aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2010-05-17 12:24:04 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2010-05-17 12:24:04 -0400
commitac1d426e825ab5778995f2f6f053ca2e6b45c622 (patch)
tree75b91356ca39463e0112931aa6790802fb1e07a2 /drivers
parentfda0e18c8a7a3e02747c2b045b4fcd2c920410b9 (diff)
parenta3685f00652af83f12b63e3b4ef48f29581ba48b (diff)
Merge branch 'devel-stable' into devel
Conflicts: arch/arm/Kconfig arch/arm/include/asm/system.h arch/arm/mm/Kconfig
Diffstat (limited to 'drivers')
-rw-r--r--drivers/Makefile2
-rw-r--r--drivers/acpi/ac.c1
-rw-r--r--drivers/acpi/acpi_memhotplug.c1
-rw-r--r--drivers/acpi/acpi_pad.c3
-rw-r--r--drivers/acpi/acpica/evgpe.c19
-rw-r--r--drivers/acpi/acpica/exprep.c17
-rw-r--r--drivers/acpi/battery.c7
-rw-r--r--drivers/acpi/bus.c3
-rw-r--r--drivers/acpi/button.c1
-rw-r--r--drivers/acpi/container.c1
-rw-r--r--drivers/acpi/debug.c1
-rw-r--r--drivers/acpi/dock.c8
-rw-r--r--drivers/acpi/ec.c36
-rw-r--r--drivers/acpi/event.c1
-rw-r--r--drivers/acpi/glue.c1
-rw-r--r--drivers/acpi/hest.c4
-rw-r--r--drivers/acpi/numa.c6
-rw-r--r--drivers/acpi/osl.c23
-rw-r--r--drivers/acpi/pci_irq.c1
-rw-r--r--drivers/acpi/pci_link.c1
-rw-r--r--drivers/acpi/pci_root.c1
-rw-r--r--drivers/acpi/pci_slot.c1
-rw-r--r--drivers/acpi/power.c1
-rw-r--r--drivers/acpi/power_meter.c3
-rw-r--r--drivers/acpi/processor_core.c1
-rw-r--r--drivers/acpi/processor_driver.c1
-rw-r--r--drivers/acpi/processor_idle.c1
-rw-r--r--drivers/acpi/processor_perflib.c1
-rw-r--r--drivers/acpi/processor_throttling.c1
-rw-r--r--drivers/acpi/sbs.c1
-rw-r--r--drivers/acpi/sbshc.c3
-rw-r--r--drivers/acpi/scan.c51
-rw-r--r--drivers/acpi/sleep.c144
-rw-r--r--drivers/acpi/system.c1
-rw-r--r--drivers/acpi/thermal.c1
-rw-r--r--drivers/acpi/utils.c1
-rw-r--r--drivers/acpi/video.c68
-rw-r--r--drivers/ata/ahci.c1
-rw-r--r--drivers/ata/ata_piix.c1
-rw-r--r--drivers/ata/libata-acpi.c1
-rw-r--r--drivers/ata/libata-core.c78
-rw-r--r--drivers/ata/libata-eh.c5
-rw-r--r--drivers/ata/libata-pmp.c1
-rw-r--r--drivers/ata/libata-scsi.c1
-rw-r--r--drivers/ata/libata-sff.c46
-rw-r--r--drivers/ata/pata_acpi.c1
-rw-r--r--drivers/ata/pata_at32.c1
-rw-r--r--drivers/ata/pata_at91.c1
-rw-r--r--drivers/ata/pata_atp867x.c1
-rw-r--r--drivers/ata/pata_cmd640.c1
-rw-r--r--drivers/ata/pata_icside.c1
-rw-r--r--drivers/ata/pata_it821x.c1
-rw-r--r--drivers/ata/pata_macio.c1
-rw-r--r--drivers/ata/pata_mpc52xx.c2
-rw-r--r--drivers/ata/pata_octeon_cf.c1
-rw-r--r--drivers/ata/pata_pcmcia.c5
-rw-r--r--drivers/ata/pata_rb532_cf.c1
-rw-r--r--drivers/ata/pata_rdc.c1
-rw-r--r--drivers/ata/pata_via.c6
-rw-r--r--drivers/ata/pdc_adma.c1
-rw-r--r--drivers/ata/sata_fsl.c1
-rw-r--r--drivers/ata/sata_inic162x.c1
-rw-r--r--drivers/ata/sata_mv.c1
-rw-r--r--drivers/ata/sata_nv.c1
-rw-r--r--drivers/ata/sata_promise.c1
-rw-r--r--drivers/ata/sata_qstor.c1
-rw-r--r--drivers/ata/sata_sil24.c1
-rw-r--r--drivers/ata/sata_sx4.c1
-rw-r--r--drivers/ata/sata_uli.c1
-rw-r--r--drivers/atm/adummy.c1
-rw-r--r--drivers/atm/ambassador.c1
-rw-r--r--drivers/atm/atmtcp.c1
-rw-r--r--drivers/atm/eni.c1
-rw-r--r--drivers/atm/firestream.c1
-rw-r--r--drivers/atm/he.c1
-rw-r--r--drivers/atm/horizon.c1
-rw-r--r--drivers/atm/idt77105.c1
-rw-r--r--drivers/atm/idt77252.c1
-rw-r--r--drivers/atm/iphase.c1
-rw-r--r--drivers/atm/lanai.c1
-rw-r--r--drivers/atm/nicstar.c1
-rw-r--r--drivers/atm/solos-pci.c1
-rw-r--r--drivers/atm/suni.c1
-rw-r--r--drivers/atm/uPD98402.c1
-rw-r--r--drivers/atm/zatm.c1
-rw-r--r--drivers/auxdisplay/cfag12864b.c1
-rw-r--r--drivers/auxdisplay/cfag12864bfb.c1
-rw-r--r--drivers/base/attribute_container.c1
-rw-r--r--drivers/base/bus.c1
-rw-r--r--drivers/base/class.c2
-rw-r--r--drivers/base/core.c6
-rw-r--r--drivers/base/cpu.c17
-rw-r--r--drivers/base/devres.c1
-rw-r--r--drivers/base/devtmpfs.c1
-rw-r--r--drivers/base/dma-coherent.c1
-rw-r--r--drivers/base/dma-mapping.c1
-rw-r--r--drivers/base/driver.c1
-rw-r--r--drivers/base/firmware_class.c3
-rw-r--r--drivers/base/memory.c3
-rw-r--r--drivers/base/module.c1
-rw-r--r--drivers/base/node.c8
-rw-r--r--drivers/base/platform.c33
-rw-r--r--drivers/base/power/main.c31
-rw-r--r--drivers/base/sys.c1
-rw-r--r--drivers/block/DAC960.c1
-rw-r--r--drivers/block/amiflop.c1
-rw-r--r--drivers/block/aoe/aoeblk.c1
-rw-r--r--drivers/block/aoe/aoechr.c1
-rw-r--r--drivers/block/aoe/aoecmd.c1
-rw-r--r--drivers/block/aoe/aoedev.c1
-rw-r--r--drivers/block/aoe/aoenet.c1
-rw-r--r--drivers/block/brd.c2
-rw-r--r--drivers/block/cciss.c1
-rw-r--r--drivers/block/drbd/drbd_actlog.c19
-rw-r--r--drivers/block/drbd/drbd_bitmap.c11
-rw-r--r--drivers/block/drbd/drbd_int.h12
-rw-r--r--drivers/block/drbd/drbd_main.c21
-rw-r--r--drivers/block/drbd/drbd_nl.c44
-rw-r--r--drivers/block/drbd/drbd_proc.c1
-rw-r--r--drivers/block/drbd/drbd_receiver.c37
-rw-r--r--drivers/block/drbd/drbd_worker.c20
-rw-r--r--drivers/block/hd.c1
-rw-r--r--drivers/block/loop.c3
-rw-r--r--drivers/block/mg_disk.c1
-rw-r--r--drivers/block/nbd.c1
-rw-r--r--drivers/block/osdblk.c1
-rw-r--r--drivers/block/paride/pcd.c4
-rw-r--r--drivers/block/paride/pd.c1
-rw-r--r--drivers/block/paride/pf.c4
-rw-r--r--drivers/block/paride/pt.c4
-rw-r--r--drivers/block/pktcdvd.c18
-rw-r--r--drivers/block/ps3disk.c1
-rw-r--r--drivers/block/ps3vram.c1
-rw-r--r--drivers/block/swim.c1
-rw-r--r--drivers/block/ub.c1
-rw-r--r--drivers/block/umem.c2
-rw-r--r--drivers/block/virtio_blk.c6
-rw-r--r--drivers/block/xd.c1
-rw-r--r--drivers/block/xen-blkfront.c1
-rw-r--r--drivers/block/z2ram.c1
-rw-r--r--drivers/bluetooth/btmrvl_debugfs.c1
-rw-r--r--drivers/bluetooth/btmrvl_drv.h1
-rw-r--r--drivers/bluetooth/btmrvl_sdio.c1
-rw-r--r--drivers/char/agp/amd-k7-agp.c2
-rw-r--r--drivers/char/agp/backend.c1
-rw-r--r--drivers/char/agp/compat_ioctl.c1
-rw-r--r--drivers/char/agp/generic.c1
-rw-r--r--drivers/char/agp/hp-agp.c1
-rw-r--r--drivers/char/agp/intel-agp.c38
-rw-r--r--drivers/char/agp/nvidia-agp.c1
-rw-r--r--drivers/char/agp/sgi-agp.c1
-rw-r--r--drivers/char/agp/uninorth-agp.c1
-rw-r--r--drivers/char/amiserial.c4
-rw-r--r--drivers/char/bfin_jtag_comm.c1
-rw-r--r--drivers/char/briq_panel.c1
-rw-r--r--drivers/char/bsr.c1
-rw-r--r--drivers/char/cyclades.c1
-rw-r--r--drivers/char/dsp56k.c1
-rw-r--r--drivers/char/epca.c1
-rw-r--r--drivers/char/generic_serial.c1
-rw-r--r--drivers/char/hpet.c1
-rw-r--r--drivers/char/hvc_console.c28
-rw-r--r--drivers/char/hvc_iucv.c1
-rw-r--r--drivers/char/hvcs.c1
-rw-r--r--drivers/char/hw_random/intel-rng.c1
-rw-r--r--drivers/char/hw_random/octeon-rng.c1
-rw-r--r--drivers/char/hw_random/tx4939-rng.c1
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c10
-rw-r--r--drivers/char/isicom.c10
-rw-r--r--drivers/char/istallion.c2
-rw-r--r--drivers/char/mbcs.c1
-rw-r--r--drivers/char/mem.c10
-rw-r--r--drivers/char/misc.c2
-rw-r--r--drivers/char/mmtimer.c1
-rw-r--r--drivers/char/moxa.c1
-rw-r--r--drivers/char/mxser.c11
-rw-r--r--drivers/char/nozomi.c1
-rw-r--r--drivers/char/nvram.c1
-rw-r--r--drivers/char/pcmcia/cm4000_cs.c8
-rw-r--r--drivers/char/pcmcia/ipwireless/network.c1
-rw-r--r--drivers/char/ppdev.c1
-rw-r--r--drivers/char/ps3flash.c1
-rw-r--r--drivers/char/pty.c1
-rw-r--r--drivers/char/raw.c2
-rw-r--r--drivers/char/rio/rioinit.c1
-rw-r--r--drivers/char/rio/riointr.c1
-rw-r--r--drivers/char/rio/rioparam.c1
-rw-r--r--drivers/char/rio/rioroute.c1
-rw-r--r--drivers/char/rio/riotty.c1
-rw-r--r--drivers/char/riscom8.c1
-rw-r--r--drivers/char/serial167.c1
-rw-r--r--drivers/char/snsc_event.c1
-rw-r--r--drivers/char/sonypi.c1
-rw-r--r--drivers/char/specialix.c1
-rw-r--r--drivers/char/stallion.c7
-rw-r--r--drivers/char/sysrq.c1
-rw-r--r--drivers/char/tpm/tpm.c1
-rw-r--r--drivers/char/tpm/tpm_bios.c1
-rw-r--r--drivers/char/tpm/tpm_nsc.c1
-rw-r--r--drivers/char/tpm/tpm_tis.c1
-rw-r--r--drivers/char/tty_audit.c1
-rw-r--r--drivers/char/tty_buffer.c4
-rw-r--r--drivers/char/tty_io.c2
-rw-r--r--drivers/char/tty_port.c2
-rw-r--r--drivers/char/viotape.c1
-rw-r--r--drivers/char/virtio_console.c81
-rw-r--r--drivers/char/vme_scc.c1
-rw-r--r--drivers/char/vt_ioctl.c39
-rw-r--r--drivers/char/xilinx_hwicap/xilinx_hwicap.c1
-rw-r--r--drivers/clocksource/sh_cmt.c1
-rw-r--r--drivers/clocksource/sh_mtu2.c1
-rw-r--r--drivers/clocksource/sh_tmu.c1
-rw-r--r--drivers/connector/cn_proc.c1
-rw-r--r--drivers/connector/connector.c1
-rw-r--r--drivers/cpufreq/cpufreq.c19
-rw-r--r--drivers/cpufreq/cpufreq_conservative.c8
-rw-r--r--drivers/cpufreq/cpufreq_stats.c1
-rw-r--r--drivers/cpuidle/governors/menu.c9
-rw-r--r--drivers/cpuidle/sysfs.c1
-rw-r--r--drivers/crypto/amcc/crypto4xx_core.c1
-rw-r--r--drivers/crypto/ixp4xx_crypto.c1
-rw-r--r--drivers/crypto/mv_cesa.c1
-rw-r--r--drivers/crypto/padlock-aes.c1
-rw-r--r--drivers/crypto/talitos.c1
-rw-r--r--drivers/dca/dca-core.c1
-rw-r--r--drivers/dca/dca-sysfs.c1
-rw-r--r--drivers/dma/at_hdmac.c1
-rw-r--r--drivers/dma/coh901318_lli.c1
-rw-r--r--drivers/dma/dmaengine.c1
-rw-r--r--drivers/dma/dmatest.c1
-rw-r--r--drivers/dma/fsldma.c1
-rw-r--r--drivers/dma/ioat/dma.c1
-rw-r--r--drivers/dma/ioat/dma_v2.c1
-rw-r--r--drivers/dma/ioat/dma_v3.c1
-rw-r--r--drivers/dma/ioat/pci.c1
-rw-r--r--drivers/dma/iop-adma.c1
-rw-r--r--drivers/dma/iovlock.c1
-rw-r--r--drivers/dma/mpc512x_dma.c1
-rw-r--r--drivers/dma/mv_xor.c1
-rw-r--r--drivers/dma/ppc4xx/adma.c1
-rw-r--r--drivers/dma/shdma.c28
-rw-r--r--drivers/dma/txx9dmac.c2
-rw-r--r--drivers/edac/amd76x_edac.c1
-rw-r--r--drivers/edac/cpc925_edac.c1
-rw-r--r--drivers/edac/e752x_edac.c1
-rw-r--r--drivers/edac/e7xxx_edac.c1
-rw-r--r--drivers/edac/edac_device_sysfs.c1
-rw-r--r--drivers/edac/edac_mc_sysfs.c1
-rw-r--r--drivers/edac/edac_mce_amd.c12
-rw-r--r--drivers/edac/edac_pci_sysfs.c1
-rw-r--r--drivers/edac/i3000_edac.c1
-rw-r--r--drivers/edac/i3200_edac.c1
-rw-r--r--drivers/edac/i5100_edac.c1
-rw-r--r--drivers/edac/i82443bxgx_edac.c1
-rw-r--r--drivers/edac/i82860_edac.c1
-rw-r--r--drivers/edac/i82875p_edac.c1
-rw-r--r--drivers/edac/i82975x_edac.c1
-rw-r--r--drivers/edac/mpc85xx_edac.c2
-rw-r--r--drivers/edac/mv64x60_edac.c2
-rw-r--r--drivers/edac/pasemi_edac.c1
-rw-r--r--drivers/edac/r82600_edac.c1
-rw-r--r--drivers/edac/x38_edac.c1
-rw-r--r--drivers/firewire/core-cdev.c24
-rw-r--r--drivers/firewire/core-device.c104
-rw-r--r--drivers/firewire/core-iso.c20
-rw-r--r--drivers/firewire/net.c1
-rw-r--r--drivers/firewire/ohci.c29
-rw-r--r--drivers/firmware/dcdbas.c1
-rw-r--r--drivers/firmware/dell_rbu.c1
-rw-r--r--drivers/firmware/dmi-id.c1
-rw-r--r--drivers/firmware/dmi_scan.c1
-rw-r--r--drivers/firmware/efivars.c1
-rw-r--r--drivers/firmware/iscsi_ibft_find.c12
-rw-r--r--drivers/firmware/memmap.c1
-rw-r--r--drivers/gpio/adp5520-gpio.c1
-rw-r--r--drivers/gpio/adp5588-gpio.c1
-rw-r--r--drivers/gpio/bt8xxgpio.c1
-rw-r--r--drivers/gpio/gpiolib.c4
-rw-r--r--drivers/gpio/langwell_gpio.c1
-rw-r--r--drivers/gpio/max7300.c1
-rw-r--r--drivers/gpio/max7301.c1
-rw-r--r--drivers/gpio/max730x.c5
-rw-r--r--drivers/gpio/mc33880.c1
-rw-r--r--drivers/gpio/mcp23s08.c1
-rw-r--r--drivers/gpio/pca953x.c15
-rw-r--r--drivers/gpio/pl061.c15
-rw-r--r--drivers/gpio/timbgpio.c13
-rw-r--r--drivers/gpio/twl4030-gpio.c1
-rw-r--r--drivers/gpio/wm831x-gpio.c1
-rw-r--r--drivers/gpio/wm8350-gpiolib.c1
-rw-r--r--drivers/gpio/wm8994-gpio.c1
-rw-r--r--drivers/gpio/xilinx_gpio.c1
-rw-r--r--drivers/gpu/drm/drm_agpsupport.c1
-rw-r--r--drivers/gpu/drm/drm_bufs.c1
-rw-r--r--drivers/gpu/drm/drm_crtc.c1
-rw-r--r--drivers/gpu/drm/drm_crtc_helper.c1
-rw-r--r--drivers/gpu/drm/drm_debugfs.c1
-rw-r--r--drivers/gpu/drm/drm_dp_i2c_helper.c1
-rw-r--r--drivers/gpu/drm/drm_drv.c1
-rw-r--r--drivers/gpu/drm/drm_edid.c12
-rw-r--r--drivers/gpu/drm/drm_fb_helper.c3
-rw-r--r--drivers/gpu/drm/drm_fops.c17
-rw-r--r--drivers/gpu/drm/drm_hashtab.c1
-rw-r--r--drivers/gpu/drm/drm_irq.c2
-rw-r--r--drivers/gpu/drm/drm_memory.c2
-rw-r--r--drivers/gpu/drm/drm_pci.c1
-rw-r--r--drivers/gpu/drm/drm_proc.c1
-rw-r--r--drivers/gpu/drm/drm_scatter.c1
-rw-r--r--drivers/gpu/drm/drm_stub.c5
-rw-r--r--drivers/gpu/drm/drm_sysfs.c22
-rw-r--r--drivers/gpu/drm/drm_vm.c1
-rw-r--r--drivers/gpu/drm/i810/i810_dma.c1
-rw-r--r--drivers/gpu/drm/i830/i830_dma.c1
-rw-r--r--drivers/gpu/drm/i915/i915_debugfs.c3
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c61
-rw-r--r--drivers/gpu/drm/i915/i915_drv.c15
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h18
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c315
-rw-r--r--drivers/gpu/drm/i915/i915_gem_debug.c4
-rw-r--r--drivers/gpu/drm/i915/i915_gem_tiling.c39
-rw-r--r--drivers/gpu/drm/i915/i915_irq.c17
-rw-r--r--drivers/gpu/drm/i915/i915_opregion.c54
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h27
-rw-r--r--drivers/gpu/drm/i915/intel_bios.c5
-rw-r--r--drivers/gpu/drm/i915/intel_crt.c69
-rw-r--r--drivers/gpu/drm/i915/intel_display.c124
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c257
-rw-r--r--drivers/gpu/drm/i915/intel_drv.h18
-rw-r--r--drivers/gpu/drm/i915/intel_dvo.c93
-rw-r--r--drivers/gpu/drm/i915/intel_fb.c3
-rw-r--r--drivers/gpu/drm/i915/intel_hdmi.c87
-rw-r--r--drivers/gpu/drm/i915/intel_i2c.c1
-rw-r--r--drivers/gpu/drm/i915/intel_lvds.c134
-rw-r--r--drivers/gpu/drm/i915/intel_modes.c23
-rw-r--r--drivers/gpu/drm/i915/intel_overlay.c19
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo.c732
-rw-r--r--drivers/gpu/drm/i915/intel_tv.c96
-rw-r--r--drivers/gpu/drm/nouveau/Makefile4
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_acpi.c1
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bios.c155
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bios.h7
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bo.c67
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_channel.c2
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_connector.c2
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_debugfs.c5
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_dma.c5
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_dp.c8
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drv.c10
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drv.h46
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_encoder.h1
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_fbcon.c1
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_gem.c55
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_grctx.c1
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_irq.c610
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_mem.c124
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_sgdma.c19
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_state.c20
-rw-r--r--drivers/gpu/drm/nouveau/nv04_crtc.c6
-rw-r--r--drivers/gpu/drm/nouveau/nv04_fbcon.c6
-rw-r--r--drivers/gpu/drm/nouveau/nv40_fifo.c2
-rw-r--r--drivers/gpu/drm/nouveau/nv40_graph.c21
-rw-r--r--drivers/gpu/drm/nouveau/nv50_display.c26
-rw-r--r--drivers/gpu/drm/nouveau/nv50_display.h1
-rw-r--r--drivers/gpu/drm/nouveau/nv50_fb.c32
-rw-r--r--drivers/gpu/drm/nouveau/nv50_fbcon.c15
-rw-r--r--drivers/gpu/drm/nouveau/nv50_gpio.c76
-rw-r--r--drivers/gpu/drm/nouveau/nv50_graph.c29
-rw-r--r--drivers/gpu/drm/nouveau/nv50_grctx.c32
-rw-r--r--drivers/gpu/drm/nouveau/nv50_instmem.c16
-rw-r--r--drivers/gpu/drm/nouveau/nv50_sor.c25
-rw-r--r--drivers/gpu/drm/r128/r128_cce.c1
-rw-r--r--drivers/gpu/drm/radeon/Makefile2
-rw-r--r--drivers/gpu/drm/radeon/atom.c105
-rw-r--r--drivers/gpu/drm/radeon/atom.h8
-rw-r--r--drivers/gpu/drm/radeon/atombios.h2
-rw-r--r--drivers/gpu/drm/radeon/atombios_crtc.c100
-rw-r--r--drivers/gpu/drm/radeon/atombios_dp.c6
-rw-r--r--drivers/gpu/drm/radeon/evergreen.c12
-rw-r--r--drivers/gpu/drm/radeon/r100.c49
-rw-r--r--drivers/gpu/drm/radeon/r100_track.h3
-rw-r--r--drivers/gpu/drm/radeon/r200.c1
-rw-r--r--drivers/gpu/drm/radeon/r300.c29
-rw-r--r--drivers/gpu/drm/radeon/r300_cmdbuf.c2
-rw-r--r--drivers/gpu/drm/radeon/r420.c9
-rw-r--r--drivers/gpu/drm/radeon/r520.c9
-rw-r--r--drivers/gpu/drm/radeon/r600.c31
-rw-r--r--drivers/gpu/drm/radeon/r600_audio.c54
-rw-r--r--drivers/gpu/drm/radeon/r600_blit_shaders.c35
-rw-r--r--drivers/gpu/drm/radeon/r600_cp.c3
-rw-r--r--drivers/gpu/drm/radeon/r600_cs.c70
-rw-r--r--drivers/gpu/drm/radeon/r600_hdmi.c200
-rw-r--r--drivers/gpu/drm/radeon/r600_reg.h10
-rw-r--r--drivers/gpu/drm/radeon/r600d.h49
-rw-r--r--drivers/gpu/drm/radeon/radeon.h66
-rw-r--r--drivers/gpu/drm/radeon/radeon_agp.c10
-rw-r--r--drivers/gpu/drm/radeon/radeon_asic.c772
-rw-r--r--drivers/gpu/drm/radeon/radeon_asic.h545
-rw-r--r--drivers/gpu/drm/radeon/radeon_atombios.c472
-rw-r--r--drivers/gpu/drm/radeon/radeon_atpx_handler.c1
-rw-r--r--drivers/gpu/drm/radeon/radeon_bios.c1
-rw-r--r--drivers/gpu/drm/radeon/radeon_combios.c27
-rw-r--r--drivers/gpu/drm/radeon/radeon_connectors.c19
-rw-r--r--drivers/gpu/drm/radeon/radeon_cp.c17
-rw-r--r--drivers/gpu/drm/radeon/radeon_cs.c11
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c291
-rw-r--r--drivers/gpu/drm/radeon/radeon_display.c76
-rw-r--r--drivers/gpu/drm/radeon/radeon_drv.c14
-rw-r--r--drivers/gpu/drm/radeon/radeon_drv.h3
-rw-r--r--drivers/gpu/drm/radeon/radeon_encoders.c217
-rw-r--r--drivers/gpu/drm/radeon/radeon_family.h3
-rw-r--r--drivers/gpu/drm/radeon/radeon_fb.c1
-rw-r--r--drivers/gpu/drm/radeon/radeon_fence.c1
-rw-r--r--drivers/gpu/drm/radeon/radeon_i2c.c153
-rw-r--r--drivers/gpu/drm/radeon/radeon_irq_kms.c22
-rw-r--r--drivers/gpu/drm/radeon/radeon_kms.c7
-rw-r--r--drivers/gpu/drm/radeon/radeon_legacy_crtc.c8
-rw-r--r--drivers/gpu/drm/radeon/radeon_legacy_encoders.c70
-rw-r--r--drivers/gpu/drm/radeon/radeon_legacy_tv.c29
-rw-r--r--drivers/gpu/drm/radeon/radeon_mode.h14
-rw-r--r--drivers/gpu/drm/radeon/radeon_object.c7
-rw-r--r--drivers/gpu/drm/radeon/radeon_pm.c46
-rw-r--r--drivers/gpu/drm/radeon/radeon_reg.h1
-rw-r--r--drivers/gpu/drm/radeon/radeon_ring.c1
-rw-r--r--drivers/gpu/drm/radeon/radeon_ttm.c1
-rw-r--r--drivers/gpu/drm/radeon/reg_srcs/r3002
-rw-r--r--drivers/gpu/drm/radeon/reg_srcs/r4202
-rw-r--r--drivers/gpu/drm/radeon/reg_srcs/r60075
-rw-r--r--drivers/gpu/drm/radeon/reg_srcs/rs6002
-rw-r--r--drivers/gpu/drm/radeon/reg_srcs/rv5153
-rw-r--r--drivers/gpu/drm/radeon/rs400.c8
-rw-r--r--drivers/gpu/drm/radeon/rs600.c35
-rw-r--r--drivers/gpu/drm/radeon/rs600d.h53
-rw-r--r--drivers/gpu/drm/radeon/rs690.c122
-rw-r--r--drivers/gpu/drm/radeon/rs690d.h3
-rw-r--r--drivers/gpu/drm/radeon/rv515.c46
-rw-r--r--drivers/gpu/drm/radeon/rv770.c32
-rw-r--r--drivers/gpu/drm/ttm/ttm_agp_backend.c1
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo.c34
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo_util.c1
-rw-r--r--drivers/gpu/drm/ttm/ttm_lock.c5
-rw-r--r--drivers/gpu/drm/ttm/ttm_memory.c19
-rw-r--r--drivers/gpu/drm/ttm/ttm_tt.c24
-rw-r--r--drivers/gpu/drm/via/via_dmablit.c1
-rw-r--r--drivers/gpu/drm/via/via_video.c2
-rw-r--r--drivers/gpu/drm/vmwgfx/Kconfig2
-rw-r--r--drivers/gpu/vga/vga_switcheroo.c6
-rw-r--r--drivers/gpu/vga/vgaarb.c1
-rw-r--r--drivers/hid/hid-3m-pct.c1
-rw-r--r--drivers/hid/hid-a4tech.c1
-rw-r--r--drivers/hid/hid-apple.c1
-rw-r--r--drivers/hid/hid-debug.c1
-rw-r--r--drivers/hid/hid-drff.c1
-rw-r--r--drivers/hid/hid-gaff.c1
-rw-r--r--drivers/hid/hid-gyration.c5
-rw-r--r--drivers/hid/hid-lg2ff.c1
-rw-r--r--drivers/hid/hid-magicmouse.c1
-rw-r--r--drivers/hid/hid-mosart.c1
-rw-r--r--drivers/hid/hid-ntrig.c1
-rw-r--r--drivers/hid/hid-pl.c1
-rw-r--r--drivers/hid/hid-quanta.c1
-rw-r--r--drivers/hid/hid-sjoy.c1
-rw-r--r--drivers/hid/hid-sony.c1
-rw-r--r--drivers/hid/hid-stantum.c1
-rw-r--r--drivers/hid/hid-tmff.c1
-rw-r--r--drivers/hid/hid-wacom.c1
-rw-r--r--drivers/hid/hid-zpff.c1
-rw-r--r--drivers/hid/hidraw.c1
-rw-r--r--drivers/hid/usbhid/hid-pidff.c1
-rw-r--r--drivers/hid/usbhid/hid-quirks.c2
-rw-r--r--drivers/hwmon/Kconfig4
-rw-r--r--drivers/hwmon/ad7414.c1
-rw-r--r--drivers/hwmon/ad7418.c1
-rw-r--r--drivers/hwmon/adcxx.c1
-rw-r--r--drivers/hwmon/adt7411.c1
-rw-r--r--drivers/hwmon/adt7462.c1
-rw-r--r--drivers/hwmon/adt7470.c1
-rw-r--r--drivers/hwmon/applesmc.c18
-rw-r--r--drivers/hwmon/asus_atk0110.c5
-rw-r--r--drivers/hwmon/atxp1.c1
-rw-r--r--drivers/hwmon/coretemp.c4
-rw-r--r--drivers/hwmon/f75375s.c1
-rw-r--r--drivers/hwmon/hp_accel.c4
-rw-r--r--drivers/hwmon/i5k_amb.c1
-rw-r--r--drivers/hwmon/ibmaem.c1
-rw-r--r--drivers/hwmon/ibmpex.c1
-rw-r--r--drivers/hwmon/it87.c32
-rw-r--r--drivers/hwmon/lm70.c1
-rw-r--r--drivers/hwmon/lm73.c1
-rw-r--r--drivers/hwmon/max1111.c1
-rw-r--r--drivers/hwmon/mc13783-adc.c1
-rw-r--r--drivers/hwmon/sht15.c14
-rw-r--r--drivers/hwmon/w83793.c2
-rw-r--r--drivers/hwmon/wm831x-hwmon.c1
-rw-r--r--drivers/i2c/algos/i2c-algo-bit.c1
-rw-r--r--drivers/i2c/algos/i2c-algo-pcf.c1
-rw-r--r--drivers/i2c/busses/i2c-amd8111.c1
-rw-r--r--drivers/i2c/busses/i2c-bfin-twi.c1
-rw-r--r--drivers/i2c/busses/i2c-davinci.c1
-rw-r--r--drivers/i2c/busses/i2c-designware.c1
-rw-r--r--drivers/i2c/busses/i2c-elektor.c1
-rw-r--r--drivers/i2c/busses/i2c-gpio.c1
-rw-r--r--drivers/i2c/busses/i2c-highlander.c1
-rw-r--r--drivers/i2c/busses/i2c-imx.c7
-rw-r--r--drivers/i2c/busses/i2c-ixp2000.c1
-rw-r--r--drivers/i2c/busses/i2c-mpc.c1
-rw-r--r--drivers/i2c/busses/i2c-mv64xxx.c1
-rw-r--r--drivers/i2c/busses/i2c-nforce2.c1
-rw-r--r--drivers/i2c/busses/i2c-nomadik.c1
-rw-r--r--drivers/i2c/busses/i2c-ocores.c1
-rw-r--r--drivers/i2c/busses/i2c-octeon.c5
-rw-r--r--drivers/i2c/busses/i2c-omap.c11
-rw-r--r--drivers/i2c/busses/i2c-parport.c1
-rw-r--r--drivers/i2c/busses/i2c-pasemi.c1
-rw-r--r--drivers/i2c/busses/i2c-pnx.c9
-rw-r--r--drivers/i2c/busses/i2c-pxa.c1
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c1
-rw-r--r--drivers/i2c/busses/i2c-scmi.c32
-rw-r--r--drivers/i2c/busses/i2c-sh_mobile.c1
-rw-r--r--drivers/i2c/busses/i2c-simtec.c1
-rw-r--r--drivers/i2c/busses/i2c-stu300.c3
-rw-r--r--drivers/i2c/busses/i2c-tiny-usb.c1
-rw-r--r--drivers/i2c/busses/i2c-versatile.c1
-rw-r--r--drivers/i2c/busses/i2c-xiic.c1
-rw-r--r--drivers/i2c/busses/scx200_acb.c1
-rw-r--r--drivers/i2c/i2c-boardinfo.c1
-rw-r--r--drivers/i2c/i2c-core.c63
-rw-r--r--drivers/i2c/i2c-smbus.c1
-rw-r--r--drivers/ide/hpt366.c1
-rw-r--r--drivers/ide/ide-acpi.c1
-rw-r--r--drivers/ide/ide-atapi.c3
-rw-r--r--drivers/ide/ide-cd_ioctl.c1
-rw-r--r--drivers/ide/ide-cs.c4
-rw-r--r--drivers/ide/ide-devsets.c1
-rw-r--r--drivers/ide/ide-disk_proc.c1
-rw-r--r--drivers/ide/ide-dma.c2
-rw-r--r--drivers/ide/ide-floppy.c1
-rw-r--r--drivers/ide/ide-gd.c1
-rw-r--r--drivers/ide/ide-io.c2
-rw-r--r--drivers/ide/ide-ioctls.c1
-rw-r--r--drivers/ide/ide-park.c1
-rw-r--r--drivers/ide/ide-pm.c1
-rw-r--r--drivers/ide/ide-probe.c12
-rw-r--r--drivers/ide/ide-proc.c1
-rw-r--r--drivers/ide/ide-taskfile.c6
-rw-r--r--drivers/ide/ide.c1
-rw-r--r--drivers/ide/it821x.c1
-rw-r--r--drivers/ide/pmac.c1
-rw-r--r--drivers/ide/rapide.c1
-rw-r--r--drivers/ide/sc1200.c1
-rw-r--r--drivers/ide/via82cxxx.c58
-rw-r--r--drivers/idle/i7300_idle.c1
-rw-r--r--drivers/ieee1394/dma.c1
-rw-r--r--drivers/ieee1394/sbp2.c1
-rw-r--r--drivers/infiniband/core/addr.c1
-rw-r--r--drivers/infiniband/core/cm.c3
-rw-r--r--drivers/infiniband/core/cma.c2
-rw-r--r--drivers/infiniband/core/iwcm.c1
-rw-r--r--drivers/infiniband/core/mad.c1
-rw-r--r--drivers/infiniband/core/mad_rmpp.c2
-rw-r--r--drivers/infiniband/core/multicast.c1
-rw-r--r--drivers/infiniband/core/sysfs.c1
-rw-r--r--drivers/infiniband/core/ucm.c1
-rw-r--r--drivers/infiniband/core/ucma.c1
-rw-r--r--drivers/infiniband/core/umem.c1
-rw-r--r--drivers/infiniband/core/user_mad.c1
-rw-r--r--drivers/infiniband/core/uverbs_cmd.c1
-rw-r--r--drivers/infiniband/core/uverbs_main.c1
-rw-r--r--drivers/infiniband/hw/amso1100/c2.c1
-rw-r--r--drivers/infiniband/hw/amso1100/c2_alloc.c1
-rw-r--r--drivers/infiniband/hw/amso1100/c2_cm.c2
-rw-r--r--drivers/infiniband/hw/amso1100/c2_cq.c2
-rw-r--r--drivers/infiniband/hw/amso1100/c2_mm.c2
-rw-r--r--drivers/infiniband/hw/amso1100/c2_pd.c1
-rw-r--r--drivers/infiniband/hw/amso1100/c2_provider.c1
-rw-r--r--drivers/infiniband/hw/amso1100/c2_qp.c1
-rw-r--r--drivers/infiniband/hw/amso1100/c2_rnic.c1
-rw-r--r--drivers/infiniband/hw/cxgb3/cxio_dbg.c1
-rw-r--r--drivers/infiniband/hw/cxgb3/cxio_hal.c1
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_cm.c1
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_ev.c2
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_mem.c1
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_provider.c1
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_qp.c1
-rw-r--r--drivers/infiniband/hw/ehca/ehca_av.c2
-rw-r--r--drivers/infiniband/hw/ehca/ehca_cq.c2
-rw-r--r--drivers/infiniband/hw/ehca/ehca_hca.c2
-rw-r--r--drivers/infiniband/hw/ehca/ehca_irq.c2
-rw-r--r--drivers/infiniband/hw/ehca/ehca_mrmw.c1
-rw-r--r--drivers/infiniband/hw/ehca/ehca_pd.c2
-rw-r--r--drivers/infiniband/hw/ehca/ehca_qp.c2
-rw-r--r--drivers/infiniband/hw/ehca/ehca_uverbs.c2
-rw-r--r--drivers/infiniband/hw/ehca/ipz_pt_fn.c2
-rw-r--r--drivers/infiniband/hw/ipath/ipath_cq.c1
-rw-r--r--drivers/infiniband/hw/ipath/ipath_dma.c1
-rw-r--r--drivers/infiniband/hw/ipath/ipath_driver.c1
-rw-r--r--drivers/infiniband/hw/ipath/ipath_file_ops.c1
-rw-r--r--drivers/infiniband/hw/ipath/ipath_fs.c1
-rw-r--r--drivers/infiniband/hw/ipath/ipath_init_chip.c1
-rw-r--r--drivers/infiniband/hw/ipath/ipath_mmap.c1
-rw-r--r--drivers/infiniband/hw/ipath/ipath_mr.c2
-rw-r--r--drivers/infiniband/hw/ipath/ipath_qp.c1
-rw-r--r--drivers/infiniband/hw/ipath/ipath_sdma.c1
-rw-r--r--drivers/infiniband/hw/ipath/ipath_srq.c1
-rw-r--r--drivers/infiniband/hw/ipath/ipath_user_pages.c1
-rw-r--r--drivers/infiniband/hw/ipath/ipath_verbs.c1
-rw-r--r--drivers/infiniband/hw/ipath/ipath_verbs_mcast.c1
-rw-r--r--drivers/infiniband/hw/mlx4/ah.c2
-rw-r--r--drivers/infiniband/hw/mlx4/cq.c1
-rw-r--r--drivers/infiniband/hw/mlx4/mad.c1
-rw-r--r--drivers/infiniband/hw/mlx4/main.c1
-rw-r--r--drivers/infiniband/hw/mlx4/mr.c4
-rw-r--r--drivers/infiniband/hw/mlx4/qp.c1
-rw-r--r--drivers/infiniband/hw/mlx4/srq.c1
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cmd.c1
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cq.c1
-rw-r--r--drivers/infiniband/hw/mthca/mthca_eq.c1
-rw-r--r--drivers/infiniband/hw/mthca/mthca_main.c1
-rw-r--r--drivers/infiniband/hw/mthca/mthca_mcg.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_memfree.c1
-rw-r--r--drivers/infiniband/hw/mthca/mthca_provider.c1
-rw-r--r--drivers/infiniband/hw/nes/nes.c1
-rw-r--r--drivers/infiniband/hw/nes/nes_cm.c1
-rw-r--r--drivers/infiniband/hw/nes/nes_hw.c1
-rw-r--r--drivers/infiniband/hw/nes/nes_nic.c1
-rw-r--r--drivers/infiniband/hw/nes/nes_utils.c1
-rw-r--r--drivers/infiniband/hw/nes/nes_verbs.c10
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_cm.c1
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_fs.c1
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_ib.c1
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_multicast.c1
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_verbs.c2
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_vlan.c1
-rw-r--r--drivers/infiniband/ulp/iser/iscsi_iser.c1
-rw-r--r--drivers/infiniband/ulp/iser/iser_verbs.c1
-rw-r--r--drivers/input/ff-core.c1
-rw-r--r--drivers/input/ff-memless.c1
-rw-r--r--drivers/input/gameport/lightning.c1
-rw-r--r--drivers/input/input-polldev.c1
-rw-r--r--drivers/input/input.c10
-rw-r--r--drivers/input/joydev.c18
-rw-r--r--drivers/input/joystick/db9.c1
-rw-r--r--drivers/input/joystick/gamecon.c1
-rw-r--r--drivers/input/joystick/turbografx.c1
-rw-r--r--drivers/input/keyboard/Kconfig48
-rw-r--r--drivers/input/keyboard/Makefile3
-rw-r--r--drivers/input/keyboard/adp5520-keys.c1
-rw-r--r--drivers/input/keyboard/adp5588-keys.c1
-rw-r--r--drivers/input/keyboard/bf54x-keys.c1
-rw-r--r--drivers/input/keyboard/corgikbd.c414
-rw-r--r--drivers/input/keyboard/davinci_keyscan.c1
-rw-r--r--drivers/input/keyboard/ep93xx_keypad.c1
-rw-r--r--drivers/input/keyboard/gpio_keys.c1
-rw-r--r--drivers/input/keyboard/imx_keypad.c1
-rw-r--r--drivers/input/keyboard/jornada680_kbd.c1
-rw-r--r--drivers/input/keyboard/jornada720_kbd.c1
-rw-r--r--drivers/input/keyboard/lm8323.c1
-rw-r--r--drivers/input/keyboard/matrix_keypad.c5
-rw-r--r--drivers/input/keyboard/max7359_keypad.c1
-rw-r--r--drivers/input/keyboard/omap-keypad.c1
-rw-r--r--drivers/input/keyboard/opencores-kbd.c1
-rw-r--r--drivers/input/keyboard/pxa27x_keypad.c1
-rw-r--r--drivers/input/keyboard/pxa930_rotary.c1
-rw-r--r--drivers/input/keyboard/sh_keysc.c1
-rw-r--r--drivers/input/keyboard/spitzkbd.c496
-rw-r--r--drivers/input/keyboard/tosakbd.c430
-rw-r--r--drivers/input/keyboard/twl4030_keypad.c1
-rw-r--r--drivers/input/keyboard/w90p910_keypad.c1
-rw-r--r--drivers/input/misc/88pm860x_onkey.c1
-rw-r--r--drivers/input/misc/ati_remote.c14
-rw-r--r--drivers/input/misc/ati_remote2.c1
-rw-r--r--drivers/input/misc/bfin_rotary.c1
-rw-r--r--drivers/input/misc/cobalt_btns.c1
-rw-r--r--drivers/input/misc/dm355evm_keys.c1
-rw-r--r--drivers/input/misc/pcap_keys.c1
-rw-r--r--drivers/input/misc/pcf50633-input.c1
-rw-r--r--drivers/input/misc/rotary_encoder.c1
-rw-r--r--drivers/input/misc/sgi_btns.c1
-rw-r--r--drivers/input/misc/sparcspkr.c1
-rw-r--r--drivers/input/misc/twl4030-vibra.c1
-rw-r--r--drivers/input/misc/winbond-cir.c1
-rw-r--r--drivers/input/misc/wistron_btns.c1
-rw-r--r--drivers/input/misc/wm831x-on.c1
-rw-r--r--drivers/input/mouse/alps.c1
-rw-r--r--drivers/input/mouse/bcm5974.c1
-rw-r--r--drivers/input/mouse/elantech.c85
-rw-r--r--drivers/input/mouse/hgpk.c1
-rw-r--r--drivers/input/mouse/lifebook.c1
-rw-r--r--drivers/input/mouse/psmouse-base.c18
-rw-r--r--drivers/input/mouse/psmouse.h1
-rw-r--r--drivers/input/mouse/pxa930_trkball.c1
-rw-r--r--drivers/input/mouse/sentelic.c1
-rw-r--r--drivers/input/mouse/synaptics.c36
-rw-r--r--drivers/input/mouse/synaptics.h4
-rw-r--r--drivers/input/mouse/synaptics_i2c.c1
-rw-r--r--drivers/input/mouse/touchkit_ps2.c1
-rw-r--r--drivers/input/mouse/trackpoint.c1
-rw-r--r--drivers/input/serio/altera_ps2.c1
-rw-r--r--drivers/input/serio/at32psif.c1
-rw-r--r--drivers/input/serio/ct82c710.c1
-rw-r--r--drivers/input/serio/gscps2.c1
-rw-r--r--drivers/input/serio/hil_mlc.c1
-rw-r--r--drivers/input/serio/i8042.c3
-rw-r--r--drivers/input/serio/libps2.c1
-rw-r--r--drivers/input/serio/parkbd.c1
-rw-r--r--drivers/input/serio/pcips2.c1
-rw-r--r--drivers/input/serio/q40kbd.c1
-rw-r--r--drivers/input/serio/rpckbd.c1
-rw-r--r--drivers/input/serio/xilinx_ps2.c1
-rw-r--r--drivers/input/sparse-keymap.c53
-rw-r--r--drivers/input/tablet/wacom_sys.c12
-rw-r--r--drivers/input/tablet/wacom_wac.c163
-rw-r--r--drivers/input/touchscreen/88pm860x-ts.c1
-rw-r--r--drivers/input/touchscreen/Kconfig16
-rw-r--r--drivers/input/touchscreen/Makefile1
-rw-r--r--drivers/input/touchscreen/atmel-wm97xx.c1
-rw-r--r--drivers/input/touchscreen/corgi_ts.c385
-rw-r--r--drivers/input/touchscreen/da9034-ts.c1
-rw-r--r--drivers/input/touchscreen/eeti_ts.c57
-rw-r--r--drivers/input/touchscreen/jornada720_ts.c1
-rw-r--r--drivers/input/touchscreen/mc13783_ts.c1
-rw-r--r--drivers/input/touchscreen/mcs5000_ts.c1
-rw-r--r--drivers/input/touchscreen/migor_ts.c1
-rw-r--r--drivers/input/touchscreen/pcap_ts.c1
-rw-r--r--drivers/input/touchscreen/s3c2410_ts.c1
-rw-r--r--drivers/input/touchscreen/ucb1400_ts.c1
-rw-r--r--drivers/input/touchscreen/w90p910_ts.c1
-rw-r--r--drivers/input/touchscreen/wm97xx-core.c1
-rw-r--r--drivers/input/xen-kbdfront.c1
-rw-r--r--drivers/isdn/act2000/module.c1
-rw-r--r--drivers/isdn/capi/capifs.c1
-rw-r--r--drivers/isdn/capi/capilib.c1
-rw-r--r--drivers/isdn/capi/capiutil.c1
-rw-r--r--drivers/isdn/capi/kcapi.c1
-rw-r--r--drivers/isdn/divert/divert_procfs.c1
-rw-r--r--drivers/isdn/divert/isdn_divert.c1
-rw-r--r--drivers/isdn/gigaset/bas-gigaset.c5
-rw-r--r--drivers/isdn/gigaset/capi.c1
-rw-r--r--drivers/isdn/gigaset/common.c1
-rw-r--r--drivers/isdn/gigaset/gigaset.h4
-rw-r--r--drivers/isdn/gigaset/interface.c1
-rw-r--r--drivers/isdn/gigaset/proc.c1
-rw-r--r--drivers/isdn/gigaset/ser-gigaset.c2
-rw-r--r--drivers/isdn/gigaset/usb-gigaset.c4
-rw-r--r--drivers/isdn/hardware/avm/b1.c1
-rw-r--r--drivers/isdn/hardware/avm/b1dma.c1
-rw-r--r--drivers/isdn/hardware/avm/c4.c1
-rw-r--r--drivers/isdn/hardware/avm/t1isa.c1
-rw-r--r--drivers/isdn/hardware/eicon/capimain.c1
-rw-r--r--drivers/isdn/hardware/mISDN/avmfritz.c1
-rw-r--r--drivers/isdn/hardware/mISDN/hfcmulti.c1
-rw-r--r--drivers/isdn/hardware/mISDN/hfcpci.c1
-rw-r--r--drivers/isdn/hardware/mISDN/hfcsusb.c1
-rw-r--r--drivers/isdn/hardware/mISDN/mISDNinfineon.c1
-rw-r--r--drivers/isdn/hardware/mISDN/mISDNipac.c1
-rw-r--r--drivers/isdn/hardware/mISDN/mISDNisar.c1
-rw-r--r--drivers/isdn/hardware/mISDN/netjet.c1
-rw-r--r--drivers/isdn/hardware/mISDN/speedfax.c1
-rw-r--r--drivers/isdn/hardware/mISDN/w6692.c1
-rw-r--r--drivers/isdn/hisax/amd7930_fn.c1
-rw-r--r--drivers/isdn/hisax/avm_pci.c1
-rw-r--r--drivers/isdn/hisax/avma1_cs.c12
-rw-r--r--drivers/isdn/hisax/callc.c1
-rw-r--r--drivers/isdn/hisax/config.c1
-rw-r--r--drivers/isdn/hisax/elsa.c1
-rw-r--r--drivers/isdn/hisax/elsa_cs.c12
-rw-r--r--drivers/isdn/hisax/elsa_ser.c1
-rw-r--r--drivers/isdn/hisax/fsm.c1
-rw-r--r--drivers/isdn/hisax/hfc4s8s_l1.c1
-rw-r--r--drivers/isdn/hisax/hfc_2bds0.c1
-rw-r--r--drivers/isdn/hisax/hfc_2bs0.c1
-rw-r--r--drivers/isdn/hisax/hfc_sx.c1
-rw-r--r--drivers/isdn/hisax/hfc_usb.c1
-rw-r--r--drivers/isdn/hisax/hisax_isac.c1
-rw-r--r--drivers/isdn/hisax/hscx.c1
-rw-r--r--drivers/isdn/hisax/icc.c1
-rw-r--r--drivers/isdn/hisax/ipacx.c1
-rw-r--r--drivers/isdn/hisax/isac.c1
-rw-r--r--drivers/isdn/hisax/isar.c1
-rw-r--r--drivers/isdn/hisax/isdnl1.c1
-rw-r--r--drivers/isdn/hisax/isdnl2.c1
-rw-r--r--drivers/isdn/hisax/isdnl3.c1
-rw-r--r--drivers/isdn/hisax/jade.c1
-rw-r--r--drivers/isdn/hisax/l3dss1.c1
-rw-r--r--drivers/isdn/hisax/l3ni1.c1
-rw-r--r--drivers/isdn/hisax/netjet.c1
-rw-r--r--drivers/isdn/hisax/sedlbauer_cs.c12
-rw-r--r--drivers/isdn/hisax/st5481_b.c2
-rw-r--r--drivers/isdn/hisax/st5481_d.c2
-rw-r--r--drivers/isdn/hisax/tei.c1
-rw-r--r--drivers/isdn/hisax/teles_cs.c12
-rw-r--r--drivers/isdn/hisax/w6692.c1
-rw-r--r--drivers/isdn/hysdn/hycapi.c1
-rw-r--r--drivers/isdn/hysdn/hysdn_procconf.c1
-rw-r--r--drivers/isdn/hysdn/hysdn_proclog.c1
-rw-r--r--drivers/isdn/i4l/isdn_audio.c1
-rw-r--r--drivers/isdn/i4l/isdn_common.c1
-rw-r--r--drivers/isdn/i4l/isdn_net.c1
-rw-r--r--drivers/isdn/i4l/isdn_ppp.c1
-rw-r--r--drivers/isdn/i4l/isdn_tty.c1
-rw-r--r--drivers/isdn/i4l/isdn_x25iface.c1
-rw-r--r--drivers/isdn/icn/icn.c1
-rw-r--r--drivers/isdn/isdnloop/isdnloop.c1
-rw-r--r--drivers/isdn/mISDN/clock.c1
-rw-r--r--drivers/isdn/mISDN/core.c1
-rw-r--r--drivers/isdn/mISDN/dsp_cmx.c1
-rw-r--r--drivers/isdn/mISDN/dsp_core.c1
-rw-r--r--drivers/isdn/mISDN/dsp_pipeline.c1
-rw-r--r--drivers/isdn/mISDN/dsp_tones.c1
-rw-r--r--drivers/isdn/mISDN/hwchannel.c1
-rw-r--r--drivers/isdn/mISDN/l1oip_core.c1
-rw-r--r--drivers/isdn/mISDN/layer1.c1
-rw-r--r--drivers/isdn/mISDN/layer2.c1
-rw-r--r--drivers/isdn/mISDN/socket.c1
-rw-r--r--drivers/isdn/mISDN/stack.c1
-rw-r--r--drivers/isdn/mISDN/tei.c1
-rw-r--r--drivers/isdn/mISDN/timerdev.c1
-rw-r--r--drivers/isdn/pcbit/callbacks.c1
-rw-r--r--drivers/isdn/pcbit/edss1.c1
-rw-r--r--drivers/isdn/sc/init.c1
-rw-r--r--drivers/leds/dell-led.c1
-rw-r--r--drivers/leds/led-triggers.c1
-rw-r--r--drivers/leds/leds-88pm860x.c1
-rw-r--r--drivers/leds/leds-adp5520.c1
-rw-r--r--drivers/leds/leds-atmel-pwm.c1
-rw-r--r--drivers/leds/leds-bd2802.c1
-rw-r--r--drivers/leds/leds-da903x.c1
-rw-r--r--drivers/leds/leds-dac124s085.c1
-rw-r--r--drivers/leds/leds-gpio.c1
-rw-r--r--drivers/leds/leds-lp3944.c1
-rw-r--r--drivers/leds/leds-lt3593.c1
-rw-r--r--drivers/leds/leds-pca9532.c1
-rw-r--r--drivers/leds/leds-pca955x.c1
-rw-r--r--drivers/leds/leds-pwm.c1
-rw-r--r--drivers/leds/leds-regulator.c1
-rw-r--r--drivers/leds/leds-s3c24xx.c1
-rw-r--r--drivers/leds/leds-sunfire.c1
-rw-r--r--drivers/leds/leds-wm831x-status.c1
-rw-r--r--drivers/leds/leds-wm8350.c1
-rw-r--r--drivers/leds/ledtrig-backlight.c1
-rw-r--r--drivers/leds/ledtrig-gpio.c1
-rw-r--r--drivers/leds/ledtrig-heartbeat.c1
-rw-r--r--drivers/leds/ledtrig-timer.c1
-rw-r--r--drivers/lguest/core.c1
-rw-r--r--drivers/lguest/lg.h1
-rw-r--r--drivers/lguest/lguest_device.c5
-rw-r--r--drivers/lguest/lguest_user.c1
-rw-r--r--drivers/lguest/page_tables.c1
-rw-r--r--drivers/lguest/x86/core.c12
-rw-r--r--drivers/macintosh/mac_hid.c1
-rw-r--r--drivers/macintosh/rack-meter.c1
-rw-r--r--drivers/macintosh/smu.c1
-rw-r--r--drivers/macintosh/therm_pm72.c1
-rw-r--r--drivers/macintosh/therm_windtunnel.c1
-rw-r--r--drivers/macintosh/via-pmu68k.c1
-rw-r--r--drivers/macintosh/windfarm_core.c2
-rw-r--r--drivers/md/dm-log-userspace-base.c1
-rw-r--r--drivers/md/dm-log-userspace-transfer.c1
-rw-r--r--drivers/md/dm-region-hash.c1
-rw-r--r--drivers/md/dm-service-time.c2
-rw-r--r--drivers/md/dm-target.c1
-rw-r--r--drivers/md/faulty.c1
-rw-r--r--drivers/md/linear.c1
-rw-r--r--drivers/md/md.c11
-rw-r--r--drivers/md/multipath.c1
-rw-r--r--drivers/md/raid0.c1
-rw-r--r--drivers/md/raid1.c1
-rw-r--r--drivers/md/raid10.c1
-rw-r--r--drivers/md/raid5.c55
-rw-r--r--drivers/md/raid6algos.c1
-rw-r--r--drivers/media/IR/ir-keytable.c1
-rw-r--r--drivers/media/IR/ir-sysfs.c1
-rw-r--r--drivers/media/common/saa7146_fops.c11
-rw-r--r--drivers/media/common/saa7146_video.c8
-rw-r--r--drivers/media/common/tuners/max2165.c1
-rw-r--r--drivers/media/common/tuners/mc44s803.c1
-rw-r--r--drivers/media/common/tuners/mt2060.c1
-rw-r--r--drivers/media/common/tuners/mt20xx.c1
-rw-r--r--drivers/media/common/tuners/mt2131.c1
-rw-r--r--drivers/media/common/tuners/mt2266.c1
-rw-r--r--drivers/media/common/tuners/tda827x.c1
-rw-r--r--drivers/media/common/tuners/tda8290.c1
-rw-r--r--drivers/media/common/tuners/tda9887.c1
-rw-r--r--drivers/media/common/tuners/tea5761.c1
-rw-r--r--drivers/media/common/tuners/tea5767.c1
-rw-r--r--drivers/media/common/tuners/tuner-i2c.h1
-rw-r--r--drivers/media/common/tuners/tuner-xc2028.c1
-rw-r--r--drivers/media/dvb/bt8xx/dst_ca.c1
-rw-r--r--drivers/media/dvb/dm1105/dm1105.c1
-rw-r--r--drivers/media/dvb/dvb-core/dmxdev.h1
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.h1
-rw-r--r--drivers/media/dvb/dvb-usb/af9015.c1
-rw-r--r--drivers/media/dvb/dvb-usb/cxusb.c1
-rw-r--r--drivers/media/dvb/firewire/firedtv-1394.c1
-rw-r--r--drivers/media/dvb/firewire/firedtv-rc.c1
-rw-r--r--drivers/media/dvb/frontends/au8522_dig.c1
-rw-r--r--drivers/media/dvb/frontends/dib0070.c1
-rw-r--r--drivers/media/dvb/frontends/dib0090.c1
-rw-r--r--drivers/media/dvb/frontends/dib3000mc.c1
-rw-r--r--drivers/media/dvb/frontends/dib7000m.c1
-rw-r--r--drivers/media/dvb/frontends/dib7000p.c1
-rw-r--r--drivers/media/dvb/frontends/dib8000.c1
-rw-r--r--drivers/media/dvb/frontends/drx397xD.c1
-rw-r--r--drivers/media/dvb/frontends/dvb-pll.c1
-rw-r--r--drivers/media/dvb/frontends/itd1000.c1
-rw-r--r--drivers/media/dvb/frontends/lgdt3304.c1
-rw-r--r--drivers/media/dvb/frontends/lgdt3305.c1
-rw-r--r--drivers/media/dvb/frontends/mb86a16.c1
-rw-r--r--drivers/media/dvb/frontends/s921_module.c1
-rw-r--r--drivers/media/dvb/frontends/stb0899_drv.c1
-rw-r--r--drivers/media/dvb/frontends/stb6000.c1
-rw-r--r--drivers/media/dvb/frontends/stb6100.c1
-rw-r--r--drivers/media/dvb/frontends/stv090x.c5
-rw-r--r--drivers/media/dvb/frontends/stv6110.c1
-rw-r--r--drivers/media/dvb/frontends/stv6110x.c1
-rw-r--r--drivers/media/dvb/frontends/tda665x.c1
-rw-r--r--drivers/media/dvb/frontends/tda8261.c1
-rw-r--r--drivers/media/dvb/frontends/tda826x.c1
-rw-r--r--drivers/media/dvb/frontends/tua6100.c1
-rw-r--r--drivers/media/dvb/frontends/zl10036.c1
-rw-r--r--drivers/media/dvb/mantis/hopper_cards.c1
-rw-r--r--drivers/media/dvb/mantis/mantis_ca.c1
-rw-r--r--drivers/media/dvb/mantis/mantis_cards.c1
-rw-r--r--drivers/media/dvb/ngene/ngene-core.c1
-rw-r--r--drivers/media/dvb/pluto2/pluto2.c1
-rw-r--r--drivers/media/dvb/pt1/pt1.c1
-rw-r--r--drivers/media/dvb/siano/smscoreapi.c1
-rw-r--r--drivers/media/dvb/siano/smsdvb.c1
-rw-r--r--drivers/media/dvb/siano/smssdio.c1
-rw-r--r--drivers/media/dvb/siano/smsusb.c1
-rw-r--r--drivers/media/dvb/ttpci/av7110.c1
-rw-r--r--drivers/media/dvb/ttpci/av7110_ca.c1
-rw-r--r--drivers/media/dvb/ttpci/budget.c3
-rw-r--r--drivers/media/radio/radio-gemtek-pci.c1
-rw-r--r--drivers/media/radio/radio-maestro.c1
-rw-r--r--drivers/media/radio/radio-maxiradio.c1
-rw-r--r--drivers/media/radio/radio-si4713.c1
-rw-r--r--drivers/media/radio/radio-tea5764.c1
-rw-r--r--drivers/media/radio/radio-timb.c1
-rw-r--r--drivers/media/radio/saa7706h.c1
-rw-r--r--drivers/media/radio/si470x/radio-si470x-i2c.c1
-rw-r--r--drivers/media/radio/si470x/radio-si470x-usb.c1
-rw-r--r--drivers/media/radio/si4713-i2c.c1
-rw-r--r--drivers/media/radio/tef6862.c1
-rw-r--r--drivers/media/video/Kconfig4
-rw-r--r--drivers/media/video/Makefile2
-rw-r--r--drivers/media/video/adv7170.c1
-rw-r--r--drivers/media/video/adv7175.c1
-rw-r--r--drivers/media/video/adv7180.c1
-rw-r--r--drivers/media/video/adv7343.c1
-rw-r--r--drivers/media/video/au0828/au0828-core.c1
-rw-r--r--drivers/media/video/au0828/au0828-dvb.c1
-rw-r--r--drivers/media/video/au0828/au0828-video.c1
-rw-r--r--drivers/media/video/bt819.c1
-rw-r--r--drivers/media/video/bt856.c1
-rw-r--r--drivers/media/video/bt866.c1
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c1
-rw-r--r--drivers/media/video/bt8xx/bttv-gpio.c1
-rw-r--r--drivers/media/video/bt8xx/bttv-input.c1
-rw-r--r--drivers/media/video/bt8xx/bttv-risc.c1
-rw-r--r--drivers/media/video/cafe_ccic.c1
-rw-r--r--drivers/media/video/cpia_pp.c1
-rw-r--r--drivers/media/video/cs5345.c1
-rw-r--r--drivers/media/video/cs53l32a.c1
-rw-r--r--drivers/media/video/cx18/cx18-alsa-main.c1
-rw-r--r--drivers/media/video/cx18/cx18-controls.c1
-rw-r--r--drivers/media/video/cx18/cx18-driver.h1
-rw-r--r--drivers/media/video/cx231xx/cx231xx-cards.c1
-rw-r--r--drivers/media/video/cx231xx/cx231xx-core.c1
-rw-r--r--drivers/media/video/cx231xx/cx231xx-dvb.c1
-rw-r--r--drivers/media/video/cx231xx/cx231xx-input.c1
-rw-r--r--drivers/media/video/cx231xx/cx231xx-vbi.c1
-rw-r--r--drivers/media/video/cx231xx/cx231xx-video.c1
-rw-r--r--drivers/media/video/cx23885/cx23885-417.c1
-rw-r--r--drivers/media/video/cx23885/cx23885-input.c1
-rw-r--r--drivers/media/video/cx23885/cx23885-vbi.c1
-rw-r--r--drivers/media/video/cx23885/cx23885.h1
-rw-r--r--drivers/media/video/cx23885/cx23888-ir.c1
-rw-r--r--drivers/media/video/cx88/cx88-alsa.c1
-rw-r--r--drivers/media/video/cx88/cx88-blackbird.c1
-rw-r--r--drivers/media/video/cx88/cx88-cards.c1
-rw-r--r--drivers/media/video/cx88/cx88-dsp.c1
-rw-r--r--drivers/media/video/cx88/cx88-input.c1
-rw-r--r--drivers/media/video/cx88/cx88-mpeg.c1
-rw-r--r--drivers/media/video/cx88/cx88-tvaudio.c1
-rw-r--r--drivers/media/video/cx88/cx88-vbi.c1
-rw-r--r--drivers/media/video/cx88/cx88-vp3054-i2c.c1
-rw-r--r--drivers/media/video/davinci/dm644x_ccdc.c1
-rw-r--r--drivers/media/video/davinci/vpfe_capture.c39
-rw-r--r--drivers/media/video/davinci/vpif_capture.c1
-rw-r--r--drivers/media/video/davinci/vpif_display.c1
-rw-r--r--drivers/media/video/em28xx/em28xx-cards.c1
-rw-r--r--drivers/media/video/em28xx/em28xx-core.c1
-rw-r--r--drivers/media/video/em28xx/em28xx-dvb.c1
-rw-r--r--drivers/media/video/em28xx/em28xx-input.c1
-rw-r--r--drivers/media/video/em28xx/em28xx-vbi.c1
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c1
-rw-r--r--drivers/media/video/gspca/gspca.h1
-rw-r--r--drivers/media/video/gspca/jeilinj.c1
-rw-r--r--drivers/media/video/gspca/m5602/m5602_s5k83a.c1
-rw-r--r--drivers/media/video/gspca/sn9c20x.c3
-rw-r--r--drivers/media/video/gspca/sonixj.c1
-rw-r--r--drivers/media/video/gspca/spca508.c1
-rw-r--r--drivers/media/video/gspca/spca561.c1
-rw-r--r--drivers/media/video/gspca/sq905.c1
-rw-r--r--drivers/media/video/gspca/sq905c.c1
-rw-r--r--drivers/media/video/gspca/stv06xx/stv06xx.c2
-rw-r--r--drivers/media/video/gspca/zc3xx.c1
-rw-r--r--drivers/media/video/hdpvr/hdpvr-i2c.c1
-rw-r--r--drivers/media/video/hexium_gemini.c3
-rw-r--r--drivers/media/video/hexium_orion.c4
-rw-r--r--drivers/media/video/ivtv/ivtv-controls.c1
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.h1
-rw-r--r--drivers/media/video/ivtv/ivtvfb.c1
-rw-r--r--drivers/media/video/ks0127.c1
-rw-r--r--drivers/media/video/m52790.c1
-rw-r--r--drivers/media/video/meye.c1
-rw-r--r--drivers/media/video/msp3400-kthreads.c1
-rw-r--r--drivers/media/video/mt9v011.c1
-rw-r--r--drivers/media/video/mx1_camera.c9
-rw-r--r--drivers/media/video/mxb.c17
-rw-r--r--drivers/media/video/omap24xxcam.c3
-rw-r--r--drivers/media/video/ov7670.c1
-rw-r--r--drivers/media/video/pms.c1
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-cs53l32a.c1
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c1
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-debugifc.c1
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-dvb.c1
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-eeprom.c1
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-main.c1
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-sysfs.c8
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-v4l2.c1
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-video-v4l.c1
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-wm8775.c1
-rw-r--r--drivers/media/video/pwc/pwc-dec23.c1
-rw-r--r--drivers/media/video/pwc/pwc-v4l.c1
-rw-r--r--drivers/media/video/pwc/pwc.h1
-rw-r--r--drivers/media/video/pxa_camera.c12
-rw-r--r--drivers/media/video/s2255drv.c1
-rw-r--r--drivers/media/video/saa5246a.c1
-rw-r--r--drivers/media/video/saa5249.c1
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c1
-rw-r--r--drivers/media/video/saa7134/saa7134-empress.c1
-rw-r--r--drivers/media/video/saa7134/saa7134-i2c.c1
-rw-r--r--drivers/media/video/saa7134/saa7134-input.c1
-rw-r--r--drivers/media/video/saa7134/saa7134-ts.c1
-rw-r--r--drivers/media/video/saa7134/saa7134-tvaudio.c1
-rw-r--r--drivers/media/video/saa7134/saa7134-vbi.c1
-rw-r--r--drivers/media/video/saa7164/saa7164-api.c1
-rw-r--r--drivers/media/video/saa7164/saa7164-buffer.c2
-rw-r--r--drivers/media/video/saa7164/saa7164-fw.c1
-rw-r--r--drivers/media/video/saa717x.c1
-rw-r--r--drivers/media/video/saa7185.c1
-rw-r--r--drivers/media/video/sh_mobile_ceu_camera.c3
-rw-r--r--drivers/media/video/soc_camera.c1
-rw-r--r--drivers/media/video/tda9840.c1
-rw-r--r--drivers/media/video/tea6415c.c1
-rw-r--r--drivers/media/video/tea6420.c1
-rw-r--r--drivers/media/video/ths7303.c1
-rw-r--r--drivers/media/video/tlg2300/pd-alsa.c2
-rw-r--r--drivers/media/video/tlg2300/pd-dvb.c1
-rw-r--r--drivers/media/video/tlg2300/pd-video.c1
-rw-r--r--drivers/media/video/tlv320aic23b.c1
-rw-r--r--drivers/media/video/tvp514x.c1
-rw-r--r--drivers/media/video/tvp5150.c1
-rw-r--r--drivers/media/video/tvp7002.c1
-rw-r--r--drivers/media/video/upd64031a.c1
-rw-r--r--drivers/media/video/upd64083.c1
-rw-r--r--drivers/media/video/usbvideo/konicawc.c1
-rw-r--r--drivers/media/video/usbvideo/quickcam_messenger.c1
-rw-r--r--drivers/media/video/usbvision/usbvision-core.c2
-rw-r--r--drivers/media/video/usbvision/usbvision-i2c.c1
-rw-r--r--drivers/media/video/uvc/uvc_ctrl.c1
-rw-r--r--drivers/media/video/uvc/uvc_driver.c1
-rw-r--r--drivers/media/video/uvc/uvc_status.c1
-rw-r--r--drivers/media/video/uvc/uvc_v4l2.c1
-rw-r--r--drivers/media/video/uvc/uvc_video.c1
-rw-r--r--drivers/media/video/v4l2-ioctl.c1
-rw-r--r--drivers/media/video/videobuf-dma-contig.c1
-rw-r--r--drivers/media/video/videobuf-dvb.c1
-rw-r--r--drivers/media/video/vino.c1
-rw-r--r--drivers/media/video/vp27smpx.c1
-rw-r--r--drivers/media/video/vpx3220.c1
-rw-r--r--drivers/media/video/w9966.c1
-rw-r--r--drivers/media/video/wm8739.c1
-rw-r--r--drivers/media/video/wm8775.c1
-rw-r--r--drivers/media/video/zoran/zoran_card.c1
-rw-r--r--drivers/memstick/core/memstick.c1
-rw-r--r--drivers/memstick/core/mspro_block.c1
-rw-r--r--drivers/memstick/host/jmb38x_ms.c1
-rw-r--r--drivers/message/fusion/mptfc.c1
-rw-r--r--drivers/message/fusion/mptlan.c1
-rw-r--r--drivers/message/fusion/mptsas.c1
-rw-r--r--drivers/message/fusion/mptscsih.c1
-rw-r--r--drivers/message/fusion/mptspi.c1
-rw-r--r--drivers/message/i2o/i2o_block.c1
-rw-r--r--drivers/message/i2o/i2o_config.c1
-rw-r--r--drivers/message/i2o/i2o_proc.c1
-rw-r--r--drivers/message/i2o/iop.c1
-rw-r--r--drivers/message/i2o/pci.c1
-rw-r--r--drivers/mfd/88pm860x-i2c.c1
-rw-r--r--drivers/mfd/ab3100-core.c1
-rw-r--r--drivers/mfd/ab3100-otp.c1
-rw-r--r--drivers/mfd/ab4500-core.c1
-rw-r--r--drivers/mfd/adp5520.c1
-rw-r--r--drivers/mfd/asic3.c1
-rw-r--r--drivers/mfd/da903x.c1
-rw-r--r--drivers/mfd/ezx-pcap.c1
-rw-r--r--drivers/mfd/htc-egpio.c1
-rw-r--r--drivers/mfd/htc-i2cpld.c1
-rw-r--r--drivers/mfd/htc-pasic3.c1
-rw-r--r--drivers/mfd/max8925-i2c.c1
-rw-r--r--drivers/mfd/mc13783-core.c1
-rw-r--r--drivers/mfd/mcp-sa11x0.c1
-rw-r--r--drivers/mfd/menelaus.c1
-rw-r--r--drivers/mfd/mfd-core.c1
-rw-r--r--drivers/mfd/pcf50633-adc.c1
-rw-r--r--drivers/mfd/pcf50633-core.c1
-rw-r--r--drivers/mfd/sh_mobile_sdhi.c1
-rw-r--r--drivers/mfd/sm501.c1
-rw-r--r--drivers/mfd/t7l66xb.c1
-rw-r--r--drivers/mfd/tc6387xb.c1
-rw-r--r--drivers/mfd/tc6393xb.c1
-rw-r--r--drivers/mfd/timberdale.c1
-rw-r--r--drivers/mfd/twl4030-codec.c1
-rw-r--r--drivers/mfd/twl4030-irq.c1
-rw-r--r--drivers/mfd/ucb1400_core.c1
-rw-r--r--drivers/mfd/wm831x-core.c1
-rw-r--r--drivers/mfd/wm8350-core.c1
-rw-r--r--drivers/mfd/wm8350-i2c.c1
-rw-r--r--drivers/mfd/wm8400-core.c1
-rw-r--r--drivers/mfd/wm8994-core.c1
-rw-r--r--drivers/misc/Kconfig16
-rw-r--r--drivers/misc/Makefile1
-rw-r--r--drivers/misc/atmel-ssc.c1
-rw-r--r--drivers/misc/atmel_pwm.c1
-rw-r--r--drivers/misc/atmel_tclib.c1
-rw-r--r--drivers/misc/c2port/core.c5
-rw-r--r--drivers/misc/cb710/core.c2
-rw-r--r--drivers/misc/cb710/debug.c1
-rw-r--r--drivers/misc/cs5535-mfgpt.c1
-rw-r--r--drivers/misc/ds1682.c1
-rw-r--r--drivers/misc/enclosure.c1
-rw-r--r--drivers/misc/ep93xx_pwm.c1
-rw-r--r--drivers/misc/hpilo.c1
-rw-r--r--drivers/misc/ibmasm/command.c1
-rw-r--r--drivers/misc/ibmasm/event.c1
-rw-r--r--drivers/misc/ibmasm/ibmasmfs.c1
-rw-r--r--drivers/misc/ibmasm/module.c1
-rw-r--r--drivers/misc/ics932s401.c1
-rw-r--r--drivers/misc/ioc4.c1
-rw-r--r--drivers/misc/iwmc3200top/debugfs.c1
-rw-r--r--drivers/misc/iwmc3200top/fw-download.c1
-rw-r--r--drivers/misc/iwmc3200top/log.c1
-rw-r--r--drivers/misc/iwmc3200top/main.c1
-rw-r--r--drivers/misc/kgdbts.c6
-rw-r--r--drivers/misc/lkdtm.c1
-rw-r--r--drivers/misc/phantom.c1
-rw-r--r--drivers/misc/sgi-xp/xpc_main.c1
-rw-r--r--drivers/misc/sgi-xp/xpc_partition.c1
-rw-r--r--drivers/misc/sgi-xp/xpc_sn2.c1
-rw-r--r--drivers/misc/sgi-xp/xpc_uv.c1
-rw-r--r--drivers/misc/sgi-xp/xpnet.c1
-rw-r--r--drivers/misc/tifm_core.c1
-rw-r--r--drivers/misc/vmware_balloon.c832
-rw-r--r--drivers/mmc/card/block.c1
-rw-r--r--drivers/mmc/card/mmc_test.c1
-rw-r--r--drivers/mmc/card/queue.c1
-rw-r--r--drivers/mmc/card/sdio_uart.c2
-rw-r--r--drivers/mmc/core/bus.c1
-rw-r--r--drivers/mmc/core/debugfs.c1
-rw-r--r--drivers/mmc/core/host.c1
-rw-r--r--drivers/mmc/core/mmc.c4
-rw-r--r--drivers/mmc/core/mmc_ops.c1
-rw-r--r--drivers/mmc/core/sd.c1
-rw-r--r--drivers/mmc/core/sdio_bus.c1
-rw-r--r--drivers/mmc/core/sdio_cis.c1
-rw-r--r--drivers/mmc/host/at91_mci.c1
-rw-r--r--drivers/mmc/host/atmel-mci.c1
-rw-r--r--drivers/mmc/host/au1xmmc.c1
-rw-r--r--drivers/mmc/host/bfin_sdh.c1
-rw-r--r--drivers/mmc/host/cb710-mmc.c1
-rw-r--r--drivers/mmc/host/mmc_spi.c1
-rw-r--r--drivers/mmc/host/msm_sdcc.c1
-rw-r--r--drivers/mmc/host/of_mmc_spi.c1
-rw-r--r--drivers/mmc/host/omap.c1
-rw-r--r--drivers/mmc/host/omap_hsmmc.c9
-rw-r--r--drivers/mmc/host/pxamci.c3
-rw-r--r--drivers/mmc/host/sdhci-pci.c1
-rw-r--r--drivers/mmc/host/sdhci-s3c.c1
-rw-r--r--drivers/mmc/host/sdhci.c1
-rw-r--r--drivers/mmc/host/wbsd.c1
-rw-r--r--drivers/mtd/Makefile2
-rw-r--r--drivers/mtd/devices/block2mtd.c1
-rw-r--r--drivers/mtd/devices/m25p80.c1
-rw-r--r--drivers/mtd/devices/sst25l.c1
-rw-r--r--drivers/mtd/internal.h17
-rw-r--r--drivers/mtd/lpddr/lpddr_cmds.c1
-rw-r--r--drivers/mtd/maps/amd76xrom.c1
-rw-r--r--drivers/mtd/maps/bfin-async-flash.c1
-rw-r--r--drivers/mtd/maps/ck804xrom.c1
-rw-r--r--drivers/mtd/maps/esb2rom.c1
-rw-r--r--drivers/mtd/maps/gpio-addr-flash.c1
-rw-r--r--drivers/mtd/maps/ichxrom.c1
-rw-r--r--drivers/mtd/maps/intel_vr_nor.c1
-rw-r--r--drivers/mtd/maps/octagon-5066.c1
-rw-r--r--drivers/mtd/maps/omap_nor.c0
-rw-r--r--drivers/mtd/maps/physmap_of.c1
-rw-r--r--drivers/mtd/maps/pismo.c1
-rw-r--r--drivers/mtd/maps/pmcmsp-flash.c1
-rw-r--r--drivers/mtd/maps/pxa2xx-flash.c1
-rw-r--r--drivers/mtd/maps/sbc_gxx.c1
-rw-r--r--drivers/mtd/maps/sun_uflash.c1
-rw-r--r--drivers/mtd/maps/vmax301.c1
-rw-r--r--drivers/mtd/maps/vmu-flash.c1
-rw-r--r--drivers/mtd/mtdbdi.c43
-rw-r--r--drivers/mtd/mtdcore.c80
-rw-r--r--drivers/mtd/mtdsuper.c2
-rw-r--r--drivers/mtd/nand/bcm_umi_nand.c1
-rw-r--r--drivers/mtd/nand/cafe_nand.c1
-rw-r--r--drivers/mtd/nand/cmx270_nand.c1
-rw-r--r--drivers/mtd/nand/davinci_nand.c1
-rw-r--r--drivers/mtd/nand/diskonchip.c1
-rw-r--r--drivers/mtd/nand/fsl_upm.c1
-rw-r--r--drivers/mtd/nand/ndfc.c1
-rw-r--r--drivers/mtd/nand/nomadik_nand.c1
-rw-r--r--drivers/mtd/nand/omap2.c1
-rw-r--r--drivers/mtd/nand/orion_nand.c8
-rw-r--r--drivers/mtd/nand/pxa3xx_nand.c1
-rw-r--r--drivers/mtd/nand/sh_flctl.c1
-rw-r--r--drivers/mtd/nand/tmio_nand.c1
-rw-r--r--drivers/mtd/ofpart.c1
-rw-r--r--drivers/mtd/onenand/omap2.c1
-rw-r--r--drivers/mtd/onenand/onenand_base.c1
-rw-r--r--drivers/mtd/onenand/onenand_sim.c1
-rw-r--r--drivers/mtd/tests/mtd_nandecctest.c1
-rw-r--r--drivers/mtd/tests/mtd_oobtest.c1
-rw-r--r--drivers/mtd/tests/mtd_pagetest.c1
-rw-r--r--drivers/mtd/tests/mtd_readtest.c1
-rw-r--r--drivers/mtd/tests/mtd_speedtest.c1
-rw-r--r--drivers/mtd/tests/mtd_stresstest.c1
-rw-r--r--drivers/mtd/tests/mtd_subpagetest.c1
-rw-r--r--drivers/mtd/tests/mtd_torturetest.c1
-rw-r--r--drivers/mtd/ubi/build.c1
-rw-r--r--drivers/mtd/ubi/cdev.c1
-rw-r--r--drivers/mtd/ubi/gluebi.c1
-rw-r--r--drivers/mtd/ubi/io.c1
-rw-r--r--drivers/mtd/ubi/kapi.c1
-rw-r--r--drivers/mtd/ubi/scan.c1
-rw-r--r--drivers/mtd/ubi/ubi.h1
-rw-r--r--drivers/mtd/ubi/vmt.c1
-rw-r--r--drivers/mtd/ubi/vtbl.c1
-rw-r--r--drivers/net/3c501.c1
-rw-r--r--drivers/net/3c505.c2
-rw-r--r--drivers/net/3c507.c1
-rw-r--r--drivers/net/3c509.c1
-rw-r--r--drivers/net/3c515.c1
-rw-r--r--drivers/net/3c523.c1
-rw-r--r--drivers/net/3c59x.c2
-rw-r--r--drivers/net/7990.c1
-rw-r--r--drivers/net/8139cp.c1
-rw-r--r--drivers/net/8139too.c3
-rw-r--r--drivers/net/82596.c2
-rw-r--r--drivers/net/Kconfig25
-rw-r--r--drivers/net/Makefile2
-rw-r--r--drivers/net/a2065.c1
-rw-r--r--drivers/net/acenic.c1
-rw-r--r--drivers/net/amd8111e.c1
-rw-r--r--drivers/net/appletalk/cops.c1
-rw-r--r--drivers/net/appletalk/ipddp.c1
-rw-r--r--drivers/net/appletalk/ltpc.c2
-rw-r--r--drivers/net/arcnet/arc-rawmode.c1
-rw-r--r--drivers/net/arcnet/arc-rimi.c1
-rw-r--r--drivers/net/arcnet/capmode.c1
-rw-r--r--drivers/net/arcnet/com20020-isa.c1
-rw-r--r--drivers/net/arcnet/com20020-pci.c1
-rw-r--r--drivers/net/arcnet/com20020.c1
-rw-r--r--drivers/net/arcnet/com90io.c1
-rw-r--r--drivers/net/arcnet/com90xx.c1
-rw-r--r--drivers/net/arcnet/rfc1051.c1
-rw-r--r--drivers/net/arcnet/rfc1201.c1
-rw-r--r--drivers/net/ariadne.c1
-rw-r--r--drivers/net/arm/at91_ether.c1
-rw-r--r--drivers/net/arm/ep93xx_eth.c11
-rw-r--r--drivers/net/arm/etherh.c1
-rw-r--r--drivers/net/arm/ixp4xx_eth.c1
-rw-r--r--drivers/net/arm/ks8695net.c25
-rw-r--r--drivers/net/arm/w90p910_ether.c1
-rw-r--r--drivers/net/at1700.c1
-rw-r--r--drivers/net/atarilance.c1
-rw-r--r--drivers/net/atl1c/atl1c_ethtool.c1
-rw-r--r--drivers/net/atl1e/atl1e_ethtool.c1
-rw-r--r--drivers/net/atlx/atl1.c2
-rw-r--r--drivers/net/atlx/atl2.c1
-rw-r--r--drivers/net/atp.c1
-rw-r--r--drivers/net/ax88796.c1
-rw-r--r--drivers/net/b44.c1
-rw-r--r--drivers/net/bcm63xx_enet.c1
-rw-r--r--drivers/net/benet/be.h1
-rw-r--r--drivers/net/benet/be_cmds.c4
-rw-r--r--drivers/net/benet/be_ethtool.c2
-rw-r--r--drivers/net/benet/be_main.c21
-rw-r--r--drivers/net/bmac.c1
-rw-r--r--drivers/net/bnx2.c62
-rw-r--r--drivers/net/bonding/bond_main.c66
-rw-r--r--drivers/net/can/bfin_can.c97
-rw-r--r--drivers/net/can/dev.c1
-rw-r--r--drivers/net/can/mcp251x.c1
-rw-r--r--drivers/net/can/sja1000/ems_pci.c1
-rw-r--r--drivers/net/can/sja1000/plx_pci.c1
-rw-r--r--drivers/net/can/usb/ems_usb.c8
-rw-r--r--drivers/net/can/vcan.c1
-rw-r--r--drivers/net/chelsio/common.h1
-rw-r--r--drivers/net/chelsio/pm3393.c1
-rw-r--r--drivers/net/chelsio/sge.c1
-rw-r--r--drivers/net/cnic.c10
-rw-r--r--drivers/net/cris/eth_v10.c1
-rw-r--r--drivers/net/cs89x0.c2
-rw-r--r--drivers/net/cxgb3/ael1002.c2
-rw-r--r--drivers/net/cxgb3/cxgb3_main.c3
-rw-r--r--drivers/net/cxgb3/cxgb3_offload.c1
-rw-r--r--drivers/net/cxgb3/l2t.c1
-rw-r--r--drivers/net/cxgb3/sge.c1
-rw-r--r--drivers/net/cxgb4/Makefile7
-rw-r--r--drivers/net/cxgb4/cxgb4.h741
-rw-r--r--drivers/net/cxgb4/cxgb4_main.c3388
-rw-r--r--drivers/net/cxgb4/cxgb4_uld.h239
-rw-r--r--drivers/net/cxgb4/l2t.c624
-rw-r--r--drivers/net/cxgb4/l2t.h110
-rw-r--r--drivers/net/cxgb4/sge.c2431
-rw-r--r--drivers/net/cxgb4/t4_hw.c3131
-rw-r--r--drivers/net/cxgb4/t4_hw.h100
-rw-r--r--drivers/net/cxgb4/t4_msg.h664
-rw-r--r--drivers/net/cxgb4/t4_regs.h878
-rw-r--r--drivers/net/cxgb4/t4fw_api.h1580
-rw-r--r--drivers/net/dm9000.c1
-rw-r--r--drivers/net/e100.c10
-rw-r--r--drivers/net/e1000/e1000.h1
-rw-r--r--drivers/net/e1000/e1000_main.c9
-rw-r--r--drivers/net/e1000e/82571.c20
-rw-r--r--drivers/net/e1000e/e1000.h6
-rw-r--r--drivers/net/e1000e/ethtool.c1
-rw-r--r--drivers/net/e1000e/netdev.c87
-rw-r--r--drivers/net/eepro.c1
-rw-r--r--drivers/net/eexpress.c1
-rw-r--r--drivers/net/ehea/ehea_main.c1
-rw-r--r--drivers/net/ehea/ehea_qmr.c1
-rw-r--r--drivers/net/enc28j60.c1
-rw-r--r--drivers/net/enic/vnic_dev.c1
-rw-r--r--drivers/net/enic/vnic_rq.c1
-rw-r--r--drivers/net/enic/vnic_wq.c1
-rw-r--r--drivers/net/epic100.c1
-rw-r--r--drivers/net/eql.c1
-rw-r--r--drivers/net/eth16i.c1
-rw-r--r--drivers/net/ethoc.c1
-rw-r--r--drivers/net/fealnx.c1
-rw-r--r--drivers/net/fec.c2
-rw-r--r--drivers/net/fec_mpc52xx.c1
-rw-r--r--drivers/net/fec_mpc52xx_phy.c1
-rw-r--r--drivers/net/forcedeth.c3
-rw-r--r--drivers/net/fs_enet/mac-fcc.c2
-rw-r--r--drivers/net/fs_enet/mac-fec.c2
-rw-r--r--drivers/net/fs_enet/mac-scc.c1
-rw-r--r--drivers/net/fsl_pq_mdio.c20
-rw-r--r--drivers/net/gianfar.c29
-rw-r--r--drivers/net/gianfar.h6
-rw-r--r--drivers/net/gianfar_ethtool.c1
-rw-r--r--drivers/net/gianfar_sysfs.c1
-rw-r--r--drivers/net/greth.c1
-rw-r--r--drivers/net/hamachi.c1
-rw-r--r--drivers/net/hamradio/6pack.c1
-rw-r--r--drivers/net/hamradio/bpqether.c1
-rw-r--r--drivers/net/hamradio/dmascc.c1
-rw-r--r--drivers/net/hamradio/hdlcdrv.c1
-rw-r--r--drivers/net/hamradio/mkiss.c1
-rw-r--r--drivers/net/hamradio/scc.c1
-rw-r--r--drivers/net/hp100.c1
-rw-r--r--drivers/net/hplance.c1
-rw-r--r--drivers/net/hydra.c1
-rw-r--r--drivers/net/ibm_newemac/core.c1
-rw-r--r--drivers/net/ibm_newemac/core.h1
-rw-r--r--drivers/net/ibm_newemac/mal.c1
-rw-r--r--drivers/net/ibm_newemac/rgmii.c1
-rw-r--r--drivers/net/ibm_newemac/zmii.c1
-rw-r--r--drivers/net/ibmlana.c1
-rw-r--r--drivers/net/ibmveth.c1
-rw-r--r--drivers/net/igb/e1000_82575.c2
-rw-r--r--drivers/net/igb/e1000_hw.h1
-rw-r--r--drivers/net/igb/e1000_mac.c6
-rw-r--r--drivers/net/igb/igb.h1
-rw-r--r--drivers/net/igb/igb_ethtool.c2
-rw-r--r--drivers/net/igb/igb_main.c25
-rw-r--r--drivers/net/igbvf/igbvf.h1
-rw-r--r--drivers/net/igbvf/netdev.c12
-rw-r--r--drivers/net/ioc3-eth.c1
-rw-r--r--drivers/net/ipg.c1
-rw-r--r--drivers/net/irda/ali-ircc.c2
-rw-r--r--drivers/net/irda/bfin_sir.h1
-rw-r--r--drivers/net/irda/irtty-sir.c1
-rw-r--r--drivers/net/irda/nsc-ircc.c2
-rw-r--r--drivers/net/irda/pxaficp_ir.c1
-rw-r--r--drivers/net/irda/sh_sir.c1
-rw-r--r--drivers/net/irda/sir_dev.c1
-rw-r--r--drivers/net/irda/smsc-ircc2.c2
-rw-r--r--drivers/net/irda/via-ircc.c2
-rw-r--r--drivers/net/irda/w83977af_ir.c2
-rw-r--r--drivers/net/iseries_veth.c1
-rw-r--r--drivers/net/ixgbe/ixgbe.h7
-rw-r--r--drivers/net/ixgbe/ixgbe_82599.c112
-rw-r--r--drivers/net/ixgbe/ixgbe_ethtool.c22
-rw-r--r--drivers/net/ixgbe/ixgbe_fcoe.c40
-rw-r--r--drivers/net/ixgbe/ixgbe_main.c68
-rw-r--r--drivers/net/ixgbe/ixgbe_type.h4
-rw-r--r--drivers/net/ixgbevf/ethtool.c43
-rw-r--r--drivers/net/ixgbevf/ixgbevf_main.c78
-rw-r--r--drivers/net/ixgbevf/vf.h6
-rw-r--r--drivers/net/ixp2000/ixpdev.c1
-rw-r--r--drivers/net/jazzsonic.c3
-rw-r--r--drivers/net/jme.c36
-rw-r--r--drivers/net/jme.h2
-rw-r--r--drivers/net/ks8851.c13
-rw-r--r--drivers/net/ks8851_mll.c1
-rw-r--r--drivers/net/ksz884x.c3
-rw-r--r--drivers/net/lasi_82596.c1
-rw-r--r--drivers/net/lib82596.c2
-rw-r--r--drivers/net/ll_temac_main.c1
-rw-r--r--drivers/net/ll_temac_mdio.c1
-rw-r--r--drivers/net/mac8390.c1
-rw-r--r--drivers/net/mac89x0.c2
-rw-r--r--drivers/net/mace.c1
-rw-r--r--drivers/net/macmace.c1
-rw-r--r--drivers/net/macsonic.c3
-rw-r--r--drivers/net/macvtap.c1
-rw-r--r--drivers/net/mlx4/cmd.c1
-rw-r--r--drivers/net/mlx4/cq.c1
-rw-r--r--drivers/net/mlx4/en_main.c1
-rw-r--r--drivers/net/mlx4/en_netdev.c1
-rw-r--r--drivers/net/mlx4/en_resources.c1
-rw-r--r--drivers/net/mlx4/en_rx.c1
-rw-r--r--drivers/net/mlx4/en_tx.c1
-rw-r--r--drivers/net/mlx4/eq.c1
-rw-r--r--drivers/net/mlx4/icm.c1
-rw-r--r--drivers/net/mlx4/intf.c2
-rw-r--r--drivers/net/mlx4/main.c2
-rw-r--r--drivers/net/mlx4/mcg.c1
-rw-r--r--drivers/net/mlx4/mr.c1
-rw-r--r--drivers/net/mlx4/profile.c2
-rw-r--r--drivers/net/mlx4/qp.c1
-rw-r--r--drivers/net/mlx4/srq.c1
-rw-r--r--drivers/net/mv643xx_eth.c1
-rw-r--r--drivers/net/mvme147.c2
-rw-r--r--drivers/net/myri10ge/myri10ge.c3
-rw-r--r--drivers/net/myri_sbus.c2
-rw-r--r--drivers/net/ne2.c1
-rw-r--r--drivers/net/netconsole.c1
-rw-r--r--drivers/net/netxen/netxen_nic.h4
-rw-r--r--drivers/net/netxen/netxen_nic_ctx.c14
-rw-r--r--drivers/net/netxen/netxen_nic_hw.c1
-rw-r--r--drivers/net/netxen/netxen_nic_init.c3
-rw-r--r--drivers/net/netxen/netxen_nic_main.c50
-rw-r--r--drivers/net/ni5010.c1
-rw-r--r--drivers/net/ni52.c1
-rw-r--r--drivers/net/niu.c1
-rw-r--r--drivers/net/ns83820.c1
-rw-r--r--drivers/net/octeon/octeon_mgmt.c1
-rw-r--r--drivers/net/pasemi_mac.c1
-rw-r--r--drivers/net/pcmcia/3c574_cs.c7
-rw-r--r--drivers/net/pcmcia/axnet_cs.c1
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c4
-rw-r--r--drivers/net/pcmcia/smc91c92_cs.c56
-rw-r--r--drivers/net/phy/Kconfig5
-rw-r--r--drivers/net/phy/Makefile1
-rw-r--r--drivers/net/phy/cicada.c1
-rw-r--r--drivers/net/phy/davicom.c1
-rw-r--r--drivers/net/phy/et1011c.c1
-rw-r--r--drivers/net/phy/fixed.c1
-rw-r--r--drivers/net/phy/icplus.c1
-rw-r--r--drivers/net/phy/lxt.c1
-rw-r--r--drivers/net/phy/marvell.c1
-rw-r--r--drivers/net/phy/mdio-bitbang.c1
-rw-r--r--drivers/net/phy/mdio-octeon.c11
-rw-r--r--drivers/net/phy/micrel.c104
-rw-r--r--drivers/net/phy/phy.c1
-rw-r--r--drivers/net/phy/qsemi.c1
-rw-r--r--drivers/net/plip.c1
-rw-r--r--drivers/net/ppp_async.c1
-rw-r--r--drivers/net/ppp_generic.c35
-rw-r--r--drivers/net/ppp_synctty.c1
-rw-r--r--drivers/net/pppox.c1
-rw-r--r--drivers/net/ps3_gelic_net.c1
-rw-r--r--drivers/net/ps3_gelic_wireless.c1
-rw-r--r--drivers/net/qlcnic/qlcnic_hw.c4
-rw-r--r--drivers/net/qlcnic/qlcnic_init.c1
-rw-r--r--drivers/net/qlcnic/qlcnic_main.c1
-rw-r--r--drivers/net/qlge/qlge_dbg.c2
-rw-r--r--drivers/net/qlge/qlge_ethtool.c1
-rw-r--r--drivers/net/r6040.c12
-rw-r--r--drivers/net/r8169.c108
-rw-r--r--drivers/net/rionet.c1
-rw-r--r--drivers/net/rrunner.c1
-rw-r--r--drivers/net/s2io.c1
-rw-r--r--drivers/net/sb1000.c2
-rw-r--r--drivers/net/sb1250-mac.c67
-rw-r--r--drivers/net/seeq8005.c1
-rw-r--r--drivers/net/sfc/efx.c5
-rw-r--r--drivers/net/sfc/falcon.c5
-rw-r--r--drivers/net/sfc/falcon_boards.c13
-rw-r--r--drivers/net/sfc/mcdi_phy.c1
-rw-r--r--drivers/net/sfc/mtd.c1
-rw-r--r--drivers/net/sfc/nic.h2
-rw-r--r--drivers/net/sfc/qt202x_phy.c1
-rw-r--r--drivers/net/sfc/rx.c1
-rw-r--r--drivers/net/sfc/selftest.c1
-rw-r--r--drivers/net/sfc/siena.c14
-rw-r--r--drivers/net/sfc/tenxpress.c1
-rw-r--r--drivers/net/sfc/tx.c1
-rw-r--r--drivers/net/sgiseeq.c5
-rw-r--r--drivers/net/sh_eth.c1
-rw-r--r--drivers/net/sis190.c1
-rw-r--r--drivers/net/skfp/skfddi.c2
-rw-r--r--drivers/net/skge.c1
-rw-r--r--drivers/net/sky2.c1
-rw-r--r--drivers/net/slhc.c1
-rw-r--r--drivers/net/slip.c1
-rw-r--r--drivers/net/smc911x.c1
-rw-r--r--drivers/net/smc9194.c1
-rw-r--r--drivers/net/smc91x.c1
-rw-r--r--drivers/net/smsc911x.c1
-rw-r--r--drivers/net/smsc9420.c1
-rw-r--r--drivers/net/sni_82596.c1
-rw-r--r--drivers/net/spider_net.c2
-rw-r--r--drivers/net/stmmac/Kconfig1
-rw-r--r--drivers/net/stmmac/dwmac100.c1
-rw-r--r--drivers/net/stmmac/dwmac1000_core.c1
-rw-r--r--drivers/net/stmmac/stmmac_main.c11
-rw-r--r--drivers/net/stmmac/stmmac_mdio.c1
-rw-r--r--drivers/net/sun3_82586.c1
-rw-r--r--drivers/net/sun3lance.c1
-rw-r--r--drivers/net/sunbmac.c2
-rw-r--r--drivers/net/sundance.c1
-rw-r--r--drivers/net/sungem.c2
-rw-r--r--drivers/net/sunlance.c2
-rw-r--r--drivers/net/tehuti.h1
-rw-r--r--drivers/net/tg3.c1
-rw-r--r--drivers/net/tokenring/3c359.c1
-rw-r--r--drivers/net/tokenring/lanstreamer.c1
-rw-r--r--drivers/net/tokenring/madgemc.c1
-rw-r--r--drivers/net/tokenring/smctr.c1
-rw-r--r--drivers/net/tokenring/tms380tr.c1
-rw-r--r--drivers/net/tsi108_eth.c2
-rw-r--r--drivers/net/tulip/de2104x.c1
-rw-r--r--drivers/net/tulip/de4x5.c2
-rw-r--r--drivers/net/tulip/dmfe.c1
-rw-r--r--drivers/net/tulip/eeprom.c1
-rw-r--r--drivers/net/tulip/tulip_core.c1
-rw-r--r--drivers/net/tulip/uli526x.c9
-rw-r--r--drivers/net/tulip/winbond-840.c1
-rw-r--r--drivers/net/tun.c4
-rw-r--r--drivers/net/typhoon.c1
-rw-r--r--drivers/net/ucc_geth_ethtool.c1
-rw-r--r--drivers/net/usb/Kconfig21
-rw-r--r--drivers/net/usb/Makefile2
-rw-r--r--drivers/net/usb/asix.c1
-rw-r--r--drivers/net/usb/catc.c2
-rw-r--r--drivers/net/usb/cdc-phonet.c1
-rw-r--r--drivers/net/usb/cdc_eem.c1
-rw-r--r--drivers/net/usb/cdc_ether.c1
-rw-r--r--drivers/net/usb/dm9601.c3
-rw-r--r--drivers/net/usb/gl620a.c1
-rw-r--r--drivers/net/usb/int51x1.c1
-rw-r--r--drivers/net/usb/ipheth.c569
-rw-r--r--drivers/net/usb/kaweth.c1
-rw-r--r--drivers/net/usb/mcs7830.c1
-rw-r--r--drivers/net/usb/net1080.c1
-rw-r--r--drivers/net/usb/rndis_host.c1
-rw-r--r--drivers/net/usb/sierra_net.c1004
-rw-r--r--drivers/net/usb/smsc75xx.c1
-rw-r--r--drivers/net/usb/smsc95xx.c19
-rw-r--r--drivers/net/usb/usbnet.c1
-rw-r--r--drivers/net/veth.c1
-rw-r--r--drivers/net/via-rhine.c1
-rw-r--r--drivers/net/via-velocity.c2
-rw-r--r--drivers/net/virtio_net.c3
-rw-r--r--drivers/net/vxge/vxge-config.c1
-rw-r--r--drivers/net/vxge/vxge-config.h1
-rw-r--r--drivers/net/vxge/vxge-ethtool.c1
-rw-r--r--drivers/net/vxge/vxge-main.c1
-rw-r--r--drivers/net/wan/dscc4.c1
-rw-r--r--drivers/net/wan/farsync.c1
-rw-r--r--drivers/net/wan/hd64570.c1
-rw-r--r--drivers/net/wan/hd64572.c1
-rw-r--r--drivers/net/wan/hdlc_cisco.c1
-rw-r--r--drivers/net/wan/hdlc_ppp.c6
-rw-r--r--drivers/net/wan/hdlc_raw.c1
-rw-r--r--drivers/net/wan/hdlc_raw_eth.c2
-rw-r--r--drivers/net/wan/hdlc_x25.c2
-rw-r--r--drivers/net/wan/hostess_sv11.c1
-rw-r--r--drivers/net/wan/ixp4xx_hss.c1
-rw-r--r--drivers/net/wan/lapbether.c1
-rw-r--r--drivers/net/wan/lmc/lmc_media.c1
-rw-r--r--drivers/net/wan/lmc/lmc_proto.c1
-rw-r--r--drivers/net/wan/pc300_drv.c1
-rw-r--r--drivers/net/wan/sbni.c1
-rw-r--r--drivers/net/wan/sealevel.c1
-rw-r--r--drivers/net/wan/x25_asy.c1
-rw-r--r--drivers/net/wan/z85230.c1
-rw-r--r--drivers/net/wimax/i2400m/control.c1
-rw-r--r--drivers/net/wimax/i2400m/driver.c1
-rw-r--r--drivers/net/wimax/i2400m/fw.c1
-rw-r--r--drivers/net/wimax/i2400m/netdev.c1
-rw-r--r--drivers/net/wimax/i2400m/op-rfkill.c1
-rw-r--r--drivers/net/wimax/i2400m/rx.c1
-rw-r--r--drivers/net/wimax/i2400m/sdio-rx.c1
-rw-r--r--drivers/net/wimax/i2400m/sdio.c1
-rw-r--r--drivers/net/wimax/i2400m/tx.c1
-rw-r--r--drivers/net/wimax/i2400m/usb-fw.c1
-rw-r--r--drivers/net/wimax/i2400m/usb-notif.c1
-rw-r--r--drivers/net/wimax/i2400m/usb-rx.c1
-rw-r--r--drivers/net/wimax/i2400m/usb.c1
-rw-r--r--drivers/net/wireless/adm8211.c1
-rw-r--r--drivers/net/wireless/ath/ar9170/main.c1
-rw-r--r--drivers/net/wireless/ath/ar9170/usb.c5
-rw-r--r--drivers/net/wireless/ath/ath5k/attach.c1
-rw-r--r--drivers/net/wireless/ath/ath5k/base.c1
-rw-r--r--drivers/net/wireless/ath/ath5k/eeprom.c2
-rw-r--r--drivers/net/wireless/ath/ath5k/phy.c1
-rw-r--r--drivers/net/wireless/ath/ath9k/debug.c1
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c1
-rw-r--r--drivers/net/wireless/ath/ath9k/init.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c3
-rw-r--r--drivers/net/wireless/ath/ath9k/phy.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/rc.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/virtual.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c21
-rw-r--r--drivers/net/wireless/ath/regd.c1
-rw-r--r--drivers/net/wireless/b43/dma.c1
-rw-r--r--drivers/net/wireless/b43/lo.c1
-rw-r--r--drivers/net/wireless/b43/main.c1
-rw-r--r--drivers/net/wireless/b43/pcmcia.c1
-rw-r--r--drivers/net/wireless/b43/phy_a.c2
-rw-r--r--drivers/net/wireless/b43/phy_g.c1
-rw-r--r--drivers/net/wireless/b43/phy_lp.c2
-rw-r--r--drivers/net/wireless/b43/phy_n.c1
-rw-r--r--drivers/net/wireless/b43/pio.c1
-rw-r--r--drivers/net/wireless/b43/sdio.c1
-rw-r--r--drivers/net/wireless/b43legacy/dma.c1
-rw-r--r--drivers/net/wireless/b43legacy/main.c1
-rw-r--r--drivers/net/wireless/b43legacy/phy.c1
-rw-r--r--drivers/net/wireless/b43legacy/pio.c1
-rw-r--r--drivers/net/wireless/hostap/hostap_80211_rx.c1
-rw-r--r--drivers/net/wireless/hostap/hostap_80211_tx.c2
-rw-r--r--drivers/net/wireless/hostap/hostap_ap.c1
-rw-r--r--drivers/net/wireless/hostap/hostap_cs.c1
-rw-r--r--drivers/net/wireless/hostap/hostap_info.c1
-rw-r--r--drivers/net/wireless/hostap/hostap_ioctl.c1
-rw-r--r--drivers/net/wireless/hostap/hostap_pci.c1
-rw-r--r--drivers/net/wireless/hostap/hostap_plx.c1
-rw-r--r--drivers/net/wireless/ipw2x00/ipw2200.c1
-rw-r--r--drivers/net/wireless/ipw2x00/libipw_geo.c1
-rw-r--r--drivers/net/wireless/ipw2x00/libipw_rx.c2
-rw-r--r--drivers/net/wireless/ipw2x00/libipw_wx.c1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-rs.c1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c9
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-6000.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.c56
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c14
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-calib.c13
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c13
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h7
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debugfs.c1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-devtrace.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-devtrace.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.c1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.h4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-io.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-power.c1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-rx.c1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c32
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-tx.c110
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c5
-rw-r--r--drivers/net/wireless/iwmc3200wifi/cfg80211.c1
-rw-r--r--drivers/net/wireless/iwmc3200wifi/commands.c1
-rw-r--r--drivers/net/wireless/iwmc3200wifi/debugfs.c1
-rw-r--r--drivers/net/wireless/iwmc3200wifi/eeprom.c1
-rw-r--r--drivers/net/wireless/iwmc3200wifi/hal.c1
-rw-r--r--drivers/net/wireless/iwmc3200wifi/main.c1
-rw-r--r--drivers/net/wireless/iwmc3200wifi/netdev.c1
-rw-r--r--drivers/net/wireless/iwmc3200wifi/rx.c1
-rw-r--r--drivers/net/wireless/iwmc3200wifi/sdio.c1
-rw-r--r--drivers/net/wireless/iwmc3200wifi/tx.c1
-rw-r--r--drivers/net/wireless/libertas/assoc.c1
-rw-r--r--drivers/net/wireless/libertas/cfg.c9
-rw-r--r--drivers/net/wireless/libertas/cmd.c1
-rw-r--r--drivers/net/wireless/libertas/cmdresp.c1
-rw-r--r--drivers/net/wireless/libertas/debugfs.c1
-rw-r--r--drivers/net/wireless/libertas/dev.h1
-rw-r--r--drivers/net/wireless/libertas/if_cs.c1
-rw-r--r--drivers/net/wireless/libertas/if_sdio.c1
-rw-r--r--drivers/net/wireless/libertas/if_spi.c1
-rw-r--r--drivers/net/wireless/libertas/if_usb.c1
-rw-r--r--drivers/net/wireless/libertas/main.c1
-rw-r--r--drivers/net/wireless/libertas/rx.c1
-rw-r--r--drivers/net/wireless/libertas/scan.c1
-rw-r--r--drivers/net/wireless/libertas/wext.c1
-rw-r--r--drivers/net/wireless/libertas_tf/cmd.c2
-rw-r--r--drivers/net/wireless/libertas_tf/if_usb.c1
-rw-r--r--drivers/net/wireless/libertas_tf/main.c2
-rw-r--r--drivers/net/wireless/mac80211_hwsim.c1
-rw-r--r--drivers/net/wireless/mwl8k.c2
-rw-r--r--drivers/net/wireless/orinoco/fw.c1
-rw-r--r--drivers/net/wireless/orinoco/main.c1
-rw-r--r--drivers/net/wireless/orinoco/scan.c1
-rw-r--r--drivers/net/wireless/orinoco/wext.c1
-rw-r--r--drivers/net/wireless/p54/eeprom.c1
-rw-r--r--drivers/net/wireless/p54/fwio.c1
-rw-r--r--drivers/net/wireless/p54/main.c1
-rw-r--r--drivers/net/wireless/p54/p54pci.c3
-rw-r--r--drivers/net/wireless/p54/p54spi.c1
-rw-r--r--drivers/net/wireless/p54/p54usb.c2
-rw-r--r--drivers/net/wireless/prism54/isl_ioctl.c1
-rw-r--r--drivers/net/wireless/prism54/islpci_dev.c1
-rw-r--r--drivers/net/wireless/prism54/islpci_eth.c1
-rw-r--r--drivers/net/wireless/prism54/islpci_mgt.c1
-rw-r--r--drivers/net/wireless/prism54/islpci_mgt.h1
-rw-r--r--drivers/net/wireless/prism54/oid_mgt.c1
-rw-r--r--drivers/net/wireless/ray_cs.c1
-rw-r--r--drivers/net/wireless/rndis_wlan.c1
-rw-r--r--drivers/net/wireless/rt2x00/rt2400pci.c1
-rw-r--r--drivers/net/wireless/rt2x00/rt2500pci.c1
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c6
-rw-r--r--drivers/net/wireless/rt2x00/rt2800lib.c5
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00debug.c1
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c1
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00pci.c1
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00queue.c1
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00soc.c1
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00usb.c1
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c1
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c1
-rw-r--r--drivers/net/wireless/rtl818x/rtl8180_dev.c1
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187_dev.c1
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_acx.c1
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_boot.c1
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_cmd.c1
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_debugfs.c4
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_init.c1
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_main.c1
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_rx.c1
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_spi.c1
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_acx.c1
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_boot.c1
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_cmd.c1
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_debugfs.c1
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_init.c1
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_main.c1
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_rx.c2
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_spi.c1
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_testmode.c1
-rw-r--r--drivers/net/wireless/zd1201.c1
-rw-r--r--drivers/net/wireless/zd1211rw/zd_chip.c1
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c1
-rw-r--r--drivers/net/wireless/zd1211rw/zd_rf_uw2453.c1
-rw-r--r--drivers/net/wireless/zd1211rw/zd_usb.c1
-rw-r--r--drivers/net/xen-netfront.c1
-rw-r--r--drivers/net/xilinx_emaclite.c1
-rw-r--r--drivers/net/xtsonic.c3
-rw-r--r--drivers/net/yellowfin.c1
-rw-r--r--drivers/net/znet.c1
-rw-r--r--drivers/nubus/nubus.c1
-rw-r--r--drivers/of/base.c1
-rw-r--r--drivers/of/fdt.c7
-rw-r--r--drivers/of/gpio.c1
-rw-r--r--drivers/of/of_mdio.c2
-rw-r--r--drivers/oprofile/buffer_sync.c1
-rw-r--r--drivers/parisc/asp.c1
-rw-r--r--drivers/parisc/ccio-rm-dma.c1
-rw-r--r--drivers/parisc/gsc.c1
-rw-r--r--drivers/parport/daisy.c1
-rw-r--r--drivers/parport/parport_ax88796.c1
-rw-r--r--drivers/parport/parport_ip32.c1
-rw-r--r--drivers/parport/parport_serial.c1
-rw-r--r--drivers/parport/probe.c1
-rw-r--r--drivers/pci/access.c1
-rw-r--r--drivers/pci/bus.c1
-rw-r--r--drivers/pci/dmar.c1
-rw-r--r--drivers/pci/hotplug/acpi_pcihp.c1
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c1
-rw-r--r--drivers/pci/hotplug/acpiphp_ibm.c1
-rw-r--r--drivers/pci/hotplug/cpqphp_sysfs.c1
-rw-r--r--drivers/pci/hotplug/fakephp.c1
-rw-r--r--drivers/pci/hotplug/pci_hotplug_core.c1
-rw-r--r--drivers/pci/hotplug/pciehp_acpi.c1
-rw-r--r--drivers/pci/hotplug/pciehp_core.c1
-rw-r--r--drivers/pci/hotplug/pciehp_ctrl.c1
-rw-r--r--drivers/pci/hotplug/pciehp_hpc.c6
-rw-r--r--drivers/pci/hotplug/rpadlpar_core.c3
-rw-r--r--drivers/pci/hotplug/rpaphp_core.c4
-rw-r--r--drivers/pci/hotplug/sgi_hotplug.c1
-rw-r--r--drivers/pci/hotplug/shpchp_core.c1
-rw-r--r--drivers/pci/hotplug/shpchp_ctrl.c1
-rw-r--r--drivers/pci/htirq.c1
-rw-r--r--drivers/pci/intr_remapping.c1
-rw-r--r--drivers/pci/ioapic.c10
-rw-r--r--drivers/pci/iov.c1
-rw-r--r--drivers/pci/msi.c1
-rw-r--r--drivers/pci/pci-sysfs.c3
-rw-r--r--drivers/pci/pci.c51
-rw-r--r--drivers/pci/pcie/aer/aer_inject.c1
-rw-r--r--drivers/pci/pcie/aer/aerdrv.c11
-rw-r--r--drivers/pci/pcie/aer/aerdrv_core.c1
-rw-r--r--drivers/pci/pcie/pme/pcie_pme.c1
-rw-r--r--drivers/pci/pcie/portdrv_pci.c1
-rw-r--r--drivers/pci/probe.c30
-rw-r--r--drivers/pci/proc.c1
-rw-r--r--drivers/pci/quirks.c29
-rw-r--r--drivers/pci/search.c1
-rw-r--r--drivers/pci/setup-res.c14
-rw-r--r--drivers/pci/slot.c1
-rw-r--r--drivers/pcmcia/Kconfig3
-rw-r--r--drivers/pcmcia/Makefile1
-rw-r--r--drivers/pcmcia/at91_cf.c3
-rw-r--r--drivers/pcmcia/au1000_generic.c14
-rw-r--r--drivers/pcmcia/bcm63xx_pcmcia.c1
-rw-r--r--drivers/pcmcia/bfin_cf_pcmcia.c13
-rw-r--r--drivers/pcmcia/cistpl.c9
-rw-r--r--drivers/pcmcia/cs.c140
-rw-r--r--drivers/pcmcia/db1xxx_ss.c40
-rw-r--r--drivers/pcmcia/ds.c86
-rw-r--r--drivers/pcmcia/electra_cf.c1
-rw-r--r--drivers/pcmcia/i82092.c16
-rw-r--r--drivers/pcmcia/i82365.c12
-rw-r--r--drivers/pcmcia/m32r_cfc.c12
-rw-r--r--drivers/pcmcia/m32r_pcc.c13
-rw-r--r--drivers/pcmcia/m8xx_pcmcia.c18
-rw-r--r--drivers/pcmcia/omap_cf.c13
-rw-r--r--drivers/pcmcia/pcmcia_ioctl.c8
-rw-r--r--drivers/pcmcia/pcmcia_resource.c11
-rw-r--r--drivers/pcmcia/pd6729.c81
-rw-r--r--drivers/pcmcia/pxa2xx_base.c9
-rw-r--r--drivers/pcmcia/pxa2xx_vpac270.c229
-rw-r--r--drivers/pcmcia/rsrc_mgr.c1
-rw-r--r--drivers/pcmcia/rsrc_nonstatic.c66
-rw-r--r--drivers/pcmcia/sa1100_generic.c14
-rw-r--r--drivers/pcmcia/sa1111_generic.c13
-rw-r--r--drivers/pcmcia/sa11xx_base.c1
-rw-r--r--drivers/pcmcia/socket_sysfs.c1
-rw-r--r--drivers/pcmcia/tcic.c13
-rw-r--r--drivers/pcmcia/vrc4171_card.c13
-rw-r--r--drivers/pcmcia/xxs1500_ss.c1
-rw-r--r--drivers/pcmcia/yenta_socket.c18
-rw-r--r--drivers/platform/x86/Kconfig11
-rw-r--r--drivers/platform/x86/Makefile1
-rw-r--r--drivers/platform/x86/acer-wmi.c1
-rw-r--r--drivers/platform/x86/asus-laptop.c13
-rw-r--r--drivers/platform/x86/asus_acpi.c1
-rw-r--r--drivers/platform/x86/classmate-laptop.c1
-rw-r--r--drivers/platform/x86/dell-laptop.c1
-rw-r--r--drivers/platform/x86/dell-wmi.c4
-rw-r--r--drivers/platform/x86/eeepc-laptop.c4
-rw-r--r--drivers/platform/x86/eeepc-wmi.c413
-rw-r--r--drivers/platform/x86/fujitsu-laptop.c1
-rw-r--r--drivers/platform/x86/hp-wmi.c1
-rw-r--r--drivers/platform/x86/intel_menlow.c2
-rw-r--r--drivers/platform/x86/msi-wmi.c1
-rw-r--r--drivers/platform/x86/panasonic-laptop.c1
-rw-r--r--drivers/platform/x86/sony-laptop.c1
-rw-r--r--drivers/platform/x86/tc1100-wmi.c1
-rw-r--r--drivers/platform/x86/thinkpad_acpi.c1
-rw-r--r--drivers/platform/x86/topstar-laptop.c1
-rw-r--r--drivers/platform/x86/toshiba_acpi.c1
-rw-r--r--drivers/platform/x86/wmi.c1
-rw-r--r--drivers/pnp/isapnp/core.c1
-rw-r--r--drivers/pnp/manager.c1
-rw-r--r--drivers/pnp/pnpacpi/core.c1
-rw-r--r--drivers/pnp/pnpacpi/rsparser.c25
-rw-r--r--drivers/pnp/pnpbios/bioscalls.c1
-rw-r--r--drivers/pnp/pnpbios/rsparser.c1
-rw-r--r--drivers/pnp/resource.c5
-rw-r--r--drivers/power/bq27x00_battery.c1
-rw-r--r--drivers/power/da9030_battery.c1
-rw-r--r--drivers/power/ds2760_battery.c1
-rw-r--r--drivers/power/ds2782_battery.c1
-rw-r--r--drivers/power/max17040_battery.c1
-rw-r--r--drivers/power/max8925_power.c1
-rw-r--r--drivers/power/pcf50633-charger.c1
-rw-r--r--drivers/power/pmu_battery.c1
-rw-r--r--drivers/power/power_supply_leds.c1
-rw-r--r--drivers/power/power_supply_sysfs.c1
-rw-r--r--drivers/power/wm831x_backup.c1
-rw-r--r--drivers/power/wm831x_power.c1
-rw-r--r--drivers/power/wm97xx_battery.c1
-rw-r--r--drivers/pps/kapi.c1
-rw-r--r--drivers/ps3/ps3-lpm.c1
-rw-r--r--drivers/ps3/ps3-vuart.c1
-rw-r--r--drivers/ps3/ps3av.c1
-rw-r--r--drivers/regulator/core.c2
-rw-r--r--drivers/regulator/fixed.c1
-rw-r--r--drivers/regulator/lp3971.c11
-rw-r--r--drivers/regulator/max1586.c3
-rw-r--r--drivers/regulator/max8649.c4
-rw-r--r--drivers/regulator/max8660.c3
-rw-r--r--drivers/regulator/max8925-regulator.c8
-rw-r--r--drivers/regulator/mc13783-regulator.c4
-rw-r--r--drivers/regulator/tps65023-regulator.c1
-rw-r--r--drivers/regulator/tps6507x-regulator.c1
-rw-r--r--drivers/regulator/userspace-consumer.c1
-rw-r--r--drivers/regulator/virtual.c1
-rw-r--r--drivers/regulator/wm831x-dcdc.c1
-rw-r--r--drivers/regulator/wm831x-isink.c1
-rw-r--r--drivers/regulator/wm831x-ldo.c1
-rw-r--r--drivers/regulator/wm8994-regulator.c1
-rw-r--r--drivers/rtc/class.c1
-rw-r--r--drivers/rtc/rtc-at32ap700x.c1
-rw-r--r--drivers/rtc/rtc-at91sam9.c1
-rw-r--r--drivers/rtc/rtc-bfin.c1
-rw-r--r--drivers/rtc/rtc-bq4802.c1
-rw-r--r--drivers/rtc/rtc-coh901331.c1
-rw-r--r--drivers/rtc/rtc-ds1216.c1
-rw-r--r--drivers/rtc/rtc-ds1286.c1
-rw-r--r--drivers/rtc/rtc-ds1305.c1
-rw-r--r--drivers/rtc/rtc-ds1374.c1
-rw-r--r--drivers/rtc/rtc-ds1390.c1
-rw-r--r--drivers/rtc/rtc-ds1511.c1
-rw-r--r--drivers/rtc/rtc-ds1553.c1
-rw-r--r--drivers/rtc/rtc-ds1742.c1
-rw-r--r--drivers/rtc/rtc-ep93xx.c1
-rw-r--r--drivers/rtc/rtc-fm3130.c1
-rw-r--r--drivers/rtc/rtc-m48t35.c1
-rw-r--r--drivers/rtc/rtc-m48t59.c1
-rw-r--r--drivers/rtc/rtc-max8925.c1
-rw-r--r--drivers/rtc/rtc-mc13783.c24
-rw-r--r--drivers/rtc/rtc-mpc5121.c1
-rw-r--r--drivers/rtc/rtc-msm6242.c1
-rw-r--r--drivers/rtc/rtc-mv.c1
-rw-r--r--drivers/rtc/rtc-mxc.c27
-rw-r--r--drivers/rtc/rtc-nuc900.c1
-rw-r--r--drivers/rtc/rtc-pcap.c1
-rw-r--r--drivers/rtc/rtc-pcf2123.c1
-rw-r--r--drivers/rtc/rtc-pcf50633.c1
-rw-r--r--drivers/rtc/rtc-pcf8563.c1
-rw-r--r--drivers/rtc/rtc-pl030.c1
-rw-r--r--drivers/rtc/rtc-pl031.c1
-rw-r--r--drivers/rtc/rtc-pxa.c1
-rw-r--r--drivers/rtc/rtc-rp5c01.c1
-rw-r--r--drivers/rtc/rtc-rs5c348.c1
-rw-r--r--drivers/rtc/rtc-rs5c372.c1
-rw-r--r--drivers/rtc/rtc-rx8025.c1
-rw-r--r--drivers/rtc/rtc-s3c.c1
-rw-r--r--drivers/rtc/rtc-sh.c1
-rw-r--r--drivers/rtc/rtc-stk17ta8.c1
-rw-r--r--drivers/rtc/rtc-stmp3xxx.c1
-rw-r--r--drivers/rtc/rtc-tx4939.c1
-rw-r--r--drivers/rtc/rtc-v3020.c1
-rw-r--r--drivers/rtc/rtc-wm831x.c1
-rw-r--r--drivers/s390/block/dasd.c3
-rw-r--r--drivers/s390/block/dasd_3990_erp.c15
-rw-r--r--drivers/s390/block/dasd_alias.c1
-rw-r--r--drivers/s390/block/dasd_devmap.c1
-rw-r--r--drivers/s390/block/dasd_eckd.c4
-rw-r--r--drivers/s390/block/dasd_eer.c1
-rw-r--r--drivers/s390/block/dasd_ioctl.c1
-rw-r--r--drivers/s390/block/dasd_proc.c1
-rw-r--r--drivers/s390/block/xpram.c2
-rw-r--r--drivers/s390/char/con3270.c1
-rw-r--r--drivers/s390/char/fs3270.c1
-rw-r--r--drivers/s390/char/keyboard.c1
-rw-r--r--drivers/s390/char/monreader.c1
-rw-r--r--drivers/s390/char/monwriter.c1
-rw-r--r--drivers/s390/char/sclp_async.c2
-rw-r--r--drivers/s390/char/sclp_cmd.c14
-rw-r--r--drivers/s390/char/sclp_con.c1
-rw-r--r--drivers/s390/char/sclp_tty.c2
-rw-r--r--drivers/s390/char/sclp_vt220.c1
-rw-r--r--drivers/s390/char/tape_34xx.c1
-rw-r--r--drivers/s390/char/tape_3590.c1
-rw-r--r--drivers/s390/char/tape_class.c2
-rw-r--r--drivers/s390/char/tape_core.c1
-rw-r--r--drivers/s390/char/vmcp.c1
-rw-r--r--drivers/s390/char/vmlogrdr.c1
-rw-r--r--drivers/s390/char/vmur.c1
-rw-r--r--drivers/s390/char/vmwatchdog.c1
-rw-r--r--drivers/s390/char/zcore.c38
-rw-r--r--drivers/s390/cio/blacklist.c1
-rw-r--r--drivers/s390/cio/chp.c1
-rw-r--r--drivers/s390/cio/chsc.c29
-rw-r--r--drivers/s390/cio/chsc_sch.c3
-rw-r--r--drivers/s390/cio/cio.c18
-rw-r--r--drivers/s390/cio/css.c16
-rw-r--r--drivers/s390/cio/device_fsm.c2
-rw-r--r--drivers/s390/cio/qdio_main.c1
-rw-r--r--drivers/s390/cio/qdio_thinint.c1
-rw-r--r--drivers/s390/crypto/ap_bus.c1
-rw-r--r--drivers/s390/crypto/zcrypt_api.c1
-rw-r--r--drivers/s390/crypto/zcrypt_cex2a.c1
-rw-r--r--drivers/s390/crypto/zcrypt_pcica.c1
-rw-r--r--drivers/s390/crypto/zcrypt_pcicc.c1
-rw-r--r--drivers/s390/crypto/zcrypt_pcixcc.c1
-rw-r--r--drivers/s390/kvm/kvm_virtio.c1
-rw-r--r--drivers/s390/net/ctcm_dbug.c1
-rw-r--r--drivers/s390/net/ctcm_sysfs.c1
-rw-r--r--drivers/s390/net/fsm.c1
-rw-r--r--drivers/s390/net/lcs.c1
-rw-r--r--drivers/s390/net/qeth_core_main.c1
-rw-r--r--drivers/s390/net/qeth_l2_main.c1
-rw-r--r--drivers/s390/net/qeth_l3_main.c1
-rw-r--r--drivers/s390/net/qeth_l3_sys.c2
-rw-r--r--drivers/s390/net/smsgiucv.c1
-rw-r--r--drivers/s390/net/smsgiucv_app.c1
-rw-r--r--drivers/s390/scsi/zfcp_aux.c1
-rw-r--r--drivers/s390/scsi/zfcp_cfdc.c1
-rw-r--r--drivers/s390/scsi/zfcp_dbf.c1
-rw-r--r--drivers/s390/scsi/zfcp_fc.c1
-rw-r--r--drivers/s390/scsi/zfcp_fsf.c7
-rw-r--r--drivers/s390/scsi/zfcp_qdio.c1
-rw-r--r--drivers/s390/scsi/zfcp_scsi.c1
-rw-r--r--drivers/s390/scsi/zfcp_sysfs.c1
-rw-r--r--drivers/sbus/char/bbc_envctrl.c1
-rw-r--r--drivers/sbus/char/display7seg.c1
-rw-r--r--drivers/sbus/char/envctrl.c1
-rw-r--r--drivers/sbus/char/flash.c1
-rw-r--r--drivers/sbus/char/jsflash.c1
-rw-r--r--drivers/scsi/3w-9xxx.c1
-rw-r--r--drivers/scsi/3w-sas.c1
-rw-r--r--drivers/scsi/3w-xxxx.c1
-rw-r--r--drivers/scsi/53c700.c1
-rw-r--r--drivers/scsi/BusLogic.c1
-rw-r--r--drivers/scsi/NCR_D700.c1
-rw-r--r--drivers/scsi/NCR_Q720.c1
-rw-r--r--drivers/scsi/a100u2w.c1
-rw-r--r--drivers/scsi/a2091.c1
-rw-r--r--drivers/scsi/a3000.c1
-rw-r--r--drivers/scsi/a4000t.c1
-rw-r--r--drivers/scsi/aacraid/rx.c1
-rw-r--r--drivers/scsi/aacraid/sa.c1
-rw-r--r--drivers/scsi/advansys.c58
-rw-r--r--drivers/scsi/aha152x.c1
-rw-r--r--drivers/scsi/aha1542.c1
-rw-r--r--drivers/scsi/aha1740.c1
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm.c1
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm.c1
-rw-r--r--drivers/scsi/aic94xx/aic94xx_hwi.c1
-rw-r--r--drivers/scsi/aic94xx/aic94xx_init.c1
-rw-r--r--drivers/scsi/aic94xx/aic94xx_scb.c1
-rw-r--r--drivers/scsi/aic94xx/aic94xx_sds.c1
-rw-r--r--drivers/scsi/aic94xx/aic94xx_seq.c1
-rw-r--r--drivers/scsi/aic94xx/aic94xx_tmf.c1
-rw-r--r--drivers/scsi/arcmsr/arcmsr_hba.c1
-rw-r--r--drivers/scsi/atari_NCR5380.c1
-rw-r--r--drivers/scsi/atp870u.c1
-rw-r--r--drivers/scsi/be2iscsi/be_main.c1
-rw-r--r--drivers/scsi/be2iscsi/be_mgmt.c1
-rw-r--r--drivers/scsi/bfa/bfad.c1
-rw-r--r--drivers/scsi/bfa/bfad_attr.c1
-rw-r--r--drivers/scsi/bfa/bfad_im.c1
-rw-r--r--drivers/scsi/bfa/rport.c1
-rw-r--r--drivers/scsi/bnx2i/bnx2i.h2
-rw-r--r--drivers/scsi/bnx2i/bnx2i_hwi.c1
-rw-r--r--drivers/scsi/bnx2i/bnx2i_init.c13
-rw-r--r--drivers/scsi/bnx2i/bnx2i_iscsi.c14
-rw-r--r--drivers/scsi/bvme6000_scsi.c1
-rw-r--r--drivers/scsi/ch.c1
-rw-r--r--drivers/scsi/cxgb3i/cxgb3i_ddp.c1
-rw-r--r--drivers/scsi/cxgb3i/cxgb3i_ddp.h1
-rw-r--r--drivers/scsi/cxgb3i/cxgb3i_iscsi.c1
-rw-r--r--drivers/scsi/cxgb3i/cxgb3i_offload.c1
-rw-r--r--drivers/scsi/cxgb3i/cxgb3i_pdu.c1
-rw-r--r--drivers/scsi/dc395x.c1
-rw-r--r--drivers/scsi/device_handler/scsi_dh.c1
-rw-r--r--drivers/scsi/device_handler/scsi_dh_alua.c1
-rw-r--r--drivers/scsi/device_handler/scsi_dh_emc.c1
-rw-r--r--drivers/scsi/device_handler/scsi_dh_hp_sw.c1
-rw-r--r--drivers/scsi/device_handler/scsi_dh_rdac.c1
-rw-r--r--drivers/scsi/dpt_i2o.c15
-rw-r--r--drivers/scsi/eata.c1
-rw-r--r--drivers/scsi/eata_pio.c1
-rw-r--r--drivers/scsi/fcoe/fcoe.c1
-rw-r--r--drivers/scsi/fcoe/libfcoe.c1
-rw-r--r--drivers/scsi/fd_mcs.c1
-rw-r--r--drivers/scsi/fdomain.c1
-rw-r--r--drivers/scsi/fnic/fnic_fcs.c1
-rw-r--r--drivers/scsi/fnic/fnic_main.c1
-rw-r--r--drivers/scsi/fnic/fnic_scsi.c1
-rw-r--r--drivers/scsi/fnic/vnic_dev.c1
-rw-r--r--drivers/scsi/fnic/vnic_rq.c1
-rw-r--r--drivers/scsi/fnic/vnic_wq.c1
-rw-r--r--drivers/scsi/gdth.c1
-rw-r--r--drivers/scsi/gdth_proc.c1
-rw-r--r--drivers/scsi/gvp11.c1
-rw-r--r--drivers/scsi/hosts.c1
-rw-r--r--drivers/scsi/hptiop.c1
-rw-r--r--drivers/scsi/ibmvscsi/ibmvfc.c1
-rw-r--r--drivers/scsi/ibmvscsi/ibmvscsi.c30
-rw-r--r--drivers/scsi/ibmvscsi/ibmvstgt.c1
-rw-r--r--drivers/scsi/ibmvscsi/rpa_vscsi.c1
-rw-r--r--drivers/scsi/imm.c1
-rw-r--r--drivers/scsi/ipr.c1
-rw-r--r--drivers/scsi/iscsi_tcp.c3
-rw-r--r--drivers/scsi/jazz_esp.c1
-rw-r--r--drivers/scsi/lasi700.c1
-rw-r--r--drivers/scsi/libfc/fc_disc.c1
-rw-r--r--drivers/scsi/libfc/fc_exch.c2
-rw-r--r--drivers/scsi/libfc/fc_fcp.c1
-rw-r--r--drivers/scsi/libfc/fc_frame.c1
-rw-r--r--drivers/scsi/libfc/fc_lport.c1
-rw-r--r--drivers/scsi/libfc/fc_rport.c1
-rw-r--r--drivers/scsi/libiscsi.c8
-rw-r--r--drivers/scsi/libiscsi_tcp.c1
-rw-r--r--drivers/scsi/libsas/sas_ata.c5
-rw-r--r--drivers/scsi/libsas/sas_discover.c1
-rw-r--r--drivers/scsi/libsas/sas_expander.c1
-rw-r--r--drivers/scsi/libsas/sas_host_smp.c1
-rw-r--r--drivers/scsi/libsas/sas_init.c1
-rw-r--r--drivers/scsi/libsas/sas_scsi_host.c5
-rw-r--r--drivers/scsi/libsrp.c1
-rw-r--r--drivers/scsi/lpfc/lpfc_attr.c1
-rw-r--r--drivers/scsi/lpfc/lpfc_bsg.c5
-rw-r--r--drivers/scsi/lpfc/lpfc_ct.c1
-rw-r--r--drivers/scsi/lpfc/lpfc_debugfs.c1
-rw-r--r--drivers/scsi/lpfc/lpfc_els.c1
-rw-r--r--drivers/scsi/lpfc/lpfc_hbadisc.c1
-rw-r--r--drivers/scsi/lpfc/lpfc_init.c1
-rw-r--r--drivers/scsi/lpfc/lpfc_mbox.c1
-rw-r--r--drivers/scsi/lpfc/lpfc_mem.c1
-rw-r--r--drivers/scsi/lpfc/lpfc_nportdisc.c1
-rw-r--r--drivers/scsi/lpfc/lpfc_scsi.c1
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.c1
-rw-r--r--drivers/scsi/lpfc/lpfc_vport.c1
-rw-r--r--drivers/scsi/mac_esp.c1
-rw-r--r--drivers/scsi/megaraid.c1
-rw-r--r--drivers/scsi/megaraid/megaraid_mbox.c1
-rw-r--r--drivers/scsi/megaraid/megaraid_mm.c1
-rw-r--r--drivers/scsi/megaraid/megaraid_sas.c1
-rw-r--r--drivers/scsi/mesh.c1
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_config.c1
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_scsih.c1
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_transport.c1
-rw-r--r--drivers/scsi/mvme16x_scsi.c1
-rw-r--r--drivers/scsi/mvsas/mv_sas.h1
-rw-r--r--drivers/scsi/ncr53c8xx.c1
-rw-r--r--drivers/scsi/nsp32.c1
-rw-r--r--drivers/scsi/osd/osd_initiator.c2
-rw-r--r--drivers/scsi/osd/osd_uld.c1
-rw-r--r--drivers/scsi/osst.c1
-rw-r--r--drivers/scsi/pm8001/pm8001_ctl.c1
-rw-r--r--drivers/scsi/pm8001/pm8001_hwi.c1
-rw-r--r--drivers/scsi/pm8001/pm8001_init.c1
-rw-r--r--drivers/scsi/pm8001/pm8001_sas.c1
-rw-r--r--drivers/scsi/pmcraid.c1
-rw-r--r--drivers/scsi/ppa.c1
-rw-r--r--drivers/scsi/ps3rom.c1
-rw-r--r--drivers/scsi/qla1280.c162
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c8
-rw-r--r--drivers/scsi/qla2xxx/qla_fw.h18
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c1
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c38
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c9
-rw-r--r--drivers/scsi/qla2xxx/qla_mid.c1
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c5
-rw-r--r--drivers/scsi/qla2xxx/qla_sup.c1
-rw-r--r--drivers/scsi/qla2xxx/qla_version.h4
-rw-r--r--drivers/scsi/qla4xxx/ql4_mbx.c2
-rw-r--r--drivers/scsi/qla4xxx/ql4_os.c1
-rw-r--r--drivers/scsi/qlogicpti.c2
-rw-r--r--drivers/scsi/scsi_debug.c4
-rw-r--r--drivers/scsi/scsi_devinfo.c1
-rw-r--r--drivers/scsi/scsi_error.c16
-rw-r--r--drivers/scsi/scsi_netlink.c1
-rw-r--r--drivers/scsi/scsi_proc.c2
-rw-r--r--drivers/scsi/scsi_scan.c1
-rw-r--r--drivers/scsi/scsi_sysfs.c1
-rw-r--r--drivers/scsi/scsi_tgt_if.c1
-rw-r--r--drivers/scsi/scsi_tgt_lib.c1
-rw-r--r--drivers/scsi/scsi_transport_fc.c5
-rw-r--r--drivers/scsi/scsi_transport_iscsi.c1
-rw-r--r--drivers/scsi/scsi_transport_spi.c1
-rw-r--r--drivers/scsi/scsicam.c1
-rw-r--r--drivers/scsi/sd.c4
-rw-r--r--drivers/scsi/ses.c1
-rw-r--r--drivers/scsi/sg.c1
-rw-r--r--drivers/scsi/sim710.c1
-rw-r--r--drivers/scsi/sni_53c710.c1
-rw-r--r--drivers/scsi/sr.c1
-rw-r--r--drivers/scsi/sr_ioctl.c1
-rw-r--r--drivers/scsi/sr_vendor.c1
-rw-r--r--drivers/scsi/st.c1
-rw-r--r--drivers/scsi/stex.c1
-rw-r--r--drivers/scsi/sun3_NCR5380.c1
-rw-r--r--drivers/scsi/sun3x_esp.c1
-rw-r--r--drivers/scsi/sun_esp.c1
-rw-r--r--drivers/scsi/tmscsim.c1
-rw-r--r--drivers/scsi/u14-34f.c1
-rw-r--r--drivers/scsi/vmw_pvscsi.c1
-rw-r--r--drivers/scsi/wd7000.c3
-rw-r--r--drivers/scsi/zorro7xx.c1
-rw-r--r--drivers/serial/68328serial.c1
-rw-r--r--drivers/serial/8250.c1
-rw-r--r--drivers/serial/8250_gsc.c1
-rw-r--r--drivers/serial/8250_hp300.c1
-rw-r--r--drivers/serial/8250_pnp.c2
-rw-r--r--drivers/serial/Kconfig7
-rw-r--r--drivers/serial/amba-pl010.c1
-rw-r--r--drivers/serial/amba-pl011.c1
-rw-r--r--drivers/serial/bfin_5xx.c1
-rw-r--r--drivers/serial/bfin_sport_uart.c1
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_cpm1.c1
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_cpm2.c5
-rw-r--r--drivers/serial/imx.c1
-rw-r--r--drivers/serial/ioc3_serial.c1
-rw-r--r--drivers/serial/ioc4_serial.c1
-rw-r--r--drivers/serial/jsm/jsm_driver.c1
-rw-r--r--drivers/serial/jsm/jsm_tty.c1
-rw-r--r--drivers/serial/max3100.c1
-rw-r--r--drivers/serial/mcf.c6
-rw-r--r--drivers/serial/mpc52xx_uart.c33
-rw-r--r--drivers/serial/mpsc.c1
-rw-r--r--drivers/serial/mux.c1
-rw-r--r--drivers/serial/of_serial.c1
-rw-r--r--drivers/serial/pmac_zilog.c5
-rw-r--r--drivers/serial/pxa.c1
-rw-r--r--drivers/serial/serial_cs.c10
-rw-r--r--drivers/serial/serial_ks8695.c1
-rw-r--r--drivers/serial/sh-sci.c6
-rw-r--r--drivers/serial/sh-sci.h35
-rw-r--r--drivers/serial/sunsu.c5
-rw-r--r--drivers/serial/timbuart.c1
-rw-r--r--drivers/serial/ucc_uart.c1
-rw-r--r--drivers/sh/intc.c32
-rw-r--r--drivers/sn/ioc3.c1
-rw-r--r--drivers/spi/amba-pl022.c1
-rw-r--r--drivers/spi/atmel_spi.c1
-rw-r--r--drivers/spi/au1550_spi.c1
-rw-r--r--drivers/spi/davinci_spi.c1
-rw-r--r--drivers/spi/dw_spi.c1
-rw-r--r--drivers/spi/dw_spi_mmio.c1
-rw-r--r--drivers/spi/dw_spi_pci.c1
-rw-r--r--drivers/spi/mpc52xx_psc_spi.c1
-rw-r--r--drivers/spi/mpc52xx_spi.c1
-rw-r--r--drivers/spi/omap2_mcspi.c6
-rw-r--r--drivers/spi/omap_spi_100k.c1
-rw-r--r--drivers/spi/omap_uwire.c1
-rw-r--r--drivers/spi/pxa2xx_spi.c26
-rw-r--r--drivers/spi/spi.c9
-rw-r--r--drivers/spi/spi_bfin5xx.c1
-rw-r--r--drivers/spi/spi_bitbang.c1
-rw-r--r--drivers/spi/spi_imx.c1
-rw-r--r--drivers/spi/spi_mpc8xxx.c1
-rw-r--r--drivers/spi/spi_nuc900.c1
-rw-r--r--drivers/spi/spi_ppc4xx.c1
-rw-r--r--drivers/spi/spi_s3c24xx.c1
-rw-r--r--drivers/spi/tle62x0.c1
-rw-r--r--drivers/spi/xilinx_spi_of.c1
-rw-r--r--drivers/ssb/driver_gige.c1
-rw-r--r--drivers/ssb/driver_pcicore.c29
-rw-r--r--drivers/ssb/main.c1
-rw-r--r--drivers/ssb/pci.c1
-rw-r--r--drivers/ssb/pcihost_wrapper.c1
-rw-r--r--drivers/ssb/sprom.c1
-rw-r--r--drivers/staging/batman-adv/device.c1
-rw-r--r--drivers/staging/batman-adv/main.h1
-rw-r--r--drivers/staging/batman-adv/soft-interface.c1
-rw-r--r--drivers/staging/comedi/drivers/8255.c1
-rw-r--r--drivers/staging/comedi/drivers/addi-data/addi_common.c2
-rw-r--r--drivers/staging/comedi/drivers/adl_pci9118.c1
-rw-r--r--drivers/staging/comedi/drivers/amplc_dio200.c1
-rw-r--r--drivers/staging/comedi/drivers/amplc_pci224.c1
-rw-r--r--drivers/staging/comedi/drivers/cb_das16_cs.c1
-rw-r--r--drivers/staging/comedi/drivers/comedi_bond.c1
-rw-r--r--drivers/staging/comedi/drivers/das08_cs.c1
-rw-r--r--drivers/staging/comedi/drivers/das16.c1
-rw-r--r--drivers/staging/comedi/drivers/das1800.c1
-rw-r--r--drivers/staging/comedi/drivers/dt282x.c1
-rw-r--r--drivers/staging/comedi/drivers/jr3_pci.c1
-rw-r--r--drivers/staging/comedi/drivers/ni_65xx.c1
-rw-r--r--drivers/staging/comedi/drivers/ni_670x.c1
-rw-r--r--drivers/staging/comedi/drivers/ni_at_a2150.c1
-rw-r--r--drivers/staging/comedi/drivers/ni_daq_700.c1
-rw-r--r--drivers/staging/comedi/drivers/ni_daq_dio24.c1
-rw-r--r--drivers/staging/comedi/drivers/ni_labpc.c1
-rw-r--r--drivers/staging/comedi/drivers/ni_labpc_cs.c1
-rw-r--r--drivers/staging/comedi/drivers/pcl812.c1
-rw-r--r--drivers/staging/comedi/drivers/pcl816.c1
-rw-r--r--drivers/staging/comedi/drivers/pcl818.c1
-rw-r--r--drivers/staging/comedi/drivers/pcmmio.c1
-rw-r--r--drivers/staging/comedi/drivers/pcmuio.c1
-rw-r--r--drivers/staging/comedi/drivers/serial2002.c1
-rw-r--r--drivers/staging/comedi/drivers/unioxx5.c1
-rw-r--r--drivers/staging/comedi/kcomedilib/kcomedilib_main.c1
-rw-r--r--drivers/staging/comedi/kcomedilib/ksyms.c1
-rw-r--r--drivers/staging/crystalhd/crystalhd_hw.c1
-rw-r--r--drivers/staging/crystalhd/crystalhd_lnx.c1
-rw-r--r--drivers/staging/crystalhd/crystalhd_misc.c2
-rw-r--r--drivers/staging/cx25821/cx25821-alsa.c1
-rw-r--r--drivers/staging/cx25821/cx25821-audio-upstream.c1
-rw-r--r--drivers/staging/cx25821/cx25821-audups11.c2
-rw-r--r--drivers/staging/cx25821/cx25821-core.c1
-rw-r--r--drivers/staging/cx25821/cx25821-video-upstream-ch2.c1
-rw-r--r--drivers/staging/cx25821/cx25821-video-upstream.c1
-rw-r--r--drivers/staging/dream/camera/msm_camera.c1
-rw-r--r--drivers/staging/dream/camera/msm_v4l2.c1
-rw-r--r--drivers/staging/dream/camera/msm_vfe7x.c1
-rw-r--r--drivers/staging/dream/camera/msm_vfe8x.c1
-rw-r--r--drivers/staging/dream/camera/mt9d112.c1
-rw-r--r--drivers/staging/dream/camera/mt9p012_fox.c1
-rw-r--r--drivers/staging/dream/camera/mt9t013.c1
-rw-r--r--drivers/staging/dream/camera/s5k3e2fx.c1
-rw-r--r--drivers/staging/dream/gpio_axis.c1
-rw-r--r--drivers/staging/dream/gpio_event.c1
-rw-r--r--drivers/staging/dream/gpio_input.c1
-rw-r--r--drivers/staging/dream/gpio_matrix.c1
-rw-r--r--drivers/staging/dream/pmem.c1
-rw-r--r--drivers/staging/dream/qdsp5/adsp.c1
-rw-r--r--drivers/staging/dream/qdsp5/adsp_driver.c1
-rw-r--r--drivers/staging/dream/qdsp5/audio_aac.c1
-rw-r--r--drivers/staging/dream/qdsp5/audio_amrnb.c1
-rw-r--r--drivers/staging/dream/qdsp5/audio_evrc.c1
-rw-r--r--drivers/staging/dream/qdsp5/audio_in.c1
-rw-r--r--drivers/staging/dream/qdsp5/audio_mp3.c1
-rw-r--r--drivers/staging/dream/qdsp5/audio_out.c1
-rw-r--r--drivers/staging/dream/qdsp5/audio_qcelp.c1
-rw-r--r--drivers/staging/dream/qdsp5/audmgr.c1
-rw-r--r--drivers/staging/dream/smd/smd_rpcrouter.c1
-rw-r--r--drivers/staging/dream/smd/smd_rpcrouter_device.c1
-rw-r--r--drivers/staging/dream/smd/smd_rpcrouter_servers.c1
-rw-r--r--drivers/staging/dream/synaptics_i2c_rmi.c1
-rw-r--r--drivers/staging/dt3155/allocator.c1
-rw-r--r--drivers/staging/dt3155/dt3155_drv.c18
-rw-r--r--drivers/staging/dt3155/dt3155_isr.c2
-rw-r--r--drivers/staging/et131x/et1310_eeprom.c1
-rw-r--r--drivers/staging/et131x/et1310_mac.c3
-rw-r--r--drivers/staging/et131x/et1310_phy.c1
-rw-r--r--drivers/staging/et131x/et1310_pm.c1
-rw-r--r--drivers/staging/et131x/et131x_initpci.c1
-rw-r--r--drivers/staging/et131x/et131x_isr.c1
-rw-r--r--drivers/staging/et131x/et131x_netdev.c1
-rw-r--r--drivers/staging/go7007/go7007-driver.c1
-rw-r--r--drivers/staging/go7007/go7007-fw.c1
-rw-r--r--drivers/staging/go7007/go7007-v4l2.c1
-rw-r--r--drivers/staging/go7007/s2250-board.c1
-rw-r--r--drivers/staging/go7007/s2250-loader.c1
-rw-r--r--drivers/staging/go7007/snd-go7007.c1
-rw-r--r--drivers/staging/go7007/wis-saa7113.c1
-rw-r--r--drivers/staging/go7007/wis-saa7115.c1
-rw-r--r--drivers/staging/go7007/wis-sony-tuner.c1
-rw-r--r--drivers/staging/go7007/wis-tw2804.c1
-rw-r--r--drivers/staging/go7007/wis-tw9903.c1
-rw-r--r--drivers/staging/hv/Channel.c1
-rw-r--r--drivers/staging/hv/ChannelMgmt.c1
-rw-r--r--drivers/staging/hv/Connection.c1
-rw-r--r--drivers/staging/hv/Hv.c3
-rw-r--r--drivers/staging/hv/NetVsc.c1
-rw-r--r--drivers/staging/hv/RndisFilter.c2
-rw-r--r--drivers/staging/hv/StorVsc.c1
-rw-r--r--drivers/staging/hv/Vmbus.c1
-rw-r--r--drivers/staging/hv/blkvsc_drv.c1
-rw-r--r--drivers/staging/hv/netvsc_drv.c4
-rw-r--r--drivers/staging/hv/osd.c1
-rw-r--r--drivers/staging/hv/storvsc_drv.c1
-rw-r--r--drivers/staging/hv/vmbus_drv.c1
-rw-r--r--drivers/staging/iio/accel/kxsd9.c1
-rw-r--r--drivers/staging/iio/accel/lis3l02dq_core.c3
-rw-r--r--drivers/staging/iio/accel/lis3l02dq_ring.c4
-rw-r--r--drivers/staging/iio/accel/sca3000_core.c1
-rw-r--r--drivers/staging/iio/accel/sca3000_ring.c1
-rw-r--r--drivers/staging/iio/adc/max1363_core.c3
-rw-r--r--drivers/staging/iio/adc/max1363_ring.c1
-rw-r--r--drivers/staging/iio/industrialio-core.c4
-rw-r--r--drivers/staging/iio/industrialio-ring.c1
-rw-r--r--drivers/staging/iio/industrialio-trigger.c1
-rw-r--r--drivers/staging/iio/light/tsl2563.c3
-rw-r--r--drivers/staging/iio/ring_sw.c3
-rw-r--r--drivers/staging/iio/trigger/iio-trig-gpio.c1
-rw-r--r--drivers/staging/iio/trigger/iio-trig-periodic-rtc.c1
-rw-r--r--drivers/staging/line6/capture.c2
-rw-r--r--drivers/staging/line6/driver.c1
-rw-r--r--drivers/staging/line6/dumprequest.c3
-rw-r--r--drivers/staging/line6/midi.c1
-rw-r--r--drivers/staging/line6/pcm.c2
-rw-r--r--drivers/staging/line6/playback.c2
-rw-r--r--drivers/staging/line6/pod.c2
-rw-r--r--drivers/staging/line6/variax.c2
-rw-r--r--drivers/staging/netwave/netwave_cs.c1
-rw-r--r--drivers/staging/octeon/cvmx-helper-board.c8
-rw-r--r--drivers/staging/octeon/ethernet-mem.c1
-rw-r--r--drivers/staging/octeon/ethernet.c1
-rw-r--r--drivers/staging/otus/ioctl.c1
-rw-r--r--drivers/staging/otus/usbdrv.c1
-rw-r--r--drivers/staging/otus/usbdrv.h1
-rw-r--r--drivers/staging/otus/wrap_mem.c1
-rw-r--r--drivers/staging/otus/wrap_pkt.c1
-rw-r--r--drivers/staging/otus/wrap_usb.c1
-rw-r--r--drivers/staging/otus/wwrap.c1
-rw-r--r--drivers/staging/otus/zdusb.c1
-rw-r--r--drivers/staging/poch/poch.c1
-rw-r--r--drivers/staging/pohmelfs/config.c1
-rw-r--r--drivers/staging/pohmelfs/dir.c1
-rw-r--r--drivers/staging/pohmelfs/lock.c1
-rw-r--r--drivers/staging/pohmelfs/net.c1
-rw-r--r--drivers/staging/pohmelfs/path_entry.c1
-rw-r--r--drivers/staging/ramzswap/ramzswap_drv.c1
-rw-r--r--drivers/staging/rt2860/pci_main_dev.c1
-rw-r--r--drivers/staging/rt2860/rt_linux.c1
-rw-r--r--drivers/staging/rt2860/usb_main_dev.c1
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c1
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c1
-rw-r--r--drivers/staging/rtl8187se/r8180_core.c1
-rw-r--r--drivers/staging/rtl8192e/ieee80211/ieee80211_softmac.c1
-rw-r--r--drivers/staging/rtl8192e/ieee80211/ieee80211_wx.c1
-rw-r--r--drivers/staging/rtl8192e/ieee80211/rtl819x_TSProc.c1
-rw-r--r--drivers/staging/rtl8192e/r8192E_core.c1
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_softmac.c1
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_wx.c1
-rw-r--r--drivers/staging/rtl8192su/ieee80211/rtl819x_TSProc.c1
-rw-r--r--drivers/staging/rtl8192su/r8192U_core.c4
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c1
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c1
-rw-r--r--drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c1
-rw-r--r--drivers/staging/rtl8192u/r8192U_core.c1
-rw-r--r--drivers/staging/sep/sep_driver.c1
-rw-r--r--drivers/staging/sm7xx/smtcfb.c1
-rw-r--r--drivers/staging/strip/strip.c1
-rw-r--r--drivers/staging/udlfb/udlfb.c1
-rw-r--r--drivers/staging/usbip/stub_dev.c2
-rw-r--r--drivers/staging/usbip/stub_main.c1
-rw-r--r--drivers/staging/usbip/stub_rx.c2
-rw-r--r--drivers/staging/usbip/stub_tx.c2
-rw-r--r--drivers/staging/usbip/usbip_common.c1
-rw-r--r--drivers/staging/usbip/usbip_event.c3
-rw-r--r--drivers/staging/usbip/vhci_hcd.c1
-rw-r--r--drivers/staging/usbip/vhci_rx.c2
-rw-r--r--drivers/staging/usbip/vhci_tx.c2
-rw-r--r--drivers/staging/vme/bridges/vme_ca91cx42.c1
-rw-r--r--drivers/staging/vme/bridges/vme_tsi148.c4
-rw-r--r--drivers/staging/vme/devices/vme_user.c1
-rw-r--r--drivers/staging/vme/vme.c1
-rw-r--r--drivers/staging/vt6655/device_main.c1
-rw-r--r--drivers/staging/winbond/wb35reg.c1
-rw-r--r--drivers/staging/winbond/wb35rx.c1
-rw-r--r--drivers/staging/winbond/wb35tx.c1
-rw-r--r--drivers/staging/wlags49_h2/wl_cs.c1
-rw-r--r--drivers/staging/wlags49_h2/wl_netdev.c1
-rw-r--r--drivers/staging/wlags49_h2/wl_pci.c1
-rw-r--r--drivers/staging/wlags49_h2/wl_priv.c1
-rw-r--r--drivers/staging/wlan-ng/p80211req.c1
-rw-r--r--drivers/staging/wlan-ng/p80211wep.c1
-rw-r--r--drivers/staging/wlan-ng/p80211wext.c1
-rw-r--r--drivers/staging/wlan-ng/prism2fw.c1
-rw-r--r--drivers/staging/wlan-ng/prism2mgmt.c1
-rw-r--r--drivers/staging/wlan-ng/prism2mib.c1
-rw-r--r--drivers/tc/tc.c1
-rw-r--r--drivers/thermal/thermal_sys.c4
-rw-r--r--drivers/uio/uio.c1
-rw-r--r--drivers/uio/uio_aec.c1
-rw-r--r--drivers/uio/uio_cif.c1
-rw-r--r--drivers/uio/uio_netx.c1
-rw-r--r--drivers/uio/uio_pci_generic.c1
-rw-r--r--drivers/uio/uio_pdrv.c1
-rw-r--r--drivers/uio/uio_pdrv_genirq.c1
-rw-r--r--drivers/uio/uio_sercos3.c1
-rw-r--r--drivers/usb/atm/speedtch.c1
-rw-r--r--drivers/usb/atm/ueagle-atm.c1
-rw-r--r--drivers/usb/c67x00/c67x00-drv.c1
-rw-r--r--drivers/usb/c67x00/c67x00-sched.c1
-rw-r--r--drivers/usb/class/cdc-acm.c5
-rw-r--r--drivers/usb/class/cdc-wdm.c134
-rw-r--r--drivers/usb/class/usbtmc.c1
-rw-r--r--drivers/usb/core/Kconfig2
-rw-r--r--drivers/usb/core/devices.c2
-rw-r--r--drivers/usb/core/devio.c17
-rw-r--r--drivers/usb/core/driver.c50
-rw-r--r--drivers/usb/core/endpoint.c1
-rw-r--r--drivers/usb/core/file.c1
-rw-r--r--drivers/usb/core/generic.c2
-rw-r--r--drivers/usb/core/inode.c4
-rw-r--r--drivers/usb/core/urb.c1
-rw-r--r--drivers/usb/core/usb.c20
-rw-r--r--drivers/usb/gadget/Kconfig2
-rw-r--r--drivers/usb/gadget/at91_udc.c9
-rw-r--r--drivers/usb/gadget/atmel_usba_udc.c1
-rw-r--r--drivers/usb/gadget/ci13xxx_udc.c1
-rw-r--r--drivers/usb/gadget/config.c1
-rw-r--r--drivers/usb/gadget/epautoconf.c2
-rw-r--r--drivers/usb/gadget/f_acm.c1
-rw-r--r--drivers/usb/gadget/f_audio.c1
-rw-r--r--drivers/usb/gadget/f_ecm.c1
-rw-r--r--drivers/usb/gadget/f_eem.c1
-rw-r--r--drivers/usb/gadget/f_loopback.c1
-rw-r--r--drivers/usb/gadget/f_mass_storage.c3
-rw-r--r--drivers/usb/gadget/f_obex.c1
-rw-r--r--drivers/usb/gadget/f_phonet.c1
-rw-r--r--drivers/usb/gadget/f_rndis.c1
-rw-r--r--drivers/usb/gadget/f_serial.c1
-rw-r--r--drivers/usb/gadget/f_sourcesink.c1
-rw-r--r--drivers/usb/gadget/f_subset.c1
-rw-r--r--drivers/usb/gadget/gadget_chips.h8
-rw-r--r--drivers/usb/gadget/gmidi.c1
-rw-r--r--drivers/usb/gadget/goku_udc.c2
-rw-r--r--drivers/usb/gadget/imx_udc.c1
-rw-r--r--drivers/usb/gadget/lh7a40x_udc.c1
-rw-r--r--drivers/usb/gadget/m66592-udc.c1
-rw-r--r--drivers/usb/gadget/multi.c2
-rw-r--r--drivers/usb/gadget/pxa27x_udc.c1
-rw-r--r--drivers/usb/gadget/r8a66597-udc.c1
-rw-r--r--drivers/usb/gadget/rndis.c1
-rw-r--r--drivers/usb/gadget/s3c-hsotg.c8
-rw-r--r--drivers/usb/gadget/u_audio.c1
-rw-r--r--drivers/usb/gadget/u_ether.c1
-rw-r--r--drivers/usb/gadget/u_serial.c1
-rw-r--r--drivers/usb/gadget/zero.c1
-rw-r--r--drivers/usb/host/Makefile4
-rw-r--r--drivers/usb/host/ehci-hcd.c5
-rw-r--r--drivers/usb/host/ehci-hub.c2
-rw-r--r--drivers/usb/host/ehci-mem.c2
-rw-r--r--drivers/usb/host/ehci-mxc.c1
-rw-r--r--drivers/usb/host/ehci-omap.c7
-rw-r--r--drivers/usb/host/ehci-sched.c68
-rw-r--r--drivers/usb/host/ehci.h10
-rw-r--r--drivers/usb/host/fhci-hcd.c1
-rw-r--r--drivers/usb/host/fhci-mem.c1
-rw-r--r--drivers/usb/host/fhci-q.c1
-rw-r--r--drivers/usb/host/fhci-tds.c1
-rw-r--r--drivers/usb/host/hwa-hc.c1
-rw-r--r--drivers/usb/host/imx21-hcd.c1
-rw-r--r--drivers/usb/host/isp116x-hcd.c1
-rw-r--r--drivers/usb/host/ohci-at91.c2
-rw-r--r--drivers/usb/host/ohci-da8xx.c2
-rw-r--r--drivers/usb/host/ohci-hub.c2
-rw-r--r--drivers/usb/host/ohci-q.c1
-rw-r--r--drivers/usb/host/oxu210hp-hcd.c6
-rw-r--r--drivers/usb/host/r8a66597-hcd.c17
-rw-r--r--drivers/usb/host/sl811-hcd.c6
-rw-r--r--drivers/usb/host/uhci-debug.c1
-rw-r--r--drivers/usb/host/whci/asl.c1
-rw-r--r--drivers/usb/host/whci/debug.c1
-rw-r--r--drivers/usb/host/whci/init.c1
-rw-r--r--drivers/usb/host/whci/pzl.c1
-rw-r--r--drivers/usb/host/whci/qset.c1
-rw-r--r--drivers/usb/host/xhci-mem.c75
-rw-r--r--drivers/usb/host/xhci-ring.c1
-rw-r--r--drivers/usb/host/xhci.c (renamed from drivers/usb/host/xhci-hcd.c)2
-rw-r--r--drivers/usb/host/xhci.h4
-rw-r--r--drivers/usb/misc/appledisplay.c1
-rw-r--r--drivers/usb/misc/cypress_cy7c63.c1
-rw-r--r--drivers/usb/misc/cytherm.c1
-rw-r--r--drivers/usb/misc/isight_firmware.c1
-rw-r--r--drivers/usb/misc/sisusbvga/sisusb_con.c1
-rw-r--r--drivers/usb/misc/sisusbvga/sisusb_init.c1
-rw-r--r--drivers/usb/misc/trancevibrator.c1
-rw-r--r--drivers/usb/misc/usbsevseg.c15
-rw-r--r--drivers/usb/misc/uss720.c1
-rw-r--r--drivers/usb/mon/mon_bin.c1
-rw-r--r--drivers/usb/mon/mon_main.c1
-rw-r--r--drivers/usb/mon/mon_stat.c1
-rw-r--r--drivers/usb/mon/mon_text.c1
-rw-r--r--drivers/usb/musb/Kconfig2
-rw-r--r--drivers/usb/musb/Makefile2
-rw-r--r--drivers/usb/musb/blackfin.c9
-rw-r--r--drivers/usb/musb/cppi_dma.c1
-rw-r--r--drivers/usb/musb/davinci.c3
-rw-r--r--drivers/usb/musb/musb_core.c90
-rw-r--r--drivers/usb/musb/musb_core.h6
-rw-r--r--drivers/usb/musb/musb_gadget.c1
-rw-r--r--drivers/usb/musb/musb_host.c3
-rw-r--r--drivers/usb/musb/musb_regs.h28
-rw-r--r--drivers/usb/musb/musb_virthub.c1
-rw-r--r--drivers/usb/musb/musbhsdma.c1
-rw-r--r--drivers/usb/musb/omap2430.c4
-rw-r--r--drivers/usb/musb/tusb6010.c13
-rw-r--r--drivers/usb/musb/tusb6010_omap.c23
-rw-r--r--drivers/usb/otg/gpio_vbus.c1
-rw-r--r--drivers/usb/otg/nop-usb-xceiv.c1
-rw-r--r--drivers/usb/otg/twl4030-usb.c1
-rw-r--r--drivers/usb/otg/ulpi.c1
-rw-r--r--drivers/usb/serial/Kconfig4
-rw-r--r--drivers/usb/serial/aircable.c1
-rw-r--r--drivers/usb/serial/ark3116.c1
-rw-r--r--drivers/usb/serial/bus.c1
-rw-r--r--drivers/usb/serial/ch341.c1
-rw-r--r--drivers/usb/serial/console.c1
-rw-r--r--drivers/usb/serial/cp210x.c5
-rw-r--r--drivers/usb/serial/ftdi_sio.c7
-rw-r--r--drivers/usb/serial/ftdi_sio_ids.h7
-rw-r--r--drivers/usb/serial/generic.c49
-rw-r--r--drivers/usb/serial/navman.c1
-rw-r--r--drivers/usb/serial/opticon.c1
-rw-r--r--drivers/usb/serial/option.c64
-rw-r--r--drivers/usb/serial/pl2303.c2
-rw-r--r--drivers/usb/serial/pl2303.h5
-rw-r--r--drivers/usb/serial/qcaux.c10
-rw-r--r--drivers/usb/serial/qcserial.c29
-rw-r--r--drivers/usb/serial/safe_serial.c2
-rw-r--r--drivers/usb/serial/sierra.c2
-rw-r--r--drivers/usb/serial/symbolserial.c1
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c26
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.h3
-rw-r--r--drivers/usb/serial/usb_debug.c1
-rw-r--r--drivers/usb/storage/alauda.c1
-rw-r--r--drivers/usb/storage/karma.c1
-rw-r--r--drivers/usb/storage/option_ms.c1
-rw-r--r--drivers/usb/storage/scsiglue.c1
-rw-r--r--drivers/usb/storage/sierra_ms.c1
-rw-r--r--drivers/usb/storage/transport.c2
-rw-r--r--drivers/usb/storage/unusual_devs.h23
-rw-r--r--drivers/usb/wusbcore/cbaf.c1
-rw-r--r--drivers/usb/wusbcore/crypto.c1
-rw-r--r--drivers/usb/wusbcore/devconnect.c3
-rw-r--r--drivers/usb/wusbcore/mmc.c1
-rw-r--r--drivers/usb/wusbcore/rh.c1
-rw-r--r--drivers/usb/wusbcore/security.c1
-rw-r--r--drivers/usb/wusbcore/wa-hc.c1
-rw-r--r--drivers/usb/wusbcore/wa-nep.c1
-rw-r--r--drivers/usb/wusbcore/wa-rpipe.c1
-rw-r--r--drivers/usb/wusbcore/wa-xfer.c1
-rw-r--r--drivers/uwb/address.c1
-rw-r--r--drivers/uwb/allocator.c1
-rw-r--r--drivers/uwb/beacon.c1
-rw-r--r--drivers/uwb/drp-ie.c1
-rw-r--r--drivers/uwb/drp.c1
-rw-r--r--drivers/uwb/est.c1
-rw-r--r--drivers/uwb/hwa-rc.c3
-rw-r--r--drivers/uwb/i1480/dfu/mac.c1
-rw-r--r--drivers/uwb/i1480/dfu/usb.c13
-rw-r--r--drivers/uwb/i1480/i1480u-wlp/lc.c1
-rw-r--r--drivers/uwb/i1480/i1480u-wlp/netdev.c1
-rw-r--r--drivers/uwb/i1480/i1480u-wlp/rx.c1
-rw-r--r--drivers/uwb/i1480/i1480u-wlp/tx.c1
-rw-r--r--drivers/uwb/ie.c1
-rw-r--r--drivers/uwb/lc-dev.c1
-rw-r--r--drivers/uwb/lc-rc.c1
-rw-r--r--drivers/uwb/neh.c1
-rw-r--r--drivers/uwb/reset.c1
-rw-r--r--drivers/uwb/rsv.c1
-rw-r--r--drivers/uwb/scan.c1
-rw-r--r--drivers/uwb/umc-dev.c1
-rw-r--r--drivers/uwb/uwbd.c1
-rw-r--r--drivers/uwb/whc-rc.c1
-rw-r--r--drivers/uwb/whci.c1
-rw-r--r--drivers/uwb/wlp/eda.c1
-rw-r--r--drivers/uwb/wlp/messages.c107
-rw-r--r--drivers/uwb/wlp/txrx.c1
-rw-r--r--drivers/uwb/wlp/wlp-lc.c1
-rw-r--r--drivers/uwb/wlp/wss-lc.c1
-rw-r--r--drivers/vhost/net.c11
-rw-r--r--drivers/vhost/vhost.c23
-rw-r--r--drivers/video/68328fb.c1
-rw-r--r--drivers/video/acornfb.c2
-rw-r--r--drivers/video/amifb.c1
-rw-r--r--drivers/video/arcfb.c1
-rw-r--r--drivers/video/asiliantfb.c1
-rw-r--r--drivers/video/atafb.c1
-rw-r--r--drivers/video/atmel_lcdfb.c1
-rw-r--r--drivers/video/aty/aty128fb.c1
-rw-r--r--drivers/video/aty/mach64_cursor.c1
-rw-r--r--drivers/video/aty/radeon_backlight.c1
-rw-r--r--drivers/video/aty/radeon_monitor.c3
-rw-r--r--drivers/video/au1100fb.c1
-rw-r--r--drivers/video/au1200fb.c1
-rw-r--r--drivers/video/backlight/88pm860x_bl.c1
-rw-r--r--drivers/video/backlight/adp5520_bl.c1
-rw-r--r--drivers/video/backlight/adx_bl.c1
-rw-r--r--drivers/video/backlight/atmel-pwm-bl.c1
-rw-r--r--drivers/video/backlight/backlight.c1
-rw-r--r--drivers/video/backlight/corgi_lcd.c1
-rw-r--r--drivers/video/backlight/cr_bllcd.c1
-rw-r--r--drivers/video/backlight/da903x_bl.c1
-rw-r--r--drivers/video/backlight/ili9320.c1
-rw-r--r--drivers/video/backlight/l4f00242t03.c1
-rw-r--r--drivers/video/backlight/lcd.c1
-rw-r--r--drivers/video/backlight/lms283gf05.c1
-rw-r--r--drivers/video/backlight/ltv350qv.c1
-rw-r--r--drivers/video/backlight/max8925_bl.c1
-rw-r--r--drivers/video/backlight/omap1_bl.c1
-rw-r--r--drivers/video/backlight/platform_lcd.c1
-rw-r--r--drivers/video/backlight/pwm_bl.c1
-rw-r--r--drivers/video/backlight/tdo24m.c1
-rw-r--r--drivers/video/backlight/tosa_bl.c1
-rw-r--r--drivers/video/backlight/tosa_lcd.c1
-rw-r--r--drivers/video/backlight/wm831x_bl.c1
-rw-r--r--drivers/video/bfin-lq035q1-fb.c1
-rw-r--r--drivers/video/bfin-t350mcqb-fb.c1
-rw-r--r--drivers/video/bw2.c1
-rw-r--r--drivers/video/carminefb.c1
-rw-r--r--drivers/video/cfbcopyarea.c1
-rw-r--r--drivers/video/cg14.c1
-rw-r--r--drivers/video/cg3.c1
-rw-r--r--drivers/video/cg6.c1
-rw-r--r--drivers/video/chipsfb.c1
-rw-r--r--drivers/video/cirrusfb.c1
-rw-r--r--drivers/video/console/bitblit.c1
-rw-r--r--drivers/video/console/fbcon_ccw.c1
-rw-r--r--drivers/video/console/fbcon_cw.c1
-rw-r--r--drivers/video/console/fbcon_rotate.c1
-rw-r--r--drivers/video/console/fbcon_ud.c1
-rw-r--r--drivers/video/console/mdacon.c1
-rw-r--r--drivers/video/da8xx-fb.c1
-rw-r--r--drivers/video/display/display-sysfs.c1
-rw-r--r--drivers/video/dnfb.c1
-rw-r--r--drivers/video/efifb.c3
-rw-r--r--drivers/video/ep93xx-fb.c1
-rw-r--r--drivers/video/epson1355fb.c1
-rw-r--r--drivers/video/fb_ddc.c1
-rw-r--r--drivers/video/fb_defio.c1
-rw-r--r--drivers/video/fbcvt.c1
-rw-r--r--drivers/video/fbmon.c1
-rw-r--r--drivers/video/fbsysfs.c1
-rw-r--r--drivers/video/ffb.c1
-rw-r--r--drivers/video/fsl-diu-fb.c1
-rw-r--r--drivers/video/g364fb.c1
-rw-r--r--drivers/video/gbefb.c1
-rw-r--r--drivers/video/geode/gx1fb_core.c1
-rw-r--r--drivers/video/geode/gxfb_core.c1
-rw-r--r--drivers/video/geode/lxfb.h2
-rw-r--r--drivers/video/geode/lxfb_core.c1
-rw-r--r--drivers/video/geode/lxfb_ops.c10
-rw-r--r--drivers/video/hecubafb.c1
-rw-r--r--drivers/video/hgafb.c1
-rw-r--r--drivers/video/hitfb.c1
-rw-r--r--drivers/video/hpfb.c1
-rw-r--r--drivers/video/i810/i810-i2c.c1
-rw-r--r--drivers/video/imsttfb.c1
-rw-r--r--drivers/video/intelfb/intelfbhw.c1
-rw-r--r--drivers/video/leo.c1
-rw-r--r--drivers/video/matrox/i2c-matroxfb.c1
-rw-r--r--drivers/video/matrox/matroxfb_base.c1
-rw-r--r--drivers/video/matrox/matroxfb_crtc2.c1
-rw-r--r--drivers/video/matrox/matroxfb_maven.c1
-rw-r--r--drivers/video/maxinefb.c1
-rw-r--r--drivers/video/mb862xx/mb862xxfb_accel.c6
-rw-r--r--drivers/video/mbx/mbxdebugfs.c1
-rw-r--r--drivers/video/metronomefb.c1
-rw-r--r--drivers/video/modedb.c1
-rw-r--r--drivers/video/msm/mddi.c1
-rw-r--r--drivers/video/msm/mddi_client_dummy.c1
-rw-r--r--drivers/video/msm/mddi_client_nt35399.c1
-rw-r--r--drivers/video/msm/mddi_client_toshiba.c1
-rw-r--r--drivers/video/msm/mdp.c1
-rw-r--r--drivers/video/msm/msm_fb.c1
-rw-r--r--drivers/video/nvidia/nv_i2c.c1
-rw-r--r--drivers/video/nvidia/nv_of.c1
-rw-r--r--drivers/video/nvidia/nv_setup.c1
-rw-r--r--drivers/video/offb.c1
-rw-r--r--drivers/video/omap/dispc.c1
-rw-r--r--drivers/video/omap/lcd_mipid.c1
-rw-r--r--drivers/video/omap/lcdc.c1
-rw-r--r--drivers/video/omap/omapfb_main.c1
-rw-r--r--drivers/video/omap2/displays/panel-generic.c22
-rw-r--r--drivers/video/omap2/displays/panel-taal.c1
-rw-r--r--drivers/video/omap2/displays/panel-tpo-td043mtea1.c1
-rw-r--r--drivers/video/omap2/dss/dss.c3
-rw-r--r--drivers/video/omap2/dss/manager.c1
-rw-r--r--drivers/video/omap2/dss/overlay.c1
-rw-r--r--drivers/video/omap2/omapfb/omapfb-main.c1
-rw-r--r--drivers/video/omap2/vram.c12
-rw-r--r--drivers/video/output.c1
-rw-r--r--drivers/video/p9100.c1
-rw-r--r--drivers/video/platinumfb.c1
-rw-r--r--drivers/video/pmag-aa-fb.c1
-rw-r--r--drivers/video/pnx4008/pnxrgbfb.c1
-rw-r--r--drivers/video/pnx4008/sdum.c2
-rw-r--r--drivers/video/pxa168fb.c2
-rw-r--r--drivers/video/q40fb.c1
-rw-r--r--drivers/video/s1d13xxxfb.c1
-rw-r--r--drivers/video/s3c-fb.c2
-rw-r--r--drivers/video/s3fb.c1
-rw-r--r--drivers/video/savage/savagefb-i2c.c1
-rw-r--r--drivers/video/sh7760fb.c1
-rw-r--r--drivers/video/sh_mobile_lcdcfb.c28
-rw-r--r--drivers/video/sstfb.c1
-rw-r--r--drivers/video/sunxvr1000.c1
-rw-r--r--drivers/video/sunxvr2500.c1
-rw-r--r--drivers/video/sunxvr500.c25
-rw-r--r--drivers/video/svgalib.c1
-rw-r--r--drivers/video/syscopyarea.c1
-rw-r--r--drivers/video/tcx.c1
-rw-r--r--drivers/video/tgafb.c1
-rw-r--r--drivers/video/tridentfb.c1
-rw-r--r--drivers/video/uvesafb.c1
-rw-r--r--drivers/video/vermilion/vermilion.c1
-rw-r--r--drivers/video/vesafb.c27
-rw-r--r--drivers/video/vfb.c1
-rw-r--r--drivers/video/vga16fb.c1
-rw-r--r--drivers/video/via/viafbdev.c1
-rw-r--r--drivers/video/vt8623fb.c1
-rw-r--r--drivers/video/w100fb.c1
-rw-r--r--drivers/video/xen-fbfront.c1
-rw-r--r--drivers/video/xilinxfb.c1
-rw-r--r--drivers/virtio/virtio_balloon.c4
-rw-r--r--drivers/virtio/virtio_pci.c1
-rw-r--r--drivers/virtio/virtio_ring.c1
-rw-r--r--drivers/vlynq/vlynq.c1
-rw-r--r--drivers/w1/masters/ds1wm.c1
-rw-r--r--drivers/w1/masters/ds2490.c1
-rw-r--r--drivers/w1/masters/mxc_w1.c1
-rw-r--r--drivers/w1/masters/omap_hdq.c2
-rw-r--r--drivers/w1/masters/w1-gpio.c1
-rw-r--r--drivers/w1/slaves/w1_ds2433.c1
-rw-r--r--drivers/w1/slaves/w1_ds2760.c1
-rw-r--r--drivers/w1/slaves/w1_therm.c5
-rw-r--r--drivers/w1/w1_int.c1
-rw-r--r--drivers/w1/w1_netlink.c1
-rw-r--r--drivers/watchdog/Kconfig17
-rw-r--r--drivers/watchdog/adx_wdt.c1
-rw-r--r--drivers/watchdog/at32ap700x_wdt.c1
-rw-r--r--drivers/watchdog/booke_wdt.c4
-rw-r--r--drivers/watchdog/cpwd.c1
-rw-r--r--drivers/watchdog/davinci_wdt.c1
-rw-r--r--drivers/watchdog/ep93xx_wdt.c2
-rw-r--r--drivers/watchdog/hpwdt.c3
-rw-r--r--drivers/watchdog/iTCO_wdt.c99
-rw-r--r--drivers/watchdog/ibmasr.c1
-rw-r--r--drivers/watchdog/max63xx_wdt.c8
-rw-r--r--drivers/watchdog/mpcore_wdt.c1
-rw-r--r--drivers/watchdog/nuc900_wdt.c1
-rw-r--r--drivers/watchdog/omap_wdt.c1
-rw-r--r--drivers/watchdog/pika_wdt.c2
-rw-r--r--drivers/watchdog/pnx4008_wdt.c1
-rw-r--r--drivers/watchdog/riowd.c1
-rw-r--r--drivers/watchdog/s3c2410_wdt.c1
-rw-r--r--drivers/watchdog/sb_wdog.c4
-rw-r--r--drivers/watchdog/sbc_fitpc2_wdt.c14
-rw-r--r--drivers/watchdog/ts72xx_wdt.c1
-rw-r--r--drivers/watchdog/twl4030_wdt.c1
-rw-r--r--drivers/xen/balloon.c1
-rw-r--r--drivers/xen/events.c1
-rw-r--r--drivers/xen/evtchn.c1
-rw-r--r--drivers/xen/grant-table.c1
-rw-r--r--drivers/xen/manage.c1
-rw-r--r--drivers/xen/sys-hypervisor.c1
-rw-r--r--drivers/xen/xenbus/xenbus_client.c1
-rw-r--r--drivers/xen/xenbus/xenbus_probe.c1
-rw-r--r--drivers/xen/xencomm.c2
-rw-r--r--drivers/xen/xenfs/xenbus.c1
2832 files changed, 28746 insertions, 8062 deletions
diff --git a/drivers/Makefile b/drivers/Makefile
index 34f1e1064db..f42a03029b7 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -17,6 +17,7 @@ obj-$(CONFIG_SFI) += sfi/
17obj-$(CONFIG_PNP) += pnp/ 17obj-$(CONFIG_PNP) += pnp/
18obj-$(CONFIG_ARM_AMBA) += amba/ 18obj-$(CONFIG_ARM_AMBA) += amba/
19 19
20obj-$(CONFIG_VIRTIO) += virtio/
20obj-$(CONFIG_XEN) += xen/ 21obj-$(CONFIG_XEN) += xen/
21 22
22# regulators early, since some subsystems rely on them to initialize 23# regulators early, since some subsystems rely on them to initialize
@@ -108,7 +109,6 @@ obj-$(CONFIG_PPC_PS3) += ps3/
108obj-$(CONFIG_OF) += of/ 109obj-$(CONFIG_OF) += of/
109obj-$(CONFIG_SSB) += ssb/ 110obj-$(CONFIG_SSB) += ssb/
110obj-$(CONFIG_VHOST_NET) += vhost/ 111obj-$(CONFIG_VHOST_NET) += vhost/
111obj-$(CONFIG_VIRTIO) += virtio/
112obj-$(CONFIG_VLYNQ) += vlynq/ 112obj-$(CONFIG_VLYNQ) += vlynq/
113obj-$(CONFIG_STAGING) += staging/ 113obj-$(CONFIG_STAGING) += staging/
114obj-y += platform/ 114obj-y += platform/
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index b6ed60b57b0..56205a0b85d 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -25,6 +25,7 @@
25 25
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/slab.h>
28#include <linux/init.h> 29#include <linux/init.h>
29#include <linux/types.h> 30#include <linux/types.h>
30#ifdef CONFIG_ACPI_PROCFS_POWER 31#ifdef CONFIG_ACPI_PROCFS_POWER
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 3597d73f28f..d9857138565 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -30,6 +30,7 @@
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/types.h> 31#include <linux/types.h>
32#include <linux/memory_hotplug.h> 32#include <linux/memory_hotplug.h>
33#include <linux/slab.h>
33#include <acpi/acpi_drivers.h> 34#include <acpi/acpi_drivers.h>
34 35
35#define ACPI_MEMORY_DEVICE_CLASS "memory" 36#define ACPI_MEMORY_DEVICE_CLASS "memory"
diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index 7e52295f1ec..62122134693 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -27,10 +27,11 @@
27#include <linux/freezer.h> 27#include <linux/freezer.h>
28#include <linux/cpu.h> 28#include <linux/cpu.h>
29#include <linux/clockchips.h> 29#include <linux/clockchips.h>
30#include <linux/slab.h>
30#include <acpi/acpi_bus.h> 31#include <acpi/acpi_bus.h>
31#include <acpi/acpi_drivers.h> 32#include <acpi/acpi_drivers.h>
32 33
33#define ACPI_PROCESSOR_AGGREGATOR_CLASS "processor_aggregator" 34#define ACPI_PROCESSOR_AGGREGATOR_CLASS "acpi_pad"
34#define ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME "Processor Aggregator" 35#define ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME "Processor Aggregator"
35#define ACPI_PROCESSOR_AGGREGATOR_NOTIFY 0x80 36#define ACPI_PROCESSOR_AGGREGATOR_NOTIFY 0x80
36static DEFINE_MUTEX(isolated_cpus_lock); 37static DEFINE_MUTEX(isolated_cpus_lock);
diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c
index 837de669743..78c55508aff 100644
--- a/drivers/acpi/acpica/evgpe.c
+++ b/drivers/acpi/acpica/evgpe.c
@@ -117,19 +117,14 @@ acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info)
117 if (ACPI_FAILURE(status)) 117 if (ACPI_FAILURE(status))
118 return_ACPI_STATUS(status); 118 return_ACPI_STATUS(status);
119 119
120 /* Mark wake-enabled or HW enable, or both */ 120 /* Clear the GPE (of stale events), then enable it */
121 121 status = acpi_hw_clear_gpe(gpe_event_info);
122 if (gpe_event_info->runtime_count) { 122 if (ACPI_FAILURE(status))
123 /* Clear the GPE (of stale events), then enable it */ 123 return_ACPI_STATUS(status);
124 status = acpi_hw_clear_gpe(gpe_event_info);
125 if (ACPI_FAILURE(status))
126 return_ACPI_STATUS(status);
127
128 /* Enable the requested runtime GPE */
129 status = acpi_hw_write_gpe_enable_reg(gpe_event_info);
130 }
131 124
132 return_ACPI_STATUS(AE_OK); 125 /* Enable the requested GPE */
126 status = acpi_hw_write_gpe_enable_reg(gpe_event_info);
127 return_ACPI_STATUS(status);
133} 128}
134 129
135/******************************************************************************* 130/*******************************************************************************
diff --git a/drivers/acpi/acpica/exprep.c b/drivers/acpi/acpica/exprep.c
index edf62bf5b26..2fbfe51fb14 100644
--- a/drivers/acpi/acpica/exprep.c
+++ b/drivers/acpi/acpica/exprep.c
@@ -468,6 +468,23 @@ acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info)
468 468
469 acpi_ut_add_reference(obj_desc->field.region_obj); 469 acpi_ut_add_reference(obj_desc->field.region_obj);
470 470
471 /* allow full data read from EC address space */
472 if (obj_desc->field.region_obj->region.space_id ==
473 ACPI_ADR_SPACE_EC) {
474 if (obj_desc->common_field.bit_length > 8) {
475 unsigned width =
476 ACPI_ROUND_BITS_UP_TO_BYTES(
477 obj_desc->common_field.bit_length);
478 // access_bit_width is u8, don't overflow it
479 if (width > 8)
480 width = 8;
481 obj_desc->common_field.access_byte_width =
482 width;
483 obj_desc->common_field.access_bit_width =
484 8 * width;
485 }
486 }
487
471 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD, 488 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
472 "RegionField: BitOff %X, Off %X, Gran %X, Region %p\n", 489 "RegionField: BitOff %X, Off %X, Gran %X, Region %p\n",
473 obj_desc->field.start_field_bit_offset, 490 obj_desc->field.start_field_bit_offset,
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 75f39f2c166..3026e3fa83e 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -32,6 +32,7 @@
32#include <linux/jiffies.h> 32#include <linux/jiffies.h>
33#include <linux/async.h> 33#include <linux/async.h>
34#include <linux/dmi.h> 34#include <linux/dmi.h>
35#include <linux/slab.h>
35 36
36#ifdef CONFIG_ACPI_PROCFS_POWER 37#ifdef CONFIG_ACPI_PROCFS_POWER
37#include <linux/proc_fs.h> 38#include <linux/proc_fs.h>
@@ -567,13 +568,13 @@ static int acpi_battery_update(struct acpi_battery *battery)
567 result = acpi_battery_get_status(battery); 568 result = acpi_battery_get_status(battery);
568 if (result) 569 if (result)
569 return result; 570 return result;
570#ifdef CONFIG_ACPI_SYSFS_POWER
571 if (!acpi_battery_present(battery)) { 571 if (!acpi_battery_present(battery)) {
572#ifdef CONFIG_ACPI_SYSFS_POWER
572 sysfs_remove_battery(battery); 573 sysfs_remove_battery(battery);
574#endif
573 battery->update_time = 0; 575 battery->update_time = 0;
574 return 0; 576 return 0;
575 } 577 }
576#endif
577 if (!battery->update_time || 578 if (!battery->update_time ||
578 old_present != acpi_battery_present(battery)) { 579 old_present != acpi_battery_present(battery)) {
579 result = acpi_battery_get_info(battery); 580 result = acpi_battery_get_info(battery);
@@ -879,7 +880,7 @@ static void acpi_battery_notify(struct acpi_device *device, u32 event)
879#ifdef CONFIG_ACPI_SYSFS_POWER 880#ifdef CONFIG_ACPI_SYSFS_POWER
880 /* acpi_battery_update could remove power_supply object */ 881 /* acpi_battery_update could remove power_supply object */
881 if (battery->bat.dev) 882 if (battery->bat.dev)
882 kobject_uevent(&battery->bat.dev->kobj, KOBJ_CHANGE); 883 power_supply_changed(&battery->bat);
883#endif 884#endif
884} 885}
885 886
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index b70cd375614..743576bf1bd 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -32,6 +32,7 @@
32#include <linux/device.h> 32#include <linux/device.h>
33#include <linux/proc_fs.h> 33#include <linux/proc_fs.h>
34#include <linux/acpi.h> 34#include <linux/acpi.h>
35#include <linux/slab.h>
35#ifdef CONFIG_X86 36#ifdef CONFIG_X86
36#include <asm/mpspec.h> 37#include <asm/mpspec.h>
37#endif 38#endif
@@ -526,7 +527,7 @@ int acpi_bus_generate_proc_event4(const char *device_class, const char *bus_id,
526 if (!event_is_open) 527 if (!event_is_open)
527 return 0; 528 return 0;
528 529
529 event = kmalloc(sizeof(struct acpi_bus_event), GFP_ATOMIC); 530 event = kzalloc(sizeof(struct acpi_bus_event), GFP_ATOMIC);
530 if (!event) 531 if (!event)
531 return -ENOMEM; 532 return -ENOMEM;
532 533
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index f53fbe307c9..fd51c4ab482 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -30,6 +30,7 @@
30#include <linux/proc_fs.h> 30#include <linux/proc_fs.h>
31#include <linux/seq_file.h> 31#include <linux/seq_file.h>
32#include <linux/input.h> 32#include <linux/input.h>
33#include <linux/slab.h>
33#include <acpi/acpi_bus.h> 34#include <acpi/acpi_bus.h>
34#include <acpi/acpi_drivers.h> 35#include <acpi/acpi_drivers.h>
35 36
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c
index 5faf6c21257..45cd03b4630 100644
--- a/drivers/acpi/container.c
+++ b/drivers/acpi/container.c
@@ -29,6 +29,7 @@
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/init.h> 31#include <linux/init.h>
32#include <linux/slab.h>
32#include <linux/types.h> 33#include <linux/types.h>
33#include <linux/acpi.h> 34#include <linux/acpi.h>
34#include <acpi/acpi_bus.h> 35#include <acpi/acpi_bus.h>
diff --git a/drivers/acpi/debug.c b/drivers/acpi/debug.c
index cc421b7ae16..146135e7a6a 100644
--- a/drivers/acpi/debug.c
+++ b/drivers/acpi/debug.c
@@ -9,6 +9,7 @@
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/moduleparam.h> 10#include <linux/moduleparam.h>
11#include <linux/debugfs.h> 11#include <linux/debugfs.h>
12#include <linux/slab.h>
12#include <asm/uaccess.h> 13#include <asm/uaccess.h>
13#include <acpi/acpi_drivers.h> 14#include <acpi/acpi_drivers.h>
14 15
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index d9a85f1ddde..3fe29e992be 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -24,6 +24,7 @@
24 24
25#include <linux/kernel.h> 25#include <linux/kernel.h>
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/slab.h>
27#include <linux/init.h> 28#include <linux/init.h>
28#include <linux/types.h> 29#include <linux/types.h>
29#include <linux/notifier.h> 30#include <linux/notifier.h>
@@ -1025,13 +1026,10 @@ static int dock_remove(struct dock_station *ds)
1025static acpi_status 1026static acpi_status
1026find_dock(acpi_handle handle, u32 lvl, void *context, void **rv) 1027find_dock(acpi_handle handle, u32 lvl, void *context, void **rv)
1027{ 1028{
1028 acpi_status status = AE_OK;
1029
1030 if (is_dock(handle)) 1029 if (is_dock(handle))
1031 if (dock_add(handle) >= 0) 1030 dock_add(handle);
1032 status = AE_CTRL_TERMINATE;
1033 1031
1034 return status; 1032 return AE_OK;
1035} 1033}
1036 1034
1037static acpi_status 1035static acpi_status
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 1ac28c6a672..f2234db85da 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -39,6 +39,7 @@
39#include <linux/interrupt.h> 39#include <linux/interrupt.h>
40#include <linux/list.h> 40#include <linux/list.h>
41#include <linux/spinlock.h> 41#include <linux/spinlock.h>
42#include <linux/slab.h>
42#include <asm/io.h> 43#include <asm/io.h>
43#include <acpi/acpi_bus.h> 44#include <acpi/acpi_bus.h>
44#include <acpi/acpi_drivers.h> 45#include <acpi/acpi_drivers.h>
@@ -628,12 +629,12 @@ static u32 acpi_ec_gpe_handler(void *data)
628 629
629static acpi_status 630static acpi_status
630acpi_ec_space_handler(u32 function, acpi_physical_address address, 631acpi_ec_space_handler(u32 function, acpi_physical_address address,
631 u32 bits, u64 *value, 632 u32 bits, u64 *value64,
632 void *handler_context, void *region_context) 633 void *handler_context, void *region_context)
633{ 634{
634 struct acpi_ec *ec = handler_context; 635 struct acpi_ec *ec = handler_context;
635 int result = 0, i; 636 int result = 0, i, bytes = bits / 8;
636 u8 temp = 0; 637 u8 *value = (u8 *)value64;
637 638
638 if ((address > 0xFF) || !value || !handler_context) 639 if ((address > 0xFF) || !value || !handler_context)
639 return AE_BAD_PARAMETER; 640 return AE_BAD_PARAMETER;
@@ -641,32 +642,15 @@ acpi_ec_space_handler(u32 function, acpi_physical_address address,
641 if (function != ACPI_READ && function != ACPI_WRITE) 642 if (function != ACPI_READ && function != ACPI_WRITE)
642 return AE_BAD_PARAMETER; 643 return AE_BAD_PARAMETER;
643 644
644 if (bits != 8 && acpi_strict) 645 if (EC_FLAGS_MSI || bits > 8)
645 return AE_BAD_PARAMETER;
646
647 if (EC_FLAGS_MSI)
648 acpi_ec_burst_enable(ec); 646 acpi_ec_burst_enable(ec);
649 647
650 if (function == ACPI_READ) { 648 for (i = 0; i < bytes; ++i, ++address, ++value)
651 result = acpi_ec_read(ec, address, &temp); 649 result = (function == ACPI_READ) ?
652 *value = temp; 650 acpi_ec_read(ec, address, value) :
653 } else { 651 acpi_ec_write(ec, address, *value);
654 temp = 0xff & (*value);
655 result = acpi_ec_write(ec, address, temp);
656 }
657
658 for (i = 8; unlikely(bits - i > 0); i += 8) {
659 ++address;
660 if (function == ACPI_READ) {
661 result = acpi_ec_read(ec, address, &temp);
662 (*value) |= ((u64)temp) << i;
663 } else {
664 temp = 0xff & ((*value) >> i);
665 result = acpi_ec_write(ec, address, temp);
666 }
667 }
668 652
669 if (EC_FLAGS_MSI) 653 if (EC_FLAGS_MSI || bits > 8)
670 acpi_ec_burst_disable(ec); 654 acpi_ec_burst_disable(ec);
671 655
672 switch (result) { 656 switch (result) {
diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c
index c511071bfd7..d439314a75d 100644
--- a/drivers/acpi/event.c
+++ b/drivers/acpi/event.c
@@ -10,6 +10,7 @@
10#include <linux/proc_fs.h> 10#include <linux/proc_fs.h>
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/poll.h> 12#include <linux/poll.h>
13#include <linux/gfp.h>
13#include <acpi/acpi_drivers.h> 14#include <acpi/acpi_drivers.h>
14#include <net/netlink.h> 15#include <net/netlink.h>
15#include <net/genetlink.h> 16#include <net/genetlink.h>
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 6d5b64b7d52..4af6301601e 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -9,6 +9,7 @@
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/list.h> 10#include <linux/list.h>
11#include <linux/device.h> 11#include <linux/device.h>
12#include <linux/slab.h>
12#include <linux/rwsem.h> 13#include <linux/rwsem.h>
13#include <linux/acpi.h> 14#include <linux/acpi.h>
14 15
diff --git a/drivers/acpi/hest.c b/drivers/acpi/hest.c
index 4bb18c980ac..1c527a19287 100644
--- a/drivers/acpi/hest.c
+++ b/drivers/acpi/hest.c
@@ -123,6 +123,10 @@ int acpi_hest_firmware_first_pci(struct pci_dev *pci)
123{ 123{
124 acpi_status status = AE_NOT_FOUND; 124 acpi_status status = AE_NOT_FOUND;
125 struct acpi_table_header *hest = NULL; 125 struct acpi_table_header *hest = NULL;
126
127 if (acpi_disabled)
128 return 0;
129
126 status = acpi_get_table(ACPI_SIG_HEST, 1, &hest); 130 status = acpi_get_table(ACPI_SIG_HEST, 1, &hest);
127 131
128 if (ACPI_SUCCESS(status)) { 132 if (ACPI_SUCCESS(status)) {
diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c
index b8725461d88..b0337d31460 100644
--- a/drivers/acpi/numa.c
+++ b/drivers/acpi/numa.c
@@ -61,8 +61,10 @@ int node_to_pxm(int node)
61 61
62void __acpi_map_pxm_to_node(int pxm, int node) 62void __acpi_map_pxm_to_node(int pxm, int node)
63{ 63{
64 pxm_to_node_map[pxm] = node; 64 if (pxm_to_node_map[pxm] == NUMA_NO_NODE || node < pxm_to_node_map[pxm])
65 node_to_pxm_map[node] = pxm; 65 pxm_to_node_map[pxm] = node;
66 if (node_to_pxm_map[node] == PXM_INVAL || pxm < node_to_pxm_map[node])
67 node_to_pxm_map[node] = pxm;
66} 68}
67 69
68int acpi_map_pxm_to_node(int pxm) 70int acpi_map_pxm_to_node(int pxm)
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 8e6d8665f0a..7594f65800c 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -758,7 +758,14 @@ static acpi_status __acpi_os_execute(acpi_execute_type type,
758 queue = hp ? kacpi_hotplug_wq : 758 queue = hp ? kacpi_hotplug_wq :
759 (type == OSL_NOTIFY_HANDLER ? kacpi_notify_wq : kacpid_wq); 759 (type == OSL_NOTIFY_HANDLER ? kacpi_notify_wq : kacpid_wq);
760 dpc->wait = hp ? 1 : 0; 760 dpc->wait = hp ? 1 : 0;
761 INIT_WORK(&dpc->work, acpi_os_execute_deferred); 761
762 if (queue == kacpi_hotplug_wq)
763 INIT_WORK(&dpc->work, acpi_os_execute_deferred);
764 else if (queue == kacpi_notify_wq)
765 INIT_WORK(&dpc->work, acpi_os_execute_deferred);
766 else
767 INIT_WORK(&dpc->work, acpi_os_execute_deferred);
768
762 ret = queue_work(queue, &dpc->work); 769 ret = queue_work(queue, &dpc->work);
763 770
764 if (!ret) { 771 if (!ret) {
@@ -1151,16 +1158,10 @@ int acpi_check_resource_conflict(const struct resource *res)
1151 1158
1152 if (clash) { 1159 if (clash) {
1153 if (acpi_enforce_resources != ENFORCE_RESOURCES_NO) { 1160 if (acpi_enforce_resources != ENFORCE_RESOURCES_NO) {
1154 printk("%sACPI: %s resource %s [0x%llx-0x%llx]" 1161 printk(KERN_WARNING "ACPI: resource %s %pR"
1155 " conflicts with ACPI region %s" 1162 " conflicts with ACPI region %s %pR\n",
1156 " [0x%llx-0x%llx]\n", 1163 res->name, res, res_list_elem->name,
1157 acpi_enforce_resources == ENFORCE_RESOURCES_LAX 1164 res_list_elem);
1158 ? KERN_WARNING : KERN_ERR,
1159 ioport ? "I/O" : "Memory", res->name,
1160 (long long) res->start, (long long) res->end,
1161 res_list_elem->name,
1162 (long long) res_list_elem->start,
1163 (long long) res_list_elem->end);
1164 if (acpi_enforce_resources == ENFORCE_RESOURCES_LAX) 1165 if (acpi_enforce_resources == ENFORCE_RESOURCES_LAX)
1165 printk(KERN_NOTICE "ACPI: This conflict may" 1166 printk(KERN_NOTICE "ACPI: This conflict may"
1166 " cause random problems and system" 1167 " cause random problems and system"
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index 843699ed93f..b0a71ecee68 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -37,6 +37,7 @@
37#include <linux/pm.h> 37#include <linux/pm.h>
38#include <linux/pci.h> 38#include <linux/pci.h>
39#include <linux/acpi.h> 39#include <linux/acpi.h>
40#include <linux/slab.h>
40#include <acpi/acpi_bus.h> 41#include <acpi/acpi_bus.h>
41#include <acpi/acpi_drivers.h> 42#include <acpi/acpi_drivers.h>
42 43
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index 04b0f007c9b..8d47a5846ae 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -39,6 +39,7 @@
39#include <linux/pm.h> 39#include <linux/pm.h>
40#include <linux/pci.h> 40#include <linux/pci.h>
41#include <linux/mutex.h> 41#include <linux/mutex.h>
42#include <linux/slab.h>
42 43
43#include <acpi/acpi_bus.h> 44#include <acpi/acpi_bus.h>
44#include <acpi/acpi_drivers.h> 45#include <acpi/acpi_drivers.h>
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index d724736d56c..aefce33f2a0 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -34,6 +34,7 @@
34#include <linux/pci.h> 34#include <linux/pci.h>
35#include <linux/pci-acpi.h> 35#include <linux/pci-acpi.h>
36#include <linux/acpi.h> 36#include <linux/acpi.h>
37#include <linux/slab.h>
37#include <acpi/acpi_bus.h> 38#include <acpi/acpi_bus.h>
38#include <acpi/acpi_drivers.h> 39#include <acpi/acpi_drivers.h>
39 40
diff --git a/drivers/acpi/pci_slot.c b/drivers/acpi/pci_slot.c
index 11f21974320..07f7fea8a4e 100644
--- a/drivers/acpi/pci_slot.c
+++ b/drivers/acpi/pci_slot.c
@@ -26,6 +26,7 @@
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/slab.h>
29#include <linux/types.h> 30#include <linux/types.h>
30#include <linux/pci.h> 31#include <linux/pci.h>
31#include <linux/acpi.h> 32#include <linux/acpi.h>
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index 0f30c3c1eea..ddc76787b84 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -39,6 +39,7 @@
39#include <linux/module.h> 39#include <linux/module.h>
40#include <linux/init.h> 40#include <linux/init.h>
41#include <linux/types.h> 41#include <linux/types.h>
42#include <linux/slab.h>
42#include <linux/proc_fs.h> 43#include <linux/proc_fs.h>
43#include <linux/seq_file.h> 44#include <linux/seq_file.h>
44#include <acpi/acpi_bus.h> 45#include <acpi/acpi_bus.h>
diff --git a/drivers/acpi/power_meter.c b/drivers/acpi/power_meter.c
index 834c5af0de4..66f67293341 100644
--- a/drivers/acpi/power_meter.c
+++ b/drivers/acpi/power_meter.c
@@ -25,6 +25,7 @@
25#include <linux/jiffies.h> 25#include <linux/jiffies.h>
26#include <linux/mutex.h> 26#include <linux/mutex.h>
27#include <linux/dmi.h> 27#include <linux/dmi.h>
28#include <linux/slab.h>
28#include <linux/kdev_t.h> 29#include <linux/kdev_t.h>
29#include <linux/sched.h> 30#include <linux/sched.h>
30#include <linux/time.h> 31#include <linux/time.h>
@@ -34,7 +35,7 @@
34#define ACPI_POWER_METER_NAME "power_meter" 35#define ACPI_POWER_METER_NAME "power_meter"
35ACPI_MODULE_NAME(ACPI_POWER_METER_NAME); 36ACPI_MODULE_NAME(ACPI_POWER_METER_NAME);
36#define ACPI_POWER_METER_DEVICE_NAME "Power Meter" 37#define ACPI_POWER_METER_DEVICE_NAME "Power Meter"
37#define ACPI_POWER_METER_CLASS "power_meter_resource" 38#define ACPI_POWER_METER_CLASS "pwr_meter_resource"
38 39
39#define NUM_SENSORS 17 40#define NUM_SENSORS 17
40 41
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 791ac7b0f8d..51284351418 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -8,6 +8,7 @@
8 * - Added _PDC for platforms with Intel CPUs 8 * - Added _PDC for platforms with Intel CPUs
9 */ 9 */
10#include <linux/dmi.h> 10#include <linux/dmi.h>
11#include <linux/slab.h>
11 12
12#include <acpi/acpi_drivers.h> 13#include <acpi/acpi_drivers.h>
13#include <acpi/processor.h> 14#include <acpi/processor.h>
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index b5658cdce27..5675d9747e8 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -45,6 +45,7 @@
45#include <linux/dmi.h> 45#include <linux/dmi.h>
46#include <linux/moduleparam.h> 46#include <linux/moduleparam.h>
47#include <linux/cpuidle.h> 47#include <linux/cpuidle.h>
48#include <linux/slab.h>
48 49
49#include <asm/io.h> 50#include <asm/io.h>
50#include <asm/system.h> 51#include <asm/system.h>
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 37dfce74939..5939e7f7d8e 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -32,6 +32,7 @@
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/cpufreq.h> 34#include <linux/cpufreq.h>
35#include <linux/slab.h>
35#include <linux/proc_fs.h> 36#include <linux/proc_fs.h>
36#include <linux/seq_file.h> 37#include <linux/seq_file.h>
37#include <linux/acpi.h> 38#include <linux/acpi.h>
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index d648a9860b8..ba1bd263d90 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -30,6 +30,7 @@
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/init.h> 31#include <linux/init.h>
32#include <linux/cpufreq.h> 32#include <linux/cpufreq.h>
33#include <linux/slab.h>
33 34
34#ifdef CONFIG_X86 35#ifdef CONFIG_X86
35#include <asm/cpufeature.h> 36#include <asm/cpufeature.h>
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 29c6f5766dc..9ade1a5b32e 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -28,6 +28,7 @@
28 28
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/slab.h>
31#include <linux/init.h> 32#include <linux/init.h>
32#include <linux/sched.h> 33#include <linux/sched.h>
33#include <linux/cpufreq.h> 34#include <linux/cpufreq.h>
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index 89ad11138e4..4ff76e8174e 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -25,6 +25,7 @@
25 */ 25 */
26 26
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/slab.h>
28#include <linux/module.h> 29#include <linux/module.h>
29#include <linux/moduleparam.h> 30#include <linux/moduleparam.h>
30#include <linux/kernel.h> 31#include <linux/kernel.h>
diff --git a/drivers/acpi/sbshc.c b/drivers/acpi/sbshc.c
index fd09229282e..f8be23b6c12 100644
--- a/drivers/acpi/sbshc.c
+++ b/drivers/acpi/sbshc.c
@@ -11,13 +11,14 @@
11#include <acpi/acpi_bus.h> 11#include <acpi/acpi_bus.h>
12#include <acpi/acpi_drivers.h> 12#include <acpi/acpi_drivers.h>
13#include <linux/wait.h> 13#include <linux/wait.h>
14#include <linux/slab.h>
14#include <linux/delay.h> 15#include <linux/delay.h>
15#include <linux/interrupt.h> 16#include <linux/interrupt.h>
16#include "sbshc.h" 17#include "sbshc.h"
17 18
18#define PREFIX "ACPI: " 19#define PREFIX "ACPI: "
19 20
20#define ACPI_SMB_HC_CLASS "smbus_host_controller" 21#define ACPI_SMB_HC_CLASS "smbus_host_ctl"
21#define ACPI_SMB_HC_DEVICE_NAME "ACPI SMBus HC" 22#define ACPI_SMB_HC_DEVICE_NAME "ACPI SMBus HC"
22 23
23struct acpi_smb_hc { 24struct acpi_smb_hc {
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index fb7fc24fe72..0338f513a01 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -4,10 +4,12 @@
4 4
5#include <linux/module.h> 5#include <linux/module.h>
6#include <linux/init.h> 6#include <linux/init.h>
7#include <linux/slab.h>
7#include <linux/kernel.h> 8#include <linux/kernel.h>
8#include <linux/acpi.h> 9#include <linux/acpi.h>
9#include <linux/signal.h> 10#include <linux/signal.h>
10#include <linux/kthread.h> 11#include <linux/kthread.h>
12#include <linux/dmi.h>
11 13
12#include <acpi/acpi_drivers.h> 14#include <acpi/acpi_drivers.h>
13 15
@@ -1032,6 +1034,41 @@ static void acpi_add_id(struct acpi_device *device, const char *dev_id)
1032 list_add_tail(&id->list, &device->pnp.ids); 1034 list_add_tail(&id->list, &device->pnp.ids);
1033} 1035}
1034 1036
1037/*
1038 * Old IBM workstations have a DSDT bug wherein the SMBus object
1039 * lacks the SMBUS01 HID and the methods do not have the necessary "_"
1040 * prefix. Work around this.
1041 */
1042static int acpi_ibm_smbus_match(struct acpi_device *device)
1043{
1044 acpi_handle h_dummy;
1045 struct acpi_buffer path = {ACPI_ALLOCATE_BUFFER, NULL};
1046 int result;
1047
1048 if (!dmi_name_in_vendors("IBM"))
1049 return -ENODEV;
1050
1051 /* Look for SMBS object */
1052 result = acpi_get_name(device->handle, ACPI_SINGLE_NAME, &path);
1053 if (result)
1054 return result;
1055
1056 if (strcmp("SMBS", path.pointer)) {
1057 result = -ENODEV;
1058 goto out;
1059 }
1060
1061 /* Does it have the necessary (but misnamed) methods? */
1062 result = -ENODEV;
1063 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "SBI", &h_dummy)) &&
1064 ACPI_SUCCESS(acpi_get_handle(device->handle, "SBR", &h_dummy)) &&
1065 ACPI_SUCCESS(acpi_get_handle(device->handle, "SBW", &h_dummy)))
1066 result = 0;
1067out:
1068 kfree(path.pointer);
1069 return result;
1070}
1071
1035static void acpi_device_set_id(struct acpi_device *device) 1072static void acpi_device_set_id(struct acpi_device *device)
1036{ 1073{
1037 acpi_status status; 1074 acpi_status status;
@@ -1044,12 +1081,6 @@ static void acpi_device_set_id(struct acpi_device *device)
1044 if (ACPI_IS_ROOT_DEVICE(device)) { 1081 if (ACPI_IS_ROOT_DEVICE(device)) {
1045 acpi_add_id(device, ACPI_SYSTEM_HID); 1082 acpi_add_id(device, ACPI_SYSTEM_HID);
1046 break; 1083 break;
1047 } else if (ACPI_IS_ROOT_DEVICE(device->parent)) {
1048 /* \_SB_, the only root-level namespace device */
1049 acpi_add_id(device, ACPI_BUS_HID);
1050 strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME);
1051 strcpy(device->pnp.device_class, ACPI_BUS_CLASS);
1052 break;
1053 } 1084 }
1054 1085
1055 status = acpi_get_object_info(device->handle, &info); 1086 status = acpi_get_object_info(device->handle, &info);
@@ -1082,6 +1113,14 @@ static void acpi_device_set_id(struct acpi_device *device)
1082 acpi_add_id(device, ACPI_BAY_HID); 1113 acpi_add_id(device, ACPI_BAY_HID);
1083 else if (ACPI_SUCCESS(acpi_dock_match(device))) 1114 else if (ACPI_SUCCESS(acpi_dock_match(device)))
1084 acpi_add_id(device, ACPI_DOCK_HID); 1115 acpi_add_id(device, ACPI_DOCK_HID);
1116 else if (!acpi_ibm_smbus_match(device))
1117 acpi_add_id(device, ACPI_SMBUS_IBM_HID);
1118 else if (!acpi_device_hid(device) &&
1119 ACPI_IS_ROOT_DEVICE(device->parent)) {
1120 acpi_add_id(device, ACPI_BUS_HID); /* \_SB, LNXSYBUS */
1121 strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME);
1122 strcpy(device->pnp.device_class, ACPI_BUS_CLASS);
1123 }
1085 1124
1086 break; 1125 break;
1087 case ACPI_BUS_TYPE_POWER: 1126 case ACPI_BUS_TYPE_POWER:
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index f74834a544f..e2e992599e6 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -450,6 +450,126 @@ static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
450 }, 450 },
451 }, 451 },
452 { 452 {
453 .callback = init_set_sci_en_on_resume,
454 .ident = "Lenovo ThinkPad T410",
455 .matches = {
456 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
457 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T410"),
458 },
459 },
460 {
461 .callback = init_set_sci_en_on_resume,
462 .ident = "Lenovo ThinkPad T510",
463 .matches = {
464 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
465 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T510"),
466 },
467 },
468 {
469 .callback = init_set_sci_en_on_resume,
470 .ident = "Lenovo ThinkPad W510",
471 .matches = {
472 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
473 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad W510"),
474 },
475 },
476 {
477 .callback = init_set_sci_en_on_resume,
478 .ident = "Lenovo ThinkPad X201",
479 .matches = {
480 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
481 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X201"),
482 },
483 },
484 {
485 .callback = init_set_sci_en_on_resume,
486 .ident = "Lenovo ThinkPad X201",
487 .matches = {
488 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
489 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X201s"),
490 },
491 },
492 {
493 .callback = init_set_sci_en_on_resume,
494 .ident = "Lenovo ThinkPad T410",
495 .matches = {
496 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
497 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T410"),
498 },
499 },
500 {
501 .callback = init_set_sci_en_on_resume,
502 .ident = "Lenovo ThinkPad T510",
503 .matches = {
504 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
505 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T510"),
506 },
507 },
508 {
509 .callback = init_set_sci_en_on_resume,
510 .ident = "Lenovo ThinkPad W510",
511 .matches = {
512 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
513 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad W510"),
514 },
515 },
516 {
517 .callback = init_set_sci_en_on_resume,
518 .ident = "Lenovo ThinkPad X201",
519 .matches = {
520 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
521 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X201"),
522 },
523 },
524 {
525 .callback = init_set_sci_en_on_resume,
526 .ident = "Lenovo ThinkPad X201",
527 .matches = {
528 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
529 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X201s"),
530 },
531 },
532 {
533 .callback = init_set_sci_en_on_resume,
534 .ident = "Lenovo ThinkPad T410",
535 .matches = {
536 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
537 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T410"),
538 },
539 },
540 {
541 .callback = init_set_sci_en_on_resume,
542 .ident = "Lenovo ThinkPad T510",
543 .matches = {
544 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
545 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T510"),
546 },
547 },
548 {
549 .callback = init_set_sci_en_on_resume,
550 .ident = "Lenovo ThinkPad W510",
551 .matches = {
552 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
553 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad W510"),
554 },
555 },
556 {
557 .callback = init_set_sci_en_on_resume,
558 .ident = "Lenovo ThinkPad X201",
559 .matches = {
560 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
561 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X201"),
562 },
563 },
564 {
565 .callback = init_set_sci_en_on_resume,
566 .ident = "Lenovo ThinkPad X201",
567 .matches = {
568 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
569 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X201s"),
570 },
571 },
572 {
453 .callback = init_old_suspend_ordering, 573 .callback = init_old_suspend_ordering,
454 .ident = "Panasonic CF51-2L", 574 .ident = "Panasonic CF51-2L",
455 .matches = { 575 .matches = {
@@ -458,6 +578,30 @@ static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
458 DMI_MATCH(DMI_BOARD_NAME, "CF51-2L"), 578 DMI_MATCH(DMI_BOARD_NAME, "CF51-2L"),
459 }, 579 },
460 }, 580 },
581 {
582 .callback = init_set_sci_en_on_resume,
583 .ident = "Dell Studio 1558",
584 .matches = {
585 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
586 DMI_MATCH(DMI_PRODUCT_NAME, "Studio 1558"),
587 },
588 },
589 {
590 .callback = init_set_sci_en_on_resume,
591 .ident = "Dell Studio 1557",
592 .matches = {
593 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
594 DMI_MATCH(DMI_PRODUCT_NAME, "Studio 1557"),
595 },
596 },
597 {
598 .callback = init_set_sci_en_on_resume,
599 .ident = "Dell Studio 1555",
600 .matches = {
601 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
602 DMI_MATCH(DMI_PRODUCT_NAME, "Studio 1555"),
603 },
604 },
461 {}, 605 {},
462}; 606};
463#endif /* CONFIG_SUSPEND */ 607#endif /* CONFIG_SUSPEND */
diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c
index 743f2445e2a..4aaf2497613 100644
--- a/drivers/acpi/system.c
+++ b/drivers/acpi/system.c
@@ -25,6 +25,7 @@
25 25
26#include <linux/proc_fs.h> 26#include <linux/proc_fs.h>
27#include <linux/seq_file.h> 27#include <linux/seq_file.h>
28#include <linux/slab.h>
28#include <linux/init.h> 29#include <linux/init.h>
29#include <linux/string.h> 30#include <linux/string.h>
30#include <asm/uaccess.h> 31#include <asm/uaccess.h>
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 5d3893558cf..efad1f33aeb 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -35,6 +35,7 @@
35#include <linux/module.h> 35#include <linux/module.h>
36#include <linux/dmi.h> 36#include <linux/dmi.h>
37#include <linux/init.h> 37#include <linux/init.h>
38#include <linux/slab.h>
38#include <linux/types.h> 39#include <linux/types.h>
39#include <linux/proc_fs.h> 40#include <linux/proc_fs.h>
40#include <linux/jiffies.h> 41#include <linux/jiffies.h>
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index c9a49f4747e..b002a471c5d 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -25,6 +25,7 @@
25 25
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/slab.h>
28#include <linux/init.h> 29#include <linux/init.h>
29#include <linux/types.h> 30#include <linux/types.h>
30#include <acpi/acpi_bus.h> 31#include <acpi/acpi_bus.h>
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index cbe6f3924a1..a0c93b32148 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -39,10 +39,12 @@
39#include <linux/sort.h> 39#include <linux/sort.h>
40#include <linux/pci.h> 40#include <linux/pci.h>
41#include <linux/pci_ids.h> 41#include <linux/pci_ids.h>
42#include <linux/slab.h>
42#include <asm/uaccess.h> 43#include <asm/uaccess.h>
43#include <linux/dmi.h> 44#include <linux/dmi.h>
44#include <acpi/acpi_bus.h> 45#include <acpi/acpi_bus.h>
45#include <acpi/acpi_drivers.h> 46#include <acpi/acpi_drivers.h>
47#include <linux/suspend.h>
46 48
47#define PREFIX "ACPI: " 49#define PREFIX "ACPI: "
48 50
@@ -88,7 +90,6 @@ module_param(allow_duplicates, bool, 0644);
88static int register_count = 0; 90static int register_count = 0;
89static int acpi_video_bus_add(struct acpi_device *device); 91static int acpi_video_bus_add(struct acpi_device *device);
90static int acpi_video_bus_remove(struct acpi_device *device, int type); 92static int acpi_video_bus_remove(struct acpi_device *device, int type);
91static int acpi_video_resume(struct acpi_device *device);
92static void acpi_video_bus_notify(struct acpi_device *device, u32 event); 93static void acpi_video_bus_notify(struct acpi_device *device, u32 event);
93 94
94static const struct acpi_device_id video_device_ids[] = { 95static const struct acpi_device_id video_device_ids[] = {
@@ -104,7 +105,6 @@ static struct acpi_driver acpi_video_bus = {
104 .ops = { 105 .ops = {
105 .add = acpi_video_bus_add, 106 .add = acpi_video_bus_add,
106 .remove = acpi_video_bus_remove, 107 .remove = acpi_video_bus_remove,
107 .resume = acpi_video_resume,
108 .notify = acpi_video_bus_notify, 108 .notify = acpi_video_bus_notify,
109 }, 109 },
110}; 110};
@@ -159,6 +159,7 @@ struct acpi_video_bus {
159 struct proc_dir_entry *dir; 159 struct proc_dir_entry *dir;
160 struct input_dev *input; 160 struct input_dev *input;
161 char phys[32]; /* for input device */ 161 char phys[32]; /* for input device */
162 struct notifier_block pm_nb;
162}; 163};
163 164
164struct acpi_video_device_flags { 165struct acpi_video_device_flags {
@@ -1020,6 +1021,13 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
1020 if (IS_ERR(device->backlight)) 1021 if (IS_ERR(device->backlight))
1021 return; 1022 return;
1022 1023
1024 /*
1025 * Save current brightness level in case we have to restore it
1026 * before acpi_video_device_lcd_set_level() is called next time.
1027 */
1028 device->backlight->props.brightness =
1029 acpi_video_get_brightness(device->backlight);
1030
1023 result = sysfs_create_link(&device->backlight->dev.kobj, 1031 result = sysfs_create_link(&device->backlight->dev.kobj,
1024 &device->dev->dev.kobj, "device"); 1032 &device->dev->dev.kobj, "device");
1025 if (result) 1033 if (result)
@@ -2122,7 +2130,7 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event)
2122{ 2130{
2123 struct acpi_video_bus *video = acpi_driver_data(device); 2131 struct acpi_video_bus *video = acpi_driver_data(device);
2124 struct input_dev *input; 2132 struct input_dev *input;
2125 int keycode; 2133 int keycode = 0;
2126 2134
2127 if (!video) 2135 if (!video)
2128 return; 2136 return;
@@ -2158,17 +2166,19 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event)
2158 break; 2166 break;
2159 2167
2160 default: 2168 default:
2161 keycode = KEY_UNKNOWN;
2162 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 2169 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
2163 "Unsupported event [0x%x]\n", event)); 2170 "Unsupported event [0x%x]\n", event));
2164 break; 2171 break;
2165 } 2172 }
2166 2173
2167 acpi_notifier_call_chain(device, event, 0); 2174 acpi_notifier_call_chain(device, event, 0);
2168 input_report_key(input, keycode, 1); 2175
2169 input_sync(input); 2176 if (keycode) {
2170 input_report_key(input, keycode, 0); 2177 input_report_key(input, keycode, 1);
2171 input_sync(input); 2178 input_sync(input);
2179 input_report_key(input, keycode, 0);
2180 input_sync(input);
2181 }
2172 2182
2173 return; 2183 return;
2174} 2184}
@@ -2179,7 +2189,7 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
2179 struct acpi_device *device = NULL; 2189 struct acpi_device *device = NULL;
2180 struct acpi_video_bus *bus; 2190 struct acpi_video_bus *bus;
2181 struct input_dev *input; 2191 struct input_dev *input;
2182 int keycode; 2192 int keycode = 0;
2183 2193
2184 if (!video_device) 2194 if (!video_device)
2185 return; 2195 return;
@@ -2220,39 +2230,48 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
2220 keycode = KEY_DISPLAY_OFF; 2230 keycode = KEY_DISPLAY_OFF;
2221 break; 2231 break;
2222 default: 2232 default:
2223 keycode = KEY_UNKNOWN;
2224 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 2233 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
2225 "Unsupported event [0x%x]\n", event)); 2234 "Unsupported event [0x%x]\n", event));
2226 break; 2235 break;
2227 } 2236 }
2228 2237
2229 acpi_notifier_call_chain(device, event, 0); 2238 acpi_notifier_call_chain(device, event, 0);
2230 input_report_key(input, keycode, 1); 2239
2231 input_sync(input); 2240 if (keycode) {
2232 input_report_key(input, keycode, 0); 2241 input_report_key(input, keycode, 1);
2233 input_sync(input); 2242 input_sync(input);
2243 input_report_key(input, keycode, 0);
2244 input_sync(input);
2245 }
2234 2246
2235 return; 2247 return;
2236} 2248}
2237 2249
2238static int instance; 2250static int acpi_video_resume(struct notifier_block *nb,
2239static int acpi_video_resume(struct acpi_device *device) 2251 unsigned long val, void *ign)
2240{ 2252{
2241 struct acpi_video_bus *video; 2253 struct acpi_video_bus *video;
2242 struct acpi_video_device *video_device; 2254 struct acpi_video_device *video_device;
2243 int i; 2255 int i;
2244 2256
2245 if (!device || !acpi_driver_data(device)) 2257 switch (val) {
2246 return -EINVAL; 2258 case PM_HIBERNATION_PREPARE:
2259 case PM_SUSPEND_PREPARE:
2260 case PM_RESTORE_PREPARE:
2261 return NOTIFY_DONE;
2262 }
2247 2263
2248 video = acpi_driver_data(device); 2264 video = container_of(nb, struct acpi_video_bus, pm_nb);
2265
2266 dev_info(&video->device->dev, "Restoring backlight state\n");
2249 2267
2250 for (i = 0; i < video->attached_count; i++) { 2268 for (i = 0; i < video->attached_count; i++) {
2251 video_device = video->attached_array[i].bind_info; 2269 video_device = video->attached_array[i].bind_info;
2252 if (video_device && video_device->backlight) 2270 if (video_device && video_device->backlight)
2253 acpi_video_set_brightness(video_device->backlight); 2271 acpi_video_set_brightness(video_device->backlight);
2254 } 2272 }
2255 return AE_OK; 2273
2274 return NOTIFY_OK;
2256} 2275}
2257 2276
2258static acpi_status 2277static acpi_status
@@ -2276,6 +2295,8 @@ acpi_video_bus_match(acpi_handle handle, u32 level, void *context,
2276 return AE_OK; 2295 return AE_OK;
2277} 2296}
2278 2297
2298static int instance;
2299
2279static int acpi_video_bus_add(struct acpi_device *device) 2300static int acpi_video_bus_add(struct acpi_device *device)
2280{ 2301{
2281 struct acpi_video_bus *video; 2302 struct acpi_video_bus *video;
@@ -2357,7 +2378,6 @@ static int acpi_video_bus_add(struct acpi_device *device)
2357 set_bit(KEY_BRIGHTNESSDOWN, input->keybit); 2378 set_bit(KEY_BRIGHTNESSDOWN, input->keybit);
2358 set_bit(KEY_BRIGHTNESS_ZERO, input->keybit); 2379 set_bit(KEY_BRIGHTNESS_ZERO, input->keybit);
2359 set_bit(KEY_DISPLAY_OFF, input->keybit); 2380 set_bit(KEY_DISPLAY_OFF, input->keybit);
2360 set_bit(KEY_UNKNOWN, input->keybit);
2361 2381
2362 error = input_register_device(input); 2382 error = input_register_device(input);
2363 if (error) 2383 if (error)
@@ -2369,6 +2389,10 @@ static int acpi_video_bus_add(struct acpi_device *device)
2369 video->flags.rom ? "yes" : "no", 2389 video->flags.rom ? "yes" : "no",
2370 video->flags.post ? "yes" : "no"); 2390 video->flags.post ? "yes" : "no");
2371 2391
2392 video->pm_nb.notifier_call = acpi_video_resume;
2393 video->pm_nb.priority = 0;
2394 register_pm_notifier(&video->pm_nb);
2395
2372 return 0; 2396 return 0;
2373 2397
2374 err_free_input_dev: 2398 err_free_input_dev:
@@ -2395,6 +2419,8 @@ static int acpi_video_bus_remove(struct acpi_device *device, int type)
2395 2419
2396 video = acpi_driver_data(device); 2420 video = acpi_driver_data(device);
2397 2421
2422 unregister_pm_notifier(&video->pm_nb);
2423
2398 acpi_video_bus_stop_devices(video); 2424 acpi_video_bus_stop_devices(video);
2399 acpi_video_bus_put_devices(video); 2425 acpi_video_bus_put_devices(video);
2400 acpi_video_bus_remove_fs(device); 2426 acpi_video_bus_remove_fs(device);
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index fdc9bcbe55a..5326af28a41 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -42,6 +42,7 @@
42#include <linux/dma-mapping.h> 42#include <linux/dma-mapping.h>
43#include <linux/device.h> 43#include <linux/device.h>
44#include <linux/dmi.h> 44#include <linux/dmi.h>
45#include <linux/gfp.h>
45#include <scsi/scsi_host.h> 46#include <scsi/scsi_host.h>
46#include <scsi/scsi_cmnd.h> 47#include <scsi/scsi_cmnd.h>
47#include <linux/libata.h> 48#include <linux/libata.h>
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index c33806654e4..83bc49fac9b 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -90,6 +90,7 @@
90#include <linux/blkdev.h> 90#include <linux/blkdev.h>
91#include <linux/delay.h> 91#include <linux/delay.h>
92#include <linux/device.h> 92#include <linux/device.h>
93#include <linux/gfp.h>
93#include <scsi/scsi_host.h> 94#include <scsi/scsi_host.h>
94#include <linux/libata.h> 95#include <linux/libata.h>
95#include <linux/dmi.h> 96#include <linux/dmi.h>
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index 292fdbc0431..7b5eea7e01d 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -15,6 +15,7 @@
15#include <linux/acpi.h> 15#include <linux/acpi.h>
16#include <linux/libata.h> 16#include <linux/libata.h>
17#include <linux/pci.h> 17#include <linux/pci.h>
18#include <linux/slab.h>
18#include <scsi/scsi_device.h> 19#include <scsi/scsi_device.h>
19#include "libata.h" 20#include "libata.h"
20 21
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 4a28420efff..49cffb6094a 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -58,6 +58,7 @@
58#include <linux/io.h> 58#include <linux/io.h>
59#include <linux/async.h> 59#include <linux/async.h>
60#include <linux/log2.h> 60#include <linux/log2.h>
61#include <linux/slab.h>
61#include <scsi/scsi.h> 62#include <scsi/scsi.h>
62#include <scsi/scsi_cmnd.h> 63#include <scsi/scsi_cmnd.h>
63#include <scsi/scsi_host.h> 64#include <scsi/scsi_host.h>
@@ -1493,6 +1494,7 @@ static int ata_hpa_resize(struct ata_device *dev)
1493{ 1494{
1494 struct ata_eh_context *ehc = &dev->link->eh_context; 1495 struct ata_eh_context *ehc = &dev->link->eh_context;
1495 int print_info = ehc->i.flags & ATA_EHI_PRINTINFO; 1496 int print_info = ehc->i.flags & ATA_EHI_PRINTINFO;
1497 bool unlock_hpa = ata_ignore_hpa || dev->flags & ATA_DFLAG_UNLOCK_HPA;
1496 u64 sectors = ata_id_n_sectors(dev->id); 1498 u64 sectors = ata_id_n_sectors(dev->id);
1497 u64 native_sectors; 1499 u64 native_sectors;
1498 int rc; 1500 int rc;
@@ -1509,7 +1511,7 @@ static int ata_hpa_resize(struct ata_device *dev)
1509 /* If device aborted the command or HPA isn't going to 1511 /* If device aborted the command or HPA isn't going to
1510 * be unlocked, skip HPA resizing. 1512 * be unlocked, skip HPA resizing.
1511 */ 1513 */
1512 if (rc == -EACCES || !ata_ignore_hpa) { 1514 if (rc == -EACCES || !unlock_hpa) {
1513 ata_dev_printk(dev, KERN_WARNING, "HPA support seems " 1515 ata_dev_printk(dev, KERN_WARNING, "HPA support seems "
1514 "broken, skipping HPA handling\n"); 1516 "broken, skipping HPA handling\n");
1515 dev->horkage |= ATA_HORKAGE_BROKEN_HPA; 1517 dev->horkage |= ATA_HORKAGE_BROKEN_HPA;
@@ -1524,7 +1526,7 @@ static int ata_hpa_resize(struct ata_device *dev)
1524 dev->n_native_sectors = native_sectors; 1526 dev->n_native_sectors = native_sectors;
1525 1527
1526 /* nothing to do? */ 1528 /* nothing to do? */
1527 if (native_sectors <= sectors || !ata_ignore_hpa) { 1529 if (native_sectors <= sectors || !unlock_hpa) {
1528 if (!print_info || native_sectors == sectors) 1530 if (!print_info || native_sectors == sectors)
1529 return 0; 1531 return 0;
1530 1532
@@ -4185,36 +4187,51 @@ int ata_dev_revalidate(struct ata_device *dev, unsigned int new_class,
4185 goto fail; 4187 goto fail;
4186 4188
4187 /* verify n_sectors hasn't changed */ 4189 /* verify n_sectors hasn't changed */
4188 if (dev->class == ATA_DEV_ATA && n_sectors && 4190 if (dev->class != ATA_DEV_ATA || !n_sectors ||
4189 dev->n_sectors != n_sectors) { 4191 dev->n_sectors == n_sectors)
4190 ata_dev_printk(dev, KERN_WARNING, "n_sectors mismatch " 4192 return 0;
4191 "%llu != %llu\n", 4193
4192 (unsigned long long)n_sectors, 4194 /* n_sectors has changed */
4193 (unsigned long long)dev->n_sectors); 4195 ata_dev_printk(dev, KERN_WARNING, "n_sectors mismatch %llu != %llu\n",
4194 /* 4196 (unsigned long long)n_sectors,
4195 * Something could have caused HPA to be unlocked 4197 (unsigned long long)dev->n_sectors);
4196 * involuntarily. If n_native_sectors hasn't changed 4198
4197 * and the new size matches it, keep the device. 4199 /*
4198 */ 4200 * Something could have caused HPA to be unlocked
4199 if (dev->n_native_sectors == n_native_sectors && 4201 * involuntarily. If n_native_sectors hasn't changed and the
4200 dev->n_sectors > n_sectors && 4202 * new size matches it, keep the device.
4201 dev->n_sectors == n_native_sectors) { 4203 */
4202 ata_dev_printk(dev, KERN_WARNING, 4204 if (dev->n_native_sectors == n_native_sectors &&
4203 "new n_sectors matches native, probably " 4205 dev->n_sectors > n_sectors && dev->n_sectors == n_native_sectors) {
4204 "late HPA unlock, continuing\n"); 4206 ata_dev_printk(dev, KERN_WARNING,
4205 /* keep using the old n_sectors */ 4207 "new n_sectors matches native, probably "
4206 dev->n_sectors = n_sectors; 4208 "late HPA unlock, continuing\n");
4207 } else { 4209 /* keep using the old n_sectors */
4208 /* restore original n_[native]_sectors and fail */ 4210 dev->n_sectors = n_sectors;
4209 dev->n_native_sectors = n_native_sectors; 4211 return 0;
4210 dev->n_sectors = n_sectors;
4211 rc = -ENODEV;
4212 goto fail;
4213 }
4214 } 4212 }
4215 4213
4216 return 0; 4214 /*
4215 * Some BIOSes boot w/o HPA but resume w/ HPA locked. Try
4216 * unlocking HPA in those cases.
4217 *
4218 * https://bugzilla.kernel.org/show_bug.cgi?id=15396
4219 */
4220 if (dev->n_native_sectors == n_native_sectors &&
4221 dev->n_sectors < n_sectors && n_sectors == n_native_sectors &&
4222 !(dev->horkage & ATA_HORKAGE_BROKEN_HPA)) {
4223 ata_dev_printk(dev, KERN_WARNING,
4224 "old n_sectors matches native, probably "
4225 "late HPA lock, will try to unlock HPA\n");
4226 /* try unlocking HPA */
4227 dev->flags |= ATA_DFLAG_UNLOCK_HPA;
4228 rc = -EIO;
4229 } else
4230 rc = -ENODEV;
4217 4231
4232 /* restore original n_[native_]sectors and fail */
4233 dev->n_native_sectors = n_native_sectors;
4234 dev->n_sectors = n_sectors;
4218 fail: 4235 fail:
4219 ata_dev_printk(dev, KERN_ERR, "revalidation failed (errno=%d)\n", rc); 4236 ata_dev_printk(dev, KERN_ERR, "revalidation failed (errno=%d)\n", rc);
4220 return rc; 4237 return rc;
@@ -4353,6 +4370,9 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
4353 { "HTS541080G9SA00", "MB4OC60D", ATA_HORKAGE_NONCQ, }, 4370 { "HTS541080G9SA00", "MB4OC60D", ATA_HORKAGE_NONCQ, },
4354 { "HTS541010G9SA00", "MBZOC60D", ATA_HORKAGE_NONCQ, }, 4371 { "HTS541010G9SA00", "MBZOC60D", ATA_HORKAGE_NONCQ, },
4355 4372
4373 /* https://bugzilla.kernel.org/show_bug.cgi?id=15573 */
4374 { "C300-CTFDDAC128MAG", "0001", ATA_HORKAGE_NONCQ, },
4375
4356 /* devices which puke on READ_NATIVE_MAX */ 4376 /* devices which puke on READ_NATIVE_MAX */
4357 { "HDS724040KLSA80", "KFAOA20N", ATA_HORKAGE_BROKEN_HPA, }, 4377 { "HDS724040KLSA80", "KFAOA20N", ATA_HORKAGE_BROKEN_HPA, },
4358 { "WDC WD3200JD-00KLB0", "WD-WCAMR1130137", ATA_HORKAGE_BROKEN_HPA }, 4378 { "WDC WD3200JD-00KLB0", "WD-WCAMR1130137", ATA_HORKAGE_BROKEN_HPA },
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 9f6cfac0f2c..228740f356c 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -879,6 +879,8 @@ static void ata_eh_set_pending(struct ata_port *ap, int fastdrain)
879void ata_qc_schedule_eh(struct ata_queued_cmd *qc) 879void ata_qc_schedule_eh(struct ata_queued_cmd *qc)
880{ 880{
881 struct ata_port *ap = qc->ap; 881 struct ata_port *ap = qc->ap;
882 struct request_queue *q = qc->scsicmd->device->request_queue;
883 unsigned long flags;
882 884
883 WARN_ON(!ap->ops->error_handler); 885 WARN_ON(!ap->ops->error_handler);
884 886
@@ -890,7 +892,9 @@ void ata_qc_schedule_eh(struct ata_queued_cmd *qc)
890 * Note that ATA_QCFLAG_FAILED is unconditionally set after 892 * Note that ATA_QCFLAG_FAILED is unconditionally set after
891 * this function completes. 893 * this function completes.
892 */ 894 */
895 spin_lock_irqsave(q->queue_lock, flags);
893 blk_abort_request(qc->scsicmd->request); 896 blk_abort_request(qc->scsicmd->request);
897 spin_unlock_irqrestore(q->queue_lock, flags);
894} 898}
895 899
896/** 900/**
@@ -1624,6 +1628,7 @@ void ata_eh_analyze_ncq_error(struct ata_link *link)
1624 } 1628 }
1625 1629
1626 /* okay, this error is ours */ 1630 /* okay, this error is ours */
1631 memset(&tf, 0, sizeof(tf));
1627 rc = ata_eh_read_log_10h(dev, &tag, &tf); 1632 rc = ata_eh_read_log_10h(dev, &tag, &tf);
1628 if (rc) { 1633 if (rc) {
1629 ata_link_printk(link, KERN_ERR, "failed to read log page 10h " 1634 ata_link_printk(link, KERN_ERR, "failed to read log page 10h "
diff --git a/drivers/ata/libata-pmp.c b/drivers/ata/libata-pmp.c
index 51f0ffb78cb..00305f41ed8 100644
--- a/drivers/ata/libata-pmp.c
+++ b/drivers/ata/libata-pmp.c
@@ -9,6 +9,7 @@
9 9
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/libata.h> 11#include <linux/libata.h>
12#include <linux/slab.h>
12#include "libata.h" 13#include "libata.h"
13 14
14const struct ata_port_operations sata_pmp_port_ops = { 15const struct ata_port_operations sata_pmp_port_ops = {
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index bea003a24d2..0088cdeb0b1 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -33,6 +33,7 @@
33 * 33 *
34 */ 34 */
35 35
36#include <linux/slab.h>
36#include <linux/kernel.h> 37#include <linux/kernel.h>
37#include <linux/blkdev.h> 38#include <linux/blkdev.h>
38#include <linux/spinlock.h> 39#include <linux/spinlock.h>
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index 561dec2481c..e3877b6843c 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -33,6 +33,7 @@
33 */ 33 */
34 34
35#include <linux/kernel.h> 35#include <linux/kernel.h>
36#include <linux/gfp.h>
36#include <linux/pci.h> 37#include <linux/pci.h>
37#include <linux/libata.h> 38#include <linux/libata.h>
38#include <linux/highmem.h> 39#include <linux/highmem.h>
@@ -1667,6 +1668,7 @@ unsigned int ata_sff_host_intr(struct ata_port *ap,
1667{ 1668{
1668 struct ata_eh_info *ehi = &ap->link.eh_info; 1669 struct ata_eh_info *ehi = &ap->link.eh_info;
1669 u8 status, host_stat = 0; 1670 u8 status, host_stat = 0;
1671 bool bmdma_stopped = false;
1670 1672
1671 VPRINTK("ata%u: protocol %d task_state %d\n", 1673 VPRINTK("ata%u: protocol %d task_state %d\n",
1672 ap->print_id, qc->tf.protocol, ap->hsm_task_state); 1674 ap->print_id, qc->tf.protocol, ap->hsm_task_state);
@@ -1699,6 +1701,7 @@ unsigned int ata_sff_host_intr(struct ata_port *ap,
1699 1701
1700 /* before we do anything else, clear DMA-Start bit */ 1702 /* before we do anything else, clear DMA-Start bit */
1701 ap->ops->bmdma_stop(qc); 1703 ap->ops->bmdma_stop(qc);
1704 bmdma_stopped = true;
1702 1705
1703 if (unlikely(host_stat & ATA_DMA_ERR)) { 1706 if (unlikely(host_stat & ATA_DMA_ERR)) {
1704 /* error when transfering data to/from memory */ 1707 /* error when transfering data to/from memory */
@@ -1716,8 +1719,14 @@ unsigned int ata_sff_host_intr(struct ata_port *ap,
1716 1719
1717 /* check main status, clearing INTRQ if needed */ 1720 /* check main status, clearing INTRQ if needed */
1718 status = ata_sff_irq_status(ap); 1721 status = ata_sff_irq_status(ap);
1719 if (status & ATA_BUSY) 1722 if (status & ATA_BUSY) {
1720 goto idle_irq; 1723 if (bmdma_stopped) {
1724 /* BMDMA engine is already stopped, we're screwed */
1725 qc->err_mask |= AC_ERR_HSM;
1726 ap->hsm_task_state = HSM_ST_ERR;
1727 } else
1728 goto idle_irq;
1729 }
1721 1730
1722 /* ack bmdma irq events */ 1731 /* ack bmdma irq events */
1723 ap->ops->sff_irq_clear(ap); 1732 ap->ops->sff_irq_clear(ap);
@@ -1762,13 +1771,16 @@ EXPORT_SYMBOL_GPL(ata_sff_host_intr);
1762irqreturn_t ata_sff_interrupt(int irq, void *dev_instance) 1771irqreturn_t ata_sff_interrupt(int irq, void *dev_instance)
1763{ 1772{
1764 struct ata_host *host = dev_instance; 1773 struct ata_host *host = dev_instance;
1774 bool retried = false;
1765 unsigned int i; 1775 unsigned int i;
1766 unsigned int handled = 0, polling = 0; 1776 unsigned int handled, idle, polling;
1767 unsigned long flags; 1777 unsigned long flags;
1768 1778
1769 /* TODO: make _irqsave conditional on x86 PCI IDE legacy mode */ 1779 /* TODO: make _irqsave conditional on x86 PCI IDE legacy mode */
1770 spin_lock_irqsave(&host->lock, flags); 1780 spin_lock_irqsave(&host->lock, flags);
1771 1781
1782retry:
1783 handled = idle = polling = 0;
1772 for (i = 0; i < host->n_ports; i++) { 1784 for (i = 0; i < host->n_ports; i++) {
1773 struct ata_port *ap = host->ports[i]; 1785 struct ata_port *ap = host->ports[i];
1774 struct ata_queued_cmd *qc; 1786 struct ata_queued_cmd *qc;
@@ -1782,7 +1794,8 @@ irqreturn_t ata_sff_interrupt(int irq, void *dev_instance)
1782 handled |= ata_sff_host_intr(ap, qc); 1794 handled |= ata_sff_host_intr(ap, qc);
1783 else 1795 else
1784 polling |= 1 << i; 1796 polling |= 1 << i;
1785 } 1797 } else
1798 idle |= 1 << i;
1786 } 1799 }
1787 1800
1788 /* 1801 /*
@@ -1790,7 +1803,9 @@ irqreturn_t ata_sff_interrupt(int irq, void *dev_instance)
1790 * asserting IRQ line, nobody cared will ensue. Check IRQ 1803 * asserting IRQ line, nobody cared will ensue. Check IRQ
1791 * pending status if available and clear spurious IRQ. 1804 * pending status if available and clear spurious IRQ.
1792 */ 1805 */
1793 if (!handled) { 1806 if (!handled && !retried) {
1807 bool retry = false;
1808
1794 for (i = 0; i < host->n_ports; i++) { 1809 for (i = 0; i < host->n_ports; i++) {
1795 struct ata_port *ap = host->ports[i]; 1810 struct ata_port *ap = host->ports[i];
1796 1811
@@ -1801,12 +1816,23 @@ irqreturn_t ata_sff_interrupt(int irq, void *dev_instance)
1801 !ap->ops->sff_irq_check(ap)) 1816 !ap->ops->sff_irq_check(ap))
1802 continue; 1817 continue;
1803 1818
1804 if (printk_ratelimit()) 1819 if (idle & (1 << i)) {
1805 ata_port_printk(ap, KERN_INFO, 1820 ap->ops->sff_check_status(ap);
1806 "clearing spurious IRQ\n"); 1821 ap->ops->sff_irq_clear(ap);
1822 } else {
1823 /* clear INTRQ and check if BUSY cleared */
1824 if (!(ap->ops->sff_check_status(ap) & ATA_BUSY))
1825 retry |= true;
1826 /*
1827 * With command in flight, we can't do
1828 * sff_irq_clear() w/o racing with completion.
1829 */
1830 }
1831 }
1807 1832
1808 ap->ops->sff_check_status(ap); 1833 if (retry) {
1809 ap->ops->sff_irq_clear(ap); 1834 retried = true;
1835 goto retry;
1810 } 1836 }
1811 } 1837 }
1812 1838
diff --git a/drivers/ata/pata_acpi.c b/drivers/ata/pata_acpi.c
index 8e5e1321042..1ea2be0f4b9 100644
--- a/drivers/ata/pata_acpi.c
+++ b/drivers/ata/pata_acpi.c
@@ -11,6 +11,7 @@
11#include <linux/blkdev.h> 11#include <linux/blkdev.h>
12#include <linux/delay.h> 12#include <linux/delay.h>
13#include <linux/device.h> 13#include <linux/device.h>
14#include <linux/gfp.h>
14#include <scsi/scsi_host.h> 15#include <scsi/scsi_host.h>
15#include <acpi/acpi_bus.h> 16#include <acpi/acpi_bus.h>
16 17
diff --git a/drivers/ata/pata_at32.c b/drivers/ata/pata_at32.c
index 5c129f99a7e..66ce6a526f2 100644
--- a/drivers/ata/pata_at32.c
+++ b/drivers/ata/pata_at32.c
@@ -18,6 +18,7 @@
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#include <linux/irq.h> 20#include <linux/irq.h>
21#include <linux/slab.h>
21#include <scsi/scsi_host.h> 22#include <scsi/scsi_host.h>
22#include <linux/ata.h> 23#include <linux/ata.h>
23#include <linux/libata.h> 24#include <linux/libata.h>
diff --git a/drivers/ata/pata_at91.c b/drivers/ata/pata_at91.c
index 376dd380b43..c6a946aa252 100644
--- a/drivers/ata/pata_at91.c
+++ b/drivers/ata/pata_at91.c
@@ -19,6 +19,7 @@
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/blkdev.h> 21#include <linux/blkdev.h>
22#include <linux/gfp.h>
22#include <scsi/scsi_host.h> 23#include <scsi/scsi_host.h>
23#include <linux/ata.h> 24#include <linux/ata.h>
24#include <linux/clk.h> 25#include <linux/clk.h>
diff --git a/drivers/ata/pata_atp867x.c b/drivers/ata/pata_atp867x.c
index 6fe7ded40c6..bb6e0746e07 100644
--- a/drivers/ata/pata_atp867x.c
+++ b/drivers/ata/pata_atp867x.c
@@ -33,6 +33,7 @@
33#include <linux/blkdev.h> 33#include <linux/blkdev.h>
34#include <linux/delay.h> 34#include <linux/delay.h>
35#include <linux/device.h> 35#include <linux/device.h>
36#include <linux/gfp.h>
36#include <scsi/scsi_host.h> 37#include <scsi/scsi_host.h>
37#include <linux/libata.h> 38#include <linux/libata.h>
38 39
diff --git a/drivers/ata/pata_cmd640.c b/drivers/ata/pata_cmd640.c
index 6cd5d5dd9e3..45896b3c653 100644
--- a/drivers/ata/pata_cmd640.c
+++ b/drivers/ata/pata_cmd640.c
@@ -18,6 +18,7 @@
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/blkdev.h> 19#include <linux/blkdev.h>
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include <linux/gfp.h>
21#include <scsi/scsi_host.h> 22#include <scsi/scsi_host.h>
22#include <linux/libata.h> 23#include <linux/libata.h>
23 24
diff --git a/drivers/ata/pata_icside.c b/drivers/ata/pata_icside.c
index b663b7ffae4..fa812e206ee 100644
--- a/drivers/ata/pata_icside.c
+++ b/drivers/ata/pata_icside.c
@@ -2,6 +2,7 @@
2#include <linux/module.h> 2#include <linux/module.h>
3#include <linux/init.h> 3#include <linux/init.h>
4#include <linux/blkdev.h> 4#include <linux/blkdev.h>
5#include <linux/gfp.h>
5#include <scsi/scsi_host.h> 6#include <scsi/scsi_host.h>
6#include <linux/ata.h> 7#include <linux/ata.h>
7#include <linux/libata.h> 8#include <linux/libata.h>
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c
index 9bde1cb5f98..5cb286fd839 100644
--- a/drivers/ata/pata_it821x.c
+++ b/drivers/ata/pata_it821x.c
@@ -75,6 +75,7 @@
75#include <linux/init.h> 75#include <linux/init.h>
76#include <linux/blkdev.h> 76#include <linux/blkdev.h>
77#include <linux/delay.h> 77#include <linux/delay.h>
78#include <linux/slab.h>
78#include <scsi/scsi_host.h> 79#include <scsi/scsi_host.h>
79#include <linux/libata.h> 80#include <linux/libata.h>
80 81
diff --git a/drivers/ata/pata_macio.c b/drivers/ata/pata_macio.c
index 4cc7bbd10ec..211b6438b3a 100644
--- a/drivers/ata/pata_macio.c
+++ b/drivers/ata/pata_macio.c
@@ -21,6 +21,7 @@
21#include <linux/pmu.h> 21#include <linux/pmu.h>
22#include <linux/scatterlist.h> 22#include <linux/scatterlist.h>
23#include <linux/of.h> 23#include <linux/of.h>
24#include <linux/gfp.h>
24 25
25#include <scsi/scsi.h> 26#include <scsi/scsi.h>
26#include <scsi/scsi_host.h> 27#include <scsi/scsi_host.h>
diff --git a/drivers/ata/pata_mpc52xx.c b/drivers/ata/pata_mpc52xx.c
index 2bc2dbe30e8..9f5b053611d 100644
--- a/drivers/ata/pata_mpc52xx.c
+++ b/drivers/ata/pata_mpc52xx.c
@@ -16,7 +16,7 @@
16 16
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/slab.h> 19#include <linux/gfp.h>
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include <linux/libata.h> 21#include <linux/libata.h>
22#include <linux/of_platform.h> 22#include <linux/of_platform.h>
diff --git a/drivers/ata/pata_octeon_cf.c b/drivers/ata/pata_octeon_cf.c
index 37ef416c124..005a44483a7 100644
--- a/drivers/ata/pata_octeon_cf.c
+++ b/drivers/ata/pata_octeon_cf.c
@@ -13,6 +13,7 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/libata.h> 14#include <linux/libata.h>
15#include <linux/irq.h> 15#include <linux/irq.h>
16#include <linux/slab.h>
16#include <linux/platform_device.h> 17#include <linux/platform_device.h>
17#include <linux/workqueue.h> 18#include <linux/workqueue.h>
18#include <scsi/scsi_host.h> 19#include <scsi/scsi_host.h>
diff --git a/drivers/ata/pata_pcmcia.c b/drivers/ata/pata_pcmcia.c
index 147de2fd66d..d94b8f0bd74 100644
--- a/drivers/ata/pata_pcmcia.c
+++ b/drivers/ata/pata_pcmcia.c
@@ -29,6 +29,7 @@
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/blkdev.h> 30#include <linux/blkdev.h>
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/slab.h>
32#include <scsi/scsi_host.h> 33#include <scsi/scsi_host.h>
33#include <linux/ata.h> 34#include <linux/ata.h>
34#include <linux/libata.h> 35#include <linux/libata.h>
@@ -423,6 +424,8 @@ static struct pcmcia_device_id pcmcia_devices[] = {
423 PCMCIA_DEVICE_PROD_ID12("Hyperstone", "Model1", 0x3d5b9ef5, 0xca6ab420), 424 PCMCIA_DEVICE_PROD_ID12("Hyperstone", "Model1", 0x3d5b9ef5, 0xca6ab420),
424 PCMCIA_DEVICE_PROD_ID12("IBM", "microdrive", 0xb569a6e5, 0xa6d76178), 425 PCMCIA_DEVICE_PROD_ID12("IBM", "microdrive", 0xb569a6e5, 0xa6d76178),
425 PCMCIA_DEVICE_PROD_ID12("IBM", "IBM17JSSFP20", 0xb569a6e5, 0xf2508753), 426 PCMCIA_DEVICE_PROD_ID12("IBM", "IBM17JSSFP20", 0xb569a6e5, 0xf2508753),
427 PCMCIA_DEVICE_PROD_ID12("KINGSTON", "CF CARD 1GB", 0x2e6d1829, 0x55d5bffb),
428 PCMCIA_DEVICE_PROD_ID12("KINGSTON", "CF CARD 4GB", 0x2e6d1829, 0x531e7d10),
426 PCMCIA_DEVICE_PROD_ID12("KINGSTON", "CF8GB", 0x2e6d1829, 0xacbe682e), 429 PCMCIA_DEVICE_PROD_ID12("KINGSTON", "CF8GB", 0x2e6d1829, 0xacbe682e),
427 PCMCIA_DEVICE_PROD_ID12("IO DATA", "CBIDE2 ", 0x547e66dc, 0x8671043b), 430 PCMCIA_DEVICE_PROD_ID12("IO DATA", "CBIDE2 ", 0x547e66dc, 0x8671043b),
428 PCMCIA_DEVICE_PROD_ID12("IO DATA", "PCIDE", 0x547e66dc, 0x5c5ab149), 431 PCMCIA_DEVICE_PROD_ID12("IO DATA", "PCIDE", 0x547e66dc, 0x5c5ab149),
@@ -443,6 +446,8 @@ static struct pcmcia_device_id pcmcia_devices[] = {
443 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS1GCF80", 0x709b1bf1, 0x2a54d4b1), 446 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS1GCF80", 0x709b1bf1, 0x2a54d4b1),
444 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS2GCF120", 0x709b1bf1, 0x969aa4f2), 447 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS2GCF120", 0x709b1bf1, 0x969aa4f2),
445 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS4GCF120", 0x709b1bf1, 0xf54a91c8), 448 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS4GCF120", 0x709b1bf1, 0xf54a91c8),
449 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS4GCF133", 0x709b1bf1, 0x7558f133),
450 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS8GCF133", 0x709b1bf1, 0xb2f89b47),
446 PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852), 451 PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852),
447 PCMCIA_DEVICE_PROD_ID12("WEIDA", "TWTTI", 0xcc7cf69c, 0x212bb918), 452 PCMCIA_DEVICE_PROD_ID12("WEIDA", "TWTTI", 0xcc7cf69c, 0x212bb918),
448 PCMCIA_DEVICE_PROD_ID1("STI Flash", 0xe4a13209), 453 PCMCIA_DEVICE_PROD_ID1("STI Flash", 0xe4a13209),
diff --git a/drivers/ata/pata_rb532_cf.c b/drivers/ata/pata_rb532_cf.c
index 45f1e10f917..0ffd631000b 100644
--- a/drivers/ata/pata_rb532_cf.c
+++ b/drivers/ata/pata_rb532_cf.c
@@ -19,6 +19,7 @@
19 * 19 *
20 */ 20 */
21 21
22#include <linux/gfp.h>
22#include <linux/kernel.h> 23#include <linux/kernel.h>
23#include <linux/module.h> 24#include <linux/module.h>
24#include <linux/platform_device.h> 25#include <linux/platform_device.h>
diff --git a/drivers/ata/pata_rdc.c b/drivers/ata/pata_rdc.c
index 237a24d41a2..37092cfd7bc 100644
--- a/drivers/ata/pata_rdc.c
+++ b/drivers/ata/pata_rdc.c
@@ -28,6 +28,7 @@
28#include <linux/blkdev.h> 28#include <linux/blkdev.h>
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/device.h> 30#include <linux/device.h>
31#include <linux/gfp.h>
31#include <scsi/scsi_host.h> 32#include <scsi/scsi_host.h>
32#include <linux/libata.h> 33#include <linux/libata.h>
33#include <linux/dmi.h> 34#include <linux/dmi.h>
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c
index 3059ec017de..741e7cb69d8 100644
--- a/drivers/ata/pata_via.c
+++ b/drivers/ata/pata_via.c
@@ -58,6 +58,7 @@
58#include <linux/init.h> 58#include <linux/init.h>
59#include <linux/blkdev.h> 59#include <linux/blkdev.h>
60#include <linux/delay.h> 60#include <linux/delay.h>
61#include <linux/gfp.h>
61#include <scsi/scsi_host.h> 62#include <scsi/scsi_host.h>
62#include <linux/libata.h> 63#include <linux/libata.h>
63#include <linux/dmi.h> 64#include <linux/dmi.h>
@@ -576,6 +577,10 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
576 u8 rev = isa->revision; 577 u8 rev = isa->revision;
577 pci_dev_put(isa); 578 pci_dev_put(isa);
578 579
580 if ((id->device == 0x0415 || id->device == 0x3164) &&
581 (config->id != id->device))
582 continue;
583
579 if (rev >= config->rev_min && rev <= config->rev_max) 584 if (rev >= config->rev_min && rev <= config->rev_max)
580 break; 585 break;
581 } 586 }
@@ -677,6 +682,7 @@ static const struct pci_device_id via[] = {
677 { PCI_VDEVICE(VIA, 0x3164), }, 682 { PCI_VDEVICE(VIA, 0x3164), },
678 { PCI_VDEVICE(VIA, 0x5324), }, 683 { PCI_VDEVICE(VIA, 0x5324), },
679 { PCI_VDEVICE(VIA, 0xC409), VIA_IDFLAG_SINGLE }, 684 { PCI_VDEVICE(VIA, 0xC409), VIA_IDFLAG_SINGLE },
685 { PCI_VDEVICE(VIA, 0x9001), VIA_IDFLAG_SINGLE },
680 686
681 { }, 687 { },
682}; 688};
diff --git a/drivers/ata/pdc_adma.c b/drivers/ata/pdc_adma.c
index 6c65b0776a2..5904cfdb8db 100644
--- a/drivers/ata/pdc_adma.c
+++ b/drivers/ata/pdc_adma.c
@@ -34,6 +34,7 @@
34 34
35#include <linux/kernel.h> 35#include <linux/kernel.h>
36#include <linux/module.h> 36#include <linux/module.h>
37#include <linux/gfp.h>
37#include <linux/pci.h> 38#include <linux/pci.h>
38#include <linux/init.h> 39#include <linux/init.h>
39#include <linux/blkdev.h> 40#include <linux/blkdev.h>
diff --git a/drivers/ata/sata_fsl.c b/drivers/ata/sata_fsl.c
index ce4136eea08..a69192b38b4 100644
--- a/drivers/ata/sata_fsl.c
+++ b/drivers/ata/sata_fsl.c
@@ -18,6 +18,7 @@
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/slab.h>
21 22
22#include <scsi/scsi_host.h> 23#include <scsi/scsi_host.h>
23#include <scsi/scsi_cmnd.h> 24#include <scsi/scsi_cmnd.h>
diff --git a/drivers/ata/sata_inic162x.c b/drivers/ata/sata_inic162x.c
index 4406902b429..27dc6c86a4c 100644
--- a/drivers/ata/sata_inic162x.c
+++ b/drivers/ata/sata_inic162x.c
@@ -39,6 +39,7 @@
39 * happy to assist. 39 * happy to assist.
40 */ 40 */
41 41
42#include <linux/gfp.h>
42#include <linux/kernel.h> 43#include <linux/kernel.h>
43#include <linux/module.h> 44#include <linux/module.h>
44#include <linux/pci.h> 45#include <linux/pci.h>
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index df8ee325d3c..71cc0d42f9e 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -64,6 +64,7 @@
64#include <linux/ata_platform.h> 64#include <linux/ata_platform.h>
65#include <linux/mbus.h> 65#include <linux/mbus.h>
66#include <linux/bitops.h> 66#include <linux/bitops.h>
67#include <linux/gfp.h>
67#include <scsi/scsi_host.h> 68#include <scsi/scsi_host.h>
68#include <scsi/scsi_cmnd.h> 69#include <scsi/scsi_cmnd.h>
69#include <scsi/scsi_device.h> 70#include <scsi/scsi_device.h>
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c
index 684fe04dbbb..2a98b09ab73 100644
--- a/drivers/ata/sata_nv.c
+++ b/drivers/ata/sata_nv.c
@@ -38,6 +38,7 @@
38 38
39#include <linux/kernel.h> 39#include <linux/kernel.h>
40#include <linux/module.h> 40#include <linux/module.h>
41#include <linux/gfp.h>
41#include <linux/pci.h> 42#include <linux/pci.h>
42#include <linux/init.h> 43#include <linux/init.h>
43#include <linux/blkdev.h> 44#include <linux/blkdev.h>
diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c
index 63306285c84..5356ec00d2b 100644
--- a/drivers/ata/sata_promise.c
+++ b/drivers/ata/sata_promise.c
@@ -33,6 +33,7 @@
33 33
34#include <linux/kernel.h> 34#include <linux/kernel.h>
35#include <linux/module.h> 35#include <linux/module.h>
36#include <linux/gfp.h>
36#include <linux/pci.h> 37#include <linux/pci.h>
37#include <linux/init.h> 38#include <linux/init.h>
38#include <linux/blkdev.h> 39#include <linux/blkdev.h>
diff --git a/drivers/ata/sata_qstor.c b/drivers/ata/sata_qstor.c
index 326c0cfc29b..92ba45e6689 100644
--- a/drivers/ata/sata_qstor.c
+++ b/drivers/ata/sata_qstor.c
@@ -29,6 +29,7 @@
29 29
30#include <linux/kernel.h> 30#include <linux/kernel.h>
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/gfp.h>
32#include <linux/pci.h> 33#include <linux/pci.h>
33#include <linux/init.h> 34#include <linux/init.h>
34#include <linux/blkdev.h> 35#include <linux/blkdev.h>
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c
index 1370df6c420..433b6b89c79 100644
--- a/drivers/ata/sata_sil24.c
+++ b/drivers/ata/sata_sil24.c
@@ -19,6 +19,7 @@
19 19
20#include <linux/kernel.h> 20#include <linux/kernel.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/gfp.h>
22#include <linux/pci.h> 23#include <linux/pci.h>
23#include <linux/blkdev.h> 24#include <linux/blkdev.h>
24#include <linux/delay.h> 25#include <linux/delay.h>
diff --git a/drivers/ata/sata_sx4.c b/drivers/ata/sata_sx4.c
index bbcf970068a..232468f2ea9 100644
--- a/drivers/ata/sata_sx4.c
+++ b/drivers/ata/sata_sx4.c
@@ -81,6 +81,7 @@
81#include <linux/kernel.h> 81#include <linux/kernel.h>
82#include <linux/module.h> 82#include <linux/module.h>
83#include <linux/pci.h> 83#include <linux/pci.h>
84#include <linux/slab.h>
84#include <linux/init.h> 85#include <linux/init.h>
85#include <linux/blkdev.h> 86#include <linux/blkdev.h>
86#include <linux/delay.h> 87#include <linux/delay.h>
diff --git a/drivers/ata/sata_uli.c b/drivers/ata/sata_uli.c
index e5bff47e8aa..011e098590d 100644
--- a/drivers/ata/sata_uli.c
+++ b/drivers/ata/sata_uli.c
@@ -26,6 +26,7 @@
26 26
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/gfp.h>
29#include <linux/pci.h> 30#include <linux/pci.h>
30#include <linux/init.h> 31#include <linux/init.h>
31#include <linux/blkdev.h> 32#include <linux/blkdev.h>
diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
index 5effec6f545..6d44f07b69f 100644
--- a/drivers/atm/adummy.c
+++ b/drivers/atm/adummy.c
@@ -13,6 +13,7 @@
13#include <linux/mm.h> 13#include <linux/mm.h>
14#include <linux/timer.h> 14#include <linux/timer.h>
15#include <linux/interrupt.h> 15#include <linux/interrupt.h>
16#include <linux/slab.h>
16#include <asm/io.h> 17#include <asm/io.h>
17#include <asm/byteorder.h> 18#include <asm/byteorder.h>
18#include <asm/uaccess.h> 19#include <asm/uaccess.h>
diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
index 8af23411743..9d18644c897 100644
--- a/drivers/atm/ambassador.c
+++ b/drivers/atm/ambassador.c
@@ -36,6 +36,7 @@
36#include <linux/mutex.h> 36#include <linux/mutex.h>
37#include <linux/firmware.h> 37#include <linux/firmware.h>
38#include <linux/ihex.h> 38#include <linux/ihex.h>
39#include <linux/slab.h>
39 40
40#include <asm/atomic.h> 41#include <asm/atomic.h>
41#include <asm/io.h> 42#include <asm/io.h>
diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
index 02ad83d6b56..b86712167eb 100644
--- a/drivers/atm/atmtcp.c
+++ b/drivers/atm/atmtcp.c
@@ -9,6 +9,7 @@
9#include <linux/atm_tcp.h> 9#include <linux/atm_tcp.h>
10#include <linux/bitops.h> 10#include <linux/bitops.h>
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/slab.h>
12#include <asm/uaccess.h> 13#include <asm/uaccess.h>
13#include <asm/atomic.h> 14#include <asm/atomic.h>
14 15
diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
index 0c302614544..719ec5a0dca 100644
--- a/drivers/atm/eni.c
+++ b/drivers/atm/eni.c
@@ -18,6 +18,7 @@
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/atm_eni.h> 19#include <linux/atm_eni.h>
20#include <linux/bitops.h> 20#include <linux/bitops.h>
21#include <linux/slab.h>
21#include <asm/system.h> 22#include <asm/system.h>
22#include <asm/io.h> 23#include <asm/io.h>
23#include <asm/atomic.h> 24#include <asm/atomic.h>
diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
index cd5049af47a..6e600afd06a 100644
--- a/drivers/atm/firestream.c
+++ b/drivers/atm/firestream.c
@@ -46,6 +46,7 @@
46#include <linux/init.h> 46#include <linux/init.h>
47#include <linux/capability.h> 47#include <linux/capability.h>
48#include <linux/bitops.h> 48#include <linux/bitops.h>
49#include <linux/slab.h>
49#include <asm/byteorder.h> 50#include <asm/byteorder.h>
50#include <asm/system.h> 51#include <asm/system.h>
51#include <asm/string.h> 52#include <asm/string.h>
diff --git a/drivers/atm/he.c b/drivers/atm/he.c
index e8c6529dc36..c213e0da034 100644
--- a/drivers/atm/he.c
+++ b/drivers/atm/he.c
@@ -67,6 +67,7 @@
67#include <linux/timer.h> 67#include <linux/timer.h>
68#include <linux/interrupt.h> 68#include <linux/interrupt.h>
69#include <linux/dma-mapping.h> 69#include <linux/dma-mapping.h>
70#include <linux/slab.h>
70#include <asm/io.h> 71#include <asm/io.h>
71#include <asm/byteorder.h> 72#include <asm/byteorder.h>
72#include <asm/uaccess.h> 73#include <asm/uaccess.h>
diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
index 4e49021e67e..54720baa736 100644
--- a/drivers/atm/horizon.c
+++ b/drivers/atm/horizon.c
@@ -40,6 +40,7 @@
40#include <linux/init.h> 40#include <linux/init.h>
41#include <linux/ioport.h> 41#include <linux/ioport.h>
42#include <linux/wait.h> 42#include <linux/wait.h>
43#include <linux/slab.h>
43 44
44#include <asm/system.h> 45#include <asm/system.h>
45#include <asm/io.h> 46#include <asm/io.h>
diff --git a/drivers/atm/idt77105.c b/drivers/atm/idt77105.c
index 84672dc57f7..dab5cf5274f 100644
--- a/drivers/atm/idt77105.c
+++ b/drivers/atm/idt77105.c
@@ -15,6 +15,7 @@
15#include <linux/capability.h> 15#include <linux/capability.h>
16#include <linux/atm_idt77105.h> 16#include <linux/atm_idt77105.h>
17#include <linux/spinlock.h> 17#include <linux/spinlock.h>
18#include <linux/slab.h>
18#include <asm/system.h> 19#include <asm/system.h>
19#include <asm/param.h> 20#include <asm/param.h>
20#include <asm/uaccess.h> 21#include <asm/uaccess.h>
diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
index 01f36c08cb5..98657a6a330 100644
--- a/drivers/atm/idt77252.c
+++ b/drivers/atm/idt77252.c
@@ -41,6 +41,7 @@
41#include <linux/wait.h> 41#include <linux/wait.h>
42#include <linux/jiffies.h> 42#include <linux/jiffies.h>
43#include <linux/mutex.h> 43#include <linux/mutex.h>
44#include <linux/slab.h>
44 45
45#include <asm/io.h> 46#include <asm/io.h>
46#include <asm/uaccess.h> 47#include <asm/uaccess.h>
diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
index 25a4c86f839..ee9ddeb5341 100644
--- a/drivers/atm/iphase.c
+++ b/drivers/atm/iphase.c
@@ -54,6 +54,7 @@
54#include <linux/uio.h> 54#include <linux/uio.h>
55#include <linux/init.h> 55#include <linux/init.h>
56#include <linux/wait.h> 56#include <linux/wait.h>
57#include <linux/slab.h>
57#include <asm/system.h> 58#include <asm/system.h>
58#include <asm/io.h> 59#include <asm/io.h>
59#include <asm/atomic.h> 60#include <asm/atomic.h>
diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
index 23d95054705..cbe15a86c66 100644
--- a/drivers/atm/lanai.c
+++ b/drivers/atm/lanai.c
@@ -55,6 +55,7 @@
55 */ 55 */
56 56
57#include <linux/module.h> 57#include <linux/module.h>
58#include <linux/slab.h>
58#include <linux/mm.h> 59#include <linux/mm.h>
59#include <linux/atmdev.h> 60#include <linux/atmdev.h>
60#include <asm/io.h> 61#include <asm/io.h>
diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
index 50838407b11..b7473a6110a 100644
--- a/drivers/atm/nicstar.c
+++ b/drivers/atm/nicstar.c
@@ -49,6 +49,7 @@
49#include <linux/timer.h> 49#include <linux/timer.h>
50#include <linux/interrupt.h> 50#include <linux/interrupt.h>
51#include <linux/bitops.h> 51#include <linux/bitops.h>
52#include <linux/slab.h>
52#include <asm/io.h> 53#include <asm/io.h>
53#include <asm/uaccess.h> 54#include <asm/uaccess.h>
54#include <asm/atomic.h> 55#include <asm/atomic.h>
diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
index 51eed679a05..ded76c4c9f4 100644
--- a/drivers/atm/solos-pci.c
+++ b/drivers/atm/solos-pci.c
@@ -40,6 +40,7 @@
40#include <linux/firmware.h> 40#include <linux/firmware.h>
41#include <linux/ctype.h> 41#include <linux/ctype.h>
42#include <linux/swab.h> 42#include <linux/swab.h>
43#include <linux/slab.h>
43 44
44#define VERSION "0.07" 45#define VERSION "0.07"
45#define PTAG "solos-pci" 46#define PTAG "solos-pci"
diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
index 6dd3f591996..da4b91ffa53 100644
--- a/drivers/atm/suni.c
+++ b/drivers/atm/suni.c
@@ -21,6 +21,7 @@
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/capability.h> 22#include <linux/capability.h>
23#include <linux/atm_suni.h> 23#include <linux/atm_suni.h>
24#include <linux/slab.h>
24#include <asm/system.h> 25#include <asm/system.h>
25#include <asm/param.h> 26#include <asm/param.h>
26#include <asm/uaccess.h> 27#include <asm/uaccess.h>
diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
index fc8cb07c247..c45ae0573bb 100644
--- a/drivers/atm/uPD98402.c
+++ b/drivers/atm/uPD98402.c
@@ -9,6 +9,7 @@
9#include <linux/atmdev.h> 9#include <linux/atmdev.h>
10#include <linux/sonet.h> 10#include <linux/sonet.h>
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/slab.h>
12#include <asm/uaccess.h> 13#include <asm/uaccess.h>
13#include <asm/atomic.h> 14#include <asm/atomic.h>
14 15
diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
index 2e9635be048..702accec89e 100644
--- a/drivers/atm/zatm.c
+++ b/drivers/atm/zatm.c
@@ -21,6 +21,7 @@
21#include <linux/capability.h> 21#include <linux/capability.h>
22#include <linux/bitops.h> 22#include <linux/bitops.h>
23#include <linux/wait.h> 23#include <linux/wait.h>
24#include <linux/slab.h>
24#include <asm/byteorder.h> 25#include <asm/byteorder.h>
25#include <asm/system.h> 26#include <asm/system.h>
26#include <asm/string.h> 27#include <asm/string.h>
diff --git a/drivers/auxdisplay/cfag12864b.c b/drivers/auxdisplay/cfag12864b.c
index eacb175f6bd..49758593a5b 100644
--- a/drivers/auxdisplay/cfag12864b.c
+++ b/drivers/auxdisplay/cfag12864b.c
@@ -27,6 +27,7 @@
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/kernel.h> 28#include <linux/kernel.h>
29#include <linux/fs.h> 29#include <linux/fs.h>
30#include <linux/slab.h>
30#include <linux/cdev.h> 31#include <linux/cdev.h>
31#include <linux/delay.h> 32#include <linux/delay.h>
32#include <linux/device.h> 33#include <linux/device.h>
diff --git a/drivers/auxdisplay/cfag12864bfb.c b/drivers/auxdisplay/cfag12864bfb.c
index b0ca5a47f47..3fecfb446d9 100644
--- a/drivers/auxdisplay/cfag12864bfb.c
+++ b/drivers/auxdisplay/cfag12864bfb.c
@@ -31,7 +31,6 @@
31#include <linux/fb.h> 31#include <linux/fb.h>
32#include <linux/mm.h> 32#include <linux/mm.h>
33#include <linux/platform_device.h> 33#include <linux/platform_device.h>
34#include <linux/slab.h>
35#include <linux/string.h> 34#include <linux/string.h>
36#include <linux/uaccess.h> 35#include <linux/uaccess.h>
37#include <linux/cfag12864b.h> 36#include <linux/cfag12864b.h>
diff --git a/drivers/base/attribute_container.c b/drivers/base/attribute_container.c
index b9cda053d3c..8fc200b2e2c 100644
--- a/drivers/base/attribute_container.c
+++ b/drivers/base/attribute_container.c
@@ -328,6 +328,7 @@ attribute_container_add_attrs(struct device *classdev)
328 return sysfs_create_group(&classdev->kobj, cont->grp); 328 return sysfs_create_group(&classdev->kobj, cont->grp);
329 329
330 for (i = 0; attrs[i]; i++) { 330 for (i = 0; attrs[i]; i++) {
331 sysfs_attr_init(&attrs[i]->attr);
331 error = device_create_file(classdev, attrs[i]); 332 error = device_create_file(classdev, attrs[i]);
332 if (error) 333 if (error)
333 return error; 334 return error;
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 71f6af5c8b0..12eec3f633b 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -13,6 +13,7 @@
13#include <linux/device.h> 13#include <linux/device.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/slab.h>
16#include <linux/init.h> 17#include <linux/init.h>
17#include <linux/string.h> 18#include <linux/string.h>
18#include "base.h" 19#include "base.h"
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 0147f476b8a..9c6a0d6408e 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -219,6 +219,8 @@ static void class_create_release(struct class *cls)
219 * This is used to create a struct class pointer that can then be used 219 * This is used to create a struct class pointer that can then be used
220 * in calls to device_create(). 220 * in calls to device_create().
221 * 221 *
222 * Returns &struct class pointer on success, or ERR_PTR() on error.
223 *
222 * Note, the pointer created here is to be destroyed when finished by 224 * Note, the pointer created here is to be destroyed when finished by
223 * making a call to class_destroy(). 225 * making a call to class_destroy().
224 */ 226 */
diff --git a/drivers/base/core.c b/drivers/base/core.c
index ef55df34ddd..b56a0ba31d4 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1345,6 +1345,8 @@ static void root_device_release(struct device *dev)
1345 * 'module' symlink which points to the @owner directory 1345 * 'module' symlink which points to the @owner directory
1346 * in sysfs. 1346 * in sysfs.
1347 * 1347 *
1348 * Returns &struct device pointer on success, or ERR_PTR() on error.
1349 *
1348 * Note: You probably want to use root_device_register(). 1350 * Note: You probably want to use root_device_register().
1349 */ 1351 */
1350struct device *__root_device_register(const char *name, struct module *owner) 1352struct device *__root_device_register(const char *name, struct module *owner)
@@ -1432,6 +1434,8 @@ static void device_create_release(struct device *dev)
1432 * Any further sysfs files that might be required can be created using this 1434 * Any further sysfs files that might be required can be created using this
1433 * pointer. 1435 * pointer.
1434 * 1436 *
1437 * Returns &struct device pointer on success, or ERR_PTR() on error.
1438 *
1435 * Note: the struct class passed to this function must have previously 1439 * Note: the struct class passed to this function must have previously
1436 * been created with a call to class_create(). 1440 * been created with a call to class_create().
1437 */ 1441 */
@@ -1492,6 +1496,8 @@ EXPORT_SYMBOL_GPL(device_create_vargs);
1492 * Any further sysfs files that might be required can be created using this 1496 * Any further sysfs files that might be required can be created using this
1493 * pointer. 1497 * pointer.
1494 * 1498 *
1499 * Returns &struct device pointer on success, or ERR_PTR() on error.
1500 *
1495 * Note: the struct class passed to this function must have previously 1501 * Note: the struct class passed to this function must have previously
1496 * been created with a call to class_create(). 1502 * been created with a call to class_create().
1497 */ 1503 */
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 7036e8e96ab..f35719aab3c 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -10,6 +10,7 @@
10#include <linux/topology.h> 10#include <linux/topology.h>
11#include <linux/device.h> 11#include <linux/device.h>
12#include <linux/node.h> 12#include <linux/node.h>
13#include <linux/gfp.h>
13 14
14#include "base.h" 15#include "base.h"
15 16
@@ -79,24 +80,24 @@ void unregister_cpu(struct cpu *cpu)
79} 80}
80 81
81#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE 82#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
82static ssize_t cpu_probe_store(struct sys_device *dev, 83static ssize_t cpu_probe_store(struct sysdev_class *class,
83 struct sysdev_attribute *attr, 84 struct sysdev_class_attribute *attr,
84 const char *buf, 85 const char *buf,
85 size_t count) 86 size_t count)
86{ 87{
87 return arch_cpu_probe(buf, count); 88 return arch_cpu_probe(buf, count);
88} 89}
89 90
90static ssize_t cpu_release_store(struct sys_device *dev, 91static ssize_t cpu_release_store(struct sysdev_class *class,
91 struct sysdev_attribute *attr, 92 struct sysdev_class_attribute *attr,
92 const char *buf, 93 const char *buf,
93 size_t count) 94 size_t count)
94{ 95{
95 return arch_cpu_release(buf, count); 96 return arch_cpu_release(buf, count);
96} 97}
97 98
98static SYSDEV_ATTR(probe, S_IWUSR, NULL, cpu_probe_store); 99static SYSDEV_CLASS_ATTR(probe, S_IWUSR, NULL, cpu_probe_store);
99static SYSDEV_ATTR(release, S_IWUSR, NULL, cpu_release_store); 100static SYSDEV_CLASS_ATTR(release, S_IWUSR, NULL, cpu_release_store);
100#endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */ 101#endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */
101 102
102#else /* ... !CONFIG_HOTPLUG_CPU */ 103#else /* ... !CONFIG_HOTPLUG_CPU */
diff --git a/drivers/base/devres.c b/drivers/base/devres.c
index 05dd307e8f0..cf7a0c78805 100644
--- a/drivers/base/devres.c
+++ b/drivers/base/devres.c
@@ -9,6 +9,7 @@
9 9
10#include <linux/device.h> 10#include <linux/device.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/slab.h>
12 13
13#include "base.h" 14#include "base.h"
14 15
diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
index dac478c6e46..057cf11326b 100644
--- a/drivers/base/devtmpfs.c
+++ b/drivers/base/devtmpfs.c
@@ -23,6 +23,7 @@
23#include <linux/cred.h> 23#include <linux/cred.h>
24#include <linux/sched.h> 24#include <linux/sched.h>
25#include <linux/init_task.h> 25#include <linux/init_task.h>
26#include <linux/slab.h>
26 27
27static struct vfsmount *dev_mnt; 28static struct vfsmount *dev_mnt;
28 29
diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c
index 962a3b574f2..d4d8ce53886 100644
--- a/drivers/base/dma-coherent.c
+++ b/drivers/base/dma-coherent.c
@@ -2,6 +2,7 @@
2 * Coherent per-device memory handling. 2 * Coherent per-device memory handling.
3 * Borrowed from i386 3 * Borrowed from i386
4 */ 4 */
5#include <linux/slab.h>
5#include <linux/kernel.h> 6#include <linux/kernel.h>
6#include <linux/dma-mapping.h> 7#include <linux/dma-mapping.h>
7 8
diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
index ca9186f70a6..763d59c1eb6 100644
--- a/drivers/base/dma-mapping.c
+++ b/drivers/base/dma-mapping.c
@@ -8,6 +8,7 @@
8 */ 8 */
9 9
10#include <linux/dma-mapping.h> 10#include <linux/dma-mapping.h>
11#include <linux/gfp.h>
11 12
12/* 13/*
13 * Managed DMA API 14 * Managed DMA API
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 90c9fff09ea..b631f7c5945 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -13,6 +13,7 @@
13#include <linux/device.h> 13#include <linux/device.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/slab.h>
16#include <linux/string.h> 17#include <linux/string.h>
17#include "base.h" 18#include "base.h"
18 19
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index d0dc26ad538..985da11174e 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -19,6 +19,7 @@
19#include <linux/kthread.h> 19#include <linux/kthread.h>
20#include <linux/highmem.h> 20#include <linux/highmem.h>
21#include <linux/firmware.h> 21#include <linux/firmware.h>
22#include <linux/slab.h>
22 23
23#define to_dev(obj) container_of(obj, struct device, kobj) 24#define to_dev(obj) container_of(obj, struct device, kobj)
24 25
@@ -78,6 +79,7 @@ firmware_timeout_show(struct class *class,
78/** 79/**
79 * firmware_timeout_store - set number of seconds to wait for firmware 80 * firmware_timeout_store - set number of seconds to wait for firmware
80 * @class: device class pointer 81 * @class: device class pointer
82 * @attr: device attribute pointer
81 * @buf: buffer to scan for timeout value 83 * @buf: buffer to scan for timeout value
82 * @count: number of bytes in @buf 84 * @count: number of bytes in @buf
83 * 85 *
@@ -442,6 +444,7 @@ static int fw_setup_device(struct firmware *fw, struct device **dev_p,
442 fw_priv = dev_get_drvdata(f_dev); 444 fw_priv = dev_get_drvdata(f_dev);
443 445
444 fw_priv->fw = fw; 446 fw_priv->fw = fw;
447 sysfs_bin_attr_init(&fw_priv->attr_data);
445 retval = sysfs_create_bin_file(&f_dev->kobj, &fw_priv->attr_data); 448 retval = sysfs_create_bin_file(&f_dev->kobj, &fw_priv->attr_data);
446 if (retval) { 449 if (retval) {
447 dev_err(device, "%s: sysfs_create_bin_file failed\n", __func__); 450 dev_err(device, "%s: sysfs_create_bin_file failed\n", __func__);
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index db0848e54cc..933442f4032 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -22,6 +22,7 @@
22#include <linux/mm.h> 22#include <linux/mm.h>
23#include <linux/mutex.h> 23#include <linux/mutex.h>
24#include <linux/stat.h> 24#include <linux/stat.h>
25#include <linux/slab.h>
25 26
26#include <asm/atomic.h> 27#include <asm/atomic.h>
27#include <asm/uaccess.h> 28#include <asm/uaccess.h>
@@ -312,7 +313,7 @@ static ssize_t
312print_block_size(struct sysdev_class *class, struct sysdev_class_attribute *attr, 313print_block_size(struct sysdev_class *class, struct sysdev_class_attribute *attr,
313 char *buf) 314 char *buf)
314{ 315{
315 return sprintf(buf, "%#lx\n", (unsigned long)PAGES_PER_SECTION * PAGE_SIZE); 316 return sprintf(buf, "%lx\n", (unsigned long)PAGES_PER_SECTION * PAGE_SIZE);
316} 317}
317 318
318static SYSDEV_CLASS_ATTR(block_size_bytes, 0444, print_block_size, NULL); 319static SYSDEV_CLASS_ATTR(block_size_bytes, 0444, print_block_size, NULL);
diff --git a/drivers/base/module.c b/drivers/base/module.c
index 103be9cacb0..f32f2f9b7be 100644
--- a/drivers/base/module.c
+++ b/drivers/base/module.c
@@ -7,6 +7,7 @@
7#include <linux/device.h> 7#include <linux/device.h>
8#include <linux/module.h> 8#include <linux/module.h>
9#include <linux/errno.h> 9#include <linux/errno.h>
10#include <linux/slab.h>
10#include <linux/string.h> 11#include <linux/string.h>
11#include "base.h" 12#include "base.h"
12 13
diff --git a/drivers/base/node.c b/drivers/base/node.c
index ad43185ec15..057979a19ee 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -15,6 +15,7 @@
15#include <linux/cpu.h> 15#include <linux/cpu.h>
16#include <linux/device.h> 16#include <linux/device.h>
17#include <linux/swap.h> 17#include <linux/swap.h>
18#include <linux/slab.h>
18 19
19static struct sysdev_class_attribute *node_state_attrs[]; 20static struct sysdev_class_attribute *node_state_attrs[];
20 21
@@ -165,8 +166,11 @@ static ssize_t node_read_distance(struct sys_device * dev,
165 int len = 0; 166 int len = 0;
166 int i; 167 int i;
167 168
168 /* buf currently PAGE_SIZE, need ~4 chars per node */ 169 /*
169 BUILD_BUG_ON(MAX_NUMNODES*4 > PAGE_SIZE/2); 170 * buf is currently PAGE_SIZE in length and each node needs 4 chars
171 * at the most (distance + space or newline).
172 */
173 BUILD_BUG_ON(MAX_NUMNODES * 4 > PAGE_SIZE);
170 174
171 for_each_online_node(i) 175 for_each_online_node(i)
172 len += sprintf(buf + len, "%s%d", i ? " " : "", node_distance(nid, i)); 176 len += sprintf(buf + len, "%s%d", i ? " " : "", node_distance(nid, i));
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 1ba9d617d24..4b4b565c835 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -362,6 +362,8 @@ EXPORT_SYMBOL_GPL(platform_device_unregister);
362 * enumeration tasks, they don't fully conform to the Linux driver model. 362 * enumeration tasks, they don't fully conform to the Linux driver model.
363 * In particular, when such drivers are built as modules, they can't be 363 * In particular, when such drivers are built as modules, they can't be
364 * "hotplugged". 364 * "hotplugged".
365 *
366 * Returns &struct platform_device pointer on success, or ERR_PTR() on error.
365 */ 367 */
366struct platform_device *platform_device_register_simple(const char *name, 368struct platform_device *platform_device_register_simple(const char *name,
367 int id, 369 int id,
@@ -408,6 +410,8 @@ EXPORT_SYMBOL_GPL(platform_device_register_simple);
408 * allocated for the device allows drivers using such devices to be 410 * allocated for the device allows drivers using such devices to be
409 * unloaded without waiting for the last reference to the device to be 411 * unloaded without waiting for the last reference to the device to be
410 * dropped. 412 * dropped.
413 *
414 * Returns &struct platform_device pointer on success, or ERR_PTR() on error.
411 */ 415 */
412struct platform_device *platform_device_register_data( 416struct platform_device *platform_device_register_data(
413 struct device *parent, 417 struct device *parent,
@@ -559,6 +563,8 @@ EXPORT_SYMBOL_GPL(platform_driver_probe);
559 * 563 *
560 * Use this in legacy-style modules that probe hardware directly and 564 * Use this in legacy-style modules that probe hardware directly and
561 * register a single platform device and corresponding platform driver. 565 * register a single platform device and corresponding platform driver.
566 *
567 * Returns &struct platform_device pointer on success, or ERR_PTR() on error.
562 */ 568 */
563struct platform_device * __init_or_module platform_create_bundle( 569struct platform_device * __init_or_module platform_create_bundle(
564 struct platform_driver *driver, 570 struct platform_driver *driver,
@@ -1052,9 +1058,11 @@ static __initdata LIST_HEAD(early_platform_driver_list);
1052static __initdata LIST_HEAD(early_platform_device_list); 1058static __initdata LIST_HEAD(early_platform_device_list);
1053 1059
1054/** 1060/**
1055 * early_platform_driver_register 1061 * early_platform_driver_register - register early platform driver
1056 * @epdrv: early_platform driver structure 1062 * @epdrv: early_platform driver structure
1057 * @buf: string passed from early_param() 1063 * @buf: string passed from early_param()
1064 *
1065 * Helper function for early_platform_init() / early_platform_init_buffer()
1058 */ 1066 */
1059int __init early_platform_driver_register(struct early_platform_driver *epdrv, 1067int __init early_platform_driver_register(struct early_platform_driver *epdrv,
1060 char *buf) 1068 char *buf)
@@ -1106,9 +1114,12 @@ int __init early_platform_driver_register(struct early_platform_driver *epdrv,
1106} 1114}
1107 1115
1108/** 1116/**
1109 * early_platform_add_devices - add a numbers of early platform devices 1117 * early_platform_add_devices - adds a number of early platform devices
1110 * @devs: array of early platform devices to add 1118 * @devs: array of early platform devices to add
1111 * @num: number of early platform devices in array 1119 * @num: number of early platform devices in array
1120 *
1121 * Used by early architecture code to register early platform devices and
1122 * their platform data.
1112 */ 1123 */
1113void __init early_platform_add_devices(struct platform_device **devs, int num) 1124void __init early_platform_add_devices(struct platform_device **devs, int num)
1114{ 1125{
@@ -1128,8 +1139,12 @@ void __init early_platform_add_devices(struct platform_device **devs, int num)
1128} 1139}
1129 1140
1130/** 1141/**
1131 * early_platform_driver_register_all 1142 * early_platform_driver_register_all - register early platform drivers
1132 * @class_str: string to identify early platform driver class 1143 * @class_str: string to identify early platform driver class
1144 *
1145 * Used by architecture code to register all early platform drivers
1146 * for a certain class. If omitted then only early platform drivers
1147 * with matching kernel command line class parameters will be registered.
1133 */ 1148 */
1134void __init early_platform_driver_register_all(char *class_str) 1149void __init early_platform_driver_register_all(char *class_str)
1135{ 1150{
@@ -1151,7 +1166,7 @@ void __init early_platform_driver_register_all(char *class_str)
1151} 1166}
1152 1167
1153/** 1168/**
1154 * early_platform_match 1169 * early_platform_match - find early platform device matching driver
1155 * @epdrv: early platform driver structure 1170 * @epdrv: early platform driver structure
1156 * @id: id to match against 1171 * @id: id to match against
1157 */ 1172 */
@@ -1169,7 +1184,7 @@ early_platform_match(struct early_platform_driver *epdrv, int id)
1169} 1184}
1170 1185
1171/** 1186/**
1172 * early_platform_left 1187 * early_platform_left - check if early platform driver has matching devices
1173 * @epdrv: early platform driver structure 1188 * @epdrv: early platform driver structure
1174 * @id: return true if id or above exists 1189 * @id: return true if id or above exists
1175 */ 1190 */
@@ -1187,7 +1202,7 @@ static __init int early_platform_left(struct early_platform_driver *epdrv,
1187} 1202}
1188 1203
1189/** 1204/**
1190 * early_platform_driver_probe_id 1205 * early_platform_driver_probe_id - probe drivers matching class_str and id
1191 * @class_str: string to identify early platform driver class 1206 * @class_str: string to identify early platform driver class
1192 * @id: id to match against 1207 * @id: id to match against
1193 * @nr_probe: number of platform devices to successfully probe before exiting 1208 * @nr_probe: number of platform devices to successfully probe before exiting
@@ -1257,10 +1272,14 @@ static int __init early_platform_driver_probe_id(char *class_str,
1257} 1272}
1258 1273
1259/** 1274/**
1260 * early_platform_driver_probe 1275 * early_platform_driver_probe - probe a class of registered drivers
1261 * @class_str: string to identify early platform driver class 1276 * @class_str: string to identify early platform driver class
1262 * @nr_probe: number of platform devices to successfully probe before exiting 1277 * @nr_probe: number of platform devices to successfully probe before exiting
1263 * @user_only: only probe user specified early platform devices 1278 * @user_only: only probe user specified early platform devices
1279 *
1280 * Used by architecture code to probe registered early platform drivers
1281 * within a certain class. For probe to happen a registered early platform
1282 * device matching a registered early platform driver is needed.
1264 */ 1283 */
1265int __init early_platform_driver_probe(char *class_str, 1284int __init early_platform_driver_probe(char *class_str,
1266 int nr_probe, 1285 int nr_probe,
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index d477f4dc5e5..941fcb87e52 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -439,8 +439,23 @@ static int device_resume_noirq(struct device *dev, pm_message_t state)
439 if (dev->bus && dev->bus->pm) { 439 if (dev->bus && dev->bus->pm) {
440 pm_dev_dbg(dev, state, "EARLY "); 440 pm_dev_dbg(dev, state, "EARLY ");
441 error = pm_noirq_op(dev, dev->bus->pm, state); 441 error = pm_noirq_op(dev, dev->bus->pm, state);
442 if (error)
443 goto End;
442 } 444 }
443 445
446 if (dev->type && dev->type->pm) {
447 pm_dev_dbg(dev, state, "EARLY type ");
448 error = pm_noirq_op(dev, dev->type->pm, state);
449 if (error)
450 goto End;
451 }
452
453 if (dev->class && dev->class->pm) {
454 pm_dev_dbg(dev, state, "EARLY class ");
455 error = pm_noirq_op(dev, dev->class->pm, state);
456 }
457
458End:
444 TRACE_RESUME(error); 459 TRACE_RESUME(error);
445 return error; 460 return error;
446} 461}
@@ -735,10 +750,26 @@ static int device_suspend_noirq(struct device *dev, pm_message_t state)
735{ 750{
736 int error = 0; 751 int error = 0;
737 752
753 if (dev->class && dev->class->pm) {
754 pm_dev_dbg(dev, state, "LATE class ");
755 error = pm_noirq_op(dev, dev->class->pm, state);
756 if (error)
757 goto End;
758 }
759
760 if (dev->type && dev->type->pm) {
761 pm_dev_dbg(dev, state, "LATE type ");
762 error = pm_noirq_op(dev, dev->type->pm, state);
763 if (error)
764 goto End;
765 }
766
738 if (dev->bus && dev->bus->pm) { 767 if (dev->bus && dev->bus->pm) {
739 pm_dev_dbg(dev, state, "LATE "); 768 pm_dev_dbg(dev, state, "LATE ");
740 error = pm_noirq_op(dev, dev->bus->pm, state); 769 error = pm_noirq_op(dev, dev->bus->pm, state);
741 } 770 }
771
772End:
742 return error; 773 return error;
743} 774}
744 775
diff --git a/drivers/base/sys.c b/drivers/base/sys.c
index 8980feec5d1..9354dc10a36 100644
--- a/drivers/base/sys.c
+++ b/drivers/base/sys.c
@@ -17,7 +17,6 @@
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/slab.h>
21#include <linux/string.h> 20#include <linux/string.h>
22#include <linux/pm.h> 21#include <linux/pm.h>
23#include <linux/device.h> 22#include <linux/device.h>
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
index 459f1bc25a7..c5f22bb0a48 100644
--- a/drivers/block/DAC960.c
+++ b/drivers/block/DAC960.c
@@ -2533,7 +2533,6 @@ static bool DAC960_RegisterBlockDevice(DAC960_Controller_T *Controller)
2533 Controller->RequestQueue[n] = RequestQueue; 2533 Controller->RequestQueue[n] = RequestQueue;
2534 blk_queue_bounce_limit(RequestQueue, Controller->BounceBufferLimit); 2534 blk_queue_bounce_limit(RequestQueue, Controller->BounceBufferLimit);
2535 RequestQueue->queuedata = Controller; 2535 RequestQueue->queuedata = Controller;
2536 blk_queue_max_hw_segments(RequestQueue, Controller->DriverScatterGatherLimit);
2537 blk_queue_max_segments(RequestQueue, Controller->DriverScatterGatherLimit); 2536 blk_queue_max_segments(RequestQueue, Controller->DriverScatterGatherLimit);
2538 blk_queue_max_hw_sectors(RequestQueue, Controller->MaxBlocksPerCommand); 2537 blk_queue_max_hw_sectors(RequestQueue, Controller->MaxBlocksPerCommand);
2539 disk->queue = RequestQueue; 2538 disk->queue = RequestQueue;
diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c
index 05522583902..0182a22c423 100644
--- a/drivers/block/amiflop.c
+++ b/drivers/block/amiflop.c
@@ -54,6 +54,7 @@
54 */ 54 */
55 55
56#include <linux/module.h> 56#include <linux/module.h>
57#include <linux/slab.h>
57 58
58#include <linux/fd.h> 59#include <linux/fd.h>
59#include <linux/hdreg.h> 60#include <linux/hdreg.h>
diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
index 3af97d4da2d..035cefe4045 100644
--- a/drivers/block/aoe/aoeblk.c
+++ b/drivers/block/aoe/aoeblk.c
@@ -9,6 +9,7 @@
9#include <linux/backing-dev.h> 9#include <linux/backing-dev.h>
10#include <linux/fs.h> 10#include <linux/fs.h>
11#include <linux/ioctl.h> 11#include <linux/ioctl.h>
12#include <linux/slab.h>
12#include <linux/genhd.h> 13#include <linux/genhd.h>
13#include <linux/netdevice.h> 14#include <linux/netdevice.h>
14#include "aoe.h" 15#include "aoe.h"
diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c
index 62141ec09a2..4a1b9e7464a 100644
--- a/drivers/block/aoe/aoechr.c
+++ b/drivers/block/aoe/aoechr.c
@@ -8,6 +8,7 @@
8#include <linux/blkdev.h> 8#include <linux/blkdev.h>
9#include <linux/completion.h> 9#include <linux/completion.h>
10#include <linux/delay.h> 10#include <linux/delay.h>
11#include <linux/slab.h>
11#include <linux/smp_lock.h> 12#include <linux/smp_lock.h>
12#include <linux/skbuff.h> 13#include <linux/skbuff.h>
13#include "aoe.h" 14#include "aoe.h"
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index 64a223b0cc2..5674bd01d96 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -5,6 +5,7 @@
5 */ 5 */
6 6
7#include <linux/ata.h> 7#include <linux/ata.h>
8#include <linux/slab.h>
8#include <linux/hdreg.h> 9#include <linux/hdreg.h>
9#include <linux/blkdev.h> 10#include <linux/blkdev.h>
10#include <linux/skbuff.h> 11#include <linux/skbuff.h>
diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c
index fa67027789a..0849280bfc1 100644
--- a/drivers/block/aoe/aoedev.c
+++ b/drivers/block/aoe/aoedev.c
@@ -8,6 +8,7 @@
8#include <linux/blkdev.h> 8#include <linux/blkdev.h>
9#include <linux/netdevice.h> 9#include <linux/netdevice.h>
10#include <linux/delay.h> 10#include <linux/delay.h>
11#include <linux/slab.h>
11#include "aoe.h" 12#include "aoe.h"
12 13
13static void dummy_timer(ulong); 14static void dummy_timer(ulong);
diff --git a/drivers/block/aoe/aoenet.c b/drivers/block/aoe/aoenet.c
index ce0d62cd71b..4d3bc0d49df 100644
--- a/drivers/block/aoe/aoenet.c
+++ b/drivers/block/aoe/aoenet.c
@@ -4,6 +4,7 @@
4 * Ethernet portion of AoE driver 4 * Ethernet portion of AoE driver
5 */ 5 */
6 6
7#include <linux/gfp.h>
7#include <linux/hdreg.h> 8#include <linux/hdreg.h>
8#include <linux/blkdev.h> 9#include <linux/blkdev.h>
9#include <linux/netdevice.h> 10#include <linux/netdevice.h>
diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index c6ddeacb77f..6081e81d573 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -15,9 +15,9 @@
15#include <linux/blkdev.h> 15#include <linux/blkdev.h>
16#include <linux/bio.h> 16#include <linux/bio.h>
17#include <linux/highmem.h> 17#include <linux/highmem.h>
18#include <linux/gfp.h>
19#include <linux/radix-tree.h> 18#include <linux/radix-tree.h>
20#include <linux/buffer_head.h> /* invalidate_bh_lrus() */ 19#include <linux/buffer_head.h> /* invalidate_bh_lrus() */
20#include <linux/slab.h>
21 21
22#include <asm/uaccess.h> 22#include <asm/uaccess.h>
23 23
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 9e3af307aae..eb5ff0531cf 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -3341,6 +3341,7 @@ static irqreturn_t do_cciss_intr(int irq, void *dev_id)
3341 printk(KERN_WARNING 3341 printk(KERN_WARNING
3342 "cciss: controller cciss%d failed, stopping.\n", 3342 "cciss: controller cciss%d failed, stopping.\n",
3343 h->ctlr); 3343 h->ctlr);
3344 spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags);
3344 fail_all_cmds(h->ctlr); 3345 fail_all_cmds(h->ctlr);
3345 return IRQ_HANDLED; 3346 return IRQ_HANDLED;
3346 } 3347 }
diff --git a/drivers/block/drbd/drbd_actlog.c b/drivers/block/drbd/drbd_actlog.c
index 17956ff6a08..df018990c42 100644
--- a/drivers/block/drbd/drbd_actlog.c
+++ b/drivers/block/drbd/drbd_actlog.c
@@ -536,7 +536,9 @@ static void atodb_endio(struct bio *bio, int error)
536 put_ldev(mdev); 536 put_ldev(mdev);
537} 537}
538 538
539/* sector to word */
539#define S2W(s) ((s)<<(BM_EXT_SHIFT-BM_BLOCK_SHIFT-LN2_BPL)) 540#define S2W(s) ((s)<<(BM_EXT_SHIFT-BM_BLOCK_SHIFT-LN2_BPL))
541
540/* activity log to on disk bitmap -- prepare bio unless that sector 542/* activity log to on disk bitmap -- prepare bio unless that sector
541 * is already covered by previously prepared bios */ 543 * is already covered by previously prepared bios */
542static int atodb_prepare_unless_covered(struct drbd_conf *mdev, 544static int atodb_prepare_unless_covered(struct drbd_conf *mdev,
@@ -546,13 +548,20 @@ static int atodb_prepare_unless_covered(struct drbd_conf *mdev,
546{ 548{
547 struct bio *bio; 549 struct bio *bio;
548 struct page *page; 550 struct page *page;
549 sector_t on_disk_sector = enr + mdev->ldev->md.md_offset 551 sector_t on_disk_sector;
550 + mdev->ldev->md.bm_offset;
551 unsigned int page_offset = PAGE_SIZE; 552 unsigned int page_offset = PAGE_SIZE;
552 int offset; 553 int offset;
553 int i = 0; 554 int i = 0;
554 int err = -ENOMEM; 555 int err = -ENOMEM;
555 556
557 /* We always write aligned, full 4k blocks,
558 * so we can ignore the logical_block_size (for now) */
559 enr &= ~7U;
560 on_disk_sector = enr + mdev->ldev->md.md_offset
561 + mdev->ldev->md.bm_offset;
562
563 D_ASSERT(!(on_disk_sector & 7U));
564
556 /* Check if that enr is already covered by an already created bio. 565 /* Check if that enr is already covered by an already created bio.
557 * Caution, bios[] is not NULL terminated, 566 * Caution, bios[] is not NULL terminated,
558 * but only initialized to all NULL. 567 * but only initialized to all NULL.
@@ -588,7 +597,7 @@ static int atodb_prepare_unless_covered(struct drbd_conf *mdev,
588 597
589 offset = S2W(enr); 598 offset = S2W(enr);
590 drbd_bm_get_lel(mdev, offset, 599 drbd_bm_get_lel(mdev, offset,
591 min_t(size_t, S2W(1), drbd_bm_words(mdev) - offset), 600 min_t(size_t, S2W(8), drbd_bm_words(mdev) - offset),
592 kmap(page) + page_offset); 601 kmap(page) + page_offset);
593 kunmap(page); 602 kunmap(page);
594 603
@@ -597,7 +606,7 @@ static int atodb_prepare_unless_covered(struct drbd_conf *mdev,
597 bio->bi_bdev = mdev->ldev->md_bdev; 606 bio->bi_bdev = mdev->ldev->md_bdev;
598 bio->bi_sector = on_disk_sector; 607 bio->bi_sector = on_disk_sector;
599 608
600 if (bio_add_page(bio, page, MD_SECTOR_SIZE, page_offset) != MD_SECTOR_SIZE) 609 if (bio_add_page(bio, page, 4096, page_offset) != 4096)
601 goto out_put_page; 610 goto out_put_page;
602 611
603 atomic_inc(&wc->count); 612 atomic_inc(&wc->count);
@@ -1327,7 +1336,7 @@ int drbd_rs_del_all(struct drbd_conf *mdev)
1327 /* ok, ->resync is there. */ 1336 /* ok, ->resync is there. */
1328 for (i = 0; i < mdev->resync->nr_elements; i++) { 1337 for (i = 0; i < mdev->resync->nr_elements; i++) {
1329 e = lc_element_by_index(mdev->resync, i); 1338 e = lc_element_by_index(mdev->resync, i);
1330 bm_ext = e ? lc_entry(e, struct bm_extent, lce) : NULL; 1339 bm_ext = lc_entry(e, struct bm_extent, lce);
1331 if (bm_ext->lce.lc_number == LC_FREE) 1340 if (bm_ext->lce.lc_number == LC_FREE)
1332 continue; 1341 continue;
1333 if (bm_ext->lce.lc_number == mdev->resync_wenr) { 1342 if (bm_ext->lce.lc_number == mdev->resync_wenr) {
diff --git a/drivers/block/drbd/drbd_bitmap.c b/drivers/block/drbd/drbd_bitmap.c
index b61057e7788..3390716898d 100644
--- a/drivers/block/drbd/drbd_bitmap.c
+++ b/drivers/block/drbd/drbd_bitmap.c
@@ -26,6 +26,7 @@
26#include <linux/vmalloc.h> 26#include <linux/vmalloc.h>
27#include <linux/string.h> 27#include <linux/string.h>
28#include <linux/drbd.h> 28#include <linux/drbd.h>
29#include <linux/slab.h>
29#include <asm/kmap_types.h> 30#include <asm/kmap_types.h>
30#include "drbd_int.h" 31#include "drbd_int.h"
31 32
@@ -66,7 +67,7 @@ struct drbd_bitmap {
66 size_t bm_words; 67 size_t bm_words;
67 size_t bm_number_of_pages; 68 size_t bm_number_of_pages;
68 sector_t bm_dev_capacity; 69 sector_t bm_dev_capacity;
69 struct semaphore bm_change; /* serializes resize operations */ 70 struct mutex bm_change; /* serializes resize operations */
70 71
71 atomic_t bm_async_io; 72 atomic_t bm_async_io;
72 wait_queue_head_t bm_io_wait; 73 wait_queue_head_t bm_io_wait;
@@ -114,7 +115,7 @@ void drbd_bm_lock(struct drbd_conf *mdev, char *why)
114 return; 115 return;
115 } 116 }
116 117
117 trylock_failed = down_trylock(&b->bm_change); 118 trylock_failed = !mutex_trylock(&b->bm_change);
118 119
119 if (trylock_failed) { 120 if (trylock_failed) {
120 dev_warn(DEV, "%s going to '%s' but bitmap already locked for '%s' by %s\n", 121 dev_warn(DEV, "%s going to '%s' but bitmap already locked for '%s' by %s\n",
@@ -125,7 +126,7 @@ void drbd_bm_lock(struct drbd_conf *mdev, char *why)
125 b->bm_task == mdev->receiver.task ? "receiver" : 126 b->bm_task == mdev->receiver.task ? "receiver" :
126 b->bm_task == mdev->asender.task ? "asender" : 127 b->bm_task == mdev->asender.task ? "asender" :
127 b->bm_task == mdev->worker.task ? "worker" : "?"); 128 b->bm_task == mdev->worker.task ? "worker" : "?");
128 down(&b->bm_change); 129 mutex_lock(&b->bm_change);
129 } 130 }
130 if (__test_and_set_bit(BM_LOCKED, &b->bm_flags)) 131 if (__test_and_set_bit(BM_LOCKED, &b->bm_flags))
131 dev_err(DEV, "FIXME bitmap already locked in bm_lock\n"); 132 dev_err(DEV, "FIXME bitmap already locked in bm_lock\n");
@@ -147,7 +148,7 @@ void drbd_bm_unlock(struct drbd_conf *mdev)
147 148
148 b->bm_why = NULL; 149 b->bm_why = NULL;
149 b->bm_task = NULL; 150 b->bm_task = NULL;
150 up(&b->bm_change); 151 mutex_unlock(&b->bm_change);
151} 152}
152 153
153/* word offset to long pointer */ 154/* word offset to long pointer */
@@ -295,7 +296,7 @@ int drbd_bm_init(struct drbd_conf *mdev)
295 if (!b) 296 if (!b)
296 return -ENOMEM; 297 return -ENOMEM;
297 spin_lock_init(&b->bm_lock); 298 spin_lock_init(&b->bm_lock);
298 init_MUTEX(&b->bm_change); 299 mutex_init(&b->bm_change);
299 init_waitqueue_head(&b->bm_io_wait); 300 init_waitqueue_head(&b->bm_io_wait);
300 301
301 mdev->bitmap = b; 302 mdev->bitmap = b;
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
index d9301e861d9..e5e86a78182 100644
--- a/drivers/block/drbd/drbd_int.h
+++ b/drivers/block/drbd/drbd_int.h
@@ -261,6 +261,9 @@ static inline const char *cmdname(enum drbd_packets cmd)
261 [P_OV_REQUEST] = "OVRequest", 261 [P_OV_REQUEST] = "OVRequest",
262 [P_OV_REPLY] = "OVReply", 262 [P_OV_REPLY] = "OVReply",
263 [P_OV_RESULT] = "OVResult", 263 [P_OV_RESULT] = "OVResult",
264 [P_CSUM_RS_REQUEST] = "CsumRSRequest",
265 [P_RS_IS_IN_SYNC] = "CsumRSIsInSync",
266 [P_COMPRESSED_BITMAP] = "CBitmap",
264 [P_MAX_CMD] = NULL, 267 [P_MAX_CMD] = NULL,
265 }; 268 };
266 269
@@ -443,13 +446,18 @@ struct p_rs_param_89 {
443 char csums_alg[SHARED_SECRET_MAX]; 446 char csums_alg[SHARED_SECRET_MAX];
444} __packed; 447} __packed;
445 448
449enum drbd_conn_flags {
450 CF_WANT_LOSE = 1,
451 CF_DRY_RUN = 2,
452};
453
446struct p_protocol { 454struct p_protocol {
447 struct p_header head; 455 struct p_header head;
448 u32 protocol; 456 u32 protocol;
449 u32 after_sb_0p; 457 u32 after_sb_0p;
450 u32 after_sb_1p; 458 u32 after_sb_1p;
451 u32 after_sb_2p; 459 u32 after_sb_2p;
452 u32 want_lose; 460 u32 conn_flags;
453 u32 two_primaries; 461 u32 two_primaries;
454 462
455 /* Since protocol version 87 and higher. */ 463 /* Since protocol version 87 and higher. */
@@ -791,6 +799,8 @@ enum {
791 * while this is set. */ 799 * while this is set. */
792 RESIZE_PENDING, /* Size change detected locally, waiting for the response from 800 RESIZE_PENDING, /* Size change detected locally, waiting for the response from
793 * the peer, if it changed there as well. */ 801 * the peer, if it changed there as well. */
802 CONN_DRY_RUN, /* Expect disconnect after resync handshake. */
803 GOT_PING_ACK, /* set when we receive a ping_ack packet, misc wait gets woken */
794}; 804};
795 805
796struct drbd_bitmap; /* opaque for drbd_conf */ 806struct drbd_bitmap; /* opaque for drbd_conf */
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index ab871e00ffc..93d1f9b469d 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -1668,7 +1668,7 @@ int drbd_send_sync_param(struct drbd_conf *mdev, struct syncer_conf *sc)
1668int drbd_send_protocol(struct drbd_conf *mdev) 1668int drbd_send_protocol(struct drbd_conf *mdev)
1669{ 1669{
1670 struct p_protocol *p; 1670 struct p_protocol *p;
1671 int size, rv; 1671 int size, cf, rv;
1672 1672
1673 size = sizeof(struct p_protocol); 1673 size = sizeof(struct p_protocol);
1674 1674
@@ -1685,9 +1685,22 @@ int drbd_send_protocol(struct drbd_conf *mdev)
1685 p->after_sb_0p = cpu_to_be32(mdev->net_conf->after_sb_0p); 1685 p->after_sb_0p = cpu_to_be32(mdev->net_conf->after_sb_0p);
1686 p->after_sb_1p = cpu_to_be32(mdev->net_conf->after_sb_1p); 1686 p->after_sb_1p = cpu_to_be32(mdev->net_conf->after_sb_1p);
1687 p->after_sb_2p = cpu_to_be32(mdev->net_conf->after_sb_2p); 1687 p->after_sb_2p = cpu_to_be32(mdev->net_conf->after_sb_2p);
1688 p->want_lose = cpu_to_be32(mdev->net_conf->want_lose);
1689 p->two_primaries = cpu_to_be32(mdev->net_conf->two_primaries); 1688 p->two_primaries = cpu_to_be32(mdev->net_conf->two_primaries);
1690 1689
1690 cf = 0;
1691 if (mdev->net_conf->want_lose)
1692 cf |= CF_WANT_LOSE;
1693 if (mdev->net_conf->dry_run) {
1694 if (mdev->agreed_pro_version >= 92)
1695 cf |= CF_DRY_RUN;
1696 else {
1697 dev_err(DEV, "--dry-run is not supported by peer");
1698 kfree(p);
1699 return 0;
1700 }
1701 }
1702 p->conn_flags = cpu_to_be32(cf);
1703
1691 if (mdev->agreed_pro_version >= 87) 1704 if (mdev->agreed_pro_version >= 87)
1692 strcpy(p->integrity_alg, mdev->net_conf->integrity_alg); 1705 strcpy(p->integrity_alg, mdev->net_conf->integrity_alg);
1693 1706
@@ -3161,14 +3174,18 @@ void drbd_free_bc(struct drbd_backing_dev *ldev)
3161void drbd_free_sock(struct drbd_conf *mdev) 3174void drbd_free_sock(struct drbd_conf *mdev)
3162{ 3175{
3163 if (mdev->data.socket) { 3176 if (mdev->data.socket) {
3177 mutex_lock(&mdev->data.mutex);
3164 kernel_sock_shutdown(mdev->data.socket, SHUT_RDWR); 3178 kernel_sock_shutdown(mdev->data.socket, SHUT_RDWR);
3165 sock_release(mdev->data.socket); 3179 sock_release(mdev->data.socket);
3166 mdev->data.socket = NULL; 3180 mdev->data.socket = NULL;
3181 mutex_unlock(&mdev->data.mutex);
3167 } 3182 }
3168 if (mdev->meta.socket) { 3183 if (mdev->meta.socket) {
3184 mutex_lock(&mdev->meta.mutex);
3169 kernel_sock_shutdown(mdev->meta.socket, SHUT_RDWR); 3185 kernel_sock_shutdown(mdev->meta.socket, SHUT_RDWR);
3170 sock_release(mdev->meta.socket); 3186 sock_release(mdev->meta.socket);
3171 mdev->meta.socket = NULL; 3187 mdev->meta.socket = NULL;
3188 mutex_unlock(&mdev->meta.mutex);
3172 } 3189 }
3173} 3190}
3174 3191
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index 4df3b40b105..6429d2b19e0 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -285,8 +285,8 @@ int drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force)
285 } 285 }
286 286
287 if (r == SS_NO_UP_TO_DATE_DISK && force && 287 if (r == SS_NO_UP_TO_DATE_DISK && force &&
288 (mdev->state.disk == D_INCONSISTENT || 288 (mdev->state.disk < D_UP_TO_DATE &&
289 mdev->state.disk == D_OUTDATED)) { 289 mdev->state.disk >= D_INCONSISTENT)) {
290 mask.disk = D_MASK; 290 mask.disk = D_MASK;
291 val.disk = D_UP_TO_DATE; 291 val.disk = D_UP_TO_DATE;
292 forced = 1; 292 forced = 1;
@@ -407,7 +407,7 @@ static int drbd_nl_primary(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp,
407 } 407 }
408 408
409 reply->ret_code = 409 reply->ret_code =
410 drbd_set_role(mdev, R_PRIMARY, primary_args.overwrite_peer); 410 drbd_set_role(mdev, R_PRIMARY, primary_args.primary_force);
411 411
412 return 0; 412 return 0;
413} 413}
@@ -941,6 +941,25 @@ static int drbd_nl_disk_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp
941 941
942 drbd_md_set_sector_offsets(mdev, nbc); 942 drbd_md_set_sector_offsets(mdev, nbc);
943 943
944 /* allocate a second IO page if logical_block_size != 512 */
945 logical_block_size = bdev_logical_block_size(nbc->md_bdev);
946 if (logical_block_size == 0)
947 logical_block_size = MD_SECTOR_SIZE;
948
949 if (logical_block_size != MD_SECTOR_SIZE) {
950 if (!mdev->md_io_tmpp) {
951 struct page *page = alloc_page(GFP_NOIO);
952 if (!page)
953 goto force_diskless_dec;
954
955 dev_warn(DEV, "Meta data's bdev logical_block_size = %d != %d\n",
956 logical_block_size, MD_SECTOR_SIZE);
957 dev_warn(DEV, "Workaround engaged (has performance impact).\n");
958
959 mdev->md_io_tmpp = page;
960 }
961 }
962
944 if (!mdev->bitmap) { 963 if (!mdev->bitmap) {
945 if (drbd_bm_init(mdev)) { 964 if (drbd_bm_init(mdev)) {
946 retcode = ERR_NOMEM; 965 retcode = ERR_NOMEM;
@@ -980,25 +999,6 @@ static int drbd_nl_disk_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp
980 goto force_diskless_dec; 999 goto force_diskless_dec;
981 } 1000 }
982 1001
983 /* allocate a second IO page if logical_block_size != 512 */
984 logical_block_size = bdev_logical_block_size(nbc->md_bdev);
985 if (logical_block_size == 0)
986 logical_block_size = MD_SECTOR_SIZE;
987
988 if (logical_block_size != MD_SECTOR_SIZE) {
989 if (!mdev->md_io_tmpp) {
990 struct page *page = alloc_page(GFP_NOIO);
991 if (!page)
992 goto force_diskless_dec;
993
994 dev_warn(DEV, "Meta data's bdev logical_block_size = %d != %d\n",
995 logical_block_size, MD_SECTOR_SIZE);
996 dev_warn(DEV, "Workaround engaged (has performance impact).\n");
997
998 mdev->md_io_tmpp = page;
999 }
1000 }
1001
1002 /* Reset the "barriers don't work" bits here, then force meta data to 1002 /* Reset the "barriers don't work" bits here, then force meta data to
1003 * be written, to ensure we determine if barriers are supported. */ 1003 * be written, to ensure we determine if barriers are supported. */
1004 if (nbc->dc.no_md_flush) 1004 if (nbc->dc.no_md_flush)
diff --git a/drivers/block/drbd/drbd_proc.c b/drivers/block/drbd/drbd_proc.c
index df8ad9660d8..be3374b6846 100644
--- a/drivers/block/drbd/drbd_proc.c
+++ b/drivers/block/drbd/drbd_proc.c
@@ -28,7 +28,6 @@
28#include <asm/uaccess.h> 28#include <asm/uaccess.h>
29#include <linux/fs.h> 29#include <linux/fs.h>
30#include <linux/file.h> 30#include <linux/file.h>
31#include <linux/slab.h>
32#include <linux/proc_fs.h> 31#include <linux/proc_fs.h>
33#include <linux/seq_file.h> 32#include <linux/seq_file.h>
34#include <linux/drbd.h> 33#include <linux/drbd.h>
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index d065c646b35..3f096e7959b 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -899,7 +899,8 @@ retry:
899 899
900 drbd_thread_start(&mdev->asender); 900 drbd_thread_start(&mdev->asender);
901 901
902 drbd_send_protocol(mdev); 902 if (!drbd_send_protocol(mdev))
903 return -1;
903 drbd_send_sync_param(mdev, &mdev->sync_conf); 904 drbd_send_sync_param(mdev, &mdev->sync_conf);
904 drbd_send_sizes(mdev, 0); 905 drbd_send_sizes(mdev, 0);
905 drbd_send_uuids(mdev); 906 drbd_send_uuids(mdev);
@@ -2513,6 +2514,10 @@ static enum drbd_conns drbd_sync_handshake(struct drbd_conf *mdev, enum drbd_rol
2513 } 2514 }
2514 2515
2515 if (hg == -100) { 2516 if (hg == -100) {
2517 /* FIXME this log message is not correct if we end up here
2518 * after an attempted attach on a diskless node.
2519 * We just refuse to attach -- well, we drop the "connection"
2520 * to that disk, in a way... */
2516 dev_alert(DEV, "Split-Brain detected, dropping connection!\n"); 2521 dev_alert(DEV, "Split-Brain detected, dropping connection!\n");
2517 drbd_khelper(mdev, "split-brain"); 2522 drbd_khelper(mdev, "split-brain");
2518 return C_MASK; 2523 return C_MASK;
@@ -2538,6 +2543,16 @@ static enum drbd_conns drbd_sync_handshake(struct drbd_conf *mdev, enum drbd_rol
2538 } 2543 }
2539 } 2544 }
2540 2545
2546 if (mdev->net_conf->dry_run || test_bit(CONN_DRY_RUN, &mdev->flags)) {
2547 if (hg == 0)
2548 dev_info(DEV, "dry-run connect: No resync, would become Connected immediately.\n");
2549 else
2550 dev_info(DEV, "dry-run connect: Would become %s, doing a %s resync.",
2551 drbd_conn_str(hg > 0 ? C_SYNC_SOURCE : C_SYNC_TARGET),
2552 abs(hg) >= 2 ? "full" : "bit-map based");
2553 return C_MASK;
2554 }
2555
2541 if (abs(hg) >= 2) { 2556 if (abs(hg) >= 2) {
2542 dev_info(DEV, "Writing the whole bitmap, full sync required after drbd_sync_handshake.\n"); 2557 dev_info(DEV, "Writing the whole bitmap, full sync required after drbd_sync_handshake.\n");
2543 if (drbd_bitmap_io(mdev, &drbd_bmio_set_n_write, "set_n_write from sync_handshake")) 2558 if (drbd_bitmap_io(mdev, &drbd_bmio_set_n_write, "set_n_write from sync_handshake"))
@@ -2585,7 +2600,7 @@ static int receive_protocol(struct drbd_conf *mdev, struct p_header *h)
2585 struct p_protocol *p = (struct p_protocol *)h; 2600 struct p_protocol *p = (struct p_protocol *)h;
2586 int header_size, data_size; 2601 int header_size, data_size;
2587 int p_proto, p_after_sb_0p, p_after_sb_1p, p_after_sb_2p; 2602 int p_proto, p_after_sb_0p, p_after_sb_1p, p_after_sb_2p;
2588 int p_want_lose, p_two_primaries; 2603 int p_want_lose, p_two_primaries, cf;
2589 char p_integrity_alg[SHARED_SECRET_MAX] = ""; 2604 char p_integrity_alg[SHARED_SECRET_MAX] = "";
2590 2605
2591 header_size = sizeof(*p) - sizeof(*h); 2606 header_size = sizeof(*p) - sizeof(*h);
@@ -2598,8 +2613,14 @@ static int receive_protocol(struct drbd_conf *mdev, struct p_header *h)
2598 p_after_sb_0p = be32_to_cpu(p->after_sb_0p); 2613 p_after_sb_0p = be32_to_cpu(p->after_sb_0p);
2599 p_after_sb_1p = be32_to_cpu(p->after_sb_1p); 2614 p_after_sb_1p = be32_to_cpu(p->after_sb_1p);
2600 p_after_sb_2p = be32_to_cpu(p->after_sb_2p); 2615 p_after_sb_2p = be32_to_cpu(p->after_sb_2p);
2601 p_want_lose = be32_to_cpu(p->want_lose);
2602 p_two_primaries = be32_to_cpu(p->two_primaries); 2616 p_two_primaries = be32_to_cpu(p->two_primaries);
2617 cf = be32_to_cpu(p->conn_flags);
2618 p_want_lose = cf & CF_WANT_LOSE;
2619
2620 clear_bit(CONN_DRY_RUN, &mdev->flags);
2621
2622 if (cf & CF_DRY_RUN)
2623 set_bit(CONN_DRY_RUN, &mdev->flags);
2603 2624
2604 if (p_proto != mdev->net_conf->wire_protocol) { 2625 if (p_proto != mdev->net_conf->wire_protocol) {
2605 dev_err(DEV, "incompatible communication protocols\n"); 2626 dev_err(DEV, "incompatible communication protocols\n");
@@ -3118,13 +3139,16 @@ static int receive_state(struct drbd_conf *mdev, struct p_header *h)
3118 3139
3119 put_ldev(mdev); 3140 put_ldev(mdev);
3120 if (nconn == C_MASK) { 3141 if (nconn == C_MASK) {
3142 nconn = C_CONNECTED;
3121 if (mdev->state.disk == D_NEGOTIATING) { 3143 if (mdev->state.disk == D_NEGOTIATING) {
3122 drbd_force_state(mdev, NS(disk, D_DISKLESS)); 3144 drbd_force_state(mdev, NS(disk, D_DISKLESS));
3123 nconn = C_CONNECTED;
3124 } else if (peer_state.disk == D_NEGOTIATING) { 3145 } else if (peer_state.disk == D_NEGOTIATING) {
3125 dev_err(DEV, "Disk attach process on the peer node was aborted.\n"); 3146 dev_err(DEV, "Disk attach process on the peer node was aborted.\n");
3126 peer_state.disk = D_DISKLESS; 3147 peer_state.disk = D_DISKLESS;
3148 real_peer_disk = D_DISKLESS;
3127 } else { 3149 } else {
3150 if (test_and_clear_bit(CONN_DRY_RUN, &mdev->flags))
3151 return FALSE;
3128 D_ASSERT(oconn == C_WF_REPORT_PARAMS); 3152 D_ASSERT(oconn == C_WF_REPORT_PARAMS);
3129 drbd_force_state(mdev, NS(conn, C_DISCONNECTING)); 3153 drbd_force_state(mdev, NS(conn, C_DISCONNECTING));
3130 return FALSE; 3154 return FALSE;
@@ -3594,10 +3618,7 @@ static void drbd_disconnect(struct drbd_conf *mdev)
3594 3618
3595 /* asender does not clean up anything. it must not interfere, either */ 3619 /* asender does not clean up anything. it must not interfere, either */
3596 drbd_thread_stop(&mdev->asender); 3620 drbd_thread_stop(&mdev->asender);
3597
3598 mutex_lock(&mdev->data.mutex);
3599 drbd_free_sock(mdev); 3621 drbd_free_sock(mdev);
3600 mutex_unlock(&mdev->data.mutex);
3601 3622
3602 spin_lock_irq(&mdev->req_lock); 3623 spin_lock_irq(&mdev->req_lock);
3603 _drbd_wait_ee_list_empty(mdev, &mdev->active_ee); 3624 _drbd_wait_ee_list_empty(mdev, &mdev->active_ee);
@@ -4054,6 +4075,8 @@ static int got_PingAck(struct drbd_conf *mdev, struct p_header *h)
4054{ 4075{
4055 /* restore idle timeout */ 4076 /* restore idle timeout */
4056 mdev->meta.socket->sk->sk_rcvtimeo = mdev->net_conf->ping_int*HZ; 4077 mdev->meta.socket->sk->sk_rcvtimeo = mdev->net_conf->ping_int*HZ;
4078 if (!test_and_set_bit(GOT_PING_ACK, &mdev->flags))
4079 wake_up(&mdev->misc_wait);
4057 4080
4058 return TRUE; 4081 return TRUE;
4059} 4082}
diff --git a/drivers/block/drbd/drbd_worker.c b/drivers/block/drbd/drbd_worker.c
index b453c2bca3b..d48a1dfd7b2 100644
--- a/drivers/block/drbd/drbd_worker.c
+++ b/drivers/block/drbd/drbd_worker.c
@@ -235,7 +235,7 @@ void drbd_endio_pri(struct bio *bio, int error)
235 if (unlikely(error)) { 235 if (unlikely(error)) {
236 what = (bio_data_dir(bio) == WRITE) 236 what = (bio_data_dir(bio) == WRITE)
237 ? write_completed_with_error 237 ? write_completed_with_error
238 : (bio_rw(bio) == READA) 238 : (bio_rw(bio) == READ)
239 ? read_completed_with_error 239 ? read_completed_with_error
240 : read_ahead_completed_with_error; 240 : read_ahead_completed_with_error;
241 } else 241 } else
@@ -938,7 +938,8 @@ int w_e_end_csum_rs_req(struct drbd_conf *mdev, struct drbd_work *w, int cancel)
938 938
939 if (eq) { 939 if (eq) {
940 drbd_set_in_sync(mdev, e->sector, e->size); 940 drbd_set_in_sync(mdev, e->sector, e->size);
941 mdev->rs_same_csum++; 941 /* rs_same_csums unit is BM_BLOCK_SIZE */
942 mdev->rs_same_csum += e->size >> BM_BLOCK_SHIFT;
942 ok = drbd_send_ack(mdev, P_RS_IS_IN_SYNC, e); 943 ok = drbd_send_ack(mdev, P_RS_IS_IN_SYNC, e);
943 } else { 944 } else {
944 inc_rs_pending(mdev); 945 inc_rs_pending(mdev);
@@ -1288,6 +1289,14 @@ int drbd_alter_sa(struct drbd_conf *mdev, int na)
1288 return retcode; 1289 return retcode;
1289} 1290}
1290 1291
1292static void ping_peer(struct drbd_conf *mdev)
1293{
1294 clear_bit(GOT_PING_ACK, &mdev->flags);
1295 request_ping(mdev);
1296 wait_event(mdev->misc_wait,
1297 test_bit(GOT_PING_ACK, &mdev->flags) || mdev->state.conn < C_CONNECTED);
1298}
1299
1291/** 1300/**
1292 * drbd_start_resync() - Start the resync process 1301 * drbd_start_resync() - Start the resync process
1293 * @mdev: DRBD device. 1302 * @mdev: DRBD device.
@@ -1371,7 +1380,6 @@ void drbd_start_resync(struct drbd_conf *mdev, enum drbd_conns side)
1371 _drbd_pause_after(mdev); 1380 _drbd_pause_after(mdev);
1372 } 1381 }
1373 write_unlock_irq(&global_state_lock); 1382 write_unlock_irq(&global_state_lock);
1374 drbd_state_unlock(mdev);
1375 put_ldev(mdev); 1383 put_ldev(mdev);
1376 1384
1377 if (r == SS_SUCCESS) { 1385 if (r == SS_SUCCESS) {
@@ -1382,11 +1390,8 @@ void drbd_start_resync(struct drbd_conf *mdev, enum drbd_conns side)
1382 1390
1383 if (mdev->rs_total == 0) { 1391 if (mdev->rs_total == 0) {
1384 /* Peer still reachable? Beware of failing before-resync-target handlers! */ 1392 /* Peer still reachable? Beware of failing before-resync-target handlers! */
1385 request_ping(mdev); 1393 ping_peer(mdev);
1386 __set_current_state(TASK_INTERRUPTIBLE);
1387 schedule_timeout(mdev->net_conf->ping_timeo*HZ/9); /* 9 instead 10 */
1388 drbd_resync_finished(mdev); 1394 drbd_resync_finished(mdev);
1389 return;
1390 } 1395 }
1391 1396
1392 /* ns.conn may already be != mdev->state.conn, 1397 /* ns.conn may already be != mdev->state.conn,
@@ -1398,6 +1403,7 @@ void drbd_start_resync(struct drbd_conf *mdev, enum drbd_conns side)
1398 1403
1399 drbd_md_sync(mdev); 1404 drbd_md_sync(mdev);
1400 } 1405 }
1406 drbd_state_unlock(mdev);
1401} 1407}
1402 1408
1403int drbd_worker(struct drbd_thread *thi) 1409int drbd_worker(struct drbd_thread *thi)
diff --git a/drivers/block/hd.c b/drivers/block/hd.c
index 5116c65c07c..034e6dfc878 100644
--- a/drivers/block/hd.c
+++ b/drivers/block/hd.c
@@ -34,7 +34,6 @@
34#include <linux/fs.h> 34#include <linux/fs.h>
35#include <linux/kernel.h> 35#include <linux/kernel.h>
36#include <linux/genhd.h> 36#include <linux/genhd.h>
37#include <linux/slab.h>
38#include <linux/string.h> 37#include <linux/string.h>
39#include <linux/ioport.h> 38#include <linux/ioport.h>
40#include <linux/init.h> 39#include <linux/init.h>
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index bd112c8c7bc..8546d123b9a 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -71,7 +71,6 @@
71#include <linux/buffer_head.h> /* for invalidate_bdev() */ 71#include <linux/buffer_head.h> /* for invalidate_bdev() */
72#include <linux/completion.h> 72#include <linux/completion.h>
73#include <linux/highmem.h> 73#include <linux/highmem.h>
74#include <linux/gfp.h>
75#include <linux/kthread.h> 74#include <linux/kthread.h>
76#include <linux/splice.h> 75#include <linux/splice.h>
77 76
@@ -238,6 +237,8 @@ static int do_lo_send_aops(struct loop_device *lo, struct bio_vec *bvec,
238 if (ret) 237 if (ret)
239 goto fail; 238 goto fail;
240 239
240 file_update_time(file);
241
241 transfer_result = lo_do_transfer(lo, WRITE, page, offset, 242 transfer_result = lo_do_transfer(lo, WRITE, page, offset,
242 bvec->bv_page, bv_offs, size, IV); 243 bvec->bv_page, bv_offs, size, IV);
243 copied = size; 244 copied = size;
diff --git a/drivers/block/mg_disk.c b/drivers/block/mg_disk.c
index 5416c9a606e..28db925dbda 100644
--- a/drivers/block/mg_disk.c
+++ b/drivers/block/mg_disk.c
@@ -23,6 +23,7 @@
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/gpio.h> 24#include <linux/gpio.h>
25#include <linux/mg_disk.h> 25#include <linux/mg_disk.h>
26#include <linux/slab.h>
26 27
27#define MG_RES_SEC (CONFIG_MG_DISK_RES << 1) 28#define MG_RES_SEC (CONFIG_MG_DISK_RES << 1)
28 29
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index cc923a5b430..218d091f3c5 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -27,6 +27,7 @@
27#include <linux/compiler.h> 27#include <linux/compiler.h>
28#include <linux/err.h> 28#include <linux/err.h>
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <linux/slab.h>
30#include <net/sock.h> 31#include <net/sock.h>
31#include <linux/net.h> 32#include <linux/net.h>
32#include <linux/kthread.h> 33#include <linux/kthread.h>
diff --git a/drivers/block/osdblk.c b/drivers/block/osdblk.c
index eb2091aa1c1..6cd8b705b11 100644
--- a/drivers/block/osdblk.c
+++ b/drivers/block/osdblk.c
@@ -63,6 +63,7 @@
63#include <linux/device.h> 63#include <linux/device.h>
64#include <linux/module.h> 64#include <linux/module.h>
65#include <linux/fs.h> 65#include <linux/fs.h>
66#include <linux/slab.h>
66#include <scsi/osd_initiator.h> 67#include <scsi/osd_initiator.h>
67#include <scsi/osd_attributes.h> 68#include <scsi/osd_attributes.h>
68#include <scsi/osd_sec.h> 69#include <scsi/osd_sec.h>
diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c
index 8866ca369d5..71acf4e5335 100644
--- a/drivers/block/paride/pcd.c
+++ b/drivers/block/paride/pcd.c
@@ -341,11 +341,11 @@ static int pcd_wait(struct pcd_unit *cd, int go, int stop, char *fun, char *msg)
341 && (j++ < PCD_SPIN)) 341 && (j++ < PCD_SPIN))
342 udelay(PCD_DELAY); 342 udelay(PCD_DELAY);
343 343
344 if ((r & (IDE_ERR & stop)) || (j >= PCD_SPIN)) { 344 if ((r & (IDE_ERR & stop)) || (j > PCD_SPIN)) {
345 s = read_reg(cd, 7); 345 s = read_reg(cd, 7);
346 e = read_reg(cd, 1); 346 e = read_reg(cd, 1);
347 p = read_reg(cd, 2); 347 p = read_reg(cd, 2);
348 if (j >= PCD_SPIN) 348 if (j > PCD_SPIN)
349 e |= 0x100; 349 e |= 0x100;
350 if (fun) 350 if (fun)
351 printk("%s: %s %s: alt=0x%x stat=0x%x err=0x%x" 351 printk("%s: %s %s: alt=0x%x stat=0x%x err=0x%x"
diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c
index e712cd51af1..c1e5cd029b2 100644
--- a/drivers/block/paride/pd.c
+++ b/drivers/block/paride/pd.c
@@ -145,6 +145,7 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_GEO, D_SBY, D_DLY, D_SLV};
145 145
146#include <linux/init.h> 146#include <linux/init.h>
147#include <linux/module.h> 147#include <linux/module.h>
148#include <linux/gfp.h>
148#include <linux/fs.h> 149#include <linux/fs.h>
149#include <linux/delay.h> 150#include <linux/delay.h>
150#include <linux/hdreg.h> 151#include <linux/hdreg.h>
diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c
index ddb4f9abd48..c059aab3006 100644
--- a/drivers/block/paride/pf.c
+++ b/drivers/block/paride/pf.c
@@ -391,11 +391,11 @@ static int pf_wait(struct pf_unit *pf, int go, int stop, char *fun, char *msg)
391 && (j++ < PF_SPIN)) 391 && (j++ < PF_SPIN))
392 udelay(PF_SPIN_DEL); 392 udelay(PF_SPIN_DEL);
393 393
394 if ((r & (STAT_ERR & stop)) || (j >= PF_SPIN)) { 394 if ((r & (STAT_ERR & stop)) || (j > PF_SPIN)) {
395 s = read_reg(pf, 7); 395 s = read_reg(pf, 7);
396 e = read_reg(pf, 1); 396 e = read_reg(pf, 1);
397 p = read_reg(pf, 2); 397 p = read_reg(pf, 2);
398 if (j >= PF_SPIN) 398 if (j > PF_SPIN)
399 e |= 0x100; 399 e |= 0x100;
400 if (fun) 400 if (fun)
401 printk("%s: %s %s: alt=0x%x stat=0x%x err=0x%x" 401 printk("%s: %s %s: alt=0x%x stat=0x%x err=0x%x"
diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c
index 1e4006e18f0..bc5825fdeaa 100644
--- a/drivers/block/paride/pt.c
+++ b/drivers/block/paride/pt.c
@@ -274,11 +274,11 @@ static int pt_wait(struct pt_unit *tape, int go, int stop, char *fun, char *msg)
274 && (j++ < PT_SPIN)) 274 && (j++ < PT_SPIN))
275 udelay(PT_SPIN_DEL); 275 udelay(PT_SPIN_DEL);
276 276
277 if ((r & (STAT_ERR & stop)) || (j >= PT_SPIN)) { 277 if ((r & (STAT_ERR & stop)) || (j > PT_SPIN)) {
278 s = read_reg(pi, 7); 278 s = read_reg(pi, 7);
279 e = read_reg(pi, 1); 279 e = read_reg(pi, 1);
280 p = read_reg(pi, 2); 280 p = read_reg(pi, 2);
281 if (j >= PT_SPIN) 281 if (j > PT_SPIN)
282 e |= 0x100; 282 e |= 0x100;
283 if (fun) 283 if (fun)
284 printk("%s: %s %s: alt=0x%x stat=0x%x err=0x%x" 284 printk("%s: %s %s: alt=0x%x stat=0x%x err=0x%x"
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 39c8514442e..8a549db2aa7 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -48,6 +48,7 @@
48#include <linux/module.h> 48#include <linux/module.h>
49#include <linux/types.h> 49#include <linux/types.h>
50#include <linux/kernel.h> 50#include <linux/kernel.h>
51#include <linux/compat.h>
51#include <linux/kthread.h> 52#include <linux/kthread.h>
52#include <linux/errno.h> 53#include <linux/errno.h>
53#include <linux/spinlock.h> 54#include <linux/spinlock.h>
@@ -57,6 +58,7 @@
57#include <linux/miscdevice.h> 58#include <linux/miscdevice.h>
58#include <linux/freezer.h> 59#include <linux/freezer.h>
59#include <linux/mutex.h> 60#include <linux/mutex.h>
61#include <linux/slab.h>
60#include <scsi/scsi_cmnd.h> 62#include <scsi/scsi_cmnd.h>
61#include <scsi/scsi_ioctl.h> 63#include <scsi/scsi_ioctl.h>
62#include <scsi/scsi.h> 64#include <scsi/scsi.h>
@@ -2983,7 +2985,7 @@ static void pkt_get_status(struct pkt_ctrl_command *ctrl_cmd)
2983 mutex_unlock(&ctl_mutex); 2985 mutex_unlock(&ctl_mutex);
2984} 2986}
2985 2987
2986static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) 2988static long pkt_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
2987{ 2989{
2988 void __user *argp = (void __user *)arg; 2990 void __user *argp = (void __user *)arg;
2989 struct pkt_ctrl_command ctrl_cmd; 2991 struct pkt_ctrl_command ctrl_cmd;
@@ -3020,10 +3022,20 @@ static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cm
3020 return ret; 3022 return ret;
3021} 3023}
3022 3024
3025#ifdef CONFIG_COMPAT
3026static long pkt_ctl_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
3027{
3028 return pkt_ctl_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
3029}
3030#endif
3023 3031
3024static const struct file_operations pkt_ctl_fops = { 3032static const struct file_operations pkt_ctl_fops = {
3025 .ioctl = pkt_ctl_ioctl, 3033 .open = nonseekable_open,
3026 .owner = THIS_MODULE, 3034 .unlocked_ioctl = pkt_ctl_ioctl,
3035#ifdef CONFIG_COMPAT
3036 .compat_ioctl = pkt_ctl_compat_ioctl,
3037#endif
3038 .owner = THIS_MODULE,
3027}; 3039};
3028 3040
3029static struct miscdevice pkt_misc = { 3041static struct miscdevice pkt_misc = {
diff --git a/drivers/block/ps3disk.c b/drivers/block/ps3disk.c
index bc95469d33c..3b419e3fffa 100644
--- a/drivers/block/ps3disk.c
+++ b/drivers/block/ps3disk.c
@@ -20,6 +20,7 @@
20 20
21#include <linux/ata.h> 21#include <linux/ata.h>
22#include <linux/blkdev.h> 22#include <linux/blkdev.h>
23#include <linux/slab.h>
23 24
24#include <asm/lv1call.h> 25#include <asm/lv1call.h>
25#include <asm/ps3stor.h> 26#include <asm/ps3stor.h>
diff --git a/drivers/block/ps3vram.c b/drivers/block/ps3vram.c
index e4460822997..b3bdb8af89c 100644
--- a/drivers/block/ps3vram.c
+++ b/drivers/block/ps3vram.c
@@ -12,6 +12,7 @@
12#include <linux/delay.h> 12#include <linux/delay.h>
13#include <linux/proc_fs.h> 13#include <linux/proc_fs.h>
14#include <linux/seq_file.h> 14#include <linux/seq_file.h>
15#include <linux/slab.h>
15 16
16#include <asm/cell-regs.h> 17#include <asm/cell-regs.h>
17#include <asm/firmware.h> 18#include <asm/firmware.h>
diff --git a/drivers/block/swim.c b/drivers/block/swim.c
index 821c2833f9c..e463657569f 100644
--- a/drivers/block/swim.c
+++ b/drivers/block/swim.c
@@ -18,6 +18,7 @@
18 18
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/fd.h> 20#include <linux/fd.h>
21#include <linux/slab.h>
21#include <linux/blkdev.h> 22#include <linux/blkdev.h>
22#include <linux/hdreg.h> 23#include <linux/hdreg.h>
23#include <linux/kernel.h> 24#include <linux/kernel.h>
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index 2e889838e81..0536b5b29ad 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -27,6 +27,7 @@
27#include <linux/blkdev.h> 27#include <linux/blkdev.h>
28#include <linux/timer.h> 28#include <linux/timer.h>
29#include <linux/scatterlist.h> 29#include <linux/scatterlist.h>
30#include <linux/slab.h>
30#include <scsi/scsi.h> 31#include <scsi/scsi.h>
31 32
32#define DRV_NAME "ub" 33#define DRV_NAME "ub"
diff --git a/drivers/block/umem.c b/drivers/block/umem.c
index ad1ba393801..2f9470ff8f7 100644
--- a/drivers/block/umem.c
+++ b/drivers/block/umem.c
@@ -40,13 +40,13 @@
40#include <linux/kernel.h> 40#include <linux/kernel.h>
41#include <linux/mm.h> 41#include <linux/mm.h>
42#include <linux/mman.h> 42#include <linux/mman.h>
43#include <linux/gfp.h>
43#include <linux/ioctl.h> 44#include <linux/ioctl.h>
44#include <linux/module.h> 45#include <linux/module.h>
45#include <linux/init.h> 46#include <linux/init.h>
46#include <linux/interrupt.h> 47#include <linux/interrupt.h>
47#include <linux/timer.h> 48#include <linux/timer.h>
48#include <linux/pci.h> 49#include <linux/pci.h>
49#include <linux/slab.h>
50#include <linux/dma-mapping.h> 50#include <linux/dma-mapping.h>
51 51
52#include <linux/fcntl.h> /* O_ACCMODE */ 52#include <linux/fcntl.h> /* O_ACCMODE */
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 3c64af05fa8..2138a7ae050 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -1,5 +1,6 @@
1//#define DEBUG 1//#define DEBUG
2#include <linux/spinlock.h> 2#include <linux/spinlock.h>
3#include <linux/slab.h>
3#include <linux/blkdev.h> 4#include <linux/blkdev.h>
4#include <linux/hdreg.h> 5#include <linux/hdreg.h>
5#include <linux/virtio.h> 6#include <linux/virtio.h>
@@ -347,14 +348,13 @@ static int __devinit virtblk_probe(struct virtio_device *vdev)
347 set_capacity(vblk->disk, cap); 348 set_capacity(vblk->disk, cap);
348 349
349 /* We can handle whatever the host told us to handle. */ 350 /* We can handle whatever the host told us to handle. */
350 blk_queue_max_phys_segments(q, vblk->sg_elems-2); 351 blk_queue_max_segments(q, vblk->sg_elems-2);
351 blk_queue_max_hw_segments(q, vblk->sg_elems-2);
352 352
353 /* No need to bounce any requests */ 353 /* No need to bounce any requests */
354 blk_queue_bounce_limit(q, BLK_BOUNCE_ANY); 354 blk_queue_bounce_limit(q, BLK_BOUNCE_ANY);
355 355
356 /* No real sector limit. */ 356 /* No real sector limit. */
357 blk_queue_max_sectors(q, -1U); 357 blk_queue_max_hw_sectors(q, -1U);
358 358
359 /* Host can optionally specify maximum segment size and number of 359 /* Host can optionally specify maximum segment size and number of
360 * segments. */ 360 * segments. */
diff --git a/drivers/block/xd.c b/drivers/block/xd.c
index 1a325fb05c9..18a80ff57ce 100644
--- a/drivers/block/xd.c
+++ b/drivers/block/xd.c
@@ -49,6 +49,7 @@
49#include <linux/blkpg.h> 49#include <linux/blkpg.h>
50#include <linux/delay.h> 50#include <linux/delay.h>
51#include <linux/io.h> 51#include <linux/io.h>
52#include <linux/gfp.h>
52 53
53#include <asm/system.h> 54#include <asm/system.h>
54#include <asm/uaccess.h> 55#include <asm/uaccess.h>
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 9c09694b252..82ed403147c 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -40,6 +40,7 @@
40#include <linux/hdreg.h> 40#include <linux/hdreg.h>
41#include <linux/cdrom.h> 41#include <linux/cdrom.h>
42#include <linux/module.h> 42#include <linux/module.h>
43#include <linux/slab.h>
43#include <linux/scatterlist.h> 44#include <linux/scatterlist.h>
44 45
45#include <xen/xen.h> 46#include <xen/xen.h>
diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c
index 64f941e0f14..9114654b54d 100644
--- a/drivers/block/z2ram.c
+++ b/drivers/block/z2ram.c
@@ -33,6 +33,7 @@
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/blkdev.h> 34#include <linux/blkdev.h>
35#include <linux/bitops.h> 35#include <linux/bitops.h>
36#include <linux/slab.h>
36 37
37#include <asm/setup.h> 38#include <asm/setup.h>
38#include <asm/amigahw.h> 39#include <asm/amigahw.h>
diff --git a/drivers/bluetooth/btmrvl_debugfs.c b/drivers/bluetooth/btmrvl_debugfs.c
index 3126a3d0c45..b50b41d97a7 100644
--- a/drivers/bluetooth/btmrvl_debugfs.c
+++ b/drivers/bluetooth/btmrvl_debugfs.c
@@ -19,6 +19,7 @@
19 **/ 19 **/
20 20
21#include <linux/debugfs.h> 21#include <linux/debugfs.h>
22#include <linux/slab.h>
22 23
23#include <net/bluetooth/bluetooth.h> 24#include <net/bluetooth/bluetooth.h>
24#include <net/bluetooth/hci_core.h> 25#include <net/bluetooth/hci_core.h>
diff --git a/drivers/bluetooth/btmrvl_drv.h b/drivers/bluetooth/btmrvl_drv.h
index 523d197b982..204727586ee 100644
--- a/drivers/bluetooth/btmrvl_drv.h
+++ b/drivers/bluetooth/btmrvl_drv.h
@@ -21,6 +21,7 @@
21 21
22#include <linux/kthread.h> 22#include <linux/kthread.h>
23#include <linux/bitops.h> 23#include <linux/bitops.h>
24#include <linux/slab.h>
24#include <net/bluetooth/bluetooth.h> 25#include <net/bluetooth/bluetooth.h>
25 26
26#define BTM_HEADER_LEN 4 27#define BTM_HEADER_LEN 4
diff --git a/drivers/bluetooth/btmrvl_sdio.c b/drivers/bluetooth/btmrvl_sdio.c
index 94f1f55f81f..0dba76aa223 100644
--- a/drivers/bluetooth/btmrvl_sdio.c
+++ b/drivers/bluetooth/btmrvl_sdio.c
@@ -19,6 +19,7 @@
19 **/ 19 **/
20 20
21#include <linux/firmware.h> 21#include <linux/firmware.h>
22#include <linux/slab.h>
22 23
23#include <linux/mmc/sdio_ids.h> 24#include <linux/mmc/sdio_ids.h>
24#include <linux/mmc/sdio_func.h> 25#include <linux/mmc/sdio_func.h>
diff --git a/drivers/char/agp/amd-k7-agp.c b/drivers/char/agp/amd-k7-agp.c
index 73dbf40c874..a7637d72cef 100644
--- a/drivers/char/agp/amd-k7-agp.c
+++ b/drivers/char/agp/amd-k7-agp.c
@@ -6,9 +6,9 @@
6#include <linux/pci.h> 6#include <linux/pci.h>
7#include <linux/init.h> 7#include <linux/init.h>
8#include <linux/agp_backend.h> 8#include <linux/agp_backend.h>
9#include <linux/gfp.h>
10#include <linux/page-flags.h> 9#include <linux/page-flags.h>
11#include <linux/mm.h> 10#include <linux/mm.h>
11#include <linux/slab.h>
12#include "agp.h" 12#include "agp.h"
13 13
14#define AMD_MMBASE 0x14 14#define AMD_MMBASE 0x14
diff --git a/drivers/char/agp/backend.c b/drivers/char/agp/backend.c
index c3ab46da51a..ee4f855611b 100644
--- a/drivers/char/agp/backend.c
+++ b/drivers/char/agp/backend.c
@@ -30,6 +30,7 @@
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/pci.h> 31#include <linux/pci.h>
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/slab.h>
33#include <linux/pagemap.h> 34#include <linux/pagemap.h>
34#include <linux/miscdevice.h> 35#include <linux/miscdevice.h>
35#include <linux/pm.h> 36#include <linux/pm.h>
diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
index 58c57cb2518..9d2c97a69cd 100644
--- a/drivers/char/agp/compat_ioctl.c
+++ b/drivers/char/agp/compat_ioctl.c
@@ -30,6 +30,7 @@
30#include <linux/pci.h> 30#include <linux/pci.h>
31#include <linux/fs.h> 31#include <linux/fs.h>
32#include <linux/agpgart.h> 32#include <linux/agpgart.h>
33#include <linux/slab.h>
33#include <asm/uaccess.h> 34#include <asm/uaccess.h>
34#include "agp.h" 35#include "agp.h"
35#include "compat_ioctl.h" 36#include "compat_ioctl.h"
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
index c50543966eb..fb86708e47e 100644
--- a/drivers/char/agp/generic.c
+++ b/drivers/char/agp/generic.c
@@ -38,6 +38,7 @@
38#include <linux/dma-mapping.h> 38#include <linux/dma-mapping.h>
39#include <linux/mm.h> 39#include <linux/mm.h>
40#include <linux/sched.h> 40#include <linux/sched.h>
41#include <linux/slab.h>
41#include <asm/io.h> 42#include <asm/io.h>
42#include <asm/cacheflush.h> 43#include <asm/cacheflush.h>
43#include <asm/pgtable.h> 44#include <asm/pgtable.h>
diff --git a/drivers/char/agp/hp-agp.c b/drivers/char/agp/hp-agp.c
index 58752b70efe..056b289a1e8 100644
--- a/drivers/char/agp/hp-agp.c
+++ b/drivers/char/agp/hp-agp.c
@@ -15,6 +15,7 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/agp_backend.h> 16#include <linux/agp_backend.h>
17#include <linux/log2.h> 17#include <linux/log2.h>
18#include <linux/slab.h>
18 19
19#include <asm/acpi-ext.h> 20#include <asm/acpi-ext.h>
20 21
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index a3e10dc7cc2..aa4248efc5d 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -4,6 +4,7 @@
4 4
5#include <linux/module.h> 5#include <linux/module.h>
6#include <linux/pci.h> 6#include <linux/pci.h>
7#include <linux/slab.h>
7#include <linux/init.h> 8#include <linux/init.h>
8#include <linux/kernel.h> 9#include <linux/kernel.h>
9#include <linux/pagemap.h> 10#include <linux/pagemap.h>
@@ -97,6 +98,9 @@ EXPORT_SYMBOL(intel_agp_enabled);
97#define IS_PINEVIEW (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_PINEVIEW_M_HB || \ 98#define IS_PINEVIEW (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_PINEVIEW_M_HB || \
98 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_PINEVIEW_HB) 99 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_PINEVIEW_HB)
99 100
101#define IS_SNB (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_SANDYBRIDGE_HB || \
102 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_HB)
103
100#define IS_G4X (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_EAGLELAKE_HB || \ 104#define IS_G4X (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_EAGLELAKE_HB || \
101 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q45_HB || \ 105 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q45_HB || \
102 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_G45_HB || \ 106 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_G45_HB || \
@@ -107,8 +111,7 @@ EXPORT_SYMBOL(intel_agp_enabled);
107 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IRONLAKE_M_HB || \ 111 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IRONLAKE_M_HB || \
108 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IRONLAKE_MA_HB || \ 112 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IRONLAKE_MA_HB || \
109 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IRONLAKE_MC2_HB || \ 113 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IRONLAKE_MC2_HB || \
110 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_SANDYBRIDGE_HB || \ 114 IS_SNB)
111 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_HB)
112 115
113extern int agp_memory_reserved; 116extern int agp_memory_reserved;
114 117
@@ -175,6 +178,10 @@ extern int agp_memory_reserved;
175#define SNB_GMCH_GMS_STOLEN_448M (0xe << 3) 178#define SNB_GMCH_GMS_STOLEN_448M (0xe << 3)
176#define SNB_GMCH_GMS_STOLEN_480M (0xf << 3) 179#define SNB_GMCH_GMS_STOLEN_480M (0xf << 3)
177#define SNB_GMCH_GMS_STOLEN_512M (0x10 << 3) 180#define SNB_GMCH_GMS_STOLEN_512M (0x10 << 3)
181#define SNB_GTT_SIZE_0M (0 << 8)
182#define SNB_GTT_SIZE_1M (1 << 8)
183#define SNB_GTT_SIZE_2M (2 << 8)
184#define SNB_GTT_SIZE_MASK (3 << 8)
178 185
179static const struct aper_size_info_fixed intel_i810_sizes[] = 186static const struct aper_size_info_fixed intel_i810_sizes[] =
180{ 187{
@@ -1200,6 +1207,9 @@ static void intel_i9xx_setup_flush(void)
1200 if (intel_private.ifp_resource.start) 1207 if (intel_private.ifp_resource.start)
1201 return; 1208 return;
1202 1209
1210 if (IS_SNB)
1211 return;
1212
1203 /* setup a resource for this object */ 1213 /* setup a resource for this object */
1204 intel_private.ifp_resource.name = "Intel Flush Page"; 1214 intel_private.ifp_resource.name = "Intel Flush Page";
1205 intel_private.ifp_resource.flags = IORESOURCE_MEM; 1215 intel_private.ifp_resource.flags = IORESOURCE_MEM;
@@ -1438,6 +1448,8 @@ static unsigned long intel_i965_mask_memory(struct agp_bridge_data *bridge,
1438 1448
1439static void intel_i965_get_gtt_range(int *gtt_offset, int *gtt_size) 1449static void intel_i965_get_gtt_range(int *gtt_offset, int *gtt_size)
1440{ 1450{
1451 u16 snb_gmch_ctl;
1452
1441 switch (agp_bridge->dev->device) { 1453 switch (agp_bridge->dev->device) {
1442 case PCI_DEVICE_ID_INTEL_GM45_HB: 1454 case PCI_DEVICE_ID_INTEL_GM45_HB:
1443 case PCI_DEVICE_ID_INTEL_EAGLELAKE_HB: 1455 case PCI_DEVICE_ID_INTEL_EAGLELAKE_HB:
@@ -1449,9 +1461,26 @@ static void intel_i965_get_gtt_range(int *gtt_offset, int *gtt_size)
1449 case PCI_DEVICE_ID_INTEL_IRONLAKE_M_HB: 1461 case PCI_DEVICE_ID_INTEL_IRONLAKE_M_HB:
1450 case PCI_DEVICE_ID_INTEL_IRONLAKE_MA_HB: 1462 case PCI_DEVICE_ID_INTEL_IRONLAKE_MA_HB:
1451 case PCI_DEVICE_ID_INTEL_IRONLAKE_MC2_HB: 1463 case PCI_DEVICE_ID_INTEL_IRONLAKE_MC2_HB:
1464 *gtt_offset = *gtt_size = MB(2);
1465 break;
1452 case PCI_DEVICE_ID_INTEL_SANDYBRIDGE_HB: 1466 case PCI_DEVICE_ID_INTEL_SANDYBRIDGE_HB:
1453 case PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_HB: 1467 case PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_HB:
1454 *gtt_offset = *gtt_size = MB(2); 1468 *gtt_offset = MB(2);
1469
1470 pci_read_config_word(intel_private.pcidev, SNB_GMCH_CTRL, &snb_gmch_ctl);
1471 switch (snb_gmch_ctl & SNB_GTT_SIZE_MASK) {
1472 default:
1473 case SNB_GTT_SIZE_0M:
1474 printk(KERN_ERR "Bad GTT size mask: 0x%04x.\n", snb_gmch_ctl);
1475 *gtt_size = MB(0);
1476 break;
1477 case SNB_GTT_SIZE_1M:
1478 *gtt_size = MB(1);
1479 break;
1480 case SNB_GTT_SIZE_2M:
1481 *gtt_size = MB(2);
1482 break;
1483 }
1455 break; 1484 break;
1456 default: 1485 default:
1457 *gtt_offset = *gtt_size = KB(512); 1486 *gtt_offset = *gtt_size = KB(512);
@@ -1788,8 +1817,6 @@ static int intel_845_configure(void)
1788 pci_write_config_byte(agp_bridge->dev, INTEL_I845_AGPM, temp2 | (1 << 1)); 1817 pci_write_config_byte(agp_bridge->dev, INTEL_I845_AGPM, temp2 | (1 << 1));
1789 /* clear any possible error conditions */ 1818 /* clear any possible error conditions */
1790 pci_write_config_word(agp_bridge->dev, INTEL_I845_ERRSTS, 0x001c); 1819 pci_write_config_word(agp_bridge->dev, INTEL_I845_ERRSTS, 0x001c);
1791
1792 intel_i830_setup_flush();
1793 return 0; 1820 return 0;
1794} 1821}
1795 1822
@@ -2159,7 +2186,6 @@ static const struct agp_bridge_driver intel_845_driver = {
2159 .agp_destroy_page = agp_generic_destroy_page, 2186 .agp_destroy_page = agp_generic_destroy_page,
2160 .agp_destroy_pages = agp_generic_destroy_pages, 2187 .agp_destroy_pages = agp_generic_destroy_pages,
2161 .agp_type_to_mask_type = agp_generic_type_to_mask_type, 2188 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
2162 .chipset_flush = intel_i830_chipset_flush,
2163}; 2189};
2164 2190
2165static const struct agp_bridge_driver intel_850_driver = { 2191static const struct agp_bridge_driver intel_850_driver = {
diff --git a/drivers/char/agp/nvidia-agp.c b/drivers/char/agp/nvidia-agp.c
index 7e36d2b4f9d..10f24e349a2 100644
--- a/drivers/char/agp/nvidia-agp.c
+++ b/drivers/char/agp/nvidia-agp.c
@@ -8,7 +8,6 @@
8#include <linux/pci.h> 8#include <linux/pci.h>
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/agp_backend.h> 10#include <linux/agp_backend.h>
11#include <linux/gfp.h>
12#include <linux/page-flags.h> 11#include <linux/page-flags.h>
13#include <linux/mm.h> 12#include <linux/mm.h>
14#include <linux/jiffies.h> 13#include <linux/jiffies.h>
diff --git a/drivers/char/agp/sgi-agp.c b/drivers/char/agp/sgi-agp.c
index 0d426ae39c8..ffa888cd1c8 100644
--- a/drivers/char/agp/sgi-agp.c
+++ b/drivers/char/agp/sgi-agp.c
@@ -14,6 +14,7 @@
14#include <linux/acpi.h> 14#include <linux/acpi.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/pci.h> 16#include <linux/pci.h>
17#include <linux/slab.h>
17#include <linux/init.h> 18#include <linux/init.h>
18#include <linux/agp_backend.h> 19#include <linux/agp_backend.h>
19#include <asm/sn/addrs.h> 20#include <asm/sn/addrs.h>
diff --git a/drivers/char/agp/uninorth-agp.c b/drivers/char/agp/uninorth-agp.c
index d89da4ac061..6f48931ac1c 100644
--- a/drivers/char/agp/uninorth-agp.c
+++ b/drivers/char/agp/uninorth-agp.c
@@ -3,6 +3,7 @@
3 */ 3 */
4#include <linux/module.h> 4#include <linux/module.h>
5#include <linux/pci.h> 5#include <linux/pci.h>
6#include <linux/slab.h>
6#include <linux/init.h> 7#include <linux/init.h>
7#include <linux/pagemap.h> 8#include <linux/pagemap.h>
8#include <linux/agp_backend.h> 9#include <linux/agp_backend.h>
diff --git a/drivers/char/amiserial.c b/drivers/char/amiserial.c
index 6c32fbf0716..56b27671adc 100644
--- a/drivers/char/amiserial.c
+++ b/drivers/char/amiserial.c
@@ -2021,8 +2021,6 @@ static int __init rs_init(void)
2021 state->baud_base = amiga_colorclock; 2021 state->baud_base = amiga_colorclock;
2022 state->xmit_fifo_size = 1; 2022 state->xmit_fifo_size = 1;
2023 2023
2024 local_irq_save(flags);
2025
2026 /* set ISRs, and then disable the rx interrupts */ 2024 /* set ISRs, and then disable the rx interrupts */
2027 error = request_irq(IRQ_AMIGA_TBE, ser_tx_int, 0, "serial TX", state); 2025 error = request_irq(IRQ_AMIGA_TBE, ser_tx_int, 0, "serial TX", state);
2028 if (error) 2026 if (error)
@@ -2033,6 +2031,8 @@ static int __init rs_init(void)
2033 if (error) 2031 if (error)
2034 goto fail_free_irq; 2032 goto fail_free_irq;
2035 2033
2034 local_irq_save(flags);
2035
2036 /* turn off Rx and Tx interrupts */ 2036 /* turn off Rx and Tx interrupts */
2037 custom.intena = IF_RBF | IF_TBE; 2037 custom.intena = IF_RBF | IF_TBE;
2038 mb(); 2038 mb();
diff --git a/drivers/char/bfin_jtag_comm.c b/drivers/char/bfin_jtag_comm.c
index 2628c7415ea..e397df3ad98 100644
--- a/drivers/char/bfin_jtag_comm.c
+++ b/drivers/char/bfin_jtag_comm.c
@@ -21,6 +21,7 @@
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/mutex.h> 22#include <linux/mutex.h>
23#include <linux/sched.h> 23#include <linux/sched.h>
24#include <linux/slab.h>
24#include <linux/tty.h> 25#include <linux/tty.h>
25#include <linux/tty_driver.h> 26#include <linux/tty_driver.h>
26#include <linux/tty_flip.h> 27#include <linux/tty_flip.h>
diff --git a/drivers/char/briq_panel.c b/drivers/char/briq_panel.c
index d8cff909001..555cd93c2ee 100644
--- a/drivers/char/briq_panel.c
+++ b/drivers/char/briq_panel.c
@@ -14,7 +14,6 @@
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/wait.h> 15#include <linux/wait.h>
16#include <linux/string.h> 16#include <linux/string.h>
17#include <linux/slab.h>
18#include <linux/ioport.h> 17#include <linux/ioport.h>
19#include <linux/delay.h> 18#include <linux/delay.h>
20#include <linux/miscdevice.h> 19#include <linux/miscdevice.h>
diff --git a/drivers/char/bsr.c b/drivers/char/bsr.c
index c02db01f736..7fef305774d 100644
--- a/drivers/char/bsr.c
+++ b/drivers/char/bsr.c
@@ -27,6 +27,7 @@
27#include <linux/cdev.h> 27#include <linux/cdev.h>
28#include <linux/list.h> 28#include <linux/list.h>
29#include <linux/mm.h> 29#include <linux/mm.h>
30#include <linux/slab.h>
30#include <asm/pgtable.h> 31#include <asm/pgtable.h>
31#include <asm/io.h> 32#include <asm/io.h>
32 33
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index b861c08263a..9824b416290 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -79,6 +79,7 @@
79#include <linux/bitops.h> 79#include <linux/bitops.h>
80#include <linux/firmware.h> 80#include <linux/firmware.h>
81#include <linux/device.h> 81#include <linux/device.h>
82#include <linux/slab.h>
82 83
83#include <linux/io.h> 84#include <linux/io.h>
84#include <linux/uaccess.h> 85#include <linux/uaccess.h>
diff --git a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c
index 85832ab924e..8a1b28a10ef 100644
--- a/drivers/char/dsp56k.c
+++ b/drivers/char/dsp56k.c
@@ -24,7 +24,6 @@
24 */ 24 */
25 25
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/slab.h> /* for kmalloc() and kfree() */
28#include <linux/major.h> 27#include <linux/major.h>
29#include <linux/types.h> 28#include <linux/types.h>
30#include <linux/errno.h> 29#include <linux/errno.h>
diff --git a/drivers/char/epca.c b/drivers/char/epca.c
index 17b044a71e0..6f5ffe1320f 100644
--- a/drivers/char/epca.c
+++ b/drivers/char/epca.c
@@ -36,7 +36,6 @@
36#include <linux/ctype.h> 36#include <linux/ctype.h>
37#include <linux/tty.h> 37#include <linux/tty.h>
38#include <linux/tty_flip.h> 38#include <linux/tty_flip.h>
39#include <linux/slab.h>
40#include <linux/smp_lock.h> 39#include <linux/smp_lock.h>
41#include <linux/ioport.h> 40#include <linux/ioport.h>
42#include <linux/interrupt.h> 41#include <linux/interrupt.h>
diff --git a/drivers/char/generic_serial.c b/drivers/char/generic_serial.c
index d400cbd280f..5954ee1dc95 100644
--- a/drivers/char/generic_serial.c
+++ b/drivers/char/generic_serial.c
@@ -29,6 +29,7 @@
29#include <linux/interrupt.h> 29#include <linux/interrupt.h>
30#include <linux/tty_flip.h> 30#include <linux/tty_flip.h>
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/gfp.h>
32#include <asm/uaccess.h> 33#include <asm/uaccess.h>
33 34
34#define DEBUG 35#define DEBUG
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index 9c5eea3ea4d..9ded667625a 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -31,6 +31,7 @@
31#include <linux/seq_file.h> 31#include <linux/seq_file.h>
32#include <linux/bitops.h> 32#include <linux/bitops.h>
33#include <linux/clocksource.h> 33#include <linux/clocksource.h>
34#include <linux/slab.h>
34 35
35#include <asm/current.h> 36#include <asm/current.h>
36#include <asm/uaccess.h> 37#include <asm/uaccess.h>
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c
index 465185fc0f5..35cca4c7fb1 100644
--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -38,6 +38,7 @@
38#include <linux/spinlock.h> 38#include <linux/spinlock.h>
39#include <linux/delay.h> 39#include <linux/delay.h>
40#include <linux/freezer.h> 40#include <linux/freezer.h>
41#include <linux/slab.h>
41 42
42#include <asm/uaccess.h> 43#include <asm/uaccess.h>
43 44
@@ -312,6 +313,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
312 spin_lock_irqsave(&hp->lock, flags); 313 spin_lock_irqsave(&hp->lock, flags);
313 /* Check and then increment for fast path open. */ 314 /* Check and then increment for fast path open. */
314 if (hp->count++ > 0) { 315 if (hp->count++ > 0) {
316 tty_kref_get(tty);
315 spin_unlock_irqrestore(&hp->lock, flags); 317 spin_unlock_irqrestore(&hp->lock, flags);
316 hvc_kick(); 318 hvc_kick();
317 return 0; 319 return 0;
@@ -319,7 +321,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
319 321
320 tty->driver_data = hp; 322 tty->driver_data = hp;
321 323
322 hp->tty = tty; 324 hp->tty = tty_kref_get(tty);
323 325
324 spin_unlock_irqrestore(&hp->lock, flags); 326 spin_unlock_irqrestore(&hp->lock, flags);
325 327
@@ -336,6 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
336 spin_lock_irqsave(&hp->lock, flags); 338 spin_lock_irqsave(&hp->lock, flags);
337 hp->tty = NULL; 339 hp->tty = NULL;
338 spin_unlock_irqrestore(&hp->lock, flags); 340 spin_unlock_irqrestore(&hp->lock, flags);
341 tty_kref_put(tty);
339 tty->driver_data = NULL; 342 tty->driver_data = NULL;
340 kref_put(&hp->kref, destroy_hvc_struct); 343 kref_put(&hp->kref, destroy_hvc_struct);
341 printk(KERN_ERR "hvc_open: request_irq failed with rc %d.\n", rc); 344 printk(KERN_ERR "hvc_open: request_irq failed with rc %d.\n", rc);
@@ -363,6 +366,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
363 return; 366 return;
364 367
365 hp = tty->driver_data; 368 hp = tty->driver_data;
369
366 spin_lock_irqsave(&hp->lock, flags); 370 spin_lock_irqsave(&hp->lock, flags);
367 371
368 if (--hp->count == 0) { 372 if (--hp->count == 0) {
@@ -389,6 +393,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
389 spin_unlock_irqrestore(&hp->lock, flags); 393 spin_unlock_irqrestore(&hp->lock, flags);
390 } 394 }
391 395
396 tty_kref_put(tty);
392 kref_put(&hp->kref, destroy_hvc_struct); 397 kref_put(&hp->kref, destroy_hvc_struct);
393} 398}
394 399
@@ -424,10 +429,11 @@ static void hvc_hangup(struct tty_struct *tty)
424 spin_unlock_irqrestore(&hp->lock, flags); 429 spin_unlock_irqrestore(&hp->lock, flags);
425 430
426 if (hp->ops->notifier_hangup) 431 if (hp->ops->notifier_hangup)
427 hp->ops->notifier_hangup(hp, hp->data); 432 hp->ops->notifier_hangup(hp, hp->data);
428 433
429 while(temp_open_count) { 434 while(temp_open_count) {
430 --temp_open_count; 435 --temp_open_count;
436 tty_kref_put(tty);
431 kref_put(&hp->kref, destroy_hvc_struct); 437 kref_put(&hp->kref, destroy_hvc_struct);
432 } 438 }
433} 439}
@@ -592,7 +598,7 @@ int hvc_poll(struct hvc_struct *hp)
592 } 598 }
593 599
594 /* No tty attached, just skip */ 600 /* No tty attached, just skip */
595 tty = hp->tty; 601 tty = tty_kref_get(hp->tty);
596 if (tty == NULL) 602 if (tty == NULL)
597 goto bail; 603 goto bail;
598 604
@@ -672,6 +678,8 @@ int hvc_poll(struct hvc_struct *hp)
672 678
673 tty_flip_buffer_push(tty); 679 tty_flip_buffer_push(tty);
674 } 680 }
681 if (tty)
682 tty_kref_put(tty);
675 683
676 return poll_mask; 684 return poll_mask;
677} 685}
@@ -807,7 +815,7 @@ int hvc_remove(struct hvc_struct *hp)
807 struct tty_struct *tty; 815 struct tty_struct *tty;
808 816
809 spin_lock_irqsave(&hp->lock, flags); 817 spin_lock_irqsave(&hp->lock, flags);
810 tty = hp->tty; 818 tty = tty_kref_get(hp->tty);
811 819
812 if (hp->index < MAX_NR_HVC_CONSOLES) 820 if (hp->index < MAX_NR_HVC_CONSOLES)
813 vtermnos[hp->index] = -1; 821 vtermnos[hp->index] = -1;
@@ -819,18 +827,18 @@ int hvc_remove(struct hvc_struct *hp)
819 /* 827 /*
820 * We 'put' the instance that was grabbed when the kref instance 828 * We 'put' the instance that was grabbed when the kref instance
821 * was initialized using kref_init(). Let the last holder of this 829 * was initialized using kref_init(). Let the last holder of this
822 * kref cause it to be removed, which will probably be the tty_hangup 830 * kref cause it to be removed, which will probably be the tty_vhangup
823 * below. 831 * below.
824 */ 832 */
825 kref_put(&hp->kref, destroy_hvc_struct); 833 kref_put(&hp->kref, destroy_hvc_struct);
826 834
827 /* 835 /*
828 * This function call will auto chain call hvc_hangup. The tty should 836 * This function call will auto chain call hvc_hangup.
829 * always be valid at this time unless a simultaneous tty close already
830 * cleaned up the hvc_struct.
831 */ 837 */
832 if (tty) 838 if (tty) {
833 tty_hangup(tty); 839 tty_vhangup(tty);
840 tty_kref_put(tty);
841 }
834 return 0; 842 return 0;
835} 843}
836EXPORT_SYMBOL_GPL(hvc_remove); 844EXPORT_SYMBOL_GPL(hvc_remove);
diff --git a/drivers/char/hvc_iucv.c b/drivers/char/hvc_iucv.c
index 37b0542a4ee..5a80ad68ef2 100644
--- a/drivers/char/hvc_iucv.c
+++ b/drivers/char/hvc_iucv.c
@@ -12,6 +12,7 @@
12#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt 12#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
13 13
14#include <linux/types.h> 14#include <linux/types.h>
15#include <linux/slab.h>
15#include <asm/ebcdic.h> 16#include <asm/ebcdic.h>
16#include <linux/ctype.h> 17#include <linux/ctype.h>
17#include <linux/delay.h> 18#include <linux/delay.h>
diff --git a/drivers/char/hvcs.c b/drivers/char/hvcs.c
index 266b858b8f8..bedc6c1b6fa 100644
--- a/drivers/char/hvcs.c
+++ b/drivers/char/hvcs.c
@@ -74,6 +74,7 @@
74#include <linux/module.h> 74#include <linux/module.h>
75#include <linux/moduleparam.h> 75#include <linux/moduleparam.h>
76#include <linux/sched.h> 76#include <linux/sched.h>
77#include <linux/slab.h>
77#include <linux/spinlock.h> 78#include <linux/spinlock.h>
78#include <linux/stat.h> 79#include <linux/stat.h>
79#include <linux/tty.h> 80#include <linux/tty.h>
diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
index 91b53eb1c05..86fe45c1996 100644
--- a/drivers/char/hw_random/intel-rng.c
+++ b/drivers/char/hw_random/intel-rng.c
@@ -30,6 +30,7 @@
30#include <linux/pci.h> 30#include <linux/pci.h>
31#include <linux/stop_machine.h> 31#include <linux/stop_machine.h>
32#include <linux/delay.h> 32#include <linux/delay.h>
33#include <linux/slab.h>
33#include <asm/io.h> 34#include <asm/io.h>
34 35
35 36
diff --git a/drivers/char/hw_random/octeon-rng.c b/drivers/char/hw_random/octeon-rng.c
index 54b0d9ba65c..9cd0feca318 100644
--- a/drivers/char/hw_random/octeon-rng.c
+++ b/drivers/char/hw_random/octeon-rng.c
@@ -15,6 +15,7 @@
15#include <linux/device.h> 15#include <linux/device.h>
16#include <linux/hw_random.h> 16#include <linux/hw_random.h>
17#include <linux/io.h> 17#include <linux/io.h>
18#include <linux/gfp.h>
18 19
19#include <asm/octeon/octeon.h> 20#include <asm/octeon/octeon.h>
20#include <asm/octeon/cvmx-rnm-defs.h> 21#include <asm/octeon/cvmx-rnm-defs.h>
diff --git a/drivers/char/hw_random/tx4939-rng.c b/drivers/char/hw_random/tx4939-rng.c
index 544d9085a8e..0bc0cb70210 100644
--- a/drivers/char/hw_random/tx4939-rng.c
+++ b/drivers/char/hw_random/tx4939-rng.c
@@ -14,6 +14,7 @@
14#include <linux/io.h> 14#include <linux/io.h>
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/hw_random.h> 16#include <linux/hw_random.h>
17#include <linux/gfp.h>
17 18
18#define TX4939_RNG_RCSR 0x00000000 19#define TX4939_RNG_RCSR 0x00000000
19#define TX4939_RNG_ROR(n) (0x00000018 + (n) * 8) 20#define TX4939_RNG_ROR(n) (0x00000018 + (n) * 8)
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index ec5e3f8df64..c6ad4234378 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -2272,42 +2272,52 @@ static int create_files(struct bmc_device *bmc)
2272 bmc->device_id_attr.attr.name = "device_id"; 2272 bmc->device_id_attr.attr.name = "device_id";
2273 bmc->device_id_attr.attr.mode = S_IRUGO; 2273 bmc->device_id_attr.attr.mode = S_IRUGO;
2274 bmc->device_id_attr.show = device_id_show; 2274 bmc->device_id_attr.show = device_id_show;
2275 sysfs_attr_init(&bmc->device_id_attr.attr);
2275 2276
2276 bmc->provides_dev_sdrs_attr.attr.name = "provides_device_sdrs"; 2277 bmc->provides_dev_sdrs_attr.attr.name = "provides_device_sdrs";
2277 bmc->provides_dev_sdrs_attr.attr.mode = S_IRUGO; 2278 bmc->provides_dev_sdrs_attr.attr.mode = S_IRUGO;
2278 bmc->provides_dev_sdrs_attr.show = provides_dev_sdrs_show; 2279 bmc->provides_dev_sdrs_attr.show = provides_dev_sdrs_show;
2280 sysfs_attr_init(&bmc->provides_dev_sdrs_attr.attr);
2279 2281
2280 bmc->revision_attr.attr.name = "revision"; 2282 bmc->revision_attr.attr.name = "revision";
2281 bmc->revision_attr.attr.mode = S_IRUGO; 2283 bmc->revision_attr.attr.mode = S_IRUGO;
2282 bmc->revision_attr.show = revision_show; 2284 bmc->revision_attr.show = revision_show;
2285 sysfs_attr_init(&bmc->revision_attr.attr);
2283 2286
2284 bmc->firmware_rev_attr.attr.name = "firmware_revision"; 2287 bmc->firmware_rev_attr.attr.name = "firmware_revision";
2285 bmc->firmware_rev_attr.attr.mode = S_IRUGO; 2288 bmc->firmware_rev_attr.attr.mode = S_IRUGO;
2286 bmc->firmware_rev_attr.show = firmware_rev_show; 2289 bmc->firmware_rev_attr.show = firmware_rev_show;
2290 sysfs_attr_init(&bmc->firmware_rev_attr.attr);
2287 2291
2288 bmc->version_attr.attr.name = "ipmi_version"; 2292 bmc->version_attr.attr.name = "ipmi_version";
2289 bmc->version_attr.attr.mode = S_IRUGO; 2293 bmc->version_attr.attr.mode = S_IRUGO;
2290 bmc->version_attr.show = ipmi_version_show; 2294 bmc->version_attr.show = ipmi_version_show;
2295 sysfs_attr_init(&bmc->version_attr.attr);
2291 2296
2292 bmc->add_dev_support_attr.attr.name = "additional_device_support"; 2297 bmc->add_dev_support_attr.attr.name = "additional_device_support";
2293 bmc->add_dev_support_attr.attr.mode = S_IRUGO; 2298 bmc->add_dev_support_attr.attr.mode = S_IRUGO;
2294 bmc->add_dev_support_attr.show = add_dev_support_show; 2299 bmc->add_dev_support_attr.show = add_dev_support_show;
2300 sysfs_attr_init(&bmc->add_dev_support_attr.attr);
2295 2301
2296 bmc->manufacturer_id_attr.attr.name = "manufacturer_id"; 2302 bmc->manufacturer_id_attr.attr.name = "manufacturer_id";
2297 bmc->manufacturer_id_attr.attr.mode = S_IRUGO; 2303 bmc->manufacturer_id_attr.attr.mode = S_IRUGO;
2298 bmc->manufacturer_id_attr.show = manufacturer_id_show; 2304 bmc->manufacturer_id_attr.show = manufacturer_id_show;
2305 sysfs_attr_init(&bmc->manufacturer_id_attr.attr);
2299 2306
2300 bmc->product_id_attr.attr.name = "product_id"; 2307 bmc->product_id_attr.attr.name = "product_id";
2301 bmc->product_id_attr.attr.mode = S_IRUGO; 2308 bmc->product_id_attr.attr.mode = S_IRUGO;
2302 bmc->product_id_attr.show = product_id_show; 2309 bmc->product_id_attr.show = product_id_show;
2310 sysfs_attr_init(&bmc->product_id_attr.attr);
2303 2311
2304 bmc->guid_attr.attr.name = "guid"; 2312 bmc->guid_attr.attr.name = "guid";
2305 bmc->guid_attr.attr.mode = S_IRUGO; 2313 bmc->guid_attr.attr.mode = S_IRUGO;
2306 bmc->guid_attr.show = guid_show; 2314 bmc->guid_attr.show = guid_show;
2315 sysfs_attr_init(&bmc->guid_attr.attr);
2307 2316
2308 bmc->aux_firmware_rev_attr.attr.name = "aux_firmware_revision"; 2317 bmc->aux_firmware_rev_attr.attr.name = "aux_firmware_revision";
2309 bmc->aux_firmware_rev_attr.attr.mode = S_IRUGO; 2318 bmc->aux_firmware_rev_attr.attr.mode = S_IRUGO;
2310 bmc->aux_firmware_rev_attr.show = aux_firmware_rev_show; 2319 bmc->aux_firmware_rev_attr.show = aux_firmware_rev_show;
2320 sysfs_attr_init(&bmc->aux_firmware_rev_attr.attr);
2311 2321
2312 err = device_create_file(&bmc->dev->dev, 2322 err = device_create_file(&bmc->dev->dev,
2313 &bmc->device_id_attr); 2323 &bmc->device_id_attr);
diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c
index be2e8f9a27c..c1ab303455c 100644
--- a/drivers/char/isicom.c
+++ b/drivers/char/isicom.c
@@ -130,6 +130,7 @@
130#include <linux/timer.h> 130#include <linux/timer.h>
131#include <linux/delay.h> 131#include <linux/delay.h>
132#include <linux/ioport.h> 132#include <linux/ioport.h>
133#include <linux/slab.h>
133 134
134#include <linux/uaccess.h> 135#include <linux/uaccess.h>
135#include <linux/io.h> 136#include <linux/io.h>
@@ -878,8 +879,8 @@ static int isicom_open(struct tty_struct *tty, struct file *filp)
878 if (tport == NULL) 879 if (tport == NULL)
879 return -ENODEV; 880 return -ENODEV;
880 port = container_of(tport, struct isi_port, port); 881 port = container_of(tport, struct isi_port, port);
881 card = &isi_card[BOARD(tty->index)];
882 882
883 tty->driver_data = port;
883 return tty_port_open(tport, tty, filp); 884 return tty_port_open(tport, tty, filp);
884} 885}
885 886
@@ -935,7 +936,12 @@ static void isicom_shutdown(struct tty_port *port)
935static void isicom_close(struct tty_struct *tty, struct file *filp) 936static void isicom_close(struct tty_struct *tty, struct file *filp)
936{ 937{
937 struct isi_port *ip = tty->driver_data; 938 struct isi_port *ip = tty->driver_data;
938 struct tty_port *port = &ip->port; 939 struct tty_port *port;
940
941 if (ip == NULL)
942 return;
943
944 port = &ip->port;
939 if (isicom_paranoia_check(ip, tty->name, "isicom_close")) 945 if (isicom_paranoia_check(ip, tty->name, "isicom_close"))
940 return; 946 return;
941 tty_port_close(port, tty, filp); 947 tty_port_close(port, tty, filp);
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index 4cd6c527ee4..4e395c956a0 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -827,6 +827,8 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
827 return -ENODEV; 827 return -ENODEV;
828 if (portp->devnr < 1) 828 if (portp->devnr < 1)
829 return -ENODEV; 829 return -ENODEV;
830
831 tty->driver_data = portp;
830 return tty_port_open(&portp->port, tty, filp); 832 return tty_port_open(&portp->port, tty, filp);
831} 833}
832 834
diff --git a/drivers/char/mbcs.c b/drivers/char/mbcs.c
index 87c67b42bc0..83bef4efe37 100644
--- a/drivers/char/mbcs.c
+++ b/drivers/char/mbcs.c
@@ -26,6 +26,7 @@
26#include <linux/uio.h> 26#include <linux/uio.h>
27#include <linux/mutex.h> 27#include <linux/mutex.h>
28#include <linux/smp_lock.h> 28#include <linux/smp_lock.h>
29#include <linux/slab.h>
29#include <asm/io.h> 30#include <asm/io.h>
30#include <asm/uaccess.h> 31#include <asm/uaccess.h>
31#include <asm/system.h> 32#include <asm/system.h>
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 1f3215ac085..f54dab8acdc 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -225,6 +225,7 @@ int __weak phys_mem_access_prot_allowed(struct file *file,
225 * outside of main memory. 225 * outside of main memory.
226 * 226 *
227 */ 227 */
228#ifdef pgprot_noncached
228static int uncached_access(struct file *file, unsigned long addr) 229static int uncached_access(struct file *file, unsigned long addr)
229{ 230{
230#if defined(CONFIG_IA64) 231#if defined(CONFIG_IA64)
@@ -251,6 +252,7 @@ static int uncached_access(struct file *file, unsigned long addr)
251 return addr >= __pa(high_memory); 252 return addr >= __pa(high_memory);
252#endif 253#endif
253} 254}
255#endif
254 256
255static pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, 257static pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
256 unsigned long size, pgprot_t vma_prot) 258 unsigned long size, pgprot_t vma_prot)
@@ -710,11 +712,6 @@ static loff_t memory_lseek(struct file *file, loff_t offset, int orig)
710 switch (orig) { 712 switch (orig) {
711 case SEEK_CUR: 713 case SEEK_CUR:
712 offset += file->f_pos; 714 offset += file->f_pos;
713 if ((unsigned long long)offset <
714 (unsigned long long)file->f_pos) {
715 ret = -EOVERFLOW;
716 break;
717 }
718 case SEEK_SET: 715 case SEEK_SET:
719 /* to avoid userland mistaking f_pos=-9 as -EBADF=-9 */ 716 /* to avoid userland mistaking f_pos=-9 as -EBADF=-9 */
720 if ((unsigned long long)offset >= ~0xFFFULL) { 717 if ((unsigned long long)offset >= ~0xFFFULL) {
@@ -908,6 +905,9 @@ static int __init chr_dev_init(void)
908 printk("unable to get major %d for memory devs\n", MEM_MAJOR); 905 printk("unable to get major %d for memory devs\n", MEM_MAJOR);
909 906
910 mem_class = class_create(THIS_MODULE, "mem"); 907 mem_class = class_create(THIS_MODULE, "mem");
908 if (IS_ERR(mem_class))
909 return PTR_ERR(mem_class);
910
911 mem_class->devnode = mem_devnode; 911 mem_class->devnode = mem_devnode;
912 for (minor = 1; minor < ARRAY_SIZE(devlist); minor++) { 912 for (minor = 1; minor < ARRAY_SIZE(devlist); minor++) {
913 if (!devlist[minor].name) 913 if (!devlist[minor].name)
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index 94a136e96c0..92ab03d2829 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -40,7 +40,6 @@
40#include <linux/miscdevice.h> 40#include <linux/miscdevice.h>
41#include <linux/kernel.h> 41#include <linux/kernel.h>
42#include <linux/major.h> 42#include <linux/major.h>
43#include <linux/slab.h>
44#include <linux/mutex.h> 43#include <linux/mutex.h>
45#include <linux/proc_fs.h> 44#include <linux/proc_fs.h>
46#include <linux/seq_file.h> 45#include <linux/seq_file.h>
@@ -49,6 +48,7 @@
49#include <linux/device.h> 48#include <linux/device.h>
50#include <linux/tty.h> 49#include <linux/tty.h>
51#include <linux/kmod.h> 50#include <linux/kmod.h>
51#include <linux/gfp.h>
52 52
53/* 53/*
54 * Head entry for the doubly linked miscdevice list 54 * Head entry for the doubly linked miscdevice list
diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index 04fd0d843b3..ea7c99fa978 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -33,6 +33,7 @@
33#include <linux/time.h> 33#include <linux/time.h>
34#include <linux/math64.h> 34#include <linux/math64.h>
35#include <linux/smp_lock.h> 35#include <linux/smp_lock.h>
36#include <linux/slab.h>
36 37
37#include <asm/uaccess.h> 38#include <asm/uaccess.h>
38#include <asm/sn/addrs.h> 39#include <asm/sn/addrs.h>
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
index 166495d6a1d..107b0bd58d1 100644
--- a/drivers/char/moxa.c
+++ b/drivers/char/moxa.c
@@ -43,6 +43,7 @@
43#include <linux/pci.h> 43#include <linux/pci.h>
44#include <linux/init.h> 44#include <linux/init.h>
45#include <linux/bitops.h> 45#include <linux/bitops.h>
46#include <linux/slab.h>
46 47
47#include <asm/system.h> 48#include <asm/system.h>
48#include <asm/io.h> 49#include <asm/io.h>
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
index e0c5d2a6904..d2692d443f7 100644
--- a/drivers/char/mxser.c
+++ b/drivers/char/mxser.c
@@ -33,12 +33,12 @@
33#include <linux/string.h> 33#include <linux/string.h>
34#include <linux/fcntl.h> 34#include <linux/fcntl.h>
35#include <linux/ptrace.h> 35#include <linux/ptrace.h>
36#include <linux/gfp.h>
37#include <linux/ioport.h> 36#include <linux/ioport.h>
38#include <linux/mm.h> 37#include <linux/mm.h>
39#include <linux/delay.h> 38#include <linux/delay.h>
40#include <linux/pci.h> 39#include <linux/pci.h>
41#include <linux/bitops.h> 40#include <linux/bitops.h>
41#include <linux/slab.h>
42 42
43#include <asm/system.h> 43#include <asm/system.h>
44#include <asm/io.h> 44#include <asm/io.h>
@@ -1011,6 +1011,7 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
1011 if (!info->ioaddr) 1011 if (!info->ioaddr)
1012 return -ENODEV; 1012 return -ENODEV;
1013 1013
1014 tty->driver_data = info;
1014 return tty_port_open(&info->port, tty, filp); 1015 return tty_port_open(&info->port, tty, filp);
1015} 1016}
1016 1017
@@ -1074,7 +1075,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
1074 struct mxser_port *info = tty->driver_data; 1075 struct mxser_port *info = tty->driver_data;
1075 struct tty_port *port = &info->port; 1076 struct tty_port *port = &info->port;
1076 1077
1077 if (tty->index == MXSER_PORTS) 1078 if (tty->index == MXSER_PORTS || info == NULL)
1078 return; 1079 return;
1079 if (tty_port_close_start(port, tty, filp) == 0) 1080 if (tty_port_close_start(port, tty, filp) == 0)
1080 return; 1081 return;
@@ -1768,7 +1769,7 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
1768 int len, lsr; 1769 int len, lsr;
1769 1770
1770 len = mxser_chars_in_buffer(tty); 1771 len = mxser_chars_in_buffer(tty);
1771 spin_lock(&info->slock); 1772 spin_lock_irq(&info->slock);
1772 lsr = inb(info->ioaddr + UART_LSR) & UART_LSR_THRE; 1773 lsr = inb(info->ioaddr + UART_LSR) & UART_LSR_THRE;
1773 spin_unlock_irq(&info->slock); 1774 spin_unlock_irq(&info->slock);
1774 len += (lsr ? 0 : 1); 1775 len += (lsr ? 0 : 1);
@@ -1778,12 +1779,12 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
1778 case MOXA_ASPP_MON: { 1779 case MOXA_ASPP_MON: {
1779 int mcr, status; 1780 int mcr, status;
1780 1781
1781 spin_lock(&info->slock); 1782 spin_lock_irq(&info->slock);
1782 status = mxser_get_msr(info->ioaddr, 1, tty->index); 1783 status = mxser_get_msr(info->ioaddr, 1, tty->index);
1783 mxser_check_modem_status(tty, info, status); 1784 mxser_check_modem_status(tty, info, status);
1784 1785
1785 mcr = inb(info->ioaddr + UART_MCR); 1786 mcr = inb(info->ioaddr + UART_MCR);
1786 spin_unlock(&info->slock); 1787 spin_unlock_irq(&info->slock);
1787 1788
1788 if (mcr & MOXA_MUST_MCR_XON_FLAG) 1789 if (mcr & MOXA_MUST_MCR_XON_FLAG)
1789 info->mon_data.hold_reason &= ~NPPI_NOTIFY_XOFFHOLD; 1790 info->mon_data.hold_reason &= ~NPPI_NOTIFY_XOFFHOLD;
diff --git a/drivers/char/nozomi.c b/drivers/char/nozomi.c
index a3f32a15fde..a6638003f53 100644
--- a/drivers/char/nozomi.c
+++ b/drivers/char/nozomi.c
@@ -55,6 +55,7 @@
55#include <linux/init.h> 55#include <linux/init.h>
56#include <linux/kfifo.h> 56#include <linux/kfifo.h>
57#include <linux/uaccess.h> 57#include <linux/uaccess.h>
58#include <linux/slab.h>
58#include <asm/byteorder.h> 59#include <asm/byteorder.h>
59 60
60#include <linux/delay.h> 61#include <linux/delay.h>
diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
index 5eb83c3ca20..47e8f7b0e4c 100644
--- a/drivers/char/nvram.c
+++ b/drivers/char/nvram.c
@@ -100,7 +100,6 @@
100#include <linux/types.h> 100#include <linux/types.h>
101#include <linux/errno.h> 101#include <linux/errno.h>
102#include <linux/miscdevice.h> 102#include <linux/miscdevice.h>
103#include <linux/slab.h>
104#include <linux/ioport.h> 103#include <linux/ioport.h>
105#include <linux/fcntl.h> 104#include <linux/fcntl.h>
106#include <linux/mc146818rtc.h> 105#include <linux/mc146818rtc.h>
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index c9bc896d68a..90b199f97be 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -1026,14 +1026,16 @@ static ssize_t cmm_read(struct file *filp, __user char *buf, size_t count,
1026 1026
1027 xoutb(0, REG_FLAGS1(iobase)); /* clear detectCMM */ 1027 xoutb(0, REG_FLAGS1(iobase)); /* clear detectCMM */
1028 /* last check before exit */ 1028 /* last check before exit */
1029 if (!io_detect_cm4000(iobase, dev)) 1029 if (!io_detect_cm4000(iobase, dev)) {
1030 count = -ENODEV; 1030 rc = -ENODEV;
1031 goto release_io;
1032 }
1031 1033
1032 if (test_bit(IS_INVREV, &dev->flags) && count > 0) 1034 if (test_bit(IS_INVREV, &dev->flags) && count > 0)
1033 str_invert_revert(dev->rbuf, count); 1035 str_invert_revert(dev->rbuf, count);
1034 1036
1035 if (copy_to_user(buf, dev->rbuf, count)) 1037 if (copy_to_user(buf, dev->rbuf, count))
1036 return -EFAULT; 1038 rc = -EFAULT;
1037 1039
1038release_io: 1040release_io:
1039 clear_bit(LOCK_IO, &dev->flags); 1041 clear_bit(LOCK_IO, &dev->flags);
diff --git a/drivers/char/pcmcia/ipwireless/network.c b/drivers/char/pcmcia/ipwireless/network.c
index 590762a7f21..65920163f53 100644
--- a/drivers/char/pcmcia/ipwireless/network.c
+++ b/drivers/char/pcmcia/ipwireless/network.c
@@ -21,6 +21,7 @@
21#include <linux/netdevice.h> 21#include <linux/netdevice.h>
22#include <linux/ppp_channel.h> 22#include <linux/ppp_channel.h>
23#include <linux/ppp_defs.h> 23#include <linux/ppp_defs.h>
24#include <linux/slab.h>
24#include <linux/if_ppp.h> 25#include <linux/if_ppp.h>
25#include <linux/skbuff.h> 26#include <linux/skbuff.h>
26 27
diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
index 432655bcb04..fdd37543aa7 100644
--- a/drivers/char/ppdev.c
+++ b/drivers/char/ppdev.c
@@ -64,6 +64,7 @@
64#include <linux/parport.h> 64#include <linux/parport.h>
65#include <linux/ctype.h> 65#include <linux/ctype.h>
66#include <linux/poll.h> 66#include <linux/poll.h>
67#include <linux/slab.h>
67#include <linux/major.h> 68#include <linux/major.h>
68#include <linux/ppdev.h> 69#include <linux/ppdev.h>
69#include <linux/smp_lock.h> 70#include <linux/smp_lock.h>
diff --git a/drivers/char/ps3flash.c b/drivers/char/ps3flash.c
index f424d394a28..606048b72bc 100644
--- a/drivers/char/ps3flash.c
+++ b/drivers/char/ps3flash.c
@@ -20,6 +20,7 @@
20 20
21#include <linux/fs.h> 21#include <linux/fs.h>
22#include <linux/miscdevice.h> 22#include <linux/miscdevice.h>
23#include <linux/slab.h>
23#include <linux/uaccess.h> 24#include <linux/uaccess.h>
24 25
25#include <asm/lv1call.h> 26#include <asm/lv1call.h>
diff --git a/drivers/char/pty.c b/drivers/char/pty.c
index 5ee42481726..d83a43130df 100644
--- a/drivers/char/pty.c
+++ b/drivers/char/pty.c
@@ -29,6 +29,7 @@
29#include <linux/uaccess.h> 29#include <linux/uaccess.h>
30#include <linux/bitops.h> 30#include <linux/bitops.h>
31#include <linux/devpts_fs.h> 31#include <linux/devpts_fs.h>
32#include <linux/slab.h>
32 33
33#include <asm/system.h> 34#include <asm/system.h>
34 35
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index 64acd05f71c..8756ab0daa8 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -20,6 +20,7 @@
20#include <linux/device.h> 20#include <linux/device.h>
21#include <linux/mutex.h> 21#include <linux/mutex.h>
22#include <linux/smp_lock.h> 22#include <linux/smp_lock.h>
23#include <linux/gfp.h>
23 24
24#include <asm/uaccess.h> 25#include <asm/uaccess.h>
25 26
@@ -247,6 +248,7 @@ static const struct file_operations raw_fops = {
247 .aio_read = generic_file_aio_read, 248 .aio_read = generic_file_aio_read,
248 .write = do_sync_write, 249 .write = do_sync_write,
249 .aio_write = blkdev_aio_write, 250 .aio_write = blkdev_aio_write,
251 .fsync = blkdev_fsync,
250 .open = raw_open, 252 .open = raw_open,
251 .release= raw_release, 253 .release= raw_release,
252 .ioctl = raw_ioctl, 254 .ioctl = raw_ioctl,
diff --git a/drivers/char/rio/rioinit.c b/drivers/char/rio/rioinit.c
index be0ba401966..24a282bb89d 100644
--- a/drivers/char/rio/rioinit.c
+++ b/drivers/char/rio/rioinit.c
@@ -31,7 +31,6 @@
31*/ 31*/
32 32
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/slab.h>
35#include <linux/errno.h> 34#include <linux/errno.h>
36#include <linux/delay.h> 35#include <linux/delay.h>
37#include <asm/io.h> 36#include <asm/io.h>
diff --git a/drivers/char/rio/riointr.c b/drivers/char/rio/riointr.c
index 71f87600907..2e71aecae20 100644
--- a/drivers/char/rio/riointr.c
+++ b/drivers/char/rio/riointr.c
@@ -31,7 +31,6 @@
31*/ 31*/
32 32
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/slab.h>
35#include <linux/errno.h> 34#include <linux/errno.h>
36#include <linux/tty.h> 35#include <linux/tty.h>
37#include <linux/tty_flip.h> 36#include <linux/tty_flip.h>
diff --git a/drivers/char/rio/rioparam.c b/drivers/char/rio/rioparam.c
index d687c17be15..6415f3f32a7 100644
--- a/drivers/char/rio/rioparam.c
+++ b/drivers/char/rio/rioparam.c
@@ -31,7 +31,6 @@
31*/ 31*/
32 32
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/slab.h>
35#include <linux/errno.h> 34#include <linux/errno.h>
36#include <linux/tty.h> 35#include <linux/tty.h>
37#include <asm/io.h> 36#include <asm/io.h>
diff --git a/drivers/char/rio/rioroute.c b/drivers/char/rio/rioroute.c
index 706c2a25f7a..f9b936ac339 100644
--- a/drivers/char/rio/rioroute.c
+++ b/drivers/char/rio/rioroute.c
@@ -31,7 +31,6 @@
31*/ 31*/
32 32
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/slab.h>
35#include <linux/errno.h> 34#include <linux/errno.h>
36#include <asm/io.h> 35#include <asm/io.h>
37#include <asm/system.h> 36#include <asm/system.h>
diff --git a/drivers/char/rio/riotty.c b/drivers/char/rio/riotty.c
index 47fab7c3307..8a90393faf3 100644
--- a/drivers/char/rio/riotty.c
+++ b/drivers/char/rio/riotty.c
@@ -34,7 +34,6 @@
34 34
35#include <linux/module.h> 35#include <linux/module.h>
36#include <linux/sched.h> 36#include <linux/sched.h>
37#include <linux/slab.h>
38#include <linux/errno.h> 37#include <linux/errno.h>
39#include <linux/tty.h> 38#include <linux/tty.h>
40#include <linux/string.h> 39#include <linux/string.h>
diff --git a/drivers/char/riscom8.c b/drivers/char/riscom8.c
index 0a8d1e56c99..b02332a5412 100644
--- a/drivers/char/riscom8.c
+++ b/drivers/char/riscom8.c
@@ -909,6 +909,7 @@ static int rc_open(struct tty_struct *tty, struct file *filp)
909 if (error) 909 if (error)
910 return error; 910 return error;
911 911
912 tty->driver_data = port;
912 return tty_port_open(&port->port, tty, filp); 913 return tty_port_open(&port->port, tty, filp);
913} 914}
914 915
diff --git a/drivers/char/serial167.c b/drivers/char/serial167.c
index 1ec3d5cd748..8dfd24721a8 100644
--- a/drivers/char/serial167.c
+++ b/drivers/char/serial167.c
@@ -64,6 +64,7 @@
64#include <linux/module.h> 64#include <linux/module.h>
65#include <linux/bitops.h> 65#include <linux/bitops.h>
66#include <linux/tty_flip.h> 66#include <linux/tty_flip.h>
67#include <linux/gfp.h>
67 68
68#include <asm/system.h> 69#include <asm/system.h>
69#include <asm/io.h> 70#include <asm/io.h>
diff --git a/drivers/char/snsc_event.c b/drivers/char/snsc_event.c
index 55a95892ccf..ee156948b9f 100644
--- a/drivers/char/snsc_event.c
+++ b/drivers/char/snsc_event.c
@@ -17,6 +17,7 @@
17 17
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/sched.h> 19#include <linux/sched.h>
20#include <linux/slab.h>
20#include <asm/byteorder.h> 21#include <asm/byteorder.h>
21#include <asm/sn/sn_sal.h> 22#include <asm/sn/sn_sal.h>
22#include <asm/unaligned.h> 23#include <asm/unaligned.h>
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index bba727c3807..73f66d03624 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -50,6 +50,7 @@
50#include <linux/err.h> 50#include <linux/err.h>
51#include <linux/kfifo.h> 51#include <linux/kfifo.h>
52#include <linux/platform_device.h> 52#include <linux/platform_device.h>
53#include <linux/gfp.h>
53 54
54#include <asm/uaccess.h> 55#include <asm/uaccess.h>
55#include <asm/io.h> 56#include <asm/io.h>
diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c
index 07ac14d949c..2c24fcdc722 100644
--- a/drivers/char/specialix.c
+++ b/drivers/char/specialix.c
@@ -94,6 +94,7 @@
94#include <linux/pci.h> 94#include <linux/pci.h>
95#include <linux/init.h> 95#include <linux/init.h>
96#include <linux/uaccess.h> 96#include <linux/uaccess.h>
97#include <linux/gfp.h>
97 98
98#include "specialix_io8.h" 99#include "specialix_io8.h"
99#include "cd1865.h" 100#include "cd1865.h"
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index 0e511d61f54..6049fd73192 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -724,7 +724,6 @@ static int stl_open(struct tty_struct *tty, struct file *filp)
724{ 724{
725 struct stlport *portp; 725 struct stlport *portp;
726 struct stlbrd *brdp; 726 struct stlbrd *brdp;
727 struct tty_port *port;
728 unsigned int minordev, brdnr, panelnr; 727 unsigned int minordev, brdnr, panelnr;
729 int portnr; 728 int portnr;
730 729
@@ -754,7 +753,8 @@ static int stl_open(struct tty_struct *tty, struct file *filp)
754 portp = brdp->panels[panelnr]->ports[portnr]; 753 portp = brdp->panels[panelnr]->ports[portnr];
755 if (portp == NULL) 754 if (portp == NULL)
756 return -ENODEV; 755 return -ENODEV;
757 port = &portp->port; 756
757 tty->driver_data = portp;
758 return tty_port_open(&portp->port, tty, filp); 758 return tty_port_open(&portp->port, tty, filp);
759 759
760} 760}
@@ -841,7 +841,8 @@ static void stl_close(struct tty_struct *tty, struct file *filp)
841 pr_debug("stl_close(tty=%p,filp=%p)\n", tty, filp); 841 pr_debug("stl_close(tty=%p,filp=%p)\n", tty, filp);
842 842
843 portp = tty->driver_data; 843 portp = tty->driver_data;
844 BUG_ON(portp == NULL); 844 if(portp == NULL)
845 return;
845 tty_port_close(&portp->port, tty, filp); 846 tty_port_close(&portp->port, tty, filp);
846} 847}
847 848
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c
index 1ae2de7d8b4..59de2525d30 100644
--- a/drivers/char/sysrq.c
+++ b/drivers/char/sysrq.c
@@ -38,6 +38,7 @@
38#include <linux/workqueue.h> 38#include <linux/workqueue.h>
39#include <linux/hrtimer.h> 39#include <linux/hrtimer.h>
40#include <linux/oom.h> 40#include <linux/oom.h>
41#include <linux/slab.h>
41 42
42#include <asm/ptrace.h> 43#include <asm/ptrace.h>
43#include <asm/irq_regs.h> 44#include <asm/irq_regs.h>
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index f06bb37defb..068c816e694 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -24,6 +24,7 @@
24 */ 24 */
25 25
26#include <linux/poll.h> 26#include <linux/poll.h>
27#include <linux/slab.h>
27#include <linux/mutex.h> 28#include <linux/mutex.h>
28#include <linux/spinlock.h> 29#include <linux/spinlock.h>
29 30
diff --git a/drivers/char/tpm/tpm_bios.c b/drivers/char/tpm/tpm_bios.c
index bf2170fb1cd..0636520fa9b 100644
--- a/drivers/char/tpm/tpm_bios.c
+++ b/drivers/char/tpm/tpm_bios.c
@@ -22,6 +22,7 @@
22#include <linux/fs.h> 22#include <linux/fs.h>
23#include <linux/security.h> 23#include <linux/security.h>
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/slab.h>
25#include <acpi/acpi.h> 26#include <acpi/acpi.h>
26#include "tpm.h" 27#include "tpm.h"
27 28
diff --git a/drivers/char/tpm/tpm_nsc.c b/drivers/char/tpm/tpm_nsc.c
index 70efba2ee05..a605cb7dd89 100644
--- a/drivers/char/tpm/tpm_nsc.c
+++ b/drivers/char/tpm/tpm_nsc.c
@@ -20,6 +20,7 @@
20 */ 20 */
21 21
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/slab.h>
23#include "tpm.h" 24#include "tpm.h"
24 25
25/* National definitions */ 26/* National definitions */
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 2405f17b29d..94345994f8a 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -22,6 +22,7 @@
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/moduleparam.h> 23#include <linux/moduleparam.h>
24#include <linux/pnp.h> 24#include <linux/pnp.h>
25#include <linux/slab.h>
25#include <linux/interrupt.h> 26#include <linux/interrupt.h>
26#include <linux/wait.h> 27#include <linux/wait.h>
27#include "tpm.h" 28#include "tpm.h"
diff --git a/drivers/char/tty_audit.c b/drivers/char/tty_audit.c
index 283a15bc84e..1b8ee590b4c 100644
--- a/drivers/char/tty_audit.c
+++ b/drivers/char/tty_audit.c
@@ -10,6 +10,7 @@
10 */ 10 */
11 11
12#include <linux/audit.h> 12#include <linux/audit.h>
13#include <linux/slab.h>
13#include <linux/tty.h> 14#include <linux/tty.h>
14 15
15struct tty_audit_buf { 16struct tty_audit_buf {
diff --git a/drivers/char/tty_buffer.c b/drivers/char/tty_buffer.c
index af8d9771572..7ee52164d47 100644
--- a/drivers/char/tty_buffer.c
+++ b/drivers/char/tty_buffer.c
@@ -248,7 +248,7 @@ int tty_insert_flip_string_fixed_flag(struct tty_struct *tty,
248{ 248{
249 int copied = 0; 249 int copied = 0;
250 do { 250 do {
251 int goal = min(size - copied, TTY_BUFFER_PAGE); 251 int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE);
252 int space = tty_buffer_request_room(tty, goal); 252 int space = tty_buffer_request_room(tty, goal);
253 struct tty_buffer *tb = tty->buf.tail; 253 struct tty_buffer *tb = tty->buf.tail;
254 /* If there is no space then tb may be NULL */ 254 /* If there is no space then tb may be NULL */
@@ -285,7 +285,7 @@ int tty_insert_flip_string_flags(struct tty_struct *tty,
285{ 285{
286 int copied = 0; 286 int copied = 0;
287 do { 287 do {
288 int goal = min(size - copied, TTY_BUFFER_PAGE); 288 int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE);
289 int space = tty_buffer_request_room(tty, goal); 289 int space = tty_buffer_request_room(tty, goal);
290 struct tty_buffer *tb = tty->buf.tail; 290 struct tty_buffer *tb = tty->buf.tail;
291 /* If there is no space then tb may be NULL */ 291 /* If there is no space then tb may be NULL */
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index a42c466f709..6da962c9b21 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -1423,6 +1423,8 @@ static void release_one_tty(struct work_struct *work)
1423 list_del_init(&tty->tty_files); 1423 list_del_init(&tty->tty_files);
1424 file_list_unlock(); 1424 file_list_unlock();
1425 1425
1426 put_pid(tty->pgrp);
1427 put_pid(tty->session);
1426 free_tty_struct(tty); 1428 free_tty_struct(tty);
1427} 1429}
1428 1430
diff --git a/drivers/char/tty_port.c b/drivers/char/tty_port.c
index be492dd6643..a3bd1d0b66c 100644
--- a/drivers/char/tty_port.c
+++ b/drivers/char/tty_port.c
@@ -119,7 +119,7 @@ EXPORT_SYMBOL(tty_port_tty_set);
119static void tty_port_shutdown(struct tty_port *port) 119static void tty_port_shutdown(struct tty_port *port)
120{ 120{
121 mutex_lock(&port->mutex); 121 mutex_lock(&port->mutex);
122 if (port->ops->shutdown && 122 if (port->ops->shutdown && !port->console &&
123 test_and_clear_bit(ASYNCB_INITIALIZED, &port->flags)) 123 test_and_clear_bit(ASYNCB_INITIALIZED, &port->flags))
124 port->ops->shutdown(port); 124 port->ops->shutdown(port);
125 mutex_unlock(&port->mutex); 125 mutex_unlock(&port->mutex);
diff --git a/drivers/char/viotape.c b/drivers/char/viotape.c
index 042c8149a6d..1144a04cda6 100644
--- a/drivers/char/viotape.c
+++ b/drivers/char/viotape.c
@@ -47,6 +47,7 @@
47#include <linux/proc_fs.h> 47#include <linux/proc_fs.h>
48#include <linux/seq_file.h> 48#include <linux/seq_file.h>
49#include <linux/smp_lock.h> 49#include <linux/smp_lock.h>
50#include <linux/slab.h>
50 51
51#include <asm/uaccess.h> 52#include <asm/uaccess.h>
52#include <asm/ioctls.h> 53#include <asm/ioctls.h>
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index f404ccfc9c2..196428c2287 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -25,6 +25,7 @@
25#include <linux/list.h> 25#include <linux/list.h>
26#include <linux/poll.h> 26#include <linux/poll.h>
27#include <linux/sched.h> 27#include <linux/sched.h>
28#include <linux/slab.h>
28#include <linux/spinlock.h> 29#include <linux/spinlock.h>
29#include <linux/virtio.h> 30#include <linux/virtio.h>
30#include <linux/virtio_console.h> 31#include <linux/virtio_console.h>
@@ -32,6 +33,35 @@
32#include <linux/workqueue.h> 33#include <linux/workqueue.h>
33#include "hvc_console.h" 34#include "hvc_console.h"
34 35
36/* Moved here from .h file in order to disable MULTIPORT. */
37#define VIRTIO_CONSOLE_F_MULTIPORT 1 /* Does host provide multiple ports? */
38
39struct virtio_console_multiport_conf {
40 struct virtio_console_config config;
41 /* max. number of ports this device can hold */
42 __u32 max_nr_ports;
43 /* number of ports added so far */
44 __u32 nr_ports;
45} __attribute__((packed));
46
47/*
48 * A message that's passed between the Host and the Guest for a
49 * particular port.
50 */
51struct virtio_console_control {
52 __u32 id; /* Port number */
53 __u16 event; /* The kind of control event (see below) */
54 __u16 value; /* Extra information for the key */
55};
56
57/* Some events for control messages */
58#define VIRTIO_CONSOLE_PORT_READY 0
59#define VIRTIO_CONSOLE_CONSOLE_PORT 1
60#define VIRTIO_CONSOLE_RESIZE 2
61#define VIRTIO_CONSOLE_PORT_OPEN 3
62#define VIRTIO_CONSOLE_PORT_NAME 4
63#define VIRTIO_CONSOLE_PORT_REMOVE 5
64
35/* 65/*
36 * This is a global struct for storing common data for all the devices 66 * This is a global struct for storing common data for all the devices
37 * this driver handles. 67 * this driver handles.
@@ -120,7 +150,7 @@ struct ports_device {
120 spinlock_t cvq_lock; 150 spinlock_t cvq_lock;
121 151
122 /* The current config space is stored here */ 152 /* The current config space is stored here */
123 struct virtio_console_config config; 153 struct virtio_console_multiport_conf config;
124 154
125 /* The virtio device we're associated with */ 155 /* The virtio device we're associated with */
126 struct virtio_device *vdev; 156 struct virtio_device *vdev;
@@ -415,20 +445,16 @@ static ssize_t send_buf(struct port *port, void *in_buf, size_t in_count)
415 out_vq->vq_ops->kick(out_vq); 445 out_vq->vq_ops->kick(out_vq);
416 446
417 if (ret < 0) { 447 if (ret < 0) {
418 len = 0; 448 in_count = 0;
419 goto fail; 449 goto fail;
420 } 450 }
421 451
422 /* 452 /* Wait till the host acknowledges it pushed out the data we sent. */
423 * Wait till the host acknowledges it pushed out the data we
424 * sent. Also ensure we return to userspace the number of
425 * bytes that were successfully consumed by the host.
426 */
427 while (!out_vq->vq_ops->get_buf(out_vq, &len)) 453 while (!out_vq->vq_ops->get_buf(out_vq, &len))
428 cpu_relax(); 454 cpu_relax();
429fail: 455fail:
430 /* We're expected to return the amount of data we wrote */ 456 /* We're expected to return the amount of data we wrote */
431 return len; 457 return in_count;
432} 458}
433 459
434/* 460/*
@@ -645,13 +671,13 @@ static int put_chars(u32 vtermno, const char *buf, int count)
645{ 671{
646 struct port *port; 672 struct port *port;
647 673
674 if (unlikely(early_put_chars))
675 return early_put_chars(vtermno, buf, count);
676
648 port = find_port_by_vtermno(vtermno); 677 port = find_port_by_vtermno(vtermno);
649 if (!port) 678 if (!port)
650 return 0; 679 return 0;
651 680
652 if (unlikely(early_put_chars))
653 return early_put_chars(vtermno, buf, count);
654
655 return send_buf(port, (void *)buf, count); 681 return send_buf(port, (void *)buf, count);
656} 682}
657 683
@@ -681,6 +707,10 @@ static void resize_console(struct port *port)
681 struct virtio_device *vdev; 707 struct virtio_device *vdev;
682 struct winsize ws; 708 struct winsize ws;
683 709
710 /* The port could have been hot-unplugged */
711 if (!port)
712 return;
713
684 vdev = port->portdev->vdev; 714 vdev = port->portdev->vdev;
685 if (virtio_has_feature(vdev, VIRTIO_CONSOLE_F_SIZE)) { 715 if (virtio_has_feature(vdev, VIRTIO_CONSOLE_F_SIZE)) {
686 vdev->config->get(vdev, 716 vdev->config->get(vdev,
@@ -947,11 +977,18 @@ static void handle_control_message(struct ports_device *portdev,
947 */ 977 */
948 err = sysfs_create_group(&port->dev->kobj, 978 err = sysfs_create_group(&port->dev->kobj,
949 &port_attribute_group); 979 &port_attribute_group);
950 if (err) 980 if (err) {
951 dev_err(port->dev, 981 dev_err(port->dev,
952 "Error %d creating sysfs device attributes\n", 982 "Error %d creating sysfs device attributes\n",
953 err); 983 err);
954 984 } else {
985 /*
986 * Generate a udev event so that appropriate
987 * symlinks can be created based on udev
988 * rules.
989 */
990 kobject_uevent(&port->dev->kobj, KOBJ_CHANGE);
991 }
955 break; 992 break;
956 case VIRTIO_CONSOLE_PORT_REMOVE: 993 case VIRTIO_CONSOLE_PORT_REMOVE:
957 /* 994 /*
@@ -1206,7 +1243,7 @@ fail:
1206 */ 1243 */
1207static void config_work_handler(struct work_struct *work) 1244static void config_work_handler(struct work_struct *work)
1208{ 1245{
1209 struct virtio_console_config virtconconf; 1246 struct virtio_console_multiport_conf virtconconf;
1210 struct ports_device *portdev; 1247 struct ports_device *portdev;
1211 struct virtio_device *vdev; 1248 struct virtio_device *vdev;
1212 int err; 1249 int err;
@@ -1215,7 +1252,8 @@ static void config_work_handler(struct work_struct *work)
1215 1252
1216 vdev = portdev->vdev; 1253 vdev = portdev->vdev;
1217 vdev->config->get(vdev, 1254 vdev->config->get(vdev,
1218 offsetof(struct virtio_console_config, nr_ports), 1255 offsetof(struct virtio_console_multiport_conf,
1256 nr_ports),
1219 &virtconconf.nr_ports, 1257 &virtconconf.nr_ports,
1220 sizeof(virtconconf.nr_ports)); 1258 sizeof(virtconconf.nr_ports));
1221 1259
@@ -1407,16 +1445,19 @@ static int __devinit virtcons_probe(struct virtio_device *vdev)
1407 multiport = false; 1445 multiport = false;
1408 portdev->config.nr_ports = 1; 1446 portdev->config.nr_ports = 1;
1409 portdev->config.max_nr_ports = 1; 1447 portdev->config.max_nr_ports = 1;
1448#if 0 /* Multiport is not quite ready yet --RR */
1410 if (virtio_has_feature(vdev, VIRTIO_CONSOLE_F_MULTIPORT)) { 1449 if (virtio_has_feature(vdev, VIRTIO_CONSOLE_F_MULTIPORT)) {
1411 multiport = true; 1450 multiport = true;
1412 vdev->features[0] |= 1 << VIRTIO_CONSOLE_F_MULTIPORT; 1451 vdev->features[0] |= 1 << VIRTIO_CONSOLE_F_MULTIPORT;
1413 1452
1414 vdev->config->get(vdev, offsetof(struct virtio_console_config, 1453 vdev->config->get(vdev,
1415 nr_ports), 1454 offsetof(struct virtio_console_multiport_conf,
1455 nr_ports),
1416 &portdev->config.nr_ports, 1456 &portdev->config.nr_ports,
1417 sizeof(portdev->config.nr_ports)); 1457 sizeof(portdev->config.nr_ports));
1418 vdev->config->get(vdev, offsetof(struct virtio_console_config, 1458 vdev->config->get(vdev,
1419 max_nr_ports), 1459 offsetof(struct virtio_console_multiport_conf,
1460 max_nr_ports),
1420 &portdev->config.max_nr_ports, 1461 &portdev->config.max_nr_ports,
1421 sizeof(portdev->config.max_nr_ports)); 1462 sizeof(portdev->config.max_nr_ports));
1422 if (portdev->config.nr_ports > portdev->config.max_nr_ports) { 1463 if (portdev->config.nr_ports > portdev->config.max_nr_ports) {
@@ -1432,6 +1473,7 @@ static int __devinit virtcons_probe(struct virtio_device *vdev)
1432 1473
1433 /* Let the Host know we support multiple ports.*/ 1474 /* Let the Host know we support multiple ports.*/
1434 vdev->config->finalize_features(vdev); 1475 vdev->config->finalize_features(vdev);
1476#endif
1435 1477
1436 err = init_vqs(portdev); 1478 err = init_vqs(portdev);
1437 if (err < 0) { 1479 if (err < 0) {
@@ -1514,7 +1556,6 @@ static struct virtio_device_id id_table[] = {
1514 1556
1515static unsigned int features[] = { 1557static unsigned int features[] = {
1516 VIRTIO_CONSOLE_F_SIZE, 1558 VIRTIO_CONSOLE_F_SIZE,
1517 VIRTIO_CONSOLE_F_MULTIPORT,
1518}; 1559};
1519 1560
1520static struct virtio_driver virtio_console = { 1561static struct virtio_driver virtio_console = {
diff --git a/drivers/char/vme_scc.c b/drivers/char/vme_scc.c
index 8b24729fec8..12de1202d22 100644
--- a/drivers/char/vme_scc.c
+++ b/drivers/char/vme_scc.c
@@ -27,7 +27,6 @@
27#include <linux/fcntl.h> 27#include <linux/fcntl.h>
28#include <linux/major.h> 28#include <linux/major.h>
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/slab.h>
31#include <linux/miscdevice.h> 30#include <linux/miscdevice.h>
32#include <linux/console.h> 31#include <linux/console.h>
33#include <linux/init.h> 32#include <linux/init.h>
diff --git a/drivers/char/vt_ioctl.c b/drivers/char/vt_ioctl.c
index 87778dcf872..6aa10284104 100644
--- a/drivers/char/vt_ioctl.c
+++ b/drivers/char/vt_ioctl.c
@@ -888,7 +888,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
888 ret = -EFAULT; 888 ret = -EFAULT;
889 goto out; 889 goto out;
890 } 890 }
891 if (tmp.mode != VT_AUTO && tmp.mode != VT_PROCESS && tmp.mode != VT_PROCESS_AUTO) { 891 if (tmp.mode != VT_AUTO && tmp.mode != VT_PROCESS) {
892 ret = -EINVAL; 892 ret = -EINVAL;
893 goto out; 893 goto out;
894 } 894 }
@@ -1622,7 +1622,7 @@ static void complete_change_console(struct vc_data *vc)
1622 * telling it that it has acquired. Also check if it has died and 1622 * telling it that it has acquired. Also check if it has died and
1623 * clean up (similar to logic employed in change_console()) 1623 * clean up (similar to logic employed in change_console())
1624 */ 1624 */
1625 if (vc->vt_mode.mode == VT_PROCESS || vc->vt_mode.mode == VT_PROCESS_AUTO) { 1625 if (vc->vt_mode.mode == VT_PROCESS) {
1626 /* 1626 /*
1627 * Send the signal as privileged - kill_pid() will 1627 * Send the signal as privileged - kill_pid() will
1628 * tell us if the process has gone or something else 1628 * tell us if the process has gone or something else
@@ -1682,7 +1682,7 @@ void change_console(struct vc_data *new_vc)
1682 * vt to auto control. 1682 * vt to auto control.
1683 */ 1683 */
1684 vc = vc_cons[fg_console].d; 1684 vc = vc_cons[fg_console].d;
1685 if (vc->vt_mode.mode == VT_PROCESS || vc->vt_mode.mode == VT_PROCESS_AUTO) { 1685 if (vc->vt_mode.mode == VT_PROCESS) {
1686 /* 1686 /*
1687 * Send the signal as privileged - kill_pid() will 1687 * Send the signal as privileged - kill_pid() will
1688 * tell us if the process has gone or something else 1688 * tell us if the process has gone or something else
@@ -1693,28 +1693,27 @@ void change_console(struct vc_data *new_vc)
1693 */ 1693 */
1694 vc->vt_newvt = new_vc->vc_num; 1694 vc->vt_newvt = new_vc->vc_num;
1695 if (kill_pid(vc->vt_pid, vc->vt_mode.relsig, 1) == 0) { 1695 if (kill_pid(vc->vt_pid, vc->vt_mode.relsig, 1) == 0) {
1696 if(vc->vt_mode.mode == VT_PROCESS)
1697 /*
1698 * It worked. Mark the vt to switch to and
1699 * return. The process needs to send us a
1700 * VT_RELDISP ioctl to complete the switch.
1701 */
1702 return;
1703 } else {
1704 /* 1696 /*
1705 * The controlling process has died, so we revert back to 1697 * It worked. Mark the vt to switch to and
1706 * normal operation. In this case, we'll also change back 1698 * return. The process needs to send us a
1707 * to KD_TEXT mode. I'm not sure if this is strictly correct 1699 * VT_RELDISP ioctl to complete the switch.
1708 * but it saves the agony when the X server dies and the screen
1709 * remains blanked due to KD_GRAPHICS! It would be nice to do
1710 * this outside of VT_PROCESS but there is no single process
1711 * to account for and tracking tty count may be undesirable.
1712 */ 1700 */
1713 reset_vc(vc); 1701 return;
1714 } 1702 }
1715 1703
1716 /* 1704 /*
1717 * Fall through to normal (VT_AUTO and VT_PROCESS_AUTO) handling of the switch... 1705 * The controlling process has died, so we revert back to
1706 * normal operation. In this case, we'll also change back
1707 * to KD_TEXT mode. I'm not sure if this is strictly correct
1708 * but it saves the agony when the X server dies and the screen
1709 * remains blanked due to KD_GRAPHICS! It would be nice to do
1710 * this outside of VT_PROCESS but there is no single process
1711 * to account for and tracking tty count may be undesirable.
1712 */
1713 reset_vc(vc);
1714
1715 /*
1716 * Fall through to normal (VT_AUTO) handling of the switch...
1718 */ 1717 */
1719 } 1718 }
1720 1719
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
index 4846d50199f..7261b8d9087 100644
--- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c
+++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
@@ -86,6 +86,7 @@
86#include <linux/fs.h> 86#include <linux/fs.h>
87#include <linux/cdev.h> 87#include <linux/cdev.h>
88#include <linux/platform_device.h> 88#include <linux/platform_device.h>
89#include <linux/slab.h>
89 90
90#include <asm/io.h> 91#include <asm/io.h>
91#include <asm/uaccess.h> 92#include <asm/uaccess.h>
diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c
index 578595c4425..744f748cc84 100644
--- a/drivers/clocksource/sh_cmt.c
+++ b/drivers/clocksource/sh_cmt.c
@@ -29,6 +29,7 @@
29#include <linux/clocksource.h> 29#include <linux/clocksource.h>
30#include <linux/clockchips.h> 30#include <linux/clockchips.h>
31#include <linux/sh_timer.h> 31#include <linux/sh_timer.h>
32#include <linux/slab.h>
32 33
33struct sh_cmt_priv { 34struct sh_cmt_priv {
34 void __iomem *mapbase; 35 void __iomem *mapbase;
diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c
index 4c8a759e60c..5fb78bfd73b 100644
--- a/drivers/clocksource/sh_mtu2.c
+++ b/drivers/clocksource/sh_mtu2.c
@@ -29,6 +29,7 @@
29#include <linux/err.h> 29#include <linux/err.h>
30#include <linux/clockchips.h> 30#include <linux/clockchips.h>
31#include <linux/sh_timer.h> 31#include <linux/sh_timer.h>
32#include <linux/slab.h>
32 33
33struct sh_mtu2_priv { 34struct sh_mtu2_priv {
34 void __iomem *mapbase; 35 void __iomem *mapbase;
diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
index 961f5b5ef6a..fc9ff1e5b77 100644
--- a/drivers/clocksource/sh_tmu.c
+++ b/drivers/clocksource/sh_tmu.c
@@ -30,6 +30,7 @@
30#include <linux/clocksource.h> 30#include <linux/clocksource.h>
31#include <linux/clockchips.h> 31#include <linux/clockchips.h>
32#include <linux/sh_timer.h> 32#include <linux/sh_timer.h>
33#include <linux/slab.h>
33 34
34struct sh_tmu_priv { 35struct sh_tmu_priv {
35 void __iomem *mapbase; 36 void __iomem *mapbase;
diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c
index 60697909ebd..a7f046b0096 100644
--- a/drivers/connector/cn_proc.c
+++ b/drivers/connector/cn_proc.c
@@ -27,6 +27,7 @@
27#include <linux/ktime.h> 27#include <linux/ktime.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/connector.h> 29#include <linux/connector.h>
30#include <linux/gfp.h>
30#include <asm/atomic.h> 31#include <asm/atomic.h>
31#include <asm/unaligned.h> 32#include <asm/unaligned.h>
32 33
diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index 537c29ac448..1d48f40342c 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -26,6 +26,7 @@
26#include <linux/netlink.h> 26#include <linux/netlink.h>
27#include <linux/moduleparam.h> 27#include <linux/moduleparam.h>
28#include <linux/connector.h> 28#include <linux/connector.h>
29#include <linux/slab.h>
29#include <linux/mutex.h> 30#include <linux/mutex.h>
30#include <linux/proc_fs.h> 31#include <linux/proc_fs.h>
31#include <linux/spinlock.h> 32#include <linux/spinlock.h>
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 2d5d575e889..75d293eeb3e 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1113,6 +1113,8 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
1113 unsigned int cpu = sys_dev->id; 1113 unsigned int cpu = sys_dev->id;
1114 unsigned long flags; 1114 unsigned long flags;
1115 struct cpufreq_policy *data; 1115 struct cpufreq_policy *data;
1116 struct kobject *kobj;
1117 struct completion *cmp;
1116#ifdef CONFIG_SMP 1118#ifdef CONFIG_SMP
1117 struct sys_device *cpu_sys_dev; 1119 struct sys_device *cpu_sys_dev;
1118 unsigned int j; 1120 unsigned int j;
@@ -1141,10 +1143,11 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
1141 dprintk("removing link\n"); 1143 dprintk("removing link\n");
1142 cpumask_clear_cpu(cpu, data->cpus); 1144 cpumask_clear_cpu(cpu, data->cpus);
1143 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 1145 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
1144 sysfs_remove_link(&sys_dev->kobj, "cpufreq"); 1146 kobj = &sys_dev->kobj;
1145 cpufreq_cpu_put(data); 1147 cpufreq_cpu_put(data);
1146 cpufreq_debug_enable_ratelimit(); 1148 cpufreq_debug_enable_ratelimit();
1147 unlock_policy_rwsem_write(cpu); 1149 unlock_policy_rwsem_write(cpu);
1150 sysfs_remove_link(kobj, "cpufreq");
1148 return 0; 1151 return 0;
1149 } 1152 }
1150#endif 1153#endif
@@ -1181,7 +1184,10 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
1181 data->governor->name, CPUFREQ_NAME_LEN); 1184 data->governor->name, CPUFREQ_NAME_LEN);
1182#endif 1185#endif
1183 cpu_sys_dev = get_cpu_sysdev(j); 1186 cpu_sys_dev = get_cpu_sysdev(j);
1184 sysfs_remove_link(&cpu_sys_dev->kobj, "cpufreq"); 1187 kobj = &cpu_sys_dev->kobj;
1188 unlock_policy_rwsem_write(cpu);
1189 sysfs_remove_link(kobj, "cpufreq");
1190 lock_policy_rwsem_write(cpu);
1185 cpufreq_cpu_put(data); 1191 cpufreq_cpu_put(data);
1186 } 1192 }
1187 } 1193 }
@@ -1192,19 +1198,22 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
1192 if (cpufreq_driver->target) 1198 if (cpufreq_driver->target)
1193 __cpufreq_governor(data, CPUFREQ_GOV_STOP); 1199 __cpufreq_governor(data, CPUFREQ_GOV_STOP);
1194 1200
1195 kobject_put(&data->kobj); 1201 kobj = &data->kobj;
1202 cmp = &data->kobj_unregister;
1203 unlock_policy_rwsem_write(cpu);
1204 kobject_put(kobj);
1196 1205
1197 /* we need to make sure that the underlying kobj is actually 1206 /* we need to make sure that the underlying kobj is actually
1198 * not referenced anymore by anybody before we proceed with 1207 * not referenced anymore by anybody before we proceed with
1199 * unloading. 1208 * unloading.
1200 */ 1209 */
1201 dprintk("waiting for dropping of refcount\n"); 1210 dprintk("waiting for dropping of refcount\n");
1202 wait_for_completion(&data->kobj_unregister); 1211 wait_for_completion(cmp);
1203 dprintk("wait complete\n"); 1212 dprintk("wait complete\n");
1204 1213
1214 lock_policy_rwsem_write(cpu);
1205 if (cpufreq_driver->exit) 1215 if (cpufreq_driver->exit)
1206 cpufreq_driver->exit(data); 1216 cpufreq_driver->exit(data);
1207
1208 unlock_policy_rwsem_write(cpu); 1217 unlock_policy_rwsem_write(cpu);
1209 1218
1210 free_cpumask_var(data->related_cpus); 1219 free_cpumask_var(data->related_cpus);
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c
index 599a40b25cb..3a147874a46 100644
--- a/drivers/cpufreq/cpufreq_conservative.c
+++ b/drivers/cpufreq/cpufreq_conservative.c
@@ -444,6 +444,7 @@ static struct attribute_group dbs_attr_group_old = {
444static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) 444static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
445{ 445{
446 unsigned int load = 0; 446 unsigned int load = 0;
447 unsigned int max_load = 0;
447 unsigned int freq_target; 448 unsigned int freq_target;
448 449
449 struct cpufreq_policy *policy; 450 struct cpufreq_policy *policy;
@@ -501,6 +502,9 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
501 continue; 502 continue;
502 503
503 load = 100 * (wall_time - idle_time) / wall_time; 504 load = 100 * (wall_time - idle_time) / wall_time;
505
506 if (load > max_load)
507 max_load = load;
504 } 508 }
505 509
506 /* 510 /*
@@ -511,7 +515,7 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
511 return; 515 return;
512 516
513 /* Check for frequency increase */ 517 /* Check for frequency increase */
514 if (load > dbs_tuners_ins.up_threshold) { 518 if (max_load > dbs_tuners_ins.up_threshold) {
515 this_dbs_info->down_skip = 0; 519 this_dbs_info->down_skip = 0;
516 520
517 /* if we are already at full speed then break out early */ 521 /* if we are already at full speed then break out early */
@@ -538,7 +542,7 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
538 * can support the current CPU usage without triggering the up 542 * can support the current CPU usage without triggering the up
539 * policy. To be safe, we focus 10 points under the threshold. 543 * policy. To be safe, we focus 10 points under the threshold.
540 */ 544 */
541 if (load < (dbs_tuners_ins.down_threshold - 10)) { 545 if (max_load < (dbs_tuners_ins.down_threshold - 10)) {
542 freq_target = (dbs_tuners_ins.freq_step * policy->max) / 100; 546 freq_target = (dbs_tuners_ins.freq_step * policy->max) / 100;
543 547
544 this_dbs_info->requested_freq -= freq_target; 548 this_dbs_info->requested_freq -= freq_target;
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index 5a62d678dd1..00d73fc8e4e 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -10,6 +10,7 @@
10 */ 10 */
11 11
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/slab.h>
13#include <linux/sysdev.h> 14#include <linux/sysdev.h>
14#include <linux/cpu.h> 15#include <linux/cpu.h>
15#include <linux/sysfs.h> 16#include <linux/sysfs.h>
diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index 1aea7157d8f..f8e57c6303f 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -100,7 +100,6 @@ struct menu_device {
100 int needs_update; 100 int needs_update;
101 101
102 unsigned int expected_us; 102 unsigned int expected_us;
103 unsigned int measured_us;
104 u64 predicted_us; 103 u64 predicted_us;
105 unsigned int exit_us; 104 unsigned int exit_us;
106 unsigned int bucket; 105 unsigned int bucket;
@@ -187,14 +186,14 @@ static int menu_select(struct cpuidle_device *dev)
187 int i; 186 int i;
188 int multiplier; 187 int multiplier;
189 188
190 data->last_state_idx = 0;
191 data->exit_us = 0;
192
193 if (data->needs_update) { 189 if (data->needs_update) {
194 menu_update(dev); 190 menu_update(dev);
195 data->needs_update = 0; 191 data->needs_update = 0;
196 } 192 }
197 193
194 data->last_state_idx = 0;
195 data->exit_us = 0;
196
198 /* Special case when user has set very strict latency requirement */ 197 /* Special case when user has set very strict latency requirement */
199 if (unlikely(latency_req == 0)) 198 if (unlikely(latency_req == 0))
200 return 0; 199 return 0;
@@ -294,7 +293,7 @@ static void menu_update(struct cpuidle_device *dev)
294 new_factor = data->correction_factor[data->bucket] 293 new_factor = data->correction_factor[data->bucket]
295 * (DECAY - 1) / DECAY; 294 * (DECAY - 1) / DECAY;
296 295
297 if (data->expected_us > 0 && data->measured_us < MAX_INTERESTING) 296 if (data->expected_us > 0 && measured_us < MAX_INTERESTING)
298 new_factor += RESOLUTION * measured_us / data->expected_us; 297 new_factor += RESOLUTION * measured_us / data->expected_us;
299 else 298 else
300 /* 299 /*
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
index 8719b36e1a4..0ba9c8b8ee7 100644
--- a/drivers/cpuidle/sysfs.c
+++ b/drivers/cpuidle/sysfs.c
@@ -9,6 +9,7 @@
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/cpuidle.h> 10#include <linux/cpuidle.h>
11#include <linux/sysfs.h> 11#include <linux/sysfs.h>
12#include <linux/slab.h>
12#include <linux/cpu.h> 13#include <linux/cpu.h>
13 14
14#include "cpuidle.h" 15#include "cpuidle.h"
diff --git a/drivers/crypto/amcc/crypto4xx_core.c b/drivers/crypto/amcc/crypto4xx_core.c
index 1c3849f6b7a..6c4c8b7ce3a 100644
--- a/drivers/crypto/amcc/crypto4xx_core.c
+++ b/drivers/crypto/amcc/crypto4xx_core.c
@@ -28,6 +28,7 @@
28#include <linux/platform_device.h> 28#include <linux/platform_device.h>
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/of_platform.h> 30#include <linux/of_platform.h>
31#include <linux/slab.h>
31#include <asm/dcr.h> 32#include <asm/dcr.h>
32#include <asm/dcr-regs.h> 33#include <asm/dcr-regs.h>
33#include <asm/cacheflush.h> 34#include <asm/cacheflush.h>
diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c
index 6c6656d3b1e..f17ddf37a1e 100644
--- a/drivers/crypto/ixp4xx_crypto.c
+++ b/drivers/crypto/ixp4xx_crypto.c
@@ -17,6 +17,7 @@
17#include <linux/rtnetlink.h> 17#include <linux/rtnetlink.h>
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/spinlock.h> 19#include <linux/spinlock.h>
20#include <linux/gfp.h>
20 21
21#include <crypto/ctr.h> 22#include <crypto/ctr.h>
22#include <crypto/des.h> 23#include <crypto/des.h>
diff --git a/drivers/crypto/mv_cesa.c b/drivers/crypto/mv_cesa.c
index b21ef635f35..6f29012bcc4 100644
--- a/drivers/crypto/mv_cesa.c
+++ b/drivers/crypto/mv_cesa.c
@@ -14,6 +14,7 @@
14#include <linux/kthread.h> 14#include <linux/kthread.h>
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/scatterlist.h> 16#include <linux/scatterlist.h>
17#include <linux/slab.h>
17 18
18#include "mv_cesa.h" 19#include "mv_cesa.h"
19/* 20/*
diff --git a/drivers/crypto/padlock-aes.c b/drivers/crypto/padlock-aes.c
index 8c2f3703ec8..2e992bc8015 100644
--- a/drivers/crypto/padlock-aes.c
+++ b/drivers/crypto/padlock-aes.c
@@ -17,6 +17,7 @@
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/percpu.h> 18#include <linux/percpu.h>
19#include <linux/smp.h> 19#include <linux/smp.h>
20#include <linux/slab.h>
20#include <asm/byteorder.h> 21#include <asm/byteorder.h>
21#include <asm/processor.h> 22#include <asm/processor.h>
22#include <asm/i387.h> 23#include <asm/i387.h>
diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
index fd529d68c5b..dc558a09731 100644
--- a/drivers/crypto/talitos.c
+++ b/drivers/crypto/talitos.c
@@ -37,6 +37,7 @@
37#include <linux/io.h> 37#include <linux/io.h>
38#include <linux/spinlock.h> 38#include <linux/spinlock.h>
39#include <linux/rtnetlink.h> 39#include <linux/rtnetlink.h>
40#include <linux/slab.h>
40 41
41#include <crypto/algapi.h> 42#include <crypto/algapi.h>
42#include <crypto/aes.h> 43#include <crypto/aes.h>
diff --git a/drivers/dca/dca-core.c b/drivers/dca/dca-core.c
index 52e6bb70a49..8661c84a105 100644
--- a/drivers/dca/dca-core.c
+++ b/drivers/dca/dca-core.c
@@ -27,6 +27,7 @@
27#include <linux/notifier.h> 27#include <linux/notifier.h>
28#include <linux/device.h> 28#include <linux/device.h>
29#include <linux/dca.h> 29#include <linux/dca.h>
30#include <linux/slab.h>
30 31
31#define DCA_VERSION "1.12.1" 32#define DCA_VERSION "1.12.1"
32 33
diff --git a/drivers/dca/dca-sysfs.c b/drivers/dca/dca-sysfs.c
index ee916c9857e..5e8f335e6f6 100644
--- a/drivers/dca/dca-sysfs.c
+++ b/drivers/dca/dca-sysfs.c
@@ -26,6 +26,7 @@
26#include <linux/kdev_t.h> 26#include <linux/kdev_t.h>
27#include <linux/err.h> 27#include <linux/err.h>
28#include <linux/dca.h> 28#include <linux/dca.h>
29#include <linux/gfp.h>
29 30
30static struct class *dca_class; 31static struct class *dca_class;
31static struct idr dca_idr; 32static struct idr dca_idr;
diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
index efc1a61ca23..278cf5bceef 100644
--- a/drivers/dma/at_hdmac.c
+++ b/drivers/dma/at_hdmac.c
@@ -22,6 +22,7 @@
22#include <linux/interrupt.h> 22#include <linux/interrupt.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/slab.h>
25 26
26#include "at_hdmac_regs.h" 27#include "at_hdmac_regs.h"
27 28
diff --git a/drivers/dma/coh901318_lli.c b/drivers/dma/coh901318_lli.c
index 71d58c1a1e8..9f7e0e6a7ee 100644
--- a/drivers/dma/coh901318_lli.c
+++ b/drivers/dma/coh901318_lli.c
@@ -11,6 +11,7 @@
11#include <linux/spinlock.h> 11#include <linux/spinlock.h>
12#include <linux/dmapool.h> 12#include <linux/dmapool.h>
13#include <linux/memory.h> 13#include <linux/memory.h>
14#include <linux/gfp.h>
14#include <mach/coh901318.h> 15#include <mach/coh901318.h>
15 16
16#include "coh901318_lli.h" 17#include "coh901318_lli.h"
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index 87399cafce3..d18b5d069d7 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -58,6 +58,7 @@
58#include <linux/jiffies.h> 58#include <linux/jiffies.h>
59#include <linux/rculist.h> 59#include <linux/rculist.h>
60#include <linux/idr.h> 60#include <linux/idr.h>
61#include <linux/slab.h>
61 62
62static DEFINE_MUTEX(dma_list_mutex); 63static DEFINE_MUTEX(dma_list_mutex);
63static LIST_HEAD(dma_device_list); 64static LIST_HEAD(dma_device_list);
diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
index 6fa55fe3dd2..68d58c414cf 100644
--- a/drivers/dma/dmatest.c
+++ b/drivers/dma/dmatest.c
@@ -14,6 +14,7 @@
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/moduleparam.h> 15#include <linux/moduleparam.h>
16#include <linux/random.h> 16#include <linux/random.h>
17#include <linux/slab.h>
17#include <linux/wait.h> 18#include <linux/wait.h>
18 19
19static unsigned int test_buf_size = 16384; 20static unsigned int test_buf_size = 16384;
diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c
index bbb4be5a3ff..88f470f0d82 100644
--- a/drivers/dma/fsldma.c
+++ b/drivers/dma/fsldma.c
@@ -27,6 +27,7 @@
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/pci.h> 29#include <linux/pci.h>
30#include <linux/slab.h>
30#include <linux/interrupt.h> 31#include <linux/interrupt.h>
31#include <linux/dmaengine.h> 32#include <linux/dmaengine.h>
32#include <linux/delay.h> 33#include <linux/delay.h>
diff --git a/drivers/dma/ioat/dma.c b/drivers/dma/ioat/dma.c
index 0099340b961..3e5a8005c62 100644
--- a/drivers/dma/ioat/dma.c
+++ b/drivers/dma/ioat/dma.c
@@ -27,6 +27,7 @@
27 27
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/slab.h>
30#include <linux/pci.h> 31#include <linux/pci.h>
31#include <linux/interrupt.h> 32#include <linux/interrupt.h>
32#include <linux/dmaengine.h> 33#include <linux/dmaengine.h>
diff --git a/drivers/dma/ioat/dma_v2.c b/drivers/dma/ioat/dma_v2.c
index 1ed5d66d7dc..b5ae56c211e 100644
--- a/drivers/dma/ioat/dma_v2.c
+++ b/drivers/dma/ioat/dma_v2.c
@@ -27,6 +27,7 @@
27 27
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/slab.h>
30#include <linux/pci.h> 31#include <linux/pci.h>
31#include <linux/interrupt.h> 32#include <linux/interrupt.h>
32#include <linux/dmaengine.h> 33#include <linux/dmaengine.h>
diff --git a/drivers/dma/ioat/dma_v3.c b/drivers/dma/ioat/dma_v3.c
index 26febc56dab..6740e319c9c 100644
--- a/drivers/dma/ioat/dma_v3.c
+++ b/drivers/dma/ioat/dma_v3.c
@@ -57,6 +57,7 @@
57 */ 57 */
58 58
59#include <linux/pci.h> 59#include <linux/pci.h>
60#include <linux/gfp.h>
60#include <linux/dmaengine.h> 61#include <linux/dmaengine.h>
61#include <linux/dma-mapping.h> 62#include <linux/dma-mapping.h>
62#include "registers.h" 63#include "registers.h"
diff --git a/drivers/dma/ioat/pci.c b/drivers/dma/ioat/pci.c
index d545fae30f3..99ec26725ba 100644
--- a/drivers/dma/ioat/pci.c
+++ b/drivers/dma/ioat/pci.c
@@ -30,6 +30,7 @@
30#include <linux/pci.h> 30#include <linux/pci.h>
31#include <linux/interrupt.h> 31#include <linux/interrupt.h>
32#include <linux/dca.h> 32#include <linux/dca.h>
33#include <linux/slab.h>
33#include "dma.h" 34#include "dma.h"
34#include "dma_v2.h" 35#include "dma_v2.h"
35#include "registers.h" 36#include "registers.h"
diff --git a/drivers/dma/iop-adma.c b/drivers/dma/iop-adma.c
index ca6e6a0cb79..1ebc801678b 100644
--- a/drivers/dma/iop-adma.c
+++ b/drivers/dma/iop-adma.c
@@ -32,6 +32,7 @@
32#include <linux/memory.h> 32#include <linux/memory.h>
33#include <linux/ioport.h> 33#include <linux/ioport.h>
34#include <linux/raid/pq.h> 34#include <linux/raid/pq.h>
35#include <linux/slab.h>
35 36
36#include <mach/adma.h> 37#include <mach/adma.h>
37 38
diff --git a/drivers/dma/iovlock.c b/drivers/dma/iovlock.c
index c0a272c7368..bb48a57c2fc 100644
--- a/drivers/dma/iovlock.c
+++ b/drivers/dma/iovlock.c
@@ -27,6 +27,7 @@
27 27
28#include <linux/dmaengine.h> 28#include <linux/dmaengine.h>
29#include <linux/pagemap.h> 29#include <linux/pagemap.h>
30#include <linux/slab.h>
30#include <net/tcp.h> /* for memcpy_toiovec */ 31#include <net/tcp.h> /* for memcpy_toiovec */
31#include <asm/io.h> 32#include <asm/io.h>
32#include <asm/uaccess.h> 33#include <asm/uaccess.h>
diff --git a/drivers/dma/mpc512x_dma.c b/drivers/dma/mpc512x_dma.c
index 3fdf1f46bd6..bbbd5856662 100644
--- a/drivers/dma/mpc512x_dma.c
+++ b/drivers/dma/mpc512x_dma.c
@@ -37,6 +37,7 @@
37#include <linux/dma-mapping.h> 37#include <linux/dma-mapping.h>
38#include <linux/interrupt.h> 38#include <linux/interrupt.h>
39#include <linux/io.h> 39#include <linux/io.h>
40#include <linux/slab.h>
40#include <linux/of_device.h> 41#include <linux/of_device.h>
41#include <linux/of_platform.h> 42#include <linux/of_platform.h>
42 43
diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c
index 466ab10c1ff..e2fd34da64f 100644
--- a/drivers/dma/mv_xor.c
+++ b/drivers/dma/mv_xor.c
@@ -18,6 +18,7 @@
18 18
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/slab.h>
21#include <linux/delay.h> 22#include <linux/delay.h>
22#include <linux/dma-mapping.h> 23#include <linux/dma-mapping.h>
23#include <linux/spinlock.h> 24#include <linux/spinlock.h>
diff --git a/drivers/dma/ppc4xx/adma.c b/drivers/dma/ppc4xx/adma.c
index e69d87f24a2..d44626fa35a 100644
--- a/drivers/dma/ppc4xx/adma.c
+++ b/drivers/dma/ppc4xx/adma.c
@@ -38,6 +38,7 @@
38#include <linux/dma-mapping.h> 38#include <linux/dma-mapping.h>
39#include <linux/spinlock.h> 39#include <linux/spinlock.h>
40#include <linux/interrupt.h> 40#include <linux/interrupt.h>
41#include <linux/slab.h>
41#include <linux/uaccess.h> 42#include <linux/uaccess.h>
42#include <linux/proc_fs.h> 43#include <linux/proc_fs.h>
43#include <linux/of.h> 44#include <linux/of.h>
diff --git a/drivers/dma/shdma.c b/drivers/dma/shdma.c
index 5d17e09cb62..6f25a20de99 100644
--- a/drivers/dma/shdma.c
+++ b/drivers/dma/shdma.c
@@ -19,6 +19,7 @@
19 19
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/slab.h>
22#include <linux/interrupt.h> 23#include <linux/interrupt.h>
23#include <linux/dmaengine.h> 24#include <linux/dmaengine.h>
24#include <linux/delay.h> 25#include <linux/delay.h>
@@ -289,6 +290,7 @@ static int sh_dmae_alloc_chan_resources(struct dma_chan *chan)
289 struct sh_dmae_chan *sh_chan = to_sh_chan(chan); 290 struct sh_dmae_chan *sh_chan = to_sh_chan(chan);
290 struct sh_desc *desc; 291 struct sh_desc *desc;
291 struct sh_dmae_slave *param = chan->private; 292 struct sh_dmae_slave *param = chan->private;
293 int ret;
292 294
293 pm_runtime_get_sync(sh_chan->dev); 295 pm_runtime_get_sync(sh_chan->dev);
294 296
@@ -300,11 +302,15 @@ static int sh_dmae_alloc_chan_resources(struct dma_chan *chan)
300 struct sh_dmae_slave_config *cfg; 302 struct sh_dmae_slave_config *cfg;
301 303
302 cfg = sh_dmae_find_slave(sh_chan, param->slave_id); 304 cfg = sh_dmae_find_slave(sh_chan, param->slave_id);
303 if (!cfg) 305 if (!cfg) {
304 return -EINVAL; 306 ret = -EINVAL;
307 goto efindslave;
308 }
305 309
306 if (test_and_set_bit(param->slave_id, sh_dmae_slave_used)) 310 if (test_and_set_bit(param->slave_id, sh_dmae_slave_used)) {
307 return -EBUSY; 311 ret = -EBUSY;
312 goto etestused;
313 }
308 314
309 param->config = cfg; 315 param->config = cfg;
310 316
@@ -333,10 +339,20 @@ static int sh_dmae_alloc_chan_resources(struct dma_chan *chan)
333 } 339 }
334 spin_unlock_bh(&sh_chan->desc_lock); 340 spin_unlock_bh(&sh_chan->desc_lock);
335 341
336 if (!sh_chan->descs_allocated) 342 if (!sh_chan->descs_allocated) {
337 pm_runtime_put(sh_chan->dev); 343 ret = -ENOMEM;
344 goto edescalloc;
345 }
338 346
339 return sh_chan->descs_allocated; 347 return sh_chan->descs_allocated;
348
349edescalloc:
350 if (param)
351 clear_bit(param->slave_id, sh_dmae_slave_used);
352etestused:
353efindslave:
354 pm_runtime_put(sh_chan->dev);
355 return ret;
340} 356}
341 357
342/* 358/*
diff --git a/drivers/dma/txx9dmac.c b/drivers/dma/txx9dmac.c
index 3ebc61067e5..75fcf1ac8bb 100644
--- a/drivers/dma/txx9dmac.c
+++ b/drivers/dma/txx9dmac.c
@@ -1359,3 +1359,5 @@ module_exit(txx9dmac_exit);
1359MODULE_LICENSE("GPL"); 1359MODULE_LICENSE("GPL");
1360MODULE_DESCRIPTION("TXx9 DMA Controller driver"); 1360MODULE_DESCRIPTION("TXx9 DMA Controller driver");
1361MODULE_AUTHOR("Atsushi Nemoto <anemo@mba.ocn.ne.jp>"); 1361MODULE_AUTHOR("Atsushi Nemoto <anemo@mba.ocn.ne.jp>");
1362MODULE_ALIAS("platform:txx9dmac");
1363MODULE_ALIAS("platform:txx9dmac-chan");
diff --git a/drivers/edac/amd76x_edac.c b/drivers/edac/amd76x_edac.c
index 2b95f1a3edf..f2330f81cb5 100644
--- a/drivers/edac/amd76x_edac.c
+++ b/drivers/edac/amd76x_edac.c
@@ -16,7 +16,6 @@
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/pci.h> 17#include <linux/pci.h>
18#include <linux/pci_ids.h> 18#include <linux/pci_ids.h>
19#include <linux/slab.h>
20#include <linux/edac.h> 19#include <linux/edac.h>
21#include "edac_core.h" 20#include "edac_core.h"
22 21
diff --git a/drivers/edac/cpc925_edac.c b/drivers/edac/cpc925_edac.c
index 3d50274f134..1609a19df49 100644
--- a/drivers/edac/cpc925_edac.c
+++ b/drivers/edac/cpc925_edac.c
@@ -25,6 +25,7 @@
25#include <linux/edac.h> 25#include <linux/edac.h>
26#include <linux/of.h> 26#include <linux/of.h>
27#include <linux/platform_device.h> 27#include <linux/platform_device.h>
28#include <linux/gfp.h>
28 29
29#include "edac_core.h" 30#include "edac_core.h"
30#include "edac_module.h" 31#include "edac_module.h"
diff --git a/drivers/edac/e752x_edac.c b/drivers/edac/e752x_edac.c
index 243e9aacad6..ae3f80c5419 100644
--- a/drivers/edac/e752x_edac.c
+++ b/drivers/edac/e752x_edac.c
@@ -21,7 +21,6 @@
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/pci.h> 22#include <linux/pci.h>
23#include <linux/pci_ids.h> 23#include <linux/pci_ids.h>
24#include <linux/slab.h>
25#include <linux/edac.h> 24#include <linux/edac.h>
26#include "edac_core.h" 25#include "edac_core.h"
27 26
diff --git a/drivers/edac/e7xxx_edac.c b/drivers/edac/e7xxx_edac.c
index c7d11cc4e21..1731d724581 100644
--- a/drivers/edac/e7xxx_edac.c
+++ b/drivers/edac/e7xxx_edac.c
@@ -26,7 +26,6 @@
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/pci.h> 27#include <linux/pci.h>
28#include <linux/pci_ids.h> 28#include <linux/pci_ids.h>
29#include <linux/slab.h>
30#include <linux/edac.h> 29#include <linux/edac.h>
31#include "edac_core.h" 30#include "edac_core.h"
32 31
diff --git a/drivers/edac/edac_device_sysfs.c b/drivers/edac/edac_device_sysfs.c
index 5fdedbc0f54..070968178a2 100644
--- a/drivers/edac/edac_device_sysfs.c
+++ b/drivers/edac/edac_device_sysfs.c
@@ -12,6 +12,7 @@
12 12
13#include <linux/ctype.h> 13#include <linux/ctype.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/slab.h>
15 16
16#include "edac_core.h" 17#include "edac_core.h"
17#include "edac_module.h" 18#include "edac_module.h"
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index 88840e9fa3e..418b65f1a1d 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -10,6 +10,7 @@
10 */ 10 */
11 11
12#include <linux/ctype.h> 12#include <linux/ctype.h>
13#include <linux/slab.h>
13#include <linux/bug.h> 14#include <linux/bug.h>
14 15
15#include "edac_core.h" 16#include "edac_core.h"
diff --git a/drivers/edac/edac_mce_amd.c b/drivers/edac/edac_mce_amd.c
index 8fc91a01962..97e64bcdbc0 100644
--- a/drivers/edac/edac_mce_amd.c
+++ b/drivers/edac/edac_mce_amd.c
@@ -294,7 +294,6 @@ wrong_ls_mce:
294void amd_decode_nb_mce(int node_id, struct err_regs *regs, int handle_errors) 294void amd_decode_nb_mce(int node_id, struct err_regs *regs, int handle_errors)
295{ 295{
296 u32 ec = ERROR_CODE(regs->nbsl); 296 u32 ec = ERROR_CODE(regs->nbsl);
297 u32 xec = EXT_ERROR_CODE(regs->nbsl);
298 297
299 if (!handle_errors) 298 if (!handle_errors)
300 return; 299 return;
@@ -316,10 +315,15 @@ void amd_decode_nb_mce(int node_id, struct err_regs *regs, int handle_errors)
316 if (regs->nbsh & K8_NBSH_ERR_CPU_VAL) 315 if (regs->nbsh & K8_NBSH_ERR_CPU_VAL)
317 pr_cont(", core: %u\n", (u8)(regs->nbsh & 0xf)); 316 pr_cont(", core: %u\n", (u8)(regs->nbsh & 0xf));
318 } else { 317 } else {
319 pr_cont(", core: %d\n", fls((regs->nbsh & 0xf) - 1)); 318 u8 assoc_cpus = regs->nbsh & 0xf;
319
320 if (assoc_cpus > 0)
321 pr_cont(", core: %d", fls(assoc_cpus) - 1);
322
323 pr_cont("\n");
320 } 324 }
321 325
322 pr_emerg("%s.\n", EXT_ERR_MSG(xec)); 326 pr_emerg("%s.\n", EXT_ERR_MSG(regs->nbsl));
323 327
324 if (BUS_ERROR(ec) && nb_bus_decoder) 328 if (BUS_ERROR(ec) && nb_bus_decoder)
325 nb_bus_decoder(node_id, regs); 329 nb_bus_decoder(node_id, regs);
@@ -369,7 +373,7 @@ static int amd_decode_mce(struct notifier_block *nb, unsigned long val,
369 ((m->status & MCI_STATUS_PCC) ? "yes" : "no")); 373 ((m->status & MCI_STATUS_PCC) ? "yes" : "no"));
370 374
371 /* do the two bits[14:13] together */ 375 /* do the two bits[14:13] together */
372 ecc = m->status & (3ULL << 45); 376 ecc = (m->status >> 45) & 0x3;
373 if (ecc) 377 if (ecc)
374 pr_cont(", %sECC Error", ((ecc == 2) ? "C" : "U")); 378 pr_cont(", %sECC Error", ((ecc == 2) ? "C" : "U"));
375 379
diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
index bef94e3d994..c39697df9cb 100644
--- a/drivers/edac/edac_pci_sysfs.c
+++ b/drivers/edac/edac_pci_sysfs.c
@@ -8,6 +8,7 @@
8 */ 8 */
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/sysdev.h> 10#include <linux/sysdev.h>
11#include <linux/slab.h>
11#include <linux/ctype.h> 12#include <linux/ctype.h>
12 13
13#include "edac_core.h" 14#include "edac_core.h"
diff --git a/drivers/edac/i3000_edac.c b/drivers/edac/i3000_edac.c
index 6c9a0f2a593..c0510b3d703 100644
--- a/drivers/edac/i3000_edac.c
+++ b/drivers/edac/i3000_edac.c
@@ -13,7 +13,6 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/pci.h> 14#include <linux/pci.h>
15#include <linux/pci_ids.h> 15#include <linux/pci_ids.h>
16#include <linux/slab.h>
17#include <linux/edac.h> 16#include <linux/edac.h>
18#include "edac_core.h" 17#include "edac_core.h"
19 18
diff --git a/drivers/edac/i3200_edac.c b/drivers/edac/i3200_edac.c
index fde4db91c4d..d41f9002da4 100644
--- a/drivers/edac/i3200_edac.c
+++ b/drivers/edac/i3200_edac.c
@@ -11,7 +11,6 @@
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/pci.h> 12#include <linux/pci.h>
13#include <linux/pci_ids.h> 13#include <linux/pci_ids.h>
14#include <linux/slab.h>
15#include <linux/edac.h> 14#include <linux/edac.h>
16#include <linux/io.h> 15#include <linux/io.h>
17#include "edac_core.h" 16#include "edac_core.h"
diff --git a/drivers/edac/i5100_edac.c b/drivers/edac/i5100_edac.c
index 7785d8ffa40..ee9753cf362 100644
--- a/drivers/edac/i5100_edac.c
+++ b/drivers/edac/i5100_edac.c
@@ -19,7 +19,6 @@
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/pci.h> 20#include <linux/pci.h>
21#include <linux/pci_ids.h> 21#include <linux/pci_ids.h>
22#include <linux/slab.h>
23#include <linux/edac.h> 22#include <linux/edac.h>
24#include <linux/delay.h> 23#include <linux/delay.h>
25#include <linux/mmzone.h> 24#include <linux/mmzone.h>
diff --git a/drivers/edac/i82443bxgx_edac.c b/drivers/edac/i82443bxgx_edac.c
index 577760a82a0..7f3884fcbd4 100644
--- a/drivers/edac/i82443bxgx_edac.c
+++ b/drivers/edac/i82443bxgx_edac.c
@@ -27,7 +27,6 @@
27#include <linux/pci.h> 27#include <linux/pci.h>
28#include <linux/pci_ids.h> 28#include <linux/pci_ids.h>
29 29
30#include <linux/slab.h>
31 30
32#include <linux/edac.h> 31#include <linux/edac.h>
33#include "edac_core.h" 32#include "edac_core.h"
diff --git a/drivers/edac/i82860_edac.c b/drivers/edac/i82860_edac.c
index c0088ba9672..b8a95cf5071 100644
--- a/drivers/edac/i82860_edac.c
+++ b/drivers/edac/i82860_edac.c
@@ -13,7 +13,6 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/pci.h> 14#include <linux/pci.h>
15#include <linux/pci_ids.h> 15#include <linux/pci_ids.h>
16#include <linux/slab.h>
17#include <linux/edac.h> 16#include <linux/edac.h>
18#include "edac_core.h" 17#include "edac_core.h"
19 18
diff --git a/drivers/edac/i82875p_edac.c b/drivers/edac/i82875p_edac.c
index b2d83b95033..b2fd1e89914 100644
--- a/drivers/edac/i82875p_edac.c
+++ b/drivers/edac/i82875p_edac.c
@@ -17,7 +17,6 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/pci.h> 18#include <linux/pci.h>
19#include <linux/pci_ids.h> 19#include <linux/pci_ids.h>
20#include <linux/slab.h>
21#include <linux/edac.h> 20#include <linux/edac.h>
22#include "edac_core.h" 21#include "edac_core.h"
23 22
diff --git a/drivers/edac/i82975x_edac.c b/drivers/edac/i82975x_edac.c
index 2eed3ea2cf6..3218819b728 100644
--- a/drivers/edac/i82975x_edac.c
+++ b/drivers/edac/i82975x_edac.c
@@ -13,7 +13,6 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/pci.h> 14#include <linux/pci.h>
15#include <linux/pci_ids.h> 15#include <linux/pci_ids.h>
16#include <linux/slab.h>
17#include <linux/edac.h> 16#include <linux/edac.h>
18#include "edac_core.h" 17#include "edac_core.h"
19 18
diff --git a/drivers/edac/mpc85xx_edac.c b/drivers/edac/mpc85xx_edac.c
index 94cac0aacea..4471647b480 100644
--- a/drivers/edac/mpc85xx_edac.c
+++ b/drivers/edac/mpc85xx_edac.c
@@ -11,13 +11,13 @@
11 */ 11 */
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/slab.h>
15#include <linux/interrupt.h> 14#include <linux/interrupt.h>
16#include <linux/ctype.h> 15#include <linux/ctype.h>
17#include <linux/io.h> 16#include <linux/io.h>
18#include <linux/mod_devicetable.h> 17#include <linux/mod_devicetable.h>
19#include <linux/edac.h> 18#include <linux/edac.h>
20#include <linux/smp.h> 19#include <linux/smp.h>
20#include <linux/gfp.h>
21 21
22#include <linux/of_platform.h> 22#include <linux/of_platform.h>
23#include <linux/of_device.h> 23#include <linux/of_device.h>
diff --git a/drivers/edac/mv64x60_edac.c b/drivers/edac/mv64x60_edac.c
index a6b9fec13a7..7e5ff367705 100644
--- a/drivers/edac/mv64x60_edac.c
+++ b/drivers/edac/mv64x60_edac.c
@@ -12,10 +12,10 @@
12 12
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/slab.h>
16#include <linux/interrupt.h> 15#include <linux/interrupt.h>
17#include <linux/io.h> 16#include <linux/io.h>
18#include <linux/edac.h> 17#include <linux/edac.h>
18#include <linux/gfp.h>
19 19
20#include "edac_core.h" 20#include "edac_core.h"
21#include "edac_module.h" 21#include "edac_module.h"
diff --git a/drivers/edac/pasemi_edac.c b/drivers/edac/pasemi_edac.c
index 8e6b91bd2e9..7f71ee43674 100644
--- a/drivers/edac/pasemi_edac.c
+++ b/drivers/edac/pasemi_edac.c
@@ -25,7 +25,6 @@
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/pci.h> 26#include <linux/pci.h>
27#include <linux/pci_ids.h> 27#include <linux/pci_ids.h>
28#include <linux/slab.h>
29#include <linux/edac.h> 28#include <linux/edac.h>
30#include "edac_core.h" 29#include "edac_core.h"
31 30
diff --git a/drivers/edac/r82600_edac.c b/drivers/edac/r82600_edac.c
index 9900675e959..d55f8e9de78 100644
--- a/drivers/edac/r82600_edac.c
+++ b/drivers/edac/r82600_edac.c
@@ -19,7 +19,6 @@
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/pci.h> 20#include <linux/pci.h>
21#include <linux/pci_ids.h> 21#include <linux/pci_ids.h>
22#include <linux/slab.h>
23#include <linux/edac.h> 22#include <linux/edac.h>
24#include "edac_core.h" 23#include "edac_core.h"
25 24
diff --git a/drivers/edac/x38_edac.c b/drivers/edac/x38_edac.c
index d4ec6059317..b6f47de152f 100644
--- a/drivers/edac/x38_edac.c
+++ b/drivers/edac/x38_edac.c
@@ -13,7 +13,6 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/pci.h> 14#include <linux/pci.h>
15#include <linux/pci_ids.h> 15#include <linux/pci_ids.h>
16#include <linux/slab.h>
17#include <linux/edac.h> 16#include <linux/edac.h>
18#include "edac_core.h" 17#include "edac_core.h"
19 18
diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
index 8be720b278b..14a34d99eea 100644
--- a/drivers/firewire/core-cdev.c
+++ b/drivers/firewire/core-cdev.c
@@ -34,6 +34,7 @@
34#include <linux/mutex.h> 34#include <linux/mutex.h>
35#include <linux/poll.h> 35#include <linux/poll.h>
36#include <linux/sched.h> 36#include <linux/sched.h>
37#include <linux/slab.h>
37#include <linux/spinlock.h> 38#include <linux/spinlock.h>
38#include <linux/string.h> 39#include <linux/string.h>
39#include <linux/time.h> 40#include <linux/time.h>
@@ -959,6 +960,8 @@ static int ioctl_queue_iso(struct client *client, union ioctl_arg *arg)
959 u.packet.header_length = GET_HEADER_LENGTH(control); 960 u.packet.header_length = GET_HEADER_LENGTH(control);
960 961
961 if (ctx->type == FW_ISO_CONTEXT_TRANSMIT) { 962 if (ctx->type == FW_ISO_CONTEXT_TRANSMIT) {
963 if (u.packet.header_length % 4 != 0)
964 return -EINVAL;
962 header_length = u.packet.header_length; 965 header_length = u.packet.header_length;
963 } else { 966 } else {
964 /* 967 /*
@@ -968,7 +971,8 @@ static int ioctl_queue_iso(struct client *client, union ioctl_arg *arg)
968 if (ctx->header_size == 0) { 971 if (ctx->header_size == 0) {
969 if (u.packet.header_length > 0) 972 if (u.packet.header_length > 0)
970 return -EINVAL; 973 return -EINVAL;
971 } else if (u.packet.header_length % ctx->header_size != 0) { 974 } else if (u.packet.header_length == 0 ||
975 u.packet.header_length % ctx->header_size != 0) {
972 return -EINVAL; 976 return -EINVAL;
973 } 977 }
974 header_length = 0; 978 header_length = 0;
@@ -1353,24 +1357,24 @@ static int dispatch_ioctl(struct client *client,
1353 return -ENODEV; 1357 return -ENODEV;
1354 1358
1355 if (_IOC_TYPE(cmd) != '#' || 1359 if (_IOC_TYPE(cmd) != '#' ||
1356 _IOC_NR(cmd) >= ARRAY_SIZE(ioctl_handlers)) 1360 _IOC_NR(cmd) >= ARRAY_SIZE(ioctl_handlers) ||
1361 _IOC_SIZE(cmd) > sizeof(buffer))
1357 return -EINVAL; 1362 return -EINVAL;
1358 1363
1359 if (_IOC_DIR(cmd) & _IOC_WRITE) { 1364 if (_IOC_DIR(cmd) == _IOC_READ)
1360 if (_IOC_SIZE(cmd) > sizeof(buffer) || 1365 memset(&buffer, 0, _IOC_SIZE(cmd));
1361 copy_from_user(&buffer, arg, _IOC_SIZE(cmd))) 1366
1367 if (_IOC_DIR(cmd) & _IOC_WRITE)
1368 if (copy_from_user(&buffer, arg, _IOC_SIZE(cmd)))
1362 return -EFAULT; 1369 return -EFAULT;
1363 }
1364 1370
1365 ret = ioctl_handlers[_IOC_NR(cmd)](client, &buffer); 1371 ret = ioctl_handlers[_IOC_NR(cmd)](client, &buffer);
1366 if (ret < 0) 1372 if (ret < 0)
1367 return ret; 1373 return ret;
1368 1374
1369 if (_IOC_DIR(cmd) & _IOC_READ) { 1375 if (_IOC_DIR(cmd) & _IOC_READ)
1370 if (_IOC_SIZE(cmd) > sizeof(buffer) || 1376 if (copy_to_user(arg, &buffer, _IOC_SIZE(cmd)))
1371 copy_to_user(arg, &buffer, _IOC_SIZE(cmd)))
1372 return -EFAULT; 1377 return -EFAULT;
1373 }
1374 1378
1375 return ret; 1379 return ret;
1376} 1380}
diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
index 5db0518c66d..4b8523f00dc 100644
--- a/drivers/firewire/core-device.c
+++ b/drivers/firewire/core-device.c
@@ -33,6 +33,7 @@
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/mutex.h> 34#include <linux/mutex.h>
35#include <linux/rwsem.h> 35#include <linux/rwsem.h>
36#include <linux/slab.h>
36#include <linux/spinlock.h> 37#include <linux/spinlock.h>
37#include <linux/string.h> 38#include <linux/string.h>
38#include <linux/workqueue.h> 39#include <linux/workqueue.h>
@@ -126,97 +127,74 @@ int fw_csr_string(const u32 *directory, int key, char *buf, size_t size)
126} 127}
127EXPORT_SYMBOL(fw_csr_string); 128EXPORT_SYMBOL(fw_csr_string);
128 129
129static bool is_fw_unit(struct device *dev); 130static void get_ids(const u32 *directory, int *id)
130
131static int match_unit_directory(const u32 *directory, u32 match_flags,
132 const struct ieee1394_device_id *id)
133{ 131{
134 struct fw_csr_iterator ci; 132 struct fw_csr_iterator ci;
135 int key, value, match; 133 int key, value;
136 134
137 match = 0;
138 fw_csr_iterator_init(&ci, directory); 135 fw_csr_iterator_init(&ci, directory);
139 while (fw_csr_iterator_next(&ci, &key, &value)) { 136 while (fw_csr_iterator_next(&ci, &key, &value)) {
140 if (key == CSR_VENDOR && value == id->vendor_id) 137 switch (key) {
141 match |= IEEE1394_MATCH_VENDOR_ID; 138 case CSR_VENDOR: id[0] = value; break;
142 if (key == CSR_MODEL && value == id->model_id) 139 case CSR_MODEL: id[1] = value; break;
143 match |= IEEE1394_MATCH_MODEL_ID; 140 case CSR_SPECIFIER_ID: id[2] = value; break;
144 if (key == CSR_SPECIFIER_ID && value == id->specifier_id) 141 case CSR_VERSION: id[3] = value; break;
145 match |= IEEE1394_MATCH_SPECIFIER_ID; 142 }
146 if (key == CSR_VERSION && value == id->version)
147 match |= IEEE1394_MATCH_VERSION;
148 } 143 }
144}
145
146static void get_modalias_ids(struct fw_unit *unit, int *id)
147{
148 get_ids(&fw_parent_device(unit)->config_rom[5], id);
149 get_ids(unit->directory, id);
150}
151
152static bool match_ids(const struct ieee1394_device_id *id_table, int *id)
153{
154 int match = 0;
155
156 if (id[0] == id_table->vendor_id)
157 match |= IEEE1394_MATCH_VENDOR_ID;
158 if (id[1] == id_table->model_id)
159 match |= IEEE1394_MATCH_MODEL_ID;
160 if (id[2] == id_table->specifier_id)
161 match |= IEEE1394_MATCH_SPECIFIER_ID;
162 if (id[3] == id_table->version)
163 match |= IEEE1394_MATCH_VERSION;
149 164
150 return (match & match_flags) == match_flags; 165 return (match & id_table->match_flags) == id_table->match_flags;
151} 166}
152 167
168static bool is_fw_unit(struct device *dev);
169
153static int fw_unit_match(struct device *dev, struct device_driver *drv) 170static int fw_unit_match(struct device *dev, struct device_driver *drv)
154{ 171{
155 struct fw_unit *unit = fw_unit(dev); 172 const struct ieee1394_device_id *id_table =
156 struct fw_device *device; 173 container_of(drv, struct fw_driver, driver)->id_table;
157 const struct ieee1394_device_id *id; 174 int id[] = {0, 0, 0, 0};
158 175
159 /* We only allow binding to fw_units. */ 176 /* We only allow binding to fw_units. */
160 if (!is_fw_unit(dev)) 177 if (!is_fw_unit(dev))
161 return 0; 178 return 0;
162 179
163 device = fw_parent_device(unit); 180 get_modalias_ids(fw_unit(dev), id);
164 id = container_of(drv, struct fw_driver, driver)->id_table;
165 181
166 for (; id->match_flags != 0; id++) { 182 for (; id_table->match_flags != 0; id_table++)
167 if (match_unit_directory(unit->directory, id->match_flags, id)) 183 if (match_ids(id_table, id))
168 return 1; 184 return 1;
169 185
170 /* Also check vendor ID in the root directory. */
171 if ((id->match_flags & IEEE1394_MATCH_VENDOR_ID) &&
172 match_unit_directory(&device->config_rom[5],
173 IEEE1394_MATCH_VENDOR_ID, id) &&
174 match_unit_directory(unit->directory, id->match_flags
175 & ~IEEE1394_MATCH_VENDOR_ID, id))
176 return 1;
177 }
178
179 return 0; 186 return 0;
180} 187}
181 188
182static int get_modalias(struct fw_unit *unit, char *buffer, size_t buffer_size) 189static int get_modalias(struct fw_unit *unit, char *buffer, size_t buffer_size)
183{ 190{
184 struct fw_device *device = fw_parent_device(unit); 191 int id[] = {0, 0, 0, 0};
185 struct fw_csr_iterator ci;
186 192
187 int key, value; 193 get_modalias_ids(unit, id);
188 int vendor = 0;
189 int model = 0;
190 int specifier_id = 0;
191 int version = 0;
192
193 fw_csr_iterator_init(&ci, &device->config_rom[5]);
194 while (fw_csr_iterator_next(&ci, &key, &value)) {
195 switch (key) {
196 case CSR_VENDOR:
197 vendor = value;
198 break;
199 case CSR_MODEL:
200 model = value;
201 break;
202 }
203 }
204
205 fw_csr_iterator_init(&ci, unit->directory);
206 while (fw_csr_iterator_next(&ci, &key, &value)) {
207 switch (key) {
208 case CSR_SPECIFIER_ID:
209 specifier_id = value;
210 break;
211 case CSR_VERSION:
212 version = value;
213 break;
214 }
215 }
216 194
217 return snprintf(buffer, buffer_size, 195 return snprintf(buffer, buffer_size,
218 "ieee1394:ven%08Xmo%08Xsp%08Xver%08X", 196 "ieee1394:ven%08Xmo%08Xsp%08Xver%08X",
219 vendor, model, specifier_id, version); 197 id[0], id[1], id[2], id[3]);
220} 198}
221 199
222static int fw_unit_uevent(struct device *dev, struct kobj_uevent_env *env) 200static int fw_unit_uevent(struct device *dev, struct kobj_uevent_env *env)
diff --git a/drivers/firewire/core-iso.c b/drivers/firewire/core-iso.c
index 1c0b504a42f..8f5aebfb29d 100644
--- a/drivers/firewire/core-iso.c
+++ b/drivers/firewire/core-iso.c
@@ -26,6 +26,7 @@
26#include <linux/firewire-constants.h> 26#include <linux/firewire-constants.h>
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/mm.h> 28#include <linux/mm.h>
29#include <linux/slab.h>
29#include <linux/spinlock.h> 30#include <linux/spinlock.h>
30#include <linux/vmalloc.h> 31#include <linux/vmalloc.h>
31 32
@@ -189,7 +190,7 @@ static int manage_bandwidth(struct fw_card *card, int irm_id, int generation,
189 for (try = 0; try < 5; try++) { 190 for (try = 0; try < 5; try++) {
190 new = allocate ? old - bandwidth : old + bandwidth; 191 new = allocate ? old - bandwidth : old + bandwidth;
191 if (new < 0 || new > BANDWIDTH_AVAILABLE_INITIAL) 192 if (new < 0 || new > BANDWIDTH_AVAILABLE_INITIAL)
192 break; 193 return -EBUSY;
193 194
194 data[0] = cpu_to_be32(old); 195 data[0] = cpu_to_be32(old);
195 data[1] = cpu_to_be32(new); 196 data[1] = cpu_to_be32(new);
@@ -217,7 +218,7 @@ static int manage_channel(struct fw_card *card, int irm_id, int generation,
217 u32 channels_mask, u64 offset, bool allocate, __be32 data[2]) 218 u32 channels_mask, u64 offset, bool allocate, __be32 data[2])
218{ 219{
219 __be32 c, all, old; 220 __be32 c, all, old;
220 int i, retry = 5; 221 int i, ret = -EIO, retry = 5;
221 222
222 old = all = allocate ? cpu_to_be32(~0) : 0; 223 old = all = allocate ? cpu_to_be32(~0) : 0;
223 224
@@ -225,6 +226,8 @@ static int manage_channel(struct fw_card *card, int irm_id, int generation,
225 if (!(channels_mask & 1 << i)) 226 if (!(channels_mask & 1 << i))
226 continue; 227 continue;
227 228
229 ret = -EBUSY;
230
228 c = cpu_to_be32(1 << (31 - i)); 231 c = cpu_to_be32(1 << (31 - i));
229 if ((old & c) != (all & c)) 232 if ((old & c) != (all & c))
230 continue; 233 continue;
@@ -250,12 +253,16 @@ static int manage_channel(struct fw_card *card, int irm_id, int generation,
250 253
251 /* 1394-1995 IRM, fall through to retry. */ 254 /* 1394-1995 IRM, fall through to retry. */
252 default: 255 default:
253 if (retry--) 256 if (retry) {
257 retry--;
254 i--; 258 i--;
259 } else {
260 ret = -EIO;
261 }
255 } 262 }
256 } 263 }
257 264
258 return -EIO; 265 return ret;
259} 266}
260 267
261static void deallocate_channel(struct fw_card *card, int irm_id, 268static void deallocate_channel(struct fw_card *card, int irm_id,
@@ -331,8 +338,9 @@ void fw_iso_resource_manage(struct fw_card *card, int generation,
331 if (ret < 0) 338 if (ret < 0)
332 *bandwidth = 0; 339 *bandwidth = 0;
333 340
334 if (allocate && ret < 0 && c >= 0) { 341 if (allocate && ret < 0) {
335 deallocate_channel(card, irm_id, generation, c, buffer); 342 if (c >= 0)
343 deallocate_channel(card, irm_id, generation, c, buffer);
336 *channel = ret; 344 *channel = ret;
337 } 345 }
338} 346}
diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
index 2d3dc7ded0a..7142eeec807 100644
--- a/drivers/firewire/net.c
+++ b/drivers/firewire/net.c
@@ -21,6 +21,7 @@
21#include <linux/mutex.h> 21#include <linux/mutex.h>
22#include <linux/netdevice.h> 22#include <linux/netdevice.h>
23#include <linux/skbuff.h> 23#include <linux/skbuff.h>
24#include <linux/slab.h>
24#include <linux/spinlock.h> 25#include <linux/spinlock.h>
25 26
26#include <asm/unaligned.h> 27#include <asm/unaligned.h>
diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c
index 75dc6988cff..94b16e0340a 100644
--- a/drivers/firewire/ohci.c
+++ b/drivers/firewire/ohci.c
@@ -24,7 +24,6 @@
24#include <linux/dma-mapping.h> 24#include <linux/dma-mapping.h>
25#include <linux/firewire.h> 25#include <linux/firewire.h>
26#include <linux/firewire-constants.h> 26#include <linux/firewire-constants.h>
27#include <linux/gfp.h>
28#include <linux/init.h> 27#include <linux/init.h>
29#include <linux/interrupt.h> 28#include <linux/interrupt.h>
30#include <linux/io.h> 29#include <linux/io.h>
@@ -35,6 +34,7 @@
35#include <linux/moduleparam.h> 34#include <linux/moduleparam.h>
36#include <linux/pci.h> 35#include <linux/pci.h>
37#include <linux/pci_ids.h> 36#include <linux/pci_ids.h>
37#include <linux/slab.h>
38#include <linux/spinlock.h> 38#include <linux/spinlock.h>
39#include <linux/string.h> 39#include <linux/string.h>
40 40
@@ -231,6 +231,8 @@ static inline struct fw_ohci *fw_ohci(struct fw_card *card)
231 231
232static char ohci_driver_name[] = KBUILD_MODNAME; 232static char ohci_driver_name[] = KBUILD_MODNAME;
233 233
234#define PCI_DEVICE_ID_TI_TSB12LV22 0x8009
235
234#define QUIRK_CYCLE_TIMER 1 236#define QUIRK_CYCLE_TIMER 1
235#define QUIRK_RESET_PACKET 2 237#define QUIRK_RESET_PACKET 2
236#define QUIRK_BE_HEADERS 4 238#define QUIRK_BE_HEADERS 4
@@ -239,6 +241,8 @@ static char ohci_driver_name[] = KBUILD_MODNAME;
239static const struct { 241static const struct {
240 unsigned short vendor, device, flags; 242 unsigned short vendor, device, flags;
241} ohci_quirks[] = { 243} ohci_quirks[] = {
244 {PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_TSB12LV22, QUIRK_CYCLE_TIMER |
245 QUIRK_RESET_PACKET},
242 {PCI_VENDOR_ID_TI, PCI_ANY_ID, QUIRK_RESET_PACKET}, 246 {PCI_VENDOR_ID_TI, PCI_ANY_ID, QUIRK_RESET_PACKET},
243 {PCI_VENDOR_ID_AL, PCI_ANY_ID, QUIRK_CYCLE_TIMER}, 247 {PCI_VENDOR_ID_AL, PCI_ANY_ID, QUIRK_CYCLE_TIMER},
244 {PCI_VENDOR_ID_NEC, PCI_ANY_ID, QUIRK_CYCLE_TIMER}, 248 {PCI_VENDOR_ID_NEC, PCI_ANY_ID, QUIRK_CYCLE_TIMER},
@@ -1154,7 +1158,7 @@ static void handle_local_lock(struct fw_ohci *ohci,
1154 struct fw_packet *packet, u32 csr) 1158 struct fw_packet *packet, u32 csr)
1155{ 1159{
1156 struct fw_packet response; 1160 struct fw_packet response;
1157 int tcode, length, ext_tcode, sel; 1161 int tcode, length, ext_tcode, sel, try;
1158 __be32 *payload, lock_old; 1162 __be32 *payload, lock_old;
1159 u32 lock_arg, lock_data; 1163 u32 lock_arg, lock_data;
1160 1164
@@ -1181,21 +1185,26 @@ static void handle_local_lock(struct fw_ohci *ohci,
1181 reg_write(ohci, OHCI1394_CSRCompareData, lock_arg); 1185 reg_write(ohci, OHCI1394_CSRCompareData, lock_arg);
1182 reg_write(ohci, OHCI1394_CSRControl, sel); 1186 reg_write(ohci, OHCI1394_CSRControl, sel);
1183 1187
1184 if (reg_read(ohci, OHCI1394_CSRControl) & 0x80000000) 1188 for (try = 0; try < 20; try++)
1185 lock_old = cpu_to_be32(reg_read(ohci, OHCI1394_CSRData)); 1189 if (reg_read(ohci, OHCI1394_CSRControl) & 0x80000000) {
1186 else 1190 lock_old = cpu_to_be32(reg_read(ohci,
1187 fw_notify("swap not done yet\n"); 1191 OHCI1394_CSRData));
1192 fw_fill_response(&response, packet->header,
1193 RCODE_COMPLETE,
1194 &lock_old, sizeof(lock_old));
1195 goto out;
1196 }
1197
1198 fw_error("swap not done (CSR lock timeout)\n");
1199 fw_fill_response(&response, packet->header, RCODE_BUSY, NULL, 0);
1188 1200
1189 fw_fill_response(&response, packet->header,
1190 RCODE_COMPLETE, &lock_old, sizeof(lock_old));
1191 out: 1201 out:
1192 fw_core_handle_response(&ohci->card, &response); 1202 fw_core_handle_response(&ohci->card, &response);
1193} 1203}
1194 1204
1195static void handle_local_request(struct context *ctx, struct fw_packet *packet) 1205static void handle_local_request(struct context *ctx, struct fw_packet *packet)
1196{ 1206{
1197 u64 offset; 1207 u64 offset, csr;
1198 u32 csr;
1199 1208
1200 if (ctx == &ctx->ohci->at_request_ctx) { 1209 if (ctx == &ctx->ohci->at_request_ctx) {
1201 packet->ack = ACK_PENDING; 1210 packet->ack = ACK_PENDING;
diff --git a/drivers/firmware/dcdbas.c b/drivers/firmware/dcdbas.c
index 18d65fb42ee..fb09bb3c0ad 100644
--- a/drivers/firmware/dcdbas.c
+++ b/drivers/firmware/dcdbas.c
@@ -23,6 +23,7 @@
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/dma-mapping.h> 24#include <linux/dma-mapping.h>
25#include <linux/errno.h> 25#include <linux/errno.h>
26#include <linux/gfp.h>
26#include <linux/init.h> 27#include <linux/init.h>
27#include <linux/kernel.h> 28#include <linux/kernel.h>
28#include <linux/mc146818rtc.h> 29#include <linux/mc146818rtc.h>
diff --git a/drivers/firmware/dell_rbu.c b/drivers/firmware/dell_rbu.c
index b3a0cf57442..3a4460265b1 100644
--- a/drivers/firmware/dell_rbu.c
+++ b/drivers/firmware/dell_rbu.c
@@ -36,6 +36,7 @@
36 */ 36 */
37#include <linux/init.h> 37#include <linux/init.h>
38#include <linux/module.h> 38#include <linux/module.h>
39#include <linux/slab.h>
39#include <linux/string.h> 40#include <linux/string.h>
40#include <linux/errno.h> 41#include <linux/errno.h>
41#include <linux/blkdev.h> 42#include <linux/blkdev.h>
diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
index dbdf6fadfc7..a777a35381d 100644
--- a/drivers/firmware/dmi-id.c
+++ b/drivers/firmware/dmi-id.c
@@ -11,6 +11,7 @@
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/dmi.h> 12#include <linux/dmi.h>
13#include <linux/device.h> 13#include <linux/device.h>
14#include <linux/slab.h>
14 15
15struct dmi_device_attribute{ 16struct dmi_device_attribute{
16 struct device_attribute dev_attr; 17 struct device_attribute dev_attr;
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index 31b983d9462..d4646727134 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -5,7 +5,6 @@
5#include <linux/dmi.h> 5#include <linux/dmi.h>
6#include <linux/efi.h> 6#include <linux/efi.h>
7#include <linux/bootmem.h> 7#include <linux/bootmem.h>
8#include <linux/slab.h>
9#include <asm/dmi.h> 8#include <asm/dmi.h>
10 9
11/* 10/*
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index 082f06ecd32..81b70bd0758 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -77,6 +77,7 @@
77#include <linux/sysfs.h> 77#include <linux/sysfs.h>
78#include <linux/kobject.h> 78#include <linux/kobject.h>
79#include <linux/device.h> 79#include <linux/device.h>
80#include <linux/slab.h>
80 81
81#include <asm/uaccess.h> 82#include <asm/uaccess.h>
82 83
diff --git a/drivers/firmware/iscsi_ibft_find.c b/drivers/firmware/iscsi_ibft_find.c
index dfb15c06c88..d6470ef36e4 100644
--- a/drivers/firmware/iscsi_ibft_find.c
+++ b/drivers/firmware/iscsi_ibft_find.c
@@ -27,7 +27,6 @@
27#include <linux/limits.h> 27#include <linux/limits.h>
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/pci.h> 29#include <linux/pci.h>
30#include <linux/slab.h>
31#include <linux/stat.h> 30#include <linux/stat.h>
32#include <linux/string.h> 31#include <linux/string.h>
33#include <linux/types.h> 32#include <linux/types.h>
@@ -52,7 +51,7 @@ EXPORT_SYMBOL_GPL(ibft_addr);
52 * Routine used to find the iSCSI Boot Format Table. The logical 51 * Routine used to find the iSCSI Boot Format Table. The logical
53 * kernel address is set in the ibft_addr global variable. 52 * kernel address is set in the ibft_addr global variable.
54 */ 53 */
55void __init reserve_ibft_region(void) 54unsigned long __init find_ibft_region(unsigned long *sizep)
56{ 55{
57 unsigned long pos; 56 unsigned long pos;
58 unsigned int len = 0; 57 unsigned int len = 0;
@@ -78,6 +77,11 @@ void __init reserve_ibft_region(void)
78 } 77 }
79 } 78 }
80 } 79 }
81 if (ibft_addr) 80 if (ibft_addr) {
82 reserve_bootmem(pos, PAGE_ALIGN(len), BOOTMEM_DEFAULT); 81 *sizep = PAGE_ALIGN(len);
82 return pos;
83 }
84
85 *sizep = 0;
86 return 0;
83} 87}
diff --git a/drivers/firmware/memmap.c b/drivers/firmware/memmap.c
index d59f7cad226..adc07102a20 100644
--- a/drivers/firmware/memmap.c
+++ b/drivers/firmware/memmap.c
@@ -20,6 +20,7 @@
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/types.h> 21#include <linux/types.h>
22#include <linux/bootmem.h> 22#include <linux/bootmem.h>
23#include <linux/slab.h>
23 24
24/* 25/*
25 * Data types ------------------------------------------------------------------ 26 * Data types ------------------------------------------------------------------
diff --git a/drivers/gpio/adp5520-gpio.c b/drivers/gpio/adp5520-gpio.c
index 0f93105873c..9f278153700 100644
--- a/drivers/gpio/adp5520-gpio.c
+++ b/drivers/gpio/adp5520-gpio.c
@@ -7,6 +7,7 @@
7 */ 7 */
8 8
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/slab.h>
10#include <linux/kernel.h> 11#include <linux/kernel.h>
11#include <linux/init.h> 12#include <linux/init.h>
12#include <linux/platform_device.h> 13#include <linux/platform_device.h>
diff --git a/drivers/gpio/adp5588-gpio.c b/drivers/gpio/adp5588-gpio.c
index afc097a16b3..2e8e9e24f88 100644
--- a/drivers/gpio/adp5588-gpio.c
+++ b/drivers/gpio/adp5588-gpio.c
@@ -9,6 +9,7 @@
9 9
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/slab.h>
12#include <linux/init.h> 13#include <linux/init.h>
13#include <linux/i2c.h> 14#include <linux/i2c.h>
14#include <linux/gpio.h> 15#include <linux/gpio.h>
diff --git a/drivers/gpio/bt8xxgpio.c b/drivers/gpio/bt8xxgpio.c
index 2559f228940..aa4f09ad3ce 100644
--- a/drivers/gpio/bt8xxgpio.c
+++ b/drivers/gpio/bt8xxgpio.c
@@ -47,6 +47,7 @@
47#include <linux/pci.h> 47#include <linux/pci.h>
48#include <linux/spinlock.h> 48#include <linux/spinlock.h>
49#include <linux/gpio.h> 49#include <linux/gpio.h>
50#include <linux/slab.h>
50 51
51/* Steal the hardware definitions from the bttv driver. */ 52/* Steal the hardware definitions from the bttv driver. */
52#include "../media/video/bt8xx/bt848.h" 53#include "../media/video/bt8xx/bt848.h"
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 6d1b86661e6..eb0c3fe44b2 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -9,6 +9,7 @@
9#include <linux/seq_file.h> 9#include <linux/seq_file.h>
10#include <linux/gpio.h> 10#include <linux/gpio.h>
11#include <linux/idr.h> 11#include <linux/idr.h>
12#include <linux/slab.h>
12 13
13 14
14/* Optional implementation infrastructure for GPIO interfaces. 15/* Optional implementation infrastructure for GPIO interfaces.
@@ -415,7 +416,8 @@ static int gpio_setup_irq(struct gpio_desc *desc, struct device *dev,
415 return 0; 416 return 0;
416 417
417free_sd: 418free_sd:
418 sysfs_put(pdesc->value_sd); 419 if (pdesc)
420 sysfs_put(pdesc->value_sd);
419free_id: 421free_id:
420 idr_remove(&pdesc_idr, id); 422 idr_remove(&pdesc_idr, id);
421 desc->flags &= GPIO_FLAGS_MASK; 423 desc->flags &= GPIO_FLAGS_MASK;
diff --git a/drivers/gpio/langwell_gpio.c b/drivers/gpio/langwell_gpio.c
index 6c0ebbdc659..00c3a14127a 100644
--- a/drivers/gpio/langwell_gpio.c
+++ b/drivers/gpio/langwell_gpio.c
@@ -29,6 +29,7 @@
29#include <linux/irq.h> 29#include <linux/irq.h>
30#include <linux/io.h> 30#include <linux/io.h>
31#include <linux/gpio.h> 31#include <linux/gpio.h>
32#include <linux/slab.h>
32 33
33struct lnw_gpio_register { 34struct lnw_gpio_register {
34 u32 GPLR[2]; 35 u32 GPLR[2];
diff --git a/drivers/gpio/max7300.c b/drivers/gpio/max7300.c
index 9d74eef1157..962f661c18c 100644
--- a/drivers/gpio/max7300.c
+++ b/drivers/gpio/max7300.c
@@ -16,6 +16,7 @@
16#include <linux/mutex.h> 16#include <linux/mutex.h>
17#include <linux/i2c.h> 17#include <linux/i2c.h>
18#include <linux/spi/max7301.h> 18#include <linux/spi/max7301.h>
19#include <linux/slab.h>
19 20
20static int max7300_i2c_write(struct device *dev, unsigned int reg, 21static int max7300_i2c_write(struct device *dev, unsigned int reg,
21 unsigned int val) 22 unsigned int val)
diff --git a/drivers/gpio/max7301.c b/drivers/gpio/max7301.c
index 965d9b1ea13..92a100ddef6 100644
--- a/drivers/gpio/max7301.c
+++ b/drivers/gpio/max7301.c
@@ -16,6 +16,7 @@
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/mutex.h> 18#include <linux/mutex.h>
19#include <linux/slab.h>
19#include <linux/spi/spi.h> 20#include <linux/spi/spi.h>
20#include <linux/spi/max7301.h> 21#include <linux/spi/max7301.h>
21 22
diff --git a/drivers/gpio/max730x.c b/drivers/gpio/max730x.c
index c9bced55f82..7696a5625d5 100644
--- a/drivers/gpio/max730x.c
+++ b/drivers/gpio/max730x.c
@@ -38,6 +38,7 @@
38#include <linux/mutex.h> 38#include <linux/mutex.h>
39#include <linux/spi/max7301.h> 39#include <linux/spi/max7301.h>
40#include <linux/gpio.h> 40#include <linux/gpio.h>
41#include <linux/slab.h>
41 42
42/* 43/*
43 * Pin configurations, see MAX7301 datasheet page 6 44 * Pin configurations, see MAX7301 datasheet page 6
@@ -242,3 +243,7 @@ int __devexit __max730x_remove(struct device *dev)
242 return ret; 243 return ret;
243} 244}
244EXPORT_SYMBOL_GPL(__max730x_remove); 245EXPORT_SYMBOL_GPL(__max730x_remove);
246
247MODULE_AUTHOR("Juergen Beisert, Wolfram Sang");
248MODULE_LICENSE("GPL v2");
249MODULE_DESCRIPTION("MAX730x GPIO-Expanders, generic parts");
diff --git a/drivers/gpio/mc33880.c b/drivers/gpio/mc33880.c
index e7d01bd8fdb..935479da670 100644
--- a/drivers/gpio/mc33880.c
+++ b/drivers/gpio/mc33880.c
@@ -25,6 +25,7 @@
25#include <linux/spi/spi.h> 25#include <linux/spi/spi.h>
26#include <linux/spi/mc33880.h> 26#include <linux/spi/mc33880.h>
27#include <linux/gpio.h> 27#include <linux/gpio.h>
28#include <linux/slab.h>
28 29
29#define DRIVER_NAME "mc33880" 30#define DRIVER_NAME "mc33880"
30 31
diff --git a/drivers/gpio/mcp23s08.c b/drivers/gpio/mcp23s08.c
index cd651ec8d03..69f6f1955a3 100644
--- a/drivers/gpio/mcp23s08.c
+++ b/drivers/gpio/mcp23s08.c
@@ -9,6 +9,7 @@
9#include <linux/gpio.h> 9#include <linux/gpio.h>
10#include <linux/spi/spi.h> 10#include <linux/spi/spi.h>
11#include <linux/spi/mcp23s08.h> 11#include <linux/spi/mcp23s08.h>
12#include <linux/slab.h>
12 13
13 14
14/* Registers are all 8 bits wide. 15/* Registers are all 8 bits wide.
diff --git a/drivers/gpio/pca953x.c b/drivers/gpio/pca953x.c
index ab5daab14bc..b827c976dc6 100644
--- a/drivers/gpio/pca953x.c
+++ b/drivers/gpio/pca953x.c
@@ -18,6 +18,7 @@
18#include <linux/irq.h> 18#include <linux/irq.h>
19#include <linux/i2c.h> 19#include <linux/i2c.h>
20#include <linux/i2c/pca953x.h> 20#include <linux/i2c/pca953x.h>
21#include <linux/slab.h>
21#ifdef CONFIG_OF_GPIO 22#ifdef CONFIG_OF_GPIO
22#include <linux/of_platform.h> 23#include <linux/of_platform.h>
23#include <linux/of_gpio.h> 24#include <linux/of_gpio.h>
@@ -251,6 +252,18 @@ static void pca953x_irq_bus_lock(unsigned int irq)
251static void pca953x_irq_bus_sync_unlock(unsigned int irq) 252static void pca953x_irq_bus_sync_unlock(unsigned int irq)
252{ 253{
253 struct pca953x_chip *chip = get_irq_chip_data(irq); 254 struct pca953x_chip *chip = get_irq_chip_data(irq);
255 uint16_t new_irqs;
256 uint16_t level;
257
258 /* Look for any newly setup interrupt */
259 new_irqs = chip->irq_trig_fall | chip->irq_trig_raise;
260 new_irqs &= ~chip->reg_direction;
261
262 while (new_irqs) {
263 level = __ffs(new_irqs);
264 pca953x_gpio_direction_input(&chip->gpio_chip, level);
265 new_irqs &= ~(1 << level);
266 }
254 267
255 mutex_unlock(&chip->irq_lock); 268 mutex_unlock(&chip->irq_lock);
256} 269}
@@ -277,7 +290,7 @@ static int pca953x_irq_set_type(unsigned int irq, unsigned int type)
277 else 290 else
278 chip->irq_trig_raise &= ~mask; 291 chip->irq_trig_raise &= ~mask;
279 292
280 return pca953x_gpio_direction_input(&chip->gpio_chip, level); 293 return 0;
281} 294}
282 295
283static struct irq_chip pca953x_irq_chip = { 296static struct irq_chip pca953x_irq_chip = {
diff --git a/drivers/gpio/pl061.c b/drivers/gpio/pl061.c
index 3ad1eeb4960..105701a1f05 100644
--- a/drivers/gpio/pl061.c
+++ b/drivers/gpio/pl061.c
@@ -24,6 +24,7 @@
24#include <linux/device.h> 24#include <linux/device.h>
25#include <linux/amba/bus.h> 25#include <linux/amba/bus.h>
26#include <linux/amba/pl061.h> 26#include <linux/amba/pl061.h>
27#include <linux/slab.h>
27 28
28#define GPIODIR 0x400 29#define GPIODIR 0x400
29#define GPIOIS 0x404 30#define GPIOIS 0x404
@@ -90,6 +91,12 @@ static int pl061_direction_output(struct gpio_chip *gc, unsigned offset,
90 gpiodir = readb(chip->base + GPIODIR); 91 gpiodir = readb(chip->base + GPIODIR);
91 gpiodir |= 1 << offset; 92 gpiodir |= 1 << offset;
92 writeb(gpiodir, chip->base + GPIODIR); 93 writeb(gpiodir, chip->base + GPIODIR);
94
95 /*
96 * gpio value is set again, because pl061 doesn't allow to set value of
97 * a gpio pin before configuring it in OUT mode.
98 */
99 writeb(!!value << offset, chip->base + (1 << (offset + 2)));
93 spin_unlock_irqrestore(&chip->lock, flags); 100 spin_unlock_irqrestore(&chip->lock, flags);
94 101
95 return 0; 102 return 0;
@@ -182,7 +189,7 @@ static int pl061_irq_type(unsigned irq, unsigned trigger)
182 gpioibe &= ~(1 << offset); 189 gpioibe &= ~(1 << offset);
183 if (trigger & IRQ_TYPE_EDGE_RISING) 190 if (trigger & IRQ_TYPE_EDGE_RISING)
184 gpioiev |= 1 << offset; 191 gpioiev |= 1 << offset;
185 else 192 else if (trigger & IRQ_TYPE_EDGE_FALLING)
186 gpioiev &= ~(1 << offset); 193 gpioiev &= ~(1 << offset);
187 } 194 }
188 writeb(gpioibe, chip->base + GPIOIBE); 195 writeb(gpioibe, chip->base + GPIOIBE);
@@ -203,7 +210,7 @@ static struct irq_chip pl061_irqchip = {
203 210
204static void pl061_irq_handler(unsigned irq, struct irq_desc *desc) 211static void pl061_irq_handler(unsigned irq, struct irq_desc *desc)
205{ 212{
206 struct list_head *chip_list = get_irq_chip_data(irq); 213 struct list_head *chip_list = get_irq_data(irq);
207 struct list_head *ptr; 214 struct list_head *ptr;
208 struct pl061_gpio *chip; 215 struct pl061_gpio *chip;
209 216
@@ -296,9 +303,9 @@ static int __init pl061_probe(struct amba_device *dev, struct amba_id *id)
296 goto iounmap; 303 goto iounmap;
297 } 304 }
298 INIT_LIST_HEAD(chip_list); 305 INIT_LIST_HEAD(chip_list);
299 set_irq_chip_data(irq, chip_list); 306 set_irq_data(irq, chip_list);
300 } else 307 } else
301 chip_list = get_irq_chip_data(irq); 308 chip_list = get_irq_data(irq);
302 list_add(&chip->list, chip_list); 309 list_add(&chip->list, chip_list);
303 310
304 for (i = 0; i < PL061_GPIO_NR; i++) { 311 for (i = 0; i < PL061_GPIO_NR; i++) {
diff --git a/drivers/gpio/timbgpio.c b/drivers/gpio/timbgpio.c
index d4295fa5369..ddd053108a1 100644
--- a/drivers/gpio/timbgpio.c
+++ b/drivers/gpio/timbgpio.c
@@ -27,6 +27,7 @@
27#include <linux/io.h> 27#include <linux/io.h>
28#include <linux/timb_gpio.h> 28#include <linux/timb_gpio.h>
29#include <linux/interrupt.h> 29#include <linux/interrupt.h>
30#include <linux/slab.h>
30 31
31#define DRIVER_NAME "timb-gpio" 32#define DRIVER_NAME "timb-gpio"
32 33
@@ -130,6 +131,7 @@ static int timbgpio_irq_type(unsigned irq, unsigned trigger)
130 unsigned long flags; 131 unsigned long flags;
131 u32 lvr, flr, bflr = 0; 132 u32 lvr, flr, bflr = 0;
132 u32 ver; 133 u32 ver;
134 int ret = 0;
133 135
134 if (offset < 0 || offset > tgpio->gpio.ngpio) 136 if (offset < 0 || offset > tgpio->gpio.ngpio)
135 return -EINVAL; 137 return -EINVAL;
@@ -153,8 +155,10 @@ static int timbgpio_irq_type(unsigned irq, unsigned trigger)
153 } 155 }
154 156
155 if ((trigger & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH) { 157 if ((trigger & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH) {
156 if (ver < 3) 158 if (ver < 3) {
157 return -EINVAL; 159 ret = -EINVAL;
160 goto out;
161 }
158 else { 162 else {
159 flr |= 1 << offset; 163 flr |= 1 << offset;
160 bflr |= 1 << offset; 164 bflr |= 1 << offset;
@@ -174,9 +178,10 @@ static int timbgpio_irq_type(unsigned irq, unsigned trigger)
174 iowrite32(bflr, tgpio->membase + TGPIO_BFLR); 178 iowrite32(bflr, tgpio->membase + TGPIO_BFLR);
175 179
176 iowrite32(1 << offset, tgpio->membase + TGPIO_ICR); 180 iowrite32(1 << offset, tgpio->membase + TGPIO_ICR);
177 spin_unlock_irqrestore(&tgpio->lock, flags);
178 181
179 return 0; 182out:
183 spin_unlock_irqrestore(&tgpio->lock, flags);
184 return ret;
180} 185}
181 186
182static void timbgpio_irq(unsigned int irq, struct irq_desc *desc) 187static void timbgpio_irq(unsigned int irq, struct irq_desc *desc)
diff --git a/drivers/gpio/twl4030-gpio.c b/drivers/gpio/twl4030-gpio.c
index 7fe881e2bdf..57635ac35a7 100644
--- a/drivers/gpio/twl4030-gpio.c
+++ b/drivers/gpio/twl4030-gpio.c
@@ -32,7 +32,6 @@
32#include <linux/irq.h> 32#include <linux/irq.h>
33#include <linux/gpio.h> 33#include <linux/gpio.h>
34#include <linux/platform_device.h> 34#include <linux/platform_device.h>
35#include <linux/slab.h>
36 35
37#include <linux/i2c/twl.h> 36#include <linux/i2c/twl.h>
38 37
diff --git a/drivers/gpio/wm831x-gpio.c b/drivers/gpio/wm831x-gpio.c
index d09021f4a7d..1fa449a1a4c 100644
--- a/drivers/gpio/wm831x-gpio.c
+++ b/drivers/gpio/wm831x-gpio.c
@@ -13,6 +13,7 @@
13 */ 13 */
14 14
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/slab.h>
16#include <linux/module.h> 17#include <linux/module.h>
17#include <linux/gpio.h> 18#include <linux/gpio.h>
18#include <linux/mfd/core.h> 19#include <linux/mfd/core.h>
diff --git a/drivers/gpio/wm8350-gpiolib.c b/drivers/gpio/wm8350-gpiolib.c
index 511840d1c7b..359999290f5 100644
--- a/drivers/gpio/wm8350-gpiolib.c
+++ b/drivers/gpio/wm8350-gpiolib.c
@@ -13,6 +13,7 @@
13 */ 13 */
14 14
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/slab.h>
16#include <linux/module.h> 17#include <linux/module.h>
17#include <linux/gpio.h> 18#include <linux/gpio.h>
18#include <linux/mfd/core.h> 19#include <linux/mfd/core.h>
diff --git a/drivers/gpio/wm8994-gpio.c b/drivers/gpio/wm8994-gpio.c
index de28b4a470e..7607cc61e1d 100644
--- a/drivers/gpio/wm8994-gpio.c
+++ b/drivers/gpio/wm8994-gpio.c
@@ -13,6 +13,7 @@
13 */ 13 */
14 14
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/slab.h>
16#include <linux/module.h> 17#include <linux/module.h>
17#include <linux/gpio.h> 18#include <linux/gpio.h>
18#include <linux/mfd/core.h> 19#include <linux/mfd/core.h>
diff --git a/drivers/gpio/xilinx_gpio.c b/drivers/gpio/xilinx_gpio.c
index 3c1177abebd..b8fa65b5bfc 100644
--- a/drivers/gpio/xilinx_gpio.c
+++ b/drivers/gpio/xilinx_gpio.c
@@ -19,6 +19,7 @@
19#include <linux/of_gpio.h> 19#include <linux/of_gpio.h>
20#include <linux/io.h> 20#include <linux/io.h>
21#include <linux/gpio.h> 21#include <linux/gpio.h>
22#include <linux/slab.h>
22 23
23/* Register Offset Definitions */ 24/* Register Offset Definitions */
24#define XGPIO_DATA_OFFSET (0x0) /* Data register */ 25#define XGPIO_DATA_OFFSET (0x0) /* Data register */
diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c
index d68888fe3df..ba38e014722 100644
--- a/drivers/gpu/drm/drm_agpsupport.c
+++ b/drivers/gpu/drm/drm_agpsupport.c
@@ -33,6 +33,7 @@
33 33
34#include "drmP.h" 34#include "drmP.h"
35#include <linux/module.h> 35#include <linux/module.h>
36#include <linux/slab.h>
36 37
37#if __OS_HAS_AGP 38#if __OS_HAS_AGP
38 39
diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 8417cc4c43f..f7ba82ebf65 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -34,6 +34,7 @@
34 */ 34 */
35 35
36#include <linux/vmalloc.h> 36#include <linux/vmalloc.h>
37#include <linux/slab.h>
37#include <linux/log2.h> 38#include <linux/log2.h>
38#include <asm/shmparam.h> 39#include <asm/shmparam.h>
39#include "drmP.h" 40#include "drmP.h"
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index d91fb8c0b7b..61b9bcfdf04 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -30,6 +30,7 @@
30 * Jesse Barnes <jesse.barnes@intel.com> 30 * Jesse Barnes <jesse.barnes@intel.com>
31 */ 31 */
32#include <linux/list.h> 32#include <linux/list.h>
33#include <linux/slab.h>
33#include "drm.h" 34#include "drm.h"
34#include "drmP.h" 35#include "drmP.h"
35#include "drm_crtc.h" 36#include "drm_crtc.h"
diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index f2aaf39be39..51103aa469f 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -104,6 +104,7 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector,
104 if (connector->status == connector_status_disconnected) { 104 if (connector->status == connector_status_disconnected) {
105 DRM_DEBUG_KMS("%s is disconnected\n", 105 DRM_DEBUG_KMS("%s is disconnected\n",
106 drm_get_connector_name(connector)); 106 drm_get_connector_name(connector));
107 drm_mode_connector_update_edid_property(connector, NULL);
107 goto prune; 108 goto prune;
108 } 109 }
109 110
diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index 9903f270e44..677b275fa72 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -32,6 +32,7 @@
32 32
33#include <linux/debugfs.h> 33#include <linux/debugfs.h>
34#include <linux/seq_file.h> 34#include <linux/seq_file.h>
35#include <linux/slab.h>
35#include "drmP.h" 36#include "drmP.h"
36 37
37#if defined(CONFIG_DEBUG_FS) 38#if defined(CONFIG_DEBUG_FS)
diff --git a/drivers/gpu/drm/drm_dp_i2c_helper.c b/drivers/gpu/drm/drm_dp_i2c_helper.c
index 548887c8506..f7eba0a0973 100644
--- a/drivers/gpu/drm/drm_dp_i2c_helper.c
+++ b/drivers/gpu/drm/drm_dp_i2c_helper.c
@@ -23,7 +23,6 @@
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/slab.h>
27#include <linux/init.h> 26#include <linux/init.h>
28#include <linux/errno.h> 27#include <linux/errno.h>
29#include <linux/sched.h> 28#include <linux/sched.h>
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index f3c58e2bd75..4a66201edae 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -47,6 +47,7 @@
47 */ 47 */
48 48
49#include <linux/debugfs.h> 49#include <linux/debugfs.h>
50#include <linux/slab.h>
50#include "drmP.h" 51#include "drmP.h"
51#include "drm_core.h" 52#include "drm_core.h"
52 53
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index f97e7c42ac8..18f41d7061f 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -27,6 +27,7 @@
27 * DEALINGS IN THE SOFTWARE. 27 * DEALINGS IN THE SOFTWARE.
28 */ 28 */
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <linux/slab.h>
30#include <linux/i2c.h> 31#include <linux/i2c.h>
31#include <linux/i2c-algo-bit.h> 32#include <linux/i2c-algo-bit.h>
32#include "drmP.h" 33#include "drmP.h"
@@ -84,6 +85,8 @@ static struct edid_quirk {
84 85
85 /* Envision Peripherals, Inc. EN-7100e */ 86 /* Envision Peripherals, Inc. EN-7100e */
86 { "EPI", 59264, EDID_QUIRK_135_CLOCK_TOO_HIGH }, 87 { "EPI", 59264, EDID_QUIRK_135_CLOCK_TOO_HIGH },
88 /* Envision EN2028 */
89 { "EPI", 8232, EDID_QUIRK_PREFER_LARGE_60 },
87 90
88 /* Funai Electronics PM36B */ 91 /* Funai Electronics PM36B */
89 { "FCM", 13600, EDID_QUIRK_PREFER_LARGE_75 | 92 { "FCM", 13600, EDID_QUIRK_PREFER_LARGE_75 |
@@ -707,15 +710,6 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
707 mode->vsync_end = mode->vsync_start + vsync_pulse_width; 710 mode->vsync_end = mode->vsync_start + vsync_pulse_width;
708 mode->vtotal = mode->vdisplay + vblank; 711 mode->vtotal = mode->vdisplay + vblank;
709 712
710 /* perform the basic check for the detailed timing */
711 if (mode->hsync_end > mode->htotal ||
712 mode->vsync_end > mode->vtotal) {
713 drm_mode_destroy(dev, mode);
714 DRM_DEBUG_KMS("Incorrect detailed timing. "
715 "Sync is beyond the blank.\n");
716 return NULL;
717 }
718
719 /* Some EDIDs have bogus h/vtotal values */ 713 /* Some EDIDs have bogus h/vtotal values */
720 if (mode->hsync_end > mode->htotal) 714 if (mode->hsync_end > mode->htotal)
721 mode->htotal = mode->hsync_end + 1; 715 mode->htotal = mode->hsync_end + 1;
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 50549703584..288ea2f3277 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -29,6 +29,7 @@
29 */ 29 */
30#include <linux/kernel.h> 30#include <linux/kernel.h>
31#include <linux/sysrq.h> 31#include <linux/sysrq.h>
32#include <linux/slab.h>
32#include <linux/fb.h> 33#include <linux/fb.h>
33#include "drmP.h" 34#include "drmP.h"
34#include "drm_crtc.h" 35#include "drm_crtc.h"
@@ -283,6 +284,8 @@ static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = {
283 .help_msg = "force-fb(V)", 284 .help_msg = "force-fb(V)",
284 .action_msg = "Restore framebuffer console", 285 .action_msg = "Restore framebuffer console",
285}; 286};
287#else
288static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { };
286#endif 289#endif
287 290
288static void drm_fb_helper_on(struct fb_info *info) 291static void drm_fb_helper_on(struct fb_info *info)
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 08d14df3bb4..9d532d7fdf5 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -36,6 +36,7 @@
36 36
37#include "drmP.h" 37#include "drmP.h"
38#include <linux/poll.h> 38#include <linux/poll.h>
39#include <linux/slab.h>
39#include <linux/smp_lock.h> 40#include <linux/smp_lock.h>
40 41
41static int drm_open_helper(struct inode *inode, struct file *filp, 42static int drm_open_helper(struct inode *inode, struct file *filp,
@@ -140,14 +141,16 @@ int drm_open(struct inode *inode, struct file *filp)
140 spin_unlock(&dev->count_lock); 141 spin_unlock(&dev->count_lock);
141 } 142 }
142out: 143out:
143 mutex_lock(&dev->struct_mutex); 144 if (!retcode) {
144 if (minor->type == DRM_MINOR_LEGACY) { 145 mutex_lock(&dev->struct_mutex);
145 BUG_ON((dev->dev_mapping != NULL) && 146 if (minor->type == DRM_MINOR_LEGACY) {
146 (dev->dev_mapping != inode->i_mapping)); 147 if (dev->dev_mapping == NULL)
147 if (dev->dev_mapping == NULL) 148 dev->dev_mapping = inode->i_mapping;
148 dev->dev_mapping = inode->i_mapping; 149 else if (dev->dev_mapping != inode->i_mapping)
150 retcode = -ENODEV;
151 }
152 mutex_unlock(&dev->struct_mutex);
149 } 153 }
150 mutex_unlock(&dev->struct_mutex);
151 154
152 return retcode; 155 return retcode;
153} 156}
diff --git a/drivers/gpu/drm/drm_hashtab.c b/drivers/gpu/drm/drm_hashtab.c
index f36b21c5b2e..a93d7b4ddaa 100644
--- a/drivers/gpu/drm/drm_hashtab.c
+++ b/drivers/gpu/drm/drm_hashtab.c
@@ -35,6 +35,7 @@
35#include "drmP.h" 35#include "drmP.h"
36#include "drm_hashtab.h" 36#include "drm_hashtab.h"
37#include <linux/hash.h> 37#include <linux/hash.h>
38#include <linux/slab.h>
38 39
39int drm_ht_create(struct drm_open_hash *ht, unsigned int order) 40int drm_ht_create(struct drm_open_hash *ht, unsigned int order)
40{ 41{
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index b98384dbd9a..a263b7070fc 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -36,6 +36,7 @@
36#include "drmP.h" 36#include "drmP.h"
37 37
38#include <linux/interrupt.h> /* For task queue support */ 38#include <linux/interrupt.h> /* For task queue support */
39#include <linux/slab.h>
39 40
40#include <linux/vgaarb.h> 41#include <linux/vgaarb.h>
41/** 42/**
@@ -475,6 +476,7 @@ void drm_vblank_off(struct drm_device *dev, int crtc)
475 unsigned long irqflags; 476 unsigned long irqflags;
476 477
477 spin_lock_irqsave(&dev->vbl_lock, irqflags); 478 spin_lock_irqsave(&dev->vbl_lock, irqflags);
479 dev->driver->disable_vblank(dev, crtc);
478 DRM_WAKEUP(&dev->vbl_queue[crtc]); 480 DRM_WAKEUP(&dev->vbl_queue[crtc]);
479 dev->vblank_enabled[crtc] = 0; 481 dev->vblank_enabled[crtc] = 0;
480 dev->last_vblank[crtc] = dev->driver->get_vblank_counter(dev, crtc); 482 dev->last_vblank[crtc] = dev->driver->get_vblank_counter(dev, crtc);
diff --git a/drivers/gpu/drm/drm_memory.c b/drivers/gpu/drm/drm_memory.c
index e4865f99989..7732268eced 100644
--- a/drivers/gpu/drm/drm_memory.c
+++ b/drivers/gpu/drm/drm_memory.c
@@ -77,7 +77,7 @@ static void *agp_remap(unsigned long offset, unsigned long size,
77 && (agpmem->bound + (agpmem->pages << PAGE_SHIFT)) >= 77 && (agpmem->bound + (agpmem->pages << PAGE_SHIFT)) >=
78 (offset + size)) 78 (offset + size))
79 break; 79 break;
80 if (!agpmem) 80 if (&agpmem->head == &dev->agp->memory)
81 return NULL; 81 return NULL;
82 82
83 /* 83 /*
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index e68ebf92fa2..2ea9ad4a8d6 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -37,6 +37,7 @@
37 */ 37 */
38 38
39#include <linux/pci.h> 39#include <linux/pci.h>
40#include <linux/slab.h>
40#include <linux/dma-mapping.h> 41#include <linux/dma-mapping.h>
41#include "drmP.h" 42#include "drmP.h"
42 43
diff --git a/drivers/gpu/drm/drm_proc.c b/drivers/gpu/drm/drm_proc.c
index d379c4f2892..a9ba6b69ad3 100644
--- a/drivers/gpu/drm/drm_proc.c
+++ b/drivers/gpu/drm/drm_proc.c
@@ -38,6 +38,7 @@
38 */ 38 */
39 39
40#include <linux/seq_file.h> 40#include <linux/seq_file.h>
41#include <linux/slab.h>
41#include "drmP.h" 42#include "drmP.h"
42 43
43/*************************************************** 44/***************************************************
diff --git a/drivers/gpu/drm/drm_scatter.c b/drivers/gpu/drm/drm_scatter.c
index c7823c863d4..9034c4c6100 100644
--- a/drivers/gpu/drm/drm_scatter.c
+++ b/drivers/gpu/drm/drm_scatter.c
@@ -32,6 +32,7 @@
32 */ 32 */
33 33
34#include <linux/vmalloc.h> 34#include <linux/vmalloc.h>
35#include <linux/slab.h>
35#include "drmP.h" 36#include "drmP.h"
36 37
37#define DEBUG_SCATTER 0 38#define DEBUG_SCATTER 0
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index ad73e141afd..a0c365f2e52 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -33,6 +33,7 @@
33 33
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/moduleparam.h> 35#include <linux/moduleparam.h>
36#include <linux/slab.h>
36#include "drmP.h" 37#include "drmP.h"
37#include "drm_core.h" 38#include "drm_core.h"
38 39
@@ -515,8 +516,6 @@ void drm_put_dev(struct drm_device *dev)
515 } 516 }
516 driver = dev->driver; 517 driver = dev->driver;
517 518
518 drm_vblank_cleanup(dev);
519
520 drm_lastclose(dev); 519 drm_lastclose(dev);
521 520
522 if (drm_core_has_MTRR(dev) && drm_core_has_AGP(dev) && 521 if (drm_core_has_MTRR(dev) && drm_core_has_AGP(dev) &&
@@ -536,6 +535,8 @@ void drm_put_dev(struct drm_device *dev)
536 dev->agp = NULL; 535 dev->agp = NULL;
537 } 536 }
538 537
538 drm_vblank_cleanup(dev);
539
539 list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head) 540 list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head)
540 drm_rmmap(dev, r_list->map); 541 drm_rmmap(dev, r_list->map);
541 drm_ht_remove(&dev->map_hash); 542 drm_ht_remove(&dev->map_hash);
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index 014ce24761b..25bbd30ed7a 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -14,6 +14,7 @@
14 14
15#include <linux/device.h> 15#include <linux/device.h>
16#include <linux/kdev_t.h> 16#include <linux/kdev_t.h>
17#include <linux/gfp.h>
17#include <linux/err.h> 18#include <linux/err.h>
18 19
19#include "drm_sysfs.h" 20#include "drm_sysfs.h"
@@ -353,7 +354,10 @@ static struct bin_attribute edid_attr = {
353int drm_sysfs_connector_add(struct drm_connector *connector) 354int drm_sysfs_connector_add(struct drm_connector *connector)
354{ 355{
355 struct drm_device *dev = connector->dev; 356 struct drm_device *dev = connector->dev;
356 int ret = 0, i, j; 357 int attr_cnt = 0;
358 int opt_cnt = 0;
359 int i;
360 int ret = 0;
357 361
358 /* We shouldn't get called more than once for the same connector */ 362 /* We shouldn't get called more than once for the same connector */
359 BUG_ON(device_is_registered(&connector->kdev)); 363 BUG_ON(device_is_registered(&connector->kdev));
@@ -376,8 +380,8 @@ int drm_sysfs_connector_add(struct drm_connector *connector)
376 380
377 /* Standard attributes */ 381 /* Standard attributes */
378 382
379 for (i = 0; i < ARRAY_SIZE(connector_attrs); i++) { 383 for (attr_cnt = 0; attr_cnt < ARRAY_SIZE(connector_attrs); attr_cnt++) {
380 ret = device_create_file(&connector->kdev, &connector_attrs[i]); 384 ret = device_create_file(&connector->kdev, &connector_attrs[attr_cnt]);
381 if (ret) 385 if (ret)
382 goto err_out_files; 386 goto err_out_files;
383 } 387 }
@@ -393,8 +397,8 @@ int drm_sysfs_connector_add(struct drm_connector *connector)
393 case DRM_MODE_CONNECTOR_SVIDEO: 397 case DRM_MODE_CONNECTOR_SVIDEO:
394 case DRM_MODE_CONNECTOR_Component: 398 case DRM_MODE_CONNECTOR_Component:
395 case DRM_MODE_CONNECTOR_TV: 399 case DRM_MODE_CONNECTOR_TV:
396 for (i = 0; i < ARRAY_SIZE(connector_attrs_opt1); i++) { 400 for (opt_cnt = 0; opt_cnt < ARRAY_SIZE(connector_attrs_opt1); opt_cnt++) {
397 ret = device_create_file(&connector->kdev, &connector_attrs_opt1[i]); 401 ret = device_create_file(&connector->kdev, &connector_attrs_opt1[opt_cnt]);
398 if (ret) 402 if (ret)
399 goto err_out_files; 403 goto err_out_files;
400 } 404 }
@@ -413,10 +417,10 @@ int drm_sysfs_connector_add(struct drm_connector *connector)
413 return 0; 417 return 0;
414 418
415err_out_files: 419err_out_files:
416 if (i > 0) 420 for (i = 0; i < opt_cnt; i++)
417 for (j = 0; j < i; j++) 421 device_remove_file(&connector->kdev, &connector_attrs_opt1[i]);
418 device_remove_file(&connector->kdev, 422 for (i = 0; i < attr_cnt; i++)
419 &connector_attrs[i]); 423 device_remove_file(&connector->kdev, &connector_attrs[i]);
420 device_unregister(&connector->kdev); 424 device_unregister(&connector->kdev);
421 425
422out: 426out:
diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
index 4ac900f4647..c3b13fb41d0 100644
--- a/drivers/gpu/drm/drm_vm.c
+++ b/drivers/gpu/drm/drm_vm.c
@@ -36,6 +36,7 @@
36#include "drmP.h" 36#include "drmP.h"
37#if defined(__ia64__) 37#if defined(__ia64__)
38#include <linux/efi.h> 38#include <linux/efi.h>
39#include <linux/slab.h>
39#endif 40#endif
40 41
41static void drm_vm_open(struct vm_area_struct *vma); 42static void drm_vm_open(struct vm_area_struct *vma);
diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
index de32d22a8c3..997d91707ad 100644
--- a/drivers/gpu/drm/i810/i810_dma.c
+++ b/drivers/gpu/drm/i810/i810_dma.c
@@ -36,6 +36,7 @@
36#include "i810_drv.h" 36#include "i810_drv.h"
37#include <linux/interrupt.h> /* For task queue support */ 37#include <linux/interrupt.h> /* For task queue support */
38#include <linux/delay.h> 38#include <linux/delay.h>
39#include <linux/slab.h>
39#include <linux/pagemap.h> 40#include <linux/pagemap.h>
40 41
41#define I810_BUF_FREE 2 42#define I810_BUF_FREE 2
diff --git a/drivers/gpu/drm/i830/i830_dma.c b/drivers/gpu/drm/i830/i830_dma.c
index 06bd732e646..65759a9a85c 100644
--- a/drivers/gpu/drm/i830/i830_dma.c
+++ b/drivers/gpu/drm/i830/i830_dma.c
@@ -38,6 +38,7 @@
38#include <linux/interrupt.h> /* For task queue support */ 38#include <linux/interrupt.h> /* For task queue support */
39#include <linux/pagemap.h> 39#include <linux/pagemap.h>
40#include <linux/delay.h> 40#include <linux/delay.h>
41#include <linux/slab.h>
41#include <asm/uaccess.h> 42#include <asm/uaccess.h>
42 43
43#define I830_BUF_FREE 2 44#define I830_BUF_FREE 2
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 1376dfe44c9..a0b8447b06e 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -28,6 +28,7 @@
28 28
29#include <linux/seq_file.h> 29#include <linux/seq_file.h>
30#include <linux/debugfs.h> 30#include <linux/debugfs.h>
31#include <linux/slab.h>
31#include "drmP.h" 32#include "drmP.h"
32#include "drm.h" 33#include "drm.h"
33#include "i915_drm.h" 34#include "i915_drm.h"
@@ -225,7 +226,7 @@ static int i915_gem_fence_regs_info(struct seq_file *m, void *data)
225 } else { 226 } else {
226 struct drm_i915_gem_object *obj_priv; 227 struct drm_i915_gem_object *obj_priv;
227 228
228 obj_priv = obj->driver_private; 229 obj_priv = to_intel_bo(obj);
229 seq_printf(m, "Fenced object[%2d] = %p: %s " 230 seq_printf(m, "Fenced object[%2d] = %p: %s "
230 "%08x %08zx %08x %s %08x %08x %d", 231 "%08x %08zx %08x %s %08x %08x %d",
231 i, obj, get_pin_flag(obj_priv), 232 i, obj, get_pin_flag(obj_priv),
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 8bfc0bbf13e..c3cfafcbfe7 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -38,6 +38,7 @@
38#include <linux/acpi.h> 38#include <linux/acpi.h>
39#include <linux/pnp.h> 39#include <linux/pnp.h>
40#include <linux/vga_switcheroo.h> 40#include <linux/vga_switcheroo.h>
41#include <linux/slab.h>
41 42
42/* Really want an OS-independent resettable timer. Would like to have 43/* Really want an OS-independent resettable timer. Would like to have
43 * this loop run for (eg) 3 sec, but have the timer reset every time 44 * this loop run for (eg) 3 sec, but have the timer reset every time
@@ -1356,6 +1357,8 @@ static void i915_setup_compression(struct drm_device *dev, int size)
1356 1357
1357 dev_priv->cfb_size = size; 1358 dev_priv->cfb_size = size;
1358 1359
1360 dev_priv->compressed_fb = compressed_fb;
1361
1359 if (IS_GM45(dev)) { 1362 if (IS_GM45(dev)) {
1360 g4x_disable_fbc(dev); 1363 g4x_disable_fbc(dev);
1361 I915_WRITE(DPFC_CB_BASE, compressed_fb->start); 1364 I915_WRITE(DPFC_CB_BASE, compressed_fb->start);
@@ -1363,12 +1366,22 @@ static void i915_setup_compression(struct drm_device *dev, int size)
1363 i8xx_disable_fbc(dev); 1366 i8xx_disable_fbc(dev);
1364 I915_WRITE(FBC_CFB_BASE, cfb_base); 1367 I915_WRITE(FBC_CFB_BASE, cfb_base);
1365 I915_WRITE(FBC_LL_BASE, ll_base); 1368 I915_WRITE(FBC_LL_BASE, ll_base);
1369 dev_priv->compressed_llb = compressed_llb;
1366 } 1370 }
1367 1371
1368 DRM_DEBUG("FBC base 0x%08lx, ll base 0x%08lx, size %dM\n", cfb_base, 1372 DRM_DEBUG("FBC base 0x%08lx, ll base 0x%08lx, size %dM\n", cfb_base,
1369 ll_base, size >> 20); 1373 ll_base, size >> 20);
1370} 1374}
1371 1375
1376static void i915_cleanup_compression(struct drm_device *dev)
1377{
1378 struct drm_i915_private *dev_priv = dev->dev_private;
1379
1380 drm_mm_put_block(dev_priv->compressed_fb);
1381 if (!IS_GM45(dev))
1382 drm_mm_put_block(dev_priv->compressed_llb);
1383}
1384
1372/* true = enable decode, false = disable decoder */ 1385/* true = enable decode, false = disable decoder */
1373static unsigned int i915_vga_set_decode(void *cookie, bool state) 1386static unsigned int i915_vga_set_decode(void *cookie, bool state)
1374{ 1387{
@@ -1786,6 +1799,8 @@ int i915_driver_unload(struct drm_device *dev)
1786 mutex_lock(&dev->struct_mutex); 1799 mutex_lock(&dev->struct_mutex);
1787 i915_gem_cleanup_ringbuffer(dev); 1800 i915_gem_cleanup_ringbuffer(dev);
1788 mutex_unlock(&dev->struct_mutex); 1801 mutex_unlock(&dev->struct_mutex);
1802 if (I915_HAS_FBC(dev) && i915_powersave)
1803 i915_cleanup_compression(dev);
1789 drm_mm_takedown(&dev_priv->vram); 1804 drm_mm_takedown(&dev_priv->vram);
1790 i915_gem_lastclose(dev); 1805 i915_gem_lastclose(dev);
1791 1806
@@ -1881,29 +1896,29 @@ struct drm_ioctl_desc i915_ioctls[] = {
1881 DRM_IOCTL_DEF(DRM_I915_GET_VBLANK_PIPE, i915_vblank_pipe_get, DRM_AUTH ), 1896 DRM_IOCTL_DEF(DRM_I915_GET_VBLANK_PIPE, i915_vblank_pipe_get, DRM_AUTH ),
1882 DRM_IOCTL_DEF(DRM_I915_VBLANK_SWAP, i915_vblank_swap, DRM_AUTH), 1897 DRM_IOCTL_DEF(DRM_I915_VBLANK_SWAP, i915_vblank_swap, DRM_AUTH),
1883 DRM_IOCTL_DEF(DRM_I915_HWS_ADDR, i915_set_status_page, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), 1898 DRM_IOCTL_DEF(DRM_I915_HWS_ADDR, i915_set_status_page, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
1884 DRM_IOCTL_DEF(DRM_I915_GEM_INIT, i915_gem_init_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), 1899 DRM_IOCTL_DEF(DRM_I915_GEM_INIT, i915_gem_init_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY|DRM_UNLOCKED),
1885 DRM_IOCTL_DEF(DRM_I915_GEM_EXECBUFFER, i915_gem_execbuffer, DRM_AUTH), 1900 DRM_IOCTL_DEF(DRM_I915_GEM_EXECBUFFER, i915_gem_execbuffer, DRM_AUTH|DRM_UNLOCKED),
1886 DRM_IOCTL_DEF(DRM_I915_GEM_EXECBUFFER2, i915_gem_execbuffer2, DRM_AUTH), 1901 DRM_IOCTL_DEF(DRM_I915_GEM_EXECBUFFER2, i915_gem_execbuffer2, DRM_AUTH|DRM_UNLOCKED),
1887 DRM_IOCTL_DEF(DRM_I915_GEM_PIN, i915_gem_pin_ioctl, DRM_AUTH|DRM_ROOT_ONLY), 1902 DRM_IOCTL_DEF(DRM_I915_GEM_PIN, i915_gem_pin_ioctl, DRM_AUTH|DRM_ROOT_ONLY|DRM_UNLOCKED),
1888 DRM_IOCTL_DEF(DRM_I915_GEM_UNPIN, i915_gem_unpin_ioctl, DRM_AUTH|DRM_ROOT_ONLY), 1903 DRM_IOCTL_DEF(DRM_I915_GEM_UNPIN, i915_gem_unpin_ioctl, DRM_AUTH|DRM_ROOT_ONLY|DRM_UNLOCKED),
1889 DRM_IOCTL_DEF(DRM_I915_GEM_BUSY, i915_gem_busy_ioctl, DRM_AUTH), 1904 DRM_IOCTL_DEF(DRM_I915_GEM_BUSY, i915_gem_busy_ioctl, DRM_AUTH|DRM_UNLOCKED),
1890 DRM_IOCTL_DEF(DRM_I915_GEM_THROTTLE, i915_gem_throttle_ioctl, DRM_AUTH), 1905 DRM_IOCTL_DEF(DRM_I915_GEM_THROTTLE, i915_gem_throttle_ioctl, DRM_AUTH|DRM_UNLOCKED),
1891 DRM_IOCTL_DEF(DRM_I915_GEM_ENTERVT, i915_gem_entervt_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), 1906 DRM_IOCTL_DEF(DRM_I915_GEM_ENTERVT, i915_gem_entervt_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY|DRM_UNLOCKED),
1892 DRM_IOCTL_DEF(DRM_I915_GEM_LEAVEVT, i915_gem_leavevt_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), 1907 DRM_IOCTL_DEF(DRM_I915_GEM_LEAVEVT, i915_gem_leavevt_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY|DRM_UNLOCKED),
1893 DRM_IOCTL_DEF(DRM_I915_GEM_CREATE, i915_gem_create_ioctl, 0), 1908 DRM_IOCTL_DEF(DRM_I915_GEM_CREATE, i915_gem_create_ioctl, DRM_UNLOCKED),
1894 DRM_IOCTL_DEF(DRM_I915_GEM_PREAD, i915_gem_pread_ioctl, 0), 1909 DRM_IOCTL_DEF(DRM_I915_GEM_PREAD, i915_gem_pread_ioctl, DRM_UNLOCKED),
1895 DRM_IOCTL_DEF(DRM_I915_GEM_PWRITE, i915_gem_pwrite_ioctl, 0), 1910 DRM_IOCTL_DEF(DRM_I915_GEM_PWRITE, i915_gem_pwrite_ioctl, DRM_UNLOCKED),
1896 DRM_IOCTL_DEF(DRM_I915_GEM_MMAP, i915_gem_mmap_ioctl, 0), 1911 DRM_IOCTL_DEF(DRM_I915_GEM_MMAP, i915_gem_mmap_ioctl, DRM_UNLOCKED),
1897 DRM_IOCTL_DEF(DRM_I915_GEM_MMAP_GTT, i915_gem_mmap_gtt_ioctl, 0), 1912 DRM_IOCTL_DEF(DRM_I915_GEM_MMAP_GTT, i915_gem_mmap_gtt_ioctl, DRM_UNLOCKED),
1898 DRM_IOCTL_DEF(DRM_I915_GEM_SET_DOMAIN, i915_gem_set_domain_ioctl, 0), 1913 DRM_IOCTL_DEF(DRM_I915_GEM_SET_DOMAIN, i915_gem_set_domain_ioctl, DRM_UNLOCKED),
1899 DRM_IOCTL_DEF(DRM_I915_GEM_SW_FINISH, i915_gem_sw_finish_ioctl, 0), 1914 DRM_IOCTL_DEF(DRM_I915_GEM_SW_FINISH, i915_gem_sw_finish_ioctl, DRM_UNLOCKED),
1900 DRM_IOCTL_DEF(DRM_I915_GEM_SET_TILING, i915_gem_set_tiling, 0), 1915 DRM_IOCTL_DEF(DRM_I915_GEM_SET_TILING, i915_gem_set_tiling, DRM_UNLOCKED),
1901 DRM_IOCTL_DEF(DRM_I915_GEM_GET_TILING, i915_gem_get_tiling, 0), 1916 DRM_IOCTL_DEF(DRM_I915_GEM_GET_TILING, i915_gem_get_tiling, DRM_UNLOCKED),
1902 DRM_IOCTL_DEF(DRM_I915_GEM_GET_APERTURE, i915_gem_get_aperture_ioctl, 0), 1917 DRM_IOCTL_DEF(DRM_I915_GEM_GET_APERTURE, i915_gem_get_aperture_ioctl, DRM_UNLOCKED),
1903 DRM_IOCTL_DEF(DRM_I915_GET_PIPE_FROM_CRTC_ID, intel_get_pipe_from_crtc_id, 0), 1918 DRM_IOCTL_DEF(DRM_I915_GET_PIPE_FROM_CRTC_ID, intel_get_pipe_from_crtc_id, DRM_UNLOCKED),
1904 DRM_IOCTL_DEF(DRM_I915_GEM_MADVISE, i915_gem_madvise_ioctl, 0), 1919 DRM_IOCTL_DEF(DRM_I915_GEM_MADVISE, i915_gem_madvise_ioctl, DRM_UNLOCKED),
1905 DRM_IOCTL_DEF(DRM_I915_OVERLAY_PUT_IMAGE, intel_overlay_put_image, DRM_MASTER|DRM_CONTROL_ALLOW), 1920 DRM_IOCTL_DEF(DRM_I915_OVERLAY_PUT_IMAGE, intel_overlay_put_image, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
1906 DRM_IOCTL_DEF(DRM_I915_OVERLAY_ATTRS, intel_overlay_attrs, DRM_MASTER|DRM_CONTROL_ALLOW), 1921 DRM_IOCTL_DEF(DRM_I915_OVERLAY_ATTRS, intel_overlay_attrs, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
1907}; 1922};
1908 1923
1909int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); 1924int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls);
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 1b2e95455c0..cc03537bb88 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -69,7 +69,8 @@ const static struct intel_device_info intel_845g_info = {
69}; 69};
70 70
71const static struct intel_device_info intel_i85x_info = { 71const static struct intel_device_info intel_i85x_info = {
72 .is_i8xx = 1, .is_mobile = 1, .cursor_needs_physical = 1, 72 .is_i8xx = 1, .is_i85x = 1, .is_mobile = 1,
73 .cursor_needs_physical = 1,
73}; 74};
74 75
75const static struct intel_device_info intel_i865g_info = { 76const static struct intel_device_info intel_i865g_info = {
@@ -80,14 +81,14 @@ const static struct intel_device_info intel_i915g_info = {
80 .is_i915g = 1, .is_i9xx = 1, .cursor_needs_physical = 1, 81 .is_i915g = 1, .is_i9xx = 1, .cursor_needs_physical = 1,
81}; 82};
82const static struct intel_device_info intel_i915gm_info = { 83const static struct intel_device_info intel_i915gm_info = {
83 .is_i9xx = 1, .is_mobile = 1, .has_fbc = 1, 84 .is_i9xx = 1, .is_mobile = 1,
84 .cursor_needs_physical = 1, 85 .cursor_needs_physical = 1,
85}; 86};
86const static struct intel_device_info intel_i945g_info = { 87const static struct intel_device_info intel_i945g_info = {
87 .is_i9xx = 1, .has_hotplug = 1, .cursor_needs_physical = 1, 88 .is_i9xx = 1, .has_hotplug = 1, .cursor_needs_physical = 1,
88}; 89};
89const static struct intel_device_info intel_i945gm_info = { 90const static struct intel_device_info intel_i945gm_info = {
90 .is_i945gm = 1, .is_i9xx = 1, .is_mobile = 1, .has_fbc = 1, 91 .is_i945gm = 1, .is_i9xx = 1, .is_mobile = 1,
91 .has_hotplug = 1, .cursor_needs_physical = 1, 92 .has_hotplug = 1, .cursor_needs_physical = 1,
92}; 93};
93 94
@@ -139,19 +140,19 @@ const static struct intel_device_info intel_ironlake_m_info = {
139 140
140const static struct intel_device_info intel_sandybridge_d_info = { 141const static struct intel_device_info intel_sandybridge_d_info = {
141 .is_i965g = 1, .is_i9xx = 1, .need_gfx_hws = 1, 142 .is_i965g = 1, .is_i9xx = 1, .need_gfx_hws = 1,
142 .has_hotplug = 1, 143 .has_hotplug = 1, .is_gen6 = 1,
143}; 144};
144 145
145const static struct intel_device_info intel_sandybridge_m_info = { 146const static struct intel_device_info intel_sandybridge_m_info = {
146 .is_i965g = 1, .is_mobile = 1, .is_i9xx = 1, .need_gfx_hws = 1, 147 .is_i965g = 1, .is_mobile = 1, .is_i9xx = 1, .need_gfx_hws = 1,
147 .has_hotplug = 1, 148 .has_hotplug = 1, .is_gen6 = 1,
148}; 149};
149 150
150const static struct pci_device_id pciidlist[] = { 151const static struct pci_device_id pciidlist[] = {
151 INTEL_VGA_DEVICE(0x3577, &intel_i830_info), 152 INTEL_VGA_DEVICE(0x3577, &intel_i830_info),
152 INTEL_VGA_DEVICE(0x2562, &intel_845g_info), 153 INTEL_VGA_DEVICE(0x2562, &intel_845g_info),
153 INTEL_VGA_DEVICE(0x3582, &intel_i85x_info), 154 INTEL_VGA_DEVICE(0x3582, &intel_i85x_info),
154 INTEL_VGA_DEVICE(0x35e8, &intel_i85x_info), 155 INTEL_VGA_DEVICE(0x358e, &intel_i85x_info),
155 INTEL_VGA_DEVICE(0x2572, &intel_i865g_info), 156 INTEL_VGA_DEVICE(0x2572, &intel_i865g_info),
156 INTEL_VGA_DEVICE(0x2582, &intel_i915g_info), 157 INTEL_VGA_DEVICE(0x2582, &intel_i915g_info),
157 INTEL_VGA_DEVICE(0x258a, &intel_i915g_info), 158 INTEL_VGA_DEVICE(0x258a, &intel_i915g_info),
@@ -361,7 +362,7 @@ int i965_reset(struct drm_device *dev, u8 flags)
361 !dev_priv->mm.suspended) { 362 !dev_priv->mm.suspended) {
362 drm_i915_ring_buffer_t *ring = &dev_priv->ring; 363 drm_i915_ring_buffer_t *ring = &dev_priv->ring;
363 struct drm_gem_object *obj = ring->ring_obj; 364 struct drm_gem_object *obj = ring->ring_obj;
364 struct drm_i915_gem_object *obj_priv = obj->driver_private; 365 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
365 dev_priv->mm.suspended = 0; 366 dev_priv->mm.suspended = 0;
366 367
367 /* Stop the ring if it's running. */ 368 /* Stop the ring if it's running. */
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 979439cfb82..6e4790065d9 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -195,6 +195,7 @@ struct intel_overlay;
195struct intel_device_info { 195struct intel_device_info {
196 u8 is_mobile : 1; 196 u8 is_mobile : 1;
197 u8 is_i8xx : 1; 197 u8 is_i8xx : 1;
198 u8 is_i85x : 1;
198 u8 is_i915g : 1; 199 u8 is_i915g : 1;
199 u8 is_i9xx : 1; 200 u8 is_i9xx : 1;
200 u8 is_i945gm : 1; 201 u8 is_i945gm : 1;
@@ -205,6 +206,7 @@ struct intel_device_info {
205 u8 is_g4x : 1; 206 u8 is_g4x : 1;
206 u8 is_pineview : 1; 207 u8 is_pineview : 1;
207 u8 is_ironlake : 1; 208 u8 is_ironlake : 1;
209 u8 is_gen6 : 1;
208 u8 has_fbc : 1; 210 u8 has_fbc : 1;
209 u8 has_rc6 : 1; 211 u8 has_rc6 : 1;
210 u8 has_pipe_cxsr : 1; 212 u8 has_pipe_cxsr : 1;
@@ -234,11 +236,14 @@ typedef struct drm_i915_private {
234 236
235 drm_dma_handle_t *status_page_dmah; 237 drm_dma_handle_t *status_page_dmah;
236 void *hw_status_page; 238 void *hw_status_page;
239 void *seqno_page;
237 dma_addr_t dma_status_page; 240 dma_addr_t dma_status_page;
238 uint32_t counter; 241 uint32_t counter;
239 unsigned int status_gfx_addr; 242 unsigned int status_gfx_addr;
243 unsigned int seqno_gfx_addr;
240 drm_local_map_t hws_map; 244 drm_local_map_t hws_map;
241 struct drm_gem_object *hws_obj; 245 struct drm_gem_object *hws_obj;
246 struct drm_gem_object *seqno_obj;
242 struct drm_gem_object *pwrctx; 247 struct drm_gem_object *pwrctx;
243 248
244 struct resource mch_res; 249 struct resource mch_res;
@@ -610,6 +615,8 @@ typedef struct drm_i915_private {
610 /* Reclocking support */ 615 /* Reclocking support */
611 bool render_reclock_avail; 616 bool render_reclock_avail;
612 bool lvds_downclock_avail; 617 bool lvds_downclock_avail;
618 /* indicate whether the LVDS EDID is OK */
619 bool lvds_edid_good;
613 /* indicates the reduced downclock for LVDS*/ 620 /* indicates the reduced downclock for LVDS*/
614 int lvds_downclock; 621 int lvds_downclock;
615 struct work_struct idle_work; 622 struct work_struct idle_work;
@@ -627,6 +634,9 @@ typedef struct drm_i915_private {
627 u8 max_delay; 634 u8 max_delay;
628 635
629 enum no_fbc_reason no_fbc_reason; 636 enum no_fbc_reason no_fbc_reason;
637
638 struct drm_mm_node *compressed_fb;
639 struct drm_mm_node *compressed_llb;
630} drm_i915_private_t; 640} drm_i915_private_t;
631 641
632/** driver private structure attached to each drm_gem_object */ 642/** driver private structure attached to each drm_gem_object */
@@ -730,6 +740,8 @@ struct drm_i915_gem_object {
730 atomic_t pending_flip; 740 atomic_t pending_flip;
731}; 741};
732 742
743#define to_intel_bo(x) ((struct drm_i915_gem_object *) (x)->driver_private)
744
733/** 745/**
734 * Request queue structure. 746 * Request queue structure.
735 * 747 *
@@ -1065,7 +1077,7 @@ extern int i915_wait_ring(struct drm_device * dev, int n, const char *caller);
1065 1077
1066#define IS_I830(dev) ((dev)->pci_device == 0x3577) 1078#define IS_I830(dev) ((dev)->pci_device == 0x3577)
1067#define IS_845G(dev) ((dev)->pci_device == 0x2562) 1079#define IS_845G(dev) ((dev)->pci_device == 0x2562)
1068#define IS_I85X(dev) ((dev)->pci_device == 0x3582) 1080#define IS_I85X(dev) (INTEL_INFO(dev)->is_i85x)
1069#define IS_I865G(dev) ((dev)->pci_device == 0x2572) 1081#define IS_I865G(dev) ((dev)->pci_device == 0x2572)
1070#define IS_GEN2(dev) (INTEL_INFO(dev)->is_i8xx) 1082#define IS_GEN2(dev) (INTEL_INFO(dev)->is_i8xx)
1071#define IS_I915G(dev) (INTEL_INFO(dev)->is_i915g) 1083#define IS_I915G(dev) (INTEL_INFO(dev)->is_i915g)
@@ -1084,6 +1096,7 @@ extern int i915_wait_ring(struct drm_device * dev, int n, const char *caller);
1084#define IS_IRONLAKE_M(dev) ((dev)->pci_device == 0x0046) 1096#define IS_IRONLAKE_M(dev) ((dev)->pci_device == 0x0046)
1085#define IS_IRONLAKE(dev) (INTEL_INFO(dev)->is_ironlake) 1097#define IS_IRONLAKE(dev) (INTEL_INFO(dev)->is_ironlake)
1086#define IS_I9XX(dev) (INTEL_INFO(dev)->is_i9xx) 1098#define IS_I9XX(dev) (INTEL_INFO(dev)->is_i9xx)
1099#define IS_GEN6(dev) (INTEL_INFO(dev)->is_gen6)
1087#define IS_MOBILE(dev) (INTEL_INFO(dev)->is_mobile) 1100#define IS_MOBILE(dev) (INTEL_INFO(dev)->is_mobile)
1088 1101
1089#define IS_GEN3(dev) (IS_I915G(dev) || \ 1102#define IS_GEN3(dev) (IS_I915G(dev) || \
@@ -1107,8 +1120,6 @@ extern int i915_wait_ring(struct drm_device * dev, int n, const char *caller);
1107 1120
1108#define I915_NEED_GFX_HWS(dev) (INTEL_INFO(dev)->need_gfx_hws) 1121#define I915_NEED_GFX_HWS(dev) (INTEL_INFO(dev)->need_gfx_hws)
1109 1122
1110#define IS_GEN6(dev) ((dev)->pci_device == 0x0102)
1111
1112/* With the 945 and later, Y tiling got adjusted so that it was 32 128-byte 1123/* With the 945 and later, Y tiling got adjusted so that it was 32 128-byte
1113 * rows, which changed the alignment requirements and fence programming. 1124 * rows, which changed the alignment requirements and fence programming.
1114 */ 1125 */
@@ -1131,6 +1142,7 @@ extern int i915_wait_ring(struct drm_device * dev, int n, const char *caller);
1131 1142
1132#define HAS_PCH_SPLIT(dev) (IS_IRONLAKE(dev) || \ 1143#define HAS_PCH_SPLIT(dev) (IS_IRONLAKE(dev) || \
1133 IS_GEN6(dev)) 1144 IS_GEN6(dev))
1145#define HAS_PIPE_CONTROL(dev) (IS_IRONLAKE(dev) || IS_GEN6(dev))
1134 1146
1135#define PRIMARY_RINGBUFFER_SIZE (128*1024) 1147#define PRIMARY_RINGBUFFER_SIZE (128*1024)
1136 1148
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index fba37e9f775..ef3d91dda71 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -31,6 +31,7 @@
31#include "i915_drv.h" 31#include "i915_drv.h"
32#include "i915_trace.h" 32#include "i915_trace.h"
33#include "intel_drv.h" 33#include "intel_drv.h"
34#include <linux/slab.h>
34#include <linux/swap.h> 35#include <linux/swap.h>
35#include <linux/pci.h> 36#include <linux/pci.h>
36 37
@@ -162,7 +163,7 @@ fast_shmem_read(struct page **pages,
162static int i915_gem_object_needs_bit17_swizzle(struct drm_gem_object *obj) 163static int i915_gem_object_needs_bit17_swizzle(struct drm_gem_object *obj)
163{ 164{
164 drm_i915_private_t *dev_priv = obj->dev->dev_private; 165 drm_i915_private_t *dev_priv = obj->dev->dev_private;
165 struct drm_i915_gem_object *obj_priv = obj->driver_private; 166 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
166 167
167 return dev_priv->mm.bit_6_swizzle_x == I915_BIT_6_SWIZZLE_9_10_17 && 168 return dev_priv->mm.bit_6_swizzle_x == I915_BIT_6_SWIZZLE_9_10_17 &&
168 obj_priv->tiling_mode != I915_TILING_NONE; 169 obj_priv->tiling_mode != I915_TILING_NONE;
@@ -263,7 +264,7 @@ i915_gem_shmem_pread_fast(struct drm_device *dev, struct drm_gem_object *obj,
263 struct drm_i915_gem_pread *args, 264 struct drm_i915_gem_pread *args,
264 struct drm_file *file_priv) 265 struct drm_file *file_priv)
265{ 266{
266 struct drm_i915_gem_object *obj_priv = obj->driver_private; 267 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
267 ssize_t remain; 268 ssize_t remain;
268 loff_t offset, page_base; 269 loff_t offset, page_base;
269 char __user *user_data; 270 char __user *user_data;
@@ -284,7 +285,7 @@ i915_gem_shmem_pread_fast(struct drm_device *dev, struct drm_gem_object *obj,
284 if (ret != 0) 285 if (ret != 0)
285 goto fail_put_pages; 286 goto fail_put_pages;
286 287
287 obj_priv = obj->driver_private; 288 obj_priv = to_intel_bo(obj);
288 offset = args->offset; 289 offset = args->offset;
289 290
290 while (remain > 0) { 291 while (remain > 0) {
@@ -353,7 +354,7 @@ i915_gem_shmem_pread_slow(struct drm_device *dev, struct drm_gem_object *obj,
353 struct drm_i915_gem_pread *args, 354 struct drm_i915_gem_pread *args,
354 struct drm_file *file_priv) 355 struct drm_file *file_priv)
355{ 356{
356 struct drm_i915_gem_object *obj_priv = obj->driver_private; 357 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
357 struct mm_struct *mm = current->mm; 358 struct mm_struct *mm = current->mm;
358 struct page **user_pages; 359 struct page **user_pages;
359 ssize_t remain; 360 ssize_t remain;
@@ -402,7 +403,7 @@ i915_gem_shmem_pread_slow(struct drm_device *dev, struct drm_gem_object *obj,
402 if (ret != 0) 403 if (ret != 0)
403 goto fail_put_pages; 404 goto fail_put_pages;
404 405
405 obj_priv = obj->driver_private; 406 obj_priv = to_intel_bo(obj);
406 offset = args->offset; 407 offset = args->offset;
407 408
408 while (remain > 0) { 409 while (remain > 0) {
@@ -478,7 +479,7 @@ i915_gem_pread_ioctl(struct drm_device *dev, void *data,
478 obj = drm_gem_object_lookup(dev, file_priv, args->handle); 479 obj = drm_gem_object_lookup(dev, file_priv, args->handle);
479 if (obj == NULL) 480 if (obj == NULL)
480 return -EBADF; 481 return -EBADF;
481 obj_priv = obj->driver_private; 482 obj_priv = to_intel_bo(obj);
482 483
483 /* Bounds check source. 484 /* Bounds check source.
484 * 485 *
@@ -580,7 +581,7 @@ i915_gem_gtt_pwrite_fast(struct drm_device *dev, struct drm_gem_object *obj,
580 struct drm_i915_gem_pwrite *args, 581 struct drm_i915_gem_pwrite *args,
581 struct drm_file *file_priv) 582 struct drm_file *file_priv)
582{ 583{
583 struct drm_i915_gem_object *obj_priv = obj->driver_private; 584 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
584 drm_i915_private_t *dev_priv = dev->dev_private; 585 drm_i915_private_t *dev_priv = dev->dev_private;
585 ssize_t remain; 586 ssize_t remain;
586 loff_t offset, page_base; 587 loff_t offset, page_base;
@@ -604,7 +605,7 @@ i915_gem_gtt_pwrite_fast(struct drm_device *dev, struct drm_gem_object *obj,
604 if (ret) 605 if (ret)
605 goto fail; 606 goto fail;
606 607
607 obj_priv = obj->driver_private; 608 obj_priv = to_intel_bo(obj);
608 offset = obj_priv->gtt_offset + args->offset; 609 offset = obj_priv->gtt_offset + args->offset;
609 610
610 while (remain > 0) { 611 while (remain > 0) {
@@ -654,7 +655,7 @@ i915_gem_gtt_pwrite_slow(struct drm_device *dev, struct drm_gem_object *obj,
654 struct drm_i915_gem_pwrite *args, 655 struct drm_i915_gem_pwrite *args,
655 struct drm_file *file_priv) 656 struct drm_file *file_priv)
656{ 657{
657 struct drm_i915_gem_object *obj_priv = obj->driver_private; 658 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
658 drm_i915_private_t *dev_priv = dev->dev_private; 659 drm_i915_private_t *dev_priv = dev->dev_private;
659 ssize_t remain; 660 ssize_t remain;
660 loff_t gtt_page_base, offset; 661 loff_t gtt_page_base, offset;
@@ -698,7 +699,7 @@ i915_gem_gtt_pwrite_slow(struct drm_device *dev, struct drm_gem_object *obj,
698 if (ret) 699 if (ret)
699 goto out_unpin_object; 700 goto out_unpin_object;
700 701
701 obj_priv = obj->driver_private; 702 obj_priv = to_intel_bo(obj);
702 offset = obj_priv->gtt_offset + args->offset; 703 offset = obj_priv->gtt_offset + args->offset;
703 704
704 while (remain > 0) { 705 while (remain > 0) {
@@ -760,7 +761,7 @@ i915_gem_shmem_pwrite_fast(struct drm_device *dev, struct drm_gem_object *obj,
760 struct drm_i915_gem_pwrite *args, 761 struct drm_i915_gem_pwrite *args,
761 struct drm_file *file_priv) 762 struct drm_file *file_priv)
762{ 763{
763 struct drm_i915_gem_object *obj_priv = obj->driver_private; 764 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
764 ssize_t remain; 765 ssize_t remain;
765 loff_t offset, page_base; 766 loff_t offset, page_base;
766 char __user *user_data; 767 char __user *user_data;
@@ -780,7 +781,7 @@ i915_gem_shmem_pwrite_fast(struct drm_device *dev, struct drm_gem_object *obj,
780 if (ret != 0) 781 if (ret != 0)
781 goto fail_put_pages; 782 goto fail_put_pages;
782 783
783 obj_priv = obj->driver_private; 784 obj_priv = to_intel_bo(obj);
784 offset = args->offset; 785 offset = args->offset;
785 obj_priv->dirty = 1; 786 obj_priv->dirty = 1;
786 787
@@ -828,7 +829,7 @@ i915_gem_shmem_pwrite_slow(struct drm_device *dev, struct drm_gem_object *obj,
828 struct drm_i915_gem_pwrite *args, 829 struct drm_i915_gem_pwrite *args,
829 struct drm_file *file_priv) 830 struct drm_file *file_priv)
830{ 831{
831 struct drm_i915_gem_object *obj_priv = obj->driver_private; 832 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
832 struct mm_struct *mm = current->mm; 833 struct mm_struct *mm = current->mm;
833 struct page **user_pages; 834 struct page **user_pages;
834 ssize_t remain; 835 ssize_t remain;
@@ -876,7 +877,7 @@ i915_gem_shmem_pwrite_slow(struct drm_device *dev, struct drm_gem_object *obj,
876 if (ret != 0) 877 if (ret != 0)
877 goto fail_put_pages; 878 goto fail_put_pages;
878 879
879 obj_priv = obj->driver_private; 880 obj_priv = to_intel_bo(obj);
880 offset = args->offset; 881 offset = args->offset;
881 obj_priv->dirty = 1; 882 obj_priv->dirty = 1;
882 883
@@ -951,7 +952,7 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data,
951 obj = drm_gem_object_lookup(dev, file_priv, args->handle); 952 obj = drm_gem_object_lookup(dev, file_priv, args->handle);
952 if (obj == NULL) 953 if (obj == NULL)
953 return -EBADF; 954 return -EBADF;
954 obj_priv = obj->driver_private; 955 obj_priv = to_intel_bo(obj);
955 956
956 /* Bounds check destination. 957 /* Bounds check destination.
957 * 958 *
@@ -1033,7 +1034,7 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,
1033 obj = drm_gem_object_lookup(dev, file_priv, args->handle); 1034 obj = drm_gem_object_lookup(dev, file_priv, args->handle);
1034 if (obj == NULL) 1035 if (obj == NULL)
1035 return -EBADF; 1036 return -EBADF;
1036 obj_priv = obj->driver_private; 1037 obj_priv = to_intel_bo(obj);
1037 1038
1038 mutex_lock(&dev->struct_mutex); 1039 mutex_lock(&dev->struct_mutex);
1039 1040
@@ -1095,7 +1096,7 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,
1095 DRM_INFO("%s: sw_finish %d (%p %zd)\n", 1096 DRM_INFO("%s: sw_finish %d (%p %zd)\n",
1096 __func__, args->handle, obj, obj->size); 1097 __func__, args->handle, obj, obj->size);
1097#endif 1098#endif
1098 obj_priv = obj->driver_private; 1099 obj_priv = to_intel_bo(obj);
1099 1100
1100 /* Pinned buffers may be scanout, so flush the cache */ 1101 /* Pinned buffers may be scanout, so flush the cache */
1101 if (obj_priv->pin_count) 1102 if (obj_priv->pin_count)
@@ -1166,7 +1167,7 @@ int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
1166 struct drm_gem_object *obj = vma->vm_private_data; 1167 struct drm_gem_object *obj = vma->vm_private_data;
1167 struct drm_device *dev = obj->dev; 1168 struct drm_device *dev = obj->dev;
1168 struct drm_i915_private *dev_priv = dev->dev_private; 1169 struct drm_i915_private *dev_priv = dev->dev_private;
1169 struct drm_i915_gem_object *obj_priv = obj->driver_private; 1170 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
1170 pgoff_t page_offset; 1171 pgoff_t page_offset;
1171 unsigned long pfn; 1172 unsigned long pfn;
1172 int ret = 0; 1173 int ret = 0;
@@ -1233,7 +1234,7 @@ i915_gem_create_mmap_offset(struct drm_gem_object *obj)
1233{ 1234{
1234 struct drm_device *dev = obj->dev; 1235 struct drm_device *dev = obj->dev;
1235 struct drm_gem_mm *mm = dev->mm_private; 1236 struct drm_gem_mm *mm = dev->mm_private;
1236 struct drm_i915_gem_object *obj_priv = obj->driver_private; 1237 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
1237 struct drm_map_list *list; 1238 struct drm_map_list *list;
1238 struct drm_local_map *map; 1239 struct drm_local_map *map;
1239 int ret = 0; 1240 int ret = 0;
@@ -1304,7 +1305,7 @@ void
1304i915_gem_release_mmap(struct drm_gem_object *obj) 1305i915_gem_release_mmap(struct drm_gem_object *obj)
1305{ 1306{
1306 struct drm_device *dev = obj->dev; 1307 struct drm_device *dev = obj->dev;
1307 struct drm_i915_gem_object *obj_priv = obj->driver_private; 1308 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
1308 1309
1309 if (dev->dev_mapping) 1310 if (dev->dev_mapping)
1310 unmap_mapping_range(dev->dev_mapping, 1311 unmap_mapping_range(dev->dev_mapping,
@@ -1315,7 +1316,7 @@ static void
1315i915_gem_free_mmap_offset(struct drm_gem_object *obj) 1316i915_gem_free_mmap_offset(struct drm_gem_object *obj)
1316{ 1317{
1317 struct drm_device *dev = obj->dev; 1318 struct drm_device *dev = obj->dev;
1318 struct drm_i915_gem_object *obj_priv = obj->driver_private; 1319 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
1319 struct drm_gem_mm *mm = dev->mm_private; 1320 struct drm_gem_mm *mm = dev->mm_private;
1320 struct drm_map_list *list; 1321 struct drm_map_list *list;
1321 1322
@@ -1346,7 +1347,7 @@ static uint32_t
1346i915_gem_get_gtt_alignment(struct drm_gem_object *obj) 1347i915_gem_get_gtt_alignment(struct drm_gem_object *obj)
1347{ 1348{
1348 struct drm_device *dev = obj->dev; 1349 struct drm_device *dev = obj->dev;
1349 struct drm_i915_gem_object *obj_priv = obj->driver_private; 1350 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
1350 int start, i; 1351 int start, i;
1351 1352
1352 /* 1353 /*
@@ -1405,7 +1406,7 @@ i915_gem_mmap_gtt_ioctl(struct drm_device *dev, void *data,
1405 1406
1406 mutex_lock(&dev->struct_mutex); 1407 mutex_lock(&dev->struct_mutex);
1407 1408
1408 obj_priv = obj->driver_private; 1409 obj_priv = to_intel_bo(obj);
1409 1410
1410 if (obj_priv->madv != I915_MADV_WILLNEED) { 1411 if (obj_priv->madv != I915_MADV_WILLNEED) {
1411 DRM_ERROR("Attempting to mmap a purgeable buffer\n"); 1412 DRM_ERROR("Attempting to mmap a purgeable buffer\n");
@@ -1449,7 +1450,7 @@ i915_gem_mmap_gtt_ioctl(struct drm_device *dev, void *data,
1449void 1450void
1450i915_gem_object_put_pages(struct drm_gem_object *obj) 1451i915_gem_object_put_pages(struct drm_gem_object *obj)
1451{ 1452{
1452 struct drm_i915_gem_object *obj_priv = obj->driver_private; 1453 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
1453 int page_count = obj->size / PAGE_SIZE; 1454 int page_count = obj->size / PAGE_SIZE;
1454 int i; 1455 int i;
1455 1456
@@ -1466,9 +1467,6 @@ i915_gem_object_put_pages(struct drm_gem_object *obj)
1466 obj_priv->dirty = 0; 1467 obj_priv->dirty = 0;
1467 1468
1468 for (i = 0; i < page_count; i++) { 1469 for (i = 0; i < page_count; i++) {
1469 if (obj_priv->pages[i] == NULL)
1470 break;
1471
1472 if (obj_priv->dirty) 1470 if (obj_priv->dirty)
1473 set_page_dirty(obj_priv->pages[i]); 1471 set_page_dirty(obj_priv->pages[i]);
1474 1472
@@ -1488,7 +1486,7 @@ i915_gem_object_move_to_active(struct drm_gem_object *obj, uint32_t seqno)
1488{ 1486{
1489 struct drm_device *dev = obj->dev; 1487 struct drm_device *dev = obj->dev;
1490 drm_i915_private_t *dev_priv = dev->dev_private; 1488 drm_i915_private_t *dev_priv = dev->dev_private;
1491 struct drm_i915_gem_object *obj_priv = obj->driver_private; 1489 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
1492 1490
1493 /* Add a reference if we're newly entering the active list. */ 1491 /* Add a reference if we're newly entering the active list. */
1494 if (!obj_priv->active) { 1492 if (!obj_priv->active) {
@@ -1508,7 +1506,7 @@ i915_gem_object_move_to_flushing(struct drm_gem_object *obj)
1508{ 1506{
1509 struct drm_device *dev = obj->dev; 1507 struct drm_device *dev = obj->dev;
1510 drm_i915_private_t *dev_priv = dev->dev_private; 1508 drm_i915_private_t *dev_priv = dev->dev_private;
1511 struct drm_i915_gem_object *obj_priv = obj->driver_private; 1509 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
1512 1510
1513 BUG_ON(!obj_priv->active); 1511 BUG_ON(!obj_priv->active);
1514 list_move_tail(&obj_priv->list, &dev_priv->mm.flushing_list); 1512 list_move_tail(&obj_priv->list, &dev_priv->mm.flushing_list);
@@ -1519,7 +1517,7 @@ i915_gem_object_move_to_flushing(struct drm_gem_object *obj)
1519static void 1517static void
1520i915_gem_object_truncate(struct drm_gem_object *obj) 1518i915_gem_object_truncate(struct drm_gem_object *obj)
1521{ 1519{
1522 struct drm_i915_gem_object *obj_priv = obj->driver_private; 1520 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
1523 struct inode *inode; 1521 struct inode *inode;
1524 1522
1525 inode = obj->filp->f_path.dentry->d_inode; 1523 inode = obj->filp->f_path.dentry->d_inode;
@@ -1540,7 +1538,7 @@ i915_gem_object_move_to_inactive(struct drm_gem_object *obj)
1540{ 1538{
1541 struct drm_device *dev = obj->dev; 1539 struct drm_device *dev = obj->dev;
1542 drm_i915_private_t *dev_priv = dev->dev_private; 1540 drm_i915_private_t *dev_priv = dev->dev_private;
1543 struct drm_i915_gem_object *obj_priv = obj->driver_private; 1541 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
1544 1542
1545 i915_verify_inactive(dev, __FILE__, __LINE__); 1543 i915_verify_inactive(dev, __FILE__, __LINE__);
1546 if (obj_priv->pin_count != 0) 1544 if (obj_priv->pin_count != 0)
@@ -1590,6 +1588,13 @@ i915_gem_process_flushing_list(struct drm_device *dev,
1590 } 1588 }
1591} 1589}
1592 1590
1591#define PIPE_CONTROL_FLUSH(addr) \
1592 OUT_RING(GFX_OP_PIPE_CONTROL | PIPE_CONTROL_QW_WRITE | \
1593 PIPE_CONTROL_DEPTH_STALL); \
1594 OUT_RING(addr | PIPE_CONTROL_GLOBAL_GTT); \
1595 OUT_RING(0); \
1596 OUT_RING(0); \
1597
1593/** 1598/**
1594 * Creates a new sequence number, emitting a write of it to the status page 1599 * Creates a new sequence number, emitting a write of it to the status page
1595 * plus an interrupt, which will trigger i915_user_interrupt_handler. 1600 * plus an interrupt, which will trigger i915_user_interrupt_handler.
@@ -1624,13 +1629,47 @@ i915_add_request(struct drm_device *dev, struct drm_file *file_priv,
1624 if (dev_priv->mm.next_gem_seqno == 0) 1629 if (dev_priv->mm.next_gem_seqno == 0)
1625 dev_priv->mm.next_gem_seqno++; 1630 dev_priv->mm.next_gem_seqno++;
1626 1631
1627 BEGIN_LP_RING(4); 1632 if (HAS_PIPE_CONTROL(dev)) {
1628 OUT_RING(MI_STORE_DWORD_INDEX); 1633 u32 scratch_addr = dev_priv->seqno_gfx_addr + 128;
1629 OUT_RING(I915_GEM_HWS_INDEX << MI_STORE_DWORD_INDEX_SHIFT);
1630 OUT_RING(seqno);
1631 1634
1632 OUT_RING(MI_USER_INTERRUPT); 1635 /*
1633 ADVANCE_LP_RING(); 1636 * Workaround qword write incoherence by flushing the
1637 * PIPE_NOTIFY buffers out to memory before requesting
1638 * an interrupt.
1639 */
1640 BEGIN_LP_RING(32);
1641 OUT_RING(GFX_OP_PIPE_CONTROL | PIPE_CONTROL_QW_WRITE |
1642 PIPE_CONTROL_WC_FLUSH | PIPE_CONTROL_TC_FLUSH);
1643 OUT_RING(dev_priv->seqno_gfx_addr | PIPE_CONTROL_GLOBAL_GTT);
1644 OUT_RING(seqno);
1645 OUT_RING(0);
1646 PIPE_CONTROL_FLUSH(scratch_addr);
1647 scratch_addr += 128; /* write to separate cachelines */
1648 PIPE_CONTROL_FLUSH(scratch_addr);
1649 scratch_addr += 128;
1650 PIPE_CONTROL_FLUSH(scratch_addr);
1651 scratch_addr += 128;
1652 PIPE_CONTROL_FLUSH(scratch_addr);
1653 scratch_addr += 128;
1654 PIPE_CONTROL_FLUSH(scratch_addr);
1655 scratch_addr += 128;
1656 PIPE_CONTROL_FLUSH(scratch_addr);
1657 OUT_RING(GFX_OP_PIPE_CONTROL | PIPE_CONTROL_QW_WRITE |
1658 PIPE_CONTROL_WC_FLUSH | PIPE_CONTROL_TC_FLUSH |
1659 PIPE_CONTROL_NOTIFY);
1660 OUT_RING(dev_priv->seqno_gfx_addr | PIPE_CONTROL_GLOBAL_GTT);
1661 OUT_RING(seqno);
1662 OUT_RING(0);
1663 ADVANCE_LP_RING();
1664 } else {
1665 BEGIN_LP_RING(4);
1666 OUT_RING(MI_STORE_DWORD_INDEX);
1667 OUT_RING(I915_GEM_HWS_INDEX << MI_STORE_DWORD_INDEX_SHIFT);
1668 OUT_RING(seqno);
1669
1670 OUT_RING(MI_USER_INTERRUPT);
1671 ADVANCE_LP_RING();
1672 }
1634 1673
1635 DRM_DEBUG_DRIVER("%d\n", seqno); 1674 DRM_DEBUG_DRIVER("%d\n", seqno);
1636 1675
@@ -1754,7 +1793,10 @@ i915_get_gem_seqno(struct drm_device *dev)
1754{ 1793{
1755 drm_i915_private_t *dev_priv = dev->dev_private; 1794 drm_i915_private_t *dev_priv = dev->dev_private;
1756 1795
1757 return READ_HWSP(dev_priv, I915_GEM_HWS_INDEX); 1796 if (HAS_PIPE_CONTROL(dev))
1797 return ((volatile u32 *)(dev_priv->seqno_page))[0];
1798 else
1799 return READ_HWSP(dev_priv, I915_GEM_HWS_INDEX);
1758} 1800}
1759 1801
1760/** 1802/**
@@ -1967,7 +2009,7 @@ static int
1967i915_gem_object_wait_rendering(struct drm_gem_object *obj) 2009i915_gem_object_wait_rendering(struct drm_gem_object *obj)
1968{ 2010{
1969 struct drm_device *dev = obj->dev; 2011 struct drm_device *dev = obj->dev;
1970 struct drm_i915_gem_object *obj_priv = obj->driver_private; 2012 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
1971 int ret; 2013 int ret;
1972 2014
1973 /* This function only exists to support waiting for existing rendering, 2015 /* This function only exists to support waiting for existing rendering,
@@ -1999,7 +2041,7 @@ i915_gem_object_unbind(struct drm_gem_object *obj)
1999{ 2041{
2000 struct drm_device *dev = obj->dev; 2042 struct drm_device *dev = obj->dev;
2001 drm_i915_private_t *dev_priv = dev->dev_private; 2043 drm_i915_private_t *dev_priv = dev->dev_private;
2002 struct drm_i915_gem_object *obj_priv = obj->driver_private; 2044 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
2003 int ret = 0; 2045 int ret = 0;
2004 2046
2005#if WATCH_BUF 2047#if WATCH_BUF
@@ -2175,7 +2217,7 @@ i915_gem_evict_something(struct drm_device *dev, int min_size)
2175#if WATCH_LRU 2217#if WATCH_LRU
2176 DRM_INFO("%s: evicting %p\n", __func__, obj); 2218 DRM_INFO("%s: evicting %p\n", __func__, obj);
2177#endif 2219#endif
2178 obj_priv = obj->driver_private; 2220 obj_priv = to_intel_bo(obj);
2179 BUG_ON(obj_priv->pin_count != 0); 2221 BUG_ON(obj_priv->pin_count != 0);
2180 BUG_ON(obj_priv->active); 2222 BUG_ON(obj_priv->active);
2181 2223
@@ -2227,11 +2269,6 @@ i915_gem_evict_something(struct drm_device *dev, int min_size)
2227 seqno = i915_add_request(dev, NULL, obj->write_domain); 2269 seqno = i915_add_request(dev, NULL, obj->write_domain);
2228 if (seqno == 0) 2270 if (seqno == 0)
2229 return -ENOMEM; 2271 return -ENOMEM;
2230
2231 ret = i915_wait_request(dev, seqno);
2232 if (ret)
2233 return ret;
2234
2235 continue; 2272 continue;
2236 } 2273 }
2237 } 2274 }
@@ -2251,12 +2288,11 @@ int
2251i915_gem_object_get_pages(struct drm_gem_object *obj, 2288i915_gem_object_get_pages(struct drm_gem_object *obj,
2252 gfp_t gfpmask) 2289 gfp_t gfpmask)
2253{ 2290{
2254 struct drm_i915_gem_object *obj_priv = obj->driver_private; 2291 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
2255 int page_count, i; 2292 int page_count, i;
2256 struct address_space *mapping; 2293 struct address_space *mapping;
2257 struct inode *inode; 2294 struct inode *inode;
2258 struct page *page; 2295 struct page *page;
2259 int ret;
2260 2296
2261 if (obj_priv->pages_refcount++ != 0) 2297 if (obj_priv->pages_refcount++ != 0)
2262 return 0; 2298 return 0;
@@ -2279,11 +2315,9 @@ i915_gem_object_get_pages(struct drm_gem_object *obj,
2279 mapping_gfp_mask (mapping) | 2315 mapping_gfp_mask (mapping) |
2280 __GFP_COLD | 2316 __GFP_COLD |
2281 gfpmask); 2317 gfpmask);
2282 if (IS_ERR(page)) { 2318 if (IS_ERR(page))
2283 ret = PTR_ERR(page); 2319 goto err_pages;
2284 i915_gem_object_put_pages(obj); 2320
2285 return ret;
2286 }
2287 obj_priv->pages[i] = page; 2321 obj_priv->pages[i] = page;
2288 } 2322 }
2289 2323
@@ -2291,6 +2325,15 @@ i915_gem_object_get_pages(struct drm_gem_object *obj,
2291 i915_gem_object_do_bit_17_swizzle(obj); 2325 i915_gem_object_do_bit_17_swizzle(obj);
2292 2326
2293 return 0; 2327 return 0;
2328
2329err_pages:
2330 while (i--)
2331 page_cache_release(obj_priv->pages[i]);
2332
2333 drm_free_large(obj_priv->pages);
2334 obj_priv->pages = NULL;
2335 obj_priv->pages_refcount--;
2336 return PTR_ERR(page);
2294} 2337}
2295 2338
2296static void sandybridge_write_fence_reg(struct drm_i915_fence_reg *reg) 2339static void sandybridge_write_fence_reg(struct drm_i915_fence_reg *reg)
@@ -2298,7 +2341,7 @@ static void sandybridge_write_fence_reg(struct drm_i915_fence_reg *reg)
2298 struct drm_gem_object *obj = reg->obj; 2341 struct drm_gem_object *obj = reg->obj;
2299 struct drm_device *dev = obj->dev; 2342 struct drm_device *dev = obj->dev;
2300 drm_i915_private_t *dev_priv = dev->dev_private; 2343 drm_i915_private_t *dev_priv = dev->dev_private;
2301 struct drm_i915_gem_object *obj_priv = obj->driver_private; 2344 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
2302 int regnum = obj_priv->fence_reg; 2345 int regnum = obj_priv->fence_reg;
2303 uint64_t val; 2346 uint64_t val;
2304 2347
@@ -2320,7 +2363,7 @@ static void i965_write_fence_reg(struct drm_i915_fence_reg *reg)
2320 struct drm_gem_object *obj = reg->obj; 2363 struct drm_gem_object *obj = reg->obj;
2321 struct drm_device *dev = obj->dev; 2364 struct drm_device *dev = obj->dev;
2322 drm_i915_private_t *dev_priv = dev->dev_private; 2365 drm_i915_private_t *dev_priv = dev->dev_private;
2323 struct drm_i915_gem_object *obj_priv = obj->driver_private; 2366 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
2324 int regnum = obj_priv->fence_reg; 2367 int regnum = obj_priv->fence_reg;
2325 uint64_t val; 2368 uint64_t val;
2326 2369
@@ -2340,7 +2383,7 @@ static void i915_write_fence_reg(struct drm_i915_fence_reg *reg)
2340 struct drm_gem_object *obj = reg->obj; 2383 struct drm_gem_object *obj = reg->obj;
2341 struct drm_device *dev = obj->dev; 2384 struct drm_device *dev = obj->dev;
2342 drm_i915_private_t *dev_priv = dev->dev_private; 2385 drm_i915_private_t *dev_priv = dev->dev_private;
2343 struct drm_i915_gem_object *obj_priv = obj->driver_private; 2386 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
2344 int regnum = obj_priv->fence_reg; 2387 int regnum = obj_priv->fence_reg;
2345 int tile_width; 2388 int tile_width;
2346 uint32_t fence_reg, val; 2389 uint32_t fence_reg, val;
@@ -2363,6 +2406,12 @@ static void i915_write_fence_reg(struct drm_i915_fence_reg *reg)
2363 pitch_val = obj_priv->stride / tile_width; 2406 pitch_val = obj_priv->stride / tile_width;
2364 pitch_val = ffs(pitch_val) - 1; 2407 pitch_val = ffs(pitch_val) - 1;
2365 2408
2409 if (obj_priv->tiling_mode == I915_TILING_Y &&
2410 HAS_128_BYTE_Y_TILING(dev))
2411 WARN_ON(pitch_val > I830_FENCE_MAX_PITCH_VAL);
2412 else
2413 WARN_ON(pitch_val > I915_FENCE_MAX_PITCH_VAL);
2414
2366 val = obj_priv->gtt_offset; 2415 val = obj_priv->gtt_offset;
2367 if (obj_priv->tiling_mode == I915_TILING_Y) 2416 if (obj_priv->tiling_mode == I915_TILING_Y)
2368 val |= 1 << I830_FENCE_TILING_Y_SHIFT; 2417 val |= 1 << I830_FENCE_TILING_Y_SHIFT;
@@ -2382,7 +2431,7 @@ static void i830_write_fence_reg(struct drm_i915_fence_reg *reg)
2382 struct drm_gem_object *obj = reg->obj; 2431 struct drm_gem_object *obj = reg->obj;
2383 struct drm_device *dev = obj->dev; 2432 struct drm_device *dev = obj->dev;
2384 drm_i915_private_t *dev_priv = dev->dev_private; 2433 drm_i915_private_t *dev_priv = dev->dev_private;
2385 struct drm_i915_gem_object *obj_priv = obj->driver_private; 2434 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
2386 int regnum = obj_priv->fence_reg; 2435 int regnum = obj_priv->fence_reg;
2387 uint32_t val; 2436 uint32_t val;
2388 uint32_t pitch_val; 2437 uint32_t pitch_val;
@@ -2426,7 +2475,7 @@ static int i915_find_fence_reg(struct drm_device *dev)
2426 if (!reg->obj) 2475 if (!reg->obj)
2427 return i; 2476 return i;
2428 2477
2429 obj_priv = reg->obj->driver_private; 2478 obj_priv = to_intel_bo(reg->obj);
2430 if (!obj_priv->pin_count) 2479 if (!obj_priv->pin_count)
2431 avail++; 2480 avail++;
2432 } 2481 }
@@ -2481,7 +2530,7 @@ i915_gem_object_get_fence_reg(struct drm_gem_object *obj)
2481{ 2530{
2482 struct drm_device *dev = obj->dev; 2531 struct drm_device *dev = obj->dev;
2483 struct drm_i915_private *dev_priv = dev->dev_private; 2532 struct drm_i915_private *dev_priv = dev->dev_private;
2484 struct drm_i915_gem_object *obj_priv = obj->driver_private; 2533 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
2485 struct drm_i915_fence_reg *reg = NULL; 2534 struct drm_i915_fence_reg *reg = NULL;
2486 int ret; 2535 int ret;
2487 2536
@@ -2548,7 +2597,7 @@ i915_gem_clear_fence_reg(struct drm_gem_object *obj)
2548{ 2597{
2549 struct drm_device *dev = obj->dev; 2598 struct drm_device *dev = obj->dev;
2550 drm_i915_private_t *dev_priv = dev->dev_private; 2599 drm_i915_private_t *dev_priv = dev->dev_private;
2551 struct drm_i915_gem_object *obj_priv = obj->driver_private; 2600 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
2552 2601
2553 if (IS_GEN6(dev)) { 2602 if (IS_GEN6(dev)) {
2554 I915_WRITE64(FENCE_REG_SANDYBRIDGE_0 + 2603 I915_WRITE64(FENCE_REG_SANDYBRIDGE_0 +
@@ -2584,7 +2633,7 @@ int
2584i915_gem_object_put_fence_reg(struct drm_gem_object *obj) 2633i915_gem_object_put_fence_reg(struct drm_gem_object *obj)
2585{ 2634{
2586 struct drm_device *dev = obj->dev; 2635 struct drm_device *dev = obj->dev;
2587 struct drm_i915_gem_object *obj_priv = obj->driver_private; 2636 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
2588 2637
2589 if (obj_priv->fence_reg == I915_FENCE_REG_NONE) 2638 if (obj_priv->fence_reg == I915_FENCE_REG_NONE)
2590 return 0; 2639 return 0;
@@ -2622,7 +2671,7 @@ i915_gem_object_bind_to_gtt(struct drm_gem_object *obj, unsigned alignment)
2622{ 2671{
2623 struct drm_device *dev = obj->dev; 2672 struct drm_device *dev = obj->dev;
2624 drm_i915_private_t *dev_priv = dev->dev_private; 2673 drm_i915_private_t *dev_priv = dev->dev_private;
2625 struct drm_i915_gem_object *obj_priv = obj->driver_private; 2674 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
2626 struct drm_mm_node *free_space; 2675 struct drm_mm_node *free_space;
2627 gfp_t gfpmask = __GFP_NORETRY | __GFP_NOWARN; 2676 gfp_t gfpmask = __GFP_NORETRY | __GFP_NOWARN;
2628 int ret; 2677 int ret;
@@ -2729,7 +2778,7 @@ i915_gem_object_bind_to_gtt(struct drm_gem_object *obj, unsigned alignment)
2729void 2778void
2730i915_gem_clflush_object(struct drm_gem_object *obj) 2779i915_gem_clflush_object(struct drm_gem_object *obj)
2731{ 2780{
2732 struct drm_i915_gem_object *obj_priv = obj->driver_private; 2781 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
2733 2782
2734 /* If we don't have a page list set up, then we're not pinned 2783 /* If we don't have a page list set up, then we're not pinned
2735 * to GPU, and we can ignore the cache flush because it'll happen 2784 * to GPU, and we can ignore the cache flush because it'll happen
@@ -2830,7 +2879,7 @@ i915_gem_object_flush_write_domain(struct drm_gem_object *obj)
2830int 2879int
2831i915_gem_object_set_to_gtt_domain(struct drm_gem_object *obj, int write) 2880i915_gem_object_set_to_gtt_domain(struct drm_gem_object *obj, int write)
2832{ 2881{
2833 struct drm_i915_gem_object *obj_priv = obj->driver_private; 2882 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
2834 uint32_t old_write_domain, old_read_domains; 2883 uint32_t old_write_domain, old_read_domains;
2835 int ret; 2884 int ret;
2836 2885
@@ -2880,7 +2929,7 @@ int
2880i915_gem_object_set_to_display_plane(struct drm_gem_object *obj) 2929i915_gem_object_set_to_display_plane(struct drm_gem_object *obj)
2881{ 2930{
2882 struct drm_device *dev = obj->dev; 2931 struct drm_device *dev = obj->dev;
2883 struct drm_i915_gem_object *obj_priv = obj->driver_private; 2932 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
2884 uint32_t old_write_domain, old_read_domains; 2933 uint32_t old_write_domain, old_read_domains;
2885 int ret; 2934 int ret;
2886 2935
@@ -3093,7 +3142,7 @@ static void
3093i915_gem_object_set_to_gpu_domain(struct drm_gem_object *obj) 3142i915_gem_object_set_to_gpu_domain(struct drm_gem_object *obj)
3094{ 3143{
3095 struct drm_device *dev = obj->dev; 3144 struct drm_device *dev = obj->dev;
3096 struct drm_i915_gem_object *obj_priv = obj->driver_private; 3145 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
3097 uint32_t invalidate_domains = 0; 3146 uint32_t invalidate_domains = 0;
3098 uint32_t flush_domains = 0; 3147 uint32_t flush_domains = 0;
3099 uint32_t old_read_domains; 3148 uint32_t old_read_domains;
@@ -3178,7 +3227,7 @@ i915_gem_object_set_to_gpu_domain(struct drm_gem_object *obj)
3178static void 3227static void
3179i915_gem_object_set_to_full_cpu_read_domain(struct drm_gem_object *obj) 3228i915_gem_object_set_to_full_cpu_read_domain(struct drm_gem_object *obj)
3180{ 3229{
3181 struct drm_i915_gem_object *obj_priv = obj->driver_private; 3230 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
3182 3231
3183 if (!obj_priv->page_cpu_valid) 3232 if (!obj_priv->page_cpu_valid)
3184 return; 3233 return;
@@ -3218,7 +3267,7 @@ static int
3218i915_gem_object_set_cpu_read_domain_range(struct drm_gem_object *obj, 3267i915_gem_object_set_cpu_read_domain_range(struct drm_gem_object *obj,
3219 uint64_t offset, uint64_t size) 3268 uint64_t offset, uint64_t size)
3220{ 3269{
3221 struct drm_i915_gem_object *obj_priv = obj->driver_private; 3270 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
3222 uint32_t old_read_domains; 3271 uint32_t old_read_domains;
3223 int i, ret; 3272 int i, ret;
3224 3273
@@ -3287,7 +3336,7 @@ i915_gem_object_pin_and_relocate(struct drm_gem_object *obj,
3287{ 3336{
3288 struct drm_device *dev = obj->dev; 3337 struct drm_device *dev = obj->dev;
3289 drm_i915_private_t *dev_priv = dev->dev_private; 3338 drm_i915_private_t *dev_priv = dev->dev_private;
3290 struct drm_i915_gem_object *obj_priv = obj->driver_private; 3339 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
3291 int i, ret; 3340 int i, ret;
3292 void __iomem *reloc_page; 3341 void __iomem *reloc_page;
3293 bool need_fence; 3342 bool need_fence;
@@ -3338,7 +3387,7 @@ i915_gem_object_pin_and_relocate(struct drm_gem_object *obj,
3338 i915_gem_object_unpin(obj); 3387 i915_gem_object_unpin(obj);
3339 return -EBADF; 3388 return -EBADF;
3340 } 3389 }
3341 target_obj_priv = target_obj->driver_private; 3390 target_obj_priv = to_intel_bo(target_obj);
3342 3391
3343#if WATCH_RELOC 3392#if WATCH_RELOC
3344 DRM_INFO("%s: obj %p offset %08x target %d " 3393 DRM_INFO("%s: obj %p offset %08x target %d "
@@ -3690,7 +3739,7 @@ i915_gem_wait_for_pending_flip(struct drm_device *dev,
3690 prepare_to_wait(&dev_priv->pending_flip_queue, 3739 prepare_to_wait(&dev_priv->pending_flip_queue,
3691 &wait, TASK_INTERRUPTIBLE); 3740 &wait, TASK_INTERRUPTIBLE);
3692 for (i = 0; i < count; i++) { 3741 for (i = 0; i < count; i++) {
3693 obj_priv = object_list[i]->driver_private; 3742 obj_priv = to_intel_bo(object_list[i]);
3694 if (atomic_read(&obj_priv->pending_flip) > 0) 3743 if (atomic_read(&obj_priv->pending_flip) > 0)
3695 break; 3744 break;
3696 } 3745 }
@@ -3799,7 +3848,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
3799 goto err; 3848 goto err;
3800 } 3849 }
3801 3850
3802 obj_priv = object_list[i]->driver_private; 3851 obj_priv = to_intel_bo(object_list[i]);
3803 if (obj_priv->in_execbuffer) { 3852 if (obj_priv->in_execbuffer) {
3804 DRM_ERROR("Object %p appears more than once in object list\n", 3853 DRM_ERROR("Object %p appears more than once in object list\n",
3805 object_list[i]); 3854 object_list[i]);
@@ -3925,7 +3974,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
3925 3974
3926 for (i = 0; i < args->buffer_count; i++) { 3975 for (i = 0; i < args->buffer_count; i++) {
3927 struct drm_gem_object *obj = object_list[i]; 3976 struct drm_gem_object *obj = object_list[i];
3928 struct drm_i915_gem_object *obj_priv = obj->driver_private; 3977 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
3929 uint32_t old_write_domain = obj->write_domain; 3978 uint32_t old_write_domain = obj->write_domain;
3930 3979
3931 obj->write_domain = obj->pending_write_domain; 3980 obj->write_domain = obj->pending_write_domain;
@@ -4000,7 +4049,7 @@ err:
4000 4049
4001 for (i = 0; i < args->buffer_count; i++) { 4050 for (i = 0; i < args->buffer_count; i++) {
4002 if (object_list[i]) { 4051 if (object_list[i]) {
4003 obj_priv = object_list[i]->driver_private; 4052 obj_priv = to_intel_bo(object_list[i]);
4004 obj_priv->in_execbuffer = false; 4053 obj_priv->in_execbuffer = false;
4005 } 4054 }
4006 drm_gem_object_unreference(object_list[i]); 4055 drm_gem_object_unreference(object_list[i]);
@@ -4178,7 +4227,7 @@ int
4178i915_gem_object_pin(struct drm_gem_object *obj, uint32_t alignment) 4227i915_gem_object_pin(struct drm_gem_object *obj, uint32_t alignment)
4179{ 4228{
4180 struct drm_device *dev = obj->dev; 4229 struct drm_device *dev = obj->dev;
4181 struct drm_i915_gem_object *obj_priv = obj->driver_private; 4230 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
4182 int ret; 4231 int ret;
4183 4232
4184 i915_verify_inactive(dev, __FILE__, __LINE__); 4233 i915_verify_inactive(dev, __FILE__, __LINE__);
@@ -4211,7 +4260,7 @@ i915_gem_object_unpin(struct drm_gem_object *obj)
4211{ 4260{
4212 struct drm_device *dev = obj->dev; 4261 struct drm_device *dev = obj->dev;
4213 drm_i915_private_t *dev_priv = dev->dev_private; 4262 drm_i915_private_t *dev_priv = dev->dev_private;
4214 struct drm_i915_gem_object *obj_priv = obj->driver_private; 4263 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
4215 4264
4216 i915_verify_inactive(dev, __FILE__, __LINE__); 4265 i915_verify_inactive(dev, __FILE__, __LINE__);
4217 obj_priv->pin_count--; 4266 obj_priv->pin_count--;
@@ -4251,7 +4300,7 @@ i915_gem_pin_ioctl(struct drm_device *dev, void *data,
4251 mutex_unlock(&dev->struct_mutex); 4300 mutex_unlock(&dev->struct_mutex);
4252 return -EBADF; 4301 return -EBADF;
4253 } 4302 }
4254 obj_priv = obj->driver_private; 4303 obj_priv = to_intel_bo(obj);
4255 4304
4256 if (obj_priv->madv != I915_MADV_WILLNEED) { 4305 if (obj_priv->madv != I915_MADV_WILLNEED) {
4257 DRM_ERROR("Attempting to pin a purgeable buffer\n"); 4306 DRM_ERROR("Attempting to pin a purgeable buffer\n");
@@ -4308,7 +4357,7 @@ i915_gem_unpin_ioctl(struct drm_device *dev, void *data,
4308 return -EBADF; 4357 return -EBADF;
4309 } 4358 }
4310 4359
4311 obj_priv = obj->driver_private; 4360 obj_priv = to_intel_bo(obj);
4312 if (obj_priv->pin_filp != file_priv) { 4361 if (obj_priv->pin_filp != file_priv) {
4313 DRM_ERROR("Not pinned by caller in i915_gem_pin_ioctl(): %d\n", 4362 DRM_ERROR("Not pinned by caller in i915_gem_pin_ioctl(): %d\n",
4314 args->handle); 4363 args->handle);
@@ -4350,7 +4399,7 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,
4350 */ 4399 */
4351 i915_gem_retire_requests(dev); 4400 i915_gem_retire_requests(dev);
4352 4401
4353 obj_priv = obj->driver_private; 4402 obj_priv = to_intel_bo(obj);
4354 /* Don't count being on the flushing list against the object being 4403 /* Don't count being on the flushing list against the object being
4355 * done. Otherwise, a buffer left on the flushing list but not getting 4404 * done. Otherwise, a buffer left on the flushing list but not getting
4356 * flushed (because nobody's flushing that domain) won't ever return 4405 * flushed (because nobody's flushing that domain) won't ever return
@@ -4396,7 +4445,7 @@ i915_gem_madvise_ioctl(struct drm_device *dev, void *data,
4396 } 4445 }
4397 4446
4398 mutex_lock(&dev->struct_mutex); 4447 mutex_lock(&dev->struct_mutex);
4399 obj_priv = obj->driver_private; 4448 obj_priv = to_intel_bo(obj);
4400 4449
4401 if (obj_priv->pin_count) { 4450 if (obj_priv->pin_count) {
4402 drm_gem_object_unreference(obj); 4451 drm_gem_object_unreference(obj);
@@ -4457,7 +4506,7 @@ int i915_gem_init_object(struct drm_gem_object *obj)
4457void i915_gem_free_object(struct drm_gem_object *obj) 4506void i915_gem_free_object(struct drm_gem_object *obj)
4458{ 4507{
4459 struct drm_device *dev = obj->dev; 4508 struct drm_device *dev = obj->dev;
4460 struct drm_i915_gem_object *obj_priv = obj->driver_private; 4509 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
4461 4510
4462 trace_i915_gem_object_destroy(obj); 4511 trace_i915_gem_object_destroy(obj);
4463 4512
@@ -4547,6 +4596,49 @@ i915_gem_idle(struct drm_device *dev)
4547 return 0; 4596 return 0;
4548} 4597}
4549 4598
4599/*
4600 * 965+ support PIPE_CONTROL commands, which provide finer grained control
4601 * over cache flushing.
4602 */
4603static int
4604i915_gem_init_pipe_control(struct drm_device *dev)
4605{
4606 drm_i915_private_t *dev_priv = dev->dev_private;
4607 struct drm_gem_object *obj;
4608 struct drm_i915_gem_object *obj_priv;
4609 int ret;
4610
4611 obj = drm_gem_object_alloc(dev, 4096);
4612 if (obj == NULL) {
4613 DRM_ERROR("Failed to allocate seqno page\n");
4614 ret = -ENOMEM;
4615 goto err;
4616 }
4617 obj_priv = to_intel_bo(obj);
4618 obj_priv->agp_type = AGP_USER_CACHED_MEMORY;
4619
4620 ret = i915_gem_object_pin(obj, 4096);
4621 if (ret)
4622 goto err_unref;
4623
4624 dev_priv->seqno_gfx_addr = obj_priv->gtt_offset;
4625 dev_priv->seqno_page = kmap(obj_priv->pages[0]);
4626 if (dev_priv->seqno_page == NULL)
4627 goto err_unpin;
4628
4629 dev_priv->seqno_obj = obj;
4630 memset(dev_priv->seqno_page, 0, PAGE_SIZE);
4631
4632 return 0;
4633
4634err_unpin:
4635 i915_gem_object_unpin(obj);
4636err_unref:
4637 drm_gem_object_unreference(obj);
4638err:
4639 return ret;
4640}
4641
4550static int 4642static int
4551i915_gem_init_hws(struct drm_device *dev) 4643i915_gem_init_hws(struct drm_device *dev)
4552{ 4644{
@@ -4564,15 +4656,16 @@ i915_gem_init_hws(struct drm_device *dev)
4564 obj = drm_gem_object_alloc(dev, 4096); 4656 obj = drm_gem_object_alloc(dev, 4096);
4565 if (obj == NULL) { 4657 if (obj == NULL) {
4566 DRM_ERROR("Failed to allocate status page\n"); 4658 DRM_ERROR("Failed to allocate status page\n");
4567 return -ENOMEM; 4659 ret = -ENOMEM;
4660 goto err;
4568 } 4661 }
4569 obj_priv = obj->driver_private; 4662 obj_priv = to_intel_bo(obj);
4570 obj_priv->agp_type = AGP_USER_CACHED_MEMORY; 4663 obj_priv->agp_type = AGP_USER_CACHED_MEMORY;
4571 4664
4572 ret = i915_gem_object_pin(obj, 4096); 4665 ret = i915_gem_object_pin(obj, 4096);
4573 if (ret != 0) { 4666 if (ret != 0) {
4574 drm_gem_object_unreference(obj); 4667 drm_gem_object_unreference(obj);
4575 return ret; 4668 goto err_unref;
4576 } 4669 }
4577 4670
4578 dev_priv->status_gfx_addr = obj_priv->gtt_offset; 4671 dev_priv->status_gfx_addr = obj_priv->gtt_offset;
@@ -4581,10 +4674,16 @@ i915_gem_init_hws(struct drm_device *dev)
4581 if (dev_priv->hw_status_page == NULL) { 4674 if (dev_priv->hw_status_page == NULL) {
4582 DRM_ERROR("Failed to map status page.\n"); 4675 DRM_ERROR("Failed to map status page.\n");
4583 memset(&dev_priv->hws_map, 0, sizeof(dev_priv->hws_map)); 4676 memset(&dev_priv->hws_map, 0, sizeof(dev_priv->hws_map));
4584 i915_gem_object_unpin(obj); 4677 ret = -EINVAL;
4585 drm_gem_object_unreference(obj); 4678 goto err_unpin;
4586 return -EINVAL; 4679 }
4680
4681 if (HAS_PIPE_CONTROL(dev)) {
4682 ret = i915_gem_init_pipe_control(dev);
4683 if (ret)
4684 goto err_unpin;
4587 } 4685 }
4686
4588 dev_priv->hws_obj = obj; 4687 dev_priv->hws_obj = obj;
4589 memset(dev_priv->hw_status_page, 0, PAGE_SIZE); 4688 memset(dev_priv->hw_status_page, 0, PAGE_SIZE);
4590 if (IS_GEN6(dev)) { 4689 if (IS_GEN6(dev)) {
@@ -4597,6 +4696,30 @@ i915_gem_init_hws(struct drm_device *dev)
4597 DRM_DEBUG_DRIVER("hws offset: 0x%08x\n", dev_priv->status_gfx_addr); 4696 DRM_DEBUG_DRIVER("hws offset: 0x%08x\n", dev_priv->status_gfx_addr);
4598 4697
4599 return 0; 4698 return 0;
4699
4700err_unpin:
4701 i915_gem_object_unpin(obj);
4702err_unref:
4703 drm_gem_object_unreference(obj);
4704err:
4705 return 0;
4706}
4707
4708static void
4709i915_gem_cleanup_pipe_control(struct drm_device *dev)
4710{
4711 drm_i915_private_t *dev_priv = dev->dev_private;
4712 struct drm_gem_object *obj;
4713 struct drm_i915_gem_object *obj_priv;
4714
4715 obj = dev_priv->seqno_obj;
4716 obj_priv = to_intel_bo(obj);
4717 kunmap(obj_priv->pages[0]);
4718 i915_gem_object_unpin(obj);
4719 drm_gem_object_unreference(obj);
4720 dev_priv->seqno_obj = NULL;
4721
4722 dev_priv->seqno_page = NULL;
4600} 4723}
4601 4724
4602static void 4725static void
@@ -4610,7 +4733,7 @@ i915_gem_cleanup_hws(struct drm_device *dev)
4610 return; 4733 return;
4611 4734
4612 obj = dev_priv->hws_obj; 4735 obj = dev_priv->hws_obj;
4613 obj_priv = obj->driver_private; 4736 obj_priv = to_intel_bo(obj);
4614 4737
4615 kunmap(obj_priv->pages[0]); 4738 kunmap(obj_priv->pages[0]);
4616 i915_gem_object_unpin(obj); 4739 i915_gem_object_unpin(obj);
@@ -4620,6 +4743,9 @@ i915_gem_cleanup_hws(struct drm_device *dev)
4620 memset(&dev_priv->hws_map, 0, sizeof(dev_priv->hws_map)); 4743 memset(&dev_priv->hws_map, 0, sizeof(dev_priv->hws_map));
4621 dev_priv->hw_status_page = NULL; 4744 dev_priv->hw_status_page = NULL;
4622 4745
4746 if (HAS_PIPE_CONTROL(dev))
4747 i915_gem_cleanup_pipe_control(dev);
4748
4623 /* Write high address into HWS_PGA when disabling. */ 4749 /* Write high address into HWS_PGA when disabling. */
4624 I915_WRITE(HWS_PGA, 0x1ffff000); 4750 I915_WRITE(HWS_PGA, 0x1ffff000);
4625} 4751}
@@ -4644,7 +4770,7 @@ i915_gem_init_ringbuffer(struct drm_device *dev)
4644 i915_gem_cleanup_hws(dev); 4770 i915_gem_cleanup_hws(dev);
4645 return -ENOMEM; 4771 return -ENOMEM;
4646 } 4772 }
4647 obj_priv = obj->driver_private; 4773 obj_priv = to_intel_bo(obj);
4648 4774
4649 ret = i915_gem_object_pin(obj, 4096); 4775 ret = i915_gem_object_pin(obj, 4096);
4650 if (ret != 0) { 4776 if (ret != 0) {
@@ -4730,6 +4856,11 @@ i915_gem_init_ringbuffer(struct drm_device *dev)
4730 ring->space += ring->Size; 4856 ring->space += ring->Size;
4731 } 4857 }
4732 4858
4859 if (IS_I9XX(dev) && !IS_GEN3(dev)) {
4860 I915_WRITE(MI_MODE,
4861 (VS_TIMER_DISPATCH) << 16 | VS_TIMER_DISPATCH);
4862 }
4863
4733 return 0; 4864 return 0;
4734} 4865}
4735 4866
@@ -4932,7 +5063,7 @@ void i915_gem_detach_phys_object(struct drm_device *dev,
4932 int ret; 5063 int ret;
4933 int page_count; 5064 int page_count;
4934 5065
4935 obj_priv = obj->driver_private; 5066 obj_priv = to_intel_bo(obj);
4936 if (!obj_priv->phys_obj) 5067 if (!obj_priv->phys_obj)
4937 return; 5068 return;
4938 5069
@@ -4971,7 +5102,7 @@ i915_gem_attach_phys_object(struct drm_device *dev,
4971 if (id > I915_MAX_PHYS_OBJECT) 5102 if (id > I915_MAX_PHYS_OBJECT)
4972 return -EINVAL; 5103 return -EINVAL;
4973 5104
4974 obj_priv = obj->driver_private; 5105 obj_priv = to_intel_bo(obj);
4975 5106
4976 if (obj_priv->phys_obj) { 5107 if (obj_priv->phys_obj) {
4977 if (obj_priv->phys_obj->id == id) 5108 if (obj_priv->phys_obj->id == id)
@@ -5022,7 +5153,7 @@ i915_gem_phys_pwrite(struct drm_device *dev, struct drm_gem_object *obj,
5022 struct drm_i915_gem_pwrite *args, 5153 struct drm_i915_gem_pwrite *args,
5023 struct drm_file *file_priv) 5154 struct drm_file *file_priv)
5024{ 5155{
5025 struct drm_i915_gem_object *obj_priv = obj->driver_private; 5156 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
5026 void *obj_addr; 5157 void *obj_addr;
5027 int ret; 5158 int ret;
5028 char __user *user_data; 5159 char __user *user_data;
diff --git a/drivers/gpu/drm/i915/i915_gem_debug.c b/drivers/gpu/drm/i915/i915_gem_debug.c
index e602614bd3f..35507cf53fa 100644
--- a/drivers/gpu/drm/i915/i915_gem_debug.c
+++ b/drivers/gpu/drm/i915/i915_gem_debug.c
@@ -72,7 +72,7 @@ void
72i915_gem_dump_object(struct drm_gem_object *obj, int len, 72i915_gem_dump_object(struct drm_gem_object *obj, int len,
73 const char *where, uint32_t mark) 73 const char *where, uint32_t mark)
74{ 74{
75 struct drm_i915_gem_object *obj_priv = obj->driver_private; 75 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
76 int page; 76 int page;
77 77
78 DRM_INFO("%s: object at offset %08x\n", where, obj_priv->gtt_offset); 78 DRM_INFO("%s: object at offset %08x\n", where, obj_priv->gtt_offset);
@@ -137,7 +137,7 @@ void
137i915_gem_object_check_coherency(struct drm_gem_object *obj, int handle) 137i915_gem_object_check_coherency(struct drm_gem_object *obj, int handle)
138{ 138{
139 struct drm_device *dev = obj->dev; 139 struct drm_device *dev = obj->dev;
140 struct drm_i915_gem_object *obj_priv = obj->driver_private; 140 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
141 int page; 141 int page;
142 uint32_t *gtt_mapping; 142 uint32_t *gtt_mapping;
143 uint32_t *backing_map = NULL; 143 uint32_t *backing_map = NULL;
diff --git a/drivers/gpu/drm/i915/i915_gem_tiling.c b/drivers/gpu/drm/i915/i915_gem_tiling.c
index b5c55d88ff7..4bdccefcf2c 100644
--- a/drivers/gpu/drm/i915/i915_gem_tiling.c
+++ b/drivers/gpu/drm/i915/i915_gem_tiling.c
@@ -202,21 +202,17 @@ i915_tiling_ok(struct drm_device *dev, int stride, int size, int tiling_mode)
202 * reg, so dont bother to check the size */ 202 * reg, so dont bother to check the size */
203 if (stride / 128 > I965_FENCE_MAX_PITCH_VAL) 203 if (stride / 128 > I965_FENCE_MAX_PITCH_VAL)
204 return false; 204 return false;
205 } else if (IS_I9XX(dev)) { 205 } else if (IS_GEN3(dev) || IS_GEN2(dev)) {
206 uint32_t pitch_val = ffs(stride / tile_width) - 1; 206 if (stride > 8192)
207
208 /* XXX: For Y tiling, FENCE_MAX_PITCH_VAL is actually 6 (8KB)
209 * instead of 4 (2KB) on 945s.
210 */
211 if (pitch_val > I915_FENCE_MAX_PITCH_VAL ||
212 size > (I830_FENCE_MAX_SIZE_VAL << 20))
213 return false; 207 return false;
214 } else {
215 uint32_t pitch_val = ffs(stride / tile_width) - 1;
216 208
217 if (pitch_val > I830_FENCE_MAX_PITCH_VAL || 209 if (IS_GEN3(dev)) {
218 size > (I830_FENCE_MAX_SIZE_VAL << 19)) 210 if (size > I830_FENCE_MAX_SIZE_VAL << 20)
219 return false; 211 return false;
212 } else {
213 if (size > I830_FENCE_MAX_SIZE_VAL << 19)
214 return false;
215 }
220 } 216 }
221 217
222 /* 965+ just needs multiples of tile width */ 218 /* 965+ just needs multiples of tile width */
@@ -240,7 +236,7 @@ bool
240i915_gem_object_fence_offset_ok(struct drm_gem_object *obj, int tiling_mode) 236i915_gem_object_fence_offset_ok(struct drm_gem_object *obj, int tiling_mode)
241{ 237{
242 struct drm_device *dev = obj->dev; 238 struct drm_device *dev = obj->dev;
243 struct drm_i915_gem_object *obj_priv = obj->driver_private; 239 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
244 240
245 if (obj_priv->gtt_space == NULL) 241 if (obj_priv->gtt_space == NULL)
246 return true; 242 return true;
@@ -280,7 +276,7 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,
280 obj = drm_gem_object_lookup(dev, file_priv, args->handle); 276 obj = drm_gem_object_lookup(dev, file_priv, args->handle);
281 if (obj == NULL) 277 if (obj == NULL)
282 return -EINVAL; 278 return -EINVAL;
283 obj_priv = obj->driver_private; 279 obj_priv = to_intel_bo(obj);
284 280
285 if (!i915_tiling_ok(dev, args->stride, obj->size, args->tiling_mode)) { 281 if (!i915_tiling_ok(dev, args->stride, obj->size, args->tiling_mode)) {
286 drm_gem_object_unreference_unlocked(obj); 282 drm_gem_object_unreference_unlocked(obj);
@@ -325,9 +321,12 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,
325 * need to ensure that any fence register is cleared. 321 * need to ensure that any fence register is cleared.
326 */ 322 */
327 if (!i915_gem_object_fence_offset_ok(obj, args->tiling_mode)) 323 if (!i915_gem_object_fence_offset_ok(obj, args->tiling_mode))
328 ret = i915_gem_object_unbind(obj); 324 ret = i915_gem_object_unbind(obj);
325 else if (obj_priv->fence_reg != I915_FENCE_REG_NONE)
326 ret = i915_gem_object_put_fence_reg(obj);
329 else 327 else
330 ret = i915_gem_object_put_fence_reg(obj); 328 i915_gem_release_mmap(obj);
329
331 if (ret != 0) { 330 if (ret != 0) {
332 WARN(ret != -ERESTARTSYS, 331 WARN(ret != -ERESTARTSYS,
333 "failed to reset object for tiling switch"); 332 "failed to reset object for tiling switch");
@@ -361,7 +360,7 @@ i915_gem_get_tiling(struct drm_device *dev, void *data,
361 obj = drm_gem_object_lookup(dev, file_priv, args->handle); 360 obj = drm_gem_object_lookup(dev, file_priv, args->handle);
362 if (obj == NULL) 361 if (obj == NULL)
363 return -EINVAL; 362 return -EINVAL;
364 obj_priv = obj->driver_private; 363 obj_priv = to_intel_bo(obj);
365 364
366 mutex_lock(&dev->struct_mutex); 365 mutex_lock(&dev->struct_mutex);
367 366
@@ -424,7 +423,7 @@ i915_gem_object_do_bit_17_swizzle(struct drm_gem_object *obj)
424{ 423{
425 struct drm_device *dev = obj->dev; 424 struct drm_device *dev = obj->dev;
426 drm_i915_private_t *dev_priv = dev->dev_private; 425 drm_i915_private_t *dev_priv = dev->dev_private;
427 struct drm_i915_gem_object *obj_priv = obj->driver_private; 426 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
428 int page_count = obj->size >> PAGE_SHIFT; 427 int page_count = obj->size >> PAGE_SHIFT;
429 int i; 428 int i;
430 429
@@ -453,7 +452,7 @@ i915_gem_object_save_bit_17_swizzle(struct drm_gem_object *obj)
453{ 452{
454 struct drm_device *dev = obj->dev; 453 struct drm_device *dev = obj->dev;
455 drm_i915_private_t *dev_priv = dev->dev_private; 454 drm_i915_private_t *dev_priv = dev->dev_private;
456 struct drm_i915_gem_object *obj_priv = obj->driver_private; 455 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
457 int page_count = obj->size >> PAGE_SHIFT; 456 int page_count = obj->size >> PAGE_SHIFT;
458 int i; 457 int i;
459 458
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 5388354da0d..2b8b969d0c1 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -27,6 +27,7 @@
27 */ 27 */
28 28
29#include <linux/sysrq.h> 29#include <linux/sysrq.h>
30#include <linux/slab.h>
30#include "drmP.h" 31#include "drmP.h"
31#include "drm.h" 32#include "drm.h"
32#include "i915_drm.h" 33#include "i915_drm.h"
@@ -259,10 +260,10 @@ static void i915_hotplug_work_func(struct work_struct *work)
259 260
260 if (mode_config->num_connector) { 261 if (mode_config->num_connector) {
261 list_for_each_entry(connector, &mode_config->connector_list, head) { 262 list_for_each_entry(connector, &mode_config->connector_list, head) {
262 struct intel_output *intel_output = to_intel_output(connector); 263 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
263 264
264 if (intel_output->hot_plug) 265 if (intel_encoder->hot_plug)
265 (*intel_output->hot_plug) (intel_output); 266 (*intel_encoder->hot_plug) (intel_encoder);
266 } 267 }
267 } 268 }
268 /* Just fire off a uevent and let userspace tell us what to do */ 269 /* Just fire off a uevent and let userspace tell us what to do */
@@ -348,7 +349,7 @@ irqreturn_t ironlake_irq_handler(struct drm_device *dev)
348 READ_BREADCRUMB(dev_priv); 349 READ_BREADCRUMB(dev_priv);
349 } 350 }
350 351
351 if (gt_iir & GT_USER_INTERRUPT) { 352 if (gt_iir & GT_PIPE_NOTIFY) {
352 u32 seqno = i915_get_gem_seqno(dev); 353 u32 seqno = i915_get_gem_seqno(dev);
353 dev_priv->mm.irq_gem_seqno = seqno; 354 dev_priv->mm.irq_gem_seqno = seqno;
354 trace_i915_gem_request_complete(dev, seqno); 355 trace_i915_gem_request_complete(dev, seqno);
@@ -443,7 +444,7 @@ i915_error_object_create(struct drm_device *dev,
443 if (src == NULL) 444 if (src == NULL)
444 return NULL; 445 return NULL;
445 446
446 src_priv = src->driver_private; 447 src_priv = to_intel_bo(src);
447 if (src_priv->pages == NULL) 448 if (src_priv->pages == NULL)
448 return NULL; 449 return NULL;
449 450
@@ -1004,7 +1005,7 @@ void i915_user_irq_get(struct drm_device *dev)
1004 spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags); 1005 spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags);
1005 if (dev->irq_enabled && (++dev_priv->user_irq_refcount == 1)) { 1006 if (dev->irq_enabled && (++dev_priv->user_irq_refcount == 1)) {
1006 if (HAS_PCH_SPLIT(dev)) 1007 if (HAS_PCH_SPLIT(dev))
1007 ironlake_enable_graphics_irq(dev_priv, GT_USER_INTERRUPT); 1008 ironlake_enable_graphics_irq(dev_priv, GT_PIPE_NOTIFY);
1008 else 1009 else
1009 i915_enable_irq(dev_priv, I915_USER_INTERRUPT); 1010 i915_enable_irq(dev_priv, I915_USER_INTERRUPT);
1010 } 1011 }
@@ -1020,7 +1021,7 @@ void i915_user_irq_put(struct drm_device *dev)
1020 BUG_ON(dev->irq_enabled && dev_priv->user_irq_refcount <= 0); 1021 BUG_ON(dev->irq_enabled && dev_priv->user_irq_refcount <= 0);
1021 if (dev->irq_enabled && (--dev_priv->user_irq_refcount == 0)) { 1022 if (dev->irq_enabled && (--dev_priv->user_irq_refcount == 0)) {
1022 if (HAS_PCH_SPLIT(dev)) 1023 if (HAS_PCH_SPLIT(dev))
1023 ironlake_disable_graphics_irq(dev_priv, GT_USER_INTERRUPT); 1024 ironlake_disable_graphics_irq(dev_priv, GT_PIPE_NOTIFY);
1024 else 1025 else
1025 i915_disable_irq(dev_priv, I915_USER_INTERRUPT); 1026 i915_disable_irq(dev_priv, I915_USER_INTERRUPT);
1026 } 1027 }
@@ -1304,7 +1305,7 @@ static int ironlake_irq_postinstall(struct drm_device *dev)
1304 /* enable kind of interrupts always enabled */ 1305 /* enable kind of interrupts always enabled */
1305 u32 display_mask = DE_MASTER_IRQ_CONTROL | DE_GSE | DE_PCH_EVENT | 1306 u32 display_mask = DE_MASTER_IRQ_CONTROL | DE_GSE | DE_PCH_EVENT |
1306 DE_PLANEA_FLIP_DONE | DE_PLANEB_FLIP_DONE; 1307 DE_PLANEA_FLIP_DONE | DE_PLANEB_FLIP_DONE;
1307 u32 render_mask = GT_USER_INTERRUPT; 1308 u32 render_mask = GT_PIPE_NOTIFY;
1308 u32 hotplug_mask = SDE_CRT_HOTPLUG | SDE_PORTB_HOTPLUG | 1309 u32 hotplug_mask = SDE_CRT_HOTPLUG | SDE_PORTB_HOTPLUG |
1309 SDE_PORTC_HOTPLUG | SDE_PORTD_HOTPLUG; 1310 SDE_PORTC_HOTPLUG | SDE_PORTD_HOTPLUG;
1310 1311
diff --git a/drivers/gpu/drm/i915/i915_opregion.c b/drivers/gpu/drm/i915/i915_opregion.c
index 7cc8410239c..8fcc75c1aa2 100644
--- a/drivers/gpu/drm/i915/i915_opregion.c
+++ b/drivers/gpu/drm/i915/i915_opregion.c
@@ -382,8 +382,57 @@ static void intel_didl_outputs(struct drm_device *dev)
382 struct drm_i915_private *dev_priv = dev->dev_private; 382 struct drm_i915_private *dev_priv = dev->dev_private;
383 struct intel_opregion *opregion = &dev_priv->opregion; 383 struct intel_opregion *opregion = &dev_priv->opregion;
384 struct drm_connector *connector; 384 struct drm_connector *connector;
385 acpi_handle handle;
386 struct acpi_device *acpi_dev, *acpi_cdev, *acpi_video_bus = NULL;
387 unsigned long long device_id;
388 acpi_status status;
385 int i = 0; 389 int i = 0;
386 390
391 handle = DEVICE_ACPI_HANDLE(&dev->pdev->dev);
392 if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &acpi_dev)))
393 return;
394
395 if (acpi_is_video_device(acpi_dev))
396 acpi_video_bus = acpi_dev;
397 else {
398 list_for_each_entry(acpi_cdev, &acpi_dev->children, node) {
399 if (acpi_is_video_device(acpi_cdev)) {
400 acpi_video_bus = acpi_cdev;
401 break;
402 }
403 }
404 }
405
406 if (!acpi_video_bus) {
407 printk(KERN_WARNING "No ACPI video bus found\n");
408 return;
409 }
410
411 list_for_each_entry(acpi_cdev, &acpi_video_bus->children, node) {
412 if (i >= 8) {
413 dev_printk (KERN_ERR, &dev->pdev->dev,
414 "More than 8 outputs detected\n");
415 return;
416 }
417 status =
418 acpi_evaluate_integer(acpi_cdev->handle, "_ADR",
419 NULL, &device_id);
420 if (ACPI_SUCCESS(status)) {
421 if (!device_id)
422 goto blind_set;
423 opregion->acpi->didl[i] = (u32)(device_id & 0x0f0f);
424 i++;
425 }
426 }
427
428end:
429 /* If fewer than 8 outputs, the list must be null terminated */
430 if (i < 8)
431 opregion->acpi->didl[i] = 0;
432 return;
433
434blind_set:
435 i = 0;
387 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 436 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
388 int output_type = ACPI_OTHER_OUTPUT; 437 int output_type = ACPI_OTHER_OUTPUT;
389 if (i >= 8) { 438 if (i >= 8) {
@@ -416,10 +465,7 @@ static void intel_didl_outputs(struct drm_device *dev)
416 opregion->acpi->didl[i] |= (1<<31) | output_type | i; 465 opregion->acpi->didl[i] |= (1<<31) | output_type | i;
417 i++; 466 i++;
418 } 467 }
419 468 goto end;
420 /* If fewer than 8 outputs, the list must be null terminated */
421 if (i < 8)
422 opregion->acpi->didl[i] = 0;
423} 469}
424 470
425int intel_opregion_init(struct drm_device *dev, int resume) 471int intel_opregion_init(struct drm_device *dev, int resume)
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 3d59862c7cc..4cbc5210fd3 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -230,6 +230,16 @@
230#define ASYNC_FLIP (1<<22) 230#define ASYNC_FLIP (1<<22)
231#define DISPLAY_PLANE_A (0<<20) 231#define DISPLAY_PLANE_A (0<<20)
232#define DISPLAY_PLANE_B (1<<20) 232#define DISPLAY_PLANE_B (1<<20)
233#define GFX_OP_PIPE_CONTROL ((0x3<<29)|(0x3<<27)|(0x2<<24)|2)
234#define PIPE_CONTROL_QW_WRITE (1<<14)
235#define PIPE_CONTROL_DEPTH_STALL (1<<13)
236#define PIPE_CONTROL_WC_FLUSH (1<<12)
237#define PIPE_CONTROL_IS_FLUSH (1<<11) /* MBZ on Ironlake */
238#define PIPE_CONTROL_TC_FLUSH (1<<10) /* GM45+ only */
239#define PIPE_CONTROL_ISP_DIS (1<<9)
240#define PIPE_CONTROL_NOTIFY (1<<8)
241#define PIPE_CONTROL_GLOBAL_GTT (1<<2) /* in addr dword */
242#define PIPE_CONTROL_STALL_EN (1<<1) /* in addr word, Ironlake+ only */
233 243
234/* 244/*
235 * Fence registers 245 * Fence registers
@@ -241,7 +251,7 @@
241#define I830_FENCE_SIZE_BITS(size) ((ffs((size) >> 19) - 1) << 8) 251#define I830_FENCE_SIZE_BITS(size) ((ffs((size) >> 19) - 1) << 8)
242#define I830_FENCE_PITCH_SHIFT 4 252#define I830_FENCE_PITCH_SHIFT 4
243#define I830_FENCE_REG_VALID (1<<0) 253#define I830_FENCE_REG_VALID (1<<0)
244#define I915_FENCE_MAX_PITCH_VAL 0x10 254#define I915_FENCE_MAX_PITCH_VAL 4
245#define I830_FENCE_MAX_PITCH_VAL 6 255#define I830_FENCE_MAX_PITCH_VAL 6
246#define I830_FENCE_MAX_SIZE_VAL (1<<8) 256#define I830_FENCE_MAX_SIZE_VAL (1<<8)
247 257
@@ -298,6 +308,10 @@
298#define INSTDONE 0x02090 308#define INSTDONE 0x02090
299#define NOPID 0x02094 309#define NOPID 0x02094
300#define HWSTAM 0x02098 310#define HWSTAM 0x02098
311
312#define MI_MODE 0x0209c
313# define VS_TIMER_DISPATCH (1 << 6)
314
301#define SCPD0 0x0209c /* 915+ only */ 315#define SCPD0 0x0209c /* 915+ only */
302#define IER 0x020a0 316#define IER 0x020a0
303#define IIR 0x020a4 317#define IIR 0x020a4
@@ -366,7 +380,7 @@
366#define FBC_CTL_PERIODIC (1<<30) 380#define FBC_CTL_PERIODIC (1<<30)
367#define FBC_CTL_INTERVAL_SHIFT (16) 381#define FBC_CTL_INTERVAL_SHIFT (16)
368#define FBC_CTL_UNCOMPRESSIBLE (1<<14) 382#define FBC_CTL_UNCOMPRESSIBLE (1<<14)
369#define FBC_C3_IDLE (1<<13) 383#define FBC_CTL_C3_IDLE (1<<13)
370#define FBC_CTL_STRIDE_SHIFT (5) 384#define FBC_CTL_STRIDE_SHIFT (5)
371#define FBC_CTL_FENCENO (1<<0) 385#define FBC_CTL_FENCENO (1<<0)
372#define FBC_COMMAND 0x0320c 386#define FBC_COMMAND 0x0320c
@@ -2172,6 +2186,14 @@
2172#define DISPLAY_PORT_PLL_BIOS_1 0x46010 2186#define DISPLAY_PORT_PLL_BIOS_1 0x46010
2173#define DISPLAY_PORT_PLL_BIOS_2 0x46014 2187#define DISPLAY_PORT_PLL_BIOS_2 0x46014
2174 2188
2189#define PCH_DSPCLK_GATE_D 0x42020
2190# define DPFDUNIT_CLOCK_GATE_DISABLE (1 << 7)
2191# define DPARBUNIT_CLOCK_GATE_DISABLE (1 << 5)
2192
2193#define PCH_3DCGDIS0 0x46020
2194# define MARIUNIT_CLOCK_GATE_DISABLE (1 << 18)
2195# define SVSMUNIT_CLOCK_GATE_DISABLE (1 << 1)
2196
2175#define FDI_PLL_FREQ_CTL 0x46030 2197#define FDI_PLL_FREQ_CTL 0x46030
2176#define FDI_PLL_FREQ_CHANGE_REQUEST (1<<24) 2198#define FDI_PLL_FREQ_CHANGE_REQUEST (1<<24)
2177#define FDI_PLL_FREQ_LOCK_LIMIT_MASK 0xfff00 2199#define FDI_PLL_FREQ_LOCK_LIMIT_MASK 0xfff00
@@ -2273,6 +2295,7 @@
2273#define DEIER 0x4400c 2295#define DEIER 0x4400c
2274 2296
2275/* GT interrupt */ 2297/* GT interrupt */
2298#define GT_PIPE_NOTIFY (1 << 4)
2276#define GT_SYNC_STATUS (1 << 2) 2299#define GT_SYNC_STATUS (1 << 2)
2277#define GT_USER_INTERRUPT (1 << 0) 2300#define GT_USER_INTERRUPT (1 << 0)
2278 2301
diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
index 70c9d4ba704..f9ba452f0cb 100644
--- a/drivers/gpu/drm/i915/intel_bios.c
+++ b/drivers/gpu/drm/i915/intel_bios.c
@@ -417,8 +417,9 @@ parse_edp(struct drm_i915_private *dev_priv, struct bdb_header *bdb)
417 edp = find_section(bdb, BDB_EDP); 417 edp = find_section(bdb, BDB_EDP);
418 if (!edp) { 418 if (!edp) {
419 if (SUPPORTS_EDP(dev_priv->dev) && dev_priv->edp_support) { 419 if (SUPPORTS_EDP(dev_priv->dev) && dev_priv->edp_support) {
420 DRM_DEBUG_KMS("No eDP BDB found but eDP panel supported,\ 420 DRM_DEBUG_KMS("No eDP BDB found but eDP panel "
421 assume 18bpp panel color depth.\n"); 421 "supported, assume 18bpp panel color "
422 "depth.\n");
422 dev_priv->edp_bpp = 18; 423 dev_priv->edp_bpp = 18;
423 } 424 }
424 return; 425 return;
diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c
index fccf07470c8..759c2ef72ef 100644
--- a/drivers/gpu/drm/i915/intel_crt.c
+++ b/drivers/gpu/drm/i915/intel_crt.c
@@ -25,6 +25,7 @@
25 */ 25 */
26 26
27#include <linux/i2c.h> 27#include <linux/i2c.h>
28#include <linux/slab.h>
28#include "drmP.h" 29#include "drmP.h"
29#include "drm.h" 30#include "drm.h"
30#include "drm_crtc.h" 31#include "drm_crtc.h"
@@ -246,19 +247,19 @@ static bool intel_crt_detect_hotplug(struct drm_connector *connector)
246 247
247static bool intel_crt_detect_ddc(struct drm_connector *connector) 248static bool intel_crt_detect_ddc(struct drm_connector *connector)
248{ 249{
249 struct intel_output *intel_output = to_intel_output(connector); 250 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
250 251
251 /* CRT should always be at 0, but check anyway */ 252 /* CRT should always be at 0, but check anyway */
252 if (intel_output->type != INTEL_OUTPUT_ANALOG) 253 if (intel_encoder->type != INTEL_OUTPUT_ANALOG)
253 return false; 254 return false;
254 255
255 return intel_ddc_probe(intel_output); 256 return intel_ddc_probe(intel_encoder);
256} 257}
257 258
258static enum drm_connector_status 259static enum drm_connector_status
259intel_crt_load_detect(struct drm_crtc *crtc, struct intel_output *intel_output) 260intel_crt_load_detect(struct drm_crtc *crtc, struct intel_encoder *intel_encoder)
260{ 261{
261 struct drm_encoder *encoder = &intel_output->enc; 262 struct drm_encoder *encoder = &intel_encoder->enc;
262 struct drm_device *dev = encoder->dev; 263 struct drm_device *dev = encoder->dev;
263 struct drm_i915_private *dev_priv = dev->dev_private; 264 struct drm_i915_private *dev_priv = dev->dev_private;
264 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 265 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
@@ -386,8 +387,8 @@ intel_crt_load_detect(struct drm_crtc *crtc, struct intel_output *intel_output)
386static enum drm_connector_status intel_crt_detect(struct drm_connector *connector) 387static enum drm_connector_status intel_crt_detect(struct drm_connector *connector)
387{ 388{
388 struct drm_device *dev = connector->dev; 389 struct drm_device *dev = connector->dev;
389 struct intel_output *intel_output = to_intel_output(connector); 390 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
390 struct drm_encoder *encoder = &intel_output->enc; 391 struct drm_encoder *encoder = &intel_encoder->enc;
391 struct drm_crtc *crtc; 392 struct drm_crtc *crtc;
392 int dpms_mode; 393 int dpms_mode;
393 enum drm_connector_status status; 394 enum drm_connector_status status;
@@ -404,13 +405,13 @@ static enum drm_connector_status intel_crt_detect(struct drm_connector *connecto
404 405
405 /* for pre-945g platforms use load detect */ 406 /* for pre-945g platforms use load detect */
406 if (encoder->crtc && encoder->crtc->enabled) { 407 if (encoder->crtc && encoder->crtc->enabled) {
407 status = intel_crt_load_detect(encoder->crtc, intel_output); 408 status = intel_crt_load_detect(encoder->crtc, intel_encoder);
408 } else { 409 } else {
409 crtc = intel_get_load_detect_pipe(intel_output, 410 crtc = intel_get_load_detect_pipe(intel_encoder,
410 NULL, &dpms_mode); 411 NULL, &dpms_mode);
411 if (crtc) { 412 if (crtc) {
412 status = intel_crt_load_detect(crtc, intel_output); 413 status = intel_crt_load_detect(crtc, intel_encoder);
413 intel_release_load_detect_pipe(intel_output, dpms_mode); 414 intel_release_load_detect_pipe(intel_encoder, dpms_mode);
414 } else 415 } else
415 status = connector_status_unknown; 416 status = connector_status_unknown;
416 } 417 }
@@ -420,9 +421,9 @@ static enum drm_connector_status intel_crt_detect(struct drm_connector *connecto
420 421
421static void intel_crt_destroy(struct drm_connector *connector) 422static void intel_crt_destroy(struct drm_connector *connector)
422{ 423{
423 struct intel_output *intel_output = to_intel_output(connector); 424 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
424 425
425 intel_i2c_destroy(intel_output->ddc_bus); 426 intel_i2c_destroy(intel_encoder->ddc_bus);
426 drm_sysfs_connector_remove(connector); 427 drm_sysfs_connector_remove(connector);
427 drm_connector_cleanup(connector); 428 drm_connector_cleanup(connector);
428 kfree(connector); 429 kfree(connector);
@@ -431,28 +432,28 @@ static void intel_crt_destroy(struct drm_connector *connector)
431static int intel_crt_get_modes(struct drm_connector *connector) 432static int intel_crt_get_modes(struct drm_connector *connector)
432{ 433{
433 int ret; 434 int ret;
434 struct intel_output *intel_output = to_intel_output(connector); 435 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
435 struct i2c_adapter *ddcbus; 436 struct i2c_adapter *ddcbus;
436 struct drm_device *dev = connector->dev; 437 struct drm_device *dev = connector->dev;
437 438
438 439
439 ret = intel_ddc_get_modes(intel_output); 440 ret = intel_ddc_get_modes(intel_encoder);
440 if (ret || !IS_G4X(dev)) 441 if (ret || !IS_G4X(dev))
441 goto end; 442 goto end;
442 443
443 ddcbus = intel_output->ddc_bus; 444 ddcbus = intel_encoder->ddc_bus;
444 /* Try to probe digital port for output in DVI-I -> VGA mode. */ 445 /* Try to probe digital port for output in DVI-I -> VGA mode. */
445 intel_output->ddc_bus = 446 intel_encoder->ddc_bus =
446 intel_i2c_create(connector->dev, GPIOD, "CRTDDC_D"); 447 intel_i2c_create(connector->dev, GPIOD, "CRTDDC_D");
447 448
448 if (!intel_output->ddc_bus) { 449 if (!intel_encoder->ddc_bus) {
449 intel_output->ddc_bus = ddcbus; 450 intel_encoder->ddc_bus = ddcbus;
450 dev_printk(KERN_ERR, &connector->dev->pdev->dev, 451 dev_printk(KERN_ERR, &connector->dev->pdev->dev,
451 "DDC bus registration failed for CRTDDC_D.\n"); 452 "DDC bus registration failed for CRTDDC_D.\n");
452 goto end; 453 goto end;
453 } 454 }
454 /* Try to get modes by GPIOD port */ 455 /* Try to get modes by GPIOD port */
455 ret = intel_ddc_get_modes(intel_output); 456 ret = intel_ddc_get_modes(intel_encoder);
456 intel_i2c_destroy(ddcbus); 457 intel_i2c_destroy(ddcbus);
457 458
458end: 459end:
@@ -505,23 +506,23 @@ static const struct drm_encoder_funcs intel_crt_enc_funcs = {
505void intel_crt_init(struct drm_device *dev) 506void intel_crt_init(struct drm_device *dev)
506{ 507{
507 struct drm_connector *connector; 508 struct drm_connector *connector;
508 struct intel_output *intel_output; 509 struct intel_encoder *intel_encoder;
509 struct drm_i915_private *dev_priv = dev->dev_private; 510 struct drm_i915_private *dev_priv = dev->dev_private;
510 u32 i2c_reg; 511 u32 i2c_reg;
511 512
512 intel_output = kzalloc(sizeof(struct intel_output), GFP_KERNEL); 513 intel_encoder = kzalloc(sizeof(struct intel_encoder), GFP_KERNEL);
513 if (!intel_output) 514 if (!intel_encoder)
514 return; 515 return;
515 516
516 connector = &intel_output->base; 517 connector = &intel_encoder->base;
517 drm_connector_init(dev, &intel_output->base, 518 drm_connector_init(dev, &intel_encoder->base,
518 &intel_crt_connector_funcs, DRM_MODE_CONNECTOR_VGA); 519 &intel_crt_connector_funcs, DRM_MODE_CONNECTOR_VGA);
519 520
520 drm_encoder_init(dev, &intel_output->enc, &intel_crt_enc_funcs, 521 drm_encoder_init(dev, &intel_encoder->enc, &intel_crt_enc_funcs,
521 DRM_MODE_ENCODER_DAC); 522 DRM_MODE_ENCODER_DAC);
522 523
523 drm_mode_connector_attach_encoder(&intel_output->base, 524 drm_mode_connector_attach_encoder(&intel_encoder->base,
524 &intel_output->enc); 525 &intel_encoder->enc);
525 526
526 /* Set up the DDC bus. */ 527 /* Set up the DDC bus. */
527 if (HAS_PCH_SPLIT(dev)) 528 if (HAS_PCH_SPLIT(dev))
@@ -532,22 +533,22 @@ void intel_crt_init(struct drm_device *dev)
532 if (dev_priv->crt_ddc_bus != 0) 533 if (dev_priv->crt_ddc_bus != 0)
533 i2c_reg = dev_priv->crt_ddc_bus; 534 i2c_reg = dev_priv->crt_ddc_bus;
534 } 535 }
535 intel_output->ddc_bus = intel_i2c_create(dev, i2c_reg, "CRTDDC_A"); 536 intel_encoder->ddc_bus = intel_i2c_create(dev, i2c_reg, "CRTDDC_A");
536 if (!intel_output->ddc_bus) { 537 if (!intel_encoder->ddc_bus) {
537 dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration " 538 dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration "
538 "failed.\n"); 539 "failed.\n");
539 return; 540 return;
540 } 541 }
541 542
542 intel_output->type = INTEL_OUTPUT_ANALOG; 543 intel_encoder->type = INTEL_OUTPUT_ANALOG;
543 intel_output->clone_mask = (1 << INTEL_SDVO_NON_TV_CLONE_BIT) | 544 intel_encoder->clone_mask = (1 << INTEL_SDVO_NON_TV_CLONE_BIT) |
544 (1 << INTEL_ANALOG_CLONE_BIT) | 545 (1 << INTEL_ANALOG_CLONE_BIT) |
545 (1 << INTEL_SDVO_LVDS_CLONE_BIT); 546 (1 << INTEL_SDVO_LVDS_CLONE_BIT);
546 intel_output->crtc_mask = (1 << 0) | (1 << 1); 547 intel_encoder->crtc_mask = (1 << 0) | (1 << 1);
547 connector->interlace_allowed = 0; 548 connector->interlace_allowed = 0;
548 connector->doublescan_allowed = 0; 549 connector->doublescan_allowed = 0;
549 550
550 drm_encoder_helper_add(&intel_output->enc, &intel_crt_helper_funcs); 551 drm_encoder_helper_add(&intel_encoder->enc, &intel_crt_helper_funcs);
551 drm_connector_helper_add(connector, &intel_crt_connector_helper_funcs); 552 drm_connector_helper_add(connector, &intel_crt_connector_helper_funcs);
552 553
553 drm_sysfs_connector_add(connector); 554 drm_sysfs_connector_add(connector);
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 9cd6de5f990..c7502b6b160 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -28,6 +28,7 @@
28#include <linux/input.h> 28#include <linux/input.h>
29#include <linux/i2c.h> 29#include <linux/i2c.h>
30#include <linux/kernel.h> 30#include <linux/kernel.h>
31#include <linux/slab.h>
31#include "drmP.h" 32#include "drmP.h"
32#include "intel_drv.h" 33#include "intel_drv.h"
33#include "i915_drm.h" 34#include "i915_drm.h"
@@ -746,16 +747,16 @@ bool intel_pipe_has_type (struct drm_crtc *crtc, int type)
746 list_for_each_entry(l_entry, &mode_config->connector_list, head) { 747 list_for_each_entry(l_entry, &mode_config->connector_list, head) {
747 if (l_entry->encoder && 748 if (l_entry->encoder &&
748 l_entry->encoder->crtc == crtc) { 749 l_entry->encoder->crtc == crtc) {
749 struct intel_output *intel_output = to_intel_output(l_entry); 750 struct intel_encoder *intel_encoder = to_intel_encoder(l_entry);
750 if (intel_output->type == type) 751 if (intel_encoder->type == type)
751 return true; 752 return true;
752 } 753 }
753 } 754 }
754 return false; 755 return false;
755} 756}
756 757
757struct drm_connector * 758static struct drm_connector *
758intel_pipe_get_output (struct drm_crtc *crtc) 759intel_pipe_get_connector (struct drm_crtc *crtc)
759{ 760{
760 struct drm_device *dev = crtc->dev; 761 struct drm_device *dev = crtc->dev;
761 struct drm_mode_config *mode_config = &dev->mode_config; 762 struct drm_mode_config *mode_config = &dev->mode_config;
@@ -1002,7 +1003,7 @@ static void i8xx_enable_fbc(struct drm_crtc *crtc, unsigned long interval)
1002 struct drm_i915_private *dev_priv = dev->dev_private; 1003 struct drm_i915_private *dev_priv = dev->dev_private;
1003 struct drm_framebuffer *fb = crtc->fb; 1004 struct drm_framebuffer *fb = crtc->fb;
1004 struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); 1005 struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb);
1005 struct drm_i915_gem_object *obj_priv = intel_fb->obj->driver_private; 1006 struct drm_i915_gem_object *obj_priv = to_intel_bo(intel_fb->obj);
1006 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 1007 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
1007 int plane, i; 1008 int plane, i;
1008 u32 fbc_ctl, fbc_ctl2; 1009 u32 fbc_ctl, fbc_ctl2;
@@ -1032,7 +1033,7 @@ static void i8xx_enable_fbc(struct drm_crtc *crtc, unsigned long interval)
1032 /* enable it... */ 1033 /* enable it... */
1033 fbc_ctl = FBC_CTL_EN | FBC_CTL_PERIODIC; 1034 fbc_ctl = FBC_CTL_EN | FBC_CTL_PERIODIC;
1034 if (IS_I945GM(dev)) 1035 if (IS_I945GM(dev))
1035 fbc_ctl |= FBC_C3_IDLE; /* 945 needs special SR handling */ 1036 fbc_ctl |= FBC_CTL_C3_IDLE; /* 945 needs special SR handling */
1036 fbc_ctl |= (dev_priv->cfb_pitch & 0xff) << FBC_CTL_STRIDE_SHIFT; 1037 fbc_ctl |= (dev_priv->cfb_pitch & 0xff) << FBC_CTL_STRIDE_SHIFT;
1037 fbc_ctl |= (interval & 0x2fff) << FBC_CTL_INTERVAL_SHIFT; 1038 fbc_ctl |= (interval & 0x2fff) << FBC_CTL_INTERVAL_SHIFT;
1038 if (obj_priv->tiling_mode != I915_TILING_NONE) 1039 if (obj_priv->tiling_mode != I915_TILING_NONE)
@@ -1079,7 +1080,7 @@ static void g4x_enable_fbc(struct drm_crtc *crtc, unsigned long interval)
1079 struct drm_i915_private *dev_priv = dev->dev_private; 1080 struct drm_i915_private *dev_priv = dev->dev_private;
1080 struct drm_framebuffer *fb = crtc->fb; 1081 struct drm_framebuffer *fb = crtc->fb;
1081 struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); 1082 struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb);
1082 struct drm_i915_gem_object *obj_priv = intel_fb->obj->driver_private; 1083 struct drm_i915_gem_object *obj_priv = to_intel_bo(intel_fb->obj);
1083 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 1084 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
1084 int plane = (intel_crtc->plane == 0 ? DPFC_CTL_PLANEA : 1085 int plane = (intel_crtc->plane == 0 ? DPFC_CTL_PLANEA :
1085 DPFC_CTL_PLANEB); 1086 DPFC_CTL_PLANEB);
@@ -1175,7 +1176,7 @@ static void intel_update_fbc(struct drm_crtc *crtc,
1175 return; 1176 return;
1176 1177
1177 intel_fb = to_intel_framebuffer(fb); 1178 intel_fb = to_intel_framebuffer(fb);
1178 obj_priv = intel_fb->obj->driver_private; 1179 obj_priv = to_intel_bo(intel_fb->obj);
1179 1180
1180 /* 1181 /*
1181 * If FBC is already on, we just have to verify that we can 1182 * If FBC is already on, we just have to verify that we can
@@ -1242,7 +1243,7 @@ out_disable:
1242static int 1243static int
1243intel_pin_and_fence_fb_obj(struct drm_device *dev, struct drm_gem_object *obj) 1244intel_pin_and_fence_fb_obj(struct drm_device *dev, struct drm_gem_object *obj)
1244{ 1245{
1245 struct drm_i915_gem_object *obj_priv = obj->driver_private; 1246 struct drm_i915_gem_object *obj_priv = to_intel_bo(obj);
1246 u32 alignment; 1247 u32 alignment;
1247 int ret; 1248 int ret;
1248 1249
@@ -1322,7 +1323,7 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
1322 1323
1323 intel_fb = to_intel_framebuffer(crtc->fb); 1324 intel_fb = to_intel_framebuffer(crtc->fb);
1324 obj = intel_fb->obj; 1325 obj = intel_fb->obj;
1325 obj_priv = obj->driver_private; 1326 obj_priv = to_intel_bo(obj);
1326 1327
1327 mutex_lock(&dev->struct_mutex); 1328 mutex_lock(&dev->struct_mutex);
1328 ret = intel_pin_and_fence_fb_obj(dev, obj); 1329 ret = intel_pin_and_fence_fb_obj(dev, obj);
@@ -1400,7 +1401,7 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
1400 1401
1401 if (old_fb) { 1402 if (old_fb) {
1402 intel_fb = to_intel_framebuffer(old_fb); 1403 intel_fb = to_intel_framebuffer(old_fb);
1403 obj_priv = intel_fb->obj->driver_private; 1404 obj_priv = to_intel_bo(intel_fb->obj);
1404 i915_gem_object_unpin(intel_fb->obj); 1405 i915_gem_object_unpin(intel_fb->obj);
1405 } 1406 }
1406 intel_increase_pllclock(crtc, true); 1407 intel_increase_pllclock(crtc, true);
@@ -2916,7 +2917,7 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
2916 int dspsize_reg = (plane == 0) ? DSPASIZE : DSPBSIZE; 2917 int dspsize_reg = (plane == 0) ? DSPASIZE : DSPBSIZE;
2917 int dsppos_reg = (plane == 0) ? DSPAPOS : DSPBPOS; 2918 int dsppos_reg = (plane == 0) ? DSPAPOS : DSPBPOS;
2918 int pipesrc_reg = (pipe == 0) ? PIPEASRC : PIPEBSRC; 2919 int pipesrc_reg = (pipe == 0) ? PIPEASRC : PIPEBSRC;
2919 int refclk, num_outputs = 0; 2920 int refclk, num_connectors = 0;
2920 intel_clock_t clock, reduced_clock; 2921 intel_clock_t clock, reduced_clock;
2921 u32 dpll = 0, fp = 0, fp2 = 0, dspcntr, pipeconf; 2922 u32 dpll = 0, fp = 0, fp2 = 0, dspcntr, pipeconf;
2922 bool ok, has_reduced_clock = false, is_sdvo = false, is_dvo = false; 2923 bool ok, has_reduced_clock = false, is_sdvo = false, is_dvo = false;
@@ -2942,19 +2943,19 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
2942 drm_vblank_pre_modeset(dev, pipe); 2943 drm_vblank_pre_modeset(dev, pipe);
2943 2944
2944 list_for_each_entry(connector, &mode_config->connector_list, head) { 2945 list_for_each_entry(connector, &mode_config->connector_list, head) {
2945 struct intel_output *intel_output = to_intel_output(connector); 2946 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
2946 2947
2947 if (!connector->encoder || connector->encoder->crtc != crtc) 2948 if (!connector->encoder || connector->encoder->crtc != crtc)
2948 continue; 2949 continue;
2949 2950
2950 switch (intel_output->type) { 2951 switch (intel_encoder->type) {
2951 case INTEL_OUTPUT_LVDS: 2952 case INTEL_OUTPUT_LVDS:
2952 is_lvds = true; 2953 is_lvds = true;
2953 break; 2954 break;
2954 case INTEL_OUTPUT_SDVO: 2955 case INTEL_OUTPUT_SDVO:
2955 case INTEL_OUTPUT_HDMI: 2956 case INTEL_OUTPUT_HDMI:
2956 is_sdvo = true; 2957 is_sdvo = true;
2957 if (intel_output->needs_tv_clock) 2958 if (intel_encoder->needs_tv_clock)
2958 is_tv = true; 2959 is_tv = true;
2959 break; 2960 break;
2960 case INTEL_OUTPUT_DVO: 2961 case INTEL_OUTPUT_DVO:
@@ -2974,10 +2975,10 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
2974 break; 2975 break;
2975 } 2976 }
2976 2977
2977 num_outputs++; 2978 num_connectors++;
2978 } 2979 }
2979 2980
2980 if (is_lvds && dev_priv->lvds_use_ssc && num_outputs < 2) { 2981 if (is_lvds && dev_priv->lvds_use_ssc && num_connectors < 2) {
2981 refclk = dev_priv->lvds_ssc_freq * 1000; 2982 refclk = dev_priv->lvds_ssc_freq * 1000;
2982 DRM_DEBUG_KMS("using SSC reference clock of %d MHz\n", 2983 DRM_DEBUG_KMS("using SSC reference clock of %d MHz\n",
2983 refclk / 1000); 2984 refclk / 1000);
@@ -3048,8 +3049,8 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
3048 if (is_edp) { 3049 if (is_edp) {
3049 struct drm_connector *edp; 3050 struct drm_connector *edp;
3050 target_clock = mode->clock; 3051 target_clock = mode->clock;
3051 edp = intel_pipe_get_output(crtc); 3052 edp = intel_pipe_get_connector(crtc);
3052 intel_edp_link_config(to_intel_output(edp), 3053 intel_edp_link_config(to_intel_encoder(edp),
3053 &lane, &link_bw); 3054 &lane, &link_bw);
3054 } else { 3055 } else {
3055 /* DP over FDI requires target mode clock 3056 /* DP over FDI requires target mode clock
@@ -3230,7 +3231,7 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
3230 /* XXX: just matching BIOS for now */ 3231 /* XXX: just matching BIOS for now */
3231 /* dpll |= PLL_REF_INPUT_TVCLKINBC; */ 3232 /* dpll |= PLL_REF_INPUT_TVCLKINBC; */
3232 dpll |= 3; 3233 dpll |= 3;
3233 else if (is_lvds && dev_priv->lvds_use_ssc && num_outputs < 2) 3234 else if (is_lvds && dev_priv->lvds_use_ssc && num_connectors < 2)
3234 dpll |= PLLB_REF_INPUT_SPREADSPECTRUMIN; 3235 dpll |= PLLB_REF_INPUT_SPREADSPECTRUMIN;
3235 else 3236 else
3236 dpll |= PLL_REF_INPUT_DREFCLK; 3237 dpll |= PLL_REF_INPUT_DREFCLK;
@@ -3510,7 +3511,7 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc,
3510 if (!bo) 3511 if (!bo)
3511 return -ENOENT; 3512 return -ENOENT;
3512 3513
3513 obj_priv = bo->driver_private; 3514 obj_priv = to_intel_bo(bo);
3514 3515
3515 if (bo->size < width * height * 4) { 3516 if (bo->size < width * height * 4) {
3516 DRM_ERROR("buffer is to small\n"); 3517 DRM_ERROR("buffer is to small\n");
@@ -3654,9 +3655,9 @@ static void intel_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
3654 * detection. 3655 * detection.
3655 * 3656 *
3656 * It will be up to the load-detect code to adjust the pipe as appropriate for 3657 * It will be up to the load-detect code to adjust the pipe as appropriate for
3657 * its requirements. The pipe will be connected to no other outputs. 3658 * its requirements. The pipe will be connected to no other encoders.
3658 * 3659 *
3659 * Currently this code will only succeed if there is a pipe with no outputs 3660 * Currently this code will only succeed if there is a pipe with no encoders
3660 * configured for it. In the future, it could choose to temporarily disable 3661 * configured for it. In the future, it could choose to temporarily disable
3661 * some outputs to free up a pipe for its use. 3662 * some outputs to free up a pipe for its use.
3662 * 3663 *
@@ -3669,14 +3670,14 @@ static struct drm_display_mode load_detect_mode = {
3669 704, 832, 0, 480, 489, 491, 520, 0, DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC), 3670 704, 832, 0, 480, 489, 491, 520, 0, DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
3670}; 3671};
3671 3672
3672struct drm_crtc *intel_get_load_detect_pipe(struct intel_output *intel_output, 3673struct drm_crtc *intel_get_load_detect_pipe(struct intel_encoder *intel_encoder,
3673 struct drm_display_mode *mode, 3674 struct drm_display_mode *mode,
3674 int *dpms_mode) 3675 int *dpms_mode)
3675{ 3676{
3676 struct intel_crtc *intel_crtc; 3677 struct intel_crtc *intel_crtc;
3677 struct drm_crtc *possible_crtc; 3678 struct drm_crtc *possible_crtc;
3678 struct drm_crtc *supported_crtc =NULL; 3679 struct drm_crtc *supported_crtc =NULL;
3679 struct drm_encoder *encoder = &intel_output->enc; 3680 struct drm_encoder *encoder = &intel_encoder->enc;
3680 struct drm_crtc *crtc = NULL; 3681 struct drm_crtc *crtc = NULL;
3681 struct drm_device *dev = encoder->dev; 3682 struct drm_device *dev = encoder->dev;
3682 struct drm_encoder_helper_funcs *encoder_funcs = encoder->helper_private; 3683 struct drm_encoder_helper_funcs *encoder_funcs = encoder->helper_private;
@@ -3728,8 +3729,8 @@ struct drm_crtc *intel_get_load_detect_pipe(struct intel_output *intel_output,
3728 } 3729 }
3729 3730
3730 encoder->crtc = crtc; 3731 encoder->crtc = crtc;
3731 intel_output->base.encoder = encoder; 3732 intel_encoder->base.encoder = encoder;
3732 intel_output->load_detect_temp = true; 3733 intel_encoder->load_detect_temp = true;
3733 3734
3734 intel_crtc = to_intel_crtc(crtc); 3735 intel_crtc = to_intel_crtc(crtc);
3735 *dpms_mode = intel_crtc->dpms_mode; 3736 *dpms_mode = intel_crtc->dpms_mode;
@@ -3754,23 +3755,23 @@ struct drm_crtc *intel_get_load_detect_pipe(struct intel_output *intel_output,
3754 return crtc; 3755 return crtc;
3755} 3756}
3756 3757
3757void intel_release_load_detect_pipe(struct intel_output *intel_output, int dpms_mode) 3758void intel_release_load_detect_pipe(struct intel_encoder *intel_encoder, int dpms_mode)
3758{ 3759{
3759 struct drm_encoder *encoder = &intel_output->enc; 3760 struct drm_encoder *encoder = &intel_encoder->enc;
3760 struct drm_device *dev = encoder->dev; 3761 struct drm_device *dev = encoder->dev;
3761 struct drm_crtc *crtc = encoder->crtc; 3762 struct drm_crtc *crtc = encoder->crtc;
3762 struct drm_encoder_helper_funcs *encoder_funcs = encoder->helper_private; 3763 struct drm_encoder_helper_funcs *encoder_funcs = encoder->helper_private;
3763 struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; 3764 struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
3764 3765
3765 if (intel_output->load_detect_temp) { 3766 if (intel_encoder->load_detect_temp) {
3766 encoder->crtc = NULL; 3767 encoder->crtc = NULL;
3767 intel_output->base.encoder = NULL; 3768 intel_encoder->base.encoder = NULL;
3768 intel_output->load_detect_temp = false; 3769 intel_encoder->load_detect_temp = false;
3769 crtc->enabled = drm_helper_crtc_in_use(crtc); 3770 crtc->enabled = drm_helper_crtc_in_use(crtc);
3770 drm_helper_disable_unused_functions(dev); 3771 drm_helper_disable_unused_functions(dev);
3771 } 3772 }
3772 3773
3773 /* Switch crtc and output back off if necessary */ 3774 /* Switch crtc and encoder back off if necessary */
3774 if (crtc->enabled && dpms_mode != DRM_MODE_DPMS_ON) { 3775 if (crtc->enabled && dpms_mode != DRM_MODE_DPMS_ON) {
3775 if (encoder->crtc == crtc) 3776 if (encoder->crtc == crtc)
3776 encoder_funcs->dpms(encoder, dpms_mode); 3777 encoder_funcs->dpms(encoder, dpms_mode);
@@ -4155,7 +4156,7 @@ void intel_finish_page_flip(struct drm_device *dev, int pipe)
4155 work = intel_crtc->unpin_work; 4156 work = intel_crtc->unpin_work;
4156 if (work == NULL || !work->pending) { 4157 if (work == NULL || !work->pending) {
4157 if (work && !work->pending) { 4158 if (work && !work->pending) {
4158 obj_priv = work->pending_flip_obj->driver_private; 4159 obj_priv = to_intel_bo(work->pending_flip_obj);
4159 DRM_DEBUG_DRIVER("flip finish: %p (%d) not pending?\n", 4160 DRM_DEBUG_DRIVER("flip finish: %p (%d) not pending?\n",
4160 obj_priv, 4161 obj_priv,
4161 atomic_read(&obj_priv->pending_flip)); 4162 atomic_read(&obj_priv->pending_flip));
@@ -4180,7 +4181,7 @@ void intel_finish_page_flip(struct drm_device *dev, int pipe)
4180 4181
4181 spin_unlock_irqrestore(&dev->event_lock, flags); 4182 spin_unlock_irqrestore(&dev->event_lock, flags);
4182 4183
4183 obj_priv = work->pending_flip_obj->driver_private; 4184 obj_priv = to_intel_bo(work->pending_flip_obj);
4184 4185
4185 /* Initial scanout buffer will have a 0 pending flip count */ 4186 /* Initial scanout buffer will have a 0 pending flip count */
4186 if ((atomic_read(&obj_priv->pending_flip) == 0) || 4187 if ((atomic_read(&obj_priv->pending_flip) == 0) ||
@@ -4251,7 +4252,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
4251 ret = intel_pin_and_fence_fb_obj(dev, obj); 4252 ret = intel_pin_and_fence_fb_obj(dev, obj);
4252 if (ret != 0) { 4253 if (ret != 0) {
4253 DRM_DEBUG_DRIVER("flip queue: %p pin & fence failed\n", 4254 DRM_DEBUG_DRIVER("flip queue: %p pin & fence failed\n",
4254 obj->driver_private); 4255 to_intel_bo(obj));
4255 kfree(work); 4256 kfree(work);
4256 intel_crtc->unpin_work = NULL; 4257 intel_crtc->unpin_work = NULL;
4257 mutex_unlock(&dev->struct_mutex); 4258 mutex_unlock(&dev->struct_mutex);
@@ -4265,7 +4266,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
4265 crtc->fb = fb; 4266 crtc->fb = fb;
4266 i915_gem_object_flush_write_domain(obj); 4267 i915_gem_object_flush_write_domain(obj);
4267 drm_vblank_get(dev, intel_crtc->pipe); 4268 drm_vblank_get(dev, intel_crtc->pipe);
4268 obj_priv = obj->driver_private; 4269 obj_priv = to_intel_bo(obj);
4269 atomic_inc(&obj_priv->pending_flip); 4270 atomic_inc(&obj_priv->pending_flip);
4270 work->pending_flip_obj = obj; 4271 work->pending_flip_obj = obj;
4271 4272
@@ -4398,8 +4399,8 @@ static int intel_connector_clones(struct drm_device *dev, int type_mask)
4398 int entry = 0; 4399 int entry = 0;
4399 4400
4400 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 4401 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
4401 struct intel_output *intel_output = to_intel_output(connector); 4402 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
4402 if (type_mask & intel_output->clone_mask) 4403 if (type_mask & intel_encoder->clone_mask)
4403 index_mask |= (1 << entry); 4404 index_mask |= (1 << entry);
4404 entry++; 4405 entry++;
4405 } 4406 }
@@ -4494,12 +4495,12 @@ static void intel_setup_outputs(struct drm_device *dev)
4494 intel_tv_init(dev); 4495 intel_tv_init(dev);
4495 4496
4496 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 4497 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
4497 struct intel_output *intel_output = to_intel_output(connector); 4498 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
4498 struct drm_encoder *encoder = &intel_output->enc; 4499 struct drm_encoder *encoder = &intel_encoder->enc;
4499 4500
4500 encoder->possible_crtcs = intel_output->crtc_mask; 4501 encoder->possible_crtcs = intel_encoder->crtc_mask;
4501 encoder->possible_clones = intel_connector_clones(dev, 4502 encoder->possible_clones = intel_connector_clones(dev,
4502 intel_output->clone_mask); 4503 intel_encoder->clone_mask);
4503 } 4504 }
4504} 4505}
4505 4506
@@ -4717,6 +4718,20 @@ void intel_init_clock_gating(struct drm_device *dev)
4717 * specs, but enable as much else as we can. 4718 * specs, but enable as much else as we can.
4718 */ 4719 */
4719 if (HAS_PCH_SPLIT(dev)) { 4720 if (HAS_PCH_SPLIT(dev)) {
4721 uint32_t dspclk_gate = VRHUNIT_CLOCK_GATE_DISABLE;
4722
4723 if (IS_IRONLAKE(dev)) {
4724 /* Required for FBC */
4725 dspclk_gate |= DPFDUNIT_CLOCK_GATE_DISABLE;
4726 /* Required for CxSR */
4727 dspclk_gate |= DPARBUNIT_CLOCK_GATE_DISABLE;
4728
4729 I915_WRITE(PCH_3DCGDIS0,
4730 MARIUNIT_CLOCK_GATE_DISABLE |
4731 SVSMUNIT_CLOCK_GATE_DISABLE);
4732 }
4733
4734 I915_WRITE(PCH_DSPCLK_GATE_D, dspclk_gate);
4720 return; 4735 return;
4721 } else if (IS_G4X(dev)) { 4736 } else if (IS_G4X(dev)) {
4722 uint32_t dspclk_gate; 4737 uint32_t dspclk_gate;
@@ -4764,14 +4779,14 @@ void intel_init_clock_gating(struct drm_device *dev)
4764 struct drm_i915_gem_object *obj_priv = NULL; 4779 struct drm_i915_gem_object *obj_priv = NULL;
4765 4780
4766 if (dev_priv->pwrctx) { 4781 if (dev_priv->pwrctx) {
4767 obj_priv = dev_priv->pwrctx->driver_private; 4782 obj_priv = to_intel_bo(dev_priv->pwrctx);
4768 } else { 4783 } else {
4769 struct drm_gem_object *pwrctx; 4784 struct drm_gem_object *pwrctx;
4770 4785
4771 pwrctx = intel_alloc_power_context(dev); 4786 pwrctx = intel_alloc_power_context(dev);
4772 if (pwrctx) { 4787 if (pwrctx) {
4773 dev_priv->pwrctx = pwrctx; 4788 dev_priv->pwrctx = pwrctx;
4774 obj_priv = pwrctx->driver_private; 4789 obj_priv = to_intel_bo(pwrctx);
4775 } 4790 }
4776 } 4791 }
4777 4792
@@ -4800,7 +4815,7 @@ static void intel_init_display(struct drm_device *dev)
4800 dev_priv->display.fbc_enabled = g4x_fbc_enabled; 4815 dev_priv->display.fbc_enabled = g4x_fbc_enabled;
4801 dev_priv->display.enable_fbc = g4x_enable_fbc; 4816 dev_priv->display.enable_fbc = g4x_enable_fbc;
4802 dev_priv->display.disable_fbc = g4x_disable_fbc; 4817 dev_priv->display.disable_fbc = g4x_disable_fbc;
4803 } else if (IS_I965GM(dev) || IS_I945GM(dev) || IS_I915GM(dev)) { 4818 } else if (IS_I965GM(dev)) {
4804 dev_priv->display.fbc_enabled = i8xx_fbc_enabled; 4819 dev_priv->display.fbc_enabled = i8xx_fbc_enabled;
4805 dev_priv->display.enable_fbc = i8xx_enable_fbc; 4820 dev_priv->display.enable_fbc = i8xx_enable_fbc;
4806 dev_priv->display.disable_fbc = i8xx_disable_fbc; 4821 dev_priv->display.disable_fbc = i8xx_disable_fbc;
@@ -4838,17 +4853,18 @@ static void intel_init_display(struct drm_device *dev)
4838 dev_priv->display.update_wm = g4x_update_wm; 4853 dev_priv->display.update_wm = g4x_update_wm;
4839 else if (IS_I965G(dev)) 4854 else if (IS_I965G(dev))
4840 dev_priv->display.update_wm = i965_update_wm; 4855 dev_priv->display.update_wm = i965_update_wm;
4841 else if (IS_I9XX(dev) || IS_MOBILE(dev)) { 4856 else if (IS_I9XX(dev)) {
4842 dev_priv->display.update_wm = i9xx_update_wm; 4857 dev_priv->display.update_wm = i9xx_update_wm;
4843 dev_priv->display.get_fifo_size = i9xx_get_fifo_size; 4858 dev_priv->display.get_fifo_size = i9xx_get_fifo_size;
4859 } else if (IS_I85X(dev)) {
4860 dev_priv->display.update_wm = i9xx_update_wm;
4861 dev_priv->display.get_fifo_size = i85x_get_fifo_size;
4844 } else { 4862 } else {
4845 if (IS_I85X(dev)) 4863 dev_priv->display.update_wm = i830_update_wm;
4846 dev_priv->display.get_fifo_size = i85x_get_fifo_size; 4864 if (IS_845G(dev))
4847 else if (IS_845G(dev))
4848 dev_priv->display.get_fifo_size = i845_get_fifo_size; 4865 dev_priv->display.get_fifo_size = i845_get_fifo_size;
4849 else 4866 else
4850 dev_priv->display.get_fifo_size = i830_get_fifo_size; 4867 dev_priv->display.get_fifo_size = i830_get_fifo_size;
4851 dev_priv->display.update_wm = i830_update_wm;
4852 } 4868 }
4853} 4869}
4854 4870
@@ -4942,7 +4958,7 @@ void intel_modeset_cleanup(struct drm_device *dev)
4942 if (dev_priv->pwrctx) { 4958 if (dev_priv->pwrctx) {
4943 struct drm_i915_gem_object *obj_priv; 4959 struct drm_i915_gem_object *obj_priv;
4944 4960
4945 obj_priv = dev_priv->pwrctx->driver_private; 4961 obj_priv = to_intel_bo(dev_priv->pwrctx);
4946 I915_WRITE(PWRCTXA, obj_priv->gtt_offset &~ PWRCTX_EN); 4962 I915_WRITE(PWRCTXA, obj_priv->gtt_offset &~ PWRCTX_EN);
4947 I915_READ(PWRCTXA); 4963 I915_READ(PWRCTXA);
4948 i915_gem_object_unpin(dev_priv->pwrctx); 4964 i915_gem_object_unpin(dev_priv->pwrctx);
@@ -4963,9 +4979,9 @@ void intel_modeset_cleanup(struct drm_device *dev)
4963*/ 4979*/
4964struct drm_encoder *intel_best_encoder(struct drm_connector *connector) 4980struct drm_encoder *intel_best_encoder(struct drm_connector *connector)
4965{ 4981{
4966 struct intel_output *intel_output = to_intel_output(connector); 4982 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
4967 4983
4968 return &intel_output->enc; 4984 return &intel_encoder->enc;
4969} 4985}
4970 4986
4971/* 4987/*
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 3ef3a0d0edd..77e40cfcf21 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <linux/slab.h>
29#include "drmP.h" 30#include "drmP.h"
30#include "drm.h" 31#include "drm.h"
31#include "drm_crtc.h" 32#include "drm_crtc.h"
@@ -54,23 +55,23 @@ struct intel_dp_priv {
54 uint8_t link_bw; 55 uint8_t link_bw;
55 uint8_t lane_count; 56 uint8_t lane_count;
56 uint8_t dpcd[4]; 57 uint8_t dpcd[4];
57 struct intel_output *intel_output; 58 struct intel_encoder *intel_encoder;
58 struct i2c_adapter adapter; 59 struct i2c_adapter adapter;
59 struct i2c_algo_dp_aux_data algo; 60 struct i2c_algo_dp_aux_data algo;
60}; 61};
61 62
62static void 63static void
63intel_dp_link_train(struct intel_output *intel_output, uint32_t DP, 64intel_dp_link_train(struct intel_encoder *intel_encoder, uint32_t DP,
64 uint8_t link_configuration[DP_LINK_CONFIGURATION_SIZE]); 65 uint8_t link_configuration[DP_LINK_CONFIGURATION_SIZE]);
65 66
66static void 67static void
67intel_dp_link_down(struct intel_output *intel_output, uint32_t DP); 68intel_dp_link_down(struct intel_encoder *intel_encoder, uint32_t DP);
68 69
69void 70void
70intel_edp_link_config (struct intel_output *intel_output, 71intel_edp_link_config (struct intel_encoder *intel_encoder,
71 int *lane_num, int *link_bw) 72 int *lane_num, int *link_bw)
72{ 73{
73 struct intel_dp_priv *dp_priv = intel_output->dev_priv; 74 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv;
74 75
75 *lane_num = dp_priv->lane_count; 76 *lane_num = dp_priv->lane_count;
76 if (dp_priv->link_bw == DP_LINK_BW_1_62) 77 if (dp_priv->link_bw == DP_LINK_BW_1_62)
@@ -80,9 +81,9 @@ intel_edp_link_config (struct intel_output *intel_output,
80} 81}
81 82
82static int 83static int
83intel_dp_max_lane_count(struct intel_output *intel_output) 84intel_dp_max_lane_count(struct intel_encoder *intel_encoder)
84{ 85{
85 struct intel_dp_priv *dp_priv = intel_output->dev_priv; 86 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv;
86 int max_lane_count = 4; 87 int max_lane_count = 4;
87 88
88 if (dp_priv->dpcd[0] >= 0x11) { 89 if (dp_priv->dpcd[0] >= 0x11) {
@@ -98,9 +99,9 @@ intel_dp_max_lane_count(struct intel_output *intel_output)
98} 99}
99 100
100static int 101static int
101intel_dp_max_link_bw(struct intel_output *intel_output) 102intel_dp_max_link_bw(struct intel_encoder *intel_encoder)
102{ 103{
103 struct intel_dp_priv *dp_priv = intel_output->dev_priv; 104 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv;
104 int max_link_bw = dp_priv->dpcd[1]; 105 int max_link_bw = dp_priv->dpcd[1];
105 106
106 switch (max_link_bw) { 107 switch (max_link_bw) {
@@ -126,11 +127,11 @@ intel_dp_link_clock(uint8_t link_bw)
126/* I think this is a fiction */ 127/* I think this is a fiction */
127static int 128static int
128intel_dp_link_required(struct drm_device *dev, 129intel_dp_link_required(struct drm_device *dev,
129 struct intel_output *intel_output, int pixel_clock) 130 struct intel_encoder *intel_encoder, int pixel_clock)
130{ 131{
131 struct drm_i915_private *dev_priv = dev->dev_private; 132 struct drm_i915_private *dev_priv = dev->dev_private;
132 133
133 if (IS_eDP(intel_output)) 134 if (IS_eDP(intel_encoder))
134 return (pixel_clock * dev_priv->edp_bpp) / 8; 135 return (pixel_clock * dev_priv->edp_bpp) / 8;
135 else 136 else
136 return pixel_clock * 3; 137 return pixel_clock * 3;
@@ -140,11 +141,11 @@ static int
140intel_dp_mode_valid(struct drm_connector *connector, 141intel_dp_mode_valid(struct drm_connector *connector,
141 struct drm_display_mode *mode) 142 struct drm_display_mode *mode)
142{ 143{
143 struct intel_output *intel_output = to_intel_output(connector); 144 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
144 int max_link_clock = intel_dp_link_clock(intel_dp_max_link_bw(intel_output)); 145 int max_link_clock = intel_dp_link_clock(intel_dp_max_link_bw(intel_encoder));
145 int max_lanes = intel_dp_max_lane_count(intel_output); 146 int max_lanes = intel_dp_max_lane_count(intel_encoder);
146 147
147 if (intel_dp_link_required(connector->dev, intel_output, mode->clock) 148 if (intel_dp_link_required(connector->dev, intel_encoder, mode->clock)
148 > max_link_clock * max_lanes) 149 > max_link_clock * max_lanes)
149 return MODE_CLOCK_HIGH; 150 return MODE_CLOCK_HIGH;
150 151
@@ -208,13 +209,13 @@ intel_hrawclk(struct drm_device *dev)
208} 209}
209 210
210static int 211static int
211intel_dp_aux_ch(struct intel_output *intel_output, 212intel_dp_aux_ch(struct intel_encoder *intel_encoder,
212 uint8_t *send, int send_bytes, 213 uint8_t *send, int send_bytes,
213 uint8_t *recv, int recv_size) 214 uint8_t *recv, int recv_size)
214{ 215{
215 struct intel_dp_priv *dp_priv = intel_output->dev_priv; 216 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv;
216 uint32_t output_reg = dp_priv->output_reg; 217 uint32_t output_reg = dp_priv->output_reg;
217 struct drm_device *dev = intel_output->base.dev; 218 struct drm_device *dev = intel_encoder->base.dev;
218 struct drm_i915_private *dev_priv = dev->dev_private; 219 struct drm_i915_private *dev_priv = dev->dev_private;
219 uint32_t ch_ctl = output_reg + 0x10; 220 uint32_t ch_ctl = output_reg + 0x10;
220 uint32_t ch_data = ch_ctl + 4; 221 uint32_t ch_data = ch_ctl + 4;
@@ -229,7 +230,7 @@ intel_dp_aux_ch(struct intel_output *intel_output,
229 * and would like to run at 2MHz. So, take the 230 * and would like to run at 2MHz. So, take the
230 * hrawclk value and divide by 2 and use that 231 * hrawclk value and divide by 2 and use that
231 */ 232 */
232 if (IS_eDP(intel_output)) 233 if (IS_eDP(intel_encoder))
233 aux_clock_divider = 225; /* eDP input clock at 450Mhz */ 234 aux_clock_divider = 225; /* eDP input clock at 450Mhz */
234 else if (HAS_PCH_SPLIT(dev)) 235 else if (HAS_PCH_SPLIT(dev))
235 aux_clock_divider = 62; /* IRL input clock fixed at 125Mhz */ 236 aux_clock_divider = 62; /* IRL input clock fixed at 125Mhz */
@@ -312,7 +313,7 @@ intel_dp_aux_ch(struct intel_output *intel_output,
312 313
313/* Write data to the aux channel in native mode */ 314/* Write data to the aux channel in native mode */
314static int 315static int
315intel_dp_aux_native_write(struct intel_output *intel_output, 316intel_dp_aux_native_write(struct intel_encoder *intel_encoder,
316 uint16_t address, uint8_t *send, int send_bytes) 317 uint16_t address, uint8_t *send, int send_bytes)
317{ 318{
318 int ret; 319 int ret;
@@ -329,7 +330,7 @@ intel_dp_aux_native_write(struct intel_output *intel_output,
329 memcpy(&msg[4], send, send_bytes); 330 memcpy(&msg[4], send, send_bytes);
330 msg_bytes = send_bytes + 4; 331 msg_bytes = send_bytes + 4;
331 for (;;) { 332 for (;;) {
332 ret = intel_dp_aux_ch(intel_output, msg, msg_bytes, &ack, 1); 333 ret = intel_dp_aux_ch(intel_encoder, msg, msg_bytes, &ack, 1);
333 if (ret < 0) 334 if (ret < 0)
334 return ret; 335 return ret;
335 if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_ACK) 336 if ((ack & AUX_NATIVE_REPLY_MASK) == AUX_NATIVE_REPLY_ACK)
@@ -344,15 +345,15 @@ intel_dp_aux_native_write(struct intel_output *intel_output,
344 345
345/* Write a single byte to the aux channel in native mode */ 346/* Write a single byte to the aux channel in native mode */
346static int 347static int
347intel_dp_aux_native_write_1(struct intel_output *intel_output, 348intel_dp_aux_native_write_1(struct intel_encoder *intel_encoder,
348 uint16_t address, uint8_t byte) 349 uint16_t address, uint8_t byte)
349{ 350{
350 return intel_dp_aux_native_write(intel_output, address, &byte, 1); 351 return intel_dp_aux_native_write(intel_encoder, address, &byte, 1);
351} 352}
352 353
353/* read bytes from a native aux channel */ 354/* read bytes from a native aux channel */
354static int 355static int
355intel_dp_aux_native_read(struct intel_output *intel_output, 356intel_dp_aux_native_read(struct intel_encoder *intel_encoder,
356 uint16_t address, uint8_t *recv, int recv_bytes) 357 uint16_t address, uint8_t *recv, int recv_bytes)
357{ 358{
358 uint8_t msg[4]; 359 uint8_t msg[4];
@@ -371,7 +372,7 @@ intel_dp_aux_native_read(struct intel_output *intel_output,
371 reply_bytes = recv_bytes + 1; 372 reply_bytes = recv_bytes + 1;
372 373
373 for (;;) { 374 for (;;) {
374 ret = intel_dp_aux_ch(intel_output, msg, msg_bytes, 375 ret = intel_dp_aux_ch(intel_encoder, msg, msg_bytes,
375 reply, reply_bytes); 376 reply, reply_bytes);
376 if (ret == 0) 377 if (ret == 0)
377 return -EPROTO; 378 return -EPROTO;
@@ -397,7 +398,7 @@ intel_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode,
397 struct intel_dp_priv *dp_priv = container_of(adapter, 398 struct intel_dp_priv *dp_priv = container_of(adapter,
398 struct intel_dp_priv, 399 struct intel_dp_priv,
399 adapter); 400 adapter);
400 struct intel_output *intel_output = dp_priv->intel_output; 401 struct intel_encoder *intel_encoder = dp_priv->intel_encoder;
401 uint16_t address = algo_data->address; 402 uint16_t address = algo_data->address;
402 uint8_t msg[5]; 403 uint8_t msg[5];
403 uint8_t reply[2]; 404 uint8_t reply[2];
@@ -436,7 +437,7 @@ intel_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode,
436 } 437 }
437 438
438 for (;;) { 439 for (;;) {
439 ret = intel_dp_aux_ch(intel_output, 440 ret = intel_dp_aux_ch(intel_encoder,
440 msg, msg_bytes, 441 msg, msg_bytes,
441 reply, reply_bytes); 442 reply, reply_bytes);
442 if (ret < 0) { 443 if (ret < 0) {
@@ -464,9 +465,9 @@ intel_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode,
464} 465}
465 466
466static int 467static int
467intel_dp_i2c_init(struct intel_output *intel_output, const char *name) 468intel_dp_i2c_init(struct intel_encoder *intel_encoder, const char *name)
468{ 469{
469 struct intel_dp_priv *dp_priv = intel_output->dev_priv; 470 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv;
470 471
471 DRM_DEBUG_KMS("i2c_init %s\n", name); 472 DRM_DEBUG_KMS("i2c_init %s\n", name);
472 dp_priv->algo.running = false; 473 dp_priv->algo.running = false;
@@ -479,7 +480,7 @@ intel_dp_i2c_init(struct intel_output *intel_output, const char *name)
479 strncpy (dp_priv->adapter.name, name, sizeof(dp_priv->adapter.name) - 1); 480 strncpy (dp_priv->adapter.name, name, sizeof(dp_priv->adapter.name) - 1);
480 dp_priv->adapter.name[sizeof(dp_priv->adapter.name) - 1] = '\0'; 481 dp_priv->adapter.name[sizeof(dp_priv->adapter.name) - 1] = '\0';
481 dp_priv->adapter.algo_data = &dp_priv->algo; 482 dp_priv->adapter.algo_data = &dp_priv->algo;
482 dp_priv->adapter.dev.parent = &intel_output->base.kdev; 483 dp_priv->adapter.dev.parent = &intel_encoder->base.kdev;
483 484
484 return i2c_dp_aux_add_bus(&dp_priv->adapter); 485 return i2c_dp_aux_add_bus(&dp_priv->adapter);
485} 486}
@@ -488,18 +489,18 @@ static bool
488intel_dp_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode, 489intel_dp_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode,
489 struct drm_display_mode *adjusted_mode) 490 struct drm_display_mode *adjusted_mode)
490{ 491{
491 struct intel_output *intel_output = enc_to_intel_output(encoder); 492 struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder);
492 struct intel_dp_priv *dp_priv = intel_output->dev_priv; 493 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv;
493 int lane_count, clock; 494 int lane_count, clock;
494 int max_lane_count = intel_dp_max_lane_count(intel_output); 495 int max_lane_count = intel_dp_max_lane_count(intel_encoder);
495 int max_clock = intel_dp_max_link_bw(intel_output) == DP_LINK_BW_2_7 ? 1 : 0; 496 int max_clock = intel_dp_max_link_bw(intel_encoder) == DP_LINK_BW_2_7 ? 1 : 0;
496 static int bws[2] = { DP_LINK_BW_1_62, DP_LINK_BW_2_7 }; 497 static int bws[2] = { DP_LINK_BW_1_62, DP_LINK_BW_2_7 };
497 498
498 for (lane_count = 1; lane_count <= max_lane_count; lane_count <<= 1) { 499 for (lane_count = 1; lane_count <= max_lane_count; lane_count <<= 1) {
499 for (clock = 0; clock <= max_clock; clock++) { 500 for (clock = 0; clock <= max_clock; clock++) {
500 int link_avail = intel_dp_link_clock(bws[clock]) * lane_count; 501 int link_avail = intel_dp_link_clock(bws[clock]) * lane_count;
501 502
502 if (intel_dp_link_required(encoder->dev, intel_output, mode->clock) 503 if (intel_dp_link_required(encoder->dev, intel_encoder, mode->clock)
503 <= link_avail) { 504 <= link_avail) {
504 dp_priv->link_bw = bws[clock]; 505 dp_priv->link_bw = bws[clock];
505 dp_priv->lane_count = lane_count; 506 dp_priv->lane_count = lane_count;
@@ -561,16 +562,16 @@ intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode,
561 struct intel_dp_m_n m_n; 562 struct intel_dp_m_n m_n;
562 563
563 /* 564 /*
564 * Find the lane count in the intel_output private 565 * Find the lane count in the intel_encoder private
565 */ 566 */
566 list_for_each_entry(connector, &mode_config->connector_list, head) { 567 list_for_each_entry(connector, &mode_config->connector_list, head) {
567 struct intel_output *intel_output = to_intel_output(connector); 568 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
568 struct intel_dp_priv *dp_priv = intel_output->dev_priv; 569 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv;
569 570
570 if (!connector->encoder || connector->encoder->crtc != crtc) 571 if (!connector->encoder || connector->encoder->crtc != crtc)
571 continue; 572 continue;
572 573
573 if (intel_output->type == INTEL_OUTPUT_DISPLAYPORT) { 574 if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT) {
574 lane_count = dp_priv->lane_count; 575 lane_count = dp_priv->lane_count;
575 break; 576 break;
576 } 577 }
@@ -625,9 +626,9 @@ static void
625intel_dp_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode, 626intel_dp_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode,
626 struct drm_display_mode *adjusted_mode) 627 struct drm_display_mode *adjusted_mode)
627{ 628{
628 struct intel_output *intel_output = enc_to_intel_output(encoder); 629 struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder);
629 struct intel_dp_priv *dp_priv = intel_output->dev_priv; 630 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv;
630 struct drm_crtc *crtc = intel_output->enc.crtc; 631 struct drm_crtc *crtc = intel_encoder->enc.crtc;
631 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 632 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
632 633
633 dp_priv->DP = (DP_LINK_TRAIN_OFF | 634 dp_priv->DP = (DP_LINK_TRAIN_OFF |
@@ -666,7 +667,7 @@ intel_dp_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode,
666 if (intel_crtc->pipe == 1) 667 if (intel_crtc->pipe == 1)
667 dp_priv->DP |= DP_PIPEB_SELECT; 668 dp_priv->DP |= DP_PIPEB_SELECT;
668 669
669 if (IS_eDP(intel_output)) { 670 if (IS_eDP(intel_encoder)) {
670 /* don't miss out required setting for eDP */ 671 /* don't miss out required setting for eDP */
671 dp_priv->DP |= DP_PLL_ENABLE; 672 dp_priv->DP |= DP_PLL_ENABLE;
672 if (adjusted_mode->clock < 200000) 673 if (adjusted_mode->clock < 200000)
@@ -701,22 +702,22 @@ static void ironlake_edp_backlight_off (struct drm_device *dev)
701static void 702static void
702intel_dp_dpms(struct drm_encoder *encoder, int mode) 703intel_dp_dpms(struct drm_encoder *encoder, int mode)
703{ 704{
704 struct intel_output *intel_output = enc_to_intel_output(encoder); 705 struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder);
705 struct intel_dp_priv *dp_priv = intel_output->dev_priv; 706 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv;
706 struct drm_device *dev = intel_output->base.dev; 707 struct drm_device *dev = intel_encoder->base.dev;
707 struct drm_i915_private *dev_priv = dev->dev_private; 708 struct drm_i915_private *dev_priv = dev->dev_private;
708 uint32_t dp_reg = I915_READ(dp_priv->output_reg); 709 uint32_t dp_reg = I915_READ(dp_priv->output_reg);
709 710
710 if (mode != DRM_MODE_DPMS_ON) { 711 if (mode != DRM_MODE_DPMS_ON) {
711 if (dp_reg & DP_PORT_EN) { 712 if (dp_reg & DP_PORT_EN) {
712 intel_dp_link_down(intel_output, dp_priv->DP); 713 intel_dp_link_down(intel_encoder, dp_priv->DP);
713 if (IS_eDP(intel_output)) 714 if (IS_eDP(intel_encoder))
714 ironlake_edp_backlight_off(dev); 715 ironlake_edp_backlight_off(dev);
715 } 716 }
716 } else { 717 } else {
717 if (!(dp_reg & DP_PORT_EN)) { 718 if (!(dp_reg & DP_PORT_EN)) {
718 intel_dp_link_train(intel_output, dp_priv->DP, dp_priv->link_configuration); 719 intel_dp_link_train(intel_encoder, dp_priv->DP, dp_priv->link_configuration);
719 if (IS_eDP(intel_output)) 720 if (IS_eDP(intel_encoder))
720 ironlake_edp_backlight_on(dev); 721 ironlake_edp_backlight_on(dev);
721 } 722 }
722 } 723 }
@@ -728,12 +729,12 @@ intel_dp_dpms(struct drm_encoder *encoder, int mode)
728 * link status information 729 * link status information
729 */ 730 */
730static bool 731static bool
731intel_dp_get_link_status(struct intel_output *intel_output, 732intel_dp_get_link_status(struct intel_encoder *intel_encoder,
732 uint8_t link_status[DP_LINK_STATUS_SIZE]) 733 uint8_t link_status[DP_LINK_STATUS_SIZE])
733{ 734{
734 int ret; 735 int ret;
735 736
736 ret = intel_dp_aux_native_read(intel_output, 737 ret = intel_dp_aux_native_read(intel_encoder,
737 DP_LANE0_1_STATUS, 738 DP_LANE0_1_STATUS,
738 link_status, DP_LINK_STATUS_SIZE); 739 link_status, DP_LINK_STATUS_SIZE);
739 if (ret != DP_LINK_STATUS_SIZE) 740 if (ret != DP_LINK_STATUS_SIZE)
@@ -751,13 +752,13 @@ intel_dp_link_status(uint8_t link_status[DP_LINK_STATUS_SIZE],
751static void 752static void
752intel_dp_save(struct drm_connector *connector) 753intel_dp_save(struct drm_connector *connector)
753{ 754{
754 struct intel_output *intel_output = to_intel_output(connector); 755 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
755 struct drm_device *dev = intel_output->base.dev; 756 struct drm_device *dev = intel_encoder->base.dev;
756 struct drm_i915_private *dev_priv = dev->dev_private; 757 struct drm_i915_private *dev_priv = dev->dev_private;
757 struct intel_dp_priv *dp_priv = intel_output->dev_priv; 758 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv;
758 759
759 dp_priv->save_DP = I915_READ(dp_priv->output_reg); 760 dp_priv->save_DP = I915_READ(dp_priv->output_reg);
760 intel_dp_aux_native_read(intel_output, DP_LINK_BW_SET, 761 intel_dp_aux_native_read(intel_encoder, DP_LINK_BW_SET,
761 dp_priv->save_link_configuration, 762 dp_priv->save_link_configuration,
762 sizeof (dp_priv->save_link_configuration)); 763 sizeof (dp_priv->save_link_configuration));
763} 764}
@@ -824,7 +825,7 @@ intel_dp_pre_emphasis_max(uint8_t voltage_swing)
824} 825}
825 826
826static void 827static void
827intel_get_adjust_train(struct intel_output *intel_output, 828intel_get_adjust_train(struct intel_encoder *intel_encoder,
828 uint8_t link_status[DP_LINK_STATUS_SIZE], 829 uint8_t link_status[DP_LINK_STATUS_SIZE],
829 int lane_count, 830 int lane_count,
830 uint8_t train_set[4]) 831 uint8_t train_set[4])
@@ -941,15 +942,15 @@ intel_channel_eq_ok(uint8_t link_status[DP_LINK_STATUS_SIZE], int lane_count)
941} 942}
942 943
943static bool 944static bool
944intel_dp_set_link_train(struct intel_output *intel_output, 945intel_dp_set_link_train(struct intel_encoder *intel_encoder,
945 uint32_t dp_reg_value, 946 uint32_t dp_reg_value,
946 uint8_t dp_train_pat, 947 uint8_t dp_train_pat,
947 uint8_t train_set[4], 948 uint8_t train_set[4],
948 bool first) 949 bool first)
949{ 950{
950 struct drm_device *dev = intel_output->base.dev; 951 struct drm_device *dev = intel_encoder->base.dev;
951 struct drm_i915_private *dev_priv = dev->dev_private; 952 struct drm_i915_private *dev_priv = dev->dev_private;
952 struct intel_dp_priv *dp_priv = intel_output->dev_priv; 953 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv;
953 int ret; 954 int ret;
954 955
955 I915_WRITE(dp_priv->output_reg, dp_reg_value); 956 I915_WRITE(dp_priv->output_reg, dp_reg_value);
@@ -957,11 +958,11 @@ intel_dp_set_link_train(struct intel_output *intel_output,
957 if (first) 958 if (first)
958 intel_wait_for_vblank(dev); 959 intel_wait_for_vblank(dev);
959 960
960 intel_dp_aux_native_write_1(intel_output, 961 intel_dp_aux_native_write_1(intel_encoder,
961 DP_TRAINING_PATTERN_SET, 962 DP_TRAINING_PATTERN_SET,
962 dp_train_pat); 963 dp_train_pat);
963 964
964 ret = intel_dp_aux_native_write(intel_output, 965 ret = intel_dp_aux_native_write(intel_encoder,
965 DP_TRAINING_LANE0_SET, train_set, 4); 966 DP_TRAINING_LANE0_SET, train_set, 4);
966 if (ret != 4) 967 if (ret != 4)
967 return false; 968 return false;
@@ -970,12 +971,12 @@ intel_dp_set_link_train(struct intel_output *intel_output,
970} 971}
971 972
972static void 973static void
973intel_dp_link_train(struct intel_output *intel_output, uint32_t DP, 974intel_dp_link_train(struct intel_encoder *intel_encoder, uint32_t DP,
974 uint8_t link_configuration[DP_LINK_CONFIGURATION_SIZE]) 975 uint8_t link_configuration[DP_LINK_CONFIGURATION_SIZE])
975{ 976{
976 struct drm_device *dev = intel_output->base.dev; 977 struct drm_device *dev = intel_encoder->base.dev;
977 struct drm_i915_private *dev_priv = dev->dev_private; 978 struct drm_i915_private *dev_priv = dev->dev_private;
978 struct intel_dp_priv *dp_priv = intel_output->dev_priv; 979 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv;
979 uint8_t train_set[4]; 980 uint8_t train_set[4];
980 uint8_t link_status[DP_LINK_STATUS_SIZE]; 981 uint8_t link_status[DP_LINK_STATUS_SIZE];
981 int i; 982 int i;
@@ -986,7 +987,7 @@ intel_dp_link_train(struct intel_output *intel_output, uint32_t DP,
986 int tries; 987 int tries;
987 988
988 /* Write the link configuration data */ 989 /* Write the link configuration data */
989 intel_dp_aux_native_write(intel_output, 0x100, 990 intel_dp_aux_native_write(intel_encoder, 0x100,
990 link_configuration, DP_LINK_CONFIGURATION_SIZE); 991 link_configuration, DP_LINK_CONFIGURATION_SIZE);
991 992
992 DP |= DP_PORT_EN; 993 DP |= DP_PORT_EN;
@@ -1000,14 +1001,14 @@ intel_dp_link_train(struct intel_output *intel_output, uint32_t DP,
1000 uint32_t signal_levels = intel_dp_signal_levels(train_set[0], dp_priv->lane_count); 1001 uint32_t signal_levels = intel_dp_signal_levels(train_set[0], dp_priv->lane_count);
1001 DP = (DP & ~(DP_VOLTAGE_MASK|DP_PRE_EMPHASIS_MASK)) | signal_levels; 1002 DP = (DP & ~(DP_VOLTAGE_MASK|DP_PRE_EMPHASIS_MASK)) | signal_levels;
1002 1003
1003 if (!intel_dp_set_link_train(intel_output, DP | DP_LINK_TRAIN_PAT_1, 1004 if (!intel_dp_set_link_train(intel_encoder, DP | DP_LINK_TRAIN_PAT_1,
1004 DP_TRAINING_PATTERN_1, train_set, first)) 1005 DP_TRAINING_PATTERN_1, train_set, first))
1005 break; 1006 break;
1006 first = false; 1007 first = false;
1007 /* Set training pattern 1 */ 1008 /* Set training pattern 1 */
1008 1009
1009 udelay(100); 1010 udelay(100);
1010 if (!intel_dp_get_link_status(intel_output, link_status)) 1011 if (!intel_dp_get_link_status(intel_encoder, link_status))
1011 break; 1012 break;
1012 1013
1013 if (intel_clock_recovery_ok(link_status, dp_priv->lane_count)) { 1014 if (intel_clock_recovery_ok(link_status, dp_priv->lane_count)) {
@@ -1032,7 +1033,7 @@ intel_dp_link_train(struct intel_output *intel_output, uint32_t DP,
1032 voltage = train_set[0] & DP_TRAIN_VOLTAGE_SWING_MASK; 1033 voltage = train_set[0] & DP_TRAIN_VOLTAGE_SWING_MASK;
1033 1034
1034 /* Compute new train_set as requested by target */ 1035 /* Compute new train_set as requested by target */
1035 intel_get_adjust_train(intel_output, link_status, dp_priv->lane_count, train_set); 1036 intel_get_adjust_train(intel_encoder, link_status, dp_priv->lane_count, train_set);
1036 } 1037 }
1037 1038
1038 /* channel equalization */ 1039 /* channel equalization */
@@ -1044,13 +1045,13 @@ intel_dp_link_train(struct intel_output *intel_output, uint32_t DP,
1044 DP = (DP & ~(DP_VOLTAGE_MASK|DP_PRE_EMPHASIS_MASK)) | signal_levels; 1045 DP = (DP & ~(DP_VOLTAGE_MASK|DP_PRE_EMPHASIS_MASK)) | signal_levels;
1045 1046
1046 /* channel eq pattern */ 1047 /* channel eq pattern */
1047 if (!intel_dp_set_link_train(intel_output, DP | DP_LINK_TRAIN_PAT_2, 1048 if (!intel_dp_set_link_train(intel_encoder, DP | DP_LINK_TRAIN_PAT_2,
1048 DP_TRAINING_PATTERN_2, train_set, 1049 DP_TRAINING_PATTERN_2, train_set,
1049 false)) 1050 false))
1050 break; 1051 break;
1051 1052
1052 udelay(400); 1053 udelay(400);
1053 if (!intel_dp_get_link_status(intel_output, link_status)) 1054 if (!intel_dp_get_link_status(intel_encoder, link_status))
1054 break; 1055 break;
1055 1056
1056 if (intel_channel_eq_ok(link_status, dp_priv->lane_count)) { 1057 if (intel_channel_eq_ok(link_status, dp_priv->lane_count)) {
@@ -1063,26 +1064,26 @@ intel_dp_link_train(struct intel_output *intel_output, uint32_t DP,
1063 break; 1064 break;
1064 1065
1065 /* Compute new train_set as requested by target */ 1066 /* Compute new train_set as requested by target */
1066 intel_get_adjust_train(intel_output, link_status, dp_priv->lane_count, train_set); 1067 intel_get_adjust_train(intel_encoder, link_status, dp_priv->lane_count, train_set);
1067 ++tries; 1068 ++tries;
1068 } 1069 }
1069 1070
1070 I915_WRITE(dp_priv->output_reg, DP | DP_LINK_TRAIN_OFF); 1071 I915_WRITE(dp_priv->output_reg, DP | DP_LINK_TRAIN_OFF);
1071 POSTING_READ(dp_priv->output_reg); 1072 POSTING_READ(dp_priv->output_reg);
1072 intel_dp_aux_native_write_1(intel_output, 1073 intel_dp_aux_native_write_1(intel_encoder,
1073 DP_TRAINING_PATTERN_SET, DP_TRAINING_PATTERN_DISABLE); 1074 DP_TRAINING_PATTERN_SET, DP_TRAINING_PATTERN_DISABLE);
1074} 1075}
1075 1076
1076static void 1077static void
1077intel_dp_link_down(struct intel_output *intel_output, uint32_t DP) 1078intel_dp_link_down(struct intel_encoder *intel_encoder, uint32_t DP)
1078{ 1079{
1079 struct drm_device *dev = intel_output->base.dev; 1080 struct drm_device *dev = intel_encoder->base.dev;
1080 struct drm_i915_private *dev_priv = dev->dev_private; 1081 struct drm_i915_private *dev_priv = dev->dev_private;
1081 struct intel_dp_priv *dp_priv = intel_output->dev_priv; 1082 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv;
1082 1083
1083 DRM_DEBUG_KMS("\n"); 1084 DRM_DEBUG_KMS("\n");
1084 1085
1085 if (IS_eDP(intel_output)) { 1086 if (IS_eDP(intel_encoder)) {
1086 DP &= ~DP_PLL_ENABLE; 1087 DP &= ~DP_PLL_ENABLE;
1087 I915_WRITE(dp_priv->output_reg, DP); 1088 I915_WRITE(dp_priv->output_reg, DP);
1088 POSTING_READ(dp_priv->output_reg); 1089 POSTING_READ(dp_priv->output_reg);
@@ -1095,7 +1096,7 @@ intel_dp_link_down(struct intel_output *intel_output, uint32_t DP)
1095 1096
1096 udelay(17000); 1097 udelay(17000);
1097 1098
1098 if (IS_eDP(intel_output)) 1099 if (IS_eDP(intel_encoder))
1099 DP |= DP_LINK_TRAIN_OFF; 1100 DP |= DP_LINK_TRAIN_OFF;
1100 I915_WRITE(dp_priv->output_reg, DP & ~DP_PORT_EN); 1101 I915_WRITE(dp_priv->output_reg, DP & ~DP_PORT_EN);
1101 POSTING_READ(dp_priv->output_reg); 1102 POSTING_READ(dp_priv->output_reg);
@@ -1104,13 +1105,13 @@ intel_dp_link_down(struct intel_output *intel_output, uint32_t DP)
1104static void 1105static void
1105intel_dp_restore(struct drm_connector *connector) 1106intel_dp_restore(struct drm_connector *connector)
1106{ 1107{
1107 struct intel_output *intel_output = to_intel_output(connector); 1108 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
1108 struct intel_dp_priv *dp_priv = intel_output->dev_priv; 1109 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv;
1109 1110
1110 if (dp_priv->save_DP & DP_PORT_EN) 1111 if (dp_priv->save_DP & DP_PORT_EN)
1111 intel_dp_link_train(intel_output, dp_priv->save_DP, dp_priv->save_link_configuration); 1112 intel_dp_link_train(intel_encoder, dp_priv->save_DP, dp_priv->save_link_configuration);
1112 else 1113 else
1113 intel_dp_link_down(intel_output, dp_priv->save_DP); 1114 intel_dp_link_down(intel_encoder, dp_priv->save_DP);
1114} 1115}
1115 1116
1116/* 1117/*
@@ -1123,32 +1124,32 @@ intel_dp_restore(struct drm_connector *connector)
1123 */ 1124 */
1124 1125
1125static void 1126static void
1126intel_dp_check_link_status(struct intel_output *intel_output) 1127intel_dp_check_link_status(struct intel_encoder *intel_encoder)
1127{ 1128{
1128 struct intel_dp_priv *dp_priv = intel_output->dev_priv; 1129 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv;
1129 uint8_t link_status[DP_LINK_STATUS_SIZE]; 1130 uint8_t link_status[DP_LINK_STATUS_SIZE];
1130 1131
1131 if (!intel_output->enc.crtc) 1132 if (!intel_encoder->enc.crtc)
1132 return; 1133 return;
1133 1134
1134 if (!intel_dp_get_link_status(intel_output, link_status)) { 1135 if (!intel_dp_get_link_status(intel_encoder, link_status)) {
1135 intel_dp_link_down(intel_output, dp_priv->DP); 1136 intel_dp_link_down(intel_encoder, dp_priv->DP);
1136 return; 1137 return;
1137 } 1138 }
1138 1139
1139 if (!intel_channel_eq_ok(link_status, dp_priv->lane_count)) 1140 if (!intel_channel_eq_ok(link_status, dp_priv->lane_count))
1140 intel_dp_link_train(intel_output, dp_priv->DP, dp_priv->link_configuration); 1141 intel_dp_link_train(intel_encoder, dp_priv->DP, dp_priv->link_configuration);
1141} 1142}
1142 1143
1143static enum drm_connector_status 1144static enum drm_connector_status
1144ironlake_dp_detect(struct drm_connector *connector) 1145ironlake_dp_detect(struct drm_connector *connector)
1145{ 1146{
1146 struct intel_output *intel_output = to_intel_output(connector); 1147 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
1147 struct intel_dp_priv *dp_priv = intel_output->dev_priv; 1148 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv;
1148 enum drm_connector_status status; 1149 enum drm_connector_status status;
1149 1150
1150 status = connector_status_disconnected; 1151 status = connector_status_disconnected;
1151 if (intel_dp_aux_native_read(intel_output, 1152 if (intel_dp_aux_native_read(intel_encoder,
1152 0x000, dp_priv->dpcd, 1153 0x000, dp_priv->dpcd,
1153 sizeof (dp_priv->dpcd)) == sizeof (dp_priv->dpcd)) 1154 sizeof (dp_priv->dpcd)) == sizeof (dp_priv->dpcd))
1154 { 1155 {
@@ -1167,10 +1168,10 @@ ironlake_dp_detect(struct drm_connector *connector)
1167static enum drm_connector_status 1168static enum drm_connector_status
1168intel_dp_detect(struct drm_connector *connector) 1169intel_dp_detect(struct drm_connector *connector)
1169{ 1170{
1170 struct intel_output *intel_output = to_intel_output(connector); 1171 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
1171 struct drm_device *dev = intel_output->base.dev; 1172 struct drm_device *dev = intel_encoder->base.dev;
1172 struct drm_i915_private *dev_priv = dev->dev_private; 1173 struct drm_i915_private *dev_priv = dev->dev_private;
1173 struct intel_dp_priv *dp_priv = intel_output->dev_priv; 1174 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv;
1174 uint32_t temp, bit; 1175 uint32_t temp, bit;
1175 enum drm_connector_status status; 1176 enum drm_connector_status status;
1176 1177
@@ -1209,7 +1210,7 @@ intel_dp_detect(struct drm_connector *connector)
1209 return connector_status_disconnected; 1210 return connector_status_disconnected;
1210 1211
1211 status = connector_status_disconnected; 1212 status = connector_status_disconnected;
1212 if (intel_dp_aux_native_read(intel_output, 1213 if (intel_dp_aux_native_read(intel_encoder,
1213 0x000, dp_priv->dpcd, 1214 0x000, dp_priv->dpcd,
1214 sizeof (dp_priv->dpcd)) == sizeof (dp_priv->dpcd)) 1215 sizeof (dp_priv->dpcd)) == sizeof (dp_priv->dpcd))
1215 { 1216 {
@@ -1221,20 +1222,20 @@ intel_dp_detect(struct drm_connector *connector)
1221 1222
1222static int intel_dp_get_modes(struct drm_connector *connector) 1223static int intel_dp_get_modes(struct drm_connector *connector)
1223{ 1224{
1224 struct intel_output *intel_output = to_intel_output(connector); 1225 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
1225 struct drm_device *dev = intel_output->base.dev; 1226 struct drm_device *dev = intel_encoder->base.dev;
1226 struct drm_i915_private *dev_priv = dev->dev_private; 1227 struct drm_i915_private *dev_priv = dev->dev_private;
1227 int ret; 1228 int ret;
1228 1229
1229 /* We should parse the EDID data and find out if it has an audio sink 1230 /* We should parse the EDID data and find out if it has an audio sink
1230 */ 1231 */
1231 1232
1232 ret = intel_ddc_get_modes(intel_output); 1233 ret = intel_ddc_get_modes(intel_encoder);
1233 if (ret) 1234 if (ret)
1234 return ret; 1235 return ret;
1235 1236
1236 /* if eDP has no EDID, try to use fixed panel mode from VBT */ 1237 /* if eDP has no EDID, try to use fixed panel mode from VBT */
1237 if (IS_eDP(intel_output)) { 1238 if (IS_eDP(intel_encoder)) {
1238 if (dev_priv->panel_fixed_mode != NULL) { 1239 if (dev_priv->panel_fixed_mode != NULL) {
1239 struct drm_display_mode *mode; 1240 struct drm_display_mode *mode;
1240 mode = drm_mode_duplicate(dev, dev_priv->panel_fixed_mode); 1241 mode = drm_mode_duplicate(dev, dev_priv->panel_fixed_mode);
@@ -1248,13 +1249,13 @@ static int intel_dp_get_modes(struct drm_connector *connector)
1248static void 1249static void
1249intel_dp_destroy (struct drm_connector *connector) 1250intel_dp_destroy (struct drm_connector *connector)
1250{ 1251{
1251 struct intel_output *intel_output = to_intel_output(connector); 1252 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
1252 1253
1253 if (intel_output->i2c_bus) 1254 if (intel_encoder->i2c_bus)
1254 intel_i2c_destroy(intel_output->i2c_bus); 1255 intel_i2c_destroy(intel_encoder->i2c_bus);
1255 drm_sysfs_connector_remove(connector); 1256 drm_sysfs_connector_remove(connector);
1256 drm_connector_cleanup(connector); 1257 drm_connector_cleanup(connector);
1257 kfree(intel_output); 1258 kfree(intel_encoder);
1258} 1259}
1259 1260
1260static const struct drm_encoder_helper_funcs intel_dp_helper_funcs = { 1261static const struct drm_encoder_helper_funcs intel_dp_helper_funcs = {
@@ -1290,12 +1291,12 @@ static const struct drm_encoder_funcs intel_dp_enc_funcs = {
1290}; 1291};
1291 1292
1292void 1293void
1293intel_dp_hot_plug(struct intel_output *intel_output) 1294intel_dp_hot_plug(struct intel_encoder *intel_encoder)
1294{ 1295{
1295 struct intel_dp_priv *dp_priv = intel_output->dev_priv; 1296 struct intel_dp_priv *dp_priv = intel_encoder->dev_priv;
1296 1297
1297 if (dp_priv->dpms_mode == DRM_MODE_DPMS_ON) 1298 if (dp_priv->dpms_mode == DRM_MODE_DPMS_ON)
1298 intel_dp_check_link_status(intel_output); 1299 intel_dp_check_link_status(intel_encoder);
1299} 1300}
1300 1301
1301void 1302void
@@ -1303,53 +1304,53 @@ intel_dp_init(struct drm_device *dev, int output_reg)
1303{ 1304{
1304 struct drm_i915_private *dev_priv = dev->dev_private; 1305 struct drm_i915_private *dev_priv = dev->dev_private;
1305 struct drm_connector *connector; 1306 struct drm_connector *connector;
1306 struct intel_output *intel_output; 1307 struct intel_encoder *intel_encoder;
1307 struct intel_dp_priv *dp_priv; 1308 struct intel_dp_priv *dp_priv;
1308 const char *name = NULL; 1309 const char *name = NULL;
1309 1310
1310 intel_output = kcalloc(sizeof(struct intel_output) + 1311 intel_encoder = kcalloc(sizeof(struct intel_encoder) +
1311 sizeof(struct intel_dp_priv), 1, GFP_KERNEL); 1312 sizeof(struct intel_dp_priv), 1, GFP_KERNEL);
1312 if (!intel_output) 1313 if (!intel_encoder)
1313 return; 1314 return;
1314 1315
1315 dp_priv = (struct intel_dp_priv *)(intel_output + 1); 1316 dp_priv = (struct intel_dp_priv *)(intel_encoder + 1);
1316 1317
1317 connector = &intel_output->base; 1318 connector = &intel_encoder->base;
1318 drm_connector_init(dev, connector, &intel_dp_connector_funcs, 1319 drm_connector_init(dev, connector, &intel_dp_connector_funcs,
1319 DRM_MODE_CONNECTOR_DisplayPort); 1320 DRM_MODE_CONNECTOR_DisplayPort);
1320 drm_connector_helper_add(connector, &intel_dp_connector_helper_funcs); 1321 drm_connector_helper_add(connector, &intel_dp_connector_helper_funcs);
1321 1322
1322 if (output_reg == DP_A) 1323 if (output_reg == DP_A)
1323 intel_output->type = INTEL_OUTPUT_EDP; 1324 intel_encoder->type = INTEL_OUTPUT_EDP;
1324 else 1325 else
1325 intel_output->type = INTEL_OUTPUT_DISPLAYPORT; 1326 intel_encoder->type = INTEL_OUTPUT_DISPLAYPORT;
1326 1327
1327 if (output_reg == DP_B || output_reg == PCH_DP_B) 1328 if (output_reg == DP_B || output_reg == PCH_DP_B)
1328 intel_output->clone_mask = (1 << INTEL_DP_B_CLONE_BIT); 1329 intel_encoder->clone_mask = (1 << INTEL_DP_B_CLONE_BIT);
1329 else if (output_reg == DP_C || output_reg == PCH_DP_C) 1330 else if (output_reg == DP_C || output_reg == PCH_DP_C)
1330 intel_output->clone_mask = (1 << INTEL_DP_C_CLONE_BIT); 1331 intel_encoder->clone_mask = (1 << INTEL_DP_C_CLONE_BIT);
1331 else if (output_reg == DP_D || output_reg == PCH_DP_D) 1332 else if (output_reg == DP_D || output_reg == PCH_DP_D)
1332 intel_output->clone_mask = (1 << INTEL_DP_D_CLONE_BIT); 1333 intel_encoder->clone_mask = (1 << INTEL_DP_D_CLONE_BIT);
1333 1334
1334 if (IS_eDP(intel_output)) 1335 if (IS_eDP(intel_encoder))
1335 intel_output->clone_mask = (1 << INTEL_EDP_CLONE_BIT); 1336 intel_encoder->clone_mask = (1 << INTEL_EDP_CLONE_BIT);
1336 1337
1337 intel_output->crtc_mask = (1 << 0) | (1 << 1); 1338 intel_encoder->crtc_mask = (1 << 0) | (1 << 1);
1338 connector->interlace_allowed = true; 1339 connector->interlace_allowed = true;
1339 connector->doublescan_allowed = 0; 1340 connector->doublescan_allowed = 0;
1340 1341
1341 dp_priv->intel_output = intel_output; 1342 dp_priv->intel_encoder = intel_encoder;
1342 dp_priv->output_reg = output_reg; 1343 dp_priv->output_reg = output_reg;
1343 dp_priv->has_audio = false; 1344 dp_priv->has_audio = false;
1344 dp_priv->dpms_mode = DRM_MODE_DPMS_ON; 1345 dp_priv->dpms_mode = DRM_MODE_DPMS_ON;
1345 intel_output->dev_priv = dp_priv; 1346 intel_encoder->dev_priv = dp_priv;
1346 1347
1347 drm_encoder_init(dev, &intel_output->enc, &intel_dp_enc_funcs, 1348 drm_encoder_init(dev, &intel_encoder->enc, &intel_dp_enc_funcs,
1348 DRM_MODE_ENCODER_TMDS); 1349 DRM_MODE_ENCODER_TMDS);
1349 drm_encoder_helper_add(&intel_output->enc, &intel_dp_helper_funcs); 1350 drm_encoder_helper_add(&intel_encoder->enc, &intel_dp_helper_funcs);
1350 1351
1351 drm_mode_connector_attach_encoder(&intel_output->base, 1352 drm_mode_connector_attach_encoder(&intel_encoder->base,
1352 &intel_output->enc); 1353 &intel_encoder->enc);
1353 drm_sysfs_connector_add(connector); 1354 drm_sysfs_connector_add(connector);
1354 1355
1355 /* Set up the DDC bus. */ 1356 /* Set up the DDC bus. */
@@ -1377,10 +1378,10 @@ intel_dp_init(struct drm_device *dev, int output_reg)
1377 break; 1378 break;
1378 } 1379 }
1379 1380
1380 intel_dp_i2c_init(intel_output, name); 1381 intel_dp_i2c_init(intel_encoder, name);
1381 1382
1382 intel_output->ddc_bus = &dp_priv->adapter; 1383 intel_encoder->ddc_bus = &dp_priv->adapter;
1383 intel_output->hot_plug = intel_dp_hot_plug; 1384 intel_encoder->hot_plug = intel_dp_hot_plug;
1384 1385
1385 if (output_reg == DP_A) { 1386 if (output_reg == DP_A) {
1386 /* initialize panel mode from VBT if available for eDP */ 1387 /* initialize panel mode from VBT if available for eDP */
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 3a467ca5785..e30253755f1 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -95,7 +95,7 @@ struct intel_framebuffer {
95}; 95};
96 96
97 97
98struct intel_output { 98struct intel_encoder {
99 struct drm_connector base; 99 struct drm_connector base;
100 100
101 struct drm_encoder enc; 101 struct drm_encoder enc;
@@ -105,7 +105,7 @@ struct intel_output {
105 bool load_detect_temp; 105 bool load_detect_temp;
106 bool needs_tv_clock; 106 bool needs_tv_clock;
107 void *dev_priv; 107 void *dev_priv;
108 void (*hot_plug)(struct intel_output *); 108 void (*hot_plug)(struct intel_encoder *);
109 int crtc_mask; 109 int crtc_mask;
110 int clone_mask; 110 int clone_mask;
111}; 111};
@@ -152,15 +152,15 @@ struct intel_crtc {
152}; 152};
153 153
154#define to_intel_crtc(x) container_of(x, struct intel_crtc, base) 154#define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
155#define to_intel_output(x) container_of(x, struct intel_output, base) 155#define to_intel_encoder(x) container_of(x, struct intel_encoder, base)
156#define enc_to_intel_output(x) container_of(x, struct intel_output, enc) 156#define enc_to_intel_encoder(x) container_of(x, struct intel_encoder, enc)
157#define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base) 157#define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base)
158 158
159struct i2c_adapter *intel_i2c_create(struct drm_device *dev, const u32 reg, 159struct i2c_adapter *intel_i2c_create(struct drm_device *dev, const u32 reg,
160 const char *name); 160 const char *name);
161void intel_i2c_destroy(struct i2c_adapter *adapter); 161void intel_i2c_destroy(struct i2c_adapter *adapter);
162int intel_ddc_get_modes(struct intel_output *intel_output); 162int intel_ddc_get_modes(struct intel_encoder *intel_encoder);
163extern bool intel_ddc_probe(struct intel_output *intel_output); 163extern bool intel_ddc_probe(struct intel_encoder *intel_encoder);
164void intel_i2c_quirk_set(struct drm_device *dev, bool enable); 164void intel_i2c_quirk_set(struct drm_device *dev, bool enable);
165void intel_i2c_reset_gmbus(struct drm_device *dev); 165void intel_i2c_reset_gmbus(struct drm_device *dev);
166 166
@@ -175,7 +175,7 @@ extern void intel_dp_init(struct drm_device *dev, int dp_reg);
175void 175void
176intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode, 176intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode,
177 struct drm_display_mode *adjusted_mode); 177 struct drm_display_mode *adjusted_mode);
178extern void intel_edp_link_config (struct intel_output *, int *, int *); 178extern void intel_edp_link_config (struct intel_encoder *, int *, int *);
179 179
180 180
181extern int intel_panel_fitter_pipe (struct drm_device *dev); 181extern int intel_panel_fitter_pipe (struct drm_device *dev);
@@ -191,10 +191,10 @@ int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
191 struct drm_file *file_priv); 191 struct drm_file *file_priv);
192extern void intel_wait_for_vblank(struct drm_device *dev); 192extern void intel_wait_for_vblank(struct drm_device *dev);
193extern struct drm_crtc *intel_get_crtc_from_pipe(struct drm_device *dev, int pipe); 193extern struct drm_crtc *intel_get_crtc_from_pipe(struct drm_device *dev, int pipe);
194extern struct drm_crtc *intel_get_load_detect_pipe(struct intel_output *intel_output, 194extern struct drm_crtc *intel_get_load_detect_pipe(struct intel_encoder *intel_encoder,
195 struct drm_display_mode *mode, 195 struct drm_display_mode *mode,
196 int *dpms_mode); 196 int *dpms_mode);
197extern void intel_release_load_detect_pipe(struct intel_output *intel_output, 197extern void intel_release_load_detect_pipe(struct intel_encoder *intel_encoder,
198 int dpms_mode); 198 int dpms_mode);
199 199
200extern struct drm_connector* intel_sdvo_find(struct drm_device *dev, int sdvoB); 200extern struct drm_connector* intel_sdvo_find(struct drm_device *dev, int sdvoB);
diff --git a/drivers/gpu/drm/i915/intel_dvo.c b/drivers/gpu/drm/i915/intel_dvo.c
index a4d2606de77..ebf213c96b9 100644
--- a/drivers/gpu/drm/i915/intel_dvo.c
+++ b/drivers/gpu/drm/i915/intel_dvo.c
@@ -25,6 +25,7 @@
25 * Eric Anholt <eric@anholt.net> 25 * Eric Anholt <eric@anholt.net>
26 */ 26 */
27#include <linux/i2c.h> 27#include <linux/i2c.h>
28#include <linux/slab.h>
28#include "drmP.h" 29#include "drmP.h"
29#include "drm.h" 30#include "drm.h"
30#include "drm_crtc.h" 31#include "drm_crtc.h"
@@ -79,8 +80,8 @@ static struct intel_dvo_device intel_dvo_devices[] = {
79static void intel_dvo_dpms(struct drm_encoder *encoder, int mode) 80static void intel_dvo_dpms(struct drm_encoder *encoder, int mode)
80{ 81{
81 struct drm_i915_private *dev_priv = encoder->dev->dev_private; 82 struct drm_i915_private *dev_priv = encoder->dev->dev_private;
82 struct intel_output *intel_output = enc_to_intel_output(encoder); 83 struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder);
83 struct intel_dvo_device *dvo = intel_output->dev_priv; 84 struct intel_dvo_device *dvo = intel_encoder->dev_priv;
84 u32 dvo_reg = dvo->dvo_reg; 85 u32 dvo_reg = dvo->dvo_reg;
85 u32 temp = I915_READ(dvo_reg); 86 u32 temp = I915_READ(dvo_reg);
86 87
@@ -98,8 +99,8 @@ static void intel_dvo_dpms(struct drm_encoder *encoder, int mode)
98static void intel_dvo_save(struct drm_connector *connector) 99static void intel_dvo_save(struct drm_connector *connector)
99{ 100{
100 struct drm_i915_private *dev_priv = connector->dev->dev_private; 101 struct drm_i915_private *dev_priv = connector->dev->dev_private;
101 struct intel_output *intel_output = to_intel_output(connector); 102 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
102 struct intel_dvo_device *dvo = intel_output->dev_priv; 103 struct intel_dvo_device *dvo = intel_encoder->dev_priv;
103 104
104 /* Each output should probably just save the registers it touches, 105 /* Each output should probably just save the registers it touches,
105 * but for now, use more overkill. 106 * but for now, use more overkill.
@@ -114,8 +115,8 @@ static void intel_dvo_save(struct drm_connector *connector)
114static void intel_dvo_restore(struct drm_connector *connector) 115static void intel_dvo_restore(struct drm_connector *connector)
115{ 116{
116 struct drm_i915_private *dev_priv = connector->dev->dev_private; 117 struct drm_i915_private *dev_priv = connector->dev->dev_private;
117 struct intel_output *intel_output = to_intel_output(connector); 118 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
118 struct intel_dvo_device *dvo = intel_output->dev_priv; 119 struct intel_dvo_device *dvo = intel_encoder->dev_priv;
119 120
120 dvo->dev_ops->restore(dvo); 121 dvo->dev_ops->restore(dvo);
121 122
@@ -127,8 +128,8 @@ static void intel_dvo_restore(struct drm_connector *connector)
127static int intel_dvo_mode_valid(struct drm_connector *connector, 128static int intel_dvo_mode_valid(struct drm_connector *connector,
128 struct drm_display_mode *mode) 129 struct drm_display_mode *mode)
129{ 130{
130 struct intel_output *intel_output = to_intel_output(connector); 131 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
131 struct intel_dvo_device *dvo = intel_output->dev_priv; 132 struct intel_dvo_device *dvo = intel_encoder->dev_priv;
132 133
133 if (mode->flags & DRM_MODE_FLAG_DBLSCAN) 134 if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
134 return MODE_NO_DBLESCAN; 135 return MODE_NO_DBLESCAN;
@@ -149,8 +150,8 @@ static bool intel_dvo_mode_fixup(struct drm_encoder *encoder,
149 struct drm_display_mode *mode, 150 struct drm_display_mode *mode,
150 struct drm_display_mode *adjusted_mode) 151 struct drm_display_mode *adjusted_mode)
151{ 152{
152 struct intel_output *intel_output = enc_to_intel_output(encoder); 153 struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder);
153 struct intel_dvo_device *dvo = intel_output->dev_priv; 154 struct intel_dvo_device *dvo = intel_encoder->dev_priv;
154 155
155 /* If we have timings from the BIOS for the panel, put them in 156 /* If we have timings from the BIOS for the panel, put them in
156 * to the adjusted mode. The CRTC will be set up for this mode, 157 * to the adjusted mode. The CRTC will be set up for this mode,
@@ -185,8 +186,8 @@ static void intel_dvo_mode_set(struct drm_encoder *encoder,
185 struct drm_device *dev = encoder->dev; 186 struct drm_device *dev = encoder->dev;
186 struct drm_i915_private *dev_priv = dev->dev_private; 187 struct drm_i915_private *dev_priv = dev->dev_private;
187 struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); 188 struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
188 struct intel_output *intel_output = enc_to_intel_output(encoder); 189 struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder);
189 struct intel_dvo_device *dvo = intel_output->dev_priv; 190 struct intel_dvo_device *dvo = intel_encoder->dev_priv;
190 int pipe = intel_crtc->pipe; 191 int pipe = intel_crtc->pipe;
191 u32 dvo_val; 192 u32 dvo_val;
192 u32 dvo_reg = dvo->dvo_reg, dvo_srcdim_reg; 193 u32 dvo_reg = dvo->dvo_reg, dvo_srcdim_reg;
@@ -240,23 +241,23 @@ static void intel_dvo_mode_set(struct drm_encoder *encoder,
240 */ 241 */
241static enum drm_connector_status intel_dvo_detect(struct drm_connector *connector) 242static enum drm_connector_status intel_dvo_detect(struct drm_connector *connector)
242{ 243{
243 struct intel_output *intel_output = to_intel_output(connector); 244 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
244 struct intel_dvo_device *dvo = intel_output->dev_priv; 245 struct intel_dvo_device *dvo = intel_encoder->dev_priv;
245 246
246 return dvo->dev_ops->detect(dvo); 247 return dvo->dev_ops->detect(dvo);
247} 248}
248 249
249static int intel_dvo_get_modes(struct drm_connector *connector) 250static int intel_dvo_get_modes(struct drm_connector *connector)
250{ 251{
251 struct intel_output *intel_output = to_intel_output(connector); 252 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
252 struct intel_dvo_device *dvo = intel_output->dev_priv; 253 struct intel_dvo_device *dvo = intel_encoder->dev_priv;
253 254
254 /* We should probably have an i2c driver get_modes function for those 255 /* We should probably have an i2c driver get_modes function for those
255 * devices which will have a fixed set of modes determined by the chip 256 * devices which will have a fixed set of modes determined by the chip
256 * (TV-out, for example), but for now with just TMDS and LVDS, 257 * (TV-out, for example), but for now with just TMDS and LVDS,
257 * that's not the case. 258 * that's not the case.
258 */ 259 */
259 intel_ddc_get_modes(intel_output); 260 intel_ddc_get_modes(intel_encoder);
260 if (!list_empty(&connector->probed_modes)) 261 if (!list_empty(&connector->probed_modes))
261 return 1; 262 return 1;
262 263
@@ -274,8 +275,8 @@ static int intel_dvo_get_modes(struct drm_connector *connector)
274 275
275static void intel_dvo_destroy (struct drm_connector *connector) 276static void intel_dvo_destroy (struct drm_connector *connector)
276{ 277{
277 struct intel_output *intel_output = to_intel_output(connector); 278 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
278 struct intel_dvo_device *dvo = intel_output->dev_priv; 279 struct intel_dvo_device *dvo = intel_encoder->dev_priv;
279 280
280 if (dvo) { 281 if (dvo) {
281 if (dvo->dev_ops->destroy) 282 if (dvo->dev_ops->destroy)
@@ -285,13 +286,13 @@ static void intel_dvo_destroy (struct drm_connector *connector)
285 /* no need, in i830_dvoices[] now */ 286 /* no need, in i830_dvoices[] now */
286 //kfree(dvo); 287 //kfree(dvo);
287 } 288 }
288 if (intel_output->i2c_bus) 289 if (intel_encoder->i2c_bus)
289 intel_i2c_destroy(intel_output->i2c_bus); 290 intel_i2c_destroy(intel_encoder->i2c_bus);
290 if (intel_output->ddc_bus) 291 if (intel_encoder->ddc_bus)
291 intel_i2c_destroy(intel_output->ddc_bus); 292 intel_i2c_destroy(intel_encoder->ddc_bus);
292 drm_sysfs_connector_remove(connector); 293 drm_sysfs_connector_remove(connector);
293 drm_connector_cleanup(connector); 294 drm_connector_cleanup(connector);
294 kfree(intel_output); 295 kfree(intel_encoder);
295} 296}
296 297
297#ifdef RANDR_GET_CRTC_INTERFACE 298#ifdef RANDR_GET_CRTC_INTERFACE
@@ -299,8 +300,8 @@ static struct drm_crtc *intel_dvo_get_crtc(struct drm_connector *connector)
299{ 300{
300 struct drm_device *dev = connector->dev; 301 struct drm_device *dev = connector->dev;
301 struct drm_i915_private *dev_priv = dev->dev_private; 302 struct drm_i915_private *dev_priv = dev->dev_private;
302 struct intel_output *intel_output = to_intel_output(connector); 303 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
303 struct intel_dvo_device *dvo = intel_output->dev_priv; 304 struct intel_dvo_device *dvo = intel_encoder->dev_priv;
304 int pipe = !!(I915_READ(dvo->dvo_reg) & SDVO_PIPE_B_SELECT); 305 int pipe = !!(I915_READ(dvo->dvo_reg) & SDVO_PIPE_B_SELECT);
305 306
306 return intel_pipe_to_crtc(pScrn, pipe); 307 return intel_pipe_to_crtc(pScrn, pipe);
@@ -351,8 +352,8 @@ intel_dvo_get_current_mode (struct drm_connector *connector)
351{ 352{
352 struct drm_device *dev = connector->dev; 353 struct drm_device *dev = connector->dev;
353 struct drm_i915_private *dev_priv = dev->dev_private; 354 struct drm_i915_private *dev_priv = dev->dev_private;
354 struct intel_output *intel_output = to_intel_output(connector); 355 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
355 struct intel_dvo_device *dvo = intel_output->dev_priv; 356 struct intel_dvo_device *dvo = intel_encoder->dev_priv;
356 uint32_t dvo_reg = dvo->dvo_reg; 357 uint32_t dvo_reg = dvo->dvo_reg;
357 uint32_t dvo_val = I915_READ(dvo_reg); 358 uint32_t dvo_val = I915_READ(dvo_reg);
358 struct drm_display_mode *mode = NULL; 359 struct drm_display_mode *mode = NULL;
@@ -382,24 +383,24 @@ intel_dvo_get_current_mode (struct drm_connector *connector)
382 383
383void intel_dvo_init(struct drm_device *dev) 384void intel_dvo_init(struct drm_device *dev)
384{ 385{
385 struct intel_output *intel_output; 386 struct intel_encoder *intel_encoder;
386 struct intel_dvo_device *dvo; 387 struct intel_dvo_device *dvo;
387 struct i2c_adapter *i2cbus = NULL; 388 struct i2c_adapter *i2cbus = NULL;
388 int ret = 0; 389 int ret = 0;
389 int i; 390 int i;
390 int encoder_type = DRM_MODE_ENCODER_NONE; 391 int encoder_type = DRM_MODE_ENCODER_NONE;
391 intel_output = kzalloc (sizeof(struct intel_output), GFP_KERNEL); 392 intel_encoder = kzalloc (sizeof(struct intel_encoder), GFP_KERNEL);
392 if (!intel_output) 393 if (!intel_encoder)
393 return; 394 return;
394 395
395 /* Set up the DDC bus */ 396 /* Set up the DDC bus */
396 intel_output->ddc_bus = intel_i2c_create(dev, GPIOD, "DVODDC_D"); 397 intel_encoder->ddc_bus = intel_i2c_create(dev, GPIOD, "DVODDC_D");
397 if (!intel_output->ddc_bus) 398 if (!intel_encoder->ddc_bus)
398 goto free_intel; 399 goto free_intel;
399 400
400 /* Now, try to find a controller */ 401 /* Now, try to find a controller */
401 for (i = 0; i < ARRAY_SIZE(intel_dvo_devices); i++) { 402 for (i = 0; i < ARRAY_SIZE(intel_dvo_devices); i++) {
402 struct drm_connector *connector = &intel_output->base; 403 struct drm_connector *connector = &intel_encoder->base;
403 int gpio; 404 int gpio;
404 405
405 dvo = &intel_dvo_devices[i]; 406 dvo = &intel_dvo_devices[i];
@@ -434,11 +435,11 @@ void intel_dvo_init(struct drm_device *dev)
434 if (!ret) 435 if (!ret)
435 continue; 436 continue;
436 437
437 intel_output->type = INTEL_OUTPUT_DVO; 438 intel_encoder->type = INTEL_OUTPUT_DVO;
438 intel_output->crtc_mask = (1 << 0) | (1 << 1); 439 intel_encoder->crtc_mask = (1 << 0) | (1 << 1);
439 switch (dvo->type) { 440 switch (dvo->type) {
440 case INTEL_DVO_CHIP_TMDS: 441 case INTEL_DVO_CHIP_TMDS:
441 intel_output->clone_mask = 442 intel_encoder->clone_mask =
442 (1 << INTEL_DVO_TMDS_CLONE_BIT) | 443 (1 << INTEL_DVO_TMDS_CLONE_BIT) |
443 (1 << INTEL_ANALOG_CLONE_BIT); 444 (1 << INTEL_ANALOG_CLONE_BIT);
444 drm_connector_init(dev, connector, 445 drm_connector_init(dev, connector,
@@ -447,7 +448,7 @@ void intel_dvo_init(struct drm_device *dev)
447 encoder_type = DRM_MODE_ENCODER_TMDS; 448 encoder_type = DRM_MODE_ENCODER_TMDS;
448 break; 449 break;
449 case INTEL_DVO_CHIP_LVDS: 450 case INTEL_DVO_CHIP_LVDS:
450 intel_output->clone_mask = 451 intel_encoder->clone_mask =
451 (1 << INTEL_DVO_LVDS_CLONE_BIT); 452 (1 << INTEL_DVO_LVDS_CLONE_BIT);
452 drm_connector_init(dev, connector, 453 drm_connector_init(dev, connector,
453 &intel_dvo_connector_funcs, 454 &intel_dvo_connector_funcs,
@@ -462,16 +463,16 @@ void intel_dvo_init(struct drm_device *dev)
462 connector->interlace_allowed = false; 463 connector->interlace_allowed = false;
463 connector->doublescan_allowed = false; 464 connector->doublescan_allowed = false;
464 465
465 intel_output->dev_priv = dvo; 466 intel_encoder->dev_priv = dvo;
466 intel_output->i2c_bus = i2cbus; 467 intel_encoder->i2c_bus = i2cbus;
467 468
468 drm_encoder_init(dev, &intel_output->enc, 469 drm_encoder_init(dev, &intel_encoder->enc,
469 &intel_dvo_enc_funcs, encoder_type); 470 &intel_dvo_enc_funcs, encoder_type);
470 drm_encoder_helper_add(&intel_output->enc, 471 drm_encoder_helper_add(&intel_encoder->enc,
471 &intel_dvo_helper_funcs); 472 &intel_dvo_helper_funcs);
472 473
473 drm_mode_connector_attach_encoder(&intel_output->base, 474 drm_mode_connector_attach_encoder(&intel_encoder->base,
474 &intel_output->enc); 475 &intel_encoder->enc);
475 if (dvo->type == INTEL_DVO_CHIP_LVDS) { 476 if (dvo->type == INTEL_DVO_CHIP_LVDS) {
476 /* For our LVDS chipsets, we should hopefully be able 477 /* For our LVDS chipsets, we should hopefully be able
477 * to dig the fixed panel mode out of the BIOS data. 478 * to dig the fixed panel mode out of the BIOS data.
@@ -489,10 +490,10 @@ void intel_dvo_init(struct drm_device *dev)
489 return; 490 return;
490 } 491 }
491 492
492 intel_i2c_destroy(intel_output->ddc_bus); 493 intel_i2c_destroy(intel_encoder->ddc_bus);
493 /* Didn't find a chip, so tear down. */ 494 /* Didn't find a chip, so tear down. */
494 if (i2cbus != NULL) 495 if (i2cbus != NULL)
495 intel_i2c_destroy(i2cbus); 496 intel_i2c_destroy(i2cbus);
496free_intel: 497free_intel:
497 kfree(intel_output); 498 kfree(intel_encoder);
498} 499}
diff --git a/drivers/gpu/drm/i915/intel_fb.c b/drivers/gpu/drm/i915/intel_fb.c
index 8cd791dc5b2..8a0b3bcdc7b 100644
--- a/drivers/gpu/drm/i915/intel_fb.c
+++ b/drivers/gpu/drm/i915/intel_fb.c
@@ -30,7 +30,6 @@
30#include <linux/string.h> 30#include <linux/string.h>
31#include <linux/mm.h> 31#include <linux/mm.h>
32#include <linux/tty.h> 32#include <linux/tty.h>
33#include <linux/slab.h>
34#include <linux/sysrq.h> 33#include <linux/sysrq.h>
35#include <linux/delay.h> 34#include <linux/delay.h>
36#include <linux/fb.h> 35#include <linux/fb.h>
@@ -145,7 +144,7 @@ static int intelfb_create(struct drm_device *dev, uint32_t fb_width,
145 ret = -ENOMEM; 144 ret = -ENOMEM;
146 goto out; 145 goto out;
147 } 146 }
148 obj_priv = fbo->driver_private; 147 obj_priv = to_intel_bo(fbo);
149 148
150 mutex_lock(&dev->struct_mutex); 149 mutex_lock(&dev->struct_mutex);
151 150
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
index a30f8bfc198..48cade0cf7b 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -27,6 +27,7 @@
27 */ 27 */
28 28
29#include <linux/i2c.h> 29#include <linux/i2c.h>
30#include <linux/slab.h>
30#include <linux/delay.h> 31#include <linux/delay.h>
31#include "drmP.h" 32#include "drmP.h"
32#include "drm.h" 33#include "drm.h"
@@ -50,8 +51,8 @@ static void intel_hdmi_mode_set(struct drm_encoder *encoder,
50 struct drm_i915_private *dev_priv = dev->dev_private; 51 struct drm_i915_private *dev_priv = dev->dev_private;
51 struct drm_crtc *crtc = encoder->crtc; 52 struct drm_crtc *crtc = encoder->crtc;
52 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 53 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
53 struct intel_output *intel_output = enc_to_intel_output(encoder); 54 struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder);
54 struct intel_hdmi_priv *hdmi_priv = intel_output->dev_priv; 55 struct intel_hdmi_priv *hdmi_priv = intel_encoder->dev_priv;
55 u32 sdvox; 56 u32 sdvox;
56 57
57 sdvox = SDVO_ENCODING_HDMI | 58 sdvox = SDVO_ENCODING_HDMI |
@@ -73,8 +74,8 @@ static void intel_hdmi_dpms(struct drm_encoder *encoder, int mode)
73{ 74{
74 struct drm_device *dev = encoder->dev; 75 struct drm_device *dev = encoder->dev;
75 struct drm_i915_private *dev_priv = dev->dev_private; 76 struct drm_i915_private *dev_priv = dev->dev_private;
76 struct intel_output *intel_output = enc_to_intel_output(encoder); 77 struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder);
77 struct intel_hdmi_priv *hdmi_priv = intel_output->dev_priv; 78 struct intel_hdmi_priv *hdmi_priv = intel_encoder->dev_priv;
78 u32 temp; 79 u32 temp;
79 80
80 temp = I915_READ(hdmi_priv->sdvox_reg); 81 temp = I915_READ(hdmi_priv->sdvox_reg);
@@ -109,8 +110,8 @@ static void intel_hdmi_save(struct drm_connector *connector)
109{ 110{
110 struct drm_device *dev = connector->dev; 111 struct drm_device *dev = connector->dev;
111 struct drm_i915_private *dev_priv = dev->dev_private; 112 struct drm_i915_private *dev_priv = dev->dev_private;
112 struct intel_output *intel_output = to_intel_output(connector); 113 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
113 struct intel_hdmi_priv *hdmi_priv = intel_output->dev_priv; 114 struct intel_hdmi_priv *hdmi_priv = intel_encoder->dev_priv;
114 115
115 hdmi_priv->save_SDVOX = I915_READ(hdmi_priv->sdvox_reg); 116 hdmi_priv->save_SDVOX = I915_READ(hdmi_priv->sdvox_reg);
116} 117}
@@ -119,8 +120,8 @@ static void intel_hdmi_restore(struct drm_connector *connector)
119{ 120{
120 struct drm_device *dev = connector->dev; 121 struct drm_device *dev = connector->dev;
121 struct drm_i915_private *dev_priv = dev->dev_private; 122 struct drm_i915_private *dev_priv = dev->dev_private;
122 struct intel_output *intel_output = to_intel_output(connector); 123 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
123 struct intel_hdmi_priv *hdmi_priv = intel_output->dev_priv; 124 struct intel_hdmi_priv *hdmi_priv = intel_encoder->dev_priv;
124 125
125 I915_WRITE(hdmi_priv->sdvox_reg, hdmi_priv->save_SDVOX); 126 I915_WRITE(hdmi_priv->sdvox_reg, hdmi_priv->save_SDVOX);
126 POSTING_READ(hdmi_priv->sdvox_reg); 127 POSTING_READ(hdmi_priv->sdvox_reg);
@@ -150,21 +151,21 @@ static bool intel_hdmi_mode_fixup(struct drm_encoder *encoder,
150static enum drm_connector_status 151static enum drm_connector_status
151intel_hdmi_detect(struct drm_connector *connector) 152intel_hdmi_detect(struct drm_connector *connector)
152{ 153{
153 struct intel_output *intel_output = to_intel_output(connector); 154 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
154 struct intel_hdmi_priv *hdmi_priv = intel_output->dev_priv; 155 struct intel_hdmi_priv *hdmi_priv = intel_encoder->dev_priv;
155 struct edid *edid = NULL; 156 struct edid *edid = NULL;
156 enum drm_connector_status status = connector_status_disconnected; 157 enum drm_connector_status status = connector_status_disconnected;
157 158
158 hdmi_priv->has_hdmi_sink = false; 159 hdmi_priv->has_hdmi_sink = false;
159 edid = drm_get_edid(&intel_output->base, 160 edid = drm_get_edid(&intel_encoder->base,
160 intel_output->ddc_bus); 161 intel_encoder->ddc_bus);
161 162
162 if (edid) { 163 if (edid) {
163 if (edid->input & DRM_EDID_INPUT_DIGITAL) { 164 if (edid->input & DRM_EDID_INPUT_DIGITAL) {
164 status = connector_status_connected; 165 status = connector_status_connected;
165 hdmi_priv->has_hdmi_sink = drm_detect_hdmi_monitor(edid); 166 hdmi_priv->has_hdmi_sink = drm_detect_hdmi_monitor(edid);
166 } 167 }
167 intel_output->base.display_info.raw_edid = NULL; 168 intel_encoder->base.display_info.raw_edid = NULL;
168 kfree(edid); 169 kfree(edid);
169 } 170 }
170 171
@@ -173,24 +174,24 @@ intel_hdmi_detect(struct drm_connector *connector)
173 174
174static int intel_hdmi_get_modes(struct drm_connector *connector) 175static int intel_hdmi_get_modes(struct drm_connector *connector)
175{ 176{
176 struct intel_output *intel_output = to_intel_output(connector); 177 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
177 178
178 /* We should parse the EDID data and find out if it's an HDMI sink so 179 /* We should parse the EDID data and find out if it's an HDMI sink so
179 * we can send audio to it. 180 * we can send audio to it.
180 */ 181 */
181 182
182 return intel_ddc_get_modes(intel_output); 183 return intel_ddc_get_modes(intel_encoder);
183} 184}
184 185
185static void intel_hdmi_destroy(struct drm_connector *connector) 186static void intel_hdmi_destroy(struct drm_connector *connector)
186{ 187{
187 struct intel_output *intel_output = to_intel_output(connector); 188 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
188 189
189 if (intel_output->i2c_bus) 190 if (intel_encoder->i2c_bus)
190 intel_i2c_destroy(intel_output->i2c_bus); 191 intel_i2c_destroy(intel_encoder->i2c_bus);
191 drm_sysfs_connector_remove(connector); 192 drm_sysfs_connector_remove(connector);
192 drm_connector_cleanup(connector); 193 drm_connector_cleanup(connector);
193 kfree(intel_output); 194 kfree(intel_encoder);
194} 195}
195 196
196static const struct drm_encoder_helper_funcs intel_hdmi_helper_funcs = { 197static const struct drm_encoder_helper_funcs intel_hdmi_helper_funcs = {
@@ -229,63 +230,63 @@ void intel_hdmi_init(struct drm_device *dev, int sdvox_reg)
229{ 230{
230 struct drm_i915_private *dev_priv = dev->dev_private; 231 struct drm_i915_private *dev_priv = dev->dev_private;
231 struct drm_connector *connector; 232 struct drm_connector *connector;
232 struct intel_output *intel_output; 233 struct intel_encoder *intel_encoder;
233 struct intel_hdmi_priv *hdmi_priv; 234 struct intel_hdmi_priv *hdmi_priv;
234 235
235 intel_output = kcalloc(sizeof(struct intel_output) + 236 intel_encoder = kcalloc(sizeof(struct intel_encoder) +
236 sizeof(struct intel_hdmi_priv), 1, GFP_KERNEL); 237 sizeof(struct intel_hdmi_priv), 1, GFP_KERNEL);
237 if (!intel_output) 238 if (!intel_encoder)
238 return; 239 return;
239 hdmi_priv = (struct intel_hdmi_priv *)(intel_output + 1); 240 hdmi_priv = (struct intel_hdmi_priv *)(intel_encoder + 1);
240 241
241 connector = &intel_output->base; 242 connector = &intel_encoder->base;
242 drm_connector_init(dev, connector, &intel_hdmi_connector_funcs, 243 drm_connector_init(dev, connector, &intel_hdmi_connector_funcs,
243 DRM_MODE_CONNECTOR_HDMIA); 244 DRM_MODE_CONNECTOR_HDMIA);
244 drm_connector_helper_add(connector, &intel_hdmi_connector_helper_funcs); 245 drm_connector_helper_add(connector, &intel_hdmi_connector_helper_funcs);
245 246
246 intel_output->type = INTEL_OUTPUT_HDMI; 247 intel_encoder->type = INTEL_OUTPUT_HDMI;
247 248
248 connector->interlace_allowed = 0; 249 connector->interlace_allowed = 0;
249 connector->doublescan_allowed = 0; 250 connector->doublescan_allowed = 0;
250 intel_output->crtc_mask = (1 << 0) | (1 << 1); 251 intel_encoder->crtc_mask = (1 << 0) | (1 << 1);
251 252
252 /* Set up the DDC bus. */ 253 /* Set up the DDC bus. */
253 if (sdvox_reg == SDVOB) { 254 if (sdvox_reg == SDVOB) {
254 intel_output->clone_mask = (1 << INTEL_HDMIB_CLONE_BIT); 255 intel_encoder->clone_mask = (1 << INTEL_HDMIB_CLONE_BIT);
255 intel_output->ddc_bus = intel_i2c_create(dev, GPIOE, "HDMIB"); 256 intel_encoder->ddc_bus = intel_i2c_create(dev, GPIOE, "HDMIB");
256 dev_priv->hotplug_supported_mask |= HDMIB_HOTPLUG_INT_STATUS; 257 dev_priv->hotplug_supported_mask |= HDMIB_HOTPLUG_INT_STATUS;
257 } else if (sdvox_reg == SDVOC) { 258 } else if (sdvox_reg == SDVOC) {
258 intel_output->clone_mask = (1 << INTEL_HDMIC_CLONE_BIT); 259 intel_encoder->clone_mask = (1 << INTEL_HDMIC_CLONE_BIT);
259 intel_output->ddc_bus = intel_i2c_create(dev, GPIOD, "HDMIC"); 260 intel_encoder->ddc_bus = intel_i2c_create(dev, GPIOD, "HDMIC");
260 dev_priv->hotplug_supported_mask |= HDMIC_HOTPLUG_INT_STATUS; 261 dev_priv->hotplug_supported_mask |= HDMIC_HOTPLUG_INT_STATUS;
261 } else if (sdvox_reg == HDMIB) { 262 } else if (sdvox_reg == HDMIB) {
262 intel_output->clone_mask = (1 << INTEL_HDMID_CLONE_BIT); 263 intel_encoder->clone_mask = (1 << INTEL_HDMID_CLONE_BIT);
263 intel_output->ddc_bus = intel_i2c_create(dev, PCH_GPIOE, 264 intel_encoder->ddc_bus = intel_i2c_create(dev, PCH_GPIOE,
264 "HDMIB"); 265 "HDMIB");
265 dev_priv->hotplug_supported_mask |= HDMIB_HOTPLUG_INT_STATUS; 266 dev_priv->hotplug_supported_mask |= HDMIB_HOTPLUG_INT_STATUS;
266 } else if (sdvox_reg == HDMIC) { 267 } else if (sdvox_reg == HDMIC) {
267 intel_output->clone_mask = (1 << INTEL_HDMIE_CLONE_BIT); 268 intel_encoder->clone_mask = (1 << INTEL_HDMIE_CLONE_BIT);
268 intel_output->ddc_bus = intel_i2c_create(dev, PCH_GPIOD, 269 intel_encoder->ddc_bus = intel_i2c_create(dev, PCH_GPIOD,
269 "HDMIC"); 270 "HDMIC");
270 dev_priv->hotplug_supported_mask |= HDMIC_HOTPLUG_INT_STATUS; 271 dev_priv->hotplug_supported_mask |= HDMIC_HOTPLUG_INT_STATUS;
271 } else if (sdvox_reg == HDMID) { 272 } else if (sdvox_reg == HDMID) {
272 intel_output->clone_mask = (1 << INTEL_HDMIF_CLONE_BIT); 273 intel_encoder->clone_mask = (1 << INTEL_HDMIF_CLONE_BIT);
273 intel_output->ddc_bus = intel_i2c_create(dev, PCH_GPIOF, 274 intel_encoder->ddc_bus = intel_i2c_create(dev, PCH_GPIOF,
274 "HDMID"); 275 "HDMID");
275 dev_priv->hotplug_supported_mask |= HDMID_HOTPLUG_INT_STATUS; 276 dev_priv->hotplug_supported_mask |= HDMID_HOTPLUG_INT_STATUS;
276 } 277 }
277 if (!intel_output->ddc_bus) 278 if (!intel_encoder->ddc_bus)
278 goto err_connector; 279 goto err_connector;
279 280
280 hdmi_priv->sdvox_reg = sdvox_reg; 281 hdmi_priv->sdvox_reg = sdvox_reg;
281 intel_output->dev_priv = hdmi_priv; 282 intel_encoder->dev_priv = hdmi_priv;
282 283
283 drm_encoder_init(dev, &intel_output->enc, &intel_hdmi_enc_funcs, 284 drm_encoder_init(dev, &intel_encoder->enc, &intel_hdmi_enc_funcs,
284 DRM_MODE_ENCODER_TMDS); 285 DRM_MODE_ENCODER_TMDS);
285 drm_encoder_helper_add(&intel_output->enc, &intel_hdmi_helper_funcs); 286 drm_encoder_helper_add(&intel_encoder->enc, &intel_hdmi_helper_funcs);
286 287
287 drm_mode_connector_attach_encoder(&intel_output->base, 288 drm_mode_connector_attach_encoder(&intel_encoder->base,
288 &intel_output->enc); 289 &intel_encoder->enc);
289 drm_sysfs_connector_add(connector); 290 drm_sysfs_connector_add(connector);
290 291
291 /* For G4X desktop chip, PEG_BAND_GAP_DATA 3:0 must first be written 292 /* For G4X desktop chip, PEG_BAND_GAP_DATA 3:0 must first be written
@@ -301,7 +302,7 @@ void intel_hdmi_init(struct drm_device *dev, int sdvox_reg)
301 302
302err_connector: 303err_connector:
303 drm_connector_cleanup(connector); 304 drm_connector_cleanup(connector);
304 kfree(intel_output); 305 kfree(intel_encoder);
305 306
306 return; 307 return;
307} 308}
diff --git a/drivers/gpu/drm/i915/intel_i2c.c b/drivers/gpu/drm/i915/intel_i2c.c
index fcc753ca5d9..c2649c7df14 100644
--- a/drivers/gpu/drm/i915/intel_i2c.c
+++ b/drivers/gpu/drm/i915/intel_i2c.c
@@ -26,6 +26,7 @@
26 * Eric Anholt <eric@anholt.net> 26 * Eric Anholt <eric@anholt.net>
27 */ 27 */
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <linux/slab.h>
29#include <linux/i2c-id.h> 30#include <linux/i2c-id.h>
30#include <linux/i2c-algo-bit.h> 31#include <linux/i2c-algo-bit.h>
31#include "drmP.h" 32#include "drmP.h"
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index 14e516fdc2d..b66806a37d3 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -30,6 +30,7 @@
30#include <acpi/button.h> 30#include <acpi/button.h>
31#include <linux/dmi.h> 31#include <linux/dmi.h>
32#include <linux/i2c.h> 32#include <linux/i2c.h>
33#include <linux/slab.h>
33#include "drmP.h" 34#include "drmP.h"
34#include "drm.h" 35#include "drm.h"
35#include "drm_crtc.h" 36#include "drm_crtc.h"
@@ -238,8 +239,8 @@ static bool intel_lvds_mode_fixup(struct drm_encoder *encoder,
238 struct drm_i915_private *dev_priv = dev->dev_private; 239 struct drm_i915_private *dev_priv = dev->dev_private;
239 struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc); 240 struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
240 struct drm_encoder *tmp_encoder; 241 struct drm_encoder *tmp_encoder;
241 struct intel_output *intel_output = enc_to_intel_output(encoder); 242 struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder);
242 struct intel_lvds_priv *lvds_priv = intel_output->dev_priv; 243 struct intel_lvds_priv *lvds_priv = intel_encoder->dev_priv;
243 u32 pfit_control = 0, pfit_pgm_ratios = 0; 244 u32 pfit_control = 0, pfit_pgm_ratios = 0;
244 int left_border = 0, right_border = 0, top_border = 0; 245 int left_border = 0, right_border = 0, top_border = 0;
245 int bottom_border = 0; 246 int bottom_border = 0;
@@ -586,8 +587,8 @@ static void intel_lvds_mode_set(struct drm_encoder *encoder,
586{ 587{
587 struct drm_device *dev = encoder->dev; 588 struct drm_device *dev = encoder->dev;
588 struct drm_i915_private *dev_priv = dev->dev_private; 589 struct drm_i915_private *dev_priv = dev->dev_private;
589 struct intel_output *intel_output = enc_to_intel_output(encoder); 590 struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder);
590 struct intel_lvds_priv *lvds_priv = intel_output->dev_priv; 591 struct intel_lvds_priv *lvds_priv = intel_encoder->dev_priv;
591 592
592 /* 593 /*
593 * The LVDS pin pair will already have been turned on in the 594 * The LVDS pin pair will already have been turned on in the
@@ -607,53 +608,6 @@ static void intel_lvds_mode_set(struct drm_encoder *encoder,
607 I915_WRITE(PFIT_CONTROL, lvds_priv->pfit_control); 608 I915_WRITE(PFIT_CONTROL, lvds_priv->pfit_control);
608} 609}
609 610
610/* Some lid devices report incorrect lid status, assume they're connected */
611static const struct dmi_system_id bad_lid_status[] = {
612 {
613 .ident = "Compaq nx9020",
614 .matches = {
615 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
616 DMI_MATCH(DMI_BOARD_NAME, "3084"),
617 },
618 },
619 {
620 .ident = "Samsung SX20S",
621 .matches = {
622 DMI_MATCH(DMI_SYS_VENDOR, "Samsung Electronics"),
623 DMI_MATCH(DMI_BOARD_NAME, "SX20S"),
624 },
625 },
626 {
627 .ident = "Aspire One",
628 .matches = {
629 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
630 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire one"),
631 },
632 },
633 {
634 .ident = "Aspire 1810T",
635 .matches = {
636 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
637 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 1810T"),
638 },
639 },
640 {
641 .ident = "PC-81005",
642 .matches = {
643 DMI_MATCH(DMI_SYS_VENDOR, "MALATA"),
644 DMI_MATCH(DMI_PRODUCT_NAME, "PC-81005"),
645 },
646 },
647 {
648 .ident = "Clevo M5x0N",
649 .matches = {
650 DMI_MATCH(DMI_SYS_VENDOR, "CLEVO Co."),
651 DMI_MATCH(DMI_BOARD_NAME, "M5x0N"),
652 },
653 },
654 { }
655};
656
657/** 611/**
658 * Detect the LVDS connection. 612 * Detect the LVDS connection.
659 * 613 *
@@ -669,12 +623,9 @@ static enum drm_connector_status intel_lvds_detect(struct drm_connector *connect
669 /* ACPI lid methods were generally unreliable in this generation, so 623 /* ACPI lid methods were generally unreliable in this generation, so
670 * don't even bother. 624 * don't even bother.
671 */ 625 */
672 if (IS_GEN2(dev)) 626 if (IS_GEN2(dev) || IS_GEN3(dev))
673 return connector_status_connected; 627 return connector_status_connected;
674 628
675 if (!dmi_check_system(bad_lid_status) && !acpi_lid_open())
676 status = connector_status_disconnected;
677
678 return status; 629 return status;
679} 630}
680 631
@@ -684,14 +635,16 @@ static enum drm_connector_status intel_lvds_detect(struct drm_connector *connect
684static int intel_lvds_get_modes(struct drm_connector *connector) 635static int intel_lvds_get_modes(struct drm_connector *connector)
685{ 636{
686 struct drm_device *dev = connector->dev; 637 struct drm_device *dev = connector->dev;
687 struct intel_output *intel_output = to_intel_output(connector); 638 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
688 struct drm_i915_private *dev_priv = dev->dev_private; 639 struct drm_i915_private *dev_priv = dev->dev_private;
689 int ret = 0; 640 int ret = 0;
690 641
691 ret = intel_ddc_get_modes(intel_output); 642 if (dev_priv->lvds_edid_good) {
643 ret = intel_ddc_get_modes(intel_encoder);
692 644
693 if (ret) 645 if (ret)
694 return ret; 646 return ret;
647 }
695 648
696 /* Didn't get an EDID, so 649 /* Didn't get an EDID, so
697 * Set wide sync ranges so we get all modes 650 * Set wide sync ranges so we get all modes
@@ -764,11 +717,11 @@ static int intel_lid_notify(struct notifier_block *nb, unsigned long val,
764static void intel_lvds_destroy(struct drm_connector *connector) 717static void intel_lvds_destroy(struct drm_connector *connector)
765{ 718{
766 struct drm_device *dev = connector->dev; 719 struct drm_device *dev = connector->dev;
767 struct intel_output *intel_output = to_intel_output(connector); 720 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
768 struct drm_i915_private *dev_priv = dev->dev_private; 721 struct drm_i915_private *dev_priv = dev->dev_private;
769 722
770 if (intel_output->ddc_bus) 723 if (intel_encoder->ddc_bus)
771 intel_i2c_destroy(intel_output->ddc_bus); 724 intel_i2c_destroy(intel_encoder->ddc_bus);
772 if (dev_priv->lid_notifier.notifier_call) 725 if (dev_priv->lid_notifier.notifier_call)
773 acpi_lid_notifier_unregister(&dev_priv->lid_notifier); 726 acpi_lid_notifier_unregister(&dev_priv->lid_notifier);
774 drm_sysfs_connector_remove(connector); 727 drm_sysfs_connector_remove(connector);
@@ -781,13 +734,13 @@ static int intel_lvds_set_property(struct drm_connector *connector,
781 uint64_t value) 734 uint64_t value)
782{ 735{
783 struct drm_device *dev = connector->dev; 736 struct drm_device *dev = connector->dev;
784 struct intel_output *intel_output = 737 struct intel_encoder *intel_encoder =
785 to_intel_output(connector); 738 to_intel_encoder(connector);
786 739
787 if (property == dev->mode_config.scaling_mode_property && 740 if (property == dev->mode_config.scaling_mode_property &&
788 connector->encoder) { 741 connector->encoder) {
789 struct drm_crtc *crtc = connector->encoder->crtc; 742 struct drm_crtc *crtc = connector->encoder->crtc;
790 struct intel_lvds_priv *lvds_priv = intel_output->dev_priv; 743 struct intel_lvds_priv *lvds_priv = intel_encoder->dev_priv;
791 if (value == DRM_MODE_SCALE_NONE) { 744 if (value == DRM_MODE_SCALE_NONE) {
792 DRM_DEBUG_KMS("no scaling not supported\n"); 745 DRM_DEBUG_KMS("no scaling not supported\n");
793 return 0; 746 return 0;
@@ -907,6 +860,14 @@ static const struct dmi_system_id intel_no_lvds[] = {
907 DMI_MATCH(DMI_PRODUCT_VERSION, "AO00001JW"), 860 DMI_MATCH(DMI_PRODUCT_VERSION, "AO00001JW"),
908 }, 861 },
909 }, 862 },
863 {
864 .callback = intel_no_lvds_dmi_callback,
865 .ident = "Clientron U800",
866 .matches = {
867 DMI_MATCH(DMI_SYS_VENDOR, "Clientron"),
868 DMI_MATCH(DMI_PRODUCT_NAME, "U800"),
869 },
870 },
910 871
911 { } /* terminating entry */ 872 { } /* terminating entry */
912}; 873};
@@ -1017,7 +978,7 @@ static int lvds_is_present_in_vbt(struct drm_device *dev)
1017void intel_lvds_init(struct drm_device *dev) 978void intel_lvds_init(struct drm_device *dev)
1018{ 979{
1019 struct drm_i915_private *dev_priv = dev->dev_private; 980 struct drm_i915_private *dev_priv = dev->dev_private;
1020 struct intel_output *intel_output; 981 struct intel_encoder *intel_encoder;
1021 struct drm_connector *connector; 982 struct drm_connector *connector;
1022 struct drm_encoder *encoder; 983 struct drm_encoder *encoder;
1023 struct drm_display_mode *scan; /* *modes, *bios_mode; */ 984 struct drm_display_mode *scan; /* *modes, *bios_mode; */
@@ -1045,40 +1006,40 @@ void intel_lvds_init(struct drm_device *dev)
1045 gpio = PCH_GPIOC; 1006 gpio = PCH_GPIOC;
1046 } 1007 }
1047 1008
1048 intel_output = kzalloc(sizeof(struct intel_output) + 1009 intel_encoder = kzalloc(sizeof(struct intel_encoder) +
1049 sizeof(struct intel_lvds_priv), GFP_KERNEL); 1010 sizeof(struct intel_lvds_priv), GFP_KERNEL);
1050 if (!intel_output) { 1011 if (!intel_encoder) {
1051 return; 1012 return;
1052 } 1013 }
1053 1014
1054 connector = &intel_output->base; 1015 connector = &intel_encoder->base;
1055 encoder = &intel_output->enc; 1016 encoder = &intel_encoder->enc;
1056 drm_connector_init(dev, &intel_output->base, &intel_lvds_connector_funcs, 1017 drm_connector_init(dev, &intel_encoder->base, &intel_lvds_connector_funcs,
1057 DRM_MODE_CONNECTOR_LVDS); 1018 DRM_MODE_CONNECTOR_LVDS);
1058 1019
1059 drm_encoder_init(dev, &intel_output->enc, &intel_lvds_enc_funcs, 1020 drm_encoder_init(dev, &intel_encoder->enc, &intel_lvds_enc_funcs,
1060 DRM_MODE_ENCODER_LVDS); 1021 DRM_MODE_ENCODER_LVDS);
1061 1022
1062 drm_mode_connector_attach_encoder(&intel_output->base, &intel_output->enc); 1023 drm_mode_connector_attach_encoder(&intel_encoder->base, &intel_encoder->enc);
1063 intel_output->type = INTEL_OUTPUT_LVDS; 1024 intel_encoder->type = INTEL_OUTPUT_LVDS;
1064 1025
1065 intel_output->clone_mask = (1 << INTEL_LVDS_CLONE_BIT); 1026 intel_encoder->clone_mask = (1 << INTEL_LVDS_CLONE_BIT);
1066 intel_output->crtc_mask = (1 << 1); 1027 intel_encoder->crtc_mask = (1 << 1);
1067 drm_encoder_helper_add(encoder, &intel_lvds_helper_funcs); 1028 drm_encoder_helper_add(encoder, &intel_lvds_helper_funcs);
1068 drm_connector_helper_add(connector, &intel_lvds_connector_helper_funcs); 1029 drm_connector_helper_add(connector, &intel_lvds_connector_helper_funcs);
1069 connector->display_info.subpixel_order = SubPixelHorizontalRGB; 1030 connector->display_info.subpixel_order = SubPixelHorizontalRGB;
1070 connector->interlace_allowed = false; 1031 connector->interlace_allowed = false;
1071 connector->doublescan_allowed = false; 1032 connector->doublescan_allowed = false;
1072 1033
1073 lvds_priv = (struct intel_lvds_priv *)(intel_output + 1); 1034 lvds_priv = (struct intel_lvds_priv *)(intel_encoder + 1);
1074 intel_output->dev_priv = lvds_priv; 1035 intel_encoder->dev_priv = lvds_priv;
1075 /* create the scaling mode property */ 1036 /* create the scaling mode property */
1076 drm_mode_create_scaling_mode_property(dev); 1037 drm_mode_create_scaling_mode_property(dev);
1077 /* 1038 /*
1078 * the initial panel fitting mode will be FULL_SCREEN. 1039 * the initial panel fitting mode will be FULL_SCREEN.
1079 */ 1040 */
1080 1041
1081 drm_connector_attach_property(&intel_output->base, 1042 drm_connector_attach_property(&intel_encoder->base,
1082 dev->mode_config.scaling_mode_property, 1043 dev->mode_config.scaling_mode_property,
1083 DRM_MODE_SCALE_FULLSCREEN); 1044 DRM_MODE_SCALE_FULLSCREEN);
1084 lvds_priv->fitting_mode = DRM_MODE_SCALE_FULLSCREEN; 1045 lvds_priv->fitting_mode = DRM_MODE_SCALE_FULLSCREEN;
@@ -1093,8 +1054,8 @@ void intel_lvds_init(struct drm_device *dev)
1093 */ 1054 */
1094 1055
1095 /* Set up the DDC bus. */ 1056 /* Set up the DDC bus. */
1096 intel_output->ddc_bus = intel_i2c_create(dev, gpio, "LVDSDDC_C"); 1057 intel_encoder->ddc_bus = intel_i2c_create(dev, gpio, "LVDSDDC_C");
1097 if (!intel_output->ddc_bus) { 1058 if (!intel_encoder->ddc_bus) {
1098 dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration " 1059 dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration "
1099 "failed.\n"); 1060 "failed.\n");
1100 goto failed; 1061 goto failed;
@@ -1104,7 +1065,10 @@ void intel_lvds_init(struct drm_device *dev)
1104 * Attempt to get the fixed panel mode from DDC. Assume that the 1065 * Attempt to get the fixed panel mode from DDC. Assume that the
1105 * preferred mode is the right one. 1066 * preferred mode is the right one.
1106 */ 1067 */
1107 intel_ddc_get_modes(intel_output); 1068 dev_priv->lvds_edid_good = true;
1069
1070 if (!intel_ddc_get_modes(intel_encoder))
1071 dev_priv->lvds_edid_good = false;
1108 1072
1109 list_for_each_entry(scan, &connector->probed_modes, head) { 1073 list_for_each_entry(scan, &connector->probed_modes, head) {
1110 mutex_lock(&dev->mode_config.mutex); 1074 mutex_lock(&dev->mode_config.mutex);
@@ -1182,9 +1146,9 @@ out:
1182 1146
1183failed: 1147failed:
1184 DRM_DEBUG_KMS("No LVDS modes found, disabling.\n"); 1148 DRM_DEBUG_KMS("No LVDS modes found, disabling.\n");
1185 if (intel_output->ddc_bus) 1149 if (intel_encoder->ddc_bus)
1186 intel_i2c_destroy(intel_output->ddc_bus); 1150 intel_i2c_destroy(intel_encoder->ddc_bus);
1187 drm_connector_cleanup(connector); 1151 drm_connector_cleanup(connector);
1188 drm_encoder_cleanup(encoder); 1152 drm_encoder_cleanup(encoder);
1189 kfree(intel_output); 1153 kfree(intel_encoder);
1190} 1154}
diff --git a/drivers/gpu/drm/i915/intel_modes.c b/drivers/gpu/drm/i915/intel_modes.c
index 67e2f4632a2..8e5c83b2d12 100644
--- a/drivers/gpu/drm/i915/intel_modes.c
+++ b/drivers/gpu/drm/i915/intel_modes.c
@@ -23,6 +23,7 @@
23 * DEALINGS IN THE SOFTWARE. 23 * DEALINGS IN THE SOFTWARE.
24 */ 24 */
25 25
26#include <linux/slab.h>
26#include <linux/i2c.h> 27#include <linux/i2c.h>
27#include <linux/fb.h> 28#include <linux/fb.h>
28#include "drmP.h" 29#include "drmP.h"
@@ -33,7 +34,7 @@
33 * intel_ddc_probe 34 * intel_ddc_probe
34 * 35 *
35 */ 36 */
36bool intel_ddc_probe(struct intel_output *intel_output) 37bool intel_ddc_probe(struct intel_encoder *intel_encoder)
37{ 38{
38 u8 out_buf[] = { 0x0, 0x0}; 39 u8 out_buf[] = { 0x0, 0x0};
39 u8 buf[2]; 40 u8 buf[2];
@@ -53,9 +54,9 @@ bool intel_ddc_probe(struct intel_output *intel_output)
53 } 54 }
54 }; 55 };
55 56
56 intel_i2c_quirk_set(intel_output->base.dev, true); 57 intel_i2c_quirk_set(intel_encoder->base.dev, true);
57 ret = i2c_transfer(intel_output->ddc_bus, msgs, 2); 58 ret = i2c_transfer(intel_encoder->ddc_bus, msgs, 2);
58 intel_i2c_quirk_set(intel_output->base.dev, false); 59 intel_i2c_quirk_set(intel_encoder->base.dev, false);
59 if (ret == 2) 60 if (ret == 2)
60 return true; 61 return true;
61 62
@@ -68,19 +69,19 @@ bool intel_ddc_probe(struct intel_output *intel_output)
68 * 69 *
69 * Fetch the EDID information from @connector using the DDC bus. 70 * Fetch the EDID information from @connector using the DDC bus.
70 */ 71 */
71int intel_ddc_get_modes(struct intel_output *intel_output) 72int intel_ddc_get_modes(struct intel_encoder *intel_encoder)
72{ 73{
73 struct edid *edid; 74 struct edid *edid;
74 int ret = 0; 75 int ret = 0;
75 76
76 intel_i2c_quirk_set(intel_output->base.dev, true); 77 intel_i2c_quirk_set(intel_encoder->base.dev, true);
77 edid = drm_get_edid(&intel_output->base, intel_output->ddc_bus); 78 edid = drm_get_edid(&intel_encoder->base, intel_encoder->ddc_bus);
78 intel_i2c_quirk_set(intel_output->base.dev, false); 79 intel_i2c_quirk_set(intel_encoder->base.dev, false);
79 if (edid) { 80 if (edid) {
80 drm_mode_connector_update_edid_property(&intel_output->base, 81 drm_mode_connector_update_edid_property(&intel_encoder->base,
81 edid); 82 edid);
82 ret = drm_add_edid_modes(&intel_output->base, edid); 83 ret = drm_add_edid_modes(&intel_encoder->base, edid);
83 intel_output->base.display_info.raw_edid = NULL; 84 intel_encoder->base.display_info.raw_edid = NULL;
84 kfree(edid); 85 kfree(edid);
85 } 86 }
86 87
diff --git a/drivers/gpu/drm/i915/intel_overlay.c b/drivers/gpu/drm/i915/intel_overlay.c
index d355d1d527e..6d524a1fc27 100644
--- a/drivers/gpu/drm/i915/intel_overlay.c
+++ b/drivers/gpu/drm/i915/intel_overlay.c
@@ -724,7 +724,7 @@ int intel_overlay_do_put_image(struct intel_overlay *overlay,
724 int ret, tmp_width; 724 int ret, tmp_width;
725 struct overlay_registers *regs; 725 struct overlay_registers *regs;
726 bool scale_changed = false; 726 bool scale_changed = false;
727 struct drm_i915_gem_object *bo_priv = new_bo->driver_private; 727 struct drm_i915_gem_object *bo_priv = to_intel_bo(new_bo);
728 struct drm_device *dev = overlay->dev; 728 struct drm_device *dev = overlay->dev;
729 729
730 BUG_ON(!mutex_is_locked(&dev->struct_mutex)); 730 BUG_ON(!mutex_is_locked(&dev->struct_mutex));
@@ -809,7 +809,7 @@ int intel_overlay_do_put_image(struct intel_overlay *overlay,
809 intel_overlay_continue(overlay, scale_changed); 809 intel_overlay_continue(overlay, scale_changed);
810 810
811 overlay->old_vid_bo = overlay->vid_bo; 811 overlay->old_vid_bo = overlay->vid_bo;
812 overlay->vid_bo = new_bo->driver_private; 812 overlay->vid_bo = to_intel_bo(new_bo);
813 813
814 return 0; 814 return 0;
815 815
@@ -1068,14 +1068,18 @@ int intel_overlay_put_image(struct drm_device *dev, void *data,
1068 1068
1069 drmmode_obj = drm_mode_object_find(dev, put_image_rec->crtc_id, 1069 drmmode_obj = drm_mode_object_find(dev, put_image_rec->crtc_id,
1070 DRM_MODE_OBJECT_CRTC); 1070 DRM_MODE_OBJECT_CRTC);
1071 if (!drmmode_obj) 1071 if (!drmmode_obj) {
1072 return -ENOENT; 1072 ret = -ENOENT;
1073 goto out_free;
1074 }
1073 crtc = to_intel_crtc(obj_to_crtc(drmmode_obj)); 1075 crtc = to_intel_crtc(obj_to_crtc(drmmode_obj));
1074 1076
1075 new_bo = drm_gem_object_lookup(dev, file_priv, 1077 new_bo = drm_gem_object_lookup(dev, file_priv,
1076 put_image_rec->bo_handle); 1078 put_image_rec->bo_handle);
1077 if (!new_bo) 1079 if (!new_bo) {
1078 return -ENOENT; 1080 ret = -ENOENT;
1081 goto out_free;
1082 }
1079 1083
1080 mutex_lock(&dev->mode_config.mutex); 1084 mutex_lock(&dev->mode_config.mutex);
1081 mutex_lock(&dev->struct_mutex); 1085 mutex_lock(&dev->struct_mutex);
@@ -1165,6 +1169,7 @@ out_unlock:
1165 mutex_unlock(&dev->struct_mutex); 1169 mutex_unlock(&dev->struct_mutex);
1166 mutex_unlock(&dev->mode_config.mutex); 1170 mutex_unlock(&dev->mode_config.mutex);
1167 drm_gem_object_unreference_unlocked(new_bo); 1171 drm_gem_object_unreference_unlocked(new_bo);
1172out_free:
1168 kfree(params); 1173 kfree(params);
1169 1174
1170 return ret; 1175 return ret;
@@ -1339,7 +1344,7 @@ void intel_setup_overlay(struct drm_device *dev)
1339 reg_bo = drm_gem_object_alloc(dev, PAGE_SIZE); 1344 reg_bo = drm_gem_object_alloc(dev, PAGE_SIZE);
1340 if (!reg_bo) 1345 if (!reg_bo)
1341 goto out_free; 1346 goto out_free;
1342 overlay->reg_bo = reg_bo->driver_private; 1347 overlay->reg_bo = to_intel_bo(reg_bo);
1343 1348
1344 if (OVERLAY_NONPHYSICAL(dev)) { 1349 if (OVERLAY_NONPHYSICAL(dev)) {
1345 ret = i915_gem_object_pin(reg_bo, PAGE_SIZE); 1350 ret = i915_gem_object_pin(reg_bo, PAGE_SIZE);
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index 48daee5c9c6..87d953664cb 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -26,6 +26,7 @@
26 * Eric Anholt <eric@anholt.net> 26 * Eric Anholt <eric@anholt.net>
27 */ 27 */
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <linux/slab.h>
29#include <linux/delay.h> 30#include <linux/delay.h>
30#include "drmP.h" 31#include "drmP.h"
31#include "drm.h" 32#include "drm.h"
@@ -53,7 +54,7 @@ struct intel_sdvo_priv {
53 u8 slave_addr; 54 u8 slave_addr;
54 55
55 /* Register for the SDVO device: SDVOB or SDVOC */ 56 /* Register for the SDVO device: SDVOB or SDVOC */
56 int output_device; 57 int sdvo_reg;
57 58
58 /* Active outputs controlled by this SDVO output */ 59 /* Active outputs controlled by this SDVO output */
59 uint16_t controlled_output; 60 uint16_t controlled_output;
@@ -123,7 +124,7 @@ struct intel_sdvo_priv {
123 */ 124 */
124 struct intel_sdvo_encode encode; 125 struct intel_sdvo_encode encode;
125 126
126 /* DDC bus used by this SDVO output */ 127 /* DDC bus used by this SDVO encoder */
127 uint8_t ddc_bus; 128 uint8_t ddc_bus;
128 129
129 /* Mac mini hack -- use the same DDC as the analog connector */ 130 /* Mac mini hack -- use the same DDC as the analog connector */
@@ -161,22 +162,22 @@ struct intel_sdvo_priv {
161}; 162};
162 163
163static bool 164static bool
164intel_sdvo_output_setup(struct intel_output *intel_output, uint16_t flags); 165intel_sdvo_output_setup(struct intel_encoder *intel_encoder, uint16_t flags);
165 166
166/** 167/**
167 * Writes the SDVOB or SDVOC with the given value, but always writes both 168 * Writes the SDVOB or SDVOC with the given value, but always writes both
168 * SDVOB and SDVOC to work around apparent hardware issues (according to 169 * SDVOB and SDVOC to work around apparent hardware issues (according to
169 * comments in the BIOS). 170 * comments in the BIOS).
170 */ 171 */
171static void intel_sdvo_write_sdvox(struct intel_output *intel_output, u32 val) 172static void intel_sdvo_write_sdvox(struct intel_encoder *intel_encoder, u32 val)
172{ 173{
173 struct drm_device *dev = intel_output->base.dev; 174 struct drm_device *dev = intel_encoder->base.dev;
174 struct drm_i915_private *dev_priv = dev->dev_private; 175 struct drm_i915_private *dev_priv = dev->dev_private;
175 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; 176 struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv;
176 u32 bval = val, cval = val; 177 u32 bval = val, cval = val;
177 int i; 178 int i;
178 179
179 if (sdvo_priv->output_device == SDVOB) { 180 if (sdvo_priv->sdvo_reg == SDVOB) {
180 cval = I915_READ(SDVOC); 181 cval = I915_READ(SDVOC);
181 } else { 182 } else {
182 bval = I915_READ(SDVOB); 183 bval = I915_READ(SDVOB);
@@ -195,10 +196,10 @@ static void intel_sdvo_write_sdvox(struct intel_output *intel_output, u32 val)
195 } 196 }
196} 197}
197 198
198static bool intel_sdvo_read_byte(struct intel_output *intel_output, u8 addr, 199static bool intel_sdvo_read_byte(struct intel_encoder *intel_encoder, u8 addr,
199 u8 *ch) 200 u8 *ch)
200{ 201{
201 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; 202 struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv;
202 u8 out_buf[2]; 203 u8 out_buf[2];
203 u8 buf[2]; 204 u8 buf[2];
204 int ret; 205 int ret;
@@ -221,7 +222,7 @@ static bool intel_sdvo_read_byte(struct intel_output *intel_output, u8 addr,
221 out_buf[0] = addr; 222 out_buf[0] = addr;
222 out_buf[1] = 0; 223 out_buf[1] = 0;
223 224
224 if ((ret = i2c_transfer(intel_output->i2c_bus, msgs, 2)) == 2) 225 if ((ret = i2c_transfer(intel_encoder->i2c_bus, msgs, 2)) == 2)
225 { 226 {
226 *ch = buf[0]; 227 *ch = buf[0];
227 return true; 228 return true;
@@ -231,10 +232,10 @@ static bool intel_sdvo_read_byte(struct intel_output *intel_output, u8 addr,
231 return false; 232 return false;
232} 233}
233 234
234static bool intel_sdvo_write_byte(struct intel_output *intel_output, int addr, 235static bool intel_sdvo_write_byte(struct intel_encoder *intel_encoder, int addr,
235 u8 ch) 236 u8 ch)
236{ 237{
237 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; 238 struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv;
238 u8 out_buf[2]; 239 u8 out_buf[2];
239 struct i2c_msg msgs[] = { 240 struct i2c_msg msgs[] = {
240 { 241 {
@@ -248,7 +249,7 @@ static bool intel_sdvo_write_byte(struct intel_output *intel_output, int addr,
248 out_buf[0] = addr; 249 out_buf[0] = addr;
249 out_buf[1] = ch; 250 out_buf[1] = ch;
250 251
251 if (i2c_transfer(intel_output->i2c_bus, msgs, 1) == 1) 252 if (i2c_transfer(intel_encoder->i2c_bus, msgs, 1) == 1)
252 { 253 {
253 return true; 254 return true;
254 } 255 }
@@ -352,13 +353,13 @@ static const struct _sdvo_cmd_name {
352 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HBUF_DATA), 353 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HBUF_DATA),
353}; 354};
354 355
355#define SDVO_NAME(dev_priv) ((dev_priv)->output_device == SDVOB ? "SDVOB" : "SDVOC") 356#define SDVO_NAME(dev_priv) ((dev_priv)->sdvo_reg == SDVOB ? "SDVOB" : "SDVOC")
356#define SDVO_PRIV(output) ((struct intel_sdvo_priv *) (output)->dev_priv) 357#define SDVO_PRIV(encoder) ((struct intel_sdvo_priv *) (encoder)->dev_priv)
357 358
358static void intel_sdvo_debug_write(struct intel_output *intel_output, u8 cmd, 359static void intel_sdvo_debug_write(struct intel_encoder *intel_encoder, u8 cmd,
359 void *args, int args_len) 360 void *args, int args_len)
360{ 361{
361 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; 362 struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv;
362 int i; 363 int i;
363 364
364 DRM_DEBUG_KMS("%s: W: %02X ", 365 DRM_DEBUG_KMS("%s: W: %02X ",
@@ -378,19 +379,19 @@ static void intel_sdvo_debug_write(struct intel_output *intel_output, u8 cmd,
378 DRM_LOG_KMS("\n"); 379 DRM_LOG_KMS("\n");
379} 380}
380 381
381static void intel_sdvo_write_cmd(struct intel_output *intel_output, u8 cmd, 382static void intel_sdvo_write_cmd(struct intel_encoder *intel_encoder, u8 cmd,
382 void *args, int args_len) 383 void *args, int args_len)
383{ 384{
384 int i; 385 int i;
385 386
386 intel_sdvo_debug_write(intel_output, cmd, args, args_len); 387 intel_sdvo_debug_write(intel_encoder, cmd, args, args_len);
387 388
388 for (i = 0; i < args_len; i++) { 389 for (i = 0; i < args_len; i++) {
389 intel_sdvo_write_byte(intel_output, SDVO_I2C_ARG_0 - i, 390 intel_sdvo_write_byte(intel_encoder, SDVO_I2C_ARG_0 - i,
390 ((u8*)args)[i]); 391 ((u8*)args)[i]);
391 } 392 }
392 393
393 intel_sdvo_write_byte(intel_output, SDVO_I2C_OPCODE, cmd); 394 intel_sdvo_write_byte(intel_encoder, SDVO_I2C_OPCODE, cmd);
394} 395}
395 396
396static const char *cmd_status_names[] = { 397static const char *cmd_status_names[] = {
@@ -403,11 +404,11 @@ static const char *cmd_status_names[] = {
403 "Scaling not supported" 404 "Scaling not supported"
404}; 405};
405 406
406static void intel_sdvo_debug_response(struct intel_output *intel_output, 407static void intel_sdvo_debug_response(struct intel_encoder *intel_encoder,
407 void *response, int response_len, 408 void *response, int response_len,
408 u8 status) 409 u8 status)
409{ 410{
410 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; 411 struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv;
411 int i; 412 int i;
412 413
413 DRM_DEBUG_KMS("%s: R: ", SDVO_NAME(sdvo_priv)); 414 DRM_DEBUG_KMS("%s: R: ", SDVO_NAME(sdvo_priv));
@@ -422,7 +423,7 @@ static void intel_sdvo_debug_response(struct intel_output *intel_output,
422 DRM_LOG_KMS("\n"); 423 DRM_LOG_KMS("\n");
423} 424}
424 425
425static u8 intel_sdvo_read_response(struct intel_output *intel_output, 426static u8 intel_sdvo_read_response(struct intel_encoder *intel_encoder,
426 void *response, int response_len) 427 void *response, int response_len)
427{ 428{
428 int i; 429 int i;
@@ -432,16 +433,16 @@ static u8 intel_sdvo_read_response(struct intel_output *intel_output,
432 while (retry--) { 433 while (retry--) {
433 /* Read the command response */ 434 /* Read the command response */
434 for (i = 0; i < response_len; i++) { 435 for (i = 0; i < response_len; i++) {
435 intel_sdvo_read_byte(intel_output, 436 intel_sdvo_read_byte(intel_encoder,
436 SDVO_I2C_RETURN_0 + i, 437 SDVO_I2C_RETURN_0 + i,
437 &((u8 *)response)[i]); 438 &((u8 *)response)[i]);
438 } 439 }
439 440
440 /* read the return status */ 441 /* read the return status */
441 intel_sdvo_read_byte(intel_output, SDVO_I2C_CMD_STATUS, 442 intel_sdvo_read_byte(intel_encoder, SDVO_I2C_CMD_STATUS,
442 &status); 443 &status);
443 444
444 intel_sdvo_debug_response(intel_output, response, response_len, 445 intel_sdvo_debug_response(intel_encoder, response, response_len,
445 status); 446 status);
446 if (status != SDVO_CMD_STATUS_PENDING) 447 if (status != SDVO_CMD_STATUS_PENDING)
447 return status; 448 return status;
@@ -469,10 +470,10 @@ static int intel_sdvo_get_pixel_multiplier(struct drm_display_mode *mode)
469 * another I2C transaction after issuing the DDC bus switch, it will be 470 * another I2C transaction after issuing the DDC bus switch, it will be
470 * switched to the internal SDVO register. 471 * switched to the internal SDVO register.
471 */ 472 */
472static void intel_sdvo_set_control_bus_switch(struct intel_output *intel_output, 473static void intel_sdvo_set_control_bus_switch(struct intel_encoder *intel_encoder,
473 u8 target) 474 u8 target)
474{ 475{
475 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; 476 struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv;
476 u8 out_buf[2], cmd_buf[2], ret_value[2], ret; 477 u8 out_buf[2], cmd_buf[2], ret_value[2], ret;
477 struct i2c_msg msgs[] = { 478 struct i2c_msg msgs[] = {
478 { 479 {
@@ -496,10 +497,10 @@ static void intel_sdvo_set_control_bus_switch(struct intel_output *intel_output,
496 }, 497 },
497 }; 498 };
498 499
499 intel_sdvo_debug_write(intel_output, SDVO_CMD_SET_CONTROL_BUS_SWITCH, 500 intel_sdvo_debug_write(intel_encoder, SDVO_CMD_SET_CONTROL_BUS_SWITCH,
500 &target, 1); 501 &target, 1);
501 /* write the DDC switch command argument */ 502 /* write the DDC switch command argument */
502 intel_sdvo_write_byte(intel_output, SDVO_I2C_ARG_0, target); 503 intel_sdvo_write_byte(intel_encoder, SDVO_I2C_ARG_0, target);
503 504
504 out_buf[0] = SDVO_I2C_OPCODE; 505 out_buf[0] = SDVO_I2C_OPCODE;
505 out_buf[1] = SDVO_CMD_SET_CONTROL_BUS_SWITCH; 506 out_buf[1] = SDVO_CMD_SET_CONTROL_BUS_SWITCH;
@@ -508,7 +509,7 @@ static void intel_sdvo_set_control_bus_switch(struct intel_output *intel_output,
508 ret_value[0] = 0; 509 ret_value[0] = 0;
509 ret_value[1] = 0; 510 ret_value[1] = 0;
510 511
511 ret = i2c_transfer(intel_output->i2c_bus, msgs, 3); 512 ret = i2c_transfer(intel_encoder->i2c_bus, msgs, 3);
512 if (ret != 3) { 513 if (ret != 3) {
513 /* failure in I2C transfer */ 514 /* failure in I2C transfer */
514 DRM_DEBUG_KMS("I2c transfer returned %d\n", ret); 515 DRM_DEBUG_KMS("I2c transfer returned %d\n", ret);
@@ -522,7 +523,7 @@ static void intel_sdvo_set_control_bus_switch(struct intel_output *intel_output,
522 return; 523 return;
523} 524}
524 525
525static bool intel_sdvo_set_target_input(struct intel_output *intel_output, bool target_0, bool target_1) 526static bool intel_sdvo_set_target_input(struct intel_encoder *intel_encoder, bool target_0, bool target_1)
526{ 527{
527 struct intel_sdvo_set_target_input_args targets = {0}; 528 struct intel_sdvo_set_target_input_args targets = {0};
528 u8 status; 529 u8 status;
@@ -533,10 +534,10 @@ static bool intel_sdvo_set_target_input(struct intel_output *intel_output, bool
533 if (target_1) 534 if (target_1)
534 targets.target_1 = 1; 535 targets.target_1 = 1;
535 536
536 intel_sdvo_write_cmd(intel_output, SDVO_CMD_SET_TARGET_INPUT, &targets, 537 intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_SET_TARGET_INPUT, &targets,
537 sizeof(targets)); 538 sizeof(targets));
538 539
539 status = intel_sdvo_read_response(intel_output, NULL, 0); 540 status = intel_sdvo_read_response(intel_encoder, NULL, 0);
540 541
541 return (status == SDVO_CMD_STATUS_SUCCESS); 542 return (status == SDVO_CMD_STATUS_SUCCESS);
542} 543}
@@ -547,13 +548,13 @@ static bool intel_sdvo_set_target_input(struct intel_output *intel_output, bool
547 * This function is making an assumption about the layout of the response, 548 * This function is making an assumption about the layout of the response,
548 * which should be checked against the docs. 549 * which should be checked against the docs.
549 */ 550 */
550static bool intel_sdvo_get_trained_inputs(struct intel_output *intel_output, bool *input_1, bool *input_2) 551static bool intel_sdvo_get_trained_inputs(struct intel_encoder *intel_encoder, bool *input_1, bool *input_2)
551{ 552{
552 struct intel_sdvo_get_trained_inputs_response response; 553 struct intel_sdvo_get_trained_inputs_response response;
553 u8 status; 554 u8 status;
554 555
555 intel_sdvo_write_cmd(intel_output, SDVO_CMD_GET_TRAINED_INPUTS, NULL, 0); 556 intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_GET_TRAINED_INPUTS, NULL, 0);
556 status = intel_sdvo_read_response(intel_output, &response, sizeof(response)); 557 status = intel_sdvo_read_response(intel_encoder, &response, sizeof(response));
557 if (status != SDVO_CMD_STATUS_SUCCESS) 558 if (status != SDVO_CMD_STATUS_SUCCESS)
558 return false; 559 return false;
559 560
@@ -562,29 +563,29 @@ static bool intel_sdvo_get_trained_inputs(struct intel_output *intel_output, boo
562 return true; 563 return true;
563} 564}
564 565
565static bool intel_sdvo_get_active_outputs(struct intel_output *intel_output, 566static bool intel_sdvo_get_active_outputs(struct intel_encoder *intel_encoder,
566 u16 *outputs) 567 u16 *outputs)
567{ 568{
568 u8 status; 569 u8 status;
569 570
570 intel_sdvo_write_cmd(intel_output, SDVO_CMD_GET_ACTIVE_OUTPUTS, NULL, 0); 571 intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_GET_ACTIVE_OUTPUTS, NULL, 0);
571 status = intel_sdvo_read_response(intel_output, outputs, sizeof(*outputs)); 572 status = intel_sdvo_read_response(intel_encoder, outputs, sizeof(*outputs));
572 573
573 return (status == SDVO_CMD_STATUS_SUCCESS); 574 return (status == SDVO_CMD_STATUS_SUCCESS);
574} 575}
575 576
576static bool intel_sdvo_set_active_outputs(struct intel_output *intel_output, 577static bool intel_sdvo_set_active_outputs(struct intel_encoder *intel_encoder,
577 u16 outputs) 578 u16 outputs)
578{ 579{
579 u8 status; 580 u8 status;
580 581
581 intel_sdvo_write_cmd(intel_output, SDVO_CMD_SET_ACTIVE_OUTPUTS, &outputs, 582 intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_SET_ACTIVE_OUTPUTS, &outputs,
582 sizeof(outputs)); 583 sizeof(outputs));
583 status = intel_sdvo_read_response(intel_output, NULL, 0); 584 status = intel_sdvo_read_response(intel_encoder, NULL, 0);
584 return (status == SDVO_CMD_STATUS_SUCCESS); 585 return (status == SDVO_CMD_STATUS_SUCCESS);
585} 586}
586 587
587static bool intel_sdvo_set_encoder_power_state(struct intel_output *intel_output, 588static bool intel_sdvo_set_encoder_power_state(struct intel_encoder *intel_encoder,
588 int mode) 589 int mode)
589{ 590{
590 u8 status, state = SDVO_ENCODER_STATE_ON; 591 u8 status, state = SDVO_ENCODER_STATE_ON;
@@ -604,24 +605,24 @@ static bool intel_sdvo_set_encoder_power_state(struct intel_output *intel_output
604 break; 605 break;
605 } 606 }
606 607
607 intel_sdvo_write_cmd(intel_output, SDVO_CMD_SET_ENCODER_POWER_STATE, &state, 608 intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_SET_ENCODER_POWER_STATE, &state,
608 sizeof(state)); 609 sizeof(state));
609 status = intel_sdvo_read_response(intel_output, NULL, 0); 610 status = intel_sdvo_read_response(intel_encoder, NULL, 0);
610 611
611 return (status == SDVO_CMD_STATUS_SUCCESS); 612 return (status == SDVO_CMD_STATUS_SUCCESS);
612} 613}
613 614
614static bool intel_sdvo_get_input_pixel_clock_range(struct intel_output *intel_output, 615static bool intel_sdvo_get_input_pixel_clock_range(struct intel_encoder *intel_encoder,
615 int *clock_min, 616 int *clock_min,
616 int *clock_max) 617 int *clock_max)
617{ 618{
618 struct intel_sdvo_pixel_clock_range clocks; 619 struct intel_sdvo_pixel_clock_range clocks;
619 u8 status; 620 u8 status;
620 621
621 intel_sdvo_write_cmd(intel_output, SDVO_CMD_GET_INPUT_PIXEL_CLOCK_RANGE, 622 intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_GET_INPUT_PIXEL_CLOCK_RANGE,
622 NULL, 0); 623 NULL, 0);
623 624
624 status = intel_sdvo_read_response(intel_output, &clocks, sizeof(clocks)); 625 status = intel_sdvo_read_response(intel_encoder, &clocks, sizeof(clocks));
625 626
626 if (status != SDVO_CMD_STATUS_SUCCESS) 627 if (status != SDVO_CMD_STATUS_SUCCESS)
627 return false; 628 return false;
@@ -633,31 +634,31 @@ static bool intel_sdvo_get_input_pixel_clock_range(struct intel_output *intel_ou
633 return true; 634 return true;
634} 635}
635 636
636static bool intel_sdvo_set_target_output(struct intel_output *intel_output, 637static bool intel_sdvo_set_target_output(struct intel_encoder *intel_encoder,
637 u16 outputs) 638 u16 outputs)
638{ 639{
639 u8 status; 640 u8 status;
640 641
641 intel_sdvo_write_cmd(intel_output, SDVO_CMD_SET_TARGET_OUTPUT, &outputs, 642 intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_SET_TARGET_OUTPUT, &outputs,
642 sizeof(outputs)); 643 sizeof(outputs));
643 644
644 status = intel_sdvo_read_response(intel_output, NULL, 0); 645 status = intel_sdvo_read_response(intel_encoder, NULL, 0);
645 return (status == SDVO_CMD_STATUS_SUCCESS); 646 return (status == SDVO_CMD_STATUS_SUCCESS);
646} 647}
647 648
648static bool intel_sdvo_get_timing(struct intel_output *intel_output, u8 cmd, 649static bool intel_sdvo_get_timing(struct intel_encoder *intel_encoder, u8 cmd,
649 struct intel_sdvo_dtd *dtd) 650 struct intel_sdvo_dtd *dtd)
650{ 651{
651 u8 status; 652 u8 status;
652 653
653 intel_sdvo_write_cmd(intel_output, cmd, NULL, 0); 654 intel_sdvo_write_cmd(intel_encoder, cmd, NULL, 0);
654 status = intel_sdvo_read_response(intel_output, &dtd->part1, 655 status = intel_sdvo_read_response(intel_encoder, &dtd->part1,
655 sizeof(dtd->part1)); 656 sizeof(dtd->part1));
656 if (status != SDVO_CMD_STATUS_SUCCESS) 657 if (status != SDVO_CMD_STATUS_SUCCESS)
657 return false; 658 return false;
658 659
659 intel_sdvo_write_cmd(intel_output, cmd + 1, NULL, 0); 660 intel_sdvo_write_cmd(intel_encoder, cmd + 1, NULL, 0);
660 status = intel_sdvo_read_response(intel_output, &dtd->part2, 661 status = intel_sdvo_read_response(intel_encoder, &dtd->part2,
661 sizeof(dtd->part2)); 662 sizeof(dtd->part2));
662 if (status != SDVO_CMD_STATUS_SUCCESS) 663 if (status != SDVO_CMD_STATUS_SUCCESS)
663 return false; 664 return false;
@@ -665,60 +666,60 @@ static bool intel_sdvo_get_timing(struct intel_output *intel_output, u8 cmd,
665 return true; 666 return true;
666} 667}
667 668
668static bool intel_sdvo_get_input_timing(struct intel_output *intel_output, 669static bool intel_sdvo_get_input_timing(struct intel_encoder *intel_encoder,
669 struct intel_sdvo_dtd *dtd) 670 struct intel_sdvo_dtd *dtd)
670{ 671{
671 return intel_sdvo_get_timing(intel_output, 672 return intel_sdvo_get_timing(intel_encoder,
672 SDVO_CMD_GET_INPUT_TIMINGS_PART1, dtd); 673 SDVO_CMD_GET_INPUT_TIMINGS_PART1, dtd);
673} 674}
674 675
675static bool intel_sdvo_get_output_timing(struct intel_output *intel_output, 676static bool intel_sdvo_get_output_timing(struct intel_encoder *intel_encoder,
676 struct intel_sdvo_dtd *dtd) 677 struct intel_sdvo_dtd *dtd)
677{ 678{
678 return intel_sdvo_get_timing(intel_output, 679 return intel_sdvo_get_timing(intel_encoder,
679 SDVO_CMD_GET_OUTPUT_TIMINGS_PART1, dtd); 680 SDVO_CMD_GET_OUTPUT_TIMINGS_PART1, dtd);
680} 681}
681 682
682static bool intel_sdvo_set_timing(struct intel_output *intel_output, u8 cmd, 683static bool intel_sdvo_set_timing(struct intel_encoder *intel_encoder, u8 cmd,
683 struct intel_sdvo_dtd *dtd) 684 struct intel_sdvo_dtd *dtd)
684{ 685{
685 u8 status; 686 u8 status;
686 687
687 intel_sdvo_write_cmd(intel_output, cmd, &dtd->part1, sizeof(dtd->part1)); 688 intel_sdvo_write_cmd(intel_encoder, cmd, &dtd->part1, sizeof(dtd->part1));
688 status = intel_sdvo_read_response(intel_output, NULL, 0); 689 status = intel_sdvo_read_response(intel_encoder, NULL, 0);
689 if (status != SDVO_CMD_STATUS_SUCCESS) 690 if (status != SDVO_CMD_STATUS_SUCCESS)
690 return false; 691 return false;
691 692
692 intel_sdvo_write_cmd(intel_output, cmd + 1, &dtd->part2, sizeof(dtd->part2)); 693 intel_sdvo_write_cmd(intel_encoder, cmd + 1, &dtd->part2, sizeof(dtd->part2));
693 status = intel_sdvo_read_response(intel_output, NULL, 0); 694 status = intel_sdvo_read_response(intel_encoder, NULL, 0);
694 if (status != SDVO_CMD_STATUS_SUCCESS) 695 if (status != SDVO_CMD_STATUS_SUCCESS)
695 return false; 696 return false;
696 697
697 return true; 698 return true;
698} 699}
699 700
700static bool intel_sdvo_set_input_timing(struct intel_output *intel_output, 701static bool intel_sdvo_set_input_timing(struct intel_encoder *intel_encoder,
701 struct intel_sdvo_dtd *dtd) 702 struct intel_sdvo_dtd *dtd)
702{ 703{
703 return intel_sdvo_set_timing(intel_output, 704 return intel_sdvo_set_timing(intel_encoder,
704 SDVO_CMD_SET_INPUT_TIMINGS_PART1, dtd); 705 SDVO_CMD_SET_INPUT_TIMINGS_PART1, dtd);
705} 706}
706 707
707static bool intel_sdvo_set_output_timing(struct intel_output *intel_output, 708static bool intel_sdvo_set_output_timing(struct intel_encoder *intel_encoder,
708 struct intel_sdvo_dtd *dtd) 709 struct intel_sdvo_dtd *dtd)
709{ 710{
710 return intel_sdvo_set_timing(intel_output, 711 return intel_sdvo_set_timing(intel_encoder,
711 SDVO_CMD_SET_OUTPUT_TIMINGS_PART1, dtd); 712 SDVO_CMD_SET_OUTPUT_TIMINGS_PART1, dtd);
712} 713}
713 714
714static bool 715static bool
715intel_sdvo_create_preferred_input_timing(struct intel_output *output, 716intel_sdvo_create_preferred_input_timing(struct intel_encoder *intel_encoder,
716 uint16_t clock, 717 uint16_t clock,
717 uint16_t width, 718 uint16_t width,
718 uint16_t height) 719 uint16_t height)
719{ 720{
720 struct intel_sdvo_preferred_input_timing_args args; 721 struct intel_sdvo_preferred_input_timing_args args;
721 struct intel_sdvo_priv *sdvo_priv = output->dev_priv; 722 struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv;
722 uint8_t status; 723 uint8_t status;
723 724
724 memset(&args, 0, sizeof(args)); 725 memset(&args, 0, sizeof(args));
@@ -732,32 +733,33 @@ intel_sdvo_create_preferred_input_timing(struct intel_output *output,
732 sdvo_priv->sdvo_lvds_fixed_mode->vdisplay != height)) 733 sdvo_priv->sdvo_lvds_fixed_mode->vdisplay != height))
733 args.scaled = 1; 734 args.scaled = 1;
734 735
735 intel_sdvo_write_cmd(output, SDVO_CMD_CREATE_PREFERRED_INPUT_TIMING, 736 intel_sdvo_write_cmd(intel_encoder,
737 SDVO_CMD_CREATE_PREFERRED_INPUT_TIMING,
736 &args, sizeof(args)); 738 &args, sizeof(args));
737 status = intel_sdvo_read_response(output, NULL, 0); 739 status = intel_sdvo_read_response(intel_encoder, NULL, 0);
738 if (status != SDVO_CMD_STATUS_SUCCESS) 740 if (status != SDVO_CMD_STATUS_SUCCESS)
739 return false; 741 return false;
740 742
741 return true; 743 return true;
742} 744}
743 745
744static bool intel_sdvo_get_preferred_input_timing(struct intel_output *output, 746static bool intel_sdvo_get_preferred_input_timing(struct intel_encoder *intel_encoder,
745 struct intel_sdvo_dtd *dtd) 747 struct intel_sdvo_dtd *dtd)
746{ 748{
747 bool status; 749 bool status;
748 750
749 intel_sdvo_write_cmd(output, SDVO_CMD_GET_PREFERRED_INPUT_TIMING_PART1, 751 intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_GET_PREFERRED_INPUT_TIMING_PART1,
750 NULL, 0); 752 NULL, 0);
751 753
752 status = intel_sdvo_read_response(output, &dtd->part1, 754 status = intel_sdvo_read_response(intel_encoder, &dtd->part1,
753 sizeof(dtd->part1)); 755 sizeof(dtd->part1));
754 if (status != SDVO_CMD_STATUS_SUCCESS) 756 if (status != SDVO_CMD_STATUS_SUCCESS)
755 return false; 757 return false;
756 758
757 intel_sdvo_write_cmd(output, SDVO_CMD_GET_PREFERRED_INPUT_TIMING_PART2, 759 intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_GET_PREFERRED_INPUT_TIMING_PART2,
758 NULL, 0); 760 NULL, 0);
759 761
760 status = intel_sdvo_read_response(output, &dtd->part2, 762 status = intel_sdvo_read_response(intel_encoder, &dtd->part2,
761 sizeof(dtd->part2)); 763 sizeof(dtd->part2));
762 if (status != SDVO_CMD_STATUS_SUCCESS) 764 if (status != SDVO_CMD_STATUS_SUCCESS)
763 return false; 765 return false;
@@ -765,12 +767,12 @@ static bool intel_sdvo_get_preferred_input_timing(struct intel_output *output,
765 return false; 767 return false;
766} 768}
767 769
768static int intel_sdvo_get_clock_rate_mult(struct intel_output *intel_output) 770static int intel_sdvo_get_clock_rate_mult(struct intel_encoder *intel_encoder)
769{ 771{
770 u8 response, status; 772 u8 response, status;
771 773
772 intel_sdvo_write_cmd(intel_output, SDVO_CMD_GET_CLOCK_RATE_MULT, NULL, 0); 774 intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_GET_CLOCK_RATE_MULT, NULL, 0);
773 status = intel_sdvo_read_response(intel_output, &response, 1); 775 status = intel_sdvo_read_response(intel_encoder, &response, 1);
774 776
775 if (status != SDVO_CMD_STATUS_SUCCESS) { 777 if (status != SDVO_CMD_STATUS_SUCCESS) {
776 DRM_DEBUG_KMS("Couldn't get SDVO clock rate multiplier\n"); 778 DRM_DEBUG_KMS("Couldn't get SDVO clock rate multiplier\n");
@@ -782,12 +784,12 @@ static int intel_sdvo_get_clock_rate_mult(struct intel_output *intel_output)
782 return response; 784 return response;
783} 785}
784 786
785static bool intel_sdvo_set_clock_rate_mult(struct intel_output *intel_output, u8 val) 787static bool intel_sdvo_set_clock_rate_mult(struct intel_encoder *intel_encoder, u8 val)
786{ 788{
787 u8 status; 789 u8 status;
788 790
789 intel_sdvo_write_cmd(intel_output, SDVO_CMD_SET_CLOCK_RATE_MULT, &val, 1); 791 intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_SET_CLOCK_RATE_MULT, &val, 1);
790 status = intel_sdvo_read_response(intel_output, NULL, 0); 792 status = intel_sdvo_read_response(intel_encoder, NULL, 0);
791 if (status != SDVO_CMD_STATUS_SUCCESS) 793 if (status != SDVO_CMD_STATUS_SUCCESS)
792 return false; 794 return false;
793 795
@@ -876,13 +878,13 @@ static void intel_sdvo_get_mode_from_dtd(struct drm_display_mode * mode,
876 mode->flags |= DRM_MODE_FLAG_PVSYNC; 878 mode->flags |= DRM_MODE_FLAG_PVSYNC;
877} 879}
878 880
879static bool intel_sdvo_get_supp_encode(struct intel_output *output, 881static bool intel_sdvo_get_supp_encode(struct intel_encoder *intel_encoder,
880 struct intel_sdvo_encode *encode) 882 struct intel_sdvo_encode *encode)
881{ 883{
882 uint8_t status; 884 uint8_t status;
883 885
884 intel_sdvo_write_cmd(output, SDVO_CMD_GET_SUPP_ENCODE, NULL, 0); 886 intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_GET_SUPP_ENCODE, NULL, 0);
885 status = intel_sdvo_read_response(output, encode, sizeof(*encode)); 887 status = intel_sdvo_read_response(intel_encoder, encode, sizeof(*encode));
886 if (status != SDVO_CMD_STATUS_SUCCESS) { /* non-support means DVI */ 888 if (status != SDVO_CMD_STATUS_SUCCESS) { /* non-support means DVI */
887 memset(encode, 0, sizeof(*encode)); 889 memset(encode, 0, sizeof(*encode));
888 return false; 890 return false;
@@ -891,29 +893,30 @@ static bool intel_sdvo_get_supp_encode(struct intel_output *output,
891 return true; 893 return true;
892} 894}
893 895
894static bool intel_sdvo_set_encode(struct intel_output *output, uint8_t mode) 896static bool intel_sdvo_set_encode(struct intel_encoder *intel_encoder,
897 uint8_t mode)
895{ 898{
896 uint8_t status; 899 uint8_t status;
897 900
898 intel_sdvo_write_cmd(output, SDVO_CMD_SET_ENCODE, &mode, 1); 901 intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_SET_ENCODE, &mode, 1);
899 status = intel_sdvo_read_response(output, NULL, 0); 902 status = intel_sdvo_read_response(intel_encoder, NULL, 0);
900 903
901 return (status == SDVO_CMD_STATUS_SUCCESS); 904 return (status == SDVO_CMD_STATUS_SUCCESS);
902} 905}
903 906
904static bool intel_sdvo_set_colorimetry(struct intel_output *output, 907static bool intel_sdvo_set_colorimetry(struct intel_encoder *intel_encoder,
905 uint8_t mode) 908 uint8_t mode)
906{ 909{
907 uint8_t status; 910 uint8_t status;
908 911
909 intel_sdvo_write_cmd(output, SDVO_CMD_SET_COLORIMETRY, &mode, 1); 912 intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_SET_COLORIMETRY, &mode, 1);
910 status = intel_sdvo_read_response(output, NULL, 0); 913 status = intel_sdvo_read_response(intel_encoder, NULL, 0);
911 914
912 return (status == SDVO_CMD_STATUS_SUCCESS); 915 return (status == SDVO_CMD_STATUS_SUCCESS);
913} 916}
914 917
915#if 0 918#if 0
916static void intel_sdvo_dump_hdmi_buf(struct intel_output *output) 919static void intel_sdvo_dump_hdmi_buf(struct intel_encoder *intel_encoder)
917{ 920{
918 int i, j; 921 int i, j;
919 uint8_t set_buf_index[2]; 922 uint8_t set_buf_index[2];
@@ -922,43 +925,45 @@ static void intel_sdvo_dump_hdmi_buf(struct intel_output *output)
922 uint8_t buf[48]; 925 uint8_t buf[48];
923 uint8_t *pos; 926 uint8_t *pos;
924 927
925 intel_sdvo_write_cmd(output, SDVO_CMD_GET_HBUF_AV_SPLIT, NULL, 0); 928 intel_sdvo_write_cmd(encoder, SDVO_CMD_GET_HBUF_AV_SPLIT, NULL, 0);
926 intel_sdvo_read_response(output, &av_split, 1); 929 intel_sdvo_read_response(encoder, &av_split, 1);
927 930
928 for (i = 0; i <= av_split; i++) { 931 for (i = 0; i <= av_split; i++) {
929 set_buf_index[0] = i; set_buf_index[1] = 0; 932 set_buf_index[0] = i; set_buf_index[1] = 0;
930 intel_sdvo_write_cmd(output, SDVO_CMD_SET_HBUF_INDEX, 933 intel_sdvo_write_cmd(encoder, SDVO_CMD_SET_HBUF_INDEX,
931 set_buf_index, 2); 934 set_buf_index, 2);
932 intel_sdvo_write_cmd(output, SDVO_CMD_GET_HBUF_INFO, NULL, 0); 935 intel_sdvo_write_cmd(encoder, SDVO_CMD_GET_HBUF_INFO, NULL, 0);
933 intel_sdvo_read_response(output, &buf_size, 1); 936 intel_sdvo_read_response(encoder, &buf_size, 1);
934 937
935 pos = buf; 938 pos = buf;
936 for (j = 0; j <= buf_size; j += 8) { 939 for (j = 0; j <= buf_size; j += 8) {
937 intel_sdvo_write_cmd(output, SDVO_CMD_GET_HBUF_DATA, 940 intel_sdvo_write_cmd(encoder, SDVO_CMD_GET_HBUF_DATA,
938 NULL, 0); 941 NULL, 0);
939 intel_sdvo_read_response(output, pos, 8); 942 intel_sdvo_read_response(encoder, pos, 8);
940 pos += 8; 943 pos += 8;
941 } 944 }
942 } 945 }
943} 946}
944#endif 947#endif
945 948
946static void intel_sdvo_set_hdmi_buf(struct intel_output *output, int index, 949static void intel_sdvo_set_hdmi_buf(struct intel_encoder *intel_encoder,
947 uint8_t *data, int8_t size, uint8_t tx_rate) 950 int index,
951 uint8_t *data, int8_t size, uint8_t tx_rate)
948{ 952{
949 uint8_t set_buf_index[2]; 953 uint8_t set_buf_index[2];
950 954
951 set_buf_index[0] = index; 955 set_buf_index[0] = index;
952 set_buf_index[1] = 0; 956 set_buf_index[1] = 0;
953 957
954 intel_sdvo_write_cmd(output, SDVO_CMD_SET_HBUF_INDEX, set_buf_index, 2); 958 intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_SET_HBUF_INDEX,
959 set_buf_index, 2);
955 960
956 for (; size > 0; size -= 8) { 961 for (; size > 0; size -= 8) {
957 intel_sdvo_write_cmd(output, SDVO_CMD_SET_HBUF_DATA, data, 8); 962 intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_SET_HBUF_DATA, data, 8);
958 data += 8; 963 data += 8;
959 } 964 }
960 965
961 intel_sdvo_write_cmd(output, SDVO_CMD_SET_HBUF_TXRATE, &tx_rate, 1); 966 intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_SET_HBUF_TXRATE, &tx_rate, 1);
962} 967}
963 968
964static uint8_t intel_sdvo_calc_hbuf_csum(uint8_t *data, uint8_t size) 969static uint8_t intel_sdvo_calc_hbuf_csum(uint8_t *data, uint8_t size)
@@ -1033,7 +1038,7 @@ struct dip_infoframe {
1033 } __attribute__ ((packed)) u; 1038 } __attribute__ ((packed)) u;
1034} __attribute__((packed)); 1039} __attribute__((packed));
1035 1040
1036static void intel_sdvo_set_avi_infoframe(struct intel_output *output, 1041static void intel_sdvo_set_avi_infoframe(struct intel_encoder *intel_encoder,
1037 struct drm_display_mode * mode) 1042 struct drm_display_mode * mode)
1038{ 1043{
1039 struct dip_infoframe avi_if = { 1044 struct dip_infoframe avi_if = {
@@ -1044,15 +1049,16 @@ static void intel_sdvo_set_avi_infoframe(struct intel_output *output,
1044 1049
1045 avi_if.checksum = intel_sdvo_calc_hbuf_csum((uint8_t *)&avi_if, 1050 avi_if.checksum = intel_sdvo_calc_hbuf_csum((uint8_t *)&avi_if,
1046 4 + avi_if.len); 1051 4 + avi_if.len);
1047 intel_sdvo_set_hdmi_buf(output, 1, (uint8_t *)&avi_if, 4 + avi_if.len, 1052 intel_sdvo_set_hdmi_buf(intel_encoder, 1, (uint8_t *)&avi_if,
1053 4 + avi_if.len,
1048 SDVO_HBUF_TX_VSYNC); 1054 SDVO_HBUF_TX_VSYNC);
1049} 1055}
1050 1056
1051static void intel_sdvo_set_tv_format(struct intel_output *output) 1057static void intel_sdvo_set_tv_format(struct intel_encoder *intel_encoder)
1052{ 1058{
1053 1059
1054 struct intel_sdvo_tv_format format; 1060 struct intel_sdvo_tv_format format;
1055 struct intel_sdvo_priv *sdvo_priv = output->dev_priv; 1061 struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv;
1056 uint32_t format_map, i; 1062 uint32_t format_map, i;
1057 uint8_t status; 1063 uint8_t status;
1058 1064
@@ -1065,10 +1071,10 @@ static void intel_sdvo_set_tv_format(struct intel_output *output)
1065 memcpy(&format, &format_map, sizeof(format_map) > sizeof(format) ? 1071 memcpy(&format, &format_map, sizeof(format_map) > sizeof(format) ?
1066 sizeof(format) : sizeof(format_map)); 1072 sizeof(format) : sizeof(format_map));
1067 1073
1068 intel_sdvo_write_cmd(output, SDVO_CMD_SET_TV_FORMAT, &format_map, 1074 intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_SET_TV_FORMAT, &format_map,
1069 sizeof(format)); 1075 sizeof(format));
1070 1076
1071 status = intel_sdvo_read_response(output, NULL, 0); 1077 status = intel_sdvo_read_response(intel_encoder, NULL, 0);
1072 if (status != SDVO_CMD_STATUS_SUCCESS) 1078 if (status != SDVO_CMD_STATUS_SUCCESS)
1073 DRM_DEBUG_KMS("%s: Failed to set TV format\n", 1079 DRM_DEBUG_KMS("%s: Failed to set TV format\n",
1074 SDVO_NAME(sdvo_priv)); 1080 SDVO_NAME(sdvo_priv));
@@ -1078,8 +1084,8 @@ static bool intel_sdvo_mode_fixup(struct drm_encoder *encoder,
1078 struct drm_display_mode *mode, 1084 struct drm_display_mode *mode,
1079 struct drm_display_mode *adjusted_mode) 1085 struct drm_display_mode *adjusted_mode)
1080{ 1086{
1081 struct intel_output *output = enc_to_intel_output(encoder); 1087 struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder);
1082 struct intel_sdvo_priv *dev_priv = output->dev_priv; 1088 struct intel_sdvo_priv *dev_priv = intel_encoder->dev_priv;
1083 1089
1084 if (dev_priv->is_tv) { 1090 if (dev_priv->is_tv) {
1085 struct intel_sdvo_dtd output_dtd; 1091 struct intel_sdvo_dtd output_dtd;
@@ -1094,22 +1100,22 @@ static bool intel_sdvo_mode_fixup(struct drm_encoder *encoder,
1094 1100
1095 /* Set output timings */ 1101 /* Set output timings */
1096 intel_sdvo_get_dtd_from_mode(&output_dtd, mode); 1102 intel_sdvo_get_dtd_from_mode(&output_dtd, mode);
1097 intel_sdvo_set_target_output(output, 1103 intel_sdvo_set_target_output(intel_encoder,
1098 dev_priv->controlled_output); 1104 dev_priv->controlled_output);
1099 intel_sdvo_set_output_timing(output, &output_dtd); 1105 intel_sdvo_set_output_timing(intel_encoder, &output_dtd);
1100 1106
1101 /* Set the input timing to the screen. Assume always input 0. */ 1107 /* Set the input timing to the screen. Assume always input 0. */
1102 intel_sdvo_set_target_input(output, true, false); 1108 intel_sdvo_set_target_input(intel_encoder, true, false);
1103 1109
1104 1110
1105 success = intel_sdvo_create_preferred_input_timing(output, 1111 success = intel_sdvo_create_preferred_input_timing(intel_encoder,
1106 mode->clock / 10, 1112 mode->clock / 10,
1107 mode->hdisplay, 1113 mode->hdisplay,
1108 mode->vdisplay); 1114 mode->vdisplay);
1109 if (success) { 1115 if (success) {
1110 struct intel_sdvo_dtd input_dtd; 1116 struct intel_sdvo_dtd input_dtd;
1111 1117
1112 intel_sdvo_get_preferred_input_timing(output, 1118 intel_sdvo_get_preferred_input_timing(intel_encoder,
1113 &input_dtd); 1119 &input_dtd);
1114 intel_sdvo_get_mode_from_dtd(adjusted_mode, &input_dtd); 1120 intel_sdvo_get_mode_from_dtd(adjusted_mode, &input_dtd);
1115 dev_priv->sdvo_flags = input_dtd.part2.sdvo_flags; 1121 dev_priv->sdvo_flags = input_dtd.part2.sdvo_flags;
@@ -1132,16 +1138,16 @@ static bool intel_sdvo_mode_fixup(struct drm_encoder *encoder,
1132 intel_sdvo_get_dtd_from_mode(&output_dtd, 1138 intel_sdvo_get_dtd_from_mode(&output_dtd,
1133 dev_priv->sdvo_lvds_fixed_mode); 1139 dev_priv->sdvo_lvds_fixed_mode);
1134 1140
1135 intel_sdvo_set_target_output(output, 1141 intel_sdvo_set_target_output(intel_encoder,
1136 dev_priv->controlled_output); 1142 dev_priv->controlled_output);
1137 intel_sdvo_set_output_timing(output, &output_dtd); 1143 intel_sdvo_set_output_timing(intel_encoder, &output_dtd);
1138 1144
1139 /* Set the input timing to the screen. Assume always input 0. */ 1145 /* Set the input timing to the screen. Assume always input 0. */
1140 intel_sdvo_set_target_input(output, true, false); 1146 intel_sdvo_set_target_input(intel_encoder, true, false);
1141 1147
1142 1148
1143 success = intel_sdvo_create_preferred_input_timing( 1149 success = intel_sdvo_create_preferred_input_timing(
1144 output, 1150 intel_encoder,
1145 mode->clock / 10, 1151 mode->clock / 10,
1146 mode->hdisplay, 1152 mode->hdisplay,
1147 mode->vdisplay); 1153 mode->vdisplay);
@@ -1149,7 +1155,7 @@ static bool intel_sdvo_mode_fixup(struct drm_encoder *encoder,
1149 if (success) { 1155 if (success) {
1150 struct intel_sdvo_dtd input_dtd; 1156 struct intel_sdvo_dtd input_dtd;
1151 1157
1152 intel_sdvo_get_preferred_input_timing(output, 1158 intel_sdvo_get_preferred_input_timing(intel_encoder,
1153 &input_dtd); 1159 &input_dtd);
1154 intel_sdvo_get_mode_from_dtd(adjusted_mode, &input_dtd); 1160 intel_sdvo_get_mode_from_dtd(adjusted_mode, &input_dtd);
1155 dev_priv->sdvo_flags = input_dtd.part2.sdvo_flags; 1161 dev_priv->sdvo_flags = input_dtd.part2.sdvo_flags;
@@ -1181,8 +1187,8 @@ static void intel_sdvo_mode_set(struct drm_encoder *encoder,
1181 struct drm_i915_private *dev_priv = dev->dev_private; 1187 struct drm_i915_private *dev_priv = dev->dev_private;
1182 struct drm_crtc *crtc = encoder->crtc; 1188 struct drm_crtc *crtc = encoder->crtc;
1183 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 1189 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
1184 struct intel_output *output = enc_to_intel_output(encoder); 1190 struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder);
1185 struct intel_sdvo_priv *sdvo_priv = output->dev_priv; 1191 struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv;
1186 u32 sdvox = 0; 1192 u32 sdvox = 0;
1187 int sdvo_pixel_multiply; 1193 int sdvo_pixel_multiply;
1188 struct intel_sdvo_in_out_map in_out; 1194 struct intel_sdvo_in_out_map in_out;
@@ -1201,12 +1207,12 @@ static void intel_sdvo_mode_set(struct drm_encoder *encoder,
1201 in_out.in0 = sdvo_priv->controlled_output; 1207 in_out.in0 = sdvo_priv->controlled_output;
1202 in_out.in1 = 0; 1208 in_out.in1 = 0;
1203 1209
1204 intel_sdvo_write_cmd(output, SDVO_CMD_SET_IN_OUT_MAP, 1210 intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_SET_IN_OUT_MAP,
1205 &in_out, sizeof(in_out)); 1211 &in_out, sizeof(in_out));
1206 status = intel_sdvo_read_response(output, NULL, 0); 1212 status = intel_sdvo_read_response(intel_encoder, NULL, 0);
1207 1213
1208 if (sdvo_priv->is_hdmi) { 1214 if (sdvo_priv->is_hdmi) {
1209 intel_sdvo_set_avi_infoframe(output, mode); 1215 intel_sdvo_set_avi_infoframe(intel_encoder, mode);
1210 sdvox |= SDVO_AUDIO_ENABLE; 1216 sdvox |= SDVO_AUDIO_ENABLE;
1211 } 1217 }
1212 1218
@@ -1223,16 +1229,16 @@ static void intel_sdvo_mode_set(struct drm_encoder *encoder,
1223 */ 1229 */
1224 if (!sdvo_priv->is_tv && !sdvo_priv->is_lvds) { 1230 if (!sdvo_priv->is_tv && !sdvo_priv->is_lvds) {
1225 /* Set the output timing to the screen */ 1231 /* Set the output timing to the screen */
1226 intel_sdvo_set_target_output(output, 1232 intel_sdvo_set_target_output(intel_encoder,
1227 sdvo_priv->controlled_output); 1233 sdvo_priv->controlled_output);
1228 intel_sdvo_set_output_timing(output, &input_dtd); 1234 intel_sdvo_set_output_timing(intel_encoder, &input_dtd);
1229 } 1235 }
1230 1236
1231 /* Set the input timing to the screen. Assume always input 0. */ 1237 /* Set the input timing to the screen. Assume always input 0. */
1232 intel_sdvo_set_target_input(output, true, false); 1238 intel_sdvo_set_target_input(intel_encoder, true, false);
1233 1239
1234 if (sdvo_priv->is_tv) 1240 if (sdvo_priv->is_tv)
1235 intel_sdvo_set_tv_format(output); 1241 intel_sdvo_set_tv_format(intel_encoder);
1236 1242
1237 /* We would like to use intel_sdvo_create_preferred_input_timing() to 1243 /* We would like to use intel_sdvo_create_preferred_input_timing() to
1238 * provide the device with a timing it can support, if it supports that 1244 * provide the device with a timing it can support, if it supports that
@@ -1240,29 +1246,29 @@ static void intel_sdvo_mode_set(struct drm_encoder *encoder,
1240 * output the preferred timing, and we don't support that currently. 1246 * output the preferred timing, and we don't support that currently.
1241 */ 1247 */
1242#if 0 1248#if 0
1243 success = intel_sdvo_create_preferred_input_timing(output, clock, 1249 success = intel_sdvo_create_preferred_input_timing(encoder, clock,
1244 width, height); 1250 width, height);
1245 if (success) { 1251 if (success) {
1246 struct intel_sdvo_dtd *input_dtd; 1252 struct intel_sdvo_dtd *input_dtd;
1247 1253
1248 intel_sdvo_get_preferred_input_timing(output, &input_dtd); 1254 intel_sdvo_get_preferred_input_timing(encoder, &input_dtd);
1249 intel_sdvo_set_input_timing(output, &input_dtd); 1255 intel_sdvo_set_input_timing(encoder, &input_dtd);
1250 } 1256 }
1251#else 1257#else
1252 intel_sdvo_set_input_timing(output, &input_dtd); 1258 intel_sdvo_set_input_timing(intel_encoder, &input_dtd);
1253#endif 1259#endif
1254 1260
1255 switch (intel_sdvo_get_pixel_multiplier(mode)) { 1261 switch (intel_sdvo_get_pixel_multiplier(mode)) {
1256 case 1: 1262 case 1:
1257 intel_sdvo_set_clock_rate_mult(output, 1263 intel_sdvo_set_clock_rate_mult(intel_encoder,
1258 SDVO_CLOCK_RATE_MULT_1X); 1264 SDVO_CLOCK_RATE_MULT_1X);
1259 break; 1265 break;
1260 case 2: 1266 case 2:
1261 intel_sdvo_set_clock_rate_mult(output, 1267 intel_sdvo_set_clock_rate_mult(intel_encoder,
1262 SDVO_CLOCK_RATE_MULT_2X); 1268 SDVO_CLOCK_RATE_MULT_2X);
1263 break; 1269 break;
1264 case 4: 1270 case 4:
1265 intel_sdvo_set_clock_rate_mult(output, 1271 intel_sdvo_set_clock_rate_mult(intel_encoder,
1266 SDVO_CLOCK_RATE_MULT_4X); 1272 SDVO_CLOCK_RATE_MULT_4X);
1267 break; 1273 break;
1268 } 1274 }
@@ -1273,8 +1279,8 @@ static void intel_sdvo_mode_set(struct drm_encoder *encoder,
1273 SDVO_VSYNC_ACTIVE_HIGH | 1279 SDVO_VSYNC_ACTIVE_HIGH |
1274 SDVO_HSYNC_ACTIVE_HIGH; 1280 SDVO_HSYNC_ACTIVE_HIGH;
1275 } else { 1281 } else {
1276 sdvox |= I915_READ(sdvo_priv->output_device); 1282 sdvox |= I915_READ(sdvo_priv->sdvo_reg);
1277 switch (sdvo_priv->output_device) { 1283 switch (sdvo_priv->sdvo_reg) {
1278 case SDVOB: 1284 case SDVOB:
1279 sdvox &= SDVOB_PRESERVE_MASK; 1285 sdvox &= SDVOB_PRESERVE_MASK;
1280 break; 1286 break;
@@ -1298,26 +1304,26 @@ static void intel_sdvo_mode_set(struct drm_encoder *encoder,
1298 1304
1299 if (sdvo_priv->sdvo_flags & SDVO_NEED_TO_STALL) 1305 if (sdvo_priv->sdvo_flags & SDVO_NEED_TO_STALL)
1300 sdvox |= SDVO_STALL_SELECT; 1306 sdvox |= SDVO_STALL_SELECT;
1301 intel_sdvo_write_sdvox(output, sdvox); 1307 intel_sdvo_write_sdvox(intel_encoder, sdvox);
1302} 1308}
1303 1309
1304static void intel_sdvo_dpms(struct drm_encoder *encoder, int mode) 1310static void intel_sdvo_dpms(struct drm_encoder *encoder, int mode)
1305{ 1311{
1306 struct drm_device *dev = encoder->dev; 1312 struct drm_device *dev = encoder->dev;
1307 struct drm_i915_private *dev_priv = dev->dev_private; 1313 struct drm_i915_private *dev_priv = dev->dev_private;
1308 struct intel_output *intel_output = enc_to_intel_output(encoder); 1314 struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder);
1309 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; 1315 struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv;
1310 u32 temp; 1316 u32 temp;
1311 1317
1312 if (mode != DRM_MODE_DPMS_ON) { 1318 if (mode != DRM_MODE_DPMS_ON) {
1313 intel_sdvo_set_active_outputs(intel_output, 0); 1319 intel_sdvo_set_active_outputs(intel_encoder, 0);
1314 if (0) 1320 if (0)
1315 intel_sdvo_set_encoder_power_state(intel_output, mode); 1321 intel_sdvo_set_encoder_power_state(intel_encoder, mode);
1316 1322
1317 if (mode == DRM_MODE_DPMS_OFF) { 1323 if (mode == DRM_MODE_DPMS_OFF) {
1318 temp = I915_READ(sdvo_priv->output_device); 1324 temp = I915_READ(sdvo_priv->sdvo_reg);
1319 if ((temp & SDVO_ENABLE) != 0) { 1325 if ((temp & SDVO_ENABLE) != 0) {
1320 intel_sdvo_write_sdvox(intel_output, temp & ~SDVO_ENABLE); 1326 intel_sdvo_write_sdvox(intel_encoder, temp & ~SDVO_ENABLE);
1321 } 1327 }
1322 } 1328 }
1323 } else { 1329 } else {
@@ -1325,13 +1331,13 @@ static void intel_sdvo_dpms(struct drm_encoder *encoder, int mode)
1325 int i; 1331 int i;
1326 u8 status; 1332 u8 status;
1327 1333
1328 temp = I915_READ(sdvo_priv->output_device); 1334 temp = I915_READ(sdvo_priv->sdvo_reg);
1329 if ((temp & SDVO_ENABLE) == 0) 1335 if ((temp & SDVO_ENABLE) == 0)
1330 intel_sdvo_write_sdvox(intel_output, temp | SDVO_ENABLE); 1336 intel_sdvo_write_sdvox(intel_encoder, temp | SDVO_ENABLE);
1331 for (i = 0; i < 2; i++) 1337 for (i = 0; i < 2; i++)
1332 intel_wait_for_vblank(dev); 1338 intel_wait_for_vblank(dev);
1333 1339
1334 status = intel_sdvo_get_trained_inputs(intel_output, &input1, 1340 status = intel_sdvo_get_trained_inputs(intel_encoder, &input1,
1335 &input2); 1341 &input2);
1336 1342
1337 1343
@@ -1345,8 +1351,8 @@ static void intel_sdvo_dpms(struct drm_encoder *encoder, int mode)
1345 } 1351 }
1346 1352
1347 if (0) 1353 if (0)
1348 intel_sdvo_set_encoder_power_state(intel_output, mode); 1354 intel_sdvo_set_encoder_power_state(intel_encoder, mode);
1349 intel_sdvo_set_active_outputs(intel_output, sdvo_priv->controlled_output); 1355 intel_sdvo_set_active_outputs(intel_encoder, sdvo_priv->controlled_output);
1350 } 1356 }
1351 return; 1357 return;
1352} 1358}
@@ -1355,22 +1361,22 @@ static void intel_sdvo_save(struct drm_connector *connector)
1355{ 1361{
1356 struct drm_device *dev = connector->dev; 1362 struct drm_device *dev = connector->dev;
1357 struct drm_i915_private *dev_priv = dev->dev_private; 1363 struct drm_i915_private *dev_priv = dev->dev_private;
1358 struct intel_output *intel_output = to_intel_output(connector); 1364 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
1359 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; 1365 struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv;
1360 int o; 1366 int o;
1361 1367
1362 sdvo_priv->save_sdvo_mult = intel_sdvo_get_clock_rate_mult(intel_output); 1368 sdvo_priv->save_sdvo_mult = intel_sdvo_get_clock_rate_mult(intel_encoder);
1363 intel_sdvo_get_active_outputs(intel_output, &sdvo_priv->save_active_outputs); 1369 intel_sdvo_get_active_outputs(intel_encoder, &sdvo_priv->save_active_outputs);
1364 1370
1365 if (sdvo_priv->caps.sdvo_inputs_mask & 0x1) { 1371 if (sdvo_priv->caps.sdvo_inputs_mask & 0x1) {
1366 intel_sdvo_set_target_input(intel_output, true, false); 1372 intel_sdvo_set_target_input(intel_encoder, true, false);
1367 intel_sdvo_get_input_timing(intel_output, 1373 intel_sdvo_get_input_timing(intel_encoder,
1368 &sdvo_priv->save_input_dtd_1); 1374 &sdvo_priv->save_input_dtd_1);
1369 } 1375 }
1370 1376
1371 if (sdvo_priv->caps.sdvo_inputs_mask & 0x2) { 1377 if (sdvo_priv->caps.sdvo_inputs_mask & 0x2) {
1372 intel_sdvo_set_target_input(intel_output, false, true); 1378 intel_sdvo_set_target_input(intel_encoder, false, true);
1373 intel_sdvo_get_input_timing(intel_output, 1379 intel_sdvo_get_input_timing(intel_encoder,
1374 &sdvo_priv->save_input_dtd_2); 1380 &sdvo_priv->save_input_dtd_2);
1375 } 1381 }
1376 1382
@@ -1379,8 +1385,8 @@ static void intel_sdvo_save(struct drm_connector *connector)
1379 u16 this_output = (1 << o); 1385 u16 this_output = (1 << o);
1380 if (sdvo_priv->caps.output_flags & this_output) 1386 if (sdvo_priv->caps.output_flags & this_output)
1381 { 1387 {
1382 intel_sdvo_set_target_output(intel_output, this_output); 1388 intel_sdvo_set_target_output(intel_encoder, this_output);
1383 intel_sdvo_get_output_timing(intel_output, 1389 intel_sdvo_get_output_timing(intel_encoder,
1384 &sdvo_priv->save_output_dtd[o]); 1390 &sdvo_priv->save_output_dtd[o]);
1385 } 1391 }
1386 } 1392 }
@@ -1388,66 +1394,66 @@ static void intel_sdvo_save(struct drm_connector *connector)
1388 /* XXX: Save TV format/enhancements. */ 1394 /* XXX: Save TV format/enhancements. */
1389 } 1395 }
1390 1396
1391 sdvo_priv->save_SDVOX = I915_READ(sdvo_priv->output_device); 1397 sdvo_priv->save_SDVOX = I915_READ(sdvo_priv->sdvo_reg);
1392} 1398}
1393 1399
1394static void intel_sdvo_restore(struct drm_connector *connector) 1400static void intel_sdvo_restore(struct drm_connector *connector)
1395{ 1401{
1396 struct drm_device *dev = connector->dev; 1402 struct drm_device *dev = connector->dev;
1397 struct intel_output *intel_output = to_intel_output(connector); 1403 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
1398 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; 1404 struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv;
1399 int o; 1405 int o;
1400 int i; 1406 int i;
1401 bool input1, input2; 1407 bool input1, input2;
1402 u8 status; 1408 u8 status;
1403 1409
1404 intel_sdvo_set_active_outputs(intel_output, 0); 1410 intel_sdvo_set_active_outputs(intel_encoder, 0);
1405 1411
1406 for (o = SDVO_OUTPUT_FIRST; o <= SDVO_OUTPUT_LAST; o++) 1412 for (o = SDVO_OUTPUT_FIRST; o <= SDVO_OUTPUT_LAST; o++)
1407 { 1413 {
1408 u16 this_output = (1 << o); 1414 u16 this_output = (1 << o);
1409 if (sdvo_priv->caps.output_flags & this_output) { 1415 if (sdvo_priv->caps.output_flags & this_output) {
1410 intel_sdvo_set_target_output(intel_output, this_output); 1416 intel_sdvo_set_target_output(intel_encoder, this_output);
1411 intel_sdvo_set_output_timing(intel_output, &sdvo_priv->save_output_dtd[o]); 1417 intel_sdvo_set_output_timing(intel_encoder, &sdvo_priv->save_output_dtd[o]);
1412 } 1418 }
1413 } 1419 }
1414 1420
1415 if (sdvo_priv->caps.sdvo_inputs_mask & 0x1) { 1421 if (sdvo_priv->caps.sdvo_inputs_mask & 0x1) {
1416 intel_sdvo_set_target_input(intel_output, true, false); 1422 intel_sdvo_set_target_input(intel_encoder, true, false);
1417 intel_sdvo_set_input_timing(intel_output, &sdvo_priv->save_input_dtd_1); 1423 intel_sdvo_set_input_timing(intel_encoder, &sdvo_priv->save_input_dtd_1);
1418 } 1424 }
1419 1425
1420 if (sdvo_priv->caps.sdvo_inputs_mask & 0x2) { 1426 if (sdvo_priv->caps.sdvo_inputs_mask & 0x2) {
1421 intel_sdvo_set_target_input(intel_output, false, true); 1427 intel_sdvo_set_target_input(intel_encoder, false, true);
1422 intel_sdvo_set_input_timing(intel_output, &sdvo_priv->save_input_dtd_2); 1428 intel_sdvo_set_input_timing(intel_encoder, &sdvo_priv->save_input_dtd_2);
1423 } 1429 }
1424 1430
1425 intel_sdvo_set_clock_rate_mult(intel_output, sdvo_priv->save_sdvo_mult); 1431 intel_sdvo_set_clock_rate_mult(intel_encoder, sdvo_priv->save_sdvo_mult);
1426 1432
1427 if (sdvo_priv->is_tv) { 1433 if (sdvo_priv->is_tv) {
1428 /* XXX: Restore TV format/enhancements. */ 1434 /* XXX: Restore TV format/enhancements. */
1429 } 1435 }
1430 1436
1431 intel_sdvo_write_sdvox(intel_output, sdvo_priv->save_SDVOX); 1437 intel_sdvo_write_sdvox(intel_encoder, sdvo_priv->save_SDVOX);
1432 1438
1433 if (sdvo_priv->save_SDVOX & SDVO_ENABLE) 1439 if (sdvo_priv->save_SDVOX & SDVO_ENABLE)
1434 { 1440 {
1435 for (i = 0; i < 2; i++) 1441 for (i = 0; i < 2; i++)
1436 intel_wait_for_vblank(dev); 1442 intel_wait_for_vblank(dev);
1437 status = intel_sdvo_get_trained_inputs(intel_output, &input1, &input2); 1443 status = intel_sdvo_get_trained_inputs(intel_encoder, &input1, &input2);
1438 if (status == SDVO_CMD_STATUS_SUCCESS && !input1) 1444 if (status == SDVO_CMD_STATUS_SUCCESS && !input1)
1439 DRM_DEBUG_KMS("First %s output reported failure to " 1445 DRM_DEBUG_KMS("First %s output reported failure to "
1440 "sync\n", SDVO_NAME(sdvo_priv)); 1446 "sync\n", SDVO_NAME(sdvo_priv));
1441 } 1447 }
1442 1448
1443 intel_sdvo_set_active_outputs(intel_output, sdvo_priv->save_active_outputs); 1449 intel_sdvo_set_active_outputs(intel_encoder, sdvo_priv->save_active_outputs);
1444} 1450}
1445 1451
1446static int intel_sdvo_mode_valid(struct drm_connector *connector, 1452static int intel_sdvo_mode_valid(struct drm_connector *connector,
1447 struct drm_display_mode *mode) 1453 struct drm_display_mode *mode)
1448{ 1454{
1449 struct intel_output *intel_output = to_intel_output(connector); 1455 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
1450 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; 1456 struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv;
1451 1457
1452 if (mode->flags & DRM_MODE_FLAG_DBLSCAN) 1458 if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
1453 return MODE_NO_DBLESCAN; 1459 return MODE_NO_DBLESCAN;
@@ -1472,12 +1478,12 @@ static int intel_sdvo_mode_valid(struct drm_connector *connector,
1472 return MODE_OK; 1478 return MODE_OK;
1473} 1479}
1474 1480
1475static bool intel_sdvo_get_capabilities(struct intel_output *intel_output, struct intel_sdvo_caps *caps) 1481static bool intel_sdvo_get_capabilities(struct intel_encoder *intel_encoder, struct intel_sdvo_caps *caps)
1476{ 1482{
1477 u8 status; 1483 u8 status;
1478 1484
1479 intel_sdvo_write_cmd(intel_output, SDVO_CMD_GET_DEVICE_CAPS, NULL, 0); 1485 intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_GET_DEVICE_CAPS, NULL, 0);
1480 status = intel_sdvo_read_response(intel_output, caps, sizeof(*caps)); 1486 status = intel_sdvo_read_response(intel_encoder, caps, sizeof(*caps));
1481 if (status != SDVO_CMD_STATUS_SUCCESS) 1487 if (status != SDVO_CMD_STATUS_SUCCESS)
1482 return false; 1488 return false;
1483 1489
@@ -1487,22 +1493,22 @@ static bool intel_sdvo_get_capabilities(struct intel_output *intel_output, struc
1487struct drm_connector* intel_sdvo_find(struct drm_device *dev, int sdvoB) 1493struct drm_connector* intel_sdvo_find(struct drm_device *dev, int sdvoB)
1488{ 1494{
1489 struct drm_connector *connector = NULL; 1495 struct drm_connector *connector = NULL;
1490 struct intel_output *iout = NULL; 1496 struct intel_encoder *iout = NULL;
1491 struct intel_sdvo_priv *sdvo; 1497 struct intel_sdvo_priv *sdvo;
1492 1498
1493 /* find the sdvo connector */ 1499 /* find the sdvo connector */
1494 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 1500 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
1495 iout = to_intel_output(connector); 1501 iout = to_intel_encoder(connector);
1496 1502
1497 if (iout->type != INTEL_OUTPUT_SDVO) 1503 if (iout->type != INTEL_OUTPUT_SDVO)
1498 continue; 1504 continue;
1499 1505
1500 sdvo = iout->dev_priv; 1506 sdvo = iout->dev_priv;
1501 1507
1502 if (sdvo->output_device == SDVOB && sdvoB) 1508 if (sdvo->sdvo_reg == SDVOB && sdvoB)
1503 return connector; 1509 return connector;
1504 1510
1505 if (sdvo->output_device == SDVOC && !sdvoB) 1511 if (sdvo->sdvo_reg == SDVOC && !sdvoB)
1506 return connector; 1512 return connector;
1507 1513
1508 } 1514 }
@@ -1514,16 +1520,16 @@ int intel_sdvo_supports_hotplug(struct drm_connector *connector)
1514{ 1520{
1515 u8 response[2]; 1521 u8 response[2];
1516 u8 status; 1522 u8 status;
1517 struct intel_output *intel_output; 1523 struct intel_encoder *intel_encoder;
1518 DRM_DEBUG_KMS("\n"); 1524 DRM_DEBUG_KMS("\n");
1519 1525
1520 if (!connector) 1526 if (!connector)
1521 return 0; 1527 return 0;
1522 1528
1523 intel_output = to_intel_output(connector); 1529 intel_encoder = to_intel_encoder(connector);
1524 1530
1525 intel_sdvo_write_cmd(intel_output, SDVO_CMD_GET_HOT_PLUG_SUPPORT, NULL, 0); 1531 intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_GET_HOT_PLUG_SUPPORT, NULL, 0);
1526 status = intel_sdvo_read_response(intel_output, &response, 2); 1532 status = intel_sdvo_read_response(intel_encoder, &response, 2);
1527 1533
1528 if (response[0] !=0) 1534 if (response[0] !=0)
1529 return 1; 1535 return 1;
@@ -1535,30 +1541,30 @@ void intel_sdvo_set_hotplug(struct drm_connector *connector, int on)
1535{ 1541{
1536 u8 response[2]; 1542 u8 response[2];
1537 u8 status; 1543 u8 status;
1538 struct intel_output *intel_output = to_intel_output(connector); 1544 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
1539 1545
1540 intel_sdvo_write_cmd(intel_output, SDVO_CMD_GET_ACTIVE_HOT_PLUG, NULL, 0); 1546 intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_GET_ACTIVE_HOT_PLUG, NULL, 0);
1541 intel_sdvo_read_response(intel_output, &response, 2); 1547 intel_sdvo_read_response(intel_encoder, &response, 2);
1542 1548
1543 if (on) { 1549 if (on) {
1544 intel_sdvo_write_cmd(intel_output, SDVO_CMD_GET_HOT_PLUG_SUPPORT, NULL, 0); 1550 intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_GET_HOT_PLUG_SUPPORT, NULL, 0);
1545 status = intel_sdvo_read_response(intel_output, &response, 2); 1551 status = intel_sdvo_read_response(intel_encoder, &response, 2);
1546 1552
1547 intel_sdvo_write_cmd(intel_output, SDVO_CMD_SET_ACTIVE_HOT_PLUG, &response, 2); 1553 intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_SET_ACTIVE_HOT_PLUG, &response, 2);
1548 } else { 1554 } else {
1549 response[0] = 0; 1555 response[0] = 0;
1550 response[1] = 0; 1556 response[1] = 0;
1551 intel_sdvo_write_cmd(intel_output, SDVO_CMD_SET_ACTIVE_HOT_PLUG, &response, 2); 1557 intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_SET_ACTIVE_HOT_PLUG, &response, 2);
1552 } 1558 }
1553 1559
1554 intel_sdvo_write_cmd(intel_output, SDVO_CMD_GET_ACTIVE_HOT_PLUG, NULL, 0); 1560 intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_GET_ACTIVE_HOT_PLUG, NULL, 0);
1555 intel_sdvo_read_response(intel_output, &response, 2); 1561 intel_sdvo_read_response(intel_encoder, &response, 2);
1556} 1562}
1557 1563
1558static bool 1564static bool
1559intel_sdvo_multifunc_encoder(struct intel_output *intel_output) 1565intel_sdvo_multifunc_encoder(struct intel_encoder *intel_encoder)
1560{ 1566{
1561 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; 1567 struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv;
1562 int caps = 0; 1568 int caps = 0;
1563 1569
1564 if (sdvo_priv->caps.output_flags & 1570 if (sdvo_priv->caps.output_flags &
@@ -1592,11 +1598,11 @@ static struct drm_connector *
1592intel_find_analog_connector(struct drm_device *dev) 1598intel_find_analog_connector(struct drm_device *dev)
1593{ 1599{
1594 struct drm_connector *connector; 1600 struct drm_connector *connector;
1595 struct intel_output *intel_output; 1601 struct intel_encoder *intel_encoder;
1596 1602
1597 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 1603 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
1598 intel_output = to_intel_output(connector); 1604 intel_encoder = to_intel_encoder(connector);
1599 if (intel_output->type == INTEL_OUTPUT_ANALOG) 1605 if (intel_encoder->type == INTEL_OUTPUT_ANALOG)
1600 return connector; 1606 return connector;
1601 } 1607 }
1602 return NULL; 1608 return NULL;
@@ -1621,16 +1627,16 @@ intel_analog_is_connected(struct drm_device *dev)
1621enum drm_connector_status 1627enum drm_connector_status
1622intel_sdvo_hdmi_sink_detect(struct drm_connector *connector, u16 response) 1628intel_sdvo_hdmi_sink_detect(struct drm_connector *connector, u16 response)
1623{ 1629{
1624 struct intel_output *intel_output = to_intel_output(connector); 1630 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
1625 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; 1631 struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv;
1626 enum drm_connector_status status = connector_status_connected; 1632 enum drm_connector_status status = connector_status_connected;
1627 struct edid *edid = NULL; 1633 struct edid *edid = NULL;
1628 1634
1629 edid = drm_get_edid(&intel_output->base, 1635 edid = drm_get_edid(&intel_encoder->base,
1630 intel_output->ddc_bus); 1636 intel_encoder->ddc_bus);
1631 1637
1632 /* This is only applied to SDVO cards with multiple outputs */ 1638 /* This is only applied to SDVO cards with multiple outputs */
1633 if (edid == NULL && intel_sdvo_multifunc_encoder(intel_output)) { 1639 if (edid == NULL && intel_sdvo_multifunc_encoder(intel_encoder)) {
1634 uint8_t saved_ddc, temp_ddc; 1640 uint8_t saved_ddc, temp_ddc;
1635 saved_ddc = sdvo_priv->ddc_bus; 1641 saved_ddc = sdvo_priv->ddc_bus;
1636 temp_ddc = sdvo_priv->ddc_bus >> 1; 1642 temp_ddc = sdvo_priv->ddc_bus >> 1;
@@ -1640,8 +1646,8 @@ intel_sdvo_hdmi_sink_detect(struct drm_connector *connector, u16 response)
1640 */ 1646 */
1641 while(temp_ddc > 1) { 1647 while(temp_ddc > 1) {
1642 sdvo_priv->ddc_bus = temp_ddc; 1648 sdvo_priv->ddc_bus = temp_ddc;
1643 edid = drm_get_edid(&intel_output->base, 1649 edid = drm_get_edid(&intel_encoder->base,
1644 intel_output->ddc_bus); 1650 intel_encoder->ddc_bus);
1645 if (edid) { 1651 if (edid) {
1646 /* 1652 /*
1647 * When we can get the EDID, maybe it is the 1653 * When we can get the EDID, maybe it is the
@@ -1660,8 +1666,8 @@ intel_sdvo_hdmi_sink_detect(struct drm_connector *connector, u16 response)
1660 */ 1666 */
1661 if (edid == NULL && 1667 if (edid == NULL &&
1662 sdvo_priv->analog_ddc_bus && 1668 sdvo_priv->analog_ddc_bus &&
1663 !intel_analog_is_connected(intel_output->base.dev)) 1669 !intel_analog_is_connected(intel_encoder->base.dev))
1664 edid = drm_get_edid(&intel_output->base, 1670 edid = drm_get_edid(&intel_encoder->base,
1665 sdvo_priv->analog_ddc_bus); 1671 sdvo_priv->analog_ddc_bus);
1666 if (edid != NULL) { 1672 if (edid != NULL) {
1667 /* Don't report the output as connected if it's a DVI-I 1673 /* Don't report the output as connected if it's a DVI-I
@@ -1676,7 +1682,7 @@ intel_sdvo_hdmi_sink_detect(struct drm_connector *connector, u16 response)
1676 } 1682 }
1677 1683
1678 kfree(edid); 1684 kfree(edid);
1679 intel_output->base.display_info.raw_edid = NULL; 1685 intel_encoder->base.display_info.raw_edid = NULL;
1680 1686
1681 } else if (response & (SDVO_OUTPUT_TMDS0 | SDVO_OUTPUT_TMDS1)) 1687 } else if (response & (SDVO_OUTPUT_TMDS0 | SDVO_OUTPUT_TMDS1))
1682 status = connector_status_disconnected; 1688 status = connector_status_disconnected;
@@ -1688,16 +1694,16 @@ static enum drm_connector_status intel_sdvo_detect(struct drm_connector *connect
1688{ 1694{
1689 uint16_t response; 1695 uint16_t response;
1690 u8 status; 1696 u8 status;
1691 struct intel_output *intel_output = to_intel_output(connector); 1697 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
1692 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; 1698 struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv;
1693 1699
1694 intel_sdvo_write_cmd(intel_output, 1700 intel_sdvo_write_cmd(intel_encoder,
1695 SDVO_CMD_GET_ATTACHED_DISPLAYS, NULL, 0); 1701 SDVO_CMD_GET_ATTACHED_DISPLAYS, NULL, 0);
1696 if (sdvo_priv->is_tv) { 1702 if (sdvo_priv->is_tv) {
1697 /* add 30ms delay when the output type is SDVO-TV */ 1703 /* add 30ms delay when the output type is SDVO-TV */
1698 mdelay(30); 1704 mdelay(30);
1699 } 1705 }
1700 status = intel_sdvo_read_response(intel_output, &response, 2); 1706 status = intel_sdvo_read_response(intel_encoder, &response, 2);
1701 1707
1702 DRM_DEBUG_KMS("SDVO response %d %d\n", response & 0xff, response >> 8); 1708 DRM_DEBUG_KMS("SDVO response %d %d\n", response & 0xff, response >> 8);
1703 1709
@@ -1707,10 +1713,10 @@ static enum drm_connector_status intel_sdvo_detect(struct drm_connector *connect
1707 if (response == 0) 1713 if (response == 0)
1708 return connector_status_disconnected; 1714 return connector_status_disconnected;
1709 1715
1710 if (intel_sdvo_multifunc_encoder(intel_output) && 1716 if (intel_sdvo_multifunc_encoder(intel_encoder) &&
1711 sdvo_priv->attached_output != response) { 1717 sdvo_priv->attached_output != response) {
1712 if (sdvo_priv->controlled_output != response && 1718 if (sdvo_priv->controlled_output != response &&
1713 intel_sdvo_output_setup(intel_output, response) != true) 1719 intel_sdvo_output_setup(intel_encoder, response) != true)
1714 return connector_status_unknown; 1720 return connector_status_unknown;
1715 sdvo_priv->attached_output = response; 1721 sdvo_priv->attached_output = response;
1716 } 1722 }
@@ -1719,12 +1725,12 @@ static enum drm_connector_status intel_sdvo_detect(struct drm_connector *connect
1719 1725
1720static void intel_sdvo_get_ddc_modes(struct drm_connector *connector) 1726static void intel_sdvo_get_ddc_modes(struct drm_connector *connector)
1721{ 1727{
1722 struct intel_output *intel_output = to_intel_output(connector); 1728 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
1723 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; 1729 struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv;
1724 int num_modes; 1730 int num_modes;
1725 1731
1726 /* set the bus switch and get the modes */ 1732 /* set the bus switch and get the modes */
1727 num_modes = intel_ddc_get_modes(intel_output); 1733 num_modes = intel_ddc_get_modes(intel_encoder);
1728 1734
1729 /* 1735 /*
1730 * Mac mini hack. On this device, the DVI-I connector shares one DDC 1736 * Mac mini hack. On this device, the DVI-I connector shares one DDC
@@ -1734,17 +1740,17 @@ static void intel_sdvo_get_ddc_modes(struct drm_connector *connector)
1734 */ 1740 */
1735 if (num_modes == 0 && 1741 if (num_modes == 0 &&
1736 sdvo_priv->analog_ddc_bus && 1742 sdvo_priv->analog_ddc_bus &&
1737 !intel_analog_is_connected(intel_output->base.dev)) { 1743 !intel_analog_is_connected(intel_encoder->base.dev)) {
1738 struct i2c_adapter *digital_ddc_bus; 1744 struct i2c_adapter *digital_ddc_bus;
1739 1745
1740 /* Switch to the analog ddc bus and try that 1746 /* Switch to the analog ddc bus and try that
1741 */ 1747 */
1742 digital_ddc_bus = intel_output->ddc_bus; 1748 digital_ddc_bus = intel_encoder->ddc_bus;
1743 intel_output->ddc_bus = sdvo_priv->analog_ddc_bus; 1749 intel_encoder->ddc_bus = sdvo_priv->analog_ddc_bus;
1744 1750
1745 (void) intel_ddc_get_modes(intel_output); 1751 (void) intel_ddc_get_modes(intel_encoder);
1746 1752
1747 intel_output->ddc_bus = digital_ddc_bus; 1753 intel_encoder->ddc_bus = digital_ddc_bus;
1748 } 1754 }
1749} 1755}
1750 1756
@@ -1815,7 +1821,7 @@ struct drm_display_mode sdvo_tv_modes[] = {
1815 1821
1816static void intel_sdvo_get_tv_modes(struct drm_connector *connector) 1822static void intel_sdvo_get_tv_modes(struct drm_connector *connector)
1817{ 1823{
1818 struct intel_output *output = to_intel_output(connector); 1824 struct intel_encoder *output = to_intel_encoder(connector);
1819 struct intel_sdvo_priv *sdvo_priv = output->dev_priv; 1825 struct intel_sdvo_priv *sdvo_priv = output->dev_priv;
1820 struct intel_sdvo_sdtv_resolution_request tv_res; 1826 struct intel_sdvo_sdtv_resolution_request tv_res;
1821 uint32_t reply = 0, format_map = 0; 1827 uint32_t reply = 0, format_map = 0;
@@ -1857,9 +1863,9 @@ static void intel_sdvo_get_tv_modes(struct drm_connector *connector)
1857 1863
1858static void intel_sdvo_get_lvds_modes(struct drm_connector *connector) 1864static void intel_sdvo_get_lvds_modes(struct drm_connector *connector)
1859{ 1865{
1860 struct intel_output *intel_output = to_intel_output(connector); 1866 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
1861 struct drm_i915_private *dev_priv = connector->dev->dev_private; 1867 struct drm_i915_private *dev_priv = connector->dev->dev_private;
1862 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; 1868 struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv;
1863 struct drm_display_mode *newmode; 1869 struct drm_display_mode *newmode;
1864 1870
1865 /* 1871 /*
@@ -1867,7 +1873,7 @@ static void intel_sdvo_get_lvds_modes(struct drm_connector *connector)
1867 * Assume that the preferred modes are 1873 * Assume that the preferred modes are
1868 * arranged in priority order. 1874 * arranged in priority order.
1869 */ 1875 */
1870 intel_ddc_get_modes(intel_output); 1876 intel_ddc_get_modes(intel_encoder);
1871 if (list_empty(&connector->probed_modes) == false) 1877 if (list_empty(&connector->probed_modes) == false)
1872 goto end; 1878 goto end;
1873 1879
@@ -1896,7 +1902,7 @@ end:
1896 1902
1897static int intel_sdvo_get_modes(struct drm_connector *connector) 1903static int intel_sdvo_get_modes(struct drm_connector *connector)
1898{ 1904{
1899 struct intel_output *output = to_intel_output(connector); 1905 struct intel_encoder *output = to_intel_encoder(connector);
1900 struct intel_sdvo_priv *sdvo_priv = output->dev_priv; 1906 struct intel_sdvo_priv *sdvo_priv = output->dev_priv;
1901 1907
1902 if (sdvo_priv->is_tv) 1908 if (sdvo_priv->is_tv)
@@ -1914,8 +1920,8 @@ static int intel_sdvo_get_modes(struct drm_connector *connector)
1914static 1920static
1915void intel_sdvo_destroy_enhance_property(struct drm_connector *connector) 1921void intel_sdvo_destroy_enhance_property(struct drm_connector *connector)
1916{ 1922{
1917 struct intel_output *intel_output = to_intel_output(connector); 1923 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
1918 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; 1924 struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv;
1919 struct drm_device *dev = connector->dev; 1925 struct drm_device *dev = connector->dev;
1920 1926
1921 if (sdvo_priv->is_tv) { 1927 if (sdvo_priv->is_tv) {
@@ -1952,13 +1958,13 @@ void intel_sdvo_destroy_enhance_property(struct drm_connector *connector)
1952 1958
1953static void intel_sdvo_destroy(struct drm_connector *connector) 1959static void intel_sdvo_destroy(struct drm_connector *connector)
1954{ 1960{
1955 struct intel_output *intel_output = to_intel_output(connector); 1961 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
1956 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; 1962 struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv;
1957 1963
1958 if (intel_output->i2c_bus) 1964 if (intel_encoder->i2c_bus)
1959 intel_i2c_destroy(intel_output->i2c_bus); 1965 intel_i2c_destroy(intel_encoder->i2c_bus);
1960 if (intel_output->ddc_bus) 1966 if (intel_encoder->ddc_bus)
1961 intel_i2c_destroy(intel_output->ddc_bus); 1967 intel_i2c_destroy(intel_encoder->ddc_bus);
1962 if (sdvo_priv->analog_ddc_bus) 1968 if (sdvo_priv->analog_ddc_bus)
1963 intel_i2c_destroy(sdvo_priv->analog_ddc_bus); 1969 intel_i2c_destroy(sdvo_priv->analog_ddc_bus);
1964 1970
@@ -1976,7 +1982,7 @@ static void intel_sdvo_destroy(struct drm_connector *connector)
1976 drm_sysfs_connector_remove(connector); 1982 drm_sysfs_connector_remove(connector);
1977 drm_connector_cleanup(connector); 1983 drm_connector_cleanup(connector);
1978 1984
1979 kfree(intel_output); 1985 kfree(intel_encoder);
1980} 1986}
1981 1987
1982static int 1988static int
@@ -1984,9 +1990,9 @@ intel_sdvo_set_property(struct drm_connector *connector,
1984 struct drm_property *property, 1990 struct drm_property *property,
1985 uint64_t val) 1991 uint64_t val)
1986{ 1992{
1987 struct intel_output *intel_output = to_intel_output(connector); 1993 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
1988 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; 1994 struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv;
1989 struct drm_encoder *encoder = &intel_output->enc; 1995 struct drm_encoder *encoder = &intel_encoder->enc;
1990 struct drm_crtc *crtc = encoder->crtc; 1996 struct drm_crtc *crtc = encoder->crtc;
1991 int ret = 0; 1997 int ret = 0;
1992 bool changed = false; 1998 bool changed = false;
@@ -2094,8 +2100,8 @@ intel_sdvo_set_property(struct drm_connector *connector,
2094 sdvo_priv->cur_brightness = temp_value; 2100 sdvo_priv->cur_brightness = temp_value;
2095 } 2101 }
2096 if (cmd) { 2102 if (cmd) {
2097 intel_sdvo_write_cmd(intel_output, cmd, &temp_value, 2); 2103 intel_sdvo_write_cmd(intel_encoder, cmd, &temp_value, 2);
2098 status = intel_sdvo_read_response(intel_output, 2104 status = intel_sdvo_read_response(intel_encoder,
2099 NULL, 0); 2105 NULL, 0);
2100 if (status != SDVO_CMD_STATUS_SUCCESS) { 2106 if (status != SDVO_CMD_STATUS_SUCCESS) {
2101 DRM_DEBUG_KMS("Incorrect SDVO command \n"); 2107 DRM_DEBUG_KMS("Incorrect SDVO command \n");
@@ -2190,7 +2196,7 @@ intel_sdvo_select_ddc_bus(struct intel_sdvo_priv *dev_priv)
2190} 2196}
2191 2197
2192static bool 2198static bool
2193intel_sdvo_get_digital_encoding_mode(struct intel_output *output) 2199intel_sdvo_get_digital_encoding_mode(struct intel_encoder *output)
2194{ 2200{
2195 struct intel_sdvo_priv *sdvo_priv = output->dev_priv; 2201 struct intel_sdvo_priv *sdvo_priv = output->dev_priv;
2196 uint8_t status; 2202 uint8_t status;
@@ -2204,42 +2210,42 @@ intel_sdvo_get_digital_encoding_mode(struct intel_output *output)
2204 return true; 2210 return true;
2205} 2211}
2206 2212
2207static struct intel_output * 2213static struct intel_encoder *
2208intel_sdvo_chan_to_intel_output(struct intel_i2c_chan *chan) 2214intel_sdvo_chan_to_intel_encoder(struct intel_i2c_chan *chan)
2209{ 2215{
2210 struct drm_device *dev = chan->drm_dev; 2216 struct drm_device *dev = chan->drm_dev;
2211 struct drm_connector *connector; 2217 struct drm_connector *connector;
2212 struct intel_output *intel_output = NULL; 2218 struct intel_encoder *intel_encoder = NULL;
2213 2219
2214 list_for_each_entry(connector, 2220 list_for_each_entry(connector,
2215 &dev->mode_config.connector_list, head) { 2221 &dev->mode_config.connector_list, head) {
2216 if (to_intel_output(connector)->ddc_bus == &chan->adapter) { 2222 if (to_intel_encoder(connector)->ddc_bus == &chan->adapter) {
2217 intel_output = to_intel_output(connector); 2223 intel_encoder = to_intel_encoder(connector);
2218 break; 2224 break;
2219 } 2225 }
2220 } 2226 }
2221 return intel_output; 2227 return intel_encoder;
2222} 2228}
2223 2229
2224static int intel_sdvo_master_xfer(struct i2c_adapter *i2c_adap, 2230static int intel_sdvo_master_xfer(struct i2c_adapter *i2c_adap,
2225 struct i2c_msg msgs[], int num) 2231 struct i2c_msg msgs[], int num)
2226{ 2232{
2227 struct intel_output *intel_output; 2233 struct intel_encoder *intel_encoder;
2228 struct intel_sdvo_priv *sdvo_priv; 2234 struct intel_sdvo_priv *sdvo_priv;
2229 struct i2c_algo_bit_data *algo_data; 2235 struct i2c_algo_bit_data *algo_data;
2230 const struct i2c_algorithm *algo; 2236 const struct i2c_algorithm *algo;
2231 2237
2232 algo_data = (struct i2c_algo_bit_data *)i2c_adap->algo_data; 2238 algo_data = (struct i2c_algo_bit_data *)i2c_adap->algo_data;
2233 intel_output = 2239 intel_encoder =
2234 intel_sdvo_chan_to_intel_output( 2240 intel_sdvo_chan_to_intel_encoder(
2235 (struct intel_i2c_chan *)(algo_data->data)); 2241 (struct intel_i2c_chan *)(algo_data->data));
2236 if (intel_output == NULL) 2242 if (intel_encoder == NULL)
2237 return -EINVAL; 2243 return -EINVAL;
2238 2244
2239 sdvo_priv = intel_output->dev_priv; 2245 sdvo_priv = intel_encoder->dev_priv;
2240 algo = intel_output->i2c_bus->algo; 2246 algo = intel_encoder->i2c_bus->algo;
2241 2247
2242 intel_sdvo_set_control_bus_switch(intel_output, sdvo_priv->ddc_bus); 2248 intel_sdvo_set_control_bus_switch(intel_encoder, sdvo_priv->ddc_bus);
2243 return algo->master_xfer(i2c_adap, msgs, num); 2249 return algo->master_xfer(i2c_adap, msgs, num);
2244} 2250}
2245 2251
@@ -2248,12 +2254,12 @@ static struct i2c_algorithm intel_sdvo_i2c_bit_algo = {
2248}; 2254};
2249 2255
2250static u8 2256static u8
2251intel_sdvo_get_slave_addr(struct drm_device *dev, int output_device) 2257intel_sdvo_get_slave_addr(struct drm_device *dev, int sdvo_reg)
2252{ 2258{
2253 struct drm_i915_private *dev_priv = dev->dev_private; 2259 struct drm_i915_private *dev_priv = dev->dev_private;
2254 struct sdvo_device_mapping *my_mapping, *other_mapping; 2260 struct sdvo_device_mapping *my_mapping, *other_mapping;
2255 2261
2256 if (output_device == SDVOB) { 2262 if (sdvo_reg == SDVOB) {
2257 my_mapping = &dev_priv->sdvo_mappings[0]; 2263 my_mapping = &dev_priv->sdvo_mappings[0];
2258 other_mapping = &dev_priv->sdvo_mappings[1]; 2264 other_mapping = &dev_priv->sdvo_mappings[1];
2259 } else { 2265 } else {
@@ -2278,7 +2284,7 @@ intel_sdvo_get_slave_addr(struct drm_device *dev, int output_device)
2278 /* No SDVO device info is found for another DVO port, 2284 /* No SDVO device info is found for another DVO port,
2279 * so use mapping assumption we had before BIOS parsing. 2285 * so use mapping assumption we had before BIOS parsing.
2280 */ 2286 */
2281 if (output_device == SDVOB) 2287 if (sdvo_reg == SDVOB)
2282 return 0x70; 2288 return 0x70;
2283 else 2289 else
2284 return 0x72; 2290 return 0x72;
@@ -2304,15 +2310,15 @@ static struct dmi_system_id intel_sdvo_bad_tv[] = {
2304}; 2310};
2305 2311
2306static bool 2312static bool
2307intel_sdvo_output_setup(struct intel_output *intel_output, uint16_t flags) 2313intel_sdvo_output_setup(struct intel_encoder *intel_encoder, uint16_t flags)
2308{ 2314{
2309 struct drm_connector *connector = &intel_output->base; 2315 struct drm_connector *connector = &intel_encoder->base;
2310 struct drm_encoder *encoder = &intel_output->enc; 2316 struct drm_encoder *encoder = &intel_encoder->enc;
2311 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; 2317 struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv;
2312 bool ret = true, registered = false; 2318 bool ret = true, registered = false;
2313 2319
2314 sdvo_priv->is_tv = false; 2320 sdvo_priv->is_tv = false;
2315 intel_output->needs_tv_clock = false; 2321 intel_encoder->needs_tv_clock = false;
2316 sdvo_priv->is_lvds = false; 2322 sdvo_priv->is_lvds = false;
2317 2323
2318 if (device_is_registered(&connector->kdev)) { 2324 if (device_is_registered(&connector->kdev)) {
@@ -2330,16 +2336,16 @@ intel_sdvo_output_setup(struct intel_output *intel_output, uint16_t flags)
2330 encoder->encoder_type = DRM_MODE_ENCODER_TMDS; 2336 encoder->encoder_type = DRM_MODE_ENCODER_TMDS;
2331 connector->connector_type = DRM_MODE_CONNECTOR_DVID; 2337 connector->connector_type = DRM_MODE_CONNECTOR_DVID;
2332 2338
2333 if (intel_sdvo_get_supp_encode(intel_output, 2339 if (intel_sdvo_get_supp_encode(intel_encoder,
2334 &sdvo_priv->encode) && 2340 &sdvo_priv->encode) &&
2335 intel_sdvo_get_digital_encoding_mode(intel_output) && 2341 intel_sdvo_get_digital_encoding_mode(intel_encoder) &&
2336 sdvo_priv->is_hdmi) { 2342 sdvo_priv->is_hdmi) {
2337 /* enable hdmi encoding mode if supported */ 2343 /* enable hdmi encoding mode if supported */
2338 intel_sdvo_set_encode(intel_output, SDVO_ENCODE_HDMI); 2344 intel_sdvo_set_encode(intel_encoder, SDVO_ENCODE_HDMI);
2339 intel_sdvo_set_colorimetry(intel_output, 2345 intel_sdvo_set_colorimetry(intel_encoder,
2340 SDVO_COLORIMETRY_RGB256); 2346 SDVO_COLORIMETRY_RGB256);
2341 connector->connector_type = DRM_MODE_CONNECTOR_HDMIA; 2347 connector->connector_type = DRM_MODE_CONNECTOR_HDMIA;
2342 intel_output->clone_mask = 2348 intel_encoder->clone_mask =
2343 (1 << INTEL_SDVO_NON_TV_CLONE_BIT) | 2349 (1 << INTEL_SDVO_NON_TV_CLONE_BIT) |
2344 (1 << INTEL_ANALOG_CLONE_BIT); 2350 (1 << INTEL_ANALOG_CLONE_BIT);
2345 } 2351 }
@@ -2350,21 +2356,21 @@ intel_sdvo_output_setup(struct intel_output *intel_output, uint16_t flags)
2350 encoder->encoder_type = DRM_MODE_ENCODER_TVDAC; 2356 encoder->encoder_type = DRM_MODE_ENCODER_TVDAC;
2351 connector->connector_type = DRM_MODE_CONNECTOR_SVIDEO; 2357 connector->connector_type = DRM_MODE_CONNECTOR_SVIDEO;
2352 sdvo_priv->is_tv = true; 2358 sdvo_priv->is_tv = true;
2353 intel_output->needs_tv_clock = true; 2359 intel_encoder->needs_tv_clock = true;
2354 intel_output->clone_mask = 1 << INTEL_SDVO_TV_CLONE_BIT; 2360 intel_encoder->clone_mask = 1 << INTEL_SDVO_TV_CLONE_BIT;
2355 } else if (flags & SDVO_OUTPUT_RGB0) { 2361 } else if (flags & SDVO_OUTPUT_RGB0) {
2356 2362
2357 sdvo_priv->controlled_output = SDVO_OUTPUT_RGB0; 2363 sdvo_priv->controlled_output = SDVO_OUTPUT_RGB0;
2358 encoder->encoder_type = DRM_MODE_ENCODER_DAC; 2364 encoder->encoder_type = DRM_MODE_ENCODER_DAC;
2359 connector->connector_type = DRM_MODE_CONNECTOR_VGA; 2365 connector->connector_type = DRM_MODE_CONNECTOR_VGA;
2360 intel_output->clone_mask = (1 << INTEL_SDVO_NON_TV_CLONE_BIT) | 2366 intel_encoder->clone_mask = (1 << INTEL_SDVO_NON_TV_CLONE_BIT) |
2361 (1 << INTEL_ANALOG_CLONE_BIT); 2367 (1 << INTEL_ANALOG_CLONE_BIT);
2362 } else if (flags & SDVO_OUTPUT_RGB1) { 2368 } else if (flags & SDVO_OUTPUT_RGB1) {
2363 2369
2364 sdvo_priv->controlled_output = SDVO_OUTPUT_RGB1; 2370 sdvo_priv->controlled_output = SDVO_OUTPUT_RGB1;
2365 encoder->encoder_type = DRM_MODE_ENCODER_DAC; 2371 encoder->encoder_type = DRM_MODE_ENCODER_DAC;
2366 connector->connector_type = DRM_MODE_CONNECTOR_VGA; 2372 connector->connector_type = DRM_MODE_CONNECTOR_VGA;
2367 intel_output->clone_mask = (1 << INTEL_SDVO_NON_TV_CLONE_BIT) | 2373 intel_encoder->clone_mask = (1 << INTEL_SDVO_NON_TV_CLONE_BIT) |
2368 (1 << INTEL_ANALOG_CLONE_BIT); 2374 (1 << INTEL_ANALOG_CLONE_BIT);
2369 } else if (flags & SDVO_OUTPUT_CVBS0) { 2375 } else if (flags & SDVO_OUTPUT_CVBS0) {
2370 2376
@@ -2372,15 +2378,15 @@ intel_sdvo_output_setup(struct intel_output *intel_output, uint16_t flags)
2372 encoder->encoder_type = DRM_MODE_ENCODER_TVDAC; 2378 encoder->encoder_type = DRM_MODE_ENCODER_TVDAC;
2373 connector->connector_type = DRM_MODE_CONNECTOR_SVIDEO; 2379 connector->connector_type = DRM_MODE_CONNECTOR_SVIDEO;
2374 sdvo_priv->is_tv = true; 2380 sdvo_priv->is_tv = true;
2375 intel_output->needs_tv_clock = true; 2381 intel_encoder->needs_tv_clock = true;
2376 intel_output->clone_mask = 1 << INTEL_SDVO_TV_CLONE_BIT; 2382 intel_encoder->clone_mask = 1 << INTEL_SDVO_TV_CLONE_BIT;
2377 } else if (flags & SDVO_OUTPUT_LVDS0) { 2383 } else if (flags & SDVO_OUTPUT_LVDS0) {
2378 2384
2379 sdvo_priv->controlled_output = SDVO_OUTPUT_LVDS0; 2385 sdvo_priv->controlled_output = SDVO_OUTPUT_LVDS0;
2380 encoder->encoder_type = DRM_MODE_ENCODER_LVDS; 2386 encoder->encoder_type = DRM_MODE_ENCODER_LVDS;
2381 connector->connector_type = DRM_MODE_CONNECTOR_LVDS; 2387 connector->connector_type = DRM_MODE_CONNECTOR_LVDS;
2382 sdvo_priv->is_lvds = true; 2388 sdvo_priv->is_lvds = true;
2383 intel_output->clone_mask = (1 << INTEL_ANALOG_CLONE_BIT) | 2389 intel_encoder->clone_mask = (1 << INTEL_ANALOG_CLONE_BIT) |
2384 (1 << INTEL_SDVO_LVDS_CLONE_BIT); 2390 (1 << INTEL_SDVO_LVDS_CLONE_BIT);
2385 } else if (flags & SDVO_OUTPUT_LVDS1) { 2391 } else if (flags & SDVO_OUTPUT_LVDS1) {
2386 2392
@@ -2388,7 +2394,7 @@ intel_sdvo_output_setup(struct intel_output *intel_output, uint16_t flags)
2388 encoder->encoder_type = DRM_MODE_ENCODER_LVDS; 2394 encoder->encoder_type = DRM_MODE_ENCODER_LVDS;
2389 connector->connector_type = DRM_MODE_CONNECTOR_LVDS; 2395 connector->connector_type = DRM_MODE_CONNECTOR_LVDS;
2390 sdvo_priv->is_lvds = true; 2396 sdvo_priv->is_lvds = true;
2391 intel_output->clone_mask = (1 << INTEL_ANALOG_CLONE_BIT) | 2397 intel_encoder->clone_mask = (1 << INTEL_ANALOG_CLONE_BIT) |
2392 (1 << INTEL_SDVO_LVDS_CLONE_BIT); 2398 (1 << INTEL_SDVO_LVDS_CLONE_BIT);
2393 } else { 2399 } else {
2394 2400
@@ -2401,7 +2407,7 @@ intel_sdvo_output_setup(struct intel_output *intel_output, uint16_t flags)
2401 bytes[0], bytes[1]); 2407 bytes[0], bytes[1]);
2402 ret = false; 2408 ret = false;
2403 } 2409 }
2404 intel_output->crtc_mask = (1 << 0) | (1 << 1); 2410 intel_encoder->crtc_mask = (1 << 0) | (1 << 1);
2405 2411
2406 if (ret && registered) 2412 if (ret && registered)
2407 ret = drm_sysfs_connector_add(connector) == 0 ? true : false; 2413 ret = drm_sysfs_connector_add(connector) == 0 ? true : false;
@@ -2413,18 +2419,18 @@ intel_sdvo_output_setup(struct intel_output *intel_output, uint16_t flags)
2413 2419
2414static void intel_sdvo_tv_create_property(struct drm_connector *connector) 2420static void intel_sdvo_tv_create_property(struct drm_connector *connector)
2415{ 2421{
2416 struct intel_output *intel_output = to_intel_output(connector); 2422 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
2417 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; 2423 struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv;
2418 struct intel_sdvo_tv_format format; 2424 struct intel_sdvo_tv_format format;
2419 uint32_t format_map, i; 2425 uint32_t format_map, i;
2420 uint8_t status; 2426 uint8_t status;
2421 2427
2422 intel_sdvo_set_target_output(intel_output, 2428 intel_sdvo_set_target_output(intel_encoder,
2423 sdvo_priv->controlled_output); 2429 sdvo_priv->controlled_output);
2424 2430
2425 intel_sdvo_write_cmd(intel_output, 2431 intel_sdvo_write_cmd(intel_encoder,
2426 SDVO_CMD_GET_SUPPORTED_TV_FORMATS, NULL, 0); 2432 SDVO_CMD_GET_SUPPORTED_TV_FORMATS, NULL, 0);
2427 status = intel_sdvo_read_response(intel_output, 2433 status = intel_sdvo_read_response(intel_encoder,
2428 &format, sizeof(format)); 2434 &format, sizeof(format));
2429 if (status != SDVO_CMD_STATUS_SUCCESS) 2435 if (status != SDVO_CMD_STATUS_SUCCESS)
2430 return; 2436 return;
@@ -2462,16 +2468,16 @@ static void intel_sdvo_tv_create_property(struct drm_connector *connector)
2462 2468
2463static void intel_sdvo_create_enhance_property(struct drm_connector *connector) 2469static void intel_sdvo_create_enhance_property(struct drm_connector *connector)
2464{ 2470{
2465 struct intel_output *intel_output = to_intel_output(connector); 2471 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
2466 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; 2472 struct intel_sdvo_priv *sdvo_priv = intel_encoder->dev_priv;
2467 struct intel_sdvo_enhancements_reply sdvo_data; 2473 struct intel_sdvo_enhancements_reply sdvo_data;
2468 struct drm_device *dev = connector->dev; 2474 struct drm_device *dev = connector->dev;
2469 uint8_t status; 2475 uint8_t status;
2470 uint16_t response, data_value[2]; 2476 uint16_t response, data_value[2];
2471 2477
2472 intel_sdvo_write_cmd(intel_output, SDVO_CMD_GET_SUPPORTED_ENHANCEMENTS, 2478 intel_sdvo_write_cmd(intel_encoder, SDVO_CMD_GET_SUPPORTED_ENHANCEMENTS,
2473 NULL, 0); 2479 NULL, 0);
2474 status = intel_sdvo_read_response(intel_output, &sdvo_data, 2480 status = intel_sdvo_read_response(intel_encoder, &sdvo_data,
2475 sizeof(sdvo_data)); 2481 sizeof(sdvo_data));
2476 if (status != SDVO_CMD_STATUS_SUCCESS) { 2482 if (status != SDVO_CMD_STATUS_SUCCESS) {
2477 DRM_DEBUG_KMS(" incorrect response is returned\n"); 2483 DRM_DEBUG_KMS(" incorrect response is returned\n");
@@ -2487,18 +2493,18 @@ static void intel_sdvo_create_enhance_property(struct drm_connector *connector)
2487 * property 2493 * property
2488 */ 2494 */
2489 if (sdvo_data.overscan_h) { 2495 if (sdvo_data.overscan_h) {
2490 intel_sdvo_write_cmd(intel_output, 2496 intel_sdvo_write_cmd(intel_encoder,
2491 SDVO_CMD_GET_MAX_OVERSCAN_H, NULL, 0); 2497 SDVO_CMD_GET_MAX_OVERSCAN_H, NULL, 0);
2492 status = intel_sdvo_read_response(intel_output, 2498 status = intel_sdvo_read_response(intel_encoder,
2493 &data_value, 4); 2499 &data_value, 4);
2494 if (status != SDVO_CMD_STATUS_SUCCESS) { 2500 if (status != SDVO_CMD_STATUS_SUCCESS) {
2495 DRM_DEBUG_KMS("Incorrect SDVO max " 2501 DRM_DEBUG_KMS("Incorrect SDVO max "
2496 "h_overscan\n"); 2502 "h_overscan\n");
2497 return; 2503 return;
2498 } 2504 }
2499 intel_sdvo_write_cmd(intel_output, 2505 intel_sdvo_write_cmd(intel_encoder,
2500 SDVO_CMD_GET_OVERSCAN_H, NULL, 0); 2506 SDVO_CMD_GET_OVERSCAN_H, NULL, 0);
2501 status = intel_sdvo_read_response(intel_output, 2507 status = intel_sdvo_read_response(intel_encoder,
2502 &response, 2); 2508 &response, 2);
2503 if (status != SDVO_CMD_STATUS_SUCCESS) { 2509 if (status != SDVO_CMD_STATUS_SUCCESS) {
2504 DRM_DEBUG_KMS("Incorrect SDVO h_overscan\n"); 2510 DRM_DEBUG_KMS("Incorrect SDVO h_overscan\n");
@@ -2528,18 +2534,18 @@ static void intel_sdvo_create_enhance_property(struct drm_connector *connector)
2528 data_value[0], data_value[1], response); 2534 data_value[0], data_value[1], response);
2529 } 2535 }
2530 if (sdvo_data.overscan_v) { 2536 if (sdvo_data.overscan_v) {
2531 intel_sdvo_write_cmd(intel_output, 2537 intel_sdvo_write_cmd(intel_encoder,
2532 SDVO_CMD_GET_MAX_OVERSCAN_V, NULL, 0); 2538 SDVO_CMD_GET_MAX_OVERSCAN_V, NULL, 0);
2533 status = intel_sdvo_read_response(intel_output, 2539 status = intel_sdvo_read_response(intel_encoder,
2534 &data_value, 4); 2540 &data_value, 4);
2535 if (status != SDVO_CMD_STATUS_SUCCESS) { 2541 if (status != SDVO_CMD_STATUS_SUCCESS) {
2536 DRM_DEBUG_KMS("Incorrect SDVO max " 2542 DRM_DEBUG_KMS("Incorrect SDVO max "
2537 "v_overscan\n"); 2543 "v_overscan\n");
2538 return; 2544 return;
2539 } 2545 }
2540 intel_sdvo_write_cmd(intel_output, 2546 intel_sdvo_write_cmd(intel_encoder,
2541 SDVO_CMD_GET_OVERSCAN_V, NULL, 0); 2547 SDVO_CMD_GET_OVERSCAN_V, NULL, 0);
2542 status = intel_sdvo_read_response(intel_output, 2548 status = intel_sdvo_read_response(intel_encoder,
2543 &response, 2); 2549 &response, 2);
2544 if (status != SDVO_CMD_STATUS_SUCCESS) { 2550 if (status != SDVO_CMD_STATUS_SUCCESS) {
2545 DRM_DEBUG_KMS("Incorrect SDVO v_overscan\n"); 2551 DRM_DEBUG_KMS("Incorrect SDVO v_overscan\n");
@@ -2569,17 +2575,17 @@ static void intel_sdvo_create_enhance_property(struct drm_connector *connector)
2569 data_value[0], data_value[1], response); 2575 data_value[0], data_value[1], response);
2570 } 2576 }
2571 if (sdvo_data.position_h) { 2577 if (sdvo_data.position_h) {
2572 intel_sdvo_write_cmd(intel_output, 2578 intel_sdvo_write_cmd(intel_encoder,
2573 SDVO_CMD_GET_MAX_POSITION_H, NULL, 0); 2579 SDVO_CMD_GET_MAX_POSITION_H, NULL, 0);
2574 status = intel_sdvo_read_response(intel_output, 2580 status = intel_sdvo_read_response(intel_encoder,
2575 &data_value, 4); 2581 &data_value, 4);
2576 if (status != SDVO_CMD_STATUS_SUCCESS) { 2582 if (status != SDVO_CMD_STATUS_SUCCESS) {
2577 DRM_DEBUG_KMS("Incorrect SDVO Max h_pos\n"); 2583 DRM_DEBUG_KMS("Incorrect SDVO Max h_pos\n");
2578 return; 2584 return;
2579 } 2585 }
2580 intel_sdvo_write_cmd(intel_output, 2586 intel_sdvo_write_cmd(intel_encoder,
2581 SDVO_CMD_GET_POSITION_H, NULL, 0); 2587 SDVO_CMD_GET_POSITION_H, NULL, 0);
2582 status = intel_sdvo_read_response(intel_output, 2588 status = intel_sdvo_read_response(intel_encoder,
2583 &response, 2); 2589 &response, 2);
2584 if (status != SDVO_CMD_STATUS_SUCCESS) { 2590 if (status != SDVO_CMD_STATUS_SUCCESS) {
2585 DRM_DEBUG_KMS("Incorrect SDVO get h_postion\n"); 2591 DRM_DEBUG_KMS("Incorrect SDVO get h_postion\n");
@@ -2600,17 +2606,17 @@ static void intel_sdvo_create_enhance_property(struct drm_connector *connector)
2600 data_value[0], data_value[1], response); 2606 data_value[0], data_value[1], response);
2601 } 2607 }
2602 if (sdvo_data.position_v) { 2608 if (sdvo_data.position_v) {
2603 intel_sdvo_write_cmd(intel_output, 2609 intel_sdvo_write_cmd(intel_encoder,
2604 SDVO_CMD_GET_MAX_POSITION_V, NULL, 0); 2610 SDVO_CMD_GET_MAX_POSITION_V, NULL, 0);
2605 status = intel_sdvo_read_response(intel_output, 2611 status = intel_sdvo_read_response(intel_encoder,
2606 &data_value, 4); 2612 &data_value, 4);
2607 if (status != SDVO_CMD_STATUS_SUCCESS) { 2613 if (status != SDVO_CMD_STATUS_SUCCESS) {
2608 DRM_DEBUG_KMS("Incorrect SDVO Max v_pos\n"); 2614 DRM_DEBUG_KMS("Incorrect SDVO Max v_pos\n");
2609 return; 2615 return;
2610 } 2616 }
2611 intel_sdvo_write_cmd(intel_output, 2617 intel_sdvo_write_cmd(intel_encoder,
2612 SDVO_CMD_GET_POSITION_V, NULL, 0); 2618 SDVO_CMD_GET_POSITION_V, NULL, 0);
2613 status = intel_sdvo_read_response(intel_output, 2619 status = intel_sdvo_read_response(intel_encoder,
2614 &response, 2); 2620 &response, 2);
2615 if (status != SDVO_CMD_STATUS_SUCCESS) { 2621 if (status != SDVO_CMD_STATUS_SUCCESS) {
2616 DRM_DEBUG_KMS("Incorrect SDVO get v_postion\n"); 2622 DRM_DEBUG_KMS("Incorrect SDVO get v_postion\n");
@@ -2633,17 +2639,17 @@ static void intel_sdvo_create_enhance_property(struct drm_connector *connector)
2633 } 2639 }
2634 if (sdvo_priv->is_tv) { 2640 if (sdvo_priv->is_tv) {
2635 if (sdvo_data.saturation) { 2641 if (sdvo_data.saturation) {
2636 intel_sdvo_write_cmd(intel_output, 2642 intel_sdvo_write_cmd(intel_encoder,
2637 SDVO_CMD_GET_MAX_SATURATION, NULL, 0); 2643 SDVO_CMD_GET_MAX_SATURATION, NULL, 0);
2638 status = intel_sdvo_read_response(intel_output, 2644 status = intel_sdvo_read_response(intel_encoder,
2639 &data_value, 4); 2645 &data_value, 4);
2640 if (status != SDVO_CMD_STATUS_SUCCESS) { 2646 if (status != SDVO_CMD_STATUS_SUCCESS) {
2641 DRM_DEBUG_KMS("Incorrect SDVO Max sat\n"); 2647 DRM_DEBUG_KMS("Incorrect SDVO Max sat\n");
2642 return; 2648 return;
2643 } 2649 }
2644 intel_sdvo_write_cmd(intel_output, 2650 intel_sdvo_write_cmd(intel_encoder,
2645 SDVO_CMD_GET_SATURATION, NULL, 0); 2651 SDVO_CMD_GET_SATURATION, NULL, 0);
2646 status = intel_sdvo_read_response(intel_output, 2652 status = intel_sdvo_read_response(intel_encoder,
2647 &response, 2); 2653 &response, 2);
2648 if (status != SDVO_CMD_STATUS_SUCCESS) { 2654 if (status != SDVO_CMD_STATUS_SUCCESS) {
2649 DRM_DEBUG_KMS("Incorrect SDVO get sat\n"); 2655 DRM_DEBUG_KMS("Incorrect SDVO get sat\n");
@@ -2665,17 +2671,17 @@ static void intel_sdvo_create_enhance_property(struct drm_connector *connector)
2665 data_value[0], data_value[1], response); 2671 data_value[0], data_value[1], response);
2666 } 2672 }
2667 if (sdvo_data.contrast) { 2673 if (sdvo_data.contrast) {
2668 intel_sdvo_write_cmd(intel_output, 2674 intel_sdvo_write_cmd(intel_encoder,
2669 SDVO_CMD_GET_MAX_CONTRAST, NULL, 0); 2675 SDVO_CMD_GET_MAX_CONTRAST, NULL, 0);
2670 status = intel_sdvo_read_response(intel_output, 2676 status = intel_sdvo_read_response(intel_encoder,
2671 &data_value, 4); 2677 &data_value, 4);
2672 if (status != SDVO_CMD_STATUS_SUCCESS) { 2678 if (status != SDVO_CMD_STATUS_SUCCESS) {
2673 DRM_DEBUG_KMS("Incorrect SDVO Max contrast\n"); 2679 DRM_DEBUG_KMS("Incorrect SDVO Max contrast\n");
2674 return; 2680 return;
2675 } 2681 }
2676 intel_sdvo_write_cmd(intel_output, 2682 intel_sdvo_write_cmd(intel_encoder,
2677 SDVO_CMD_GET_CONTRAST, NULL, 0); 2683 SDVO_CMD_GET_CONTRAST, NULL, 0);
2678 status = intel_sdvo_read_response(intel_output, 2684 status = intel_sdvo_read_response(intel_encoder,
2679 &response, 2); 2685 &response, 2);
2680 if (status != SDVO_CMD_STATUS_SUCCESS) { 2686 if (status != SDVO_CMD_STATUS_SUCCESS) {
2681 DRM_DEBUG_KMS("Incorrect SDVO get contrast\n"); 2687 DRM_DEBUG_KMS("Incorrect SDVO get contrast\n");
@@ -2696,17 +2702,17 @@ static void intel_sdvo_create_enhance_property(struct drm_connector *connector)
2696 data_value[0], data_value[1], response); 2702 data_value[0], data_value[1], response);
2697 } 2703 }
2698 if (sdvo_data.hue) { 2704 if (sdvo_data.hue) {
2699 intel_sdvo_write_cmd(intel_output, 2705 intel_sdvo_write_cmd(intel_encoder,
2700 SDVO_CMD_GET_MAX_HUE, NULL, 0); 2706 SDVO_CMD_GET_MAX_HUE, NULL, 0);
2701 status = intel_sdvo_read_response(intel_output, 2707 status = intel_sdvo_read_response(intel_encoder,
2702 &data_value, 4); 2708 &data_value, 4);
2703 if (status != SDVO_CMD_STATUS_SUCCESS) { 2709 if (status != SDVO_CMD_STATUS_SUCCESS) {
2704 DRM_DEBUG_KMS("Incorrect SDVO Max hue\n"); 2710 DRM_DEBUG_KMS("Incorrect SDVO Max hue\n");
2705 return; 2711 return;
2706 } 2712 }
2707 intel_sdvo_write_cmd(intel_output, 2713 intel_sdvo_write_cmd(intel_encoder,
2708 SDVO_CMD_GET_HUE, NULL, 0); 2714 SDVO_CMD_GET_HUE, NULL, 0);
2709 status = intel_sdvo_read_response(intel_output, 2715 status = intel_sdvo_read_response(intel_encoder,
2710 &response, 2); 2716 &response, 2);
2711 if (status != SDVO_CMD_STATUS_SUCCESS) { 2717 if (status != SDVO_CMD_STATUS_SUCCESS) {
2712 DRM_DEBUG_KMS("Incorrect SDVO get hue\n"); 2718 DRM_DEBUG_KMS("Incorrect SDVO get hue\n");
@@ -2729,17 +2735,17 @@ static void intel_sdvo_create_enhance_property(struct drm_connector *connector)
2729 } 2735 }
2730 if (sdvo_priv->is_tv || sdvo_priv->is_lvds) { 2736 if (sdvo_priv->is_tv || sdvo_priv->is_lvds) {
2731 if (sdvo_data.brightness) { 2737 if (sdvo_data.brightness) {
2732 intel_sdvo_write_cmd(intel_output, 2738 intel_sdvo_write_cmd(intel_encoder,
2733 SDVO_CMD_GET_MAX_BRIGHTNESS, NULL, 0); 2739 SDVO_CMD_GET_MAX_BRIGHTNESS, NULL, 0);
2734 status = intel_sdvo_read_response(intel_output, 2740 status = intel_sdvo_read_response(intel_encoder,
2735 &data_value, 4); 2741 &data_value, 4);
2736 if (status != SDVO_CMD_STATUS_SUCCESS) { 2742 if (status != SDVO_CMD_STATUS_SUCCESS) {
2737 DRM_DEBUG_KMS("Incorrect SDVO Max bright\n"); 2743 DRM_DEBUG_KMS("Incorrect SDVO Max bright\n");
2738 return; 2744 return;
2739 } 2745 }
2740 intel_sdvo_write_cmd(intel_output, 2746 intel_sdvo_write_cmd(intel_encoder,
2741 SDVO_CMD_GET_BRIGHTNESS, NULL, 0); 2747 SDVO_CMD_GET_BRIGHTNESS, NULL, 0);
2742 status = intel_sdvo_read_response(intel_output, 2748 status = intel_sdvo_read_response(intel_encoder,
2743 &response, 2); 2749 &response, 2);
2744 if (status != SDVO_CMD_STATUS_SUCCESS) { 2750 if (status != SDVO_CMD_STATUS_SUCCESS) {
2745 DRM_DEBUG_KMS("Incorrect SDVO get brigh\n"); 2751 DRM_DEBUG_KMS("Incorrect SDVO get brigh\n");
@@ -2764,81 +2770,81 @@ static void intel_sdvo_create_enhance_property(struct drm_connector *connector)
2764 return; 2770 return;
2765} 2771}
2766 2772
2767bool intel_sdvo_init(struct drm_device *dev, int output_device) 2773bool intel_sdvo_init(struct drm_device *dev, int sdvo_reg)
2768{ 2774{
2769 struct drm_i915_private *dev_priv = dev->dev_private; 2775 struct drm_i915_private *dev_priv = dev->dev_private;
2770 struct drm_connector *connector; 2776 struct drm_connector *connector;
2771 struct intel_output *intel_output; 2777 struct intel_encoder *intel_encoder;
2772 struct intel_sdvo_priv *sdvo_priv; 2778 struct intel_sdvo_priv *sdvo_priv;
2773 2779
2774 u8 ch[0x40]; 2780 u8 ch[0x40];
2775 int i; 2781 int i;
2776 2782
2777 intel_output = kcalloc(sizeof(struct intel_output)+sizeof(struct intel_sdvo_priv), 1, GFP_KERNEL); 2783 intel_encoder = kcalloc(sizeof(struct intel_encoder)+sizeof(struct intel_sdvo_priv), 1, GFP_KERNEL);
2778 if (!intel_output) { 2784 if (!intel_encoder) {
2779 return false; 2785 return false;
2780 } 2786 }
2781 2787
2782 sdvo_priv = (struct intel_sdvo_priv *)(intel_output + 1); 2788 sdvo_priv = (struct intel_sdvo_priv *)(intel_encoder + 1);
2783 sdvo_priv->output_device = output_device; 2789 sdvo_priv->sdvo_reg = sdvo_reg;
2784 2790
2785 intel_output->dev_priv = sdvo_priv; 2791 intel_encoder->dev_priv = sdvo_priv;
2786 intel_output->type = INTEL_OUTPUT_SDVO; 2792 intel_encoder->type = INTEL_OUTPUT_SDVO;
2787 2793
2788 /* setup the DDC bus. */ 2794 /* setup the DDC bus. */
2789 if (output_device == SDVOB) 2795 if (sdvo_reg == SDVOB)
2790 intel_output->i2c_bus = intel_i2c_create(dev, GPIOE, "SDVOCTRL_E for SDVOB"); 2796 intel_encoder->i2c_bus = intel_i2c_create(dev, GPIOE, "SDVOCTRL_E for SDVOB");
2791 else 2797 else
2792 intel_output->i2c_bus = intel_i2c_create(dev, GPIOE, "SDVOCTRL_E for SDVOC"); 2798 intel_encoder->i2c_bus = intel_i2c_create(dev, GPIOE, "SDVOCTRL_E for SDVOC");
2793 2799
2794 if (!intel_output->i2c_bus) 2800 if (!intel_encoder->i2c_bus)
2795 goto err_inteloutput; 2801 goto err_inteloutput;
2796 2802
2797 sdvo_priv->slave_addr = intel_sdvo_get_slave_addr(dev, output_device); 2803 sdvo_priv->slave_addr = intel_sdvo_get_slave_addr(dev, sdvo_reg);
2798 2804
2799 /* Save the bit-banging i2c functionality for use by the DDC wrapper */ 2805 /* Save the bit-banging i2c functionality for use by the DDC wrapper */
2800 intel_sdvo_i2c_bit_algo.functionality = intel_output->i2c_bus->algo->functionality; 2806 intel_sdvo_i2c_bit_algo.functionality = intel_encoder->i2c_bus->algo->functionality;
2801 2807
2802 /* Read the regs to test if we can talk to the device */ 2808 /* Read the regs to test if we can talk to the device */
2803 for (i = 0; i < 0x40; i++) { 2809 for (i = 0; i < 0x40; i++) {
2804 if (!intel_sdvo_read_byte(intel_output, i, &ch[i])) { 2810 if (!intel_sdvo_read_byte(intel_encoder, i, &ch[i])) {
2805 DRM_DEBUG_KMS("No SDVO device found on SDVO%c\n", 2811 DRM_DEBUG_KMS("No SDVO device found on SDVO%c\n",
2806 output_device == SDVOB ? 'B' : 'C'); 2812 sdvo_reg == SDVOB ? 'B' : 'C');
2807 goto err_i2c; 2813 goto err_i2c;
2808 } 2814 }
2809 } 2815 }
2810 2816
2811 /* setup the DDC bus. */ 2817 /* setup the DDC bus. */
2812 if (output_device == SDVOB) { 2818 if (sdvo_reg == SDVOB) {
2813 intel_output->ddc_bus = intel_i2c_create(dev, GPIOE, "SDVOB DDC BUS"); 2819 intel_encoder->ddc_bus = intel_i2c_create(dev, GPIOE, "SDVOB DDC BUS");
2814 sdvo_priv->analog_ddc_bus = intel_i2c_create(dev, GPIOA, 2820 sdvo_priv->analog_ddc_bus = intel_i2c_create(dev, GPIOA,
2815 "SDVOB/VGA DDC BUS"); 2821 "SDVOB/VGA DDC BUS");
2816 dev_priv->hotplug_supported_mask |= SDVOB_HOTPLUG_INT_STATUS; 2822 dev_priv->hotplug_supported_mask |= SDVOB_HOTPLUG_INT_STATUS;
2817 } else { 2823 } else {
2818 intel_output->ddc_bus = intel_i2c_create(dev, GPIOE, "SDVOC DDC BUS"); 2824 intel_encoder->ddc_bus = intel_i2c_create(dev, GPIOE, "SDVOC DDC BUS");
2819 sdvo_priv->analog_ddc_bus = intel_i2c_create(dev, GPIOA, 2825 sdvo_priv->analog_ddc_bus = intel_i2c_create(dev, GPIOA,
2820 "SDVOC/VGA DDC BUS"); 2826 "SDVOC/VGA DDC BUS");
2821 dev_priv->hotplug_supported_mask |= SDVOC_HOTPLUG_INT_STATUS; 2827 dev_priv->hotplug_supported_mask |= SDVOC_HOTPLUG_INT_STATUS;
2822 } 2828 }
2823 2829
2824 if (intel_output->ddc_bus == NULL) 2830 if (intel_encoder->ddc_bus == NULL)
2825 goto err_i2c; 2831 goto err_i2c;
2826 2832
2827 /* Wrap with our custom algo which switches to DDC mode */ 2833 /* Wrap with our custom algo which switches to DDC mode */
2828 intel_output->ddc_bus->algo = &intel_sdvo_i2c_bit_algo; 2834 intel_encoder->ddc_bus->algo = &intel_sdvo_i2c_bit_algo;
2829 2835
2830 /* In default case sdvo lvds is false */ 2836 /* In default case sdvo lvds is false */
2831 intel_sdvo_get_capabilities(intel_output, &sdvo_priv->caps); 2837 intel_sdvo_get_capabilities(intel_encoder, &sdvo_priv->caps);
2832 2838
2833 if (intel_sdvo_output_setup(intel_output, 2839 if (intel_sdvo_output_setup(intel_encoder,
2834 sdvo_priv->caps.output_flags) != true) { 2840 sdvo_priv->caps.output_flags) != true) {
2835 DRM_DEBUG_KMS("SDVO output failed to setup on SDVO%c\n", 2841 DRM_DEBUG_KMS("SDVO output failed to setup on SDVO%c\n",
2836 output_device == SDVOB ? 'B' : 'C'); 2842 sdvo_reg == SDVOB ? 'B' : 'C');
2837 goto err_i2c; 2843 goto err_i2c;
2838 } 2844 }
2839 2845
2840 2846
2841 connector = &intel_output->base; 2847 connector = &intel_encoder->base;
2842 drm_connector_init(dev, connector, &intel_sdvo_connector_funcs, 2848 drm_connector_init(dev, connector, &intel_sdvo_connector_funcs,
2843 connector->connector_type); 2849 connector->connector_type);
2844 2850
@@ -2847,12 +2853,12 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
2847 connector->doublescan_allowed = 0; 2853 connector->doublescan_allowed = 0;
2848 connector->display_info.subpixel_order = SubPixelHorizontalRGB; 2854 connector->display_info.subpixel_order = SubPixelHorizontalRGB;
2849 2855
2850 drm_encoder_init(dev, &intel_output->enc, 2856 drm_encoder_init(dev, &intel_encoder->enc,
2851 &intel_sdvo_enc_funcs, intel_output->enc.encoder_type); 2857 &intel_sdvo_enc_funcs, intel_encoder->enc.encoder_type);
2852 2858
2853 drm_encoder_helper_add(&intel_output->enc, &intel_sdvo_helper_funcs); 2859 drm_encoder_helper_add(&intel_encoder->enc, &intel_sdvo_helper_funcs);
2854 2860
2855 drm_mode_connector_attach_encoder(&intel_output->base, &intel_output->enc); 2861 drm_mode_connector_attach_encoder(&intel_encoder->base, &intel_encoder->enc);
2856 if (sdvo_priv->is_tv) 2862 if (sdvo_priv->is_tv)
2857 intel_sdvo_tv_create_property(connector); 2863 intel_sdvo_tv_create_property(connector);
2858 2864
@@ -2864,9 +2870,9 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
2864 intel_sdvo_select_ddc_bus(sdvo_priv); 2870 intel_sdvo_select_ddc_bus(sdvo_priv);
2865 2871
2866 /* Set the input timing to the screen. Assume always input 0. */ 2872 /* Set the input timing to the screen. Assume always input 0. */
2867 intel_sdvo_set_target_input(intel_output, true, false); 2873 intel_sdvo_set_target_input(intel_encoder, true, false);
2868 2874
2869 intel_sdvo_get_input_pixel_clock_range(intel_output, 2875 intel_sdvo_get_input_pixel_clock_range(intel_encoder,
2870 &sdvo_priv->pixel_clock_min, 2876 &sdvo_priv->pixel_clock_min,
2871 &sdvo_priv->pixel_clock_max); 2877 &sdvo_priv->pixel_clock_max);
2872 2878
@@ -2893,12 +2899,12 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
2893err_i2c: 2899err_i2c:
2894 if (sdvo_priv->analog_ddc_bus != NULL) 2900 if (sdvo_priv->analog_ddc_bus != NULL)
2895 intel_i2c_destroy(sdvo_priv->analog_ddc_bus); 2901 intel_i2c_destroy(sdvo_priv->analog_ddc_bus);
2896 if (intel_output->ddc_bus != NULL) 2902 if (intel_encoder->ddc_bus != NULL)
2897 intel_i2c_destroy(intel_output->ddc_bus); 2903 intel_i2c_destroy(intel_encoder->ddc_bus);
2898 if (intel_output->i2c_bus != NULL) 2904 if (intel_encoder->i2c_bus != NULL)
2899 intel_i2c_destroy(intel_output->i2c_bus); 2905 intel_i2c_destroy(intel_encoder->i2c_bus);
2900err_inteloutput: 2906err_inteloutput:
2901 kfree(intel_output); 2907 kfree(intel_encoder);
2902 2908
2903 return false; 2909 return false;
2904} 2910}
diff --git a/drivers/gpu/drm/i915/intel_tv.c b/drivers/gpu/drm/i915/intel_tv.c
index 552ec110b74..d7d39b2327d 100644
--- a/drivers/gpu/drm/i915/intel_tv.c
+++ b/drivers/gpu/drm/i915/intel_tv.c
@@ -921,8 +921,8 @@ intel_tv_save(struct drm_connector *connector)
921{ 921{
922 struct drm_device *dev = connector->dev; 922 struct drm_device *dev = connector->dev;
923 struct drm_i915_private *dev_priv = dev->dev_private; 923 struct drm_i915_private *dev_priv = dev->dev_private;
924 struct intel_output *intel_output = to_intel_output(connector); 924 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
925 struct intel_tv_priv *tv_priv = intel_output->dev_priv; 925 struct intel_tv_priv *tv_priv = intel_encoder->dev_priv;
926 int i; 926 int i;
927 927
928 tv_priv->save_TV_H_CTL_1 = I915_READ(TV_H_CTL_1); 928 tv_priv->save_TV_H_CTL_1 = I915_READ(TV_H_CTL_1);
@@ -971,8 +971,8 @@ intel_tv_restore(struct drm_connector *connector)
971{ 971{
972 struct drm_device *dev = connector->dev; 972 struct drm_device *dev = connector->dev;
973 struct drm_i915_private *dev_priv = dev->dev_private; 973 struct drm_i915_private *dev_priv = dev->dev_private;
974 struct intel_output *intel_output = to_intel_output(connector); 974 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
975 struct intel_tv_priv *tv_priv = intel_output->dev_priv; 975 struct intel_tv_priv *tv_priv = intel_encoder->dev_priv;
976 struct drm_crtc *crtc = connector->encoder->crtc; 976 struct drm_crtc *crtc = connector->encoder->crtc;
977 struct intel_crtc *intel_crtc; 977 struct intel_crtc *intel_crtc;
978 int i; 978 int i;
@@ -1068,9 +1068,9 @@ intel_tv_mode_lookup (char *tv_format)
1068} 1068}
1069 1069
1070static const struct tv_mode * 1070static const struct tv_mode *
1071intel_tv_mode_find (struct intel_output *intel_output) 1071intel_tv_mode_find (struct intel_encoder *intel_encoder)
1072{ 1072{
1073 struct intel_tv_priv *tv_priv = intel_output->dev_priv; 1073 struct intel_tv_priv *tv_priv = intel_encoder->dev_priv;
1074 1074
1075 return intel_tv_mode_lookup(tv_priv->tv_format); 1075 return intel_tv_mode_lookup(tv_priv->tv_format);
1076} 1076}
@@ -1078,8 +1078,8 @@ intel_tv_mode_find (struct intel_output *intel_output)
1078static enum drm_mode_status 1078static enum drm_mode_status
1079intel_tv_mode_valid(struct drm_connector *connector, struct drm_display_mode *mode) 1079intel_tv_mode_valid(struct drm_connector *connector, struct drm_display_mode *mode)
1080{ 1080{
1081 struct intel_output *intel_output = to_intel_output(connector); 1081 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
1082 const struct tv_mode *tv_mode = intel_tv_mode_find(intel_output); 1082 const struct tv_mode *tv_mode = intel_tv_mode_find(intel_encoder);
1083 1083
1084 /* Ensure TV refresh is close to desired refresh */ 1084 /* Ensure TV refresh is close to desired refresh */
1085 if (tv_mode && abs(tv_mode->refresh - drm_mode_vrefresh(mode) * 1000) 1085 if (tv_mode && abs(tv_mode->refresh - drm_mode_vrefresh(mode) * 1000)
@@ -1095,8 +1095,8 @@ intel_tv_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode,
1095{ 1095{
1096 struct drm_device *dev = encoder->dev; 1096 struct drm_device *dev = encoder->dev;
1097 struct drm_mode_config *drm_config = &dev->mode_config; 1097 struct drm_mode_config *drm_config = &dev->mode_config;
1098 struct intel_output *intel_output = enc_to_intel_output(encoder); 1098 struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder);
1099 const struct tv_mode *tv_mode = intel_tv_mode_find (intel_output); 1099 const struct tv_mode *tv_mode = intel_tv_mode_find (intel_encoder);
1100 struct drm_encoder *other_encoder; 1100 struct drm_encoder *other_encoder;
1101 1101
1102 if (!tv_mode) 1102 if (!tv_mode)
@@ -1121,9 +1121,9 @@ intel_tv_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode,
1121 struct drm_i915_private *dev_priv = dev->dev_private; 1121 struct drm_i915_private *dev_priv = dev->dev_private;
1122 struct drm_crtc *crtc = encoder->crtc; 1122 struct drm_crtc *crtc = encoder->crtc;
1123 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 1123 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
1124 struct intel_output *intel_output = enc_to_intel_output(encoder); 1124 struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder);
1125 struct intel_tv_priv *tv_priv = intel_output->dev_priv; 1125 struct intel_tv_priv *tv_priv = intel_encoder->dev_priv;
1126 const struct tv_mode *tv_mode = intel_tv_mode_find(intel_output); 1126 const struct tv_mode *tv_mode = intel_tv_mode_find(intel_encoder);
1127 u32 tv_ctl; 1127 u32 tv_ctl;
1128 u32 hctl1, hctl2, hctl3; 1128 u32 hctl1, hctl2, hctl3;
1129 u32 vctl1, vctl2, vctl3, vctl4, vctl5, vctl6, vctl7; 1129 u32 vctl1, vctl2, vctl3, vctl4, vctl5, vctl6, vctl7;
@@ -1360,9 +1360,9 @@ static const struct drm_display_mode reported_modes[] = {
1360 * \return false if TV is disconnected. 1360 * \return false if TV is disconnected.
1361 */ 1361 */
1362static int 1362static int
1363intel_tv_detect_type (struct drm_crtc *crtc, struct intel_output *intel_output) 1363intel_tv_detect_type (struct drm_crtc *crtc, struct intel_encoder *intel_encoder)
1364{ 1364{
1365 struct drm_encoder *encoder = &intel_output->enc; 1365 struct drm_encoder *encoder = &intel_encoder->enc;
1366 struct drm_device *dev = encoder->dev; 1366 struct drm_device *dev = encoder->dev;
1367 struct drm_i915_private *dev_priv = dev->dev_private; 1367 struct drm_i915_private *dev_priv = dev->dev_private;
1368 unsigned long irqflags; 1368 unsigned long irqflags;
@@ -1441,9 +1441,9 @@ intel_tv_detect_type (struct drm_crtc *crtc, struct intel_output *intel_output)
1441 */ 1441 */
1442static void intel_tv_find_better_format(struct drm_connector *connector) 1442static void intel_tv_find_better_format(struct drm_connector *connector)
1443{ 1443{
1444 struct intel_output *intel_output = to_intel_output(connector); 1444 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
1445 struct intel_tv_priv *tv_priv = intel_output->dev_priv; 1445 struct intel_tv_priv *tv_priv = intel_encoder->dev_priv;
1446 const struct tv_mode *tv_mode = intel_tv_mode_find(intel_output); 1446 const struct tv_mode *tv_mode = intel_tv_mode_find(intel_encoder);
1447 int i; 1447 int i;
1448 1448
1449 if ((tv_priv->type == DRM_MODE_CONNECTOR_Component) == 1449 if ((tv_priv->type == DRM_MODE_CONNECTOR_Component) ==
@@ -1475,9 +1475,9 @@ intel_tv_detect(struct drm_connector *connector)
1475{ 1475{
1476 struct drm_crtc *crtc; 1476 struct drm_crtc *crtc;
1477 struct drm_display_mode mode; 1477 struct drm_display_mode mode;
1478 struct intel_output *intel_output = to_intel_output(connector); 1478 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
1479 struct intel_tv_priv *tv_priv = intel_output->dev_priv; 1479 struct intel_tv_priv *tv_priv = intel_encoder->dev_priv;
1480 struct drm_encoder *encoder = &intel_output->enc; 1480 struct drm_encoder *encoder = &intel_encoder->enc;
1481 int dpms_mode; 1481 int dpms_mode;
1482 int type = tv_priv->type; 1482 int type = tv_priv->type;
1483 1483
@@ -1485,12 +1485,12 @@ intel_tv_detect(struct drm_connector *connector)
1485 drm_mode_set_crtcinfo(&mode, CRTC_INTERLACE_HALVE_V); 1485 drm_mode_set_crtcinfo(&mode, CRTC_INTERLACE_HALVE_V);
1486 1486
1487 if (encoder->crtc && encoder->crtc->enabled) { 1487 if (encoder->crtc && encoder->crtc->enabled) {
1488 type = intel_tv_detect_type(encoder->crtc, intel_output); 1488 type = intel_tv_detect_type(encoder->crtc, intel_encoder);
1489 } else { 1489 } else {
1490 crtc = intel_get_load_detect_pipe(intel_output, &mode, &dpms_mode); 1490 crtc = intel_get_load_detect_pipe(intel_encoder, &mode, &dpms_mode);
1491 if (crtc) { 1491 if (crtc) {
1492 type = intel_tv_detect_type(crtc, intel_output); 1492 type = intel_tv_detect_type(crtc, intel_encoder);
1493 intel_release_load_detect_pipe(intel_output, dpms_mode); 1493 intel_release_load_detect_pipe(intel_encoder, dpms_mode);
1494 } else 1494 } else
1495 type = -1; 1495 type = -1;
1496 } 1496 }
@@ -1525,8 +1525,8 @@ static void
1525intel_tv_chose_preferred_modes(struct drm_connector *connector, 1525intel_tv_chose_preferred_modes(struct drm_connector *connector,
1526 struct drm_display_mode *mode_ptr) 1526 struct drm_display_mode *mode_ptr)
1527{ 1527{
1528 struct intel_output *intel_output = to_intel_output(connector); 1528 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
1529 const struct tv_mode *tv_mode = intel_tv_mode_find(intel_output); 1529 const struct tv_mode *tv_mode = intel_tv_mode_find(intel_encoder);
1530 1530
1531 if (tv_mode->nbr_end < 480 && mode_ptr->vdisplay == 480) 1531 if (tv_mode->nbr_end < 480 && mode_ptr->vdisplay == 480)
1532 mode_ptr->type |= DRM_MODE_TYPE_PREFERRED; 1532 mode_ptr->type |= DRM_MODE_TYPE_PREFERRED;
@@ -1550,8 +1550,8 @@ static int
1550intel_tv_get_modes(struct drm_connector *connector) 1550intel_tv_get_modes(struct drm_connector *connector)
1551{ 1551{
1552 struct drm_display_mode *mode_ptr; 1552 struct drm_display_mode *mode_ptr;
1553 struct intel_output *intel_output = to_intel_output(connector); 1553 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
1554 const struct tv_mode *tv_mode = intel_tv_mode_find(intel_output); 1554 const struct tv_mode *tv_mode = intel_tv_mode_find(intel_encoder);
1555 int j, count = 0; 1555 int j, count = 0;
1556 u64 tmp; 1556 u64 tmp;
1557 1557
@@ -1604,11 +1604,11 @@ intel_tv_get_modes(struct drm_connector *connector)
1604static void 1604static void
1605intel_tv_destroy (struct drm_connector *connector) 1605intel_tv_destroy (struct drm_connector *connector)
1606{ 1606{
1607 struct intel_output *intel_output = to_intel_output(connector); 1607 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
1608 1608
1609 drm_sysfs_connector_remove(connector); 1609 drm_sysfs_connector_remove(connector);
1610 drm_connector_cleanup(connector); 1610 drm_connector_cleanup(connector);
1611 kfree(intel_output); 1611 kfree(intel_encoder);
1612} 1612}
1613 1613
1614 1614
@@ -1617,9 +1617,9 @@ intel_tv_set_property(struct drm_connector *connector, struct drm_property *prop
1617 uint64_t val) 1617 uint64_t val)
1618{ 1618{
1619 struct drm_device *dev = connector->dev; 1619 struct drm_device *dev = connector->dev;
1620 struct intel_output *intel_output = to_intel_output(connector); 1620 struct intel_encoder *intel_encoder = to_intel_encoder(connector);
1621 struct intel_tv_priv *tv_priv = intel_output->dev_priv; 1621 struct intel_tv_priv *tv_priv = intel_encoder->dev_priv;
1622 struct drm_encoder *encoder = &intel_output->enc; 1622 struct drm_encoder *encoder = &intel_encoder->enc;
1623 struct drm_crtc *crtc = encoder->crtc; 1623 struct drm_crtc *crtc = encoder->crtc;
1624 int ret = 0; 1624 int ret = 0;
1625 bool changed = false; 1625 bool changed = false;
@@ -1740,7 +1740,7 @@ intel_tv_init(struct drm_device *dev)
1740{ 1740{
1741 struct drm_i915_private *dev_priv = dev->dev_private; 1741 struct drm_i915_private *dev_priv = dev->dev_private;
1742 struct drm_connector *connector; 1742 struct drm_connector *connector;
1743 struct intel_output *intel_output; 1743 struct intel_encoder *intel_encoder;
1744 struct intel_tv_priv *tv_priv; 1744 struct intel_tv_priv *tv_priv;
1745 u32 tv_dac_on, tv_dac_off, save_tv_dac; 1745 u32 tv_dac_on, tv_dac_off, save_tv_dac;
1746 char **tv_format_names; 1746 char **tv_format_names;
@@ -1780,28 +1780,28 @@ intel_tv_init(struct drm_device *dev)
1780 (tv_dac_off & TVDAC_STATE_CHG_EN) != 0) 1780 (tv_dac_off & TVDAC_STATE_CHG_EN) != 0)
1781 return; 1781 return;
1782 1782
1783 intel_output = kzalloc(sizeof(struct intel_output) + 1783 intel_encoder = kzalloc(sizeof(struct intel_encoder) +
1784 sizeof(struct intel_tv_priv), GFP_KERNEL); 1784 sizeof(struct intel_tv_priv), GFP_KERNEL);
1785 if (!intel_output) { 1785 if (!intel_encoder) {
1786 return; 1786 return;
1787 } 1787 }
1788 1788
1789 connector = &intel_output->base; 1789 connector = &intel_encoder->base;
1790 1790
1791 drm_connector_init(dev, connector, &intel_tv_connector_funcs, 1791 drm_connector_init(dev, connector, &intel_tv_connector_funcs,
1792 DRM_MODE_CONNECTOR_SVIDEO); 1792 DRM_MODE_CONNECTOR_SVIDEO);
1793 1793
1794 drm_encoder_init(dev, &intel_output->enc, &intel_tv_enc_funcs, 1794 drm_encoder_init(dev, &intel_encoder->enc, &intel_tv_enc_funcs,
1795 DRM_MODE_ENCODER_TVDAC); 1795 DRM_MODE_ENCODER_TVDAC);
1796 1796
1797 drm_mode_connector_attach_encoder(&intel_output->base, &intel_output->enc); 1797 drm_mode_connector_attach_encoder(&intel_encoder->base, &intel_encoder->enc);
1798 tv_priv = (struct intel_tv_priv *)(intel_output + 1); 1798 tv_priv = (struct intel_tv_priv *)(intel_encoder + 1);
1799 intel_output->type = INTEL_OUTPUT_TVOUT; 1799 intel_encoder->type = INTEL_OUTPUT_TVOUT;
1800 intel_output->crtc_mask = (1 << 0) | (1 << 1); 1800 intel_encoder->crtc_mask = (1 << 0) | (1 << 1);
1801 intel_output->clone_mask = (1 << INTEL_TV_CLONE_BIT); 1801 intel_encoder->clone_mask = (1 << INTEL_TV_CLONE_BIT);
1802 intel_output->enc.possible_crtcs = ((1 << 0) | (1 << 1)); 1802 intel_encoder->enc.possible_crtcs = ((1 << 0) | (1 << 1));
1803 intel_output->enc.possible_clones = (1 << INTEL_OUTPUT_TVOUT); 1803 intel_encoder->enc.possible_clones = (1 << INTEL_OUTPUT_TVOUT);
1804 intel_output->dev_priv = tv_priv; 1804 intel_encoder->dev_priv = tv_priv;
1805 tv_priv->type = DRM_MODE_CONNECTOR_Unknown; 1805 tv_priv->type = DRM_MODE_CONNECTOR_Unknown;
1806 1806
1807 /* BIOS margin values */ 1807 /* BIOS margin values */
@@ -1812,7 +1812,7 @@ intel_tv_init(struct drm_device *dev)
1812 1812
1813 tv_priv->tv_format = kstrdup(tv_modes[initial_mode].name, GFP_KERNEL); 1813 tv_priv->tv_format = kstrdup(tv_modes[initial_mode].name, GFP_KERNEL);
1814 1814
1815 drm_encoder_helper_add(&intel_output->enc, &intel_tv_helper_funcs); 1815 drm_encoder_helper_add(&intel_encoder->enc, &intel_tv_helper_funcs);
1816 drm_connector_helper_add(connector, &intel_tv_connector_helper_funcs); 1816 drm_connector_helper_add(connector, &intel_tv_connector_helper_funcs);
1817 connector->interlace_allowed = false; 1817 connector->interlace_allowed = false;
1818 connector->doublescan_allowed = false; 1818 connector->doublescan_allowed = false;
diff --git a/drivers/gpu/drm/nouveau/Makefile b/drivers/gpu/drm/nouveau/Makefile
index 32db806f3b5..453df3f6053 100644
--- a/drivers/gpu/drm/nouveau/Makefile
+++ b/drivers/gpu/drm/nouveau/Makefile
@@ -12,7 +12,7 @@ nouveau-y := nouveau_drv.o nouveau_state.o nouveau_channel.o nouveau_mem.o \
12 nouveau_dp.o nouveau_grctx.o \ 12 nouveau_dp.o nouveau_grctx.o \
13 nv04_timer.o \ 13 nv04_timer.o \
14 nv04_mc.o nv40_mc.o nv50_mc.o \ 14 nv04_mc.o nv40_mc.o nv50_mc.o \
15 nv04_fb.o nv10_fb.o nv40_fb.o \ 15 nv04_fb.o nv10_fb.o nv40_fb.o nv50_fb.o \
16 nv04_fifo.o nv10_fifo.o nv40_fifo.o nv50_fifo.o \ 16 nv04_fifo.o nv10_fifo.o nv40_fifo.o nv50_fifo.o \
17 nv04_graph.o nv10_graph.o nv20_graph.o \ 17 nv04_graph.o nv10_graph.o nv20_graph.o \
18 nv40_graph.o nv50_graph.o \ 18 nv40_graph.o nv50_graph.o \
@@ -22,7 +22,7 @@ nouveau-y := nouveau_drv.o nouveau_state.o nouveau_channel.o nouveau_mem.o \
22 nv50_cursor.o nv50_display.o nv50_fbcon.o \ 22 nv50_cursor.o nv50_display.o nv50_fbcon.o \
23 nv04_dac.o nv04_dfp.o nv04_tv.o nv17_tv.o nv17_tv_modes.o \ 23 nv04_dac.o nv04_dfp.o nv04_tv.o nv17_tv.o nv17_tv_modes.o \
24 nv04_crtc.o nv04_display.o nv04_cursor.o nv04_fbcon.o \ 24 nv04_crtc.o nv04_display.o nv04_cursor.o nv04_fbcon.o \
25 nv17_gpio.o 25 nv17_gpio.o nv50_gpio.o
26 26
27nouveau-$(CONFIG_DRM_NOUVEAU_DEBUG) += nouveau_debugfs.o 27nouveau-$(CONFIG_DRM_NOUVEAU_DEBUG) += nouveau_debugfs.o
28nouveau-$(CONFIG_COMPAT) += nouveau_ioc32.o 28nouveau-$(CONFIG_COMPAT) += nouveau_ioc32.o
diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.c b/drivers/gpu/drm/nouveau/nouveau_acpi.c
index 0e0730a5313..e13f6af0037 100644
--- a/drivers/gpu/drm/nouveau/nouveau_acpi.c
+++ b/drivers/gpu/drm/nouveau/nouveau_acpi.c
@@ -1,5 +1,6 @@
1#include <linux/pci.h> 1#include <linux/pci.h>
2#include <linux/acpi.h> 2#include <linux/acpi.h>
3#include <linux/slab.h>
3#include <acpi/acpi_drivers.h> 4#include <acpi/acpi_drivers.h>
4#include <acpi/acpi_bus.h> 5#include <acpi/acpi_bus.h>
5 6
diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
index 75bceee7604..abc382a9918 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bios.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
@@ -2573,48 +2573,34 @@ init_gpio(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
2573 * each GPIO according to various values listed in each entry 2573 * each GPIO according to various values listed in each entry
2574 */ 2574 */
2575 2575
2576 const uint32_t nv50_gpio_reg[4] = { 0xe104, 0xe108, 0xe280, 0xe284 }; 2576 struct drm_nouveau_private *dev_priv = bios->dev->dev_private;
2577 const uint32_t nv50_gpio_ctl[2] = { 0xe100, 0xe28c }; 2577 const uint32_t nv50_gpio_ctl[2] = { 0xe100, 0xe28c };
2578 const uint8_t *gpio_table = &bios->data[bios->dcb.gpio_table_ptr];
2579 const uint8_t *gpio_entry;
2580 int i; 2578 int i;
2581 2579
2582 if (!iexec->execute) 2580 if (dev_priv->card_type != NV_50) {
2583 return 1; 2581 NV_ERROR(bios->dev, "INIT_GPIO on unsupported chipset\n");
2584 2582 return -ENODEV;
2585 if (bios->dcb.version != 0x40) {
2586 NV_ERROR(bios->dev, "DCB table not version 4.0\n");
2587 return 0;
2588 } 2583 }
2589 2584
2590 if (!bios->dcb.gpio_table_ptr) { 2585 if (!iexec->execute)
2591 NV_WARN(bios->dev, "Invalid pointer to INIT_8E table\n"); 2586 return 1;
2592 return 0;
2593 }
2594 2587
2595 gpio_entry = gpio_table + gpio_table[1]; 2588 for (i = 0; i < bios->dcb.gpio.entries; i++) {
2596 for (i = 0; i < gpio_table[2]; i++, gpio_entry += gpio_table[3]) { 2589 struct dcb_gpio_entry *gpio = &bios->dcb.gpio.entry[i];
2597 uint32_t entry = ROM32(gpio_entry[0]), r, s, v; 2590 uint32_t r, s, v;
2598 int line = (entry & 0x0000001f);
2599 2591
2600 BIOSLOG(bios, "0x%04X: Entry: 0x%08X\n", offset, entry); 2592 BIOSLOG(bios, "0x%04X: Entry: 0x%08X\n", offset, gpio->entry);
2601 2593
2602 if ((entry & 0x0000ff00) == 0x0000ff00) 2594 nv50_gpio_set(bios->dev, gpio->tag, gpio->state_default);
2603 continue;
2604 2595
2605 r = nv50_gpio_reg[line >> 3]; 2596 /* The NVIDIA binary driver doesn't appear to actually do
2606 s = (line & 0x07) << 2; 2597 * any of this, my VBIOS does however.
2607 v = bios_rd32(bios, r) & ~(0x00000003 << s); 2598 */
2608 if (entry & 0x01000000) 2599 /* Not a clue, needs de-magicing */
2609 v |= (((entry & 0x60000000) >> 29) ^ 2) << s; 2600 r = nv50_gpio_ctl[gpio->line >> 4];
2610 else 2601 s = (gpio->line & 0x0f);
2611 v |= (((entry & 0x18000000) >> 27) ^ 2) << s;
2612 bios_wr32(bios, r, v);
2613
2614 r = nv50_gpio_ctl[line >> 4];
2615 s = (line & 0x0f);
2616 v = bios_rd32(bios, r) & ~(0x00010001 << s); 2602 v = bios_rd32(bios, r) & ~(0x00010001 << s);
2617 switch ((entry & 0x06000000) >> 25) { 2603 switch ((gpio->entry & 0x06000000) >> 25) {
2618 case 1: 2604 case 1:
2619 v |= (0x00000001 << s); 2605 v |= (0x00000001 << s);
2620 break; 2606 break;
@@ -3198,7 +3184,6 @@ static int run_lvds_table(struct drm_device *dev, struct dcb_entry *dcbent, int
3198 struct nvbios *bios = &dev_priv->vbios; 3184 struct nvbios *bios = &dev_priv->vbios;
3199 unsigned int outputset = (dcbent->or == 4) ? 1 : 0; 3185 unsigned int outputset = (dcbent->or == 4) ? 1 : 0;
3200 uint16_t scriptptr = 0, clktable; 3186 uint16_t scriptptr = 0, clktable;
3201 uint8_t clktableptr = 0;
3202 3187
3203 /* 3188 /*
3204 * For now we assume version 3.0 table - g80 support will need some 3189 * For now we assume version 3.0 table - g80 support will need some
@@ -3217,26 +3202,29 @@ static int run_lvds_table(struct drm_device *dev, struct dcb_entry *dcbent, int
3217 scriptptr = ROM16(bios->data[bios->fp.lvdsmanufacturerpointer + 11 + outputset * 2]); 3202 scriptptr = ROM16(bios->data[bios->fp.lvdsmanufacturerpointer + 11 + outputset * 2]);
3218 break; 3203 break;
3219 case LVDS_RESET: 3204 case LVDS_RESET:
3205 clktable = bios->fp.lvdsmanufacturerpointer + 15;
3206 if (dcbent->or == 4)
3207 clktable += 8;
3208
3220 if (dcbent->lvdsconf.use_straps_for_mode) { 3209 if (dcbent->lvdsconf.use_straps_for_mode) {
3221 if (bios->fp.dual_link) 3210 if (bios->fp.dual_link)
3222 clktableptr += 2; 3211 clktable += 4;
3223 if (bios->fp.BITbit1) 3212 if (bios->fp.if_is_24bit)
3224 clktableptr++; 3213 clktable += 2;
3225 } else { 3214 } else {
3226 /* using EDID */ 3215 /* using EDID */
3227 uint8_t fallback = bios->data[bios->fp.lvdsmanufacturerpointer + 4]; 3216 int cmpval_24bit = (dcbent->or == 4) ? 4 : 1;
3228 int fallbackcmpval = (dcbent->or == 4) ? 4 : 1;
3229 3217
3230 if (bios->fp.dual_link) { 3218 if (bios->fp.dual_link) {
3231 clktableptr += 2; 3219 clktable += 4;
3232 fallbackcmpval *= 2; 3220 cmpval_24bit <<= 1;
3233 } 3221 }
3234 if (fallbackcmpval & fallback) 3222
3235 clktableptr++; 3223 if (bios->fp.strapless_is_24bit & cmpval_24bit)
3224 clktable += 2;
3236 } 3225 }
3237 3226
3238 /* adding outputset * 8 may not be correct */ 3227 clktable = ROM16(bios->data[clktable]);
3239 clktable = ROM16(bios->data[bios->fp.lvdsmanufacturerpointer + 15 + clktableptr * 2 + outputset * 8]);
3240 if (!clktable) { 3228 if (!clktable) {
3241 NV_ERROR(dev, "Pixel clock comparison table not found\n"); 3229 NV_ERROR(dev, "Pixel clock comparison table not found\n");
3242 return -ENOENT; 3230 return -ENOENT;
@@ -3638,37 +3626,40 @@ int nouveau_bios_parse_lvds_table(struct drm_device *dev, int pxclk, bool *dl, b
3638 *if_is_24bit = bios->data[lvdsofs] & 16; 3626 *if_is_24bit = bios->data[lvdsofs] & 16;
3639 break; 3627 break;
3640 case 0x30: 3628 case 0x30:
3641 /* 3629 case 0x40:
3642 * My money would be on there being a 24 bit interface bit in
3643 * this table, but I have no example of a laptop bios with a
3644 * 24 bit panel to confirm that. Hence we shout loudly if any
3645 * bit other than bit 0 is set (I've not even seen bit 1)
3646 */
3647 if (bios->data[lvdsofs] > 1)
3648 NV_ERROR(dev,
3649 "You have a very unusual laptop display; please report it\n");
3650 /* 3630 /*
3651 * No sign of the "power off for reset" or "reset for panel 3631 * No sign of the "power off for reset" or "reset for panel
3652 * on" bits, but it's safer to assume we should 3632 * on" bits, but it's safer to assume we should
3653 */ 3633 */
3654 bios->fp.power_off_for_reset = true; 3634 bios->fp.power_off_for_reset = true;
3655 bios->fp.reset_after_pclk_change = true; 3635 bios->fp.reset_after_pclk_change = true;
3636
3656 /* 3637 /*
3657 * It's ok lvdsofs is wrong for nv4x edid case; dual_link is 3638 * It's ok lvdsofs is wrong for nv4x edid case; dual_link is
3658 * over-written, and BITbit1 isn't used 3639 * over-written, and if_is_24bit isn't used
3659 */ 3640 */
3660 bios->fp.dual_link = bios->data[lvdsofs] & 1; 3641 bios->fp.dual_link = bios->data[lvdsofs] & 1;
3661 bios->fp.BITbit1 = bios->data[lvdsofs] & 2;
3662 bios->fp.duallink_transition_clk = ROM16(bios->data[bios->fp.lvdsmanufacturerpointer + 5]) * 10;
3663 break;
3664 case 0x40:
3665 bios->fp.dual_link = bios->data[lvdsofs] & 1;
3666 bios->fp.if_is_24bit = bios->data[lvdsofs] & 2; 3642 bios->fp.if_is_24bit = bios->data[lvdsofs] & 2;
3667 bios->fp.strapless_is_24bit = bios->data[bios->fp.lvdsmanufacturerpointer + 4]; 3643 bios->fp.strapless_is_24bit = bios->data[bios->fp.lvdsmanufacturerpointer + 4];
3668 bios->fp.duallink_transition_clk = ROM16(bios->data[bios->fp.lvdsmanufacturerpointer + 5]) * 10; 3644 bios->fp.duallink_transition_clk = ROM16(bios->data[bios->fp.lvdsmanufacturerpointer + 5]) * 10;
3669 break; 3645 break;
3670 } 3646 }
3671 3647
3648 /* Dell Latitude D620 reports a too-high value for the dual-link
3649 * transition freq, causing us to program the panel incorrectly.
3650 *
3651 * It doesn't appear the VBIOS actually uses its transition freq
3652 * (90000kHz), instead it uses the "Number of LVDS channels" field
3653 * out of the panel ID structure (http://www.spwg.org/).
3654 *
3655 * For the moment, a quirk will do :)
3656 */
3657 if ((dev->pdev->device == 0x01d7) &&
3658 (dev->pdev->subsystem_vendor == 0x1028) &&
3659 (dev->pdev->subsystem_device == 0x01c2)) {
3660 bios->fp.duallink_transition_clk = 80000;
3661 }
3662
3672 /* set dual_link flag for EDID case */ 3663 /* set dual_link flag for EDID case */
3673 if (pxclk && (chip_version < 0x25 || chip_version > 0x28)) 3664 if (pxclk && (chip_version < 0x25 || chip_version > 0x28))
3674 bios->fp.dual_link = (pxclk >= bios->fp.duallink_transition_clk); 3665 bios->fp.dual_link = (pxclk >= bios->fp.duallink_transition_clk);
@@ -5077,25 +5068,25 @@ parse_dcb30_gpio_entry(struct nvbios *bios, uint16_t offset)
5077 gpio->tag = tag; 5068 gpio->tag = tag;
5078 gpio->line = line; 5069 gpio->line = line;
5079 gpio->invert = flags != 4; 5070 gpio->invert = flags != 4;
5071 gpio->entry = ent;
5080} 5072}
5081 5073
5082static void 5074static void
5083parse_dcb40_gpio_entry(struct nvbios *bios, uint16_t offset) 5075parse_dcb40_gpio_entry(struct nvbios *bios, uint16_t offset)
5084{ 5076{
5077 uint32_t entry = ROM32(bios->data[offset]);
5085 struct dcb_gpio_entry *gpio; 5078 struct dcb_gpio_entry *gpio;
5086 uint32_t ent = ROM32(bios->data[offset]);
5087 uint8_t line = ent & 0x1f,
5088 tag = ent >> 8 & 0xff;
5089 5079
5090 if (tag == 0xff) 5080 if ((entry & 0x0000ff00) == 0x0000ff00)
5091 return; 5081 return;
5092 5082
5093 gpio = new_gpio_entry(bios); 5083 gpio = new_gpio_entry(bios);
5094 5084 gpio->tag = (entry & 0x0000ff00) >> 8;
5095 /* Currently unused, we may need more fields parsed at some 5085 gpio->line = (entry & 0x0000001f) >> 0;
5096 * point. */ 5086 gpio->state_default = (entry & 0x01000000) >> 24;
5097 gpio->tag = tag; 5087 gpio->state[0] = (entry & 0x18000000) >> 27;
5098 gpio->line = line; 5088 gpio->state[1] = (entry & 0x60000000) >> 29;
5089 gpio->entry = entry;
5099} 5090}
5100 5091
5101static void 5092static void
@@ -5211,6 +5202,21 @@ divine_connector_type(struct nvbios *bios, int index)
5211} 5202}
5212 5203
5213static void 5204static void
5205apply_dcb_connector_quirks(struct nvbios *bios, int idx)
5206{
5207 struct dcb_connector_table_entry *cte = &bios->dcb.connector.entry[idx];
5208 struct drm_device *dev = bios->dev;
5209
5210 /* Gigabyte NX85T */
5211 if ((dev->pdev->device == 0x0421) &&
5212 (dev->pdev->subsystem_vendor == 0x1458) &&
5213 (dev->pdev->subsystem_device == 0x344c)) {
5214 if (cte->type == DCB_CONNECTOR_HDMI_1)
5215 cte->type = DCB_CONNECTOR_DVI_I;
5216 }
5217}
5218
5219static void
5214parse_dcb_connector_table(struct nvbios *bios) 5220parse_dcb_connector_table(struct nvbios *bios)
5215{ 5221{
5216 struct drm_device *dev = bios->dev; 5222 struct drm_device *dev = bios->dev;
@@ -5238,13 +5244,14 @@ parse_dcb_connector_table(struct nvbios *bios)
5238 entry = conntab + conntab[1]; 5244 entry = conntab + conntab[1];
5239 cte = &ct->entry[0]; 5245 cte = &ct->entry[0];
5240 for (i = 0; i < conntab[2]; i++, entry += conntab[3], cte++) { 5246 for (i = 0; i < conntab[2]; i++, entry += conntab[3], cte++) {
5247 cte->index = i;
5241 if (conntab[3] == 2) 5248 if (conntab[3] == 2)
5242 cte->entry = ROM16(entry[0]); 5249 cte->entry = ROM16(entry[0]);
5243 else 5250 else
5244 cte->entry = ROM32(entry[0]); 5251 cte->entry = ROM32(entry[0]);
5245 5252
5246 cte->type = (cte->entry & 0x000000ff) >> 0; 5253 cte->type = (cte->entry & 0x000000ff) >> 0;
5247 cte->index = (cte->entry & 0x00000f00) >> 8; 5254 cte->index2 = (cte->entry & 0x00000f00) >> 8;
5248 switch (cte->entry & 0x00033000) { 5255 switch (cte->entry & 0x00033000) {
5249 case 0x00001000: 5256 case 0x00001000:
5250 cte->gpio_tag = 0x07; 5257 cte->gpio_tag = 0x07;
@@ -5266,6 +5273,8 @@ parse_dcb_connector_table(struct nvbios *bios)
5266 if (cte->type == 0xff) 5273 if (cte->type == 0xff)
5267 continue; 5274 continue;
5268 5275
5276 apply_dcb_connector_quirks(bios, i);
5277
5269 NV_INFO(dev, " %d: 0x%08x: type 0x%02x idx %d tag 0x%02x\n", 5278 NV_INFO(dev, " %d: 0x%08x: type 0x%02x idx %d tag 0x%02x\n",
5270 i, cte->entry, cte->type, cte->index, cte->gpio_tag); 5279 i, cte->entry, cte->type, cte->index, cte->gpio_tag);
5271 5280
@@ -5287,10 +5296,16 @@ parse_dcb_connector_table(struct nvbios *bios)
5287 break; 5296 break;
5288 default: 5297 default:
5289 cte->type = divine_connector_type(bios, cte->index); 5298 cte->type = divine_connector_type(bios, cte->index);
5290 NV_WARN(dev, "unknown type, using 0x%02x", cte->type); 5299 NV_WARN(dev, "unknown type, using 0x%02x\n", cte->type);
5291 break; 5300 break;
5292 } 5301 }
5293 5302
5303 if (nouveau_override_conntype) {
5304 int type = divine_connector_type(bios, cte->index);
5305 if (type != cte->type)
5306 NV_WARN(dev, " -> type 0x%02x\n", cte->type);
5307 }
5308
5294 } 5309 }
5295} 5310}
5296 5311
diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.h b/drivers/gpu/drm/nouveau/nouveau_bios.h
index 9f688aa9a65..c0d7b0a3ece 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bios.h
+++ b/drivers/gpu/drm/nouveau/nouveau_bios.h
@@ -49,6 +49,9 @@ struct dcb_gpio_entry {
49 enum dcb_gpio_tag tag; 49 enum dcb_gpio_tag tag;
50 int line; 50 int line;
51 bool invert; 51 bool invert;
52 uint32_t entry;
53 uint8_t state_default;
54 uint8_t state[2];
52}; 55};
53 56
54struct dcb_gpio_table { 57struct dcb_gpio_table {
@@ -72,9 +75,10 @@ enum dcb_connector_type {
72}; 75};
73 76
74struct dcb_connector_table_entry { 77struct dcb_connector_table_entry {
78 uint8_t index;
75 uint32_t entry; 79 uint32_t entry;
76 enum dcb_connector_type type; 80 enum dcb_connector_type type;
77 uint8_t index; 81 uint8_t index2;
78 uint8_t gpio_tag; 82 uint8_t gpio_tag;
79}; 83};
80 84
@@ -266,7 +270,6 @@ struct nvbios {
266 bool reset_after_pclk_change; 270 bool reset_after_pclk_change;
267 bool dual_link; 271 bool dual_link;
268 bool link_c_increment; 272 bool link_c_increment;
269 bool BITbit1;
270 bool if_is_24bit; 273 bool if_is_24bit;
271 int duallink_transition_clk; 274 int duallink_transition_clk;
272 uint8_t strapless_is_24bit; 275 uint8_t strapless_is_24bit;
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 028719fddf7..957d1762984 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -34,6 +34,7 @@
34#include "nouveau_dma.h" 34#include "nouveau_dma.h"
35 35
36#include <linux/log2.h> 36#include <linux/log2.h>
37#include <linux/slab.h>
37 38
38static void 39static void
39nouveau_bo_del_ttm(struct ttm_buffer_object *bo) 40nouveau_bo_del_ttm(struct ttm_buffer_object *bo)
@@ -71,7 +72,7 @@ nouveau_bo_fixup_align(struct drm_device *dev,
71 * many small buffers. 72 * many small buffers.
72 */ 73 */
73 if (dev_priv->card_type == NV_50) { 74 if (dev_priv->card_type == NV_50) {
74 uint32_t block_size = nouveau_mem_fb_amount(dev) >> 15; 75 uint32_t block_size = dev_priv->vram_size >> 15;
75 int i; 76 int i;
76 77
77 switch (tile_flags) { 78 switch (tile_flags) {
@@ -153,7 +154,7 @@ nouveau_bo_new(struct drm_device *dev, struct nouveau_channel *chan,
153 154
154 nvbo->placement.fpfn = 0; 155 nvbo->placement.fpfn = 0;
155 nvbo->placement.lpfn = mappable ? dev_priv->fb_mappable_pages : 0; 156 nvbo->placement.lpfn = mappable ? dev_priv->fb_mappable_pages : 0;
156 nouveau_bo_placement_set(nvbo, flags); 157 nouveau_bo_placement_set(nvbo, flags, 0);
157 158
158 nvbo->channel = chan; 159 nvbo->channel = chan;
159 ret = ttm_bo_init(&dev_priv->ttm.bdev, &nvbo->bo, size, 160 ret = ttm_bo_init(&dev_priv->ttm.bdev, &nvbo->bo, size,
@@ -172,26 +173,33 @@ nouveau_bo_new(struct drm_device *dev, struct nouveau_channel *chan,
172 return 0; 173 return 0;
173} 174}
174 175
176static void
177set_placement_list(uint32_t *pl, unsigned *n, uint32_t type, uint32_t flags)
178{
179 *n = 0;
180
181 if (type & TTM_PL_FLAG_VRAM)
182 pl[(*n)++] = TTM_PL_FLAG_VRAM | flags;
183 if (type & TTM_PL_FLAG_TT)
184 pl[(*n)++] = TTM_PL_FLAG_TT | flags;
185 if (type & TTM_PL_FLAG_SYSTEM)
186 pl[(*n)++] = TTM_PL_FLAG_SYSTEM | flags;
187}
188
175void 189void
176nouveau_bo_placement_set(struct nouveau_bo *nvbo, uint32_t memtype) 190nouveau_bo_placement_set(struct nouveau_bo *nvbo, uint32_t type, uint32_t busy)
177{ 191{
178 int n = 0; 192 struct ttm_placement *pl = &nvbo->placement;
179 193 uint32_t flags = TTM_PL_MASK_CACHING |
180 if (memtype & TTM_PL_FLAG_VRAM) 194 (nvbo->pin_refcnt ? TTM_PL_FLAG_NO_EVICT : 0);
181 nvbo->placements[n++] = TTM_PL_FLAG_VRAM | TTM_PL_MASK_CACHING; 195
182 if (memtype & TTM_PL_FLAG_TT) 196 pl->placement = nvbo->placements;
183 nvbo->placements[n++] = TTM_PL_FLAG_TT | TTM_PL_MASK_CACHING; 197 set_placement_list(nvbo->placements, &pl->num_placement,
184 if (memtype & TTM_PL_FLAG_SYSTEM) 198 type, flags);
185 nvbo->placements[n++] = TTM_PL_FLAG_SYSTEM | TTM_PL_MASK_CACHING; 199
186 nvbo->placement.placement = nvbo->placements; 200 pl->busy_placement = nvbo->busy_placements;
187 nvbo->placement.busy_placement = nvbo->placements; 201 set_placement_list(nvbo->busy_placements, &pl->num_busy_placement,
188 nvbo->placement.num_placement = n; 202 type | busy, flags);
189 nvbo->placement.num_busy_placement = n;
190
191 if (nvbo->pin_refcnt) {
192 while (n--)
193 nvbo->placements[n] |= TTM_PL_FLAG_NO_EVICT;
194 }
195} 203}
196 204
197int 205int
@@ -199,7 +207,7 @@ nouveau_bo_pin(struct nouveau_bo *nvbo, uint32_t memtype)
199{ 207{
200 struct drm_nouveau_private *dev_priv = nouveau_bdev(nvbo->bo.bdev); 208 struct drm_nouveau_private *dev_priv = nouveau_bdev(nvbo->bo.bdev);
201 struct ttm_buffer_object *bo = &nvbo->bo; 209 struct ttm_buffer_object *bo = &nvbo->bo;
202 int ret, i; 210 int ret;
203 211
204 if (nvbo->pin_refcnt && !(memtype & (1 << bo->mem.mem_type))) { 212 if (nvbo->pin_refcnt && !(memtype & (1 << bo->mem.mem_type))) {
205 NV_ERROR(nouveau_bdev(bo->bdev)->dev, 213 NV_ERROR(nouveau_bdev(bo->bdev)->dev,
@@ -215,9 +223,7 @@ nouveau_bo_pin(struct nouveau_bo *nvbo, uint32_t memtype)
215 if (ret) 223 if (ret)
216 goto out; 224 goto out;
217 225
218 nouveau_bo_placement_set(nvbo, memtype); 226 nouveau_bo_placement_set(nvbo, memtype, 0);
219 for (i = 0; i < nvbo->placement.num_placement; i++)
220 nvbo->placements[i] |= TTM_PL_FLAG_NO_EVICT;
221 227
222 ret = ttm_bo_validate(bo, &nvbo->placement, false, false); 228 ret = ttm_bo_validate(bo, &nvbo->placement, false, false);
223 if (ret == 0) { 229 if (ret == 0) {
@@ -244,7 +250,7 @@ nouveau_bo_unpin(struct nouveau_bo *nvbo)
244{ 250{
245 struct drm_nouveau_private *dev_priv = nouveau_bdev(nvbo->bo.bdev); 251 struct drm_nouveau_private *dev_priv = nouveau_bdev(nvbo->bo.bdev);
246 struct ttm_buffer_object *bo = &nvbo->bo; 252 struct ttm_buffer_object *bo = &nvbo->bo;
247 int ret, i; 253 int ret;
248 254
249 if (--nvbo->pin_refcnt) 255 if (--nvbo->pin_refcnt)
250 return 0; 256 return 0;
@@ -253,8 +259,7 @@ nouveau_bo_unpin(struct nouveau_bo *nvbo)
253 if (ret) 259 if (ret)
254 return ret; 260 return ret;
255 261
256 for (i = 0; i < nvbo->placement.num_placement; i++) 262 nouveau_bo_placement_set(nvbo, bo->mem.placement, 0);
257 nvbo->placements[i] &= ~TTM_PL_FLAG_NO_EVICT;
258 263
259 ret = ttm_bo_validate(bo, &nvbo->placement, false, false); 264 ret = ttm_bo_validate(bo, &nvbo->placement, false, false);
260 if (ret == 0) { 265 if (ret == 0) {
@@ -395,8 +400,8 @@ nouveau_bo_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
395 man->io_addr = NULL; 400 man->io_addr = NULL;
396 man->io_offset = drm_get_resource_start(dev, 1); 401 man->io_offset = drm_get_resource_start(dev, 1);
397 man->io_size = drm_get_resource_len(dev, 1); 402 man->io_size = drm_get_resource_len(dev, 1);
398 if (man->io_size > nouveau_mem_fb_amount(dev)) 403 if (man->io_size > dev_priv->vram_size)
399 man->io_size = nouveau_mem_fb_amount(dev); 404 man->io_size = dev_priv->vram_size;
400 405
401 man->gpu_offset = dev_priv->vm_vram_base; 406 man->gpu_offset = dev_priv->vm_vram_base;
402 break; 407 break;
@@ -439,11 +444,11 @@ nouveau_bo_evict_flags(struct ttm_buffer_object *bo, struct ttm_placement *pl)
439 444
440 switch (bo->mem.mem_type) { 445 switch (bo->mem.mem_type) {
441 case TTM_PL_VRAM: 446 case TTM_PL_VRAM:
442 nouveau_bo_placement_set(nvbo, TTM_PL_FLAG_TT | 447 nouveau_bo_placement_set(nvbo, TTM_PL_FLAG_TT,
443 TTM_PL_FLAG_SYSTEM); 448 TTM_PL_FLAG_SYSTEM);
444 break; 449 break;
445 default: 450 default:
446 nouveau_bo_placement_set(nvbo, TTM_PL_FLAG_SYSTEM); 451 nouveau_bo_placement_set(nvbo, TTM_PL_FLAG_SYSTEM, 0);
447 break; 452 break;
448 } 453 }
449 454
diff --git a/drivers/gpu/drm/nouveau/nouveau_channel.c b/drivers/gpu/drm/nouveau/nouveau_channel.c
index 6dfb425cbae..1fc57ef5829 100644
--- a/drivers/gpu/drm/nouveau/nouveau_channel.c
+++ b/drivers/gpu/drm/nouveau/nouveau_channel.c
@@ -142,7 +142,6 @@ nouveau_channel_alloc(struct drm_device *dev, struct nouveau_channel **chan_ret,
142 GFP_KERNEL); 142 GFP_KERNEL);
143 if (!dev_priv->fifos[channel]) 143 if (!dev_priv->fifos[channel])
144 return -ENOMEM; 144 return -ENOMEM;
145 dev_priv->fifo_alloc_count++;
146 chan = dev_priv->fifos[channel]; 145 chan = dev_priv->fifos[channel];
147 INIT_LIST_HEAD(&chan->nvsw.vbl_wait); 146 INIT_LIST_HEAD(&chan->nvsw.vbl_wait);
148 INIT_LIST_HEAD(&chan->fence.pending); 147 INIT_LIST_HEAD(&chan->fence.pending);
@@ -321,7 +320,6 @@ nouveau_channel_free(struct nouveau_channel *chan)
321 iounmap(chan->user); 320 iounmap(chan->user);
322 321
323 dev_priv->fifos[chan->id] = NULL; 322 dev_priv->fifos[chan->id] = NULL;
324 dev_priv->fifo_alloc_count--;
325 kfree(chan); 323 kfree(chan);
326} 324}
327 325
diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
index 24327f468c4..14afe1e47e5 100644
--- a/drivers/gpu/drm/nouveau/nouveau_connector.c
+++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
@@ -302,7 +302,7 @@ nouveau_connector_detect(struct drm_connector *connector)
302 302
303detect_analog: 303detect_analog:
304 nv_encoder = find_encoder_by_type(connector, OUTPUT_ANALOG); 304 nv_encoder = find_encoder_by_type(connector, OUTPUT_ANALOG);
305 if (!nv_encoder) 305 if (!nv_encoder && !nouveau_tv_disable)
306 nv_encoder = find_encoder_by_type(connector, OUTPUT_TV); 306 nv_encoder = find_encoder_by_type(connector, OUTPUT_TV);
307 if (nv_encoder) { 307 if (nv_encoder) {
308 struct drm_encoder *encoder = to_drm_encoder(nv_encoder); 308 struct drm_encoder *encoder = to_drm_encoder(nv_encoder);
diff --git a/drivers/gpu/drm/nouveau/nouveau_debugfs.c b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
index 8ff9ef5d4b4..a251886a0ce 100644
--- a/drivers/gpu/drm/nouveau/nouveau_debugfs.c
+++ b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
@@ -137,10 +137,9 @@ nouveau_debugfs_memory_info(struct seq_file *m, void *data)
137{ 137{
138 struct drm_info_node *node = (struct drm_info_node *) m->private; 138 struct drm_info_node *node = (struct drm_info_node *) m->private;
139 struct drm_minor *minor = node->minor; 139 struct drm_minor *minor = node->minor;
140 struct drm_device *dev = minor->dev; 140 struct drm_nouveau_private *dev_priv = minor->dev->dev_private;
141 141
142 seq_printf(m, "VRAM total: %dKiB\n", 142 seq_printf(m, "VRAM total: %dKiB\n", (int)(dev_priv->vram_size >> 10));
143 (int)(nouveau_mem_fb_amount(dev) >> 10));
144 return 0; 143 return 0;
145} 144}
146 145
diff --git a/drivers/gpu/drm/nouveau/nouveau_dma.c b/drivers/gpu/drm/nouveau/nouveau_dma.c
index c8482a108a7..65c441a1999 100644
--- a/drivers/gpu/drm/nouveau/nouveau_dma.c
+++ b/drivers/gpu/drm/nouveau/nouveau_dma.c
@@ -190,6 +190,11 @@ nv50_dma_push(struct nouveau_channel *chan, struct nouveau_bo *bo,
190 nouveau_bo_wr32(pb, ip++, upper_32_bits(offset) | length << 8); 190 nouveau_bo_wr32(pb, ip++, upper_32_bits(offset) | length << 8);
191 191
192 chan->dma.ib_put = (chan->dma.ib_put + 1) & chan->dma.ib_max; 192 chan->dma.ib_put = (chan->dma.ib_put + 1) & chan->dma.ib_max;
193
194 DRM_MEMORYBARRIER();
195 /* Flush writes. */
196 nouveau_bo_rd32(pb, 0);
197
193 nvchan_wr32(chan, 0x8c, chan->dma.ib_put); 198 nvchan_wr32(chan, 0x8c, chan->dma.ib_put);
194 chan->dma.ib_free--; 199 chan->dma.ib_free--;
195} 200}
diff --git a/drivers/gpu/drm/nouveau/nouveau_dp.c b/drivers/gpu/drm/nouveau/nouveau_dp.c
index f954ad93e81..deeb21c6865 100644
--- a/drivers/gpu/drm/nouveau/nouveau_dp.c
+++ b/drivers/gpu/drm/nouveau/nouveau_dp.c
@@ -483,7 +483,7 @@ nouveau_dp_auxch(struct nouveau_i2c_chan *auxch, int cmd, int addr,
483 ctrl |= (cmd << NV50_AUXCH_CTRL_CMD_SHIFT); 483 ctrl |= (cmd << NV50_AUXCH_CTRL_CMD_SHIFT);
484 ctrl |= ((data_nr - 1) << NV50_AUXCH_CTRL_LEN_SHIFT); 484 ctrl |= ((data_nr - 1) << NV50_AUXCH_CTRL_LEN_SHIFT);
485 485
486 for (;;) { 486 for (i = 0; i < 16; i++) {
487 nv_wr32(dev, NV50_AUXCH_CTRL(index), ctrl | 0x80000000); 487 nv_wr32(dev, NV50_AUXCH_CTRL(index), ctrl | 0x80000000);
488 nv_wr32(dev, NV50_AUXCH_CTRL(index), ctrl); 488 nv_wr32(dev, NV50_AUXCH_CTRL(index), ctrl);
489 nv_wr32(dev, NV50_AUXCH_CTRL(index), ctrl | 0x00010000); 489 nv_wr32(dev, NV50_AUXCH_CTRL(index), ctrl | 0x00010000);
@@ -502,6 +502,12 @@ nouveau_dp_auxch(struct nouveau_i2c_chan *auxch, int cmd, int addr,
502 break; 502 break;
503 } 503 }
504 504
505 if (i == 16) {
506 NV_ERROR(dev, "auxch DEFER too many times, bailing\n");
507 ret = -EREMOTEIO;
508 goto out;
509 }
510
505 if (cmd & 1) { 511 if (cmd & 1) {
506 if ((stat & NV50_AUXCH_STAT_COUNT) != data_nr) { 512 if ((stat & NV50_AUXCH_STAT_COUNT) != data_nr) {
507 ret = -EREMOTEIO; 513 ret = -EREMOTEIO;
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.c b/drivers/gpu/drm/nouveau/nouveau_drv.c
index 30cc09e8a70..1de974acbc6 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.c
@@ -83,6 +83,14 @@ MODULE_PARM_DESC(nofbaccel, "Disable fbcon acceleration");
83int nouveau_nofbaccel = 0; 83int nouveau_nofbaccel = 0;
84module_param_named(nofbaccel, nouveau_nofbaccel, int, 0400); 84module_param_named(nofbaccel, nouveau_nofbaccel, int, 0400);
85 85
86MODULE_PARM_DESC(override_conntype, "Ignore DCB connector type");
87int nouveau_override_conntype = 0;
88module_param_named(override_conntype, nouveau_override_conntype, int, 0400);
89
90MODULE_PARM_DESC(tv_disable, "Disable TV-out detection\n");
91int nouveau_tv_disable = 0;
92module_param_named(tv_disable, nouveau_tv_disable, int, 0400);
93
86MODULE_PARM_DESC(tv_norm, "Default TV norm.\n" 94MODULE_PARM_DESC(tv_norm, "Default TV norm.\n"
87 "\t\tSupported: PAL, PAL-M, PAL-N, PAL-Nc, NTSC-M, NTSC-J,\n" 95 "\t\tSupported: PAL, PAL-M, PAL-N, PAL-Nc, NTSC-M, NTSC-J,\n"
88 "\t\t\thd480i, hd480p, hd576i, hd576p, hd720p, hd1080i.\n" 96 "\t\t\thd480i, hd480p, hd576i, hd576p, hd720p, hd1080i.\n"
@@ -154,9 +162,11 @@ nouveau_pci_suspend(struct pci_dev *pdev, pm_message_t pm_state)
154 if (pm_state.event == PM_EVENT_PRETHAW) 162 if (pm_state.event == PM_EVENT_PRETHAW)
155 return 0; 163 return 0;
156 164
165 NV_INFO(dev, "Disabling fbcon acceleration...\n");
157 fbdev_flags = dev_priv->fbdev_info->flags; 166 fbdev_flags = dev_priv->fbdev_info->flags;
158 dev_priv->fbdev_info->flags |= FBINFO_HWACCEL_DISABLED; 167 dev_priv->fbdev_info->flags |= FBINFO_HWACCEL_DISABLED;
159 168
169 NV_INFO(dev, "Unpinning framebuffer(s)...\n");
160 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { 170 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
161 struct nouveau_framebuffer *nouveau_fb; 171 struct nouveau_framebuffer *nouveau_fb;
162 172
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index 4b9aaf2a8d0..ace630aa89e 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -76,6 +76,7 @@ struct nouveau_bo {
76 struct ttm_buffer_object bo; 76 struct ttm_buffer_object bo;
77 struct ttm_placement placement; 77 struct ttm_placement placement;
78 u32 placements[3]; 78 u32 placements[3];
79 u32 busy_placements[3];
79 struct ttm_bo_kmap_obj kmap; 80 struct ttm_bo_kmap_obj kmap;
80 struct list_head head; 81 struct list_head head;
81 82
@@ -519,6 +520,7 @@ struct drm_nouveau_private {
519 520
520 struct workqueue_struct *wq; 521 struct workqueue_struct *wq;
521 struct work_struct irq_work; 522 struct work_struct irq_work;
523 struct work_struct hpd_work;
522 524
523 struct list_head vbl_waiting; 525 struct list_head vbl_waiting;
524 526
@@ -533,7 +535,6 @@ struct drm_nouveau_private {
533 535
534 struct fb_info *fbdev_info; 536 struct fb_info *fbdev_info;
535 537
536 int fifo_alloc_count;
537 struct nouveau_channel *fifos[NOUVEAU_MAX_CHANNEL_NR]; 538 struct nouveau_channel *fifos[NOUVEAU_MAX_CHANNEL_NR];
538 539
539 struct nouveau_engine engine; 540 struct nouveau_engine engine;
@@ -553,12 +554,6 @@ struct drm_nouveau_private {
553 uint32_t ramro_offset; 554 uint32_t ramro_offset;
554 uint32_t ramro_size; 555 uint32_t ramro_size;
555 556
556 /* base physical addresses */
557 uint64_t fb_phys;
558 uint64_t fb_available_size;
559 uint64_t fb_mappable_pages;
560 uint64_t fb_aper_free;
561
562 struct { 557 struct {
563 enum { 558 enum {
564 NOUVEAU_GART_NONE = 0, 559 NOUVEAU_GART_NONE = 0,
@@ -572,10 +567,6 @@ struct drm_nouveau_private {
572 struct nouveau_gpuobj *sg_ctxdma; 567 struct nouveau_gpuobj *sg_ctxdma;
573 struct page *sg_dummy_page; 568 struct page *sg_dummy_page;
574 dma_addr_t sg_dummy_bus; 569 dma_addr_t sg_dummy_bus;
575
576 /* nottm hack */
577 struct drm_ttm_backend *sg_be;
578 unsigned long sg_handle;
579 } gart_info; 570 } gart_info;
580 571
581 /* nv10-nv40 tiling regions */ 572 /* nv10-nv40 tiling regions */
@@ -584,6 +575,16 @@ struct drm_nouveau_private {
584 spinlock_t lock; 575 spinlock_t lock;
585 } tile; 576 } tile;
586 577
578 /* VRAM/fb configuration */
579 uint64_t vram_size;
580 uint64_t vram_sys_base;
581
582 uint64_t fb_phys;
583 uint64_t fb_available_size;
584 uint64_t fb_mappable_pages;
585 uint64_t fb_aper_free;
586 int fb_mtrr;
587
587 /* G8x/G9x virtual address space */ 588 /* G8x/G9x virtual address space */
588 uint64_t vm_gart_base; 589 uint64_t vm_gart_base;
589 uint64_t vm_gart_size; 590 uint64_t vm_gart_size;
@@ -592,10 +593,6 @@ struct drm_nouveau_private {
592 uint64_t vm_end; 593 uint64_t vm_end;
593 struct nouveau_gpuobj *vm_vram_pt[NV50_VM_VRAM_NR]; 594 struct nouveau_gpuobj *vm_vram_pt[NV50_VM_VRAM_NR];
594 int vm_vram_pt_nr; 595 int vm_vram_pt_nr;
595 uint64_t vram_sys_base;
596
597 /* the mtrr covering the FB */
598 int fb_mtrr;
599 596
600 struct mem_block *ramin_heap; 597 struct mem_block *ramin_heap;
601 598
@@ -614,11 +611,7 @@ struct drm_nouveau_private {
614 uint32_t dac_users[4]; 611 uint32_t dac_users[4];
615 612
616 struct nouveau_suspend_resume { 613 struct nouveau_suspend_resume {
617 uint32_t fifo_mode;
618 uint32_t graph_ctx_control;
619 uint32_t graph_state;
620 uint32_t *ramin_copy; 614 uint32_t *ramin_copy;
621 uint64_t ramin_size;
622 } susres; 615 } susres;
623 616
624 struct backlight_device *backlight; 617 struct backlight_device *backlight;
@@ -681,6 +674,7 @@ extern int nouveau_uscript_tmds;
681extern int nouveau_vram_pushbuf; 674extern int nouveau_vram_pushbuf;
682extern int nouveau_vram_notify; 675extern int nouveau_vram_notify;
683extern int nouveau_fbpercrtc; 676extern int nouveau_fbpercrtc;
677extern int nouveau_tv_disable;
684extern char *nouveau_tv_norm; 678extern char *nouveau_tv_norm;
685extern int nouveau_reg_debug; 679extern int nouveau_reg_debug;
686extern char *nouveau_vbios; 680extern char *nouveau_vbios;
@@ -688,6 +682,7 @@ extern int nouveau_ctxfw;
688extern int nouveau_ignorelid; 682extern int nouveau_ignorelid;
689extern int nouveau_nofbaccel; 683extern int nouveau_nofbaccel;
690extern int nouveau_noaccel; 684extern int nouveau_noaccel;
685extern int nouveau_override_conntype;
691 686
692extern int nouveau_pci_suspend(struct pci_dev *pdev, pm_message_t pm_state); 687extern int nouveau_pci_suspend(struct pci_dev *pdev, pm_message_t pm_state);
693extern int nouveau_pci_resume(struct pci_dev *pdev); 688extern int nouveau_pci_resume(struct pci_dev *pdev);
@@ -715,7 +710,7 @@ extern struct mem_block *nouveau_mem_alloc_block(struct mem_block *,
715 struct drm_file *, int tail); 710 struct drm_file *, int tail);
716extern void nouveau_mem_takedown(struct mem_block **heap); 711extern void nouveau_mem_takedown(struct mem_block **heap);
717extern void nouveau_mem_free_block(struct mem_block *); 712extern void nouveau_mem_free_block(struct mem_block *);
718extern uint64_t nouveau_mem_fb_amount(struct drm_device *); 713extern int nouveau_mem_detect(struct drm_device *dev);
719extern void nouveau_mem_release(struct drm_file *, struct mem_block *heap); 714extern void nouveau_mem_release(struct drm_file *, struct mem_block *heap);
720extern int nouveau_mem_init(struct drm_device *); 715extern int nouveau_mem_init(struct drm_device *);
721extern int nouveau_mem_init_agp(struct drm_device *); 716extern int nouveau_mem_init_agp(struct drm_device *);
@@ -926,6 +921,10 @@ extern void nv40_fb_takedown(struct drm_device *);
926extern void nv40_fb_set_region_tiling(struct drm_device *, int, uint32_t, 921extern void nv40_fb_set_region_tiling(struct drm_device *, int, uint32_t,
927 uint32_t, uint32_t); 922 uint32_t, uint32_t);
928 923
924/* nv50_fb.c */
925extern int nv50_fb_init(struct drm_device *);
926extern void nv50_fb_takedown(struct drm_device *);
927
929/* nv04_fifo.c */ 928/* nv04_fifo.c */
930extern int nv04_fifo_init(struct drm_device *); 929extern int nv04_fifo_init(struct drm_device *);
931extern void nv04_fifo_disable(struct drm_device *); 930extern void nv04_fifo_disable(struct drm_device *);
@@ -1118,7 +1117,8 @@ extern int nouveau_bo_pin(struct nouveau_bo *, uint32_t flags);
1118extern int nouveau_bo_unpin(struct nouveau_bo *); 1117extern int nouveau_bo_unpin(struct nouveau_bo *);
1119extern int nouveau_bo_map(struct nouveau_bo *); 1118extern int nouveau_bo_map(struct nouveau_bo *);
1120extern void nouveau_bo_unmap(struct nouveau_bo *); 1119extern void nouveau_bo_unmap(struct nouveau_bo *);
1121extern void nouveau_bo_placement_set(struct nouveau_bo *, uint32_t memtype); 1120extern void nouveau_bo_placement_set(struct nouveau_bo *, uint32_t type,
1121 uint32_t busy);
1122extern u16 nouveau_bo_rd16(struct nouveau_bo *nvbo, unsigned index); 1122extern u16 nouveau_bo_rd16(struct nouveau_bo *nvbo, unsigned index);
1123extern void nouveau_bo_wr16(struct nouveau_bo *nvbo, unsigned index, u16 val); 1123extern void nouveau_bo_wr16(struct nouveau_bo *nvbo, unsigned index, u16 val);
1124extern u32 nouveau_bo_rd32(struct nouveau_bo *nvbo, unsigned index); 1124extern u32 nouveau_bo_rd32(struct nouveau_bo *nvbo, unsigned index);
@@ -1162,6 +1162,10 @@ extern int nouveau_gem_ioctl_info(struct drm_device *, void *,
1162int nv17_gpio_get(struct drm_device *dev, enum dcb_gpio_tag tag); 1162int nv17_gpio_get(struct drm_device *dev, enum dcb_gpio_tag tag);
1163int nv17_gpio_set(struct drm_device *dev, enum dcb_gpio_tag tag, int state); 1163int nv17_gpio_set(struct drm_device *dev, enum dcb_gpio_tag tag, int state);
1164 1164
1165/* nv50_gpio.c */
1166int nv50_gpio_get(struct drm_device *dev, enum dcb_gpio_tag tag);
1167int nv50_gpio_set(struct drm_device *dev, enum dcb_gpio_tag tag, int state);
1168
1165#ifndef ioread32_native 1169#ifndef ioread32_native
1166#ifdef __BIG_ENDIAN 1170#ifdef __BIG_ENDIAN
1167#define ioread16_native ioread16be 1171#define ioread16_native ioread16be
diff --git a/drivers/gpu/drm/nouveau/nouveau_encoder.h b/drivers/gpu/drm/nouveau/nouveau_encoder.h
index bc4a24029ed..9f28b94e479 100644
--- a/drivers/gpu/drm/nouveau/nouveau_encoder.h
+++ b/drivers/gpu/drm/nouveau/nouveau_encoder.h
@@ -47,6 +47,7 @@ struct nouveau_encoder {
47 47
48 union { 48 union {
49 struct { 49 struct {
50 int mc_unknown;
50 int dpcd_version; 51 int dpcd_version;
51 int link_nr; 52 int link_nr;
52 int link_bw; 53 int link_bw;
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
index 68cedd9194f..8e7dc1d4912 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
@@ -30,7 +30,6 @@
30#include <linux/string.h> 30#include <linux/string.h>
31#include <linux/mm.h> 31#include <linux/mm.h>
32#include <linux/tty.h> 32#include <linux/tty.h>
33#include <linux/slab.h>
34#include <linux/sysrq.h> 33#include <linux/sysrq.h>
35#include <linux/delay.h> 34#include <linux/delay.h>
36#include <linux/fb.h> 35#include <linux/fb.h>
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 0d22f66f1c7..1bc0b38a516 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -180,40 +180,35 @@ nouveau_gem_set_domain(struct drm_gem_object *gem, uint32_t read_domains,
180{ 180{
181 struct nouveau_bo *nvbo = gem->driver_private; 181 struct nouveau_bo *nvbo = gem->driver_private;
182 struct ttm_buffer_object *bo = &nvbo->bo; 182 struct ttm_buffer_object *bo = &nvbo->bo;
183 uint64_t flags; 183 uint32_t domains = valid_domains &
184 (write_domains ? write_domains : read_domains);
185 uint32_t pref_flags = 0, valid_flags = 0;
184 186
185 if (!valid_domains || (!read_domains && !write_domains)) 187 if (!domains)
186 return -EINVAL; 188 return -EINVAL;
187 189
188 if (write_domains) { 190 if (valid_domains & NOUVEAU_GEM_DOMAIN_VRAM)
189 if ((valid_domains & NOUVEAU_GEM_DOMAIN_VRAM) && 191 valid_flags |= TTM_PL_FLAG_VRAM;
190 (write_domains & NOUVEAU_GEM_DOMAIN_VRAM)) 192
191 flags = TTM_PL_FLAG_VRAM; 193 if (valid_domains & NOUVEAU_GEM_DOMAIN_GART)
192 else 194 valid_flags |= TTM_PL_FLAG_TT;
193 if ((valid_domains & NOUVEAU_GEM_DOMAIN_GART) && 195
194 (write_domains & NOUVEAU_GEM_DOMAIN_GART)) 196 if ((domains & NOUVEAU_GEM_DOMAIN_VRAM) &&
195 flags = TTM_PL_FLAG_TT; 197 bo->mem.mem_type == TTM_PL_VRAM)
196 else 198 pref_flags |= TTM_PL_FLAG_VRAM;
197 return -EINVAL; 199
198 } else { 200 else if ((domains & NOUVEAU_GEM_DOMAIN_GART) &&
199 if ((valid_domains & NOUVEAU_GEM_DOMAIN_VRAM) && 201 bo->mem.mem_type == TTM_PL_TT)
200 (read_domains & NOUVEAU_GEM_DOMAIN_VRAM) && 202 pref_flags |= TTM_PL_FLAG_TT;
201 bo->mem.mem_type == TTM_PL_VRAM) 203
202 flags = TTM_PL_FLAG_VRAM; 204 else if (domains & NOUVEAU_GEM_DOMAIN_VRAM)
203 else 205 pref_flags |= TTM_PL_FLAG_VRAM;
204 if ((valid_domains & NOUVEAU_GEM_DOMAIN_GART) && 206
205 (read_domains & NOUVEAU_GEM_DOMAIN_GART) && 207 else
206 bo->mem.mem_type == TTM_PL_TT) 208 pref_flags |= TTM_PL_FLAG_TT;
207 flags = TTM_PL_FLAG_TT; 209
208 else 210 nouveau_bo_placement_set(nvbo, pref_flags, valid_flags);
209 if ((valid_domains & NOUVEAU_GEM_DOMAIN_VRAM) &&
210 (read_domains & NOUVEAU_GEM_DOMAIN_VRAM))
211 flags = TTM_PL_FLAG_VRAM;
212 else
213 flags = TTM_PL_FLAG_TT;
214 }
215 211
216 nouveau_bo_placement_set(nvbo, flags);
217 return 0; 212 return 0;
218} 213}
219 214
diff --git a/drivers/gpu/drm/nouveau/nouveau_grctx.c b/drivers/gpu/drm/nouveau/nouveau_grctx.c
index c7ebec69674..32f0e495464 100644
--- a/drivers/gpu/drm/nouveau/nouveau_grctx.c
+++ b/drivers/gpu/drm/nouveau/nouveau_grctx.c
@@ -23,6 +23,7 @@
23 */ 23 */
24 24
25#include <linux/firmware.h> 25#include <linux/firmware.h>
26#include <linux/slab.h>
26 27
27#include "drmP.h" 28#include "drmP.h"
28#include "nouveau_drv.h" 29#include "nouveau_drv.h"
diff --git a/drivers/gpu/drm/nouveau/nouveau_irq.c b/drivers/gpu/drm/nouveau/nouveau_irq.c
index 95220ddebb4..13e73cee4c4 100644
--- a/drivers/gpu/drm/nouveau/nouveau_irq.c
+++ b/drivers/gpu/drm/nouveau/nouveau_irq.c
@@ -51,6 +51,7 @@ nouveau_irq_preinstall(struct drm_device *dev)
51 51
52 if (dev_priv->card_type == NV_50) { 52 if (dev_priv->card_type == NV_50) {
53 INIT_WORK(&dev_priv->irq_work, nv50_display_irq_handler_bh); 53 INIT_WORK(&dev_priv->irq_work, nv50_display_irq_handler_bh);
54 INIT_WORK(&dev_priv->hpd_work, nv50_display_irq_hotplug_bh);
54 INIT_LIST_HEAD(&dev_priv->vbl_waiting); 55 INIT_LIST_HEAD(&dev_priv->vbl_waiting);
55 } 56 }
56} 57}
@@ -311,6 +312,31 @@ nouveau_print_bitfield_names_(uint32_t value,
311#define nouveau_print_bitfield_names(val, namelist) \ 312#define nouveau_print_bitfield_names(val, namelist) \
312 nouveau_print_bitfield_names_((val), (namelist), ARRAY_SIZE(namelist)) 313 nouveau_print_bitfield_names_((val), (namelist), ARRAY_SIZE(namelist))
313 314
315struct nouveau_enum_names {
316 uint32_t value;
317 const char *name;
318};
319
320static void
321nouveau_print_enum_names_(uint32_t value,
322 const struct nouveau_enum_names *namelist,
323 const int namelist_len)
324{
325 /*
326 * Caller must have already printed the KERN_* log level for us.
327 * Also the caller is responsible for adding the newline.
328 */
329 int i;
330 for (i = 0; i < namelist_len; ++i) {
331 if (value == namelist[i].value) {
332 printk("%s", namelist[i].name);
333 return;
334 }
335 }
336 printk("unknown value 0x%08x", value);
337}
338#define nouveau_print_enum_names(val, namelist) \
339 nouveau_print_enum_names_((val), (namelist), ARRAY_SIZE(namelist))
314 340
315static int 341static int
316nouveau_graph_chid_from_grctx(struct drm_device *dev) 342nouveau_graph_chid_from_grctx(struct drm_device *dev)
@@ -427,14 +453,16 @@ nouveau_graph_dump_trap_info(struct drm_device *dev, const char *id,
427 struct drm_nouveau_private *dev_priv = dev->dev_private; 453 struct drm_nouveau_private *dev_priv = dev->dev_private;
428 uint32_t nsource = trap->nsource, nstatus = trap->nstatus; 454 uint32_t nsource = trap->nsource, nstatus = trap->nstatus;
429 455
430 NV_INFO(dev, "%s - nSource:", id); 456 if (dev_priv->card_type < NV_50) {
431 nouveau_print_bitfield_names(nsource, nsource_names); 457 NV_INFO(dev, "%s - nSource:", id);
432 printk(", nStatus:"); 458 nouveau_print_bitfield_names(nsource, nsource_names);
433 if (dev_priv->card_type < NV_10) 459 printk(", nStatus:");
434 nouveau_print_bitfield_names(nstatus, nstatus_names); 460 if (dev_priv->card_type < NV_10)
435 else 461 nouveau_print_bitfield_names(nstatus, nstatus_names);
436 nouveau_print_bitfield_names(nstatus, nstatus_names_nv10); 462 else
437 printk("\n"); 463 nouveau_print_bitfield_names(nstatus, nstatus_names_nv10);
464 printk("\n");
465 }
438 466
439 NV_INFO(dev, "%s - Ch %d/%d Class 0x%04x Mthd 0x%04x " 467 NV_INFO(dev, "%s - Ch %d/%d Class 0x%04x Mthd 0x%04x "
440 "Data 0x%08x:0x%08x\n", 468 "Data 0x%08x:0x%08x\n",
@@ -578,27 +606,502 @@ nouveau_pgraph_irq_handler(struct drm_device *dev)
578} 606}
579 607
580static void 608static void
609nv50_pfb_vm_trap(struct drm_device *dev, int display, const char *name)
610{
611 struct drm_nouveau_private *dev_priv = dev->dev_private;
612 uint32_t trap[6];
613 int i, ch;
614 uint32_t idx = nv_rd32(dev, 0x100c90);
615 if (idx & 0x80000000) {
616 idx &= 0xffffff;
617 if (display) {
618 for (i = 0; i < 6; i++) {
619 nv_wr32(dev, 0x100c90, idx | i << 24);
620 trap[i] = nv_rd32(dev, 0x100c94);
621 }
622 for (ch = 0; ch < dev_priv->engine.fifo.channels; ch++) {
623 struct nouveau_channel *chan = dev_priv->fifos[ch];
624
625 if (!chan || !chan->ramin)
626 continue;
627
628 if (trap[1] == chan->ramin->instance >> 12)
629 break;
630 }
631 NV_INFO(dev, "%s - VM: Trapped %s at %02x%04x%04x status %08x %08x channel %d\n",
632 name, (trap[5]&0x100?"read":"write"),
633 trap[5]&0xff, trap[4]&0xffff,
634 trap[3]&0xffff, trap[0], trap[2], ch);
635 }
636 nv_wr32(dev, 0x100c90, idx | 0x80000000);
637 } else if (display) {
638 NV_INFO(dev, "%s - no VM fault?\n", name);
639 }
640}
641
642static struct nouveau_enum_names nv50_mp_exec_error_names[] =
643{
644 { 3, "STACK_UNDERFLOW" },
645 { 4, "QUADON_ACTIVE" },
646 { 8, "TIMEOUT" },
647 { 0x10, "INVALID_OPCODE" },
648 { 0x40, "BREAKPOINT" },
649};
650
651static void
652nv50_pgraph_mp_trap(struct drm_device *dev, int tpid, int display)
653{
654 struct drm_nouveau_private *dev_priv = dev->dev_private;
655 uint32_t units = nv_rd32(dev, 0x1540);
656 uint32_t addr, mp10, status, pc, oplow, ophigh;
657 int i;
658 int mps = 0;
659 for (i = 0; i < 4; i++) {
660 if (!(units & 1 << (i+24)))
661 continue;
662 if (dev_priv->chipset < 0xa0)
663 addr = 0x408200 + (tpid << 12) + (i << 7);
664 else
665 addr = 0x408100 + (tpid << 11) + (i << 7);
666 mp10 = nv_rd32(dev, addr + 0x10);
667 status = nv_rd32(dev, addr + 0x14);
668 if (!status)
669 continue;
670 if (display) {
671 nv_rd32(dev, addr + 0x20);
672 pc = nv_rd32(dev, addr + 0x24);
673 oplow = nv_rd32(dev, addr + 0x70);
674 ophigh= nv_rd32(dev, addr + 0x74);
675 NV_INFO(dev, "PGRAPH_TRAP_MP_EXEC - "
676 "TP %d MP %d: ", tpid, i);
677 nouveau_print_enum_names(status,
678 nv50_mp_exec_error_names);
679 printk(" at %06x warp %d, opcode %08x %08x\n",
680 pc&0xffffff, pc >> 24,
681 oplow, ophigh);
682 }
683 nv_wr32(dev, addr + 0x10, mp10);
684 nv_wr32(dev, addr + 0x14, 0);
685 mps++;
686 }
687 if (!mps && display)
688 NV_INFO(dev, "PGRAPH_TRAP_MP_EXEC - TP %d: "
689 "No MPs claiming errors?\n", tpid);
690}
691
692static void
693nv50_pgraph_tp_trap(struct drm_device *dev, int type, uint32_t ustatus_old,
694 uint32_t ustatus_new, int display, const char *name)
695{
696 struct drm_nouveau_private *dev_priv = dev->dev_private;
697 int tps = 0;
698 uint32_t units = nv_rd32(dev, 0x1540);
699 int i, r;
700 uint32_t ustatus_addr, ustatus;
701 for (i = 0; i < 16; i++) {
702 if (!(units & (1 << i)))
703 continue;
704 if (dev_priv->chipset < 0xa0)
705 ustatus_addr = ustatus_old + (i << 12);
706 else
707 ustatus_addr = ustatus_new + (i << 11);
708 ustatus = nv_rd32(dev, ustatus_addr) & 0x7fffffff;
709 if (!ustatus)
710 continue;
711 tps++;
712 switch (type) {
713 case 6: /* texture error... unknown for now */
714 nv50_pfb_vm_trap(dev, display, name);
715 if (display) {
716 NV_ERROR(dev, "magic set %d:\n", i);
717 for (r = ustatus_addr + 4; r <= ustatus_addr + 0x10; r += 4)
718 NV_ERROR(dev, "\t0x%08x: 0x%08x\n", r,
719 nv_rd32(dev, r));
720 }
721 break;
722 case 7: /* MP error */
723 if (ustatus & 0x00010000) {
724 nv50_pgraph_mp_trap(dev, i, display);
725 ustatus &= ~0x00010000;
726 }
727 break;
728 case 8: /* TPDMA error */
729 {
730 uint32_t e0c = nv_rd32(dev, ustatus_addr + 4);
731 uint32_t e10 = nv_rd32(dev, ustatus_addr + 8);
732 uint32_t e14 = nv_rd32(dev, ustatus_addr + 0xc);
733 uint32_t e18 = nv_rd32(dev, ustatus_addr + 0x10);
734 uint32_t e1c = nv_rd32(dev, ustatus_addr + 0x14);
735 uint32_t e20 = nv_rd32(dev, ustatus_addr + 0x18);
736 uint32_t e24 = nv_rd32(dev, ustatus_addr + 0x1c);
737 nv50_pfb_vm_trap(dev, display, name);
738 /* 2d engine destination */
739 if (ustatus & 0x00000010) {
740 if (display) {
741 NV_INFO(dev, "PGRAPH_TRAP_TPDMA_2D - TP %d - Unknown fault at address %02x%08x\n",
742 i, e14, e10);
743 NV_INFO(dev, "PGRAPH_TRAP_TPDMA_2D - TP %d - e0c: %08x, e18: %08x, e1c: %08x, e20: %08x, e24: %08x\n",
744 i, e0c, e18, e1c, e20, e24);
745 }
746 ustatus &= ~0x00000010;
747 }
748 /* Render target */
749 if (ustatus & 0x00000040) {
750 if (display) {
751 NV_INFO(dev, "PGRAPH_TRAP_TPDMA_RT - TP %d - Unknown fault at address %02x%08x\n",
752 i, e14, e10);
753 NV_INFO(dev, "PGRAPH_TRAP_TPDMA_RT - TP %d - e0c: %08x, e18: %08x, e1c: %08x, e20: %08x, e24: %08x\n",
754 i, e0c, e18, e1c, e20, e24);
755 }
756 ustatus &= ~0x00000040;
757 }
758 /* CUDA memory: l[], g[] or stack. */
759 if (ustatus & 0x00000080) {
760 if (display) {
761 if (e18 & 0x80000000) {
762 /* g[] read fault? */
763 NV_INFO(dev, "PGRAPH_TRAP_TPDMA - TP %d - Global read fault at address %02x%08x\n",
764 i, e14, e10 | ((e18 >> 24) & 0x1f));
765 e18 &= ~0x1f000000;
766 } else if (e18 & 0xc) {
767 /* g[] write fault? */
768 NV_INFO(dev, "PGRAPH_TRAP_TPDMA - TP %d - Global write fault at address %02x%08x\n",
769 i, e14, e10 | ((e18 >> 7) & 0x1f));
770 e18 &= ~0x00000f80;
771 } else {
772 NV_INFO(dev, "PGRAPH_TRAP_TPDMA - TP %d - Unknown CUDA fault at address %02x%08x\n",
773 i, e14, e10);
774 }
775 NV_INFO(dev, "PGRAPH_TRAP_TPDMA - TP %d - e0c: %08x, e18: %08x, e1c: %08x, e20: %08x, e24: %08x\n",
776 i, e0c, e18, e1c, e20, e24);
777 }
778 ustatus &= ~0x00000080;
779 }
780 }
781 break;
782 }
783 if (ustatus) {
784 if (display)
785 NV_INFO(dev, "%s - TP%d: Unhandled ustatus 0x%08x\n", name, i, ustatus);
786 }
787 nv_wr32(dev, ustatus_addr, 0xc0000000);
788 }
789
790 if (!tps && display)
791 NV_INFO(dev, "%s - No TPs claiming errors?\n", name);
792}
793
794static void
795nv50_pgraph_trap_handler(struct drm_device *dev)
796{
797 struct nouveau_pgraph_trap trap;
798 uint32_t status = nv_rd32(dev, 0x400108);
799 uint32_t ustatus;
800 int display = nouveau_ratelimit();
801
802
803 if (!status && display) {
804 nouveau_graph_trap_info(dev, &trap);
805 nouveau_graph_dump_trap_info(dev, "PGRAPH_TRAP", &trap);
806 NV_INFO(dev, "PGRAPH_TRAP - no units reporting traps?\n");
807 }
808
809 /* DISPATCH: Relays commands to other units and handles NOTIFY,
810 * COND, QUERY. If you get a trap from it, the command is still stuck
811 * in DISPATCH and you need to do something about it. */
812 if (status & 0x001) {
813 ustatus = nv_rd32(dev, 0x400804) & 0x7fffffff;
814 if (!ustatus && display) {
815 NV_INFO(dev, "PGRAPH_TRAP_DISPATCH - no ustatus?\n");
816 }
817
818 /* Known to be triggered by screwed up NOTIFY and COND... */
819 if (ustatus & 0x00000001) {
820 nv50_pfb_vm_trap(dev, display, "PGRAPH_TRAP_DISPATCH_FAULT");
821 nv_wr32(dev, 0x400500, 0);
822 if (nv_rd32(dev, 0x400808) & 0x80000000) {
823 if (display) {
824 if (nouveau_graph_trapped_channel(dev, &trap.channel))
825 trap.channel = -1;
826 trap.class = nv_rd32(dev, 0x400814);
827 trap.mthd = nv_rd32(dev, 0x400808) & 0x1ffc;
828 trap.subc = (nv_rd32(dev, 0x400808) >> 16) & 0x7;
829 trap.data = nv_rd32(dev, 0x40080c);
830 trap.data2 = nv_rd32(dev, 0x400810);
831 nouveau_graph_dump_trap_info(dev,
832 "PGRAPH_TRAP_DISPATCH_FAULT", &trap);
833 NV_INFO(dev, "PGRAPH_TRAP_DISPATCH_FAULT - 400808: %08x\n", nv_rd32(dev, 0x400808));
834 NV_INFO(dev, "PGRAPH_TRAP_DISPATCH_FAULT - 400848: %08x\n", nv_rd32(dev, 0x400848));
835 }
836 nv_wr32(dev, 0x400808, 0);
837 } else if (display) {
838 NV_INFO(dev, "PGRAPH_TRAP_DISPATCH_FAULT - No stuck command?\n");
839 }
840 nv_wr32(dev, 0x4008e8, nv_rd32(dev, 0x4008e8) & 3);
841 nv_wr32(dev, 0x400848, 0);
842 ustatus &= ~0x00000001;
843 }
844 if (ustatus & 0x00000002) {
845 nv50_pfb_vm_trap(dev, display, "PGRAPH_TRAP_DISPATCH_QUERY");
846 nv_wr32(dev, 0x400500, 0);
847 if (nv_rd32(dev, 0x40084c) & 0x80000000) {
848 if (display) {
849 if (nouveau_graph_trapped_channel(dev, &trap.channel))
850 trap.channel = -1;
851 trap.class = nv_rd32(dev, 0x400814);
852 trap.mthd = nv_rd32(dev, 0x40084c) & 0x1ffc;
853 trap.subc = (nv_rd32(dev, 0x40084c) >> 16) & 0x7;
854 trap.data = nv_rd32(dev, 0x40085c);
855 trap.data2 = 0;
856 nouveau_graph_dump_trap_info(dev,
857 "PGRAPH_TRAP_DISPATCH_QUERY", &trap);
858 NV_INFO(dev, "PGRAPH_TRAP_DISPATCH_QUERY - 40084c: %08x\n", nv_rd32(dev, 0x40084c));
859 }
860 nv_wr32(dev, 0x40084c, 0);
861 } else if (display) {
862 NV_INFO(dev, "PGRAPH_TRAP_DISPATCH_QUERY - No stuck command?\n");
863 }
864 ustatus &= ~0x00000002;
865 }
866 if (ustatus && display)
867 NV_INFO(dev, "PGRAPH_TRAP_DISPATCH - Unhandled ustatus 0x%08x\n", ustatus);
868 nv_wr32(dev, 0x400804, 0xc0000000);
869 nv_wr32(dev, 0x400108, 0x001);
870 status &= ~0x001;
871 }
872
873 /* TRAPs other than dispatch use the "normal" trap regs. */
874 if (status && display) {
875 nouveau_graph_trap_info(dev, &trap);
876 nouveau_graph_dump_trap_info(dev,
877 "PGRAPH_TRAP", &trap);
878 }
879
880 /* M2MF: Memory to memory copy engine. */
881 if (status & 0x002) {
882 ustatus = nv_rd32(dev, 0x406800) & 0x7fffffff;
883 if (!ustatus && display) {
884 NV_INFO(dev, "PGRAPH_TRAP_M2MF - no ustatus?\n");
885 }
886 if (ustatus & 0x00000001) {
887 nv50_pfb_vm_trap(dev, display, "PGRAPH_TRAP_M2MF_NOTIFY");
888 ustatus &= ~0x00000001;
889 }
890 if (ustatus & 0x00000002) {
891 nv50_pfb_vm_trap(dev, display, "PGRAPH_TRAP_M2MF_IN");
892 ustatus &= ~0x00000002;
893 }
894 if (ustatus & 0x00000004) {
895 nv50_pfb_vm_trap(dev, display, "PGRAPH_TRAP_M2MF_OUT");
896 ustatus &= ~0x00000004;
897 }
898 NV_INFO (dev, "PGRAPH_TRAP_M2MF - %08x %08x %08x %08x\n",
899 nv_rd32(dev, 0x406804),
900 nv_rd32(dev, 0x406808),
901 nv_rd32(dev, 0x40680c),
902 nv_rd32(dev, 0x406810));
903 if (ustatus && display)
904 NV_INFO(dev, "PGRAPH_TRAP_M2MF - Unhandled ustatus 0x%08x\n", ustatus);
905 /* No sane way found yet -- just reset the bugger. */
906 nv_wr32(dev, 0x400040, 2);
907 nv_wr32(dev, 0x400040, 0);
908 nv_wr32(dev, 0x406800, 0xc0000000);
909 nv_wr32(dev, 0x400108, 0x002);
910 status &= ~0x002;
911 }
912
913 /* VFETCH: Fetches data from vertex buffers. */
914 if (status & 0x004) {
915 ustatus = nv_rd32(dev, 0x400c04) & 0x7fffffff;
916 if (!ustatus && display) {
917 NV_INFO(dev, "PGRAPH_TRAP_VFETCH - no ustatus?\n");
918 }
919 if (ustatus & 0x00000001) {
920 nv50_pfb_vm_trap(dev, display, "PGRAPH_TRAP_VFETCH_FAULT");
921 NV_INFO (dev, "PGRAPH_TRAP_VFETCH_FAULT - %08x %08x %08x %08x\n",
922 nv_rd32(dev, 0x400c00),
923 nv_rd32(dev, 0x400c08),
924 nv_rd32(dev, 0x400c0c),
925 nv_rd32(dev, 0x400c10));
926 ustatus &= ~0x00000001;
927 }
928 if (ustatus && display)
929 NV_INFO(dev, "PGRAPH_TRAP_VFETCH - Unhandled ustatus 0x%08x\n", ustatus);
930 nv_wr32(dev, 0x400c04, 0xc0000000);
931 nv_wr32(dev, 0x400108, 0x004);
932 status &= ~0x004;
933 }
934
935 /* STRMOUT: DirectX streamout / OpenGL transform feedback. */
936 if (status & 0x008) {
937 ustatus = nv_rd32(dev, 0x401800) & 0x7fffffff;
938 if (!ustatus && display) {
939 NV_INFO(dev, "PGRAPH_TRAP_STRMOUT - no ustatus?\n");
940 }
941 if (ustatus & 0x00000001) {
942 nv50_pfb_vm_trap(dev, display, "PGRAPH_TRAP_STRMOUT_FAULT");
943 NV_INFO (dev, "PGRAPH_TRAP_STRMOUT_FAULT - %08x %08x %08x %08x\n",
944 nv_rd32(dev, 0x401804),
945 nv_rd32(dev, 0x401808),
946 nv_rd32(dev, 0x40180c),
947 nv_rd32(dev, 0x401810));
948 ustatus &= ~0x00000001;
949 }
950 if (ustatus && display)
951 NV_INFO(dev, "PGRAPH_TRAP_STRMOUT - Unhandled ustatus 0x%08x\n", ustatus);
952 /* No sane way found yet -- just reset the bugger. */
953 nv_wr32(dev, 0x400040, 0x80);
954 nv_wr32(dev, 0x400040, 0);
955 nv_wr32(dev, 0x401800, 0xc0000000);
956 nv_wr32(dev, 0x400108, 0x008);
957 status &= ~0x008;
958 }
959
960 /* CCACHE: Handles code and c[] caches and fills them. */
961 if (status & 0x010) {
962 ustatus = nv_rd32(dev, 0x405018) & 0x7fffffff;
963 if (!ustatus && display) {
964 NV_INFO(dev, "PGRAPH_TRAP_CCACHE - no ustatus?\n");
965 }
966 if (ustatus & 0x00000001) {
967 nv50_pfb_vm_trap(dev, display, "PGRAPH_TRAP_CCACHE_FAULT");
968 NV_INFO (dev, "PGRAPH_TRAP_CCACHE_FAULT - %08x %08x %08x %08x %08x %08x %08x\n",
969 nv_rd32(dev, 0x405800),
970 nv_rd32(dev, 0x405804),
971 nv_rd32(dev, 0x405808),
972 nv_rd32(dev, 0x40580c),
973 nv_rd32(dev, 0x405810),
974 nv_rd32(dev, 0x405814),
975 nv_rd32(dev, 0x40581c));
976 ustatus &= ~0x00000001;
977 }
978 if (ustatus && display)
979 NV_INFO(dev, "PGRAPH_TRAP_CCACHE - Unhandled ustatus 0x%08x\n", ustatus);
980 nv_wr32(dev, 0x405018, 0xc0000000);
981 nv_wr32(dev, 0x400108, 0x010);
982 status &= ~0x010;
983 }
984
985 /* Unknown, not seen yet... 0x402000 is the only trap status reg
986 * remaining, so try to handle it anyway. Perhaps related to that
987 * unknown DMA slot on tesla? */
988 if (status & 0x20) {
989 nv50_pfb_vm_trap(dev, display, "PGRAPH_TRAP_UNKC04");
990 ustatus = nv_rd32(dev, 0x402000) & 0x7fffffff;
991 if (display)
992 NV_INFO(dev, "PGRAPH_TRAP_UNKC04 - Unhandled ustatus 0x%08x\n", ustatus);
993 nv_wr32(dev, 0x402000, 0xc0000000);
994 /* no status modifiction on purpose */
995 }
996
997 /* TEXTURE: CUDA texturing units */
998 if (status & 0x040) {
999 nv50_pgraph_tp_trap (dev, 6, 0x408900, 0x408600, display,
1000 "PGRAPH_TRAP_TEXTURE");
1001 nv_wr32(dev, 0x400108, 0x040);
1002 status &= ~0x040;
1003 }
1004
1005 /* MP: CUDA execution engines. */
1006 if (status & 0x080) {
1007 nv50_pgraph_tp_trap (dev, 7, 0x408314, 0x40831c, display,
1008 "PGRAPH_TRAP_MP");
1009 nv_wr32(dev, 0x400108, 0x080);
1010 status &= ~0x080;
1011 }
1012
1013 /* TPDMA: Handles TP-initiated uncached memory accesses:
1014 * l[], g[], stack, 2d surfaces, render targets. */
1015 if (status & 0x100) {
1016 nv50_pgraph_tp_trap (dev, 8, 0x408e08, 0x408708, display,
1017 "PGRAPH_TRAP_TPDMA");
1018 nv_wr32(dev, 0x400108, 0x100);
1019 status &= ~0x100;
1020 }
1021
1022 if (status) {
1023 if (display)
1024 NV_INFO(dev, "PGRAPH_TRAP - Unknown trap 0x%08x\n",
1025 status);
1026 nv_wr32(dev, 0x400108, status);
1027 }
1028}
1029
1030/* There must be a *lot* of these. Will take some time to gather them up. */
1031static struct nouveau_enum_names nv50_data_error_names[] =
1032{
1033 { 4, "INVALID_VALUE" },
1034 { 5, "INVALID_ENUM" },
1035 { 8, "INVALID_OBJECT" },
1036 { 0xc, "INVALID_BITFIELD" },
1037 { 0x28, "MP_NO_REG_SPACE" },
1038 { 0x2b, "MP_BLOCK_SIZE_MISMATCH" },
1039};
1040
1041static void
581nv50_pgraph_irq_handler(struct drm_device *dev) 1042nv50_pgraph_irq_handler(struct drm_device *dev)
582{ 1043{
1044 struct nouveau_pgraph_trap trap;
1045 int unhandled = 0;
583 uint32_t status; 1046 uint32_t status;
584 1047
585 while ((status = nv_rd32(dev, NV03_PGRAPH_INTR))) { 1048 while ((status = nv_rd32(dev, NV03_PGRAPH_INTR))) {
586 uint32_t nsource = nv_rd32(dev, NV03_PGRAPH_NSOURCE); 1049 /* NOTIFY: You've set a NOTIFY an a command and it's done. */
587
588 if (status & 0x00000001) { 1050 if (status & 0x00000001) {
589 nouveau_pgraph_intr_notify(dev, nsource); 1051 nouveau_graph_trap_info(dev, &trap);
1052 if (nouveau_ratelimit())
1053 nouveau_graph_dump_trap_info(dev,
1054 "PGRAPH_NOTIFY", &trap);
590 status &= ~0x00000001; 1055 status &= ~0x00000001;
591 nv_wr32(dev, NV03_PGRAPH_INTR, 0x00000001); 1056 nv_wr32(dev, NV03_PGRAPH_INTR, 0x00000001);
592 } 1057 }
593 1058
594 if (status & 0x00000010) { 1059 /* COMPUTE_QUERY: Purpose and exact cause unknown, happens
595 nouveau_pgraph_intr_error(dev, nsource | 1060 * when you write 0x200 to 0x50c0 method 0x31c. */
596 NV03_PGRAPH_NSOURCE_ILLEGAL_MTHD); 1061 if (status & 0x00000002) {
1062 nouveau_graph_trap_info(dev, &trap);
1063 if (nouveau_ratelimit())
1064 nouveau_graph_dump_trap_info(dev,
1065 "PGRAPH_COMPUTE_QUERY", &trap);
1066 status &= ~0x00000002;
1067 nv_wr32(dev, NV03_PGRAPH_INTR, 0x00000002);
1068 }
597 1069
1070 /* Unknown, never seen: 0x4 */
1071
1072 /* ILLEGAL_MTHD: You used a wrong method for this class. */
1073 if (status & 0x00000010) {
1074 nouveau_graph_trap_info(dev, &trap);
1075 if (nouveau_pgraph_intr_swmthd(dev, &trap))
1076 unhandled = 1;
1077 if (unhandled && nouveau_ratelimit())
1078 nouveau_graph_dump_trap_info(dev,
1079 "PGRAPH_ILLEGAL_MTHD", &trap);
598 status &= ~0x00000010; 1080 status &= ~0x00000010;
599 nv_wr32(dev, NV03_PGRAPH_INTR, 0x00000010); 1081 nv_wr32(dev, NV03_PGRAPH_INTR, 0x00000010);
600 } 1082 }
601 1083
1084 /* ILLEGAL_CLASS: You used a wrong class. */
1085 if (status & 0x00000020) {
1086 nouveau_graph_trap_info(dev, &trap);
1087 if (nouveau_ratelimit())
1088 nouveau_graph_dump_trap_info(dev,
1089 "PGRAPH_ILLEGAL_CLASS", &trap);
1090 status &= ~0x00000020;
1091 nv_wr32(dev, NV03_PGRAPH_INTR, 0x00000020);
1092 }
1093
1094 /* DOUBLE_NOTIFY: You tried to set a NOTIFY on another NOTIFY. */
1095 if (status & 0x00000040) {
1096 nouveau_graph_trap_info(dev, &trap);
1097 if (nouveau_ratelimit())
1098 nouveau_graph_dump_trap_info(dev,
1099 "PGRAPH_DOUBLE_NOTIFY", &trap);
1100 status &= ~0x00000040;
1101 nv_wr32(dev, NV03_PGRAPH_INTR, 0x00000040);
1102 }
1103
1104 /* CONTEXT_SWITCH: PGRAPH needs us to load a new context */
602 if (status & 0x00001000) { 1105 if (status & 0x00001000) {
603 nv_wr32(dev, 0x400500, 0x00000000); 1106 nv_wr32(dev, 0x400500, 0x00000000);
604 nv_wr32(dev, NV03_PGRAPH_INTR, 1107 nv_wr32(dev, NV03_PGRAPH_INTR,
@@ -613,49 +1116,59 @@ nv50_pgraph_irq_handler(struct drm_device *dev)
613 status &= ~NV_PGRAPH_INTR_CONTEXT_SWITCH; 1116 status &= ~NV_PGRAPH_INTR_CONTEXT_SWITCH;
614 } 1117 }
615 1118
616 if (status & 0x00100000) { 1119 /* BUFFER_NOTIFY: Your m2mf transfer finished */
617 nouveau_pgraph_intr_error(dev, nsource | 1120 if (status & 0x00010000) {
618 NV03_PGRAPH_NSOURCE_DATA_ERROR); 1121 nouveau_graph_trap_info(dev, &trap);
1122 if (nouveau_ratelimit())
1123 nouveau_graph_dump_trap_info(dev,
1124 "PGRAPH_BUFFER_NOTIFY", &trap);
1125 status &= ~0x00010000;
1126 nv_wr32(dev, NV03_PGRAPH_INTR, 0x00010000);
1127 }
619 1128
1129 /* DATA_ERROR: Invalid value for this method, or invalid
1130 * state in current PGRAPH context for this operation */
1131 if (status & 0x00100000) {
1132 nouveau_graph_trap_info(dev, &trap);
1133 if (nouveau_ratelimit()) {
1134 nouveau_graph_dump_trap_info(dev,
1135 "PGRAPH_DATA_ERROR", &trap);
1136 NV_INFO (dev, "PGRAPH_DATA_ERROR - ");
1137 nouveau_print_enum_names(nv_rd32(dev, 0x400110),
1138 nv50_data_error_names);
1139 printk("\n");
1140 }
620 status &= ~0x00100000; 1141 status &= ~0x00100000;
621 nv_wr32(dev, NV03_PGRAPH_INTR, 0x00100000); 1142 nv_wr32(dev, NV03_PGRAPH_INTR, 0x00100000);
622 } 1143 }
623 1144
1145 /* TRAP: Something bad happened in the middle of command
1146 * execution. Has a billion types, subtypes, and even
1147 * subsubtypes. */
624 if (status & 0x00200000) { 1148 if (status & 0x00200000) {
625 int r; 1149 nv50_pgraph_trap_handler(dev);
626
627 nouveau_pgraph_intr_error(dev, nsource |
628 NV03_PGRAPH_NSOURCE_PROTECTION_ERROR);
629
630 NV_ERROR(dev, "magic set 1:\n");
631 for (r = 0x408900; r <= 0x408910; r += 4)
632 NV_ERROR(dev, "\t0x%08x: 0x%08x\n", r,
633 nv_rd32(dev, r));
634 nv_wr32(dev, 0x408900,
635 nv_rd32(dev, 0x408904) | 0xc0000000);
636 for (r = 0x408e08; r <= 0x408e24; r += 4)
637 NV_ERROR(dev, "\t0x%08x: 0x%08x\n", r,
638 nv_rd32(dev, r));
639 nv_wr32(dev, 0x408e08,
640 nv_rd32(dev, 0x408e08) | 0xc0000000);
641
642 NV_ERROR(dev, "magic set 2:\n");
643 for (r = 0x409900; r <= 0x409910; r += 4)
644 NV_ERROR(dev, "\t0x%08x: 0x%08x\n", r,
645 nv_rd32(dev, r));
646 nv_wr32(dev, 0x409900,
647 nv_rd32(dev, 0x409904) | 0xc0000000);
648 for (r = 0x409e08; r <= 0x409e24; r += 4)
649 NV_ERROR(dev, "\t0x%08x: 0x%08x\n", r,
650 nv_rd32(dev, r));
651 nv_wr32(dev, 0x409e08,
652 nv_rd32(dev, 0x409e08) | 0xc0000000);
653
654 status &= ~0x00200000; 1150 status &= ~0x00200000;
655 nv_wr32(dev, NV03_PGRAPH_NSOURCE, nsource);
656 nv_wr32(dev, NV03_PGRAPH_INTR, 0x00200000); 1151 nv_wr32(dev, NV03_PGRAPH_INTR, 0x00200000);
657 } 1152 }
658 1153
1154 /* Unknown, never seen: 0x00400000 */
1155
1156 /* SINGLE_STEP: Happens on every method if you turned on
1157 * single stepping in 40008c */
1158 if (status & 0x01000000) {
1159 nouveau_graph_trap_info(dev, &trap);
1160 if (nouveau_ratelimit())
1161 nouveau_graph_dump_trap_info(dev,
1162 "PGRAPH_SINGLE_STEP", &trap);
1163 status &= ~0x01000000;
1164 nv_wr32(dev, NV03_PGRAPH_INTR, 0x01000000);
1165 }
1166
1167 /* 0x02000000 happens when you pause a ctxprog...
1168 * but the only way this can happen that I know is by
1169 * poking the relevant MMIO register, and we don't
1170 * do that. */
1171
659 if (status) { 1172 if (status) {
660 NV_INFO(dev, "Unhandled PGRAPH_INTR - 0x%08x\n", 1173 NV_INFO(dev, "Unhandled PGRAPH_INTR - 0x%08x\n",
661 status); 1174 status);
@@ -672,7 +1185,8 @@ nv50_pgraph_irq_handler(struct drm_device *dev)
672 } 1185 }
673 1186
674 nv_wr32(dev, NV03_PMC_INTR_0, NV_PMC_INTR_0_PGRAPH_PENDING); 1187 nv_wr32(dev, NV03_PMC_INTR_0, NV_PMC_INTR_0_PGRAPH_PENDING);
675 nv_wr32(dev, 0x400824, nv_rd32(dev, 0x400824) & ~(1 << 31)); 1188 if (nv_rd32(dev, 0x400824) & (1 << 31))
1189 nv_wr32(dev, 0x400824, nv_rd32(dev, 0x400824) & ~(1 << 31));
676} 1190}
677 1191
678static void 1192static void
diff --git a/drivers/gpu/drm/nouveau/nouveau_mem.c b/drivers/gpu/drm/nouveau/nouveau_mem.c
index 2dc09dbd817..775a7017af6 100644
--- a/drivers/gpu/drm/nouveau/nouveau_mem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_mem.c
@@ -347,6 +347,20 @@ nv50_mem_vm_bind_linear(struct drm_device *dev, uint64_t virt, uint32_t size,
347 return -EBUSY; 347 return -EBUSY;
348 } 348 }
349 349
350 nv_wr32(dev, 0x100c80, 0x00040001);
351 if (!nv_wait(0x100c80, 0x00000001, 0x00000000)) {
352 NV_ERROR(dev, "timeout: (0x100c80 & 1) == 0 (2)\n");
353 NV_ERROR(dev, "0x100c80 = 0x%08x\n", nv_rd32(dev, 0x100c80));
354 return -EBUSY;
355 }
356
357 nv_wr32(dev, 0x100c80, 0x00060001);
358 if (!nv_wait(0x100c80, 0x00000001, 0x00000000)) {
359 NV_ERROR(dev, "timeout: (0x100c80 & 1) == 0 (2)\n");
360 NV_ERROR(dev, "0x100c80 = 0x%08x\n", nv_rd32(dev, 0x100c80));
361 return -EBUSY;
362 }
363
350 return 0; 364 return 0;
351} 365}
352 366
@@ -387,6 +401,20 @@ nv50_mem_vm_unbind(struct drm_device *dev, uint64_t virt, uint32_t size)
387 if (!nv_wait(0x100c80, 0x00000001, 0x00000000)) { 401 if (!nv_wait(0x100c80, 0x00000001, 0x00000000)) {
388 NV_ERROR(dev, "timeout: (0x100c80 & 1) == 0 (2)\n"); 402 NV_ERROR(dev, "timeout: (0x100c80 & 1) == 0 (2)\n");
389 NV_ERROR(dev, "0x100c80 = 0x%08x\n", nv_rd32(dev, 0x100c80)); 403 NV_ERROR(dev, "0x100c80 = 0x%08x\n", nv_rd32(dev, 0x100c80));
404 return;
405 }
406
407 nv_wr32(dev, 0x100c80, 0x00040001);
408 if (!nv_wait(0x100c80, 0x00000001, 0x00000000)) {
409 NV_ERROR(dev, "timeout: (0x100c80 & 1) == 0 (2)\n");
410 NV_ERROR(dev, "0x100c80 = 0x%08x\n", nv_rd32(dev, 0x100c80));
411 return;
412 }
413
414 nv_wr32(dev, 0x100c80, 0x00060001);
415 if (!nv_wait(0x100c80, 0x00000001, 0x00000000)) {
416 NV_ERROR(dev, "timeout: (0x100c80 & 1) == 0 (2)\n");
417 NV_ERROR(dev, "0x100c80 = 0x%08x\n", nv_rd32(dev, 0x100c80));
390 } 418 }
391} 419}
392 420
@@ -449,9 +477,30 @@ void nouveau_mem_close(struct drm_device *dev)
449 } 477 }
450} 478}
451 479
452/*XXX won't work on BSD because of pci_read_config_dword */
453static uint32_t 480static uint32_t
454nouveau_mem_fb_amount_igp(struct drm_device *dev) 481nouveau_mem_detect_nv04(struct drm_device *dev)
482{
483 uint32_t boot0 = nv_rd32(dev, NV03_BOOT_0);
484
485 if (boot0 & 0x00000100)
486 return (((boot0 >> 12) & 0xf) * 2 + 2) * 1024 * 1024;
487
488 switch (boot0 & NV03_BOOT_0_RAM_AMOUNT) {
489 case NV04_BOOT_0_RAM_AMOUNT_32MB:
490 return 32 * 1024 * 1024;
491 case NV04_BOOT_0_RAM_AMOUNT_16MB:
492 return 16 * 1024 * 1024;
493 case NV04_BOOT_0_RAM_AMOUNT_8MB:
494 return 8 * 1024 * 1024;
495 case NV04_BOOT_0_RAM_AMOUNT_4MB:
496 return 4 * 1024 * 1024;
497 }
498
499 return 0;
500}
501
502static uint32_t
503nouveau_mem_detect_nforce(struct drm_device *dev)
455{ 504{
456 struct drm_nouveau_private *dev_priv = dev->dev_private; 505 struct drm_nouveau_private *dev_priv = dev->dev_private;
457 struct pci_dev *bridge; 506 struct pci_dev *bridge;
@@ -463,11 +512,11 @@ nouveau_mem_fb_amount_igp(struct drm_device *dev)
463 return 0; 512 return 0;
464 } 513 }
465 514
466 if (dev_priv->flags&NV_NFORCE) { 515 if (dev_priv->flags & NV_NFORCE) {
467 pci_read_config_dword(bridge, 0x7C, &mem); 516 pci_read_config_dword(bridge, 0x7C, &mem);
468 return (uint64_t)(((mem >> 6) & 31) + 1)*1024*1024; 517 return (uint64_t)(((mem >> 6) & 31) + 1)*1024*1024;
469 } else 518 } else
470 if (dev_priv->flags&NV_NFORCE2) { 519 if (dev_priv->flags & NV_NFORCE2) {
471 pci_read_config_dword(bridge, 0x84, &mem); 520 pci_read_config_dword(bridge, 0x84, &mem);
472 return (uint64_t)(((mem >> 4) & 127) + 1)*1024*1024; 521 return (uint64_t)(((mem >> 4) & 127) + 1)*1024*1024;
473 } 522 }
@@ -477,50 +526,32 @@ nouveau_mem_fb_amount_igp(struct drm_device *dev)
477} 526}
478 527
479/* returns the amount of FB ram in bytes */ 528/* returns the amount of FB ram in bytes */
480uint64_t nouveau_mem_fb_amount(struct drm_device *dev) 529int
530nouveau_mem_detect(struct drm_device *dev)
481{ 531{
482 struct drm_nouveau_private *dev_priv = dev->dev_private; 532 struct drm_nouveau_private *dev_priv = dev->dev_private;
483 uint32_t boot0; 533
484 534 if (dev_priv->card_type == NV_04) {
485 switch (dev_priv->card_type) { 535 dev_priv->vram_size = nouveau_mem_detect_nv04(dev);
486 case NV_04: 536 } else
487 boot0 = nv_rd32(dev, NV03_BOOT_0); 537 if (dev_priv->flags & (NV_NFORCE | NV_NFORCE2)) {
488 if (boot0 & 0x00000100) 538 dev_priv->vram_size = nouveau_mem_detect_nforce(dev);
489 return (((boot0 >> 12) & 0xf) * 2 + 2) * 1024 * 1024; 539 } else {
490 540 dev_priv->vram_size = nv_rd32(dev, NV04_FIFO_DATA);
491 switch (boot0 & NV03_BOOT_0_RAM_AMOUNT) { 541 dev_priv->vram_size &= NV10_FIFO_DATA_RAM_AMOUNT_MB_MASK;
492 case NV04_BOOT_0_RAM_AMOUNT_32MB: 542 if (dev_priv->chipset == 0xaa || dev_priv->chipset == 0xac)
493 return 32 * 1024 * 1024; 543 dev_priv->vram_sys_base = nv_rd32(dev, 0x100e10) << 12;
494 case NV04_BOOT_0_RAM_AMOUNT_16MB:
495 return 16 * 1024 * 1024;
496 case NV04_BOOT_0_RAM_AMOUNT_8MB:
497 return 8 * 1024 * 1024;
498 case NV04_BOOT_0_RAM_AMOUNT_4MB:
499 return 4 * 1024 * 1024;
500 }
501 break;
502 case NV_10:
503 case NV_20:
504 case NV_30:
505 case NV_40:
506 case NV_50:
507 default:
508 if (dev_priv->flags & (NV_NFORCE | NV_NFORCE2)) {
509 return nouveau_mem_fb_amount_igp(dev);
510 } else {
511 uint64_t mem;
512 mem = (nv_rd32(dev, NV04_FIFO_DATA) &
513 NV10_FIFO_DATA_RAM_AMOUNT_MB_MASK) >>
514 NV10_FIFO_DATA_RAM_AMOUNT_MB_SHIFT;
515 return mem * 1024 * 1024;
516 }
517 break;
518 } 544 }
519 545
520 NV_ERROR(dev, 546 NV_INFO(dev, "Detected %dMiB VRAM\n", (int)(dev_priv->vram_size >> 20));
521 "Unable to detect video ram size. Please report your setup to " 547 if (dev_priv->vram_sys_base) {
522 DRIVER_EMAIL "\n"); 548 NV_INFO(dev, "Stolen system memory at: 0x%010llx\n",
523 return 0; 549 dev_priv->vram_sys_base);
550 }
551
552 if (dev_priv->vram_size)
553 return 0;
554 return -ENOMEM;
524} 555}
525 556
526#if __OS_HAS_AGP 557#if __OS_HAS_AGP
@@ -631,15 +662,12 @@ nouveau_mem_init(struct drm_device *dev)
631 spin_lock_init(&dev_priv->ttm.bo_list_lock); 662 spin_lock_init(&dev_priv->ttm.bo_list_lock);
632 spin_lock_init(&dev_priv->tile.lock); 663 spin_lock_init(&dev_priv->tile.lock);
633 664
634 dev_priv->fb_available_size = nouveau_mem_fb_amount(dev); 665 dev_priv->fb_available_size = dev_priv->vram_size;
635
636 dev_priv->fb_mappable_pages = dev_priv->fb_available_size; 666 dev_priv->fb_mappable_pages = dev_priv->fb_available_size;
637 if (dev_priv->fb_mappable_pages > drm_get_resource_len(dev, 1)) 667 if (dev_priv->fb_mappable_pages > drm_get_resource_len(dev, 1))
638 dev_priv->fb_mappable_pages = drm_get_resource_len(dev, 1); 668 dev_priv->fb_mappable_pages = drm_get_resource_len(dev, 1);
639 dev_priv->fb_mappable_pages >>= PAGE_SHIFT; 669 dev_priv->fb_mappable_pages >>= PAGE_SHIFT;
640 670
641 NV_INFO(dev, "%d MiB VRAM\n", (int)(dev_priv->fb_available_size >> 20));
642
643 /* remove reserved space at end of vram from available amount */ 671 /* remove reserved space at end of vram from available amount */
644 dev_priv->fb_available_size -= dev_priv->ramin_rsvd_vram; 672 dev_priv->fb_available_size -= dev_priv->ramin_rsvd_vram;
645 dev_priv->fb_aper_free = dev_priv->fb_available_size; 673 dev_priv->fb_aper_free = dev_priv->fb_available_size;
diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
index ed1590577b6..1d6ee8b5515 100644
--- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c
+++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
@@ -1,6 +1,7 @@
1#include "drmP.h" 1#include "drmP.h"
2#include "nouveau_drv.h" 2#include "nouveau_drv.h"
3#include <linux/pagemap.h> 3#include <linux/pagemap.h>
4#include <linux/slab.h>
4 5
5#define NV_CTXDMA_PAGE_SHIFT 12 6#define NV_CTXDMA_PAGE_SHIFT 12
6#define NV_CTXDMA_PAGE_SIZE (1 << NV_CTXDMA_PAGE_SHIFT) 7#define NV_CTXDMA_PAGE_SIZE (1 << NV_CTXDMA_PAGE_SHIFT)
@@ -171,6 +172,24 @@ nouveau_sgdma_unbind(struct ttm_backend *be)
171 } 172 }
172 dev_priv->engine.instmem.finish_access(nvbe->dev); 173 dev_priv->engine.instmem.finish_access(nvbe->dev);
173 174
175 if (dev_priv->card_type == NV_50) {
176 nv_wr32(dev, 0x100c80, 0x00050001);
177 if (!nv_wait(0x100c80, 0x00000001, 0x00000000)) {
178 NV_ERROR(dev, "timeout: (0x100c80 & 1) == 0 (2)\n");
179 NV_ERROR(dev, "0x100c80 = 0x%08x\n",
180 nv_rd32(dev, 0x100c80));
181 return -EBUSY;
182 }
183
184 nv_wr32(dev, 0x100c80, 0x00000001);
185 if (!nv_wait(0x100c80, 0x00000001, 0x00000000)) {
186 NV_ERROR(dev, "timeout: (0x100c80 & 1) == 0 (2)\n");
187 NV_ERROR(dev, "0x100c80 = 0x%08x\n",
188 nv_rd32(dev, 0x100c80));
189 return -EBUSY;
190 }
191 }
192
174 nvbe->bound = false; 193 nvbe->bound = false;
175 return 0; 194 return 0;
176} 195}
diff --git a/drivers/gpu/drm/nouveau/nouveau_state.c b/drivers/gpu/drm/nouveau/nouveau_state.c
index eb8f084d5f5..e1710640a27 100644
--- a/drivers/gpu/drm/nouveau/nouveau_state.c
+++ b/drivers/gpu/drm/nouveau/nouveau_state.c
@@ -24,6 +24,7 @@
24 */ 24 */
25 25
26#include <linux/swab.h> 26#include <linux/swab.h>
27#include <linux/slab.h>
27#include "drmP.h" 28#include "drmP.h"
28#include "drm.h" 29#include "drm.h"
29#include "drm_sarea.h" 30#include "drm_sarea.h"
@@ -35,7 +36,6 @@
35#include "nouveau_drm.h" 36#include "nouveau_drm.h"
36#include "nv50_display.h" 37#include "nv50_display.h"
37 38
38static int nouveau_stub_init(struct drm_device *dev) { return 0; }
39static void nouveau_stub_takedown(struct drm_device *dev) {} 39static void nouveau_stub_takedown(struct drm_device *dev) {}
40 40
41static int nouveau_init_engine_ptrs(struct drm_device *dev) 41static int nouveau_init_engine_ptrs(struct drm_device *dev)
@@ -277,8 +277,8 @@ static int nouveau_init_engine_ptrs(struct drm_device *dev)
277 engine->timer.init = nv04_timer_init; 277 engine->timer.init = nv04_timer_init;
278 engine->timer.read = nv04_timer_read; 278 engine->timer.read = nv04_timer_read;
279 engine->timer.takedown = nv04_timer_takedown; 279 engine->timer.takedown = nv04_timer_takedown;
280 engine->fb.init = nouveau_stub_init; 280 engine->fb.init = nv50_fb_init;
281 engine->fb.takedown = nouveau_stub_takedown; 281 engine->fb.takedown = nv50_fb_takedown;
282 engine->graph.grclass = nv50_graph_grclass; 282 engine->graph.grclass = nv50_graph_grclass;
283 engine->graph.init = nv50_graph_init; 283 engine->graph.init = nv50_graph_init;
284 engine->graph.takedown = nv50_graph_takedown; 284 engine->graph.takedown = nv50_graph_takedown;
@@ -341,7 +341,7 @@ nouveau_card_init_channel(struct drm_device *dev)
341 341
342 gpuobj = NULL; 342 gpuobj = NULL;
343 ret = nouveau_gpuobj_dma_new(dev_priv->channel, NV_CLASS_DMA_IN_MEMORY, 343 ret = nouveau_gpuobj_dma_new(dev_priv->channel, NV_CLASS_DMA_IN_MEMORY,
344 0, nouveau_mem_fb_amount(dev), 344 0, dev_priv->vram_size,
345 NV_DMA_ACCESS_RW, NV_DMA_TARGET_VIDMEM, 345 NV_DMA_ACCESS_RW, NV_DMA_TARGET_VIDMEM,
346 &gpuobj); 346 &gpuobj);
347 if (ret) 347 if (ret)
@@ -427,6 +427,10 @@ nouveau_card_init(struct drm_device *dev)
427 goto out; 427 goto out;
428 } 428 }
429 429
430 ret = nouveau_mem_detect(dev);
431 if (ret)
432 goto out_bios;
433
430 ret = nouveau_gpuobj_early_init(dev); 434 ret = nouveau_gpuobj_early_init(dev);
431 if (ret) 435 if (ret)
432 goto out_bios; 436 goto out_bios;
@@ -502,7 +506,7 @@ nouveau_card_init(struct drm_device *dev)
502 else 506 else
503 ret = nv04_display_create(dev); 507 ret = nv04_display_create(dev);
504 if (ret) 508 if (ret)
505 goto out_irq; 509 goto out_channel;
506 } 510 }
507 511
508 ret = nouveau_backlight_init(dev); 512 ret = nouveau_backlight_init(dev);
@@ -516,6 +520,11 @@ nouveau_card_init(struct drm_device *dev)
516 520
517 return 0; 521 return 0;
518 522
523out_channel:
524 if (dev_priv->channel) {
525 nouveau_channel_free(dev_priv->channel);
526 dev_priv->channel = NULL;
527 }
519out_irq: 528out_irq:
520 drm_irq_uninstall(dev); 529 drm_irq_uninstall(dev);
521out_fifo: 530out_fifo:
@@ -533,6 +542,7 @@ out_mc:
533out_gpuobj: 542out_gpuobj:
534 nouveau_gpuobj_takedown(dev); 543 nouveau_gpuobj_takedown(dev);
535out_mem: 544out_mem:
545 nouveau_sgdma_takedown(dev);
536 nouveau_mem_close(dev); 546 nouveau_mem_close(dev);
537out_instmem: 547out_instmem:
538 engine->instmem.takedown(dev); 548 engine->instmem.takedown(dev);
diff --git a/drivers/gpu/drm/nouveau/nv04_crtc.c b/drivers/gpu/drm/nouveau/nv04_crtc.c
index a1d1ebb073d..eba687f1099 100644
--- a/drivers/gpu/drm/nouveau/nv04_crtc.c
+++ b/drivers/gpu/drm/nouveau/nv04_crtc.c
@@ -230,9 +230,9 @@ nv_crtc_mode_set_vga(struct drm_crtc *crtc, struct drm_display_mode *mode)
230 struct drm_framebuffer *fb = crtc->fb; 230 struct drm_framebuffer *fb = crtc->fb;
231 231
232 /* Calculate our timings */ 232 /* Calculate our timings */
233 int horizDisplay = (mode->crtc_hdisplay >> 3) - 1; 233 int horizDisplay = (mode->crtc_hdisplay >> 3) - 1;
234 int horizStart = (mode->crtc_hsync_start >> 3) - 1; 234 int horizStart = (mode->crtc_hsync_start >> 3) + 1;
235 int horizEnd = (mode->crtc_hsync_end >> 3) - 1; 235 int horizEnd = (mode->crtc_hsync_end >> 3) + 1;
236 int horizTotal = (mode->crtc_htotal >> 3) - 5; 236 int horizTotal = (mode->crtc_htotal >> 3) - 5;
237 int horizBlankStart = (mode->crtc_hdisplay >> 3) - 1; 237 int horizBlankStart = (mode->crtc_hdisplay >> 3) - 1;
238 int horizBlankEnd = (mode->crtc_htotal >> 3) - 1; 238 int horizBlankEnd = (mode->crtc_htotal >> 3) - 1;
diff --git a/drivers/gpu/drm/nouveau/nv04_fbcon.c b/drivers/gpu/drm/nouveau/nv04_fbcon.c
index 3da90c2c4e6..813b25cec72 100644
--- a/drivers/gpu/drm/nouveau/nv04_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nv04_fbcon.c
@@ -118,8 +118,8 @@ nv04_fbcon_imageblit(struct fb_info *info, const struct fb_image *image)
118 return; 118 return;
119 } 119 }
120 120
121 width = ALIGN(image->width, 32); 121 width = ALIGN(image->width, 8);
122 dsize = (width * image->height) >> 5; 122 dsize = ALIGN(width * image->height, 32) >> 5;
123 123
124 if (info->fix.visual == FB_VISUAL_TRUECOLOR || 124 if (info->fix.visual == FB_VISUAL_TRUECOLOR ||
125 info->fix.visual == FB_VISUAL_DIRECTCOLOR) { 125 info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
@@ -136,8 +136,8 @@ nv04_fbcon_imageblit(struct fb_info *info, const struct fb_image *image)
136 ((image->dx + image->width) & 0xffff)); 136 ((image->dx + image->width) & 0xffff));
137 OUT_RING(chan, bg); 137 OUT_RING(chan, bg);
138 OUT_RING(chan, fg); 138 OUT_RING(chan, fg);
139 OUT_RING(chan, (image->height << 16) | image->width);
140 OUT_RING(chan, (image->height << 16) | width); 139 OUT_RING(chan, (image->height << 16) | width);
140 OUT_RING(chan, (image->height << 16) | image->width);
141 OUT_RING(chan, (image->dy << 16) | (image->dx & 0xffff)); 141 OUT_RING(chan, (image->dy << 16) | (image->dx & 0xffff));
142 142
143 while (dsize) { 143 while (dsize) {
diff --git a/drivers/gpu/drm/nouveau/nv40_fifo.c b/drivers/gpu/drm/nouveau/nv40_fifo.c
index 6b2ef4a9fce..500ccfd3a0b 100644
--- a/drivers/gpu/drm/nouveau/nv40_fifo.c
+++ b/drivers/gpu/drm/nouveau/nv40_fifo.c
@@ -278,7 +278,7 @@ nv40_fifo_init_ramxx(struct drm_device *dev)
278 default: 278 default:
279 nv_wr32(dev, 0x2230, 0); 279 nv_wr32(dev, 0x2230, 0);
280 nv_wr32(dev, NV40_PFIFO_RAMFC, 280 nv_wr32(dev, NV40_PFIFO_RAMFC,
281 ((nouveau_mem_fb_amount(dev) - 512 * 1024 + 281 ((dev_priv->vram_size - 512 * 1024 +
282 dev_priv->ramfc_offset) >> 16) | (3 << 16)); 282 dev_priv->ramfc_offset) >> 16) | (3 << 16));
283 break; 283 break;
284 } 284 }
diff --git a/drivers/gpu/drm/nouveau/nv40_graph.c b/drivers/gpu/drm/nouveau/nv40_graph.c
index 53e8afe1dcd..0616c96e4b6 100644
--- a/drivers/gpu/drm/nouveau/nv40_graph.c
+++ b/drivers/gpu/drm/nouveau/nv40_graph.c
@@ -335,6 +335,27 @@ nv40_graph_init(struct drm_device *dev)
335 nv_wr32(dev, 0x400b38, 0x2ffff800); 335 nv_wr32(dev, 0x400b38, 0x2ffff800);
336 nv_wr32(dev, 0x400b3c, 0x00006000); 336 nv_wr32(dev, 0x400b3c, 0x00006000);
337 337
338 /* Tiling related stuff. */
339 switch (dev_priv->chipset) {
340 case 0x44:
341 case 0x4a:
342 nv_wr32(dev, 0x400bc4, 0x1003d888);
343 nv_wr32(dev, 0x400bbc, 0xb7a7b500);
344 break;
345 case 0x46:
346 nv_wr32(dev, 0x400bc4, 0x0000e024);
347 nv_wr32(dev, 0x400bbc, 0xb7a7b520);
348 break;
349 case 0x4c:
350 case 0x4e:
351 case 0x67:
352 nv_wr32(dev, 0x400bc4, 0x1003d888);
353 nv_wr32(dev, 0x400bbc, 0xb7a7b540);
354 break;
355 default:
356 break;
357 }
358
338 /* Turn all the tiling regions off. */ 359 /* Turn all the tiling regions off. */
339 for (i = 0; i < pfb->num_tiles; i++) 360 for (i = 0; i < pfb->num_tiles; i++)
340 nv40_graph_set_region_tiling(dev, i, 0, 0, 0); 361 nv40_graph_set_region_tiling(dev, i, 0, 0, 0);
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c
index 61a89f2dc55..649db4c1b69 100644
--- a/drivers/gpu/drm/nouveau/nv50_display.c
+++ b/drivers/gpu/drm/nouveau/nv50_display.c
@@ -143,7 +143,7 @@ nv50_evo_channel_new(struct drm_device *dev, struct nouveau_channel **pchan)
143 } 143 }
144 144
145 ret = nv50_evo_dmaobj_new(chan, 0x3d, NvEvoVRAM, 0, 0x19, 145 ret = nv50_evo_dmaobj_new(chan, 0x3d, NvEvoVRAM, 0, 0x19,
146 0, nouveau_mem_fb_amount(dev)); 146 0, dev_priv->vram_size);
147 if (ret) { 147 if (ret) {
148 nv50_evo_channel_del(pchan); 148 nv50_evo_channel_del(pchan);
149 return ret; 149 return ret;
@@ -231,7 +231,7 @@ nv50_display_init(struct drm_device *dev)
231 /* This used to be in crtc unblank, but seems out of place there. */ 231 /* This used to be in crtc unblank, but seems out of place there. */
232 nv_wr32(dev, NV50_PDISPLAY_UNK_380, 0); 232 nv_wr32(dev, NV50_PDISPLAY_UNK_380, 0);
233 /* RAM is clamped to 256 MiB. */ 233 /* RAM is clamped to 256 MiB. */
234 ram_amount = nouveau_mem_fb_amount(dev); 234 ram_amount = dev_priv->vram_size;
235 NV_DEBUG_KMS(dev, "ram_amount %d\n", ram_amount); 235 NV_DEBUG_KMS(dev, "ram_amount %d\n", ram_amount);
236 if (ram_amount > 256*1024*1024) 236 if (ram_amount > 256*1024*1024)
237 ram_amount = 256*1024*1024; 237 ram_amount = 256*1024*1024;
@@ -522,15 +522,17 @@ int nv50_display_create(struct drm_device *dev)
522 } 522 }
523 523
524 for (i = 0 ; i < dcb->connector.entries; i++) { 524 for (i = 0 ; i < dcb->connector.entries; i++) {
525 if (i != 0 && dcb->connector.entry[i].index == 525 if (i != 0 && dcb->connector.entry[i].index2 ==
526 dcb->connector.entry[i - 1].index) 526 dcb->connector.entry[i - 1].index2)
527 continue; 527 continue;
528 nouveau_connector_create(dev, &dcb->connector.entry[i]); 528 nouveau_connector_create(dev, &dcb->connector.entry[i]);
529 } 529 }
530 530
531 ret = nv50_display_init(dev); 531 ret = nv50_display_init(dev);
532 if (ret) 532 if (ret) {
533 nv50_display_destroy(dev);
533 return ret; 534 return ret;
535 }
534 536
535 return 0; 537 return 0;
536} 538}
@@ -885,10 +887,12 @@ nv50_display_error_handler(struct drm_device *dev)
885 nv_wr32(dev, NV50_PDISPLAY_TRAPPED_ADDR, 0x90000000); 887 nv_wr32(dev, NV50_PDISPLAY_TRAPPED_ADDR, 0x90000000);
886} 888}
887 889
888static void 890void
889nv50_display_irq_hotplug(struct drm_device *dev) 891nv50_display_irq_hotplug_bh(struct work_struct *work)
890{ 892{
891 struct drm_nouveau_private *dev_priv = dev->dev_private; 893 struct drm_nouveau_private *dev_priv =
894 container_of(work, struct drm_nouveau_private, hpd_work);
895 struct drm_device *dev = dev_priv->dev;
892 struct drm_connector *connector; 896 struct drm_connector *connector;
893 const uint32_t gpio_reg[4] = { 0xe104, 0xe108, 0xe280, 0xe284 }; 897 const uint32_t gpio_reg[4] = { 0xe104, 0xe108, 0xe280, 0xe284 };
894 uint32_t unplug_mask, plug_mask, change_mask; 898 uint32_t unplug_mask, plug_mask, change_mask;
@@ -949,8 +953,10 @@ nv50_display_irq_handler(struct drm_device *dev)
949 struct drm_nouveau_private *dev_priv = dev->dev_private; 953 struct drm_nouveau_private *dev_priv = dev->dev_private;
950 uint32_t delayed = 0; 954 uint32_t delayed = 0;
951 955
952 while (nv_rd32(dev, NV50_PMC_INTR_0) & NV50_PMC_INTR_0_HOTPLUG) 956 if (nv_rd32(dev, NV50_PMC_INTR_0) & NV50_PMC_INTR_0_HOTPLUG) {
953 nv50_display_irq_hotplug(dev); 957 if (!work_pending(&dev_priv->hpd_work))
958 queue_work(dev_priv->wq, &dev_priv->hpd_work);
959 }
954 960
955 while (nv_rd32(dev, NV50_PMC_INTR_0) & NV50_PMC_INTR_0_DISPLAY) { 961 while (nv_rd32(dev, NV50_PMC_INTR_0) & NV50_PMC_INTR_0_DISPLAY) {
956 uint32_t intr0 = nv_rd32(dev, NV50_PDISPLAY_INTR_0); 962 uint32_t intr0 = nv_rd32(dev, NV50_PDISPLAY_INTR_0);
diff --git a/drivers/gpu/drm/nouveau/nv50_display.h b/drivers/gpu/drm/nouveau/nv50_display.h
index 3ae8d0725f6..581d405ac01 100644
--- a/drivers/gpu/drm/nouveau/nv50_display.h
+++ b/drivers/gpu/drm/nouveau/nv50_display.h
@@ -37,6 +37,7 @@
37 37
38void nv50_display_irq_handler(struct drm_device *dev); 38void nv50_display_irq_handler(struct drm_device *dev);
39void nv50_display_irq_handler_bh(struct work_struct *work); 39void nv50_display_irq_handler_bh(struct work_struct *work);
40void nv50_display_irq_hotplug_bh(struct work_struct *work);
40int nv50_display_init(struct drm_device *dev); 41int nv50_display_init(struct drm_device *dev);
41int nv50_display_create(struct drm_device *dev); 42int nv50_display_create(struct drm_device *dev);
42int nv50_display_destroy(struct drm_device *dev); 43int nv50_display_destroy(struct drm_device *dev);
diff --git a/drivers/gpu/drm/nouveau/nv50_fb.c b/drivers/gpu/drm/nouveau/nv50_fb.c
new file mode 100644
index 00000000000..a95e6941ba8
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nv50_fb.c
@@ -0,0 +1,32 @@
1#include "drmP.h"
2#include "drm.h"
3#include "nouveau_drv.h"
4#include "nouveau_drm.h"
5
6int
7nv50_fb_init(struct drm_device *dev)
8{
9 /* This is needed to get meaningful information from 100c90
10 * on traps. No idea what these values mean exactly. */
11 struct drm_nouveau_private *dev_priv = dev->dev_private;
12
13 switch (dev_priv->chipset) {
14 case 0x50:
15 nv_wr32(dev, 0x100c90, 0x0707ff);
16 break;
17 case 0xa5:
18 case 0xa8:
19 nv_wr32(dev, 0x100c90, 0x0d0fff);
20 break;
21 default:
22 nv_wr32(dev, 0x100c90, 0x1d07ff);
23 break;
24 }
25
26 return 0;
27}
28
29void
30nv50_fb_takedown(struct drm_device *dev)
31{
32}
diff --git a/drivers/gpu/drm/nouveau/nv50_fbcon.c b/drivers/gpu/drm/nouveau/nv50_fbcon.c
index 993c7126fbd..a8c70e7e918 100644
--- a/drivers/gpu/drm/nouveau/nv50_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nv50_fbcon.c
@@ -157,8 +157,11 @@ nv50_fbcon_accel_init(struct fb_info *info)
157 struct drm_nouveau_private *dev_priv = dev->dev_private; 157 struct drm_nouveau_private *dev_priv = dev->dev_private;
158 struct nouveau_channel *chan = dev_priv->channel; 158 struct nouveau_channel *chan = dev_priv->channel;
159 struct nouveau_gpuobj *eng2d = NULL; 159 struct nouveau_gpuobj *eng2d = NULL;
160 uint64_t fb;
160 int ret, format; 161 int ret, format;
161 162
163 fb = info->fix.smem_start - dev_priv->fb_phys + dev_priv->vm_vram_base;
164
162 switch (info->var.bits_per_pixel) { 165 switch (info->var.bits_per_pixel) {
163 case 8: 166 case 8:
164 format = 0xf3; 167 format = 0xf3;
@@ -233,7 +236,7 @@ nv50_fbcon_accel_init(struct fb_info *info)
233 BEGIN_RING(chan, NvSub2D, 0x0808, 3); 236 BEGIN_RING(chan, NvSub2D, 0x0808, 3);
234 OUT_RING(chan, 0); 237 OUT_RING(chan, 0);
235 OUT_RING(chan, 0); 238 OUT_RING(chan, 0);
236 OUT_RING(chan, 0); 239 OUT_RING(chan, 1);
237 BEGIN_RING(chan, NvSub2D, 0x081c, 1); 240 BEGIN_RING(chan, NvSub2D, 0x081c, 1);
238 OUT_RING(chan, 1); 241 OUT_RING(chan, 1);
239 BEGIN_RING(chan, NvSub2D, 0x0840, 4); 242 BEGIN_RING(chan, NvSub2D, 0x0840, 4);
@@ -248,9 +251,8 @@ nv50_fbcon_accel_init(struct fb_info *info)
248 OUT_RING(chan, info->fix.line_length); 251 OUT_RING(chan, info->fix.line_length);
249 OUT_RING(chan, info->var.xres_virtual); 252 OUT_RING(chan, info->var.xres_virtual);
250 OUT_RING(chan, info->var.yres_virtual); 253 OUT_RING(chan, info->var.yres_virtual);
251 OUT_RING(chan, 0); 254 OUT_RING(chan, upper_32_bits(fb));
252 OUT_RING(chan, info->fix.smem_start - dev_priv->fb_phys + 255 OUT_RING(chan, lower_32_bits(fb));
253 dev_priv->vm_vram_base);
254 BEGIN_RING(chan, NvSub2D, 0x0230, 2); 256 BEGIN_RING(chan, NvSub2D, 0x0230, 2);
255 OUT_RING(chan, format); 257 OUT_RING(chan, format);
256 OUT_RING(chan, 1); 258 OUT_RING(chan, 1);
@@ -258,9 +260,8 @@ nv50_fbcon_accel_init(struct fb_info *info)
258 OUT_RING(chan, info->fix.line_length); 260 OUT_RING(chan, info->fix.line_length);
259 OUT_RING(chan, info->var.xres_virtual); 261 OUT_RING(chan, info->var.xres_virtual);
260 OUT_RING(chan, info->var.yres_virtual); 262 OUT_RING(chan, info->var.yres_virtual);
261 OUT_RING(chan, 0); 263 OUT_RING(chan, upper_32_bits(fb));
262 OUT_RING(chan, info->fix.smem_start - dev_priv->fb_phys + 264 OUT_RING(chan, lower_32_bits(fb));
263 dev_priv->vm_vram_base);
264 265
265 return 0; 266 return 0;
266} 267}
diff --git a/drivers/gpu/drm/nouveau/nv50_gpio.c b/drivers/gpu/drm/nouveau/nv50_gpio.c
new file mode 100644
index 00000000000..c61782b314e
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nv50_gpio.c
@@ -0,0 +1,76 @@
1/*
2 * Copyright 2010 Red Hat Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Ben Skeggs
23 */
24
25#include "drmP.h"
26#include "nouveau_drv.h"
27#include "nouveau_hw.h"
28
29static int
30nv50_gpio_location(struct dcb_gpio_entry *gpio, uint32_t *reg, uint32_t *shift)
31{
32 const uint32_t nv50_gpio_reg[4] = { 0xe104, 0xe108, 0xe280, 0xe284 };
33
34 if (gpio->line > 32)
35 return -EINVAL;
36
37 *reg = nv50_gpio_reg[gpio->line >> 3];
38 *shift = (gpio->line & 7) << 2;
39 return 0;
40}
41
42int
43nv50_gpio_get(struct drm_device *dev, enum dcb_gpio_tag tag)
44{
45 struct dcb_gpio_entry *gpio;
46 uint32_t r, s, v;
47
48 gpio = nouveau_bios_gpio_entry(dev, tag);
49 if (!gpio)
50 return -ENOENT;
51
52 if (nv50_gpio_location(gpio, &r, &s))
53 return -EINVAL;
54
55 v = nv_rd32(dev, r) >> (s + 2);
56 return ((v & 1) == (gpio->state[1] & 1));
57}
58
59int
60nv50_gpio_set(struct drm_device *dev, enum dcb_gpio_tag tag, int state)
61{
62 struct dcb_gpio_entry *gpio;
63 uint32_t r, s, v;
64
65 gpio = nouveau_bios_gpio_entry(dev, tag);
66 if (!gpio)
67 return -ENOENT;
68
69 if (nv50_gpio_location(gpio, &r, &s))
70 return -EINVAL;
71
72 v = nv_rd32(dev, r) & ~(0x3 << s);
73 v |= (gpio->state[state] ^ 2) << s;
74 nv_wr32(dev, r, v);
75 return 0;
76}
diff --git a/drivers/gpu/drm/nouveau/nv50_graph.c b/drivers/gpu/drm/nouveau/nv50_graph.c
index 857a09671a3..b203d06f601 100644
--- a/drivers/gpu/drm/nouveau/nv50_graph.c
+++ b/drivers/gpu/drm/nouveau/nv50_graph.c
@@ -56,6 +56,10 @@ nv50_graph_init_intr(struct drm_device *dev)
56static void 56static void
57nv50_graph_init_regs__nv(struct drm_device *dev) 57nv50_graph_init_regs__nv(struct drm_device *dev)
58{ 58{
59 struct drm_nouveau_private *dev_priv = dev->dev_private;
60 uint32_t units = nv_rd32(dev, 0x1540);
61 int i;
62
59 NV_DEBUG(dev, "\n"); 63 NV_DEBUG(dev, "\n");
60 64
61 nv_wr32(dev, 0x400804, 0xc0000000); 65 nv_wr32(dev, 0x400804, 0xc0000000);
@@ -65,6 +69,20 @@ nv50_graph_init_regs__nv(struct drm_device *dev)
65 nv_wr32(dev, 0x405018, 0xc0000000); 69 nv_wr32(dev, 0x405018, 0xc0000000);
66 nv_wr32(dev, 0x402000, 0xc0000000); 70 nv_wr32(dev, 0x402000, 0xc0000000);
67 71
72 for (i = 0; i < 16; i++) {
73 if (units & 1 << i) {
74 if (dev_priv->chipset < 0xa0) {
75 nv_wr32(dev, 0x408900 + (i << 12), 0xc0000000);
76 nv_wr32(dev, 0x408e08 + (i << 12), 0xc0000000);
77 nv_wr32(dev, 0x408314 + (i << 12), 0xc0000000);
78 } else {
79 nv_wr32(dev, 0x408600 + (i << 11), 0xc0000000);
80 nv_wr32(dev, 0x408708 + (i << 11), 0xc0000000);
81 nv_wr32(dev, 0x40831c + (i << 11), 0xc0000000);
82 }
83 }
84 }
85
68 nv_wr32(dev, 0x400108, 0xffffffff); 86 nv_wr32(dev, 0x400108, 0xffffffff);
69 87
70 nv_wr32(dev, 0x400824, 0x00004000); 88 nv_wr32(dev, 0x400824, 0x00004000);
@@ -229,10 +247,6 @@ nv50_graph_create_context(struct nouveau_channel *chan)
229 nouveau_grctx_vals_load(dev, ctx); 247 nouveau_grctx_vals_load(dev, ctx);
230 } 248 }
231 nv_wo32(dev, ctx, 0x00000/4, chan->ramin->instance >> 12); 249 nv_wo32(dev, ctx, 0x00000/4, chan->ramin->instance >> 12);
232 if ((dev_priv->chipset & 0xf0) == 0xa0)
233 nv_wo32(dev, ctx, 0x00004/4, 0x00000000);
234 else
235 nv_wo32(dev, ctx, 0x0011c/4, 0x00000000);
236 dev_priv->engine.instmem.finish_access(dev); 250 dev_priv->engine.instmem.finish_access(dev);
237 251
238 return 0; 252 return 0;
@@ -396,9 +410,10 @@ struct nouveau_pgraph_object_class nv50_graph_grclass[] = {
396 { 0x5039, false, NULL }, /* m2mf */ 410 { 0x5039, false, NULL }, /* m2mf */
397 { 0x502d, false, NULL }, /* 2d */ 411 { 0x502d, false, NULL }, /* 2d */
398 { 0x50c0, false, NULL }, /* compute */ 412 { 0x50c0, false, NULL }, /* compute */
413 { 0x85c0, false, NULL }, /* compute (nva3, nva5, nva8) */
399 { 0x5097, false, NULL }, /* tesla (nv50) */ 414 { 0x5097, false, NULL }, /* tesla (nv50) */
400 { 0x8297, false, NULL }, /* tesla (nv80/nv90) */ 415 { 0x8297, false, NULL }, /* tesla (nv8x/nv9x) */
401 { 0x8397, false, NULL }, /* tesla (nva0) */ 416 { 0x8397, false, NULL }, /* tesla (nva0, nvaa, nvac) */
402 { 0x8597, false, NULL }, /* tesla (nva8) */ 417 { 0x8597, false, NULL }, /* tesla (nva3, nva5, nva8) */
403 {} 418 {}
404}; 419};
diff --git a/drivers/gpu/drm/nouveau/nv50_grctx.c b/drivers/gpu/drm/nouveau/nv50_grctx.c
index d105fcd42ca..42a8fb20c1e 100644
--- a/drivers/gpu/drm/nouveau/nv50_grctx.c
+++ b/drivers/gpu/drm/nouveau/nv50_grctx.c
@@ -55,15 +55,18 @@
55#define CP_FLAG_AUTO_LOAD ((2 * 32) + 5) 55#define CP_FLAG_AUTO_LOAD ((2 * 32) + 5)
56#define CP_FLAG_AUTO_LOAD_NOT_PENDING 0 56#define CP_FLAG_AUTO_LOAD_NOT_PENDING 0
57#define CP_FLAG_AUTO_LOAD_PENDING 1 57#define CP_FLAG_AUTO_LOAD_PENDING 1
58#define CP_FLAG_NEWCTX ((2 * 32) + 10)
59#define CP_FLAG_NEWCTX_BUSY 0
60#define CP_FLAG_NEWCTX_DONE 1
58#define CP_FLAG_XFER ((2 * 32) + 11) 61#define CP_FLAG_XFER ((2 * 32) + 11)
59#define CP_FLAG_XFER_IDLE 0 62#define CP_FLAG_XFER_IDLE 0
60#define CP_FLAG_XFER_BUSY 1 63#define CP_FLAG_XFER_BUSY 1
61#define CP_FLAG_NEWCTX ((2 * 32) + 12)
62#define CP_FLAG_NEWCTX_BUSY 0
63#define CP_FLAG_NEWCTX_DONE 1
64#define CP_FLAG_ALWAYS ((2 * 32) + 13) 64#define CP_FLAG_ALWAYS ((2 * 32) + 13)
65#define CP_FLAG_ALWAYS_FALSE 0 65#define CP_FLAG_ALWAYS_FALSE 0
66#define CP_FLAG_ALWAYS_TRUE 1 66#define CP_FLAG_ALWAYS_TRUE 1
67#define CP_FLAG_INTR ((2 * 32) + 15)
68#define CP_FLAG_INTR_NOT_PENDING 0
69#define CP_FLAG_INTR_PENDING 1
67 70
68#define CP_CTX 0x00100000 71#define CP_CTX 0x00100000
69#define CP_CTX_COUNT 0x000f0000 72#define CP_CTX_COUNT 0x000f0000
@@ -174,6 +177,7 @@ nv50_grctx_init(struct nouveau_grctx *ctx)
174 case 0x96: 177 case 0x96:
175 case 0x98: 178 case 0x98:
176 case 0xa0: 179 case 0xa0:
180 case 0xa3:
177 case 0xa5: 181 case 0xa5:
178 case 0xa8: 182 case 0xa8:
179 case 0xaa: 183 case 0xaa:
@@ -214,6 +218,8 @@ nv50_grctx_init(struct nouveau_grctx *ctx)
214 cp_name(ctx, cp_setup_save); 218 cp_name(ctx, cp_setup_save);
215 cp_set (ctx, UNK1D, SET); 219 cp_set (ctx, UNK1D, SET);
216 cp_wait(ctx, STATUS, BUSY); 220 cp_wait(ctx, STATUS, BUSY);
221 cp_wait(ctx, INTR, PENDING);
222 cp_bra (ctx, STATUS, BUSY, cp_setup_save);
217 cp_set (ctx, UNK01, SET); 223 cp_set (ctx, UNK01, SET);
218 cp_set (ctx, SWAP_DIRECTION, SAVE); 224 cp_set (ctx, SWAP_DIRECTION, SAVE);
219 225
@@ -269,7 +275,7 @@ nv50_graph_construct_mmio(struct nouveau_grctx *ctx)
269 int offset, base; 275 int offset, base;
270 uint32_t units = nv_rd32 (ctx->dev, 0x1540); 276 uint32_t units = nv_rd32 (ctx->dev, 0x1540);
271 277
272 /* 0800 */ 278 /* 0800: DISPATCH */
273 cp_ctx(ctx, 0x400808, 7); 279 cp_ctx(ctx, 0x400808, 7);
274 gr_def(ctx, 0x400814, 0x00000030); 280 gr_def(ctx, 0x400814, 0x00000030);
275 cp_ctx(ctx, 0x400834, 0x32); 281 cp_ctx(ctx, 0x400834, 0x32);
@@ -300,7 +306,7 @@ nv50_graph_construct_mmio(struct nouveau_grctx *ctx)
300 gr_def(ctx, 0x400b20, 0x0001629d); 306 gr_def(ctx, 0x400b20, 0x0001629d);
301 } 307 }
302 308
303 /* 0C00 */ 309 /* 0C00: VFETCH */
304 cp_ctx(ctx, 0x400c08, 0x2); 310 cp_ctx(ctx, 0x400c08, 0x2);
305 gr_def(ctx, 0x400c08, 0x0000fe0c); 311 gr_def(ctx, 0x400c08, 0x0000fe0c);
306 312
@@ -326,7 +332,7 @@ nv50_graph_construct_mmio(struct nouveau_grctx *ctx)
326 cp_ctx(ctx, 0x401540, 0x5); 332 cp_ctx(ctx, 0x401540, 0x5);
327 gr_def(ctx, 0x401550, 0x00001018); 333 gr_def(ctx, 0x401550, 0x00001018);
328 334
329 /* 1800 */ 335 /* 1800: STREAMOUT */
330 cp_ctx(ctx, 0x401814, 0x1); 336 cp_ctx(ctx, 0x401814, 0x1);
331 gr_def(ctx, 0x401814, 0x000000ff); 337 gr_def(ctx, 0x401814, 0x000000ff);
332 if (dev_priv->chipset == 0x50) { 338 if (dev_priv->chipset == 0x50) {
@@ -359,6 +365,7 @@ nv50_graph_construct_mmio(struct nouveau_grctx *ctx)
359 case 0xac: 365 case 0xac:
360 gr_def(ctx, 0x401c00, 0x042500df); 366 gr_def(ctx, 0x401c00, 0x042500df);
361 break; 367 break;
368 case 0xa3:
362 case 0xa5: 369 case 0xa5:
363 case 0xa8: 370 case 0xa8:
364 gr_def(ctx, 0x401c00, 0x142500df); 371 gr_def(ctx, 0x401c00, 0x142500df);
@@ -413,6 +420,7 @@ nv50_graph_construct_mmio(struct nouveau_grctx *ctx)
413 break; 420 break;
414 case 0x84: 421 case 0x84:
415 case 0xa0: 422 case 0xa0:
423 case 0xa3:
416 case 0xa5: 424 case 0xa5:
417 case 0xa8: 425 case 0xa8:
418 case 0xaa: 426 case 0xaa:
@@ -641,7 +649,7 @@ nv50_graph_construct_mmio(struct nouveau_grctx *ctx)
641 if (dev_priv->chipset == 0x50) 649 if (dev_priv->chipset == 0x50)
642 cp_ctx(ctx, 0x4063e0, 0x1); 650 cp_ctx(ctx, 0x4063e0, 0x1);
643 651
644 /* 6800 */ 652 /* 6800: M2MF */
645 if (dev_priv->chipset < 0x90) { 653 if (dev_priv->chipset < 0x90) {
646 cp_ctx(ctx, 0x406814, 0x2b); 654 cp_ctx(ctx, 0x406814, 0x2b);
647 gr_def(ctx, 0x406818, 0x00000f80); 655 gr_def(ctx, 0x406818, 0x00000f80);
@@ -787,6 +795,7 @@ nv50_graph_construct_mmio(struct nouveau_grctx *ctx)
787 case 0xa5: 795 case 0xa5:
788 gr_def(ctx, offset + 0x1c, 0x310c0000); 796 gr_def(ctx, offset + 0x1c, 0x310c0000);
789 break; 797 break;
798 case 0xa3:
790 case 0xa8: 799 case 0xa8:
791 case 0xaa: 800 case 0xaa:
792 case 0xac: 801 case 0xac:
@@ -854,6 +863,8 @@ nv50_graph_construct_mmio(struct nouveau_grctx *ctx)
854 else 863 else
855 gr_def(ctx, offset + 0x8, 0x05010202); 864 gr_def(ctx, offset + 0x8, 0x05010202);
856 gr_def(ctx, offset + 0xc, 0x00030201); 865 gr_def(ctx, offset + 0xc, 0x00030201);
866 if (dev_priv->chipset == 0xa3)
867 cp_ctx(ctx, base + 0x36c, 1);
857 868
858 cp_ctx(ctx, base + 0x400, 2); 869 cp_ctx(ctx, base + 0x400, 2);
859 gr_def(ctx, base + 0x404, 0x00000040); 870 gr_def(ctx, base + 0x404, 0x00000040);
@@ -1154,7 +1165,9 @@ nv50_graph_construct_xfer1(struct nouveau_grctx *ctx)
1154 nv50_graph_construct_gene_unk8(ctx); 1165 nv50_graph_construct_gene_unk8(ctx);
1155 if (dev_priv->chipset == 0xa0) 1166 if (dev_priv->chipset == 0xa0)
1156 xf_emit(ctx, 0x189, 0); 1167 xf_emit(ctx, 0x189, 0);
1157 else if (dev_priv->chipset < 0xa8) 1168 else if (dev_priv->chipset == 0xa3)
1169 xf_emit(ctx, 0xd5, 0);
1170 else if (dev_priv->chipset == 0xa5)
1158 xf_emit(ctx, 0x99, 0); 1171 xf_emit(ctx, 0x99, 0);
1159 else if (dev_priv->chipset == 0xaa) 1172 else if (dev_priv->chipset == 0xaa)
1160 xf_emit(ctx, 0x65, 0); 1173 xf_emit(ctx, 0x65, 0);
@@ -1192,6 +1205,8 @@ nv50_graph_construct_xfer1(struct nouveau_grctx *ctx)
1192 ctx->ctxvals_pos = offset + 4; 1205 ctx->ctxvals_pos = offset + 4;
1193 if (dev_priv->chipset == 0xa0) 1206 if (dev_priv->chipset == 0xa0)
1194 xf_emit(ctx, 0xa80, 0); 1207 xf_emit(ctx, 0xa80, 0);
1208 else if (dev_priv->chipset == 0xa3)
1209 xf_emit(ctx, 0xa7c, 0);
1195 else 1210 else
1196 xf_emit(ctx, 0xa7a, 0); 1211 xf_emit(ctx, 0xa7a, 0);
1197 xf_emit(ctx, 1, 0x3fffff); 1212 xf_emit(ctx, 1, 0x3fffff);
@@ -1336,6 +1351,7 @@ nv50_graph_construct_gene_unk1(struct nouveau_grctx *ctx)
1336 xf_emit(ctx, 0x942, 0); 1351 xf_emit(ctx, 0x942, 0);
1337 break; 1352 break;
1338 case 0xa0: 1353 case 0xa0:
1354 case 0xa3:
1339 xf_emit(ctx, 0x2042, 0); 1355 xf_emit(ctx, 0x2042, 0);
1340 break; 1356 break;
1341 case 0xa5: 1357 case 0xa5:
diff --git a/drivers/gpu/drm/nouveau/nv50_instmem.c b/drivers/gpu/drm/nouveau/nv50_instmem.c
index de1f5b0062c..5f21df31f3a 100644
--- a/drivers/gpu/drm/nouveau/nv50_instmem.c
+++ b/drivers/gpu/drm/nouveau/nv50_instmem.c
@@ -63,9 +63,10 @@ nv50_instmem_init(struct drm_device *dev)
63 struct drm_nouveau_private *dev_priv = dev->dev_private; 63 struct drm_nouveau_private *dev_priv = dev->dev_private;
64 struct nouveau_channel *chan; 64 struct nouveau_channel *chan;
65 uint32_t c_offset, c_size, c_ramfc, c_vmpd, c_base, pt_size; 65 uint32_t c_offset, c_size, c_ramfc, c_vmpd, c_base, pt_size;
66 uint32_t save_nv001700;
67 uint64_t v;
66 struct nv50_instmem_priv *priv; 68 struct nv50_instmem_priv *priv;
67 int ret, i; 69 int ret, i;
68 uint32_t v, save_nv001700;
69 70
70 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 71 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
71 if (!priv) 72 if (!priv)
@@ -76,17 +77,12 @@ nv50_instmem_init(struct drm_device *dev)
76 for (i = 0x1700; i <= 0x1710; i += 4) 77 for (i = 0x1700; i <= 0x1710; i += 4)
77 priv->save1700[(i-0x1700)/4] = nv_rd32(dev, i); 78 priv->save1700[(i-0x1700)/4] = nv_rd32(dev, i);
78 79
79 if (dev_priv->chipset == 0xaa || dev_priv->chipset == 0xac)
80 dev_priv->vram_sys_base = nv_rd32(dev, 0x100e10) << 12;
81 else
82 dev_priv->vram_sys_base = 0;
83
84 /* Reserve the last MiB of VRAM, we should probably try to avoid 80 /* Reserve the last MiB of VRAM, we should probably try to avoid
85 * setting up the below tables over the top of the VBIOS image at 81 * setting up the below tables over the top of the VBIOS image at
86 * some point. 82 * some point.
87 */ 83 */
88 dev_priv->ramin_rsvd_vram = 1 << 20; 84 dev_priv->ramin_rsvd_vram = 1 << 20;
89 c_offset = nouveau_mem_fb_amount(dev) - dev_priv->ramin_rsvd_vram; 85 c_offset = dev_priv->vram_size - dev_priv->ramin_rsvd_vram;
90 c_size = 128 << 10; 86 c_size = 128 << 10;
91 c_vmpd = ((dev_priv->chipset & 0xf0) == 0x50) ? 0x1400 : 0x200; 87 c_vmpd = ((dev_priv->chipset & 0xf0) == 0x50) ? 0x1400 : 0x200;
92 c_ramfc = ((dev_priv->chipset & 0xf0) == 0x50) ? 0x0 : 0x20; 88 c_ramfc = ((dev_priv->chipset & 0xf0) == 0x50) ? 0x0 : 0x20;
@@ -106,7 +102,7 @@ nv50_instmem_init(struct drm_device *dev)
106 dev_priv->vm_gart_size = NV50_VM_BLOCK; 102 dev_priv->vm_gart_size = NV50_VM_BLOCK;
107 103
108 dev_priv->vm_vram_base = dev_priv->vm_gart_base + dev_priv->vm_gart_size; 104 dev_priv->vm_vram_base = dev_priv->vm_gart_base + dev_priv->vm_gart_size;
109 dev_priv->vm_vram_size = nouveau_mem_fb_amount(dev); 105 dev_priv->vm_vram_size = dev_priv->vram_size;
110 if (dev_priv->vm_vram_size > NV50_VM_MAX_VRAM) 106 if (dev_priv->vm_vram_size > NV50_VM_MAX_VRAM)
111 dev_priv->vm_vram_size = NV50_VM_MAX_VRAM; 107 dev_priv->vm_vram_size = NV50_VM_MAX_VRAM;
112 dev_priv->vm_vram_size = roundup(dev_priv->vm_vram_size, NV50_VM_BLOCK); 108 dev_priv->vm_vram_size = roundup(dev_priv->vm_vram_size, NV50_VM_BLOCK);
@@ -189,8 +185,8 @@ nv50_instmem_init(struct drm_device *dev)
189 185
190 i = 0; 186 i = 0;
191 while (v < dev_priv->vram_sys_base + c_offset + c_size) { 187 while (v < dev_priv->vram_sys_base + c_offset + c_size) {
192 BAR0_WI32(priv->pramin_pt->gpuobj, i + 0, v); 188 BAR0_WI32(priv->pramin_pt->gpuobj, i + 0, lower_32_bits(v));
193 BAR0_WI32(priv->pramin_pt->gpuobj, i + 4, 0x00000000); 189 BAR0_WI32(priv->pramin_pt->gpuobj, i + 4, upper_32_bits(v));
194 v += 0x1000; 190 v += 0x1000;
195 i += 8; 191 i += 8;
196 } 192 }
diff --git a/drivers/gpu/drm/nouveau/nv50_sor.c b/drivers/gpu/drm/nouveau/nv50_sor.c
index c2fff543b06..0c68698f23d 100644
--- a/drivers/gpu/drm/nouveau/nv50_sor.c
+++ b/drivers/gpu/drm/nouveau/nv50_sor.c
@@ -211,7 +211,7 @@ nv50_sor_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode,
211 mode_ctl = 0x0200; 211 mode_ctl = 0x0200;
212 break; 212 break;
213 case OUTPUT_DP: 213 case OUTPUT_DP:
214 mode_ctl |= 0x00050000; 214 mode_ctl |= (nv_encoder->dp.mc_unknown << 16);
215 if (nv_encoder->dcb->sorconf.link & 1) 215 if (nv_encoder->dcb->sorconf.link & 1)
216 mode_ctl |= 0x00000800; 216 mode_ctl |= 0x00000800;
217 else 217 else
@@ -274,6 +274,7 @@ static const struct drm_encoder_funcs nv50_sor_encoder_funcs = {
274int 274int
275nv50_sor_create(struct drm_device *dev, struct dcb_entry *entry) 275nv50_sor_create(struct drm_device *dev, struct dcb_entry *entry)
276{ 276{
277 struct drm_nouveau_private *dev_priv = dev->dev_private;
277 struct nouveau_encoder *nv_encoder = NULL; 278 struct nouveau_encoder *nv_encoder = NULL;
278 struct drm_encoder *encoder; 279 struct drm_encoder *encoder;
279 bool dum; 280 bool dum;
@@ -319,5 +320,27 @@ nv50_sor_create(struct drm_device *dev, struct dcb_entry *entry)
319 encoder->possible_crtcs = entry->heads; 320 encoder->possible_crtcs = entry->heads;
320 encoder->possible_clones = 0; 321 encoder->possible_clones = 0;
321 322
323 if (nv_encoder->dcb->type == OUTPUT_DP) {
324 uint32_t mc, or = nv_encoder->or;
325
326 if (dev_priv->chipset < 0x90 ||
327 dev_priv->chipset == 0x92 || dev_priv->chipset == 0xa0)
328 mc = nv_rd32(dev, NV50_PDISPLAY_SOR_MODE_CTRL_C(or));
329 else
330 mc = nv_rd32(dev, NV90_PDISPLAY_SOR_MODE_CTRL_C(or));
331
332 switch ((mc & 0x00000f00) >> 8) {
333 case 8:
334 case 9:
335 nv_encoder->dp.mc_unknown = (mc & 0x000f0000) >> 16;
336 break;
337 default:
338 break;
339 }
340
341 if (!nv_encoder->dp.mc_unknown)
342 nv_encoder->dp.mc_unknown = 5;
343 }
344
322 return 0; 345 return 0;
323} 346}
diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
index 4c39a407aa4..e671d0e74d4 100644
--- a/drivers/gpu/drm/r128/r128_cce.c
+++ b/drivers/gpu/drm/r128/r128_cce.c
@@ -31,6 +31,7 @@
31 31
32#include <linux/firmware.h> 32#include <linux/firmware.h>
33#include <linux/platform_device.h> 33#include <linux/platform_device.h>
34#include <linux/slab.h>
34 35
35#include "drmP.h" 36#include "drmP.h"
36#include "drm.h" 37#include "drm.h"
diff --git a/drivers/gpu/drm/radeon/Makefile b/drivers/gpu/drm/radeon/Makefile
index ed38262d998..3c91312dea9 100644
--- a/drivers/gpu/drm/radeon/Makefile
+++ b/drivers/gpu/drm/radeon/Makefile
@@ -50,7 +50,7 @@ $(obj)/r600_cs.o: $(obj)/r600_reg_safe.h
50radeon-y := radeon_drv.o radeon_cp.o radeon_state.o radeon_mem.o \ 50radeon-y := radeon_drv.o radeon_cp.o radeon_state.o radeon_mem.o \
51 radeon_irq.o r300_cmdbuf.o r600_cp.o 51 radeon_irq.o r300_cmdbuf.o r600_cp.o
52# add KMS driver 52# add KMS driver
53radeon-y += radeon_device.o radeon_kms.o \ 53radeon-y += radeon_device.o radeon_asic.o radeon_kms.o \
54 radeon_atombios.o radeon_agp.o atombios_crtc.o radeon_combios.o \ 54 radeon_atombios.o radeon_agp.o atombios_crtc.o radeon_combios.o \
55 atom.o radeon_fence.o radeon_ttm.o radeon_object.o radeon_gart.o \ 55 atom.o radeon_fence.o radeon_ttm.o radeon_object.o radeon_gart.o \
56 radeon_legacy_crtc.o radeon_legacy_encoders.o radeon_connectors.o \ 56 radeon_legacy_crtc.o radeon_legacy_encoders.o radeon_connectors.o \
diff --git a/drivers/gpu/drm/radeon/atom.c b/drivers/gpu/drm/radeon/atom.c
index d75788feac6..1d569830ed9 100644
--- a/drivers/gpu/drm/radeon/atom.c
+++ b/drivers/gpu/drm/radeon/atom.c
@@ -24,6 +24,7 @@
24 24
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/sched.h> 26#include <linux/sched.h>
27#include <linux/slab.h>
27#include <asm/unaligned.h> 28#include <asm/unaligned.h>
28 29
29#define ATOM_DEBUG 30#define ATOM_DEBUG
@@ -52,15 +53,17 @@
52 53
53typedef struct { 54typedef struct {
54 struct atom_context *ctx; 55 struct atom_context *ctx;
55
56 uint32_t *ps, *ws; 56 uint32_t *ps, *ws;
57 int ps_shift; 57 int ps_shift;
58 uint16_t start; 58 uint16_t start;
59 unsigned last_jump;
60 unsigned long last_jump_jiffies;
61 bool abort;
59} atom_exec_context; 62} atom_exec_context;
60 63
61int atom_debug = 0; 64int atom_debug = 0;
62static void atom_execute_table_locked(struct atom_context *ctx, int index, uint32_t * params); 65static int atom_execute_table_locked(struct atom_context *ctx, int index, uint32_t * params);
63void atom_execute_table(struct atom_context *ctx, int index, uint32_t * params); 66int atom_execute_table(struct atom_context *ctx, int index, uint32_t * params);
64 67
65static uint32_t atom_arg_mask[8] = 68static uint32_t atom_arg_mask[8] =
66 { 0xFFFFFFFF, 0xFFFF, 0xFFFF00, 0xFFFF0000, 0xFF, 0xFF00, 0xFF0000, 69 { 0xFFFFFFFF, 0xFFFF, 0xFFFF00, 0xFFFF0000, 0xFF, 0xFF00, 0xFF0000,
@@ -604,12 +607,17 @@ static void atom_op_beep(atom_exec_context *ctx, int *ptr, int arg)
604static void atom_op_calltable(atom_exec_context *ctx, int *ptr, int arg) 607static void atom_op_calltable(atom_exec_context *ctx, int *ptr, int arg)
605{ 608{
606 int idx = U8((*ptr)++); 609 int idx = U8((*ptr)++);
610 int r = 0;
611
607 if (idx < ATOM_TABLE_NAMES_CNT) 612 if (idx < ATOM_TABLE_NAMES_CNT)
608 SDEBUG(" table: %d (%s)\n", idx, atom_table_names[idx]); 613 SDEBUG(" table: %d (%s)\n", idx, atom_table_names[idx]);
609 else 614 else
610 SDEBUG(" table: %d\n", idx); 615 SDEBUG(" table: %d\n", idx);
611 if (U16(ctx->ctx->cmd_table + 4 + 2 * idx)) 616 if (U16(ctx->ctx->cmd_table + 4 + 2 * idx))
612 atom_execute_table_locked(ctx->ctx, idx, ctx->ps + ctx->ps_shift); 617 r = atom_execute_table_locked(ctx->ctx, idx, ctx->ps + ctx->ps_shift);
618 if (r) {
619 ctx->abort = true;
620 }
613} 621}
614 622
615static void atom_op_clear(atom_exec_context *ctx, int *ptr, int arg) 623static void atom_op_clear(atom_exec_context *ctx, int *ptr, int arg)
@@ -673,6 +681,8 @@ static void atom_op_eot(atom_exec_context *ctx, int *ptr, int arg)
673static void atom_op_jump(atom_exec_context *ctx, int *ptr, int arg) 681static void atom_op_jump(atom_exec_context *ctx, int *ptr, int arg)
674{ 682{
675 int execute = 0, target = U16(*ptr); 683 int execute = 0, target = U16(*ptr);
684 unsigned long cjiffies;
685
676 (*ptr) += 2; 686 (*ptr) += 2;
677 switch (arg) { 687 switch (arg) {
678 case ATOM_COND_ABOVE: 688 case ATOM_COND_ABOVE:
@@ -700,8 +710,25 @@ static void atom_op_jump(atom_exec_context *ctx, int *ptr, int arg)
700 if (arg != ATOM_COND_ALWAYS) 710 if (arg != ATOM_COND_ALWAYS)
701 SDEBUG(" taken: %s\n", execute ? "yes" : "no"); 711 SDEBUG(" taken: %s\n", execute ? "yes" : "no");
702 SDEBUG(" target: 0x%04X\n", target); 712 SDEBUG(" target: 0x%04X\n", target);
703 if (execute) 713 if (execute) {
714 if (ctx->last_jump == (ctx->start + target)) {
715 cjiffies = jiffies;
716 if (time_after(cjiffies, ctx->last_jump_jiffies)) {
717 cjiffies -= ctx->last_jump_jiffies;
718 if ((jiffies_to_msecs(cjiffies) > 1000)) {
719 DRM_ERROR("atombios stuck in loop for more than 1sec aborting\n");
720 ctx->abort = true;
721 }
722 } else {
723 /* jiffies wrap around we will just wait a little longer */
724 ctx->last_jump_jiffies = jiffies;
725 }
726 } else {
727 ctx->last_jump = ctx->start + target;
728 ctx->last_jump_jiffies = jiffies;
729 }
704 *ptr = ctx->start + target; 730 *ptr = ctx->start + target;
731 }
705} 732}
706 733
707static void atom_op_mask(atom_exec_context *ctx, int *ptr, int arg) 734static void atom_op_mask(atom_exec_context *ctx, int *ptr, int arg)
@@ -881,11 +908,16 @@ static void atom_op_shl(atom_exec_context *ctx, int *ptr, int arg)
881 uint8_t attr = U8((*ptr)++), shift; 908 uint8_t attr = U8((*ptr)++), shift;
882 uint32_t saved, dst; 909 uint32_t saved, dst;
883 int dptr = *ptr; 910 int dptr = *ptr;
911 uint32_t dst_align = atom_dst_to_src[(attr >> 3) & 7][(attr >> 6) & 3];
884 SDEBUG(" dst: "); 912 SDEBUG(" dst: ");
885 dst = atom_get_dst(ctx, arg, attr, ptr, &saved, 1); 913 dst = atom_get_dst(ctx, arg, attr, ptr, &saved, 1);
914 /* op needs to full dst value */
915 dst = saved;
886 shift = atom_get_src(ctx, attr, ptr); 916 shift = atom_get_src(ctx, attr, ptr);
887 SDEBUG(" shift: %d\n", shift); 917 SDEBUG(" shift: %d\n", shift);
888 dst <<= shift; 918 dst <<= shift;
919 dst &= atom_arg_mask[dst_align];
920 dst >>= atom_arg_shift[dst_align];
889 SDEBUG(" dst: "); 921 SDEBUG(" dst: ");
890 atom_put_dst(ctx, arg, attr, &dptr, dst, saved); 922 atom_put_dst(ctx, arg, attr, &dptr, dst, saved);
891} 923}
@@ -895,11 +927,16 @@ static void atom_op_shr(atom_exec_context *ctx, int *ptr, int arg)
895 uint8_t attr = U8((*ptr)++), shift; 927 uint8_t attr = U8((*ptr)++), shift;
896 uint32_t saved, dst; 928 uint32_t saved, dst;
897 int dptr = *ptr; 929 int dptr = *ptr;
930 uint32_t dst_align = atom_dst_to_src[(attr >> 3) & 7][(attr >> 6) & 3];
898 SDEBUG(" dst: "); 931 SDEBUG(" dst: ");
899 dst = atom_get_dst(ctx, arg, attr, ptr, &saved, 1); 932 dst = atom_get_dst(ctx, arg, attr, ptr, &saved, 1);
933 /* op needs to full dst value */
934 dst = saved;
900 shift = atom_get_src(ctx, attr, ptr); 935 shift = atom_get_src(ctx, attr, ptr);
901 SDEBUG(" shift: %d\n", shift); 936 SDEBUG(" shift: %d\n", shift);
902 dst >>= shift; 937 dst >>= shift;
938 dst &= atom_arg_mask[dst_align];
939 dst >>= atom_arg_shift[dst_align];
903 SDEBUG(" dst: "); 940 SDEBUG(" dst: ");
904 atom_put_dst(ctx, arg, attr, &dptr, dst, saved); 941 atom_put_dst(ctx, arg, attr, &dptr, dst, saved);
905} 942}
@@ -1104,15 +1141,16 @@ static struct {
1104 atom_op_shr, ATOM_ARG_MC}, { 1141 atom_op_shr, ATOM_ARG_MC}, {
1105atom_op_debug, 0},}; 1142atom_op_debug, 0},};
1106 1143
1107static void atom_execute_table_locked(struct atom_context *ctx, int index, uint32_t * params) 1144static int atom_execute_table_locked(struct atom_context *ctx, int index, uint32_t * params)
1108{ 1145{
1109 int base = CU16(ctx->cmd_table + 4 + 2 * index); 1146 int base = CU16(ctx->cmd_table + 4 + 2 * index);
1110 int len, ws, ps, ptr; 1147 int len, ws, ps, ptr;
1111 unsigned char op; 1148 unsigned char op;
1112 atom_exec_context ectx; 1149 atom_exec_context ectx;
1150 int ret = 0;
1113 1151
1114 if (!base) 1152 if (!base)
1115 return; 1153 return -EINVAL;
1116 1154
1117 len = CU16(base + ATOM_CT_SIZE_PTR); 1155 len = CU16(base + ATOM_CT_SIZE_PTR);
1118 ws = CU8(base + ATOM_CT_WS_PTR); 1156 ws = CU8(base + ATOM_CT_WS_PTR);
@@ -1125,6 +1163,8 @@ static void atom_execute_table_locked(struct atom_context *ctx, int index, uint3
1125 ectx.ps_shift = ps / 4; 1163 ectx.ps_shift = ps / 4;
1126 ectx.start = base; 1164 ectx.start = base;
1127 ectx.ps = params; 1165 ectx.ps = params;
1166 ectx.abort = false;
1167 ectx.last_jump = 0;
1128 if (ws) 1168 if (ws)
1129 ectx.ws = kzalloc(4 * ws, GFP_KERNEL); 1169 ectx.ws = kzalloc(4 * ws, GFP_KERNEL);
1130 else 1170 else
@@ -1137,6 +1177,12 @@ static void atom_execute_table_locked(struct atom_context *ctx, int index, uint3
1137 SDEBUG("%s @ 0x%04X\n", atom_op_names[op], ptr - 1); 1177 SDEBUG("%s @ 0x%04X\n", atom_op_names[op], ptr - 1);
1138 else 1178 else
1139 SDEBUG("[%d] @ 0x%04X\n", op, ptr - 1); 1179 SDEBUG("[%d] @ 0x%04X\n", op, ptr - 1);
1180 if (ectx.abort) {
1181 DRM_ERROR("atombios stuck executing %04X (len %d, WS %d, PS %d) @ 0x%04X\n",
1182 base, len, ws, ps, ptr - 1);
1183 ret = -EINVAL;
1184 goto free;
1185 }
1140 1186
1141 if (op < ATOM_OP_CNT && op > 0) 1187 if (op < ATOM_OP_CNT && op > 0)
1142 opcode_table[op].func(&ectx, &ptr, 1188 opcode_table[op].func(&ectx, &ptr,
@@ -1150,12 +1196,16 @@ static void atom_execute_table_locked(struct atom_context *ctx, int index, uint3
1150 debug_depth--; 1196 debug_depth--;
1151 SDEBUG("<<\n"); 1197 SDEBUG("<<\n");
1152 1198
1199free:
1153 if (ws) 1200 if (ws)
1154 kfree(ectx.ws); 1201 kfree(ectx.ws);
1202 return ret;
1155} 1203}
1156 1204
1157void atom_execute_table(struct atom_context *ctx, int index, uint32_t * params) 1205int atom_execute_table(struct atom_context *ctx, int index, uint32_t * params)
1158{ 1206{
1207 int r;
1208
1159 mutex_lock(&ctx->mutex); 1209 mutex_lock(&ctx->mutex);
1160 /* reset reg block */ 1210 /* reset reg block */
1161 ctx->reg_block = 0; 1211 ctx->reg_block = 0;
@@ -1163,8 +1213,9 @@ void atom_execute_table(struct atom_context *ctx, int index, uint32_t * params)
1163 ctx->fb_base = 0; 1213 ctx->fb_base = 0;
1164 /* reset io mode */ 1214 /* reset io mode */
1165 ctx->io_mode = ATOM_IO_MM; 1215 ctx->io_mode = ATOM_IO_MM;
1166 atom_execute_table_locked(ctx, index, params); 1216 r = atom_execute_table_locked(ctx, index, params);
1167 mutex_unlock(&ctx->mutex); 1217 mutex_unlock(&ctx->mutex);
1218 return r;
1168} 1219}
1169 1220
1170static int atom_iio_len[] = { 1, 2, 3, 3, 3, 3, 4, 4, 4, 3 }; 1221static int atom_iio_len[] = { 1, 2, 3, 3, 3, 3, 4, 4, 4, 3 };
@@ -1248,9 +1299,7 @@ int atom_asic_init(struct atom_context *ctx)
1248 1299
1249 if (!CU16(ctx->cmd_table + 4 + 2 * ATOM_CMD_INIT)) 1300 if (!CU16(ctx->cmd_table + 4 + 2 * ATOM_CMD_INIT))
1250 return 1; 1301 return 1;
1251 atom_execute_table(ctx, ATOM_CMD_INIT, ps); 1302 return atom_execute_table(ctx, ATOM_CMD_INIT, ps);
1252
1253 return 0;
1254} 1303}
1255 1304
1256void atom_destroy(struct atom_context *ctx) 1305void atom_destroy(struct atom_context *ctx)
@@ -1260,12 +1309,16 @@ void atom_destroy(struct atom_context *ctx)
1260 kfree(ctx); 1309 kfree(ctx);
1261} 1310}
1262 1311
1263void atom_parse_data_header(struct atom_context *ctx, int index, 1312bool atom_parse_data_header(struct atom_context *ctx, int index,
1264 uint16_t * size, uint8_t * frev, uint8_t * crev, 1313 uint16_t * size, uint8_t * frev, uint8_t * crev,
1265 uint16_t * data_start) 1314 uint16_t * data_start)
1266{ 1315{
1267 int offset = index * 2 + 4; 1316 int offset = index * 2 + 4;
1268 int idx = CU16(ctx->data_table + offset); 1317 int idx = CU16(ctx->data_table + offset);
1318 u16 *mdt = (u16 *)(ctx->bios + ctx->data_table + 4);
1319
1320 if (!mdt[index])
1321 return false;
1269 1322
1270 if (size) 1323 if (size)
1271 *size = CU16(idx); 1324 *size = CU16(idx);
@@ -1274,38 +1327,42 @@ void atom_parse_data_header(struct atom_context *ctx, int index,
1274 if (crev) 1327 if (crev)
1275 *crev = CU8(idx + 3); 1328 *crev = CU8(idx + 3);
1276 *data_start = idx; 1329 *data_start = idx;
1277 return; 1330 return true;
1278} 1331}
1279 1332
1280void atom_parse_cmd_header(struct atom_context *ctx, int index, uint8_t * frev, 1333bool atom_parse_cmd_header(struct atom_context *ctx, int index, uint8_t * frev,
1281 uint8_t * crev) 1334 uint8_t * crev)
1282{ 1335{
1283 int offset = index * 2 + 4; 1336 int offset = index * 2 + 4;
1284 int idx = CU16(ctx->cmd_table + offset); 1337 int idx = CU16(ctx->cmd_table + offset);
1338 u16 *mct = (u16 *)(ctx->bios + ctx->cmd_table + 4);
1339
1340 if (!mct[index])
1341 return false;
1285 1342
1286 if (frev) 1343 if (frev)
1287 *frev = CU8(idx + 2); 1344 *frev = CU8(idx + 2);
1288 if (crev) 1345 if (crev)
1289 *crev = CU8(idx + 3); 1346 *crev = CU8(idx + 3);
1290 return; 1347 return true;
1291} 1348}
1292 1349
1293int atom_allocate_fb_scratch(struct atom_context *ctx) 1350int atom_allocate_fb_scratch(struct atom_context *ctx)
1294{ 1351{
1295 int index = GetIndexIntoMasterTable(DATA, VRAM_UsageByFirmware); 1352 int index = GetIndexIntoMasterTable(DATA, VRAM_UsageByFirmware);
1296 uint16_t data_offset; 1353 uint16_t data_offset;
1297 int usage_bytes; 1354 int usage_bytes = 0;
1298 struct _ATOM_VRAM_USAGE_BY_FIRMWARE *firmware_usage; 1355 struct _ATOM_VRAM_USAGE_BY_FIRMWARE *firmware_usage;
1299 1356
1300 atom_parse_data_header(ctx, index, NULL, NULL, NULL, &data_offset); 1357 if (atom_parse_data_header(ctx, index, NULL, NULL, NULL, &data_offset)) {
1358 firmware_usage = (struct _ATOM_VRAM_USAGE_BY_FIRMWARE *)(ctx->bios + data_offset);
1301 1359
1302 firmware_usage = (struct _ATOM_VRAM_USAGE_BY_FIRMWARE *)(ctx->bios + data_offset); 1360 DRM_DEBUG("atom firmware requested %08x %dkb\n",
1361 firmware_usage->asFirmwareVramReserveInfo[0].ulStartAddrUsedByFirmware,
1362 firmware_usage->asFirmwareVramReserveInfo[0].usFirmwareUseInKb);
1303 1363
1304 DRM_DEBUG("atom firmware requested %08x %dkb\n", 1364 usage_bytes = firmware_usage->asFirmwareVramReserveInfo[0].usFirmwareUseInKb * 1024;
1305 firmware_usage->asFirmwareVramReserveInfo[0].ulStartAddrUsedByFirmware, 1365 }
1306 firmware_usage->asFirmwareVramReserveInfo[0].usFirmwareUseInKb);
1307
1308 usage_bytes = firmware_usage->asFirmwareVramReserveInfo[0].usFirmwareUseInKb * 1024;
1309 if (usage_bytes == 0) 1366 if (usage_bytes == 0)
1310 usage_bytes = 20 * 1024; 1367 usage_bytes = 20 * 1024;
1311 /* allocate some scratch memory */ 1368 /* allocate some scratch memory */
diff --git a/drivers/gpu/drm/radeon/atom.h b/drivers/gpu/drm/radeon/atom.h
index bc73781423a..cd1b64ab5ca 100644
--- a/drivers/gpu/drm/radeon/atom.h
+++ b/drivers/gpu/drm/radeon/atom.h
@@ -140,11 +140,13 @@ struct atom_context {
140extern int atom_debug; 140extern int atom_debug;
141 141
142struct atom_context *atom_parse(struct card_info *, void *); 142struct atom_context *atom_parse(struct card_info *, void *);
143void atom_execute_table(struct atom_context *, int, uint32_t *); 143int atom_execute_table(struct atom_context *, int, uint32_t *);
144int atom_asic_init(struct atom_context *); 144int atom_asic_init(struct atom_context *);
145void atom_destroy(struct atom_context *); 145void atom_destroy(struct atom_context *);
146void atom_parse_data_header(struct atom_context *ctx, int index, uint16_t *size, uint8_t *frev, uint8_t *crev, uint16_t *data_start); 146bool atom_parse_data_header(struct atom_context *ctx, int index, uint16_t *size,
147void atom_parse_cmd_header(struct atom_context *ctx, int index, uint8_t *frev, uint8_t *crev); 147 uint8_t *frev, uint8_t *crev, uint16_t *data_start);
148bool atom_parse_cmd_header(struct atom_context *ctx, int index,
149 uint8_t *frev, uint8_t *crev);
148int atom_allocate_fb_scratch(struct atom_context *ctx); 150int atom_allocate_fb_scratch(struct atom_context *ctx);
149#include "atom-types.h" 151#include "atom-types.h"
150#include "atombios.h" 152#include "atombios.h"
diff --git a/drivers/gpu/drm/radeon/atombios.h b/drivers/gpu/drm/radeon/atombios.h
index 6732b5dd8ff..27e2c715be1 100644
--- a/drivers/gpu/drm/radeon/atombios.h
+++ b/drivers/gpu/drm/radeon/atombios.h
@@ -2912,7 +2912,7 @@ typedef struct _ATOM_ANALOG_TV_INFO_V1_2
2912 UCHAR ucTV_BootUpDefaultStandard; 2912 UCHAR ucTV_BootUpDefaultStandard;
2913 UCHAR ucExt_TV_ASIC_ID; 2913 UCHAR ucExt_TV_ASIC_ID;
2914 UCHAR ucExt_TV_ASIC_SlaveAddr; 2914 UCHAR ucExt_TV_ASIC_SlaveAddr;
2915 ATOM_DTD_FORMAT aModeTimings[MAX_SUPPORTED_TV_TIMING]; 2915 ATOM_DTD_FORMAT aModeTimings[MAX_SUPPORTED_TV_TIMING_V1_2];
2916}ATOM_ANALOG_TV_INFO_V1_2; 2916}ATOM_ANALOG_TV_INFO_V1_2;
2917 2917
2918typedef struct _ATOM_DPCD_INFO 2918typedef struct _ATOM_DPCD_INFO
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index dd9fdf56061..a87990b3ae8 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -353,12 +353,55 @@ static void atombios_crtc_set_timing(struct drm_crtc *crtc,
353 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); 353 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
354} 354}
355 355
356static void atombios_disable_ss(struct drm_crtc *crtc)
357{
358 struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
359 struct drm_device *dev = crtc->dev;
360 struct radeon_device *rdev = dev->dev_private;
361 u32 ss_cntl;
362
363 if (ASIC_IS_DCE4(rdev)) {
364 switch (radeon_crtc->pll_id) {
365 case ATOM_PPLL1:
366 ss_cntl = RREG32(EVERGREEN_P1PLL_SS_CNTL);
367 ss_cntl &= ~EVERGREEN_PxPLL_SS_EN;
368 WREG32(EVERGREEN_P1PLL_SS_CNTL, ss_cntl);
369 break;
370 case ATOM_PPLL2:
371 ss_cntl = RREG32(EVERGREEN_P2PLL_SS_CNTL);
372 ss_cntl &= ~EVERGREEN_PxPLL_SS_EN;
373 WREG32(EVERGREEN_P2PLL_SS_CNTL, ss_cntl);
374 break;
375 case ATOM_DCPLL:
376 case ATOM_PPLL_INVALID:
377 return;
378 }
379 } else if (ASIC_IS_AVIVO(rdev)) {
380 switch (radeon_crtc->pll_id) {
381 case ATOM_PPLL1:
382 ss_cntl = RREG32(AVIVO_P1PLL_INT_SS_CNTL);
383 ss_cntl &= ~1;
384 WREG32(AVIVO_P1PLL_INT_SS_CNTL, ss_cntl);
385 break;
386 case ATOM_PPLL2:
387 ss_cntl = RREG32(AVIVO_P2PLL_INT_SS_CNTL);
388 ss_cntl &= ~1;
389 WREG32(AVIVO_P2PLL_INT_SS_CNTL, ss_cntl);
390 break;
391 case ATOM_DCPLL:
392 case ATOM_PPLL_INVALID:
393 return;
394 }
395 }
396}
397
398
356union atom_enable_ss { 399union atom_enable_ss {
357 ENABLE_LVDS_SS_PARAMETERS legacy; 400 ENABLE_LVDS_SS_PARAMETERS legacy;
358 ENABLE_SPREAD_SPECTRUM_ON_PPLL_PS_ALLOCATION v1; 401 ENABLE_SPREAD_SPECTRUM_ON_PPLL_PS_ALLOCATION v1;
359}; 402};
360 403
361static void atombios_set_ss(struct drm_crtc *crtc, int enable) 404static void atombios_enable_ss(struct drm_crtc *crtc)
362{ 405{
363 struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); 406 struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
364 struct drm_device *dev = crtc->dev; 407 struct drm_device *dev = crtc->dev;
@@ -387,9 +430,9 @@ static void atombios_set_ss(struct drm_crtc *crtc, int enable)
387 step = dig->ss->step; 430 step = dig->ss->step;
388 delay = dig->ss->delay; 431 delay = dig->ss->delay;
389 range = dig->ss->range; 432 range = dig->ss->range;
390 } else if (enable) 433 } else
391 return; 434 return;
392 } else if (enable) 435 } else
393 return; 436 return;
394 break; 437 break;
395 } 438 }
@@ -406,13 +449,13 @@ static void atombios_set_ss(struct drm_crtc *crtc, int enable)
406 args.v1.ucSpreadSpectrumDelay = delay; 449 args.v1.ucSpreadSpectrumDelay = delay;
407 args.v1.ucSpreadSpectrumRange = range; 450 args.v1.ucSpreadSpectrumRange = range;
408 args.v1.ucPpll = radeon_crtc->crtc_id ? ATOM_PPLL2 : ATOM_PPLL1; 451 args.v1.ucPpll = radeon_crtc->crtc_id ? ATOM_PPLL2 : ATOM_PPLL1;
409 args.v1.ucEnable = enable; 452 args.v1.ucEnable = ATOM_ENABLE;
410 } else { 453 } else {
411 args.legacy.usSpreadSpectrumPercentage = cpu_to_le16(percentage); 454 args.legacy.usSpreadSpectrumPercentage = cpu_to_le16(percentage);
412 args.legacy.ucSpreadSpectrumType = type; 455 args.legacy.ucSpreadSpectrumType = type;
413 args.legacy.ucSpreadSpectrumStepSize_Delay = (step & 3) << 2; 456 args.legacy.ucSpreadSpectrumStepSize_Delay = (step & 3) << 2;
414 args.legacy.ucSpreadSpectrumStepSize_Delay |= (delay & 7) << 4; 457 args.legacy.ucSpreadSpectrumStepSize_Delay |= (delay & 7) << 4;
415 args.legacy.ucEnable = enable; 458 args.legacy.ucEnable = ATOM_ENABLE;
416 } 459 }
417 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); 460 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
418} 461}
@@ -478,10 +521,9 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc,
478 /* DVO wants 2x pixel clock if the DVO chip is in 12 bit mode */ 521 /* DVO wants 2x pixel clock if the DVO chip is in 12 bit mode */
479 if (radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1) 522 if (radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1)
480 adjusted_clock = mode->clock * 2; 523 adjusted_clock = mode->clock * 2;
481 /* LVDS PLL quirks */ 524 if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT)) {
482 if (encoder->encoder_type == DRM_MODE_ENCODER_LVDS) { 525 pll->algo = PLL_ALGO_LEGACY;
483 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; 526 pll->flags |= RADEON_PLL_PREFER_CLOSEST_LOWER;
484 pll->algo = dig->pll_algo;
485 } 527 }
486 } else { 528 } else {
487 if (encoder->encoder_type != DRM_MODE_ENCODER_DAC) 529 if (encoder->encoder_type != DRM_MODE_ENCODER_DAC)
@@ -503,8 +545,9 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc,
503 int index; 545 int index;
504 546
505 index = GetIndexIntoMasterTable(COMMAND, AdjustDisplayPll); 547 index = GetIndexIntoMasterTable(COMMAND, AdjustDisplayPll);
506 atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, 548 if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev,
507 &crev); 549 &crev))
550 return adjusted_clock;
508 551
509 memset(&args, 0, sizeof(args)); 552 memset(&args, 0, sizeof(args));
510 553
@@ -542,11 +585,16 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc,
542 } 585 }
543 } else if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { 586 } else if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
544 /* may want to enable SS on DP/eDP eventually */ 587 /* may want to enable SS on DP/eDP eventually */
545 args.v3.sInput.ucDispPllConfig |= 588 /*args.v3.sInput.ucDispPllConfig |=
546 DISPPLL_CONFIG_SS_ENABLE; 589 DISPPLL_CONFIG_SS_ENABLE;*/
547 if (mode->clock > 165000) 590 if (encoder_mode == ATOM_ENCODER_MODE_DP)
548 args.v3.sInput.ucDispPllConfig |= 591 args.v3.sInput.ucDispPllConfig |=
549 DISPPLL_CONFIG_DUAL_LINK; 592 DISPPLL_CONFIG_COHERENT_MODE;
593 else {
594 if (mode->clock > 165000)
595 args.v3.sInput.ucDispPllConfig |=
596 DISPPLL_CONFIG_DUAL_LINK;
597 }
550 } 598 }
551 atom_execute_table(rdev->mode_info.atom_context, 599 atom_execute_table(rdev->mode_info.atom_context,
552 index, (uint32_t *)&args); 600 index, (uint32_t *)&args);
@@ -592,8 +640,9 @@ static void atombios_crtc_set_dcpll(struct drm_crtc *crtc)
592 memset(&args, 0, sizeof(args)); 640 memset(&args, 0, sizeof(args));
593 641
594 index = GetIndexIntoMasterTable(COMMAND, SetPixelClock); 642 index = GetIndexIntoMasterTable(COMMAND, SetPixelClock);
595 atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, 643 if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev,
596 &crev); 644 &crev))
645 return;
597 646
598 switch (frev) { 647 switch (frev) {
599 case 1: 648 case 1:
@@ -667,8 +716,9 @@ static void atombios_crtc_set_pll(struct drm_crtc *crtc, struct drm_display_mode
667 &ref_div, &post_div); 716 &ref_div, &post_div);
668 717
669 index = GetIndexIntoMasterTable(COMMAND, SetPixelClock); 718 index = GetIndexIntoMasterTable(COMMAND, SetPixelClock);
670 atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, 719 if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev,
671 &crev); 720 &crev))
721 return;
672 722
673 switch (frev) { 723 switch (frev) {
674 case 1: 724 case 1:
@@ -1083,15 +1133,12 @@ int atombios_crtc_mode_set(struct drm_crtc *crtc,
1083 1133
1084 /* TODO color tiling */ 1134 /* TODO color tiling */
1085 1135
1086 /* pick pll */ 1136 atombios_disable_ss(crtc);
1087 radeon_crtc->pll_id = radeon_atom_pick_pll(crtc);
1088
1089 atombios_set_ss(crtc, 0);
1090 /* always set DCPLL */ 1137 /* always set DCPLL */
1091 if (ASIC_IS_DCE4(rdev)) 1138 if (ASIC_IS_DCE4(rdev))
1092 atombios_crtc_set_dcpll(crtc); 1139 atombios_crtc_set_dcpll(crtc);
1093 atombios_crtc_set_pll(crtc, adjusted_mode); 1140 atombios_crtc_set_pll(crtc, adjusted_mode);
1094 atombios_set_ss(crtc, 1); 1141 atombios_enable_ss(crtc);
1095 1142
1096 if (ASIC_IS_DCE4(rdev)) 1143 if (ASIC_IS_DCE4(rdev))
1097 atombios_set_crtc_dtd_timing(crtc, adjusted_mode); 1144 atombios_set_crtc_dtd_timing(crtc, adjusted_mode);
@@ -1120,6 +1167,11 @@ static bool atombios_crtc_mode_fixup(struct drm_crtc *crtc,
1120 1167
1121static void atombios_crtc_prepare(struct drm_crtc *crtc) 1168static void atombios_crtc_prepare(struct drm_crtc *crtc)
1122{ 1169{
1170 struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
1171
1172 /* pick pll */
1173 radeon_crtc->pll_id = radeon_atom_pick_pll(crtc);
1174
1123 atombios_lock_crtc(crtc, ATOM_ENABLE); 1175 atombios_lock_crtc(crtc, ATOM_ENABLE);
1124 atombios_crtc_dpms(crtc, DRM_MODE_DPMS_OFF); 1176 atombios_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
1125} 1177}
diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c
index 8a133bda00a..28b31c64f48 100644
--- a/drivers/gpu/drm/radeon/atombios_dp.c
+++ b/drivers/gpu/drm/radeon/atombios_dp.c
@@ -745,14 +745,14 @@ void dp_link_train(struct drm_encoder *encoder,
745 >> DP_TRAIN_PRE_EMPHASIS_SHIFT); 745 >> DP_TRAIN_PRE_EMPHASIS_SHIFT);
746 746
747 /* disable the training pattern on the sink */ 747 /* disable the training pattern on the sink */
748 dp_set_training(radeon_connector, DP_TRAINING_PATTERN_DISABLE);
749
750 /* disable the training pattern on the source */
748 if (ASIC_IS_DCE4(rdev)) 751 if (ASIC_IS_DCE4(rdev))
749 atombios_dig_encoder_setup(encoder, ATOM_ENCODER_CMD_DP_LINK_TRAINING_COMPLETE); 752 atombios_dig_encoder_setup(encoder, ATOM_ENCODER_CMD_DP_LINK_TRAINING_COMPLETE);
750 else 753 else
751 radeon_dp_encoder_service(rdev, ATOM_DP_ACTION_TRAINING_COMPLETE, 754 radeon_dp_encoder_service(rdev, ATOM_DP_ACTION_TRAINING_COMPLETE,
752 dig_connector->dp_clock, enc_id, 0); 755 dig_connector->dp_clock, enc_id, 0);
753
754 radeon_dp_encoder_service(rdev, ATOM_DP_ACTION_TRAINING_COMPLETE,
755 dig_connector->dp_clock, enc_id, 0);
756} 756}
757 757
758int radeon_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode, 758int radeon_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode,
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index bd2e7aa85c1..e8f447e2050 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -23,8 +23,10 @@
23 */ 23 */
24#include <linux/firmware.h> 24#include <linux/firmware.h>
25#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26#include <linux/slab.h>
26#include "drmP.h" 27#include "drmP.h"
27#include "radeon.h" 28#include "radeon.h"
29#include "radeon_asic.h"
28#include "radeon_drm.h" 30#include "radeon_drm.h"
29#include "rv770d.h" 31#include "rv770d.h"
30#include "atom.h" 32#include "atom.h"
@@ -436,7 +438,6 @@ static void evergreen_gpu_init(struct radeon_device *rdev)
436 438
437int evergreen_mc_init(struct radeon_device *rdev) 439int evergreen_mc_init(struct radeon_device *rdev)
438{ 440{
439 fixed20_12 a;
440 u32 tmp; 441 u32 tmp;
441 int chansize, numchan; 442 int chansize, numchan;
442 443
@@ -481,12 +482,8 @@ int evergreen_mc_init(struct radeon_device *rdev)
481 rdev->mc.real_vram_size = rdev->mc.aper_size; 482 rdev->mc.real_vram_size = rdev->mc.aper_size;
482 } 483 }
483 r600_vram_gtt_location(rdev, &rdev->mc); 484 r600_vram_gtt_location(rdev, &rdev->mc);
484 /* FIXME: we should enforce default clock in case GPU is not in 485 radeon_update_bandwidth_info(rdev);
485 * default setup 486
486 */
487 a.full = rfixed_const(100);
488 rdev->pm.sclk.full = rfixed_const(rdev->clock.default_sclk);
489 rdev->pm.sclk.full = rfixed_div(rdev->pm.sclk, a);
490 return 0; 487 return 0;
491} 488}
492 489
@@ -746,6 +743,7 @@ int evergreen_init(struct radeon_device *rdev)
746 743
747void evergreen_fini(struct radeon_device *rdev) 744void evergreen_fini(struct radeon_device *rdev)
748{ 745{
746 radeon_pm_fini(rdev);
749 evergreen_suspend(rdev); 747 evergreen_suspend(rdev);
750#if 0 748#if 0
751 r600_blit_fini(rdev); 749 r600_blit_fini(rdev);
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index 91eb762eb3f..cf60c0b3ef1 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -26,11 +26,13 @@
26 * Jerome Glisse 26 * Jerome Glisse
27 */ 27 */
28#include <linux/seq_file.h> 28#include <linux/seq_file.h>
29#include <linux/slab.h>
29#include "drmP.h" 30#include "drmP.h"
30#include "drm.h" 31#include "drm.h"
31#include "radeon_drm.h" 32#include "radeon_drm.h"
32#include "radeon_reg.h" 33#include "radeon_reg.h"
33#include "radeon.h" 34#include "radeon.h"
35#include "radeon_asic.h"
34#include "r100d.h" 36#include "r100d.h"
35#include "rs100d.h" 37#include "rs100d.h"
36#include "rv200d.h" 38#include "rv200d.h"
@@ -235,9 +237,9 @@ int r100_pci_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr)
235 237
236void r100_pci_gart_fini(struct radeon_device *rdev) 238void r100_pci_gart_fini(struct radeon_device *rdev)
237{ 239{
240 radeon_gart_fini(rdev);
238 r100_pci_gart_disable(rdev); 241 r100_pci_gart_disable(rdev);
239 radeon_gart_table_ram_free(rdev); 242 radeon_gart_table_ram_free(rdev);
240 radeon_gart_fini(rdev);
241} 243}
242 244
243int r100_irq_set(struct radeon_device *rdev) 245int r100_irq_set(struct radeon_device *rdev)
@@ -312,10 +314,12 @@ int r100_irq_process(struct radeon_device *rdev)
312 /* Vertical blank interrupts */ 314 /* Vertical blank interrupts */
313 if (status & RADEON_CRTC_VBLANK_STAT) { 315 if (status & RADEON_CRTC_VBLANK_STAT) {
314 drm_handle_vblank(rdev->ddev, 0); 316 drm_handle_vblank(rdev->ddev, 0);
317 rdev->pm.vblank_sync = true;
315 wake_up(&rdev->irq.vblank_queue); 318 wake_up(&rdev->irq.vblank_queue);
316 } 319 }
317 if (status & RADEON_CRTC2_VBLANK_STAT) { 320 if (status & RADEON_CRTC2_VBLANK_STAT) {
318 drm_handle_vblank(rdev->ddev, 1); 321 drm_handle_vblank(rdev->ddev, 1);
322 rdev->pm.vblank_sync = true;
319 wake_up(&rdev->irq.vblank_queue); 323 wake_up(&rdev->irq.vblank_queue);
320 } 324 }
321 if (status & RADEON_FP_DETECT_STAT) { 325 if (status & RADEON_FP_DETECT_STAT) {
@@ -741,6 +745,8 @@ int r100_cp_init(struct radeon_device *rdev, unsigned ring_size)
741 udelay(10); 745 udelay(10);
742 rdev->cp.rptr = RREG32(RADEON_CP_RB_RPTR); 746 rdev->cp.rptr = RREG32(RADEON_CP_RB_RPTR);
743 rdev->cp.wptr = RREG32(RADEON_CP_RB_WPTR); 747 rdev->cp.wptr = RREG32(RADEON_CP_RB_WPTR);
748 /* protect against crazy HW on resume */
749 rdev->cp.wptr &= rdev->cp.ptr_mask;
744 /* Set cp mode to bus mastering & enable cp*/ 750 /* Set cp mode to bus mastering & enable cp*/
745 WREG32(RADEON_CP_CSQ_MODE, 751 WREG32(RADEON_CP_CSQ_MODE,
746 REG_SET(RADEON_INDIRECT2_START, indirect2_start) | 752 REG_SET(RADEON_INDIRECT2_START, indirect2_start) |
@@ -1804,6 +1810,7 @@ void r100_set_common_regs(struct radeon_device *rdev)
1804{ 1810{
1805 struct drm_device *dev = rdev->ddev; 1811 struct drm_device *dev = rdev->ddev;
1806 bool force_dac2 = false; 1812 bool force_dac2 = false;
1813 u32 tmp;
1807 1814
1808 /* set these so they don't interfere with anything */ 1815 /* set these so they don't interfere with anything */
1809 WREG32(RADEON_OV0_SCALE_CNTL, 0); 1816 WREG32(RADEON_OV0_SCALE_CNTL, 0);
@@ -1875,6 +1882,12 @@ void r100_set_common_regs(struct radeon_device *rdev)
1875 WREG32(RADEON_DISP_HW_DEBUG, disp_hw_debug); 1882 WREG32(RADEON_DISP_HW_DEBUG, disp_hw_debug);
1876 WREG32(RADEON_DAC_CNTL2, dac2_cntl); 1883 WREG32(RADEON_DAC_CNTL2, dac2_cntl);
1877 } 1884 }
1885
1886 /* switch PM block to ACPI mode */
1887 tmp = RREG32_PLL(RADEON_PLL_PWRMGT_CNTL);
1888 tmp &= ~RADEON_PM_MODE_SEL;
1889 WREG32_PLL(RADEON_PLL_PWRMGT_CNTL, tmp);
1890
1878} 1891}
1879 1892
1880/* 1893/*
@@ -2022,6 +2035,7 @@ void r100_mc_init(struct radeon_device *rdev)
2022 radeon_vram_location(rdev, &rdev->mc, base); 2035 radeon_vram_location(rdev, &rdev->mc, base);
2023 if (!(rdev->flags & RADEON_IS_AGP)) 2036 if (!(rdev->flags & RADEON_IS_AGP))
2024 radeon_gtt_location(rdev, &rdev->mc); 2037 radeon_gtt_location(rdev, &rdev->mc);
2038 radeon_update_bandwidth_info(rdev);
2025} 2039}
2026 2040
2027 2041
@@ -2385,6 +2399,8 @@ void r100_bandwidth_update(struct radeon_device *rdev)
2385 uint32_t pixel_bytes1 = 0; 2399 uint32_t pixel_bytes1 = 0;
2386 uint32_t pixel_bytes2 = 0; 2400 uint32_t pixel_bytes2 = 0;
2387 2401
2402 radeon_update_display_priority(rdev);
2403
2388 if (rdev->mode_info.crtcs[0]->base.enabled) { 2404 if (rdev->mode_info.crtcs[0]->base.enabled) {
2389 mode1 = &rdev->mode_info.crtcs[0]->base.mode; 2405 mode1 = &rdev->mode_info.crtcs[0]->base.mode;
2390 pixel_bytes1 = rdev->mode_info.crtcs[0]->base.fb->bits_per_pixel / 8; 2406 pixel_bytes1 = rdev->mode_info.crtcs[0]->base.fb->bits_per_pixel / 8;
@@ -2413,11 +2429,8 @@ void r100_bandwidth_update(struct radeon_device *rdev)
2413 /* 2429 /*
2414 * determine is there is enough bw for current mode 2430 * determine is there is enough bw for current mode
2415 */ 2431 */
2416 mclk_ff.full = rfixed_const(rdev->clock.default_mclk); 2432 sclk_ff = rdev->pm.sclk;
2417 temp_ff.full = rfixed_const(100); 2433 mclk_ff = rdev->pm.mclk;
2418 mclk_ff.full = rfixed_div(mclk_ff, temp_ff);
2419 sclk_ff.full = rfixed_const(rdev->clock.default_sclk);
2420 sclk_ff.full = rfixed_div(sclk_ff, temp_ff);
2421 2434
2422 temp = (rdev->mc.vram_width / 8) * (rdev->mc.vram_is_ddr ? 2 : 1); 2435 temp = (rdev->mc.vram_width / 8) * (rdev->mc.vram_is_ddr ? 2 : 1);
2423 temp_ff.full = rfixed_const(temp); 2436 temp_ff.full = rfixed_const(temp);
@@ -2878,7 +2891,7 @@ static int r100_cs_track_texture_check(struct radeon_device *rdev,
2878{ 2891{
2879 struct radeon_bo *robj; 2892 struct radeon_bo *robj;
2880 unsigned long size; 2893 unsigned long size;
2881 unsigned u, i, w, h; 2894 unsigned u, i, w, h, d;
2882 int ret; 2895 int ret;
2883 2896
2884 for (u = 0; u < track->num_texture; u++) { 2897 for (u = 0; u < track->num_texture; u++) {
@@ -2910,20 +2923,25 @@ static int r100_cs_track_texture_check(struct radeon_device *rdev,
2910 h = h / (1 << i); 2923 h = h / (1 << i);
2911 if (track->textures[u].roundup_h) 2924 if (track->textures[u].roundup_h)
2912 h = roundup_pow_of_two(h); 2925 h = roundup_pow_of_two(h);
2926 if (track->textures[u].tex_coord_type == 1) {
2927 d = (1 << track->textures[u].txdepth) / (1 << i);
2928 if (!d)
2929 d = 1;
2930 } else {
2931 d = 1;
2932 }
2913 if (track->textures[u].compress_format) { 2933 if (track->textures[u].compress_format) {
2914 2934
2915 size += r100_track_compress_size(track->textures[u].compress_format, w, h); 2935 size += r100_track_compress_size(track->textures[u].compress_format, w, h) * d;
2916 /* compressed textures are block based */ 2936 /* compressed textures are block based */
2917 } else 2937 } else
2918 size += w * h; 2938 size += w * h * d;
2919 } 2939 }
2920 size *= track->textures[u].cpp; 2940 size *= track->textures[u].cpp;
2921 2941
2922 switch (track->textures[u].tex_coord_type) { 2942 switch (track->textures[u].tex_coord_type) {
2923 case 0: 2943 case 0:
2924 break;
2925 case 1: 2944 case 1:
2926 size *= (1 << track->textures[u].txdepth);
2927 break; 2945 break;
2928 case 2: 2946 case 2:
2929 if (track->separate_cube) { 2947 if (track->separate_cube) {
@@ -2957,7 +2975,7 @@ int r100_cs_track_check(struct radeon_device *rdev, struct r100_cs_track *track)
2957 2975
2958 for (i = 0; i < track->num_cb; i++) { 2976 for (i = 0; i < track->num_cb; i++) {
2959 if (track->cb[i].robj == NULL) { 2977 if (track->cb[i].robj == NULL) {
2960 if (!(track->fastfill || track->color_channel_mask || 2978 if (!(track->zb_cb_clear || track->color_channel_mask ||
2961 track->blend_read_enable)) { 2979 track->blend_read_enable)) {
2962 continue; 2980 continue;
2963 } 2981 }
@@ -2994,7 +3012,11 @@ int r100_cs_track_check(struct radeon_device *rdev, struct r100_cs_track *track)
2994 } 3012 }
2995 } 3013 }
2996 prim_walk = (track->vap_vf_cntl >> 4) & 0x3; 3014 prim_walk = (track->vap_vf_cntl >> 4) & 0x3;
2997 nverts = (track->vap_vf_cntl >> 16) & 0xFFFF; 3015 if (track->vap_vf_cntl & (1 << 14)) {
3016 nverts = track->vap_alt_nverts;
3017 } else {
3018 nverts = (track->vap_vf_cntl >> 16) & 0xFFFF;
3019 }
2998 switch (prim_walk) { 3020 switch (prim_walk) {
2999 case 1: 3021 case 1:
3000 for (i = 0; i < track->num_arrays; i++) { 3022 for (i = 0; i < track->num_arrays; i++) {
@@ -3440,6 +3462,7 @@ int r100_suspend(struct radeon_device *rdev)
3440 3462
3441void r100_fini(struct radeon_device *rdev) 3463void r100_fini(struct radeon_device *rdev)
3442{ 3464{
3465 radeon_pm_fini(rdev);
3443 r100_cp_fini(rdev); 3466 r100_cp_fini(rdev);
3444 r100_wb_fini(rdev); 3467 r100_wb_fini(rdev);
3445 r100_ib_fini(rdev); 3468 r100_ib_fini(rdev);
diff --git a/drivers/gpu/drm/radeon/r100_track.h b/drivers/gpu/drm/radeon/r100_track.h
index b27a6999d21..f47cdca1c00 100644
--- a/drivers/gpu/drm/radeon/r100_track.h
+++ b/drivers/gpu/drm/radeon/r100_track.h
@@ -64,6 +64,7 @@ struct r100_cs_track {
64 unsigned maxy; 64 unsigned maxy;
65 unsigned vtx_size; 65 unsigned vtx_size;
66 unsigned vap_vf_cntl; 66 unsigned vap_vf_cntl;
67 unsigned vap_alt_nverts;
67 unsigned immd_dwords; 68 unsigned immd_dwords;
68 unsigned num_arrays; 69 unsigned num_arrays;
69 unsigned max_indx; 70 unsigned max_indx;
@@ -74,7 +75,7 @@ struct r100_cs_track {
74 struct r100_cs_track_texture textures[R300_TRACK_MAX_TEXTURE]; 75 struct r100_cs_track_texture textures[R300_TRACK_MAX_TEXTURE];
75 bool z_enabled; 76 bool z_enabled;
76 bool separate_cube; 77 bool separate_cube;
77 bool fastfill; 78 bool zb_cb_clear;
78 bool blend_read_enable; 79 bool blend_read_enable;
79}; 80};
80 81
diff --git a/drivers/gpu/drm/radeon/r200.c b/drivers/gpu/drm/radeon/r200.c
index 1146c9909c2..85617c31121 100644
--- a/drivers/gpu/drm/radeon/r200.c
+++ b/drivers/gpu/drm/radeon/r200.c
@@ -30,6 +30,7 @@
30#include "radeon_drm.h" 30#include "radeon_drm.h"
31#include "radeon_reg.h" 31#include "radeon_reg.h"
32#include "radeon.h" 32#include "radeon.h"
33#include "radeon_asic.h"
33 34
34#include "r100d.h" 35#include "r100d.h"
35#include "r200_reg_safe.h" 36#include "r200_reg_safe.h"
diff --git a/drivers/gpu/drm/radeon/r300.c b/drivers/gpu/drm/radeon/r300.c
index 4cef90cd74e..a5ff8076b42 100644
--- a/drivers/gpu/drm/radeon/r300.c
+++ b/drivers/gpu/drm/radeon/r300.c
@@ -26,10 +26,12 @@
26 * Jerome Glisse 26 * Jerome Glisse
27 */ 27 */
28#include <linux/seq_file.h> 28#include <linux/seq_file.h>
29#include <linux/slab.h>
29#include "drmP.h" 30#include "drmP.h"
30#include "drm.h" 31#include "drm.h"
31#include "radeon_reg.h" 32#include "radeon_reg.h"
32#include "radeon.h" 33#include "radeon.h"
34#include "radeon_asic.h"
33#include "radeon_drm.h" 35#include "radeon_drm.h"
34#include "r100_track.h" 36#include "r100_track.h"
35#include "r300d.h" 37#include "r300d.h"
@@ -164,9 +166,9 @@ void rv370_pcie_gart_disable(struct radeon_device *rdev)
164 166
165void rv370_pcie_gart_fini(struct radeon_device *rdev) 167void rv370_pcie_gart_fini(struct radeon_device *rdev)
166{ 168{
169 radeon_gart_fini(rdev);
167 rv370_pcie_gart_disable(rdev); 170 rv370_pcie_gart_disable(rdev);
168 radeon_gart_table_vram_free(rdev); 171 radeon_gart_table_vram_free(rdev);
169 radeon_gart_fini(rdev);
170} 172}
171 173
172void r300_fence_ring_emit(struct radeon_device *rdev, 174void r300_fence_ring_emit(struct radeon_device *rdev,
@@ -322,12 +324,12 @@ void r300_gpu_init(struct radeon_device *rdev)
322 uint32_t gb_tile_config, tmp; 324 uint32_t gb_tile_config, tmp;
323 325
324 r100_hdp_reset(rdev); 326 r100_hdp_reset(rdev);
325 /* FIXME: rv380 one pipes ? */ 327 if ((rdev->family == CHIP_R300 && rdev->pdev->device != 0x4144) ||
326 if ((rdev->family == CHIP_R300) || (rdev->family == CHIP_R350)) { 328 (rdev->family == CHIP_R350 && rdev->pdev->device != 0x4148)) {
327 /* r300,r350 */ 329 /* r300,r350 */
328 rdev->num_gb_pipes = 2; 330 rdev->num_gb_pipes = 2;
329 } else { 331 } else {
330 /* rv350,rv370,rv380 */ 332 /* rv350,rv370,rv380,r300 AD, r350 AH */
331 rdev->num_gb_pipes = 1; 333 rdev->num_gb_pipes = 1;
332 } 334 }
333 rdev->num_z_pipes = 1; 335 rdev->num_z_pipes = 1;
@@ -481,6 +483,7 @@ void r300_mc_init(struct radeon_device *rdev)
481 radeon_vram_location(rdev, &rdev->mc, base); 483 radeon_vram_location(rdev, &rdev->mc, base);
482 if (!(rdev->flags & RADEON_IS_AGP)) 484 if (!(rdev->flags & RADEON_IS_AGP))
483 radeon_gtt_location(rdev, &rdev->mc); 485 radeon_gtt_location(rdev, &rdev->mc);
486 radeon_update_bandwidth_info(rdev);
484} 487}
485 488
486void rv370_set_pcie_lanes(struct radeon_device *rdev, int lanes) 489void rv370_set_pcie_lanes(struct radeon_device *rdev, int lanes)
@@ -726,6 +729,12 @@ static int r300_packet0_check(struct radeon_cs_parser *p,
726 /* VAP_VF_MAX_VTX_INDX */ 729 /* VAP_VF_MAX_VTX_INDX */
727 track->max_indx = idx_value & 0x00FFFFFFUL; 730 track->max_indx = idx_value & 0x00FFFFFFUL;
728 break; 731 break;
732 case 0x2088:
733 /* VAP_ALT_NUM_VERTICES - only valid on r500 */
734 if (p->rdev->family < CHIP_RV515)
735 goto fail;
736 track->vap_alt_nverts = idx_value & 0xFFFFFF;
737 break;
729 case 0x43E4: 738 case 0x43E4:
730 /* SC_SCISSOR1 */ 739 /* SC_SCISSOR1 */
731 track->maxy = ((idx_value >> 13) & 0x1FFF) + 1; 740 track->maxy = ((idx_value >> 13) & 0x1FFF) + 1;
@@ -763,7 +772,6 @@ static int r300_packet0_check(struct radeon_cs_parser *p,
763 tmp = idx_value & ~(0x7 << 16); 772 tmp = idx_value & ~(0x7 << 16);
764 tmp |= tile_flags; 773 tmp |= tile_flags;
765 ib[idx] = tmp; 774 ib[idx] = tmp;
766
767 i = (reg - 0x4E38) >> 2; 775 i = (reg - 0x4E38) >> 2;
768 track->cb[i].pitch = idx_value & 0x3FFE; 776 track->cb[i].pitch = idx_value & 0x3FFE;
769 switch (((idx_value >> 21) & 0xF)) { 777 switch (((idx_value >> 21) & 0xF)) {
@@ -1036,7 +1044,7 @@ static int r300_packet0_check(struct radeon_cs_parser *p,
1036 break; 1044 break;
1037 case 0x4d1c: 1045 case 0x4d1c:
1038 /* ZB_BW_CNTL */ 1046 /* ZB_BW_CNTL */
1039 track->fastfill = !!(idx_value & (1 << 2)); 1047 track->zb_cb_clear = !!(idx_value & (1 << 5));
1040 break; 1048 break;
1041 case 0x4e04: 1049 case 0x4e04:
1042 /* RB3D_BLENDCNTL */ 1050 /* RB3D_BLENDCNTL */
@@ -1048,11 +1056,13 @@ static int r300_packet0_check(struct radeon_cs_parser *p,
1048 break; 1056 break;
1049 /* fallthrough do not move */ 1057 /* fallthrough do not move */
1050 default: 1058 default:
1051 printk(KERN_ERR "Forbidden register 0x%04X in cs at %d\n", 1059 goto fail;
1052 reg, idx);
1053 return -EINVAL;
1054 } 1060 }
1055 return 0; 1061 return 0;
1062fail:
1063 printk(KERN_ERR "Forbidden register 0x%04X in cs at %d\n",
1064 reg, idx);
1065 return -EINVAL;
1056} 1066}
1057 1067
1058static int r300_packet3_check(struct radeon_cs_parser *p, 1068static int r300_packet3_check(struct radeon_cs_parser *p,
@@ -1334,6 +1344,7 @@ int r300_suspend(struct radeon_device *rdev)
1334 1344
1335void r300_fini(struct radeon_device *rdev) 1345void r300_fini(struct radeon_device *rdev)
1336{ 1346{
1347 radeon_pm_fini(rdev);
1337 r100_cp_fini(rdev); 1348 r100_cp_fini(rdev);
1338 r100_wb_fini(rdev); 1349 r100_wb_fini(rdev);
1339 r100_ib_fini(rdev); 1350 r100_ib_fini(rdev);
diff --git a/drivers/gpu/drm/radeon/r300_cmdbuf.c b/drivers/gpu/drm/radeon/r300_cmdbuf.c
index ea46d558e8f..c5c2742e414 100644
--- a/drivers/gpu/drm/radeon/r300_cmdbuf.c
+++ b/drivers/gpu/drm/radeon/r300_cmdbuf.c
@@ -921,7 +921,7 @@ static int r300_scratch(drm_radeon_private_t *dev_priv,
921 921
922 ptr_addr = drm_buffer_read_object(cmdbuf->buffer, 922 ptr_addr = drm_buffer_read_object(cmdbuf->buffer,
923 sizeof(stack_ptr_addr), &stack_ptr_addr); 923 sizeof(stack_ptr_addr), &stack_ptr_addr);
924 ref_age_base = (u32 *)(unsigned long)*ptr_addr; 924 ref_age_base = (u32 *)(unsigned long)get_unaligned(ptr_addr);
925 925
926 for (i=0; i < header.scratch.n_bufs; i++) { 926 for (i=0; i < header.scratch.n_bufs; i++) {
927 buf_idx = drm_buffer_pointer_to_dword(cmdbuf->buffer, 0); 927 buf_idx = drm_buffer_pointer_to_dword(cmdbuf->buffer, 0);
diff --git a/drivers/gpu/drm/radeon/r420.c b/drivers/gpu/drm/radeon/r420.c
index c7593b8f58e..c2bda4ad62e 100644
--- a/drivers/gpu/drm/radeon/r420.c
+++ b/drivers/gpu/drm/radeon/r420.c
@@ -26,9 +26,11 @@
26 * Jerome Glisse 26 * Jerome Glisse
27 */ 27 */
28#include <linux/seq_file.h> 28#include <linux/seq_file.h>
29#include <linux/slab.h>
29#include "drmP.h" 30#include "drmP.h"
30#include "radeon_reg.h" 31#include "radeon_reg.h"
31#include "radeon.h" 32#include "radeon.h"
33#include "radeon_asic.h"
32#include "atom.h" 34#include "atom.h"
33#include "r100d.h" 35#include "r100d.h"
34#include "r420d.h" 36#include "r420d.h"
@@ -57,6 +59,12 @@ void r420_pipes_init(struct radeon_device *rdev)
57 /* get max number of pipes */ 59 /* get max number of pipes */
58 gb_pipe_select = RREG32(0x402C); 60 gb_pipe_select = RREG32(0x402C);
59 num_pipes = ((gb_pipe_select >> 12) & 3) + 1; 61 num_pipes = ((gb_pipe_select >> 12) & 3) + 1;
62
63 /* SE chips have 1 pipe */
64 if ((rdev->pdev->device == 0x5e4c) ||
65 (rdev->pdev->device == 0x5e4f))
66 num_pipes = 1;
67
60 rdev->num_gb_pipes = num_pipes; 68 rdev->num_gb_pipes = num_pipes;
61 tmp = 0; 69 tmp = 0;
62 switch (num_pipes) { 70 switch (num_pipes) {
@@ -266,6 +274,7 @@ int r420_suspend(struct radeon_device *rdev)
266 274
267void r420_fini(struct radeon_device *rdev) 275void r420_fini(struct radeon_device *rdev)
268{ 276{
277 radeon_pm_fini(rdev);
269 r100_cp_fini(rdev); 278 r100_cp_fini(rdev);
270 r100_wb_fini(rdev); 279 r100_wb_fini(rdev);
271 r100_ib_fini(rdev); 280 r100_ib_fini(rdev);
diff --git a/drivers/gpu/drm/radeon/r520.c b/drivers/gpu/drm/radeon/r520.c
index 2b8a5dd1351..3c44b8d3931 100644
--- a/drivers/gpu/drm/radeon/r520.c
+++ b/drivers/gpu/drm/radeon/r520.c
@@ -27,6 +27,7 @@
27 */ 27 */
28#include "drmP.h" 28#include "drmP.h"
29#include "radeon.h" 29#include "radeon.h"
30#include "radeon_asic.h"
30#include "atom.h" 31#include "atom.h"
31#include "r520d.h" 32#include "r520d.h"
32 33
@@ -121,19 +122,13 @@ static void r520_vram_get_type(struct radeon_device *rdev)
121 122
122void r520_mc_init(struct radeon_device *rdev) 123void r520_mc_init(struct radeon_device *rdev)
123{ 124{
124 fixed20_12 a;
125 125
126 r520_vram_get_type(rdev); 126 r520_vram_get_type(rdev);
127 r100_vram_init_sizes(rdev); 127 r100_vram_init_sizes(rdev);
128 radeon_vram_location(rdev, &rdev->mc, 0); 128 radeon_vram_location(rdev, &rdev->mc, 0);
129 if (!(rdev->flags & RADEON_IS_AGP)) 129 if (!(rdev->flags & RADEON_IS_AGP))
130 radeon_gtt_location(rdev, &rdev->mc); 130 radeon_gtt_location(rdev, &rdev->mc);
131 /* FIXME: we should enforce default clock in case GPU is not in 131 radeon_update_bandwidth_info(rdev);
132 * default setup
133 */
134 a.full = rfixed_const(100);
135 rdev->pm.sclk.full = rfixed_const(rdev->clock.default_sclk);
136 rdev->pm.sclk.full = rfixed_div(rdev->pm.sclk, a);
137} 132}
138 133
139void r520_mc_program(struct radeon_device *rdev) 134void r520_mc_program(struct radeon_device *rdev)
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index c5229019729..8f3454e2056 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -25,12 +25,14 @@
25 * Alex Deucher 25 * Alex Deucher
26 * Jerome Glisse 26 * Jerome Glisse
27 */ 27 */
28#include <linux/slab.h>
28#include <linux/seq_file.h> 29#include <linux/seq_file.h>
29#include <linux/firmware.h> 30#include <linux/firmware.h>
30#include <linux/platform_device.h> 31#include <linux/platform_device.h>
31#include "drmP.h" 32#include "drmP.h"
32#include "radeon_drm.h" 33#include "radeon_drm.h"
33#include "radeon.h" 34#include "radeon.h"
35#include "radeon_asic.h"
34#include "radeon_mode.h" 36#include "radeon_mode.h"
35#include "r600d.h" 37#include "r600d.h"
36#include "atom.h" 38#include "atom.h"
@@ -491,9 +493,9 @@ void r600_pcie_gart_disable(struct radeon_device *rdev)
491 493
492void r600_pcie_gart_fini(struct radeon_device *rdev) 494void r600_pcie_gart_fini(struct radeon_device *rdev)
493{ 495{
496 radeon_gart_fini(rdev);
494 r600_pcie_gart_disable(rdev); 497 r600_pcie_gart_disable(rdev);
495 radeon_gart_table_vram_free(rdev); 498 radeon_gart_table_vram_free(rdev);
496 radeon_gart_fini(rdev);
497} 499}
498 500
499void r600_agp_enable(struct radeon_device *rdev) 501void r600_agp_enable(struct radeon_device *rdev)
@@ -675,7 +677,6 @@ void r600_vram_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc)
675 677
676int r600_mc_init(struct radeon_device *rdev) 678int r600_mc_init(struct radeon_device *rdev)
677{ 679{
678 fixed20_12 a;
679 u32 tmp; 680 u32 tmp;
680 int chansize, numchan; 681 int chansize, numchan;
681 682
@@ -719,14 +720,10 @@ int r600_mc_init(struct radeon_device *rdev)
719 rdev->mc.real_vram_size = rdev->mc.aper_size; 720 rdev->mc.real_vram_size = rdev->mc.aper_size;
720 } 721 }
721 r600_vram_gtt_location(rdev, &rdev->mc); 722 r600_vram_gtt_location(rdev, &rdev->mc);
722 /* FIXME: we should enforce default clock in case GPU is not in 723
723 * default setup
724 */
725 a.full = rfixed_const(100);
726 rdev->pm.sclk.full = rfixed_const(rdev->clock.default_sclk);
727 rdev->pm.sclk.full = rfixed_div(rdev->pm.sclk, a);
728 if (rdev->flags & RADEON_IS_IGP) 724 if (rdev->flags & RADEON_IS_IGP)
729 rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev); 725 rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev);
726 radeon_update_bandwidth_info(rdev);
730 return 0; 727 return 0;
731} 728}
732 729
@@ -1132,6 +1129,7 @@ void r600_gpu_init(struct radeon_device *rdev)
1132 /* Setup pipes */ 1129 /* Setup pipes */
1133 WREG32(CC_RB_BACKEND_DISABLE, cc_rb_backend_disable); 1130 WREG32(CC_RB_BACKEND_DISABLE, cc_rb_backend_disable);
1134 WREG32(CC_GC_SHADER_PIPE_CONFIG, cc_gc_shader_pipe_config); 1131 WREG32(CC_GC_SHADER_PIPE_CONFIG, cc_gc_shader_pipe_config);
1132 WREG32(GC_USER_SHADER_PIPE_CONFIG, cc_gc_shader_pipe_config);
1135 1133
1136 tmp = R6XX_MAX_PIPES - r600_count_pipe_bits((cc_gc_shader_pipe_config & INACTIVE_QD_PIPES_MASK) >> 8); 1134 tmp = R6XX_MAX_PIPES - r600_count_pipe_bits((cc_gc_shader_pipe_config & INACTIVE_QD_PIPES_MASK) >> 8);
1137 WREG32(VGT_OUT_DEALLOC_CNTL, (tmp * 4) & DEALLOC_DIST_MASK); 1135 WREG32(VGT_OUT_DEALLOC_CNTL, (tmp * 4) & DEALLOC_DIST_MASK);
@@ -2119,6 +2117,7 @@ int r600_init(struct radeon_device *rdev)
2119 2117
2120void r600_fini(struct radeon_device *rdev) 2118void r600_fini(struct radeon_device *rdev)
2121{ 2119{
2120 radeon_pm_fini(rdev);
2122 r600_audio_fini(rdev); 2121 r600_audio_fini(rdev);
2123 r600_blit_fini(rdev); 2122 r600_blit_fini(rdev);
2124 r600_cp_fini(rdev); 2123 r600_cp_fini(rdev);
@@ -2398,19 +2397,19 @@ static void r600_disable_interrupt_state(struct radeon_device *rdev)
2398 WREG32(DC_HPD4_INT_CONTROL, tmp); 2397 WREG32(DC_HPD4_INT_CONTROL, tmp);
2399 if (ASIC_IS_DCE32(rdev)) { 2398 if (ASIC_IS_DCE32(rdev)) {
2400 tmp = RREG32(DC_HPD5_INT_CONTROL) & DC_HPDx_INT_POLARITY; 2399 tmp = RREG32(DC_HPD5_INT_CONTROL) & DC_HPDx_INT_POLARITY;
2401 WREG32(DC_HPD5_INT_CONTROL, 0); 2400 WREG32(DC_HPD5_INT_CONTROL, tmp);
2402 tmp = RREG32(DC_HPD6_INT_CONTROL) & DC_HPDx_INT_POLARITY; 2401 tmp = RREG32(DC_HPD6_INT_CONTROL) & DC_HPDx_INT_POLARITY;
2403 WREG32(DC_HPD6_INT_CONTROL, 0); 2402 WREG32(DC_HPD6_INT_CONTROL, tmp);
2404 } 2403 }
2405 } else { 2404 } else {
2406 WREG32(DACA_AUTODETECT_INT_CONTROL, 0); 2405 WREG32(DACA_AUTODETECT_INT_CONTROL, 0);
2407 WREG32(DACB_AUTODETECT_INT_CONTROL, 0); 2406 WREG32(DACB_AUTODETECT_INT_CONTROL, 0);
2408 tmp = RREG32(DC_HOT_PLUG_DETECT1_INT_CONTROL) & DC_HOT_PLUG_DETECTx_INT_POLARITY; 2407 tmp = RREG32(DC_HOT_PLUG_DETECT1_INT_CONTROL) & DC_HOT_PLUG_DETECTx_INT_POLARITY;
2409 WREG32(DC_HOT_PLUG_DETECT1_INT_CONTROL, 0); 2408 WREG32(DC_HOT_PLUG_DETECT1_INT_CONTROL, tmp);
2410 tmp = RREG32(DC_HOT_PLUG_DETECT2_INT_CONTROL) & DC_HOT_PLUG_DETECTx_INT_POLARITY; 2409 tmp = RREG32(DC_HOT_PLUG_DETECT2_INT_CONTROL) & DC_HOT_PLUG_DETECTx_INT_POLARITY;
2411 WREG32(DC_HOT_PLUG_DETECT2_INT_CONTROL, 0); 2410 WREG32(DC_HOT_PLUG_DETECT2_INT_CONTROL, tmp);
2412 tmp = RREG32(DC_HOT_PLUG_DETECT3_INT_CONTROL) & DC_HOT_PLUG_DETECTx_INT_POLARITY; 2411 tmp = RREG32(DC_HOT_PLUG_DETECT3_INT_CONTROL) & DC_HOT_PLUG_DETECTx_INT_POLARITY;
2413 WREG32(DC_HOT_PLUG_DETECT3_INT_CONTROL, 0); 2412 WREG32(DC_HOT_PLUG_DETECT3_INT_CONTROL, tmp);
2414 } 2413 }
2415} 2414}
2416 2415
@@ -2765,6 +2764,7 @@ restart_ih:
2765 case 0: /* D1 vblank */ 2764 case 0: /* D1 vblank */
2766 if (disp_int & LB_D1_VBLANK_INTERRUPT) { 2765 if (disp_int & LB_D1_VBLANK_INTERRUPT) {
2767 drm_handle_vblank(rdev->ddev, 0); 2766 drm_handle_vblank(rdev->ddev, 0);
2767 rdev->pm.vblank_sync = true;
2768 wake_up(&rdev->irq.vblank_queue); 2768 wake_up(&rdev->irq.vblank_queue);
2769 disp_int &= ~LB_D1_VBLANK_INTERRUPT; 2769 disp_int &= ~LB_D1_VBLANK_INTERRUPT;
2770 DRM_DEBUG("IH: D1 vblank\n"); 2770 DRM_DEBUG("IH: D1 vblank\n");
@@ -2786,6 +2786,7 @@ restart_ih:
2786 case 0: /* D2 vblank */ 2786 case 0: /* D2 vblank */
2787 if (disp_int & LB_D2_VBLANK_INTERRUPT) { 2787 if (disp_int & LB_D2_VBLANK_INTERRUPT) {
2788 drm_handle_vblank(rdev->ddev, 1); 2788 drm_handle_vblank(rdev->ddev, 1);
2789 rdev->pm.vblank_sync = true;
2789 wake_up(&rdev->irq.vblank_queue); 2790 wake_up(&rdev->irq.vblank_queue);
2790 disp_int &= ~LB_D2_VBLANK_INTERRUPT; 2791 disp_int &= ~LB_D2_VBLANK_INTERRUPT;
2791 DRM_DEBUG("IH: D2 vblank\n"); 2792 DRM_DEBUG("IH: D2 vblank\n");
@@ -2834,14 +2835,14 @@ restart_ih:
2834 break; 2835 break;
2835 case 10: 2836 case 10:
2836 if (disp_int_cont2 & DC_HPD5_INTERRUPT) { 2837 if (disp_int_cont2 & DC_HPD5_INTERRUPT) {
2837 disp_int_cont &= ~DC_HPD5_INTERRUPT; 2838 disp_int_cont2 &= ~DC_HPD5_INTERRUPT;
2838 queue_hotplug = true; 2839 queue_hotplug = true;
2839 DRM_DEBUG("IH: HPD5\n"); 2840 DRM_DEBUG("IH: HPD5\n");
2840 } 2841 }
2841 break; 2842 break;
2842 case 12: 2843 case 12:
2843 if (disp_int_cont2 & DC_HPD6_INTERRUPT) { 2844 if (disp_int_cont2 & DC_HPD6_INTERRUPT) {
2844 disp_int_cont &= ~DC_HPD6_INTERRUPT; 2845 disp_int_cont2 &= ~DC_HPD6_INTERRUPT;
2845 queue_hotplug = true; 2846 queue_hotplug = true;
2846 DRM_DEBUG("IH: HPD6\n"); 2847 DRM_DEBUG("IH: HPD6\n");
2847 } 2848 }
diff --git a/drivers/gpu/drm/radeon/r600_audio.c b/drivers/gpu/drm/radeon/r600_audio.c
index db928016d03..1d898051c63 100644
--- a/drivers/gpu/drm/radeon/r600_audio.c
+++ b/drivers/gpu/drm/radeon/r600_audio.c
@@ -35,7 +35,7 @@
35 */ 35 */
36static int r600_audio_chipset_supported(struct radeon_device *rdev) 36static int r600_audio_chipset_supported(struct radeon_device *rdev)
37{ 37{
38 return rdev->family >= CHIP_R600 38 return (rdev->family >= CHIP_R600 && rdev->family < CHIP_CEDAR)
39 || rdev->family == CHIP_RS600 39 || rdev->family == CHIP_RS600
40 || rdev->family == CHIP_RS690 40 || rdev->family == CHIP_RS690
41 || rdev->family == CHIP_RS740; 41 || rdev->family == CHIP_RS740;
@@ -182,41 +182,6 @@ int r600_audio_init(struct radeon_device *rdev)
182} 182}
183 183
184/* 184/*
185 * determin how the encoders and audio interface is wired together
186 */
187int r600_audio_tmds_index(struct drm_encoder *encoder)
188{
189 struct drm_device *dev = encoder->dev;
190 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
191 struct drm_encoder *other;
192
193 switch (radeon_encoder->encoder_id) {
194 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1:
195 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
196 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
197 return 0;
198
199 case ENCODER_OBJECT_ID_INTERNAL_LVTM1:
200 /* special case check if an TMDS1 is present */
201 list_for_each_entry(other, &dev->mode_config.encoder_list, head) {
202 if (to_radeon_encoder(other)->encoder_id ==
203 ENCODER_OBJECT_ID_INTERNAL_TMDS1)
204 return 1;
205 }
206 return 0;
207
208 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
209 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA:
210 return 1;
211
212 default:
213 DRM_ERROR("Unsupported encoder type 0x%02X\n",
214 radeon_encoder->encoder_id);
215 return -1;
216 }
217}
218
219/*
220 * atach the audio codec to the clock source of the encoder 185 * atach the audio codec to the clock source of the encoder
221 */ 186 */
222void r600_audio_set_clock(struct drm_encoder *encoder, int clock) 187void r600_audio_set_clock(struct drm_encoder *encoder, int clock)
@@ -224,6 +189,7 @@ void r600_audio_set_clock(struct drm_encoder *encoder, int clock)
224 struct drm_device *dev = encoder->dev; 189 struct drm_device *dev = encoder->dev;
225 struct radeon_device *rdev = dev->dev_private; 190 struct radeon_device *rdev = dev->dev_private;
226 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 191 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
192 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
227 int base_rate = 48000; 193 int base_rate = 48000;
228 194
229 switch (radeon_encoder->encoder_id) { 195 switch (radeon_encoder->encoder_id) {
@@ -231,32 +197,34 @@ void r600_audio_set_clock(struct drm_encoder *encoder, int clock)
231 case ENCODER_OBJECT_ID_INTERNAL_LVTM1: 197 case ENCODER_OBJECT_ID_INTERNAL_LVTM1:
232 WREG32_P(R600_AUDIO_TIMING, 0, ~0x301); 198 WREG32_P(R600_AUDIO_TIMING, 0, ~0x301);
233 break; 199 break;
234
235 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY: 200 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
236 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1: 201 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
237 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2: 202 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
238 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA: 203 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA:
239 WREG32_P(R600_AUDIO_TIMING, 0x100, ~0x301); 204 WREG32_P(R600_AUDIO_TIMING, 0x100, ~0x301);
240 break; 205 break;
241
242 default: 206 default:
243 DRM_ERROR("Unsupported encoder type 0x%02X\n", 207 DRM_ERROR("Unsupported encoder type 0x%02X\n",
244 radeon_encoder->encoder_id); 208 radeon_encoder->encoder_id);
245 return; 209 return;
246 } 210 }
247 211
248 switch (r600_audio_tmds_index(encoder)) { 212 switch (dig->dig_encoder) {
249 case 0: 213 case 0:
250 WREG32(R600_AUDIO_PLL1_MUL, base_rate*50); 214 WREG32(R600_AUDIO_PLL1_MUL, base_rate * 50);
251 WREG32(R600_AUDIO_PLL1_DIV, clock*100); 215 WREG32(R600_AUDIO_PLL1_DIV, clock * 100);
252 WREG32(R600_AUDIO_CLK_SRCSEL, 0); 216 WREG32(R600_AUDIO_CLK_SRCSEL, 0);
253 break; 217 break;
254 218
255 case 1: 219 case 1:
256 WREG32(R600_AUDIO_PLL2_MUL, base_rate*50); 220 WREG32(R600_AUDIO_PLL2_MUL, base_rate * 50);
257 WREG32(R600_AUDIO_PLL2_DIV, clock*100); 221 WREG32(R600_AUDIO_PLL2_DIV, clock * 100);
258 WREG32(R600_AUDIO_CLK_SRCSEL, 1); 222 WREG32(R600_AUDIO_CLK_SRCSEL, 1);
259 break; 223 break;
224 default:
225 dev_err(rdev->dev, "Unsupported DIG on encoder 0x%02X\n",
226 radeon_encoder->encoder_id);
227 return;
260 } 228 }
261} 229}
262 230
diff --git a/drivers/gpu/drm/radeon/r600_blit_shaders.c b/drivers/gpu/drm/radeon/r600_blit_shaders.c
index a112c59f9d8..0271b53fa2d 100644
--- a/drivers/gpu/drm/radeon/r600_blit_shaders.c
+++ b/drivers/gpu/drm/radeon/r600_blit_shaders.c
@@ -1,7 +1,42 @@
1/*
2 * Copyright 2009 Advanced Micro Devices, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE COPYRIGHT HOLDER(S) AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 *
23 * Authors:
24 * Alex Deucher <alexander.deucher@amd.com>
25 */
1 26
2#include <linux/types.h> 27#include <linux/types.h>
3#include <linux/kernel.h> 28#include <linux/kernel.h>
4 29
30/*
31 * R6xx+ cards need to use the 3D engine to blit data which requires
32 * quite a bit of hw state setup. Rather than pull the whole 3D driver
33 * (which normally generates the 3D state) into the DRM, we opt to use
34 * statically generated state tables. The regsiter state and shaders
35 * were hand generated to support blitting functionality. See the 3D
36 * driver or documentation for descriptions of the registers and
37 * shader instructions.
38 */
39
5const u32 r6xx_default_state[] = 40const u32 r6xx_default_state[] =
6{ 41{
7 0xc0002400, 42 0xc0002400,
diff --git a/drivers/gpu/drm/radeon/r600_cp.c b/drivers/gpu/drm/radeon/r600_cp.c
index 40416c068d9..68e6f434930 100644
--- a/drivers/gpu/drm/radeon/r600_cp.c
+++ b/drivers/gpu/drm/radeon/r600_cp.c
@@ -1548,10 +1548,13 @@ static void r700_gfx_init(struct drm_device *dev,
1548 1548
1549 RADEON_WRITE(R600_CC_RB_BACKEND_DISABLE, cc_rb_backend_disable); 1549 RADEON_WRITE(R600_CC_RB_BACKEND_DISABLE, cc_rb_backend_disable);
1550 RADEON_WRITE(R600_CC_GC_SHADER_PIPE_CONFIG, cc_gc_shader_pipe_config); 1550 RADEON_WRITE(R600_CC_GC_SHADER_PIPE_CONFIG, cc_gc_shader_pipe_config);
1551 RADEON_WRITE(R600_GC_USER_SHADER_PIPE_CONFIG, cc_gc_shader_pipe_config);
1551 1552
1552 RADEON_WRITE(R700_CC_SYS_RB_BACKEND_DISABLE, cc_rb_backend_disable); 1553 RADEON_WRITE(R700_CC_SYS_RB_BACKEND_DISABLE, cc_rb_backend_disable);
1553 RADEON_WRITE(R700_CGTS_SYS_TCC_DISABLE, 0); 1554 RADEON_WRITE(R700_CGTS_SYS_TCC_DISABLE, 0);
1554 RADEON_WRITE(R700_CGTS_TCC_DISABLE, 0); 1555 RADEON_WRITE(R700_CGTS_TCC_DISABLE, 0);
1556 RADEON_WRITE(R700_CGTS_USER_SYS_TCC_DISABLE, 0);
1557 RADEON_WRITE(R700_CGTS_USER_TCC_DISABLE, 0);
1555 1558
1556 num_qd_pipes = 1559 num_qd_pipes =
1557 R7XX_MAX_PIPES - r600_count_pipe_bits((cc_gc_shader_pipe_config & R600_INACTIVE_QD_PIPES_MASK) >> 8); 1560 R7XX_MAX_PIPES - r600_count_pipe_bits((cc_gc_shader_pipe_config & R600_INACTIVE_QD_PIPES_MASK) >> 8);
diff --git a/drivers/gpu/drm/radeon/r600_cs.c b/drivers/gpu/drm/radeon/r600_cs.c
index cd2c63bce50..c39c1bc1301 100644
--- a/drivers/gpu/drm/radeon/r600_cs.c
+++ b/drivers/gpu/drm/radeon/r600_cs.c
@@ -45,6 +45,7 @@ struct r600_cs_track {
45 u32 nbanks; 45 u32 nbanks;
46 u32 npipes; 46 u32 npipes;
47 /* value we track */ 47 /* value we track */
48 u32 sq_config;
48 u32 nsamples; 49 u32 nsamples;
49 u32 cb_color_base_last[8]; 50 u32 cb_color_base_last[8];
50 struct radeon_bo *cb_color_bo[8]; 51 struct radeon_bo *cb_color_bo[8];
@@ -141,6 +142,8 @@ static void r600_cs_track_init(struct r600_cs_track *track)
141{ 142{
142 int i; 143 int i;
143 144
145 /* assume DX9 mode */
146 track->sq_config = DX9_CONSTS;
144 for (i = 0; i < 8; i++) { 147 for (i = 0; i < 8; i++) {
145 track->cb_color_base_last[i] = 0; 148 track->cb_color_base_last[i] = 0;
146 track->cb_color_size[i] = 0; 149 track->cb_color_size[i] = 0;
@@ -715,6 +718,9 @@ static inline int r600_cs_check_reg(struct radeon_cs_parser *p, u32 reg, u32 idx
715 tmp =radeon_get_ib_value(p, idx); 718 tmp =radeon_get_ib_value(p, idx);
716 ib[idx] = 0; 719 ib[idx] = 0;
717 break; 720 break;
721 case SQ_CONFIG:
722 track->sq_config = radeon_get_ib_value(p, idx);
723 break;
718 case R_028800_DB_DEPTH_CONTROL: 724 case R_028800_DB_DEPTH_CONTROL:
719 track->db_depth_control = radeon_get_ib_value(p, idx); 725 track->db_depth_control = radeon_get_ib_value(p, idx);
720 break; 726 break;
@@ -869,6 +875,54 @@ static inline int r600_cs_check_reg(struct radeon_cs_parser *p, u32 reg, u32 idx
869 case SQ_PGM_START_VS: 875 case SQ_PGM_START_VS:
870 case SQ_PGM_START_GS: 876 case SQ_PGM_START_GS:
871 case SQ_PGM_START_PS: 877 case SQ_PGM_START_PS:
878 case SQ_ALU_CONST_CACHE_GS_0:
879 case SQ_ALU_CONST_CACHE_GS_1:
880 case SQ_ALU_CONST_CACHE_GS_2:
881 case SQ_ALU_CONST_CACHE_GS_3:
882 case SQ_ALU_CONST_CACHE_GS_4:
883 case SQ_ALU_CONST_CACHE_GS_5:
884 case SQ_ALU_CONST_CACHE_GS_6:
885 case SQ_ALU_CONST_CACHE_GS_7:
886 case SQ_ALU_CONST_CACHE_GS_8:
887 case SQ_ALU_CONST_CACHE_GS_9:
888 case SQ_ALU_CONST_CACHE_GS_10:
889 case SQ_ALU_CONST_CACHE_GS_11:
890 case SQ_ALU_CONST_CACHE_GS_12:
891 case SQ_ALU_CONST_CACHE_GS_13:
892 case SQ_ALU_CONST_CACHE_GS_14:
893 case SQ_ALU_CONST_CACHE_GS_15:
894 case SQ_ALU_CONST_CACHE_PS_0:
895 case SQ_ALU_CONST_CACHE_PS_1:
896 case SQ_ALU_CONST_CACHE_PS_2:
897 case SQ_ALU_CONST_CACHE_PS_3:
898 case SQ_ALU_CONST_CACHE_PS_4:
899 case SQ_ALU_CONST_CACHE_PS_5:
900 case SQ_ALU_CONST_CACHE_PS_6:
901 case SQ_ALU_CONST_CACHE_PS_7:
902 case SQ_ALU_CONST_CACHE_PS_8:
903 case SQ_ALU_CONST_CACHE_PS_9:
904 case SQ_ALU_CONST_CACHE_PS_10:
905 case SQ_ALU_CONST_CACHE_PS_11:
906 case SQ_ALU_CONST_CACHE_PS_12:
907 case SQ_ALU_CONST_CACHE_PS_13:
908 case SQ_ALU_CONST_CACHE_PS_14:
909 case SQ_ALU_CONST_CACHE_PS_15:
910 case SQ_ALU_CONST_CACHE_VS_0:
911 case SQ_ALU_CONST_CACHE_VS_1:
912 case SQ_ALU_CONST_CACHE_VS_2:
913 case SQ_ALU_CONST_CACHE_VS_3:
914 case SQ_ALU_CONST_CACHE_VS_4:
915 case SQ_ALU_CONST_CACHE_VS_5:
916 case SQ_ALU_CONST_CACHE_VS_6:
917 case SQ_ALU_CONST_CACHE_VS_7:
918 case SQ_ALU_CONST_CACHE_VS_8:
919 case SQ_ALU_CONST_CACHE_VS_9:
920 case SQ_ALU_CONST_CACHE_VS_10:
921 case SQ_ALU_CONST_CACHE_VS_11:
922 case SQ_ALU_CONST_CACHE_VS_12:
923 case SQ_ALU_CONST_CACHE_VS_13:
924 case SQ_ALU_CONST_CACHE_VS_14:
925 case SQ_ALU_CONST_CACHE_VS_15:
872 r = r600_cs_packet_next_reloc(p, &reloc); 926 r = r600_cs_packet_next_reloc(p, &reloc);
873 if (r) { 927 if (r) {
874 dev_warn(p->dev, "bad SET_CONTEXT_REG " 928 dev_warn(p->dev, "bad SET_CONTEXT_REG "
@@ -1226,13 +1280,15 @@ static int r600_packet3_check(struct radeon_cs_parser *p,
1226 } 1280 }
1227 break; 1281 break;
1228 case PACKET3_SET_ALU_CONST: 1282 case PACKET3_SET_ALU_CONST:
1229 start_reg = (idx_value << 2) + PACKET3_SET_ALU_CONST_OFFSET; 1283 if (track->sq_config & DX9_CONSTS) {
1230 end_reg = 4 * pkt->count + start_reg - 4; 1284 start_reg = (idx_value << 2) + PACKET3_SET_ALU_CONST_OFFSET;
1231 if ((start_reg < PACKET3_SET_ALU_CONST_OFFSET) || 1285 end_reg = 4 * pkt->count + start_reg - 4;
1232 (start_reg >= PACKET3_SET_ALU_CONST_END) || 1286 if ((start_reg < PACKET3_SET_ALU_CONST_OFFSET) ||
1233 (end_reg >= PACKET3_SET_ALU_CONST_END)) { 1287 (start_reg >= PACKET3_SET_ALU_CONST_END) ||
1234 DRM_ERROR("bad SET_ALU_CONST\n"); 1288 (end_reg >= PACKET3_SET_ALU_CONST_END)) {
1235 return -EINVAL; 1289 DRM_ERROR("bad SET_ALU_CONST\n");
1290 return -EINVAL;
1291 }
1236 } 1292 }
1237 break; 1293 break;
1238 case PACKET3_SET_BOOL_CONST: 1294 case PACKET3_SET_BOOL_CONST:
diff --git a/drivers/gpu/drm/radeon/r600_hdmi.c b/drivers/gpu/drm/radeon/r600_hdmi.c
index fcc949df0e5..2616b822ba6 100644
--- a/drivers/gpu/drm/radeon/r600_hdmi.c
+++ b/drivers/gpu/drm/radeon/r600_hdmi.c
@@ -42,13 +42,13 @@ enum r600_hdmi_color_format {
42 */ 42 */
43enum r600_hdmi_iec_status_bits { 43enum r600_hdmi_iec_status_bits {
44 AUDIO_STATUS_DIG_ENABLE = 0x01, 44 AUDIO_STATUS_DIG_ENABLE = 0x01,
45 AUDIO_STATUS_V = 0x02, 45 AUDIO_STATUS_V = 0x02,
46 AUDIO_STATUS_VCFG = 0x04, 46 AUDIO_STATUS_VCFG = 0x04,
47 AUDIO_STATUS_EMPHASIS = 0x08, 47 AUDIO_STATUS_EMPHASIS = 0x08,
48 AUDIO_STATUS_COPYRIGHT = 0x10, 48 AUDIO_STATUS_COPYRIGHT = 0x10,
49 AUDIO_STATUS_NONAUDIO = 0x20, 49 AUDIO_STATUS_NONAUDIO = 0x20,
50 AUDIO_STATUS_PROFESSIONAL = 0x40, 50 AUDIO_STATUS_PROFESSIONAL = 0x40,
51 AUDIO_STATUS_LEVEL = 0x80 51 AUDIO_STATUS_LEVEL = 0x80
52}; 52};
53 53
54struct { 54struct {
@@ -85,7 +85,7 @@ struct {
85static void r600_hdmi_calc_CTS(uint32_t clock, int *CTS, int N, int freq) 85static void r600_hdmi_calc_CTS(uint32_t clock, int *CTS, int N, int freq)
86{ 86{
87 if (*CTS == 0) 87 if (*CTS == 0)
88 *CTS = clock*N/(128*freq)*1000; 88 *CTS = clock * N / (128 * freq) * 1000;
89 DRM_DEBUG("Using ACR timing N=%d CTS=%d for frequency %d\n", 89 DRM_DEBUG("Using ACR timing N=%d CTS=%d for frequency %d\n",
90 N, *CTS, freq); 90 N, *CTS, freq);
91} 91}
@@ -131,11 +131,11 @@ static void r600_hdmi_infoframe_checksum(uint8_t packetType,
131 uint8_t length, 131 uint8_t length,
132 uint8_t *frame) 132 uint8_t *frame)
133{ 133{
134 int i; 134 int i;
135 frame[0] = packetType + versionNumber + length; 135 frame[0] = packetType + versionNumber + length;
136 for (i = 1; i <= length; i++) 136 for (i = 1; i <= length; i++)
137 frame[0] += frame[i]; 137 frame[0] += frame[i];
138 frame[0] = 0x100 - frame[0]; 138 frame[0] = 0x100 - frame[0];
139} 139}
140 140
141/* 141/*
@@ -314,6 +314,9 @@ void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mod
314 struct radeon_device *rdev = dev->dev_private; 314 struct radeon_device *rdev = dev->dev_private;
315 uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset; 315 uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset;
316 316
317 if (ASIC_IS_DCE4(rdev))
318 return;
319
317 if (!offset) 320 if (!offset)
318 return; 321 return;
319 322
@@ -417,90 +420,147 @@ void r600_hdmi_update_audio_settings(struct drm_encoder *encoder,
417 WREG32_P(offset+R600_HDMI_CNTL, 0x04000000, ~0x04000000); 420 WREG32_P(offset+R600_HDMI_CNTL, 0x04000000, ~0x04000000);
418} 421}
419 422
420/* 423static int r600_hdmi_find_free_block(struct drm_device *dev)
421 * enable/disable the HDMI engine 424{
422 */ 425 struct radeon_device *rdev = dev->dev_private;
423void r600_hdmi_enable(struct drm_encoder *encoder, int enable) 426 struct drm_encoder *encoder;
427 struct radeon_encoder *radeon_encoder;
428 bool free_blocks[3] = { true, true, true };
429
430 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
431 radeon_encoder = to_radeon_encoder(encoder);
432 switch (radeon_encoder->hdmi_offset) {
433 case R600_HDMI_BLOCK1:
434 free_blocks[0] = false;
435 break;
436 case R600_HDMI_BLOCK2:
437 free_blocks[1] = false;
438 break;
439 case R600_HDMI_BLOCK3:
440 free_blocks[2] = false;
441 break;
442 }
443 }
444
445 if (rdev->family == CHIP_RS600 || rdev->family == CHIP_RS690) {
446 return free_blocks[0] ? R600_HDMI_BLOCK1 : 0;
447 } else if (rdev->family >= CHIP_R600) {
448 if (free_blocks[0])
449 return R600_HDMI_BLOCK1;
450 else if (free_blocks[1])
451 return R600_HDMI_BLOCK2;
452 }
453 return 0;
454}
455
456static void r600_hdmi_assign_block(struct drm_encoder *encoder)
424{ 457{
425 struct drm_device *dev = encoder->dev; 458 struct drm_device *dev = encoder->dev;
426 struct radeon_device *rdev = dev->dev_private; 459 struct radeon_device *rdev = dev->dev_private;
427 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 460 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
428 uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset; 461 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
429 462
430 if (!offset) 463 if (!dig) {
464 dev_err(rdev->dev, "Enabling HDMI on non-dig encoder\n");
431 return; 465 return;
466 }
432 467
433 DRM_DEBUG("%s HDMI interface @ 0x%04X\n", enable ? "Enabling" : "Disabling", offset); 468 if (ASIC_IS_DCE4(rdev)) {
434 469 /* TODO */
435 /* some version of atombios ignore the enable HDMI flag 470 } else if (ASIC_IS_DCE3(rdev)) {
436 * so enabling/disabling HDMI was moved here for TMDS1+2 */ 471 radeon_encoder->hdmi_offset = dig->dig_encoder ?
437 switch (radeon_encoder->encoder_id) { 472 R600_HDMI_BLOCK3 : R600_HDMI_BLOCK1;
438 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1: 473 if (ASIC_IS_DCE32(rdev))
439 WREG32_P(AVIVO_TMDSA_CNTL, enable ? 0x4 : 0x0, ~0x4); 474 radeon_encoder->hdmi_config_offset = dig->dig_encoder ?
440 WREG32(offset+R600_HDMI_ENABLE, enable ? 0x101 : 0x0); 475 R600_HDMI_CONFIG2 : R600_HDMI_CONFIG1;
441 break; 476 } else if (rdev->family >= CHIP_R600) {
442 477 radeon_encoder->hdmi_offset = r600_hdmi_find_free_block(dev);
443 case ENCODER_OBJECT_ID_INTERNAL_LVTM1:
444 WREG32_P(AVIVO_LVTMA_CNTL, enable ? 0x4 : 0x0, ~0x4);
445 WREG32(offset+R600_HDMI_ENABLE, enable ? 0x105 : 0x0);
446 break;
447
448 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
449 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
450 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
451 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA:
452 /* This part is doubtfull in my opinion */
453 WREG32(offset+R600_HDMI_ENABLE, enable ? 0x110 : 0x0);
454 break;
455
456 default:
457 DRM_ERROR("unknown HDMI output type\n");
458 break;
459 } 478 }
460} 479}
461 480
462/* 481/*
463 * determin at which register offset the HDMI encoder is 482 * enable the HDMI engine
464 */ 483 */
465void r600_hdmi_init(struct drm_encoder *encoder) 484void r600_hdmi_enable(struct drm_encoder *encoder)
466{ 485{
486 struct drm_device *dev = encoder->dev;
487 struct radeon_device *rdev = dev->dev_private;
467 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 488 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
468 489
469 switch (radeon_encoder->encoder_id) { 490 if (ASIC_IS_DCE4(rdev))
470 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1: 491 return;
471 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY: 492
472 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1: 493 if (!radeon_encoder->hdmi_offset) {
473 radeon_encoder->hdmi_offset = R600_HDMI_TMDS1; 494 r600_hdmi_assign_block(encoder);
474 break; 495 if (!radeon_encoder->hdmi_offset) {
475 496 dev_warn(rdev->dev, "Could not find HDMI block for "
476 case ENCODER_OBJECT_ID_INTERNAL_LVTM1: 497 "0x%x encoder\n", radeon_encoder->encoder_id);
477 switch (r600_audio_tmds_index(encoder)) { 498 return;
478 case 0: 499 }
479 radeon_encoder->hdmi_offset = R600_HDMI_TMDS1; 500 }
501
502 if (ASIC_IS_DCE32(rdev) && !ASIC_IS_DCE4(rdev)) {
503 WREG32_P(radeon_encoder->hdmi_config_offset + 0x4, 0x1, ~0x1);
504 } else if (rdev->family >= CHIP_R600 && !ASIC_IS_DCE3(rdev)) {
505 int offset = radeon_encoder->hdmi_offset;
506 switch (radeon_encoder->encoder_id) {
507 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1:
508 WREG32_P(AVIVO_TMDSA_CNTL, 0x4, ~0x4);
509 WREG32(offset + R600_HDMI_ENABLE, 0x101);
480 break; 510 break;
481 case 1: 511 case ENCODER_OBJECT_ID_INTERNAL_LVTM1:
482 radeon_encoder->hdmi_offset = R600_HDMI_TMDS2; 512 WREG32_P(AVIVO_LVTMA_CNTL, 0x4, ~0x4);
513 WREG32(offset + R600_HDMI_ENABLE, 0x105);
483 break; 514 break;
484 default: 515 default:
485 radeon_encoder->hdmi_offset = 0; 516 dev_err(rdev->dev, "Unknown HDMI output type\n");
486 break; 517 break;
487 } 518 }
488 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2: 519 }
489 radeon_encoder->hdmi_offset = R600_HDMI_TMDS2; 520
490 break; 521 DRM_DEBUG("Enabling HDMI interface @ 0x%04X for encoder 0x%x\n",
522 radeon_encoder->hdmi_offset, radeon_encoder->encoder_id);
523}
524
525/*
526 * disable the HDMI engine
527 */
528void r600_hdmi_disable(struct drm_encoder *encoder)
529{
530 struct drm_device *dev = encoder->dev;
531 struct radeon_device *rdev = dev->dev_private;
532 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
491 533
492 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA: 534 if (ASIC_IS_DCE4(rdev))
493 radeon_encoder->hdmi_offset = R600_HDMI_DIG; 535 return;
494 break;
495 536
496 default: 537 if (!radeon_encoder->hdmi_offset) {
497 radeon_encoder->hdmi_offset = 0; 538 dev_err(rdev->dev, "Disabling not enabled HDMI\n");
498 break; 539 return;
499 } 540 }
500 541
501 DRM_DEBUG("using HDMI engine at offset 0x%04X for encoder 0x%x\n", 542 DRM_DEBUG("Disabling HDMI interface @ 0x%04X for encoder 0x%x\n",
502 radeon_encoder->hdmi_offset, radeon_encoder->encoder_id); 543 radeon_encoder->hdmi_offset, radeon_encoder->encoder_id);
544
545 if (ASIC_IS_DCE32(rdev) && !ASIC_IS_DCE4(rdev)) {
546 WREG32_P(radeon_encoder->hdmi_config_offset + 0x4, 0, ~0x1);
547 } else if (rdev->family >= CHIP_R600 && !ASIC_IS_DCE3(rdev)) {
548 int offset = radeon_encoder->hdmi_offset;
549 switch (radeon_encoder->encoder_id) {
550 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1:
551 WREG32_P(AVIVO_TMDSA_CNTL, 0, ~0x4);
552 WREG32(offset + R600_HDMI_ENABLE, 0);
553 break;
554 case ENCODER_OBJECT_ID_INTERNAL_LVTM1:
555 WREG32_P(AVIVO_LVTMA_CNTL, 0, ~0x4);
556 WREG32(offset + R600_HDMI_ENABLE, 0);
557 break;
558 default:
559 dev_err(rdev->dev, "Unknown HDMI output type\n");
560 break;
561 }
562 }
503 563
504 /* TODO: make this configureable */ 564 radeon_encoder->hdmi_offset = 0;
505 radeon_encoder->hdmi_audio_workaround = 0; 565 radeon_encoder->hdmi_config_offset = 0;
506} 566}
diff --git a/drivers/gpu/drm/radeon/r600_reg.h b/drivers/gpu/drm/radeon/r600_reg.h
index d0e28ffdeda..7b1d22370f6 100644
--- a/drivers/gpu/drm/radeon/r600_reg.h
+++ b/drivers/gpu/drm/radeon/r600_reg.h
@@ -152,9 +152,9 @@
152#define R600_AUDIO_STATUS_BITS 0x73d8 152#define R600_AUDIO_STATUS_BITS 0x73d8
153 153
154/* HDMI base register addresses */ 154/* HDMI base register addresses */
155#define R600_HDMI_TMDS1 0x7400 155#define R600_HDMI_BLOCK1 0x7400
156#define R600_HDMI_TMDS2 0x7700 156#define R600_HDMI_BLOCK2 0x7700
157#define R600_HDMI_DIG 0x7800 157#define R600_HDMI_BLOCK3 0x7800
158 158
159/* HDMI registers */ 159/* HDMI registers */
160#define R600_HDMI_ENABLE 0x00 160#define R600_HDMI_ENABLE 0x00
@@ -185,4 +185,8 @@
185#define R600_HDMI_AUDIO_DEBUG_2 0xe8 185#define R600_HDMI_AUDIO_DEBUG_2 0xe8
186#define R600_HDMI_AUDIO_DEBUG_3 0xec 186#define R600_HDMI_AUDIO_DEBUG_3 0xec
187 187
188/* HDMI additional config base register addresses */
189#define R600_HDMI_CONFIG1 0x7600
190#define R600_HDMI_CONFIG2 0x7a00
191
188#endif 192#endif
diff --git a/drivers/gpu/drm/radeon/r600d.h b/drivers/gpu/drm/radeon/r600d.h
index 5b2e4d44282..59c1f8793e6 100644
--- a/drivers/gpu/drm/radeon/r600d.h
+++ b/drivers/gpu/drm/radeon/r600d.h
@@ -77,6 +77,55 @@
77#define CB_COLOR0_FRAG 0x280e0 77#define CB_COLOR0_FRAG 0x280e0
78#define CB_COLOR0_MASK 0x28100 78#define CB_COLOR0_MASK 0x28100
79 79
80#define SQ_ALU_CONST_CACHE_PS_0 0x28940
81#define SQ_ALU_CONST_CACHE_PS_1 0x28944
82#define SQ_ALU_CONST_CACHE_PS_2 0x28948
83#define SQ_ALU_CONST_CACHE_PS_3 0x2894c
84#define SQ_ALU_CONST_CACHE_PS_4 0x28950
85#define SQ_ALU_CONST_CACHE_PS_5 0x28954
86#define SQ_ALU_CONST_CACHE_PS_6 0x28958
87#define SQ_ALU_CONST_CACHE_PS_7 0x2895c
88#define SQ_ALU_CONST_CACHE_PS_8 0x28960
89#define SQ_ALU_CONST_CACHE_PS_9 0x28964
90#define SQ_ALU_CONST_CACHE_PS_10 0x28968
91#define SQ_ALU_CONST_CACHE_PS_11 0x2896c
92#define SQ_ALU_CONST_CACHE_PS_12 0x28970
93#define SQ_ALU_CONST_CACHE_PS_13 0x28974
94#define SQ_ALU_CONST_CACHE_PS_14 0x28978
95#define SQ_ALU_CONST_CACHE_PS_15 0x2897c
96#define SQ_ALU_CONST_CACHE_VS_0 0x28980
97#define SQ_ALU_CONST_CACHE_VS_1 0x28984
98#define SQ_ALU_CONST_CACHE_VS_2 0x28988
99#define SQ_ALU_CONST_CACHE_VS_3 0x2898c
100#define SQ_ALU_CONST_CACHE_VS_4 0x28990
101#define SQ_ALU_CONST_CACHE_VS_5 0x28994
102#define SQ_ALU_CONST_CACHE_VS_6 0x28998
103#define SQ_ALU_CONST_CACHE_VS_7 0x2899c
104#define SQ_ALU_CONST_CACHE_VS_8 0x289a0
105#define SQ_ALU_CONST_CACHE_VS_9 0x289a4
106#define SQ_ALU_CONST_CACHE_VS_10 0x289a8
107#define SQ_ALU_CONST_CACHE_VS_11 0x289ac
108#define SQ_ALU_CONST_CACHE_VS_12 0x289b0
109#define SQ_ALU_CONST_CACHE_VS_13 0x289b4
110#define SQ_ALU_CONST_CACHE_VS_14 0x289b8
111#define SQ_ALU_CONST_CACHE_VS_15 0x289bc
112#define SQ_ALU_CONST_CACHE_GS_0 0x289c0
113#define SQ_ALU_CONST_CACHE_GS_1 0x289c4
114#define SQ_ALU_CONST_CACHE_GS_2 0x289c8
115#define SQ_ALU_CONST_CACHE_GS_3 0x289cc
116#define SQ_ALU_CONST_CACHE_GS_4 0x289d0
117#define SQ_ALU_CONST_CACHE_GS_5 0x289d4
118#define SQ_ALU_CONST_CACHE_GS_6 0x289d8
119#define SQ_ALU_CONST_CACHE_GS_7 0x289dc
120#define SQ_ALU_CONST_CACHE_GS_8 0x289e0
121#define SQ_ALU_CONST_CACHE_GS_9 0x289e4
122#define SQ_ALU_CONST_CACHE_GS_10 0x289e8
123#define SQ_ALU_CONST_CACHE_GS_11 0x289ec
124#define SQ_ALU_CONST_CACHE_GS_12 0x289f0
125#define SQ_ALU_CONST_CACHE_GS_13 0x289f4
126#define SQ_ALU_CONST_CACHE_GS_14 0x289f8
127#define SQ_ALU_CONST_CACHE_GS_15 0x289fc
128
80#define CONFIG_MEMSIZE 0x5428 129#define CONFIG_MEMSIZE 0x5428
81#define CONFIG_CNTL 0x5424 130#define CONFIG_CNTL 0x5424
82#define CP_STAT 0x8680 131#define CP_STAT 0x8680
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 829e26e8a4b..034218c3dbb 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -91,6 +91,8 @@ extern int radeon_tv;
91extern int radeon_new_pll; 91extern int radeon_new_pll;
92extern int radeon_dynpm; 92extern int radeon_dynpm;
93extern int radeon_audio; 93extern int radeon_audio;
94extern int radeon_disp_priority;
95extern int radeon_hw_i2c;
94 96
95/* 97/*
96 * Copy from radeon_drv.h so we don't have to include both and have conflicting 98 * Copy from radeon_drv.h so we don't have to include both and have conflicting
@@ -168,6 +170,7 @@ struct radeon_clock {
168 * Power management 170 * Power management
169 */ 171 */
170int radeon_pm_init(struct radeon_device *rdev); 172int radeon_pm_init(struct radeon_device *rdev);
173void radeon_pm_fini(struct radeon_device *rdev);
171void radeon_pm_compute_clocks(struct radeon_device *rdev); 174void radeon_pm_compute_clocks(struct radeon_device *rdev);
172void radeon_combios_get_power_modes(struct radeon_device *rdev); 175void radeon_combios_get_power_modes(struct radeon_device *rdev);
173void radeon_atombios_get_power_modes(struct radeon_device *rdev); 176void radeon_atombios_get_power_modes(struct radeon_device *rdev);
@@ -687,6 +690,7 @@ struct radeon_pm {
687 bool downclocked; 690 bool downclocked;
688 int active_crtcs; 691 int active_crtcs;
689 int req_vblank; 692 int req_vblank;
693 bool vblank_sync;
690 fixed20_12 max_bandwidth; 694 fixed20_12 max_bandwidth;
691 fixed20_12 igp_sideport_mclk; 695 fixed20_12 igp_sideport_mclk;
692 fixed20_12 igp_system_mclk; 696 fixed20_12 igp_system_mclk;
@@ -697,6 +701,7 @@ struct radeon_pm {
697 fixed20_12 ht_bandwidth; 701 fixed20_12 ht_bandwidth;
698 fixed20_12 core_bandwidth; 702 fixed20_12 core_bandwidth;
699 fixed20_12 sclk; 703 fixed20_12 sclk;
704 fixed20_12 mclk;
700 fixed20_12 needed_bandwidth; 705 fixed20_12 needed_bandwidth;
701 /* XXX: use a define for num power modes */ 706 /* XXX: use a define for num power modes */
702 struct radeon_power_state power_state[8]; 707 struct radeon_power_state power_state[8];
@@ -707,6 +712,7 @@ struct radeon_pm {
707 struct radeon_power_state *requested_power_state; 712 struct radeon_power_state *requested_power_state;
708 struct radeon_pm_clock_info *requested_clock_mode; 713 struct radeon_pm_clock_info *requested_clock_mode;
709 struct radeon_power_state *default_power_state; 714 struct radeon_power_state *default_power_state;
715 struct radeon_i2c_chan *i2c_bus;
710}; 716};
711 717
712 718
@@ -729,8 +735,6 @@ int radeon_debugfs_add_files(struct radeon_device *rdev,
729 struct drm_info_list *files, 735 struct drm_info_list *files,
730 unsigned nfiles); 736 unsigned nfiles);
731int radeon_debugfs_fence_init(struct radeon_device *rdev); 737int radeon_debugfs_fence_init(struct radeon_device *rdev);
732int r100_debugfs_rbbm_init(struct radeon_device *rdev);
733int r100_debugfs_cp_init(struct radeon_device *rdev);
734 738
735 739
736/* 740/*
@@ -782,7 +786,7 @@ struct radeon_asic {
782 int (*set_surface_reg)(struct radeon_device *rdev, int reg, 786 int (*set_surface_reg)(struct radeon_device *rdev, int reg,
783 uint32_t tiling_flags, uint32_t pitch, 787 uint32_t tiling_flags, uint32_t pitch,
784 uint32_t offset, uint32_t obj_size); 788 uint32_t offset, uint32_t obj_size);
785 int (*clear_surface_reg)(struct radeon_device *rdev, int reg); 789 void (*clear_surface_reg)(struct radeon_device *rdev, int reg);
786 void (*bandwidth_update)(struct radeon_device *rdev); 790 void (*bandwidth_update)(struct radeon_device *rdev);
787 void (*hpd_init)(struct radeon_device *rdev); 791 void (*hpd_init)(struct radeon_device *rdev);
788 void (*hpd_fini)(struct radeon_device *rdev); 792 void (*hpd_fini)(struct radeon_device *rdev);
@@ -862,6 +866,12 @@ union radeon_asic_config {
862 struct rv770_asic rv770; 866 struct rv770_asic rv770;
863}; 867};
864 868
869/*
870 * asic initizalization from radeon_asic.c
871 */
872void radeon_agp_disable(struct radeon_device *rdev);
873int radeon_asic_init(struct radeon_device *rdev);
874
865 875
866/* 876/*
867 * IOCTL. 877 * IOCTL.
@@ -1172,6 +1182,8 @@ extern void radeon_gart_restore(struct radeon_device *rdev);
1172extern int radeon_modeset_init(struct radeon_device *rdev); 1182extern int radeon_modeset_init(struct radeon_device *rdev);
1173extern void radeon_modeset_fini(struct radeon_device *rdev); 1183extern void radeon_modeset_fini(struct radeon_device *rdev);
1174extern bool radeon_card_posted(struct radeon_device *rdev); 1184extern bool radeon_card_posted(struct radeon_device *rdev);
1185extern void radeon_update_bandwidth_info(struct radeon_device *rdev);
1186extern void radeon_update_display_priority(struct radeon_device *rdev);
1175extern bool radeon_boot_test_post_card(struct radeon_device *rdev); 1187extern bool radeon_boot_test_post_card(struct radeon_device *rdev);
1176extern int radeon_clocks_init(struct radeon_device *rdev); 1188extern int radeon_clocks_init(struct radeon_device *rdev);
1177extern void radeon_clocks_fini(struct radeon_device *rdev); 1189extern void radeon_clocks_fini(struct radeon_device *rdev);
@@ -1188,51 +1200,6 @@ extern int radeon_resume_kms(struct drm_device *dev);
1188extern int radeon_suspend_kms(struct drm_device *dev, pm_message_t state); 1200extern int radeon_suspend_kms(struct drm_device *dev, pm_message_t state);
1189 1201
1190/* r100,rv100,rs100,rv200,rs200,r200,rv250,rs300,rv280 */ 1202/* r100,rv100,rs100,rv200,rs200,r200,rv250,rs300,rv280 */
1191struct r100_mc_save {
1192 u32 GENMO_WT;
1193 u32 CRTC_EXT_CNTL;
1194 u32 CRTC_GEN_CNTL;
1195 u32 CRTC2_GEN_CNTL;
1196 u32 CUR_OFFSET;
1197 u32 CUR2_OFFSET;
1198};
1199extern void r100_cp_disable(struct radeon_device *rdev);
1200extern int r100_cp_init(struct radeon_device *rdev, unsigned ring_size);
1201extern void r100_cp_fini(struct radeon_device *rdev);
1202extern void r100_pci_gart_tlb_flush(struct radeon_device *rdev);
1203extern int r100_pci_gart_init(struct radeon_device *rdev);
1204extern void r100_pci_gart_fini(struct radeon_device *rdev);
1205extern int r100_pci_gart_enable(struct radeon_device *rdev);
1206extern void r100_pci_gart_disable(struct radeon_device *rdev);
1207extern int r100_pci_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr);
1208extern int r100_debugfs_mc_info_init(struct radeon_device *rdev);
1209extern int r100_gui_wait_for_idle(struct radeon_device *rdev);
1210extern void r100_ib_fini(struct radeon_device *rdev);
1211extern int r100_ib_init(struct radeon_device *rdev);
1212extern void r100_irq_disable(struct radeon_device *rdev);
1213extern int r100_irq_set(struct radeon_device *rdev);
1214extern void r100_mc_stop(struct radeon_device *rdev, struct r100_mc_save *save);
1215extern void r100_mc_resume(struct radeon_device *rdev, struct r100_mc_save *save);
1216extern void r100_vram_init_sizes(struct radeon_device *rdev);
1217extern void r100_wb_disable(struct radeon_device *rdev);
1218extern void r100_wb_fini(struct radeon_device *rdev);
1219extern int r100_wb_init(struct radeon_device *rdev);
1220extern void r100_hdp_reset(struct radeon_device *rdev);
1221extern int r100_rb2d_reset(struct radeon_device *rdev);
1222extern int r100_cp_reset(struct radeon_device *rdev);
1223extern void r100_vga_render_disable(struct radeon_device *rdev);
1224extern int r100_cs_track_check_pkt3_indx_buffer(struct radeon_cs_parser *p,
1225 struct radeon_cs_packet *pkt,
1226 struct radeon_bo *robj);
1227extern int r100_cs_parse_packet0(struct radeon_cs_parser *p,
1228 struct radeon_cs_packet *pkt,
1229 const unsigned *auth, unsigned n,
1230 radeon_packet0_check_t check);
1231extern int r100_cs_packet_parse(struct radeon_cs_parser *p,
1232 struct radeon_cs_packet *pkt,
1233 unsigned idx);
1234extern void r100_enable_bm(struct radeon_device *rdev);
1235extern void r100_set_common_regs(struct radeon_device *rdev);
1236 1203
1237/* rv200,rv250,rv280 */ 1204/* rv200,rv250,rv280 */
1238extern void r200_set_safe_registers(struct radeon_device *rdev); 1205extern void r200_set_safe_registers(struct radeon_device *rdev);
@@ -1322,7 +1289,8 @@ extern int r600_audio_tmds_index(struct drm_encoder *encoder);
1322extern void r600_audio_set_clock(struct drm_encoder *encoder, int clock); 1289extern void r600_audio_set_clock(struct drm_encoder *encoder, int clock);
1323extern void r600_audio_fini(struct radeon_device *rdev); 1290extern void r600_audio_fini(struct radeon_device *rdev);
1324extern void r600_hdmi_init(struct drm_encoder *encoder); 1291extern void r600_hdmi_init(struct drm_encoder *encoder);
1325extern void r600_hdmi_enable(struct drm_encoder *encoder, int enable); 1292extern void r600_hdmi_enable(struct drm_encoder *encoder);
1293extern void r600_hdmi_disable(struct drm_encoder *encoder);
1326extern void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mode); 1294extern void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mode);
1327extern int r600_hdmi_buffer_status_changed(struct drm_encoder *encoder); 1295extern int r600_hdmi_buffer_status_changed(struct drm_encoder *encoder);
1328extern void r600_hdmi_update_audio_settings(struct drm_encoder *encoder, 1296extern void r600_hdmi_update_audio_settings(struct drm_encoder *encoder,
diff --git a/drivers/gpu/drm/radeon/radeon_agp.c b/drivers/gpu/drm/radeon/radeon_agp.c
index c4457791dff..28e473f1f56 100644
--- a/drivers/gpu/drm/radeon/radeon_agp.c
+++ b/drivers/gpu/drm/radeon/radeon_agp.c
@@ -134,12 +134,10 @@ int radeon_agp_init(struct radeon_device *rdev)
134 int ret; 134 int ret;
135 135
136 /* Acquire AGP. */ 136 /* Acquire AGP. */
137 if (!rdev->ddev->agp->acquired) { 137 ret = drm_agp_acquire(rdev->ddev);
138 ret = drm_agp_acquire(rdev->ddev); 138 if (ret) {
139 if (ret) { 139 DRM_ERROR("Unable to acquire AGP: %d\n", ret);
140 DRM_ERROR("Unable to acquire AGP: %d\n", ret); 140 return ret;
141 return ret;
142 }
143 } 141 }
144 142
145 ret = drm_agp_info(rdev->ddev, &info); 143 ret = drm_agp_info(rdev->ddev, &info);
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c b/drivers/gpu/drm/radeon/radeon_asic.c
new file mode 100644
index 00000000000..a4b4bc9fa32
--- /dev/null
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -0,0 +1,772 @@
1/*
2 * Copyright 2008 Advanced Micro Devices, Inc.
3 * Copyright 2008 Red Hat Inc.
4 * Copyright 2009 Jerome Glisse.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
23 *
24 * Authors: Dave Airlie
25 * Alex Deucher
26 * Jerome Glisse
27 */
28
29#include <linux/console.h>
30#include <drm/drmP.h>
31#include <drm/drm_crtc_helper.h>
32#include <drm/radeon_drm.h>
33#include <linux/vgaarb.h>
34#include <linux/vga_switcheroo.h>
35#include "radeon_reg.h"
36#include "radeon.h"
37#include "radeon_asic.h"
38#include "atom.h"
39
40/*
41 * Registers accessors functions.
42 */
43static uint32_t radeon_invalid_rreg(struct radeon_device *rdev, uint32_t reg)
44{
45 DRM_ERROR("Invalid callback to read register 0x%04X\n", reg);
46 BUG_ON(1);
47 return 0;
48}
49
50static void radeon_invalid_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
51{
52 DRM_ERROR("Invalid callback to write register 0x%04X with 0x%08X\n",
53 reg, v);
54 BUG_ON(1);
55}
56
57static void radeon_register_accessor_init(struct radeon_device *rdev)
58{
59 rdev->mc_rreg = &radeon_invalid_rreg;
60 rdev->mc_wreg = &radeon_invalid_wreg;
61 rdev->pll_rreg = &radeon_invalid_rreg;
62 rdev->pll_wreg = &radeon_invalid_wreg;
63 rdev->pciep_rreg = &radeon_invalid_rreg;
64 rdev->pciep_wreg = &radeon_invalid_wreg;
65
66 /* Don't change order as we are overridding accessor. */
67 if (rdev->family < CHIP_RV515) {
68 rdev->pcie_reg_mask = 0xff;
69 } else {
70 rdev->pcie_reg_mask = 0x7ff;
71 }
72 /* FIXME: not sure here */
73 if (rdev->family <= CHIP_R580) {
74 rdev->pll_rreg = &r100_pll_rreg;
75 rdev->pll_wreg = &r100_pll_wreg;
76 }
77 if (rdev->family >= CHIP_R420) {
78 rdev->mc_rreg = &r420_mc_rreg;
79 rdev->mc_wreg = &r420_mc_wreg;
80 }
81 if (rdev->family >= CHIP_RV515) {
82 rdev->mc_rreg = &rv515_mc_rreg;
83 rdev->mc_wreg = &rv515_mc_wreg;
84 }
85 if (rdev->family == CHIP_RS400 || rdev->family == CHIP_RS480) {
86 rdev->mc_rreg = &rs400_mc_rreg;
87 rdev->mc_wreg = &rs400_mc_wreg;
88 }
89 if (rdev->family == CHIP_RS690 || rdev->family == CHIP_RS740) {
90 rdev->mc_rreg = &rs690_mc_rreg;
91 rdev->mc_wreg = &rs690_mc_wreg;
92 }
93 if (rdev->family == CHIP_RS600) {
94 rdev->mc_rreg = &rs600_mc_rreg;
95 rdev->mc_wreg = &rs600_mc_wreg;
96 }
97 if ((rdev->family >= CHIP_R600) && (rdev->family <= CHIP_RV740)) {
98 rdev->pciep_rreg = &r600_pciep_rreg;
99 rdev->pciep_wreg = &r600_pciep_wreg;
100 }
101}
102
103
104/* helper to disable agp */
105void radeon_agp_disable(struct radeon_device *rdev)
106{
107 rdev->flags &= ~RADEON_IS_AGP;
108 if (rdev->family >= CHIP_R600) {
109 DRM_INFO("Forcing AGP to PCIE mode\n");
110 rdev->flags |= RADEON_IS_PCIE;
111 } else if (rdev->family >= CHIP_RV515 ||
112 rdev->family == CHIP_RV380 ||
113 rdev->family == CHIP_RV410 ||
114 rdev->family == CHIP_R423) {
115 DRM_INFO("Forcing AGP to PCIE mode\n");
116 rdev->flags |= RADEON_IS_PCIE;
117 rdev->asic->gart_tlb_flush = &rv370_pcie_gart_tlb_flush;
118 rdev->asic->gart_set_page = &rv370_pcie_gart_set_page;
119 } else {
120 DRM_INFO("Forcing AGP to PCI mode\n");
121 rdev->flags |= RADEON_IS_PCI;
122 rdev->asic->gart_tlb_flush = &r100_pci_gart_tlb_flush;
123 rdev->asic->gart_set_page = &r100_pci_gart_set_page;
124 }
125 rdev->mc.gtt_size = radeon_gart_size * 1024 * 1024;
126}
127
128/*
129 * ASIC
130 */
131static struct radeon_asic r100_asic = {
132 .init = &r100_init,
133 .fini = &r100_fini,
134 .suspend = &r100_suspend,
135 .resume = &r100_resume,
136 .vga_set_state = &r100_vga_set_state,
137 .gpu_reset = &r100_gpu_reset,
138 .gart_tlb_flush = &r100_pci_gart_tlb_flush,
139 .gart_set_page = &r100_pci_gart_set_page,
140 .cp_commit = &r100_cp_commit,
141 .ring_start = &r100_ring_start,
142 .ring_test = &r100_ring_test,
143 .ring_ib_execute = &r100_ring_ib_execute,
144 .irq_set = &r100_irq_set,
145 .irq_process = &r100_irq_process,
146 .get_vblank_counter = &r100_get_vblank_counter,
147 .fence_ring_emit = &r100_fence_ring_emit,
148 .cs_parse = &r100_cs_parse,
149 .copy_blit = &r100_copy_blit,
150 .copy_dma = NULL,
151 .copy = &r100_copy_blit,
152 .get_engine_clock = &radeon_legacy_get_engine_clock,
153 .set_engine_clock = &radeon_legacy_set_engine_clock,
154 .get_memory_clock = &radeon_legacy_get_memory_clock,
155 .set_memory_clock = NULL,
156 .get_pcie_lanes = NULL,
157 .set_pcie_lanes = NULL,
158 .set_clock_gating = &radeon_legacy_set_clock_gating,
159 .set_surface_reg = r100_set_surface_reg,
160 .clear_surface_reg = r100_clear_surface_reg,
161 .bandwidth_update = &r100_bandwidth_update,
162 .hpd_init = &r100_hpd_init,
163 .hpd_fini = &r100_hpd_fini,
164 .hpd_sense = &r100_hpd_sense,
165 .hpd_set_polarity = &r100_hpd_set_polarity,
166 .ioctl_wait_idle = NULL,
167};
168
169static struct radeon_asic r200_asic = {
170 .init = &r100_init,
171 .fini = &r100_fini,
172 .suspend = &r100_suspend,
173 .resume = &r100_resume,
174 .vga_set_state = &r100_vga_set_state,
175 .gpu_reset = &r100_gpu_reset,
176 .gart_tlb_flush = &r100_pci_gart_tlb_flush,
177 .gart_set_page = &r100_pci_gart_set_page,
178 .cp_commit = &r100_cp_commit,
179 .ring_start = &r100_ring_start,
180 .ring_test = &r100_ring_test,
181 .ring_ib_execute = &r100_ring_ib_execute,
182 .irq_set = &r100_irq_set,
183 .irq_process = &r100_irq_process,
184 .get_vblank_counter = &r100_get_vblank_counter,
185 .fence_ring_emit = &r100_fence_ring_emit,
186 .cs_parse = &r100_cs_parse,
187 .copy_blit = &r100_copy_blit,
188 .copy_dma = &r200_copy_dma,
189 .copy = &r100_copy_blit,
190 .get_engine_clock = &radeon_legacy_get_engine_clock,
191 .set_engine_clock = &radeon_legacy_set_engine_clock,
192 .get_memory_clock = &radeon_legacy_get_memory_clock,
193 .set_memory_clock = NULL,
194 .set_pcie_lanes = NULL,
195 .set_clock_gating = &radeon_legacy_set_clock_gating,
196 .set_surface_reg = r100_set_surface_reg,
197 .clear_surface_reg = r100_clear_surface_reg,
198 .bandwidth_update = &r100_bandwidth_update,
199 .hpd_init = &r100_hpd_init,
200 .hpd_fini = &r100_hpd_fini,
201 .hpd_sense = &r100_hpd_sense,
202 .hpd_set_polarity = &r100_hpd_set_polarity,
203 .ioctl_wait_idle = NULL,
204};
205
206static struct radeon_asic r300_asic = {
207 .init = &r300_init,
208 .fini = &r300_fini,
209 .suspend = &r300_suspend,
210 .resume = &r300_resume,
211 .vga_set_state = &r100_vga_set_state,
212 .gpu_reset = &r300_gpu_reset,
213 .gart_tlb_flush = &r100_pci_gart_tlb_flush,
214 .gart_set_page = &r100_pci_gart_set_page,
215 .cp_commit = &r100_cp_commit,
216 .ring_start = &r300_ring_start,
217 .ring_test = &r100_ring_test,
218 .ring_ib_execute = &r100_ring_ib_execute,
219 .irq_set = &r100_irq_set,
220 .irq_process = &r100_irq_process,
221 .get_vblank_counter = &r100_get_vblank_counter,
222 .fence_ring_emit = &r300_fence_ring_emit,
223 .cs_parse = &r300_cs_parse,
224 .copy_blit = &r100_copy_blit,
225 .copy_dma = &r200_copy_dma,
226 .copy = &r100_copy_blit,
227 .get_engine_clock = &radeon_legacy_get_engine_clock,
228 .set_engine_clock = &radeon_legacy_set_engine_clock,
229 .get_memory_clock = &radeon_legacy_get_memory_clock,
230 .set_memory_clock = NULL,
231 .get_pcie_lanes = &rv370_get_pcie_lanes,
232 .set_pcie_lanes = &rv370_set_pcie_lanes,
233 .set_clock_gating = &radeon_legacy_set_clock_gating,
234 .set_surface_reg = r100_set_surface_reg,
235 .clear_surface_reg = r100_clear_surface_reg,
236 .bandwidth_update = &r100_bandwidth_update,
237 .hpd_init = &r100_hpd_init,
238 .hpd_fini = &r100_hpd_fini,
239 .hpd_sense = &r100_hpd_sense,
240 .hpd_set_polarity = &r100_hpd_set_polarity,
241 .ioctl_wait_idle = NULL,
242};
243
244static struct radeon_asic r300_asic_pcie = {
245 .init = &r300_init,
246 .fini = &r300_fini,
247 .suspend = &r300_suspend,
248 .resume = &r300_resume,
249 .vga_set_state = &r100_vga_set_state,
250 .gpu_reset = &r300_gpu_reset,
251 .gart_tlb_flush = &rv370_pcie_gart_tlb_flush,
252 .gart_set_page = &rv370_pcie_gart_set_page,
253 .cp_commit = &r100_cp_commit,
254 .ring_start = &r300_ring_start,
255 .ring_test = &r100_ring_test,
256 .ring_ib_execute = &r100_ring_ib_execute,
257 .irq_set = &r100_irq_set,
258 .irq_process = &r100_irq_process,
259 .get_vblank_counter = &r100_get_vblank_counter,
260 .fence_ring_emit = &r300_fence_ring_emit,
261 .cs_parse = &r300_cs_parse,
262 .copy_blit = &r100_copy_blit,
263 .copy_dma = &r200_copy_dma,
264 .copy = &r100_copy_blit,
265 .get_engine_clock = &radeon_legacy_get_engine_clock,
266 .set_engine_clock = &radeon_legacy_set_engine_clock,
267 .get_memory_clock = &radeon_legacy_get_memory_clock,
268 .set_memory_clock = NULL,
269 .set_pcie_lanes = &rv370_set_pcie_lanes,
270 .set_clock_gating = &radeon_legacy_set_clock_gating,
271 .set_surface_reg = r100_set_surface_reg,
272 .clear_surface_reg = r100_clear_surface_reg,
273 .bandwidth_update = &r100_bandwidth_update,
274 .hpd_init = &r100_hpd_init,
275 .hpd_fini = &r100_hpd_fini,
276 .hpd_sense = &r100_hpd_sense,
277 .hpd_set_polarity = &r100_hpd_set_polarity,
278 .ioctl_wait_idle = NULL,
279};
280
281static struct radeon_asic r420_asic = {
282 .init = &r420_init,
283 .fini = &r420_fini,
284 .suspend = &r420_suspend,
285 .resume = &r420_resume,
286 .vga_set_state = &r100_vga_set_state,
287 .gpu_reset = &r300_gpu_reset,
288 .gart_tlb_flush = &rv370_pcie_gart_tlb_flush,
289 .gart_set_page = &rv370_pcie_gart_set_page,
290 .cp_commit = &r100_cp_commit,
291 .ring_start = &r300_ring_start,
292 .ring_test = &r100_ring_test,
293 .ring_ib_execute = &r100_ring_ib_execute,
294 .irq_set = &r100_irq_set,
295 .irq_process = &r100_irq_process,
296 .get_vblank_counter = &r100_get_vblank_counter,
297 .fence_ring_emit = &r300_fence_ring_emit,
298 .cs_parse = &r300_cs_parse,
299 .copy_blit = &r100_copy_blit,
300 .copy_dma = &r200_copy_dma,
301 .copy = &r100_copy_blit,
302 .get_engine_clock = &radeon_atom_get_engine_clock,
303 .set_engine_clock = &radeon_atom_set_engine_clock,
304 .get_memory_clock = &radeon_atom_get_memory_clock,
305 .set_memory_clock = &radeon_atom_set_memory_clock,
306 .get_pcie_lanes = &rv370_get_pcie_lanes,
307 .set_pcie_lanes = &rv370_set_pcie_lanes,
308 .set_clock_gating = &radeon_atom_set_clock_gating,
309 .set_surface_reg = r100_set_surface_reg,
310 .clear_surface_reg = r100_clear_surface_reg,
311 .bandwidth_update = &r100_bandwidth_update,
312 .hpd_init = &r100_hpd_init,
313 .hpd_fini = &r100_hpd_fini,
314 .hpd_sense = &r100_hpd_sense,
315 .hpd_set_polarity = &r100_hpd_set_polarity,
316 .ioctl_wait_idle = NULL,
317};
318
319static struct radeon_asic rs400_asic = {
320 .init = &rs400_init,
321 .fini = &rs400_fini,
322 .suspend = &rs400_suspend,
323 .resume = &rs400_resume,
324 .vga_set_state = &r100_vga_set_state,
325 .gpu_reset = &r300_gpu_reset,
326 .gart_tlb_flush = &rs400_gart_tlb_flush,
327 .gart_set_page = &rs400_gart_set_page,
328 .cp_commit = &r100_cp_commit,
329 .ring_start = &r300_ring_start,
330 .ring_test = &r100_ring_test,
331 .ring_ib_execute = &r100_ring_ib_execute,
332 .irq_set = &r100_irq_set,
333 .irq_process = &r100_irq_process,
334 .get_vblank_counter = &r100_get_vblank_counter,
335 .fence_ring_emit = &r300_fence_ring_emit,
336 .cs_parse = &r300_cs_parse,
337 .copy_blit = &r100_copy_blit,
338 .copy_dma = &r200_copy_dma,
339 .copy = &r100_copy_blit,
340 .get_engine_clock = &radeon_legacy_get_engine_clock,
341 .set_engine_clock = &radeon_legacy_set_engine_clock,
342 .get_memory_clock = &radeon_legacy_get_memory_clock,
343 .set_memory_clock = NULL,
344 .get_pcie_lanes = NULL,
345 .set_pcie_lanes = NULL,
346 .set_clock_gating = &radeon_legacy_set_clock_gating,
347 .set_surface_reg = r100_set_surface_reg,
348 .clear_surface_reg = r100_clear_surface_reg,
349 .bandwidth_update = &r100_bandwidth_update,
350 .hpd_init = &r100_hpd_init,
351 .hpd_fini = &r100_hpd_fini,
352 .hpd_sense = &r100_hpd_sense,
353 .hpd_set_polarity = &r100_hpd_set_polarity,
354 .ioctl_wait_idle = NULL,
355};
356
357static struct radeon_asic rs600_asic = {
358 .init = &rs600_init,
359 .fini = &rs600_fini,
360 .suspend = &rs600_suspend,
361 .resume = &rs600_resume,
362 .vga_set_state = &r100_vga_set_state,
363 .gpu_reset = &r300_gpu_reset,
364 .gart_tlb_flush = &rs600_gart_tlb_flush,
365 .gart_set_page = &rs600_gart_set_page,
366 .cp_commit = &r100_cp_commit,
367 .ring_start = &r300_ring_start,
368 .ring_test = &r100_ring_test,
369 .ring_ib_execute = &r100_ring_ib_execute,
370 .irq_set = &rs600_irq_set,
371 .irq_process = &rs600_irq_process,
372 .get_vblank_counter = &rs600_get_vblank_counter,
373 .fence_ring_emit = &r300_fence_ring_emit,
374 .cs_parse = &r300_cs_parse,
375 .copy_blit = &r100_copy_blit,
376 .copy_dma = &r200_copy_dma,
377 .copy = &r100_copy_blit,
378 .get_engine_clock = &radeon_atom_get_engine_clock,
379 .set_engine_clock = &radeon_atom_set_engine_clock,
380 .get_memory_clock = &radeon_atom_get_memory_clock,
381 .set_memory_clock = &radeon_atom_set_memory_clock,
382 .get_pcie_lanes = NULL,
383 .set_pcie_lanes = NULL,
384 .set_clock_gating = &radeon_atom_set_clock_gating,
385 .set_surface_reg = r100_set_surface_reg,
386 .clear_surface_reg = r100_clear_surface_reg,
387 .bandwidth_update = &rs600_bandwidth_update,
388 .hpd_init = &rs600_hpd_init,
389 .hpd_fini = &rs600_hpd_fini,
390 .hpd_sense = &rs600_hpd_sense,
391 .hpd_set_polarity = &rs600_hpd_set_polarity,
392 .ioctl_wait_idle = NULL,
393};
394
395static struct radeon_asic rs690_asic = {
396 .init = &rs690_init,
397 .fini = &rs690_fini,
398 .suspend = &rs690_suspend,
399 .resume = &rs690_resume,
400 .vga_set_state = &r100_vga_set_state,
401 .gpu_reset = &r300_gpu_reset,
402 .gart_tlb_flush = &rs400_gart_tlb_flush,
403 .gart_set_page = &rs400_gart_set_page,
404 .cp_commit = &r100_cp_commit,
405 .ring_start = &r300_ring_start,
406 .ring_test = &r100_ring_test,
407 .ring_ib_execute = &r100_ring_ib_execute,
408 .irq_set = &rs600_irq_set,
409 .irq_process = &rs600_irq_process,
410 .get_vblank_counter = &rs600_get_vblank_counter,
411 .fence_ring_emit = &r300_fence_ring_emit,
412 .cs_parse = &r300_cs_parse,
413 .copy_blit = &r100_copy_blit,
414 .copy_dma = &r200_copy_dma,
415 .copy = &r200_copy_dma,
416 .get_engine_clock = &radeon_atom_get_engine_clock,
417 .set_engine_clock = &radeon_atom_set_engine_clock,
418 .get_memory_clock = &radeon_atom_get_memory_clock,
419 .set_memory_clock = &radeon_atom_set_memory_clock,
420 .get_pcie_lanes = NULL,
421 .set_pcie_lanes = NULL,
422 .set_clock_gating = &radeon_atom_set_clock_gating,
423 .set_surface_reg = r100_set_surface_reg,
424 .clear_surface_reg = r100_clear_surface_reg,
425 .bandwidth_update = &rs690_bandwidth_update,
426 .hpd_init = &rs600_hpd_init,
427 .hpd_fini = &rs600_hpd_fini,
428 .hpd_sense = &rs600_hpd_sense,
429 .hpd_set_polarity = &rs600_hpd_set_polarity,
430 .ioctl_wait_idle = NULL,
431};
432
433static struct radeon_asic rv515_asic = {
434 .init = &rv515_init,
435 .fini = &rv515_fini,
436 .suspend = &rv515_suspend,
437 .resume = &rv515_resume,
438 .vga_set_state = &r100_vga_set_state,
439 .gpu_reset = &rv515_gpu_reset,
440 .gart_tlb_flush = &rv370_pcie_gart_tlb_flush,
441 .gart_set_page = &rv370_pcie_gart_set_page,
442 .cp_commit = &r100_cp_commit,
443 .ring_start = &rv515_ring_start,
444 .ring_test = &r100_ring_test,
445 .ring_ib_execute = &r100_ring_ib_execute,
446 .irq_set = &rs600_irq_set,
447 .irq_process = &rs600_irq_process,
448 .get_vblank_counter = &rs600_get_vblank_counter,
449 .fence_ring_emit = &r300_fence_ring_emit,
450 .cs_parse = &r300_cs_parse,
451 .copy_blit = &r100_copy_blit,
452 .copy_dma = &r200_copy_dma,
453 .copy = &r100_copy_blit,
454 .get_engine_clock = &radeon_atom_get_engine_clock,
455 .set_engine_clock = &radeon_atom_set_engine_clock,
456 .get_memory_clock = &radeon_atom_get_memory_clock,
457 .set_memory_clock = &radeon_atom_set_memory_clock,
458 .get_pcie_lanes = &rv370_get_pcie_lanes,
459 .set_pcie_lanes = &rv370_set_pcie_lanes,
460 .set_clock_gating = &radeon_atom_set_clock_gating,
461 .set_surface_reg = r100_set_surface_reg,
462 .clear_surface_reg = r100_clear_surface_reg,
463 .bandwidth_update = &rv515_bandwidth_update,
464 .hpd_init = &rs600_hpd_init,
465 .hpd_fini = &rs600_hpd_fini,
466 .hpd_sense = &rs600_hpd_sense,
467 .hpd_set_polarity = &rs600_hpd_set_polarity,
468 .ioctl_wait_idle = NULL,
469};
470
471static struct radeon_asic r520_asic = {
472 .init = &r520_init,
473 .fini = &rv515_fini,
474 .suspend = &rv515_suspend,
475 .resume = &r520_resume,
476 .vga_set_state = &r100_vga_set_state,
477 .gpu_reset = &rv515_gpu_reset,
478 .gart_tlb_flush = &rv370_pcie_gart_tlb_flush,
479 .gart_set_page = &rv370_pcie_gart_set_page,
480 .cp_commit = &r100_cp_commit,
481 .ring_start = &rv515_ring_start,
482 .ring_test = &r100_ring_test,
483 .ring_ib_execute = &r100_ring_ib_execute,
484 .irq_set = &rs600_irq_set,
485 .irq_process = &rs600_irq_process,
486 .get_vblank_counter = &rs600_get_vblank_counter,
487 .fence_ring_emit = &r300_fence_ring_emit,
488 .cs_parse = &r300_cs_parse,
489 .copy_blit = &r100_copy_blit,
490 .copy_dma = &r200_copy_dma,
491 .copy = &r100_copy_blit,
492 .get_engine_clock = &radeon_atom_get_engine_clock,
493 .set_engine_clock = &radeon_atom_set_engine_clock,
494 .get_memory_clock = &radeon_atom_get_memory_clock,
495 .set_memory_clock = &radeon_atom_set_memory_clock,
496 .get_pcie_lanes = &rv370_get_pcie_lanes,
497 .set_pcie_lanes = &rv370_set_pcie_lanes,
498 .set_clock_gating = &radeon_atom_set_clock_gating,
499 .set_surface_reg = r100_set_surface_reg,
500 .clear_surface_reg = r100_clear_surface_reg,
501 .bandwidth_update = &rv515_bandwidth_update,
502 .hpd_init = &rs600_hpd_init,
503 .hpd_fini = &rs600_hpd_fini,
504 .hpd_sense = &rs600_hpd_sense,
505 .hpd_set_polarity = &rs600_hpd_set_polarity,
506 .ioctl_wait_idle = NULL,
507};
508
509static struct radeon_asic r600_asic = {
510 .init = &r600_init,
511 .fini = &r600_fini,
512 .suspend = &r600_suspend,
513 .resume = &r600_resume,
514 .cp_commit = &r600_cp_commit,
515 .vga_set_state = &r600_vga_set_state,
516 .gpu_reset = &r600_gpu_reset,
517 .gart_tlb_flush = &r600_pcie_gart_tlb_flush,
518 .gart_set_page = &rs600_gart_set_page,
519 .ring_test = &r600_ring_test,
520 .ring_ib_execute = &r600_ring_ib_execute,
521 .irq_set = &r600_irq_set,
522 .irq_process = &r600_irq_process,
523 .get_vblank_counter = &rs600_get_vblank_counter,
524 .fence_ring_emit = &r600_fence_ring_emit,
525 .cs_parse = &r600_cs_parse,
526 .copy_blit = &r600_copy_blit,
527 .copy_dma = &r600_copy_blit,
528 .copy = &r600_copy_blit,
529 .get_engine_clock = &radeon_atom_get_engine_clock,
530 .set_engine_clock = &radeon_atom_set_engine_clock,
531 .get_memory_clock = &radeon_atom_get_memory_clock,
532 .set_memory_clock = &radeon_atom_set_memory_clock,
533 .get_pcie_lanes = &rv370_get_pcie_lanes,
534 .set_pcie_lanes = NULL,
535 .set_clock_gating = NULL,
536 .set_surface_reg = r600_set_surface_reg,
537 .clear_surface_reg = r600_clear_surface_reg,
538 .bandwidth_update = &rv515_bandwidth_update,
539 .hpd_init = &r600_hpd_init,
540 .hpd_fini = &r600_hpd_fini,
541 .hpd_sense = &r600_hpd_sense,
542 .hpd_set_polarity = &r600_hpd_set_polarity,
543 .ioctl_wait_idle = r600_ioctl_wait_idle,
544};
545
546static struct radeon_asic rs780_asic = {
547 .init = &r600_init,
548 .fini = &r600_fini,
549 .suspend = &r600_suspend,
550 .resume = &r600_resume,
551 .cp_commit = &r600_cp_commit,
552 .vga_set_state = &r600_vga_set_state,
553 .gpu_reset = &r600_gpu_reset,
554 .gart_tlb_flush = &r600_pcie_gart_tlb_flush,
555 .gart_set_page = &rs600_gart_set_page,
556 .ring_test = &r600_ring_test,
557 .ring_ib_execute = &r600_ring_ib_execute,
558 .irq_set = &r600_irq_set,
559 .irq_process = &r600_irq_process,
560 .get_vblank_counter = &rs600_get_vblank_counter,
561 .fence_ring_emit = &r600_fence_ring_emit,
562 .cs_parse = &r600_cs_parse,
563 .copy_blit = &r600_copy_blit,
564 .copy_dma = &r600_copy_blit,
565 .copy = &r600_copy_blit,
566 .get_engine_clock = &radeon_atom_get_engine_clock,
567 .set_engine_clock = &radeon_atom_set_engine_clock,
568 .get_memory_clock = NULL,
569 .set_memory_clock = NULL,
570 .get_pcie_lanes = NULL,
571 .set_pcie_lanes = NULL,
572 .set_clock_gating = NULL,
573 .set_surface_reg = r600_set_surface_reg,
574 .clear_surface_reg = r600_clear_surface_reg,
575 .bandwidth_update = &rs690_bandwidth_update,
576 .hpd_init = &r600_hpd_init,
577 .hpd_fini = &r600_hpd_fini,
578 .hpd_sense = &r600_hpd_sense,
579 .hpd_set_polarity = &r600_hpd_set_polarity,
580 .ioctl_wait_idle = r600_ioctl_wait_idle,
581};
582
583static struct radeon_asic rv770_asic = {
584 .init = &rv770_init,
585 .fini = &rv770_fini,
586 .suspend = &rv770_suspend,
587 .resume = &rv770_resume,
588 .cp_commit = &r600_cp_commit,
589 .gpu_reset = &rv770_gpu_reset,
590 .vga_set_state = &r600_vga_set_state,
591 .gart_tlb_flush = &r600_pcie_gart_tlb_flush,
592 .gart_set_page = &rs600_gart_set_page,
593 .ring_test = &r600_ring_test,
594 .ring_ib_execute = &r600_ring_ib_execute,
595 .irq_set = &r600_irq_set,
596 .irq_process = &r600_irq_process,
597 .get_vblank_counter = &rs600_get_vblank_counter,
598 .fence_ring_emit = &r600_fence_ring_emit,
599 .cs_parse = &r600_cs_parse,
600 .copy_blit = &r600_copy_blit,
601 .copy_dma = &r600_copy_blit,
602 .copy = &r600_copy_blit,
603 .get_engine_clock = &radeon_atom_get_engine_clock,
604 .set_engine_clock = &radeon_atom_set_engine_clock,
605 .get_memory_clock = &radeon_atom_get_memory_clock,
606 .set_memory_clock = &radeon_atom_set_memory_clock,
607 .get_pcie_lanes = &rv370_get_pcie_lanes,
608 .set_pcie_lanes = NULL,
609 .set_clock_gating = &radeon_atom_set_clock_gating,
610 .set_surface_reg = r600_set_surface_reg,
611 .clear_surface_reg = r600_clear_surface_reg,
612 .bandwidth_update = &rv515_bandwidth_update,
613 .hpd_init = &r600_hpd_init,
614 .hpd_fini = &r600_hpd_fini,
615 .hpd_sense = &r600_hpd_sense,
616 .hpd_set_polarity = &r600_hpd_set_polarity,
617 .ioctl_wait_idle = r600_ioctl_wait_idle,
618};
619
620static struct radeon_asic evergreen_asic = {
621 .init = &evergreen_init,
622 .fini = &evergreen_fini,
623 .suspend = &evergreen_suspend,
624 .resume = &evergreen_resume,
625 .cp_commit = NULL,
626 .gpu_reset = &evergreen_gpu_reset,
627 .vga_set_state = &r600_vga_set_state,
628 .gart_tlb_flush = &r600_pcie_gart_tlb_flush,
629 .gart_set_page = &rs600_gart_set_page,
630 .ring_test = NULL,
631 .ring_ib_execute = NULL,
632 .irq_set = NULL,
633 .irq_process = NULL,
634 .get_vblank_counter = NULL,
635 .fence_ring_emit = NULL,
636 .cs_parse = NULL,
637 .copy_blit = NULL,
638 .copy_dma = NULL,
639 .copy = NULL,
640 .get_engine_clock = &radeon_atom_get_engine_clock,
641 .set_engine_clock = &radeon_atom_set_engine_clock,
642 .get_memory_clock = &radeon_atom_get_memory_clock,
643 .set_memory_clock = &radeon_atom_set_memory_clock,
644 .set_pcie_lanes = NULL,
645 .set_clock_gating = NULL,
646 .set_surface_reg = r600_set_surface_reg,
647 .clear_surface_reg = r600_clear_surface_reg,
648 .bandwidth_update = &evergreen_bandwidth_update,
649 .hpd_init = &evergreen_hpd_init,
650 .hpd_fini = &evergreen_hpd_fini,
651 .hpd_sense = &evergreen_hpd_sense,
652 .hpd_set_polarity = &evergreen_hpd_set_polarity,
653};
654
655int radeon_asic_init(struct radeon_device *rdev)
656{
657 radeon_register_accessor_init(rdev);
658 switch (rdev->family) {
659 case CHIP_R100:
660 case CHIP_RV100:
661 case CHIP_RS100:
662 case CHIP_RV200:
663 case CHIP_RS200:
664 rdev->asic = &r100_asic;
665 break;
666 case CHIP_R200:
667 case CHIP_RV250:
668 case CHIP_RS300:
669 case CHIP_RV280:
670 rdev->asic = &r200_asic;
671 break;
672 case CHIP_R300:
673 case CHIP_R350:
674 case CHIP_RV350:
675 case CHIP_RV380:
676 if (rdev->flags & RADEON_IS_PCIE)
677 rdev->asic = &r300_asic_pcie;
678 else
679 rdev->asic = &r300_asic;
680 break;
681 case CHIP_R420:
682 case CHIP_R423:
683 case CHIP_RV410:
684 rdev->asic = &r420_asic;
685 break;
686 case CHIP_RS400:
687 case CHIP_RS480:
688 rdev->asic = &rs400_asic;
689 break;
690 case CHIP_RS600:
691 rdev->asic = &rs600_asic;
692 break;
693 case CHIP_RS690:
694 case CHIP_RS740:
695 rdev->asic = &rs690_asic;
696 break;
697 case CHIP_RV515:
698 rdev->asic = &rv515_asic;
699 break;
700 case CHIP_R520:
701 case CHIP_RV530:
702 case CHIP_RV560:
703 case CHIP_RV570:
704 case CHIP_R580:
705 rdev->asic = &r520_asic;
706 break;
707 case CHIP_R600:
708 case CHIP_RV610:
709 case CHIP_RV630:
710 case CHIP_RV620:
711 case CHIP_RV635:
712 case CHIP_RV670:
713 rdev->asic = &r600_asic;
714 break;
715 case CHIP_RS780:
716 case CHIP_RS880:
717 rdev->asic = &rs780_asic;
718 break;
719 case CHIP_RV770:
720 case CHIP_RV730:
721 case CHIP_RV710:
722 case CHIP_RV740:
723 rdev->asic = &rv770_asic;
724 break;
725 case CHIP_CEDAR:
726 case CHIP_REDWOOD:
727 case CHIP_JUNIPER:
728 case CHIP_CYPRESS:
729 case CHIP_HEMLOCK:
730 rdev->asic = &evergreen_asic;
731 break;
732 default:
733 /* FIXME: not supported yet */
734 return -EINVAL;
735 }
736
737 if (rdev->flags & RADEON_IS_IGP) {
738 rdev->asic->get_memory_clock = NULL;
739 rdev->asic->set_memory_clock = NULL;
740 }
741
742 /* set the number of crtcs */
743 if (rdev->flags & RADEON_SINGLE_CRTC)
744 rdev->num_crtc = 1;
745 else {
746 if (ASIC_IS_DCE4(rdev))
747 rdev->num_crtc = 6;
748 else
749 rdev->num_crtc = 2;
750 }
751
752 return 0;
753}
754
755/*
756 * Wrapper around modesetting bits. Move to radeon_clocks.c?
757 */
758int radeon_clocks_init(struct radeon_device *rdev)
759{
760 int r;
761
762 r = radeon_static_clocks_init(rdev->ddev);
763 if (r) {
764 return r;
765 }
766 DRM_INFO("Clocks initialized !\n");
767 return 0;
768}
769
770void radeon_clocks_fini(struct radeon_device *rdev)
771{
772}
diff --git a/drivers/gpu/drm/radeon/radeon_asic.h b/drivers/gpu/drm/radeon/radeon_asic.h
index d3a157b2bcb..a0b8280663d 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.h
+++ b/drivers/gpu/drm/radeon/radeon_asic.h
@@ -45,10 +45,18 @@ void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable);
45/* 45/*
46 * r100,rv100,rs100,rv200,rs200 46 * r100,rv100,rs100,rv200,rs200
47 */ 47 */
48extern int r100_init(struct radeon_device *rdev); 48struct r100_mc_save {
49extern void r100_fini(struct radeon_device *rdev); 49 u32 GENMO_WT;
50extern int r100_suspend(struct radeon_device *rdev); 50 u32 CRTC_EXT_CNTL;
51extern int r100_resume(struct radeon_device *rdev); 51 u32 CRTC_GEN_CNTL;
52 u32 CRTC2_GEN_CNTL;
53 u32 CUR_OFFSET;
54 u32 CUR2_OFFSET;
55};
56int r100_init(struct radeon_device *rdev);
57void r100_fini(struct radeon_device *rdev);
58int r100_suspend(struct radeon_device *rdev);
59int r100_resume(struct radeon_device *rdev);
52uint32_t r100_mm_rreg(struct radeon_device *rdev, uint32_t reg); 60uint32_t r100_mm_rreg(struct radeon_device *rdev, uint32_t reg);
53void r100_mm_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v); 61void r100_mm_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v);
54void r100_vga_set_state(struct radeon_device *rdev, bool state); 62void r100_vga_set_state(struct radeon_device *rdev, bool state);
@@ -73,7 +81,7 @@ int r100_copy_blit(struct radeon_device *rdev,
73int r100_set_surface_reg(struct radeon_device *rdev, int reg, 81int r100_set_surface_reg(struct radeon_device *rdev, int reg,
74 uint32_t tiling_flags, uint32_t pitch, 82 uint32_t tiling_flags, uint32_t pitch,
75 uint32_t offset, uint32_t obj_size); 83 uint32_t offset, uint32_t obj_size);
76int r100_clear_surface_reg(struct radeon_device *rdev, int reg); 84void r100_clear_surface_reg(struct radeon_device *rdev, int reg);
77void r100_bandwidth_update(struct radeon_device *rdev); 85void r100_bandwidth_update(struct radeon_device *rdev);
78void r100_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib); 86void r100_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib);
79int r100_ring_test(struct radeon_device *rdev); 87int r100_ring_test(struct radeon_device *rdev);
@@ -82,44 +90,42 @@ void r100_hpd_fini(struct radeon_device *rdev);
82bool r100_hpd_sense(struct radeon_device *rdev, enum radeon_hpd_id hpd); 90bool r100_hpd_sense(struct radeon_device *rdev, enum radeon_hpd_id hpd);
83void r100_hpd_set_polarity(struct radeon_device *rdev, 91void r100_hpd_set_polarity(struct radeon_device *rdev,
84 enum radeon_hpd_id hpd); 92 enum radeon_hpd_id hpd);
85 93int r100_debugfs_rbbm_init(struct radeon_device *rdev);
86static struct radeon_asic r100_asic = { 94int r100_debugfs_cp_init(struct radeon_device *rdev);
87 .init = &r100_init, 95void r100_cp_disable(struct radeon_device *rdev);
88 .fini = &r100_fini, 96int r100_cp_init(struct radeon_device *rdev, unsigned ring_size);
89 .suspend = &r100_suspend, 97void r100_cp_fini(struct radeon_device *rdev);
90 .resume = &r100_resume, 98int r100_pci_gart_init(struct radeon_device *rdev);
91 .vga_set_state = &r100_vga_set_state, 99void r100_pci_gart_fini(struct radeon_device *rdev);
92 .gpu_reset = &r100_gpu_reset, 100int r100_pci_gart_enable(struct radeon_device *rdev);
93 .gart_tlb_flush = &r100_pci_gart_tlb_flush, 101void r100_pci_gart_disable(struct radeon_device *rdev);
94 .gart_set_page = &r100_pci_gart_set_page, 102int r100_debugfs_mc_info_init(struct radeon_device *rdev);
95 .cp_commit = &r100_cp_commit, 103int r100_gui_wait_for_idle(struct radeon_device *rdev);
96 .ring_start = &r100_ring_start, 104void r100_ib_fini(struct radeon_device *rdev);
97 .ring_test = &r100_ring_test, 105int r100_ib_init(struct radeon_device *rdev);
98 .ring_ib_execute = &r100_ring_ib_execute, 106void r100_irq_disable(struct radeon_device *rdev);
99 .irq_set = &r100_irq_set, 107void r100_mc_stop(struct radeon_device *rdev, struct r100_mc_save *save);
100 .irq_process = &r100_irq_process, 108void r100_mc_resume(struct radeon_device *rdev, struct r100_mc_save *save);
101 .get_vblank_counter = &r100_get_vblank_counter, 109void r100_vram_init_sizes(struct radeon_device *rdev);
102 .fence_ring_emit = &r100_fence_ring_emit, 110void r100_wb_disable(struct radeon_device *rdev);
103 .cs_parse = &r100_cs_parse, 111void r100_wb_fini(struct radeon_device *rdev);
104 .copy_blit = &r100_copy_blit, 112int r100_wb_init(struct radeon_device *rdev);
105 .copy_dma = NULL, 113void r100_hdp_reset(struct radeon_device *rdev);
106 .copy = &r100_copy_blit, 114int r100_rb2d_reset(struct radeon_device *rdev);
107 .get_engine_clock = &radeon_legacy_get_engine_clock, 115int r100_cp_reset(struct radeon_device *rdev);
108 .set_engine_clock = &radeon_legacy_set_engine_clock, 116void r100_vga_render_disable(struct radeon_device *rdev);
109 .get_memory_clock = &radeon_legacy_get_memory_clock, 117int r100_cs_track_check_pkt3_indx_buffer(struct radeon_cs_parser *p,
110 .set_memory_clock = NULL, 118 struct radeon_cs_packet *pkt,
111 .get_pcie_lanes = NULL, 119 struct radeon_bo *robj);
112 .set_pcie_lanes = NULL, 120int r100_cs_parse_packet0(struct radeon_cs_parser *p,
113 .set_clock_gating = &radeon_legacy_set_clock_gating, 121 struct radeon_cs_packet *pkt,
114 .set_surface_reg = r100_set_surface_reg, 122 const unsigned *auth, unsigned n,
115 .clear_surface_reg = r100_clear_surface_reg, 123 radeon_packet0_check_t check);
116 .bandwidth_update = &r100_bandwidth_update, 124int r100_cs_packet_parse(struct radeon_cs_parser *p,
117 .hpd_init = &r100_hpd_init, 125 struct radeon_cs_packet *pkt,
118 .hpd_fini = &r100_hpd_fini, 126 unsigned idx);
119 .hpd_sense = &r100_hpd_sense, 127void r100_enable_bm(struct radeon_device *rdev);
120 .hpd_set_polarity = &r100_hpd_set_polarity, 128void r100_set_common_regs(struct radeon_device *rdev);
121 .ioctl_wait_idle = NULL,
122};
123 129
124/* 130/*
125 * r200,rv250,rs300,rv280 131 * r200,rv250,rs300,rv280
@@ -129,43 +135,6 @@ extern int r200_copy_dma(struct radeon_device *rdev,
129 uint64_t dst_offset, 135 uint64_t dst_offset,
130 unsigned num_pages, 136 unsigned num_pages,
131 struct radeon_fence *fence); 137 struct radeon_fence *fence);
132static struct radeon_asic r200_asic = {
133 .init = &r100_init,
134 .fini = &r100_fini,
135 .suspend = &r100_suspend,
136 .resume = &r100_resume,
137 .vga_set_state = &r100_vga_set_state,
138 .gpu_reset = &r100_gpu_reset,
139 .gart_tlb_flush = &r100_pci_gart_tlb_flush,
140 .gart_set_page = &r100_pci_gart_set_page,
141 .cp_commit = &r100_cp_commit,
142 .ring_start = &r100_ring_start,
143 .ring_test = &r100_ring_test,
144 .ring_ib_execute = &r100_ring_ib_execute,
145 .irq_set = &r100_irq_set,
146 .irq_process = &r100_irq_process,
147 .get_vblank_counter = &r100_get_vblank_counter,
148 .fence_ring_emit = &r100_fence_ring_emit,
149 .cs_parse = &r100_cs_parse,
150 .copy_blit = &r100_copy_blit,
151 .copy_dma = &r200_copy_dma,
152 .copy = &r100_copy_blit,
153 .get_engine_clock = &radeon_legacy_get_engine_clock,
154 .set_engine_clock = &radeon_legacy_set_engine_clock,
155 .get_memory_clock = &radeon_legacy_get_memory_clock,
156 .set_memory_clock = NULL,
157 .set_pcie_lanes = NULL,
158 .set_clock_gating = &radeon_legacy_set_clock_gating,
159 .set_surface_reg = r100_set_surface_reg,
160 .clear_surface_reg = r100_clear_surface_reg,
161 .bandwidth_update = &r100_bandwidth_update,
162 .hpd_init = &r100_hpd_init,
163 .hpd_fini = &r100_hpd_fini,
164 .hpd_sense = &r100_hpd_sense,
165 .hpd_set_polarity = &r100_hpd_set_polarity,
166 .ioctl_wait_idle = NULL,
167};
168
169 138
170/* 139/*
171 * r300,r350,rv350,rv380 140 * r300,r350,rv350,rv380
@@ -186,82 +155,6 @@ extern void rv370_pcie_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v
186extern void rv370_set_pcie_lanes(struct radeon_device *rdev, int lanes); 155extern void rv370_set_pcie_lanes(struct radeon_device *rdev, int lanes);
187extern int rv370_get_pcie_lanes(struct radeon_device *rdev); 156extern int rv370_get_pcie_lanes(struct radeon_device *rdev);
188 157
189static struct radeon_asic r300_asic = {
190 .init = &r300_init,
191 .fini = &r300_fini,
192 .suspend = &r300_suspend,
193 .resume = &r300_resume,
194 .vga_set_state = &r100_vga_set_state,
195 .gpu_reset = &r300_gpu_reset,
196 .gart_tlb_flush = &r100_pci_gart_tlb_flush,
197 .gart_set_page = &r100_pci_gart_set_page,
198 .cp_commit = &r100_cp_commit,
199 .ring_start = &r300_ring_start,
200 .ring_test = &r100_ring_test,
201 .ring_ib_execute = &r100_ring_ib_execute,
202 .irq_set = &r100_irq_set,
203 .irq_process = &r100_irq_process,
204 .get_vblank_counter = &r100_get_vblank_counter,
205 .fence_ring_emit = &r300_fence_ring_emit,
206 .cs_parse = &r300_cs_parse,
207 .copy_blit = &r100_copy_blit,
208 .copy_dma = &r200_copy_dma,
209 .copy = &r100_copy_blit,
210 .get_engine_clock = &radeon_legacy_get_engine_clock,
211 .set_engine_clock = &radeon_legacy_set_engine_clock,
212 .get_memory_clock = &radeon_legacy_get_memory_clock,
213 .set_memory_clock = NULL,
214 .get_pcie_lanes = &rv370_get_pcie_lanes,
215 .set_pcie_lanes = &rv370_set_pcie_lanes,
216 .set_clock_gating = &radeon_legacy_set_clock_gating,
217 .set_surface_reg = r100_set_surface_reg,
218 .clear_surface_reg = r100_clear_surface_reg,
219 .bandwidth_update = &r100_bandwidth_update,
220 .hpd_init = &r100_hpd_init,
221 .hpd_fini = &r100_hpd_fini,
222 .hpd_sense = &r100_hpd_sense,
223 .hpd_set_polarity = &r100_hpd_set_polarity,
224 .ioctl_wait_idle = NULL,
225};
226
227
228static struct radeon_asic r300_asic_pcie = {
229 .init = &r300_init,
230 .fini = &r300_fini,
231 .suspend = &r300_suspend,
232 .resume = &r300_resume,
233 .vga_set_state = &r100_vga_set_state,
234 .gpu_reset = &r300_gpu_reset,
235 .gart_tlb_flush = &rv370_pcie_gart_tlb_flush,
236 .gart_set_page = &rv370_pcie_gart_set_page,
237 .cp_commit = &r100_cp_commit,
238 .ring_start = &r300_ring_start,
239 .ring_test = &r100_ring_test,
240 .ring_ib_execute = &r100_ring_ib_execute,
241 .irq_set = &r100_irq_set,
242 .irq_process = &r100_irq_process,
243 .get_vblank_counter = &r100_get_vblank_counter,
244 .fence_ring_emit = &r300_fence_ring_emit,
245 .cs_parse = &r300_cs_parse,
246 .copy_blit = &r100_copy_blit,
247 .copy_dma = &r200_copy_dma,
248 .copy = &r100_copy_blit,
249 .get_engine_clock = &radeon_legacy_get_engine_clock,
250 .set_engine_clock = &radeon_legacy_set_engine_clock,
251 .get_memory_clock = &radeon_legacy_get_memory_clock,
252 .set_memory_clock = NULL,
253 .set_pcie_lanes = &rv370_set_pcie_lanes,
254 .set_clock_gating = &radeon_legacy_set_clock_gating,
255 .set_surface_reg = r100_set_surface_reg,
256 .clear_surface_reg = r100_clear_surface_reg,
257 .bandwidth_update = &r100_bandwidth_update,
258 .hpd_init = &r100_hpd_init,
259 .hpd_fini = &r100_hpd_fini,
260 .hpd_sense = &r100_hpd_sense,
261 .hpd_set_polarity = &r100_hpd_set_polarity,
262 .ioctl_wait_idle = NULL,
263};
264
265/* 158/*
266 * r420,r423,rv410 159 * r420,r423,rv410
267 */ 160 */
@@ -269,44 +162,6 @@ extern int r420_init(struct radeon_device *rdev);
269extern void r420_fini(struct radeon_device *rdev); 162extern void r420_fini(struct radeon_device *rdev);
270extern int r420_suspend(struct radeon_device *rdev); 163extern int r420_suspend(struct radeon_device *rdev);
271extern int r420_resume(struct radeon_device *rdev); 164extern int r420_resume(struct radeon_device *rdev);
272static struct radeon_asic r420_asic = {
273 .init = &r420_init,
274 .fini = &r420_fini,
275 .suspend = &r420_suspend,
276 .resume = &r420_resume,
277 .vga_set_state = &r100_vga_set_state,
278 .gpu_reset = &r300_gpu_reset,
279 .gart_tlb_flush = &rv370_pcie_gart_tlb_flush,
280 .gart_set_page = &rv370_pcie_gart_set_page,
281 .cp_commit = &r100_cp_commit,
282 .ring_start = &r300_ring_start,
283 .ring_test = &r100_ring_test,
284 .ring_ib_execute = &r100_ring_ib_execute,
285 .irq_set = &r100_irq_set,
286 .irq_process = &r100_irq_process,
287 .get_vblank_counter = &r100_get_vblank_counter,
288 .fence_ring_emit = &r300_fence_ring_emit,
289 .cs_parse = &r300_cs_parse,
290 .copy_blit = &r100_copy_blit,
291 .copy_dma = &r200_copy_dma,
292 .copy = &r100_copy_blit,
293 .get_engine_clock = &radeon_atom_get_engine_clock,
294 .set_engine_clock = &radeon_atom_set_engine_clock,
295 .get_memory_clock = &radeon_atom_get_memory_clock,
296 .set_memory_clock = &radeon_atom_set_memory_clock,
297 .get_pcie_lanes = &rv370_get_pcie_lanes,
298 .set_pcie_lanes = &rv370_set_pcie_lanes,
299 .set_clock_gating = &radeon_atom_set_clock_gating,
300 .set_surface_reg = r100_set_surface_reg,
301 .clear_surface_reg = r100_clear_surface_reg,
302 .bandwidth_update = &r100_bandwidth_update,
303 .hpd_init = &r100_hpd_init,
304 .hpd_fini = &r100_hpd_fini,
305 .hpd_sense = &r100_hpd_sense,
306 .hpd_set_polarity = &r100_hpd_set_polarity,
307 .ioctl_wait_idle = NULL,
308};
309
310 165
311/* 166/*
312 * rs400,rs480 167 * rs400,rs480
@@ -319,44 +174,6 @@ void rs400_gart_tlb_flush(struct radeon_device *rdev);
319int rs400_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr); 174int rs400_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr);
320uint32_t rs400_mc_rreg(struct radeon_device *rdev, uint32_t reg); 175uint32_t rs400_mc_rreg(struct radeon_device *rdev, uint32_t reg);
321void rs400_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v); 176void rs400_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v);
322static struct radeon_asic rs400_asic = {
323 .init = &rs400_init,
324 .fini = &rs400_fini,
325 .suspend = &rs400_suspend,
326 .resume = &rs400_resume,
327 .vga_set_state = &r100_vga_set_state,
328 .gpu_reset = &r300_gpu_reset,
329 .gart_tlb_flush = &rs400_gart_tlb_flush,
330 .gart_set_page = &rs400_gart_set_page,
331 .cp_commit = &r100_cp_commit,
332 .ring_start = &r300_ring_start,
333 .ring_test = &r100_ring_test,
334 .ring_ib_execute = &r100_ring_ib_execute,
335 .irq_set = &r100_irq_set,
336 .irq_process = &r100_irq_process,
337 .get_vblank_counter = &r100_get_vblank_counter,
338 .fence_ring_emit = &r300_fence_ring_emit,
339 .cs_parse = &r300_cs_parse,
340 .copy_blit = &r100_copy_blit,
341 .copy_dma = &r200_copy_dma,
342 .copy = &r100_copy_blit,
343 .get_engine_clock = &radeon_legacy_get_engine_clock,
344 .set_engine_clock = &radeon_legacy_set_engine_clock,
345 .get_memory_clock = &radeon_legacy_get_memory_clock,
346 .set_memory_clock = NULL,
347 .get_pcie_lanes = NULL,
348 .set_pcie_lanes = NULL,
349 .set_clock_gating = &radeon_legacy_set_clock_gating,
350 .set_surface_reg = r100_set_surface_reg,
351 .clear_surface_reg = r100_clear_surface_reg,
352 .bandwidth_update = &r100_bandwidth_update,
353 .hpd_init = &r100_hpd_init,
354 .hpd_fini = &r100_hpd_fini,
355 .hpd_sense = &r100_hpd_sense,
356 .hpd_set_polarity = &r100_hpd_set_polarity,
357 .ioctl_wait_idle = NULL,
358};
359
360 177
361/* 178/*
362 * rs600. 179 * rs600.
@@ -379,45 +196,6 @@ bool rs600_hpd_sense(struct radeon_device *rdev, enum radeon_hpd_id hpd);
379void rs600_hpd_set_polarity(struct radeon_device *rdev, 196void rs600_hpd_set_polarity(struct radeon_device *rdev,
380 enum radeon_hpd_id hpd); 197 enum radeon_hpd_id hpd);
381 198
382static struct radeon_asic rs600_asic = {
383 .init = &rs600_init,
384 .fini = &rs600_fini,
385 .suspend = &rs600_suspend,
386 .resume = &rs600_resume,
387 .vga_set_state = &r100_vga_set_state,
388 .gpu_reset = &r300_gpu_reset,
389 .gart_tlb_flush = &rs600_gart_tlb_flush,
390 .gart_set_page = &rs600_gart_set_page,
391 .cp_commit = &r100_cp_commit,
392 .ring_start = &r300_ring_start,
393 .ring_test = &r100_ring_test,
394 .ring_ib_execute = &r100_ring_ib_execute,
395 .irq_set = &rs600_irq_set,
396 .irq_process = &rs600_irq_process,
397 .get_vblank_counter = &rs600_get_vblank_counter,
398 .fence_ring_emit = &r300_fence_ring_emit,
399 .cs_parse = &r300_cs_parse,
400 .copy_blit = &r100_copy_blit,
401 .copy_dma = &r200_copy_dma,
402 .copy = &r100_copy_blit,
403 .get_engine_clock = &radeon_atom_get_engine_clock,
404 .set_engine_clock = &radeon_atom_set_engine_clock,
405 .get_memory_clock = &radeon_atom_get_memory_clock,
406 .set_memory_clock = &radeon_atom_set_memory_clock,
407 .get_pcie_lanes = NULL,
408 .set_pcie_lanes = NULL,
409 .set_clock_gating = &radeon_atom_set_clock_gating,
410 .set_surface_reg = r100_set_surface_reg,
411 .clear_surface_reg = r100_clear_surface_reg,
412 .bandwidth_update = &rs600_bandwidth_update,
413 .hpd_init = &rs600_hpd_init,
414 .hpd_fini = &rs600_hpd_fini,
415 .hpd_sense = &rs600_hpd_sense,
416 .hpd_set_polarity = &rs600_hpd_set_polarity,
417 .ioctl_wait_idle = NULL,
418};
419
420
421/* 199/*
422 * rs690,rs740 200 * rs690,rs740
423 */ 201 */
@@ -428,44 +206,6 @@ int rs690_suspend(struct radeon_device *rdev);
428uint32_t rs690_mc_rreg(struct radeon_device *rdev, uint32_t reg); 206uint32_t rs690_mc_rreg(struct radeon_device *rdev, uint32_t reg);
429void rs690_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v); 207void rs690_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v);
430void rs690_bandwidth_update(struct radeon_device *rdev); 208void rs690_bandwidth_update(struct radeon_device *rdev);
431static struct radeon_asic rs690_asic = {
432 .init = &rs690_init,
433 .fini = &rs690_fini,
434 .suspend = &rs690_suspend,
435 .resume = &rs690_resume,
436 .vga_set_state = &r100_vga_set_state,
437 .gpu_reset = &r300_gpu_reset,
438 .gart_tlb_flush = &rs400_gart_tlb_flush,
439 .gart_set_page = &rs400_gart_set_page,
440 .cp_commit = &r100_cp_commit,
441 .ring_start = &r300_ring_start,
442 .ring_test = &r100_ring_test,
443 .ring_ib_execute = &r100_ring_ib_execute,
444 .irq_set = &rs600_irq_set,
445 .irq_process = &rs600_irq_process,
446 .get_vblank_counter = &rs600_get_vblank_counter,
447 .fence_ring_emit = &r300_fence_ring_emit,
448 .cs_parse = &r300_cs_parse,
449 .copy_blit = &r100_copy_blit,
450 .copy_dma = &r200_copy_dma,
451 .copy = &r200_copy_dma,
452 .get_engine_clock = &radeon_atom_get_engine_clock,
453 .set_engine_clock = &radeon_atom_set_engine_clock,
454 .get_memory_clock = &radeon_atom_get_memory_clock,
455 .set_memory_clock = &radeon_atom_set_memory_clock,
456 .get_pcie_lanes = NULL,
457 .set_pcie_lanes = NULL,
458 .set_clock_gating = &radeon_atom_set_clock_gating,
459 .set_surface_reg = r100_set_surface_reg,
460 .clear_surface_reg = r100_clear_surface_reg,
461 .bandwidth_update = &rs690_bandwidth_update,
462 .hpd_init = &rs600_hpd_init,
463 .hpd_fini = &rs600_hpd_fini,
464 .hpd_sense = &rs600_hpd_sense,
465 .hpd_set_polarity = &rs600_hpd_set_polarity,
466 .ioctl_wait_idle = NULL,
467};
468
469 209
470/* 210/*
471 * rv515 211 * rv515
@@ -481,87 +221,12 @@ void rv515_pcie_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v);
481void rv515_bandwidth_update(struct radeon_device *rdev); 221void rv515_bandwidth_update(struct radeon_device *rdev);
482int rv515_resume(struct radeon_device *rdev); 222int rv515_resume(struct radeon_device *rdev);
483int rv515_suspend(struct radeon_device *rdev); 223int rv515_suspend(struct radeon_device *rdev);
484static struct radeon_asic rv515_asic = {
485 .init = &rv515_init,
486 .fini = &rv515_fini,
487 .suspend = &rv515_suspend,
488 .resume = &rv515_resume,
489 .vga_set_state = &r100_vga_set_state,
490 .gpu_reset = &rv515_gpu_reset,
491 .gart_tlb_flush = &rv370_pcie_gart_tlb_flush,
492 .gart_set_page = &rv370_pcie_gart_set_page,
493 .cp_commit = &r100_cp_commit,
494 .ring_start = &rv515_ring_start,
495 .ring_test = &r100_ring_test,
496 .ring_ib_execute = &r100_ring_ib_execute,
497 .irq_set = &rs600_irq_set,
498 .irq_process = &rs600_irq_process,
499 .get_vblank_counter = &rs600_get_vblank_counter,
500 .fence_ring_emit = &r300_fence_ring_emit,
501 .cs_parse = &r300_cs_parse,
502 .copy_blit = &r100_copy_blit,
503 .copy_dma = &r200_copy_dma,
504 .copy = &r100_copy_blit,
505 .get_engine_clock = &radeon_atom_get_engine_clock,
506 .set_engine_clock = &radeon_atom_set_engine_clock,
507 .get_memory_clock = &radeon_atom_get_memory_clock,
508 .set_memory_clock = &radeon_atom_set_memory_clock,
509 .get_pcie_lanes = &rv370_get_pcie_lanes,
510 .set_pcie_lanes = &rv370_set_pcie_lanes,
511 .set_clock_gating = &radeon_atom_set_clock_gating,
512 .set_surface_reg = r100_set_surface_reg,
513 .clear_surface_reg = r100_clear_surface_reg,
514 .bandwidth_update = &rv515_bandwidth_update,
515 .hpd_init = &rs600_hpd_init,
516 .hpd_fini = &rs600_hpd_fini,
517 .hpd_sense = &rs600_hpd_sense,
518 .hpd_set_polarity = &rs600_hpd_set_polarity,
519 .ioctl_wait_idle = NULL,
520};
521
522 224
523/* 225/*
524 * r520,rv530,rv560,rv570,r580 226 * r520,rv530,rv560,rv570,r580
525 */ 227 */
526int r520_init(struct radeon_device *rdev); 228int r520_init(struct radeon_device *rdev);
527int r520_resume(struct radeon_device *rdev); 229int r520_resume(struct radeon_device *rdev);
528static struct radeon_asic r520_asic = {
529 .init = &r520_init,
530 .fini = &rv515_fini,
531 .suspend = &rv515_suspend,
532 .resume = &r520_resume,
533 .vga_set_state = &r100_vga_set_state,
534 .gpu_reset = &rv515_gpu_reset,
535 .gart_tlb_flush = &rv370_pcie_gart_tlb_flush,
536 .gart_set_page = &rv370_pcie_gart_set_page,
537 .cp_commit = &r100_cp_commit,
538 .ring_start = &rv515_ring_start,
539 .ring_test = &r100_ring_test,
540 .ring_ib_execute = &r100_ring_ib_execute,
541 .irq_set = &rs600_irq_set,
542 .irq_process = &rs600_irq_process,
543 .get_vblank_counter = &rs600_get_vblank_counter,
544 .fence_ring_emit = &r300_fence_ring_emit,
545 .cs_parse = &r300_cs_parse,
546 .copy_blit = &r100_copy_blit,
547 .copy_dma = &r200_copy_dma,
548 .copy = &r100_copy_blit,
549 .get_engine_clock = &radeon_atom_get_engine_clock,
550 .set_engine_clock = &radeon_atom_set_engine_clock,
551 .get_memory_clock = &radeon_atom_get_memory_clock,
552 .set_memory_clock = &radeon_atom_set_memory_clock,
553 .get_pcie_lanes = &rv370_get_pcie_lanes,
554 .set_pcie_lanes = &rv370_set_pcie_lanes,
555 .set_clock_gating = &radeon_atom_set_clock_gating,
556 .set_surface_reg = r100_set_surface_reg,
557 .clear_surface_reg = r100_clear_surface_reg,
558 .bandwidth_update = &rv515_bandwidth_update,
559 .hpd_init = &rs600_hpd_init,
560 .hpd_fini = &rs600_hpd_fini,
561 .hpd_sense = &rs600_hpd_sense,
562 .hpd_set_polarity = &rs600_hpd_set_polarity,
563 .ioctl_wait_idle = NULL,
564};
565 230
566/* 231/*
567 * r600,rv610,rv630,rv620,rv635,rv670,rs780,rs880 232 * r600,rv610,rv630,rv620,rv635,rv670,rs780,rs880
@@ -591,7 +256,7 @@ int r600_gpu_reset(struct radeon_device *rdev);
591int r600_set_surface_reg(struct radeon_device *rdev, int reg, 256int r600_set_surface_reg(struct radeon_device *rdev, int reg,
592 uint32_t tiling_flags, uint32_t pitch, 257 uint32_t tiling_flags, uint32_t pitch,
593 uint32_t offset, uint32_t obj_size); 258 uint32_t offset, uint32_t obj_size);
594int r600_clear_surface_reg(struct radeon_device *rdev, int reg); 259void r600_clear_surface_reg(struct radeon_device *rdev, int reg);
595void r600_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib); 260void r600_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib);
596int r600_ring_test(struct radeon_device *rdev); 261int r600_ring_test(struct radeon_device *rdev);
597int r600_copy_blit(struct radeon_device *rdev, 262int r600_copy_blit(struct radeon_device *rdev,
@@ -604,43 +269,6 @@ void r600_hpd_set_polarity(struct radeon_device *rdev,
604 enum radeon_hpd_id hpd); 269 enum radeon_hpd_id hpd);
605extern void r600_ioctl_wait_idle(struct radeon_device *rdev, struct radeon_bo *bo); 270extern void r600_ioctl_wait_idle(struct radeon_device *rdev, struct radeon_bo *bo);
606 271
607static struct radeon_asic r600_asic = {
608 .init = &r600_init,
609 .fini = &r600_fini,
610 .suspend = &r600_suspend,
611 .resume = &r600_resume,
612 .cp_commit = &r600_cp_commit,
613 .vga_set_state = &r600_vga_set_state,
614 .gpu_reset = &r600_gpu_reset,
615 .gart_tlb_flush = &r600_pcie_gart_tlb_flush,
616 .gart_set_page = &rs600_gart_set_page,
617 .ring_test = &r600_ring_test,
618 .ring_ib_execute = &r600_ring_ib_execute,
619 .irq_set = &r600_irq_set,
620 .irq_process = &r600_irq_process,
621 .get_vblank_counter = &rs600_get_vblank_counter,
622 .fence_ring_emit = &r600_fence_ring_emit,
623 .cs_parse = &r600_cs_parse,
624 .copy_blit = &r600_copy_blit,
625 .copy_dma = &r600_copy_blit,
626 .copy = &r600_copy_blit,
627 .get_engine_clock = &radeon_atom_get_engine_clock,
628 .set_engine_clock = &radeon_atom_set_engine_clock,
629 .get_memory_clock = &radeon_atom_get_memory_clock,
630 .set_memory_clock = &radeon_atom_set_memory_clock,
631 .get_pcie_lanes = &rv370_get_pcie_lanes,
632 .set_pcie_lanes = NULL,
633 .set_clock_gating = NULL,
634 .set_surface_reg = r600_set_surface_reg,
635 .clear_surface_reg = r600_clear_surface_reg,
636 .bandwidth_update = &rv515_bandwidth_update,
637 .hpd_init = &r600_hpd_init,
638 .hpd_fini = &r600_hpd_fini,
639 .hpd_sense = &r600_hpd_sense,
640 .hpd_set_polarity = &r600_hpd_set_polarity,
641 .ioctl_wait_idle = r600_ioctl_wait_idle,
642};
643
644/* 272/*
645 * rv770,rv730,rv710,rv740 273 * rv770,rv730,rv710,rv740
646 */ 274 */
@@ -650,43 +278,6 @@ int rv770_suspend(struct radeon_device *rdev);
650int rv770_resume(struct radeon_device *rdev); 278int rv770_resume(struct radeon_device *rdev);
651int rv770_gpu_reset(struct radeon_device *rdev); 279int rv770_gpu_reset(struct radeon_device *rdev);
652 280
653static struct radeon_asic rv770_asic = {
654 .init = &rv770_init,
655 .fini = &rv770_fini,
656 .suspend = &rv770_suspend,
657 .resume = &rv770_resume,
658 .cp_commit = &r600_cp_commit,
659 .gpu_reset = &rv770_gpu_reset,
660 .vga_set_state = &r600_vga_set_state,
661 .gart_tlb_flush = &r600_pcie_gart_tlb_flush,
662 .gart_set_page = &rs600_gart_set_page,
663 .ring_test = &r600_ring_test,
664 .ring_ib_execute = &r600_ring_ib_execute,
665 .irq_set = &r600_irq_set,
666 .irq_process = &r600_irq_process,
667 .get_vblank_counter = &rs600_get_vblank_counter,
668 .fence_ring_emit = &r600_fence_ring_emit,
669 .cs_parse = &r600_cs_parse,
670 .copy_blit = &r600_copy_blit,
671 .copy_dma = &r600_copy_blit,
672 .copy = &r600_copy_blit,
673 .get_engine_clock = &radeon_atom_get_engine_clock,
674 .set_engine_clock = &radeon_atom_set_engine_clock,
675 .get_memory_clock = &radeon_atom_get_memory_clock,
676 .set_memory_clock = &radeon_atom_set_memory_clock,
677 .get_pcie_lanes = &rv370_get_pcie_lanes,
678 .set_pcie_lanes = NULL,
679 .set_clock_gating = &radeon_atom_set_clock_gating,
680 .set_surface_reg = r600_set_surface_reg,
681 .clear_surface_reg = r600_clear_surface_reg,
682 .bandwidth_update = &rv515_bandwidth_update,
683 .hpd_init = &r600_hpd_init,
684 .hpd_fini = &r600_hpd_fini,
685 .hpd_sense = &r600_hpd_sense,
686 .hpd_set_polarity = &r600_hpd_set_polarity,
687 .ioctl_wait_idle = r600_ioctl_wait_idle,
688};
689
690/* 281/*
691 * evergreen 282 * evergreen
692 */ 283 */
@@ -701,40 +292,4 @@ void evergreen_hpd_fini(struct radeon_device *rdev);
701bool evergreen_hpd_sense(struct radeon_device *rdev, enum radeon_hpd_id hpd); 292bool evergreen_hpd_sense(struct radeon_device *rdev, enum radeon_hpd_id hpd);
702void evergreen_hpd_set_polarity(struct radeon_device *rdev, 293void evergreen_hpd_set_polarity(struct radeon_device *rdev,
703 enum radeon_hpd_id hpd); 294 enum radeon_hpd_id hpd);
704
705static struct radeon_asic evergreen_asic = {
706 .init = &evergreen_init,
707 .fini = &evergreen_fini,
708 .suspend = &evergreen_suspend,
709 .resume = &evergreen_resume,
710 .cp_commit = NULL,
711 .gpu_reset = &evergreen_gpu_reset,
712 .vga_set_state = &r600_vga_set_state,
713 .gart_tlb_flush = &r600_pcie_gart_tlb_flush,
714 .gart_set_page = &rs600_gart_set_page,
715 .ring_test = NULL,
716 .ring_ib_execute = NULL,
717 .irq_set = NULL,
718 .irq_process = NULL,
719 .get_vblank_counter = NULL,
720 .fence_ring_emit = NULL,
721 .cs_parse = NULL,
722 .copy_blit = NULL,
723 .copy_dma = NULL,
724 .copy = NULL,
725 .get_engine_clock = &radeon_atom_get_engine_clock,
726 .set_engine_clock = &radeon_atom_set_engine_clock,
727 .get_memory_clock = &radeon_atom_get_memory_clock,
728 .set_memory_clock = &radeon_atom_set_memory_clock,
729 .set_pcie_lanes = NULL,
730 .set_clock_gating = NULL,
731 .set_surface_reg = r600_set_surface_reg,
732 .clear_surface_reg = r600_clear_surface_reg,
733 .bandwidth_update = &evergreen_bandwidth_update,
734 .hpd_init = &evergreen_hpd_init,
735 .hpd_fini = &evergreen_hpd_fini,
736 .hpd_sense = &evergreen_hpd_sense,
737 .hpd_set_polarity = &evergreen_hpd_set_polarity,
738};
739
740#endif 295#endif
diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c
index 93783b15c81..9916d825401 100644
--- a/drivers/gpu/drm/radeon/radeon_atombios.c
+++ b/drivers/gpu/drm/radeon/radeon_atombios.c
@@ -69,52 +69,54 @@ static inline struct radeon_i2c_bus_rec radeon_lookup_i2c_gpio(struct radeon_dev
69 struct radeon_i2c_bus_rec i2c; 69 struct radeon_i2c_bus_rec i2c;
70 int index = GetIndexIntoMasterTable(DATA, GPIO_I2C_Info); 70 int index = GetIndexIntoMasterTable(DATA, GPIO_I2C_Info);
71 struct _ATOM_GPIO_I2C_INFO *i2c_info; 71 struct _ATOM_GPIO_I2C_INFO *i2c_info;
72 uint16_t data_offset; 72 uint16_t data_offset, size;
73 int i; 73 int i, num_indices;
74 74
75 memset(&i2c, 0, sizeof(struct radeon_i2c_bus_rec)); 75 memset(&i2c, 0, sizeof(struct radeon_i2c_bus_rec));
76 i2c.valid = false; 76 i2c.valid = false;
77 77
78 atom_parse_data_header(ctx, index, NULL, NULL, NULL, &data_offset); 78 if (atom_parse_data_header(ctx, index, &size, NULL, NULL, &data_offset)) {
79 79 i2c_info = (struct _ATOM_GPIO_I2C_INFO *)(ctx->bios + data_offset);
80 i2c_info = (struct _ATOM_GPIO_I2C_INFO *)(ctx->bios + data_offset); 80
81 81 num_indices = (size - sizeof(ATOM_COMMON_TABLE_HEADER)) /
82 82 sizeof(ATOM_GPIO_I2C_ASSIGMENT);
83 for (i = 0; i < ATOM_MAX_SUPPORTED_DEVICE; i++) { 83
84 gpio = &i2c_info->asGPIO_Info[i]; 84 for (i = 0; i < num_indices; i++) {
85 85 gpio = &i2c_info->asGPIO_Info[i];
86 if (gpio->sucI2cId.ucAccess == id) { 86
87 i2c.mask_clk_reg = le16_to_cpu(gpio->usClkMaskRegisterIndex) * 4; 87 if (gpio->sucI2cId.ucAccess == id) {
88 i2c.mask_data_reg = le16_to_cpu(gpio->usDataMaskRegisterIndex) * 4; 88 i2c.mask_clk_reg = le16_to_cpu(gpio->usClkMaskRegisterIndex) * 4;
89 i2c.en_clk_reg = le16_to_cpu(gpio->usClkEnRegisterIndex) * 4; 89 i2c.mask_data_reg = le16_to_cpu(gpio->usDataMaskRegisterIndex) * 4;
90 i2c.en_data_reg = le16_to_cpu(gpio->usDataEnRegisterIndex) * 4; 90 i2c.en_clk_reg = le16_to_cpu(gpio->usClkEnRegisterIndex) * 4;
91 i2c.y_clk_reg = le16_to_cpu(gpio->usClkY_RegisterIndex) * 4; 91 i2c.en_data_reg = le16_to_cpu(gpio->usDataEnRegisterIndex) * 4;
92 i2c.y_data_reg = le16_to_cpu(gpio->usDataY_RegisterIndex) * 4; 92 i2c.y_clk_reg = le16_to_cpu(gpio->usClkY_RegisterIndex) * 4;
93 i2c.a_clk_reg = le16_to_cpu(gpio->usClkA_RegisterIndex) * 4; 93 i2c.y_data_reg = le16_to_cpu(gpio->usDataY_RegisterIndex) * 4;
94 i2c.a_data_reg = le16_to_cpu(gpio->usDataA_RegisterIndex) * 4; 94 i2c.a_clk_reg = le16_to_cpu(gpio->usClkA_RegisterIndex) * 4;
95 i2c.mask_clk_mask = (1 << gpio->ucClkMaskShift); 95 i2c.a_data_reg = le16_to_cpu(gpio->usDataA_RegisterIndex) * 4;
96 i2c.mask_data_mask = (1 << gpio->ucDataMaskShift); 96 i2c.mask_clk_mask = (1 << gpio->ucClkMaskShift);
97 i2c.en_clk_mask = (1 << gpio->ucClkEnShift); 97 i2c.mask_data_mask = (1 << gpio->ucDataMaskShift);
98 i2c.en_data_mask = (1 << gpio->ucDataEnShift); 98 i2c.en_clk_mask = (1 << gpio->ucClkEnShift);
99 i2c.y_clk_mask = (1 << gpio->ucClkY_Shift); 99 i2c.en_data_mask = (1 << gpio->ucDataEnShift);
100 i2c.y_data_mask = (1 << gpio->ucDataY_Shift); 100 i2c.y_clk_mask = (1 << gpio->ucClkY_Shift);
101 i2c.a_clk_mask = (1 << gpio->ucClkA_Shift); 101 i2c.y_data_mask = (1 << gpio->ucDataY_Shift);
102 i2c.a_data_mask = (1 << gpio->ucDataA_Shift); 102 i2c.a_clk_mask = (1 << gpio->ucClkA_Shift);
103 103 i2c.a_data_mask = (1 << gpio->ucDataA_Shift);
104 if (gpio->sucI2cId.sbfAccess.bfHW_Capable) 104
105 i2c.hw_capable = true; 105 if (gpio->sucI2cId.sbfAccess.bfHW_Capable)
106 else 106 i2c.hw_capable = true;
107 i2c.hw_capable = false; 107 else
108 108 i2c.hw_capable = false;
109 if (gpio->sucI2cId.ucAccess == 0xa0) 109
110 i2c.mm_i2c = true; 110 if (gpio->sucI2cId.ucAccess == 0xa0)
111 else 111 i2c.mm_i2c = true;
112 i2c.mm_i2c = false; 112 else
113 113 i2c.mm_i2c = false;
114 i2c.i2c_id = gpio->sucI2cId.ucAccess; 114
115 115 i2c.i2c_id = gpio->sucI2cId.ucAccess;
116 i2c.valid = true; 116
117 break; 117 i2c.valid = true;
118 break;
119 }
118 } 120 }
119 } 121 }
120 122
@@ -135,20 +137,21 @@ static inline struct radeon_gpio_rec radeon_lookup_gpio(struct radeon_device *rd
135 memset(&gpio, 0, sizeof(struct radeon_gpio_rec)); 137 memset(&gpio, 0, sizeof(struct radeon_gpio_rec));
136 gpio.valid = false; 138 gpio.valid = false;
137 139
138 atom_parse_data_header(ctx, index, &size, NULL, NULL, &data_offset); 140 if (atom_parse_data_header(ctx, index, &size, NULL, NULL, &data_offset)) {
141 gpio_info = (struct _ATOM_GPIO_PIN_LUT *)(ctx->bios + data_offset);
139 142
140 gpio_info = (struct _ATOM_GPIO_PIN_LUT *)(ctx->bios + data_offset); 143 num_indices = (size - sizeof(ATOM_COMMON_TABLE_HEADER)) /
144 sizeof(ATOM_GPIO_PIN_ASSIGNMENT);
141 145
142 num_indices = (size - sizeof(ATOM_COMMON_TABLE_HEADER)) / sizeof(ATOM_GPIO_PIN_ASSIGNMENT); 146 for (i = 0; i < num_indices; i++) {
143 147 pin = &gpio_info->asGPIO_Pin[i];
144 for (i = 0; i < num_indices; i++) { 148 if (id == pin->ucGPIO_ID) {
145 pin = &gpio_info->asGPIO_Pin[i]; 149 gpio.id = pin->ucGPIO_ID;
146 if (id == pin->ucGPIO_ID) { 150 gpio.reg = pin->usGpioPin_AIndex * 4;
147 gpio.id = pin->ucGPIO_ID; 151 gpio.mask = (1 << pin->ucGpioPinBitShift);
148 gpio.reg = pin->usGpioPin_AIndex * 4; 152 gpio.valid = true;
149 gpio.mask = (1 << pin->ucGpioPinBitShift); 153 break;
150 gpio.valid = true; 154 }
151 break;
152 } 155 }
153 } 156 }
154 157
@@ -264,6 +267,8 @@ static bool radeon_atom_apply_quirks(struct drm_device *dev,
264 if ((supported_device == ATOM_DEVICE_CRT1_SUPPORT) || 267 if ((supported_device == ATOM_DEVICE_CRT1_SUPPORT) ||
265 (supported_device == ATOM_DEVICE_DFP2_SUPPORT)) 268 (supported_device == ATOM_DEVICE_DFP2_SUPPORT))
266 return false; 269 return false;
270 if (supported_device == ATOM_DEVICE_CRT2_SUPPORT)
271 *line_mux = 0x90;
267 } 272 }
268 273
269 /* ASUS HD 3600 XT board lists the DVI port as HDMI */ 274 /* ASUS HD 3600 XT board lists the DVI port as HDMI */
@@ -395,9 +400,7 @@ bool radeon_get_atom_connector_info_from_object_table(struct drm_device *dev)
395 struct radeon_gpio_rec gpio; 400 struct radeon_gpio_rec gpio;
396 struct radeon_hpd hpd; 401 struct radeon_hpd hpd;
397 402
398 atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset); 403 if (!atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset))
399
400 if (data_offset == 0)
401 return false; 404 return false;
402 405
403 if (crev < 2) 406 if (crev < 2)
@@ -449,37 +452,43 @@ bool radeon_get_atom_connector_info_from_object_table(struct drm_device *dev)
449 GetIndexIntoMasterTable(DATA, 452 GetIndexIntoMasterTable(DATA,
450 IntegratedSystemInfo); 453 IntegratedSystemInfo);
451 454
452 atom_parse_data_header(ctx, index, &size, &frev, 455 if (atom_parse_data_header(ctx, index, &size, &frev,
453 &crev, &igp_offset); 456 &crev, &igp_offset)) {
454 457
455 if (crev >= 2) { 458 if (crev >= 2) {
456 igp_obj = 459 igp_obj =
457 (ATOM_INTEGRATED_SYSTEM_INFO_V2 460 (ATOM_INTEGRATED_SYSTEM_INFO_V2
458 *) (ctx->bios + igp_offset); 461 *) (ctx->bios + igp_offset);
459 462
460 if (igp_obj) { 463 if (igp_obj) {
461 uint32_t slot_config, ct; 464 uint32_t slot_config, ct;
462 465
463 if (con_obj_num == 1) 466 if (con_obj_num == 1)
464 slot_config = 467 slot_config =
465 igp_obj-> 468 igp_obj->
466 ulDDISlot1Config; 469 ulDDISlot1Config;
467 else 470 else
468 slot_config = 471 slot_config =
469 igp_obj-> 472 igp_obj->
470 ulDDISlot2Config; 473 ulDDISlot2Config;
471 474
472 ct = (slot_config >> 16) & 0xff; 475 ct = (slot_config >> 16) & 0xff;
473 connector_type = 476 connector_type =
474 object_connector_convert 477 object_connector_convert
475 [ct]; 478 [ct];
476 connector_object_id = ct; 479 connector_object_id = ct;
477 igp_lane_info = 480 igp_lane_info =
478 slot_config & 0xffff; 481 slot_config & 0xffff;
482 } else
483 continue;
479 } else 484 } else
480 continue; 485 continue;
481 } else 486 } else {
482 continue; 487 igp_lane_info = 0;
488 connector_type =
489 object_connector_convert[con_obj_id];
490 connector_object_id = con_obj_id;
491 }
483 } else { 492 } else {
484 igp_lane_info = 0; 493 igp_lane_info = 0;
485 connector_type = 494 connector_type =
@@ -627,20 +636,23 @@ static uint16_t atombios_get_connector_object_id(struct drm_device *dev,
627 uint8_t frev, crev; 636 uint8_t frev, crev;
628 ATOM_XTMDS_INFO *xtmds; 637 ATOM_XTMDS_INFO *xtmds;
629 638
630 atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset); 639 if (atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset)) {
631 xtmds = (ATOM_XTMDS_INFO *)(ctx->bios + data_offset); 640 xtmds = (ATOM_XTMDS_INFO *)(ctx->bios + data_offset);
632 641
633 if (xtmds->ucSupportedLink & ATOM_XTMDS_SUPPORTED_DUALLINK) { 642 if (xtmds->ucSupportedLink & ATOM_XTMDS_SUPPORTED_DUALLINK) {
634 if (connector_type == DRM_MODE_CONNECTOR_DVII) 643 if (connector_type == DRM_MODE_CONNECTOR_DVII)
635 return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I; 644 return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I;
636 else 645 else
637 return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D; 646 return CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D;
638 } else { 647 } else {
639 if (connector_type == DRM_MODE_CONNECTOR_DVII) 648 if (connector_type == DRM_MODE_CONNECTOR_DVII)
640 return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I; 649 return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I;
641 else 650 else
642 return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D; 651 return CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D;
643 } 652 }
653 } else
654 return supported_devices_connector_object_id_convert
655 [connector_type];
644 } else { 656 } else {
645 return supported_devices_connector_object_id_convert 657 return supported_devices_connector_object_id_convert
646 [connector_type]; 658 [connector_type];
@@ -672,7 +684,8 @@ bool radeon_get_atom_connector_info_from_supported_devices_table(struct
672 int i, j, max_device; 684 int i, j, max_device;
673 struct bios_connector bios_connectors[ATOM_MAX_SUPPORTED_DEVICE]; 685 struct bios_connector bios_connectors[ATOM_MAX_SUPPORTED_DEVICE];
674 686
675 atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset); 687 if (!atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset))
688 return false;
676 689
677 supported_devices = 690 supported_devices =
678 (union atom_supported_devices *)(ctx->bios + data_offset); 691 (union atom_supported_devices *)(ctx->bios + data_offset);
@@ -865,14 +878,11 @@ bool radeon_atom_get_clock_info(struct drm_device *dev)
865 struct radeon_pll *mpll = &rdev->clock.mpll; 878 struct radeon_pll *mpll = &rdev->clock.mpll;
866 uint16_t data_offset; 879 uint16_t data_offset;
867 880
868 atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, 881 if (atom_parse_data_header(mode_info->atom_context, index, NULL,
869 &crev, &data_offset); 882 &frev, &crev, &data_offset)) {
870 883 firmware_info =
871 firmware_info = 884 (union firmware_info *)(mode_info->atom_context->bios +
872 (union firmware_info *)(mode_info->atom_context->bios + 885 data_offset);
873 data_offset);
874
875 if (firmware_info) {
876 /* pixel clocks */ 886 /* pixel clocks */
877 p1pll->reference_freq = 887 p1pll->reference_freq =
878 le16_to_cpu(firmware_info->info.usReferenceClock); 888 le16_to_cpu(firmware_info->info.usReferenceClock);
@@ -887,6 +897,20 @@ bool radeon_atom_get_clock_info(struct drm_device *dev)
887 p1pll->pll_out_max = 897 p1pll->pll_out_max =
888 le32_to_cpu(firmware_info->info.ulMaxPixelClockPLL_Output); 898 le32_to_cpu(firmware_info->info.ulMaxPixelClockPLL_Output);
889 899
900 if (crev >= 4) {
901 p1pll->lcd_pll_out_min =
902 le16_to_cpu(firmware_info->info_14.usLcdMinPixelClockPLL_Output) * 100;
903 if (p1pll->lcd_pll_out_min == 0)
904 p1pll->lcd_pll_out_min = p1pll->pll_out_min;
905 p1pll->lcd_pll_out_max =
906 le16_to_cpu(firmware_info->info_14.usLcdMaxPixelClockPLL_Output) * 100;
907 if (p1pll->lcd_pll_out_max == 0)
908 p1pll->lcd_pll_out_max = p1pll->pll_out_max;
909 } else {
910 p1pll->lcd_pll_out_min = p1pll->pll_out_min;
911 p1pll->lcd_pll_out_max = p1pll->pll_out_max;
912 }
913
890 if (p1pll->pll_out_min == 0) { 914 if (p1pll->pll_out_min == 0) {
891 if (ASIC_IS_AVIVO(rdev)) 915 if (ASIC_IS_AVIVO(rdev))
892 p1pll->pll_out_min = 64800; 916 p1pll->pll_out_min = 64800;
@@ -992,13 +1016,10 @@ bool radeon_atombios_sideport_present(struct radeon_device *rdev)
992 u8 frev, crev; 1016 u8 frev, crev;
993 u16 data_offset; 1017 u16 data_offset;
994 1018
995 atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, 1019 if (atom_parse_data_header(mode_info->atom_context, index, NULL,
996 &crev, &data_offset); 1020 &frev, &crev, &data_offset)) {
997 1021 igp_info = (union igp_info *)(mode_info->atom_context->bios +
998 igp_info = (union igp_info *)(mode_info->atom_context->bios +
999 data_offset); 1022 data_offset);
1000
1001 if (igp_info) {
1002 switch (crev) { 1023 switch (crev) {
1003 case 1: 1024 case 1:
1004 if (igp_info->info.ucMemoryType & 0xf0) 1025 if (igp_info->info.ucMemoryType & 0xf0)
@@ -1029,14 +1050,12 @@ bool radeon_atombios_get_tmds_info(struct radeon_encoder *encoder,
1029 uint16_t maxfreq; 1050 uint16_t maxfreq;
1030 int i; 1051 int i;
1031 1052
1032 atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, 1053 if (atom_parse_data_header(mode_info->atom_context, index, NULL,
1033 &crev, &data_offset); 1054 &frev, &crev, &data_offset)) {
1055 tmds_info =
1056 (struct _ATOM_TMDS_INFO *)(mode_info->atom_context->bios +
1057 data_offset);
1034 1058
1035 tmds_info =
1036 (struct _ATOM_TMDS_INFO *)(mode_info->atom_context->bios +
1037 data_offset);
1038
1039 if (tmds_info) {
1040 maxfreq = le16_to_cpu(tmds_info->usMaxFrequency); 1059 maxfreq = le16_to_cpu(tmds_info->usMaxFrequency);
1041 for (i = 0; i < 4; i++) { 1060 for (i = 0; i < 4; i++) {
1042 tmds->tmds_pll[i].freq = 1061 tmds->tmds_pll[i].freq =
@@ -1085,13 +1104,11 @@ static struct radeon_atom_ss *radeon_atombios_get_ss_info(struct
1085 if (id > ATOM_MAX_SS_ENTRY) 1104 if (id > ATOM_MAX_SS_ENTRY)
1086 return NULL; 1105 return NULL;
1087 1106
1088 atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, 1107 if (atom_parse_data_header(mode_info->atom_context, index, NULL,
1089 &crev, &data_offset); 1108 &frev, &crev, &data_offset)) {
1090 1109 ss_info =
1091 ss_info = 1110 (struct _ATOM_SPREAD_SPECTRUM_INFO *)(mode_info->atom_context->bios + data_offset);
1092 (struct _ATOM_SPREAD_SPECTRUM_INFO *)(mode_info->atom_context->bios + data_offset);
1093 1111
1094 if (ss_info) {
1095 ss = 1112 ss =
1096 kzalloc(sizeof(struct radeon_atom_ss), GFP_KERNEL); 1113 kzalloc(sizeof(struct radeon_atom_ss), GFP_KERNEL);
1097 1114
@@ -1114,30 +1131,6 @@ static struct radeon_atom_ss *radeon_atombios_get_ss_info(struct
1114 return ss; 1131 return ss;
1115} 1132}
1116 1133
1117static void radeon_atom_apply_lvds_quirks(struct drm_device *dev,
1118 struct radeon_encoder_atom_dig *lvds)
1119{
1120
1121 /* Toshiba A300-1BU laptop panel doesn't like new pll divider algo */
1122 if ((dev->pdev->device == 0x95c4) &&
1123 (dev->pdev->subsystem_vendor == 0x1179) &&
1124 (dev->pdev->subsystem_device == 0xff50)) {
1125 if ((lvds->native_mode.hdisplay == 1280) &&
1126 (lvds->native_mode.vdisplay == 800))
1127 lvds->pll_algo = PLL_ALGO_LEGACY;
1128 }
1129
1130 /* Dell Studio 15 laptop panel doesn't like new pll divider algo */
1131 if ((dev->pdev->device == 0x95c4) &&
1132 (dev->pdev->subsystem_vendor == 0x1028) &&
1133 (dev->pdev->subsystem_device == 0x029f)) {
1134 if ((lvds->native_mode.hdisplay == 1280) &&
1135 (lvds->native_mode.vdisplay == 800))
1136 lvds->pll_algo = PLL_ALGO_LEGACY;
1137 }
1138
1139}
1140
1141union lvds_info { 1134union lvds_info {
1142 struct _ATOM_LVDS_INFO info; 1135 struct _ATOM_LVDS_INFO info;
1143 struct _ATOM_LVDS_INFO_V12 info_12; 1136 struct _ATOM_LVDS_INFO_V12 info_12;
@@ -1156,13 +1149,10 @@ struct radeon_encoder_atom_dig *radeon_atombios_get_lvds_info(struct
1156 uint8_t frev, crev; 1149 uint8_t frev, crev;
1157 struct radeon_encoder_atom_dig *lvds = NULL; 1150 struct radeon_encoder_atom_dig *lvds = NULL;
1158 1151
1159 atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, 1152 if (atom_parse_data_header(mode_info->atom_context, index, NULL,
1160 &crev, &data_offset); 1153 &frev, &crev, &data_offset)) {
1161 1154 lvds_info =
1162 lvds_info = 1155 (union lvds_info *)(mode_info->atom_context->bios + data_offset);
1163 (union lvds_info *)(mode_info->atom_context->bios + data_offset);
1164
1165 if (lvds_info) {
1166 lvds = 1156 lvds =
1167 kzalloc(sizeof(struct radeon_encoder_atom_dig), GFP_KERNEL); 1157 kzalloc(sizeof(struct radeon_encoder_atom_dig), GFP_KERNEL);
1168 1158
@@ -1220,9 +1210,6 @@ struct radeon_encoder_atom_dig *radeon_atombios_get_lvds_info(struct
1220 lvds->pll_algo = PLL_ALGO_LEGACY; 1210 lvds->pll_algo = PLL_ALGO_LEGACY;
1221 } 1211 }
1222 1212
1223 /* LVDS quirks */
1224 radeon_atom_apply_lvds_quirks(dev, lvds);
1225
1226 encoder->native_mode = lvds->native_mode; 1213 encoder->native_mode = lvds->native_mode;
1227 } 1214 }
1228 return lvds; 1215 return lvds;
@@ -1241,11 +1228,11 @@ radeon_atombios_get_primary_dac_info(struct radeon_encoder *encoder)
1241 uint8_t bg, dac; 1228 uint8_t bg, dac;
1242 struct radeon_encoder_primary_dac *p_dac = NULL; 1229 struct radeon_encoder_primary_dac *p_dac = NULL;
1243 1230
1244 atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, &crev, &data_offset); 1231 if (atom_parse_data_header(mode_info->atom_context, index, NULL,
1245 1232 &frev, &crev, &data_offset)) {
1246 dac_info = (struct _COMPASSIONATE_DATA *)(mode_info->atom_context->bios + data_offset); 1233 dac_info = (struct _COMPASSIONATE_DATA *)
1234 (mode_info->atom_context->bios + data_offset);
1247 1235
1248 if (dac_info) {
1249 p_dac = kzalloc(sizeof(struct radeon_encoder_primary_dac), GFP_KERNEL); 1236 p_dac = kzalloc(sizeof(struct radeon_encoder_primary_dac), GFP_KERNEL);
1250 1237
1251 if (!p_dac) 1238 if (!p_dac)
@@ -1270,12 +1257,14 @@ bool radeon_atom_get_tv_timings(struct radeon_device *rdev, int index,
1270 u8 frev, crev; 1257 u8 frev, crev;
1271 u16 data_offset, misc; 1258 u16 data_offset, misc;
1272 1259
1273 atom_parse_data_header(mode_info->atom_context, data_index, NULL, &frev, &crev, &data_offset); 1260 if (!atom_parse_data_header(mode_info->atom_context, data_index, NULL,
1261 &frev, &crev, &data_offset))
1262 return false;
1274 1263
1275 switch (crev) { 1264 switch (crev) {
1276 case 1: 1265 case 1:
1277 tv_info = (ATOM_ANALOG_TV_INFO *)(mode_info->atom_context->bios + data_offset); 1266 tv_info = (ATOM_ANALOG_TV_INFO *)(mode_info->atom_context->bios + data_offset);
1278 if (index > MAX_SUPPORTED_TV_TIMING) 1267 if (index >= MAX_SUPPORTED_TV_TIMING)
1279 return false; 1268 return false;
1280 1269
1281 mode->crtc_htotal = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_Total); 1270 mode->crtc_htotal = le16_to_cpu(tv_info->aModeTimings[index].usCRTC_H_Total);
@@ -1313,7 +1302,7 @@ bool radeon_atom_get_tv_timings(struct radeon_device *rdev, int index,
1313 break; 1302 break;
1314 case 2: 1303 case 2:
1315 tv_info_v1_2 = (ATOM_ANALOG_TV_INFO_V1_2 *)(mode_info->atom_context->bios + data_offset); 1304 tv_info_v1_2 = (ATOM_ANALOG_TV_INFO_V1_2 *)(mode_info->atom_context->bios + data_offset);
1316 if (index > MAX_SUPPORTED_TV_TIMING_V1_2) 1305 if (index >= MAX_SUPPORTED_TV_TIMING_V1_2)
1317 return false; 1306 return false;
1318 1307
1319 dtd_timings = &tv_info_v1_2->aModeTimings[index]; 1308 dtd_timings = &tv_info_v1_2->aModeTimings[index];
@@ -1362,47 +1351,50 @@ radeon_atombios_get_tv_info(struct radeon_device *rdev)
1362 struct _ATOM_ANALOG_TV_INFO *tv_info; 1351 struct _ATOM_ANALOG_TV_INFO *tv_info;
1363 enum radeon_tv_std tv_std = TV_STD_NTSC; 1352 enum radeon_tv_std tv_std = TV_STD_NTSC;
1364 1353
1365 atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, &crev, &data_offset); 1354 if (atom_parse_data_header(mode_info->atom_context, index, NULL,
1355 &frev, &crev, &data_offset)) {
1366 1356
1367 tv_info = (struct _ATOM_ANALOG_TV_INFO *)(mode_info->atom_context->bios + data_offset); 1357 tv_info = (struct _ATOM_ANALOG_TV_INFO *)
1358 (mode_info->atom_context->bios + data_offset);
1368 1359
1369 switch (tv_info->ucTV_BootUpDefaultStandard) { 1360 switch (tv_info->ucTV_BootUpDefaultStandard) {
1370 case ATOM_TV_NTSC: 1361 case ATOM_TV_NTSC:
1371 tv_std = TV_STD_NTSC; 1362 tv_std = TV_STD_NTSC;
1372 DRM_INFO("Default TV standard: NTSC\n"); 1363 DRM_INFO("Default TV standard: NTSC\n");
1373 break; 1364 break;
1374 case ATOM_TV_NTSCJ: 1365 case ATOM_TV_NTSCJ:
1375 tv_std = TV_STD_NTSC_J; 1366 tv_std = TV_STD_NTSC_J;
1376 DRM_INFO("Default TV standard: NTSC-J\n"); 1367 DRM_INFO("Default TV standard: NTSC-J\n");
1377 break; 1368 break;
1378 case ATOM_TV_PAL: 1369 case ATOM_TV_PAL:
1379 tv_std = TV_STD_PAL; 1370 tv_std = TV_STD_PAL;
1380 DRM_INFO("Default TV standard: PAL\n"); 1371 DRM_INFO("Default TV standard: PAL\n");
1381 break; 1372 break;
1382 case ATOM_TV_PALM: 1373 case ATOM_TV_PALM:
1383 tv_std = TV_STD_PAL_M; 1374 tv_std = TV_STD_PAL_M;
1384 DRM_INFO("Default TV standard: PAL-M\n"); 1375 DRM_INFO("Default TV standard: PAL-M\n");
1385 break; 1376 break;
1386 case ATOM_TV_PALN: 1377 case ATOM_TV_PALN:
1387 tv_std = TV_STD_PAL_N; 1378 tv_std = TV_STD_PAL_N;
1388 DRM_INFO("Default TV standard: PAL-N\n"); 1379 DRM_INFO("Default TV standard: PAL-N\n");
1389 break; 1380 break;
1390 case ATOM_TV_PALCN: 1381 case ATOM_TV_PALCN:
1391 tv_std = TV_STD_PAL_CN; 1382 tv_std = TV_STD_PAL_CN;
1392 DRM_INFO("Default TV standard: PAL-CN\n"); 1383 DRM_INFO("Default TV standard: PAL-CN\n");
1393 break; 1384 break;
1394 case ATOM_TV_PAL60: 1385 case ATOM_TV_PAL60:
1395 tv_std = TV_STD_PAL_60; 1386 tv_std = TV_STD_PAL_60;
1396 DRM_INFO("Default TV standard: PAL-60\n"); 1387 DRM_INFO("Default TV standard: PAL-60\n");
1397 break; 1388 break;
1398 case ATOM_TV_SECAM: 1389 case ATOM_TV_SECAM:
1399 tv_std = TV_STD_SECAM; 1390 tv_std = TV_STD_SECAM;
1400 DRM_INFO("Default TV standard: SECAM\n"); 1391 DRM_INFO("Default TV standard: SECAM\n");
1401 break; 1392 break;
1402 default: 1393 default:
1403 tv_std = TV_STD_NTSC; 1394 tv_std = TV_STD_NTSC;
1404 DRM_INFO("Unknown TV standard; defaulting to NTSC\n"); 1395 DRM_INFO("Unknown TV standard; defaulting to NTSC\n");
1405 break; 1396 break;
1397 }
1406 } 1398 }
1407 return tv_std; 1399 return tv_std;
1408} 1400}
@@ -1420,11 +1412,12 @@ radeon_atombios_get_tv_dac_info(struct radeon_encoder *encoder)
1420 uint8_t bg, dac; 1412 uint8_t bg, dac;
1421 struct radeon_encoder_tv_dac *tv_dac = NULL; 1413 struct radeon_encoder_tv_dac *tv_dac = NULL;
1422 1414
1423 atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, &crev, &data_offset); 1415 if (atom_parse_data_header(mode_info->atom_context, index, NULL,
1416 &frev, &crev, &data_offset)) {
1424 1417
1425 dac_info = (struct _COMPASSIONATE_DATA *)(mode_info->atom_context->bios + data_offset); 1418 dac_info = (struct _COMPASSIONATE_DATA *)
1419 (mode_info->atom_context->bios + data_offset);
1426 1420
1427 if (dac_info) {
1428 tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL); 1421 tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL);
1429 1422
1430 if (!tv_dac) 1423 if (!tv_dac)
@@ -1447,6 +1440,30 @@ radeon_atombios_get_tv_dac_info(struct radeon_encoder *encoder)
1447 return tv_dac; 1440 return tv_dac;
1448} 1441}
1449 1442
1443static const char *thermal_controller_names[] = {
1444 "NONE",
1445 "LM63",
1446 "ADM1032",
1447 "ADM1030",
1448 "MUA6649",
1449 "LM64",
1450 "F75375",
1451 "ASC7512",
1452};
1453
1454static const char *pp_lib_thermal_controller_names[] = {
1455 "NONE",
1456 "LM63",
1457 "ADM1032",
1458 "ADM1030",
1459 "MUA6649",
1460 "LM64",
1461 "F75375",
1462 "RV6xx",
1463 "RV770",
1464 "ADT7473",
1465};
1466
1450union power_info { 1467union power_info {
1451 struct _ATOM_POWERPLAY_INFO info; 1468 struct _ATOM_POWERPLAY_INFO info;
1452 struct _ATOM_POWERPLAY_INFO_V2 info_2; 1469 struct _ATOM_POWERPLAY_INFO_V2 info_2;
@@ -1466,15 +1483,22 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev)
1466 struct _ATOM_PPLIB_STATE *power_state; 1483 struct _ATOM_PPLIB_STATE *power_state;
1467 int num_modes = 0, i, j; 1484 int num_modes = 0, i, j;
1468 int state_index = 0, mode_index = 0; 1485 int state_index = 0, mode_index = 0;
1469 1486 struct radeon_i2c_bus_rec i2c_bus;
1470 atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, &crev, &data_offset);
1471
1472 power_info = (union power_info *)(mode_info->atom_context->bios + data_offset);
1473 1487
1474 rdev->pm.default_power_state = NULL; 1488 rdev->pm.default_power_state = NULL;
1475 1489
1476 if (power_info) { 1490 if (atom_parse_data_header(mode_info->atom_context, index, NULL,
1491 &frev, &crev, &data_offset)) {
1492 power_info = (union power_info *)(mode_info->atom_context->bios + data_offset);
1477 if (frev < 4) { 1493 if (frev < 4) {
1494 /* add the i2c bus for thermal/fan chip */
1495 if (power_info->info.ucOverdriveThermalController > 0) {
1496 DRM_INFO("Possible %s thermal controller at 0x%02x\n",
1497 thermal_controller_names[power_info->info.ucOverdriveThermalController],
1498 power_info->info.ucOverdriveControllerAddress >> 1);
1499 i2c_bus = radeon_lookup_i2c_gpio(rdev, power_info->info.ucOverdriveI2cLine);
1500 rdev->pm.i2c_bus = radeon_i2c_create(rdev->ddev, &i2c_bus, "Thermal");
1501 }
1478 num_modes = power_info->info.ucNumOfPowerModeEntries; 1502 num_modes = power_info->info.ucNumOfPowerModeEntries;
1479 if (num_modes > ATOM_MAX_NUMBEROF_POWER_BLOCK) 1503 if (num_modes > ATOM_MAX_NUMBEROF_POWER_BLOCK)
1480 num_modes = ATOM_MAX_NUMBEROF_POWER_BLOCK; 1504 num_modes = ATOM_MAX_NUMBEROF_POWER_BLOCK;
@@ -1684,6 +1708,24 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev)
1684 } 1708 }
1685 } 1709 }
1686 } else if (frev == 4) { 1710 } else if (frev == 4) {
1711 /* add the i2c bus for thermal/fan chip */
1712 /* no support for internal controller yet */
1713 if (power_info->info_4.sThermalController.ucType > 0) {
1714 if ((power_info->info_4.sThermalController.ucType == ATOM_PP_THERMALCONTROLLER_RV6xx) ||
1715 (power_info->info_4.sThermalController.ucType == ATOM_PP_THERMALCONTROLLER_RV770)) {
1716 DRM_INFO("Internal thermal controller %s fan control\n",
1717 (power_info->info_4.sThermalController.ucFanParameters &
1718 ATOM_PP_FANPARAMETERS_NOFAN) ? "without" : "with");
1719 } else {
1720 DRM_INFO("Possible %s thermal controller at 0x%02x %s fan control\n",
1721 pp_lib_thermal_controller_names[power_info->info_4.sThermalController.ucType],
1722 power_info->info_4.sThermalController.ucI2cAddress >> 1,
1723 (power_info->info_4.sThermalController.ucFanParameters &
1724 ATOM_PP_FANPARAMETERS_NOFAN) ? "without" : "with");
1725 i2c_bus = radeon_lookup_i2c_gpio(rdev, power_info->info_4.sThermalController.ucI2cLine);
1726 rdev->pm.i2c_bus = radeon_i2c_create(rdev->ddev, &i2c_bus, "Thermal");
1727 }
1728 }
1687 for (i = 0; i < power_info->info_4.ucNumStates; i++) { 1729 for (i = 0; i < power_info->info_4.ucNumStates; i++) {
1688 mode_index = 0; 1730 mode_index = 0;
1689 power_state = (struct _ATOM_PPLIB_STATE *) 1731 power_state = (struct _ATOM_PPLIB_STATE *)
diff --git a/drivers/gpu/drm/radeon/radeon_atpx_handler.c b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
index 3f557c4151e..ed5dfe58f29 100644
--- a/drivers/gpu/drm/radeon/radeon_atpx_handler.c
+++ b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
@@ -7,6 +7,7 @@
7 * ATPX support for both Intel/ATI 7 * ATPX support for both Intel/ATI
8 */ 8 */
9#include <linux/vga_switcheroo.h> 9#include <linux/vga_switcheroo.h>
10#include <linux/slab.h>
10#include <acpi/acpi.h> 11#include <acpi/acpi.h>
11#include <acpi/acpi_bus.h> 12#include <acpi/acpi_bus.h>
12#include <linux/pci.h> 13#include <linux/pci.h>
diff --git a/drivers/gpu/drm/radeon/radeon_bios.c b/drivers/gpu/drm/radeon/radeon_bios.c
index 55724046052..8ad71f70131 100644
--- a/drivers/gpu/drm/radeon/radeon_bios.c
+++ b/drivers/gpu/drm/radeon/radeon_bios.c
@@ -31,6 +31,7 @@
31#include "atom.h" 31#include "atom.h"
32 32
33#include <linux/vga_switcheroo.h> 33#include <linux/vga_switcheroo.h>
34#include <linux/slab.h>
34/* 35/*
35 * BIOS. 36 * BIOS.
36 */ 37 */
diff --git a/drivers/gpu/drm/radeon/radeon_combios.c b/drivers/gpu/drm/radeon/radeon_combios.c
index e9ea38ece37..37db8adb274 100644
--- a/drivers/gpu/drm/radeon/radeon_combios.c
+++ b/drivers/gpu/drm/radeon/radeon_combios.c
@@ -531,10 +531,7 @@ static struct radeon_i2c_bus_rec combios_setup_i2c_bus(struct radeon_device *rde
531 case CHIP_RS300: 531 case CHIP_RS300:
532 switch (ddc_line) { 532 switch (ddc_line) {
533 case RADEON_GPIO_DVI_DDC: 533 case RADEON_GPIO_DVI_DDC:
534 /* in theory this should be hw capable, 534 i2c.hw_capable = true;
535 * but it doesn't seem to work
536 */
537 i2c.hw_capable = false;
538 break; 535 break;
539 default: 536 default:
540 i2c.hw_capable = false; 537 i2c.hw_capable = false;
@@ -633,6 +630,8 @@ bool radeon_combios_get_clock_info(struct drm_device *dev)
633 p1pll->reference_div = RBIOS16(pll_info + 0x10); 630 p1pll->reference_div = RBIOS16(pll_info + 0x10);
634 p1pll->pll_out_min = RBIOS32(pll_info + 0x12); 631 p1pll->pll_out_min = RBIOS32(pll_info + 0x12);
635 p1pll->pll_out_max = RBIOS32(pll_info + 0x16); 632 p1pll->pll_out_max = RBIOS32(pll_info + 0x16);
633 p1pll->lcd_pll_out_min = p1pll->pll_out_min;
634 p1pll->lcd_pll_out_max = p1pll->pll_out_max;
636 635
637 if (rev > 9) { 636 if (rev > 9) {
638 p1pll->pll_in_min = RBIOS32(pll_info + 0x36); 637 p1pll->pll_in_min = RBIOS32(pll_info + 0x36);
@@ -761,7 +760,9 @@ struct radeon_encoder_primary_dac *radeon_combios_get_primary_dac_info(struct
761 dac = RBIOS8(dac_info + 0x3) & 0xf; 760 dac = RBIOS8(dac_info + 0x3) & 0xf;
762 p_dac->ps2_pdac_adj = (bg << 8) | (dac); 761 p_dac->ps2_pdac_adj = (bg << 8) | (dac);
763 } 762 }
764 found = 1; 763 /* if the values are all zeros, use the table */
764 if (p_dac->ps2_pdac_adj)
765 found = 1;
765 } 766 }
766 767
767 if (!found) /* fallback to defaults */ 768 if (!found) /* fallback to defaults */
@@ -896,7 +897,9 @@ struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct
896 bg = RBIOS8(dac_info + 0x10) & 0xf; 897 bg = RBIOS8(dac_info + 0x10) & 0xf;
897 dac = RBIOS8(dac_info + 0x11) & 0xf; 898 dac = RBIOS8(dac_info + 0x11) & 0xf;
898 tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); 899 tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20);
899 found = 1; 900 /* if the values are all zeros, use the table */
901 if (tv_dac->ps2_tvdac_adj)
902 found = 1;
900 } else if (rev > 1) { 903 } else if (rev > 1) {
901 bg = RBIOS8(dac_info + 0xc) & 0xf; 904 bg = RBIOS8(dac_info + 0xc) & 0xf;
902 dac = (RBIOS8(dac_info + 0xc) >> 4) & 0xf; 905 dac = (RBIOS8(dac_info + 0xc) >> 4) & 0xf;
@@ -909,7 +912,9 @@ struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct
909 bg = RBIOS8(dac_info + 0xe) & 0xf; 912 bg = RBIOS8(dac_info + 0xe) & 0xf;
910 dac = (RBIOS8(dac_info + 0xe) >> 4) & 0xf; 913 dac = (RBIOS8(dac_info + 0xe) >> 4) & 0xf;
911 tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); 914 tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20);
912 found = 1; 915 /* if the values are all zeros, use the table */
916 if (tv_dac->ps2_tvdac_adj)
917 found = 1;
913 } 918 }
914 tv_dac->tv_std = radeon_combios_get_tv_info(rdev); 919 tv_dac->tv_std = radeon_combios_get_tv_info(rdev);
915 } 920 }
@@ -926,7 +931,9 @@ struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct
926 (bg << 16) | (dac << 20); 931 (bg << 16) | (dac << 20);
927 tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 932 tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj;
928 tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 933 tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj;
929 found = 1; 934 /* if the values are all zeros, use the table */
935 if (tv_dac->ps2_tvdac_adj)
936 found = 1;
930 } else { 937 } else {
931 bg = RBIOS8(dac_info + 0x4) & 0xf; 938 bg = RBIOS8(dac_info + 0x4) & 0xf;
932 dac = RBIOS8(dac_info + 0x5) & 0xf; 939 dac = RBIOS8(dac_info + 0x5) & 0xf;
@@ -934,7 +941,9 @@ struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct
934 (bg << 16) | (dac << 20); 941 (bg << 16) | (dac << 20);
935 tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 942 tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj;
936 tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 943 tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj;
937 found = 1; 944 /* if the values are all zeros, use the table */
945 if (tv_dac->ps2_tvdac_adj)
946 found = 1;
938 } 947 }
939 } else { 948 } else {
940 DRM_INFO("No TV DAC info found in BIOS\n"); 949 DRM_INFO("No TV DAC info found in BIOS\n");
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
index ee0083f982d..4559a53d5e5 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -162,12 +162,14 @@ radeon_connector_analog_encoder_conflict_solve(struct drm_connector *connector,
162{ 162{
163 struct drm_device *dev = connector->dev; 163 struct drm_device *dev = connector->dev;
164 struct drm_connector *conflict; 164 struct drm_connector *conflict;
165 struct radeon_connector *radeon_conflict;
165 int i; 166 int i;
166 167
167 list_for_each_entry(conflict, &dev->mode_config.connector_list, head) { 168 list_for_each_entry(conflict, &dev->mode_config.connector_list, head) {
168 if (conflict == connector) 169 if (conflict == connector)
169 continue; 170 continue;
170 171
172 radeon_conflict = to_radeon_connector(conflict);
171 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { 173 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
172 if (conflict->encoder_ids[i] == 0) 174 if (conflict->encoder_ids[i] == 0)
173 break; 175 break;
@@ -177,6 +179,9 @@ radeon_connector_analog_encoder_conflict_solve(struct drm_connector *connector,
177 if (conflict->status != connector_status_connected) 179 if (conflict->status != connector_status_connected)
178 continue; 180 continue;
179 181
182 if (radeon_conflict->use_digital)
183 continue;
184
180 if (priority == true) { 185 if (priority == true) {
181 DRM_INFO("1: conflicting encoders switching off %s\n", drm_get_connector_name(conflict)); 186 DRM_INFO("1: conflicting encoders switching off %s\n", drm_get_connector_name(conflict));
182 DRM_INFO("in favor of %s\n", drm_get_connector_name(connector)); 187 DRM_INFO("in favor of %s\n", drm_get_connector_name(connector));
@@ -287,6 +292,7 @@ int radeon_connector_set_property(struct drm_connector *connector, struct drm_pr
287 292
288 if (property == rdev->mode_info.coherent_mode_property) { 293 if (property == rdev->mode_info.coherent_mode_property) {
289 struct radeon_encoder_atom_dig *dig; 294 struct radeon_encoder_atom_dig *dig;
295 bool new_coherent_mode;
290 296
291 /* need to find digital encoder on connector */ 297 /* need to find digital encoder on connector */
292 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS); 298 encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
@@ -299,8 +305,11 @@ int radeon_connector_set_property(struct drm_connector *connector, struct drm_pr
299 return 0; 305 return 0;
300 306
301 dig = radeon_encoder->enc_priv; 307 dig = radeon_encoder->enc_priv;
302 dig->coherent_mode = val ? true : false; 308 new_coherent_mode = val ? true : false;
303 radeon_property_change_mode(&radeon_encoder->base); 309 if (dig->coherent_mode != new_coherent_mode) {
310 dig->coherent_mode = new_coherent_mode;
311 radeon_property_change_mode(&radeon_encoder->base);
312 }
304 } 313 }
305 314
306 if (property == rdev->mode_info.tv_std_property) { 315 if (property == rdev->mode_info.tv_std_property) {
@@ -315,7 +324,7 @@ int radeon_connector_set_property(struct drm_connector *connector, struct drm_pr
315 radeon_encoder = to_radeon_encoder(encoder); 324 radeon_encoder = to_radeon_encoder(encoder);
316 if (!radeon_encoder->enc_priv) 325 if (!radeon_encoder->enc_priv)
317 return 0; 326 return 0;
318 if (rdev->is_atom_bios) { 327 if (ASIC_IS_AVIVO(rdev) || radeon_r4xx_atom) {
319 struct radeon_encoder_atom_dac *dac_int; 328 struct radeon_encoder_atom_dac *dac_int;
320 dac_int = radeon_encoder->enc_priv; 329 dac_int = radeon_encoder->enc_priv;
321 dac_int->tv_std = val; 330 dac_int->tv_std = val;
@@ -940,7 +949,7 @@ static void radeon_dp_connector_destroy(struct drm_connector *connector)
940 if (radeon_connector->edid) 949 if (radeon_connector->edid)
941 kfree(radeon_connector->edid); 950 kfree(radeon_connector->edid);
942 if (radeon_dig_connector->dp_i2c_bus) 951 if (radeon_dig_connector->dp_i2c_bus)
943 radeon_i2c_destroy_dp(radeon_dig_connector->dp_i2c_bus); 952 radeon_i2c_destroy(radeon_dig_connector->dp_i2c_bus);
944 kfree(radeon_connector->con_priv); 953 kfree(radeon_connector->con_priv);
945 drm_sysfs_connector_remove(connector); 954 drm_sysfs_connector_remove(connector);
946 drm_connector_cleanup(connector); 955 drm_connector_cleanup(connector);
@@ -1307,6 +1316,8 @@ radeon_add_legacy_connector(struct drm_device *dev,
1307 radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DVI"); 1316 radeon_connector->ddc_bus = radeon_i2c_create(dev, i2c_bus, "DVI");
1308 if (!radeon_connector->ddc_bus) 1317 if (!radeon_connector->ddc_bus)
1309 goto failed; 1318 goto failed;
1319 }
1320 if (connector_type == DRM_MODE_CONNECTOR_DVII) {
1310 radeon_connector->dac_load_detect = true; 1321 radeon_connector->dac_load_detect = true;
1311 drm_connector_attach_property(&radeon_connector->base, 1322 drm_connector_attach_property(&radeon_connector->base,
1312 rdev->mode_info.load_detect_property, 1323 rdev->mode_info.load_detect_property,
diff --git a/drivers/gpu/drm/radeon/radeon_cp.c b/drivers/gpu/drm/radeon/radeon_cp.c
index dc6eba6b96d..2f042a3c0e6 100644
--- a/drivers/gpu/drm/radeon/radeon_cp.c
+++ b/drivers/gpu/drm/radeon/radeon_cp.c
@@ -417,8 +417,9 @@ static int radeon_do_wait_for_idle(drm_radeon_private_t * dev_priv)
417 return -EBUSY; 417 return -EBUSY;
418} 418}
419 419
420static void radeon_init_pipes(drm_radeon_private_t *dev_priv) 420static void radeon_init_pipes(struct drm_device *dev)
421{ 421{
422 drm_radeon_private_t *dev_priv = dev->dev_private;
422 uint32_t gb_tile_config, gb_pipe_sel = 0; 423 uint32_t gb_tile_config, gb_pipe_sel = 0;
423 424
424 if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV530) { 425 if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV530) {
@@ -434,13 +435,19 @@ static void radeon_init_pipes(drm_radeon_private_t *dev_priv)
434 if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R420) { 435 if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R420) {
435 gb_pipe_sel = RADEON_READ(R400_GB_PIPE_SELECT); 436 gb_pipe_sel = RADEON_READ(R400_GB_PIPE_SELECT);
436 dev_priv->num_gb_pipes = ((gb_pipe_sel >> 12) & 0x3) + 1; 437 dev_priv->num_gb_pipes = ((gb_pipe_sel >> 12) & 0x3) + 1;
438 /* SE cards have 1 pipe */
439 if ((dev->pdev->device == 0x5e4c) ||
440 (dev->pdev->device == 0x5e4f))
441 dev_priv->num_gb_pipes = 1;
437 } else { 442 } else {
438 /* R3xx */ 443 /* R3xx */
439 if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_R300) || 444 if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_R300 &&
440 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_R350)) { 445 dev->pdev->device != 0x4144) ||
446 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_R350 &&
447 dev->pdev->device != 0x4148)) {
441 dev_priv->num_gb_pipes = 2; 448 dev_priv->num_gb_pipes = 2;
442 } else { 449 } else {
443 /* R3Vxx */ 450 /* RV3xx/R300 AD/R350 AH */
444 dev_priv->num_gb_pipes = 1; 451 dev_priv->num_gb_pipes = 1;
445 } 452 }
446 } 453 }
@@ -736,7 +743,7 @@ static int radeon_do_engine_reset(struct drm_device * dev)
736 743
737 /* setup the raster pipes */ 744 /* setup the raster pipes */
738 if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R300) 745 if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R300)
739 radeon_init_pipes(dev_priv); 746 radeon_init_pipes(dev);
740 747
741 /* Reset the CP ring */ 748 /* Reset the CP ring */
742 radeon_do_cp_reset(dev_priv); 749 radeon_do_cp_reset(dev_priv);
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c
index 70ba02ed772..f9b0fe002c0 100644
--- a/drivers/gpu/drm/radeon/radeon_cs.c
+++ b/drivers/gpu/drm/radeon/radeon_cs.c
@@ -193,9 +193,11 @@ static void radeon_cs_parser_fini(struct radeon_cs_parser *parser, int error)
193 radeon_bo_list_fence(&parser->validated, parser->ib->fence); 193 radeon_bo_list_fence(&parser->validated, parser->ib->fence);
194 } 194 }
195 radeon_bo_list_unreserve(&parser->validated); 195 radeon_bo_list_unreserve(&parser->validated);
196 for (i = 0; i < parser->nrelocs; i++) { 196 if (parser->relocs != NULL) {
197 if (parser->relocs[i].gobj) 197 for (i = 0; i < parser->nrelocs; i++) {
198 drm_gem_object_unreference_unlocked(parser->relocs[i].gobj); 198 if (parser->relocs[i].gobj)
199 drm_gem_object_unreference_unlocked(parser->relocs[i].gobj);
200 }
199 } 201 }
200 kfree(parser->track); 202 kfree(parser->track);
201 kfree(parser->relocs); 203 kfree(parser->relocs);
@@ -243,7 +245,8 @@ int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
243 } 245 }
244 r = radeon_cs_parser_relocs(&parser); 246 r = radeon_cs_parser_relocs(&parser);
245 if (r) { 247 if (r) {
246 DRM_ERROR("Failed to parse relocation !\n"); 248 if (r != -ERESTARTSYS)
249 DRM_ERROR("Failed to parse relocation %d!\n", r);
247 radeon_cs_parser_fini(&parser, r); 250 radeon_cs_parser_fini(&parser, r);
248 mutex_unlock(&rdev->cs_mutex); 251 mutex_unlock(&rdev->cs_mutex);
249 return r; 252 return r;
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index e28e4ed5f72..7b629e30556 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -26,6 +26,7 @@
26 * Jerome Glisse 26 * Jerome Glisse
27 */ 27 */
28#include <linux/console.h> 28#include <linux/console.h>
29#include <linux/slab.h>
29#include <drm/drmP.h> 30#include <drm/drmP.h>
30#include <drm/drm_crtc_helper.h> 31#include <drm/drm_crtc_helper.h>
31#include <drm/radeon_drm.h> 32#include <drm/radeon_drm.h>
@@ -33,9 +34,56 @@
33#include <linux/vga_switcheroo.h> 34#include <linux/vga_switcheroo.h>
34#include "radeon_reg.h" 35#include "radeon_reg.h"
35#include "radeon.h" 36#include "radeon.h"
36#include "radeon_asic.h"
37#include "atom.h" 37#include "atom.h"
38 38
39static const char radeon_family_name[][16] = {
40 "R100",
41 "RV100",
42 "RS100",
43 "RV200",
44 "RS200",
45 "R200",
46 "RV250",
47 "RS300",
48 "RV280",
49 "R300",
50 "R350",
51 "RV350",
52 "RV380",
53 "R420",
54 "R423",
55 "RV410",
56 "RS400",
57 "RS480",
58 "RS600",
59 "RS690",
60 "RS740",
61 "RV515",
62 "R520",
63 "RV530",
64 "RV560",
65 "RV570",
66 "R580",
67 "R600",
68 "RV610",
69 "RV630",
70 "RV670",
71 "RV620",
72 "RV635",
73 "RS780",
74 "RS880",
75 "RV770",
76 "RV730",
77 "RV710",
78 "RV740",
79 "CEDAR",
80 "REDWOOD",
81 "JUNIPER",
82 "CYPRESS",
83 "HEMLOCK",
84 "LAST",
85};
86
39/* 87/*
40 * Clear GPU surface registers. 88 * Clear GPU surface registers.
41 */ 89 */
@@ -242,6 +290,36 @@ bool radeon_card_posted(struct radeon_device *rdev)
242 290
243} 291}
244 292
293void radeon_update_bandwidth_info(struct radeon_device *rdev)
294{
295 fixed20_12 a;
296 u32 sclk, mclk;
297
298 if (rdev->flags & RADEON_IS_IGP) {
299 sclk = radeon_get_engine_clock(rdev);
300 mclk = rdev->clock.default_mclk;
301
302 a.full = rfixed_const(100);
303 rdev->pm.sclk.full = rfixed_const(sclk);
304 rdev->pm.sclk.full = rfixed_div(rdev->pm.sclk, a);
305 rdev->pm.mclk.full = rfixed_const(mclk);
306 rdev->pm.mclk.full = rfixed_div(rdev->pm.mclk, a);
307
308 a.full = rfixed_const(16);
309 /* core_bandwidth = sclk(Mhz) * 16 */
310 rdev->pm.core_bandwidth.full = rfixed_div(rdev->pm.sclk, a);
311 } else {
312 sclk = radeon_get_engine_clock(rdev);
313 mclk = radeon_get_memory_clock(rdev);
314
315 a.full = rfixed_const(100);
316 rdev->pm.sclk.full = rfixed_const(sclk);
317 rdev->pm.sclk.full = rfixed_div(rdev->pm.sclk, a);
318 rdev->pm.mclk.full = rfixed_const(mclk);
319 rdev->pm.mclk.full = rfixed_div(rdev->pm.mclk, a);
320 }
321}
322
245bool radeon_boot_test_post_card(struct radeon_device *rdev) 323bool radeon_boot_test_post_card(struct radeon_device *rdev)
246{ 324{
247 if (radeon_card_posted(rdev)) 325 if (radeon_card_posted(rdev))
@@ -288,181 +366,6 @@ void radeon_dummy_page_fini(struct radeon_device *rdev)
288} 366}
289 367
290 368
291/*
292 * Registers accessors functions.
293 */
294uint32_t radeon_invalid_rreg(struct radeon_device *rdev, uint32_t reg)
295{
296 DRM_ERROR("Invalid callback to read register 0x%04X\n", reg);
297 BUG_ON(1);
298 return 0;
299}
300
301void radeon_invalid_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
302{
303 DRM_ERROR("Invalid callback to write register 0x%04X with 0x%08X\n",
304 reg, v);
305 BUG_ON(1);
306}
307
308void radeon_register_accessor_init(struct radeon_device *rdev)
309{
310 rdev->mc_rreg = &radeon_invalid_rreg;
311 rdev->mc_wreg = &radeon_invalid_wreg;
312 rdev->pll_rreg = &radeon_invalid_rreg;
313 rdev->pll_wreg = &radeon_invalid_wreg;
314 rdev->pciep_rreg = &radeon_invalid_rreg;
315 rdev->pciep_wreg = &radeon_invalid_wreg;
316
317 /* Don't change order as we are overridding accessor. */
318 if (rdev->family < CHIP_RV515) {
319 rdev->pcie_reg_mask = 0xff;
320 } else {
321 rdev->pcie_reg_mask = 0x7ff;
322 }
323 /* FIXME: not sure here */
324 if (rdev->family <= CHIP_R580) {
325 rdev->pll_rreg = &r100_pll_rreg;
326 rdev->pll_wreg = &r100_pll_wreg;
327 }
328 if (rdev->family >= CHIP_R420) {
329 rdev->mc_rreg = &r420_mc_rreg;
330 rdev->mc_wreg = &r420_mc_wreg;
331 }
332 if (rdev->family >= CHIP_RV515) {
333 rdev->mc_rreg = &rv515_mc_rreg;
334 rdev->mc_wreg = &rv515_mc_wreg;
335 }
336 if (rdev->family == CHIP_RS400 || rdev->family == CHIP_RS480) {
337 rdev->mc_rreg = &rs400_mc_rreg;
338 rdev->mc_wreg = &rs400_mc_wreg;
339 }
340 if (rdev->family == CHIP_RS690 || rdev->family == CHIP_RS740) {
341 rdev->mc_rreg = &rs690_mc_rreg;
342 rdev->mc_wreg = &rs690_mc_wreg;
343 }
344 if (rdev->family == CHIP_RS600) {
345 rdev->mc_rreg = &rs600_mc_rreg;
346 rdev->mc_wreg = &rs600_mc_wreg;
347 }
348 if ((rdev->family >= CHIP_R600) && (rdev->family <= CHIP_RV740)) {
349 rdev->pciep_rreg = &r600_pciep_rreg;
350 rdev->pciep_wreg = &r600_pciep_wreg;
351 }
352}
353
354
355/*
356 * ASIC
357 */
358int radeon_asic_init(struct radeon_device *rdev)
359{
360 radeon_register_accessor_init(rdev);
361 switch (rdev->family) {
362 case CHIP_R100:
363 case CHIP_RV100:
364 case CHIP_RS100:
365 case CHIP_RV200:
366 case CHIP_RS200:
367 rdev->asic = &r100_asic;
368 break;
369 case CHIP_R200:
370 case CHIP_RV250:
371 case CHIP_RS300:
372 case CHIP_RV280:
373 rdev->asic = &r200_asic;
374 break;
375 case CHIP_R300:
376 case CHIP_R350:
377 case CHIP_RV350:
378 case CHIP_RV380:
379 if (rdev->flags & RADEON_IS_PCIE)
380 rdev->asic = &r300_asic_pcie;
381 else
382 rdev->asic = &r300_asic;
383 break;
384 case CHIP_R420:
385 case CHIP_R423:
386 case CHIP_RV410:
387 rdev->asic = &r420_asic;
388 break;
389 case CHIP_RS400:
390 case CHIP_RS480:
391 rdev->asic = &rs400_asic;
392 break;
393 case CHIP_RS600:
394 rdev->asic = &rs600_asic;
395 break;
396 case CHIP_RS690:
397 case CHIP_RS740:
398 rdev->asic = &rs690_asic;
399 break;
400 case CHIP_RV515:
401 rdev->asic = &rv515_asic;
402 break;
403 case CHIP_R520:
404 case CHIP_RV530:
405 case CHIP_RV560:
406 case CHIP_RV570:
407 case CHIP_R580:
408 rdev->asic = &r520_asic;
409 break;
410 case CHIP_R600:
411 case CHIP_RV610:
412 case CHIP_RV630:
413 case CHIP_RV620:
414 case CHIP_RV635:
415 case CHIP_RV670:
416 case CHIP_RS780:
417 case CHIP_RS880:
418 rdev->asic = &r600_asic;
419 break;
420 case CHIP_RV770:
421 case CHIP_RV730:
422 case CHIP_RV710:
423 case CHIP_RV740:
424 rdev->asic = &rv770_asic;
425 break;
426 case CHIP_CEDAR:
427 case CHIP_REDWOOD:
428 case CHIP_JUNIPER:
429 case CHIP_CYPRESS:
430 case CHIP_HEMLOCK:
431 rdev->asic = &evergreen_asic;
432 break;
433 default:
434 /* FIXME: not supported yet */
435 return -EINVAL;
436 }
437
438 if (rdev->flags & RADEON_IS_IGP) {
439 rdev->asic->get_memory_clock = NULL;
440 rdev->asic->set_memory_clock = NULL;
441 }
442
443 return 0;
444}
445
446
447/*
448 * Wrapper around modesetting bits.
449 */
450int radeon_clocks_init(struct radeon_device *rdev)
451{
452 int r;
453
454 r = radeon_static_clocks_init(rdev->ddev);
455 if (r) {
456 return r;
457 }
458 DRM_INFO("Clocks initialized !\n");
459 return 0;
460}
461
462void radeon_clocks_fini(struct radeon_device *rdev)
463{
464}
465
466/* ATOM accessor methods */ 369/* ATOM accessor methods */
467static uint32_t cail_pll_read(struct card_info *info, uint32_t reg) 370static uint32_t cail_pll_read(struct card_info *info, uint32_t reg)
468{ 371{
@@ -567,29 +470,6 @@ static unsigned int radeon_vga_set_decode(void *cookie, bool state)
567 return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM; 470 return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM;
568} 471}
569 472
570void radeon_agp_disable(struct radeon_device *rdev)
571{
572 rdev->flags &= ~RADEON_IS_AGP;
573 if (rdev->family >= CHIP_R600) {
574 DRM_INFO("Forcing AGP to PCIE mode\n");
575 rdev->flags |= RADEON_IS_PCIE;
576 } else if (rdev->family >= CHIP_RV515 ||
577 rdev->family == CHIP_RV380 ||
578 rdev->family == CHIP_RV410 ||
579 rdev->family == CHIP_R423) {
580 DRM_INFO("Forcing AGP to PCIE mode\n");
581 rdev->flags |= RADEON_IS_PCIE;
582 rdev->asic->gart_tlb_flush = &rv370_pcie_gart_tlb_flush;
583 rdev->asic->gart_set_page = &rv370_pcie_gart_set_page;
584 } else {
585 DRM_INFO("Forcing AGP to PCI mode\n");
586 rdev->flags |= RADEON_IS_PCI;
587 rdev->asic->gart_tlb_flush = &r100_pci_gart_tlb_flush;
588 rdev->asic->gart_set_page = &r100_pci_gart_set_page;
589 }
590 rdev->mc.gtt_size = radeon_gart_size * 1024 * 1024;
591}
592
593void radeon_check_arguments(struct radeon_device *rdev) 473void radeon_check_arguments(struct radeon_device *rdev)
594{ 474{
595 /* vramlimit must be a power of two */ 475 /* vramlimit must be a power of two */
@@ -694,7 +574,6 @@ int radeon_device_init(struct radeon_device *rdev,
694 int r; 574 int r;
695 int dma_bits; 575 int dma_bits;
696 576
697 DRM_INFO("radeon: Initializing kernel modesetting.\n");
698 rdev->shutdown = false; 577 rdev->shutdown = false;
699 rdev->dev = &pdev->dev; 578 rdev->dev = &pdev->dev;
700 rdev->ddev = ddev; 579 rdev->ddev = ddev;
@@ -706,6 +585,10 @@ int radeon_device_init(struct radeon_device *rdev,
706 rdev->mc.gtt_size = radeon_gart_size * 1024 * 1024; 585 rdev->mc.gtt_size = radeon_gart_size * 1024 * 1024;
707 rdev->gpu_lockup = false; 586 rdev->gpu_lockup = false;
708 rdev->accel_working = false; 587 rdev->accel_working = false;
588
589 DRM_INFO("initializing kernel modesetting (%s 0x%04X:0x%04X).\n",
590 radeon_family_name[rdev->family], pdev->vendor, pdev->device);
591
709 /* mutex initialization are all done here so we 592 /* mutex initialization are all done here so we
710 * can recall function without having locking issues */ 593 * can recall function without having locking issues */
711 mutex_init(&rdev->cs_mutex); 594 mutex_init(&rdev->cs_mutex);
@@ -731,6 +614,14 @@ int radeon_device_init(struct radeon_device *rdev,
731 return r; 614 return r;
732 radeon_check_arguments(rdev); 615 radeon_check_arguments(rdev);
733 616
617 /* all of the newer IGP chips have an internal gart
618 * However some rs4xx report as AGP, so remove that here.
619 */
620 if ((rdev->family >= CHIP_RS400) &&
621 (rdev->flags & RADEON_IS_IGP)) {
622 rdev->flags &= ~RADEON_IS_AGP;
623 }
624
734 if (rdev->flags & RADEON_IS_AGP && radeon_agpmode == -1) { 625 if (rdev->flags & RADEON_IS_AGP && radeon_agpmode == -1) {
735 radeon_agp_disable(rdev); 626 radeon_agp_disable(rdev);
736 } 627 }
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index ba8d806dcf3..bb1c122cad2 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -86,12 +86,12 @@ static void evergreen_crtc_load_lut(struct drm_crtc *crtc)
86 WREG32(EVERGREEN_DC_LUT_WHITE_OFFSET_GREEN + radeon_crtc->crtc_offset, 0xffff); 86 WREG32(EVERGREEN_DC_LUT_WHITE_OFFSET_GREEN + radeon_crtc->crtc_offset, 0xffff);
87 WREG32(EVERGREEN_DC_LUT_WHITE_OFFSET_RED + radeon_crtc->crtc_offset, 0xffff); 87 WREG32(EVERGREEN_DC_LUT_WHITE_OFFSET_RED + radeon_crtc->crtc_offset, 0xffff);
88 88
89 WREG32(EVERGREEN_DC_LUT_RW_MODE, radeon_crtc->crtc_id); 89 WREG32(EVERGREEN_DC_LUT_RW_MODE + radeon_crtc->crtc_offset, 0);
90 WREG32(EVERGREEN_DC_LUT_WRITE_EN_MASK, 0x00000007); 90 WREG32(EVERGREEN_DC_LUT_WRITE_EN_MASK + radeon_crtc->crtc_offset, 0x00000007);
91 91
92 WREG32(EVERGREEN_DC_LUT_RW_INDEX, 0); 92 WREG32(EVERGREEN_DC_LUT_RW_INDEX + radeon_crtc->crtc_offset, 0);
93 for (i = 0; i < 256; i++) { 93 for (i = 0; i < 256; i++) {
94 WREG32(EVERGREEN_DC_LUT_30_COLOR, 94 WREG32(EVERGREEN_DC_LUT_30_COLOR + radeon_crtc->crtc_offset,
95 (radeon_crtc->lut_r[i] << 20) | 95 (radeon_crtc->lut_r[i] << 20) |
96 (radeon_crtc->lut_g[i] << 10) | 96 (radeon_crtc->lut_g[i] << 10) |
97 (radeon_crtc->lut_b[i] << 0)); 97 (radeon_crtc->lut_b[i] << 0));
@@ -368,10 +368,9 @@ static bool radeon_setup_enc_conn(struct drm_device *dev)
368 368
369 if (rdev->bios) { 369 if (rdev->bios) {
370 if (rdev->is_atom_bios) { 370 if (rdev->is_atom_bios) {
371 if (rdev->family >= CHIP_R600) 371 ret = radeon_get_atom_connector_info_from_supported_devices_table(dev);
372 if (ret == false)
372 ret = radeon_get_atom_connector_info_from_object_table(dev); 373 ret = radeon_get_atom_connector_info_from_object_table(dev);
373 else
374 ret = radeon_get_atom_connector_info_from_supported_devices_table(dev);
375 } else { 374 } else {
376 ret = radeon_get_legacy_connector_info_from_bios(dev); 375 ret = radeon_get_legacy_connector_info_from_bios(dev);
377 if (ret == false) 376 if (ret == false)
@@ -469,10 +468,19 @@ static void radeon_compute_pll_legacy(struct radeon_pll *pll,
469 uint32_t best_error = 0xffffffff; 468 uint32_t best_error = 0xffffffff;
470 uint32_t best_vco_diff = 1; 469 uint32_t best_vco_diff = 1;
471 uint32_t post_div; 470 uint32_t post_div;
471 u32 pll_out_min, pll_out_max;
472 472
473 DRM_DEBUG("PLL freq %llu %u %u\n", freq, pll->min_ref_div, pll->max_ref_div); 473 DRM_DEBUG("PLL freq %llu %u %u\n", freq, pll->min_ref_div, pll->max_ref_div);
474 freq = freq * 1000; 474 freq = freq * 1000;
475 475
476 if (pll->flags & RADEON_PLL_IS_LCD) {
477 pll_out_min = pll->lcd_pll_out_min;
478 pll_out_max = pll->lcd_pll_out_max;
479 } else {
480 pll_out_min = pll->pll_out_min;
481 pll_out_max = pll->pll_out_max;
482 }
483
476 if (pll->flags & RADEON_PLL_USE_REF_DIV) 484 if (pll->flags & RADEON_PLL_USE_REF_DIV)
477 min_ref_div = max_ref_div = pll->reference_div; 485 min_ref_div = max_ref_div = pll->reference_div;
478 else { 486 else {
@@ -536,10 +544,10 @@ static void radeon_compute_pll_legacy(struct radeon_pll *pll,
536 tmp = (uint64_t)pll->reference_freq * feedback_div; 544 tmp = (uint64_t)pll->reference_freq * feedback_div;
537 vco = radeon_div(tmp, ref_div); 545 vco = radeon_div(tmp, ref_div);
538 546
539 if (vco < pll->pll_out_min) { 547 if (vco < pll_out_min) {
540 min_feed_div = feedback_div + 1; 548 min_feed_div = feedback_div + 1;
541 continue; 549 continue;
542 } else if (vco > pll->pll_out_max) { 550 } else if (vco > pll_out_max) {
543 max_feed_div = feedback_div; 551 max_feed_div = feedback_div;
544 continue; 552 continue;
545 } 553 }
@@ -675,6 +683,15 @@ calc_fb_ref_div(struct radeon_pll *pll,
675{ 683{
676 fixed20_12 ffreq, max_error, error, pll_out, a; 684 fixed20_12 ffreq, max_error, error, pll_out, a;
677 u32 vco; 685 u32 vco;
686 u32 pll_out_min, pll_out_max;
687
688 if (pll->flags & RADEON_PLL_IS_LCD) {
689 pll_out_min = pll->lcd_pll_out_min;
690 pll_out_max = pll->lcd_pll_out_max;
691 } else {
692 pll_out_min = pll->pll_out_min;
693 pll_out_max = pll->pll_out_max;
694 }
678 695
679 ffreq.full = rfixed_const(freq); 696 ffreq.full = rfixed_const(freq);
680 /* max_error = ffreq * 0.0025; */ 697 /* max_error = ffreq * 0.0025; */
@@ -686,7 +703,7 @@ calc_fb_ref_div(struct radeon_pll *pll,
686 vco = pll->reference_freq * (((*fb_div) * 10) + (*fb_div_frac)); 703 vco = pll->reference_freq * (((*fb_div) * 10) + (*fb_div_frac));
687 vco = vco / ((*ref_div) * 10); 704 vco = vco / ((*ref_div) * 10);
688 705
689 if ((vco < pll->pll_out_min) || (vco > pll->pll_out_max)) 706 if ((vco < pll_out_min) || (vco > pll_out_max))
690 continue; 707 continue;
691 708
692 /* pll_out = vco / post_div; */ 709 /* pll_out = vco / post_div; */
@@ -714,6 +731,15 @@ static void radeon_compute_pll_new(struct radeon_pll *pll,
714{ 731{
715 u32 fb_div = 0, fb_div_frac = 0, post_div = 0, ref_div = 0; 732 u32 fb_div = 0, fb_div_frac = 0, post_div = 0, ref_div = 0;
716 u32 best_freq = 0, vco_frequency; 733 u32 best_freq = 0, vco_frequency;
734 u32 pll_out_min, pll_out_max;
735
736 if (pll->flags & RADEON_PLL_IS_LCD) {
737 pll_out_min = pll->lcd_pll_out_min;
738 pll_out_max = pll->lcd_pll_out_max;
739 } else {
740 pll_out_min = pll->pll_out_min;
741 pll_out_max = pll->pll_out_max;
742 }
717 743
718 /* freq = freq / 10; */ 744 /* freq = freq / 10; */
719 do_div(freq, 10); 745 do_div(freq, 10);
@@ -724,7 +750,7 @@ static void radeon_compute_pll_new(struct radeon_pll *pll,
724 goto done; 750 goto done;
725 751
726 vco_frequency = freq * post_div; 752 vco_frequency = freq * post_div;
727 if ((vco_frequency < pll->pll_out_min) || (vco_frequency > pll->pll_out_max)) 753 if ((vco_frequency < pll_out_min) || (vco_frequency > pll_out_max))
728 goto done; 754 goto done;
729 755
730 if (pll->flags & RADEON_PLL_USE_REF_DIV) { 756 if (pll->flags & RADEON_PLL_USE_REF_DIV) {
@@ -749,7 +775,7 @@ static void radeon_compute_pll_new(struct radeon_pll *pll,
749 continue; 775 continue;
750 776
751 vco_frequency = freq * post_div; 777 vco_frequency = freq * post_div;
752 if ((vco_frequency < pll->pll_out_min) || (vco_frequency > pll->pll_out_max)) 778 if ((vco_frequency < pll_out_min) || (vco_frequency > pll_out_max))
753 continue; 779 continue;
754 if (pll->flags & RADEON_PLL_USE_REF_DIV) { 780 if (pll->flags & RADEON_PLL_USE_REF_DIV) {
755 ref_div = pll->reference_div; 781 ref_div = pll->reference_div;
@@ -945,6 +971,23 @@ static int radeon_modeset_create_props(struct radeon_device *rdev)
945 return 0; 971 return 0;
946} 972}
947 973
974void radeon_update_display_priority(struct radeon_device *rdev)
975{
976 /* adjustment options for the display watermarks */
977 if ((radeon_disp_priority == 0) || (radeon_disp_priority > 2)) {
978 /* set display priority to high for r3xx, rv515 chips
979 * this avoids flickering due to underflow to the
980 * display controllers during heavy acceleration.
981 */
982 if (ASIC_IS_R300(rdev) || (rdev->family == CHIP_RV515))
983 rdev->disp_priority = 2;
984 else
985 rdev->disp_priority = 0;
986 } else
987 rdev->disp_priority = radeon_disp_priority;
988
989}
990
948int radeon_modeset_init(struct radeon_device *rdev) 991int radeon_modeset_init(struct radeon_device *rdev)
949{ 992{
950 int i; 993 int i;
@@ -976,15 +1019,6 @@ int radeon_modeset_init(struct radeon_device *rdev)
976 radeon_combios_check_hardcoded_edid(rdev); 1019 radeon_combios_check_hardcoded_edid(rdev);
977 } 1020 }
978 1021
979 if (rdev->flags & RADEON_SINGLE_CRTC)
980 rdev->num_crtc = 1;
981 else {
982 if (ASIC_IS_DCE4(rdev))
983 rdev->num_crtc = 6;
984 else
985 rdev->num_crtc = 2;
986 }
987
988 /* allocate crtcs */ 1022 /* allocate crtcs */
989 for (i = 0; i < rdev->num_crtc; i++) { 1023 for (i = 0; i < rdev->num_crtc; i++) {
990 radeon_crtc_init(rdev->ddev, i); 1024 radeon_crtc_init(rdev->ddev, i);
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 6eec0ece6a6..b3749d47be7 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -42,9 +42,11 @@
42 * KMS wrapper. 42 * KMS wrapper.
43 * - 2.0.0 - initial interface 43 * - 2.0.0 - initial interface
44 * - 2.1.0 - add square tiling interface 44 * - 2.1.0 - add square tiling interface
45 * - 2.2.0 - add r6xx/r7xx const buffer support
46 * - 2.3.0 - add MSPOS + 3D texture + r500 VAP regs
45 */ 47 */
46#define KMS_DRIVER_MAJOR 2 48#define KMS_DRIVER_MAJOR 2
47#define KMS_DRIVER_MINOR 1 49#define KMS_DRIVER_MINOR 3
48#define KMS_DRIVER_PATCHLEVEL 0 50#define KMS_DRIVER_PATCHLEVEL 0
49int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags); 51int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags);
50int radeon_driver_unload_kms(struct drm_device *dev); 52int radeon_driver_unload_kms(struct drm_device *dev);
@@ -91,6 +93,8 @@ int radeon_tv = 1;
91int radeon_new_pll = -1; 93int radeon_new_pll = -1;
92int radeon_dynpm = -1; 94int radeon_dynpm = -1;
93int radeon_audio = 1; 95int radeon_audio = 1;
96int radeon_disp_priority = 0;
97int radeon_hw_i2c = 0;
94 98
95MODULE_PARM_DESC(no_wb, "Disable AGP writeback for scratch registers"); 99MODULE_PARM_DESC(no_wb, "Disable AGP writeback for scratch registers");
96module_param_named(no_wb, radeon_no_wb, int, 0444); 100module_param_named(no_wb, radeon_no_wb, int, 0444);
@@ -134,6 +138,12 @@ module_param_named(dynpm, radeon_dynpm, int, 0444);
134MODULE_PARM_DESC(audio, "Audio enable (0 = disable)"); 138MODULE_PARM_DESC(audio, "Audio enable (0 = disable)");
135module_param_named(audio, radeon_audio, int, 0444); 139module_param_named(audio, radeon_audio, int, 0444);
136 140
141MODULE_PARM_DESC(disp_priority, "Display Priority (0 = auto, 1 = normal, 2 = high)");
142module_param_named(disp_priority, radeon_disp_priority, int, 0444);
143
144MODULE_PARM_DESC(hw_i2c, "hw i2c engine enable (0 = disable)");
145module_param_named(hw_i2c, radeon_hw_i2c, int, 0444);
146
137static int radeon_suspend(struct drm_device *dev, pm_message_t state) 147static int radeon_suspend(struct drm_device *dev, pm_message_t state)
138{ 148{
139 drm_radeon_private_t *dev_priv = dev->dev_private; 149 drm_radeon_private_t *dev_priv = dev->dev_private;
@@ -206,6 +216,7 @@ static struct drm_driver driver_old = {
206 .mmap = drm_mmap, 216 .mmap = drm_mmap,
207 .poll = drm_poll, 217 .poll = drm_poll,
208 .fasync = drm_fasync, 218 .fasync = drm_fasync,
219 .read = drm_read,
209#ifdef CONFIG_COMPAT 220#ifdef CONFIG_COMPAT
210 .compat_ioctl = radeon_compat_ioctl, 221 .compat_ioctl = radeon_compat_ioctl,
211#endif 222#endif
@@ -294,6 +305,7 @@ static struct drm_driver kms_driver = {
294 .mmap = radeon_mmap, 305 .mmap = radeon_mmap,
295 .poll = drm_poll, 306 .poll = drm_poll,
296 .fasync = drm_fasync, 307 .fasync = drm_fasync,
308 .read = drm_read,
297#ifdef CONFIG_COMPAT 309#ifdef CONFIG_COMPAT
298 .compat_ioctl = radeon_kms_compat_ioctl, 310 .compat_ioctl = radeon_kms_compat_ioctl,
299#endif 311#endif
diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
index ec55f2b23c2..448eba89d1e 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.h
+++ b/drivers/gpu/drm/radeon/radeon_drv.h
@@ -107,9 +107,10 @@
107 * 1.30- Add support for occlusion queries 107 * 1.30- Add support for occlusion queries
108 * 1.31- Add support for num Z pipes from GET_PARAM 108 * 1.31- Add support for num Z pipes from GET_PARAM
109 * 1.32- fixes for rv740 setup 109 * 1.32- fixes for rv740 setup
110 * 1.33- Add r6xx/r7xx const buffer support
110 */ 111 */
111#define DRIVER_MAJOR 1 112#define DRIVER_MAJOR 1
112#define DRIVER_MINOR 32 113#define DRIVER_MINOR 33
113#define DRIVER_PATCHLEVEL 0 114#define DRIVER_PATCHLEVEL 0
114 115
115enum radeon_cp_microcode_version { 116enum radeon_cp_microcode_version {
diff --git a/drivers/gpu/drm/radeon/radeon_encoders.c b/drivers/gpu/drm/radeon/radeon_encoders.c
index bc926ea0a53..c5ddaf58563 100644
--- a/drivers/gpu/drm/radeon/radeon_encoders.c
+++ b/drivers/gpu/drm/radeon/radeon_encoders.c
@@ -254,6 +254,53 @@ radeon_get_atom_connector_priv_from_encoder(struct drm_encoder *encoder)
254 return dig_connector; 254 return dig_connector;
255} 255}
256 256
257void radeon_panel_mode_fixup(struct drm_encoder *encoder,
258 struct drm_display_mode *adjusted_mode)
259{
260 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
261 struct drm_device *dev = encoder->dev;
262 struct radeon_device *rdev = dev->dev_private;
263 struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
264 unsigned hblank = native_mode->htotal - native_mode->hdisplay;
265 unsigned vblank = native_mode->vtotal - native_mode->vdisplay;
266 unsigned hover = native_mode->hsync_start - native_mode->hdisplay;
267 unsigned vover = native_mode->vsync_start - native_mode->vdisplay;
268 unsigned hsync_width = native_mode->hsync_end - native_mode->hsync_start;
269 unsigned vsync_width = native_mode->vsync_end - native_mode->vsync_start;
270
271 adjusted_mode->clock = native_mode->clock;
272 adjusted_mode->flags = native_mode->flags;
273
274 if (ASIC_IS_AVIVO(rdev)) {
275 adjusted_mode->hdisplay = native_mode->hdisplay;
276 adjusted_mode->vdisplay = native_mode->vdisplay;
277 }
278
279 adjusted_mode->htotal = native_mode->hdisplay + hblank;
280 adjusted_mode->hsync_start = native_mode->hdisplay + hover;
281 adjusted_mode->hsync_end = adjusted_mode->hsync_start + hsync_width;
282
283 adjusted_mode->vtotal = native_mode->vdisplay + vblank;
284 adjusted_mode->vsync_start = native_mode->vdisplay + vover;
285 adjusted_mode->vsync_end = adjusted_mode->vsync_start + vsync_width;
286
287 drm_mode_set_crtcinfo(adjusted_mode, CRTC_INTERLACE_HALVE_V);
288
289 if (ASIC_IS_AVIVO(rdev)) {
290 adjusted_mode->crtc_hdisplay = native_mode->hdisplay;
291 adjusted_mode->crtc_vdisplay = native_mode->vdisplay;
292 }
293
294 adjusted_mode->crtc_htotal = adjusted_mode->crtc_hdisplay + hblank;
295 adjusted_mode->crtc_hsync_start = adjusted_mode->crtc_hdisplay + hover;
296 adjusted_mode->crtc_hsync_end = adjusted_mode->crtc_hsync_start + hsync_width;
297
298 adjusted_mode->crtc_vtotal = adjusted_mode->crtc_vdisplay + vblank;
299 adjusted_mode->crtc_vsync_start = adjusted_mode->crtc_vdisplay + vover;
300 adjusted_mode->crtc_vsync_end = adjusted_mode->crtc_vsync_start + vsync_width;
301
302}
303
257static bool radeon_atom_mode_fixup(struct drm_encoder *encoder, 304static bool radeon_atom_mode_fixup(struct drm_encoder *encoder,
258 struct drm_display_mode *mode, 305 struct drm_display_mode *mode,
259 struct drm_display_mode *adjusted_mode) 306 struct drm_display_mode *adjusted_mode)
@@ -275,18 +322,8 @@ static bool radeon_atom_mode_fixup(struct drm_encoder *encoder,
275 adjusted_mode->crtc_vsync_start = adjusted_mode->crtc_vdisplay + 2; 322 adjusted_mode->crtc_vsync_start = adjusted_mode->crtc_vdisplay + 2;
276 323
277 /* get the native mode for LVDS */ 324 /* get the native mode for LVDS */
278 if (radeon_encoder->active_device & (ATOM_DEVICE_LCD_SUPPORT)) { 325 if (radeon_encoder->active_device & (ATOM_DEVICE_LCD_SUPPORT))
279 struct drm_display_mode *native_mode = &radeon_encoder->native_mode; 326 radeon_panel_mode_fixup(encoder, adjusted_mode);
280 int mode_id = adjusted_mode->base.id;
281 *adjusted_mode = *native_mode;
282 if (!ASIC_IS_AVIVO(rdev)) {
283 adjusted_mode->hdisplay = mode->hdisplay;
284 adjusted_mode->vdisplay = mode->vdisplay;
285 adjusted_mode->crtc_hdisplay = mode->hdisplay;
286 adjusted_mode->crtc_vdisplay = mode->vdisplay;
287 }
288 adjusted_mode->base.id = mode_id;
289 }
290 327
291 /* get the native mode for TV */ 328 /* get the native mode for TV */
292 if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT)) { 329 if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT)) {
@@ -302,7 +339,7 @@ static bool radeon_atom_mode_fixup(struct drm_encoder *encoder,
302 } 339 }
303 340
304 if (ASIC_IS_DCE3(rdev) && 341 if (ASIC_IS_DCE3(rdev) &&
305 (radeon_encoder->active_device & (ATOM_DEVICE_DFP_SUPPORT))) { 342 (radeon_encoder->active_device & (ATOM_DEVICE_DFP_SUPPORT | ATOM_DEVICE_LCD_SUPPORT))) {
306 struct drm_connector *connector = radeon_get_connector_for_encoder(encoder); 343 struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
307 radeon_dp_set_link_config(connector, mode); 344 radeon_dp_set_link_config(connector, mode);
308 } 345 }
@@ -317,12 +354,8 @@ atombios_dac_setup(struct drm_encoder *encoder, int action)
317 struct radeon_device *rdev = dev->dev_private; 354 struct radeon_device *rdev = dev->dev_private;
318 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 355 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
319 DAC_ENCODER_CONTROL_PS_ALLOCATION args; 356 DAC_ENCODER_CONTROL_PS_ALLOCATION args;
320 int index = 0, num = 0; 357 int index = 0;
321 struct radeon_encoder_atom_dac *dac_info = radeon_encoder->enc_priv; 358 struct radeon_encoder_atom_dac *dac_info = radeon_encoder->enc_priv;
322 enum radeon_tv_std tv_std = TV_STD_NTSC;
323
324 if (dac_info->tv_std)
325 tv_std = dac_info->tv_std;
326 359
327 memset(&args, 0, sizeof(args)); 360 memset(&args, 0, sizeof(args));
328 361
@@ -330,12 +363,10 @@ atombios_dac_setup(struct drm_encoder *encoder, int action)
330 case ENCODER_OBJECT_ID_INTERNAL_DAC1: 363 case ENCODER_OBJECT_ID_INTERNAL_DAC1:
331 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1: 364 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1:
332 index = GetIndexIntoMasterTable(COMMAND, DAC1EncoderControl); 365 index = GetIndexIntoMasterTable(COMMAND, DAC1EncoderControl);
333 num = 1;
334 break; 366 break;
335 case ENCODER_OBJECT_ID_INTERNAL_DAC2: 367 case ENCODER_OBJECT_ID_INTERNAL_DAC2:
336 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2: 368 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2:
337 index = GetIndexIntoMasterTable(COMMAND, DAC2EncoderControl); 369 index = GetIndexIntoMasterTable(COMMAND, DAC2EncoderControl);
338 num = 2;
339 break; 370 break;
340 } 371 }
341 372
@@ -346,7 +377,7 @@ atombios_dac_setup(struct drm_encoder *encoder, int action)
346 else if (radeon_encoder->active_device & (ATOM_DEVICE_CV_SUPPORT)) 377 else if (radeon_encoder->active_device & (ATOM_DEVICE_CV_SUPPORT))
347 args.ucDacStandard = ATOM_DAC1_CV; 378 args.ucDacStandard = ATOM_DAC1_CV;
348 else { 379 else {
349 switch (tv_std) { 380 switch (dac_info->tv_std) {
350 case TV_STD_PAL: 381 case TV_STD_PAL:
351 case TV_STD_PAL_M: 382 case TV_STD_PAL_M:
352 case TV_STD_SCART_PAL: 383 case TV_STD_SCART_PAL:
@@ -377,10 +408,6 @@ atombios_tv_setup(struct drm_encoder *encoder, int action)
377 TV_ENCODER_CONTROL_PS_ALLOCATION args; 408 TV_ENCODER_CONTROL_PS_ALLOCATION args;
378 int index = 0; 409 int index = 0;
379 struct radeon_encoder_atom_dac *dac_info = radeon_encoder->enc_priv; 410 struct radeon_encoder_atom_dac *dac_info = radeon_encoder->enc_priv;
380 enum radeon_tv_std tv_std = TV_STD_NTSC;
381
382 if (dac_info->tv_std)
383 tv_std = dac_info->tv_std;
384 411
385 memset(&args, 0, sizeof(args)); 412 memset(&args, 0, sizeof(args));
386 413
@@ -391,7 +418,7 @@ atombios_tv_setup(struct drm_encoder *encoder, int action)
391 if (radeon_encoder->active_device & (ATOM_DEVICE_CV_SUPPORT)) 418 if (radeon_encoder->active_device & (ATOM_DEVICE_CV_SUPPORT))
392 args.sTVEncoder.ucTvStandard = ATOM_TV_CV; 419 args.sTVEncoder.ucTvStandard = ATOM_TV_CV;
393 else { 420 else {
394 switch (tv_std) { 421 switch (dac_info->tv_std) {
395 case TV_STD_NTSC: 422 case TV_STD_NTSC:
396 args.sTVEncoder.ucTvStandard = ATOM_TV_NTSC; 423 args.sTVEncoder.ucTvStandard = ATOM_TV_NTSC;
397 break; 424 break;
@@ -519,7 +546,8 @@ atombios_digital_setup(struct drm_encoder *encoder, int action)
519 break; 546 break;
520 } 547 }
521 548
522 atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev); 549 if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev))
550 return;
523 551
524 switch (frev) { 552 switch (frev) {
525 case 1: 553 case 1:
@@ -593,7 +621,6 @@ atombios_digital_setup(struct drm_encoder *encoder, int action)
593 } 621 }
594 622
595 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); 623 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
596 r600_hdmi_enable(encoder, hdmi_detected);
597} 624}
598 625
599int 626int
@@ -708,7 +735,7 @@ atombios_dig_encoder_setup(struct drm_encoder *encoder, int action)
708 struct radeon_connector_atom_dig *dig_connector = 735 struct radeon_connector_atom_dig *dig_connector =
709 radeon_get_atom_connector_priv_from_encoder(encoder); 736 radeon_get_atom_connector_priv_from_encoder(encoder);
710 union dig_encoder_control args; 737 union dig_encoder_control args;
711 int index = 0, num = 0; 738 int index = 0;
712 uint8_t frev, crev; 739 uint8_t frev, crev;
713 740
714 if (!dig || !dig_connector) 741 if (!dig || !dig_connector)
@@ -724,9 +751,9 @@ atombios_dig_encoder_setup(struct drm_encoder *encoder, int action)
724 else 751 else
725 index = GetIndexIntoMasterTable(COMMAND, DIG1EncoderControl); 752 index = GetIndexIntoMasterTable(COMMAND, DIG1EncoderControl);
726 } 753 }
727 num = dig->dig_encoder + 1;
728 754
729 atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev); 755 if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev))
756 return;
730 757
731 args.v1.ucAction = action; 758 args.v1.ucAction = action;
732 args.v1.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10); 759 args.v1.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10);
@@ -785,7 +812,7 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
785 struct drm_connector *connector; 812 struct drm_connector *connector;
786 struct radeon_connector *radeon_connector; 813 struct radeon_connector *radeon_connector;
787 union dig_transmitter_control args; 814 union dig_transmitter_control args;
788 int index = 0, num = 0; 815 int index = 0;
789 uint8_t frev, crev; 816 uint8_t frev, crev;
790 bool is_dp = false; 817 bool is_dp = false;
791 int pll_id = 0; 818 int pll_id = 0;
@@ -814,7 +841,8 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
814 } 841 }
815 } 842 }
816 843
817 atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev); 844 if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev))
845 return;
818 846
819 args.v1.ucAction = action; 847 args.v1.ucAction = action;
820 if (action == ATOM_TRANSMITTER_ACTION_INIT) { 848 if (action == ATOM_TRANSMITTER_ACTION_INIT) {
@@ -860,15 +888,12 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
860 switch (radeon_encoder->encoder_id) { 888 switch (radeon_encoder->encoder_id) {
861 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY: 889 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
862 args.v3.acConfig.ucTransmitterSel = 0; 890 args.v3.acConfig.ucTransmitterSel = 0;
863 num = 0;
864 break; 891 break;
865 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1: 892 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
866 args.v3.acConfig.ucTransmitterSel = 1; 893 args.v3.acConfig.ucTransmitterSel = 1;
867 num = 1;
868 break; 894 break;
869 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2: 895 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
870 args.v3.acConfig.ucTransmitterSel = 2; 896 args.v3.acConfig.ucTransmitterSel = 2;
871 num = 2;
872 break; 897 break;
873 } 898 }
874 899
@@ -877,25 +902,23 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
877 else if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) { 902 else if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) {
878 if (dig->coherent_mode) 903 if (dig->coherent_mode)
879 args.v3.acConfig.fCoherentMode = 1; 904 args.v3.acConfig.fCoherentMode = 1;
905 if (radeon_encoder->pixel_clock > 165000)
906 args.v3.acConfig.fDualLinkConnector = 1;
880 } 907 }
881 } else if (ASIC_IS_DCE32(rdev)) { 908 } else if (ASIC_IS_DCE32(rdev)) {
882 if (dig->dig_encoder == 1) 909 args.v2.acConfig.ucEncoderSel = dig->dig_encoder;
883 args.v2.acConfig.ucEncoderSel = 1;
884 if (dig_connector->linkb) 910 if (dig_connector->linkb)
885 args.v2.acConfig.ucLinkSel = 1; 911 args.v2.acConfig.ucLinkSel = 1;
886 912
887 switch (radeon_encoder->encoder_id) { 913 switch (radeon_encoder->encoder_id) {
888 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY: 914 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
889 args.v2.acConfig.ucTransmitterSel = 0; 915 args.v2.acConfig.ucTransmitterSel = 0;
890 num = 0;
891 break; 916 break;
892 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1: 917 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
893 args.v2.acConfig.ucTransmitterSel = 1; 918 args.v2.acConfig.ucTransmitterSel = 1;
894 num = 1;
895 break; 919 break;
896 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2: 920 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
897 args.v2.acConfig.ucTransmitterSel = 2; 921 args.v2.acConfig.ucTransmitterSel = 2;
898 num = 2;
899 break; 922 break;
900 } 923 }
901 924
@@ -904,6 +927,8 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
904 else if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) { 927 else if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) {
905 if (dig->coherent_mode) 928 if (dig->coherent_mode)
906 args.v2.acConfig.fCoherentMode = 1; 929 args.v2.acConfig.fCoherentMode = 1;
930 if (radeon_encoder->pixel_clock > 165000)
931 args.v2.acConfig.fDualLinkConnector = 1;
907 } 932 }
908 } else { 933 } else {
909 args.v1.ucConfig = ATOM_TRANSMITTER_CONFIG_CLKSRC_PPLL; 934 args.v1.ucConfig = ATOM_TRANSMITTER_CONFIG_CLKSRC_PPLL;
@@ -913,31 +938,25 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
913 else 938 else
914 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_DIG1_ENCODER; 939 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_DIG1_ENCODER;
915 940
916 switch (radeon_encoder->encoder_id) { 941 if ((rdev->flags & RADEON_IS_IGP) &&
917 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY: 942 (radeon_encoder->encoder_id == ENCODER_OBJECT_ID_INTERNAL_UNIPHY)) {
918 if (rdev->flags & RADEON_IS_IGP) { 943 if (is_dp || (radeon_encoder->pixel_clock <= 165000)) {
919 if (radeon_encoder->pixel_clock > 165000) { 944 if (dig_connector->igp_lane_info & 0x1)
920 if (dig_connector->igp_lane_info & 0x3) 945 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_0_3;
921 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_0_7; 946 else if (dig_connector->igp_lane_info & 0x2)
922 else if (dig_connector->igp_lane_info & 0xc) 947 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_4_7;
923 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_8_15; 948 else if (dig_connector->igp_lane_info & 0x4)
924 } else { 949 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_8_11;
925 if (dig_connector->igp_lane_info & 0x1) 950 else if (dig_connector->igp_lane_info & 0x8)
926 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_0_3; 951 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_12_15;
927 else if (dig_connector->igp_lane_info & 0x2) 952 } else {
928 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_4_7; 953 if (dig_connector->igp_lane_info & 0x3)
929 else if (dig_connector->igp_lane_info & 0x4) 954 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_0_7;
930 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_8_11; 955 else if (dig_connector->igp_lane_info & 0xc)
931 else if (dig_connector->igp_lane_info & 0x8) 956 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_8_15;
932 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LANE_12_15;
933 }
934 } 957 }
935 break;
936 } 958 }
937 959
938 if (radeon_encoder->pixel_clock > 165000)
939 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_8LANE_LINK;
940
941 if (dig_connector->linkb) 960 if (dig_connector->linkb)
942 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LINKB; 961 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_LINKB;
943 else 962 else
@@ -948,6 +967,8 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
948 else if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) { 967 else if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) {
949 if (dig->coherent_mode) 968 if (dig->coherent_mode)
950 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_COHERENT; 969 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_COHERENT;
970 if (radeon_encoder->pixel_clock > 165000)
971 args.v1.ucConfig |= ATOM_TRANSMITTER_CONFIG_8LANE_LINK;
951 } 972 }
952 } 973 }
953 974
@@ -1054,16 +1075,25 @@ radeon_atom_encoder_dpms(struct drm_encoder *encoder, int mode)
1054 if (is_dig) { 1075 if (is_dig) {
1055 switch (mode) { 1076 switch (mode) {
1056 case DRM_MODE_DPMS_ON: 1077 case DRM_MODE_DPMS_ON:
1057 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE_OUTPUT, 0, 0); 1078 if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_DP) {
1058 {
1059 struct drm_connector *connector = radeon_get_connector_for_encoder(encoder); 1079 struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
1080
1060 dp_link_train(encoder, connector); 1081 dp_link_train(encoder, connector);
1082 if (ASIC_IS_DCE4(rdev))
1083 atombios_dig_encoder_setup(encoder, ATOM_ENCODER_CMD_DP_VIDEO_ON);
1061 } 1084 }
1085 if (!ASIC_IS_DCE4(rdev))
1086 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE_OUTPUT, 0, 0);
1062 break; 1087 break;
1063 case DRM_MODE_DPMS_STANDBY: 1088 case DRM_MODE_DPMS_STANDBY:
1064 case DRM_MODE_DPMS_SUSPEND: 1089 case DRM_MODE_DPMS_SUSPEND:
1065 case DRM_MODE_DPMS_OFF: 1090 case DRM_MODE_DPMS_OFF:
1066 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_DISABLE_OUTPUT, 0, 0); 1091 if (!ASIC_IS_DCE4(rdev))
1092 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_DISABLE_OUTPUT, 0, 0);
1093 if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_DP) {
1094 if (ASIC_IS_DCE4(rdev))
1095 atombios_dig_encoder_setup(encoder, ATOM_ENCODER_CMD_DP_VIDEO_OFF);
1096 }
1067 break; 1097 break;
1068 } 1098 }
1069 } else { 1099 } else {
@@ -1104,7 +1134,8 @@ atombios_set_encoder_crtc_source(struct drm_encoder *encoder)
1104 1134
1105 memset(&args, 0, sizeof(args)); 1135 memset(&args, 0, sizeof(args));
1106 1136
1107 atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev); 1137 if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev))
1138 return;
1108 1139
1109 switch (frev) { 1140 switch (frev) {
1110 case 1: 1141 case 1:
@@ -1216,6 +1247,9 @@ atombios_set_encoder_crtc_source(struct drm_encoder *encoder)
1216 } 1247 }
1217 1248
1218 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); 1249 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
1250
1251 /* update scratch regs with new routing */
1252 radeon_atombios_encoder_crtc_scratch_regs(encoder, radeon_crtc->crtc_id);
1219} 1253}
1220 1254
1221static void 1255static void
@@ -1326,20 +1360,10 @@ radeon_atom_encoder_mode_set(struct drm_encoder *encoder,
1326 struct drm_device *dev = encoder->dev; 1360 struct drm_device *dev = encoder->dev;
1327 struct radeon_device *rdev = dev->dev_private; 1361 struct radeon_device *rdev = dev->dev_private;
1328 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 1362 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
1329 struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc);
1330 1363
1331 if (radeon_encoder->active_device &
1332 (ATOM_DEVICE_DFP_SUPPORT | ATOM_DEVICE_LCD_SUPPORT)) {
1333 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
1334 if (dig)
1335 dig->dig_encoder = radeon_atom_pick_dig_encoder(encoder);
1336 }
1337 radeon_encoder->pixel_clock = adjusted_mode->clock; 1364 radeon_encoder->pixel_clock = adjusted_mode->clock;
1338 1365
1339 radeon_atombios_encoder_crtc_scratch_regs(encoder, radeon_crtc->crtc_id); 1366 if (ASIC_IS_AVIVO(rdev) && !ASIC_IS_DCE4(rdev)) {
1340 atombios_set_encoder_crtc_source(encoder);
1341
1342 if (ASIC_IS_AVIVO(rdev)) {
1343 if (radeon_encoder->active_device & (ATOM_DEVICE_CV_SUPPORT | ATOM_DEVICE_TV_SUPPORT)) 1367 if (radeon_encoder->active_device & (ATOM_DEVICE_CV_SUPPORT | ATOM_DEVICE_TV_SUPPORT))
1344 atombios_yuv_setup(encoder, true); 1368 atombios_yuv_setup(encoder, true);
1345 else 1369 else
@@ -1390,15 +1414,20 @@ radeon_atom_encoder_mode_set(struct drm_encoder *encoder,
1390 case ENCODER_OBJECT_ID_INTERNAL_DAC2: 1414 case ENCODER_OBJECT_ID_INTERNAL_DAC2:
1391 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2: 1415 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2:
1392 atombios_dac_setup(encoder, ATOM_ENABLE); 1416 atombios_dac_setup(encoder, ATOM_ENABLE);
1393 if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT | ATOM_DEVICE_CV_SUPPORT)) 1417 if (radeon_encoder->devices & (ATOM_DEVICE_TV_SUPPORT | ATOM_DEVICE_CV_SUPPORT)) {
1394 atombios_tv_setup(encoder, ATOM_ENABLE); 1418 if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT | ATOM_DEVICE_CV_SUPPORT))
1419 atombios_tv_setup(encoder, ATOM_ENABLE);
1420 else
1421 atombios_tv_setup(encoder, ATOM_DISABLE);
1422 }
1395 break; 1423 break;
1396 } 1424 }
1397 atombios_apply_encoder_quirks(encoder, adjusted_mode); 1425 atombios_apply_encoder_quirks(encoder, adjusted_mode);
1398 1426
1399 /* XXX */ 1427 if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_HDMI) {
1400 if (!ASIC_IS_DCE4(rdev)) 1428 r600_hdmi_enable(encoder);
1401 r600_hdmi_setmode(encoder, adjusted_mode); 1429 r600_hdmi_setmode(encoder, adjusted_mode);
1430 }
1402} 1431}
1403 1432
1404static bool 1433static bool
@@ -1418,7 +1447,8 @@ atombios_dac_load_detect(struct drm_encoder *encoder, struct drm_connector *conn
1418 1447
1419 memset(&args, 0, sizeof(args)); 1448 memset(&args, 0, sizeof(args));
1420 1449
1421 atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev); 1450 if (!atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev))
1451 return false;
1422 1452
1423 args.sDacload.ucMisc = 0; 1453 args.sDacload.ucMisc = 0;
1424 1454
@@ -1492,8 +1522,20 @@ radeon_atom_dac_detect(struct drm_encoder *encoder, struct drm_connector *connec
1492 1522
1493static void radeon_atom_encoder_prepare(struct drm_encoder *encoder) 1523static void radeon_atom_encoder_prepare(struct drm_encoder *encoder)
1494{ 1524{
1525 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
1526
1527 if (radeon_encoder->active_device &
1528 (ATOM_DEVICE_DFP_SUPPORT | ATOM_DEVICE_LCD_SUPPORT)) {
1529 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
1530 if (dig)
1531 dig->dig_encoder = radeon_atom_pick_dig_encoder(encoder);
1532 }
1533
1495 radeon_atom_output_lock(encoder, true); 1534 radeon_atom_output_lock(encoder, true);
1496 radeon_atom_encoder_dpms(encoder, DRM_MODE_DPMS_OFF); 1535 radeon_atom_encoder_dpms(encoder, DRM_MODE_DPMS_OFF);
1536
1537 /* this is needed for the pll/ss setup to work correctly in some cases */
1538 atombios_set_encoder_crtc_source(encoder);
1497} 1539}
1498 1540
1499static void radeon_atom_encoder_commit(struct drm_encoder *encoder) 1541static void radeon_atom_encoder_commit(struct drm_encoder *encoder)
@@ -1509,6 +1551,8 @@ static void radeon_atom_encoder_disable(struct drm_encoder *encoder)
1509 radeon_atom_encoder_dpms(encoder, DRM_MODE_DPMS_OFF); 1551 radeon_atom_encoder_dpms(encoder, DRM_MODE_DPMS_OFF);
1510 1552
1511 if (radeon_encoder_is_digital(encoder)) { 1553 if (radeon_encoder_is_digital(encoder)) {
1554 if (atombios_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_HDMI)
1555 r600_hdmi_disable(encoder);
1512 dig = radeon_encoder->enc_priv; 1556 dig = radeon_encoder->enc_priv;
1513 dig->dig_encoder = -1; 1557 dig->dig_encoder = -1;
1514 } 1558 }
@@ -1549,12 +1593,14 @@ static const struct drm_encoder_funcs radeon_atom_enc_funcs = {
1549struct radeon_encoder_atom_dac * 1593struct radeon_encoder_atom_dac *
1550radeon_atombios_set_dac_info(struct radeon_encoder *radeon_encoder) 1594radeon_atombios_set_dac_info(struct radeon_encoder *radeon_encoder)
1551{ 1595{
1596 struct drm_device *dev = radeon_encoder->base.dev;
1597 struct radeon_device *rdev = dev->dev_private;
1552 struct radeon_encoder_atom_dac *dac = kzalloc(sizeof(struct radeon_encoder_atom_dac), GFP_KERNEL); 1598 struct radeon_encoder_atom_dac *dac = kzalloc(sizeof(struct radeon_encoder_atom_dac), GFP_KERNEL);
1553 1599
1554 if (!dac) 1600 if (!dac)
1555 return NULL; 1601 return NULL;
1556 1602
1557 dac->tv_std = TV_STD_NTSC; 1603 dac->tv_std = radeon_atombios_get_tv_info(rdev);
1558 return dac; 1604 return dac;
1559} 1605}
1560 1606
@@ -1632,6 +1678,7 @@ radeon_add_atom_encoder(struct drm_device *dev, uint32_t encoder_id, uint32_t su
1632 break; 1678 break;
1633 case ENCODER_OBJECT_ID_INTERNAL_DAC1: 1679 case ENCODER_OBJECT_ID_INTERNAL_DAC1:
1634 drm_encoder_init(dev, encoder, &radeon_atom_enc_funcs, DRM_MODE_ENCODER_DAC); 1680 drm_encoder_init(dev, encoder, &radeon_atom_enc_funcs, DRM_MODE_ENCODER_DAC);
1681 radeon_encoder->enc_priv = radeon_atombios_set_dac_info(radeon_encoder);
1635 drm_encoder_helper_add(encoder, &radeon_atom_dac_helper_funcs); 1682 drm_encoder_helper_add(encoder, &radeon_atom_dac_helper_funcs);
1636 break; 1683 break;
1637 case ENCODER_OBJECT_ID_INTERNAL_DAC2: 1684 case ENCODER_OBJECT_ID_INTERNAL_DAC2:
@@ -1659,6 +1706,4 @@ radeon_add_atom_encoder(struct drm_device *dev, uint32_t encoder_id, uint32_t su
1659 drm_encoder_helper_add(encoder, &radeon_atom_dig_helper_funcs); 1706 drm_encoder_helper_add(encoder, &radeon_atom_dig_helper_funcs);
1660 break; 1707 break;
1661 } 1708 }
1662
1663 r600_hdmi_init(encoder);
1664} 1709}
diff --git a/drivers/gpu/drm/radeon/radeon_family.h b/drivers/gpu/drm/radeon/radeon_family.h
index 93c7d5d4191..e329066dcab 100644
--- a/drivers/gpu/drm/radeon/radeon_family.h
+++ b/drivers/gpu/drm/radeon/radeon_family.h
@@ -36,7 +36,7 @@
36 * Radeon chip families 36 * Radeon chip families
37 */ 37 */
38enum radeon_family { 38enum radeon_family {
39 CHIP_R100, 39 CHIP_R100 = 0,
40 CHIP_RV100, 40 CHIP_RV100,
41 CHIP_RS100, 41 CHIP_RS100,
42 CHIP_RV200, 42 CHIP_RV200,
@@ -99,4 +99,5 @@ enum radeon_chip_flags {
99 RADEON_IS_PCI = 0x00800000UL, 99 RADEON_IS_PCI = 0x00800000UL,
100 RADEON_IS_IGPGART = 0x01000000UL, 100 RADEON_IS_IGPGART = 0x01000000UL,
101}; 101};
102
102#endif 103#endif
diff --git a/drivers/gpu/drm/radeon/radeon_fb.c b/drivers/gpu/drm/radeon/radeon_fb.c
index 8fccbf29235..9ac57a09784 100644
--- a/drivers/gpu/drm/radeon/radeon_fb.c
+++ b/drivers/gpu/drm/radeon/radeon_fb.c
@@ -28,6 +28,7 @@
28 */ 28 */
29 29
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/slab.h>
31#include <linux/fb.h> 32#include <linux/fb.h>
32 33
33#include "drmP.h" 34#include "drmP.h"
diff --git a/drivers/gpu/drm/radeon/radeon_fence.c b/drivers/gpu/drm/radeon/radeon_fence.c
index 8495d4e32e1..d90f95b405c 100644
--- a/drivers/gpu/drm/radeon/radeon_fence.c
+++ b/drivers/gpu/drm/radeon/radeon_fence.c
@@ -33,6 +33,7 @@
33#include <linux/wait.h> 33#include <linux/wait.h>
34#include <linux/list.h> 34#include <linux/list.h>
35#include <linux/kref.h> 35#include <linux/kref.h>
36#include <linux/slab.h>
36#include "drmP.h" 37#include "drmP.h"
37#include "drm.h" 38#include "drm.h"
38#include "radeon_reg.h" 39#include "radeon_reg.h"
diff --git a/drivers/gpu/drm/radeon/radeon_i2c.c b/drivers/gpu/drm/radeon/radeon_i2c.c
index 4ae50c19589..5def6f5dff3 100644
--- a/drivers/gpu/drm/radeon/radeon_i2c.c
+++ b/drivers/gpu/drm/radeon/radeon_i2c.c
@@ -59,6 +59,7 @@ bool radeon_ddc_probe(struct radeon_connector *radeon_connector)
59 return false; 59 return false;
60} 60}
61 61
62/* bit banging i2c */
62 63
63static void radeon_i2c_do_lock(struct radeon_i2c_chan *i2c, int lock_state) 64static void radeon_i2c_do_lock(struct radeon_i2c_chan *i2c, int lock_state)
64{ 65{
@@ -181,13 +182,30 @@ static void set_data(void *i2c_priv, int data)
181 WREG32(rec->en_data_reg, val); 182 WREG32(rec->en_data_reg, val);
182} 183}
183 184
185static int pre_xfer(struct i2c_adapter *i2c_adap)
186{
187 struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap);
188
189 radeon_i2c_do_lock(i2c, 1);
190
191 return 0;
192}
193
194static void post_xfer(struct i2c_adapter *i2c_adap)
195{
196 struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap);
197
198 radeon_i2c_do_lock(i2c, 0);
199}
200
201/* hw i2c */
202
184static u32 radeon_get_i2c_prescale(struct radeon_device *rdev) 203static u32 radeon_get_i2c_prescale(struct radeon_device *rdev)
185{ 204{
186 struct radeon_pll *spll = &rdev->clock.spll;
187 u32 sclk = radeon_get_engine_clock(rdev); 205 u32 sclk = radeon_get_engine_clock(rdev);
188 u32 prescale = 0; 206 u32 prescale = 0;
189 u32 n, m; 207 u32 nm;
190 u8 loop; 208 u8 n, m, loop;
191 int i2c_clock; 209 int i2c_clock;
192 210
193 switch (rdev->family) { 211 switch (rdev->family) {
@@ -203,13 +221,15 @@ static u32 radeon_get_i2c_prescale(struct radeon_device *rdev)
203 case CHIP_R300: 221 case CHIP_R300:
204 case CHIP_R350: 222 case CHIP_R350:
205 case CHIP_RV350: 223 case CHIP_RV350:
206 n = (spll->reference_freq) / (4 * 6); 224 i2c_clock = 60;
225 nm = (sclk * 10) / (i2c_clock * 4);
207 for (loop = 1; loop < 255; loop++) { 226 for (loop = 1; loop < 255; loop++) {
208 if ((loop * (loop - 1)) > n) 227 if ((nm / loop) < loop)
209 break; 228 break;
210 } 229 }
211 m = loop - 1; 230 n = loop - 1;
212 prescale = m | (loop << 8); 231 m = loop - 2;
232 prescale = m | (n << 8);
213 break; 233 break;
214 case CHIP_RV380: 234 case CHIP_RV380:
215 case CHIP_RS400: 235 case CHIP_RS400:
@@ -217,7 +237,6 @@ static u32 radeon_get_i2c_prescale(struct radeon_device *rdev)
217 case CHIP_R420: 237 case CHIP_R420:
218 case CHIP_R423: 238 case CHIP_R423:
219 case CHIP_RV410: 239 case CHIP_RV410:
220 sclk = radeon_get_engine_clock(rdev);
221 prescale = (((sclk * 10)/(4 * 128 * 100) + 1) << 8) + 128; 240 prescale = (((sclk * 10)/(4 * 128 * 100) + 1) << 8) + 128;
222 break; 241 break;
223 case CHIP_RS600: 242 case CHIP_RS600:
@@ -232,7 +251,6 @@ static u32 radeon_get_i2c_prescale(struct radeon_device *rdev)
232 case CHIP_RV570: 251 case CHIP_RV570:
233 case CHIP_R580: 252 case CHIP_R580:
234 i2c_clock = 50; 253 i2c_clock = 50;
235 sclk = radeon_get_engine_clock(rdev);
236 if (rdev->family == CHIP_R520) 254 if (rdev->family == CHIP_R520)
237 prescale = (127 << 8) + ((sclk * 10) / (4 * 127 * i2c_clock)); 255 prescale = (127 << 8) + ((sclk * 10) / (4 * 127 * i2c_clock));
238 else 256 else
@@ -291,6 +309,7 @@ static int r100_hw_i2c_xfer(struct i2c_adapter *i2c_adap,
291 prescale = radeon_get_i2c_prescale(rdev); 309 prescale = radeon_get_i2c_prescale(rdev);
292 310
293 reg = ((prescale << RADEON_I2C_PRESCALE_SHIFT) | 311 reg = ((prescale << RADEON_I2C_PRESCALE_SHIFT) |
312 RADEON_I2C_DRIVE_EN |
294 RADEON_I2C_START | 313 RADEON_I2C_START |
295 RADEON_I2C_STOP | 314 RADEON_I2C_STOP |
296 RADEON_I2C_GO); 315 RADEON_I2C_GO);
@@ -757,26 +776,13 @@ done:
757 return ret; 776 return ret;
758} 777}
759 778
760static int radeon_sw_i2c_xfer(struct i2c_adapter *i2c_adap, 779static int radeon_hw_i2c_xfer(struct i2c_adapter *i2c_adap,
761 struct i2c_msg *msgs, int num) 780 struct i2c_msg *msgs, int num)
762{ 781{
763 struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap); 782 struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap);
764 int ret;
765
766 radeon_i2c_do_lock(i2c, 1);
767 ret = i2c_transfer(&i2c->algo.radeon.bit_adapter, msgs, num);
768 radeon_i2c_do_lock(i2c, 0);
769
770 return ret;
771}
772
773static int radeon_i2c_xfer(struct i2c_adapter *i2c_adap,
774 struct i2c_msg *msgs, int num)
775{
776 struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap);
777 struct radeon_device *rdev = i2c->dev->dev_private; 783 struct radeon_device *rdev = i2c->dev->dev_private;
778 struct radeon_i2c_bus_rec *rec = &i2c->rec; 784 struct radeon_i2c_bus_rec *rec = &i2c->rec;
779 int ret; 785 int ret = 0;
780 786
781 switch (rdev->family) { 787 switch (rdev->family) {
782 case CHIP_R100: 788 case CHIP_R100:
@@ -797,16 +803,12 @@ static int radeon_i2c_xfer(struct i2c_adapter *i2c_adap,
797 case CHIP_RV410: 803 case CHIP_RV410:
798 case CHIP_RS400: 804 case CHIP_RS400:
799 case CHIP_RS480: 805 case CHIP_RS480:
800 if (rec->hw_capable) 806 ret = r100_hw_i2c_xfer(i2c_adap, msgs, num);
801 ret = r100_hw_i2c_xfer(i2c_adap, msgs, num);
802 else
803 ret = radeon_sw_i2c_xfer(i2c_adap, msgs, num);
804 break; 807 break;
805 case CHIP_RS600: 808 case CHIP_RS600:
806 case CHIP_RS690: 809 case CHIP_RS690:
807 case CHIP_RS740: 810 case CHIP_RS740:
808 /* XXX fill in hw i2c implementation */ 811 /* XXX fill in hw i2c implementation */
809 ret = radeon_sw_i2c_xfer(i2c_adap, msgs, num);
810 break; 812 break;
811 case CHIP_RV515: 813 case CHIP_RV515:
812 case CHIP_R520: 814 case CHIP_R520:
@@ -814,20 +816,16 @@ static int radeon_i2c_xfer(struct i2c_adapter *i2c_adap,
814 case CHIP_RV560: 816 case CHIP_RV560:
815 case CHIP_RV570: 817 case CHIP_RV570:
816 case CHIP_R580: 818 case CHIP_R580:
817 if (rec->hw_capable) { 819 if (rec->mm_i2c)
818 if (rec->mm_i2c) 820 ret = r100_hw_i2c_xfer(i2c_adap, msgs, num);
819 ret = r100_hw_i2c_xfer(i2c_adap, msgs, num); 821 else
820 else 822 ret = r500_hw_i2c_xfer(i2c_adap, msgs, num);
821 ret = r500_hw_i2c_xfer(i2c_adap, msgs, num);
822 } else
823 ret = radeon_sw_i2c_xfer(i2c_adap, msgs, num);
824 break; 823 break;
825 case CHIP_R600: 824 case CHIP_R600:
826 case CHIP_RV610: 825 case CHIP_RV610:
827 case CHIP_RV630: 826 case CHIP_RV630:
828 case CHIP_RV670: 827 case CHIP_RV670:
829 /* XXX fill in hw i2c implementation */ 828 /* XXX fill in hw i2c implementation */
830 ret = radeon_sw_i2c_xfer(i2c_adap, msgs, num);
831 break; 829 break;
832 case CHIP_RV620: 830 case CHIP_RV620:
833 case CHIP_RV635: 831 case CHIP_RV635:
@@ -838,7 +836,6 @@ static int radeon_i2c_xfer(struct i2c_adapter *i2c_adap,
838 case CHIP_RV710: 836 case CHIP_RV710:
839 case CHIP_RV740: 837 case CHIP_RV740:
840 /* XXX fill in hw i2c implementation */ 838 /* XXX fill in hw i2c implementation */
841 ret = radeon_sw_i2c_xfer(i2c_adap, msgs, num);
842 break; 839 break;
843 case CHIP_CEDAR: 840 case CHIP_CEDAR:
844 case CHIP_REDWOOD: 841 case CHIP_REDWOOD:
@@ -846,7 +843,6 @@ static int radeon_i2c_xfer(struct i2c_adapter *i2c_adap,
846 case CHIP_CYPRESS: 843 case CHIP_CYPRESS:
847 case CHIP_HEMLOCK: 844 case CHIP_HEMLOCK:
848 /* XXX fill in hw i2c implementation */ 845 /* XXX fill in hw i2c implementation */
849 ret = radeon_sw_i2c_xfer(i2c_adap, msgs, num);
850 break; 846 break;
851 default: 847 default:
852 DRM_ERROR("i2c: unhandled radeon chip\n"); 848 DRM_ERROR("i2c: unhandled radeon chip\n");
@@ -857,20 +853,21 @@ static int radeon_i2c_xfer(struct i2c_adapter *i2c_adap,
857 return ret; 853 return ret;
858} 854}
859 855
860static u32 radeon_i2c_func(struct i2c_adapter *adap) 856static u32 radeon_hw_i2c_func(struct i2c_adapter *adap)
861{ 857{
862 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; 858 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
863} 859}
864 860
865static const struct i2c_algorithm radeon_i2c_algo = { 861static const struct i2c_algorithm radeon_i2c_algo = {
866 .master_xfer = radeon_i2c_xfer, 862 .master_xfer = radeon_hw_i2c_xfer,
867 .functionality = radeon_i2c_func, 863 .functionality = radeon_hw_i2c_func,
868}; 864};
869 865
870struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev, 866struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev,
871 struct radeon_i2c_bus_rec *rec, 867 struct radeon_i2c_bus_rec *rec,
872 const char *name) 868 const char *name)
873{ 869{
870 struct radeon_device *rdev = dev->dev_private;
874 struct radeon_i2c_chan *i2c; 871 struct radeon_i2c_chan *i2c;
875 int ret; 872 int ret;
876 873
@@ -878,37 +875,43 @@ struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev,
878 if (i2c == NULL) 875 if (i2c == NULL)
879 return NULL; 876 return NULL;
880 877
881 /* set the internal bit adapter */
882 i2c->algo.radeon.bit_adapter.owner = THIS_MODULE;
883 i2c_set_adapdata(&i2c->algo.radeon.bit_adapter, i2c);
884 sprintf(i2c->algo.radeon.bit_adapter.name, "Radeon internal i2c bit bus %s", name);
885 i2c->algo.radeon.bit_adapter.algo_data = &i2c->algo.radeon.bit_data;
886 i2c->algo.radeon.bit_data.setsda = set_data;
887 i2c->algo.radeon.bit_data.setscl = set_clock;
888 i2c->algo.radeon.bit_data.getsda = get_data;
889 i2c->algo.radeon.bit_data.getscl = get_clock;
890 i2c->algo.radeon.bit_data.udelay = 20;
891 /* vesa says 2.2 ms is enough, 1 jiffy doesn't seem to always
892 * make this, 2 jiffies is a lot more reliable */
893 i2c->algo.radeon.bit_data.timeout = 2;
894 i2c->algo.radeon.bit_data.data = i2c;
895 ret = i2c_bit_add_bus(&i2c->algo.radeon.bit_adapter);
896 if (ret) {
897 DRM_ERROR("Failed to register internal bit i2c %s\n", name);
898 goto out_free;
899 }
900 /* set the radeon i2c adapter */
901 i2c->dev = dev;
902 i2c->rec = *rec; 878 i2c->rec = *rec;
903 i2c->adapter.owner = THIS_MODULE; 879 i2c->adapter.owner = THIS_MODULE;
880 i2c->dev = dev;
904 i2c_set_adapdata(&i2c->adapter, i2c); 881 i2c_set_adapdata(&i2c->adapter, i2c);
905 sprintf(i2c->adapter.name, "Radeon i2c %s", name); 882 if (rec->mm_i2c ||
906 i2c->adapter.algo_data = &i2c->algo.radeon; 883 (rec->hw_capable &&
907 i2c->adapter.algo = &radeon_i2c_algo; 884 radeon_hw_i2c &&
908 ret = i2c_add_adapter(&i2c->adapter); 885 ((rdev->family <= CHIP_RS480) ||
909 if (ret) { 886 ((rdev->family >= CHIP_RV515) && (rdev->family <= CHIP_R580))))) {
910 DRM_ERROR("Failed to register i2c %s\n", name); 887 /* set the radeon hw i2c adapter */
911 goto out_free; 888 sprintf(i2c->adapter.name, "Radeon i2c hw bus %s", name);
889 i2c->adapter.algo = &radeon_i2c_algo;
890 ret = i2c_add_adapter(&i2c->adapter);
891 if (ret) {
892 DRM_ERROR("Failed to register hw i2c %s\n", name);
893 goto out_free;
894 }
895 } else {
896 /* set the radeon bit adapter */
897 sprintf(i2c->adapter.name, "Radeon i2c bit bus %s", name);
898 i2c->adapter.algo_data = &i2c->algo.bit;
899 i2c->algo.bit.pre_xfer = pre_xfer;
900 i2c->algo.bit.post_xfer = post_xfer;
901 i2c->algo.bit.setsda = set_data;
902 i2c->algo.bit.setscl = set_clock;
903 i2c->algo.bit.getsda = get_data;
904 i2c->algo.bit.getscl = get_clock;
905 i2c->algo.bit.udelay = 20;
906 /* vesa says 2.2 ms is enough, 1 jiffy doesn't seem to always
907 * make this, 2 jiffies is a lot more reliable */
908 i2c->algo.bit.timeout = 2;
909 i2c->algo.bit.data = i2c;
910 ret = i2c_bit_add_bus(&i2c->adapter);
911 if (ret) {
912 DRM_ERROR("Failed to register bit i2c %s\n", name);
913 goto out_free;
914 }
912 } 915 }
913 916
914 return i2c; 917 return i2c;
@@ -953,16 +956,6 @@ void radeon_i2c_destroy(struct radeon_i2c_chan *i2c)
953{ 956{
954 if (!i2c) 957 if (!i2c)
955 return; 958 return;
956 i2c_del_adapter(&i2c->algo.radeon.bit_adapter);
957 i2c_del_adapter(&i2c->adapter);
958 kfree(i2c);
959}
960
961void radeon_i2c_destroy_dp(struct radeon_i2c_chan *i2c)
962{
963 if (!i2c)
964 return;
965
966 i2c_del_adapter(&i2c->adapter); 959 i2c_del_adapter(&i2c->adapter);
967 kfree(i2c); 960 kfree(i2c);
968} 961}
diff --git a/drivers/gpu/drm/radeon/radeon_irq_kms.c b/drivers/gpu/drm/radeon/radeon_irq_kms.c
index 3cfd60fd008..a212041e8b0 100644
--- a/drivers/gpu/drm/radeon/radeon_irq_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_irq_kms.c
@@ -67,9 +67,10 @@ void radeon_driver_irq_preinstall_kms(struct drm_device *dev)
67 67
68 /* Disable *all* interrupts */ 68 /* Disable *all* interrupts */
69 rdev->irq.sw_int = false; 69 rdev->irq.sw_int = false;
70 for (i = 0; i < 2; i++) { 70 for (i = 0; i < rdev->num_crtc; i++)
71 rdev->irq.crtc_vblank_int[i] = false; 71 rdev->irq.crtc_vblank_int[i] = false;
72 } 72 for (i = 0; i < 6; i++)
73 rdev->irq.hpd[i] = false;
73 radeon_irq_set(rdev); 74 radeon_irq_set(rdev);
74 /* Clear bits */ 75 /* Clear bits */
75 radeon_irq_process(rdev); 76 radeon_irq_process(rdev);
@@ -95,34 +96,29 @@ void radeon_driver_irq_uninstall_kms(struct drm_device *dev)
95 } 96 }
96 /* Disable *all* interrupts */ 97 /* Disable *all* interrupts */
97 rdev->irq.sw_int = false; 98 rdev->irq.sw_int = false;
98 for (i = 0; i < 2; i++) { 99 for (i = 0; i < rdev->num_crtc; i++)
99 rdev->irq.crtc_vblank_int[i] = false; 100 rdev->irq.crtc_vblank_int[i] = false;
101 for (i = 0; i < 6; i++)
100 rdev->irq.hpd[i] = false; 102 rdev->irq.hpd[i] = false;
101 }
102 radeon_irq_set(rdev); 103 radeon_irq_set(rdev);
103} 104}
104 105
105int radeon_irq_kms_init(struct radeon_device *rdev) 106int radeon_irq_kms_init(struct radeon_device *rdev)
106{ 107{
107 int r = 0; 108 int r = 0;
108 int num_crtc = 2;
109 109
110 if (rdev->flags & RADEON_SINGLE_CRTC)
111 num_crtc = 1;
112 spin_lock_init(&rdev->irq.sw_lock); 110 spin_lock_init(&rdev->irq.sw_lock);
113 r = drm_vblank_init(rdev->ddev, num_crtc); 111 r = drm_vblank_init(rdev->ddev, rdev->num_crtc);
114 if (r) { 112 if (r) {
115 return r; 113 return r;
116 } 114 }
117 /* enable msi */ 115 /* enable msi */
118 rdev->msi_enabled = 0; 116 rdev->msi_enabled = 0;
119 /* MSIs don't seem to work on my rs780; 117 /* MSIs don't seem to work reliably on all IGP
120 * not sure about rs880 or other rs780s. 118 * chips. Disable MSI on them for now.
121 * Needs more investigation.
122 */ 119 */
123 if ((rdev->family >= CHIP_RV380) && 120 if ((rdev->family >= CHIP_RV380) &&
124 (rdev->family != CHIP_RS780) && 121 (!(rdev->flags & RADEON_IS_IGP))) {
125 (rdev->family != CHIP_RS880)) {
126 int ret = pci_enable_msi(rdev->pdev); 122 int ret = pci_enable_msi(rdev->pdev);
127 if (!ret) { 123 if (!ret) {
128 rdev->msi_enabled = 1; 124 rdev->msi_enabled = 1;
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
index 20ec276e759..c633319f98e 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -31,6 +31,7 @@
31#include "radeon_drm.h" 31#include "radeon_drm.h"
32 32
33#include <linux/vga_switcheroo.h> 33#include <linux/vga_switcheroo.h>
34#include <linux/slab.h>
34 35
35int radeon_driver_unload_kms(struct drm_device *dev) 36int radeon_driver_unload_kms(struct drm_device *dev)
36{ 37{
@@ -164,7 +165,7 @@ u32 radeon_get_vblank_counter_kms(struct drm_device *dev, int crtc)
164{ 165{
165 struct radeon_device *rdev = dev->dev_private; 166 struct radeon_device *rdev = dev->dev_private;
166 167
167 if (crtc < 0 || crtc > 1) { 168 if (crtc < 0 || crtc >= rdev->num_crtc) {
168 DRM_ERROR("Invalid crtc %d\n", crtc); 169 DRM_ERROR("Invalid crtc %d\n", crtc);
169 return -EINVAL; 170 return -EINVAL;
170 } 171 }
@@ -176,7 +177,7 @@ int radeon_enable_vblank_kms(struct drm_device *dev, int crtc)
176{ 177{
177 struct radeon_device *rdev = dev->dev_private; 178 struct radeon_device *rdev = dev->dev_private;
178 179
179 if (crtc < 0 || crtc > 1) { 180 if (crtc < 0 || crtc >= rdev->num_crtc) {
180 DRM_ERROR("Invalid crtc %d\n", crtc); 181 DRM_ERROR("Invalid crtc %d\n", crtc);
181 return -EINVAL; 182 return -EINVAL;
182 } 183 }
@@ -190,7 +191,7 @@ void radeon_disable_vblank_kms(struct drm_device *dev, int crtc)
190{ 191{
191 struct radeon_device *rdev = dev->dev_private; 192 struct radeon_device *rdev = dev->dev_private;
192 193
193 if (crtc < 0 || crtc > 1) { 194 if (crtc < 0 || crtc >= rdev->num_crtc) {
194 DRM_ERROR("Invalid crtc %d\n", crtc); 195 DRM_ERROR("Invalid crtc %d\n", crtc);
195 return; 196 return;
196 } 197 }
diff --git a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
index df23d6a01d0..88865e38fe3 100644
--- a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
+++ b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
@@ -603,6 +603,10 @@ static bool radeon_set_crtc_timing(struct drm_crtc *crtc, struct drm_display_mod
603 ? RADEON_CRTC2_INTERLACE_EN 603 ? RADEON_CRTC2_INTERLACE_EN
604 : 0)); 604 : 0));
605 605
606 /* rs4xx chips seem to like to have the crtc enabled when the timing is set */
607 if ((rdev->family == CHIP_RS400) || (rdev->family == CHIP_RS480))
608 crtc2_gen_cntl |= RADEON_CRTC2_EN;
609
606 disp2_merge_cntl = RREG32(RADEON_DISP2_MERGE_CNTL); 610 disp2_merge_cntl = RREG32(RADEON_DISP2_MERGE_CNTL);
607 disp2_merge_cntl &= ~RADEON_DISP2_RGB_OFFSET_EN; 611 disp2_merge_cntl &= ~RADEON_DISP2_RGB_OFFSET_EN;
608 612
@@ -630,6 +634,10 @@ static bool radeon_set_crtc_timing(struct drm_crtc *crtc, struct drm_display_mod
630 ? RADEON_CRTC_INTERLACE_EN 634 ? RADEON_CRTC_INTERLACE_EN
631 : 0)); 635 : 0));
632 636
637 /* rs4xx chips seem to like to have the crtc enabled when the timing is set */
638 if ((rdev->family == CHIP_RS400) || (rdev->family == CHIP_RS480))
639 crtc_gen_cntl |= RADEON_CRTC_EN;
640
633 crtc_ext_cntl = RREG32(RADEON_CRTC_EXT_CNTL); 641 crtc_ext_cntl = RREG32(RADEON_CRTC_EXT_CNTL);
634 crtc_ext_cntl |= (RADEON_XCRT_CNT_EN | 642 crtc_ext_cntl |= (RADEON_XCRT_CNT_EN |
635 RADEON_CRTC_VSYNC_DIS | 643 RADEON_CRTC_VSYNC_DIS |
diff --git a/drivers/gpu/drm/radeon/radeon_legacy_encoders.c b/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
index cf389ce50a8..0274abe17ad 100644
--- a/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
+++ b/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
@@ -228,16 +228,8 @@ static bool radeon_legacy_mode_fixup(struct drm_encoder *encoder,
228 drm_mode_set_crtcinfo(adjusted_mode, 0); 228 drm_mode_set_crtcinfo(adjusted_mode, 0);
229 229
230 /* get the native mode for LVDS */ 230 /* get the native mode for LVDS */
231 if (radeon_encoder->active_device & (ATOM_DEVICE_LCD_SUPPORT)) { 231 if (radeon_encoder->active_device & (ATOM_DEVICE_LCD_SUPPORT))
232 struct drm_display_mode *native_mode = &radeon_encoder->native_mode; 232 radeon_panel_mode_fixup(encoder, adjusted_mode);
233 int mode_id = adjusted_mode->base.id;
234 *adjusted_mode = *native_mode;
235 adjusted_mode->hdisplay = mode->hdisplay;
236 adjusted_mode->vdisplay = mode->vdisplay;
237 adjusted_mode->crtc_hdisplay = mode->hdisplay;
238 adjusted_mode->crtc_vdisplay = mode->vdisplay;
239 adjusted_mode->base.id = mode_id;
240 }
241 233
242 return true; 234 return true;
243} 235}
@@ -830,8 +822,8 @@ static void radeon_legacy_tv_dac_dpms(struct drm_encoder *encoder, int mode)
830 crtc2_gen_cntl &= ~RADEON_CRTC2_CRT2_ON; 822 crtc2_gen_cntl &= ~RADEON_CRTC2_CRT2_ON;
831 823
832 if (rdev->family == CHIP_R420 || 824 if (rdev->family == CHIP_R420 ||
833 rdev->family == CHIP_R423 || 825 rdev->family == CHIP_R423 ||
834 rdev->family == CHIP_RV410) 826 rdev->family == CHIP_RV410)
835 tv_dac_cntl |= (R420_TV_DAC_RDACPD | 827 tv_dac_cntl |= (R420_TV_DAC_RDACPD |
836 R420_TV_DAC_GDACPD | 828 R420_TV_DAC_GDACPD |
837 R420_TV_DAC_BDACPD | 829 R420_TV_DAC_BDACPD |
@@ -907,35 +899,43 @@ static void radeon_legacy_tv_dac_mode_set(struct drm_encoder *encoder,
907 if (rdev->family != CHIP_R200) { 899 if (rdev->family != CHIP_R200) {
908 tv_dac_cntl = RREG32(RADEON_TV_DAC_CNTL); 900 tv_dac_cntl = RREG32(RADEON_TV_DAC_CNTL);
909 if (rdev->family == CHIP_R420 || 901 if (rdev->family == CHIP_R420 ||
910 rdev->family == CHIP_R423 || 902 rdev->family == CHIP_R423 ||
911 rdev->family == CHIP_RV410) { 903 rdev->family == CHIP_RV410) {
912 tv_dac_cntl &= ~(RADEON_TV_DAC_STD_MASK | 904 tv_dac_cntl &= ~(RADEON_TV_DAC_STD_MASK |
913 RADEON_TV_DAC_BGADJ_MASK | 905 RADEON_TV_DAC_BGADJ_MASK |
914 R420_TV_DAC_DACADJ_MASK | 906 R420_TV_DAC_DACADJ_MASK |
915 R420_TV_DAC_RDACPD | 907 R420_TV_DAC_RDACPD |
916 R420_TV_DAC_GDACPD | 908 R420_TV_DAC_GDACPD |
917 R420_TV_DAC_BDACPD | 909 R420_TV_DAC_BDACPD |
918 R420_TV_DAC_TVENABLE); 910 R420_TV_DAC_TVENABLE);
919 } else { 911 } else {
920 tv_dac_cntl &= ~(RADEON_TV_DAC_STD_MASK | 912 tv_dac_cntl &= ~(RADEON_TV_DAC_STD_MASK |
921 RADEON_TV_DAC_BGADJ_MASK | 913 RADEON_TV_DAC_BGADJ_MASK |
922 RADEON_TV_DAC_DACADJ_MASK | 914 RADEON_TV_DAC_DACADJ_MASK |
923 RADEON_TV_DAC_RDACPD | 915 RADEON_TV_DAC_RDACPD |
924 RADEON_TV_DAC_GDACPD | 916 RADEON_TV_DAC_GDACPD |
925 RADEON_TV_DAC_BDACPD); 917 RADEON_TV_DAC_BDACPD);
926 } 918 }
927 919
928 /* FIXME TV */ 920 tv_dac_cntl |= RADEON_TV_DAC_NBLANK | RADEON_TV_DAC_NHOLD;
929 if (tv_dac) { 921
930 struct radeon_encoder_tv_dac *tv_dac = radeon_encoder->enc_priv; 922 if (is_tv) {
931 tv_dac_cntl |= (RADEON_TV_DAC_NBLANK | 923 if (tv_dac->tv_std == TV_STD_NTSC ||
932 RADEON_TV_DAC_NHOLD | 924 tv_dac->tv_std == TV_STD_NTSC_J ||
933 RADEON_TV_DAC_STD_PS2 | 925 tv_dac->tv_std == TV_STD_PAL_M ||
934 tv_dac->ps2_tvdac_adj); 926 tv_dac->tv_std == TV_STD_PAL_60)
927 tv_dac_cntl |= tv_dac->ntsc_tvdac_adj;
928 else
929 tv_dac_cntl |= tv_dac->pal_tvdac_adj;
930
931 if (tv_dac->tv_std == TV_STD_NTSC ||
932 tv_dac->tv_std == TV_STD_NTSC_J)
933 tv_dac_cntl |= RADEON_TV_DAC_STD_NTSC;
934 else
935 tv_dac_cntl |= RADEON_TV_DAC_STD_PAL;
935 } else 936 } else
936 tv_dac_cntl |= (RADEON_TV_DAC_NBLANK | 937 tv_dac_cntl |= (RADEON_TV_DAC_STD_PS2 |
937 RADEON_TV_DAC_NHOLD | 938 tv_dac->ps2_tvdac_adj);
938 RADEON_TV_DAC_STD_PS2);
939 939
940 WREG32(RADEON_TV_DAC_CNTL, tv_dac_cntl); 940 WREG32(RADEON_TV_DAC_CNTL, tv_dac_cntl);
941 } 941 }
diff --git a/drivers/gpu/drm/radeon/radeon_legacy_tv.c b/drivers/gpu/drm/radeon/radeon_legacy_tv.c
index 417684daef4..f2ed27c8055 100644
--- a/drivers/gpu/drm/radeon/radeon_legacy_tv.c
+++ b/drivers/gpu/drm/radeon/radeon_legacy_tv.c
@@ -57,6 +57,10 @@
57#define NTSC_TV_PLL_N_14 693 57#define NTSC_TV_PLL_N_14 693
58#define NTSC_TV_PLL_P_14 7 58#define NTSC_TV_PLL_P_14 7
59 59
60#define PAL_TV_PLL_M_14 19
61#define PAL_TV_PLL_N_14 353
62#define PAL_TV_PLL_P_14 5
63
60#define VERT_LEAD_IN_LINES 2 64#define VERT_LEAD_IN_LINES 2
61#define FRAC_BITS 0xe 65#define FRAC_BITS 0xe
62#define FRAC_MASK 0x3fff 66#define FRAC_MASK 0x3fff
@@ -205,9 +209,24 @@ static const struct radeon_tv_mode_constants available_tv_modes[] = {
205 630627, /* defRestart */ 209 630627, /* defRestart */
206 347, /* crtcPLL_N */ 210 347, /* crtcPLL_N */
207 14, /* crtcPLL_M */ 211 14, /* crtcPLL_M */
208 8, /* crtcPLL_postDiv */ 212 8, /* crtcPLL_postDiv */
209 1022, /* pixToTV */ 213 1022, /* pixToTV */
210 }, 214 },
215 { /* PAL timing for 14 Mhz ref clk */
216 800, /* horResolution */
217 600, /* verResolution */
218 TV_STD_PAL, /* standard */
219 1131, /* horTotal */
220 742, /* verTotal */
221 813, /* horStart */
222 840, /* horSyncStart */
223 633, /* verSyncStart */
224 708369, /* defRestart */
225 211, /* crtcPLL_N */
226 9, /* crtcPLL_M */
227 8, /* crtcPLL_postDiv */
228 759, /* pixToTV */
229 },
211}; 230};
212 231
213#define N_AVAILABLE_MODES ARRAY_SIZE(available_tv_modes) 232#define N_AVAILABLE_MODES ARRAY_SIZE(available_tv_modes)
@@ -242,7 +261,7 @@ static const struct radeon_tv_mode_constants *radeon_legacy_tv_get_std_mode(stru
242 if (pll->reference_freq == 2700) 261 if (pll->reference_freq == 2700)
243 const_ptr = &available_tv_modes[1]; 262 const_ptr = &available_tv_modes[1];
244 else 263 else
245 const_ptr = &available_tv_modes[1]; /* FIX ME */ 264 const_ptr = &available_tv_modes[3];
246 } 265 }
247 return const_ptr; 266 return const_ptr;
248} 267}
@@ -685,9 +704,9 @@ void radeon_legacy_tv_mode_set(struct drm_encoder *encoder,
685 n = PAL_TV_PLL_N_27; 704 n = PAL_TV_PLL_N_27;
686 p = PAL_TV_PLL_P_27; 705 p = PAL_TV_PLL_P_27;
687 } else { 706 } else {
688 m = PAL_TV_PLL_M_27; 707 m = PAL_TV_PLL_M_14;
689 n = PAL_TV_PLL_N_27; 708 n = PAL_TV_PLL_N_14;
690 p = PAL_TV_PLL_P_27; 709 p = PAL_TV_PLL_P_14;
691 } 710 }
692 } 711 }
693 712
diff --git a/drivers/gpu/drm/radeon/radeon_mode.h b/drivers/gpu/drm/radeon/radeon_mode.h
index 1702b820aa4..5413fcd6308 100644
--- a/drivers/gpu/drm/radeon/radeon_mode.h
+++ b/drivers/gpu/drm/radeon/radeon_mode.h
@@ -129,6 +129,7 @@ struct radeon_tmds_pll {
129#define RADEON_PLL_USE_FRAC_FB_DIV (1 << 10) 129#define RADEON_PLL_USE_FRAC_FB_DIV (1 << 10)
130#define RADEON_PLL_PREFER_CLOSEST_LOWER (1 << 11) 130#define RADEON_PLL_PREFER_CLOSEST_LOWER (1 << 11)
131#define RADEON_PLL_USE_POST_DIV (1 << 12) 131#define RADEON_PLL_USE_POST_DIV (1 << 12)
132#define RADEON_PLL_IS_LCD (1 << 13)
132 133
133/* pll algo */ 134/* pll algo */
134enum radeon_pll_algo { 135enum radeon_pll_algo {
@@ -149,6 +150,8 @@ struct radeon_pll {
149 uint32_t pll_in_max; 150 uint32_t pll_in_max;
150 uint32_t pll_out_min; 151 uint32_t pll_out_min;
151 uint32_t pll_out_max; 152 uint32_t pll_out_max;
153 uint32_t lcd_pll_out_min;
154 uint32_t lcd_pll_out_max;
152 uint32_t best_vco; 155 uint32_t best_vco;
153 156
154 /* divider limits */ 157 /* divider limits */
@@ -170,17 +173,12 @@ struct radeon_pll {
170 enum radeon_pll_algo algo; 173 enum radeon_pll_algo algo;
171}; 174};
172 175
173struct i2c_algo_radeon_data {
174 struct i2c_adapter bit_adapter;
175 struct i2c_algo_bit_data bit_data;
176};
177
178struct radeon_i2c_chan { 176struct radeon_i2c_chan {
179 struct i2c_adapter adapter; 177 struct i2c_adapter adapter;
180 struct drm_device *dev; 178 struct drm_device *dev;
181 union { 179 union {
180 struct i2c_algo_bit_data bit;
182 struct i2c_algo_dp_aux_data dp; 181 struct i2c_algo_dp_aux_data dp;
183 struct i2c_algo_radeon_data radeon;
184 } algo; 182 } algo;
185 struct radeon_i2c_bus_rec rec; 183 struct radeon_i2c_bus_rec rec;
186}; 184};
@@ -342,6 +340,7 @@ struct radeon_encoder {
342 struct drm_display_mode native_mode; 340 struct drm_display_mode native_mode;
343 void *enc_priv; 341 void *enc_priv;
344 int hdmi_offset; 342 int hdmi_offset;
343 int hdmi_config_offset;
345 int hdmi_audio_workaround; 344 int hdmi_audio_workaround;
346 int hdmi_buffer_status; 345 int hdmi_buffer_status;
347}; 346};
@@ -431,7 +430,6 @@ extern struct radeon_i2c_chan *radeon_i2c_create(struct drm_device *dev,
431 struct radeon_i2c_bus_rec *rec, 430 struct radeon_i2c_bus_rec *rec,
432 const char *name); 431 const char *name);
433extern void radeon_i2c_destroy(struct radeon_i2c_chan *i2c); 432extern void radeon_i2c_destroy(struct radeon_i2c_chan *i2c);
434extern void radeon_i2c_destroy_dp(struct radeon_i2c_chan *i2c);
435extern void radeon_i2c_get_byte(struct radeon_i2c_chan *i2c_bus, 433extern void radeon_i2c_get_byte(struct radeon_i2c_chan *i2c_bus,
436 u8 slave_addr, 434 u8 slave_addr,
437 u8 addr, 435 u8 addr,
@@ -560,6 +558,8 @@ extern int radeon_static_clocks_init(struct drm_device *dev);
560bool radeon_crtc_scaling_mode_fixup(struct drm_crtc *crtc, 558bool radeon_crtc_scaling_mode_fixup(struct drm_crtc *crtc,
561 struct drm_display_mode *mode, 559 struct drm_display_mode *mode,
562 struct drm_display_mode *adjusted_mode); 560 struct drm_display_mode *adjusted_mode);
561void radeon_panel_mode_fixup(struct drm_encoder *encoder,
562 struct drm_display_mode *adjusted_mode);
563void atom_rv515_force_tv_scaler(struct radeon_device *rdev, struct radeon_crtc *radeon_crtc); 563void atom_rv515_force_tv_scaler(struct radeon_device *rdev, struct radeon_crtc *radeon_crtc);
564 564
565/* legacy tv */ 565/* legacy tv */
diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
index fc9d00ac6b1..122774742bd 100644
--- a/drivers/gpu/drm/radeon/radeon_object.c
+++ b/drivers/gpu/drm/radeon/radeon_object.c
@@ -30,6 +30,7 @@
30 * Dave Airlie 30 * Dave Airlie
31 */ 31 */
32#include <linux/list.h> 32#include <linux/list.h>
33#include <linux/slab.h>
33#include <drm/drmP.h> 34#include <drm/drmP.h>
34#include "radeon_drm.h" 35#include "radeon_drm.h"
35#include "radeon.h" 36#include "radeon.h"
@@ -185,8 +186,10 @@ int radeon_bo_pin(struct radeon_bo *bo, u32 domain, u64 *gpu_addr)
185 return 0; 186 return 0;
186 } 187 }
187 radeon_ttm_placement_from_domain(bo, domain); 188 radeon_ttm_placement_from_domain(bo, domain);
188 /* force to pin into visible video ram */ 189 if (domain == RADEON_GEM_DOMAIN_VRAM) {
189 bo->placement.lpfn = bo->rdev->mc.visible_vram_size >> PAGE_SHIFT; 190 /* force to pin into visible video ram */
191 bo->placement.lpfn = bo->rdev->mc.visible_vram_size >> PAGE_SHIFT;
192 }
190 for (i = 0; i < bo->placement.num_placement; i++) 193 for (i = 0; i < bo->placement.num_placement; i++)
191 bo->placements[i] |= TTM_PL_FLAG_NO_EVICT; 194 bo->placements[i] |= TTM_PL_FLAG_NO_EVICT;
192 r = ttm_bo_validate(&bo->tbo, &bo->placement, false, false); 195 r = ttm_bo_validate(&bo->tbo, &bo->placement, false, false);
diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c
index d4d1c39a0e9..a4b57493aa7 100644
--- a/drivers/gpu/drm/radeon/radeon_pm.c
+++ b/drivers/gpu/drm/radeon/radeon_pm.c
@@ -28,6 +28,7 @@
28#define RADEON_RECLOCK_DELAY_MS 200 28#define RADEON_RECLOCK_DELAY_MS 200
29#define RADEON_WAIT_VBLANK_TIMEOUT 200 29#define RADEON_WAIT_VBLANK_TIMEOUT 200
30 30
31static bool radeon_pm_debug_check_in_vbl(struct radeon_device *rdev, bool finish);
31static void radeon_pm_set_clocks_locked(struct radeon_device *rdev); 32static void radeon_pm_set_clocks_locked(struct radeon_device *rdev);
32static void radeon_pm_set_clocks(struct radeon_device *rdev); 33static void radeon_pm_set_clocks(struct radeon_device *rdev);
33static void radeon_pm_idle_work_handler(struct work_struct *work); 34static void radeon_pm_idle_work_handler(struct work_struct *work);
@@ -179,6 +180,16 @@ static void radeon_get_power_state(struct radeon_device *rdev,
179 rdev->pm.requested_power_state->non_clock_info.pcie_lanes); 180 rdev->pm.requested_power_state->non_clock_info.pcie_lanes);
180} 181}
181 182
183static inline void radeon_sync_with_vblank(struct radeon_device *rdev)
184{
185 if (rdev->pm.active_crtcs) {
186 rdev->pm.vblank_sync = false;
187 wait_event_timeout(
188 rdev->irq.vblank_queue, rdev->pm.vblank_sync,
189 msecs_to_jiffies(RADEON_WAIT_VBLANK_TIMEOUT));
190 }
191}
192
182static void radeon_set_power_state(struct radeon_device *rdev) 193static void radeon_set_power_state(struct radeon_device *rdev)
183{ 194{
184 /* if *_clock_mode are the same, *_power_state are as well */ 195 /* if *_clock_mode are the same, *_power_state are as well */
@@ -189,11 +200,28 @@ static void radeon_set_power_state(struct radeon_device *rdev)
189 rdev->pm.requested_clock_mode->sclk, 200 rdev->pm.requested_clock_mode->sclk,
190 rdev->pm.requested_clock_mode->mclk, 201 rdev->pm.requested_clock_mode->mclk,
191 rdev->pm.requested_power_state->non_clock_info.pcie_lanes); 202 rdev->pm.requested_power_state->non_clock_info.pcie_lanes);
203
192 /* set pcie lanes */ 204 /* set pcie lanes */
205 /* TODO */
206
193 /* set voltage */ 207 /* set voltage */
208 /* TODO */
209
194 /* set engine clock */ 210 /* set engine clock */
211 radeon_sync_with_vblank(rdev);
212 radeon_pm_debug_check_in_vbl(rdev, false);
195 radeon_set_engine_clock(rdev, rdev->pm.requested_clock_mode->sclk); 213 radeon_set_engine_clock(rdev, rdev->pm.requested_clock_mode->sclk);
214 radeon_pm_debug_check_in_vbl(rdev, true);
215
216#if 0
196 /* set memory clock */ 217 /* set memory clock */
218 if (rdev->asic->set_memory_clock) {
219 radeon_sync_with_vblank(rdev);
220 radeon_pm_debug_check_in_vbl(rdev, false);
221 radeon_set_memory_clock(rdev, rdev->pm.requested_clock_mode->mclk);
222 radeon_pm_debug_check_in_vbl(rdev, true);
223 }
224#endif
197 225
198 rdev->pm.current_power_state = rdev->pm.requested_power_state; 226 rdev->pm.current_power_state = rdev->pm.requested_power_state;
199 rdev->pm.current_clock_mode = rdev->pm.requested_clock_mode; 227 rdev->pm.current_clock_mode = rdev->pm.requested_clock_mode;
@@ -229,6 +257,12 @@ int radeon_pm_init(struct radeon_device *rdev)
229 return 0; 257 return 0;
230} 258}
231 259
260void radeon_pm_fini(struct radeon_device *rdev)
261{
262 if (rdev->pm.i2c_bus)
263 radeon_i2c_destroy(rdev->pm.i2c_bus);
264}
265
232void radeon_pm_compute_clocks(struct radeon_device *rdev) 266void radeon_pm_compute_clocks(struct radeon_device *rdev)
233{ 267{
234 struct drm_device *ddev = rdev->ddev; 268 struct drm_device *ddev = rdev->ddev;
@@ -245,7 +279,8 @@ void radeon_pm_compute_clocks(struct radeon_device *rdev)
245 list_for_each_entry(connector, 279 list_for_each_entry(connector,
246 &ddev->mode_config.connector_list, head) { 280 &ddev->mode_config.connector_list, head) {
247 if (connector->encoder && 281 if (connector->encoder &&
248 connector->dpms != DRM_MODE_DPMS_OFF) { 282 connector->encoder->crtc &&
283 connector->dpms != DRM_MODE_DPMS_OFF) {
249 radeon_crtc = to_radeon_crtc(connector->encoder->crtc); 284 radeon_crtc = to_radeon_crtc(connector->encoder->crtc);
250 rdev->pm.active_crtcs |= (1 << radeon_crtc->crtc_id); 285 rdev->pm.active_crtcs |= (1 << radeon_crtc->crtc_id);
251 ++count; 286 ++count;
@@ -333,10 +368,7 @@ static void radeon_pm_set_clocks_locked(struct radeon_device *rdev)
333 break; 368 break;
334 } 369 }
335 370
336 /* check if we are in vblank */
337 radeon_pm_debug_check_in_vbl(rdev, false);
338 radeon_set_power_state(rdev); 371 radeon_set_power_state(rdev);
339 radeon_pm_debug_check_in_vbl(rdev, true);
340 rdev->pm.planned_action = PM_ACTION_NONE; 372 rdev->pm.planned_action = PM_ACTION_NONE;
341} 373}
342 374
@@ -353,10 +385,7 @@ static void radeon_pm_set_clocks(struct radeon_device *rdev)
353 rdev->pm.req_vblank |= (1 << 1); 385 rdev->pm.req_vblank |= (1 << 1);
354 drm_vblank_get(rdev->ddev, 1); 386 drm_vblank_get(rdev->ddev, 1);
355 } 387 }
356 if (rdev->pm.active_crtcs) 388 radeon_pm_set_clocks_locked(rdev);
357 wait_event_interruptible_timeout(
358 rdev->irq.vblank_queue, 0,
359 msecs_to_jiffies(RADEON_WAIT_VBLANK_TIMEOUT));
360 if (rdev->pm.req_vblank & (1 << 0)) { 389 if (rdev->pm.req_vblank & (1 << 0)) {
361 rdev->pm.req_vblank &= ~(1 << 0); 390 rdev->pm.req_vblank &= ~(1 << 0);
362 drm_vblank_put(rdev->ddev, 0); 391 drm_vblank_put(rdev->ddev, 0);
@@ -366,7 +395,6 @@ static void radeon_pm_set_clocks(struct radeon_device *rdev)
366 drm_vblank_put(rdev->ddev, 1); 395 drm_vblank_put(rdev->ddev, 1);
367 } 396 }
368 397
369 radeon_pm_set_clocks_locked(rdev);
370 mutex_unlock(&rdev->cp.mutex); 398 mutex_unlock(&rdev->cp.mutex);
371} 399}
372 400
diff --git a/drivers/gpu/drm/radeon/radeon_reg.h b/drivers/gpu/drm/radeon/radeon_reg.h
index 5c0dc082d33..eabbc9cf30a 100644
--- a/drivers/gpu/drm/radeon/radeon_reg.h
+++ b/drivers/gpu/drm/radeon/radeon_reg.h
@@ -346,6 +346,7 @@
346# define RADEON_TVPLL_PWRMGT_OFF (1 << 30) 346# define RADEON_TVPLL_PWRMGT_OFF (1 << 30)
347# define RADEON_TVCLK_TURNOFF (1 << 31) 347# define RADEON_TVCLK_TURNOFF (1 << 31)
348#define RADEON_PLL_PWRMGT_CNTL 0x0015 /* PLL */ 348#define RADEON_PLL_PWRMGT_CNTL 0x0015 /* PLL */
349# define RADEON_PM_MODE_SEL (1 << 13)
349# define RADEON_TCL_BYPASS_DISABLE (1 << 20) 350# define RADEON_TCL_BYPASS_DISABLE (1 << 20)
350#define RADEON_CLR_CMP_CLR_3D 0x1a24 351#define RADEON_CLR_CMP_CLR_3D 0x1a24
351#define RADEON_CLR_CMP_CLR_DST 0x15c8 352#define RADEON_CLR_CMP_CLR_DST 0x15c8
diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c
index e50513a6273..f6e1e8d4d98 100644
--- a/drivers/gpu/drm/radeon/radeon_ring.c
+++ b/drivers/gpu/drm/radeon/radeon_ring.c
@@ -26,6 +26,7 @@
26 * Jerome Glisse 26 * Jerome Glisse
27 */ 27 */
28#include <linux/seq_file.h> 28#include <linux/seq_file.h>
29#include <linux/slab.h>
29#include "drmP.h" 30#include "drmP.h"
30#include "radeon_drm.h" 31#include "radeon_drm.h"
31#include "radeon_reg.h" 32#include "radeon_reg.h"
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index 43c5ab34b63..d031b686308 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -36,6 +36,7 @@
36#include <drm/drmP.h> 36#include <drm/drmP.h>
37#include <drm/radeon_drm.h> 37#include <drm/radeon_drm.h>
38#include <linux/seq_file.h> 38#include <linux/seq_file.h>
39#include <linux/slab.h>
39#include "radeon_reg.h" 40#include "radeon_reg.h"
40#include "radeon.h" 41#include "radeon.h"
41 42
diff --git a/drivers/gpu/drm/radeon/reg_srcs/r300 b/drivers/gpu/drm/radeon/reg_srcs/r300
index 19c4663fa9c..1e97b2d129f 100644
--- a/drivers/gpu/drm/radeon/reg_srcs/r300
+++ b/drivers/gpu/drm/radeon/reg_srcs/r300
@@ -125,6 +125,8 @@ r300 0x4f60
1250x4000 GB_VAP_RASTER_VTX_FMT_0 1250x4000 GB_VAP_RASTER_VTX_FMT_0
1260x4004 GB_VAP_RASTER_VTX_FMT_1 1260x4004 GB_VAP_RASTER_VTX_FMT_1
1270x4008 GB_ENABLE 1270x4008 GB_ENABLE
1280x4010 GB_MSPOS0
1290x4014 GB_MSPOS1
1280x401C GB_SELECT 1300x401C GB_SELECT
1290x4020 GB_AA_CONFIG 1310x4020 GB_AA_CONFIG
1300x4024 GB_FIFO_SIZE 1320x4024 GB_FIFO_SIZE
diff --git a/drivers/gpu/drm/radeon/reg_srcs/r420 b/drivers/gpu/drm/radeon/reg_srcs/r420
index 989f7a02083..e958980d00f 100644
--- a/drivers/gpu/drm/radeon/reg_srcs/r420
+++ b/drivers/gpu/drm/radeon/reg_srcs/r420
@@ -125,6 +125,8 @@ r420 0x4f60
1250x4000 GB_VAP_RASTER_VTX_FMT_0 1250x4000 GB_VAP_RASTER_VTX_FMT_0
1260x4004 GB_VAP_RASTER_VTX_FMT_1 1260x4004 GB_VAP_RASTER_VTX_FMT_1
1270x4008 GB_ENABLE 1270x4008 GB_ENABLE
1280x4010 GB_MSPOS0
1290x4014 GB_MSPOS1
1280x401C GB_SELECT 1300x401C GB_SELECT
1290x4020 GB_AA_CONFIG 1310x4020 GB_AA_CONFIG
1300x4024 GB_FIFO_SIZE 1320x4024 GB_FIFO_SIZE
diff --git a/drivers/gpu/drm/radeon/reg_srcs/r600 b/drivers/gpu/drm/radeon/reg_srcs/r600
index 8f414a5f520..af0da4ae3f5 100644
--- a/drivers/gpu/drm/radeon/reg_srcs/r600
+++ b/drivers/gpu/drm/radeon/reg_srcs/r600
@@ -26,20 +26,16 @@ r600 0x9400
260x00028408 VGT_INDX_OFFSET 260x00028408 VGT_INDX_OFFSET
270x00028AA0 VGT_INSTANCE_STEP_RATE_0 270x00028AA0 VGT_INSTANCE_STEP_RATE_0
280x00028AA4 VGT_INSTANCE_STEP_RATE_1 280x00028AA4 VGT_INSTANCE_STEP_RATE_1
290x000088C0 VGT_LAST_COPY_STATE
300x00028400 VGT_MAX_VTX_INDX 290x00028400 VGT_MAX_VTX_INDX
310x000088D8 VGT_MC_LAT_CNTL
320x00028404 VGT_MIN_VTX_INDX 300x00028404 VGT_MIN_VTX_INDX
330x00028A94 VGT_MULTI_PRIM_IB_RESET_EN 310x00028A94 VGT_MULTI_PRIM_IB_RESET_EN
340x0002840C VGT_MULTI_PRIM_IB_RESET_INDX 320x0002840C VGT_MULTI_PRIM_IB_RESET_INDX
350x00008970 VGT_NUM_INDICES 330x00008970 VGT_NUM_INDICES
360x00008974 VGT_NUM_INSTANCES 340x00008974 VGT_NUM_INSTANCES
370x00028A10 VGT_OUTPUT_PATH_CNTL 350x00028A10 VGT_OUTPUT_PATH_CNTL
380x00028C5C VGT_OUT_DEALLOC_CNTL
390x00028A84 VGT_PRIMITIVEID_EN 360x00028A84 VGT_PRIMITIVEID_EN
400x00008958 VGT_PRIMITIVE_TYPE 370x00008958 VGT_PRIMITIVE_TYPE
410x00028AB4 VGT_REUSE_OFF 380x00028AB4 VGT_REUSE_OFF
420x00028C58 VGT_VERTEX_REUSE_BLOCK_CNTL
430x00028AB8 VGT_VTX_CNT_EN 390x00028AB8 VGT_VTX_CNT_EN
440x000088B0 VGT_VTX_VECT_EJECT_REG 400x000088B0 VGT_VTX_VECT_EJECT_REG
450x00028810 PA_CL_CLIP_CNTL 410x00028810 PA_CL_CLIP_CNTL
@@ -280,7 +276,6 @@ r600 0x9400
2800x00028E00 PA_SU_POLY_OFFSET_FRONT_SCALE 2760x00028E00 PA_SU_POLY_OFFSET_FRONT_SCALE
2810x00028814 PA_SU_SC_MODE_CNTL 2770x00028814 PA_SU_SC_MODE_CNTL
2820x00028C08 PA_SU_VTX_CNTL 2780x00028C08 PA_SU_VTX_CNTL
2830x00008C00 SQ_CONFIG
2840x00008C04 SQ_GPR_RESOURCE_MGMT_1 2790x00008C04 SQ_GPR_RESOURCE_MGMT_1
2850x00008C08 SQ_GPR_RESOURCE_MGMT_2 2800x00008C08 SQ_GPR_RESOURCE_MGMT_2
2860x00008C10 SQ_STACK_RESOURCE_MGMT_1 2810x00008C10 SQ_STACK_RESOURCE_MGMT_1
@@ -320,18 +315,6 @@ r600 0x9400
3200x000283FC SQ_VTX_SEMANTIC_31 3150x000283FC SQ_VTX_SEMANTIC_31
3210x000288E0 SQ_VTX_SEMANTIC_CLEAR 3160x000288E0 SQ_VTX_SEMANTIC_CLEAR
3220x0003CFF4 SQ_VTX_START_INST_LOC 3170x0003CFF4 SQ_VTX_START_INST_LOC
3230x0003C000 SQ_TEX_SAMPLER_WORD0_0
3240x0003C004 SQ_TEX_SAMPLER_WORD1_0
3250x0003C008 SQ_TEX_SAMPLER_WORD2_0
3260x00030000 SQ_ALU_CONSTANT0_0
3270x00030004 SQ_ALU_CONSTANT1_0
3280x00030008 SQ_ALU_CONSTANT2_0
3290x0003000C SQ_ALU_CONSTANT3_0
3300x0003E380 SQ_BOOL_CONST_0
3310x0003E384 SQ_BOOL_CONST_1
3320x0003E388 SQ_BOOL_CONST_2
3330x0003E200 SQ_LOOP_CONST_0
3340x0003E200 SQ_LOOP_CONST_DX10_0
3350x000281C0 SQ_ALU_CONST_BUFFER_SIZE_GS_0 3180x000281C0 SQ_ALU_CONST_BUFFER_SIZE_GS_0
3360x000281C4 SQ_ALU_CONST_BUFFER_SIZE_GS_1 3190x000281C4 SQ_ALU_CONST_BUFFER_SIZE_GS_1
3370x000281C8 SQ_ALU_CONST_BUFFER_SIZE_GS_2 3200x000281C8 SQ_ALU_CONST_BUFFER_SIZE_GS_2
@@ -380,54 +363,6 @@ r600 0x9400
3800x000281B4 SQ_ALU_CONST_BUFFER_SIZE_VS_13 3630x000281B4 SQ_ALU_CONST_BUFFER_SIZE_VS_13
3810x000281B8 SQ_ALU_CONST_BUFFER_SIZE_VS_14 3640x000281B8 SQ_ALU_CONST_BUFFER_SIZE_VS_14
3820x000281BC SQ_ALU_CONST_BUFFER_SIZE_VS_15 3650x000281BC SQ_ALU_CONST_BUFFER_SIZE_VS_15
3830x000289C0 SQ_ALU_CONST_CACHE_GS_0
3840x000289C4 SQ_ALU_CONST_CACHE_GS_1
3850x000289C8 SQ_ALU_CONST_CACHE_GS_2
3860x000289CC SQ_ALU_CONST_CACHE_GS_3
3870x000289D0 SQ_ALU_CONST_CACHE_GS_4
3880x000289D4 SQ_ALU_CONST_CACHE_GS_5
3890x000289D8 SQ_ALU_CONST_CACHE_GS_6
3900x000289DC SQ_ALU_CONST_CACHE_GS_7
3910x000289E0 SQ_ALU_CONST_CACHE_GS_8
3920x000289E4 SQ_ALU_CONST_CACHE_GS_9
3930x000289E8 SQ_ALU_CONST_CACHE_GS_10
3940x000289EC SQ_ALU_CONST_CACHE_GS_11
3950x000289F0 SQ_ALU_CONST_CACHE_GS_12
3960x000289F4 SQ_ALU_CONST_CACHE_GS_13
3970x000289F8 SQ_ALU_CONST_CACHE_GS_14
3980x000289FC SQ_ALU_CONST_CACHE_GS_15
3990x00028940 SQ_ALU_CONST_CACHE_PS_0
4000x00028944 SQ_ALU_CONST_CACHE_PS_1
4010x00028948 SQ_ALU_CONST_CACHE_PS_2
4020x0002894C SQ_ALU_CONST_CACHE_PS_3
4030x00028950 SQ_ALU_CONST_CACHE_PS_4
4040x00028954 SQ_ALU_CONST_CACHE_PS_5
4050x00028958 SQ_ALU_CONST_CACHE_PS_6
4060x0002895C SQ_ALU_CONST_CACHE_PS_7
4070x00028960 SQ_ALU_CONST_CACHE_PS_8
4080x00028964 SQ_ALU_CONST_CACHE_PS_9
4090x00028968 SQ_ALU_CONST_CACHE_PS_10
4100x0002896C SQ_ALU_CONST_CACHE_PS_11
4110x00028970 SQ_ALU_CONST_CACHE_PS_12
4120x00028974 SQ_ALU_CONST_CACHE_PS_13
4130x00028978 SQ_ALU_CONST_CACHE_PS_14
4140x0002897C SQ_ALU_CONST_CACHE_PS_15
4150x00028980 SQ_ALU_CONST_CACHE_VS_0
4160x00028984 SQ_ALU_CONST_CACHE_VS_1
4170x00028988 SQ_ALU_CONST_CACHE_VS_2
4180x0002898C SQ_ALU_CONST_CACHE_VS_3
4190x00028990 SQ_ALU_CONST_CACHE_VS_4
4200x00028994 SQ_ALU_CONST_CACHE_VS_5
4210x00028998 SQ_ALU_CONST_CACHE_VS_6
4220x0002899C SQ_ALU_CONST_CACHE_VS_7
4230x000289A0 SQ_ALU_CONST_CACHE_VS_8
4240x000289A4 SQ_ALU_CONST_CACHE_VS_9
4250x000289A8 SQ_ALU_CONST_CACHE_VS_10
4260x000289AC SQ_ALU_CONST_CACHE_VS_11
4270x000289B0 SQ_ALU_CONST_CACHE_VS_12
4280x000289B4 SQ_ALU_CONST_CACHE_VS_13
4290x000289B8 SQ_ALU_CONST_CACHE_VS_14
4300x000289BC SQ_ALU_CONST_CACHE_VS_15
4310x000288D8 SQ_PGM_CF_OFFSET_ES 3660x000288D8 SQ_PGM_CF_OFFSET_ES
4320x000288DC SQ_PGM_CF_OFFSET_FS 3670x000288DC SQ_PGM_CF_OFFSET_FS
4330x000288D4 SQ_PGM_CF_OFFSET_GS 3680x000288D4 SQ_PGM_CF_OFFSET_GS
@@ -494,12 +429,7 @@ r600 0x9400
4940x00028438 SX_ALPHA_REF 4290x00028438 SX_ALPHA_REF
4950x00028410 SX_ALPHA_TEST_CONTROL 4300x00028410 SX_ALPHA_TEST_CONTROL
4960x00028350 SX_MISC 4310x00028350 SX_MISC
4970x0000A020 SMX_DC_CTL0
4980x0000A024 SMX_DC_CTL1
4990x0000A028 SMX_DC_CTL2
5000x00009608 TC_CNTL
5010x00009604 TC_INVALIDATE 4320x00009604 TC_INVALIDATE
5020x00009490 TD_CNTL
5030x00009400 TD_FILTER4 4330x00009400 TD_FILTER4
5040x00009404 TD_FILTER4_1 4340x00009404 TD_FILTER4_1
5050x00009408 TD_FILTER4_2 4350x00009408 TD_FILTER4_2
@@ -824,14 +754,9 @@ r600 0x9400
8240x00028428 CB_FOG_GREEN 7540x00028428 CB_FOG_GREEN
8250x00028424 CB_FOG_RED 7550x00028424 CB_FOG_RED
8260x00008040 WAIT_UNTIL 7560x00008040 WAIT_UNTIL
8270x00008950 CC_GC_SHADER_PIPE_CONFIG
8280x00008954 GC_USER_SHADER_PIPE_CONFIG
8290x00009714 VC_ENHANCE 7570x00009714 VC_ENHANCE
8300x00009830 DB_DEBUG 7580x00009830 DB_DEBUG
8310x00009838 DB_WATERMARKS 7590x00009838 DB_WATERMARKS
8320x00028D28 DB_SRESULTS_COMPARE_STATE0 7600x00028D28 DB_SRESULTS_COMPARE_STATE0
8330x00028D44 DB_ALPHA_TO_MASK 7610x00028D44 DB_ALPHA_TO_MASK
8340x00009504 TA_CNTL
8350x00009700 VC_CNTL 7620x00009700 VC_CNTL
8360x00009718 VC_CONFIG
8370x0000A02C SMX_DC_MC_INTF_CTL
diff --git a/drivers/gpu/drm/radeon/reg_srcs/rs600 b/drivers/gpu/drm/radeon/reg_srcs/rs600
index 6801b865d1c..83e8bc0c2bb 100644
--- a/drivers/gpu/drm/radeon/reg_srcs/rs600
+++ b/drivers/gpu/drm/radeon/reg_srcs/rs600
@@ -125,6 +125,8 @@ rs600 0x6d40
1250x4000 GB_VAP_RASTER_VTX_FMT_0 1250x4000 GB_VAP_RASTER_VTX_FMT_0
1260x4004 GB_VAP_RASTER_VTX_FMT_1 1260x4004 GB_VAP_RASTER_VTX_FMT_1
1270x4008 GB_ENABLE 1270x4008 GB_ENABLE
1280x4010 GB_MSPOS0
1290x4014 GB_MSPOS1
1280x401C GB_SELECT 1300x401C GB_SELECT
1290x4020 GB_AA_CONFIG 1310x4020 GB_AA_CONFIG
1300x4024 GB_FIFO_SIZE 1320x4024 GB_FIFO_SIZE
diff --git a/drivers/gpu/drm/radeon/reg_srcs/rv515 b/drivers/gpu/drm/radeon/reg_srcs/rv515
index 38abf63bf2c..1e46233985e 100644
--- a/drivers/gpu/drm/radeon/reg_srcs/rv515
+++ b/drivers/gpu/drm/radeon/reg_srcs/rv515
@@ -35,6 +35,7 @@ rv515 0x6d40
350x1DA8 VAP_VPORT_ZSCALE 350x1DA8 VAP_VPORT_ZSCALE
360x1DAC VAP_VPORT_ZOFFSET 360x1DAC VAP_VPORT_ZOFFSET
370x2080 VAP_CNTL 370x2080 VAP_CNTL
380x208C VAP_INDEX_OFFSET
380x2090 VAP_OUT_VTX_FMT_0 390x2090 VAP_OUT_VTX_FMT_0
390x2094 VAP_OUT_VTX_FMT_1 400x2094 VAP_OUT_VTX_FMT_1
400x20B0 VAP_VTE_CNTL 410x20B0 VAP_VTE_CNTL
@@ -158,6 +159,8 @@ rv515 0x6d40
1580x4000 GB_VAP_RASTER_VTX_FMT_0 1590x4000 GB_VAP_RASTER_VTX_FMT_0
1590x4004 GB_VAP_RASTER_VTX_FMT_1 1600x4004 GB_VAP_RASTER_VTX_FMT_1
1600x4008 GB_ENABLE 1610x4008 GB_ENABLE
1620x4010 GB_MSPOS0
1630x4014 GB_MSPOS1
1610x401C GB_SELECT 1640x401C GB_SELECT
1620x4020 GB_AA_CONFIG 1650x4020 GB_AA_CONFIG
1630x4024 GB_FIFO_SIZE 1660x4024 GB_FIFO_SIZE
diff --git a/drivers/gpu/drm/radeon/rs400.c b/drivers/gpu/drm/radeon/rs400.c
index 626d51891ee..1a41cb268b7 100644
--- a/drivers/gpu/drm/radeon/rs400.c
+++ b/drivers/gpu/drm/radeon/rs400.c
@@ -26,8 +26,10 @@
26 * Jerome Glisse 26 * Jerome Glisse
27 */ 27 */
28#include <linux/seq_file.h> 28#include <linux/seq_file.h>
29#include <linux/slab.h>
29#include <drm/drmP.h> 30#include <drm/drmP.h>
30#include "radeon.h" 31#include "radeon.h"
32#include "radeon_asic.h"
31#include "rs400d.h" 33#include "rs400d.h"
32 34
33/* This files gather functions specifics to : rs400,rs480 */ 35/* This files gather functions specifics to : rs400,rs480 */
@@ -202,9 +204,9 @@ void rs400_gart_disable(struct radeon_device *rdev)
202 204
203void rs400_gart_fini(struct radeon_device *rdev) 205void rs400_gart_fini(struct radeon_device *rdev)
204{ 206{
207 radeon_gart_fini(rdev);
205 rs400_gart_disable(rdev); 208 rs400_gart_disable(rdev);
206 radeon_gart_table_ram_free(rdev); 209 radeon_gart_table_ram_free(rdev);
207 radeon_gart_fini(rdev);
208} 210}
209 211
210int rs400_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr) 212int rs400_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr)
@@ -264,6 +266,7 @@ void rs400_mc_init(struct radeon_device *rdev)
264 base = (RREG32(RADEON_NB_TOM) & 0xffff) << 16; 266 base = (RREG32(RADEON_NB_TOM) & 0xffff) << 16;
265 radeon_vram_location(rdev, &rdev->mc, base); 267 radeon_vram_location(rdev, &rdev->mc, base);
266 radeon_gtt_location(rdev, &rdev->mc); 268 radeon_gtt_location(rdev, &rdev->mc);
269 radeon_update_bandwidth_info(rdev);
267} 270}
268 271
269uint32_t rs400_mc_rreg(struct radeon_device *rdev, uint32_t reg) 272uint32_t rs400_mc_rreg(struct radeon_device *rdev, uint32_t reg)
@@ -388,6 +391,8 @@ static int rs400_startup(struct radeon_device *rdev)
388{ 391{
389 int r; 392 int r;
390 393
394 r100_set_common_regs(rdev);
395
391 rs400_mc_program(rdev); 396 rs400_mc_program(rdev);
392 /* Resume clock */ 397 /* Resume clock */
393 r300_clock_startup(rdev); 398 r300_clock_startup(rdev);
@@ -453,6 +458,7 @@ int rs400_suspend(struct radeon_device *rdev)
453 458
454void rs400_fini(struct radeon_device *rdev) 459void rs400_fini(struct radeon_device *rdev)
455{ 460{
461 radeon_pm_fini(rdev);
456 r100_cp_fini(rdev); 462 r100_cp_fini(rdev);
457 r100_wb_fini(rdev); 463 r100_wb_fini(rdev);
458 r100_ib_fini(rdev); 464 r100_ib_fini(rdev);
diff --git a/drivers/gpu/drm/radeon/rs600.c b/drivers/gpu/drm/radeon/rs600.c
index 47f046b78c6..a81bc7a21e1 100644
--- a/drivers/gpu/drm/radeon/rs600.c
+++ b/drivers/gpu/drm/radeon/rs600.c
@@ -37,6 +37,7 @@
37 */ 37 */
38#include "drmP.h" 38#include "drmP.h"
39#include "radeon.h" 39#include "radeon.h"
40#include "radeon_asic.h"
40#include "atom.h" 41#include "atom.h"
41#include "rs600d.h" 42#include "rs600d.h"
42 43
@@ -158,7 +159,7 @@ void rs600_gart_tlb_flush(struct radeon_device *rdev)
158 WREG32_MC(R_000100_MC_PT0_CNTL, tmp); 159 WREG32_MC(R_000100_MC_PT0_CNTL, tmp);
159 160
160 tmp = RREG32_MC(R_000100_MC_PT0_CNTL); 161 tmp = RREG32_MC(R_000100_MC_PT0_CNTL);
161 tmp |= S_000100_INVALIDATE_ALL_L1_TLBS(1) & S_000100_INVALIDATE_L2_CACHE(1); 162 tmp |= S_000100_INVALIDATE_ALL_L1_TLBS(1) | S_000100_INVALIDATE_L2_CACHE(1);
162 WREG32_MC(R_000100_MC_PT0_CNTL, tmp); 163 WREG32_MC(R_000100_MC_PT0_CNTL, tmp);
163 164
164 tmp = RREG32_MC(R_000100_MC_PT0_CNTL); 165 tmp = RREG32_MC(R_000100_MC_PT0_CNTL);
@@ -267,9 +268,9 @@ void rs600_gart_disable(struct radeon_device *rdev)
267 268
268void rs600_gart_fini(struct radeon_device *rdev) 269void rs600_gart_fini(struct radeon_device *rdev)
269{ 270{
271 radeon_gart_fini(rdev);
270 rs600_gart_disable(rdev); 272 rs600_gart_disable(rdev);
271 radeon_gart_table_vram_free(rdev); 273 radeon_gart_table_vram_free(rdev);
272 radeon_gart_fini(rdev);
273} 274}
274 275
275#define R600_PTE_VALID (1 << 0) 276#define R600_PTE_VALID (1 << 0)
@@ -392,10 +393,12 @@ int rs600_irq_process(struct radeon_device *rdev)
392 /* Vertical blank interrupts */ 393 /* Vertical blank interrupts */
393 if (G_007EDC_LB_D1_VBLANK_INTERRUPT(r500_disp_int)) { 394 if (G_007EDC_LB_D1_VBLANK_INTERRUPT(r500_disp_int)) {
394 drm_handle_vblank(rdev->ddev, 0); 395 drm_handle_vblank(rdev->ddev, 0);
396 rdev->pm.vblank_sync = true;
395 wake_up(&rdev->irq.vblank_queue); 397 wake_up(&rdev->irq.vblank_queue);
396 } 398 }
397 if (G_007EDC_LB_D2_VBLANK_INTERRUPT(r500_disp_int)) { 399 if (G_007EDC_LB_D2_VBLANK_INTERRUPT(r500_disp_int)) {
398 drm_handle_vblank(rdev->ddev, 1); 400 drm_handle_vblank(rdev->ddev, 1);
401 rdev->pm.vblank_sync = true;
399 wake_up(&rdev->irq.vblank_queue); 402 wake_up(&rdev->irq.vblank_queue);
400 } 403 }
401 if (G_007EDC_DC_HOT_PLUG_DETECT1_INTERRUPT(r500_disp_int)) { 404 if (G_007EDC_DC_HOT_PLUG_DETECT1_INTERRUPT(r500_disp_int)) {
@@ -472,13 +475,38 @@ void rs600_mc_init(struct radeon_device *rdev)
472 rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev); 475 rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev);
473 base = RREG32_MC(R_000004_MC_FB_LOCATION); 476 base = RREG32_MC(R_000004_MC_FB_LOCATION);
474 base = G_000004_MC_FB_START(base) << 16; 477 base = G_000004_MC_FB_START(base) << 16;
478 rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev);
475 radeon_vram_location(rdev, &rdev->mc, base); 479 radeon_vram_location(rdev, &rdev->mc, base);
476 radeon_gtt_location(rdev, &rdev->mc); 480 radeon_gtt_location(rdev, &rdev->mc);
481 radeon_update_bandwidth_info(rdev);
477} 482}
478 483
479void rs600_bandwidth_update(struct radeon_device *rdev) 484void rs600_bandwidth_update(struct radeon_device *rdev)
480{ 485{
481 /* FIXME: implement, should this be like rs690 ? */ 486 struct drm_display_mode *mode0 = NULL;
487 struct drm_display_mode *mode1 = NULL;
488 u32 d1mode_priority_a_cnt, d2mode_priority_a_cnt;
489 /* FIXME: implement full support */
490
491 radeon_update_display_priority(rdev);
492
493 if (rdev->mode_info.crtcs[0]->base.enabled)
494 mode0 = &rdev->mode_info.crtcs[0]->base.mode;
495 if (rdev->mode_info.crtcs[1]->base.enabled)
496 mode1 = &rdev->mode_info.crtcs[1]->base.mode;
497
498 rs690_line_buffer_adjust(rdev, mode0, mode1);
499
500 if (rdev->disp_priority == 2) {
501 d1mode_priority_a_cnt = RREG32(R_006548_D1MODE_PRIORITY_A_CNT);
502 d2mode_priority_a_cnt = RREG32(R_006D48_D2MODE_PRIORITY_A_CNT);
503 d1mode_priority_a_cnt |= S_006548_D1MODE_PRIORITY_A_ALWAYS_ON(1);
504 d2mode_priority_a_cnt |= S_006D48_D2MODE_PRIORITY_A_ALWAYS_ON(1);
505 WREG32(R_006548_D1MODE_PRIORITY_A_CNT, d1mode_priority_a_cnt);
506 WREG32(R_00654C_D1MODE_PRIORITY_B_CNT, d1mode_priority_a_cnt);
507 WREG32(R_006D48_D2MODE_PRIORITY_A_CNT, d2mode_priority_a_cnt);
508 WREG32(R_006D4C_D2MODE_PRIORITY_B_CNT, d2mode_priority_a_cnt);
509 }
482} 510}
483 511
484uint32_t rs600_mc_rreg(struct radeon_device *rdev, uint32_t reg) 512uint32_t rs600_mc_rreg(struct radeon_device *rdev, uint32_t reg)
@@ -598,6 +626,7 @@ int rs600_suspend(struct radeon_device *rdev)
598 626
599void rs600_fini(struct radeon_device *rdev) 627void rs600_fini(struct radeon_device *rdev)
600{ 628{
629 radeon_pm_fini(rdev);
601 r100_cp_fini(rdev); 630 r100_cp_fini(rdev);
602 r100_wb_fini(rdev); 631 r100_wb_fini(rdev);
603 r100_ib_fini(rdev); 632 r100_ib_fini(rdev);
diff --git a/drivers/gpu/drm/radeon/rs600d.h b/drivers/gpu/drm/radeon/rs600d.h
index c1c8f5885cb..e52d2695510 100644
--- a/drivers/gpu/drm/radeon/rs600d.h
+++ b/drivers/gpu/drm/radeon/rs600d.h
@@ -535,4 +535,57 @@
535#define G_00016C_INVALIDATE_L1_TLB(x) (((x) >> 20) & 0x1) 535#define G_00016C_INVALIDATE_L1_TLB(x) (((x) >> 20) & 0x1)
536#define C_00016C_INVALIDATE_L1_TLB 0xFFEFFFFF 536#define C_00016C_INVALIDATE_L1_TLB 0xFFEFFFFF
537 537
538#define R_006548_D1MODE_PRIORITY_A_CNT 0x006548
539#define S_006548_D1MODE_PRIORITY_MARK_A(x) (((x) & 0x7FFF) << 0)
540#define G_006548_D1MODE_PRIORITY_MARK_A(x) (((x) >> 0) & 0x7FFF)
541#define C_006548_D1MODE_PRIORITY_MARK_A 0xFFFF8000
542#define S_006548_D1MODE_PRIORITY_A_OFF(x) (((x) & 0x1) << 16)
543#define G_006548_D1MODE_PRIORITY_A_OFF(x) (((x) >> 16) & 0x1)
544#define C_006548_D1MODE_PRIORITY_A_OFF 0xFFFEFFFF
545#define S_006548_D1MODE_PRIORITY_A_ALWAYS_ON(x) (((x) & 0x1) << 20)
546#define G_006548_D1MODE_PRIORITY_A_ALWAYS_ON(x) (((x) >> 20) & 0x1)
547#define C_006548_D1MODE_PRIORITY_A_ALWAYS_ON 0xFFEFFFFF
548#define S_006548_D1MODE_PRIORITY_A_FORCE_MASK(x) (((x) & 0x1) << 24)
549#define G_006548_D1MODE_PRIORITY_A_FORCE_MASK(x) (((x) >> 24) & 0x1)
550#define C_006548_D1MODE_PRIORITY_A_FORCE_MASK 0xFEFFFFFF
551#define R_00654C_D1MODE_PRIORITY_B_CNT 0x00654C
552#define S_00654C_D1MODE_PRIORITY_MARK_B(x) (((x) & 0x7FFF) << 0)
553#define G_00654C_D1MODE_PRIORITY_MARK_B(x) (((x) >> 0) & 0x7FFF)
554#define C_00654C_D1MODE_PRIORITY_MARK_B 0xFFFF8000
555#define S_00654C_D1MODE_PRIORITY_B_OFF(x) (((x) & 0x1) << 16)
556#define G_00654C_D1MODE_PRIORITY_B_OFF(x) (((x) >> 16) & 0x1)
557#define C_00654C_D1MODE_PRIORITY_B_OFF 0xFFFEFFFF
558#define S_00654C_D1MODE_PRIORITY_B_ALWAYS_ON(x) (((x) & 0x1) << 20)
559#define G_00654C_D1MODE_PRIORITY_B_ALWAYS_ON(x) (((x) >> 20) & 0x1)
560#define C_00654C_D1MODE_PRIORITY_B_ALWAYS_ON 0xFFEFFFFF
561#define S_00654C_D1MODE_PRIORITY_B_FORCE_MASK(x) (((x) & 0x1) << 24)
562#define G_00654C_D1MODE_PRIORITY_B_FORCE_MASK(x) (((x) >> 24) & 0x1)
563#define C_00654C_D1MODE_PRIORITY_B_FORCE_MASK 0xFEFFFFFF
564#define R_006D48_D2MODE_PRIORITY_A_CNT 0x006D48
565#define S_006D48_D2MODE_PRIORITY_MARK_A(x) (((x) & 0x7FFF) << 0)
566#define G_006D48_D2MODE_PRIORITY_MARK_A(x) (((x) >> 0) & 0x7FFF)
567#define C_006D48_D2MODE_PRIORITY_MARK_A 0xFFFF8000
568#define S_006D48_D2MODE_PRIORITY_A_OFF(x) (((x) & 0x1) << 16)
569#define G_006D48_D2MODE_PRIORITY_A_OFF(x) (((x) >> 16) & 0x1)
570#define C_006D48_D2MODE_PRIORITY_A_OFF 0xFFFEFFFF
571#define S_006D48_D2MODE_PRIORITY_A_ALWAYS_ON(x) (((x) & 0x1) << 20)
572#define G_006D48_D2MODE_PRIORITY_A_ALWAYS_ON(x) (((x) >> 20) & 0x1)
573#define C_006D48_D2MODE_PRIORITY_A_ALWAYS_ON 0xFFEFFFFF
574#define S_006D48_D2MODE_PRIORITY_A_FORCE_MASK(x) (((x) & 0x1) << 24)
575#define G_006D48_D2MODE_PRIORITY_A_FORCE_MASK(x) (((x) >> 24) & 0x1)
576#define C_006D48_D2MODE_PRIORITY_A_FORCE_MASK 0xFEFFFFFF
577#define R_006D4C_D2MODE_PRIORITY_B_CNT 0x006D4C
578#define S_006D4C_D2MODE_PRIORITY_MARK_B(x) (((x) & 0x7FFF) << 0)
579#define G_006D4C_D2MODE_PRIORITY_MARK_B(x) (((x) >> 0) & 0x7FFF)
580#define C_006D4C_D2MODE_PRIORITY_MARK_B 0xFFFF8000
581#define S_006D4C_D2MODE_PRIORITY_B_OFF(x) (((x) & 0x1) << 16)
582#define G_006D4C_D2MODE_PRIORITY_B_OFF(x) (((x) >> 16) & 0x1)
583#define C_006D4C_D2MODE_PRIORITY_B_OFF 0xFFFEFFFF
584#define S_006D4C_D2MODE_PRIORITY_B_ALWAYS_ON(x) (((x) & 0x1) << 20)
585#define G_006D4C_D2MODE_PRIORITY_B_ALWAYS_ON(x) (((x) >> 20) & 0x1)
586#define C_006D4C_D2MODE_PRIORITY_B_ALWAYS_ON 0xFFEFFFFF
587#define S_006D4C_D2MODE_PRIORITY_B_FORCE_MASK(x) (((x) & 0x1) << 24)
588#define G_006D4C_D2MODE_PRIORITY_B_FORCE_MASK(x) (((x) >> 24) & 0x1)
589#define C_006D4C_D2MODE_PRIORITY_B_FORCE_MASK 0xFEFFFFFF
590
538#endif 591#endif
diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
index 83b9174f76f..bbf3da790fd 100644
--- a/drivers/gpu/drm/radeon/rs690.c
+++ b/drivers/gpu/drm/radeon/rs690.c
@@ -27,6 +27,7 @@
27 */ 27 */
28#include "drmP.h" 28#include "drmP.h"
29#include "radeon.h" 29#include "radeon.h"
30#include "radeon_asic.h"
30#include "atom.h" 31#include "atom.h"
31#include "rs690d.h" 32#include "rs690d.h"
32 33
@@ -57,42 +58,57 @@ static void rs690_gpu_init(struct radeon_device *rdev)
57 } 58 }
58} 59}
59 60
61union igp_info {
62 struct _ATOM_INTEGRATED_SYSTEM_INFO info;
63 struct _ATOM_INTEGRATED_SYSTEM_INFO_V2 info_v2;
64};
65
60void rs690_pm_info(struct radeon_device *rdev) 66void rs690_pm_info(struct radeon_device *rdev)
61{ 67{
62 int index = GetIndexIntoMasterTable(DATA, IntegratedSystemInfo); 68 int index = GetIndexIntoMasterTable(DATA, IntegratedSystemInfo);
63 struct _ATOM_INTEGRATED_SYSTEM_INFO *info; 69 union igp_info *info;
64 struct _ATOM_INTEGRATED_SYSTEM_INFO_V2 *info_v2;
65 void *ptr;
66 uint16_t data_offset; 70 uint16_t data_offset;
67 uint8_t frev, crev; 71 uint8_t frev, crev;
68 fixed20_12 tmp; 72 fixed20_12 tmp;
69 73
70 atom_parse_data_header(rdev->mode_info.atom_context, index, NULL, 74 if (atom_parse_data_header(rdev->mode_info.atom_context, index, NULL,
71 &frev, &crev, &data_offset); 75 &frev, &crev, &data_offset)) {
72 ptr = rdev->mode_info.atom_context->bios + data_offset; 76 info = (union igp_info *)(rdev->mode_info.atom_context->bios + data_offset);
73 info = (struct _ATOM_INTEGRATED_SYSTEM_INFO *)ptr; 77
74 info_v2 = (struct _ATOM_INTEGRATED_SYSTEM_INFO_V2 *)ptr; 78 /* Get various system informations from bios */
75 /* Get various system informations from bios */ 79 switch (crev) {
76 switch (crev) { 80 case 1:
77 case 1: 81 tmp.full = rfixed_const(100);
78 tmp.full = rfixed_const(100); 82 rdev->pm.igp_sideport_mclk.full = rfixed_const(info->info.ulBootUpMemoryClock);
79 rdev->pm.igp_sideport_mclk.full = rfixed_const(info->ulBootUpMemoryClock); 83 rdev->pm.igp_sideport_mclk.full = rfixed_div(rdev->pm.igp_sideport_mclk, tmp);
80 rdev->pm.igp_sideport_mclk.full = rfixed_div(rdev->pm.igp_sideport_mclk, tmp); 84 rdev->pm.igp_system_mclk.full = rfixed_const(le16_to_cpu(info->info.usK8MemoryClock));
81 rdev->pm.igp_system_mclk.full = rfixed_const(le16_to_cpu(info->usK8MemoryClock)); 85 rdev->pm.igp_ht_link_clk.full = rfixed_const(le16_to_cpu(info->info.usFSBClock));
82 rdev->pm.igp_ht_link_clk.full = rfixed_const(le16_to_cpu(info->usFSBClock)); 86 rdev->pm.igp_ht_link_width.full = rfixed_const(info->info.ucHTLinkWidth);
83 rdev->pm.igp_ht_link_width.full = rfixed_const(info->ucHTLinkWidth); 87 break;
84 break; 88 case 2:
85 case 2: 89 tmp.full = rfixed_const(100);
86 tmp.full = rfixed_const(100); 90 rdev->pm.igp_sideport_mclk.full = rfixed_const(info->info_v2.ulBootUpSidePortClock);
87 rdev->pm.igp_sideport_mclk.full = rfixed_const(info_v2->ulBootUpSidePortClock); 91 rdev->pm.igp_sideport_mclk.full = rfixed_div(rdev->pm.igp_sideport_mclk, tmp);
88 rdev->pm.igp_sideport_mclk.full = rfixed_div(rdev->pm.igp_sideport_mclk, tmp); 92 rdev->pm.igp_system_mclk.full = rfixed_const(info->info_v2.ulBootUpUMAClock);
89 rdev->pm.igp_system_mclk.full = rfixed_const(info_v2->ulBootUpUMAClock); 93 rdev->pm.igp_system_mclk.full = rfixed_div(rdev->pm.igp_system_mclk, tmp);
90 rdev->pm.igp_system_mclk.full = rfixed_div(rdev->pm.igp_system_mclk, tmp); 94 rdev->pm.igp_ht_link_clk.full = rfixed_const(info->info_v2.ulHTLinkFreq);
91 rdev->pm.igp_ht_link_clk.full = rfixed_const(info_v2->ulHTLinkFreq); 95 rdev->pm.igp_ht_link_clk.full = rfixed_div(rdev->pm.igp_ht_link_clk, tmp);
92 rdev->pm.igp_ht_link_clk.full = rfixed_div(rdev->pm.igp_ht_link_clk, tmp); 96 rdev->pm.igp_ht_link_width.full = rfixed_const(le16_to_cpu(info->info_v2.usMinHTLinkWidth));
93 rdev->pm.igp_ht_link_width.full = rfixed_const(le16_to_cpu(info_v2->usMinHTLinkWidth)); 97 break;
94 break; 98 default:
95 default: 99 tmp.full = rfixed_const(100);
100 /* We assume the slower possible clock ie worst case */
101 /* DDR 333Mhz */
102 rdev->pm.igp_sideport_mclk.full = rfixed_const(333);
103 /* FIXME: system clock ? */
104 rdev->pm.igp_system_mclk.full = rfixed_const(100);
105 rdev->pm.igp_system_mclk.full = rfixed_div(rdev->pm.igp_system_mclk, tmp);
106 rdev->pm.igp_ht_link_clk.full = rfixed_const(200);
107 rdev->pm.igp_ht_link_width.full = rfixed_const(8);
108 DRM_ERROR("No integrated system info for your GPU, using safe default\n");
109 break;
110 }
111 } else {
96 tmp.full = rfixed_const(100); 112 tmp.full = rfixed_const(100);
97 /* We assume the slower possible clock ie worst case */ 113 /* We assume the slower possible clock ie worst case */
98 /* DDR 333Mhz */ 114 /* DDR 333Mhz */
@@ -103,7 +119,6 @@ void rs690_pm_info(struct radeon_device *rdev)
103 rdev->pm.igp_ht_link_clk.full = rfixed_const(200); 119 rdev->pm.igp_ht_link_clk.full = rfixed_const(200);
104 rdev->pm.igp_ht_link_width.full = rfixed_const(8); 120 rdev->pm.igp_ht_link_width.full = rfixed_const(8);
105 DRM_ERROR("No integrated system info for your GPU, using safe default\n"); 121 DRM_ERROR("No integrated system info for your GPU, using safe default\n");
106 break;
107 } 122 }
108 /* Compute various bandwidth */ 123 /* Compute various bandwidth */
109 /* k8_bandwidth = (memory_clk / 2) * 2 * 8 * 0.5 = memory_clk * 4 */ 124 /* k8_bandwidth = (memory_clk / 2) * 2 * 8 * 0.5 = memory_clk * 4 */
@@ -131,7 +146,6 @@ void rs690_pm_info(struct radeon_device *rdev)
131 146
132void rs690_mc_init(struct radeon_device *rdev) 147void rs690_mc_init(struct radeon_device *rdev)
133{ 148{
134 fixed20_12 a;
135 u64 base; 149 u64 base;
136 150
137 rs400_gart_adjust_size(rdev); 151 rs400_gart_adjust_size(rdev);
@@ -145,18 +159,10 @@ void rs690_mc_init(struct radeon_device *rdev)
145 base = RREG32_MC(R_000100_MCCFG_FB_LOCATION); 159 base = RREG32_MC(R_000100_MCCFG_FB_LOCATION);
146 base = G_000100_MC_FB_START(base) << 16; 160 base = G_000100_MC_FB_START(base) << 16;
147 rs690_pm_info(rdev); 161 rs690_pm_info(rdev);
148 /* FIXME: we should enforce default clock in case GPU is not in
149 * default setup
150 */
151 a.full = rfixed_const(100);
152 rdev->pm.sclk.full = rfixed_const(rdev->clock.default_sclk);
153 rdev->pm.sclk.full = rfixed_div(rdev->pm.sclk, a);
154 a.full = rfixed_const(16);
155 /* core_bandwidth = sclk(Mhz) * 16 */
156 rdev->pm.core_bandwidth.full = rfixed_div(rdev->pm.sclk, a);
157 rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev); 162 rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev);
158 radeon_vram_location(rdev, &rdev->mc, base); 163 radeon_vram_location(rdev, &rdev->mc, base);
159 radeon_gtt_location(rdev, &rdev->mc); 164 radeon_gtt_location(rdev, &rdev->mc);
165 radeon_update_bandwidth_info(rdev);
160} 166}
161 167
162void rs690_line_buffer_adjust(struct radeon_device *rdev, 168void rs690_line_buffer_adjust(struct radeon_device *rdev,
@@ -394,10 +400,12 @@ void rs690_bandwidth_update(struct radeon_device *rdev)
394 struct drm_display_mode *mode1 = NULL; 400 struct drm_display_mode *mode1 = NULL;
395 struct rs690_watermark wm0; 401 struct rs690_watermark wm0;
396 struct rs690_watermark wm1; 402 struct rs690_watermark wm1;
397 u32 tmp; 403 u32 tmp, d1mode_priority_a_cnt, d2mode_priority_a_cnt;
398 fixed20_12 priority_mark02, priority_mark12, fill_rate; 404 fixed20_12 priority_mark02, priority_mark12, fill_rate;
399 fixed20_12 a, b; 405 fixed20_12 a, b;
400 406
407 radeon_update_display_priority(rdev);
408
401 if (rdev->mode_info.crtcs[0]->base.enabled) 409 if (rdev->mode_info.crtcs[0]->base.enabled)
402 mode0 = &rdev->mode_info.crtcs[0]->base.mode; 410 mode0 = &rdev->mode_info.crtcs[0]->base.mode;
403 if (rdev->mode_info.crtcs[1]->base.enabled) 411 if (rdev->mode_info.crtcs[1]->base.enabled)
@@ -407,7 +415,8 @@ void rs690_bandwidth_update(struct radeon_device *rdev)
407 * modes if the user specifies HIGH for displaypriority 415 * modes if the user specifies HIGH for displaypriority
408 * option. 416 * option.
409 */ 417 */
410 if (rdev->disp_priority == 2) { 418 if ((rdev->disp_priority == 2) &&
419 ((rdev->family == CHIP_RS690) || (rdev->family == CHIP_RS740))) {
411 tmp = RREG32_MC(R_000104_MC_INIT_MISC_LAT_TIMER); 420 tmp = RREG32_MC(R_000104_MC_INIT_MISC_LAT_TIMER);
412 tmp &= C_000104_MC_DISP0R_INIT_LAT; 421 tmp &= C_000104_MC_DISP0R_INIT_LAT;
413 tmp &= C_000104_MC_DISP1R_INIT_LAT; 422 tmp &= C_000104_MC_DISP1R_INIT_LAT;
@@ -482,10 +491,16 @@ void rs690_bandwidth_update(struct radeon_device *rdev)
482 priority_mark12.full = 0; 491 priority_mark12.full = 0;
483 if (wm1.priority_mark_max.full > priority_mark12.full) 492 if (wm1.priority_mark_max.full > priority_mark12.full)
484 priority_mark12.full = wm1.priority_mark_max.full; 493 priority_mark12.full = wm1.priority_mark_max.full;
485 WREG32(R_006548_D1MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark02)); 494 d1mode_priority_a_cnt = rfixed_trunc(priority_mark02);
486 WREG32(R_00654C_D1MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark02)); 495 d2mode_priority_a_cnt = rfixed_trunc(priority_mark12);
487 WREG32(R_006D48_D2MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark12)); 496 if (rdev->disp_priority == 2) {
488 WREG32(R_006D4C_D2MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark12)); 497 d1mode_priority_a_cnt |= S_006548_D1MODE_PRIORITY_A_ALWAYS_ON(1);
498 d2mode_priority_a_cnt |= S_006D48_D2MODE_PRIORITY_A_ALWAYS_ON(1);
499 }
500 WREG32(R_006548_D1MODE_PRIORITY_A_CNT, d1mode_priority_a_cnt);
501 WREG32(R_00654C_D1MODE_PRIORITY_B_CNT, d1mode_priority_a_cnt);
502 WREG32(R_006D48_D2MODE_PRIORITY_A_CNT, d2mode_priority_a_cnt);
503 WREG32(R_006D4C_D2MODE_PRIORITY_B_CNT, d2mode_priority_a_cnt);
489 } else if (mode0) { 504 } else if (mode0) {
490 if (rfixed_trunc(wm0.dbpp) > 64) 505 if (rfixed_trunc(wm0.dbpp) > 64)
491 a.full = rfixed_mul(wm0.dbpp, wm0.num_line_pair); 506 a.full = rfixed_mul(wm0.dbpp, wm0.num_line_pair);
@@ -512,8 +527,11 @@ void rs690_bandwidth_update(struct radeon_device *rdev)
512 priority_mark02.full = 0; 527 priority_mark02.full = 0;
513 if (wm0.priority_mark_max.full > priority_mark02.full) 528 if (wm0.priority_mark_max.full > priority_mark02.full)
514 priority_mark02.full = wm0.priority_mark_max.full; 529 priority_mark02.full = wm0.priority_mark_max.full;
515 WREG32(R_006548_D1MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark02)); 530 d1mode_priority_a_cnt = rfixed_trunc(priority_mark02);
516 WREG32(R_00654C_D1MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark02)); 531 if (rdev->disp_priority == 2)
532 d1mode_priority_a_cnt |= S_006548_D1MODE_PRIORITY_A_ALWAYS_ON(1);
533 WREG32(R_006548_D1MODE_PRIORITY_A_CNT, d1mode_priority_a_cnt);
534 WREG32(R_00654C_D1MODE_PRIORITY_B_CNT, d1mode_priority_a_cnt);
517 WREG32(R_006D48_D2MODE_PRIORITY_A_CNT, 535 WREG32(R_006D48_D2MODE_PRIORITY_A_CNT,
518 S_006D48_D2MODE_PRIORITY_A_OFF(1)); 536 S_006D48_D2MODE_PRIORITY_A_OFF(1));
519 WREG32(R_006D4C_D2MODE_PRIORITY_B_CNT, 537 WREG32(R_006D4C_D2MODE_PRIORITY_B_CNT,
@@ -544,12 +562,15 @@ void rs690_bandwidth_update(struct radeon_device *rdev)
544 priority_mark12.full = 0; 562 priority_mark12.full = 0;
545 if (wm1.priority_mark_max.full > priority_mark12.full) 563 if (wm1.priority_mark_max.full > priority_mark12.full)
546 priority_mark12.full = wm1.priority_mark_max.full; 564 priority_mark12.full = wm1.priority_mark_max.full;
565 d2mode_priority_a_cnt = rfixed_trunc(priority_mark12);
566 if (rdev->disp_priority == 2)
567 d2mode_priority_a_cnt |= S_006D48_D2MODE_PRIORITY_A_ALWAYS_ON(1);
547 WREG32(R_006548_D1MODE_PRIORITY_A_CNT, 568 WREG32(R_006548_D1MODE_PRIORITY_A_CNT,
548 S_006548_D1MODE_PRIORITY_A_OFF(1)); 569 S_006548_D1MODE_PRIORITY_A_OFF(1));
549 WREG32(R_00654C_D1MODE_PRIORITY_B_CNT, 570 WREG32(R_00654C_D1MODE_PRIORITY_B_CNT,
550 S_00654C_D1MODE_PRIORITY_B_OFF(1)); 571 S_00654C_D1MODE_PRIORITY_B_OFF(1));
551 WREG32(R_006D48_D2MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark12)); 572 WREG32(R_006D48_D2MODE_PRIORITY_A_CNT, d2mode_priority_a_cnt);
552 WREG32(R_006D4C_D2MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark12)); 573 WREG32(R_006D4C_D2MODE_PRIORITY_B_CNT, d2mode_priority_a_cnt);
553 } 574 }
554} 575}
555 576
@@ -657,6 +678,7 @@ int rs690_suspend(struct radeon_device *rdev)
657 678
658void rs690_fini(struct radeon_device *rdev) 679void rs690_fini(struct radeon_device *rdev)
659{ 680{
681 radeon_pm_fini(rdev);
660 r100_cp_fini(rdev); 682 r100_cp_fini(rdev);
661 r100_wb_fini(rdev); 683 r100_wb_fini(rdev);
662 r100_ib_fini(rdev); 684 r100_ib_fini(rdev);
diff --git a/drivers/gpu/drm/radeon/rs690d.h b/drivers/gpu/drm/radeon/rs690d.h
index 62d31e7a897..36e6398a98a 100644
--- a/drivers/gpu/drm/radeon/rs690d.h
+++ b/drivers/gpu/drm/radeon/rs690d.h
@@ -182,6 +182,9 @@
182#define S_006548_D1MODE_PRIORITY_A_OFF(x) (((x) & 0x1) << 16) 182#define S_006548_D1MODE_PRIORITY_A_OFF(x) (((x) & 0x1) << 16)
183#define G_006548_D1MODE_PRIORITY_A_OFF(x) (((x) >> 16) & 0x1) 183#define G_006548_D1MODE_PRIORITY_A_OFF(x) (((x) >> 16) & 0x1)
184#define C_006548_D1MODE_PRIORITY_A_OFF 0xFFFEFFFF 184#define C_006548_D1MODE_PRIORITY_A_OFF 0xFFFEFFFF
185#define S_006548_D1MODE_PRIORITY_A_ALWAYS_ON(x) (((x) & 0x1) << 20)
186#define G_006548_D1MODE_PRIORITY_A_ALWAYS_ON(x) (((x) >> 20) & 0x1)
187#define C_006548_D1MODE_PRIORITY_A_ALWAYS_ON 0xFFEFFFFF
185#define S_006548_D1MODE_PRIORITY_A_FORCE_MASK(x) (((x) & 0x1) << 24) 188#define S_006548_D1MODE_PRIORITY_A_FORCE_MASK(x) (((x) & 0x1) << 24)
186#define G_006548_D1MODE_PRIORITY_A_FORCE_MASK(x) (((x) >> 24) & 0x1) 189#define G_006548_D1MODE_PRIORITY_A_FORCE_MASK(x) (((x) >> 24) & 0x1)
187#define C_006548_D1MODE_PRIORITY_A_FORCE_MASK 0xFEFFFFFF 190#define C_006548_D1MODE_PRIORITY_A_FORCE_MASK 0xFEFFFFFF
diff --git a/drivers/gpu/drm/radeon/rv515.c b/drivers/gpu/drm/radeon/rv515.c
index bea747da123..9035121f4b5 100644
--- a/drivers/gpu/drm/radeon/rv515.c
+++ b/drivers/gpu/drm/radeon/rv515.c
@@ -26,9 +26,11 @@
26 * Jerome Glisse 26 * Jerome Glisse
27 */ 27 */
28#include <linux/seq_file.h> 28#include <linux/seq_file.h>
29#include <linux/slab.h>
29#include "drmP.h" 30#include "drmP.h"
30#include "rv515d.h" 31#include "rv515d.h"
31#include "radeon.h" 32#include "radeon.h"
33#include "radeon_asic.h"
32#include "atom.h" 34#include "atom.h"
33#include "rv515_reg_safe.h" 35#include "rv515_reg_safe.h"
34 36
@@ -279,19 +281,13 @@ static void rv515_vram_get_type(struct radeon_device *rdev)
279 281
280void rv515_mc_init(struct radeon_device *rdev) 282void rv515_mc_init(struct radeon_device *rdev)
281{ 283{
282 fixed20_12 a;
283 284
284 rv515_vram_get_type(rdev); 285 rv515_vram_get_type(rdev);
285 r100_vram_init_sizes(rdev); 286 r100_vram_init_sizes(rdev);
286 radeon_vram_location(rdev, &rdev->mc, 0); 287 radeon_vram_location(rdev, &rdev->mc, 0);
287 if (!(rdev->flags & RADEON_IS_AGP)) 288 if (!(rdev->flags & RADEON_IS_AGP))
288 radeon_gtt_location(rdev, &rdev->mc); 289 radeon_gtt_location(rdev, &rdev->mc);
289 /* FIXME: we should enforce default clock in case GPU is not in 290 radeon_update_bandwidth_info(rdev);
290 * default setup
291 */
292 a.full = rfixed_const(100);
293 rdev->pm.sclk.full = rfixed_const(rdev->clock.default_sclk);
294 rdev->pm.sclk.full = rfixed_div(rdev->pm.sclk, a);
295} 291}
296 292
297uint32_t rv515_mc_rreg(struct radeon_device *rdev, uint32_t reg) 293uint32_t rv515_mc_rreg(struct radeon_device *rdev, uint32_t reg)
@@ -539,6 +535,7 @@ void rv515_set_safe_registers(struct radeon_device *rdev)
539 535
540void rv515_fini(struct radeon_device *rdev) 536void rv515_fini(struct radeon_device *rdev)
541{ 537{
538 radeon_pm_fini(rdev);
542 r100_cp_fini(rdev); 539 r100_cp_fini(rdev);
543 r100_wb_fini(rdev); 540 r100_wb_fini(rdev);
544 r100_ib_fini(rdev); 541 r100_ib_fini(rdev);
@@ -1020,7 +1017,7 @@ void rv515_bandwidth_avivo_update(struct radeon_device *rdev)
1020 struct drm_display_mode *mode1 = NULL; 1017 struct drm_display_mode *mode1 = NULL;
1021 struct rv515_watermark wm0; 1018 struct rv515_watermark wm0;
1022 struct rv515_watermark wm1; 1019 struct rv515_watermark wm1;
1023 u32 tmp; 1020 u32 tmp, d1mode_priority_a_cnt, d2mode_priority_a_cnt;
1024 fixed20_12 priority_mark02, priority_mark12, fill_rate; 1021 fixed20_12 priority_mark02, priority_mark12, fill_rate;
1025 fixed20_12 a, b; 1022 fixed20_12 a, b;
1026 1023
@@ -1088,10 +1085,16 @@ void rv515_bandwidth_avivo_update(struct radeon_device *rdev)
1088 priority_mark12.full = 0; 1085 priority_mark12.full = 0;
1089 if (wm1.priority_mark_max.full > priority_mark12.full) 1086 if (wm1.priority_mark_max.full > priority_mark12.full)
1090 priority_mark12.full = wm1.priority_mark_max.full; 1087 priority_mark12.full = wm1.priority_mark_max.full;
1091 WREG32(D1MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark02)); 1088 d1mode_priority_a_cnt = rfixed_trunc(priority_mark02);
1092 WREG32(D1MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark02)); 1089 d2mode_priority_a_cnt = rfixed_trunc(priority_mark12);
1093 WREG32(D2MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark12)); 1090 if (rdev->disp_priority == 2) {
1094 WREG32(D2MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark12)); 1091 d1mode_priority_a_cnt |= MODE_PRIORITY_ALWAYS_ON;
1092 d2mode_priority_a_cnt |= MODE_PRIORITY_ALWAYS_ON;
1093 }
1094 WREG32(D1MODE_PRIORITY_A_CNT, d1mode_priority_a_cnt);
1095 WREG32(D1MODE_PRIORITY_B_CNT, d1mode_priority_a_cnt);
1096 WREG32(D2MODE_PRIORITY_A_CNT, d2mode_priority_a_cnt);
1097 WREG32(D2MODE_PRIORITY_B_CNT, d2mode_priority_a_cnt);
1095 } else if (mode0) { 1098 } else if (mode0) {
1096 if (rfixed_trunc(wm0.dbpp) > 64) 1099 if (rfixed_trunc(wm0.dbpp) > 64)
1097 a.full = rfixed_div(wm0.dbpp, wm0.num_line_pair); 1100 a.full = rfixed_div(wm0.dbpp, wm0.num_line_pair);
@@ -1118,8 +1121,11 @@ void rv515_bandwidth_avivo_update(struct radeon_device *rdev)
1118 priority_mark02.full = 0; 1121 priority_mark02.full = 0;
1119 if (wm0.priority_mark_max.full > priority_mark02.full) 1122 if (wm0.priority_mark_max.full > priority_mark02.full)
1120 priority_mark02.full = wm0.priority_mark_max.full; 1123 priority_mark02.full = wm0.priority_mark_max.full;
1121 WREG32(D1MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark02)); 1124 d1mode_priority_a_cnt = rfixed_trunc(priority_mark02);
1122 WREG32(D1MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark02)); 1125 if (rdev->disp_priority == 2)
1126 d1mode_priority_a_cnt |= MODE_PRIORITY_ALWAYS_ON;
1127 WREG32(D1MODE_PRIORITY_A_CNT, d1mode_priority_a_cnt);
1128 WREG32(D1MODE_PRIORITY_B_CNT, d1mode_priority_a_cnt);
1123 WREG32(D2MODE_PRIORITY_A_CNT, MODE_PRIORITY_OFF); 1129 WREG32(D2MODE_PRIORITY_A_CNT, MODE_PRIORITY_OFF);
1124 WREG32(D2MODE_PRIORITY_B_CNT, MODE_PRIORITY_OFF); 1130 WREG32(D2MODE_PRIORITY_B_CNT, MODE_PRIORITY_OFF);
1125 } else { 1131 } else {
@@ -1148,10 +1154,13 @@ void rv515_bandwidth_avivo_update(struct radeon_device *rdev)
1148 priority_mark12.full = 0; 1154 priority_mark12.full = 0;
1149 if (wm1.priority_mark_max.full > priority_mark12.full) 1155 if (wm1.priority_mark_max.full > priority_mark12.full)
1150 priority_mark12.full = wm1.priority_mark_max.full; 1156 priority_mark12.full = wm1.priority_mark_max.full;
1157 d2mode_priority_a_cnt = rfixed_trunc(priority_mark12);
1158 if (rdev->disp_priority == 2)
1159 d2mode_priority_a_cnt |= MODE_PRIORITY_ALWAYS_ON;
1151 WREG32(D1MODE_PRIORITY_A_CNT, MODE_PRIORITY_OFF); 1160 WREG32(D1MODE_PRIORITY_A_CNT, MODE_PRIORITY_OFF);
1152 WREG32(D1MODE_PRIORITY_B_CNT, MODE_PRIORITY_OFF); 1161 WREG32(D1MODE_PRIORITY_B_CNT, MODE_PRIORITY_OFF);
1153 WREG32(D2MODE_PRIORITY_A_CNT, rfixed_trunc(priority_mark12)); 1162 WREG32(D2MODE_PRIORITY_A_CNT, d2mode_priority_a_cnt);
1154 WREG32(D2MODE_PRIORITY_B_CNT, rfixed_trunc(priority_mark12)); 1163 WREG32(D2MODE_PRIORITY_B_CNT, d2mode_priority_a_cnt);
1155 } 1164 }
1156} 1165}
1157 1166
@@ -1161,6 +1170,8 @@ void rv515_bandwidth_update(struct radeon_device *rdev)
1161 struct drm_display_mode *mode0 = NULL; 1170 struct drm_display_mode *mode0 = NULL;
1162 struct drm_display_mode *mode1 = NULL; 1171 struct drm_display_mode *mode1 = NULL;
1163 1172
1173 radeon_update_display_priority(rdev);
1174
1164 if (rdev->mode_info.crtcs[0]->base.enabled) 1175 if (rdev->mode_info.crtcs[0]->base.enabled)
1165 mode0 = &rdev->mode_info.crtcs[0]->base.mode; 1176 mode0 = &rdev->mode_info.crtcs[0]->base.mode;
1166 if (rdev->mode_info.crtcs[1]->base.enabled) 1177 if (rdev->mode_info.crtcs[1]->base.enabled)
@@ -1170,7 +1181,8 @@ void rv515_bandwidth_update(struct radeon_device *rdev)
1170 * modes if the user specifies HIGH for displaypriority 1181 * modes if the user specifies HIGH for displaypriority
1171 * option. 1182 * option.
1172 */ 1183 */
1173 if (rdev->disp_priority == 2) { 1184 if ((rdev->disp_priority == 2) &&
1185 (rdev->family == CHIP_RV515)) {
1174 tmp = RREG32_MC(MC_MISC_LAT_TIMER); 1186 tmp = RREG32_MC(MC_MISC_LAT_TIMER);
1175 tmp &= ~MC_DISP1R_INIT_LAT_MASK; 1187 tmp &= ~MC_DISP1R_INIT_LAT_MASK;
1176 tmp &= ~MC_DISP0R_INIT_LAT_MASK; 1188 tmp &= ~MC_DISP0R_INIT_LAT_MASK;
diff --git a/drivers/gpu/drm/radeon/rv770.c b/drivers/gpu/drm/radeon/rv770.c
index 37887dee12a..97958a64df1 100644
--- a/drivers/gpu/drm/radeon/rv770.c
+++ b/drivers/gpu/drm/radeon/rv770.c
@@ -27,8 +27,10 @@
27 */ 27 */
28#include <linux/firmware.h> 28#include <linux/firmware.h>
29#include <linux/platform_device.h> 29#include <linux/platform_device.h>
30#include <linux/slab.h>
30#include "drmP.h" 31#include "drmP.h"
31#include "radeon.h" 32#include "radeon.h"
33#include "radeon_asic.h"
32#include "radeon_drm.h" 34#include "radeon_drm.h"
33#include "rv770d.h" 35#include "rv770d.h"
34#include "atom.h" 36#include "atom.h"
@@ -125,9 +127,9 @@ void rv770_pcie_gart_disable(struct radeon_device *rdev)
125 127
126void rv770_pcie_gart_fini(struct radeon_device *rdev) 128void rv770_pcie_gart_fini(struct radeon_device *rdev)
127{ 129{
130 radeon_gart_fini(rdev);
128 rv770_pcie_gart_disable(rdev); 131 rv770_pcie_gart_disable(rdev);
129 radeon_gart_table_vram_free(rdev); 132 radeon_gart_table_vram_free(rdev);
130 radeon_gart_fini(rdev);
131} 133}
132 134
133 135
@@ -647,10 +649,13 @@ static void rv770_gpu_init(struct radeon_device *rdev)
647 649
648 WREG32(CC_RB_BACKEND_DISABLE, cc_rb_backend_disable); 650 WREG32(CC_RB_BACKEND_DISABLE, cc_rb_backend_disable);
649 WREG32(CC_GC_SHADER_PIPE_CONFIG, cc_gc_shader_pipe_config); 651 WREG32(CC_GC_SHADER_PIPE_CONFIG, cc_gc_shader_pipe_config);
652 WREG32(GC_USER_SHADER_PIPE_CONFIG, cc_gc_shader_pipe_config);
650 WREG32(CC_SYS_RB_BACKEND_DISABLE, cc_rb_backend_disable); 653 WREG32(CC_SYS_RB_BACKEND_DISABLE, cc_rb_backend_disable);
651 654
652 WREG32(CGTS_SYS_TCC_DISABLE, 0); 655 WREG32(CGTS_SYS_TCC_DISABLE, 0);
653 WREG32(CGTS_TCC_DISABLE, 0); 656 WREG32(CGTS_TCC_DISABLE, 0);
657 WREG32(CGTS_USER_SYS_TCC_DISABLE, 0);
658 WREG32(CGTS_USER_TCC_DISABLE, 0);
654 659
655 num_qd_pipes = 660 num_qd_pipes =
656 R7XX_MAX_PIPES - r600_count_pipe_bits((cc_gc_shader_pipe_config & INACTIVE_QD_PIPES_MASK) >> 8); 661 R7XX_MAX_PIPES - r600_count_pipe_bits((cc_gc_shader_pipe_config & INACTIVE_QD_PIPES_MASK) >> 8);
@@ -864,7 +869,6 @@ static void rv770_gpu_init(struct radeon_device *rdev)
864 869
865int rv770_mc_init(struct radeon_device *rdev) 870int rv770_mc_init(struct radeon_device *rdev)
866{ 871{
867 fixed20_12 a;
868 u32 tmp; 872 u32 tmp;
869 int chansize, numchan; 873 int chansize, numchan;
870 874
@@ -908,12 +912,8 @@ int rv770_mc_init(struct radeon_device *rdev)
908 rdev->mc.real_vram_size = rdev->mc.aper_size; 912 rdev->mc.real_vram_size = rdev->mc.aper_size;
909 } 913 }
910 r600_vram_gtt_location(rdev, &rdev->mc); 914 r600_vram_gtt_location(rdev, &rdev->mc);
911 /* FIXME: we should enforce default clock in case GPU is not in 915 radeon_update_bandwidth_info(rdev);
912 * default setup 916
913 */
914 a.full = rfixed_const(100);
915 rdev->pm.sclk.full = rfixed_const(rdev->clock.default_sclk);
916 rdev->pm.sclk.full = rfixed_div(rdev->pm.sclk, a);
917 return 0; 917 return 0;
918} 918}
919 919
@@ -1013,6 +1013,13 @@ int rv770_resume(struct radeon_device *rdev)
1013 DRM_ERROR("radeon: failled testing IB (%d).\n", r); 1013 DRM_ERROR("radeon: failled testing IB (%d).\n", r);
1014 return r; 1014 return r;
1015 } 1015 }
1016
1017 r = r600_audio_init(rdev);
1018 if (r) {
1019 dev_err(rdev->dev, "radeon: audio init failed\n");
1020 return r;
1021 }
1022
1016 return r; 1023 return r;
1017 1024
1018} 1025}
@@ -1021,6 +1028,7 @@ int rv770_suspend(struct radeon_device *rdev)
1021{ 1028{
1022 int r; 1029 int r;
1023 1030
1031 r600_audio_fini(rdev);
1024 /* FIXME: we should wait for ring to be empty */ 1032 /* FIXME: we should wait for ring to be empty */
1025 r700_cp_stop(rdev); 1033 r700_cp_stop(rdev);
1026 rdev->cp.ready = false; 1034 rdev->cp.ready = false;
@@ -1144,11 +1152,19 @@ int rv770_init(struct radeon_device *rdev)
1144 } 1152 }
1145 } 1153 }
1146 } 1154 }
1155
1156 r = r600_audio_init(rdev);
1157 if (r) {
1158 dev_err(rdev->dev, "radeon: audio init failed\n");
1159 return r;
1160 }
1161
1147 return 0; 1162 return 0;
1148} 1163}
1149 1164
1150void rv770_fini(struct radeon_device *rdev) 1165void rv770_fini(struct radeon_device *rdev)
1151{ 1166{
1167 radeon_pm_fini(rdev);
1152 r600_blit_fini(rdev); 1168 r600_blit_fini(rdev);
1153 r600_cp_fini(rdev); 1169 r600_cp_fini(rdev);
1154 r600_wb_fini(rdev); 1170 r600_wb_fini(rdev);
diff --git a/drivers/gpu/drm/ttm/ttm_agp_backend.c b/drivers/gpu/drm/ttm/ttm_agp_backend.c
index 4648ed2f014..4bf69c40449 100644
--- a/drivers/gpu/drm/ttm/ttm_agp_backend.c
+++ b/drivers/gpu/drm/ttm/ttm_agp_backend.c
@@ -35,6 +35,7 @@
35#include "ttm/ttm_placement.h" 35#include "ttm/ttm_placement.h"
36#include <linux/agp_backend.h> 36#include <linux/agp_backend.h>
37#include <linux/module.h> 37#include <linux/module.h>
38#include <linux/slab.h>
38#include <linux/io.h> 39#include <linux/io.h>
39#include <asm/agp.h> 40#include <asm/agp.h>
40 41
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 89c38c49066..0e3754a3a30 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1425,8 +1425,8 @@ int ttm_bo_global_init(struct ttm_global_reference *ref)
1425 1425
1426 atomic_set(&glob->bo_count, 0); 1426 atomic_set(&glob->bo_count, 0);
1427 1427
1428 kobject_init(&glob->kobj, &ttm_bo_glob_kobj_type); 1428 ret = kobject_init_and_add(
1429 ret = kobject_add(&glob->kobj, ttm_get_kobj(), "buffer_objects"); 1429 &glob->kobj, &ttm_bo_glob_kobj_type, ttm_get_kobj(), "buffer_objects");
1430 if (unlikely(ret != 0)) 1430 if (unlikely(ret != 0))
1431 kobject_put(&glob->kobj); 1431 kobject_put(&glob->kobj);
1432 return ret; 1432 return ret;
@@ -1716,40 +1716,12 @@ int ttm_bo_wait(struct ttm_buffer_object *bo,
1716} 1716}
1717EXPORT_SYMBOL(ttm_bo_wait); 1717EXPORT_SYMBOL(ttm_bo_wait);
1718 1718
1719void ttm_bo_unblock_reservation(struct ttm_buffer_object *bo)
1720{
1721 atomic_set(&bo->reserved, 0);
1722 wake_up_all(&bo->event_queue);
1723}
1724
1725int ttm_bo_block_reservation(struct ttm_buffer_object *bo, bool interruptible,
1726 bool no_wait)
1727{
1728 int ret;
1729
1730 while (unlikely(atomic_cmpxchg(&bo->reserved, 0, 1) != 0)) {
1731 if (no_wait)
1732 return -EBUSY;
1733 else if (interruptible) {
1734 ret = wait_event_interruptible
1735 (bo->event_queue, atomic_read(&bo->reserved) == 0);
1736 if (unlikely(ret != 0))
1737 return ret;
1738 } else {
1739 wait_event(bo->event_queue,
1740 atomic_read(&bo->reserved) == 0);
1741 }
1742 }
1743 return 0;
1744}
1745
1746int ttm_bo_synccpu_write_grab(struct ttm_buffer_object *bo, bool no_wait) 1719int ttm_bo_synccpu_write_grab(struct ttm_buffer_object *bo, bool no_wait)
1747{ 1720{
1748 int ret = 0; 1721 int ret = 0;
1749 1722
1750 /* 1723 /*
1751 * Using ttm_bo_reserve instead of ttm_bo_block_reservation 1724 * Using ttm_bo_reserve makes sure the lru lists are updated.
1752 * makes sure the lru lists are updated.
1753 */ 1725 */
1754 1726
1755 ret = ttm_bo_reserve(bo, true, no_wait, false, 0); 1727 ret = ttm_bo_reserve(bo, true, no_wait, false, 0);
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 5ca37a58a98..d764e82e799 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -33,6 +33,7 @@
33#include <linux/io.h> 33#include <linux/io.h>
34#include <linux/highmem.h> 34#include <linux/highmem.h>
35#include <linux/wait.h> 35#include <linux/wait.h>
36#include <linux/slab.h>
36#include <linux/vmalloc.h> 37#include <linux/vmalloc.h>
37#include <linux/module.h> 38#include <linux/module.h>
38 39
diff --git a/drivers/gpu/drm/ttm/ttm_lock.c b/drivers/gpu/drm/ttm/ttm_lock.c
index 3d172ef04ee..de41e55a944 100644
--- a/drivers/gpu/drm/ttm/ttm_lock.c
+++ b/drivers/gpu/drm/ttm/ttm_lock.c
@@ -204,7 +204,6 @@ static int __ttm_vt_unlock(struct ttm_lock *lock)
204 lock->flags &= ~TTM_VT_LOCK; 204 lock->flags &= ~TTM_VT_LOCK;
205 wake_up_all(&lock->queue); 205 wake_up_all(&lock->queue);
206 spin_unlock(&lock->lock); 206 spin_unlock(&lock->lock);
207 printk(KERN_INFO TTM_PFX "vt unlock.\n");
208 207
209 return ret; 208 return ret;
210} 209}
@@ -265,10 +264,8 @@ int ttm_vt_lock(struct ttm_lock *lock,
265 ttm_lock_type, &ttm_vt_lock_remove, NULL); 264 ttm_lock_type, &ttm_vt_lock_remove, NULL);
266 if (ret) 265 if (ret)
267 (void)__ttm_vt_unlock(lock); 266 (void)__ttm_vt_unlock(lock);
268 else { 267 else
269 lock->vt_holder = tfile; 268 lock->vt_holder = tfile;
270 printk(KERN_INFO TTM_PFX "vt lock.\n");
271 }
272 269
273 return ret; 270 return ret;
274} 271}
diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
index eb143e04d40..801b702566e 100644
--- a/drivers/gpu/drm/ttm/ttm_memory.c
+++ b/drivers/gpu/drm/ttm/ttm_memory.c
@@ -32,6 +32,7 @@
32#include <linux/wait.h> 32#include <linux/wait.h>
33#include <linux/mm.h> 33#include <linux/mm.h>
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/slab.h>
35 36
36#define TTM_MEMORY_ALLOC_RETRIES 4 37#define TTM_MEMORY_ALLOC_RETRIES 4
37 38
@@ -260,8 +261,8 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
260 zone->used_mem = 0; 261 zone->used_mem = 0;
261 zone->glob = glob; 262 zone->glob = glob;
262 glob->zone_kernel = zone; 263 glob->zone_kernel = zone;
263 kobject_init(&zone->kobj, &ttm_mem_zone_kobj_type); 264 ret = kobject_init_and_add(
264 ret = kobject_add(&zone->kobj, &glob->kobj, zone->name); 265 &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
265 if (unlikely(ret != 0)) { 266 if (unlikely(ret != 0)) {
266 kobject_put(&zone->kobj); 267 kobject_put(&zone->kobj);
267 return ret; 268 return ret;
@@ -296,8 +297,8 @@ static int ttm_mem_init_highmem_zone(struct ttm_mem_global *glob,
296 zone->used_mem = 0; 297 zone->used_mem = 0;
297 zone->glob = glob; 298 zone->glob = glob;
298 glob->zone_highmem = zone; 299 glob->zone_highmem = zone;
299 kobject_init(&zone->kobj, &ttm_mem_zone_kobj_type); 300 ret = kobject_init_and_add(
300 ret = kobject_add(&zone->kobj, &glob->kobj, zone->name); 301 &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
301 if (unlikely(ret != 0)) { 302 if (unlikely(ret != 0)) {
302 kobject_put(&zone->kobj); 303 kobject_put(&zone->kobj);
303 return ret; 304 return ret;
@@ -343,8 +344,8 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
343 zone->used_mem = 0; 344 zone->used_mem = 0;
344 zone->glob = glob; 345 zone->glob = glob;
345 glob->zone_dma32 = zone; 346 glob->zone_dma32 = zone;
346 kobject_init(&zone->kobj, &ttm_mem_zone_kobj_type); 347 ret = kobject_init_and_add(
347 ret = kobject_add(&zone->kobj, &glob->kobj, zone->name); 348 &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
348 if (unlikely(ret != 0)) { 349 if (unlikely(ret != 0)) {
349 kobject_put(&zone->kobj); 350 kobject_put(&zone->kobj);
350 return ret; 351 return ret;
@@ -365,10 +366,8 @@ int ttm_mem_global_init(struct ttm_mem_global *glob)
365 glob->swap_queue = create_singlethread_workqueue("ttm_swap"); 366 glob->swap_queue = create_singlethread_workqueue("ttm_swap");
366 INIT_WORK(&glob->work, ttm_shrink_work); 367 INIT_WORK(&glob->work, ttm_shrink_work);
367 init_waitqueue_head(&glob->queue); 368 init_waitqueue_head(&glob->queue);
368 kobject_init(&glob->kobj, &ttm_mem_glob_kobj_type); 369 ret = kobject_init_and_add(
369 ret = kobject_add(&glob->kobj, 370 &glob->kobj, &ttm_mem_glob_kobj_type, ttm_get_kobj(), "memory_accounting");
370 ttm_get_kobj(),
371 "memory_accounting");
372 if (unlikely(ret != 0)) { 371 if (unlikely(ret != 0)) {
373 kobject_put(&glob->kobj); 372 kobject_put(&glob->kobj);
374 return ret; 373 return ret;
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index a759170763b..d5fd5b8faeb 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -28,13 +28,14 @@
28 * Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com> 28 * Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
29 */ 29 */
30 30
31#include <linux/vmalloc.h>
32#include <linux/sched.h> 31#include <linux/sched.h>
33#include <linux/highmem.h> 32#include <linux/highmem.h>
34#include <linux/pagemap.h> 33#include <linux/pagemap.h>
35#include <linux/file.h> 34#include <linux/file.h>
36#include <linux/swap.h> 35#include <linux/swap.h>
36#include <linux/slab.h>
37#include "drm_cache.h" 37#include "drm_cache.h"
38#include "drm_mem_util.h"
38#include "ttm/ttm_module.h" 39#include "ttm/ttm_module.h"
39#include "ttm/ttm_bo_driver.h" 40#include "ttm/ttm_bo_driver.h"
40#include "ttm/ttm_placement.h" 41#include "ttm/ttm_placement.h"
@@ -43,32 +44,15 @@ static int ttm_tt_swapin(struct ttm_tt *ttm);
43 44
44/** 45/**
45 * Allocates storage for pointers to the pages that back the ttm. 46 * Allocates storage for pointers to the pages that back the ttm.
46 *
47 * Uses kmalloc if possible. Otherwise falls back to vmalloc.
48 */ 47 */
49static void ttm_tt_alloc_page_directory(struct ttm_tt *ttm) 48static void ttm_tt_alloc_page_directory(struct ttm_tt *ttm)
50{ 49{
51 unsigned long size = ttm->num_pages * sizeof(*ttm->pages); 50 ttm->pages = drm_calloc_large(ttm->num_pages, sizeof(*ttm->pages));
52 ttm->pages = NULL;
53
54 if (size <= PAGE_SIZE)
55 ttm->pages = kzalloc(size, GFP_KERNEL);
56
57 if (!ttm->pages) {
58 ttm->pages = vmalloc_user(size);
59 if (ttm->pages)
60 ttm->page_flags |= TTM_PAGE_FLAG_VMALLOC;
61 }
62} 51}
63 52
64static void ttm_tt_free_page_directory(struct ttm_tt *ttm) 53static void ttm_tt_free_page_directory(struct ttm_tt *ttm)
65{ 54{
66 if (ttm->page_flags & TTM_PAGE_FLAG_VMALLOC) { 55 drm_free_large(ttm->pages);
67 vfree(ttm->pages);
68 ttm->page_flags &= ~TTM_PAGE_FLAG_VMALLOC;
69 } else {
70 kfree(ttm->pages);
71 }
72 ttm->pages = NULL; 56 ttm->pages = NULL;
73} 57}
74 58
diff --git a/drivers/gpu/drm/via/via_dmablit.c b/drivers/gpu/drm/via/via_dmablit.c
index 327380888b4..4c54f043068 100644
--- a/drivers/gpu/drm/via/via_dmablit.c
+++ b/drivers/gpu/drm/via/via_dmablit.c
@@ -40,6 +40,7 @@
40#include "via_dmablit.h" 40#include "via_dmablit.h"
41 41
42#include <linux/pagemap.h> 42#include <linux/pagemap.h>
43#include <linux/slab.h>
43 44
44#define VIA_PGDN(x) (((unsigned long)(x)) & PAGE_MASK) 45#define VIA_PGDN(x) (((unsigned long)(x)) & PAGE_MASK)
45#define VIA_PGOFF(x) (((unsigned long)(x)) & ~PAGE_MASK) 46#define VIA_PGOFF(x) (((unsigned long)(x)) & ~PAGE_MASK)
diff --git a/drivers/gpu/drm/via/via_video.c b/drivers/gpu/drm/via/via_video.c
index 6ec04ac1245..6efac8117c9 100644
--- a/drivers/gpu/drm/via/via_video.c
+++ b/drivers/gpu/drm/via/via_video.c
@@ -75,7 +75,7 @@ int via_decoder_futex(struct drm_device *dev, void *data, struct drm_file *file_
75 75
76 DRM_DEBUG("\n"); 76 DRM_DEBUG("\n");
77 77
78 if (fx->lock > VIA_NR_XVMC_LOCKS) 78 if (fx->lock >= VIA_NR_XVMC_LOCKS)
79 return -EFAULT; 79 return -EFAULT;
80 80
81 lock = (volatile int *)XVMCLOCKPTR(sAPriv, fx->lock); 81 lock = (volatile int *)XVMCLOCKPTR(sAPriv, fx->lock);
diff --git a/drivers/gpu/drm/vmwgfx/Kconfig b/drivers/gpu/drm/vmwgfx/Kconfig
index f20b8bcbef3..30ad13344f7 100644
--- a/drivers/gpu/drm/vmwgfx/Kconfig
+++ b/drivers/gpu/drm/vmwgfx/Kconfig
@@ -1,6 +1,6 @@
1config DRM_VMWGFX 1config DRM_VMWGFX
2 tristate "DRM driver for VMware Virtual GPU" 2 tristate "DRM driver for VMware Virtual GPU"
3 depends on DRM && PCI 3 depends on DRM && PCI && FB
4 select FB_DEFERRED_IO 4 select FB_DEFERRED_IO
5 select FB_CFB_FILLRECT 5 select FB_CFB_FILLRECT
6 select FB_CFB_COPYAREA 6 select FB_CFB_COPYAREA
diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
index d6d1149d525..c8768f38511 100644
--- a/drivers/gpu/vga/vga_switcheroo.c
+++ b/drivers/gpu/vga/vga_switcheroo.c
@@ -276,8 +276,10 @@ vga_switcheroo_debugfs_write(struct file *filp, const char __user *ubuf,
276 276
277 mutex_lock(&vgasr_mutex); 277 mutex_lock(&vgasr_mutex);
278 278
279 if (!vgasr_priv.active) 279 if (!vgasr_priv.active) {
280 return -EINVAL; 280 cnt = -EINVAL;
281 goto out;
282 }
281 283
282 /* pwr off the device not in use */ 284 /* pwr off the device not in use */
283 if (strncmp(usercmd, "OFF", 3) == 0) { 285 if (strncmp(usercmd, "OFF", 3) == 0) {
diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c
index 8827814d073..441e38c95a8 100644
--- a/drivers/gpu/vga/vgaarb.c
+++ b/drivers/gpu/vga/vgaarb.c
@@ -20,6 +20,7 @@
20#include <linux/spinlock.h> 20#include <linux/spinlock.h>
21#include <linux/poll.h> 21#include <linux/poll.h>
22#include <linux/miscdevice.h> 22#include <linux/miscdevice.h>
23#include <linux/slab.h>
23 24
24#include <linux/uaccess.h> 25#include <linux/uaccess.h>
25 26
diff --git a/drivers/hid/hid-3m-pct.c b/drivers/hid/hid-3m-pct.c
index 2370aefc86b..c31e0be8cce 100644
--- a/drivers/hid/hid-3m-pct.c
+++ b/drivers/hid/hid-3m-pct.c
@@ -15,6 +15,7 @@
15#include <linux/device.h> 15#include <linux/device.h>
16#include <linux/hid.h> 16#include <linux/hid.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/slab.h>
18#include <linux/usb.h> 19#include <linux/usb.h>
19 20
20MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>"); 21MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>");
diff --git a/drivers/hid/hid-a4tech.c b/drivers/hid/hid-a4tech.c
index df474c699fb..3a2b223c1da 100644
--- a/drivers/hid/hid-a4tech.c
+++ b/drivers/hid/hid-a4tech.c
@@ -20,6 +20,7 @@
20#include <linux/input.h> 20#include <linux/input.h>
21#include <linux/hid.h> 21#include <linux/hid.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/slab.h>
23 24
24#include "hid-ids.h" 25#include "hid-ids.h"
25 26
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
index 78286b184ac..bba05d0a898 100644
--- a/drivers/hid/hid-apple.c
+++ b/drivers/hid/hid-apple.c
@@ -19,6 +19,7 @@
19#include <linux/device.h> 19#include <linux/device.h>
20#include <linux/hid.h> 20#include <linux/hid.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/slab.h>
22#include <linux/usb.h> 23#include <linux/usb.h>
23 24
24#include "hid-ids.h" 25#include "hid-ids.h"
diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 0c4e7557318..56f314fbd4f 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -29,6 +29,7 @@
29#include <linux/debugfs.h> 29#include <linux/debugfs.h>
30#include <linux/seq_file.h> 30#include <linux/seq_file.h>
31#include <linux/sched.h> 31#include <linux/sched.h>
32#include <linux/slab.h>
32#include <linux/uaccess.h> 33#include <linux/uaccess.h>
33#include <linux/poll.h> 34#include <linux/poll.h>
34 35
diff --git a/drivers/hid/hid-drff.c b/drivers/hid/hid-drff.c
index a239d20ad7a..968b04f9b79 100644
--- a/drivers/hid/hid-drff.c
+++ b/drivers/hid/hid-drff.c
@@ -28,6 +28,7 @@
28 */ 28 */
29 29
30#include <linux/input.h> 30#include <linux/input.h>
31#include <linux/slab.h>
31#include <linux/usb.h> 32#include <linux/usb.h>
32#include <linux/hid.h> 33#include <linux/hid.h>
33 34
diff --git a/drivers/hid/hid-gaff.c b/drivers/hid/hid-gaff.c
index 8a11ccddaf2..88dfcf49a5d 100644
--- a/drivers/hid/hid-gaff.c
+++ b/drivers/hid/hid-gaff.c
@@ -28,6 +28,7 @@
28 */ 28 */
29 29
30#include <linux/input.h> 30#include <linux/input.h>
31#include <linux/slab.h>
31#include <linux/usb.h> 32#include <linux/usb.h>
32#include <linux/hid.h> 33#include <linux/hid.h>
33#include "hid-ids.h" 34#include "hid-ids.h"
diff --git a/drivers/hid/hid-gyration.c b/drivers/hid/hid-gyration.c
index cab13e8c7d2..62416e6baec 100644
--- a/drivers/hid/hid-gyration.c
+++ b/drivers/hid/hid-gyration.c
@@ -53,10 +53,13 @@ static int gyration_input_mapping(struct hid_device *hdev, struct hid_input *hi,
53static int gyration_event(struct hid_device *hdev, struct hid_field *field, 53static int gyration_event(struct hid_device *hdev, struct hid_field *field,
54 struct hid_usage *usage, __s32 value) 54 struct hid_usage *usage, __s32 value)
55{ 55{
56 struct input_dev *input = field->hidinput->input; 56
57 if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput)
58 return 0;
57 59
58 if ((usage->hid & HID_USAGE_PAGE) == HID_UP_GENDESK && 60 if ((usage->hid & HID_USAGE_PAGE) == HID_UP_GENDESK &&
59 (usage->hid & 0xff) == 0x82) { 61 (usage->hid & 0xff) == 0x82) {
62 struct input_dev *input = field->hidinput->input;
60 input_event(input, usage->type, usage->code, 1); 63 input_event(input, usage->type, usage->code, 1);
61 input_sync(input); 64 input_sync(input);
62 input_event(input, usage->type, usage->code, 0); 65 input_event(input, usage->type, usage->code, 0);
diff --git a/drivers/hid/hid-lg2ff.c b/drivers/hid/hid-lg2ff.c
index 4e6dc6e2652..d888f1e6794 100644
--- a/drivers/hid/hid-lg2ff.c
+++ b/drivers/hid/hid-lg2ff.c
@@ -22,6 +22,7 @@
22 22
23 23
24#include <linux/input.h> 24#include <linux/input.h>
25#include <linux/slab.h>
25#include <linux/usb.h> 26#include <linux/usb.h>
26#include <linux/hid.h> 27#include <linux/hid.h>
27 28
diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index c174b64c381..0d471fc2ab8 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -14,6 +14,7 @@
14#include <linux/device.h> 14#include <linux/device.h>
15#include <linux/hid.h> 15#include <linux/hid.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/slab.h>
17#include <linux/usb.h> 18#include <linux/usb.h>
18 19
19#include "hid-ids.h" 20#include "hid-ids.h"
diff --git a/drivers/hid/hid-mosart.c b/drivers/hid/hid-mosart.c
index c8718168fe4..e91437c1890 100644
--- a/drivers/hid/hid-mosart.c
+++ b/drivers/hid/hid-mosart.c
@@ -16,6 +16,7 @@
16#include <linux/device.h> 16#include <linux/device.h>
17#include <linux/hid.h> 17#include <linux/hid.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/slab.h>
19#include <linux/usb.h> 20#include <linux/usb.h>
20#include "usbhid/usbhid.h" 21#include "usbhid/usbhid.h"
21 22
diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
index edcc0c4247b..9b24fc51071 100644
--- a/drivers/hid/hid-ntrig.c
+++ b/drivers/hid/hid-ntrig.c
@@ -16,6 +16,7 @@
16#include <linux/device.h> 16#include <linux/device.h>
17#include <linux/hid.h> 17#include <linux/hid.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/slab.h>
19 20
20#include "hid-ids.h" 21#include "hid-ids.h"
21 22
diff --git a/drivers/hid/hid-pl.c b/drivers/hid/hid-pl.c
index c6d7dbc935b..9f41e2bd848 100644
--- a/drivers/hid/hid-pl.c
+++ b/drivers/hid/hid-pl.c
@@ -39,6 +39,7 @@
39#define debug(format, arg...) pr_debug("hid-plff: " format "\n" , ## arg) 39#define debug(format, arg...) pr_debug("hid-plff: " format "\n" , ## arg)
40 40
41#include <linux/input.h> 41#include <linux/input.h>
42#include <linux/slab.h>
42#include <linux/usb.h> 43#include <linux/usb.h>
43#include <linux/hid.h> 44#include <linux/hid.h>
44 45
diff --git a/drivers/hid/hid-quanta.c b/drivers/hid/hid-quanta.c
index 01dd51c4986..54d3db50605 100644
--- a/drivers/hid/hid-quanta.c
+++ b/drivers/hid/hid-quanta.c
@@ -15,6 +15,7 @@
15#include <linux/device.h> 15#include <linux/device.h>
16#include <linux/hid.h> 16#include <linux/hid.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/slab.h>
18 19
19MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>"); 20MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>");
20MODULE_DESCRIPTION("Quanta dual-touch panel"); 21MODULE_DESCRIPTION("Quanta dual-touch panel");
diff --git a/drivers/hid/hid-sjoy.c b/drivers/hid/hid-sjoy.c
index 203c438b016..e10a7687ebf 100644
--- a/drivers/hid/hid-sjoy.c
+++ b/drivers/hid/hid-sjoy.c
@@ -27,6 +27,7 @@
27/* #define DEBUG */ 27/* #define DEBUG */
28 28
29#include <linux/input.h> 29#include <linux/input.h>
30#include <linux/slab.h>
30#include <linux/usb.h> 31#include <linux/usb.h>
31#include <linux/hid.h> 32#include <linux/hid.h>
32#include "hid-ids.h" 33#include "hid-ids.h"
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 9bf00d77d92..7502a4b2fa8 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -19,6 +19,7 @@
19#include <linux/device.h> 19#include <linux/device.h>
20#include <linux/hid.h> 20#include <linux/hid.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/slab.h>
22#include <linux/usb.h> 23#include <linux/usb.h>
23 24
24#include "hid-ids.h" 25#include "hid-ids.h"
diff --git a/drivers/hid/hid-stantum.c b/drivers/hid/hid-stantum.c
index 2e592a06654..90df886c5e0 100644
--- a/drivers/hid/hid-stantum.c
+++ b/drivers/hid/hid-stantum.c
@@ -15,6 +15,7 @@
15#include <linux/device.h> 15#include <linux/device.h>
16#include <linux/hid.h> 16#include <linux/hid.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/slab.h>
18 19
19MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>"); 20MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>");
20MODULE_DESCRIPTION("Stantum HID multitouch panels"); 21MODULE_DESCRIPTION("Stantum HID multitouch panels");
diff --git a/drivers/hid/hid-tmff.c b/drivers/hid/hid-tmff.c
index c32f32c84ac..15434c81479 100644
--- a/drivers/hid/hid-tmff.c
+++ b/drivers/hid/hid-tmff.c
@@ -29,6 +29,7 @@
29 29
30#include <linux/hid.h> 30#include <linux/hid.h>
31#include <linux/input.h> 31#include <linux/input.h>
32#include <linux/slab.h>
32#include <linux/usb.h> 33#include <linux/usb.h>
33 34
34#include "hid-ids.h" 35#include "hid-ids.h"
diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c
index 8d3b46f5d14..f7700cf4972 100644
--- a/drivers/hid/hid-wacom.c
+++ b/drivers/hid/hid-wacom.c
@@ -21,6 +21,7 @@
21#include <linux/device.h> 21#include <linux/device.h>
22#include <linux/hid.h> 22#include <linux/hid.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/slab.h>
24 25
25#include "hid-ids.h" 26#include "hid-ids.h"
26 27
diff --git a/drivers/hid/hid-zpff.c b/drivers/hid/hid-zpff.c
index a79f0d78c6b..b7acceabba8 100644
--- a/drivers/hid/hid-zpff.c
+++ b/drivers/hid/hid-zpff.c
@@ -23,6 +23,7 @@
23 23
24#include <linux/hid.h> 24#include <linux/hid.h>
25#include <linux/input.h> 25#include <linux/input.h>
26#include <linux/slab.h>
26#include <linux/usb.h> 27#include <linux/usb.h>
27 28
28#include "hid-ids.h" 29#include "hid-ids.h"
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index d04476700b7..6eadf1a9b3c 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -28,6 +28,7 @@
28#include <linux/poll.h> 28#include <linux/poll.h>
29#include <linux/device.h> 29#include <linux/device.h>
30#include <linux/major.h> 30#include <linux/major.h>
31#include <linux/slab.h>
31#include <linux/hid.h> 32#include <linux/hid.h>
32#include <linux/mutex.h> 33#include <linux/mutex.h>
33#include <linux/sched.h> 34#include <linux/sched.h>
diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c
index e565dbe91d9..ef381d79cfa 100644
--- a/drivers/hid/usbhid/hid-pidff.c
+++ b/drivers/hid/usbhid/hid-pidff.c
@@ -25,6 +25,7 @@
25#define debug(format, arg...) pr_debug("hid-pidff: " format "\n" , ## arg) 25#define debug(format, arg...) pr_debug("hid-pidff: " format "\n" , ## arg)
26 26
27#include <linux/input.h> 27#include <linux/input.h>
28#include <linux/slab.h>
28#include <linux/usb.h> 29#include <linux/usb.h>
29 30
30#include <linux/hid.h> 31#include <linux/hid.h>
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index 928943c7ce9..1152f9b5fd4 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -16,6 +16,7 @@
16 */ 16 */
17 17
18#include <linux/hid.h> 18#include <linux/hid.h>
19#include <linux/slab.h>
19 20
20#include "../hid-ids.h" 21#include "../hid-ids.h"
21 22
@@ -60,6 +61,7 @@ static const struct hid_blacklist {
60 { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET }, 61 { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET },
61 { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET }, 62 { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET },
62 { USB_VENDOR_ID_PRODIGE, USB_DEVICE_ID_PRODIGE_CORDLESS, HID_QUIRK_NOGET }, 63 { USB_VENDOR_ID_PRODIGE, USB_DEVICE_ID_PRODIGE_CORDLESS, HID_QUIRK_NOGET },
64 { USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN, HID_QUIRK_NOGET },
63 { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET }, 65 { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET },
64 { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET }, 66 { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET },
65 { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209, HID_QUIRK_MULTI_INPUT }, 67 { USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209, HID_QUIRK_MULTI_INPUT },
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index e4595e6147b..9be8e1754a0 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -217,8 +217,8 @@ config SENSORS_ASC7621
217 depends on HWMON && I2C 217 depends on HWMON && I2C
218 help 218 help
219 If you say yes here you get support for the aSC7621 219 If you say yes here you get support for the aSC7621
220 family of SMBus sensors chip found on most Intel X48, X38, 975, 220 family of SMBus sensors chip found on most Intel X38, X48, X58,
221 965 and 945 desktop boards. Currently supported chips: 221 945, 965 and 975 desktop boards. Currently supported chips:
222 aSC7621 222 aSC7621
223 aSC7621a 223 aSC7621a
224 224
diff --git a/drivers/hwmon/ad7414.c b/drivers/hwmon/ad7414.c
index bfda8c80ef2..1e4c21fc1a8 100644
--- a/drivers/hwmon/ad7414.c
+++ b/drivers/hwmon/ad7414.c
@@ -27,6 +27,7 @@
27#include <linux/err.h> 27#include <linux/err.h>
28#include <linux/mutex.h> 28#include <linux/mutex.h>
29#include <linux/sysfs.h> 29#include <linux/sysfs.h>
30#include <linux/slab.h>
30 31
31 32
32/* AD7414 registers */ 33/* AD7414 registers */
diff --git a/drivers/hwmon/ad7418.c b/drivers/hwmon/ad7418.c
index f97b5b35687..ffc781fec18 100644
--- a/drivers/hwmon/ad7418.c
+++ b/drivers/hwmon/ad7418.c
@@ -20,6 +20,7 @@
20#include <linux/err.h> 20#include <linux/err.h>
21#include <linux/mutex.h> 21#include <linux/mutex.h>
22#include <linux/delay.h> 22#include <linux/delay.h>
23#include <linux/slab.h>
23 24
24#include "lm75.h" 25#include "lm75.h"
25 26
diff --git a/drivers/hwmon/adcxx.c b/drivers/hwmon/adcxx.c
index 74d9c5195e4..fbdc7655303 100644
--- a/drivers/hwmon/adcxx.c
+++ b/drivers/hwmon/adcxx.c
@@ -37,6 +37,7 @@
37#include <linux/init.h> 37#include <linux/init.h>
38#include <linux/module.h> 38#include <linux/module.h>
39#include <linux/kernel.h> 39#include <linux/kernel.h>
40#include <linux/slab.h>
40#include <linux/device.h> 41#include <linux/device.h>
41#include <linux/err.h> 42#include <linux/err.h>
42#include <linux/sysfs.h> 43#include <linux/sysfs.h>
diff --git a/drivers/hwmon/adt7411.c b/drivers/hwmon/adt7411.c
index 3471884e42d..4086c7257f9 100644
--- a/drivers/hwmon/adt7411.c
+++ b/drivers/hwmon/adt7411.c
@@ -21,6 +21,7 @@
21#include <linux/i2c.h> 21#include <linux/i2c.h>
22#include <linux/hwmon.h> 22#include <linux/hwmon.h>
23#include <linux/hwmon-sysfs.h> 23#include <linux/hwmon-sysfs.h>
24#include <linux/slab.h>
24 25
25#define ADT7411_REG_INT_TEMP_VDD_LSB 0x03 26#define ADT7411_REG_INT_TEMP_VDD_LSB 0x03
26#define ADT7411_REG_EXT_TEMP_AIN14_LSB 0x04 27#define ADT7411_REG_EXT_TEMP_AIN14_LSB 0x04
diff --git a/drivers/hwmon/adt7462.c b/drivers/hwmon/adt7462.c
index b8156b4893b..2af0c7b6b4e 100644
--- a/drivers/hwmon/adt7462.c
+++ b/drivers/hwmon/adt7462.c
@@ -28,6 +28,7 @@
28#include <linux/mutex.h> 28#include <linux/mutex.h>
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/log2.h> 30#include <linux/log2.h>
31#include <linux/slab.h>
31 32
32/* Addresses to scan */ 33/* Addresses to scan */
33static const unsigned short normal_i2c[] = { 0x58, 0x5C, I2C_CLIENT_END }; 34static const unsigned short normal_i2c[] = { 0x58, 0x5C, I2C_CLIENT_END };
diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c
index 3445ce1cba8..9e775717abb 100644
--- a/drivers/hwmon/adt7470.c
+++ b/drivers/hwmon/adt7470.c
@@ -29,6 +29,7 @@
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/log2.h> 30#include <linux/log2.h>
31#include <linux/kthread.h> 31#include <linux/kthread.h>
32#include <linux/slab.h>
32 33
33/* Addresses to scan */ 34/* Addresses to scan */
34static const unsigned short normal_i2c[] = { 0x2C, 0x2E, 0x2F, I2C_CLIENT_END }; 35static const unsigned short normal_i2c[] = { 0x2C, 0x2E, 0x2F, I2C_CLIENT_END };
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index c1605b528e8..0f28d91f29d 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -142,6 +142,12 @@ static const char *temperature_sensors_sets[][41] = {
142 "TM1S", "TM2P", "TM2S", "TM3S", "TM8P", "TM8S", "TM9P", "TM9S", 142 "TM1S", "TM2P", "TM2S", "TM3S", "TM8P", "TM8S", "TM9P", "TM9S",
143 "TN0C", "TN0D", "TN0H", "TS0C", "Tp0C", "Tp1C", "Tv0S", "Tv1S", 143 "TN0C", "TN0D", "TN0H", "TS0C", "Tp0C", "Tp1C", "Tv0S", "Tv1S",
144 NULL }, 144 NULL },
145/* Set 17: iMac 9,1 */
146 { "TA0P", "TC0D", "TC0H", "TC0P", "TG0D", "TG0H", "TH0P", "TL0P",
147 "TN0D", "TN0H", "TN0P", "TO0P", "Tm0P", "Tp0P", NULL },
148/* Set 18: MacBook Pro 2,2 */
149 { "TB0T", "TC0D", "TC0P", "TG0H", "TG0P", "TG0T", "TM0P", "TTF0",
150 "Th0H", "Th1H", "Tm0P", "Ts0P", NULL },
145}; 151};
146 152
147/* List of keys used to read/write fan speeds */ 153/* List of keys used to read/write fan speeds */
@@ -1350,6 +1356,10 @@ static __initdata struct dmi_match_data applesmc_dmi_data[] = {
1350 { .accelerometer = 1, .light = 1, .temperature_set = 15 }, 1356 { .accelerometer = 1, .light = 1, .temperature_set = 15 },
1351/* MacPro3,1: temperature set 16 */ 1357/* MacPro3,1: temperature set 16 */
1352 { .accelerometer = 0, .light = 0, .temperature_set = 16 }, 1358 { .accelerometer = 0, .light = 0, .temperature_set = 16 },
1359/* iMac 9,1: light sensor only, temperature set 17 */
1360 { .accelerometer = 0, .light = 0, .temperature_set = 17 },
1361/* MacBook Pro 2,2: accelerometer, backlight and temperature set 18 */
1362 { .accelerometer = 1, .light = 1, .temperature_set = 18 },
1353}; 1363};
1354 1364
1355/* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1". 1365/* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1".
@@ -1375,6 +1385,10 @@ static __initdata struct dmi_system_id applesmc_whitelist[] = {
1375 DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), 1385 DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
1376 DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro3") }, 1386 DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro3") },
1377 &applesmc_dmi_data[9]}, 1387 &applesmc_dmi_data[9]},
1388 { applesmc_dmi_match, "Apple MacBook Pro 2,2", {
1389 DMI_MATCH(DMI_BOARD_VENDOR, "Apple Computer, Inc."),
1390 DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro2,2") },
1391 &applesmc_dmi_data[18]},
1378 { applesmc_dmi_match, "Apple MacBook Pro", { 1392 { applesmc_dmi_match, "Apple MacBook Pro", {
1379 DMI_MATCH(DMI_BOARD_VENDOR,"Apple"), 1393 DMI_MATCH(DMI_BOARD_VENDOR,"Apple"),
1380 DMI_MATCH(DMI_PRODUCT_NAME,"MacBookPro") }, 1394 DMI_MATCH(DMI_PRODUCT_NAME,"MacBookPro") },
@@ -1415,6 +1429,10 @@ static __initdata struct dmi_system_id applesmc_whitelist[] = {
1415 DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), 1429 DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
1416 DMI_MATCH(DMI_PRODUCT_NAME, "MacPro") }, 1430 DMI_MATCH(DMI_PRODUCT_NAME, "MacPro") },
1417 &applesmc_dmi_data[4]}, 1431 &applesmc_dmi_data[4]},
1432 { applesmc_dmi_match, "Apple iMac 9,1", {
1433 DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
1434 DMI_MATCH(DMI_PRODUCT_NAME, "iMac9,1") },
1435 &applesmc_dmi_data[17]},
1418 { applesmc_dmi_match, "Apple iMac 8", { 1436 { applesmc_dmi_match, "Apple iMac 8", {
1419 DMI_MATCH(DMI_BOARD_VENDOR, "Apple"), 1437 DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
1420 DMI_MATCH(DMI_PRODUCT_NAME, "iMac8") }, 1438 DMI_MATCH(DMI_PRODUCT_NAME, "iMac8") },
diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
index 028284f544e..16c42024072 100644
--- a/drivers/hwmon/asus_atk0110.c
+++ b/drivers/hwmon/asus_atk0110.c
@@ -10,6 +10,7 @@
10#include <linux/hwmon.h> 10#include <linux/hwmon.h>
11#include <linux/list.h> 11#include <linux/list.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/slab.h>
13 14
14#include <acpi/acpi.h> 15#include <acpi/acpi.h>
15#include <acpi/acpixf.h> 16#include <acpi/acpixf.h>
@@ -1168,15 +1169,19 @@ static int atk_create_files(struct atk_data *data)
1168 int err; 1169 int err;
1169 1170
1170 list_for_each_entry(s, &data->sensor_list, list) { 1171 list_for_each_entry(s, &data->sensor_list, list) {
1172 sysfs_attr_init(&s->input_attr.attr);
1171 err = device_create_file(data->hwmon_dev, &s->input_attr); 1173 err = device_create_file(data->hwmon_dev, &s->input_attr);
1172 if (err) 1174 if (err)
1173 return err; 1175 return err;
1176 sysfs_attr_init(&s->label_attr.attr);
1174 err = device_create_file(data->hwmon_dev, &s->label_attr); 1177 err = device_create_file(data->hwmon_dev, &s->label_attr);
1175 if (err) 1178 if (err)
1176 return err; 1179 return err;
1180 sysfs_attr_init(&s->limit1_attr.attr);
1177 err = device_create_file(data->hwmon_dev, &s->limit1_attr); 1181 err = device_create_file(data->hwmon_dev, &s->limit1_attr);
1178 if (err) 1182 if (err)
1179 return err; 1183 return err;
1184 sysfs_attr_init(&s->limit2_attr.attr);
1180 err = device_create_file(data->hwmon_dev, &s->limit2_attr); 1185 err = device_create_file(data->hwmon_dev, &s->limit2_attr);
1181 if (err) 1186 if (err)
1182 return err; 1187 return err;
diff --git a/drivers/hwmon/atxp1.c b/drivers/hwmon/atxp1.c
index 94cadc19f0c..33cc143b206 100644
--- a/drivers/hwmon/atxp1.c
+++ b/drivers/hwmon/atxp1.c
@@ -28,6 +28,7 @@
28#include <linux/err.h> 28#include <linux/err.h>
29#include <linux/mutex.h> 29#include <linux/mutex.h>
30#include <linux/sysfs.h> 30#include <linux/sysfs.h>
31#include <linux/slab.h>
31 32
32MODULE_LICENSE("GPL"); 33MODULE_LICENSE("GPL");
33MODULE_DESCRIPTION("System voltages control via Attansic ATXP1"); 34MODULE_DESCRIPTION("System voltages control via Attansic ATXP1");
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index 2d7bceeed0b..e9b7fbc5a44 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -228,7 +228,7 @@ static int __devinit adjust_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *
228 if (err) { 228 if (err) {
229 dev_warn(dev, 229 dev_warn(dev,
230 "Unable to access MSR 0xEE, for Tjmax, left" 230 "Unable to access MSR 0xEE, for Tjmax, left"
231 " at default"); 231 " at default\n");
232 } else if (eax & 0x40000000) { 232 } else if (eax & 0x40000000) {
233 tjmax = tjmax_ee; 233 tjmax = tjmax_ee;
234 } 234 }
@@ -466,7 +466,7 @@ static int __init coretemp_init(void)
466 family 6 CPU */ 466 family 6 CPU */
467 if ((c->x86 == 0x6) && (c->x86_model > 0xf)) 467 if ((c->x86 == 0x6) && (c->x86_model > 0xf))
468 printk(KERN_WARNING DRVNAME ": Unknown CPU " 468 printk(KERN_WARNING DRVNAME ": Unknown CPU "
469 "model %x\n", c->x86_model); 469 "model 0x%x\n", c->x86_model);
470 continue; 470 continue;
471 } 471 }
472 472
diff --git a/drivers/hwmon/f75375s.c b/drivers/hwmon/f75375s.c
index 277398f9c93..bad2cf3ef4a 100644
--- a/drivers/hwmon/f75375s.c
+++ b/drivers/hwmon/f75375s.c
@@ -35,6 +35,7 @@
35#include <linux/err.h> 35#include <linux/err.h>
36#include <linux/mutex.h> 36#include <linux/mutex.h>
37#include <linux/f75375s.h> 37#include <linux/f75375s.h>
38#include <linux/slab.h>
38 39
39/* Addresses to scan */ 40/* Addresses to scan */
40static const unsigned short normal_i2c[] = { 0x2d, 0x2e, I2C_CLIENT_END }; 41static const unsigned short normal_i2c[] = { 0x2d, 0x2e, I2C_CLIENT_END };
diff --git a/drivers/hwmon/hp_accel.c b/drivers/hwmon/hp_accel.c
index be475e844c2..c8ab5051667 100644
--- a/drivers/hwmon/hp_accel.c
+++ b/drivers/hwmon/hp_accel.c
@@ -217,6 +217,10 @@ static struct dmi_system_id lis3lv02d_dmi_ids[] = {
217 AXIS_DMI_MATCH("DV7", "HP Pavilion dv7", x_inverted), 217 AXIS_DMI_MATCH("DV7", "HP Pavilion dv7", x_inverted),
218 AXIS_DMI_MATCH("HP8710", "HP Compaq 8710", y_inverted), 218 AXIS_DMI_MATCH("HP8710", "HP Compaq 8710", y_inverted),
219 AXIS_DMI_MATCH("HDX18", "HP HDX 18", x_inverted), 219 AXIS_DMI_MATCH("HDX18", "HP HDX 18", x_inverted),
220 AXIS_DMI_MATCH("HPB432x", "HP ProBook 432", xy_rotated_left),
221 AXIS_DMI_MATCH("HPB442x", "HP ProBook 442", xy_rotated_left),
222 AXIS_DMI_MATCH("HPB452x", "HP ProBook 452", y_inverted),
223 AXIS_DMI_MATCH("HPB522x", "HP ProBook 522", xy_swap),
220 { NULL, } 224 { NULL, }
221/* Laptop models without axis info (yet): 225/* Laptop models without axis info (yet):
222 * "NC6910" "HP Compaq 6910" 226 * "NC6910" "HP Compaq 6910"
diff --git a/drivers/hwmon/i5k_amb.c b/drivers/hwmon/i5k_amb.c
index 27d7f72a5f1..e880e2c3871 100644
--- a/drivers/hwmon/i5k_amb.c
+++ b/drivers/hwmon/i5k_amb.c
@@ -30,6 +30,7 @@
30#include <linux/log2.h> 30#include <linux/log2.h>
31#include <linux/pci.h> 31#include <linux/pci.h>
32#include <linux/platform_device.h> 32#include <linux/platform_device.h>
33#include <linux/slab.h>
33 34
34#define DRVNAME "i5k_amb" 35#define DRVNAME "i5k_amb"
35 36
diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
index 405d3fb5d76..eaee546af19 100644
--- a/drivers/hwmon/ibmaem.c
+++ b/drivers/hwmon/ibmaem.c
@@ -29,6 +29,7 @@
29#include <linux/kdev_t.h> 29#include <linux/kdev_t.h>
30#include <linux/spinlock.h> 30#include <linux/spinlock.h>
31#include <linux/idr.h> 31#include <linux/idr.h>
32#include <linux/slab.h>
32#include <linux/sched.h> 33#include <linux/sched.h>
33#include <linux/platform_device.h> 34#include <linux/platform_device.h>
34#include <linux/math64.h> 35#include <linux/math64.h>
diff --git a/drivers/hwmon/ibmpex.c b/drivers/hwmon/ibmpex.c
index a36363312f2..06d4eafcf76 100644
--- a/drivers/hwmon/ibmpex.c
+++ b/drivers/hwmon/ibmpex.c
@@ -25,6 +25,7 @@
25#include <linux/hwmon-sysfs.h> 25#include <linux/hwmon-sysfs.h>
26#include <linux/jiffies.h> 26#include <linux/jiffies.h>
27#include <linux/mutex.h> 27#include <linux/mutex.h>
28#include <linux/slab.h>
28 29
29#define REFRESH_INTERVAL (2 * HZ) 30#define REFRESH_INTERVAL (2 * HZ)
30#define DRVNAME "ibmpex" 31#define DRVNAME "ibmpex"
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index 1002befd87d..5be09c048c5 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -539,14 +539,14 @@ static ssize_t set_sensor(struct device *dev, struct device_attribute *attr,
539 539
540 struct it87_data *data = dev_get_drvdata(dev); 540 struct it87_data *data = dev_get_drvdata(dev);
541 long val; 541 long val;
542 u8 reg;
542 543
543 if (strict_strtol(buf, 10, &val) < 0) 544 if (strict_strtol(buf, 10, &val) < 0)
544 return -EINVAL; 545 return -EINVAL;
545 546
546 mutex_lock(&data->update_lock); 547 reg = it87_read_value(data, IT87_REG_TEMP_ENABLE);
547 548 reg &= ~(1 << nr);
548 data->sensor &= ~(1 << nr); 549 reg &= ~(8 << nr);
549 data->sensor &= ~(8 << nr);
550 if (val == 2) { /* backwards compatibility */ 550 if (val == 2) { /* backwards compatibility */
551 dev_warn(dev, "Sensor type 2 is deprecated, please use 4 " 551 dev_warn(dev, "Sensor type 2 is deprecated, please use 4 "
552 "instead\n"); 552 "instead\n");
@@ -554,14 +554,16 @@ static ssize_t set_sensor(struct device *dev, struct device_attribute *attr,
554 } 554 }
555 /* 3 = thermal diode; 4 = thermistor; 0 = disabled */ 555 /* 3 = thermal diode; 4 = thermistor; 0 = disabled */
556 if (val == 3) 556 if (val == 3)
557 data->sensor |= 1 << nr; 557 reg |= 1 << nr;
558 else if (val == 4) 558 else if (val == 4)
559 data->sensor |= 8 << nr; 559 reg |= 8 << nr;
560 else if (val != 0) { 560 else if (val != 0)
561 mutex_unlock(&data->update_lock);
562 return -EINVAL; 561 return -EINVAL;
563 } 562
563 mutex_lock(&data->update_lock);
564 data->sensor = reg;
564 it87_write_value(data, IT87_REG_TEMP_ENABLE, data->sensor); 565 it87_write_value(data, IT87_REG_TEMP_ENABLE, data->sensor);
566 data->valid = 0; /* Force cache refresh */
565 mutex_unlock(&data->update_lock); 567 mutex_unlock(&data->update_lock);
566 return count; 568 return count;
567} 569}
@@ -1841,14 +1843,10 @@ static void __devinit it87_init_device(struct platform_device *pdev)
1841 it87_write_value(data, IT87_REG_TEMP_HIGH(i), 127); 1843 it87_write_value(data, IT87_REG_TEMP_HIGH(i), 127);
1842 } 1844 }
1843 1845
1844 /* Check if temperature channels are reset manually or by some reason */ 1846 /* Temperature channels are not forcibly enabled, as they can be
1845 tmp = it87_read_value(data, IT87_REG_TEMP_ENABLE); 1847 * set to two different sensor types and we can't guess which one
1846 if ((tmp & 0x3f) == 0) { 1848 * is correct for a given system. These channels can be enabled at
1847 /* Temp1,Temp3=thermistor; Temp2=thermal diode */ 1849 * run-time through the temp{1-3}_type sysfs accessors if needed. */
1848 tmp = (tmp & 0xc0) | 0x2a;
1849 it87_write_value(data, IT87_REG_TEMP_ENABLE, tmp);
1850 }
1851 data->sensor = tmp;
1852 1850
1853 /* Check if voltage monitors are reset manually or by some reason */ 1851 /* Check if voltage monitors are reset manually or by some reason */
1854 tmp = it87_read_value(data, IT87_REG_VIN_ENABLE); 1852 tmp = it87_read_value(data, IT87_REG_VIN_ENABLE);
diff --git a/drivers/hwmon/lm70.c b/drivers/hwmon/lm70.c
index ab8a5d3c769..fd108cfc05c 100644
--- a/drivers/hwmon/lm70.c
+++ b/drivers/hwmon/lm70.c
@@ -34,6 +34,7 @@
34#include <linux/mutex.h> 34#include <linux/mutex.h>
35#include <linux/mod_devicetable.h> 35#include <linux/mod_devicetable.h>
36#include <linux/spi/spi.h> 36#include <linux/spi/spi.h>
37#include <linux/slab.h>
37 38
38 39
39#define DRVNAME "lm70" 40#define DRVNAME "lm70"
diff --git a/drivers/hwmon/lm73.c b/drivers/hwmon/lm73.c
index c5f39ba103c..4d1b76bc814 100644
--- a/drivers/hwmon/lm73.c
+++ b/drivers/hwmon/lm73.c
@@ -16,7 +16,6 @@
16 16
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/slab.h>
20#include <linux/i2c.h> 19#include <linux/i2c.h>
21#include <linux/hwmon.h> 20#include <linux/hwmon.h>
22#include <linux/hwmon-sysfs.h> 21#include <linux/hwmon-sysfs.h>
diff --git a/drivers/hwmon/max1111.c b/drivers/hwmon/max1111.c
index 9ac497271ad..12a54aa2977 100644
--- a/drivers/hwmon/max1111.c
+++ b/drivers/hwmon/max1111.c
@@ -20,6 +20,7 @@
20#include <linux/hwmon.h> 20#include <linux/hwmon.h>
21#include <linux/hwmon-sysfs.h> 21#include <linux/hwmon-sysfs.h>
22#include <linux/spi/spi.h> 22#include <linux/spi/spi.h>
23#include <linux/slab.h>
23 24
24#define MAX1111_TX_BUF_SIZE 1 25#define MAX1111_TX_BUF_SIZE 1
25#define MAX1111_RX_BUF_SIZE 2 26#define MAX1111_RX_BUF_SIZE 2
diff --git a/drivers/hwmon/mc13783-adc.c b/drivers/hwmon/mc13783-adc.c
index 883fa8197da..ce3c7bc8181 100644
--- a/drivers/hwmon/mc13783-adc.c
+++ b/drivers/hwmon/mc13783-adc.c
@@ -24,6 +24,7 @@
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/hwmon.h> 26#include <linux/hwmon.h>
27#include <linux/slab.h>
27#include <linux/init.h> 28#include <linux/init.h>
28#include <linux/err.h> 29#include <linux/err.h>
29 30
diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
index 864a371f6eb..a610e7880fb 100644
--- a/drivers/hwmon/sht15.c
+++ b/drivers/hwmon/sht15.c
@@ -36,6 +36,7 @@
36#include <linux/err.h> 36#include <linux/err.h>
37#include <linux/sht15.h> 37#include <linux/sht15.h>
38#include <linux/regulator/consumer.h> 38#include <linux/regulator/consumer.h>
39#include <linux/slab.h>
39#include <asm/atomic.h> 40#include <asm/atomic.h>
40 41
41#define SHT15_MEASURE_TEMP 3 42#define SHT15_MEASURE_TEMP 3
@@ -302,13 +303,13 @@ error_ret:
302 **/ 303 **/
303static inline int sht15_calc_temp(struct sht15_data *data) 304static inline int sht15_calc_temp(struct sht15_data *data)
304{ 305{
305 int d1 = 0; 306 int d1 = temppoints[0].d1;
306 int i; 307 int i;
307 308
308 for (i = 1; i < ARRAY_SIZE(temppoints); i++) 309 for (i = ARRAY_SIZE(temppoints) - 1; i > 0; i--)
309 /* Find pointer to interpolate */ 310 /* Find pointer to interpolate */
310 if (data->supply_uV > temppoints[i - 1].vdd) { 311 if (data->supply_uV > temppoints[i - 1].vdd) {
311 d1 = (data->supply_uV/1000 - temppoints[i - 1].vdd) 312 d1 = (data->supply_uV - temppoints[i - 1].vdd)
312 * (temppoints[i].d1 - temppoints[i - 1].d1) 313 * (temppoints[i].d1 - temppoints[i - 1].d1)
313 / (temppoints[i].vdd - temppoints[i - 1].vdd) 314 / (temppoints[i].vdd - temppoints[i - 1].vdd)
314 + temppoints[i - 1].d1; 315 + temppoints[i - 1].d1;
@@ -541,7 +542,12 @@ static int __devinit sht15_probe(struct platform_device *pdev)
541/* If a regulator is available, query what the supply voltage actually is!*/ 542/* If a regulator is available, query what the supply voltage actually is!*/
542 data->reg = regulator_get(data->dev, "vcc"); 543 data->reg = regulator_get(data->dev, "vcc");
543 if (!IS_ERR(data->reg)) { 544 if (!IS_ERR(data->reg)) {
544 data->supply_uV = regulator_get_voltage(data->reg); 545 int voltage;
546
547 voltage = regulator_get_voltage(data->reg);
548 if (voltage)
549 data->supply_uV = voltage;
550
545 regulator_enable(data->reg); 551 regulator_enable(data->reg);
546 /* setup a notifier block to update this if another device 552 /* setup a notifier block to update this if another device
547 * causes the voltage to change */ 553 * causes the voltage to change */
diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c
index 9de81a4c15a..612807d9715 100644
--- a/drivers/hwmon/w83793.c
+++ b/drivers/hwmon/w83793.c
@@ -1294,7 +1294,7 @@ static int watchdog_close(struct inode *inode, struct file *filp)
1294static ssize_t watchdog_write(struct file *filp, const char __user *buf, 1294static ssize_t watchdog_write(struct file *filp, const char __user *buf,
1295 size_t count, loff_t *offset) 1295 size_t count, loff_t *offset)
1296{ 1296{
1297 size_t ret; 1297 ssize_t ret;
1298 struct w83793_data *data = filp->private_data; 1298 struct w83793_data *data = filp->private_data;
1299 1299
1300 if (count) { 1300 if (count) {
diff --git a/drivers/hwmon/wm831x-hwmon.c b/drivers/hwmon/wm831x-hwmon.c
index c16e9e74c35..97b1f834a47 100644
--- a/drivers/hwmon/wm831x-hwmon.c
+++ b/drivers/hwmon/wm831x-hwmon.c
@@ -24,6 +24,7 @@
24#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/hwmon.h> 25#include <linux/hwmon.h>
26#include <linux/hwmon-sysfs.h> 26#include <linux/hwmon-sysfs.h>
27#include <linux/slab.h>
27 28
28#include <linux/mfd/wm831x/core.h> 29#include <linux/mfd/wm831x/core.h>
29#include <linux/mfd/wm831x/auxadc.h> 30#include <linux/mfd/wm831x/auxadc.h>
diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c
index e8d568c3fb0..a39e6cff86e 100644
--- a/drivers/i2c/algos/i2c-algo-bit.c
+++ b/drivers/i2c/algos/i2c-algo-bit.c
@@ -24,7 +24,6 @@
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/slab.h>
28#include <linux/init.h> 27#include <linux/init.h>
29#include <linux/errno.h> 28#include <linux/errno.h>
30#include <linux/sched.h> 29#include <linux/sched.h>
diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index 6b6bd06202b..5eebf562ff3 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -29,7 +29,6 @@
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/slab.h>
33#include <linux/init.h> 32#include <linux/init.h>
34#include <linux/errno.h> 33#include <linux/errno.h>
35#include <linux/i2c.h> 34#include <linux/i2c.h>
diff --git a/drivers/i2c/busses/i2c-amd8111.c b/drivers/i2c/busses/i2c-amd8111.c
index d0dc970d737..2fbef27b6cd 100644
--- a/drivers/i2c/busses/i2c-amd8111.c
+++ b/drivers/i2c/busses/i2c-amd8111.c
@@ -17,6 +17,7 @@
17#include <linux/i2c.h> 17#include <linux/i2c.h>
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/acpi.h> 19#include <linux/acpi.h>
20#include <linux/slab.h>
20#include <asm/io.h> 21#include <asm/io.h>
21 22
22MODULE_LICENSE("GPL"); 23MODULE_LICENSE("GPL");
diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
index fe3fb567317..f1e14dd590c 100644
--- a/drivers/i2c/busses/i2c-bfin-twi.c
+++ b/drivers/i2c/busses/i2c-bfin-twi.c
@@ -12,6 +12,7 @@
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/i2c.h> 14#include <linux/i2c.h>
15#include <linux/slab.h>
15#include <linux/io.h> 16#include <linux/io.h>
16#include <linux/mm.h> 17#include <linux/mm.h>
17#include <linux/timer.h> 18#include <linux/timer.h>
diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index c89687a1083..4523364e672 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -35,6 +35,7 @@
35#include <linux/interrupt.h> 35#include <linux/interrupt.h>
36#include <linux/platform_device.h> 36#include <linux/platform_device.h>
37#include <linux/io.h> 37#include <linux/io.h>
38#include <linux/slab.h>
38 39
39#include <mach/hardware.h> 40#include <mach/hardware.h>
40 41
diff --git a/drivers/i2c/busses/i2c-designware.c b/drivers/i2c/busses/i2c-designware.c
index 3e72b69aa7f..b664ed8bbdb 100644
--- a/drivers/i2c/busses/i2c-designware.c
+++ b/drivers/i2c/busses/i2c-designware.c
@@ -36,6 +36,7 @@
36#include <linux/interrupt.h> 36#include <linux/interrupt.h>
37#include <linux/platform_device.h> 37#include <linux/platform_device.h>
38#include <linux/io.h> 38#include <linux/io.h>
39#include <linux/slab.h>
39 40
40/* 41/*
41 * Registers offset 42 * Registers offset
diff --git a/drivers/i2c/busses/i2c-elektor.c b/drivers/i2c/busses/i2c-elektor.c
index 448b4bf35eb..612255614a6 100644
--- a/drivers/i2c/busses/i2c-elektor.c
+++ b/drivers/i2c/busses/i2c-elektor.c
@@ -29,7 +29,6 @@
29#include <linux/ioport.h> 29#include <linux/ioport.h>
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/slab.h>
33#include <linux/init.h> 32#include <linux/init.h>
34#include <linux/interrupt.h> 33#include <linux/interrupt.h>
35#include <linux/pci.h> 34#include <linux/pci.h>
diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
index 32104eac8d3..c21077d248a 100644
--- a/drivers/i2c/busses/i2c-gpio.c
+++ b/drivers/i2c/busses/i2c-gpio.c
@@ -12,6 +12,7 @@
12#include <linux/i2c-gpio.h> 12#include <linux/i2c-gpio.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/slab.h>
15#include <linux/platform_device.h> 16#include <linux/platform_device.h>
16 17
17#include <asm/gpio.h> 18#include <asm/gpio.h>
diff --git a/drivers/i2c/busses/i2c-highlander.c b/drivers/i2c/busses/i2c-highlander.c
index 87ecace415d..ce87a902c94 100644
--- a/drivers/i2c/busses/i2c-highlander.c
+++ b/drivers/i2c/busses/i2c-highlander.c
@@ -19,6 +19,7 @@
19#include <linux/completion.h> 19#include <linux/completion.h>
20#include <linux/io.h> 20#include <linux/io.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/slab.h>
22 23
23#define SMCR 0x00 24#define SMCR 0x00
24#define SMCR_START (1 << 0) 25#define SMCR_START (1 << 0)
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 32375bddae7..d1ff9408dc1 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -47,6 +47,7 @@
47#include <linux/sched.h> 47#include <linux/sched.h>
48#include <linux/platform_device.h> 48#include <linux/platform_device.h>
49#include <linux/clk.h> 49#include <linux/clk.h>
50#include <linux/slab.h>
50 51
51#include <mach/irqs.h> 52#include <mach/irqs.h>
52#include <mach/hardware.h> 53#include <mach/hardware.h>
@@ -145,10 +146,10 @@ static int i2c_imx_bus_busy(struct imx_i2c_struct *i2c_imx, int for_busy)
145 "<%s> I2C Interrupted\n", __func__); 146 "<%s> I2C Interrupted\n", __func__);
146 return -EINTR; 147 return -EINTR;
147 } 148 }
148 if (time_after(jiffies, orig_jiffies + HZ / 1000)) { 149 if (time_after(jiffies, orig_jiffies + msecs_to_jiffies(500))) {
149 dev_dbg(&i2c_imx->adapter.dev, 150 dev_dbg(&i2c_imx->adapter.dev,
150 "<%s> I2C bus is busy\n", __func__); 151 "<%s> I2C bus is busy\n", __func__);
151 return -EIO; 152 return -ETIMEDOUT;
152 } 153 }
153 schedule(); 154 schedule();
154 } 155 }
@@ -443,6 +444,8 @@ static int i2c_imx_xfer(struct i2c_adapter *adapter,
443 result = i2c_imx_read(i2c_imx, &msgs[i]); 444 result = i2c_imx_read(i2c_imx, &msgs[i]);
444 else 445 else
445 result = i2c_imx_write(i2c_imx, &msgs[i]); 446 result = i2c_imx_write(i2c_imx, &msgs[i]);
447 if (result)
448 goto fail0;
446 } 449 }
447 450
448fail0: 451fail0:
diff --git a/drivers/i2c/busses/i2c-ixp2000.c b/drivers/i2c/busses/i2c-ixp2000.c
index c016f7a2c5f..5d8aed5ec21 100644
--- a/drivers/i2c/busses/i2c-ixp2000.c
+++ b/drivers/i2c/busses/i2c-ixp2000.c
@@ -32,6 +32,7 @@
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/i2c.h> 33#include <linux/i2c.h>
34#include <linux/i2c-algo-bit.h> 34#include <linux/i2c-algo-bit.h>
35#include <linux/slab.h>
35 36
36#include <mach/hardware.h> /* Pick up IXP2000-specific bits */ 37#include <mach/hardware.h> /* Pick up IXP2000-specific bits */
37#include <mach/gpio.h> 38#include <mach/gpio.h>
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 78a15af3294..f1321f76378 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -19,6 +19,7 @@
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/of_platform.h> 20#include <linux/of_platform.h>
21#include <linux/of_i2c.h> 21#include <linux/of_i2c.h>
22#include <linux/slab.h>
22 23
23#include <linux/io.h> 24#include <linux/io.h>
24#include <linux/fsl_devices.h> 25#include <linux/fsl_devices.h>
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
index ed387ffa473..3623a449908 100644
--- a/drivers/i2c/busses/i2c-mv64xxx.c
+++ b/drivers/i2c/busses/i2c-mv64xxx.c
@@ -10,6 +10,7 @@
10 * or implied. 10 * or implied.
11 */ 11 */
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/slab.h>
13#include <linux/module.h> 14#include <linux/module.h>
14#include <linux/spinlock.h> 15#include <linux/spinlock.h>
15#include <linux/i2c.h> 16#include <linux/i2c.h>
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c
index 4a700587ef1..4a48dd4ef78 100644
--- a/drivers/i2c/busses/i2c-nforce2.c
+++ b/drivers/i2c/busses/i2c-nforce2.c
@@ -56,6 +56,7 @@
56#include <linux/delay.h> 56#include <linux/delay.h>
57#include <linux/dmi.h> 57#include <linux/dmi.h>
58#include <linux/acpi.h> 58#include <linux/acpi.h>
59#include <linux/slab.h>
59#include <asm/io.h> 60#include <asm/io.h>
60 61
61MODULE_LICENSE("GPL"); 62MODULE_LICENSE("GPL");
diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
index a15f731fa45..a4f8d33fa38 100644
--- a/drivers/i2c/busses/i2c-nomadik.c
+++ b/drivers/i2c/busses/i2c-nomadik.c
@@ -16,6 +16,7 @@
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/slab.h>
19#include <linux/interrupt.h> 20#include <linux/interrupt.h>
20#include <linux/i2c.h> 21#include <linux/i2c.h>
21#include <linux/err.h> 22#include <linux/err.h>
diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
index 0dabe643ec5..b4ed4ca802e 100644
--- a/drivers/i2c/busses/i2c-ocores.c
+++ b/drivers/i2c/busses/i2c-ocores.c
@@ -18,6 +18,7 @@
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/wait.h> 19#include <linux/wait.h>
20#include <linux/i2c-ocores.h> 20#include <linux/i2c-ocores.h>
21#include <linux/slab.h>
21#include <asm/io.h> 22#include <asm/io.h>
22 23
23struct ocores_i2c { 24struct ocores_i2c {
diff --git a/drivers/i2c/busses/i2c-octeon.c b/drivers/i2c/busses/i2c-octeon.c
index 60375504fa4..0e9f85d0a83 100644
--- a/drivers/i2c/busses/i2c-octeon.c
+++ b/drivers/i2c/busses/i2c-octeon.c
@@ -14,6 +14,7 @@
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/sched.h> 16#include <linux/sched.h>
17#include <linux/slab.h>
17#include <linux/init.h> 18#include <linux/init.h>
18 19
19#include <linux/io.h> 20#include <linux/io.h>
@@ -446,7 +447,7 @@ static struct i2c_adapter octeon_i2c_ops = {
446/** 447/**
447 * octeon_i2c_setclock - Calculate and set clock divisors. 448 * octeon_i2c_setclock - Calculate and set clock divisors.
448 */ 449 */
449static int __init octeon_i2c_setclock(struct octeon_i2c *i2c) 450static int __devinit octeon_i2c_setclock(struct octeon_i2c *i2c)
450{ 451{
451 int tclk, thp_base, inc, thp_idx, mdiv_idx, ndiv_idx, foscl, diff; 452 int tclk, thp_base, inc, thp_idx, mdiv_idx, ndiv_idx, foscl, diff;
452 int thp = 0x18, mdiv = 2, ndiv = 0, delta_hz = 1000000; 453 int thp = 0x18, mdiv = 2, ndiv = 0, delta_hz = 1000000;
@@ -489,7 +490,7 @@ static int __init octeon_i2c_setclock(struct octeon_i2c *i2c)
489 return 0; 490 return 0;
490} 491}
491 492
492static int __init octeon_i2c_initlowlevel(struct octeon_i2c *i2c) 493static int __devinit octeon_i2c_initlowlevel(struct octeon_i2c *i2c)
493{ 494{
494 u8 status; 495 u8 status;
495 int tries; 496 int tries;
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index c7c237537f8..389ac6032a7 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -37,6 +37,7 @@
37#include <linux/platform_device.h> 37#include <linux/platform_device.h>
38#include <linux/clk.h> 38#include <linux/clk.h>
39#include <linux/io.h> 39#include <linux/io.h>
40#include <linux/slab.h>
40 41
41/* I2C controller revisions */ 42/* I2C controller revisions */
42#define OMAP_I2C_REV_2 0x20 43#define OMAP_I2C_REV_2 0x20
@@ -902,6 +903,11 @@ omap_i2c_probe(struct platform_device *pdev)
902 903
903 platform_set_drvdata(pdev, dev); 904 platform_set_drvdata(pdev, dev);
904 905
906 if (cpu_is_omap7xx())
907 dev->reg_shift = 1;
908 else
909 dev->reg_shift = 2;
910
905 if ((r = omap_i2c_get_clocks(dev)) != 0) 911 if ((r = omap_i2c_get_clocks(dev)) != 0)
906 goto err_iounmap; 912 goto err_iounmap;
907 913
@@ -925,11 +931,6 @@ omap_i2c_probe(struct platform_device *pdev)
925 dev->b_hw = 1; /* Enable hardware fixes */ 931 dev->b_hw = 1; /* Enable hardware fixes */
926 } 932 }
927 933
928 if (cpu_is_omap7xx())
929 dev->reg_shift = 1;
930 else
931 dev->reg_shift = 2;
932
933 /* reset ASAP, clearing any IRQs */ 934 /* reset ASAP, clearing any IRQs */
934 omap_i2c_init(dev); 935 omap_i2c_init(dev);
935 936
diff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c
index 220fca7f23a..846583ed476 100644
--- a/drivers/i2c/busses/i2c-parport.c
+++ b/drivers/i2c/busses/i2c-parport.c
@@ -32,6 +32,7 @@
32#include <linux/i2c.h> 32#include <linux/i2c.h>
33#include <linux/i2c-algo-bit.h> 33#include <linux/i2c-algo-bit.h>
34#include <linux/i2c-smbus.h> 34#include <linux/i2c-smbus.h>
35#include <linux/slab.h>
35#include "i2c-parport.h" 36#include "i2c-parport.h"
36 37
37/* ----- Device list ------------------------------------------------------ */ 38/* ----- Device list ------------------------------------------------------ */
diff --git a/drivers/i2c/busses/i2c-pasemi.c b/drivers/i2c/busses/i2c-pasemi.c
index 0d20ff46a51..d3d4a4b43a1 100644
--- a/drivers/i2c/busses/i2c-pasemi.c
+++ b/drivers/i2c/busses/i2c-pasemi.c
@@ -24,6 +24,7 @@
24#include <linux/sched.h> 24#include <linux/sched.h>
25#include <linux/i2c.h> 25#include <linux/i2c.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/slab.h>
27#include <asm/io.h> 28#include <asm/io.h>
28 29
29static struct pci_driver pasemi_smb_driver; 30static struct pci_driver pasemi_smb_driver;
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c
index 9532dee6b58..a97e3fec814 100644
--- a/drivers/i2c/busses/i2c-pnx.c
+++ b/drivers/i2c/busses/i2c-pnx.c
@@ -22,6 +22,7 @@
22#include <linux/io.h> 22#include <linux/io.h>
23#include <linux/err.h> 23#include <linux/err.h>
24#include <linux/clk.h> 24#include <linux/clk.h>
25#include <linux/slab.h>
25 26
26#include <mach/hardware.h> 27#include <mach/hardware.h>
27#include <mach/i2c.h> 28#include <mach/i2c.h>
@@ -172,6 +173,9 @@ static int i2c_pnx_master_xmit(struct i2c_pnx_algo_data *alg_data)
172 /* We still have something to talk about... */ 173 /* We still have something to talk about... */
173 val = *alg_data->mif.buf++; 174 val = *alg_data->mif.buf++;
174 175
176 if (alg_data->mif.len == 1)
177 val |= stop_bit;
178
175 alg_data->mif.len--; 179 alg_data->mif.len--;
176 iowrite32(val, I2C_REG_TX(alg_data)); 180 iowrite32(val, I2C_REG_TX(alg_data));
177 181
@@ -245,6 +249,9 @@ static int i2c_pnx_master_rcv(struct i2c_pnx_algo_data *alg_data)
245 __func__); 249 __func__);
246 250
247 if (alg_data->mif.len == 1) { 251 if (alg_data->mif.len == 1) {
252 /* Last byte, do not acknowledge next rcv. */
253 val |= stop_bit;
254
248 /* 255 /*
249 * Enable interrupt RFDAIE (data in Rx fifo), 256 * Enable interrupt RFDAIE (data in Rx fifo),
250 * and disable DRMIE (need data for Tx) 257 * and disable DRMIE (need data for Tx)
@@ -632,6 +639,8 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
632 */ 639 */
633 640
634 tmp = ((freq / 1000) / I2C_PNX_SPEED_KHZ) / 2 - 2; 641 tmp = ((freq / 1000) / I2C_PNX_SPEED_KHZ) / 2 - 2;
642 if (tmp > 0x3FF)
643 tmp = 0x3FF;
635 iowrite32(tmp, I2C_REG_CKH(alg_data)); 644 iowrite32(tmp, I2C_REG_CKH(alg_data));
636 iowrite32(tmp, I2C_REG_CKL(alg_data)); 645 iowrite32(tmp, I2C_REG_CKL(alg_data));
637 646
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 90ffbf6f9d4..14d249f5ed3 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -33,6 +33,7 @@
33#include <linux/platform_device.h> 33#include <linux/platform_device.h>
34#include <linux/err.h> 34#include <linux/err.h>
35#include <linux/clk.h> 35#include <linux/clk.h>
36#include <linux/slab.h>
36 37
37#include <asm/irq.h> 38#include <asm/irq.h>
38#include <asm/io.h> 39#include <asm/io.h>
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 1d8c98613fa..d27072b2249 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -34,6 +34,7 @@
34#include <linux/platform_device.h> 34#include <linux/platform_device.h>
35#include <linux/clk.h> 35#include <linux/clk.h>
36#include <linux/cpufreq.h> 36#include <linux/cpufreq.h>
37#include <linux/slab.h>
37 38
38#include <asm/irq.h> 39#include <asm/irq.h>
39#include <asm/io.h> 40#include <asm/io.h>
diff --git a/drivers/i2c/busses/i2c-scmi.c b/drivers/i2c/busses/i2c-scmi.c
index 365e0becaf1..388cbdc96db 100644
--- a/drivers/i2c/busses/i2c-scmi.c
+++ b/drivers/i2c/busses/i2c-scmi.c
@@ -33,6 +33,7 @@ struct acpi_smbus_cmi {
33 u8 cap_info:1; 33 u8 cap_info:1;
34 u8 cap_read:1; 34 u8 cap_read:1;
35 u8 cap_write:1; 35 u8 cap_write:1;
36 struct smbus_methods_t *methods;
36}; 37};
37 38
38static const struct smbus_methods_t smbus_methods = { 39static const struct smbus_methods_t smbus_methods = {
@@ -41,10 +42,19 @@ static const struct smbus_methods_t smbus_methods = {
41 .mt_sbw = "_SBW", 42 .mt_sbw = "_SBW",
42}; 43};
43 44
45/* Some IBM BIOSes omit the leading underscore */
46static const struct smbus_methods_t ibm_smbus_methods = {
47 .mt_info = "SBI_",
48 .mt_sbr = "SBR_",
49 .mt_sbw = "SBW_",
50};
51
44static const struct acpi_device_id acpi_smbus_cmi_ids[] = { 52static const struct acpi_device_id acpi_smbus_cmi_ids[] = {
45 {"SMBUS01", 0}, 53 {"SMBUS01", (kernel_ulong_t)&smbus_methods},
54 {ACPI_SMBUS_IBM_HID, (kernel_ulong_t)&ibm_smbus_methods},
46 {"", 0} 55 {"", 0}
47}; 56};
57MODULE_DEVICE_TABLE(acpi, acpi_smbus_cmi_ids);
48 58
49#define ACPI_SMBUS_STATUS_OK 0x00 59#define ACPI_SMBUS_STATUS_OK 0x00
50#define ACPI_SMBUS_STATUS_FAIL 0x07 60#define ACPI_SMBUS_STATUS_FAIL 0x07
@@ -150,11 +160,11 @@ acpi_smbus_cmi_access(struct i2c_adapter *adap, u16 addr, unsigned short flags,
150 160
151 if (read_write == I2C_SMBUS_READ) { 161 if (read_write == I2C_SMBUS_READ) {
152 protocol |= ACPI_SMBUS_PRTCL_READ; 162 protocol |= ACPI_SMBUS_PRTCL_READ;
153 method = smbus_methods.mt_sbr; 163 method = smbus_cmi->methods->mt_sbr;
154 input.count = 3; 164 input.count = 3;
155 } else { 165 } else {
156 protocol |= ACPI_SMBUS_PRTCL_WRITE; 166 protocol |= ACPI_SMBUS_PRTCL_WRITE;
157 method = smbus_methods.mt_sbw; 167 method = smbus_cmi->methods->mt_sbw;
158 input.count = 5; 168 input.count = 5;
159 } 169 }
160 170
@@ -290,13 +300,13 @@ static int acpi_smbus_cmi_add_cap(struct acpi_smbus_cmi *smbus_cmi,
290 union acpi_object *obj; 300 union acpi_object *obj;
291 acpi_status status; 301 acpi_status status;
292 302
293 if (!strcmp(name, smbus_methods.mt_info)) { 303 if (!strcmp(name, smbus_cmi->methods->mt_info)) {
294 status = acpi_evaluate_object(smbus_cmi->handle, 304 status = acpi_evaluate_object(smbus_cmi->handle,
295 smbus_methods.mt_info, 305 smbus_cmi->methods->mt_info,
296 NULL, &buffer); 306 NULL, &buffer);
297 if (ACPI_FAILURE(status)) { 307 if (ACPI_FAILURE(status)) {
298 ACPI_ERROR((AE_INFO, "Evaluating %s: %i", 308 ACPI_ERROR((AE_INFO, "Evaluating %s: %i",
299 smbus_methods.mt_info, status)); 309 smbus_cmi->methods->mt_info, status));
300 return -EIO; 310 return -EIO;
301 } 311 }
302 312
@@ -319,9 +329,9 @@ static int acpi_smbus_cmi_add_cap(struct acpi_smbus_cmi *smbus_cmi,
319 329
320 kfree(buffer.pointer); 330 kfree(buffer.pointer);
321 smbus_cmi->cap_info = 1; 331 smbus_cmi->cap_info = 1;
322 } else if (!strcmp(name, smbus_methods.mt_sbr)) 332 } else if (!strcmp(name, smbus_cmi->methods->mt_sbr))
323 smbus_cmi->cap_read = 1; 333 smbus_cmi->cap_read = 1;
324 else if (!strcmp(name, smbus_methods.mt_sbw)) 334 else if (!strcmp(name, smbus_cmi->methods->mt_sbw))
325 smbus_cmi->cap_write = 1; 335 smbus_cmi->cap_write = 1;
326 else 336 else
327 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Unsupported CMI method: %s\n", 337 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Unsupported CMI method: %s\n",
@@ -349,6 +359,7 @@ static acpi_status acpi_smbus_cmi_query_methods(acpi_handle handle, u32 level,
349static int acpi_smbus_cmi_add(struct acpi_device *device) 359static int acpi_smbus_cmi_add(struct acpi_device *device)
350{ 360{
351 struct acpi_smbus_cmi *smbus_cmi; 361 struct acpi_smbus_cmi *smbus_cmi;
362 const struct acpi_device_id *id;
352 363
353 smbus_cmi = kzalloc(sizeof(struct acpi_smbus_cmi), GFP_KERNEL); 364 smbus_cmi = kzalloc(sizeof(struct acpi_smbus_cmi), GFP_KERNEL);
354 if (!smbus_cmi) 365 if (!smbus_cmi)
@@ -362,6 +373,11 @@ static int acpi_smbus_cmi_add(struct acpi_device *device)
362 smbus_cmi->cap_read = 0; 373 smbus_cmi->cap_read = 0;
363 smbus_cmi->cap_write = 0; 374 smbus_cmi->cap_write = 0;
364 375
376 for (id = acpi_smbus_cmi_ids; id->id[0]; id++)
377 if (!strcmp(id->id, acpi_device_hid(device)))
378 smbus_cmi->methods =
379 (struct smbus_methods_t *) id->driver_data;
380
365 acpi_walk_namespace(ACPI_TYPE_METHOD, smbus_cmi->handle, 1, 381 acpi_walk_namespace(ACPI_TYPE_METHOD, smbus_cmi->handle, 1,
366 acpi_smbus_cmi_query_methods, NULL, smbus_cmi, NULL); 382 acpi_smbus_cmi_query_methods, NULL, smbus_cmi, NULL);
367 383
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c
index ccc46418ef7..ffb405d7c6f 100644
--- a/drivers/i2c/busses/i2c-sh_mobile.c
+++ b/drivers/i2c/busses/i2c-sh_mobile.c
@@ -31,6 +31,7 @@
31#include <linux/pm_runtime.h> 31#include <linux/pm_runtime.h>
32#include <linux/clk.h> 32#include <linux/clk.h>
33#include <linux/io.h> 33#include <linux/io.h>
34#include <linux/slab.h>
34 35
35/* Transmit operation: */ 36/* Transmit operation: */
36/* */ 37/* */
diff --git a/drivers/i2c/busses/i2c-simtec.c b/drivers/i2c/busses/i2c-simtec.c
index 6407f47bda8..78b06107342 100644
--- a/drivers/i2c/busses/i2c-simtec.c
+++ b/drivers/i2c/busses/i2c-simtec.c
@@ -23,6 +23,7 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26#include <linux/slab.h>
26 27
27#include <linux/i2c.h> 28#include <linux/i2c.h>
28#include <linux/i2c-algo-bit.h> 29#include <linux/i2c-algo-bit.h>
diff --git a/drivers/i2c/busses/i2c-stu300.c b/drivers/i2c/busses/i2c-stu300.c
index d2728a28a8d..495be451d32 100644
--- a/drivers/i2c/busses/i2c-stu300.c
+++ b/drivers/i2c/busses/i2c-stu300.c
@@ -16,6 +16,7 @@
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/clk.h> 17#include <linux/clk.h>
18#include <linux/io.h> 18#include <linux/io.h>
19#include <linux/slab.h>
19 20
20/* the name of this kernel module */ 21/* the name of this kernel module */
21#define NAME "stu300" 22#define NAME "stu300"
@@ -497,7 +498,7 @@ static int stu300_set_clk(struct stu300_dev *dev, unsigned long clkrate)
497 int i = 0; 498 int i = 0;
498 499
499 /* Locate the apropriate clock setting */ 500 /* Locate the apropriate clock setting */
500 while (i < ARRAY_SIZE(stu300_clktable) && 501 while (i < ARRAY_SIZE(stu300_clktable) - 1 &&
501 stu300_clktable[i].rate < clkrate) 502 stu300_clktable[i].rate < clkrate)
502 i++; 503 i++;
503 504
diff --git a/drivers/i2c/busses/i2c-tiny-usb.c b/drivers/i2c/busses/i2c-tiny-usb.c
index b5b1bbf37d3..d03b04002f0 100644
--- a/drivers/i2c/busses/i2c-tiny-usb.c
+++ b/drivers/i2c/busses/i2c-tiny-usb.c
@@ -13,6 +13,7 @@
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/errno.h> 14#include <linux/errno.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/slab.h>
16#include <linux/types.h> 17#include <linux/types.h>
17 18
18/* include interfaces to usb layer */ 19/* include interfaces to usb layer */
diff --git a/drivers/i2c/busses/i2c-versatile.c b/drivers/i2c/busses/i2c-versatile.c
index 70de8216346..5c473833d94 100644
--- a/drivers/i2c/busses/i2c-versatile.c
+++ b/drivers/i2c/busses/i2c-versatile.c
@@ -14,6 +14,7 @@
14#include <linux/i2c-algo-bit.h> 14#include <linux/i2c-algo-bit.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/slab.h>
17 18
18#include <asm/io.h> 19#include <asm/io.h>
19 20
diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index f0ef8da6c55..a9c419e075a 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -39,6 +39,7 @@
39#include <linux/wait.h> 39#include <linux/wait.h>
40#include <linux/i2c-xiic.h> 40#include <linux/i2c-xiic.h>
41#include <linux/io.h> 41#include <linux/io.h>
42#include <linux/slab.h>
42 43
43#define DRIVER_NAME "xiic-i2c" 44#define DRIVER_NAME "xiic-i2c"
44 45
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c
index cf994bd01d9..684395b6f3e 100644
--- a/drivers/i2c/busses/scx200_acb.c
+++ b/drivers/i2c/busses/scx200_acb.c
@@ -31,6 +31,7 @@
31#include <linux/pci.h> 31#include <linux/pci.h>
32#include <linux/delay.h> 32#include <linux/delay.h>
33#include <linux/mutex.h> 33#include <linux/mutex.h>
34#include <linux/slab.h>
34#include <asm/io.h> 35#include <asm/io.h>
35 36
36#include <linux/scx200.h> 37#include <linux/scx200.h>
diff --git a/drivers/i2c/i2c-boardinfo.c b/drivers/i2c/i2c-boardinfo.c
index a26a34a0664..7e6a63b5716 100644
--- a/drivers/i2c/i2c-boardinfo.c
+++ b/drivers/i2c/i2c-boardinfo.c
@@ -18,6 +18,7 @@
18 18
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <linux/slab.h>
21#include <linux/rwsem.h> 22#include <linux/rwsem.h>
22 23
23#include "i2c-core.h" 24#include "i2c-core.h"
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 3202a86f420..c2258a51fe0 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -40,12 +40,11 @@
40#include "i2c-core.h" 40#include "i2c-core.h"
41 41
42 42
43/* core_lock protects i2c_adapter_idr, userspace_devices, and guarantees 43/* core_lock protects i2c_adapter_idr, and guarantees
44 that device detection, deletion of detected devices, and attach_adapter 44 that device detection, deletion of detected devices, and attach_adapter
45 and detach_adapter calls are serialized */ 45 and detach_adapter calls are serialized */
46static DEFINE_MUTEX(core_lock); 46static DEFINE_MUTEX(core_lock);
47static DEFINE_IDR(i2c_adapter_idr); 47static DEFINE_IDR(i2c_adapter_idr);
48static LIST_HEAD(userspace_devices);
49 48
50static struct device_type i2c_client_type; 49static struct device_type i2c_client_type;
51static int i2c_check_addr(struct i2c_adapter *adapter, int addr); 50static int i2c_check_addr(struct i2c_adapter *adapter, int addr);
@@ -117,8 +116,10 @@ static int i2c_device_probe(struct device *dev)
117 dev_dbg(dev, "probe\n"); 116 dev_dbg(dev, "probe\n");
118 117
119 status = driver->probe(client, i2c_match_id(driver->id_table, client)); 118 status = driver->probe(client, i2c_match_id(driver->id_table, client));
120 if (status) 119 if (status) {
121 client->driver = NULL; 120 client->driver = NULL;
121 i2c_set_clientdata(client, NULL);
122 }
122 return status; 123 return status;
123} 124}
124 125
@@ -139,8 +140,10 @@ static int i2c_device_remove(struct device *dev)
139 dev->driver = NULL; 140 dev->driver = NULL;
140 status = 0; 141 status = 0;
141 } 142 }
142 if (status == 0) 143 if (status == 0) {
143 client->driver = NULL; 144 client->driver = NULL;
145 i2c_set_clientdata(client, NULL);
146 }
144 return status; 147 return status;
145} 148}
146 149
@@ -538,9 +541,9 @@ i2c_sysfs_new_device(struct device *dev, struct device_attribute *attr,
538 return -EEXIST; 541 return -EEXIST;
539 542
540 /* Keep track of the added device */ 543 /* Keep track of the added device */
541 mutex_lock(&core_lock); 544 i2c_lock_adapter(adap);
542 list_add_tail(&client->detected, &userspace_devices); 545 list_add_tail(&client->detected, &adap->userspace_clients);
543 mutex_unlock(&core_lock); 546 i2c_unlock_adapter(adap);
544 dev_info(dev, "%s: Instantiated device %s at 0x%02hx\n", "new_device", 547 dev_info(dev, "%s: Instantiated device %s at 0x%02hx\n", "new_device",
545 info.type, info.addr); 548 info.type, info.addr);
546 549
@@ -579,9 +582,10 @@ i2c_sysfs_delete_device(struct device *dev, struct device_attribute *attr,
579 582
580 /* Make sure the device was added through sysfs */ 583 /* Make sure the device was added through sysfs */
581 res = -ENOENT; 584 res = -ENOENT;
582 mutex_lock(&core_lock); 585 i2c_lock_adapter(adap);
583 list_for_each_entry_safe(client, next, &userspace_devices, detected) { 586 list_for_each_entry_safe(client, next, &adap->userspace_clients,
584 if (client->addr == addr && client->adapter == adap) { 587 detected) {
588 if (client->addr == addr) {
585 dev_info(dev, "%s: Deleting device %s at 0x%02hx\n", 589 dev_info(dev, "%s: Deleting device %s at 0x%02hx\n",
586 "delete_device", client->name, client->addr); 590 "delete_device", client->name, client->addr);
587 591
@@ -591,7 +595,7 @@ i2c_sysfs_delete_device(struct device *dev, struct device_attribute *attr,
591 break; 595 break;
592 } 596 }
593 } 597 }
594 mutex_unlock(&core_lock); 598 i2c_unlock_adapter(adap);
595 599
596 if (res < 0) 600 if (res < 0)
597 dev_err(dev, "%s: Can't find device in list\n", 601 dev_err(dev, "%s: Can't find device in list\n",
@@ -673,6 +677,7 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
673 } 677 }
674 678
675 rt_mutex_init(&adap->bus_lock); 679 rt_mutex_init(&adap->bus_lock);
680 INIT_LIST_HEAD(&adap->userspace_clients);
676 681
677 /* Set default timeout to 1 second if not already set */ 682 /* Set default timeout to 1 second if not already set */
678 if (adap->timeout == 0) 683 if (adap->timeout == 0)
@@ -875,14 +880,15 @@ int i2c_del_adapter(struct i2c_adapter *adap)
875 return res; 880 return res;
876 881
877 /* Remove devices instantiated from sysfs */ 882 /* Remove devices instantiated from sysfs */
878 list_for_each_entry_safe(client, next, &userspace_devices, detected) { 883 i2c_lock_adapter(adap);
879 if (client->adapter == adap) { 884 list_for_each_entry_safe(client, next, &adap->userspace_clients,
880 dev_dbg(&adap->dev, "Removing %s at 0x%x\n", 885 detected) {
881 client->name, client->addr); 886 dev_dbg(&adap->dev, "Removing %s at 0x%x\n", client->name,
882 list_del(&client->detected); 887 client->addr);
883 i2c_unregister_device(client); 888 list_del(&client->detected);
884 } 889 i2c_unregister_device(client);
885 } 890 }
891 i2c_unlock_adapter(adap);
886 892
887 /* Detach any active clients. This can't fail, thus we do not 893 /* Detach any active clients. This can't fail, thus we do not
888 checking the returned value. */ 894 checking the returned value. */
@@ -1260,12 +1266,23 @@ static int i2c_detect_address(struct i2c_client *temp_client,
1260 return 0; 1266 return 0;
1261 1267
1262 /* Make sure there is something at this address */ 1268 /* Make sure there is something at this address */
1263 if (i2c_smbus_xfer(adapter, addr, 0, 0, 0, I2C_SMBUS_QUICK, NULL) < 0) 1269 if (addr == 0x73 && (adapter->class & I2C_CLASS_HWMON)) {
1264 return 0; 1270 /* Special probe for FSC hwmon chips */
1271 union i2c_smbus_data dummy;
1265 1272
1266 /* Prevent 24RF08 corruption */ 1273 if (i2c_smbus_xfer(adapter, addr, 0, I2C_SMBUS_READ, 0,
1267 if ((addr & ~0x0f) == 0x50) 1274 I2C_SMBUS_BYTE_DATA, &dummy) < 0)
1268 i2c_smbus_xfer(adapter, addr, 0, 0, 0, I2C_SMBUS_QUICK, NULL); 1275 return 0;
1276 } else {
1277 if (i2c_smbus_xfer(adapter, addr, 0, I2C_SMBUS_WRITE, 0,
1278 I2C_SMBUS_QUICK, NULL) < 0)
1279 return 0;
1280
1281 /* Prevent 24RF08 corruption */
1282 if ((addr & ~0x0f) == 0x50)
1283 i2c_smbus_xfer(adapter, addr, 0, I2C_SMBUS_WRITE, 0,
1284 I2C_SMBUS_QUICK, NULL);
1285 }
1269 1286
1270 /* Finally call the custom detection function */ 1287 /* Finally call the custom detection function */
1271 memset(&info, 0, sizeof(struct i2c_board_info)); 1288 memset(&info, 0, sizeof(struct i2c_board_info));
diff --git a/drivers/i2c/i2c-smbus.c b/drivers/i2c/i2c-smbus.c
index 7a8201ed218..a24e0bfe920 100644
--- a/drivers/i2c/i2c-smbus.c
+++ b/drivers/i2c/i2c-smbus.c
@@ -26,6 +26,7 @@
26#include <linux/workqueue.h> 26#include <linux/workqueue.h>
27#include <linux/i2c.h> 27#include <linux/i2c.h>
28#include <linux/i2c-smbus.h> 28#include <linux/i2c-smbus.h>
29#include <linux/slab.h>
29 30
30struct i2c_smbus_alert { 31struct i2c_smbus_alert {
31 unsigned int alert_edge_triggered:1; 32 unsigned int alert_edge_triggered:1;
diff --git a/drivers/ide/hpt366.c b/drivers/ide/hpt366.c
index b885c1d548f..45163693f73 100644
--- a/drivers/ide/hpt366.c
+++ b/drivers/ide/hpt366.c
@@ -128,6 +128,7 @@
128#include <linux/pci.h> 128#include <linux/pci.h>
129#include <linux/init.h> 129#include <linux/init.h>
130#include <linux/ide.h> 130#include <linux/ide.h>
131#include <linux/slab.h>
131 132
132#include <asm/uaccess.h> 133#include <asm/uaccess.h>
133#include <asm/io.h> 134#include <asm/io.h>
diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c
index 5cb01e5c323..c26c11905ff 100644
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -12,6 +12,7 @@
12#include <linux/device.h> 12#include <linux/device.h>
13#include <linux/errno.h> 13#include <linux/errno.h>
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/slab.h>
15#include <acpi/acpi.h> 16#include <acpi/acpi.h>
16#include <linux/ide.h> 17#include <linux/ide.h>
17#include <linux/pci.h> 18#include <linux/pci.h>
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index eb2181a6a11..f9daffd7d0e 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -7,6 +7,7 @@
7#include <linux/delay.h> 7#include <linux/delay.h>
8#include <linux/ide.h> 8#include <linux/ide.h>
9#include <linux/scatterlist.h> 9#include <linux/scatterlist.h>
10#include <linux/gfp.h>
10 11
11#include <scsi/scsi.h> 12#include <scsi/scsi.h>
12 13
@@ -263,8 +264,8 @@ void ide_retry_pc(ide_drive_t *drive)
263 * of it. The failed command will be retried after sense data 264 * of it. The failed command will be retried after sense data
264 * is acquired. 265 * is acquired.
265 */ 266 */
266 blk_requeue_request(failed_rq->q, failed_rq);
267 drive->hwif->rq = NULL; 267 drive->hwif->rq = NULL;
268 ide_requeue_and_plug(drive, failed_rq);
268 if (ide_queue_sense_rq(drive, pc)) { 269 if (ide_queue_sense_rq(drive, pc)) {
269 blk_start_request(failed_rq); 270 blk_start_request(failed_rq);
270 ide_complete_rq(drive, -EIO, blk_rq_bytes(failed_rq)); 271 ide_complete_rq(drive, -EIO, blk_rq_bytes(failed_rq));
diff --git a/drivers/ide/ide-cd_ioctl.c b/drivers/ide/ide-cd_ioctl.c
index df3df0041eb..02712bf045c 100644
--- a/drivers/ide/ide-cd_ioctl.c
+++ b/drivers/ide/ide-cd_ioctl.c
@@ -8,6 +8,7 @@
8 8
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/cdrom.h> 10#include <linux/cdrom.h>
11#include <linux/gfp.h>
11#include <linux/ide.h> 12#include <linux/ide.h>
12#include <scsi/scsi.h> 13#include <scsi/scsi.h>
13 14
diff --git a/drivers/ide/ide-cs.c b/drivers/ide/ide-cs.c
index ab87e4f7cec..b85450865ff 100644
--- a/drivers/ide/ide-cs.c
+++ b/drivers/ide/ide-cs.c
@@ -409,6 +409,8 @@ static struct pcmcia_device_id ide_ids[] = {
409 PCMCIA_DEVICE_PROD_ID12("Hyperstone", "Model1", 0x3d5b9ef5, 0xca6ab420), 409 PCMCIA_DEVICE_PROD_ID12("Hyperstone", "Model1", 0x3d5b9ef5, 0xca6ab420),
410 PCMCIA_DEVICE_PROD_ID12("IBM", "microdrive", 0xb569a6e5, 0xa6d76178), 410 PCMCIA_DEVICE_PROD_ID12("IBM", "microdrive", 0xb569a6e5, 0xa6d76178),
411 PCMCIA_DEVICE_PROD_ID12("IBM", "IBM17JSSFP20", 0xb569a6e5, 0xf2508753), 411 PCMCIA_DEVICE_PROD_ID12("IBM", "IBM17JSSFP20", 0xb569a6e5, 0xf2508753),
412 PCMCIA_DEVICE_PROD_ID12("KINGSTON", "CF CARD 1GB", 0x2e6d1829, 0x55d5bffb),
413 PCMCIA_DEVICE_PROD_ID12("KINGSTON", "CF CARD 4GB", 0x2e6d1829, 0x531e7d10),
412 PCMCIA_DEVICE_PROD_ID12("KINGSTON", "CF8GB", 0x2e6d1829, 0xacbe682e), 414 PCMCIA_DEVICE_PROD_ID12("KINGSTON", "CF8GB", 0x2e6d1829, 0xacbe682e),
413 PCMCIA_DEVICE_PROD_ID12("IO DATA", "CBIDE2 ", 0x547e66dc, 0x8671043b), 415 PCMCIA_DEVICE_PROD_ID12("IO DATA", "CBIDE2 ", 0x547e66dc, 0x8671043b),
414 PCMCIA_DEVICE_PROD_ID12("IO DATA", "PCIDE", 0x547e66dc, 0x5c5ab149), 416 PCMCIA_DEVICE_PROD_ID12("IO DATA", "PCIDE", 0x547e66dc, 0x5c5ab149),
@@ -429,6 +431,8 @@ static struct pcmcia_device_id ide_ids[] = {
429 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS1GCF80", 0x709b1bf1, 0x2a54d4b1), 431 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS1GCF80", 0x709b1bf1, 0x2a54d4b1),
430 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS2GCF120", 0x709b1bf1, 0x969aa4f2), 432 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS2GCF120", 0x709b1bf1, 0x969aa4f2),
431 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS4GCF120", 0x709b1bf1, 0xf54a91c8), 433 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS4GCF120", 0x709b1bf1, 0xf54a91c8),
434 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS4GCF133", 0x709b1bf1, 0x7558f133),
435 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS8GCF133", 0x709b1bf1, 0xb2f89b47),
432 PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852), 436 PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852),
433 PCMCIA_DEVICE_PROD_ID12("WEIDA", "TWTTI", 0xcc7cf69c, 0x212bb918), 437 PCMCIA_DEVICE_PROD_ID12("WEIDA", "TWTTI", 0xcc7cf69c, 0x212bb918),
434 PCMCIA_DEVICE_PROD_ID1("STI Flash", 0xe4a13209), 438 PCMCIA_DEVICE_PROD_ID1("STI Flash", 0xe4a13209),
diff --git a/drivers/ide/ide-devsets.c b/drivers/ide/ide-devsets.c
index c6935c78757..9e98122f646 100644
--- a/drivers/ide/ide-devsets.c
+++ b/drivers/ide/ide-devsets.c
@@ -1,5 +1,6 @@
1 1
2#include <linux/kernel.h> 2#include <linux/kernel.h>
3#include <linux/gfp.h>
3#include <linux/ide.h> 4#include <linux/ide.h>
4 5
5DEFINE_MUTEX(ide_setting_mtx); 6DEFINE_MUTEX(ide_setting_mtx);
diff --git a/drivers/ide/ide-disk_proc.c b/drivers/ide/ide-disk_proc.c
index 60b0590ccc9..f9bbd904eae 100644
--- a/drivers/ide/ide-disk_proc.c
+++ b/drivers/ide/ide-disk_proc.c
@@ -1,5 +1,6 @@
1#include <linux/kernel.h> 1#include <linux/kernel.h>
2#include <linux/ide.h> 2#include <linux/ide.h>
3#include <linux/slab.h>
3#include <linux/seq_file.h> 4#include <linux/seq_file.h>
4 5
5#include "ide-disk.h" 6#include "ide-disk.h"
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index ee58c88dee5..06b14bc9a1d 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -29,6 +29,7 @@
29 */ 29 */
30 30
31#include <linux/types.h> 31#include <linux/types.h>
32#include <linux/gfp.h>
32#include <linux/kernel.h> 33#include <linux/kernel.h>
33#include <linux/ide.h> 34#include <linux/ide.h>
34#include <linux/scatterlist.h> 35#include <linux/scatterlist.h>
@@ -492,6 +493,7 @@ ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error)
492 if (rq) { 493 if (rq) {
493 hwif->rq = NULL; 494 hwif->rq = NULL;
494 rq->errors = 0; 495 rq->errors = 0;
496 ide_requeue_and_plug(drive, rq);
495 } 497 }
496 return ret; 498 return ret;
497} 499}
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index efd90762346..4713bdca20b 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -25,7 +25,6 @@
25#include <linux/major.h> 25#include <linux/major.h>
26#include <linux/errno.h> 26#include <linux/errno.h>
27#include <linux/genhd.h> 27#include <linux/genhd.h>
28#include <linux/slab.h>
29#include <linux/cdrom.h> 28#include <linux/cdrom.h>
30#include <linux/ide.h> 29#include <linux/ide.h>
31#include <linux/hdreg.h> 30#include <linux/hdreg.h>
diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c
index 753241429c2..c32d83996ae 100644
--- a/drivers/ide/ide-gd.c
+++ b/drivers/ide/ide-gd.c
@@ -8,6 +8,7 @@
8#include <linux/ide.h> 8#include <linux/ide.h>
9#include <linux/hdreg.h> 9#include <linux/hdreg.h>
10#include <linux/dmi.h> 10#include <linux/dmi.h>
11#include <linux/slab.h>
11 12
12#if !defined(CONFIG_DEBUG_BLOCK_EXT_DEVT) 13#if !defined(CONFIG_DEBUG_BLOCK_EXT_DEVT)
13#define IDE_DISK_MINORS (1 << PARTN_BITS) 14#define IDE_DISK_MINORS (1 << PARTN_BITS)
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index db96138fefc..172ac921815 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -566,7 +566,7 @@ plug_device_2:
566 blk_plug_device(q); 566 blk_plug_device(q);
567} 567}
568 568
569static void ide_requeue_and_plug(ide_drive_t *drive, struct request *rq) 569void ide_requeue_and_plug(ide_drive_t *drive, struct request *rq)
570{ 570{
571 struct request_queue *q = drive->queue; 571 struct request_queue *q = drive->queue;
572 unsigned long flags; 572 unsigned long flags;
diff --git a/drivers/ide/ide-ioctls.c b/drivers/ide/ide-ioctls.c
index 6e7ae2b6cfc..9965ecd5078 100644
--- a/drivers/ide/ide-ioctls.c
+++ b/drivers/ide/ide-ioctls.c
@@ -4,6 +4,7 @@
4 4
5#include <linux/hdreg.h> 5#include <linux/hdreg.h>
6#include <linux/ide.h> 6#include <linux/ide.h>
7#include <linux/slab.h>
7 8
8static const struct ide_ioctl_devset ide_ioctl_settings[] = { 9static const struct ide_ioctl_devset ide_ioctl_settings[] = {
9{ HDIO_GET_32BIT, HDIO_SET_32BIT, &ide_devset_io_32bit }, 10{ HDIO_GET_32BIT, HDIO_SET_32BIT, &ide_devset_io_32bit },
diff --git a/drivers/ide/ide-park.c b/drivers/ide/ide-park.c
index a914023d6d0..88a380c5a47 100644
--- a/drivers/ide/ide-park.c
+++ b/drivers/ide/ide-park.c
@@ -1,4 +1,5 @@
1#include <linux/kernel.h> 1#include <linux/kernel.h>
2#include <linux/gfp.h>
2#include <linux/ide.h> 3#include <linux/ide.h>
3#include <linux/jiffies.h> 4#include <linux/jiffies.h>
4#include <linux/blkdev.h> 5#include <linux/blkdev.h>
diff --git a/drivers/ide/ide-pm.c b/drivers/ide/ide-pm.c
index ad7be2669dc..1c08311b0a0 100644
--- a/drivers/ide/ide-pm.c
+++ b/drivers/ide/ide-pm.c
@@ -1,4 +1,5 @@
1#include <linux/kernel.h> 1#include <linux/kernel.h>
2#include <linux/gfp.h>
2#include <linux/ide.h> 3#include <linux/ide.h>
3 4
4int generic_ide_suspend(struct device *dev, pm_message_t mesg) 5int generic_ide_suspend(struct device *dev, pm_message_t mesg)
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index fbedd35feb4..4c3d1bfec0c 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -695,14 +695,8 @@ static int ide_probe_port(ide_hwif_t *hwif)
695 if (irqd) 695 if (irqd)
696 disable_irq(hwif->irq); 696 disable_irq(hwif->irq);
697 697
698 rc = ide_port_wait_ready(hwif); 698 if (ide_port_wait_ready(hwif) == -EBUSY)
699 if (rc == -ENODEV) { 699 printk(KERN_DEBUG "%s: Wait for ready failed before probe !\n", hwif->name);
700 printk(KERN_INFO "%s: no devices on the port\n", hwif->name);
701 goto out;
702 } else if (rc == -EBUSY)
703 printk(KERN_ERR "%s: not ready before the probe\n", hwif->name);
704 else
705 rc = -ENODEV;
706 700
707 /* 701 /*
708 * Second drive should only exist if first drive was found, 702 * Second drive should only exist if first drive was found,
@@ -713,7 +707,7 @@ static int ide_probe_port(ide_hwif_t *hwif)
713 if (drive->dev_flags & IDE_DFLAG_PRESENT) 707 if (drive->dev_flags & IDE_DFLAG_PRESENT)
714 rc = 0; 708 rc = 0;
715 } 709 }
716out: 710
717 /* 711 /*
718 * Use cached IRQ number. It might be (and is...) changed by probe 712 * Use cached IRQ number. It might be (and is...) changed by probe
719 * code above 713 * code above
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c
index 017c09540c2..a3133d7b2a0 100644
--- a/drivers/ide/ide-proc.c
+++ b/drivers/ide/ide-proc.c
@@ -25,6 +25,7 @@
25#include <linux/ctype.h> 25#include <linux/ctype.h>
26#include <linux/ide.h> 26#include <linux/ide.h>
27#include <linux/seq_file.h> 27#include <linux/seq_file.h>
28#include <linux/slab.h>
28 29
29#include <asm/io.h> 30#include <asm/io.h>
30 31
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index cc8633cbe13..67fb73559fd 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -428,13 +428,11 @@ int ide_raw_taskfile(ide_drive_t *drive, struct ide_cmd *cmd, u8 *buf,
428{ 428{
429 struct request *rq; 429 struct request *rq;
430 int error; 430 int error;
431 int rw = !(cmd->tf_flags & IDE_TFLAG_WRITE) ? READ : WRITE;
431 432
432 rq = blk_get_request(drive->queue, READ, __GFP_WAIT); 433 rq = blk_get_request(drive->queue, rw, __GFP_WAIT);
433 rq->cmd_type = REQ_TYPE_ATA_TASKFILE; 434 rq->cmd_type = REQ_TYPE_ATA_TASKFILE;
434 435
435 if (cmd->tf_flags & IDE_TFLAG_WRITE)
436 rq->cmd_flags |= REQ_RW;
437
438 /* 436 /*
439 * (ks) We transfer currently only whole sectors. 437 * (ks) We transfer currently only whole sectors.
440 * This is suffient for now. But, it would be great, 438 * This is suffient for now. But, it would be great,
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 16d056939f9..3cb9c4e056f 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -52,7 +52,6 @@
52#include <linux/major.h> 52#include <linux/major.h>
53#include <linux/errno.h> 53#include <linux/errno.h>
54#include <linux/genhd.h> 54#include <linux/genhd.h>
55#include <linux/slab.h>
56#include <linux/init.h> 55#include <linux/init.h>
57#include <linux/pci.h> 56#include <linux/pci.h>
58#include <linux/ide.h> 57#include <linux/ide.h>
diff --git a/drivers/ide/it821x.c b/drivers/ide/it821x.c
index b2709c73348..2e3169f2acd 100644
--- a/drivers/ide/it821x.c
+++ b/drivers/ide/it821x.c
@@ -61,6 +61,7 @@
61 61
62#include <linux/types.h> 62#include <linux/types.h>
63#include <linux/module.h> 63#include <linux/module.h>
64#include <linux/slab.h>
64#include <linux/pci.h> 65#include <linux/pci.h>
65#include <linux/ide.h> 66#include <linux/ide.h>
66#include <linux/init.h> 67#include <linux/init.h>
diff --git a/drivers/ide/pmac.c b/drivers/ide/pmac.c
index 850ee452e9b..159955d16c4 100644
--- a/drivers/ide/pmac.c
+++ b/drivers/ide/pmac.c
@@ -33,6 +33,7 @@
33#include <linux/adb.h> 33#include <linux/adb.h>
34#include <linux/pmu.h> 34#include <linux/pmu.h>
35#include <linux/scatterlist.h> 35#include <linux/scatterlist.h>
36#include <linux/slab.h>
36 37
37#include <asm/prom.h> 38#include <asm/prom.h>
38#include <asm/io.h> 39#include <asm/io.h>
diff --git a/drivers/ide/rapide.c b/drivers/ide/rapide.c
index 00f54248f41..48d976aad7a 100644
--- a/drivers/ide/rapide.c
+++ b/drivers/ide/rapide.c
@@ -3,7 +3,6 @@
3 */ 3 */
4 4
5#include <linux/module.h> 5#include <linux/module.h>
6#include <linux/slab.h>
7#include <linux/blkdev.h> 6#include <linux/blkdev.h>
8#include <linux/errno.h> 7#include <linux/errno.h>
9#include <linux/ide.h> 8#include <linux/ide.h>
diff --git a/drivers/ide/sc1200.c b/drivers/ide/sc1200.c
index 134f1fd1386..356b9b504ff 100644
--- a/drivers/ide/sc1200.c
+++ b/drivers/ide/sc1200.c
@@ -14,6 +14,7 @@
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/types.h> 15#include <linux/types.h>
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/slab.h>
17#include <linux/pci.h> 18#include <linux/pci.h>
18#include <linux/init.h> 19#include <linux/init.h>
19#include <linux/ide.h> 20#include <linux/ide.h>
diff --git a/drivers/ide/via82cxxx.c b/drivers/ide/via82cxxx.c
index e65d010b708..101f4002238 100644
--- a/drivers/ide/via82cxxx.c
+++ b/drivers/ide/via82cxxx.c
@@ -26,6 +26,7 @@
26 26
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/kernel.h> 28#include <linux/kernel.h>
29#include <linux/slab.h>
29#include <linux/pci.h> 30#include <linux/pci.h>
30#include <linux/init.h> 31#include <linux/init.h>
31#include <linux/ide.h> 32#include <linux/ide.h>
@@ -110,7 +111,6 @@ struct via82cxxx_dev
110{ 111{
111 struct via_isa_bridge *via_config; 112 struct via_isa_bridge *via_config;
112 unsigned int via_80w; 113 unsigned int via_80w;
113 u8 cached_device[2];
114}; 114};
115 115
116/** 116/**
@@ -403,66 +403,10 @@ static const struct ide_port_ops via_port_ops = {
403 .cable_detect = via82cxxx_cable_detect, 403 .cable_detect = via82cxxx_cable_detect,
404}; 404};
405 405
406static void via_write_devctl(ide_hwif_t *hwif, u8 ctl)
407{
408 struct via82cxxx_dev *vdev = hwif->host->host_priv;
409
410 outb(ctl, hwif->io_ports.ctl_addr);
411 outb(vdev->cached_device[hwif->channel], hwif->io_ports.device_addr);
412}
413
414static void __via_dev_select(ide_drive_t *drive, u8 select)
415{
416 ide_hwif_t *hwif = drive->hwif;
417 struct via82cxxx_dev *vdev = hwif->host->host_priv;
418
419 outb(select, hwif->io_ports.device_addr);
420 vdev->cached_device[hwif->channel] = select;
421}
422
423static void via_dev_select(ide_drive_t *drive)
424{
425 __via_dev_select(drive, drive->select | ATA_DEVICE_OBS);
426}
427
428static void via_tf_load(ide_drive_t *drive, struct ide_taskfile *tf, u8 valid)
429{
430 ide_hwif_t *hwif = drive->hwif;
431 struct ide_io_ports *io_ports = &hwif->io_ports;
432
433 if (valid & IDE_VALID_FEATURE)
434 outb(tf->feature, io_ports->feature_addr);
435 if (valid & IDE_VALID_NSECT)
436 outb(tf->nsect, io_ports->nsect_addr);
437 if (valid & IDE_VALID_LBAL)
438 outb(tf->lbal, io_ports->lbal_addr);
439 if (valid & IDE_VALID_LBAM)
440 outb(tf->lbam, io_ports->lbam_addr);
441 if (valid & IDE_VALID_LBAH)
442 outb(tf->lbah, io_ports->lbah_addr);
443 if (valid & IDE_VALID_DEVICE)
444 __via_dev_select(drive, tf->device);
445}
446
447const struct ide_tp_ops via_tp_ops = {
448 .exec_command = ide_exec_command,
449 .read_status = ide_read_status,
450 .read_altstatus = ide_read_altstatus,
451 .write_devctl = via_write_devctl,
452
453 .dev_select = via_dev_select,
454 .tf_load = via_tf_load,
455 .tf_read = ide_tf_read,
456
457 .input_data = ide_input_data,
458 .output_data = ide_output_data,
459};
460
461static const struct ide_port_info via82cxxx_chipset __devinitdata = { 406static const struct ide_port_info via82cxxx_chipset __devinitdata = {
462 .name = DRV_NAME, 407 .name = DRV_NAME,
463 .init_chipset = init_chipset_via82cxxx, 408 .init_chipset = init_chipset_via82cxxx,
464 .enablebits = { { 0x40, 0x02, 0x02 }, { 0x40, 0x01, 0x01 } }, 409 .enablebits = { { 0x40, 0x02, 0x02 }, { 0x40, 0x01, 0x01 } },
465 .tp_ops = &via_tp_ops,
466 .port_ops = &via_port_ops, 410 .port_ops = &via_port_ops,
467 .host_flags = IDE_HFLAG_PIO_NO_BLACKLIST | 411 .host_flags = IDE_HFLAG_PIO_NO_BLACKLIST |
468 IDE_HFLAG_POST_SET_MODE | 412 IDE_HFLAG_POST_SET_MODE |
diff --git a/drivers/idle/i7300_idle.c b/drivers/idle/i7300_idle.c
index dd253002cd5..15341fc1c68 100644
--- a/drivers/idle/i7300_idle.c
+++ b/drivers/idle/i7300_idle.c
@@ -18,6 +18,7 @@
18 18
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/pci.h> 20#include <linux/pci.h>
21#include <linux/gfp.h>
21#include <linux/sched.h> 22#include <linux/sched.h>
22#include <linux/notifier.h> 23#include <linux/notifier.h>
23#include <linux/cpumask.h> 24#include <linux/cpumask.h>
diff --git a/drivers/ieee1394/dma.c b/drivers/ieee1394/dma.c
index 8e7e3344c4b..d178699b194 100644
--- a/drivers/ieee1394/dma.c
+++ b/drivers/ieee1394/dma.c
@@ -10,7 +10,6 @@
10#include <linux/mm.h> 10#include <linux/mm.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/pci.h> 12#include <linux/pci.h>
13#include <linux/slab.h>
14#include <linux/vmalloc.h> 13#include <linux/vmalloc.h>
15#include <linux/scatterlist.h> 14#include <linux/scatterlist.h>
16 15
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index c88696a6cf8..4565cb5d3d1 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -56,7 +56,6 @@
56#include <linux/delay.h> 56#include <linux/delay.h>
57#include <linux/device.h> 57#include <linux/device.h>
58#include <linux/dma-mapping.h> 58#include <linux/dma-mapping.h>
59#include <linux/gfp.h>
60#include <linux/init.h> 59#include <linux/init.h>
61#include <linux/kernel.h> 60#include <linux/kernel.h>
62#include <linux/list.h> 61#include <linux/list.h>
diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index abbb06996f9..0b926e45afe 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -35,6 +35,7 @@
35 35
36#include <linux/mutex.h> 36#include <linux/mutex.h>
37#include <linux/inetdevice.h> 37#include <linux/inetdevice.h>
38#include <linux/slab.h>
38#include <linux/workqueue.h> 39#include <linux/workqueue.h>
39#include <net/arp.h> 40#include <net/arp.h>
40#include <net/neighbour.h> 41#include <net/neighbour.h>
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index 764787ebe8d..ad63b79afac 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -42,6 +42,7 @@
42#include <linux/random.h> 42#include <linux/random.h>
43#include <linux/rbtree.h> 43#include <linux/rbtree.h>
44#include <linux/spinlock.h> 44#include <linux/spinlock.h>
45#include <linux/slab.h>
45#include <linux/sysfs.h> 46#include <linux/sysfs.h>
46#include <linux/workqueue.h> 47#include <linux/workqueue.h>
47#include <linux/kdev_t.h> 48#include <linux/kdev_t.h>
@@ -3693,7 +3694,7 @@ static void cm_add_one(struct ib_device *ib_device)
3693 cm_dev->device = device_create(&cm_class, &ib_device->dev, 3694 cm_dev->device = device_create(&cm_class, &ib_device->dev,
3694 MKDEV(0, 0), NULL, 3695 MKDEV(0, 0), NULL,
3695 "%s", ib_device->name); 3696 "%s", ib_device->name);
3696 if (!cm_dev->device) { 3697 if (IS_ERR(cm_dev->device)) {
3697 kfree(cm_dev); 3698 kfree(cm_dev);
3698 return; 3699 return;
3699 } 3700 }
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 875e34e0b23..6d777069d86 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -40,6 +40,7 @@
40#include <linux/random.h> 40#include <linux/random.h>
41#include <linux/idr.h> 41#include <linux/idr.h>
42#include <linux/inetdevice.h> 42#include <linux/inetdevice.h>
43#include <linux/slab.h>
43 44
44#include <net/tcp.h> 45#include <net/tcp.h>
45#include <net/ipv6.h> 46#include <net/ipv6.h>
@@ -1683,6 +1684,7 @@ int rdma_set_ib_paths(struct rdma_cm_id *id,
1683 } 1684 }
1684 1685
1685 memcpy(id->route.path_rec, path_rec, sizeof *path_rec * num_paths); 1686 memcpy(id->route.path_rec, path_rec, sizeof *path_rec * num_paths);
1687 id->route.num_paths = num_paths;
1686 return 0; 1688 return 0;
1687err: 1689err:
1688 cma_comp_exch(id_priv, CMA_ROUTE_RESOLVED, CMA_ADDR_RESOLVED); 1690 cma_comp_exch(id_priv, CMA_ROUTE_RESOLVED, CMA_ADDR_RESOLVED);
diff --git a/drivers/infiniband/core/iwcm.c b/drivers/infiniband/core/iwcm.c
index 0f89909abce..bfead5bc25f 100644
--- a/drivers/infiniband/core/iwcm.c
+++ b/drivers/infiniband/core/iwcm.c
@@ -44,6 +44,7 @@
44#include <linux/spinlock.h> 44#include <linux/spinlock.h>
45#include <linux/workqueue.h> 45#include <linux/workqueue.h>
46#include <linux/completion.h> 46#include <linux/completion.h>
47#include <linux/slab.h>
47 48
48#include <rdma/iw_cm.h> 49#include <rdma/iw_cm.h>
49#include <rdma/ib_addr.h> 50#include <rdma/ib_addr.h>
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index e351b154853..1df1194aeba 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -34,6 +34,7 @@
34 * 34 *
35 */ 35 */
36#include <linux/dma-mapping.h> 36#include <linux/dma-mapping.h>
37#include <linux/slab.h>
37#include <rdma/ib_cache.h> 38#include <rdma/ib_cache.h>
38 39
39#include "mad_priv.h" 40#include "mad_priv.h"
diff --git a/drivers/infiniband/core/mad_rmpp.c b/drivers/infiniband/core/mad_rmpp.c
index 4e0f2829e0e..f37878c9c06 100644
--- a/drivers/infiniband/core/mad_rmpp.c
+++ b/drivers/infiniband/core/mad_rmpp.c
@@ -31,6 +31,8 @@
31 * SOFTWARE. 31 * SOFTWARE.
32 */ 32 */
33 33
34#include <linux/slab.h>
35
34#include "mad_priv.h" 36#include "mad_priv.h"
35#include "mad_rmpp.h" 37#include "mad_rmpp.h"
36 38
diff --git a/drivers/infiniband/core/multicast.c b/drivers/infiniband/core/multicast.c
index 8d82ba17135..a519801dcfb 100644
--- a/drivers/infiniband/core/multicast.c
+++ b/drivers/infiniband/core/multicast.c
@@ -34,6 +34,7 @@
34#include <linux/dma-mapping.h> 34#include <linux/dma-mapping.h>
35#include <linux/err.h> 35#include <linux/err.h>
36#include <linux/interrupt.h> 36#include <linux/interrupt.h>
37#include <linux/slab.h>
37#include <linux/bitops.h> 38#include <linux/bitops.h>
38#include <linux/random.h> 39#include <linux/random.h>
39 40
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index 1558bb7fc74..f901957abc8 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -461,6 +461,7 @@ alloc_group_attrs(ssize_t (*show)(struct ib_port *,
461 element->attr.attr.mode = S_IRUGO; 461 element->attr.attr.mode = S_IRUGO;
462 element->attr.show = show; 462 element->attr.show = show;
463 element->index = i; 463 element->index = i;
464 sysfs_attr_init(&element->attr.attr);
464 465
465 tab_attr[i] = &element->attr.attr; 466 tab_attr[i] = &element->attr.attr;
466 } 467 }
diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c
index 017d6e24448..512b1c43460 100644
--- a/drivers/infiniband/core/ucm.c
+++ b/drivers/infiniband/core/ucm.c
@@ -44,6 +44,7 @@
44#include <linux/cdev.h> 44#include <linux/cdev.h>
45#include <linux/idr.h> 45#include <linux/idr.h>
46#include <linux/mutex.h> 46#include <linux/mutex.h>
47#include <linux/slab.h>
47 48
48#include <asm/uaccess.h> 49#include <asm/uaccess.h>
49 50
diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
index b2e16c332d5..46185084121 100644
--- a/drivers/infiniband/core/ucma.c
+++ b/drivers/infiniband/core/ucma.c
@@ -39,6 +39,7 @@
39#include <linux/in.h> 39#include <linux/in.h>
40#include <linux/in6.h> 40#include <linux/in6.h>
41#include <linux/miscdevice.h> 41#include <linux/miscdevice.h>
42#include <linux/slab.h>
42 43
43#include <rdma/rdma_user_cm.h> 44#include <rdma/rdma_user_cm.h>
44#include <rdma/ib_marshall.h> 45#include <rdma/ib_marshall.h>
diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
index 4f906f0614f..415e186eee3 100644
--- a/drivers/infiniband/core/umem.c
+++ b/drivers/infiniband/core/umem.c
@@ -37,6 +37,7 @@
37#include <linux/sched.h> 37#include <linux/sched.h>
38#include <linux/hugetlb.h> 38#include <linux/hugetlb.h>
39#include <linux/dma-attrs.h> 39#include <linux/dma-attrs.h>
40#include <linux/slab.h>
40 41
41#include "uverbs.h" 42#include "uverbs.h"
42 43
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index 04b585e86cb..e7db054fb1c 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -46,6 +46,7 @@
46#include <linux/compat.h> 46#include <linux/compat.h>
47#include <linux/sched.h> 47#include <linux/sched.h>
48#include <linux/semaphore.h> 48#include <linux/semaphore.h>
49#include <linux/slab.h>
49 50
50#include <asm/uaccess.h> 51#include <asm/uaccess.h>
51 52
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index f71cf138d67..6fcfbeb24a2 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -35,6 +35,7 @@
35 35
36#include <linux/file.h> 36#include <linux/file.h>
37#include <linux/fs.h> 37#include <linux/fs.h>
38#include <linux/slab.h>
38 39
39#include <asm/uaccess.h> 40#include <asm/uaccess.h>
40 41
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index d805cf365c8..fb352625442 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -44,6 +44,7 @@
44#include <linux/file.h> 44#include <linux/file.h>
45#include <linux/cdev.h> 45#include <linux/cdev.h>
46#include <linux/anon_inodes.h> 46#include <linux/anon_inodes.h>
47#include <linux/slab.h>
47 48
48#include <asm/uaccess.h> 49#include <asm/uaccess.h>
49 50
diff --git a/drivers/infiniband/hw/amso1100/c2.c b/drivers/infiniband/hw/amso1100/c2.c
index c61fd2b4a55..dc85d777578 100644
--- a/drivers/infiniband/hw/amso1100/c2.c
+++ b/drivers/infiniband/hw/amso1100/c2.c
@@ -46,6 +46,7 @@
46#include <linux/tcp.h> 46#include <linux/tcp.h>
47#include <linux/init.h> 47#include <linux/init.h>
48#include <linux/dma-mapping.h> 48#include <linux/dma-mapping.h>
49#include <linux/slab.h>
49 50
50#include <asm/io.h> 51#include <asm/io.h>
51#include <asm/irq.h> 52#include <asm/irq.h>
diff --git a/drivers/infiniband/hw/amso1100/c2_alloc.c b/drivers/infiniband/hw/amso1100/c2_alloc.c
index e9110163aef..d4f5f5d42e9 100644
--- a/drivers/infiniband/hw/amso1100/c2_alloc.c
+++ b/drivers/infiniband/hw/amso1100/c2_alloc.c
@@ -32,7 +32,6 @@
32 */ 32 */
33 33
34#include <linux/errno.h> 34#include <linux/errno.h>
35#include <linux/slab.h>
36#include <linux/bitmap.h> 35#include <linux/bitmap.h>
37 36
38#include "c2.h" 37#include "c2.h"
diff --git a/drivers/infiniband/hw/amso1100/c2_cm.c b/drivers/infiniband/hw/amso1100/c2_cm.c
index 75b93e9b881..95f58ab1e0b 100644
--- a/drivers/infiniband/hw/amso1100/c2_cm.c
+++ b/drivers/infiniband/hw/amso1100/c2_cm.c
@@ -31,6 +31,8 @@
31 * SOFTWARE. 31 * SOFTWARE.
32 * 32 *
33 */ 33 */
34#include <linux/slab.h>
35
34#include "c2.h" 36#include "c2.h"
35#include "c2_wr.h" 37#include "c2_wr.h"
36#include "c2_vq.h" 38#include "c2_vq.h"
diff --git a/drivers/infiniband/hw/amso1100/c2_cq.c b/drivers/infiniband/hw/amso1100/c2_cq.c
index f5c45b194f5..f7b0fc23f41 100644
--- a/drivers/infiniband/hw/amso1100/c2_cq.c
+++ b/drivers/infiniband/hw/amso1100/c2_cq.c
@@ -35,6 +35,8 @@
35 * SOFTWARE. 35 * SOFTWARE.
36 * 36 *
37 */ 37 */
38#include <linux/gfp.h>
39
38#include "c2.h" 40#include "c2.h"
39#include "c2_vq.h" 41#include "c2_vq.h"
40#include "c2_status.h" 42#include "c2_status.h"
diff --git a/drivers/infiniband/hw/amso1100/c2_mm.c b/drivers/infiniband/hw/amso1100/c2_mm.c
index b506fe22b4d..119c4f3d979 100644
--- a/drivers/infiniband/hw/amso1100/c2_mm.c
+++ b/drivers/infiniband/hw/amso1100/c2_mm.c
@@ -30,6 +30,8 @@
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 */ 32 */
33#include <linux/slab.h>
34
33#include "c2.h" 35#include "c2.h"
34#include "c2_vq.h" 36#include "c2_vq.h"
35 37
diff --git a/drivers/infiniband/hw/amso1100/c2_pd.c b/drivers/infiniband/hw/amso1100/c2_pd.c
index 00c709926c8..161f2a28535 100644
--- a/drivers/infiniband/hw/amso1100/c2_pd.c
+++ b/drivers/infiniband/hw/amso1100/c2_pd.c
@@ -34,6 +34,7 @@
34 */ 34 */
35 35
36#include <linux/init.h> 36#include <linux/init.h>
37#include <linux/slab.h>
37#include <linux/errno.h> 38#include <linux/errno.h>
38 39
39#include "c2.h" 40#include "c2.h"
diff --git a/drivers/infiniband/hw/amso1100/c2_provider.c b/drivers/infiniband/hw/amso1100/c2_provider.c
index ad723bd8bf4..c47f618d12e 100644
--- a/drivers/infiniband/hw/amso1100/c2_provider.c
+++ b/drivers/infiniband/hw/amso1100/c2_provider.c
@@ -50,6 +50,7 @@
50#include <linux/dma-mapping.h> 50#include <linux/dma-mapping.h>
51#include <linux/if_arp.h> 51#include <linux/if_arp.h>
52#include <linux/vmalloc.h> 52#include <linux/vmalloc.h>
53#include <linux/slab.h>
53 54
54#include <asm/io.h> 55#include <asm/io.h>
55#include <asm/irq.h> 56#include <asm/irq.h>
diff --git a/drivers/infiniband/hw/amso1100/c2_qp.c b/drivers/infiniband/hw/amso1100/c2_qp.c
index ad518868df7..d8f4bb8bf42 100644
--- a/drivers/infiniband/hw/amso1100/c2_qp.c
+++ b/drivers/infiniband/hw/amso1100/c2_qp.c
@@ -36,6 +36,7 @@
36 */ 36 */
37 37
38#include <linux/delay.h> 38#include <linux/delay.h>
39#include <linux/gfp.h>
39 40
40#include "c2.h" 41#include "c2.h"
41#include "c2_vq.h" 42#include "c2_vq.h"
diff --git a/drivers/infiniband/hw/amso1100/c2_rnic.c b/drivers/infiniband/hw/amso1100/c2_rnic.c
index dd05c483564..78c4bcc6ef6 100644
--- a/drivers/infiniband/hw/amso1100/c2_rnic.c
+++ b/drivers/infiniband/hw/amso1100/c2_rnic.c
@@ -51,6 +51,7 @@
51#include <linux/mm.h> 51#include <linux/mm.h>
52#include <linux/inet.h> 52#include <linux/inet.h>
53#include <linux/vmalloc.h> 53#include <linux/vmalloc.h>
54#include <linux/slab.h>
54 55
55#include <linux/route.h> 56#include <linux/route.h>
56 57
diff --git a/drivers/infiniband/hw/cxgb3/cxio_dbg.c b/drivers/infiniband/hw/cxgb3/cxio_dbg.c
index a8d24d53f30..8bca6b4ec9a 100644
--- a/drivers/infiniband/hw/cxgb3/cxio_dbg.c
+++ b/drivers/infiniband/hw/cxgb3/cxio_dbg.c
@@ -31,6 +31,7 @@
31 */ 31 */
32#ifdef DEBUG 32#ifdef DEBUG
33#include <linux/types.h> 33#include <linux/types.h>
34#include <linux/slab.h>
34#include "common.h" 35#include "common.h"
35#include "cxgb3_ioctl.h" 36#include "cxgb3_ioctl.h"
36#include "cxio_hal.h" 37#include "cxio_hal.h"
diff --git a/drivers/infiniband/hw/cxgb3/cxio_hal.c b/drivers/infiniband/hw/cxgb3/cxio_hal.c
index a28e862f2d6..35f286f1ad1 100644
--- a/drivers/infiniband/hw/cxgb3/cxio_hal.c
+++ b/drivers/infiniband/hw/cxgb3/cxio_hal.c
@@ -37,6 +37,7 @@
37#include <linux/spinlock.h> 37#include <linux/spinlock.h>
38#include <linux/pci.h> 38#include <linux/pci.h>
39#include <linux/dma-mapping.h> 39#include <linux/dma-mapping.h>
40#include <linux/slab.h>
40#include <net/net_namespace.h> 41#include <net/net_namespace.h>
41 42
42#include "cxio_resource.h" 43#include "cxio_resource.h"
diff --git a/drivers/infiniband/hw/cxgb3/iwch_cm.c b/drivers/infiniband/hw/cxgb3/iwch_cm.c
index d94388b81a4..4fef0329627 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_cm.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_cm.c
@@ -31,6 +31,7 @@
31 */ 31 */
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/list.h> 33#include <linux/list.h>
34#include <linux/slab.h>
34#include <linux/workqueue.h> 35#include <linux/workqueue.h>
35#include <linux/skbuff.h> 36#include <linux/skbuff.h>
36#include <linux/timer.h> 37#include <linux/timer.h>
diff --git a/drivers/infiniband/hw/cxgb3/iwch_ev.c b/drivers/infiniband/hw/cxgb3/iwch_ev.c
index 743c5d8b880..6afc89e7572 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_ev.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_ev.c
@@ -29,7 +29,7 @@
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 */ 31 */
32#include <linux/slab.h> 32#include <linux/gfp.h>
33#include <linux/mman.h> 33#include <linux/mman.h>
34#include <net/sock.h> 34#include <net/sock.h>
35#include "iwch_provider.h" 35#include "iwch_provider.h"
diff --git a/drivers/infiniband/hw/cxgb3/iwch_mem.c b/drivers/infiniband/hw/cxgb3/iwch_mem.c
index e1ec65ebb01..5c36ee2809a 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_mem.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_mem.c
@@ -29,6 +29,7 @@
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 */ 31 */
32#include <linux/slab.h>
32#include <asm/byteorder.h> 33#include <asm/byteorder.h>
33 34
34#include <rdma/iw_cm.h> 35#include <rdma/iw_cm.h>
diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.c b/drivers/infiniband/hw/cxgb3/iwch_provider.c
index 47b35c6608d..19b1c4a62a2 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_provider.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_provider.c
@@ -42,6 +42,7 @@
42#include <linux/ethtool.h> 42#include <linux/ethtool.h>
43#include <linux/rtnetlink.h> 43#include <linux/rtnetlink.h>
44#include <linux/inetdevice.h> 44#include <linux/inetdevice.h>
45#include <linux/slab.h>
45 46
46#include <asm/io.h> 47#include <asm/io.h>
47#include <asm/irq.h> 48#include <asm/irq.h>
diff --git a/drivers/infiniband/hw/cxgb3/iwch_qp.c b/drivers/infiniband/hw/cxgb3/iwch_qp.c
index b4d893de365..ae47bfd22bd 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_qp.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_qp.c
@@ -30,6 +30,7 @@
30 * SOFTWARE. 30 * SOFTWARE.
31 */ 31 */
32#include <linux/sched.h> 32#include <linux/sched.h>
33#include <linux/gfp.h>
33#include "iwch_provider.h" 34#include "iwch_provider.h"
34#include "iwch.h" 35#include "iwch.h"
35#include "iwch_cm.h" 36#include "iwch_cm.h"
diff --git a/drivers/infiniband/hw/ehca/ehca_av.c b/drivers/infiniband/hw/ehca/ehca_av.c
index 56735ea2fc5..465926319f3 100644
--- a/drivers/infiniband/hw/ehca/ehca_av.c
+++ b/drivers/infiniband/hw/ehca/ehca_av.c
@@ -41,6 +41,8 @@
41 * POSSIBILITY OF SUCH DAMAGE. 41 * POSSIBILITY OF SUCH DAMAGE.
42 */ 42 */
43 43
44#include <linux/slab.h>
45
44#include "ehca_tools.h" 46#include "ehca_tools.h"
45#include "ehca_iverbs.h" 47#include "ehca_iverbs.h"
46#include "hcp_if.h" 48#include "hcp_if.h"
diff --git a/drivers/infiniband/hw/ehca/ehca_cq.c b/drivers/infiniband/hw/ehca/ehca_cq.c
index 97e4b231cdc..d9b0ebcb67d 100644
--- a/drivers/infiniband/hw/ehca/ehca_cq.c
+++ b/drivers/infiniband/hw/ehca/ehca_cq.c
@@ -43,6 +43,8 @@
43 * POSSIBILITY OF SUCH DAMAGE. 43 * POSSIBILITY OF SUCH DAMAGE.
44 */ 44 */
45 45
46#include <linux/slab.h>
47
46#include "ehca_iverbs.h" 48#include "ehca_iverbs.h"
47#include "ehca_classes.h" 49#include "ehca_classes.h"
48#include "ehca_irq.h" 50#include "ehca_irq.h"
diff --git a/drivers/infiniband/hw/ehca/ehca_hca.c b/drivers/infiniband/hw/ehca/ehca_hca.c
index 8b92f85d4dd..73edc366866 100644
--- a/drivers/infiniband/hw/ehca/ehca_hca.c
+++ b/drivers/infiniband/hw/ehca/ehca_hca.c
@@ -39,6 +39,8 @@
39 * POSSIBILITY OF SUCH DAMAGE. 39 * POSSIBILITY OF SUCH DAMAGE.
40 */ 40 */
41 41
42#include <linux/gfp.h>
43
42#include "ehca_tools.h" 44#include "ehca_tools.h"
43#include "ehca_iverbs.h" 45#include "ehca_iverbs.h"
44#include "hcp_if.h" 46#include "hcp_if.h"
diff --git a/drivers/infiniband/hw/ehca/ehca_irq.c b/drivers/infiniband/hw/ehca/ehca_irq.c
index b2b6fea2b14..07cae552caf 100644
--- a/drivers/infiniband/hw/ehca/ehca_irq.c
+++ b/drivers/infiniband/hw/ehca/ehca_irq.c
@@ -41,6 +41,8 @@
41 * POSSIBILITY OF SUCH DAMAGE. 41 * POSSIBILITY OF SUCH DAMAGE.
42 */ 42 */
43 43
44#include <linux/slab.h>
45
44#include "ehca_classes.h" 46#include "ehca_classes.h"
45#include "ehca_irq.h" 47#include "ehca_irq.h"
46#include "ehca_iverbs.h" 48#include "ehca_iverbs.h"
diff --git a/drivers/infiniband/hw/ehca/ehca_mrmw.c b/drivers/infiniband/hw/ehca/ehca_mrmw.c
index 7550a534005..31a68b9c52d 100644
--- a/drivers/infiniband/hw/ehca/ehca_mrmw.c
+++ b/drivers/infiniband/hw/ehca/ehca_mrmw.c
@@ -40,6 +40,7 @@
40 * POSSIBILITY OF SUCH DAMAGE. 40 * POSSIBILITY OF SUCH DAMAGE.
41 */ 41 */
42 42
43#include <linux/slab.h>
43#include <rdma/ib_umem.h> 44#include <rdma/ib_umem.h>
44 45
45#include "ehca_iverbs.h" 46#include "ehca_iverbs.h"
diff --git a/drivers/infiniband/hw/ehca/ehca_pd.c b/drivers/infiniband/hw/ehca/ehca_pd.c
index 2fe554855fa..351577a6670 100644
--- a/drivers/infiniband/hw/ehca/ehca_pd.c
+++ b/drivers/infiniband/hw/ehca/ehca_pd.c
@@ -38,6 +38,8 @@
38 * POSSIBILITY OF SUCH DAMAGE. 38 * POSSIBILITY OF SUCH DAMAGE.
39 */ 39 */
40 40
41#include <linux/slab.h>
42
41#include "ehca_tools.h" 43#include "ehca_tools.h"
42#include "ehca_iverbs.h" 44#include "ehca_iverbs.h"
43 45
diff --git a/drivers/infiniband/hw/ehca/ehca_qp.c b/drivers/infiniband/hw/ehca/ehca_qp.c
index b105f664d3e..47d388ec1cd 100644
--- a/drivers/infiniband/hw/ehca/ehca_qp.c
+++ b/drivers/infiniband/hw/ehca/ehca_qp.c
@@ -43,6 +43,8 @@
43 * POSSIBILITY OF SUCH DAMAGE. 43 * POSSIBILITY OF SUCH DAMAGE.
44 */ 44 */
45 45
46#include <linux/slab.h>
47
46#include "ehca_classes.h" 48#include "ehca_classes.h"
47#include "ehca_tools.h" 49#include "ehca_tools.h"
48#include "ehca_qes.h" 50#include "ehca_qes.h"
diff --git a/drivers/infiniband/hw/ehca/ehca_uverbs.c b/drivers/infiniband/hw/ehca/ehca_uverbs.c
index f1565cae8ec..45ee89b65c2 100644
--- a/drivers/infiniband/hw/ehca/ehca_uverbs.c
+++ b/drivers/infiniband/hw/ehca/ehca_uverbs.c
@@ -40,6 +40,8 @@
40 * POSSIBILITY OF SUCH DAMAGE. 40 * POSSIBILITY OF SUCH DAMAGE.
41 */ 41 */
42 42
43#include <linux/slab.h>
44
43#include "ehca_classes.h" 45#include "ehca_classes.h"
44#include "ehca_iverbs.h" 46#include "ehca_iverbs.h"
45#include "ehca_mrmw.h" 47#include "ehca_mrmw.h"
diff --git a/drivers/infiniband/hw/ehca/ipz_pt_fn.c b/drivers/infiniband/hw/ehca/ipz_pt_fn.c
index 1227c593627..1596e308534 100644
--- a/drivers/infiniband/hw/ehca/ipz_pt_fn.c
+++ b/drivers/infiniband/hw/ehca/ipz_pt_fn.c
@@ -38,6 +38,8 @@
38 * POSSIBILITY OF SUCH DAMAGE. 38 * POSSIBILITY OF SUCH DAMAGE.
39 */ 39 */
40 40
41#include <linux/slab.h>
42
41#include "ehca_tools.h" 43#include "ehca_tools.h"
42#include "ipz_pt_fn.h" 44#include "ipz_pt_fn.h"
43#include "ehca_classes.h" 45#include "ehca_classes.h"
diff --git a/drivers/infiniband/hw/ipath/ipath_cq.c b/drivers/infiniband/hw/ipath/ipath_cq.c
index d385e4168c9..0416c6c0e12 100644
--- a/drivers/infiniband/hw/ipath/ipath_cq.c
+++ b/drivers/infiniband/hw/ipath/ipath_cq.c
@@ -32,6 +32,7 @@
32 */ 32 */
33 33
34#include <linux/err.h> 34#include <linux/err.h>
35#include <linux/slab.h>
35#include <linux/vmalloc.h> 36#include <linux/vmalloc.h>
36 37
37#include "ipath_verbs.h" 38#include "ipath_verbs.h"
diff --git a/drivers/infiniband/hw/ipath/ipath_dma.c b/drivers/infiniband/hw/ipath/ipath_dma.c
index e90a0ea538a..644c2c74e05 100644
--- a/drivers/infiniband/hw/ipath/ipath_dma.c
+++ b/drivers/infiniband/hw/ipath/ipath_dma.c
@@ -31,6 +31,7 @@
31 */ 31 */
32 32
33#include <linux/scatterlist.h> 33#include <linux/scatterlist.h>
34#include <linux/gfp.h>
34#include <rdma/ib_verbs.h> 35#include <rdma/ib_verbs.h>
35 36
36#include "ipath_verbs.h" 37#include "ipath_verbs.h"
diff --git a/drivers/infiniband/hw/ipath/ipath_driver.c b/drivers/infiniband/hw/ipath/ipath_driver.c
index d2787fe8030..6302626d17f 100644
--- a/drivers/infiniband/hw/ipath/ipath_driver.c
+++ b/drivers/infiniband/hw/ipath/ipath_driver.c
@@ -40,6 +40,7 @@
40#include <linux/netdevice.h> 40#include <linux/netdevice.h>
41#include <linux/vmalloc.h> 41#include <linux/vmalloc.h>
42#include <linux/bitmap.h> 42#include <linux/bitmap.h>
43#include <linux/slab.h>
43 44
44#include "ipath_kernel.h" 45#include "ipath_kernel.h"
45#include "ipath_verbs.h" 46#include "ipath_verbs.h"
diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c
index 73933a41ce8..9c5c66d16a2 100644
--- a/drivers/infiniband/hw/ipath/ipath_file_ops.c
+++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c
@@ -36,6 +36,7 @@
36#include <linux/cdev.h> 36#include <linux/cdev.h>
37#include <linux/swap.h> 37#include <linux/swap.h>
38#include <linux/vmalloc.h> 38#include <linux/vmalloc.h>
39#include <linux/slab.h>
39#include <linux/highmem.h> 40#include <linux/highmem.h>
40#include <linux/io.h> 41#include <linux/io.h>
41#include <linux/jiffies.h> 42#include <linux/jiffies.h>
diff --git a/drivers/infiniband/hw/ipath/ipath_fs.c b/drivers/infiniband/hw/ipath/ipath_fs.c
index 100da8542bb..2fca70836da 100644
--- a/drivers/infiniband/hw/ipath/ipath_fs.c
+++ b/drivers/infiniband/hw/ipath/ipath_fs.c
@@ -37,6 +37,7 @@
37#include <linux/pagemap.h> 37#include <linux/pagemap.h>
38#include <linux/init.h> 38#include <linux/init.h>
39#include <linux/namei.h> 39#include <linux/namei.h>
40#include <linux/slab.h>
40 41
41#include "ipath_kernel.h" 42#include "ipath_kernel.h"
42 43
diff --git a/drivers/infiniband/hw/ipath/ipath_init_chip.c b/drivers/infiniband/hw/ipath/ipath_init_chip.c
index 077879c0bdb..776938299e4 100644
--- a/drivers/infiniband/hw/ipath/ipath_init_chip.c
+++ b/drivers/infiniband/hw/ipath/ipath_init_chip.c
@@ -33,6 +33,7 @@
33 33
34#include <linux/pci.h> 34#include <linux/pci.h>
35#include <linux/netdevice.h> 35#include <linux/netdevice.h>
36#include <linux/slab.h>
36#include <linux/vmalloc.h> 37#include <linux/vmalloc.h>
37 38
38#include "ipath_kernel.h" 39#include "ipath_kernel.h"
diff --git a/drivers/infiniband/hw/ipath/ipath_mmap.c b/drivers/infiniband/hw/ipath/ipath_mmap.c
index b28865faf43..e7327422940 100644
--- a/drivers/infiniband/hw/ipath/ipath_mmap.c
+++ b/drivers/infiniband/hw/ipath/ipath_mmap.c
@@ -32,6 +32,7 @@
32 32
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/vmalloc.h> 34#include <linux/vmalloc.h>
35#include <linux/slab.h>
35#include <linux/mm.h> 36#include <linux/mm.h>
36#include <linux/errno.h> 37#include <linux/errno.h>
37#include <asm/pgtable.h> 38#include <asm/pgtable.h>
diff --git a/drivers/infiniband/hw/ipath/ipath_mr.c b/drivers/infiniband/hw/ipath/ipath_mr.c
index 9d343b7c2f3..e346d3890a0 100644
--- a/drivers/infiniband/hw/ipath/ipath_mr.c
+++ b/drivers/infiniband/hw/ipath/ipath_mr.c
@@ -31,6 +31,8 @@
31 * SOFTWARE. 31 * SOFTWARE.
32 */ 32 */
33 33
34#include <linux/slab.h>
35
34#include <rdma/ib_umem.h> 36#include <rdma/ib_umem.h>
35#include <rdma/ib_pack.h> 37#include <rdma/ib_pack.h>
36#include <rdma/ib_smi.h> 38#include <rdma/ib_smi.h>
diff --git a/drivers/infiniband/hw/ipath/ipath_qp.c b/drivers/infiniband/hw/ipath/ipath_qp.c
index cb2d3ef2ae1..0857a9c3cd3 100644
--- a/drivers/infiniband/hw/ipath/ipath_qp.c
+++ b/drivers/infiniband/hw/ipath/ipath_qp.c
@@ -33,6 +33,7 @@
33 33
34#include <linux/err.h> 34#include <linux/err.h>
35#include <linux/sched.h> 35#include <linux/sched.h>
36#include <linux/slab.h>
36#include <linux/vmalloc.h> 37#include <linux/vmalloc.h>
37 38
38#include "ipath_verbs.h" 39#include "ipath_verbs.h"
diff --git a/drivers/infiniband/hw/ipath/ipath_sdma.c b/drivers/infiniband/hw/ipath/ipath_sdma.c
index 4b069859085..98ac18ec977 100644
--- a/drivers/infiniband/hw/ipath/ipath_sdma.c
+++ b/drivers/infiniband/hw/ipath/ipath_sdma.c
@@ -31,6 +31,7 @@
31 */ 31 */
32 32
33#include <linux/spinlock.h> 33#include <linux/spinlock.h>
34#include <linux/gfp.h>
34 35
35#include "ipath_kernel.h" 36#include "ipath_kernel.h"
36#include "ipath_verbs.h" 37#include "ipath_verbs.h"
diff --git a/drivers/infiniband/hw/ipath/ipath_srq.c b/drivers/infiniband/hw/ipath/ipath_srq.c
index e3d80ca84c1..386e2c717c5 100644
--- a/drivers/infiniband/hw/ipath/ipath_srq.c
+++ b/drivers/infiniband/hw/ipath/ipath_srq.c
@@ -32,6 +32,7 @@
32 */ 32 */
33 33
34#include <linux/err.h> 34#include <linux/err.h>
35#include <linux/slab.h>
35#include <linux/vmalloc.h> 36#include <linux/vmalloc.h>
36 37
37#include "ipath_verbs.h" 38#include "ipath_verbs.h"
diff --git a/drivers/infiniband/hw/ipath/ipath_user_pages.c b/drivers/infiniband/hw/ipath/ipath_user_pages.c
index eb7d59abd12..5e86d73eba2 100644
--- a/drivers/infiniband/hw/ipath/ipath_user_pages.c
+++ b/drivers/infiniband/hw/ipath/ipath_user_pages.c
@@ -33,6 +33,7 @@
33 33
34#include <linux/mm.h> 34#include <linux/mm.h>
35#include <linux/device.h> 35#include <linux/device.h>
36#include <linux/slab.h>
36#include <linux/sched.h> 37#include <linux/sched.h>
37 38
38#include "ipath_kernel.h" 39#include "ipath_kernel.h"
diff --git a/drivers/infiniband/hw/ipath/ipath_verbs.c b/drivers/infiniband/hw/ipath/ipath_verbs.c
index 9289ab4b0ae..559f39be0dc 100644
--- a/drivers/infiniband/hw/ipath/ipath_verbs.c
+++ b/drivers/infiniband/hw/ipath/ipath_verbs.c
@@ -34,6 +34,7 @@
34#include <rdma/ib_mad.h> 34#include <rdma/ib_mad.h>
35#include <rdma/ib_user_verbs.h> 35#include <rdma/ib_user_verbs.h>
36#include <linux/io.h> 36#include <linux/io.h>
37#include <linux/slab.h>
37#include <linux/utsname.h> 38#include <linux/utsname.h>
38#include <linux/rculist.h> 39#include <linux/rculist.h>
39 40
diff --git a/drivers/infiniband/hw/ipath/ipath_verbs_mcast.c b/drivers/infiniband/hw/ipath/ipath_verbs_mcast.c
index 6923e1d986d..6216ea92385 100644
--- a/drivers/infiniband/hw/ipath/ipath_verbs_mcast.c
+++ b/drivers/infiniband/hw/ipath/ipath_verbs_mcast.c
@@ -33,6 +33,7 @@
33 33
34#include <linux/rculist.h> 34#include <linux/rculist.h>
35#include <linux/sched.h> 35#include <linux/sched.h>
36#include <linux/slab.h>
36 37
37#include "ipath_verbs.h" 38#include "ipath_verbs.h"
38 39
diff --git a/drivers/infiniband/hw/mlx4/ah.c b/drivers/infiniband/hw/mlx4/ah.c
index c75ac9463e2..11a236f8d88 100644
--- a/drivers/infiniband/hw/mlx4/ah.c
+++ b/drivers/infiniband/hw/mlx4/ah.c
@@ -30,6 +30,8 @@
30 * SOFTWARE. 30 * SOFTWARE.
31 */ 31 */
32 32
33#include <linux/slab.h>
34
33#include "mlx4_ib.h" 35#include "mlx4_ib.h"
34 36
35struct ib_ah *mlx4_ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr) 37struct ib_ah *mlx4_ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
index de5263beab4..cc2ddd29ac5 100644
--- a/drivers/infiniband/hw/mlx4/cq.c
+++ b/drivers/infiniband/hw/mlx4/cq.c
@@ -33,6 +33,7 @@
33 33
34#include <linux/mlx4/cq.h> 34#include <linux/mlx4/cq.h>
35#include <linux/mlx4/qp.h> 35#include <linux/mlx4/qp.h>
36#include <linux/slab.h>
36 37
37#include "mlx4_ib.h" 38#include "mlx4_ib.h"
38#include "user.h" 39#include "user.h"
diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 19e68ab6616..f38d5b11892 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -34,6 +34,7 @@
34#include <rdma/ib_smi.h> 34#include <rdma/ib_smi.h>
35 35
36#include <linux/mlx4/cmd.h> 36#include <linux/mlx4/cmd.h>
37#include <linux/gfp.h>
37 38
38#include "mlx4_ib.h" 39#include "mlx4_ib.h"
39 40
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index e596537ff35..01f2a3f9335 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -33,6 +33,7 @@
33 33
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/slab.h>
36#include <linux/errno.h> 37#include <linux/errno.h>
37 38
38#include <rdma/ib_smi.h> 39#include <rdma/ib_smi.h>
diff --git a/drivers/infiniband/hw/mlx4/mr.c b/drivers/infiniband/hw/mlx4/mr.c
index 8f3666b20ea..1d27b9a8e2d 100644
--- a/drivers/infiniband/hw/mlx4/mr.c
+++ b/drivers/infiniband/hw/mlx4/mr.c
@@ -31,6 +31,8 @@
31 * SOFTWARE. 31 * SOFTWARE.
32 */ 32 */
33 33
34#include <linux/slab.h>
35
34#include "mlx4_ib.h" 36#include "mlx4_ib.h"
35 37
36static u32 convert_access(int acc) 38static u32 convert_access(int acc)
@@ -238,7 +240,7 @@ struct ib_fast_reg_page_list *mlx4_ib_alloc_fast_reg_page_list(struct ib_device
238 mfrpl->mapped_page_list = dma_alloc_coherent(&dev->dev->pdev->dev, 240 mfrpl->mapped_page_list = dma_alloc_coherent(&dev->dev->pdev->dev,
239 size, &mfrpl->map, 241 size, &mfrpl->map,
240 GFP_KERNEL); 242 GFP_KERNEL);
241 if (!mfrpl->ibfrpl.page_list) 243 if (!mfrpl->mapped_page_list)
242 goto err_free; 244 goto err_free;
243 245
244 WARN_ON(mfrpl->map & 0x3f); 246 WARN_ON(mfrpl->map & 0x3f);
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index ae75389937d..5643f4a8ffe 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -32,6 +32,7 @@
32 */ 32 */
33 33
34#include <linux/log2.h> 34#include <linux/log2.h>
35#include <linux/slab.h>
35 36
36#include <rdma/ib_cache.h> 37#include <rdma/ib_cache.h>
37#include <rdma/ib_pack.h> 38#include <rdma/ib_pack.h>
diff --git a/drivers/infiniband/hw/mlx4/srq.c b/drivers/infiniband/hw/mlx4/srq.c
index cf8085bcbd6..818b7ecace5 100644
--- a/drivers/infiniband/hw/mlx4/srq.c
+++ b/drivers/infiniband/hw/mlx4/srq.c
@@ -33,6 +33,7 @@
33 33
34#include <linux/mlx4/qp.h> 34#include <linux/mlx4/qp.h>
35#include <linux/mlx4/srq.h> 35#include <linux/mlx4/srq.h>
36#include <linux/slab.h>
36 37
37#include "mlx4_ib.h" 38#include "mlx4_ib.h"
38#include "user.h" 39#include "user.h"
diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
index 8c2ed994d54..3603ae89b60 100644
--- a/drivers/infiniband/hw/mthca/mthca_cmd.c
+++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
@@ -36,6 +36,7 @@
36#include <linux/pci.h> 36#include <linux/pci.h>
37#include <linux/errno.h> 37#include <linux/errno.h>
38#include <linux/sched.h> 38#include <linux/sched.h>
39#include <linux/slab.h>
39#include <asm/io.h> 40#include <asm/io.h>
40#include <rdma/ib_mad.h> 41#include <rdma/ib_mad.h>
41 42
diff --git a/drivers/infiniband/hw/mthca/mthca_cq.c b/drivers/infiniband/hw/mthca/mthca_cq.c
index d9f4735c2b3..18ee3fa4b88 100644
--- a/drivers/infiniband/hw/mthca/mthca_cq.c
+++ b/drivers/infiniband/hw/mthca/mthca_cq.c
@@ -34,6 +34,7 @@
34 * SOFTWARE. 34 * SOFTWARE.
35 */ 35 */
36 36
37#include <linux/gfp.h>
37#include <linux/hardirq.h> 38#include <linux/hardirq.h>
38#include <linux/sched.h> 39#include <linux/sched.h>
39 40
diff --git a/drivers/infiniband/hw/mthca/mthca_eq.c b/drivers/infiniband/hw/mthca/mthca_eq.c
index 8c31fa36e95..9388164b605 100644
--- a/drivers/infiniband/hw/mthca/mthca_eq.c
+++ b/drivers/infiniband/hw/mthca/mthca_eq.c
@@ -34,6 +34,7 @@
34#include <linux/errno.h> 34#include <linux/errno.h>
35#include <linux/interrupt.h> 35#include <linux/interrupt.h>
36#include <linux/pci.h> 36#include <linux/pci.h>
37#include <linux/slab.h>
37 38
38#include "mthca_dev.h" 39#include "mthca_dev.h"
39#include "mthca_cmd.h" 40#include "mthca_cmd.h"
diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
index b01b2898787..5eee6665919 100644
--- a/drivers/infiniband/hw/mthca/mthca_main.c
+++ b/drivers/infiniband/hw/mthca/mthca_main.c
@@ -37,6 +37,7 @@
37#include <linux/errno.h> 37#include <linux/errno.h>
38#include <linux/pci.h> 38#include <linux/pci.h>
39#include <linux/interrupt.h> 39#include <linux/interrupt.h>
40#include <linux/gfp.h>
40 41
41#include "mthca_dev.h" 42#include "mthca_dev.h"
42#include "mthca_config_reg.h" 43#include "mthca_config_reg.h"
diff --git a/drivers/infiniband/hw/mthca/mthca_mcg.c b/drivers/infiniband/hw/mthca/mthca_mcg.c
index d4c81053e43..515790a606e 100644
--- a/drivers/infiniband/hw/mthca/mthca_mcg.c
+++ b/drivers/infiniband/hw/mthca/mthca_mcg.c
@@ -31,7 +31,7 @@
31 */ 31 */
32 32
33#include <linux/string.h> 33#include <linux/string.h>
34#include <linux/slab.h> 34#include <linux/gfp.h>
35 35
36#include "mthca_dev.h" 36#include "mthca_dev.h"
37#include "mthca_cmd.h" 37#include "mthca_cmd.h"
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c
index 1f7d1a29d2a..8c2a83732b5 100644
--- a/drivers/infiniband/hw/mthca/mthca_memfree.c
+++ b/drivers/infiniband/hw/mthca/mthca_memfree.c
@@ -35,6 +35,7 @@
35#include <linux/mm.h> 35#include <linux/mm.h>
36#include <linux/scatterlist.h> 36#include <linux/scatterlist.h>
37#include <linux/sched.h> 37#include <linux/sched.h>
38#include <linux/slab.h>
38 39
39#include <asm/page.h> 40#include <asm/page.h>
40 41
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
index bcf7a401482..f080a784bc7 100644
--- a/drivers/infiniband/hw/mthca/mthca_provider.c
+++ b/drivers/infiniband/hw/mthca/mthca_provider.c
@@ -39,6 +39,7 @@
39#include <rdma/ib_user_verbs.h> 39#include <rdma/ib_user_verbs.h>
40 40
41#include <linux/sched.h> 41#include <linux/sched.h>
42#include <linux/slab.h>
42#include <linux/mm.h> 43#include <linux/mm.h>
43 44
44#include "mthca_dev.h" 45#include "mthca_dev.h"
diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
index 4272c52e38a..de7b9d7166f 100644
--- a/drivers/infiniband/hw/nes/nes.c
+++ b/drivers/infiniband/hw/nes/nes.c
@@ -44,6 +44,7 @@
44#include <linux/init.h> 44#include <linux/init.h>
45#include <linux/if_arp.h> 45#include <linux/if_arp.h>
46#include <linux/highmem.h> 46#include <linux/highmem.h>
47#include <linux/slab.h>
47#include <asm/io.h> 48#include <asm/io.h>
48#include <asm/irq.h> 49#include <asm/irq.h>
49#include <asm/byteorder.h> 50#include <asm/byteorder.h>
diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
index 2a49ee40b52..986d6f32dde 100644
--- a/drivers/infiniband/hw/nes/nes_cm.c
+++ b/drivers/infiniband/hw/nes/nes_cm.c
@@ -53,6 +53,7 @@
53#include <linux/list.h> 53#include <linux/list.h>
54#include <linux/threads.h> 54#include <linux/threads.h>
55#include <linux/highmem.h> 55#include <linux/highmem.h>
56#include <linux/slab.h>
56#include <net/arp.h> 57#include <net/arp.h>
57#include <net/neighbour.h> 58#include <net/neighbour.h>
58#include <net/route.h> 59#include <net/route.h>
diff --git a/drivers/infiniband/hw/nes/nes_hw.c b/drivers/infiniband/hw/nes/nes_hw.c
index 925075557dc..c36a3f51492 100644
--- a/drivers/infiniband/hw/nes/nes_hw.c
+++ b/drivers/infiniband/hw/nes/nes_hw.c
@@ -39,6 +39,7 @@
39#include <linux/tcp.h> 39#include <linux/tcp.h>
40#include <linux/if_vlan.h> 40#include <linux/if_vlan.h>
41#include <linux/inet_lro.h> 41#include <linux/inet_lro.h>
42#include <linux/slab.h>
42 43
43#include "nes.h" 44#include "nes.h"
44 45
diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
index 91fdde382e8..b7c813f4be4 100644
--- a/drivers/infiniband/hw/nes/nes_nic.c
+++ b/drivers/infiniband/hw/nes/nes_nic.c
@@ -40,6 +40,7 @@
40#include <linux/if_arp.h> 40#include <linux/if_arp.h>
41#include <linux/if_vlan.h> 41#include <linux/if_vlan.h>
42#include <linux/ethtool.h> 42#include <linux/ethtool.h>
43#include <linux/slab.h>
43#include <net/tcp.h> 44#include <net/tcp.h>
44 45
45#include <net/inet_common.h> 46#include <net/inet_common.h>
diff --git a/drivers/infiniband/hw/nes/nes_utils.c b/drivers/infiniband/hw/nes/nes_utils.c
index 729d525c5b7..186623d8695 100644
--- a/drivers/infiniband/hw/nes/nes_utils.c
+++ b/drivers/infiniband/hw/nes/nes_utils.c
@@ -38,6 +38,7 @@
38#include <linux/ethtool.h> 38#include <linux/ethtool.h>
39#include <linux/mii.h> 39#include <linux/mii.h>
40#include <linux/if_vlan.h> 40#include <linux/if_vlan.h>
41#include <linux/slab.h>
41#include <linux/crc32.h> 42#include <linux/crc32.h>
42#include <linux/in.h> 43#include <linux/in.h>
43#include <linux/ip.h> 44#include <linux/ip.h>
diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
index 69928296d74..e54f312e4bd 100644
--- a/drivers/infiniband/hw/nes/nes_verbs.c
+++ b/drivers/infiniband/hw/nes/nes_verbs.c
@@ -35,6 +35,7 @@
35#include <linux/moduleparam.h> 35#include <linux/moduleparam.h>
36#include <linux/random.h> 36#include <linux/random.h>
37#include <linux/highmem.h> 37#include <linux/highmem.h>
38#include <linux/slab.h>
38#include <asm/byteorder.h> 39#include <asm/byteorder.h>
39 40
40#include <rdma/ib_verbs.h> 41#include <rdma/ib_verbs.h>
@@ -2820,11 +2821,10 @@ static int nes_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
2820 attr->cap.max_send_wr = nesqp->hwqp.sq_size; 2821 attr->cap.max_send_wr = nesqp->hwqp.sq_size;
2821 attr->cap.max_recv_wr = nesqp->hwqp.rq_size; 2822 attr->cap.max_recv_wr = nesqp->hwqp.rq_size;
2822 attr->cap.max_recv_sge = 1; 2823 attr->cap.max_recv_sge = 1;
2823 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) { 2824 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA)
2824 init_attr->cap.max_inline_data = 0; 2825 attr->cap.max_inline_data = 0;
2825 } else { 2826 else
2826 init_attr->cap.max_inline_data = 64; 2827 attr->cap.max_inline_data = 64;
2827 }
2828 2828
2829 init_attr->event_handler = nesqp->ibqp.event_handler; 2829 init_attr->event_handler = nesqp->ibqp.event_handler;
2830 init_attr->qp_context = nesqp->ibqp.qp_context; 2830 init_attr->qp_context = nesqp->ibqp.qp_context;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
index bc658373ad5..bb1004114de 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
@@ -35,6 +35,7 @@
35#include <net/icmp.h> 35#include <net/icmp.h>
36#include <linux/icmpv6.h> 36#include <linux/icmpv6.h>
37#include <linux/delay.h> 37#include <linux/delay.h>
38#include <linux/slab.h>
38#include <linux/vmalloc.h> 39#include <linux/vmalloc.h>
39 40
40#include "ipoib.h" 41#include "ipoib.h"
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_fs.c b/drivers/infiniband/ulp/ipoib/ipoib_fs.c
index 961c585da21..86eae229dc4 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_fs.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_fs.c
@@ -32,6 +32,7 @@
32 32
33#include <linux/err.h> 33#include <linux/err.h>
34#include <linux/seq_file.h> 34#include <linux/seq_file.h>
35#include <linux/slab.h>
35 36
36struct file_operations; 37struct file_operations;
37 38
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
index 5df40b128f8..ec6b4fbe25e 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
@@ -35,6 +35,7 @@
35 35
36#include <linux/delay.h> 36#include <linux/delay.h>
37#include <linux/dma-mapping.h> 37#include <linux/dma-mapping.h>
38#include <linux/slab.h>
38 39
39#include <linux/ip.h> 40#include <linux/ip.h>
40#include <linux/tcp.h> 41#include <linux/tcp.h>
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
index d41ea27be5e..b166bb75753 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
@@ -40,6 +40,7 @@
40#include <linux/inetdevice.h> 40#include <linux/inetdevice.h>
41#include <linux/delay.h> 41#include <linux/delay.h>
42#include <linux/completion.h> 42#include <linux/completion.h>
43#include <linux/slab.h>
43 44
44#include <net/dst.h> 45#include <net/dst.h>
45 46
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
index 68325119f74..049a997caff 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
@@ -31,6 +31,8 @@
31 * SOFTWARE. 31 * SOFTWARE.
32 */ 32 */
33 33
34#include <linux/slab.h>
35
34#include "ipoib.h" 36#include "ipoib.h"
35 37
36int ipoib_mcast_attach(struct net_device *dev, u16 mlid, union ib_gid *mgid, int set_qkey) 38int ipoib_mcast_attach(struct net_device *dev, u16 mlid, union ib_gid *mgid, int set_qkey)
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
index e3bf00d8cd2..d7e9740c724 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
@@ -33,7 +33,6 @@
33#include <linux/module.h> 33#include <linux/module.h>
34 34
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/slab.h>
37#include <linux/seq_file.h> 36#include <linux/seq_file.h>
38 37
39#include <asm/uaccess.h> 38#include <asm/uaccess.h>
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c
index e78af36d3a0..93399dff0c6 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.c
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.c
@@ -56,6 +56,7 @@
56#include <linux/net.h> 56#include <linux/net.h>
57#include <linux/scatterlist.h> 57#include <linux/scatterlist.h>
58#include <linux/delay.h> 58#include <linux/delay.h>
59#include <linux/slab.h>
59 60
60#include <net/sock.h> 61#include <net/sock.h>
61 62
diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c
index 308d17bb514..b89d76b39a1 100644
--- a/drivers/infiniband/ulp/iser/iser_verbs.c
+++ b/drivers/infiniband/ulp/iser/iser_verbs.c
@@ -32,6 +32,7 @@
32 */ 32 */
33#include <linux/kernel.h> 33#include <linux/kernel.h>
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/slab.h>
35#include <linux/delay.h> 36#include <linux/delay.h>
36 37
37#include "iscsi_iser.h" 38#include "iscsi_iser.h"
diff --git a/drivers/input/ff-core.c b/drivers/input/ff-core.c
index b2f07aa1604..03078c08309 100644
--- a/drivers/input/ff-core.c
+++ b/drivers/input/ff-core.c
@@ -29,6 +29,7 @@
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/mutex.h> 30#include <linux/mutex.h>
31#include <linux/sched.h> 31#include <linux/sched.h>
32#include <linux/slab.h>
32 33
33/* 34/*
34 * Check that the effect_id is a valid effect and whether the user 35 * Check that the effect_id is a valid effect and whether the user
diff --git a/drivers/input/ff-memless.c b/drivers/input/ff-memless.c
index f967008f332..1d881c96ba8 100644
--- a/drivers/input/ff-memless.c
+++ b/drivers/input/ff-memless.c
@@ -25,6 +25,7 @@
25 25
26#define debug(format, arg...) pr_debug("ff-memless: " format "\n", ## arg) 26#define debug(format, arg...) pr_debug("ff-memless: " format "\n", ## arg)
27 27
28#include <linux/slab.h>
28#include <linux/input.h> 29#include <linux/input.h>
29#include <linux/module.h> 30#include <linux/module.h>
30#include <linux/mutex.h> 31#include <linux/mutex.h>
diff --git a/drivers/input/gameport/lightning.c b/drivers/input/gameport/lightning.c
index 06ad36ed348..85d6ee09f11 100644
--- a/drivers/input/gameport/lightning.c
+++ b/drivers/input/gameport/lightning.c
@@ -34,7 +34,6 @@
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/gameport.h> 36#include <linux/gameport.h>
37#include <linux/slab.h>
38 37
39#define L4_PORT 0x201 38#define L4_PORT 0x201
40#define L4_SELECT_ANALOG 0xa4 39#define L4_SELECT_ANALOG 0xa4
diff --git a/drivers/input/input-polldev.c b/drivers/input/input-polldev.c
index 291d9393d35..10c9b0a845f 100644
--- a/drivers/input/input-polldev.c
+++ b/drivers/input/input-polldev.c
@@ -9,6 +9,7 @@
9 */ 9 */
10 10
11#include <linux/jiffies.h> 11#include <linux/jiffies.h>
12#include <linux/slab.h>
12#include <linux/mutex.h> 13#include <linux/mutex.h>
13#include <linux/input-polldev.h> 14#include <linux/input-polldev.h>
14 15
diff --git a/drivers/input/input.c b/drivers/input/input.c
index e2aad0a5182..9c79bd56b51 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -14,6 +14,7 @@
14#include <linux/types.h> 14#include <linux/types.h>
15#include <linux/input.h> 15#include <linux/input.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/slab.h>
17#include <linux/random.h> 18#include <linux/random.h>
18#include <linux/major.h> 19#include <linux/major.h>
19#include <linux/proc_fs.h> 20#include <linux/proc_fs.h>
@@ -659,7 +660,14 @@ static int input_default_setkeycode(struct input_dev *dev,
659int input_get_keycode(struct input_dev *dev, 660int input_get_keycode(struct input_dev *dev,
660 unsigned int scancode, unsigned int *keycode) 661 unsigned int scancode, unsigned int *keycode)
661{ 662{
662 return dev->getkeycode(dev, scancode, keycode); 663 unsigned long flags;
664 int retval;
665
666 spin_lock_irqsave(&dev->event_lock, flags);
667 retval = dev->getkeycode(dev, scancode, keycode);
668 spin_unlock_irqrestore(&dev->event_lock, flags);
669
670 return retval;
663} 671}
664EXPORT_SYMBOL(input_get_keycode); 672EXPORT_SYMBOL(input_get_keycode);
665 673
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index c52bec4d053..423e0e6031a 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -929,6 +929,24 @@ static const struct input_device_id joydev_ids[] = {
929 .evbit = { BIT_MASK(EV_ABS) }, 929 .evbit = { BIT_MASK(EV_ABS) },
930 .absbit = { BIT_MASK(ABS_THROTTLE) }, 930 .absbit = { BIT_MASK(ABS_THROTTLE) },
931 }, 931 },
932 {
933 .flags = INPUT_DEVICE_ID_MATCH_EVBIT |
934 INPUT_DEVICE_ID_MATCH_KEYBIT,
935 .evbit = { BIT_MASK(EV_KEY) },
936 .keybit = {[BIT_WORD(BTN_JOYSTICK)] = BIT_MASK(BTN_JOYSTICK) },
937 },
938 {
939 .flags = INPUT_DEVICE_ID_MATCH_EVBIT |
940 INPUT_DEVICE_ID_MATCH_KEYBIT,
941 .evbit = { BIT_MASK(EV_KEY) },
942 .keybit = { [BIT_WORD(BTN_GAMEPAD)] = BIT_MASK(BTN_GAMEPAD) },
943 },
944 {
945 .flags = INPUT_DEVICE_ID_MATCH_EVBIT |
946 INPUT_DEVICE_ID_MATCH_KEYBIT,
947 .evbit = { BIT_MASK(EV_KEY) },
948 .keybit = { [BIT_WORD(BTN_TRIGGER_HAPPY)] = BIT_MASK(BTN_TRIGGER_HAPPY) },
949 },
932 { } /* Terminating entry */ 950 { } /* Terminating entry */
933}; 951};
934 952
diff --git a/drivers/input/joystick/db9.c b/drivers/input/joystick/db9.c
index 52395948475..8e7de5c7754 100644
--- a/drivers/input/joystick/db9.c
+++ b/drivers/input/joystick/db9.c
@@ -36,6 +36,7 @@
36#include <linux/parport.h> 36#include <linux/parport.h>
37#include <linux/input.h> 37#include <linux/input.h>
38#include <linux/mutex.h> 38#include <linux/mutex.h>
39#include <linux/slab.h>
39 40
40MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); 41MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
41MODULE_DESCRIPTION("Atari, Amstrad, Commodore, Amiga, Sega, etc. joystick driver"); 42MODULE_DESCRIPTION("Atari, Amstrad, Commodore, Amiga, Sega, etc. joystick driver");
diff --git a/drivers/input/joystick/gamecon.c b/drivers/input/joystick/gamecon.c
index 7a55714a148..fbd62abb66f 100644
--- a/drivers/input/joystick/gamecon.c
+++ b/drivers/input/joystick/gamecon.c
@@ -39,6 +39,7 @@
39#include <linux/parport.h> 39#include <linux/parport.h>
40#include <linux/input.h> 40#include <linux/input.h>
41#include <linux/mutex.h> 41#include <linux/mutex.h>
42#include <linux/slab.h>
42 43
43MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); 44MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
44MODULE_DESCRIPTION("NES, SNES, N64, MultiSystem, PSX gamepad driver"); 45MODULE_DESCRIPTION("NES, SNES, N64, MultiSystem, PSX gamepad driver");
diff --git a/drivers/input/joystick/turbografx.c b/drivers/input/joystick/turbografx.c
index b6f85986954..d53b9e90023 100644
--- a/drivers/input/joystick/turbografx.c
+++ b/drivers/input/joystick/turbografx.c
@@ -35,6 +35,7 @@
35#include <linux/module.h> 35#include <linux/module.h>
36#include <linux/init.h> 36#include <linux/init.h>
37#include <linux/mutex.h> 37#include <linux/mutex.h>
38#include <linux/slab.h>
38 39
39MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); 40MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
40MODULE_DESCRIPTION("TurboGraFX parallel port interface driver"); 41MODULE_DESCRIPTION("TurboGraFX parallel port interface driver");
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index 64c102355f5..a8293388d01 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -143,19 +143,6 @@ config KEYBOARD_BFIN
143 To compile this driver as a module, choose M here: the 143 To compile this driver as a module, choose M here: the
144 module will be called bf54x-keys. 144 module will be called bf54x-keys.
145 145
146config KEYBOARD_CORGI
147 tristate "Corgi keyboard (deprecated)"
148 depends on PXA_SHARPSL
149 help
150 Say Y here to enable the keyboard on the Sharp Zaurus SL-C7xx
151 series of PDAs.
152
153 This driver is now deprecated, use generic GPIO based matrix
154 keyboard driver instead.
155
156 To compile this driver as a module, choose M here: the
157 module will be called corgikbd.
158
159config KEYBOARD_LKKBD 146config KEYBOARD_LKKBD
160 tristate "DECstation/VAXstation LK201/LK401 keyboard" 147 tristate "DECstation/VAXstation LK201/LK401 keyboard"
161 select SERIO 148 select SERIO
@@ -339,19 +326,6 @@ config KEYBOARD_PXA930_ROTARY
339 To compile this driver as a module, choose M here: the 326 To compile this driver as a module, choose M here: the
340 module will be called pxa930_rotary. 327 module will be called pxa930_rotary.
341 328
342config KEYBOARD_SPITZ
343 tristate "Spitz keyboard (deprecated)"
344 depends on PXA_SHARPSL
345 help
346 Say Y here to enable the keyboard on the Sharp Zaurus SL-C1000,
347 SL-C3000 and Sl-C3100 series of PDAs.
348
349 This driver is now deprecated, use generic GPIO based matrix
350 keyboard driver instead.
351
352 To compile this driver as a module, choose M here: the
353 module will be called spitzkbd.
354
355config KEYBOARD_STOWAWAY 329config KEYBOARD_STOWAWAY
356 tristate "Stowaway keyboard" 330 tristate "Stowaway keyboard"
357 select SERIO 331 select SERIO
@@ -414,28 +388,6 @@ config KEYBOARD_TWL4030
414 To compile this driver as a module, choose M here: the 388 To compile this driver as a module, choose M here: the
415 module will be called twl4030_keypad. 389 module will be called twl4030_keypad.
416 390
417config KEYBOARD_TOSA
418 tristate "Tosa keyboard (deprecated)"
419 depends on MACH_TOSA
420 help
421 Say Y here to enable the keyboard on the Sharp Zaurus SL-6000x (Tosa)
422
423 This driver is now deprecated, use generic GPIO based matrix
424 keyboard driver instead.
425
426 To compile this driver as a module, choose M here: the
427 module will be called tosakbd.
428
429config KEYBOARD_TOSA_USE_EXT_KEYCODES
430 bool "Tosa keyboard: use extended keycodes"
431 depends on KEYBOARD_TOSA
432 help
433 Say Y here to enable the tosa keyboard driver to generate extended
434 (>= 127) keycodes. Be aware, that they can't be correctly interpreted
435 by either console keyboard driver or by Kdrive keybd driver.
436
437 Say Y only if you know, what you are doing!
438
439config KEYBOARD_XTKBD 391config KEYBOARD_XTKBD
440 tristate "XT keyboard" 392 tristate "XT keyboard"
441 select SERIO 393 select SERIO
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 706c6b5ed5f..9a74127e4d1 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -11,7 +11,6 @@ obj-$(CONFIG_KEYBOARD_AMIGA) += amikbd.o
11obj-$(CONFIG_KEYBOARD_ATARI) += atakbd.o 11obj-$(CONFIG_KEYBOARD_ATARI) += atakbd.o
12obj-$(CONFIG_KEYBOARD_ATKBD) += atkbd.o 12obj-$(CONFIG_KEYBOARD_ATKBD) += atkbd.o
13obj-$(CONFIG_KEYBOARD_BFIN) += bf54x-keys.o 13obj-$(CONFIG_KEYBOARD_BFIN) += bf54x-keys.o
14obj-$(CONFIG_KEYBOARD_CORGI) += corgikbd.o
15obj-$(CONFIG_KEYBOARD_DAVINCI) += davinci_keyscan.o 14obj-$(CONFIG_KEYBOARD_DAVINCI) += davinci_keyscan.o
16obj-$(CONFIG_KEYBOARD_EP93XX) += ep93xx_keypad.o 15obj-$(CONFIG_KEYBOARD_EP93XX) += ep93xx_keypad.o
17obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o 16obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o
@@ -33,10 +32,8 @@ obj-$(CONFIG_KEYBOARD_PXA27x) += pxa27x_keypad.o
33obj-$(CONFIG_KEYBOARD_PXA930_ROTARY) += pxa930_rotary.o 32obj-$(CONFIG_KEYBOARD_PXA930_ROTARY) += pxa930_rotary.o
34obj-$(CONFIG_KEYBOARD_QT2160) += qt2160.o 33obj-$(CONFIG_KEYBOARD_QT2160) += qt2160.o
35obj-$(CONFIG_KEYBOARD_SH_KEYSC) += sh_keysc.o 34obj-$(CONFIG_KEYBOARD_SH_KEYSC) += sh_keysc.o
36obj-$(CONFIG_KEYBOARD_SPITZ) += spitzkbd.o
37obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o 35obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o
38obj-$(CONFIG_KEYBOARD_SUNKBD) += sunkbd.o 36obj-$(CONFIG_KEYBOARD_SUNKBD) += sunkbd.o
39obj-$(CONFIG_KEYBOARD_TOSA) += tosakbd.o
40obj-$(CONFIG_KEYBOARD_TWL4030) += twl4030_keypad.o 37obj-$(CONFIG_KEYBOARD_TWL4030) += twl4030_keypad.o
41obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o 38obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o
42obj-$(CONFIG_KEYBOARD_W90P910) += w90p910_keypad.o 39obj-$(CONFIG_KEYBOARD_W90P910) += w90p910_keypad.o
diff --git a/drivers/input/keyboard/adp5520-keys.c b/drivers/input/keyboard/adp5520-keys.c
index a7ba27fb410..3db8006dac3 100644
--- a/drivers/input/keyboard/adp5520-keys.c
+++ b/drivers/input/keyboard/adp5520-keys.c
@@ -12,6 +12,7 @@
12#include <linux/platform_device.h> 12#include <linux/platform_device.h>
13#include <linux/input.h> 13#include <linux/input.h>
14#include <linux/mfd/adp5520.h> 14#include <linux/mfd/adp5520.h>
15#include <linux/slab.h>
15 16
16struct adp5520_keys { 17struct adp5520_keys {
17 struct input_dev *input; 18 struct input_dev *input;
diff --git a/drivers/input/keyboard/adp5588-keys.c b/drivers/input/keyboard/adp5588-keys.c
index b5142d2d511..4771ab172b5 100644
--- a/drivers/input/keyboard/adp5588-keys.c
+++ b/drivers/input/keyboard/adp5588-keys.c
@@ -19,6 +19,7 @@
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/input.h> 20#include <linux/input.h>
21#include <linux/i2c.h> 21#include <linux/i2c.h>
22#include <linux/slab.h>
22 23
23#include <linux/i2c/adp5588.h> 24#include <linux/i2c/adp5588.h>
24 25
diff --git a/drivers/input/keyboard/bf54x-keys.c b/drivers/input/keyboard/bf54x-keys.c
index 593c052416b..7d989603f87 100644
--- a/drivers/input/keyboard/bf54x-keys.c
+++ b/drivers/input/keyboard/bf54x-keys.c
@@ -34,6 +34,7 @@
34#include <linux/fs.h> 34#include <linux/fs.h>
35#include <linux/interrupt.h> 35#include <linux/interrupt.h>
36#include <linux/irq.h> 36#include <linux/irq.h>
37#include <linux/slab.h>
37#include <linux/sched.h> 38#include <linux/sched.h>
38#include <linux/pm.h> 39#include <linux/pm.h>
39#include <linux/sysctl.h> 40#include <linux/sysctl.h>
diff --git a/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c
deleted file mode 100644
index 634af6a8e6b..00000000000
--- a/drivers/input/keyboard/corgikbd.c
+++ /dev/null
@@ -1,414 +0,0 @@
1/*
2 * Keyboard driver for Sharp Corgi models (SL-C7xx)
3 *
4 * Copyright (c) 2004-2005 Richard Purdie
5 *
6 * Based on xtkbd.c/locomkbd.c
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 */
13
14#include <linux/delay.h>
15#include <linux/platform_device.h>
16#include <linux/init.h>
17#include <linux/input.h>
18#include <linux/interrupt.h>
19#include <linux/jiffies.h>
20#include <linux/module.h>
21#include <linux/slab.h>
22
23#include <mach/corgi.h>
24#include <mach/pxa2xx-gpio.h>
25#include <asm/hardware/scoop.h>
26
27#define KB_ROWS 8
28#define KB_COLS 12
29#define KB_ROWMASK(r) (1 << (r))
30#define SCANCODE(r,c) ( ((r)<<4) + (c) + 1 )
31/* zero code, 124 scancodes */
32#define NR_SCANCODES ( SCANCODE(KB_ROWS-1,KB_COLS-1) +1 +1 )
33
34#define SCAN_INTERVAL (50) /* ms */
35#define HINGE_SCAN_INTERVAL (250) /* ms */
36
37#define CORGI_KEY_CALENDER KEY_F1
38#define CORGI_KEY_ADDRESS KEY_F2
39#define CORGI_KEY_FN KEY_F3
40#define CORGI_KEY_CANCEL KEY_F4
41#define CORGI_KEY_OFF KEY_SUSPEND
42#define CORGI_KEY_EXOK KEY_F5
43#define CORGI_KEY_EXCANCEL KEY_F6
44#define CORGI_KEY_EXJOGDOWN KEY_F7
45#define CORGI_KEY_EXJOGUP KEY_F8
46#define CORGI_KEY_JAP1 KEY_LEFTCTRL
47#define CORGI_KEY_JAP2 KEY_LEFTALT
48#define CORGI_KEY_MAIL KEY_F10
49#define CORGI_KEY_OK KEY_F11
50#define CORGI_KEY_MENU KEY_F12
51
52static unsigned char corgikbd_keycode[NR_SCANCODES] = {
53 0, /* 0 */
54 0, KEY_1, KEY_3, KEY_5, KEY_6, KEY_7, KEY_9, KEY_0, KEY_BACKSPACE, 0, 0, 0, 0, 0, 0, 0, /* 1-16 */
55 0, KEY_2, KEY_4, KEY_R, KEY_Y, KEY_8, KEY_I, KEY_O, KEY_P, 0, 0, 0, 0, 0, 0, 0, /* 17-32 */
56 KEY_TAB, KEY_Q, KEY_E, KEY_T, KEY_G, KEY_U, KEY_J, KEY_K, 0, 0, 0, 0, 0, 0, 0, 0, /* 33-48 */
57 CORGI_KEY_CALENDER, KEY_W, KEY_S, KEY_F, KEY_V, KEY_H, KEY_M, KEY_L, 0, KEY_RIGHTSHIFT, 0, 0, 0, 0, 0, 0, /* 49-64 */
58 CORGI_KEY_ADDRESS, KEY_A, KEY_D, KEY_C, KEY_B, KEY_N, KEY_DOT, 0, KEY_ENTER, 0, KEY_LEFTSHIFT, 0, 0, 0, 0, 0, /* 65-80 */
59 CORGI_KEY_MAIL, KEY_Z, KEY_X, KEY_MINUS, KEY_SPACE, KEY_COMMA, 0, KEY_UP, 0, 0, 0, CORGI_KEY_FN, 0, 0, 0, 0, /* 81-96 */
60 KEY_SYSRQ, CORGI_KEY_JAP1, CORGI_KEY_JAP2, CORGI_KEY_CANCEL, CORGI_KEY_OK, CORGI_KEY_MENU, KEY_LEFT, KEY_DOWN, KEY_RIGHT, 0, 0, 0, 0, 0, 0, 0, /* 97-112 */
61 CORGI_KEY_OFF, CORGI_KEY_EXOK, CORGI_KEY_EXCANCEL, CORGI_KEY_EXJOGDOWN, CORGI_KEY_EXJOGUP, 0, 0, 0, 0, 0, 0, 0, /* 113-124 */
62};
63
64
65struct corgikbd {
66 unsigned char keycode[ARRAY_SIZE(corgikbd_keycode)];
67 struct input_dev *input;
68
69 spinlock_t lock;
70 struct timer_list timer;
71 struct timer_list htimer;
72
73 unsigned int suspended;
74 unsigned long suspend_jiffies;
75};
76
77#define KB_DISCHARGE_DELAY 10
78#define KB_ACTIVATE_DELAY 10
79
80/* Helper functions for reading the keyboard matrix
81 * Note: We should really be using the generic gpio functions to alter
82 * GPDR but it requires a function call per GPIO bit which is
83 * excessive when we need to access 12 bits at once, multiple times.
84 * These functions must be called within local_irq_save()/local_irq_restore()
85 * or similar.
86 */
87static inline void corgikbd_discharge_all(void)
88{
89 /* STROBE All HiZ */
90 GPCR2 = CORGI_GPIO_ALL_STROBE_BIT;
91 GPDR2 &= ~CORGI_GPIO_ALL_STROBE_BIT;
92}
93
94static inline void corgikbd_activate_all(void)
95{
96 /* STROBE ALL -> High */
97 GPSR2 = CORGI_GPIO_ALL_STROBE_BIT;
98 GPDR2 |= CORGI_GPIO_ALL_STROBE_BIT;
99
100 udelay(KB_DISCHARGE_DELAY);
101
102 /* Clear any interrupts we may have triggered when altering the GPIO lines */
103 GEDR1 = CORGI_GPIO_HIGH_SENSE_BIT;
104 GEDR2 = CORGI_GPIO_LOW_SENSE_BIT;
105}
106
107static inline void corgikbd_activate_col(int col)
108{
109 /* STROBE col -> High, not col -> HiZ */
110 GPSR2 = CORGI_GPIO_STROBE_BIT(col);
111 GPDR2 = (GPDR2 & ~CORGI_GPIO_ALL_STROBE_BIT) | CORGI_GPIO_STROBE_BIT(col);
112}
113
114static inline void corgikbd_reset_col(int col)
115{
116 /* STROBE col -> Low */
117 GPCR2 = CORGI_GPIO_STROBE_BIT(col);
118 /* STROBE col -> out, not col -> HiZ */
119 GPDR2 = (GPDR2 & ~CORGI_GPIO_ALL_STROBE_BIT) | CORGI_GPIO_STROBE_BIT(col);
120}
121
122#define GET_ROWS_STATUS(c) (((GPLR1 & CORGI_GPIO_HIGH_SENSE_BIT) >> CORGI_GPIO_HIGH_SENSE_RSHIFT) | ((GPLR2 & CORGI_GPIO_LOW_SENSE_BIT) << CORGI_GPIO_LOW_SENSE_LSHIFT))
123
124/*
125 * The corgi keyboard only generates interrupts when a key is pressed.
126 * When a key is pressed, we enable a timer which then scans the
127 * keyboard to detect when the key is released.
128 */
129
130/* Scan the hardware keyboard and push any changes up through the input layer */
131static void corgikbd_scankeyboard(struct corgikbd *corgikbd_data)
132{
133 unsigned int row, col, rowd;
134 unsigned long flags;
135 unsigned int num_pressed;
136
137 if (corgikbd_data->suspended)
138 return;
139
140 spin_lock_irqsave(&corgikbd_data->lock, flags);
141
142 num_pressed = 0;
143 for (col = 0; col < KB_COLS; col++) {
144 /*
145 * Discharge the output driver capacitatance
146 * in the keyboard matrix. (Yes it is significant..)
147 */
148
149 corgikbd_discharge_all();
150 udelay(KB_DISCHARGE_DELAY);
151
152 corgikbd_activate_col(col);
153 udelay(KB_ACTIVATE_DELAY);
154
155 rowd = GET_ROWS_STATUS(col);
156 for (row = 0; row < KB_ROWS; row++) {
157 unsigned int scancode, pressed;
158
159 scancode = SCANCODE(row, col);
160 pressed = rowd & KB_ROWMASK(row);
161
162 input_report_key(corgikbd_data->input, corgikbd_data->keycode[scancode], pressed);
163
164 if (pressed)
165 num_pressed++;
166
167 if (pressed && (corgikbd_data->keycode[scancode] == CORGI_KEY_OFF)
168 && time_after(jiffies, corgikbd_data->suspend_jiffies + HZ)) {
169 input_event(corgikbd_data->input, EV_PWR, CORGI_KEY_OFF, 1);
170 corgikbd_data->suspend_jiffies=jiffies;
171 }
172 }
173 corgikbd_reset_col(col);
174 }
175
176 corgikbd_activate_all();
177
178 input_sync(corgikbd_data->input);
179
180 /* if any keys are pressed, enable the timer */
181 if (num_pressed)
182 mod_timer(&corgikbd_data->timer, jiffies + msecs_to_jiffies(SCAN_INTERVAL));
183
184 spin_unlock_irqrestore(&corgikbd_data->lock, flags);
185}
186
187/*
188 * corgi keyboard interrupt handler.
189 */
190static irqreturn_t corgikbd_interrupt(int irq, void *dev_id)
191{
192 struct corgikbd *corgikbd_data = dev_id;
193
194 if (!timer_pending(&corgikbd_data->timer)) {
195 /** wait chattering delay **/
196 udelay(20);
197 corgikbd_scankeyboard(corgikbd_data);
198 }
199
200 return IRQ_HANDLED;
201}
202
203/*
204 * corgi timer checking for released keys
205 */
206static void corgikbd_timer_callback(unsigned long data)
207{
208 struct corgikbd *corgikbd_data = (struct corgikbd *) data;
209 corgikbd_scankeyboard(corgikbd_data);
210}
211
212/*
213 * The hinge switches generate no interrupt so they need to be
214 * monitored by a timer.
215 *
216 * We debounce the switches and pass them to the input system.
217 *
218 * gprr == 0x00 - Keyboard with Landscape Screen
219 * 0x08 - No Keyboard with Portrait Screen
220 * 0x0c - Keyboard and Screen Closed
221 */
222
223#define READ_GPIO_BIT(x) (GPLR(x) & GPIO_bit(x))
224#define HINGE_STABLE_COUNT 2
225static int sharpsl_hinge_state;
226static int hinge_count;
227
228static void corgikbd_hinge_timer(unsigned long data)
229{
230 struct corgikbd *corgikbd_data = (struct corgikbd *) data;
231 unsigned long gprr;
232 unsigned long flags;
233
234 gprr = read_scoop_reg(&corgiscoop_device.dev, SCOOP_GPRR) & (CORGI_SCP_SWA | CORGI_SCP_SWB);
235 gprr |= (READ_GPIO_BIT(CORGI_GPIO_AK_INT) != 0);
236 if (gprr != sharpsl_hinge_state) {
237 hinge_count = 0;
238 sharpsl_hinge_state = gprr;
239 } else if (hinge_count < HINGE_STABLE_COUNT) {
240 hinge_count++;
241 if (hinge_count >= HINGE_STABLE_COUNT) {
242 spin_lock_irqsave(&corgikbd_data->lock, flags);
243
244 input_report_switch(corgikbd_data->input, SW_LID, ((sharpsl_hinge_state & CORGI_SCP_SWA) != 0));
245 input_report_switch(corgikbd_data->input, SW_TABLET_MODE, ((sharpsl_hinge_state & CORGI_SCP_SWB) != 0));
246 input_report_switch(corgikbd_data->input, SW_HEADPHONE_INSERT, (READ_GPIO_BIT(CORGI_GPIO_AK_INT) != 0));
247 input_sync(corgikbd_data->input);
248
249 spin_unlock_irqrestore(&corgikbd_data->lock, flags);
250 }
251 }
252 mod_timer(&corgikbd_data->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL));
253}
254
255#ifdef CONFIG_PM
256static int corgikbd_suspend(struct platform_device *dev, pm_message_t state)
257{
258 int i;
259 struct corgikbd *corgikbd = platform_get_drvdata(dev);
260
261 corgikbd->suspended = 1;
262 /* strobe 0 is the power key so this can't be made an input for
263 powersaving therefore i = 1 */
264 for (i = 1; i < CORGI_KEY_STROBE_NUM; i++)
265 pxa_gpio_mode(CORGI_GPIO_KEY_STROBE(i) | GPIO_IN);
266
267 return 0;
268}
269
270static int corgikbd_resume(struct platform_device *dev)
271{
272 int i;
273 struct corgikbd *corgikbd = platform_get_drvdata(dev);
274
275 for (i = 1; i < CORGI_KEY_STROBE_NUM; i++)
276 pxa_gpio_mode(CORGI_GPIO_KEY_STROBE(i) | GPIO_OUT | GPIO_DFLT_HIGH);
277
278 /* Upon resume, ignore the suspend key for a short while */
279 corgikbd->suspend_jiffies=jiffies;
280 corgikbd->suspended = 0;
281
282 return 0;
283}
284#else
285#define corgikbd_suspend NULL
286#define corgikbd_resume NULL
287#endif
288
289static int __devinit corgikbd_probe(struct platform_device *pdev)
290{
291 struct corgikbd *corgikbd;
292 struct input_dev *input_dev;
293 int i, err = -ENOMEM;
294
295 corgikbd = kzalloc(sizeof(struct corgikbd), GFP_KERNEL);
296 input_dev = input_allocate_device();
297 if (!corgikbd || !input_dev)
298 goto fail;
299
300 platform_set_drvdata(pdev, corgikbd);
301
302 corgikbd->input = input_dev;
303 spin_lock_init(&corgikbd->lock);
304
305 /* Init Keyboard rescan timer */
306 init_timer(&corgikbd->timer);
307 corgikbd->timer.function = corgikbd_timer_callback;
308 corgikbd->timer.data = (unsigned long) corgikbd;
309
310 /* Init Hinge Timer */
311 init_timer(&corgikbd->htimer);
312 corgikbd->htimer.function = corgikbd_hinge_timer;
313 corgikbd->htimer.data = (unsigned long) corgikbd;
314
315 corgikbd->suspend_jiffies=jiffies;
316
317 memcpy(corgikbd->keycode, corgikbd_keycode, sizeof(corgikbd->keycode));
318
319 input_dev->name = "Corgi Keyboard";
320 input_dev->phys = "corgikbd/input0";
321 input_dev->id.bustype = BUS_HOST;
322 input_dev->id.vendor = 0x0001;
323 input_dev->id.product = 0x0001;
324 input_dev->id.version = 0x0100;
325 input_dev->dev.parent = &pdev->dev;
326
327 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) |
328 BIT_MASK(EV_PWR) | BIT_MASK(EV_SW);
329 input_dev->keycode = corgikbd->keycode;
330 input_dev->keycodesize = sizeof(unsigned char);
331 input_dev->keycodemax = ARRAY_SIZE(corgikbd_keycode);
332
333 for (i = 0; i < ARRAY_SIZE(corgikbd_keycode); i++)
334 set_bit(corgikbd->keycode[i], input_dev->keybit);
335 clear_bit(0, input_dev->keybit);
336 set_bit(SW_LID, input_dev->swbit);
337 set_bit(SW_TABLET_MODE, input_dev->swbit);
338 set_bit(SW_HEADPHONE_INSERT, input_dev->swbit);
339
340 err = input_register_device(corgikbd->input);
341 if (err)
342 goto fail;
343
344 mod_timer(&corgikbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL));
345
346 /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */
347 for (i = 0; i < CORGI_KEY_SENSE_NUM; i++) {
348 pxa_gpio_mode(CORGI_GPIO_KEY_SENSE(i) | GPIO_IN);
349 if (request_irq(CORGI_IRQ_GPIO_KEY_SENSE(i), corgikbd_interrupt,
350 IRQF_DISABLED | IRQF_TRIGGER_RISING,
351 "corgikbd", corgikbd))
352 printk(KERN_WARNING "corgikbd: Can't get IRQ: %d!\n", i);
353 }
354
355 /* Set Strobe lines as outputs - set high */
356 for (i = 0; i < CORGI_KEY_STROBE_NUM; i++)
357 pxa_gpio_mode(CORGI_GPIO_KEY_STROBE(i) | GPIO_OUT | GPIO_DFLT_HIGH);
358
359 /* Setup the headphone jack as an input */
360 pxa_gpio_mode(CORGI_GPIO_AK_INT | GPIO_IN);
361
362 return 0;
363
364 fail: input_free_device(input_dev);
365 kfree(corgikbd);
366 return err;
367}
368
369static int __devexit corgikbd_remove(struct platform_device *pdev)
370{
371 int i;
372 struct corgikbd *corgikbd = platform_get_drvdata(pdev);
373
374 for (i = 0; i < CORGI_KEY_SENSE_NUM; i++)
375 free_irq(CORGI_IRQ_GPIO_KEY_SENSE(i), corgikbd);
376
377 del_timer_sync(&corgikbd->htimer);
378 del_timer_sync(&corgikbd->timer);
379
380 input_unregister_device(corgikbd->input);
381
382 kfree(corgikbd);
383
384 return 0;
385}
386
387static struct platform_driver corgikbd_driver = {
388 .probe = corgikbd_probe,
389 .remove = __devexit_p(corgikbd_remove),
390 .suspend = corgikbd_suspend,
391 .resume = corgikbd_resume,
392 .driver = {
393 .name = "corgi-keyboard",
394 .owner = THIS_MODULE,
395 },
396};
397
398static int __init corgikbd_init(void)
399{
400 return platform_driver_register(&corgikbd_driver);
401}
402
403static void __exit corgikbd_exit(void)
404{
405 platform_driver_unregister(&corgikbd_driver);
406}
407
408module_init(corgikbd_init);
409module_exit(corgikbd_exit);
410
411MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>");
412MODULE_DESCRIPTION("Corgi Keyboard Driver");
413MODULE_LICENSE("GPL v2");
414MODULE_ALIAS("platform:corgi-keyboard");
diff --git a/drivers/input/keyboard/davinci_keyscan.c b/drivers/input/keyboard/davinci_keyscan.c
index d410d7a52f1..a91ee941b5c 100644
--- a/drivers/input/keyboard/davinci_keyscan.c
+++ b/drivers/input/keyboard/davinci_keyscan.c
@@ -30,6 +30,7 @@
30#include <linux/delay.h> 30#include <linux/delay.h>
31#include <linux/platform_device.h> 31#include <linux/platform_device.h>
32#include <linux/errno.h> 32#include <linux/errno.h>
33#include <linux/slab.h>
33 34
34#include <asm/irq.h> 35#include <asm/irq.h>
35 36
diff --git a/drivers/input/keyboard/ep93xx_keypad.c b/drivers/input/keyboard/ep93xx_keypad.c
index bd25a3af166..c8242dd190d 100644
--- a/drivers/input/keyboard/ep93xx_keypad.c
+++ b/drivers/input/keyboard/ep93xx_keypad.c
@@ -25,6 +25,7 @@
25#include <linux/clk.h> 25#include <linux/clk.h>
26#include <linux/io.h> 26#include <linux/io.h>
27#include <linux/input/matrix_keypad.h> 27#include <linux/input/matrix_keypad.h>
28#include <linux/slab.h>
28 29
29#include <mach/hardware.h> 30#include <mach/hardware.h>
30#include <mach/ep93xx_keypad.h> 31#include <mach/ep93xx_keypad.h>
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 2b708aa8555..b8213fd13c3 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -16,6 +16,7 @@
16#include <linux/irq.h> 16#include <linux/irq.h>
17#include <linux/sched.h> 17#include <linux/sched.h>
18#include <linux/pm.h> 18#include <linux/pm.h>
19#include <linux/slab.h>
19#include <linux/sysctl.h> 20#include <linux/sysctl.h>
20#include <linux/proc_fs.h> 21#include <linux/proc_fs.h>
21#include <linux/delay.h> 22#include <linux/delay.h>
diff --git a/drivers/input/keyboard/imx_keypad.c b/drivers/input/keyboard/imx_keypad.c
index 2ee5b798024..d92c15c39e6 100644
--- a/drivers/input/keyboard/imx_keypad.c
+++ b/drivers/input/keyboard/imx_keypad.c
@@ -21,6 +21,7 @@
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/slab.h>
24#include <linux/timer.h> 25#include <linux/timer.h>
25 26
26/* 27/*
diff --git a/drivers/input/keyboard/jornada680_kbd.c b/drivers/input/keyboard/jornada680_kbd.c
index 781fc610286..5fc976dbce0 100644
--- a/drivers/input/keyboard/jornada680_kbd.c
+++ b/drivers/input/keyboard/jornada680_kbd.c
@@ -24,6 +24,7 @@
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/platform_device.h> 26#include <linux/platform_device.h>
27#include <linux/slab.h>
27 28
28#include <asm/delay.h> 29#include <asm/delay.h>
29#include <asm/io.h> 30#include <asm/io.h>
diff --git a/drivers/input/keyboard/jornada720_kbd.c b/drivers/input/keyboard/jornada720_kbd.c
index 4e016d82306..2cd3e1d56ea 100644
--- a/drivers/input/keyboard/jornada720_kbd.c
+++ b/drivers/input/keyboard/jornada720_kbd.c
@@ -23,6 +23,7 @@
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26#include <linux/slab.h>
26 27
27#include <mach/jornada720.h> 28#include <mach/jornada720.h>
28#include <mach/hardware.h> 29#include <mach/hardware.h>
diff --git a/drivers/input/keyboard/lm8323.c b/drivers/input/keyboard/lm8323.c
index 574eda2a495..60ac4684f87 100644
--- a/drivers/input/keyboard/lm8323.c
+++ b/drivers/input/keyboard/lm8323.c
@@ -31,6 +31,7 @@
31#include <linux/input.h> 31#include <linux/input.h>
32#include <linux/leds.h> 32#include <linux/leds.h>
33#include <linux/i2c/lm8323.h> 33#include <linux/i2c/lm8323.h>
34#include <linux/slab.h>
34 35
35/* Commands to send to the chip. */ 36/* Commands to send to the chip. */
36#define LM8323_CMD_READ_ID 0x80 /* Read chip ID. */ 37#define LM8323_CMD_READ_ID 0x80 /* Read chip ID. */
diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c
index d3c8b61a941..b443e088fd3 100644
--- a/drivers/input/keyboard/matrix_keypad.c
+++ b/drivers/input/keyboard/matrix_keypad.c
@@ -22,6 +22,7 @@
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/gpio.h> 23#include <linux/gpio.h>
24#include <linux/input/matrix_keypad.h> 24#include <linux/input/matrix_keypad.h>
25#include <linux/slab.h>
25 26
26struct matrix_keypad { 27struct matrix_keypad {
27 const struct matrix_keypad_platform_data *pdata; 28 const struct matrix_keypad_platform_data *pdata;
@@ -373,7 +374,9 @@ static int __devinit matrix_keypad_probe(struct platform_device *pdev)
373 input_dev->name = pdev->name; 374 input_dev->name = pdev->name;
374 input_dev->id.bustype = BUS_HOST; 375 input_dev->id.bustype = BUS_HOST;
375 input_dev->dev.parent = &pdev->dev; 376 input_dev->dev.parent = &pdev->dev;
376 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); 377 input_dev->evbit[0] = BIT_MASK(EV_KEY);
378 if (!pdata->no_autorepeat)
379 input_dev->evbit[0] |= BIT_MASK(EV_REP);
377 input_dev->open = matrix_keypad_start; 380 input_dev->open = matrix_keypad_start;
378 input_dev->close = matrix_keypad_stop; 381 input_dev->close = matrix_keypad_stop;
379 382
diff --git a/drivers/input/keyboard/max7359_keypad.c b/drivers/input/keyboard/max7359_keypad.c
index 3b5b948eba3..7fc8185e5c1 100644
--- a/drivers/input/keyboard/max7359_keypad.c
+++ b/drivers/input/keyboard/max7359_keypad.c
@@ -15,6 +15,7 @@
15 15
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/i2c.h> 17#include <linux/i2c.h>
18#include <linux/slab.h>
18#include <linux/interrupt.h> 19#include <linux/interrupt.h>
19#include <linux/input.h> 20#include <linux/input.h>
20#include <linux/input/matrix_keypad.h> 21#include <linux/input/matrix_keypad.h>
diff --git a/drivers/input/keyboard/omap-keypad.c b/drivers/input/keyboard/omap-keypad.c
index 1a494d50543..a72e61ddca9 100644
--- a/drivers/input/keyboard/omap-keypad.c
+++ b/drivers/input/keyboard/omap-keypad.c
@@ -34,6 +34,7 @@
34#include <linux/platform_device.h> 34#include <linux/platform_device.h>
35#include <linux/mutex.h> 35#include <linux/mutex.h>
36#include <linux/errno.h> 36#include <linux/errno.h>
37#include <linux/slab.h>
37#include <mach/gpio.h> 38#include <mach/gpio.h>
38#include <plat/keypad.h> 39#include <plat/keypad.h>
39#include <plat/menelaus.h> 40#include <plat/menelaus.h>
diff --git a/drivers/input/keyboard/opencores-kbd.c b/drivers/input/keyboard/opencores-kbd.c
index 78cccddbf55..1f1a5563f60 100644
--- a/drivers/input/keyboard/opencores-kbd.c
+++ b/drivers/input/keyboard/opencores-kbd.c
@@ -14,6 +14,7 @@
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/slab.h>
17 18
18struct opencores_kbd { 19struct opencores_kbd {
19 struct input_dev *input; 20 struct input_dev *input;
diff --git a/drivers/input/keyboard/pxa27x_keypad.c b/drivers/input/keyboard/pxa27x_keypad.c
index 79cd3e9fdf2..0e53b3bc39a 100644
--- a/drivers/input/keyboard/pxa27x_keypad.c
+++ b/drivers/input/keyboard/pxa27x_keypad.c
@@ -26,6 +26,7 @@
26#include <linux/clk.h> 26#include <linux/clk.h>
27#include <linux/err.h> 27#include <linux/err.h>
28#include <linux/input/matrix_keypad.h> 28#include <linux/input/matrix_keypad.h>
29#include <linux/slab.h>
29 30
30#include <asm/mach/arch.h> 31#include <asm/mach/arch.h>
31#include <asm/mach/map.h> 32#include <asm/mach/map.h>
diff --git a/drivers/input/keyboard/pxa930_rotary.c b/drivers/input/keyboard/pxa930_rotary.c
index 95fbba470e6..b7123a44b6e 100644
--- a/drivers/input/keyboard/pxa930_rotary.c
+++ b/drivers/input/keyboard/pxa930_rotary.c
@@ -13,6 +13,7 @@
13#include <linux/input.h> 13#include <linux/input.h>
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/io.h> 15#include <linux/io.h>
16#include <linux/slab.h>
16 17
17#include <mach/pxa930_rotary.h> 18#include <mach/pxa930_rotary.h>
18 19
diff --git a/drivers/input/keyboard/sh_keysc.c b/drivers/input/keyboard/sh_keysc.c
index 854e2035cd6..d7dafd9425b 100644
--- a/drivers/input/keyboard/sh_keysc.c
+++ b/drivers/input/keyboard/sh_keysc.c
@@ -22,6 +22,7 @@
22#include <linux/bitmap.h> 22#include <linux/bitmap.h>
23#include <linux/clk.h> 23#include <linux/clk.h>
24#include <linux/io.h> 24#include <linux/io.h>
25#include <linux/slab.h>
25 26
26static const struct { 27static const struct {
27 unsigned char kymd, keyout, keyin; 28 unsigned char kymd, keyout, keyin;
diff --git a/drivers/input/keyboard/spitzkbd.c b/drivers/input/keyboard/spitzkbd.c
deleted file mode 100644
index 13967422658..00000000000
--- a/drivers/input/keyboard/spitzkbd.c
+++ /dev/null
@@ -1,496 +0,0 @@
1/*
2 * Keyboard driver for Sharp Spitz, Borzoi and Akita (SL-Cxx00 series)
3 *
4 * Copyright (c) 2005 Richard Purdie
5 *
6 * Based on corgikbd.c
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 */
13
14#include <linux/delay.h>
15#include <linux/platform_device.h>
16#include <linux/init.h>
17#include <linux/input.h>
18#include <linux/interrupt.h>
19#include <linux/jiffies.h>
20#include <linux/module.h>
21#include <linux/slab.h>
22
23#include <mach/spitz.h>
24#include <mach/pxa2xx-gpio.h>
25
26#define KB_ROWS 7
27#define KB_COLS 11
28#define KB_ROWMASK(r) (1 << (r))
29#define SCANCODE(r,c) (((r)<<4) + (c) + 1)
30#define NR_SCANCODES ((KB_ROWS<<4) + 1)
31
32#define SCAN_INTERVAL (50) /* ms */
33#define HINGE_SCAN_INTERVAL (150) /* ms */
34
35#define SPITZ_KEY_CALENDER KEY_F1
36#define SPITZ_KEY_ADDRESS KEY_F2
37#define SPITZ_KEY_FN KEY_F3
38#define SPITZ_KEY_CANCEL KEY_F4
39#define SPITZ_KEY_EXOK KEY_F5
40#define SPITZ_KEY_EXCANCEL KEY_F6
41#define SPITZ_KEY_EXJOGDOWN KEY_F7
42#define SPITZ_KEY_EXJOGUP KEY_F8
43#define SPITZ_KEY_JAP1 KEY_LEFTALT
44#define SPITZ_KEY_JAP2 KEY_RIGHTCTRL
45#define SPITZ_KEY_SYNC KEY_F9
46#define SPITZ_KEY_MAIL KEY_F10
47#define SPITZ_KEY_OK KEY_F11
48#define SPITZ_KEY_MENU KEY_F12
49
50static unsigned char spitzkbd_keycode[NR_SCANCODES] = {
51 0, /* 0 */
52 KEY_LEFTCTRL, KEY_1, KEY_3, KEY_5, KEY_6, KEY_7, KEY_9, KEY_0, KEY_BACKSPACE, SPITZ_KEY_EXOK, SPITZ_KEY_EXCANCEL, 0, 0, 0, 0, 0, /* 1-16 */
53 0, KEY_2, KEY_4, KEY_R, KEY_Y, KEY_8, KEY_I, KEY_O, KEY_P, SPITZ_KEY_EXJOGDOWN, SPITZ_KEY_EXJOGUP, 0, 0, 0, 0, 0, /* 17-32 */
54 KEY_TAB, KEY_Q, KEY_E, KEY_T, KEY_G, KEY_U, KEY_J, KEY_K, 0, 0, 0, 0, 0, 0, 0, 0, /* 33-48 */
55 SPITZ_KEY_ADDRESS, KEY_W, KEY_S, KEY_F, KEY_V, KEY_H, KEY_M, KEY_L, 0, KEY_RIGHTSHIFT, 0, 0, 0, 0, 0, 0, /* 49-64 */
56 SPITZ_KEY_CALENDER, KEY_A, KEY_D, KEY_C, KEY_B, KEY_N, KEY_DOT, 0, KEY_ENTER, KEY_LEFTSHIFT, 0, 0, 0, 0, 0, 0, /* 65-80 */
57 SPITZ_KEY_MAIL, KEY_Z, KEY_X, KEY_MINUS, KEY_SPACE, KEY_COMMA, 0, KEY_UP, 0, 0, SPITZ_KEY_FN, 0, 0, 0, 0, 0, /* 81-96 */
58 KEY_SYSRQ, SPITZ_KEY_JAP1, SPITZ_KEY_JAP2, SPITZ_KEY_CANCEL, SPITZ_KEY_OK, SPITZ_KEY_MENU, KEY_LEFT, KEY_DOWN, KEY_RIGHT, 0, 0, 0, 0, 0, 0, 0 /* 97-112 */
59};
60
61static int spitz_strobes[] = {
62 SPITZ_GPIO_KEY_STROBE0,
63 SPITZ_GPIO_KEY_STROBE1,
64 SPITZ_GPIO_KEY_STROBE2,
65 SPITZ_GPIO_KEY_STROBE3,
66 SPITZ_GPIO_KEY_STROBE4,
67 SPITZ_GPIO_KEY_STROBE5,
68 SPITZ_GPIO_KEY_STROBE6,
69 SPITZ_GPIO_KEY_STROBE7,
70 SPITZ_GPIO_KEY_STROBE8,
71 SPITZ_GPIO_KEY_STROBE9,
72 SPITZ_GPIO_KEY_STROBE10,
73};
74
75static int spitz_senses[] = {
76 SPITZ_GPIO_KEY_SENSE0,
77 SPITZ_GPIO_KEY_SENSE1,
78 SPITZ_GPIO_KEY_SENSE2,
79 SPITZ_GPIO_KEY_SENSE3,
80 SPITZ_GPIO_KEY_SENSE4,
81 SPITZ_GPIO_KEY_SENSE5,
82 SPITZ_GPIO_KEY_SENSE6,
83};
84
85struct spitzkbd {
86 unsigned char keycode[ARRAY_SIZE(spitzkbd_keycode)];
87 struct input_dev *input;
88 char phys[32];
89
90 spinlock_t lock;
91 struct timer_list timer;
92 struct timer_list htimer;
93
94 unsigned int suspended;
95 unsigned long suspend_jiffies;
96};
97
98#define KB_DISCHARGE_DELAY 10
99#define KB_ACTIVATE_DELAY 10
100
101/* Helper functions for reading the keyboard matrix
102 * Note: We should really be using the generic gpio functions to alter
103 * GPDR but it requires a function call per GPIO bit which is
104 * excessive when we need to access 11 bits at once, multiple times.
105 * These functions must be called within local_irq_save()/local_irq_restore()
106 * or similar.
107 */
108static inline void spitzkbd_discharge_all(void)
109{
110 /* STROBE All HiZ */
111 GPCR0 = SPITZ_GPIO_G0_STROBE_BIT;
112 GPDR0 &= ~SPITZ_GPIO_G0_STROBE_BIT;
113 GPCR1 = SPITZ_GPIO_G1_STROBE_BIT;
114 GPDR1 &= ~SPITZ_GPIO_G1_STROBE_BIT;
115 GPCR2 = SPITZ_GPIO_G2_STROBE_BIT;
116 GPDR2 &= ~SPITZ_GPIO_G2_STROBE_BIT;
117 GPCR3 = SPITZ_GPIO_G3_STROBE_BIT;
118 GPDR3 &= ~SPITZ_GPIO_G3_STROBE_BIT;
119}
120
121static inline void spitzkbd_activate_all(void)
122{
123 /* STROBE ALL -> High */
124 GPSR0 = SPITZ_GPIO_G0_STROBE_BIT;
125 GPDR0 |= SPITZ_GPIO_G0_STROBE_BIT;
126 GPSR1 = SPITZ_GPIO_G1_STROBE_BIT;
127 GPDR1 |= SPITZ_GPIO_G1_STROBE_BIT;
128 GPSR2 = SPITZ_GPIO_G2_STROBE_BIT;
129 GPDR2 |= SPITZ_GPIO_G2_STROBE_BIT;
130 GPSR3 = SPITZ_GPIO_G3_STROBE_BIT;
131 GPDR3 |= SPITZ_GPIO_G3_STROBE_BIT;
132
133 udelay(KB_DISCHARGE_DELAY);
134
135 /* Clear any interrupts we may have triggered when altering the GPIO lines */
136 GEDR0 = SPITZ_GPIO_G0_SENSE_BIT;
137 GEDR1 = SPITZ_GPIO_G1_SENSE_BIT;
138 GEDR2 = SPITZ_GPIO_G2_SENSE_BIT;
139 GEDR3 = SPITZ_GPIO_G3_SENSE_BIT;
140}
141
142static inline void spitzkbd_activate_col(int col)
143{
144 int gpio = spitz_strobes[col];
145 GPDR0 &= ~SPITZ_GPIO_G0_STROBE_BIT;
146 GPDR1 &= ~SPITZ_GPIO_G1_STROBE_BIT;
147 GPDR2 &= ~SPITZ_GPIO_G2_STROBE_BIT;
148 GPDR3 &= ~SPITZ_GPIO_G3_STROBE_BIT;
149 GPSR(gpio) = GPIO_bit(gpio);
150 GPDR(gpio) |= GPIO_bit(gpio);
151}
152
153static inline void spitzkbd_reset_col(int col)
154{
155 int gpio = spitz_strobes[col];
156 GPDR0 &= ~SPITZ_GPIO_G0_STROBE_BIT;
157 GPDR1 &= ~SPITZ_GPIO_G1_STROBE_BIT;
158 GPDR2 &= ~SPITZ_GPIO_G2_STROBE_BIT;
159 GPDR3 &= ~SPITZ_GPIO_G3_STROBE_BIT;
160 GPCR(gpio) = GPIO_bit(gpio);
161 GPDR(gpio) |= GPIO_bit(gpio);
162}
163
164static inline int spitzkbd_get_row_status(int col)
165{
166 return ((GPLR0 >> 12) & 0x01) | ((GPLR0 >> 16) & 0x02)
167 | ((GPLR2 >> 25) & 0x04) | ((GPLR1 << 1) & 0x08)
168 | ((GPLR1 >> 0) & 0x10) | ((GPLR1 >> 1) & 0x60);
169}
170
171/*
172 * The spitz keyboard only generates interrupts when a key is pressed.
173 * When a key is pressed, we enable a timer which then scans the
174 * keyboard to detect when the key is released.
175 */
176
177/* Scan the hardware keyboard and push any changes up through the input layer */
178static void spitzkbd_scankeyboard(struct spitzkbd *spitzkbd_data)
179{
180 unsigned int row, col, rowd;
181 unsigned long flags;
182 unsigned int num_pressed, pwrkey = ((GPLR(SPITZ_GPIO_ON_KEY) & GPIO_bit(SPITZ_GPIO_ON_KEY)) != 0);
183
184 if (spitzkbd_data->suspended)
185 return;
186
187 spin_lock_irqsave(&spitzkbd_data->lock, flags);
188
189 num_pressed = 0;
190 for (col = 0; col < KB_COLS; col++) {
191 /*
192 * Discharge the output driver capacitatance
193 * in the keyboard matrix. (Yes it is significant..)
194 */
195
196 spitzkbd_discharge_all();
197 udelay(KB_DISCHARGE_DELAY);
198
199 spitzkbd_activate_col(col);
200 udelay(KB_ACTIVATE_DELAY);
201
202 rowd = spitzkbd_get_row_status(col);
203 for (row = 0; row < KB_ROWS; row++) {
204 unsigned int scancode, pressed;
205
206 scancode = SCANCODE(row, col);
207 pressed = rowd & KB_ROWMASK(row);
208
209 input_report_key(spitzkbd_data->input, spitzkbd_data->keycode[scancode], pressed);
210
211 if (pressed)
212 num_pressed++;
213 }
214 spitzkbd_reset_col(col);
215 }
216
217 spitzkbd_activate_all();
218
219 input_report_key(spitzkbd_data->input, SPITZ_KEY_SYNC, (GPLR(SPITZ_GPIO_SYNC) & GPIO_bit(SPITZ_GPIO_SYNC)) != 0 );
220 input_report_key(spitzkbd_data->input, KEY_SUSPEND, pwrkey);
221
222 if (pwrkey && time_after(jiffies, spitzkbd_data->suspend_jiffies + msecs_to_jiffies(1000))) {
223 input_event(spitzkbd_data->input, EV_PWR, KEY_SUSPEND, 1);
224 spitzkbd_data->suspend_jiffies = jiffies;
225 }
226
227 input_sync(spitzkbd_data->input);
228
229 /* if any keys are pressed, enable the timer */
230 if (num_pressed)
231 mod_timer(&spitzkbd_data->timer, jiffies + msecs_to_jiffies(SCAN_INTERVAL));
232
233 spin_unlock_irqrestore(&spitzkbd_data->lock, flags);
234}
235
236/*
237 * spitz keyboard interrupt handler.
238 */
239static irqreturn_t spitzkbd_interrupt(int irq, void *dev_id)
240{
241 struct spitzkbd *spitzkbd_data = dev_id;
242
243 if (!timer_pending(&spitzkbd_data->timer)) {
244 /** wait chattering delay **/
245 udelay(20);
246 spitzkbd_scankeyboard(spitzkbd_data);
247 }
248
249 return IRQ_HANDLED;
250}
251
252/*
253 * spitz timer checking for released keys
254 */
255static void spitzkbd_timer_callback(unsigned long data)
256{
257 struct spitzkbd *spitzkbd_data = (struct spitzkbd *) data;
258
259 spitzkbd_scankeyboard(spitzkbd_data);
260}
261
262/*
263 * The hinge switches generate an interrupt.
264 * We debounce the switches and pass them to the input system.
265 */
266
267static irqreturn_t spitzkbd_hinge_isr(int irq, void *dev_id)
268{
269 struct spitzkbd *spitzkbd_data = dev_id;
270
271 if (!timer_pending(&spitzkbd_data->htimer))
272 mod_timer(&spitzkbd_data->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL));
273
274 return IRQ_HANDLED;
275}
276
277#define HINGE_STABLE_COUNT 2
278static int sharpsl_hinge_state;
279static int hinge_count;
280
281static void spitzkbd_hinge_timer(unsigned long data)
282{
283 struct spitzkbd *spitzkbd_data = (struct spitzkbd *) data;
284 unsigned long state;
285 unsigned long flags;
286
287 state = GPLR(SPITZ_GPIO_SWA) & (GPIO_bit(SPITZ_GPIO_SWA)|GPIO_bit(SPITZ_GPIO_SWB));
288 state |= (GPLR(SPITZ_GPIO_AK_INT) & GPIO_bit(SPITZ_GPIO_AK_INT));
289 if (state != sharpsl_hinge_state) {
290 hinge_count = 0;
291 sharpsl_hinge_state = state;
292 } else if (hinge_count < HINGE_STABLE_COUNT) {
293 hinge_count++;
294 }
295
296 if (hinge_count >= HINGE_STABLE_COUNT) {
297 spin_lock_irqsave(&spitzkbd_data->lock, flags);
298
299 input_report_switch(spitzkbd_data->input, SW_LID, ((GPLR(SPITZ_GPIO_SWA) & GPIO_bit(SPITZ_GPIO_SWA)) != 0));
300 input_report_switch(spitzkbd_data->input, SW_TABLET_MODE, ((GPLR(SPITZ_GPIO_SWB) & GPIO_bit(SPITZ_GPIO_SWB)) != 0));
301 input_report_switch(spitzkbd_data->input, SW_HEADPHONE_INSERT, ((GPLR(SPITZ_GPIO_AK_INT) & GPIO_bit(SPITZ_GPIO_AK_INT)) != 0));
302 input_sync(spitzkbd_data->input);
303
304 spin_unlock_irqrestore(&spitzkbd_data->lock, flags);
305 } else {
306 mod_timer(&spitzkbd_data->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL));
307 }
308}
309
310#ifdef CONFIG_PM
311static int spitzkbd_suspend(struct platform_device *dev, pm_message_t state)
312{
313 int i;
314 struct spitzkbd *spitzkbd = platform_get_drvdata(dev);
315 spitzkbd->suspended = 1;
316
317 /* Set Strobe lines as inputs - *except* strobe line 0 leave this
318 enabled so we can detect a power button press for resume */
319 for (i = 1; i < SPITZ_KEY_STROBE_NUM; i++)
320 pxa_gpio_mode(spitz_strobes[i] | GPIO_IN);
321
322 return 0;
323}
324
325static int spitzkbd_resume(struct platform_device *dev)
326{
327 int i;
328 struct spitzkbd *spitzkbd = platform_get_drvdata(dev);
329
330 for (i = 0; i < SPITZ_KEY_STROBE_NUM; i++)
331 pxa_gpio_mode(spitz_strobes[i] | GPIO_OUT | GPIO_DFLT_HIGH);
332
333 /* Upon resume, ignore the suspend key for a short while */
334 spitzkbd->suspend_jiffies = jiffies;
335 spitzkbd->suspended = 0;
336
337 return 0;
338}
339#else
340#define spitzkbd_suspend NULL
341#define spitzkbd_resume NULL
342#endif
343
344static int __devinit spitzkbd_probe(struct platform_device *dev)
345{
346 struct spitzkbd *spitzkbd;
347 struct input_dev *input_dev;
348 int i, err = -ENOMEM;
349
350 spitzkbd = kzalloc(sizeof(struct spitzkbd), GFP_KERNEL);
351 input_dev = input_allocate_device();
352 if (!spitzkbd || !input_dev)
353 goto fail;
354
355 platform_set_drvdata(dev, spitzkbd);
356 strcpy(spitzkbd->phys, "spitzkbd/input0");
357
358 spin_lock_init(&spitzkbd->lock);
359
360 /* Init Keyboard rescan timer */
361 init_timer(&spitzkbd->timer);
362 spitzkbd->timer.function = spitzkbd_timer_callback;
363 spitzkbd->timer.data = (unsigned long) spitzkbd;
364
365 /* Init Hinge Timer */
366 init_timer(&spitzkbd->htimer);
367 spitzkbd->htimer.function = spitzkbd_hinge_timer;
368 spitzkbd->htimer.data = (unsigned long) spitzkbd;
369
370 spitzkbd->suspend_jiffies = jiffies;
371
372 spitzkbd->input = input_dev;
373
374 input_dev->name = "Spitz Keyboard";
375 input_dev->phys = spitzkbd->phys;
376 input_dev->dev.parent = &dev->dev;
377
378 input_dev->id.bustype = BUS_HOST;
379 input_dev->id.vendor = 0x0001;
380 input_dev->id.product = 0x0001;
381 input_dev->id.version = 0x0100;
382
383 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) |
384 BIT_MASK(EV_PWR) | BIT_MASK(EV_SW);
385 input_dev->keycode = spitzkbd->keycode;
386 input_dev->keycodesize = sizeof(unsigned char);
387 input_dev->keycodemax = ARRAY_SIZE(spitzkbd_keycode);
388
389 memcpy(spitzkbd->keycode, spitzkbd_keycode, sizeof(spitzkbd->keycode));
390 for (i = 0; i < ARRAY_SIZE(spitzkbd_keycode); i++)
391 set_bit(spitzkbd->keycode[i], input_dev->keybit);
392 clear_bit(0, input_dev->keybit);
393 set_bit(KEY_SUSPEND, input_dev->keybit);
394 set_bit(SW_LID, input_dev->swbit);
395 set_bit(SW_TABLET_MODE, input_dev->swbit);
396 set_bit(SW_HEADPHONE_INSERT, input_dev->swbit);
397
398 err = input_register_device(input_dev);
399 if (err)
400 goto fail;
401
402 mod_timer(&spitzkbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL));
403
404 /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */
405 for (i = 0; i < SPITZ_KEY_SENSE_NUM; i++) {
406 pxa_gpio_mode(spitz_senses[i] | GPIO_IN);
407 if (request_irq(IRQ_GPIO(spitz_senses[i]), spitzkbd_interrupt,
408 IRQF_DISABLED|IRQF_TRIGGER_RISING,
409 "Spitzkbd Sense", spitzkbd))
410 printk(KERN_WARNING "spitzkbd: Can't get Sense IRQ: %d!\n", i);
411 }
412
413 /* Set Strobe lines as outputs - set high */
414 for (i = 0; i < SPITZ_KEY_STROBE_NUM; i++)
415 pxa_gpio_mode(spitz_strobes[i] | GPIO_OUT | GPIO_DFLT_HIGH);
416
417 pxa_gpio_mode(SPITZ_GPIO_SYNC | GPIO_IN);
418 pxa_gpio_mode(SPITZ_GPIO_ON_KEY | GPIO_IN);
419 pxa_gpio_mode(SPITZ_GPIO_SWA | GPIO_IN);
420 pxa_gpio_mode(SPITZ_GPIO_SWB | GPIO_IN);
421
422 request_irq(SPITZ_IRQ_GPIO_SYNC, spitzkbd_interrupt,
423 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
424 "Spitzkbd Sync", spitzkbd);
425 request_irq(SPITZ_IRQ_GPIO_ON_KEY, spitzkbd_interrupt,
426 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
427 "Spitzkbd PwrOn", spitzkbd);
428 request_irq(SPITZ_IRQ_GPIO_SWA, spitzkbd_hinge_isr,
429 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
430 "Spitzkbd SWA", spitzkbd);
431 request_irq(SPITZ_IRQ_GPIO_SWB, spitzkbd_hinge_isr,
432 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
433 "Spitzkbd SWB", spitzkbd);
434 request_irq(SPITZ_IRQ_GPIO_AK_INT, spitzkbd_hinge_isr,
435 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
436 "Spitzkbd HP", spitzkbd);
437
438 return 0;
439
440 fail: input_free_device(input_dev);
441 kfree(spitzkbd);
442 return err;
443}
444
445static int __devexit spitzkbd_remove(struct platform_device *dev)
446{
447 int i;
448 struct spitzkbd *spitzkbd = platform_get_drvdata(dev);
449
450 for (i = 0; i < SPITZ_KEY_SENSE_NUM; i++)
451 free_irq(IRQ_GPIO(spitz_senses[i]), spitzkbd);
452
453 free_irq(SPITZ_IRQ_GPIO_SYNC, spitzkbd);
454 free_irq(SPITZ_IRQ_GPIO_ON_KEY, spitzkbd);
455 free_irq(SPITZ_IRQ_GPIO_SWA, spitzkbd);
456 free_irq(SPITZ_IRQ_GPIO_SWB, spitzkbd);
457 free_irq(SPITZ_IRQ_GPIO_AK_INT, spitzkbd);
458
459 del_timer_sync(&spitzkbd->htimer);
460 del_timer_sync(&spitzkbd->timer);
461
462 input_unregister_device(spitzkbd->input);
463
464 kfree(spitzkbd);
465
466 return 0;
467}
468
469static struct platform_driver spitzkbd_driver = {
470 .probe = spitzkbd_probe,
471 .remove = __devexit_p(spitzkbd_remove),
472 .suspend = spitzkbd_suspend,
473 .resume = spitzkbd_resume,
474 .driver = {
475 .name = "spitz-keyboard",
476 .owner = THIS_MODULE,
477 },
478};
479
480static int __init spitzkbd_init(void)
481{
482 return platform_driver_register(&spitzkbd_driver);
483}
484
485static void __exit spitzkbd_exit(void)
486{
487 platform_driver_unregister(&spitzkbd_driver);
488}
489
490module_init(spitzkbd_init);
491module_exit(spitzkbd_exit);
492
493MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>");
494MODULE_DESCRIPTION("Spitz Keyboard Driver");
495MODULE_LICENSE("GPL v2");
496MODULE_ALIAS("platform:spitz-keyboard");
diff --git a/drivers/input/keyboard/tosakbd.c b/drivers/input/keyboard/tosakbd.c
deleted file mode 100644
index 42cb3faf733..00000000000
--- a/drivers/input/keyboard/tosakbd.c
+++ /dev/null
@@ -1,430 +0,0 @@
1/*
2 * Keyboard driver for Sharp Tosa models (SL-6000x)
3 *
4 * Copyright (c) 2005 Dirk Opfer
5 * Copyright (c) 2007 Dmitry Baryshkov
6 *
7 * Based on xtkbd.c/locomkbd.c/corgikbd.c
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 */
14
15#include <linux/kernel.h>
16#include <linux/module.h>
17#include <linux/platform_device.h>
18#include <linux/input.h>
19#include <linux/delay.h>
20#include <linux/interrupt.h>
21
22#include <mach/gpio.h>
23#include <mach/tosa.h>
24
25#define KB_ROWMASK(r) (1 << (r))
26#define SCANCODE(r, c) (((r)<<4) + (c) + 1)
27#define NR_SCANCODES SCANCODE(TOSA_KEY_SENSE_NUM - 1, TOSA_KEY_STROBE_NUM - 1) + 1
28
29#define SCAN_INTERVAL (HZ/10)
30
31#define KB_DISCHARGE_DELAY 10
32#define KB_ACTIVATE_DELAY 10
33
34static unsigned short tosakbd_keycode[NR_SCANCODES] = {
350,
360, KEY_W, 0, 0, 0, KEY_K, KEY_BACKSPACE, KEY_P,
370, 0, 0, 0, 0, 0, 0, 0,
38KEY_Q, KEY_E, KEY_T, KEY_Y, 0, KEY_O, KEY_I, KEY_COMMA,
390, 0, 0, 0, 0, 0, 0, 0,
40KEY_A, KEY_D, KEY_G, KEY_U, 0, KEY_L, KEY_ENTER, KEY_DOT,
410, 0, 0, 0, 0, 0, 0, 0,
42KEY_Z, KEY_C, KEY_V, KEY_J, TOSA_KEY_ADDRESSBOOK, TOSA_KEY_CANCEL, TOSA_KEY_CENTER, TOSA_KEY_OK,
43KEY_LEFTSHIFT, 0, 0, 0, 0, 0, 0, 0,
44KEY_S, KEY_R, KEY_B, KEY_N, TOSA_KEY_CALENDAR, TOSA_KEY_HOMEPAGE, KEY_LEFTCTRL, TOSA_KEY_LIGHT,
450, KEY_RIGHTSHIFT, 0, 0, 0, 0, 0, 0,
46KEY_TAB, KEY_SLASH, KEY_H, KEY_M, TOSA_KEY_MENU, 0, KEY_UP, 0,
470, 0, TOSA_KEY_FN, 0, 0, 0, 0, 0,
48KEY_X, KEY_F, KEY_SPACE, KEY_APOSTROPHE, TOSA_KEY_MAIL, KEY_LEFT, KEY_DOWN, KEY_RIGHT,
490, 0, 0,
50};
51
52struct tosakbd {
53 unsigned short keycode[ARRAY_SIZE(tosakbd_keycode)];
54 struct input_dev *input;
55 bool suspended;
56 spinlock_t lock; /* protect kbd scanning */
57 struct timer_list timer;
58};
59
60
61/* Helper functions for reading the keyboard matrix
62 * Note: We should really be using the generic gpio functions to alter
63 * GPDR but it requires a function call per GPIO bit which is
64 * excessive when we need to access 12 bits at once, multiple times.
65 * These functions must be called within local_irq_save()/local_irq_restore()
66 * or similar.
67 */
68#define GET_ROWS_STATUS(c) ((GPLR2 & TOSA_GPIO_ALL_SENSE_BIT) >> TOSA_GPIO_ALL_SENSE_RSHIFT)
69
70static inline void tosakbd_discharge_all(void)
71{
72 /* STROBE All HiZ */
73 GPCR1 = TOSA_GPIO_HIGH_STROBE_BIT;
74 GPDR1 &= ~TOSA_GPIO_HIGH_STROBE_BIT;
75 GPCR2 = TOSA_GPIO_LOW_STROBE_BIT;
76 GPDR2 &= ~TOSA_GPIO_LOW_STROBE_BIT;
77}
78
79static inline void tosakbd_activate_all(void)
80{
81 /* STROBE ALL -> High */
82 GPSR1 = TOSA_GPIO_HIGH_STROBE_BIT;
83 GPDR1 |= TOSA_GPIO_HIGH_STROBE_BIT;
84 GPSR2 = TOSA_GPIO_LOW_STROBE_BIT;
85 GPDR2 |= TOSA_GPIO_LOW_STROBE_BIT;
86
87 udelay(KB_DISCHARGE_DELAY);
88
89 /* STATE CLEAR */
90 GEDR2 |= TOSA_GPIO_ALL_SENSE_BIT;
91}
92
93static inline void tosakbd_activate_col(int col)
94{
95 if (col <= 5) {
96 /* STROBE col -> High, not col -> HiZ */
97 GPSR1 = TOSA_GPIO_STROBE_BIT(col);
98 GPDR1 = (GPDR1 & ~TOSA_GPIO_HIGH_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col);
99 } else {
100 /* STROBE col -> High, not col -> HiZ */
101 GPSR2 = TOSA_GPIO_STROBE_BIT(col);
102 GPDR2 = (GPDR2 & ~TOSA_GPIO_LOW_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col);
103 }
104}
105
106static inline void tosakbd_reset_col(int col)
107{
108 if (col <= 5) {
109 /* STROBE col -> Low */
110 GPCR1 = TOSA_GPIO_STROBE_BIT(col);
111 /* STROBE col -> out, not col -> HiZ */
112 GPDR1 = (GPDR1 & ~TOSA_GPIO_HIGH_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col);
113 } else {
114 /* STROBE col -> Low */
115 GPCR2 = TOSA_GPIO_STROBE_BIT(col);
116 /* STROBE col -> out, not col -> HiZ */
117 GPDR2 = (GPDR2 & ~TOSA_GPIO_LOW_STROBE_BIT) | TOSA_GPIO_STROBE_BIT(col);
118 }
119}
120/*
121 * The tosa keyboard only generates interrupts when a key is pressed.
122 * So when a key is pressed, we enable a timer. This timer scans the
123 * keyboard, and this is how we detect when the key is released.
124 */
125
126/* Scan the hardware keyboard and push any changes up through the input layer */
127static void tosakbd_scankeyboard(struct platform_device *dev)
128{
129 struct tosakbd *tosakbd = platform_get_drvdata(dev);
130 unsigned int row, col, rowd;
131 unsigned long flags;
132 unsigned int num_pressed = 0;
133
134 spin_lock_irqsave(&tosakbd->lock, flags);
135
136 if (tosakbd->suspended)
137 goto out;
138
139 for (col = 0; col < TOSA_KEY_STROBE_NUM; col++) {
140 /*
141 * Discharge the output driver capacitatance
142 * in the keyboard matrix. (Yes it is significant..)
143 */
144 tosakbd_discharge_all();
145 udelay(KB_DISCHARGE_DELAY);
146
147 tosakbd_activate_col(col);
148 udelay(KB_ACTIVATE_DELAY);
149
150 rowd = GET_ROWS_STATUS(col);
151
152 for (row = 0; row < TOSA_KEY_SENSE_NUM; row++) {
153 unsigned int scancode, pressed;
154 scancode = SCANCODE(row, col);
155 pressed = rowd & KB_ROWMASK(row);
156
157 if (pressed && !tosakbd->keycode[scancode])
158 dev_warn(&dev->dev,
159 "unhandled scancode: 0x%02x\n",
160 scancode);
161
162 input_report_key(tosakbd->input,
163 tosakbd->keycode[scancode],
164 pressed);
165 if (pressed)
166 num_pressed++;
167 }
168
169 tosakbd_reset_col(col);
170 }
171
172 tosakbd_activate_all();
173
174 input_sync(tosakbd->input);
175
176 /* if any keys are pressed, enable the timer */
177 if (num_pressed)
178 mod_timer(&tosakbd->timer, jiffies + SCAN_INTERVAL);
179
180 out:
181 spin_unlock_irqrestore(&tosakbd->lock, flags);
182}
183
184/*
185 * tosa keyboard interrupt handler.
186 */
187static irqreturn_t tosakbd_interrupt(int irq, void *__dev)
188{
189 struct platform_device *dev = __dev;
190 struct tosakbd *tosakbd = platform_get_drvdata(dev);
191
192 if (!timer_pending(&tosakbd->timer)) {
193 /** wait chattering delay **/
194 udelay(20);
195 tosakbd_scankeyboard(dev);
196 }
197
198 return IRQ_HANDLED;
199}
200
201/*
202 * tosa timer checking for released keys
203 */
204static void tosakbd_timer_callback(unsigned long __dev)
205{
206 struct platform_device *dev = (struct platform_device *)__dev;
207
208 tosakbd_scankeyboard(dev);
209}
210
211#ifdef CONFIG_PM
212static int tosakbd_suspend(struct platform_device *dev, pm_message_t state)
213{
214 struct tosakbd *tosakbd = platform_get_drvdata(dev);
215 unsigned long flags;
216
217 spin_lock_irqsave(&tosakbd->lock, flags);
218 tosakbd->suspended = true;
219 spin_unlock_irqrestore(&tosakbd->lock, flags);
220
221 del_timer_sync(&tosakbd->timer);
222
223 return 0;
224}
225
226static int tosakbd_resume(struct platform_device *dev)
227{
228 struct tosakbd *tosakbd = platform_get_drvdata(dev);
229
230 tosakbd->suspended = false;
231 tosakbd_scankeyboard(dev);
232
233 return 0;
234}
235#else
236#define tosakbd_suspend NULL
237#define tosakbd_resume NULL
238#endif
239
240static int __devinit tosakbd_probe(struct platform_device *pdev) {
241
242 int i;
243 struct tosakbd *tosakbd;
244 struct input_dev *input_dev;
245 int error;
246
247 tosakbd = kzalloc(sizeof(struct tosakbd), GFP_KERNEL);
248 if (!tosakbd)
249 return -ENOMEM;
250
251 input_dev = input_allocate_device();
252 if (!input_dev) {
253 kfree(tosakbd);
254 return -ENOMEM;
255 }
256
257 platform_set_drvdata(pdev, tosakbd);
258
259 spin_lock_init(&tosakbd->lock);
260
261 /* Init Keyboard rescan timer */
262 init_timer(&tosakbd->timer);
263 tosakbd->timer.function = tosakbd_timer_callback;
264 tosakbd->timer.data = (unsigned long) pdev;
265
266 tosakbd->input = input_dev;
267
268 input_set_drvdata(input_dev, tosakbd);
269 input_dev->name = "Tosa Keyboard";
270 input_dev->phys = "tosakbd/input0";
271 input_dev->dev.parent = &pdev->dev;
272
273 input_dev->id.bustype = BUS_HOST;
274 input_dev->id.vendor = 0x0001;
275 input_dev->id.product = 0x0001;
276 input_dev->id.version = 0x0100;
277
278 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
279 input_dev->keycode = tosakbd->keycode;
280 input_dev->keycodesize = sizeof(tosakbd->keycode[0]);
281 input_dev->keycodemax = ARRAY_SIZE(tosakbd_keycode);
282
283 memcpy(tosakbd->keycode, tosakbd_keycode, sizeof(tosakbd_keycode));
284
285 for (i = 0; i < ARRAY_SIZE(tosakbd_keycode); i++)
286 __set_bit(tosakbd->keycode[i], input_dev->keybit);
287 __clear_bit(KEY_RESERVED, input_dev->keybit);
288
289 /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */
290 for (i = 0; i < TOSA_KEY_SENSE_NUM; i++) {
291 int gpio = TOSA_GPIO_KEY_SENSE(i);
292 int irq;
293 error = gpio_request(gpio, "tosakbd");
294 if (error < 0) {
295 printk(KERN_ERR "tosakbd: failed to request GPIO %d, "
296 " error %d\n", gpio, error);
297 goto fail;
298 }
299
300 error = gpio_direction_input(TOSA_GPIO_KEY_SENSE(i));
301 if (error < 0) {
302 printk(KERN_ERR "tosakbd: failed to configure input"
303 " direction for GPIO %d, error %d\n",
304 gpio, error);
305 gpio_free(gpio);
306 goto fail;
307 }
308
309 irq = gpio_to_irq(gpio);
310 if (irq < 0) {
311 error = irq;
312 printk(KERN_ERR "gpio-keys: Unable to get irq number"
313 " for GPIO %d, error %d\n",
314 gpio, error);
315 gpio_free(gpio);
316 goto fail;
317 }
318
319 error = request_irq(irq, tosakbd_interrupt,
320 IRQF_DISABLED | IRQF_TRIGGER_RISING,
321 "tosakbd", pdev);
322
323 if (error) {
324 printk("tosakbd: Can't get IRQ: %d: error %d!\n",
325 irq, error);
326 gpio_free(gpio);
327 goto fail;
328 }
329 }
330
331 /* Set Strobe lines as outputs - set high */
332 for (i = 0; i < TOSA_KEY_STROBE_NUM; i++) {
333 int gpio = TOSA_GPIO_KEY_STROBE(i);
334 error = gpio_request(gpio, "tosakbd");
335 if (error < 0) {
336 printk(KERN_ERR "tosakbd: failed to request GPIO %d, "
337 " error %d\n", gpio, error);
338 goto fail2;
339 }
340
341 error = gpio_direction_output(gpio, 1);
342 if (error < 0) {
343 printk(KERN_ERR "tosakbd: failed to configure input"
344 " direction for GPIO %d, error %d\n",
345 gpio, error);
346 gpio_free(gpio);
347 goto fail2;
348 }
349
350 }
351
352 error = input_register_device(input_dev);
353 if (error) {
354 printk(KERN_ERR "tosakbd: Unable to register input device, "
355 "error: %d\n", error);
356 goto fail2;
357 }
358
359 printk(KERN_INFO "input: Tosa Keyboard Registered\n");
360
361 return 0;
362
363fail2:
364 while (--i >= 0)
365 gpio_free(TOSA_GPIO_KEY_STROBE(i));
366
367 i = TOSA_KEY_SENSE_NUM;
368fail:
369 while (--i >= 0) {
370 free_irq(gpio_to_irq(TOSA_GPIO_KEY_SENSE(i)), pdev);
371 gpio_free(TOSA_GPIO_KEY_SENSE(i));
372 }
373
374 platform_set_drvdata(pdev, NULL);
375 input_free_device(input_dev);
376 kfree(tosakbd);
377
378 return error;
379}
380
381static int __devexit tosakbd_remove(struct platform_device *dev)
382{
383 int i;
384 struct tosakbd *tosakbd = platform_get_drvdata(dev);
385
386 for (i = 0; i < TOSA_KEY_STROBE_NUM; i++)
387 gpio_free(TOSA_GPIO_KEY_STROBE(i));
388
389 for (i = 0; i < TOSA_KEY_SENSE_NUM; i++) {
390 free_irq(gpio_to_irq(TOSA_GPIO_KEY_SENSE(i)), dev);
391 gpio_free(TOSA_GPIO_KEY_SENSE(i));
392 }
393
394 del_timer_sync(&tosakbd->timer);
395
396 input_unregister_device(tosakbd->input);
397
398 kfree(tosakbd);
399
400 return 0;
401}
402
403static struct platform_driver tosakbd_driver = {
404 .probe = tosakbd_probe,
405 .remove = __devexit_p(tosakbd_remove),
406 .suspend = tosakbd_suspend,
407 .resume = tosakbd_resume,
408 .driver = {
409 .name = "tosa-keyboard",
410 .owner = THIS_MODULE,
411 },
412};
413
414static int __devinit tosakbd_init(void)
415{
416 return platform_driver_register(&tosakbd_driver);
417}
418
419static void __exit tosakbd_exit(void)
420{
421 platform_driver_unregister(&tosakbd_driver);
422}
423
424module_init(tosakbd_init);
425module_exit(tosakbd_exit);
426
427MODULE_AUTHOR("Dirk Opfer <Dirk@Opfer-Online.de>");
428MODULE_DESCRIPTION("Tosa Keyboard Driver");
429MODULE_LICENSE("GPL v2");
430MODULE_ALIAS("platform:tosa-keyboard");
diff --git a/drivers/input/keyboard/twl4030_keypad.c b/drivers/input/keyboard/twl4030_keypad.c
index 21d6184efa9..7aa59e07b68 100644
--- a/drivers/input/keyboard/twl4030_keypad.c
+++ b/drivers/input/keyboard/twl4030_keypad.c
@@ -32,6 +32,7 @@
32#include <linux/input.h> 32#include <linux/input.h>
33#include <linux/platform_device.h> 33#include <linux/platform_device.h>
34#include <linux/i2c/twl.h> 34#include <linux/i2c/twl.h>
35#include <linux/slab.h>
35 36
36 37
37/* 38/*
diff --git a/drivers/input/keyboard/w90p910_keypad.c b/drivers/input/keyboard/w90p910_keypad.c
index 6032def0370..4ef764cc493 100644
--- a/drivers/input/keyboard/w90p910_keypad.c
+++ b/drivers/input/keyboard/w90p910_keypad.c
@@ -19,6 +19,7 @@
19#include <linux/clk.h> 19#include <linux/clk.h>
20#include <linux/err.h> 20#include <linux/err.h>
21#include <linux/io.h> 21#include <linux/io.h>
22#include <linux/slab.h>
22 23
23#include <mach/w90p910_keypad.h> 24#include <mach/w90p910_keypad.h>
24 25
diff --git a/drivers/input/misc/88pm860x_onkey.c b/drivers/input/misc/88pm860x_onkey.c
index 69a48e8701b..40dabd8487b 100644
--- a/drivers/input/misc/88pm860x_onkey.c
+++ b/drivers/input/misc/88pm860x_onkey.c
@@ -25,6 +25,7 @@
25#include <linux/input.h> 25#include <linux/input.h>
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/mfd/88pm860x.h> 27#include <linux/mfd/88pm860x.h>
28#include <linux/slab.h>
28 29
29#define PM8607_WAKEUP 0x0b 30#define PM8607_WAKEUP 0x0b
30 31
diff --git a/drivers/input/misc/ati_remote.c b/drivers/input/misc/ati_remote.c
index 614b65d78fe..e8bbc619f6d 100644
--- a/drivers/input/misc/ati_remote.c
+++ b/drivers/input/misc/ati_remote.c
@@ -98,10 +98,12 @@
98 * Module and Version Information, Module Parameters 98 * Module and Version Information, Module Parameters
99 */ 99 */
100 100
101#define ATI_REMOTE_VENDOR_ID 0x0bc7 101#define ATI_REMOTE_VENDOR_ID 0x0bc7
102#define ATI_REMOTE_PRODUCT_ID 0x004 102#define LOLA_REMOTE_PRODUCT_ID 0x0002
103#define LOLA_REMOTE_PRODUCT_ID 0x002 103#define LOLA2_REMOTE_PRODUCT_ID 0x0003
104#define MEDION_REMOTE_PRODUCT_ID 0x006 104#define ATI_REMOTE_PRODUCT_ID 0x0004
105#define NVIDIA_REMOTE_PRODUCT_ID 0x0005
106#define MEDION_REMOTE_PRODUCT_ID 0x0006
105 107
106#define DRIVER_VERSION "2.2.1" 108#define DRIVER_VERSION "2.2.1"
107#define DRIVER_AUTHOR "Torrey Hoffman <thoffman@arnor.net>" 109#define DRIVER_AUTHOR "Torrey Hoffman <thoffman@arnor.net>"
@@ -142,8 +144,10 @@ MODULE_PARM_DESC(repeat_delay, "Delay before sending repeats, default = 500 msec
142#define err(format, arg...) printk(KERN_ERR format , ## arg) 144#define err(format, arg...) printk(KERN_ERR format , ## arg)
143 145
144static struct usb_device_id ati_remote_table[] = { 146static struct usb_device_id ati_remote_table[] = {
145 { USB_DEVICE(ATI_REMOTE_VENDOR_ID, ATI_REMOTE_PRODUCT_ID) },
146 { USB_DEVICE(ATI_REMOTE_VENDOR_ID, LOLA_REMOTE_PRODUCT_ID) }, 147 { USB_DEVICE(ATI_REMOTE_VENDOR_ID, LOLA_REMOTE_PRODUCT_ID) },
148 { USB_DEVICE(ATI_REMOTE_VENDOR_ID, LOLA2_REMOTE_PRODUCT_ID) },
149 { USB_DEVICE(ATI_REMOTE_VENDOR_ID, ATI_REMOTE_PRODUCT_ID) },
150 { USB_DEVICE(ATI_REMOTE_VENDOR_ID, NVIDIA_REMOTE_PRODUCT_ID) },
147 { USB_DEVICE(ATI_REMOTE_VENDOR_ID, MEDION_REMOTE_PRODUCT_ID) }, 151 { USB_DEVICE(ATI_REMOTE_VENDOR_ID, MEDION_REMOTE_PRODUCT_ID) },
148 {} /* Terminating entry */ 152 {} /* Terminating entry */
149}; 153};
diff --git a/drivers/input/misc/ati_remote2.c b/drivers/input/misc/ati_remote2.c
index 15be5430bc6..2124b99378b 100644
--- a/drivers/input/misc/ati_remote2.c
+++ b/drivers/input/misc/ati_remote2.c
@@ -10,6 +10,7 @@
10 */ 10 */
11 11
12#include <linux/usb/input.h> 12#include <linux/usb/input.h>
13#include <linux/slab.h>
13 14
14#define DRIVER_DESC "ATI/Philips USB RF remote driver" 15#define DRIVER_DESC "ATI/Philips USB RF remote driver"
15#define DRIVER_VERSION "0.3" 16#define DRIVER_VERSION "0.3"
diff --git a/drivers/input/misc/bfin_rotary.c b/drivers/input/misc/bfin_rotary.c
index 61d10177fa8..4f72bdd6941 100644
--- a/drivers/input/misc/bfin_rotary.c
+++ b/drivers/input/misc/bfin_rotary.c
@@ -13,6 +13,7 @@
13#include <linux/pm.h> 13#include <linux/pm.h>
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/input.h> 15#include <linux/input.h>
16#include <linux/slab.h>
16 17
17#include <asm/portmux.h> 18#include <asm/portmux.h>
18#include <asm/bfin_rotary.h> 19#include <asm/bfin_rotary.h>
diff --git a/drivers/input/misc/cobalt_btns.c b/drivers/input/misc/cobalt_btns.c
index ee73d7219c9..fd8407a2963 100644
--- a/drivers/input/misc/cobalt_btns.c
+++ b/drivers/input/misc/cobalt_btns.c
@@ -22,6 +22,7 @@
22#include <linux/ioport.h> 22#include <linux/ioport.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/slab.h>
25 26
26#define BUTTONS_POLL_INTERVAL 30 /* msec */ 27#define BUTTONS_POLL_INTERVAL 30 /* msec */
27#define BUTTONS_COUNT_THRESHOLD 3 28#define BUTTONS_COUNT_THRESHOLD 3
diff --git a/drivers/input/misc/dm355evm_keys.c b/drivers/input/misc/dm355evm_keys.c
index 766c06911f4..19af682c24f 100644
--- a/drivers/input/misc/dm355evm_keys.c
+++ b/drivers/input/misc/dm355evm_keys.c
@@ -10,6 +10,7 @@
10 */ 10 */
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/slab.h>
13#include <linux/input.h> 14#include <linux/input.h>
14#include <linux/input/sparse-keymap.h> 15#include <linux/input/sparse-keymap.h>
15#include <linux/platform_device.h> 16#include <linux/platform_device.h>
diff --git a/drivers/input/misc/pcap_keys.c b/drivers/input/misc/pcap_keys.c
index 7ea969347ca..99335c28625 100644
--- a/drivers/input/misc/pcap_keys.c
+++ b/drivers/input/misc/pcap_keys.c
@@ -17,6 +17,7 @@
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/input.h> 18#include <linux/input.h>
19#include <linux/mfd/ezx-pcap.h> 19#include <linux/mfd/ezx-pcap.h>
20#include <linux/slab.h>
20 21
21struct pcap_keys { 22struct pcap_keys {
22 struct pcap_chip *pcap; 23 struct pcap_chip *pcap;
diff --git a/drivers/input/misc/pcf50633-input.c b/drivers/input/misc/pcf50633-input.c
index 008de0c5834..95562735728 100644
--- a/drivers/input/misc/pcf50633-input.c
+++ b/drivers/input/misc/pcf50633-input.c
@@ -20,6 +20,7 @@
20#include <linux/device.h> 20#include <linux/device.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/input.h> 22#include <linux/input.h>
23#include <linux/slab.h>
23 24
24#include <linux/mfd/pcf50633/core.h> 25#include <linux/mfd/pcf50633/core.h>
25 26
diff --git a/drivers/input/misc/rotary_encoder.c b/drivers/input/misc/rotary_encoder.c
index 4ae07935985..1f8e0108962 100644
--- a/drivers/input/misc/rotary_encoder.c
+++ b/drivers/input/misc/rotary_encoder.c
@@ -22,6 +22,7 @@
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/gpio.h> 23#include <linux/gpio.h>
24#include <linux/rotary_encoder.h> 24#include <linux/rotary_encoder.h>
25#include <linux/slab.h>
25 26
26#define DRV_NAME "rotary-encoder" 27#define DRV_NAME "rotary-encoder"
27 28
diff --git a/drivers/input/misc/sgi_btns.c b/drivers/input/misc/sgi_btns.c
index be3a15f5b25..1a80c0dab83 100644
--- a/drivers/input/misc/sgi_btns.c
+++ b/drivers/input/misc/sgi_btns.c
@@ -22,6 +22,7 @@
22#include <linux/ioport.h> 22#include <linux/ioport.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/slab.h>
25 26
26#ifdef CONFIG_SGI_IP22 27#ifdef CONFIG_SGI_IP22
27#include <asm/sgi/ioc.h> 28#include <asm/sgi/ioc.h>
diff --git a/drivers/input/misc/sparcspkr.c b/drivers/input/misc/sparcspkr.c
index b064419b90a..0d45422f809 100644
--- a/drivers/input/misc/sparcspkr.c
+++ b/drivers/input/misc/sparcspkr.c
@@ -9,6 +9,7 @@
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/input.h> 10#include <linux/input.h>
11#include <linux/of_device.h> 11#include <linux/of_device.h>
12#include <linux/slab.h>
12 13
13#include <asm/io.h> 14#include <asm/io.h>
14 15
diff --git a/drivers/input/misc/twl4030-vibra.c b/drivers/input/misc/twl4030-vibra.c
index 2fb79e064da..fee9eac8e04 100644
--- a/drivers/input/misc/twl4030-vibra.c
+++ b/drivers/input/misc/twl4030-vibra.c
@@ -30,6 +30,7 @@
30#include <linux/i2c/twl.h> 30#include <linux/i2c/twl.h>
31#include <linux/mfd/twl4030-codec.h> 31#include <linux/mfd/twl4030-codec.h>
32#include <linux/input.h> 32#include <linux/input.h>
33#include <linux/slab.h>
33 34
34/* MODULE ID2 */ 35/* MODULE ID2 */
35#define LEDEN 0x00 36#define LEDEN 0x00
diff --git a/drivers/input/misc/winbond-cir.c b/drivers/input/misc/winbond-cir.c
index 9c155a43abc..64f1de7960c 100644
--- a/drivers/input/misc/winbond-cir.c
+++ b/drivers/input/misc/winbond-cir.c
@@ -56,6 +56,7 @@
56#include <linux/io.h> 56#include <linux/io.h>
57#include <linux/bitrev.h> 57#include <linux/bitrev.h>
58#include <linux/bitops.h> 58#include <linux/bitops.h>
59#include <linux/slab.h>
59 60
60#define DRVNAME "winbond-cir" 61#define DRVNAME "winbond-cir"
61 62
diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c
index c0afb71a3a6..04d5a4a3181 100644
--- a/drivers/input/misc/wistron_btns.c
+++ b/drivers/input/misc/wistron_btns.c
@@ -29,6 +29,7 @@
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/preempt.h> 30#include <linux/preempt.h>
31#include <linux/string.h> 31#include <linux/string.h>
32#include <linux/slab.h>
32#include <linux/types.h> 33#include <linux/types.h>
33#include <linux/platform_device.h> 34#include <linux/platform_device.h>
34#include <linux/leds.h> 35#include <linux/leds.h>
diff --git a/drivers/input/misc/wm831x-on.c b/drivers/input/misc/wm831x-on.c
index 1e54bce72db..c3d7ba5f5b4 100644
--- a/drivers/input/misc/wm831x-on.c
+++ b/drivers/input/misc/wm831x-on.c
@@ -19,6 +19,7 @@
19 19
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/slab.h>
22#include <linux/kernel.h> 23#include <linux/kernel.h>
23#include <linux/errno.h> 24#include <linux/errno.h>
24#include <linux/input.h> 25#include <linux/input.h>
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
index 7490f1da4a5..99d58764ef0 100644
--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -15,6 +15,7 @@
15 * the Free Software Foundation. 15 * the Free Software Foundation.
16 */ 16 */
17 17
18#include <linux/slab.h>
18#include <linux/input.h> 19#include <linux/input.h>
19#include <linux/serio.h> 20#include <linux/serio.h>
20#include <linux/libps2.h> 21#include <linux/libps2.h>
diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c
index 4f8fe0886b2..b89879bd860 100644
--- a/drivers/input/mouse/bcm5974.c
+++ b/drivers/input/mouse/bcm5974.c
@@ -803,7 +803,6 @@ static struct usb_driver bcm5974_driver = {
803 .disconnect = bcm5974_disconnect, 803 .disconnect = bcm5974_disconnect,
804 .suspend = bcm5974_suspend, 804 .suspend = bcm5974_suspend,
805 .resume = bcm5974_resume, 805 .resume = bcm5974_resume,
806 .reset_resume = bcm5974_resume,
807 .id_table = bcm5974_table, 806 .id_table = bcm5974_table,
808 .supports_autosuspend = 1, 807 .supports_autosuspend = 1,
809}; 808};
diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index b27684f267b..0520c2e1992 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -11,6 +11,7 @@
11 */ 11 */
12 12
13#include <linux/delay.h> 13#include <linux/delay.h>
14#include <linux/slab.h>
14#include <linux/module.h> 15#include <linux/module.h>
15#include <linux/input.h> 16#include <linux/input.h>
16#include <linux/serio.h> 17#include <linux/serio.h>
@@ -24,6 +25,10 @@
24 printk(KERN_DEBUG format, ##arg); \ 25 printk(KERN_DEBUG format, ##arg); \
25 } while (0) 26 } while (0)
26 27
28static bool force_elantech;
29module_param_named(force_elantech, force_elantech, bool, 0644);
30MODULE_PARM_DESC(force_elantech, "Force the Elantech PS/2 protocol extension to be used, 1 = enabled, 0 = disabled (default).");
31
27/* 32/*
28 * Send a Synaptics style sliced query command 33 * Send a Synaptics style sliced query command
29 */ 34 */
@@ -181,13 +186,17 @@ static void elantech_report_absolute_v1(struct psmouse *psmouse)
181 static int old_fingers; 186 static int old_fingers;
182 187
183 if (etd->fw_version_maj == 0x01) { 188 if (etd->fw_version_maj == 0x01) {
184 /* byte 0: D U p1 p2 1 p3 R L 189 /*
185 byte 1: f 0 th tw x9 x8 y9 y8 */ 190 * byte 0: D U p1 p2 1 p3 R L
191 * byte 1: f 0 th tw x9 x8 y9 y8
192 */
186 fingers = ((packet[1] & 0x80) >> 7) + 193 fingers = ((packet[1] & 0x80) >> 7) +
187 ((packet[1] & 0x30) >> 4); 194 ((packet[1] & 0x30) >> 4);
188 } else { 195 } else {
189 /* byte 0: n1 n0 p2 p1 1 p3 R L 196 /*
190 byte 1: 0 0 0 0 x9 x8 y9 y8 */ 197 * byte 0: n1 n0 p2 p1 1 p3 R L
198 * byte 1: 0 0 0 0 x9 x8 y9 y8
199 */
191 fingers = (packet[0] & 0xc0) >> 6; 200 fingers = (packet[0] & 0xc0) >> 6;
192 } 201 }
193 202
@@ -201,13 +210,15 @@ static void elantech_report_absolute_v1(struct psmouse *psmouse)
201 210
202 input_report_key(dev, BTN_TOUCH, fingers != 0); 211 input_report_key(dev, BTN_TOUCH, fingers != 0);
203 212
204 /* byte 2: x7 x6 x5 x4 x3 x2 x1 x0 213 /*
205 byte 3: y7 y6 y5 y4 y3 y2 y1 y0 */ 214 * byte 2: x7 x6 x5 x4 x3 x2 x1 x0
215 * byte 3: y7 y6 y5 y4 y3 y2 y1 y0
216 */
206 if (fingers) { 217 if (fingers) {
207 input_report_abs(dev, ABS_X, 218 input_report_abs(dev, ABS_X,
208 ((packet[1] & 0x0c) << 6) | packet[2]); 219 ((packet[1] & 0x0c) << 6) | packet[2]);
209 input_report_abs(dev, ABS_Y, ETP_YMAX_V1 - 220 input_report_abs(dev, ABS_Y,
210 (((packet[1] & 0x03) << 8) | packet[3])); 221 ETP_YMAX_V1 - (((packet[1] & 0x03) << 8) | packet[3]));
211 } 222 }
212 223
213 input_report_key(dev, BTN_TOOL_FINGER, fingers == 1); 224 input_report_key(dev, BTN_TOOL_FINGER, fingers == 1);
@@ -246,34 +257,47 @@ static void elantech_report_absolute_v2(struct psmouse *psmouse)
246 257
247 switch (fingers) { 258 switch (fingers) {
248 case 1: 259 case 1:
249 /* byte 1: x15 x14 x13 x12 x11 x10 x9 x8 260 /*
250 byte 2: x7 x6 x5 x4 x4 x2 x1 x0 */ 261 * byte 1: . . . . . x10 x9 x8
251 input_report_abs(dev, ABS_X, (packet[1] << 8) | packet[2]); 262 * byte 2: x7 x6 x5 x4 x4 x2 x1 x0
252 /* byte 4: y15 y14 y13 y12 y11 y10 y8 y8 263 */
253 byte 5: y7 y6 y5 y4 y3 y2 y1 y0 */ 264 input_report_abs(dev, ABS_X,
254 input_report_abs(dev, ABS_Y, ETP_YMAX_V2 - 265 ((packet[1] & 0x07) << 8) | packet[2]);
255 ((packet[4] << 8) | packet[5])); 266 /*
267 * byte 4: . . . . . . y9 y8
268 * byte 5: y7 y6 y5 y4 y3 y2 y1 y0
269 */
270 input_report_abs(dev, ABS_Y,
271 ETP_YMAX_V2 - (((packet[4] & 0x03) << 8) | packet[5]));
256 break; 272 break;
257 273
258 case 2: 274 case 2:
259 /* The coordinate of each finger is reported separately with 275 /*
260 a lower resolution for two finger touches */ 276 * The coordinate of each finger is reported separately
261 /* byte 0: . . ay8 ax8 . . . . 277 * with a lower resolution for two finger touches:
262 byte 1: ax7 ax6 ax5 ax4 ax3 ax2 ax1 ax0 */ 278 * byte 0: . . ay8 ax8 . . . .
279 * byte 1: ax7 ax6 ax5 ax4 ax3 ax2 ax1 ax0
280 */
263 x1 = ((packet[0] & 0x10) << 4) | packet[1]; 281 x1 = ((packet[0] & 0x10) << 4) | packet[1];
264 /* byte 2: ay7 ay6 ay5 ay4 ay3 ay2 ay1 ay0 */ 282 /* byte 2: ay7 ay6 ay5 ay4 ay3 ay2 ay1 ay0 */
265 y1 = ETP_2FT_YMAX - (((packet[0] & 0x20) << 3) | packet[2]); 283 y1 = ETP_2FT_YMAX - (((packet[0] & 0x20) << 3) | packet[2]);
266 /* byte 3: . . by8 bx8 . . . . 284 /*
267 byte 4: bx7 bx6 bx5 bx4 bx3 bx2 bx1 bx0 */ 285 * byte 3: . . by8 bx8 . . . .
286 * byte 4: bx7 bx6 bx5 bx4 bx3 bx2 bx1 bx0
287 */
268 x2 = ((packet[3] & 0x10) << 4) | packet[4]; 288 x2 = ((packet[3] & 0x10) << 4) | packet[4];
269 /* byte 5: by7 by8 by5 by4 by3 by2 by1 by0 */ 289 /* byte 5: by7 by8 by5 by4 by3 by2 by1 by0 */
270 y2 = ETP_2FT_YMAX - (((packet[3] & 0x20) << 3) | packet[5]); 290 y2 = ETP_2FT_YMAX - (((packet[3] & 0x20) << 3) | packet[5]);
271 /* For compatibility with the X Synaptics driver scale up one 291 /*
272 coordinate and report as ordinary mouse movent */ 292 * For compatibility with the X Synaptics driver scale up
293 * one coordinate and report as ordinary mouse movent
294 */
273 input_report_abs(dev, ABS_X, x1 << 2); 295 input_report_abs(dev, ABS_X, x1 << 2);
274 input_report_abs(dev, ABS_Y, y1 << 2); 296 input_report_abs(dev, ABS_Y, y1 << 2);
275 /* For compatibility with the proprietary X Elantech driver 297 /*
276 report both coordinates as hat coordinates */ 298 * For compatibility with the proprietary X Elantech driver
299 * report both coordinates as hat coordinates
300 */
277 input_report_abs(dev, ABS_HAT0X, x1); 301 input_report_abs(dev, ABS_HAT0X, x1);
278 input_report_abs(dev, ABS_HAT0Y, y1); 302 input_report_abs(dev, ABS_HAT0Y, y1);
279 input_report_abs(dev, ABS_HAT1X, x2); 303 input_report_abs(dev, ABS_HAT1X, x2);
@@ -595,8 +619,12 @@ int elantech_detect(struct psmouse *psmouse, bool set_properties)
595 param[0], param[1], param[2]); 619 param[0], param[1], param[2]);
596 620
597 if (param[0] == 0 || param[1] != 0) { 621 if (param[0] == 0 || param[1] != 0) {
598 pr_debug("elantech.c: Probably not a real Elantech touchpad. Aborting.\n"); 622 if (!force_elantech) {
599 return -1; 623 pr_debug("elantech.c: Probably not a real Elantech touchpad. Aborting.\n");
624 return -1;
625 }
626
627 pr_debug("elantech.c: Probably not a real Elantech touchpad. Enabling anyway due to force_elantech.\n");
600 } 628 }
601 629
602 if (set_properties) { 630 if (set_properties) {
@@ -665,7 +693,8 @@ int elantech_init(struct psmouse *psmouse)
665 * Assume every version greater than this is new EeePC style 693 * Assume every version greater than this is new EeePC style
666 * hardware with 6 byte packets 694 * hardware with 6 byte packets
667 */ 695 */
668 if (etd->fw_version_maj >= 0x02 && etd->fw_version_min >= 0x30) { 696 if ((etd->fw_version_maj == 0x02 && etd->fw_version_min >= 0x30) ||
697 etd->fw_version_maj > 0x02) {
669 etd->hw_version = 2; 698 etd->hw_version = 2;
670 /* For now show extra debug information */ 699 /* For now show extra debug information */
671 etd->debug = 1; 700 etd->debug = 1;
diff --git a/drivers/input/mouse/hgpk.c b/drivers/input/mouse/hgpk.c
index 9169d1591c1..08d66d820d2 100644
--- a/drivers/input/mouse/hgpk.c
+++ b/drivers/input/mouse/hgpk.c
@@ -30,6 +30,7 @@
30 */ 30 */
31 31
32#define DEBUG 32#define DEBUG
33#include <linux/slab.h>
33#include <linux/input.h> 34#include <linux/input.h>
34#include <linux/serio.h> 35#include <linux/serio.h>
35#include <linux/libps2.h> 36#include <linux/libps2.h>
diff --git a/drivers/input/mouse/lifebook.c b/drivers/input/mouse/lifebook.c
index 7c1d7d420ae..c31ad11df6b 100644
--- a/drivers/input/mouse/lifebook.c
+++ b/drivers/input/mouse/lifebook.c
@@ -16,6 +16,7 @@
16#include <linux/serio.h> 16#include <linux/serio.h>
17#include <linux/libps2.h> 17#include <linux/libps2.h>
18#include <linux/dmi.h> 18#include <linux/dmi.h>
19#include <linux/slab.h>
19 20
20#include "psmouse.h" 21#include "psmouse.h"
21#include "lifebook.h" 22#include "lifebook.h"
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index d8c0c8d6992..cbc80726494 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -110,6 +110,7 @@ static struct workqueue_struct *kpsmoused_wq;
110struct psmouse_protocol { 110struct psmouse_protocol {
111 enum psmouse_type type; 111 enum psmouse_type type;
112 bool maxproto; 112 bool maxproto;
113 bool ignore_parity; /* Protocol should ignore parity errors from KBC */
113 const char *name; 114 const char *name;
114 const char *alias; 115 const char *alias;
115 int (*detect)(struct psmouse *, bool); 116 int (*detect)(struct psmouse *, bool);
@@ -288,7 +289,9 @@ static irqreturn_t psmouse_interrupt(struct serio *serio,
288 if (psmouse->state == PSMOUSE_IGNORE) 289 if (psmouse->state == PSMOUSE_IGNORE)
289 goto out; 290 goto out;
290 291
291 if (flags & (SERIO_PARITY|SERIO_TIMEOUT)) { 292 if (unlikely((flags & SERIO_TIMEOUT) ||
293 ((flags & SERIO_PARITY) && !psmouse->ignore_parity))) {
294
292 if (psmouse->state == PSMOUSE_ACTIVATED) 295 if (psmouse->state == PSMOUSE_ACTIVATED)
293 printk(KERN_WARNING "psmouse.c: bad data from KBC -%s%s\n", 296 printk(KERN_WARNING "psmouse.c: bad data from KBC -%s%s\n",
294 flags & SERIO_TIMEOUT ? " timeout" : "", 297 flags & SERIO_TIMEOUT ? " timeout" : "",
@@ -759,6 +762,7 @@ static const struct psmouse_protocol psmouse_protocols[] = {
759 .name = "PS/2", 762 .name = "PS/2",
760 .alias = "bare", 763 .alias = "bare",
761 .maxproto = true, 764 .maxproto = true,
765 .ignore_parity = true,
762 .detect = ps2bare_detect, 766 .detect = ps2bare_detect,
763 }, 767 },
764#ifdef CONFIG_MOUSE_PS2_LOGIPS2PP 768#ifdef CONFIG_MOUSE_PS2_LOGIPS2PP
@@ -786,6 +790,7 @@ static const struct psmouse_protocol psmouse_protocols[] = {
786 .name = "ImPS/2", 790 .name = "ImPS/2",
787 .alias = "imps", 791 .alias = "imps",
788 .maxproto = true, 792 .maxproto = true,
793 .ignore_parity = true,
789 .detect = intellimouse_detect, 794 .detect = intellimouse_detect,
790 }, 795 },
791 { 796 {
@@ -793,6 +798,7 @@ static const struct psmouse_protocol psmouse_protocols[] = {
793 .name = "ImExPS/2", 798 .name = "ImExPS/2",
794 .alias = "exps", 799 .alias = "exps",
795 .maxproto = true, 800 .maxproto = true,
801 .ignore_parity = true,
796 .detect = im_explorer_detect, 802 .detect = im_explorer_detect,
797 }, 803 },
798#ifdef CONFIG_MOUSE_PS2_SYNAPTICS 804#ifdef CONFIG_MOUSE_PS2_SYNAPTICS
@@ -1222,6 +1228,7 @@ static void psmouse_disconnect(struct serio *serio)
1222static int psmouse_switch_protocol(struct psmouse *psmouse, 1228static int psmouse_switch_protocol(struct psmouse *psmouse,
1223 const struct psmouse_protocol *proto) 1229 const struct psmouse_protocol *proto)
1224{ 1230{
1231 const struct psmouse_protocol *selected_proto;
1225 struct input_dev *input_dev = psmouse->dev; 1232 struct input_dev *input_dev = psmouse->dev;
1226 1233
1227 input_dev->dev.parent = &psmouse->ps2dev.serio->dev; 1234 input_dev->dev.parent = &psmouse->ps2dev.serio->dev;
@@ -1245,9 +1252,14 @@ static int psmouse_switch_protocol(struct psmouse *psmouse,
1245 return -1; 1252 return -1;
1246 1253
1247 psmouse->type = proto->type; 1254 psmouse->type = proto->type;
1248 } else 1255 selected_proto = proto;
1256 } else {
1249 psmouse->type = psmouse_extensions(psmouse, 1257 psmouse->type = psmouse_extensions(psmouse,
1250 psmouse_max_proto, true); 1258 psmouse_max_proto, true);
1259 selected_proto = psmouse_protocol_by_type(psmouse->type);
1260 }
1261
1262 psmouse->ignore_parity = selected_proto->ignore_parity;
1251 1263
1252 /* 1264 /*
1253 * If mouse's packet size is 3 there is no point in polling the 1265 * If mouse's packet size is 3 there is no point in polling the
@@ -1267,7 +1279,7 @@ static int psmouse_switch_protocol(struct psmouse *psmouse,
1267 psmouse->resync_time = 0; 1279 psmouse->resync_time = 0;
1268 1280
1269 snprintf(psmouse->devname, sizeof(psmouse->devname), "%s %s %s", 1281 snprintf(psmouse->devname, sizeof(psmouse->devname), "%s %s %s",
1270 psmouse_protocol_by_type(psmouse->type)->name, psmouse->vendor, psmouse->name); 1282 selected_proto->name, psmouse->vendor, psmouse->name);
1271 1283
1272 input_dev->name = psmouse->devname; 1284 input_dev->name = psmouse->devname;
1273 input_dev->phys = psmouse->phys; 1285 input_dev->phys = psmouse->phys;
diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
index e053bdd137f..593e910bfc7 100644
--- a/drivers/input/mouse/psmouse.h
+++ b/drivers/input/mouse/psmouse.h
@@ -47,6 +47,7 @@ struct psmouse {
47 unsigned char pktcnt; 47 unsigned char pktcnt;
48 unsigned char pktsize; 48 unsigned char pktsize;
49 unsigned char type; 49 unsigned char type;
50 bool ignore_parity;
50 bool acks_disable_command; 51 bool acks_disable_command;
51 unsigned int model; 52 unsigned int model;
52 unsigned long last; 53 unsigned long last;
diff --git a/drivers/input/mouse/pxa930_trkball.c b/drivers/input/mouse/pxa930_trkball.c
index 1e827ad0afb..943cfec1566 100644
--- a/drivers/input/mouse/pxa930_trkball.c
+++ b/drivers/input/mouse/pxa930_trkball.c
@@ -18,6 +18,7 @@
18#include <linux/platform_device.h> 18#include <linux/platform_device.h>
19#include <linux/delay.h> 19#include <linux/delay.h>
20#include <linux/io.h> 20#include <linux/io.h>
21#include <linux/slab.h>
21 22
22#include <mach/hardware.h> 23#include <mach/hardware.h>
23#include <mach/pxa930_trkball.h> 24#include <mach/pxa930_trkball.h>
diff --git a/drivers/input/mouse/sentelic.c b/drivers/input/mouse/sentelic.c
index 81a6b81cb2f..1242775fee1 100644
--- a/drivers/input/mouse/sentelic.c
+++ b/drivers/input/mouse/sentelic.c
@@ -26,6 +26,7 @@
26#include <linux/libps2.h> 26#include <linux/libps2.h>
27#include <linux/serio.h> 27#include <linux/serio.h>
28#include <linux/jiffies.h> 28#include <linux/jiffies.h>
29#include <linux/slab.h>
29 30
30#include "psmouse.h" 31#include "psmouse.h"
31#include "sentelic.h" 32#include "sentelic.h"
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index d3f5243fa09..ebd7a99efea 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -28,6 +28,7 @@
28#include <linux/input.h> 28#include <linux/input.h>
29#include <linux/serio.h> 29#include <linux/serio.h>
30#include <linux/libps2.h> 30#include <linux/libps2.h>
31#include <linux/slab.h>
31#include "psmouse.h" 32#include "psmouse.h"
32#include "synaptics.h" 33#include "synaptics.h"
33 34
@@ -136,7 +137,8 @@ static int synaptics_capability(struct psmouse *psmouse)
136 if (synaptics_send_cmd(psmouse, SYN_QUE_CAPABILITIES, cap)) 137 if (synaptics_send_cmd(psmouse, SYN_QUE_CAPABILITIES, cap))
137 return -1; 138 return -1;
138 priv->capabilities = (cap[0] << 16) | (cap[1] << 8) | cap[2]; 139 priv->capabilities = (cap[0] << 16) | (cap[1] << 8) | cap[2];
139 priv->ext_cap = 0; 140 priv->ext_cap = priv->ext_cap_0c = 0;
141
140 if (!SYN_CAP_VALID(priv->capabilities)) 142 if (!SYN_CAP_VALID(priv->capabilities))
141 return -1; 143 return -1;
142 144
@@ -149,7 +151,7 @@ static int synaptics_capability(struct psmouse *psmouse)
149 if (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 1) { 151 if (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 1) {
150 if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_CAPAB, cap)) { 152 if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_CAPAB, cap)) {
151 printk(KERN_ERR "Synaptics claims to have extended capabilities," 153 printk(KERN_ERR "Synaptics claims to have extended capabilities,"
152 " but I'm not able to read them."); 154 " but I'm not able to read them.\n");
153 } else { 155 } else {
154 priv->ext_cap = (cap[0] << 16) | (cap[1] << 8) | cap[2]; 156 priv->ext_cap = (cap[0] << 16) | (cap[1] << 8) | cap[2];
155 157
@@ -161,6 +163,16 @@ static int synaptics_capability(struct psmouse *psmouse)
161 priv->ext_cap &= 0xff0fff; 163 priv->ext_cap &= 0xff0fff;
162 } 164 }
163 } 165 }
166
167 if (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 4) {
168 if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_CAPAB_0C, cap)) {
169 printk(KERN_ERR "Synaptics claims to have extended capability 0x0c,"
170 " but I'm not able to read it.\n");
171 } else {
172 priv->ext_cap_0c = (cap[0] << 16) | (cap[1] << 8) | cap[2];
173 }
174 }
175
164 return 0; 176 return 0;
165} 177}
166 178
@@ -347,7 +359,15 @@ static void synaptics_parse_hw_state(unsigned char buf[], struct synaptics_data
347 hw->left = (buf[0] & 0x01) ? 1 : 0; 359 hw->left = (buf[0] & 0x01) ? 1 : 0;
348 hw->right = (buf[0] & 0x02) ? 1 : 0; 360 hw->right = (buf[0] & 0x02) ? 1 : 0;
349 361
350 if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities)) { 362 if (SYN_CAP_CLICKPAD(priv->ext_cap_0c)) {
363 /*
364 * Clickpad's button is transmitted as middle button,
365 * however, since it is primary button, we will report
366 * it as BTN_LEFT.
367 */
368 hw->left = ((buf[0] ^ buf[3]) & 0x01) ? 1 : 0;
369
370 } else if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities)) {
351 hw->middle = ((buf[0] ^ buf[3]) & 0x01) ? 1 : 0; 371 hw->middle = ((buf[0] ^ buf[3]) & 0x01) ? 1 : 0;
352 if (hw->w == 2) 372 if (hw->w == 2)
353 hw->scroll = (signed char)(buf[1]); 373 hw->scroll = (signed char)(buf[1]);
@@ -592,6 +612,12 @@ static void set_input_params(struct input_dev *dev, struct synaptics_data *priv)
592 612
593 dev->absres[ABS_X] = priv->x_res; 613 dev->absres[ABS_X] = priv->x_res;
594 dev->absres[ABS_Y] = priv->y_res; 614 dev->absres[ABS_Y] = priv->y_res;
615
616 if (SYN_CAP_CLICKPAD(priv->ext_cap_0c)) {
617 /* Clickpads report only left button */
618 __clear_bit(BTN_RIGHT, dev->keybit);
619 __clear_bit(BTN_MIDDLE, dev->keybit);
620 }
595} 621}
596 622
597static void synaptics_disconnect(struct psmouse *psmouse) 623static void synaptics_disconnect(struct psmouse *psmouse)
@@ -696,10 +722,10 @@ int synaptics_init(struct psmouse *psmouse)
696 722
697 priv->pkt_type = SYN_MODEL_NEWABS(priv->model_id) ? SYN_NEWABS : SYN_OLDABS; 723 priv->pkt_type = SYN_MODEL_NEWABS(priv->model_id) ? SYN_NEWABS : SYN_OLDABS;
698 724
699 printk(KERN_INFO "Synaptics Touchpad, model: %ld, fw: %ld.%ld, id: %#lx, caps: %#lx/%#lx\n", 725 printk(KERN_INFO "Synaptics Touchpad, model: %ld, fw: %ld.%ld, id: %#lx, caps: %#lx/%#lx/%#lx\n",
700 SYN_ID_MODEL(priv->identity), 726 SYN_ID_MODEL(priv->identity),
701 SYN_ID_MAJOR(priv->identity), SYN_ID_MINOR(priv->identity), 727 SYN_ID_MAJOR(priv->identity), SYN_ID_MINOR(priv->identity),
702 priv->model_id, priv->capabilities, priv->ext_cap); 728 priv->model_id, priv->capabilities, priv->ext_cap, priv->ext_cap_0c);
703 729
704 set_input_params(psmouse->dev, priv); 730 set_input_params(psmouse->dev, priv);
705 731
diff --git a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h
index f0f40a331dc..ae37c5d162a 100644
--- a/drivers/input/mouse/synaptics.h
+++ b/drivers/input/mouse/synaptics.h
@@ -18,6 +18,7 @@
18#define SYN_QUE_SERIAL_NUMBER_SUFFIX 0x07 18#define SYN_QUE_SERIAL_NUMBER_SUFFIX 0x07
19#define SYN_QUE_RESOLUTION 0x08 19#define SYN_QUE_RESOLUTION 0x08
20#define SYN_QUE_EXT_CAPAB 0x09 20#define SYN_QUE_EXT_CAPAB 0x09
21#define SYN_QUE_EXT_CAPAB_0C 0x0c
21 22
22/* synatics modes */ 23/* synatics modes */
23#define SYN_BIT_ABSOLUTE_MODE (1 << 7) 24#define SYN_BIT_ABSOLUTE_MODE (1 << 7)
@@ -48,6 +49,8 @@
48#define SYN_CAP_VALID(c) ((((c) & 0x00ff00) >> 8) == 0x47) 49#define SYN_CAP_VALID(c) ((((c) & 0x00ff00) >> 8) == 0x47)
49#define SYN_EXT_CAP_REQUESTS(c) (((c) & 0x700000) >> 20) 50#define SYN_EXT_CAP_REQUESTS(c) (((c) & 0x700000) >> 20)
50#define SYN_CAP_MULTI_BUTTON_NO(ec) (((ec) & 0x00f000) >> 12) 51#define SYN_CAP_MULTI_BUTTON_NO(ec) (((ec) & 0x00f000) >> 12)
52#define SYN_CAP_PRODUCT_ID(ec) (((ec) & 0xff0000) >> 16)
53#define SYN_CAP_CLICKPAD(ex0c) ((ex0c) & 0x100100)
51 54
52/* synaptics modes query bits */ 55/* synaptics modes query bits */
53#define SYN_MODE_ABSOLUTE(m) ((m) & (1 << 7)) 56#define SYN_MODE_ABSOLUTE(m) ((m) & (1 << 7))
@@ -96,6 +99,7 @@ struct synaptics_data {
96 unsigned long int model_id; /* Model-ID */ 99 unsigned long int model_id; /* Model-ID */
97 unsigned long int capabilities; /* Capabilities */ 100 unsigned long int capabilities; /* Capabilities */
98 unsigned long int ext_cap; /* Extended Capabilities */ 101 unsigned long int ext_cap; /* Extended Capabilities */
102 unsigned long int ext_cap_0c; /* Ext Caps from 0x0c query */
99 unsigned long int identity; /* Identification */ 103 unsigned long int identity; /* Identification */
100 int x_res; /* X resolution in units/mm */ 104 int x_res; /* X resolution in units/mm */
101 int y_res; /* Y resolution in units/mm */ 105 int y_res; /* Y resolution in units/mm */
diff --git a/drivers/input/mouse/synaptics_i2c.c b/drivers/input/mouse/synaptics_i2c.c
index 9867dfe2a63..8291e7399ff 100644
--- a/drivers/input/mouse/synaptics_i2c.c
+++ b/drivers/input/mouse/synaptics_i2c.c
@@ -17,6 +17,7 @@
17#include <linux/input.h> 17#include <linux/input.h>
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/workqueue.h> 19#include <linux/workqueue.h>
20#include <linux/slab.h>
20 21
21#define DRIVER_NAME "synaptics_i2c" 22#define DRIVER_NAME "synaptics_i2c"
22/* maximum product id is 15 characters */ 23/* maximum product id is 15 characters */
diff --git a/drivers/input/mouse/touchkit_ps2.c b/drivers/input/mouse/touchkit_ps2.c
index 909431c31ab..88121c59c3c 100644
--- a/drivers/input/mouse/touchkit_ps2.c
+++ b/drivers/input/mouse/touchkit_ps2.c
@@ -26,7 +26,6 @@
26 */ 26 */
27 27
28#include <linux/kernel.h> 28#include <linux/kernel.h>
29#include <linux/slab.h>
30 29
31#include <linux/input.h> 30#include <linux/input.h>
32#include <linux/serio.h> 31#include <linux/serio.h>
diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c
index 63d4a67830f..0643e49ca60 100644
--- a/drivers/input/mouse/trackpoint.c
+++ b/drivers/input/mouse/trackpoint.c
@@ -8,6 +8,7 @@
8 * Trademarks are the property of their respective owners. 8 * Trademarks are the property of their respective owners.
9 */ 9 */
10 10
11#include <linux/slab.h>
11#include <linux/delay.h> 12#include <linux/delay.h>
12#include <linux/serio.h> 13#include <linux/serio.h>
13#include <linux/module.h> 14#include <linux/module.h>
diff --git a/drivers/input/serio/altera_ps2.c b/drivers/input/serio/altera_ps2.c
index 320b7ca48bf..7998560a190 100644
--- a/drivers/input/serio/altera_ps2.c
+++ b/drivers/input/serio/altera_ps2.c
@@ -18,6 +18,7 @@
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/io.h> 20#include <linux/io.h>
21#include <linux/slab.h>
21 22
22#define DRV_NAME "altera_ps2" 23#define DRV_NAME "altera_ps2"
23 24
diff --git a/drivers/input/serio/at32psif.c b/drivers/input/serio/at32psif.c
index b54452a8c77..6ee8f0ddad5 100644
--- a/drivers/input/serio/at32psif.c
+++ b/drivers/input/serio/at32psif.c
@@ -18,6 +18,7 @@
18#include <linux/io.h> 18#include <linux/io.h>
19#include <linux/clk.h> 19#include <linux/clk.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/slab.h>
21 22
22/* PSIF register offsets */ 23/* PSIF register offsets */
23#define PSIF_CR 0x00 24#define PSIF_CR 0x00
diff --git a/drivers/input/serio/ct82c710.c b/drivers/input/serio/ct82c710.c
index d1380fc72cc..4a3084695c0 100644
--- a/drivers/input/serio/ct82c710.c
+++ b/drivers/input/serio/ct82c710.c
@@ -35,6 +35,7 @@
35#include <linux/errno.h> 35#include <linux/errno.h>
36#include <linux/err.h> 36#include <linux/err.h>
37#include <linux/platform_device.h> 37#include <linux/platform_device.h>
38#include <linux/slab.h>
38 39
39#include <asm/io.h> 40#include <asm/io.h>
40 41
diff --git a/drivers/input/serio/gscps2.c b/drivers/input/serio/gscps2.c
index 06addfa7cc4..3c287dd879d 100644
--- a/drivers/input/serio/gscps2.c
+++ b/drivers/input/serio/gscps2.c
@@ -24,6 +24,7 @@
24 24
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/slab.h>
27#include <linux/serio.h> 28#include <linux/serio.h>
28#include <linux/input.h> 29#include <linux/input.h>
29#include <linux/interrupt.h> 30#include <linux/interrupt.h>
diff --git a/drivers/input/serio/hil_mlc.c b/drivers/input/serio/hil_mlc.c
index 6cd03ebaf5f..c92f4edfee7 100644
--- a/drivers/input/serio/hil_mlc.c
+++ b/drivers/input/serio/hil_mlc.c
@@ -58,6 +58,7 @@
58#include <linux/module.h> 58#include <linux/module.h>
59#include <linux/init.h> 59#include <linux/init.h>
60#include <linux/interrupt.h> 60#include <linux/interrupt.h>
61#include <linux/slab.h>
61#include <linux/timer.h> 62#include <linux/timer.h>
62#include <linux/list.h> 63#include <linux/list.h>
63 64
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 9302ba0e48f..6440a8f5568 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -21,6 +21,7 @@
21#include <linux/rcupdate.h> 21#include <linux/rcupdate.h>
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/i8042.h> 23#include <linux/i8042.h>
24#include <linux/slab.h>
24 25
25#include <asm/io.h> 26#include <asm/io.h>
26 27
@@ -38,7 +39,7 @@ MODULE_PARM_DESC(noaux, "Do not probe or use AUX (mouse) port.");
38 39
39static bool i8042_nomux; 40static bool i8042_nomux;
40module_param_named(nomux, i8042_nomux, bool, 0); 41module_param_named(nomux, i8042_nomux, bool, 0);
41MODULE_PARM_DESC(nomux, "Do not check whether an active multiplexing conrtoller is present."); 42MODULE_PARM_DESC(nomux, "Do not check whether an active multiplexing controller is present.");
42 43
43static bool i8042_unlock; 44static bool i8042_unlock;
44module_param_named(unlock, i8042_unlock, bool, 0); 45module_param_named(unlock, i8042_unlock, bool, 0);
diff --git a/drivers/input/serio/libps2.c b/drivers/input/serio/libps2.c
index f3876acc3e8..980af94ba9c 100644
--- a/drivers/input/serio/libps2.c
+++ b/drivers/input/serio/libps2.c
@@ -14,7 +14,6 @@
14#include <linux/delay.h> 14#include <linux/delay.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/sched.h> 16#include <linux/sched.h>
17#include <linux/slab.h>
18#include <linux/interrupt.h> 17#include <linux/interrupt.h>
19#include <linux/input.h> 18#include <linux/input.h>
20#include <linux/serio.h> 19#include <linux/serio.h>
diff --git a/drivers/input/serio/parkbd.c b/drivers/input/serio/parkbd.c
index b089977e0ef..26b45936f9f 100644
--- a/drivers/input/serio/parkbd.c
+++ b/drivers/input/serio/parkbd.c
@@ -46,6 +46,7 @@
46 46
47#include <linux/module.h> 47#include <linux/module.h>
48#include <linux/parport.h> 48#include <linux/parport.h>
49#include <linux/slab.h>
49#include <linux/init.h> 50#include <linux/init.h>
50#include <linux/serio.h> 51#include <linux/serio.h>
51 52
diff --git a/drivers/input/serio/pcips2.c b/drivers/input/serio/pcips2.c
index 797314be7af..43494742541 100644
--- a/drivers/input/serio/pcips2.c
+++ b/drivers/input/serio/pcips2.c
@@ -15,6 +15,7 @@
15#include <linux/ioport.h> 15#include <linux/ioport.h>
16#include <linux/input.h> 16#include <linux/input.h>
17#include <linux/pci.h> 17#include <linux/pci.h>
18#include <linux/slab.h>
18#include <linux/init.h> 19#include <linux/init.h>
19#include <linux/serio.h> 20#include <linux/serio.h>
20#include <linux/delay.h> 21#include <linux/delay.h>
diff --git a/drivers/input/serio/q40kbd.c b/drivers/input/serio/q40kbd.c
index e36a0901646..5eb84b3b67f 100644
--- a/drivers/input/serio/q40kbd.c
+++ b/drivers/input/serio/q40kbd.c
@@ -36,6 +36,7 @@
36#include <linux/err.h> 36#include <linux/err.h>
37#include <linux/bitops.h> 37#include <linux/bitops.h>
38#include <linux/platform_device.h> 38#include <linux/platform_device.h>
39#include <linux/slab.h>
39 40
40#include <asm/io.h> 41#include <asm/io.h>
41#include <asm/uaccess.h> 42#include <asm/uaccess.h>
diff --git a/drivers/input/serio/rpckbd.c b/drivers/input/serio/rpckbd.c
index ed045c99f84..9da6fbcaaa7 100644
--- a/drivers/input/serio/rpckbd.c
+++ b/drivers/input/serio/rpckbd.c
@@ -34,6 +34,7 @@
34#include <linux/err.h> 34#include <linux/err.h>
35#include <linux/platform_device.h> 35#include <linux/platform_device.h>
36#include <linux/io.h> 36#include <linux/io.h>
37#include <linux/slab.h>
37 38
38#include <asm/irq.h> 39#include <asm/irq.h>
39#include <mach/hardware.h> 40#include <mach/hardware.h>
diff --git a/drivers/input/serio/xilinx_ps2.c b/drivers/input/serio/xilinx_ps2.c
index 8298e1f6823..f84f8e32e3f 100644
--- a/drivers/input/serio/xilinx_ps2.c
+++ b/drivers/input/serio/xilinx_ps2.c
@@ -19,6 +19,7 @@
19#include <linux/serio.h> 19#include <linux/serio.h>
20#include <linux/interrupt.h> 20#include <linux/interrupt.h>
21#include <linux/errno.h> 21#include <linux/errno.h>
22#include <linux/slab.h>
22#include <linux/init.h> 23#include <linux/init.h>
23#include <linux/list.h> 24#include <linux/list.h>
24#include <linux/io.h> 25#include <linux/io.h>
diff --git a/drivers/input/sparse-keymap.c b/drivers/input/sparse-keymap.c
index e6bde55e520..01424834476 100644
--- a/drivers/input/sparse-keymap.c
+++ b/drivers/input/sparse-keymap.c
@@ -15,6 +15,7 @@
15 15
16#include <linux/input.h> 16#include <linux/input.h>
17#include <linux/input/sparse-keymap.h> 17#include <linux/input/sparse-keymap.h>
18#include <linux/slab.h>
18 19
19MODULE_AUTHOR("Dmitry Torokhov <dtor@mail.ru>"); 20MODULE_AUTHOR("Dmitry Torokhov <dtor@mail.ru>");
20MODULE_DESCRIPTION("Generic support for sparse keymaps"); 21MODULE_DESCRIPTION("Generic support for sparse keymaps");
@@ -67,12 +68,14 @@ static int sparse_keymap_getkeycode(struct input_dev *dev,
67 unsigned int scancode, 68 unsigned int scancode,
68 unsigned int *keycode) 69 unsigned int *keycode)
69{ 70{
70 const struct key_entry *key = 71 const struct key_entry *key;
71 sparse_keymap_entry_from_scancode(dev, scancode);
72 72
73 if (key && key->type == KE_KEY) { 73 if (dev->keycode) {
74 *keycode = key->keycode; 74 key = sparse_keymap_entry_from_scancode(dev, scancode);
75 return 0; 75 if (key && key->type == KE_KEY) {
76 *keycode = key->keycode;
77 return 0;
78 }
76 } 79 }
77 80
78 return -EINVAL; 81 return -EINVAL;
@@ -85,17 +88,16 @@ static int sparse_keymap_setkeycode(struct input_dev *dev,
85 struct key_entry *key; 88 struct key_entry *key;
86 int old_keycode; 89 int old_keycode;
87 90
88 if (keycode < 0 || keycode > KEY_MAX) 91 if (dev->keycode) {
89 return -EINVAL; 92 key = sparse_keymap_entry_from_scancode(dev, scancode);
90 93 if (key && key->type == KE_KEY) {
91 key = sparse_keymap_entry_from_scancode(dev, scancode); 94 old_keycode = key->keycode;
92 if (key && key->type == KE_KEY) { 95 key->keycode = keycode;
93 old_keycode = key->keycode; 96 set_bit(keycode, dev->keybit);
94 key->keycode = keycode; 97 if (!sparse_keymap_entry_from_keycode(dev, old_keycode))
95 set_bit(keycode, dev->keybit); 98 clear_bit(old_keycode, dev->keybit);
96 if (!sparse_keymap_entry_from_keycode(dev, old_keycode)) 99 return 0;
97 clear_bit(old_keycode, dev->keybit); 100 }
98 return 0;
99 } 101 }
100 102
101 return -EINVAL; 103 return -EINVAL;
@@ -163,7 +165,7 @@ int sparse_keymap_setup(struct input_dev *dev,
163 return 0; 165 return 0;
164 166
165 err_out: 167 err_out:
166 kfree(keymap); 168 kfree(map);
167 return error; 169 return error;
168 170
169} 171}
@@ -175,14 +177,27 @@ EXPORT_SYMBOL(sparse_keymap_setup);
175 * 177 *
176 * This function is used to free memory allocated by sparse keymap 178 * This function is used to free memory allocated by sparse keymap
177 * in an input device that was set up by sparse_keymap_setup(). 179 * in an input device that was set up by sparse_keymap_setup().
180 * NOTE: It is safe to cal this function while input device is
181 * still registered (however the drivers should care not to try to
182 * use freed keymap and thus have to shut off interrups/polling
183 * before freeing the keymap).
178 */ 184 */
179void sparse_keymap_free(struct input_dev *dev) 185void sparse_keymap_free(struct input_dev *dev)
180{ 186{
187 unsigned long flags;
188
189 /*
190 * Take event lock to prevent racing with input_get_keycode()
191 * and input_set_keycode() if we are called while input device
192 * is still registered.
193 */
194 spin_lock_irqsave(&dev->event_lock, flags);
195
181 kfree(dev->keycode); 196 kfree(dev->keycode);
182 dev->keycode = NULL; 197 dev->keycode = NULL;
183 dev->keycodemax = 0; 198 dev->keycodemax = 0;
184 dev->getkeycode = NULL; 199
185 dev->setkeycode = NULL; 200 spin_unlock_irqrestore(&dev->event_lock, flags);
186} 201}
187EXPORT_SYMBOL(sparse_keymap_free); 202EXPORT_SYMBOL(sparse_keymap_free);
188 203
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index 8b5d2873f0c..f46502589e4 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -673,13 +673,15 @@ static int wacom_resume(struct usb_interface *intf)
673 int rv; 673 int rv;
674 674
675 mutex_lock(&wacom->lock); 675 mutex_lock(&wacom->lock);
676 if (wacom->open) { 676
677 /* switch to wacom mode first */
678 wacom_query_tablet_data(intf, features);
679
680 if (wacom->open)
677 rv = usb_submit_urb(wacom->irq, GFP_NOIO); 681 rv = usb_submit_urb(wacom->irq, GFP_NOIO);
678 /* switch to wacom mode if needed */ 682 else
679 if (!wacom_retrieve_hid_descriptor(intf, features))
680 wacom_query_tablet_data(intf, features);
681 } else
682 rv = 0; 683 rv = 0;
684
683 mutex_unlock(&wacom->lock); 685 mutex_unlock(&wacom->lock);
684 686
685 return rv; 687 return rv;
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index b3ba3437a2e..4a852d815c6 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -155,19 +155,19 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
155{ 155{
156 struct wacom_features *features = &wacom->features; 156 struct wacom_features *features = &wacom->features;
157 unsigned char *data = wacom->data; 157 unsigned char *data = wacom->data;
158 int x, y, prox; 158 int x, y, rw;
159 int rw = 0; 159 static int penData = 0;
160 int retval = 0;
161 160
162 if (data[0] != WACOM_REPORT_PENABLED) { 161 if (data[0] != WACOM_REPORT_PENABLED) {
163 dbg("wacom_graphire_irq: received unknown report #%d", data[0]); 162 dbg("wacom_graphire_irq: received unknown report #%d", data[0]);
164 goto exit; 163 return 0;
165 } 164 }
166 165
167 prox = data[1] & 0x80; 166 if (data[1] & 0x80) {
168 if (prox || wacom->id[0]) { 167 /* in prox and not a pad data */
169 if (prox) { 168 penData = 1;
170 switch ((data[1] >> 5) & 3) { 169
170 switch ((data[1] >> 5) & 3) {
171 171
172 case 0: /* Pen */ 172 case 0: /* Pen */
173 wacom->tool[0] = BTN_TOOL_PEN; 173 wacom->tool[0] = BTN_TOOL_PEN;
@@ -181,13 +181,23 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
181 181
182 case 2: /* Mouse with wheel */ 182 case 2: /* Mouse with wheel */
183 wacom_report_key(wcombo, BTN_MIDDLE, data[1] & 0x04); 183 wacom_report_key(wcombo, BTN_MIDDLE, data[1] & 0x04);
184 if (features->type == WACOM_G4 || features->type == WACOM_MO) {
185 rw = data[7] & 0x04 ? (data[7] & 0x03)-4 : (data[7] & 0x03);
186 wacom_report_rel(wcombo, REL_WHEEL, -rw);
187 } else
188 wacom_report_rel(wcombo, REL_WHEEL, -(signed char) data[6]);
184 /* fall through */ 189 /* fall through */
185 190
186 case 3: /* Mouse without wheel */ 191 case 3: /* Mouse without wheel */
187 wacom->tool[0] = BTN_TOOL_MOUSE; 192 wacom->tool[0] = BTN_TOOL_MOUSE;
188 wacom->id[0] = CURSOR_DEVICE_ID; 193 wacom->id[0] = CURSOR_DEVICE_ID;
194 wacom_report_key(wcombo, BTN_LEFT, data[1] & 0x01);
195 wacom_report_key(wcombo, BTN_RIGHT, data[1] & 0x02);
196 if (features->type == WACOM_G4 || features->type == WACOM_MO)
197 wacom_report_abs(wcombo, ABS_DISTANCE, data[6] & 0x3f);
198 else
199 wacom_report_abs(wcombo, ABS_DISTANCE, data[7] & 0x3f);
189 break; 200 break;
190 }
191 } 201 }
192 x = wacom_le16_to_cpu(&data[2]); 202 x = wacom_le16_to_cpu(&data[2]);
193 y = wacom_le16_to_cpu(&data[4]); 203 y = wacom_le16_to_cpu(&data[4]);
@@ -198,32 +208,36 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
198 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x01); 208 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x01);
199 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02); 209 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02);
200 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x04); 210 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x04);
201 } else {
202 wacom_report_key(wcombo, BTN_LEFT, data[1] & 0x01);
203 wacom_report_key(wcombo, BTN_RIGHT, data[1] & 0x02);
204 if (features->type == WACOM_G4 ||
205 features->type == WACOM_MO) {
206 wacom_report_abs(wcombo, ABS_DISTANCE, data[6] & 0x3f);
207 rw = (signed)(data[7] & 0x04) - (data[7] & 0x03);
208 } else {
209 wacom_report_abs(wcombo, ABS_DISTANCE, data[7] & 0x3f);
210 rw = -(signed)data[6];
211 }
212 wacom_report_rel(wcombo, REL_WHEEL, rw);
213 } 211 }
214
215 if (!prox)
216 wacom->id[0] = 0;
217 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]); /* report tool id */ 212 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]); /* report tool id */
218 wacom_report_key(wcombo, wacom->tool[0], prox); 213 wacom_report_key(wcombo, wacom->tool[0], 1);
219 wacom_input_sync(wcombo); /* sync last event */ 214 } else if (wacom->id[0]) {
215 wacom_report_abs(wcombo, ABS_X, 0);
216 wacom_report_abs(wcombo, ABS_Y, 0);
217 if (wacom->tool[0] == BTN_TOOL_MOUSE) {
218 wacom_report_key(wcombo, BTN_LEFT, 0);
219 wacom_report_key(wcombo, BTN_RIGHT, 0);
220 wacom_report_abs(wcombo, ABS_DISTANCE, 0);
221 } else {
222 wacom_report_abs(wcombo, ABS_PRESSURE, 0);
223 wacom_report_key(wcombo, BTN_TOUCH, 0);
224 wacom_report_key(wcombo, BTN_STYLUS, 0);
225 wacom_report_key(wcombo, BTN_STYLUS2, 0);
226 }
227 wacom->id[0] = 0;
228 wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */
229 wacom_report_key(wcombo, wacom->tool[0], 0);
220 } 230 }
221 231
222 /* send pad data */ 232 /* send pad data */
223 switch (features->type) { 233 switch (features->type) {
224 case WACOM_G4: 234 case WACOM_G4:
225 prox = data[7] & 0xf8; 235 if (data[7] & 0xf8) {
226 if (prox || wacom->id[1]) { 236 if (penData) {
237 wacom_input_sync(wcombo); /* sync last event */
238 if (!wacom->id[0])
239 penData = 0;
240 }
227 wacom->id[1] = PAD_DEVICE_ID; 241 wacom->id[1] = PAD_DEVICE_ID;
228 wacom_report_key(wcombo, BTN_0, (data[7] & 0x40)); 242 wacom_report_key(wcombo, BTN_0, (data[7] & 0x40));
229 wacom_report_key(wcombo, BTN_4, (data[7] & 0x80)); 243 wacom_report_key(wcombo, BTN_4, (data[7] & 0x80));
@@ -231,16 +245,29 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
231 wacom_report_rel(wcombo, REL_WHEEL, rw); 245 wacom_report_rel(wcombo, REL_WHEEL, rw);
232 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0xf0); 246 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0xf0);
233 wacom_report_abs(wcombo, ABS_MISC, wacom->id[1]); 247 wacom_report_abs(wcombo, ABS_MISC, wacom->id[1]);
234 if (!prox) 248 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
235 wacom->id[1] = 0; 249 } else if (wacom->id[1]) {
236 wacom_report_abs(wcombo, ABS_MISC, wacom->id[1]); 250 if (penData) {
251 wacom_input_sync(wcombo); /* sync last event */
252 if (!wacom->id[0])
253 penData = 0;
254 }
255 wacom->id[1] = 0;
256 wacom_report_key(wcombo, BTN_0, (data[7] & 0x40));
257 wacom_report_key(wcombo, BTN_4, (data[7] & 0x80));
258 wacom_report_rel(wcombo, REL_WHEEL, 0);
259 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0);
260 wacom_report_abs(wcombo, ABS_MISC, 0);
237 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0); 261 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
238 } 262 }
239 retval = 1;
240 break; 263 break;
241 case WACOM_MO: 264 case WACOM_MO:
242 prox = (data[7] & 0xf8) || data[8]; 265 if ((data[7] & 0xf8) || (data[8] & 0xff)) {
243 if (prox || wacom->id[1]) { 266 if (penData) {
267 wacom_input_sync(wcombo); /* sync last event */
268 if (!wacom->id[0])
269 penData = 0;
270 }
244 wacom->id[1] = PAD_DEVICE_ID; 271 wacom->id[1] = PAD_DEVICE_ID;
245 wacom_report_key(wcombo, BTN_0, (data[7] & 0x08)); 272 wacom_report_key(wcombo, BTN_0, (data[7] & 0x08));
246 wacom_report_key(wcombo, BTN_1, (data[7] & 0x20)); 273 wacom_report_key(wcombo, BTN_1, (data[7] & 0x20));
@@ -248,16 +275,27 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
248 wacom_report_key(wcombo, BTN_5, (data[7] & 0x40)); 275 wacom_report_key(wcombo, BTN_5, (data[7] & 0x40));
249 wacom_report_abs(wcombo, ABS_WHEEL, (data[8] & 0x7f)); 276 wacom_report_abs(wcombo, ABS_WHEEL, (data[8] & 0x7f));
250 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0xf0); 277 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0xf0);
251 if (!prox)
252 wacom->id[1] = 0;
253 wacom_report_abs(wcombo, ABS_MISC, wacom->id[1]); 278 wacom_report_abs(wcombo, ABS_MISC, wacom->id[1]);
254 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0); 279 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
280 } else if (wacom->id[1]) {
281 if (penData) {
282 wacom_input_sync(wcombo); /* sync last event */
283 if (!wacom->id[0])
284 penData = 0;
285 }
286 wacom->id[1] = 0;
287 wacom_report_key(wcombo, BTN_0, (data[7] & 0x08));
288 wacom_report_key(wcombo, BTN_1, (data[7] & 0x20));
289 wacom_report_key(wcombo, BTN_4, (data[7] & 0x10));
290 wacom_report_key(wcombo, BTN_5, (data[7] & 0x40));
291 wacom_report_abs(wcombo, ABS_WHEEL, (data[8] & 0x7f));
292 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0);
293 wacom_report_abs(wcombo, ABS_MISC, 0);
294 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
255 } 295 }
256 retval = 1;
257 break; 296 break;
258 } 297 }
259exit: 298 return 1;
260 return retval;
261} 299}
262 300
263static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo) 301static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
@@ -598,9 +636,9 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
598static void wacom_tpc_finger_in(struct wacom_wac *wacom, void *wcombo, char *data, int idx) 636static void wacom_tpc_finger_in(struct wacom_wac *wacom, void *wcombo, char *data, int idx)
599{ 637{
600 wacom_report_abs(wcombo, ABS_X, 638 wacom_report_abs(wcombo, ABS_X,
601 data[2 + idx * 2] | ((data[3 + idx * 2] & 0x7f) << 8)); 639 (data[2 + idx * 2] & 0xff) | ((data[3 + idx * 2] & 0x7f) << 8));
602 wacom_report_abs(wcombo, ABS_Y, 640 wacom_report_abs(wcombo, ABS_Y,
603 data[6 + idx * 2] | ((data[7 + idx * 2] & 0x7f) << 8)); 641 (data[6 + idx * 2] & 0xff) | ((data[7 + idx * 2] & 0x7f) << 8));
604 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]); 642 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]);
605 wacom_report_key(wcombo, wacom->tool[idx], 1); 643 wacom_report_key(wcombo, wacom->tool[idx], 1);
606 if (idx) 644 if (idx)
@@ -744,24 +782,31 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, void *wcombo)
744 782
745 touchInProx = 0; 783 touchInProx = 0;
746 784
747 if (!wacom->id[0]) { /* first in prox */ 785 if (prox) { /* in prox */
748 /* Going into proximity select tool */ 786 if (!wacom->id[0]) {
749 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN; 787 /* Going into proximity select tool */
750 if (wacom->tool[0] == BTN_TOOL_PEN) 788 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
751 wacom->id[0] = STYLUS_DEVICE_ID; 789 if (wacom->tool[0] == BTN_TOOL_PEN)
752 else 790 wacom->id[0] = STYLUS_DEVICE_ID;
753 wacom->id[0] = ERASER_DEVICE_ID; 791 else
754 } 792 wacom->id[0] = ERASER_DEVICE_ID;
755 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02); 793 }
756 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x10); 794 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02);
757 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[2])); 795 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x10);
758 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4])); 796 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[2]));
759 pressure = ((data[7] & 0x01) << 8) | data[6]; 797 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4]));
760 if (pressure < 0) 798 pressure = ((data[7] & 0x01) << 8) | data[6];
761 pressure = features->pressure_max + pressure + 1; 799 if (pressure < 0)
762 wacom_report_abs(wcombo, ABS_PRESSURE, pressure); 800 pressure = features->pressure_max + pressure + 1;
763 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x05); 801 wacom_report_abs(wcombo, ABS_PRESSURE, pressure);
764 if (!prox) { /* out-prox */ 802 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x05);
803 } else {
804 wacom_report_abs(wcombo, ABS_X, 0);
805 wacom_report_abs(wcombo, ABS_Y, 0);
806 wacom_report_abs(wcombo, ABS_PRESSURE, 0);
807 wacom_report_key(wcombo, BTN_STYLUS, 0);
808 wacom_report_key(wcombo, BTN_STYLUS2, 0);
809 wacom_report_key(wcombo, BTN_TOUCH, 0);
765 wacom->id[0] = 0; 810 wacom->id[0] = 0;
766 /* pen is out so touch can be enabled now */ 811 /* pen is out so touch can be enabled now */
767 touchInProx = 1; 812 touchInProx = 1;
diff --git a/drivers/input/touchscreen/88pm860x-ts.c b/drivers/input/touchscreen/88pm860x-ts.c
index 286bb490a9f..b3aebc2166b 100644
--- a/drivers/input/touchscreen/88pm860x-ts.c
+++ b/drivers/input/touchscreen/88pm860x-ts.c
@@ -14,6 +14,7 @@
14#include <linux/i2c.h> 14#include <linux/i2c.h>
15#include <linux/input.h> 15#include <linux/input.h>
16#include <linux/mfd/88pm860x.h> 16#include <linux/mfd/88pm860x.h>
17#include <linux/slab.h>
17 18
18#define MEAS_LEN (8) 19#define MEAS_LEN (8)
19#define ACCURATE_BIT (12) 20#define ACCURATE_BIT (12)
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 8a8fa4d2d6a..3d1ade2e519 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -99,22 +99,6 @@ config TOUCHSCREEN_BITSY
99 To compile this driver as a module, choose M here: the 99 To compile this driver as a module, choose M here: the
100 module will be called h3600_ts_input. 100 module will be called h3600_ts_input.
101 101
102config TOUCHSCREEN_CORGI
103 tristate "SharpSL (Corgi and Spitz series) touchscreen driver (DEPRECATED)"
104 depends on PXA_SHARPSL
105 select CORGI_SSP_DEPRECATED
106 help
107 Say Y here to enable the driver for the touchscreen on the
108 Sharp SL-C7xx and SL-Cxx00 series of PDAs.
109
110 If unsure, say N.
111
112 To compile this driver as a module, choose M here: the
113 module will be called corgi_ts.
114
115 NOTE: this driver is deprecated, try enable SPI and generic
116 ADS7846-based touchscreen driver.
117
118config TOUCHSCREEN_DA9034 102config TOUCHSCREEN_DA9034
119 tristate "Touchscreen support for Dialog Semiconductor DA9034" 103 tristate "Touchscreen support for Dialog Semiconductor DA9034"
120 depends on PMIC_DA903X 104 depends on PMIC_DA903X
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index 7fef7d5cca2..41145d074de 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -12,7 +12,6 @@ obj-$(CONFIG_TOUCHSCREEN_AD7879) += ad7879.o
12obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o 12obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o
13obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) += atmel_tsadcc.o 13obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) += atmel_tsadcc.o
14obj-$(CONFIG_TOUCHSCREEN_BITSY) += h3600_ts_input.o 14obj-$(CONFIG_TOUCHSCREEN_BITSY) += h3600_ts_input.o
15obj-$(CONFIG_TOUCHSCREEN_CORGI) += corgi_ts.o
16obj-$(CONFIG_TOUCHSCREEN_DYNAPRO) += dynapro.o 15obj-$(CONFIG_TOUCHSCREEN_DYNAPRO) += dynapro.o
17obj-$(CONFIG_TOUCHSCREEN_GUNZE) += gunze.o 16obj-$(CONFIG_TOUCHSCREEN_GUNZE) += gunze.o
18obj-$(CONFIG_TOUCHSCREEN_EETI) += eeti_ts.o 17obj-$(CONFIG_TOUCHSCREEN_EETI) += eeti_ts.o
diff --git a/drivers/input/touchscreen/atmel-wm97xx.c b/drivers/input/touchscreen/atmel-wm97xx.c
index a12242f77e2..fa8e56bd909 100644
--- a/drivers/input/touchscreen/atmel-wm97xx.c
+++ b/drivers/input/touchscreen/atmel-wm97xx.c
@@ -19,6 +19,7 @@
19#include <linux/timer.h> 19#include <linux/timer.h>
20#include <linux/gpio.h> 20#include <linux/gpio.h>
21#include <linux/io.h> 21#include <linux/io.h>
22#include <linux/slab.h>
22 23
23#define AC97C_ICA 0x10 24#define AC97C_ICA 0x10
24#define AC97C_CBRHR 0x30 25#define AC97C_CBRHR 0x30
diff --git a/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c
deleted file mode 100644
index 94a1919d439..00000000000
--- a/drivers/input/touchscreen/corgi_ts.c
+++ /dev/null
@@ -1,385 +0,0 @@
1/*
2 * Touchscreen driver for Sharp SL-C7xx and SL-Cxx00 models
3 *
4 * Copyright (c) 2004-2005 Richard Purdie
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11
12
13#include <linux/delay.h>
14#include <linux/platform_device.h>
15#include <linux/init.h>
16#include <linux/input.h>
17#include <linux/interrupt.h>
18#include <linux/module.h>
19#include <linux/slab.h>
20#include <linux/irq.h>
21
22#include <mach/sharpsl.h>
23#include <mach/hardware.h>
24#include <mach/pxa2xx-gpio.h>
25
26
27#define PWR_MODE_ACTIVE 0
28#define PWR_MODE_SUSPEND 1
29
30#define X_AXIS_MAX 3830
31#define X_AXIS_MIN 150
32#define Y_AXIS_MAX 3830
33#define Y_AXIS_MIN 190
34#define PRESSURE_MIN 0
35#define PRESSURE_MAX 15000
36
37struct ts_event {
38 short pressure;
39 short x;
40 short y;
41};
42
43struct corgi_ts {
44 struct input_dev *input;
45 struct timer_list timer;
46 struct ts_event tc;
47 int pendown;
48 int power_mode;
49 int irq_gpio;
50 struct corgits_machinfo *machinfo;
51};
52
53#ifdef CONFIG_PXA25x
54#define CCNT(a) asm volatile ("mrc p14, 0, %0, C1, C0, 0" : "=r"(a))
55#define PMNC_GET(x) asm volatile ("mrc p14, 0, %0, C0, C0, 0" : "=r"(x))
56#define PMNC_SET(x) asm volatile ("mcr p14, 0, %0, C0, C0, 0" : : "r"(x))
57#endif
58#ifdef CONFIG_PXA27x
59#define CCNT(a) asm volatile ("mrc p14, 0, %0, C1, C1, 0" : "=r"(a))
60#define PMNC_GET(x) asm volatile ("mrc p14, 0, %0, C0, C1, 0" : "=r"(x))
61#define PMNC_SET(x) asm volatile ("mcr p14, 0, %0, C0, C1, 0" : : "r"(x))
62#endif
63
64/* ADS7846 Touch Screen Controller bit definitions */
65#define ADSCTRL_PD0 (1u << 0) /* PD0 */
66#define ADSCTRL_PD1 (1u << 1) /* PD1 */
67#define ADSCTRL_DFR (1u << 2) /* SER/DFR */
68#define ADSCTRL_MOD (1u << 3) /* Mode */
69#define ADSCTRL_ADR_SH 4 /* Address setting */
70#define ADSCTRL_STS (1u << 7) /* Start Bit */
71
72/* External Functions */
73extern unsigned int get_clk_frequency_khz(int info);
74
75static unsigned long calc_waittime(struct corgi_ts *corgi_ts)
76{
77 unsigned long hsync_invperiod = corgi_ts->machinfo->get_hsync_invperiod();
78
79 if (hsync_invperiod)
80 return get_clk_frequency_khz(0)*1000/hsync_invperiod;
81 else
82 return 0;
83}
84
85static int sync_receive_data_send_cmd(struct corgi_ts *corgi_ts, int doRecive, int doSend,
86 unsigned int address, unsigned long wait_time)
87{
88 unsigned long timer1 = 0, timer2, pmnc = 0;
89 int pos = 0;
90
91 if (wait_time && doSend) {
92 PMNC_GET(pmnc);
93 if (!(pmnc & 0x01))
94 PMNC_SET(0x01);
95
96 /* polling HSync */
97 corgi_ts->machinfo->wait_hsync();
98 /* get CCNT */
99 CCNT(timer1);
100 }
101
102 if (doRecive)
103 pos = corgi_ssp_ads7846_get();
104
105 if (doSend) {
106 int cmd = ADSCTRL_PD0 | ADSCTRL_PD1 | (address << ADSCTRL_ADR_SH) | ADSCTRL_STS;
107 /* dummy command */
108 corgi_ssp_ads7846_put(cmd);
109 corgi_ssp_ads7846_get();
110
111 if (wait_time) {
112 /* Wait after HSync */
113 CCNT(timer2);
114 if (timer2-timer1 > wait_time) {
115 /* too slow - timeout, try again */
116 corgi_ts->machinfo->wait_hsync();
117 /* get CCNT */
118 CCNT(timer1);
119 /* Wait after HSync */
120 CCNT(timer2);
121 }
122 while (timer2 - timer1 < wait_time)
123 CCNT(timer2);
124 }
125 corgi_ssp_ads7846_put(cmd);
126 if (wait_time && !(pmnc & 0x01))
127 PMNC_SET(pmnc);
128 }
129 return pos;
130}
131
132static int read_xydata(struct corgi_ts *corgi_ts)
133{
134 unsigned int x, y, z1, z2;
135 unsigned long flags, wait_time;
136
137 /* critical section */
138 local_irq_save(flags);
139 corgi_ssp_ads7846_lock();
140 wait_time = calc_waittime(corgi_ts);
141
142 /* Y-axis */
143 sync_receive_data_send_cmd(corgi_ts, 0, 1, 1u, wait_time);
144
145 /* Y-axis */
146 sync_receive_data_send_cmd(corgi_ts, 1, 1, 1u, wait_time);
147
148 /* X-axis */
149 y = sync_receive_data_send_cmd(corgi_ts, 1, 1, 5u, wait_time);
150
151 /* Z1 */
152 x = sync_receive_data_send_cmd(corgi_ts, 1, 1, 3u, wait_time);
153
154 /* Z2 */
155 z1 = sync_receive_data_send_cmd(corgi_ts, 1, 1, 4u, wait_time);
156 z2 = sync_receive_data_send_cmd(corgi_ts, 1, 0, 4u, wait_time);
157
158 /* Power-Down Enable */
159 corgi_ssp_ads7846_put((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS);
160 corgi_ssp_ads7846_get();
161
162 corgi_ssp_ads7846_unlock();
163 local_irq_restore(flags);
164
165 if (x== 0 || y == 0 || z1 == 0 || (x * (z2 - z1) / z1) >= 15000) {
166 corgi_ts->tc.pressure = 0;
167 return 0;
168 }
169
170 corgi_ts->tc.x = x;
171 corgi_ts->tc.y = y;
172 corgi_ts->tc.pressure = (x * (z2 - z1)) / z1;
173 return 1;
174}
175
176static void new_data(struct corgi_ts *corgi_ts)
177{
178 struct input_dev *dev = corgi_ts->input;
179
180 if (corgi_ts->power_mode != PWR_MODE_ACTIVE)
181 return;
182
183 if (!corgi_ts->tc.pressure && corgi_ts->pendown == 0)
184 return;
185
186 input_report_abs(dev, ABS_X, corgi_ts->tc.x);
187 input_report_abs(dev, ABS_Y, corgi_ts->tc.y);
188 input_report_abs(dev, ABS_PRESSURE, corgi_ts->tc.pressure);
189 input_report_key(dev, BTN_TOUCH, corgi_ts->pendown);
190 input_sync(dev);
191}
192
193static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer)
194{
195 if ((GPLR(IRQ_TO_GPIO(corgi_ts->irq_gpio)) & GPIO_bit(IRQ_TO_GPIO(corgi_ts->irq_gpio))) == 0) {
196 /* Disable Interrupt */
197 set_irq_type(corgi_ts->irq_gpio, IRQ_TYPE_NONE);
198 if (read_xydata(corgi_ts)) {
199 corgi_ts->pendown = 1;
200 new_data(corgi_ts);
201 }
202 mod_timer(&corgi_ts->timer, jiffies + HZ / 100);
203 } else {
204 if (corgi_ts->pendown == 1 || corgi_ts->pendown == 2) {
205 mod_timer(&corgi_ts->timer, jiffies + HZ / 100);
206 corgi_ts->pendown++;
207 return;
208 }
209
210 if (corgi_ts->pendown) {
211 corgi_ts->tc.pressure = 0;
212 new_data(corgi_ts);
213 }
214
215 /* Enable Falling Edge */
216 set_irq_type(corgi_ts->irq_gpio, IRQ_TYPE_EDGE_FALLING);
217 corgi_ts->pendown = 0;
218 }
219}
220
221static void corgi_ts_timer(unsigned long data)
222{
223 struct corgi_ts *corgits_data = (struct corgi_ts *) data;
224
225 ts_interrupt_main(corgits_data, 1);
226}
227
228static irqreturn_t ts_interrupt(int irq, void *dev_id)
229{
230 struct corgi_ts *corgits_data = dev_id;
231
232 ts_interrupt_main(corgits_data, 0);
233 return IRQ_HANDLED;
234}
235
236#ifdef CONFIG_PM
237static int corgits_suspend(struct platform_device *dev, pm_message_t state)
238{
239 struct corgi_ts *corgi_ts = platform_get_drvdata(dev);
240
241 if (corgi_ts->pendown) {
242 del_timer_sync(&corgi_ts->timer);
243 corgi_ts->tc.pressure = 0;
244 new_data(corgi_ts);
245 corgi_ts->pendown = 0;
246 }
247 corgi_ts->power_mode = PWR_MODE_SUSPEND;
248
249 corgi_ssp_ads7846_putget((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS);
250
251 return 0;
252}
253
254static int corgits_resume(struct platform_device *dev)
255{
256 struct corgi_ts *corgi_ts = platform_get_drvdata(dev);
257
258 corgi_ssp_ads7846_putget((4u << ADSCTRL_ADR_SH) | ADSCTRL_STS);
259 /* Enable Falling Edge */
260 set_irq_type(corgi_ts->irq_gpio, IRQ_TYPE_EDGE_FALLING);
261 corgi_ts->power_mode = PWR_MODE_ACTIVE;
262
263 return 0;
264}
265#else
266#define corgits_suspend NULL
267#define corgits_resume NULL
268#endif
269
270static int __devinit corgits_probe(struct platform_device *pdev)
271{
272 struct corgi_ts *corgi_ts;
273 struct input_dev *input_dev;
274 int err = -ENOMEM;
275
276 corgi_ts = kzalloc(sizeof(struct corgi_ts), GFP_KERNEL);
277 input_dev = input_allocate_device();
278 if (!corgi_ts || !input_dev)
279 goto fail1;
280
281 platform_set_drvdata(pdev, corgi_ts);
282
283 corgi_ts->machinfo = pdev->dev.platform_data;
284 corgi_ts->irq_gpio = platform_get_irq(pdev, 0);
285
286 if (corgi_ts->irq_gpio < 0) {
287 err = -ENODEV;
288 goto fail1;
289 }
290
291 corgi_ts->input = input_dev;
292
293 init_timer(&corgi_ts->timer);
294 corgi_ts->timer.data = (unsigned long) corgi_ts;
295 corgi_ts->timer.function = corgi_ts_timer;
296
297 input_dev->name = "Corgi Touchscreen";
298 input_dev->phys = "corgits/input0";
299 input_dev->id.bustype = BUS_HOST;
300 input_dev->id.vendor = 0x0001;
301 input_dev->id.product = 0x0002;
302 input_dev->id.version = 0x0100;
303 input_dev->dev.parent = &pdev->dev;
304
305 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
306 input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
307 input_set_abs_params(input_dev, ABS_X, X_AXIS_MIN, X_AXIS_MAX, 0, 0);
308 input_set_abs_params(input_dev, ABS_Y, Y_AXIS_MIN, Y_AXIS_MAX, 0, 0);
309 input_set_abs_params(input_dev, ABS_PRESSURE, PRESSURE_MIN, PRESSURE_MAX, 0, 0);
310
311 pxa_gpio_mode(IRQ_TO_GPIO(corgi_ts->irq_gpio) | GPIO_IN);
312
313 /* Initiaize ADS7846 Difference Reference mode */
314 corgi_ssp_ads7846_putget((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS);
315 mdelay(5);
316 corgi_ssp_ads7846_putget((3u << ADSCTRL_ADR_SH) | ADSCTRL_STS);
317 mdelay(5);
318 corgi_ssp_ads7846_putget((4u << ADSCTRL_ADR_SH) | ADSCTRL_STS);
319 mdelay(5);
320 corgi_ssp_ads7846_putget((5u << ADSCTRL_ADR_SH) | ADSCTRL_STS);
321 mdelay(5);
322
323 if (request_irq(corgi_ts->irq_gpio, ts_interrupt, IRQF_DISABLED, "ts", corgi_ts)) {
324 err = -EBUSY;
325 goto fail1;
326 }
327
328 err = input_register_device(corgi_ts->input);
329 if (err)
330 goto fail2;
331
332 corgi_ts->power_mode = PWR_MODE_ACTIVE;
333
334 /* Enable Falling Edge */
335 set_irq_type(corgi_ts->irq_gpio, IRQ_TYPE_EDGE_FALLING);
336
337 return 0;
338
339 fail2: free_irq(corgi_ts->irq_gpio, corgi_ts);
340 fail1: input_free_device(input_dev);
341 kfree(corgi_ts);
342 return err;
343}
344
345static int __devexit corgits_remove(struct platform_device *pdev)
346{
347 struct corgi_ts *corgi_ts = platform_get_drvdata(pdev);
348
349 free_irq(corgi_ts->irq_gpio, corgi_ts);
350 del_timer_sync(&corgi_ts->timer);
351 corgi_ts->machinfo->put_hsync();
352 input_unregister_device(corgi_ts->input);
353 kfree(corgi_ts);
354
355 return 0;
356}
357
358static struct platform_driver corgits_driver = {
359 .probe = corgits_probe,
360 .remove = __devexit_p(corgits_remove),
361 .suspend = corgits_suspend,
362 .resume = corgits_resume,
363 .driver = {
364 .name = "corgi-ts",
365 .owner = THIS_MODULE,
366 },
367};
368
369static int __init corgits_init(void)
370{
371 return platform_driver_register(&corgits_driver);
372}
373
374static void __exit corgits_exit(void)
375{
376 platform_driver_unregister(&corgits_driver);
377}
378
379module_init(corgits_init);
380module_exit(corgits_exit);
381
382MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>");
383MODULE_DESCRIPTION("Corgi TouchScreen Driver");
384MODULE_LICENSE("GPL");
385MODULE_ALIAS("platform:corgi-ts");
diff --git a/drivers/input/touchscreen/da9034-ts.c b/drivers/input/touchscreen/da9034-ts.c
index 3ffd4c4b170..2b72a5923c1 100644
--- a/drivers/input/touchscreen/da9034-ts.c
+++ b/drivers/input/touchscreen/da9034-ts.c
@@ -19,6 +19,7 @@
19#include <linux/input.h> 19#include <linux/input.h>
20#include <linux/workqueue.h> 20#include <linux/workqueue.h>
21#include <linux/mfd/da903x.h> 21#include <linux/mfd/da903x.h>
22#include <linux/slab.h>
22 23
23#define DA9034_MANUAL_CTRL 0x50 24#define DA9034_MANUAL_CTRL 0x50
24#define DA9034_LDO_ADC_EN (1 << 4) 25#define DA9034_LDO_ADC_EN (1 << 4)
diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c
index 9029bd3f34e..75f8b73010f 100644
--- a/drivers/input/touchscreen/eeti_ts.c
+++ b/drivers/input/touchscreen/eeti_ts.c
@@ -33,6 +33,7 @@
33#include <linux/timer.h> 33#include <linux/timer.h>
34#include <linux/gpio.h> 34#include <linux/gpio.h>
35#include <linux/input/eeti_ts.h> 35#include <linux/input/eeti_ts.h>
36#include <linux/slab.h>
36 37
37static int flip_x; 38static int flip_x;
38module_param(flip_x, bool, 0644); 39module_param(flip_x, bool, 0644);
@@ -123,14 +124,25 @@ static irqreturn_t eeti_ts_isr(int irq, void *dev_id)
123 return IRQ_HANDLED; 124 return IRQ_HANDLED;
124} 125}
125 126
126static int eeti_ts_open(struct input_dev *dev) 127static void eeti_ts_start(struct eeti_ts_priv *priv)
127{ 128{
128 struct eeti_ts_priv *priv = input_get_drvdata(dev);
129
130 enable_irq(priv->irq); 129 enable_irq(priv->irq);
131 130
132 /* Read the events once to arm the IRQ */ 131 /* Read the events once to arm the IRQ */
133 eeti_ts_read(&priv->work); 132 eeti_ts_read(&priv->work);
133}
134
135static void eeti_ts_stop(struct eeti_ts_priv *priv)
136{
137 disable_irq(priv->irq);
138 cancel_work_sync(&priv->work);
139}
140
141static int eeti_ts_open(struct input_dev *dev)
142{
143 struct eeti_ts_priv *priv = input_get_drvdata(dev);
144
145 eeti_ts_start(priv);
134 146
135 return 0; 147 return 0;
136} 148}
@@ -139,8 +151,7 @@ static void eeti_ts_close(struct input_dev *dev)
139{ 151{
140 struct eeti_ts_priv *priv = input_get_drvdata(dev); 152 struct eeti_ts_priv *priv = input_get_drvdata(dev);
141 153
142 disable_irq(priv->irq); 154 eeti_ts_stop(priv);
143 cancel_work_sync(&priv->work);
144} 155}
145 156
146static int __devinit eeti_ts_probe(struct i2c_client *client, 157static int __devinit eeti_ts_probe(struct i2c_client *client,
@@ -152,10 +163,12 @@ static int __devinit eeti_ts_probe(struct i2c_client *client,
152 unsigned int irq_flags; 163 unsigned int irq_flags;
153 int err = -ENOMEM; 164 int err = -ENOMEM;
154 165
155 /* In contrast to what's described in the datasheet, there seems 166 /*
167 * In contrast to what's described in the datasheet, there seems
156 * to be no way of probing the presence of that device using I2C 168 * to be no way of probing the presence of that device using I2C
157 * commands. So we need to blindly believe it is there, and wait 169 * commands. So we need to blindly believe it is there, and wait
158 * for interrupts to occur. */ 170 * for interrupts to occur.
171 */
159 172
160 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 173 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
161 if (!priv) { 174 if (!priv) {
@@ -211,9 +224,11 @@ static int __devinit eeti_ts_probe(struct i2c_client *client,
211 goto err2; 224 goto err2;
212 } 225 }
213 226
214 /* Disable the irq for now. It will be enabled once the input device 227 /*
215 * is opened. */ 228 * Disable the device for now. It will be enabled once the
216 disable_irq(priv->irq); 229 * input device is opened.
230 */
231 eeti_ts_stop(priv);
217 232
218 device_init_wakeup(&client->dev, 0); 233 device_init_wakeup(&client->dev, 0);
219 return 0; 234 return 0;
@@ -234,6 +249,12 @@ static int __devexit eeti_ts_remove(struct i2c_client *client)
234 struct eeti_ts_priv *priv = i2c_get_clientdata(client); 249 struct eeti_ts_priv *priv = i2c_get_clientdata(client);
235 250
236 free_irq(priv->irq, priv); 251 free_irq(priv->irq, priv);
252 /*
253 * eeti_ts_stop() leaves IRQ disabled. We need to re-enable it
254 * so that device still works if we reload the driver.
255 */
256 enable_irq(priv->irq);
257
237 input_unregister_device(priv->input); 258 input_unregister_device(priv->input);
238 i2c_set_clientdata(client, NULL); 259 i2c_set_clientdata(client, NULL);
239 kfree(priv); 260 kfree(priv);
@@ -245,6 +266,14 @@ static int __devexit eeti_ts_remove(struct i2c_client *client)
245static int eeti_ts_suspend(struct i2c_client *client, pm_message_t mesg) 266static int eeti_ts_suspend(struct i2c_client *client, pm_message_t mesg)
246{ 267{
247 struct eeti_ts_priv *priv = i2c_get_clientdata(client); 268 struct eeti_ts_priv *priv = i2c_get_clientdata(client);
269 struct input_dev *input_dev = priv->input;
270
271 mutex_lock(&input_dev->mutex);
272
273 if (input_dev->users)
274 eeti_ts_stop(priv);
275
276 mutex_unlock(&input_dev->mutex);
248 277
249 if (device_may_wakeup(&client->dev)) 278 if (device_may_wakeup(&client->dev))
250 enable_irq_wake(priv->irq); 279 enable_irq_wake(priv->irq);
@@ -255,10 +284,18 @@ static int eeti_ts_suspend(struct i2c_client *client, pm_message_t mesg)
255static int eeti_ts_resume(struct i2c_client *client) 284static int eeti_ts_resume(struct i2c_client *client)
256{ 285{
257 struct eeti_ts_priv *priv = i2c_get_clientdata(client); 286 struct eeti_ts_priv *priv = i2c_get_clientdata(client);
287 struct input_dev *input_dev = priv->input;
258 288
259 if (device_may_wakeup(&client->dev)) 289 if (device_may_wakeup(&client->dev))
260 disable_irq_wake(priv->irq); 290 disable_irq_wake(priv->irq);
261 291
292 mutex_lock(&input_dev->mutex);
293
294 if (input_dev->users)
295 eeti_ts_start(priv);
296
297 mutex_unlock(&input_dev->mutex);
298
262 return 0; 299 return 0;
263} 300}
264#else 301#else
diff --git a/drivers/input/touchscreen/jornada720_ts.c b/drivers/input/touchscreen/jornada720_ts.c
index c8b7e8a45c4..4b0a061811f 100644
--- a/drivers/input/touchscreen/jornada720_ts.c
+++ b/drivers/input/touchscreen/jornada720_ts.c
@@ -18,6 +18,7 @@
18#include <linux/input.h> 18#include <linux/input.h>
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/slab.h>
21 22
22#include <mach/hardware.h> 23#include <mach/hardware.h>
23#include <mach/jornada720.h> 24#include <mach/jornada720.h>
diff --git a/drivers/input/touchscreen/mc13783_ts.c b/drivers/input/touchscreen/mc13783_ts.c
index be54fd639ac..c5bc62d85bb 100644
--- a/drivers/input/touchscreen/mc13783_ts.c
+++ b/drivers/input/touchscreen/mc13783_ts.c
@@ -17,6 +17,7 @@
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/input.h> 18#include <linux/input.h>
19#include <linux/sched.h> 19#include <linux/sched.h>
20#include <linux/slab.h>
20#include <linux/init.h> 21#include <linux/init.h>
21 22
22#define MC13783_TS_NAME "mc13783-ts" 23#define MC13783_TS_NAME "mc13783-ts"
diff --git a/drivers/input/touchscreen/mcs5000_ts.c b/drivers/input/touchscreen/mcs5000_ts.c
index 4c28b89757f..ce8ab0269f6 100644
--- a/drivers/input/touchscreen/mcs5000_ts.c
+++ b/drivers/input/touchscreen/mcs5000_ts.c
@@ -20,6 +20,7 @@
20#include <linux/interrupt.h> 20#include <linux/interrupt.h>
21#include <linux/input.h> 21#include <linux/input.h>
22#include <linux/irq.h> 22#include <linux/irq.h>
23#include <linux/slab.h>
23 24
24/* Registers */ 25/* Registers */
25#define MCS5000_TS_STATUS 0x00 26#define MCS5000_TS_STATUS 0x00
diff --git a/drivers/input/touchscreen/migor_ts.c b/drivers/input/touchscreen/migor_ts.c
index 141dd584330..defe5dd3627 100644
--- a/drivers/input/touchscreen/migor_ts.c
+++ b/drivers/input/touchscreen/migor_ts.c
@@ -23,6 +23,7 @@
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/input.h> 24#include <linux/input.h>
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/slab.h>
26#include <asm/io.h> 27#include <asm/io.h>
27#include <linux/i2c.h> 28#include <linux/i2c.h>
28#include <linux/timer.h> 29#include <linux/timer.h>
diff --git a/drivers/input/touchscreen/pcap_ts.c b/drivers/input/touchscreen/pcap_ts.c
index b79097e3028..ea6ef16e59b 100644
--- a/drivers/input/touchscreen/pcap_ts.c
+++ b/drivers/input/touchscreen/pcap_ts.c
@@ -14,6 +14,7 @@
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/fs.h> 15#include <linux/fs.h>
16#include <linux/string.h> 16#include <linux/string.h>
17#include <linux/slab.h>
17#include <linux/pm.h> 18#include <linux/pm.h>
18#include <linux/timer.h> 19#include <linux/timer.h>
19#include <linux/interrupt.h> 20#include <linux/interrupt.h>
diff --git a/drivers/input/touchscreen/s3c2410_ts.c b/drivers/input/touchscreen/s3c2410_ts.c
index 3755a47d053..98a7d127948 100644
--- a/drivers/input/touchscreen/s3c2410_ts.c
+++ b/drivers/input/touchscreen/s3c2410_ts.c
@@ -26,7 +26,6 @@
26#include <linux/errno.h> 26#include <linux/errno.h>
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/slab.h>
30#include <linux/gpio.h> 29#include <linux/gpio.h>
31#include <linux/input.h> 30#include <linux/input.h>
32#include <linux/init.h> 31#include <linux/init.h>
diff --git a/drivers/input/touchscreen/ucb1400_ts.c b/drivers/input/touchscreen/ucb1400_ts.c
index 89dcbe7b4b0..028a5363eea 100644
--- a/drivers/input/touchscreen/ucb1400_ts.c
+++ b/drivers/input/touchscreen/ucb1400_ts.c
@@ -26,7 +26,6 @@
26#include <linux/device.h> 26#include <linux/device.h>
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/suspend.h> 28#include <linux/suspend.h>
29#include <linux/slab.h>
30#include <linux/kthread.h> 29#include <linux/kthread.h>
31#include <linux/freezer.h> 30#include <linux/freezer.h>
32#include <linux/ucb1400.h> 31#include <linux/ucb1400.h>
diff --git a/drivers/input/touchscreen/w90p910_ts.c b/drivers/input/touchscreen/w90p910_ts.c
index 6ccbdbbf33f..cc18265be1a 100644
--- a/drivers/input/touchscreen/w90p910_ts.c
+++ b/drivers/input/touchscreen/w90p910_ts.c
@@ -16,6 +16,7 @@
16#include <linux/clk.h> 16#include <linux/clk.h>
17#include <linux/input.h> 17#include <linux/input.h>
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/slab.h>
19 20
20/* ADC controller bit defines */ 21/* ADC controller bit defines */
21#define ADC_DELAY 0xf00 22#define ADC_DELAY 0xf00
diff --git a/drivers/input/touchscreen/wm97xx-core.c b/drivers/input/touchscreen/wm97xx-core.c
index f944918466e..5109bf3dd85 100644
--- a/drivers/input/touchscreen/wm97xx-core.c
+++ b/drivers/input/touchscreen/wm97xx-core.c
@@ -48,6 +48,7 @@
48#include <linux/wm97xx.h> 48#include <linux/wm97xx.h>
49#include <linux/uaccess.h> 49#include <linux/uaccess.h>
50#include <linux/io.h> 50#include <linux/io.h>
51#include <linux/slab.h>
51 52
52#define TS_NAME "wm97xx" 53#define TS_NAME "wm97xx"
53#define WM_CORE_VERSION "1.00" 54#define WM_CORE_VERSION "1.00"
diff --git a/drivers/input/xen-kbdfront.c b/drivers/input/xen-kbdfront.c
index d30436fee47..e14081675bb 100644
--- a/drivers/input/xen-kbdfront.c
+++ b/drivers/input/xen-kbdfront.c
@@ -21,6 +21,7 @@
21#include <linux/errno.h> 21#include <linux/errno.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/input.h> 23#include <linux/input.h>
24#include <linux/slab.h>
24 25
25#include <asm/xen/hypervisor.h> 26#include <asm/xen/hypervisor.h>
26 27
diff --git a/drivers/isdn/act2000/module.c b/drivers/isdn/act2000/module.c
index f774e12bb64..05ed72c4cf5 100644
--- a/drivers/isdn/act2000/module.c
+++ b/drivers/isdn/act2000/module.c
@@ -16,6 +16,7 @@
16#include "act2000_isa.h" 16#include "act2000_isa.h"
17#include "capi.h" 17#include "capi.h"
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/slab.h>
19#include <linux/init.h> 20#include <linux/init.h>
20 21
21static unsigned short act2000_isa_ports[] = 22static unsigned short act2000_isa_ports[] =
diff --git a/drivers/isdn/capi/capifs.c b/drivers/isdn/capi/capifs.c
index 8596bd1a4d2..2b83850997c 100644
--- a/drivers/isdn/capi/capifs.c
+++ b/drivers/isdn/capi/capifs.c
@@ -11,6 +11,7 @@
11 11
12#include <linux/fs.h> 12#include <linux/fs.h>
13#include <linux/mount.h> 13#include <linux/mount.h>
14#include <linux/slab.h>
14#include <linux/namei.h> 15#include <linux/namei.h>
15#include <linux/module.h> 16#include <linux/module.h>
16#include <linux/init.h> 17#include <linux/init.h>
diff --git a/drivers/isdn/capi/capilib.c b/drivers/isdn/capi/capilib.c
index fcaa1241ee7..0b041df2108 100644
--- a/drivers/isdn/capi/capilib.c
+++ b/drivers/isdn/capi/capilib.c
@@ -1,4 +1,5 @@
1 1
2#include <linux/slab.h>
2#include <linux/kernel.h> 3#include <linux/kernel.h>
3#include <linux/module.h> 4#include <linux/module.h>
4#include <linux/isdn/capilli.h> 5#include <linux/isdn/capilli.h>
diff --git a/drivers/isdn/capi/capiutil.c b/drivers/isdn/capi/capiutil.c
index 26626eead82..03c469e4451 100644
--- a/drivers/isdn/capi/capiutil.c
+++ b/drivers/isdn/capi/capiutil.c
@@ -18,6 +18,7 @@
18#include <linux/mm.h> 18#include <linux/mm.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/isdn/capiutil.h> 20#include <linux/isdn/capiutil.h>
21#include <linux/slab.h>
21 22
22/* from CAPI2.0 DDK AVM Berlin GmbH */ 23/* from CAPI2.0 DDK AVM Berlin GmbH */
23 24
diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c
index ce9b05b9e93..bd00dceacaf 100644
--- a/drivers/isdn/capi/kcapi.c
+++ b/drivers/isdn/capi/kcapi.c
@@ -27,6 +27,7 @@
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/slab.h>
30#include <asm/uaccess.h> 31#include <asm/uaccess.h>
31#include <linux/isdn/capicmd.h> 32#include <linux/isdn/capicmd.h>
32#include <linux/isdn/capiutil.h> 33#include <linux/isdn/capiutil.h>
diff --git a/drivers/isdn/divert/divert_procfs.c b/drivers/isdn/divert/divert_procfs.c
index 3697c409bec..9f49d906579 100644
--- a/drivers/isdn/divert/divert_procfs.c
+++ b/drivers/isdn/divert/divert_procfs.c
@@ -11,6 +11,7 @@
11 11
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/poll.h> 13#include <linux/poll.h>
14#include <linux/slab.h>
14#ifdef CONFIG_PROC_FS 15#ifdef CONFIG_PROC_FS
15#include <linux/proc_fs.h> 16#include <linux/proc_fs.h>
16#else 17#else
diff --git a/drivers/isdn/divert/isdn_divert.c b/drivers/isdn/divert/isdn_divert.c
index 77e9fdda059..70cf6bac7a5 100644
--- a/drivers/isdn/divert/isdn_divert.c
+++ b/drivers/isdn/divert/isdn_divert.c
@@ -10,6 +10,7 @@
10 */ 10 */
11 11
12#include <linux/proc_fs.h> 12#include <linux/proc_fs.h>
13#include <linux/slab.h>
13#include <linux/timer.h> 14#include <linux/timer.h>
14#include <linux/jiffies.h> 15#include <linux/jiffies.h>
15 16
diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c
index 0be15c70c16..47a5ffec55a 100644
--- a/drivers/isdn/gigaset/bas-gigaset.c
+++ b/drivers/isdn/gigaset/bas-gigaset.c
@@ -14,11 +14,6 @@
14 */ 14 */
15 15
16#include "gigaset.h" 16#include "gigaset.h"
17
18#include <linux/errno.h>
19#include <linux/init.h>
20#include <linux/slab.h>
21#include <linux/timer.h>
22#include <linux/usb.h> 17#include <linux/usb.h>
23#include <linux/module.h> 18#include <linux/module.h>
24#include <linux/moduleparam.h> 19#include <linux/moduleparam.h>
diff --git a/drivers/isdn/gigaset/capi.c b/drivers/isdn/gigaset/capi.c
index 0220c19351d..964a55fb148 100644
--- a/drivers/isdn/gigaset/capi.c
+++ b/drivers/isdn/gigaset/capi.c
@@ -12,7 +12,6 @@
12 */ 12 */
13 13
14#include "gigaset.h" 14#include "gigaset.h"
15#include <linux/ctype.h>
16#include <linux/proc_fs.h> 15#include <linux/proc_fs.h>
17#include <linux/seq_file.h> 16#include <linux/seq_file.h>
18#include <linux/isdn/capilli.h> 17#include <linux/isdn/capilli.h>
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c
index bdc01cb9f0a..f6f45f22192 100644
--- a/drivers/isdn/gigaset/common.c
+++ b/drivers/isdn/gigaset/common.c
@@ -14,7 +14,6 @@
14 */ 14 */
15 15
16#include "gigaset.h" 16#include "gigaset.h"
17#include <linux/ctype.h>
18#include <linux/module.h> 17#include <linux/module.h>
19#include <linux/moduleparam.h> 18#include <linux/moduleparam.h>
20 19
diff --git a/drivers/isdn/gigaset/gigaset.h b/drivers/isdn/gigaset/gigaset.h
index cdd144ecdc5..05947f9c184 100644
--- a/drivers/isdn/gigaset/gigaset.h
+++ b/drivers/isdn/gigaset/gigaset.h
@@ -20,10 +20,12 @@
20#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 20#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
21 21
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/sched.h>
23#include <linux/compiler.h> 24#include <linux/compiler.h>
24#include <linux/types.h> 25#include <linux/types.h>
26#include <linux/ctype.h>
27#include <linux/slab.h>
25#include <linux/spinlock.h> 28#include <linux/spinlock.h>
26#include <linux/usb.h>
27#include <linux/skbuff.h> 29#include <linux/skbuff.h>
28#include <linux/netdevice.h> 30#include <linux/netdevice.h>
29#include <linux/ppp_defs.h> 31#include <linux/ppp_defs.h>
diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
index f0dc6c9cc28..c9f28dd40d5 100644
--- a/drivers/isdn/gigaset/interface.c
+++ b/drivers/isdn/gigaset/interface.c
@@ -13,7 +13,6 @@
13 13
14#include "gigaset.h" 14#include "gigaset.h"
15#include <linux/gigaset_dev.h> 15#include <linux/gigaset_dev.h>
16#include <linux/tty.h>
17#include <linux/tty_flip.h> 16#include <linux/tty_flip.h>
18 17
19/*** our ioctls ***/ 18/*** our ioctls ***/
diff --git a/drivers/isdn/gigaset/proc.c b/drivers/isdn/gigaset/proc.c
index b69f73a0668..b943efbff44 100644
--- a/drivers/isdn/gigaset/proc.c
+++ b/drivers/isdn/gigaset/proc.c
@@ -14,7 +14,6 @@
14 */ 14 */
15 15
16#include "gigaset.h" 16#include "gigaset.h"
17#include <linux/ctype.h>
18 17
19static ssize_t show_cidmode(struct device *dev, 18static ssize_t show_cidmode(struct device *dev,
20 struct device_attribute *attr, char *buf) 19 struct device_attribute *attr, char *buf)
diff --git a/drivers/isdn/gigaset/ser-gigaset.c b/drivers/isdn/gigaset/ser-gigaset.c
index 168d585d64d..e96c0586886 100644
--- a/drivers/isdn/gigaset/ser-gigaset.c
+++ b/drivers/isdn/gigaset/ser-gigaset.c
@@ -11,11 +11,9 @@
11 */ 11 */
12 12
13#include "gigaset.h" 13#include "gigaset.h"
14
15#include <linux/module.h> 14#include <linux/module.h>
16#include <linux/moduleparam.h> 15#include <linux/moduleparam.h>
17#include <linux/platform_device.h> 16#include <linux/platform_device.h>
18#include <linux/tty.h>
19#include <linux/completion.h> 17#include <linux/completion.h>
20 18
21/* Version Information */ 19/* Version Information */
diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
index 9430a2bbb52..76dbb20f306 100644
--- a/drivers/isdn/gigaset/usb-gigaset.c
+++ b/drivers/isdn/gigaset/usb-gigaset.c
@@ -16,10 +16,6 @@
16 */ 16 */
17 17
18#include "gigaset.h" 18#include "gigaset.h"
19
20#include <linux/errno.h>
21#include <linux/init.h>
22#include <linux/slab.h>
23#include <linux/usb.h> 19#include <linux/usb.h>
24#include <linux/module.h> 20#include <linux/module.h>
25#include <linux/moduleparam.h> 21#include <linux/moduleparam.h>
diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
index c38fa0f4c72..2a57da590d7 100644
--- a/drivers/isdn/hardware/avm/b1.c
+++ b/drivers/isdn/hardware/avm/b1.c
@@ -21,6 +21,7 @@
21#include <linux/ioport.h> 21#include <linux/ioport.h>
22#include <linux/capi.h> 22#include <linux/capi.h>
23#include <linux/kernelcapi.h> 23#include <linux/kernelcapi.h>
24#include <linux/slab.h>
24#include <asm/io.h> 25#include <asm/io.h>
25#include <linux/init.h> 26#include <linux/init.h>
26#include <asm/uaccess.h> 27#include <asm/uaccess.h>
diff --git a/drivers/isdn/hardware/avm/b1dma.c b/drivers/isdn/hardware/avm/b1dma.c
index 124550d0dbf..9c8d7aa053c 100644
--- a/drivers/isdn/hardware/avm/b1dma.c
+++ b/drivers/isdn/hardware/avm/b1dma.c
@@ -20,6 +20,7 @@
20#include <linux/ioport.h> 20#include <linux/ioport.h>
21#include <linux/capi.h> 21#include <linux/capi.h>
22#include <linux/kernelcapi.h> 22#include <linux/kernelcapi.h>
23#include <linux/gfp.h>
23#include <asm/io.h> 24#include <asm/io.h>
24#include <linux/init.h> 25#include <linux/init.h>
25#include <asm/uaccess.h> 26#include <asm/uaccess.h>
diff --git a/drivers/isdn/hardware/avm/c4.c b/drivers/isdn/hardware/avm/c4.c
index de6e6b31181..7715d3242ec 100644
--- a/drivers/isdn/hardware/avm/c4.c
+++ b/drivers/isdn/hardware/avm/c4.c
@@ -22,6 +22,7 @@
22#include <linux/capi.h> 22#include <linux/capi.h>
23#include <linux/kernelcapi.h> 23#include <linux/kernelcapi.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/gfp.h>
25#include <asm/io.h> 26#include <asm/io.h>
26#include <asm/uaccess.h> 27#include <asm/uaccess.h>
27#include <linux/netdevice.h> 28#include <linux/netdevice.h>
diff --git a/drivers/isdn/hardware/avm/t1isa.c b/drivers/isdn/hardware/avm/t1isa.c
index baeeb3c2a3e..08216b14be1 100644
--- a/drivers/isdn/hardware/avm/t1isa.c
+++ b/drivers/isdn/hardware/avm/t1isa.c
@@ -21,6 +21,7 @@
21#include <linux/kernelcapi.h> 21#include <linux/kernelcapi.h>
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/pci.h> 23#include <linux/pci.h>
24#include <linux/gfp.h>
24#include <asm/io.h> 25#include <asm/io.h>
25#include <linux/isdn/capicmd.h> 26#include <linux/isdn/capicmd.h>
26#include <linux/isdn/capiutil.h> 27#include <linux/isdn/capiutil.h>
diff --git a/drivers/isdn/hardware/eicon/capimain.c b/drivers/isdn/hardware/eicon/capimain.c
index 0f073cd7376..97a20964cfc 100644
--- a/drivers/isdn/hardware/eicon/capimain.c
+++ b/drivers/isdn/hardware/eicon/capimain.c
@@ -11,6 +11,7 @@
11 */ 11 */
12 12
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/slab.h>
14#include <linux/init.h> 15#include <linux/init.h>
15#include <asm/uaccess.h> 16#include <asm/uaccess.h>
16#include <linux/seq_file.h> 17#include <linux/seq_file.h>
diff --git a/drivers/isdn/hardware/mISDN/avmfritz.c b/drivers/isdn/hardware/mISDN/avmfritz.c
index 81ac541d40d..d4215369bb5 100644
--- a/drivers/isdn/hardware/mISDN/avmfritz.c
+++ b/drivers/isdn/hardware/mISDN/avmfritz.c
@@ -24,6 +24,7 @@
24#include <linux/pci.h> 24#include <linux/pci.h>
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/mISDNhw.h> 26#include <linux/mISDNhw.h>
27#include <linux/slab.h>
27#include <asm/unaligned.h> 28#include <asm/unaligned.h>
28#include "ipac.h" 29#include "ipac.h"
29 30
diff --git a/drivers/isdn/hardware/mISDN/hfcmulti.c b/drivers/isdn/hardware/mISDN/hfcmulti.c
index 8affba3e569..75e71b5d921 100644
--- a/drivers/isdn/hardware/mISDN/hfcmulti.c
+++ b/drivers/isdn/hardware/mISDN/hfcmulti.c
@@ -153,6 +153,7 @@
153#define HFC_MULTI_VERSION "2.03" 153#define HFC_MULTI_VERSION "2.03"
154 154
155#include <linux/module.h> 155#include <linux/module.h>
156#include <linux/slab.h>
156#include <linux/pci.h> 157#include <linux/pci.h>
157#include <linux/delay.h> 158#include <linux/delay.h>
158#include <linux/mISDNhw.h> 159#include <linux/mISDNhw.h>
diff --git a/drivers/isdn/hardware/mISDN/hfcpci.c b/drivers/isdn/hardware/mISDN/hfcpci.c
index 70e6b0e0112..5940a2c1207 100644
--- a/drivers/isdn/hardware/mISDN/hfcpci.c
+++ b/drivers/isdn/hardware/mISDN/hfcpci.c
@@ -48,6 +48,7 @@
48#include <linux/pci.h> 48#include <linux/pci.h>
49#include <linux/delay.h> 49#include <linux/delay.h>
50#include <linux/mISDNhw.h> 50#include <linux/mISDNhw.h>
51#include <linux/slab.h>
51 52
52#include "hfc_pci.h" 53#include "hfc_pci.h"
53 54
diff --git a/drivers/isdn/hardware/mISDN/hfcsusb.c b/drivers/isdn/hardware/mISDN/hfcsusb.c
index a64bb6c67ba..b3b7e2879ba 100644
--- a/drivers/isdn/hardware/mISDN/hfcsusb.c
+++ b/drivers/isdn/hardware/mISDN/hfcsusb.c
@@ -33,6 +33,7 @@
33#include <linux/delay.h> 33#include <linux/delay.h>
34#include <linux/usb.h> 34#include <linux/usb.h>
35#include <linux/mISDNhw.h> 35#include <linux/mISDNhw.h>
36#include <linux/slab.h>
36#include "hfcsusb.h" 37#include "hfcsusb.h"
37 38
38static const char *hfcsusb_rev = "Revision: 0.3.3 (socket), 2008-11-05"; 39static const char *hfcsusb_rev = "Revision: 0.3.3 (socket), 2008-11-05";
diff --git a/drivers/isdn/hardware/mISDN/mISDNinfineon.c b/drivers/isdn/hardware/mISDN/mISDNinfineon.c
index 36c6c616a65..f5b3d2b26a0 100644
--- a/drivers/isdn/hardware/mISDN/mISDNinfineon.c
+++ b/drivers/isdn/hardware/mISDN/mISDNinfineon.c
@@ -42,6 +42,7 @@
42#include <linux/pci.h> 42#include <linux/pci.h>
43#include <linux/delay.h> 43#include <linux/delay.h>
44#include <linux/mISDNhw.h> 44#include <linux/mISDNhw.h>
45#include <linux/slab.h>
45#include "ipac.h" 46#include "ipac.h"
46 47
47#define INFINEON_REV "1.0" 48#define INFINEON_REV "1.0"
diff --git a/drivers/isdn/hardware/mISDN/mISDNipac.c b/drivers/isdn/hardware/mISDN/mISDNipac.c
index 613ba043537..64ecc6f5ffa 100644
--- a/drivers/isdn/hardware/mISDN/mISDNipac.c
+++ b/drivers/isdn/hardware/mISDN/mISDNipac.c
@@ -20,6 +20,7 @@
20 * 20 *
21 */ 21 */
22 22
23#include <linux/slab.h>
23#include <linux/module.h> 24#include <linux/module.h>
24#include <linux/mISDNhw.h> 25#include <linux/mISDNhw.h>
25#include "ipac.h" 26#include "ipac.h"
diff --git a/drivers/isdn/hardware/mISDN/mISDNisar.c b/drivers/isdn/hardware/mISDN/mISDNisar.c
index f0bc6fa9580..38eb31439a7 100644
--- a/drivers/isdn/hardware/mISDN/mISDNisar.c
+++ b/drivers/isdn/hardware/mISDN/mISDNisar.c
@@ -25,6 +25,7 @@
25 */ 25 */
26/* #define DEBUG */ 26/* #define DEBUG */
27 27
28#include <linux/gfp.h>
28#include <linux/delay.h> 29#include <linux/delay.h>
29#include <linux/vmalloc.h> 30#include <linux/vmalloc.h>
30#include <linux/mISDNhw.h> 31#include <linux/mISDNhw.h>
diff --git a/drivers/isdn/hardware/mISDN/netjet.c b/drivers/isdn/hardware/mISDN/netjet.c
index 6c1b164937a..0a3553df065 100644
--- a/drivers/isdn/hardware/mISDN/netjet.c
+++ b/drivers/isdn/hardware/mISDN/netjet.c
@@ -24,6 +24,7 @@
24#include <linux/pci.h> 24#include <linux/pci.h>
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/mISDNhw.h> 26#include <linux/mISDNhw.h>
27#include <linux/slab.h>
27#include "ipac.h" 28#include "ipac.h"
28#include "iohelper.h" 29#include "iohelper.h"
29#include "netjet.h" 30#include "netjet.h"
diff --git a/drivers/isdn/hardware/mISDN/speedfax.c b/drivers/isdn/hardware/mISDN/speedfax.c
index 7726afdbb40..d097a4e40e2 100644
--- a/drivers/isdn/hardware/mISDN/speedfax.c
+++ b/drivers/isdn/hardware/mISDN/speedfax.c
@@ -23,6 +23,7 @@
23 */ 23 */
24 24
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/slab.h>
26#include <linux/pci.h> 27#include <linux/pci.h>
27#include <linux/delay.h> 28#include <linux/delay.h>
28#include <linux/mISDNhw.h> 29#include <linux/mISDNhw.h>
diff --git a/drivers/isdn/hardware/mISDN/w6692.c b/drivers/isdn/hardware/mISDN/w6692.c
index 2952a58c7a6..31f9d71fb22 100644
--- a/drivers/isdn/hardware/mISDN/w6692.c
+++ b/drivers/isdn/hardware/mISDN/w6692.c
@@ -25,6 +25,7 @@
25#include <linux/pci.h> 25#include <linux/pci.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/mISDNhw.h> 27#include <linux/mISDNhw.h>
28#include <linux/slab.h>
28#include "w6692.h" 29#include "w6692.h"
29 30
30#define W6692_REV "2.0" 31#define W6692_REV "2.0"
diff --git a/drivers/isdn/hisax/amd7930_fn.c b/drivers/isdn/hisax/amd7930_fn.c
index d6fdf1f6675..5d727839787 100644
--- a/drivers/isdn/hisax/amd7930_fn.c
+++ b/drivers/isdn/hisax/amd7930_fn.c
@@ -59,6 +59,7 @@
59#include "amd7930_fn.h" 59#include "amd7930_fn.h"
60#include <linux/interrupt.h> 60#include <linux/interrupt.h>
61#include <linux/init.h> 61#include <linux/init.h>
62#include <linux/gfp.h>
62 63
63static void Amd7930_new_ph(struct IsdnCardState *cs); 64static void Amd7930_new_ph(struct IsdnCardState *cs);
64 65
diff --git a/drivers/isdn/hisax/avm_pci.c b/drivers/isdn/hisax/avm_pci.c
index 14295a155e7..fcf4ed1cb4b 100644
--- a/drivers/isdn/hisax/avm_pci.c
+++ b/drivers/isdn/hisax/avm_pci.c
@@ -17,6 +17,7 @@
17#include "isac.h" 17#include "isac.h"
18#include "isdnl1.h" 18#include "isdnl1.h"
19#include <linux/pci.h> 19#include <linux/pci.h>
20#include <linux/slab.h>
20#include <linux/isapnp.h> 21#include <linux/isapnp.h>
21#include <linux/interrupt.h> 22#include <linux/interrupt.h>
22 23
diff --git a/drivers/isdn/hisax/avma1_cs.c b/drivers/isdn/hisax/avma1_cs.c
index e5deb15cf40..8d1d63a02b3 100644
--- a/drivers/isdn/hisax/avma1_cs.c
+++ b/drivers/isdn/hisax/avma1_cs.c
@@ -50,7 +50,7 @@ module_param(isdnprot, int, 0);
50 handler. 50 handler.
51*/ 51*/
52 52
53static int avma1cs_config(struct pcmcia_device *link); 53static int avma1cs_config(struct pcmcia_device *link) __devinit ;
54static void avma1cs_release(struct pcmcia_device *link); 54static void avma1cs_release(struct pcmcia_device *link);
55 55
56/* 56/*
@@ -59,7 +59,7 @@ static void avma1cs_release(struct pcmcia_device *link);
59 needed to manage one actual PCMCIA card. 59 needed to manage one actual PCMCIA card.
60*/ 60*/
61 61
62static void avma1cs_detach(struct pcmcia_device *p_dev); 62static void avma1cs_detach(struct pcmcia_device *p_dev) __devexit ;
63 63
64 64
65/* 65/*
@@ -99,7 +99,7 @@ typedef struct local_info_t {
99 99
100======================================================================*/ 100======================================================================*/
101 101
102static int avma1cs_probe(struct pcmcia_device *p_dev) 102static int __devinit avma1cs_probe(struct pcmcia_device *p_dev)
103{ 103{
104 local_info_t *local; 104 local_info_t *local;
105 105
@@ -140,7 +140,7 @@ static int avma1cs_probe(struct pcmcia_device *p_dev)
140 140
141======================================================================*/ 141======================================================================*/
142 142
143static void avma1cs_detach(struct pcmcia_device *link) 143static void __devexit avma1cs_detach(struct pcmcia_device *link)
144{ 144{
145 dev_dbg(&link->dev, "avma1cs_detach(0x%p)\n", link); 145 dev_dbg(&link->dev, "avma1cs_detach(0x%p)\n", link);
146 avma1cs_release(link); 146 avma1cs_release(link);
@@ -174,7 +174,7 @@ static int avma1cs_configcheck(struct pcmcia_device *p_dev,
174} 174}
175 175
176 176
177static int avma1cs_config(struct pcmcia_device *link) 177static int __devinit avma1cs_config(struct pcmcia_device *link)
178{ 178{
179 local_info_t *dev; 179 local_info_t *dev;
180 int i; 180 int i;
@@ -282,7 +282,7 @@ static struct pcmcia_driver avma1cs_driver = {
282 .name = "avma1_cs", 282 .name = "avma1_cs",
283 }, 283 },
284 .probe = avma1cs_probe, 284 .probe = avma1cs_probe,
285 .remove = avma1cs_detach, 285 .remove = __devexit_p(avma1cs_detach),
286 .id_table = avma1cs_ids, 286 .id_table = avma1cs_ids,
287}; 287};
288 288
diff --git a/drivers/isdn/hisax/callc.c b/drivers/isdn/hisax/callc.c
index 475b1a02000..f58ded8f403 100644
--- a/drivers/isdn/hisax/callc.c
+++ b/drivers/isdn/hisax/callc.c
@@ -17,6 +17,7 @@
17 */ 17 */
18 18
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/slab.h>
20#include <linux/init.h> 21#include <linux/init.h>
21#include "hisax.h" 22#include "hisax.h"
22#include <linux/isdn/capicmd.h> 23#include <linux/isdn/capicmd.h>
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index 4fab18d4d02..544cf4b1cce 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -23,6 +23,7 @@
23#include <linux/kernel_stat.h> 23#include <linux/kernel_stat.h>
24#include <linux/workqueue.h> 24#include <linux/workqueue.h>
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/slab.h>
26#define HISAX_STATUS_BUFSIZE 4096 27#define HISAX_STATUS_BUFSIZE 4096
27 28
28/* 29/*
diff --git a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c
index 23c41fcd864..5d9d338814a 100644
--- a/drivers/isdn/hisax/elsa.c
+++ b/drivers/isdn/hisax/elsa.c
@@ -19,6 +19,7 @@
19 */ 19 */
20 20
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/slab.h>
22#include "hisax.h" 23#include "hisax.h"
23#include "arcofi.h" 24#include "arcofi.h"
24#include "isac.h" 25#include "isac.h"
diff --git a/drivers/isdn/hisax/elsa_cs.c b/drivers/isdn/hisax/elsa_cs.c
index c9a30b1c923..c9f2279e21f 100644
--- a/drivers/isdn/hisax/elsa_cs.c
+++ b/drivers/isdn/hisax/elsa_cs.c
@@ -76,7 +76,7 @@ module_param(protocol, int, 0);
76 handler. 76 handler.
77*/ 77*/
78 78
79static int elsa_cs_config(struct pcmcia_device *link); 79static int elsa_cs_config(struct pcmcia_device *link) __devinit ;
80static void elsa_cs_release(struct pcmcia_device *link); 80static void elsa_cs_release(struct pcmcia_device *link);
81 81
82/* 82/*
@@ -85,7 +85,7 @@ static void elsa_cs_release(struct pcmcia_device *link);
85 needed to manage one actual PCMCIA card. 85 needed to manage one actual PCMCIA card.
86*/ 86*/
87 87
88static void elsa_cs_detach(struct pcmcia_device *p_dev); 88static void elsa_cs_detach(struct pcmcia_device *p_dev) __devexit;
89 89
90/* 90/*
91 A driver needs to provide a dev_node_t structure for each device 91 A driver needs to provide a dev_node_t structure for each device
@@ -121,7 +121,7 @@ typedef struct local_info_t {
121 121
122======================================================================*/ 122======================================================================*/
123 123
124static int elsa_cs_probe(struct pcmcia_device *link) 124static int __devinit elsa_cs_probe(struct pcmcia_device *link)
125{ 125{
126 local_info_t *local; 126 local_info_t *local;
127 127
@@ -166,7 +166,7 @@ static int elsa_cs_probe(struct pcmcia_device *link)
166 166
167======================================================================*/ 167======================================================================*/
168 168
169static void elsa_cs_detach(struct pcmcia_device *link) 169static void __devexit elsa_cs_detach(struct pcmcia_device *link)
170{ 170{
171 local_info_t *info = link->priv; 171 local_info_t *info = link->priv;
172 172
@@ -210,7 +210,7 @@ static int elsa_cs_configcheck(struct pcmcia_device *p_dev,
210 return -ENODEV; 210 return -ENODEV;
211} 211}
212 212
213static int elsa_cs_config(struct pcmcia_device *link) 213static int __devinit elsa_cs_config(struct pcmcia_device *link)
214{ 214{
215 local_info_t *dev; 215 local_info_t *dev;
216 int i; 216 int i;
@@ -327,7 +327,7 @@ static struct pcmcia_driver elsa_cs_driver = {
327 .name = "elsa_cs", 327 .name = "elsa_cs",
328 }, 328 },
329 .probe = elsa_cs_probe, 329 .probe = elsa_cs_probe,
330 .remove = elsa_cs_detach, 330 .remove = __devexit_p(elsa_cs_detach),
331 .id_table = elsa_ids, 331 .id_table = elsa_ids,
332 .suspend = elsa_suspend, 332 .suspend = elsa_suspend,
333 .resume = elsa_resume, 333 .resume = elsa_resume,
diff --git a/drivers/isdn/hisax/elsa_ser.c b/drivers/isdn/hisax/elsa_ser.c
index 1657bba7879..cbda3790a10 100644
--- a/drivers/isdn/hisax/elsa_ser.c
+++ b/drivers/isdn/hisax/elsa_ser.c
@@ -9,6 +9,7 @@
9 9
10#include <linux/serial.h> 10#include <linux/serial.h>
11#include <linux/serial_reg.h> 11#include <linux/serial_reg.h>
12#include <linux/slab.h>
12 13
13#define MAX_MODEM_BUF 256 14#define MAX_MODEM_BUF 256
14#define WAKEUP_CHARS (MAX_MODEM_BUF/2) 15#define WAKEUP_CHARS (MAX_MODEM_BUF/2)
diff --git a/drivers/isdn/hisax/fsm.c b/drivers/isdn/hisax/fsm.c
index 34fade96a58..732ea633758 100644
--- a/drivers/isdn/hisax/fsm.c
+++ b/drivers/isdn/hisax/fsm.c
@@ -15,6 +15,7 @@
15 */ 15 */
16 16
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/slab.h>
18#include <linux/init.h> 19#include <linux/init.h>
19#include "hisax.h" 20#include "hisax.h"
20 21
diff --git a/drivers/isdn/hisax/hfc4s8s_l1.c b/drivers/isdn/hisax/hfc4s8s_l1.c
index ab98e135bcb..051b44e2556 100644
--- a/drivers/isdn/hisax/hfc4s8s_l1.c
+++ b/drivers/isdn/hisax/hfc4s8s_l1.c
@@ -25,6 +25,7 @@
25#include <linux/pci.h> 25#include <linux/pci.h>
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/slab.h>
28#include <linux/timer.h> 29#include <linux/timer.h>
29#include <linux/skbuff.h> 30#include <linux/skbuff.h>
30#include <linux/wait.h> 31#include <linux/wait.h>
diff --git a/drivers/isdn/hisax/hfc_2bds0.c b/drivers/isdn/hisax/hfc_2bds0.c
index 8d22f50760e..7250f56a524 100644
--- a/drivers/isdn/hisax/hfc_2bds0.c
+++ b/drivers/isdn/hisax/hfc_2bds0.c
@@ -12,6 +12,7 @@
12 12
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/sched.h> 14#include <linux/sched.h>
15#include <linux/slab.h>
15#include "hisax.h" 16#include "hisax.h"
16#include "hfc_2bds0.h" 17#include "hfc_2bds0.h"
17#include "isdnl1.h" 18#include "isdnl1.h"
diff --git a/drivers/isdn/hisax/hfc_2bs0.c b/drivers/isdn/hisax/hfc_2bs0.c
index d0520ad3067..b1f6481e119 100644
--- a/drivers/isdn/hisax/hfc_2bs0.c
+++ b/drivers/isdn/hisax/hfc_2bs0.c
@@ -16,6 +16,7 @@
16#include "isac.h" 16#include "isac.h"
17#include "isdnl1.h" 17#include "isdnl1.h"
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/slab.h>
19 20
20static inline int 21static inline int
21WaitForBusy(struct IsdnCardState *cs) 22WaitForBusy(struct IsdnCardState *cs)
diff --git a/drivers/isdn/hisax/hfc_sx.c b/drivers/isdn/hisax/hfc_sx.c
index 419f87cad8c..be5faf4aa86 100644
--- a/drivers/isdn/hisax/hfc_sx.c
+++ b/drivers/isdn/hisax/hfc_sx.c
@@ -17,6 +17,7 @@
17#include "isdnl1.h" 17#include "isdnl1.h"
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/isapnp.h> 19#include <linux/isapnp.h>
20#include <linux/slab.h>
20 21
21static const char *hfcsx_revision = "$Revision: 1.12.2.5 $"; 22static const char *hfcsx_revision = "$Revision: 1.12.2.5 $";
22 23
diff --git a/drivers/isdn/hisax/hfc_usb.c b/drivers/isdn/hisax/hfc_usb.c
index aaaeaafd86f..ed9527aa5f2 100644
--- a/drivers/isdn/hisax/hfc_usb.c
+++ b/drivers/isdn/hisax/hfc_usb.c
@@ -39,6 +39,7 @@
39#include <linux/kernel.h> 39#include <linux/kernel.h>
40#include <linux/sched.h> 40#include <linux/sched.h>
41#include <linux/moduleparam.h> 41#include <linux/moduleparam.h>
42#include <linux/slab.h>
42#include "hisax.h" 43#include "hisax.h"
43#include "hisax_if.h" 44#include "hisax_if.h"
44#include "hfc_usb.h" 45#include "hfc_usb.h"
diff --git a/drivers/isdn/hisax/hisax_isac.c b/drivers/isdn/hisax/hisax_isac.c
index d0fefcf999c..a8447fa2f47 100644
--- a/drivers/isdn/hisax/hisax_isac.c
+++ b/drivers/isdn/hisax/hisax_isac.c
@@ -21,6 +21,7 @@
21 */ 21 */
22 22
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/gfp.h>
24#include <linux/init.h> 25#include <linux/init.h>
25#include <linux/netdevice.h> 26#include <linux/netdevice.h>
26#include "hisax_isac.h" 27#include "hisax_isac.h"
diff --git a/drivers/isdn/hisax/hscx.c b/drivers/isdn/hisax/hscx.c
index c8f9951f791..904b9100df9 100644
--- a/drivers/isdn/hisax/hscx.c
+++ b/drivers/isdn/hisax/hscx.c
@@ -16,6 +16,7 @@
16#include "isac.h" 16#include "isac.h"
17#include "isdnl1.h" 17#include "isdnl1.h"
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/slab.h>
19 20
20static char *HSCXVer[] = 21static char *HSCXVer[] =
21{"A1", "?1", "A2", "?3", "A3", "V2.1", "?6", "?7", 22{"A1", "?1", "A2", "?3", "A3", "V2.1", "?6", "?7",
diff --git a/drivers/isdn/hisax/icc.c b/drivers/isdn/hisax/icc.c
index c80cbb8a2ef..63057268cc3 100644
--- a/drivers/isdn/hisax/icc.c
+++ b/drivers/isdn/hisax/icc.c
@@ -20,6 +20,7 @@
20// #include "arcofi.h" 20// #include "arcofi.h"
21#include "isdnl1.h" 21#include "isdnl1.h"
22#include <linux/interrupt.h> 22#include <linux/interrupt.h>
23#include <linux/slab.h>
23 24
24#define DBUSY_TIMER_VALUE 80 25#define DBUSY_TIMER_VALUE 80
25#define ARCOFI_USE 0 26#define ARCOFI_USE 0
diff --git a/drivers/isdn/hisax/ipacx.c b/drivers/isdn/hisax/ipacx.c
index 00afd553890..751b25f2ff5 100644
--- a/drivers/isdn/hisax/ipacx.c
+++ b/drivers/isdn/hisax/ipacx.c
@@ -10,6 +10,7 @@
10 * 10 *
11 */ 11 */
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/slab.h>
13#include <linux/init.h> 14#include <linux/init.h>
14#include "hisax_if.h" 15#include "hisax_if.h"
15#include "hisax.h" 16#include "hisax.h"
diff --git a/drivers/isdn/hisax/isac.c b/drivers/isdn/hisax/isac.c
index a19354d9434..2b66728136d 100644
--- a/drivers/isdn/hisax/isac.c
+++ b/drivers/isdn/hisax/isac.c
@@ -18,6 +18,7 @@
18#include "arcofi.h" 18#include "arcofi.h"
19#include "isdnl1.h" 19#include "isdnl1.h"
20#include <linux/interrupt.h> 20#include <linux/interrupt.h>
21#include <linux/slab.h>
21#include <linux/init.h> 22#include <linux/init.h>
22 23
23#define DBUSY_TIMER_VALUE 80 24#define DBUSY_TIMER_VALUE 80
diff --git a/drivers/isdn/hisax/isar.c b/drivers/isdn/hisax/isar.c
index 6bde16c00fb..40b914bded8 100644
--- a/drivers/isdn/hisax/isar.c
+++ b/drivers/isdn/hisax/isar.c
@@ -13,6 +13,7 @@
13#include "isar.h" 13#include "isar.h"
14#include "isdnl1.h" 14#include "isdnl1.h"
15#include <linux/interrupt.h> 15#include <linux/interrupt.h>
16#include <linux/slab.h>
16 17
17#define DBG_LOADFIRM 0 18#define DBG_LOADFIRM 0
18#define DUMP_MBOXFRAME 2 19#define DUMP_MBOXFRAME 2
diff --git a/drivers/isdn/hisax/isdnl1.c b/drivers/isdn/hisax/isdnl1.c
index 9ce6abe05b1..d5eeacf565d 100644
--- a/drivers/isdn/hisax/isdnl1.c
+++ b/drivers/isdn/hisax/isdnl1.c
@@ -19,6 +19,7 @@
19 */ 19 */
20 20
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/gfp.h>
22#include "hisax.h" 23#include "hisax.h"
23#include "isdnl1.h" 24#include "isdnl1.h"
24 25
diff --git a/drivers/isdn/hisax/isdnl2.c b/drivers/isdn/hisax/isdnl2.c
index 7b9496a63b5..0858791978d 100644
--- a/drivers/isdn/hisax/isdnl2.c
+++ b/drivers/isdn/hisax/isdnl2.c
@@ -16,6 +16,7 @@
16 */ 16 */
17 17
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/gfp.h>
19#include "hisax.h" 20#include "hisax.h"
20#include "isdnl2.h" 21#include "isdnl2.h"
21 22
diff --git a/drivers/isdn/hisax/isdnl3.c b/drivers/isdn/hisax/isdnl3.c
index 06766022d3a..fd0b643ab74 100644
--- a/drivers/isdn/hisax/isdnl3.c
+++ b/drivers/isdn/hisax/isdnl3.c
@@ -16,6 +16,7 @@
16 */ 16 */
17 17
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/slab.h>
19#include "hisax.h" 20#include "hisax.h"
20#include "isdnl3.h" 21#include "isdnl3.h"
21 22
diff --git a/drivers/isdn/hisax/jade.c b/drivers/isdn/hisax/jade.c
index 70840a710ac..ea8f840871d 100644
--- a/drivers/isdn/hisax/jade.c
+++ b/drivers/isdn/hisax/jade.c
@@ -17,6 +17,7 @@
17#include "jade.h" 17#include "jade.h"
18#include "isdnl1.h" 18#include "isdnl1.h"
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#include <linux/slab.h>
20 21
21 22
22int 23int
diff --git a/drivers/isdn/hisax/l3dss1.c b/drivers/isdn/hisax/l3dss1.c
index a12fa4d3490..cc6ee2d3988 100644
--- a/drivers/isdn/hisax/l3dss1.c
+++ b/drivers/isdn/hisax/l3dss1.c
@@ -23,6 +23,7 @@
23#include "isdnl3.h" 23#include "isdnl3.h"
24#include "l3dss1.h" 24#include "l3dss1.h"
25#include <linux/ctype.h> 25#include <linux/ctype.h>
26#include <linux/slab.h>
26 27
27extern char *HiSax_getrev(const char *revision); 28extern char *HiSax_getrev(const char *revision);
28static const char *dss1_revision = "$Revision: 2.32.2.3 $"; 29static const char *dss1_revision = "$Revision: 2.32.2.3 $";
diff --git a/drivers/isdn/hisax/l3ni1.c b/drivers/isdn/hisax/l3ni1.c
index 4622d43c7e1..f9584491fe8 100644
--- a/drivers/isdn/hisax/l3ni1.c
+++ b/drivers/isdn/hisax/l3ni1.c
@@ -22,6 +22,7 @@
22#include "isdnl3.h" 22#include "isdnl3.h"
23#include "l3ni1.h" 23#include "l3ni1.h"
24#include <linux/ctype.h> 24#include <linux/ctype.h>
25#include <linux/slab.h>
25 26
26extern char *HiSax_getrev(const char *revision); 27extern char *HiSax_getrev(const char *revision);
27static const char *ni1_revision = "$Revision: 2.8.2.3 $"; 28static const char *ni1_revision = "$Revision: 2.8.2.3 $";
diff --git a/drivers/isdn/hisax/netjet.c b/drivers/isdn/hisax/netjet.c
index 02c6fbaeccf..5d7f0f2ff9b 100644
--- a/drivers/isdn/hisax/netjet.c
+++ b/drivers/isdn/hisax/netjet.c
@@ -21,6 +21,7 @@
21#include "isdnl1.h" 21#include "isdnl1.h"
22#include <linux/interrupt.h> 22#include <linux/interrupt.h>
23#include <linux/ppp_defs.h> 23#include <linux/ppp_defs.h>
24#include <linux/slab.h>
24#include <asm/io.h> 25#include <asm/io.h>
25#include "netjet.h" 26#include "netjet.h"
26 27
diff --git a/drivers/isdn/hisax/sedlbauer_cs.c b/drivers/isdn/hisax/sedlbauer_cs.c
index 7836ec3c7f8..71b3ddef03b 100644
--- a/drivers/isdn/hisax/sedlbauer_cs.c
+++ b/drivers/isdn/hisax/sedlbauer_cs.c
@@ -76,7 +76,7 @@ module_param(protocol, int, 0);
76 event handler. 76 event handler.
77*/ 77*/
78 78
79static int sedlbauer_config(struct pcmcia_device *link); 79static int sedlbauer_config(struct pcmcia_device *link) __devinit ;
80static void sedlbauer_release(struct pcmcia_device *link); 80static void sedlbauer_release(struct pcmcia_device *link);
81 81
82/* 82/*
@@ -85,7 +85,7 @@ static void sedlbauer_release(struct pcmcia_device *link);
85 needed to manage one actual PCMCIA card. 85 needed to manage one actual PCMCIA card.
86*/ 86*/
87 87
88static void sedlbauer_detach(struct pcmcia_device *p_dev); 88static void sedlbauer_detach(struct pcmcia_device *p_dev) __devexit;
89 89
90/* 90/*
91 You'll also need to prototype all the functions that will actually 91 You'll also need to prototype all the functions that will actually
@@ -129,7 +129,7 @@ typedef struct local_info_t {
129 129
130======================================================================*/ 130======================================================================*/
131 131
132static int sedlbauer_probe(struct pcmcia_device *link) 132static int __devinit sedlbauer_probe(struct pcmcia_device *link)
133{ 133{
134 local_info_t *local; 134 local_info_t *local;
135 135
@@ -177,7 +177,7 @@ static int sedlbauer_probe(struct pcmcia_device *link)
177 177
178======================================================================*/ 178======================================================================*/
179 179
180static void sedlbauer_detach(struct pcmcia_device *link) 180static void __devexit sedlbauer_detach(struct pcmcia_device *link)
181{ 181{
182 dev_dbg(&link->dev, "sedlbauer_detach(0x%p)\n", link); 182 dev_dbg(&link->dev, "sedlbauer_detach(0x%p)\n", link);
183 183
@@ -283,7 +283,7 @@ static int sedlbauer_config_check(struct pcmcia_device *p_dev,
283 283
284 284
285 285
286static int sedlbauer_config(struct pcmcia_device *link) 286static int __devinit sedlbauer_config(struct pcmcia_device *link)
287{ 287{
288 local_info_t *dev = link->priv; 288 local_info_t *dev = link->priv;
289 win_req_t *req; 289 win_req_t *req;
@@ -441,7 +441,7 @@ static struct pcmcia_driver sedlbauer_driver = {
441 .name = "sedlbauer_cs", 441 .name = "sedlbauer_cs",
442 }, 442 },
443 .probe = sedlbauer_probe, 443 .probe = sedlbauer_probe,
444 .remove = sedlbauer_detach, 444 .remove = __devexit_p(sedlbauer_detach),
445 .id_table = sedlbauer_ids, 445 .id_table = sedlbauer_ids,
446 .suspend = sedlbauer_suspend, 446 .suspend = sedlbauer_suspend,
447 .resume = sedlbauer_resume, 447 .resume = sedlbauer_resume,
diff --git a/drivers/isdn/hisax/st5481_b.c b/drivers/isdn/hisax/st5481_b.c
index 95b1cdd9795..e56e5af889b 100644
--- a/drivers/isdn/hisax/st5481_b.c
+++ b/drivers/isdn/hisax/st5481_b.c
@@ -11,8 +11,8 @@
11 */ 11 */
12 12
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/gfp.h>
14#include <linux/usb.h> 15#include <linux/usb.h>
15#include <linux/slab.h>
16#include <linux/netdevice.h> 16#include <linux/netdevice.h>
17#include <linux/bitrev.h> 17#include <linux/bitrev.h>
18#include "st5481.h" 18#include "st5481.h"
diff --git a/drivers/isdn/hisax/st5481_d.c b/drivers/isdn/hisax/st5481_d.c
index 39e8e49cfd2..b7876b19fe7 100644
--- a/drivers/isdn/hisax/st5481_d.c
+++ b/drivers/isdn/hisax/st5481_d.c
@@ -11,8 +11,8 @@
11 */ 11 */
12 12
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/gfp.h>
14#include <linux/usb.h> 15#include <linux/usb.h>
15#include <linux/slab.h>
16#include <linux/netdevice.h> 16#include <linux/netdevice.h>
17#include "st5481.h" 17#include "st5481.h"
18 18
diff --git a/drivers/isdn/hisax/tei.c b/drivers/isdn/hisax/tei.c
index 6e65424f1f0..f4cb178b066 100644
--- a/drivers/isdn/hisax/tei.c
+++ b/drivers/isdn/hisax/tei.c
@@ -17,6 +17,7 @@
17 17
18#include "hisax.h" 18#include "hisax.h"
19#include "isdnl2.h" 19#include "isdnl2.h"
20#include <linux/gfp.h>
20#include <linux/init.h> 21#include <linux/init.h>
21#include <linux/random.h> 22#include <linux/random.h>
22 23
diff --git a/drivers/isdn/hisax/teles_cs.c b/drivers/isdn/hisax/teles_cs.c
index b0c5976cbdb..d010a0da8e1 100644
--- a/drivers/isdn/hisax/teles_cs.c
+++ b/drivers/isdn/hisax/teles_cs.c
@@ -57,7 +57,7 @@ module_param(protocol, int, 0);
57 handler. 57 handler.
58*/ 58*/
59 59
60static int teles_cs_config(struct pcmcia_device *link); 60static int teles_cs_config(struct pcmcia_device *link) __devinit ;
61static void teles_cs_release(struct pcmcia_device *link); 61static void teles_cs_release(struct pcmcia_device *link);
62 62
63/* 63/*
@@ -66,7 +66,7 @@ static void teles_cs_release(struct pcmcia_device *link);
66 needed to manage one actual PCMCIA card. 66 needed to manage one actual PCMCIA card.
67*/ 67*/
68 68
69static void teles_detach(struct pcmcia_device *p_dev); 69static void teles_detach(struct pcmcia_device *p_dev) __devexit ;
70 70
71/* 71/*
72 A linked list of "instances" of the teles_cs device. Each actual 72 A linked list of "instances" of the teles_cs device. Each actual
@@ -112,7 +112,7 @@ typedef struct local_info_t {
112 112
113======================================================================*/ 113======================================================================*/
114 114
115static int teles_probe(struct pcmcia_device *link) 115static int __devinit teles_probe(struct pcmcia_device *link)
116{ 116{
117 local_info_t *local; 117 local_info_t *local;
118 118
@@ -156,7 +156,7 @@ static int teles_probe(struct pcmcia_device *link)
156 156
157======================================================================*/ 157======================================================================*/
158 158
159static void teles_detach(struct pcmcia_device *link) 159static void __devexit teles_detach(struct pcmcia_device *link)
160{ 160{
161 local_info_t *info = link->priv; 161 local_info_t *info = link->priv;
162 162
@@ -200,7 +200,7 @@ static int teles_cs_configcheck(struct pcmcia_device *p_dev,
200 return -ENODEV; 200 return -ENODEV;
201} 201}
202 202
203static int teles_cs_config(struct pcmcia_device *link) 203static int __devinit teles_cs_config(struct pcmcia_device *link)
204{ 204{
205 local_info_t *dev; 205 local_info_t *dev;
206 int i; 206 int i;
@@ -319,7 +319,7 @@ static struct pcmcia_driver teles_cs_driver = {
319 .name = "teles_cs", 319 .name = "teles_cs",
320 }, 320 },
321 .probe = teles_probe, 321 .probe = teles_probe,
322 .remove = teles_detach, 322 .remove = __devexit_p(teles_detach),
323 .id_table = teles_ids, 323 .id_table = teles_ids,
324 .suspend = teles_suspend, 324 .suspend = teles_suspend,
325 .resume = teles_resume, 325 .resume = teles_resume,
diff --git a/drivers/isdn/hisax/w6692.c b/drivers/isdn/hisax/w6692.c
index 9d6e864023f..e2cfb6f5aa4 100644
--- a/drivers/isdn/hisax/w6692.c
+++ b/drivers/isdn/hisax/w6692.c
@@ -16,6 +16,7 @@
16#include "isdnl1.h" 16#include "isdnl1.h"
17#include <linux/interrupt.h> 17#include <linux/interrupt.h>
18#include <linux/pci.h> 18#include <linux/pci.h>
19#include <linux/slab.h>
19 20
20/* table entry in the PCI devices list */ 21/* table entry in the PCI devices list */
21typedef struct { 22typedef struct {
diff --git a/drivers/isdn/hysdn/hycapi.c b/drivers/isdn/hysdn/hycapi.c
index fe874afa4f8..6299b06ae00 100644
--- a/drivers/isdn/hysdn/hycapi.c
+++ b/drivers/isdn/hysdn/hycapi.c
@@ -17,6 +17,7 @@
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/skbuff.h> 18#include <linux/skbuff.h>
19#include <linux/netdevice.h> 19#include <linux/netdevice.h>
20#include <linux/slab.h>
20 21
21#define VER_DRIVER 0 22#define VER_DRIVER 0
22#define VER_CARDTYPE 1 23#define VER_CARDTYPE 1
diff --git a/drivers/isdn/hysdn/hysdn_procconf.c b/drivers/isdn/hysdn/hysdn_procconf.c
index 90b35e1a4b7..80966462d6d 100644
--- a/drivers/isdn/hysdn/hysdn_procconf.c
+++ b/drivers/isdn/hysdn/hysdn_procconf.c
@@ -16,6 +16,7 @@
16#include <linux/poll.h> 16#include <linux/poll.h>
17#include <linux/proc_fs.h> 17#include <linux/proc_fs.h>
18#include <linux/pci.h> 18#include <linux/pci.h>
19#include <linux/slab.h>
19#include <linux/smp_lock.h> 20#include <linux/smp_lock.h>
20#include <net/net_namespace.h> 21#include <net/net_namespace.h>
21 22
diff --git a/drivers/isdn/hysdn/hysdn_proclog.c b/drivers/isdn/hysdn/hysdn_proclog.c
index 8bcae28c440..e83f6fda32f 100644
--- a/drivers/isdn/hysdn/hysdn_proclog.c
+++ b/drivers/isdn/hysdn/hysdn_proclog.c
@@ -14,6 +14,7 @@
14#include <linux/poll.h> 14#include <linux/poll.h>
15#include <linux/proc_fs.h> 15#include <linux/proc_fs.h>
16#include <linux/sched.h> 16#include <linux/sched.h>
17#include <linux/slab.h>
17#include <linux/smp_lock.h> 18#include <linux/smp_lock.h>
18 19
19#include "hysdn_defs.h" 20#include "hysdn_defs.h"
diff --git a/drivers/isdn/i4l/isdn_audio.c b/drivers/isdn/i4l/isdn_audio.c
index fb350c567c6..861bdf3421f 100644
--- a/drivers/isdn/i4l/isdn_audio.c
+++ b/drivers/isdn/i4l/isdn_audio.c
@@ -12,6 +12,7 @@
12 */ 12 */
13 13
14#include <linux/isdn.h> 14#include <linux/isdn.h>
15#include <linux/slab.h>
15#include "isdn_audio.h" 16#include "isdn_audio.h"
16#include "isdn_common.h" 17#include "isdn_common.h"
17 18
diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
index 00c60e2e0ff..70044ee4b22 100644
--- a/drivers/isdn/i4l/isdn_common.c
+++ b/drivers/isdn/i4l/isdn_common.c
@@ -14,6 +14,7 @@
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/poll.h> 16#include <linux/poll.h>
17#include <linux/slab.h>
17#include <linux/vmalloc.h> 18#include <linux/vmalloc.h>
18#include <linux/isdn.h> 19#include <linux/isdn.h>
19#include <linux/smp_lock.h> 20#include <linux/smp_lock.h>
diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c
index 507e13d9a57..8c85d1e88cc 100644
--- a/drivers/isdn/i4l/isdn_net.c
+++ b/drivers/isdn/i4l/isdn_net.c
@@ -23,6 +23,7 @@
23 */ 23 */
24 24
25#include <linux/isdn.h> 25#include <linux/isdn.h>
26#include <linux/slab.h>
26#include <net/arp.h> 27#include <net/arp.h>
27#include <net/dst.h> 28#include <net/dst.h>
28#include <net/pkt_sched.h> 29#include <net/pkt_sched.h>
diff --git a/drivers/isdn/i4l/isdn_ppp.c b/drivers/isdn/i4l/isdn_ppp.c
index 45df6675e8e..f37b8f68d0a 100644
--- a/drivers/isdn/i4l/isdn_ppp.c
+++ b/drivers/isdn/i4l/isdn_ppp.c
@@ -12,6 +12,7 @@
12#include <linux/isdn.h> 12#include <linux/isdn.h>
13#include <linux/poll.h> 13#include <linux/poll.h>
14#include <linux/ppp-comp.h> 14#include <linux/ppp-comp.h>
15#include <linux/slab.h>
15#ifdef CONFIG_IPPP_FILTER 16#ifdef CONFIG_IPPP_FILTER
16#include <linux/filter.h> 17#include <linux/filter.h>
17#endif 18#endif
diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
index 2881a66c1aa..fc8454d2eea 100644
--- a/drivers/isdn/i4l/isdn_tty.c
+++ b/drivers/isdn/i4l/isdn_tty.c
@@ -12,6 +12,7 @@
12#undef ISDN_TTY_STAT_DEBUG 12#undef ISDN_TTY_STAT_DEBUG
13 13
14#include <linux/isdn.h> 14#include <linux/isdn.h>
15#include <linux/slab.h>
15#include <linux/delay.h> 16#include <linux/delay.h>
16#include <linux/smp_lock.h> 17#include <linux/smp_lock.h>
17#include "isdn_common.h" 18#include "isdn_common.h"
diff --git a/drivers/isdn/i4l/isdn_x25iface.c b/drivers/isdn/i4l/isdn_x25iface.c
index 8b3efc24316..efcf1f9327e 100644
--- a/drivers/isdn/i4l/isdn_x25iface.c
+++ b/drivers/isdn/i4l/isdn_x25iface.c
@@ -20,6 +20,7 @@
20/* #include <linux/isdn.h> */ 20/* #include <linux/isdn.h> */
21#include <linux/netdevice.h> 21#include <linux/netdevice.h>
22#include <linux/concap.h> 22#include <linux/concap.h>
23#include <linux/slab.h>
23#include <linux/wanrouter.h> 24#include <linux/wanrouter.h>
24#include <net/x25device.h> 25#include <net/x25device.h>
25#include "isdn_x25iface.h" 26#include "isdn_x25iface.h"
diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
index bf7997abc4a..2e847a90bad 100644
--- a/drivers/isdn/icn/icn.c
+++ b/drivers/isdn/icn/icn.c
@@ -12,6 +12,7 @@
12#include "icn.h" 12#include "icn.h"
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/slab.h>
15#include <linux/sched.h> 16#include <linux/sched.h>
16 17
17static int portbase = ICN_BASEADDR; 18static int portbase = ICN_BASEADDR;
diff --git a/drivers/isdn/isdnloop/isdnloop.c b/drivers/isdn/isdnloop/isdnloop.c
index a335c85a736..b8a1098b66e 100644
--- a/drivers/isdn/isdnloop/isdnloop.c
+++ b/drivers/isdn/isdnloop/isdnloop.c
@@ -11,6 +11,7 @@
11 11
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/interrupt.h> 13#include <linux/interrupt.h>
14#include <linux/slab.h>
14#include <linux/init.h> 15#include <linux/init.h>
15#include <linux/sched.h> 16#include <linux/sched.h>
16#include "isdnloop.h" 17#include "isdnloop.h"
diff --git a/drivers/isdn/mISDN/clock.c b/drivers/isdn/mISDN/clock.c
index f1bbc88763b..1fa629b3b94 100644
--- a/drivers/isdn/mISDN/clock.c
+++ b/drivers/isdn/mISDN/clock.c
@@ -33,6 +33,7 @@
33 * 33 *
34 */ 34 */
35 35
36#include <linux/slab.h>
36#include <linux/types.h> 37#include <linux/types.h>
37#include <linux/stddef.h> 38#include <linux/stddef.h>
38#include <linux/spinlock.h> 39#include <linux/spinlock.h>
diff --git a/drivers/isdn/mISDN/core.c b/drivers/isdn/mISDN/core.c
index 21d34be5af6..afeebb00fe0 100644
--- a/drivers/isdn/mISDN/core.c
+++ b/drivers/isdn/mISDN/core.c
@@ -12,6 +12,7 @@
12 * 12 *
13 */ 13 */
14 14
15#include <linux/slab.h>
15#include <linux/types.h> 16#include <linux/types.h>
16#include <linux/stddef.h> 17#include <linux/stddef.h>
17#include <linux/module.h> 18#include <linux/module.h>
diff --git a/drivers/isdn/mISDN/dsp_cmx.c b/drivers/isdn/mISDN/dsp_cmx.c
index 9c7c0d1ba55..713ef2b805a 100644
--- a/drivers/isdn/mISDN/dsp_cmx.c
+++ b/drivers/isdn/mISDN/dsp_cmx.c
@@ -124,6 +124,7 @@
124 124
125/* delay.h is required for hw_lock.h */ 125/* delay.h is required for hw_lock.h */
126 126
127#include <linux/slab.h>
127#include <linux/delay.h> 128#include <linux/delay.h>
128#include <linux/mISDNif.h> 129#include <linux/mISDNif.h>
129#include <linux/mISDNdsp.h> 130#include <linux/mISDNdsp.h>
diff --git a/drivers/isdn/mISDN/dsp_core.c b/drivers/isdn/mISDN/dsp_core.c
index 6eac588e0a3..6f5b5486428 100644
--- a/drivers/isdn/mISDN/dsp_core.c
+++ b/drivers/isdn/mISDN/dsp_core.c
@@ -154,6 +154,7 @@
154 */ 154 */
155 155
156#include <linux/delay.h> 156#include <linux/delay.h>
157#include <linux/gfp.h>
157#include <linux/mISDNif.h> 158#include <linux/mISDNif.h>
158#include <linux/mISDNdsp.h> 159#include <linux/mISDNdsp.h>
159#include <linux/module.h> 160#include <linux/module.h>
diff --git a/drivers/isdn/mISDN/dsp_pipeline.c b/drivers/isdn/mISDN/dsp_pipeline.c
index e9941678edf..621f3100709 100644
--- a/drivers/isdn/mISDN/dsp_pipeline.c
+++ b/drivers/isdn/mISDN/dsp_pipeline.c
@@ -25,6 +25,7 @@
25 */ 25 */
26 26
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/slab.h>
28#include <linux/list.h> 29#include <linux/list.h>
29#include <linux/string.h> 30#include <linux/string.h>
30#include <linux/mISDNif.h> 31#include <linux/mISDNif.h>
diff --git a/drivers/isdn/mISDN/dsp_tones.c b/drivers/isdn/mISDN/dsp_tones.c
index 1debf53670d..7dbe54ed1de 100644
--- a/drivers/isdn/mISDN/dsp_tones.c
+++ b/drivers/isdn/mISDN/dsp_tones.c
@@ -8,6 +8,7 @@
8 * 8 *
9 */ 9 */
10 10
11#include <linux/gfp.h>
11#include <linux/mISDNif.h> 12#include <linux/mISDNif.h>
12#include <linux/mISDNdsp.h> 13#include <linux/mISDNdsp.h>
13#include "core.h" 14#include "core.h"
diff --git a/drivers/isdn/mISDN/hwchannel.c b/drivers/isdn/mISDN/hwchannel.c
index e8049be552a..307bd6e8988 100644
--- a/drivers/isdn/mISDN/hwchannel.c
+++ b/drivers/isdn/mISDN/hwchannel.c
@@ -15,6 +15,7 @@
15 * 15 *
16 */ 16 */
17 17
18#include <linux/gfp.h>
18#include <linux/module.h> 19#include <linux/module.h>
19#include <linux/mISDNhw.h> 20#include <linux/mISDNhw.h>
20 21
diff --git a/drivers/isdn/mISDN/l1oip_core.c b/drivers/isdn/mISDN/l1oip_core.c
index 325b1ad7d4b..22f38e48ac4 100644
--- a/drivers/isdn/mISDN/l1oip_core.c
+++ b/drivers/isdn/mISDN/l1oip_core.c
@@ -233,6 +233,7 @@ socket process and create a new one.
233#include <linux/inet.h> 233#include <linux/inet.h>
234#include <linux/workqueue.h> 234#include <linux/workqueue.h>
235#include <linux/kthread.h> 235#include <linux/kthread.h>
236#include <linux/slab.h>
236#include <net/sock.h> 237#include <net/sock.h>
237#include "core.h" 238#include "core.h"
238#include "l1oip.h" 239#include "l1oip.h"
diff --git a/drivers/isdn/mISDN/layer1.c b/drivers/isdn/mISDN/layer1.c
index e826eeb1ece..ac4aa18c632 100644
--- a/drivers/isdn/mISDN/layer1.c
+++ b/drivers/isdn/mISDN/layer1.c
@@ -16,6 +16,7 @@
16 */ 16 */
17 17
18 18
19#include <linux/slab.h>
19#include <linux/module.h> 20#include <linux/module.h>
20#include <linux/mISDNhw.h> 21#include <linux/mISDNhw.h>
21#include "core.h" 22#include "core.h"
diff --git a/drivers/isdn/mISDN/layer2.c b/drivers/isdn/mISDN/layer2.c
index e17f0044e0b..c9737178876 100644
--- a/drivers/isdn/mISDN/layer2.c
+++ b/drivers/isdn/mISDN/layer2.c
@@ -16,6 +16,7 @@
16 */ 16 */
17 17
18#include <linux/mISDNif.h> 18#include <linux/mISDNif.h>
19#include <linux/slab.h>
19#include "core.h" 20#include "core.h"
20#include "fsm.h" 21#include "fsm.h"
21#include "layer2.h" 22#include "layer2.h"
diff --git a/drivers/isdn/mISDN/socket.c b/drivers/isdn/mISDN/socket.c
index fcfe17a19a6..3232206406b 100644
--- a/drivers/isdn/mISDN/socket.c
+++ b/drivers/isdn/mISDN/socket.c
@@ -16,6 +16,7 @@
16 */ 16 */
17 17
18#include <linux/mISDNif.h> 18#include <linux/mISDNif.h>
19#include <linux/slab.h>
19#include "core.h" 20#include "core.h"
20 21
21static u_int *debug; 22static u_int *debug;
diff --git a/drivers/isdn/mISDN/stack.c b/drivers/isdn/mISDN/stack.c
index 0d05ec43012..b159bd59e64 100644
--- a/drivers/isdn/mISDN/stack.c
+++ b/drivers/isdn/mISDN/stack.c
@@ -15,6 +15,7 @@
15 * 15 *
16 */ 16 */
17 17
18#include <linux/slab.h>
18#include <linux/mISDNif.h> 19#include <linux/mISDNif.h>
19#include <linux/kthread.h> 20#include <linux/kthread.h>
20#include <linux/smp_lock.h> 21#include <linux/smp_lock.h>
diff --git a/drivers/isdn/mISDN/tei.c b/drivers/isdn/mISDN/tei.c
index 6d4da609588..34e898fe2f4 100644
--- a/drivers/isdn/mISDN/tei.c
+++ b/drivers/isdn/mISDN/tei.c
@@ -16,6 +16,7 @@
16 */ 16 */
17#include "layer2.h" 17#include "layer2.h"
18#include <linux/random.h> 18#include <linux/random.h>
19#include <linux/slab.h>
19#include "core.h" 20#include "core.h"
20 21
21#define ID_REQUEST 1 22#define ID_REQUEST 1
diff --git a/drivers/isdn/mISDN/timerdev.c b/drivers/isdn/mISDN/timerdev.c
index 5b7e9bf514f..8785004e85e 100644
--- a/drivers/isdn/mISDN/timerdev.c
+++ b/drivers/isdn/mISDN/timerdev.c
@@ -19,6 +19,7 @@
19 19
20#include <linux/poll.h> 20#include <linux/poll.h>
21#include <linux/vmalloc.h> 21#include <linux/vmalloc.h>
22#include <linux/slab.h>
22#include <linux/timer.h> 23#include <linux/timer.h>
23#include <linux/miscdevice.h> 24#include <linux/miscdevice.h>
24#include <linux/module.h> 25#include <linux/module.h>
diff --git a/drivers/isdn/pcbit/callbacks.c b/drivers/isdn/pcbit/callbacks.c
index 43ecd0f5423..976143b2346 100644
--- a/drivers/isdn/pcbit/callbacks.c
+++ b/drivers/isdn/pcbit/callbacks.c
@@ -19,7 +19,6 @@
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20 20
21#include <linux/types.h> 21#include <linux/types.h>
22#include <linux/slab.h>
23#include <linux/mm.h> 22#include <linux/mm.h>
24#include <linux/skbuff.h> 23#include <linux/skbuff.h>
25 24
diff --git a/drivers/isdn/pcbit/edss1.c b/drivers/isdn/pcbit/edss1.c
index 37e9626cebf..d5920ae22d7 100644
--- a/drivers/isdn/pcbit/edss1.c
+++ b/drivers/isdn/pcbit/edss1.c
@@ -19,7 +19,6 @@
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20 20
21#include <linux/types.h> 21#include <linux/types.h>
22#include <linux/slab.h>
23#include <linux/mm.h> 22#include <linux/mm.h>
24#include <linux/skbuff.h> 23#include <linux/skbuff.h>
25 24
diff --git a/drivers/isdn/sc/init.c b/drivers/isdn/sc/init.c
index 5a0774880d5..ca710ab278e 100644
--- a/drivers/isdn/sc/init.c
+++ b/drivers/isdn/sc/init.c
@@ -9,6 +9,7 @@
9#include <linux/interrupt.h> 9#include <linux/interrupt.h>
10#include <linux/delay.h> 10#include <linux/delay.h>
11#include <linux/sched.h> 11#include <linux/sched.h>
12#include <linux/slab.h>
12#include "includes.h" 13#include "includes.h"
13#include "hardware.h" 14#include "hardware.h"
14#include "card.h" 15#include "card.h"
diff --git a/drivers/leds/dell-led.c b/drivers/leds/dell-led.c
index ee310891fff..52590296af3 100644
--- a/drivers/leds/dell-led.c
+++ b/drivers/leds/dell-led.c
@@ -13,6 +13,7 @@
13 13
14#include <linux/acpi.h> 14#include <linux/acpi.h>
15#include <linux/leds.h> 15#include <linux/leds.h>
16#include <linux/slab.h>
16 17
17MODULE_AUTHOR("Louis Davis/Jim Dailey"); 18MODULE_AUTHOR("Louis Davis/Jim Dailey");
18MODULE_DESCRIPTION("Dell LED Control Driver"); 19MODULE_DESCRIPTION("Dell LED Control Driver");
diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
index d8ddd9ef899..f1c00db88b5 100644
--- a/drivers/leds/led-triggers.c
+++ b/drivers/leds/led-triggers.c
@@ -21,6 +21,7 @@
21#include <linux/timer.h> 21#include <linux/timer.h>
22#include <linux/rwsem.h> 22#include <linux/rwsem.h>
23#include <linux/leds.h> 23#include <linux/leds.h>
24#include <linux/slab.h>
24#include "leds.h" 25#include "leds.h"
25 26
26/* 27/*
diff --git a/drivers/leds/leds-88pm860x.c b/drivers/leds/leds-88pm860x.c
index d196073a6ae..16a60c06c96 100644
--- a/drivers/leds/leds-88pm860x.c
+++ b/drivers/leds/leds-88pm860x.c
@@ -15,6 +15,7 @@
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/i2c.h> 16#include <linux/i2c.h>
17#include <linux/leds.h> 17#include <linux/leds.h>
18#include <linux/slab.h>
18#include <linux/workqueue.h> 19#include <linux/workqueue.h>
19#include <linux/mfd/88pm860x.h> 20#include <linux/mfd/88pm860x.h>
20 21
diff --git a/drivers/leds/leds-adp5520.c b/drivers/leds/leds-adp5520.c
index a8f31590213..7ba4c7b5b97 100644
--- a/drivers/leds/leds-adp5520.c
+++ b/drivers/leds/leds-adp5520.c
@@ -20,6 +20,7 @@
20#include <linux/leds.h> 20#include <linux/leds.h>
21#include <linux/workqueue.h> 21#include <linux/workqueue.h>
22#include <linux/mfd/adp5520.h> 22#include <linux/mfd/adp5520.h>
23#include <linux/slab.h>
23 24
24struct adp5520_led { 25struct adp5520_led {
25 struct led_classdev cdev; 26 struct led_classdev cdev;
diff --git a/drivers/leds/leds-atmel-pwm.c b/drivers/leds/leds-atmel-pwm.c
index 52297c3ab24..c941d906bba 100644
--- a/drivers/leds/leds-atmel-pwm.c
+++ b/drivers/leds/leds-atmel-pwm.c
@@ -3,6 +3,7 @@
3#include <linux/leds.h> 3#include <linux/leds.h>
4#include <linux/io.h> 4#include <linux/io.h>
5#include <linux/atmel_pwm.h> 5#include <linux/atmel_pwm.h>
6#include <linux/slab.h>
6 7
7 8
8struct pwmled { 9struct pwmled {
diff --git a/drivers/leds/leds-bd2802.c b/drivers/leds/leds-bd2802.c
index 779d7f262c0..286b501a357 100644
--- a/drivers/leds/leds-bd2802.c
+++ b/drivers/leds/leds-bd2802.c
@@ -18,6 +18,7 @@
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/leds.h> 19#include <linux/leds.h>
20#include <linux/leds-bd2802.h> 20#include <linux/leds-bd2802.h>
21#include <linux/slab.h>
21 22
22 23
23#define LED_CTL(rgb2en, rgb1en) ((rgb2en) << 4 | ((rgb1en) << 0)) 24#define LED_CTL(rgb2en, rgb1en) ((rgb2en) << 4 | ((rgb1en) << 0))
diff --git a/drivers/leds/leds-da903x.c b/drivers/leds/leds-da903x.c
index 1f3cc512eff..f28931cf678 100644
--- a/drivers/leds/leds-da903x.c
+++ b/drivers/leds/leds-da903x.c
@@ -19,6 +19,7 @@
19#include <linux/leds.h> 19#include <linux/leds.h>
20#include <linux/workqueue.h> 20#include <linux/workqueue.h>
21#include <linux/mfd/da903x.h> 21#include <linux/mfd/da903x.h>
22#include <linux/slab.h>
22 23
23#define DA9030_LED1_CONTROL 0x20 24#define DA9030_LED1_CONTROL 0x20
24#define DA9030_LED2_CONTROL 0x21 25#define DA9030_LED2_CONTROL 0x21
diff --git a/drivers/leds/leds-dac124s085.c b/drivers/leds/leds-dac124s085.c
index 2913d76ad3d..31cf0d60a9a 100644
--- a/drivers/leds/leds-dac124s085.c
+++ b/drivers/leds/leds-dac124s085.c
@@ -9,7 +9,6 @@
9 * LED driver for the DAC124S085 SPI DAC 9 * LED driver for the DAC124S085 SPI DAC
10 */ 10 */
11 11
12#include <linux/gfp.h>
13#include <linux/leds.h> 12#include <linux/leds.h>
14#include <linux/module.h> 13#include <linux/module.h>
15#include <linux/mutex.h> 14#include <linux/mutex.h>
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index 0823e2622e8..c6e4b772b75 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -14,6 +14,7 @@
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/leds.h> 16#include <linux/leds.h>
17#include <linux/slab.h>
17#include <linux/workqueue.h> 18#include <linux/workqueue.h>
18 19
19#include <asm/gpio.h> 20#include <asm/gpio.h>
diff --git a/drivers/leds/leds-lp3944.c b/drivers/leds/leds-lp3944.c
index 5946208ba26..8d5ecceba18 100644
--- a/drivers/leds/leds-lp3944.c
+++ b/drivers/leds/leds-lp3944.c
@@ -28,6 +28,7 @@
28 28
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/i2c.h> 30#include <linux/i2c.h>
31#include <linux/slab.h>
31#include <linux/leds.h> 32#include <linux/leds.h>
32#include <linux/mutex.h> 33#include <linux/mutex.h>
33#include <linux/workqueue.h> 34#include <linux/workqueue.h>
diff --git a/drivers/leds/leds-lt3593.c b/drivers/leds/leds-lt3593.c
index fee40a84195..2579678f97a 100644
--- a/drivers/leds/leds-lt3593.c
+++ b/drivers/leds/leds-lt3593.c
@@ -23,6 +23,7 @@
23#include <linux/workqueue.h> 23#include <linux/workqueue.h>
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/gpio.h> 25#include <linux/gpio.h>
26#include <linux/slab.h>
26 27
27struct lt3593_led_data { 28struct lt3593_led_data {
28 struct led_classdev cdev; 29 struct led_classdev cdev;
diff --git a/drivers/leds/leds-pca9532.c b/drivers/leds/leds-pca9532.c
index adc561eb59d..6682175fa9f 100644
--- a/drivers/leds/leds-pca9532.c
+++ b/drivers/leds/leds-pca9532.c
@@ -13,6 +13,7 @@
13 13
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/i2c.h> 15#include <linux/i2c.h>
16#include <linux/slab.h>
16#include <linux/leds.h> 17#include <linux/leds.h>
17#include <linux/input.h> 18#include <linux/input.h>
18#include <linux/mutex.h> 19#include <linux/mutex.h>
diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c
index 4e2d1a42b48..8ff50f23419 100644
--- a/drivers/leds/leds-pca955x.c
+++ b/drivers/leds/leds-pca955x.c
@@ -48,6 +48,7 @@
48#include <linux/err.h> 48#include <linux/err.h>
49#include <linux/i2c.h> 49#include <linux/i2c.h>
50#include <linux/workqueue.h> 50#include <linux/workqueue.h>
51#include <linux/slab.h>
51 52
52/* LED select registers determine the source that drives LED outputs */ 53/* LED select registers determine the source that drives LED outputs */
53#define PCA955X_LS_LED_ON 0x0 /* Output LOW */ 54#define PCA955X_LS_LED_ON 0x0 /* Output LOW */
diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
index 88b1dd091cf..da3fa8dcdf5 100644
--- a/drivers/leds/leds-pwm.c
+++ b/drivers/leds/leds-pwm.c
@@ -21,6 +21,7 @@
21#include <linux/err.h> 21#include <linux/err.h>
22#include <linux/pwm.h> 22#include <linux/pwm.h>
23#include <linux/leds_pwm.h> 23#include <linux/leds_pwm.h>
24#include <linux/slab.h>
24 25
25struct led_pwm_data { 26struct led_pwm_data {
26 struct led_classdev cdev; 27 struct led_classdev cdev;
diff --git a/drivers/leds/leds-regulator.c b/drivers/leds/leds-regulator.c
index 7f00de3ef92..3790816643b 100644
--- a/drivers/leds/leds-regulator.c
+++ b/drivers/leds/leds-regulator.c
@@ -13,6 +13,7 @@
13 13
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/err.h> 15#include <linux/err.h>
16#include <linux/slab.h>
16#include <linux/workqueue.h> 17#include <linux/workqueue.h>
17#include <linux/leds.h> 18#include <linux/leds.h>
18#include <linux/leds-regulator.h> 19#include <linux/leds-regulator.h>
diff --git a/drivers/leds/leds-s3c24xx.c b/drivers/leds/leds-s3c24xx.c
index aa7acf3b922..a77771dc2e9 100644
--- a/drivers/leds/leds-s3c24xx.c
+++ b/drivers/leds/leds-s3c24xx.c
@@ -16,6 +16,7 @@
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/leds.h> 17#include <linux/leds.h>
18#include <linux/gpio.h> 18#include <linux/gpio.h>
19#include <linux/slab.h>
19 20
20#include <mach/hardware.h> 21#include <mach/hardware.h>
21#include <mach/regs-gpio.h> 22#include <mach/regs-gpio.h>
diff --git a/drivers/leds/leds-sunfire.c b/drivers/leds/leds-sunfire.c
index 6b008f0c3f6..ab6d18f5c39 100644
--- a/drivers/leds/leds-sunfire.c
+++ b/drivers/leds/leds-sunfire.c
@@ -9,6 +9,7 @@
9#include <linux/leds.h> 9#include <linux/leds.h>
10#include <linux/io.h> 10#include <linux/io.h>
11#include <linux/platform_device.h> 11#include <linux/platform_device.h>
12#include <linux/slab.h>
12 13
13#include <asm/fhc.h> 14#include <asm/fhc.h>
14#include <asm/upa.h> 15#include <asm/upa.h>
diff --git a/drivers/leds/leds-wm831x-status.c b/drivers/leds/leds-wm831x-status.c
index c586d05e336..ef5c24140a4 100644
--- a/drivers/leds/leds-wm831x-status.c
+++ b/drivers/leds/leds-wm831x-status.c
@@ -12,6 +12,7 @@
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/slab.h>
15#include <linux/leds.h> 16#include <linux/leds.h>
16#include <linux/err.h> 17#include <linux/err.h>
17#include <linux/mfd/wm831x/core.h> 18#include <linux/mfd/wm831x/core.h>
diff --git a/drivers/leds/leds-wm8350.c b/drivers/leds/leds-wm8350.c
index 38c6bcb07e6..5aab32ce4f4 100644
--- a/drivers/leds/leds-wm8350.c
+++ b/drivers/leds/leds-wm8350.c
@@ -16,6 +16,7 @@
16#include <linux/err.h> 16#include <linux/err.h>
17#include <linux/mfd/wm8350/pmic.h> 17#include <linux/mfd/wm8350/pmic.h>
18#include <linux/regulator/consumer.h> 18#include <linux/regulator/consumer.h>
19#include <linux/slab.h>
19 20
20/* Microamps */ 21/* Microamps */
21static const int isink_cur[] = { 22static const int isink_cur[] = {
diff --git a/drivers/leds/ledtrig-backlight.c b/drivers/leds/ledtrig-backlight.c
index d3dfcfb417b..f948e57bd9b 100644
--- a/drivers/leds/ledtrig-backlight.c
+++ b/drivers/leds/ledtrig-backlight.c
@@ -12,6 +12,7 @@
12 12
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/slab.h>
15#include <linux/init.h> 16#include <linux/init.h>
16#include <linux/fb.h> 17#include <linux/fb.h>
17#include <linux/leds.h> 18#include <linux/leds.h>
diff --git a/drivers/leds/ledtrig-gpio.c b/drivers/leds/ledtrig-gpio.c
index f5913372d69..991d93be0f4 100644
--- a/drivers/leds/ledtrig-gpio.c
+++ b/drivers/leds/ledtrig-gpio.c
@@ -16,6 +16,7 @@
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/workqueue.h> 17#include <linux/workqueue.h>
18#include <linux/leds.h> 18#include <linux/leds.h>
19#include <linux/slab.h>
19#include "leds.h" 20#include "leds.h"
20 21
21struct gpio_trig_data { 22struct gpio_trig_data {
diff --git a/drivers/leds/ledtrig-heartbeat.c b/drivers/leds/ledtrig-heartbeat.c
index c1c1ea6f817..759c0bba4a8 100644
--- a/drivers/leds/ledtrig-heartbeat.c
+++ b/drivers/leds/ledtrig-heartbeat.c
@@ -14,6 +14,7 @@
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/slab.h>
17#include <linux/timer.h> 18#include <linux/timer.h>
18#include <linux/sched.h> 19#include <linux/sched.h>
19#include <linux/leds.h> 20#include <linux/leds.h>
diff --git a/drivers/leds/ledtrig-timer.c b/drivers/leds/ledtrig-timer.c
index 38b3378be44..82b77bd482f 100644
--- a/drivers/leds/ledtrig-timer.c
+++ b/drivers/leds/ledtrig-timer.c
@@ -22,6 +22,7 @@
22#include <linux/timer.h> 22#include <linux/timer.h>
23#include <linux/ctype.h> 23#include <linux/ctype.h>
24#include <linux/leds.h> 24#include <linux/leds.h>
25#include <linux/slab.h>
25#include "leds.h" 26#include "leds.h"
26 27
27struct timer_trig_data { 28struct timer_trig_data {
diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
index 8744d24ac6e..efa202499e3 100644
--- a/drivers/lguest/core.c
+++ b/drivers/lguest/core.c
@@ -12,6 +12,7 @@
12#include <linux/cpu.h> 12#include <linux/cpu.h>
13#include <linux/freezer.h> 13#include <linux/freezer.h>
14#include <linux/highmem.h> 14#include <linux/highmem.h>
15#include <linux/slab.h>
15#include <asm/paravirt.h> 16#include <asm/paravirt.h>
16#include <asm/pgtable.h> 17#include <asm/pgtable.h>
17#include <asm/uaccess.h> 18#include <asm/uaccess.h>
diff --git a/drivers/lguest/lg.h b/drivers/lguest/lg.h
index bc28745d05a..9136411fadd 100644
--- a/drivers/lguest/lg.h
+++ b/drivers/lguest/lg.h
@@ -10,6 +10,7 @@
10#include <linux/wait.h> 10#include <linux/wait.h>
11#include <linux/hrtimer.h> 11#include <linux/hrtimer.h>
12#include <linux/err.h> 12#include <linux/err.h>
13#include <linux/slab.h>
13 14
14#include <asm/lguest.h> 15#include <asm/lguest.h>
15 16
diff --git a/drivers/lguest/lguest_device.c b/drivers/lguest/lguest_device.c
index b6200bc39b5..69c84a1d88e 100644
--- a/drivers/lguest/lguest_device.c
+++ b/drivers/lguest/lguest_device.c
@@ -15,6 +15,7 @@
15#include <linux/interrupt.h> 15#include <linux/interrupt.h>
16#include <linux/virtio_ring.h> 16#include <linux/virtio_ring.h>
17#include <linux/err.h> 17#include <linux/err.h>
18#include <linux/slab.h>
18#include <asm/io.h> 19#include <asm/io.h>
19#include <asm/paravirt.h> 20#include <asm/paravirt.h>
20#include <asm/lguest_hcall.h> 21#include <asm/lguest_hcall.h>
@@ -177,7 +178,7 @@ static void set_status(struct virtio_device *vdev, u8 status)
177 178
178 /* We set the status. */ 179 /* We set the status. */
179 to_lgdev(vdev)->desc->status = status; 180 to_lgdev(vdev)->desc->status = status;
180 kvm_hypercall1(LHCALL_NOTIFY, (max_pfn << PAGE_SHIFT) + offset); 181 hcall(LHCALL_NOTIFY, (max_pfn << PAGE_SHIFT) + offset, 0, 0, 0);
181} 182}
182 183
183static void lg_set_status(struct virtio_device *vdev, u8 status) 184static void lg_set_status(struct virtio_device *vdev, u8 status)
@@ -228,7 +229,7 @@ static void lg_notify(struct virtqueue *vq)
228 */ 229 */
229 struct lguest_vq_info *lvq = vq->priv; 230 struct lguest_vq_info *lvq = vq->priv;
230 231
231 kvm_hypercall1(LHCALL_NOTIFY, lvq->config.pfn << PAGE_SHIFT); 232 hcall(LHCALL_NOTIFY, lvq->config.pfn << PAGE_SHIFT, 0, 0, 0);
232} 233}
233 234
234/* An extern declaration inside a C file is bad form. Don't do it. */ 235/* An extern declaration inside a C file is bad form. Don't do it. */
diff --git a/drivers/lguest/lguest_user.c b/drivers/lguest/lguest_user.c
index bd1632388e4..85b714df8ea 100644
--- a/drivers/lguest/lguest_user.c
+++ b/drivers/lguest/lguest_user.c
@@ -10,6 +10,7 @@
10#include <linux/sched.h> 10#include <linux/sched.h>
11#include <linux/eventfd.h> 11#include <linux/eventfd.h>
12#include <linux/file.h> 12#include <linux/file.h>
13#include <linux/slab.h>
13#include "lg.h" 14#include "lg.h"
14 15
15/*L:056 16/*L:056
diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
index cf94326f1b5..04b22128a47 100644
--- a/drivers/lguest/page_tables.c
+++ b/drivers/lguest/page_tables.c
@@ -10,6 +10,7 @@
10/* Copyright (C) Rusty Russell IBM Corporation 2006. 10/* Copyright (C) Rusty Russell IBM Corporation 2006.
11 * GPL v2 and any later version */ 11 * GPL v2 and any later version */
12#include <linux/mm.h> 12#include <linux/mm.h>
13#include <linux/gfp.h>
13#include <linux/types.h> 14#include <linux/types.h>
14#include <linux/spinlock.h> 15#include <linux/spinlock.h>
15#include <linux/random.h> 16#include <linux/random.h>
diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
index fb2b7ef7868..b4eb675a807 100644
--- a/drivers/lguest/x86/core.c
+++ b/drivers/lguest/x86/core.c
@@ -288,6 +288,18 @@ static int emulate_insn(struct lg_cpu *cpu)
288 insn = lgread(cpu, physaddr, u8); 288 insn = lgread(cpu, physaddr, u8);
289 289
290 /* 290 /*
291 * Around 2.6.33, the kernel started using an emulation for the
292 * cmpxchg8b instruction in early boot on many configurations. This
293 * code isn't paravirtualized, and it tries to disable interrupts.
294 * Ignore it, which will Mostly Work.
295 */
296 if (insn == 0xfa) {
297 /* "cli", or Clear Interrupt Enable instruction. Skip it. */
298 cpu->regs->eip++;
299 return 1;
300 }
301
302 /*
291 * 0x66 is an "operand prefix". It means it's using the upper 16 bits 303 * 0x66 is an "operand prefix". It means it's using the upper 16 bits
292 * of the eax register. 304 * of the eax register.
293 */ 305 */
diff --git a/drivers/macintosh/mac_hid.c b/drivers/macintosh/mac_hid.c
index e943d2a2925..067f9962f49 100644
--- a/drivers/macintosh/mac_hid.c
+++ b/drivers/macintosh/mac_hid.c
@@ -13,6 +13,7 @@
13#include <linux/sysctl.h> 13#include <linux/sysctl.h>
14#include <linux/input.h> 14#include <linux/input.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/slab.h>
16 17
17MODULE_LICENSE("GPL"); 18MODULE_LICENSE("GPL");
18 19
diff --git a/drivers/macintosh/rack-meter.c b/drivers/macintosh/rack-meter.c
index 93fb32038b1..7c54d80c4fb 100644
--- a/drivers/macintosh/rack-meter.c
+++ b/drivers/macintosh/rack-meter.c
@@ -18,6 +18,7 @@
18 18
19#include <linux/types.h> 19#include <linux/types.h>
20#include <linux/kernel.h> 20#include <linux/kernel.h>
21#include <linux/slab.h>
21#include <linux/device.h> 22#include <linux/device.h>
22#include <linux/interrupt.h> 23#include <linux/interrupt.h>
23#include <linux/module.h> 24#include <linux/module.h>
diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c
index f96feeb6b9c..888448cf7f1 100644
--- a/drivers/macintosh/smu.c
+++ b/drivers/macintosh/smu.c
@@ -38,6 +38,7 @@
38#include <linux/mutex.h> 38#include <linux/mutex.h>
39#include <linux/of_device.h> 39#include <linux/of_device.h>
40#include <linux/of_platform.h> 40#include <linux/of_platform.h>
41#include <linux/slab.h>
41 42
42#include <asm/byteorder.h> 43#include <asm/byteorder.h>
43#include <asm/io.h> 44#include <asm/io.h>
diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c
index 921373e4e3a..b18fa948f3d 100644
--- a/drivers/macintosh/therm_pm72.c
+++ b/drivers/macintosh/therm_pm72.c
@@ -114,7 +114,6 @@
114#include <linux/kernel.h> 114#include <linux/kernel.h>
115#include <linux/delay.h> 115#include <linux/delay.h>
116#include <linux/sched.h> 116#include <linux/sched.h>
117#include <linux/slab.h>
118#include <linux/init.h> 117#include <linux/init.h>
119#include <linux/spinlock.h> 118#include <linux/spinlock.h>
120#include <linux/wait.h> 119#include <linux/wait.h>
diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c
index 7fb8b4da35a..0839770e4ec 100644
--- a/drivers/macintosh/therm_windtunnel.c
+++ b/drivers/macintosh/therm_windtunnel.c
@@ -34,7 +34,6 @@
34#include <linux/delay.h> 34#include <linux/delay.h>
35#include <linux/sched.h> 35#include <linux/sched.h>
36#include <linux/i2c.h> 36#include <linux/i2c.h>
37#include <linux/slab.h>
38#include <linux/init.h> 37#include <linux/init.h>
39#include <linux/kthread.h> 38#include <linux/kthread.h>
40#include <linux/of_platform.h> 39#include <linux/of_platform.h>
diff --git a/drivers/macintosh/via-pmu68k.c b/drivers/macintosh/via-pmu68k.c
index fb9fa614a0e..aeb30d07d5a 100644
--- a/drivers/macintosh/via-pmu68k.c
+++ b/drivers/macintosh/via-pmu68k.c
@@ -25,7 +25,6 @@
25#include <linux/miscdevice.h> 25#include <linux/miscdevice.h>
26#include <linux/blkdev.h> 26#include <linux/blkdev.h>
27#include <linux/pci.h> 27#include <linux/pci.h>
28#include <linux/slab.h>
29#include <linux/init.h> 28#include <linux/init.h>
30#include <linux/interrupt.h> 29#include <linux/interrupt.h>
31 30
diff --git a/drivers/macintosh/windfarm_core.c b/drivers/macintosh/windfarm_core.c
index 419795f4a2a..ce8897933a8 100644
--- a/drivers/macintosh/windfarm_core.c
+++ b/drivers/macintosh/windfarm_core.c
@@ -25,6 +25,7 @@
25#include <linux/types.h> 25#include <linux/types.h>
26#include <linux/errno.h> 26#include <linux/errno.h>
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/slab.h>
28#include <linux/init.h> 29#include <linux/init.h>
29#include <linux/spinlock.h> 30#include <linux/spinlock.h>
30#include <linux/kthread.h> 31#include <linux/kthread.h>
@@ -209,6 +210,7 @@ int wf_register_control(struct wf_control *new_ct)
209 kref_init(&new_ct->ref); 210 kref_init(&new_ct->ref);
210 list_add(&new_ct->link, &wf_controls); 211 list_add(&new_ct->link, &wf_controls);
211 212
213 sysfs_attr_init(&new_ct->attr.attr);
212 new_ct->attr.attr.name = new_ct->name; 214 new_ct->attr.attr.name = new_ct->name;
213 new_ct->attr.attr.mode = 0644; 215 new_ct->attr.attr.mode = 0644;
214 new_ct->attr.show = wf_show_control; 216 new_ct->attr.show = wf_show_control;
diff --git a/drivers/md/dm-log-userspace-base.c b/drivers/md/dm-log-userspace-base.c
index 7ac2c1450d1..1ed0094f064 100644
--- a/drivers/md/dm-log-userspace-base.c
+++ b/drivers/md/dm-log-userspace-base.c
@@ -5,6 +5,7 @@
5 */ 5 */
6 6
7#include <linux/bio.h> 7#include <linux/bio.h>
8#include <linux/slab.h>
8#include <linux/dm-dirty-log.h> 9#include <linux/dm-dirty-log.h>
9#include <linux/device-mapper.h> 10#include <linux/device-mapper.h>
10#include <linux/dm-log-userspace.h> 11#include <linux/dm-log-userspace.h>
diff --git a/drivers/md/dm-log-userspace-transfer.c b/drivers/md/dm-log-userspace-transfer.c
index f1c8cae70b4..075cbcf8a9f 100644
--- a/drivers/md/dm-log-userspace-transfer.c
+++ b/drivers/md/dm-log-userspace-transfer.c
@@ -6,6 +6,7 @@
6 6
7#include <linux/kernel.h> 7#include <linux/kernel.h>
8#include <linux/module.h> 8#include <linux/module.h>
9#include <linux/slab.h>
9#include <net/sock.h> 10#include <net/sock.h>
10#include <linux/workqueue.h> 11#include <linux/workqueue.h>
11#include <linux/connector.h> 12#include <linux/connector.h>
diff --git a/drivers/md/dm-region-hash.c b/drivers/md/dm-region-hash.c
index 168bd38f500..bd5c58b2886 100644
--- a/drivers/md/dm-region-hash.c
+++ b/drivers/md/dm-region-hash.c
@@ -11,6 +11,7 @@
11#include <linux/ctype.h> 11#include <linux/ctype.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/slab.h>
14#include <linux/vmalloc.h> 15#include <linux/vmalloc.h>
15 16
16#include "dm.h" 17#include "dm.h"
diff --git a/drivers/md/dm-service-time.c b/drivers/md/dm-service-time.c
index cfa668f46c4..9c6c2e47ad6 100644
--- a/drivers/md/dm-service-time.c
+++ b/drivers/md/dm-service-time.c
@@ -11,6 +11,8 @@
11#include "dm.h" 11#include "dm.h"
12#include "dm-path-selector.h" 12#include "dm-path-selector.h"
13 13
14#include <linux/slab.h>
15
14#define DM_MSG_PREFIX "multipath service-time" 16#define DM_MSG_PREFIX "multipath service-time"
15#define ST_MIN_IO 1 17#define ST_MIN_IO 1
16#define ST_MAX_RELATIVE_THROUGHPUT 100 18#define ST_MAX_RELATIVE_THROUGHPUT 100
diff --git a/drivers/md/dm-target.c b/drivers/md/dm-target.c
index 04feccf2a99..11dea11dc0b 100644
--- a/drivers/md/dm-target.c
+++ b/drivers/md/dm-target.c
@@ -10,7 +10,6 @@
10#include <linux/init.h> 10#include <linux/init.h>
11#include <linux/kmod.h> 11#include <linux/kmod.h>
12#include <linux/bio.h> 12#include <linux/bio.h>
13#include <linux/slab.h>
14 13
15#define DM_MSG_PREFIX "target" 14#define DM_MSG_PREFIX "target"
16 15
diff --git a/drivers/md/faulty.c b/drivers/md/faulty.c
index 713acd02ab3..8e3850b98cc 100644
--- a/drivers/md/faulty.c
+++ b/drivers/md/faulty.c
@@ -64,6 +64,7 @@
64#define MaxFault 50 64#define MaxFault 50
65#include <linux/blkdev.h> 65#include <linux/blkdev.h>
66#include <linux/raid/md_u.h> 66#include <linux/raid/md_u.h>
67#include <linux/slab.h>
67#include "md.h" 68#include "md.h"
68#include <linux/seq_file.h> 69#include <linux/seq_file.h>
69 70
diff --git a/drivers/md/linear.c b/drivers/md/linear.c
index bb2a23159b2..09437e95823 100644
--- a/drivers/md/linear.c
+++ b/drivers/md/linear.c
@@ -19,6 +19,7 @@
19#include <linux/blkdev.h> 19#include <linux/blkdev.h>
20#include <linux/raid/md_u.h> 20#include <linux/raid/md_u.h>
21#include <linux/seq_file.h> 21#include <linux/seq_file.h>
22#include <linux/slab.h>
22#include "md.h" 23#include "md.h"
23#include "linear.h" 24#include "linear.h"
24 25
diff --git a/drivers/md/md.c b/drivers/md/md.c
index fdc1890b6ac..cefd63daff3 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -49,6 +49,7 @@
49#include <linux/delay.h> 49#include <linux/delay.h>
50#include <linux/raid/md_p.h> 50#include <linux/raid/md_p.h>
51#include <linux/raid/md_u.h> 51#include <linux/raid/md_u.h>
52#include <linux/slab.h>
52#include "md.h" 53#include "md.h"
53#include "bitmap.h" 54#include "bitmap.h"
54 55
@@ -2108,12 +2109,18 @@ repeat:
2108 if (!mddev->in_sync || mddev->recovery_cp != MaxSector) { /* not clean */ 2109 if (!mddev->in_sync || mddev->recovery_cp != MaxSector) { /* not clean */
2109 /* .. if the array isn't clean, an 'even' event must also go 2110 /* .. if the array isn't clean, an 'even' event must also go
2110 * to spares. */ 2111 * to spares. */
2111 if ((mddev->events&1)==0) 2112 if ((mddev->events&1)==0) {
2112 nospares = 0; 2113 nospares = 0;
2114 sync_req = 2; /* force a second update to get the
2115 * even/odd in sync */
2116 }
2113 } else { 2117 } else {
2114 /* otherwise an 'odd' event must go to spares */ 2118 /* otherwise an 'odd' event must go to spares */
2115 if ((mddev->events&1)) 2119 if ((mddev->events&1)) {
2116 nospares = 0; 2120 nospares = 0;
2121 sync_req = 2; /* force a second update to get the
2122 * even/odd in sync */
2123 }
2117 } 2124 }
2118 } 2125 }
2119 2126
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index 5558ebc705c..789bf535d29 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -22,6 +22,7 @@
22#include <linux/blkdev.h> 22#include <linux/blkdev.h>
23#include <linux/raid/md_u.h> 23#include <linux/raid/md_u.h>
24#include <linux/seq_file.h> 24#include <linux/seq_file.h>
25#include <linux/slab.h>
25#include "md.h" 26#include "md.h"
26#include "multipath.h" 27#include "multipath.h"
27 28
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 377cf2a3c33..c3bec024612 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -20,6 +20,7 @@
20 20
21#include <linux/blkdev.h> 21#include <linux/blkdev.h>
22#include <linux/seq_file.h> 22#include <linux/seq_file.h>
23#include <linux/slab.h>
23#include "md.h" 24#include "md.h"
24#include "raid0.h" 25#include "raid0.h"
25 26
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index f741f77eeb2..e59b10e66ed 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -31,6 +31,7 @@
31 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 31 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32 */ 32 */
33 33
34#include <linux/slab.h>
34#include <linux/delay.h> 35#include <linux/delay.h>
35#include <linux/blkdev.h> 36#include <linux/blkdev.h>
36#include <linux/seq_file.h> 37#include <linux/seq_file.h>
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index b4ba41ecbd2..e2766d8251a 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -18,6 +18,7 @@
18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 19 */
20 20
21#include <linux/slab.h>
21#include <linux/delay.h> 22#include <linux/delay.h>
22#include <linux/blkdev.h> 23#include <linux/blkdev.h>
23#include <linux/seq_file.h> 24#include <linux/seq_file.h>
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 70ffbd071b2..15348c393b5 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -50,6 +50,7 @@
50#include <linux/async.h> 50#include <linux/async.h>
51#include <linux/seq_file.h> 51#include <linux/seq_file.h>
52#include <linux/cpu.h> 52#include <linux/cpu.h>
53#include <linux/slab.h>
53#include "md.h" 54#include "md.h"
54#include "raid5.h" 55#include "raid5.h"
55#include "bitmap.h" 56#include "bitmap.h"
@@ -1526,7 +1527,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
1526 1527
1527 clear_bit(R5_UPTODATE, &sh->dev[i].flags); 1528 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
1528 atomic_inc(&rdev->read_errors); 1529 atomic_inc(&rdev->read_errors);
1529 if (conf->mddev->degraded) 1530 if (conf->mddev->degraded >= conf->max_degraded)
1530 printk_rl(KERN_WARNING 1531 printk_rl(KERN_WARNING
1531 "raid5:%s: read error not correctable " 1532 "raid5:%s: read error not correctable "
1532 "(sector %llu on %s).\n", 1533 "(sector %llu on %s).\n",
@@ -1649,8 +1650,8 @@ static sector_t raid5_compute_sector(raid5_conf_t *conf, sector_t r_sector,
1649 int previous, int *dd_idx, 1650 int previous, int *dd_idx,
1650 struct stripe_head *sh) 1651 struct stripe_head *sh)
1651{ 1652{
1652 long stripe; 1653 sector_t stripe, stripe2;
1653 unsigned long chunk_number; 1654 sector_t chunk_number;
1654 unsigned int chunk_offset; 1655 unsigned int chunk_offset;
1655 int pd_idx, qd_idx; 1656 int pd_idx, qd_idx;
1656 int ddf_layout = 0; 1657 int ddf_layout = 0;
@@ -1670,18 +1671,13 @@ static sector_t raid5_compute_sector(raid5_conf_t *conf, sector_t r_sector,
1670 */ 1671 */
1671 chunk_offset = sector_div(r_sector, sectors_per_chunk); 1672 chunk_offset = sector_div(r_sector, sectors_per_chunk);
1672 chunk_number = r_sector; 1673 chunk_number = r_sector;
1673 BUG_ON(r_sector != chunk_number);
1674 1674
1675 /* 1675 /*
1676 * Compute the stripe number 1676 * Compute the stripe number
1677 */ 1677 */
1678 stripe = chunk_number / data_disks; 1678 stripe = chunk_number;
1679 1679 *dd_idx = sector_div(stripe, data_disks);
1680 /* 1680 stripe2 = stripe;
1681 * Compute the data disk and parity disk indexes inside the stripe
1682 */
1683 *dd_idx = chunk_number % data_disks;
1684
1685 /* 1681 /*
1686 * Select the parity disk based on the user selected algorithm. 1682 * Select the parity disk based on the user selected algorithm.
1687 */ 1683 */
@@ -1693,21 +1689,21 @@ static sector_t raid5_compute_sector(raid5_conf_t *conf, sector_t r_sector,
1693 case 5: 1689 case 5:
1694 switch (algorithm) { 1690 switch (algorithm) {
1695 case ALGORITHM_LEFT_ASYMMETRIC: 1691 case ALGORITHM_LEFT_ASYMMETRIC:
1696 pd_idx = data_disks - stripe % raid_disks; 1692 pd_idx = data_disks - sector_div(stripe2, raid_disks);
1697 if (*dd_idx >= pd_idx) 1693 if (*dd_idx >= pd_idx)
1698 (*dd_idx)++; 1694 (*dd_idx)++;
1699 break; 1695 break;
1700 case ALGORITHM_RIGHT_ASYMMETRIC: 1696 case ALGORITHM_RIGHT_ASYMMETRIC:
1701 pd_idx = stripe % raid_disks; 1697 pd_idx = sector_div(stripe2, raid_disks);
1702 if (*dd_idx >= pd_idx) 1698 if (*dd_idx >= pd_idx)
1703 (*dd_idx)++; 1699 (*dd_idx)++;
1704 break; 1700 break;
1705 case ALGORITHM_LEFT_SYMMETRIC: 1701 case ALGORITHM_LEFT_SYMMETRIC:
1706 pd_idx = data_disks - stripe % raid_disks; 1702 pd_idx = data_disks - sector_div(stripe2, raid_disks);
1707 *dd_idx = (pd_idx + 1 + *dd_idx) % raid_disks; 1703 *dd_idx = (pd_idx + 1 + *dd_idx) % raid_disks;
1708 break; 1704 break;
1709 case ALGORITHM_RIGHT_SYMMETRIC: 1705 case ALGORITHM_RIGHT_SYMMETRIC:
1710 pd_idx = stripe % raid_disks; 1706 pd_idx = sector_div(stripe2, raid_disks);
1711 *dd_idx = (pd_idx + 1 + *dd_idx) % raid_disks; 1707 *dd_idx = (pd_idx + 1 + *dd_idx) % raid_disks;
1712 break; 1708 break;
1713 case ALGORITHM_PARITY_0: 1709 case ALGORITHM_PARITY_0:
@@ -1727,7 +1723,7 @@ static sector_t raid5_compute_sector(raid5_conf_t *conf, sector_t r_sector,
1727 1723
1728 switch (algorithm) { 1724 switch (algorithm) {
1729 case ALGORITHM_LEFT_ASYMMETRIC: 1725 case ALGORITHM_LEFT_ASYMMETRIC:
1730 pd_idx = raid_disks - 1 - (stripe % raid_disks); 1726 pd_idx = raid_disks - 1 - sector_div(stripe2, raid_disks);
1731 qd_idx = pd_idx + 1; 1727 qd_idx = pd_idx + 1;
1732 if (pd_idx == raid_disks-1) { 1728 if (pd_idx == raid_disks-1) {
1733 (*dd_idx)++; /* Q D D D P */ 1729 (*dd_idx)++; /* Q D D D P */
@@ -1736,7 +1732,7 @@ static sector_t raid5_compute_sector(raid5_conf_t *conf, sector_t r_sector,
1736 (*dd_idx) += 2; /* D D P Q D */ 1732 (*dd_idx) += 2; /* D D P Q D */
1737 break; 1733 break;
1738 case ALGORITHM_RIGHT_ASYMMETRIC: 1734 case ALGORITHM_RIGHT_ASYMMETRIC:
1739 pd_idx = stripe % raid_disks; 1735 pd_idx = sector_div(stripe2, raid_disks);
1740 qd_idx = pd_idx + 1; 1736 qd_idx = pd_idx + 1;
1741 if (pd_idx == raid_disks-1) { 1737 if (pd_idx == raid_disks-1) {
1742 (*dd_idx)++; /* Q D D D P */ 1738 (*dd_idx)++; /* Q D D D P */
@@ -1745,12 +1741,12 @@ static sector_t raid5_compute_sector(raid5_conf_t *conf, sector_t r_sector,
1745 (*dd_idx) += 2; /* D D P Q D */ 1741 (*dd_idx) += 2; /* D D P Q D */
1746 break; 1742 break;
1747 case ALGORITHM_LEFT_SYMMETRIC: 1743 case ALGORITHM_LEFT_SYMMETRIC:
1748 pd_idx = raid_disks - 1 - (stripe % raid_disks); 1744 pd_idx = raid_disks - 1 - sector_div(stripe2, raid_disks);
1749 qd_idx = (pd_idx + 1) % raid_disks; 1745 qd_idx = (pd_idx + 1) % raid_disks;
1750 *dd_idx = (pd_idx + 2 + *dd_idx) % raid_disks; 1746 *dd_idx = (pd_idx + 2 + *dd_idx) % raid_disks;
1751 break; 1747 break;
1752 case ALGORITHM_RIGHT_SYMMETRIC: 1748 case ALGORITHM_RIGHT_SYMMETRIC:
1753 pd_idx = stripe % raid_disks; 1749 pd_idx = sector_div(stripe2, raid_disks);
1754 qd_idx = (pd_idx + 1) % raid_disks; 1750 qd_idx = (pd_idx + 1) % raid_disks;
1755 *dd_idx = (pd_idx + 2 + *dd_idx) % raid_disks; 1751 *dd_idx = (pd_idx + 2 + *dd_idx) % raid_disks;
1756 break; 1752 break;
@@ -1769,7 +1765,7 @@ static sector_t raid5_compute_sector(raid5_conf_t *conf, sector_t r_sector,
1769 /* Exactly the same as RIGHT_ASYMMETRIC, but or 1765 /* Exactly the same as RIGHT_ASYMMETRIC, but or
1770 * of blocks for computing Q is different. 1766 * of blocks for computing Q is different.
1771 */ 1767 */
1772 pd_idx = stripe % raid_disks; 1768 pd_idx = sector_div(stripe2, raid_disks);
1773 qd_idx = pd_idx + 1; 1769 qd_idx = pd_idx + 1;
1774 if (pd_idx == raid_disks-1) { 1770 if (pd_idx == raid_disks-1) {
1775 (*dd_idx)++; /* Q D D D P */ 1771 (*dd_idx)++; /* Q D D D P */
@@ -1784,7 +1780,8 @@ static sector_t raid5_compute_sector(raid5_conf_t *conf, sector_t r_sector,
1784 * D D D P Q rather than 1780 * D D D P Q rather than
1785 * Q D D D P 1781 * Q D D D P
1786 */ 1782 */
1787 pd_idx = raid_disks - 1 - ((stripe + 1) % raid_disks); 1783 stripe2 += 1;
1784 pd_idx = raid_disks - 1 - sector_div(stripe2, raid_disks);
1788 qd_idx = pd_idx + 1; 1785 qd_idx = pd_idx + 1;
1789 if (pd_idx == raid_disks-1) { 1786 if (pd_idx == raid_disks-1) {
1790 (*dd_idx)++; /* Q D D D P */ 1787 (*dd_idx)++; /* Q D D D P */
@@ -1796,7 +1793,7 @@ static sector_t raid5_compute_sector(raid5_conf_t *conf, sector_t r_sector,
1796 1793
1797 case ALGORITHM_ROTATING_N_CONTINUE: 1794 case ALGORITHM_ROTATING_N_CONTINUE:
1798 /* Same as left_symmetric but Q is before P */ 1795 /* Same as left_symmetric but Q is before P */
1799 pd_idx = raid_disks - 1 - (stripe % raid_disks); 1796 pd_idx = raid_disks - 1 - sector_div(stripe2, raid_disks);
1800 qd_idx = (pd_idx + raid_disks - 1) % raid_disks; 1797 qd_idx = (pd_idx + raid_disks - 1) % raid_disks;
1801 *dd_idx = (pd_idx + 1 + *dd_idx) % raid_disks; 1798 *dd_idx = (pd_idx + 1 + *dd_idx) % raid_disks;
1802 ddf_layout = 1; 1799 ddf_layout = 1;
@@ -1804,27 +1801,27 @@ static sector_t raid5_compute_sector(raid5_conf_t *conf, sector_t r_sector,
1804 1801
1805 case ALGORITHM_LEFT_ASYMMETRIC_6: 1802 case ALGORITHM_LEFT_ASYMMETRIC_6:
1806 /* RAID5 left_asymmetric, with Q on last device */ 1803 /* RAID5 left_asymmetric, with Q on last device */
1807 pd_idx = data_disks - stripe % (raid_disks-1); 1804 pd_idx = data_disks - sector_div(stripe2, raid_disks-1);
1808 if (*dd_idx >= pd_idx) 1805 if (*dd_idx >= pd_idx)
1809 (*dd_idx)++; 1806 (*dd_idx)++;
1810 qd_idx = raid_disks - 1; 1807 qd_idx = raid_disks - 1;
1811 break; 1808 break;
1812 1809
1813 case ALGORITHM_RIGHT_ASYMMETRIC_6: 1810 case ALGORITHM_RIGHT_ASYMMETRIC_6:
1814 pd_idx = stripe % (raid_disks-1); 1811 pd_idx = sector_div(stripe2, raid_disks-1);
1815 if (*dd_idx >= pd_idx) 1812 if (*dd_idx >= pd_idx)
1816 (*dd_idx)++; 1813 (*dd_idx)++;
1817 qd_idx = raid_disks - 1; 1814 qd_idx = raid_disks - 1;
1818 break; 1815 break;
1819 1816
1820 case ALGORITHM_LEFT_SYMMETRIC_6: 1817 case ALGORITHM_LEFT_SYMMETRIC_6:
1821 pd_idx = data_disks - stripe % (raid_disks-1); 1818 pd_idx = data_disks - sector_div(stripe2, raid_disks-1);
1822 *dd_idx = (pd_idx + 1 + *dd_idx) % (raid_disks-1); 1819 *dd_idx = (pd_idx + 1 + *dd_idx) % (raid_disks-1);
1823 qd_idx = raid_disks - 1; 1820 qd_idx = raid_disks - 1;
1824 break; 1821 break;
1825 1822
1826 case ALGORITHM_RIGHT_SYMMETRIC_6: 1823 case ALGORITHM_RIGHT_SYMMETRIC_6:
1827 pd_idx = stripe % (raid_disks-1); 1824 pd_idx = sector_div(stripe2, raid_disks-1);
1828 *dd_idx = (pd_idx + 1 + *dd_idx) % (raid_disks-1); 1825 *dd_idx = (pd_idx + 1 + *dd_idx) % (raid_disks-1);
1829 qd_idx = raid_disks - 1; 1826 qd_idx = raid_disks - 1;
1830 break; 1827 break;
@@ -1869,14 +1866,14 @@ static sector_t compute_blocknr(struct stripe_head *sh, int i, int previous)
1869 : conf->algorithm; 1866 : conf->algorithm;
1870 sector_t stripe; 1867 sector_t stripe;
1871 int chunk_offset; 1868 int chunk_offset;
1872 int chunk_number, dummy1, dd_idx = i; 1869 sector_t chunk_number;
1870 int dummy1, dd_idx = i;
1873 sector_t r_sector; 1871 sector_t r_sector;
1874 struct stripe_head sh2; 1872 struct stripe_head sh2;
1875 1873
1876 1874
1877 chunk_offset = sector_div(new_sector, sectors_per_chunk); 1875 chunk_offset = sector_div(new_sector, sectors_per_chunk);
1878 stripe = new_sector; 1876 stripe = new_sector;
1879 BUG_ON(new_sector != stripe);
1880 1877
1881 if (i == sh->pd_idx) 1878 if (i == sh->pd_idx)
1882 return 0; 1879 return 0;
@@ -1969,7 +1966,7 @@ static sector_t compute_blocknr(struct stripe_head *sh, int i, int previous)
1969 } 1966 }
1970 1967
1971 chunk_number = stripe * data_disks + i; 1968 chunk_number = stripe * data_disks + i;
1972 r_sector = (sector_t)chunk_number * sectors_per_chunk + chunk_offset; 1969 r_sector = chunk_number * sectors_per_chunk + chunk_offset;
1973 1970
1974 check = raid5_compute_sector(conf, r_sector, 1971 check = raid5_compute_sector(conf, r_sector,
1975 previous, &dummy1, &sh2); 1972 previous, &dummy1, &sh2);
diff --git a/drivers/md/raid6algos.c b/drivers/md/raid6algos.c
index bffc61bff5a..1f8784bfd44 100644
--- a/drivers/md/raid6algos.c
+++ b/drivers/md/raid6algos.c
@@ -17,6 +17,7 @@
17 */ 17 */
18 18
19#include <linux/raid/pq.h> 19#include <linux/raid/pq.h>
20#include <linux/gfp.h>
20#ifndef __KERNEL__ 21#ifndef __KERNEL__
21#include <sys/mman.h> 22#include <sys/mman.h>
22#include <stdio.h> 23#include <stdio.h>
diff --git a/drivers/media/IR/ir-keytable.c b/drivers/media/IR/ir-keytable.c
index 0a3b4ed38e4..bfca26d5182 100644
--- a/drivers/media/IR/ir-keytable.c
+++ b/drivers/media/IR/ir-keytable.c
@@ -14,6 +14,7 @@
14 14
15 15
16#include <linux/input.h> 16#include <linux/input.h>
17#include <linux/slab.h>
17#include <media/ir-common.h> 18#include <media/ir-common.h>
18 19
19#define IR_TAB_MIN_SIZE 32 20#define IR_TAB_MIN_SIZE 32
diff --git a/drivers/media/IR/ir-sysfs.c b/drivers/media/IR/ir-sysfs.c
index bf5fbcd8423..e14e6c486b5 100644
--- a/drivers/media/IR/ir-sysfs.c
+++ b/drivers/media/IR/ir-sysfs.c
@@ -12,6 +12,7 @@
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 */ 13 */
14 14
15#include <linux/slab.h>
15#include <linux/input.h> 16#include <linux/input.h>
16#include <linux/device.h> 17#include <linux/device.h>
17#include <media/ir-core.h> 18#include <media/ir-core.h>
diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c
index fd8e1f45be3..7364b9642d0 100644
--- a/drivers/media/common/saa7146_fops.c
+++ b/drivers/media/common/saa7146_fops.c
@@ -423,15 +423,14 @@ static void vv_callback(struct saa7146_dev *dev, unsigned long status)
423 } 423 }
424} 424}
425 425
426int saa7146_vv_devinit(struct saa7146_dev *dev)
427{
428 return v4l2_device_register(&dev->pci->dev, &dev->v4l2_dev);
429}
430EXPORT_SYMBOL_GPL(saa7146_vv_devinit);
431
432int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv) 426int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv)
433{ 427{
434 struct saa7146_vv *vv; 428 struct saa7146_vv *vv;
429 int err;
430
431 err = v4l2_device_register(&dev->pci->dev, &dev->v4l2_dev);
432 if (err)
433 return err;
435 434
436 vv = kzalloc(sizeof(struct saa7146_vv), GFP_KERNEL); 435 vv = kzalloc(sizeof(struct saa7146_vv), GFP_KERNEL);
437 if (vv == NULL) { 436 if (vv == NULL) {
diff --git a/drivers/media/common/saa7146_video.c b/drivers/media/common/saa7146_video.c
index 5ed75263340..b8b2c551a1e 100644
--- a/drivers/media/common/saa7146_video.c
+++ b/drivers/media/common/saa7146_video.c
@@ -558,9 +558,11 @@ static int vidioc_s_fbuf(struct file *file, void *fh, struct v4l2_framebuffer *f
558 /* ok, accept it */ 558 /* ok, accept it */
559 vv->ov_fb = *fb; 559 vv->ov_fb = *fb;
560 vv->ov_fmt = fmt; 560 vv->ov_fmt = fmt;
561 if (0 == vv->ov_fb.fmt.bytesperline) 561
562 vv->ov_fb.fmt.bytesperline = 562 if (vv->ov_fb.fmt.bytesperline < vv->ov_fb.fmt.width) {
563 vv->ov_fb.fmt.width * fmt->depth / 8; 563 vv->ov_fb.fmt.bytesperline = vv->ov_fb.fmt.width * fmt->depth / 8;
564 DEB_D(("setting bytesperline to %d\n", vv->ov_fb.fmt.bytesperline));
565 }
564 566
565 mutex_unlock(&dev->lock); 567 mutex_unlock(&dev->lock);
566 return 0; 568 return 0;
diff --git a/drivers/media/common/tuners/max2165.c b/drivers/media/common/tuners/max2165.c
index 3d03640cf1f..937e4b00d7e 100644
--- a/drivers/media/common/tuners/max2165.c
+++ b/drivers/media/common/tuners/max2165.c
@@ -25,6 +25,7 @@
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/dvb/frontend.h> 26#include <linux/dvb/frontend.h>
27#include <linux/i2c.h> 27#include <linux/i2c.h>
28#include <linux/slab.h>
28 29
29#include "dvb_frontend.h" 30#include "dvb_frontend.h"
30 31
diff --git a/drivers/media/common/tuners/mc44s803.c b/drivers/media/common/tuners/mc44s803.c
index 20c4485ce16..fe5c4b8d83e 100644
--- a/drivers/media/common/tuners/mc44s803.c
+++ b/drivers/media/common/tuners/mc44s803.c
@@ -23,6 +23,7 @@
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/dvb/frontend.h> 24#include <linux/dvb/frontend.h>
25#include <linux/i2c.h> 25#include <linux/i2c.h>
26#include <linux/slab.h>
26 27
27#include "dvb_frontend.h" 28#include "dvb_frontend.h"
28 29
diff --git a/drivers/media/common/tuners/mt2060.c b/drivers/media/common/tuners/mt2060.c
index c7abe3d8f90..2d0e7689c6a 100644
--- a/drivers/media/common/tuners/mt2060.c
+++ b/drivers/media/common/tuners/mt2060.c
@@ -25,6 +25,7 @@
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/dvb/frontend.h> 26#include <linux/dvb/frontend.h>
27#include <linux/i2c.h> 27#include <linux/i2c.h>
28#include <linux/slab.h>
28 29
29#include "dvb_frontend.h" 30#include "dvb_frontend.h"
30 31
diff --git a/drivers/media/common/tuners/mt20xx.c b/drivers/media/common/tuners/mt20xx.c
index 44608ad4e2d..d0e70e10a71 100644
--- a/drivers/media/common/tuners/mt20xx.c
+++ b/drivers/media/common/tuners/mt20xx.c
@@ -6,6 +6,7 @@
6 */ 6 */
7#include <linux/delay.h> 7#include <linux/delay.h>
8#include <linux/i2c.h> 8#include <linux/i2c.h>
9#include <linux/slab.h>
9#include <linux/videodev2.h> 10#include <linux/videodev2.h>
10#include "tuner-i2c.h" 11#include "tuner-i2c.h"
11#include "mt20xx.h" 12#include "mt20xx.h"
diff --git a/drivers/media/common/tuners/mt2131.c b/drivers/media/common/tuners/mt2131.c
index e8d3c48f860..a4f830bb25d 100644
--- a/drivers/media/common/tuners/mt2131.c
+++ b/drivers/media/common/tuners/mt2131.c
@@ -23,6 +23,7 @@
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/dvb/frontend.h> 24#include <linux/dvb/frontend.h>
25#include <linux/i2c.h> 25#include <linux/i2c.h>
26#include <linux/slab.h>
26 27
27#include "dvb_frontend.h" 28#include "dvb_frontend.h"
28 29
diff --git a/drivers/media/common/tuners/mt2266.c b/drivers/media/common/tuners/mt2266.c
index 54b18f94b14..25a8ea342c4 100644
--- a/drivers/media/common/tuners/mt2266.c
+++ b/drivers/media/common/tuners/mt2266.c
@@ -18,6 +18,7 @@
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/dvb/frontend.h> 19#include <linux/dvb/frontend.h>
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <linux/slab.h>
21 22
22#include "dvb_frontend.h" 23#include "dvb_frontend.h"
23#include "mt2266.h" 24#include "mt2266.h"
diff --git a/drivers/media/common/tuners/tda827x.c b/drivers/media/common/tuners/tda827x.c
index 36a7bc7585a..b21b6ea68b2 100644
--- a/drivers/media/common/tuners/tda827x.c
+++ b/drivers/media/common/tuners/tda827x.c
@@ -19,6 +19,7 @@
19 */ 19 */
20 20
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/slab.h>
22#include <asm/types.h> 23#include <asm/types.h>
23#include <linux/dvb/frontend.h> 24#include <linux/dvb/frontend.h>
24#include <linux/videodev2.h> 25#include <linux/videodev2.h>
diff --git a/drivers/media/common/tuners/tda8290.c b/drivers/media/common/tuners/tda8290.c
index 2833137fa81..c9062ceddc7 100644
--- a/drivers/media/common/tuners/tda8290.c
+++ b/drivers/media/common/tuners/tda8290.c
@@ -21,6 +21,7 @@
21*/ 21*/
22 22
23#include <linux/i2c.h> 23#include <linux/i2c.h>
24#include <linux/slab.h>
24#include <linux/delay.h> 25#include <linux/delay.h>
25#include <linux/videodev2.h> 26#include <linux/videodev2.h>
26#include "tuner-i2c.h" 27#include "tuner-i2c.h"
diff --git a/drivers/media/common/tuners/tda9887.c b/drivers/media/common/tuners/tda9887.c
index a71c100c95d..bf14bd79e2f 100644
--- a/drivers/media/common/tuners/tda9887.c
+++ b/drivers/media/common/tuners/tda9887.c
@@ -4,7 +4,6 @@
4#include <linux/types.h> 4#include <linux/types.h>
5#include <linux/init.h> 5#include <linux/init.h>
6#include <linux/errno.h> 6#include <linux/errno.h>
7#include <linux/slab.h>
8#include <linux/delay.h> 7#include <linux/delay.h>
9#include <linux/videodev2.h> 8#include <linux/videodev2.h>
10#include <media/v4l2-common.h> 9#include <media/v4l2-common.h>
diff --git a/drivers/media/common/tuners/tea5761.c b/drivers/media/common/tuners/tea5761.c
index 60ed872f3d4..925399dffbe 100644
--- a/drivers/media/common/tuners/tea5761.c
+++ b/drivers/media/common/tuners/tea5761.c
@@ -8,6 +8,7 @@
8 */ 8 */
9 9
10#include <linux/i2c.h> 10#include <linux/i2c.h>
11#include <linux/slab.h>
11#include <linux/delay.h> 12#include <linux/delay.h>
12#include <linux/videodev2.h> 13#include <linux/videodev2.h>
13#include <media/tuner.h> 14#include <media/tuner.h>
diff --git a/drivers/media/common/tuners/tea5767.c b/drivers/media/common/tuners/tea5767.c
index 223a226d20a..36e85d81acb 100644
--- a/drivers/media/common/tuners/tea5767.c
+++ b/drivers/media/common/tuners/tea5767.c
@@ -11,6 +11,7 @@
11 */ 11 */
12 12
13#include <linux/i2c.h> 13#include <linux/i2c.h>
14#include <linux/slab.h>
14#include <linux/delay.h> 15#include <linux/delay.h>
15#include <linux/videodev2.h> 16#include <linux/videodev2.h>
16#include "tuner-i2c.h" 17#include "tuner-i2c.h"
diff --git a/drivers/media/common/tuners/tuner-i2c.h b/drivers/media/common/tuners/tuner-i2c.h
index cb1c7141f0c..18f005634c6 100644
--- a/drivers/media/common/tuners/tuner-i2c.h
+++ b/drivers/media/common/tuners/tuner-i2c.h
@@ -22,6 +22,7 @@
22#define __TUNER_I2C_H__ 22#define __TUNER_I2C_H__
23 23
24#include <linux/i2c.h> 24#include <linux/i2c.h>
25#include <linux/slab.h>
25 26
26struct tuner_i2c_props { 27struct tuner_i2c_props {
27 u8 addr; 28 u8 addr;
diff --git a/drivers/media/common/tuners/tuner-xc2028.c b/drivers/media/common/tuners/tuner-xc2028.c
index be51c294b37..96d61707f50 100644
--- a/drivers/media/common/tuners/tuner-xc2028.c
+++ b/drivers/media/common/tuners/tuner-xc2028.c
@@ -15,6 +15,7 @@
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <media/tuner.h> 16#include <media/tuner.h>
17#include <linux/mutex.h> 17#include <linux/mutex.h>
18#include <linux/slab.h>
18#include <asm/unaligned.h> 19#include <asm/unaligned.h>
19#include "tuner-i2c.h" 20#include "tuner-i2c.h"
20#include "tuner-xc2028.h" 21#include "tuner-xc2028.h"
diff --git a/drivers/media/dvb/bt8xx/dst_ca.c b/drivers/media/dvb/bt8xx/dst_ca.c
index 0e246eaad05..770243c720d 100644
--- a/drivers/media/dvb/bt8xx/dst_ca.c
+++ b/drivers/media/dvb/bt8xx/dst_ca.c
@@ -20,6 +20,7 @@
20 20
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/slab.h>
23#include <linux/init.h> 24#include <linux/init.h>
24#include <linux/smp_lock.h> 25#include <linux/smp_lock.h>
25#include <linux/string.h> 26#include <linux/string.h>
diff --git a/drivers/media/dvb/dm1105/dm1105.c b/drivers/media/dvb/dm1105/dm1105.c
index 383cca378b8..b6d46961a99 100644
--- a/drivers/media/dvb/dm1105/dm1105.c
+++ b/drivers/media/dvb/dm1105/dm1105.c
@@ -27,6 +27,7 @@
27#include <linux/pci.h> 27#include <linux/pci.h>
28#include <linux/dma-mapping.h> 28#include <linux/dma-mapping.h>
29#include <linux/input.h> 29#include <linux/input.h>
30#include <linux/slab.h>
30#include <media/ir-common.h> 31#include <media/ir-common.h>
31 32
32#include "demux.h" 33#include "demux.h"
diff --git a/drivers/media/dvb/dvb-core/dmxdev.h b/drivers/media/dvb/dvb-core/dmxdev.h
index c1379b56dfb..02ebe28f830 100644
--- a/drivers/media/dvb/dvb-core/dmxdev.h
+++ b/drivers/media/dvb/dvb-core/dmxdev.h
@@ -31,6 +31,7 @@
31#include <linux/fs.h> 31#include <linux/fs.h>
32#include <linux/string.h> 32#include <linux/string.h>
33#include <linux/mutex.h> 33#include <linux/mutex.h>
34#include <linux/slab.h>
34 35
35#include <linux/dvb/dmx.h> 36#include <linux/dvb/dmx.h>
36 37
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.h b/drivers/media/dvb/dvb-core/dvb_frontend.h
index 80dda308ff7..bf0e6bed28d 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.h
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.h
@@ -36,6 +36,7 @@
36#include <linux/errno.h> 36#include <linux/errno.h>
37#include <linux/delay.h> 37#include <linux/delay.h>
38#include <linux/mutex.h> 38#include <linux/mutex.h>
39#include <linux/slab.h>
39 40
40#include <linux/dvb/frontend.h> 41#include <linux/dvb/frontend.h>
41 42
diff --git a/drivers/media/dvb/dvb-usb/af9015.c b/drivers/media/dvb/dvb-usb/af9015.c
index d7975383d31..74d94e45324 100644
--- a/drivers/media/dvb/dvb-usb/af9015.c
+++ b/drivers/media/dvb/dvb-usb/af9015.c
@@ -22,6 +22,7 @@
22 */ 22 */
23 23
24#include <linux/hash.h> 24#include <linux/hash.h>
25#include <linux/slab.h>
25 26
26#include "af9015.h" 27#include "af9015.h"
27#include "af9013.h" 28#include "af9013.h"
diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c
index a7b8405c291..960376da7d5 100644
--- a/drivers/media/dvb/dvb-usb/cxusb.c
+++ b/drivers/media/dvb/dvb-usb/cxusb.c
@@ -25,6 +25,7 @@
25 */ 25 */
26#include <media/tuner.h> 26#include <media/tuner.h>
27#include <linux/vmalloc.h> 27#include <linux/vmalloc.h>
28#include <linux/slab.h>
28 29
29#include "cxusb.h" 30#include "cxusb.h"
30 31
diff --git a/drivers/media/dvb/firewire/firedtv-1394.c b/drivers/media/dvb/firewire/firedtv-1394.c
index c3e0ec2dcfc..26333b4f4d3 100644
--- a/drivers/media/dvb/firewire/firedtv-1394.c
+++ b/drivers/media/dvb/firewire/firedtv-1394.c
@@ -15,6 +15,7 @@
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/list.h> 17#include <linux/list.h>
18#include <linux/slab.h>
18#include <linux/spinlock.h> 19#include <linux/spinlock.h>
19#include <linux/types.h> 20#include <linux/types.h>
20 21
diff --git a/drivers/media/dvb/firewire/firedtv-rc.c b/drivers/media/dvb/firewire/firedtv-rc.c
index 599d66e5843..fcf3828472b 100644
--- a/drivers/media/dvb/firewire/firedtv-rc.c
+++ b/drivers/media/dvb/firewire/firedtv-rc.c
@@ -12,6 +12,7 @@
12#include <linux/bitops.h> 12#include <linux/bitops.h>
13#include <linux/input.h> 13#include <linux/input.h>
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/slab.h>
15#include <linux/string.h> 16#include <linux/string.h>
16#include <linux/types.h> 17#include <linux/types.h>
17#include <linux/workqueue.h> 18#include <linux/workqueue.h>
diff --git a/drivers/media/dvb/frontends/au8522_dig.c b/drivers/media/dvb/frontends/au8522_dig.c
index 956b80f4979..a1fed0fa8ed 100644
--- a/drivers/media/dvb/frontends/au8522_dig.c
+++ b/drivers/media/dvb/frontends/au8522_dig.c
@@ -23,7 +23,6 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/string.h> 25#include <linux/string.h>
26#include <linux/slab.h>
27#include <linux/delay.h> 26#include <linux/delay.h>
28#include "dvb_frontend.h" 27#include "dvb_frontend.h"
29#include "au8522.h" 28#include "au8522.h"
diff --git a/drivers/media/dvb/frontends/dib0070.c b/drivers/media/dvb/frontends/dib0070.c
index 0d12763603b..d4e466a90e4 100644
--- a/drivers/media/dvb/frontends/dib0070.c
+++ b/drivers/media/dvb/frontends/dib0070.c
@@ -25,6 +25,7 @@
25 */ 25 */
26 26
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/slab.h>
28#include <linux/i2c.h> 29#include <linux/i2c.h>
29 30
30#include "dvb_frontend.h" 31#include "dvb_frontend.h"
diff --git a/drivers/media/dvb/frontends/dib0090.c b/drivers/media/dvb/frontends/dib0090.c
index 7eac178f57b..65240b7801e 100644
--- a/drivers/media/dvb/frontends/dib0090.c
+++ b/drivers/media/dvb/frontends/dib0090.c
@@ -25,6 +25,7 @@
25 */ 25 */
26 26
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/slab.h>
28#include <linux/i2c.h> 29#include <linux/i2c.h>
29 30
30#include "dvb_frontend.h" 31#include "dvb_frontend.h"
diff --git a/drivers/media/dvb/frontends/dib3000mc.c b/drivers/media/dvb/frontends/dib3000mc.c
index fa851601e7d..40a09981027 100644
--- a/drivers/media/dvb/frontends/dib3000mc.c
+++ b/drivers/media/dvb/frontends/dib3000mc.c
@@ -12,6 +12,7 @@
12 */ 12 */
13 13
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/slab.h>
15#include <linux/i2c.h> 16#include <linux/i2c.h>
16 17
17#include "dvb_frontend.h" 18#include "dvb_frontend.h"
diff --git a/drivers/media/dvb/frontends/dib7000m.c b/drivers/media/dvb/frontends/dib7000m.c
index 0109720353b..0f09fd31cb2 100644
--- a/drivers/media/dvb/frontends/dib7000m.c
+++ b/drivers/media/dvb/frontends/dib7000m.c
@@ -9,6 +9,7 @@
9 * published by the Free Software Foundation, version 2. 9 * published by the Free Software Foundation, version 2.
10 */ 10 */
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/slab.h>
12#include <linux/i2c.h> 13#include <linux/i2c.h>
13 14
14#include "dvb_frontend.h" 15#include "dvb_frontend.h"
diff --git a/drivers/media/dvb/frontends/dib7000p.c b/drivers/media/dvb/frontends/dib7000p.c
index 750ae61a20f..85468a45c34 100644
--- a/drivers/media/dvb/frontends/dib7000p.c
+++ b/drivers/media/dvb/frontends/dib7000p.c
@@ -8,6 +8,7 @@
8 * published by the Free Software Foundation, version 2. 8 * published by the Free Software Foundation, version 2.
9 */ 9 */
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/slab.h>
11#include <linux/i2c.h> 12#include <linux/i2c.h>
12 13
13#include "dvb_math.h" 14#include "dvb_math.h"
diff --git a/drivers/media/dvb/frontends/dib8000.c b/drivers/media/dvb/frontends/dib8000.c
index 2aa97dd6a8a..df17b91b325 100644
--- a/drivers/media/dvb/frontends/dib8000.c
+++ b/drivers/media/dvb/frontends/dib8000.c
@@ -8,6 +8,7 @@
8 * published by the Free Software Foundation, version 2. 8 * published by the Free Software Foundation, version 2.
9 */ 9 */
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/slab.h>
11#include <linux/i2c.h> 12#include <linux/i2c.h>
12#include "dvb_math.h" 13#include "dvb_math.h"
13 14
diff --git a/drivers/media/dvb/frontends/drx397xD.c b/drivers/media/dvb/frontends/drx397xD.c
index 868b78bfae7..f74cca6dc26 100644
--- a/drivers/media/dvb/frontends/drx397xD.c
+++ b/drivers/media/dvb/frontends/drx397xD.c
@@ -26,6 +26,7 @@
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/string.h> 27#include <linux/string.h>
28#include <linux/firmware.h> 28#include <linux/firmware.h>
29#include <linux/slab.h>
29#include <asm/div64.h> 30#include <asm/div64.h>
30 31
31#include "dvb_frontend.h" 32#include "dvb_frontend.h"
diff --git a/drivers/media/dvb/frontends/dvb-pll.c b/drivers/media/dvb/frontends/dvb-pll.c
index 6d865d6161d..4d4d0bb5920 100644
--- a/drivers/media/dvb/frontends/dvb-pll.c
+++ b/drivers/media/dvb/frontends/dvb-pll.c
@@ -18,6 +18,7 @@
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 19 */
20 20
21#include <linux/slab.h>
21#include <linux/module.h> 22#include <linux/module.h>
22#include <linux/dvb/frontend.h> 23#include <linux/dvb/frontend.h>
23#include <asm/types.h> 24#include <asm/types.h>
diff --git a/drivers/media/dvb/frontends/itd1000.c b/drivers/media/dvb/frontends/itd1000.c
index 600dad6b41e..f7a40a18777 100644
--- a/drivers/media/dvb/frontends/itd1000.c
+++ b/drivers/media/dvb/frontends/itd1000.c
@@ -24,6 +24,7 @@
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/dvb/frontend.h> 25#include <linux/dvb/frontend.h>
26#include <linux/i2c.h> 26#include <linux/i2c.h>
27#include <linux/slab.h>
27 28
28#include "dvb_frontend.h" 29#include "dvb_frontend.h"
29 30
diff --git a/drivers/media/dvb/frontends/lgdt3304.c b/drivers/media/dvb/frontends/lgdt3304.c
index e334b5d4e57..45a529b06b9 100644
--- a/drivers/media/dvb/frontends/lgdt3304.c
+++ b/drivers/media/dvb/frontends/lgdt3304.c
@@ -7,6 +7,7 @@
7 7
8#include <linux/kernel.h> 8#include <linux/kernel.h>
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/slab.h>
10#include <linux/delay.h> 11#include <linux/delay.h>
11#include "dvb_frontend.h" 12#include "dvb_frontend.h"
12#include "lgdt3304.h" 13#include "lgdt3304.h"
diff --git a/drivers/media/dvb/frontends/lgdt3305.c b/drivers/media/dvb/frontends/lgdt3305.c
index fde8c59700f..d69c775f864 100644
--- a/drivers/media/dvb/frontends/lgdt3305.c
+++ b/drivers/media/dvb/frontends/lgdt3305.c
@@ -21,6 +21,7 @@
21 21
22#include <asm/div64.h> 22#include <asm/div64.h>
23#include <linux/dvb/frontend.h> 23#include <linux/dvb/frontend.h>
24#include <linux/slab.h>
24#include "dvb_math.h" 25#include "dvb_math.h"
25#include "lgdt3305.h" 26#include "lgdt3305.h"
26 27
diff --git a/drivers/media/dvb/frontends/mb86a16.c b/drivers/media/dvb/frontends/mb86a16.c
index d05f7500e0c..599d1aa519a 100644
--- a/drivers/media/dvb/frontends/mb86a16.c
+++ b/drivers/media/dvb/frontends/mb86a16.c
@@ -22,6 +22,7 @@
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/moduleparam.h> 24#include <linux/moduleparam.h>
25#include <linux/slab.h>
25 26
26#include "dvb_frontend.h" 27#include "dvb_frontend.h"
27#include "mb86a16.h" 28#include "mb86a16.h"
diff --git a/drivers/media/dvb/frontends/s921_module.c b/drivers/media/dvb/frontends/s921_module.c
index 3156b64cfc9..0eefff61cc5 100644
--- a/drivers/media/dvb/frontends/s921_module.c
+++ b/drivers/media/dvb/frontends/s921_module.c
@@ -9,6 +9,7 @@
9 9
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/slab.h>
12#include <linux/delay.h> 13#include <linux/delay.h>
13#include "dvb_frontend.h" 14#include "dvb_frontend.h"
14#include "s921_module.h" 15#include "s921_module.h"
diff --git a/drivers/media/dvb/frontends/stb0899_drv.c b/drivers/media/dvb/frontends/stb0899_drv.c
index 1570669837e..8e38fcee564 100644
--- a/drivers/media/dvb/frontends/stb0899_drv.c
+++ b/drivers/media/dvb/frontends/stb0899_drv.c
@@ -22,6 +22,7 @@
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/slab.h>
25#include <linux/string.h> 26#include <linux/string.h>
26 27
27#include <linux/dvb/frontend.h> 28#include <linux/dvb/frontend.h>
diff --git a/drivers/media/dvb/frontends/stb6000.c b/drivers/media/dvb/frontends/stb6000.c
index 0e2cb0df144..ed699647050 100644
--- a/drivers/media/dvb/frontends/stb6000.c
+++ b/drivers/media/dvb/frontends/stb6000.c
@@ -20,6 +20,7 @@
20 20
21 */ 21 */
22 22
23#include <linux/slab.h>
23#include <linux/module.h> 24#include <linux/module.h>
24#include <linux/dvb/frontend.h> 25#include <linux/dvb/frontend.h>
25#include <asm/types.h> 26#include <asm/types.h>
diff --git a/drivers/media/dvb/frontends/stb6100.c b/drivers/media/dvb/frontends/stb6100.c
index 60ee18a94f4..f73c13323e9 100644
--- a/drivers/media/dvb/frontends/stb6100.c
+++ b/drivers/media/dvb/frontends/stb6100.c
@@ -22,6 +22,7 @@
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/slab.h>
25#include <linux/string.h> 26#include <linux/string.h>
26 27
27#include "dvb_frontend.h" 28#include "dvb_frontend.h"
diff --git a/drivers/media/dvb/frontends/stv090x.c b/drivers/media/dvb/frontends/stv090x.c
index c52c3357dc5..96972804f4a 100644
--- a/drivers/media/dvb/frontends/stv090x.c
+++ b/drivers/media/dvb/frontends/stv090x.c
@@ -23,6 +23,7 @@
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/string.h> 25#include <linux/string.h>
26#include <linux/slab.h>
26#include <linux/mutex.h> 27#include <linux/mutex.h>
27 28
28#include <linux/dvb/frontend.h> 29#include <linux/dvb/frontend.h>
@@ -4469,6 +4470,10 @@ static int stv090x_setup(struct dvb_frontend *fe)
4469 if (stv090x_write_reg(state, STV090x_TSTRES0, 0x00) < 0) 4470 if (stv090x_write_reg(state, STV090x_TSTRES0, 0x00) < 0)
4470 goto err; 4471 goto err;
4471 4472
4473 /* workaround for stuck DiSEqC output */
4474 if (config->diseqc_envelope_mode)
4475 stv090x_send_diseqc_burst(fe, SEC_MINI_A);
4476
4472 return 0; 4477 return 0;
4473err: 4478err:
4474 dprintk(FE_ERROR, 1, "I/O error"); 4479 dprintk(FE_ERROR, 1, "I/O error");
diff --git a/drivers/media/dvb/frontends/stv6110.c b/drivers/media/dvb/frontends/stv6110.c
index bef0cc83847..2dca7c8e514 100644
--- a/drivers/media/dvb/frontends/stv6110.c
+++ b/drivers/media/dvb/frontends/stv6110.c
@@ -22,6 +22,7 @@
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */ 23 */
24 24
25#include <linux/slab.h>
25#include <linux/module.h> 26#include <linux/module.h>
26#include <linux/dvb/frontend.h> 27#include <linux/dvb/frontend.h>
27 28
diff --git a/drivers/media/dvb/frontends/stv6110x.c b/drivers/media/dvb/frontends/stv6110x.c
index f931ed07e92..dea4245f077 100644
--- a/drivers/media/dvb/frontends/stv6110x.c
+++ b/drivers/media/dvb/frontends/stv6110x.c
@@ -23,6 +23,7 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/slab.h>
26#include <linux/string.h> 27#include <linux/string.h>
27 28
28#include "dvb_frontend.h" 29#include "dvb_frontend.h"
diff --git a/drivers/media/dvb/frontends/tda665x.c b/drivers/media/dvb/frontends/tda665x.c
index c44fefe92d9..2c1c759a4f4 100644
--- a/drivers/media/dvb/frontends/tda665x.c
+++ b/drivers/media/dvb/frontends/tda665x.c
@@ -20,6 +20,7 @@
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/slab.h>
23 24
24#include "dvb_frontend.h" 25#include "dvb_frontend.h"
25#include "tda665x.h" 26#include "tda665x.h"
diff --git a/drivers/media/dvb/frontends/tda8261.c b/drivers/media/dvb/frontends/tda8261.c
index 614afcec05f..1742056a34e 100644
--- a/drivers/media/dvb/frontends/tda8261.c
+++ b/drivers/media/dvb/frontends/tda8261.c
@@ -21,6 +21,7 @@
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/slab.h>
24 25
25#include "dvb_frontend.h" 26#include "dvb_frontend.h"
26#include "tda8261.h" 27#include "tda8261.h"
diff --git a/drivers/media/dvb/frontends/tda826x.c b/drivers/media/dvb/frontends/tda826x.c
index a051554b5e2..06c94800b94 100644
--- a/drivers/media/dvb/frontends/tda826x.c
+++ b/drivers/media/dvb/frontends/tda826x.c
@@ -20,6 +20,7 @@
20 20
21 */ 21 */
22 22
23#include <linux/slab.h>
23#include <linux/module.h> 24#include <linux/module.h>
24#include <linux/dvb/frontend.h> 25#include <linux/dvb/frontend.h>
25#include <asm/types.h> 26#include <asm/types.h>
diff --git a/drivers/media/dvb/frontends/tua6100.c b/drivers/media/dvb/frontends/tua6100.c
index 1790baee014..bcb95c2ef29 100644
--- a/drivers/media/dvb/frontends/tua6100.c
+++ b/drivers/media/dvb/frontends/tua6100.c
@@ -28,6 +28,7 @@
28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 */ 29 */
30 30
31#include <linux/slab.h>
31#include <linux/module.h> 32#include <linux/module.h>
32#include <linux/dvb/frontend.h> 33#include <linux/dvb/frontend.h>
33#include <asm/types.h> 34#include <asm/types.h>
diff --git a/drivers/media/dvb/frontends/zl10036.c b/drivers/media/dvb/frontends/zl10036.c
index 34c5de491d2..4627f491656 100644
--- a/drivers/media/dvb/frontends/zl10036.c
+++ b/drivers/media/dvb/frontends/zl10036.c
@@ -29,6 +29,7 @@
29 29
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/dvb/frontend.h> 31#include <linux/dvb/frontend.h>
32#include <linux/slab.h>
32#include <linux/types.h> 33#include <linux/types.h>
33 34
34#include "zl10036.h" 35#include "zl10036.h"
diff --git a/drivers/media/dvb/mantis/hopper_cards.c b/drivers/media/dvb/mantis/hopper_cards.c
index d073c61e3c0..09e9fc78518 100644
--- a/drivers/media/dvb/mantis/hopper_cards.c
+++ b/drivers/media/dvb/mantis/hopper_cards.c
@@ -22,6 +22,7 @@
22#include <linux/moduleparam.h> 22#include <linux/moduleparam.h>
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/pci.h> 24#include <linux/pci.h>
25#include <linux/slab.h>
25#include <asm/irq.h> 26#include <asm/irq.h>
26#include <linux/interrupt.h> 27#include <linux/interrupt.h>
27 28
diff --git a/drivers/media/dvb/mantis/mantis_ca.c b/drivers/media/dvb/mantis/mantis_ca.c
index 403ce043d00..330216febd7 100644
--- a/drivers/media/dvb/mantis/mantis_ca.c
+++ b/drivers/media/dvb/mantis/mantis_ca.c
@@ -19,6 +19,7 @@
19*/ 19*/
20 20
21#include <linux/signal.h> 21#include <linux/signal.h>
22#include <linux/slab.h>
22#include <linux/sched.h> 23#include <linux/sched.h>
23#include <linux/interrupt.h> 24#include <linux/interrupt.h>
24 25
diff --git a/drivers/media/dvb/mantis/mantis_cards.c b/drivers/media/dvb/mantis/mantis_cards.c
index 16f1708fd3b..cf4b39ffdaa 100644
--- a/drivers/media/dvb/mantis/mantis_cards.c
+++ b/drivers/media/dvb/mantis/mantis_cards.c
@@ -22,6 +22,7 @@
22#include <linux/moduleparam.h> 22#include <linux/moduleparam.h>
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/pci.h> 24#include <linux/pci.h>
25#include <linux/slab.h>
25#include <asm/irq.h> 26#include <asm/irq.h>
26#include <linux/interrupt.h> 27#include <linux/interrupt.h>
27 28
diff --git a/drivers/media/dvb/ngene/ngene-core.c b/drivers/media/dvb/ngene/ngene-core.c
index 0150dfe7cfb..645e8b8a713 100644
--- a/drivers/media/dvb/ngene/ngene-core.c
+++ b/drivers/media/dvb/ngene/ngene-core.c
@@ -30,7 +30,6 @@
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/init.h> 31#include <linux/init.h>
32#include <linux/delay.h> 32#include <linux/delay.h>
33#include <linux/slab.h>
34#include <linux/poll.h> 33#include <linux/poll.h>
35#include <linux/io.h> 34#include <linux/io.h>
36#include <asm/div64.h> 35#include <asm/div64.h>
diff --git a/drivers/media/dvb/pluto2/pluto2.c b/drivers/media/dvb/pluto2/pluto2.c
index 80d14a065ba..1c798219dc7 100644
--- a/drivers/media/dvb/pluto2/pluto2.c
+++ b/drivers/media/dvb/pluto2/pluto2.c
@@ -30,6 +30,7 @@
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/pci.h> 31#include <linux/pci.h>
32#include <linux/dma-mapping.h> 32#include <linux/dma-mapping.h>
33#include <linux/slab.h>
33 34
34#include "demux.h" 35#include "demux.h"
35#include "dmxdev.h" 36#include "dmxdev.h"
diff --git a/drivers/media/dvb/pt1/pt1.c b/drivers/media/dvb/pt1/pt1.c
index 81e623a90f0..6aded234aa6 100644
--- a/drivers/media/dvb/pt1/pt1.c
+++ b/drivers/media/dvb/pt1/pt1.c
@@ -23,6 +23,7 @@
23 23
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/slab.h>
26#include <linux/vmalloc.h> 27#include <linux/vmalloc.h>
27#include <linux/pci.h> 28#include <linux/pci.h>
28#include <linux/kthread.h> 29#include <linux/kthread.h>
diff --git a/drivers/media/dvb/siano/smscoreapi.c b/drivers/media/dvb/siano/smscoreapi.c
index 4bfd3451b56..0c87a3c3899 100644
--- a/drivers/media/dvb/siano/smscoreapi.c
+++ b/drivers/media/dvb/siano/smscoreapi.c
@@ -28,6 +28,7 @@
28#include <linux/dma-mapping.h> 28#include <linux/dma-mapping.h>
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/io.h> 30#include <linux/io.h>
31#include <linux/slab.h>
31 32
32#include <linux/firmware.h> 33#include <linux/firmware.h>
33#include <linux/wait.h> 34#include <linux/wait.h>
diff --git a/drivers/media/dvb/siano/smsdvb.c b/drivers/media/dvb/siano/smsdvb.c
index 5f3939821ca..b80d09b035a 100644
--- a/drivers/media/dvb/siano/smsdvb.c
+++ b/drivers/media/dvb/siano/smsdvb.c
@@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
20****************************************************************/ 20****************************************************************/
21 21
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/slab.h>
23#include <linux/init.h> 24#include <linux/init.h>
24 25
25#include "dmxdev.h" 26#include "dmxdev.h"
diff --git a/drivers/media/dvb/siano/smssdio.c b/drivers/media/dvb/siano/smssdio.c
index 195244a3e69..e57d38b0197 100644
--- a/drivers/media/dvb/siano/smssdio.c
+++ b/drivers/media/dvb/siano/smssdio.c
@@ -33,6 +33,7 @@
33 */ 33 */
34 34
35#include <linux/moduleparam.h> 35#include <linux/moduleparam.h>
36#include <linux/slab.h>
36#include <linux/firmware.h> 37#include <linux/firmware.h>
37#include <linux/delay.h> 38#include <linux/delay.h>
38#include <linux/mmc/card.h> 39#include <linux/mmc/card.h>
diff --git a/drivers/media/dvb/siano/smsusb.c b/drivers/media/dvb/siano/smsusb.c
index 5eac27287d9..a9c27fb69ba 100644
--- a/drivers/media/dvb/siano/smsusb.c
+++ b/drivers/media/dvb/siano/smsusb.c
@@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/usb.h> 24#include <linux/usb.h>
25#include <linux/firmware.h> 25#include <linux/firmware.h>
26#include <linux/slab.h>
26 27
27#include "smscoreapi.h" 28#include "smscoreapi.h"
28#include "sms-cards.h" 29#include "sms-cards.h"
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
index baf3159a3aa..38915591c6e 100644
--- a/drivers/media/dvb/ttpci/av7110.c
+++ b/drivers/media/dvb/ttpci/av7110.c
@@ -49,6 +49,7 @@
49#include <linux/crc32.h> 49#include <linux/crc32.h>
50#include <linux/i2c.h> 50#include <linux/i2c.h>
51#include <linux/kthread.h> 51#include <linux/kthread.h>
52#include <linux/slab.h>
52#include <asm/unaligned.h> 53#include <asm/unaligned.h>
53#include <asm/byteorder.h> 54#include <asm/byteorder.h>
54 55
diff --git a/drivers/media/dvb/ttpci/av7110_ca.c b/drivers/media/dvb/ttpci/av7110_ca.c
index c7a65b1544a..ac7779c45c5 100644
--- a/drivers/media/dvb/ttpci/av7110_ca.c
+++ b/drivers/media/dvb/ttpci/av7110_ca.c
@@ -34,6 +34,7 @@
34#include <linux/fs.h> 34#include <linux/fs.h>
35#include <linux/timer.h> 35#include <linux/timer.h>
36#include <linux/poll.h> 36#include <linux/poll.h>
37#include <linux/gfp.h>
37 38
38#include "av7110.h" 39#include "av7110.h"
39#include "av7110_hw.h" 40#include "av7110_hw.h"
diff --git a/drivers/media/dvb/ttpci/budget.c b/drivers/media/dvb/ttpci/budget.c
index 9fdf26cc699..1500210c06c 100644
--- a/drivers/media/dvb/ttpci/budget.c
+++ b/drivers/media/dvb/ttpci/budget.c
@@ -643,9 +643,6 @@ static void frontend_init(struct budget *budget)
643 &budget->i2c_adap, 643 &budget->i2c_adap,
644 &tt1600_isl6423_config); 644 &tt1600_isl6423_config);
645 645
646 } else {
647 dvb_frontend_detach(budget->dvb_frontend);
648 budget->dvb_frontend = NULL;
649 } 646 }
650 } 647 }
651 break; 648 break;
diff --git a/drivers/media/radio/radio-gemtek-pci.c b/drivers/media/radio/radio-gemtek-pci.c
index 000f4d34087..79039674a0e 100644
--- a/drivers/media/radio/radio-gemtek-pci.c
+++ b/drivers/media/radio/radio-gemtek-pci.c
@@ -48,6 +48,7 @@
48#include <linux/errno.h> 48#include <linux/errno.h>
49#include <linux/version.h> /* for KERNEL_VERSION MACRO */ 49#include <linux/version.h> /* for KERNEL_VERSION MACRO */
50#include <linux/io.h> 50#include <linux/io.h>
51#include <linux/slab.h>
51#include <media/v4l2-device.h> 52#include <media/v4l2-device.h>
52#include <media/v4l2-ioctl.h> 53#include <media/v4l2-ioctl.h>
53 54
diff --git a/drivers/media/radio/radio-maestro.c b/drivers/media/radio/radio-maestro.c
index f8213b7c8dd..08f1051979c 100644
--- a/drivers/media/radio/radio-maestro.c
+++ b/drivers/media/radio/radio-maestro.c
@@ -26,6 +26,7 @@
26#include <linux/pci.h> 26#include <linux/pci.h>
27#include <linux/videodev2.h> 27#include <linux/videodev2.h>
28#include <linux/io.h> 28#include <linux/io.h>
29#include <linux/slab.h>
29#include <media/v4l2-device.h> 30#include <media/v4l2-device.h>
30#include <media/v4l2-ioctl.h> 31#include <media/v4l2-ioctl.h>
31 32
diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
index 44b4dbedb32..4349213b403 100644
--- a/drivers/media/radio/radio-maxiradio.c
+++ b/drivers/media/radio/radio-maxiradio.c
@@ -42,6 +42,7 @@
42#include <linux/videodev2.h> 42#include <linux/videodev2.h>
43#include <linux/version.h> /* for KERNEL_VERSION MACRO */ 43#include <linux/version.h> /* for KERNEL_VERSION MACRO */
44#include <linux/io.h> 44#include <linux/io.h>
45#include <linux/slab.h>
45#include <media/v4l2-device.h> 46#include <media/v4l2-device.h>
46#include <media/v4l2-ioctl.h> 47#include <media/v4l2-ioctl.h>
47 48
diff --git a/drivers/media/radio/radio-si4713.c b/drivers/media/radio/radio-si4713.c
index 170bbe55478..13554ab13f7 100644
--- a/drivers/media/radio/radio-si4713.c
+++ b/drivers/media/radio/radio-si4713.c
@@ -27,6 +27,7 @@
27#include <linux/platform_device.h> 27#include <linux/platform_device.h>
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <linux/videodev2.h> 29#include <linux/videodev2.h>
30#include <linux/slab.h>
30#include <media/v4l2-device.h> 31#include <media/v4l2-device.h>
31#include <media/v4l2-common.h> 32#include <media/v4l2-common.h>
32#include <media/v4l2-ioctl.h> 33#include <media/v4l2-ioctl.h>
diff --git a/drivers/media/radio/radio-tea5764.c b/drivers/media/radio/radio-tea5764.c
index 8e718bfcdad..789d2ec66e1 100644
--- a/drivers/media/radio/radio-tea5764.c
+++ b/drivers/media/radio/radio-tea5764.c
@@ -32,6 +32,7 @@
32 * add RDS support 32 * add RDS support
33 */ 33 */
34#include <linux/kernel.h> 34#include <linux/kernel.h>
35#include <linux/slab.h>
35#include <linux/module.h> 36#include <linux/module.h>
36#include <linux/init.h> /* Initdata */ 37#include <linux/init.h> /* Initdata */
37#include <linux/videodev2.h> /* kernel radio structs */ 38#include <linux/videodev2.h> /* kernel radio structs */
diff --git a/drivers/media/radio/radio-timb.c b/drivers/media/radio/radio-timb.c
index 0de457f6e6e..b8bb3ef47df 100644
--- a/drivers/media/radio/radio-timb.c
+++ b/drivers/media/radio/radio-timb.c
@@ -22,6 +22,7 @@
22#include <media/v4l2-device.h> 22#include <media/v4l2-device.h>
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/slab.h>
25#include <linux/i2c.h> 26#include <linux/i2c.h>
26#include <media/timb_radio.h> 27#include <media/timb_radio.h>
27 28
diff --git a/drivers/media/radio/saa7706h.c b/drivers/media/radio/saa7706h.c
index 5db5528a8b2..585680ffbfb 100644
--- a/drivers/media/radio/saa7706h.c
+++ b/drivers/media/radio/saa7706h.c
@@ -23,6 +23,7 @@
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/i2c.h> 25#include <linux/i2c.h>
26#include <linux/slab.h>
26#include <media/v4l2-device.h> 27#include <media/v4l2-device.h>
27#include <media/v4l2-chip-ident.h> 28#include <media/v4l2-chip-ident.h>
28 29
diff --git a/drivers/media/radio/si470x/radio-si470x-i2c.c b/drivers/media/radio/si470x/radio-si470x-i2c.c
index 5466015346a..a5844d08d8b 100644
--- a/drivers/media/radio/si470x/radio-si470x-i2c.c
+++ b/drivers/media/radio/si470x/radio-si470x-i2c.c
@@ -31,6 +31,7 @@
31 31
32/* kernel includes */ 32/* kernel includes */
33#include <linux/i2c.h> 33#include <linux/i2c.h>
34#include <linux/slab.h>
34#include <linux/delay.h> 35#include <linux/delay.h>
35#include <linux/interrupt.h> 36#include <linux/interrupt.h>
36 37
diff --git a/drivers/media/radio/si470x/radio-si470x-usb.c b/drivers/media/radio/si470x/radio-si470x-usb.c
index 6f60841828d..5ec13e50a9f 100644
--- a/drivers/media/radio/si470x/radio-si470x-usb.c
+++ b/drivers/media/radio/si470x/radio-si470x-usb.c
@@ -37,6 +37,7 @@
37/* kernel includes */ 37/* kernel includes */
38#include <linux/usb.h> 38#include <linux/usb.h>
39#include <linux/hid.h> 39#include <linux/hid.h>
40#include <linux/slab.h>
40 41
41#include "radio-si470x.h" 42#include "radio-si470x.h"
42 43
diff --git a/drivers/media/radio/si4713-i2c.c b/drivers/media/radio/si4713-i2c.c
index 6a0028eb461..ab63dd5b25c 100644
--- a/drivers/media/radio/si4713-i2c.c
+++ b/drivers/media/radio/si4713-i2c.c
@@ -26,6 +26,7 @@
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <linux/slab.h>
29#include <media/v4l2-device.h> 30#include <media/v4l2-device.h>
30#include <media/v4l2-ioctl.h> 31#include <media/v4l2-ioctl.h>
31#include <media/v4l2-common.h> 32#include <media/v4l2-common.h>
diff --git a/drivers/media/radio/tef6862.c b/drivers/media/radio/tef6862.c
index 6e607ff0c16..90cae90277e 100644
--- a/drivers/media/radio/tef6862.c
+++ b/drivers/media/radio/tef6862.c
@@ -23,6 +23,7 @@
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/i2c.h> 24#include <linux/i2c.h>
25#include <linux/i2c-id.h> 25#include <linux/i2c-id.h>
26#include <linux/slab.h>
26#include <media/v4l2-ioctl.h> 27#include <media/v4l2-ioctl.h>
27#include <media/v4l2-device.h> 28#include <media/v4l2-device.h>
28#include <media/v4l2-chip-ident.h> 29#include <media/v4l2-chip-ident.h>
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index f8fc8654693..9644cf760aa 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -361,7 +361,7 @@ config VIDEO_SAA717X
361 361
362config VIDEO_SAA7191 362config VIDEO_SAA7191
363 tristate "Philips SAA7191 video decoder" 363 tristate "Philips SAA7191 video decoder"
364 depends on VIDEO_V4L1 && I2C 364 depends on VIDEO_V4L2 && I2C
365 ---help--- 365 ---help---
366 Support for the Philips SAA7191 video decoder. 366 Support for the Philips SAA7191 video decoder.
367 367
@@ -756,7 +756,7 @@ source "drivers/media/video/saa7134/Kconfig"
756 756
757config VIDEO_MXB 757config VIDEO_MXB
758 tristate "Siemens-Nixdorf 'Multimedia eXtension Board'" 758 tristate "Siemens-Nixdorf 'Multimedia eXtension Board'"
759 depends on PCI && VIDEO_V4L1 && I2C 759 depends on PCI && VIDEO_V4L2 && I2C
760 select VIDEO_SAA7146_VV 760 select VIDEO_SAA7146_VV
761 select VIDEO_TUNER 761 select VIDEO_TUNER
762 select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO 762 select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index b88b6174a33..c51c386559f 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -160,8 +160,6 @@ obj-$(CONFIG_VIDEO_MX3) += mx3_camera.o
160obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o 160obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o
161obj-$(CONFIG_VIDEO_SH_MOBILE_CEU) += sh_mobile_ceu_camera.o 161obj-$(CONFIG_VIDEO_SH_MOBILE_CEU) += sh_mobile_ceu_camera.o
162 162
163obj-$(CONFIG_ARCH_DAVINCI) += davinci/
164
165obj-$(CONFIG_VIDEO_AU0828) += au0828/ 163obj-$(CONFIG_VIDEO_AU0828) += au0828/
166 164
167obj-$(CONFIG_USB_VIDEO_CLASS) += uvc/ 165obj-$(CONFIG_USB_VIDEO_CLASS) += uvc/
diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c
index 97b003449c9..48e89fbf391 100644
--- a/drivers/media/video/adv7170.c
+++ b/drivers/media/video/adv7170.c
@@ -30,6 +30,7 @@
30 30
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/slab.h>
33#include <linux/ioctl.h> 34#include <linux/ioctl.h>
34#include <asm/uaccess.h> 35#include <asm/uaccess.h>
35#include <linux/i2c.h> 36#include <linux/i2c.h>
diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c
index cf8c06c85de..f1ba0d742c6 100644
--- a/drivers/media/video/adv7175.c
+++ b/drivers/media/video/adv7175.c
@@ -26,6 +26,7 @@
26 26
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/types.h> 28#include <linux/types.h>
29#include <linux/slab.h>
29#include <linux/ioctl.h> 30#include <linux/ioctl.h>
30#include <asm/uaccess.h> 31#include <asm/uaccess.h>
31#include <linux/i2c.h> 32#include <linux/i2c.h>
diff --git a/drivers/media/video/adv7180.c b/drivers/media/video/adv7180.c
index 0826f0dabc1..23e610f6273 100644
--- a/drivers/media/video/adv7180.c
+++ b/drivers/media/video/adv7180.c
@@ -23,6 +23,7 @@
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/i2c.h> 24#include <linux/i2c.h>
25#include <linux/i2c-id.h> 25#include <linux/i2c-id.h>
26#include <linux/slab.h>
26#include <media/v4l2-ioctl.h> 27#include <media/v4l2-ioctl.h>
27#include <linux/videodev2.h> 28#include <linux/videodev2.h>
28#include <media/v4l2-device.h> 29#include <media/v4l2-device.h>
diff --git a/drivers/media/video/adv7343.c b/drivers/media/video/adv7343.c
index df26f2fe44e..41b2930d0ce 100644
--- a/drivers/media/video/adv7343.c
+++ b/drivers/media/video/adv7343.c
@@ -18,6 +18,7 @@
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/ctype.h> 20#include <linux/ctype.h>
21#include <linux/slab.h>
21#include <linux/i2c.h> 22#include <linux/i2c.h>
22#include <linux/device.h> 23#include <linux/device.h>
23#include <linux/delay.h> 24#include <linux/delay.h>
diff --git a/drivers/media/video/au0828/au0828-core.c b/drivers/media/video/au0828/au0828-core.c
index 3544a2f12f1..ca342e4c61f 100644
--- a/drivers/media/video/au0828/au0828-core.c
+++ b/drivers/media/video/au0828/au0828-core.c
@@ -20,6 +20,7 @@
20 */ 20 */
21 21
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/slab.h>
23#include <linux/videodev2.h> 24#include <linux/videodev2.h>
24#include <media/v4l2-common.h> 25#include <media/v4l2-common.h>
25#include <linux/mutex.h> 26#include <linux/mutex.h>
diff --git a/drivers/media/video/au0828/au0828-dvb.c b/drivers/media/video/au0828/au0828-dvb.c
index b8a4b52e8d4..f1edf1d4afe 100644
--- a/drivers/media/video/au0828/au0828-dvb.c
+++ b/drivers/media/video/au0828/au0828-dvb.c
@@ -20,6 +20,7 @@
20 */ 20 */
21 21
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/slab.h>
23#include <linux/init.h> 24#include <linux/init.h>
24#include <linux/device.h> 25#include <linux/device.h>
25#include <linux/suspend.h> 26#include <linux/suspend.h>
diff --git a/drivers/media/video/au0828/au0828-video.c b/drivers/media/video/au0828/au0828-video.c
index dc67bc40f36..8c140c01c5e 100644
--- a/drivers/media/video/au0828/au0828-video.c
+++ b/drivers/media/video/au0828/au0828-video.c
@@ -29,6 +29,7 @@
29 */ 29 */
30 30
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/slab.h>
32#include <linux/init.h> 33#include <linux/init.h>
33#include <linux/device.h> 34#include <linux/device.h>
34#include <linux/suspend.h> 35#include <linux/suspend.h>
diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c
index 547e1a93c42..770cb9accf8 100644
--- a/drivers/media/video/bt819.c
+++ b/drivers/media/video/bt819.c
@@ -35,6 +35,7 @@
35#include <linux/i2c.h> 35#include <linux/i2c.h>
36#include <linux/i2c-id.h> 36#include <linux/i2c-id.h>
37#include <linux/videodev2.h> 37#include <linux/videodev2.h>
38#include <linux/slab.h>
38#include <media/v4l2-device.h> 39#include <media/v4l2-device.h>
39#include <media/v4l2-chip-ident.h> 40#include <media/v4l2-chip-ident.h>
40#include <media/v4l2-i2c-drv.h> 41#include <media/v4l2-i2c-drv.h>
diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c
index d0b4d4925ff..ae333739250 100644
--- a/drivers/media/video/bt856.c
+++ b/drivers/media/video/bt856.c
@@ -30,6 +30,7 @@
30 30
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/slab.h>
33#include <linux/ioctl.h> 34#include <linux/ioctl.h>
34#include <asm/uaccess.h> 35#include <asm/uaccess.h>
35#include <linux/i2c.h> 36#include <linux/i2c.h>
diff --git a/drivers/media/video/bt866.c b/drivers/media/video/bt866.c
index af7e3a5bac9..62ac422bb15 100644
--- a/drivers/media/video/bt866.c
+++ b/drivers/media/video/bt866.c
@@ -30,6 +30,7 @@
30 30
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/slab.h>
33#include <linux/ioctl.h> 34#include <linux/ioctl.h>
34#include <asm/uaccess.h> 35#include <asm/uaccess.h>
35#include <linux/i2c.h> 36#include <linux/i2c.h>
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index cb46e8fa8aa..f4860f03dfc 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -37,6 +37,7 @@
37#include <linux/init.h> 37#include <linux/init.h>
38#include <linux/module.h> 38#include <linux/module.h>
39#include <linux/delay.h> 39#include <linux/delay.h>
40#include <linux/slab.h>
40#include <linux/errno.h> 41#include <linux/errno.h>
41#include <linux/fs.h> 42#include <linux/fs.h>
42#include <linux/kernel.h> 43#include <linux/kernel.h>
diff --git a/drivers/media/video/bt8xx/bttv-gpio.c b/drivers/media/video/bt8xx/bttv-gpio.c
index 74c325e594a..fd604d32bbb 100644
--- a/drivers/media/video/bt8xx/bttv-gpio.c
+++ b/drivers/media/video/bt8xx/bttv-gpio.c
@@ -30,6 +30,7 @@
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/device.h> 32#include <linux/device.h>
33#include <linux/slab.h>
33#include <asm/io.h> 34#include <asm/io.h>
34 35
35#include "bttvp.h" 36#include "bttvp.h"
diff --git a/drivers/media/video/bt8xx/bttv-input.c b/drivers/media/video/bt8xx/bttv-input.c
index b320dbd635a..aa153a986ad 100644
--- a/drivers/media/video/bt8xx/bttv-input.c
+++ b/drivers/media/video/bt8xx/bttv-input.c
@@ -23,6 +23,7 @@
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/input.h> 25#include <linux/input.h>
26#include <linux/slab.h>
26 27
27#include "bttv.h" 28#include "bttv.h"
28#include "bttvp.h" 29#include "bttvp.h"
diff --git a/drivers/media/video/bt8xx/bttv-risc.c b/drivers/media/video/bt8xx/bttv-risc.c
index d16af283637..c24b1c100e1 100644
--- a/drivers/media/video/bt8xx/bttv-risc.c
+++ b/drivers/media/video/bt8xx/bttv-risc.c
@@ -26,6 +26,7 @@
26 26
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/slab.h>
29#include <linux/pci.h> 30#include <linux/pci.h>
30#include <linux/vmalloc.h> 31#include <linux/vmalloc.h>
31#include <linux/interrupt.h> 32#include <linux/interrupt.h>
diff --git a/drivers/media/video/cafe_ccic.c b/drivers/media/video/cafe_ccic.c
index cbbf7e80d2c..be35e696582 100644
--- a/drivers/media/video/cafe_ccic.c
+++ b/drivers/media/video/cafe_ccic.c
@@ -31,6 +31,7 @@
31#include <linux/interrupt.h> 31#include <linux/interrupt.h>
32#include <linux/spinlock.h> 32#include <linux/spinlock.h>
33#include <linux/videodev2.h> 33#include <linux/videodev2.h>
34#include <linux/slab.h>
34#include <media/v4l2-device.h> 35#include <media/v4l2-device.h>
35#include <media/v4l2-ioctl.h> 36#include <media/v4l2-ioctl.h>
36#include <media/v4l2-chip-ident.h> 37#include <media/v4l2-chip-ident.h>
diff --git a/drivers/media/video/cpia_pp.c b/drivers/media/video/cpia_pp.c
index c431df8248d..f5604c16a09 100644
--- a/drivers/media/video/cpia_pp.c
+++ b/drivers/media/video/cpia_pp.c
@@ -35,6 +35,7 @@
35#include <linux/delay.h> 35#include <linux/delay.h>
36#include <linux/workqueue.h> 36#include <linux/workqueue.h>
37#include <linux/sched.h> 37#include <linux/sched.h>
38#include <linux/slab.h>
38 39
39#include <linux/kmod.h> 40#include <linux/kmod.h>
40 41
diff --git a/drivers/media/video/cs5345.c b/drivers/media/video/cs5345.c
index 57dc1704b6c..8362db509e2 100644
--- a/drivers/media/video/cs5345.c
+++ b/drivers/media/video/cs5345.c
@@ -22,6 +22,7 @@
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/i2c.h> 23#include <linux/i2c.h>
24#include <linux/videodev2.h> 24#include <linux/videodev2.h>
25#include <linux/slab.h>
25#include <media/v4l2-device.h> 26#include <media/v4l2-device.h>
26#include <media/v4l2-chip-ident.h> 27#include <media/v4l2-chip-ident.h>
27#include <media/v4l2-i2c-drv.h> 28#include <media/v4l2-i2c-drv.h>
diff --git a/drivers/media/video/cs53l32a.c b/drivers/media/video/cs53l32a.c
index 80bca8df9fb..3cc135a98d8 100644
--- a/drivers/media/video/cs53l32a.c
+++ b/drivers/media/video/cs53l32a.c
@@ -22,6 +22,7 @@
22 22
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/types.h> 24#include <linux/types.h>
25#include <linux/slab.h>
25#include <linux/ioctl.h> 26#include <linux/ioctl.h>
26#include <asm/uaccess.h> 27#include <asm/uaccess.h>
27#include <linux/i2c.h> 28#include <linux/i2c.h>
diff --git a/drivers/media/video/cx18/cx18-alsa-main.c b/drivers/media/video/cx18/cx18-alsa-main.c
index eb41d7ec65b..b5d7cbf4528 100644
--- a/drivers/media/video/cx18/cx18-alsa-main.c
+++ b/drivers/media/video/cx18/cx18-alsa-main.c
@@ -23,6 +23,7 @@
23 */ 23 */
24 24
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/slab.h>
26#include <linux/module.h> 27#include <linux/module.h>
27#include <linux/kernel.h> 28#include <linux/kernel.h>
28#include <linux/device.h> 29#include <linux/device.h>
diff --git a/drivers/media/video/cx18/cx18-controls.c b/drivers/media/video/cx18/cx18-controls.c
index 93f0dae0135..7fa589240ff 100644
--- a/drivers/media/video/cx18/cx18-controls.c
+++ b/drivers/media/video/cx18/cx18-controls.c
@@ -21,6 +21,7 @@
21 * 02111-1307 USA 21 * 02111-1307 USA
22 */ 22 */
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/slab.h>
24 25
25#include "cx18-driver.h" 26#include "cx18-driver.h"
26#include "cx18-cards.h" 27#include "cx18-cards.h"
diff --git a/drivers/media/video/cx18/cx18-driver.h b/drivers/media/video/cx18/cx18-driver.h
index 23ad6d548dc..b9728e8eee4 100644
--- a/drivers/media/video/cx18/cx18-driver.h
+++ b/drivers/media/video/cx18/cx18-driver.h
@@ -42,6 +42,7 @@
42#include <linux/pagemap.h> 42#include <linux/pagemap.h>
43#include <linux/workqueue.h> 43#include <linux/workqueue.h>
44#include <linux/mutex.h> 44#include <linux/mutex.h>
45#include <linux/slab.h>
45#include <asm/byteorder.h> 46#include <asm/byteorder.h>
46 47
47#include <linux/dvb/video.h> 48#include <linux/dvb/video.h>
diff --git a/drivers/media/video/cx231xx/cx231xx-cards.c b/drivers/media/video/cx231xx/cx231xx-cards.c
index a5490823500..6bdc0ef1811 100644
--- a/drivers/media/video/cx231xx/cx231xx-cards.c
+++ b/drivers/media/video/cx231xx/cx231xx-cards.c
@@ -22,6 +22,7 @@
22 22
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/slab.h>
25#include <linux/delay.h> 26#include <linux/delay.h>
26#include <linux/i2c.h> 27#include <linux/i2c.h>
27#include <linux/usb.h> 28#include <linux/usb.h>
diff --git a/drivers/media/video/cx231xx/cx231xx-core.c b/drivers/media/video/cx231xx/cx231xx-core.c
index 4a60dfbc347..b24eee115e7 100644
--- a/drivers/media/video/cx231xx/cx231xx-core.c
+++ b/drivers/media/video/cx231xx/cx231xx-core.c
@@ -23,6 +23,7 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/list.h> 24#include <linux/list.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/slab.h>
26#include <linux/usb.h> 27#include <linux/usb.h>
27#include <linux/vmalloc.h> 28#include <linux/vmalloc.h>
28#include <media/v4l2-common.h> 29#include <media/v4l2-common.h>
diff --git a/drivers/media/video/cx231xx/cx231xx-dvb.c b/drivers/media/video/cx231xx/cx231xx-dvb.c
index 64e025e2bdf..4ea3776b39f 100644
--- a/drivers/media/video/cx231xx/cx231xx-dvb.c
+++ b/drivers/media/video/cx231xx/cx231xx-dvb.c
@@ -20,6 +20,7 @@
20 */ 20 */
21 21
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/slab.h>
23#include <linux/usb.h> 24#include <linux/usb.h>
24 25
25#include "cx231xx.h" 26#include "cx231xx.h"
diff --git a/drivers/media/video/cx231xx/cx231xx-input.c b/drivers/media/video/cx231xx/cx231xx-input.c
index c5771db3bfc..b473cd8367f 100644
--- a/drivers/media/video/cx231xx/cx231xx-input.c
+++ b/drivers/media/video/cx231xx/cx231xx-input.c
@@ -27,6 +27,7 @@
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/input.h> 28#include <linux/input.h>
29#include <linux/usb.h> 29#include <linux/usb.h>
30#include <linux/slab.h>
30 31
31#include "cx231xx.h" 32#include "cx231xx.h"
32 33
diff --git a/drivers/media/video/cx231xx/cx231xx-vbi.c b/drivers/media/video/cx231xx/cx231xx-vbi.c
index e97b8023a65..689c5e25776 100644
--- a/drivers/media/video/cx231xx/cx231xx-vbi.c
+++ b/drivers/media/video/cx231xx/cx231xx-vbi.c
@@ -28,6 +28,7 @@
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <linux/mm.h> 29#include <linux/mm.h>
30#include <linux/mutex.h> 30#include <linux/mutex.h>
31#include <linux/slab.h>
31 32
32#include <media/v4l2-common.h> 33#include <media/v4l2-common.h>
33#include <media/v4l2-ioctl.h> 34#include <media/v4l2-ioctl.h>
diff --git a/drivers/media/video/cx231xx/cx231xx-video.c b/drivers/media/video/cx231xx/cx231xx-video.c
index d4f546f11d7..16a73eab672 100644
--- a/drivers/media/video/cx231xx/cx231xx-video.c
+++ b/drivers/media/video/cx231xx/cx231xx-video.c
@@ -32,6 +32,7 @@
32#include <linux/version.h> 32#include <linux/version.h>
33#include <linux/mm.h> 33#include <linux/mm.h>
34#include <linux/mutex.h> 34#include <linux/mutex.h>
35#include <linux/slab.h>
35 36
36#include <media/v4l2-common.h> 37#include <media/v4l2-common.h>
37#include <media/v4l2-ioctl.h> 38#include <media/v4l2-ioctl.h>
diff --git a/drivers/media/video/cx23885/cx23885-417.c b/drivers/media/video/cx23885/cx23885-417.c
index 2ab97ad7b6f..a8ddc227cf8 100644
--- a/drivers/media/video/cx23885/cx23885-417.c
+++ b/drivers/media/video/cx23885/cx23885-417.c
@@ -32,6 +32,7 @@
32#include <linux/device.h> 32#include <linux/device.h>
33#include <linux/firmware.h> 33#include <linux/firmware.h>
34#include <linux/smp_lock.h> 34#include <linux/smp_lock.h>
35#include <linux/slab.h>
35#include <media/v4l2-common.h> 36#include <media/v4l2-common.h>
36#include <media/v4l2-ioctl.h> 37#include <media/v4l2-ioctl.h>
37#include <media/cx2341x.h> 38#include <media/cx2341x.h>
diff --git a/drivers/media/video/cx23885/cx23885-input.c b/drivers/media/video/cx23885/cx23885-input.c
index 9c6620f86dc..8e9d990dbe9 100644
--- a/drivers/media/video/cx23885/cx23885-input.c
+++ b/drivers/media/video/cx23885/cx23885-input.c
@@ -36,6 +36,7 @@
36 */ 36 */
37 37
38#include <linux/input.h> 38#include <linux/input.h>
39#include <linux/slab.h>
39#include <media/ir-common.h> 40#include <media/ir-common.h>
40#include <media/v4l2-subdev.h> 41#include <media/v4l2-subdev.h>
41 42
diff --git a/drivers/media/video/cx23885/cx23885-vbi.c b/drivers/media/video/cx23885/cx23885-vbi.c
index 5b297f0323b..708a8c766d1 100644
--- a/drivers/media/video/cx23885/cx23885-vbi.c
+++ b/drivers/media/video/cx23885/cx23885-vbi.c
@@ -23,7 +23,6 @@
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/moduleparam.h> 24#include <linux/moduleparam.h>
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/slab.h>
27 26
28#include "cx23885.h" 27#include "cx23885.h"
29 28
diff --git a/drivers/media/video/cx23885/cx23885.h b/drivers/media/video/cx23885/cx23885.h
index 0e3a98d243c..8d6a55e54ee 100644
--- a/drivers/media/video/cx23885/cx23885.h
+++ b/drivers/media/video/cx23885/cx23885.h
@@ -23,6 +23,7 @@
23#include <linux/i2c.h> 23#include <linux/i2c.h>
24#include <linux/i2c-algo-bit.h> 24#include <linux/i2c-algo-bit.h>
25#include <linux/kdev_t.h> 25#include <linux/kdev_t.h>
26#include <linux/slab.h>
26 27
27#include <media/v4l2-device.h> 28#include <media/v4l2-device.h>
28#include <media/tuner.h> 29#include <media/tuner.h>
diff --git a/drivers/media/video/cx23885/cx23888-ir.c b/drivers/media/video/cx23885/cx23888-ir.c
index 2bf57a4527d..ad728d767d6 100644
--- a/drivers/media/video/cx23885/cx23888-ir.c
+++ b/drivers/media/video/cx23885/cx23888-ir.c
@@ -22,6 +22,7 @@
22 */ 22 */
23 23
24#include <linux/kfifo.h> 24#include <linux/kfifo.h>
25#include <linux/slab.h>
25 26
26#include <media/v4l2-device.h> 27#include <media/v4l2-device.h>
27#include <media/v4l2-chip-ident.h> 28#include <media/v4l2-chip-ident.h>
diff --git a/drivers/media/video/cx88/cx88-alsa.c b/drivers/media/video/cx88/cx88-alsa.c
index 64b350df78e..33082c96745 100644
--- a/drivers/media/video/cx88/cx88-alsa.c
+++ b/drivers/media/video/cx88/cx88-alsa.c
@@ -31,6 +31,7 @@
31#include <linux/vmalloc.h> 31#include <linux/vmalloc.h>
32#include <linux/dma-mapping.h> 32#include <linux/dma-mapping.h>
33#include <linux/pci.h> 33#include <linux/pci.h>
34#include <linux/slab.h>
34 35
35#include <asm/delay.h> 36#include <asm/delay.h>
36#include <sound/core.h> 37#include <sound/core.h>
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c
index 6fe30e6c426..e46e1ceef72 100644
--- a/drivers/media/video/cx88/cx88-blackbird.c
+++ b/drivers/media/video/cx88/cx88-blackbird.c
@@ -28,6 +28,7 @@
28 28
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/slab.h>
31#include <linux/fs.h> 32#include <linux/fs.h>
32#include <linux/delay.h> 33#include <linux/delay.h>
33#include <linux/device.h> 34#include <linux/device.h>
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c
index eaf0ee7de83..2918a6e38fe 100644
--- a/drivers/media/video/cx88/cx88-cards.c
+++ b/drivers/media/video/cx88/cx88-cards.c
@@ -24,6 +24,7 @@
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/pci.h> 25#include <linux/pci.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/slab.h>
27 28
28#include "cx88.h" 29#include "cx88.h"
29#include "tea5767.h" 30#include "tea5767.h"
diff --git a/drivers/media/video/cx88/cx88-dsp.c b/drivers/media/video/cx88/cx88-dsp.c
index 3e5eaf3fe2a..a94e00a4ac5 100644
--- a/drivers/media/video/cx88/cx88-dsp.c
+++ b/drivers/media/video/cx88/cx88-dsp.c
@@ -19,6 +19,7 @@
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/slab.h>
22#include <linux/kernel.h> 23#include <linux/kernel.h>
23#include <linux/module.h> 24#include <linux/module.h>
24#include <linux/jiffies.h> 25#include <linux/jiffies.h>
diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c
index de180d4d5a2..6b6abf062c2 100644
--- a/drivers/media/video/cx88/cx88-input.c
+++ b/drivers/media/video/cx88/cx88-input.c
@@ -26,6 +26,7 @@
26#include <linux/hrtimer.h> 26#include <linux/hrtimer.h>
27#include <linux/input.h> 27#include <linux/input.h>
28#include <linux/pci.h> 28#include <linux/pci.h>
29#include <linux/slab.h>
29#include <linux/module.h> 30#include <linux/module.h>
30 31
31#include "cx88.h" 32#include "cx88.h"
diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c
index 338af77f7f0..6aba7af9160 100644
--- a/drivers/media/video/cx88/cx88-mpeg.c
+++ b/drivers/media/video/cx88/cx88-mpeg.c
@@ -23,6 +23,7 @@
23 */ 23 */
24 24
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/slab.h>
26#include <linux/init.h> 27#include <linux/init.h>
27#include <linux/device.h> 28#include <linux/device.h>
28#include <linux/dma-mapping.h> 29#include <linux/dma-mapping.h>
diff --git a/drivers/media/video/cx88/cx88-tvaudio.c b/drivers/media/video/cx88/cx88-tvaudio.c
index e8316cf7f32..239631568f3 100644
--- a/drivers/media/video/cx88/cx88-tvaudio.c
+++ b/drivers/media/video/cx88/cx88-tvaudio.c
@@ -39,7 +39,6 @@
39#include <linux/errno.h> 39#include <linux/errno.h>
40#include <linux/freezer.h> 40#include <linux/freezer.h>
41#include <linux/kernel.h> 41#include <linux/kernel.h>
42#include <linux/slab.h>
43#include <linux/mm.h> 42#include <linux/mm.h>
44#include <linux/poll.h> 43#include <linux/poll.h>
45#include <linux/signal.h> 44#include <linux/signal.h>
diff --git a/drivers/media/video/cx88/cx88-vbi.c b/drivers/media/video/cx88/cx88-vbi.c
index 0943060682b..d9445b0e7ab 100644
--- a/drivers/media/video/cx88/cx88-vbi.c
+++ b/drivers/media/video/cx88/cx88-vbi.c
@@ -3,7 +3,6 @@
3#include <linux/kernel.h> 3#include <linux/kernel.h>
4#include <linux/module.h> 4#include <linux/module.h>
5#include <linux/init.h> 5#include <linux/init.h>
6#include <linux/slab.h>
7 6
8#include "cx88.h" 7#include "cx88.h"
9 8
diff --git a/drivers/media/video/cx88/cx88-vp3054-i2c.c b/drivers/media/video/cx88/cx88-vp3054-i2c.c
index 20800425c51..794f2932b75 100644
--- a/drivers/media/video/cx88/cx88-vp3054-i2c.c
+++ b/drivers/media/video/cx88/cx88-vp3054-i2c.c
@@ -23,6 +23,7 @@
23*/ 23*/
24 24
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/slab.h>
26#include <linux/init.h> 27#include <linux/init.h>
27 28
28#include <asm/io.h> 29#include <asm/io.h>
diff --git a/drivers/media/video/davinci/dm644x_ccdc.c b/drivers/media/video/davinci/dm644x_ccdc.c
index 0c394cade22..b4cc96dc99e 100644
--- a/drivers/media/video/davinci/dm644x_ccdc.c
+++ b/drivers/media/video/davinci/dm644x_ccdc.c
@@ -37,6 +37,7 @@
37#include <linux/platform_device.h> 37#include <linux/platform_device.h>
38#include <linux/uaccess.h> 38#include <linux/uaccess.h>
39#include <linux/videodev2.h> 39#include <linux/videodev2.h>
40#include <linux/gfp.h>
40#include <linux/clk.h> 41#include <linux/clk.h>
41#include <linux/err.h> 42#include <linux/err.h>
42 43
diff --git a/drivers/media/video/davinci/vpfe_capture.c b/drivers/media/video/davinci/vpfe_capture.c
index 885cd54499c..398dbe71cb8 100644
--- a/drivers/media/video/davinci/vpfe_capture.c
+++ b/drivers/media/video/davinci/vpfe_capture.c
@@ -67,6 +67,7 @@
67 * - Support for control ioctls 67 * - Support for control ioctls
68 */ 68 */
69#include <linux/module.h> 69#include <linux/module.h>
70#include <linux/slab.h>
70#include <linux/init.h> 71#include <linux/init.h>
71#include <linux/platform_device.h> 72#include <linux/platform_device.h>
72#include <linux/interrupt.h> 73#include <linux/interrupt.h>
@@ -222,7 +223,6 @@ int vpfe_register_ccdc_device(struct ccdc_hw_device *dev)
222 BUG_ON(!dev->hw_ops.get_frame_format); 223 BUG_ON(!dev->hw_ops.get_frame_format);
223 BUG_ON(!dev->hw_ops.get_pixel_format); 224 BUG_ON(!dev->hw_ops.get_pixel_format);
224 BUG_ON(!dev->hw_ops.set_pixel_format); 225 BUG_ON(!dev->hw_ops.set_pixel_format);
225 BUG_ON(!dev->hw_ops.set_params);
226 BUG_ON(!dev->hw_ops.set_image_window); 226 BUG_ON(!dev->hw_ops.set_image_window);
227 BUG_ON(!dev->hw_ops.get_image_window); 227 BUG_ON(!dev->hw_ops.get_image_window);
228 BUG_ON(!dev->hw_ops.get_line_length); 228 BUG_ON(!dev->hw_ops.get_line_length);
@@ -1688,11 +1688,12 @@ static long vpfe_param_handler(struct file *file, void *priv,
1688 struct vpfe_device *vpfe_dev = video_drvdata(file); 1688 struct vpfe_device *vpfe_dev = video_drvdata(file);
1689 int ret = 0; 1689 int ret = 0;
1690 1690
1691 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_param_handler\n"); 1691 v4l2_dbg(2, debug, &vpfe_dev->v4l2_dev, "vpfe_param_handler\n");
1692 1692
1693 if (vpfe_dev->started) { 1693 if (vpfe_dev->started) {
1694 /* only allowed if streaming is not started */ 1694 /* only allowed if streaming is not started */
1695 v4l2_err(&vpfe_dev->v4l2_dev, "device already started\n"); 1695 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
1696 "device already started\n");
1696 return -EBUSY; 1697 return -EBUSY;
1697 } 1698 }
1698 1699
@@ -1704,16 +1705,23 @@ static long vpfe_param_handler(struct file *file, void *priv,
1704 case VPFE_CMD_S_CCDC_RAW_PARAMS: 1705 case VPFE_CMD_S_CCDC_RAW_PARAMS:
1705 v4l2_warn(&vpfe_dev->v4l2_dev, 1706 v4l2_warn(&vpfe_dev->v4l2_dev,
1706 "VPFE_CMD_S_CCDC_RAW_PARAMS: experimental ioctl\n"); 1707 "VPFE_CMD_S_CCDC_RAW_PARAMS: experimental ioctl\n");
1707 ret = ccdc_dev->hw_ops.set_params(param); 1708 if (ccdc_dev->hw_ops.set_params) {
1708 if (ret) { 1709 ret = ccdc_dev->hw_ops.set_params(param);
1709 v4l2_err(&vpfe_dev->v4l2_dev, 1710 if (ret) {
1710 "Error in setting parameters in CCDC\n"); 1711 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
1711 goto unlock_out; 1712 "Error setting parameters in CCDC\n");
1712 } 1713 goto unlock_out;
1713 if (vpfe_get_ccdc_image_format(vpfe_dev, &vpfe_dev->fmt) < 0) { 1714 }
1714 v4l2_err(&vpfe_dev->v4l2_dev, 1715 if (vpfe_get_ccdc_image_format(vpfe_dev,
1715 "Invalid image format at CCDC\n"); 1716 &vpfe_dev->fmt) < 0) {
1716 goto unlock_out; 1717 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
1718 "Invalid image format at CCDC\n");
1719 goto unlock_out;
1720 }
1721 } else {
1722 ret = -EINVAL;
1723 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
1724 "VPFE_CMD_S_CCDC_RAW_PARAMS not supported\n");
1717 } 1725 }
1718 break; 1726 break;
1719 default: 1727 default:
@@ -1829,7 +1837,7 @@ static __init int vpfe_probe(struct platform_device *pdev)
1829 if (NULL == ccdc_cfg) { 1837 if (NULL == ccdc_cfg) {
1830 v4l2_err(pdev->dev.driver, 1838 v4l2_err(pdev->dev.driver,
1831 "Memory allocation failed for ccdc_cfg\n"); 1839 "Memory allocation failed for ccdc_cfg\n");
1832 goto probe_free_dev_mem; 1840 goto probe_free_lock;
1833 } 1841 }
1834 1842
1835 strncpy(ccdc_cfg->name, vpfe_cfg->ccdc, 32); 1843 strncpy(ccdc_cfg->name, vpfe_cfg->ccdc, 32);
@@ -1981,8 +1989,9 @@ probe_out_video_release:
1981probe_out_release_irq: 1989probe_out_release_irq:
1982 free_irq(vpfe_dev->ccdc_irq0, vpfe_dev); 1990 free_irq(vpfe_dev->ccdc_irq0, vpfe_dev);
1983probe_free_ccdc_cfg_mem: 1991probe_free_ccdc_cfg_mem:
1984 mutex_unlock(&ccdc_lock);
1985 kfree(ccdc_cfg); 1992 kfree(ccdc_cfg);
1993probe_free_lock:
1994 mutex_unlock(&ccdc_lock);
1986probe_free_dev_mem: 1995probe_free_dev_mem:
1987 kfree(vpfe_dev); 1996 kfree(vpfe_dev);
1988 return ret; 1997 return ret;
diff --git a/drivers/media/video/davinci/vpif_capture.c b/drivers/media/video/davinci/vpif_capture.c
index 78130721f57..2e5a7fb2d0c 100644
--- a/drivers/media/video/davinci/vpif_capture.c
+++ b/drivers/media/video/davinci/vpif_capture.c
@@ -34,6 +34,7 @@
34#include <linux/platform_device.h> 34#include <linux/platform_device.h>
35#include <linux/io.h> 35#include <linux/io.h>
36#include <linux/version.h> 36#include <linux/version.h>
37#include <linux/slab.h>
37#include <media/v4l2-device.h> 38#include <media/v4l2-device.h>
38#include <media/v4l2-ioctl.h> 39#include <media/v4l2-ioctl.h>
39 40
diff --git a/drivers/media/video/davinci/vpif_display.c b/drivers/media/video/davinci/vpif_display.c
index dfddef7228d..13c3a1b9776 100644
--- a/drivers/media/video/davinci/vpif_display.c
+++ b/drivers/media/video/davinci/vpif_display.c
@@ -30,6 +30,7 @@
30#include <linux/platform_device.h> 30#include <linux/platform_device.h>
31#include <linux/io.h> 31#include <linux/io.h>
32#include <linux/version.h> 32#include <linux/version.h>
33#include <linux/slab.h>
33 34
34#include <asm/irq.h> 35#include <asm/irq.h>
35#include <asm/page.h> 36#include <asm/page.h>
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index ecbcefb0873..b0fb0833771 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -24,6 +24,7 @@
24 24
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/slab.h>
27#include <linux/delay.h> 28#include <linux/delay.h>
28#include <linux/i2c.h> 29#include <linux/i2c.h>
29#include <linux/usb.h> 30#include <linux/usb.h>
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c
index 5a37eccbd7d..a41cc556677 100644
--- a/drivers/media/video/em28xx/em28xx-core.c
+++ b/drivers/media/video/em28xx/em28xx-core.c
@@ -24,6 +24,7 @@
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/list.h> 25#include <linux/list.h>
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/slab.h>
27#include <linux/usb.h> 28#include <linux/usb.h>
28#include <linux/vmalloc.h> 29#include <linux/vmalloc.h>
29#include <media/v4l2-common.h> 30#include <media/v4l2-common.h>
diff --git a/drivers/media/video/em28xx/em28xx-dvb.c b/drivers/media/video/em28xx/em28xx-dvb.c
index 1b96356b3ab..bcd3c371009 100644
--- a/drivers/media/video/em28xx/em28xx-dvb.c
+++ b/drivers/media/video/em28xx/em28xx-dvb.c
@@ -20,6 +20,7 @@
20 */ 20 */
21 21
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/slab.h>
23#include <linux/usb.h> 24#include <linux/usb.h>
24 25
25#include "em28xx.h" 26#include "em28xx.h"
diff --git a/drivers/media/video/em28xx/em28xx-input.c b/drivers/media/video/em28xx/em28xx-input.c
index 1fb754e2087..20a0001e888 100644
--- a/drivers/media/video/em28xx/em28xx-input.c
+++ b/drivers/media/video/em28xx/em28xx-input.c
@@ -27,6 +27,7 @@
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/input.h> 28#include <linux/input.h>
29#include <linux/usb.h> 29#include <linux/usb.h>
30#include <linux/slab.h>
30 31
31#include "em28xx.h" 32#include "em28xx.h"
32 33
diff --git a/drivers/media/video/em28xx/em28xx-vbi.c b/drivers/media/video/em28xx/em28xx-vbi.c
index c7dce39823d..7f1c4a2173b 100644
--- a/drivers/media/video/em28xx/em28xx-vbi.c
+++ b/drivers/media/video/em28xx/em28xx-vbi.c
@@ -24,7 +24,6 @@
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/slab.h>
28 27
29#include "em28xx.h" 28#include "em28xx.h"
30 29
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index ac2bd935927..0fe20110bfd 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -35,6 +35,7 @@
35#include <linux/version.h> 35#include <linux/version.h>
36#include <linux/mm.h> 36#include <linux/mm.h>
37#include <linux/mutex.h> 37#include <linux/mutex.h>
38#include <linux/slab.h>
38 39
39#include "em28xx.h" 40#include "em28xx.h"
40#include <media/v4l2-common.h> 41#include <media/v4l2-common.h>
diff --git a/drivers/media/video/gspca/gspca.h b/drivers/media/video/gspca/gspca.h
index 02c696a22be..8bb242fb79d 100644
--- a/drivers/media/video/gspca/gspca.h
+++ b/drivers/media/video/gspca/gspca.h
@@ -7,6 +7,7 @@
7#include <linux/videodev2.h> 7#include <linux/videodev2.h>
8#include <media/v4l2-common.h> 8#include <media/v4l2-common.h>
9#include <linux/mutex.h> 9#include <linux/mutex.h>
10#include <linux/slab.h>
10 11
11/* compilation option */ 12/* compilation option */
12#define GSPCA_DEBUG 1 13#define GSPCA_DEBUG 1
diff --git a/drivers/media/video/gspca/jeilinj.c b/drivers/media/video/gspca/jeilinj.c
index 2019b04f923..84ecd56c647 100644
--- a/drivers/media/video/gspca/jeilinj.c
+++ b/drivers/media/video/gspca/jeilinj.c
@@ -24,6 +24,7 @@
24#define MODULE_NAME "jeilinj" 24#define MODULE_NAME "jeilinj"
25 25
26#include <linux/workqueue.h> 26#include <linux/workqueue.h>
27#include <linux/slab.h>
27#include "gspca.h" 28#include "gspca.h"
28#include "jpeg.h" 29#include "jpeg.h"
29 30
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k83a.c b/drivers/media/video/gspca/m5602/m5602_s5k83a.c
index fbd91545497..6b3be4fa2c0 100644
--- a/drivers/media/video/gspca/m5602/m5602_s5k83a.c
+++ b/drivers/media/video/gspca/m5602/m5602_s5k83a.c
@@ -17,6 +17,7 @@
17 */ 17 */
18 18
19#include <linux/kthread.h> 19#include <linux/kthread.h>
20#include <linux/slab.h>
20#include "m5602_s5k83a.h" 21#include "m5602_s5k83a.h"
21 22
22static int s5k83a_set_gain(struct gspca_dev *gspca_dev, __s32 val); 23static int s5k83a_set_gain(struct gspca_dev *gspca_dev, __s32 val);
diff --git a/drivers/media/video/gspca/sn9c20x.c b/drivers/media/video/gspca/sn9c20x.c
index 4a1bc08f82b..3dee3e5844b 100644
--- a/drivers/media/video/gspca/sn9c20x.c
+++ b/drivers/media/video/gspca/sn9c20x.c
@@ -23,6 +23,7 @@
23#include <linux/freezer.h> 23#include <linux/freezer.h>
24#include <linux/usb/input.h> 24#include <linux/usb/input.h>
25#include <linux/input.h> 25#include <linux/input.h>
26#include <linux/slab.h>
26#endif 27#endif
27 28
28#include "gspca.h" 29#include "gspca.h"
@@ -1426,7 +1427,7 @@ static int input_kthread(void *data)
1426 struct gspca_dev *gspca_dev = (struct gspca_dev *)data; 1427 struct gspca_dev *gspca_dev = (struct gspca_dev *)data;
1427 struct sd *sd = (struct sd *) gspca_dev; 1428 struct sd *sd = (struct sd *) gspca_dev;
1428 1429
1429 DECLARE_WAIT_QUEUE_HEAD(wait); 1430 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wait);
1430 set_freezable(); 1431 set_freezable();
1431 for (;;) { 1432 for (;;) {
1432 if (kthread_should_stop()) 1433 if (kthread_should_stop())
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c
index 83d5773d462..1d61b92f6bf 100644
--- a/drivers/media/video/gspca/sonixj.c
+++ b/drivers/media/video/gspca/sonixj.c
@@ -22,6 +22,7 @@
22#define MODULE_NAME "sonixj" 22#define MODULE_NAME "sonixj"
23 23
24#include <linux/input.h> 24#include <linux/input.h>
25#include <linux/slab.h>
25#include "gspca.h" 26#include "gspca.h"
26#include "jpeg.h" 27#include "jpeg.h"
27 28
diff --git a/drivers/media/video/gspca/spca508.c b/drivers/media/video/gspca/spca508.c
index 15b2eef8a3f..edf0fe15750 100644
--- a/drivers/media/video/gspca/spca508.c
+++ b/drivers/media/video/gspca/spca508.c
@@ -1513,7 +1513,6 @@ static const struct sd_desc sd_desc = {
1513static const __devinitdata struct usb_device_id device_table[] = { 1513static const __devinitdata struct usb_device_id device_table[] = {
1514 {USB_DEVICE(0x0130, 0x0130), .driver_info = HamaUSBSightcam}, 1514 {USB_DEVICE(0x0130, 0x0130), .driver_info = HamaUSBSightcam},
1515 {USB_DEVICE(0x041e, 0x4018), .driver_info = CreativeVista}, 1515 {USB_DEVICE(0x041e, 0x4018), .driver_info = CreativeVista},
1516 {USB_DEVICE(0x0461, 0x0815), .driver_info = MicroInnovationIC200},
1517 {USB_DEVICE(0x0733, 0x0110), .driver_info = ViewQuestVQ110}, 1516 {USB_DEVICE(0x0733, 0x0110), .driver_info = ViewQuestVQ110},
1518 {USB_DEVICE(0x0af9, 0x0010), .driver_info = HamaUSBSightcam}, 1517 {USB_DEVICE(0x0af9, 0x0010), .driver_info = HamaUSBSightcam},
1519 {USB_DEVICE(0x0af9, 0x0011), .driver_info = HamaUSBSightcam2}, 1518 {USB_DEVICE(0x0af9, 0x0011), .driver_info = HamaUSBSightcam2},
diff --git a/drivers/media/video/gspca/spca561.c b/drivers/media/video/gspca/spca561.c
index dc7f2b0fbc7..b9c80e2103b 100644
--- a/drivers/media/video/gspca/spca561.c
+++ b/drivers/media/video/gspca/spca561.c
@@ -1053,6 +1053,7 @@ static const __devinitdata struct usb_device_id device_table[] = {
1053 {USB_DEVICE(0x041e, 0x401a), .driver_info = Rev072A}, 1053 {USB_DEVICE(0x041e, 0x401a), .driver_info = Rev072A},
1054 {USB_DEVICE(0x041e, 0x403b), .driver_info = Rev012A}, 1054 {USB_DEVICE(0x041e, 0x403b), .driver_info = Rev012A},
1055 {USB_DEVICE(0x0458, 0x7004), .driver_info = Rev072A}, 1055 {USB_DEVICE(0x0458, 0x7004), .driver_info = Rev072A},
1056 {USB_DEVICE(0x0461, 0x0815), .driver_info = Rev072A},
1056 {USB_DEVICE(0x046d, 0x0928), .driver_info = Rev012A}, 1057 {USB_DEVICE(0x046d, 0x0928), .driver_info = Rev012A},
1057 {USB_DEVICE(0x046d, 0x0929), .driver_info = Rev012A}, 1058 {USB_DEVICE(0x046d, 0x0929), .driver_info = Rev012A},
1058 {USB_DEVICE(0x046d, 0x092a), .driver_info = Rev012A}, 1059 {USB_DEVICE(0x046d, 0x092a), .driver_info = Rev012A},
diff --git a/drivers/media/video/gspca/sq905.c b/drivers/media/video/gspca/sq905.c
index 1fcaca6a87f..09b3f93fa4d 100644
--- a/drivers/media/video/gspca/sq905.c
+++ b/drivers/media/video/gspca/sq905.c
@@ -36,6 +36,7 @@
36#define MODULE_NAME "sq905" 36#define MODULE_NAME "sq905"
37 37
38#include <linux/workqueue.h> 38#include <linux/workqueue.h>
39#include <linux/slab.h>
39#include "gspca.h" 40#include "gspca.h"
40 41
41MODULE_AUTHOR("Adam Baker <linux@baker-net.org.uk>, " 42MODULE_AUTHOR("Adam Baker <linux@baker-net.org.uk>, "
diff --git a/drivers/media/video/gspca/sq905c.c b/drivers/media/video/gspca/sq905c.c
index e6466205299..4c70628ca61 100644
--- a/drivers/media/video/gspca/sq905c.c
+++ b/drivers/media/video/gspca/sq905c.c
@@ -30,6 +30,7 @@
30#define MODULE_NAME "sq905c" 30#define MODULE_NAME "sq905c"
31 31
32#include <linux/workqueue.h> 32#include <linux/workqueue.h>
33#include <linux/slab.h>
33#include "gspca.h" 34#include "gspca.h"
34 35
35MODULE_AUTHOR("Theodore Kilgore <kilgota@auburn.edu>"); 36MODULE_AUTHOR("Theodore Kilgore <kilgota@auburn.edu>");
diff --git a/drivers/media/video/gspca/stv06xx/stv06xx.c b/drivers/media/video/gspca/stv06xx/stv06xx.c
index af73da34c83..14f179a1948 100644
--- a/drivers/media/video/gspca/stv06xx/stv06xx.c
+++ b/drivers/media/video/gspca/stv06xx/stv06xx.c
@@ -524,8 +524,6 @@ static const __devinitdata struct usb_device_id device_table[] = {
524 {USB_DEVICE(0x046D, 0x08F5), .driver_info = BRIDGE_ST6422 }, 524 {USB_DEVICE(0x046D, 0x08F5), .driver_info = BRIDGE_ST6422 },
525 /* QuickCam Messenger (new) */ 525 /* QuickCam Messenger (new) */
526 {USB_DEVICE(0x046D, 0x08F6), .driver_info = BRIDGE_ST6422 }, 526 {USB_DEVICE(0x046D, 0x08F6), .driver_info = BRIDGE_ST6422 },
527 /* QuickCam Messenger (new) */
528 {USB_DEVICE(0x046D, 0x08DA), .driver_info = BRIDGE_ST6422 },
529 {} 527 {}
530}; 528};
531MODULE_DEVICE_TABLE(usb, device_table); 529MODULE_DEVICE_TABLE(usb, device_table);
diff --git a/drivers/media/video/gspca/zc3xx.c b/drivers/media/video/gspca/zc3xx.c
index 50986da3d91..7d7814c43f9 100644
--- a/drivers/media/video/gspca/zc3xx.c
+++ b/drivers/media/video/gspca/zc3xx.c
@@ -22,6 +22,7 @@
22#define MODULE_NAME "zc3xx" 22#define MODULE_NAME "zc3xx"
23 23
24#include <linux/input.h> 24#include <linux/input.h>
25#include <linux/slab.h>
25#include "gspca.h" 26#include "gspca.h"
26#include "jpeg.h" 27#include "jpeg.h"
27 28
diff --git a/drivers/media/video/hdpvr/hdpvr-i2c.c b/drivers/media/video/hdpvr/hdpvr-i2c.c
index 296330a0e1e..463b81bef6e 100644
--- a/drivers/media/video/hdpvr/hdpvr-i2c.c
+++ b/drivers/media/video/hdpvr/hdpvr-i2c.c
@@ -11,6 +11,7 @@
11 */ 11 */
12 12
13#include <linux/i2c.h> 13#include <linux/i2c.h>
14#include <linux/slab.h>
14 15
15#include "hdpvr.h" 16#include "hdpvr.h"
16 17
diff --git a/drivers/media/video/hexium_gemini.c b/drivers/media/video/hexium_gemini.c
index e620a3a92f2..ad2c232baa6 100644
--- a/drivers/media/video/hexium_gemini.c
+++ b/drivers/media/video/hexium_gemini.c
@@ -356,9 +356,6 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_d
356 356
357 DEB_EE((".\n")); 357 DEB_EE((".\n"));
358 358
359 ret = saa7146_vv_devinit(dev);
360 if (ret)
361 return ret;
362 hexium = kzalloc(sizeof(struct hexium), GFP_KERNEL); 359 hexium = kzalloc(sizeof(struct hexium), GFP_KERNEL);
363 if (NULL == hexium) { 360 if (NULL == hexium) {
364 printk("hexium_gemini: not enough kernel memory in hexium_attach().\n"); 361 printk("hexium_gemini: not enough kernel memory in hexium_attach().\n");
diff --git a/drivers/media/video/hexium_orion.c b/drivers/media/video/hexium_orion.c
index fe596a1c12a..938a1f8f880 100644
--- a/drivers/media/video/hexium_orion.c
+++ b/drivers/media/video/hexium_orion.c
@@ -216,10 +216,6 @@ static int hexium_probe(struct saa7146_dev *dev)
216 return -EFAULT; 216 return -EFAULT;
217 } 217 }
218 218
219 err = saa7146_vv_devinit(dev);
220 if (err)
221 return err;
222
223 hexium = kzalloc(sizeof(struct hexium), GFP_KERNEL); 219 hexium = kzalloc(sizeof(struct hexium), GFP_KERNEL);
224 if (NULL == hexium) { 220 if (NULL == hexium) {
225 printk("hexium_orion: hexium_probe: not enough kernel memory.\n"); 221 printk("hexium_orion: hexium_probe: not enough kernel memory.\n");
diff --git a/drivers/media/video/ivtv/ivtv-controls.c b/drivers/media/video/ivtv/ivtv-controls.c
index 4a9c8ce0ecb..b59475bfc24 100644
--- a/drivers/media/video/ivtv/ivtv-controls.c
+++ b/drivers/media/video/ivtv/ivtv-controls.c
@@ -18,6 +18,7 @@
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20#include <linux/kernel.h> 20#include <linux/kernel.h>
21#include <linux/slab.h>
21 22
22#include "ivtv-driver.h" 23#include "ivtv-driver.h"
23#include "ivtv-cards.h" 24#include "ivtv-cards.h"
diff --git a/drivers/media/video/ivtv/ivtv-driver.h b/drivers/media/video/ivtv/ivtv-driver.h
index e4816da6482..5028e31c564 100644
--- a/drivers/media/video/ivtv/ivtv-driver.h
+++ b/drivers/media/video/ivtv/ivtv-driver.h
@@ -53,6 +53,7 @@
53#include <linux/scatterlist.h> 53#include <linux/scatterlist.h>
54#include <linux/workqueue.h> 54#include <linux/workqueue.h>
55#include <linux/mutex.h> 55#include <linux/mutex.h>
56#include <linux/slab.h>
56#include <asm/uaccess.h> 57#include <asm/uaccess.h>
57#include <asm/system.h> 58#include <asm/system.h>
58#include <asm/byteorder.h> 59#include <asm/byteorder.h>
diff --git a/drivers/media/video/ivtv/ivtvfb.c b/drivers/media/video/ivtv/ivtvfb.c
index fa6bb85cb4b..de2ff1c6ac3 100644
--- a/drivers/media/video/ivtv/ivtvfb.c
+++ b/drivers/media/video/ivtv/ivtvfb.c
@@ -42,6 +42,7 @@
42#include <linux/kernel.h> 42#include <linux/kernel.h>
43#include <linux/fb.h> 43#include <linux/fb.h>
44#include <linux/ivtvfb.h> 44#include <linux/ivtvfb.h>
45#include <linux/slab.h>
45 46
46#ifdef CONFIG_MTRR 47#ifdef CONFIG_MTRR
47#include <asm/mtrr.h> 48#include <asm/mtrr.h>
diff --git a/drivers/media/video/ks0127.c b/drivers/media/video/ks0127.c
index fab8e0254bb..94734828053 100644
--- a/drivers/media/video/ks0127.c
+++ b/drivers/media/video/ks0127.c
@@ -40,6 +40,7 @@
40#include <linux/kernel.h> 40#include <linux/kernel.h>
41#include <linux/i2c.h> 41#include <linux/i2c.h>
42#include <linux/videodev2.h> 42#include <linux/videodev2.h>
43#include <linux/slab.h>
43#include <media/v4l2-device.h> 44#include <media/v4l2-device.h>
44#include <media/v4l2-chip-ident.h> 45#include <media/v4l2-chip-ident.h>
45#include <media/v4l2-i2c-drv.h> 46#include <media/v4l2-i2c-drv.h>
diff --git a/drivers/media/video/m52790.c b/drivers/media/video/m52790.c
index d7317e798cc..4491d018eba 100644
--- a/drivers/media/video/m52790.c
+++ b/drivers/media/video/m52790.c
@@ -22,6 +22,7 @@
22 22
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/types.h> 24#include <linux/types.h>
25#include <linux/slab.h>
25#include <linux/ioctl.h> 26#include <linux/ioctl.h>
26#include <asm/uaccess.h> 27#include <asm/uaccess.h>
27#include <linux/i2c.h> 28#include <linux/i2c.h>
diff --git a/drivers/media/video/meye.c b/drivers/media/video/meye.c
index b421858ccf9..4404e5ef818 100644
--- a/drivers/media/video/meye.c
+++ b/drivers/media/video/meye.c
@@ -31,6 +31,7 @@
31#include <linux/sched.h> 31#include <linux/sched.h>
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/videodev.h> 33#include <linux/videodev.h>
34#include <linux/gfp.h>
34#include <media/v4l2-common.h> 35#include <media/v4l2-common.h>
35#include <media/v4l2-ioctl.h> 36#include <media/v4l2-ioctl.h>
36#include <asm/uaccess.h> 37#include <asm/uaccess.h>
diff --git a/drivers/media/video/msp3400-kthreads.c b/drivers/media/video/msp3400-kthreads.c
index 168bca70361..d5a69c5ee5e 100644
--- a/drivers/media/video/msp3400-kthreads.c
+++ b/drivers/media/video/msp3400-kthreads.c
@@ -22,7 +22,6 @@
22 22
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/slab.h>
26#include <linux/i2c.h> 25#include <linux/i2c.h>
27#include <linux/freezer.h> 26#include <linux/freezer.h>
28#include <linux/videodev2.h> 27#include <linux/videodev2.h>
diff --git a/drivers/media/video/mt9v011.c b/drivers/media/video/mt9v011.c
index cc85f77a570..72e55be0b4a 100644
--- a/drivers/media/video/mt9v011.c
+++ b/drivers/media/video/mt9v011.c
@@ -6,6 +6,7 @@
6 */ 6 */
7 7
8#include <linux/i2c.h> 8#include <linux/i2c.h>
9#include <linux/slab.h>
9#include <linux/videodev2.h> 10#include <linux/videodev2.h>
10#include <linux/delay.h> 11#include <linux/delay.h>
11#include <asm/div64.h> 12#include <asm/div64.h>
diff --git a/drivers/media/video/mx1_camera.c b/drivers/media/video/mx1_camera.c
index c167cc3de49..34a66019190 100644
--- a/drivers/media/video/mx1_camera.c
+++ b/drivers/media/video/mx1_camera.c
@@ -29,6 +29,7 @@
29#include <linux/mutex.h> 29#include <linux/mutex.h>
30#include <linux/platform_device.h> 30#include <linux/platform_device.h>
31#include <linux/sched.h> 31#include <linux/sched.h>
32#include <linux/slab.h>
32#include <linux/time.h> 33#include <linux/time.h>
33#include <linux/version.h> 34#include <linux/version.h>
34#include <linux/videodev2.h> 35#include <linux/videodev2.h>
@@ -48,8 +49,6 @@
48/* 49/*
49 * CSI registers 50 * CSI registers
50 */ 51 */
51#define DMA_CCR(x) (0x8c + ((x) << 6)) /* Control Registers */
52#define DMA_DIMR 0x08 /* Interrupt mask Register */
53#define CSICR1 0x00 /* CSI Control Register 1 */ 52#define CSICR1 0x00 /* CSI Control Register 1 */
54#define CSISR 0x08 /* CSI Status Register */ 53#define CSISR 0x08 /* CSI Status Register */
55#define CSIRXR 0x10 /* CSI RxFIFO Register */ 54#define CSIRXR 0x10 /* CSI RxFIFO Register */
@@ -783,7 +782,7 @@ static int __init mx1_camera_probe(struct platform_device *pdev)
783 pcdev); 782 pcdev);
784 783
785 imx_dma_config_channel(pcdev->dma_chan, IMX_DMA_TYPE_FIFO, 784 imx_dma_config_channel(pcdev->dma_chan, IMX_DMA_TYPE_FIFO,
786 IMX_DMA_MEMSIZE_32, DMA_REQ_CSI_R, 0); 785 IMX_DMA_MEMSIZE_32, MX1_DMA_REQ_CSI_R, 0);
787 /* burst length : 16 words = 64 bytes */ 786 /* burst length : 16 words = 64 bytes */
788 imx_dma_config_burstlen(pcdev->dma_chan, 0); 787 imx_dma_config_burstlen(pcdev->dma_chan, 0);
789 788
@@ -797,8 +796,8 @@ static int __init mx1_camera_probe(struct platform_device *pdev)
797 set_fiq_handler(&mx1_camera_sof_fiq_start, &mx1_camera_sof_fiq_end - 796 set_fiq_handler(&mx1_camera_sof_fiq_start, &mx1_camera_sof_fiq_end -
798 &mx1_camera_sof_fiq_start); 797 &mx1_camera_sof_fiq_start);
799 798
800 regs.ARM_r8 = DMA_BASE + DMA_DIMR; 799 regs.ARM_r8 = (long)MX1_DMA_DIMR;
801 regs.ARM_r9 = DMA_BASE + DMA_CCR(pcdev->dma_chan); 800 regs.ARM_r9 = (long)MX1_DMA_CCR(pcdev->dma_chan);
802 regs.ARM_r10 = (long)pcdev->base + CSICR1; 801 regs.ARM_r10 = (long)pcdev->base + CSICR1;
803 regs.ARM_fp = (long)pcdev->base + CSISR; 802 regs.ARM_fp = (long)pcdev->base + CSISR;
804 regs.ARM_sp = 1 << pcdev->dma_chan; 803 regs.ARM_sp = 1 << pcdev->dma_chan;
diff --git a/drivers/media/video/mxb.c b/drivers/media/video/mxb.c
index 9f01f14e4aa..ef0c8178f25 100644
--- a/drivers/media/video/mxb.c
+++ b/drivers/media/video/mxb.c
@@ -169,11 +169,7 @@ static struct saa7146_extension extension;
169static int mxb_probe(struct saa7146_dev *dev) 169static int mxb_probe(struct saa7146_dev *dev)
170{ 170{
171 struct mxb *mxb = NULL; 171 struct mxb *mxb = NULL;
172 int err;
173 172
174 err = saa7146_vv_devinit(dev);
175 if (err)
176 return err;
177 mxb = kzalloc(sizeof(struct mxb), GFP_KERNEL); 173 mxb = kzalloc(sizeof(struct mxb), GFP_KERNEL);
178 if (mxb == NULL) { 174 if (mxb == NULL) {
179 DEB_D(("not enough kernel memory.\n")); 175 DEB_D(("not enough kernel memory.\n"));
@@ -699,14 +695,17 @@ static struct saa7146_ext_vv vv_data;
699/* this function only gets called when the probing was successful */ 695/* this function only gets called when the probing was successful */
700static int mxb_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_data *info) 696static int mxb_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_data *info)
701{ 697{
702 struct mxb *mxb = (struct mxb *)dev->ext_priv; 698 struct mxb *mxb;
703 699
704 DEB_EE(("dev:%p\n", dev)); 700 DEB_EE(("dev:%p\n", dev));
705 701
706 /* checking for i2c-devices can be omitted here, because we
707 already did this in "mxb_vl42_probe" */
708
709 saa7146_vv_init(dev, &vv_data); 702 saa7146_vv_init(dev, &vv_data);
703 if (mxb_probe(dev)) {
704 saa7146_vv_release(dev);
705 return -1;
706 }
707 mxb = (struct mxb *)dev->ext_priv;
708
710 vv_data.ops.vidioc_queryctrl = vidioc_queryctrl; 709 vv_data.ops.vidioc_queryctrl = vidioc_queryctrl;
711 vv_data.ops.vidioc_g_ctrl = vidioc_g_ctrl; 710 vv_data.ops.vidioc_g_ctrl = vidioc_g_ctrl;
712 vv_data.ops.vidioc_s_ctrl = vidioc_s_ctrl; 711 vv_data.ops.vidioc_s_ctrl = vidioc_s_ctrl;
@@ -726,6 +725,7 @@ static int mxb_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_data
726 vv_data.ops.vidioc_default = vidioc_default; 725 vv_data.ops.vidioc_default = vidioc_default;
727 if (saa7146_register_device(&mxb->video_dev, dev, "mxb", VFL_TYPE_GRABBER)) { 726 if (saa7146_register_device(&mxb->video_dev, dev, "mxb", VFL_TYPE_GRABBER)) {
728 ERR(("cannot register capture v4l2 device. skipping.\n")); 727 ERR(("cannot register capture v4l2 device. skipping.\n"));
728 saa7146_vv_release(dev);
729 return -1; 729 return -1;
730 } 730 }
731 731
@@ -846,7 +846,6 @@ static struct saa7146_extension extension = {
846 .pci_tbl = &pci_tbl[0], 846 .pci_tbl = &pci_tbl[0],
847 .module = THIS_MODULE, 847 .module = THIS_MODULE,
848 848
849 .probe = mxb_probe,
850 .attach = mxb_attach, 849 .attach = mxb_attach,
851 .detach = mxb_detach, 850 .detach = mxb_detach,
852 851
diff --git a/drivers/media/video/omap24xxcam.c b/drivers/media/video/omap24xxcam.c
index 142c327afb3..ce76d952e16 100644
--- a/drivers/media/video/omap24xxcam.c
+++ b/drivers/media/video/omap24xxcam.c
@@ -35,6 +35,7 @@
35#include <linux/platform_device.h> 35#include <linux/platform_device.h>
36#include <linux/clk.h> 36#include <linux/clk.h>
37#include <linux/io.h> 37#include <linux/io.h>
38#include <linux/slab.h>
38 39
39#include <media/v4l2-common.h> 40#include <media/v4l2-common.h>
40#include <media/v4l2-ioctl.h> 41#include <media/v4l2-ioctl.h>
@@ -1404,7 +1405,7 @@ static int omap24xxcam_mmap_buffers(struct file *file,
1404 } 1405 }
1405 1406
1406 size = 0; 1407 size = 0;
1407 for (i = first; i <= last; i++) { 1408 for (i = first; i <= last && i < VIDEO_MAX_FRAME; i++) {
1408 struct videobuf_dmabuf *dma = videobuf_to_dma(vbq->bufs[i]); 1409 struct videobuf_dmabuf *dma = videobuf_to_dma(vbq->bufs[i]);
1409 1410
1410 for (j = 0; j < dma->sglen; j++) { 1411 for (j = 0; j < dma->sglen; j++) {
diff --git a/drivers/media/video/ov7670.c b/drivers/media/video/ov7670.c
index 0e2184ec994..aaa50f9b8e7 100644
--- a/drivers/media/video/ov7670.c
+++ b/drivers/media/video/ov7670.c
@@ -12,6 +12,7 @@
12 */ 12 */
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/slab.h>
15#include <linux/i2c.h> 16#include <linux/i2c.h>
16#include <linux/delay.h> 17#include <linux/delay.h>
17#include <linux/videodev2.h> 18#include <linux/videodev2.h>
diff --git a/drivers/media/video/pms.c b/drivers/media/video/pms.c
index 11a2c26399b..0598bbd3f36 100644
--- a/drivers/media/video/pms.c
+++ b/drivers/media/video/pms.c
@@ -25,7 +25,6 @@
25#include <linux/errno.h> 25#include <linux/errno.h>
26#include <linux/fs.h> 26#include <linux/fs.h>
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/slab.h>
29#include <linux/mm.h> 28#include <linux/mm.h>
30#include <linux/ioport.h> 29#include <linux/ioport.h>
31#include <linux/init.h> 30#include <linux/init.h>
diff --git a/drivers/media/video/pvrusb2/pvrusb2-cs53l32a.c b/drivers/media/video/pvrusb2/pvrusb2-cs53l32a.c
index 68980e19409..88320900dbd 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-cs53l32a.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-cs53l32a.c
@@ -34,7 +34,6 @@
34#include <linux/videodev2.h> 34#include <linux/videodev2.h>
35#include <media/v4l2-common.h> 35#include <media/v4l2-common.h>
36#include <linux/errno.h> 36#include <linux/errno.h>
37#include <linux/slab.h>
38 37
39struct routing_scheme { 38struct routing_scheme {
40 const int *def; 39 const int *def;
diff --git a/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c b/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
index 82c13583575..2222da8d0ca 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
@@ -36,7 +36,6 @@
36#include <linux/videodev2.h> 36#include <linux/videodev2.h>
37#include <media/v4l2-common.h> 37#include <media/v4l2-common.h>
38#include <linux/errno.h> 38#include <linux/errno.h>
39#include <linux/slab.h>
40 39
41 40
42struct routing_scheme_item { 41struct routing_scheme_item {
diff --git a/drivers/media/video/pvrusb2/pvrusb2-debugifc.c b/drivers/media/video/pvrusb2/pvrusb2-debugifc.c
index ae977668c49..e9b11e119f6 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-debugifc.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-debugifc.c
@@ -19,7 +19,6 @@
19 */ 19 */
20 20
21#include <linux/string.h> 21#include <linux/string.h>
22#include <linux/slab.h>
23#include "pvrusb2-debugifc.h" 22#include "pvrusb2-debugifc.h"
24#include "pvrusb2-hdw.h" 23#include "pvrusb2-hdw.h"
25#include "pvrusb2-debug.h" 24#include "pvrusb2-debug.h"
diff --git a/drivers/media/video/pvrusb2/pvrusb2-dvb.c b/drivers/media/video/pvrusb2/pvrusb2-dvb.c
index b7f5c49b1db..8c95793433e 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-dvb.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-dvb.c
@@ -20,6 +20,7 @@
20 20
21#include <linux/kthread.h> 21#include <linux/kthread.h>
22#include <linux/freezer.h> 22#include <linux/freezer.h>
23#include <linux/slab.h>
23#include <linux/mm.h> 24#include <linux/mm.h>
24#include "dvbdev.h" 25#include "dvbdev.h"
25#include "pvrusb2-debug.h" 26#include "pvrusb2-debug.h"
diff --git a/drivers/media/video/pvrusb2/pvrusb2-eeprom.c b/drivers/media/video/pvrusb2/pvrusb2-eeprom.c
index 299afa4fa96..aeed1c2945f 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-eeprom.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-eeprom.c
@@ -19,6 +19,7 @@
19 * 19 *
20 */ 20 */
21 21
22#include <linux/slab.h>
22#include "pvrusb2-eeprom.h" 23#include "pvrusb2-eeprom.h"
23#include "pvrusb2-hdw-internal.h" 24#include "pvrusb2-hdw-internal.h"
24#include "pvrusb2-debug.h" 25#include "pvrusb2-debug.h"
diff --git a/drivers/media/video/pvrusb2/pvrusb2-main.c b/drivers/media/video/pvrusb2/pvrusb2-main.c
index 8689ddb5442..eeacd0f6785 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-main.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-main.c
@@ -21,7 +21,6 @@
21 21
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/errno.h> 23#include <linux/errno.h>
24#include <linux/slab.h>
25#include <linux/module.h> 24#include <linux/module.h>
26#include <linux/usb.h> 25#include <linux/usb.h>
27#include <linux/videodev2.h> 26#include <linux/videodev2.h>
diff --git a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
index 6c23456e0bd..71f50565f63 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
@@ -423,10 +423,12 @@ static void pvr2_sysfs_add_debugifc(struct pvr2_sysfs *sfp)
423 423
424 dip = kzalloc(sizeof(*dip),GFP_KERNEL); 424 dip = kzalloc(sizeof(*dip),GFP_KERNEL);
425 if (!dip) return; 425 if (!dip) return;
426 sysfs_attr_init(&dip->attr_debugcmd.attr);
426 dip->attr_debugcmd.attr.name = "debugcmd"; 427 dip->attr_debugcmd.attr.name = "debugcmd";
427 dip->attr_debugcmd.attr.mode = S_IRUGO|S_IWUSR|S_IWGRP; 428 dip->attr_debugcmd.attr.mode = S_IRUGO|S_IWUSR|S_IWGRP;
428 dip->attr_debugcmd.show = debugcmd_show; 429 dip->attr_debugcmd.show = debugcmd_show;
429 dip->attr_debugcmd.store = debugcmd_store; 430 dip->attr_debugcmd.store = debugcmd_store;
431 sysfs_attr_init(&dip->attr_debuginfo.attr);
430 dip->attr_debuginfo.attr.name = "debuginfo"; 432 dip->attr_debuginfo.attr.name = "debuginfo";
431 dip->attr_debuginfo.attr.mode = S_IRUGO; 433 dip->attr_debuginfo.attr.mode = S_IRUGO;
432 dip->attr_debuginfo.show = debuginfo_show; 434 dip->attr_debuginfo.show = debuginfo_show;
@@ -644,6 +646,7 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
644 return; 646 return;
645 } 647 }
646 648
649 sysfs_attr_init(&sfp->attr_v4l_minor_number.attr);
647 sfp->attr_v4l_minor_number.attr.name = "v4l_minor_number"; 650 sfp->attr_v4l_minor_number.attr.name = "v4l_minor_number";
648 sfp->attr_v4l_minor_number.attr.mode = S_IRUGO; 651 sfp->attr_v4l_minor_number.attr.mode = S_IRUGO;
649 sfp->attr_v4l_minor_number.show = v4l_minor_number_show; 652 sfp->attr_v4l_minor_number.show = v4l_minor_number_show;
@@ -658,6 +661,7 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
658 sfp->v4l_minor_number_created_ok = !0; 661 sfp->v4l_minor_number_created_ok = !0;
659 } 662 }
660 663
664 sysfs_attr_init(&sfp->attr_v4l_radio_minor_number.attr);
661 sfp->attr_v4l_radio_minor_number.attr.name = "v4l_radio_minor_number"; 665 sfp->attr_v4l_radio_minor_number.attr.name = "v4l_radio_minor_number";
662 sfp->attr_v4l_radio_minor_number.attr.mode = S_IRUGO; 666 sfp->attr_v4l_radio_minor_number.attr.mode = S_IRUGO;
663 sfp->attr_v4l_radio_minor_number.show = v4l_radio_minor_number_show; 667 sfp->attr_v4l_radio_minor_number.show = v4l_radio_minor_number_show;
@@ -672,6 +676,7 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
672 sfp->v4l_radio_minor_number_created_ok = !0; 676 sfp->v4l_radio_minor_number_created_ok = !0;
673 } 677 }
674 678
679 sysfs_attr_init(&sfp->attr_unit_number.attr);
675 sfp->attr_unit_number.attr.name = "unit_number"; 680 sfp->attr_unit_number.attr.name = "unit_number";
676 sfp->attr_unit_number.attr.mode = S_IRUGO; 681 sfp->attr_unit_number.attr.mode = S_IRUGO;
677 sfp->attr_unit_number.show = unit_number_show; 682 sfp->attr_unit_number.show = unit_number_show;
@@ -685,6 +690,7 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
685 sfp->unit_number_created_ok = !0; 690 sfp->unit_number_created_ok = !0;
686 } 691 }
687 692
693 sysfs_attr_init(&sfp->attr_bus_info.attr);
688 sfp->attr_bus_info.attr.name = "bus_info_str"; 694 sfp->attr_bus_info.attr.name = "bus_info_str";
689 sfp->attr_bus_info.attr.mode = S_IRUGO; 695 sfp->attr_bus_info.attr.mode = S_IRUGO;
690 sfp->attr_bus_info.show = bus_info_show; 696 sfp->attr_bus_info.show = bus_info_show;
@@ -699,6 +705,7 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
699 sfp->bus_info_created_ok = !0; 705 sfp->bus_info_created_ok = !0;
700 } 706 }
701 707
708 sysfs_attr_init(&sfp->attr_hdw_name.attr);
702 sfp->attr_hdw_name.attr.name = "device_hardware_type"; 709 sfp->attr_hdw_name.attr.name = "device_hardware_type";
703 sfp->attr_hdw_name.attr.mode = S_IRUGO; 710 sfp->attr_hdw_name.attr.mode = S_IRUGO;
704 sfp->attr_hdw_name.show = hdw_name_show; 711 sfp->attr_hdw_name.show = hdw_name_show;
@@ -713,6 +720,7 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
713 sfp->hdw_name_created_ok = !0; 720 sfp->hdw_name_created_ok = !0;
714 } 721 }
715 722
723 sysfs_attr_init(&sfp->attr_hdw_desc.attr);
716 sfp->attr_hdw_desc.attr.name = "device_hardware_description"; 724 sfp->attr_hdw_desc.attr.name = "device_hardware_description";
717 sfp->attr_hdw_desc.attr.mode = S_IRUGO; 725 sfp->attr_hdw_desc.attr.mode = S_IRUGO;
718 sfp->attr_hdw_desc.show = hdw_desc_show; 726 sfp->attr_hdw_desc.show = hdw_desc_show;
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
index cc8ddb2d238..bf1e0fe9f4d 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
@@ -20,6 +20,7 @@
20 */ 20 */
21 21
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/slab.h>
23#include <linux/version.h> 24#include <linux/version.h>
24#include "pvrusb2-context.h" 25#include "pvrusb2-context.h"
25#include "pvrusb2-hdw.h" 26#include "pvrusb2-hdw.h"
diff --git a/drivers/media/video/pvrusb2/pvrusb2-video-v4l.c b/drivers/media/video/pvrusb2/pvrusb2-video-v4l.c
index 4c96cf48c79..2e205c99eb9 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-video-v4l.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-video-v4l.c
@@ -37,7 +37,6 @@
37#include <media/v4l2-common.h> 37#include <media/v4l2-common.h>
38#include <media/saa7115.h> 38#include <media/saa7115.h>
39#include <linux/errno.h> 39#include <linux/errno.h>
40#include <linux/slab.h>
41 40
42struct routing_scheme { 41struct routing_scheme {
43 const int *def; 42 const int *def;
diff --git a/drivers/media/video/pvrusb2/pvrusb2-wm8775.c b/drivers/media/video/pvrusb2/pvrusb2-wm8775.c
index 8c1eae05aa0..3ac8d751a5c 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-wm8775.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-wm8775.c
@@ -34,7 +34,6 @@
34#include <linux/videodev2.h> 34#include <linux/videodev2.h>
35#include <media/v4l2-common.h> 35#include <media/v4l2-common.h>
36#include <linux/errno.h> 36#include <linux/errno.h>
37#include <linux/slab.h>
38 37
39void pvr2_wm8775_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) 38void pvr2_wm8775_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
40{ 39{
diff --git a/drivers/media/video/pwc/pwc-dec23.c b/drivers/media/video/pwc/pwc-dec23.c
index 9e2d91f26bf..0c801b8f3ec 100644
--- a/drivers/media/video/pwc/pwc-dec23.c
+++ b/drivers/media/video/pwc/pwc-dec23.c
@@ -30,6 +30,7 @@
30#include <media/pwc-ioctl.h> 30#include <media/pwc-ioctl.h>
31 31
32#include <linux/string.h> 32#include <linux/string.h>
33#include <linux/slab.h>
33 34
34/* 35/*
35 * USE_LOOKUP_TABLE_TO_CLAMP 36 * USE_LOOKUP_TABLE_TO_CLAMP
diff --git a/drivers/media/video/pwc/pwc-v4l.c b/drivers/media/video/pwc/pwc-v4l.c
index bdb4ced5749..62d89b3113a 100644
--- a/drivers/media/video/pwc/pwc-v4l.c
+++ b/drivers/media/video/pwc/pwc-v4l.c
@@ -30,7 +30,6 @@
30#include <linux/mm.h> 30#include <linux/mm.h>
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/poll.h> 32#include <linux/poll.h>
33#include <linux/slab.h>
34#include <linux/vmalloc.h> 33#include <linux/vmalloc.h>
35#include <asm/io.h> 34#include <asm/io.h>
36 35
diff --git a/drivers/media/video/pwc/pwc.h b/drivers/media/video/pwc/pwc.h
index 0902355dfa7..f1b20663295 100644
--- a/drivers/media/video/pwc/pwc.h
+++ b/drivers/media/video/pwc/pwc.h
@@ -32,6 +32,7 @@
32#include <linux/version.h> 32#include <linux/version.h>
33#include <linux/mutex.h> 33#include <linux/mutex.h>
34#include <linux/mm.h> 34#include <linux/mm.h>
35#include <linux/slab.h>
35#include <asm/errno.h> 36#include <asm/errno.h>
36#include <linux/videodev.h> 37#include <linux/videodev.h>
37#include <media/v4l2-common.h> 38#include <media/v4l2-common.h>
diff --git a/drivers/media/video/pxa_camera.c b/drivers/media/video/pxa_camera.c
index 322ac4eecf0..04bf5c11308 100644
--- a/drivers/media/video/pxa_camera.c
+++ b/drivers/media/video/pxa_camera.c
@@ -27,6 +27,7 @@
27#include <linux/platform_device.h> 27#include <linux/platform_device.h>
28#include <linux/clk.h> 28#include <linux/clk.h>
29#include <linux/sched.h> 29#include <linux/sched.h>
30#include <linux/slab.h>
30 31
31#include <media/v4l2-common.h> 32#include <media/v4l2-common.h>
32#include <media/v4l2-dev.h> 33#include <media/v4l2-dev.h>
@@ -608,12 +609,9 @@ static void pxa_dma_add_tail_buf(struct pxa_camera_dev *pcdev,
608 */ 609 */
609static void pxa_camera_start_capture(struct pxa_camera_dev *pcdev) 610static void pxa_camera_start_capture(struct pxa_camera_dev *pcdev)
610{ 611{
611 unsigned long cicr0, cifr; 612 unsigned long cicr0;
612 613
613 dev_dbg(pcdev->soc_host.v4l2_dev.dev, "%s\n", __func__); 614 dev_dbg(pcdev->soc_host.v4l2_dev.dev, "%s\n", __func__);
614 /* Reset the FIFOs */
615 cifr = __raw_readl(pcdev->base + CIFR) | CIFR_RESET_F;
616 __raw_writel(cifr, pcdev->base + CIFR);
617 /* Enable End-Of-Frame Interrupt */ 615 /* Enable End-Of-Frame Interrupt */
618 cicr0 = __raw_readl(pcdev->base + CICR0) | CICR0_ENB; 616 cicr0 = __raw_readl(pcdev->base + CICR0) | CICR0_ENB;
619 cicr0 &= ~CICR0_EOFM; 617 cicr0 &= ~CICR0_EOFM;
@@ -934,7 +932,7 @@ static void pxa_camera_deactivate(struct pxa_camera_dev *pcdev)
934static irqreturn_t pxa_camera_irq(int irq, void *data) 932static irqreturn_t pxa_camera_irq(int irq, void *data)
935{ 933{
936 struct pxa_camera_dev *pcdev = data; 934 struct pxa_camera_dev *pcdev = data;
937 unsigned long status, cicr0; 935 unsigned long status, cifr, cicr0;
938 struct pxa_buffer *buf; 936 struct pxa_buffer *buf;
939 struct videobuf_buffer *vb; 937 struct videobuf_buffer *vb;
940 938
@@ -948,6 +946,10 @@ static irqreturn_t pxa_camera_irq(int irq, void *data)
948 __raw_writel(status, pcdev->base + CISR); 946 __raw_writel(status, pcdev->base + CISR);
949 947
950 if (status & CISR_EOF) { 948 if (status & CISR_EOF) {
949 /* Reset the FIFOs */
950 cifr = __raw_readl(pcdev->base + CIFR) | CIFR_RESET_F;
951 __raw_writel(cifr, pcdev->base + CIFR);
952
951 pcdev->active = list_first_entry(&pcdev->capture, 953 pcdev->active = list_first_entry(&pcdev->capture,
952 struct pxa_buffer, vb.queue); 954 struct pxa_buffer, vb.queue);
953 vb = &pcdev->active->vb; 955 vb = &pcdev->active->vb;
diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c
index fb742f1ae71..3de914deb8e 100644
--- a/drivers/media/video/s2255drv.c
+++ b/drivers/media/video/s2255drv.c
@@ -45,6 +45,7 @@
45#include <linux/firmware.h> 45#include <linux/firmware.h>
46#include <linux/kernel.h> 46#include <linux/kernel.h>
47#include <linux/mutex.h> 47#include <linux/mutex.h>
48#include <linux/slab.h>
48#include <linux/videodev2.h> 49#include <linux/videodev2.h>
49#include <linux/version.h> 50#include <linux/version.h>
50#include <linux/mm.h> 51#include <linux/mm.h>
diff --git a/drivers/media/video/saa5246a.c b/drivers/media/video/saa5246a.c
index 5ab6a0f901c..6b3b09ef897 100644
--- a/drivers/media/video/saa5246a.c
+++ b/drivers/media/video/saa5246a.c
@@ -43,6 +43,7 @@
43#include <linux/mm.h> 43#include <linux/mm.h>
44#include <linux/init.h> 44#include <linux/init.h>
45#include <linux/i2c.h> 45#include <linux/i2c.h>
46#include <linux/slab.h>
46#include <linux/mutex.h> 47#include <linux/mutex.h>
47#include <linux/videotext.h> 48#include <linux/videotext.h>
48#include <linux/videodev2.h> 49#include <linux/videodev2.h>
diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c
index 12835fb82c9..31ff27df4cb 100644
--- a/drivers/media/video/saa5249.c
+++ b/drivers/media/video/saa5249.c
@@ -50,6 +50,7 @@
50#include <linux/delay.h> 50#include <linux/delay.h>
51#include <linux/videotext.h> 51#include <linux/videotext.h>
52#include <linux/videodev2.h> 52#include <linux/videodev2.h>
53#include <linux/slab.h>
53#include <media/v4l2-device.h> 54#include <media/v4l2-device.h>
54#include <media/v4l2-chip-ident.h> 55#include <media/v4l2-chip-ident.h>
55#include <media/v4l2-ioctl.h> 56#include <media/v4l2-ioctl.h>
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index 73739d2a63d..4ab4a987c9b 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -24,7 +24,6 @@
24#include <linux/list.h> 24#include <linux/list.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/slab.h>
28#include <linux/delay.h> 27#include <linux/delay.h>
29#include <linux/kthread.h> 28#include <linux/kthread.h>
30#include <linux/suspend.h> 29#include <linux/suspend.h>
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c
index ee5bff02a92..ea877a50f52 100644
--- a/drivers/media/video/saa7134/saa7134-empress.c
+++ b/drivers/media/video/saa7134/saa7134-empress.c
@@ -21,7 +21,6 @@
21#include <linux/list.h> 21#include <linux/list.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/slab.h>
25#include <linux/smp_lock.h> 24#include <linux/smp_lock.h>
26#include <linux/delay.h> 25#include <linux/delay.h>
27 26
diff --git a/drivers/media/video/saa7134/saa7134-i2c.c b/drivers/media/video/saa7134/saa7134-i2c.c
index 8096dace5f6..da41b6b1e64 100644
--- a/drivers/media/video/saa7134/saa7134-i2c.c
+++ b/drivers/media/video/saa7134/saa7134-i2c.c
@@ -24,7 +24,6 @@
24#include <linux/list.h> 24#include <linux/list.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/slab.h>
28#include <linux/delay.h> 27#include <linux/delay.h>
29 28
30#include "saa7134-reg.h" 29#include "saa7134-reg.h"
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c
index 9499000f66b..58a0cdc8414 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -23,6 +23,7 @@
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/input.h> 25#include <linux/input.h>
26#include <linux/slab.h>
26 27
27#include "saa7134-reg.h" 28#include "saa7134-reg.h"
28#include "saa7134.h" 29#include "saa7134.h"
diff --git a/drivers/media/video/saa7134/saa7134-ts.c b/drivers/media/video/saa7134/saa7134-ts.c
index b9817d74943..2e3f4b412d8 100644
--- a/drivers/media/video/saa7134/saa7134-ts.c
+++ b/drivers/media/video/saa7134/saa7134-ts.c
@@ -24,7 +24,6 @@
24#include <linux/list.h> 24#include <linux/list.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/slab.h>
28#include <linux/delay.h> 27#include <linux/delay.h>
29 28
30#include "saa7134-reg.h" 29#include "saa7134-reg.h"
diff --git a/drivers/media/video/saa7134/saa7134-tvaudio.c b/drivers/media/video/saa7134/saa7134-tvaudio.c
index 76b16407b01..3e7d2fd1688 100644
--- a/drivers/media/video/saa7134/saa7134-tvaudio.c
+++ b/drivers/media/video/saa7134/saa7134-tvaudio.c
@@ -25,7 +25,6 @@
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/kthread.h> 27#include <linux/kthread.h>
28#include <linux/slab.h>
29#include <linux/delay.h> 28#include <linux/delay.h>
30#include <linux/freezer.h> 29#include <linux/freezer.h>
31#include <asm/div64.h> 30#include <asm/div64.h>
diff --git a/drivers/media/video/saa7134/saa7134-vbi.c b/drivers/media/video/saa7134/saa7134-vbi.c
index cb0304298a9..e9aa94b807f 100644
--- a/drivers/media/video/saa7134/saa7134-vbi.c
+++ b/drivers/media/video/saa7134/saa7134-vbi.c
@@ -24,7 +24,6 @@
24#include <linux/list.h> 24#include <linux/list.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/slab.h>
28 27
29#include "saa7134-reg.h" 28#include "saa7134-reg.h"
30#include "saa7134.h" 29#include "saa7134.h"
diff --git a/drivers/media/video/saa7164/saa7164-api.c b/drivers/media/video/saa7164/saa7164-api.c
index 1d487c15034..3f1262b00cc 100644
--- a/drivers/media/video/saa7164/saa7164-api.c
+++ b/drivers/media/video/saa7164/saa7164-api.c
@@ -20,6 +20,7 @@
20 */ 20 */
21 21
22#include <linux/wait.h> 22#include <linux/wait.h>
23#include <linux/slab.h>
23 24
24#include "saa7164.h" 25#include "saa7164.h"
25 26
diff --git a/drivers/media/video/saa7164/saa7164-buffer.c b/drivers/media/video/saa7164/saa7164-buffer.c
index 9ca5c83d165..5713f3a4b76 100644
--- a/drivers/media/video/saa7164/saa7164-buffer.c
+++ b/drivers/media/video/saa7164/saa7164-buffer.c
@@ -19,6 +19,8 @@
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/slab.h>
23
22#include "saa7164.h" 24#include "saa7164.h"
23 25
24/* The PCI address space for buffer handling looks like this: 26/* The PCI address space for buffer handling looks like this:
diff --git a/drivers/media/video/saa7164/saa7164-fw.c b/drivers/media/video/saa7164/saa7164-fw.c
index ee0af3534ed..270245d275a 100644
--- a/drivers/media/video/saa7164/saa7164-fw.c
+++ b/drivers/media/video/saa7164/saa7164-fw.c
@@ -20,6 +20,7 @@
20 */ 20 */
21 21
22#include <linux/firmware.h> 22#include <linux/firmware.h>
23#include <linux/slab.h>
23 24
24#include "saa7164.h" 25#include "saa7164.h"
25 26
diff --git a/drivers/media/video/saa717x.c b/drivers/media/video/saa717x.c
index 6818df57116..d521c648e15 100644
--- a/drivers/media/video/saa717x.c
+++ b/drivers/media/video/saa717x.c
@@ -32,6 +32,7 @@
32 32
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/kernel.h> 34#include <linux/kernel.h>
35#include <linux/slab.h>
35#include <linux/sched.h> 36#include <linux/sched.h>
36 37
37#include <linux/videodev2.h> 38#include <linux/videodev2.h>
diff --git a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c
index 212baa10829..77db2039291 100644
--- a/drivers/media/video/saa7185.c
+++ b/drivers/media/video/saa7185.c
@@ -26,6 +26,7 @@
26 26
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/types.h> 28#include <linux/types.h>
29#include <linux/slab.h>
29#include <linux/ioctl.h> 30#include <linux/ioctl.h>
30#include <asm/uaccess.h> 31#include <asm/uaccess.h>
31#include <linux/i2c.h> 32#include <linux/i2c.h>
diff --git a/drivers/media/video/sh_mobile_ceu_camera.c b/drivers/media/video/sh_mobile_ceu_camera.c
index fb88c63188f..1ad980f8e77 100644
--- a/drivers/media/video/sh_mobile_ceu_camera.c
+++ b/drivers/media/video/sh_mobile_ceu_camera.c
@@ -27,6 +27,7 @@
27#include <linux/moduleparam.h> 27#include <linux/moduleparam.h>
28#include <linux/time.h> 28#include <linux/time.h>
29#include <linux/version.h> 29#include <linux/version.h>
30#include <linux/slab.h>
30#include <linux/device.h> 31#include <linux/device.h>
31#include <linux/platform_device.h> 32#include <linux/platform_device.h>
32#include <linux/videodev2.h> 33#include <linux/videodev2.h>
@@ -1632,7 +1633,7 @@ static int sh_mobile_ceu_try_fmt(struct soc_camera_device *icd,
1632 height = pix->height; 1633 height = pix->height;
1633 1634
1634 pix->bytesperline = soc_mbus_bytes_per_line(width, xlate->host_fmt); 1635 pix->bytesperline = soc_mbus_bytes_per_line(width, xlate->host_fmt);
1635 if (pix->bytesperline < 0) 1636 if ((int)pix->bytesperline < 0)
1636 return pix->bytesperline; 1637 return pix->bytesperline;
1637 pix->sizeimage = height * pix->bytesperline; 1638 pix->sizeimage = height * pix->bytesperline;
1638 1639
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c
index 80f6bfa2632..a24174ddec4 100644
--- a/drivers/media/video/soc_camera.c
+++ b/drivers/media/video/soc_camera.c
@@ -24,6 +24,7 @@
24#include <linux/mutex.h> 24#include <linux/mutex.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/platform_device.h> 26#include <linux/platform_device.h>
27#include <linux/slab.h>
27#include <linux/vmalloc.h> 28#include <linux/vmalloc.h>
28 29
29#include <media/soc_camera.h> 30#include <media/soc_camera.h>
diff --git a/drivers/media/video/tda9840.c b/drivers/media/video/tda9840.c
index d381fce3db4..92d22d8931c 100644
--- a/drivers/media/video/tda9840.c
+++ b/drivers/media/video/tda9840.c
@@ -28,6 +28,7 @@
28 28
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/ioctl.h> 30#include <linux/ioctl.h>
31#include <linux/slab.h>
31#include <linux/i2c.h> 32#include <linux/i2c.h>
32#include <media/v4l2-device.h> 33#include <media/v4l2-device.h>
33#include <media/v4l2-chip-ident.h> 34#include <media/v4l2-chip-ident.h>
diff --git a/drivers/media/video/tea6415c.c b/drivers/media/video/tea6415c.c
index 1585839bd0b..3021a1e6b7b 100644
--- a/drivers/media/video/tea6415c.c
+++ b/drivers/media/video/tea6415c.c
@@ -30,6 +30,7 @@
30 30
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/ioctl.h> 32#include <linux/ioctl.h>
33#include <linux/slab.h>
33#include <linux/i2c.h> 34#include <linux/i2c.h>
34#include <media/v4l2-device.h> 35#include <media/v4l2-device.h>
35#include <media/v4l2-chip-ident.h> 36#include <media/v4l2-chip-ident.h>
diff --git a/drivers/media/video/tea6420.c b/drivers/media/video/tea6420.c
index 6bf6bc7dbc7..49dafc5e1e2 100644
--- a/drivers/media/video/tea6420.c
+++ b/drivers/media/video/tea6420.c
@@ -30,6 +30,7 @@
30 30
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/ioctl.h> 32#include <linux/ioctl.h>
33#include <linux/slab.h>
33#include <linux/i2c.h> 34#include <linux/i2c.h>
34#include <media/v4l2-device.h> 35#include <media/v4l2-device.h>
35#include <media/v4l2-chip-ident.h> 36#include <media/v4l2-chip-ident.h>
diff --git a/drivers/media/video/ths7303.c b/drivers/media/video/ths7303.c
index 21781f8a0e8..61b1dd11836 100644
--- a/drivers/media/video/ths7303.c
+++ b/drivers/media/video/ths7303.c
@@ -16,6 +16,7 @@
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/ctype.h> 18#include <linux/ctype.h>
19#include <linux/slab.h>
19#include <linux/i2c.h> 20#include <linux/i2c.h>
20#include <linux/device.h> 21#include <linux/device.h>
21#include <linux/delay.h> 22#include <linux/delay.h>
diff --git a/drivers/media/video/tlg2300/pd-alsa.c b/drivers/media/video/tlg2300/pd-alsa.c
index 6f42621ad47..9f8b7da56b6 100644
--- a/drivers/media/video/tlg2300/pd-alsa.c
+++ b/drivers/media/video/tlg2300/pd-alsa.c
@@ -4,10 +4,10 @@
4#include <linux/sound.h> 4#include <linux/sound.h>
5#include <linux/spinlock.h> 5#include <linux/spinlock.h>
6#include <linux/soundcard.h> 6#include <linux/soundcard.h>
7#include <linux/slab.h>
8#include <linux/vmalloc.h> 7#include <linux/vmalloc.h>
9#include <linux/proc_fs.h> 8#include <linux/proc_fs.h>
10#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/gfp.h>
11#include <sound/core.h> 11#include <sound/core.h>
12#include <sound/pcm.h> 12#include <sound/pcm.h>
13#include <sound/pcm_params.h> 13#include <sound/pcm_params.h>
diff --git a/drivers/media/video/tlg2300/pd-dvb.c b/drivers/media/video/tlg2300/pd-dvb.c
index 4133aee568b..ebd9cb5bec7 100644
--- a/drivers/media/video/tlg2300/pd-dvb.c
+++ b/drivers/media/video/tlg2300/pd-dvb.c
@@ -3,6 +3,7 @@
3#include <linux/usb.h> 3#include <linux/usb.h>
4#include <linux/dvb/dmx.h> 4#include <linux/dvb/dmx.h>
5#include <linux/delay.h> 5#include <linux/delay.h>
6#include <linux/gfp.h>
6 7
7#include "vendorcmds.h" 8#include "vendorcmds.h"
8#include <linux/sched.h> 9#include <linux/sched.h>
diff --git a/drivers/media/video/tlg2300/pd-video.c b/drivers/media/video/tlg2300/pd-video.c
index becfba6a304..cf8f18c007e 100644
--- a/drivers/media/video/tlg2300/pd-video.c
+++ b/drivers/media/video/tlg2300/pd-video.c
@@ -4,6 +4,7 @@
4#include <linux/usb.h> 4#include <linux/usb.h>
5#include <linux/mm.h> 5#include <linux/mm.h>
6#include <linux/sched.h> 6#include <linux/sched.h>
7#include <linux/slab.h>
7 8
8#include <media/v4l2-ioctl.h> 9#include <media/v4l2-ioctl.h>
9#include <media/v4l2-dev.h> 10#include <media/v4l2-dev.h>
diff --git a/drivers/media/video/tlv320aic23b.c b/drivers/media/video/tlv320aic23b.c
index 07789c64814..9ddb32bc7af 100644
--- a/drivers/media/video/tlv320aic23b.c
+++ b/drivers/media/video/tlv320aic23b.c
@@ -25,6 +25,7 @@
25 25
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/types.h> 27#include <linux/types.h>
28#include <linux/slab.h>
28#include <linux/ioctl.h> 29#include <linux/ioctl.h>
29#include <asm/uaccess.h> 30#include <asm/uaccess.h>
30#include <linux/i2c.h> 31#include <linux/i2c.h>
diff --git a/drivers/media/video/tvp514x.c b/drivers/media/video/tvp514x.c
index 26b4e718cd6..e4815a1806e 100644
--- a/drivers/media/video/tvp514x.c
+++ b/drivers/media/video/tvp514x.c
@@ -29,6 +29,7 @@
29 */ 29 */
30 30
31#include <linux/i2c.h> 31#include <linux/i2c.h>
32#include <linux/slab.h>
32#include <linux/delay.h> 33#include <linux/delay.h>
33#include <linux/videodev2.h> 34#include <linux/videodev2.h>
34 35
diff --git a/drivers/media/video/tvp5150.c b/drivers/media/video/tvp5150.c
index 2d38e253f14..908ffb68e92 100644
--- a/drivers/media/video/tvp5150.c
+++ b/drivers/media/video/tvp5150.c
@@ -6,6 +6,7 @@
6 */ 6 */
7 7
8#include <linux/i2c.h> 8#include <linux/i2c.h>
9#include <linux/slab.h>
9#include <linux/videodev2.h> 10#include <linux/videodev2.h>
10#include <linux/delay.h> 11#include <linux/delay.h>
11#include <media/v4l2-device.h> 12#include <media/v4l2-device.h>
diff --git a/drivers/media/video/tvp7002.c b/drivers/media/video/tvp7002.c
index 5a878bca02d..4a69bcc738f 100644
--- a/drivers/media/video/tvp7002.c
+++ b/drivers/media/video/tvp7002.c
@@ -26,6 +26,7 @@
26 */ 26 */
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <linux/slab.h>
29#include <linux/videodev2.h> 30#include <linux/videodev2.h>
30#include <media/tvp7002.h> 31#include <media/tvp7002.h>
31#include <media/v4l2-device.h> 32#include <media/v4l2-device.h>
diff --git a/drivers/media/video/upd64031a.c b/drivers/media/video/upd64031a.c
index a07a3fbb51e..36c0c461d8b 100644
--- a/drivers/media/video/upd64031a.c
+++ b/drivers/media/video/upd64031a.c
@@ -25,6 +25,7 @@
25#include <linux/kernel.h> 25#include <linux/kernel.h>
26#include <linux/i2c.h> 26#include <linux/i2c.h>
27#include <linux/videodev2.h> 27#include <linux/videodev2.h>
28#include <linux/slab.h>
28#include <media/v4l2-device.h> 29#include <media/v4l2-device.h>
29#include <media/v4l2-chip-ident.h> 30#include <media/v4l2-chip-ident.h>
30#include <media/v4l2-i2c-drv.h> 31#include <media/v4l2-i2c-drv.h>
diff --git a/drivers/media/video/upd64083.c b/drivers/media/video/upd64083.c
index 6eb0e5b00c3..c5af93b30a2 100644
--- a/drivers/media/video/upd64083.c
+++ b/drivers/media/video/upd64083.c
@@ -25,6 +25,7 @@
25#include <linux/kernel.h> 25#include <linux/kernel.h>
26#include <linux/i2c.h> 26#include <linux/i2c.h>
27#include <linux/videodev2.h> 27#include <linux/videodev2.h>
28#include <linux/slab.h>
28#include <media/v4l2-device.h> 29#include <media/v4l2-device.h>
29#include <media/v4l2-chip-ident.h> 30#include <media/v4l2-chip-ident.h>
30#include <media/v4l2-i2c-drv.h> 31#include <media/v4l2-i2c-drv.h>
diff --git a/drivers/media/video/usbvideo/konicawc.c b/drivers/media/video/usbvideo/konicawc.c
index a0addcb0429..562e1d170be 100644
--- a/drivers/media/video/usbvideo/konicawc.c
+++ b/drivers/media/video/usbvideo/konicawc.c
@@ -16,6 +16,7 @@
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/usb/input.h> 18#include <linux/usb/input.h>
19#include <linux/gfp.h>
19 20
20#include "usbvideo.h" 21#include "usbvideo.h"
21 22
diff --git a/drivers/media/video/usbvideo/quickcam_messenger.c b/drivers/media/video/usbvideo/quickcam_messenger.c
index c4d1b96b5ce..fab48ec6c0e 100644
--- a/drivers/media/video/usbvideo/quickcam_messenger.c
+++ b/drivers/media/video/usbvideo/quickcam_messenger.c
@@ -34,6 +34,7 @@
34#include <linux/init.h> 34#include <linux/init.h>
35#include <linux/input.h> 35#include <linux/input.h>
36#include <linux/usb/input.h> 36#include <linux/usb/input.h>
37#include <linux/slab.h>
37 38
38#include "usbvideo.h" 39#include "usbvideo.h"
39#include "quickcam_messenger.h" 40#include "quickcam_messenger.h"
diff --git a/drivers/media/video/usbvision/usbvision-core.c b/drivers/media/video/usbvision/usbvision-core.c
index e0f91e4ab65..f7aae229375 100644
--- a/drivers/media/video/usbvision/usbvision-core.c
+++ b/drivers/media/video/usbvision/usbvision-core.c
@@ -26,7 +26,7 @@
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/list.h> 27#include <linux/list.h>
28#include <linux/timer.h> 28#include <linux/timer.h>
29#include <linux/slab.h> 29#include <linux/gfp.h>
30#include <linux/mm.h> 30#include <linux/mm.h>
31#include <linux/highmem.h> 31#include <linux/highmem.h>
32#include <linux/vmalloc.h> 32#include <linux/vmalloc.h>
diff --git a/drivers/media/video/usbvision/usbvision-i2c.c b/drivers/media/video/usbvision/usbvision-i2c.c
index 0613922997e..083765238a6 100644
--- a/drivers/media/video/usbvision/usbvision-i2c.c
+++ b/drivers/media/video/usbvision/usbvision-i2c.c
@@ -27,7 +27,6 @@
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/slab.h>
31#include <linux/init.h> 30#include <linux/init.h>
32#include <asm/uaccess.h> 31#include <asm/uaccess.h>
33#include <linux/ioport.h> 32#include <linux/ioport.h>
diff --git a/drivers/media/video/uvc/uvc_ctrl.c b/drivers/media/video/uvc/uvc_ctrl.c
index 3b2e7800d56..6d3850b3716 100644
--- a/drivers/media/video/uvc/uvc_ctrl.c
+++ b/drivers/media/video/uvc/uvc_ctrl.c
@@ -14,6 +14,7 @@
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/list.h> 15#include <linux/list.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/slab.h>
17#include <linux/uaccess.h> 18#include <linux/uaccess.h>
18#include <linux/usb.h> 19#include <linux/usb.h>
19#include <linux/videodev2.h> 20#include <linux/videodev2.h>
diff --git a/drivers/media/video/uvc/uvc_driver.c b/drivers/media/video/uvc/uvc_driver.c
index a814820a3f6..86ff8c12ea5 100644
--- a/drivers/media/video/uvc/uvc_driver.c
+++ b/drivers/media/video/uvc/uvc_driver.c
@@ -26,6 +26,7 @@
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/list.h> 27#include <linux/list.h>
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/slab.h>
29#include <linux/usb.h> 30#include <linux/usb.h>
30#include <linux/videodev2.h> 31#include <linux/videodev2.h>
31#include <linux/vmalloc.h> 32#include <linux/vmalloc.h>
diff --git a/drivers/media/video/uvc/uvc_status.c b/drivers/media/video/uvc/uvc_status.c
index 1ca6dff7361..85019bdacdf 100644
--- a/drivers/media/video/uvc/uvc_status.c
+++ b/drivers/media/video/uvc/uvc_status.c
@@ -13,6 +13,7 @@
13 13
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/input.h> 15#include <linux/input.h>
16#include <linux/slab.h>
16#include <linux/usb.h> 17#include <linux/usb.h>
17#include <linux/usb/input.h> 18#include <linux/usb/input.h>
18 19
diff --git a/drivers/media/video/uvc/uvc_v4l2.c b/drivers/media/video/uvc/uvc_v4l2.c
index 43152aa5222..7c9ab293349 100644
--- a/drivers/media/video/uvc/uvc_v4l2.c
+++ b/drivers/media/video/uvc/uvc_v4l2.c
@@ -15,6 +15,7 @@
15#include <linux/version.h> 15#include <linux/version.h>
16#include <linux/list.h> 16#include <linux/list.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/slab.h>
18#include <linux/usb.h> 19#include <linux/usb.h>
19#include <linux/videodev2.h> 20#include <linux/videodev2.h>
20#include <linux/vmalloc.h> 21#include <linux/vmalloc.h>
diff --git a/drivers/media/video/uvc/uvc_video.c b/drivers/media/video/uvc/uvc_video.c
index 6b0666be370..821a9969b7b 100644
--- a/drivers/media/video/uvc/uvc_video.c
+++ b/drivers/media/video/uvc/uvc_video.c
@@ -14,6 +14,7 @@
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/list.h> 15#include <linux/list.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/slab.h>
17#include <linux/usb.h> 18#include <linux/usb.h>
18#include <linux/videodev2.h> 19#include <linux/videodev2.h>
19#include <linux/vmalloc.h> 20#include <linux/vmalloc.h>
diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c
index 4b11257c318..7d59c107f13 100644
--- a/drivers/media/video/v4l2-ioctl.c
+++ b/drivers/media/video/v4l2-ioctl.c
@@ -13,6 +13,7 @@
13 */ 13 */
14 14
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/slab.h>
16#include <linux/types.h> 17#include <linux/types.h>
17#include <linux/kernel.h> 18#include <linux/kernel.h>
18 19
diff --git a/drivers/media/video/videobuf-dma-contig.c b/drivers/media/video/videobuf-dma-contig.c
index 22c01097e8a..dce4f3aa4af 100644
--- a/drivers/media/video/videobuf-dma-contig.c
+++ b/drivers/media/video/videobuf-dma-contig.c
@@ -20,6 +20,7 @@
20#include <linux/pagemap.h> 20#include <linux/pagemap.h>
21#include <linux/dma-mapping.h> 21#include <linux/dma-mapping.h>
22#include <linux/sched.h> 22#include <linux/sched.h>
23#include <linux/slab.h>
23#include <media/videobuf-dma-contig.h> 24#include <media/videobuf-dma-contig.h>
24 25
25struct videobuf_dma_contig_memory { 26struct videobuf_dma_contig_memory {
diff --git a/drivers/media/video/videobuf-dvb.c b/drivers/media/video/videobuf-dvb.c
index a56cf0d3a6d..0afb62e63d9 100644
--- a/drivers/media/video/videobuf-dvb.c
+++ b/drivers/media/video/videobuf-dvb.c
@@ -19,6 +19,7 @@
19#include <linux/fs.h> 19#include <linux/fs.h>
20#include <linux/kthread.h> 20#include <linux/kthread.h>
21#include <linux/file.h> 21#include <linux/file.h>
22#include <linux/slab.h>
22 23
23#include <linux/freezer.h> 24#include <linux/freezer.h>
24 25
diff --git a/drivers/media/video/vino.c b/drivers/media/video/vino.c
index a15d1e7cbed..3eb15f72ac0 100644
--- a/drivers/media/video/vino.c
+++ b/drivers/media/video/vino.c
@@ -33,6 +33,7 @@
33#include <linux/fs.h> 33#include <linux/fs.h>
34#include <linux/interrupt.h> 34#include <linux/interrupt.h>
35#include <linux/kernel.h> 35#include <linux/kernel.h>
36#include <linux/slab.h>
36#include <linux/mm.h> 37#include <linux/mm.h>
37#include <linux/time.h> 38#include <linux/time.h>
38#include <linux/version.h> 39#include <linux/version.h>
diff --git a/drivers/media/video/vp27smpx.c b/drivers/media/video/vp27smpx.c
index 38e53b303cc..ca8303bd240 100644
--- a/drivers/media/video/vp27smpx.c
+++ b/drivers/media/video/vp27smpx.c
@@ -23,6 +23,7 @@
23 23
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/types.h> 25#include <linux/types.h>
26#include <linux/slab.h>
26#include <linux/ioctl.h> 27#include <linux/ioctl.h>
27#include <asm/uaccess.h> 28#include <asm/uaccess.h>
28#include <linux/i2c.h> 29#include <linux/i2c.h>
diff --git a/drivers/media/video/vpx3220.c b/drivers/media/video/vpx3220.c
index 33205d7537d..77ebcea7c3d 100644
--- a/drivers/media/video/vpx3220.c
+++ b/drivers/media/video/vpx3220.c
@@ -22,6 +22,7 @@
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/types.h> 24#include <linux/types.h>
25#include <linux/slab.h>
25#include <asm/uaccess.h> 26#include <asm/uaccess.h>
26#include <linux/i2c.h> 27#include <linux/i2c.h>
27#include <linux/videodev2.h> 28#include <linux/videodev2.h>
diff --git a/drivers/media/video/w9966.c b/drivers/media/video/w9966.c
index dcade619cbd..bf9bf650a31 100644
--- a/drivers/media/video/w9966.c
+++ b/drivers/media/video/w9966.c
@@ -58,6 +58,7 @@
58#include <linux/init.h> 58#include <linux/init.h>
59#include <linux/delay.h> 59#include <linux/delay.h>
60#include <linux/videodev.h> 60#include <linux/videodev.h>
61#include <linux/slab.h>
61#include <media/v4l2-common.h> 62#include <media/v4l2-common.h>
62#include <media/v4l2-ioctl.h> 63#include <media/v4l2-ioctl.h>
63#include <linux/parport.h> 64#include <linux/parport.h>
diff --git a/drivers/media/video/wm8739.c b/drivers/media/video/wm8739.c
index b572ce288e1..a11b99b4226 100644
--- a/drivers/media/video/wm8739.c
+++ b/drivers/media/video/wm8739.c
@@ -23,6 +23,7 @@
23 23
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/types.h> 25#include <linux/types.h>
26#include <linux/slab.h>
26#include <linux/ioctl.h> 27#include <linux/ioctl.h>
27#include <asm/uaccess.h> 28#include <asm/uaccess.h>
28#include <linux/i2c.h> 29#include <linux/i2c.h>
diff --git a/drivers/media/video/wm8775.c b/drivers/media/video/wm8775.c
index f1f261a3524..5c2ba599c0c 100644
--- a/drivers/media/video/wm8775.c
+++ b/drivers/media/video/wm8775.c
@@ -27,6 +27,7 @@
27 27
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/types.h> 29#include <linux/types.h>
30#include <linux/slab.h>
30#include <linux/ioctl.h> 31#include <linux/ioctl.h>
31#include <asm/uaccess.h> 32#include <asm/uaccess.h>
32#include <linux/i2c.h> 33#include <linux/i2c.h>
diff --git a/drivers/media/video/zoran/zoran_card.c b/drivers/media/video/zoran/zoran_card.c
index be70574870d..bfcd3aef50f 100644
--- a/drivers/media/video/zoran/zoran_card.c
+++ b/drivers/media/video/zoran/zoran_card.c
@@ -34,6 +34,7 @@
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/vmalloc.h> 36#include <linux/vmalloc.h>
37#include <linux/slab.h>
37 38
38#include <linux/proc_fs.h> 39#include <linux/proc_fs.h>
39#include <linux/i2c.h> 40#include <linux/i2c.h>
diff --git a/drivers/memstick/core/memstick.c b/drivers/memstick/core/memstick.c
index b3bf1c44d74..c00fe8253c5 100644
--- a/drivers/memstick/core/memstick.c
+++ b/drivers/memstick/core/memstick.c
@@ -16,6 +16,7 @@
16#include <linux/idr.h> 16#include <linux/idr.h>
17#include <linux/fs.h> 17#include <linux/fs.h>
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/slab.h>
19 20
20#define DRIVER_NAME "memstick" 21#define DRIVER_NAME "memstick"
21 22
diff --git a/drivers/memstick/core/mspro_block.c b/drivers/memstick/core/mspro_block.c
index 972b87069d5..8327e248520 100644
--- a/drivers/memstick/core/mspro_block.c
+++ b/drivers/memstick/core/mspro_block.c
@@ -17,6 +17,7 @@
17#include <linux/hdreg.h> 17#include <linux/hdreg.h>
18#include <linux/kthread.h> 18#include <linux/kthread.h>
19#include <linux/delay.h> 19#include <linux/delay.h>
20#include <linux/slab.h>
20#include <linux/memstick.h> 21#include <linux/memstick.h>
21 22
22#define DRIVER_NAME "mspro_block" 23#define DRIVER_NAME "mspro_block"
diff --git a/drivers/memstick/host/jmb38x_ms.c b/drivers/memstick/host/jmb38x_ms.c
index f4a162a4bec..f2b894cd8b0 100644
--- a/drivers/memstick/host/jmb38x_ms.c
+++ b/drivers/memstick/host/jmb38x_ms.c
@@ -16,6 +16,7 @@
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/highmem.h> 17#include <linux/highmem.h>
18#include <linux/memstick.h> 18#include <linux/memstick.h>
19#include <linux/slab.h>
19 20
20#define DRIVER_NAME "jmb38x_ms" 21#define DRIVER_NAME "jmb38x_ms"
21 22
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index 612ab3c51a6..33f7256055b 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -54,6 +54,7 @@
54#include <linux/reboot.h> /* notifier code */ 54#include <linux/reboot.h> /* notifier code */
55#include <linux/workqueue.h> 55#include <linux/workqueue.h>
56#include <linux/sort.h> 56#include <linux/sort.h>
57#include <linux/slab.h>
57 58
58#include <scsi/scsi.h> 59#include <scsi/scsi.h>
59#include <scsi/scsi_cmnd.h> 60#include <scsi/scsi_cmnd.h>
diff --git a/drivers/message/fusion/mptlan.c b/drivers/message/fusion/mptlan.c
index 34f3f36f819..4fa9665cbe9 100644
--- a/drivers/message/fusion/mptlan.c
+++ b/drivers/message/fusion/mptlan.c
@@ -57,6 +57,7 @@
57#include <linux/module.h> 57#include <linux/module.h>
58#include <linux/fs.h> 58#include <linux/fs.h>
59#include <linux/sched.h> 59#include <linux/sched.h>
60#include <linux/slab.h>
60 61
61#define my_VERSION MPT_LINUX_VERSION_COMMON 62#define my_VERSION MPT_LINUX_VERSION_COMMON
62#define MYNAM "mptlan" 63#define MYNAM "mptlan"
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index c20bbe45da8..76687126b57 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -45,6 +45,7 @@
45 45
46#include <linux/module.h> 46#include <linux/module.h>
47#include <linux/kernel.h> 47#include <linux/kernel.h>
48#include <linux/slab.h>
48#include <linux/init.h> 49#include <linux/init.h>
49#include <linux/errno.h> 50#include <linux/errno.h>
50#include <linux/jiffies.h> 51#include <linux/jiffies.h>
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index 4a7d1afcb66..6796597dcee 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -46,6 +46,7 @@
46 46
47#include <linux/module.h> 47#include <linux/module.h>
48#include <linux/kernel.h> 48#include <linux/kernel.h>
49#include <linux/slab.h>
49#include <linux/init.h> 50#include <linux/init.h>
50#include <linux/errno.h> 51#include <linux/errno.h>
51#include <linux/kdev_t.h> 52#include <linux/kdev_t.h>
diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c
index 69f4257419b..e44365193fd 100644
--- a/drivers/message/fusion/mptspi.c
+++ b/drivers/message/fusion/mptspi.c
@@ -46,6 +46,7 @@
46 46
47#include <linux/module.h> 47#include <linux/module.h>
48#include <linux/kernel.h> 48#include <linux/kernel.h>
49#include <linux/slab.h>
49#include <linux/init.h> 50#include <linux/init.h>
50#include <linux/errno.h> 51#include <linux/errno.h>
51#include <linux/kdev_t.h> 52#include <linux/kdev_t.h>
diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c
index 2658b1484a2..fc593fbab69 100644
--- a/drivers/message/i2o/i2o_block.c
+++ b/drivers/message/i2o/i2o_block.c
@@ -51,6 +51,7 @@
51 */ 51 */
52 52
53#include <linux/module.h> 53#include <linux/module.h>
54#include <linux/slab.h>
54#include <linux/i2o.h> 55#include <linux/i2o.h>
55 56
56#include <linux/mempool.h> 57#include <linux/mempool.h>
diff --git a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c
index 3d5f40cd69d..11073fa3d9f 100644
--- a/drivers/message/i2o/i2o_config.c
+++ b/drivers/message/i2o/i2o_config.c
@@ -33,6 +33,7 @@
33#include <linux/miscdevice.h> 33#include <linux/miscdevice.h>
34#include <linux/smp_lock.h> 34#include <linux/smp_lock.h>
35#include <linux/compat.h> 35#include <linux/compat.h>
36#include <linux/slab.h>
36 37
37#include <asm/uaccess.h> 38#include <asm/uaccess.h>
38 39
diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
index 949a648f8e2..07dbeaf9df9 100644
--- a/drivers/message/i2o/i2o_proc.c
+++ b/drivers/message/i2o/i2o_proc.c
@@ -40,6 +40,7 @@
40#include <linux/kernel.h> 40#include <linux/kernel.h>
41#include <linux/pci.h> 41#include <linux/pci.h>
42#include <linux/i2o.h> 42#include <linux/i2o.h>
43#include <linux/slab.h>
43#include <linux/proc_fs.h> 44#include <linux/proc_fs.h>
44#include <linux/seq_file.h> 45#include <linux/seq_file.h>
45#include <linux/init.h> 46#include <linux/init.h>
diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
index ef5ce2676f0..090d2a3a654 100644
--- a/drivers/message/i2o/iop.c
+++ b/drivers/message/i2o/iop.c
@@ -29,6 +29,7 @@
29#include <linux/i2o.h> 29#include <linux/i2o.h>
30#include <linux/delay.h> 30#include <linux/delay.h>
31#include <linux/sched.h> 31#include <linux/sched.h>
32#include <linux/slab.h>
32#include "core.h" 33#include "core.h"
33 34
34#define OSM_NAME "i2o" 35#define OSM_NAME "i2o"
diff --git a/drivers/message/i2o/pci.c b/drivers/message/i2o/pci.c
index 35ba2ae38b4..73e4658af53 100644
--- a/drivers/message/i2o/pci.c
+++ b/drivers/message/i2o/pci.c
@@ -29,6 +29,7 @@
29 29
30#include <linux/pci.h> 30#include <linux/pci.h>
31#include <linux/interrupt.h> 31#include <linux/interrupt.h>
32#include <linux/slab.h>
32#include <linux/i2o.h> 33#include <linux/i2o.h>
33#include "core.h" 34#include "core.h"
34 35
diff --git a/drivers/mfd/88pm860x-i2c.c b/drivers/mfd/88pm860x-i2c.c
index c37e12bf300..4a6e7186334 100644
--- a/drivers/mfd/88pm860x-i2c.c
+++ b/drivers/mfd/88pm860x-i2c.c
@@ -13,6 +13,7 @@
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <linux/i2c.h> 14#include <linux/i2c.h>
15#include <linux/mfd/88pm860x.h> 15#include <linux/mfd/88pm860x.h>
16#include <linux/slab.h>
16 17
17static inline int pm860x_read_device(struct i2c_client *i2c, 18static inline int pm860x_read_device(struct i2c_client *i2c,
18 int reg, int bytes, void *dest) 19 int reg, int bytes, void *dest)
diff --git a/drivers/mfd/ab3100-core.c b/drivers/mfd/ab3100-core.c
index a2ce3b6af4a..e4ca5909e42 100644
--- a/drivers/mfd/ab3100-core.c
+++ b/drivers/mfd/ab3100-core.c
@@ -10,6 +10,7 @@
10#include <linux/mutex.h> 10#include <linux/mutex.h>
11#include <linux/list.h> 11#include <linux/list.h>
12#include <linux/notifier.h> 12#include <linux/notifier.h>
13#include <linux/slab.h>
13#include <linux/err.h> 14#include <linux/err.h>
14#include <linux/platform_device.h> 15#include <linux/platform_device.h>
15#include <linux/device.h> 16#include <linux/device.h>
diff --git a/drivers/mfd/ab3100-otp.c b/drivers/mfd/ab3100-otp.c
index b603469dff6..2d14655fdeb 100644
--- a/drivers/mfd/ab3100-otp.c
+++ b/drivers/mfd/ab3100-otp.c
@@ -9,6 +9,7 @@
9 9
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/slab.h>
12#include <linux/init.h> 13#include <linux/init.h>
13#include <linux/platform_device.h> 14#include <linux/platform_device.h>
14#include <linux/mfd/ab3100.h> 15#include <linux/mfd/ab3100.h>
diff --git a/drivers/mfd/ab4500-core.c b/drivers/mfd/ab4500-core.c
index 1c44c19e073..c275daa3ab1 100644
--- a/drivers/mfd/ab4500-core.c
+++ b/drivers/mfd/ab4500-core.c
@@ -15,6 +15,7 @@
15 * Interrupt management to be added - TODO. 15 * Interrupt management to be added - TODO.
16 */ 16 */
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/slab.h>
18#include <linux/init.h> 19#include <linux/init.h>
19#include <linux/module.h> 20#include <linux/module.h>
20#include <linux/platform_device.h> 21#include <linux/platform_device.h>
diff --git a/drivers/mfd/adp5520.c b/drivers/mfd/adp5520.c
index b26644772d0..00553286565 100644
--- a/drivers/mfd/adp5520.c
+++ b/drivers/mfd/adp5520.c
@@ -21,6 +21,7 @@
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/slab.h>
24#include <linux/interrupt.h> 25#include <linux/interrupt.h>
25#include <linux/irq.h> 26#include <linux/irq.h>
26#include <linux/err.h> 27#include <linux/err.h>
diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c
index 95c1e6bd172..7de708d15d7 100644
--- a/drivers/mfd/asic3.c
+++ b/drivers/mfd/asic3.c
@@ -21,6 +21,7 @@
21#include <linux/irq.h> 21#include <linux/irq.h>
22#include <linux/gpio.h> 22#include <linux/gpio.h>
23#include <linux/io.h> 23#include <linux/io.h>
24#include <linux/slab.h>
24#include <linux/spinlock.h> 25#include <linux/spinlock.h>
25#include <linux/platform_device.h> 26#include <linux/platform_device.h>
26 27
diff --git a/drivers/mfd/da903x.c b/drivers/mfd/da903x.c
index e5ffe561739..67181b147ab 100644
--- a/drivers/mfd/da903x.c
+++ b/drivers/mfd/da903x.c
@@ -18,6 +18,7 @@
18#include <linux/platform_device.h> 18#include <linux/platform_device.h>
19#include <linux/i2c.h> 19#include <linux/i2c.h>
20#include <linux/mfd/da903x.h> 20#include <linux/mfd/da903x.h>
21#include <linux/slab.h>
21 22
22#define DA9030_CHIP_ID 0x00 23#define DA9030_CHIP_ID 0x00
23#define DA9030_EVENT_A 0x01 24#define DA9030_EVENT_A 0x01
diff --git a/drivers/mfd/ezx-pcap.c b/drivers/mfd/ezx-pcap.c
index df405af968f..134c69aa479 100644
--- a/drivers/mfd/ezx-pcap.c
+++ b/drivers/mfd/ezx-pcap.c
@@ -18,6 +18,7 @@
18#include <linux/mfd/ezx-pcap.h> 18#include <linux/mfd/ezx-pcap.h>
19#include <linux/spi/spi.h> 19#include <linux/spi/spi.h>
20#include <linux/gpio.h> 20#include <linux/gpio.h>
21#include <linux/slab.h>
21 22
22#define PCAP_ADC_MAXQ 8 23#define PCAP_ADC_MAXQ 8
23struct pcap_adc_request { 24struct pcap_adc_request {
diff --git a/drivers/mfd/htc-egpio.c b/drivers/mfd/htc-egpio.c
index addb846c1e3..d3e74f8585e 100644
--- a/drivers/mfd/htc-egpio.c
+++ b/drivers/mfd/htc-egpio.c
@@ -15,6 +15,7 @@
15#include <linux/io.h> 15#include <linux/io.h>
16#include <linux/spinlock.h> 16#include <linux/spinlock.h>
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/slab.h>
18#include <linux/module.h> 19#include <linux/module.h>
19#include <linux/mfd/htc-egpio.h> 20#include <linux/mfd/htc-egpio.h>
20 21
diff --git a/drivers/mfd/htc-i2cpld.c b/drivers/mfd/htc-i2cpld.c
index 37b9fdab4f3..594c9a8e25e 100644
--- a/drivers/mfd/htc-i2cpld.c
+++ b/drivers/mfd/htc-i2cpld.c
@@ -35,6 +35,7 @@
35#include <linux/spinlock.h> 35#include <linux/spinlock.h>
36#include <linux/htcpld.h> 36#include <linux/htcpld.h>
37#include <linux/gpio.h> 37#include <linux/gpio.h>
38#include <linux/slab.h>
38 39
39struct htcpld_chip { 40struct htcpld_chip {
40 spinlock_t lock; 41 spinlock_t lock;
diff --git a/drivers/mfd/htc-pasic3.c b/drivers/mfd/htc-pasic3.c
index cb73051e43d..f04300e05fd 100644
--- a/drivers/mfd/htc-pasic3.c
+++ b/drivers/mfd/htc-pasic3.c
@@ -19,6 +19,7 @@
19#include <linux/mfd/core.h> 19#include <linux/mfd/core.h>
20#include <linux/mfd/ds1wm.h> 20#include <linux/mfd/ds1wm.h>
21#include <linux/mfd/htc-pasic3.h> 21#include <linux/mfd/htc-pasic3.h>
22#include <linux/slab.h>
22 23
23struct pasic3_data { 24struct pasic3_data {
24 void __iomem *mapping; 25 void __iomem *mapping;
diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
index c0b883c14f4..d9fd8785da4 100644
--- a/drivers/mfd/max8925-i2c.c
+++ b/drivers/mfd/max8925-i2c.c
@@ -13,6 +13,7 @@
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <linux/i2c.h> 14#include <linux/i2c.h>
15#include <linux/mfd/max8925.h> 15#include <linux/mfd/max8925.h>
16#include <linux/slab.h>
16 17
17#define RTC_I2C_ADDR 0x68 18#define RTC_I2C_ADDR 0x68
18#define ADC_I2C_ADDR 0x47 19#define ADC_I2C_ADDR 0x47
diff --git a/drivers/mfd/mc13783-core.c b/drivers/mfd/mc13783-core.c
index 62a847e4c2d..1f68ecadddc 100644
--- a/drivers/mfd/mc13783-core.c
+++ b/drivers/mfd/mc13783-core.c
@@ -9,6 +9,7 @@
9 * the terms of the GNU General Public License version 2 as published by the 9 * the terms of the GNU General Public License version 2 as published by the
10 * Free Software Foundation. 10 * Free Software Foundation.
11 */ 11 */
12#include <linux/slab.h>
12#include <linux/module.h> 13#include <linux/module.h>
13#include <linux/spi/spi.h> 14#include <linux/spi/spi.h>
14#include <linux/mfd/core.h> 15#include <linux/mfd/core.h>
diff --git a/drivers/mfd/mcp-sa11x0.c b/drivers/mfd/mcp-sa11x0.c
index 25842723272..2dab02d9ac8 100644
--- a/drivers/mfd/mcp-sa11x0.c
+++ b/drivers/mfd/mcp-sa11x0.c
@@ -17,7 +17,6 @@
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/spinlock.h> 19#include <linux/spinlock.h>
20#include <linux/slab.h>
21#include <linux/platform_device.h> 20#include <linux/platform_device.h>
22#include <linux/mfd/mcp.h> 21#include <linux/mfd/mcp.h>
23 22
diff --git a/drivers/mfd/menelaus.c b/drivers/mfd/menelaus.c
index 970afa10326..a94b131a18e 100644
--- a/drivers/mfd/menelaus.c
+++ b/drivers/mfd/menelaus.c
@@ -40,6 +40,7 @@
40#include <linux/delay.h> 40#include <linux/delay.h>
41#include <linux/rtc.h> 41#include <linux/rtc.h>
42#include <linux/bcd.h> 42#include <linux/bcd.h>
43#include <linux/slab.h>
43 44
44#include <asm/mach/irq.h> 45#include <asm/mach/irq.h>
45 46
diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
index aa17f4bddc5..8ffbb7a85a7 100644
--- a/drivers/mfd/mfd-core.c
+++ b/drivers/mfd/mfd-core.c
@@ -15,6 +15,7 @@
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/acpi.h> 16#include <linux/acpi.h>
17#include <linux/mfd/core.h> 17#include <linux/mfd/core.h>
18#include <linux/slab.h>
18 19
19static int mfd_add_device(struct device *parent, int id, 20static int mfd_add_device(struct device *parent, int id,
20 const struct mfd_cell *cell, 21 const struct mfd_cell *cell,
diff --git a/drivers/mfd/pcf50633-adc.c b/drivers/mfd/pcf50633-adc.c
index 6d2e8466df1..fe8f922f665 100644
--- a/drivers/mfd/pcf50633-adc.c
+++ b/drivers/mfd/pcf50633-adc.c
@@ -17,6 +17,7 @@
17 */ 17 */
18 18
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/slab.h>
20#include <linux/module.h> 21#include <linux/module.h>
21#include <linux/init.h> 22#include <linux/init.h>
22#include <linux/device.h> 23#include <linux/device.h>
diff --git a/drivers/mfd/pcf50633-core.c b/drivers/mfd/pcf50633-core.c
index 03dcc920070..63a614d696c 100644
--- a/drivers/mfd/pcf50633-core.c
+++ b/drivers/mfd/pcf50633-core.c
@@ -22,6 +22,7 @@
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/i2c.h> 23#include <linux/i2c.h>
24#include <linux/irq.h> 24#include <linux/irq.h>
25#include <linux/slab.h>
25 26
26#include <linux/mfd/pcf50633/core.h> 27#include <linux/mfd/pcf50633/core.h>
27 28
diff --git a/drivers/mfd/sh_mobile_sdhi.c b/drivers/mfd/sh_mobile_sdhi.c
index 468fd366d4d..497f91b6138 100644
--- a/drivers/mfd/sh_mobile_sdhi.c
+++ b/drivers/mfd/sh_mobile_sdhi.c
@@ -20,6 +20,7 @@
20 20
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/clk.h> 22#include <linux/clk.h>
23#include <linux/slab.h>
23#include <linux/platform_device.h> 24#include <linux/platform_device.h>
24#include <linux/mmc/host.h> 25#include <linux/mmc/host.h>
25#include <linux/mfd/core.h> 26#include <linux/mfd/core.h>
diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
index 7b6652f6011..bc9275c1213 100644
--- a/drivers/mfd/sm501.c
+++ b/drivers/mfd/sm501.c
@@ -20,6 +20,7 @@
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/pci.h> 21#include <linux/pci.h>
22#include <linux/i2c-gpio.h> 22#include <linux/i2c-gpio.h>
23#include <linux/slab.h>
23 24
24#include <linux/sm501.h> 25#include <linux/sm501.h>
25#include <linux/sm501-regs.h> 26#include <linux/sm501-regs.h>
diff --git a/drivers/mfd/t7l66xb.c b/drivers/mfd/t7l66xb.c
index 26d9176fca9..da6383a934a 100644
--- a/drivers/mfd/t7l66xb.c
+++ b/drivers/mfd/t7l66xb.c
@@ -26,6 +26,7 @@
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/err.h> 27#include <linux/err.h>
28#include <linux/io.h> 28#include <linux/io.h>
29#include <linux/slab.h>
29#include <linux/irq.h> 30#include <linux/irq.h>
30#include <linux/clk.h> 31#include <linux/clk.h>
31#include <linux/platform_device.h> 32#include <linux/platform_device.h>
diff --git a/drivers/mfd/tc6387xb.c b/drivers/mfd/tc6387xb.c
index 5c7f04343d5..517f9bcdeaa 100644
--- a/drivers/mfd/tc6387xb.c
+++ b/drivers/mfd/tc6387xb.c
@@ -17,6 +17,7 @@
17#include <linux/mfd/core.h> 17#include <linux/mfd/core.h>
18#include <linux/mfd/tmio.h> 18#include <linux/mfd/tmio.h>
19#include <linux/mfd/tc6387xb.h> 19#include <linux/mfd/tc6387xb.h>
20#include <linux/slab.h>
20 21
21enum { 22enum {
22 TC6387XB_CELL_MMC, 23 TC6387XB_CELL_MMC,
diff --git a/drivers/mfd/tc6393xb.c b/drivers/mfd/tc6393xb.c
index c59e5c5737d..fcf9068810f 100644
--- a/drivers/mfd/tc6393xb.c
+++ b/drivers/mfd/tc6393xb.c
@@ -25,6 +25,7 @@
25#include <linux/mfd/tmio.h> 25#include <linux/mfd/tmio.h>
26#include <linux/mfd/tc6393xb.h> 26#include <linux/mfd/tc6393xb.h>
27#include <linux/gpio.h> 27#include <linux/gpio.h>
28#include <linux/slab.h>
28 29
29#define SCR_REVID 0x08 /* b Revision ID */ 30#define SCR_REVID 0x08 /* b Revision ID */
30#define SCR_ISR 0x50 /* b Interrupt Status */ 31#define SCR_ISR 0x50 /* b Interrupt Status */
diff --git a/drivers/mfd/timberdale.c b/drivers/mfd/timberdale.c
index 1ed44d28380..7f478ec4184 100644
--- a/drivers/mfd/timberdale.c
+++ b/drivers/mfd/timberdale.c
@@ -25,6 +25,7 @@
25#include <linux/pci.h> 25#include <linux/pci.h>
26#include <linux/msi.h> 26#include <linux/msi.h>
27#include <linux/mfd/core.h> 27#include <linux/mfd/core.h>
28#include <linux/slab.h>
28 29
29#include <linux/timb_gpio.h> 30#include <linux/timb_gpio.h>
30 31
diff --git a/drivers/mfd/twl4030-codec.c b/drivers/mfd/twl4030-codec.c
index 700b149c1b9..add6f67d803 100644
--- a/drivers/mfd/twl4030-codec.c
+++ b/drivers/mfd/twl4030-codec.c
@@ -23,6 +23,7 @@
23 23
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/types.h> 25#include <linux/types.h>
26#include <linux/slab.h>
26#include <linux/kernel.h> 27#include <linux/kernel.h>
27#include <linux/fs.h> 28#include <linux/fs.h>
28#include <linux/platform_device.h> 29#include <linux/platform_device.h>
diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
index 9df9a5ad38f..202bdd59632 100644
--- a/drivers/mfd/twl4030-irq.c
+++ b/drivers/mfd/twl4030-irq.c
@@ -31,6 +31,7 @@
31#include <linux/interrupt.h> 31#include <linux/interrupt.h>
32#include <linux/irq.h> 32#include <linux/irq.h>
33#include <linux/kthread.h> 33#include <linux/kthread.h>
34#include <linux/slab.h>
34 35
35#include <linux/i2c/twl.h> 36#include <linux/i2c/twl.h>
36 37
diff --git a/drivers/mfd/ucb1400_core.c b/drivers/mfd/ucb1400_core.c
index 85fd9421be9..dbe280153f9 100644
--- a/drivers/mfd/ucb1400_core.c
+++ b/drivers/mfd/ucb1400_core.c
@@ -22,6 +22,7 @@
22 22
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/sched.h> 24#include <linux/sched.h>
25#include <linux/slab.h>
25#include <linux/ucb1400.h> 26#include <linux/ucb1400.h>
26 27
27unsigned int ucb1400_adc_read(struct snd_ac97 *ac97, u16 adc_channel, 28unsigned int ucb1400_adc_read(struct snd_ac97 *ac97, u16 adc_channel,
diff --git a/drivers/mfd/wm831x-core.c b/drivers/mfd/wm831x-core.c
index 07101e9e1cb..a3d5728b644 100644
--- a/drivers/mfd/wm831x-core.c
+++ b/drivers/mfd/wm831x-core.c
@@ -18,6 +18,7 @@
18#include <linux/bcd.h> 18#include <linux/bcd.h>
19#include <linux/delay.h> 19#include <linux/delay.h>
20#include <linux/mfd/core.h> 20#include <linux/mfd/core.h>
21#include <linux/slab.h>
21 22
22#include <linux/mfd/wm831x/core.h> 23#include <linux/mfd/wm831x/core.h>
23#include <linux/mfd/wm831x/pdata.h> 24#include <linux/mfd/wm831x/pdata.h>
diff --git a/drivers/mfd/wm8350-core.c b/drivers/mfd/wm8350-core.c
index bd75807d530..e400a3bed06 100644
--- a/drivers/mfd/wm8350-core.c
+++ b/drivers/mfd/wm8350-core.c
@@ -15,6 +15,7 @@
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/slab.h>
18#include <linux/bug.h> 19#include <linux/bug.h>
19#include <linux/device.h> 20#include <linux/device.h>
20#include <linux/delay.h> 21#include <linux/delay.h>
diff --git a/drivers/mfd/wm8350-i2c.c b/drivers/mfd/wm8350-i2c.c
index 8d8c9321757..65830f57c09 100644
--- a/drivers/mfd/wm8350-i2c.c
+++ b/drivers/mfd/wm8350-i2c.c
@@ -19,6 +19,7 @@
19#include <linux/i2c.h> 19#include <linux/i2c.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/mfd/wm8350/core.h> 21#include <linux/mfd/wm8350/core.h>
22#include <linux/slab.h>
22 23
23static int wm8350_i2c_read_device(struct wm8350 *wm8350, char reg, 24static int wm8350_i2c_read_device(struct wm8350 *wm8350, char reg,
24 int bytes, void *dest) 25 int bytes, void *dest)
diff --git a/drivers/mfd/wm8400-core.c b/drivers/mfd/wm8400-core.c
index ecfc8bbe89b..865ce013a82 100644
--- a/drivers/mfd/wm8400-core.c
+++ b/drivers/mfd/wm8400-core.c
@@ -18,6 +18,7 @@
18#include <linux/mfd/core.h> 18#include <linux/mfd/core.h>
19#include <linux/mfd/wm8400-private.h> 19#include <linux/mfd/wm8400-private.h>
20#include <linux/mfd/wm8400-audio.h> 20#include <linux/mfd/wm8400-audio.h>
21#include <linux/slab.h>
21 22
22static struct { 23static struct {
23 u16 readable; /* Mask of readable bits */ 24 u16 readable; /* Mask of readable bits */
diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c
index 844e1c1b7d9..cc524df10aa 100644
--- a/drivers/mfd/wm8994-core.c
+++ b/drivers/mfd/wm8994-core.c
@@ -14,6 +14,7 @@
14 14
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/slab.h>
17#include <linux/i2c.h> 18#include <linux/i2c.h>
18#include <linux/delay.h> 19#include <linux/delay.h>
19#include <linux/mfd/core.h> 20#include <linux/mfd/core.h>
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 2191c8d896a..0d0d625fece 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -311,6 +311,22 @@ config TI_DAC7512
311 This driver can also be built as a module. If so, the module 311 This driver can also be built as a module. If so, the module
312 will be calles ti_dac7512. 312 will be calles ti_dac7512.
313 313
314config VMWARE_BALLOON
315 tristate "VMware Balloon Driver"
316 depends on X86
317 help
318 This is VMware physical memory management driver which acts
319 like a "balloon" that can be inflated to reclaim physical pages
320 by reserving them in the guest and invalidating them in the
321 monitor, freeing up the underlying machine pages so they can
322 be allocated to other guests. The balloon can also be deflated
323 to allow the guest to use more physical memory.
324
325 If unsure, say N.
326
327 To compile this driver as a module, choose M here: the
328 module will be called vmware_balloon.
329
314source "drivers/misc/c2port/Kconfig" 330source "drivers/misc/c2port/Kconfig"
315source "drivers/misc/eeprom/Kconfig" 331source "drivers/misc/eeprom/Kconfig"
316source "drivers/misc/cb710/Kconfig" 332source "drivers/misc/cb710/Kconfig"
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 27c48435541..7b6f7eefdf8 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -29,3 +29,4 @@ obj-$(CONFIG_C2PORT) += c2port/
29obj-$(CONFIG_IWMC3200TOP) += iwmc3200top/ 29obj-$(CONFIG_IWMC3200TOP) += iwmc3200top/
30obj-y += eeprom/ 30obj-y += eeprom/
31obj-y += cb710/ 31obj-y += cb710/
32obj-$(CONFIG_VMWARE_BALLOON) += vmware_balloon.o
diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c
index 558bf3f2c27..4afffe610f9 100644
--- a/drivers/misc/atmel-ssc.c
+++ b/drivers/misc/atmel-ssc.c
@@ -15,6 +15,7 @@
15#include <linux/io.h> 15#include <linux/io.h>
16#include <linux/spinlock.h> 16#include <linux/spinlock.h>
17#include <linux/atmel-ssc.h> 17#include <linux/atmel-ssc.h>
18#include <linux/slab.h>
18 19
19/* Serialize access to ssc_list and user count */ 20/* Serialize access to ssc_list and user count */
20static DEFINE_SPINLOCK(user_lock); 21static DEFINE_SPINLOCK(user_lock);
diff --git a/drivers/misc/atmel_pwm.c b/drivers/misc/atmel_pwm.c
index 6aa5294dfec..0f3fb4f03bd 100644
--- a/drivers/misc/atmel_pwm.c
+++ b/drivers/misc/atmel_pwm.c
@@ -1,6 +1,7 @@
1#include <linux/module.h> 1#include <linux/module.h>
2#include <linux/clk.h> 2#include <linux/clk.h>
3#include <linux/err.h> 3#include <linux/err.h>
4#include <linux/slab.h>
4#include <linux/io.h> 5#include <linux/io.h>
5#include <linux/interrupt.h> 6#include <linux/interrupt.h>
6#include <linux/platform_device.h> 7#include <linux/platform_device.h>
diff --git a/drivers/misc/atmel_tclib.c b/drivers/misc/atmel_tclib.c
index 05dc8a31f28..3891124001f 100644
--- a/drivers/misc/atmel_tclib.c
+++ b/drivers/misc/atmel_tclib.c
@@ -6,6 +6,7 @@
6#include <linux/ioport.h> 6#include <linux/ioport.h>
7#include <linux/kernel.h> 7#include <linux/kernel.h>
8#include <linux/platform_device.h> 8#include <linux/platform_device.h>
9#include <linux/slab.h>
9 10
10/* Number of bytes to reserve for the iomem resource */ 11/* Number of bytes to reserve for the iomem resource */
11#define ATMEL_TC_IOMEM_SIZE 256 12#define ATMEL_TC_IOMEM_SIZE 256
diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
index b5346b4db91..ed090e77c9c 100644
--- a/drivers/misc/c2port/core.c
+++ b/drivers/misc/c2port/core.c
@@ -20,6 +20,7 @@
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include <linux/idr.h> 21#include <linux/idr.h>
22#include <linux/sched.h> 22#include <linux/sched.h>
23#include <linux/slab.h>
23 24
24#include <linux/c2port.h> 25#include <linux/c2port.h>
25 26
@@ -912,8 +913,8 @@ struct c2port_device *c2port_device_register(char *name,
912 913
913 c2dev->dev = device_create(c2port_class, NULL, 0, c2dev, 914 c2dev->dev = device_create(c2port_class, NULL, 0, c2dev,
914 "c2port%d", id); 915 "c2port%d", id);
915 if (unlikely(!c2dev->dev)) { 916 if (unlikely(IS_ERR(c2dev->dev))) {
916 ret = -ENOMEM; 917 ret = PTR_ERR(c2dev->dev);
917 goto error_device_create; 918 goto error_device_create;
918 } 919 }
919 dev_set_drvdata(c2dev->dev, c2dev); 920 dev_set_drvdata(c2dev->dev, c2dev);
diff --git a/drivers/misc/cb710/core.c b/drivers/misc/cb710/core.c
index b14eab0f2ba..efec4139c3f 100644
--- a/drivers/misc/cb710/core.c
+++ b/drivers/misc/cb710/core.c
@@ -9,11 +9,11 @@
9 */ 9 */
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/slab.h>
13#include <linux/pci.h> 12#include <linux/pci.h>
14#include <linux/spinlock.h> 13#include <linux/spinlock.h>
15#include <linux/idr.h> 14#include <linux/idr.h>
16#include <linux/cb710.h> 15#include <linux/cb710.h>
16#include <linux/gfp.h>
17 17
18static DEFINE_IDA(cb710_ida); 18static DEFINE_IDA(cb710_ida);
19static DEFINE_SPINLOCK(cb710_ida_lock); 19static DEFINE_SPINLOCK(cb710_ida_lock);
diff --git a/drivers/misc/cb710/debug.c b/drivers/misc/cb710/debug.c
index 02358d086e0..fcb3b8e30c5 100644
--- a/drivers/misc/cb710/debug.c
+++ b/drivers/misc/cb710/debug.c
@@ -10,7 +10,6 @@
10#include <linux/cb710.h> 10#include <linux/cb710.h>
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/slab.h>
14 13
15#define CB710_REG_COUNT 0x80 14#define CB710_REG_COUNT 0x80
16 15
diff --git a/drivers/misc/cs5535-mfgpt.c b/drivers/misc/cs5535-mfgpt.c
index 8110460558f..9bec24db4d4 100644
--- a/drivers/misc/cs5535-mfgpt.c
+++ b/drivers/misc/cs5535-mfgpt.c
@@ -18,6 +18,7 @@
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/pci.h> 19#include <linux/pci.h>
20#include <linux/cs5535.h> 20#include <linux/cs5535.h>
21#include <linux/slab.h>
21 22
22#define DRV_NAME "cs5535-mfgpt" 23#define DRV_NAME "cs5535-mfgpt"
23#define MFGPT_BAR 2 24#define MFGPT_BAR 2
diff --git a/drivers/misc/ds1682.c b/drivers/misc/ds1682.c
index f3ee4a1abb7..9197cfc5501 100644
--- a/drivers/misc/ds1682.c
+++ b/drivers/misc/ds1682.c
@@ -33,7 +33,6 @@
33 33
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/slab.h>
37#include <linux/i2c.h> 36#include <linux/i2c.h>
38#include <linux/string.h> 37#include <linux/string.h>
39#include <linux/list.h> 38#include <linux/list.h>
diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c
index 1eac626e710..48c84a58163 100644
--- a/drivers/misc/enclosure.c
+++ b/drivers/misc/enclosure.c
@@ -27,6 +27,7 @@
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/mutex.h> 29#include <linux/mutex.h>
30#include <linux/slab.h>
30 31
31static LIST_HEAD(container_list); 32static LIST_HEAD(container_list);
32static DEFINE_MUTEX(container_list_lock); 33static DEFINE_MUTEX(container_list_lock);
diff --git a/drivers/misc/ep93xx_pwm.c b/drivers/misc/ep93xx_pwm.c
index ba4694169d7..46b3439673e 100644
--- a/drivers/misc/ep93xx_pwm.c
+++ b/drivers/misc/ep93xx_pwm.c
@@ -19,6 +19,7 @@
19 19
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/slab.h>
22#include <linux/clk.h> 23#include <linux/clk.h>
23#include <linux/err.h> 24#include <linux/err.h>
24#include <linux/io.h> 25#include <linux/io.h>
diff --git a/drivers/misc/hpilo.c b/drivers/misc/hpilo.c
index a92a3a742b4..98ad0120aa9 100644
--- a/drivers/misc/hpilo.c
+++ b/drivers/misc/hpilo.c
@@ -25,6 +25,7 @@
25#include <linux/io.h> 25#include <linux/io.h>
26#include <linux/wait.h> 26#include <linux/wait.h>
27#include <linux/poll.h> 27#include <linux/poll.h>
28#include <linux/slab.h>
28#include "hpilo.h" 29#include "hpilo.h"
29 30
30static struct class *ilo_class; 31static struct class *ilo_class;
diff --git a/drivers/misc/ibmasm/command.c b/drivers/misc/ibmasm/command.c
index e2031739aa2..5c766b4fb23 100644
--- a/drivers/misc/ibmasm/command.c
+++ b/drivers/misc/ibmasm/command.c
@@ -23,6 +23,7 @@
23 */ 23 */
24 24
25#include <linux/sched.h> 25#include <linux/sched.h>
26#include <linux/slab.h>
26#include "ibmasm.h" 27#include "ibmasm.h"
27#include "lowlevel.h" 28#include "lowlevel.h"
28 29
diff --git a/drivers/misc/ibmasm/event.c b/drivers/misc/ibmasm/event.c
index 572d41ffc18..76bfda1ffaa 100644
--- a/drivers/misc/ibmasm/event.c
+++ b/drivers/misc/ibmasm/event.c
@@ -23,6 +23,7 @@
23 */ 23 */
24 24
25#include <linux/sched.h> 25#include <linux/sched.h>
26#include <linux/slab.h>
26#include "ibmasm.h" 27#include "ibmasm.h"
27#include "lowlevel.h" 28#include "lowlevel.h"
28 29
diff --git a/drivers/misc/ibmasm/ibmasmfs.c b/drivers/misc/ibmasm/ibmasmfs.c
index aecf40ecb3a..8844a3f4538 100644
--- a/drivers/misc/ibmasm/ibmasmfs.c
+++ b/drivers/misc/ibmasm/ibmasmfs.c
@@ -75,6 +75,7 @@
75 75
76#include <linux/fs.h> 76#include <linux/fs.h>
77#include <linux/pagemap.h> 77#include <linux/pagemap.h>
78#include <linux/slab.h>
78#include <asm/uaccess.h> 79#include <asm/uaccess.h>
79#include <asm/io.h> 80#include <asm/io.h>
80#include "ibmasm.h" 81#include "ibmasm.h"
diff --git a/drivers/misc/ibmasm/module.c b/drivers/misc/ibmasm/module.c
index dc14b0b9cbf..a234d965243 100644
--- a/drivers/misc/ibmasm/module.c
+++ b/drivers/misc/ibmasm/module.c
@@ -52,6 +52,7 @@
52 52
53#include <linux/pci.h> 53#include <linux/pci.h>
54#include <linux/init.h> 54#include <linux/init.h>
55#include <linux/slab.h>
55#include "ibmasm.h" 56#include "ibmasm.h"
56#include "lowlevel.h" 57#include "lowlevel.h"
57#include "remote.h" 58#include "remote.h"
diff --git a/drivers/misc/ics932s401.c b/drivers/misc/ics932s401.c
index 395a4ea64e9..152e9d93eec 100644
--- a/drivers/misc/ics932s401.c
+++ b/drivers/misc/ics932s401.c
@@ -26,6 +26,7 @@
26#include <linux/mutex.h> 26#include <linux/mutex.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/log2.h> 28#include <linux/log2.h>
29#include <linux/slab.h>
29 30
30/* Addresses to scan */ 31/* Addresses to scan */
31static const unsigned short normal_i2c[] = { 0x69, I2C_CLIENT_END }; 32static const unsigned short normal_i2c[] = { 0x69, I2C_CLIENT_END };
diff --git a/drivers/misc/ioc4.c b/drivers/misc/ioc4.c
index 09dcb699e66..193206602d8 100644
--- a/drivers/misc/ioc4.c
+++ b/drivers/misc/ioc4.c
@@ -30,6 +30,7 @@
30#include <linux/pci.h> 30#include <linux/pci.h>
31#include <linux/ioc4.h> 31#include <linux/ioc4.h>
32#include <linux/ktime.h> 32#include <linux/ktime.h>
33#include <linux/slab.h>
33#include <linux/mutex.h> 34#include <linux/mutex.h>
34#include <linux/time.h> 35#include <linux/time.h>
35#include <asm/io.h> 36#include <asm/io.h>
diff --git a/drivers/misc/iwmc3200top/debugfs.c b/drivers/misc/iwmc3200top/debugfs.c
index 0c8ea0a1c8a..e9eda471f6e 100644
--- a/drivers/misc/iwmc3200top/debugfs.c
+++ b/drivers/misc/iwmc3200top/debugfs.c
@@ -25,6 +25,7 @@
25 */ 25 */
26 26
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/slab.h>
28#include <linux/string.h> 29#include <linux/string.h>
29#include <linux/ctype.h> 30#include <linux/ctype.h>
30#include <linux/mmc/sdio_func.h> 31#include <linux/mmc/sdio_func.h>
diff --git a/drivers/misc/iwmc3200top/fw-download.c b/drivers/misc/iwmc3200top/fw-download.c
index 9dbaeb574e6..e27afde6e99 100644
--- a/drivers/misc/iwmc3200top/fw-download.c
+++ b/drivers/misc/iwmc3200top/fw-download.c
@@ -26,6 +26,7 @@
26 26
27#include <linux/firmware.h> 27#include <linux/firmware.h>
28#include <linux/mmc/sdio_func.h> 28#include <linux/mmc/sdio_func.h>
29#include <linux/slab.h>
29#include <asm/unaligned.h> 30#include <asm/unaligned.h>
30 31
31#include "iwmc3200top.h" 32#include "iwmc3200top.h"
diff --git a/drivers/misc/iwmc3200top/log.c b/drivers/misc/iwmc3200top/log.c
index d569279698f..a36a55a49ca 100644
--- a/drivers/misc/iwmc3200top/log.c
+++ b/drivers/misc/iwmc3200top/log.c
@@ -26,6 +26,7 @@
26 26
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/mmc/sdio_func.h> 28#include <linux/mmc/sdio_func.h>
29#include <linux/slab.h>
29#include <linux/ctype.h> 30#include <linux/ctype.h>
30#include "fw-msg.h" 31#include "fw-msg.h"
31#include "iwmc3200top.h" 32#include "iwmc3200top.h"
diff --git a/drivers/misc/iwmc3200top/main.c b/drivers/misc/iwmc3200top/main.c
index 3b7292a5cea..c73cef2c3c5 100644
--- a/drivers/misc/iwmc3200top/main.c
+++ b/drivers/misc/iwmc3200top/main.c
@@ -25,6 +25,7 @@
25 */ 25 */
26 26
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/slab.h>
28#include <linux/init.h> 29#include <linux/init.h>
29#include <linux/kernel.h> 30#include <linux/kernel.h>
30#include <linux/debugfs.h> 31#include <linux/debugfs.h>
diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
index fcb6ec1af17..72450237a0f 100644
--- a/drivers/misc/kgdbts.c
+++ b/drivers/misc/kgdbts.c
@@ -295,6 +295,10 @@ static int check_and_rewind_pc(char *put_str, char *arg)
295 /* On x86 a breakpoint stop requires it to be decremented */ 295 /* On x86 a breakpoint stop requires it to be decremented */
296 if (addr + 1 == kgdbts_regs.ip) 296 if (addr + 1 == kgdbts_regs.ip)
297 offset = -1; 297 offset = -1;
298#elif defined(CONFIG_SUPERH)
299 /* On SUPERH a breakpoint stop requires it to be decremented */
300 if (addr + 2 == kgdbts_regs.pc)
301 offset = -2;
298#endif 302#endif
299 if (strcmp(arg, "silent") && 303 if (strcmp(arg, "silent") &&
300 instruction_pointer(&kgdbts_regs) + offset != addr) { 304 instruction_pointer(&kgdbts_regs) + offset != addr) {
@@ -305,6 +309,8 @@ static int check_and_rewind_pc(char *put_str, char *arg)
305#ifdef CONFIG_X86 309#ifdef CONFIG_X86
306 /* On x86 adjust the instruction pointer if needed */ 310 /* On x86 adjust the instruction pointer if needed */
307 kgdbts_regs.ip += offset; 311 kgdbts_regs.ip += offset;
312#elif defined(CONFIG_SUPERH)
313 kgdbts_regs.pc += offset;
308#endif 314#endif
309 return 0; 315 return 0;
310} 316}
diff --git a/drivers/misc/lkdtm.c b/drivers/misc/lkdtm.c
index 4a0648301fd..31a991161f0 100644
--- a/drivers/misc/lkdtm.c
+++ b/drivers/misc/lkdtm.c
@@ -40,6 +40,7 @@
40#include <linux/init.h> 40#include <linux/init.h>
41#include <linux/interrupt.h> 41#include <linux/interrupt.h>
42#include <linux/hrtimer.h> 42#include <linux/hrtimer.h>
43#include <linux/slab.h>
43#include <scsi/scsi_cmnd.h> 44#include <scsi/scsi_cmnd.h>
44#include <linux/debugfs.h> 45#include <linux/debugfs.h>
45 46
diff --git a/drivers/misc/phantom.c b/drivers/misc/phantom.c
index 779aa8ebe4c..75ee0d3f6f4 100644
--- a/drivers/misc/phantom.c
+++ b/drivers/misc/phantom.c
@@ -21,6 +21,7 @@
21#include <linux/poll.h> 21#include <linux/poll.h>
22#include <linux/interrupt.h> 22#include <linux/interrupt.h>
23#include <linux/cdev.h> 23#include <linux/cdev.h>
24#include <linux/slab.h>
24#include <linux/phantom.h> 25#include <linux/phantom.h>
25#include <linux/sched.h> 26#include <linux/sched.h>
26#include <linux/smp_lock.h> 27#include <linux/smp_lock.h>
diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
index 832ed4c88cf..8d082b46426 100644
--- a/drivers/misc/sgi-xp/xpc_main.c
+++ b/drivers/misc/sgi-xp/xpc_main.c
@@ -44,6 +44,7 @@
44 */ 44 */
45 45
46#include <linux/module.h> 46#include <linux/module.h>
47#include <linux/slab.h>
47#include <linux/sysctl.h> 48#include <linux/sysctl.h>
48#include <linux/device.h> 49#include <linux/device.h>
49#include <linux/delay.h> 50#include <linux/delay.h>
diff --git a/drivers/misc/sgi-xp/xpc_partition.c b/drivers/misc/sgi-xp/xpc_partition.c
index 9a6268c89fd..d551f09ccb7 100644
--- a/drivers/misc/sgi-xp/xpc_partition.c
+++ b/drivers/misc/sgi-xp/xpc_partition.c
@@ -17,6 +17,7 @@
17 17
18#include <linux/device.h> 18#include <linux/device.h>
19#include <linux/hardirq.h> 19#include <linux/hardirq.h>
20#include <linux/slab.h>
20#include "xpc.h" 21#include "xpc.h"
21#include <asm/uv/uv_hub.h> 22#include <asm/uv/uv_hub.h>
22 23
diff --git a/drivers/misc/sgi-xp/xpc_sn2.c b/drivers/misc/sgi-xp/xpc_sn2.c
index 8b70e03f939..7d71c04fc93 100644
--- a/drivers/misc/sgi-xp/xpc_sn2.c
+++ b/drivers/misc/sgi-xp/xpc_sn2.c
@@ -14,6 +14,7 @@
14 */ 14 */
15 15
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/slab.h>
17#include <asm/uncached.h> 18#include <asm/uncached.h>
18#include <asm/sn/mspec.h> 19#include <asm/sn/mspec.h>
19#include <asm/sn/sn_sal.h> 20#include <asm/sn/sn_sal.h>
diff --git a/drivers/misc/sgi-xp/xpc_uv.c b/drivers/misc/sgi-xp/xpc_uv.c
index 8725d5e8ab0..1f59ee2226c 100644
--- a/drivers/misc/sgi-xp/xpc_uv.c
+++ b/drivers/misc/sgi-xp/xpc_uv.c
@@ -19,6 +19,7 @@
19#include <linux/delay.h> 19#include <linux/delay.h>
20#include <linux/device.h> 20#include <linux/device.h>
21#include <linux/err.h> 21#include <linux/err.h>
22#include <linux/slab.h>
22#include <asm/uv/uv_hub.h> 23#include <asm/uv/uv_hub.h>
23#if defined CONFIG_X86_64 24#if defined CONFIG_X86_64
24#include <asm/uv/bios.h> 25#include <asm/uv/bios.h>
diff --git a/drivers/misc/sgi-xp/xpnet.c b/drivers/misc/sgi-xp/xpnet.c
index 57b152f8d1b..ee5109a3cd9 100644
--- a/drivers/misc/sgi-xp/xpnet.c
+++ b/drivers/misc/sgi-xp/xpnet.c
@@ -20,6 +20,7 @@
20 * 20 *
21 */ 21 */
22 22
23#include <linux/slab.h>
23#include <linux/module.h> 24#include <linux/module.h>
24#include <linux/netdevice.h> 25#include <linux/netdevice.h>
25#include <linux/etherdevice.h> 26#include <linux/etherdevice.h>
diff --git a/drivers/misc/tifm_core.c b/drivers/misc/tifm_core.c
index 98bcba521da..5f6852dff40 100644
--- a/drivers/misc/tifm_core.c
+++ b/drivers/misc/tifm_core.c
@@ -10,6 +10,7 @@
10 */ 10 */
11 11
12#include <linux/tifm.h> 12#include <linux/tifm.h>
13#include <linux/slab.h>
13#include <linux/init.h> 14#include <linux/init.h>
14#include <linux/idr.h> 15#include <linux/idr.h>
15 16
diff --git a/drivers/misc/vmware_balloon.c b/drivers/misc/vmware_balloon.c
new file mode 100644
index 00000000000..e7161c4e379
--- /dev/null
+++ b/drivers/misc/vmware_balloon.c
@@ -0,0 +1,832 @@
1/*
2 * VMware Balloon driver.
3 *
4 * Copyright (C) 2000-2010, VMware, Inc. All Rights Reserved.
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; version 2 of the License and no later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
13 * NON INFRINGEMENT. See the GNU General Public License for more
14 * 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 * Maintained by: Dmitry Torokhov <dtor@vmware.com>
21 */
22
23/*
24 * This is VMware physical memory management driver for Linux. The driver
25 * acts like a "balloon" that can be inflated to reclaim physical pages by
26 * reserving them in the guest and invalidating them in the monitor,
27 * freeing up the underlying machine pages so they can be allocated to
28 * other guests. The balloon can also be deflated to allow the guest to
29 * use more physical memory. Higher level policies can control the sizes
30 * of balloons in VMs in order to manage physical memory resources.
31 */
32
33//#define DEBUG
34#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
35
36#include <linux/types.h>
37#include <linux/kernel.h>
38#include <linux/mm.h>
39#include <linux/sched.h>
40#include <linux/module.h>
41#include <linux/workqueue.h>
42#include <linux/debugfs.h>
43#include <linux/seq_file.h>
44#include <asm/vmware.h>
45
46MODULE_AUTHOR("VMware, Inc.");
47MODULE_DESCRIPTION("VMware Memory Control (Balloon) Driver");
48MODULE_VERSION("1.2.1.0-K");
49MODULE_ALIAS("dmi:*:svnVMware*:*");
50MODULE_ALIAS("vmware_vmmemctl");
51MODULE_LICENSE("GPL");
52
53/*
54 * Various constants controlling rate of inflaint/deflating balloon,
55 * measured in pages.
56 */
57
58/*
59 * Rate of allocating memory when there is no memory pressure
60 * (driver performs non-sleeping allocations).
61 */
62#define VMW_BALLOON_NOSLEEP_ALLOC_MAX 16384U
63
64/*
65 * Rates of memory allocaton when guest experiences memory pressure
66 * (driver performs sleeping allocations).
67 */
68#define VMW_BALLOON_RATE_ALLOC_MIN 512U
69#define VMW_BALLOON_RATE_ALLOC_MAX 2048U
70#define VMW_BALLOON_RATE_ALLOC_INC 16U
71
72/*
73 * Rates for releasing pages while deflating balloon.
74 */
75#define VMW_BALLOON_RATE_FREE_MIN 512U
76#define VMW_BALLOON_RATE_FREE_MAX 16384U
77#define VMW_BALLOON_RATE_FREE_INC 16U
78
79/*
80 * When guest is under memory pressure, use a reduced page allocation
81 * rate for next several cycles.
82 */
83#define VMW_BALLOON_SLOW_CYCLES 4
84
85/*
86 * Use __GFP_HIGHMEM to allow pages from HIGHMEM zone. We don't
87 * allow wait (__GFP_WAIT) for NOSLEEP page allocations. Use
88 * __GFP_NOWARN, to suppress page allocation failure warnings.
89 */
90#define VMW_PAGE_ALLOC_NOSLEEP (__GFP_HIGHMEM|__GFP_NOWARN)
91
92/*
93 * Use GFP_HIGHUSER when executing in a separate kernel thread
94 * context and allocation can sleep. This is less stressful to
95 * the guest memory system, since it allows the thread to block
96 * while memory is reclaimed, and won't take pages from emergency
97 * low-memory pools.
98 */
99#define VMW_PAGE_ALLOC_CANSLEEP (GFP_HIGHUSER)
100
101/* Maximum number of page allocations without yielding processor */
102#define VMW_BALLOON_YIELD_THRESHOLD 1024
103
104
105/*
106 * Hypervisor communication port definitions.
107 */
108#define VMW_BALLOON_HV_PORT 0x5670
109#define VMW_BALLOON_HV_MAGIC 0x456c6d6f
110#define VMW_BALLOON_PROTOCOL_VERSION 2
111#define VMW_BALLOON_GUEST_ID 1 /* Linux */
112
113#define VMW_BALLOON_CMD_START 0
114#define VMW_BALLOON_CMD_GET_TARGET 1
115#define VMW_BALLOON_CMD_LOCK 2
116#define VMW_BALLOON_CMD_UNLOCK 3
117#define VMW_BALLOON_CMD_GUEST_ID 4
118
119/* error codes */
120#define VMW_BALLOON_SUCCESS 0
121#define VMW_BALLOON_FAILURE -1
122#define VMW_BALLOON_ERROR_CMD_INVALID 1
123#define VMW_BALLOON_ERROR_PPN_INVALID 2
124#define VMW_BALLOON_ERROR_PPN_LOCKED 3
125#define VMW_BALLOON_ERROR_PPN_UNLOCKED 4
126#define VMW_BALLOON_ERROR_PPN_PINNED 5
127#define VMW_BALLOON_ERROR_PPN_NOTNEEDED 6
128#define VMW_BALLOON_ERROR_RESET 7
129#define VMW_BALLOON_ERROR_BUSY 8
130
131#define VMWARE_BALLOON_CMD(cmd, data, result) \
132({ \
133 unsigned long __stat, __dummy1, __dummy2; \
134 __asm__ __volatile__ ("inl (%%dx)" : \
135 "=a"(__stat), \
136 "=c"(__dummy1), \
137 "=d"(__dummy2), \
138 "=b"(result) : \
139 "0"(VMW_BALLOON_HV_MAGIC), \
140 "1"(VMW_BALLOON_CMD_##cmd), \
141 "2"(VMW_BALLOON_HV_PORT), \
142 "3"(data) : \
143 "memory"); \
144 result &= -1UL; \
145 __stat & -1UL; \
146})
147
148#ifdef CONFIG_DEBUG_FS
149struct vmballoon_stats {
150 unsigned int timer;
151
152 /* allocation statustics */
153 unsigned int alloc;
154 unsigned int alloc_fail;
155 unsigned int sleep_alloc;
156 unsigned int sleep_alloc_fail;
157 unsigned int refused_alloc;
158 unsigned int refused_free;
159 unsigned int free;
160
161 /* monitor operations */
162 unsigned int lock;
163 unsigned int lock_fail;
164 unsigned int unlock;
165 unsigned int unlock_fail;
166 unsigned int target;
167 unsigned int target_fail;
168 unsigned int start;
169 unsigned int start_fail;
170 unsigned int guest_type;
171 unsigned int guest_type_fail;
172};
173
174#define STATS_INC(stat) (stat)++
175#else
176#define STATS_INC(stat)
177#endif
178
179struct vmballoon {
180
181 /* list of reserved physical pages */
182 struct list_head pages;
183
184 /* transient list of non-balloonable pages */
185 struct list_head refused_pages;
186
187 /* balloon size in pages */
188 unsigned int size;
189 unsigned int target;
190
191 /* reset flag */
192 bool reset_required;
193
194 /* adjustment rates (pages per second) */
195 unsigned int rate_alloc;
196 unsigned int rate_free;
197
198 /* slowdown page allocations for next few cycles */
199 unsigned int slow_allocation_cycles;
200
201#ifdef CONFIG_DEBUG_FS
202 /* statistics */
203 struct vmballoon_stats stats;
204
205 /* debugfs file exporting statistics */
206 struct dentry *dbg_entry;
207#endif
208
209 struct sysinfo sysinfo;
210
211 struct delayed_work dwork;
212};
213
214static struct vmballoon balloon;
215static struct workqueue_struct *vmballoon_wq;
216
217/*
218 * Send "start" command to the host, communicating supported version
219 * of the protocol.
220 */
221static bool vmballoon_send_start(struct vmballoon *b)
222{
223 unsigned long status, dummy;
224
225 STATS_INC(b->stats.start);
226
227 status = VMWARE_BALLOON_CMD(START, VMW_BALLOON_PROTOCOL_VERSION, dummy);
228 if (status == VMW_BALLOON_SUCCESS)
229 return true;
230
231 pr_debug("%s - failed, hv returns %ld\n", __func__, status);
232 STATS_INC(b->stats.start_fail);
233 return false;
234}
235
236static bool vmballoon_check_status(struct vmballoon *b, unsigned long status)
237{
238 switch (status) {
239 case VMW_BALLOON_SUCCESS:
240 return true;
241
242 case VMW_BALLOON_ERROR_RESET:
243 b->reset_required = true;
244 /* fall through */
245
246 default:
247 return false;
248 }
249}
250
251/*
252 * Communicate guest type to the host so that it can adjust ballooning
253 * algorithm to the one most appropriate for the guest. This command
254 * is normally issued after sending "start" command and is part of
255 * standard reset sequence.
256 */
257static bool vmballoon_send_guest_id(struct vmballoon *b)
258{
259 unsigned long status, dummy;
260
261 status = VMWARE_BALLOON_CMD(GUEST_ID, VMW_BALLOON_GUEST_ID, dummy);
262
263 STATS_INC(b->stats.guest_type);
264
265 if (vmballoon_check_status(b, status))
266 return true;
267
268 pr_debug("%s - failed, hv returns %ld\n", __func__, status);
269 STATS_INC(b->stats.guest_type_fail);
270 return false;
271}
272
273/*
274 * Retrieve desired balloon size from the host.
275 */
276static bool vmballoon_send_get_target(struct vmballoon *b, u32 *new_target)
277{
278 unsigned long status;
279 unsigned long target;
280 unsigned long limit;
281 u32 limit32;
282
283 /*
284 * si_meminfo() is cheap. Moreover, we want to provide dynamic
285 * max balloon size later. So let us call si_meminfo() every
286 * iteration.
287 */
288 si_meminfo(&b->sysinfo);
289 limit = b->sysinfo.totalram;
290
291 /* Ensure limit fits in 32-bits */
292 limit32 = (u32)limit;
293 if (limit != limit32)
294 return false;
295
296 /* update stats */
297 STATS_INC(b->stats.target);
298
299 status = VMWARE_BALLOON_CMD(GET_TARGET, limit, target);
300 if (vmballoon_check_status(b, status)) {
301 *new_target = target;
302 return true;
303 }
304
305 pr_debug("%s - failed, hv returns %ld\n", __func__, status);
306 STATS_INC(b->stats.target_fail);
307 return false;
308}
309
310/*
311 * Notify the host about allocated page so that host can use it without
312 * fear that guest will need it. Host may reject some pages, we need to
313 * check the return value and maybe submit a different page.
314 */
315static bool vmballoon_send_lock_page(struct vmballoon *b, unsigned long pfn)
316{
317 unsigned long status, dummy;
318 u32 pfn32;
319
320 pfn32 = (u32)pfn;
321 if (pfn32 != pfn)
322 return false;
323
324 STATS_INC(b->stats.lock);
325
326 status = VMWARE_BALLOON_CMD(LOCK, pfn, dummy);
327 if (vmballoon_check_status(b, status))
328 return true;
329
330 pr_debug("%s - ppn %lx, hv returns %ld\n", __func__, pfn, status);
331 STATS_INC(b->stats.lock_fail);
332 return false;
333}
334
335/*
336 * Notify the host that guest intends to release given page back into
337 * the pool of available (to the guest) pages.
338 */
339static bool vmballoon_send_unlock_page(struct vmballoon *b, unsigned long pfn)
340{
341 unsigned long status, dummy;
342 u32 pfn32;
343
344 pfn32 = (u32)pfn;
345 if (pfn32 != pfn)
346 return false;
347
348 STATS_INC(b->stats.unlock);
349
350 status = VMWARE_BALLOON_CMD(UNLOCK, pfn, dummy);
351 if (vmballoon_check_status(b, status))
352 return true;
353
354 pr_debug("%s - ppn %lx, hv returns %ld\n", __func__, pfn, status);
355 STATS_INC(b->stats.unlock_fail);
356 return false;
357}
358
359/*
360 * Quickly release all pages allocated for the balloon. This function is
361 * called when host decides to "reset" balloon for one reason or another.
362 * Unlike normal "deflate" we do not (shall not) notify host of the pages
363 * being released.
364 */
365static void vmballoon_pop(struct vmballoon *b)
366{
367 struct page *page, *next;
368 unsigned int count = 0;
369
370 list_for_each_entry_safe(page, next, &b->pages, lru) {
371 list_del(&page->lru);
372 __free_page(page);
373 STATS_INC(b->stats.free);
374 b->size--;
375
376 if (++count >= b->rate_free) {
377 count = 0;
378 cond_resched();
379 }
380 }
381}
382
383/*
384 * Perform standard reset sequence by popping the balloon (in case it
385 * is not empty) and then restarting protocol. This operation normally
386 * happens when host responds with VMW_BALLOON_ERROR_RESET to a command.
387 */
388static void vmballoon_reset(struct vmballoon *b)
389{
390 /* free all pages, skipping monitor unlock */
391 vmballoon_pop(b);
392
393 if (vmballoon_send_start(b)) {
394 b->reset_required = false;
395 if (!vmballoon_send_guest_id(b))
396 pr_err("failed to send guest ID to the host\n");
397 }
398}
399
400/*
401 * Allocate (or reserve) a page for the balloon and notify the host. If host
402 * refuses the page put it on "refuse" list and allocate another one until host
403 * is satisfied. "Refused" pages are released at the end of inflation cycle
404 * (when we allocate b->rate_alloc pages).
405 */
406static int vmballoon_reserve_page(struct vmballoon *b, bool can_sleep)
407{
408 struct page *page;
409 gfp_t flags;
410 bool locked = false;
411
412 do {
413 if (!can_sleep)
414 STATS_INC(b->stats.alloc);
415 else
416 STATS_INC(b->stats.sleep_alloc);
417
418 flags = can_sleep ? VMW_PAGE_ALLOC_CANSLEEP : VMW_PAGE_ALLOC_NOSLEEP;
419 page = alloc_page(flags);
420 if (!page) {
421 if (!can_sleep)
422 STATS_INC(b->stats.alloc_fail);
423 else
424 STATS_INC(b->stats.sleep_alloc_fail);
425 return -ENOMEM;
426 }
427
428 /* inform monitor */
429 locked = vmballoon_send_lock_page(b, page_to_pfn(page));
430 if (!locked) {
431 if (b->reset_required) {
432 __free_page(page);
433 return -EIO;
434 }
435
436 /* place on list of non-balloonable pages, retry allocation */
437 list_add(&page->lru, &b->refused_pages);
438 STATS_INC(b->stats.refused_alloc);
439 }
440 } while (!locked);
441
442 /* track allocated page */
443 list_add(&page->lru, &b->pages);
444
445 /* update balloon size */
446 b->size++;
447
448 return 0;
449}
450
451/*
452 * Release the page allocated for the balloon. Note that we first notify
453 * the host so it can make sure the page will be available for the guest
454 * to use, if needed.
455 */
456static int vmballoon_release_page(struct vmballoon *b, struct page *page)
457{
458 if (!vmballoon_send_unlock_page(b, page_to_pfn(page)))
459 return -EIO;
460
461 list_del(&page->lru);
462
463 /* deallocate page */
464 __free_page(page);
465 STATS_INC(b->stats.free);
466
467 /* update balloon size */
468 b->size--;
469
470 return 0;
471}
472
473/*
474 * Release pages that were allocated while attempting to inflate the
475 * balloon but were refused by the host for one reason or another.
476 */
477static void vmballoon_release_refused_pages(struct vmballoon *b)
478{
479 struct page *page, *next;
480
481 list_for_each_entry_safe(page, next, &b->refused_pages, lru) {
482 list_del(&page->lru);
483 __free_page(page);
484 STATS_INC(b->stats.refused_free);
485 }
486}
487
488/*
489 * Inflate the balloon towards its target size. Note that we try to limit
490 * the rate of allocation to make sure we are not choking the rest of the
491 * system.
492 */
493static void vmballoon_inflate(struct vmballoon *b)
494{
495 unsigned int goal;
496 unsigned int rate;
497 unsigned int i;
498 unsigned int allocations = 0;
499 int error = 0;
500 bool alloc_can_sleep = false;
501
502 pr_debug("%s - size: %d, target %d\n", __func__, b->size, b->target);
503
504 /*
505 * First try NOSLEEP page allocations to inflate balloon.
506 *
507 * If we do not throttle nosleep allocations, we can drain all
508 * free pages in the guest quickly (if the balloon target is high).
509 * As a side-effect, draining free pages helps to inform (force)
510 * the guest to start swapping if balloon target is not met yet,
511 * which is a desired behavior. However, balloon driver can consume
512 * all available CPU cycles if too many pages are allocated in a
513 * second. Therefore, we throttle nosleep allocations even when
514 * the guest is not under memory pressure. OTOH, if we have already
515 * predicted that the guest is under memory pressure, then we
516 * slowdown page allocations considerably.
517 */
518
519 goal = b->target - b->size;
520 /*
521 * Start with no sleep allocation rate which may be higher
522 * than sleeping allocation rate.
523 */
524 rate = b->slow_allocation_cycles ?
525 b->rate_alloc : VMW_BALLOON_NOSLEEP_ALLOC_MAX;
526
527 pr_debug("%s - goal: %d, no-sleep rate: %d, sleep rate: %d\n",
528 __func__, goal, rate, b->rate_alloc);
529
530 for (i = 0; i < goal; i++) {
531
532 error = vmballoon_reserve_page(b, alloc_can_sleep);
533 if (error) {
534 if (error != -ENOMEM) {
535 /*
536 * Not a page allocation failure, stop this
537 * cycle. Maybe we'll get new target from
538 * the host soon.
539 */
540 break;
541 }
542
543 if (alloc_can_sleep) {
544 /*
545 * CANSLEEP page allocation failed, so guest
546 * is under severe memory pressure. Quickly
547 * decrease allocation rate.
548 */
549 b->rate_alloc = max(b->rate_alloc / 2,
550 VMW_BALLOON_RATE_ALLOC_MIN);
551 break;
552 }
553
554 /*
555 * NOSLEEP page allocation failed, so the guest is
556 * under memory pressure. Let us slow down page
557 * allocations for next few cycles so that the guest
558 * gets out of memory pressure. Also, if we already
559 * allocated b->rate_alloc pages, let's pause,
560 * otherwise switch to sleeping allocations.
561 */
562 b->slow_allocation_cycles = VMW_BALLOON_SLOW_CYCLES;
563
564 if (i >= b->rate_alloc)
565 break;
566
567 alloc_can_sleep = true;
568 /* Lower rate for sleeping allocations. */
569 rate = b->rate_alloc;
570 }
571
572 if (++allocations > VMW_BALLOON_YIELD_THRESHOLD) {
573 cond_resched();
574 allocations = 0;
575 }
576
577 if (i >= rate) {
578 /* We allocated enough pages, let's take a break. */
579 break;
580 }
581 }
582
583 /*
584 * We reached our goal without failures so try increasing
585 * allocation rate.
586 */
587 if (error == 0 && i >= b->rate_alloc) {
588 unsigned int mult = i / b->rate_alloc;
589
590 b->rate_alloc =
591 min(b->rate_alloc + mult * VMW_BALLOON_RATE_ALLOC_INC,
592 VMW_BALLOON_RATE_ALLOC_MAX);
593 }
594
595 vmballoon_release_refused_pages(b);
596}
597
598/*
599 * Decrease the size of the balloon allowing guest to use more memory.
600 */
601static void vmballoon_deflate(struct vmballoon *b)
602{
603 struct page *page, *next;
604 unsigned int i = 0;
605 unsigned int goal;
606 int error;
607
608 pr_debug("%s - size: %d, target %d\n", __func__, b->size, b->target);
609
610 /* limit deallocation rate */
611 goal = min(b->size - b->target, b->rate_free);
612
613 pr_debug("%s - goal: %d, rate: %d\n", __func__, goal, b->rate_free);
614
615 /* free pages to reach target */
616 list_for_each_entry_safe(page, next, &b->pages, lru) {
617 error = vmballoon_release_page(b, page);
618 if (error) {
619 /* quickly decrease rate in case of error */
620 b->rate_free = max(b->rate_free / 2,
621 VMW_BALLOON_RATE_FREE_MIN);
622 return;
623 }
624
625 if (++i >= goal)
626 break;
627 }
628
629 /* slowly increase rate if there were no errors */
630 b->rate_free = min(b->rate_free + VMW_BALLOON_RATE_FREE_INC,
631 VMW_BALLOON_RATE_FREE_MAX);
632}
633
634/*
635 * Balloon work function: reset protocol, if needed, get the new size and
636 * adjust balloon as needed. Repeat in 1 sec.
637 */
638static void vmballoon_work(struct work_struct *work)
639{
640 struct delayed_work *dwork = to_delayed_work(work);
641 struct vmballoon *b = container_of(dwork, struct vmballoon, dwork);
642 unsigned int target;
643
644 STATS_INC(b->stats.timer);
645
646 if (b->reset_required)
647 vmballoon_reset(b);
648
649 if (b->slow_allocation_cycles > 0)
650 b->slow_allocation_cycles--;
651
652 if (vmballoon_send_get_target(b, &target)) {
653 /* update target, adjust size */
654 b->target = target;
655
656 if (b->size < target)
657 vmballoon_inflate(b);
658 else if (b->size > target)
659 vmballoon_deflate(b);
660 }
661
662 queue_delayed_work(vmballoon_wq, dwork, round_jiffies_relative(HZ));
663}
664
665/*
666 * DEBUGFS Interface
667 */
668#ifdef CONFIG_DEBUG_FS
669
670static int vmballoon_debug_show(struct seq_file *f, void *offset)
671{
672 struct vmballoon *b = f->private;
673 struct vmballoon_stats *stats = &b->stats;
674
675 /* format size info */
676 seq_printf(f,
677 "target: %8d pages\n"
678 "current: %8d pages\n",
679 b->target, b->size);
680
681 /* format rate info */
682 seq_printf(f,
683 "rateNoSleepAlloc: %8d pages/sec\n"
684 "rateSleepAlloc: %8d pages/sec\n"
685 "rateFree: %8d pages/sec\n",
686 VMW_BALLOON_NOSLEEP_ALLOC_MAX,
687 b->rate_alloc, b->rate_free);
688
689 seq_printf(f,
690 "\n"
691 "timer: %8u\n"
692 "start: %8u (%4u failed)\n"
693 "guestType: %8u (%4u failed)\n"
694 "lock: %8u (%4u failed)\n"
695 "unlock: %8u (%4u failed)\n"
696 "target: %8u (%4u failed)\n"
697 "primNoSleepAlloc: %8u (%4u failed)\n"
698 "primCanSleepAlloc: %8u (%4u failed)\n"
699 "primFree: %8u\n"
700 "errAlloc: %8u\n"
701 "errFree: %8u\n",
702 stats->timer,
703 stats->start, stats->start_fail,
704 stats->guest_type, stats->guest_type_fail,
705 stats->lock, stats->lock_fail,
706 stats->unlock, stats->unlock_fail,
707 stats->target, stats->target_fail,
708 stats->alloc, stats->alloc_fail,
709 stats->sleep_alloc, stats->sleep_alloc_fail,
710 stats->free,
711 stats->refused_alloc, stats->refused_free);
712
713 return 0;
714}
715
716static int vmballoon_debug_open(struct inode *inode, struct file *file)
717{
718 return single_open(file, vmballoon_debug_show, inode->i_private);
719}
720
721static const struct file_operations vmballoon_debug_fops = {
722 .owner = THIS_MODULE,
723 .open = vmballoon_debug_open,
724 .read = seq_read,
725 .llseek = seq_lseek,
726 .release = single_release,
727};
728
729static int __init vmballoon_debugfs_init(struct vmballoon *b)
730{
731 int error;
732
733 b->dbg_entry = debugfs_create_file("vmmemctl", S_IRUGO, NULL, b,
734 &vmballoon_debug_fops);
735 if (IS_ERR(b->dbg_entry)) {
736 error = PTR_ERR(b->dbg_entry);
737 pr_err("failed to create debugfs entry, error: %d\n", error);
738 return error;
739 }
740
741 return 0;
742}
743
744static void __exit vmballoon_debugfs_exit(struct vmballoon *b)
745{
746 debugfs_remove(b->dbg_entry);
747}
748
749#else
750
751static inline int vmballoon_debugfs_init(struct vmballoon *b)
752{
753 return 0;
754}
755
756static inline void vmballoon_debugfs_exit(struct vmballoon *b)
757{
758}
759
760#endif /* CONFIG_DEBUG_FS */
761
762static int __init vmballoon_init(void)
763{
764 int error;
765
766 /*
767 * Check if we are running on VMware's hypervisor and bail out
768 * if we are not.
769 */
770 if (!vmware_platform())
771 return -ENODEV;
772
773 vmballoon_wq = create_freezeable_workqueue("vmmemctl");
774 if (!vmballoon_wq) {
775 pr_err("failed to create workqueue\n");
776 return -ENOMEM;
777 }
778
779 INIT_LIST_HEAD(&balloon.pages);
780 INIT_LIST_HEAD(&balloon.refused_pages);
781
782 /* initialize rates */
783 balloon.rate_alloc = VMW_BALLOON_RATE_ALLOC_MAX;
784 balloon.rate_free = VMW_BALLOON_RATE_FREE_MAX;
785
786 INIT_DELAYED_WORK(&balloon.dwork, vmballoon_work);
787
788 /*
789 * Start balloon.
790 */
791 if (!vmballoon_send_start(&balloon)) {
792 pr_err("failed to send start command to the host\n");
793 error = -EIO;
794 goto fail;
795 }
796
797 if (!vmballoon_send_guest_id(&balloon)) {
798 pr_err("failed to send guest ID to the host\n");
799 error = -EIO;
800 goto fail;
801 }
802
803 error = vmballoon_debugfs_init(&balloon);
804 if (error)
805 goto fail;
806
807 queue_delayed_work(vmballoon_wq, &balloon.dwork, 0);
808
809 return 0;
810
811fail:
812 destroy_workqueue(vmballoon_wq);
813 return error;
814}
815module_init(vmballoon_init);
816
817static void __exit vmballoon_exit(void)
818{
819 cancel_delayed_work_sync(&balloon.dwork);
820 destroy_workqueue(vmballoon_wq);
821
822 vmballoon_debugfs_exit(&balloon);
823
824 /*
825 * Deallocate all reserved memory, and reset connection with monitor.
826 * Reset connection before deallocating memory to avoid potential for
827 * additional spurious resets from guest touching deallocated pages.
828 */
829 vmballoon_send_start(&balloon);
830 vmballoon_pop(&balloon);
831}
832module_exit(vmballoon_exit);
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 1f552c6e757..cb9fbc83b09 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -23,6 +23,7 @@
23 23
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/fs.h> 25#include <linux/fs.h>
26#include <linux/slab.h>
26#include <linux/errno.h> 27#include <linux/errno.h>
27#include <linux/hdreg.h> 28#include <linux/hdreg.h>
28#include <linux/kdev_t.h> 29#include <linux/kdev_t.h>
diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c
index e7f8027165e..445d7db2277 100644
--- a/drivers/mmc/card/mmc_test.c
+++ b/drivers/mmc/card/mmc_test.c
@@ -13,6 +13,7 @@
13#include <linux/mmc/card.h> 13#include <linux/mmc/card.h>
14#include <linux/mmc/host.h> 14#include <linux/mmc/host.h>
15#include <linux/mmc/mmc.h> 15#include <linux/mmc/mmc.h>
16#include <linux/slab.h>
16 17
17#include <linux/scatterlist.h> 18#include <linux/scatterlist.h>
18 19
diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c
index 381fe032caa..d6ded247d94 100644
--- a/drivers/mmc/card/queue.c
+++ b/drivers/mmc/card/queue.c
@@ -9,6 +9,7 @@
9 * published by the Free Software Foundation. 9 * published by the Free Software Foundation.
10 * 10 *
11 */ 11 */
12#include <linux/slab.h>
12#include <linux/module.h> 13#include <linux/module.h>
13#include <linux/blkdev.h> 14#include <linux/blkdev.h>
14#include <linux/freezer.h> 15#include <linux/freezer.h>
diff --git a/drivers/mmc/card/sdio_uart.c b/drivers/mmc/card/sdio_uart.c
index 723e50894db..a0716967b7c 100644
--- a/drivers/mmc/card/sdio_uart.c
+++ b/drivers/mmc/card/sdio_uart.c
@@ -34,10 +34,10 @@
34#include <linux/seq_file.h> 34#include <linux/seq_file.h>
35#include <linux/serial_reg.h> 35#include <linux/serial_reg.h>
36#include <linux/circ_buf.h> 36#include <linux/circ_buf.h>
37#include <linux/gfp.h>
38#include <linux/tty.h> 37#include <linux/tty.h>
39#include <linux/tty_flip.h> 38#include <linux/tty_flip.h>
40#include <linux/kfifo.h> 39#include <linux/kfifo.h>
40#include <linux/slab.h>
41 41
42#include <linux/mmc/core.h> 42#include <linux/mmc/core.h>
43#include <linux/mmc/card.h> 43#include <linux/mmc/card.h>
diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
index bdb165f9304..49d9dcaeca4 100644
--- a/drivers/mmc/core/bus.c
+++ b/drivers/mmc/core/bus.c
@@ -13,6 +13,7 @@
13 13
14#include <linux/device.h> 14#include <linux/device.h>
15#include <linux/err.h> 15#include <linux/err.h>
16#include <linux/slab.h>
16 17
17#include <linux/mmc/card.h> 18#include <linux/mmc/card.h>
18#include <linux/mmc/host.h> 19#include <linux/mmc/host.h>
diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
index 96d10f40fb2..53cb380c098 100644
--- a/drivers/mmc/core/debugfs.c
+++ b/drivers/mmc/core/debugfs.c
@@ -10,6 +10,7 @@
10#include <linux/debugfs.h> 10#include <linux/debugfs.h>
11#include <linux/fs.h> 11#include <linux/fs.h>
12#include <linux/seq_file.h> 12#include <linux/seq_file.h>
13#include <linux/slab.h>
13#include <linux/stat.h> 14#include <linux/stat.h>
14 15
15#include <linux/mmc/card.h> 16#include <linux/mmc/card.h>
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index a268d12f1af..47353909e34 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -16,6 +16,7 @@
16#include <linux/idr.h> 16#include <linux/idr.h>
17#include <linux/pagemap.h> 17#include <linux/pagemap.h>
18#include <linux/leds.h> 18#include <linux/leds.h>
19#include <linux/slab.h>
19 20
20#include <linux/mmc/host.h> 21#include <linux/mmc/host.h>
21 22
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 0eac6c81490..89f7a25b7ac 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -11,6 +11,7 @@
11 */ 11 */
12 12
13#include <linux/err.h> 13#include <linux/err.h>
14#include <linux/slab.h>
14 15
15#include <linux/mmc/host.h> 16#include <linux/mmc/host.h>
16#include <linux/mmc/card.h> 17#include <linux/mmc/card.h>
@@ -225,7 +226,7 @@ static int mmc_read_ext_csd(struct mmc_card *card)
225 mmc_card_set_blockaddr(card); 226 mmc_card_set_blockaddr(card);
226 } 227 }
227 228
228 switch (ext_csd[EXT_CSD_CARD_TYPE]) { 229 switch (ext_csd[EXT_CSD_CARD_TYPE] & EXT_CSD_CARD_TYPE_MASK) {
229 case EXT_CSD_CARD_TYPE_52 | EXT_CSD_CARD_TYPE_26: 230 case EXT_CSD_CARD_TYPE_52 | EXT_CSD_CARD_TYPE_26:
230 card->ext_csd.hs_max_dtr = 52000000; 231 card->ext_csd.hs_max_dtr = 52000000;
231 break; 232 break;
@@ -237,7 +238,6 @@ static int mmc_read_ext_csd(struct mmc_card *card)
237 printk(KERN_WARNING "%s: card is mmc v4 but doesn't " 238 printk(KERN_WARNING "%s: card is mmc v4 but doesn't "
238 "support any high-speed modes.\n", 239 "support any high-speed modes.\n",
239 mmc_hostname(card->host)); 240 mmc_hostname(card->host));
240 goto out;
241 } 241 }
242 242
243 if (card->ext_csd.rev >= 3) { 243 if (card->ext_csd.rev >= 3) {
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
index d2cb5c63439..326447c9ede 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -9,6 +9,7 @@
9 * your option) any later version. 9 * your option) any later version.
10 */ 10 */
11 11
12#include <linux/slab.h>
12#include <linux/types.h> 13#include <linux/types.h>
13#include <linux/scatterlist.h> 14#include <linux/scatterlist.h>
14 15
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index fdd414eded0..5eac21df480 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -11,6 +11,7 @@
11 */ 11 */
12 12
13#include <linux/err.h> 13#include <linux/err.h>
14#include <linux/slab.h>
14 15
15#include <linux/mmc/host.h> 16#include <linux/mmc/host.h>
16#include <linux/mmc/card.h> 17#include <linux/mmc/card.h>
diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c
index 9e060c87e64..4a890dcb95a 100644
--- a/drivers/mmc/core/sdio_bus.c
+++ b/drivers/mmc/core/sdio_bus.c
@@ -13,6 +13,7 @@
13 13
14#include <linux/device.h> 14#include <linux/device.h>
15#include <linux/err.h> 15#include <linux/err.h>
16#include <linux/slab.h>
16 17
17#include <linux/mmc/card.h> 18#include <linux/mmc/card.h>
18#include <linux/mmc/sdio_func.h> 19#include <linux/mmc/sdio_func.h>
diff --git a/drivers/mmc/core/sdio_cis.c b/drivers/mmc/core/sdio_cis.c
index 9538389783c..541bdb89e0c 100644
--- a/drivers/mmc/core/sdio_cis.c
+++ b/drivers/mmc/core/sdio_cis.c
@@ -14,6 +14,7 @@
14 */ 14 */
15 15
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/slab.h>
17 18
18#include <linux/mmc/host.h> 19#include <linux/mmc/host.h>
19#include <linux/mmc/card.h> 20#include <linux/mmc/card.h>
diff --git a/drivers/mmc/host/at91_mci.c b/drivers/mmc/host/at91_mci.c
index 91dc60cd032..a6dd7da3735 100644
--- a/drivers/mmc/host/at91_mci.c
+++ b/drivers/mmc/host/at91_mci.c
@@ -65,6 +65,7 @@
65#include <linux/dma-mapping.h> 65#include <linux/dma-mapping.h>
66#include <linux/clk.h> 66#include <linux/clk.h>
67#include <linux/atmel_pdc.h> 67#include <linux/atmel_pdc.h>
68#include <linux/gfp.h>
68 69
69#include <linux/mmc/host.h> 70#include <linux/mmc/host.h>
70 71
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 8072128e933..88be37d9e9a 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -22,6 +22,7 @@
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/scatterlist.h> 23#include <linux/scatterlist.h>
24#include <linux/seq_file.h> 24#include <linux/seq_file.h>
25#include <linux/slab.h>
25#include <linux/stat.h> 26#include <linux/stat.h>
26 27
27#include <linux/mmc/host.h> 28#include <linux/mmc/host.h>
diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c
index 57b21198828..f5834449400 100644
--- a/drivers/mmc/host/au1xmmc.c
+++ b/drivers/mmc/host/au1xmmc.c
@@ -41,6 +41,7 @@
41#include <linux/scatterlist.h> 41#include <linux/scatterlist.h>
42#include <linux/leds.h> 42#include <linux/leds.h>
43#include <linux/mmc/host.h> 43#include <linux/mmc/host.h>
44#include <linux/slab.h>
44 45
45#include <asm/io.h> 46#include <asm/io.h>
46#include <asm/mach-au1x00/au1000.h> 47#include <asm/mach-au1x00/au1000.h>
diff --git a/drivers/mmc/host/bfin_sdh.c b/drivers/mmc/host/bfin_sdh.c
index 56f7b448b91..6919e844072 100644
--- a/drivers/mmc/host/bfin_sdh.c
+++ b/drivers/mmc/host/bfin_sdh.c
@@ -17,6 +17,7 @@
17#include <linux/dma-mapping.h> 17#include <linux/dma-mapping.h>
18#include <linux/mmc/host.h> 18#include <linux/mmc/host.h>
19#include <linux/proc_fs.h> 19#include <linux/proc_fs.h>
20#include <linux/gfp.h>
20 21
21#include <asm/cacheflush.h> 22#include <asm/cacheflush.h>
22#include <asm/dma.h> 23#include <asm/dma.h>
diff --git a/drivers/mmc/host/cb710-mmc.c b/drivers/mmc/host/cb710-mmc.c
index 4e72964a7b4..92a324f7417 100644
--- a/drivers/mmc/host/cb710-mmc.c
+++ b/drivers/mmc/host/cb710-mmc.c
@@ -9,7 +9,6 @@
9 */ 9 */
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/slab.h>
13#include <linux/pci.h> 12#include <linux/pci.h>
14#include <linux/delay.h> 13#include <linux/delay.h>
15#include "cb710-mmc.h" 14#include "cb710-mmc.h"
diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
index d55fe4fb793..ad847a24a67 100644
--- a/drivers/mmc/host/mmc_spi.c
+++ b/drivers/mmc/host/mmc_spi.c
@@ -26,6 +26,7 @@
26 */ 26 */
27#include <linux/sched.h> 27#include <linux/sched.h>
28#include <linux/delay.h> 28#include <linux/delay.h>
29#include <linux/slab.h>
29#include <linux/bio.h> 30#include <linux/bio.h>
30#include <linux/dma-mapping.h> 31#include <linux/dma-mapping.h>
31#include <linux/crc7.h> 32#include <linux/crc7.h>
diff --git a/drivers/mmc/host/msm_sdcc.c b/drivers/mmc/host/msm_sdcc.c
index 4c068e5fe6b..04ae884383f 100644
--- a/drivers/mmc/host/msm_sdcc.c
+++ b/drivers/mmc/host/msm_sdcc.c
@@ -33,6 +33,7 @@
33#include <linux/debugfs.h> 33#include <linux/debugfs.h>
34#include <linux/io.h> 34#include <linux/io.h>
35#include <linux/memory.h> 35#include <linux/memory.h>
36#include <linux/gfp.h>
36 37
37#include <asm/cacheflush.h> 38#include <asm/cacheflush.h>
38#include <asm/div64.h> 39#include <asm/div64.h>
diff --git a/drivers/mmc/host/of_mmc_spi.c b/drivers/mmc/host/of_mmc_spi.c
index 0c7a63c1f12..bb6cc54b558 100644
--- a/drivers/mmc/host/of_mmc_spi.c
+++ b/drivers/mmc/host/of_mmc_spi.c
@@ -14,6 +14,7 @@
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/device.h> 16#include <linux/device.h>
17#include <linux/slab.h>
17#include <linux/gpio.h> 18#include <linux/gpio.h>
18#include <linux/of.h> 19#include <linux/of.h>
19#include <linux/of_gpio.h> 20#include <linux/of_gpio.h>
diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c
index c6d7e8ecadb..84d28040634 100644
--- a/drivers/mmc/host/omap.c
+++ b/drivers/mmc/host/omap.c
@@ -26,6 +26,7 @@
26#include <linux/clk.h> 26#include <linux/clk.h>
27#include <linux/scatterlist.h> 27#include <linux/scatterlist.h>
28#include <linux/i2c/tps65010.h> 28#include <linux/i2c/tps65010.h>
29#include <linux/slab.h>
29 30
30#include <asm/io.h> 31#include <asm/io.h>
31#include <asm/irq.h> 32#include <asm/irq.h>
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 83f0affadca..e9caf694c59 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -1179,15 +1179,10 @@ static void omap_hsmmc_detect(struct work_struct *work)
1179 carddetect = -ENOSYS; 1179 carddetect = -ENOSYS;
1180 } 1180 }
1181 1181
1182 if (carddetect) { 1182 if (carddetect)
1183 mmc_detect_change(host->mmc, (HZ * 200) / 1000); 1183 mmc_detect_change(host->mmc, (HZ * 200) / 1000);
1184 } else { 1184 else
1185 mmc_host_enable(host->mmc);
1186 omap_hsmmc_reset_controller_fsm(host, SRD);
1187 mmc_host_lazy_disable(host->mmc);
1188
1189 mmc_detect_change(host->mmc, (HZ * 50) / 1000); 1185 mmc_detect_change(host->mmc, (HZ * 50) / 1000);
1190 }
1191} 1186}
1192 1187
1193/* 1188/*
diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c
index 0d783f3e79e..e4f00e70a74 100644
--- a/drivers/mmc/host/pxamci.c
+++ b/drivers/mmc/host/pxamci.c
@@ -29,6 +29,7 @@
29#include <linux/io.h> 29#include <linux/io.h>
30#include <linux/regulator/consumer.h> 30#include <linux/regulator/consumer.h>
31#include <linux/gpio.h> 31#include <linux/gpio.h>
32#include <linux/gfp.h>
32 33
33#include <asm/sizes.h> 34#include <asm/sizes.h>
34 35
@@ -543,7 +544,7 @@ static irqreturn_t pxamci_detect_irq(int irq, void *devid)
543{ 544{
544 struct pxamci_host *host = mmc_priv(devid); 545 struct pxamci_host *host = mmc_priv(devid);
545 546
546 mmc_detect_change(devid, host->pdata->detect_delay); 547 mmc_detect_change(devid, msecs_to_jiffies(host->pdata->detect_delay_ms));
547 return IRQ_HANDLED; 548 return IRQ_HANDLED;
548} 549}
549 550
diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c
index 8e1020cf73f..6701af629c3 100644
--- a/drivers/mmc/host/sdhci-pci.c
+++ b/drivers/mmc/host/sdhci-pci.c
@@ -16,6 +16,7 @@
16#include <linux/highmem.h> 16#include <linux/highmem.h>
17#include <linux/pci.h> 17#include <linux/pci.h>
18#include <linux/dma-mapping.h> 18#include <linux/dma-mapping.h>
19#include <linux/slab.h>
19 20
20#include <linux/mmc/host.h> 21#include <linux/mmc/host.h>
21 22
diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index 50997d2a63e..2136794c0cf 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -15,6 +15,7 @@
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/dma-mapping.h> 16#include <linux/dma-mapping.h>
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/slab.h>
18#include <linux/clk.h> 19#include <linux/clk.h>
19#include <linux/io.h> 20#include <linux/io.h>
20 21
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index d6ab62d539f..9d4fdfa685e 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -17,6 +17,7 @@
17#include <linux/highmem.h> 17#include <linux/highmem.h>
18#include <linux/io.h> 18#include <linux/io.h>
19#include <linux/dma-mapping.h> 19#include <linux/dma-mapping.h>
20#include <linux/slab.h>
20#include <linux/scatterlist.h> 21#include <linux/scatterlist.h>
21 22
22#include <linux/leds.h> 23#include <linux/leds.h>
diff --git a/drivers/mmc/host/wbsd.c b/drivers/mmc/host/wbsd.c
index 89bf8cd25ca..69efe01eece 100644
--- a/drivers/mmc/host/wbsd.c
+++ b/drivers/mmc/host/wbsd.c
@@ -34,6 +34,7 @@
34#include <linux/highmem.h> 34#include <linux/highmem.h>
35#include <linux/mmc/host.h> 35#include <linux/mmc/host.h>
36#include <linux/scatterlist.h> 36#include <linux/scatterlist.h>
37#include <linux/slab.h>
37 38
38#include <asm/io.h> 39#include <asm/io.h>
39#include <asm/dma.h> 40#include <asm/dma.h>
diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile
index 82d1e4de475..4521b1ecce4 100644
--- a/drivers/mtd/Makefile
+++ b/drivers/mtd/Makefile
@@ -4,7 +4,7 @@
4 4
5# Core functionality. 5# Core functionality.
6obj-$(CONFIG_MTD) += mtd.o 6obj-$(CONFIG_MTD) += mtd.o
7mtd-y := mtdcore.o mtdsuper.o mtdbdi.o 7mtd-y := mtdcore.o mtdsuper.o
8mtd-$(CONFIG_MTD_PARTITIONS) += mtdpart.o 8mtd-$(CONFIG_MTD_PARTITIONS) += mtdpart.o
9 9
10obj-$(CONFIG_MTD_CONCAT) += mtdconcat.o 10obj-$(CONFIG_MTD_CONCAT) += mtdconcat.o
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c
index 8c295f40d2a..ce6424008ed 100644
--- a/drivers/mtd/devices/block2mtd.c
+++ b/drivers/mtd/devices/block2mtd.c
@@ -17,6 +17,7 @@
17#include <linux/buffer_head.h> 17#include <linux/buffer_head.h>
18#include <linux/mutex.h> 18#include <linux/mutex.h>
19#include <linux/mount.h> 19#include <linux/mount.h>
20#include <linux/slab.h>
20 21
21#define ERROR(fmt, args...) printk(KERN_ERR "block2mtd: " fmt "\n" , ## args) 22#define ERROR(fmt, args...) printk(KERN_ERR "block2mtd: " fmt "\n" , ## args)
22#define INFO(fmt, args...) printk(KERN_INFO "block2mtd: " fmt "\n" , ## args) 23#define INFO(fmt, args...) printk(KERN_INFO "block2mtd: " fmt "\n" , ## args)
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index f3f4768d6e1..81e49a9b017 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -21,6 +21,7 @@
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/mutex.h> 22#include <linux/mutex.h>
23#include <linux/math64.h> 23#include <linux/math64.h>
24#include <linux/slab.h>
24#include <linux/sched.h> 25#include <linux/sched.h>
25#include <linux/mod_devicetable.h> 26#include <linux/mod_devicetable.h>
26 27
diff --git a/drivers/mtd/devices/sst25l.c b/drivers/mtd/devices/sst25l.c
index 0a11721f146..fe17054ee2f 100644
--- a/drivers/mtd/devices/sst25l.c
+++ b/drivers/mtd/devices/sst25l.c
@@ -20,6 +20,7 @@
20#include <linux/device.h> 20#include <linux/device.h>
21#include <linux/mutex.h> 21#include <linux/mutex.h>
22#include <linux/interrupt.h> 22#include <linux/interrupt.h>
23#include <linux/slab.h>
23#include <linux/sched.h> 24#include <linux/sched.h>
24 25
25#include <linux/mtd/mtd.h> 26#include <linux/mtd/mtd.h>
diff --git a/drivers/mtd/internal.h b/drivers/mtd/internal.h
deleted file mode 100644
index c658fe7216b..00000000000
--- a/drivers/mtd/internal.h
+++ /dev/null
@@ -1,17 +0,0 @@
1/* Internal MTD definitions
2 *
3 * Copyright © 2006 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 License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12/*
13 * mtdbdi.c
14 */
15extern struct backing_dev_info mtd_bdi_unmappable;
16extern struct backing_dev_info mtd_bdi_ro_mappable;
17extern struct backing_dev_info mtd_bdi_rw_mappable;
diff --git a/drivers/mtd/lpddr/lpddr_cmds.c b/drivers/mtd/lpddr/lpddr_cmds.c
index e22ca49583e..a73ee12aad8 100644
--- a/drivers/mtd/lpddr/lpddr_cmds.c
+++ b/drivers/mtd/lpddr/lpddr_cmds.c
@@ -26,6 +26,7 @@
26 */ 26 */
27#include <linux/mtd/pfow.h> 27#include <linux/mtd/pfow.h>
28#include <linux/mtd/qinfo.h> 28#include <linux/mtd/qinfo.h>
29#include <linux/slab.h>
29 30
30static int lpddr_read(struct mtd_info *mtd, loff_t adr, size_t len, 31static int lpddr_read(struct mtd_info *mtd, loff_t adr, size_t len,
31 size_t *retlen, u_char *buf); 32 size_t *retlen, u_char *buf);
diff --git a/drivers/mtd/maps/amd76xrom.c b/drivers/mtd/maps/amd76xrom.c
index 237733d094c..19fe92db0c4 100644
--- a/drivers/mtd/maps/amd76xrom.c
+++ b/drivers/mtd/maps/amd76xrom.c
@@ -8,6 +8,7 @@
8#include <linux/types.h> 8#include <linux/types.h>
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/init.h> 10#include <linux/init.h>
11#include <linux/slab.h>
11#include <asm/io.h> 12#include <asm/io.h>
12#include <linux/mtd/mtd.h> 13#include <linux/mtd/mtd.h>
13#include <linux/mtd/map.h> 14#include <linux/mtd/map.h>
diff --git a/drivers/mtd/maps/bfin-async-flash.c b/drivers/mtd/maps/bfin-async-flash.c
index a7c808b577d..c0fd99b0c52 100644
--- a/drivers/mtd/maps/bfin-async-flash.c
+++ b/drivers/mtd/maps/bfin-async-flash.c
@@ -22,6 +22,7 @@
22#include <linux/mtd/partitions.h> 22#include <linux/mtd/partitions.h>
23#include <linux/mtd/physmap.h> 23#include <linux/mtd/physmap.h>
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/slab.h>
25#include <linux/types.h> 26#include <linux/types.h>
26 27
27#include <asm/blackfin.h> 28#include <asm/blackfin.h>
diff --git a/drivers/mtd/maps/ck804xrom.c b/drivers/mtd/maps/ck804xrom.c
index 424f17d6ffd..ddb462bea9b 100644
--- a/drivers/mtd/maps/ck804xrom.c
+++ b/drivers/mtd/maps/ck804xrom.c
@@ -11,6 +11,7 @@
11#include <linux/types.h> 11#include <linux/types.h>
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/slab.h>
14#include <asm/io.h> 15#include <asm/io.h>
15#include <linux/mtd/mtd.h> 16#include <linux/mtd/mtd.h>
16#include <linux/mtd/map.h> 17#include <linux/mtd/map.h>
diff --git a/drivers/mtd/maps/esb2rom.c b/drivers/mtd/maps/esb2rom.c
index 11a2f57df9c..d12c93dc1aa 100644
--- a/drivers/mtd/maps/esb2rom.c
+++ b/drivers/mtd/maps/esb2rom.c
@@ -14,6 +14,7 @@
14#include <linux/types.h> 14#include <linux/types.h>
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/slab.h>
17#include <asm/io.h> 18#include <asm/io.h>
18#include <linux/mtd/mtd.h> 19#include <linux/mtd/mtd.h>
19#include <linux/mtd/map.h> 20#include <linux/mtd/map.h>
diff --git a/drivers/mtd/maps/gpio-addr-flash.c b/drivers/mtd/maps/gpio-addr-flash.c
index 1ad5caf9fe6..32e89d773b4 100644
--- a/drivers/mtd/maps/gpio-addr-flash.c
+++ b/drivers/mtd/maps/gpio-addr-flash.c
@@ -23,6 +23,7 @@
23#include <linux/mtd/partitions.h> 23#include <linux/mtd/partitions.h>
24#include <linux/mtd/physmap.h> 24#include <linux/mtd/physmap.h>
25#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26#include <linux/slab.h>
26#include <linux/types.h> 27#include <linux/types.h>
27 28
28#define pr_devinit(fmt, args...) ({ static const __devinitconst char __fmt[] = fmt; printk(__fmt, ## args); }) 29#define pr_devinit(fmt, args...) ({ static const __devinitconst char __fmt[] = fmt; printk(__fmt, ## args); })
diff --git a/drivers/mtd/maps/ichxrom.c b/drivers/mtd/maps/ichxrom.c
index c32bc28920b..f102bf243a7 100644
--- a/drivers/mtd/maps/ichxrom.c
+++ b/drivers/mtd/maps/ichxrom.c
@@ -8,6 +8,7 @@
8#include <linux/types.h> 8#include <linux/types.h>
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/init.h> 10#include <linux/init.h>
11#include <linux/slab.h>
11#include <asm/io.h> 12#include <asm/io.h>
12#include <linux/mtd/mtd.h> 13#include <linux/mtd/mtd.h>
13#include <linux/mtd/map.h> 14#include <linux/mtd/map.h>
diff --git a/drivers/mtd/maps/intel_vr_nor.c b/drivers/mtd/maps/intel_vr_nor.c
index 1e7814ae212..fc1998512eb 100644
--- a/drivers/mtd/maps/intel_vr_nor.c
+++ b/drivers/mtd/maps/intel_vr_nor.c
@@ -29,6 +29,7 @@
29 29
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/kernel.h> 31#include <linux/kernel.h>
32#include <linux/slab.h>
32#include <linux/pci.h> 33#include <linux/pci.h>
33#include <linux/init.h> 34#include <linux/init.h>
34#include <linux/mtd/mtd.h> 35#include <linux/mtd/mtd.h>
diff --git a/drivers/mtd/maps/octagon-5066.c b/drivers/mtd/maps/octagon-5066.c
index 2b2e4509321..23fe1786770 100644
--- a/drivers/mtd/maps/octagon-5066.c
+++ b/drivers/mtd/maps/octagon-5066.c
@@ -24,7 +24,6 @@
24 ##################################################################### */ 24 ##################################################################### */
25 25
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/slab.h>
28#include <linux/ioport.h> 27#include <linux/ioport.h>
29#include <linux/init.h> 28#include <linux/init.h>
30#include <asm/io.h> 29#include <asm/io.h>
diff --git a/drivers/mtd/maps/omap_nor.c b/drivers/mtd/maps/omap_nor.c
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/drivers/mtd/maps/omap_nor.c
+++ /dev/null
diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c
index 61e4eb48bb2..101ee6ead05 100644
--- a/drivers/mtd/maps/physmap_of.c
+++ b/drivers/mtd/maps/physmap_of.c
@@ -23,6 +23,7 @@
23#include <linux/mtd/concat.h> 23#include <linux/mtd/concat.h>
24#include <linux/of.h> 24#include <linux/of.h>
25#include <linux/of_platform.h> 25#include <linux/of_platform.h>
26#include <linux/slab.h>
26 27
27struct of_flash_list { 28struct of_flash_list {
28 struct mtd_info *mtd; 29 struct mtd_info *mtd;
diff --git a/drivers/mtd/maps/pismo.c b/drivers/mtd/maps/pismo.c
index 30e12c88d1d..60c068db452 100644
--- a/drivers/mtd/maps/pismo.c
+++ b/drivers/mtd/maps/pismo.c
@@ -10,6 +10,7 @@
10#include <linux/init.h> 10#include <linux/init.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/i2c.h> 12#include <linux/i2c.h>
13#include <linux/slab.h>
13#include <linux/platform_device.h> 14#include <linux/platform_device.h>
14#include <linux/spinlock.h> 15#include <linux/spinlock.h>
15#include <linux/mutex.h> 16#include <linux/mutex.h>
diff --git a/drivers/mtd/maps/pmcmsp-flash.c b/drivers/mtd/maps/pmcmsp-flash.c
index c8fd8da4bc8..acb13fa5001 100644
--- a/drivers/mtd/maps/pmcmsp-flash.c
+++ b/drivers/mtd/maps/pmcmsp-flash.c
@@ -28,6 +28,7 @@
28 * 675 Mass Ave, Cambridge, MA 02139, USA. 28 * 675 Mass Ave, Cambridge, MA 02139, USA.
29 */ 29 */
30 30
31#include <linux/slab.h>
31#include <linux/module.h> 32#include <linux/module.h>
32#include <linux/types.h> 33#include <linux/types.h>
33#include <linux/kernel.h> 34#include <linux/kernel.h>
diff --git a/drivers/mtd/maps/pxa2xx-flash.c b/drivers/mtd/maps/pxa2xx-flash.c
index b13f6417b5b..91dc6331053 100644
--- a/drivers/mtd/maps/pxa2xx-flash.c
+++ b/drivers/mtd/maps/pxa2xx-flash.c
@@ -11,6 +11,7 @@
11 11
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/types.h> 13#include <linux/types.h>
14#include <linux/slab.h>
14#include <linux/kernel.h> 15#include <linux/kernel.h>
15#include <linux/init.h> 16#include <linux/init.h>
16#include <linux/platform_device.h> 17#include <linux/platform_device.h>
diff --git a/drivers/mtd/maps/sbc_gxx.c b/drivers/mtd/maps/sbc_gxx.c
index 1b1c0b7e11e..04b2781fc62 100644
--- a/drivers/mtd/maps/sbc_gxx.c
+++ b/drivers/mtd/maps/sbc_gxx.c
@@ -45,7 +45,6 @@ separate MTD devices.
45// Includes 45// Includes
46 46
47#include <linux/module.h> 47#include <linux/module.h>
48#include <linux/slab.h>
49#include <linux/ioport.h> 48#include <linux/ioport.h>
50#include <linux/init.h> 49#include <linux/init.h>
51#include <asm/io.h> 50#include <asm/io.h>
diff --git a/drivers/mtd/maps/sun_uflash.c b/drivers/mtd/maps/sun_uflash.c
index fd7a1017399..fadc4c45b45 100644
--- a/drivers/mtd/maps/sun_uflash.c
+++ b/drivers/mtd/maps/sun_uflash.c
@@ -15,6 +15,7 @@
15#include <linux/ioport.h> 15#include <linux/ioport.h>
16#include <linux/of.h> 16#include <linux/of.h>
17#include <linux/of_device.h> 17#include <linux/of_device.h>
18#include <linux/slab.h>
18#include <asm/prom.h> 19#include <asm/prom.h>
19#include <asm/uaccess.h> 20#include <asm/uaccess.h>
20#include <asm/io.h> 21#include <asm/io.h>
diff --git a/drivers/mtd/maps/vmax301.c b/drivers/mtd/maps/vmax301.c
index 6d452dcdfe3..6adaa6acc19 100644
--- a/drivers/mtd/maps/vmax301.c
+++ b/drivers/mtd/maps/vmax301.c
@@ -16,7 +16,6 @@
16 ##################################################################### */ 16 ##################################################################### */
17 17
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/slab.h>
20#include <linux/ioport.h> 19#include <linux/ioport.h>
21#include <linux/init.h> 20#include <linux/init.h>
22#include <linux/spinlock.h> 21#include <linux/spinlock.h>
diff --git a/drivers/mtd/maps/vmu-flash.c b/drivers/mtd/maps/vmu-flash.c
index 82afad0ddd7..4afc167731e 100644
--- a/drivers/mtd/maps/vmu-flash.c
+++ b/drivers/mtd/maps/vmu-flash.c
@@ -8,6 +8,7 @@
8 * GNU General Public Licence 8 * GNU General Public Licence
9 */ 9 */
10#include <linux/init.h> 10#include <linux/init.h>
11#include <linux/slab.h>
11#include <linux/sched.h> 12#include <linux/sched.h>
12#include <linux/delay.h> 13#include <linux/delay.h>
13#include <linux/maple.h> 14#include <linux/maple.h>
diff --git a/drivers/mtd/mtdbdi.c b/drivers/mtd/mtdbdi.c
deleted file mode 100644
index 5ca5aed0b22..00000000000
--- a/drivers/mtd/mtdbdi.c
+++ /dev/null
@@ -1,43 +0,0 @@
1/* MTD backing device capabilities
2 *
3 * Copyright © 2006 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 License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#include <linux/backing-dev.h>
13#include <linux/mtd/mtd.h>
14#include "internal.h"
15
16/*
17 * backing device capabilities for non-mappable devices (such as NAND flash)
18 * - permits private mappings, copies are taken of the data
19 */
20struct backing_dev_info mtd_bdi_unmappable = {
21 .capabilities = BDI_CAP_MAP_COPY,
22};
23
24/*
25 * backing device capabilities for R/O mappable devices (such as ROM)
26 * - permits private mappings, copies are taken of the data
27 * - permits non-writable shared mappings
28 */
29struct backing_dev_info mtd_bdi_ro_mappable = {
30 .capabilities = (BDI_CAP_MAP_COPY | BDI_CAP_MAP_DIRECT |
31 BDI_CAP_EXEC_MAP | BDI_CAP_READ_MAP),
32};
33
34/*
35 * backing device capabilities for writable mappable devices (such as RAM)
36 * - permits private mappings, copies are taken of the data
37 * - permits non-writable shared mappings
38 */
39struct backing_dev_info mtd_bdi_rw_mappable = {
40 .capabilities = (BDI_CAP_MAP_COPY | BDI_CAP_MAP_DIRECT |
41 BDI_CAP_EXEC_MAP | BDI_CAP_READ_MAP |
42 BDI_CAP_WRITE_MAP),
43};
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index c356c0a30c3..b177e750efc 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -2,12 +2,14 @@
2 * Core registration and callback routines for MTD 2 * Core registration and callback routines for MTD
3 * drivers and users. 3 * drivers and users.
4 * 4 *
5 * bdi bits are:
6 * Copyright © 2006 Red Hat, Inc. All Rights Reserved.
7 * Written by David Howells (dhowells@redhat.com)
5 */ 8 */
6 9
7#include <linux/module.h> 10#include <linux/module.h>
8#include <linux/kernel.h> 11#include <linux/kernel.h>
9#include <linux/ptrace.h> 12#include <linux/ptrace.h>
10#include <linux/slab.h>
11#include <linux/string.h> 13#include <linux/string.h>
12#include <linux/timer.h> 14#include <linux/timer.h>
13#include <linux/major.h> 15#include <linux/major.h>
@@ -17,11 +19,39 @@
17#include <linux/init.h> 19#include <linux/init.h>
18#include <linux/mtd/compatmac.h> 20#include <linux/mtd/compatmac.h>
19#include <linux/proc_fs.h> 21#include <linux/proc_fs.h>
22#include <linux/backing-dev.h>
20 23
21#include <linux/mtd/mtd.h> 24#include <linux/mtd/mtd.h>
22#include "internal.h"
23 25
24#include "mtdcore.h" 26#include "mtdcore.h"
27/*
28 * backing device capabilities for non-mappable devices (such as NAND flash)
29 * - permits private mappings, copies are taken of the data
30 */
31struct backing_dev_info mtd_bdi_unmappable = {
32 .capabilities = BDI_CAP_MAP_COPY,
33};
34
35/*
36 * backing device capabilities for R/O mappable devices (such as ROM)
37 * - permits private mappings, copies are taken of the data
38 * - permits non-writable shared mappings
39 */
40struct backing_dev_info mtd_bdi_ro_mappable = {
41 .capabilities = (BDI_CAP_MAP_COPY | BDI_CAP_MAP_DIRECT |
42 BDI_CAP_EXEC_MAP | BDI_CAP_READ_MAP),
43};
44
45/*
46 * backing device capabilities for writable mappable devices (such as RAM)
47 * - permits private mappings, copies are taken of the data
48 * - permits non-writable shared mappings
49 */
50struct backing_dev_info mtd_bdi_rw_mappable = {
51 .capabilities = (BDI_CAP_MAP_COPY | BDI_CAP_MAP_DIRECT |
52 BDI_CAP_EXEC_MAP | BDI_CAP_READ_MAP |
53 BDI_CAP_WRITE_MAP),
54};
25 55
26static int mtd_cls_suspend(struct device *dev, pm_message_t state); 56static int mtd_cls_suspend(struct device *dev, pm_message_t state);
27static int mtd_cls_resume(struct device *dev); 57static int mtd_cls_resume(struct device *dev);
@@ -629,20 +659,55 @@ done:
629/*====================================================================*/ 659/*====================================================================*/
630/* Init code */ 660/* Init code */
631 661
662static int __init mtd_bdi_init(struct backing_dev_info *bdi, const char *name)
663{
664 int ret;
665
666 ret = bdi_init(bdi);
667 if (!ret)
668 ret = bdi_register(bdi, NULL, name);
669
670 if (ret)
671 bdi_destroy(bdi);
672
673 return ret;
674}
675
632static int __init init_mtd(void) 676static int __init init_mtd(void)
633{ 677{
634 int ret; 678 int ret;
679
635 ret = class_register(&mtd_class); 680 ret = class_register(&mtd_class);
681 if (ret)
682 goto err_reg;
683
684 ret = mtd_bdi_init(&mtd_bdi_unmappable, "mtd-unmap");
685 if (ret)
686 goto err_bdi1;
687
688 ret = mtd_bdi_init(&mtd_bdi_ro_mappable, "mtd-romap");
689 if (ret)
690 goto err_bdi2;
691
692 ret = mtd_bdi_init(&mtd_bdi_rw_mappable, "mtd-rwmap");
693 if (ret)
694 goto err_bdi3;
636 695
637 if (ret) {
638 pr_err("Error registering mtd class: %d\n", ret);
639 return ret;
640 }
641#ifdef CONFIG_PROC_FS 696#ifdef CONFIG_PROC_FS
642 if ((proc_mtd = create_proc_entry( "mtd", 0, NULL ))) 697 if ((proc_mtd = create_proc_entry( "mtd", 0, NULL )))
643 proc_mtd->read_proc = mtd_read_proc; 698 proc_mtd->read_proc = mtd_read_proc;
644#endif /* CONFIG_PROC_FS */ 699#endif /* CONFIG_PROC_FS */
645 return 0; 700 return 0;
701
702err_bdi3:
703 bdi_destroy(&mtd_bdi_ro_mappable);
704err_bdi2:
705 bdi_destroy(&mtd_bdi_unmappable);
706err_bdi1:
707 class_unregister(&mtd_class);
708err_reg:
709 pr_err("Error registering mtd class or bdi: %d\n", ret);
710 return ret;
646} 711}
647 712
648static void __exit cleanup_mtd(void) 713static void __exit cleanup_mtd(void)
@@ -652,6 +717,9 @@ static void __exit cleanup_mtd(void)
652 remove_proc_entry( "mtd", NULL); 717 remove_proc_entry( "mtd", NULL);
653#endif /* CONFIG_PROC_FS */ 718#endif /* CONFIG_PROC_FS */
654 class_unregister(&mtd_class); 719 class_unregister(&mtd_class);
720 bdi_destroy(&mtd_bdi_unmappable);
721 bdi_destroy(&mtd_bdi_ro_mappable);
722 bdi_destroy(&mtd_bdi_rw_mappable);
655} 723}
656 724
657module_init(init_mtd); 725module_init(init_mtd);
diff --git a/drivers/mtd/mtdsuper.c b/drivers/mtd/mtdsuper.c
index af8b42e0a55..7c003191fca 100644
--- a/drivers/mtd/mtdsuper.c
+++ b/drivers/mtd/mtdsuper.c
@@ -13,6 +13,7 @@
13#include <linux/mtd/super.h> 13#include <linux/mtd/super.h>
14#include <linux/namei.h> 14#include <linux/namei.h>
15#include <linux/ctype.h> 15#include <linux/ctype.h>
16#include <linux/slab.h>
16 17
17/* 18/*
18 * compare superblocks to see if they're equivalent 19 * compare superblocks to see if they're equivalent
@@ -44,6 +45,7 @@ static int get_sb_mtd_set(struct super_block *sb, void *_mtd)
44 45
45 sb->s_mtd = mtd; 46 sb->s_mtd = mtd;
46 sb->s_dev = MKDEV(MTD_BLOCK_MAJOR, mtd->index); 47 sb->s_dev = MKDEV(MTD_BLOCK_MAJOR, mtd->index);
48 sb->s_bdi = mtd->backing_dev_info;
47 return 0; 49 return 0;
48} 50}
49 51
diff --git a/drivers/mtd/nand/bcm_umi_nand.c b/drivers/mtd/nand/bcm_umi_nand.c
index 7d1cca7a31a..c997f98eeb3 100644
--- a/drivers/mtd/nand/bcm_umi_nand.c
+++ b/drivers/mtd/nand/bcm_umi_nand.c
@@ -18,6 +18,7 @@
18#include <linux/types.h> 18#include <linux/types.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/kernel.h> 20#include <linux/kernel.h>
21#include <linux/slab.h>
21#include <linux/string.h> 22#include <linux/string.h>
22#include <linux/ioport.h> 23#include <linux/ioport.h>
23#include <linux/device.h> 24#include <linux/device.h>
diff --git a/drivers/mtd/nand/cafe_nand.c b/drivers/mtd/nand/cafe_nand.c
index c828d9ac7bd..e5a9f9ccea6 100644
--- a/drivers/mtd/nand/cafe_nand.c
+++ b/drivers/mtd/nand/cafe_nand.c
@@ -20,6 +20,7 @@
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/dma-mapping.h> 22#include <linux/dma-mapping.h>
23#include <linux/slab.h>
23#include <asm/io.h> 24#include <asm/io.h>
24 25
25#define CAFE_NAND_CTRL1 0x00 26#define CAFE_NAND_CTRL1 0x00
diff --git a/drivers/mtd/nand/cmx270_nand.c b/drivers/mtd/nand/cmx270_nand.c
index 826cacffcef..6e649527825 100644
--- a/drivers/mtd/nand/cmx270_nand.c
+++ b/drivers/mtd/nand/cmx270_nand.c
@@ -20,6 +20,7 @@
20 20
21#include <linux/mtd/nand.h> 21#include <linux/mtd/nand.h>
22#include <linux/mtd/partitions.h> 22#include <linux/mtd/partitions.h>
23#include <linux/slab.h>
23#include <linux/gpio.h> 24#include <linux/gpio.h>
24 25
25#include <asm/io.h> 26#include <asm/io.h>
diff --git a/drivers/mtd/nand/davinci_nand.c b/drivers/mtd/nand/davinci_nand.c
index fe3eba87de4..76e2dc8e62f 100644
--- a/drivers/mtd/nand/davinci_nand.c
+++ b/drivers/mtd/nand/davinci_nand.c
@@ -32,6 +32,7 @@
32#include <linux/io.h> 32#include <linux/io.h>
33#include <linux/mtd/nand.h> 33#include <linux/mtd/nand.h>
34#include <linux/mtd/partitions.h> 34#include <linux/mtd/partitions.h>
35#include <linux/slab.h>
35 36
36#include <mach/nand.h> 37#include <mach/nand.h>
37 38
diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c
index b126cf88747..47067bc9824 100644
--- a/drivers/mtd/nand/diskonchip.c
+++ b/drivers/mtd/nand/diskonchip.c
@@ -23,6 +23,7 @@
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/rslib.h> 24#include <linux/rslib.h>
25#include <linux/moduleparam.h> 25#include <linux/moduleparam.h>
26#include <linux/slab.h>
26#include <asm/io.h> 27#include <asm/io.h>
27 28
28#include <linux/mtd/mtd.h> 29#include <linux/mtd/mtd.h>
diff --git a/drivers/mtd/nand/fsl_upm.c b/drivers/mtd/nand/fsl_upm.c
index 071a60cb420..4b96296af32 100644
--- a/drivers/mtd/nand/fsl_upm.c
+++ b/drivers/mtd/nand/fsl_upm.c
@@ -21,6 +21,7 @@
21#include <linux/of_platform.h> 21#include <linux/of_platform.h>
22#include <linux/of_gpio.h> 22#include <linux/of_gpio.h>
23#include <linux/io.h> 23#include <linux/io.h>
24#include <linux/slab.h>
24#include <asm/fsl_lbc.h> 25#include <asm/fsl_lbc.h>
25 26
26#define FSL_UPM_WAIT_RUN_PATTERN 0x1 27#define FSL_UPM_WAIT_RUN_PATTERN 0x1
diff --git a/drivers/mtd/nand/ndfc.c b/drivers/mtd/nand/ndfc.c
index 40b5658bdbe..b983cae8c29 100644
--- a/drivers/mtd/nand/ndfc.c
+++ b/drivers/mtd/nand/ndfc.c
@@ -28,6 +28,7 @@
28#include <linux/mtd/nand_ecc.h> 28#include <linux/mtd/nand_ecc.h>
29#include <linux/mtd/partitions.h> 29#include <linux/mtd/partitions.h>
30#include <linux/mtd/ndfc.h> 30#include <linux/mtd/ndfc.h>
31#include <linux/slab.h>
31#include <linux/mtd/mtd.h> 32#include <linux/mtd/mtd.h>
32#include <linux/of_platform.h> 33#include <linux/of_platform.h>
33#include <asm/io.h> 34#include <asm/io.h>
diff --git a/drivers/mtd/nand/nomadik_nand.c b/drivers/mtd/nand/nomadik_nand.c
index 66123419f65..1f6f741af5d 100644
--- a/drivers/mtd/nand/nomadik_nand.c
+++ b/drivers/mtd/nand/nomadik_nand.c
@@ -30,6 +30,7 @@
30#include <linux/platform_device.h> 30#include <linux/platform_device.h>
31#include <linux/mtd/partitions.h> 31#include <linux/mtd/partitions.h>
32#include <linux/io.h> 32#include <linux/io.h>
33#include <linux/slab.h>
33#include <mach/nand.h> 34#include <mach/nand.h>
34#include <mach/fsmc.h> 35#include <mach/fsmc.h>
35 36
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 26aec008018..7545568fce4 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -17,6 +17,7 @@
17#include <linux/mtd/nand.h> 17#include <linux/mtd/nand.h>
18#include <linux/mtd/partitions.h> 18#include <linux/mtd/partitions.h>
19#include <linux/io.h> 19#include <linux/io.h>
20#include <linux/slab.h>
20 21
21#include <plat/dma.h> 22#include <plat/dma.h>
22#include <plat/gpmc.h> 23#include <plat/gpmc.h>
diff --git a/drivers/mtd/nand/orion_nand.c b/drivers/mtd/nand/orion_nand.c
index f59c07427af..d60fc5719fe 100644
--- a/drivers/mtd/nand/orion_nand.c
+++ b/drivers/mtd/nand/orion_nand.c
@@ -60,7 +60,13 @@ static void orion_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
60 } 60 }
61 buf64 = (uint64_t *)buf; 61 buf64 = (uint64_t *)buf;
62 while (i < len/8) { 62 while (i < len/8) {
63 uint64_t x; 63 /*
64 * Since GCC has no proper constraint (PR 43518)
65 * force x variable to r2/r3 registers as ldrd instruction
66 * requires first register to be even.
67 */
68 register uint64_t x asm ("r2");
69
64 asm volatile ("ldrd\t%0, [%1]" : "=&r" (x) : "r" (io_base)); 70 asm volatile ("ldrd\t%0, [%1]" : "=&r" (x) : "r" (io_base));
65 buf64[i++] = x; 71 buf64[i++] = x;
66 } 72 }
diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
index 1a5a0365c98..5d55152162c 100644
--- a/drivers/mtd/nand/pxa3xx_nand.c
+++ b/drivers/mtd/nand/pxa3xx_nand.c
@@ -21,6 +21,7 @@
21#include <linux/mtd/partitions.h> 21#include <linux/mtd/partitions.h>
22#include <linux/io.h> 22#include <linux/io.h>
23#include <linux/irq.h> 23#include <linux/irq.h>
24#include <linux/slab.h>
24 25
25#include <mach/dma.h> 26#include <mach/dma.h>
26#include <plat/pxa3xx_nand.h> 27#include <plat/pxa3xx_nand.h>
diff --git a/drivers/mtd/nand/sh_flctl.c b/drivers/mtd/nand/sh_flctl.c
index 1842df8bdd9..34752fce079 100644
--- a/drivers/mtd/nand/sh_flctl.c
+++ b/drivers/mtd/nand/sh_flctl.c
@@ -26,6 +26,7 @@
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/io.h> 27#include <linux/io.h>
28#include <linux/platform_device.h> 28#include <linux/platform_device.h>
29#include <linux/slab.h>
29 30
30#include <linux/mtd/mtd.h> 31#include <linux/mtd/mtd.h>
31#include <linux/mtd/nand.h> 32#include <linux/mtd/nand.h>
diff --git a/drivers/mtd/nand/tmio_nand.c b/drivers/mtd/nand/tmio_nand.c
index 92c73344a66..fa28f01ae00 100644
--- a/drivers/mtd/nand/tmio_nand.c
+++ b/drivers/mtd/nand/tmio_nand.c
@@ -37,6 +37,7 @@
37#include <linux/mtd/nand.h> 37#include <linux/mtd/nand.h>
38#include <linux/mtd/nand_ecc.h> 38#include <linux/mtd/nand_ecc.h>
39#include <linux/mtd/partitions.h> 39#include <linux/mtd/partitions.h>
40#include <linux/slab.h>
40 41
41/*--------------------------------------------------------------------------*/ 42/*--------------------------------------------------------------------------*/
42 43
diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c
index 62d6a78c4ee..4f0d635674f 100644
--- a/drivers/mtd/ofpart.c
+++ b/drivers/mtd/ofpart.c
@@ -17,6 +17,7 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/of.h> 18#include <linux/of.h>
19#include <linux/mtd/mtd.h> 19#include <linux/mtd/mtd.h>
20#include <linux/slab.h>
20#include <linux/mtd/partitions.h> 21#include <linux/mtd/partitions.h>
21 22
22int __devinit of_mtd_parse_partitions(struct device *dev, 23int __devinit of_mtd_parse_partitions(struct device *dev,
diff --git a/drivers/mtd/onenand/omap2.c b/drivers/mtd/onenand/omap2.c
index 75f38b95811..fd406348fdf 100644
--- a/drivers/mtd/onenand/omap2.c
+++ b/drivers/mtd/onenand/omap2.c
@@ -34,6 +34,7 @@
34#include <linux/delay.h> 34#include <linux/delay.h>
35#include <linux/dma-mapping.h> 35#include <linux/dma-mapping.h>
36#include <linux/io.h> 36#include <linux/io.h>
37#include <linux/slab.h>
37 38
38#include <asm/mach/flash.h> 39#include <asm/mach/flash.h>
39#include <plat/gpmc.h> 40#include <plat/gpmc.h>
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index f63b1db3ffb..32f0ed33afe 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -23,6 +23,7 @@
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/moduleparam.h> 25#include <linux/moduleparam.h>
26#include <linux/slab.h>
26#include <linux/init.h> 27#include <linux/init.h>
27#include <linux/sched.h> 28#include <linux/sched.h>
28#include <linux/delay.h> 29#include <linux/delay.h>
diff --git a/drivers/mtd/onenand/onenand_sim.c b/drivers/mtd/onenand/onenand_sim.c
index f6e3c8aebd3..8b246061d51 100644
--- a/drivers/mtd/onenand/onenand_sim.c
+++ b/drivers/mtd/onenand/onenand_sim.c
@@ -16,6 +16,7 @@
16 */ 16 */
17 17
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/slab.h>
19#include <linux/module.h> 20#include <linux/module.h>
20#include <linux/init.h> 21#include <linux/init.h>
21#include <linux/vmalloc.h> 22#include <linux/vmalloc.h>
diff --git a/drivers/mtd/tests/mtd_nandecctest.c b/drivers/mtd/tests/mtd_nandecctest.c
index c1f31051784..70d6d7d0d65 100644
--- a/drivers/mtd/tests/mtd_nandecctest.c
+++ b/drivers/mtd/tests/mtd_nandecctest.c
@@ -1,7 +1,6 @@
1#include <linux/kernel.h> 1#include <linux/kernel.h>
2#include <linux/module.h> 2#include <linux/module.h>
3#include <linux/list.h> 3#include <linux/list.h>
4#include <linux/slab.h>
5#include <linux/random.h> 4#include <linux/random.h>
6#include <linux/string.h> 5#include <linux/string.h>
7#include <linux/bitops.h> 6#include <linux/bitops.h>
diff --git a/drivers/mtd/tests/mtd_oobtest.c b/drivers/mtd/tests/mtd_oobtest.c
index 5813920e79a..dec92ae6111 100644
--- a/drivers/mtd/tests/mtd_oobtest.c
+++ b/drivers/mtd/tests/mtd_oobtest.c
@@ -25,6 +25,7 @@
25#include <linux/moduleparam.h> 25#include <linux/moduleparam.h>
26#include <linux/err.h> 26#include <linux/err.h>
27#include <linux/mtd/mtd.h> 27#include <linux/mtd/mtd.h>
28#include <linux/slab.h>
28#include <linux/sched.h> 29#include <linux/sched.h>
29 30
30#define PRINT_PREF KERN_INFO "mtd_oobtest: " 31#define PRINT_PREF KERN_INFO "mtd_oobtest: "
diff --git a/drivers/mtd/tests/mtd_pagetest.c b/drivers/mtd/tests/mtd_pagetest.c
index ce17cbe918c..921a85df919 100644
--- a/drivers/mtd/tests/mtd_pagetest.c
+++ b/drivers/mtd/tests/mtd_pagetest.c
@@ -25,6 +25,7 @@
25#include <linux/moduleparam.h> 25#include <linux/moduleparam.h>
26#include <linux/err.h> 26#include <linux/err.h>
27#include <linux/mtd/mtd.h> 27#include <linux/mtd/mtd.h>
28#include <linux/slab.h>
28#include <linux/sched.h> 29#include <linux/sched.h>
29 30
30#define PRINT_PREF KERN_INFO "mtd_pagetest: " 31#define PRINT_PREF KERN_INFO "mtd_pagetest: "
diff --git a/drivers/mtd/tests/mtd_readtest.c b/drivers/mtd/tests/mtd_readtest.c
index 25c5dd03a83..7107fccbc7d 100644
--- a/drivers/mtd/tests/mtd_readtest.c
+++ b/drivers/mtd/tests/mtd_readtest.c
@@ -24,6 +24,7 @@
24#include <linux/moduleparam.h> 24#include <linux/moduleparam.h>
25#include <linux/err.h> 25#include <linux/err.h>
26#include <linux/mtd/mtd.h> 26#include <linux/mtd/mtd.h>
27#include <linux/slab.h>
27#include <linux/sched.h> 28#include <linux/sched.h>
28 29
29#define PRINT_PREF KERN_INFO "mtd_readtest: " 30#define PRINT_PREF KERN_INFO "mtd_readtest: "
diff --git a/drivers/mtd/tests/mtd_speedtest.c b/drivers/mtd/tests/mtd_speedtest.c
index 7fbb51d4eab..56ca62bb96b 100644
--- a/drivers/mtd/tests/mtd_speedtest.c
+++ b/drivers/mtd/tests/mtd_speedtest.c
@@ -24,6 +24,7 @@
24#include <linux/moduleparam.h> 24#include <linux/moduleparam.h>
25#include <linux/err.h> 25#include <linux/err.h>
26#include <linux/mtd/mtd.h> 26#include <linux/mtd/mtd.h>
27#include <linux/slab.h>
27#include <linux/sched.h> 28#include <linux/sched.h>
28 29
29#define PRINT_PREF KERN_INFO "mtd_speedtest: " 30#define PRINT_PREF KERN_INFO "mtd_speedtest: "
diff --git a/drivers/mtd/tests/mtd_stresstest.c b/drivers/mtd/tests/mtd_stresstest.c
index a99d3cd737d..3854afec56d 100644
--- a/drivers/mtd/tests/mtd_stresstest.c
+++ b/drivers/mtd/tests/mtd_stresstest.c
@@ -24,6 +24,7 @@
24#include <linux/moduleparam.h> 24#include <linux/moduleparam.h>
25#include <linux/err.h> 25#include <linux/err.h>
26#include <linux/mtd/mtd.h> 26#include <linux/mtd/mtd.h>
27#include <linux/slab.h>
27#include <linux/sched.h> 28#include <linux/sched.h>
28#include <linux/vmalloc.h> 29#include <linux/vmalloc.h>
29 30
diff --git a/drivers/mtd/tests/mtd_subpagetest.c b/drivers/mtd/tests/mtd_subpagetest.c
index 5b889724268..700237a3d12 100644
--- a/drivers/mtd/tests/mtd_subpagetest.c
+++ b/drivers/mtd/tests/mtd_subpagetest.c
@@ -24,6 +24,7 @@
24#include <linux/moduleparam.h> 24#include <linux/moduleparam.h>
25#include <linux/err.h> 25#include <linux/err.h>
26#include <linux/mtd/mtd.h> 26#include <linux/mtd/mtd.h>
27#include <linux/slab.h>
27#include <linux/sched.h> 28#include <linux/sched.h>
28 29
29#define PRINT_PREF KERN_INFO "mtd_subpagetest: " 30#define PRINT_PREF KERN_INFO "mtd_subpagetest: "
diff --git a/drivers/mtd/tests/mtd_torturetest.c b/drivers/mtd/tests/mtd_torturetest.c
index 631a0ab3a33..5c6c3d24890 100644
--- a/drivers/mtd/tests/mtd_torturetest.c
+++ b/drivers/mtd/tests/mtd_torturetest.c
@@ -28,6 +28,7 @@
28#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
29#include <linux/err.h> 29#include <linux/err.h>
30#include <linux/mtd/mtd.h> 30#include <linux/mtd/mtd.h>
31#include <linux/slab.h>
31#include <linux/sched.h> 32#include <linux/sched.h>
32 33
33#define PRINT_PREF KERN_INFO "mtd_torturetest: " 34#define PRINT_PREF KERN_INFO "mtd_torturetest: "
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index fad40aa6f09..55c726dde94 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -44,6 +44,7 @@
44#include <linux/kthread.h> 44#include <linux/kthread.h>
45#include <linux/reboot.h> 45#include <linux/reboot.h>
46#include <linux/kernel.h> 46#include <linux/kernel.h>
47#include <linux/slab.h>
47#include "ubi.h" 48#include "ubi.h"
48 49
49/* Maximum length of the 'mtd=' parameter */ 50/* Maximum length of the 'mtd=' parameter */
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
index 111ea41c4ec..72ebb3f06b8 100644
--- a/drivers/mtd/ubi/cdev.c
+++ b/drivers/mtd/ubi/cdev.c
@@ -37,6 +37,7 @@
37 37
38#include <linux/module.h> 38#include <linux/module.h>
39#include <linux/stat.h> 39#include <linux/stat.h>
40#include <linux/slab.h>
40#include <linux/ioctl.h> 41#include <linux/ioctl.h>
41#include <linux/capability.h> 42#include <linux/capability.h>
42#include <linux/uaccess.h> 43#include <linux/uaccess.h>
diff --git a/drivers/mtd/ubi/gluebi.c b/drivers/mtd/ubi/gluebi.c
index b5e478fa266..9aa81584c8a 100644
--- a/drivers/mtd/ubi/gluebi.c
+++ b/drivers/mtd/ubi/gluebi.c
@@ -31,6 +31,7 @@
31 31
32#include <linux/err.h> 32#include <linux/err.h>
33#include <linux/list.h> 33#include <linux/list.h>
34#include <linux/slab.h>
34#include <linux/sched.h> 35#include <linux/sched.h>
35#include <linux/math64.h> 36#include <linux/math64.h>
36#include <linux/module.h> 37#include <linux/module.h>
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index b4ecc84c754..533b1a4b9af 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -88,6 +88,7 @@
88 88
89#include <linux/crc32.h> 89#include <linux/crc32.h>
90#include <linux/err.h> 90#include <linux/err.h>
91#include <linux/slab.h>
91#include "ubi.h" 92#include "ubi.h"
92 93
93#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID 94#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID
diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c
index 1361574e2b0..17f287decc3 100644
--- a/drivers/mtd/ubi/kapi.c
+++ b/drivers/mtd/ubi/kapi.c
@@ -22,6 +22,7 @@
22 22
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/slab.h>
25#include <linux/namei.h> 26#include <linux/namei.h>
26#include <linux/fs.h> 27#include <linux/fs.h>
27#include <asm/div64.h> 28#include <asm/div64.h>
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index 594184bbd56..dc5f688699d 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -41,6 +41,7 @@
41 */ 41 */
42 42
43#include <linux/err.h> 43#include <linux/err.h>
44#include <linux/slab.h>
44#include <linux/crc32.h> 45#include <linux/crc32.h>
45#include <linux/math64.h> 46#include <linux/math64.h>
46#include "ubi.h" 47#include "ubi.h"
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index 1af08178def..5176d488651 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -34,6 +34,7 @@
34#include <linux/fs.h> 34#include <linux/fs.h>
35#include <linux/cdev.h> 35#include <linux/cdev.h>
36#include <linux/device.h> 36#include <linux/device.h>
37#include <linux/slab.h>
37#include <linux/string.h> 38#include <linux/string.h>
38#include <linux/vmalloc.h> 39#include <linux/vmalloc.h>
39#include <linux/notifier.h> 40#include <linux/notifier.h>
diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c
index ab64cb56df6..e42afab9a9f 100644
--- a/drivers/mtd/ubi/vmt.c
+++ b/drivers/mtd/ubi/vmt.c
@@ -25,6 +25,7 @@
25 25
26#include <linux/err.h> 26#include <linux/err.h>
27#include <linux/math64.h> 27#include <linux/math64.h>
28#include <linux/slab.h>
28#include "ubi.h" 29#include "ubi.h"
29 30
30#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID 31#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID
diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
index 40044028d68..cd90ff3b76b 100644
--- a/drivers/mtd/ubi/vtbl.c
+++ b/drivers/mtd/ubi/vtbl.c
@@ -58,6 +58,7 @@
58 58
59#include <linux/crc32.h> 59#include <linux/crc32.h>
60#include <linux/err.h> 60#include <linux/err.h>
61#include <linux/slab.h>
61#include <asm/div64.h> 62#include <asm/div64.h>
62#include "ubi.h" 63#include "ubi.h"
63 64
diff --git a/drivers/net/3c501.c b/drivers/net/3c501.c
index b6de7b1e2a5..3ea42ff1765 100644
--- a/drivers/net/3c501.c
+++ b/drivers/net/3c501.c
@@ -117,7 +117,6 @@ static const char version[] =
117#include <linux/fcntl.h> 117#include <linux/fcntl.h>
118#include <linux/ioport.h> 118#include <linux/ioport.h>
119#include <linux/interrupt.h> 119#include <linux/interrupt.h>
120#include <linux/slab.h>
121#include <linux/string.h> 120#include <linux/string.h>
122#include <linux/errno.h> 121#include <linux/errno.h>
123#include <linux/spinlock.h> 122#include <linux/spinlock.h>
diff --git a/drivers/net/3c505.c b/drivers/net/3c505.c
index 04b5bba1902..29b8d1d63bd 100644
--- a/drivers/net/3c505.c
+++ b/drivers/net/3c505.c
@@ -102,12 +102,12 @@
102#include <linux/interrupt.h> 102#include <linux/interrupt.h>
103#include <linux/errno.h> 103#include <linux/errno.h>
104#include <linux/in.h> 104#include <linux/in.h>
105#include <linux/slab.h>
106#include <linux/ioport.h> 105#include <linux/ioport.h>
107#include <linux/spinlock.h> 106#include <linux/spinlock.h>
108#include <linux/ethtool.h> 107#include <linux/ethtool.h>
109#include <linux/delay.h> 108#include <linux/delay.h>
110#include <linux/bitops.h> 109#include <linux/bitops.h>
110#include <linux/gfp.h>
111 111
112#include <asm/uaccess.h> 112#include <asm/uaccess.h>
113#include <asm/io.h> 113#include <asm/io.h>
diff --git a/drivers/net/3c507.c b/drivers/net/3c507.c
index 77cf0901a44..b32b7a1710b 100644
--- a/drivers/net/3c507.c
+++ b/drivers/net/3c507.c
@@ -58,7 +58,6 @@ static const char version[] =
58#include <linux/etherdevice.h> 58#include <linux/etherdevice.h>
59#include <linux/if_ether.h> 59#include <linux/if_ether.h>
60#include <linux/skbuff.h> 60#include <linux/skbuff.h>
61#include <linux/slab.h>
62#include <linux/init.h> 61#include <linux/init.h>
63#include <linux/bitops.h> 62#include <linux/bitops.h>
64 63
diff --git a/drivers/net/3c509.c b/drivers/net/3c509.c
index 902435a7646..ab9bb3c5200 100644
--- a/drivers/net/3c509.c
+++ b/drivers/net/3c509.c
@@ -76,7 +76,6 @@
76#include <linux/interrupt.h> 76#include <linux/interrupt.h>
77#include <linux/errno.h> 77#include <linux/errno.h>
78#include <linux/in.h> 78#include <linux/in.h>
79#include <linux/slab.h>
80#include <linux/ioport.h> 79#include <linux/ioport.h>
81#include <linux/init.h> 80#include <linux/init.h>
82#include <linux/netdevice.h> 81#include <linux/netdevice.h>
diff --git a/drivers/net/3c515.c b/drivers/net/3c515.c
index 1e898b1c806..2e17837be54 100644
--- a/drivers/net/3c515.c
+++ b/drivers/net/3c515.c
@@ -65,7 +65,6 @@ static int max_interrupt_work = 20;
65#include <linux/errno.h> 65#include <linux/errno.h>
66#include <linux/in.h> 66#include <linux/in.h>
67#include <linux/ioport.h> 67#include <linux/ioport.h>
68#include <linux/slab.h>
69#include <linux/skbuff.h> 68#include <linux/skbuff.h>
70#include <linux/etherdevice.h> 69#include <linux/etherdevice.h>
71#include <linux/interrupt.h> 70#include <linux/interrupt.h>
diff --git a/drivers/net/3c523.c b/drivers/net/3c523.c
index beed4fa10c6..1719079cc49 100644
--- a/drivers/net/3c523.c
+++ b/drivers/net/3c523.c
@@ -99,7 +99,6 @@
99#include <linux/errno.h> 99#include <linux/errno.h>
100#include <linux/ioport.h> 100#include <linux/ioport.h>
101#include <linux/skbuff.h> 101#include <linux/skbuff.h>
102#include <linux/slab.h>
103#include <linux/interrupt.h> 102#include <linux/interrupt.h>
104#include <linux/delay.h> 103#include <linux/delay.h>
105#include <linux/mca-legacy.h> 104#include <linux/mca-legacy.h>
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
index f965431f492..5f92fdbe66e 100644
--- a/drivers/net/3c59x.c
+++ b/drivers/net/3c59x.c
@@ -77,7 +77,6 @@ static int vortex_debug = 1;
77#include <linux/errno.h> 77#include <linux/errno.h>
78#include <linux/in.h> 78#include <linux/in.h>
79#include <linux/ioport.h> 79#include <linux/ioport.h>
80#include <linux/slab.h>
81#include <linux/interrupt.h> 80#include <linux/interrupt.h>
82#include <linux/pci.h> 81#include <linux/pci.h>
83#include <linux/mii.h> 82#include <linux/mii.h>
@@ -90,6 +89,7 @@ static int vortex_debug = 1;
90#include <linux/eisa.h> 89#include <linux/eisa.h>
91#include <linux/bitops.h> 90#include <linux/bitops.h>
92#include <linux/jiffies.h> 91#include <linux/jiffies.h>
92#include <linux/gfp.h>
93#include <asm/irq.h> /* For nr_irqs only. */ 93#include <asm/irq.h> /* For nr_irqs only. */
94#include <asm/io.h> 94#include <asm/io.h>
95#include <asm/uaccess.h> 95#include <asm/uaccess.h>
diff --git a/drivers/net/7990.c b/drivers/net/7990.c
index 4e9a5a20b6a..500e135723b 100644
--- a/drivers/net/7990.c
+++ b/drivers/net/7990.c
@@ -26,7 +26,6 @@
26#include <linux/ioport.h> 26#include <linux/ioport.h>
27#include <linux/in.h> 27#include <linux/in.h>
28#include <linux/route.h> 28#include <linux/route.h>
29#include <linux/slab.h>
30#include <linux/string.h> 29#include <linux/string.h>
31#include <linux/skbuff.h> 30#include <linux/skbuff.h>
32#include <asm/irq.h> 31#include <asm/irq.h>
diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c
index 3d4406b1665..a09e6ce3eaa 100644
--- a/drivers/net/8139cp.c
+++ b/drivers/net/8139cp.c
@@ -64,6 +64,7 @@
64#include <linux/dma-mapping.h> 64#include <linux/dma-mapping.h>
65#include <linux/delay.h> 65#include <linux/delay.h>
66#include <linux/ethtool.h> 66#include <linux/ethtool.h>
67#include <linux/gfp.h>
67#include <linux/mii.h> 68#include <linux/mii.h>
68#include <linux/if_vlan.h> 69#include <linux/if_vlan.h>
69#include <linux/crc32.h> 70#include <linux/crc32.h>
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index b4efc913978..f0d23de3296 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -110,6 +110,7 @@
110#include <linux/crc32.h> 110#include <linux/crc32.h>
111#include <linux/io.h> 111#include <linux/io.h>
112#include <linux/uaccess.h> 112#include <linux/uaccess.h>
113#include <linux/gfp.h>
113#include <asm/irq.h> 114#include <asm/irq.h>
114 115
115#define RTL8139_DRIVER_NAME DRV_NAME " Fast Ethernet driver " DRV_VERSION 116#define RTL8139_DRIVER_NAME DRV_NAME " Fast Ethernet driver " DRV_VERSION
@@ -1943,7 +1944,7 @@ static int rtl8139_rx(struct net_device *dev, struct rtl8139_private *tp,
1943 netif_dbg(tp, rx_status, dev, "%s() status %04x, size %04x, cur %04x\n", 1944 netif_dbg(tp, rx_status, dev, "%s() status %04x, size %04x, cur %04x\n",
1944 __func__, rx_status, rx_size, cur_rx); 1945 __func__, rx_status, rx_size, cur_rx);
1945#if RTL8139_DEBUG > 2 1946#if RTL8139_DEBUG > 2
1946 print_dump_hex(KERN_DEBUG, "Frame contents: ", 1947 print_hex_dump(KERN_DEBUG, "Frame contents: ",
1947 DUMP_PREFIX_OFFSET, 16, 1, 1948 DUMP_PREFIX_OFFSET, 16, 1,
1948 &rx_ring[ring_offset], 70, true); 1949 &rx_ring[ring_offset], 70, true);
1949#endif 1950#endif
diff --git a/drivers/net/82596.c b/drivers/net/82596.c
index f94d17d78bb..56e68db4886 100644
--- a/drivers/net/82596.c
+++ b/drivers/net/82596.c
@@ -45,7 +45,6 @@
45#include <linux/string.h> 45#include <linux/string.h>
46#include <linux/errno.h> 46#include <linux/errno.h>
47#include <linux/ioport.h> 47#include <linux/ioport.h>
48#include <linux/slab.h>
49#include <linux/interrupt.h> 48#include <linux/interrupt.h>
50#include <linux/delay.h> 49#include <linux/delay.h>
51#include <linux/netdevice.h> 50#include <linux/netdevice.h>
@@ -53,6 +52,7 @@
53#include <linux/skbuff.h> 52#include <linux/skbuff.h>
54#include <linux/init.h> 53#include <linux/init.h>
55#include <linux/bitops.h> 54#include <linux/bitops.h>
55#include <linux/gfp.h>
56 56
57#include <asm/io.h> 57#include <asm/io.h>
58#include <asm/dma.h> 58#include <asm/dma.h>
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 0ba5b8e50a7..7b832c727f8 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2582,6 +2582,31 @@ config CHELSIO_T3
2582 To compile this driver as a module, choose M here: the module 2582 To compile this driver as a module, choose M here: the module
2583 will be called cxgb3. 2583 will be called cxgb3.
2584 2584
2585config CHELSIO_T4_DEPENDS
2586 tristate
2587 depends on PCI && INET
2588 default y
2589
2590config CHELSIO_T4
2591 tristate "Chelsio Communications T4 Ethernet support"
2592 depends on CHELSIO_T4_DEPENDS
2593 select FW_LOADER
2594 select MDIO
2595 help
2596 This driver supports Chelsio T4-based gigabit and 10Gb Ethernet
2597 adapters.
2598
2599 For general information about Chelsio and our products, visit
2600 our website at <http://www.chelsio.com>.
2601
2602 For customer support, please visit our customer support page at
2603 <http://www.chelsio.com/support.htm>.
2604
2605 Please send feedback to <linux-bugs@chelsio.com>.
2606
2607 To compile this driver as a module choose M here; the module
2608 will be called cxgb4.
2609
2585config EHEA 2610config EHEA
2586 tristate "eHEA Ethernet support" 2611 tristate "eHEA Ethernet support"
2587 depends on IBMEBUS && INET && SPARSEMEM 2612 depends on IBMEBUS && INET && SPARSEMEM
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 478886234c2..12b280afdd5 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_IXGB) += ixgb/
19obj-$(CONFIG_IP1000) += ipg.o 19obj-$(CONFIG_IP1000) += ipg.o
20obj-$(CONFIG_CHELSIO_T1) += chelsio/ 20obj-$(CONFIG_CHELSIO_T1) += chelsio/
21obj-$(CONFIG_CHELSIO_T3) += cxgb3/ 21obj-$(CONFIG_CHELSIO_T3) += cxgb3/
22obj-$(CONFIG_CHELSIO_T4) += cxgb4/
22obj-$(CONFIG_EHEA) += ehea/ 23obj-$(CONFIG_EHEA) += ehea/
23obj-$(CONFIG_CAN) += can/ 24obj-$(CONFIG_CAN) += can/
24obj-$(CONFIG_BONDING) += bonding/ 25obj-$(CONFIG_BONDING) += bonding/
@@ -272,6 +273,7 @@ obj-$(CONFIG_USB_RTL8150) += usb/
272obj-$(CONFIG_USB_HSO) += usb/ 273obj-$(CONFIG_USB_HSO) += usb/
273obj-$(CONFIG_USB_USBNET) += usb/ 274obj-$(CONFIG_USB_USBNET) += usb/
274obj-$(CONFIG_USB_ZD1201) += usb/ 275obj-$(CONFIG_USB_ZD1201) += usb/
276obj-$(CONFIG_USB_IPHETH) += usb/
275 277
276obj-y += wireless/ 278obj-y += wireless/
277obj-$(CONFIG_NET_TULIP) += tulip/ 279obj-$(CONFIG_NET_TULIP) += tulip/
diff --git a/drivers/net/a2065.c b/drivers/net/a2065.c
index bd4d829eca1..ed5e9742be2 100644
--- a/drivers/net/a2065.c
+++ b/drivers/net/a2065.c
@@ -46,7 +46,6 @@
46#include <linux/interrupt.h> 46#include <linux/interrupt.h>
47#include <linux/ioport.h> 47#include <linux/ioport.h>
48#include <linux/skbuff.h> 48#include <linux/skbuff.h>
49#include <linux/slab.h>
50#include <linux/string.h> 49#include <linux/string.h>
51#include <linux/init.h> 50#include <linux/init.h>
52#include <linux/crc32.h> 51#include <linux/crc32.h>
diff --git a/drivers/net/acenic.c b/drivers/net/acenic.c
index 4ae750ef1e1..97a3dfd94df 100644
--- a/drivers/net/acenic.c
+++ b/drivers/net/acenic.c
@@ -67,6 +67,7 @@
67#include <linux/highmem.h> 67#include <linux/highmem.h>
68#include <linux/sockios.h> 68#include <linux/sockios.h>
69#include <linux/firmware.h> 69#include <linux/firmware.h>
70#include <linux/slab.h>
70 71
71#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) 72#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
72#include <linux/if_vlan.h> 73#include <linux/if_vlan.h>
diff --git a/drivers/net/amd8111e.c b/drivers/net/amd8111e.c
index b8a59d255b4..8d58f0a8f42 100644
--- a/drivers/net/amd8111e.c
+++ b/drivers/net/amd8111e.c
@@ -73,7 +73,6 @@ Revision History:
73#include <linux/kernel.h> 73#include <linux/kernel.h>
74#include <linux/types.h> 74#include <linux/types.h>
75#include <linux/compiler.h> 75#include <linux/compiler.h>
76#include <linux/slab.h>
77#include <linux/delay.h> 76#include <linux/delay.h>
78#include <linux/init.h> 77#include <linux/init.h>
79#include <linux/ioport.h> 78#include <linux/ioport.h>
diff --git a/drivers/net/appletalk/cops.c b/drivers/net/appletalk/cops.c
index 73b38c204eb..6f8d6206b5c 100644
--- a/drivers/net/appletalk/cops.c
+++ b/drivers/net/appletalk/cops.c
@@ -56,7 +56,6 @@ static const char *version =
56#include <linux/ptrace.h> 56#include <linux/ptrace.h>
57#include <linux/ioport.h> 57#include <linux/ioport.h>
58#include <linux/in.h> 58#include <linux/in.h>
59#include <linux/slab.h>
60#include <linux/string.h> 59#include <linux/string.h>
61#include <linux/errno.h> 60#include <linux/errno.h>
62#include <linux/init.h> 61#include <linux/init.h>
diff --git a/drivers/net/appletalk/ipddp.c b/drivers/net/appletalk/ipddp.c
index eb0448b03f4..79636ee3582 100644
--- a/drivers/net/appletalk/ipddp.c
+++ b/drivers/net/appletalk/ipddp.c
@@ -31,6 +31,7 @@
31#include <linux/ip.h> 31#include <linux/ip.h>
32#include <linux/atalk.h> 32#include <linux/atalk.h>
33#include <linux/if_arp.h> 33#include <linux/if_arp.h>
34#include <linux/slab.h>
34#include <net/route.h> 35#include <net/route.h>
35#include <asm/uaccess.h> 36#include <asm/uaccess.h>
36 37
diff --git a/drivers/net/appletalk/ltpc.c b/drivers/net/appletalk/ltpc.c
index 8ea4ec705be..6af65b656f3 100644
--- a/drivers/net/appletalk/ltpc.c
+++ b/drivers/net/appletalk/ltpc.c
@@ -215,7 +215,6 @@ static int dma;
215#include <linux/ioport.h> 215#include <linux/ioport.h>
216#include <linux/spinlock.h> 216#include <linux/spinlock.h>
217#include <linux/in.h> 217#include <linux/in.h>
218#include <linux/slab.h>
219#include <linux/string.h> 218#include <linux/string.h>
220#include <linux/errno.h> 219#include <linux/errno.h>
221#include <linux/init.h> 220#include <linux/init.h>
@@ -228,6 +227,7 @@ static int dma;
228#include <linux/timer.h> 227#include <linux/timer.h>
229#include <linux/atalk.h> 228#include <linux/atalk.h>
230#include <linux/bitops.h> 229#include <linux/bitops.h>
230#include <linux/gfp.h>
231 231
232#include <asm/system.h> 232#include <asm/system.h>
233#include <asm/dma.h> 233#include <asm/dma.h>
diff --git a/drivers/net/arcnet/arc-rawmode.c b/drivers/net/arcnet/arc-rawmode.c
index 8ea9c7545c1..705e6ce2eb9 100644
--- a/drivers/net/arcnet/arc-rawmode.c
+++ b/drivers/net/arcnet/arc-rawmode.c
@@ -25,6 +25,7 @@
25 */ 25 */
26 26
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/gfp.h>
28#include <linux/init.h> 29#include <linux/init.h>
29#include <linux/if_arp.h> 30#include <linux/if_arp.h>
30#include <net/arp.h> 31#include <net/arp.h>
diff --git a/drivers/net/arcnet/arc-rimi.c b/drivers/net/arcnet/arc-rimi.c
index e6afab2455b..9efbbbae47c 100644
--- a/drivers/net/arcnet/arc-rimi.c
+++ b/drivers/net/arcnet/arc-rimi.c
@@ -28,7 +28,6 @@
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
30#include <linux/ioport.h> 30#include <linux/ioport.h>
31#include <linux/slab.h>
32#include <linux/delay.h> 31#include <linux/delay.h>
33#include <linux/netdevice.h> 32#include <linux/netdevice.h>
34#include <linux/bootmem.h> 33#include <linux/bootmem.h>
diff --git a/drivers/net/arcnet/capmode.c b/drivers/net/arcnet/capmode.c
index 66bcbbb6bab..355797f7004 100644
--- a/drivers/net/arcnet/capmode.c
+++ b/drivers/net/arcnet/capmode.c
@@ -27,6 +27,7 @@
27 */ 27 */
28 28
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/gfp.h>
30#include <linux/init.h> 31#include <linux/init.h>
31#include <linux/if_arp.h> 32#include <linux/if_arp.h>
32#include <net/arp.h> 33#include <net/arp.h>
diff --git a/drivers/net/arcnet/com20020-isa.c b/drivers/net/arcnet/com20020-isa.c
index db08fc24047..0402da30a4e 100644
--- a/drivers/net/arcnet/com20020-isa.c
+++ b/drivers/net/arcnet/com20020-isa.c
@@ -30,7 +30,6 @@
30#include <linux/kernel.h> 30#include <linux/kernel.h>
31#include <linux/types.h> 31#include <linux/types.h>
32#include <linux/ioport.h> 32#include <linux/ioport.h>
33#include <linux/slab.h>
34#include <linux/errno.h> 33#include <linux/errno.h>
35#include <linux/delay.h> 34#include <linux/delay.h>
36#include <linux/netdevice.h> 35#include <linux/netdevice.h>
diff --git a/drivers/net/arcnet/com20020-pci.c b/drivers/net/arcnet/com20020-pci.c
index b68e1eb405f..2c712af6c26 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -31,7 +31,6 @@
31#include <linux/kernel.h> 31#include <linux/kernel.h>
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/ioport.h> 33#include <linux/ioport.h>
34#include <linux/slab.h>
35#include <linux/errno.h> 34#include <linux/errno.h>
36#include <linux/netdevice.h> 35#include <linux/netdevice.h>
37#include <linux/init.h> 36#include <linux/init.h>
diff --git a/drivers/net/arcnet/com20020.c b/drivers/net/arcnet/com20020.c
index 0a74f21409c..c9e459400ff 100644
--- a/drivers/net/arcnet/com20020.c
+++ b/drivers/net/arcnet/com20020.c
@@ -29,7 +29,6 @@
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/ioport.h> 31#include <linux/ioport.h>
32#include <linux/slab.h>
33#include <linux/errno.h> 32#include <linux/errno.h>
34#include <linux/delay.h> 33#include <linux/delay.h>
35#include <linux/netdevice.h> 34#include <linux/netdevice.h>
diff --git a/drivers/net/arcnet/com90io.c b/drivers/net/arcnet/com90io.c
index 28dea518d55..4cb401813b7 100644
--- a/drivers/net/arcnet/com90io.c
+++ b/drivers/net/arcnet/com90io.c
@@ -29,7 +29,6 @@
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/moduleparam.h> 30#include <linux/moduleparam.h>
31#include <linux/ioport.h> 31#include <linux/ioport.h>
32#include <linux/slab.h>
33#include <linux/delay.h> 32#include <linux/delay.h>
34#include <linux/netdevice.h> 33#include <linux/netdevice.h>
35#include <linux/bootmem.h> 34#include <linux/bootmem.h>
diff --git a/drivers/net/arcnet/com90xx.c b/drivers/net/arcnet/com90xx.c
index 112e230cb13..f3b46f71e29 100644
--- a/drivers/net/arcnet/com90xx.c
+++ b/drivers/net/arcnet/com90xx.c
@@ -30,6 +30,7 @@
30#include <linux/ioport.h> 30#include <linux/ioport.h>
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/netdevice.h> 32#include <linux/netdevice.h>
33#include <linux/slab.h>
33#include <asm/io.h> 34#include <asm/io.h>
34#include <linux/arcdevice.h> 35#include <linux/arcdevice.h>
35 36
diff --git a/drivers/net/arcnet/rfc1051.c b/drivers/net/arcnet/rfc1051.c
index 06f8fa2f8f2..f81db4070a5 100644
--- a/drivers/net/arcnet/rfc1051.c
+++ b/drivers/net/arcnet/rfc1051.c
@@ -24,6 +24,7 @@
24 * ********************** 24 * **********************
25 */ 25 */
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/gfp.h>
27#include <linux/init.h> 28#include <linux/init.h>
28#include <linux/if_arp.h> 29#include <linux/if_arp.h>
29#include <net/arp.h> 30#include <net/arp.h>
diff --git a/drivers/net/arcnet/rfc1201.c b/drivers/net/arcnet/rfc1201.c
index 745530651c4..b71431aae08 100644
--- a/drivers/net/arcnet/rfc1201.c
+++ b/drivers/net/arcnet/rfc1201.c
@@ -23,6 +23,7 @@
23 * 23 *
24 * ********************** 24 * **********************
25 */ 25 */
26#include <linux/gfp.h>
26#include <linux/module.h> 27#include <linux/module.h>
27#include <linux/init.h> 28#include <linux/init.h>
28#include <linux/if_arp.h> 29#include <linux/if_arp.h>
diff --git a/drivers/net/ariadne.c b/drivers/net/ariadne.c
index 08d8be47dae..fa1a2354f5f 100644
--- a/drivers/net/ariadne.c
+++ b/drivers/net/ariadne.c
@@ -40,7 +40,6 @@
40#include <linux/string.h> 40#include <linux/string.h>
41#include <linux/errno.h> 41#include <linux/errno.h>
42#include <linux/ioport.h> 42#include <linux/ioport.h>
43#include <linux/slab.h>
44#include <linux/netdevice.h> 43#include <linux/netdevice.h>
45#include <linux/etherdevice.h> 44#include <linux/etherdevice.h>
46#include <linux/interrupt.h> 45#include <linux/interrupt.h>
diff --git a/drivers/net/arm/at91_ether.c b/drivers/net/arm/at91_ether.c
index 8b23d5a175b..aed5b5479b5 100644
--- a/drivers/net/arm/at91_ether.c
+++ b/drivers/net/arm/at91_ether.c
@@ -27,6 +27,7 @@
27#include <linux/ethtool.h> 27#include <linux/ethtool.h>
28#include <linux/platform_device.h> 28#include <linux/platform_device.h>
29#include <linux/clk.h> 29#include <linux/clk.h>
30#include <linux/gfp.h>
30 31
31#include <asm/io.h> 32#include <asm/io.h>
32#include <asm/uaccess.h> 33#include <asm/uaccess.h>
diff --git a/drivers/net/arm/ep93xx_eth.c b/drivers/net/arm/ep93xx_eth.c
index bf72d57a0af..cd17d09f385 100644
--- a/drivers/net/arm/ep93xx_eth.c
+++ b/drivers/net/arm/ep93xx_eth.c
@@ -23,6 +23,7 @@
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/io.h> 25#include <linux/io.h>
26#include <linux/slab.h>
26 27
27#include <mach/hardware.h> 28#include <mach/hardware.h>
28 29
@@ -310,11 +311,6 @@ err:
310 processed++; 311 processed++;
311 } 312 }
312 313
313 if (processed) {
314 wrw(ep, REG_RXDENQ, processed);
315 wrw(ep, REG_RXSTSENQ, processed);
316 }
317
318 return processed; 314 return processed;
319} 315}
320 316
@@ -349,6 +345,11 @@ poll_some_more:
349 goto poll_some_more; 345 goto poll_some_more;
350 } 346 }
351 347
348 if (rx) {
349 wrw(ep, REG_RXDENQ, rx);
350 wrw(ep, REG_RXSTSENQ, rx);
351 }
352
352 return rx; 353 return rx;
353} 354}
354 355
diff --git a/drivers/net/arm/etherh.c b/drivers/net/arm/etherh.c
index f52f668c49b..4af235d41fd 100644
--- a/drivers/net/arm/etherh.c
+++ b/drivers/net/arm/etherh.c
@@ -33,7 +33,6 @@
33#include <linux/interrupt.h> 33#include <linux/interrupt.h>
34#include <linux/ioport.h> 34#include <linux/ioport.h>
35#include <linux/in.h> 35#include <linux/in.h>
36#include <linux/slab.h>
37#include <linux/string.h> 36#include <linux/string.h>
38#include <linux/errno.h> 37#include <linux/errno.h>
39#include <linux/netdevice.h> 38#include <linux/netdevice.h>
diff --git a/drivers/net/arm/ixp4xx_eth.c b/drivers/net/arm/ixp4xx_eth.c
index 6e2ae1d06df..6be8b098b8b 100644
--- a/drivers/net/arm/ixp4xx_eth.c
+++ b/drivers/net/arm/ixp4xx_eth.c
@@ -32,6 +32,7 @@
32#include <linux/kernel.h> 32#include <linux/kernel.h>
33#include <linux/phy.h> 33#include <linux/phy.h>
34#include <linux/platform_device.h> 34#include <linux/platform_device.h>
35#include <linux/slab.h>
35#include <mach/npe.h> 36#include <mach/npe.h>
36#include <mach/qmgr.h> 37#include <mach/qmgr.h>
37 38
diff --git a/drivers/net/arm/ks8695net.c b/drivers/net/arm/ks8695net.c
index a1d4188c430..84f8a8f7380 100644
--- a/drivers/net/arm/ks8695net.c
+++ b/drivers/net/arm/ks8695net.c
@@ -30,6 +30,7 @@
30#include <linux/platform_device.h> 30#include <linux/platform_device.h>
31#include <linux/irq.h> 31#include <linux/irq.h>
32#include <linux/io.h> 32#include <linux/io.h>
33#include <linux/slab.h>
33 34
34#include <asm/irq.h> 35#include <asm/irq.h>
35 36
@@ -449,11 +450,10 @@ ks8695_rx_irq(int irq, void *dev_id)
449} 450}
450 451
451/** 452/**
452 * ks8695_rx - Receive packets called by NAPI poll method 453 * ks8695_rx - Receive packets called by NAPI poll method
453 * @ksp: Private data for the KS8695 Ethernet 454 * @ksp: Private data for the KS8695 Ethernet
454 * @budget: The max packets would be receive 455 * @budget: Number of packets allowed to process
455 */ 456 */
456
457static int ks8695_rx(struct ks8695_priv *ksp, int budget) 457static int ks8695_rx(struct ks8695_priv *ksp, int budget)
458{ 458{
459 struct net_device *ndev = ksp->ndev; 459 struct net_device *ndev = ksp->ndev;
@@ -461,7 +461,6 @@ static int ks8695_rx(struct ks8695_priv *ksp, int budget)
461 int buff_n; 461 int buff_n;
462 u32 flags; 462 u32 flags;
463 int pktlen; 463 int pktlen;
464 int last_rx_processed = -1;
465 int received = 0; 464 int received = 0;
466 465
467 buff_n = ksp->next_rx_desc_read; 466 buff_n = ksp->next_rx_desc_read;
@@ -471,6 +470,7 @@ static int ks8695_rx(struct ks8695_priv *ksp, int budget)
471 cpu_to_le32(RDES_OWN)))) { 470 cpu_to_le32(RDES_OWN)))) {
472 rmb(); 471 rmb();
473 flags = le32_to_cpu(ksp->rx_ring[buff_n].status); 472 flags = le32_to_cpu(ksp->rx_ring[buff_n].status);
473
474 /* Found an SKB which we own, this means we 474 /* Found an SKB which we own, this means we
475 * received a packet 475 * received a packet
476 */ 476 */
@@ -533,23 +533,18 @@ rx_failure:
533 ksp->rx_ring[buff_n].status = cpu_to_le32(RDES_OWN); 533 ksp->rx_ring[buff_n].status = cpu_to_le32(RDES_OWN);
534rx_finished: 534rx_finished:
535 received++; 535 received++;
536 /* And note this as processed so we can start
537 * from here next time
538 */
539 last_rx_processed = buff_n;
540 buff_n = (buff_n + 1) & MAX_RX_DESC_MASK; 536 buff_n = (buff_n + 1) & MAX_RX_DESC_MASK;
541 /*And note which RX descriptor we last did */
542 if (likely(last_rx_processed != -1))
543 ksp->next_rx_desc_read =
544 (last_rx_processed + 1) &
545 MAX_RX_DESC_MASK;
546 } 537 }
538
539 /* And note which RX descriptor we last did */
540 ksp->next_rx_desc_read = buff_n;
541
547 /* And refill the buffers */ 542 /* And refill the buffers */
548 ks8695_refill_rxbuffers(ksp); 543 ks8695_refill_rxbuffers(ksp);
549 544
550 /* Kick the RX DMA engine, in case it became 545 /* Kick the RX DMA engine, in case it became suspended */
551 * suspended */
552 ks8695_writereg(ksp, KS8695_DRSC, 0); 546 ks8695_writereg(ksp, KS8695_DRSC, 0);
547
553 return received; 548 return received;
554} 549}
555 550
diff --git a/drivers/net/arm/w90p910_ether.c b/drivers/net/arm/w90p910_ether.c
index febd813c916..f7c9ca1dfb1 100644
--- a/drivers/net/arm/w90p910_ether.c
+++ b/drivers/net/arm/w90p910_ether.c
@@ -18,6 +18,7 @@
18#include <linux/ethtool.h> 18#include <linux/ethtool.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/clk.h> 20#include <linux/clk.h>
21#include <linux/gfp.h>
21 22
22#define DRV_MODULE_NAME "w90p910-emc" 23#define DRV_MODULE_NAME "w90p910-emc"
23#define DRV_MODULE_VERSION "0.1" 24#define DRV_MODULE_VERSION "0.1"
diff --git a/drivers/net/at1700.c b/drivers/net/at1700.c
index 309843ab886..10a20fb9ae6 100644
--- a/drivers/net/at1700.c
+++ b/drivers/net/at1700.c
@@ -47,7 +47,6 @@
47#include <linux/ioport.h> 47#include <linux/ioport.h>
48#include <linux/in.h> 48#include <linux/in.h>
49#include <linux/skbuff.h> 49#include <linux/skbuff.h>
50#include <linux/slab.h>
51#include <linux/string.h> 50#include <linux/string.h>
52#include <linux/init.h> 51#include <linux/init.h>
53#include <linux/crc32.h> 52#include <linux/crc32.h>
diff --git a/drivers/net/atarilance.c b/drivers/net/atarilance.c
index 280cfff48b4..a8686bfec7a 100644
--- a/drivers/net/atarilance.c
+++ b/drivers/net/atarilance.c
@@ -53,7 +53,6 @@ static char version[] = "atarilance.c: v1.3 04/04/96 "
53#include <linux/string.h> 53#include <linux/string.h>
54#include <linux/errno.h> 54#include <linux/errno.h>
55#include <linux/skbuff.h> 55#include <linux/skbuff.h>
56#include <linux/slab.h>
57#include <linux/interrupt.h> 56#include <linux/interrupt.h>
58#include <linux/init.h> 57#include <linux/init.h>
59#include <linux/bitops.h> 58#include <linux/bitops.h>
diff --git a/drivers/net/atl1c/atl1c_ethtool.c b/drivers/net/atl1c/atl1c_ethtool.c
index 61a0f2ff11e..32339243d61 100644
--- a/drivers/net/atl1c/atl1c_ethtool.c
+++ b/drivers/net/atl1c/atl1c_ethtool.c
@@ -22,6 +22,7 @@
22 22
23#include <linux/netdevice.h> 23#include <linux/netdevice.h>
24#include <linux/ethtool.h> 24#include <linux/ethtool.h>
25#include <linux/slab.h>
25 26
26#include "atl1c.h" 27#include "atl1c.h"
27 28
diff --git a/drivers/net/atl1e/atl1e_ethtool.c b/drivers/net/atl1e/atl1e_ethtool.c
index a76006c1bc6..ffd696ee7c8 100644
--- a/drivers/net/atl1e/atl1e_ethtool.c
+++ b/drivers/net/atl1e/atl1e_ethtool.c
@@ -22,6 +22,7 @@
22 22
23#include <linux/netdevice.h> 23#include <linux/netdevice.h>
24#include <linux/ethtool.h> 24#include <linux/ethtool.h>
25#include <linux/slab.h>
25 26
26#include "atl1e.h" 27#include "atl1e.h"
27 28
diff --git a/drivers/net/atlx/atl1.c b/drivers/net/atlx/atl1.c
index 9ba547069db..0ebd8208f60 100644
--- a/drivers/net/atlx/atl1.c
+++ b/drivers/net/atlx/atl1.c
@@ -84,7 +84,7 @@
84 84
85#define ATLX_DRIVER_VERSION "2.1.3" 85#define ATLX_DRIVER_VERSION "2.1.3"
86MODULE_AUTHOR("Xiong Huang <xiong.huang@atheros.com>, \ 86MODULE_AUTHOR("Xiong Huang <xiong.huang@atheros.com>, \
87 Chris Snook <csnook@redhat.com>, Jay Cliburn <jcliburn@gmail.com>"); 87Chris Snook <csnook@redhat.com>, Jay Cliburn <jcliburn@gmail.com>");
88MODULE_LICENSE("GPL"); 88MODULE_LICENSE("GPL");
89MODULE_VERSION(ATLX_DRIVER_VERSION); 89MODULE_VERSION(ATLX_DRIVER_VERSION);
90 90
diff --git a/drivers/net/atlx/atl2.c b/drivers/net/atlx/atl2.c
index 7061d7108f0..54662f24f9b 100644
--- a/drivers/net/atlx/atl2.c
+++ b/drivers/net/atlx/atl2.c
@@ -39,6 +39,7 @@
39#include <linux/pci_ids.h> 39#include <linux/pci_ids.h>
40#include <linux/pm.h> 40#include <linux/pm.h>
41#include <linux/skbuff.h> 41#include <linux/skbuff.h>
42#include <linux/slab.h>
42#include <linux/spinlock.h> 43#include <linux/spinlock.h>
43#include <linux/string.h> 44#include <linux/string.h>
44#include <linux/tcp.h> 45#include <linux/tcp.h>
diff --git a/drivers/net/atp.c b/drivers/net/atp.c
index 6ad16205dc1..55039d44dc4 100644
--- a/drivers/net/atp.c
+++ b/drivers/net/atp.c
@@ -129,7 +129,6 @@ static int xcvr[NUM_UNITS]; /* The data transfer mode. */
129#include <linux/interrupt.h> 129#include <linux/interrupt.h>
130#include <linux/ioport.h> 130#include <linux/ioport.h>
131#include <linux/in.h> 131#include <linux/in.h>
132#include <linux/slab.h>
133#include <linux/string.h> 132#include <linux/string.h>
134#include <linux/errno.h> 133#include <linux/errno.h>
135#include <linux/init.h> 134#include <linux/init.h>
diff --git a/drivers/net/ax88796.c b/drivers/net/ax88796.c
index 1dd4403247c..b718dc60afc 100644
--- a/drivers/net/ax88796.c
+++ b/drivers/net/ax88796.c
@@ -25,6 +25,7 @@
25#include <linux/ethtool.h> 25#include <linux/ethtool.h>
26#include <linux/mii.h> 26#include <linux/mii.h>
27#include <linux/eeprom_93cx6.h> 27#include <linux/eeprom_93cx6.h>
28#include <linux/slab.h>
28 29
29#include <net/ax88796.h> 30#include <net/ax88796.h>
30 31
diff --git a/drivers/net/b44.c b/drivers/net/b44.c
index 332c6035628..69d9f3d368a 100644
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -27,6 +27,7 @@
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/dma-mapping.h> 28#include <linux/dma-mapping.h>
29#include <linux/ssb/ssb.h> 29#include <linux/ssb/ssb.h>
30#include <linux/slab.h>
30 31
31#include <asm/uaccess.h> 32#include <asm/uaccess.h>
32#include <asm/io.h> 33#include <asm/io.h>
diff --git a/drivers/net/bcm63xx_enet.c b/drivers/net/bcm63xx_enet.c
index 8cdcab7655c..17460aba3ba 100644
--- a/drivers/net/bcm63xx_enet.c
+++ b/drivers/net/bcm63xx_enet.c
@@ -21,6 +21,7 @@
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/clk.h> 22#include <linux/clk.h>
23#include <linux/etherdevice.h> 23#include <linux/etherdevice.h>
24#include <linux/slab.h>
24#include <linux/delay.h> 25#include <linux/delay.h>
25#include <linux/ethtool.h> 26#include <linux/ethtool.h>
26#include <linux/crc32.h> 27#include <linux/crc32.h>
diff --git a/drivers/net/benet/be.h b/drivers/net/benet/be.h
index 8f075255368..56387b191c9 100644
--- a/drivers/net/benet/be.h
+++ b/drivers/net/benet/be.h
@@ -29,6 +29,7 @@
29#include <linux/workqueue.h> 29#include <linux/workqueue.h>
30#include <linux/interrupt.h> 30#include <linux/interrupt.h>
31#include <linux/firmware.h> 31#include <linux/firmware.h>
32#include <linux/slab.h>
32 33
33#include "be_hw.h" 34#include "be_hw.h"
34 35
diff --git a/drivers/net/benet/be_cmds.c b/drivers/net/benet/be_cmds.c
index 50e6259b50e..d0ef4ac987c 100644
--- a/drivers/net/benet/be_cmds.c
+++ b/drivers/net/benet/be_cmds.c
@@ -1464,8 +1464,8 @@ int be_cmd_get_flash_crc(struct be_adapter *adapter, u8 *flashed_crc,
1464 1464
1465 req->params.op_type = cpu_to_le32(IMG_TYPE_REDBOOT); 1465 req->params.op_type = cpu_to_le32(IMG_TYPE_REDBOOT);
1466 req->params.op_code = cpu_to_le32(FLASHROM_OPER_REPORT); 1466 req->params.op_code = cpu_to_le32(FLASHROM_OPER_REPORT);
1467 req->params.offset = offset; 1467 req->params.offset = cpu_to_le32(offset);
1468 req->params.data_buf_size = 0x4; 1468 req->params.data_buf_size = cpu_to_le32(0x4);
1469 1469
1470 status = be_mcc_notify_wait(adapter); 1470 status = be_mcc_notify_wait(adapter);
1471 if (!status) 1471 if (!status)
diff --git a/drivers/net/benet/be_ethtool.c b/drivers/net/benet/be_ethtool.c
index 9560d48944a..51e1065e789 100644
--- a/drivers/net/benet/be_ethtool.c
+++ b/drivers/net/benet/be_ethtool.c
@@ -490,7 +490,7 @@ be_test_ddr_dma(struct be_adapter *adapter)
490{ 490{
491 int ret, i; 491 int ret, i;
492 struct be_dma_mem ddrdma_cmd; 492 struct be_dma_mem ddrdma_cmd;
493 u64 pattern[2] = {0x5a5a5a5a5a5a5a5a, 0xa5a5a5a5a5a5a5a5}; 493 u64 pattern[2] = {0x5a5a5a5a5a5a5a5aULL, 0xa5a5a5a5a5a5a5a5ULL};
494 494
495 ddrdma_cmd.size = sizeof(struct be_cmd_req_ddrdma_test); 495 ddrdma_cmd.size = sizeof(struct be_cmd_req_ddrdma_test);
496 ddrdma_cmd.va = pci_alloc_consistent(adapter->pdev, ddrdma_cmd.size, 496 ddrdma_cmd.va = pci_alloc_consistent(adapter->pdev, ddrdma_cmd.size,
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c
index 43e8032f923..ec6ace80225 100644
--- a/drivers/net/benet/be_main.c
+++ b/drivers/net/benet/be_main.c
@@ -807,7 +807,7 @@ static void be_rx_compl_process(struct be_adapter *adapter,
807 return; 807 return;
808 } 808 }
809 vid = AMAP_GET_BITS(struct amap_eth_rx_compl, vlan_tag, rxcp); 809 vid = AMAP_GET_BITS(struct amap_eth_rx_compl, vlan_tag, rxcp);
810 vid = be16_to_cpu(vid); 810 vid = swab16(vid);
811 vlan_hwaccel_receive_skb(skb, adapter->vlan_grp, vid); 811 vlan_hwaccel_receive_skb(skb, adapter->vlan_grp, vid);
812 } else { 812 } else {
813 netif_receive_skb(skb); 813 netif_receive_skb(skb);
@@ -884,7 +884,7 @@ static void be_rx_compl_process_gro(struct be_adapter *adapter,
884 napi_gro_frags(&eq_obj->napi); 884 napi_gro_frags(&eq_obj->napi);
885 } else { 885 } else {
886 vid = AMAP_GET_BITS(struct amap_eth_rx_compl, vlan_tag, rxcp); 886 vid = AMAP_GET_BITS(struct amap_eth_rx_compl, vlan_tag, rxcp);
887 vid = be16_to_cpu(vid); 887 vid = swab16(vid);
888 888
889 if (!adapter->vlan_grp || adapter->vlans_added == 0) 889 if (!adapter->vlan_grp || adapter->vlans_added == 0)
890 return; 890 return;
@@ -1855,7 +1855,7 @@ static bool be_flash_redboot(struct be_adapter *adapter,
1855 p += crc_offset; 1855 p += crc_offset;
1856 1856
1857 status = be_cmd_get_flash_crc(adapter, flashed_crc, 1857 status = be_cmd_get_flash_crc(adapter, flashed_crc,
1858 (img_start + image_size - 4)); 1858 (image_size - 4));
1859 if (status) { 1859 if (status) {
1860 dev_err(&adapter->pdev->dev, 1860 dev_err(&adapter->pdev->dev,
1861 "could not get crc from flash, not flashing redboot\n"); 1861 "could not get crc from flash, not flashing redboot\n");
@@ -1991,7 +1991,7 @@ int be_load_fw(struct be_adapter *adapter, u8 *func)
1991 struct flash_file_hdr_g3 *fhdr3; 1991 struct flash_file_hdr_g3 *fhdr3;
1992 struct image_hdr *img_hdr_ptr = NULL; 1992 struct image_hdr *img_hdr_ptr = NULL;
1993 struct be_dma_mem flash_cmd; 1993 struct be_dma_mem flash_cmd;
1994 int status, i = 0; 1994 int status, i = 0, num_imgs = 0;
1995 const u8 *p; 1995 const u8 *p;
1996 1996
1997 strcpy(fw_file, func); 1997 strcpy(fw_file, func);
@@ -2017,15 +2017,14 @@ int be_load_fw(struct be_adapter *adapter, u8 *func)
2017 if ((adapter->generation == BE_GEN3) && 2017 if ((adapter->generation == BE_GEN3) &&
2018 (get_ufigen_type(fhdr) == BE_GEN3)) { 2018 (get_ufigen_type(fhdr) == BE_GEN3)) {
2019 fhdr3 = (struct flash_file_hdr_g3 *) fw->data; 2019 fhdr3 = (struct flash_file_hdr_g3 *) fw->data;
2020 for (i = 0; i < fhdr3->num_imgs; i++) { 2020 num_imgs = le32_to_cpu(fhdr3->num_imgs);
2021 for (i = 0; i < num_imgs; i++) {
2021 img_hdr_ptr = (struct image_hdr *) (fw->data + 2022 img_hdr_ptr = (struct image_hdr *) (fw->data +
2022 (sizeof(struct flash_file_hdr_g3) + 2023 (sizeof(struct flash_file_hdr_g3) +
2023 i * sizeof(struct image_hdr))); 2024 i * sizeof(struct image_hdr)));
2024 if (img_hdr_ptr->imageid == 1) { 2025 if (le32_to_cpu(img_hdr_ptr->imageid) == 1)
2025 status = be_flash_data(adapter, fw, 2026 status = be_flash_data(adapter, fw, &flash_cmd,
2026 &flash_cmd, fhdr3->num_imgs); 2027 num_imgs);
2027 }
2028
2029 } 2028 }
2030 } else if ((adapter->generation == BE_GEN2) && 2029 } else if ((adapter->generation == BE_GEN2) &&
2031 (get_ufigen_type(fhdr) == BE_GEN2)) { 2030 (get_ufigen_type(fhdr) == BE_GEN2)) {
diff --git a/drivers/net/bmac.c b/drivers/net/bmac.c
index 119468e7632..598b007f199 100644
--- a/drivers/net/bmac.c
+++ b/drivers/net/bmac.c
@@ -20,6 +20,7 @@
20#include <linux/crc32.h> 20#include <linux/crc32.h>
21#include <linux/bitrev.h> 21#include <linux/bitrev.h>
22#include <linux/ethtool.h> 22#include <linux/ethtool.h>
23#include <linux/slab.h>
23#include <asm/prom.h> 24#include <asm/prom.h>
24#include <asm/dbdma.h> 25#include <asm/dbdma.h>
25#include <asm/io.h> 26#include <asm/io.h>
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 381887ba677..ac90a3828f6 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -58,8 +58,8 @@
58#include "bnx2_fw.h" 58#include "bnx2_fw.h"
59 59
60#define DRV_MODULE_NAME "bnx2" 60#define DRV_MODULE_NAME "bnx2"
61#define DRV_MODULE_VERSION "2.0.8" 61#define DRV_MODULE_VERSION "2.0.9"
62#define DRV_MODULE_RELDATE "Feb 15, 2010" 62#define DRV_MODULE_RELDATE "April 27, 2010"
63#define FW_MIPS_FILE_06 "bnx2/bnx2-mips-06-5.0.0.j6.fw" 63#define FW_MIPS_FILE_06 "bnx2/bnx2-mips-06-5.0.0.j6.fw"
64#define FW_RV2P_FILE_06 "bnx2/bnx2-rv2p-06-5.0.0.j3.fw" 64#define FW_RV2P_FILE_06 "bnx2/bnx2-rv2p-06-5.0.0.j3.fw"
65#define FW_MIPS_FILE_09 "bnx2/bnx2-mips-09-5.0.0.j9.fw" 65#define FW_MIPS_FILE_09 "bnx2/bnx2-mips-09-5.0.0.j9.fw"
@@ -246,6 +246,8 @@ static const struct flash_spec flash_5709 = {
246 246
247MODULE_DEVICE_TABLE(pci, bnx2_pci_tbl); 247MODULE_DEVICE_TABLE(pci, bnx2_pci_tbl);
248 248
249static void bnx2_init_napi(struct bnx2 *bp);
250
249static inline u32 bnx2_tx_avail(struct bnx2 *bp, struct bnx2_tx_ring_info *txr) 251static inline u32 bnx2_tx_avail(struct bnx2 *bp, struct bnx2_tx_ring_info *txr)
250{ 252{
251 u32 diff; 253 u32 diff;
@@ -649,9 +651,10 @@ bnx2_napi_enable(struct bnx2 *bp)
649} 651}
650 652
651static void 653static void
652bnx2_netif_stop(struct bnx2 *bp) 654bnx2_netif_stop(struct bnx2 *bp, bool stop_cnic)
653{ 655{
654 bnx2_cnic_stop(bp); 656 if (stop_cnic)
657 bnx2_cnic_stop(bp);
655 if (netif_running(bp->dev)) { 658 if (netif_running(bp->dev)) {
656 int i; 659 int i;
657 660
@@ -669,14 +672,15 @@ bnx2_netif_stop(struct bnx2 *bp)
669} 672}
670 673
671static void 674static void
672bnx2_netif_start(struct bnx2 *bp) 675bnx2_netif_start(struct bnx2 *bp, bool start_cnic)
673{ 676{
674 if (atomic_dec_and_test(&bp->intr_sem)) { 677 if (atomic_dec_and_test(&bp->intr_sem)) {
675 if (netif_running(bp->dev)) { 678 if (netif_running(bp->dev)) {
676 netif_tx_wake_all_queues(bp->dev); 679 netif_tx_wake_all_queues(bp->dev);
677 bnx2_napi_enable(bp); 680 bnx2_napi_enable(bp);
678 bnx2_enable_int(bp); 681 bnx2_enable_int(bp);
679 bnx2_cnic_start(bp); 682 if (start_cnic)
683 bnx2_cnic_start(bp);
680 } 684 }
681 } 685 }
682} 686}
@@ -4757,8 +4761,12 @@ bnx2_reset_chip(struct bnx2 *bp, u32 reset_code)
4757 rc = bnx2_alloc_bad_rbuf(bp); 4761 rc = bnx2_alloc_bad_rbuf(bp);
4758 } 4762 }
4759 4763
4760 if (bp->flags & BNX2_FLAG_USING_MSIX) 4764 if (bp->flags & BNX2_FLAG_USING_MSIX) {
4761 bnx2_setup_msix_tbl(bp); 4765 bnx2_setup_msix_tbl(bp);
4766 /* Prevent MSIX table reads and write from timing out */
4767 REG_WR(bp, BNX2_MISC_ECO_HW_CTL,
4768 BNX2_MISC_ECO_HW_CTL_LARGE_GRC_TMOUT_EN);
4769 }
4762 4770
4763 return rc; 4771 return rc;
4764} 4772}
@@ -6197,6 +6205,7 @@ bnx2_open(struct net_device *dev)
6197 bnx2_disable_int(bp); 6205 bnx2_disable_int(bp);
6198 6206
6199 bnx2_setup_int_mode(bp, disable_msi); 6207 bnx2_setup_int_mode(bp, disable_msi);
6208 bnx2_init_napi(bp);
6200 bnx2_napi_enable(bp); 6209 bnx2_napi_enable(bp);
6201 rc = bnx2_alloc_mem(bp); 6210 rc = bnx2_alloc_mem(bp);
6202 if (rc) 6211 if (rc)
@@ -6270,12 +6279,12 @@ bnx2_reset_task(struct work_struct *work)
6270 return; 6279 return;
6271 } 6280 }
6272 6281
6273 bnx2_netif_stop(bp); 6282 bnx2_netif_stop(bp, true);
6274 6283
6275 bnx2_init_nic(bp, 1); 6284 bnx2_init_nic(bp, 1);
6276 6285
6277 atomic_set(&bp->intr_sem, 1); 6286 atomic_set(&bp->intr_sem, 1);
6278 bnx2_netif_start(bp); 6287 bnx2_netif_start(bp, true);
6279 rtnl_unlock(); 6288 rtnl_unlock();
6280} 6289}
6281 6290
@@ -6317,7 +6326,7 @@ bnx2_vlan_rx_register(struct net_device *dev, struct vlan_group *vlgrp)
6317 struct bnx2 *bp = netdev_priv(dev); 6326 struct bnx2 *bp = netdev_priv(dev);
6318 6327
6319 if (netif_running(dev)) 6328 if (netif_running(dev))
6320 bnx2_netif_stop(bp); 6329 bnx2_netif_stop(bp, false);
6321 6330
6322 bp->vlgrp = vlgrp; 6331 bp->vlgrp = vlgrp;
6323 6332
@@ -6328,7 +6337,7 @@ bnx2_vlan_rx_register(struct net_device *dev, struct vlan_group *vlgrp)
6328 if (bp->flags & BNX2_FLAG_CAN_KEEP_VLAN) 6337 if (bp->flags & BNX2_FLAG_CAN_KEEP_VLAN)
6329 bnx2_fw_sync(bp, BNX2_DRV_MSG_CODE_KEEP_VLAN_UPDATE, 0, 1); 6338 bnx2_fw_sync(bp, BNX2_DRV_MSG_CODE_KEEP_VLAN_UPDATE, 0, 1);
6330 6339
6331 bnx2_netif_start(bp); 6340 bnx2_netif_start(bp, false);
6332} 6341}
6333#endif 6342#endif
6334 6343
@@ -7048,9 +7057,9 @@ bnx2_set_coalesce(struct net_device *dev, struct ethtool_coalesce *coal)
7048 bp->stats_ticks &= BNX2_HC_STATS_TICKS_HC_STAT_TICKS; 7057 bp->stats_ticks &= BNX2_HC_STATS_TICKS_HC_STAT_TICKS;
7049 7058
7050 if (netif_running(bp->dev)) { 7059 if (netif_running(bp->dev)) {
7051 bnx2_netif_stop(bp); 7060 bnx2_netif_stop(bp, true);
7052 bnx2_init_nic(bp, 0); 7061 bnx2_init_nic(bp, 0);
7053 bnx2_netif_start(bp); 7062 bnx2_netif_start(bp, true);
7054 } 7063 }
7055 7064
7056 return 0; 7065 return 0;
@@ -7080,7 +7089,7 @@ bnx2_change_ring_size(struct bnx2 *bp, u32 rx, u32 tx)
7080 /* Reset will erase chipset stats; save them */ 7089 /* Reset will erase chipset stats; save them */
7081 bnx2_save_stats(bp); 7090 bnx2_save_stats(bp);
7082 7091
7083 bnx2_netif_stop(bp); 7092 bnx2_netif_stop(bp, true);
7084 bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_RESET); 7093 bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_RESET);
7085 bnx2_free_skbs(bp); 7094 bnx2_free_skbs(bp);
7086 bnx2_free_mem(bp); 7095 bnx2_free_mem(bp);
@@ -7108,7 +7117,7 @@ bnx2_change_ring_size(struct bnx2 *bp, u32 rx, u32 tx)
7108 bnx2_setup_cnic_irq_info(bp); 7117 bnx2_setup_cnic_irq_info(bp);
7109 mutex_unlock(&bp->cnic_lock); 7118 mutex_unlock(&bp->cnic_lock);
7110#endif 7119#endif
7111 bnx2_netif_start(bp); 7120 bnx2_netif_start(bp, true);
7112 } 7121 }
7113 return 0; 7122 return 0;
7114} 7123}
@@ -7361,7 +7370,7 @@ bnx2_self_test(struct net_device *dev, struct ethtool_test *etest, u64 *buf)
7361 if (etest->flags & ETH_TEST_FL_OFFLINE) { 7370 if (etest->flags & ETH_TEST_FL_OFFLINE) {
7362 int i; 7371 int i;
7363 7372
7364 bnx2_netif_stop(bp); 7373 bnx2_netif_stop(bp, true);
7365 bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_DIAG); 7374 bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_DIAG);
7366 bnx2_free_skbs(bp); 7375 bnx2_free_skbs(bp);
7367 7376
@@ -7380,7 +7389,7 @@ bnx2_self_test(struct net_device *dev, struct ethtool_test *etest, u64 *buf)
7380 bnx2_shutdown_chip(bp); 7389 bnx2_shutdown_chip(bp);
7381 else { 7390 else {
7382 bnx2_init_nic(bp, 1); 7391 bnx2_init_nic(bp, 1);
7383 bnx2_netif_start(bp); 7392 bnx2_netif_start(bp, true);
7384 } 7393 }
7385 7394
7386 /* wait for link up */ 7395 /* wait for link up */
@@ -7643,9 +7652,11 @@ poll_bnx2(struct net_device *dev)
7643 int i; 7652 int i;
7644 7653
7645 for (i = 0; i < bp->irq_nvecs; i++) { 7654 for (i = 0; i < bp->irq_nvecs; i++) {
7646 disable_irq(bp->irq_tbl[i].vector); 7655 struct bnx2_irq *irq = &bp->irq_tbl[i];
7647 bnx2_interrupt(bp->irq_tbl[i].vector, &bp->bnx2_napi[i]); 7656
7648 enable_irq(bp->irq_tbl[i].vector); 7657 disable_irq(irq->vector);
7658 irq->handler(irq->vector, &bp->bnx2_napi[i]);
7659 enable_irq(irq->vector);
7649 } 7660 }
7650} 7661}
7651#endif 7662#endif
@@ -8207,7 +8218,7 @@ bnx2_init_napi(struct bnx2 *bp)
8207{ 8218{
8208 int i; 8219 int i;
8209 8220
8210 for (i = 0; i < BNX2_MAX_MSIX_VEC; i++) { 8221 for (i = 0; i < bp->irq_nvecs; i++) {
8211 struct bnx2_napi *bnapi = &bp->bnx2_napi[i]; 8222 struct bnx2_napi *bnapi = &bp->bnx2_napi[i];
8212 int (*poll)(struct napi_struct *, int); 8223 int (*poll)(struct napi_struct *, int);
8213 8224
@@ -8276,7 +8287,6 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
8276 dev->ethtool_ops = &bnx2_ethtool_ops; 8287 dev->ethtool_ops = &bnx2_ethtool_ops;
8277 8288
8278 bp = netdev_priv(dev); 8289 bp = netdev_priv(dev);
8279 bnx2_init_napi(bp);
8280 8290
8281 pci_set_drvdata(pdev, dev); 8291 pci_set_drvdata(pdev, dev);
8282 8292
@@ -8373,7 +8383,7 @@ bnx2_suspend(struct pci_dev *pdev, pm_message_t state)
8373 return 0; 8383 return 0;
8374 8384
8375 flush_scheduled_work(); 8385 flush_scheduled_work();
8376 bnx2_netif_stop(bp); 8386 bnx2_netif_stop(bp, true);
8377 netif_device_detach(dev); 8387 netif_device_detach(dev);
8378 del_timer_sync(&bp->timer); 8388 del_timer_sync(&bp->timer);
8379 bnx2_shutdown_chip(bp); 8389 bnx2_shutdown_chip(bp);
@@ -8395,7 +8405,7 @@ bnx2_resume(struct pci_dev *pdev)
8395 bnx2_set_power_state(bp, PCI_D0); 8405 bnx2_set_power_state(bp, PCI_D0);
8396 netif_device_attach(dev); 8406 netif_device_attach(dev);
8397 bnx2_init_nic(bp, 1); 8407 bnx2_init_nic(bp, 1);
8398 bnx2_netif_start(bp); 8408 bnx2_netif_start(bp, true);
8399 return 0; 8409 return 0;
8400} 8410}
8401 8411
@@ -8422,7 +8432,7 @@ static pci_ers_result_t bnx2_io_error_detected(struct pci_dev *pdev,
8422 } 8432 }
8423 8433
8424 if (netif_running(dev)) { 8434 if (netif_running(dev)) {
8425 bnx2_netif_stop(bp); 8435 bnx2_netif_stop(bp, true);
8426 del_timer_sync(&bp->timer); 8436 del_timer_sync(&bp->timer);
8427 bnx2_reset_nic(bp, BNX2_DRV_MSG_CODE_RESET); 8437 bnx2_reset_nic(bp, BNX2_DRV_MSG_CODE_RESET);
8428 } 8438 }
@@ -8479,7 +8489,7 @@ static void bnx2_io_resume(struct pci_dev *pdev)
8479 8489
8480 rtnl_lock(); 8490 rtnl_lock();
8481 if (netif_running(dev)) 8491 if (netif_running(dev))
8482 bnx2_netif_start(bp); 8492 bnx2_netif_start(bp, true);
8483 8493
8484 netif_device_attach(dev); 8494 netif_device_attach(dev);
8485 rtnl_unlock(); 8495 rtnl_unlock();
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 430c02267d7..0075514bf32 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1235,6 +1235,11 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
1235 write_lock_bh(&bond->curr_slave_lock); 1235 write_lock_bh(&bond->curr_slave_lock);
1236 } 1236 }
1237 } 1237 }
1238
1239 /* resend IGMP joins since all were sent on curr_active_slave */
1240 if (bond->params.mode == BOND_MODE_ROUNDROBIN) {
1241 bond_resend_igmp_join_requests(bond);
1242 }
1238} 1243}
1239 1244
1240/** 1245/**
@@ -4138,22 +4143,41 @@ static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *bond_dev
4138 struct bonding *bond = netdev_priv(bond_dev); 4143 struct bonding *bond = netdev_priv(bond_dev);
4139 struct slave *slave, *start_at; 4144 struct slave *slave, *start_at;
4140 int i, slave_no, res = 1; 4145 int i, slave_no, res = 1;
4146 struct iphdr *iph = ip_hdr(skb);
4141 4147
4142 read_lock(&bond->lock); 4148 read_lock(&bond->lock);
4143 4149
4144 if (!BOND_IS_OK(bond)) 4150 if (!BOND_IS_OK(bond))
4145 goto out; 4151 goto out;
4146
4147 /* 4152 /*
4148 * Concurrent TX may collide on rr_tx_counter; we accept that 4153 * Start with the curr_active_slave that joined the bond as the
4149 * as being rare enough not to justify using an atomic op here 4154 * default for sending IGMP traffic. For failover purposes one
4155 * needs to maintain some consistency for the interface that will
4156 * send the join/membership reports. The curr_active_slave found
4157 * will send all of this type of traffic.
4150 */ 4158 */
4151 slave_no = bond->rr_tx_counter++ % bond->slave_cnt; 4159 if ((iph->protocol == IPPROTO_IGMP) &&
4160 (skb->protocol == htons(ETH_P_IP))) {
4152 4161
4153 bond_for_each_slave(bond, slave, i) { 4162 read_lock(&bond->curr_slave_lock);
4154 slave_no--; 4163 slave = bond->curr_active_slave;
4155 if (slave_no < 0) 4164 read_unlock(&bond->curr_slave_lock);
4156 break; 4165
4166 if (!slave)
4167 goto out;
4168 } else {
4169 /*
4170 * Concurrent TX may collide on rr_tx_counter; we accept
4171 * that as being rare enough not to justify using an
4172 * atomic op here.
4173 */
4174 slave_no = bond->rr_tx_counter++ % bond->slave_cnt;
4175
4176 bond_for_each_slave(bond, slave, i) {
4177 slave_no--;
4178 if (slave_no < 0)
4179 break;
4180 }
4157 } 4181 }
4158 4182
4159 start_at = slave; 4183 start_at = slave;
@@ -4426,6 +4450,14 @@ static const struct net_device_ops bond_netdev_ops = {
4426 .ndo_vlan_rx_kill_vid = bond_vlan_rx_kill_vid, 4450 .ndo_vlan_rx_kill_vid = bond_vlan_rx_kill_vid,
4427}; 4451};
4428 4452
4453static void bond_destructor(struct net_device *bond_dev)
4454{
4455 struct bonding *bond = netdev_priv(bond_dev);
4456 if (bond->wq)
4457 destroy_workqueue(bond->wq);
4458 free_netdev(bond_dev);
4459}
4460
4429static void bond_setup(struct net_device *bond_dev) 4461static void bond_setup(struct net_device *bond_dev)
4430{ 4462{
4431 struct bonding *bond = netdev_priv(bond_dev); 4463 struct bonding *bond = netdev_priv(bond_dev);
@@ -4446,7 +4478,7 @@ static void bond_setup(struct net_device *bond_dev)
4446 bond_dev->ethtool_ops = &bond_ethtool_ops; 4478 bond_dev->ethtool_ops = &bond_ethtool_ops;
4447 bond_set_mode_ops(bond, bond->params.mode); 4479 bond_set_mode_ops(bond, bond->params.mode);
4448 4480
4449 bond_dev->destructor = free_netdev; 4481 bond_dev->destructor = bond_destructor;
4450 4482
4451 /* Initialize the device options */ 4483 /* Initialize the device options */
4452 bond_dev->tx_queue_len = 0; 4484 bond_dev->tx_queue_len = 0;
@@ -4518,9 +4550,6 @@ static void bond_uninit(struct net_device *bond_dev)
4518 4550
4519 bond_remove_proc_entry(bond); 4551 bond_remove_proc_entry(bond);
4520 4552
4521 if (bond->wq)
4522 destroy_workqueue(bond->wq);
4523
4524 netif_addr_lock_bh(bond_dev); 4553 netif_addr_lock_bh(bond_dev);
4525 bond_mc_list_destroy(bond); 4554 bond_mc_list_destroy(bond);
4526 netif_addr_unlock_bh(bond_dev); 4555 netif_addr_unlock_bh(bond_dev);
@@ -4932,8 +4961,8 @@ int bond_create(struct net *net, const char *name)
4932 bond_setup); 4961 bond_setup);
4933 if (!bond_dev) { 4962 if (!bond_dev) {
4934 pr_err("%s: eek! can't alloc netdev!\n", name); 4963 pr_err("%s: eek! can't alloc netdev!\n", name);
4935 res = -ENOMEM; 4964 rtnl_unlock();
4936 goto out; 4965 return -ENOMEM;
4937 } 4966 }
4938 4967
4939 dev_net_set(bond_dev, net); 4968 dev_net_set(bond_dev, net);
@@ -4942,19 +4971,16 @@ int bond_create(struct net *net, const char *name)
4942 if (!name) { 4971 if (!name) {
4943 res = dev_alloc_name(bond_dev, "bond%d"); 4972 res = dev_alloc_name(bond_dev, "bond%d");
4944 if (res < 0) 4973 if (res < 0)
4945 goto out_netdev; 4974 goto out;
4946 } 4975 }
4947 4976
4948 res = register_netdevice(bond_dev); 4977 res = register_netdevice(bond_dev);
4949 if (res < 0)
4950 goto out_netdev;
4951 4978
4952out: 4979out:
4953 rtnl_unlock(); 4980 rtnl_unlock();
4981 if (res < 0)
4982 bond_destructor(bond_dev);
4954 return res; 4983 return res;
4955out_netdev:
4956 free_netdev(bond_dev);
4957 goto out;
4958} 4984}
4959 4985
4960static int __net_init bond_net_init(struct net *net) 4986static int __net_init bond_net_init(struct net *net)
diff --git a/drivers/net/can/bfin_can.c b/drivers/net/can/bfin_can.c
index 866905fa411..03489864376 100644
--- a/drivers/net/can/bfin_can.c
+++ b/drivers/net/can/bfin_can.c
@@ -22,6 +22,7 @@
22#include <linux/can/dev.h> 22#include <linux/can/dev.h>
23#include <linux/can/error.h> 23#include <linux/can/error.h>
24 24
25#include <asm/bfin_can.h>
25#include <asm/portmux.h> 26#include <asm/portmux.h>
26 27
27#define DRV_NAME "bfin_can" 28#define DRV_NAME "bfin_can"
@@ -29,90 +30,6 @@
29#define TX_ECHO_SKB_MAX 1 30#define TX_ECHO_SKB_MAX 1
30 31
31/* 32/*
32 * transmit and receive channels
33 */
34#define TRANSMIT_CHL 24
35#define RECEIVE_STD_CHL 0
36#define RECEIVE_EXT_CHL 4
37#define RECEIVE_RTR_CHL 8
38#define RECEIVE_EXT_RTR_CHL 12
39#define MAX_CHL_NUMBER 32
40
41/*
42 * bfin can registers layout
43 */
44struct bfin_can_mask_regs {
45 u16 aml;
46 u16 dummy1;
47 u16 amh;
48 u16 dummy2;
49};
50
51struct bfin_can_channel_regs {
52 u16 data[8];
53 u16 dlc;
54 u16 dummy1;
55 u16 tsv;
56 u16 dummy2;
57 u16 id0;
58 u16 dummy3;
59 u16 id1;
60 u16 dummy4;
61};
62
63struct bfin_can_regs {
64 /*
65 * global control and status registers
66 */
67 u16 mc1; /* offset 0 */
68 u16 dummy1;
69 u16 md1; /* offset 4 */
70 u16 rsv1[13];
71 u16 mbtif1; /* offset 0x20 */
72 u16 dummy2;
73 u16 mbrif1; /* offset 0x24 */
74 u16 dummy3;
75 u16 mbim1; /* offset 0x28 */
76 u16 rsv2[11];
77 u16 mc2; /* offset 0x40 */
78 u16 dummy4;
79 u16 md2; /* offset 0x44 */
80 u16 dummy5;
81 u16 trs2; /* offset 0x48 */
82 u16 rsv3[11];
83 u16 mbtif2; /* offset 0x60 */
84 u16 dummy6;
85 u16 mbrif2; /* offset 0x64 */
86 u16 dummy7;
87 u16 mbim2; /* offset 0x68 */
88 u16 rsv4[11];
89 u16 clk; /* offset 0x80 */
90 u16 dummy8;
91 u16 timing; /* offset 0x84 */
92 u16 rsv5[3];
93 u16 status; /* offset 0x8c */
94 u16 dummy9;
95 u16 cec; /* offset 0x90 */
96 u16 dummy10;
97 u16 gis; /* offset 0x94 */
98 u16 dummy11;
99 u16 gim; /* offset 0x98 */
100 u16 rsv6[3];
101 u16 ctrl; /* offset 0xa0 */
102 u16 dummy12;
103 u16 intr; /* offset 0xa4 */
104 u16 rsv7[7];
105 u16 esr; /* offset 0xb4 */
106 u16 rsv8[37];
107
108 /*
109 * channel(mailbox) mask and message registers
110 */
111 struct bfin_can_mask_regs msk[MAX_CHL_NUMBER]; /* offset 0x100 */
112 struct bfin_can_channel_regs chl[MAX_CHL_NUMBER]; /* offset 0x200 */
113};
114
115/*
116 * bfin can private data 33 * bfin can private data
117 */ 34 */
118struct bfin_can_priv { 35struct bfin_can_priv {
@@ -163,7 +80,7 @@ static int bfin_can_set_bittiming(struct net_device *dev)
163 if (priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES) 80 if (priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES)
164 timing |= SAM; 81 timing |= SAM;
165 82
166 bfin_write16(&reg->clk, clk); 83 bfin_write16(&reg->clock, clk);
167 bfin_write16(&reg->timing, timing); 84 bfin_write16(&reg->timing, timing);
168 85
169 dev_info(dev->dev.parent, "setting CLOCK=0x%04x TIMING=0x%04x\n", 86 dev_info(dev->dev.parent, "setting CLOCK=0x%04x TIMING=0x%04x\n",
@@ -185,11 +102,11 @@ static void bfin_can_set_reset_mode(struct net_device *dev)
185 bfin_write16(&reg->gim, 0); 102 bfin_write16(&reg->gim, 0);
186 103
187 /* reset can and enter configuration mode */ 104 /* reset can and enter configuration mode */
188 bfin_write16(&reg->ctrl, SRS | CCR); 105 bfin_write16(&reg->control, SRS | CCR);
189 SSYNC(); 106 SSYNC();
190 bfin_write16(&reg->ctrl, CCR); 107 bfin_write16(&reg->control, CCR);
191 SSYNC(); 108 SSYNC();
192 while (!(bfin_read16(&reg->ctrl) & CCA)) { 109 while (!(bfin_read16(&reg->control) & CCA)) {
193 udelay(10); 110 udelay(10);
194 if (--timeout == 0) { 111 if (--timeout == 0) {
195 dev_err(dev->dev.parent, 112 dev_err(dev->dev.parent,
@@ -244,7 +161,7 @@ static void bfin_can_set_normal_mode(struct net_device *dev)
244 /* 161 /*
245 * leave configuration mode 162 * leave configuration mode
246 */ 163 */
247 bfin_write16(&reg->ctrl, bfin_read16(&reg->ctrl) & ~CCR); 164 bfin_write16(&reg->control, bfin_read16(&reg->control) & ~CCR);
248 165
249 while (bfin_read16(&reg->status) & CCA) { 166 while (bfin_read16(&reg->status) & CCA) {
250 udelay(10); 167 udelay(10);
@@ -726,7 +643,7 @@ static int bfin_can_suspend(struct platform_device *pdev, pm_message_t mesg)
726 643
727 if (netif_running(dev)) { 644 if (netif_running(dev)) {
728 /* enter sleep mode */ 645 /* enter sleep mode */
729 bfin_write16(&reg->ctrl, bfin_read16(&reg->ctrl) | SMR); 646 bfin_write16(&reg->control, bfin_read16(&reg->control) | SMR);
730 SSYNC(); 647 SSYNC();
731 while (!(bfin_read16(&reg->intr) & SMACK)) { 648 while (!(bfin_read16(&reg->intr) & SMACK)) {
732 udelay(10); 649 udelay(10);
diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index 904aa369f80..d0f8c7e67e7 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -19,6 +19,7 @@
19 19
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/slab.h>
22#include <linux/netdevice.h> 23#include <linux/netdevice.h>
23#include <linux/if_arp.h> 24#include <linux/if_arp.h>
24#include <linux/can.h> 25#include <linux/can.h>
diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
index f8cc168ec76..b39b108318b 100644
--- a/drivers/net/can/mcp251x.c
+++ b/drivers/net/can/mcp251x.c
@@ -73,6 +73,7 @@
73#include <linux/module.h> 73#include <linux/module.h>
74#include <linux/netdevice.h> 74#include <linux/netdevice.h>
75#include <linux/platform_device.h> 75#include <linux/platform_device.h>
76#include <linux/slab.h>
76#include <linux/spi/spi.h> 77#include <linux/spi/spi.h>
77#include <linux/uaccess.h> 78#include <linux/uaccess.h>
78 79
diff --git a/drivers/net/can/sja1000/ems_pci.c b/drivers/net/can/sja1000/ems_pci.c
index 87300606abb..5f53da0bc40 100644
--- a/drivers/net/can/sja1000/ems_pci.c
+++ b/drivers/net/can/sja1000/ems_pci.c
@@ -22,6 +22,7 @@
22#include <linux/interrupt.h> 22#include <linux/interrupt.h>
23#include <linux/netdevice.h> 23#include <linux/netdevice.h>
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/slab.h>
25#include <linux/pci.h> 26#include <linux/pci.h>
26#include <linux/can.h> 27#include <linux/can.h>
27#include <linux/can/dev.h> 28#include <linux/can/dev.h>
diff --git a/drivers/net/can/sja1000/plx_pci.c b/drivers/net/can/sja1000/plx_pci.c
index 6b46a6395f8..4aff4070db9 100644
--- a/drivers/net/can/sja1000/plx_pci.c
+++ b/drivers/net/can/sja1000/plx_pci.c
@@ -25,6 +25,7 @@
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/netdevice.h> 26#include <linux/netdevice.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/slab.h>
28#include <linux/pci.h> 29#include <linux/pci.h>
29#include <linux/can.h> 30#include <linux/can.h>
30#include <linux/can/dev.h> 31#include <linux/can/dev.h>
diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c
index 33451092b8e..d800b598ae3 100644
--- a/drivers/net/can/usb/ems_usb.c
+++ b/drivers/net/can/usb/ems_usb.c
@@ -1006,7 +1006,7 @@ static int ems_usb_probe(struct usb_interface *intf,
1006 1006
1007 netdev = alloc_candev(sizeof(struct ems_usb), MAX_TX_URBS); 1007 netdev = alloc_candev(sizeof(struct ems_usb), MAX_TX_URBS);
1008 if (!netdev) { 1008 if (!netdev) {
1009 dev_err(netdev->dev.parent, "Couldn't alloc candev\n"); 1009 dev_err(&intf->dev, "ems_usb: Couldn't alloc candev\n");
1010 return -ENOMEM; 1010 return -ENOMEM;
1011 } 1011 }
1012 1012
@@ -1036,20 +1036,20 @@ static int ems_usb_probe(struct usb_interface *intf,
1036 1036
1037 dev->intr_urb = usb_alloc_urb(0, GFP_KERNEL); 1037 dev->intr_urb = usb_alloc_urb(0, GFP_KERNEL);
1038 if (!dev->intr_urb) { 1038 if (!dev->intr_urb) {
1039 dev_err(netdev->dev.parent, "Couldn't alloc intr URB\n"); 1039 dev_err(&intf->dev, "Couldn't alloc intr URB\n");
1040 goto cleanup_candev; 1040 goto cleanup_candev;
1041 } 1041 }
1042 1042
1043 dev->intr_in_buffer = kzalloc(INTR_IN_BUFFER_SIZE, GFP_KERNEL); 1043 dev->intr_in_buffer = kzalloc(INTR_IN_BUFFER_SIZE, GFP_KERNEL);
1044 if (!dev->intr_in_buffer) { 1044 if (!dev->intr_in_buffer) {
1045 dev_err(netdev->dev.parent, "Couldn't alloc Intr buffer\n"); 1045 dev_err(&intf->dev, "Couldn't alloc Intr buffer\n");
1046 goto cleanup_intr_urb; 1046 goto cleanup_intr_urb;
1047 } 1047 }
1048 1048
1049 dev->tx_msg_buffer = kzalloc(CPC_HEADER_SIZE + 1049 dev->tx_msg_buffer = kzalloc(CPC_HEADER_SIZE +
1050 sizeof(struct ems_cpc_msg), GFP_KERNEL); 1050 sizeof(struct ems_cpc_msg), GFP_KERNEL);
1051 if (!dev->tx_msg_buffer) { 1051 if (!dev->tx_msg_buffer) {
1052 dev_err(netdev->dev.parent, "Couldn't alloc Tx buffer\n"); 1052 dev_err(&intf->dev, "Couldn't alloc Tx buffer\n");
1053 goto cleanup_intr_in_buffer; 1053 goto cleanup_intr_in_buffer;
1054 } 1054 }
1055 1055
diff --git a/drivers/net/can/vcan.c b/drivers/net/can/vcan.c
index d124d837ae5..a30b8f480f6 100644
--- a/drivers/net/can/vcan.c
+++ b/drivers/net/can/vcan.c
@@ -48,6 +48,7 @@
48#include <linux/if_ether.h> 48#include <linux/if_ether.h>
49#include <linux/can.h> 49#include <linux/can.h>
50#include <linux/can/dev.h> 50#include <linux/can/dev.h>
51#include <linux/slab.h>
51#include <net/rtnetlink.h> 52#include <net/rtnetlink.h>
52 53
53static __initdata const char banner[] = 54static __initdata const char banner[] =
diff --git a/drivers/net/chelsio/common.h b/drivers/net/chelsio/common.h
index 2d11afe4531..036b2dfb1d4 100644
--- a/drivers/net/chelsio/common.h
+++ b/drivers/net/chelsio/common.h
@@ -51,6 +51,7 @@
51#include <linux/mdio.h> 51#include <linux/mdio.h>
52#include <linux/crc32.h> 52#include <linux/crc32.h>
53#include <linux/init.h> 53#include <linux/init.h>
54#include <linux/slab.h>
54#include <asm/io.h> 55#include <asm/io.h>
55#include <linux/pci_ids.h> 56#include <linux/pci_ids.h>
56 57
diff --git a/drivers/net/chelsio/pm3393.c b/drivers/net/chelsio/pm3393.c
index a6eb30a6e2b..9e631b9d394 100644
--- a/drivers/net/chelsio/pm3393.c
+++ b/drivers/net/chelsio/pm3393.c
@@ -44,6 +44,7 @@
44#include "suni1x10gexp_regs.h" 44#include "suni1x10gexp_regs.h"
45 45
46#include <linux/crc32.h> 46#include <linux/crc32.h>
47#include <linux/slab.h>
47 48
48#define OFFSET(REG_ADDR) ((REG_ADDR) << 2) 49#define OFFSET(REG_ADDR) ((REG_ADDR) << 2)
49 50
diff --git a/drivers/net/chelsio/sge.c b/drivers/net/chelsio/sge.c
index 55d99ca82f8..df3a1410696 100644
--- a/drivers/net/chelsio/sge.c
+++ b/drivers/net/chelsio/sge.c
@@ -53,6 +53,7 @@
53#include <linux/ip.h> 53#include <linux/ip.h>
54#include <linux/in.h> 54#include <linux/in.h>
55#include <linux/if_arp.h> 55#include <linux/if_arp.h>
56#include <linux/slab.h>
56 57
57#include "cpl5_cmd.h" 58#include "cpl5_cmd.h"
58#include "sge.h" 59#include "sge.h"
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c
index 9781942992e..4b451a7c03e 100644
--- a/drivers/net/cnic.c
+++ b/drivers/net/cnic.c
@@ -2334,13 +2334,13 @@ static int cnic_service_bnx2x(void *data, void *status_blk)
2334 struct cnic_local *cp = dev->cnic_priv; 2334 struct cnic_local *cp = dev->cnic_priv;
2335 u16 prod = cp->kcq_prod_idx & MAX_KCQ_IDX; 2335 u16 prod = cp->kcq_prod_idx & MAX_KCQ_IDX;
2336 2336
2337 prefetch(cp->status_blk.bnx2x); 2337 if (likely(test_bit(CNIC_F_CNIC_UP, &dev->flags))) {
2338 prefetch(&cp->kcq[KCQ_PG(prod)][KCQ_IDX(prod)]); 2338 prefetch(cp->status_blk.bnx2x);
2339 prefetch(&cp->kcq[KCQ_PG(prod)][KCQ_IDX(prod)]);
2339 2340
2340 if (likely(test_bit(CNIC_F_CNIC_UP, &dev->flags)))
2341 tasklet_schedule(&cp->cnic_irq_task); 2341 tasklet_schedule(&cp->cnic_irq_task);
2342 2342 cnic_chk_pkt_rings(cp);
2343 cnic_chk_pkt_rings(cp); 2343 }
2344 2344
2345 return 0; 2345 return 0;
2346} 2346}
diff --git a/drivers/net/cris/eth_v10.c b/drivers/net/cris/eth_v10.c
index dd24aadb778..61a33914e96 100644
--- a/drivers/net/cris/eth_v10.c
+++ b/drivers/net/cris/eth_v10.c
@@ -18,7 +18,6 @@
18#include <linux/ptrace.h> 18#include <linux/ptrace.h>
19#include <linux/ioport.h> 19#include <linux/ioport.h>
20#include <linux/in.h> 20#include <linux/in.h>
21#include <linux/slab.h>
22#include <linux/string.h> 21#include <linux/string.h>
23#include <linux/spinlock.h> 22#include <linux/spinlock.h>
24#include <linux/errno.h> 23#include <linux/errno.h>
diff --git a/drivers/net/cs89x0.c b/drivers/net/cs89x0.c
index b0208e474f7..4c38491b8ef 100644
--- a/drivers/net/cs89x0.c
+++ b/drivers/net/cs89x0.c
@@ -138,12 +138,12 @@
138#include <linux/ioport.h> 138#include <linux/ioport.h>
139#include <linux/in.h> 139#include <linux/in.h>
140#include <linux/skbuff.h> 140#include <linux/skbuff.h>
141#include <linux/slab.h>
142#include <linux/spinlock.h> 141#include <linux/spinlock.h>
143#include <linux/string.h> 142#include <linux/string.h>
144#include <linux/init.h> 143#include <linux/init.h>
145#include <linux/bitops.h> 144#include <linux/bitops.h>
146#include <linux/delay.h> 145#include <linux/delay.h>
146#include <linux/gfp.h>
147 147
148#include <asm/system.h> 148#include <asm/system.h>
149#include <asm/io.h> 149#include <asm/io.h>
diff --git a/drivers/net/cxgb3/ael1002.c b/drivers/net/cxgb3/ael1002.c
index 5248f9e0b2f..35cd3672915 100644
--- a/drivers/net/cxgb3/ael1002.c
+++ b/drivers/net/cxgb3/ael1002.c
@@ -934,7 +934,7 @@ static struct cphy_ops xaui_direct_ops = {
934int t3_xaui_direct_phy_prep(struct cphy *phy, struct adapter *adapter, 934int t3_xaui_direct_phy_prep(struct cphy *phy, struct adapter *adapter,
935 int phy_addr, const struct mdio_ops *mdio_ops) 935 int phy_addr, const struct mdio_ops *mdio_ops)
936{ 936{
937 cphy_init(phy, adapter, MDIO_PRTAD_NONE, &xaui_direct_ops, mdio_ops, 937 cphy_init(phy, adapter, phy_addr, &xaui_direct_ops, mdio_ops,
938 SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_TP, 938 SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_TP,
939 "10GBASE-CX4"); 939 "10GBASE-CX4");
940 return 0; 940 return 0;
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c
index 9e3e8750b46..e3f1b856649 100644
--- a/drivers/net/cxgb3/cxgb3_main.c
+++ b/drivers/net/cxgb3/cxgb3_main.c
@@ -46,6 +46,7 @@
46#include <linux/log2.h> 46#include <linux/log2.h>
47#include <linux/stringify.h> 47#include <linux/stringify.h>
48#include <linux/sched.h> 48#include <linux/sched.h>
49#include <linux/slab.h>
49#include <asm/uaccess.h> 50#include <asm/uaccess.h>
50 51
51#include "common.h" 52#include "common.h"
@@ -438,7 +439,7 @@ static void free_irq_resources(struct adapter *adapter)
438static int await_mgmt_replies(struct adapter *adap, unsigned long init_cnt, 439static int await_mgmt_replies(struct adapter *adap, unsigned long init_cnt,
439 unsigned long n) 440 unsigned long n)
440{ 441{
441 int attempts = 5; 442 int attempts = 10;
442 443
443 while (adap->sge.qs[0].rspq.offload_pkts < init_cnt + n) { 444 while (adap->sge.qs[0].rspq.offload_pkts < init_cnt + n) {
444 if (!--attempts) 445 if (!--attempts)
diff --git a/drivers/net/cxgb3/cxgb3_offload.c b/drivers/net/cxgb3/cxgb3_offload.c
index 9498361119d..c6485b39eb0 100644
--- a/drivers/net/cxgb3/cxgb3_offload.c
+++ b/drivers/net/cxgb3/cxgb3_offload.c
@@ -31,6 +31,7 @@
31 */ 31 */
32 32
33#include <linux/list.h> 33#include <linux/list.h>
34#include <linux/slab.h>
34#include <net/neighbour.h> 35#include <net/neighbour.h>
35#include <linux/notifier.h> 36#include <linux/notifier.h>
36#include <asm/atomic.h> 37#include <asm/atomic.h>
diff --git a/drivers/net/cxgb3/l2t.c b/drivers/net/cxgb3/l2t.c
index ff1611f90e7..2f3ee721c3e 100644
--- a/drivers/net/cxgb3/l2t.c
+++ b/drivers/net/cxgb3/l2t.c
@@ -34,6 +34,7 @@
34#include <linux/if.h> 34#include <linux/if.h>
35#include <linux/if_vlan.h> 35#include <linux/if_vlan.h>
36#include <linux/jhash.h> 36#include <linux/jhash.h>
37#include <linux/slab.h>
37#include <net/neighbour.h> 38#include <net/neighbour.h>
38#include "common.h" 39#include "common.h"
39#include "t3cdev.h" 40#include "t3cdev.h"
diff --git a/drivers/net/cxgb3/sge.c b/drivers/net/cxgb3/sge.c
index 67e61b2a8c4..07d7e7fab3f 100644
--- a/drivers/net/cxgb3/sge.c
+++ b/drivers/net/cxgb3/sge.c
@@ -36,6 +36,7 @@
36#include <linux/ip.h> 36#include <linux/ip.h>
37#include <linux/tcp.h> 37#include <linux/tcp.h>
38#include <linux/dma-mapping.h> 38#include <linux/dma-mapping.h>
39#include <linux/slab.h>
39#include <net/arp.h> 40#include <net/arp.h>
40#include "common.h" 41#include "common.h"
41#include "regs.h" 42#include "regs.h"
diff --git a/drivers/net/cxgb4/Makefile b/drivers/net/cxgb4/Makefile
new file mode 100644
index 00000000000..498667487f5
--- /dev/null
+++ b/drivers/net/cxgb4/Makefile
@@ -0,0 +1,7 @@
1#
2# Chelsio T4 driver
3#
4
5obj-$(CONFIG_CHELSIO_T4) += cxgb4.o
6
7cxgb4-objs := cxgb4_main.o l2t.o t4_hw.o sge.o
diff --git a/drivers/net/cxgb4/cxgb4.h b/drivers/net/cxgb4/cxgb4.h
new file mode 100644
index 00000000000..3d8ff4889b5
--- /dev/null
+++ b/drivers/net/cxgb4/cxgb4.h
@@ -0,0 +1,741 @@
1/*
2 * This file is part of the Chelsio T4 Ethernet driver for Linux.
3 *
4 * Copyright (c) 2003-2010 Chelsio Communications, Inc. All rights reserved.
5 *
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
11 *
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
14 * conditions are met:
15 *
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer.
19 *
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
24 *
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE.
33 */
34
35#ifndef __CXGB4_H__
36#define __CXGB4_H__
37
38#include <linux/bitops.h>
39#include <linux/cache.h>
40#include <linux/interrupt.h>
41#include <linux/list.h>
42#include <linux/netdevice.h>
43#include <linux/pci.h>
44#include <linux/spinlock.h>
45#include <linux/timer.h>
46#include <asm/io.h>
47#include "cxgb4_uld.h"
48#include "t4_hw.h"
49
50#define FW_VERSION_MAJOR 1
51#define FW_VERSION_MINOR 1
52#define FW_VERSION_MICRO 0
53
54enum {
55 MAX_NPORTS = 4, /* max # of ports */
56 SERNUM_LEN = 16, /* Serial # length */
57 EC_LEN = 16, /* E/C length */
58 ID_LEN = 16, /* ID length */
59};
60
61enum {
62 MEM_EDC0,
63 MEM_EDC1,
64 MEM_MC
65};
66
67enum dev_master {
68 MASTER_CANT,
69 MASTER_MAY,
70 MASTER_MUST
71};
72
73enum dev_state {
74 DEV_STATE_UNINIT,
75 DEV_STATE_INIT,
76 DEV_STATE_ERR
77};
78
79enum {
80 PAUSE_RX = 1 << 0,
81 PAUSE_TX = 1 << 1,
82 PAUSE_AUTONEG = 1 << 2
83};
84
85struct port_stats {
86 u64 tx_octets; /* total # of octets in good frames */
87 u64 tx_frames; /* all good frames */
88 u64 tx_bcast_frames; /* all broadcast frames */
89 u64 tx_mcast_frames; /* all multicast frames */
90 u64 tx_ucast_frames; /* all unicast frames */
91 u64 tx_error_frames; /* all error frames */
92
93 u64 tx_frames_64; /* # of Tx frames in a particular range */
94 u64 tx_frames_65_127;
95 u64 tx_frames_128_255;
96 u64 tx_frames_256_511;
97 u64 tx_frames_512_1023;
98 u64 tx_frames_1024_1518;
99 u64 tx_frames_1519_max;
100
101 u64 tx_drop; /* # of dropped Tx frames */
102 u64 tx_pause; /* # of transmitted pause frames */
103 u64 tx_ppp0; /* # of transmitted PPP prio 0 frames */
104 u64 tx_ppp1; /* # of transmitted PPP prio 1 frames */
105 u64 tx_ppp2; /* # of transmitted PPP prio 2 frames */
106 u64 tx_ppp3; /* # of transmitted PPP prio 3 frames */
107 u64 tx_ppp4; /* # of transmitted PPP prio 4 frames */
108 u64 tx_ppp5; /* # of transmitted PPP prio 5 frames */
109 u64 tx_ppp6; /* # of transmitted PPP prio 6 frames */
110 u64 tx_ppp7; /* # of transmitted PPP prio 7 frames */
111
112 u64 rx_octets; /* total # of octets in good frames */
113 u64 rx_frames; /* all good frames */
114 u64 rx_bcast_frames; /* all broadcast frames */
115 u64 rx_mcast_frames; /* all multicast frames */
116 u64 rx_ucast_frames; /* all unicast frames */
117 u64 rx_too_long; /* # of frames exceeding MTU */
118 u64 rx_jabber; /* # of jabber frames */
119 u64 rx_fcs_err; /* # of received frames with bad FCS */
120 u64 rx_len_err; /* # of received frames with length error */
121 u64 rx_symbol_err; /* symbol errors */
122 u64 rx_runt; /* # of short frames */
123
124 u64 rx_frames_64; /* # of Rx frames in a particular range */
125 u64 rx_frames_65_127;
126 u64 rx_frames_128_255;
127 u64 rx_frames_256_511;
128 u64 rx_frames_512_1023;
129 u64 rx_frames_1024_1518;
130 u64 rx_frames_1519_max;
131
132 u64 rx_pause; /* # of received pause frames */
133 u64 rx_ppp0; /* # of received PPP prio 0 frames */
134 u64 rx_ppp1; /* # of received PPP prio 1 frames */
135 u64 rx_ppp2; /* # of received PPP prio 2 frames */
136 u64 rx_ppp3; /* # of received PPP prio 3 frames */
137 u64 rx_ppp4; /* # of received PPP prio 4 frames */
138 u64 rx_ppp5; /* # of received PPP prio 5 frames */
139 u64 rx_ppp6; /* # of received PPP prio 6 frames */
140 u64 rx_ppp7; /* # of received PPP prio 7 frames */
141
142 u64 rx_ovflow0; /* drops due to buffer-group 0 overflows */
143 u64 rx_ovflow1; /* drops due to buffer-group 1 overflows */
144 u64 rx_ovflow2; /* drops due to buffer-group 2 overflows */
145 u64 rx_ovflow3; /* drops due to buffer-group 3 overflows */
146 u64 rx_trunc0; /* buffer-group 0 truncated packets */
147 u64 rx_trunc1; /* buffer-group 1 truncated packets */
148 u64 rx_trunc2; /* buffer-group 2 truncated packets */
149 u64 rx_trunc3; /* buffer-group 3 truncated packets */
150};
151
152struct lb_port_stats {
153 u64 octets;
154 u64 frames;
155 u64 bcast_frames;
156 u64 mcast_frames;
157 u64 ucast_frames;
158 u64 error_frames;
159
160 u64 frames_64;
161 u64 frames_65_127;
162 u64 frames_128_255;
163 u64 frames_256_511;
164 u64 frames_512_1023;
165 u64 frames_1024_1518;
166 u64 frames_1519_max;
167
168 u64 drop;
169
170 u64 ovflow0;
171 u64 ovflow1;
172 u64 ovflow2;
173 u64 ovflow3;
174 u64 trunc0;
175 u64 trunc1;
176 u64 trunc2;
177 u64 trunc3;
178};
179
180struct tp_tcp_stats {
181 u32 tcpOutRsts;
182 u64 tcpInSegs;
183 u64 tcpOutSegs;
184 u64 tcpRetransSegs;
185};
186
187struct tp_err_stats {
188 u32 macInErrs[4];
189 u32 hdrInErrs[4];
190 u32 tcpInErrs[4];
191 u32 tnlCongDrops[4];
192 u32 ofldChanDrops[4];
193 u32 tnlTxDrops[4];
194 u32 ofldVlanDrops[4];
195 u32 tcp6InErrs[4];
196 u32 ofldNoNeigh;
197 u32 ofldCongDefer;
198};
199
200struct tp_params {
201 unsigned int ntxchan; /* # of Tx channels */
202 unsigned int tre; /* log2 of core clocks per TP tick */
203};
204
205struct vpd_params {
206 unsigned int cclk;
207 u8 ec[EC_LEN + 1];
208 u8 sn[SERNUM_LEN + 1];
209 u8 id[ID_LEN + 1];
210};
211
212struct pci_params {
213 unsigned char speed;
214 unsigned char width;
215};
216
217struct adapter_params {
218 struct tp_params tp;
219 struct vpd_params vpd;
220 struct pci_params pci;
221
222 unsigned int fw_vers;
223 unsigned int tp_vers;
224 u8 api_vers[7];
225
226 unsigned short mtus[NMTUS];
227 unsigned short a_wnd[NCCTRL_WIN];
228 unsigned short b_wnd[NCCTRL_WIN];
229
230 unsigned char nports; /* # of ethernet ports */
231 unsigned char portvec;
232 unsigned char rev; /* chip revision */
233 unsigned char offload;
234
235 unsigned int ofldq_wr_cred;
236};
237
238struct trace_params {
239 u32 data[TRACE_LEN / 4];
240 u32 mask[TRACE_LEN / 4];
241 unsigned short snap_len;
242 unsigned short min_len;
243 unsigned char skip_ofst;
244 unsigned char skip_len;
245 unsigned char invert;
246 unsigned char port;
247};
248
249struct link_config {
250 unsigned short supported; /* link capabilities */
251 unsigned short advertising; /* advertised capabilities */
252 unsigned short requested_speed; /* speed user has requested */
253 unsigned short speed; /* actual link speed */
254 unsigned char requested_fc; /* flow control user has requested */
255 unsigned char fc; /* actual link flow control */
256 unsigned char autoneg; /* autonegotiating? */
257 unsigned char link_ok; /* link up? */
258};
259
260#define FW_LEN16(fw_struct) FW_CMD_LEN16(sizeof(fw_struct) / 16)
261
262enum {
263 MAX_ETH_QSETS = 32, /* # of Ethernet Tx/Rx queue sets */
264 MAX_OFLD_QSETS = 16, /* # of offload Tx/Rx queue sets */
265 MAX_CTRL_QUEUES = NCHAN, /* # of control Tx queues */
266 MAX_RDMA_QUEUES = NCHAN, /* # of streaming RDMA Rx queues */
267};
268
269enum {
270 MAX_EGRQ = 128, /* max # of egress queues, including FLs */
271 MAX_INGQ = 64 /* max # of interrupt-capable ingress queues */
272};
273
274struct adapter;
275struct vlan_group;
276struct sge_rspq;
277
278struct port_info {
279 struct adapter *adapter;
280 struct vlan_group *vlan_grp;
281 u16 viid;
282 s16 xact_addr_filt; /* index of exact MAC address filter */
283 u16 rss_size; /* size of VI's RSS table slice */
284 s8 mdio_addr;
285 u8 port_type;
286 u8 mod_type;
287 u8 port_id;
288 u8 tx_chan;
289 u8 lport; /* associated offload logical port */
290 u8 rx_offload; /* CSO, etc */
291 u8 nqsets; /* # of qsets */
292 u8 first_qset; /* index of first qset */
293 struct link_config link_cfg;
294};
295
296/* port_info.rx_offload flags */
297enum {
298 RX_CSO = 1 << 0,
299};
300
301struct dentry;
302struct work_struct;
303
304enum { /* adapter flags */
305 FULL_INIT_DONE = (1 << 0),
306 USING_MSI = (1 << 1),
307 USING_MSIX = (1 << 2),
308 QUEUES_BOUND = (1 << 3),
309 FW_OK = (1 << 4),
310};
311
312struct rx_sw_desc;
313
314struct sge_fl { /* SGE free-buffer queue state */
315 unsigned int avail; /* # of available Rx buffers */
316 unsigned int pend_cred; /* new buffers since last FL DB ring */
317 unsigned int cidx; /* consumer index */
318 unsigned int pidx; /* producer index */
319 unsigned long alloc_failed; /* # of times buffer allocation failed */
320 unsigned long large_alloc_failed;
321 unsigned long starving;
322 /* RO fields */
323 unsigned int cntxt_id; /* SGE context id for the free list */
324 unsigned int size; /* capacity of free list */
325 struct rx_sw_desc *sdesc; /* address of SW Rx descriptor ring */
326 __be64 *desc; /* address of HW Rx descriptor ring */
327 dma_addr_t addr; /* bus address of HW ring start */
328};
329
330/* A packet gather list */
331struct pkt_gl {
332 skb_frag_t frags[MAX_SKB_FRAGS];
333 void *va; /* virtual address of first byte */
334 unsigned int nfrags; /* # of fragments */
335 unsigned int tot_len; /* total length of fragments */
336};
337
338typedef int (*rspq_handler_t)(struct sge_rspq *q, const __be64 *rsp,
339 const struct pkt_gl *gl);
340
341struct sge_rspq { /* state for an SGE response queue */
342 struct napi_struct napi;
343 const __be64 *cur_desc; /* current descriptor in queue */
344 unsigned int cidx; /* consumer index */
345 u8 gen; /* current generation bit */
346 u8 intr_params; /* interrupt holdoff parameters */
347 u8 next_intr_params; /* holdoff params for next interrupt */
348 u8 pktcnt_idx; /* interrupt packet threshold */
349 u8 uld; /* ULD handling this queue */
350 u8 idx; /* queue index within its group */
351 int offset; /* offset into current Rx buffer */
352 u16 cntxt_id; /* SGE context id for the response q */
353 u16 abs_id; /* absolute SGE id for the response q */
354 __be64 *desc; /* address of HW response ring */
355 dma_addr_t phys_addr; /* physical address of the ring */
356 unsigned int iqe_len; /* entry size */
357 unsigned int size; /* capacity of response queue */
358 struct adapter *adap;
359 struct net_device *netdev; /* associated net device */
360 rspq_handler_t handler;
361};
362
363struct sge_eth_stats { /* Ethernet queue statistics */
364 unsigned long pkts; /* # of ethernet packets */
365 unsigned long lro_pkts; /* # of LRO super packets */
366 unsigned long lro_merged; /* # of wire packets merged by LRO */
367 unsigned long rx_cso; /* # of Rx checksum offloads */
368 unsigned long vlan_ex; /* # of Rx VLAN extractions */
369 unsigned long rx_drops; /* # of packets dropped due to no mem */
370};
371
372struct sge_eth_rxq { /* SW Ethernet Rx queue */
373 struct sge_rspq rspq;
374 struct sge_fl fl;
375 struct sge_eth_stats stats;
376} ____cacheline_aligned_in_smp;
377
378struct sge_ofld_stats { /* offload queue statistics */
379 unsigned long pkts; /* # of packets */
380 unsigned long imm; /* # of immediate-data packets */
381 unsigned long an; /* # of asynchronous notifications */
382 unsigned long nomem; /* # of responses deferred due to no mem */
383};
384
385struct sge_ofld_rxq { /* SW offload Rx queue */
386 struct sge_rspq rspq;
387 struct sge_fl fl;
388 struct sge_ofld_stats stats;
389} ____cacheline_aligned_in_smp;
390
391struct tx_desc {
392 __be64 flit[8];
393};
394
395struct tx_sw_desc;
396
397struct sge_txq {
398 unsigned int in_use; /* # of in-use Tx descriptors */
399 unsigned int size; /* # of descriptors */
400 unsigned int cidx; /* SW consumer index */
401 unsigned int pidx; /* producer index */
402 unsigned long stops; /* # of times q has been stopped */
403 unsigned long restarts; /* # of queue restarts */
404 unsigned int cntxt_id; /* SGE context id for the Tx q */
405 struct tx_desc *desc; /* address of HW Tx descriptor ring */
406 struct tx_sw_desc *sdesc; /* address of SW Tx descriptor ring */
407 struct sge_qstat *stat; /* queue status entry */
408 dma_addr_t phys_addr; /* physical address of the ring */
409};
410
411struct sge_eth_txq { /* state for an SGE Ethernet Tx queue */
412 struct sge_txq q;
413 struct netdev_queue *txq; /* associated netdev TX queue */
414 unsigned long tso; /* # of TSO requests */
415 unsigned long tx_cso; /* # of Tx checksum offloads */
416 unsigned long vlan_ins; /* # of Tx VLAN insertions */
417 unsigned long mapping_err; /* # of I/O MMU packet mapping errors */
418} ____cacheline_aligned_in_smp;
419
420struct sge_ofld_txq { /* state for an SGE offload Tx queue */
421 struct sge_txq q;
422 struct adapter *adap;
423 struct sk_buff_head sendq; /* list of backpressured packets */
424 struct tasklet_struct qresume_tsk; /* restarts the queue */
425 u8 full; /* the Tx ring is full */
426 unsigned long mapping_err; /* # of I/O MMU packet mapping errors */
427} ____cacheline_aligned_in_smp;
428
429struct sge_ctrl_txq { /* state for an SGE control Tx queue */
430 struct sge_txq q;
431 struct adapter *adap;
432 struct sk_buff_head sendq; /* list of backpressured packets */
433 struct tasklet_struct qresume_tsk; /* restarts the queue */
434 u8 full; /* the Tx ring is full */
435} ____cacheline_aligned_in_smp;
436
437struct sge {
438 struct sge_eth_txq ethtxq[MAX_ETH_QSETS];
439 struct sge_ofld_txq ofldtxq[MAX_OFLD_QSETS];
440 struct sge_ctrl_txq ctrlq[MAX_CTRL_QUEUES];
441
442 struct sge_eth_rxq ethrxq[MAX_ETH_QSETS];
443 struct sge_ofld_rxq ofldrxq[MAX_OFLD_QSETS];
444 struct sge_ofld_rxq rdmarxq[MAX_RDMA_QUEUES];
445 struct sge_rspq fw_evtq ____cacheline_aligned_in_smp;
446
447 struct sge_rspq intrq ____cacheline_aligned_in_smp;
448 spinlock_t intrq_lock;
449
450 u16 max_ethqsets; /* # of available Ethernet queue sets */
451 u16 ethqsets; /* # of active Ethernet queue sets */
452 u16 ethtxq_rover; /* Tx queue to clean up next */
453 u16 ofldqsets; /* # of active offload queue sets */
454 u16 rdmaqs; /* # of available RDMA Rx queues */
455 u16 ofld_rxq[MAX_OFLD_QSETS];
456 u16 rdma_rxq[NCHAN];
457 u16 timer_val[SGE_NTIMERS];
458 u8 counter_val[SGE_NCOUNTERS];
459 unsigned int starve_thres;
460 u8 idma_state[2];
461 void *egr_map[MAX_EGRQ]; /* qid->queue egress queue map */
462 struct sge_rspq *ingr_map[MAX_INGQ]; /* qid->queue ingress queue map */
463 DECLARE_BITMAP(starving_fl, MAX_EGRQ);
464 DECLARE_BITMAP(txq_maperr, MAX_EGRQ);
465 struct timer_list rx_timer; /* refills starving FLs */
466 struct timer_list tx_timer; /* checks Tx queues */
467};
468
469#define for_each_ethrxq(sge, i) for (i = 0; i < (sge)->ethqsets; i++)
470#define for_each_ofldrxq(sge, i) for (i = 0; i < (sge)->ofldqsets; i++)
471#define for_each_rdmarxq(sge, i) for (i = 0; i < (sge)->rdmaqs; i++)
472
473struct l2t_data;
474
475struct adapter {
476 void __iomem *regs;
477 struct pci_dev *pdev;
478 struct device *pdev_dev;
479 unsigned long registered_device_map;
480 unsigned long open_device_map;
481 unsigned long flags;
482
483 const char *name;
484 int msg_enable;
485
486 struct adapter_params params;
487 struct cxgb4_virt_res vres;
488 unsigned int swintr;
489
490 unsigned int wol;
491
492 struct {
493 unsigned short vec;
494 char desc[14];
495 } msix_info[MAX_INGQ + 1];
496
497 struct sge sge;
498
499 struct net_device *port[MAX_NPORTS];
500 u8 chan_map[NCHAN]; /* channel -> port map */
501
502 struct l2t_data *l2t;
503 void *uld_handle[CXGB4_ULD_MAX];
504 struct list_head list_node;
505
506 struct tid_info tids;
507 void **tid_release_head;
508 spinlock_t tid_release_lock;
509 struct work_struct tid_release_task;
510 bool tid_release_task_busy;
511
512 struct dentry *debugfs_root;
513
514 spinlock_t stats_lock;
515};
516
517static inline u32 t4_read_reg(struct adapter *adap, u32 reg_addr)
518{
519 return readl(adap->regs + reg_addr);
520}
521
522static inline void t4_write_reg(struct adapter *adap, u32 reg_addr, u32 val)
523{
524 writel(val, adap->regs + reg_addr);
525}
526
527#ifndef readq
528static inline u64 readq(const volatile void __iomem *addr)
529{
530 return readl(addr) + ((u64)readl(addr + 4) << 32);
531}
532
533static inline void writeq(u64 val, volatile void __iomem *addr)
534{
535 writel(val, addr);
536 writel(val >> 32, addr + 4);
537}
538#endif
539
540static inline u64 t4_read_reg64(struct adapter *adap, u32 reg_addr)
541{
542 return readq(adap->regs + reg_addr);
543}
544
545static inline void t4_write_reg64(struct adapter *adap, u32 reg_addr, u64 val)
546{
547 writeq(val, adap->regs + reg_addr);
548}
549
550/**
551 * netdev2pinfo - return the port_info structure associated with a net_device
552 * @dev: the netdev
553 *
554 * Return the struct port_info associated with a net_device
555 */
556static inline struct port_info *netdev2pinfo(const struct net_device *dev)
557{
558 return netdev_priv(dev);
559}
560
561/**
562 * adap2pinfo - return the port_info of a port
563 * @adap: the adapter
564 * @idx: the port index
565 *
566 * Return the port_info structure for the port of the given index.
567 */
568static inline struct port_info *adap2pinfo(struct adapter *adap, int idx)
569{
570 return netdev_priv(adap->port[idx]);
571}
572
573/**
574 * netdev2adap - return the adapter structure associated with a net_device
575 * @dev: the netdev
576 *
577 * Return the struct adapter associated with a net_device
578 */
579static inline struct adapter *netdev2adap(const struct net_device *dev)
580{
581 return netdev2pinfo(dev)->adapter;
582}
583
584void t4_os_portmod_changed(const struct adapter *adap, int port_id);
585void t4_os_link_changed(struct adapter *adap, int port_id, int link_stat);
586
587void *t4_alloc_mem(size_t size);
588void t4_free_mem(void *addr);
589
590void t4_free_sge_resources(struct adapter *adap);
591irq_handler_t t4_intr_handler(struct adapter *adap);
592netdev_tx_t t4_eth_xmit(struct sk_buff *skb, struct net_device *dev);
593int t4_ethrx_handler(struct sge_rspq *q, const __be64 *rsp,
594 const struct pkt_gl *gl);
595int t4_mgmt_tx(struct adapter *adap, struct sk_buff *skb);
596int t4_ofld_send(struct adapter *adap, struct sk_buff *skb);
597int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
598 struct net_device *dev, int intr_idx,
599 struct sge_fl *fl, rspq_handler_t hnd);
600int t4_sge_alloc_eth_txq(struct adapter *adap, struct sge_eth_txq *txq,
601 struct net_device *dev, struct netdev_queue *netdevq,
602 unsigned int iqid);
603int t4_sge_alloc_ctrl_txq(struct adapter *adap, struct sge_ctrl_txq *txq,
604 struct net_device *dev, unsigned int iqid,
605 unsigned int cmplqid);
606int t4_sge_alloc_ofld_txq(struct adapter *adap, struct sge_ofld_txq *txq,
607 struct net_device *dev, unsigned int iqid);
608irqreturn_t t4_sge_intr_msix(int irq, void *cookie);
609void t4_sge_init(struct adapter *adap);
610void t4_sge_start(struct adapter *adap);
611void t4_sge_stop(struct adapter *adap);
612
613#define for_each_port(adapter, iter) \
614 for (iter = 0; iter < (adapter)->params.nports; ++iter)
615
616static inline unsigned int core_ticks_per_usec(const struct adapter *adap)
617{
618 return adap->params.vpd.cclk / 1000;
619}
620
621static inline unsigned int us_to_core_ticks(const struct adapter *adap,
622 unsigned int us)
623{
624 return (us * adap->params.vpd.cclk) / 1000;
625}
626
627void t4_set_reg_field(struct adapter *adap, unsigned int addr, u32 mask,
628 u32 val);
629
630int t4_wr_mbox_meat(struct adapter *adap, int mbox, const void *cmd, int size,
631 void *rpl, bool sleep_ok);
632
633static inline int t4_wr_mbox(struct adapter *adap, int mbox, const void *cmd,
634 int size, void *rpl)
635{
636 return t4_wr_mbox_meat(adap, mbox, cmd, size, rpl, true);
637}
638
639static inline int t4_wr_mbox_ns(struct adapter *adap, int mbox, const void *cmd,
640 int size, void *rpl)
641{
642 return t4_wr_mbox_meat(adap, mbox, cmd, size, rpl, false);
643}
644
645void t4_intr_enable(struct adapter *adapter);
646void t4_intr_disable(struct adapter *adapter);
647void t4_intr_clear(struct adapter *adapter);
648int t4_slow_intr_handler(struct adapter *adapter);
649
650int t4_link_start(struct adapter *adap, unsigned int mbox, unsigned int port,
651 struct link_config *lc);
652int t4_restart_aneg(struct adapter *adap, unsigned int mbox, unsigned int port);
653int t4_seeprom_wp(struct adapter *adapter, bool enable);
654int t4_read_flash(struct adapter *adapter, unsigned int addr,
655 unsigned int nwords, u32 *data, int byte_oriented);
656int t4_load_fw(struct adapter *adapter, const u8 *fw_data, unsigned int size);
657int t4_check_fw_version(struct adapter *adapter);
658int t4_prep_adapter(struct adapter *adapter);
659int t4_port_init(struct adapter *adap, int mbox, int pf, int vf);
660void t4_fatal_err(struct adapter *adapter);
661void t4_set_vlan_accel(struct adapter *adapter, unsigned int ports, int on);
662int t4_set_trace_filter(struct adapter *adapter, const struct trace_params *tp,
663 int filter_index, int enable);
664void t4_get_trace_filter(struct adapter *adapter, struct trace_params *tp,
665 int filter_index, int *enabled);
666int t4_config_rss_range(struct adapter *adapter, int mbox, unsigned int viid,
667 int start, int n, const u16 *rspq, unsigned int nrspq);
668int t4_config_glbl_rss(struct adapter *adapter, int mbox, unsigned int mode,
669 unsigned int flags);
670int t4_read_rss(struct adapter *adapter, u16 *entries);
671int t4_mc_read(struct adapter *adap, u32 addr, __be32 *data, u64 *parity);
672int t4_edc_read(struct adapter *adap, int idx, u32 addr, __be32 *data,
673 u64 *parity);
674
675void t4_get_port_stats(struct adapter *adap, int idx, struct port_stats *p);
676void t4_get_lb_stats(struct adapter *adap, int idx, struct lb_port_stats *p);
677
678void t4_read_mtu_tbl(struct adapter *adap, u16 *mtus, u8 *mtu_log);
679void t4_tp_get_err_stats(struct adapter *adap, struct tp_err_stats *st);
680void t4_tp_get_tcp_stats(struct adapter *adap, struct tp_tcp_stats *v4,
681 struct tp_tcp_stats *v6);
682void t4_load_mtus(struct adapter *adap, const unsigned short *mtus,
683 const unsigned short *alpha, const unsigned short *beta);
684
685void t4_wol_magic_enable(struct adapter *adap, unsigned int port,
686 const u8 *addr);
687int t4_wol_pat_enable(struct adapter *adap, unsigned int port, unsigned int map,
688 u64 mask0, u64 mask1, unsigned int crc, bool enable);
689
690int t4_fw_hello(struct adapter *adap, unsigned int mbox, unsigned int evt_mbox,
691 enum dev_master master, enum dev_state *state);
692int t4_fw_bye(struct adapter *adap, unsigned int mbox);
693int t4_early_init(struct adapter *adap, unsigned int mbox);
694int t4_fw_reset(struct adapter *adap, unsigned int mbox, int reset);
695int t4_query_params(struct adapter *adap, unsigned int mbox, unsigned int pf,
696 unsigned int vf, unsigned int nparams, const u32 *params,
697 u32 *val);
698int t4_set_params(struct adapter *adap, unsigned int mbox, unsigned int pf,
699 unsigned int vf, unsigned int nparams, const u32 *params,
700 const u32 *val);
701int t4_cfg_pfvf(struct adapter *adap, unsigned int mbox, unsigned int pf,
702 unsigned int vf, unsigned int txq, unsigned int txq_eth_ctrl,
703 unsigned int rxqi, unsigned int rxq, unsigned int tc,
704 unsigned int vi, unsigned int cmask, unsigned int pmask,
705 unsigned int nexact, unsigned int rcaps, unsigned int wxcaps);
706int t4_alloc_vi(struct adapter *adap, unsigned int mbox, unsigned int port,
707 unsigned int pf, unsigned int vf, unsigned int nmac, u8 *mac,
708 unsigned int *rss_size);
709int t4_free_vi(struct adapter *adap, unsigned int mbox, unsigned int pf,
710 unsigned int vf, unsigned int viid);
711int t4_set_rxmode(struct adapter *adap, unsigned int mbox, unsigned int viid,
712 int mtu, int promisc, int all_multi, int bcast, bool sleep_ok);
713int t4_alloc_mac_filt(struct adapter *adap, unsigned int mbox,
714 unsigned int viid, bool free, unsigned int naddr,
715 const u8 **addr, u16 *idx, u64 *hash, bool sleep_ok);
716int t4_change_mac(struct adapter *adap, unsigned int mbox, unsigned int viid,
717 int idx, const u8 *addr, bool persist, bool add_smt);
718int t4_set_addr_hash(struct adapter *adap, unsigned int mbox, unsigned int viid,
719 bool ucast, u64 vec, bool sleep_ok);
720int t4_enable_vi(struct adapter *adap, unsigned int mbox, unsigned int viid,
721 bool rx_en, bool tx_en);
722int t4_identify_port(struct adapter *adap, unsigned int mbox, unsigned int viid,
723 unsigned int nblinks);
724int t4_mdio_rd(struct adapter *adap, unsigned int mbox, unsigned int phy_addr,
725 unsigned int mmd, unsigned int reg, u16 *valp);
726int t4_mdio_wr(struct adapter *adap, unsigned int mbox, unsigned int phy_addr,
727 unsigned int mmd, unsigned int reg, u16 val);
728int t4_iq_start_stop(struct adapter *adap, unsigned int mbox, bool start,
729 unsigned int pf, unsigned int vf, unsigned int iqid,
730 unsigned int fl0id, unsigned int fl1id);
731int t4_iq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
732 unsigned int vf, unsigned int iqtype, unsigned int iqid,
733 unsigned int fl0id, unsigned int fl1id);
734int t4_eth_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
735 unsigned int vf, unsigned int eqid);
736int t4_ctrl_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
737 unsigned int vf, unsigned int eqid);
738int t4_ofld_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
739 unsigned int vf, unsigned int eqid);
740int t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl);
741#endif /* __CXGB4_H__ */
diff --git a/drivers/net/cxgb4/cxgb4_main.c b/drivers/net/cxgb4/cxgb4_main.c
new file mode 100644
index 00000000000..a7e30a23d32
--- /dev/null
+++ b/drivers/net/cxgb4/cxgb4_main.c
@@ -0,0 +1,3388 @@
1/*
2 * This file is part of the Chelsio T4 Ethernet driver for Linux.
3 *
4 * Copyright (c) 2003-2010 Chelsio Communications, Inc. All rights reserved.
5 *
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
11 *
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
14 * conditions are met:
15 *
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer.
19 *
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
24 *
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE.
33 */
34
35#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
36
37#include <linux/bitmap.h>
38#include <linux/crc32.h>
39#include <linux/ctype.h>
40#include <linux/debugfs.h>
41#include <linux/err.h>
42#include <linux/etherdevice.h>
43#include <linux/firmware.h>
44#include <linux/if_vlan.h>
45#include <linux/init.h>
46#include <linux/log2.h>
47#include <linux/mdio.h>
48#include <linux/module.h>
49#include <linux/moduleparam.h>
50#include <linux/mutex.h>
51#include <linux/netdevice.h>
52#include <linux/pci.h>
53#include <linux/aer.h>
54#include <linux/rtnetlink.h>
55#include <linux/sched.h>
56#include <linux/seq_file.h>
57#include <linux/sockios.h>
58#include <linux/vmalloc.h>
59#include <linux/workqueue.h>
60#include <net/neighbour.h>
61#include <net/netevent.h>
62#include <asm/uaccess.h>
63
64#include "cxgb4.h"
65#include "t4_regs.h"
66#include "t4_msg.h"
67#include "t4fw_api.h"
68#include "l2t.h"
69
70#define DRV_VERSION "1.0.0-ko"
71#define DRV_DESC "Chelsio T4 Network Driver"
72
73/*
74 * Max interrupt hold-off timer value in us. Queues fall back to this value
75 * under extreme memory pressure so it's largish to give the system time to
76 * recover.
77 */
78#define MAX_SGE_TIMERVAL 200U
79
80enum {
81 MEMWIN0_APERTURE = 65536,
82 MEMWIN0_BASE = 0x30000,
83 MEMWIN1_APERTURE = 32768,
84 MEMWIN1_BASE = 0x28000,
85 MEMWIN2_APERTURE = 2048,
86 MEMWIN2_BASE = 0x1b800,
87};
88
89enum {
90 MAX_TXQ_ENTRIES = 16384,
91 MAX_CTRL_TXQ_ENTRIES = 1024,
92 MAX_RSPQ_ENTRIES = 16384,
93 MAX_RX_BUFFERS = 16384,
94 MIN_TXQ_ENTRIES = 32,
95 MIN_CTRL_TXQ_ENTRIES = 32,
96 MIN_RSPQ_ENTRIES = 128,
97 MIN_FL_ENTRIES = 16
98};
99
100#define DFLT_MSG_ENABLE (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK | \
101 NETIF_MSG_TIMER | NETIF_MSG_IFDOWN | NETIF_MSG_IFUP |\
102 NETIF_MSG_RX_ERR | NETIF_MSG_TX_ERR)
103
104#define CH_DEVICE(devid) { PCI_VDEVICE(CHELSIO, devid), 0 }
105
106static DEFINE_PCI_DEVICE_TABLE(cxgb4_pci_tbl) = {
107 CH_DEVICE(0xa000), /* PE10K */
108 { 0, }
109};
110
111#define FW_FNAME "cxgb4/t4fw.bin"
112
113MODULE_DESCRIPTION(DRV_DESC);
114MODULE_AUTHOR("Chelsio Communications");
115MODULE_LICENSE("Dual BSD/GPL");
116MODULE_VERSION(DRV_VERSION);
117MODULE_DEVICE_TABLE(pci, cxgb4_pci_tbl);
118MODULE_FIRMWARE(FW_FNAME);
119
120static int dflt_msg_enable = DFLT_MSG_ENABLE;
121
122module_param(dflt_msg_enable, int, 0644);
123MODULE_PARM_DESC(dflt_msg_enable, "Chelsio T4 default message enable bitmap");
124
125/*
126 * The driver uses the best interrupt scheme available on a platform in the
127 * order MSI-X, MSI, legacy INTx interrupts. This parameter determines which
128 * of these schemes the driver may consider as follows:
129 *
130 * msi = 2: choose from among all three options
131 * msi = 1: only consider MSI and INTx interrupts
132 * msi = 0: force INTx interrupts
133 */
134static int msi = 2;
135
136module_param(msi, int, 0644);
137MODULE_PARM_DESC(msi, "whether to use INTx (0), MSI (1) or MSI-X (2)");
138
139/*
140 * Queue interrupt hold-off timer values. Queues default to the first of these
141 * upon creation.
142 */
143static unsigned int intr_holdoff[SGE_NTIMERS - 1] = { 5, 10, 20, 50, 100 };
144
145module_param_array(intr_holdoff, uint, NULL, 0644);
146MODULE_PARM_DESC(intr_holdoff, "values for queue interrupt hold-off timers "
147 "0..4 in microseconds");
148
149static unsigned int intr_cnt[SGE_NCOUNTERS - 1] = { 4, 8, 16 };
150
151module_param_array(intr_cnt, uint, NULL, 0644);
152MODULE_PARM_DESC(intr_cnt,
153 "thresholds 1..3 for queue interrupt packet counters");
154
155static int vf_acls;
156
157#ifdef CONFIG_PCI_IOV
158module_param(vf_acls, bool, 0644);
159MODULE_PARM_DESC(vf_acls, "if set enable virtualization L2 ACL enforcement");
160
161static unsigned int num_vf[4];
162
163module_param_array(num_vf, uint, NULL, 0644);
164MODULE_PARM_DESC(num_vf, "number of VFs for each of PFs 0-3");
165#endif
166
167static struct dentry *cxgb4_debugfs_root;
168
169static LIST_HEAD(adapter_list);
170static DEFINE_MUTEX(uld_mutex);
171static struct cxgb4_uld_info ulds[CXGB4_ULD_MAX];
172static const char *uld_str[] = { "RDMA", "iSCSI" };
173
174static void link_report(struct net_device *dev)
175{
176 if (!netif_carrier_ok(dev))
177 netdev_info(dev, "link down\n");
178 else {
179 static const char *fc[] = { "no", "Rx", "Tx", "Tx/Rx" };
180
181 const char *s = "10Mbps";
182 const struct port_info *p = netdev_priv(dev);
183
184 switch (p->link_cfg.speed) {
185 case SPEED_10000:
186 s = "10Gbps";
187 break;
188 case SPEED_1000:
189 s = "1000Mbps";
190 break;
191 case SPEED_100:
192 s = "100Mbps";
193 break;
194 }
195
196 netdev_info(dev, "link up, %s, full-duplex, %s PAUSE\n", s,
197 fc[p->link_cfg.fc]);
198 }
199}
200
201void t4_os_link_changed(struct adapter *adapter, int port_id, int link_stat)
202{
203 struct net_device *dev = adapter->port[port_id];
204
205 /* Skip changes from disabled ports. */
206 if (netif_running(dev) && link_stat != netif_carrier_ok(dev)) {
207 if (link_stat)
208 netif_carrier_on(dev);
209 else
210 netif_carrier_off(dev);
211
212 link_report(dev);
213 }
214}
215
216void t4_os_portmod_changed(const struct adapter *adap, int port_id)
217{
218 static const char *mod_str[] = {
219 NULL, "LR", "SR", "ER", "passive DA", "active DA"
220 };
221
222 const struct net_device *dev = adap->port[port_id];
223 const struct port_info *pi = netdev_priv(dev);
224
225 if (pi->mod_type == FW_PORT_MOD_TYPE_NONE)
226 netdev_info(dev, "port module unplugged\n");
227 else
228 netdev_info(dev, "%s module inserted\n", mod_str[pi->mod_type]);
229}
230
231/*
232 * Configure the exact and hash address filters to handle a port's multicast
233 * and secondary unicast MAC addresses.
234 */
235static int set_addr_filters(const struct net_device *dev, bool sleep)
236{
237 u64 mhash = 0;
238 u64 uhash = 0;
239 bool free = true;
240 u16 filt_idx[7];
241 const u8 *addr[7];
242 int ret, naddr = 0;
243 const struct dev_addr_list *d;
244 const struct netdev_hw_addr *ha;
245 int uc_cnt = netdev_uc_count(dev);
246 const struct port_info *pi = netdev_priv(dev);
247
248 /* first do the secondary unicast addresses */
249 netdev_for_each_uc_addr(ha, dev) {
250 addr[naddr++] = ha->addr;
251 if (--uc_cnt == 0 || naddr >= ARRAY_SIZE(addr)) {
252 ret = t4_alloc_mac_filt(pi->adapter, 0, pi->viid, free,
253 naddr, addr, filt_idx, &uhash, sleep);
254 if (ret < 0)
255 return ret;
256
257 free = false;
258 naddr = 0;
259 }
260 }
261
262 /* next set up the multicast addresses */
263 netdev_for_each_mc_addr(d, dev) {
264 addr[naddr++] = d->dmi_addr;
265 if (naddr >= ARRAY_SIZE(addr) || d->next == NULL) {
266 ret = t4_alloc_mac_filt(pi->adapter, 0, pi->viid, free,
267 naddr, addr, filt_idx, &mhash, sleep);
268 if (ret < 0)
269 return ret;
270
271 free = false;
272 naddr = 0;
273 }
274 }
275
276 return t4_set_addr_hash(pi->adapter, 0, pi->viid, uhash != 0,
277 uhash | mhash, sleep);
278}
279
280/*
281 * Set Rx properties of a port, such as promiscruity, address filters, and MTU.
282 * If @mtu is -1 it is left unchanged.
283 */
284static int set_rxmode(struct net_device *dev, int mtu, bool sleep_ok)
285{
286 int ret;
287 struct port_info *pi = netdev_priv(dev);
288
289 ret = set_addr_filters(dev, sleep_ok);
290 if (ret == 0)
291 ret = t4_set_rxmode(pi->adapter, 0, pi->viid, mtu,
292 (dev->flags & IFF_PROMISC) ? 1 : 0,
293 (dev->flags & IFF_ALLMULTI) ? 1 : 0, 1,
294 sleep_ok);
295 return ret;
296}
297
298/**
299 * link_start - enable a port
300 * @dev: the port to enable
301 *
302 * Performs the MAC and PHY actions needed to enable a port.
303 */
304static int link_start(struct net_device *dev)
305{
306 int ret;
307 struct port_info *pi = netdev_priv(dev);
308
309 /*
310 * We do not set address filters and promiscuity here, the stack does
311 * that step explicitly.
312 */
313 ret = t4_set_rxmode(pi->adapter, 0, pi->viid, dev->mtu, -1, -1, -1,
314 true);
315 if (ret == 0) {
316 ret = t4_change_mac(pi->adapter, 0, pi->viid,
317 pi->xact_addr_filt, dev->dev_addr, true,
318 false);
319 if (ret >= 0) {
320 pi->xact_addr_filt = ret;
321 ret = 0;
322 }
323 }
324 if (ret == 0)
325 ret = t4_link_start(pi->adapter, 0, pi->tx_chan, &pi->link_cfg);
326 if (ret == 0)
327 ret = t4_enable_vi(pi->adapter, 0, pi->viid, true, true);
328 return ret;
329}
330
331/*
332 * Response queue handler for the FW event queue.
333 */
334static int fwevtq_handler(struct sge_rspq *q, const __be64 *rsp,
335 const struct pkt_gl *gl)
336{
337 u8 opcode = ((const struct rss_header *)rsp)->opcode;
338
339 rsp++; /* skip RSS header */
340 if (likely(opcode == CPL_SGE_EGR_UPDATE)) {
341 const struct cpl_sge_egr_update *p = (void *)rsp;
342 unsigned int qid = EGR_QID(ntohl(p->opcode_qid));
343 struct sge_txq *txq = q->adap->sge.egr_map[qid];
344
345 txq->restarts++;
346 if ((u8 *)txq < (u8 *)q->adap->sge.ethrxq) {
347 struct sge_eth_txq *eq;
348
349 eq = container_of(txq, struct sge_eth_txq, q);
350 netif_tx_wake_queue(eq->txq);
351 } else {
352 struct sge_ofld_txq *oq;
353
354 oq = container_of(txq, struct sge_ofld_txq, q);
355 tasklet_schedule(&oq->qresume_tsk);
356 }
357 } else if (opcode == CPL_FW6_MSG || opcode == CPL_FW4_MSG) {
358 const struct cpl_fw6_msg *p = (void *)rsp;
359
360 if (p->type == 0)
361 t4_handle_fw_rpl(q->adap, p->data);
362 } else if (opcode == CPL_L2T_WRITE_RPL) {
363 const struct cpl_l2t_write_rpl *p = (void *)rsp;
364
365 do_l2t_write_rpl(q->adap, p);
366 } else
367 dev_err(q->adap->pdev_dev,
368 "unexpected CPL %#x on FW event queue\n", opcode);
369 return 0;
370}
371
372/**
373 * uldrx_handler - response queue handler for ULD queues
374 * @q: the response queue that received the packet
375 * @rsp: the response queue descriptor holding the offload message
376 * @gl: the gather list of packet fragments
377 *
378 * Deliver an ingress offload packet to a ULD. All processing is done by
379 * the ULD, we just maintain statistics.
380 */
381static int uldrx_handler(struct sge_rspq *q, const __be64 *rsp,
382 const struct pkt_gl *gl)
383{
384 struct sge_ofld_rxq *rxq = container_of(q, struct sge_ofld_rxq, rspq);
385
386 if (ulds[q->uld].rx_handler(q->adap->uld_handle[q->uld], rsp, gl)) {
387 rxq->stats.nomem++;
388 return -1;
389 }
390 if (gl == NULL)
391 rxq->stats.imm++;
392 else if (gl == CXGB4_MSG_AN)
393 rxq->stats.an++;
394 else
395 rxq->stats.pkts++;
396 return 0;
397}
398
399static void disable_msi(struct adapter *adapter)
400{
401 if (adapter->flags & USING_MSIX) {
402 pci_disable_msix(adapter->pdev);
403 adapter->flags &= ~USING_MSIX;
404 } else if (adapter->flags & USING_MSI) {
405 pci_disable_msi(adapter->pdev);
406 adapter->flags &= ~USING_MSI;
407 }
408}
409
410/*
411 * Interrupt handler for non-data events used with MSI-X.
412 */
413static irqreturn_t t4_nondata_intr(int irq, void *cookie)
414{
415 struct adapter *adap = cookie;
416
417 u32 v = t4_read_reg(adap, MYPF_REG(PL_PF_INT_CAUSE));
418 if (v & PFSW) {
419 adap->swintr = 1;
420 t4_write_reg(adap, MYPF_REG(PL_PF_INT_CAUSE), v);
421 }
422 t4_slow_intr_handler(adap);
423 return IRQ_HANDLED;
424}
425
426/*
427 * Name the MSI-X interrupts.
428 */
429static void name_msix_vecs(struct adapter *adap)
430{
431 int i, j, msi_idx = 2, n = sizeof(adap->msix_info[0].desc) - 1;
432
433 /* non-data interrupts */
434 snprintf(adap->msix_info[0].desc, n, "%s", adap->name);
435 adap->msix_info[0].desc[n] = 0;
436
437 /* FW events */
438 snprintf(adap->msix_info[1].desc, n, "%s-FWeventq", adap->name);
439 adap->msix_info[1].desc[n] = 0;
440
441 /* Ethernet queues */
442 for_each_port(adap, j) {
443 struct net_device *d = adap->port[j];
444 const struct port_info *pi = netdev_priv(d);
445
446 for (i = 0; i < pi->nqsets; i++, msi_idx++) {
447 snprintf(adap->msix_info[msi_idx].desc, n, "%s-Rx%d",
448 d->name, i);
449 adap->msix_info[msi_idx].desc[n] = 0;
450 }
451 }
452
453 /* offload queues */
454 for_each_ofldrxq(&adap->sge, i) {
455 snprintf(adap->msix_info[msi_idx].desc, n, "%s-ofld%d",
456 adap->name, i);
457 adap->msix_info[msi_idx++].desc[n] = 0;
458 }
459 for_each_rdmarxq(&adap->sge, i) {
460 snprintf(adap->msix_info[msi_idx].desc, n, "%s-rdma%d",
461 adap->name, i);
462 adap->msix_info[msi_idx++].desc[n] = 0;
463 }
464}
465
466static int request_msix_queue_irqs(struct adapter *adap)
467{
468 struct sge *s = &adap->sge;
469 int err, ethqidx, ofldqidx = 0, rdmaqidx = 0, msi = 2;
470
471 err = request_irq(adap->msix_info[1].vec, t4_sge_intr_msix, 0,
472 adap->msix_info[1].desc, &s->fw_evtq);
473 if (err)
474 return err;
475
476 for_each_ethrxq(s, ethqidx) {
477 err = request_irq(adap->msix_info[msi].vec, t4_sge_intr_msix, 0,
478 adap->msix_info[msi].desc,
479 &s->ethrxq[ethqidx].rspq);
480 if (err)
481 goto unwind;
482 msi++;
483 }
484 for_each_ofldrxq(s, ofldqidx) {
485 err = request_irq(adap->msix_info[msi].vec, t4_sge_intr_msix, 0,
486 adap->msix_info[msi].desc,
487 &s->ofldrxq[ofldqidx].rspq);
488 if (err)
489 goto unwind;
490 msi++;
491 }
492 for_each_rdmarxq(s, rdmaqidx) {
493 err = request_irq(adap->msix_info[msi].vec, t4_sge_intr_msix, 0,
494 adap->msix_info[msi].desc,
495 &s->rdmarxq[rdmaqidx].rspq);
496 if (err)
497 goto unwind;
498 msi++;
499 }
500 return 0;
501
502unwind:
503 while (--rdmaqidx >= 0)
504 free_irq(adap->msix_info[--msi].vec,
505 &s->rdmarxq[rdmaqidx].rspq);
506 while (--ofldqidx >= 0)
507 free_irq(adap->msix_info[--msi].vec,
508 &s->ofldrxq[ofldqidx].rspq);
509 while (--ethqidx >= 0)
510 free_irq(adap->msix_info[--msi].vec, &s->ethrxq[ethqidx].rspq);
511 free_irq(adap->msix_info[1].vec, &s->fw_evtq);
512 return err;
513}
514
515static void free_msix_queue_irqs(struct adapter *adap)
516{
517 int i, msi = 2;
518 struct sge *s = &adap->sge;
519
520 free_irq(adap->msix_info[1].vec, &s->fw_evtq);
521 for_each_ethrxq(s, i)
522 free_irq(adap->msix_info[msi++].vec, &s->ethrxq[i].rspq);
523 for_each_ofldrxq(s, i)
524 free_irq(adap->msix_info[msi++].vec, &s->ofldrxq[i].rspq);
525 for_each_rdmarxq(s, i)
526 free_irq(adap->msix_info[msi++].vec, &s->rdmarxq[i].rspq);
527}
528
529/**
530 * setup_rss - configure RSS
531 * @adap: the adapter
532 *
533 * Sets up RSS to distribute packets to multiple receive queues. We
534 * configure the RSS CPU lookup table to distribute to the number of HW
535 * receive queues, and the response queue lookup table to narrow that
536 * down to the response queues actually configured for each port.
537 * We always configure the RSS mapping for all ports since the mapping
538 * table has plenty of entries.
539 */
540static int setup_rss(struct adapter *adap)
541{
542 int i, j, err;
543 u16 rss[MAX_ETH_QSETS];
544
545 for_each_port(adap, i) {
546 const struct port_info *pi = adap2pinfo(adap, i);
547 const struct sge_eth_rxq *q = &adap->sge.ethrxq[pi->first_qset];
548
549 for (j = 0; j < pi->nqsets; j++)
550 rss[j] = q[j].rspq.abs_id;
551
552 err = t4_config_rss_range(adap, 0, pi->viid, 0, pi->rss_size,
553 rss, pi->nqsets);
554 if (err)
555 return err;
556 }
557 return 0;
558}
559
560/*
561 * Wait until all NAPI handlers are descheduled.
562 */
563static void quiesce_rx(struct adapter *adap)
564{
565 int i;
566
567 for (i = 0; i < ARRAY_SIZE(adap->sge.ingr_map); i++) {
568 struct sge_rspq *q = adap->sge.ingr_map[i];
569
570 if (q && q->handler)
571 napi_disable(&q->napi);
572 }
573}
574
575/*
576 * Enable NAPI scheduling and interrupt generation for all Rx queues.
577 */
578static void enable_rx(struct adapter *adap)
579{
580 int i;
581
582 for (i = 0; i < ARRAY_SIZE(adap->sge.ingr_map); i++) {
583 struct sge_rspq *q = adap->sge.ingr_map[i];
584
585 if (!q)
586 continue;
587 if (q->handler)
588 napi_enable(&q->napi);
589 /* 0-increment GTS to start the timer and enable interrupts */
590 t4_write_reg(adap, MYPF_REG(SGE_PF_GTS),
591 SEINTARM(q->intr_params) |
592 INGRESSQID(q->cntxt_id));
593 }
594}
595
596/**
597 * setup_sge_queues - configure SGE Tx/Rx/response queues
598 * @adap: the adapter
599 *
600 * Determines how many sets of SGE queues to use and initializes them.
601 * We support multiple queue sets per port if we have MSI-X, otherwise
602 * just one queue set per port.
603 */
604static int setup_sge_queues(struct adapter *adap)
605{
606 int err, msi_idx, i, j;
607 struct sge *s = &adap->sge;
608
609 bitmap_zero(s->starving_fl, MAX_EGRQ);
610 bitmap_zero(s->txq_maperr, MAX_EGRQ);
611
612 if (adap->flags & USING_MSIX)
613 msi_idx = 1; /* vector 0 is for non-queue interrupts */
614 else {
615 err = t4_sge_alloc_rxq(adap, &s->intrq, false, adap->port[0], 0,
616 NULL, NULL);
617 if (err)
618 return err;
619 msi_idx = -((int)s->intrq.abs_id + 1);
620 }
621
622 err = t4_sge_alloc_rxq(adap, &s->fw_evtq, true, adap->port[0],
623 msi_idx, NULL, fwevtq_handler);
624 if (err) {
625freeout: t4_free_sge_resources(adap);
626 return err;
627 }
628
629 for_each_port(adap, i) {
630 struct net_device *dev = adap->port[i];
631 struct port_info *pi = netdev_priv(dev);
632 struct sge_eth_rxq *q = &s->ethrxq[pi->first_qset];
633 struct sge_eth_txq *t = &s->ethtxq[pi->first_qset];
634
635 for (j = 0; j < pi->nqsets; j++, q++) {
636 if (msi_idx > 0)
637 msi_idx++;
638 err = t4_sge_alloc_rxq(adap, &q->rspq, false, dev,
639 msi_idx, &q->fl,
640 t4_ethrx_handler);
641 if (err)
642 goto freeout;
643 q->rspq.idx = j;
644 memset(&q->stats, 0, sizeof(q->stats));
645 }
646 for (j = 0; j < pi->nqsets; j++, t++) {
647 err = t4_sge_alloc_eth_txq(adap, t, dev,
648 netdev_get_tx_queue(dev, j),
649 s->fw_evtq.cntxt_id);
650 if (err)
651 goto freeout;
652 }
653 }
654
655 j = s->ofldqsets / adap->params.nports; /* ofld queues per channel */
656 for_each_ofldrxq(s, i) {
657 struct sge_ofld_rxq *q = &s->ofldrxq[i];
658 struct net_device *dev = adap->port[i / j];
659
660 if (msi_idx > 0)
661 msi_idx++;
662 err = t4_sge_alloc_rxq(adap, &q->rspq, false, dev, msi_idx,
663 &q->fl, uldrx_handler);
664 if (err)
665 goto freeout;
666 memset(&q->stats, 0, sizeof(q->stats));
667 s->ofld_rxq[i] = q->rspq.abs_id;
668 err = t4_sge_alloc_ofld_txq(adap, &s->ofldtxq[i], dev,
669 s->fw_evtq.cntxt_id);
670 if (err)
671 goto freeout;
672 }
673
674 for_each_rdmarxq(s, i) {
675 struct sge_ofld_rxq *q = &s->rdmarxq[i];
676
677 if (msi_idx > 0)
678 msi_idx++;
679 err = t4_sge_alloc_rxq(adap, &q->rspq, false, adap->port[i],
680 msi_idx, &q->fl, uldrx_handler);
681 if (err)
682 goto freeout;
683 memset(&q->stats, 0, sizeof(q->stats));
684 s->rdma_rxq[i] = q->rspq.abs_id;
685 }
686
687 for_each_port(adap, i) {
688 /*
689 * Note that ->rdmarxq[i].rspq.cntxt_id below is 0 if we don't
690 * have RDMA queues, and that's the right value.
691 */
692 err = t4_sge_alloc_ctrl_txq(adap, &s->ctrlq[i], adap->port[i],
693 s->fw_evtq.cntxt_id,
694 s->rdmarxq[i].rspq.cntxt_id);
695 if (err)
696 goto freeout;
697 }
698
699 t4_write_reg(adap, MPS_TRC_RSS_CONTROL,
700 RSSCONTROL(netdev2pinfo(adap->port[0])->tx_chan) |
701 QUEUENUMBER(s->ethrxq[0].rspq.abs_id));
702 return 0;
703}
704
705/*
706 * Returns 0 if new FW was successfully loaded, a positive errno if a load was
707 * started but failed, and a negative errno if flash load couldn't start.
708 */
709static int upgrade_fw(struct adapter *adap)
710{
711 int ret;
712 u32 vers;
713 const struct fw_hdr *hdr;
714 const struct firmware *fw;
715 struct device *dev = adap->pdev_dev;
716
717 ret = request_firmware(&fw, FW_FNAME, dev);
718 if (ret < 0) {
719 dev_err(dev, "unable to load firmware image " FW_FNAME
720 ", error %d\n", ret);
721 return ret;
722 }
723
724 hdr = (const struct fw_hdr *)fw->data;
725 vers = ntohl(hdr->fw_ver);
726 if (FW_HDR_FW_VER_MAJOR_GET(vers) != FW_VERSION_MAJOR) {
727 ret = -EINVAL; /* wrong major version, won't do */
728 goto out;
729 }
730
731 /*
732 * If the flash FW is unusable or we found something newer, load it.
733 */
734 if (FW_HDR_FW_VER_MAJOR_GET(adap->params.fw_vers) != FW_VERSION_MAJOR ||
735 vers > adap->params.fw_vers) {
736 ret = -t4_load_fw(adap, fw->data, fw->size);
737 if (!ret)
738 dev_info(dev, "firmware upgraded to version %pI4 from "
739 FW_FNAME "\n", &hdr->fw_ver);
740 }
741out: release_firmware(fw);
742 return ret;
743}
744
745/*
746 * Allocate a chunk of memory using kmalloc or, if that fails, vmalloc.
747 * The allocated memory is cleared.
748 */
749void *t4_alloc_mem(size_t size)
750{
751 void *p = kmalloc(size, GFP_KERNEL);
752
753 if (!p)
754 p = vmalloc(size);
755 if (p)
756 memset(p, 0, size);
757 return p;
758}
759
760/*
761 * Free memory allocated through alloc_mem().
762 */
763void t4_free_mem(void *addr)
764{
765 if (is_vmalloc_addr(addr))
766 vfree(addr);
767 else
768 kfree(addr);
769}
770
771static inline int is_offload(const struct adapter *adap)
772{
773 return adap->params.offload;
774}
775
776/*
777 * Implementation of ethtool operations.
778 */
779
780static u32 get_msglevel(struct net_device *dev)
781{
782 return netdev2adap(dev)->msg_enable;
783}
784
785static void set_msglevel(struct net_device *dev, u32 val)
786{
787 netdev2adap(dev)->msg_enable = val;
788}
789
790static char stats_strings[][ETH_GSTRING_LEN] = {
791 "TxOctetsOK ",
792 "TxFramesOK ",
793 "TxBroadcastFrames ",
794 "TxMulticastFrames ",
795 "TxUnicastFrames ",
796 "TxErrorFrames ",
797
798 "TxFrames64 ",
799 "TxFrames65To127 ",
800 "TxFrames128To255 ",
801 "TxFrames256To511 ",
802 "TxFrames512To1023 ",
803 "TxFrames1024To1518 ",
804 "TxFrames1519ToMax ",
805
806 "TxFramesDropped ",
807 "TxPauseFrames ",
808 "TxPPP0Frames ",
809 "TxPPP1Frames ",
810 "TxPPP2Frames ",
811 "TxPPP3Frames ",
812 "TxPPP4Frames ",
813 "TxPPP5Frames ",
814 "TxPPP6Frames ",
815 "TxPPP7Frames ",
816
817 "RxOctetsOK ",
818 "RxFramesOK ",
819 "RxBroadcastFrames ",
820 "RxMulticastFrames ",
821 "RxUnicastFrames ",
822
823 "RxFramesTooLong ",
824 "RxJabberErrors ",
825 "RxFCSErrors ",
826 "RxLengthErrors ",
827 "RxSymbolErrors ",
828 "RxRuntFrames ",
829
830 "RxFrames64 ",
831 "RxFrames65To127 ",
832 "RxFrames128To255 ",
833 "RxFrames256To511 ",
834 "RxFrames512To1023 ",
835 "RxFrames1024To1518 ",
836 "RxFrames1519ToMax ",
837
838 "RxPauseFrames ",
839 "RxPPP0Frames ",
840 "RxPPP1Frames ",
841 "RxPPP2Frames ",
842 "RxPPP3Frames ",
843 "RxPPP4Frames ",
844 "RxPPP5Frames ",
845 "RxPPP6Frames ",
846 "RxPPP7Frames ",
847
848 "RxBG0FramesDropped ",
849 "RxBG1FramesDropped ",
850 "RxBG2FramesDropped ",
851 "RxBG3FramesDropped ",
852 "RxBG0FramesTrunc ",
853 "RxBG1FramesTrunc ",
854 "RxBG2FramesTrunc ",
855 "RxBG3FramesTrunc ",
856
857 "TSO ",
858 "TxCsumOffload ",
859 "RxCsumGood ",
860 "VLANextractions ",
861 "VLANinsertions ",
862};
863
864static int get_sset_count(struct net_device *dev, int sset)
865{
866 switch (sset) {
867 case ETH_SS_STATS:
868 return ARRAY_SIZE(stats_strings);
869 default:
870 return -EOPNOTSUPP;
871 }
872}
873
874#define T4_REGMAP_SIZE (160 * 1024)
875
876static int get_regs_len(struct net_device *dev)
877{
878 return T4_REGMAP_SIZE;
879}
880
881static int get_eeprom_len(struct net_device *dev)
882{
883 return EEPROMSIZE;
884}
885
886static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
887{
888 struct adapter *adapter = netdev2adap(dev);
889
890 strcpy(info->driver, KBUILD_MODNAME);
891 strcpy(info->version, DRV_VERSION);
892 strcpy(info->bus_info, pci_name(adapter->pdev));
893
894 if (!adapter->params.fw_vers)
895 strcpy(info->fw_version, "N/A");
896 else
897 snprintf(info->fw_version, sizeof(info->fw_version),
898 "%u.%u.%u.%u, TP %u.%u.%u.%u",
899 FW_HDR_FW_VER_MAJOR_GET(adapter->params.fw_vers),
900 FW_HDR_FW_VER_MINOR_GET(adapter->params.fw_vers),
901 FW_HDR_FW_VER_MICRO_GET(adapter->params.fw_vers),
902 FW_HDR_FW_VER_BUILD_GET(adapter->params.fw_vers),
903 FW_HDR_FW_VER_MAJOR_GET(adapter->params.tp_vers),
904 FW_HDR_FW_VER_MINOR_GET(adapter->params.tp_vers),
905 FW_HDR_FW_VER_MICRO_GET(adapter->params.tp_vers),
906 FW_HDR_FW_VER_BUILD_GET(adapter->params.tp_vers));
907}
908
909static void get_strings(struct net_device *dev, u32 stringset, u8 *data)
910{
911 if (stringset == ETH_SS_STATS)
912 memcpy(data, stats_strings, sizeof(stats_strings));
913}
914
915/*
916 * port stats maintained per queue of the port. They should be in the same
917 * order as in stats_strings above.
918 */
919struct queue_port_stats {
920 u64 tso;
921 u64 tx_csum;
922 u64 rx_csum;
923 u64 vlan_ex;
924 u64 vlan_ins;
925};
926
927static void collect_sge_port_stats(const struct adapter *adap,
928 const struct port_info *p, struct queue_port_stats *s)
929{
930 int i;
931 const struct sge_eth_txq *tx = &adap->sge.ethtxq[p->first_qset];
932 const struct sge_eth_rxq *rx = &adap->sge.ethrxq[p->first_qset];
933
934 memset(s, 0, sizeof(*s));
935 for (i = 0; i < p->nqsets; i++, rx++, tx++) {
936 s->tso += tx->tso;
937 s->tx_csum += tx->tx_cso;
938 s->rx_csum += rx->stats.rx_cso;
939 s->vlan_ex += rx->stats.vlan_ex;
940 s->vlan_ins += tx->vlan_ins;
941 }
942}
943
944static void get_stats(struct net_device *dev, struct ethtool_stats *stats,
945 u64 *data)
946{
947 struct port_info *pi = netdev_priv(dev);
948 struct adapter *adapter = pi->adapter;
949
950 t4_get_port_stats(adapter, pi->tx_chan, (struct port_stats *)data);
951
952 data += sizeof(struct port_stats) / sizeof(u64);
953 collect_sge_port_stats(adapter, pi, (struct queue_port_stats *)data);
954}
955
956/*
957 * Return a version number to identify the type of adapter. The scheme is:
958 * - bits 0..9: chip version
959 * - bits 10..15: chip revision
960 */
961static inline unsigned int mk_adap_vers(const struct adapter *ap)
962{
963 return 4 | (ap->params.rev << 10);
964}
965
966static void reg_block_dump(struct adapter *ap, void *buf, unsigned int start,
967 unsigned int end)
968{
969 u32 *p = buf + start;
970
971 for ( ; start <= end; start += sizeof(u32))
972 *p++ = t4_read_reg(ap, start);
973}
974
975static void get_regs(struct net_device *dev, struct ethtool_regs *regs,
976 void *buf)
977{
978 static const unsigned int reg_ranges[] = {
979 0x1008, 0x1108,
980 0x1180, 0x11b4,
981 0x11fc, 0x123c,
982 0x1300, 0x173c,
983 0x1800, 0x18fc,
984 0x3000, 0x30d8,
985 0x30e0, 0x5924,
986 0x5960, 0x59d4,
987 0x5a00, 0x5af8,
988 0x6000, 0x6098,
989 0x6100, 0x6150,
990 0x6200, 0x6208,
991 0x6240, 0x6248,
992 0x6280, 0x6338,
993 0x6370, 0x638c,
994 0x6400, 0x643c,
995 0x6500, 0x6524,
996 0x6a00, 0x6a38,
997 0x6a60, 0x6a78,
998 0x6b00, 0x6b84,
999 0x6bf0, 0x6c84,
1000 0x6cf0, 0x6d84,
1001 0x6df0, 0x6e84,
1002 0x6ef0, 0x6f84,
1003 0x6ff0, 0x7084,
1004 0x70f0, 0x7184,
1005 0x71f0, 0x7284,
1006 0x72f0, 0x7384,
1007 0x73f0, 0x7450,
1008 0x7500, 0x7530,
1009 0x7600, 0x761c,
1010 0x7680, 0x76cc,
1011 0x7700, 0x7798,
1012 0x77c0, 0x77fc,
1013 0x7900, 0x79fc,
1014 0x7b00, 0x7c38,
1015 0x7d00, 0x7efc,
1016 0x8dc0, 0x8e1c,
1017 0x8e30, 0x8e78,
1018 0x8ea0, 0x8f6c,
1019 0x8fc0, 0x9074,
1020 0x90fc, 0x90fc,
1021 0x9400, 0x9458,
1022 0x9600, 0x96bc,
1023 0x9800, 0x9808,
1024 0x9820, 0x983c,
1025 0x9850, 0x9864,
1026 0x9c00, 0x9c6c,
1027 0x9c80, 0x9cec,
1028 0x9d00, 0x9d6c,
1029 0x9d80, 0x9dec,
1030 0x9e00, 0x9e6c,
1031 0x9e80, 0x9eec,
1032 0x9f00, 0x9f6c,
1033 0x9f80, 0x9fec,
1034 0xd004, 0xd03c,
1035 0xdfc0, 0xdfe0,
1036 0xe000, 0xea7c,
1037 0xf000, 0x11190,
1038 0x19040, 0x19124,
1039 0x19150, 0x191b0,
1040 0x191d0, 0x191e8,
1041 0x19238, 0x1924c,
1042 0x193f8, 0x19474,
1043 0x19490, 0x194f8,
1044 0x19800, 0x19f30,
1045 0x1a000, 0x1a06c,
1046 0x1a0b0, 0x1a120,
1047 0x1a128, 0x1a138,
1048 0x1a190, 0x1a1c4,
1049 0x1a1fc, 0x1a1fc,
1050 0x1e040, 0x1e04c,
1051 0x1e240, 0x1e28c,
1052 0x1e2c0, 0x1e2c0,
1053 0x1e2e0, 0x1e2e0,
1054 0x1e300, 0x1e384,
1055 0x1e3c0, 0x1e3c8,
1056 0x1e440, 0x1e44c,
1057 0x1e640, 0x1e68c,
1058 0x1e6c0, 0x1e6c0,
1059 0x1e6e0, 0x1e6e0,
1060 0x1e700, 0x1e784,
1061 0x1e7c0, 0x1e7c8,
1062 0x1e840, 0x1e84c,
1063 0x1ea40, 0x1ea8c,
1064 0x1eac0, 0x1eac0,
1065 0x1eae0, 0x1eae0,
1066 0x1eb00, 0x1eb84,
1067 0x1ebc0, 0x1ebc8,
1068 0x1ec40, 0x1ec4c,
1069 0x1ee40, 0x1ee8c,
1070 0x1eec0, 0x1eec0,
1071 0x1eee0, 0x1eee0,
1072 0x1ef00, 0x1ef84,
1073 0x1efc0, 0x1efc8,
1074 0x1f040, 0x1f04c,
1075 0x1f240, 0x1f28c,
1076 0x1f2c0, 0x1f2c0,
1077 0x1f2e0, 0x1f2e0,
1078 0x1f300, 0x1f384,
1079 0x1f3c0, 0x1f3c8,
1080 0x1f440, 0x1f44c,
1081 0x1f640, 0x1f68c,
1082 0x1f6c0, 0x1f6c0,
1083 0x1f6e0, 0x1f6e0,
1084 0x1f700, 0x1f784,
1085 0x1f7c0, 0x1f7c8,
1086 0x1f840, 0x1f84c,
1087 0x1fa40, 0x1fa8c,
1088 0x1fac0, 0x1fac0,
1089 0x1fae0, 0x1fae0,
1090 0x1fb00, 0x1fb84,
1091 0x1fbc0, 0x1fbc8,
1092 0x1fc40, 0x1fc4c,
1093 0x1fe40, 0x1fe8c,
1094 0x1fec0, 0x1fec0,
1095 0x1fee0, 0x1fee0,
1096 0x1ff00, 0x1ff84,
1097 0x1ffc0, 0x1ffc8,
1098 0x20000, 0x2002c,
1099 0x20100, 0x2013c,
1100 0x20190, 0x201c8,
1101 0x20200, 0x20318,
1102 0x20400, 0x20528,
1103 0x20540, 0x20614,
1104 0x21000, 0x21040,
1105 0x2104c, 0x21060,
1106 0x210c0, 0x210ec,
1107 0x21200, 0x21268,
1108 0x21270, 0x21284,
1109 0x212fc, 0x21388,
1110 0x21400, 0x21404,
1111 0x21500, 0x21518,
1112 0x2152c, 0x2153c,
1113 0x21550, 0x21554,
1114 0x21600, 0x21600,
1115 0x21608, 0x21628,
1116 0x21630, 0x2163c,
1117 0x21700, 0x2171c,
1118 0x21780, 0x2178c,
1119 0x21800, 0x21c38,
1120 0x21c80, 0x21d7c,
1121 0x21e00, 0x21e04,
1122 0x22000, 0x2202c,
1123 0x22100, 0x2213c,
1124 0x22190, 0x221c8,
1125 0x22200, 0x22318,
1126 0x22400, 0x22528,
1127 0x22540, 0x22614,
1128 0x23000, 0x23040,
1129 0x2304c, 0x23060,
1130 0x230c0, 0x230ec,
1131 0x23200, 0x23268,
1132 0x23270, 0x23284,
1133 0x232fc, 0x23388,
1134 0x23400, 0x23404,
1135 0x23500, 0x23518,
1136 0x2352c, 0x2353c,
1137 0x23550, 0x23554,
1138 0x23600, 0x23600,
1139 0x23608, 0x23628,
1140 0x23630, 0x2363c,
1141 0x23700, 0x2371c,
1142 0x23780, 0x2378c,
1143 0x23800, 0x23c38,
1144 0x23c80, 0x23d7c,
1145 0x23e00, 0x23e04,
1146 0x24000, 0x2402c,
1147 0x24100, 0x2413c,
1148 0x24190, 0x241c8,
1149 0x24200, 0x24318,
1150 0x24400, 0x24528,
1151 0x24540, 0x24614,
1152 0x25000, 0x25040,
1153 0x2504c, 0x25060,
1154 0x250c0, 0x250ec,
1155 0x25200, 0x25268,
1156 0x25270, 0x25284,
1157 0x252fc, 0x25388,
1158 0x25400, 0x25404,
1159 0x25500, 0x25518,
1160 0x2552c, 0x2553c,
1161 0x25550, 0x25554,
1162 0x25600, 0x25600,
1163 0x25608, 0x25628,
1164 0x25630, 0x2563c,
1165 0x25700, 0x2571c,
1166 0x25780, 0x2578c,
1167 0x25800, 0x25c38,
1168 0x25c80, 0x25d7c,
1169 0x25e00, 0x25e04,
1170 0x26000, 0x2602c,
1171 0x26100, 0x2613c,
1172 0x26190, 0x261c8,
1173 0x26200, 0x26318,
1174 0x26400, 0x26528,
1175 0x26540, 0x26614,
1176 0x27000, 0x27040,
1177 0x2704c, 0x27060,
1178 0x270c0, 0x270ec,
1179 0x27200, 0x27268,
1180 0x27270, 0x27284,
1181 0x272fc, 0x27388,
1182 0x27400, 0x27404,
1183 0x27500, 0x27518,
1184 0x2752c, 0x2753c,
1185 0x27550, 0x27554,
1186 0x27600, 0x27600,
1187 0x27608, 0x27628,
1188 0x27630, 0x2763c,
1189 0x27700, 0x2771c,
1190 0x27780, 0x2778c,
1191 0x27800, 0x27c38,
1192 0x27c80, 0x27d7c,
1193 0x27e00, 0x27e04
1194 };
1195
1196 int i;
1197 struct adapter *ap = netdev2adap(dev);
1198
1199 regs->version = mk_adap_vers(ap);
1200
1201 memset(buf, 0, T4_REGMAP_SIZE);
1202 for (i = 0; i < ARRAY_SIZE(reg_ranges); i += 2)
1203 reg_block_dump(ap, buf, reg_ranges[i], reg_ranges[i + 1]);
1204}
1205
1206static int restart_autoneg(struct net_device *dev)
1207{
1208 struct port_info *p = netdev_priv(dev);
1209
1210 if (!netif_running(dev))
1211 return -EAGAIN;
1212 if (p->link_cfg.autoneg != AUTONEG_ENABLE)
1213 return -EINVAL;
1214 t4_restart_aneg(p->adapter, 0, p->tx_chan);
1215 return 0;
1216}
1217
1218static int identify_port(struct net_device *dev, u32 data)
1219{
1220 if (data == 0)
1221 data = 2; /* default to 2 seconds */
1222
1223 return t4_identify_port(netdev2adap(dev), 0, netdev2pinfo(dev)->viid,
1224 data * 5);
1225}
1226
1227static unsigned int from_fw_linkcaps(unsigned int type, unsigned int caps)
1228{
1229 unsigned int v = 0;
1230
1231 if (type == FW_PORT_TYPE_BT_SGMII || type == FW_PORT_TYPE_BT_XAUI) {
1232 v |= SUPPORTED_TP;
1233 if (caps & FW_PORT_CAP_SPEED_100M)
1234 v |= SUPPORTED_100baseT_Full;
1235 if (caps & FW_PORT_CAP_SPEED_1G)
1236 v |= SUPPORTED_1000baseT_Full;
1237 if (caps & FW_PORT_CAP_SPEED_10G)
1238 v |= SUPPORTED_10000baseT_Full;
1239 } else if (type == FW_PORT_TYPE_KX4 || type == FW_PORT_TYPE_KX) {
1240 v |= SUPPORTED_Backplane;
1241 if (caps & FW_PORT_CAP_SPEED_1G)
1242 v |= SUPPORTED_1000baseKX_Full;
1243 if (caps & FW_PORT_CAP_SPEED_10G)
1244 v |= SUPPORTED_10000baseKX4_Full;
1245 } else if (type == FW_PORT_TYPE_KR)
1246 v |= SUPPORTED_Backplane | SUPPORTED_10000baseKR_Full;
1247 else if (type == FW_PORT_TYPE_FIBER)
1248 v |= SUPPORTED_FIBRE;
1249
1250 if (caps & FW_PORT_CAP_ANEG)
1251 v |= SUPPORTED_Autoneg;
1252 return v;
1253}
1254
1255static unsigned int to_fw_linkcaps(unsigned int caps)
1256{
1257 unsigned int v = 0;
1258
1259 if (caps & ADVERTISED_100baseT_Full)
1260 v |= FW_PORT_CAP_SPEED_100M;
1261 if (caps & ADVERTISED_1000baseT_Full)
1262 v |= FW_PORT_CAP_SPEED_1G;
1263 if (caps & ADVERTISED_10000baseT_Full)
1264 v |= FW_PORT_CAP_SPEED_10G;
1265 return v;
1266}
1267
1268static int get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
1269{
1270 const struct port_info *p = netdev_priv(dev);
1271
1272 if (p->port_type == FW_PORT_TYPE_BT_SGMII ||
1273 p->port_type == FW_PORT_TYPE_BT_XAUI)
1274 cmd->port = PORT_TP;
1275 else if (p->port_type == FW_PORT_TYPE_FIBER)
1276 cmd->port = PORT_FIBRE;
1277 else if (p->port_type == FW_PORT_TYPE_TWINAX)
1278 cmd->port = PORT_DA;
1279 else
1280 cmd->port = PORT_OTHER;
1281
1282 if (p->mdio_addr >= 0) {
1283 cmd->phy_address = p->mdio_addr;
1284 cmd->transceiver = XCVR_EXTERNAL;
1285 cmd->mdio_support = p->port_type == FW_PORT_TYPE_BT_SGMII ?
1286 MDIO_SUPPORTS_C22 : MDIO_SUPPORTS_C45;
1287 } else {
1288 cmd->phy_address = 0; /* not really, but no better option */
1289 cmd->transceiver = XCVR_INTERNAL;
1290 cmd->mdio_support = 0;
1291 }
1292
1293 cmd->supported = from_fw_linkcaps(p->port_type, p->link_cfg.supported);
1294 cmd->advertising = from_fw_linkcaps(p->port_type,
1295 p->link_cfg.advertising);
1296 cmd->speed = netif_carrier_ok(dev) ? p->link_cfg.speed : 0;
1297 cmd->duplex = DUPLEX_FULL;
1298 cmd->autoneg = p->link_cfg.autoneg;
1299 cmd->maxtxpkt = 0;
1300 cmd->maxrxpkt = 0;
1301 return 0;
1302}
1303
1304static unsigned int speed_to_caps(int speed)
1305{
1306 if (speed == SPEED_100)
1307 return FW_PORT_CAP_SPEED_100M;
1308 if (speed == SPEED_1000)
1309 return FW_PORT_CAP_SPEED_1G;
1310 if (speed == SPEED_10000)
1311 return FW_PORT_CAP_SPEED_10G;
1312 return 0;
1313}
1314
1315static int set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
1316{
1317 unsigned int cap;
1318 struct port_info *p = netdev_priv(dev);
1319 struct link_config *lc = &p->link_cfg;
1320
1321 if (cmd->duplex != DUPLEX_FULL) /* only full-duplex supported */
1322 return -EINVAL;
1323
1324 if (!(lc->supported & FW_PORT_CAP_ANEG)) {
1325 /*
1326 * PHY offers a single speed. See if that's what's
1327 * being requested.
1328 */
1329 if (cmd->autoneg == AUTONEG_DISABLE &&
1330 (lc->supported & speed_to_caps(cmd->speed)))
1331 return 0;
1332 return -EINVAL;
1333 }
1334
1335 if (cmd->autoneg == AUTONEG_DISABLE) {
1336 cap = speed_to_caps(cmd->speed);
1337
1338 if (!(lc->supported & cap) || cmd->speed == SPEED_1000 ||
1339 cmd->speed == SPEED_10000)
1340 return -EINVAL;
1341 lc->requested_speed = cap;
1342 lc->advertising = 0;
1343 } else {
1344 cap = to_fw_linkcaps(cmd->advertising);
1345 if (!(lc->supported & cap))
1346 return -EINVAL;
1347 lc->requested_speed = 0;
1348 lc->advertising = cap | FW_PORT_CAP_ANEG;
1349 }
1350 lc->autoneg = cmd->autoneg;
1351
1352 if (netif_running(dev))
1353 return t4_link_start(p->adapter, 0, p->tx_chan, lc);
1354 return 0;
1355}
1356
1357static void get_pauseparam(struct net_device *dev,
1358 struct ethtool_pauseparam *epause)
1359{
1360 struct port_info *p = netdev_priv(dev);
1361
1362 epause->autoneg = (p->link_cfg.requested_fc & PAUSE_AUTONEG) != 0;
1363 epause->rx_pause = (p->link_cfg.fc & PAUSE_RX) != 0;
1364 epause->tx_pause = (p->link_cfg.fc & PAUSE_TX) != 0;
1365}
1366
1367static int set_pauseparam(struct net_device *dev,
1368 struct ethtool_pauseparam *epause)
1369{
1370 struct port_info *p = netdev_priv(dev);
1371 struct link_config *lc = &p->link_cfg;
1372
1373 if (epause->autoneg == AUTONEG_DISABLE)
1374 lc->requested_fc = 0;
1375 else if (lc->supported & FW_PORT_CAP_ANEG)
1376 lc->requested_fc = PAUSE_AUTONEG;
1377 else
1378 return -EINVAL;
1379
1380 if (epause->rx_pause)
1381 lc->requested_fc |= PAUSE_RX;
1382 if (epause->tx_pause)
1383 lc->requested_fc |= PAUSE_TX;
1384 if (netif_running(dev))
1385 return t4_link_start(p->adapter, 0, p->tx_chan, lc);
1386 return 0;
1387}
1388
1389static u32 get_rx_csum(struct net_device *dev)
1390{
1391 struct port_info *p = netdev_priv(dev);
1392
1393 return p->rx_offload & RX_CSO;
1394}
1395
1396static int set_rx_csum(struct net_device *dev, u32 data)
1397{
1398 struct port_info *p = netdev_priv(dev);
1399
1400 if (data)
1401 p->rx_offload |= RX_CSO;
1402 else
1403 p->rx_offload &= ~RX_CSO;
1404 return 0;
1405}
1406
1407static void get_sge_param(struct net_device *dev, struct ethtool_ringparam *e)
1408{
1409 const struct port_info *pi = netdev_priv(dev);
1410 const struct sge *s = &pi->adapter->sge;
1411
1412 e->rx_max_pending = MAX_RX_BUFFERS;
1413 e->rx_mini_max_pending = MAX_RSPQ_ENTRIES;
1414 e->rx_jumbo_max_pending = 0;
1415 e->tx_max_pending = MAX_TXQ_ENTRIES;
1416
1417 e->rx_pending = s->ethrxq[pi->first_qset].fl.size - 8;
1418 e->rx_mini_pending = s->ethrxq[pi->first_qset].rspq.size;
1419 e->rx_jumbo_pending = 0;
1420 e->tx_pending = s->ethtxq[pi->first_qset].q.size;
1421}
1422
1423static int set_sge_param(struct net_device *dev, struct ethtool_ringparam *e)
1424{
1425 int i;
1426 const struct port_info *pi = netdev_priv(dev);
1427 struct adapter *adapter = pi->adapter;
1428 struct sge *s = &adapter->sge;
1429
1430 if (e->rx_pending > MAX_RX_BUFFERS || e->rx_jumbo_pending ||
1431 e->tx_pending > MAX_TXQ_ENTRIES ||
1432 e->rx_mini_pending > MAX_RSPQ_ENTRIES ||
1433 e->rx_mini_pending < MIN_RSPQ_ENTRIES ||
1434 e->rx_pending < MIN_FL_ENTRIES || e->tx_pending < MIN_TXQ_ENTRIES)
1435 return -EINVAL;
1436
1437 if (adapter->flags & FULL_INIT_DONE)
1438 return -EBUSY;
1439
1440 for (i = 0; i < pi->nqsets; ++i) {
1441 s->ethtxq[pi->first_qset + i].q.size = e->tx_pending;
1442 s->ethrxq[pi->first_qset + i].fl.size = e->rx_pending + 8;
1443 s->ethrxq[pi->first_qset + i].rspq.size = e->rx_mini_pending;
1444 }
1445 return 0;
1446}
1447
1448static int closest_timer(const struct sge *s, int time)
1449{
1450 int i, delta, match = 0, min_delta = INT_MAX;
1451
1452 for (i = 0; i < ARRAY_SIZE(s->timer_val); i++) {
1453 delta = time - s->timer_val[i];
1454 if (delta < 0)
1455 delta = -delta;
1456 if (delta < min_delta) {
1457 min_delta = delta;
1458 match = i;
1459 }
1460 }
1461 return match;
1462}
1463
1464static int closest_thres(const struct sge *s, int thres)
1465{
1466 int i, delta, match = 0, min_delta = INT_MAX;
1467
1468 for (i = 0; i < ARRAY_SIZE(s->counter_val); i++) {
1469 delta = thres - s->counter_val[i];
1470 if (delta < 0)
1471 delta = -delta;
1472 if (delta < min_delta) {
1473 min_delta = delta;
1474 match = i;
1475 }
1476 }
1477 return match;
1478}
1479
1480/*
1481 * Return a queue's interrupt hold-off time in us. 0 means no timer.
1482 */
1483static unsigned int qtimer_val(const struct adapter *adap,
1484 const struct sge_rspq *q)
1485{
1486 unsigned int idx = q->intr_params >> 1;
1487
1488 return idx < SGE_NTIMERS ? adap->sge.timer_val[idx] : 0;
1489}
1490
1491/**
1492 * set_rxq_intr_params - set a queue's interrupt holdoff parameters
1493 * @adap: the adapter
1494 * @q: the Rx queue
1495 * @us: the hold-off time in us, or 0 to disable timer
1496 * @cnt: the hold-off packet count, or 0 to disable counter
1497 *
1498 * Sets an Rx queue's interrupt hold-off time and packet count. At least
1499 * one of the two needs to be enabled for the queue to generate interrupts.
1500 */
1501static int set_rxq_intr_params(struct adapter *adap, struct sge_rspq *q,
1502 unsigned int us, unsigned int cnt)
1503{
1504 if ((us | cnt) == 0)
1505 cnt = 1;
1506
1507 if (cnt) {
1508 int err;
1509 u32 v, new_idx;
1510
1511 new_idx = closest_thres(&adap->sge, cnt);
1512 if (q->desc && q->pktcnt_idx != new_idx) {
1513 /* the queue has already been created, update it */
1514 v = FW_PARAMS_MNEM(FW_PARAMS_MNEM_DMAQ) |
1515 FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DMAQ_IQ_INTCNTTHRESH) |
1516 FW_PARAMS_PARAM_YZ(q->cntxt_id);
1517 err = t4_set_params(adap, 0, 0, 0, 1, &v, &new_idx);
1518 if (err)
1519 return err;
1520 }
1521 q->pktcnt_idx = new_idx;
1522 }
1523
1524 us = us == 0 ? 6 : closest_timer(&adap->sge, us);
1525 q->intr_params = QINTR_TIMER_IDX(us) | (cnt > 0 ? QINTR_CNT_EN : 0);
1526 return 0;
1527}
1528
1529static int set_coalesce(struct net_device *dev, struct ethtool_coalesce *c)
1530{
1531 const struct port_info *pi = netdev_priv(dev);
1532 struct adapter *adap = pi->adapter;
1533
1534 return set_rxq_intr_params(adap, &adap->sge.ethrxq[pi->first_qset].rspq,
1535 c->rx_coalesce_usecs, c->rx_max_coalesced_frames);
1536}
1537
1538static int get_coalesce(struct net_device *dev, struct ethtool_coalesce *c)
1539{
1540 const struct port_info *pi = netdev_priv(dev);
1541 const struct adapter *adap = pi->adapter;
1542 const struct sge_rspq *rq = &adap->sge.ethrxq[pi->first_qset].rspq;
1543
1544 c->rx_coalesce_usecs = qtimer_val(adap, rq);
1545 c->rx_max_coalesced_frames = (rq->intr_params & QINTR_CNT_EN) ?
1546 adap->sge.counter_val[rq->pktcnt_idx] : 0;
1547 return 0;
1548}
1549
1550/*
1551 * Translate a physical EEPROM address to virtual. The first 1K is accessed
1552 * through virtual addresses starting at 31K, the rest is accessed through
1553 * virtual addresses starting at 0. This mapping is correct only for PF0.
1554 */
1555static int eeprom_ptov(unsigned int phys_addr)
1556{
1557 if (phys_addr < 1024)
1558 return phys_addr + (31 << 10);
1559 if (phys_addr < EEPROMSIZE)
1560 return phys_addr - 1024;
1561 return -EINVAL;
1562}
1563
1564/*
1565 * The next two routines implement eeprom read/write from physical addresses.
1566 * The physical->virtual translation is correct only for PF0.
1567 */
1568static int eeprom_rd_phys(struct adapter *adap, unsigned int phys_addr, u32 *v)
1569{
1570 int vaddr = eeprom_ptov(phys_addr);
1571
1572 if (vaddr >= 0)
1573 vaddr = pci_read_vpd(adap->pdev, vaddr, sizeof(u32), v);
1574 return vaddr < 0 ? vaddr : 0;
1575}
1576
1577static int eeprom_wr_phys(struct adapter *adap, unsigned int phys_addr, u32 v)
1578{
1579 int vaddr = eeprom_ptov(phys_addr);
1580
1581 if (vaddr >= 0)
1582 vaddr = pci_write_vpd(adap->pdev, vaddr, sizeof(u32), &v);
1583 return vaddr < 0 ? vaddr : 0;
1584}
1585
1586#define EEPROM_MAGIC 0x38E2F10C
1587
1588static int get_eeprom(struct net_device *dev, struct ethtool_eeprom *e,
1589 u8 *data)
1590{
1591 int i, err = 0;
1592 struct adapter *adapter = netdev2adap(dev);
1593
1594 u8 *buf = kmalloc(EEPROMSIZE, GFP_KERNEL);
1595 if (!buf)
1596 return -ENOMEM;
1597
1598 e->magic = EEPROM_MAGIC;
1599 for (i = e->offset & ~3; !err && i < e->offset + e->len; i += 4)
1600 err = eeprom_rd_phys(adapter, i, (u32 *)&buf[i]);
1601
1602 if (!err)
1603 memcpy(data, buf + e->offset, e->len);
1604 kfree(buf);
1605 return err;
1606}
1607
1608static int set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
1609 u8 *data)
1610{
1611 u8 *buf;
1612 int err = 0;
1613 u32 aligned_offset, aligned_len, *p;
1614 struct adapter *adapter = netdev2adap(dev);
1615
1616 if (eeprom->magic != EEPROM_MAGIC)
1617 return -EINVAL;
1618
1619 aligned_offset = eeprom->offset & ~3;
1620 aligned_len = (eeprom->len + (eeprom->offset & 3) + 3) & ~3;
1621
1622 if (aligned_offset != eeprom->offset || aligned_len != eeprom->len) {
1623 /*
1624 * RMW possibly needed for first or last words.
1625 */
1626 buf = kmalloc(aligned_len, GFP_KERNEL);
1627 if (!buf)
1628 return -ENOMEM;
1629 err = eeprom_rd_phys(adapter, aligned_offset, (u32 *)buf);
1630 if (!err && aligned_len > 4)
1631 err = eeprom_rd_phys(adapter,
1632 aligned_offset + aligned_len - 4,
1633 (u32 *)&buf[aligned_len - 4]);
1634 if (err)
1635 goto out;
1636 memcpy(buf + (eeprom->offset & 3), data, eeprom->len);
1637 } else
1638 buf = data;
1639
1640 err = t4_seeprom_wp(adapter, false);
1641 if (err)
1642 goto out;
1643
1644 for (p = (u32 *)buf; !err && aligned_len; aligned_len -= 4, p++) {
1645 err = eeprom_wr_phys(adapter, aligned_offset, *p);
1646 aligned_offset += 4;
1647 }
1648
1649 if (!err)
1650 err = t4_seeprom_wp(adapter, true);
1651out:
1652 if (buf != data)
1653 kfree(buf);
1654 return err;
1655}
1656
1657static int set_flash(struct net_device *netdev, struct ethtool_flash *ef)
1658{
1659 int ret;
1660 const struct firmware *fw;
1661 struct adapter *adap = netdev2adap(netdev);
1662
1663 ef->data[sizeof(ef->data) - 1] = '\0';
1664 ret = request_firmware(&fw, ef->data, adap->pdev_dev);
1665 if (ret < 0)
1666 return ret;
1667
1668 ret = t4_load_fw(adap, fw->data, fw->size);
1669 release_firmware(fw);
1670 if (!ret)
1671 dev_info(adap->pdev_dev, "loaded firmware %s\n", ef->data);
1672 return ret;
1673}
1674
1675#define WOL_SUPPORTED (WAKE_BCAST | WAKE_MAGIC)
1676#define BCAST_CRC 0xa0ccc1a6
1677
1678static void get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
1679{
1680 wol->supported = WAKE_BCAST | WAKE_MAGIC;
1681 wol->wolopts = netdev2adap(dev)->wol;
1682 memset(&wol->sopass, 0, sizeof(wol->sopass));
1683}
1684
1685static int set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
1686{
1687 int err = 0;
1688 struct port_info *pi = netdev_priv(dev);
1689
1690 if (wol->wolopts & ~WOL_SUPPORTED)
1691 return -EINVAL;
1692 t4_wol_magic_enable(pi->adapter, pi->tx_chan,
1693 (wol->wolopts & WAKE_MAGIC) ? dev->dev_addr : NULL);
1694 if (wol->wolopts & WAKE_BCAST) {
1695 err = t4_wol_pat_enable(pi->adapter, pi->tx_chan, 0xfe, ~0ULL,
1696 ~0ULL, 0, false);
1697 if (!err)
1698 err = t4_wol_pat_enable(pi->adapter, pi->tx_chan, 1,
1699 ~6ULL, ~0ULL, BCAST_CRC, true);
1700 } else
1701 t4_wol_pat_enable(pi->adapter, pi->tx_chan, 0, 0, 0, 0, false);
1702 return err;
1703}
1704
1705static int set_tso(struct net_device *dev, u32 value)
1706{
1707 if (value)
1708 dev->features |= NETIF_F_TSO | NETIF_F_TSO6;
1709 else
1710 dev->features &= ~(NETIF_F_TSO | NETIF_F_TSO6);
1711 return 0;
1712}
1713
1714static struct ethtool_ops cxgb_ethtool_ops = {
1715 .get_settings = get_settings,
1716 .set_settings = set_settings,
1717 .get_drvinfo = get_drvinfo,
1718 .get_msglevel = get_msglevel,
1719 .set_msglevel = set_msglevel,
1720 .get_ringparam = get_sge_param,
1721 .set_ringparam = set_sge_param,
1722 .get_coalesce = get_coalesce,
1723 .set_coalesce = set_coalesce,
1724 .get_eeprom_len = get_eeprom_len,
1725 .get_eeprom = get_eeprom,
1726 .set_eeprom = set_eeprom,
1727 .get_pauseparam = get_pauseparam,
1728 .set_pauseparam = set_pauseparam,
1729 .get_rx_csum = get_rx_csum,
1730 .set_rx_csum = set_rx_csum,
1731 .set_tx_csum = ethtool_op_set_tx_ipv6_csum,
1732 .set_sg = ethtool_op_set_sg,
1733 .get_link = ethtool_op_get_link,
1734 .get_strings = get_strings,
1735 .phys_id = identify_port,
1736 .nway_reset = restart_autoneg,
1737 .get_sset_count = get_sset_count,
1738 .get_ethtool_stats = get_stats,
1739 .get_regs_len = get_regs_len,
1740 .get_regs = get_regs,
1741 .get_wol = get_wol,
1742 .set_wol = set_wol,
1743 .set_tso = set_tso,
1744 .flash_device = set_flash,
1745};
1746
1747/*
1748 * debugfs support
1749 */
1750
1751static int mem_open(struct inode *inode, struct file *file)
1752{
1753 file->private_data = inode->i_private;
1754 return 0;
1755}
1756
1757static ssize_t mem_read(struct file *file, char __user *buf, size_t count,
1758 loff_t *ppos)
1759{
1760 loff_t pos = *ppos;
1761 loff_t avail = file->f_path.dentry->d_inode->i_size;
1762 unsigned int mem = (uintptr_t)file->private_data & 3;
1763 struct adapter *adap = file->private_data - mem;
1764
1765 if (pos < 0)
1766 return -EINVAL;
1767 if (pos >= avail)
1768 return 0;
1769 if (count > avail - pos)
1770 count = avail - pos;
1771
1772 while (count) {
1773 size_t len;
1774 int ret, ofst;
1775 __be32 data[16];
1776
1777 if (mem == MEM_MC)
1778 ret = t4_mc_read(adap, pos, data, NULL);
1779 else
1780 ret = t4_edc_read(adap, mem, pos, data, NULL);
1781 if (ret)
1782 return ret;
1783
1784 ofst = pos % sizeof(data);
1785 len = min(count, sizeof(data) - ofst);
1786 if (copy_to_user(buf, (u8 *)data + ofst, len))
1787 return -EFAULT;
1788
1789 buf += len;
1790 pos += len;
1791 count -= len;
1792 }
1793 count = pos - *ppos;
1794 *ppos = pos;
1795 return count;
1796}
1797
1798static const struct file_operations mem_debugfs_fops = {
1799 .owner = THIS_MODULE,
1800 .open = mem_open,
1801 .read = mem_read,
1802};
1803
1804static void __devinit add_debugfs_mem(struct adapter *adap, const char *name,
1805 unsigned int idx, unsigned int size_mb)
1806{
1807 struct dentry *de;
1808
1809 de = debugfs_create_file(name, S_IRUSR, adap->debugfs_root,
1810 (void *)adap + idx, &mem_debugfs_fops);
1811 if (de && de->d_inode)
1812 de->d_inode->i_size = size_mb << 20;
1813}
1814
1815static int __devinit setup_debugfs(struct adapter *adap)
1816{
1817 int i;
1818
1819 if (IS_ERR_OR_NULL(adap->debugfs_root))
1820 return -1;
1821
1822 i = t4_read_reg(adap, MA_TARGET_MEM_ENABLE);
1823 if (i & EDRAM0_ENABLE)
1824 add_debugfs_mem(adap, "edc0", MEM_EDC0, 5);
1825 if (i & EDRAM1_ENABLE)
1826 add_debugfs_mem(adap, "edc1", MEM_EDC1, 5);
1827 if (i & EXT_MEM_ENABLE)
1828 add_debugfs_mem(adap, "mc", MEM_MC,
1829 EXT_MEM_SIZE_GET(t4_read_reg(adap, MA_EXT_MEMORY_BAR)));
1830 if (adap->l2t)
1831 debugfs_create_file("l2t", S_IRUSR, adap->debugfs_root, adap,
1832 &t4_l2t_fops);
1833 return 0;
1834}
1835
1836/*
1837 * upper-layer driver support
1838 */
1839
1840/*
1841 * Allocate an active-open TID and set it to the supplied value.
1842 */
1843int cxgb4_alloc_atid(struct tid_info *t, void *data)
1844{
1845 int atid = -1;
1846
1847 spin_lock_bh(&t->atid_lock);
1848 if (t->afree) {
1849 union aopen_entry *p = t->afree;
1850
1851 atid = p - t->atid_tab;
1852 t->afree = p->next;
1853 p->data = data;
1854 t->atids_in_use++;
1855 }
1856 spin_unlock_bh(&t->atid_lock);
1857 return atid;
1858}
1859EXPORT_SYMBOL(cxgb4_alloc_atid);
1860
1861/*
1862 * Release an active-open TID.
1863 */
1864void cxgb4_free_atid(struct tid_info *t, unsigned int atid)
1865{
1866 union aopen_entry *p = &t->atid_tab[atid];
1867
1868 spin_lock_bh(&t->atid_lock);
1869 p->next = t->afree;
1870 t->afree = p;
1871 t->atids_in_use--;
1872 spin_unlock_bh(&t->atid_lock);
1873}
1874EXPORT_SYMBOL(cxgb4_free_atid);
1875
1876/*
1877 * Allocate a server TID and set it to the supplied value.
1878 */
1879int cxgb4_alloc_stid(struct tid_info *t, int family, void *data)
1880{
1881 int stid;
1882
1883 spin_lock_bh(&t->stid_lock);
1884 if (family == PF_INET) {
1885 stid = find_first_zero_bit(t->stid_bmap, t->nstids);
1886 if (stid < t->nstids)
1887 __set_bit(stid, t->stid_bmap);
1888 else
1889 stid = -1;
1890 } else {
1891 stid = bitmap_find_free_region(t->stid_bmap, t->nstids, 2);
1892 if (stid < 0)
1893 stid = -1;
1894 }
1895 if (stid >= 0) {
1896 t->stid_tab[stid].data = data;
1897 stid += t->stid_base;
1898 t->stids_in_use++;
1899 }
1900 spin_unlock_bh(&t->stid_lock);
1901 return stid;
1902}
1903EXPORT_SYMBOL(cxgb4_alloc_stid);
1904
1905/*
1906 * Release a server TID.
1907 */
1908void cxgb4_free_stid(struct tid_info *t, unsigned int stid, int family)
1909{
1910 stid -= t->stid_base;
1911 spin_lock_bh(&t->stid_lock);
1912 if (family == PF_INET)
1913 __clear_bit(stid, t->stid_bmap);
1914 else
1915 bitmap_release_region(t->stid_bmap, stid, 2);
1916 t->stid_tab[stid].data = NULL;
1917 t->stids_in_use--;
1918 spin_unlock_bh(&t->stid_lock);
1919}
1920EXPORT_SYMBOL(cxgb4_free_stid);
1921
1922/*
1923 * Populate a TID_RELEASE WR. Caller must properly size the skb.
1924 */
1925static void mk_tid_release(struct sk_buff *skb, unsigned int chan,
1926 unsigned int tid)
1927{
1928 struct cpl_tid_release *req;
1929
1930 set_wr_txq(skb, CPL_PRIORITY_SETUP, chan);
1931 req = (struct cpl_tid_release *)__skb_put(skb, sizeof(*req));
1932 INIT_TP_WR(req, tid);
1933 OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_TID_RELEASE, tid));
1934}
1935
1936/*
1937 * Queue a TID release request and if necessary schedule a work queue to
1938 * process it.
1939 */
1940void cxgb4_queue_tid_release(struct tid_info *t, unsigned int chan,
1941 unsigned int tid)
1942{
1943 void **p = &t->tid_tab[tid];
1944 struct adapter *adap = container_of(t, struct adapter, tids);
1945
1946 spin_lock_bh(&adap->tid_release_lock);
1947 *p = adap->tid_release_head;
1948 /* Low 2 bits encode the Tx channel number */
1949 adap->tid_release_head = (void **)((uintptr_t)p | chan);
1950 if (!adap->tid_release_task_busy) {
1951 adap->tid_release_task_busy = true;
1952 schedule_work(&adap->tid_release_task);
1953 }
1954 spin_unlock_bh(&adap->tid_release_lock);
1955}
1956EXPORT_SYMBOL(cxgb4_queue_tid_release);
1957
1958/*
1959 * Process the list of pending TID release requests.
1960 */
1961static void process_tid_release_list(struct work_struct *work)
1962{
1963 struct sk_buff *skb;
1964 struct adapter *adap;
1965
1966 adap = container_of(work, struct adapter, tid_release_task);
1967
1968 spin_lock_bh(&adap->tid_release_lock);
1969 while (adap->tid_release_head) {
1970 void **p = adap->tid_release_head;
1971 unsigned int chan = (uintptr_t)p & 3;
1972 p = (void *)p - chan;
1973
1974 adap->tid_release_head = *p;
1975 *p = NULL;
1976 spin_unlock_bh(&adap->tid_release_lock);
1977
1978 while (!(skb = alloc_skb(sizeof(struct cpl_tid_release),
1979 GFP_KERNEL)))
1980 schedule_timeout_uninterruptible(1);
1981
1982 mk_tid_release(skb, chan, p - adap->tids.tid_tab);
1983 t4_ofld_send(adap, skb);
1984 spin_lock_bh(&adap->tid_release_lock);
1985 }
1986 adap->tid_release_task_busy = false;
1987 spin_unlock_bh(&adap->tid_release_lock);
1988}
1989
1990/*
1991 * Release a TID and inform HW. If we are unable to allocate the release
1992 * message we defer to a work queue.
1993 */
1994void cxgb4_remove_tid(struct tid_info *t, unsigned int chan, unsigned int tid)
1995{
1996 void *old;
1997 struct sk_buff *skb;
1998 struct adapter *adap = container_of(t, struct adapter, tids);
1999
2000 old = t->tid_tab[tid];
2001 skb = alloc_skb(sizeof(struct cpl_tid_release), GFP_ATOMIC);
2002 if (likely(skb)) {
2003 t->tid_tab[tid] = NULL;
2004 mk_tid_release(skb, chan, tid);
2005 t4_ofld_send(adap, skb);
2006 } else
2007 cxgb4_queue_tid_release(t, chan, tid);
2008 if (old)
2009 atomic_dec(&t->tids_in_use);
2010}
2011EXPORT_SYMBOL(cxgb4_remove_tid);
2012
2013/*
2014 * Allocate and initialize the TID tables. Returns 0 on success.
2015 */
2016static int tid_init(struct tid_info *t)
2017{
2018 size_t size;
2019 unsigned int natids = t->natids;
2020
2021 size = t->ntids * sizeof(*t->tid_tab) + natids * sizeof(*t->atid_tab) +
2022 t->nstids * sizeof(*t->stid_tab) +
2023 BITS_TO_LONGS(t->nstids) * sizeof(long);
2024 t->tid_tab = t4_alloc_mem(size);
2025 if (!t->tid_tab)
2026 return -ENOMEM;
2027
2028 t->atid_tab = (union aopen_entry *)&t->tid_tab[t->ntids];
2029 t->stid_tab = (struct serv_entry *)&t->atid_tab[natids];
2030 t->stid_bmap = (unsigned long *)&t->stid_tab[t->nstids];
2031 spin_lock_init(&t->stid_lock);
2032 spin_lock_init(&t->atid_lock);
2033
2034 t->stids_in_use = 0;
2035 t->afree = NULL;
2036 t->atids_in_use = 0;
2037 atomic_set(&t->tids_in_use, 0);
2038
2039 /* Setup the free list for atid_tab and clear the stid bitmap. */
2040 if (natids) {
2041 while (--natids)
2042 t->atid_tab[natids - 1].next = &t->atid_tab[natids];
2043 t->afree = t->atid_tab;
2044 }
2045 bitmap_zero(t->stid_bmap, t->nstids);
2046 return 0;
2047}
2048
2049/**
2050 * cxgb4_create_server - create an IP server
2051 * @dev: the device
2052 * @stid: the server TID
2053 * @sip: local IP address to bind server to
2054 * @sport: the server's TCP port
2055 * @queue: queue to direct messages from this server to
2056 *
2057 * Create an IP server for the given port and address.
2058 * Returns <0 on error and one of the %NET_XMIT_* values on success.
2059 */
2060int cxgb4_create_server(const struct net_device *dev, unsigned int stid,
2061 __be32 sip, __be16 sport, unsigned int queue)
2062{
2063 unsigned int chan;
2064 struct sk_buff *skb;
2065 struct adapter *adap;
2066 struct cpl_pass_open_req *req;
2067
2068 skb = alloc_skb(sizeof(*req), GFP_KERNEL);
2069 if (!skb)
2070 return -ENOMEM;
2071
2072 adap = netdev2adap(dev);
2073 req = (struct cpl_pass_open_req *)__skb_put(skb, sizeof(*req));
2074 INIT_TP_WR(req, 0);
2075 OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_PASS_OPEN_REQ, stid));
2076 req->local_port = sport;
2077 req->peer_port = htons(0);
2078 req->local_ip = sip;
2079 req->peer_ip = htonl(0);
2080 chan = netdev2pinfo(adap->sge.ingr_map[queue]->netdev)->tx_chan;
2081 req->opt0 = cpu_to_be64(TX_CHAN(chan));
2082 req->opt1 = cpu_to_be64(CONN_POLICY_ASK |
2083 SYN_RSS_ENABLE | SYN_RSS_QUEUE(queue));
2084 return t4_mgmt_tx(adap, skb);
2085}
2086EXPORT_SYMBOL(cxgb4_create_server);
2087
2088/**
2089 * cxgb4_create_server6 - create an IPv6 server
2090 * @dev: the device
2091 * @stid: the server TID
2092 * @sip: local IPv6 address to bind server to
2093 * @sport: the server's TCP port
2094 * @queue: queue to direct messages from this server to
2095 *
2096 * Create an IPv6 server for the given port and address.
2097 * Returns <0 on error and one of the %NET_XMIT_* values on success.
2098 */
2099int cxgb4_create_server6(const struct net_device *dev, unsigned int stid,
2100 const struct in6_addr *sip, __be16 sport,
2101 unsigned int queue)
2102{
2103 unsigned int chan;
2104 struct sk_buff *skb;
2105 struct adapter *adap;
2106 struct cpl_pass_open_req6 *req;
2107
2108 skb = alloc_skb(sizeof(*req), GFP_KERNEL);
2109 if (!skb)
2110 return -ENOMEM;
2111
2112 adap = netdev2adap(dev);
2113 req = (struct cpl_pass_open_req6 *)__skb_put(skb, sizeof(*req));
2114 INIT_TP_WR(req, 0);
2115 OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_PASS_OPEN_REQ6, stid));
2116 req->local_port = sport;
2117 req->peer_port = htons(0);
2118 req->local_ip_hi = *(__be64 *)(sip->s6_addr);
2119 req->local_ip_lo = *(__be64 *)(sip->s6_addr + 8);
2120 req->peer_ip_hi = cpu_to_be64(0);
2121 req->peer_ip_lo = cpu_to_be64(0);
2122 chan = netdev2pinfo(adap->sge.ingr_map[queue]->netdev)->tx_chan;
2123 req->opt0 = cpu_to_be64(TX_CHAN(chan));
2124 req->opt1 = cpu_to_be64(CONN_POLICY_ASK |
2125 SYN_RSS_ENABLE | SYN_RSS_QUEUE(queue));
2126 return t4_mgmt_tx(adap, skb);
2127}
2128EXPORT_SYMBOL(cxgb4_create_server6);
2129
2130/**
2131 * cxgb4_best_mtu - find the entry in the MTU table closest to an MTU
2132 * @mtus: the HW MTU table
2133 * @mtu: the target MTU
2134 * @idx: index of selected entry in the MTU table
2135 *
2136 * Returns the index and the value in the HW MTU table that is closest to
2137 * but does not exceed @mtu, unless @mtu is smaller than any value in the
2138 * table, in which case that smallest available value is selected.
2139 */
2140unsigned int cxgb4_best_mtu(const unsigned short *mtus, unsigned short mtu,
2141 unsigned int *idx)
2142{
2143 unsigned int i = 0;
2144
2145 while (i < NMTUS - 1 && mtus[i + 1] <= mtu)
2146 ++i;
2147 if (idx)
2148 *idx = i;
2149 return mtus[i];
2150}
2151EXPORT_SYMBOL(cxgb4_best_mtu);
2152
2153/**
2154 * cxgb4_port_chan - get the HW channel of a port
2155 * @dev: the net device for the port
2156 *
2157 * Return the HW Tx channel of the given port.
2158 */
2159unsigned int cxgb4_port_chan(const struct net_device *dev)
2160{
2161 return netdev2pinfo(dev)->tx_chan;
2162}
2163EXPORT_SYMBOL(cxgb4_port_chan);
2164
2165/**
2166 * cxgb4_port_viid - get the VI id of a port
2167 * @dev: the net device for the port
2168 *
2169 * Return the VI id of the given port.
2170 */
2171unsigned int cxgb4_port_viid(const struct net_device *dev)
2172{
2173 return netdev2pinfo(dev)->viid;
2174}
2175EXPORT_SYMBOL(cxgb4_port_viid);
2176
2177/**
2178 * cxgb4_port_idx - get the index of a port
2179 * @dev: the net device for the port
2180 *
2181 * Return the index of the given port.
2182 */
2183unsigned int cxgb4_port_idx(const struct net_device *dev)
2184{
2185 return netdev2pinfo(dev)->port_id;
2186}
2187EXPORT_SYMBOL(cxgb4_port_idx);
2188
2189/**
2190 * cxgb4_netdev_by_hwid - return the net device of a HW port
2191 * @pdev: identifies the adapter
2192 * @id: the HW port id
2193 *
2194 * Return the net device associated with the interface with the given HW
2195 * id.
2196 */
2197struct net_device *cxgb4_netdev_by_hwid(struct pci_dev *pdev, unsigned int id)
2198{
2199 const struct adapter *adap = pci_get_drvdata(pdev);
2200
2201 if (!adap || id >= NCHAN)
2202 return NULL;
2203 id = adap->chan_map[id];
2204 return id < MAX_NPORTS ? adap->port[id] : NULL;
2205}
2206EXPORT_SYMBOL(cxgb4_netdev_by_hwid);
2207
2208void cxgb4_get_tcp_stats(struct pci_dev *pdev, struct tp_tcp_stats *v4,
2209 struct tp_tcp_stats *v6)
2210{
2211 struct adapter *adap = pci_get_drvdata(pdev);
2212
2213 spin_lock(&adap->stats_lock);
2214 t4_tp_get_tcp_stats(adap, v4, v6);
2215 spin_unlock(&adap->stats_lock);
2216}
2217EXPORT_SYMBOL(cxgb4_get_tcp_stats);
2218
2219void cxgb4_iscsi_init(struct net_device *dev, unsigned int tag_mask,
2220 const unsigned int *pgsz_order)
2221{
2222 struct adapter *adap = netdev2adap(dev);
2223
2224 t4_write_reg(adap, ULP_RX_ISCSI_TAGMASK, tag_mask);
2225 t4_write_reg(adap, ULP_RX_ISCSI_PSZ, HPZ0(pgsz_order[0]) |
2226 HPZ1(pgsz_order[1]) | HPZ2(pgsz_order[2]) |
2227 HPZ3(pgsz_order[3]));
2228}
2229EXPORT_SYMBOL(cxgb4_iscsi_init);
2230
2231static struct pci_driver cxgb4_driver;
2232
2233static void check_neigh_update(struct neighbour *neigh)
2234{
2235 const struct device *parent;
2236 const struct net_device *netdev = neigh->dev;
2237
2238 if (netdev->priv_flags & IFF_802_1Q_VLAN)
2239 netdev = vlan_dev_real_dev(netdev);
2240 parent = netdev->dev.parent;
2241 if (parent && parent->driver == &cxgb4_driver.driver)
2242 t4_l2t_update(dev_get_drvdata(parent), neigh);
2243}
2244
2245static int netevent_cb(struct notifier_block *nb, unsigned long event,
2246 void *data)
2247{
2248 switch (event) {
2249 case NETEVENT_NEIGH_UPDATE:
2250 check_neigh_update(data);
2251 break;
2252 case NETEVENT_PMTU_UPDATE:
2253 case NETEVENT_REDIRECT:
2254 default:
2255 break;
2256 }
2257 return 0;
2258}
2259
2260static bool netevent_registered;
2261static struct notifier_block cxgb4_netevent_nb = {
2262 .notifier_call = netevent_cb
2263};
2264
2265static void uld_attach(struct adapter *adap, unsigned int uld)
2266{
2267 void *handle;
2268 struct cxgb4_lld_info lli;
2269
2270 lli.pdev = adap->pdev;
2271 lli.l2t = adap->l2t;
2272 lli.tids = &adap->tids;
2273 lli.ports = adap->port;
2274 lli.vr = &adap->vres;
2275 lli.mtus = adap->params.mtus;
2276 if (uld == CXGB4_ULD_RDMA) {
2277 lli.rxq_ids = adap->sge.rdma_rxq;
2278 lli.nrxq = adap->sge.rdmaqs;
2279 } else if (uld == CXGB4_ULD_ISCSI) {
2280 lli.rxq_ids = adap->sge.ofld_rxq;
2281 lli.nrxq = adap->sge.ofldqsets;
2282 }
2283 lli.ntxq = adap->sge.ofldqsets;
2284 lli.nchan = adap->params.nports;
2285 lli.nports = adap->params.nports;
2286 lli.wr_cred = adap->params.ofldq_wr_cred;
2287 lli.adapter_type = adap->params.rev;
2288 lli.iscsi_iolen = MAXRXDATA_GET(t4_read_reg(adap, TP_PARA_REG2));
2289 lli.udb_density = 1 << QUEUESPERPAGEPF0_GET(
2290 t4_read_reg(adap, SGE_EGRESS_QUEUES_PER_PAGE_PF));
2291 lli.ucq_density = 1 << QUEUESPERPAGEPF0_GET(
2292 t4_read_reg(adap, SGE_INGRESS_QUEUES_PER_PAGE_PF));
2293 lli.gts_reg = adap->regs + MYPF_REG(SGE_PF_GTS);
2294 lli.db_reg = adap->regs + MYPF_REG(SGE_PF_KDOORBELL);
2295 lli.fw_vers = adap->params.fw_vers;
2296
2297 handle = ulds[uld].add(&lli);
2298 if (IS_ERR(handle)) {
2299 dev_warn(adap->pdev_dev,
2300 "could not attach to the %s driver, error %ld\n",
2301 uld_str[uld], PTR_ERR(handle));
2302 return;
2303 }
2304
2305 adap->uld_handle[uld] = handle;
2306
2307 if (!netevent_registered) {
2308 register_netevent_notifier(&cxgb4_netevent_nb);
2309 netevent_registered = true;
2310 }
2311}
2312
2313static void attach_ulds(struct adapter *adap)
2314{
2315 unsigned int i;
2316
2317 mutex_lock(&uld_mutex);
2318 list_add_tail(&adap->list_node, &adapter_list);
2319 for (i = 0; i < CXGB4_ULD_MAX; i++)
2320 if (ulds[i].add)
2321 uld_attach(adap, i);
2322 mutex_unlock(&uld_mutex);
2323}
2324
2325static void detach_ulds(struct adapter *adap)
2326{
2327 unsigned int i;
2328
2329 mutex_lock(&uld_mutex);
2330 list_del(&adap->list_node);
2331 for (i = 0; i < CXGB4_ULD_MAX; i++)
2332 if (adap->uld_handle[i]) {
2333 ulds[i].state_change(adap->uld_handle[i],
2334 CXGB4_STATE_DETACH);
2335 adap->uld_handle[i] = NULL;
2336 }
2337 if (netevent_registered && list_empty(&adapter_list)) {
2338 unregister_netevent_notifier(&cxgb4_netevent_nb);
2339 netevent_registered = false;
2340 }
2341 mutex_unlock(&uld_mutex);
2342}
2343
2344static void notify_ulds(struct adapter *adap, enum cxgb4_state new_state)
2345{
2346 unsigned int i;
2347
2348 mutex_lock(&uld_mutex);
2349 for (i = 0; i < CXGB4_ULD_MAX; i++)
2350 if (adap->uld_handle[i])
2351 ulds[i].state_change(adap->uld_handle[i], new_state);
2352 mutex_unlock(&uld_mutex);
2353}
2354
2355/**
2356 * cxgb4_register_uld - register an upper-layer driver
2357 * @type: the ULD type
2358 * @p: the ULD methods
2359 *
2360 * Registers an upper-layer driver with this driver and notifies the ULD
2361 * about any presently available devices that support its type. Returns
2362 * %-EBUSY if a ULD of the same type is already registered.
2363 */
2364int cxgb4_register_uld(enum cxgb4_uld type, const struct cxgb4_uld_info *p)
2365{
2366 int ret = 0;
2367 struct adapter *adap;
2368
2369 if (type >= CXGB4_ULD_MAX)
2370 return -EINVAL;
2371 mutex_lock(&uld_mutex);
2372 if (ulds[type].add) {
2373 ret = -EBUSY;
2374 goto out;
2375 }
2376 ulds[type] = *p;
2377 list_for_each_entry(adap, &adapter_list, list_node)
2378 uld_attach(adap, type);
2379out: mutex_unlock(&uld_mutex);
2380 return ret;
2381}
2382EXPORT_SYMBOL(cxgb4_register_uld);
2383
2384/**
2385 * cxgb4_unregister_uld - unregister an upper-layer driver
2386 * @type: the ULD type
2387 *
2388 * Unregisters an existing upper-layer driver.
2389 */
2390int cxgb4_unregister_uld(enum cxgb4_uld type)
2391{
2392 struct adapter *adap;
2393
2394 if (type >= CXGB4_ULD_MAX)
2395 return -EINVAL;
2396 mutex_lock(&uld_mutex);
2397 list_for_each_entry(adap, &adapter_list, list_node)
2398 adap->uld_handle[type] = NULL;
2399 ulds[type].add = NULL;
2400 mutex_unlock(&uld_mutex);
2401 return 0;
2402}
2403EXPORT_SYMBOL(cxgb4_unregister_uld);
2404
2405/**
2406 * cxgb_up - enable the adapter
2407 * @adap: adapter being enabled
2408 *
2409 * Called when the first port is enabled, this function performs the
2410 * actions necessary to make an adapter operational, such as completing
2411 * the initialization of HW modules, and enabling interrupts.
2412 *
2413 * Must be called with the rtnl lock held.
2414 */
2415static int cxgb_up(struct adapter *adap)
2416{
2417 int err = 0;
2418
2419 if (!(adap->flags & FULL_INIT_DONE)) {
2420 err = setup_sge_queues(adap);
2421 if (err)
2422 goto out;
2423 err = setup_rss(adap);
2424 if (err) {
2425 t4_free_sge_resources(adap);
2426 goto out;
2427 }
2428 if (adap->flags & USING_MSIX)
2429 name_msix_vecs(adap);
2430 adap->flags |= FULL_INIT_DONE;
2431 }
2432
2433 if (adap->flags & USING_MSIX) {
2434 err = request_irq(adap->msix_info[0].vec, t4_nondata_intr, 0,
2435 adap->msix_info[0].desc, adap);
2436 if (err)
2437 goto irq_err;
2438
2439 err = request_msix_queue_irqs(adap);
2440 if (err) {
2441 free_irq(adap->msix_info[0].vec, adap);
2442 goto irq_err;
2443 }
2444 } else {
2445 err = request_irq(adap->pdev->irq, t4_intr_handler(adap),
2446 (adap->flags & USING_MSI) ? 0 : IRQF_SHARED,
2447 adap->name, adap);
2448 if (err)
2449 goto irq_err;
2450 }
2451 enable_rx(adap);
2452 t4_sge_start(adap);
2453 t4_intr_enable(adap);
2454 notify_ulds(adap, CXGB4_STATE_UP);
2455 out:
2456 return err;
2457 irq_err:
2458 dev_err(adap->pdev_dev, "request_irq failed, err %d\n", err);
2459 goto out;
2460}
2461
2462static void cxgb_down(struct adapter *adapter)
2463{
2464 t4_intr_disable(adapter);
2465 cancel_work_sync(&adapter->tid_release_task);
2466 adapter->tid_release_task_busy = false;
2467
2468 if (adapter->flags & USING_MSIX) {
2469 free_msix_queue_irqs(adapter);
2470 free_irq(adapter->msix_info[0].vec, adapter);
2471 } else
2472 free_irq(adapter->pdev->irq, adapter);
2473 quiesce_rx(adapter);
2474}
2475
2476/*
2477 * net_device operations
2478 */
2479static int cxgb_open(struct net_device *dev)
2480{
2481 int err;
2482 struct port_info *pi = netdev_priv(dev);
2483 struct adapter *adapter = pi->adapter;
2484
2485 if (!adapter->open_device_map && (err = cxgb_up(adapter)) < 0)
2486 return err;
2487
2488 dev->real_num_tx_queues = pi->nqsets;
2489 set_bit(pi->tx_chan, &adapter->open_device_map);
2490 link_start(dev);
2491 netif_tx_start_all_queues(dev);
2492 return 0;
2493}
2494
2495static int cxgb_close(struct net_device *dev)
2496{
2497 int ret;
2498 struct port_info *pi = netdev_priv(dev);
2499 struct adapter *adapter = pi->adapter;
2500
2501 netif_tx_stop_all_queues(dev);
2502 netif_carrier_off(dev);
2503 ret = t4_enable_vi(adapter, 0, pi->viid, false, false);
2504
2505 clear_bit(pi->tx_chan, &adapter->open_device_map);
2506
2507 if (!adapter->open_device_map)
2508 cxgb_down(adapter);
2509 return 0;
2510}
2511
2512static struct net_device_stats *cxgb_get_stats(struct net_device *dev)
2513{
2514 struct port_stats stats;
2515 struct port_info *p = netdev_priv(dev);
2516 struct adapter *adapter = p->adapter;
2517 struct net_device_stats *ns = &dev->stats;
2518
2519 spin_lock(&adapter->stats_lock);
2520 t4_get_port_stats(adapter, p->tx_chan, &stats);
2521 spin_unlock(&adapter->stats_lock);
2522
2523 ns->tx_bytes = stats.tx_octets;
2524 ns->tx_packets = stats.tx_frames;
2525 ns->rx_bytes = stats.rx_octets;
2526 ns->rx_packets = stats.rx_frames;
2527 ns->multicast = stats.rx_mcast_frames;
2528
2529 /* detailed rx_errors */
2530 ns->rx_length_errors = stats.rx_jabber + stats.rx_too_long +
2531 stats.rx_runt;
2532 ns->rx_over_errors = 0;
2533 ns->rx_crc_errors = stats.rx_fcs_err;
2534 ns->rx_frame_errors = stats.rx_symbol_err;
2535 ns->rx_fifo_errors = stats.rx_ovflow0 + stats.rx_ovflow1 +
2536 stats.rx_ovflow2 + stats.rx_ovflow3 +
2537 stats.rx_trunc0 + stats.rx_trunc1 +
2538 stats.rx_trunc2 + stats.rx_trunc3;
2539 ns->rx_missed_errors = 0;
2540
2541 /* detailed tx_errors */
2542 ns->tx_aborted_errors = 0;
2543 ns->tx_carrier_errors = 0;
2544 ns->tx_fifo_errors = 0;
2545 ns->tx_heartbeat_errors = 0;
2546 ns->tx_window_errors = 0;
2547
2548 ns->tx_errors = stats.tx_error_frames;
2549 ns->rx_errors = stats.rx_symbol_err + stats.rx_fcs_err +
2550 ns->rx_length_errors + stats.rx_len_err + ns->rx_fifo_errors;
2551 return ns;
2552}
2553
2554static int cxgb_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
2555{
2556 int ret = 0, prtad, devad;
2557 struct port_info *pi = netdev_priv(dev);
2558 struct mii_ioctl_data *data = (struct mii_ioctl_data *)&req->ifr_data;
2559
2560 switch (cmd) {
2561 case SIOCGMIIPHY:
2562 if (pi->mdio_addr < 0)
2563 return -EOPNOTSUPP;
2564 data->phy_id = pi->mdio_addr;
2565 break;
2566 case SIOCGMIIREG:
2567 case SIOCSMIIREG:
2568 if (mdio_phy_id_is_c45(data->phy_id)) {
2569 prtad = mdio_phy_id_prtad(data->phy_id);
2570 devad = mdio_phy_id_devad(data->phy_id);
2571 } else if (data->phy_id < 32) {
2572 prtad = data->phy_id;
2573 devad = 0;
2574 data->reg_num &= 0x1f;
2575 } else
2576 return -EINVAL;
2577
2578 if (cmd == SIOCGMIIREG)
2579 ret = t4_mdio_rd(pi->adapter, 0, prtad, devad,
2580 data->reg_num, &data->val_out);
2581 else
2582 ret = t4_mdio_wr(pi->adapter, 0, prtad, devad,
2583 data->reg_num, data->val_in);
2584 break;
2585 default:
2586 return -EOPNOTSUPP;
2587 }
2588 return ret;
2589}
2590
2591static void cxgb_set_rxmode(struct net_device *dev)
2592{
2593 /* unfortunately we can't return errors to the stack */
2594 set_rxmode(dev, -1, false);
2595}
2596
2597static int cxgb_change_mtu(struct net_device *dev, int new_mtu)
2598{
2599 int ret;
2600 struct port_info *pi = netdev_priv(dev);
2601
2602 if (new_mtu < 81 || new_mtu > MAX_MTU) /* accommodate SACK */
2603 return -EINVAL;
2604 ret = t4_set_rxmode(pi->adapter, 0, pi->viid, new_mtu, -1, -1, -1,
2605 true);
2606 if (!ret)
2607 dev->mtu = new_mtu;
2608 return ret;
2609}
2610
2611static int cxgb_set_mac_addr(struct net_device *dev, void *p)
2612{
2613 int ret;
2614 struct sockaddr *addr = p;
2615 struct port_info *pi = netdev_priv(dev);
2616
2617 if (!is_valid_ether_addr(addr->sa_data))
2618 return -EINVAL;
2619
2620 ret = t4_change_mac(pi->adapter, 0, pi->viid, pi->xact_addr_filt,
2621 addr->sa_data, true, true);
2622 if (ret < 0)
2623 return ret;
2624
2625 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
2626 pi->xact_addr_filt = ret;
2627 return 0;
2628}
2629
2630static void vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
2631{
2632 struct port_info *pi = netdev_priv(dev);
2633
2634 pi->vlan_grp = grp;
2635 t4_set_vlan_accel(pi->adapter, 1 << pi->tx_chan, grp != NULL);
2636}
2637
2638#ifdef CONFIG_NET_POLL_CONTROLLER
2639static void cxgb_netpoll(struct net_device *dev)
2640{
2641 struct port_info *pi = netdev_priv(dev);
2642 struct adapter *adap = pi->adapter;
2643
2644 if (adap->flags & USING_MSIX) {
2645 int i;
2646 struct sge_eth_rxq *rx = &adap->sge.ethrxq[pi->first_qset];
2647
2648 for (i = pi->nqsets; i; i--, rx++)
2649 t4_sge_intr_msix(0, &rx->rspq);
2650 } else
2651 t4_intr_handler(adap)(0, adap);
2652}
2653#endif
2654
2655static const struct net_device_ops cxgb4_netdev_ops = {
2656 .ndo_open = cxgb_open,
2657 .ndo_stop = cxgb_close,
2658 .ndo_start_xmit = t4_eth_xmit,
2659 .ndo_get_stats = cxgb_get_stats,
2660 .ndo_set_rx_mode = cxgb_set_rxmode,
2661 .ndo_set_mac_address = cxgb_set_mac_addr,
2662 .ndo_validate_addr = eth_validate_addr,
2663 .ndo_do_ioctl = cxgb_ioctl,
2664 .ndo_change_mtu = cxgb_change_mtu,
2665 .ndo_vlan_rx_register = vlan_rx_register,
2666#ifdef CONFIG_NET_POLL_CONTROLLER
2667 .ndo_poll_controller = cxgb_netpoll,
2668#endif
2669};
2670
2671void t4_fatal_err(struct adapter *adap)
2672{
2673 t4_set_reg_field(adap, SGE_CONTROL, GLOBALENABLE, 0);
2674 t4_intr_disable(adap);
2675 dev_alert(adap->pdev_dev, "encountered fatal error, adapter stopped\n");
2676}
2677
2678static void setup_memwin(struct adapter *adap)
2679{
2680 u32 bar0;
2681
2682 bar0 = pci_resource_start(adap->pdev, 0); /* truncation intentional */
2683 t4_write_reg(adap, PCIE_MEM_ACCESS_REG(PCIE_MEM_ACCESS_BASE_WIN, 0),
2684 (bar0 + MEMWIN0_BASE) | BIR(0) |
2685 WINDOW(ilog2(MEMWIN0_APERTURE) - 10));
2686 t4_write_reg(adap, PCIE_MEM_ACCESS_REG(PCIE_MEM_ACCESS_BASE_WIN, 1),
2687 (bar0 + MEMWIN1_BASE) | BIR(0) |
2688 WINDOW(ilog2(MEMWIN1_APERTURE) - 10));
2689 t4_write_reg(adap, PCIE_MEM_ACCESS_REG(PCIE_MEM_ACCESS_BASE_WIN, 2),
2690 (bar0 + MEMWIN2_BASE) | BIR(0) |
2691 WINDOW(ilog2(MEMWIN2_APERTURE) - 10));
2692}
2693
2694/*
2695 * Max # of ATIDs. The absolute HW max is 16K but we keep it lower.
2696 */
2697#define MAX_ATIDS 8192U
2698
2699/*
2700 * Phase 0 of initialization: contact FW, obtain config, perform basic init.
2701 */
2702static int adap_init0(struct adapter *adap)
2703{
2704 int ret;
2705 u32 v, port_vec;
2706 enum dev_state state;
2707 u32 params[7], val[7];
2708 struct fw_caps_config_cmd c;
2709
2710 ret = t4_check_fw_version(adap);
2711 if (ret == -EINVAL || ret > 0) {
2712 if (upgrade_fw(adap) >= 0) /* recache FW version */
2713 ret = t4_check_fw_version(adap);
2714 }
2715 if (ret < 0)
2716 return ret;
2717
2718 /* contact FW, request master */
2719 ret = t4_fw_hello(adap, 0, 0, MASTER_MUST, &state);
2720 if (ret < 0) {
2721 dev_err(adap->pdev_dev, "could not connect to FW, error %d\n",
2722 ret);
2723 return ret;
2724 }
2725
2726 /* reset device */
2727 ret = t4_fw_reset(adap, 0, PIORSTMODE | PIORST);
2728 if (ret < 0)
2729 goto bye;
2730
2731 /* get device capabilities */
2732 memset(&c, 0, sizeof(c));
2733 c.op_to_write = htonl(FW_CMD_OP(FW_CAPS_CONFIG_CMD) |
2734 FW_CMD_REQUEST | FW_CMD_READ);
2735 c.retval_len16 = htonl(FW_LEN16(c));
2736 ret = t4_wr_mbox(adap, 0, &c, sizeof(c), &c);
2737 if (ret < 0)
2738 goto bye;
2739
2740 /* select capabilities we'll be using */
2741 if (c.niccaps & htons(FW_CAPS_CONFIG_NIC_VM)) {
2742 if (!vf_acls)
2743 c.niccaps ^= htons(FW_CAPS_CONFIG_NIC_VM);
2744 else
2745 c.niccaps = htons(FW_CAPS_CONFIG_NIC_VM);
2746 } else if (vf_acls) {
2747 dev_err(adap->pdev_dev, "virtualization ACLs not supported");
2748 goto bye;
2749 }
2750 c.op_to_write = htonl(FW_CMD_OP(FW_CAPS_CONFIG_CMD) |
2751 FW_CMD_REQUEST | FW_CMD_WRITE);
2752 ret = t4_wr_mbox(adap, 0, &c, sizeof(c), NULL);
2753 if (ret < 0)
2754 goto bye;
2755
2756 ret = t4_config_glbl_rss(adap, 0,
2757 FW_RSS_GLB_CONFIG_CMD_MODE_BASICVIRTUAL,
2758 FW_RSS_GLB_CONFIG_CMD_TNLMAPEN |
2759 FW_RSS_GLB_CONFIG_CMD_TNLALLLKP);
2760 if (ret < 0)
2761 goto bye;
2762
2763 ret = t4_cfg_pfvf(adap, 0, 0, 0, 64, 64, 64, 0, 0, 4, 0xf, 0xf, 16,
2764 FW_CMD_CAP_PF, FW_CMD_CAP_PF);
2765 if (ret < 0)
2766 goto bye;
2767
2768 for (v = 0; v < SGE_NTIMERS - 1; v++)
2769 adap->sge.timer_val[v] = min(intr_holdoff[v], MAX_SGE_TIMERVAL);
2770 adap->sge.timer_val[SGE_NTIMERS - 1] = MAX_SGE_TIMERVAL;
2771 adap->sge.counter_val[0] = 1;
2772 for (v = 1; v < SGE_NCOUNTERS; v++)
2773 adap->sge.counter_val[v] = min(intr_cnt[v - 1],
2774 THRESHOLD_3_MASK);
2775 t4_sge_init(adap);
2776
2777 /* get basic stuff going */
2778 ret = t4_early_init(adap, 0);
2779 if (ret < 0)
2780 goto bye;
2781
2782#define FW_PARAM_DEV(param) \
2783 (FW_PARAMS_MNEM(FW_PARAMS_MNEM_DEV) | \
2784 FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DEV_##param))
2785
2786#define FW_PARAM_PFVF(param) \
2787 (FW_PARAMS_MNEM(FW_PARAMS_MNEM_PFVF) | \
2788 FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_PFVF_##param))
2789
2790 params[0] = FW_PARAM_DEV(PORTVEC);
2791 params[1] = FW_PARAM_PFVF(L2T_START);
2792 params[2] = FW_PARAM_PFVF(L2T_END);
2793 params[3] = FW_PARAM_PFVF(FILTER_START);
2794 params[4] = FW_PARAM_PFVF(FILTER_END);
2795 ret = t4_query_params(adap, 0, 0, 0, 5, params, val);
2796 if (ret < 0)
2797 goto bye;
2798 port_vec = val[0];
2799 adap->tids.ftid_base = val[3];
2800 adap->tids.nftids = val[4] - val[3] + 1;
2801
2802 if (c.ofldcaps) {
2803 /* query offload-related parameters */
2804 params[0] = FW_PARAM_DEV(NTID);
2805 params[1] = FW_PARAM_PFVF(SERVER_START);
2806 params[2] = FW_PARAM_PFVF(SERVER_END);
2807 params[3] = FW_PARAM_PFVF(TDDP_START);
2808 params[4] = FW_PARAM_PFVF(TDDP_END);
2809 params[5] = FW_PARAM_DEV(FLOWC_BUFFIFO_SZ);
2810 ret = t4_query_params(adap, 0, 0, 0, 6, params, val);
2811 if (ret < 0)
2812 goto bye;
2813 adap->tids.ntids = val[0];
2814 adap->tids.natids = min(adap->tids.ntids / 2, MAX_ATIDS);
2815 adap->tids.stid_base = val[1];
2816 adap->tids.nstids = val[2] - val[1] + 1;
2817 adap->vres.ddp.start = val[3];
2818 adap->vres.ddp.size = val[4] - val[3] + 1;
2819 adap->params.ofldq_wr_cred = val[5];
2820 adap->params.offload = 1;
2821 }
2822 if (c.rdmacaps) {
2823 params[0] = FW_PARAM_PFVF(STAG_START);
2824 params[1] = FW_PARAM_PFVF(STAG_END);
2825 params[2] = FW_PARAM_PFVF(RQ_START);
2826 params[3] = FW_PARAM_PFVF(RQ_END);
2827 params[4] = FW_PARAM_PFVF(PBL_START);
2828 params[5] = FW_PARAM_PFVF(PBL_END);
2829 ret = t4_query_params(adap, 0, 0, 0, 6, params, val);
2830 if (ret < 0)
2831 goto bye;
2832 adap->vres.stag.start = val[0];
2833 adap->vres.stag.size = val[1] - val[0] + 1;
2834 adap->vres.rq.start = val[2];
2835 adap->vres.rq.size = val[3] - val[2] + 1;
2836 adap->vres.pbl.start = val[4];
2837 adap->vres.pbl.size = val[5] - val[4] + 1;
2838 }
2839 if (c.iscsicaps) {
2840 params[0] = FW_PARAM_PFVF(ISCSI_START);
2841 params[1] = FW_PARAM_PFVF(ISCSI_END);
2842 ret = t4_query_params(adap, 0, 0, 0, 2, params, val);
2843 if (ret < 0)
2844 goto bye;
2845 adap->vres.iscsi.start = val[0];
2846 adap->vres.iscsi.size = val[1] - val[0] + 1;
2847 }
2848#undef FW_PARAM_PFVF
2849#undef FW_PARAM_DEV
2850
2851 adap->params.nports = hweight32(port_vec);
2852 adap->params.portvec = port_vec;
2853 adap->flags |= FW_OK;
2854
2855 /* These are finalized by FW initialization, load their values now */
2856 v = t4_read_reg(adap, TP_TIMER_RESOLUTION);
2857 adap->params.tp.tre = TIMERRESOLUTION_GET(v);
2858 t4_read_mtu_tbl(adap, adap->params.mtus, NULL);
2859 t4_load_mtus(adap, adap->params.mtus, adap->params.a_wnd,
2860 adap->params.b_wnd);
2861
2862 /* tweak some settings */
2863 t4_write_reg(adap, TP_SHIFT_CNT, 0x64f8849);
2864 t4_write_reg(adap, ULP_RX_TDDP_PSZ, HPZ0(PAGE_SHIFT - 12));
2865 t4_write_reg(adap, TP_PIO_ADDR, TP_INGRESS_CONFIG);
2866 v = t4_read_reg(adap, TP_PIO_DATA);
2867 t4_write_reg(adap, TP_PIO_DATA, v & ~CSUM_HAS_PSEUDO_HDR);
2868 setup_memwin(adap);
2869 return 0;
2870
2871 /*
2872 * If a command timed out or failed with EIO FW does not operate within
2873 * its spec or something catastrophic happened to HW/FW, stop issuing
2874 * commands.
2875 */
2876bye: if (ret != -ETIMEDOUT && ret != -EIO)
2877 t4_fw_bye(adap, 0);
2878 return ret;
2879}
2880
2881static inline bool is_10g_port(const struct link_config *lc)
2882{
2883 return (lc->supported & FW_PORT_CAP_SPEED_10G) != 0;
2884}
2885
2886static inline void init_rspq(struct sge_rspq *q, u8 timer_idx, u8 pkt_cnt_idx,
2887 unsigned int size, unsigned int iqe_size)
2888{
2889 q->intr_params = QINTR_TIMER_IDX(timer_idx) |
2890 (pkt_cnt_idx < SGE_NCOUNTERS ? QINTR_CNT_EN : 0);
2891 q->pktcnt_idx = pkt_cnt_idx < SGE_NCOUNTERS ? pkt_cnt_idx : 0;
2892 q->iqe_len = iqe_size;
2893 q->size = size;
2894}
2895
2896/*
2897 * Perform default configuration of DMA queues depending on the number and type
2898 * of ports we found and the number of available CPUs. Most settings can be
2899 * modified by the admin prior to actual use.
2900 */
2901static void __devinit cfg_queues(struct adapter *adap)
2902{
2903 struct sge *s = &adap->sge;
2904 int i, q10g = 0, n10g = 0, qidx = 0;
2905
2906 for_each_port(adap, i)
2907 n10g += is_10g_port(&adap2pinfo(adap, i)->link_cfg);
2908
2909 /*
2910 * We default to 1 queue per non-10G port and up to # of cores queues
2911 * per 10G port.
2912 */
2913 if (n10g)
2914 q10g = (MAX_ETH_QSETS - (adap->params.nports - n10g)) / n10g;
2915 if (q10g > num_online_cpus())
2916 q10g = num_online_cpus();
2917
2918 for_each_port(adap, i) {
2919 struct port_info *pi = adap2pinfo(adap, i);
2920
2921 pi->first_qset = qidx;
2922 pi->nqsets = is_10g_port(&pi->link_cfg) ? q10g : 1;
2923 qidx += pi->nqsets;
2924 }
2925
2926 s->ethqsets = qidx;
2927 s->max_ethqsets = qidx; /* MSI-X may lower it later */
2928
2929 if (is_offload(adap)) {
2930 /*
2931 * For offload we use 1 queue/channel if all ports are up to 1G,
2932 * otherwise we divide all available queues amongst the channels
2933 * capped by the number of available cores.
2934 */
2935 if (n10g) {
2936 i = min_t(int, ARRAY_SIZE(s->ofldrxq),
2937 num_online_cpus());
2938 s->ofldqsets = roundup(i, adap->params.nports);
2939 } else
2940 s->ofldqsets = adap->params.nports;
2941 /* For RDMA one Rx queue per channel suffices */
2942 s->rdmaqs = adap->params.nports;
2943 }
2944
2945 for (i = 0; i < ARRAY_SIZE(s->ethrxq); i++) {
2946 struct sge_eth_rxq *r = &s->ethrxq[i];
2947
2948 init_rspq(&r->rspq, 0, 0, 1024, 64);
2949 r->fl.size = 72;
2950 }
2951
2952 for (i = 0; i < ARRAY_SIZE(s->ethtxq); i++)
2953 s->ethtxq[i].q.size = 1024;
2954
2955 for (i = 0; i < ARRAY_SIZE(s->ctrlq); i++)
2956 s->ctrlq[i].q.size = 512;
2957
2958 for (i = 0; i < ARRAY_SIZE(s->ofldtxq); i++)
2959 s->ofldtxq[i].q.size = 1024;
2960
2961 for (i = 0; i < ARRAY_SIZE(s->ofldrxq); i++) {
2962 struct sge_ofld_rxq *r = &s->ofldrxq[i];
2963
2964 init_rspq(&r->rspq, 0, 0, 1024, 64);
2965 r->rspq.uld = CXGB4_ULD_ISCSI;
2966 r->fl.size = 72;
2967 }
2968
2969 for (i = 0; i < ARRAY_SIZE(s->rdmarxq); i++) {
2970 struct sge_ofld_rxq *r = &s->rdmarxq[i];
2971
2972 init_rspq(&r->rspq, 0, 0, 511, 64);
2973 r->rspq.uld = CXGB4_ULD_RDMA;
2974 r->fl.size = 72;
2975 }
2976
2977 init_rspq(&s->fw_evtq, 6, 0, 512, 64);
2978 init_rspq(&s->intrq, 6, 0, 2 * MAX_INGQ, 64);
2979}
2980
2981/*
2982 * Reduce the number of Ethernet queues across all ports to at most n.
2983 * n provides at least one queue per port.
2984 */
2985static void __devinit reduce_ethqs(struct adapter *adap, int n)
2986{
2987 int i;
2988 struct port_info *pi;
2989
2990 while (n < adap->sge.ethqsets)
2991 for_each_port(adap, i) {
2992 pi = adap2pinfo(adap, i);
2993 if (pi->nqsets > 1) {
2994 pi->nqsets--;
2995 adap->sge.ethqsets--;
2996 if (adap->sge.ethqsets <= n)
2997 break;
2998 }
2999 }
3000
3001 n = 0;
3002 for_each_port(adap, i) {
3003 pi = adap2pinfo(adap, i);
3004 pi->first_qset = n;
3005 n += pi->nqsets;
3006 }
3007}
3008
3009/* 2 MSI-X vectors needed for the FW queue and non-data interrupts */
3010#define EXTRA_VECS 2
3011
3012static int __devinit enable_msix(struct adapter *adap)
3013{
3014 int ofld_need = 0;
3015 int i, err, want, need;
3016 struct sge *s = &adap->sge;
3017 unsigned int nchan = adap->params.nports;
3018 struct msix_entry entries[MAX_INGQ + 1];
3019
3020 for (i = 0; i < ARRAY_SIZE(entries); ++i)
3021 entries[i].entry = i;
3022
3023 want = s->max_ethqsets + EXTRA_VECS;
3024 if (is_offload(adap)) {
3025 want += s->rdmaqs + s->ofldqsets;
3026 /* need nchan for each possible ULD */
3027 ofld_need = 2 * nchan;
3028 }
3029 need = adap->params.nports + EXTRA_VECS + ofld_need;
3030
3031 while ((err = pci_enable_msix(adap->pdev, entries, want)) >= need)
3032 want = err;
3033
3034 if (!err) {
3035 /*
3036 * Distribute available vectors to the various queue groups.
3037 * Every group gets its minimum requirement and NIC gets top
3038 * priority for leftovers.
3039 */
3040 i = want - EXTRA_VECS - ofld_need;
3041 if (i < s->max_ethqsets) {
3042 s->max_ethqsets = i;
3043 if (i < s->ethqsets)
3044 reduce_ethqs(adap, i);
3045 }
3046 if (is_offload(adap)) {
3047 i = want - EXTRA_VECS - s->max_ethqsets;
3048 i -= ofld_need - nchan;
3049 s->ofldqsets = (i / nchan) * nchan; /* round down */
3050 }
3051 for (i = 0; i < want; ++i)
3052 adap->msix_info[i].vec = entries[i].vector;
3053 } else if (err > 0)
3054 dev_info(adap->pdev_dev,
3055 "only %d MSI-X vectors left, not using MSI-X\n", err);
3056 return err;
3057}
3058
3059#undef EXTRA_VECS
3060
3061static void __devinit print_port_info(struct adapter *adap)
3062{
3063 static const char *base[] = {
3064 "R", "KX4", "T", "KX", "T", "KR", "CX4"
3065 };
3066
3067 int i;
3068 char buf[80];
3069
3070 for_each_port(adap, i) {
3071 struct net_device *dev = adap->port[i];
3072 const struct port_info *pi = netdev_priv(dev);
3073 char *bufp = buf;
3074
3075 if (!test_bit(i, &adap->registered_device_map))
3076 continue;
3077
3078 if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_100M)
3079 bufp += sprintf(bufp, "100/");
3080 if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_1G)
3081 bufp += sprintf(bufp, "1000/");
3082 if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_10G)
3083 bufp += sprintf(bufp, "10G/");
3084 if (bufp != buf)
3085 --bufp;
3086 sprintf(bufp, "BASE-%s", base[pi->port_type]);
3087
3088 netdev_info(dev, "Chelsio %s rev %d %s %sNIC PCIe x%d%s\n",
3089 adap->params.vpd.id, adap->params.rev,
3090 buf, is_offload(adap) ? "R" : "",
3091 adap->params.pci.width,
3092 (adap->flags & USING_MSIX) ? " MSI-X" :
3093 (adap->flags & USING_MSI) ? " MSI" : "");
3094 if (adap->name == dev->name)
3095 netdev_info(dev, "S/N: %s, E/C: %s\n",
3096 adap->params.vpd.sn, adap->params.vpd.ec);
3097 }
3098}
3099
3100#define VLAN_FEAT (NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO | NETIF_F_TSO6 |\
3101 NETIF_F_IPV6_CSUM | NETIF_F_HIGHDMA)
3102
3103static int __devinit init_one(struct pci_dev *pdev,
3104 const struct pci_device_id *ent)
3105{
3106 int func, i, err;
3107 struct port_info *pi;
3108 unsigned int highdma = 0;
3109 struct adapter *adapter = NULL;
3110
3111 printk_once(KERN_INFO "%s - version %s\n", DRV_DESC, DRV_VERSION);
3112
3113 err = pci_request_regions(pdev, KBUILD_MODNAME);
3114 if (err) {
3115 /* Just info, some other driver may have claimed the device. */
3116 dev_info(&pdev->dev, "cannot obtain PCI resources\n");
3117 return err;
3118 }
3119
3120 /* We control everything through PF 0 */
3121 func = PCI_FUNC(pdev->devfn);
3122 if (func > 0)
3123 goto sriov;
3124
3125 err = pci_enable_device(pdev);
3126 if (err) {
3127 dev_err(&pdev->dev, "cannot enable PCI device\n");
3128 goto out_release_regions;
3129 }
3130
3131 if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
3132 highdma = NETIF_F_HIGHDMA;
3133 err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
3134 if (err) {
3135 dev_err(&pdev->dev, "unable to obtain 64-bit DMA for "
3136 "coherent allocations\n");
3137 goto out_disable_device;
3138 }
3139 } else {
3140 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
3141 if (err) {
3142 dev_err(&pdev->dev, "no usable DMA configuration\n");
3143 goto out_disable_device;
3144 }
3145 }
3146
3147 pci_enable_pcie_error_reporting(pdev);
3148 pci_set_master(pdev);
3149 pci_save_state(pdev);
3150
3151 adapter = kzalloc(sizeof(*adapter), GFP_KERNEL);
3152 if (!adapter) {
3153 err = -ENOMEM;
3154 goto out_disable_device;
3155 }
3156
3157 adapter->regs = pci_ioremap_bar(pdev, 0);
3158 if (!adapter->regs) {
3159 dev_err(&pdev->dev, "cannot map device registers\n");
3160 err = -ENOMEM;
3161 goto out_free_adapter;
3162 }
3163
3164 adapter->pdev = pdev;
3165 adapter->pdev_dev = &pdev->dev;
3166 adapter->name = pci_name(pdev);
3167 adapter->msg_enable = dflt_msg_enable;
3168 memset(adapter->chan_map, 0xff, sizeof(adapter->chan_map));
3169
3170 spin_lock_init(&adapter->stats_lock);
3171 spin_lock_init(&adapter->tid_release_lock);
3172
3173 INIT_WORK(&adapter->tid_release_task, process_tid_release_list);
3174
3175 err = t4_prep_adapter(adapter);
3176 if (err)
3177 goto out_unmap_bar;
3178 err = adap_init0(adapter);
3179 if (err)
3180 goto out_unmap_bar;
3181
3182 for_each_port(adapter, i) {
3183 struct net_device *netdev;
3184
3185 netdev = alloc_etherdev_mq(sizeof(struct port_info),
3186 MAX_ETH_QSETS);
3187 if (!netdev) {
3188 err = -ENOMEM;
3189 goto out_free_dev;
3190 }
3191
3192 SET_NETDEV_DEV(netdev, &pdev->dev);
3193
3194 adapter->port[i] = netdev;
3195 pi = netdev_priv(netdev);
3196 pi->adapter = adapter;
3197 pi->xact_addr_filt = -1;
3198 pi->rx_offload = RX_CSO;
3199 pi->port_id = i;
3200 netif_carrier_off(netdev);
3201 netif_tx_stop_all_queues(netdev);
3202 netdev->irq = pdev->irq;
3203
3204 netdev->features |= NETIF_F_SG | NETIF_F_TSO | NETIF_F_TSO6;
3205 netdev->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
3206 netdev->features |= NETIF_F_GRO | highdma;
3207 netdev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
3208 netdev->vlan_features = netdev->features & VLAN_FEAT;
3209
3210 netdev->netdev_ops = &cxgb4_netdev_ops;
3211 SET_ETHTOOL_OPS(netdev, &cxgb_ethtool_ops);
3212 }
3213
3214 pci_set_drvdata(pdev, adapter);
3215
3216 if (adapter->flags & FW_OK) {
3217 err = t4_port_init(adapter, 0, 0, 0);
3218 if (err)
3219 goto out_free_dev;
3220 }
3221
3222 /*
3223 * Configure queues and allocate tables now, they can be needed as
3224 * soon as the first register_netdev completes.
3225 */
3226 cfg_queues(adapter);
3227
3228 adapter->l2t = t4_init_l2t();
3229 if (!adapter->l2t) {
3230 /* We tolerate a lack of L2T, giving up some functionality */
3231 dev_warn(&pdev->dev, "could not allocate L2T, continuing\n");
3232 adapter->params.offload = 0;
3233 }
3234
3235 if (is_offload(adapter) && tid_init(&adapter->tids) < 0) {
3236 dev_warn(&pdev->dev, "could not allocate TID table, "
3237 "continuing\n");
3238 adapter->params.offload = 0;
3239 }
3240
3241 /*
3242 * The card is now ready to go. If any errors occur during device
3243 * registration we do not fail the whole card but rather proceed only
3244 * with the ports we manage to register successfully. However we must
3245 * register at least one net device.
3246 */
3247 for_each_port(adapter, i) {
3248 err = register_netdev(adapter->port[i]);
3249 if (err)
3250 dev_warn(&pdev->dev,
3251 "cannot register net device %s, skipping\n",
3252 adapter->port[i]->name);
3253 else {
3254 /*
3255 * Change the name we use for messages to the name of
3256 * the first successfully registered interface.
3257 */
3258 if (!adapter->registered_device_map)
3259 adapter->name = adapter->port[i]->name;
3260
3261 __set_bit(i, &adapter->registered_device_map);
3262 adapter->chan_map[adap2pinfo(adapter, i)->tx_chan] = i;
3263 }
3264 }
3265 if (!adapter->registered_device_map) {
3266 dev_err(&pdev->dev, "could not register any net devices\n");
3267 goto out_free_dev;
3268 }
3269
3270 if (cxgb4_debugfs_root) {
3271 adapter->debugfs_root = debugfs_create_dir(pci_name(pdev),
3272 cxgb4_debugfs_root);
3273 setup_debugfs(adapter);
3274 }
3275
3276 /* See what interrupts we'll be using */
3277 if (msi > 1 && enable_msix(adapter) == 0)
3278 adapter->flags |= USING_MSIX;
3279 else if (msi > 0 && pci_enable_msi(pdev) == 0)
3280 adapter->flags |= USING_MSI;
3281
3282 if (is_offload(adapter))
3283 attach_ulds(adapter);
3284
3285 print_port_info(adapter);
3286
3287sriov:
3288#ifdef CONFIG_PCI_IOV
3289 if (func < ARRAY_SIZE(num_vf) && num_vf[func] > 0)
3290 if (pci_enable_sriov(pdev, num_vf[func]) == 0)
3291 dev_info(&pdev->dev,
3292 "instantiated %u virtual functions\n",
3293 num_vf[func]);
3294#endif
3295 return 0;
3296
3297 out_free_dev:
3298 t4_free_mem(adapter->tids.tid_tab);
3299 t4_free_mem(adapter->l2t);
3300 for_each_port(adapter, i)
3301 if (adapter->port[i])
3302 free_netdev(adapter->port[i]);
3303 if (adapter->flags & FW_OK)
3304 t4_fw_bye(adapter, 0);
3305 out_unmap_bar:
3306 iounmap(adapter->regs);
3307 out_free_adapter:
3308 kfree(adapter);
3309 out_disable_device:
3310 pci_disable_pcie_error_reporting(pdev);
3311 pci_disable_device(pdev);
3312 out_release_regions:
3313 pci_release_regions(pdev);
3314 pci_set_drvdata(pdev, NULL);
3315 return err;
3316}
3317
3318static void __devexit remove_one(struct pci_dev *pdev)
3319{
3320 struct adapter *adapter = pci_get_drvdata(pdev);
3321
3322 pci_disable_sriov(pdev);
3323
3324 if (adapter) {
3325 int i;
3326
3327 if (is_offload(adapter))
3328 detach_ulds(adapter);
3329
3330 for_each_port(adapter, i)
3331 if (test_bit(i, &adapter->registered_device_map))
3332 unregister_netdev(adapter->port[i]);
3333
3334 if (adapter->debugfs_root)
3335 debugfs_remove_recursive(adapter->debugfs_root);
3336
3337 t4_sge_stop(adapter);
3338 t4_free_sge_resources(adapter);
3339 t4_free_mem(adapter->l2t);
3340 t4_free_mem(adapter->tids.tid_tab);
3341 disable_msi(adapter);
3342
3343 for_each_port(adapter, i)
3344 if (adapter->port[i])
3345 free_netdev(adapter->port[i]);
3346
3347 if (adapter->flags & FW_OK)
3348 t4_fw_bye(adapter, 0);
3349 iounmap(adapter->regs);
3350 kfree(adapter);
3351 pci_disable_pcie_error_reporting(pdev);
3352 pci_disable_device(pdev);
3353 pci_release_regions(pdev);
3354 pci_set_drvdata(pdev, NULL);
3355 } else if (PCI_FUNC(pdev->devfn) > 0)
3356 pci_release_regions(pdev);
3357}
3358
3359static struct pci_driver cxgb4_driver = {
3360 .name = KBUILD_MODNAME,
3361 .id_table = cxgb4_pci_tbl,
3362 .probe = init_one,
3363 .remove = __devexit_p(remove_one),
3364};
3365
3366static int __init cxgb4_init_module(void)
3367{
3368 int ret;
3369
3370 /* Debugfs support is optional, just warn if this fails */
3371 cxgb4_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL);
3372 if (!cxgb4_debugfs_root)
3373 pr_warning("could not create debugfs entry, continuing\n");
3374
3375 ret = pci_register_driver(&cxgb4_driver);
3376 if (ret < 0)
3377 debugfs_remove(cxgb4_debugfs_root);
3378 return ret;
3379}
3380
3381static void __exit cxgb4_cleanup_module(void)
3382{
3383 pci_unregister_driver(&cxgb4_driver);
3384 debugfs_remove(cxgb4_debugfs_root); /* NULL ok */
3385}
3386
3387module_init(cxgb4_init_module);
3388module_exit(cxgb4_cleanup_module);
diff --git a/drivers/net/cxgb4/cxgb4_uld.h b/drivers/net/cxgb4/cxgb4_uld.h
new file mode 100644
index 00000000000..5b98546ac92
--- /dev/null
+++ b/drivers/net/cxgb4/cxgb4_uld.h
@@ -0,0 +1,239 @@
1/*
2 * This file is part of the Chelsio T4 Ethernet driver for Linux.
3 *
4 * Copyright (c) 2003-2010 Chelsio Communications, Inc. All rights reserved.
5 *
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
11 *
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
14 * conditions are met:
15 *
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer.
19 *
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
24 *
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE.
33 */
34
35#ifndef __CXGB4_OFLD_H
36#define __CXGB4_OFLD_H
37
38#include <linux/cache.h>
39#include <linux/spinlock.h>
40#include <linux/skbuff.h>
41#include <asm/atomic.h>
42
43/* CPL message priority levels */
44enum {
45 CPL_PRIORITY_DATA = 0, /* data messages */
46 CPL_PRIORITY_SETUP = 1, /* connection setup messages */
47 CPL_PRIORITY_TEARDOWN = 0, /* connection teardown messages */
48 CPL_PRIORITY_LISTEN = 1, /* listen start/stop messages */
49 CPL_PRIORITY_ACK = 1, /* RX ACK messages */
50 CPL_PRIORITY_CONTROL = 1 /* control messages */
51};
52
53#define INIT_TP_WR(w, tid) do { \
54 (w)->wr.wr_hi = htonl(FW_WR_OP(FW_TP_WR) | \
55 FW_WR_IMMDLEN(sizeof(*w) - sizeof(w->wr))); \
56 (w)->wr.wr_mid = htonl(FW_WR_LEN16(DIV_ROUND_UP(sizeof(*w), 16)) | \
57 FW_WR_FLOWID(tid)); \
58 (w)->wr.wr_lo = cpu_to_be64(0); \
59} while (0)
60
61#define INIT_TP_WR_CPL(w, cpl, tid) do { \
62 INIT_TP_WR(w, tid); \
63 OPCODE_TID(w) = htonl(MK_OPCODE_TID(cpl, tid)); \
64} while (0)
65
66#define INIT_ULPTX_WR(w, wrlen, atomic, tid) do { \
67 (w)->wr.wr_hi = htonl(FW_WR_OP(FW_ULPTX_WR) | FW_WR_ATOMIC(atomic)); \
68 (w)->wr.wr_mid = htonl(FW_WR_LEN16(DIV_ROUND_UP(wrlen, 16)) | \
69 FW_WR_FLOWID(tid)); \
70 (w)->wr.wr_lo = cpu_to_be64(0); \
71} while (0)
72
73/* Special asynchronous notification message */
74#define CXGB4_MSG_AN ((void *)1)
75
76struct serv_entry {
77 void *data;
78};
79
80union aopen_entry {
81 void *data;
82 union aopen_entry *next;
83};
84
85/*
86 * Holds the size, base address, free list start, etc of the TID, server TID,
87 * and active-open TID tables. The tables themselves are allocated dynamically.
88 */
89struct tid_info {
90 void **tid_tab;
91 unsigned int ntids;
92
93 struct serv_entry *stid_tab;
94 unsigned long *stid_bmap;
95 unsigned int nstids;
96 unsigned int stid_base;
97
98 union aopen_entry *atid_tab;
99 unsigned int natids;
100
101 unsigned int nftids;
102 unsigned int ftid_base;
103
104 spinlock_t atid_lock ____cacheline_aligned_in_smp;
105 union aopen_entry *afree;
106 unsigned int atids_in_use;
107
108 spinlock_t stid_lock;
109 unsigned int stids_in_use;
110
111 atomic_t tids_in_use;
112};
113
114static inline void *lookup_tid(const struct tid_info *t, unsigned int tid)
115{
116 return tid < t->ntids ? t->tid_tab[tid] : NULL;
117}
118
119static inline void *lookup_atid(const struct tid_info *t, unsigned int atid)
120{
121 return atid < t->natids ? t->atid_tab[atid].data : NULL;
122}
123
124static inline void *lookup_stid(const struct tid_info *t, unsigned int stid)
125{
126 stid -= t->stid_base;
127 return stid < t->nstids ? t->stid_tab[stid].data : NULL;
128}
129
130static inline void cxgb4_insert_tid(struct tid_info *t, void *data,
131 unsigned int tid)
132{
133 t->tid_tab[tid] = data;
134 atomic_inc(&t->tids_in_use);
135}
136
137int cxgb4_alloc_atid(struct tid_info *t, void *data);
138int cxgb4_alloc_stid(struct tid_info *t, int family, void *data);
139void cxgb4_free_atid(struct tid_info *t, unsigned int atid);
140void cxgb4_free_stid(struct tid_info *t, unsigned int stid, int family);
141void cxgb4_remove_tid(struct tid_info *t, unsigned int qid, unsigned int tid);
142void cxgb4_queue_tid_release(struct tid_info *t, unsigned int chan,
143 unsigned int tid);
144
145struct in6_addr;
146
147int cxgb4_create_server(const struct net_device *dev, unsigned int stid,
148 __be32 sip, __be16 sport, unsigned int queue);
149int cxgb4_create_server6(const struct net_device *dev, unsigned int stid,
150 const struct in6_addr *sip, __be16 sport,
151 unsigned int queue);
152
153static inline void set_wr_txq(struct sk_buff *skb, int prio, int queue)
154{
155 skb_set_queue_mapping(skb, (queue << 1) | prio);
156}
157
158enum cxgb4_uld {
159 CXGB4_ULD_RDMA,
160 CXGB4_ULD_ISCSI,
161 CXGB4_ULD_MAX
162};
163
164enum cxgb4_state {
165 CXGB4_STATE_UP,
166 CXGB4_STATE_START_RECOVERY,
167 CXGB4_STATE_DOWN,
168 CXGB4_STATE_DETACH
169};
170
171struct pci_dev;
172struct l2t_data;
173struct net_device;
174struct pkt_gl;
175struct tp_tcp_stats;
176
177struct cxgb4_range {
178 unsigned int start;
179 unsigned int size;
180};
181
182struct cxgb4_virt_res { /* virtualized HW resources */
183 struct cxgb4_range ddp;
184 struct cxgb4_range iscsi;
185 struct cxgb4_range stag;
186 struct cxgb4_range rq;
187 struct cxgb4_range pbl;
188};
189
190/*
191 * Block of information the LLD provides to ULDs attaching to a device.
192 */
193struct cxgb4_lld_info {
194 struct pci_dev *pdev; /* associated PCI device */
195 struct l2t_data *l2t; /* L2 table */
196 struct tid_info *tids; /* TID table */
197 struct net_device **ports; /* device ports */
198 const struct cxgb4_virt_res *vr; /* assorted HW resources */
199 const unsigned short *mtus; /* MTU table */
200 const unsigned short *rxq_ids; /* the ULD's Rx queue ids */
201 unsigned short nrxq; /* # of Rx queues */
202 unsigned short ntxq; /* # of Tx queues */
203 unsigned char nchan:4; /* # of channels */
204 unsigned char nports:4; /* # of ports */
205 unsigned char wr_cred; /* WR 16-byte credits */
206 unsigned char adapter_type; /* type of adapter */
207 unsigned char fw_api_ver; /* FW API version */
208 unsigned int fw_vers; /* FW version */
209 unsigned int iscsi_iolen; /* iSCSI max I/O length */
210 unsigned short udb_density; /* # of user DB/page */
211 unsigned short ucq_density; /* # of user CQs/page */
212 void __iomem *gts_reg; /* address of GTS register */
213 void __iomem *db_reg; /* address of kernel doorbell */
214};
215
216struct cxgb4_uld_info {
217 const char *name;
218 void *(*add)(const struct cxgb4_lld_info *p);
219 int (*rx_handler)(void *handle, const __be64 *rsp,
220 const struct pkt_gl *gl);
221 int (*state_change)(void *handle, enum cxgb4_state new_state);
222};
223
224int cxgb4_register_uld(enum cxgb4_uld type, const struct cxgb4_uld_info *p);
225int cxgb4_unregister_uld(enum cxgb4_uld type);
226int cxgb4_ofld_send(struct net_device *dev, struct sk_buff *skb);
227unsigned int cxgb4_port_chan(const struct net_device *dev);
228unsigned int cxgb4_port_viid(const struct net_device *dev);
229unsigned int cxgb4_port_idx(const struct net_device *dev);
230struct net_device *cxgb4_netdev_by_hwid(struct pci_dev *pdev, unsigned int id);
231unsigned int cxgb4_best_mtu(const unsigned short *mtus, unsigned short mtu,
232 unsigned int *idx);
233void cxgb4_get_tcp_stats(struct pci_dev *pdev, struct tp_tcp_stats *v4,
234 struct tp_tcp_stats *v6);
235void cxgb4_iscsi_init(struct net_device *dev, unsigned int tag_mask,
236 const unsigned int *pgsz_order);
237struct sk_buff *cxgb4_pktgl_to_skb(const struct pkt_gl *gl,
238 unsigned int skb_len, unsigned int pull_len);
239#endif /* !__CXGB4_OFLD_H */
diff --git a/drivers/net/cxgb4/l2t.c b/drivers/net/cxgb4/l2t.c
new file mode 100644
index 00000000000..9f96724a133
--- /dev/null
+++ b/drivers/net/cxgb4/l2t.c
@@ -0,0 +1,624 @@
1/*
2 * This file is part of the Chelsio T4 Ethernet driver for Linux.
3 *
4 * Copyright (c) 2003-2010 Chelsio Communications, Inc. All rights reserved.
5 *
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
11 *
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
14 * conditions are met:
15 *
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer.
19 *
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
24 *
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE.
33 */
34
35#include <linux/skbuff.h>
36#include <linux/netdevice.h>
37#include <linux/if.h>
38#include <linux/if_vlan.h>
39#include <linux/jhash.h>
40#include <net/neighbour.h>
41#include "cxgb4.h"
42#include "l2t.h"
43#include "t4_msg.h"
44#include "t4fw_api.h"
45
46#define VLAN_NONE 0xfff
47
48/* identifies sync vs async L2T_WRITE_REQs */
49#define F_SYNC_WR (1 << 12)
50
51enum {
52 L2T_STATE_VALID, /* entry is up to date */
53 L2T_STATE_STALE, /* entry may be used but needs revalidation */
54 L2T_STATE_RESOLVING, /* entry needs address resolution */
55 L2T_STATE_SYNC_WRITE, /* synchronous write of entry underway */
56
57 /* when state is one of the below the entry is not hashed */
58 L2T_STATE_SWITCHING, /* entry is being used by a switching filter */
59 L2T_STATE_UNUSED /* entry not in use */
60};
61
62struct l2t_data {
63 rwlock_t lock;
64 atomic_t nfree; /* number of free entries */
65 struct l2t_entry *rover; /* starting point for next allocation */
66 struct l2t_entry l2tab[L2T_SIZE];
67};
68
69static inline unsigned int vlan_prio(const struct l2t_entry *e)
70{
71 return e->vlan >> 13;
72}
73
74static inline void l2t_hold(struct l2t_data *d, struct l2t_entry *e)
75{
76 if (atomic_add_return(1, &e->refcnt) == 1) /* 0 -> 1 transition */
77 atomic_dec(&d->nfree);
78}
79
80/*
81 * To avoid having to check address families we do not allow v4 and v6
82 * neighbors to be on the same hash chain. We keep v4 entries in the first
83 * half of available hash buckets and v6 in the second.
84 */
85enum {
86 L2T_SZ_HALF = L2T_SIZE / 2,
87 L2T_HASH_MASK = L2T_SZ_HALF - 1
88};
89
90static inline unsigned int arp_hash(const u32 *key, int ifindex)
91{
92 return jhash_2words(*key, ifindex, 0) & L2T_HASH_MASK;
93}
94
95static inline unsigned int ipv6_hash(const u32 *key, int ifindex)
96{
97 u32 xor = key[0] ^ key[1] ^ key[2] ^ key[3];
98
99 return L2T_SZ_HALF + (jhash_2words(xor, ifindex, 0) & L2T_HASH_MASK);
100}
101
102static unsigned int addr_hash(const u32 *addr, int addr_len, int ifindex)
103{
104 return addr_len == 4 ? arp_hash(addr, ifindex) :
105 ipv6_hash(addr, ifindex);
106}
107
108/*
109 * Checks if an L2T entry is for the given IP/IPv6 address. It does not check
110 * whether the L2T entry and the address are of the same address family.
111 * Callers ensure an address is only checked against L2T entries of the same
112 * family, something made trivial by the separation of IP and IPv6 hash chains
113 * mentioned above. Returns 0 if there's a match,
114 */
115static int addreq(const struct l2t_entry *e, const u32 *addr)
116{
117 if (e->v6)
118 return (e->addr[0] ^ addr[0]) | (e->addr[1] ^ addr[1]) |
119 (e->addr[2] ^ addr[2]) | (e->addr[3] ^ addr[3]);
120 return e->addr[0] ^ addr[0];
121}
122
123static void neigh_replace(struct l2t_entry *e, struct neighbour *n)
124{
125 neigh_hold(n);
126 if (e->neigh)
127 neigh_release(e->neigh);
128 e->neigh = n;
129}
130
131/*
132 * Write an L2T entry. Must be called with the entry locked.
133 * The write may be synchronous or asynchronous.
134 */
135static int write_l2e(struct adapter *adap, struct l2t_entry *e, int sync)
136{
137 struct sk_buff *skb;
138 struct cpl_l2t_write_req *req;
139
140 skb = alloc_skb(sizeof(*req), GFP_ATOMIC);
141 if (!skb)
142 return -ENOMEM;
143
144 req = (struct cpl_l2t_write_req *)__skb_put(skb, sizeof(*req));
145 INIT_TP_WR(req, 0);
146
147 OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_L2T_WRITE_REQ,
148 e->idx | (sync ? F_SYNC_WR : 0) |
149 TID_QID(adap->sge.fw_evtq.abs_id)));
150 req->params = htons(L2T_W_PORT(e->lport) | L2T_W_NOREPLY(!sync));
151 req->l2t_idx = htons(e->idx);
152 req->vlan = htons(e->vlan);
153 if (e->neigh)
154 memcpy(e->dmac, e->neigh->ha, sizeof(e->dmac));
155 memcpy(req->dst_mac, e->dmac, sizeof(req->dst_mac));
156
157 set_wr_txq(skb, CPL_PRIORITY_CONTROL, 0);
158 t4_ofld_send(adap, skb);
159
160 if (sync && e->state != L2T_STATE_SWITCHING)
161 e->state = L2T_STATE_SYNC_WRITE;
162 return 0;
163}
164
165/*
166 * Send packets waiting in an L2T entry's ARP queue. Must be called with the
167 * entry locked.
168 */
169static void send_pending(struct adapter *adap, struct l2t_entry *e)
170{
171 while (e->arpq_head) {
172 struct sk_buff *skb = e->arpq_head;
173
174 e->arpq_head = skb->next;
175 skb->next = NULL;
176 t4_ofld_send(adap, skb);
177 }
178 e->arpq_tail = NULL;
179}
180
181/*
182 * Process a CPL_L2T_WRITE_RPL. Wake up the ARP queue if it completes a
183 * synchronous L2T_WRITE. Note that the TID in the reply is really the L2T
184 * index it refers to.
185 */
186void do_l2t_write_rpl(struct adapter *adap, const struct cpl_l2t_write_rpl *rpl)
187{
188 unsigned int tid = GET_TID(rpl);
189 unsigned int idx = tid & (L2T_SIZE - 1);
190
191 if (unlikely(rpl->status != CPL_ERR_NONE)) {
192 dev_err(adap->pdev_dev,
193 "Unexpected L2T_WRITE_RPL status %u for entry %u\n",
194 rpl->status, idx);
195 return;
196 }
197
198 if (tid & F_SYNC_WR) {
199 struct l2t_entry *e = &adap->l2t->l2tab[idx];
200
201 spin_lock(&e->lock);
202 if (e->state != L2T_STATE_SWITCHING) {
203 send_pending(adap, e);
204 e->state = (e->neigh->nud_state & NUD_STALE) ?
205 L2T_STATE_STALE : L2T_STATE_VALID;
206 }
207 spin_unlock(&e->lock);
208 }
209}
210
211/*
212 * Add a packet to an L2T entry's queue of packets awaiting resolution.
213 * Must be called with the entry's lock held.
214 */
215static inline void arpq_enqueue(struct l2t_entry *e, struct sk_buff *skb)
216{
217 skb->next = NULL;
218 if (e->arpq_head)
219 e->arpq_tail->next = skb;
220 else
221 e->arpq_head = skb;
222 e->arpq_tail = skb;
223}
224
225int cxgb4_l2t_send(struct net_device *dev, struct sk_buff *skb,
226 struct l2t_entry *e)
227{
228 struct adapter *adap = netdev2adap(dev);
229
230again:
231 switch (e->state) {
232 case L2T_STATE_STALE: /* entry is stale, kick off revalidation */
233 neigh_event_send(e->neigh, NULL);
234 spin_lock_bh(&e->lock);
235 if (e->state == L2T_STATE_STALE)
236 e->state = L2T_STATE_VALID;
237 spin_unlock_bh(&e->lock);
238 case L2T_STATE_VALID: /* fast-path, send the packet on */
239 return t4_ofld_send(adap, skb);
240 case L2T_STATE_RESOLVING:
241 case L2T_STATE_SYNC_WRITE:
242 spin_lock_bh(&e->lock);
243 if (e->state != L2T_STATE_SYNC_WRITE &&
244 e->state != L2T_STATE_RESOLVING) {
245 spin_unlock_bh(&e->lock);
246 goto again;
247 }
248 arpq_enqueue(e, skb);
249 spin_unlock_bh(&e->lock);
250
251 if (e->state == L2T_STATE_RESOLVING &&
252 !neigh_event_send(e->neigh, NULL)) {
253 spin_lock_bh(&e->lock);
254 if (e->state == L2T_STATE_RESOLVING && e->arpq_head)
255 write_l2e(adap, e, 1);
256 spin_unlock_bh(&e->lock);
257 }
258 }
259 return 0;
260}
261EXPORT_SYMBOL(cxgb4_l2t_send);
262
263/*
264 * Allocate a free L2T entry. Must be called with l2t_data.lock held.
265 */
266static struct l2t_entry *alloc_l2e(struct l2t_data *d)
267{
268 struct l2t_entry *end, *e, **p;
269
270 if (!atomic_read(&d->nfree))
271 return NULL;
272
273 /* there's definitely a free entry */
274 for (e = d->rover, end = &d->l2tab[L2T_SIZE]; e != end; ++e)
275 if (atomic_read(&e->refcnt) == 0)
276 goto found;
277
278 for (e = d->l2tab; atomic_read(&e->refcnt); ++e)
279 ;
280found:
281 d->rover = e + 1;
282 atomic_dec(&d->nfree);
283
284 /*
285 * The entry we found may be an inactive entry that is
286 * presently in the hash table. We need to remove it.
287 */
288 if (e->state < L2T_STATE_SWITCHING)
289 for (p = &d->l2tab[e->hash].first; *p; p = &(*p)->next)
290 if (*p == e) {
291 *p = e->next;
292 e->next = NULL;
293 break;
294 }
295
296 e->state = L2T_STATE_UNUSED;
297 return e;
298}
299
300/*
301 * Called when an L2T entry has no more users.
302 */
303static void t4_l2e_free(struct l2t_entry *e)
304{
305 struct l2t_data *d;
306
307 spin_lock_bh(&e->lock);
308 if (atomic_read(&e->refcnt) == 0) { /* hasn't been recycled */
309 if (e->neigh) {
310 neigh_release(e->neigh);
311 e->neigh = NULL;
312 }
313 }
314 spin_unlock_bh(&e->lock);
315
316 d = container_of(e, struct l2t_data, l2tab[e->idx]);
317 atomic_inc(&d->nfree);
318}
319
320void cxgb4_l2t_release(struct l2t_entry *e)
321{
322 if (atomic_dec_and_test(&e->refcnt))
323 t4_l2e_free(e);
324}
325EXPORT_SYMBOL(cxgb4_l2t_release);
326
327/*
328 * Update an L2T entry that was previously used for the same next hop as neigh.
329 * Must be called with softirqs disabled.
330 */
331static void reuse_entry(struct l2t_entry *e, struct neighbour *neigh)
332{
333 unsigned int nud_state;
334
335 spin_lock(&e->lock); /* avoid race with t4_l2t_free */
336 if (neigh != e->neigh)
337 neigh_replace(e, neigh);
338 nud_state = neigh->nud_state;
339 if (memcmp(e->dmac, neigh->ha, sizeof(e->dmac)) ||
340 !(nud_state & NUD_VALID))
341 e->state = L2T_STATE_RESOLVING;
342 else if (nud_state & NUD_CONNECTED)
343 e->state = L2T_STATE_VALID;
344 else
345 e->state = L2T_STATE_STALE;
346 spin_unlock(&e->lock);
347}
348
349struct l2t_entry *cxgb4_l2t_get(struct l2t_data *d, struct neighbour *neigh,
350 const struct net_device *physdev,
351 unsigned int priority)
352{
353 u8 lport;
354 u16 vlan;
355 struct l2t_entry *e;
356 int addr_len = neigh->tbl->key_len;
357 u32 *addr = (u32 *)neigh->primary_key;
358 int ifidx = neigh->dev->ifindex;
359 int hash = addr_hash(addr, addr_len, ifidx);
360
361 if (neigh->dev->flags & IFF_LOOPBACK)
362 lport = netdev2pinfo(physdev)->tx_chan + 4;
363 else
364 lport = netdev2pinfo(physdev)->lport;
365
366 if (neigh->dev->priv_flags & IFF_802_1Q_VLAN)
367 vlan = vlan_dev_vlan_id(neigh->dev);
368 else
369 vlan = VLAN_NONE;
370
371 write_lock_bh(&d->lock);
372 for (e = d->l2tab[hash].first; e; e = e->next)
373 if (!addreq(e, addr) && e->ifindex == ifidx &&
374 e->vlan == vlan && e->lport == lport) {
375 l2t_hold(d, e);
376 if (atomic_read(&e->refcnt) == 1)
377 reuse_entry(e, neigh);
378 goto done;
379 }
380
381 /* Need to allocate a new entry */
382 e = alloc_l2e(d);
383 if (e) {
384 spin_lock(&e->lock); /* avoid race with t4_l2t_free */
385 e->state = L2T_STATE_RESOLVING;
386 memcpy(e->addr, addr, addr_len);
387 e->ifindex = ifidx;
388 e->hash = hash;
389 e->lport = lport;
390 e->v6 = addr_len == 16;
391 atomic_set(&e->refcnt, 1);
392 neigh_replace(e, neigh);
393 e->vlan = vlan;
394 e->next = d->l2tab[hash].first;
395 d->l2tab[hash].first = e;
396 spin_unlock(&e->lock);
397 }
398done:
399 write_unlock_bh(&d->lock);
400 return e;
401}
402EXPORT_SYMBOL(cxgb4_l2t_get);
403
404/*
405 * Called when address resolution fails for an L2T entry to handle packets
406 * on the arpq head. If a packet specifies a failure handler it is invoked,
407 * otherwise the packet is sent to the device.
408 */
409static void handle_failed_resolution(struct adapter *adap, struct sk_buff *arpq)
410{
411 while (arpq) {
412 struct sk_buff *skb = arpq;
413 const struct l2t_skb_cb *cb = L2T_SKB_CB(skb);
414
415 arpq = skb->next;
416 skb->next = NULL;
417 if (cb->arp_err_handler)
418 cb->arp_err_handler(cb->handle, skb);
419 else
420 t4_ofld_send(adap, skb);
421 }
422}
423
424/*
425 * Called when the host's neighbor layer makes a change to some entry that is
426 * loaded into the HW L2 table.
427 */
428void t4_l2t_update(struct adapter *adap, struct neighbour *neigh)
429{
430 struct l2t_entry *e;
431 struct sk_buff *arpq = NULL;
432 struct l2t_data *d = adap->l2t;
433 int addr_len = neigh->tbl->key_len;
434 u32 *addr = (u32 *) neigh->primary_key;
435 int ifidx = neigh->dev->ifindex;
436 int hash = addr_hash(addr, addr_len, ifidx);
437
438 read_lock_bh(&d->lock);
439 for (e = d->l2tab[hash].first; e; e = e->next)
440 if (!addreq(e, addr) && e->ifindex == ifidx) {
441 spin_lock(&e->lock);
442 if (atomic_read(&e->refcnt))
443 goto found;
444 spin_unlock(&e->lock);
445 break;
446 }
447 read_unlock_bh(&d->lock);
448 return;
449
450 found:
451 read_unlock(&d->lock);
452
453 if (neigh != e->neigh)
454 neigh_replace(e, neigh);
455
456 if (e->state == L2T_STATE_RESOLVING) {
457 if (neigh->nud_state & NUD_FAILED) {
458 arpq = e->arpq_head;
459 e->arpq_head = e->arpq_tail = NULL;
460 } else if ((neigh->nud_state & (NUD_CONNECTED | NUD_STALE)) &&
461 e->arpq_head) {
462 write_l2e(adap, e, 1);
463 }
464 } else {
465 e->state = neigh->nud_state & NUD_CONNECTED ?
466 L2T_STATE_VALID : L2T_STATE_STALE;
467 if (memcmp(e->dmac, neigh->ha, sizeof(e->dmac)))
468 write_l2e(adap, e, 0);
469 }
470
471 spin_unlock_bh(&e->lock);
472
473 if (arpq)
474 handle_failed_resolution(adap, arpq);
475}
476
477/*
478 * Allocate an L2T entry for use by a switching rule. Such entries need to be
479 * explicitly freed and while busy they are not on any hash chain, so normal
480 * address resolution updates do not see them.
481 */
482struct l2t_entry *t4_l2t_alloc_switching(struct l2t_data *d)
483{
484 struct l2t_entry *e;
485
486 write_lock_bh(&d->lock);
487 e = alloc_l2e(d);
488 if (e) {
489 spin_lock(&e->lock); /* avoid race with t4_l2t_free */
490 e->state = L2T_STATE_SWITCHING;
491 atomic_set(&e->refcnt, 1);
492 spin_unlock(&e->lock);
493 }
494 write_unlock_bh(&d->lock);
495 return e;
496}
497
498/*
499 * Sets/updates the contents of a switching L2T entry that has been allocated
500 * with an earlier call to @t4_l2t_alloc_switching.
501 */
502int t4_l2t_set_switching(struct adapter *adap, struct l2t_entry *e, u16 vlan,
503 u8 port, u8 *eth_addr)
504{
505 e->vlan = vlan;
506 e->lport = port;
507 memcpy(e->dmac, eth_addr, ETH_ALEN);
508 return write_l2e(adap, e, 0);
509}
510
511struct l2t_data *t4_init_l2t(void)
512{
513 int i;
514 struct l2t_data *d;
515
516 d = t4_alloc_mem(sizeof(*d));
517 if (!d)
518 return NULL;
519
520 d->rover = d->l2tab;
521 atomic_set(&d->nfree, L2T_SIZE);
522 rwlock_init(&d->lock);
523
524 for (i = 0; i < L2T_SIZE; ++i) {
525 d->l2tab[i].idx = i;
526 d->l2tab[i].state = L2T_STATE_UNUSED;
527 spin_lock_init(&d->l2tab[i].lock);
528 atomic_set(&d->l2tab[i].refcnt, 0);
529 }
530 return d;
531}
532
533#include <linux/module.h>
534#include <linux/debugfs.h>
535#include <linux/seq_file.h>
536
537static inline void *l2t_get_idx(struct seq_file *seq, loff_t pos)
538{
539 struct l2t_entry *l2tab = seq->private;
540
541 return pos >= L2T_SIZE ? NULL : &l2tab[pos];
542}
543
544static void *l2t_seq_start(struct seq_file *seq, loff_t *pos)
545{
546 return *pos ? l2t_get_idx(seq, *pos - 1) : SEQ_START_TOKEN;
547}
548
549static void *l2t_seq_next(struct seq_file *seq, void *v, loff_t *pos)
550{
551 v = l2t_get_idx(seq, *pos);
552 if (v)
553 ++*pos;
554 return v;
555}
556
557static void l2t_seq_stop(struct seq_file *seq, void *v)
558{
559}
560
561static char l2e_state(const struct l2t_entry *e)
562{
563 switch (e->state) {
564 case L2T_STATE_VALID: return 'V';
565 case L2T_STATE_STALE: return 'S';
566 case L2T_STATE_SYNC_WRITE: return 'W';
567 case L2T_STATE_RESOLVING: return e->arpq_head ? 'A' : 'R';
568 case L2T_STATE_SWITCHING: return 'X';
569 default:
570 return 'U';
571 }
572}
573
574static int l2t_seq_show(struct seq_file *seq, void *v)
575{
576 if (v == SEQ_START_TOKEN)
577 seq_puts(seq, " Idx IP address "
578 "Ethernet address VLAN/P LP State Users Port\n");
579 else {
580 char ip[60];
581 struct l2t_entry *e = v;
582
583 spin_lock_bh(&e->lock);
584 if (e->state == L2T_STATE_SWITCHING)
585 ip[0] = '\0';
586 else
587 sprintf(ip, e->v6 ? "%pI6c" : "%pI4", e->addr);
588 seq_printf(seq, "%4u %-25s %17pM %4d %u %2u %c %5u %s\n",
589 e->idx, ip, e->dmac,
590 e->vlan & VLAN_VID_MASK, vlan_prio(e), e->lport,
591 l2e_state(e), atomic_read(&e->refcnt),
592 e->neigh ? e->neigh->dev->name : "");
593 spin_unlock_bh(&e->lock);
594 }
595 return 0;
596}
597
598static const struct seq_operations l2t_seq_ops = {
599 .start = l2t_seq_start,
600 .next = l2t_seq_next,
601 .stop = l2t_seq_stop,
602 .show = l2t_seq_show
603};
604
605static int l2t_seq_open(struct inode *inode, struct file *file)
606{
607 int rc = seq_open(file, &l2t_seq_ops);
608
609 if (!rc) {
610 struct adapter *adap = inode->i_private;
611 struct seq_file *seq = file->private_data;
612
613 seq->private = adap->l2t->l2tab;
614 }
615 return rc;
616}
617
618const struct file_operations t4_l2t_fops = {
619 .owner = THIS_MODULE,
620 .open = l2t_seq_open,
621 .read = seq_read,
622 .llseek = seq_lseek,
623 .release = seq_release,
624};
diff --git a/drivers/net/cxgb4/l2t.h b/drivers/net/cxgb4/l2t.h
new file mode 100644
index 00000000000..643f27ed3cf
--- /dev/null
+++ b/drivers/net/cxgb4/l2t.h
@@ -0,0 +1,110 @@
1/*
2 * This file is part of the Chelsio T4 Ethernet driver for Linux.
3 *
4 * Copyright (c) 2003-2010 Chelsio Communications, Inc. All rights reserved.
5 *
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
11 *
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
14 * conditions are met:
15 *
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer.
19 *
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
24 *
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE.
33 */
34
35#ifndef __CXGB4_L2T_H
36#define __CXGB4_L2T_H
37
38#include <linux/spinlock.h>
39#include <linux/if_ether.h>
40#include <asm/atomic.h>
41
42struct adapter;
43struct l2t_data;
44struct neighbour;
45struct net_device;
46struct file_operations;
47struct cpl_l2t_write_rpl;
48
49/*
50 * Each L2T entry plays multiple roles. First of all, it keeps state for the
51 * corresponding entry of the HW L2 table and maintains a queue of offload
52 * packets awaiting address resolution. Second, it is a node of a hash table
53 * chain, where the nodes of the chain are linked together through their next
54 * pointer. Finally, each node is a bucket of a hash table, pointing to the
55 * first element in its chain through its first pointer.
56 */
57struct l2t_entry {
58 u16 state; /* entry state */
59 u16 idx; /* entry index */
60 u32 addr[4]; /* next hop IP or IPv6 address */
61 int ifindex; /* neighbor's net_device's ifindex */
62 struct neighbour *neigh; /* associated neighbour */
63 struct l2t_entry *first; /* start of hash chain */
64 struct l2t_entry *next; /* next l2t_entry on chain */
65 struct sk_buff *arpq_head; /* queue of packets awaiting resolution */
66 struct sk_buff *arpq_tail;
67 spinlock_t lock;
68 atomic_t refcnt; /* entry reference count */
69 u16 hash; /* hash bucket the entry is on */
70 u16 vlan; /* VLAN TCI (id: bits 0-11, prio: 13-15 */
71 u8 v6; /* whether entry is for IPv6 */
72 u8 lport; /* associated offload logical interface */
73 u8 dmac[ETH_ALEN]; /* neighbour's MAC address */
74};
75
76typedef void (*arp_err_handler_t)(void *handle, struct sk_buff *skb);
77
78/*
79 * Callback stored in an skb to handle address resolution failure.
80 */
81struct l2t_skb_cb {
82 void *handle;
83 arp_err_handler_t arp_err_handler;
84};
85
86#define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
87
88static inline void t4_set_arp_err_handler(struct sk_buff *skb, void *handle,
89 arp_err_handler_t handler)
90{
91 L2T_SKB_CB(skb)->handle = handle;
92 L2T_SKB_CB(skb)->arp_err_handler = handler;
93}
94
95void cxgb4_l2t_release(struct l2t_entry *e);
96int cxgb4_l2t_send(struct net_device *dev, struct sk_buff *skb,
97 struct l2t_entry *e);
98struct l2t_entry *cxgb4_l2t_get(struct l2t_data *d, struct neighbour *neigh,
99 const struct net_device *physdev,
100 unsigned int priority);
101
102void t4_l2t_update(struct adapter *adap, struct neighbour *neigh);
103struct l2t_entry *t4_l2t_alloc_switching(struct l2t_data *d);
104int t4_l2t_set_switching(struct adapter *adap, struct l2t_entry *e, u16 vlan,
105 u8 port, u8 *eth_addr);
106struct l2t_data *t4_init_l2t(void);
107void do_l2t_write_rpl(struct adapter *p, const struct cpl_l2t_write_rpl *rpl);
108
109extern const struct file_operations t4_l2t_fops;
110#endif /* __CXGB4_L2T_H */
diff --git a/drivers/net/cxgb4/sge.c b/drivers/net/cxgb4/sge.c
new file mode 100644
index 00000000000..14adc58e71c
--- /dev/null
+++ b/drivers/net/cxgb4/sge.c
@@ -0,0 +1,2431 @@
1/*
2 * This file is part of the Chelsio T4 Ethernet driver for Linux.
3 *
4 * Copyright (c) 2003-2010 Chelsio Communications, Inc. All rights reserved.
5 *
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
11 *
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
14 * conditions are met:
15 *
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer.
19 *
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
24 *
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE.
33 */
34
35#include <linux/skbuff.h>
36#include <linux/netdevice.h>
37#include <linux/etherdevice.h>
38#include <linux/if_vlan.h>
39#include <linux/ip.h>
40#include <linux/dma-mapping.h>
41#include <linux/jiffies.h>
42#include <net/ipv6.h>
43#include <net/tcp.h>
44#include "cxgb4.h"
45#include "t4_regs.h"
46#include "t4_msg.h"
47#include "t4fw_api.h"
48
49/*
50 * Rx buffer size. We use largish buffers if possible but settle for single
51 * pages under memory shortage.
52 */
53#if PAGE_SHIFT >= 16
54# define FL_PG_ORDER 0
55#else
56# define FL_PG_ORDER (16 - PAGE_SHIFT)
57#endif
58
59/* RX_PULL_LEN should be <= RX_COPY_THRES */
60#define RX_COPY_THRES 256
61#define RX_PULL_LEN 128
62
63/*
64 * Main body length for sk_buffs used for Rx Ethernet packets with fragments.
65 * Should be >= RX_PULL_LEN but possibly bigger to give pskb_may_pull some room.
66 */
67#define RX_PKT_SKB_LEN 512
68
69/* Ethernet header padding prepended to RX_PKTs */
70#define RX_PKT_PAD 2
71
72/*
73 * Max number of Tx descriptors we clean up at a time. Should be modest as
74 * freeing skbs isn't cheap and it happens while holding locks. We just need
75 * to free packets faster than they arrive, we eventually catch up and keep
76 * the amortized cost reasonable. Must be >= 2 * TXQ_STOP_THRES.
77 */
78#define MAX_TX_RECLAIM 16
79
80/*
81 * Max number of Rx buffers we replenish at a time. Again keep this modest,
82 * allocating buffers isn't cheap either.
83 */
84#define MAX_RX_REFILL 16U
85
86/*
87 * Period of the Rx queue check timer. This timer is infrequent as it has
88 * something to do only when the system experiences severe memory shortage.
89 */
90#define RX_QCHECK_PERIOD (HZ / 2)
91
92/*
93 * Period of the Tx queue check timer.
94 */
95#define TX_QCHECK_PERIOD (HZ / 2)
96
97/*
98 * Max number of Tx descriptors to be reclaimed by the Tx timer.
99 */
100#define MAX_TIMER_TX_RECLAIM 100
101
102/*
103 * Timer index used when backing off due to memory shortage.
104 */
105#define NOMEM_TMR_IDX (SGE_NTIMERS - 1)
106
107/*
108 * An FL with <= FL_STARVE_THRES buffers is starving and a periodic timer will
109 * attempt to refill it.
110 */
111#define FL_STARVE_THRES 4
112
113/*
114 * Suspend an Ethernet Tx queue with fewer available descriptors than this.
115 * This is the same as calc_tx_descs() for a TSO packet with
116 * nr_frags == MAX_SKB_FRAGS.
117 */
118#define ETHTXQ_STOP_THRES \
119 (1 + DIV_ROUND_UP((3 * MAX_SKB_FRAGS) / 2 + (MAX_SKB_FRAGS & 1), 8))
120
121/*
122 * Suspension threshold for non-Ethernet Tx queues. We require enough room
123 * for a full sized WR.
124 */
125#define TXQ_STOP_THRES (SGE_MAX_WR_LEN / sizeof(struct tx_desc))
126
127/*
128 * Max Tx descriptor space we allow for an Ethernet packet to be inlined
129 * into a WR.
130 */
131#define MAX_IMM_TX_PKT_LEN 128
132
133/*
134 * Max size of a WR sent through a control Tx queue.
135 */
136#define MAX_CTRL_WR_LEN SGE_MAX_WR_LEN
137
138enum {
139 /* packet alignment in FL buffers */
140 FL_ALIGN = L1_CACHE_BYTES < 32 ? 32 : L1_CACHE_BYTES,
141 /* egress status entry size */
142 STAT_LEN = L1_CACHE_BYTES > 64 ? 128 : 64
143};
144
145struct tx_sw_desc { /* SW state per Tx descriptor */
146 struct sk_buff *skb;
147 struct ulptx_sgl *sgl;
148};
149
150struct rx_sw_desc { /* SW state per Rx descriptor */
151 struct page *page;
152 dma_addr_t dma_addr;
153};
154
155/*
156 * The low bits of rx_sw_desc.dma_addr have special meaning.
157 */
158enum {
159 RX_LARGE_BUF = 1 << 0, /* buffer is larger than PAGE_SIZE */
160 RX_UNMAPPED_BUF = 1 << 1, /* buffer is not mapped */
161};
162
163static inline dma_addr_t get_buf_addr(const struct rx_sw_desc *d)
164{
165 return d->dma_addr & ~(dma_addr_t)(RX_LARGE_BUF | RX_UNMAPPED_BUF);
166}
167
168static inline bool is_buf_mapped(const struct rx_sw_desc *d)
169{
170 return !(d->dma_addr & RX_UNMAPPED_BUF);
171}
172
173/**
174 * txq_avail - return the number of available slots in a Tx queue
175 * @q: the Tx queue
176 *
177 * Returns the number of descriptors in a Tx queue available to write new
178 * packets.
179 */
180static inline unsigned int txq_avail(const struct sge_txq *q)
181{
182 return q->size - 1 - q->in_use;
183}
184
185/**
186 * fl_cap - return the capacity of a free-buffer list
187 * @fl: the FL
188 *
189 * Returns the capacity of a free-buffer list. The capacity is less than
190 * the size because one descriptor needs to be left unpopulated, otherwise
191 * HW will think the FL is empty.
192 */
193static inline unsigned int fl_cap(const struct sge_fl *fl)
194{
195 return fl->size - 8; /* 1 descriptor = 8 buffers */
196}
197
198static inline bool fl_starving(const struct sge_fl *fl)
199{
200 return fl->avail - fl->pend_cred <= FL_STARVE_THRES;
201}
202
203static int map_skb(struct device *dev, const struct sk_buff *skb,
204 dma_addr_t *addr)
205{
206 const skb_frag_t *fp, *end;
207 const struct skb_shared_info *si;
208
209 *addr = dma_map_single(dev, skb->data, skb_headlen(skb), DMA_TO_DEVICE);
210 if (dma_mapping_error(dev, *addr))
211 goto out_err;
212
213 si = skb_shinfo(skb);
214 end = &si->frags[si->nr_frags];
215
216 for (fp = si->frags; fp < end; fp++) {
217 *++addr = dma_map_page(dev, fp->page, fp->page_offset, fp->size,
218 DMA_TO_DEVICE);
219 if (dma_mapping_error(dev, *addr))
220 goto unwind;
221 }
222 return 0;
223
224unwind:
225 while (fp-- > si->frags)
226 dma_unmap_page(dev, *--addr, fp->size, DMA_TO_DEVICE);
227
228 dma_unmap_single(dev, addr[-1], skb_headlen(skb), DMA_TO_DEVICE);
229out_err:
230 return -ENOMEM;
231}
232
233#ifdef CONFIG_NEED_DMA_MAP_STATE
234static void unmap_skb(struct device *dev, const struct sk_buff *skb,
235 const dma_addr_t *addr)
236{
237 const skb_frag_t *fp, *end;
238 const struct skb_shared_info *si;
239
240 dma_unmap_single(dev, *addr++, skb_headlen(skb), DMA_TO_DEVICE);
241
242 si = skb_shinfo(skb);
243 end = &si->frags[si->nr_frags];
244 for (fp = si->frags; fp < end; fp++)
245 dma_unmap_page(dev, *addr++, fp->size, DMA_TO_DEVICE);
246}
247
248/**
249 * deferred_unmap_destructor - unmap a packet when it is freed
250 * @skb: the packet
251 *
252 * This is the packet destructor used for Tx packets that need to remain
253 * mapped until they are freed rather than until their Tx descriptors are
254 * freed.
255 */
256static void deferred_unmap_destructor(struct sk_buff *skb)
257{
258 unmap_skb(skb->dev->dev.parent, skb, (dma_addr_t *)skb->head);
259}
260#endif
261
262static void unmap_sgl(struct device *dev, const struct sk_buff *skb,
263 const struct ulptx_sgl *sgl, const struct sge_txq *q)
264{
265 const struct ulptx_sge_pair *p;
266 unsigned int nfrags = skb_shinfo(skb)->nr_frags;
267
268 if (likely(skb_headlen(skb)))
269 dma_unmap_single(dev, be64_to_cpu(sgl->addr0), ntohl(sgl->len0),
270 DMA_TO_DEVICE);
271 else {
272 dma_unmap_page(dev, be64_to_cpu(sgl->addr0), ntohl(sgl->len0),
273 DMA_TO_DEVICE);
274 nfrags--;
275 }
276
277 /*
278 * the complexity below is because of the possibility of a wrap-around
279 * in the middle of an SGL
280 */
281 for (p = sgl->sge; nfrags >= 2; nfrags -= 2) {
282 if (likely((u8 *)(p + 1) <= (u8 *)q->stat)) {
283unmap: dma_unmap_page(dev, be64_to_cpu(p->addr[0]),
284 ntohl(p->len[0]), DMA_TO_DEVICE);
285 dma_unmap_page(dev, be64_to_cpu(p->addr[1]),
286 ntohl(p->len[1]), DMA_TO_DEVICE);
287 p++;
288 } else if ((u8 *)p == (u8 *)q->stat) {
289 p = (const struct ulptx_sge_pair *)q->desc;
290 goto unmap;
291 } else if ((u8 *)p + 8 == (u8 *)q->stat) {
292 const __be64 *addr = (const __be64 *)q->desc;
293
294 dma_unmap_page(dev, be64_to_cpu(addr[0]),
295 ntohl(p->len[0]), DMA_TO_DEVICE);
296 dma_unmap_page(dev, be64_to_cpu(addr[1]),
297 ntohl(p->len[1]), DMA_TO_DEVICE);
298 p = (const struct ulptx_sge_pair *)&addr[2];
299 } else {
300 const __be64 *addr = (const __be64 *)q->desc;
301
302 dma_unmap_page(dev, be64_to_cpu(p->addr[0]),
303 ntohl(p->len[0]), DMA_TO_DEVICE);
304 dma_unmap_page(dev, be64_to_cpu(addr[0]),
305 ntohl(p->len[1]), DMA_TO_DEVICE);
306 p = (const struct ulptx_sge_pair *)&addr[1];
307 }
308 }
309 if (nfrags) {
310 __be64 addr;
311
312 if ((u8 *)p == (u8 *)q->stat)
313 p = (const struct ulptx_sge_pair *)q->desc;
314 addr = (u8 *)p + 16 <= (u8 *)q->stat ? p->addr[0] :
315 *(const __be64 *)q->desc;
316 dma_unmap_page(dev, be64_to_cpu(addr), ntohl(p->len[0]),
317 DMA_TO_DEVICE);
318 }
319}
320
321/**
322 * free_tx_desc - reclaims Tx descriptors and their buffers
323 * @adapter: the adapter
324 * @q: the Tx queue to reclaim descriptors from
325 * @n: the number of descriptors to reclaim
326 * @unmap: whether the buffers should be unmapped for DMA
327 *
328 * Reclaims Tx descriptors from an SGE Tx queue and frees the associated
329 * Tx buffers. Called with the Tx queue lock held.
330 */
331static void free_tx_desc(struct adapter *adap, struct sge_txq *q,
332 unsigned int n, bool unmap)
333{
334 struct tx_sw_desc *d;
335 unsigned int cidx = q->cidx;
336 struct device *dev = adap->pdev_dev;
337
338 d = &q->sdesc[cidx];
339 while (n--) {
340 if (d->skb) { /* an SGL is present */
341 if (unmap)
342 unmap_sgl(dev, d->skb, d->sgl, q);
343 kfree_skb(d->skb);
344 d->skb = NULL;
345 }
346 ++d;
347 if (++cidx == q->size) {
348 cidx = 0;
349 d = q->sdesc;
350 }
351 }
352 q->cidx = cidx;
353}
354
355/*
356 * Return the number of reclaimable descriptors in a Tx queue.
357 */
358static inline int reclaimable(const struct sge_txq *q)
359{
360 int hw_cidx = ntohs(q->stat->cidx);
361 hw_cidx -= q->cidx;
362 return hw_cidx < 0 ? hw_cidx + q->size : hw_cidx;
363}
364
365/**
366 * reclaim_completed_tx - reclaims completed Tx descriptors
367 * @adap: the adapter
368 * @q: the Tx queue to reclaim completed descriptors from
369 * @unmap: whether the buffers should be unmapped for DMA
370 *
371 * Reclaims Tx descriptors that the SGE has indicated it has processed,
372 * and frees the associated buffers if possible. Called with the Tx
373 * queue locked.
374 */
375static inline void reclaim_completed_tx(struct adapter *adap, struct sge_txq *q,
376 bool unmap)
377{
378 int avail = reclaimable(q);
379
380 if (avail) {
381 /*
382 * Limit the amount of clean up work we do at a time to keep
383 * the Tx lock hold time O(1).
384 */
385 if (avail > MAX_TX_RECLAIM)
386 avail = MAX_TX_RECLAIM;
387
388 free_tx_desc(adap, q, avail, unmap);
389 q->in_use -= avail;
390 }
391}
392
393static inline int get_buf_size(const struct rx_sw_desc *d)
394{
395#if FL_PG_ORDER > 0
396 return (d->dma_addr & RX_LARGE_BUF) ? (PAGE_SIZE << FL_PG_ORDER) :
397 PAGE_SIZE;
398#else
399 return PAGE_SIZE;
400#endif
401}
402
403/**
404 * free_rx_bufs - free the Rx buffers on an SGE free list
405 * @adap: the adapter
406 * @q: the SGE free list to free buffers from
407 * @n: how many buffers to free
408 *
409 * Release the next @n buffers on an SGE free-buffer Rx queue. The
410 * buffers must be made inaccessible to HW before calling this function.
411 */
412static void free_rx_bufs(struct adapter *adap, struct sge_fl *q, int n)
413{
414 while (n--) {
415 struct rx_sw_desc *d = &q->sdesc[q->cidx];
416
417 if (is_buf_mapped(d))
418 dma_unmap_page(adap->pdev_dev, get_buf_addr(d),
419 get_buf_size(d), PCI_DMA_FROMDEVICE);
420 put_page(d->page);
421 d->page = NULL;
422 if (++q->cidx == q->size)
423 q->cidx = 0;
424 q->avail--;
425 }
426}
427
428/**
429 * unmap_rx_buf - unmap the current Rx buffer on an SGE free list
430 * @adap: the adapter
431 * @q: the SGE free list
432 *
433 * Unmap the current buffer on an SGE free-buffer Rx queue. The
434 * buffer must be made inaccessible to HW before calling this function.
435 *
436 * This is similar to @free_rx_bufs above but does not free the buffer.
437 * Do note that the FL still loses any further access to the buffer.
438 */
439static void unmap_rx_buf(struct adapter *adap, struct sge_fl *q)
440{
441 struct rx_sw_desc *d = &q->sdesc[q->cidx];
442
443 if (is_buf_mapped(d))
444 dma_unmap_page(adap->pdev_dev, get_buf_addr(d),
445 get_buf_size(d), PCI_DMA_FROMDEVICE);
446 d->page = NULL;
447 if (++q->cidx == q->size)
448 q->cidx = 0;
449 q->avail--;
450}
451
452static inline void ring_fl_db(struct adapter *adap, struct sge_fl *q)
453{
454 if (q->pend_cred >= 8) {
455 wmb();
456 t4_write_reg(adap, MYPF_REG(SGE_PF_KDOORBELL), DBPRIO |
457 QID(q->cntxt_id) | PIDX(q->pend_cred / 8));
458 q->pend_cred &= 7;
459 }
460}
461
462static inline void set_rx_sw_desc(struct rx_sw_desc *sd, struct page *pg,
463 dma_addr_t mapping)
464{
465 sd->page = pg;
466 sd->dma_addr = mapping; /* includes size low bits */
467}
468
469/**
470 * refill_fl - refill an SGE Rx buffer ring
471 * @adap: the adapter
472 * @q: the ring to refill
473 * @n: the number of new buffers to allocate
474 * @gfp: the gfp flags for the allocations
475 *
476 * (Re)populate an SGE free-buffer queue with up to @n new packet buffers,
477 * allocated with the supplied gfp flags. The caller must assure that
478 * @n does not exceed the queue's capacity. If afterwards the queue is
479 * found critically low mark it as starving in the bitmap of starving FLs.
480 *
481 * Returns the number of buffers allocated.
482 */
483static unsigned int refill_fl(struct adapter *adap, struct sge_fl *q, int n,
484 gfp_t gfp)
485{
486 struct page *pg;
487 dma_addr_t mapping;
488 unsigned int cred = q->avail;
489 __be64 *d = &q->desc[q->pidx];
490 struct rx_sw_desc *sd = &q->sdesc[q->pidx];
491
492 gfp |= __GFP_NOWARN; /* failures are expected */
493
494#if FL_PG_ORDER > 0
495 /*
496 * Prefer large buffers
497 */
498 while (n) {
499 pg = alloc_pages(gfp | __GFP_COMP, FL_PG_ORDER);
500 if (unlikely(!pg)) {
501 q->large_alloc_failed++;
502 break; /* fall back to single pages */
503 }
504
505 mapping = dma_map_page(adap->pdev_dev, pg, 0,
506 PAGE_SIZE << FL_PG_ORDER,
507 PCI_DMA_FROMDEVICE);
508 if (unlikely(dma_mapping_error(adap->pdev_dev, mapping))) {
509 __free_pages(pg, FL_PG_ORDER);
510 goto out; /* do not try small pages for this error */
511 }
512 mapping |= RX_LARGE_BUF;
513 *d++ = cpu_to_be64(mapping);
514
515 set_rx_sw_desc(sd, pg, mapping);
516 sd++;
517
518 q->avail++;
519 if (++q->pidx == q->size) {
520 q->pidx = 0;
521 sd = q->sdesc;
522 d = q->desc;
523 }
524 n--;
525 }
526#endif
527
528 while (n--) {
529 pg = __netdev_alloc_page(adap->port[0], gfp);
530 if (unlikely(!pg)) {
531 q->alloc_failed++;
532 break;
533 }
534
535 mapping = dma_map_page(adap->pdev_dev, pg, 0, PAGE_SIZE,
536 PCI_DMA_FROMDEVICE);
537 if (unlikely(dma_mapping_error(adap->pdev_dev, mapping))) {
538 netdev_free_page(adap->port[0], pg);
539 goto out;
540 }
541 *d++ = cpu_to_be64(mapping);
542
543 set_rx_sw_desc(sd, pg, mapping);
544 sd++;
545
546 q->avail++;
547 if (++q->pidx == q->size) {
548 q->pidx = 0;
549 sd = q->sdesc;
550 d = q->desc;
551 }
552 }
553
554out: cred = q->avail - cred;
555 q->pend_cred += cred;
556 ring_fl_db(adap, q);
557
558 if (unlikely(fl_starving(q))) {
559 smp_wmb();
560 set_bit(q->cntxt_id, adap->sge.starving_fl);
561 }
562
563 return cred;
564}
565
566static inline void __refill_fl(struct adapter *adap, struct sge_fl *fl)
567{
568 refill_fl(adap, fl, min(MAX_RX_REFILL, fl_cap(fl) - fl->avail),
569 GFP_ATOMIC);
570}
571
572/**
573 * alloc_ring - allocate resources for an SGE descriptor ring
574 * @dev: the PCI device's core device
575 * @nelem: the number of descriptors
576 * @elem_size: the size of each descriptor
577 * @sw_size: the size of the SW state associated with each ring element
578 * @phys: the physical address of the allocated ring
579 * @metadata: address of the array holding the SW state for the ring
580 * @stat_size: extra space in HW ring for status information
581 *
582 * Allocates resources for an SGE descriptor ring, such as Tx queues,
583 * free buffer lists, or response queues. Each SGE ring requires
584 * space for its HW descriptors plus, optionally, space for the SW state
585 * associated with each HW entry (the metadata). The function returns
586 * three values: the virtual address for the HW ring (the return value
587 * of the function), the bus address of the HW ring, and the address
588 * of the SW ring.
589 */
590static void *alloc_ring(struct device *dev, size_t nelem, size_t elem_size,
591 size_t sw_size, dma_addr_t *phys, void *metadata,
592 size_t stat_size)
593{
594 size_t len = nelem * elem_size + stat_size;
595 void *s = NULL;
596 void *p = dma_alloc_coherent(dev, len, phys, GFP_KERNEL);
597
598 if (!p)
599 return NULL;
600 if (sw_size) {
601 s = kcalloc(nelem, sw_size, GFP_KERNEL);
602
603 if (!s) {
604 dma_free_coherent(dev, len, p, *phys);
605 return NULL;
606 }
607 }
608 if (metadata)
609 *(void **)metadata = s;
610 memset(p, 0, len);
611 return p;
612}
613
614/**
615 * sgl_len - calculates the size of an SGL of the given capacity
616 * @n: the number of SGL entries
617 *
618 * Calculates the number of flits needed for a scatter/gather list that
619 * can hold the given number of entries.
620 */
621static inline unsigned int sgl_len(unsigned int n)
622{
623 n--;
624 return (3 * n) / 2 + (n & 1) + 2;
625}
626
627/**
628 * flits_to_desc - returns the num of Tx descriptors for the given flits
629 * @n: the number of flits
630 *
631 * Returns the number of Tx descriptors needed for the supplied number
632 * of flits.
633 */
634static inline unsigned int flits_to_desc(unsigned int n)
635{
636 BUG_ON(n > SGE_MAX_WR_LEN / 8);
637 return DIV_ROUND_UP(n, 8);
638}
639
640/**
641 * is_eth_imm - can an Ethernet packet be sent as immediate data?
642 * @skb: the packet
643 *
644 * Returns whether an Ethernet packet is small enough to fit as
645 * immediate data.
646 */
647static inline int is_eth_imm(const struct sk_buff *skb)
648{
649 return skb->len <= MAX_IMM_TX_PKT_LEN - sizeof(struct cpl_tx_pkt);
650}
651
652/**
653 * calc_tx_flits - calculate the number of flits for a packet Tx WR
654 * @skb: the packet
655 *
656 * Returns the number of flits needed for a Tx WR for the given Ethernet
657 * packet, including the needed WR and CPL headers.
658 */
659static inline unsigned int calc_tx_flits(const struct sk_buff *skb)
660{
661 unsigned int flits;
662
663 if (is_eth_imm(skb))
664 return DIV_ROUND_UP(skb->len + sizeof(struct cpl_tx_pkt), 8);
665
666 flits = sgl_len(skb_shinfo(skb)->nr_frags + 1) + 4;
667 if (skb_shinfo(skb)->gso_size)
668 flits += 2;
669 return flits;
670}
671
672/**
673 * calc_tx_descs - calculate the number of Tx descriptors for a packet
674 * @skb: the packet
675 *
676 * Returns the number of Tx descriptors needed for the given Ethernet
677 * packet, including the needed WR and CPL headers.
678 */
679static inline unsigned int calc_tx_descs(const struct sk_buff *skb)
680{
681 return flits_to_desc(calc_tx_flits(skb));
682}
683
684/**
685 * write_sgl - populate a scatter/gather list for a packet
686 * @skb: the packet
687 * @q: the Tx queue we are writing into
688 * @sgl: starting location for writing the SGL
689 * @end: points right after the end of the SGL
690 * @start: start offset into skb main-body data to include in the SGL
691 * @addr: the list of bus addresses for the SGL elements
692 *
693 * Generates a gather list for the buffers that make up a packet.
694 * The caller must provide adequate space for the SGL that will be written.
695 * The SGL includes all of the packet's page fragments and the data in its
696 * main body except for the first @start bytes. @sgl must be 16-byte
697 * aligned and within a Tx descriptor with available space. @end points
698 * right after the end of the SGL but does not account for any potential
699 * wrap around, i.e., @end > @sgl.
700 */
701static void write_sgl(const struct sk_buff *skb, struct sge_txq *q,
702 struct ulptx_sgl *sgl, u64 *end, unsigned int start,
703 const dma_addr_t *addr)
704{
705 unsigned int i, len;
706 struct ulptx_sge_pair *to;
707 const struct skb_shared_info *si = skb_shinfo(skb);
708 unsigned int nfrags = si->nr_frags;
709 struct ulptx_sge_pair buf[MAX_SKB_FRAGS / 2 + 1];
710
711 len = skb_headlen(skb) - start;
712 if (likely(len)) {
713 sgl->len0 = htonl(len);
714 sgl->addr0 = cpu_to_be64(addr[0] + start);
715 nfrags++;
716 } else {
717 sgl->len0 = htonl(si->frags[0].size);
718 sgl->addr0 = cpu_to_be64(addr[1]);
719 }
720
721 sgl->cmd_nsge = htonl(ULPTX_CMD(ULP_TX_SC_DSGL) | ULPTX_NSGE(nfrags));
722 if (likely(--nfrags == 0))
723 return;
724 /*
725 * Most of the complexity below deals with the possibility we hit the
726 * end of the queue in the middle of writing the SGL. For this case
727 * only we create the SGL in a temporary buffer and then copy it.
728 */
729 to = (u8 *)end > (u8 *)q->stat ? buf : sgl->sge;
730
731 for (i = (nfrags != si->nr_frags); nfrags >= 2; nfrags -= 2, to++) {
732 to->len[0] = cpu_to_be32(si->frags[i].size);
733 to->len[1] = cpu_to_be32(si->frags[++i].size);
734 to->addr[0] = cpu_to_be64(addr[i]);
735 to->addr[1] = cpu_to_be64(addr[++i]);
736 }
737 if (nfrags) {
738 to->len[0] = cpu_to_be32(si->frags[i].size);
739 to->len[1] = cpu_to_be32(0);
740 to->addr[0] = cpu_to_be64(addr[i + 1]);
741 }
742 if (unlikely((u8 *)end > (u8 *)q->stat)) {
743 unsigned int part0 = (u8 *)q->stat - (u8 *)sgl->sge, part1;
744
745 if (likely(part0))
746 memcpy(sgl->sge, buf, part0);
747 part1 = (u8 *)end - (u8 *)q->stat;
748 memcpy(q->desc, (u8 *)buf + part0, part1);
749 end = (void *)q->desc + part1;
750 }
751 if ((uintptr_t)end & 8) /* 0-pad to multiple of 16 */
752 *(u64 *)end = 0;
753}
754
755/**
756 * ring_tx_db - check and potentially ring a Tx queue's doorbell
757 * @adap: the adapter
758 * @q: the Tx queue
759 * @n: number of new descriptors to give to HW
760 *
761 * Ring the doorbel for a Tx queue.
762 */
763static inline void ring_tx_db(struct adapter *adap, struct sge_txq *q, int n)
764{
765 wmb(); /* write descriptors before telling HW */
766 t4_write_reg(adap, MYPF_REG(SGE_PF_KDOORBELL),
767 QID(q->cntxt_id) | PIDX(n));
768}
769
770/**
771 * inline_tx_skb - inline a packet's data into Tx descriptors
772 * @skb: the packet
773 * @q: the Tx queue where the packet will be inlined
774 * @pos: starting position in the Tx queue where to inline the packet
775 *
776 * Inline a packet's contents directly into Tx descriptors, starting at
777 * the given position within the Tx DMA ring.
778 * Most of the complexity of this operation is dealing with wrap arounds
779 * in the middle of the packet we want to inline.
780 */
781static void inline_tx_skb(const struct sk_buff *skb, const struct sge_txq *q,
782 void *pos)
783{
784 u64 *p;
785 int left = (void *)q->stat - pos;
786
787 if (likely(skb->len <= left)) {
788 if (likely(!skb->data_len))
789 skb_copy_from_linear_data(skb, pos, skb->len);
790 else
791 skb_copy_bits(skb, 0, pos, skb->len);
792 pos += skb->len;
793 } else {
794 skb_copy_bits(skb, 0, pos, left);
795 skb_copy_bits(skb, left, q->desc, skb->len - left);
796 pos = (void *)q->desc + (skb->len - left);
797 }
798
799 /* 0-pad to multiple of 16 */
800 p = PTR_ALIGN(pos, 8);
801 if ((uintptr_t)p & 8)
802 *p = 0;
803}
804
805/*
806 * Figure out what HW csum a packet wants and return the appropriate control
807 * bits.
808 */
809static u64 hwcsum(const struct sk_buff *skb)
810{
811 int csum_type;
812 const struct iphdr *iph = ip_hdr(skb);
813
814 if (iph->version == 4) {
815 if (iph->protocol == IPPROTO_TCP)
816 csum_type = TX_CSUM_TCPIP;
817 else if (iph->protocol == IPPROTO_UDP)
818 csum_type = TX_CSUM_UDPIP;
819 else {
820nocsum: /*
821 * unknown protocol, disable HW csum
822 * and hope a bad packet is detected
823 */
824 return TXPKT_L4CSUM_DIS;
825 }
826 } else {
827 /*
828 * this doesn't work with extension headers
829 */
830 const struct ipv6hdr *ip6h = (const struct ipv6hdr *)iph;
831
832 if (ip6h->nexthdr == IPPROTO_TCP)
833 csum_type = TX_CSUM_TCPIP6;
834 else if (ip6h->nexthdr == IPPROTO_UDP)
835 csum_type = TX_CSUM_UDPIP6;
836 else
837 goto nocsum;
838 }
839
840 if (likely(csum_type >= TX_CSUM_TCPIP))
841 return TXPKT_CSUM_TYPE(csum_type) |
842 TXPKT_IPHDR_LEN(skb_network_header_len(skb)) |
843 TXPKT_ETHHDR_LEN(skb_network_offset(skb) - ETH_HLEN);
844 else {
845 int start = skb_transport_offset(skb);
846
847 return TXPKT_CSUM_TYPE(csum_type) | TXPKT_CSUM_START(start) |
848 TXPKT_CSUM_LOC(start + skb->csum_offset);
849 }
850}
851
852static void eth_txq_stop(struct sge_eth_txq *q)
853{
854 netif_tx_stop_queue(q->txq);
855 q->q.stops++;
856}
857
858static inline void txq_advance(struct sge_txq *q, unsigned int n)
859{
860 q->in_use += n;
861 q->pidx += n;
862 if (q->pidx >= q->size)
863 q->pidx -= q->size;
864}
865
866/**
867 * t4_eth_xmit - add a packet to an Ethernet Tx queue
868 * @skb: the packet
869 * @dev: the egress net device
870 *
871 * Add a packet to an SGE Ethernet Tx queue. Runs with softirqs disabled.
872 */
873netdev_tx_t t4_eth_xmit(struct sk_buff *skb, struct net_device *dev)
874{
875 u32 wr_mid;
876 u64 cntrl, *end;
877 int qidx, credits;
878 unsigned int flits, ndesc;
879 struct adapter *adap;
880 struct sge_eth_txq *q;
881 const struct port_info *pi;
882 struct fw_eth_tx_pkt_wr *wr;
883 struct cpl_tx_pkt_core *cpl;
884 const struct skb_shared_info *ssi;
885 dma_addr_t addr[MAX_SKB_FRAGS + 1];
886
887 /*
888 * The chip min packet length is 10 octets but play safe and reject
889 * anything shorter than an Ethernet header.
890 */
891 if (unlikely(skb->len < ETH_HLEN)) {
892out_free: dev_kfree_skb(skb);
893 return NETDEV_TX_OK;
894 }
895
896 pi = netdev_priv(dev);
897 adap = pi->adapter;
898 qidx = skb_get_queue_mapping(skb);
899 q = &adap->sge.ethtxq[qidx + pi->first_qset];
900
901 reclaim_completed_tx(adap, &q->q, true);
902
903 flits = calc_tx_flits(skb);
904 ndesc = flits_to_desc(flits);
905 credits = txq_avail(&q->q) - ndesc;
906
907 if (unlikely(credits < 0)) {
908 eth_txq_stop(q);
909 dev_err(adap->pdev_dev,
910 "%s: Tx ring %u full while queue awake!\n",
911 dev->name, qidx);
912 return NETDEV_TX_BUSY;
913 }
914
915 if (!is_eth_imm(skb) &&
916 unlikely(map_skb(adap->pdev_dev, skb, addr) < 0)) {
917 q->mapping_err++;
918 goto out_free;
919 }
920
921 wr_mid = FW_WR_LEN16(DIV_ROUND_UP(flits, 2));
922 if (unlikely(credits < ETHTXQ_STOP_THRES)) {
923 eth_txq_stop(q);
924 wr_mid |= FW_WR_EQUEQ | FW_WR_EQUIQ;
925 }
926
927 wr = (void *)&q->q.desc[q->q.pidx];
928 wr->equiq_to_len16 = htonl(wr_mid);
929 wr->r3 = cpu_to_be64(0);
930 end = (u64 *)wr + flits;
931
932 ssi = skb_shinfo(skb);
933 if (ssi->gso_size) {
934 struct cpl_tx_pkt_lso *lso = (void *)wr;
935 bool v6 = (ssi->gso_type & SKB_GSO_TCPV6) != 0;
936 int l3hdr_len = skb_network_header_len(skb);
937 int eth_xtra_len = skb_network_offset(skb) - ETH_HLEN;
938
939 wr->op_immdlen = htonl(FW_WR_OP(FW_ETH_TX_PKT_WR) |
940 FW_WR_IMMDLEN(sizeof(*lso)));
941 lso->lso_ctrl = htonl(LSO_OPCODE(CPL_TX_PKT_LSO) |
942 LSO_FIRST_SLICE | LSO_LAST_SLICE |
943 LSO_IPV6(v6) |
944 LSO_ETHHDR_LEN(eth_xtra_len / 4) |
945 LSO_IPHDR_LEN(l3hdr_len / 4) |
946 LSO_TCPHDR_LEN(tcp_hdr(skb)->doff));
947 lso->ipid_ofst = htons(0);
948 lso->mss = htons(ssi->gso_size);
949 lso->seqno_offset = htonl(0);
950 lso->len = htonl(skb->len);
951 cpl = (void *)(lso + 1);
952 cntrl = TXPKT_CSUM_TYPE(v6 ? TX_CSUM_TCPIP6 : TX_CSUM_TCPIP) |
953 TXPKT_IPHDR_LEN(l3hdr_len) |
954 TXPKT_ETHHDR_LEN(eth_xtra_len);
955 q->tso++;
956 q->tx_cso += ssi->gso_segs;
957 } else {
958 int len;
959
960 len = is_eth_imm(skb) ? skb->len + sizeof(*cpl) : sizeof(*cpl);
961 wr->op_immdlen = htonl(FW_WR_OP(FW_ETH_TX_PKT_WR) |
962 FW_WR_IMMDLEN(len));
963 cpl = (void *)(wr + 1);
964 if (skb->ip_summed == CHECKSUM_PARTIAL) {
965 cntrl = hwcsum(skb) | TXPKT_IPCSUM_DIS;
966 q->tx_cso++;
967 } else
968 cntrl = TXPKT_L4CSUM_DIS | TXPKT_IPCSUM_DIS;
969 }
970
971 if (vlan_tx_tag_present(skb)) {
972 q->vlan_ins++;
973 cntrl |= TXPKT_VLAN_VLD | TXPKT_VLAN(vlan_tx_tag_get(skb));
974 }
975
976 cpl->ctrl0 = htonl(TXPKT_OPCODE(CPL_TX_PKT_XT) |
977 TXPKT_INTF(pi->tx_chan) | TXPKT_PF(0));
978 cpl->pack = htons(0);
979 cpl->len = htons(skb->len);
980 cpl->ctrl1 = cpu_to_be64(cntrl);
981
982 if (is_eth_imm(skb)) {
983 inline_tx_skb(skb, &q->q, cpl + 1);
984 dev_kfree_skb(skb);
985 } else {
986 int last_desc;
987
988 write_sgl(skb, &q->q, (struct ulptx_sgl *)(cpl + 1), end, 0,
989 addr);
990 skb_orphan(skb);
991
992 last_desc = q->q.pidx + ndesc - 1;
993 if (last_desc >= q->q.size)
994 last_desc -= q->q.size;
995 q->q.sdesc[last_desc].skb = skb;
996 q->q.sdesc[last_desc].sgl = (struct ulptx_sgl *)(cpl + 1);
997 }
998
999 txq_advance(&q->q, ndesc);
1000
1001 ring_tx_db(adap, &q->q, ndesc);
1002 return NETDEV_TX_OK;
1003}
1004
1005/**
1006 * reclaim_completed_tx_imm - reclaim completed control-queue Tx descs
1007 * @q: the SGE control Tx queue
1008 *
1009 * This is a variant of reclaim_completed_tx() that is used for Tx queues
1010 * that send only immediate data (presently just the control queues) and
1011 * thus do not have any sk_buffs to release.
1012 */
1013static inline void reclaim_completed_tx_imm(struct sge_txq *q)
1014{
1015 int hw_cidx = ntohs(q->stat->cidx);
1016 int reclaim = hw_cidx - q->cidx;
1017
1018 if (reclaim < 0)
1019 reclaim += q->size;
1020
1021 q->in_use -= reclaim;
1022 q->cidx = hw_cidx;
1023}
1024
1025/**
1026 * is_imm - check whether a packet can be sent as immediate data
1027 * @skb: the packet
1028 *
1029 * Returns true if a packet can be sent as a WR with immediate data.
1030 */
1031static inline int is_imm(const struct sk_buff *skb)
1032{
1033 return skb->len <= MAX_CTRL_WR_LEN;
1034}
1035
1036/**
1037 * ctrlq_check_stop - check if a control queue is full and should stop
1038 * @q: the queue
1039 * @wr: most recent WR written to the queue
1040 *
1041 * Check if a control queue has become full and should be stopped.
1042 * We clean up control queue descriptors very lazily, only when we are out.
1043 * If the queue is still full after reclaiming any completed descriptors
1044 * we suspend it and have the last WR wake it up.
1045 */
1046static void ctrlq_check_stop(struct sge_ctrl_txq *q, struct fw_wr_hdr *wr)
1047{
1048 reclaim_completed_tx_imm(&q->q);
1049 if (unlikely(txq_avail(&q->q) < TXQ_STOP_THRES)) {
1050 wr->lo |= htonl(FW_WR_EQUEQ | FW_WR_EQUIQ);
1051 q->q.stops++;
1052 q->full = 1;
1053 }
1054}
1055
1056/**
1057 * ctrl_xmit - send a packet through an SGE control Tx queue
1058 * @q: the control queue
1059 * @skb: the packet
1060 *
1061 * Send a packet through an SGE control Tx queue. Packets sent through
1062 * a control queue must fit entirely as immediate data.
1063 */
1064static int ctrl_xmit(struct sge_ctrl_txq *q, struct sk_buff *skb)
1065{
1066 unsigned int ndesc;
1067 struct fw_wr_hdr *wr;
1068
1069 if (unlikely(!is_imm(skb))) {
1070 WARN_ON(1);
1071 dev_kfree_skb(skb);
1072 return NET_XMIT_DROP;
1073 }
1074
1075 ndesc = DIV_ROUND_UP(skb->len, sizeof(struct tx_desc));
1076 spin_lock(&q->sendq.lock);
1077
1078 if (unlikely(q->full)) {
1079 skb->priority = ndesc; /* save for restart */
1080 __skb_queue_tail(&q->sendq, skb);
1081 spin_unlock(&q->sendq.lock);
1082 return NET_XMIT_CN;
1083 }
1084
1085 wr = (struct fw_wr_hdr *)&q->q.desc[q->q.pidx];
1086 inline_tx_skb(skb, &q->q, wr);
1087
1088 txq_advance(&q->q, ndesc);
1089 if (unlikely(txq_avail(&q->q) < TXQ_STOP_THRES))
1090 ctrlq_check_stop(q, wr);
1091
1092 ring_tx_db(q->adap, &q->q, ndesc);
1093 spin_unlock(&q->sendq.lock);
1094
1095 kfree_skb(skb);
1096 return NET_XMIT_SUCCESS;
1097}
1098
1099/**
1100 * restart_ctrlq - restart a suspended control queue
1101 * @data: the control queue to restart
1102 *
1103 * Resumes transmission on a suspended Tx control queue.
1104 */
1105static void restart_ctrlq(unsigned long data)
1106{
1107 struct sk_buff *skb;
1108 unsigned int written = 0;
1109 struct sge_ctrl_txq *q = (struct sge_ctrl_txq *)data;
1110
1111 spin_lock(&q->sendq.lock);
1112 reclaim_completed_tx_imm(&q->q);
1113 BUG_ON(txq_avail(&q->q) < TXQ_STOP_THRES); /* q should be empty */
1114
1115 while ((skb = __skb_dequeue(&q->sendq)) != NULL) {
1116 struct fw_wr_hdr *wr;
1117 unsigned int ndesc = skb->priority; /* previously saved */
1118
1119 /*
1120 * Write descriptors and free skbs outside the lock to limit
1121 * wait times. q->full is still set so new skbs will be queued.
1122 */
1123 spin_unlock(&q->sendq.lock);
1124
1125 wr = (struct fw_wr_hdr *)&q->q.desc[q->q.pidx];
1126 inline_tx_skb(skb, &q->q, wr);
1127 kfree_skb(skb);
1128
1129 written += ndesc;
1130 txq_advance(&q->q, ndesc);
1131 if (unlikely(txq_avail(&q->q) < TXQ_STOP_THRES)) {
1132 unsigned long old = q->q.stops;
1133
1134 ctrlq_check_stop(q, wr);
1135 if (q->q.stops != old) { /* suspended anew */
1136 spin_lock(&q->sendq.lock);
1137 goto ringdb;
1138 }
1139 }
1140 if (written > 16) {
1141 ring_tx_db(q->adap, &q->q, written);
1142 written = 0;
1143 }
1144 spin_lock(&q->sendq.lock);
1145 }
1146 q->full = 0;
1147ringdb: if (written)
1148 ring_tx_db(q->adap, &q->q, written);
1149 spin_unlock(&q->sendq.lock);
1150}
1151
1152/**
1153 * t4_mgmt_tx - send a management message
1154 * @adap: the adapter
1155 * @skb: the packet containing the management message
1156 *
1157 * Send a management message through control queue 0.
1158 */
1159int t4_mgmt_tx(struct adapter *adap, struct sk_buff *skb)
1160{
1161 int ret;
1162
1163 local_bh_disable();
1164 ret = ctrl_xmit(&adap->sge.ctrlq[0], skb);
1165 local_bh_enable();
1166 return ret;
1167}
1168
1169/**
1170 * is_ofld_imm - check whether a packet can be sent as immediate data
1171 * @skb: the packet
1172 *
1173 * Returns true if a packet can be sent as an offload WR with immediate
1174 * data. We currently use the same limit as for Ethernet packets.
1175 */
1176static inline int is_ofld_imm(const struct sk_buff *skb)
1177{
1178 return skb->len <= MAX_IMM_TX_PKT_LEN;
1179}
1180
1181/**
1182 * calc_tx_flits_ofld - calculate # of flits for an offload packet
1183 * @skb: the packet
1184 *
1185 * Returns the number of flits needed for the given offload packet.
1186 * These packets are already fully constructed and no additional headers
1187 * will be added.
1188 */
1189static inline unsigned int calc_tx_flits_ofld(const struct sk_buff *skb)
1190{
1191 unsigned int flits, cnt;
1192
1193 if (is_ofld_imm(skb))
1194 return DIV_ROUND_UP(skb->len, 8);
1195
1196 flits = skb_transport_offset(skb) / 8U; /* headers */
1197 cnt = skb_shinfo(skb)->nr_frags;
1198 if (skb->tail != skb->transport_header)
1199 cnt++;
1200 return flits + sgl_len(cnt);
1201}
1202
1203/**
1204 * txq_stop_maperr - stop a Tx queue due to I/O MMU exhaustion
1205 * @adap: the adapter
1206 * @q: the queue to stop
1207 *
1208 * Mark a Tx queue stopped due to I/O MMU exhaustion and resulting
1209 * inability to map packets. A periodic timer attempts to restart
1210 * queues so marked.
1211 */
1212static void txq_stop_maperr(struct sge_ofld_txq *q)
1213{
1214 q->mapping_err++;
1215 q->q.stops++;
1216 set_bit(q->q.cntxt_id, q->adap->sge.txq_maperr);
1217}
1218
1219/**
1220 * ofldtxq_stop - stop an offload Tx queue that has become full
1221 * @q: the queue to stop
1222 * @skb: the packet causing the queue to become full
1223 *
1224 * Stops an offload Tx queue that has become full and modifies the packet
1225 * being written to request a wakeup.
1226 */
1227static void ofldtxq_stop(struct sge_ofld_txq *q, struct sk_buff *skb)
1228{
1229 struct fw_wr_hdr *wr = (struct fw_wr_hdr *)skb->data;
1230
1231 wr->lo |= htonl(FW_WR_EQUEQ | FW_WR_EQUIQ);
1232 q->q.stops++;
1233 q->full = 1;
1234}
1235
1236/**
1237 * service_ofldq - restart a suspended offload queue
1238 * @q: the offload queue
1239 *
1240 * Services an offload Tx queue by moving packets from its packet queue
1241 * to the HW Tx ring. The function starts and ends with the queue locked.
1242 */
1243static void service_ofldq(struct sge_ofld_txq *q)
1244{
1245 u64 *pos;
1246 int credits;
1247 struct sk_buff *skb;
1248 unsigned int written = 0;
1249 unsigned int flits, ndesc;
1250
1251 while ((skb = skb_peek(&q->sendq)) != NULL && !q->full) {
1252 /*
1253 * We drop the lock but leave skb on sendq, thus retaining
1254 * exclusive access to the state of the queue.
1255 */
1256 spin_unlock(&q->sendq.lock);
1257
1258 reclaim_completed_tx(q->adap, &q->q, false);
1259
1260 flits = skb->priority; /* previously saved */
1261 ndesc = flits_to_desc(flits);
1262 credits = txq_avail(&q->q) - ndesc;
1263 BUG_ON(credits < 0);
1264 if (unlikely(credits < TXQ_STOP_THRES))
1265 ofldtxq_stop(q, skb);
1266
1267 pos = (u64 *)&q->q.desc[q->q.pidx];
1268 if (is_ofld_imm(skb))
1269 inline_tx_skb(skb, &q->q, pos);
1270 else if (map_skb(q->adap->pdev_dev, skb,
1271 (dma_addr_t *)skb->head)) {
1272 txq_stop_maperr(q);
1273 spin_lock(&q->sendq.lock);
1274 break;
1275 } else {
1276 int last_desc, hdr_len = skb_transport_offset(skb);
1277
1278 memcpy(pos, skb->data, hdr_len);
1279 write_sgl(skb, &q->q, (void *)pos + hdr_len,
1280 pos + flits, hdr_len,
1281 (dma_addr_t *)skb->head);
1282#ifdef CONFIG_NEED_DMA_MAP_STATE
1283 skb->dev = q->adap->port[0];
1284 skb->destructor = deferred_unmap_destructor;
1285#endif
1286 last_desc = q->q.pidx + ndesc - 1;
1287 if (last_desc >= q->q.size)
1288 last_desc -= q->q.size;
1289 q->q.sdesc[last_desc].skb = skb;
1290 }
1291
1292 txq_advance(&q->q, ndesc);
1293 written += ndesc;
1294 if (unlikely(written > 32)) {
1295 ring_tx_db(q->adap, &q->q, written);
1296 written = 0;
1297 }
1298
1299 spin_lock(&q->sendq.lock);
1300 __skb_unlink(skb, &q->sendq);
1301 if (is_ofld_imm(skb))
1302 kfree_skb(skb);
1303 }
1304 if (likely(written))
1305 ring_tx_db(q->adap, &q->q, written);
1306}
1307
1308/**
1309 * ofld_xmit - send a packet through an offload queue
1310 * @q: the Tx offload queue
1311 * @skb: the packet
1312 *
1313 * Send an offload packet through an SGE offload queue.
1314 */
1315static int ofld_xmit(struct sge_ofld_txq *q, struct sk_buff *skb)
1316{
1317 skb->priority = calc_tx_flits_ofld(skb); /* save for restart */
1318 spin_lock(&q->sendq.lock);
1319 __skb_queue_tail(&q->sendq, skb);
1320 if (q->sendq.qlen == 1)
1321 service_ofldq(q);
1322 spin_unlock(&q->sendq.lock);
1323 return NET_XMIT_SUCCESS;
1324}
1325
1326/**
1327 * restart_ofldq - restart a suspended offload queue
1328 * @data: the offload queue to restart
1329 *
1330 * Resumes transmission on a suspended Tx offload queue.
1331 */
1332static void restart_ofldq(unsigned long data)
1333{
1334 struct sge_ofld_txq *q = (struct sge_ofld_txq *)data;
1335
1336 spin_lock(&q->sendq.lock);
1337 q->full = 0; /* the queue actually is completely empty now */
1338 service_ofldq(q);
1339 spin_unlock(&q->sendq.lock);
1340}
1341
1342/**
1343 * skb_txq - return the Tx queue an offload packet should use
1344 * @skb: the packet
1345 *
1346 * Returns the Tx queue an offload packet should use as indicated by bits
1347 * 1-15 in the packet's queue_mapping.
1348 */
1349static inline unsigned int skb_txq(const struct sk_buff *skb)
1350{
1351 return skb->queue_mapping >> 1;
1352}
1353
1354/**
1355 * is_ctrl_pkt - return whether an offload packet is a control packet
1356 * @skb: the packet
1357 *
1358 * Returns whether an offload packet should use an OFLD or a CTRL
1359 * Tx queue as indicated by bit 0 in the packet's queue_mapping.
1360 */
1361static inline unsigned int is_ctrl_pkt(const struct sk_buff *skb)
1362{
1363 return skb->queue_mapping & 1;
1364}
1365
1366static inline int ofld_send(struct adapter *adap, struct sk_buff *skb)
1367{
1368 unsigned int idx = skb_txq(skb);
1369
1370 if (unlikely(is_ctrl_pkt(skb)))
1371 return ctrl_xmit(&adap->sge.ctrlq[idx], skb);
1372 return ofld_xmit(&adap->sge.ofldtxq[idx], skb);
1373}
1374
1375/**
1376 * t4_ofld_send - send an offload packet
1377 * @adap: the adapter
1378 * @skb: the packet
1379 *
1380 * Sends an offload packet. We use the packet queue_mapping to select the
1381 * appropriate Tx queue as follows: bit 0 indicates whether the packet
1382 * should be sent as regular or control, bits 1-15 select the queue.
1383 */
1384int t4_ofld_send(struct adapter *adap, struct sk_buff *skb)
1385{
1386 int ret;
1387
1388 local_bh_disable();
1389 ret = ofld_send(adap, skb);
1390 local_bh_enable();
1391 return ret;
1392}
1393
1394/**
1395 * cxgb4_ofld_send - send an offload packet
1396 * @dev: the net device
1397 * @skb: the packet
1398 *
1399 * Sends an offload packet. This is an exported version of @t4_ofld_send,
1400 * intended for ULDs.
1401 */
1402int cxgb4_ofld_send(struct net_device *dev, struct sk_buff *skb)
1403{
1404 return t4_ofld_send(netdev2adap(dev), skb);
1405}
1406EXPORT_SYMBOL(cxgb4_ofld_send);
1407
1408static inline void copy_frags(struct skb_shared_info *ssi,
1409 const struct pkt_gl *gl, unsigned int offset)
1410{
1411 unsigned int n;
1412
1413 /* usually there's just one frag */
1414 ssi->frags[0].page = gl->frags[0].page;
1415 ssi->frags[0].page_offset = gl->frags[0].page_offset + offset;
1416 ssi->frags[0].size = gl->frags[0].size - offset;
1417 ssi->nr_frags = gl->nfrags;
1418 n = gl->nfrags - 1;
1419 if (n)
1420 memcpy(&ssi->frags[1], &gl->frags[1], n * sizeof(skb_frag_t));
1421
1422 /* get a reference to the last page, we don't own it */
1423 get_page(gl->frags[n].page);
1424}
1425
1426/**
1427 * cxgb4_pktgl_to_skb - build an sk_buff from a packet gather list
1428 * @gl: the gather list
1429 * @skb_len: size of sk_buff main body if it carries fragments
1430 * @pull_len: amount of data to move to the sk_buff's main body
1431 *
1432 * Builds an sk_buff from the given packet gather list. Returns the
1433 * sk_buff or %NULL if sk_buff allocation failed.
1434 */
1435struct sk_buff *cxgb4_pktgl_to_skb(const struct pkt_gl *gl,
1436 unsigned int skb_len, unsigned int pull_len)
1437{
1438 struct sk_buff *skb;
1439
1440 /*
1441 * Below we rely on RX_COPY_THRES being less than the smallest Rx buffer
1442 * size, which is expected since buffers are at least PAGE_SIZEd.
1443 * In this case packets up to RX_COPY_THRES have only one fragment.
1444 */
1445 if (gl->tot_len <= RX_COPY_THRES) {
1446 skb = dev_alloc_skb(gl->tot_len);
1447 if (unlikely(!skb))
1448 goto out;
1449 __skb_put(skb, gl->tot_len);
1450 skb_copy_to_linear_data(skb, gl->va, gl->tot_len);
1451 } else {
1452 skb = dev_alloc_skb(skb_len);
1453 if (unlikely(!skb))
1454 goto out;
1455 __skb_put(skb, pull_len);
1456 skb_copy_to_linear_data(skb, gl->va, pull_len);
1457
1458 copy_frags(skb_shinfo(skb), gl, pull_len);
1459 skb->len = gl->tot_len;
1460 skb->data_len = skb->len - pull_len;
1461 skb->truesize += skb->data_len;
1462 }
1463out: return skb;
1464}
1465EXPORT_SYMBOL(cxgb4_pktgl_to_skb);
1466
1467/**
1468 * t4_pktgl_free - free a packet gather list
1469 * @gl: the gather list
1470 *
1471 * Releases the pages of a packet gather list. We do not own the last
1472 * page on the list and do not free it.
1473 */
1474void t4_pktgl_free(const struct pkt_gl *gl)
1475{
1476 int n;
1477 const skb_frag_t *p;
1478
1479 for (p = gl->frags, n = gl->nfrags - 1; n--; p++)
1480 put_page(p->page);
1481}
1482
1483/*
1484 * Process an MPS trace packet. Give it an unused protocol number so it won't
1485 * be delivered to anyone and send it to the stack for capture.
1486 */
1487static noinline int handle_trace_pkt(struct adapter *adap,
1488 const struct pkt_gl *gl)
1489{
1490 struct sk_buff *skb;
1491 struct cpl_trace_pkt *p;
1492
1493 skb = cxgb4_pktgl_to_skb(gl, RX_PULL_LEN, RX_PULL_LEN);
1494 if (unlikely(!skb)) {
1495 t4_pktgl_free(gl);
1496 return 0;
1497 }
1498
1499 p = (struct cpl_trace_pkt *)skb->data;
1500 __skb_pull(skb, sizeof(*p));
1501 skb_reset_mac_header(skb);
1502 skb->protocol = htons(0xffff);
1503 skb->dev = adap->port[0];
1504 netif_receive_skb(skb);
1505 return 0;
1506}
1507
1508static void do_gro(struct sge_eth_rxq *rxq, const struct pkt_gl *gl,
1509 const struct cpl_rx_pkt *pkt)
1510{
1511 int ret;
1512 struct sk_buff *skb;
1513
1514 skb = napi_get_frags(&rxq->rspq.napi);
1515 if (unlikely(!skb)) {
1516 t4_pktgl_free(gl);
1517 rxq->stats.rx_drops++;
1518 return;
1519 }
1520
1521 copy_frags(skb_shinfo(skb), gl, RX_PKT_PAD);
1522 skb->len = gl->tot_len - RX_PKT_PAD;
1523 skb->data_len = skb->len;
1524 skb->truesize += skb->data_len;
1525 skb->ip_summed = CHECKSUM_UNNECESSARY;
1526 skb_record_rx_queue(skb, rxq->rspq.idx);
1527
1528 if (unlikely(pkt->vlan_ex)) {
1529 struct port_info *pi = netdev_priv(rxq->rspq.netdev);
1530 struct vlan_group *grp = pi->vlan_grp;
1531
1532 rxq->stats.vlan_ex++;
1533 if (likely(grp)) {
1534 ret = vlan_gro_frags(&rxq->rspq.napi, grp,
1535 ntohs(pkt->vlan));
1536 goto stats;
1537 }
1538 }
1539 ret = napi_gro_frags(&rxq->rspq.napi);
1540stats: if (ret == GRO_HELD)
1541 rxq->stats.lro_pkts++;
1542 else if (ret == GRO_MERGED || ret == GRO_MERGED_FREE)
1543 rxq->stats.lro_merged++;
1544 rxq->stats.pkts++;
1545 rxq->stats.rx_cso++;
1546}
1547
1548/**
1549 * t4_ethrx_handler - process an ingress ethernet packet
1550 * @q: the response queue that received the packet
1551 * @rsp: the response queue descriptor holding the RX_PKT message
1552 * @si: the gather list of packet fragments
1553 *
1554 * Process an ingress ethernet packet and deliver it to the stack.
1555 */
1556int t4_ethrx_handler(struct sge_rspq *q, const __be64 *rsp,
1557 const struct pkt_gl *si)
1558{
1559 bool csum_ok;
1560 struct sk_buff *skb;
1561 struct port_info *pi;
1562 const struct cpl_rx_pkt *pkt;
1563 struct sge_eth_rxq *rxq = container_of(q, struct sge_eth_rxq, rspq);
1564
1565 if (unlikely(*(u8 *)rsp == CPL_TRACE_PKT))
1566 return handle_trace_pkt(q->adap, si);
1567
1568 pkt = (void *)&rsp[1];
1569 csum_ok = pkt->csum_calc && !pkt->err_vec;
1570 if ((pkt->l2info & htonl(RXF_TCP)) &&
1571 (q->netdev->features & NETIF_F_GRO) && csum_ok && !pkt->ip_frag) {
1572 do_gro(rxq, si, pkt);
1573 return 0;
1574 }
1575
1576 skb = cxgb4_pktgl_to_skb(si, RX_PKT_SKB_LEN, RX_PULL_LEN);
1577 if (unlikely(!skb)) {
1578 t4_pktgl_free(si);
1579 rxq->stats.rx_drops++;
1580 return 0;
1581 }
1582
1583 __skb_pull(skb, RX_PKT_PAD); /* remove ethernet header padding */
1584 skb->protocol = eth_type_trans(skb, q->netdev);
1585 skb_record_rx_queue(skb, q->idx);
1586 pi = netdev_priv(skb->dev);
1587 rxq->stats.pkts++;
1588
1589 if (csum_ok && (pi->rx_offload & RX_CSO) &&
1590 (pkt->l2info & htonl(RXF_UDP | RXF_TCP))) {
1591 if (!pkt->ip_frag)
1592 skb->ip_summed = CHECKSUM_UNNECESSARY;
1593 else {
1594 __sum16 c = (__force __sum16)pkt->csum;
1595 skb->csum = csum_unfold(c);
1596 skb->ip_summed = CHECKSUM_COMPLETE;
1597 }
1598 rxq->stats.rx_cso++;
1599 } else
1600 skb->ip_summed = CHECKSUM_NONE;
1601
1602 if (unlikely(pkt->vlan_ex)) {
1603 struct vlan_group *grp = pi->vlan_grp;
1604
1605 rxq->stats.vlan_ex++;
1606 if (likely(grp))
1607 vlan_hwaccel_receive_skb(skb, grp, ntohs(pkt->vlan));
1608 else
1609 dev_kfree_skb_any(skb);
1610 } else
1611 netif_receive_skb(skb);
1612
1613 return 0;
1614}
1615
1616/**
1617 * restore_rx_bufs - put back a packet's Rx buffers
1618 * @si: the packet gather list
1619 * @q: the SGE free list
1620 * @frags: number of FL buffers to restore
1621 *
1622 * Puts back on an FL the Rx buffers associated with @si. The buffers
1623 * have already been unmapped and are left unmapped, we mark them so to
1624 * prevent further unmapping attempts.
1625 *
1626 * This function undoes a series of @unmap_rx_buf calls when we find out
1627 * that the current packet can't be processed right away afterall and we
1628 * need to come back to it later. This is a very rare event and there's
1629 * no effort to make this particularly efficient.
1630 */
1631static void restore_rx_bufs(const struct pkt_gl *si, struct sge_fl *q,
1632 int frags)
1633{
1634 struct rx_sw_desc *d;
1635
1636 while (frags--) {
1637 if (q->cidx == 0)
1638 q->cidx = q->size - 1;
1639 else
1640 q->cidx--;
1641 d = &q->sdesc[q->cidx];
1642 d->page = si->frags[frags].page;
1643 d->dma_addr |= RX_UNMAPPED_BUF;
1644 q->avail++;
1645 }
1646}
1647
1648/**
1649 * is_new_response - check if a response is newly written
1650 * @r: the response descriptor
1651 * @q: the response queue
1652 *
1653 * Returns true if a response descriptor contains a yet unprocessed
1654 * response.
1655 */
1656static inline bool is_new_response(const struct rsp_ctrl *r,
1657 const struct sge_rspq *q)
1658{
1659 return RSPD_GEN(r->type_gen) == q->gen;
1660}
1661
1662/**
1663 * rspq_next - advance to the next entry in a response queue
1664 * @q: the queue
1665 *
1666 * Updates the state of a response queue to advance it to the next entry.
1667 */
1668static inline void rspq_next(struct sge_rspq *q)
1669{
1670 q->cur_desc = (void *)q->cur_desc + q->iqe_len;
1671 if (unlikely(++q->cidx == q->size)) {
1672 q->cidx = 0;
1673 q->gen ^= 1;
1674 q->cur_desc = q->desc;
1675 }
1676}
1677
1678/**
1679 * process_responses - process responses from an SGE response queue
1680 * @q: the ingress queue to process
1681 * @budget: how many responses can be processed in this round
1682 *
1683 * Process responses from an SGE response queue up to the supplied budget.
1684 * Responses include received packets as well as control messages from FW
1685 * or HW.
1686 *
1687 * Additionally choose the interrupt holdoff time for the next interrupt
1688 * on this queue. If the system is under memory shortage use a fairly
1689 * long delay to help recovery.
1690 */
1691static int process_responses(struct sge_rspq *q, int budget)
1692{
1693 int ret, rsp_type;
1694 int budget_left = budget;
1695 const struct rsp_ctrl *rc;
1696 struct sge_eth_rxq *rxq = container_of(q, struct sge_eth_rxq, rspq);
1697
1698 while (likely(budget_left)) {
1699 rc = (void *)q->cur_desc + (q->iqe_len - sizeof(*rc));
1700 if (!is_new_response(rc, q))
1701 break;
1702
1703 rmb();
1704 rsp_type = RSPD_TYPE(rc->type_gen);
1705 if (likely(rsp_type == RSP_TYPE_FLBUF)) {
1706 skb_frag_t *fp;
1707 struct pkt_gl si;
1708 const struct rx_sw_desc *rsd;
1709 u32 len = ntohl(rc->pldbuflen_qid), bufsz, frags;
1710
1711 if (len & RSPD_NEWBUF) {
1712 if (likely(q->offset > 0)) {
1713 free_rx_bufs(q->adap, &rxq->fl, 1);
1714 q->offset = 0;
1715 }
1716 len &= RSPD_LEN;
1717 }
1718 si.tot_len = len;
1719
1720 /* gather packet fragments */
1721 for (frags = 0, fp = si.frags; ; frags++, fp++) {
1722 rsd = &rxq->fl.sdesc[rxq->fl.cidx];
1723 bufsz = get_buf_size(rsd);
1724 fp->page = rsd->page;
1725 fp->page_offset = q->offset;
1726 fp->size = min(bufsz, len);
1727 len -= fp->size;
1728 if (!len)
1729 break;
1730 unmap_rx_buf(q->adap, &rxq->fl);
1731 }
1732
1733 /*
1734 * Last buffer remains mapped so explicitly make it
1735 * coherent for CPU access.
1736 */
1737 dma_sync_single_for_cpu(q->adap->pdev_dev,
1738 get_buf_addr(rsd),
1739 fp->size, DMA_FROM_DEVICE);
1740
1741 si.va = page_address(si.frags[0].page) +
1742 si.frags[0].page_offset;
1743 prefetch(si.va);
1744
1745 si.nfrags = frags + 1;
1746 ret = q->handler(q, q->cur_desc, &si);
1747 if (likely(ret == 0))
1748 q->offset += ALIGN(fp->size, FL_ALIGN);
1749 else
1750 restore_rx_bufs(&si, &rxq->fl, frags);
1751 } else if (likely(rsp_type == RSP_TYPE_CPL)) {
1752 ret = q->handler(q, q->cur_desc, NULL);
1753 } else {
1754 ret = q->handler(q, (const __be64 *)rc, CXGB4_MSG_AN);
1755 }
1756
1757 if (unlikely(ret)) {
1758 /* couldn't process descriptor, back off for recovery */
1759 q->next_intr_params = QINTR_TIMER_IDX(NOMEM_TMR_IDX);
1760 break;
1761 }
1762
1763 rspq_next(q);
1764 budget_left--;
1765 }
1766
1767 if (q->offset >= 0 && rxq->fl.size - rxq->fl.avail >= 16)
1768 __refill_fl(q->adap, &rxq->fl);
1769 return budget - budget_left;
1770}
1771
1772/**
1773 * napi_rx_handler - the NAPI handler for Rx processing
1774 * @napi: the napi instance
1775 * @budget: how many packets we can process in this round
1776 *
1777 * Handler for new data events when using NAPI. This does not need any
1778 * locking or protection from interrupts as data interrupts are off at
1779 * this point and other adapter interrupts do not interfere (the latter
1780 * in not a concern at all with MSI-X as non-data interrupts then have
1781 * a separate handler).
1782 */
1783static int napi_rx_handler(struct napi_struct *napi, int budget)
1784{
1785 unsigned int params;
1786 struct sge_rspq *q = container_of(napi, struct sge_rspq, napi);
1787 int work_done = process_responses(q, budget);
1788
1789 if (likely(work_done < budget)) {
1790 napi_complete(napi);
1791 params = q->next_intr_params;
1792 q->next_intr_params = q->intr_params;
1793 } else
1794 params = QINTR_TIMER_IDX(7);
1795
1796 t4_write_reg(q->adap, MYPF_REG(SGE_PF_GTS), CIDXINC(work_done) |
1797 INGRESSQID((u32)q->cntxt_id) | SEINTARM(params));
1798 return work_done;
1799}
1800
1801/*
1802 * The MSI-X interrupt handler for an SGE response queue.
1803 */
1804irqreturn_t t4_sge_intr_msix(int irq, void *cookie)
1805{
1806 struct sge_rspq *q = cookie;
1807
1808 napi_schedule(&q->napi);
1809 return IRQ_HANDLED;
1810}
1811
1812/*
1813 * Process the indirect interrupt entries in the interrupt queue and kick off
1814 * NAPI for each queue that has generated an entry.
1815 */
1816static unsigned int process_intrq(struct adapter *adap)
1817{
1818 unsigned int credits;
1819 const struct rsp_ctrl *rc;
1820 struct sge_rspq *q = &adap->sge.intrq;
1821
1822 spin_lock(&adap->sge.intrq_lock);
1823 for (credits = 0; ; credits++) {
1824 rc = (void *)q->cur_desc + (q->iqe_len - sizeof(*rc));
1825 if (!is_new_response(rc, q))
1826 break;
1827
1828 rmb();
1829 if (RSPD_TYPE(rc->type_gen) == RSP_TYPE_INTR) {
1830 unsigned int qid = ntohl(rc->pldbuflen_qid);
1831
1832 napi_schedule(&adap->sge.ingr_map[qid]->napi);
1833 }
1834
1835 rspq_next(q);
1836 }
1837
1838 t4_write_reg(adap, MYPF_REG(SGE_PF_GTS), CIDXINC(credits) |
1839 INGRESSQID(q->cntxt_id) | SEINTARM(q->intr_params));
1840 spin_unlock(&adap->sge.intrq_lock);
1841 return credits;
1842}
1843
1844/*
1845 * The MSI interrupt handler, which handles data events from SGE response queues
1846 * as well as error and other async events as they all use the same MSI vector.
1847 */
1848static irqreturn_t t4_intr_msi(int irq, void *cookie)
1849{
1850 struct adapter *adap = cookie;
1851
1852 t4_slow_intr_handler(adap);
1853 process_intrq(adap);
1854 return IRQ_HANDLED;
1855}
1856
1857/*
1858 * Interrupt handler for legacy INTx interrupts.
1859 * Handles data events from SGE response queues as well as error and other
1860 * async events as they all use the same interrupt line.
1861 */
1862static irqreturn_t t4_intr_intx(int irq, void *cookie)
1863{
1864 struct adapter *adap = cookie;
1865
1866 t4_write_reg(adap, MYPF_REG(PCIE_PF_CLI), 0);
1867 if (t4_slow_intr_handler(adap) | process_intrq(adap))
1868 return IRQ_HANDLED;
1869 return IRQ_NONE; /* probably shared interrupt */
1870}
1871
1872/**
1873 * t4_intr_handler - select the top-level interrupt handler
1874 * @adap: the adapter
1875 *
1876 * Selects the top-level interrupt handler based on the type of interrupts
1877 * (MSI-X, MSI, or INTx).
1878 */
1879irq_handler_t t4_intr_handler(struct adapter *adap)
1880{
1881 if (adap->flags & USING_MSIX)
1882 return t4_sge_intr_msix;
1883 if (adap->flags & USING_MSI)
1884 return t4_intr_msi;
1885 return t4_intr_intx;
1886}
1887
1888static void sge_rx_timer_cb(unsigned long data)
1889{
1890 unsigned long m;
1891 unsigned int i, cnt[2];
1892 struct adapter *adap = (struct adapter *)data;
1893 struct sge *s = &adap->sge;
1894
1895 for (i = 0; i < ARRAY_SIZE(s->starving_fl); i++)
1896 for (m = s->starving_fl[i]; m; m &= m - 1) {
1897 struct sge_eth_rxq *rxq;
1898 unsigned int id = __ffs(m) + i * BITS_PER_LONG;
1899 struct sge_fl *fl = s->egr_map[id];
1900
1901 clear_bit(id, s->starving_fl);
1902 smp_mb__after_clear_bit();
1903
1904 if (fl_starving(fl)) {
1905 rxq = container_of(fl, struct sge_eth_rxq, fl);
1906 if (napi_reschedule(&rxq->rspq.napi))
1907 fl->starving++;
1908 else
1909 set_bit(id, s->starving_fl);
1910 }
1911 }
1912
1913 t4_write_reg(adap, SGE_DEBUG_INDEX, 13);
1914 cnt[0] = t4_read_reg(adap, SGE_DEBUG_DATA_HIGH);
1915 cnt[1] = t4_read_reg(adap, SGE_DEBUG_DATA_LOW);
1916
1917 for (i = 0; i < 2; i++)
1918 if (cnt[i] >= s->starve_thres) {
1919 if (s->idma_state[i] || cnt[i] == 0xffffffff)
1920 continue;
1921 s->idma_state[i] = 1;
1922 t4_write_reg(adap, SGE_DEBUG_INDEX, 11);
1923 m = t4_read_reg(adap, SGE_DEBUG_DATA_LOW) >> (i * 16);
1924 dev_warn(adap->pdev_dev,
1925 "SGE idma%u starvation detected for "
1926 "queue %lu\n", i, m & 0xffff);
1927 } else if (s->idma_state[i])
1928 s->idma_state[i] = 0;
1929
1930 mod_timer(&s->rx_timer, jiffies + RX_QCHECK_PERIOD);
1931}
1932
1933static void sge_tx_timer_cb(unsigned long data)
1934{
1935 unsigned long m;
1936 unsigned int i, budget;
1937 struct adapter *adap = (struct adapter *)data;
1938 struct sge *s = &adap->sge;
1939
1940 for (i = 0; i < ARRAY_SIZE(s->txq_maperr); i++)
1941 for (m = s->txq_maperr[i]; m; m &= m - 1) {
1942 unsigned long id = __ffs(m) + i * BITS_PER_LONG;
1943 struct sge_ofld_txq *txq = s->egr_map[id];
1944
1945 clear_bit(id, s->txq_maperr);
1946 tasklet_schedule(&txq->qresume_tsk);
1947 }
1948
1949 budget = MAX_TIMER_TX_RECLAIM;
1950 i = s->ethtxq_rover;
1951 do {
1952 struct sge_eth_txq *q = &s->ethtxq[i];
1953
1954 if (q->q.in_use &&
1955 time_after_eq(jiffies, q->txq->trans_start + HZ / 100) &&
1956 __netif_tx_trylock(q->txq)) {
1957 int avail = reclaimable(&q->q);
1958
1959 if (avail) {
1960 if (avail > budget)
1961 avail = budget;
1962
1963 free_tx_desc(adap, &q->q, avail, true);
1964 q->q.in_use -= avail;
1965 budget -= avail;
1966 }
1967 __netif_tx_unlock(q->txq);
1968 }
1969
1970 if (++i >= s->ethqsets)
1971 i = 0;
1972 } while (budget && i != s->ethtxq_rover);
1973 s->ethtxq_rover = i;
1974 mod_timer(&s->tx_timer, jiffies + (budget ? TX_QCHECK_PERIOD : 2));
1975}
1976
1977int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
1978 struct net_device *dev, int intr_idx,
1979 struct sge_fl *fl, rspq_handler_t hnd)
1980{
1981 int ret, flsz = 0;
1982 struct fw_iq_cmd c;
1983 struct port_info *pi = netdev_priv(dev);
1984
1985 /* Size needs to be multiple of 16, including status entry. */
1986 iq->size = roundup(iq->size, 16);
1987
1988 iq->desc = alloc_ring(adap->pdev_dev, iq->size, iq->iqe_len, 0,
1989 &iq->phys_addr, NULL, 0);
1990 if (!iq->desc)
1991 return -ENOMEM;
1992
1993 memset(&c, 0, sizeof(c));
1994 c.op_to_vfn = htonl(FW_CMD_OP(FW_IQ_CMD) | FW_CMD_REQUEST |
1995 FW_CMD_WRITE | FW_CMD_EXEC |
1996 FW_IQ_CMD_PFN(0) | FW_IQ_CMD_VFN(0));
1997 c.alloc_to_len16 = htonl(FW_IQ_CMD_ALLOC | FW_IQ_CMD_IQSTART(1) |
1998 FW_LEN16(c));
1999 c.type_to_iqandstindex = htonl(FW_IQ_CMD_TYPE(FW_IQ_TYPE_FL_INT_CAP) |
2000 FW_IQ_CMD_IQASYNCH(fwevtq) | FW_IQ_CMD_VIID(pi->viid) |
2001 FW_IQ_CMD_IQANDST(intr_idx < 0) | FW_IQ_CMD_IQANUD(1) |
2002 FW_IQ_CMD_IQANDSTINDEX(intr_idx >= 0 ? intr_idx :
2003 -intr_idx - 1));
2004 c.iqdroprss_to_iqesize = htons(FW_IQ_CMD_IQPCIECH(pi->tx_chan) |
2005 FW_IQ_CMD_IQGTSMODE |
2006 FW_IQ_CMD_IQINTCNTTHRESH(iq->pktcnt_idx) |
2007 FW_IQ_CMD_IQESIZE(ilog2(iq->iqe_len) - 4));
2008 c.iqsize = htons(iq->size);
2009 c.iqaddr = cpu_to_be64(iq->phys_addr);
2010
2011 if (fl) {
2012 fl->size = roundup(fl->size, 8);
2013 fl->desc = alloc_ring(adap->pdev_dev, fl->size, sizeof(__be64),
2014 sizeof(struct rx_sw_desc), &fl->addr,
2015 &fl->sdesc, STAT_LEN);
2016 if (!fl->desc)
2017 goto fl_nomem;
2018
2019 flsz = fl->size / 8 + STAT_LEN / sizeof(struct tx_desc);
2020 c.iqns_to_fl0congen = htonl(FW_IQ_CMD_FL0PACKEN |
2021 FW_IQ_CMD_FL0PADEN);
2022 c.fl0dcaen_to_fl0cidxfthresh = htons(FW_IQ_CMD_FL0FBMIN(2) |
2023 FW_IQ_CMD_FL0FBMAX(3));
2024 c.fl0size = htons(flsz);
2025 c.fl0addr = cpu_to_be64(fl->addr);
2026 }
2027
2028 ret = t4_wr_mbox(adap, 0, &c, sizeof(c), &c);
2029 if (ret)
2030 goto err;
2031
2032 netif_napi_add(dev, &iq->napi, napi_rx_handler, 64);
2033 iq->cur_desc = iq->desc;
2034 iq->cidx = 0;
2035 iq->gen = 1;
2036 iq->next_intr_params = iq->intr_params;
2037 iq->cntxt_id = ntohs(c.iqid);
2038 iq->abs_id = ntohs(c.physiqid);
2039 iq->size--; /* subtract status entry */
2040 iq->adap = adap;
2041 iq->netdev = dev;
2042 iq->handler = hnd;
2043
2044 /* set offset to -1 to distinguish ingress queues without FL */
2045 iq->offset = fl ? 0 : -1;
2046
2047 adap->sge.ingr_map[iq->cntxt_id] = iq;
2048
2049 if (fl) {
2050 fl->cntxt_id = htons(c.fl0id);
2051 fl->avail = fl->pend_cred = 0;
2052 fl->pidx = fl->cidx = 0;
2053 fl->alloc_failed = fl->large_alloc_failed = fl->starving = 0;
2054 adap->sge.egr_map[fl->cntxt_id] = fl;
2055 refill_fl(adap, fl, fl_cap(fl), GFP_KERNEL);
2056 }
2057 return 0;
2058
2059fl_nomem:
2060 ret = -ENOMEM;
2061err:
2062 if (iq->desc) {
2063 dma_free_coherent(adap->pdev_dev, iq->size * iq->iqe_len,
2064 iq->desc, iq->phys_addr);
2065 iq->desc = NULL;
2066 }
2067 if (fl && fl->desc) {
2068 kfree(fl->sdesc);
2069 fl->sdesc = NULL;
2070 dma_free_coherent(adap->pdev_dev, flsz * sizeof(struct tx_desc),
2071 fl->desc, fl->addr);
2072 fl->desc = NULL;
2073 }
2074 return ret;
2075}
2076
2077static void init_txq(struct adapter *adap, struct sge_txq *q, unsigned int id)
2078{
2079 q->in_use = 0;
2080 q->cidx = q->pidx = 0;
2081 q->stops = q->restarts = 0;
2082 q->stat = (void *)&q->desc[q->size];
2083 q->cntxt_id = id;
2084 adap->sge.egr_map[id] = q;
2085}
2086
2087int t4_sge_alloc_eth_txq(struct adapter *adap, struct sge_eth_txq *txq,
2088 struct net_device *dev, struct netdev_queue *netdevq,
2089 unsigned int iqid)
2090{
2091 int ret, nentries;
2092 struct fw_eq_eth_cmd c;
2093 struct port_info *pi = netdev_priv(dev);
2094
2095 /* Add status entries */
2096 nentries = txq->q.size + STAT_LEN / sizeof(struct tx_desc);
2097
2098 txq->q.desc = alloc_ring(adap->pdev_dev, txq->q.size,
2099 sizeof(struct tx_desc), sizeof(struct tx_sw_desc),
2100 &txq->q.phys_addr, &txq->q.sdesc, STAT_LEN);
2101 if (!txq->q.desc)
2102 return -ENOMEM;
2103
2104 memset(&c, 0, sizeof(c));
2105 c.op_to_vfn = htonl(FW_CMD_OP(FW_EQ_ETH_CMD) | FW_CMD_REQUEST |
2106 FW_CMD_WRITE | FW_CMD_EXEC |
2107 FW_EQ_ETH_CMD_PFN(0) | FW_EQ_ETH_CMD_VFN(0));
2108 c.alloc_to_len16 = htonl(FW_EQ_ETH_CMD_ALLOC |
2109 FW_EQ_ETH_CMD_EQSTART | FW_LEN16(c));
2110 c.viid_pkd = htonl(FW_EQ_ETH_CMD_VIID(pi->viid));
2111 c.fetchszm_to_iqid = htonl(FW_EQ_ETH_CMD_HOSTFCMODE(2) |
2112 FW_EQ_ETH_CMD_PCIECHN(pi->tx_chan) |
2113 FW_EQ_ETH_CMD_IQID(iqid));
2114 c.dcaen_to_eqsize = htonl(FW_EQ_ETH_CMD_FBMIN(2) |
2115 FW_EQ_ETH_CMD_FBMAX(3) |
2116 FW_EQ_ETH_CMD_CIDXFTHRESH(5) |
2117 FW_EQ_ETH_CMD_EQSIZE(nentries));
2118 c.eqaddr = cpu_to_be64(txq->q.phys_addr);
2119
2120 ret = t4_wr_mbox(adap, 0, &c, sizeof(c), &c);
2121 if (ret) {
2122 kfree(txq->q.sdesc);
2123 txq->q.sdesc = NULL;
2124 dma_free_coherent(adap->pdev_dev,
2125 nentries * sizeof(struct tx_desc),
2126 txq->q.desc, txq->q.phys_addr);
2127 txq->q.desc = NULL;
2128 return ret;
2129 }
2130
2131 init_txq(adap, &txq->q, FW_EQ_ETH_CMD_EQID_GET(ntohl(c.eqid_pkd)));
2132 txq->txq = netdevq;
2133 txq->tso = txq->tx_cso = txq->vlan_ins = 0;
2134 txq->mapping_err = 0;
2135 return 0;
2136}
2137
2138int t4_sge_alloc_ctrl_txq(struct adapter *adap, struct sge_ctrl_txq *txq,
2139 struct net_device *dev, unsigned int iqid,
2140 unsigned int cmplqid)
2141{
2142 int ret, nentries;
2143 struct fw_eq_ctrl_cmd c;
2144 struct port_info *pi = netdev_priv(dev);
2145
2146 /* Add status entries */
2147 nentries = txq->q.size + STAT_LEN / sizeof(struct tx_desc);
2148
2149 txq->q.desc = alloc_ring(adap->pdev_dev, nentries,
2150 sizeof(struct tx_desc), 0, &txq->q.phys_addr,
2151 NULL, 0);
2152 if (!txq->q.desc)
2153 return -ENOMEM;
2154
2155 c.op_to_vfn = htonl(FW_CMD_OP(FW_EQ_CTRL_CMD) | FW_CMD_REQUEST |
2156 FW_CMD_WRITE | FW_CMD_EXEC |
2157 FW_EQ_CTRL_CMD_PFN(0) | FW_EQ_CTRL_CMD_VFN(0));
2158 c.alloc_to_len16 = htonl(FW_EQ_CTRL_CMD_ALLOC |
2159 FW_EQ_CTRL_CMD_EQSTART | FW_LEN16(c));
2160 c.cmpliqid_eqid = htonl(FW_EQ_CTRL_CMD_CMPLIQID(cmplqid));
2161 c.physeqid_pkd = htonl(0);
2162 c.fetchszm_to_iqid = htonl(FW_EQ_CTRL_CMD_HOSTFCMODE(2) |
2163 FW_EQ_CTRL_CMD_PCIECHN(pi->tx_chan) |
2164 FW_EQ_CTRL_CMD_IQID(iqid));
2165 c.dcaen_to_eqsize = htonl(FW_EQ_CTRL_CMD_FBMIN(2) |
2166 FW_EQ_CTRL_CMD_FBMAX(3) |
2167 FW_EQ_CTRL_CMD_CIDXFTHRESH(5) |
2168 FW_EQ_CTRL_CMD_EQSIZE(nentries));
2169 c.eqaddr = cpu_to_be64(txq->q.phys_addr);
2170
2171 ret = t4_wr_mbox(adap, 0, &c, sizeof(c), &c);
2172 if (ret) {
2173 dma_free_coherent(adap->pdev_dev,
2174 nentries * sizeof(struct tx_desc),
2175 txq->q.desc, txq->q.phys_addr);
2176 txq->q.desc = NULL;
2177 return ret;
2178 }
2179
2180 init_txq(adap, &txq->q, FW_EQ_CTRL_CMD_EQID_GET(ntohl(c.cmpliqid_eqid)));
2181 txq->adap = adap;
2182 skb_queue_head_init(&txq->sendq);
2183 tasklet_init(&txq->qresume_tsk, restart_ctrlq, (unsigned long)txq);
2184 txq->full = 0;
2185 return 0;
2186}
2187
2188int t4_sge_alloc_ofld_txq(struct adapter *adap, struct sge_ofld_txq *txq,
2189 struct net_device *dev, unsigned int iqid)
2190{
2191 int ret, nentries;
2192 struct fw_eq_ofld_cmd c;
2193 struct port_info *pi = netdev_priv(dev);
2194
2195 /* Add status entries */
2196 nentries = txq->q.size + STAT_LEN / sizeof(struct tx_desc);
2197
2198 txq->q.desc = alloc_ring(adap->pdev_dev, txq->q.size,
2199 sizeof(struct tx_desc), sizeof(struct tx_sw_desc),
2200 &txq->q.phys_addr, &txq->q.sdesc, STAT_LEN);
2201 if (!txq->q.desc)
2202 return -ENOMEM;
2203
2204 memset(&c, 0, sizeof(c));
2205 c.op_to_vfn = htonl(FW_CMD_OP(FW_EQ_OFLD_CMD) | FW_CMD_REQUEST |
2206 FW_CMD_WRITE | FW_CMD_EXEC |
2207 FW_EQ_OFLD_CMD_PFN(0) | FW_EQ_OFLD_CMD_VFN(0));
2208 c.alloc_to_len16 = htonl(FW_EQ_OFLD_CMD_ALLOC |
2209 FW_EQ_OFLD_CMD_EQSTART | FW_LEN16(c));
2210 c.fetchszm_to_iqid = htonl(FW_EQ_OFLD_CMD_HOSTFCMODE(2) |
2211 FW_EQ_OFLD_CMD_PCIECHN(pi->tx_chan) |
2212 FW_EQ_OFLD_CMD_IQID(iqid));
2213 c.dcaen_to_eqsize = htonl(FW_EQ_OFLD_CMD_FBMIN(2) |
2214 FW_EQ_OFLD_CMD_FBMAX(3) |
2215 FW_EQ_OFLD_CMD_CIDXFTHRESH(5) |
2216 FW_EQ_OFLD_CMD_EQSIZE(nentries));
2217 c.eqaddr = cpu_to_be64(txq->q.phys_addr);
2218
2219 ret = t4_wr_mbox(adap, 0, &c, sizeof(c), &c);
2220 if (ret) {
2221 kfree(txq->q.sdesc);
2222 txq->q.sdesc = NULL;
2223 dma_free_coherent(adap->pdev_dev,
2224 nentries * sizeof(struct tx_desc),
2225 txq->q.desc, txq->q.phys_addr);
2226 txq->q.desc = NULL;
2227 return ret;
2228 }
2229
2230 init_txq(adap, &txq->q, FW_EQ_OFLD_CMD_EQID_GET(ntohl(c.eqid_pkd)));
2231 txq->adap = adap;
2232 skb_queue_head_init(&txq->sendq);
2233 tasklet_init(&txq->qresume_tsk, restart_ofldq, (unsigned long)txq);
2234 txq->full = 0;
2235 txq->mapping_err = 0;
2236 return 0;
2237}
2238
2239static void free_txq(struct adapter *adap, struct sge_txq *q)
2240{
2241 dma_free_coherent(adap->pdev_dev,
2242 q->size * sizeof(struct tx_desc) + STAT_LEN,
2243 q->desc, q->phys_addr);
2244 q->cntxt_id = 0;
2245 q->sdesc = NULL;
2246 q->desc = NULL;
2247}
2248
2249static void free_rspq_fl(struct adapter *adap, struct sge_rspq *rq,
2250 struct sge_fl *fl)
2251{
2252 unsigned int fl_id = fl ? fl->cntxt_id : 0xffff;
2253
2254 adap->sge.ingr_map[rq->cntxt_id] = NULL;
2255 t4_iq_free(adap, 0, 0, 0, FW_IQ_TYPE_FL_INT_CAP, rq->cntxt_id, fl_id,
2256 0xffff);
2257 dma_free_coherent(adap->pdev_dev, (rq->size + 1) * rq->iqe_len,
2258 rq->desc, rq->phys_addr);
2259 netif_napi_del(&rq->napi);
2260 rq->netdev = NULL;
2261 rq->cntxt_id = rq->abs_id = 0;
2262 rq->desc = NULL;
2263
2264 if (fl) {
2265 free_rx_bufs(adap, fl, fl->avail);
2266 dma_free_coherent(adap->pdev_dev, fl->size * 8 + STAT_LEN,
2267 fl->desc, fl->addr);
2268 kfree(fl->sdesc);
2269 fl->sdesc = NULL;
2270 fl->cntxt_id = 0;
2271 fl->desc = NULL;
2272 }
2273}
2274
2275/**
2276 * t4_free_sge_resources - free SGE resources
2277 * @adap: the adapter
2278 *
2279 * Frees resources used by the SGE queue sets.
2280 */
2281void t4_free_sge_resources(struct adapter *adap)
2282{
2283 int i;
2284 struct sge_eth_rxq *eq = adap->sge.ethrxq;
2285 struct sge_eth_txq *etq = adap->sge.ethtxq;
2286 struct sge_ofld_rxq *oq = adap->sge.ofldrxq;
2287
2288 /* clean up Ethernet Tx/Rx queues */
2289 for (i = 0; i < adap->sge.ethqsets; i++, eq++, etq++) {
2290 if (eq->rspq.desc)
2291 free_rspq_fl(adap, &eq->rspq, &eq->fl);
2292 if (etq->q.desc) {
2293 t4_eth_eq_free(adap, 0, 0, 0, etq->q.cntxt_id);
2294 free_tx_desc(adap, &etq->q, etq->q.in_use, true);
2295 kfree(etq->q.sdesc);
2296 free_txq(adap, &etq->q);
2297 }
2298 }
2299
2300 /* clean up RDMA and iSCSI Rx queues */
2301 for (i = 0; i < adap->sge.ofldqsets; i++, oq++) {
2302 if (oq->rspq.desc)
2303 free_rspq_fl(adap, &oq->rspq, &oq->fl);
2304 }
2305 for (i = 0, oq = adap->sge.rdmarxq; i < adap->sge.rdmaqs; i++, oq++) {
2306 if (oq->rspq.desc)
2307 free_rspq_fl(adap, &oq->rspq, &oq->fl);
2308 }
2309
2310 /* clean up offload Tx queues */
2311 for (i = 0; i < ARRAY_SIZE(adap->sge.ofldtxq); i++) {
2312 struct sge_ofld_txq *q = &adap->sge.ofldtxq[i];
2313
2314 if (q->q.desc) {
2315 tasklet_kill(&q->qresume_tsk);
2316 t4_ofld_eq_free(adap, 0, 0, 0, q->q.cntxt_id);
2317 free_tx_desc(adap, &q->q, q->q.in_use, false);
2318 kfree(q->q.sdesc);
2319 __skb_queue_purge(&q->sendq);
2320 free_txq(adap, &q->q);
2321 }
2322 }
2323
2324 /* clean up control Tx queues */
2325 for (i = 0; i < ARRAY_SIZE(adap->sge.ctrlq); i++) {
2326 struct sge_ctrl_txq *cq = &adap->sge.ctrlq[i];
2327
2328 if (cq->q.desc) {
2329 tasklet_kill(&cq->qresume_tsk);
2330 t4_ctrl_eq_free(adap, 0, 0, 0, cq->q.cntxt_id);
2331 __skb_queue_purge(&cq->sendq);
2332 free_txq(adap, &cq->q);
2333 }
2334 }
2335
2336 if (adap->sge.fw_evtq.desc)
2337 free_rspq_fl(adap, &adap->sge.fw_evtq, NULL);
2338
2339 if (adap->sge.intrq.desc)
2340 free_rspq_fl(adap, &adap->sge.intrq, NULL);
2341
2342 /* clear the reverse egress queue map */
2343 memset(adap->sge.egr_map, 0, sizeof(adap->sge.egr_map));
2344}
2345
2346void t4_sge_start(struct adapter *adap)
2347{
2348 adap->sge.ethtxq_rover = 0;
2349 mod_timer(&adap->sge.rx_timer, jiffies + RX_QCHECK_PERIOD);
2350 mod_timer(&adap->sge.tx_timer, jiffies + TX_QCHECK_PERIOD);
2351}
2352
2353/**
2354 * t4_sge_stop - disable SGE operation
2355 * @adap: the adapter
2356 *
2357 * Stop tasklets and timers associated with the DMA engine. Note that
2358 * this is effective only if measures have been taken to disable any HW
2359 * events that may restart them.
2360 */
2361void t4_sge_stop(struct adapter *adap)
2362{
2363 int i;
2364 struct sge *s = &adap->sge;
2365
2366 if (in_interrupt()) /* actions below require waiting */
2367 return;
2368
2369 if (s->rx_timer.function)
2370 del_timer_sync(&s->rx_timer);
2371 if (s->tx_timer.function)
2372 del_timer_sync(&s->tx_timer);
2373
2374 for (i = 0; i < ARRAY_SIZE(s->ofldtxq); i++) {
2375 struct sge_ofld_txq *q = &s->ofldtxq[i];
2376
2377 if (q->q.desc)
2378 tasklet_kill(&q->qresume_tsk);
2379 }
2380 for (i = 0; i < ARRAY_SIZE(s->ctrlq); i++) {
2381 struct sge_ctrl_txq *cq = &s->ctrlq[i];
2382
2383 if (cq->q.desc)
2384 tasklet_kill(&cq->qresume_tsk);
2385 }
2386}
2387
2388/**
2389 * t4_sge_init - initialize SGE
2390 * @adap: the adapter
2391 *
2392 * Performs SGE initialization needed every time after a chip reset.
2393 * We do not initialize any of the queues here, instead the driver
2394 * top-level must request them individually.
2395 */
2396void t4_sge_init(struct adapter *adap)
2397{
2398 struct sge *s = &adap->sge;
2399 unsigned int fl_align_log = ilog2(FL_ALIGN);
2400
2401 t4_set_reg_field(adap, SGE_CONTROL, PKTSHIFT_MASK |
2402 INGPADBOUNDARY_MASK | EGRSTATUSPAGESIZE,
2403 INGPADBOUNDARY(fl_align_log - 5) | PKTSHIFT(2) |
2404 RXPKTCPLMODE |
2405 (STAT_LEN == 128 ? EGRSTATUSPAGESIZE : 0));
2406 t4_set_reg_field(adap, SGE_HOST_PAGE_SIZE, HOSTPAGESIZEPF0_MASK,
2407 HOSTPAGESIZEPF0(PAGE_SHIFT - 10));
2408 t4_write_reg(adap, SGE_FL_BUFFER_SIZE0, PAGE_SIZE);
2409#if FL_PG_ORDER > 0
2410 t4_write_reg(adap, SGE_FL_BUFFER_SIZE1, PAGE_SIZE << FL_PG_ORDER);
2411#endif
2412 t4_write_reg(adap, SGE_INGRESS_RX_THRESHOLD,
2413 THRESHOLD_0(s->counter_val[0]) |
2414 THRESHOLD_1(s->counter_val[1]) |
2415 THRESHOLD_2(s->counter_val[2]) |
2416 THRESHOLD_3(s->counter_val[3]));
2417 t4_write_reg(adap, SGE_TIMER_VALUE_0_AND_1,
2418 TIMERVALUE0(us_to_core_ticks(adap, s->timer_val[0])) |
2419 TIMERVALUE1(us_to_core_ticks(adap, s->timer_val[1])));
2420 t4_write_reg(adap, SGE_TIMER_VALUE_2_AND_3,
2421 TIMERVALUE0(us_to_core_ticks(adap, s->timer_val[2])) |
2422 TIMERVALUE1(us_to_core_ticks(adap, s->timer_val[3])));
2423 t4_write_reg(adap, SGE_TIMER_VALUE_4_AND_5,
2424 TIMERVALUE0(us_to_core_ticks(adap, s->timer_val[4])) |
2425 TIMERVALUE1(us_to_core_ticks(adap, s->timer_val[5])));
2426 setup_timer(&s->rx_timer, sge_rx_timer_cb, (unsigned long)adap);
2427 setup_timer(&s->tx_timer, sge_tx_timer_cb, (unsigned long)adap);
2428 s->starve_thres = core_ticks_per_usec(adap) * 1000000; /* 1 s */
2429 s->idma_state[0] = s->idma_state[1] = 0;
2430 spin_lock_init(&s->intrq_lock);
2431}
diff --git a/drivers/net/cxgb4/t4_hw.c b/drivers/net/cxgb4/t4_hw.c
new file mode 100644
index 00000000000..a814a3afe12
--- /dev/null
+++ b/drivers/net/cxgb4/t4_hw.c
@@ -0,0 +1,3131 @@
1/*
2 * This file is part of the Chelsio T4 Ethernet driver for Linux.
3 *
4 * Copyright (c) 2003-2010 Chelsio Communications, Inc. All rights reserved.
5 *
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
11 *
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
14 * conditions are met:
15 *
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer.
19 *
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
24 *
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE.
33 */
34
35#include <linux/init.h>
36#include <linux/delay.h>
37#include "cxgb4.h"
38#include "t4_regs.h"
39#include "t4fw_api.h"
40
41/**
42 * t4_wait_op_done_val - wait until an operation is completed
43 * @adapter: the adapter performing the operation
44 * @reg: the register to check for completion
45 * @mask: a single-bit field within @reg that indicates completion
46 * @polarity: the value of the field when the operation is completed
47 * @attempts: number of check iterations
48 * @delay: delay in usecs between iterations
49 * @valp: where to store the value of the register at completion time
50 *
51 * Wait until an operation is completed by checking a bit in a register
52 * up to @attempts times. If @valp is not NULL the value of the register
53 * at the time it indicated completion is stored there. Returns 0 if the
54 * operation completes and -EAGAIN otherwise.
55 */
56int t4_wait_op_done_val(struct adapter *adapter, int reg, u32 mask,
57 int polarity, int attempts, int delay, u32 *valp)
58{
59 while (1) {
60 u32 val = t4_read_reg(adapter, reg);
61
62 if (!!(val & mask) == polarity) {
63 if (valp)
64 *valp = val;
65 return 0;
66 }
67 if (--attempts == 0)
68 return -EAGAIN;
69 if (delay)
70 udelay(delay);
71 }
72}
73
74static inline int t4_wait_op_done(struct adapter *adapter, int reg, u32 mask,
75 int polarity, int attempts, int delay)
76{
77 return t4_wait_op_done_val(adapter, reg, mask, polarity, attempts,
78 delay, NULL);
79}
80
81/**
82 * t4_set_reg_field - set a register field to a value
83 * @adapter: the adapter to program
84 * @addr: the register address
85 * @mask: specifies the portion of the register to modify
86 * @val: the new value for the register field
87 *
88 * Sets a register field specified by the supplied mask to the
89 * given value.
90 */
91void t4_set_reg_field(struct adapter *adapter, unsigned int addr, u32 mask,
92 u32 val)
93{
94 u32 v = t4_read_reg(adapter, addr) & ~mask;
95
96 t4_write_reg(adapter, addr, v | val);
97 (void) t4_read_reg(adapter, addr); /* flush */
98}
99
100/**
101 * t4_read_indirect - read indirectly addressed registers
102 * @adap: the adapter
103 * @addr_reg: register holding the indirect address
104 * @data_reg: register holding the value of the indirect register
105 * @vals: where the read register values are stored
106 * @nregs: how many indirect registers to read
107 * @start_idx: index of first indirect register to read
108 *
109 * Reads registers that are accessed indirectly through an address/data
110 * register pair.
111 */
112void t4_read_indirect(struct adapter *adap, unsigned int addr_reg,
113 unsigned int data_reg, u32 *vals, unsigned int nregs,
114 unsigned int start_idx)
115{
116 while (nregs--) {
117 t4_write_reg(adap, addr_reg, start_idx);
118 *vals++ = t4_read_reg(adap, data_reg);
119 start_idx++;
120 }
121}
122
123/**
124 * t4_write_indirect - write indirectly addressed registers
125 * @adap: the adapter
126 * @addr_reg: register holding the indirect addresses
127 * @data_reg: register holding the value for the indirect registers
128 * @vals: values to write
129 * @nregs: how many indirect registers to write
130 * @start_idx: address of first indirect register to write
131 *
132 * Writes a sequential block of registers that are accessed indirectly
133 * through an address/data register pair.
134 */
135void t4_write_indirect(struct adapter *adap, unsigned int addr_reg,
136 unsigned int data_reg, const u32 *vals,
137 unsigned int nregs, unsigned int start_idx)
138{
139 while (nregs--) {
140 t4_write_reg(adap, addr_reg, start_idx++);
141 t4_write_reg(adap, data_reg, *vals++);
142 }
143}
144
145/*
146 * Get the reply to a mailbox command and store it in @rpl in big-endian order.
147 */
148static void get_mbox_rpl(struct adapter *adap, __be64 *rpl, int nflit,
149 u32 mbox_addr)
150{
151 for ( ; nflit; nflit--, mbox_addr += 8)
152 *rpl++ = cpu_to_be64(t4_read_reg64(adap, mbox_addr));
153}
154
155/*
156 * Handle a FW assertion reported in a mailbox.
157 */
158static void fw_asrt(struct adapter *adap, u32 mbox_addr)
159{
160 struct fw_debug_cmd asrt;
161
162 get_mbox_rpl(adap, (__be64 *)&asrt, sizeof(asrt) / 8, mbox_addr);
163 dev_alert(adap->pdev_dev,
164 "FW assertion at %.16s:%u, val0 %#x, val1 %#x\n",
165 asrt.u.assert.filename_0_7, ntohl(asrt.u.assert.line),
166 ntohl(asrt.u.assert.x), ntohl(asrt.u.assert.y));
167}
168
169static void dump_mbox(struct adapter *adap, int mbox, u32 data_reg)
170{
171 dev_err(adap->pdev_dev,
172 "mbox %d: %llx %llx %llx %llx %llx %llx %llx %llx\n", mbox,
173 (unsigned long long)t4_read_reg64(adap, data_reg),
174 (unsigned long long)t4_read_reg64(adap, data_reg + 8),
175 (unsigned long long)t4_read_reg64(adap, data_reg + 16),
176 (unsigned long long)t4_read_reg64(adap, data_reg + 24),
177 (unsigned long long)t4_read_reg64(adap, data_reg + 32),
178 (unsigned long long)t4_read_reg64(adap, data_reg + 40),
179 (unsigned long long)t4_read_reg64(adap, data_reg + 48),
180 (unsigned long long)t4_read_reg64(adap, data_reg + 56));
181}
182
183/**
184 * t4_wr_mbox_meat - send a command to FW through the given mailbox
185 * @adap: the adapter
186 * @mbox: index of the mailbox to use
187 * @cmd: the command to write
188 * @size: command length in bytes
189 * @rpl: where to optionally store the reply
190 * @sleep_ok: if true we may sleep while awaiting command completion
191 *
192 * Sends the given command to FW through the selected mailbox and waits
193 * for the FW to execute the command. If @rpl is not %NULL it is used to
194 * store the FW's reply to the command. The command and its optional
195 * reply are of the same length. FW can take up to %FW_CMD_MAX_TIMEOUT ms
196 * to respond. @sleep_ok determines whether we may sleep while awaiting
197 * the response. If sleeping is allowed we use progressive backoff
198 * otherwise we spin.
199 *
200 * The return value is 0 on success or a negative errno on failure. A
201 * failure can happen either because we are not able to execute the
202 * command or FW executes it but signals an error. In the latter case
203 * the return value is the error code indicated by FW (negated).
204 */
205int t4_wr_mbox_meat(struct adapter *adap, int mbox, const void *cmd, int size,
206 void *rpl, bool sleep_ok)
207{
208 static int delay[] = {
209 1, 1, 3, 5, 10, 10, 20, 50, 100, 200
210 };
211
212 u32 v;
213 u64 res;
214 int i, ms, delay_idx;
215 const __be64 *p = cmd;
216 u32 data_reg = PF_REG(mbox, CIM_PF_MAILBOX_DATA);
217 u32 ctl_reg = PF_REG(mbox, CIM_PF_MAILBOX_CTRL);
218
219 if ((size & 15) || size > MBOX_LEN)
220 return -EINVAL;
221
222 v = MBOWNER_GET(t4_read_reg(adap, ctl_reg));
223 for (i = 0; v == MBOX_OWNER_NONE && i < 3; i++)
224 v = MBOWNER_GET(t4_read_reg(adap, ctl_reg));
225
226 if (v != MBOX_OWNER_DRV)
227 return v ? -EBUSY : -ETIMEDOUT;
228
229 for (i = 0; i < size; i += 8)
230 t4_write_reg64(adap, data_reg + i, be64_to_cpu(*p++));
231
232 t4_write_reg(adap, ctl_reg, MBMSGVALID | MBOWNER(MBOX_OWNER_FW));
233 t4_read_reg(adap, ctl_reg); /* flush write */
234
235 delay_idx = 0;
236 ms = delay[0];
237
238 for (i = 0; i < FW_CMD_MAX_TIMEOUT; i += ms) {
239 if (sleep_ok) {
240 ms = delay[delay_idx]; /* last element may repeat */
241 if (delay_idx < ARRAY_SIZE(delay) - 1)
242 delay_idx++;
243 msleep(ms);
244 } else
245 mdelay(ms);
246
247 v = t4_read_reg(adap, ctl_reg);
248 if (MBOWNER_GET(v) == MBOX_OWNER_DRV) {
249 if (!(v & MBMSGVALID)) {
250 t4_write_reg(adap, ctl_reg, 0);
251 continue;
252 }
253
254 res = t4_read_reg64(adap, data_reg);
255 if (FW_CMD_OP_GET(res >> 32) == FW_DEBUG_CMD) {
256 fw_asrt(adap, data_reg);
257 res = FW_CMD_RETVAL(EIO);
258 } else if (rpl)
259 get_mbox_rpl(adap, rpl, size / 8, data_reg);
260
261 if (FW_CMD_RETVAL_GET((int)res))
262 dump_mbox(adap, mbox, data_reg);
263 t4_write_reg(adap, ctl_reg, 0);
264 return -FW_CMD_RETVAL_GET((int)res);
265 }
266 }
267
268 dump_mbox(adap, mbox, data_reg);
269 dev_err(adap->pdev_dev, "command %#x in mailbox %d timed out\n",
270 *(const u8 *)cmd, mbox);
271 return -ETIMEDOUT;
272}
273
274/**
275 * t4_mc_read - read from MC through backdoor accesses
276 * @adap: the adapter
277 * @addr: address of first byte requested
278 * @data: 64 bytes of data containing the requested address
279 * @ecc: where to store the corresponding 64-bit ECC word
280 *
281 * Read 64 bytes of data from MC starting at a 64-byte-aligned address
282 * that covers the requested address @addr. If @parity is not %NULL it
283 * is assigned the 64-bit ECC word for the read data.
284 */
285int t4_mc_read(struct adapter *adap, u32 addr, __be32 *data, u64 *ecc)
286{
287 int i;
288
289 if (t4_read_reg(adap, MC_BIST_CMD) & START_BIST)
290 return -EBUSY;
291 t4_write_reg(adap, MC_BIST_CMD_ADDR, addr & ~0x3fU);
292 t4_write_reg(adap, MC_BIST_CMD_LEN, 64);
293 t4_write_reg(adap, MC_BIST_DATA_PATTERN, 0xc);
294 t4_write_reg(adap, MC_BIST_CMD, BIST_OPCODE(1) | START_BIST |
295 BIST_CMD_GAP(1));
296 i = t4_wait_op_done(adap, MC_BIST_CMD, START_BIST, 0, 10, 1);
297 if (i)
298 return i;
299
300#define MC_DATA(i) MC_BIST_STATUS_REG(MC_BIST_STATUS_RDATA, i)
301
302 for (i = 15; i >= 0; i--)
303 *data++ = htonl(t4_read_reg(adap, MC_DATA(i)));
304 if (ecc)
305 *ecc = t4_read_reg64(adap, MC_DATA(16));
306#undef MC_DATA
307 return 0;
308}
309
310/**
311 * t4_edc_read - read from EDC through backdoor accesses
312 * @adap: the adapter
313 * @idx: which EDC to access
314 * @addr: address of first byte requested
315 * @data: 64 bytes of data containing the requested address
316 * @ecc: where to store the corresponding 64-bit ECC word
317 *
318 * Read 64 bytes of data from EDC starting at a 64-byte-aligned address
319 * that covers the requested address @addr. If @parity is not %NULL it
320 * is assigned the 64-bit ECC word for the read data.
321 */
322int t4_edc_read(struct adapter *adap, int idx, u32 addr, __be32 *data, u64 *ecc)
323{
324 int i;
325
326 idx *= EDC_STRIDE;
327 if (t4_read_reg(adap, EDC_BIST_CMD + idx) & START_BIST)
328 return -EBUSY;
329 t4_write_reg(adap, EDC_BIST_CMD_ADDR + idx, addr & ~0x3fU);
330 t4_write_reg(adap, EDC_BIST_CMD_LEN + idx, 64);
331 t4_write_reg(adap, EDC_BIST_DATA_PATTERN + idx, 0xc);
332 t4_write_reg(adap, EDC_BIST_CMD + idx,
333 BIST_OPCODE(1) | BIST_CMD_GAP(1) | START_BIST);
334 i = t4_wait_op_done(adap, EDC_BIST_CMD + idx, START_BIST, 0, 10, 1);
335 if (i)
336 return i;
337
338#define EDC_DATA(i) (EDC_BIST_STATUS_REG(EDC_BIST_STATUS_RDATA, i) + idx)
339
340 for (i = 15; i >= 0; i--)
341 *data++ = htonl(t4_read_reg(adap, EDC_DATA(i)));
342 if (ecc)
343 *ecc = t4_read_reg64(adap, EDC_DATA(16));
344#undef EDC_DATA
345 return 0;
346}
347
348#define VPD_ENTRY(name, len) \
349 u8 name##_kword[2]; u8 name##_len; u8 name##_data[len]
350
351/*
352 * Partial EEPROM Vital Product Data structure. Includes only the ID and
353 * VPD-R sections.
354 */
355struct t4_vpd {
356 u8 id_tag;
357 u8 id_len[2];
358 u8 id_data[ID_LEN];
359 u8 vpdr_tag;
360 u8 vpdr_len[2];
361 VPD_ENTRY(pn, 16); /* part number */
362 VPD_ENTRY(ec, EC_LEN); /* EC level */
363 VPD_ENTRY(sn, SERNUM_LEN); /* serial number */
364 VPD_ENTRY(na, 12); /* MAC address base */
365 VPD_ENTRY(port_type, 8); /* port types */
366 VPD_ENTRY(gpio, 14); /* GPIO usage */
367 VPD_ENTRY(cclk, 6); /* core clock */
368 VPD_ENTRY(port_addr, 8); /* port MDIO addresses */
369 VPD_ENTRY(rv, 1); /* csum */
370 u32 pad; /* for multiple-of-4 sizing and alignment */
371};
372
373#define EEPROM_STAT_ADDR 0x7bfc
374#define VPD_BASE 0
375
376/**
377 * t4_seeprom_wp - enable/disable EEPROM write protection
378 * @adapter: the adapter
379 * @enable: whether to enable or disable write protection
380 *
381 * Enables or disables write protection on the serial EEPROM.
382 */
383int t4_seeprom_wp(struct adapter *adapter, bool enable)
384{
385 unsigned int v = enable ? 0xc : 0;
386 int ret = pci_write_vpd(adapter->pdev, EEPROM_STAT_ADDR, 4, &v);
387 return ret < 0 ? ret : 0;
388}
389
390/**
391 * get_vpd_params - read VPD parameters from VPD EEPROM
392 * @adapter: adapter to read
393 * @p: where to store the parameters
394 *
395 * Reads card parameters stored in VPD EEPROM.
396 */
397static int get_vpd_params(struct adapter *adapter, struct vpd_params *p)
398{
399 int ret;
400 struct t4_vpd vpd;
401 u8 *q = (u8 *)&vpd, csum;
402
403 ret = pci_read_vpd(adapter->pdev, VPD_BASE, sizeof(vpd), &vpd);
404 if (ret < 0)
405 return ret;
406
407 for (csum = 0; q <= vpd.rv_data; q++)
408 csum += *q;
409
410 if (csum) {
411 dev_err(adapter->pdev_dev,
412 "corrupted VPD EEPROM, actual csum %u\n", csum);
413 return -EINVAL;
414 }
415
416 p->cclk = simple_strtoul(vpd.cclk_data, NULL, 10);
417 memcpy(p->id, vpd.id_data, sizeof(vpd.id_data));
418 strim(p->id);
419 memcpy(p->ec, vpd.ec_data, sizeof(vpd.ec_data));
420 strim(p->ec);
421 memcpy(p->sn, vpd.sn_data, sizeof(vpd.sn_data));
422 strim(p->sn);
423 return 0;
424}
425
426/* serial flash and firmware constants */
427enum {
428 SF_ATTEMPTS = 10, /* max retries for SF operations */
429
430 /* flash command opcodes */
431 SF_PROG_PAGE = 2, /* program page */
432 SF_WR_DISABLE = 4, /* disable writes */
433 SF_RD_STATUS = 5, /* read status register */
434 SF_WR_ENABLE = 6, /* enable writes */
435 SF_RD_DATA_FAST = 0xb, /* read flash */
436 SF_ERASE_SECTOR = 0xd8, /* erase sector */
437
438 FW_START_SEC = 8, /* first flash sector for FW */
439 FW_END_SEC = 15, /* last flash sector for FW */
440 FW_IMG_START = FW_START_SEC * SF_SEC_SIZE,
441 FW_MAX_SIZE = (FW_END_SEC - FW_START_SEC + 1) * SF_SEC_SIZE,
442};
443
444/**
445 * sf1_read - read data from the serial flash
446 * @adapter: the adapter
447 * @byte_cnt: number of bytes to read
448 * @cont: whether another operation will be chained
449 * @lock: whether to lock SF for PL access only
450 * @valp: where to store the read data
451 *
452 * Reads up to 4 bytes of data from the serial flash. The location of
453 * the read needs to be specified prior to calling this by issuing the
454 * appropriate commands to the serial flash.
455 */
456static int sf1_read(struct adapter *adapter, unsigned int byte_cnt, int cont,
457 int lock, u32 *valp)
458{
459 int ret;
460
461 if (!byte_cnt || byte_cnt > 4)
462 return -EINVAL;
463 if (t4_read_reg(adapter, SF_OP) & BUSY)
464 return -EBUSY;
465 cont = cont ? SF_CONT : 0;
466 lock = lock ? SF_LOCK : 0;
467 t4_write_reg(adapter, SF_OP, lock | cont | BYTECNT(byte_cnt - 1));
468 ret = t4_wait_op_done(adapter, SF_OP, BUSY, 0, SF_ATTEMPTS, 5);
469 if (!ret)
470 *valp = t4_read_reg(adapter, SF_DATA);
471 return ret;
472}
473
474/**
475 * sf1_write - write data to the serial flash
476 * @adapter: the adapter
477 * @byte_cnt: number of bytes to write
478 * @cont: whether another operation will be chained
479 * @lock: whether to lock SF for PL access only
480 * @val: value to write
481 *
482 * Writes up to 4 bytes of data to the serial flash. The location of
483 * the write needs to be specified prior to calling this by issuing the
484 * appropriate commands to the serial flash.
485 */
486static int sf1_write(struct adapter *adapter, unsigned int byte_cnt, int cont,
487 int lock, u32 val)
488{
489 if (!byte_cnt || byte_cnt > 4)
490 return -EINVAL;
491 if (t4_read_reg(adapter, SF_OP) & BUSY)
492 return -EBUSY;
493 cont = cont ? SF_CONT : 0;
494 lock = lock ? SF_LOCK : 0;
495 t4_write_reg(adapter, SF_DATA, val);
496 t4_write_reg(adapter, SF_OP, lock |
497 cont | BYTECNT(byte_cnt - 1) | OP_WR);
498 return t4_wait_op_done(adapter, SF_OP, BUSY, 0, SF_ATTEMPTS, 5);
499}
500
501/**
502 * flash_wait_op - wait for a flash operation to complete
503 * @adapter: the adapter
504 * @attempts: max number of polls of the status register
505 * @delay: delay between polls in ms
506 *
507 * Wait for a flash operation to complete by polling the status register.
508 */
509static int flash_wait_op(struct adapter *adapter, int attempts, int delay)
510{
511 int ret;
512 u32 status;
513
514 while (1) {
515 if ((ret = sf1_write(adapter, 1, 1, 1, SF_RD_STATUS)) != 0 ||
516 (ret = sf1_read(adapter, 1, 0, 1, &status)) != 0)
517 return ret;
518 if (!(status & 1))
519 return 0;
520 if (--attempts == 0)
521 return -EAGAIN;
522 if (delay)
523 msleep(delay);
524 }
525}
526
527/**
528 * t4_read_flash - read words from serial flash
529 * @adapter: the adapter
530 * @addr: the start address for the read
531 * @nwords: how many 32-bit words to read
532 * @data: where to store the read data
533 * @byte_oriented: whether to store data as bytes or as words
534 *
535 * Read the specified number of 32-bit words from the serial flash.
536 * If @byte_oriented is set the read data is stored as a byte array
537 * (i.e., big-endian), otherwise as 32-bit words in the platform's
538 * natural endianess.
539 */
540int t4_read_flash(struct adapter *adapter, unsigned int addr,
541 unsigned int nwords, u32 *data, int byte_oriented)
542{
543 int ret;
544
545 if (addr + nwords * sizeof(u32) > SF_SIZE || (addr & 3))
546 return -EINVAL;
547
548 addr = swab32(addr) | SF_RD_DATA_FAST;
549
550 if ((ret = sf1_write(adapter, 4, 1, 0, addr)) != 0 ||
551 (ret = sf1_read(adapter, 1, 1, 0, data)) != 0)
552 return ret;
553
554 for ( ; nwords; nwords--, data++) {
555 ret = sf1_read(adapter, 4, nwords > 1, nwords == 1, data);
556 if (nwords == 1)
557 t4_write_reg(adapter, SF_OP, 0); /* unlock SF */
558 if (ret)
559 return ret;
560 if (byte_oriented)
561 *data = htonl(*data);
562 }
563 return 0;
564}
565
566/**
567 * t4_write_flash - write up to a page of data to the serial flash
568 * @adapter: the adapter
569 * @addr: the start address to write
570 * @n: length of data to write in bytes
571 * @data: the data to write
572 *
573 * Writes up to a page of data (256 bytes) to the serial flash starting
574 * at the given address. All the data must be written to the same page.
575 */
576static int t4_write_flash(struct adapter *adapter, unsigned int addr,
577 unsigned int n, const u8 *data)
578{
579 int ret;
580 u32 buf[64];
581 unsigned int i, c, left, val, offset = addr & 0xff;
582
583 if (addr >= SF_SIZE || offset + n > SF_PAGE_SIZE)
584 return -EINVAL;
585
586 val = swab32(addr) | SF_PROG_PAGE;
587
588 if ((ret = sf1_write(adapter, 1, 0, 1, SF_WR_ENABLE)) != 0 ||
589 (ret = sf1_write(adapter, 4, 1, 1, val)) != 0)
590 goto unlock;
591
592 for (left = n; left; left -= c) {
593 c = min(left, 4U);
594 for (val = 0, i = 0; i < c; ++i)
595 val = (val << 8) + *data++;
596
597 ret = sf1_write(adapter, c, c != left, 1, val);
598 if (ret)
599 goto unlock;
600 }
601 ret = flash_wait_op(adapter, 5, 1);
602 if (ret)
603 goto unlock;
604
605 t4_write_reg(adapter, SF_OP, 0); /* unlock SF */
606
607 /* Read the page to verify the write succeeded */
608 ret = t4_read_flash(adapter, addr & ~0xff, ARRAY_SIZE(buf), buf, 1);
609 if (ret)
610 return ret;
611
612 if (memcmp(data - n, (u8 *)buf + offset, n)) {
613 dev_err(adapter->pdev_dev,
614 "failed to correctly write the flash page at %#x\n",
615 addr);
616 return -EIO;
617 }
618 return 0;
619
620unlock:
621 t4_write_reg(adapter, SF_OP, 0); /* unlock SF */
622 return ret;
623}
624
625/**
626 * get_fw_version - read the firmware version
627 * @adapter: the adapter
628 * @vers: where to place the version
629 *
630 * Reads the FW version from flash.
631 */
632static int get_fw_version(struct adapter *adapter, u32 *vers)
633{
634 return t4_read_flash(adapter,
635 FW_IMG_START + offsetof(struct fw_hdr, fw_ver), 1,
636 vers, 0);
637}
638
639/**
640 * get_tp_version - read the TP microcode version
641 * @adapter: the adapter
642 * @vers: where to place the version
643 *
644 * Reads the TP microcode version from flash.
645 */
646static int get_tp_version(struct adapter *adapter, u32 *vers)
647{
648 return t4_read_flash(adapter, FW_IMG_START + offsetof(struct fw_hdr,
649 tp_microcode_ver),
650 1, vers, 0);
651}
652
653/**
654 * t4_check_fw_version - check if the FW is compatible with this driver
655 * @adapter: the adapter
656 *
657 * Checks if an adapter's FW is compatible with the driver. Returns 0
658 * if there's exact match, a negative error if the version could not be
659 * read or there's a major version mismatch, and a positive value if the
660 * expected major version is found but there's a minor version mismatch.
661 */
662int t4_check_fw_version(struct adapter *adapter)
663{
664 u32 api_vers[2];
665 int ret, major, minor, micro;
666
667 ret = get_fw_version(adapter, &adapter->params.fw_vers);
668 if (!ret)
669 ret = get_tp_version(adapter, &adapter->params.tp_vers);
670 if (!ret)
671 ret = t4_read_flash(adapter,
672 FW_IMG_START + offsetof(struct fw_hdr, intfver_nic),
673 2, api_vers, 1);
674 if (ret)
675 return ret;
676
677 major = FW_HDR_FW_VER_MAJOR_GET(adapter->params.fw_vers);
678 minor = FW_HDR_FW_VER_MINOR_GET(adapter->params.fw_vers);
679 micro = FW_HDR_FW_VER_MICRO_GET(adapter->params.fw_vers);
680 memcpy(adapter->params.api_vers, api_vers,
681 sizeof(adapter->params.api_vers));
682
683 if (major != FW_VERSION_MAJOR) { /* major mismatch - fail */
684 dev_err(adapter->pdev_dev,
685 "card FW has major version %u, driver wants %u\n",
686 major, FW_VERSION_MAJOR);
687 return -EINVAL;
688 }
689
690 if (minor == FW_VERSION_MINOR && micro == FW_VERSION_MICRO)
691 return 0; /* perfect match */
692
693 /* Minor/micro version mismatch. Report it but often it's OK. */
694 return 1;
695}
696
697/**
698 * t4_flash_erase_sectors - erase a range of flash sectors
699 * @adapter: the adapter
700 * @start: the first sector to erase
701 * @end: the last sector to erase
702 *
703 * Erases the sectors in the given inclusive range.
704 */
705static int t4_flash_erase_sectors(struct adapter *adapter, int start, int end)
706{
707 int ret = 0;
708
709 while (start <= end) {
710 if ((ret = sf1_write(adapter, 1, 0, 1, SF_WR_ENABLE)) != 0 ||
711 (ret = sf1_write(adapter, 4, 0, 1,
712 SF_ERASE_SECTOR | (start << 8))) != 0 ||
713 (ret = flash_wait_op(adapter, 5, 500)) != 0) {
714 dev_err(adapter->pdev_dev,
715 "erase of flash sector %d failed, error %d\n",
716 start, ret);
717 break;
718 }
719 start++;
720 }
721 t4_write_reg(adapter, SF_OP, 0); /* unlock SF */
722 return ret;
723}
724
725/**
726 * t4_load_fw - download firmware
727 * @adap: the adapter
728 * @fw_data: the firmware image to write
729 * @size: image size
730 *
731 * Write the supplied firmware image to the card's serial flash.
732 */
733int t4_load_fw(struct adapter *adap, const u8 *fw_data, unsigned int size)
734{
735 u32 csum;
736 int ret, addr;
737 unsigned int i;
738 u8 first_page[SF_PAGE_SIZE];
739 const u32 *p = (const u32 *)fw_data;
740 const struct fw_hdr *hdr = (const struct fw_hdr *)fw_data;
741
742 if (!size) {
743 dev_err(adap->pdev_dev, "FW image has no data\n");
744 return -EINVAL;
745 }
746 if (size & 511) {
747 dev_err(adap->pdev_dev,
748 "FW image size not multiple of 512 bytes\n");
749 return -EINVAL;
750 }
751 if (ntohs(hdr->len512) * 512 != size) {
752 dev_err(adap->pdev_dev,
753 "FW image size differs from size in FW header\n");
754 return -EINVAL;
755 }
756 if (size > FW_MAX_SIZE) {
757 dev_err(adap->pdev_dev, "FW image too large, max is %u bytes\n",
758 FW_MAX_SIZE);
759 return -EFBIG;
760 }
761
762 for (csum = 0, i = 0; i < size / sizeof(csum); i++)
763 csum += ntohl(p[i]);
764
765 if (csum != 0xffffffff) {
766 dev_err(adap->pdev_dev,
767 "corrupted firmware image, checksum %#x\n", csum);
768 return -EINVAL;
769 }
770
771 i = DIV_ROUND_UP(size, SF_SEC_SIZE); /* # of sectors spanned */
772 ret = t4_flash_erase_sectors(adap, FW_START_SEC, FW_START_SEC + i - 1);
773 if (ret)
774 goto out;
775
776 /*
777 * We write the correct version at the end so the driver can see a bad
778 * version if the FW write fails. Start by writing a copy of the
779 * first page with a bad version.
780 */
781 memcpy(first_page, fw_data, SF_PAGE_SIZE);
782 ((struct fw_hdr *)first_page)->fw_ver = htonl(0xffffffff);
783 ret = t4_write_flash(adap, FW_IMG_START, SF_PAGE_SIZE, first_page);
784 if (ret)
785 goto out;
786
787 addr = FW_IMG_START;
788 for (size -= SF_PAGE_SIZE; size; size -= SF_PAGE_SIZE) {
789 addr += SF_PAGE_SIZE;
790 fw_data += SF_PAGE_SIZE;
791 ret = t4_write_flash(adap, addr, SF_PAGE_SIZE, fw_data);
792 if (ret)
793 goto out;
794 }
795
796 ret = t4_write_flash(adap,
797 FW_IMG_START + offsetof(struct fw_hdr, fw_ver),
798 sizeof(hdr->fw_ver), (const u8 *)&hdr->fw_ver);
799out:
800 if (ret)
801 dev_err(adap->pdev_dev, "firmware download failed, error %d\n",
802 ret);
803 return ret;
804}
805
806#define ADVERT_MASK (FW_PORT_CAP_SPEED_100M | FW_PORT_CAP_SPEED_1G |\
807 FW_PORT_CAP_SPEED_10G | FW_PORT_CAP_ANEG)
808
809/**
810 * t4_link_start - apply link configuration to MAC/PHY
811 * @phy: the PHY to setup
812 * @mac: the MAC to setup
813 * @lc: the requested link configuration
814 *
815 * Set up a port's MAC and PHY according to a desired link configuration.
816 * - If the PHY can auto-negotiate first decide what to advertise, then
817 * enable/disable auto-negotiation as desired, and reset.
818 * - If the PHY does not auto-negotiate just reset it.
819 * - If auto-negotiation is off set the MAC to the proper speed/duplex/FC,
820 * otherwise do it later based on the outcome of auto-negotiation.
821 */
822int t4_link_start(struct adapter *adap, unsigned int mbox, unsigned int port,
823 struct link_config *lc)
824{
825 struct fw_port_cmd c;
826 unsigned int fc = 0, mdi = FW_PORT_MDI(FW_PORT_MDI_AUTO);
827
828 lc->link_ok = 0;
829 if (lc->requested_fc & PAUSE_RX)
830 fc |= FW_PORT_CAP_FC_RX;
831 if (lc->requested_fc & PAUSE_TX)
832 fc |= FW_PORT_CAP_FC_TX;
833
834 memset(&c, 0, sizeof(c));
835 c.op_to_portid = htonl(FW_CMD_OP(FW_PORT_CMD) | FW_CMD_REQUEST |
836 FW_CMD_EXEC | FW_PORT_CMD_PORTID(port));
837 c.action_to_len16 = htonl(FW_PORT_CMD_ACTION(FW_PORT_ACTION_L1_CFG) |
838 FW_LEN16(c));
839
840 if (!(lc->supported & FW_PORT_CAP_ANEG)) {
841 c.u.l1cfg.rcap = htonl((lc->supported & ADVERT_MASK) | fc);
842 lc->fc = lc->requested_fc & (PAUSE_RX | PAUSE_TX);
843 } else if (lc->autoneg == AUTONEG_DISABLE) {
844 c.u.l1cfg.rcap = htonl(lc->requested_speed | fc | mdi);
845 lc->fc = lc->requested_fc & (PAUSE_RX | PAUSE_TX);
846 } else
847 c.u.l1cfg.rcap = htonl(lc->advertising | fc | mdi);
848
849 return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
850}
851
852/**
853 * t4_restart_aneg - restart autonegotiation
854 * @adap: the adapter
855 * @mbox: mbox to use for the FW command
856 * @port: the port id
857 *
858 * Restarts autonegotiation for the selected port.
859 */
860int t4_restart_aneg(struct adapter *adap, unsigned int mbox, unsigned int port)
861{
862 struct fw_port_cmd c;
863
864 memset(&c, 0, sizeof(c));
865 c.op_to_portid = htonl(FW_CMD_OP(FW_PORT_CMD) | FW_CMD_REQUEST |
866 FW_CMD_EXEC | FW_PORT_CMD_PORTID(port));
867 c.action_to_len16 = htonl(FW_PORT_CMD_ACTION(FW_PORT_ACTION_L1_CFG) |
868 FW_LEN16(c));
869 c.u.l1cfg.rcap = htonl(FW_PORT_CAP_ANEG);
870 return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
871}
872
873/**
874 * t4_set_vlan_accel - configure HW VLAN extraction
875 * @adap: the adapter
876 * @ports: bitmap of adapter ports to operate on
877 * @on: enable (1) or disable (0) HW VLAN extraction
878 *
879 * Enables or disables HW extraction of VLAN tags for the ports specified
880 * by @ports. @ports is a bitmap with the ith bit designating the port
881 * associated with the ith adapter channel.
882 */
883void t4_set_vlan_accel(struct adapter *adap, unsigned int ports, int on)
884{
885 ports <<= VLANEXTENABLE_SHIFT;
886 t4_set_reg_field(adap, TP_OUT_CONFIG, ports, on ? ports : 0);
887}
888
889struct intr_info {
890 unsigned int mask; /* bits to check in interrupt status */
891 const char *msg; /* message to print or NULL */
892 short stat_idx; /* stat counter to increment or -1 */
893 unsigned short fatal; /* whether the condition reported is fatal */
894};
895
896/**
897 * t4_handle_intr_status - table driven interrupt handler
898 * @adapter: the adapter that generated the interrupt
899 * @reg: the interrupt status register to process
900 * @acts: table of interrupt actions
901 *
902 * A table driven interrupt handler that applies a set of masks to an
903 * interrupt status word and performs the corresponding actions if the
904 * interrupts described by the mask have occured. The actions include
905 * optionally emitting a warning or alert message. The table is terminated
906 * by an entry specifying mask 0. Returns the number of fatal interrupt
907 * conditions.
908 */
909static int t4_handle_intr_status(struct adapter *adapter, unsigned int reg,
910 const struct intr_info *acts)
911{
912 int fatal = 0;
913 unsigned int mask = 0;
914 unsigned int status = t4_read_reg(adapter, reg);
915
916 for ( ; acts->mask; ++acts) {
917 if (!(status & acts->mask))
918 continue;
919 if (acts->fatal) {
920 fatal++;
921 dev_alert(adapter->pdev_dev, "%s (0x%x)\n", acts->msg,
922 status & acts->mask);
923 } else if (acts->msg && printk_ratelimit())
924 dev_warn(adapter->pdev_dev, "%s (0x%x)\n", acts->msg,
925 status & acts->mask);
926 mask |= acts->mask;
927 }
928 status &= mask;
929 if (status) /* clear processed interrupts */
930 t4_write_reg(adapter, reg, status);
931 return fatal;
932}
933
934/*
935 * Interrupt handler for the PCIE module.
936 */
937static void pcie_intr_handler(struct adapter *adapter)
938{
939 static struct intr_info sysbus_intr_info[] = {
940 { RNPP, "RXNP array parity error", -1, 1 },
941 { RPCP, "RXPC array parity error", -1, 1 },
942 { RCIP, "RXCIF array parity error", -1, 1 },
943 { RCCP, "Rx completions control array parity error", -1, 1 },
944 { RFTP, "RXFT array parity error", -1, 1 },
945 { 0 }
946 };
947 static struct intr_info pcie_port_intr_info[] = {
948 { TPCP, "TXPC array parity error", -1, 1 },
949 { TNPP, "TXNP array parity error", -1, 1 },
950 { TFTP, "TXFT array parity error", -1, 1 },
951 { TCAP, "TXCA array parity error", -1, 1 },
952 { TCIP, "TXCIF array parity error", -1, 1 },
953 { RCAP, "RXCA array parity error", -1, 1 },
954 { OTDD, "outbound request TLP discarded", -1, 1 },
955 { RDPE, "Rx data parity error", -1, 1 },
956 { TDUE, "Tx uncorrectable data error", -1, 1 },
957 { 0 }
958 };
959 static struct intr_info pcie_intr_info[] = {
960 { MSIADDRLPERR, "MSI AddrL parity error", -1, 1 },
961 { MSIADDRHPERR, "MSI AddrH parity error", -1, 1 },
962 { MSIDATAPERR, "MSI data parity error", -1, 1 },
963 { MSIXADDRLPERR, "MSI-X AddrL parity error", -1, 1 },
964 { MSIXADDRHPERR, "MSI-X AddrH parity error", -1, 1 },
965 { MSIXDATAPERR, "MSI-X data parity error", -1, 1 },
966 { MSIXDIPERR, "MSI-X DI parity error", -1, 1 },
967 { PIOCPLPERR, "PCI PIO completion FIFO parity error", -1, 1 },
968 { PIOREQPERR, "PCI PIO request FIFO parity error", -1, 1 },
969 { TARTAGPERR, "PCI PCI target tag FIFO parity error", -1, 1 },
970 { CCNTPERR, "PCI CMD channel count parity error", -1, 1 },
971 { CREQPERR, "PCI CMD channel request parity error", -1, 1 },
972 { CRSPPERR, "PCI CMD channel response parity error", -1, 1 },
973 { DCNTPERR, "PCI DMA channel count parity error", -1, 1 },
974 { DREQPERR, "PCI DMA channel request parity error", -1, 1 },
975 { DRSPPERR, "PCI DMA channel response parity error", -1, 1 },
976 { HCNTPERR, "PCI HMA channel count parity error", -1, 1 },
977 { HREQPERR, "PCI HMA channel request parity error", -1, 1 },
978 { HRSPPERR, "PCI HMA channel response parity error", -1, 1 },
979 { CFGSNPPERR, "PCI config snoop FIFO parity error", -1, 1 },
980 { FIDPERR, "PCI FID parity error", -1, 1 },
981 { INTXCLRPERR, "PCI INTx clear parity error", -1, 1 },
982 { MATAGPERR, "PCI MA tag parity error", -1, 1 },
983 { PIOTAGPERR, "PCI PIO tag parity error", -1, 1 },
984 { RXCPLPERR, "PCI Rx completion parity error", -1, 1 },
985 { RXWRPERR, "PCI Rx write parity error", -1, 1 },
986 { RPLPERR, "PCI replay buffer parity error", -1, 1 },
987 { PCIESINT, "PCI core secondary fault", -1, 1 },
988 { PCIEPINT, "PCI core primary fault", -1, 1 },
989 { UNXSPLCPLERR, "PCI unexpected split completion error", -1, 0 },
990 { 0 }
991 };
992
993 int fat;
994
995 fat = t4_handle_intr_status(adapter,
996 PCIE_CORE_UTL_SYSTEM_BUS_AGENT_STATUS,
997 sysbus_intr_info) +
998 t4_handle_intr_status(adapter,
999 PCIE_CORE_UTL_PCI_EXPRESS_PORT_STATUS,
1000 pcie_port_intr_info) +
1001 t4_handle_intr_status(adapter, PCIE_INT_CAUSE, pcie_intr_info);
1002 if (fat)
1003 t4_fatal_err(adapter);
1004}
1005
1006/*
1007 * TP interrupt handler.
1008 */
1009static void tp_intr_handler(struct adapter *adapter)
1010{
1011 static struct intr_info tp_intr_info[] = {
1012 { 0x3fffffff, "TP parity error", -1, 1 },
1013 { FLMTXFLSTEMPTY, "TP out of Tx pages", -1, 1 },
1014 { 0 }
1015 };
1016
1017 if (t4_handle_intr_status(adapter, TP_INT_CAUSE, tp_intr_info))
1018 t4_fatal_err(adapter);
1019}
1020
1021/*
1022 * SGE interrupt handler.
1023 */
1024static void sge_intr_handler(struct adapter *adapter)
1025{
1026 u64 v;
1027
1028 static struct intr_info sge_intr_info[] = {
1029 { ERR_CPL_EXCEED_IQE_SIZE,
1030 "SGE received CPL exceeding IQE size", -1, 1 },
1031 { ERR_INVALID_CIDX_INC,
1032 "SGE GTS CIDX increment too large", -1, 0 },
1033 { ERR_CPL_OPCODE_0, "SGE received 0-length CPL", -1, 0 },
1034 { ERR_DROPPED_DB, "SGE doorbell dropped", -1, 0 },
1035 { ERR_DATA_CPL_ON_HIGH_QID1 | ERR_DATA_CPL_ON_HIGH_QID0,
1036 "SGE IQID > 1023 received CPL for FL", -1, 0 },
1037 { ERR_BAD_DB_PIDX3, "SGE DBP 3 pidx increment too large", -1,
1038 0 },
1039 { ERR_BAD_DB_PIDX2, "SGE DBP 2 pidx increment too large", -1,
1040 0 },
1041 { ERR_BAD_DB_PIDX1, "SGE DBP 1 pidx increment too large", -1,
1042 0 },
1043 { ERR_BAD_DB_PIDX0, "SGE DBP 0 pidx increment too large", -1,
1044 0 },
1045 { ERR_ING_CTXT_PRIO,
1046 "SGE too many priority ingress contexts", -1, 0 },
1047 { ERR_EGR_CTXT_PRIO,
1048 "SGE too many priority egress contexts", -1, 0 },
1049 { INGRESS_SIZE_ERR, "SGE illegal ingress QID", -1, 0 },
1050 { EGRESS_SIZE_ERR, "SGE illegal egress QID", -1, 0 },
1051 { 0 }
1052 };
1053
1054 v = (u64)t4_read_reg(adapter, SGE_INT_CAUSE1) |
1055 ((u64)t4_read_reg(adapter, SGE_INT_CAUSE2) << 32);
1056 if (v) {
1057 dev_alert(adapter->pdev_dev, "SGE parity error (%#llx)\n",
1058 (unsigned long long)v);
1059 t4_write_reg(adapter, SGE_INT_CAUSE1, v);
1060 t4_write_reg(adapter, SGE_INT_CAUSE2, v >> 32);
1061 }
1062
1063 if (t4_handle_intr_status(adapter, SGE_INT_CAUSE3, sge_intr_info) ||
1064 v != 0)
1065 t4_fatal_err(adapter);
1066}
1067
1068/*
1069 * CIM interrupt handler.
1070 */
1071static void cim_intr_handler(struct adapter *adapter)
1072{
1073 static struct intr_info cim_intr_info[] = {
1074 { PREFDROPINT, "CIM control register prefetch drop", -1, 1 },
1075 { OBQPARERR, "CIM OBQ parity error", -1, 1 },
1076 { IBQPARERR, "CIM IBQ parity error", -1, 1 },
1077 { MBUPPARERR, "CIM mailbox uP parity error", -1, 1 },
1078 { MBHOSTPARERR, "CIM mailbox host parity error", -1, 1 },
1079 { TIEQINPARERRINT, "CIM TIEQ outgoing parity error", -1, 1 },
1080 { TIEQOUTPARERRINT, "CIM TIEQ incoming parity error", -1, 1 },
1081 { 0 }
1082 };
1083 static struct intr_info cim_upintr_info[] = {
1084 { RSVDSPACEINT, "CIM reserved space access", -1, 1 },
1085 { ILLTRANSINT, "CIM illegal transaction", -1, 1 },
1086 { ILLWRINT, "CIM illegal write", -1, 1 },
1087 { ILLRDINT, "CIM illegal read", -1, 1 },
1088 { ILLRDBEINT, "CIM illegal read BE", -1, 1 },
1089 { ILLWRBEINT, "CIM illegal write BE", -1, 1 },
1090 { SGLRDBOOTINT, "CIM single read from boot space", -1, 1 },
1091 { SGLWRBOOTINT, "CIM single write to boot space", -1, 1 },
1092 { BLKWRBOOTINT, "CIM block write to boot space", -1, 1 },
1093 { SGLRDFLASHINT, "CIM single read from flash space", -1, 1 },
1094 { SGLWRFLASHINT, "CIM single write to flash space", -1, 1 },
1095 { BLKWRFLASHINT, "CIM block write to flash space", -1, 1 },
1096 { SGLRDEEPROMINT, "CIM single EEPROM read", -1, 1 },
1097 { SGLWREEPROMINT, "CIM single EEPROM write", -1, 1 },
1098 { BLKRDEEPROMINT, "CIM block EEPROM read", -1, 1 },
1099 { BLKWREEPROMINT, "CIM block EEPROM write", -1, 1 },
1100 { SGLRDCTLINT , "CIM single read from CTL space", -1, 1 },
1101 { SGLWRCTLINT , "CIM single write to CTL space", -1, 1 },
1102 { BLKRDCTLINT , "CIM block read from CTL space", -1, 1 },
1103 { BLKWRCTLINT , "CIM block write to CTL space", -1, 1 },
1104 { SGLRDPLINT , "CIM single read from PL space", -1, 1 },
1105 { SGLWRPLINT , "CIM single write to PL space", -1, 1 },
1106 { BLKRDPLINT , "CIM block read from PL space", -1, 1 },
1107 { BLKWRPLINT , "CIM block write to PL space", -1, 1 },
1108 { REQOVRLOOKUPINT , "CIM request FIFO overwrite", -1, 1 },
1109 { RSPOVRLOOKUPINT , "CIM response FIFO overwrite", -1, 1 },
1110 { TIMEOUTINT , "CIM PIF timeout", -1, 1 },
1111 { TIMEOUTMAINT , "CIM PIF MA timeout", -1, 1 },
1112 { 0 }
1113 };
1114
1115 int fat;
1116
1117 fat = t4_handle_intr_status(adapter, CIM_HOST_INT_CAUSE,
1118 cim_intr_info) +
1119 t4_handle_intr_status(adapter, CIM_HOST_UPACC_INT_CAUSE,
1120 cim_upintr_info);
1121 if (fat)
1122 t4_fatal_err(adapter);
1123}
1124
1125/*
1126 * ULP RX interrupt handler.
1127 */
1128static void ulprx_intr_handler(struct adapter *adapter)
1129{
1130 static struct intr_info ulprx_intr_info[] = {
1131 { 0x7fffff, "ULPRX parity error", -1, 1 },
1132 { 0 }
1133 };
1134
1135 if (t4_handle_intr_status(adapter, ULP_RX_INT_CAUSE, ulprx_intr_info))
1136 t4_fatal_err(adapter);
1137}
1138
1139/*
1140 * ULP TX interrupt handler.
1141 */
1142static void ulptx_intr_handler(struct adapter *adapter)
1143{
1144 static struct intr_info ulptx_intr_info[] = {
1145 { PBL_BOUND_ERR_CH3, "ULPTX channel 3 PBL out of bounds", -1,
1146 0 },
1147 { PBL_BOUND_ERR_CH2, "ULPTX channel 2 PBL out of bounds", -1,
1148 0 },
1149 { PBL_BOUND_ERR_CH1, "ULPTX channel 1 PBL out of bounds", -1,
1150 0 },
1151 { PBL_BOUND_ERR_CH0, "ULPTX channel 0 PBL out of bounds", -1,
1152 0 },
1153 { 0xfffffff, "ULPTX parity error", -1, 1 },
1154 { 0 }
1155 };
1156
1157 if (t4_handle_intr_status(adapter, ULP_TX_INT_CAUSE, ulptx_intr_info))
1158 t4_fatal_err(adapter);
1159}
1160
1161/*
1162 * PM TX interrupt handler.
1163 */
1164static void pmtx_intr_handler(struct adapter *adapter)
1165{
1166 static struct intr_info pmtx_intr_info[] = {
1167 { PCMD_LEN_OVFL0, "PMTX channel 0 pcmd too large", -1, 1 },
1168 { PCMD_LEN_OVFL1, "PMTX channel 1 pcmd too large", -1, 1 },
1169 { PCMD_LEN_OVFL2, "PMTX channel 2 pcmd too large", -1, 1 },
1170 { ZERO_C_CMD_ERROR, "PMTX 0-length pcmd", -1, 1 },
1171 { PMTX_FRAMING_ERROR, "PMTX framing error", -1, 1 },
1172 { OESPI_PAR_ERROR, "PMTX oespi parity error", -1, 1 },
1173 { DB_OPTIONS_PAR_ERROR, "PMTX db_options parity error", -1, 1 },
1174 { ICSPI_PAR_ERROR, "PMTX icspi parity error", -1, 1 },
1175 { C_PCMD_PAR_ERROR, "PMTX c_pcmd parity error", -1, 1},
1176 { 0 }
1177 };
1178
1179 if (t4_handle_intr_status(adapter, PM_TX_INT_CAUSE, pmtx_intr_info))
1180 t4_fatal_err(adapter);
1181}
1182
1183/*
1184 * PM RX interrupt handler.
1185 */
1186static void pmrx_intr_handler(struct adapter *adapter)
1187{
1188 static struct intr_info pmrx_intr_info[] = {
1189 { ZERO_E_CMD_ERROR, "PMRX 0-length pcmd", -1, 1 },
1190 { PMRX_FRAMING_ERROR, "PMRX framing error", -1, 1 },
1191 { OCSPI_PAR_ERROR, "PMRX ocspi parity error", -1, 1 },
1192 { DB_OPTIONS_PAR_ERROR, "PMRX db_options parity error", -1, 1 },
1193 { IESPI_PAR_ERROR, "PMRX iespi parity error", -1, 1 },
1194 { E_PCMD_PAR_ERROR, "PMRX e_pcmd parity error", -1, 1},
1195 { 0 }
1196 };
1197
1198 if (t4_handle_intr_status(adapter, PM_RX_INT_CAUSE, pmrx_intr_info))
1199 t4_fatal_err(adapter);
1200}
1201
1202/*
1203 * CPL switch interrupt handler.
1204 */
1205static void cplsw_intr_handler(struct adapter *adapter)
1206{
1207 static struct intr_info cplsw_intr_info[] = {
1208 { CIM_OP_MAP_PERR, "CPLSW CIM op_map parity error", -1, 1 },
1209 { CIM_OVFL_ERROR, "CPLSW CIM overflow", -1, 1 },
1210 { TP_FRAMING_ERROR, "CPLSW TP framing error", -1, 1 },
1211 { SGE_FRAMING_ERROR, "CPLSW SGE framing error", -1, 1 },
1212 { CIM_FRAMING_ERROR, "CPLSW CIM framing error", -1, 1 },
1213 { ZERO_SWITCH_ERROR, "CPLSW no-switch error", -1, 1 },
1214 { 0 }
1215 };
1216
1217 if (t4_handle_intr_status(adapter, CPL_INTR_CAUSE, cplsw_intr_info))
1218 t4_fatal_err(adapter);
1219}
1220
1221/*
1222 * LE interrupt handler.
1223 */
1224static void le_intr_handler(struct adapter *adap)
1225{
1226 static struct intr_info le_intr_info[] = {
1227 { LIPMISS, "LE LIP miss", -1, 0 },
1228 { LIP0, "LE 0 LIP error", -1, 0 },
1229 { PARITYERR, "LE parity error", -1, 1 },
1230 { UNKNOWNCMD, "LE unknown command", -1, 1 },
1231 { REQQPARERR, "LE request queue parity error", -1, 1 },
1232 { 0 }
1233 };
1234
1235 if (t4_handle_intr_status(adap, LE_DB_INT_CAUSE, le_intr_info))
1236 t4_fatal_err(adap);
1237}
1238
1239/*
1240 * MPS interrupt handler.
1241 */
1242static void mps_intr_handler(struct adapter *adapter)
1243{
1244 static struct intr_info mps_rx_intr_info[] = {
1245 { 0xffffff, "MPS Rx parity error", -1, 1 },
1246 { 0 }
1247 };
1248 static struct intr_info mps_tx_intr_info[] = {
1249 { TPFIFO, "MPS Tx TP FIFO parity error", -1, 1 },
1250 { NCSIFIFO, "MPS Tx NC-SI FIFO parity error", -1, 1 },
1251 { TXDATAFIFO, "MPS Tx data FIFO parity error", -1, 1 },
1252 { TXDESCFIFO, "MPS Tx desc FIFO parity error", -1, 1 },
1253 { BUBBLE, "MPS Tx underflow", -1, 1 },
1254 { SECNTERR, "MPS Tx SOP/EOP error", -1, 1 },
1255 { FRMERR, "MPS Tx framing error", -1, 1 },
1256 { 0 }
1257 };
1258 static struct intr_info mps_trc_intr_info[] = {
1259 { FILTMEM, "MPS TRC filter parity error", -1, 1 },
1260 { PKTFIFO, "MPS TRC packet FIFO parity error", -1, 1 },
1261 { MISCPERR, "MPS TRC misc parity error", -1, 1 },
1262 { 0 }
1263 };
1264 static struct intr_info mps_stat_sram_intr_info[] = {
1265 { 0x1fffff, "MPS statistics SRAM parity error", -1, 1 },
1266 { 0 }
1267 };
1268 static struct intr_info mps_stat_tx_intr_info[] = {
1269 { 0xfffff, "MPS statistics Tx FIFO parity error", -1, 1 },
1270 { 0 }
1271 };
1272 static struct intr_info mps_stat_rx_intr_info[] = {
1273 { 0xffffff, "MPS statistics Rx FIFO parity error", -1, 1 },
1274 { 0 }
1275 };
1276 static struct intr_info mps_cls_intr_info[] = {
1277 { MATCHSRAM, "MPS match SRAM parity error", -1, 1 },
1278 { MATCHTCAM, "MPS match TCAM parity error", -1, 1 },
1279 { HASHSRAM, "MPS hash SRAM parity error", -1, 1 },
1280 { 0 }
1281 };
1282
1283 int fat;
1284
1285 fat = t4_handle_intr_status(adapter, MPS_RX_PERR_INT_CAUSE,
1286 mps_rx_intr_info) +
1287 t4_handle_intr_status(adapter, MPS_TX_INT_CAUSE,
1288 mps_tx_intr_info) +
1289 t4_handle_intr_status(adapter, MPS_TRC_INT_CAUSE,
1290 mps_trc_intr_info) +
1291 t4_handle_intr_status(adapter, MPS_STAT_PERR_INT_CAUSE_SRAM,
1292 mps_stat_sram_intr_info) +
1293 t4_handle_intr_status(adapter, MPS_STAT_PERR_INT_CAUSE_TX_FIFO,
1294 mps_stat_tx_intr_info) +
1295 t4_handle_intr_status(adapter, MPS_STAT_PERR_INT_CAUSE_RX_FIFO,
1296 mps_stat_rx_intr_info) +
1297 t4_handle_intr_status(adapter, MPS_CLS_INT_CAUSE,
1298 mps_cls_intr_info);
1299
1300 t4_write_reg(adapter, MPS_INT_CAUSE, CLSINT | TRCINT |
1301 RXINT | TXINT | STATINT);
1302 t4_read_reg(adapter, MPS_INT_CAUSE); /* flush */
1303 if (fat)
1304 t4_fatal_err(adapter);
1305}
1306
1307#define MEM_INT_MASK (PERR_INT_CAUSE | ECC_CE_INT_CAUSE | ECC_UE_INT_CAUSE)
1308
1309/*
1310 * EDC/MC interrupt handler.
1311 */
1312static void mem_intr_handler(struct adapter *adapter, int idx)
1313{
1314 static const char name[3][5] = { "EDC0", "EDC1", "MC" };
1315
1316 unsigned int addr, cnt_addr, v;
1317
1318 if (idx <= MEM_EDC1) {
1319 addr = EDC_REG(EDC_INT_CAUSE, idx);
1320 cnt_addr = EDC_REG(EDC_ECC_STATUS, idx);
1321 } else {
1322 addr = MC_INT_CAUSE;
1323 cnt_addr = MC_ECC_STATUS;
1324 }
1325
1326 v = t4_read_reg(adapter, addr) & MEM_INT_MASK;
1327 if (v & PERR_INT_CAUSE)
1328 dev_alert(adapter->pdev_dev, "%s FIFO parity error\n",
1329 name[idx]);
1330 if (v & ECC_CE_INT_CAUSE) {
1331 u32 cnt = ECC_CECNT_GET(t4_read_reg(adapter, cnt_addr));
1332
1333 t4_write_reg(adapter, cnt_addr, ECC_CECNT_MASK);
1334 if (printk_ratelimit())
1335 dev_warn(adapter->pdev_dev,
1336 "%u %s correctable ECC data error%s\n",
1337 cnt, name[idx], cnt > 1 ? "s" : "");
1338 }
1339 if (v & ECC_UE_INT_CAUSE)
1340 dev_alert(adapter->pdev_dev,
1341 "%s uncorrectable ECC data error\n", name[idx]);
1342
1343 t4_write_reg(adapter, addr, v);
1344 if (v & (PERR_INT_CAUSE | ECC_UE_INT_CAUSE))
1345 t4_fatal_err(adapter);
1346}
1347
1348/*
1349 * MA interrupt handler.
1350 */
1351static void ma_intr_handler(struct adapter *adap)
1352{
1353 u32 v, status = t4_read_reg(adap, MA_INT_CAUSE);
1354
1355 if (status & MEM_PERR_INT_CAUSE)
1356 dev_alert(adap->pdev_dev,
1357 "MA parity error, parity status %#x\n",
1358 t4_read_reg(adap, MA_PARITY_ERROR_STATUS));
1359 if (status & MEM_WRAP_INT_CAUSE) {
1360 v = t4_read_reg(adap, MA_INT_WRAP_STATUS);
1361 dev_alert(adap->pdev_dev, "MA address wrap-around error by "
1362 "client %u to address %#x\n",
1363 MEM_WRAP_CLIENT_NUM_GET(v),
1364 MEM_WRAP_ADDRESS_GET(v) << 4);
1365 }
1366 t4_write_reg(adap, MA_INT_CAUSE, status);
1367 t4_fatal_err(adap);
1368}
1369
1370/*
1371 * SMB interrupt handler.
1372 */
1373static void smb_intr_handler(struct adapter *adap)
1374{
1375 static struct intr_info smb_intr_info[] = {
1376 { MSTTXFIFOPARINT, "SMB master Tx FIFO parity error", -1, 1 },
1377 { MSTRXFIFOPARINT, "SMB master Rx FIFO parity error", -1, 1 },
1378 { SLVFIFOPARINT, "SMB slave FIFO parity error", -1, 1 },
1379 { 0 }
1380 };
1381
1382 if (t4_handle_intr_status(adap, SMB_INT_CAUSE, smb_intr_info))
1383 t4_fatal_err(adap);
1384}
1385
1386/*
1387 * NC-SI interrupt handler.
1388 */
1389static void ncsi_intr_handler(struct adapter *adap)
1390{
1391 static struct intr_info ncsi_intr_info[] = {
1392 { CIM_DM_PRTY_ERR, "NC-SI CIM parity error", -1, 1 },
1393 { MPS_DM_PRTY_ERR, "NC-SI MPS parity error", -1, 1 },
1394 { TXFIFO_PRTY_ERR, "NC-SI Tx FIFO parity error", -1, 1 },
1395 { RXFIFO_PRTY_ERR, "NC-SI Rx FIFO parity error", -1, 1 },
1396 { 0 }
1397 };
1398
1399 if (t4_handle_intr_status(adap, NCSI_INT_CAUSE, ncsi_intr_info))
1400 t4_fatal_err(adap);
1401}
1402
1403/*
1404 * XGMAC interrupt handler.
1405 */
1406static void xgmac_intr_handler(struct adapter *adap, int port)
1407{
1408 u32 v = t4_read_reg(adap, PORT_REG(port, XGMAC_PORT_INT_CAUSE));
1409
1410 v &= TXFIFO_PRTY_ERR | RXFIFO_PRTY_ERR;
1411 if (!v)
1412 return;
1413
1414 if (v & TXFIFO_PRTY_ERR)
1415 dev_alert(adap->pdev_dev, "XGMAC %d Tx FIFO parity error\n",
1416 port);
1417 if (v & RXFIFO_PRTY_ERR)
1418 dev_alert(adap->pdev_dev, "XGMAC %d Rx FIFO parity error\n",
1419 port);
1420 t4_write_reg(adap, PORT_REG(port, XGMAC_PORT_INT_CAUSE), v);
1421 t4_fatal_err(adap);
1422}
1423
1424/*
1425 * PL interrupt handler.
1426 */
1427static void pl_intr_handler(struct adapter *adap)
1428{
1429 static struct intr_info pl_intr_info[] = {
1430 { FATALPERR, "T4 fatal parity error", -1, 1 },
1431 { PERRVFID, "PL VFID_MAP parity error", -1, 1 },
1432 { 0 }
1433 };
1434
1435 if (t4_handle_intr_status(adap, PL_PL_INT_CAUSE, pl_intr_info))
1436 t4_fatal_err(adap);
1437}
1438
1439#define PF_INTR_MASK (PFSW | PFCIM)
1440#define GLBL_INTR_MASK (CIM | MPS | PL | PCIE | MC | EDC0 | \
1441 EDC1 | LE | TP | MA | PM_TX | PM_RX | ULP_RX | \
1442 CPL_SWITCH | SGE | ULP_TX)
1443
1444/**
1445 * t4_slow_intr_handler - control path interrupt handler
1446 * @adapter: the adapter
1447 *
1448 * T4 interrupt handler for non-data global interrupt events, e.g., errors.
1449 * The designation 'slow' is because it involves register reads, while
1450 * data interrupts typically don't involve any MMIOs.
1451 */
1452int t4_slow_intr_handler(struct adapter *adapter)
1453{
1454 u32 cause = t4_read_reg(adapter, PL_INT_CAUSE);
1455
1456 if (!(cause & GLBL_INTR_MASK))
1457 return 0;
1458 if (cause & CIM)
1459 cim_intr_handler(adapter);
1460 if (cause & MPS)
1461 mps_intr_handler(adapter);
1462 if (cause & NCSI)
1463 ncsi_intr_handler(adapter);
1464 if (cause & PL)
1465 pl_intr_handler(adapter);
1466 if (cause & SMB)
1467 smb_intr_handler(adapter);
1468 if (cause & XGMAC0)
1469 xgmac_intr_handler(adapter, 0);
1470 if (cause & XGMAC1)
1471 xgmac_intr_handler(adapter, 1);
1472 if (cause & XGMAC_KR0)
1473 xgmac_intr_handler(adapter, 2);
1474 if (cause & XGMAC_KR1)
1475 xgmac_intr_handler(adapter, 3);
1476 if (cause & PCIE)
1477 pcie_intr_handler(adapter);
1478 if (cause & MC)
1479 mem_intr_handler(adapter, MEM_MC);
1480 if (cause & EDC0)
1481 mem_intr_handler(adapter, MEM_EDC0);
1482 if (cause & EDC1)
1483 mem_intr_handler(adapter, MEM_EDC1);
1484 if (cause & LE)
1485 le_intr_handler(adapter);
1486 if (cause & TP)
1487 tp_intr_handler(adapter);
1488 if (cause & MA)
1489 ma_intr_handler(adapter);
1490 if (cause & PM_TX)
1491 pmtx_intr_handler(adapter);
1492 if (cause & PM_RX)
1493 pmrx_intr_handler(adapter);
1494 if (cause & ULP_RX)
1495 ulprx_intr_handler(adapter);
1496 if (cause & CPL_SWITCH)
1497 cplsw_intr_handler(adapter);
1498 if (cause & SGE)
1499 sge_intr_handler(adapter);
1500 if (cause & ULP_TX)
1501 ulptx_intr_handler(adapter);
1502
1503 /* Clear the interrupts just processed for which we are the master. */
1504 t4_write_reg(adapter, PL_INT_CAUSE, cause & GLBL_INTR_MASK);
1505 (void) t4_read_reg(adapter, PL_INT_CAUSE); /* flush */
1506 return 1;
1507}
1508
1509/**
1510 * t4_intr_enable - enable interrupts
1511 * @adapter: the adapter whose interrupts should be enabled
1512 *
1513 * Enable PF-specific interrupts for the calling function and the top-level
1514 * interrupt concentrator for global interrupts. Interrupts are already
1515 * enabled at each module, here we just enable the roots of the interrupt
1516 * hierarchies.
1517 *
1518 * Note: this function should be called only when the driver manages
1519 * non PF-specific interrupts from the various HW modules. Only one PCI
1520 * function at a time should be doing this.
1521 */
1522void t4_intr_enable(struct adapter *adapter)
1523{
1524 u32 pf = SOURCEPF_GET(t4_read_reg(adapter, PL_WHOAMI));
1525
1526 t4_write_reg(adapter, SGE_INT_ENABLE3, ERR_CPL_EXCEED_IQE_SIZE |
1527 ERR_INVALID_CIDX_INC | ERR_CPL_OPCODE_0 |
1528 ERR_DROPPED_DB | ERR_DATA_CPL_ON_HIGH_QID1 |
1529 ERR_DATA_CPL_ON_HIGH_QID0 | ERR_BAD_DB_PIDX3 |
1530 ERR_BAD_DB_PIDX2 | ERR_BAD_DB_PIDX1 |
1531 ERR_BAD_DB_PIDX0 | ERR_ING_CTXT_PRIO |
1532 ERR_EGR_CTXT_PRIO | INGRESS_SIZE_ERR |
1533 EGRESS_SIZE_ERR);
1534 t4_write_reg(adapter, MYPF_REG(PL_PF_INT_ENABLE), PF_INTR_MASK);
1535 t4_set_reg_field(adapter, PL_INT_MAP0, 0, 1 << pf);
1536}
1537
1538/**
1539 * t4_intr_disable - disable interrupts
1540 * @adapter: the adapter whose interrupts should be disabled
1541 *
1542 * Disable interrupts. We only disable the top-level interrupt
1543 * concentrators. The caller must be a PCI function managing global
1544 * interrupts.
1545 */
1546void t4_intr_disable(struct adapter *adapter)
1547{
1548 u32 pf = SOURCEPF_GET(t4_read_reg(adapter, PL_WHOAMI));
1549
1550 t4_write_reg(adapter, MYPF_REG(PL_PF_INT_ENABLE), 0);
1551 t4_set_reg_field(adapter, PL_INT_MAP0, 1 << pf, 0);
1552}
1553
1554/**
1555 * t4_intr_clear - clear all interrupts
1556 * @adapter: the adapter whose interrupts should be cleared
1557 *
1558 * Clears all interrupts. The caller must be a PCI function managing
1559 * global interrupts.
1560 */
1561void t4_intr_clear(struct adapter *adapter)
1562{
1563 static const unsigned int cause_reg[] = {
1564 SGE_INT_CAUSE1, SGE_INT_CAUSE2, SGE_INT_CAUSE3,
1565 PCIE_CORE_UTL_SYSTEM_BUS_AGENT_STATUS,
1566 PCIE_CORE_UTL_PCI_EXPRESS_PORT_STATUS,
1567 PCIE_NONFAT_ERR, PCIE_INT_CAUSE,
1568 MC_INT_CAUSE,
1569 MA_INT_WRAP_STATUS, MA_PARITY_ERROR_STATUS, MA_INT_CAUSE,
1570 EDC_INT_CAUSE, EDC_REG(EDC_INT_CAUSE, 1),
1571 CIM_HOST_INT_CAUSE, CIM_HOST_UPACC_INT_CAUSE,
1572 MYPF_REG(CIM_PF_HOST_INT_CAUSE),
1573 TP_INT_CAUSE,
1574 ULP_RX_INT_CAUSE, ULP_TX_INT_CAUSE,
1575 PM_RX_INT_CAUSE, PM_TX_INT_CAUSE,
1576 MPS_RX_PERR_INT_CAUSE,
1577 CPL_INTR_CAUSE,
1578 MYPF_REG(PL_PF_INT_CAUSE),
1579 PL_PL_INT_CAUSE,
1580 LE_DB_INT_CAUSE,
1581 };
1582
1583 unsigned int i;
1584
1585 for (i = 0; i < ARRAY_SIZE(cause_reg); ++i)
1586 t4_write_reg(adapter, cause_reg[i], 0xffffffff);
1587
1588 t4_write_reg(adapter, PL_INT_CAUSE, GLBL_INTR_MASK);
1589 (void) t4_read_reg(adapter, PL_INT_CAUSE); /* flush */
1590}
1591
1592/**
1593 * hash_mac_addr - return the hash value of a MAC address
1594 * @addr: the 48-bit Ethernet MAC address
1595 *
1596 * Hashes a MAC address according to the hash function used by HW inexact
1597 * (hash) address matching.
1598 */
1599static int hash_mac_addr(const u8 *addr)
1600{
1601 u32 a = ((u32)addr[0] << 16) | ((u32)addr[1] << 8) | addr[2];
1602 u32 b = ((u32)addr[3] << 16) | ((u32)addr[4] << 8) | addr[5];
1603 a ^= b;
1604 a ^= (a >> 12);
1605 a ^= (a >> 6);
1606 return a & 0x3f;
1607}
1608
1609/**
1610 * t4_config_rss_range - configure a portion of the RSS mapping table
1611 * @adapter: the adapter
1612 * @mbox: mbox to use for the FW command
1613 * @viid: virtual interface whose RSS subtable is to be written
1614 * @start: start entry in the table to write
1615 * @n: how many table entries to write
1616 * @rspq: values for the response queue lookup table
1617 * @nrspq: number of values in @rspq
1618 *
1619 * Programs the selected part of the VI's RSS mapping table with the
1620 * provided values. If @nrspq < @n the supplied values are used repeatedly
1621 * until the full table range is populated.
1622 *
1623 * The caller must ensure the values in @rspq are in the range allowed for
1624 * @viid.
1625 */
1626int t4_config_rss_range(struct adapter *adapter, int mbox, unsigned int viid,
1627 int start, int n, const u16 *rspq, unsigned int nrspq)
1628{
1629 int ret;
1630 const u16 *rsp = rspq;
1631 const u16 *rsp_end = rspq + nrspq;
1632 struct fw_rss_ind_tbl_cmd cmd;
1633
1634 memset(&cmd, 0, sizeof(cmd));
1635 cmd.op_to_viid = htonl(FW_CMD_OP(FW_RSS_IND_TBL_CMD) |
1636 FW_CMD_REQUEST | FW_CMD_WRITE |
1637 FW_RSS_IND_TBL_CMD_VIID(viid));
1638 cmd.retval_len16 = htonl(FW_LEN16(cmd));
1639
1640 /* each fw_rss_ind_tbl_cmd takes up to 32 entries */
1641 while (n > 0) {
1642 int nq = min(n, 32);
1643 __be32 *qp = &cmd.iq0_to_iq2;
1644
1645 cmd.niqid = htons(nq);
1646 cmd.startidx = htons(start);
1647
1648 start += nq;
1649 n -= nq;
1650
1651 while (nq > 0) {
1652 unsigned int v;
1653
1654 v = FW_RSS_IND_TBL_CMD_IQ0(*rsp);
1655 if (++rsp >= rsp_end)
1656 rsp = rspq;
1657 v |= FW_RSS_IND_TBL_CMD_IQ1(*rsp);
1658 if (++rsp >= rsp_end)
1659 rsp = rspq;
1660 v |= FW_RSS_IND_TBL_CMD_IQ2(*rsp);
1661 if (++rsp >= rsp_end)
1662 rsp = rspq;
1663
1664 *qp++ = htonl(v);
1665 nq -= 3;
1666 }
1667
1668 ret = t4_wr_mbox(adapter, mbox, &cmd, sizeof(cmd), NULL);
1669 if (ret)
1670 return ret;
1671 }
1672 return 0;
1673}
1674
1675/**
1676 * t4_config_glbl_rss - configure the global RSS mode
1677 * @adapter: the adapter
1678 * @mbox: mbox to use for the FW command
1679 * @mode: global RSS mode
1680 * @flags: mode-specific flags
1681 *
1682 * Sets the global RSS mode.
1683 */
1684int t4_config_glbl_rss(struct adapter *adapter, int mbox, unsigned int mode,
1685 unsigned int flags)
1686{
1687 struct fw_rss_glb_config_cmd c;
1688
1689 memset(&c, 0, sizeof(c));
1690 c.op_to_write = htonl(FW_CMD_OP(FW_RSS_GLB_CONFIG_CMD) |
1691 FW_CMD_REQUEST | FW_CMD_WRITE);
1692 c.retval_len16 = htonl(FW_LEN16(c));
1693 if (mode == FW_RSS_GLB_CONFIG_CMD_MODE_MANUAL) {
1694 c.u.manual.mode_pkd = htonl(FW_RSS_GLB_CONFIG_CMD_MODE(mode));
1695 } else if (mode == FW_RSS_GLB_CONFIG_CMD_MODE_BASICVIRTUAL) {
1696 c.u.basicvirtual.mode_pkd =
1697 htonl(FW_RSS_GLB_CONFIG_CMD_MODE(mode));
1698 c.u.basicvirtual.synmapen_to_hashtoeplitz = htonl(flags);
1699 } else
1700 return -EINVAL;
1701 return t4_wr_mbox(adapter, mbox, &c, sizeof(c), NULL);
1702}
1703
1704/* Read an RSS table row */
1705static int rd_rss_row(struct adapter *adap, int row, u32 *val)
1706{
1707 t4_write_reg(adap, TP_RSS_LKP_TABLE, 0xfff00000 | row);
1708 return t4_wait_op_done_val(adap, TP_RSS_LKP_TABLE, LKPTBLROWVLD, 1,
1709 5, 0, val);
1710}
1711
1712/**
1713 * t4_read_rss - read the contents of the RSS mapping table
1714 * @adapter: the adapter
1715 * @map: holds the contents of the RSS mapping table
1716 *
1717 * Reads the contents of the RSS hash->queue mapping table.
1718 */
1719int t4_read_rss(struct adapter *adapter, u16 *map)
1720{
1721 u32 val;
1722 int i, ret;
1723
1724 for (i = 0; i < RSS_NENTRIES / 2; ++i) {
1725 ret = rd_rss_row(adapter, i, &val);
1726 if (ret)
1727 return ret;
1728 *map++ = LKPTBLQUEUE0_GET(val);
1729 *map++ = LKPTBLQUEUE1_GET(val);
1730 }
1731 return 0;
1732}
1733
1734/**
1735 * t4_tp_get_tcp_stats - read TP's TCP MIB counters
1736 * @adap: the adapter
1737 * @v4: holds the TCP/IP counter values
1738 * @v6: holds the TCP/IPv6 counter values
1739 *
1740 * Returns the values of TP's TCP/IP and TCP/IPv6 MIB counters.
1741 * Either @v4 or @v6 may be %NULL to skip the corresponding stats.
1742 */
1743void t4_tp_get_tcp_stats(struct adapter *adap, struct tp_tcp_stats *v4,
1744 struct tp_tcp_stats *v6)
1745{
1746 u32 val[TP_MIB_TCP_RXT_SEG_LO - TP_MIB_TCP_OUT_RST + 1];
1747
1748#define STAT_IDX(x) ((TP_MIB_TCP_##x) - TP_MIB_TCP_OUT_RST)
1749#define STAT(x) val[STAT_IDX(x)]
1750#define STAT64(x) (((u64)STAT(x##_HI) << 32) | STAT(x##_LO))
1751
1752 if (v4) {
1753 t4_read_indirect(adap, TP_MIB_INDEX, TP_MIB_DATA, val,
1754 ARRAY_SIZE(val), TP_MIB_TCP_OUT_RST);
1755 v4->tcpOutRsts = STAT(OUT_RST);
1756 v4->tcpInSegs = STAT64(IN_SEG);
1757 v4->tcpOutSegs = STAT64(OUT_SEG);
1758 v4->tcpRetransSegs = STAT64(RXT_SEG);
1759 }
1760 if (v6) {
1761 t4_read_indirect(adap, TP_MIB_INDEX, TP_MIB_DATA, val,
1762 ARRAY_SIZE(val), TP_MIB_TCP_V6OUT_RST);
1763 v6->tcpOutRsts = STAT(OUT_RST);
1764 v6->tcpInSegs = STAT64(IN_SEG);
1765 v6->tcpOutSegs = STAT64(OUT_SEG);
1766 v6->tcpRetransSegs = STAT64(RXT_SEG);
1767 }
1768#undef STAT64
1769#undef STAT
1770#undef STAT_IDX
1771}
1772
1773/**
1774 * t4_tp_get_err_stats - read TP's error MIB counters
1775 * @adap: the adapter
1776 * @st: holds the counter values
1777 *
1778 * Returns the values of TP's error counters.
1779 */
1780void t4_tp_get_err_stats(struct adapter *adap, struct tp_err_stats *st)
1781{
1782 t4_read_indirect(adap, TP_MIB_INDEX, TP_MIB_DATA, st->macInErrs,
1783 12, TP_MIB_MAC_IN_ERR_0);
1784 t4_read_indirect(adap, TP_MIB_INDEX, TP_MIB_DATA, st->tnlCongDrops,
1785 8, TP_MIB_TNL_CNG_DROP_0);
1786 t4_read_indirect(adap, TP_MIB_INDEX, TP_MIB_DATA, st->tnlTxDrops,
1787 4, TP_MIB_TNL_DROP_0);
1788 t4_read_indirect(adap, TP_MIB_INDEX, TP_MIB_DATA, st->ofldVlanDrops,
1789 4, TP_MIB_OFD_VLN_DROP_0);
1790 t4_read_indirect(adap, TP_MIB_INDEX, TP_MIB_DATA, st->tcp6InErrs,
1791 4, TP_MIB_TCP_V6IN_ERR_0);
1792 t4_read_indirect(adap, TP_MIB_INDEX, TP_MIB_DATA, &st->ofldNoNeigh,
1793 2, TP_MIB_OFD_ARP_DROP);
1794}
1795
1796/**
1797 * t4_read_mtu_tbl - returns the values in the HW path MTU table
1798 * @adap: the adapter
1799 * @mtus: where to store the MTU values
1800 * @mtu_log: where to store the MTU base-2 log (may be %NULL)
1801 *
1802 * Reads the HW path MTU table.
1803 */
1804void t4_read_mtu_tbl(struct adapter *adap, u16 *mtus, u8 *mtu_log)
1805{
1806 u32 v;
1807 int i;
1808
1809 for (i = 0; i < NMTUS; ++i) {
1810 t4_write_reg(adap, TP_MTU_TABLE,
1811 MTUINDEX(0xff) | MTUVALUE(i));
1812 v = t4_read_reg(adap, TP_MTU_TABLE);
1813 mtus[i] = MTUVALUE_GET(v);
1814 if (mtu_log)
1815 mtu_log[i] = MTUWIDTH_GET(v);
1816 }
1817}
1818
1819/**
1820 * init_cong_ctrl - initialize congestion control parameters
1821 * @a: the alpha values for congestion control
1822 * @b: the beta values for congestion control
1823 *
1824 * Initialize the congestion control parameters.
1825 */
1826static void __devinit init_cong_ctrl(unsigned short *a, unsigned short *b)
1827{
1828 a[0] = a[1] = a[2] = a[3] = a[4] = a[5] = a[6] = a[7] = a[8] = 1;
1829 a[9] = 2;
1830 a[10] = 3;
1831 a[11] = 4;
1832 a[12] = 5;
1833 a[13] = 6;
1834 a[14] = 7;
1835 a[15] = 8;
1836 a[16] = 9;
1837 a[17] = 10;
1838 a[18] = 14;
1839 a[19] = 17;
1840 a[20] = 21;
1841 a[21] = 25;
1842 a[22] = 30;
1843 a[23] = 35;
1844 a[24] = 45;
1845 a[25] = 60;
1846 a[26] = 80;
1847 a[27] = 100;
1848 a[28] = 200;
1849 a[29] = 300;
1850 a[30] = 400;
1851 a[31] = 500;
1852
1853 b[0] = b[1] = b[2] = b[3] = b[4] = b[5] = b[6] = b[7] = b[8] = 0;
1854 b[9] = b[10] = 1;
1855 b[11] = b[12] = 2;
1856 b[13] = b[14] = b[15] = b[16] = 3;
1857 b[17] = b[18] = b[19] = b[20] = b[21] = 4;
1858 b[22] = b[23] = b[24] = b[25] = b[26] = b[27] = 5;
1859 b[28] = b[29] = 6;
1860 b[30] = b[31] = 7;
1861}
1862
1863/* The minimum additive increment value for the congestion control table */
1864#define CC_MIN_INCR 2U
1865
1866/**
1867 * t4_load_mtus - write the MTU and congestion control HW tables
1868 * @adap: the adapter
1869 * @mtus: the values for the MTU table
1870 * @alpha: the values for the congestion control alpha parameter
1871 * @beta: the values for the congestion control beta parameter
1872 *
1873 * Write the HW MTU table with the supplied MTUs and the high-speed
1874 * congestion control table with the supplied alpha, beta, and MTUs.
1875 * We write the two tables together because the additive increments
1876 * depend on the MTUs.
1877 */
1878void t4_load_mtus(struct adapter *adap, const unsigned short *mtus,
1879 const unsigned short *alpha, const unsigned short *beta)
1880{
1881 static const unsigned int avg_pkts[NCCTRL_WIN] = {
1882 2, 6, 10, 14, 20, 28, 40, 56, 80, 112, 160, 224, 320, 448, 640,
1883 896, 1281, 1792, 2560, 3584, 5120, 7168, 10240, 14336, 20480,
1884 28672, 40960, 57344, 81920, 114688, 163840, 229376
1885 };
1886
1887 unsigned int i, w;
1888
1889 for (i = 0; i < NMTUS; ++i) {
1890 unsigned int mtu = mtus[i];
1891 unsigned int log2 = fls(mtu);
1892
1893 if (!(mtu & ((1 << log2) >> 2))) /* round */
1894 log2--;
1895 t4_write_reg(adap, TP_MTU_TABLE, MTUINDEX(i) |
1896 MTUWIDTH(log2) | MTUVALUE(mtu));
1897
1898 for (w = 0; w < NCCTRL_WIN; ++w) {
1899 unsigned int inc;
1900
1901 inc = max(((mtu - 40) * alpha[w]) / avg_pkts[w],
1902 CC_MIN_INCR);
1903
1904 t4_write_reg(adap, TP_CCTRL_TABLE, (i << 21) |
1905 (w << 16) | (beta[w] << 13) | inc);
1906 }
1907 }
1908}
1909
1910/**
1911 * t4_set_trace_filter - configure one of the tracing filters
1912 * @adap: the adapter
1913 * @tp: the desired trace filter parameters
1914 * @idx: which filter to configure
1915 * @enable: whether to enable or disable the filter
1916 *
1917 * Configures one of the tracing filters available in HW. If @enable is
1918 * %0 @tp is not examined and may be %NULL.
1919 */
1920int t4_set_trace_filter(struct adapter *adap, const struct trace_params *tp,
1921 int idx, int enable)
1922{
1923 int i, ofst = idx * 4;
1924 u32 data_reg, mask_reg, cfg;
1925 u32 multitrc = TRCMULTIFILTER;
1926
1927 if (!enable) {
1928 t4_write_reg(adap, MPS_TRC_FILTER_MATCH_CTL_A + ofst, 0);
1929 goto out;
1930 }
1931
1932 if (tp->port > 11 || tp->invert > 1 || tp->skip_len > 0x1f ||
1933 tp->skip_ofst > 0x1f || tp->min_len > 0x1ff ||
1934 tp->snap_len > 9600 || (idx && tp->snap_len > 256))
1935 return -EINVAL;
1936
1937 if (tp->snap_len > 256) { /* must be tracer 0 */
1938 if ((t4_read_reg(adap, MPS_TRC_FILTER_MATCH_CTL_A + 4) |
1939 t4_read_reg(adap, MPS_TRC_FILTER_MATCH_CTL_A + 8) |
1940 t4_read_reg(adap, MPS_TRC_FILTER_MATCH_CTL_A + 12)) & TFEN)
1941 return -EINVAL; /* other tracers are enabled */
1942 multitrc = 0;
1943 } else if (idx) {
1944 i = t4_read_reg(adap, MPS_TRC_FILTER_MATCH_CTL_B);
1945 if (TFCAPTUREMAX_GET(i) > 256 &&
1946 (t4_read_reg(adap, MPS_TRC_FILTER_MATCH_CTL_A) & TFEN))
1947 return -EINVAL;
1948 }
1949
1950 /* stop the tracer we'll be changing */
1951 t4_write_reg(adap, MPS_TRC_FILTER_MATCH_CTL_A + ofst, 0);
1952
1953 /* disable tracing globally if running in the wrong single/multi mode */
1954 cfg = t4_read_reg(adap, MPS_TRC_CFG);
1955 if ((cfg & TRCEN) && multitrc != (cfg & TRCMULTIFILTER)) {
1956 t4_write_reg(adap, MPS_TRC_CFG, cfg ^ TRCEN);
1957 t4_read_reg(adap, MPS_TRC_CFG); /* flush */
1958 msleep(1);
1959 if (!(t4_read_reg(adap, MPS_TRC_CFG) & TRCFIFOEMPTY))
1960 return -ETIMEDOUT;
1961 }
1962 /*
1963 * At this point either the tracing is enabled and in the right mode or
1964 * disabled.
1965 */
1966
1967 idx *= (MPS_TRC_FILTER1_MATCH - MPS_TRC_FILTER0_MATCH);
1968 data_reg = MPS_TRC_FILTER0_MATCH + idx;
1969 mask_reg = MPS_TRC_FILTER0_DONT_CARE + idx;
1970
1971 for (i = 0; i < TRACE_LEN / 4; i++, data_reg += 4, mask_reg += 4) {
1972 t4_write_reg(adap, data_reg, tp->data[i]);
1973 t4_write_reg(adap, mask_reg, ~tp->mask[i]);
1974 }
1975 t4_write_reg(adap, MPS_TRC_FILTER_MATCH_CTL_B + ofst,
1976 TFCAPTUREMAX(tp->snap_len) |
1977 TFMINPKTSIZE(tp->min_len));
1978 t4_write_reg(adap, MPS_TRC_FILTER_MATCH_CTL_A + ofst,
1979 TFOFFSET(tp->skip_ofst) | TFLENGTH(tp->skip_len) |
1980 TFPORT(tp->port) | TFEN |
1981 (tp->invert ? TFINVERTMATCH : 0));
1982
1983 cfg &= ~TRCMULTIFILTER;
1984 t4_write_reg(adap, MPS_TRC_CFG, cfg | TRCEN | multitrc);
1985out: t4_read_reg(adap, MPS_TRC_CFG); /* flush */
1986 return 0;
1987}
1988
1989/**
1990 * t4_get_trace_filter - query one of the tracing filters
1991 * @adap: the adapter
1992 * @tp: the current trace filter parameters
1993 * @idx: which trace filter to query
1994 * @enabled: non-zero if the filter is enabled
1995 *
1996 * Returns the current settings of one of the HW tracing filters.
1997 */
1998void t4_get_trace_filter(struct adapter *adap, struct trace_params *tp, int idx,
1999 int *enabled)
2000{
2001 u32 ctla, ctlb;
2002 int i, ofst = idx * 4;
2003 u32 data_reg, mask_reg;
2004
2005 ctla = t4_read_reg(adap, MPS_TRC_FILTER_MATCH_CTL_A + ofst);
2006 ctlb = t4_read_reg(adap, MPS_TRC_FILTER_MATCH_CTL_B + ofst);
2007
2008 *enabled = !!(ctla & TFEN);
2009 tp->snap_len = TFCAPTUREMAX_GET(ctlb);
2010 tp->min_len = TFMINPKTSIZE_GET(ctlb);
2011 tp->skip_ofst = TFOFFSET_GET(ctla);
2012 tp->skip_len = TFLENGTH_GET(ctla);
2013 tp->invert = !!(ctla & TFINVERTMATCH);
2014 tp->port = TFPORT_GET(ctla);
2015
2016 ofst = (MPS_TRC_FILTER1_MATCH - MPS_TRC_FILTER0_MATCH) * idx;
2017 data_reg = MPS_TRC_FILTER0_MATCH + ofst;
2018 mask_reg = MPS_TRC_FILTER0_DONT_CARE + ofst;
2019
2020 for (i = 0; i < TRACE_LEN / 4; i++, data_reg += 4, mask_reg += 4) {
2021 tp->mask[i] = ~t4_read_reg(adap, mask_reg);
2022 tp->data[i] = t4_read_reg(adap, data_reg) & tp->mask[i];
2023 }
2024}
2025
2026/**
2027 * get_mps_bg_map - return the buffer groups associated with a port
2028 * @adap: the adapter
2029 * @idx: the port index
2030 *
2031 * Returns a bitmap indicating which MPS buffer groups are associated
2032 * with the given port. Bit i is set if buffer group i is used by the
2033 * port.
2034 */
2035static unsigned int get_mps_bg_map(struct adapter *adap, int idx)
2036{
2037 u32 n = NUMPORTS_GET(t4_read_reg(adap, MPS_CMN_CTL));
2038
2039 if (n == 0)
2040 return idx == 0 ? 0xf : 0;
2041 if (n == 1)
2042 return idx < 2 ? (3 << (2 * idx)) : 0;
2043 return 1 << idx;
2044}
2045
2046/**
2047 * t4_get_port_stats - collect port statistics
2048 * @adap: the adapter
2049 * @idx: the port index
2050 * @p: the stats structure to fill
2051 *
2052 * Collect statistics related to the given port from HW.
2053 */
2054void t4_get_port_stats(struct adapter *adap, int idx, struct port_stats *p)
2055{
2056 u32 bgmap = get_mps_bg_map(adap, idx);
2057
2058#define GET_STAT(name) \
2059 t4_read_reg64(adap, PORT_REG(idx, MPS_PORT_STAT_##name##_L))
2060#define GET_STAT_COM(name) t4_read_reg64(adap, MPS_STAT_##name##_L)
2061
2062 p->tx_octets = GET_STAT(TX_PORT_BYTES);
2063 p->tx_frames = GET_STAT(TX_PORT_FRAMES);
2064 p->tx_bcast_frames = GET_STAT(TX_PORT_BCAST);
2065 p->tx_mcast_frames = GET_STAT(TX_PORT_MCAST);
2066 p->tx_ucast_frames = GET_STAT(TX_PORT_UCAST);
2067 p->tx_error_frames = GET_STAT(TX_PORT_ERROR);
2068 p->tx_frames_64 = GET_STAT(TX_PORT_64B);
2069 p->tx_frames_65_127 = GET_STAT(TX_PORT_65B_127B);
2070 p->tx_frames_128_255 = GET_STAT(TX_PORT_128B_255B);
2071 p->tx_frames_256_511 = GET_STAT(TX_PORT_256B_511B);
2072 p->tx_frames_512_1023 = GET_STAT(TX_PORT_512B_1023B);
2073 p->tx_frames_1024_1518 = GET_STAT(TX_PORT_1024B_1518B);
2074 p->tx_frames_1519_max = GET_STAT(TX_PORT_1519B_MAX);
2075 p->tx_drop = GET_STAT(TX_PORT_DROP);
2076 p->tx_pause = GET_STAT(TX_PORT_PAUSE);
2077 p->tx_ppp0 = GET_STAT(TX_PORT_PPP0);
2078 p->tx_ppp1 = GET_STAT(TX_PORT_PPP1);
2079 p->tx_ppp2 = GET_STAT(TX_PORT_PPP2);
2080 p->tx_ppp3 = GET_STAT(TX_PORT_PPP3);
2081 p->tx_ppp4 = GET_STAT(TX_PORT_PPP4);
2082 p->tx_ppp5 = GET_STAT(TX_PORT_PPP5);
2083 p->tx_ppp6 = GET_STAT(TX_PORT_PPP6);
2084 p->tx_ppp7 = GET_STAT(TX_PORT_PPP7);
2085
2086 p->rx_octets = GET_STAT(RX_PORT_BYTES);
2087 p->rx_frames = GET_STAT(RX_PORT_FRAMES);
2088 p->rx_bcast_frames = GET_STAT(RX_PORT_BCAST);
2089 p->rx_mcast_frames = GET_STAT(RX_PORT_MCAST);
2090 p->rx_ucast_frames = GET_STAT(RX_PORT_UCAST);
2091 p->rx_too_long = GET_STAT(RX_PORT_MTU_ERROR);
2092 p->rx_jabber = GET_STAT(RX_PORT_MTU_CRC_ERROR);
2093 p->rx_fcs_err = GET_STAT(RX_PORT_CRC_ERROR);
2094 p->rx_len_err = GET_STAT(RX_PORT_LEN_ERROR);
2095 p->rx_symbol_err = GET_STAT(RX_PORT_SYM_ERROR);
2096 p->rx_runt = GET_STAT(RX_PORT_LESS_64B);
2097 p->rx_frames_64 = GET_STAT(RX_PORT_64B);
2098 p->rx_frames_65_127 = GET_STAT(RX_PORT_65B_127B);
2099 p->rx_frames_128_255 = GET_STAT(RX_PORT_128B_255B);
2100 p->rx_frames_256_511 = GET_STAT(RX_PORT_256B_511B);
2101 p->rx_frames_512_1023 = GET_STAT(RX_PORT_512B_1023B);
2102 p->rx_frames_1024_1518 = GET_STAT(RX_PORT_1024B_1518B);
2103 p->rx_frames_1519_max = GET_STAT(RX_PORT_1519B_MAX);
2104 p->rx_pause = GET_STAT(RX_PORT_PAUSE);
2105 p->rx_ppp0 = GET_STAT(RX_PORT_PPP0);
2106 p->rx_ppp1 = GET_STAT(RX_PORT_PPP1);
2107 p->rx_ppp2 = GET_STAT(RX_PORT_PPP2);
2108 p->rx_ppp3 = GET_STAT(RX_PORT_PPP3);
2109 p->rx_ppp4 = GET_STAT(RX_PORT_PPP4);
2110 p->rx_ppp5 = GET_STAT(RX_PORT_PPP5);
2111 p->rx_ppp6 = GET_STAT(RX_PORT_PPP6);
2112 p->rx_ppp7 = GET_STAT(RX_PORT_PPP7);
2113
2114 p->rx_ovflow0 = (bgmap & 1) ? GET_STAT_COM(RX_BG_0_MAC_DROP_FRAME) : 0;
2115 p->rx_ovflow1 = (bgmap & 2) ? GET_STAT_COM(RX_BG_1_MAC_DROP_FRAME) : 0;
2116 p->rx_ovflow2 = (bgmap & 4) ? GET_STAT_COM(RX_BG_2_MAC_DROP_FRAME) : 0;
2117 p->rx_ovflow3 = (bgmap & 8) ? GET_STAT_COM(RX_BG_3_MAC_DROP_FRAME) : 0;
2118 p->rx_trunc0 = (bgmap & 1) ? GET_STAT_COM(RX_BG_0_MAC_TRUNC_FRAME) : 0;
2119 p->rx_trunc1 = (bgmap & 2) ? GET_STAT_COM(RX_BG_1_MAC_TRUNC_FRAME) : 0;
2120 p->rx_trunc2 = (bgmap & 4) ? GET_STAT_COM(RX_BG_2_MAC_TRUNC_FRAME) : 0;
2121 p->rx_trunc3 = (bgmap & 8) ? GET_STAT_COM(RX_BG_3_MAC_TRUNC_FRAME) : 0;
2122
2123#undef GET_STAT
2124#undef GET_STAT_COM
2125}
2126
2127/**
2128 * t4_get_lb_stats - collect loopback port statistics
2129 * @adap: the adapter
2130 * @idx: the loopback port index
2131 * @p: the stats structure to fill
2132 *
2133 * Return HW statistics for the given loopback port.
2134 */
2135void t4_get_lb_stats(struct adapter *adap, int idx, struct lb_port_stats *p)
2136{
2137 u32 bgmap = get_mps_bg_map(adap, idx);
2138
2139#define GET_STAT(name) \
2140 t4_read_reg64(adap, PORT_REG(idx, MPS_PORT_STAT_LB_PORT_##name##_L))
2141#define GET_STAT_COM(name) t4_read_reg64(adap, MPS_STAT_##name##_L)
2142
2143 p->octets = GET_STAT(BYTES);
2144 p->frames = GET_STAT(FRAMES);
2145 p->bcast_frames = GET_STAT(BCAST);
2146 p->mcast_frames = GET_STAT(MCAST);
2147 p->ucast_frames = GET_STAT(UCAST);
2148 p->error_frames = GET_STAT(ERROR);
2149
2150 p->frames_64 = GET_STAT(64B);
2151 p->frames_65_127 = GET_STAT(65B_127B);
2152 p->frames_128_255 = GET_STAT(128B_255B);
2153 p->frames_256_511 = GET_STAT(256B_511B);
2154 p->frames_512_1023 = GET_STAT(512B_1023B);
2155 p->frames_1024_1518 = GET_STAT(1024B_1518B);
2156 p->frames_1519_max = GET_STAT(1519B_MAX);
2157 p->drop = t4_read_reg(adap, PORT_REG(idx,
2158 MPS_PORT_STAT_LB_PORT_DROP_FRAMES));
2159
2160 p->ovflow0 = (bgmap & 1) ? GET_STAT_COM(RX_BG_0_LB_DROP_FRAME) : 0;
2161 p->ovflow1 = (bgmap & 2) ? GET_STAT_COM(RX_BG_1_LB_DROP_FRAME) : 0;
2162 p->ovflow2 = (bgmap & 4) ? GET_STAT_COM(RX_BG_2_LB_DROP_FRAME) : 0;
2163 p->ovflow3 = (bgmap & 8) ? GET_STAT_COM(RX_BG_3_LB_DROP_FRAME) : 0;
2164 p->trunc0 = (bgmap & 1) ? GET_STAT_COM(RX_BG_0_LB_TRUNC_FRAME) : 0;
2165 p->trunc1 = (bgmap & 2) ? GET_STAT_COM(RX_BG_1_LB_TRUNC_FRAME) : 0;
2166 p->trunc2 = (bgmap & 4) ? GET_STAT_COM(RX_BG_2_LB_TRUNC_FRAME) : 0;
2167 p->trunc3 = (bgmap & 8) ? GET_STAT_COM(RX_BG_3_LB_TRUNC_FRAME) : 0;
2168
2169#undef GET_STAT
2170#undef GET_STAT_COM
2171}
2172
2173/**
2174 * t4_wol_magic_enable - enable/disable magic packet WoL
2175 * @adap: the adapter
2176 * @port: the physical port index
2177 * @addr: MAC address expected in magic packets, %NULL to disable
2178 *
2179 * Enables/disables magic packet wake-on-LAN for the selected port.
2180 */
2181void t4_wol_magic_enable(struct adapter *adap, unsigned int port,
2182 const u8 *addr)
2183{
2184 if (addr) {
2185 t4_write_reg(adap, PORT_REG(port, XGMAC_PORT_MAGIC_MACID_LO),
2186 (addr[2] << 24) | (addr[3] << 16) |
2187 (addr[4] << 8) | addr[5]);
2188 t4_write_reg(adap, PORT_REG(port, XGMAC_PORT_MAGIC_MACID_HI),
2189 (addr[0] << 8) | addr[1]);
2190 }
2191 t4_set_reg_field(adap, PORT_REG(port, XGMAC_PORT_CFG2), MAGICEN,
2192 addr ? MAGICEN : 0);
2193}
2194
2195/**
2196 * t4_wol_pat_enable - enable/disable pattern-based WoL
2197 * @adap: the adapter
2198 * @port: the physical port index
2199 * @map: bitmap of which HW pattern filters to set
2200 * @mask0: byte mask for bytes 0-63 of a packet
2201 * @mask1: byte mask for bytes 64-127 of a packet
2202 * @crc: Ethernet CRC for selected bytes
2203 * @enable: enable/disable switch
2204 *
2205 * Sets the pattern filters indicated in @map to mask out the bytes
2206 * specified in @mask0/@mask1 in received packets and compare the CRC of
2207 * the resulting packet against @crc. If @enable is %true pattern-based
2208 * WoL is enabled, otherwise disabled.
2209 */
2210int t4_wol_pat_enable(struct adapter *adap, unsigned int port, unsigned int map,
2211 u64 mask0, u64 mask1, unsigned int crc, bool enable)
2212{
2213 int i;
2214
2215 if (!enable) {
2216 t4_set_reg_field(adap, PORT_REG(port, XGMAC_PORT_CFG2),
2217 PATEN, 0);
2218 return 0;
2219 }
2220 if (map > 0xff)
2221 return -EINVAL;
2222
2223#define EPIO_REG(name) PORT_REG(port, XGMAC_PORT_EPIO_##name)
2224
2225 t4_write_reg(adap, EPIO_REG(DATA1), mask0 >> 32);
2226 t4_write_reg(adap, EPIO_REG(DATA2), mask1);
2227 t4_write_reg(adap, EPIO_REG(DATA3), mask1 >> 32);
2228
2229 for (i = 0; i < NWOL_PAT; i++, map >>= 1) {
2230 if (!(map & 1))
2231 continue;
2232
2233 /* write byte masks */
2234 t4_write_reg(adap, EPIO_REG(DATA0), mask0);
2235 t4_write_reg(adap, EPIO_REG(OP), ADDRESS(i) | EPIOWR);
2236 t4_read_reg(adap, EPIO_REG(OP)); /* flush */
2237 if (t4_read_reg(adap, EPIO_REG(OP)) & BUSY)
2238 return -ETIMEDOUT;
2239
2240 /* write CRC */
2241 t4_write_reg(adap, EPIO_REG(DATA0), crc);
2242 t4_write_reg(adap, EPIO_REG(OP), ADDRESS(i + 32) | EPIOWR);
2243 t4_read_reg(adap, EPIO_REG(OP)); /* flush */
2244 if (t4_read_reg(adap, EPIO_REG(OP)) & BUSY)
2245 return -ETIMEDOUT;
2246 }
2247#undef EPIO_REG
2248
2249 t4_set_reg_field(adap, PORT_REG(port, XGMAC_PORT_CFG2), 0, PATEN);
2250 return 0;
2251}
2252
2253#define INIT_CMD(var, cmd, rd_wr) do { \
2254 (var).op_to_write = htonl(FW_CMD_OP(FW_##cmd##_CMD) | \
2255 FW_CMD_REQUEST | FW_CMD_##rd_wr); \
2256 (var).retval_len16 = htonl(FW_LEN16(var)); \
2257} while (0)
2258
2259/**
2260 * t4_mdio_rd - read a PHY register through MDIO
2261 * @adap: the adapter
2262 * @mbox: mailbox to use for the FW command
2263 * @phy_addr: the PHY address
2264 * @mmd: the PHY MMD to access (0 for clause 22 PHYs)
2265 * @reg: the register to read
2266 * @valp: where to store the value
2267 *
2268 * Issues a FW command through the given mailbox to read a PHY register.
2269 */
2270int t4_mdio_rd(struct adapter *adap, unsigned int mbox, unsigned int phy_addr,
2271 unsigned int mmd, unsigned int reg, u16 *valp)
2272{
2273 int ret;
2274 struct fw_ldst_cmd c;
2275
2276 memset(&c, 0, sizeof(c));
2277 c.op_to_addrspace = htonl(FW_CMD_OP(FW_LDST_CMD) | FW_CMD_REQUEST |
2278 FW_CMD_READ | FW_LDST_CMD_ADDRSPACE(FW_LDST_ADDRSPC_MDIO));
2279 c.cycles_to_len16 = htonl(FW_LEN16(c));
2280 c.u.mdio.paddr_mmd = htons(FW_LDST_CMD_PADDR(phy_addr) |
2281 FW_LDST_CMD_MMD(mmd));
2282 c.u.mdio.raddr = htons(reg);
2283
2284 ret = t4_wr_mbox(adap, mbox, &c, sizeof(c), &c);
2285 if (ret == 0)
2286 *valp = ntohs(c.u.mdio.rval);
2287 return ret;
2288}
2289
2290/**
2291 * t4_mdio_wr - write a PHY register through MDIO
2292 * @adap: the adapter
2293 * @mbox: mailbox to use for the FW command
2294 * @phy_addr: the PHY address
2295 * @mmd: the PHY MMD to access (0 for clause 22 PHYs)
2296 * @reg: the register to write
2297 * @valp: value to write
2298 *
2299 * Issues a FW command through the given mailbox to write a PHY register.
2300 */
2301int t4_mdio_wr(struct adapter *adap, unsigned int mbox, unsigned int phy_addr,
2302 unsigned int mmd, unsigned int reg, u16 val)
2303{
2304 struct fw_ldst_cmd c;
2305
2306 memset(&c, 0, sizeof(c));
2307 c.op_to_addrspace = htonl(FW_CMD_OP(FW_LDST_CMD) | FW_CMD_REQUEST |
2308 FW_CMD_WRITE | FW_LDST_CMD_ADDRSPACE(FW_LDST_ADDRSPC_MDIO));
2309 c.cycles_to_len16 = htonl(FW_LEN16(c));
2310 c.u.mdio.paddr_mmd = htons(FW_LDST_CMD_PADDR(phy_addr) |
2311 FW_LDST_CMD_MMD(mmd));
2312 c.u.mdio.raddr = htons(reg);
2313 c.u.mdio.rval = htons(val);
2314
2315 return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
2316}
2317
2318/**
2319 * t4_fw_hello - establish communication with FW
2320 * @adap: the adapter
2321 * @mbox: mailbox to use for the FW command
2322 * @evt_mbox: mailbox to receive async FW events
2323 * @master: specifies the caller's willingness to be the device master
2324 * @state: returns the current device state
2325 *
2326 * Issues a command to establish communication with FW.
2327 */
2328int t4_fw_hello(struct adapter *adap, unsigned int mbox, unsigned int evt_mbox,
2329 enum dev_master master, enum dev_state *state)
2330{
2331 int ret;
2332 struct fw_hello_cmd c;
2333
2334 INIT_CMD(c, HELLO, WRITE);
2335 c.err_to_mbasyncnot = htonl(
2336 FW_HELLO_CMD_MASTERDIS(master == MASTER_CANT) |
2337 FW_HELLO_CMD_MASTERFORCE(master == MASTER_MUST) |
2338 FW_HELLO_CMD_MBMASTER(master == MASTER_MUST ? mbox : 0xff) |
2339 FW_HELLO_CMD_MBASYNCNOT(evt_mbox));
2340
2341 ret = t4_wr_mbox(adap, mbox, &c, sizeof(c), &c);
2342 if (ret == 0 && state) {
2343 u32 v = ntohl(c.err_to_mbasyncnot);
2344 if (v & FW_HELLO_CMD_INIT)
2345 *state = DEV_STATE_INIT;
2346 else if (v & FW_HELLO_CMD_ERR)
2347 *state = DEV_STATE_ERR;
2348 else
2349 *state = DEV_STATE_UNINIT;
2350 }
2351 return ret;
2352}
2353
2354/**
2355 * t4_fw_bye - end communication with FW
2356 * @adap: the adapter
2357 * @mbox: mailbox to use for the FW command
2358 *
2359 * Issues a command to terminate communication with FW.
2360 */
2361int t4_fw_bye(struct adapter *adap, unsigned int mbox)
2362{
2363 struct fw_bye_cmd c;
2364
2365 INIT_CMD(c, BYE, WRITE);
2366 return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
2367}
2368
2369/**
2370 * t4_init_cmd - ask FW to initialize the device
2371 * @adap: the adapter
2372 * @mbox: mailbox to use for the FW command
2373 *
2374 * Issues a command to FW to partially initialize the device. This
2375 * performs initialization that generally doesn't depend on user input.
2376 */
2377int t4_early_init(struct adapter *adap, unsigned int mbox)
2378{
2379 struct fw_initialize_cmd c;
2380
2381 INIT_CMD(c, INITIALIZE, WRITE);
2382 return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
2383}
2384
2385/**
2386 * t4_fw_reset - issue a reset to FW
2387 * @adap: the adapter
2388 * @mbox: mailbox to use for the FW command
2389 * @reset: specifies the type of reset to perform
2390 *
2391 * Issues a reset command of the specified type to FW.
2392 */
2393int t4_fw_reset(struct adapter *adap, unsigned int mbox, int reset)
2394{
2395 struct fw_reset_cmd c;
2396
2397 INIT_CMD(c, RESET, WRITE);
2398 c.val = htonl(reset);
2399 return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
2400}
2401
2402/**
2403 * t4_query_params - query FW or device parameters
2404 * @adap: the adapter
2405 * @mbox: mailbox to use for the FW command
2406 * @pf: the PF
2407 * @vf: the VF
2408 * @nparams: the number of parameters
2409 * @params: the parameter names
2410 * @val: the parameter values
2411 *
2412 * Reads the value of FW or device parameters. Up to 7 parameters can be
2413 * queried at once.
2414 */
2415int t4_query_params(struct adapter *adap, unsigned int mbox, unsigned int pf,
2416 unsigned int vf, unsigned int nparams, const u32 *params,
2417 u32 *val)
2418{
2419 int i, ret;
2420 struct fw_params_cmd c;
2421 __be32 *p = &c.param[0].mnem;
2422
2423 if (nparams > 7)
2424 return -EINVAL;
2425
2426 memset(&c, 0, sizeof(c));
2427 c.op_to_vfn = htonl(FW_CMD_OP(FW_PARAMS_CMD) | FW_CMD_REQUEST |
2428 FW_CMD_READ | FW_PARAMS_CMD_PFN(pf) |
2429 FW_PARAMS_CMD_VFN(vf));
2430 c.retval_len16 = htonl(FW_LEN16(c));
2431 for (i = 0; i < nparams; i++, p += 2)
2432 *p = htonl(*params++);
2433
2434 ret = t4_wr_mbox(adap, mbox, &c, sizeof(c), &c);
2435 if (ret == 0)
2436 for (i = 0, p = &c.param[0].val; i < nparams; i++, p += 2)
2437 *val++ = ntohl(*p);
2438 return ret;
2439}
2440
2441/**
2442 * t4_set_params - sets FW or device parameters
2443 * @adap: the adapter
2444 * @mbox: mailbox to use for the FW command
2445 * @pf: the PF
2446 * @vf: the VF
2447 * @nparams: the number of parameters
2448 * @params: the parameter names
2449 * @val: the parameter values
2450 *
2451 * Sets the value of FW or device parameters. Up to 7 parameters can be
2452 * specified at once.
2453 */
2454int t4_set_params(struct adapter *adap, unsigned int mbox, unsigned int pf,
2455 unsigned int vf, unsigned int nparams, const u32 *params,
2456 const u32 *val)
2457{
2458 struct fw_params_cmd c;
2459 __be32 *p = &c.param[0].mnem;
2460
2461 if (nparams > 7)
2462 return -EINVAL;
2463
2464 memset(&c, 0, sizeof(c));
2465 c.op_to_vfn = htonl(FW_CMD_OP(FW_PARAMS_CMD) | FW_CMD_REQUEST |
2466 FW_CMD_WRITE | FW_PARAMS_CMD_PFN(pf) |
2467 FW_PARAMS_CMD_VFN(vf));
2468 c.retval_len16 = htonl(FW_LEN16(c));
2469 while (nparams--) {
2470 *p++ = htonl(*params++);
2471 *p++ = htonl(*val++);
2472 }
2473
2474 return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
2475}
2476
2477/**
2478 * t4_cfg_pfvf - configure PF/VF resource limits
2479 * @adap: the adapter
2480 * @mbox: mailbox to use for the FW command
2481 * @pf: the PF being configured
2482 * @vf: the VF being configured
2483 * @txq: the max number of egress queues
2484 * @txq_eth_ctrl: the max number of egress Ethernet or control queues
2485 * @rxqi: the max number of interrupt-capable ingress queues
2486 * @rxq: the max number of interruptless ingress queues
2487 * @tc: the PCI traffic class
2488 * @vi: the max number of virtual interfaces
2489 * @cmask: the channel access rights mask for the PF/VF
2490 * @pmask: the port access rights mask for the PF/VF
2491 * @nexact: the maximum number of exact MPS filters
2492 * @rcaps: read capabilities
2493 * @wxcaps: write/execute capabilities
2494 *
2495 * Configures resource limits and capabilities for a physical or virtual
2496 * function.
2497 */
2498int t4_cfg_pfvf(struct adapter *adap, unsigned int mbox, unsigned int pf,
2499 unsigned int vf, unsigned int txq, unsigned int txq_eth_ctrl,
2500 unsigned int rxqi, unsigned int rxq, unsigned int tc,
2501 unsigned int vi, unsigned int cmask, unsigned int pmask,
2502 unsigned int nexact, unsigned int rcaps, unsigned int wxcaps)
2503{
2504 struct fw_pfvf_cmd c;
2505
2506 memset(&c, 0, sizeof(c));
2507 c.op_to_vfn = htonl(FW_CMD_OP(FW_PFVF_CMD) | FW_CMD_REQUEST |
2508 FW_CMD_WRITE | FW_PFVF_CMD_PFN(pf) |
2509 FW_PFVF_CMD_VFN(vf));
2510 c.retval_len16 = htonl(FW_LEN16(c));
2511 c.niqflint_niq = htonl(FW_PFVF_CMD_NIQFLINT(rxqi) |
2512 FW_PFVF_CMD_NIQ(rxq));
2513 c.cmask_to_neq = htonl(FW_PFVF_CMD_CMASK(cmask) |
2514 FW_PFVF_CMD_PMASK(pmask) |
2515 FW_PFVF_CMD_NEQ(txq));
2516 c.tc_to_nexactf = htonl(FW_PFVF_CMD_TC(tc) | FW_PFVF_CMD_NVI(vi) |
2517 FW_PFVF_CMD_NEXACTF(nexact));
2518 c.r_caps_to_nethctrl = htonl(FW_PFVF_CMD_R_CAPS(rcaps) |
2519 FW_PFVF_CMD_WX_CAPS(wxcaps) |
2520 FW_PFVF_CMD_NETHCTRL(txq_eth_ctrl));
2521 return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
2522}
2523
2524/**
2525 * t4_alloc_vi - allocate a virtual interface
2526 * @adap: the adapter
2527 * @mbox: mailbox to use for the FW command
2528 * @port: physical port associated with the VI
2529 * @pf: the PF owning the VI
2530 * @vf: the VF owning the VI
2531 * @nmac: number of MAC addresses needed (1 to 5)
2532 * @mac: the MAC addresses of the VI
2533 * @rss_size: size of RSS table slice associated with this VI
2534 *
2535 * Allocates a virtual interface for the given physical port. If @mac is
2536 * not %NULL it contains the MAC addresses of the VI as assigned by FW.
2537 * @mac should be large enough to hold @nmac Ethernet addresses, they are
2538 * stored consecutively so the space needed is @nmac * 6 bytes.
2539 * Returns a negative error number or the non-negative VI id.
2540 */
2541int t4_alloc_vi(struct adapter *adap, unsigned int mbox, unsigned int port,
2542 unsigned int pf, unsigned int vf, unsigned int nmac, u8 *mac,
2543 unsigned int *rss_size)
2544{
2545 int ret;
2546 struct fw_vi_cmd c;
2547
2548 memset(&c, 0, sizeof(c));
2549 c.op_to_vfn = htonl(FW_CMD_OP(FW_VI_CMD) | FW_CMD_REQUEST |
2550 FW_CMD_WRITE | FW_CMD_EXEC |
2551 FW_VI_CMD_PFN(pf) | FW_VI_CMD_VFN(vf));
2552 c.alloc_to_len16 = htonl(FW_VI_CMD_ALLOC | FW_LEN16(c));
2553 c.portid_pkd = FW_VI_CMD_PORTID(port);
2554 c.nmac = nmac - 1;
2555
2556 ret = t4_wr_mbox(adap, mbox, &c, sizeof(c), &c);
2557 if (ret)
2558 return ret;
2559
2560 if (mac) {
2561 memcpy(mac, c.mac, sizeof(c.mac));
2562 switch (nmac) {
2563 case 5:
2564 memcpy(mac + 24, c.nmac3, sizeof(c.nmac3));
2565 case 4:
2566 memcpy(mac + 18, c.nmac2, sizeof(c.nmac2));
2567 case 3:
2568 memcpy(mac + 12, c.nmac1, sizeof(c.nmac1));
2569 case 2:
2570 memcpy(mac + 6, c.nmac0, sizeof(c.nmac0));
2571 }
2572 }
2573 if (rss_size)
2574 *rss_size = FW_VI_CMD_RSSSIZE_GET(ntohs(c.rsssize_pkd));
2575 return ntohs(c.viid_pkd);
2576}
2577
2578/**
2579 * t4_free_vi - free a virtual interface
2580 * @adap: the adapter
2581 * @mbox: mailbox to use for the FW command
2582 * @pf: the PF owning the VI
2583 * @vf: the VF owning the VI
2584 * @viid: virtual interface identifiler
2585 *
2586 * Free a previously allocated virtual interface.
2587 */
2588int t4_free_vi(struct adapter *adap, unsigned int mbox, unsigned int pf,
2589 unsigned int vf, unsigned int viid)
2590{
2591 struct fw_vi_cmd c;
2592
2593 memset(&c, 0, sizeof(c));
2594 c.op_to_vfn = htonl(FW_CMD_OP(FW_VI_CMD) | FW_CMD_REQUEST |
2595 FW_CMD_EXEC | FW_VI_CMD_PFN(pf) |
2596 FW_VI_CMD_VFN(vf));
2597 c.alloc_to_len16 = htonl(FW_VI_CMD_FREE | FW_LEN16(c));
2598 c.viid_pkd = htons(FW_VI_CMD_VIID(viid));
2599 return t4_wr_mbox(adap, mbox, &c, sizeof(c), &c);
2600}
2601
2602/**
2603 * t4_set_rxmode - set Rx properties of a virtual interface
2604 * @adap: the adapter
2605 * @mbox: mailbox to use for the FW command
2606 * @viid: the VI id
2607 * @mtu: the new MTU or -1
2608 * @promisc: 1 to enable promiscuous mode, 0 to disable it, -1 no change
2609 * @all_multi: 1 to enable all-multi mode, 0 to disable it, -1 no change
2610 * @bcast: 1 to enable broadcast Rx, 0 to disable it, -1 no change
2611 * @sleep_ok: if true we may sleep while awaiting command completion
2612 *
2613 * Sets Rx properties of a virtual interface.
2614 */
2615int t4_set_rxmode(struct adapter *adap, unsigned int mbox, unsigned int viid,
2616 int mtu, int promisc, int all_multi, int bcast, bool sleep_ok)
2617{
2618 struct fw_vi_rxmode_cmd c;
2619
2620 /* convert to FW values */
2621 if (mtu < 0)
2622 mtu = FW_RXMODE_MTU_NO_CHG;
2623 if (promisc < 0)
2624 promisc = FW_VI_RXMODE_CMD_PROMISCEN_MASK;
2625 if (all_multi < 0)
2626 all_multi = FW_VI_RXMODE_CMD_ALLMULTIEN_MASK;
2627 if (bcast < 0)
2628 bcast = FW_VI_RXMODE_CMD_BROADCASTEN_MASK;
2629
2630 memset(&c, 0, sizeof(c));
2631 c.op_to_viid = htonl(FW_CMD_OP(FW_VI_RXMODE_CMD) | FW_CMD_REQUEST |
2632 FW_CMD_WRITE | FW_VI_RXMODE_CMD_VIID(viid));
2633 c.retval_len16 = htonl(FW_LEN16(c));
2634 c.mtu_to_broadcasten = htonl(FW_VI_RXMODE_CMD_MTU(mtu) |
2635 FW_VI_RXMODE_CMD_PROMISCEN(promisc) |
2636 FW_VI_RXMODE_CMD_ALLMULTIEN(all_multi) |
2637 FW_VI_RXMODE_CMD_BROADCASTEN(bcast));
2638 return t4_wr_mbox_meat(adap, mbox, &c, sizeof(c), NULL, sleep_ok);
2639}
2640
2641/**
2642 * t4_alloc_mac_filt - allocates exact-match filters for MAC addresses
2643 * @adap: the adapter
2644 * @mbox: mailbox to use for the FW command
2645 * @viid: the VI id
2646 * @free: if true any existing filters for this VI id are first removed
2647 * @naddr: the number of MAC addresses to allocate filters for (up to 7)
2648 * @addr: the MAC address(es)
2649 * @idx: where to store the index of each allocated filter
2650 * @hash: pointer to hash address filter bitmap
2651 * @sleep_ok: call is allowed to sleep
2652 *
2653 * Allocates an exact-match filter for each of the supplied addresses and
2654 * sets it to the corresponding address. If @idx is not %NULL it should
2655 * have at least @naddr entries, each of which will be set to the index of
2656 * the filter allocated for the corresponding MAC address. If a filter
2657 * could not be allocated for an address its index is set to 0xffff.
2658 * If @hash is not %NULL addresses that fail to allocate an exact filter
2659 * are hashed and update the hash filter bitmap pointed at by @hash.
2660 *
2661 * Returns a negative error number or the number of filters allocated.
2662 */
2663int t4_alloc_mac_filt(struct adapter *adap, unsigned int mbox,
2664 unsigned int viid, bool free, unsigned int naddr,
2665 const u8 **addr, u16 *idx, u64 *hash, bool sleep_ok)
2666{
2667 int i, ret;
2668 struct fw_vi_mac_cmd c;
2669 struct fw_vi_mac_exact *p;
2670
2671 if (naddr > 7)
2672 return -EINVAL;
2673
2674 memset(&c, 0, sizeof(c));
2675 c.op_to_viid = htonl(FW_CMD_OP(FW_VI_MAC_CMD) | FW_CMD_REQUEST |
2676 FW_CMD_WRITE | (free ? FW_CMD_EXEC : 0) |
2677 FW_VI_MAC_CMD_VIID(viid));
2678 c.freemacs_to_len16 = htonl(FW_VI_MAC_CMD_FREEMACS(free) |
2679 FW_CMD_LEN16((naddr + 2) / 2));
2680
2681 for (i = 0, p = c.u.exact; i < naddr; i++, p++) {
2682 p->valid_to_idx = htons(FW_VI_MAC_CMD_VALID |
2683 FW_VI_MAC_CMD_IDX(FW_VI_MAC_ADD_MAC));
2684 memcpy(p->macaddr, addr[i], sizeof(p->macaddr));
2685 }
2686
2687 ret = t4_wr_mbox_meat(adap, mbox, &c, sizeof(c), &c, sleep_ok);
2688 if (ret)
2689 return ret;
2690
2691 for (i = 0, p = c.u.exact; i < naddr; i++, p++) {
2692 u16 index = FW_VI_MAC_CMD_IDX_GET(ntohs(p->valid_to_idx));
2693
2694 if (idx)
2695 idx[i] = index >= NEXACT_MAC ? 0xffff : index;
2696 if (index < NEXACT_MAC)
2697 ret++;
2698 else if (hash)
2699 *hash |= (1 << hash_mac_addr(addr[i]));
2700 }
2701 return ret;
2702}
2703
2704/**
2705 * t4_change_mac - modifies the exact-match filter for a MAC address
2706 * @adap: the adapter
2707 * @mbox: mailbox to use for the FW command
2708 * @viid: the VI id
2709 * @idx: index of existing filter for old value of MAC address, or -1
2710 * @addr: the new MAC address value
2711 * @persist: whether a new MAC allocation should be persistent
2712 * @add_smt: if true also add the address to the HW SMT
2713 *
2714 * Modifies an exact-match filter and sets it to the new MAC address.
2715 * Note that in general it is not possible to modify the value of a given
2716 * filter so the generic way to modify an address filter is to free the one
2717 * being used by the old address value and allocate a new filter for the
2718 * new address value. @idx can be -1 if the address is a new addition.
2719 *
2720 * Returns a negative error number or the index of the filter with the new
2721 * MAC value.
2722 */
2723int t4_change_mac(struct adapter *adap, unsigned int mbox, unsigned int viid,
2724 int idx, const u8 *addr, bool persist, bool add_smt)
2725{
2726 int ret, mode;
2727 struct fw_vi_mac_cmd c;
2728 struct fw_vi_mac_exact *p = c.u.exact;
2729
2730 if (idx < 0) /* new allocation */
2731 idx = persist ? FW_VI_MAC_ADD_PERSIST_MAC : FW_VI_MAC_ADD_MAC;
2732 mode = add_smt ? FW_VI_MAC_SMT_AND_MPSTCAM : FW_VI_MAC_MPS_TCAM_ENTRY;
2733
2734 memset(&c, 0, sizeof(c));
2735 c.op_to_viid = htonl(FW_CMD_OP(FW_VI_MAC_CMD) | FW_CMD_REQUEST |
2736 FW_CMD_WRITE | FW_VI_MAC_CMD_VIID(viid));
2737 c.freemacs_to_len16 = htonl(FW_CMD_LEN16(1));
2738 p->valid_to_idx = htons(FW_VI_MAC_CMD_VALID |
2739 FW_VI_MAC_CMD_SMAC_RESULT(mode) |
2740 FW_VI_MAC_CMD_IDX(idx));
2741 memcpy(p->macaddr, addr, sizeof(p->macaddr));
2742
2743 ret = t4_wr_mbox(adap, mbox, &c, sizeof(c), &c);
2744 if (ret == 0) {
2745 ret = FW_VI_MAC_CMD_IDX_GET(ntohs(p->valid_to_idx));
2746 if (ret >= NEXACT_MAC)
2747 ret = -ENOMEM;
2748 }
2749 return ret;
2750}
2751
2752/**
2753 * t4_set_addr_hash - program the MAC inexact-match hash filter
2754 * @adap: the adapter
2755 * @mbox: mailbox to use for the FW command
2756 * @viid: the VI id
2757 * @ucast: whether the hash filter should also match unicast addresses
2758 * @vec: the value to be written to the hash filter
2759 * @sleep_ok: call is allowed to sleep
2760 *
2761 * Sets the 64-bit inexact-match hash filter for a virtual interface.
2762 */
2763int t4_set_addr_hash(struct adapter *adap, unsigned int mbox, unsigned int viid,
2764 bool ucast, u64 vec, bool sleep_ok)
2765{
2766 struct fw_vi_mac_cmd c;
2767
2768 memset(&c, 0, sizeof(c));
2769 c.op_to_viid = htonl(FW_CMD_OP(FW_VI_MAC_CMD) | FW_CMD_REQUEST |
2770 FW_CMD_WRITE | FW_VI_ENABLE_CMD_VIID(viid));
2771 c.freemacs_to_len16 = htonl(FW_VI_MAC_CMD_HASHVECEN |
2772 FW_VI_MAC_CMD_HASHUNIEN(ucast) |
2773 FW_CMD_LEN16(1));
2774 c.u.hash.hashvec = cpu_to_be64(vec);
2775 return t4_wr_mbox_meat(adap, mbox, &c, sizeof(c), NULL, sleep_ok);
2776}
2777
2778/**
2779 * t4_enable_vi - enable/disable a virtual interface
2780 * @adap: the adapter
2781 * @mbox: mailbox to use for the FW command
2782 * @viid: the VI id
2783 * @rx_en: 1=enable Rx, 0=disable Rx
2784 * @tx_en: 1=enable Tx, 0=disable Tx
2785 *
2786 * Enables/disables a virtual interface.
2787 */
2788int t4_enable_vi(struct adapter *adap, unsigned int mbox, unsigned int viid,
2789 bool rx_en, bool tx_en)
2790{
2791 struct fw_vi_enable_cmd c;
2792
2793 memset(&c, 0, sizeof(c));
2794 c.op_to_viid = htonl(FW_CMD_OP(FW_VI_ENABLE_CMD) | FW_CMD_REQUEST |
2795 FW_CMD_EXEC | FW_VI_ENABLE_CMD_VIID(viid));
2796 c.ien_to_len16 = htonl(FW_VI_ENABLE_CMD_IEN(rx_en) |
2797 FW_VI_ENABLE_CMD_EEN(tx_en) | FW_LEN16(c));
2798 return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
2799}
2800
2801/**
2802 * t4_identify_port - identify a VI's port by blinking its LED
2803 * @adap: the adapter
2804 * @mbox: mailbox to use for the FW command
2805 * @viid: the VI id
2806 * @nblinks: how many times to blink LED at 2.5 Hz
2807 *
2808 * Identifies a VI's port by blinking its LED.
2809 */
2810int t4_identify_port(struct adapter *adap, unsigned int mbox, unsigned int viid,
2811 unsigned int nblinks)
2812{
2813 struct fw_vi_enable_cmd c;
2814
2815 c.op_to_viid = htonl(FW_CMD_OP(FW_VI_ENABLE_CMD) | FW_CMD_REQUEST |
2816 FW_CMD_EXEC | FW_VI_ENABLE_CMD_VIID(viid));
2817 c.ien_to_len16 = htonl(FW_VI_ENABLE_CMD_LED | FW_LEN16(c));
2818 c.blinkdur = htons(nblinks);
2819 return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
2820}
2821
2822/**
2823 * t4_iq_start_stop - enable/disable an ingress queue and its FLs
2824 * @adap: the adapter
2825 * @mbox: mailbox to use for the FW command
2826 * @start: %true to enable the queues, %false to disable them
2827 * @pf: the PF owning the queues
2828 * @vf: the VF owning the queues
2829 * @iqid: ingress queue id
2830 * @fl0id: FL0 queue id or 0xffff if no attached FL0
2831 * @fl1id: FL1 queue id or 0xffff if no attached FL1
2832 *
2833 * Starts or stops an ingress queue and its associated FLs, if any.
2834 */
2835int t4_iq_start_stop(struct adapter *adap, unsigned int mbox, bool start,
2836 unsigned int pf, unsigned int vf, unsigned int iqid,
2837 unsigned int fl0id, unsigned int fl1id)
2838{
2839 struct fw_iq_cmd c;
2840
2841 memset(&c, 0, sizeof(c));
2842 c.op_to_vfn = htonl(FW_CMD_OP(FW_IQ_CMD) | FW_CMD_REQUEST |
2843 FW_CMD_EXEC | FW_IQ_CMD_PFN(pf) |
2844 FW_IQ_CMD_VFN(vf));
2845 c.alloc_to_len16 = htonl(FW_IQ_CMD_IQSTART(start) |
2846 FW_IQ_CMD_IQSTOP(!start) | FW_LEN16(c));
2847 c.iqid = htons(iqid);
2848 c.fl0id = htons(fl0id);
2849 c.fl1id = htons(fl1id);
2850 return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
2851}
2852
2853/**
2854 * t4_iq_free - free an ingress queue and its FLs
2855 * @adap: the adapter
2856 * @mbox: mailbox to use for the FW command
2857 * @pf: the PF owning the queues
2858 * @vf: the VF owning the queues
2859 * @iqtype: the ingress queue type
2860 * @iqid: ingress queue id
2861 * @fl0id: FL0 queue id or 0xffff if no attached FL0
2862 * @fl1id: FL1 queue id or 0xffff if no attached FL1
2863 *
2864 * Frees an ingress queue and its associated FLs, if any.
2865 */
2866int t4_iq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
2867 unsigned int vf, unsigned int iqtype, unsigned int iqid,
2868 unsigned int fl0id, unsigned int fl1id)
2869{
2870 struct fw_iq_cmd c;
2871
2872 memset(&c, 0, sizeof(c));
2873 c.op_to_vfn = htonl(FW_CMD_OP(FW_IQ_CMD) | FW_CMD_REQUEST |
2874 FW_CMD_EXEC | FW_IQ_CMD_PFN(pf) |
2875 FW_IQ_CMD_VFN(vf));
2876 c.alloc_to_len16 = htonl(FW_IQ_CMD_FREE | FW_LEN16(c));
2877 c.type_to_iqandstindex = htonl(FW_IQ_CMD_TYPE(iqtype));
2878 c.iqid = htons(iqid);
2879 c.fl0id = htons(fl0id);
2880 c.fl1id = htons(fl1id);
2881 return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
2882}
2883
2884/**
2885 * t4_eth_eq_free - free an Ethernet egress queue
2886 * @adap: the adapter
2887 * @mbox: mailbox to use for the FW command
2888 * @pf: the PF owning the queue
2889 * @vf: the VF owning the queue
2890 * @eqid: egress queue id
2891 *
2892 * Frees an Ethernet egress queue.
2893 */
2894int t4_eth_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
2895 unsigned int vf, unsigned int eqid)
2896{
2897 struct fw_eq_eth_cmd c;
2898
2899 memset(&c, 0, sizeof(c));
2900 c.op_to_vfn = htonl(FW_CMD_OP(FW_EQ_ETH_CMD) | FW_CMD_REQUEST |
2901 FW_CMD_EXEC | FW_EQ_ETH_CMD_PFN(pf) |
2902 FW_EQ_ETH_CMD_VFN(vf));
2903 c.alloc_to_len16 = htonl(FW_EQ_ETH_CMD_FREE | FW_LEN16(c));
2904 c.eqid_pkd = htonl(FW_EQ_ETH_CMD_EQID(eqid));
2905 return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
2906}
2907
2908/**
2909 * t4_ctrl_eq_free - free a control egress queue
2910 * @adap: the adapter
2911 * @mbox: mailbox to use for the FW command
2912 * @pf: the PF owning the queue
2913 * @vf: the VF owning the queue
2914 * @eqid: egress queue id
2915 *
2916 * Frees a control egress queue.
2917 */
2918int t4_ctrl_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
2919 unsigned int vf, unsigned int eqid)
2920{
2921 struct fw_eq_ctrl_cmd c;
2922
2923 memset(&c, 0, sizeof(c));
2924 c.op_to_vfn = htonl(FW_CMD_OP(FW_EQ_CTRL_CMD) | FW_CMD_REQUEST |
2925 FW_CMD_EXEC | FW_EQ_CTRL_CMD_PFN(pf) |
2926 FW_EQ_CTRL_CMD_VFN(vf));
2927 c.alloc_to_len16 = htonl(FW_EQ_CTRL_CMD_FREE | FW_LEN16(c));
2928 c.cmpliqid_eqid = htonl(FW_EQ_CTRL_CMD_EQID(eqid));
2929 return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
2930}
2931
2932/**
2933 * t4_ofld_eq_free - free an offload egress queue
2934 * @adap: the adapter
2935 * @mbox: mailbox to use for the FW command
2936 * @pf: the PF owning the queue
2937 * @vf: the VF owning the queue
2938 * @eqid: egress queue id
2939 *
2940 * Frees a control egress queue.
2941 */
2942int t4_ofld_eq_free(struct adapter *adap, unsigned int mbox, unsigned int pf,
2943 unsigned int vf, unsigned int eqid)
2944{
2945 struct fw_eq_ofld_cmd c;
2946
2947 memset(&c, 0, sizeof(c));
2948 c.op_to_vfn = htonl(FW_CMD_OP(FW_EQ_OFLD_CMD) | FW_CMD_REQUEST |
2949 FW_CMD_EXEC | FW_EQ_OFLD_CMD_PFN(pf) |
2950 FW_EQ_OFLD_CMD_VFN(vf));
2951 c.alloc_to_len16 = htonl(FW_EQ_OFLD_CMD_FREE | FW_LEN16(c));
2952 c.eqid_pkd = htonl(FW_EQ_OFLD_CMD_EQID(eqid));
2953 return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
2954}
2955
2956/**
2957 * t4_handle_fw_rpl - process a FW reply message
2958 * @adap: the adapter
2959 * @rpl: start of the FW message
2960 *
2961 * Processes a FW message, such as link state change messages.
2962 */
2963int t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl)
2964{
2965 u8 opcode = *(const u8 *)rpl;
2966
2967 if (opcode == FW_PORT_CMD) { /* link/module state change message */
2968 int speed = 0, fc = 0;
2969 const struct fw_port_cmd *p = (void *)rpl;
2970 int chan = FW_PORT_CMD_PORTID_GET(ntohl(p->op_to_portid));
2971 int port = adap->chan_map[chan];
2972 struct port_info *pi = adap2pinfo(adap, port);
2973 struct link_config *lc = &pi->link_cfg;
2974 u32 stat = ntohl(p->u.info.lstatus_to_modtype);
2975 int link_ok = (stat & FW_PORT_CMD_LSTATUS) != 0;
2976 u32 mod = FW_PORT_CMD_MODTYPE_GET(stat);
2977
2978 if (stat & FW_PORT_CMD_RXPAUSE)
2979 fc |= PAUSE_RX;
2980 if (stat & FW_PORT_CMD_TXPAUSE)
2981 fc |= PAUSE_TX;
2982 if (stat & FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_100M))
2983 speed = SPEED_100;
2984 else if (stat & FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_1G))
2985 speed = SPEED_1000;
2986 else if (stat & FW_PORT_CMD_LSPEED(FW_PORT_CAP_SPEED_10G))
2987 speed = SPEED_10000;
2988
2989 if (link_ok != lc->link_ok || speed != lc->speed ||
2990 fc != lc->fc) { /* something changed */
2991 lc->link_ok = link_ok;
2992 lc->speed = speed;
2993 lc->fc = fc;
2994 t4_os_link_changed(adap, port, link_ok);
2995 }
2996 if (mod != pi->mod_type) {
2997 pi->mod_type = mod;
2998 t4_os_portmod_changed(adap, port);
2999 }
3000 }
3001 return 0;
3002}
3003
3004static void __devinit get_pci_mode(struct adapter *adapter,
3005 struct pci_params *p)
3006{
3007 u16 val;
3008 u32 pcie_cap = pci_pcie_cap(adapter->pdev);
3009
3010 if (pcie_cap) {
3011 pci_read_config_word(adapter->pdev, pcie_cap + PCI_EXP_LNKSTA,
3012 &val);
3013 p->speed = val & PCI_EXP_LNKSTA_CLS;
3014 p->width = (val & PCI_EXP_LNKSTA_NLW) >> 4;
3015 }
3016}
3017
3018/**
3019 * init_link_config - initialize a link's SW state
3020 * @lc: structure holding the link state
3021 * @caps: link capabilities
3022 *
3023 * Initializes the SW state maintained for each link, including the link's
3024 * capabilities and default speed/flow-control/autonegotiation settings.
3025 */
3026static void __devinit init_link_config(struct link_config *lc,
3027 unsigned int caps)
3028{
3029 lc->supported = caps;
3030 lc->requested_speed = 0;
3031 lc->speed = 0;
3032 lc->requested_fc = lc->fc = PAUSE_RX | PAUSE_TX;
3033 if (lc->supported & FW_PORT_CAP_ANEG) {
3034 lc->advertising = lc->supported & ADVERT_MASK;
3035 lc->autoneg = AUTONEG_ENABLE;
3036 lc->requested_fc |= PAUSE_AUTONEG;
3037 } else {
3038 lc->advertising = 0;
3039 lc->autoneg = AUTONEG_DISABLE;
3040 }
3041}
3042
3043static int __devinit wait_dev_ready(struct adapter *adap)
3044{
3045 if (t4_read_reg(adap, PL_WHOAMI) != 0xffffffff)
3046 return 0;
3047 msleep(500);
3048 return t4_read_reg(adap, PL_WHOAMI) != 0xffffffff ? 0 : -EIO;
3049}
3050
3051/**
3052 * t4_prep_adapter - prepare SW and HW for operation
3053 * @adapter: the adapter
3054 * @reset: if true perform a HW reset
3055 *
3056 * Initialize adapter SW state for the various HW modules, set initial
3057 * values for some adapter tunables, take PHYs out of reset, and
3058 * initialize the MDIO interface.
3059 */
3060int __devinit t4_prep_adapter(struct adapter *adapter)
3061{
3062 int ret;
3063
3064 ret = wait_dev_ready(adapter);
3065 if (ret < 0)
3066 return ret;
3067
3068 get_pci_mode(adapter, &adapter->params.pci);
3069 adapter->params.rev = t4_read_reg(adapter, PL_REV);
3070
3071 ret = get_vpd_params(adapter, &adapter->params.vpd);
3072 if (ret < 0)
3073 return ret;
3074
3075 init_cong_ctrl(adapter->params.a_wnd, adapter->params.b_wnd);
3076
3077 /*
3078 * Default port for debugging in case we can't reach FW.
3079 */
3080 adapter->params.nports = 1;
3081 adapter->params.portvec = 1;
3082 return 0;
3083}
3084
3085int __devinit t4_port_init(struct adapter *adap, int mbox, int pf, int vf)
3086{
3087 u8 addr[6];
3088 int ret, i, j = 0;
3089 struct fw_port_cmd c;
3090
3091 memset(&c, 0, sizeof(c));
3092
3093 for_each_port(adap, i) {
3094 unsigned int rss_size;
3095 struct port_info *p = adap2pinfo(adap, i);
3096
3097 while ((adap->params.portvec & (1 << j)) == 0)
3098 j++;
3099
3100 c.op_to_portid = htonl(FW_CMD_OP(FW_PORT_CMD) |
3101 FW_CMD_REQUEST | FW_CMD_READ |
3102 FW_PORT_CMD_PORTID(j));
3103 c.action_to_len16 = htonl(
3104 FW_PORT_CMD_ACTION(FW_PORT_ACTION_GET_PORT_INFO) |
3105 FW_LEN16(c));
3106 ret = t4_wr_mbox(adap, mbox, &c, sizeof(c), &c);
3107 if (ret)
3108 return ret;
3109
3110 ret = t4_alloc_vi(adap, mbox, j, pf, vf, 1, addr, &rss_size);
3111 if (ret < 0)
3112 return ret;
3113
3114 p->viid = ret;
3115 p->tx_chan = j;
3116 p->lport = j;
3117 p->rss_size = rss_size;
3118 memcpy(adap->port[i]->dev_addr, addr, ETH_ALEN);
3119 memcpy(adap->port[i]->perm_addr, addr, ETH_ALEN);
3120
3121 ret = ntohl(c.u.info.lstatus_to_modtype);
3122 p->mdio_addr = (ret & FW_PORT_CMD_MDIOCAP) ?
3123 FW_PORT_CMD_MDIOADDR_GET(ret) : -1;
3124 p->port_type = FW_PORT_CMD_PTYPE_GET(ret);
3125 p->mod_type = FW_PORT_CMD_MODTYPE_GET(ret);
3126
3127 init_link_config(&p->link_cfg, ntohs(c.u.info.pcap));
3128 j++;
3129 }
3130 return 0;
3131}
diff --git a/drivers/net/cxgb4/t4_hw.h b/drivers/net/cxgb4/t4_hw.h
new file mode 100644
index 00000000000..025623285c9
--- /dev/null
+++ b/drivers/net/cxgb4/t4_hw.h
@@ -0,0 +1,100 @@
1/*
2 * This file is part of the Chelsio T4 Ethernet driver for Linux.
3 *
4 * Copyright (c) 2003-2010 Chelsio Communications, Inc. All rights reserved.
5 *
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
11 *
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
14 * conditions are met:
15 *
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer.
19 *
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
24 *
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE.
33 */
34
35#ifndef __T4_HW_H
36#define __T4_HW_H
37
38#include <linux/types.h>
39
40enum {
41 NCHAN = 4, /* # of HW channels */
42 MAX_MTU = 9600, /* max MAC MTU, excluding header + FCS */
43 EEPROMSIZE = 17408, /* Serial EEPROM physical size */
44 EEPROMVSIZE = 32768, /* Serial EEPROM virtual address space size */
45 RSS_NENTRIES = 2048, /* # of entries in RSS mapping table */
46 TCB_SIZE = 128, /* TCB size */
47 NMTUS = 16, /* size of MTU table */
48 NCCTRL_WIN = 32, /* # of congestion control windows */
49 NEXACT_MAC = 336, /* # of exact MAC address filters */
50 L2T_SIZE = 4096, /* # of L2T entries */
51 MBOX_LEN = 64, /* mailbox size in bytes */
52 TRACE_LEN = 112, /* length of trace data and mask */
53 FILTER_OPT_LEN = 36, /* filter tuple width for optional components */
54 NWOL_PAT = 8, /* # of WoL patterns */
55 WOL_PAT_LEN = 128, /* length of WoL patterns */
56};
57
58enum {
59 SF_PAGE_SIZE = 256, /* serial flash page size */
60 SF_SEC_SIZE = 64 * 1024, /* serial flash sector size */
61 SF_SIZE = SF_SEC_SIZE * 16, /* serial flash size */
62};
63
64enum { RSP_TYPE_FLBUF, RSP_TYPE_CPL, RSP_TYPE_INTR }; /* response entry types */
65
66enum { MBOX_OWNER_NONE, MBOX_OWNER_FW, MBOX_OWNER_DRV }; /* mailbox owners */
67
68enum {
69 SGE_MAX_WR_LEN = 512, /* max WR size in bytes */
70 SGE_NTIMERS = 6, /* # of interrupt holdoff timer values */
71 SGE_NCOUNTERS = 4, /* # of interrupt packet counter values */
72};
73
74struct sge_qstat { /* data written to SGE queue status entries */
75 __be32 qid;
76 __be16 cidx;
77 __be16 pidx;
78};
79
80/*
81 * Structure for last 128 bits of response descriptors
82 */
83struct rsp_ctrl {
84 __be32 hdrbuflen_pidx;
85 __be32 pldbuflen_qid;
86 union {
87 u8 type_gen;
88 __be64 last_flit;
89 };
90};
91
92#define RSPD_NEWBUF 0x80000000U
93#define RSPD_LEN 0x7fffffffU
94
95#define RSPD_GEN(x) ((x) >> 7)
96#define RSPD_TYPE(x) (((x) >> 4) & 3)
97
98#define QINTR_CNT_EN 0x1
99#define QINTR_TIMER_IDX(x) ((x) << 1)
100#endif /* __T4_HW_H */
diff --git a/drivers/net/cxgb4/t4_msg.h b/drivers/net/cxgb4/t4_msg.h
new file mode 100644
index 00000000000..fdb11744314
--- /dev/null
+++ b/drivers/net/cxgb4/t4_msg.h
@@ -0,0 +1,664 @@
1/*
2 * This file is part of the Chelsio T4 Ethernet driver for Linux.
3 *
4 * Copyright (c) 2003-2010 Chelsio Communications, Inc. All rights reserved.
5 *
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
11 *
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
14 * conditions are met:
15 *
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer.
19 *
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
24 *
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE.
33 */
34
35#ifndef __T4_MSG_H
36#define __T4_MSG_H
37
38#include <linux/types.h>
39
40enum {
41 CPL_PASS_OPEN_REQ = 0x1,
42 CPL_PASS_ACCEPT_RPL = 0x2,
43 CPL_ACT_OPEN_REQ = 0x3,
44 CPL_SET_TCB_FIELD = 0x5,
45 CPL_GET_TCB = 0x6,
46 CPL_CLOSE_CON_REQ = 0x8,
47 CPL_CLOSE_LISTSRV_REQ = 0x9,
48 CPL_ABORT_REQ = 0xA,
49 CPL_ABORT_RPL = 0xB,
50 CPL_RX_DATA_ACK = 0xD,
51 CPL_TX_PKT = 0xE,
52 CPL_L2T_WRITE_REQ = 0x12,
53 CPL_TID_RELEASE = 0x1A,
54
55 CPL_CLOSE_LISTSRV_RPL = 0x20,
56 CPL_L2T_WRITE_RPL = 0x23,
57 CPL_PASS_OPEN_RPL = 0x24,
58 CPL_ACT_OPEN_RPL = 0x25,
59 CPL_PEER_CLOSE = 0x26,
60 CPL_ABORT_REQ_RSS = 0x2B,
61 CPL_ABORT_RPL_RSS = 0x2D,
62
63 CPL_CLOSE_CON_RPL = 0x32,
64 CPL_ISCSI_HDR = 0x33,
65 CPL_RDMA_CQE = 0x35,
66 CPL_RDMA_CQE_READ_RSP = 0x36,
67 CPL_RDMA_CQE_ERR = 0x37,
68 CPL_RX_DATA = 0x39,
69 CPL_SET_TCB_RPL = 0x3A,
70 CPL_RX_PKT = 0x3B,
71 CPL_RX_DDP_COMPLETE = 0x3F,
72
73 CPL_ACT_ESTABLISH = 0x40,
74 CPL_PASS_ESTABLISH = 0x41,
75 CPL_RX_DATA_DDP = 0x42,
76 CPL_PASS_ACCEPT_REQ = 0x44,
77
78 CPL_RDMA_READ_REQ = 0x60,
79
80 CPL_PASS_OPEN_REQ6 = 0x81,
81 CPL_ACT_OPEN_REQ6 = 0x83,
82
83 CPL_RDMA_TERMINATE = 0xA2,
84 CPL_RDMA_WRITE = 0xA4,
85 CPL_SGE_EGR_UPDATE = 0xA5,
86
87 CPL_TRACE_PKT = 0xB0,
88
89 CPL_FW4_MSG = 0xC0,
90 CPL_FW4_PLD = 0xC1,
91 CPL_FW4_ACK = 0xC3,
92
93 CPL_FW6_MSG = 0xE0,
94 CPL_FW6_PLD = 0xE1,
95 CPL_TX_PKT_LSO = 0xED,
96 CPL_TX_PKT_XT = 0xEE,
97
98 NUM_CPL_CMDS
99};
100
101enum CPL_error {
102 CPL_ERR_NONE = 0,
103 CPL_ERR_TCAM_FULL = 3,
104 CPL_ERR_BAD_LENGTH = 15,
105 CPL_ERR_BAD_ROUTE = 18,
106 CPL_ERR_CONN_RESET = 20,
107 CPL_ERR_CONN_EXIST_SYNRECV = 21,
108 CPL_ERR_CONN_EXIST = 22,
109 CPL_ERR_ARP_MISS = 23,
110 CPL_ERR_BAD_SYN = 24,
111 CPL_ERR_CONN_TIMEDOUT = 30,
112 CPL_ERR_XMIT_TIMEDOUT = 31,
113 CPL_ERR_PERSIST_TIMEDOUT = 32,
114 CPL_ERR_FINWAIT2_TIMEDOUT = 33,
115 CPL_ERR_KEEPALIVE_TIMEDOUT = 34,
116 CPL_ERR_RTX_NEG_ADVICE = 35,
117 CPL_ERR_PERSIST_NEG_ADVICE = 36,
118 CPL_ERR_ABORT_FAILED = 42,
119 CPL_ERR_IWARP_FLM = 50,
120};
121
122enum {
123 ULP_MODE_NONE = 0,
124 ULP_MODE_ISCSI = 2,
125 ULP_MODE_RDMA = 4,
126 ULP_MODE_FCOE = 6,
127};
128
129enum {
130 ULP_CRC_HEADER = 1 << 0,
131 ULP_CRC_DATA = 1 << 1
132};
133
134enum {
135 CPL_ABORT_SEND_RST = 0,
136 CPL_ABORT_NO_RST,
137};
138
139enum { /* TX_PKT_XT checksum types */
140 TX_CSUM_TCP = 0,
141 TX_CSUM_UDP = 1,
142 TX_CSUM_CRC16 = 4,
143 TX_CSUM_CRC32 = 5,
144 TX_CSUM_CRC32C = 6,
145 TX_CSUM_FCOE = 7,
146 TX_CSUM_TCPIP = 8,
147 TX_CSUM_UDPIP = 9,
148 TX_CSUM_TCPIP6 = 10,
149 TX_CSUM_UDPIP6 = 11,
150 TX_CSUM_IP = 12,
151};
152
153union opcode_tid {
154 __be32 opcode_tid;
155 u8 opcode;
156};
157
158#define CPL_OPCODE(x) ((x) << 24)
159#define MK_OPCODE_TID(opcode, tid) (CPL_OPCODE(opcode) | (tid))
160#define OPCODE_TID(cmd) ((cmd)->ot.opcode_tid)
161#define GET_TID(cmd) (ntohl(OPCODE_TID(cmd)) & 0xFFFFFF)
162
163/* partitioning of TID fields that also carry a queue id */
164#define GET_TID_TID(x) ((x) & 0x3fff)
165#define GET_TID_QID(x) (((x) >> 14) & 0x3ff)
166#define TID_QID(x) ((x) << 14)
167
168struct rss_header {
169 u8 opcode;
170#if defined(__LITTLE_ENDIAN_BITFIELD)
171 u8 channel:2;
172 u8 filter_hit:1;
173 u8 filter_tid:1;
174 u8 hash_type:2;
175 u8 ipv6:1;
176 u8 send2fw:1;
177#else
178 u8 send2fw:1;
179 u8 ipv6:1;
180 u8 hash_type:2;
181 u8 filter_tid:1;
182 u8 filter_hit:1;
183 u8 channel:2;
184#endif
185 __be16 qid;
186 __be32 hash_val;
187};
188
189struct work_request_hdr {
190 __be32 wr_hi;
191 __be32 wr_mid;
192 __be64 wr_lo;
193};
194
195#define WR_HDR struct work_request_hdr wr
196
197struct cpl_pass_open_req {
198 WR_HDR;
199 union opcode_tid ot;
200 __be16 local_port;
201 __be16 peer_port;
202 __be32 local_ip;
203 __be32 peer_ip;
204 __be64 opt0;
205#define TX_CHAN(x) ((x) << 2)
206#define DELACK(x) ((x) << 5)
207#define ULP_MODE(x) ((x) << 8)
208#define RCV_BUFSIZ(x) ((x) << 12)
209#define DSCP(x) ((x) << 22)
210#define SMAC_SEL(x) ((u64)(x) << 28)
211#define L2T_IDX(x) ((u64)(x) << 36)
212#define NAGLE(x) ((u64)(x) << 49)
213#define WND_SCALE(x) ((u64)(x) << 50)
214#define KEEP_ALIVE(x) ((u64)(x) << 54)
215#define MSS_IDX(x) ((u64)(x) << 60)
216 __be64 opt1;
217#define SYN_RSS_ENABLE (1 << 0)
218#define SYN_RSS_QUEUE(x) ((x) << 2)
219#define CONN_POLICY_ASK (1 << 22)
220};
221
222struct cpl_pass_open_req6 {
223 WR_HDR;
224 union opcode_tid ot;
225 __be16 local_port;
226 __be16 peer_port;
227 __be64 local_ip_hi;
228 __be64 local_ip_lo;
229 __be64 peer_ip_hi;
230 __be64 peer_ip_lo;
231 __be64 opt0;
232 __be64 opt1;
233};
234
235struct cpl_pass_open_rpl {
236 union opcode_tid ot;
237 u8 rsvd[3];
238 u8 status;
239};
240
241struct cpl_pass_accept_rpl {
242 WR_HDR;
243 union opcode_tid ot;
244 __be32 opt2;
245#define RSS_QUEUE(x) ((x) << 0)
246#define RSS_QUEUE_VALID (1 << 10)
247#define RX_COALESCE_VALID(x) ((x) << 11)
248#define RX_COALESCE(x) ((x) << 12)
249#define TX_QUEUE(x) ((x) << 23)
250#define RX_CHANNEL(x) ((x) << 26)
251#define WND_SCALE_EN(x) ((x) << 28)
252#define TSTAMPS_EN(x) ((x) << 29)
253#define SACK_EN(x) ((x) << 30)
254 __be64 opt0;
255};
256
257struct cpl_act_open_req {
258 WR_HDR;
259 union opcode_tid ot;
260 __be16 local_port;
261 __be16 peer_port;
262 __be32 local_ip;
263 __be32 peer_ip;
264 __be64 opt0;
265 __be32 params;
266 __be32 opt2;
267};
268
269struct cpl_act_open_req6 {
270 WR_HDR;
271 union opcode_tid ot;
272 __be16 local_port;
273 __be16 peer_port;
274 __be64 local_ip_hi;
275 __be64 local_ip_lo;
276 __be64 peer_ip_hi;
277 __be64 peer_ip_lo;
278 __be64 opt0;
279 __be32 params;
280 __be32 opt2;
281};
282
283struct cpl_act_open_rpl {
284 union opcode_tid ot;
285 __be32 atid_status;
286#define GET_AOPEN_STATUS(x) ((x) & 0xff)
287#define GET_AOPEN_ATID(x) (((x) >> 8) & 0xffffff)
288};
289
290struct cpl_pass_establish {
291 union opcode_tid ot;
292 __be32 rsvd;
293 __be32 tos_stid;
294#define GET_POPEN_TID(x) ((x) & 0xffffff)
295#define GET_POPEN_TOS(x) (((x) >> 24) & 0xff)
296 __be16 mac_idx;
297 __be16 tcp_opt;
298#define GET_TCPOPT_WSCALE_OK(x) (((x) >> 5) & 1)
299#define GET_TCPOPT_SACK(x) (((x) >> 6) & 1)
300#define GET_TCPOPT_TSTAMP(x) (((x) >> 7) & 1)
301#define GET_TCPOPT_SND_WSCALE(x) (((x) >> 8) & 0xf)
302#define GET_TCPOPT_MSS(x) (((x) >> 12) & 0xf)
303 __be32 snd_isn;
304 __be32 rcv_isn;
305};
306
307struct cpl_act_establish {
308 union opcode_tid ot;
309 __be32 rsvd;
310 __be32 tos_atid;
311 __be16 mac_idx;
312 __be16 tcp_opt;
313 __be32 snd_isn;
314 __be32 rcv_isn;
315};
316
317struct cpl_get_tcb {
318 WR_HDR;
319 union opcode_tid ot;
320 __be16 reply_ctrl;
321#define QUEUENO(x) ((x) << 0)
322#define REPLY_CHAN(x) ((x) << 14)
323#define NO_REPLY(x) ((x) << 15)
324 __be16 cookie;
325};
326
327struct cpl_set_tcb_field {
328 WR_HDR;
329 union opcode_tid ot;
330 __be16 reply_ctrl;
331 __be16 word_cookie;
332#define TCB_WORD(x) ((x) << 0)
333#define TCB_COOKIE(x) ((x) << 5)
334 __be64 mask;
335 __be64 val;
336};
337
338struct cpl_set_tcb_rpl {
339 union opcode_tid ot;
340 __be16 rsvd;
341 u8 cookie;
342 u8 status;
343 __be64 oldval;
344};
345
346struct cpl_close_con_req {
347 WR_HDR;
348 union opcode_tid ot;
349 __be32 rsvd;
350};
351
352struct cpl_close_con_rpl {
353 union opcode_tid ot;
354 u8 rsvd[3];
355 u8 status;
356 __be32 snd_nxt;
357 __be32 rcv_nxt;
358};
359
360struct cpl_close_listsvr_req {
361 WR_HDR;
362 union opcode_tid ot;
363 __be16 reply_ctrl;
364#define LISTSVR_IPV6 (1 << 14)
365 __be16 rsvd;
366};
367
368struct cpl_close_listsvr_rpl {
369 union opcode_tid ot;
370 u8 rsvd[3];
371 u8 status;
372};
373
374struct cpl_abort_req_rss {
375 union opcode_tid ot;
376 u8 rsvd[3];
377 u8 status;
378};
379
380struct cpl_abort_req {
381 WR_HDR;
382 union opcode_tid ot;
383 __be32 rsvd0;
384 u8 rsvd1;
385 u8 cmd;
386 u8 rsvd2[6];
387};
388
389struct cpl_abort_rpl_rss {
390 union opcode_tid ot;
391 u8 rsvd[3];
392 u8 status;
393};
394
395struct cpl_abort_rpl {
396 WR_HDR;
397 union opcode_tid ot;
398 __be32 rsvd0;
399 u8 rsvd1;
400 u8 cmd;
401 u8 rsvd2[6];
402};
403
404struct cpl_peer_close {
405 union opcode_tid ot;
406 __be32 rcv_nxt;
407};
408
409struct cpl_tid_release {
410 WR_HDR;
411 union opcode_tid ot;
412 __be32 rsvd;
413};
414
415struct cpl_tx_pkt_core {
416 __be32 ctrl0;
417#define TXPKT_VF(x) ((x) << 0)
418#define TXPKT_PF(x) ((x) << 8)
419#define TXPKT_VF_VLD (1 << 11)
420#define TXPKT_OVLAN_IDX(x) ((x) << 12)
421#define TXPKT_INTF(x) ((x) << 16)
422#define TXPKT_INS_OVLAN (1 << 21)
423#define TXPKT_OPCODE(x) ((x) << 24)
424 __be16 pack;
425 __be16 len;
426 __be64 ctrl1;
427#define TXPKT_CSUM_END(x) ((x) << 12)
428#define TXPKT_CSUM_START(x) ((x) << 20)
429#define TXPKT_IPHDR_LEN(x) ((u64)(x) << 20)
430#define TXPKT_CSUM_LOC(x) ((u64)(x) << 30)
431#define TXPKT_ETHHDR_LEN(x) ((u64)(x) << 34)
432#define TXPKT_CSUM_TYPE(x) ((u64)(x) << 40)
433#define TXPKT_VLAN(x) ((u64)(x) << 44)
434#define TXPKT_VLAN_VLD (1ULL << 60)
435#define TXPKT_IPCSUM_DIS (1ULL << 62)
436#define TXPKT_L4CSUM_DIS (1ULL << 63)
437};
438
439struct cpl_tx_pkt {
440 WR_HDR;
441 struct cpl_tx_pkt_core c;
442};
443
444#define cpl_tx_pkt_xt cpl_tx_pkt
445
446struct cpl_tx_pkt_lso {
447 WR_HDR;
448 __be32 lso_ctrl;
449#define LSO_TCPHDR_LEN(x) ((x) << 0)
450#define LSO_IPHDR_LEN(x) ((x) << 4)
451#define LSO_ETHHDR_LEN(x) ((x) << 16)
452#define LSO_IPV6(x) ((x) << 20)
453#define LSO_LAST_SLICE (1 << 22)
454#define LSO_FIRST_SLICE (1 << 23)
455#define LSO_OPCODE(x) ((x) << 24)
456 __be16 ipid_ofst;
457 __be16 mss;
458 __be32 seqno_offset;
459 __be32 len;
460 /* encapsulated CPL (TX_PKT, TX_PKT_XT or TX_DATA) follows here */
461};
462
463struct cpl_iscsi_hdr {
464 union opcode_tid ot;
465 __be16 pdu_len_ddp;
466#define ISCSI_PDU_LEN(x) ((x) & 0x7FFF)
467#define ISCSI_DDP (1 << 15)
468 __be16 len;
469 __be32 seq;
470 __be16 urg;
471 u8 rsvd;
472 u8 status;
473};
474
475struct cpl_rx_data {
476 union opcode_tid ot;
477 __be16 rsvd;
478 __be16 len;
479 __be32 seq;
480 __be16 urg;
481#if defined(__LITTLE_ENDIAN_BITFIELD)
482 u8 dack_mode:2;
483 u8 psh:1;
484 u8 heartbeat:1;
485 u8 ddp_off:1;
486 u8 :3;
487#else
488 u8 :3;
489 u8 ddp_off:1;
490 u8 heartbeat:1;
491 u8 psh:1;
492 u8 dack_mode:2;
493#endif
494 u8 status;
495};
496
497struct cpl_rx_data_ack {
498 WR_HDR;
499 union opcode_tid ot;
500 __be32 credit_dack;
501#define RX_CREDITS(x) ((x) << 0)
502#define RX_FORCE_ACK(x) ((x) << 28)
503};
504
505struct cpl_rx_pkt {
506 u8 opcode;
507#if defined(__LITTLE_ENDIAN_BITFIELD)
508 u8 iff:4;
509 u8 csum_calc:1;
510 u8 ipmi_pkt:1;
511 u8 vlan_ex:1;
512 u8 ip_frag:1;
513#else
514 u8 ip_frag:1;
515 u8 vlan_ex:1;
516 u8 ipmi_pkt:1;
517 u8 csum_calc:1;
518 u8 iff:4;
519#endif
520 __be16 csum;
521 __be16 vlan;
522 __be16 len;
523 __be32 l2info;
524#define RXF_UDP (1 << 22)
525#define RXF_TCP (1 << 23)
526 __be16 hdr_len;
527 __be16 err_vec;
528};
529
530struct cpl_trace_pkt {
531 u8 opcode;
532 u8 intf;
533#if defined(__LITTLE_ENDIAN_BITFIELD)
534 u8 runt:4;
535 u8 filter_hit:4;
536 u8 :6;
537 u8 err:1;
538 u8 trunc:1;
539#else
540 u8 filter_hit:4;
541 u8 runt:4;
542 u8 trunc:1;
543 u8 err:1;
544 u8 :6;
545#endif
546 __be16 rsvd;
547 __be16 len;
548 __be64 tstamp;
549};
550
551struct cpl_l2t_write_req {
552 WR_HDR;
553 union opcode_tid ot;
554 __be16 params;
555#define L2T_W_INFO(x) ((x) << 2)
556#define L2T_W_PORT(x) ((x) << 8)
557#define L2T_W_NOREPLY(x) ((x) << 15)
558 __be16 l2t_idx;
559 __be16 vlan;
560 u8 dst_mac[6];
561};
562
563struct cpl_l2t_write_rpl {
564 union opcode_tid ot;
565 u8 status;
566 u8 rsvd[3];
567};
568
569struct cpl_rdma_terminate {
570 union opcode_tid ot;
571 __be16 rsvd;
572 __be16 len;
573};
574
575struct cpl_sge_egr_update {
576 __be32 opcode_qid;
577#define EGR_QID(x) ((x) & 0x1FFFF)
578 __be16 cidx;
579 __be16 pidx;
580};
581
582struct cpl_fw4_pld {
583 u8 opcode;
584 u8 rsvd0[3];
585 u8 type;
586 u8 rsvd1;
587 __be16 len;
588 __be64 data;
589 __be64 rsvd2;
590};
591
592struct cpl_fw6_pld {
593 u8 opcode;
594 u8 rsvd[5];
595 __be16 len;
596 __be64 data[4];
597};
598
599struct cpl_fw4_msg {
600 u8 opcode;
601 u8 type;
602 __be16 rsvd0;
603 __be32 rsvd1;
604 __be64 data[2];
605};
606
607struct cpl_fw4_ack {
608 union opcode_tid ot;
609 u8 credits;
610 u8 rsvd0[2];
611 u8 seq_vld;
612 __be32 snd_nxt;
613 __be32 snd_una;
614 __be64 rsvd1;
615};
616
617struct cpl_fw6_msg {
618 u8 opcode;
619 u8 type;
620 __be16 rsvd0;
621 __be32 rsvd1;
622 __be64 data[4];
623};
624
625enum {
626 ULP_TX_MEM_READ = 2,
627 ULP_TX_MEM_WRITE = 3,
628 ULP_TX_PKT = 4
629};
630
631enum {
632 ULP_TX_SC_NOOP = 0x80,
633 ULP_TX_SC_IMM = 0x81,
634 ULP_TX_SC_DSGL = 0x82,
635 ULP_TX_SC_ISGL = 0x83
636};
637
638struct ulptx_sge_pair {
639 __be32 len[2];
640 __be64 addr[2];
641};
642
643struct ulptx_sgl {
644 __be32 cmd_nsge;
645#define ULPTX_CMD(x) ((x) << 24)
646#define ULPTX_NSGE(x) ((x) << 0)
647 __be32 len0;
648 __be64 addr0;
649 struct ulptx_sge_pair sge[0];
650};
651
652struct ulp_mem_io {
653 WR_HDR;
654 __be32 cmd;
655#define ULP_MEMIO_ORDER(x) ((x) << 23)
656 __be32 len16; /* command length */
657 __be32 dlen; /* data length in 32-byte units */
658#define ULP_MEMIO_DATA_LEN(x) ((x) << 0)
659 __be32 lock_addr;
660#define ULP_MEMIO_ADDR(x) ((x) << 0)
661#define ULP_MEMIO_LOCK(x) ((x) << 31)
662};
663
664#endif /* __T4_MSG_H */
diff --git a/drivers/net/cxgb4/t4_regs.h b/drivers/net/cxgb4/t4_regs.h
new file mode 100644
index 00000000000..5ed56483cbc
--- /dev/null
+++ b/drivers/net/cxgb4/t4_regs.h
@@ -0,0 +1,878 @@
1/*
2 * This file is part of the Chelsio T4 Ethernet driver for Linux.
3 *
4 * Copyright (c) 2010 Chelsio Communications, Inc. All rights reserved.
5 *
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
11 *
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
14 * conditions are met:
15 *
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer.
19 *
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
24 *
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE.
33 */
34
35#ifndef __T4_REGS_H
36#define __T4_REGS_H
37
38#define MYPF_BASE 0x1b000
39#define MYPF_REG(reg_addr) (MYPF_BASE + (reg_addr))
40
41#define PF0_BASE 0x1e000
42#define PF0_REG(reg_addr) (PF0_BASE + (reg_addr))
43
44#define PF_STRIDE 0x400
45#define PF_BASE(idx) (PF0_BASE + (idx) * PF_STRIDE)
46#define PF_REG(idx, reg) (PF_BASE(idx) + (reg))
47
48#define MYPORT_BASE 0x1c000
49#define MYPORT_REG(reg_addr) (MYPORT_BASE + (reg_addr))
50
51#define PORT0_BASE 0x20000
52#define PORT0_REG(reg_addr) (PORT0_BASE + (reg_addr))
53
54#define PORT_STRIDE 0x2000
55#define PORT_BASE(idx) (PORT0_BASE + (idx) * PORT_STRIDE)
56#define PORT_REG(idx, reg) (PORT_BASE(idx) + (reg))
57
58#define EDC_STRIDE (EDC_1_BASE_ADDR - EDC_0_BASE_ADDR)
59#define EDC_REG(reg, idx) (reg + EDC_STRIDE * idx)
60
61#define PCIE_MEM_ACCESS_REG(reg_addr, idx) ((reg_addr) + (idx) * 8)
62#define PCIE_MAILBOX_REG(reg_addr, idx) ((reg_addr) + (idx) * 8)
63#define MC_BIST_STATUS_REG(reg_addr, idx) ((reg_addr) + (idx) * 4)
64#define EDC_BIST_STATUS_REG(reg_addr, idx) ((reg_addr) + (idx) * 4)
65
66#define SGE_PF_KDOORBELL 0x0
67#define QID_MASK 0xffff8000U
68#define QID_SHIFT 15
69#define QID(x) ((x) << QID_SHIFT)
70#define DBPRIO 0x00004000U
71#define PIDX_MASK 0x00003fffU
72#define PIDX_SHIFT 0
73#define PIDX(x) ((x) << PIDX_SHIFT)
74
75#define SGE_PF_GTS 0x4
76#define INGRESSQID_MASK 0xffff0000U
77#define INGRESSQID_SHIFT 16
78#define INGRESSQID(x) ((x) << INGRESSQID_SHIFT)
79#define TIMERREG_MASK 0x0000e000U
80#define TIMERREG_SHIFT 13
81#define TIMERREG(x) ((x) << TIMERREG_SHIFT)
82#define SEINTARM_MASK 0x00001000U
83#define SEINTARM_SHIFT 12
84#define SEINTARM(x) ((x) << SEINTARM_SHIFT)
85#define CIDXINC_MASK 0x00000fffU
86#define CIDXINC_SHIFT 0
87#define CIDXINC(x) ((x) << CIDXINC_SHIFT)
88
89#define SGE_CONTROL 0x1008
90#define DCASYSTYPE 0x00080000U
91#define RXPKTCPLMODE 0x00040000U
92#define EGRSTATUSPAGESIZE 0x00020000U
93#define PKTSHIFT_MASK 0x00001c00U
94#define PKTSHIFT_SHIFT 10
95#define PKTSHIFT(x) ((x) << PKTSHIFT_SHIFT)
96#define INGPCIEBOUNDARY_MASK 0x00000380U
97#define INGPCIEBOUNDARY_SHIFT 7
98#define INGPCIEBOUNDARY(x) ((x) << INGPCIEBOUNDARY_SHIFT)
99#define INGPADBOUNDARY_MASK 0x00000070U
100#define INGPADBOUNDARY_SHIFT 4
101#define INGPADBOUNDARY(x) ((x) << INGPADBOUNDARY_SHIFT)
102#define EGRPCIEBOUNDARY_MASK 0x0000000eU
103#define EGRPCIEBOUNDARY_SHIFT 1
104#define EGRPCIEBOUNDARY(x) ((x) << EGRPCIEBOUNDARY_SHIFT)
105#define GLOBALENABLE 0x00000001U
106
107#define SGE_HOST_PAGE_SIZE 0x100c
108#define HOSTPAGESIZEPF0_MASK 0x0000000fU
109#define HOSTPAGESIZEPF0_SHIFT 0
110#define HOSTPAGESIZEPF0(x) ((x) << HOSTPAGESIZEPF0_SHIFT)
111
112#define SGE_EGRESS_QUEUES_PER_PAGE_PF 0x1010
113#define QUEUESPERPAGEPF0_MASK 0x0000000fU
114#define QUEUESPERPAGEPF0_GET(x) ((x) & QUEUESPERPAGEPF0_MASK)
115
116#define SGE_INT_CAUSE1 0x1024
117#define SGE_INT_CAUSE2 0x1030
118#define SGE_INT_CAUSE3 0x103c
119#define ERR_FLM_DBP 0x80000000U
120#define ERR_FLM_IDMA1 0x40000000U
121#define ERR_FLM_IDMA0 0x20000000U
122#define ERR_FLM_HINT 0x10000000U
123#define ERR_PCIE_ERROR3 0x08000000U
124#define ERR_PCIE_ERROR2 0x04000000U
125#define ERR_PCIE_ERROR1 0x02000000U
126#define ERR_PCIE_ERROR0 0x01000000U
127#define ERR_TIMER_ABOVE_MAX_QID 0x00800000U
128#define ERR_CPL_EXCEED_IQE_SIZE 0x00400000U
129#define ERR_INVALID_CIDX_INC 0x00200000U
130#define ERR_ITP_TIME_PAUSED 0x00100000U
131#define ERR_CPL_OPCODE_0 0x00080000U
132#define ERR_DROPPED_DB 0x00040000U
133#define ERR_DATA_CPL_ON_HIGH_QID1 0x00020000U
134#define ERR_DATA_CPL_ON_HIGH_QID0 0x00010000U
135#define ERR_BAD_DB_PIDX3 0x00008000U
136#define ERR_BAD_DB_PIDX2 0x00004000U
137#define ERR_BAD_DB_PIDX1 0x00002000U
138#define ERR_BAD_DB_PIDX0 0x00001000U
139#define ERR_ING_PCIE_CHAN 0x00000800U
140#define ERR_ING_CTXT_PRIO 0x00000400U
141#define ERR_EGR_CTXT_PRIO 0x00000200U
142#define DBFIFO_HP_INT 0x00000100U
143#define DBFIFO_LP_INT 0x00000080U
144#define REG_ADDRESS_ERR 0x00000040U
145#define INGRESS_SIZE_ERR 0x00000020U
146#define EGRESS_SIZE_ERR 0x00000010U
147#define ERR_INV_CTXT3 0x00000008U
148#define ERR_INV_CTXT2 0x00000004U
149#define ERR_INV_CTXT1 0x00000002U
150#define ERR_INV_CTXT0 0x00000001U
151
152#define SGE_INT_ENABLE3 0x1040
153#define SGE_FL_BUFFER_SIZE0 0x1044
154#define SGE_FL_BUFFER_SIZE1 0x1048
155#define SGE_INGRESS_RX_THRESHOLD 0x10a0
156#define THRESHOLD_0_MASK 0x3f000000U
157#define THRESHOLD_0_SHIFT 24
158#define THRESHOLD_0(x) ((x) << THRESHOLD_0_SHIFT)
159#define THRESHOLD_0_GET(x) (((x) & THRESHOLD_0_MASK) >> THRESHOLD_0_SHIFT)
160#define THRESHOLD_1_MASK 0x003f0000U
161#define THRESHOLD_1_SHIFT 16
162#define THRESHOLD_1(x) ((x) << THRESHOLD_1_SHIFT)
163#define THRESHOLD_1_GET(x) (((x) & THRESHOLD_1_MASK) >> THRESHOLD_1_SHIFT)
164#define THRESHOLD_2_MASK 0x00003f00U
165#define THRESHOLD_2_SHIFT 8
166#define THRESHOLD_2(x) ((x) << THRESHOLD_2_SHIFT)
167#define THRESHOLD_2_GET(x) (((x) & THRESHOLD_2_MASK) >> THRESHOLD_2_SHIFT)
168#define THRESHOLD_3_MASK 0x0000003fU
169#define THRESHOLD_3_SHIFT 0
170#define THRESHOLD_3(x) ((x) << THRESHOLD_3_SHIFT)
171#define THRESHOLD_3_GET(x) (((x) & THRESHOLD_3_MASK) >> THRESHOLD_3_SHIFT)
172
173#define SGE_TIMER_VALUE_0_AND_1 0x10b8
174#define TIMERVALUE0_MASK 0xffff0000U
175#define TIMERVALUE0_SHIFT 16
176#define TIMERVALUE0(x) ((x) << TIMERVALUE0_SHIFT)
177#define TIMERVALUE0_GET(x) (((x) & TIMERVALUE0_MASK) >> TIMERVALUE0_SHIFT)
178#define TIMERVALUE1_MASK 0x0000ffffU
179#define TIMERVALUE1_SHIFT 0
180#define TIMERVALUE1(x) ((x) << TIMERVALUE1_SHIFT)
181#define TIMERVALUE1_GET(x) (((x) & TIMERVALUE1_MASK) >> TIMERVALUE1_SHIFT)
182
183#define SGE_TIMER_VALUE_2_AND_3 0x10bc
184#define SGE_TIMER_VALUE_4_AND_5 0x10c0
185#define SGE_DEBUG_INDEX 0x10cc
186#define SGE_DEBUG_DATA_HIGH 0x10d0
187#define SGE_DEBUG_DATA_LOW 0x10d4
188#define SGE_INGRESS_QUEUES_PER_PAGE_PF 0x10f4
189
190#define PCIE_PF_CLI 0x44
191#define PCIE_INT_CAUSE 0x3004
192#define UNXSPLCPLERR 0x20000000U
193#define PCIEPINT 0x10000000U
194#define PCIESINT 0x08000000U
195#define RPLPERR 0x04000000U
196#define RXWRPERR 0x02000000U
197#define RXCPLPERR 0x01000000U
198#define PIOTAGPERR 0x00800000U
199#define MATAGPERR 0x00400000U
200#define INTXCLRPERR 0x00200000U
201#define FIDPERR 0x00100000U
202#define CFGSNPPERR 0x00080000U
203#define HRSPPERR 0x00040000U
204#define HREQPERR 0x00020000U
205#define HCNTPERR 0x00010000U
206#define DRSPPERR 0x00008000U
207#define DREQPERR 0x00004000U
208#define DCNTPERR 0x00002000U
209#define CRSPPERR 0x00001000U
210#define CREQPERR 0x00000800U
211#define CCNTPERR 0x00000400U
212#define TARTAGPERR 0x00000200U
213#define PIOREQPERR 0x00000100U
214#define PIOCPLPERR 0x00000080U
215#define MSIXDIPERR 0x00000040U
216#define MSIXDATAPERR 0x00000020U
217#define MSIXADDRHPERR 0x00000010U
218#define MSIXADDRLPERR 0x00000008U
219#define MSIDATAPERR 0x00000004U
220#define MSIADDRHPERR 0x00000002U
221#define MSIADDRLPERR 0x00000001U
222
223#define PCIE_NONFAT_ERR 0x3010
224#define PCIE_MEM_ACCESS_BASE_WIN 0x3068
225#define PCIEOFST_MASK 0xfffffc00U
226#define BIR_MASK 0x00000300U
227#define BIR_SHIFT 8
228#define BIR(x) ((x) << BIR_SHIFT)
229#define WINDOW_MASK 0x000000ffU
230#define WINDOW_SHIFT 0
231#define WINDOW(x) ((x) << WINDOW_SHIFT)
232
233#define PCIE_CORE_UTL_SYSTEM_BUS_AGENT_STATUS 0x5908
234#define RNPP 0x80000000U
235#define RPCP 0x20000000U
236#define RCIP 0x08000000U
237#define RCCP 0x04000000U
238#define RFTP 0x00800000U
239#define PTRP 0x00100000U
240
241#define PCIE_CORE_UTL_PCI_EXPRESS_PORT_STATUS 0x59a4
242#define TPCP 0x40000000U
243#define TNPP 0x20000000U
244#define TFTP 0x10000000U
245#define TCAP 0x08000000U
246#define TCIP 0x04000000U
247#define RCAP 0x02000000U
248#define PLUP 0x00800000U
249#define PLDN 0x00400000U
250#define OTDD 0x00200000U
251#define GTRP 0x00100000U
252#define RDPE 0x00040000U
253#define TDCE 0x00020000U
254#define TDUE 0x00010000U
255
256#define MC_INT_CAUSE 0x7518
257#define ECC_UE_INT_CAUSE 0x00000004U
258#define ECC_CE_INT_CAUSE 0x00000002U
259#define PERR_INT_CAUSE 0x00000001U
260
261#define MC_ECC_STATUS 0x751c
262#define ECC_CECNT_MASK 0xffff0000U
263#define ECC_CECNT_SHIFT 16
264#define ECC_CECNT(x) ((x) << ECC_CECNT_SHIFT)
265#define ECC_CECNT_GET(x) (((x) & ECC_CECNT_MASK) >> ECC_CECNT_SHIFT)
266#define ECC_UECNT_MASK 0x0000ffffU
267#define ECC_UECNT_SHIFT 0
268#define ECC_UECNT(x) ((x) << ECC_UECNT_SHIFT)
269#define ECC_UECNT_GET(x) (((x) & ECC_UECNT_MASK) >> ECC_UECNT_SHIFT)
270
271#define MC_BIST_CMD 0x7600
272#define START_BIST 0x80000000U
273#define BIST_CMD_GAP_MASK 0x0000ff00U
274#define BIST_CMD_GAP_SHIFT 8
275#define BIST_CMD_GAP(x) ((x) << BIST_CMD_GAP_SHIFT)
276#define BIST_OPCODE_MASK 0x00000003U
277#define BIST_OPCODE_SHIFT 0
278#define BIST_OPCODE(x) ((x) << BIST_OPCODE_SHIFT)
279
280#define MC_BIST_CMD_ADDR 0x7604
281#define MC_BIST_CMD_LEN 0x7608
282#define MC_BIST_DATA_PATTERN 0x760c
283#define BIST_DATA_TYPE_MASK 0x0000000fU
284#define BIST_DATA_TYPE_SHIFT 0
285#define BIST_DATA_TYPE(x) ((x) << BIST_DATA_TYPE_SHIFT)
286
287#define MC_BIST_STATUS_RDATA 0x7688
288
289#define MA_EXT_MEMORY_BAR 0x77c8
290#define EXT_MEM_SIZE_MASK 0x00000fffU
291#define EXT_MEM_SIZE_SHIFT 0
292#define EXT_MEM_SIZE_GET(x) (((x) & EXT_MEM_SIZE_MASK) >> EXT_MEM_SIZE_SHIFT)
293
294#define MA_TARGET_MEM_ENABLE 0x77d8
295#define EXT_MEM_ENABLE 0x00000004U
296#define EDRAM1_ENABLE 0x00000002U
297#define EDRAM0_ENABLE 0x00000001U
298
299#define MA_INT_CAUSE 0x77e0
300#define MEM_PERR_INT_CAUSE 0x00000002U
301#define MEM_WRAP_INT_CAUSE 0x00000001U
302
303#define MA_INT_WRAP_STATUS 0x77e4
304#define MEM_WRAP_ADDRESS_MASK 0xfffffff0U
305#define MEM_WRAP_ADDRESS_SHIFT 4
306#define MEM_WRAP_ADDRESS_GET(x) (((x) & MEM_WRAP_ADDRESS_MASK) >> MEM_WRAP_ADDRESS_SHIFT)
307#define MEM_WRAP_CLIENT_NUM_MASK 0x0000000fU
308#define MEM_WRAP_CLIENT_NUM_SHIFT 0
309#define MEM_WRAP_CLIENT_NUM_GET(x) (((x) & MEM_WRAP_CLIENT_NUM_MASK) >> MEM_WRAP_CLIENT_NUM_SHIFT)
310
311#define MA_PARITY_ERROR_STATUS 0x77f4
312
313#define EDC_0_BASE_ADDR 0x7900
314
315#define EDC_BIST_CMD 0x7904
316#define EDC_BIST_CMD_ADDR 0x7908
317#define EDC_BIST_CMD_LEN 0x790c
318#define EDC_BIST_DATA_PATTERN 0x7910
319#define EDC_BIST_STATUS_RDATA 0x7928
320#define EDC_INT_CAUSE 0x7978
321#define ECC_UE_PAR 0x00000020U
322#define ECC_CE_PAR 0x00000010U
323#define PERR_PAR_CAUSE 0x00000008U
324
325#define EDC_ECC_STATUS 0x797c
326
327#define EDC_1_BASE_ADDR 0x7980
328
329#define CIM_PF_MAILBOX_DATA 0x240
330#define CIM_PF_MAILBOX_CTRL 0x280
331#define MBMSGVALID 0x00000008U
332#define MBINTREQ 0x00000004U
333#define MBOWNER_MASK 0x00000003U
334#define MBOWNER_SHIFT 0
335#define MBOWNER(x) ((x) << MBOWNER_SHIFT)
336#define MBOWNER_GET(x) (((x) & MBOWNER_MASK) >> MBOWNER_SHIFT)
337
338#define CIM_PF_HOST_INT_CAUSE 0x28c
339#define MBMSGRDYINT 0x00080000U
340
341#define CIM_HOST_INT_CAUSE 0x7b2c
342#define TIEQOUTPARERRINT 0x00100000U
343#define TIEQINPARERRINT 0x00080000U
344#define MBHOSTPARERR 0x00040000U
345#define MBUPPARERR 0x00020000U
346#define IBQPARERR 0x0001f800U
347#define IBQTP0PARERR 0x00010000U
348#define IBQTP1PARERR 0x00008000U
349#define IBQULPPARERR 0x00004000U
350#define IBQSGELOPARERR 0x00002000U
351#define IBQSGEHIPARERR 0x00001000U
352#define IBQNCSIPARERR 0x00000800U
353#define OBQPARERR 0x000007e0U
354#define OBQULP0PARERR 0x00000400U
355#define OBQULP1PARERR 0x00000200U
356#define OBQULP2PARERR 0x00000100U
357#define OBQULP3PARERR 0x00000080U
358#define OBQSGEPARERR 0x00000040U
359#define OBQNCSIPARERR 0x00000020U
360#define PREFDROPINT 0x00000002U
361#define UPACCNONZERO 0x00000001U
362
363#define CIM_HOST_UPACC_INT_CAUSE 0x7b34
364#define EEPROMWRINT 0x40000000U
365#define TIMEOUTMAINT 0x20000000U
366#define TIMEOUTINT 0x10000000U
367#define RSPOVRLOOKUPINT 0x08000000U
368#define REQOVRLOOKUPINT 0x04000000U
369#define BLKWRPLINT 0x02000000U
370#define BLKRDPLINT 0x01000000U
371#define SGLWRPLINT 0x00800000U
372#define SGLRDPLINT 0x00400000U
373#define BLKWRCTLINT 0x00200000U
374#define BLKRDCTLINT 0x00100000U
375#define SGLWRCTLINT 0x00080000U
376#define SGLRDCTLINT 0x00040000U
377#define BLKWREEPROMINT 0x00020000U
378#define BLKRDEEPROMINT 0x00010000U
379#define SGLWREEPROMINT 0x00008000U
380#define SGLRDEEPROMINT 0x00004000U
381#define BLKWRFLASHINT 0x00002000U
382#define BLKRDFLASHINT 0x00001000U
383#define SGLWRFLASHINT 0x00000800U
384#define SGLRDFLASHINT 0x00000400U
385#define BLKWRBOOTINT 0x00000200U
386#define BLKRDBOOTINT 0x00000100U
387#define SGLWRBOOTINT 0x00000080U
388#define SGLRDBOOTINT 0x00000040U
389#define ILLWRBEINT 0x00000020U
390#define ILLRDBEINT 0x00000010U
391#define ILLRDINT 0x00000008U
392#define ILLWRINT 0x00000004U
393#define ILLTRANSINT 0x00000002U
394#define RSVDSPACEINT 0x00000001U
395
396#define TP_OUT_CONFIG 0x7d04
397#define VLANEXTENABLE_MASK 0x0000f000U
398#define VLANEXTENABLE_SHIFT 12
399
400#define TP_PARA_REG2 0x7d68
401#define MAXRXDATA_MASK 0xffff0000U
402#define MAXRXDATA_SHIFT 16
403#define MAXRXDATA_GET(x) (((x) & MAXRXDATA_MASK) >> MAXRXDATA_SHIFT)
404
405#define TP_TIMER_RESOLUTION 0x7d90
406#define TIMERRESOLUTION_MASK 0x00ff0000U
407#define TIMERRESOLUTION_SHIFT 16
408#define TIMERRESOLUTION_GET(x) (((x) & TIMERRESOLUTION_MASK) >> TIMERRESOLUTION_SHIFT)
409
410#define TP_SHIFT_CNT 0x7dc0
411
412#define TP_CCTRL_TABLE 0x7ddc
413#define TP_MTU_TABLE 0x7de4
414#define MTUINDEX_MASK 0xff000000U
415#define MTUINDEX_SHIFT 24
416#define MTUINDEX(x) ((x) << MTUINDEX_SHIFT)
417#define MTUWIDTH_MASK 0x000f0000U
418#define MTUWIDTH_SHIFT 16
419#define MTUWIDTH(x) ((x) << MTUWIDTH_SHIFT)
420#define MTUWIDTH_GET(x) (((x) & MTUWIDTH_MASK) >> MTUWIDTH_SHIFT)
421#define MTUVALUE_MASK 0x00003fffU
422#define MTUVALUE_SHIFT 0
423#define MTUVALUE(x) ((x) << MTUVALUE_SHIFT)
424#define MTUVALUE_GET(x) (((x) & MTUVALUE_MASK) >> MTUVALUE_SHIFT)
425
426#define TP_RSS_LKP_TABLE 0x7dec
427#define LKPTBLROWVLD 0x80000000U
428#define LKPTBLQUEUE1_MASK 0x000ffc00U
429#define LKPTBLQUEUE1_SHIFT 10
430#define LKPTBLQUEUE1(x) ((x) << LKPTBLQUEUE1_SHIFT)
431#define LKPTBLQUEUE1_GET(x) (((x) & LKPTBLQUEUE1_MASK) >> LKPTBLQUEUE1_SHIFT)
432#define LKPTBLQUEUE0_MASK 0x000003ffU
433#define LKPTBLQUEUE0_SHIFT 0
434#define LKPTBLQUEUE0(x) ((x) << LKPTBLQUEUE0_SHIFT)
435#define LKPTBLQUEUE0_GET(x) (((x) & LKPTBLQUEUE0_MASK) >> LKPTBLQUEUE0_SHIFT)
436
437#define TP_PIO_ADDR 0x7e40
438#define TP_PIO_DATA 0x7e44
439#define TP_MIB_INDEX 0x7e50
440#define TP_MIB_DATA 0x7e54
441#define TP_INT_CAUSE 0x7e74
442#define FLMTXFLSTEMPTY 0x40000000U
443
444#define TP_INGRESS_CONFIG 0x141
445#define VNIC 0x00000800U
446#define CSUM_HAS_PSEUDO_HDR 0x00000400U
447#define RM_OVLAN 0x00000200U
448#define LOOKUPEVERYPKT 0x00000100U
449
450#define TP_MIB_MAC_IN_ERR_0 0x0
451#define TP_MIB_TCP_OUT_RST 0xc
452#define TP_MIB_TCP_IN_SEG_HI 0x10
453#define TP_MIB_TCP_IN_SEG_LO 0x11
454#define TP_MIB_TCP_OUT_SEG_HI 0x12
455#define TP_MIB_TCP_OUT_SEG_LO 0x13
456#define TP_MIB_TCP_RXT_SEG_HI 0x14
457#define TP_MIB_TCP_RXT_SEG_LO 0x15
458#define TP_MIB_TNL_CNG_DROP_0 0x18
459#define TP_MIB_TCP_V6IN_ERR_0 0x28
460#define TP_MIB_TCP_V6OUT_RST 0x2c
461#define TP_MIB_OFD_ARP_DROP 0x36
462#define TP_MIB_TNL_DROP_0 0x44
463#define TP_MIB_OFD_VLN_DROP_0 0x58
464
465#define ULP_TX_INT_CAUSE 0x8dcc
466#define PBL_BOUND_ERR_CH3 0x80000000U
467#define PBL_BOUND_ERR_CH2 0x40000000U
468#define PBL_BOUND_ERR_CH1 0x20000000U
469#define PBL_BOUND_ERR_CH0 0x10000000U
470
471#define PM_RX_INT_CAUSE 0x8fdc
472#define ZERO_E_CMD_ERROR 0x00400000U
473#define PMRX_FRAMING_ERROR 0x003ffff0U
474#define OCSPI_PAR_ERROR 0x00000008U
475#define DB_OPTIONS_PAR_ERROR 0x00000004U
476#define IESPI_PAR_ERROR 0x00000002U
477#define E_PCMD_PAR_ERROR 0x00000001U
478
479#define PM_TX_INT_CAUSE 0x8ffc
480#define PCMD_LEN_OVFL0 0x80000000U
481#define PCMD_LEN_OVFL1 0x40000000U
482#define PCMD_LEN_OVFL2 0x20000000U
483#define ZERO_C_CMD_ERROR 0x10000000U
484#define PMTX_FRAMING_ERROR 0x0ffffff0U
485#define OESPI_PAR_ERROR 0x00000008U
486#define ICSPI_PAR_ERROR 0x00000002U
487#define C_PCMD_PAR_ERROR 0x00000001U
488
489#define MPS_PORT_STAT_TX_PORT_BYTES_L 0x400
490#define MPS_PORT_STAT_TX_PORT_BYTES_H 0x404
491#define MPS_PORT_STAT_TX_PORT_FRAMES_L 0x408
492#define MPS_PORT_STAT_TX_PORT_FRAMES_H 0x40c
493#define MPS_PORT_STAT_TX_PORT_BCAST_L 0x410
494#define MPS_PORT_STAT_TX_PORT_BCAST_H 0x414
495#define MPS_PORT_STAT_TX_PORT_MCAST_L 0x418
496#define MPS_PORT_STAT_TX_PORT_MCAST_H 0x41c
497#define MPS_PORT_STAT_TX_PORT_UCAST_L 0x420
498#define MPS_PORT_STAT_TX_PORT_UCAST_H 0x424
499#define MPS_PORT_STAT_TX_PORT_ERROR_L 0x428
500#define MPS_PORT_STAT_TX_PORT_ERROR_H 0x42c
501#define MPS_PORT_STAT_TX_PORT_64B_L 0x430
502#define MPS_PORT_STAT_TX_PORT_64B_H 0x434
503#define MPS_PORT_STAT_TX_PORT_65B_127B_L 0x438
504#define MPS_PORT_STAT_TX_PORT_65B_127B_H 0x43c
505#define MPS_PORT_STAT_TX_PORT_128B_255B_L 0x440
506#define MPS_PORT_STAT_TX_PORT_128B_255B_H 0x444
507#define MPS_PORT_STAT_TX_PORT_256B_511B_L 0x448
508#define MPS_PORT_STAT_TX_PORT_256B_511B_H 0x44c
509#define MPS_PORT_STAT_TX_PORT_512B_1023B_L 0x450
510#define MPS_PORT_STAT_TX_PORT_512B_1023B_H 0x454
511#define MPS_PORT_STAT_TX_PORT_1024B_1518B_L 0x458
512#define MPS_PORT_STAT_TX_PORT_1024B_1518B_H 0x45c
513#define MPS_PORT_STAT_TX_PORT_1519B_MAX_L 0x460
514#define MPS_PORT_STAT_TX_PORT_1519B_MAX_H 0x464
515#define MPS_PORT_STAT_TX_PORT_DROP_L 0x468
516#define MPS_PORT_STAT_TX_PORT_DROP_H 0x46c
517#define MPS_PORT_STAT_TX_PORT_PAUSE_L 0x470
518#define MPS_PORT_STAT_TX_PORT_PAUSE_H 0x474
519#define MPS_PORT_STAT_TX_PORT_PPP0_L 0x478
520#define MPS_PORT_STAT_TX_PORT_PPP0_H 0x47c
521#define MPS_PORT_STAT_TX_PORT_PPP1_L 0x480
522#define MPS_PORT_STAT_TX_PORT_PPP1_H 0x484
523#define MPS_PORT_STAT_TX_PORT_PPP2_L 0x488
524#define MPS_PORT_STAT_TX_PORT_PPP2_H 0x48c
525#define MPS_PORT_STAT_TX_PORT_PPP3_L 0x490
526#define MPS_PORT_STAT_TX_PORT_PPP3_H 0x494
527#define MPS_PORT_STAT_TX_PORT_PPP4_L 0x498
528#define MPS_PORT_STAT_TX_PORT_PPP4_H 0x49c
529#define MPS_PORT_STAT_TX_PORT_PPP5_L 0x4a0
530#define MPS_PORT_STAT_TX_PORT_PPP5_H 0x4a4
531#define MPS_PORT_STAT_TX_PORT_PPP6_L 0x4a8
532#define MPS_PORT_STAT_TX_PORT_PPP6_H 0x4ac
533#define MPS_PORT_STAT_TX_PORT_PPP7_L 0x4b0
534#define MPS_PORT_STAT_TX_PORT_PPP7_H 0x4b4
535#define MPS_PORT_STAT_LB_PORT_BYTES_L 0x4c0
536#define MPS_PORT_STAT_LB_PORT_BYTES_H 0x4c4
537#define MPS_PORT_STAT_LB_PORT_FRAMES_L 0x4c8
538#define MPS_PORT_STAT_LB_PORT_FRAMES_H 0x4cc
539#define MPS_PORT_STAT_LB_PORT_BCAST_L 0x4d0
540#define MPS_PORT_STAT_LB_PORT_BCAST_H 0x4d4
541#define MPS_PORT_STAT_LB_PORT_MCAST_L 0x4d8
542#define MPS_PORT_STAT_LB_PORT_MCAST_H 0x4dc
543#define MPS_PORT_STAT_LB_PORT_UCAST_L 0x4e0
544#define MPS_PORT_STAT_LB_PORT_UCAST_H 0x4e4
545#define MPS_PORT_STAT_LB_PORT_ERROR_L 0x4e8
546#define MPS_PORT_STAT_LB_PORT_ERROR_H 0x4ec
547#define MPS_PORT_STAT_LB_PORT_64B_L 0x4f0
548#define MPS_PORT_STAT_LB_PORT_64B_H 0x4f4
549#define MPS_PORT_STAT_LB_PORT_65B_127B_L 0x4f8
550#define MPS_PORT_STAT_LB_PORT_65B_127B_H 0x4fc
551#define MPS_PORT_STAT_LB_PORT_128B_255B_L 0x500
552#define MPS_PORT_STAT_LB_PORT_128B_255B_H 0x504
553#define MPS_PORT_STAT_LB_PORT_256B_511B_L 0x508
554#define MPS_PORT_STAT_LB_PORT_256B_511B_H 0x50c
555#define MPS_PORT_STAT_LB_PORT_512B_1023B_L 0x510
556#define MPS_PORT_STAT_LB_PORT_512B_1023B_H 0x514
557#define MPS_PORT_STAT_LB_PORT_1024B_1518B_L 0x518
558#define MPS_PORT_STAT_LB_PORT_1024B_1518B_H 0x51c
559#define MPS_PORT_STAT_LB_PORT_1519B_MAX_L 0x520
560#define MPS_PORT_STAT_LB_PORT_1519B_MAX_H 0x524
561#define MPS_PORT_STAT_LB_PORT_DROP_FRAMES 0x528
562#define MPS_PORT_STAT_RX_PORT_BYTES_L 0x540
563#define MPS_PORT_STAT_RX_PORT_BYTES_H 0x544
564#define MPS_PORT_STAT_RX_PORT_FRAMES_L 0x548
565#define MPS_PORT_STAT_RX_PORT_FRAMES_H 0x54c
566#define MPS_PORT_STAT_RX_PORT_BCAST_L 0x550
567#define MPS_PORT_STAT_RX_PORT_BCAST_H 0x554
568#define MPS_PORT_STAT_RX_PORT_MCAST_L 0x558
569#define MPS_PORT_STAT_RX_PORT_MCAST_H 0x55c
570#define MPS_PORT_STAT_RX_PORT_UCAST_L 0x560
571#define MPS_PORT_STAT_RX_PORT_UCAST_H 0x564
572#define MPS_PORT_STAT_RX_PORT_MTU_ERROR_L 0x568
573#define MPS_PORT_STAT_RX_PORT_MTU_ERROR_H 0x56c
574#define MPS_PORT_STAT_RX_PORT_MTU_CRC_ERROR_L 0x570
575#define MPS_PORT_STAT_RX_PORT_MTU_CRC_ERROR_H 0x574
576#define MPS_PORT_STAT_RX_PORT_CRC_ERROR_L 0x578
577#define MPS_PORT_STAT_RX_PORT_CRC_ERROR_H 0x57c
578#define MPS_PORT_STAT_RX_PORT_LEN_ERROR_L 0x580
579#define MPS_PORT_STAT_RX_PORT_LEN_ERROR_H 0x584
580#define MPS_PORT_STAT_RX_PORT_SYM_ERROR_L 0x588
581#define MPS_PORT_STAT_RX_PORT_SYM_ERROR_H 0x58c
582#define MPS_PORT_STAT_RX_PORT_64B_L 0x590
583#define MPS_PORT_STAT_RX_PORT_64B_H 0x594
584#define MPS_PORT_STAT_RX_PORT_65B_127B_L 0x598
585#define MPS_PORT_STAT_RX_PORT_65B_127B_H 0x59c
586#define MPS_PORT_STAT_RX_PORT_128B_255B_L 0x5a0
587#define MPS_PORT_STAT_RX_PORT_128B_255B_H 0x5a4
588#define MPS_PORT_STAT_RX_PORT_256B_511B_L 0x5a8
589#define MPS_PORT_STAT_RX_PORT_256B_511B_H 0x5ac
590#define MPS_PORT_STAT_RX_PORT_512B_1023B_L 0x5b0
591#define MPS_PORT_STAT_RX_PORT_512B_1023B_H 0x5b4
592#define MPS_PORT_STAT_RX_PORT_1024B_1518B_L 0x5b8
593#define MPS_PORT_STAT_RX_PORT_1024B_1518B_H 0x5bc
594#define MPS_PORT_STAT_RX_PORT_1519B_MAX_L 0x5c0
595#define MPS_PORT_STAT_RX_PORT_1519B_MAX_H 0x5c4
596#define MPS_PORT_STAT_RX_PORT_PAUSE_L 0x5c8
597#define MPS_PORT_STAT_RX_PORT_PAUSE_H 0x5cc
598#define MPS_PORT_STAT_RX_PORT_PPP0_L 0x5d0
599#define MPS_PORT_STAT_RX_PORT_PPP0_H 0x5d4
600#define MPS_PORT_STAT_RX_PORT_PPP1_L 0x5d8
601#define MPS_PORT_STAT_RX_PORT_PPP1_H 0x5dc
602#define MPS_PORT_STAT_RX_PORT_PPP2_L 0x5e0
603#define MPS_PORT_STAT_RX_PORT_PPP2_H 0x5e4
604#define MPS_PORT_STAT_RX_PORT_PPP3_L 0x5e8
605#define MPS_PORT_STAT_RX_PORT_PPP3_H 0x5ec
606#define MPS_PORT_STAT_RX_PORT_PPP4_L 0x5f0
607#define MPS_PORT_STAT_RX_PORT_PPP4_H 0x5f4
608#define MPS_PORT_STAT_RX_PORT_PPP5_L 0x5f8
609#define MPS_PORT_STAT_RX_PORT_PPP5_H 0x5fc
610#define MPS_PORT_STAT_RX_PORT_PPP6_L 0x600
611#define MPS_PORT_STAT_RX_PORT_PPP6_H 0x604
612#define MPS_PORT_STAT_RX_PORT_PPP7_L 0x608
613#define MPS_PORT_STAT_RX_PORT_PPP7_H 0x60c
614#define MPS_PORT_STAT_RX_PORT_LESS_64B_L 0x610
615#define MPS_PORT_STAT_RX_PORT_LESS_64B_H 0x614
616#define MPS_CMN_CTL 0x9000
617#define NUMPORTS_MASK 0x00000003U
618#define NUMPORTS_SHIFT 0
619#define NUMPORTS_GET(x) (((x) & NUMPORTS_MASK) >> NUMPORTS_SHIFT)
620
621#define MPS_INT_CAUSE 0x9008
622#define STATINT 0x00000020U
623#define TXINT 0x00000010U
624#define RXINT 0x00000008U
625#define TRCINT 0x00000004U
626#define CLSINT 0x00000002U
627#define PLINT 0x00000001U
628
629#define MPS_TX_INT_CAUSE 0x9408
630#define PORTERR 0x00010000U
631#define FRMERR 0x00008000U
632#define SECNTERR 0x00004000U
633#define BUBBLE 0x00002000U
634#define TXDESCFIFO 0x00001e00U
635#define TXDATAFIFO 0x000001e0U
636#define NCSIFIFO 0x00000010U
637#define TPFIFO 0x0000000fU
638
639#define MPS_STAT_PERR_INT_CAUSE_SRAM 0x9614
640#define MPS_STAT_PERR_INT_CAUSE_TX_FIFO 0x9620
641#define MPS_STAT_PERR_INT_CAUSE_RX_FIFO 0x962c
642
643#define MPS_STAT_RX_BG_0_MAC_DROP_FRAME_L 0x9640
644#define MPS_STAT_RX_BG_0_MAC_DROP_FRAME_H 0x9644
645#define MPS_STAT_RX_BG_1_MAC_DROP_FRAME_L 0x9648
646#define MPS_STAT_RX_BG_1_MAC_DROP_FRAME_H 0x964c
647#define MPS_STAT_RX_BG_2_MAC_DROP_FRAME_L 0x9650
648#define MPS_STAT_RX_BG_2_MAC_DROP_FRAME_H 0x9654
649#define MPS_STAT_RX_BG_3_MAC_DROP_FRAME_L 0x9658
650#define MPS_STAT_RX_BG_3_MAC_DROP_FRAME_H 0x965c
651#define MPS_STAT_RX_BG_0_LB_DROP_FRAME_L 0x9660
652#define MPS_STAT_RX_BG_0_LB_DROP_FRAME_H 0x9664
653#define MPS_STAT_RX_BG_1_LB_DROP_FRAME_L 0x9668
654#define MPS_STAT_RX_BG_1_LB_DROP_FRAME_H 0x966c
655#define MPS_STAT_RX_BG_2_LB_DROP_FRAME_L 0x9670
656#define MPS_STAT_RX_BG_2_LB_DROP_FRAME_H 0x9674
657#define MPS_STAT_RX_BG_3_LB_DROP_FRAME_L 0x9678
658#define MPS_STAT_RX_BG_3_LB_DROP_FRAME_H 0x967c
659#define MPS_STAT_RX_BG_0_MAC_TRUNC_FRAME_L 0x9680
660#define MPS_STAT_RX_BG_0_MAC_TRUNC_FRAME_H 0x9684
661#define MPS_STAT_RX_BG_1_MAC_TRUNC_FRAME_L 0x9688
662#define MPS_STAT_RX_BG_1_MAC_TRUNC_FRAME_H 0x968c
663#define MPS_STAT_RX_BG_2_MAC_TRUNC_FRAME_L 0x9690
664#define MPS_STAT_RX_BG_2_MAC_TRUNC_FRAME_H 0x9694
665#define MPS_STAT_RX_BG_3_MAC_TRUNC_FRAME_L 0x9698
666#define MPS_STAT_RX_BG_3_MAC_TRUNC_FRAME_H 0x969c
667#define MPS_STAT_RX_BG_0_LB_TRUNC_FRAME_L 0x96a0
668#define MPS_STAT_RX_BG_0_LB_TRUNC_FRAME_H 0x96a4
669#define MPS_STAT_RX_BG_1_LB_TRUNC_FRAME_L 0x96a8
670#define MPS_STAT_RX_BG_1_LB_TRUNC_FRAME_H 0x96ac
671#define MPS_STAT_RX_BG_2_LB_TRUNC_FRAME_L 0x96b0
672#define MPS_STAT_RX_BG_2_LB_TRUNC_FRAME_H 0x96b4
673#define MPS_STAT_RX_BG_3_LB_TRUNC_FRAME_L 0x96b8
674#define MPS_STAT_RX_BG_3_LB_TRUNC_FRAME_H 0x96bc
675#define MPS_TRC_CFG 0x9800
676#define TRCFIFOEMPTY 0x00000010U
677#define TRCIGNOREDROPINPUT 0x00000008U
678#define TRCKEEPDUPLICATES 0x00000004U
679#define TRCEN 0x00000002U
680#define TRCMULTIFILTER 0x00000001U
681
682#define MPS_TRC_RSS_CONTROL 0x9808
683#define RSSCONTROL_MASK 0x00ff0000U
684#define RSSCONTROL_SHIFT 16
685#define RSSCONTROL(x) ((x) << RSSCONTROL_SHIFT)
686#define QUEUENUMBER_MASK 0x0000ffffU
687#define QUEUENUMBER_SHIFT 0
688#define QUEUENUMBER(x) ((x) << QUEUENUMBER_SHIFT)
689
690#define MPS_TRC_FILTER_MATCH_CTL_A 0x9810
691#define TFINVERTMATCH 0x01000000U
692#define TFPKTTOOLARGE 0x00800000U
693#define TFEN 0x00400000U
694#define TFPORT_MASK 0x003c0000U
695#define TFPORT_SHIFT 18
696#define TFPORT(x) ((x) << TFPORT_SHIFT)
697#define TFPORT_GET(x) (((x) & TFPORT_MASK) >> TFPORT_SHIFT)
698#define TFDROP 0x00020000U
699#define TFSOPEOPERR 0x00010000U
700#define TFLENGTH_MASK 0x00001f00U
701#define TFLENGTH_SHIFT 8
702#define TFLENGTH(x) ((x) << TFLENGTH_SHIFT)
703#define TFLENGTH_GET(x) (((x) & TFLENGTH_MASK) >> TFLENGTH_SHIFT)
704#define TFOFFSET_MASK 0x0000001fU
705#define TFOFFSET_SHIFT 0
706#define TFOFFSET(x) ((x) << TFOFFSET_SHIFT)
707#define TFOFFSET_GET(x) (((x) & TFOFFSET_MASK) >> TFOFFSET_SHIFT)
708
709#define MPS_TRC_FILTER_MATCH_CTL_B 0x9820
710#define TFMINPKTSIZE_MASK 0x01ff0000U
711#define TFMINPKTSIZE_SHIFT 16
712#define TFMINPKTSIZE(x) ((x) << TFMINPKTSIZE_SHIFT)
713#define TFMINPKTSIZE_GET(x) (((x) & TFMINPKTSIZE_MASK) >> TFMINPKTSIZE_SHIFT)
714#define TFCAPTUREMAX_MASK 0x00003fffU
715#define TFCAPTUREMAX_SHIFT 0
716#define TFCAPTUREMAX(x) ((x) << TFCAPTUREMAX_SHIFT)
717#define TFCAPTUREMAX_GET(x) (((x) & TFCAPTUREMAX_MASK) >> TFCAPTUREMAX_SHIFT)
718
719#define MPS_TRC_INT_CAUSE 0x985c
720#define MISCPERR 0x00000100U
721#define PKTFIFO 0x000000f0U
722#define FILTMEM 0x0000000fU
723
724#define MPS_TRC_FILTER0_MATCH 0x9c00
725#define MPS_TRC_FILTER0_DONT_CARE 0x9c80
726#define MPS_TRC_FILTER1_MATCH 0x9d00
727#define MPS_CLS_INT_CAUSE 0xd028
728#define PLERRENB 0x00000008U
729#define HASHSRAM 0x00000004U
730#define MATCHTCAM 0x00000002U
731#define MATCHSRAM 0x00000001U
732
733#define MPS_RX_PERR_INT_CAUSE 0x11074
734
735#define CPL_INTR_CAUSE 0x19054
736#define CIM_OP_MAP_PERR 0x00000020U
737#define CIM_OVFL_ERROR 0x00000010U
738#define TP_FRAMING_ERROR 0x00000008U
739#define SGE_FRAMING_ERROR 0x00000004U
740#define CIM_FRAMING_ERROR 0x00000002U
741#define ZERO_SWITCH_ERROR 0x00000001U
742
743#define SMB_INT_CAUSE 0x19090
744#define MSTTXFIFOPARINT 0x00200000U
745#define MSTRXFIFOPARINT 0x00100000U
746#define SLVFIFOPARINT 0x00080000U
747
748#define ULP_RX_INT_CAUSE 0x19158
749#define ULP_RX_ISCSI_TAGMASK 0x19164
750#define ULP_RX_ISCSI_PSZ 0x19168
751#define HPZ3_MASK 0x0f000000U
752#define HPZ3_SHIFT 24
753#define HPZ3(x) ((x) << HPZ3_SHIFT)
754#define HPZ2_MASK 0x000f0000U
755#define HPZ2_SHIFT 16
756#define HPZ2(x) ((x) << HPZ2_SHIFT)
757#define HPZ1_MASK 0x00000f00U
758#define HPZ1_SHIFT 8
759#define HPZ1(x) ((x) << HPZ1_SHIFT)
760#define HPZ0_MASK 0x0000000fU
761#define HPZ0_SHIFT 0
762#define HPZ0(x) ((x) << HPZ0_SHIFT)
763
764#define ULP_RX_TDDP_PSZ 0x19178
765
766#define SF_DATA 0x193f8
767#define SF_OP 0x193fc
768#define BUSY 0x80000000U
769#define SF_LOCK 0x00000010U
770#define SF_CONT 0x00000008U
771#define BYTECNT_MASK 0x00000006U
772#define BYTECNT_SHIFT 1
773#define BYTECNT(x) ((x) << BYTECNT_SHIFT)
774#define OP_WR 0x00000001U
775
776#define PL_PF_INT_CAUSE 0x3c0
777#define PFSW 0x00000008U
778#define PFSGE 0x00000004U
779#define PFCIM 0x00000002U
780#define PFMPS 0x00000001U
781
782#define PL_PF_INT_ENABLE 0x3c4
783#define PL_PF_CTL 0x3c8
784#define SWINT 0x00000001U
785
786#define PL_WHOAMI 0x19400
787#define SOURCEPF_MASK 0x00000700U
788#define SOURCEPF_SHIFT 8
789#define SOURCEPF(x) ((x) << SOURCEPF_SHIFT)
790#define SOURCEPF_GET(x) (((x) & SOURCEPF_MASK) >> SOURCEPF_SHIFT)
791#define ISVF 0x00000080U
792#define VFID_MASK 0x0000007fU
793#define VFID_SHIFT 0
794#define VFID(x) ((x) << VFID_SHIFT)
795#define VFID_GET(x) (((x) & VFID_MASK) >> VFID_SHIFT)
796
797#define PL_INT_CAUSE 0x1940c
798#define ULP_TX 0x08000000U
799#define SGE 0x04000000U
800#define HMA 0x02000000U
801#define CPL_SWITCH 0x01000000U
802#define ULP_RX 0x00800000U
803#define PM_RX 0x00400000U
804#define PM_TX 0x00200000U
805#define MA 0x00100000U
806#define TP 0x00080000U
807#define LE 0x00040000U
808#define EDC1 0x00020000U
809#define EDC0 0x00010000U
810#define MC 0x00008000U
811#define PCIE 0x00004000U
812#define PMU 0x00002000U
813#define XGMAC_KR1 0x00001000U
814#define XGMAC_KR0 0x00000800U
815#define XGMAC1 0x00000400U
816#define XGMAC0 0x00000200U
817#define SMB 0x00000100U
818#define SF 0x00000080U
819#define PL 0x00000040U
820#define NCSI 0x00000020U
821#define MPS 0x00000010U
822#define MI 0x00000008U
823#define DBG 0x00000004U
824#define I2CM 0x00000002U
825#define CIM 0x00000001U
826
827#define PL_INT_MAP0 0x19414
828#define PL_RST 0x19428
829#define PIORST 0x00000002U
830#define PIORSTMODE 0x00000001U
831
832#define PL_PL_INT_CAUSE 0x19430
833#define FATALPERR 0x00000010U
834#define PERRVFID 0x00000001U
835
836#define PL_REV 0x1943c
837
838#define LE_DB_CONFIG 0x19c04
839#define HASHEN 0x00100000U
840
841#define LE_DB_SERVER_INDEX 0x19c18
842#define LE_DB_ACT_CNT_IPV4 0x19c20
843#define LE_DB_ACT_CNT_IPV6 0x19c24
844
845#define LE_DB_INT_CAUSE 0x19c3c
846#define REQQPARERR 0x00010000U
847#define UNKNOWNCMD 0x00008000U
848#define PARITYERR 0x00000040U
849#define LIPMISS 0x00000020U
850#define LIP0 0x00000010U
851
852#define LE_DB_TID_HASHBASE 0x19df8
853
854#define NCSI_INT_CAUSE 0x1a0d8
855#define CIM_DM_PRTY_ERR 0x00000100U
856#define MPS_DM_PRTY_ERR 0x00000080U
857#define TXFIFO_PRTY_ERR 0x00000002U
858#define RXFIFO_PRTY_ERR 0x00000001U
859
860#define XGMAC_PORT_CFG2 0x1018
861#define PATEN 0x00040000U
862#define MAGICEN 0x00020000U
863
864#define XGMAC_PORT_MAGIC_MACID_LO 0x1024
865#define XGMAC_PORT_MAGIC_MACID_HI 0x1028
866
867#define XGMAC_PORT_EPIO_DATA0 0x10c0
868#define XGMAC_PORT_EPIO_DATA1 0x10c4
869#define XGMAC_PORT_EPIO_DATA2 0x10c8
870#define XGMAC_PORT_EPIO_DATA3 0x10cc
871#define XGMAC_PORT_EPIO_OP 0x10d0
872#define EPIOWR 0x00000100U
873#define ADDRESS_MASK 0x000000ffU
874#define ADDRESS_SHIFT 0
875#define ADDRESS(x) ((x) << ADDRESS_SHIFT)
876
877#define XGMAC_PORT_INT_CAUSE 0x10dc
878#endif /* __T4_REGS_H */
diff --git a/drivers/net/cxgb4/t4fw_api.h b/drivers/net/cxgb4/t4fw_api.h
new file mode 100644
index 00000000000..3393d05a388
--- /dev/null
+++ b/drivers/net/cxgb4/t4fw_api.h
@@ -0,0 +1,1580 @@
1/*
2 * This file is part of the Chelsio T4 Ethernet driver for Linux.
3 *
4 * Copyright (c) 2009-2010 Chelsio Communications, Inc. All rights reserved.
5 *
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
11 *
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
14 * conditions are met:
15 *
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer.
19 *
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
24 *
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE.
33 */
34
35#ifndef _T4FW_INTERFACE_H_
36#define _T4FW_INTERFACE_H_
37
38#define FW_T4VF_SGE_BASE_ADDR 0x0000
39#define FW_T4VF_MPS_BASE_ADDR 0x0100
40#define FW_T4VF_PL_BASE_ADDR 0x0200
41#define FW_T4VF_MBDATA_BASE_ADDR 0x0240
42#define FW_T4VF_CIM_BASE_ADDR 0x0300
43
44enum fw_wr_opcodes {
45 FW_FILTER_WR = 0x02,
46 FW_ULPTX_WR = 0x04,
47 FW_TP_WR = 0x05,
48 FW_ETH_TX_PKT_WR = 0x08,
49 FW_FLOWC_WR = 0x0a,
50 FW_OFLD_TX_DATA_WR = 0x0b,
51 FW_CMD_WR = 0x10,
52 FW_ETH_TX_PKT_VM_WR = 0x11,
53 FW_RI_RES_WR = 0x0c,
54 FW_RI_INIT_WR = 0x0d,
55 FW_RI_RDMA_WRITE_WR = 0x14,
56 FW_RI_SEND_WR = 0x15,
57 FW_RI_RDMA_READ_WR = 0x16,
58 FW_RI_RECV_WR = 0x17,
59 FW_RI_BIND_MW_WR = 0x18,
60 FW_RI_FR_NSMR_WR = 0x19,
61 FW_RI_INV_LSTAG_WR = 0x1a,
62 FW_LASTC2E_WR = 0x40
63};
64
65struct fw_wr_hdr {
66 __be32 hi;
67 __be32 lo;
68};
69
70#define FW_WR_OP(x) ((x) << 24)
71#define FW_WR_ATOMIC(x) ((x) << 23)
72#define FW_WR_FLUSH(x) ((x) << 22)
73#define FW_WR_COMPL(x) ((x) << 21)
74#define FW_WR_IMMDLEN(x) ((x) << 0)
75
76#define FW_WR_EQUIQ (1U << 31)
77#define FW_WR_EQUEQ (1U << 30)
78#define FW_WR_FLOWID(x) ((x) << 8)
79#define FW_WR_LEN16(x) ((x) << 0)
80
81struct fw_ulptx_wr {
82 __be32 op_to_compl;
83 __be32 flowid_len16;
84 u64 cookie;
85};
86
87struct fw_tp_wr {
88 __be32 op_to_immdlen;
89 __be32 flowid_len16;
90 u64 cookie;
91};
92
93struct fw_eth_tx_pkt_wr {
94 __be32 op_immdlen;
95 __be32 equiq_to_len16;
96 __be64 r3;
97};
98
99enum fw_flowc_mnem {
100 FW_FLOWC_MNEM_PFNVFN, /* PFN [15:8] VFN [7:0] */
101 FW_FLOWC_MNEM_CH,
102 FW_FLOWC_MNEM_PORT,
103 FW_FLOWC_MNEM_IQID,
104 FW_FLOWC_MNEM_SNDNXT,
105 FW_FLOWC_MNEM_RCVNXT,
106 FW_FLOWC_MNEM_SNDBUF,
107 FW_FLOWC_MNEM_MSS,
108};
109
110struct fw_flowc_mnemval {
111 u8 mnemonic;
112 u8 r4[3];
113 __be32 val;
114};
115
116struct fw_flowc_wr {
117 __be32 op_to_nparams;
118#define FW_FLOWC_WR_NPARAMS(x) ((x) << 0)
119 __be32 flowid_len16;
120 struct fw_flowc_mnemval mnemval[0];
121};
122
123struct fw_ofld_tx_data_wr {
124 __be32 op_to_immdlen;
125 __be32 flowid_len16;
126 __be32 plen;
127 __be32 tunnel_to_proxy;
128#define FW_OFLD_TX_DATA_WR_TUNNEL(x) ((x) << 19)
129#define FW_OFLD_TX_DATA_WR_SAVE(x) ((x) << 18)
130#define FW_OFLD_TX_DATA_WR_FLUSH(x) ((x) << 17)
131#define FW_OFLD_TX_DATA_WR_URGENT(x) ((x) << 16)
132#define FW_OFLD_TX_DATA_WR_MORE(x) ((x) << 15)
133#define FW_OFLD_TX_DATA_WR_SHOVE(x) ((x) << 14)
134#define FW_OFLD_TX_DATA_WR_ULPMODE(x) ((x) << 10)
135#define FW_OFLD_TX_DATA_WR_ULPSUBMODE(x) ((x) << 6)
136};
137
138struct fw_cmd_wr {
139 __be32 op_dma;
140#define FW_CMD_WR_DMA (1U << 17)
141 __be32 len16_pkd;
142 __be64 cookie_daddr;
143};
144
145struct fw_eth_tx_pkt_vm_wr {
146 __be32 op_immdlen;
147 __be32 equiq_to_len16;
148 __be32 r3[2];
149 u8 ethmacdst[6];
150 u8 ethmacsrc[6];
151 __be16 ethtype;
152 __be16 vlantci;
153};
154
155#define FW_CMD_MAX_TIMEOUT 3000
156
157enum fw_cmd_opcodes {
158 FW_LDST_CMD = 0x01,
159 FW_RESET_CMD = 0x03,
160 FW_HELLO_CMD = 0x04,
161 FW_BYE_CMD = 0x05,
162 FW_INITIALIZE_CMD = 0x06,
163 FW_CAPS_CONFIG_CMD = 0x07,
164 FW_PARAMS_CMD = 0x08,
165 FW_PFVF_CMD = 0x09,
166 FW_IQ_CMD = 0x10,
167 FW_EQ_MNGT_CMD = 0x11,
168 FW_EQ_ETH_CMD = 0x12,
169 FW_EQ_CTRL_CMD = 0x13,
170 FW_EQ_OFLD_CMD = 0x21,
171 FW_VI_CMD = 0x14,
172 FW_VI_MAC_CMD = 0x15,
173 FW_VI_RXMODE_CMD = 0x16,
174 FW_VI_ENABLE_CMD = 0x17,
175 FW_ACL_MAC_CMD = 0x18,
176 FW_ACL_VLAN_CMD = 0x19,
177 FW_VI_STATS_CMD = 0x1a,
178 FW_PORT_CMD = 0x1b,
179 FW_PORT_STATS_CMD = 0x1c,
180 FW_PORT_LB_STATS_CMD = 0x1d,
181 FW_PORT_TRACE_CMD = 0x1e,
182 FW_PORT_TRACE_MMAP_CMD = 0x1f,
183 FW_RSS_IND_TBL_CMD = 0x20,
184 FW_RSS_GLB_CONFIG_CMD = 0x22,
185 FW_RSS_VI_CONFIG_CMD = 0x23,
186 FW_LASTC2E_CMD = 0x40,
187 FW_ERROR_CMD = 0x80,
188 FW_DEBUG_CMD = 0x81,
189};
190
191enum fw_cmd_cap {
192 FW_CMD_CAP_PF = 0x01,
193 FW_CMD_CAP_DMAQ = 0x02,
194 FW_CMD_CAP_PORT = 0x04,
195 FW_CMD_CAP_PORTPROMISC = 0x08,
196 FW_CMD_CAP_PORTSTATS = 0x10,
197 FW_CMD_CAP_VF = 0x80,
198};
199
200/*
201 * Generic command header flit0
202 */
203struct fw_cmd_hdr {
204 __be32 hi;
205 __be32 lo;
206};
207
208#define FW_CMD_OP(x) ((x) << 24)
209#define FW_CMD_OP_GET(x) (((x) >> 24) & 0xff)
210#define FW_CMD_REQUEST (1U << 23)
211#define FW_CMD_READ (1U << 22)
212#define FW_CMD_WRITE (1U << 21)
213#define FW_CMD_EXEC (1U << 20)
214#define FW_CMD_RAMASK(x) ((x) << 20)
215#define FW_CMD_RETVAL(x) ((x) << 8)
216#define FW_CMD_RETVAL_GET(x) (((x) >> 8) & 0xff)
217#define FW_CMD_LEN16(x) ((x) << 0)
218
219enum fw_ldst_addrspc {
220 FW_LDST_ADDRSPC_FIRMWARE = 0x0001,
221 FW_LDST_ADDRSPC_SGE_EGRC = 0x0008,
222 FW_LDST_ADDRSPC_SGE_INGC = 0x0009,
223 FW_LDST_ADDRSPC_SGE_FLMC = 0x000a,
224 FW_LDST_ADDRSPC_SGE_CONMC = 0x000b,
225 FW_LDST_ADDRSPC_TP_PIO = 0x0010,
226 FW_LDST_ADDRSPC_TP_TM_PIO = 0x0011,
227 FW_LDST_ADDRSPC_TP_MIB = 0x0012,
228 FW_LDST_ADDRSPC_MDIO = 0x0018,
229 FW_LDST_ADDRSPC_MPS = 0x0020,
230 FW_LDST_ADDRSPC_FUNC = 0x0028
231};
232
233enum fw_ldst_mps_fid {
234 FW_LDST_MPS_ATRB,
235 FW_LDST_MPS_RPLC
236};
237
238enum fw_ldst_func_access_ctl {
239 FW_LDST_FUNC_ACC_CTL_VIID,
240 FW_LDST_FUNC_ACC_CTL_FID
241};
242
243enum fw_ldst_func_mod_index {
244 FW_LDST_FUNC_MPS
245};
246
247struct fw_ldst_cmd {
248 __be32 op_to_addrspace;
249#define FW_LDST_CMD_ADDRSPACE(x) ((x) << 0)
250 __be32 cycles_to_len16;
251 union fw_ldst {
252 struct fw_ldst_addrval {
253 __be32 addr;
254 __be32 val;
255 } addrval;
256 struct fw_ldst_idctxt {
257 __be32 physid;
258 __be32 msg_pkd;
259 __be32 ctxt_data7;
260 __be32 ctxt_data6;
261 __be32 ctxt_data5;
262 __be32 ctxt_data4;
263 __be32 ctxt_data3;
264 __be32 ctxt_data2;
265 __be32 ctxt_data1;
266 __be32 ctxt_data0;
267 } idctxt;
268 struct fw_ldst_mdio {
269 __be16 paddr_mmd;
270 __be16 raddr;
271 __be16 vctl;
272 __be16 rval;
273 } mdio;
274 struct fw_ldst_mps {
275 __be16 fid_ctl;
276 __be16 rplcpf_pkd;
277 __be32 rplc127_96;
278 __be32 rplc95_64;
279 __be32 rplc63_32;
280 __be32 rplc31_0;
281 __be32 atrb;
282 __be16 vlan[16];
283 } mps;
284 struct fw_ldst_func {
285 u8 access_ctl;
286 u8 mod_index;
287 __be16 ctl_id;
288 __be32 offset;
289 __be64 data0;
290 __be64 data1;
291 } func;
292 } u;
293};
294
295#define FW_LDST_CMD_MSG(x) ((x) << 31)
296#define FW_LDST_CMD_PADDR(x) ((x) << 8)
297#define FW_LDST_CMD_MMD(x) ((x) << 0)
298#define FW_LDST_CMD_FID(x) ((x) << 15)
299#define FW_LDST_CMD_CTL(x) ((x) << 0)
300#define FW_LDST_CMD_RPLCPF(x) ((x) << 0)
301
302struct fw_reset_cmd {
303 __be32 op_to_write;
304 __be32 retval_len16;
305 __be32 val;
306 __be32 r3;
307};
308
309struct fw_hello_cmd {
310 __be32 op_to_write;
311 __be32 retval_len16;
312 __be32 err_to_mbasyncnot;
313#define FW_HELLO_CMD_ERR (1U << 31)
314#define FW_HELLO_CMD_INIT (1U << 30)
315#define FW_HELLO_CMD_MASTERDIS(x) ((x) << 29)
316#define FW_HELLO_CMD_MASTERFORCE(x) ((x) << 28)
317#define FW_HELLO_CMD_MBMASTER(x) ((x) << 24)
318#define FW_HELLO_CMD_MBASYNCNOT(x) ((x) << 20)
319 __be32 fwrev;
320};
321
322struct fw_bye_cmd {
323 __be32 op_to_write;
324 __be32 retval_len16;
325 __be64 r3;
326};
327
328struct fw_initialize_cmd {
329 __be32 op_to_write;
330 __be32 retval_len16;
331 __be64 r3;
332};
333
334enum fw_caps_config_hm {
335 FW_CAPS_CONFIG_HM_PCIE = 0x00000001,
336 FW_CAPS_CONFIG_HM_PL = 0x00000002,
337 FW_CAPS_CONFIG_HM_SGE = 0x00000004,
338 FW_CAPS_CONFIG_HM_CIM = 0x00000008,
339 FW_CAPS_CONFIG_HM_ULPTX = 0x00000010,
340 FW_CAPS_CONFIG_HM_TP = 0x00000020,
341 FW_CAPS_CONFIG_HM_ULPRX = 0x00000040,
342 FW_CAPS_CONFIG_HM_PMRX = 0x00000080,
343 FW_CAPS_CONFIG_HM_PMTX = 0x00000100,
344 FW_CAPS_CONFIG_HM_MC = 0x00000200,
345 FW_CAPS_CONFIG_HM_LE = 0x00000400,
346 FW_CAPS_CONFIG_HM_MPS = 0x00000800,
347 FW_CAPS_CONFIG_HM_XGMAC = 0x00001000,
348 FW_CAPS_CONFIG_HM_CPLSWITCH = 0x00002000,
349 FW_CAPS_CONFIG_HM_T4DBG = 0x00004000,
350 FW_CAPS_CONFIG_HM_MI = 0x00008000,
351 FW_CAPS_CONFIG_HM_I2CM = 0x00010000,
352 FW_CAPS_CONFIG_HM_NCSI = 0x00020000,
353 FW_CAPS_CONFIG_HM_SMB = 0x00040000,
354 FW_CAPS_CONFIG_HM_MA = 0x00080000,
355 FW_CAPS_CONFIG_HM_EDRAM = 0x00100000,
356 FW_CAPS_CONFIG_HM_PMU = 0x00200000,
357 FW_CAPS_CONFIG_HM_UART = 0x00400000,
358 FW_CAPS_CONFIG_HM_SF = 0x00800000,
359};
360
361enum fw_caps_config_nbm {
362 FW_CAPS_CONFIG_NBM_IPMI = 0x00000001,
363 FW_CAPS_CONFIG_NBM_NCSI = 0x00000002,
364};
365
366enum fw_caps_config_link {
367 FW_CAPS_CONFIG_LINK_PPP = 0x00000001,
368 FW_CAPS_CONFIG_LINK_QFC = 0x00000002,
369 FW_CAPS_CONFIG_LINK_DCBX = 0x00000004,
370};
371
372enum fw_caps_config_switch {
373 FW_CAPS_CONFIG_SWITCH_INGRESS = 0x00000001,
374 FW_CAPS_CONFIG_SWITCH_EGRESS = 0x00000002,
375};
376
377enum fw_caps_config_nic {
378 FW_CAPS_CONFIG_NIC = 0x00000001,
379 FW_CAPS_CONFIG_NIC_VM = 0x00000002,
380};
381
382enum fw_caps_config_ofld {
383 FW_CAPS_CONFIG_OFLD = 0x00000001,
384};
385
386enum fw_caps_config_rdma {
387 FW_CAPS_CONFIG_RDMA_RDDP = 0x00000001,
388 FW_CAPS_CONFIG_RDMA_RDMAC = 0x00000002,
389};
390
391enum fw_caps_config_iscsi {
392 FW_CAPS_CONFIG_ISCSI_INITIATOR_PDU = 0x00000001,
393 FW_CAPS_CONFIG_ISCSI_TARGET_PDU = 0x00000002,
394 FW_CAPS_CONFIG_ISCSI_INITIATOR_CNXOFLD = 0x00000004,
395 FW_CAPS_CONFIG_ISCSI_TARGET_CNXOFLD = 0x00000008,
396};
397
398enum fw_caps_config_fcoe {
399 FW_CAPS_CONFIG_FCOE_INITIATOR = 0x00000001,
400 FW_CAPS_CONFIG_FCOE_TARGET = 0x00000002,
401};
402
403struct fw_caps_config_cmd {
404 __be32 op_to_write;
405 __be32 retval_len16;
406 __be32 r2;
407 __be32 hwmbitmap;
408 __be16 nbmcaps;
409 __be16 linkcaps;
410 __be16 switchcaps;
411 __be16 r3;
412 __be16 niccaps;
413 __be16 ofldcaps;
414 __be16 rdmacaps;
415 __be16 r4;
416 __be16 iscsicaps;
417 __be16 fcoecaps;
418 __be32 r5;
419 __be64 r6;
420};
421
422/*
423 * params command mnemonics
424 */
425enum fw_params_mnem {
426 FW_PARAMS_MNEM_DEV = 1, /* device params */
427 FW_PARAMS_MNEM_PFVF = 2, /* function params */
428 FW_PARAMS_MNEM_REG = 3, /* limited register access */
429 FW_PARAMS_MNEM_DMAQ = 4, /* dma queue params */
430 FW_PARAMS_MNEM_LAST
431};
432
433/*
434 * device parameters
435 */
436enum fw_params_param_dev {
437 FW_PARAMS_PARAM_DEV_CCLK = 0x00, /* chip core clock in khz */
438 FW_PARAMS_PARAM_DEV_PORTVEC = 0x01, /* the port vector */
439 FW_PARAMS_PARAM_DEV_NTID = 0x02, /* reads the number of TIDs
440 * allocated by the device's
441 * Lookup Engine
442 */
443 FW_PARAMS_PARAM_DEV_FLOWC_BUFFIFO_SZ = 0x03,
444 FW_PARAMS_PARAM_DEV_INTVER_NIC = 0x04,
445 FW_PARAMS_PARAM_DEV_INTVER_VNIC = 0x05,
446 FW_PARAMS_PARAM_DEV_INTVER_OFLD = 0x06,
447 FW_PARAMS_PARAM_DEV_INTVER_RI = 0x07,
448 FW_PARAMS_PARAM_DEV_INTVER_ISCSIPDU = 0x08,
449 FW_PARAMS_PARAM_DEV_INTVER_ISCSI = 0x09,
450 FW_PARAMS_PARAM_DEV_INTVER_FCOE = 0x0A
451};
452
453/*
454 * physical and virtual function parameters
455 */
456enum fw_params_param_pfvf {
457 FW_PARAMS_PARAM_PFVF_RWXCAPS = 0x00,
458 FW_PARAMS_PARAM_PFVF_ROUTE_START = 0x01,
459 FW_PARAMS_PARAM_PFVF_ROUTE_END = 0x02,
460 FW_PARAMS_PARAM_PFVF_CLIP_START = 0x03,
461 FW_PARAMS_PARAM_PFVF_CLIP_END = 0x04,
462 FW_PARAMS_PARAM_PFVF_FILTER_START = 0x05,
463 FW_PARAMS_PARAM_PFVF_FILTER_END = 0x06,
464 FW_PARAMS_PARAM_PFVF_SERVER_START = 0x07,
465 FW_PARAMS_PARAM_PFVF_SERVER_END = 0x08,
466 FW_PARAMS_PARAM_PFVF_TDDP_START = 0x09,
467 FW_PARAMS_PARAM_PFVF_TDDP_END = 0x0A,
468 FW_PARAMS_PARAM_PFVF_ISCSI_START = 0x0B,
469 FW_PARAMS_PARAM_PFVF_ISCSI_END = 0x0C,
470 FW_PARAMS_PARAM_PFVF_STAG_START = 0x0D,
471 FW_PARAMS_PARAM_PFVF_STAG_END = 0x0E,
472 FW_PARAMS_PARAM_PFVF_RQ_START = 0x1F,
473 FW_PARAMS_PARAM_PFVF_RQ_END = 0x10,
474 FW_PARAMS_PARAM_PFVF_PBL_START = 0x11,
475 FW_PARAMS_PARAM_PFVF_PBL_END = 0x12,
476 FW_PARAMS_PARAM_PFVF_L2T_START = 0x13,
477 FW_PARAMS_PARAM_PFVF_L2T_END = 0x14,
478 FW_PARAMS_PARAM_PFVF_SCHEDCLASS_ETH = 0x20,
479};
480
481/*
482 * dma queue parameters
483 */
484enum fw_params_param_dmaq {
485 FW_PARAMS_PARAM_DMAQ_IQ_DCAEN_DCACPU = 0x00,
486 FW_PARAMS_PARAM_DMAQ_IQ_INTCNTTHRESH = 0x01,
487 FW_PARAMS_PARAM_DMAQ_EQ_CMPLIQID_MNGT = 0x10,
488 FW_PARAMS_PARAM_DMAQ_EQ_CMPLIQID_CTRL = 0x11,
489 FW_PARAMS_PARAM_DMAQ_EQ_SCHEDCLASS_ETH = 0x12,
490};
491
492#define FW_PARAMS_MNEM(x) ((x) << 24)
493#define FW_PARAMS_PARAM_X(x) ((x) << 16)
494#define FW_PARAMS_PARAM_Y(x) ((x) << 8)
495#define FW_PARAMS_PARAM_Z(x) ((x) << 0)
496#define FW_PARAMS_PARAM_XYZ(x) ((x) << 0)
497#define FW_PARAMS_PARAM_YZ(x) ((x) << 0)
498
499struct fw_params_cmd {
500 __be32 op_to_vfn;
501 __be32 retval_len16;
502 struct fw_params_param {
503 __be32 mnem;
504 __be32 val;
505 } param[7];
506};
507
508#define FW_PARAMS_CMD_PFN(x) ((x) << 8)
509#define FW_PARAMS_CMD_VFN(x) ((x) << 0)
510
511struct fw_pfvf_cmd {
512 __be32 op_to_vfn;
513 __be32 retval_len16;
514 __be32 niqflint_niq;
515 __be32 cmask_to_neq;
516 __be32 tc_to_nexactf;
517 __be32 r_caps_to_nethctrl;
518 __be16 nricq;
519 __be16 nriqp;
520 __be32 r4;
521};
522
523#define FW_PFVF_CMD_PFN(x) ((x) << 8)
524#define FW_PFVF_CMD_VFN(x) ((x) << 0)
525
526#define FW_PFVF_CMD_NIQFLINT(x) ((x) << 20)
527#define FW_PFVF_CMD_NIQFLINT_GET(x) (((x) >> 20) & 0xfff)
528
529#define FW_PFVF_CMD_NIQ(x) ((x) << 0)
530#define FW_PFVF_CMD_NIQ_GET(x) (((x) >> 0) & 0xfffff)
531
532#define FW_PFVF_CMD_CMASK(x) ((x) << 24)
533#define FW_PFVF_CMD_CMASK_GET(x) (((x) >> 24) & 0xf)
534
535#define FW_PFVF_CMD_PMASK(x) ((x) << 20)
536#define FW_PFVF_CMD_PMASK_GET(x) (((x) >> 20) & 0xf)
537
538#define FW_PFVF_CMD_NEQ(x) ((x) << 0)
539#define FW_PFVF_CMD_NEQ_GET(x) (((x) >> 0) & 0xfffff)
540
541#define FW_PFVF_CMD_TC(x) ((x) << 24)
542#define FW_PFVF_CMD_TC_GET(x) (((x) >> 24) & 0xff)
543
544#define FW_PFVF_CMD_NVI(x) ((x) << 16)
545#define FW_PFVF_CMD_NVI_GET(x) (((x) >> 16) & 0xff)
546
547#define FW_PFVF_CMD_NEXACTF(x) ((x) << 0)
548#define FW_PFVF_CMD_NEXACTF_GET(x) (((x) >> 0) & 0xffff)
549
550#define FW_PFVF_CMD_R_CAPS(x) ((x) << 24)
551#define FW_PFVF_CMD_R_CAPS_GET(x) (((x) >> 24) & 0xff)
552
553#define FW_PFVF_CMD_WX_CAPS(x) ((x) << 16)
554#define FW_PFVF_CMD_WX_CAPS_GET(x) (((x) >> 16) & 0xff)
555
556#define FW_PFVF_CMD_NETHCTRL(x) ((x) << 0)
557#define FW_PFVF_CMD_NETHCTRL_GET(x) (((x) >> 0) & 0xffff)
558
559enum fw_iq_type {
560 FW_IQ_TYPE_FL_INT_CAP,
561 FW_IQ_TYPE_NO_FL_INT_CAP
562};
563
564struct fw_iq_cmd {
565 __be32 op_to_vfn;
566 __be32 alloc_to_len16;
567 __be16 physiqid;
568 __be16 iqid;
569 __be16 fl0id;
570 __be16 fl1id;
571 __be32 type_to_iqandstindex;
572 __be16 iqdroprss_to_iqesize;
573 __be16 iqsize;
574 __be64 iqaddr;
575 __be32 iqns_to_fl0congen;
576 __be16 fl0dcaen_to_fl0cidxfthresh;
577 __be16 fl0size;
578 __be64 fl0addr;
579 __be32 fl1cngchmap_to_fl1congen;
580 __be16 fl1dcaen_to_fl1cidxfthresh;
581 __be16 fl1size;
582 __be64 fl1addr;
583};
584
585#define FW_IQ_CMD_PFN(x) ((x) << 8)
586#define FW_IQ_CMD_VFN(x) ((x) << 0)
587
588#define FW_IQ_CMD_ALLOC (1U << 31)
589#define FW_IQ_CMD_FREE (1U << 30)
590#define FW_IQ_CMD_MODIFY (1U << 29)
591#define FW_IQ_CMD_IQSTART(x) ((x) << 28)
592#define FW_IQ_CMD_IQSTOP(x) ((x) << 27)
593
594#define FW_IQ_CMD_TYPE(x) ((x) << 29)
595#define FW_IQ_CMD_IQASYNCH(x) ((x) << 28)
596#define FW_IQ_CMD_VIID(x) ((x) << 16)
597#define FW_IQ_CMD_IQANDST(x) ((x) << 15)
598#define FW_IQ_CMD_IQANUS(x) ((x) << 14)
599#define FW_IQ_CMD_IQANUD(x) ((x) << 12)
600#define FW_IQ_CMD_IQANDSTINDEX(x) ((x) << 0)
601
602#define FW_IQ_CMD_IQDROPRSS (1U << 15)
603#define FW_IQ_CMD_IQGTSMODE (1U << 14)
604#define FW_IQ_CMD_IQPCIECH(x) ((x) << 12)
605#define FW_IQ_CMD_IQDCAEN(x) ((x) << 11)
606#define FW_IQ_CMD_IQDCACPU(x) ((x) << 6)
607#define FW_IQ_CMD_IQINTCNTTHRESH(x) ((x) << 4)
608#define FW_IQ_CMD_IQO (1U << 3)
609#define FW_IQ_CMD_IQCPRIO(x) ((x) << 2)
610#define FW_IQ_CMD_IQESIZE(x) ((x) << 0)
611
612#define FW_IQ_CMD_IQNS(x) ((x) << 31)
613#define FW_IQ_CMD_IQRO(x) ((x) << 30)
614#define FW_IQ_CMD_IQFLINTIQHSEN(x) ((x) << 28)
615#define FW_IQ_CMD_IQFLINTCONGEN(x) ((x) << 27)
616#define FW_IQ_CMD_IQFLINTISCSIC(x) ((x) << 26)
617#define FW_IQ_CMD_FL0CNGCHMAP(x) ((x) << 20)
618#define FW_IQ_CMD_FL0CACHELOCK(x) ((x) << 15)
619#define FW_IQ_CMD_FL0DBP(x) ((x) << 14)
620#define FW_IQ_CMD_FL0DATANS(x) ((x) << 13)
621#define FW_IQ_CMD_FL0DATARO(x) ((x) << 12)
622#define FW_IQ_CMD_FL0CONGCIF(x) ((x) << 11)
623#define FW_IQ_CMD_FL0ONCHIP(x) ((x) << 10)
624#define FW_IQ_CMD_FL0STATUSPGNS(x) ((x) << 9)
625#define FW_IQ_CMD_FL0STATUSPGRO(x) ((x) << 8)
626#define FW_IQ_CMD_FL0FETCHNS(x) ((x) << 7)
627#define FW_IQ_CMD_FL0FETCHRO(x) ((x) << 6)
628#define FW_IQ_CMD_FL0HOSTFCMODE(x) ((x) << 4)
629#define FW_IQ_CMD_FL0CPRIO(x) ((x) << 3)
630#define FW_IQ_CMD_FL0PADEN (1U << 2)
631#define FW_IQ_CMD_FL0PACKEN (1U << 1)
632#define FW_IQ_CMD_FL0CONGEN (1U << 0)
633
634#define FW_IQ_CMD_FL0DCAEN(x) ((x) << 15)
635#define FW_IQ_CMD_FL0DCACPU(x) ((x) << 10)
636#define FW_IQ_CMD_FL0FBMIN(x) ((x) << 7)
637#define FW_IQ_CMD_FL0FBMAX(x) ((x) << 4)
638#define FW_IQ_CMD_FL0CIDXFTHRESHO (1U << 3)
639#define FW_IQ_CMD_FL0CIDXFTHRESH(x) ((x) << 0)
640
641#define FW_IQ_CMD_FL1CNGCHMAP(x) ((x) << 20)
642#define FW_IQ_CMD_FL1CACHELOCK(x) ((x) << 15)
643#define FW_IQ_CMD_FL1DBP(x) ((x) << 14)
644#define FW_IQ_CMD_FL1DATANS(x) ((x) << 13)
645#define FW_IQ_CMD_FL1DATARO(x) ((x) << 12)
646#define FW_IQ_CMD_FL1CONGCIF(x) ((x) << 11)
647#define FW_IQ_CMD_FL1ONCHIP(x) ((x) << 10)
648#define FW_IQ_CMD_FL1STATUSPGNS(x) ((x) << 9)
649#define FW_IQ_CMD_FL1STATUSPGRO(x) ((x) << 8)
650#define FW_IQ_CMD_FL1FETCHNS(x) ((x) << 7)
651#define FW_IQ_CMD_FL1FETCHRO(x) ((x) << 6)
652#define FW_IQ_CMD_FL1HOSTFCMODE(x) ((x) << 4)
653#define FW_IQ_CMD_FL1CPRIO(x) ((x) << 3)
654#define FW_IQ_CMD_FL1PADEN (1U << 2)
655#define FW_IQ_CMD_FL1PACKEN (1U << 1)
656#define FW_IQ_CMD_FL1CONGEN (1U << 0)
657
658#define FW_IQ_CMD_FL1DCAEN(x) ((x) << 15)
659#define FW_IQ_CMD_FL1DCACPU(x) ((x) << 10)
660#define FW_IQ_CMD_FL1FBMIN(x) ((x) << 7)
661#define FW_IQ_CMD_FL1FBMAX(x) ((x) << 4)
662#define FW_IQ_CMD_FL1CIDXFTHRESHO (1U << 3)
663#define FW_IQ_CMD_FL1CIDXFTHRESH(x) ((x) << 0)
664
665struct fw_eq_eth_cmd {
666 __be32 op_to_vfn;
667 __be32 alloc_to_len16;
668 __be32 eqid_pkd;
669 __be32 physeqid_pkd;
670 __be32 fetchszm_to_iqid;
671 __be32 dcaen_to_eqsize;
672 __be64 eqaddr;
673 __be32 viid_pkd;
674 __be32 r8_lo;
675 __be64 r9;
676};
677
678#define FW_EQ_ETH_CMD_PFN(x) ((x) << 8)
679#define FW_EQ_ETH_CMD_VFN(x) ((x) << 0)
680#define FW_EQ_ETH_CMD_ALLOC (1U << 31)
681#define FW_EQ_ETH_CMD_FREE (1U << 30)
682#define FW_EQ_ETH_CMD_MODIFY (1U << 29)
683#define FW_EQ_ETH_CMD_EQSTART (1U << 28)
684#define FW_EQ_ETH_CMD_EQSTOP (1U << 27)
685
686#define FW_EQ_ETH_CMD_EQID(x) ((x) << 0)
687#define FW_EQ_ETH_CMD_EQID_GET(x) (((x) >> 0) & 0xfffff)
688#define FW_EQ_ETH_CMD_PHYSEQID(x) ((x) << 0)
689
690#define FW_EQ_ETH_CMD_FETCHSZM(x) ((x) << 26)
691#define FW_EQ_ETH_CMD_STATUSPGNS(x) ((x) << 25)
692#define FW_EQ_ETH_CMD_STATUSPGRO(x) ((x) << 24)
693#define FW_EQ_ETH_CMD_FETCHNS(x) ((x) << 23)
694#define FW_EQ_ETH_CMD_FETCHRO(x) ((x) << 22)
695#define FW_EQ_ETH_CMD_HOSTFCMODE(x) ((x) << 20)
696#define FW_EQ_ETH_CMD_CPRIO(x) ((x) << 19)
697#define FW_EQ_ETH_CMD_ONCHIP(x) ((x) << 18)
698#define FW_EQ_ETH_CMD_PCIECHN(x) ((x) << 16)
699#define FW_EQ_ETH_CMD_IQID(x) ((x) << 0)
700
701#define FW_EQ_ETH_CMD_DCAEN(x) ((x) << 31)
702#define FW_EQ_ETH_CMD_DCACPU(x) ((x) << 26)
703#define FW_EQ_ETH_CMD_FBMIN(x) ((x) << 23)
704#define FW_EQ_ETH_CMD_FBMAX(x) ((x) << 20)
705#define FW_EQ_ETH_CMD_CIDXFTHRESHO(x) ((x) << 19)
706#define FW_EQ_ETH_CMD_CIDXFTHRESH(x) ((x) << 16)
707#define FW_EQ_ETH_CMD_EQSIZE(x) ((x) << 0)
708
709#define FW_EQ_ETH_CMD_VIID(x) ((x) << 16)
710
711struct fw_eq_ctrl_cmd {
712 __be32 op_to_vfn;
713 __be32 alloc_to_len16;
714 __be32 cmpliqid_eqid;
715 __be32 physeqid_pkd;
716 __be32 fetchszm_to_iqid;
717 __be32 dcaen_to_eqsize;
718 __be64 eqaddr;
719};
720
721#define FW_EQ_CTRL_CMD_PFN(x) ((x) << 8)
722#define FW_EQ_CTRL_CMD_VFN(x) ((x) << 0)
723
724#define FW_EQ_CTRL_CMD_ALLOC (1U << 31)
725#define FW_EQ_CTRL_CMD_FREE (1U << 30)
726#define FW_EQ_CTRL_CMD_MODIFY (1U << 29)
727#define FW_EQ_CTRL_CMD_EQSTART (1U << 28)
728#define FW_EQ_CTRL_CMD_EQSTOP (1U << 27)
729
730#define FW_EQ_CTRL_CMD_CMPLIQID(x) ((x) << 20)
731#define FW_EQ_CTRL_CMD_EQID(x) ((x) << 0)
732#define FW_EQ_CTRL_CMD_EQID_GET(x) (((x) >> 0) & 0xfffff)
733#define FW_EQ_CTRL_CMD_PHYSEQID_GET(x) (((x) >> 0) & 0xfffff)
734
735#define FW_EQ_CTRL_CMD_FETCHSZM (1U << 26)
736#define FW_EQ_CTRL_CMD_STATUSPGNS (1U << 25)
737#define FW_EQ_CTRL_CMD_STATUSPGRO (1U << 24)
738#define FW_EQ_CTRL_CMD_FETCHNS (1U << 23)
739#define FW_EQ_CTRL_CMD_FETCHRO (1U << 22)
740#define FW_EQ_CTRL_CMD_HOSTFCMODE(x) ((x) << 20)
741#define FW_EQ_CTRL_CMD_CPRIO(x) ((x) << 19)
742#define FW_EQ_CTRL_CMD_ONCHIP(x) ((x) << 18)
743#define FW_EQ_CTRL_CMD_PCIECHN(x) ((x) << 16)
744#define FW_EQ_CTRL_CMD_IQID(x) ((x) << 0)
745
746#define FW_EQ_CTRL_CMD_DCAEN(x) ((x) << 31)
747#define FW_EQ_CTRL_CMD_DCACPU(x) ((x) << 26)
748#define FW_EQ_CTRL_CMD_FBMIN(x) ((x) << 23)
749#define FW_EQ_CTRL_CMD_FBMAX(x) ((x) << 20)
750#define FW_EQ_CTRL_CMD_CIDXFTHRESHO(x) ((x) << 19)
751#define FW_EQ_CTRL_CMD_CIDXFTHRESH(x) ((x) << 16)
752#define FW_EQ_CTRL_CMD_EQSIZE(x) ((x) << 0)
753
754struct fw_eq_ofld_cmd {
755 __be32 op_to_vfn;
756 __be32 alloc_to_len16;
757 __be32 eqid_pkd;
758 __be32 physeqid_pkd;
759 __be32 fetchszm_to_iqid;
760 __be32 dcaen_to_eqsize;
761 __be64 eqaddr;
762};
763
764#define FW_EQ_OFLD_CMD_PFN(x) ((x) << 8)
765#define FW_EQ_OFLD_CMD_VFN(x) ((x) << 0)
766
767#define FW_EQ_OFLD_CMD_ALLOC (1U << 31)
768#define FW_EQ_OFLD_CMD_FREE (1U << 30)
769#define FW_EQ_OFLD_CMD_MODIFY (1U << 29)
770#define FW_EQ_OFLD_CMD_EQSTART (1U << 28)
771#define FW_EQ_OFLD_CMD_EQSTOP (1U << 27)
772
773#define FW_EQ_OFLD_CMD_EQID(x) ((x) << 0)
774#define FW_EQ_OFLD_CMD_EQID_GET(x) (((x) >> 0) & 0xfffff)
775#define FW_EQ_OFLD_CMD_PHYSEQID_GET(x) (((x) >> 0) & 0xfffff)
776
777#define FW_EQ_OFLD_CMD_FETCHSZM(x) ((x) << 26)
778#define FW_EQ_OFLD_CMD_STATUSPGNS(x) ((x) << 25)
779#define FW_EQ_OFLD_CMD_STATUSPGRO(x) ((x) << 24)
780#define FW_EQ_OFLD_CMD_FETCHNS(x) ((x) << 23)
781#define FW_EQ_OFLD_CMD_FETCHRO(x) ((x) << 22)
782#define FW_EQ_OFLD_CMD_HOSTFCMODE(x) ((x) << 20)
783#define FW_EQ_OFLD_CMD_CPRIO(x) ((x) << 19)
784#define FW_EQ_OFLD_CMD_ONCHIP(x) ((x) << 18)
785#define FW_EQ_OFLD_CMD_PCIECHN(x) ((x) << 16)
786#define FW_EQ_OFLD_CMD_IQID(x) ((x) << 0)
787
788#define FW_EQ_OFLD_CMD_DCAEN(x) ((x) << 31)
789#define FW_EQ_OFLD_CMD_DCACPU(x) ((x) << 26)
790#define FW_EQ_OFLD_CMD_FBMIN(x) ((x) << 23)
791#define FW_EQ_OFLD_CMD_FBMAX(x) ((x) << 20)
792#define FW_EQ_OFLD_CMD_CIDXFTHRESHO(x) ((x) << 19)
793#define FW_EQ_OFLD_CMD_CIDXFTHRESH(x) ((x) << 16)
794#define FW_EQ_OFLD_CMD_EQSIZE(x) ((x) << 0)
795
796/*
797 * Macros for VIID parsing:
798 * VIID - [10:8] PFN, [7] VI Valid, [6:0] VI number
799 */
800#define FW_VIID_PFN_GET(x) (((x) >> 8) & 0x7)
801#define FW_VIID_VIVLD_GET(x) (((x) >> 7) & 0x1)
802#define FW_VIID_VIN_GET(x) (((x) >> 0) & 0x7F)
803
804struct fw_vi_cmd {
805 __be32 op_to_vfn;
806 __be32 alloc_to_len16;
807 __be16 viid_pkd;
808 u8 mac[6];
809 u8 portid_pkd;
810 u8 nmac;
811 u8 nmac0[6];
812 __be16 rsssize_pkd;
813 u8 nmac1[6];
814 __be16 r7;
815 u8 nmac2[6];
816 __be16 r8;
817 u8 nmac3[6];
818 __be64 r9;
819 __be64 r10;
820};
821
822#define FW_VI_CMD_PFN(x) ((x) << 8)
823#define FW_VI_CMD_VFN(x) ((x) << 0)
824#define FW_VI_CMD_ALLOC (1U << 31)
825#define FW_VI_CMD_FREE (1U << 30)
826#define FW_VI_CMD_VIID(x) ((x) << 0)
827#define FW_VI_CMD_PORTID(x) ((x) << 4)
828#define FW_VI_CMD_RSSSIZE_GET(x) (((x) >> 0) & 0x7ff)
829
830/* Special VI_MAC command index ids */
831#define FW_VI_MAC_ADD_MAC 0x3FF
832#define FW_VI_MAC_ADD_PERSIST_MAC 0x3FE
833#define FW_VI_MAC_MAC_BASED_FREE 0x3FD
834
835enum fw_vi_mac_smac {
836 FW_VI_MAC_MPS_TCAM_ENTRY,
837 FW_VI_MAC_MPS_TCAM_ONLY,
838 FW_VI_MAC_SMT_ONLY,
839 FW_VI_MAC_SMT_AND_MPSTCAM
840};
841
842enum fw_vi_mac_result {
843 FW_VI_MAC_R_SUCCESS,
844 FW_VI_MAC_R_F_NONEXISTENT_NOMEM,
845 FW_VI_MAC_R_SMAC_FAIL,
846 FW_VI_MAC_R_F_ACL_CHECK
847};
848
849struct fw_vi_mac_cmd {
850 __be32 op_to_viid;
851 __be32 freemacs_to_len16;
852 union fw_vi_mac {
853 struct fw_vi_mac_exact {
854 __be16 valid_to_idx;
855 u8 macaddr[6];
856 } exact[7];
857 struct fw_vi_mac_hash {
858 __be64 hashvec;
859 } hash;
860 } u;
861};
862
863#define FW_VI_MAC_CMD_VIID(x) ((x) << 0)
864#define FW_VI_MAC_CMD_FREEMACS(x) ((x) << 31)
865#define FW_VI_MAC_CMD_HASHVECEN (1U << 23)
866#define FW_VI_MAC_CMD_HASHUNIEN(x) ((x) << 22)
867#define FW_VI_MAC_CMD_VALID (1U << 15)
868#define FW_VI_MAC_CMD_PRIO(x) ((x) << 12)
869#define FW_VI_MAC_CMD_SMAC_RESULT(x) ((x) << 10)
870#define FW_VI_MAC_CMD_SMAC_RESULT_GET(x) (((x) >> 10) & 0x3)
871#define FW_VI_MAC_CMD_IDX(x) ((x) << 0)
872#define FW_VI_MAC_CMD_IDX_GET(x) (((x) >> 0) & 0x3ff)
873
874#define FW_RXMODE_MTU_NO_CHG 65535
875
876struct fw_vi_rxmode_cmd {
877 __be32 op_to_viid;
878 __be32 retval_len16;
879 __be32 mtu_to_broadcasten;
880 __be32 r4_lo;
881};
882
883#define FW_VI_RXMODE_CMD_VIID(x) ((x) << 0)
884#define FW_VI_RXMODE_CMD_MTU(x) ((x) << 16)
885#define FW_VI_RXMODE_CMD_PROMISCEN_MASK 0x3
886#define FW_VI_RXMODE_CMD_PROMISCEN(x) ((x) << 14)
887#define FW_VI_RXMODE_CMD_ALLMULTIEN_MASK 0x3
888#define FW_VI_RXMODE_CMD_ALLMULTIEN(x) ((x) << 12)
889#define FW_VI_RXMODE_CMD_BROADCASTEN_MASK 0x3
890#define FW_VI_RXMODE_CMD_BROADCASTEN(x) ((x) << 10)
891
892struct fw_vi_enable_cmd {
893 __be32 op_to_viid;
894 __be32 ien_to_len16;
895 __be16 blinkdur;
896 __be16 r3;
897 __be32 r4;
898};
899
900#define FW_VI_ENABLE_CMD_VIID(x) ((x) << 0)
901#define FW_VI_ENABLE_CMD_IEN(x) ((x) << 31)
902#define FW_VI_ENABLE_CMD_EEN(x) ((x) << 30)
903#define FW_VI_ENABLE_CMD_LED (1U << 29)
904
905/* VI VF stats offset definitions */
906#define VI_VF_NUM_STATS 16
907enum fw_vi_stats_vf_index {
908 FW_VI_VF_STAT_TX_BCAST_BYTES_IX,
909 FW_VI_VF_STAT_TX_BCAST_FRAMES_IX,
910 FW_VI_VF_STAT_TX_MCAST_BYTES_IX,
911 FW_VI_VF_STAT_TX_MCAST_FRAMES_IX,
912 FW_VI_VF_STAT_TX_UCAST_BYTES_IX,
913 FW_VI_VF_STAT_TX_UCAST_FRAMES_IX,
914 FW_VI_VF_STAT_TX_DROP_FRAMES_IX,
915 FW_VI_VF_STAT_TX_OFLD_BYTES_IX,
916 FW_VI_VF_STAT_TX_OFLD_FRAMES_IX,
917 FW_VI_VF_STAT_RX_BCAST_BYTES_IX,
918 FW_VI_VF_STAT_RX_BCAST_FRAMES_IX,
919 FW_VI_VF_STAT_RX_MCAST_BYTES_IX,
920 FW_VI_VF_STAT_RX_MCAST_FRAMES_IX,
921 FW_VI_VF_STAT_RX_UCAST_BYTES_IX,
922 FW_VI_VF_STAT_RX_UCAST_FRAMES_IX,
923 FW_VI_VF_STAT_RX_ERR_FRAMES_IX
924};
925
926/* VI PF stats offset definitions */
927#define VI_PF_NUM_STATS 17
928enum fw_vi_stats_pf_index {
929 FW_VI_PF_STAT_TX_BCAST_BYTES_IX,
930 FW_VI_PF_STAT_TX_BCAST_FRAMES_IX,
931 FW_VI_PF_STAT_TX_MCAST_BYTES_IX,
932 FW_VI_PF_STAT_TX_MCAST_FRAMES_IX,
933 FW_VI_PF_STAT_TX_UCAST_BYTES_IX,
934 FW_VI_PF_STAT_TX_UCAST_FRAMES_IX,
935 FW_VI_PF_STAT_TX_OFLD_BYTES_IX,
936 FW_VI_PF_STAT_TX_OFLD_FRAMES_IX,
937 FW_VI_PF_STAT_RX_BYTES_IX,
938 FW_VI_PF_STAT_RX_FRAMES_IX,
939 FW_VI_PF_STAT_RX_BCAST_BYTES_IX,
940 FW_VI_PF_STAT_RX_BCAST_FRAMES_IX,
941 FW_VI_PF_STAT_RX_MCAST_BYTES_IX,
942 FW_VI_PF_STAT_RX_MCAST_FRAMES_IX,
943 FW_VI_PF_STAT_RX_UCAST_BYTES_IX,
944 FW_VI_PF_STAT_RX_UCAST_FRAMES_IX,
945 FW_VI_PF_STAT_RX_ERR_FRAMES_IX
946};
947
948struct fw_vi_stats_cmd {
949 __be32 op_to_viid;
950 __be32 retval_len16;
951 union fw_vi_stats {
952 struct fw_vi_stats_ctl {
953 __be16 nstats_ix;
954 __be16 r6;
955 __be32 r7;
956 __be64 stat0;
957 __be64 stat1;
958 __be64 stat2;
959 __be64 stat3;
960 __be64 stat4;
961 __be64 stat5;
962 } ctl;
963 struct fw_vi_stats_pf {
964 __be64 tx_bcast_bytes;
965 __be64 tx_bcast_frames;
966 __be64 tx_mcast_bytes;
967 __be64 tx_mcast_frames;
968 __be64 tx_ucast_bytes;
969 __be64 tx_ucast_frames;
970 __be64 tx_offload_bytes;
971 __be64 tx_offload_frames;
972 __be64 rx_pf_bytes;
973 __be64 rx_pf_frames;
974 __be64 rx_bcast_bytes;
975 __be64 rx_bcast_frames;
976 __be64 rx_mcast_bytes;
977 __be64 rx_mcast_frames;
978 __be64 rx_ucast_bytes;
979 __be64 rx_ucast_frames;
980 __be64 rx_err_frames;
981 } pf;
982 struct fw_vi_stats_vf {
983 __be64 tx_bcast_bytes;
984 __be64 tx_bcast_frames;
985 __be64 tx_mcast_bytes;
986 __be64 tx_mcast_frames;
987 __be64 tx_ucast_bytes;
988 __be64 tx_ucast_frames;
989 __be64 tx_drop_frames;
990 __be64 tx_offload_bytes;
991 __be64 tx_offload_frames;
992 __be64 rx_bcast_bytes;
993 __be64 rx_bcast_frames;
994 __be64 rx_mcast_bytes;
995 __be64 rx_mcast_frames;
996 __be64 rx_ucast_bytes;
997 __be64 rx_ucast_frames;
998 __be64 rx_err_frames;
999 } vf;
1000 } u;
1001};
1002
1003#define FW_VI_STATS_CMD_VIID(x) ((x) << 0)
1004#define FW_VI_STATS_CMD_NSTATS(x) ((x) << 12)
1005#define FW_VI_STATS_CMD_IX(x) ((x) << 0)
1006
1007struct fw_acl_mac_cmd {
1008 __be32 op_to_vfn;
1009 __be32 en_to_len16;
1010 u8 nmac;
1011 u8 r3[7];
1012 __be16 r4;
1013 u8 macaddr0[6];
1014 __be16 r5;
1015 u8 macaddr1[6];
1016 __be16 r6;
1017 u8 macaddr2[6];
1018 __be16 r7;
1019 u8 macaddr3[6];
1020};
1021
1022#define FW_ACL_MAC_CMD_PFN(x) ((x) << 8)
1023#define FW_ACL_MAC_CMD_VFN(x) ((x) << 0)
1024#define FW_ACL_MAC_CMD_EN(x) ((x) << 31)
1025
1026struct fw_acl_vlan_cmd {
1027 __be32 op_to_vfn;
1028 __be32 en_to_len16;
1029 u8 nvlan;
1030 u8 dropnovlan_fm;
1031 u8 r3_lo[6];
1032 __be16 vlanid[16];
1033};
1034
1035#define FW_ACL_VLAN_CMD_PFN(x) ((x) << 8)
1036#define FW_ACL_VLAN_CMD_VFN(x) ((x) << 0)
1037#define FW_ACL_VLAN_CMD_EN(x) ((x) << 31)
1038#define FW_ACL_VLAN_CMD_DROPNOVLAN(x) ((x) << 7)
1039#define FW_ACL_VLAN_CMD_FM(x) ((x) << 6)
1040
1041enum fw_port_cap {
1042 FW_PORT_CAP_SPEED_100M = 0x0001,
1043 FW_PORT_CAP_SPEED_1G = 0x0002,
1044 FW_PORT_CAP_SPEED_2_5G = 0x0004,
1045 FW_PORT_CAP_SPEED_10G = 0x0008,
1046 FW_PORT_CAP_SPEED_40G = 0x0010,
1047 FW_PORT_CAP_SPEED_100G = 0x0020,
1048 FW_PORT_CAP_FC_RX = 0x0040,
1049 FW_PORT_CAP_FC_TX = 0x0080,
1050 FW_PORT_CAP_ANEG = 0x0100,
1051 FW_PORT_CAP_MDI_0 = 0x0200,
1052 FW_PORT_CAP_MDI_1 = 0x0400,
1053 FW_PORT_CAP_BEAN = 0x0800,
1054 FW_PORT_CAP_PMA_LPBK = 0x1000,
1055 FW_PORT_CAP_PCS_LPBK = 0x2000,
1056 FW_PORT_CAP_PHYXS_LPBK = 0x4000,
1057 FW_PORT_CAP_FAR_END_LPBK = 0x8000,
1058};
1059
1060enum fw_port_mdi {
1061 FW_PORT_MDI_UNCHANGED,
1062 FW_PORT_MDI_AUTO,
1063 FW_PORT_MDI_F_STRAIGHT,
1064 FW_PORT_MDI_F_CROSSOVER
1065};
1066
1067#define FW_PORT_MDI(x) ((x) << 9)
1068
1069enum fw_port_action {
1070 FW_PORT_ACTION_L1_CFG = 0x0001,
1071 FW_PORT_ACTION_L2_CFG = 0x0002,
1072 FW_PORT_ACTION_GET_PORT_INFO = 0x0003,
1073 FW_PORT_ACTION_L2_PPP_CFG = 0x0004,
1074 FW_PORT_ACTION_L2_DCB_CFG = 0x0005,
1075 FW_PORT_ACTION_LOW_PWR_TO_NORMAL = 0x0010,
1076 FW_PORT_ACTION_L1_LOW_PWR_EN = 0x0011,
1077 FW_PORT_ACTION_L2_WOL_MODE_EN = 0x0012,
1078 FW_PORT_ACTION_LPBK_TO_NORMAL = 0x0020,
1079 FW_PORT_ACTION_L1_LPBK = 0x0021,
1080 FW_PORT_ACTION_L1_PMA_LPBK = 0x0022,
1081 FW_PORT_ACTION_L1_PCS_LPBK = 0x0023,
1082 FW_PORT_ACTION_L1_PHYXS_CSIDE_LPBK = 0x0024,
1083 FW_PORT_ACTION_L1_PHYXS_ESIDE_LPBK = 0x0025,
1084 FW_PORT_ACTION_PHY_RESET = 0x0040,
1085 FW_PORT_ACTION_PMA_RESET = 0x0041,
1086 FW_PORT_ACTION_PCS_RESET = 0x0042,
1087 FW_PORT_ACTION_PHYXS_RESET = 0x0043,
1088 FW_PORT_ACTION_DTEXS_REEST = 0x0044,
1089 FW_PORT_ACTION_AN_RESET = 0x0045
1090};
1091
1092enum fw_port_l2cfg_ctlbf {
1093 FW_PORT_L2_CTLBF_OVLAN0 = 0x01,
1094 FW_PORT_L2_CTLBF_OVLAN1 = 0x02,
1095 FW_PORT_L2_CTLBF_OVLAN2 = 0x04,
1096 FW_PORT_L2_CTLBF_OVLAN3 = 0x08,
1097 FW_PORT_L2_CTLBF_IVLAN = 0x10,
1098 FW_PORT_L2_CTLBF_TXIPG = 0x20
1099};
1100
1101enum fw_port_dcb_cfg {
1102 FW_PORT_DCB_CFG_PG = 0x01,
1103 FW_PORT_DCB_CFG_PFC = 0x02,
1104 FW_PORT_DCB_CFG_APPL = 0x04
1105};
1106
1107enum fw_port_dcb_cfg_rc {
1108 FW_PORT_DCB_CFG_SUCCESS = 0x0,
1109 FW_PORT_DCB_CFG_ERROR = 0x1
1110};
1111
1112struct fw_port_cmd {
1113 __be32 op_to_portid;
1114 __be32 action_to_len16;
1115 union fw_port {
1116 struct fw_port_l1cfg {
1117 __be32 rcap;
1118 __be32 r;
1119 } l1cfg;
1120 struct fw_port_l2cfg {
1121 __be16 ctlbf_to_ivlan0;
1122 __be16 ivlantype;
1123 __be32 txipg_pkd;
1124 __be16 ovlan0mask;
1125 __be16 ovlan0type;
1126 __be16 ovlan1mask;
1127 __be16 ovlan1type;
1128 __be16 ovlan2mask;
1129 __be16 ovlan2type;
1130 __be16 ovlan3mask;
1131 __be16 ovlan3type;
1132 } l2cfg;
1133 struct fw_port_info {
1134 __be32 lstatus_to_modtype;
1135 __be16 pcap;
1136 __be16 acap;
1137 } info;
1138 struct fw_port_ppp {
1139 __be32 pppen_to_ncsich;
1140 __be32 r11;
1141 } ppp;
1142 struct fw_port_dcb {
1143 __be16 cfg;
1144 u8 up_map;
1145 u8 sf_cfgrc;
1146 __be16 prot_ix;
1147 u8 pe7_to_pe0;
1148 u8 numTCPFCs;
1149 __be32 pgid0_to_pgid7;
1150 __be32 numTCs_oui;
1151 u8 pgpc[8];
1152 } dcb;
1153 } u;
1154};
1155
1156#define FW_PORT_CMD_READ (1U << 22)
1157
1158#define FW_PORT_CMD_PORTID(x) ((x) << 0)
1159#define FW_PORT_CMD_PORTID_GET(x) (((x) >> 0) & 0xf)
1160
1161#define FW_PORT_CMD_ACTION(x) ((x) << 16)
1162
1163#define FW_PORT_CMD_CTLBF(x) ((x) << 10)
1164#define FW_PORT_CMD_OVLAN3(x) ((x) << 7)
1165#define FW_PORT_CMD_OVLAN2(x) ((x) << 6)
1166#define FW_PORT_CMD_OVLAN1(x) ((x) << 5)
1167#define FW_PORT_CMD_OVLAN0(x) ((x) << 4)
1168#define FW_PORT_CMD_IVLAN0(x) ((x) << 3)
1169
1170#define FW_PORT_CMD_TXIPG(x) ((x) << 19)
1171
1172#define FW_PORT_CMD_LSTATUS (1U << 31)
1173#define FW_PORT_CMD_LSPEED(x) ((x) << 24)
1174#define FW_PORT_CMD_LSPEED_GET(x) (((x) >> 24) & 0x3f)
1175#define FW_PORT_CMD_TXPAUSE (1U << 23)
1176#define FW_PORT_CMD_RXPAUSE (1U << 22)
1177#define FW_PORT_CMD_MDIOCAP (1U << 21)
1178#define FW_PORT_CMD_MDIOADDR_GET(x) (((x) >> 16) & 0x1f)
1179#define FW_PORT_CMD_LPTXPAUSE (1U << 15)
1180#define FW_PORT_CMD_LPRXPAUSE (1U << 14)
1181#define FW_PORT_CMD_PTYPE_MASK 0x1f
1182#define FW_PORT_CMD_PTYPE_GET(x) (((x) >> 8) & FW_PORT_CMD_PTYPE_MASK)
1183#define FW_PORT_CMD_MODTYPE_MASK 0x1f
1184#define FW_PORT_CMD_MODTYPE_GET(x) (((x) >> 0) & FW_PORT_CMD_MODTYPE_MASK)
1185
1186#define FW_PORT_CMD_PPPEN(x) ((x) << 31)
1187#define FW_PORT_CMD_TPSRC(x) ((x) << 28)
1188#define FW_PORT_CMD_NCSISRC(x) ((x) << 24)
1189
1190#define FW_PORT_CMD_CH0(x) ((x) << 20)
1191#define FW_PORT_CMD_CH1(x) ((x) << 16)
1192#define FW_PORT_CMD_CH2(x) ((x) << 12)
1193#define FW_PORT_CMD_CH3(x) ((x) << 8)
1194#define FW_PORT_CMD_NCSICH(x) ((x) << 4)
1195
1196enum fw_port_type {
1197 FW_PORT_TYPE_FIBER,
1198 FW_PORT_TYPE_KX4,
1199 FW_PORT_TYPE_BT_SGMII,
1200 FW_PORT_TYPE_KX,
1201 FW_PORT_TYPE_BT_XAUI,
1202 FW_PORT_TYPE_KR,
1203 FW_PORT_TYPE_CX4,
1204 FW_PORT_TYPE_TWINAX,
1205
1206 FW_PORT_TYPE_NONE = FW_PORT_CMD_PTYPE_MASK
1207};
1208
1209enum fw_port_module_type {
1210 FW_PORT_MOD_TYPE_NA,
1211 FW_PORT_MOD_TYPE_LR,
1212 FW_PORT_MOD_TYPE_SR,
1213 FW_PORT_MOD_TYPE_ER,
1214
1215 FW_PORT_MOD_TYPE_NONE = FW_PORT_CMD_MODTYPE_MASK
1216};
1217
1218/* port stats */
1219#define FW_NUM_PORT_STATS 50
1220#define FW_NUM_PORT_TX_STATS 23
1221#define FW_NUM_PORT_RX_STATS 27
1222
1223enum fw_port_stats_tx_index {
1224 FW_STAT_TX_PORT_BYTES_IX,
1225 FW_STAT_TX_PORT_FRAMES_IX,
1226 FW_STAT_TX_PORT_BCAST_IX,
1227 FW_STAT_TX_PORT_MCAST_IX,
1228 FW_STAT_TX_PORT_UCAST_IX,
1229 FW_STAT_TX_PORT_ERROR_IX,
1230 FW_STAT_TX_PORT_64B_IX,
1231 FW_STAT_TX_PORT_65B_127B_IX,
1232 FW_STAT_TX_PORT_128B_255B_IX,
1233 FW_STAT_TX_PORT_256B_511B_IX,
1234 FW_STAT_TX_PORT_512B_1023B_IX,
1235 FW_STAT_TX_PORT_1024B_1518B_IX,
1236 FW_STAT_TX_PORT_1519B_MAX_IX,
1237 FW_STAT_TX_PORT_DROP_IX,
1238 FW_STAT_TX_PORT_PAUSE_IX,
1239 FW_STAT_TX_PORT_PPP0_IX,
1240 FW_STAT_TX_PORT_PPP1_IX,
1241 FW_STAT_TX_PORT_PPP2_IX,
1242 FW_STAT_TX_PORT_PPP3_IX,
1243 FW_STAT_TX_PORT_PPP4_IX,
1244 FW_STAT_TX_PORT_PPP5_IX,
1245 FW_STAT_TX_PORT_PPP6_IX,
1246 FW_STAT_TX_PORT_PPP7_IX
1247};
1248
1249enum fw_port_stat_rx_index {
1250 FW_STAT_RX_PORT_BYTES_IX,
1251 FW_STAT_RX_PORT_FRAMES_IX,
1252 FW_STAT_RX_PORT_BCAST_IX,
1253 FW_STAT_RX_PORT_MCAST_IX,
1254 FW_STAT_RX_PORT_UCAST_IX,
1255 FW_STAT_RX_PORT_MTU_ERROR_IX,
1256 FW_STAT_RX_PORT_MTU_CRC_ERROR_IX,
1257 FW_STAT_RX_PORT_CRC_ERROR_IX,
1258 FW_STAT_RX_PORT_LEN_ERROR_IX,
1259 FW_STAT_RX_PORT_SYM_ERROR_IX,
1260 FW_STAT_RX_PORT_64B_IX,
1261 FW_STAT_RX_PORT_65B_127B_IX,
1262 FW_STAT_RX_PORT_128B_255B_IX,
1263 FW_STAT_RX_PORT_256B_511B_IX,
1264 FW_STAT_RX_PORT_512B_1023B_IX,
1265 FW_STAT_RX_PORT_1024B_1518B_IX,
1266 FW_STAT_RX_PORT_1519B_MAX_IX,
1267 FW_STAT_RX_PORT_PAUSE_IX,
1268 FW_STAT_RX_PORT_PPP0_IX,
1269 FW_STAT_RX_PORT_PPP1_IX,
1270 FW_STAT_RX_PORT_PPP2_IX,
1271 FW_STAT_RX_PORT_PPP3_IX,
1272 FW_STAT_RX_PORT_PPP4_IX,
1273 FW_STAT_RX_PORT_PPP5_IX,
1274 FW_STAT_RX_PORT_PPP6_IX,
1275 FW_STAT_RX_PORT_PPP7_IX,
1276 FW_STAT_RX_PORT_LESS_64B_IX
1277};
1278
1279struct fw_port_stats_cmd {
1280 __be32 op_to_portid;
1281 __be32 retval_len16;
1282 union fw_port_stats {
1283 struct fw_port_stats_ctl {
1284 u8 nstats_bg_bm;
1285 u8 tx_ix;
1286 __be16 r6;
1287 __be32 r7;
1288 __be64 stat0;
1289 __be64 stat1;
1290 __be64 stat2;
1291 __be64 stat3;
1292 __be64 stat4;
1293 __be64 stat5;
1294 } ctl;
1295 struct fw_port_stats_all {
1296 __be64 tx_bytes;
1297 __be64 tx_frames;
1298 __be64 tx_bcast;
1299 __be64 tx_mcast;
1300 __be64 tx_ucast;
1301 __be64 tx_error;
1302 __be64 tx_64b;
1303 __be64 tx_65b_127b;
1304 __be64 tx_128b_255b;
1305 __be64 tx_256b_511b;
1306 __be64 tx_512b_1023b;
1307 __be64 tx_1024b_1518b;
1308 __be64 tx_1519b_max;
1309 __be64 tx_drop;
1310 __be64 tx_pause;
1311 __be64 tx_ppp0;
1312 __be64 tx_ppp1;
1313 __be64 tx_ppp2;
1314 __be64 tx_ppp3;
1315 __be64 tx_ppp4;
1316 __be64 tx_ppp5;
1317 __be64 tx_ppp6;
1318 __be64 tx_ppp7;
1319 __be64 rx_bytes;
1320 __be64 rx_frames;
1321 __be64 rx_bcast;
1322 __be64 rx_mcast;
1323 __be64 rx_ucast;
1324 __be64 rx_mtu_error;
1325 __be64 rx_mtu_crc_error;
1326 __be64 rx_crc_error;
1327 __be64 rx_len_error;
1328 __be64 rx_sym_error;
1329 __be64 rx_64b;
1330 __be64 rx_65b_127b;
1331 __be64 rx_128b_255b;
1332 __be64 rx_256b_511b;
1333 __be64 rx_512b_1023b;
1334 __be64 rx_1024b_1518b;
1335 __be64 rx_1519b_max;
1336 __be64 rx_pause;
1337 __be64 rx_ppp0;
1338 __be64 rx_ppp1;
1339 __be64 rx_ppp2;
1340 __be64 rx_ppp3;
1341 __be64 rx_ppp4;
1342 __be64 rx_ppp5;
1343 __be64 rx_ppp6;
1344 __be64 rx_ppp7;
1345 __be64 rx_less_64b;
1346 __be64 rx_bg_drop;
1347 __be64 rx_bg_trunc;
1348 } all;
1349 } u;
1350};
1351
1352#define FW_PORT_STATS_CMD_NSTATS(x) ((x) << 4)
1353#define FW_PORT_STATS_CMD_BG_BM(x) ((x) << 0)
1354#define FW_PORT_STATS_CMD_TX(x) ((x) << 7)
1355#define FW_PORT_STATS_CMD_IX(x) ((x) << 0)
1356
1357/* port loopback stats */
1358#define FW_NUM_LB_STATS 16
1359enum fw_port_lb_stats_index {
1360 FW_STAT_LB_PORT_BYTES_IX,
1361 FW_STAT_LB_PORT_FRAMES_IX,
1362 FW_STAT_LB_PORT_BCAST_IX,
1363 FW_STAT_LB_PORT_MCAST_IX,
1364 FW_STAT_LB_PORT_UCAST_IX,
1365 FW_STAT_LB_PORT_ERROR_IX,
1366 FW_STAT_LB_PORT_64B_IX,
1367 FW_STAT_LB_PORT_65B_127B_IX,
1368 FW_STAT_LB_PORT_128B_255B_IX,
1369 FW_STAT_LB_PORT_256B_511B_IX,
1370 FW_STAT_LB_PORT_512B_1023B_IX,
1371 FW_STAT_LB_PORT_1024B_1518B_IX,
1372 FW_STAT_LB_PORT_1519B_MAX_IX,
1373 FW_STAT_LB_PORT_DROP_FRAMES_IX
1374};
1375
1376struct fw_port_lb_stats_cmd {
1377 __be32 op_to_lbport;
1378 __be32 retval_len16;
1379 union fw_port_lb_stats {
1380 struct fw_port_lb_stats_ctl {
1381 u8 nstats_bg_bm;
1382 u8 ix_pkd;
1383 __be16 r6;
1384 __be32 r7;
1385 __be64 stat0;
1386 __be64 stat1;
1387 __be64 stat2;
1388 __be64 stat3;
1389 __be64 stat4;
1390 __be64 stat5;
1391 } ctl;
1392 struct fw_port_lb_stats_all {
1393 __be64 tx_bytes;
1394 __be64 tx_frames;
1395 __be64 tx_bcast;
1396 __be64 tx_mcast;
1397 __be64 tx_ucast;
1398 __be64 tx_error;
1399 __be64 tx_64b;
1400 __be64 tx_65b_127b;
1401 __be64 tx_128b_255b;
1402 __be64 tx_256b_511b;
1403 __be64 tx_512b_1023b;
1404 __be64 tx_1024b_1518b;
1405 __be64 tx_1519b_max;
1406 __be64 rx_lb_drop;
1407 __be64 rx_lb_trunc;
1408 } all;
1409 } u;
1410};
1411
1412#define FW_PORT_LB_STATS_CMD_LBPORT(x) ((x) << 0)
1413#define FW_PORT_LB_STATS_CMD_NSTATS(x) ((x) << 4)
1414#define FW_PORT_LB_STATS_CMD_BG_BM(x) ((x) << 0)
1415#define FW_PORT_LB_STATS_CMD_IX(x) ((x) << 0)
1416
1417struct fw_rss_ind_tbl_cmd {
1418 __be32 op_to_viid;
1419#define FW_RSS_IND_TBL_CMD_VIID(x) ((x) << 0)
1420 __be32 retval_len16;
1421 __be16 niqid;
1422 __be16 startidx;
1423 __be32 r3;
1424 __be32 iq0_to_iq2;
1425#define FW_RSS_IND_TBL_CMD_IQ0(x) ((x) << 20)
1426#define FW_RSS_IND_TBL_CMD_IQ1(x) ((x) << 10)
1427#define FW_RSS_IND_TBL_CMD_IQ2(x) ((x) << 0)
1428 __be32 iq3_to_iq5;
1429 __be32 iq6_to_iq8;
1430 __be32 iq9_to_iq11;
1431 __be32 iq12_to_iq14;
1432 __be32 iq15_to_iq17;
1433 __be32 iq18_to_iq20;
1434 __be32 iq21_to_iq23;
1435 __be32 iq24_to_iq26;
1436 __be32 iq27_to_iq29;
1437 __be32 iq30_iq31;
1438 __be32 r15_lo;
1439};
1440
1441struct fw_rss_glb_config_cmd {
1442 __be32 op_to_write;
1443 __be32 retval_len16;
1444 union fw_rss_glb_config {
1445 struct fw_rss_glb_config_manual {
1446 __be32 mode_pkd;
1447 __be32 r3;
1448 __be64 r4;
1449 __be64 r5;
1450 } manual;
1451 struct fw_rss_glb_config_basicvirtual {
1452 __be32 mode_pkd;
1453 __be32 synmapen_to_hashtoeplitz;
1454#define FW_RSS_GLB_CONFIG_CMD_SYNMAPEN (1U << 8)
1455#define FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV6 (1U << 7)
1456#define FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV6 (1U << 6)
1457#define FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV4 (1U << 5)
1458#define FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV4 (1U << 4)
1459#define FW_RSS_GLB_CONFIG_CMD_OFDMAPEN (1U << 3)
1460#define FW_RSS_GLB_CONFIG_CMD_TNLMAPEN (1U << 2)
1461#define FW_RSS_GLB_CONFIG_CMD_TNLALLLKP (1U << 1)
1462#define FW_RSS_GLB_CONFIG_CMD_HASHTOEPLITZ (1U << 0)
1463 __be64 r8;
1464 __be64 r9;
1465 } basicvirtual;
1466 } u;
1467};
1468
1469#define FW_RSS_GLB_CONFIG_CMD_MODE(x) ((x) << 28)
1470
1471#define FW_RSS_GLB_CONFIG_CMD_MODE_MANUAL 0
1472#define FW_RSS_GLB_CONFIG_CMD_MODE_BASICVIRTUAL 1
1473
1474struct fw_rss_vi_config_cmd {
1475 __be32 op_to_viid;
1476#define FW_RSS_VI_CONFIG_CMD_VIID(x) ((x) << 0)
1477 __be32 retval_len16;
1478 union fw_rss_vi_config {
1479 struct fw_rss_vi_config_manual {
1480 __be64 r3;
1481 __be64 r4;
1482 __be64 r5;
1483 } manual;
1484 struct fw_rss_vi_config_basicvirtual {
1485 __be32 r6;
1486 __be32 defaultq_to_ip4udpen;
1487#define FW_RSS_VI_CONFIG_CMD_DEFAULTQ(x) ((x) << 16)
1488#define FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN (1U << 4)
1489#define FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN (1U << 3)
1490#define FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN (1U << 2)
1491#define FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN (1U << 1)
1492#define FW_RSS_VI_CONFIG_CMD_IP4UDPEN (1U << 0)
1493 __be64 r9;
1494 __be64 r10;
1495 } basicvirtual;
1496 } u;
1497};
1498
1499enum fw_error_type {
1500 FW_ERROR_TYPE_EXCEPTION = 0x0,
1501 FW_ERROR_TYPE_HWMODULE = 0x1,
1502 FW_ERROR_TYPE_WR = 0x2,
1503 FW_ERROR_TYPE_ACL = 0x3,
1504};
1505
1506struct fw_error_cmd {
1507 __be32 op_to_type;
1508 __be32 len16_pkd;
1509 union fw_error {
1510 struct fw_error_exception {
1511 __be32 info[6];
1512 } exception;
1513 struct fw_error_hwmodule {
1514 __be32 regaddr;
1515 __be32 regval;
1516 } hwmodule;
1517 struct fw_error_wr {
1518 __be16 cidx;
1519 __be16 pfn_vfn;
1520 __be32 eqid;
1521 u8 wrhdr[16];
1522 } wr;
1523 struct fw_error_acl {
1524 __be16 cidx;
1525 __be16 pfn_vfn;
1526 __be32 eqid;
1527 __be16 mv_pkd;
1528 u8 val[6];
1529 __be64 r4;
1530 } acl;
1531 } u;
1532};
1533
1534struct fw_debug_cmd {
1535 __be32 op_type;
1536#define FW_DEBUG_CMD_TYPE_GET(x) ((x) & 0xff)
1537 __be32 len16_pkd;
1538 union fw_debug {
1539 struct fw_debug_assert {
1540 __be32 fcid;
1541 __be32 line;
1542 __be32 x;
1543 __be32 y;
1544 u8 filename_0_7[8];
1545 u8 filename_8_15[8];
1546 __be64 r3;
1547 } assert;
1548 struct fw_debug_prt {
1549 __be16 dprtstridx;
1550 __be16 r3[3];
1551 __be32 dprtstrparam0;
1552 __be32 dprtstrparam1;
1553 __be32 dprtstrparam2;
1554 __be32 dprtstrparam3;
1555 } prt;
1556 } u;
1557};
1558
1559struct fw_hdr {
1560 u8 ver;
1561 u8 reserved1;
1562 __be16 len512; /* bin length in units of 512-bytes */
1563 __be32 fw_ver; /* firmware version */
1564 __be32 tp_microcode_ver;
1565 u8 intfver_nic;
1566 u8 intfver_vnic;
1567 u8 intfver_ofld;
1568 u8 intfver_ri;
1569 u8 intfver_iscsipdu;
1570 u8 intfver_iscsi;
1571 u8 intfver_fcoe;
1572 u8 reserved2;
1573 __be32 reserved3[27];
1574};
1575
1576#define FW_HDR_FW_VER_MAJOR_GET(x) (((x) >> 24) & 0xff)
1577#define FW_HDR_FW_VER_MINOR_GET(x) (((x) >> 16) & 0xff)
1578#define FW_HDR_FW_VER_MICRO_GET(x) (((x) >> 8) & 0xff)
1579#define FW_HDR_FW_VER_BUILD_GET(x) (((x) >> 0) & 0xff)
1580#endif /* _T4FW_INTERFACE_H_ */
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index 1c67f1138ca..7f9960f718e 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -33,6 +33,7 @@
33#include <linux/delay.h> 33#include <linux/delay.h>
34#include <linux/platform_device.h> 34#include <linux/platform_device.h>
35#include <linux/irq.h> 35#include <linux/irq.h>
36#include <linux/slab.h>
36 37
37#include <asm/delay.h> 38#include <asm/delay.h>
38#include <asm/irq.h> 39#include <asm/irq.h>
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index b997e578e58..791080303db 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -166,6 +166,7 @@
166#include <linux/ethtool.h> 166#include <linux/ethtool.h>
167#include <linux/string.h> 167#include <linux/string.h>
168#include <linux/firmware.h> 168#include <linux/firmware.h>
169#include <linux/rtnetlink.h>
169#include <asm/unaligned.h> 170#include <asm/unaligned.h>
170 171
171 172
@@ -2265,8 +2266,13 @@ static void e100_tx_timeout_task(struct work_struct *work)
2265 2266
2266 DPRINTK(TX_ERR, DEBUG, "scb.status=0x%02X\n", 2267 DPRINTK(TX_ERR, DEBUG, "scb.status=0x%02X\n",
2267 ioread8(&nic->csr->scb.status)); 2268 ioread8(&nic->csr->scb.status));
2268 e100_down(netdev_priv(netdev)); 2269
2269 e100_up(netdev_priv(netdev)); 2270 rtnl_lock();
2271 if (netif_running(netdev)) {
2272 e100_down(netdev_priv(netdev));
2273 e100_up(netdev_priv(netdev));
2274 }
2275 rtnl_unlock();
2270} 2276}
2271 2277
2272static int e100_loopback_test(struct nic *nic, enum loopback loopback_mode) 2278static int e100_loopback_test(struct nic *nic, enum loopback loopback_mode)
diff --git a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h
index 9902b33b716..2f29c213185 100644
--- a/drivers/net/e1000/e1000.h
+++ b/drivers/net/e1000/e1000.h
@@ -261,7 +261,6 @@ struct e1000_adapter {
261 /* TX */ 261 /* TX */
262 struct e1000_tx_ring *tx_ring; /* One per active queue */ 262 struct e1000_tx_ring *tx_ring; /* One per active queue */
263 unsigned int restart_queue; 263 unsigned int restart_queue;
264 unsigned long tx_queue_len;
265 u32 txd_cmd; 264 u32 txd_cmd;
266 u32 tx_int_delay; 265 u32 tx_int_delay;
267 u32 tx_abs_int_delay; 266 u32 tx_abs_int_delay;
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 8be6faee43e..b15ece26ed8 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -383,8 +383,6 @@ static void e1000_configure(struct e1000_adapter *adapter)
383 adapter->alloc_rx_buf(adapter, ring, 383 adapter->alloc_rx_buf(adapter, ring,
384 E1000_DESC_UNUSED(ring)); 384 E1000_DESC_UNUSED(ring));
385 } 385 }
386
387 adapter->tx_queue_len = netdev->tx_queue_len;
388} 386}
389 387
390int e1000_up(struct e1000_adapter *adapter) 388int e1000_up(struct e1000_adapter *adapter)
@@ -503,7 +501,6 @@ void e1000_down(struct e1000_adapter *adapter)
503 del_timer_sync(&adapter->watchdog_timer); 501 del_timer_sync(&adapter->watchdog_timer);
504 del_timer_sync(&adapter->phy_info_timer); 502 del_timer_sync(&adapter->phy_info_timer);
505 503
506 netdev->tx_queue_len = adapter->tx_queue_len;
507 adapter->link_speed = 0; 504 adapter->link_speed = 0;
508 adapter->link_duplex = 0; 505 adapter->link_duplex = 0;
509 netif_carrier_off(netdev); 506 netif_carrier_off(netdev);
@@ -2316,19 +2313,15 @@ static void e1000_watchdog(unsigned long data)
2316 E1000_CTRL_RFCE) ? "RX" : ((ctrl & 2313 E1000_CTRL_RFCE) ? "RX" : ((ctrl &
2317 E1000_CTRL_TFCE) ? "TX" : "None" ))); 2314 E1000_CTRL_TFCE) ? "TX" : "None" )));
2318 2315
2319 /* tweak tx_queue_len according to speed/duplex 2316 /* adjust timeout factor according to speed/duplex */
2320 * and adjust the timeout factor */
2321 netdev->tx_queue_len = adapter->tx_queue_len;
2322 adapter->tx_timeout_factor = 1; 2317 adapter->tx_timeout_factor = 1;
2323 switch (adapter->link_speed) { 2318 switch (adapter->link_speed) {
2324 case SPEED_10: 2319 case SPEED_10:
2325 txb2b = false; 2320 txb2b = false;
2326 netdev->tx_queue_len = 10;
2327 adapter->tx_timeout_factor = 16; 2321 adapter->tx_timeout_factor = 16;
2328 break; 2322 break;
2329 case SPEED_100: 2323 case SPEED_100:
2330 txb2b = false; 2324 txb2b = false;
2331 netdev->tx_queue_len = 100;
2332 /* maybe add some timeout factor ? */ 2325 /* maybe add some timeout factor ? */
2333 break; 2326 break;
2334 } 2327 }
diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
index 712ccc66ba2..90155552ea0 100644
--- a/drivers/net/e1000e/82571.c
+++ b/drivers/net/e1000e/82571.c
@@ -336,7 +336,6 @@ static s32 e1000_get_variants_82571(struct e1000_adapter *adapter)
336 struct e1000_hw *hw = &adapter->hw; 336 struct e1000_hw *hw = &adapter->hw;
337 static int global_quad_port_a; /* global port a indication */ 337 static int global_quad_port_a; /* global port a indication */
338 struct pci_dev *pdev = adapter->pdev; 338 struct pci_dev *pdev = adapter->pdev;
339 u16 eeprom_data = 0;
340 int is_port_b = er32(STATUS) & E1000_STATUS_FUNC_1; 339 int is_port_b = er32(STATUS) & E1000_STATUS_FUNC_1;
341 s32 rc; 340 s32 rc;
342 341
@@ -387,16 +386,15 @@ static s32 e1000_get_variants_82571(struct e1000_adapter *adapter)
387 if (pdev->device == E1000_DEV_ID_82571EB_SERDES_QUAD) 386 if (pdev->device == E1000_DEV_ID_82571EB_SERDES_QUAD)
388 adapter->flags &= ~FLAG_HAS_WOL; 387 adapter->flags &= ~FLAG_HAS_WOL;
389 break; 388 break;
390
391 case e1000_82573: 389 case e1000_82573:
390 case e1000_82574:
391 case e1000_82583:
392 /* Disable ASPM L0s due to hardware errata */
393 e1000e_disable_aspm(adapter->pdev, PCIE_LINK_STATE_L0S);
394
392 if (pdev->device == E1000_DEV_ID_82573L) { 395 if (pdev->device == E1000_DEV_ID_82573L) {
393 if (e1000_read_nvm(&adapter->hw, NVM_INIT_3GIO_3, 1, 396 adapter->flags |= FLAG_HAS_JUMBO_FRAMES;
394 &eeprom_data) < 0) 397 adapter->max_hw_frame_size = DEFAULT_JUMBO;
395 break;
396 if (!(eeprom_data & NVM_WORD1A_ASPM_MASK)) {
397 adapter->flags |= FLAG_HAS_JUMBO_FRAMES;
398 adapter->max_hw_frame_size = DEFAULT_JUMBO;
399 }
400 } 398 }
401 break; 399 break;
402 default: 400 default:
@@ -1792,6 +1790,7 @@ struct e1000_info e1000_82571_info = {
1792 | FLAG_RESET_OVERWRITES_LAA /* errata */ 1790 | FLAG_RESET_OVERWRITES_LAA /* errata */
1793 | FLAG_TARC_SPEED_MODE_BIT /* errata */ 1791 | FLAG_TARC_SPEED_MODE_BIT /* errata */
1794 | FLAG_APME_CHECK_PORT_B, 1792 | FLAG_APME_CHECK_PORT_B,
1793 .flags2 = FLAG2_DISABLE_ASPM_L1, /* errata 13 */
1795 .pba = 38, 1794 .pba = 38,
1796 .max_hw_frame_size = DEFAULT_JUMBO, 1795 .max_hw_frame_size = DEFAULT_JUMBO,
1797 .get_variants = e1000_get_variants_82571, 1796 .get_variants = e1000_get_variants_82571,
@@ -1809,6 +1808,7 @@ struct e1000_info e1000_82572_info = {
1809 | FLAG_RX_CSUM_ENABLED 1808 | FLAG_RX_CSUM_ENABLED
1810 | FLAG_HAS_CTRLEXT_ON_LOAD 1809 | FLAG_HAS_CTRLEXT_ON_LOAD
1811 | FLAG_TARC_SPEED_MODE_BIT, /* errata */ 1810 | FLAG_TARC_SPEED_MODE_BIT, /* errata */
1811 .flags2 = FLAG2_DISABLE_ASPM_L1, /* errata 13 */
1812 .pba = 38, 1812 .pba = 38,
1813 .max_hw_frame_size = DEFAULT_JUMBO, 1813 .max_hw_frame_size = DEFAULT_JUMBO,
1814 .get_variants = e1000_get_variants_82571, 1814 .get_variants = e1000_get_variants_82571,
@@ -1820,13 +1820,11 @@ struct e1000_info e1000_82572_info = {
1820struct e1000_info e1000_82573_info = { 1820struct e1000_info e1000_82573_info = {
1821 .mac = e1000_82573, 1821 .mac = e1000_82573,
1822 .flags = FLAG_HAS_HW_VLAN_FILTER 1822 .flags = FLAG_HAS_HW_VLAN_FILTER
1823 | FLAG_HAS_JUMBO_FRAMES
1824 | FLAG_HAS_WOL 1823 | FLAG_HAS_WOL
1825 | FLAG_APME_IN_CTRL3 1824 | FLAG_APME_IN_CTRL3
1826 | FLAG_RX_CSUM_ENABLED 1825 | FLAG_RX_CSUM_ENABLED
1827 | FLAG_HAS_SMART_POWER_DOWN 1826 | FLAG_HAS_SMART_POWER_DOWN
1828 | FLAG_HAS_AMT 1827 | FLAG_HAS_AMT
1829 | FLAG_HAS_ERT
1830 | FLAG_HAS_SWSM_ON_LOAD, 1828 | FLAG_HAS_SWSM_ON_LOAD,
1831 .pba = 20, 1829 .pba = 20,
1832 .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN, 1830 .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN,
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index c2ec095d216..ee32b9b27a9 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -37,6 +37,7 @@
37#include <linux/io.h> 37#include <linux/io.h>
38#include <linux/netdevice.h> 38#include <linux/netdevice.h>
39#include <linux/pci.h> 39#include <linux/pci.h>
40#include <linux/pci-aspm.h>
40 41
41#include "hw.h" 42#include "hw.h"
42 43
@@ -279,7 +280,6 @@ struct e1000_adapter {
279 280
280 struct napi_struct napi; 281 struct napi_struct napi;
281 282
282 unsigned long tx_queue_len;
283 unsigned int restart_queue; 283 unsigned int restart_queue;
284 u32 txd_cmd; 284 u32 txd_cmd;
285 285
@@ -375,7 +375,7 @@ struct e1000_adapter {
375struct e1000_info { 375struct e1000_info {
376 enum e1000_mac_type mac; 376 enum e1000_mac_type mac;
377 unsigned int flags; 377 unsigned int flags;
378 unsigned int flags2; 378 unsigned int flags2;
379 u32 pba; 379 u32 pba;
380 u32 max_hw_frame_size; 380 u32 max_hw_frame_size;
381 s32 (*get_variants)(struct e1000_adapter *); 381 s32 (*get_variants)(struct e1000_adapter *);
@@ -422,6 +422,7 @@ struct e1000_info {
422#define FLAG2_CRC_STRIPPING (1 << 0) 422#define FLAG2_CRC_STRIPPING (1 << 0)
423#define FLAG2_HAS_PHY_WAKEUP (1 << 1) 423#define FLAG2_HAS_PHY_WAKEUP (1 << 1)
424#define FLAG2_IS_DISCARDING (1 << 2) 424#define FLAG2_IS_DISCARDING (1 << 2)
425#define FLAG2_DISABLE_ASPM_L1 (1 << 3)
425 426
426#define E1000_RX_DESC_PS(R, i) \ 427#define E1000_RX_DESC_PS(R, i) \
427 (&(((union e1000_rx_desc_packet_split *)((R).desc))[i])) 428 (&(((union e1000_rx_desc_packet_split *)((R).desc))[i]))
@@ -462,6 +463,7 @@ extern void e1000e_update_stats(struct e1000_adapter *adapter);
462extern bool e1000e_has_link(struct e1000_adapter *adapter); 463extern bool e1000e_has_link(struct e1000_adapter *adapter);
463extern void e1000e_set_interrupt_capability(struct e1000_adapter *adapter); 464extern void e1000e_set_interrupt_capability(struct e1000_adapter *adapter);
464extern void e1000e_reset_interrupt_capability(struct e1000_adapter *adapter); 465extern void e1000e_reset_interrupt_capability(struct e1000_adapter *adapter);
466extern void e1000e_disable_aspm(struct pci_dev *pdev, u16 state);
465 467
466extern unsigned int copybreak; 468extern unsigned int copybreak;
467 469
diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c
index b33e3cbe9ab..983493f2330 100644
--- a/drivers/net/e1000e/ethtool.c
+++ b/drivers/net/e1000e/ethtool.c
@@ -31,6 +31,7 @@
31#include <linux/netdevice.h> 31#include <linux/netdevice.h>
32#include <linux/ethtool.h> 32#include <linux/ethtool.h>
33#include <linux/pci.h> 33#include <linux/pci.h>
34#include <linux/slab.h>
34#include <linux/delay.h> 35#include <linux/delay.h>
35 36
36#include "e1000.h" 37#include "e1000.h"
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 88d54d3efce..dbf81788bb4 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -36,6 +36,7 @@
36#include <linux/netdevice.h> 36#include <linux/netdevice.h>
37#include <linux/tcp.h> 37#include <linux/tcp.h>
38#include <linux/ipv6.h> 38#include <linux/ipv6.h>
39#include <linux/slab.h>
39#include <net/checksum.h> 40#include <net/checksum.h>
40#include <net/ip6_checksum.h> 41#include <net/ip6_checksum.h>
41#include <linux/mii.h> 42#include <linux/mii.h>
@@ -660,6 +661,8 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter)
660 i = 0; 661 i = 0;
661 } 662 }
662 663
664 if (i == tx_ring->next_to_use)
665 break;
663 eop = tx_ring->buffer_info[i].next_to_watch; 666 eop = tx_ring->buffer_info[i].next_to_watch;
664 eop_desc = E1000_TX_DESC(*tx_ring, eop); 667 eop_desc = E1000_TX_DESC(*tx_ring, eop);
665 } 668 }
@@ -2289,8 +2292,6 @@ static void e1000_configure_tx(struct e1000_adapter *adapter)
2289 ew32(TCTL, tctl); 2292 ew32(TCTL, tctl);
2290 2293
2291 e1000e_config_collision_dist(hw); 2294 e1000e_config_collision_dist(hw);
2292
2293 adapter->tx_queue_len = adapter->netdev->tx_queue_len;
2294} 2295}
2295 2296
2296/** 2297/**
@@ -2877,7 +2878,6 @@ void e1000e_down(struct e1000_adapter *adapter)
2877 del_timer_sync(&adapter->watchdog_timer); 2878 del_timer_sync(&adapter->watchdog_timer);
2878 del_timer_sync(&adapter->phy_info_timer); 2879 del_timer_sync(&adapter->phy_info_timer);
2879 2880
2880 netdev->tx_queue_len = adapter->tx_queue_len;
2881 netif_carrier_off(netdev); 2881 netif_carrier_off(netdev);
2882 adapter->link_speed = 0; 2882 adapter->link_speed = 0;
2883 adapter->link_duplex = 0; 2883 adapter->link_duplex = 0;
@@ -3588,21 +3588,15 @@ static void e1000_watchdog_task(struct work_struct *work)
3588 "link gets many collisions.\n"); 3588 "link gets many collisions.\n");
3589 } 3589 }
3590 3590
3591 /* 3591 /* adjust timeout factor according to speed/duplex */
3592 * tweak tx_queue_len according to speed/duplex
3593 * and adjust the timeout factor
3594 */
3595 netdev->tx_queue_len = adapter->tx_queue_len;
3596 adapter->tx_timeout_factor = 1; 3592 adapter->tx_timeout_factor = 1;
3597 switch (adapter->link_speed) { 3593 switch (adapter->link_speed) {
3598 case SPEED_10: 3594 case SPEED_10:
3599 txb2b = 0; 3595 txb2b = 0;
3600 netdev->tx_queue_len = 10;
3601 adapter->tx_timeout_factor = 16; 3596 adapter->tx_timeout_factor = 16;
3602 break; 3597 break;
3603 case SPEED_100: 3598 case SPEED_100:
3604 txb2b = 0; 3599 txb2b = 0;
3605 netdev->tx_queue_len = 100;
3606 adapter->tx_timeout_factor = 10; 3600 adapter->tx_timeout_factor = 10;
3607 break; 3601 break;
3608 } 3602 }
@@ -4289,6 +4283,14 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
4289 return -EINVAL; 4283 return -EINVAL;
4290 } 4284 }
4291 4285
4286 /* 82573 Errata 17 */
4287 if (((adapter->hw.mac.type == e1000_82573) ||
4288 (adapter->hw.mac.type == e1000_82574)) &&
4289 (max_frame > ETH_FRAME_LEN + ETH_FCS_LEN)) {
4290 adapter->flags2 |= FLAG2_DISABLE_ASPM_L1;
4291 e1000e_disable_aspm(adapter->pdev, PCIE_LINK_STATE_L1);
4292 }
4293
4292 while (test_and_set_bit(__E1000_RESETTING, &adapter->state)) 4294 while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
4293 msleep(1); 4295 msleep(1);
4294 /* e1000e_down -> e1000e_reset dependent on max_frame_size & mtu */ 4296 /* e1000e_down -> e1000e_reset dependent on max_frame_size & mtu */
@@ -4611,29 +4613,42 @@ static void e1000_complete_shutdown(struct pci_dev *pdev, bool sleep,
4611 } 4613 }
4612} 4614}
4613 4615
4614static void e1000e_disable_l1aspm(struct pci_dev *pdev) 4616#ifdef CONFIG_PCIEASPM
4617static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
4618{
4619 pci_disable_link_state(pdev, state);
4620}
4621#else
4622static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
4615{ 4623{
4616 int pos; 4624 int pos;
4617 u16 val; 4625 u16 reg16;
4618 4626
4619 /* 4627 /*
4620 * 82573 workaround - disable L1 ASPM on mobile chipsets 4628 * Both device and parent should have the same ASPM setting.
4621 * 4629 * Disable ASPM in downstream component first and then upstream.
4622 * L1 ASPM on various mobile (ich7) chipsets do not behave properly
4623 * resulting in lost data or garbage information on the pci-e link
4624 * level. This could result in (false) bad EEPROM checksum errors,
4625 * long ping times (up to 2s) or even a system freeze/hang.
4626 *
4627 * Unfortunately this feature saves about 1W power consumption when
4628 * active.
4629 */ 4630 */
4630 pos = pci_find_capability(pdev, PCI_CAP_ID_EXP); 4631 pos = pci_pcie_cap(pdev);
4631 pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, &val); 4632 pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, &reg16);
4632 if (val & 0x2) { 4633 reg16 &= ~state;
4633 dev_warn(&pdev->dev, "Disabling L1 ASPM\n"); 4634 pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, reg16);
4634 val &= ~0x2; 4635
4635 pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, val); 4636 if (!pdev->bus->self)
4636 } 4637 return;
4638
4639 pos = pci_pcie_cap(pdev->bus->self);
4640 pci_read_config_word(pdev->bus->self, pos + PCI_EXP_LNKCTL, &reg16);
4641 reg16 &= ~state;
4642 pci_write_config_word(pdev->bus->self, pos + PCI_EXP_LNKCTL, reg16);
4643}
4644#endif
4645void e1000e_disable_aspm(struct pci_dev *pdev, u16 state)
4646{
4647 dev_info(&pdev->dev, "Disabling ASPM %s %s\n",
4648 (state & PCIE_LINK_STATE_L0S) ? "L0s" : "",
4649 (state & PCIE_LINK_STATE_L1) ? "L1" : "");
4650
4651 __e1000e_disable_aspm(pdev, state);
4637} 4652}
4638 4653
4639#ifdef CONFIG_PM 4654#ifdef CONFIG_PM
@@ -4659,7 +4674,8 @@ static int e1000_resume(struct pci_dev *pdev)
4659 pci_set_power_state(pdev, PCI_D0); 4674 pci_set_power_state(pdev, PCI_D0);
4660 pci_restore_state(pdev); 4675 pci_restore_state(pdev);
4661 pci_save_state(pdev); 4676 pci_save_state(pdev);
4662 e1000e_disable_l1aspm(pdev); 4677 if (adapter->flags2 & FLAG2_DISABLE_ASPM_L1)
4678 e1000e_disable_aspm(pdev, PCIE_LINK_STATE_L1);
4663 4679
4664 err = pci_enable_device_mem(pdev); 4680 err = pci_enable_device_mem(pdev);
4665 if (err) { 4681 if (err) {
@@ -4801,7 +4817,8 @@ static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
4801 int err; 4817 int err;
4802 pci_ers_result_t result; 4818 pci_ers_result_t result;
4803 4819
4804 e1000e_disable_l1aspm(pdev); 4820 if (adapter->flags2 & FLAG2_DISABLE_ASPM_L1)
4821 e1000e_disable_aspm(pdev, PCIE_LINK_STATE_L1);
4805 err = pci_enable_device_mem(pdev); 4822 err = pci_enable_device_mem(pdev);
4806 if (err) { 4823 if (err) {
4807 dev_err(&pdev->dev, 4824 dev_err(&pdev->dev,
@@ -4895,13 +4912,6 @@ static void e1000_eeprom_checks(struct e1000_adapter *adapter)
4895 dev_warn(&adapter->pdev->dev, 4912 dev_warn(&adapter->pdev->dev,
4896 "Warning: detected DSPD enabled in EEPROM\n"); 4913 "Warning: detected DSPD enabled in EEPROM\n");
4897 } 4914 }
4898
4899 ret_val = e1000_read_nvm(hw, NVM_INIT_3GIO_3, 1, &buf);
4900 if (!ret_val && (le16_to_cpu(buf) & (3 << 2))) {
4901 /* ASPM enable */
4902 dev_warn(&adapter->pdev->dev,
4903 "Warning: detected ASPM enabled in EEPROM\n");
4904 }
4905} 4915}
4906 4916
4907static const struct net_device_ops e1000e_netdev_ops = { 4917static const struct net_device_ops e1000e_netdev_ops = {
@@ -4950,7 +4960,8 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
4950 u16 eeprom_data = 0; 4960 u16 eeprom_data = 0;
4951 u16 eeprom_apme_mask = E1000_EEPROM_APME; 4961 u16 eeprom_apme_mask = E1000_EEPROM_APME;
4952 4962
4953 e1000e_disable_l1aspm(pdev); 4963 if (ei->flags2 & FLAG2_DISABLE_ASPM_L1)
4964 e1000e_disable_aspm(pdev, PCIE_LINK_STATE_L1);
4954 4965
4955 err = pci_enable_device_mem(pdev); 4966 err = pci_enable_device_mem(pdev);
4956 if (err) 4967 if (err)
diff --git a/drivers/net/eepro.c b/drivers/net/eepro.c
index 1b05bdf62c3..27c7bdbfa00 100644
--- a/drivers/net/eepro.c
+++ b/drivers/net/eepro.c
@@ -137,7 +137,6 @@ static const char version[] =
137#include <linux/interrupt.h> 137#include <linux/interrupt.h>
138#include <linux/ioport.h> 138#include <linux/ioport.h>
139#include <linux/in.h> 139#include <linux/in.h>
140#include <linux/slab.h>
141#include <linux/string.h> 140#include <linux/string.h>
142#include <linux/errno.h> 141#include <linux/errno.h>
143#include <linux/netdevice.h> 142#include <linux/netdevice.h>
diff --git a/drivers/net/eexpress.c b/drivers/net/eexpress.c
index 7013dc8a6cb..1a7322b80ea 100644
--- a/drivers/net/eexpress.c
+++ b/drivers/net/eexpress.c
@@ -111,7 +111,6 @@
111#include <linux/netdevice.h> 111#include <linux/netdevice.h>
112#include <linux/etherdevice.h> 112#include <linux/etherdevice.h>
113#include <linux/skbuff.h> 113#include <linux/skbuff.h>
114#include <linux/slab.h>
115#include <linux/mca-legacy.h> 114#include <linux/mca-legacy.h>
116#include <linux/spinlock.h> 115#include <linux/spinlock.h>
117#include <linux/bitops.h> 116#include <linux/bitops.h>
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index b004eaba3d7..809ccc9ff09 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -32,6 +32,7 @@
32#include <linux/udp.h> 32#include <linux/udp.h>
33#include <linux/if.h> 33#include <linux/if.h>
34#include <linux/list.h> 34#include <linux/list.h>
35#include <linux/slab.h>
35#include <linux/if_ether.h> 36#include <linux/if_ether.h>
36#include <linux/notifier.h> 37#include <linux/notifier.h>
37#include <linux/reboot.h> 38#include <linux/reboot.h>
diff --git a/drivers/net/ehea/ehea_qmr.c b/drivers/net/ehea/ehea_qmr.c
index 18d405f78c0..a1b4c7e5636 100644
--- a/drivers/net/ehea/ehea_qmr.c
+++ b/drivers/net/ehea/ehea_qmr.c
@@ -27,6 +27,7 @@
27 */ 27 */
28 28
29#include <linux/mm.h> 29#include <linux/mm.h>
30#include <linux/slab.h>
30#include "ehea.h" 31#include "ehea.h"
31#include "ehea_phyp.h" 32#include "ehea_phyp.h"
32#include "ehea_qmr.h" 33#include "ehea_qmr.h"
diff --git a/drivers/net/enc28j60.c b/drivers/net/enc28j60.c
index 3ee32e58c7e..ff27f728fd9 100644
--- a/drivers/net/enc28j60.c
+++ b/drivers/net/enc28j60.c
@@ -18,7 +18,6 @@
18#include <linux/types.h> 18#include <linux/types.h>
19#include <linux/fcntl.h> 19#include <linux/fcntl.h>
20#include <linux/interrupt.h> 20#include <linux/interrupt.h>
21#include <linux/slab.h>
22#include <linux/string.h> 21#include <linux/string.h>
23#include <linux/errno.h> 22#include <linux/errno.h>
24#include <linux/init.h> 23#include <linux/init.h>
diff --git a/drivers/net/enic/vnic_dev.c b/drivers/net/enic/vnic_dev.c
index 69b9b70c7da..cf22de71014 100644
--- a/drivers/net/enic/vnic_dev.c
+++ b/drivers/net/enic/vnic_dev.c
@@ -23,6 +23,7 @@
23#include <linux/pci.h> 23#include <linux/pci.h>
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/if_ether.h> 25#include <linux/if_ether.h>
26#include <linux/slab.h>
26 27
27#include "vnic_resource.h" 28#include "vnic_resource.h"
28#include "vnic_devcmd.h" 29#include "vnic_devcmd.h"
diff --git a/drivers/net/enic/vnic_rq.c b/drivers/net/enic/vnic_rq.c
index 75583978a5e..e186efaf9da 100644
--- a/drivers/net/enic/vnic_rq.c
+++ b/drivers/net/enic/vnic_rq.c
@@ -22,6 +22,7 @@
22#include <linux/types.h> 22#include <linux/types.h>
23#include <linux/pci.h> 23#include <linux/pci.h>
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/slab.h>
25 26
26#include "vnic_dev.h" 27#include "vnic_dev.h"
27#include "vnic_rq.h" 28#include "vnic_rq.h"
diff --git a/drivers/net/enic/vnic_wq.c b/drivers/net/enic/vnic_wq.c
index d2e00e51b7b..d5f984357f5 100644
--- a/drivers/net/enic/vnic_wq.c
+++ b/drivers/net/enic/vnic_wq.c
@@ -22,6 +22,7 @@
22#include <linux/types.h> 22#include <linux/types.h>
23#include <linux/pci.h> 23#include <linux/pci.h>
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/slab.h>
25 26
26#include "vnic_dev.h" 27#include "vnic_dev.h"
27#include "vnic_wq.h" 28#include "vnic_wq.h"
diff --git a/drivers/net/epic100.c b/drivers/net/epic100.c
index 39c271b6be4..7a567201e82 100644
--- a/drivers/net/epic100.c
+++ b/drivers/net/epic100.c
@@ -73,7 +73,6 @@ static int rx_copybreak;
73#include <linux/timer.h> 73#include <linux/timer.h>
74#include <linux/errno.h> 74#include <linux/errno.h>
75#include <linux/ioport.h> 75#include <linux/ioport.h>
76#include <linux/slab.h>
77#include <linux/interrupt.h> 76#include <linux/interrupt.h>
78#include <linux/pci.h> 77#include <linux/pci.h>
79#include <linux/delay.h> 78#include <linux/delay.h>
diff --git a/drivers/net/eql.c b/drivers/net/eql.c
index f5b96cadeb2..b34a2ddeef4 100644
--- a/drivers/net/eql.c
+++ b/drivers/net/eql.c
@@ -115,6 +115,7 @@
115#include <linux/module.h> 115#include <linux/module.h>
116#include <linux/kernel.h> 116#include <linux/kernel.h>
117#include <linux/init.h> 117#include <linux/init.h>
118#include <linux/slab.h>
118#include <linux/timer.h> 119#include <linux/timer.h>
119#include <linux/netdevice.h> 120#include <linux/netdevice.h>
120#include <net/net_namespace.h> 121#include <net/net_namespace.h>
diff --git a/drivers/net/eth16i.c b/drivers/net/eth16i.c
index d3abeee3f11..d4e24f08b3b 100644
--- a/drivers/net/eth16i.c
+++ b/drivers/net/eth16i.c
@@ -152,7 +152,6 @@ static char *version =
152#include <linux/interrupt.h> 152#include <linux/interrupt.h>
153#include <linux/ioport.h> 153#include <linux/ioport.h>
154#include <linux/in.h> 154#include <linux/in.h>
155#include <linux/slab.h>
156#include <linux/string.h> 155#include <linux/string.h>
157#include <linux/errno.h> 156#include <linux/errno.h>
158#include <linux/init.h> 157#include <linux/init.h>
diff --git a/drivers/net/ethoc.c b/drivers/net/ethoc.c
index 209742304e2..a8d92503226 100644
--- a/drivers/net/ethoc.c
+++ b/drivers/net/ethoc.c
@@ -18,6 +18,7 @@
18#include <linux/phy.h> 18#include <linux/phy.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/sched.h> 20#include <linux/sched.h>
21#include <linux/slab.h>
21#include <net/ethoc.h> 22#include <net/ethoc.h>
22 23
23static int buffer_size = 0x8000; /* 32 KBytes */ 24static int buffer_size = 0x8000; /* 32 KBytes */
diff --git a/drivers/net/fealnx.c b/drivers/net/fealnx.c
index 9d5ad08a119..d11ae5197f0 100644
--- a/drivers/net/fealnx.c
+++ b/drivers/net/fealnx.c
@@ -74,7 +74,6 @@ static int full_duplex[MAX_UNITS] = { -1, -1, -1, -1, -1, -1, -1, -1 };
74#include <linux/timer.h> 74#include <linux/timer.h>
75#include <linux/errno.h> 75#include <linux/errno.h>
76#include <linux/ioport.h> 76#include <linux/ioport.h>
77#include <linux/slab.h>
78#include <linux/interrupt.h> 77#include <linux/interrupt.h>
79#include <linux/pci.h> 78#include <linux/pci.h>
80#include <linux/netdevice.h> 79#include <linux/netdevice.h>
diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index 9f98c1c4a34..9b4e8f797a7 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -1653,7 +1653,7 @@ fec_set_mac_address(struct net_device *dev, void *p)
1653 (dev->dev_addr[1] << 16) | (dev->dev_addr[0] << 24), 1653 (dev->dev_addr[1] << 16) | (dev->dev_addr[0] << 24),
1654 fep->hwp + FEC_ADDR_LOW); 1654 fep->hwp + FEC_ADDR_LOW);
1655 writel((dev->dev_addr[5] << 16) | (dev->dev_addr[4] << 24), 1655 writel((dev->dev_addr[5] << 16) | (dev->dev_addr[4] << 24),
1656 fep + FEC_ADDR_HIGH); 1656 fep->hwp + FEC_ADDR_HIGH);
1657 return 0; 1657 return 0;
1658} 1658}
1659 1659
diff --git a/drivers/net/fec_mpc52xx.c b/drivers/net/fec_mpc52xx.c
index 0dbd7219bbd..4a43e56b739 100644
--- a/drivers/net/fec_mpc52xx.c
+++ b/drivers/net/fec_mpc52xx.c
@@ -19,6 +19,7 @@
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/types.h> 20#include <linux/types.h>
21#include <linux/spinlock.h> 21#include <linux/spinlock.h>
22#include <linux/slab.h>
22#include <linux/errno.h> 23#include <linux/errno.h>
23#include <linux/init.h> 24#include <linux/init.h>
24#include <linux/crc32.h> 25#include <linux/crc32.h>
diff --git a/drivers/net/fec_mpc52xx_phy.c b/drivers/net/fec_mpc52xx_phy.c
index ee0f3c6d3f8..7658a082e39 100644
--- a/drivers/net/fec_mpc52xx_phy.c
+++ b/drivers/net/fec_mpc52xx_phy.c
@@ -14,6 +14,7 @@
14#include <linux/netdevice.h> 14#include <linux/netdevice.h>
15#include <linux/phy.h> 15#include <linux/phy.h>
16#include <linux/of_platform.h> 16#include <linux/of_platform.h>
17#include <linux/slab.h>
17#include <linux/of_mdio.h> 18#include <linux/of_mdio.h>
18#include <asm/io.h> 19#include <asm/io.h>
19#include <asm/mpc52xx.h> 20#include <asm/mpc52xx.h>
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index ca05e566202..5c98f7c2242 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -59,6 +59,7 @@
59#include <linux/init.h> 59#include <linux/init.h>
60#include <linux/if_vlan.h> 60#include <linux/if_vlan.h>
61#include <linux/dma-mapping.h> 61#include <linux/dma-mapping.h>
62#include <linux/slab.h>
62 63
63#include <asm/irq.h> 64#include <asm/irq.h>
64#include <asm/io.h> 65#include <asm/io.h>
@@ -5898,7 +5899,7 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
5898 /* Limit the number of tx's outstanding for hw bug */ 5899 /* Limit the number of tx's outstanding for hw bug */
5899 if (id->driver_data & DEV_NEED_TX_LIMIT) { 5900 if (id->driver_data & DEV_NEED_TX_LIMIT) {
5900 np->tx_limit = 1; 5901 np->tx_limit = 1;
5901 if ((id->driver_data & DEV_NEED_TX_LIMIT2) && 5902 if (((id->driver_data & DEV_NEED_TX_LIMIT2) == DEV_NEED_TX_LIMIT2) &&
5902 pci_dev->revision >= 0xA2) 5903 pci_dev->revision >= 0xA2)
5903 np->tx_limit = 0; 5904 np->tx_limit = 0;
5904 } 5905 }
diff --git a/drivers/net/fs_enet/mac-fcc.c b/drivers/net/fs_enet/mac-fcc.c
index cf4f674f9e2..0a973e71876 100644
--- a/drivers/net/fs_enet/mac-fcc.c
+++ b/drivers/net/fs_enet/mac-fcc.c
@@ -19,7 +19,6 @@
19#include <linux/ptrace.h> 19#include <linux/ptrace.h>
20#include <linux/errno.h> 20#include <linux/errno.h>
21#include <linux/ioport.h> 21#include <linux/ioport.h>
22#include <linux/slab.h>
23#include <linux/interrupt.h> 22#include <linux/interrupt.h>
24#include <linux/init.h> 23#include <linux/init.h>
25#include <linux/delay.h> 24#include <linux/delay.h>
@@ -34,6 +33,7 @@
34#include <linux/platform_device.h> 33#include <linux/platform_device.h>
35#include <linux/phy.h> 34#include <linux/phy.h>
36#include <linux/of_device.h> 35#include <linux/of_device.h>
36#include <linux/gfp.h>
37 37
38#include <asm/immap_cpm2.h> 38#include <asm/immap_cpm2.h>
39#include <asm/mpc8260.h> 39#include <asm/mpc8260.h>
diff --git a/drivers/net/fs_enet/mac-fec.c b/drivers/net/fs_enet/mac-fec.c
index cd2c6cca5f2..ec81f50d591 100644
--- a/drivers/net/fs_enet/mac-fec.c
+++ b/drivers/net/fs_enet/mac-fec.c
@@ -19,7 +19,6 @@
19#include <linux/ptrace.h> 19#include <linux/ptrace.h>
20#include <linux/errno.h> 20#include <linux/errno.h>
21#include <linux/ioport.h> 21#include <linux/ioport.h>
22#include <linux/slab.h>
23#include <linux/interrupt.h> 22#include <linux/interrupt.h>
24#include <linux/init.h> 23#include <linux/init.h>
25#include <linux/delay.h> 24#include <linux/delay.h>
@@ -33,6 +32,7 @@
33#include <linux/fs.h> 32#include <linux/fs.h>
34#include <linux/platform_device.h> 33#include <linux/platform_device.h>
35#include <linux/of_device.h> 34#include <linux/of_device.h>
35#include <linux/gfp.h>
36 36
37#include <asm/irq.h> 37#include <asm/irq.h>
38#include <asm/uaccess.h> 38#include <asm/uaccess.h>
diff --git a/drivers/net/fs_enet/mac-scc.c b/drivers/net/fs_enet/mac-scc.c
index c490a466cae..34d3da751eb 100644
--- a/drivers/net/fs_enet/mac-scc.c
+++ b/drivers/net/fs_enet/mac-scc.c
@@ -19,7 +19,6 @@
19#include <linux/ptrace.h> 19#include <linux/ptrace.h>
20#include <linux/errno.h> 20#include <linux/errno.h>
21#include <linux/ioport.h> 21#include <linux/ioport.h>
22#include <linux/slab.h>
23#include <linux/interrupt.h> 22#include <linux/interrupt.h>
24#include <linux/init.h> 23#include <linux/init.h>
25#include <linux/delay.h> 24#include <linux/delay.h>
diff --git a/drivers/net/fsl_pq_mdio.c b/drivers/net/fsl_pq_mdio.c
index d5160edf2fc..3acac5f930c 100644
--- a/drivers/net/fsl_pq_mdio.c
+++ b/drivers/net/fsl_pq_mdio.c
@@ -205,8 +205,6 @@ static int fsl_pq_mdio_find_free(struct mii_bus *new_bus)
205static u32 __iomem *get_gfar_tbipa(struct fsl_pq_mdio __iomem *regs, struct device_node *np) 205static u32 __iomem *get_gfar_tbipa(struct fsl_pq_mdio __iomem *regs, struct device_node *np)
206{ 206{
207 struct gfar __iomem *enet_regs; 207 struct gfar __iomem *enet_regs;
208 u32 __iomem *ioremap_tbipa;
209 u64 addr, size;
210 208
211 /* 209 /*
212 * This is mildly evil, but so is our hardware for doing this. 210 * This is mildly evil, but so is our hardware for doing this.
@@ -220,9 +218,7 @@ static u32 __iomem *get_gfar_tbipa(struct fsl_pq_mdio __iomem *regs, struct devi
220 return &enet_regs->tbipa; 218 return &enet_regs->tbipa;
221 } else if (of_device_is_compatible(np, "fsl,etsec2-mdio") || 219 } else if (of_device_is_compatible(np, "fsl,etsec2-mdio") ||
222 of_device_is_compatible(np, "fsl,etsec2-tbi")) { 220 of_device_is_compatible(np, "fsl,etsec2-tbi")) {
223 addr = of_translate_address(np, of_get_address(np, 1, &size, NULL)); 221 return of_iomap(np, 1);
224 ioremap_tbipa = ioremap(addr, size);
225 return ioremap_tbipa;
226 } else 222 } else
227 return NULL; 223 return NULL;
228} 224}
@@ -279,6 +275,7 @@ static int fsl_pq_mdio_probe(struct of_device *ofdev,
279 u32 __iomem *tbipa; 275 u32 __iomem *tbipa;
280 struct mii_bus *new_bus; 276 struct mii_bus *new_bus;
281 int tbiaddr = -1; 277 int tbiaddr = -1;
278 const u32 *addrp;
282 u64 addr = 0, size = 0; 279 u64 addr = 0, size = 0;
283 int err = 0; 280 int err = 0;
284 281
@@ -297,8 +294,19 @@ static int fsl_pq_mdio_probe(struct of_device *ofdev,
297 new_bus->priv = priv; 294 new_bus->priv = priv;
298 fsl_pq_mdio_bus_name(new_bus->id, np); 295 fsl_pq_mdio_bus_name(new_bus->id, np);
299 296
297 addrp = of_get_address(np, 0, &size, NULL);
298 if (!addrp) {
299 err = -EINVAL;
300 goto err_free_bus;
301 }
302
300 /* Set the PHY base address */ 303 /* Set the PHY base address */
301 addr = of_translate_address(np, of_get_address(np, 0, &size, NULL)); 304 addr = of_translate_address(np, addrp);
305 if (addr == OF_BAD_ADDR) {
306 err = -EINVAL;
307 goto err_free_bus;
308 }
309
302 map = ioremap(addr, size); 310 map = ioremap(addr, size);
303 if (!map) { 311 if (!map) {
304 err = -ENOMEM; 312 err = -ENOMEM;
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index b6715553cf1..4e97ca18299 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -549,12 +549,8 @@ static int gfar_parse_group(struct device_node *np,
549 struct gfar_private *priv, const char *model) 549 struct gfar_private *priv, const char *model)
550{ 550{
551 u32 *queue_mask; 551 u32 *queue_mask;
552 u64 addr, size;
553
554 addr = of_translate_address(np,
555 of_get_address(np, 0, &size, NULL));
556 priv->gfargrp[priv->num_grps].regs = ioremap(addr, size);
557 552
553 priv->gfargrp[priv->num_grps].regs = of_iomap(np, 0);
558 if (!priv->gfargrp[priv->num_grps].regs) 554 if (!priv->gfargrp[priv->num_grps].regs)
559 return -ENOMEM; 555 return -ENOMEM;
560 556
@@ -676,7 +672,7 @@ static int gfar_of_init(struct of_device *ofdev, struct net_device **pdev)
676 priv->rx_queue[i] = NULL; 672 priv->rx_queue[i] = NULL;
677 673
678 for (i = 0; i < priv->num_tx_queues; i++) { 674 for (i = 0; i < priv->num_tx_queues; i++) {
679 priv->tx_queue[i] = (struct gfar_priv_tx_q *)kmalloc( 675 priv->tx_queue[i] = (struct gfar_priv_tx_q *)kzalloc(
680 sizeof (struct gfar_priv_tx_q), GFP_KERNEL); 676 sizeof (struct gfar_priv_tx_q), GFP_KERNEL);
681 if (!priv->tx_queue[i]) { 677 if (!priv->tx_queue[i]) {
682 err = -ENOMEM; 678 err = -ENOMEM;
@@ -689,7 +685,7 @@ static int gfar_of_init(struct of_device *ofdev, struct net_device **pdev)
689 } 685 }
690 686
691 for (i = 0; i < priv->num_rx_queues; i++) { 687 for (i = 0; i < priv->num_rx_queues; i++) {
692 priv->rx_queue[i] = (struct gfar_priv_rx_q *)kmalloc( 688 priv->rx_queue[i] = (struct gfar_priv_rx_q *)kzalloc(
693 sizeof (struct gfar_priv_rx_q), GFP_KERNEL); 689 sizeof (struct gfar_priv_rx_q), GFP_KERNEL);
694 if (!priv->rx_queue[i]) { 690 if (!priv->rx_queue[i]) {
695 err = -ENOMEM; 691 err = -ENOMEM;
@@ -1120,10 +1116,10 @@ static int gfar_probe(struct of_device *ofdev,
1120 /* provided which set of benchmarks. */ 1116 /* provided which set of benchmarks. */
1121 printk(KERN_INFO "%s: Running with NAPI enabled\n", dev->name); 1117 printk(KERN_INFO "%s: Running with NAPI enabled\n", dev->name);
1122 for (i = 0; i < priv->num_rx_queues; i++) 1118 for (i = 0; i < priv->num_rx_queues; i++)
1123 printk(KERN_INFO "%s: :RX BD ring size for Q[%d]: %d\n", 1119 printk(KERN_INFO "%s: RX BD ring size for Q[%d]: %d\n",
1124 dev->name, i, priv->rx_queue[i]->rx_ring_size); 1120 dev->name, i, priv->rx_queue[i]->rx_ring_size);
1125 for(i = 0; i < priv->num_tx_queues; i++) 1121 for(i = 0; i < priv->num_tx_queues; i++)
1126 printk(KERN_INFO "%s:TX BD ring size for Q[%d]: %d\n", 1122 printk(KERN_INFO "%s: TX BD ring size for Q[%d]: %d\n",
1127 dev->name, i, priv->tx_queue[i]->tx_ring_size); 1123 dev->name, i, priv->tx_queue[i]->tx_ring_size);
1128 1124
1129 return 0; 1125 return 0;
@@ -1515,9 +1511,9 @@ static void gfar_halt_nodisable(struct net_device *dev)
1515 tempval |= (DMACTRL_GRS | DMACTRL_GTS); 1511 tempval |= (DMACTRL_GRS | DMACTRL_GTS);
1516 gfar_write(&regs->dmactrl, tempval); 1512 gfar_write(&regs->dmactrl, tempval);
1517 1513
1518 while (!(gfar_read(&regs->ievent) & 1514 spin_event_timeout(((gfar_read(&regs->ievent) &
1519 (IEVENT_GRSC | IEVENT_GTSC))) 1515 (IEVENT_GRSC | IEVENT_GTSC)) ==
1520 cpu_relax(); 1516 (IEVENT_GRSC | IEVENT_GTSC)), -1, 0);
1521 } 1517 }
1522} 1518}
1523 1519
@@ -1638,13 +1634,13 @@ static void free_skb_resources(struct gfar_private *priv)
1638 /* Go through all the buffer descriptors and free their data buffers */ 1634 /* Go through all the buffer descriptors and free their data buffers */
1639 for (i = 0; i < priv->num_tx_queues; i++) { 1635 for (i = 0; i < priv->num_tx_queues; i++) {
1640 tx_queue = priv->tx_queue[i]; 1636 tx_queue = priv->tx_queue[i];
1641 if(!tx_queue->tx_skbuff) 1637 if(tx_queue->tx_skbuff)
1642 free_skb_tx_queue(tx_queue); 1638 free_skb_tx_queue(tx_queue);
1643 } 1639 }
1644 1640
1645 for (i = 0; i < priv->num_rx_queues; i++) { 1641 for (i = 0; i < priv->num_rx_queues; i++) {
1646 rx_queue = priv->rx_queue[i]; 1642 rx_queue = priv->rx_queue[i];
1647 if(!rx_queue->rx_skbuff) 1643 if(rx_queue->rx_skbuff)
1648 free_skb_rx_queue(rx_queue); 1644 free_skb_rx_queue(rx_queue);
1649 } 1645 }
1650 1646
@@ -2393,6 +2389,7 @@ struct sk_buff * gfar_new_skb(struct net_device *dev)
2393 * as many bytes as needed to align the data properly 2389 * as many bytes as needed to align the data properly
2394 */ 2390 */
2395 skb_reserve(skb, alignamount); 2391 skb_reserve(skb, alignamount);
2392 GFAR_CB(skb)->alignamount = alignamount;
2396 2393
2397 return skb; 2394 return skb;
2398} 2395}
@@ -2533,13 +2530,13 @@ int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue, int rx_work_limit)
2533 newskb = skb; 2530 newskb = skb;
2534 else if (skb) { 2531 else if (skb) {
2535 /* 2532 /*
2536 * We need to reset ->data to what it 2533 * We need to un-reserve() the skb to what it
2537 * was before gfar_new_skb() re-aligned 2534 * was before gfar_new_skb() re-aligned
2538 * it to an RXBUF_ALIGNMENT boundary 2535 * it to an RXBUF_ALIGNMENT boundary
2539 * before we put the skb back on the 2536 * before we put the skb back on the
2540 * recycle list. 2537 * recycle list.
2541 */ 2538 */
2542 skb->data = skb->head + NET_SKB_PAD; 2539 skb_reserve(skb, -GFAR_CB(skb)->alignamount);
2543 __skb_queue_head(&priv->rx_recycle, skb); 2540 __skb_queue_head(&priv->rx_recycle, skb);
2544 } 2541 }
2545 } else { 2542 } else {
diff --git a/drivers/net/gianfar.h b/drivers/net/gianfar.h
index 3d72dc43dca..17d25e71423 100644
--- a/drivers/net/gianfar.h
+++ b/drivers/net/gianfar.h
@@ -566,6 +566,12 @@ struct rxfcb {
566 u16 vlctl; /* VLAN control word */ 566 u16 vlctl; /* VLAN control word */
567}; 567};
568 568
569struct gianfar_skb_cb {
570 int alignamount;
571};
572
573#define GFAR_CB(skb) ((struct gianfar_skb_cb *)((skb)->cb))
574
569struct rmon_mib 575struct rmon_mib
570{ 576{
571 u32 tr64; /* 0x.680 - Transmit and Receive 64-byte Frame Counter */ 577 u32 tr64; /* 0x.680 - Transmit and Receive 64-byte Frame Counter */
diff --git a/drivers/net/gianfar_ethtool.c b/drivers/net/gianfar_ethtool.c
index 1010367695e..9bda023c023 100644
--- a/drivers/net/gianfar_ethtool.c
+++ b/drivers/net/gianfar_ethtool.c
@@ -19,7 +19,6 @@
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/string.h> 20#include <linux/string.h>
21#include <linux/errno.h> 21#include <linux/errno.h>
22#include <linux/slab.h>
23#include <linux/interrupt.h> 22#include <linux/interrupt.h>
24#include <linux/init.h> 23#include <linux/init.h>
25#include <linux/delay.h> 24#include <linux/delay.h>
diff --git a/drivers/net/gianfar_sysfs.c b/drivers/net/gianfar_sysfs.c
index b98c6c51229..64f4094ac7f 100644
--- a/drivers/net/gianfar_sysfs.c
+++ b/drivers/net/gianfar_sysfs.c
@@ -24,7 +24,6 @@
24#include <linux/string.h> 24#include <linux/string.h>
25#include <linux/errno.h> 25#include <linux/errno.h>
26#include <linux/unistd.h> 26#include <linux/unistd.h>
27#include <linux/slab.h>
28#include <linux/init.h> 27#include <linux/init.h>
29#include <linux/delay.h> 28#include <linux/delay.h>
30#include <linux/etherdevice.h> 29#include <linux/etherdevice.h>
diff --git a/drivers/net/greth.c b/drivers/net/greth.c
index 2b9c1cbc9ec..3a90430de91 100644
--- a/drivers/net/greth.c
+++ b/drivers/net/greth.c
@@ -34,6 +34,7 @@
34#include <linux/mii.h> 34#include <linux/mii.h>
35#include <linux/of_device.h> 35#include <linux/of_device.h>
36#include <linux/of_platform.h> 36#include <linux/of_platform.h>
37#include <linux/slab.h>
37#include <asm/cacheflush.h> 38#include <asm/cacheflush.h>
38#include <asm/byteorder.h> 39#include <asm/byteorder.h>
39 40
diff --git a/drivers/net/hamachi.c b/drivers/net/hamachi.c
index 373546dd083..5d6f1387959 100644
--- a/drivers/net/hamachi.c
+++ b/drivers/net/hamachi.c
@@ -153,7 +153,6 @@ static int tx_params[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};
153#include <linux/time.h> 153#include <linux/time.h>
154#include <linux/errno.h> 154#include <linux/errno.h>
155#include <linux/ioport.h> 155#include <linux/ioport.h>
156#include <linux/slab.h>
157#include <linux/interrupt.h> 156#include <linux/interrupt.h>
158#include <linux/pci.h> 157#include <linux/pci.h>
159#include <linux/init.h> 158#include <linux/init.h>
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 689b9bd377a..4b52c767ad0 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -24,6 +24,7 @@
24#include <linux/errno.h> 24#include <linux/errno.h>
25#include <linux/netdevice.h> 25#include <linux/netdevice.h>
26#include <linux/timer.h> 26#include <linux/timer.h>
27#include <linux/slab.h>
27#include <net/ax25.h> 28#include <net/ax25.h>
28#include <linux/etherdevice.h> 29#include <linux/etherdevice.h>
29#include <linux/skbuff.h> 30#include <linux/skbuff.h>
diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
index bdadf3e23c9..14f01d156db 100644
--- a/drivers/net/hamradio/bpqether.c
+++ b/drivers/net/hamradio/bpqether.c
@@ -61,6 +61,7 @@
61#include <linux/kernel.h> 61#include <linux/kernel.h>
62#include <linux/string.h> 62#include <linux/string.h>
63#include <linux/net.h> 63#include <linux/net.h>
64#include <linux/slab.h>
64#include <net/ax25.h> 65#include <net/ax25.h>
65#include <linux/inet.h> 66#include <linux/inet.h>
66#include <linux/netdevice.h> 67#include <linux/netdevice.h>
diff --git a/drivers/net/hamradio/dmascc.c b/drivers/net/hamradio/dmascc.c
index 9ee76b42668..52b14256e2c 100644
--- a/drivers/net/hamradio/dmascc.c
+++ b/drivers/net/hamradio/dmascc.c
@@ -32,6 +32,7 @@
32#include <linux/kernel.h> 32#include <linux/kernel.h>
33#include <linux/mm.h> 33#include <linux/mm.h>
34#include <linux/netdevice.h> 34#include <linux/netdevice.h>
35#include <linux/slab.h>
35#include <linux/rtnetlink.h> 36#include <linux/rtnetlink.h>
36#include <linux/sockios.h> 37#include <linux/sockios.h>
37#include <linux/workqueue.h> 38#include <linux/workqueue.h>
diff --git a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c
index 91c5790c958..b8bdf9d51cd 100644
--- a/drivers/net/hamradio/hdlcdrv.c
+++ b/drivers/net/hamradio/hdlcdrv.c
@@ -48,7 +48,6 @@
48#include <linux/net.h> 48#include <linux/net.h>
49#include <linux/in.h> 49#include <linux/in.h>
50#include <linux/if.h> 50#include <linux/if.h>
51#include <linux/slab.h>
52#include <linux/errno.h> 51#include <linux/errno.h>
53#include <linux/init.h> 52#include <linux/init.h>
54#include <linux/bitops.h> 53#include <linux/bitops.h>
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index 7db0a1c3216..66e88bd59ca 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -26,6 +26,7 @@
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/in.h> 27#include <linux/in.h>
28#include <linux/inet.h> 28#include <linux/inet.h>
29#include <linux/slab.h>
29#include <linux/tty.h> 30#include <linux/tty.h>
30#include <linux/errno.h> 31#include <linux/errno.h>
31#include <linux/netdevice.h> 32#include <linux/netdevice.h>
diff --git a/drivers/net/hamradio/scc.c b/drivers/net/hamradio/scc.c
index 35c936175bb..f3a96b84391 100644
--- a/drivers/net/hamradio/scc.c
+++ b/drivers/net/hamradio/scc.c
@@ -158,7 +158,6 @@
158#include <linux/in.h> 158#include <linux/in.h>
159#include <linux/fcntl.h> 159#include <linux/fcntl.h>
160#include <linux/ptrace.h> 160#include <linux/ptrace.h>
161#include <linux/slab.h>
162#include <linux/delay.h> 161#include <linux/delay.h>
163#include <linux/skbuff.h> 162#include <linux/skbuff.h>
164#include <linux/netdevice.h> 163#include <linux/netdevice.h>
diff --git a/drivers/net/hp100.c b/drivers/net/hp100.c
index b766a69bf0c..4daad8cd56e 100644
--- a/drivers/net/hp100.c
+++ b/drivers/net/hp100.c
@@ -102,7 +102,6 @@
102#include <linux/string.h> 102#include <linux/string.h>
103#include <linux/errno.h> 103#include <linux/errno.h>
104#include <linux/ioport.h> 104#include <linux/ioport.h>
105#include <linux/slab.h>
106#include <linux/interrupt.h> 105#include <linux/interrupt.h>
107#include <linux/eisa.h> 106#include <linux/eisa.h>
108#include <linux/pci.h> 107#include <linux/pci.h>
diff --git a/drivers/net/hplance.c b/drivers/net/hplance.c
index 3e3528ade25..b6060f7538d 100644
--- a/drivers/net/hplance.c
+++ b/drivers/net/hplance.c
@@ -10,7 +10,6 @@
10#include <linux/types.h> 10#include <linux/types.h>
11#include <linux/interrupt.h> 11#include <linux/interrupt.h>
12#include <linux/ioport.h> 12#include <linux/ioport.h>
13#include <linux/slab.h>
14#include <linux/string.h> 13#include <linux/string.h>
15#include <linux/delay.h> 14#include <linux/delay.h>
16#include <linux/init.h> 15#include <linux/init.h>
diff --git a/drivers/net/hydra.c b/drivers/net/hydra.c
index d496b6f4a47..24724b4ad70 100644
--- a/drivers/net/hydra.c
+++ b/drivers/net/hydra.c
@@ -17,7 +17,6 @@
17#include <linux/string.h> 17#include <linux/string.h>
18#include <linux/errno.h> 18#include <linux/errno.h>
19#include <linux/ioport.h> 19#include <linux/ioport.h>
20#include <linux/slab.h>
21#include <linux/interrupt.h> 20#include <linux/interrupt.h>
22#include <linux/netdevice.h> 21#include <linux/netdevice.h>
23#include <linux/etherdevice.h> 22#include <linux/etherdevice.h>
diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c
index fb0ac6d7c04..dd873cc41c2 100644
--- a/drivers/net/ibm_newemac/core.c
+++ b/drivers/net/ibm_newemac/core.c
@@ -39,6 +39,7 @@
39#include <linux/bitops.h> 39#include <linux/bitops.h>
40#include <linux/workqueue.h> 40#include <linux/workqueue.h>
41#include <linux/of.h> 41#include <linux/of.h>
42#include <linux/slab.h>
42 43
43#include <asm/processor.h> 44#include <asm/processor.h>
44#include <asm/io.h> 45#include <asm/io.h>
diff --git a/drivers/net/ibm_newemac/core.h b/drivers/net/ibm_newemac/core.h
index 18d56c6c423..b1cbe6fdfc7 100644
--- a/drivers/net/ibm_newemac/core.h
+++ b/drivers/net/ibm_newemac/core.h
@@ -34,6 +34,7 @@
34#include <linux/dma-mapping.h> 34#include <linux/dma-mapping.h>
35#include <linux/spinlock.h> 35#include <linux/spinlock.h>
36#include <linux/of_platform.h> 36#include <linux/of_platform.h>
37#include <linux/slab.h>
37 38
38#include <asm/io.h> 39#include <asm/io.h>
39#include <asm/dcr.h> 40#include <asm/dcr.h>
diff --git a/drivers/net/ibm_newemac/mal.c b/drivers/net/ibm_newemac/mal.c
index 2a2fc17b287..5b3d94419fe 100644
--- a/drivers/net/ibm_newemac/mal.c
+++ b/drivers/net/ibm_newemac/mal.c
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28#include <linux/delay.h> 28#include <linux/delay.h>
29#include <linux/slab.h>
29 30
30#include "core.h" 31#include "core.h"
31#include <asm/dcr-regs.h> 32#include <asm/dcr-regs.h>
diff --git a/drivers/net/ibm_newemac/rgmii.c b/drivers/net/ibm_newemac/rgmii.c
index 8d76cb89dbd..5b90d34c845 100644
--- a/drivers/net/ibm_newemac/rgmii.c
+++ b/drivers/net/ibm_newemac/rgmii.c
@@ -21,6 +21,7 @@
21 * option) any later version. 21 * option) any later version.
22 * 22 *
23 */ 23 */
24#include <linux/slab.h>
24#include <linux/kernel.h> 25#include <linux/kernel.h>
25#include <linux/ethtool.h> 26#include <linux/ethtool.h>
26#include <asm/io.h> 27#include <asm/io.h>
diff --git a/drivers/net/ibm_newemac/zmii.c b/drivers/net/ibm_newemac/zmii.c
index 17b15412494..1f038f808ab 100644
--- a/drivers/net/ibm_newemac/zmii.c
+++ b/drivers/net/ibm_newemac/zmii.c
@@ -21,6 +21,7 @@
21 * option) any later version. 21 * option) any later version.
22 * 22 *
23 */ 23 */
24#include <linux/slab.h>
24#include <linux/kernel.h> 25#include <linux/kernel.h>
25#include <linux/ethtool.h> 26#include <linux/ethtool.h>
26#include <asm/io.h> 27#include <asm/io.h>
diff --git a/drivers/net/ibmlana.c b/drivers/net/ibmlana.c
index b5d0f4e973f..7d6cf3340c1 100644
--- a/drivers/net/ibmlana.c
+++ b/drivers/net/ibmlana.c
@@ -79,7 +79,6 @@ History:
79#include <linux/string.h> 79#include <linux/string.h>
80#include <linux/errno.h> 80#include <linux/errno.h>
81#include <linux/ioport.h> 81#include <linux/ioport.h>
82#include <linux/slab.h>
83#include <linux/interrupt.h> 82#include <linux/interrupt.h>
84#include <linux/delay.h> 83#include <linux/delay.h>
85#include <linux/time.h> 84#include <linux/time.h>
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
index 0bc777bac9b..cd508a8ee25 100644
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -49,6 +49,7 @@
49#include <linux/proc_fs.h> 49#include <linux/proc_fs.h>
50#include <linux/in.h> 50#include <linux/in.h>
51#include <linux/ip.h> 51#include <linux/ip.h>
52#include <linux/slab.h>
52#include <net/net_namespace.h> 53#include <net/net_namespace.h>
53#include <asm/hvcall.h> 54#include <asm/hvcall.h>
54#include <asm/atomic.h> 55#include <asm/atomic.h>
diff --git a/drivers/net/igb/e1000_82575.c b/drivers/net/igb/e1000_82575.c
index 9d7fa2fb85e..4a32bed77c7 100644
--- a/drivers/net/igb/e1000_82575.c
+++ b/drivers/net/igb/e1000_82575.c
@@ -30,7 +30,6 @@
30 */ 30 */
31 31
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/slab.h>
34#include <linux/if_ether.h> 33#include <linux/if_ether.h>
35 34
36#include "e1000_mac.h" 35#include "e1000_mac.h"
@@ -94,6 +93,7 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw)
94 case E1000_DEV_ID_82576_FIBER: 93 case E1000_DEV_ID_82576_FIBER:
95 case E1000_DEV_ID_82576_SERDES: 94 case E1000_DEV_ID_82576_SERDES:
96 case E1000_DEV_ID_82576_QUAD_COPPER: 95 case E1000_DEV_ID_82576_QUAD_COPPER:
96 case E1000_DEV_ID_82576_QUAD_COPPER_ET2:
97 case E1000_DEV_ID_82576_SERDES_QUAD: 97 case E1000_DEV_ID_82576_SERDES_QUAD:
98 mac->type = e1000_82576; 98 mac->type = e1000_82576;
99 break; 99 break;
diff --git a/drivers/net/igb/e1000_hw.h b/drivers/net/igb/e1000_hw.h
index 448005276b2..82a533f5192 100644
--- a/drivers/net/igb/e1000_hw.h
+++ b/drivers/net/igb/e1000_hw.h
@@ -41,6 +41,7 @@ struct e1000_hw;
41#define E1000_DEV_ID_82576_FIBER 0x10E6 41#define E1000_DEV_ID_82576_FIBER 0x10E6
42#define E1000_DEV_ID_82576_SERDES 0x10E7 42#define E1000_DEV_ID_82576_SERDES 0x10E7
43#define E1000_DEV_ID_82576_QUAD_COPPER 0x10E8 43#define E1000_DEV_ID_82576_QUAD_COPPER 0x10E8
44#define E1000_DEV_ID_82576_QUAD_COPPER_ET2 0x1526
44#define E1000_DEV_ID_82576_NS 0x150A 45#define E1000_DEV_ID_82576_NS 0x150A
45#define E1000_DEV_ID_82576_NS_SERDES 0x1518 46#define E1000_DEV_ID_82576_NS_SERDES 0x1518
46#define E1000_DEV_ID_82576_SERDES_QUAD 0x150D 47#define E1000_DEV_ID_82576_SERDES_QUAD 0x150D
diff --git a/drivers/net/igb/e1000_mac.c b/drivers/net/igb/e1000_mac.c
index 2a8a886b37e..be8d010e402 100644
--- a/drivers/net/igb/e1000_mac.c
+++ b/drivers/net/igb/e1000_mac.c
@@ -1367,7 +1367,8 @@ out:
1367 * igb_enable_mng_pass_thru - Enable processing of ARP's 1367 * igb_enable_mng_pass_thru - Enable processing of ARP's
1368 * @hw: pointer to the HW structure 1368 * @hw: pointer to the HW structure
1369 * 1369 *
1370 * Verifies the hardware needs to allow ARPs to be processed by the host. 1370 * Verifies the hardware needs to leave interface enabled so that frames can
1371 * be directed to and from the management interface.
1371 **/ 1372 **/
1372bool igb_enable_mng_pass_thru(struct e1000_hw *hw) 1373bool igb_enable_mng_pass_thru(struct e1000_hw *hw)
1373{ 1374{
@@ -1380,8 +1381,7 @@ bool igb_enable_mng_pass_thru(struct e1000_hw *hw)
1380 1381
1381 manc = rd32(E1000_MANC); 1382 manc = rd32(E1000_MANC);
1382 1383
1383 if (!(manc & E1000_MANC_RCV_TCO_EN) || 1384 if (!(manc & E1000_MANC_RCV_TCO_EN))
1384 !(manc & E1000_MANC_EN_MAC_ADDR_FILTER))
1385 goto out; 1385 goto out;
1386 1386
1387 if (hw->mac.arc_subsystem_valid) { 1387 if (hw->mac.arc_subsystem_valid) {
diff --git a/drivers/net/igb/igb.h b/drivers/net/igb/igb.h
index a1775705b24..3b772b822a5 100644
--- a/drivers/net/igb/igb.h
+++ b/drivers/net/igb/igb.h
@@ -267,7 +267,6 @@ struct igb_adapter {
267 267
268 /* TX */ 268 /* TX */
269 struct igb_ring *tx_ring[16]; 269 struct igb_ring *tx_ring[16];
270 unsigned long tx_queue_len;
271 u32 tx_timeout_count; 270 u32 tx_timeout_count;
272 271
273 /* RX */ 272 /* RX */
diff --git a/drivers/net/igb/igb_ethtool.c b/drivers/net/igb/igb_ethtool.c
index a4cead12fd9..74303849010 100644
--- a/drivers/net/igb/igb_ethtool.c
+++ b/drivers/net/igb/igb_ethtool.c
@@ -35,6 +35,7 @@
35#include <linux/if_ether.h> 35#include <linux/if_ether.h>
36#include <linux/ethtool.h> 36#include <linux/ethtool.h>
37#include <linux/sched.h> 37#include <linux/sched.h>
38#include <linux/slab.h>
38 39
39#include "igb.h" 40#include "igb.h"
40 41
@@ -1813,6 +1814,7 @@ static int igb_wol_exclusion(struct igb_adapter *adapter,
1813 retval = 0; 1814 retval = 0;
1814 break; 1815 break;
1815 case E1000_DEV_ID_82576_QUAD_COPPER: 1816 case E1000_DEV_ID_82576_QUAD_COPPER:
1817 case E1000_DEV_ID_82576_QUAD_COPPER_ET2:
1816 /* quad port adapters only support WoL on port A */ 1818 /* quad port adapters only support WoL on port A */
1817 if (!(adapter->flags & IGB_FLAG_QUAD_PORT_A)) { 1819 if (!(adapter->flags & IGB_FLAG_QUAD_PORT_A)) {
1818 wol->supported = 0; 1820 wol->supported = 0;
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index 0ed25f059a0..c9baa2aa98c 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -32,6 +32,7 @@
32#include <linux/pagemap.h> 32#include <linux/pagemap.h>
33#include <linux/netdevice.h> 33#include <linux/netdevice.h>
34#include <linux/ipv6.h> 34#include <linux/ipv6.h>
35#include <linux/slab.h>
35#include <net/checksum.h> 36#include <net/checksum.h>
36#include <net/ip6_checksum.h> 37#include <net/ip6_checksum.h>
37#include <linux/net_tstamp.h> 38#include <linux/net_tstamp.h>
@@ -72,6 +73,7 @@ static DEFINE_PCI_DEVICE_TABLE(igb_pci_tbl) = {
72 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_FIBER), board_82575 }, 73 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_FIBER), board_82575 },
73 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_SERDES), board_82575 }, 74 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_SERDES), board_82575 },
74 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_SERDES_QUAD), board_82575 }, 75 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_SERDES_QUAD), board_82575 },
76 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_QUAD_COPPER_ET2), board_82575 },
75 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_QUAD_COPPER), board_82575 }, 77 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_QUAD_COPPER), board_82575 },
76 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82575EB_COPPER), board_82575 }, 78 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82575EB_COPPER), board_82575 },
77 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82575EB_FIBER_SERDES), board_82575 }, 79 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82575EB_FIBER_SERDES), board_82575 },
@@ -1104,9 +1106,6 @@ static void igb_configure(struct igb_adapter *adapter)
1104 struct igb_ring *ring = adapter->rx_ring[i]; 1106 struct igb_ring *ring = adapter->rx_ring[i];
1105 igb_alloc_rx_buffers_adv(ring, igb_desc_unused(ring)); 1107 igb_alloc_rx_buffers_adv(ring, igb_desc_unused(ring));
1106 } 1108 }
1107
1108
1109 adapter->tx_queue_len = netdev->tx_queue_len;
1110} 1109}
1111 1110
1112/** 1111/**
@@ -1212,7 +1211,6 @@ void igb_down(struct igb_adapter *adapter)
1212 del_timer_sync(&adapter->watchdog_timer); 1211 del_timer_sync(&adapter->watchdog_timer);
1213 del_timer_sync(&adapter->phy_info_timer); 1212 del_timer_sync(&adapter->phy_info_timer);
1214 1213
1215 netdev->tx_queue_len = adapter->tx_queue_len;
1216 netif_carrier_off(netdev); 1214 netif_carrier_off(netdev);
1217 1215
1218 /* record the stats before reset*/ 1216 /* record the stats before reset*/
@@ -1614,6 +1612,7 @@ static int __devinit igb_probe(struct pci_dev *pdev,
1614 adapter->eeprom_wol = 0; 1612 adapter->eeprom_wol = 0;
1615 break; 1613 break;
1616 case E1000_DEV_ID_82576_QUAD_COPPER: 1614 case E1000_DEV_ID_82576_QUAD_COPPER:
1615 case E1000_DEV_ID_82576_QUAD_COPPER_ET2:
1617 /* if quad port adapter, disable WoL on all but port A */ 1616 /* if quad port adapter, disable WoL on all but port A */
1618 if (global_quad_port_a != 0) 1617 if (global_quad_port_a != 0)
1619 adapter->eeprom_wol = 0; 1618 adapter->eeprom_wol = 0;
@@ -3105,17 +3104,13 @@ static void igb_watchdog_task(struct work_struct *work)
3105 ((ctrl & E1000_CTRL_RFCE) ? "RX" : 3104 ((ctrl & E1000_CTRL_RFCE) ? "RX" :
3106 ((ctrl & E1000_CTRL_TFCE) ? "TX" : "None"))); 3105 ((ctrl & E1000_CTRL_TFCE) ? "TX" : "None")));
3107 3106
3108 /* tweak tx_queue_len according to speed/duplex and 3107 /* adjust timeout factor according to speed/duplex */
3109 * adjust the timeout factor */
3110 netdev->tx_queue_len = adapter->tx_queue_len;
3111 adapter->tx_timeout_factor = 1; 3108 adapter->tx_timeout_factor = 1;
3112 switch (adapter->link_speed) { 3109 switch (adapter->link_speed) {
3113 case SPEED_10: 3110 case SPEED_10:
3114 netdev->tx_queue_len = 10;
3115 adapter->tx_timeout_factor = 14; 3111 adapter->tx_timeout_factor = 14;
3116 break; 3112 break;
3117 case SPEED_100: 3113 case SPEED_100:
3118 netdev->tx_queue_len = 100;
3119 /* maybe add some timeout factor ? */ 3114 /* maybe add some timeout factor ? */
3120 break; 3115 break;
3121 } 3116 }
@@ -3962,7 +3957,7 @@ void igb_update_stats(struct igb_adapter *adapter)
3962 struct net_device_stats *net_stats = igb_get_stats(adapter->netdev); 3957 struct net_device_stats *net_stats = igb_get_stats(adapter->netdev);
3963 struct e1000_hw *hw = &adapter->hw; 3958 struct e1000_hw *hw = &adapter->hw;
3964 struct pci_dev *pdev = adapter->pdev; 3959 struct pci_dev *pdev = adapter->pdev;
3965 u32 rnbc, reg; 3960 u32 reg, mpc;
3966 u16 phy_tmp; 3961 u16 phy_tmp;
3967 int i; 3962 int i;
3968 u64 bytes, packets; 3963 u64 bytes, packets;
@@ -4020,7 +4015,9 @@ void igb_update_stats(struct igb_adapter *adapter)
4020 adapter->stats.symerrs += rd32(E1000_SYMERRS); 4015 adapter->stats.symerrs += rd32(E1000_SYMERRS);
4021 adapter->stats.sec += rd32(E1000_SEC); 4016 adapter->stats.sec += rd32(E1000_SEC);
4022 4017
4023 adapter->stats.mpc += rd32(E1000_MPC); 4018 mpc = rd32(E1000_MPC);
4019 adapter->stats.mpc += mpc;
4020 net_stats->rx_fifo_errors += mpc;
4024 adapter->stats.scc += rd32(E1000_SCC); 4021 adapter->stats.scc += rd32(E1000_SCC);
4025 adapter->stats.ecol += rd32(E1000_ECOL); 4022 adapter->stats.ecol += rd32(E1000_ECOL);
4026 adapter->stats.mcc += rd32(E1000_MCC); 4023 adapter->stats.mcc += rd32(E1000_MCC);
@@ -4035,9 +4032,7 @@ void igb_update_stats(struct igb_adapter *adapter)
4035 adapter->stats.gptc += rd32(E1000_GPTC); 4032 adapter->stats.gptc += rd32(E1000_GPTC);
4036 adapter->stats.gotc += rd32(E1000_GOTCL); 4033 adapter->stats.gotc += rd32(E1000_GOTCL);
4037 rd32(E1000_GOTCH); /* clear GOTCL */ 4034 rd32(E1000_GOTCH); /* clear GOTCL */
4038 rnbc = rd32(E1000_RNBC); 4035 adapter->stats.rnbc += rd32(E1000_RNBC);
4039 adapter->stats.rnbc += rnbc;
4040 net_stats->rx_fifo_errors += rnbc;
4041 adapter->stats.ruc += rd32(E1000_RUC); 4036 adapter->stats.ruc += rd32(E1000_RUC);
4042 adapter->stats.rfc += rd32(E1000_RFC); 4037 adapter->stats.rfc += rd32(E1000_RFC);
4043 adapter->stats.rjc += rd32(E1000_RJC); 4038 adapter->stats.rjc += rd32(E1000_RJC);
@@ -5109,7 +5104,7 @@ static void igb_receive_skb(struct igb_q_vector *q_vector,
5109{ 5104{
5110 struct igb_adapter *adapter = q_vector->adapter; 5105 struct igb_adapter *adapter = q_vector->adapter;
5111 5106
5112 if (vlan_tag) 5107 if (vlan_tag && adapter->vlgrp)
5113 vlan_gro_receive(&q_vector->napi, adapter->vlgrp, 5108 vlan_gro_receive(&q_vector->napi, adapter->vlgrp,
5114 vlan_tag, skb); 5109 vlan_tag, skb);
5115 else 5110 else
diff --git a/drivers/net/igbvf/igbvf.h b/drivers/net/igbvf/igbvf.h
index a1774b29d22..debeee2dc71 100644
--- a/drivers/net/igbvf/igbvf.h
+++ b/drivers/net/igbvf/igbvf.h
@@ -198,7 +198,6 @@ struct igbvf_adapter {
198 struct igbvf_ring *tx_ring /* One per active queue */ 198 struct igbvf_ring *tx_ring /* One per active queue */
199 ____cacheline_aligned_in_smp; 199 ____cacheline_aligned_in_smp;
200 200
201 unsigned long tx_queue_len;
202 unsigned int restart_queue; 201 unsigned int restart_queue;
203 u32 txd_cmd; 202 u32 txd_cmd;
204 203
diff --git a/drivers/net/igbvf/netdev.c b/drivers/net/igbvf/netdev.c
index a77afd8a14b..1b1edad1eb5 100644
--- a/drivers/net/igbvf/netdev.c
+++ b/drivers/net/igbvf/netdev.c
@@ -35,6 +35,7 @@
35#include <linux/netdevice.h> 35#include <linux/netdevice.h>
36#include <linux/tcp.h> 36#include <linux/tcp.h>
37#include <linux/ipv6.h> 37#include <linux/ipv6.h>
38#include <linux/slab.h>
38#include <net/checksum.h> 39#include <net/checksum.h>
39#include <net/ip6_checksum.h> 40#include <net/ip6_checksum.h>
40#include <linux/mii.h> 41#include <linux/mii.h>
@@ -1304,8 +1305,6 @@ static void igbvf_configure_tx(struct igbvf_adapter *adapter)
1304 1305
1305 /* enable Report Status bit */ 1306 /* enable Report Status bit */
1306 adapter->txd_cmd |= E1000_ADVTXD_DCMD_RS; 1307 adapter->txd_cmd |= E1000_ADVTXD_DCMD_RS;
1307
1308 adapter->tx_queue_len = adapter->netdev->tx_queue_len;
1309} 1308}
1310 1309
1311/** 1310/**
@@ -1524,7 +1523,6 @@ void igbvf_down(struct igbvf_adapter *adapter)
1524 1523
1525 del_timer_sync(&adapter->watchdog_timer); 1524 del_timer_sync(&adapter->watchdog_timer);
1526 1525
1527 netdev->tx_queue_len = adapter->tx_queue_len;
1528 netif_carrier_off(netdev); 1526 netif_carrier_off(netdev);
1529 1527
1530 /* record the stats before reset*/ 1528 /* record the stats before reset*/
@@ -1857,21 +1855,15 @@ static void igbvf_watchdog_task(struct work_struct *work)
1857 &adapter->link_duplex); 1855 &adapter->link_duplex);
1858 igbvf_print_link_info(adapter); 1856 igbvf_print_link_info(adapter);
1859 1857
1860 /* 1858 /* adjust timeout factor according to speed/duplex */
1861 * tweak tx_queue_len according to speed/duplex
1862 * and adjust the timeout factor
1863 */
1864 netdev->tx_queue_len = adapter->tx_queue_len;
1865 adapter->tx_timeout_factor = 1; 1859 adapter->tx_timeout_factor = 1;
1866 switch (adapter->link_speed) { 1860 switch (adapter->link_speed) {
1867 case SPEED_10: 1861 case SPEED_10:
1868 txb2b = 0; 1862 txb2b = 0;
1869 netdev->tx_queue_len = 10;
1870 adapter->tx_timeout_factor = 16; 1863 adapter->tx_timeout_factor = 16;
1871 break; 1864 break;
1872 case SPEED_100: 1865 case SPEED_100:
1873 txb2b = 0; 1866 txb2b = 0;
1874 netdev->tx_queue_len = 100;
1875 /* maybe add some timeout factor ? */ 1867 /* maybe add some timeout factor ? */
1876 break; 1868 break;
1877 } 1869 }
diff --git a/drivers/net/ioc3-eth.c b/drivers/net/ioc3-eth.c
index 70871b9b045..8f6197d647c 100644
--- a/drivers/net/ioc3-eth.c
+++ b/drivers/net/ioc3-eth.c
@@ -44,6 +44,7 @@
44#include <linux/tcp.h> 44#include <linux/tcp.h>
45#include <linux/udp.h> 45#include <linux/udp.h>
46#include <linux/dma-mapping.h> 46#include <linux/dma-mapping.h>
47#include <linux/gfp.h>
47 48
48#ifdef CONFIG_SERIAL_8250 49#ifdef CONFIG_SERIAL_8250
49#include <linux/serial_core.h> 50#include <linux/serial_core.h>
diff --git a/drivers/net/ipg.c b/drivers/net/ipg.c
index 150415e83f6..639bf9fb027 100644
--- a/drivers/net/ipg.c
+++ b/drivers/net/ipg.c
@@ -22,6 +22,7 @@
22 */ 22 */
23#include <linux/crc32.h> 23#include <linux/crc32.h>
24#include <linux/ethtool.h> 24#include <linux/ethtool.h>
25#include <linux/gfp.h>
25#include <linux/mii.h> 26#include <linux/mii.h>
26#include <linux/mutex.h> 27#include <linux/mutex.h>
27 28
diff --git a/drivers/net/irda/ali-ircc.c b/drivers/net/irda/ali-ircc.c
index 12c7b006f76..28992c815cb 100644
--- a/drivers/net/irda/ali-ircc.c
+++ b/drivers/net/irda/ali-ircc.c
@@ -22,6 +22,7 @@
22 ********************************************************************/ 22 ********************************************************************/
23 23
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/gfp.h>
25 26
26#include <linux/kernel.h> 27#include <linux/kernel.h>
27#include <linux/types.h> 28#include <linux/types.h>
@@ -29,7 +30,6 @@
29#include <linux/netdevice.h> 30#include <linux/netdevice.h>
30#include <linux/ioport.h> 31#include <linux/ioport.h>
31#include <linux/delay.h> 32#include <linux/delay.h>
32#include <linux/slab.h>
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/rtnetlink.h> 34#include <linux/rtnetlink.h>
35#include <linux/serial_reg.h> 35#include <linux/serial_reg.h>
diff --git a/drivers/net/irda/bfin_sir.h b/drivers/net/irda/bfin_sir.h
index dac71b1f4f9..b54a6f08db4 100644
--- a/drivers/net/irda/bfin_sir.h
+++ b/drivers/net/irda/bfin_sir.h
@@ -16,6 +16,7 @@
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/dma-mapping.h> 18#include <linux/dma-mapping.h>
19#include <linux/slab.h>
19 20
20#include <net/irda/irda.h> 21#include <net/irda/irda.h>
21#include <net/irda/wrapper.h> 22#include <net/irda/wrapper.h>
diff --git a/drivers/net/irda/irtty-sir.c b/drivers/net/irda/irtty-sir.c
index 20f9bc62668..ee1dde52e8f 100644
--- a/drivers/net/irda/irtty-sir.c
+++ b/drivers/net/irda/irtty-sir.c
@@ -28,6 +28,7 @@
28 28
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/kernel.h> 30#include <linux/kernel.h>
31#include <linux/slab.h>
31#include <linux/tty.h> 32#include <linux/tty.h>
32#include <linux/init.h> 33#include <linux/init.h>
33#include <asm/uaccess.h> 34#include <asm/uaccess.h>
diff --git a/drivers/net/irda/nsc-ircc.c b/drivers/net/irda/nsc-ircc.c
index 2413295ebd9..e30cdbb1474 100644
--- a/drivers/net/irda/nsc-ircc.c
+++ b/drivers/net/irda/nsc-ircc.c
@@ -43,6 +43,7 @@
43 ********************************************************************/ 43 ********************************************************************/
44 44
45#include <linux/module.h> 45#include <linux/module.h>
46#include <linux/gfp.h>
46 47
47#include <linux/kernel.h> 48#include <linux/kernel.h>
48#include <linux/types.h> 49#include <linux/types.h>
@@ -50,7 +51,6 @@
50#include <linux/netdevice.h> 51#include <linux/netdevice.h>
51#include <linux/ioport.h> 52#include <linux/ioport.h>
52#include <linux/delay.h> 53#include <linux/delay.h>
53#include <linux/slab.h>
54#include <linux/init.h> 54#include <linux/init.h>
55#include <linux/rtnetlink.h> 55#include <linux/rtnetlink.h>
56#include <linux/dma-mapping.h> 56#include <linux/dma-mapping.h>
diff --git a/drivers/net/irda/pxaficp_ir.c b/drivers/net/irda/pxaficp_ir.c
index 84db145d2b5..1a54f6bb68c 100644
--- a/drivers/net/irda/pxaficp_ir.c
+++ b/drivers/net/irda/pxaficp_ir.c
@@ -18,6 +18,7 @@
18#include <linux/platform_device.h> 18#include <linux/platform_device.h>
19#include <linux/clk.h> 19#include <linux/clk.h>
20#include <linux/gpio.h> 20#include <linux/gpio.h>
21#include <linux/slab.h>
21 22
22#include <net/irda/irda.h> 23#include <net/irda/irda.h>
23#include <net/irda/irmod.h> 24#include <net/irda/irmod.h>
diff --git a/drivers/net/irda/sh_sir.c b/drivers/net/irda/sh_sir.c
index d7c983dc91a..0745581c4b5 100644
--- a/drivers/net/irda/sh_sir.c
+++ b/drivers/net/irda/sh_sir.c
@@ -14,6 +14,7 @@
14 14
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/slab.h>
17#include <net/irda/wrapper.h> 18#include <net/irda/wrapper.h>
18#include <net/irda/irda_device.h> 19#include <net/irda/irda_device.h>
19#include <asm/clock.h> 20#include <asm/clock.h>
diff --git a/drivers/net/irda/sir_dev.c b/drivers/net/irda/sir_dev.c
index 4b2a1a9eac2..de91cd14016 100644
--- a/drivers/net/irda/sir_dev.c
+++ b/drivers/net/irda/sir_dev.c
@@ -13,6 +13,7 @@
13 13
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/slab.h>
16#include <linux/init.h> 17#include <linux/init.h>
17#include <linux/delay.h> 18#include <linux/delay.h>
18 19
diff --git a/drivers/net/irda/smsc-ircc2.c b/drivers/net/irda/smsc-ircc2.c
index 8f7d0d146f2..6af84d88cd0 100644
--- a/drivers/net/irda/smsc-ircc2.c
+++ b/drivers/net/irda/smsc-ircc2.c
@@ -48,13 +48,13 @@
48#include <linux/netdevice.h> 48#include <linux/netdevice.h>
49#include <linux/ioport.h> 49#include <linux/ioport.h>
50#include <linux/delay.h> 50#include <linux/delay.h>
51#include <linux/slab.h>
52#include <linux/init.h> 51#include <linux/init.h>
53#include <linux/rtnetlink.h> 52#include <linux/rtnetlink.h>
54#include <linux/serial_reg.h> 53#include <linux/serial_reg.h>
55#include <linux/dma-mapping.h> 54#include <linux/dma-mapping.h>
56#include <linux/pnp.h> 55#include <linux/pnp.h>
57#include <linux/platform_device.h> 56#include <linux/platform_device.h>
57#include <linux/gfp.h>
58 58
59#include <asm/io.h> 59#include <asm/io.h>
60#include <asm/dma.h> 60#include <asm/dma.h>
diff --git a/drivers/net/irda/via-ircc.c b/drivers/net/irda/via-ircc.c
index 6533c010cf5..b0a6cd815be 100644
--- a/drivers/net/irda/via-ircc.c
+++ b/drivers/net/irda/via-ircc.c
@@ -45,11 +45,11 @@ F02 Oct/28/02: Add SB device ID for 3147 and 3177.
45#include <linux/netdevice.h> 45#include <linux/netdevice.h>
46#include <linux/ioport.h> 46#include <linux/ioport.h>
47#include <linux/delay.h> 47#include <linux/delay.h>
48#include <linux/slab.h>
49#include <linux/init.h> 48#include <linux/init.h>
50#include <linux/rtnetlink.h> 49#include <linux/rtnetlink.h>
51#include <linux/pci.h> 50#include <linux/pci.h>
52#include <linux/dma-mapping.h> 51#include <linux/dma-mapping.h>
52#include <linux/gfp.h>
53 53
54#include <asm/io.h> 54#include <asm/io.h>
55#include <asm/dma.h> 55#include <asm/dma.h>
diff --git a/drivers/net/irda/w83977af_ir.c b/drivers/net/irda/w83977af_ir.c
index 980625feb2c..cb0cb758be6 100644
--- a/drivers/net/irda/w83977af_ir.c
+++ b/drivers/net/irda/w83977af_ir.c
@@ -46,10 +46,10 @@
46#include <linux/netdevice.h> 46#include <linux/netdevice.h>
47#include <linux/ioport.h> 47#include <linux/ioport.h>
48#include <linux/delay.h> 48#include <linux/delay.h>
49#include <linux/slab.h>
50#include <linux/init.h> 49#include <linux/init.h>
51#include <linux/rtnetlink.h> 50#include <linux/rtnetlink.h>
52#include <linux/dma-mapping.h> 51#include <linux/dma-mapping.h>
52#include <linux/gfp.h>
53 53
54#include <asm/io.h> 54#include <asm/io.h>
55#include <asm/dma.h> 55#include <asm/dma.h>
diff --git a/drivers/net/iseries_veth.c b/drivers/net/iseries_veth.c
index e6e972d9b7c..773c59c8969 100644
--- a/drivers/net/iseries_veth.c
+++ b/drivers/net/iseries_veth.c
@@ -69,6 +69,7 @@
69#include <linux/mm.h> 69#include <linux/mm.h>
70#include <linux/ethtool.h> 70#include <linux/ethtool.h>
71#include <linux/if_ether.h> 71#include <linux/if_ether.h>
72#include <linux/slab.h>
72 73
73#include <asm/abs_addr.h> 74#include <asm/abs_addr.h>
74#include <asm/iseries/mf.h> 75#include <asm/iseries/mf.h>
diff --git a/drivers/net/ixgbe/ixgbe.h b/drivers/net/ixgbe/ixgbe.h
index 19e94ee155a..79c35ae3718 100644
--- a/drivers/net/ixgbe/ixgbe.h
+++ b/drivers/net/ixgbe/ixgbe.h
@@ -204,14 +204,17 @@ enum ixgbe_ring_f_enum {
204#define IXGBE_MAX_FDIR_INDICES 64 204#define IXGBE_MAX_FDIR_INDICES 64
205#ifdef IXGBE_FCOE 205#ifdef IXGBE_FCOE
206#define IXGBE_MAX_FCOE_INDICES 8 206#define IXGBE_MAX_FCOE_INDICES 8
207#define MAX_RX_QUEUES (IXGBE_MAX_FDIR_INDICES + IXGBE_MAX_FCOE_INDICES)
208#define MAX_TX_QUEUES (IXGBE_MAX_FDIR_INDICES + IXGBE_MAX_FCOE_INDICES)
209#else
210#define MAX_RX_QUEUES IXGBE_MAX_FDIR_INDICES
211#define MAX_TX_QUEUES IXGBE_MAX_FDIR_INDICES
207#endif /* IXGBE_FCOE */ 212#endif /* IXGBE_FCOE */
208struct ixgbe_ring_feature { 213struct ixgbe_ring_feature {
209 int indices; 214 int indices;
210 int mask; 215 int mask;
211} ____cacheline_internodealigned_in_smp; 216} ____cacheline_internodealigned_in_smp;
212 217
213#define MAX_RX_QUEUES 128
214#define MAX_TX_QUEUES 128
215 218
216#define MAX_RX_PACKET_BUFFERS ((adapter->flags & IXGBE_FLAG_DCB_ENABLED) \ 219#define MAX_RX_PACKET_BUFFERS ((adapter->flags & IXGBE_FLAG_DCB_ENABLED) \
217 ? 8 : 1) 220 ? 8 : 1)
diff --git a/drivers/net/ixgbe/ixgbe_82599.c b/drivers/net/ixgbe/ixgbe_82599.c
index 1f30e163bd9..12fc0e7ba2c 100644
--- a/drivers/net/ixgbe/ixgbe_82599.c
+++ b/drivers/net/ixgbe/ixgbe_82599.c
@@ -39,6 +39,9 @@
39#define IXGBE_82599_MC_TBL_SIZE 128 39#define IXGBE_82599_MC_TBL_SIZE 128
40#define IXGBE_82599_VFT_TBL_SIZE 128 40#define IXGBE_82599_VFT_TBL_SIZE 128
41 41
42void ixgbe_disable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw);
43void ixgbe_enable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw);
44void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw);
42s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw, 45s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,
43 ixgbe_link_speed speed, 46 ixgbe_link_speed speed,
44 bool autoneg, 47 bool autoneg,
@@ -68,7 +71,15 @@ static void ixgbe_init_mac_link_ops_82599(struct ixgbe_hw *hw)
68 if (hw->phy.multispeed_fiber) { 71 if (hw->phy.multispeed_fiber) {
69 /* Set up dual speed SFP+ support */ 72 /* Set up dual speed SFP+ support */
70 mac->ops.setup_link = &ixgbe_setup_mac_link_multispeed_fiber; 73 mac->ops.setup_link = &ixgbe_setup_mac_link_multispeed_fiber;
74 mac->ops.disable_tx_laser =
75 &ixgbe_disable_tx_laser_multispeed_fiber;
76 mac->ops.enable_tx_laser =
77 &ixgbe_enable_tx_laser_multispeed_fiber;
78 mac->ops.flap_tx_laser = &ixgbe_flap_tx_laser_multispeed_fiber;
71 } else { 79 } else {
80 mac->ops.disable_tx_laser = NULL;
81 mac->ops.enable_tx_laser = NULL;
82 mac->ops.flap_tx_laser = NULL;
72 if ((mac->ops.get_media_type(hw) == 83 if ((mac->ops.get_media_type(hw) ==
73 ixgbe_media_type_backplane) && 84 ixgbe_media_type_backplane) &&
74 (hw->phy.smart_speed == ixgbe_smart_speed_auto || 85 (hw->phy.smart_speed == ixgbe_smart_speed_auto ||
@@ -412,6 +423,67 @@ s32 ixgbe_start_mac_link_82599(struct ixgbe_hw *hw,
412 return status; 423 return status;
413} 424}
414 425
426 /**
427 * ixgbe_disable_tx_laser_multispeed_fiber - Disable Tx laser
428 * @hw: pointer to hardware structure
429 *
430 * The base drivers may require better control over SFP+ module
431 * PHY states. This includes selectively shutting down the Tx
432 * laser on the PHY, effectively halting physical link.
433 **/
434void ixgbe_disable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw)
435{
436 u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP);
437
438 /* Disable tx laser; allow 100us to go dark per spec */
439 esdp_reg |= IXGBE_ESDP_SDP3;
440 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
441 IXGBE_WRITE_FLUSH(hw);
442 udelay(100);
443}
444
445/**
446 * ixgbe_enable_tx_laser_multispeed_fiber - Enable Tx laser
447 * @hw: pointer to hardware structure
448 *
449 * The base drivers may require better control over SFP+ module
450 * PHY states. This includes selectively turning on the Tx
451 * laser on the PHY, effectively starting physical link.
452 **/
453void ixgbe_enable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw)
454{
455 u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP);
456
457 /* Enable tx laser; allow 100ms to light up */
458 esdp_reg &= ~IXGBE_ESDP_SDP3;
459 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
460 IXGBE_WRITE_FLUSH(hw);
461 msleep(100);
462}
463
464/**
465 * ixgbe_flap_tx_laser_multispeed_fiber - Flap Tx laser
466 * @hw: pointer to hardware structure
467 *
468 * When the driver changes the link speeds that it can support,
469 * it sets autotry_restart to true to indicate that we need to
470 * initiate a new autotry session with the link partner. To do
471 * so, we set the speed then disable and re-enable the tx laser, to
472 * alert the link partner that it also needs to restart autotry on its
473 * end. This is consistent with true clause 37 autoneg, which also
474 * involves a loss of signal.
475 **/
476void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw)
477{
478 hw_dbg(hw, "ixgbe_flap_tx_laser_multispeed_fiber\n");
479
480 if (hw->mac.autotry_restart) {
481 ixgbe_disable_tx_laser_multispeed_fiber(hw);
482 ixgbe_enable_tx_laser_multispeed_fiber(hw);
483 hw->mac.autotry_restart = false;
484 }
485}
486
415/** 487/**
416 * ixgbe_setup_mac_link_multispeed_fiber - Set MAC link speed 488 * ixgbe_setup_mac_link_multispeed_fiber - Set MAC link speed
417 * @hw: pointer to hardware structure 489 * @hw: pointer to hardware structure
@@ -440,16 +512,6 @@ s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,
440 speed &= phy_link_speed; 512 speed &= phy_link_speed;
441 513
442 /* 514 /*
443 * When the driver changes the link speeds that it can support,
444 * it sets autotry_restart to true to indicate that we need to
445 * initiate a new autotry session with the link partner. To do
446 * so, we set the speed then disable and re-enable the tx laser, to
447 * alert the link partner that it also needs to restart autotry on its
448 * end. This is consistent with true clause 37 autoneg, which also
449 * involves a loss of signal.
450 */
451
452 /*
453 * Try each speed one by one, highest priority first. We do this in 515 * Try each speed one by one, highest priority first. We do this in
454 * software because 10gb fiber doesn't support speed autonegotiation. 516 * software because 10gb fiber doesn't support speed autonegotiation.
455 */ 517 */
@@ -466,6 +528,7 @@ s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,
466 /* Set the module link speed */ 528 /* Set the module link speed */
467 esdp_reg |= (IXGBE_ESDP_SDP5_DIR | IXGBE_ESDP_SDP5); 529 esdp_reg |= (IXGBE_ESDP_SDP5_DIR | IXGBE_ESDP_SDP5);
468 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg); 530 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
531 IXGBE_WRITE_FLUSH(hw);
469 532
470 /* Allow module to change analog characteristics (1G->10G) */ 533 /* Allow module to change analog characteristics (1G->10G) */
471 msleep(40); 534 msleep(40);
@@ -478,19 +541,7 @@ s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,
478 return status; 541 return status;
479 542
480 /* Flap the tx laser if it has not already been done */ 543 /* Flap the tx laser if it has not already been done */
481 if (hw->mac.autotry_restart) { 544 hw->mac.ops.flap_tx_laser(hw);
482 /* Disable tx laser; allow 100us to go dark per spec */
483 esdp_reg |= IXGBE_ESDP_SDP3;
484 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
485 udelay(100);
486
487 /* Enable tx laser; allow 2ms to light up per spec */
488 esdp_reg &= ~IXGBE_ESDP_SDP3;
489 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
490 msleep(2);
491
492 hw->mac.autotry_restart = false;
493 }
494 545
495 /* 546 /*
496 * Wait for the controller to acquire link. Per IEEE 802.3ap, 547 * Wait for the controller to acquire link. Per IEEE 802.3ap,
@@ -525,6 +576,7 @@ s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,
525 esdp_reg &= ~IXGBE_ESDP_SDP5; 576 esdp_reg &= ~IXGBE_ESDP_SDP5;
526 esdp_reg |= IXGBE_ESDP_SDP5_DIR; 577 esdp_reg |= IXGBE_ESDP_SDP5_DIR;
527 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg); 578 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
579 IXGBE_WRITE_FLUSH(hw);
528 580
529 /* Allow module to change analog characteristics (10G->1G) */ 581 /* Allow module to change analog characteristics (10G->1G) */
530 msleep(40); 582 msleep(40);
@@ -537,19 +589,7 @@ s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,
537 return status; 589 return status;
538 590
539 /* Flap the tx laser if it has not already been done */ 591 /* Flap the tx laser if it has not already been done */
540 if (hw->mac.autotry_restart) { 592 hw->mac.ops.flap_tx_laser(hw);
541 /* Disable tx laser; allow 100us to go dark per spec */
542 esdp_reg |= IXGBE_ESDP_SDP3;
543 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
544 udelay(100);
545
546 /* Enable tx laser; allow 2ms to light up per spec */
547 esdp_reg &= ~IXGBE_ESDP_SDP3;
548 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
549 msleep(2);
550
551 hw->mac.autotry_restart = false;
552 }
553 593
554 /* Wait for the link partner to also set speed */ 594 /* Wait for the link partner to also set speed */
555 msleep(100); 595 msleep(100);
diff --git a/drivers/net/ixgbe/ixgbe_ethtool.c b/drivers/net/ixgbe/ixgbe_ethtool.c
index 7949a446e4c..8f461d5cee7 100644
--- a/drivers/net/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ixgbe/ixgbe_ethtool.c
@@ -29,6 +29,7 @@
29 29
30#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/slab.h>
32#include <linux/pci.h> 33#include <linux/pci.h>
33#include <linux/netdevice.h> 34#include <linux/netdevice.h>
34#include <linux/ethtool.h> 35#include <linux/ethtool.h>
@@ -1853,6 +1854,26 @@ static void ixgbe_diag_test(struct net_device *netdev,
1853 if (ixgbe_link_test(adapter, &data[4])) 1854 if (ixgbe_link_test(adapter, &data[4]))
1854 eth_test->flags |= ETH_TEST_FL_FAILED; 1855 eth_test->flags |= ETH_TEST_FL_FAILED;
1855 1856
1857 if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) {
1858 int i;
1859 for (i = 0; i < adapter->num_vfs; i++) {
1860 if (adapter->vfinfo[i].clear_to_send) {
1861 netdev_warn(netdev, "%s",
1862 "offline diagnostic is not "
1863 "supported when VFs are "
1864 "present\n");
1865 data[0] = 1;
1866 data[1] = 1;
1867 data[2] = 1;
1868 data[3] = 1;
1869 eth_test->flags |= ETH_TEST_FL_FAILED;
1870 clear_bit(__IXGBE_TESTING,
1871 &adapter->state);
1872 goto skip_ol_tests;
1873 }
1874 }
1875 }
1876
1856 if (if_running) 1877 if (if_running)
1857 /* indicate we're in test mode */ 1878 /* indicate we're in test mode */
1858 dev_close(netdev); 1879 dev_close(netdev);
@@ -1908,6 +1929,7 @@ skip_loopback:
1908 1929
1909 clear_bit(__IXGBE_TESTING, &adapter->state); 1930 clear_bit(__IXGBE_TESTING, &adapter->state);
1910 } 1931 }
1932skip_ol_tests:
1911 msleep_interruptible(4 * 1000); 1933 msleep_interruptible(4 * 1000);
1912} 1934}
1913 1935
diff --git a/drivers/net/ixgbe/ixgbe_fcoe.c b/drivers/net/ixgbe/ixgbe_fcoe.c
index 4123dec0dfb..6493049b663 100644
--- a/drivers/net/ixgbe/ixgbe_fcoe.c
+++ b/drivers/net/ixgbe/ixgbe_fcoe.c
@@ -31,6 +31,7 @@
31#include "ixgbe_dcb_82599.h" 31#include "ixgbe_dcb_82599.h"
32#endif /* CONFIG_IXGBE_DCB */ 32#endif /* CONFIG_IXGBE_DCB */
33#include <linux/if_ether.h> 33#include <linux/if_ether.h>
34#include <linux/gfp.h>
34#include <scsi/scsi_cmnd.h> 35#include <scsi/scsi_cmnd.h>
35#include <scsi/scsi_device.h> 36#include <scsi/scsi_device.h>
36#include <scsi/fc/fc_fs.h> 37#include <scsi/fc/fc_fs.h>
@@ -202,6 +203,15 @@ int ixgbe_fcoe_ddp_get(struct net_device *netdev, u16 xid,
202 addr = sg_dma_address(sg); 203 addr = sg_dma_address(sg);
203 len = sg_dma_len(sg); 204 len = sg_dma_len(sg);
204 while (len) { 205 while (len) {
206 /* max number of buffers allowed in one DDP context */
207 if (j >= IXGBE_BUFFCNT_MAX) {
208 netif_err(adapter, drv, adapter->netdev,
209 "xid=%x:%d,%d,%d:addr=%llx "
210 "not enough descriptors\n",
211 xid, i, j, dmacount, (u64)addr);
212 goto out_noddp_free;
213 }
214
205 /* get the offset of length of current buffer */ 215 /* get the offset of length of current buffer */
206 thisoff = addr & ((dma_addr_t)bufflen - 1); 216 thisoff = addr & ((dma_addr_t)bufflen - 1);
207 thislen = min((bufflen - thisoff), len); 217 thislen = min((bufflen - thisoff), len);
@@ -227,20 +237,13 @@ int ixgbe_fcoe_ddp_get(struct net_device *netdev, u16 xid,
227 len -= thislen; 237 len -= thislen;
228 addr += thislen; 238 addr += thislen;
229 j++; 239 j++;
230 /* max number of buffers allowed in one DDP context */
231 if (j > IXGBE_BUFFCNT_MAX) {
232 DPRINTK(DRV, ERR, "xid=%x:%d,%d,%d:addr=%llx "
233 "not enough descriptors\n",
234 xid, i, j, dmacount, (u64)addr);
235 goto out_noddp_free;
236 }
237 } 240 }
238 } 241 }
239 /* only the last buffer may have non-full bufflen */ 242 /* only the last buffer may have non-full bufflen */
240 lastsize = thisoff + thislen; 243 lastsize = thisoff + thislen;
241 244
242 fcbuff = (IXGBE_FCBUFF_4KB << IXGBE_FCBUFF_BUFFSIZE_SHIFT); 245 fcbuff = (IXGBE_FCBUFF_4KB << IXGBE_FCBUFF_BUFFSIZE_SHIFT);
243 fcbuff |= (j << IXGBE_FCBUFF_BUFFCNT_SHIFT); 246 fcbuff |= ((j & 0xff) << IXGBE_FCBUFF_BUFFCNT_SHIFT);
244 fcbuff |= (firstoff << IXGBE_FCBUFF_OFFSET_SHIFT); 247 fcbuff |= (firstoff << IXGBE_FCBUFF_OFFSET_SHIFT);
245 fcbuff |= (IXGBE_FCBUFF_VALID); 248 fcbuff |= (IXGBE_FCBUFF_VALID);
246 249
@@ -520,6 +523,9 @@ void ixgbe_configure_fcoe(struct ixgbe_adapter *adapter)
520 /* Enable L2 eth type filter for FCoE */ 523 /* Enable L2 eth type filter for FCoE */
521 IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_FCOE), 524 IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_FCOE),
522 (ETH_P_FCOE | IXGBE_ETQF_FCOE | IXGBE_ETQF_FILTER_EN)); 525 (ETH_P_FCOE | IXGBE_ETQF_FCOE | IXGBE_ETQF_FILTER_EN));
526 /* Enable L2 eth type filter for FIP */
527 IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_FIP),
528 (ETH_P_FIP | IXGBE_ETQF_FILTER_EN));
523 if (adapter->ring_feature[RING_F_FCOE].indices) { 529 if (adapter->ring_feature[RING_F_FCOE].indices) {
524 /* Use multiple rx queues for FCoE by redirection table */ 530 /* Use multiple rx queues for FCoE by redirection table */
525 for (i = 0; i < IXGBE_FCRETA_SIZE; i++) { 531 for (i = 0; i < IXGBE_FCRETA_SIZE; i++) {
@@ -530,6 +536,12 @@ void ixgbe_configure_fcoe(struct ixgbe_adapter *adapter)
530 } 536 }
531 IXGBE_WRITE_REG(hw, IXGBE_FCRECTL, IXGBE_FCRECTL_ENA); 537 IXGBE_WRITE_REG(hw, IXGBE_FCRECTL, IXGBE_FCRECTL_ENA);
532 IXGBE_WRITE_REG(hw, IXGBE_ETQS(IXGBE_ETQF_FILTER_FCOE), 0); 538 IXGBE_WRITE_REG(hw, IXGBE_ETQS(IXGBE_ETQF_FILTER_FCOE), 0);
539 fcoe_i = f->mask;
540 fcoe_i &= IXGBE_FCRETA_ENTRY_MASK;
541 fcoe_q = adapter->rx_ring[fcoe_i]->reg_idx;
542 IXGBE_WRITE_REG(hw, IXGBE_ETQS(IXGBE_ETQF_FILTER_FIP),
543 IXGBE_ETQS_QUEUE_EN |
544 (fcoe_q << IXGBE_ETQS_RX_QUEUE_SHIFT));
533 } else { 545 } else {
534 /* Use single rx queue for FCoE */ 546 /* Use single rx queue for FCoE */
535 fcoe_i = f->mask; 547 fcoe_i = f->mask;
@@ -539,6 +551,12 @@ void ixgbe_configure_fcoe(struct ixgbe_adapter *adapter)
539 IXGBE_ETQS_QUEUE_EN | 551 IXGBE_ETQS_QUEUE_EN |
540 (fcoe_q << IXGBE_ETQS_RX_QUEUE_SHIFT)); 552 (fcoe_q << IXGBE_ETQS_RX_QUEUE_SHIFT));
541 } 553 }
554 /* send FIP frames to the first FCoE queue */
555 fcoe_i = f->mask;
556 fcoe_q = adapter->rx_ring[fcoe_i]->reg_idx;
557 IXGBE_WRITE_REG(hw, IXGBE_ETQS(IXGBE_ETQF_FILTER_FIP),
558 IXGBE_ETQS_QUEUE_EN |
559 (fcoe_q << IXGBE_ETQS_RX_QUEUE_SHIFT));
542 560
543 IXGBE_WRITE_REG(hw, IXGBE_FCRXCTRL, 561 IXGBE_WRITE_REG(hw, IXGBE_FCRXCTRL,
544 IXGBE_FCRXCTRL_FCOELLI | 562 IXGBE_FCRXCTRL_FCOELLI |
@@ -614,9 +632,9 @@ int ixgbe_fcoe_enable(struct net_device *netdev)
614 netdev->vlan_features |= NETIF_F_FSO; 632 netdev->vlan_features |= NETIF_F_FSO;
615 netdev->vlan_features |= NETIF_F_FCOE_MTU; 633 netdev->vlan_features |= NETIF_F_FCOE_MTU;
616 netdev->fcoe_ddp_xid = IXGBE_FCOE_DDP_MAX - 1; 634 netdev->fcoe_ddp_xid = IXGBE_FCOE_DDP_MAX - 1;
617 netdev_features_change(netdev);
618 635
619 ixgbe_init_interrupt_scheme(adapter); 636 ixgbe_init_interrupt_scheme(adapter);
637 netdev_features_change(netdev);
620 638
621 if (netif_running(netdev)) 639 if (netif_running(netdev))
622 netdev->netdev_ops->ndo_open(netdev); 640 netdev->netdev_ops->ndo_open(netdev);
@@ -660,11 +678,11 @@ int ixgbe_fcoe_disable(struct net_device *netdev)
660 netdev->vlan_features &= ~NETIF_F_FSO; 678 netdev->vlan_features &= ~NETIF_F_FSO;
661 netdev->vlan_features &= ~NETIF_F_FCOE_MTU; 679 netdev->vlan_features &= ~NETIF_F_FCOE_MTU;
662 netdev->fcoe_ddp_xid = 0; 680 netdev->fcoe_ddp_xid = 0;
663 netdev_features_change(netdev);
664 681
665 ixgbe_cleanup_fcoe(adapter); 682 ixgbe_cleanup_fcoe(adapter);
666
667 ixgbe_init_interrupt_scheme(adapter); 683 ixgbe_init_interrupt_scheme(adapter);
684 netdev_features_change(netdev);
685
668 if (netif_running(netdev)) 686 if (netif_running(netdev))
669 netdev->netdev_ops->ndo_open(netdev); 687 netdev->netdev_ops->ndo_open(netdev);
670 rc = 0; 688 rc = 0;
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index 684af371462..6c00ee493a3 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -36,6 +36,7 @@
36#include <linux/tcp.h> 36#include <linux/tcp.h>
37#include <linux/pkt_sched.h> 37#include <linux/pkt_sched.h>
38#include <linux/ipv6.h> 38#include <linux/ipv6.h>
39#include <linux/slab.h>
39#include <net/checksum.h> 40#include <net/checksum.h>
40#include <net/ip6_checksum.h> 41#include <net/ip6_checksum.h>
41#include <linux/ethtool.h> 42#include <linux/ethtool.h>
@@ -935,10 +936,12 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector,
935 if (skb->prev) 936 if (skb->prev)
936 skb = ixgbe_transform_rsc_queue(skb, &(rx_ring->rsc_count)); 937 skb = ixgbe_transform_rsc_queue(skb, &(rx_ring->rsc_count));
937 if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) { 938 if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) {
938 if (IXGBE_RSC_CB(skb)->dma) 939 if (IXGBE_RSC_CB(skb)->dma) {
939 pci_unmap_single(pdev, IXGBE_RSC_CB(skb)->dma, 940 pci_unmap_single(pdev, IXGBE_RSC_CB(skb)->dma,
940 rx_ring->rx_buf_len, 941 rx_ring->rx_buf_len,
941 PCI_DMA_FROMDEVICE); 942 PCI_DMA_FROMDEVICE);
943 IXGBE_RSC_CB(skb)->dma = 0;
944 }
942 if (rx_ring->flags & IXGBE_RING_RX_PS_ENABLED) 945 if (rx_ring->flags & IXGBE_RING_RX_PS_ENABLED)
943 rx_ring->rsc_count += skb_shinfo(skb)->nr_frags; 946 rx_ring->rsc_count += skb_shinfo(skb)->nr_frags;
944 else 947 else
@@ -2979,6 +2982,10 @@ static int ixgbe_up_complete(struct ixgbe_adapter *adapter)
2979 else 2982 else
2980 ixgbe_configure_msi_and_legacy(adapter); 2983 ixgbe_configure_msi_and_legacy(adapter);
2981 2984
2985 /* enable the optics */
2986 if (hw->phy.multispeed_fiber)
2987 hw->mac.ops.enable_tx_laser(hw);
2988
2982 clear_bit(__IXGBE_DOWN, &adapter->state); 2989 clear_bit(__IXGBE_DOWN, &adapter->state);
2983 ixgbe_napi_enable_all(adapter); 2990 ixgbe_napi_enable_all(adapter);
2984 2991
@@ -3054,6 +3061,14 @@ void ixgbe_reinit_locked(struct ixgbe_adapter *adapter)
3054 while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state)) 3061 while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state))
3055 msleep(1); 3062 msleep(1);
3056 ixgbe_down(adapter); 3063 ixgbe_down(adapter);
3064 /*
3065 * If SR-IOV enabled then wait a bit before bringing the adapter
3066 * back up to give the VFs time to respond to the reset. The
3067 * two second wait is based upon the watchdog timer cycle in
3068 * the VF driver.
3069 */
3070 if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)
3071 msleep(2000);
3057 ixgbe_up(adapter); 3072 ixgbe_up(adapter);
3058 clear_bit(__IXGBE_RESETTING, &adapter->state); 3073 clear_bit(__IXGBE_RESETTING, &adapter->state);
3059} 3074}
@@ -3126,10 +3141,12 @@ static void ixgbe_clean_rx_ring(struct ixgbe_adapter *adapter,
3126 rx_buffer_info->skb = NULL; 3141 rx_buffer_info->skb = NULL;
3127 do { 3142 do {
3128 struct sk_buff *this = skb; 3143 struct sk_buff *this = skb;
3129 if (IXGBE_RSC_CB(this)->dma) 3144 if (IXGBE_RSC_CB(this)->dma) {
3130 pci_unmap_single(pdev, IXGBE_RSC_CB(this)->dma, 3145 pci_unmap_single(pdev, IXGBE_RSC_CB(this)->dma,
3131 rx_ring->rx_buf_len, 3146 rx_ring->rx_buf_len,
3132 PCI_DMA_FROMDEVICE); 3147 PCI_DMA_FROMDEVICE);
3148 IXGBE_RSC_CB(this)->dma = 0;
3149 }
3133 skb = skb->prev; 3150 skb = skb->prev;
3134 dev_kfree_skb(this); 3151 dev_kfree_skb(this);
3135 } while (skb); 3152 } while (skb);
@@ -3230,15 +3247,21 @@ void ixgbe_down(struct ixgbe_adapter *adapter)
3230 /* signal that we are down to the interrupt handler */ 3247 /* signal that we are down to the interrupt handler */
3231 set_bit(__IXGBE_DOWN, &adapter->state); 3248 set_bit(__IXGBE_DOWN, &adapter->state);
3232 3249
3250 /* power down the optics */
3251 if (hw->phy.multispeed_fiber)
3252 hw->mac.ops.disable_tx_laser(hw);
3253
3233 /* disable receive for all VFs and wait one second */ 3254 /* disable receive for all VFs and wait one second */
3234 if (adapter->num_vfs) { 3255 if (adapter->num_vfs) {
3235 for (i = 0 ; i < adapter->num_vfs; i++)
3236 adapter->vfinfo[i].clear_to_send = 0;
3237
3238 /* ping all the active vfs to let them know we are going down */ 3256 /* ping all the active vfs to let them know we are going down */
3239 ixgbe_ping_all_vfs(adapter); 3257 ixgbe_ping_all_vfs(adapter);
3258
3240 /* Disable all VFTE/VFRE TX/RX */ 3259 /* Disable all VFTE/VFRE TX/RX */
3241 ixgbe_disable_tx_rx(adapter); 3260 ixgbe_disable_tx_rx(adapter);
3261
3262 /* Mark all the VFs as inactive */
3263 for (i = 0 ; i < adapter->num_vfs; i++)
3264 adapter->vfinfo[i].clear_to_send = 0;
3242 } 3265 }
3243 3266
3244 /* disable receives */ 3267 /* disable receives */
@@ -5018,6 +5041,7 @@ static void ixgbe_multispeed_fiber_task(struct work_struct *work)
5018 autoneg = hw->phy.autoneg_advertised; 5041 autoneg = hw->phy.autoneg_advertised;
5019 if ((!autoneg) && (hw->mac.ops.get_link_capabilities)) 5042 if ((!autoneg) && (hw->mac.ops.get_link_capabilities))
5020 hw->mac.ops.get_link_capabilities(hw, &autoneg, &negotiation); 5043 hw->mac.ops.get_link_capabilities(hw, &autoneg, &negotiation);
5044 hw->mac.autotry_restart = false;
5021 if (hw->mac.ops.setup_link) 5045 if (hw->mac.ops.setup_link)
5022 hw->mac.ops.setup_link(hw, autoneg, negotiation, true); 5046 hw->mac.ops.setup_link(hw, autoneg, negotiation, true);
5023 adapter->flags |= IXGBE_FLAG_NEED_LINK_UPDATE; 5047 adapter->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
@@ -5633,7 +5657,8 @@ static u16 ixgbe_select_queue(struct net_device *dev, struct sk_buff *skb)
5633 5657
5634#ifdef IXGBE_FCOE 5658#ifdef IXGBE_FCOE
5635 if ((adapter->flags & IXGBE_FLAG_FCOE_ENABLED) && 5659 if ((adapter->flags & IXGBE_FLAG_FCOE_ENABLED) &&
5636 (skb->protocol == htons(ETH_P_FCOE))) { 5660 ((skb->protocol == htons(ETH_P_FCOE)) ||
5661 (skb->protocol == htons(ETH_P_FIP)))) {
5637 txq &= (adapter->ring_feature[RING_F_FCOE].indices - 1); 5662 txq &= (adapter->ring_feature[RING_F_FCOE].indices - 1);
5638 txq += adapter->ring_feature[RING_F_FCOE].mask; 5663 txq += adapter->ring_feature[RING_F_FCOE].mask;
5639 return txq; 5664 return txq;
@@ -5680,18 +5705,25 @@ static netdev_tx_t ixgbe_xmit_frame(struct sk_buff *skb,
5680 5705
5681 tx_ring = adapter->tx_ring[skb->queue_mapping]; 5706 tx_ring = adapter->tx_ring[skb->queue_mapping];
5682 5707
5683 if ((adapter->flags & IXGBE_FLAG_FCOE_ENABLED) &&
5684 (skb->protocol == htons(ETH_P_FCOE))) {
5685 tx_flags |= IXGBE_TX_FLAGS_FCOE;
5686#ifdef IXGBE_FCOE 5708#ifdef IXGBE_FCOE
5709 if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) {
5687#ifdef CONFIG_IXGBE_DCB 5710#ifdef CONFIG_IXGBE_DCB
5688 tx_flags &= ~(IXGBE_TX_FLAGS_VLAN_PRIO_MASK 5711 /* for FCoE with DCB, we force the priority to what
5689 << IXGBE_TX_FLAGS_VLAN_SHIFT); 5712 * was specified by the switch */
5690 tx_flags |= ((adapter->fcoe.up << 13) 5713 if ((skb->protocol == htons(ETH_P_FCOE)) ||
5691 << IXGBE_TX_FLAGS_VLAN_SHIFT); 5714 (skb->protocol == htons(ETH_P_FIP))) {
5692#endif 5715 tx_flags &= ~(IXGBE_TX_FLAGS_VLAN_PRIO_MASK
5716 << IXGBE_TX_FLAGS_VLAN_SHIFT);
5717 tx_flags |= ((adapter->fcoe.up << 13)
5718 << IXGBE_TX_FLAGS_VLAN_SHIFT);
5719 }
5693#endif 5720#endif
5721 /* flag for FCoE offloads */
5722 if (skb->protocol == htons(ETH_P_FCOE))
5723 tx_flags |= IXGBE_TX_FLAGS_FCOE;
5694 } 5724 }
5725#endif
5726
5695 /* four things can cause us to need a context descriptor */ 5727 /* four things can cause us to need a context descriptor */
5696 if (skb_is_gso(skb) || 5728 if (skb_is_gso(skb) ||
5697 (skb->ip_summed == CHECKSUM_PARTIAL) || 5729 (skb->ip_summed == CHECKSUM_PARTIAL) ||
@@ -6046,7 +6078,6 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
6046 indices += min_t(unsigned int, num_possible_cpus(), 6078 indices += min_t(unsigned int, num_possible_cpus(),
6047 IXGBE_MAX_FCOE_INDICES); 6079 IXGBE_MAX_FCOE_INDICES);
6048#endif 6080#endif
6049 indices = min_t(unsigned int, indices, MAX_TX_QUEUES);
6050 netdev = alloc_etherdev_mq(sizeof(struct ixgbe_adapter), indices); 6081 netdev = alloc_etherdev_mq(sizeof(struct ixgbe_adapter), indices);
6051 if (!netdev) { 6082 if (!netdev) {
6052 err = -ENOMEM; 6083 err = -ENOMEM;
@@ -6230,6 +6261,10 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
6230 goto err_eeprom; 6261 goto err_eeprom;
6231 } 6262 }
6232 6263
6264 /* power down the optics */
6265 if (hw->phy.multispeed_fiber)
6266 hw->mac.ops.disable_tx_laser(hw);
6267
6233 init_timer(&adapter->watchdog_timer); 6268 init_timer(&adapter->watchdog_timer);
6234 adapter->watchdog_timer.function = &ixgbe_watchdog; 6269 adapter->watchdog_timer.function = &ixgbe_watchdog;
6235 adapter->watchdog_timer.data = (unsigned long)adapter; 6270 adapter->watchdog_timer.data = (unsigned long)adapter;
@@ -6245,9 +6280,6 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
6245 case IXGBE_DEV_ID_82599_KX4: 6280 case IXGBE_DEV_ID_82599_KX4:
6246 adapter->wol = (IXGBE_WUFC_MAG | IXGBE_WUFC_EX | 6281 adapter->wol = (IXGBE_WUFC_MAG | IXGBE_WUFC_EX |
6247 IXGBE_WUFC_MC | IXGBE_WUFC_BC); 6282 IXGBE_WUFC_MC | IXGBE_WUFC_BC);
6248 /* Enable ACPI wakeup in GRC */
6249 IXGBE_WRITE_REG(hw, IXGBE_GRC,
6250 (IXGBE_READ_REG(hw, IXGBE_GRC) & ~IXGBE_GRC_APME));
6251 break; 6283 break;
6252 default: 6284 default:
6253 adapter->wol = 0; 6285 adapter->wol = 0;
diff --git a/drivers/net/ixgbe/ixgbe_type.h b/drivers/net/ixgbe/ixgbe_type.h
index 2be90746659..534affcc38c 100644
--- a/drivers/net/ixgbe/ixgbe_type.h
+++ b/drivers/net/ixgbe/ixgbe_type.h
@@ -1298,6 +1298,7 @@
1298#define IXGBE_ETQF_FILTER_BCN 1 1298#define IXGBE_ETQF_FILTER_BCN 1
1299#define IXGBE_ETQF_FILTER_FCOE 2 1299#define IXGBE_ETQF_FILTER_FCOE 2
1300#define IXGBE_ETQF_FILTER_1588 3 1300#define IXGBE_ETQF_FILTER_1588 3
1301#define IXGBE_ETQF_FILTER_FIP 4
1301/* VLAN Control Bit Masks */ 1302/* VLAN Control Bit Masks */
1302#define IXGBE_VLNCTRL_VET 0x0000FFFF /* bits 0-15 */ 1303#define IXGBE_VLNCTRL_VET 0x0000FFFF /* bits 0-15 */
1303#define IXGBE_VLNCTRL_CFI 0x10000000 /* bit 28 */ 1304#define IXGBE_VLNCTRL_CFI 0x10000000 /* bit 28 */
@@ -2397,6 +2398,9 @@ struct ixgbe_mac_operations {
2397 s32 (*enable_rx_dma)(struct ixgbe_hw *, u32); 2398 s32 (*enable_rx_dma)(struct ixgbe_hw *, u32);
2398 2399
2399 /* Link */ 2400 /* Link */
2401 void (*disable_tx_laser)(struct ixgbe_hw *);
2402 void (*enable_tx_laser)(struct ixgbe_hw *);
2403 void (*flap_tx_laser)(struct ixgbe_hw *);
2400 s32 (*setup_link)(struct ixgbe_hw *, ixgbe_link_speed, bool, bool); 2404 s32 (*setup_link)(struct ixgbe_hw *, ixgbe_link_speed, bool, bool);
2401 s32 (*check_link)(struct ixgbe_hw *, ixgbe_link_speed *, bool *, bool); 2405 s32 (*check_link)(struct ixgbe_hw *, ixgbe_link_speed *, bool *, bool);
2402 s32 (*get_link_capabilities)(struct ixgbe_hw *, ixgbe_link_speed *, 2406 s32 (*get_link_capabilities)(struct ixgbe_hw *, ixgbe_link_speed *,
diff --git a/drivers/net/ixgbevf/ethtool.c b/drivers/net/ixgbevf/ethtool.c
index 399be0c34c3..4680b069b84 100644
--- a/drivers/net/ixgbevf/ethtool.c
+++ b/drivers/net/ixgbevf/ethtool.c
@@ -29,6 +29,7 @@
29 29
30#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/slab.h>
32#include <linux/pci.h> 33#include <linux/pci.h>
33#include <linux/netdevice.h> 34#include <linux/netdevice.h>
34#include <linux/ethtool.h> 35#include <linux/ethtool.h>
@@ -46,22 +47,32 @@ struct ixgbe_stats {
46 int sizeof_stat; 47 int sizeof_stat;
47 int stat_offset; 48 int stat_offset;
48 int base_stat_offset; 49 int base_stat_offset;
50 int saved_reset_offset;
49}; 51};
50 52
51#define IXGBEVF_STAT(m, b) sizeof(((struct ixgbevf_adapter *)0)->m), \ 53#define IXGBEVF_STAT(m, b, r) sizeof(((struct ixgbevf_adapter *)0)->m), \
52 offsetof(struct ixgbevf_adapter, m), \ 54 offsetof(struct ixgbevf_adapter, m), \
53 offsetof(struct ixgbevf_adapter, b) 55 offsetof(struct ixgbevf_adapter, b), \
56 offsetof(struct ixgbevf_adapter, r)
54static struct ixgbe_stats ixgbe_gstrings_stats[] = { 57static struct ixgbe_stats ixgbe_gstrings_stats[] = {
55 {"rx_packets", IXGBEVF_STAT(stats.vfgprc, stats.base_vfgprc)}, 58 {"rx_packets", IXGBEVF_STAT(stats.vfgprc, stats.base_vfgprc,
56 {"tx_packets", IXGBEVF_STAT(stats.vfgptc, stats.base_vfgptc)}, 59 stats.saved_reset_vfgprc)},
57 {"rx_bytes", IXGBEVF_STAT(stats.vfgorc, stats.base_vfgorc)}, 60 {"tx_packets", IXGBEVF_STAT(stats.vfgptc, stats.base_vfgptc,
58 {"tx_bytes", IXGBEVF_STAT(stats.vfgotc, stats.base_vfgotc)}, 61 stats.saved_reset_vfgptc)},
59 {"tx_busy", IXGBEVF_STAT(tx_busy, zero_base)}, 62 {"rx_bytes", IXGBEVF_STAT(stats.vfgorc, stats.base_vfgorc,
60 {"multicast", IXGBEVF_STAT(stats.vfmprc, stats.base_vfmprc)}, 63 stats.saved_reset_vfgorc)},
61 {"rx_csum_offload_good", IXGBEVF_STAT(hw_csum_rx_good, zero_base)}, 64 {"tx_bytes", IXGBEVF_STAT(stats.vfgotc, stats.base_vfgotc,
62 {"rx_csum_offload_errors", IXGBEVF_STAT(hw_csum_rx_error, zero_base)}, 65 stats.saved_reset_vfgotc)},
63 {"tx_csum_offload_ctxt", IXGBEVF_STAT(hw_csum_tx_good, zero_base)}, 66 {"tx_busy", IXGBEVF_STAT(tx_busy, zero_base, zero_base)},
64 {"rx_header_split", IXGBEVF_STAT(rx_hdr_split, zero_base)}, 67 {"multicast", IXGBEVF_STAT(stats.vfmprc, stats.base_vfmprc,
68 stats.saved_reset_vfmprc)},
69 {"rx_csum_offload_good", IXGBEVF_STAT(hw_csum_rx_good, zero_base,
70 zero_base)},
71 {"rx_csum_offload_errors", IXGBEVF_STAT(hw_csum_rx_error, zero_base,
72 zero_base)},
73 {"tx_csum_offload_ctxt", IXGBEVF_STAT(hw_csum_tx_good, zero_base,
74 zero_base)},
75 {"rx_header_split", IXGBEVF_STAT(rx_hdr_split, zero_base, zero_base)},
65}; 76};
66 77
67#define IXGBE_QUEUE_STATS_LEN 0 78#define IXGBE_QUEUE_STATS_LEN 0
@@ -455,10 +466,14 @@ static void ixgbevf_get_ethtool_stats(struct net_device *netdev,
455 ixgbe_gstrings_stats[i].stat_offset; 466 ixgbe_gstrings_stats[i].stat_offset;
456 char *b = (char *)adapter + 467 char *b = (char *)adapter +
457 ixgbe_gstrings_stats[i].base_stat_offset; 468 ixgbe_gstrings_stats[i].base_stat_offset;
469 char *r = (char *)adapter +
470 ixgbe_gstrings_stats[i].saved_reset_offset;
458 data[i] = ((ixgbe_gstrings_stats[i].sizeof_stat == 471 data[i] = ((ixgbe_gstrings_stats[i].sizeof_stat ==
459 sizeof(u64)) ? *(u64 *)p : *(u32 *)p) - 472 sizeof(u64)) ? *(u64 *)p : *(u32 *)p) -
460 ((ixgbe_gstrings_stats[i].sizeof_stat == 473 ((ixgbe_gstrings_stats[i].sizeof_stat ==
461 sizeof(u64)) ? *(u64 *)b : *(u32 *)b); 474 sizeof(u64)) ? *(u64 *)b : *(u32 *)b) +
475 ((ixgbe_gstrings_stats[i].sizeof_stat ==
476 sizeof(u64)) ? *(u64 *)r : *(u32 *)r);
462 } 477 }
463} 478}
464 479
diff --git a/drivers/net/ixgbevf/ixgbevf_main.c b/drivers/net/ixgbevf/ixgbevf_main.c
index ca653c49b76..0cd6202dfac 100644
--- a/drivers/net/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ixgbevf/ixgbevf_main.c
@@ -39,6 +39,7 @@
39#include <linux/ip.h> 39#include <linux/ip.h>
40#include <linux/tcp.h> 40#include <linux/tcp.h>
41#include <linux/ipv6.h> 41#include <linux/ipv6.h>
42#include <linux/slab.h>
42#include <net/checksum.h> 43#include <net/checksum.h>
43#include <net/ip6_checksum.h> 44#include <net/ip6_checksum.h>
44#include <linux/ethtool.h> 45#include <linux/ethtool.h>
@@ -965,7 +966,7 @@ static irqreturn_t ixgbevf_msix_mbx(int irq, void *data)
965 966
966 if ((msg & IXGBE_MBVFICR_VFREQ_MASK) == IXGBE_PF_CONTROL_MSG) 967 if ((msg & IXGBE_MBVFICR_VFREQ_MASK) == IXGBE_PF_CONTROL_MSG)
967 mod_timer(&adapter->watchdog_timer, 968 mod_timer(&adapter->watchdog_timer,
968 round_jiffies(jiffies + 10)); 969 round_jiffies(jiffies + 1));
969 970
970 return IRQ_HANDLED; 971 return IRQ_HANDLED;
971} 972}
@@ -1610,6 +1611,44 @@ static inline void ixgbevf_rx_desc_queue_enable(struct ixgbevf_adapter *adapter,
1610 (adapter->rx_ring[rxr].count - 1)); 1611 (adapter->rx_ring[rxr].count - 1));
1611} 1612}
1612 1613
1614static void ixgbevf_save_reset_stats(struct ixgbevf_adapter *adapter)
1615{
1616 /* Only save pre-reset stats if there are some */
1617 if (adapter->stats.vfgprc || adapter->stats.vfgptc) {
1618 adapter->stats.saved_reset_vfgprc += adapter->stats.vfgprc -
1619 adapter->stats.base_vfgprc;
1620 adapter->stats.saved_reset_vfgptc += adapter->stats.vfgptc -
1621 adapter->stats.base_vfgptc;
1622 adapter->stats.saved_reset_vfgorc += adapter->stats.vfgorc -
1623 adapter->stats.base_vfgorc;
1624 adapter->stats.saved_reset_vfgotc += adapter->stats.vfgotc -
1625 adapter->stats.base_vfgotc;
1626 adapter->stats.saved_reset_vfmprc += adapter->stats.vfmprc -
1627 adapter->stats.base_vfmprc;
1628 }
1629}
1630
1631static void ixgbevf_init_last_counter_stats(struct ixgbevf_adapter *adapter)
1632{
1633 struct ixgbe_hw *hw = &adapter->hw;
1634
1635 adapter->stats.last_vfgprc = IXGBE_READ_REG(hw, IXGBE_VFGPRC);
1636 adapter->stats.last_vfgorc = IXGBE_READ_REG(hw, IXGBE_VFGORC_LSB);
1637 adapter->stats.last_vfgorc |=
1638 (((u64)(IXGBE_READ_REG(hw, IXGBE_VFGORC_MSB))) << 32);
1639 adapter->stats.last_vfgptc = IXGBE_READ_REG(hw, IXGBE_VFGPTC);
1640 adapter->stats.last_vfgotc = IXGBE_READ_REG(hw, IXGBE_VFGOTC_LSB);
1641 adapter->stats.last_vfgotc |=
1642 (((u64)(IXGBE_READ_REG(hw, IXGBE_VFGOTC_MSB))) << 32);
1643 adapter->stats.last_vfmprc = IXGBE_READ_REG(hw, IXGBE_VFMPRC);
1644
1645 adapter->stats.base_vfgprc = adapter->stats.last_vfgprc;
1646 adapter->stats.base_vfgorc = adapter->stats.last_vfgorc;
1647 adapter->stats.base_vfgptc = adapter->stats.last_vfgptc;
1648 adapter->stats.base_vfgotc = adapter->stats.last_vfgotc;
1649 adapter->stats.base_vfmprc = adapter->stats.last_vfmprc;
1650}
1651
1613static int ixgbevf_up_complete(struct ixgbevf_adapter *adapter) 1652static int ixgbevf_up_complete(struct ixgbevf_adapter *adapter)
1614{ 1653{
1615 struct net_device *netdev = adapter->netdev; 1654 struct net_device *netdev = adapter->netdev;
@@ -1656,6 +1695,9 @@ static int ixgbevf_up_complete(struct ixgbevf_adapter *adapter)
1656 /* enable transmits */ 1695 /* enable transmits */
1657 netif_tx_start_all_queues(netdev); 1696 netif_tx_start_all_queues(netdev);
1658 1697
1698 ixgbevf_save_reset_stats(adapter);
1699 ixgbevf_init_last_counter_stats(adapter);
1700
1659 /* bring the link up in the watchdog, this could race with our first 1701 /* bring the link up in the watchdog, this could race with our first
1660 * link up interrupt but shouldn't be a problem */ 1702 * link up interrupt but shouldn't be a problem */
1661 adapter->flags |= IXGBE_FLAG_NEED_LINK_UPDATE; 1703 adapter->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
@@ -2228,27 +2270,6 @@ out:
2228 return err; 2270 return err;
2229} 2271}
2230 2272
2231static void ixgbevf_init_last_counter_stats(struct ixgbevf_adapter *adapter)
2232{
2233 struct ixgbe_hw *hw = &adapter->hw;
2234
2235 adapter->stats.last_vfgprc = IXGBE_READ_REG(hw, IXGBE_VFGPRC);
2236 adapter->stats.last_vfgorc = IXGBE_READ_REG(hw, IXGBE_VFGORC_LSB);
2237 adapter->stats.last_vfgorc |=
2238 (((u64)(IXGBE_READ_REG(hw, IXGBE_VFGORC_MSB))) << 32);
2239 adapter->stats.last_vfgptc = IXGBE_READ_REG(hw, IXGBE_VFGPTC);
2240 adapter->stats.last_vfgotc = IXGBE_READ_REG(hw, IXGBE_VFGOTC_LSB);
2241 adapter->stats.last_vfgotc |=
2242 (((u64)(IXGBE_READ_REG(hw, IXGBE_VFGOTC_MSB))) << 32);
2243 adapter->stats.last_vfmprc = IXGBE_READ_REG(hw, IXGBE_VFMPRC);
2244
2245 adapter->stats.base_vfgprc = adapter->stats.last_vfgprc;
2246 adapter->stats.base_vfgorc = adapter->stats.last_vfgorc;
2247 adapter->stats.base_vfgptc = adapter->stats.last_vfgptc;
2248 adapter->stats.base_vfgotc = adapter->stats.last_vfgotc;
2249 adapter->stats.base_vfmprc = adapter->stats.last_vfmprc;
2250}
2251
2252#define UPDATE_VF_COUNTER_32bit(reg, last_counter, counter) \ 2273#define UPDATE_VF_COUNTER_32bit(reg, last_counter, counter) \
2253 { \ 2274 { \
2254 u32 current_counter = IXGBE_READ_REG(hw, reg); \ 2275 u32 current_counter = IXGBE_READ_REG(hw, reg); \
@@ -2399,7 +2420,7 @@ static void ixgbevf_watchdog_task(struct work_struct *work)
2399 if (!netif_carrier_ok(netdev)) { 2420 if (!netif_carrier_ok(netdev)) {
2400 hw_dbg(&adapter->hw, "NIC Link is Up %s, ", 2421 hw_dbg(&adapter->hw, "NIC Link is Up %s, ",
2401 ((link_speed == IXGBE_LINK_SPEED_10GB_FULL) ? 2422 ((link_speed == IXGBE_LINK_SPEED_10GB_FULL) ?
2402 "10 Gbps" : "1 Gbps")); 2423 "10 Gbps\n" : "1 Gbps\n"));
2403 netif_carrier_on(netdev); 2424 netif_carrier_on(netdev);
2404 netif_tx_wake_all_queues(netdev); 2425 netif_tx_wake_all_queues(netdev);
2405 } else { 2426 } else {
@@ -2416,9 +2437,9 @@ static void ixgbevf_watchdog_task(struct work_struct *work)
2416 } 2437 }
2417 } 2438 }
2418 2439
2419pf_has_reset:
2420 ixgbevf_update_stats(adapter); 2440 ixgbevf_update_stats(adapter);
2421 2441
2442pf_has_reset:
2422 /* Force detection of hung controller every watchdog period */ 2443 /* Force detection of hung controller every watchdog period */
2423 adapter->detect_tx_hung = true; 2444 adapter->detect_tx_hung = true;
2424 2445
@@ -2675,7 +2696,7 @@ static int ixgbevf_open(struct net_device *netdev)
2675 if (hw->adapter_stopped) { 2696 if (hw->adapter_stopped) {
2676 err = IXGBE_ERR_MBX; 2697 err = IXGBE_ERR_MBX;
2677 printk(KERN_ERR "Unable to start - perhaps the PF" 2698 printk(KERN_ERR "Unable to start - perhaps the PF"
2678 "Driver isn't up yet\n"); 2699 " Driver isn't up yet\n");
2679 goto err_setup_reset; 2700 goto err_setup_reset;
2680 } 2701 }
2681 } 2702 }
@@ -2923,9 +2944,10 @@ static int ixgbevf_tx_map(struct ixgbevf_adapter *adapter,
2923 struct ixgbevf_tx_buffer *tx_buffer_info; 2944 struct ixgbevf_tx_buffer *tx_buffer_info;
2924 unsigned int len; 2945 unsigned int len;
2925 unsigned int total = skb->len; 2946 unsigned int total = skb->len;
2926 unsigned int offset = 0, size, count = 0, i; 2947 unsigned int offset = 0, size, count = 0;
2927 unsigned int nr_frags = skb_shinfo(skb)->nr_frags; 2948 unsigned int nr_frags = skb_shinfo(skb)->nr_frags;
2928 unsigned int f; 2949 unsigned int f;
2950 int i;
2929 2951
2930 i = tx_ring->next_to_use; 2952 i = tx_ring->next_to_use;
2931 2953
@@ -3390,8 +3412,6 @@ static int __devinit ixgbevf_probe(struct pci_dev *pdev,
3390 /* setup the private structure */ 3412 /* setup the private structure */
3391 err = ixgbevf_sw_init(adapter); 3413 err = ixgbevf_sw_init(adapter);
3392 3414
3393 ixgbevf_init_last_counter_stats(adapter);
3394
3395#ifdef MAX_SKB_FRAGS 3415#ifdef MAX_SKB_FRAGS
3396 netdev->features = NETIF_F_SG | 3416 netdev->features = NETIF_F_SG |
3397 NETIF_F_IP_CSUM | 3417 NETIF_F_IP_CSUM |
@@ -3449,6 +3469,8 @@ static int __devinit ixgbevf_probe(struct pci_dev *pdev,
3449 3469
3450 adapter->netdev_registered = true; 3470 adapter->netdev_registered = true;
3451 3471
3472 ixgbevf_init_last_counter_stats(adapter);
3473
3452 /* print the MAC address */ 3474 /* print the MAC address */
3453 hw_dbg(hw, "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n", 3475 hw_dbg(hw, "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n",
3454 netdev->dev_addr[0], 3476 netdev->dev_addr[0],
diff --git a/drivers/net/ixgbevf/vf.h b/drivers/net/ixgbevf/vf.h
index 799600e9270..1f31b052d4b 100644
--- a/drivers/net/ixgbevf/vf.h
+++ b/drivers/net/ixgbevf/vf.h
@@ -157,6 +157,12 @@ struct ixgbevf_hw_stats {
157 u64 vfgorc; 157 u64 vfgorc;
158 u64 vfgotc; 158 u64 vfgotc;
159 u64 vfmprc; 159 u64 vfmprc;
160
161 u64 saved_reset_vfgprc;
162 u64 saved_reset_vfgptc;
163 u64 saved_reset_vfgorc;
164 u64 saved_reset_vfgotc;
165 u64 saved_reset_vfmprc;
160}; 166};
161 167
162struct ixgbevf_info { 168struct ixgbevf_info {
diff --git a/drivers/net/ixp2000/ixpdev.c b/drivers/net/ixp2000/ixpdev.c
index e9d9d595e1b..d5932ca3e27 100644
--- a/drivers/net/ixp2000/ixpdev.c
+++ b/drivers/net/ixp2000/ixpdev.c
@@ -15,6 +15,7 @@
15#include <linux/etherdevice.h> 15#include <linux/etherdevice.h>
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/moduleparam.h> 17#include <linux/moduleparam.h>
18#include <linux/gfp.h>
18#include <asm/hardware/uengine.h> 19#include <asm/hardware/uengine.h>
19#include <asm/io.h> 20#include <asm/io.h>
20#include "ixp2400_rx.ucode" 21#include "ixp2400_rx.ucode"
diff --git a/drivers/net/jazzsonic.c b/drivers/net/jazzsonic.c
index f47d4d663b1..3e6aaf9e5ce 100644
--- a/drivers/net/jazzsonic.c
+++ b/drivers/net/jazzsonic.c
@@ -22,11 +22,11 @@
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/types.h> 23#include <linux/types.h>
24#include <linux/fcntl.h> 24#include <linux/fcntl.h>
25#include <linux/gfp.h>
25#include <linux/interrupt.h> 26#include <linux/interrupt.h>
26#include <linux/init.h> 27#include <linux/init.h>
27#include <linux/ioport.h> 28#include <linux/ioport.h>
28#include <linux/in.h> 29#include <linux/in.h>
29#include <linux/slab.h>
30#include <linux/string.h> 30#include <linux/string.h>
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/errno.h> 32#include <linux/errno.h>
@@ -35,6 +35,7 @@
35#include <linux/skbuff.h> 35#include <linux/skbuff.h>
36#include <linux/platform_device.h> 36#include <linux/platform_device.h>
37#include <linux/dma-mapping.h> 37#include <linux/dma-mapping.h>
38#include <linux/slab.h>
38 39
39#include <asm/bootinfo.h> 40#include <asm/bootinfo.h>
40#include <asm/system.h> 41#include <asm/system.h>
diff --git a/drivers/net/jme.c b/drivers/net/jme.c
index 0f31497833d..b705ad3a53a 100644
--- a/drivers/net/jme.c
+++ b/drivers/net/jme.c
@@ -37,6 +37,7 @@
37#include <linux/tcp.h> 37#include <linux/tcp.h>
38#include <linux/udp.h> 38#include <linux/udp.h>
39#include <linux/if_vlan.h> 39#include <linux/if_vlan.h>
40#include <linux/slab.h>
40#include <net/ip6_checksum.h> 41#include <net/ip6_checksum.h>
41#include "jme.h" 42#include "jme.h"
42 43
@@ -946,6 +947,8 @@ jme_alloc_and_feed_skb(struct jme_adapter *jme, int idx)
946 jme->jme_vlan_rx(skb, jme->vlgrp, 947 jme->jme_vlan_rx(skb, jme->vlgrp,
947 le16_to_cpu(rxdesc->descwb.vlan)); 948 le16_to_cpu(rxdesc->descwb.vlan));
948 NET_STAT(jme).rx_bytes += 4; 949 NET_STAT(jme).rx_bytes += 4;
950 } else {
951 dev_kfree_skb(skb);
949 } 952 }
950 } else { 953 } else {
951 jme->jme_rx(skb); 954 jme->jme_rx(skb);
@@ -2081,12 +2084,45 @@ jme_tx_timeout(struct net_device *netdev)
2081 jme_reset_link(jme); 2084 jme_reset_link(jme);
2082} 2085}
2083 2086
2087static inline void jme_pause_rx(struct jme_adapter *jme)
2088{
2089 atomic_dec(&jme->link_changing);
2090
2091 jme_set_rx_pcc(jme, PCC_OFF);
2092 if (test_bit(JME_FLAG_POLL, &jme->flags)) {
2093 JME_NAPI_DISABLE(jme);
2094 } else {
2095 tasklet_disable(&jme->rxclean_task);
2096 tasklet_disable(&jme->rxempty_task);
2097 }
2098}
2099
2100static inline void jme_resume_rx(struct jme_adapter *jme)
2101{
2102 struct dynpcc_info *dpi = &(jme->dpi);
2103
2104 if (test_bit(JME_FLAG_POLL, &jme->flags)) {
2105 JME_NAPI_ENABLE(jme);
2106 } else {
2107 tasklet_hi_enable(&jme->rxclean_task);
2108 tasklet_hi_enable(&jme->rxempty_task);
2109 }
2110 dpi->cur = PCC_P1;
2111 dpi->attempt = PCC_P1;
2112 dpi->cnt = 0;
2113 jme_set_rx_pcc(jme, PCC_P1);
2114
2115 atomic_inc(&jme->link_changing);
2116}
2117
2084static void 2118static void
2085jme_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp) 2119jme_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
2086{ 2120{
2087 struct jme_adapter *jme = netdev_priv(netdev); 2121 struct jme_adapter *jme = netdev_priv(netdev);
2088 2122
2123 jme_pause_rx(jme);
2089 jme->vlgrp = grp; 2124 jme->vlgrp = grp;
2125 jme_resume_rx(jme);
2090} 2126}
2091 2127
2092static void 2128static void
diff --git a/drivers/net/jme.h b/drivers/net/jme.h
index c19db9146a2..07ad3a45718 100644
--- a/drivers/net/jme.h
+++ b/drivers/net/jme.h
@@ -25,7 +25,7 @@
25#define __JME_H_INCLUDED__ 25#define __JME_H_INCLUDED__
26 26
27#define DRV_NAME "jme" 27#define DRV_NAME "jme"
28#define DRV_VERSION "1.0.5" 28#define DRV_VERSION "1.0.6"
29#define PFX DRV_NAME ": " 29#define PFX DRV_NAME ": "
30 30
31#define PCI_DEVICE_ID_JMICRON_JMC250 0x0250 31#define PCI_DEVICE_ID_JMICRON_JMC250 0x0250
diff --git a/drivers/net/ks8851.c b/drivers/net/ks8851.c
index 0573e0bb444..9e9f9b34976 100644
--- a/drivers/net/ks8851.c
+++ b/drivers/net/ks8851.c
@@ -722,12 +722,14 @@ static void ks8851_tx_work(struct work_struct *work)
722 txb = skb_dequeue(&ks->txq); 722 txb = skb_dequeue(&ks->txq);
723 last = skb_queue_empty(&ks->txq); 723 last = skb_queue_empty(&ks->txq);
724 724
725 ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr | RXQCR_SDA); 725 if (txb != NULL) {
726 ks8851_wrpkt(ks, txb, last); 726 ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr | RXQCR_SDA);
727 ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr); 727 ks8851_wrpkt(ks, txb, last);
728 ks8851_wrreg16(ks, KS_TXQCR, TXQCR_METFE); 728 ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr);
729 ks8851_wrreg16(ks, KS_TXQCR, TXQCR_METFE);
729 730
730 ks8851_done_tx(ks, txb); 731 ks8851_done_tx(ks, txb);
732 }
731 } 733 }
732 734
733 mutex_unlock(&ks->lock); 735 mutex_unlock(&ks->lock);
@@ -976,7 +978,6 @@ static void ks8851_set_rx_mode(struct net_device *dev)
976 crc >>= (32 - 6); /* get top six bits */ 978 crc >>= (32 - 6); /* get top six bits */
977 979
978 rxctrl.mchash[crc >> 4] |= (1 << (crc & 0xf)); 980 rxctrl.mchash[crc >> 4] |= (1 << (crc & 0xf));
979 mcptr = mcptr->next;
980 } 981 }
981 982
982 rxctrl.rxcr1 = RXCR1_RXME | RXCR1_RXPAFMA; 983 rxctrl.rxcr1 = RXCR1_RXME | RXCR1_RXPAFMA;
diff --git a/drivers/net/ks8851_mll.c b/drivers/net/ks8851_mll.c
index 84b0e15831f..6354ab3a45a 100644
--- a/drivers/net/ks8851_mll.c
+++ b/drivers/net/ks8851_mll.c
@@ -31,6 +31,7 @@
31#include <linux/mii.h> 31#include <linux/mii.h>
32#include <linux/platform_device.h> 32#include <linux/platform_device.h>
33#include <linux/delay.h> 33#include <linux/delay.h>
34#include <linux/slab.h>
34 35
35#define DRV_NAME "ks8851_mll" 36#define DRV_NAME "ks8851_mll"
36 37
diff --git a/drivers/net/ksz884x.c b/drivers/net/ksz884x.c
index 0f59099ee72..0606a1f359f 100644
--- a/drivers/net/ksz884x.c
+++ b/drivers/net/ksz884x.c
@@ -30,6 +30,7 @@
30#include <linux/if_vlan.h> 30#include <linux/if_vlan.h>
31#include <linux/crc32.h> 31#include <linux/crc32.h>
32#include <linux/sched.h> 32#include <linux/sched.h>
33#include <linux/slab.h>
33 34
34 35
35/* DMA Registers */ 36/* DMA Registers */
@@ -6322,7 +6323,7 @@ static int netdev_set_eeprom(struct net_device *dev,
6322 int len; 6323 int len;
6323 6324
6324 if (eeprom->magic != EEPROM_MAGIC) 6325 if (eeprom->magic != EEPROM_MAGIC)
6325 return 1; 6326 return -EINVAL;
6326 6327
6327 len = (eeprom->offset + eeprom->len + 1) / 2; 6328 len = (eeprom->offset + eeprom->len + 1) / 2;
6328 for (i = eeprom->offset / 2; i < len; i++) 6329 for (i = eeprom->offset / 2; i < len; i++)
diff --git a/drivers/net/lasi_82596.c b/drivers/net/lasi_82596.c
index b77238dbafb..6eba352c52e 100644
--- a/drivers/net/lasi_82596.c
+++ b/drivers/net/lasi_82596.c
@@ -74,7 +74,6 @@
74#include <linux/ptrace.h> 74#include <linux/ptrace.h>
75#include <linux/errno.h> 75#include <linux/errno.h>
76#include <linux/ioport.h> 76#include <linux/ioport.h>
77#include <linux/slab.h>
78#include <linux/interrupt.h> 77#include <linux/interrupt.h>
79#include <linux/delay.h> 78#include <linux/delay.h>
80#include <linux/netdevice.h> 79#include <linux/netdevice.h>
diff --git a/drivers/net/lib82596.c b/drivers/net/lib82596.c
index 443c39a3732..973390b82ec 100644
--- a/drivers/net/lib82596.c
+++ b/drivers/net/lib82596.c
@@ -73,7 +73,6 @@
73#include <linux/string.h> 73#include <linux/string.h>
74#include <linux/errno.h> 74#include <linux/errno.h>
75#include <linux/ioport.h> 75#include <linux/ioport.h>
76#include <linux/slab.h>
77#include <linux/interrupt.h> 76#include <linux/interrupt.h>
78#include <linux/delay.h> 77#include <linux/delay.h>
79#include <linux/netdevice.h> 78#include <linux/netdevice.h>
@@ -85,6 +84,7 @@
85#include <linux/dma-mapping.h> 84#include <linux/dma-mapping.h>
86#include <linux/io.h> 85#include <linux/io.h>
87#include <linux/irq.h> 86#include <linux/irq.h>
87#include <linux/gfp.h>
88 88
89/* DEBUG flags 89/* DEBUG flags
90 */ 90 */
diff --git a/drivers/net/ll_temac_main.c b/drivers/net/ll_temac_main.c
index a18e3485476..ba617e3cf1b 100644
--- a/drivers/net/ll_temac_main.c
+++ b/drivers/net/ll_temac_main.c
@@ -49,6 +49,7 @@
49#include <linux/in.h> 49#include <linux/in.h>
50#include <linux/io.h> 50#include <linux/io.h>
51#include <linux/ip.h> 51#include <linux/ip.h>
52#include <linux/slab.h>
52 53
53#include "ll_temac.h" 54#include "ll_temac.h"
54 55
diff --git a/drivers/net/ll_temac_mdio.c b/drivers/net/ll_temac_mdio.c
index da0e462308d..5ae28c975b3 100644
--- a/drivers/net/ll_temac_mdio.c
+++ b/drivers/net/ll_temac_mdio.c
@@ -10,6 +10,7 @@
10#include <linux/phy.h> 10#include <linux/phy.h>
11#include <linux/of.h> 11#include <linux/of.h>
12#include <linux/of_device.h> 12#include <linux/of_device.h>
13#include <linux/slab.h>
13#include <linux/of_mdio.h> 14#include <linux/of_mdio.h>
14 15
15#include "ll_temac.h" 16#include "ll_temac.h"
diff --git a/drivers/net/mac8390.c b/drivers/net/mac8390.c
index a8768672dc5..c8e68fde066 100644
--- a/drivers/net/mac8390.c
+++ b/drivers/net/mac8390.c
@@ -28,7 +28,6 @@
28#include <linux/ioport.h> 28#include <linux/ioport.h>
29#include <linux/nubus.h> 29#include <linux/nubus.h>
30#include <linux/in.h> 30#include <linux/in.h>
31#include <linux/slab.h>
32#include <linux/string.h> 31#include <linux/string.h>
33#include <linux/errno.h> 32#include <linux/errno.h>
34#include <linux/init.h> 33#include <linux/init.h>
diff --git a/drivers/net/mac89x0.c b/drivers/net/mac89x0.c
index c292a608f9a..c0876e915ee 100644
--- a/drivers/net/mac89x0.c
+++ b/drivers/net/mac89x0.c
@@ -88,7 +88,6 @@ static char *version =
88#include <linux/interrupt.h> 88#include <linux/interrupt.h>
89#include <linux/ioport.h> 89#include <linux/ioport.h>
90#include <linux/in.h> 90#include <linux/in.h>
91#include <linux/slab.h>
92#include <linux/string.h> 91#include <linux/string.h>
93#include <linux/nubus.h> 92#include <linux/nubus.h>
94#include <linux/errno.h> 93#include <linux/errno.h>
@@ -98,6 +97,7 @@ static char *version =
98#include <linux/skbuff.h> 97#include <linux/skbuff.h>
99#include <linux/delay.h> 98#include <linux/delay.h>
100#include <linux/bitops.h> 99#include <linux/bitops.h>
100#include <linux/gfp.h>
101 101
102#include <asm/system.h> 102#include <asm/system.h>
103#include <asm/io.h> 103#include <asm/io.h>
diff --git a/drivers/net/mace.c b/drivers/net/mace.c
index ab5f0bf6d1a..962c41d0c8d 100644
--- a/drivers/net/mace.c
+++ b/drivers/net/mace.c
@@ -16,6 +16,7 @@
16#include <linux/crc32.h> 16#include <linux/crc32.h>
17#include <linux/spinlock.h> 17#include <linux/spinlock.h>
18#include <linux/bitrev.h> 18#include <linux/bitrev.h>
19#include <linux/slab.h>
19#include <asm/prom.h> 20#include <asm/prom.h>
20#include <asm/dbdma.h> 21#include <asm/dbdma.h>
21#include <asm/io.h> 22#include <asm/io.h>
diff --git a/drivers/net/macmace.c b/drivers/net/macmace.c
index 13ba8f4afb7..52e9a51c4c4 100644
--- a/drivers/net/macmace.c
+++ b/drivers/net/macmace.c
@@ -30,6 +30,7 @@
30#include <linux/bitrev.h> 30#include <linux/bitrev.h>
31#include <linux/dma-mapping.h> 31#include <linux/dma-mapping.h>
32#include <linux/platform_device.h> 32#include <linux/platform_device.h>
33#include <linux/gfp.h>
33#include <asm/io.h> 34#include <asm/io.h>
34#include <asm/irq.h> 35#include <asm/irq.h>
35#include <asm/macintosh.h> 36#include <asm/macintosh.h>
diff --git a/drivers/net/macsonic.c b/drivers/net/macsonic.c
index 24109c28810..adb54fe2d82 100644
--- a/drivers/net/macsonic.c
+++ b/drivers/net/macsonic.c
@@ -35,11 +35,11 @@
35#include <linux/module.h> 35#include <linux/module.h>
36#include <linux/types.h> 36#include <linux/types.h>
37#include <linux/fcntl.h> 37#include <linux/fcntl.h>
38#include <linux/gfp.h>
38#include <linux/interrupt.h> 39#include <linux/interrupt.h>
39#include <linux/init.h> 40#include <linux/init.h>
40#include <linux/ioport.h> 41#include <linux/ioport.h>
41#include <linux/in.h> 42#include <linux/in.h>
42#include <linux/slab.h>
43#include <linux/string.h> 43#include <linux/string.h>
44#include <linux/delay.h> 44#include <linux/delay.h>
45#include <linux/nubus.h> 45#include <linux/nubus.h>
@@ -50,6 +50,7 @@
50#include <linux/platform_device.h> 50#include <linux/platform_device.h>
51#include <linux/dma-mapping.h> 51#include <linux/dma-mapping.h>
52#include <linux/bitrev.h> 52#include <linux/bitrev.h>
53#include <linux/slab.h>
53 54
54#include <asm/bootinfo.h> 55#include <asm/bootinfo.h>
55#include <asm/system.h> 56#include <asm/system.h>
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index 55ceae09738..abba3cc81f1 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -9,6 +9,7 @@
9#include <linux/cache.h> 9#include <linux/cache.h>
10#include <linux/sched.h> 10#include <linux/sched.h>
11#include <linux/types.h> 11#include <linux/types.h>
12#include <linux/slab.h>
12#include <linux/init.h> 13#include <linux/init.h>
13#include <linux/wait.h> 14#include <linux/wait.h>
14#include <linux/cdev.h> 15#include <linux/cdev.h>
diff --git a/drivers/net/mlx4/cmd.c b/drivers/net/mlx4/cmd.c
index 65ec77dc31f..23cee7b6af9 100644
--- a/drivers/net/mlx4/cmd.c
+++ b/drivers/net/mlx4/cmd.c
@@ -33,6 +33,7 @@
33 */ 33 */
34 34
35#include <linux/sched.h> 35#include <linux/sched.h>
36#include <linux/slab.h>
36#include <linux/pci.h> 37#include <linux/pci.h>
37#include <linux/errno.h> 38#include <linux/errno.h>
38 39
diff --git a/drivers/net/mlx4/cq.c b/drivers/net/mlx4/cq.c
index ccfe276943f..7cd34e9c7c7 100644
--- a/drivers/net/mlx4/cq.c
+++ b/drivers/net/mlx4/cq.c
@@ -35,6 +35,7 @@
35 */ 35 */
36 36
37#include <linux/hardirq.h> 37#include <linux/hardirq.h>
38#include <linux/gfp.h>
38 39
39#include <linux/mlx4/cmd.h> 40#include <linux/mlx4/cmd.h>
40#include <linux/mlx4/cq.h> 41#include <linux/mlx4/cq.h>
diff --git a/drivers/net/mlx4/en_main.c b/drivers/net/mlx4/en_main.c
index 507e11fce9e..cbabf14f95d 100644
--- a/drivers/net/mlx4/en_main.c
+++ b/drivers/net/mlx4/en_main.c
@@ -35,6 +35,7 @@
35#include <linux/module.h> 35#include <linux/module.h>
36#include <linux/delay.h> 36#include <linux/delay.h>
37#include <linux/netdevice.h> 37#include <linux/netdevice.h>
38#include <linux/slab.h>
38 39
39#include <linux/mlx4/driver.h> 40#include <linux/mlx4/driver.h>
40#include <linux/mlx4/device.h> 41#include <linux/mlx4/device.h>
diff --git a/drivers/net/mlx4/en_netdev.c b/drivers/net/mlx4/en_netdev.c
index c48b0f4b17b..73c3d20c645 100644
--- a/drivers/net/mlx4/en_netdev.c
+++ b/drivers/net/mlx4/en_netdev.c
@@ -35,6 +35,7 @@
35#include <linux/tcp.h> 35#include <linux/tcp.h>
36#include <linux/if_vlan.h> 36#include <linux/if_vlan.h>
37#include <linux/delay.h> 37#include <linux/delay.h>
38#include <linux/slab.h>
38 39
39#include <linux/mlx4/driver.h> 40#include <linux/mlx4/driver.h>
40#include <linux/mlx4/device.h> 41#include <linux/mlx4/device.h>
diff --git a/drivers/net/mlx4/en_resources.c b/drivers/net/mlx4/en_resources.c
index 16256784a94..0dfb4ec8a9d 100644
--- a/drivers/net/mlx4/en_resources.c
+++ b/drivers/net/mlx4/en_resources.c
@@ -31,6 +31,7 @@
31 * 31 *
32 */ 32 */
33 33
34#include <linux/slab.h>
34#include <linux/vmalloc.h> 35#include <linux/vmalloc.h>
35#include <linux/mlx4/qp.h> 36#include <linux/mlx4/qp.h>
36 37
diff --git a/drivers/net/mlx4/en_rx.c b/drivers/net/mlx4/en_rx.c
index 64394647ddd..8e2fcb7103c 100644
--- a/drivers/net/mlx4/en_rx.c
+++ b/drivers/net/mlx4/en_rx.c
@@ -32,6 +32,7 @@
32 */ 32 */
33 33
34#include <linux/mlx4/cq.h> 34#include <linux/mlx4/cq.h>
35#include <linux/slab.h>
35#include <linux/mlx4/qp.h> 36#include <linux/mlx4/qp.h>
36#include <linux/skbuff.h> 37#include <linux/skbuff.h>
37#include <linux/if_ether.h> 38#include <linux/if_ether.h>
diff --git a/drivers/net/mlx4/en_tx.c b/drivers/net/mlx4/en_tx.c
index 3d1396af946..580968f304e 100644
--- a/drivers/net/mlx4/en_tx.c
+++ b/drivers/net/mlx4/en_tx.c
@@ -33,6 +33,7 @@
33 33
34#include <asm/page.h> 34#include <asm/page.h>
35#include <linux/mlx4/cq.h> 35#include <linux/mlx4/cq.h>
36#include <linux/slab.h>
36#include <linux/mlx4/qp.h> 37#include <linux/mlx4/qp.h>
37#include <linux/skbuff.h> 38#include <linux/skbuff.h>
38#include <linux/if_vlan.h> 39#include <linux/if_vlan.h>
diff --git a/drivers/net/mlx4/eq.c b/drivers/net/mlx4/eq.c
index bffb7995cb7..7365bf488b8 100644
--- a/drivers/net/mlx4/eq.c
+++ b/drivers/net/mlx4/eq.c
@@ -32,6 +32,7 @@
32 */ 32 */
33 33
34#include <linux/interrupt.h> 34#include <linux/interrupt.h>
35#include <linux/slab.h>
35#include <linux/mm.h> 36#include <linux/mm.h>
36#include <linux/dma-mapping.h> 37#include <linux/dma-mapping.h>
37 38
diff --git a/drivers/net/mlx4/icm.c b/drivers/net/mlx4/icm.c
index 04b382fcb8c..57288ca1395 100644
--- a/drivers/net/mlx4/icm.c
+++ b/drivers/net/mlx4/icm.c
@@ -34,6 +34,7 @@
34#include <linux/errno.h> 34#include <linux/errno.h>
35#include <linux/mm.h> 35#include <linux/mm.h>
36#include <linux/scatterlist.h> 36#include <linux/scatterlist.h>
37#include <linux/slab.h>
37 38
38#include <linux/mlx4/cmd.h> 39#include <linux/mlx4/cmd.h>
39 40
diff --git a/drivers/net/mlx4/intf.c b/drivers/net/mlx4/intf.c
index 0e7eb1038f9..55506780275 100644
--- a/drivers/net/mlx4/intf.c
+++ b/drivers/net/mlx4/intf.c
@@ -31,6 +31,8 @@
31 * SOFTWARE. 31 * SOFTWARE.
32 */ 32 */
33 33
34#include <linux/slab.h>
35
34#include "mlx4.h" 36#include "mlx4.h"
35 37
36struct mlx4_device_context { 38struct mlx4_device_context {
diff --git a/drivers/net/mlx4/main.c b/drivers/net/mlx4/main.c
index 8f6e816a739..e3e0d54a7c8 100644
--- a/drivers/net/mlx4/main.c
+++ b/drivers/net/mlx4/main.c
@@ -38,6 +38,7 @@
38#include <linux/errno.h> 38#include <linux/errno.h>
39#include <linux/pci.h> 39#include <linux/pci.h>
40#include <linux/dma-mapping.h> 40#include <linux/dma-mapping.h>
41#include <linux/slab.h>
41 42
42#include <linux/mlx4/device.h> 43#include <linux/mlx4/device.h>
43#include <linux/mlx4/doorbell.h> 44#include <linux/mlx4/doorbell.h>
@@ -1023,6 +1024,7 @@ static int mlx4_init_port_info(struct mlx4_dev *dev, int port)
1023 info->port_attr.attr.mode = S_IRUGO | S_IWUSR; 1024 info->port_attr.attr.mode = S_IRUGO | S_IWUSR;
1024 info->port_attr.show = show_port_type; 1025 info->port_attr.show = show_port_type;
1025 info->port_attr.store = set_port_type; 1026 info->port_attr.store = set_port_type;
1027 sysfs_attr_init(&info->port_attr.attr);
1026 1028
1027 err = device_create_file(&dev->pdev->dev, &info->port_attr); 1029 err = device_create_file(&dev->pdev->dev, &info->port_attr);
1028 if (err) { 1030 if (err) {
diff --git a/drivers/net/mlx4/mcg.c b/drivers/net/mlx4/mcg.c
index 5ccbce9866f..c4f88b7ef7b 100644
--- a/drivers/net/mlx4/mcg.c
+++ b/drivers/net/mlx4/mcg.c
@@ -32,7 +32,6 @@
32 */ 32 */
33 33
34#include <linux/string.h> 34#include <linux/string.h>
35#include <linux/slab.h>
36 35
37#include <linux/mlx4/cmd.h> 36#include <linux/mlx4/cmd.h>
38 37
diff --git a/drivers/net/mlx4/mr.c b/drivers/net/mlx4/mr.c
index ca7ab8e7b4c..3dc69be4949 100644
--- a/drivers/net/mlx4/mr.c
+++ b/drivers/net/mlx4/mr.c
@@ -33,6 +33,7 @@
33 */ 33 */
34 34
35#include <linux/errno.h> 35#include <linux/errno.h>
36#include <linux/slab.h>
36 37
37#include <linux/mlx4/cmd.h> 38#include <linux/mlx4/cmd.h>
38 39
diff --git a/drivers/net/mlx4/profile.c b/drivers/net/mlx4/profile.c
index ca25b9dc837..5caf0115fa5 100644
--- a/drivers/net/mlx4/profile.c
+++ b/drivers/net/mlx4/profile.c
@@ -32,6 +32,8 @@
32 * SOFTWARE. 32 * SOFTWARE.
33 */ 33 */
34 34
35#include <linux/slab.h>
36
35#include "mlx4.h" 37#include "mlx4.h"
36#include "fw.h" 38#include "fw.h"
37 39
diff --git a/drivers/net/mlx4/qp.c b/drivers/net/mlx4/qp.c
index 42ab9fc01d3..ec9350e5f21 100644
--- a/drivers/net/mlx4/qp.c
+++ b/drivers/net/mlx4/qp.c
@@ -33,6 +33,7 @@
33 * SOFTWARE. 33 * SOFTWARE.
34 */ 34 */
35 35
36#include <linux/gfp.h>
36#include <linux/mlx4/cmd.h> 37#include <linux/mlx4/cmd.h>
37#include <linux/mlx4/qp.h> 38#include <linux/mlx4/qp.h>
38 39
diff --git a/drivers/net/mlx4/srq.c b/drivers/net/mlx4/srq.c
index 1377d0dc8f1..3b07b80a045 100644
--- a/drivers/net/mlx4/srq.c
+++ b/drivers/net/mlx4/srq.c
@@ -32,6 +32,7 @@
32 */ 32 */
33 33
34#include <linux/mlx4/cmd.h> 34#include <linux/mlx4/cmd.h>
35#include <linux/gfp.h>
35 36
36#include "mlx4.h" 37#include "mlx4.h"
37#include "icm.h" 38#include "icm.h"
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index c97b6e4365a..8613a52ddf1 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -54,6 +54,7 @@
54#include <linux/io.h> 54#include <linux/io.h>
55#include <linux/types.h> 55#include <linux/types.h>
56#include <linux/inet_lro.h> 56#include <linux/inet_lro.h>
57#include <linux/slab.h>
57#include <asm/system.h> 58#include <asm/system.h>
58 59
59static char mv643xx_eth_driver_name[] = "mv643xx_eth"; 60static char mv643xx_eth_driver_name[] = "mv643xx_eth";
diff --git a/drivers/net/mvme147.c b/drivers/net/mvme147.c
index 93c709d63e2..3a7ad840d5b 100644
--- a/drivers/net/mvme147.c
+++ b/drivers/net/mvme147.c
@@ -10,11 +10,11 @@
10#include <linux/types.h> 10#include <linux/types.h>
11#include <linux/interrupt.h> 11#include <linux/interrupt.h>
12#include <linux/ioport.h> 12#include <linux/ioport.h>
13#include <linux/slab.h>
14#include <linux/string.h> 13#include <linux/string.h>
15#include <linux/delay.h> 14#include <linux/delay.h>
16#include <linux/init.h> 15#include <linux/init.h>
17#include <linux/errno.h> 16#include <linux/errno.h>
17#include <linux/gfp.h>
18/* Used for the temporal inet entries and routing */ 18/* Used for the temporal inet entries and routing */
19#include <linux/socket.h> 19#include <linux/socket.h>
20#include <linux/route.h> 20#include <linux/route.h>
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c
index e84dd3ee9c5..ecde0876a78 100644
--- a/drivers/net/myri10ge/myri10ge.c
+++ b/drivers/net/myri10ge/myri10ge.c
@@ -64,6 +64,7 @@
64#include <linux/moduleparam.h> 64#include <linux/moduleparam.h>
65#include <linux/io.h> 65#include <linux/io.h>
66#include <linux/log2.h> 66#include <linux/log2.h>
67#include <linux/slab.h>
67#include <net/checksum.h> 68#include <net/checksum.h>
68#include <net/ip.h> 69#include <net/ip.h>
69#include <net/tcp.h> 70#include <net/tcp.h>
@@ -1689,7 +1690,7 @@ myri10ge_set_pauseparam(struct net_device *netdev,
1689 if (pause->tx_pause != mgp->pause) 1690 if (pause->tx_pause != mgp->pause)
1690 return myri10ge_change_pause(mgp, pause->tx_pause); 1691 return myri10ge_change_pause(mgp, pause->tx_pause);
1691 if (pause->rx_pause != mgp->pause) 1692 if (pause->rx_pause != mgp->pause)
1692 return myri10ge_change_pause(mgp, pause->tx_pause); 1693 return myri10ge_change_pause(mgp, pause->rx_pause);
1693 if (pause->autoneg != 0) 1694 if (pause->autoneg != 0)
1694 return -EINVAL; 1695 return -EINVAL;
1695 return 0; 1696 return 0;
diff --git a/drivers/net/myri_sbus.c b/drivers/net/myri_sbus.c
index 8b431308535..b72e749afdf 100644
--- a/drivers/net/myri_sbus.c
+++ b/drivers/net/myri_sbus.c
@@ -14,7 +14,6 @@ static char version[] =
14#include <linux/interrupt.h> 14#include <linux/interrupt.h>
15#include <linux/ioport.h> 15#include <linux/ioport.h>
16#include <linux/in.h> 16#include <linux/in.h>
17#include <linux/slab.h>
18#include <linux/string.h> 17#include <linux/string.h>
19#include <linux/delay.h> 18#include <linux/delay.h>
20#include <linux/init.h> 19#include <linux/init.h>
@@ -26,6 +25,7 @@ static char version[] =
26#include <linux/of.h> 25#include <linux/of.h>
27#include <linux/of_device.h> 26#include <linux/of_device.h>
28#include <linux/firmware.h> 27#include <linux/firmware.h>
28#include <linux/gfp.h>
29 29
30#include <net/dst.h> 30#include <net/dst.h>
31#include <net/arp.h> 31#include <net/arp.h>
diff --git a/drivers/net/ne2.c b/drivers/net/ne2.c
index a53bb201d3c..ff3c4c81498 100644
--- a/drivers/net/ne2.c
+++ b/drivers/net/ne2.c
@@ -66,7 +66,6 @@ static const char *version = "ne2.c:v0.91 Nov 16 1998 Wim Dumon <wimpie@kotnet.o
66#include <linux/interrupt.h> 66#include <linux/interrupt.h>
67#include <linux/ioport.h> 67#include <linux/ioport.h>
68#include <linux/in.h> 68#include <linux/in.h>
69#include <linux/slab.h>
70#include <linux/string.h> 69#include <linux/string.h>
71#include <linux/errno.h> 70#include <linux/errno.h>
72#include <linux/init.h> 71#include <linux/init.h>
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index bf4af5248cb..a361dea3557 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -37,6 +37,7 @@
37#include <linux/mm.h> 37#include <linux/mm.h>
38#include <linux/init.h> 38#include <linux/init.h>
39#include <linux/module.h> 39#include <linux/module.h>
40#include <linux/slab.h>
40#include <linux/console.h> 41#include <linux/console.h>
41#include <linux/moduleparam.h> 42#include <linux/moduleparam.h>
42#include <linux/string.h> 43#include <linux/string.h>
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index 144d2e88042..0f703838e21 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -53,8 +53,8 @@
53 53
54#define _NETXEN_NIC_LINUX_MAJOR 4 54#define _NETXEN_NIC_LINUX_MAJOR 4
55#define _NETXEN_NIC_LINUX_MINOR 0 55#define _NETXEN_NIC_LINUX_MINOR 0
56#define _NETXEN_NIC_LINUX_SUBVERSION 72 56#define _NETXEN_NIC_LINUX_SUBVERSION 73
57#define NETXEN_NIC_LINUX_VERSIONID "4.0.72" 57#define NETXEN_NIC_LINUX_VERSIONID "4.0.73"
58 58
59#define NETXEN_VERSION_CODE(a, b, c) (((a) << 24) + ((b) << 16) + (c)) 59#define NETXEN_VERSION_CODE(a, b, c) (((a) << 24) + ((b) << 16) + (c))
60#define _major(v) (((v) >> 24) & 0xff) 60#define _major(v) (((v) >> 24) & 0xff)
diff --git a/drivers/net/netxen/netxen_nic_ctx.c b/drivers/net/netxen/netxen_nic_ctx.c
index 2a8ef5fc966..f26e54716c8 100644
--- a/drivers/net/netxen/netxen_nic_ctx.c
+++ b/drivers/net/netxen/netxen_nic_ctx.c
@@ -669,13 +669,15 @@ int netxen_alloc_hw_resources(struct netxen_adapter *adapter)
669 } 669 }
670 sds_ring->desc_head = (struct status_desc *)addr; 670 sds_ring->desc_head = (struct status_desc *)addr;
671 671
672 sds_ring->crb_sts_consumer = 672 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) {
673 netxen_get_ioaddr(adapter, 673 sds_ring->crb_sts_consumer =
674 recv_crb_registers[port].crb_sts_consumer[ring]); 674 netxen_get_ioaddr(adapter,
675 recv_crb_registers[port].crb_sts_consumer[ring]);
675 676
676 sds_ring->crb_intr_mask = 677 sds_ring->crb_intr_mask =
677 netxen_get_ioaddr(adapter, 678 netxen_get_ioaddr(adapter,
678 recv_crb_registers[port].sw_int_mask[ring]); 679 recv_crb_registers[port].sw_int_mask[ring]);
680 }
679 } 681 }
680 682
681 683
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c
index a945591298a..b1cf46a0c48 100644
--- a/drivers/net/netxen/netxen_nic_hw.c
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -23,6 +23,7 @@
23 * 23 *
24 */ 24 */
25 25
26#include <linux/slab.h>
26#include "netxen_nic.h" 27#include "netxen_nic.h"
27#include "netxen_nic_hw.h" 28#include "netxen_nic_hw.h"
28 29
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index 1c63610ead4..02876f59cbb 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -25,6 +25,7 @@
25 25
26#include <linux/netdevice.h> 26#include <linux/netdevice.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/slab.h>
28#include "netxen_nic.h" 29#include "netxen_nic.h"
29#include "netxen_nic_hw.h" 30#include "netxen_nic_hw.h"
30 31
@@ -761,7 +762,7 @@ nx_get_bios_version(struct netxen_adapter *adapter)
761 if (adapter->fw_type == NX_UNIFIED_ROMIMAGE) { 762 if (adapter->fw_type == NX_UNIFIED_ROMIMAGE) {
762 bios_ver = cpu_to_le32(*((u32 *) (&fw->data[prd_off]) 763 bios_ver = cpu_to_le32(*((u32 *) (&fw->data[prd_off])
763 + NX_UNI_BIOS_VERSION_OFF)); 764 + NX_UNI_BIOS_VERSION_OFF));
764 return (bios_ver << 24) + ((bios_ver >> 8) & 0xff00) + 765 return (bios_ver << 16) + ((bios_ver >> 8) & 0xff00) +
765 (bios_ver >> 24); 766 (bios_ver >> 24);
766 } else 767 } else
767 return cpu_to_le32(*(u32 *)&fw->data[NX_BIOS_VERSION_OFFSET]); 768 return cpu_to_le32(*(u32 *)&fw->data[NX_BIOS_VERSION_OFFSET]);
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index 08780ef1c1f..ce838f7c8b0 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -23,6 +23,7 @@
23 * 23 *
24 */ 24 */
25 25
26#include <linux/slab.h>
26#include <linux/vmalloc.h> 27#include <linux/vmalloc.h>
27#include <linux/interrupt.h> 28#include <linux/interrupt.h>
28#include "netxen_nic_hw.h" 29#include "netxen_nic_hw.h"
@@ -604,16 +605,14 @@ netxen_cleanup_pci_map(struct netxen_adapter *adapter)
604static int 605static int
605netxen_setup_pci_map(struct netxen_adapter *adapter) 606netxen_setup_pci_map(struct netxen_adapter *adapter)
606{ 607{
607 void __iomem *mem_ptr0 = NULL;
608 void __iomem *mem_ptr1 = NULL;
609 void __iomem *mem_ptr2 = NULL;
610 void __iomem *db_ptr = NULL; 608 void __iomem *db_ptr = NULL;
611 609
612 resource_size_t mem_base, db_base; 610 resource_size_t mem_base, db_base;
613 unsigned long mem_len, db_len = 0, pci_len0 = 0; 611 unsigned long mem_len, db_len = 0;
614 612
615 struct pci_dev *pdev = adapter->pdev; 613 struct pci_dev *pdev = adapter->pdev;
616 int pci_func = adapter->ahw.pci_func; 614 int pci_func = adapter->ahw.pci_func;
615 struct netxen_hardware_context *ahw = &adapter->ahw;
617 616
618 int err = 0; 617 int err = 0;
619 618
@@ -630,24 +629,40 @@ netxen_setup_pci_map(struct netxen_adapter *adapter)
630 629
631 /* 128 Meg of memory */ 630 /* 128 Meg of memory */
632 if (mem_len == NETXEN_PCI_128MB_SIZE) { 631 if (mem_len == NETXEN_PCI_128MB_SIZE) {
633 mem_ptr0 = ioremap(mem_base, FIRST_PAGE_GROUP_SIZE); 632
634 mem_ptr1 = ioremap(mem_base + SECOND_PAGE_GROUP_START, 633 ahw->pci_base0 = ioremap(mem_base, FIRST_PAGE_GROUP_SIZE);
634 ahw->pci_base1 = ioremap(mem_base + SECOND_PAGE_GROUP_START,
635 SECOND_PAGE_GROUP_SIZE); 635 SECOND_PAGE_GROUP_SIZE);
636 mem_ptr2 = ioremap(mem_base + THIRD_PAGE_GROUP_START, 636 ahw->pci_base2 = ioremap(mem_base + THIRD_PAGE_GROUP_START,
637 THIRD_PAGE_GROUP_SIZE); 637 THIRD_PAGE_GROUP_SIZE);
638 pci_len0 = FIRST_PAGE_GROUP_SIZE; 638 if (ahw->pci_base0 == NULL || ahw->pci_base1 == NULL ||
639 ahw->pci_base2 == NULL) {
640 dev_err(&pdev->dev, "failed to map PCI bar 0\n");
641 err = -EIO;
642 goto err_out;
643 }
644
645 ahw->pci_len0 = FIRST_PAGE_GROUP_SIZE;
646
639 } else if (mem_len == NETXEN_PCI_32MB_SIZE) { 647 } else if (mem_len == NETXEN_PCI_32MB_SIZE) {
640 mem_ptr1 = ioremap(mem_base, SECOND_PAGE_GROUP_SIZE); 648
641 mem_ptr2 = ioremap(mem_base + THIRD_PAGE_GROUP_START - 649 ahw->pci_base1 = ioremap(mem_base, SECOND_PAGE_GROUP_SIZE);
650 ahw->pci_base2 = ioremap(mem_base + THIRD_PAGE_GROUP_START -
642 SECOND_PAGE_GROUP_START, THIRD_PAGE_GROUP_SIZE); 651 SECOND_PAGE_GROUP_START, THIRD_PAGE_GROUP_SIZE);
652 if (ahw->pci_base1 == NULL || ahw->pci_base2 == NULL) {
653 dev_err(&pdev->dev, "failed to map PCI bar 0\n");
654 err = -EIO;
655 goto err_out;
656 }
657
643 } else if (mem_len == NETXEN_PCI_2MB_SIZE) { 658 } else if (mem_len == NETXEN_PCI_2MB_SIZE) {
644 659
645 mem_ptr0 = pci_ioremap_bar(pdev, 0); 660 ahw->pci_base0 = pci_ioremap_bar(pdev, 0);
646 if (mem_ptr0 == NULL) { 661 if (ahw->pci_base0 == NULL) {
647 dev_err(&pdev->dev, "failed to map PCI bar 0\n"); 662 dev_err(&pdev->dev, "failed to map PCI bar 0\n");
648 return -EIO; 663 return -EIO;
649 } 664 }
650 pci_len0 = mem_len; 665 ahw->pci_len0 = mem_len;
651 } else { 666 } else {
652 return -EIO; 667 return -EIO;
653 } 668 }
@@ -656,11 +671,6 @@ netxen_setup_pci_map(struct netxen_adapter *adapter)
656 671
657 dev_info(&pdev->dev, "%dMB memory map\n", (int)(mem_len>>20)); 672 dev_info(&pdev->dev, "%dMB memory map\n", (int)(mem_len>>20));
658 673
659 adapter->ahw.pci_base0 = mem_ptr0;
660 adapter->ahw.pci_len0 = pci_len0;
661 adapter->ahw.pci_base1 = mem_ptr1;
662 adapter->ahw.pci_base2 = mem_ptr2;
663
664 if (NX_IS_REVISION_P3P(adapter->ahw.revision_id)) { 674 if (NX_IS_REVISION_P3P(adapter->ahw.revision_id)) {
665 adapter->ahw.ocm_win_crb = netxen_get_ioaddr(adapter, 675 adapter->ahw.ocm_win_crb = netxen_get_ioaddr(adapter,
666 NETXEN_PCIX_PS_REG(PCIX_OCM_WINDOW_REG(pci_func))); 676 NETXEN_PCIX_PS_REG(PCIX_OCM_WINDOW_REG(pci_func)));
@@ -1246,8 +1256,8 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1246 int pci_func_id = PCI_FUNC(pdev->devfn); 1256 int pci_func_id = PCI_FUNC(pdev->devfn);
1247 uint8_t revision_id; 1257 uint8_t revision_id;
1248 1258
1249 if (pdev->revision >= NX_P3_A0 && pdev->revision < NX_P3_B1) { 1259 if (pdev->revision >= NX_P3_A0 && pdev->revision <= NX_P3_B1) {
1250 pr_warning("%s: chip revisions between 0x%x-0x%x" 1260 pr_warning("%s: chip revisions between 0x%x-0x%x "
1251 "will not be enabled.\n", 1261 "will not be enabled.\n",
1252 module_name(THIS_MODULE), NX_P3_A0, NX_P3_B1); 1262 module_name(THIS_MODULE), NX_P3_A0, NX_P3_B1);
1253 return -ENODEV; 1263 return -ENODEV;
diff --git a/drivers/net/ni5010.c b/drivers/net/ni5010.c
index c16cbfb4061..3892330f244 100644
--- a/drivers/net/ni5010.c
+++ b/drivers/net/ni5010.c
@@ -51,7 +51,6 @@
51#include <linux/string.h> 51#include <linux/string.h>
52#include <linux/errno.h> 52#include <linux/errno.h>
53#include <linux/ioport.h> 53#include <linux/ioport.h>
54#include <linux/slab.h>
55#include <linux/interrupt.h> 54#include <linux/interrupt.h>
56#include <linux/delay.h> 55#include <linux/delay.h>
57#include <linux/init.h> 56#include <linux/init.h>
diff --git a/drivers/net/ni52.c b/drivers/net/ni52.c
index 05c29c2cef2..f7a8f707361 100644
--- a/drivers/net/ni52.c
+++ b/drivers/net/ni52.c
@@ -109,7 +109,6 @@ static int fifo = 0x8; /* don't change */
109#include <linux/string.h> 109#include <linux/string.h>
110#include <linux/errno.h> 110#include <linux/errno.h>
111#include <linux/ioport.h> 111#include <linux/ioport.h>
112#include <linux/slab.h>
113#include <linux/interrupt.h> 112#include <linux/interrupt.h>
114#include <linux/delay.h> 113#include <linux/delay.h>
115#include <linux/init.h> 114#include <linux/init.h>
diff --git a/drivers/net/niu.c b/drivers/net/niu.c
index 0678f3106cb..d5cd16bfc90 100644
--- a/drivers/net/niu.c
+++ b/drivers/net/niu.c
@@ -25,6 +25,7 @@
25#include <linux/jiffies.h> 25#include <linux/jiffies.h>
26#include <linux/crc32.h> 26#include <linux/crc32.h>
27#include <linux/list.h> 27#include <linux/list.h>
28#include <linux/slab.h>
28 29
29#include <linux/io.h> 30#include <linux/io.h>
30 31
diff --git a/drivers/net/ns83820.c b/drivers/net/ns83820.c
index 8dd509c09bc..e88e97cd1b1 100644
--- a/drivers/net/ns83820.c
+++ b/drivers/net/ns83820.c
@@ -116,6 +116,7 @@
116#include <linux/if_vlan.h> 116#include <linux/if_vlan.h>
117#include <linux/rtnetlink.h> 117#include <linux/rtnetlink.h>
118#include <linux/jiffies.h> 118#include <linux/jiffies.h>
119#include <linux/slab.h>
119 120
120#include <asm/io.h> 121#include <asm/io.h>
121#include <asm/uaccess.h> 122#include <asm/uaccess.h>
diff --git a/drivers/net/octeon/octeon_mgmt.c b/drivers/net/octeon/octeon_mgmt.c
index be368e5cbf7..8aadc8e2ddd 100644
--- a/drivers/net/octeon/octeon_mgmt.c
+++ b/drivers/net/octeon/octeon_mgmt.c
@@ -13,6 +13,7 @@
13#include <linux/netdevice.h> 13#include <linux/netdevice.h>
14#include <linux/etherdevice.h> 14#include <linux/etherdevice.h>
15#include <linux/if_vlan.h> 15#include <linux/if_vlan.h>
16#include <linux/slab.h>
16#include <linux/phy.h> 17#include <linux/phy.h>
17#include <linux/spinlock.h> 18#include <linux/spinlock.h>
18 19
diff --git a/drivers/net/pasemi_mac.c b/drivers/net/pasemi_mac.c
index d44d4a208bb..370c147d08a 100644
--- a/drivers/net/pasemi_mac.c
+++ b/drivers/net/pasemi_mac.c
@@ -20,6 +20,7 @@
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/pci.h> 22#include <linux/pci.h>
23#include <linux/slab.h>
23#include <linux/interrupt.h> 24#include <linux/interrupt.h>
24#include <linux/dmaengine.h> 25#include <linux/dmaengine.h>
25#include <linux/delay.h> 26#include <linux/delay.h>
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index 3d1d3a7b7ed..757f87bb1db 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -781,8 +781,13 @@ static netdev_tx_t el3_start_xmit(struct sk_buff *skb,
781 inw(ioaddr + EL3_STATUS)); 781 inw(ioaddr + EL3_STATUS));
782 782
783 spin_lock_irqsave(&lp->window_lock, flags); 783 spin_lock_irqsave(&lp->window_lock, flags);
784
785 dev->stats.tx_bytes += skb->len;
786
787 /* Put out the doubleword header... */
784 outw(skb->len, ioaddr + TX_FIFO); 788 outw(skb->len, ioaddr + TX_FIFO);
785 outw(0, ioaddr + TX_FIFO); 789 outw(0, ioaddr + TX_FIFO);
790 /* ... and the packet rounded to a doubleword. */
786 outsl(ioaddr + TX_FIFO, skb->data, (skb->len+3)>>2); 791 outsl(ioaddr + TX_FIFO, skb->data, (skb->len+3)>>2);
787 792
788 dev->trans_start = jiffies; 793 dev->trans_start = jiffies;
@@ -1021,8 +1026,6 @@ static void update_stats(struct net_device *dev)
1021 /* BadSSD */ inb(ioaddr + 12); 1026 /* BadSSD */ inb(ioaddr + 12);
1022 up = inb(ioaddr + 13); 1027 up = inb(ioaddr + 13);
1023 1028
1024 dev->stats.tx_bytes += tx + ((up & 0xf0) << 12);
1025
1026 EL3WINDOW(1); 1029 EL3WINDOW(1);
1027} 1030}
1028 1031
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index 09291e60d30..9f3d593f14e 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -28,7 +28,6 @@
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/ptrace.h> 30#include <linux/ptrace.h>
31#include <linux/slab.h>
32#include <linux/string.h> 31#include <linux/string.h>
33#include <linux/timer.h> 32#include <linux/timer.h>
34#include <linux/delay.h> 33#include <linux/delay.h>
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index 776cad2f571..4c0368de181 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -32,7 +32,6 @@
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/ptrace.h> 34#include <linux/ptrace.h>
35#include <linux/slab.h>
36#include <linux/string.h> 35#include <linux/string.h>
37#include <linux/timer.h> 36#include <linux/timer.h>
38#include <linux/delay.h> 37#include <linux/delay.h>
@@ -1549,6 +1548,7 @@ static struct pcmcia_device_id pcnet_ids[] = {
1549 PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x021b, 0x0101), 1548 PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x021b, 0x0101),
1550 PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x08a1, 0xc0ab), 1549 PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x08a1, 0xc0ab),
1551 PCMCIA_PFC_DEVICE_PROD_ID12(0, "AnyCom", "Fast Ethernet + 56K COMBO", 0x578ba6e7, 0xb0ac62c4), 1550 PCMCIA_PFC_DEVICE_PROD_ID12(0, "AnyCom", "Fast Ethernet + 56K COMBO", 0x578ba6e7, 0xb0ac62c4),
1551 PCMCIA_PFC_DEVICE_PROD_ID12(0, "ATKK", "LM33-PCM-T", 0xba9eb7e2, 0x077c174e),
1552 PCMCIA_PFC_DEVICE_PROD_ID12(0, "D-Link", "DME336T", 0x1a424a1c, 0xb23897ff), 1552 PCMCIA_PFC_DEVICE_PROD_ID12(0, "D-Link", "DME336T", 0x1a424a1c, 0xb23897ff),
1553 PCMCIA_PFC_DEVICE_PROD_ID12(0, "Grey Cell", "GCS3000", 0x2a151fac, 0x48b932ae), 1553 PCMCIA_PFC_DEVICE_PROD_ID12(0, "Grey Cell", "GCS3000", 0x2a151fac, 0x48b932ae),
1554 PCMCIA_PFC_DEVICE_PROD_ID12(0, "Linksys", "EtherFast 10&100 + 56K PC Card (PCMLM56)", 0x0733cc81, 0xb3765033), 1554 PCMCIA_PFC_DEVICE_PROD_ID12(0, "Linksys", "EtherFast 10&100 + 56K PC Card (PCMLM56)", 0x0733cc81, 0xb3765033),
@@ -1740,7 +1740,7 @@ static struct pcmcia_device_id pcnet_ids[] = {
1740 PCMCIA_MFC_DEVICE_CIS_PROD_ID12(0, "DAYNA COMMUNICATIONS", "LAN AND MODEM MULTIFUNCTION", 0x8fdf8f89, 0xdd5ed9e8, "cis/DP83903.cis"), 1740 PCMCIA_MFC_DEVICE_CIS_PROD_ID12(0, "DAYNA COMMUNICATIONS", "LAN AND MODEM MULTIFUNCTION", 0x8fdf8f89, 0xdd5ed9e8, "cis/DP83903.cis"),
1741 PCMCIA_MFC_DEVICE_CIS_PROD_ID4(0, "NSC MF LAN/Modem", 0x58fc6056, "cis/DP83903.cis"), 1741 PCMCIA_MFC_DEVICE_CIS_PROD_ID4(0, "NSC MF LAN/Modem", 0x58fc6056, "cis/DP83903.cis"),
1742 PCMCIA_MFC_DEVICE_CIS_MANF_CARD(0, 0x0175, 0x0000, "cis/DP83903.cis"), 1742 PCMCIA_MFC_DEVICE_CIS_MANF_CARD(0, 0x0175, 0x0000, "cis/DP83903.cis"),
1743 PCMCIA_DEVICE_CIS_MANF_CARD(0xc00f, 0x0002, "cis/LA-PCM.cis"), 1743 PCMCIA_DEVICE_CIS_PROD_ID12("Allied Telesis,K.K", "Ethernet LAN Card", 0x2ad62f3c, 0x9fd2f0a2, "cis/LA-PCM.cis"),
1744 PCMCIA_DEVICE_CIS_PROD_ID12("KTI", "PE520 PLUS", 0xad180345, 0x9d58d392, "cis/PE520.cis"), 1744 PCMCIA_DEVICE_CIS_PROD_ID12("KTI", "PE520 PLUS", 0xad180345, 0x9d58d392, "cis/PE520.cis"),
1745 PCMCIA_DEVICE_CIS_PROD_ID12("NDC", "Ethernet", 0x01c43ae1, 0x00b2e941, "cis/NE2K.cis"), 1745 PCMCIA_DEVICE_CIS_PROD_ID12("NDC", "Ethernet", 0x01c43ae1, 0x00b2e941, "cis/NE2K.cis"),
1746 PCMCIA_DEVICE_CIS_PROD_ID12("PMX ", "PE-200", 0x34f3f1c8, 0x10b59f8c, "cis/PE-200.cis"), 1746 PCMCIA_DEVICE_CIS_PROD_ID12("PMX ", "PE-200", 0x34f3f1c8, 0x10b59f8c, "cis/PE-200.cis"),
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
index 5adc662c4bf..ccc553782a0 100644
--- a/drivers/net/pcmcia/smc91c92_cs.c
+++ b/drivers/net/pcmcia/smc91c92_cs.c
@@ -493,13 +493,14 @@ static int pcmcia_get_versmac(struct pcmcia_device *p_dev,
493{ 493{
494 struct net_device *dev = priv; 494 struct net_device *dev = priv;
495 cisparse_t parse; 495 cisparse_t parse;
496 u8 *buf;
496 497
497 if (pcmcia_parse_tuple(tuple, &parse)) 498 if (pcmcia_parse_tuple(tuple, &parse))
498 return -EINVAL; 499 return -EINVAL;
499 500
500 if ((parse.version_1.ns > 3) && 501 buf = parse.version_1.str + parse.version_1.ofs[3];
501 (cvt_ascii_address(dev, 502
502 (parse.version_1.str + parse.version_1.ofs[3])))) 503 if ((parse.version_1.ns > 3) && (cvt_ascii_address(dev, buf) == 0))
503 return 0; 504 return 0;
504 505
505 return -EINVAL; 506 return -EINVAL;
@@ -528,7 +529,7 @@ static int mhz_setup(struct pcmcia_device *link)
528 len = pcmcia_get_tuple(link, 0x81, &buf); 529 len = pcmcia_get_tuple(link, 0x81, &buf);
529 if (buf && len >= 13) { 530 if (buf && len >= 13) {
530 buf[12] = '\0'; 531 buf[12] = '\0';
531 if (cvt_ascii_address(dev, buf)) 532 if (cvt_ascii_address(dev, buf) == 0)
532 rc = 0; 533 rc = 0;
533 } 534 }
534 kfree(buf); 535 kfree(buf);
@@ -910,7 +911,7 @@ static int smc91c92_config(struct pcmcia_device *link)
910 911
911 if (i != 0) { 912 if (i != 0) {
912 printk(KERN_NOTICE "smc91c92_cs: Unable to find hardware address.\n"); 913 printk(KERN_NOTICE "smc91c92_cs: Unable to find hardware address.\n");
913 goto config_undo; 914 goto config_failed;
914 } 915 }
915 916
916 smc->duplex = 0; 917 smc->duplex = 0;
@@ -998,6 +999,7 @@ config_undo:
998 unregister_netdev(dev); 999 unregister_netdev(dev);
999config_failed: 1000config_failed:
1000 smc91c92_release(link); 1001 smc91c92_release(link);
1002 free_netdev(dev);
1001 return -ENODEV; 1003 return -ENODEV;
1002} /* smc91c92_config */ 1004} /* smc91c92_config */
1003 1005
@@ -1606,9 +1608,12 @@ static void set_rx_mode(struct net_device *dev)
1606{ 1608{
1607 unsigned int ioaddr = dev->base_addr; 1609 unsigned int ioaddr = dev->base_addr;
1608 struct smc_private *smc = netdev_priv(dev); 1610 struct smc_private *smc = netdev_priv(dev);
1609 u_int multicast_table[ 2 ] = { 0, }; 1611 unsigned char multicast_table[8];
1610 unsigned long flags; 1612 unsigned long flags;
1611 u_short rx_cfg_setting; 1613 u_short rx_cfg_setting;
1614 int i;
1615
1616 memset(multicast_table, 0, sizeof(multicast_table));
1612 1617
1613 if (dev->flags & IFF_PROMISC) { 1618 if (dev->flags & IFF_PROMISC) {
1614 rx_cfg_setting = RxStripCRC | RxEnable | RxPromisc | RxAllMulti; 1619 rx_cfg_setting = RxStripCRC | RxEnable | RxPromisc | RxAllMulti;
@@ -1620,10 +1625,6 @@ static void set_rx_mode(struct net_device *dev)
1620 1625
1621 netdev_for_each_mc_addr(mc_addr, dev) { 1626 netdev_for_each_mc_addr(mc_addr, dev) {
1622 u_int position = ether_crc(6, mc_addr->dmi_addr); 1627 u_int position = ether_crc(6, mc_addr->dmi_addr);
1623#ifndef final_version /* Verify multicast address. */
1624 if ((mc_addr->dmi_addr[0] & 1) == 0)
1625 continue;
1626#endif
1627 multicast_table[position >> 29] |= 1 << ((position >> 26) & 7); 1628 multicast_table[position >> 29] |= 1 << ((position >> 26) & 7);
1628 } 1629 }
1629 } 1630 }
@@ -1633,8 +1634,8 @@ static void set_rx_mode(struct net_device *dev)
1633 /* Load MC table and Rx setting into the chip without interrupts. */ 1634 /* Load MC table and Rx setting into the chip without interrupts. */
1634 spin_lock_irqsave(&smc->lock, flags); 1635 spin_lock_irqsave(&smc->lock, flags);
1635 SMC_SELECT_BANK(3); 1636 SMC_SELECT_BANK(3);
1636 outl(multicast_table[0], ioaddr + MULTICAST0); 1637 for (i = 0; i < 8; i++)
1637 outl(multicast_table[1], ioaddr + MULTICAST4); 1638 outb(multicast_table[i], ioaddr + MULTICAST0 + i);
1638 SMC_SELECT_BANK(0); 1639 SMC_SELECT_BANK(0);
1639 outw(rx_cfg_setting, ioaddr + RCR); 1640 outw(rx_cfg_setting, ioaddr + RCR);
1640 SMC_SELECT_BANK(2); 1641 SMC_SELECT_BANK(2);
@@ -1803,23 +1804,30 @@ static void media_check(u_long arg)
1803 SMC_SELECT_BANK(1); 1804 SMC_SELECT_BANK(1);
1804 media |= (inw(ioaddr + CONFIG) & CFG_AUI_SELECT) ? 2 : 1; 1805 media |= (inw(ioaddr + CONFIG) & CFG_AUI_SELECT) ? 2 : 1;
1805 1806
1807 SMC_SELECT_BANK(saved_bank);
1808 spin_unlock_irqrestore(&smc->lock, flags);
1809
1806 /* Check for pending interrupt with watchdog flag set: with 1810 /* Check for pending interrupt with watchdog flag set: with
1807 this, we can limp along even if the interrupt is blocked */ 1811 this, we can limp along even if the interrupt is blocked */
1808 if (smc->watchdog++ && ((i>>8) & i)) { 1812 if (smc->watchdog++ && ((i>>8) & i)) {
1809 if (!smc->fast_poll) 1813 if (!smc->fast_poll)
1810 printk(KERN_INFO "%s: interrupt(s) dropped!\n", dev->name); 1814 printk(KERN_INFO "%s: interrupt(s) dropped!\n", dev->name);
1815 local_irq_save(flags);
1811 smc_interrupt(dev->irq, dev); 1816 smc_interrupt(dev->irq, dev);
1817 local_irq_restore(flags);
1812 smc->fast_poll = HZ; 1818 smc->fast_poll = HZ;
1813 } 1819 }
1814 if (smc->fast_poll) { 1820 if (smc->fast_poll) {
1815 smc->fast_poll--; 1821 smc->fast_poll--;
1816 smc->media.expires = jiffies + HZ/100; 1822 smc->media.expires = jiffies + HZ/100;
1817 add_timer(&smc->media); 1823 add_timer(&smc->media);
1818 SMC_SELECT_BANK(saved_bank);
1819 spin_unlock_irqrestore(&smc->lock, flags);
1820 return; 1824 return;
1821 } 1825 }
1822 1826
1827 spin_lock_irqsave(&smc->lock, flags);
1828
1829 saved_bank = inw(ioaddr + BANK_SELECT);
1830
1823 if (smc->cfg & CFG_MII_SELECT) { 1831 if (smc->cfg & CFG_MII_SELECT) {
1824 if (smc->mii_if.phy_id < 0) 1832 if (smc->mii_if.phy_id < 0)
1825 goto reschedule; 1833 goto reschedule;
@@ -1977,15 +1985,16 @@ static int smc_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
1977 unsigned int ioaddr = dev->base_addr; 1985 unsigned int ioaddr = dev->base_addr;
1978 u16 saved_bank = inw(ioaddr + BANK_SELECT); 1986 u16 saved_bank = inw(ioaddr + BANK_SELECT);
1979 int ret; 1987 int ret;
1988 unsigned long flags;
1980 1989
1981 spin_lock_irq(&smc->lock); 1990 spin_lock_irqsave(&smc->lock, flags);
1982 SMC_SELECT_BANK(3); 1991 SMC_SELECT_BANK(3);
1983 if (smc->cfg & CFG_MII_SELECT) 1992 if (smc->cfg & CFG_MII_SELECT)
1984 ret = mii_ethtool_gset(&smc->mii_if, ecmd); 1993 ret = mii_ethtool_gset(&smc->mii_if, ecmd);
1985 else 1994 else
1986 ret = smc_netdev_get_ecmd(dev, ecmd); 1995 ret = smc_netdev_get_ecmd(dev, ecmd);
1987 SMC_SELECT_BANK(saved_bank); 1996 SMC_SELECT_BANK(saved_bank);
1988 spin_unlock_irq(&smc->lock); 1997 spin_unlock_irqrestore(&smc->lock, flags);
1989 return ret; 1998 return ret;
1990} 1999}
1991 2000
@@ -1995,15 +2004,16 @@ static int smc_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
1995 unsigned int ioaddr = dev->base_addr; 2004 unsigned int ioaddr = dev->base_addr;
1996 u16 saved_bank = inw(ioaddr + BANK_SELECT); 2005 u16 saved_bank = inw(ioaddr + BANK_SELECT);
1997 int ret; 2006 int ret;
2007 unsigned long flags;
1998 2008
1999 spin_lock_irq(&smc->lock); 2009 spin_lock_irqsave(&smc->lock, flags);
2000 SMC_SELECT_BANK(3); 2010 SMC_SELECT_BANK(3);
2001 if (smc->cfg & CFG_MII_SELECT) 2011 if (smc->cfg & CFG_MII_SELECT)
2002 ret = mii_ethtool_sset(&smc->mii_if, ecmd); 2012 ret = mii_ethtool_sset(&smc->mii_if, ecmd);
2003 else 2013 else
2004 ret = smc_netdev_set_ecmd(dev, ecmd); 2014 ret = smc_netdev_set_ecmd(dev, ecmd);
2005 SMC_SELECT_BANK(saved_bank); 2015 SMC_SELECT_BANK(saved_bank);
2006 spin_unlock_irq(&smc->lock); 2016 spin_unlock_irqrestore(&smc->lock, flags);
2007 return ret; 2017 return ret;
2008} 2018}
2009 2019
@@ -2013,12 +2023,13 @@ static u32 smc_get_link(struct net_device *dev)
2013 unsigned int ioaddr = dev->base_addr; 2023 unsigned int ioaddr = dev->base_addr;
2014 u16 saved_bank = inw(ioaddr + BANK_SELECT); 2024 u16 saved_bank = inw(ioaddr + BANK_SELECT);
2015 u32 ret; 2025 u32 ret;
2026 unsigned long flags;
2016 2027
2017 spin_lock_irq(&smc->lock); 2028 spin_lock_irqsave(&smc->lock, flags);
2018 SMC_SELECT_BANK(3); 2029 SMC_SELECT_BANK(3);
2019 ret = smc_link_ok(dev); 2030 ret = smc_link_ok(dev);
2020 SMC_SELECT_BANK(saved_bank); 2031 SMC_SELECT_BANK(saved_bank);
2021 spin_unlock_irq(&smc->lock); 2032 spin_unlock_irqrestore(&smc->lock, flags);
2022 return ret; 2033 return ret;
2023} 2034}
2024 2035
@@ -2055,16 +2066,17 @@ static int smc_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
2055 int rc = 0; 2066 int rc = 0;
2056 u16 saved_bank; 2067 u16 saved_bank;
2057 unsigned int ioaddr = dev->base_addr; 2068 unsigned int ioaddr = dev->base_addr;
2069 unsigned long flags;
2058 2070
2059 if (!netif_running(dev)) 2071 if (!netif_running(dev))
2060 return -EINVAL; 2072 return -EINVAL;
2061 2073
2062 spin_lock_irq(&smc->lock); 2074 spin_lock_irqsave(&smc->lock, flags);
2063 saved_bank = inw(ioaddr + BANK_SELECT); 2075 saved_bank = inw(ioaddr + BANK_SELECT);
2064 SMC_SELECT_BANK(3); 2076 SMC_SELECT_BANK(3);
2065 rc = generic_mii_ioctl(&smc->mii_if, mii, cmd, NULL); 2077 rc = generic_mii_ioctl(&smc->mii_if, mii, cmd, NULL);
2066 SMC_SELECT_BANK(saved_bank); 2078 SMC_SELECT_BANK(saved_bank);
2067 spin_unlock_irq(&smc->lock); 2079 spin_unlock_irqrestore(&smc->lock, flags);
2068 return rc; 2080 return rc;
2069} 2081}
2070 2082
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index fc5938ba3d7..a527e37728c 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -88,6 +88,11 @@ config LSI_ET1011C_PHY
88 ---help--- 88 ---help---
89 Supports the LSI ET1011C PHY. 89 Supports the LSI ET1011C PHY.
90 90
91config MICREL_PHY
92 tristate "Driver for Micrel PHYs"
93 ---help---
94 Supports the KSZ9021, VSC8201, KS8001 PHYs.
95
91config FIXED_PHY 96config FIXED_PHY
92 bool "Driver for MDIO Bus/PHY emulation with fixed speed/link PHYs" 97 bool "Driver for MDIO Bus/PHY emulation with fixed speed/link PHYs"
93 depends on PHYLIB=y 98 depends on PHYLIB=y
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index 1342585af38..13bebab65d0 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -20,4 +20,5 @@ obj-$(CONFIG_MDIO_BITBANG) += mdio-bitbang.o
20obj-$(CONFIG_MDIO_GPIO) += mdio-gpio.o 20obj-$(CONFIG_MDIO_GPIO) += mdio-gpio.o
21obj-$(CONFIG_NATIONAL_PHY) += national.o 21obj-$(CONFIG_NATIONAL_PHY) += national.o
22obj-$(CONFIG_STE10XP) += ste10Xp.o 22obj-$(CONFIG_STE10XP) += ste10Xp.o
23obj-$(CONFIG_MICREL_PHY) += micrel.o
23obj-$(CONFIG_MDIO_OCTEON) += mdio-octeon.o 24obj-$(CONFIG_MDIO_OCTEON) += mdio-octeon.o
diff --git a/drivers/net/phy/cicada.c b/drivers/net/phy/cicada.c
index a1bd599c8a5..92282b31d94 100644
--- a/drivers/net/phy/cicada.c
+++ b/drivers/net/phy/cicada.c
@@ -17,7 +17,6 @@
17#include <linux/string.h> 17#include <linux/string.h>
18#include <linux/errno.h> 18#include <linux/errno.h>
19#include <linux/unistd.h> 19#include <linux/unistd.h>
20#include <linux/slab.h>
21#include <linux/interrupt.h> 20#include <linux/interrupt.h>
22#include <linux/init.h> 21#include <linux/init.h>
23#include <linux/delay.h> 22#include <linux/delay.h>
diff --git a/drivers/net/phy/davicom.c b/drivers/net/phy/davicom.c
index d926168bc78..c722e95853f 100644
--- a/drivers/net/phy/davicom.c
+++ b/drivers/net/phy/davicom.c
@@ -17,7 +17,6 @@
17#include <linux/string.h> 17#include <linux/string.h>
18#include <linux/errno.h> 18#include <linux/errno.h>
19#include <linux/unistd.h> 19#include <linux/unistd.h>
20#include <linux/slab.h>
21#include <linux/interrupt.h> 20#include <linux/interrupt.h>
22#include <linux/init.h> 21#include <linux/init.h>
23#include <linux/delay.h> 22#include <linux/delay.h>
diff --git a/drivers/net/phy/et1011c.c b/drivers/net/phy/et1011c.c
index b031fa21f1a..7712ebeba9b 100644
--- a/drivers/net/phy/et1011c.c
+++ b/drivers/net/phy/et1011c.c
@@ -17,7 +17,6 @@
17#include <linux/string.h> 17#include <linux/string.h>
18#include <linux/errno.h> 18#include <linux/errno.h>
19#include <linux/unistd.h> 19#include <linux/unistd.h>
20#include <linux/slab.h>
21#include <linux/interrupt.h> 20#include <linux/interrupt.h>
22#include <linux/init.h> 21#include <linux/init.h>
23#include <linux/delay.h> 22#include <linux/delay.h>
diff --git a/drivers/net/phy/fixed.c b/drivers/net/phy/fixed.c
index e7070515d2e..1fa4d73c3cc 100644
--- a/drivers/net/phy/fixed.c
+++ b/drivers/net/phy/fixed.c
@@ -20,6 +20,7 @@
20#include <linux/phy.h> 20#include <linux/phy.h>
21#include <linux/phy_fixed.h> 21#include <linux/phy_fixed.h>
22#include <linux/err.h> 22#include <linux/err.h>
23#include <linux/slab.h>
23 24
24#define MII_REGS_NUM 29 25#define MII_REGS_NUM 29
25 26
diff --git a/drivers/net/phy/icplus.c b/drivers/net/phy/icplus.c
index af3f1f2a9f8..904208b95d4 100644
--- a/drivers/net/phy/icplus.c
+++ b/drivers/net/phy/icplus.c
@@ -13,7 +13,6 @@
13#include <linux/string.h> 13#include <linux/string.h>
14#include <linux/errno.h> 14#include <linux/errno.h>
15#include <linux/unistd.h> 15#include <linux/unistd.h>
16#include <linux/slab.h>
17#include <linux/interrupt.h> 16#include <linux/interrupt.h>
18#include <linux/init.h> 17#include <linux/init.h>
19#include <linux/delay.h> 18#include <linux/delay.h>
diff --git a/drivers/net/phy/lxt.c b/drivers/net/phy/lxt.c
index 4cf3324ba16..057ecaacde6 100644
--- a/drivers/net/phy/lxt.c
+++ b/drivers/net/phy/lxt.c
@@ -17,7 +17,6 @@
17#include <linux/string.h> 17#include <linux/string.h>
18#include <linux/errno.h> 18#include <linux/errno.h>
19#include <linux/unistd.h> 19#include <linux/unistd.h>
20#include <linux/slab.h>
21#include <linux/interrupt.h> 20#include <linux/interrupt.h>
22#include <linux/init.h> 21#include <linux/init.h>
23#include <linux/delay.h> 22#include <linux/delay.h>
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index 65ed385c2ce..64c7fbe0a8e 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -17,7 +17,6 @@
17#include <linux/string.h> 17#include <linux/string.h>
18#include <linux/errno.h> 18#include <linux/errno.h>
19#include <linux/unistd.h> 19#include <linux/unistd.h>
20#include <linux/slab.h>
21#include <linux/interrupt.h> 20#include <linux/interrupt.h>
22#include <linux/init.h> 21#include <linux/init.h>
23#include <linux/delay.h> 22#include <linux/delay.h>
diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
index 2576055b350..19e70d7e27a 100644
--- a/drivers/net/phy/mdio-bitbang.c
+++ b/drivers/net/phy/mdio-bitbang.c
@@ -19,7 +19,6 @@
19 19
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/mdio-bitbang.h> 21#include <linux/mdio-bitbang.h>
22#include <linux/slab.h>
23#include <linux/types.h> 22#include <linux/types.h>
24#include <linux/delay.h> 23#include <linux/delay.h>
25 24
diff --git a/drivers/net/phy/mdio-octeon.c b/drivers/net/phy/mdio-octeon.c
index 61a4461cbda..f443d43edd8 100644
--- a/drivers/net/phy/mdio-octeon.c
+++ b/drivers/net/phy/mdio-octeon.c
@@ -6,6 +6,7 @@
6 * Copyright (C) 2009 Cavium Networks 6 * Copyright (C) 2009 Cavium Networks
7 */ 7 */
8 8
9#include <linux/gfp.h>
9#include <linux/init.h> 10#include <linux/init.h>
10#include <linux/module.h> 11#include <linux/module.h>
11#include <linux/platform_device.h> 12#include <linux/platform_device.h>
@@ -87,6 +88,7 @@ static int octeon_mdiobus_write(struct mii_bus *bus, int phy_id,
87static int __init octeon_mdiobus_probe(struct platform_device *pdev) 88static int __init octeon_mdiobus_probe(struct platform_device *pdev)
88{ 89{
89 struct octeon_mdiobus *bus; 90 struct octeon_mdiobus *bus;
91 union cvmx_smix_en smi_en;
90 int i; 92 int i;
91 int err = -ENOENT; 93 int err = -ENOENT;
92 94
@@ -102,6 +104,10 @@ static int __init octeon_mdiobus_probe(struct platform_device *pdev)
102 if (!bus->mii_bus) 104 if (!bus->mii_bus)
103 goto err; 105 goto err;
104 106
107 smi_en.u64 = 0;
108 smi_en.s.en = 1;
109 cvmx_write_csr(CVMX_SMIX_EN(bus->unit), smi_en.u64);
110
105 /* 111 /*
106 * Standard Octeon evaluation boards don't support phy 112 * Standard Octeon evaluation boards don't support phy
107 * interrupts, we need to poll. 113 * interrupts, we need to poll.
@@ -132,17 +138,22 @@ err_register:
132 138
133err: 139err:
134 devm_kfree(&pdev->dev, bus); 140 devm_kfree(&pdev->dev, bus);
141 smi_en.u64 = 0;
142 cvmx_write_csr(CVMX_SMIX_EN(bus->unit), smi_en.u64);
135 return err; 143 return err;
136} 144}
137 145
138static int __exit octeon_mdiobus_remove(struct platform_device *pdev) 146static int __exit octeon_mdiobus_remove(struct platform_device *pdev)
139{ 147{
140 struct octeon_mdiobus *bus; 148 struct octeon_mdiobus *bus;
149 union cvmx_smix_en smi_en;
141 150
142 bus = dev_get_drvdata(&pdev->dev); 151 bus = dev_get_drvdata(&pdev->dev);
143 152
144 mdiobus_unregister(bus->mii_bus); 153 mdiobus_unregister(bus->mii_bus);
145 mdiobus_free(bus->mii_bus); 154 mdiobus_free(bus->mii_bus);
155 smi_en.u64 = 0;
156 cvmx_write_csr(CVMX_SMIX_EN(bus->unit), smi_en.u64);
146 return 0; 157 return 0;
147} 158}
148 159
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
new file mode 100644
index 00000000000..0cd80e4d71d
--- /dev/null
+++ b/drivers/net/phy/micrel.c
@@ -0,0 +1,104 @@
1/*
2 * drivers/net/phy/micrel.c
3 *
4 * Driver for Micrel PHYs
5 *
6 * Author: David J. Choi
7 *
8 * Copyright (c) 2010 Micrel, Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 * Support : ksz9021 , vsc8201, ks8001
16 */
17
18#include <linux/kernel.h>
19#include <linux/module.h>
20#include <linux/phy.h>
21
22#define PHY_ID_KSZ9021 0x00221611
23#define PHY_ID_VSC8201 0x000FC413
24#define PHY_ID_KS8001 0x0022161A
25
26
27static int kszphy_config_init(struct phy_device *phydev)
28{
29 return 0;
30}
31
32
33static struct phy_driver ks8001_driver = {
34 .phy_id = PHY_ID_KS8001,
35 .phy_id_mask = 0x00fffff0,
36 .features = PHY_BASIC_FEATURES,
37 .flags = PHY_POLL,
38 .config_init = kszphy_config_init,
39 .config_aneg = genphy_config_aneg,
40 .read_status = genphy_read_status,
41 .driver = { .owner = THIS_MODULE,},
42};
43
44static struct phy_driver vsc8201_driver = {
45 .phy_id = PHY_ID_VSC8201,
46 .name = "Micrel VSC8201",
47 .phy_id_mask = 0x00fffff0,
48 .features = PHY_BASIC_FEATURES,
49 .flags = PHY_POLL,
50 .config_init = kszphy_config_init,
51 .config_aneg = genphy_config_aneg,
52 .read_status = genphy_read_status,
53 .driver = { .owner = THIS_MODULE,},
54};
55
56static struct phy_driver ksz9021_driver = {
57 .phy_id = PHY_ID_KSZ9021,
58 .phy_id_mask = 0x000fff10,
59 .name = "Micrel KSZ9021 Gigabit PHY",
60 .features = PHY_GBIT_FEATURES | SUPPORTED_Pause,
61 .flags = PHY_POLL,
62 .config_init = kszphy_config_init,
63 .config_aneg = genphy_config_aneg,
64 .read_status = genphy_read_status,
65 .driver = { .owner = THIS_MODULE, },
66};
67
68static int __init ksphy_init(void)
69{
70 int ret;
71
72 ret = phy_driver_register(&ks8001_driver);
73 if (ret)
74 goto err1;
75 ret = phy_driver_register(&vsc8201_driver);
76 if (ret)
77 goto err2;
78
79 ret = phy_driver_register(&ksz9021_driver);
80 if (ret)
81 goto err3;
82 return 0;
83
84err3:
85 phy_driver_unregister(&vsc8201_driver);
86err2:
87 phy_driver_unregister(&ks8001_driver);
88err1:
89 return ret;
90}
91
92static void __exit ksphy_exit(void)
93{
94 phy_driver_unregister(&ks8001_driver);
95 phy_driver_unregister(&vsc8201_driver);
96 phy_driver_unregister(&ksz9021_driver);
97}
98
99module_init(ksphy_init);
100module_exit(ksphy_exit);
101
102MODULE_DESCRIPTION("Micrel PHY driver");
103MODULE_AUTHOR("David J. Choi");
104MODULE_LICENSE("GPL");
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 0295097d6c4..64be4664cca 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -19,7 +19,6 @@
19#include <linux/string.h> 19#include <linux/string.h>
20#include <linux/errno.h> 20#include <linux/errno.h>
21#include <linux/unistd.h> 21#include <linux/unistd.h>
22#include <linux/slab.h>
23#include <linux/interrupt.h> 22#include <linux/interrupt.h>
24#include <linux/init.h> 23#include <linux/init.h>
25#include <linux/delay.h> 24#include <linux/delay.h>
diff --git a/drivers/net/phy/qsemi.c b/drivers/net/phy/qsemi.c
index 23062d06723..f6e190f73c3 100644
--- a/drivers/net/phy/qsemi.c
+++ b/drivers/net/phy/qsemi.c
@@ -17,7 +17,6 @@
17#include <linux/string.h> 17#include <linux/string.h>
18#include <linux/errno.h> 18#include <linux/errno.h>
19#include <linux/unistd.h> 19#include <linux/unistd.h>
20#include <linux/slab.h>
21#include <linux/interrupt.h> 20#include <linux/interrupt.h>
22#include <linux/init.h> 21#include <linux/init.h>
23#include <linux/delay.h> 22#include <linux/delay.h>
diff --git a/drivers/net/plip.c b/drivers/net/plip.c
index 3327e9fc7b5..9a2103a69e1 100644
--- a/drivers/net/plip.c
+++ b/drivers/net/plip.c
@@ -94,6 +94,7 @@ static const char version[] = "NET3 PLIP version 2.4-parport gniibe@mri.co.jp\n"
94#include <linux/fcntl.h> 94#include <linux/fcntl.h>
95#include <linux/interrupt.h> 95#include <linux/interrupt.h>
96#include <linux/string.h> 96#include <linux/string.h>
97#include <linux/slab.h>
97#include <linux/if_ether.h> 98#include <linux/if_ether.h>
98#include <linux/in.h> 99#include <linux/in.h>
99#include <linux/errno.h> 100#include <linux/errno.h>
diff --git a/drivers/net/ppp_async.c b/drivers/net/ppp_async.c
index 6a375ea4947..6c2e8fa0ca3 100644
--- a/drivers/net/ppp_async.c
+++ b/drivers/net/ppp_async.c
@@ -31,6 +31,7 @@
31#include <linux/spinlock.h> 31#include <linux/spinlock.h>
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/jiffies.h> 33#include <linux/jiffies.h>
34#include <linux/slab.h>
34#include <asm/uaccess.h> 35#include <asm/uaccess.h>
35#include <asm/string.h> 36#include <asm/string.h>
36 37
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index 6d61602208c..8518a2e58e5 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -46,6 +46,7 @@
46#include <linux/stddef.h> 46#include <linux/stddef.h>
47#include <linux/device.h> 47#include <linux/device.h>
48#include <linux/mutex.h> 48#include <linux/mutex.h>
49#include <linux/slab.h>
49#include <net/slhc_vj.h> 50#include <net/slhc_vj.h>
50#include <asm/atomic.h> 51#include <asm/atomic.h>
51 52
@@ -404,6 +405,7 @@ static ssize_t ppp_read(struct file *file, char __user *buf,
404 DECLARE_WAITQUEUE(wait, current); 405 DECLARE_WAITQUEUE(wait, current);
405 ssize_t ret; 406 ssize_t ret;
406 struct sk_buff *skb = NULL; 407 struct sk_buff *skb = NULL;
408 struct iovec iov;
407 409
408 ret = count; 410 ret = count;
409 411
@@ -447,7 +449,9 @@ static ssize_t ppp_read(struct file *file, char __user *buf,
447 if (skb->len > count) 449 if (skb->len > count)
448 goto outf; 450 goto outf;
449 ret = -EFAULT; 451 ret = -EFAULT;
450 if (copy_to_user(buf, skb->data, skb->len)) 452 iov.iov_base = buf;
453 iov.iov_len = count;
454 if (skb_copy_datagram_iovec(skb, 0, &iov, skb->len))
451 goto outf; 455 goto outf;
452 ret = skb->len; 456 ret = skb->len;
453 457
@@ -1566,13 +1570,22 @@ ppp_input(struct ppp_channel *chan, struct sk_buff *skb)
1566 struct channel *pch = chan->ppp; 1570 struct channel *pch = chan->ppp;
1567 int proto; 1571 int proto;
1568 1572
1569 if (!pch || skb->len == 0) { 1573 if (!pch) {
1570 kfree_skb(skb); 1574 kfree_skb(skb);
1571 return; 1575 return;
1572 } 1576 }
1573 1577
1574 proto = PPP_PROTO(skb);
1575 read_lock_bh(&pch->upl); 1578 read_lock_bh(&pch->upl);
1579 if (!pskb_may_pull(skb, 2)) {
1580 kfree_skb(skb);
1581 if (pch->ppp) {
1582 ++pch->ppp->dev->stats.rx_length_errors;
1583 ppp_receive_error(pch->ppp);
1584 }
1585 goto done;
1586 }
1587
1588 proto = PPP_PROTO(skb);
1576 if (!pch->ppp || proto >= 0xc000 || proto == PPP_CCPFRAG) { 1589 if (!pch->ppp || proto >= 0xc000 || proto == PPP_CCPFRAG) {
1577 /* put it on the channel queue */ 1590 /* put it on the channel queue */
1578 skb_queue_tail(&pch->file.rq, skb); 1591 skb_queue_tail(&pch->file.rq, skb);
@@ -1584,6 +1597,8 @@ ppp_input(struct ppp_channel *chan, struct sk_buff *skb)
1584 } else { 1597 } else {
1585 ppp_do_recv(pch->ppp, skb, pch); 1598 ppp_do_recv(pch->ppp, skb, pch);
1586 } 1599 }
1600
1601done:
1587 read_unlock_bh(&pch->upl); 1602 read_unlock_bh(&pch->upl);
1588} 1603}
1589 1604
@@ -1616,7 +1631,8 @@ ppp_input_error(struct ppp_channel *chan, int code)
1616static void 1631static void
1617ppp_receive_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch) 1632ppp_receive_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
1618{ 1633{
1619 if (pskb_may_pull(skb, 2)) { 1634 /* note: a 0-length skb is used as an error indication */
1635 if (skb->len > 0) {
1620#ifdef CONFIG_PPP_MULTILINK 1636#ifdef CONFIG_PPP_MULTILINK
1621 /* XXX do channel-level decompression here */ 1637 /* XXX do channel-level decompression here */
1622 if (PPP_PROTO(skb) == PPP_MP) 1638 if (PPP_PROTO(skb) == PPP_MP)
@@ -1624,15 +1640,10 @@ ppp_receive_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
1624 else 1640 else
1625#endif /* CONFIG_PPP_MULTILINK */ 1641#endif /* CONFIG_PPP_MULTILINK */
1626 ppp_receive_nonmp_frame(ppp, skb); 1642 ppp_receive_nonmp_frame(ppp, skb);
1627 return; 1643 } else {
1644 kfree_skb(skb);
1645 ppp_receive_error(ppp);
1628 } 1646 }
1629
1630 if (skb->len > 0)
1631 /* note: a 0-length skb is used as an error indication */
1632 ++ppp->dev->stats.rx_length_errors;
1633
1634 kfree_skb(skb);
1635 ppp_receive_error(ppp);
1636} 1647}
1637 1648
1638static void 1649static void
diff --git a/drivers/net/ppp_synctty.c b/drivers/net/ppp_synctty.c
index 3a13cecae3e..52938da1e54 100644
--- a/drivers/net/ppp_synctty.c
+++ b/drivers/net/ppp_synctty.c
@@ -44,6 +44,7 @@
44#include <linux/spinlock.h> 44#include <linux/spinlock.h>
45#include <linux/completion.h> 45#include <linux/completion.h>
46#include <linux/init.h> 46#include <linux/init.h>
47#include <linux/slab.h>
47#include <asm/uaccess.h> 48#include <asm/uaccess.h>
48 49
49#define PPP_VERSION "2.4.2" 50#define PPP_VERSION "2.4.2"
diff --git a/drivers/net/pppox.c b/drivers/net/pppox.c
index ac806b27c65..d4191ef9cad 100644
--- a/drivers/net/pppox.c
+++ b/drivers/net/pppox.c
@@ -22,7 +22,6 @@
22#include <linux/string.h> 22#include <linux/string.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/slab.h>
26#include <linux/errno.h> 25#include <linux/errno.h>
27#include <linux/netdevice.h> 26#include <linux/netdevice.h>
28#include <linux/net.h> 27#include <linux/net.h>
diff --git a/drivers/net/ps3_gelic_net.c b/drivers/net/ps3_gelic_net.c
index a849f6f23a1..5bf229bb34c 100644
--- a/drivers/net/ps3_gelic_net.c
+++ b/drivers/net/ps3_gelic_net.c
@@ -30,6 +30,7 @@
30 30
31#include <linux/kernel.h> 31#include <linux/kernel.h>
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/slab.h>
33 34
34#include <linux/etherdevice.h> 35#include <linux/etherdevice.h>
35#include <linux/ethtool.h> 36#include <linux/ethtool.h>
diff --git a/drivers/net/ps3_gelic_wireless.c b/drivers/net/ps3_gelic_wireless.c
index 2663b2fdc0b..f0be507e532 100644
--- a/drivers/net/ps3_gelic_wireless.c
+++ b/drivers/net/ps3_gelic_wireless.c
@@ -21,6 +21,7 @@
21 21
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/slab.h>
24 25
25#include <linux/etherdevice.h> 26#include <linux/etherdevice.h>
26#include <linux/ethtool.h> 27#include <linux/ethtool.h>
diff --git a/drivers/net/qlcnic/qlcnic_hw.c b/drivers/net/qlcnic/qlcnic_hw.c
index da00e162b6d..e73ba455aa2 100644
--- a/drivers/net/qlcnic/qlcnic_hw.c
+++ b/drivers/net/qlcnic/qlcnic_hw.c
@@ -24,6 +24,7 @@
24 24
25#include "qlcnic.h" 25#include "qlcnic.h"
26 26
27#include <linux/slab.h>
27#include <net/ip.h> 28#include <net/ip.h>
28 29
29#define MASK(n) ((1ULL<<(n))-1) 30#define MASK(n) ((1ULL<<(n))-1)
@@ -430,6 +431,9 @@ void qlcnic_set_multi(struct net_device *netdev)
430 u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; 431 u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
431 u32 mode = VPORT_MISS_MODE_DROP; 432 u32 mode = VPORT_MISS_MODE_DROP;
432 433
434 if (adapter->is_up != QLCNIC_ADAPTER_UP_MAGIC)
435 return;
436
433 qlcnic_nic_add_mac(adapter, adapter->mac_addr); 437 qlcnic_nic_add_mac(adapter, adapter->mac_addr);
434 qlcnic_nic_add_mac(adapter, bcast_addr); 438 qlcnic_nic_add_mac(adapter, bcast_addr);
435 439
diff --git a/drivers/net/qlcnic/qlcnic_init.c b/drivers/net/qlcnic/qlcnic_init.c
index 7c34e4e29b3..9d2c124048f 100644
--- a/drivers/net/qlcnic/qlcnic_init.c
+++ b/drivers/net/qlcnic/qlcnic_init.c
@@ -24,6 +24,7 @@
24 24
25#include <linux/netdevice.h> 25#include <linux/netdevice.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/slab.h>
27#include "qlcnic.h" 28#include "qlcnic.h"
28 29
29struct crb_addr_pair { 30struct crb_addr_pair {
diff --git a/drivers/net/qlcnic/qlcnic_main.c b/drivers/net/qlcnic/qlcnic_main.c
index fc721564e69..234dab1f998 100644
--- a/drivers/net/qlcnic/qlcnic_main.c
+++ b/drivers/net/qlcnic/qlcnic_main.c
@@ -22,6 +22,7 @@
22 * 22 *
23 */ 23 */
24 24
25#include <linux/slab.h>
25#include <linux/vmalloc.h> 26#include <linux/vmalloc.h>
26#include <linux/interrupt.h> 27#include <linux/interrupt.h>
27 28
diff --git a/drivers/net/qlge/qlge_dbg.c b/drivers/net/qlge/qlge_dbg.c
index ff8550d2ca8..36266462893 100644
--- a/drivers/net/qlge/qlge_dbg.c
+++ b/drivers/net/qlge/qlge_dbg.c
@@ -1,3 +1,5 @@
1#include <linux/slab.h>
2
1#include "qlge.h" 3#include "qlge.h"
2 4
3/* Read a NIC register from the alternate function. */ 5/* Read a NIC register from the alternate function. */
diff --git a/drivers/net/qlge/qlge_ethtool.c b/drivers/net/qlge/qlge_ethtool.c
index 7dbff87480d..7e09ff4a575 100644
--- a/drivers/net/qlge/qlge_ethtool.c
+++ b/drivers/net/qlge/qlge_ethtool.c
@@ -7,7 +7,6 @@
7#include <linux/dma-mapping.h> 7#include <linux/dma-mapping.h>
8#include <linux/pagemap.h> 8#include <linux/pagemap.h>
9#include <linux/sched.h> 9#include <linux/sched.h>
10#include <linux/slab.h>
11#include <linux/dmapool.h> 10#include <linux/dmapool.h>
12#include <linux/mempool.h> 11#include <linux/mempool.h>
13#include <linux/spinlock.h> 12#include <linux/spinlock.h>
diff --git a/drivers/net/r6040.c b/drivers/net/r6040.c
index 15d5373dc8f..0298d8c1dcb 100644
--- a/drivers/net/r6040.c
+++ b/drivers/net/r6040.c
@@ -29,7 +29,6 @@
29#include <linux/timer.h> 29#include <linux/timer.h>
30#include <linux/errno.h> 30#include <linux/errno.h>
31#include <linux/ioport.h> 31#include <linux/ioport.h>
32#include <linux/slab.h>
33#include <linux/interrupt.h> 32#include <linux/interrupt.h>
34#include <linux/pci.h> 33#include <linux/pci.h>
35#include <linux/netdevice.h> 34#include <linux/netdevice.h>
@@ -135,7 +134,7 @@
135#define RX_DESC_SIZE (RX_DCNT * sizeof(struct r6040_descriptor)) 134#define RX_DESC_SIZE (RX_DCNT * sizeof(struct r6040_descriptor))
136#define TX_DESC_SIZE (TX_DCNT * sizeof(struct r6040_descriptor)) 135#define TX_DESC_SIZE (TX_DCNT * sizeof(struct r6040_descriptor))
137#define MBCR_DEFAULT 0x012A /* MAC Bus Control Register */ 136#define MBCR_DEFAULT 0x012A /* MAC Bus Control Register */
138#define MCAST_MAX 4 /* Max number multicast addresses to filter */ 137#define MCAST_MAX 3 /* Max number multicast addresses to filter */
139 138
140/* Descriptor status */ 139/* Descriptor status */
141#define DSC_OWNER_MAC 0x8000 /* MAC is the owner of this descriptor */ 140#define DSC_OWNER_MAC 0x8000 /* MAC is the owner of this descriptor */
@@ -983,9 +982,6 @@ static void r6040_multicast_list(struct net_device *dev)
983 crc >>= 26; 982 crc >>= 26;
984 hash_table[crc >> 4] |= 1 << (15 - (crc & 0xf)); 983 hash_table[crc >> 4] |= 1 << (15 - (crc & 0xf));
985 } 984 }
986 /* Write the index of the hash table */
987 for (i = 0; i < 4; i++)
988 iowrite16(hash_table[i] << 14, ioaddr + MCR1);
989 /* Fill the MAC hash tables with their values */ 985 /* Fill the MAC hash tables with their values */
990 iowrite16(hash_table[0], ioaddr + MAR0); 986 iowrite16(hash_table[0], ioaddr + MAR0);
991 iowrite16(hash_table[1], ioaddr + MAR1); 987 iowrite16(hash_table[1], ioaddr + MAR1);
@@ -1001,9 +997,9 @@ static void r6040_multicast_list(struct net_device *dev)
1001 iowrite16(adrp[1], ioaddr + MID_1M + 8 * i); 997 iowrite16(adrp[1], ioaddr + MID_1M + 8 * i);
1002 iowrite16(adrp[2], ioaddr + MID_1H + 8 * i); 998 iowrite16(adrp[2], ioaddr + MID_1H + 8 * i);
1003 } else { 999 } else {
1004 iowrite16(0xffff, ioaddr + MID_0L + 8 * i); 1000 iowrite16(0xffff, ioaddr + MID_1L + 8 * i);
1005 iowrite16(0xffff, ioaddr + MID_0M + 8 * i); 1001 iowrite16(0xffff, ioaddr + MID_1M + 8 * i);
1006 iowrite16(0xffff, ioaddr + MID_0H + 8 * i); 1002 iowrite16(0xffff, ioaddr + MID_1H + 8 * i);
1007 } 1003 }
1008 i++; 1004 i++;
1009 } 1005 }
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 9d3ebf3e975..dd8106ff35a 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -186,8 +186,13 @@ static DEFINE_PCI_DEVICE_TABLE(rtl8169_pci_tbl) = {
186 186
187MODULE_DEVICE_TABLE(pci, rtl8169_pci_tbl); 187MODULE_DEVICE_TABLE(pci, rtl8169_pci_tbl);
188 188
189static int rx_copybreak = 200; 189/*
190static int use_dac = -1; 190 * we set our copybreak very high so that we don't have
191 * to allocate 16k frames all the time (see note in
192 * rtl8169_open()
193 */
194static int rx_copybreak = 16383;
195static int use_dac;
191static struct { 196static struct {
192 u32 msg_enable; 197 u32 msg_enable;
193} debug = { -1 }; 198} debug = { -1 };
@@ -511,8 +516,7 @@ MODULE_DESCRIPTION("RealTek RTL-8169 Gigabit Ethernet driver");
511module_param(rx_copybreak, int, 0); 516module_param(rx_copybreak, int, 0);
512MODULE_PARM_DESC(rx_copybreak, "Copy breakpoint for copy-only-tiny-frames"); 517MODULE_PARM_DESC(rx_copybreak, "Copy breakpoint for copy-only-tiny-frames");
513module_param(use_dac, int, 0); 518module_param(use_dac, int, 0);
514MODULE_PARM_DESC(use_dac, "Enable PCI DAC. -1 defaults on for PCI Express only." 519MODULE_PARM_DESC(use_dac, "Enable PCI DAC. Unsafe on 32 bit PCI slot.");
515" Unsafe on 32 bit PCI slot.");
516module_param_named(debug, debug.msg_enable, int, 0); 520module_param_named(debug, debug.msg_enable, int, 0);
517MODULE_PARM_DESC(debug, "Debug verbosity level (0=none, ..., 16=all)"); 521MODULE_PARM_DESC(debug, "Debug verbosity level (0=none, ..., 16=all)");
518MODULE_LICENSE("GPL"); 522MODULE_LICENSE("GPL");
@@ -1038,14 +1042,14 @@ static void rtl8169_vlan_rx_register(struct net_device *dev,
1038} 1042}
1039 1043
1040static int rtl8169_rx_vlan_skb(struct rtl8169_private *tp, struct RxDesc *desc, 1044static int rtl8169_rx_vlan_skb(struct rtl8169_private *tp, struct RxDesc *desc,
1041 struct sk_buff *skb) 1045 struct sk_buff *skb, int polling)
1042{ 1046{
1043 u32 opts2 = le32_to_cpu(desc->opts2); 1047 u32 opts2 = le32_to_cpu(desc->opts2);
1044 struct vlan_group *vlgrp = tp->vlgrp; 1048 struct vlan_group *vlgrp = tp->vlgrp;
1045 int ret; 1049 int ret;
1046 1050
1047 if (vlgrp && (opts2 & RxVlanTag)) { 1051 if (vlgrp && (opts2 & RxVlanTag)) {
1048 vlan_hwaccel_receive_skb(skb, vlgrp, swab16(opts2 & 0xffff)); 1052 __vlan_hwaccel_rx(skb, vlgrp, swab16(opts2 & 0xffff), polling);
1049 ret = 0; 1053 ret = 0;
1050 } else 1054 } else
1051 ret = -1; 1055 ret = -1;
@@ -1062,7 +1066,7 @@ static inline u32 rtl8169_tx_vlan_tag(struct rtl8169_private *tp,
1062} 1066}
1063 1067
1064static int rtl8169_rx_vlan_skb(struct rtl8169_private *tp, struct RxDesc *desc, 1068static int rtl8169_rx_vlan_skb(struct rtl8169_private *tp, struct RxDesc *desc,
1065 struct sk_buff *skb) 1069 struct sk_buff *skb, int polling)
1066{ 1070{
1067 return -1; 1071 return -1;
1068} 1072}
@@ -2755,6 +2759,7 @@ static void rtl8169_release_board(struct pci_dev *pdev, struct net_device *dev,
2755{ 2759{
2756 iounmap(ioaddr); 2760 iounmap(ioaddr);
2757 pci_release_regions(pdev); 2761 pci_release_regions(pdev);
2762 pci_clear_mwi(pdev);
2758 pci_disable_device(pdev); 2763 pci_disable_device(pdev);
2759 free_netdev(dev); 2764 free_netdev(dev);
2760} 2765}
@@ -2821,8 +2826,13 @@ static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr)
2821 spin_lock_irq(&tp->lock); 2826 spin_lock_irq(&tp->lock);
2822 2827
2823 RTL_W8(Cfg9346, Cfg9346_Unlock); 2828 RTL_W8(Cfg9346, Cfg9346_Unlock);
2824 RTL_W32(MAC0, low); 2829
2825 RTL_W32(MAC4, high); 2830 RTL_W32(MAC4, high);
2831 RTL_R32(MAC4);
2832
2833 RTL_W32(MAC0, low);
2834 RTL_R32(MAC0);
2835
2826 RTL_W8(Cfg9346, Cfg9346_Lock); 2836 RTL_W8(Cfg9346, Cfg9346_Lock);
2827 2837
2828 spin_unlock_irq(&tp->lock); 2838 spin_unlock_irq(&tp->lock);
@@ -2974,7 +2984,6 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2974 void __iomem *ioaddr; 2984 void __iomem *ioaddr;
2975 unsigned int i; 2985 unsigned int i;
2976 int rc; 2986 int rc;
2977 int this_use_dac = use_dac;
2978 2987
2979 if (netif_msg_drv(&debug)) { 2988 if (netif_msg_drv(&debug)) {
2980 printk(KERN_INFO "%s Gigabit Ethernet driver %s loaded\n", 2989 printk(KERN_INFO "%s Gigabit Ethernet driver %s loaded\n",
@@ -3011,9 +3020,8 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3011 goto err_out_free_dev_1; 3020 goto err_out_free_dev_1;
3012 } 3021 }
3013 3022
3014 rc = pci_set_mwi(pdev); 3023 if (pci_set_mwi(pdev) < 0)
3015 if (rc < 0) 3024 netif_info(tp, probe, dev, "Mem-Wr-Inval unavailable\n");
3016 goto err_out_disable_2;
3017 3025
3018 /* make sure PCI base addr 1 is MMIO */ 3026 /* make sure PCI base addr 1 is MMIO */
3019 if (!(pci_resource_flags(pdev, region) & IORESOURCE_MEM)) { 3027 if (!(pci_resource_flags(pdev, region) & IORESOURCE_MEM)) {
@@ -3021,7 +3029,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3021 "region #%d not an MMIO resource, aborting\n", 3029 "region #%d not an MMIO resource, aborting\n",
3022 region); 3030 region);
3023 rc = -ENODEV; 3031 rc = -ENODEV;
3024 goto err_out_mwi_3; 3032 goto err_out_mwi_2;
3025 } 3033 }
3026 3034
3027 /* check for weird/broken PCI region reporting */ 3035 /* check for weird/broken PCI region reporting */
@@ -3029,35 +3037,26 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3029 netif_err(tp, probe, dev, 3037 netif_err(tp, probe, dev,
3030 "Invalid PCI region size(s), aborting\n"); 3038 "Invalid PCI region size(s), aborting\n");
3031 rc = -ENODEV; 3039 rc = -ENODEV;
3032 goto err_out_mwi_3; 3040 goto err_out_mwi_2;
3033 } 3041 }
3034 3042
3035 rc = pci_request_regions(pdev, MODULENAME); 3043 rc = pci_request_regions(pdev, MODULENAME);
3036 if (rc < 0) { 3044 if (rc < 0) {
3037 netif_err(tp, probe, dev, "could not request regions\n"); 3045 netif_err(tp, probe, dev, "could not request regions\n");
3038 goto err_out_mwi_3; 3046 goto err_out_mwi_2;
3039 } 3047 }
3040 3048
3041 tp->cp_cmd = PCIMulRW | RxChkSum; 3049 tp->cp_cmd = PCIMulRW | RxChkSum;
3042 3050
3043 tp->pcie_cap = pci_find_capability(pdev, PCI_CAP_ID_EXP);
3044 if (!tp->pcie_cap)
3045 netif_info(tp, probe, dev, "no PCI Express capability\n");
3046
3047 if (this_use_dac < 0)
3048 this_use_dac = tp->pcie_cap != 0;
3049
3050 if ((sizeof(dma_addr_t) > 4) && 3051 if ((sizeof(dma_addr_t) > 4) &&
3051 this_use_dac && 3052 !pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) && use_dac) {
3052 !pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
3053 netif_info(tp, probe, dev, "using 64-bit DMA\n");
3054 tp->cp_cmd |= PCIDAC; 3053 tp->cp_cmd |= PCIDAC;
3055 dev->features |= NETIF_F_HIGHDMA; 3054 dev->features |= NETIF_F_HIGHDMA;
3056 } else { 3055 } else {
3057 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); 3056 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
3058 if (rc < 0) { 3057 if (rc < 0) {
3059 netif_err(tp, probe, dev, "DMA configuration failed\n"); 3058 netif_err(tp, probe, dev, "DMA configuration failed\n");
3060 goto err_out_free_res_4; 3059 goto err_out_free_res_3;
3061 } 3060 }
3062 } 3061 }
3063 3062
@@ -3066,9 +3065,13 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3066 if (!ioaddr) { 3065 if (!ioaddr) {
3067 netif_err(tp, probe, dev, "cannot remap MMIO, aborting\n"); 3066 netif_err(tp, probe, dev, "cannot remap MMIO, aborting\n");
3068 rc = -EIO; 3067 rc = -EIO;
3069 goto err_out_free_res_4; 3068 goto err_out_free_res_3;
3070 } 3069 }
3071 3070
3071 tp->pcie_cap = pci_find_capability(pdev, PCI_CAP_ID_EXP);
3072 if (!tp->pcie_cap)
3073 netif_info(tp, probe, dev, "no PCI Express capability\n");
3074
3072 RTL_W16(IntrMask, 0x0000); 3075 RTL_W16(IntrMask, 0x0000);
3073 3076
3074 /* Soft reset the chip. */ 3077 /* Soft reset the chip. */
@@ -3104,7 +3107,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3104 if (i == ARRAY_SIZE(rtl_chip_info)) { 3107 if (i == ARRAY_SIZE(rtl_chip_info)) {
3105 dev_err(&pdev->dev, 3108 dev_err(&pdev->dev,
3106 "driver bug, MAC version not found in rtl_chip_info\n"); 3109 "driver bug, MAC version not found in rtl_chip_info\n");
3107 goto err_out_msi_5; 3110 goto err_out_msi_4;
3108 } 3111 }
3109 tp->chipset = i; 3112 tp->chipset = i;
3110 3113
@@ -3169,7 +3172,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3169 3172
3170 rc = register_netdev(dev); 3173 rc = register_netdev(dev);
3171 if (rc < 0) 3174 if (rc < 0)
3172 goto err_out_msi_5; 3175 goto err_out_msi_4;
3173 3176
3174 pci_set_drvdata(pdev, dev); 3177 pci_set_drvdata(pdev, dev);
3175 3178
@@ -3192,14 +3195,13 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3192out: 3195out:
3193 return rc; 3196 return rc;
3194 3197
3195err_out_msi_5: 3198err_out_msi_4:
3196 rtl_disable_msi(pdev, tp); 3199 rtl_disable_msi(pdev, tp);
3197 iounmap(ioaddr); 3200 iounmap(ioaddr);
3198err_out_free_res_4: 3201err_out_free_res_3:
3199 pci_release_regions(pdev); 3202 pci_release_regions(pdev);
3200err_out_mwi_3: 3203err_out_mwi_2:
3201 pci_clear_mwi(pdev); 3204 pci_clear_mwi(pdev);
3202err_out_disable_2:
3203 pci_disable_device(pdev); 3205 pci_disable_device(pdev);
3204err_out_free_dev_1: 3206err_out_free_dev_1:
3205 free_netdev(dev); 3207 free_netdev(dev);
@@ -3224,9 +3226,13 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev)
3224} 3226}
3225 3227
3226static void rtl8169_set_rxbufsize(struct rtl8169_private *tp, 3228static void rtl8169_set_rxbufsize(struct rtl8169_private *tp,
3227 struct net_device *dev) 3229 unsigned int mtu)
3228{ 3230{
3229 unsigned int max_frame = dev->mtu + VLAN_ETH_HLEN + ETH_FCS_LEN; 3231 unsigned int max_frame = mtu + VLAN_ETH_HLEN + ETH_FCS_LEN;
3232
3233 if (max_frame != 16383)
3234 printk(KERN_WARNING PFX "WARNING! Changing of MTU on this "
3235 "NIC may lead to frame reception errors!\n");
3230 3236
3231 tp->rx_buf_sz = (max_frame > RX_BUF_SIZE) ? max_frame : RX_BUF_SIZE; 3237 tp->rx_buf_sz = (max_frame > RX_BUF_SIZE) ? max_frame : RX_BUF_SIZE;
3232} 3238}
@@ -3238,7 +3244,17 @@ static int rtl8169_open(struct net_device *dev)
3238 int retval = -ENOMEM; 3244 int retval = -ENOMEM;
3239 3245
3240 3246
3241 rtl8169_set_rxbufsize(tp, dev); 3247 /*
3248 * Note that we use a magic value here, its wierd I know
3249 * its done because, some subset of rtl8169 hardware suffers from
3250 * a problem in which frames received that are longer than
3251 * the size set in RxMaxSize register return garbage sizes
3252 * when received. To avoid this we need to turn off filtering,
3253 * which is done by setting a value of 16383 in the RxMaxSize register
3254 * and allocating 16k frames to handle the largest possible rx value
3255 * thats what the magic math below does.
3256 */
3257 rtl8169_set_rxbufsize(tp, 16383 - VLAN_ETH_HLEN - ETH_FCS_LEN);
3242 3258
3243 /* 3259 /*
3244 * Rx and Tx desscriptors needs 256 bytes alignment. 3260 * Rx and Tx desscriptors needs 256 bytes alignment.
@@ -3891,7 +3907,7 @@ static int rtl8169_change_mtu(struct net_device *dev, int new_mtu)
3891 3907
3892 rtl8169_down(dev); 3908 rtl8169_down(dev);
3893 3909
3894 rtl8169_set_rxbufsize(tp, dev); 3910 rtl8169_set_rxbufsize(tp, dev->mtu);
3895 3911
3896 ret = rtl8169_init_ring(dev); 3912 ret = rtl8169_init_ring(dev);
3897 if (ret < 0) 3913 if (ret < 0)
@@ -4429,12 +4445,20 @@ out:
4429 return done; 4445 return done;
4430} 4446}
4431 4447
4448/*
4449 * Warning : rtl8169_rx_interrupt() might be called :
4450 * 1) from NAPI (softirq) context
4451 * (polling = 1 : we should call netif_receive_skb())
4452 * 2) from process context (rtl8169_reset_task())
4453 * (polling = 0 : we must call netif_rx() instead)
4454 */
4432static int rtl8169_rx_interrupt(struct net_device *dev, 4455static int rtl8169_rx_interrupt(struct net_device *dev,
4433 struct rtl8169_private *tp, 4456 struct rtl8169_private *tp,
4434 void __iomem *ioaddr, u32 budget) 4457 void __iomem *ioaddr, u32 budget)
4435{ 4458{
4436 unsigned int cur_rx, rx_left; 4459 unsigned int cur_rx, rx_left;
4437 unsigned int delta, count; 4460 unsigned int delta, count;
4461 int polling = (budget != ~(u32)0) ? 1 : 0;
4438 4462
4439 cur_rx = tp->cur_rx; 4463 cur_rx = tp->cur_rx;
4440 rx_left = NUM_RX_DESC + tp->dirty_rx - cur_rx; 4464 rx_left = NUM_RX_DESC + tp->dirty_rx - cur_rx;
@@ -4496,8 +4520,12 @@ static int rtl8169_rx_interrupt(struct net_device *dev,
4496 skb_put(skb, pkt_size); 4520 skb_put(skb, pkt_size);
4497 skb->protocol = eth_type_trans(skb, dev); 4521 skb->protocol = eth_type_trans(skb, dev);
4498 4522
4499 if (rtl8169_rx_vlan_skb(tp, desc, skb) < 0) 4523 if (rtl8169_rx_vlan_skb(tp, desc, skb, polling) < 0) {
4500 netif_receive_skb(skb); 4524 if (likely(polling))
4525 netif_receive_skb(skb);
4526 else
4527 netif_rx(skb);
4528 }
4501 4529
4502 dev->stats.rx_bytes += pkt_size; 4530 dev->stats.rx_bytes += pkt_size;
4503 dev->stats.rx_packets++; 4531 dev->stats.rx_packets++;
@@ -4754,8 +4782,8 @@ static void rtl_set_rx_mode(struct net_device *dev)
4754 mc_filter[1] = swab32(data); 4782 mc_filter[1] = swab32(data);
4755 } 4783 }
4756 4784
4757 RTL_W32(MAR0 + 0, mc_filter[0]);
4758 RTL_W32(MAR0 + 4, mc_filter[1]); 4785 RTL_W32(MAR0 + 4, mc_filter[1]);
4786 RTL_W32(MAR0 + 0, mc_filter[0]);
4759 4787
4760 RTL_W32(RxConfig, tmp); 4788 RTL_W32(RxConfig, tmp);
4761 4789
diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c
index ede937ee50c..07eb884ff98 100644
--- a/drivers/net/rionet.c
+++ b/drivers/net/rionet.c
@@ -16,6 +16,7 @@
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/rio.h> 17#include <linux/rio.h>
18#include <linux/rio_drv.h> 18#include <linux/rio_drv.h>
19#include <linux/slab.h>
19#include <linux/rio_ids.h> 20#include <linux/rio_ids.h>
20 21
21#include <linux/netdevice.h> 22#include <linux/netdevice.h>
diff --git a/drivers/net/rrunner.c b/drivers/net/rrunner.c
index 266baf53496..f2e335f0d1b 100644
--- a/drivers/net/rrunner.c
+++ b/drivers/net/rrunner.c
@@ -40,6 +40,7 @@
40#include <linux/init.h> 40#include <linux/init.h>
41#include <linux/delay.h> 41#include <linux/delay.h>
42#include <linux/mm.h> 42#include <linux/mm.h>
43#include <linux/slab.h>
43#include <net/sock.h> 44#include <net/sock.h>
44 45
45#include <asm/system.h> 46#include <asm/system.h>
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index 2eb7f8a0d92..92ae8d3de39 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -79,6 +79,7 @@
79#include <linux/tcp.h> 79#include <linux/tcp.h>
80#include <linux/uaccess.h> 80#include <linux/uaccess.h>
81#include <linux/io.h> 81#include <linux/io.h>
82#include <linux/slab.h>
82#include <net/tcp.h> 83#include <net/tcp.h>
83 84
84#include <asm/system.h> 85#include <asm/system.h>
diff --git a/drivers/net/sb1000.c b/drivers/net/sb1000.c
index 9f83a119737..abc8eefdd4b 100644
--- a/drivers/net/sb1000.c
+++ b/drivers/net/sb1000.c
@@ -42,7 +42,6 @@ static char version[] = "sb1000.c:v1.1.2 6/01/98 (fventuri@mediaone.net)\n";
42#include <linux/errno.h> 42#include <linux/errno.h>
43#include <linux/if_cablemodem.h> /* for SIOGCM/SIOSCM stuff */ 43#include <linux/if_cablemodem.h> /* for SIOGCM/SIOSCM stuff */
44#include <linux/in.h> 44#include <linux/in.h>
45#include <linux/slab.h>
46#include <linux/ioport.h> 45#include <linux/ioport.h>
47#include <linux/netdevice.h> 46#include <linux/netdevice.h>
48#include <linux/if_arp.h> 47#include <linux/if_arp.h>
@@ -52,6 +51,7 @@ static char version[] = "sb1000.c:v1.1.2 6/01/98 (fventuri@mediaone.net)\n";
52#include <linux/pnp.h> 51#include <linux/pnp.h>
53#include <linux/init.h> 52#include <linux/init.h>
54#include <linux/bitops.h> 53#include <linux/bitops.h>
54#include <linux/gfp.h>
55 55
56#include <asm/io.h> 56#include <asm/io.h>
57#include <asm/processor.h> 57#include <asm/processor.h>
diff --git a/drivers/net/sb1250-mac.c b/drivers/net/sb1250-mac.c
index 9944e5d662c..04efc0c1bda 100644
--- a/drivers/net/sb1250-mac.c
+++ b/drivers/net/sb1250-mac.c
@@ -2353,17 +2353,36 @@ static int sbmac_init(struct platform_device *pldev, long long base)
2353 2353
2354 sc->mii_bus = mdiobus_alloc(); 2354 sc->mii_bus = mdiobus_alloc();
2355 if (sc->mii_bus == NULL) { 2355 if (sc->mii_bus == NULL) {
2356 sbmac_uninitctx(sc); 2356 err = -ENOMEM;
2357 return -ENOMEM; 2357 goto uninit_ctx;
2358 } 2358 }
2359 2359
2360 sc->mii_bus->name = sbmac_mdio_string;
2361 snprintf(sc->mii_bus->id, MII_BUS_ID_SIZE, "%x", idx);
2362 sc->mii_bus->priv = sc;
2363 sc->mii_bus->read = sbmac_mii_read;
2364 sc->mii_bus->write = sbmac_mii_write;
2365 sc->mii_bus->irq = sc->phy_irq;
2366 for (i = 0; i < PHY_MAX_ADDR; ++i)
2367 sc->mii_bus->irq[i] = SBMAC_PHY_INT;
2368
2369 sc->mii_bus->parent = &pldev->dev;
2370 /*
2371 * Probe PHY address
2372 */
2373 err = mdiobus_register(sc->mii_bus);
2374 if (err) {
2375 printk(KERN_ERR "%s: unable to register MDIO bus\n",
2376 dev->name);
2377 goto free_mdio;
2378 }
2379 dev_set_drvdata(&pldev->dev, sc->mii_bus);
2380
2360 err = register_netdev(dev); 2381 err = register_netdev(dev);
2361 if (err) { 2382 if (err) {
2362 printk(KERN_ERR "%s.%d: unable to register netdev\n", 2383 printk(KERN_ERR "%s.%d: unable to register netdev\n",
2363 sbmac_string, idx); 2384 sbmac_string, idx);
2364 mdiobus_free(sc->mii_bus); 2385 goto unreg_mdio;
2365 sbmac_uninitctx(sc);
2366 return err;
2367 } 2386 }
2368 2387
2369 pr_info("%s.%d: registered as %s\n", sbmac_string, idx, dev->name); 2388 pr_info("%s.%d: registered as %s\n", sbmac_string, idx, dev->name);
@@ -2379,19 +2398,15 @@ static int sbmac_init(struct platform_device *pldev, long long base)
2379 pr_info("%s: SiByte Ethernet at 0x%08Lx, address: %pM\n", 2398 pr_info("%s: SiByte Ethernet at 0x%08Lx, address: %pM\n",
2380 dev->name, base, eaddr); 2399 dev->name, base, eaddr);
2381 2400
2382 sc->mii_bus->name = sbmac_mdio_string;
2383 snprintf(sc->mii_bus->id, MII_BUS_ID_SIZE, "%x", idx);
2384 sc->mii_bus->priv = sc;
2385 sc->mii_bus->read = sbmac_mii_read;
2386 sc->mii_bus->write = sbmac_mii_write;
2387 sc->mii_bus->irq = sc->phy_irq;
2388 for (i = 0; i < PHY_MAX_ADDR; ++i)
2389 sc->mii_bus->irq[i] = SBMAC_PHY_INT;
2390
2391 sc->mii_bus->parent = &pldev->dev;
2392 dev_set_drvdata(&pldev->dev, sc->mii_bus);
2393
2394 return 0; 2401 return 0;
2402unreg_mdio:
2403 mdiobus_unregister(sc->mii_bus);
2404 dev_set_drvdata(&pldev->dev, NULL);
2405free_mdio:
2406 mdiobus_free(sc->mii_bus);
2407uninit_ctx:
2408 sbmac_uninitctx(sc);
2409 return err;
2395} 2410}
2396 2411
2397 2412
@@ -2417,16 +2432,6 @@ static int sbmac_open(struct net_device *dev)
2417 goto out_err; 2432 goto out_err;
2418 } 2433 }
2419 2434
2420 /*
2421 * Probe PHY address
2422 */
2423 err = mdiobus_register(sc->mii_bus);
2424 if (err) {
2425 printk(KERN_ERR "%s: unable to register MDIO bus\n",
2426 dev->name);
2427 goto out_unirq;
2428 }
2429
2430 sc->sbm_speed = sbmac_speed_none; 2435 sc->sbm_speed = sbmac_speed_none;
2431 sc->sbm_duplex = sbmac_duplex_none; 2436 sc->sbm_duplex = sbmac_duplex_none;
2432 sc->sbm_fc = sbmac_fc_none; 2437 sc->sbm_fc = sbmac_fc_none;
@@ -2457,11 +2462,7 @@ static int sbmac_open(struct net_device *dev)
2457 return 0; 2462 return 0;
2458 2463
2459out_unregister: 2464out_unregister:
2460 mdiobus_unregister(sc->mii_bus);
2461
2462out_unirq:
2463 free_irq(dev->irq, dev); 2465 free_irq(dev->irq, dev);
2464
2465out_err: 2466out_err:
2466 return err; 2467 return err;
2467} 2468}
@@ -2650,9 +2651,6 @@ static int sbmac_close(struct net_device *dev)
2650 2651
2651 phy_disconnect(sc->phy_dev); 2652 phy_disconnect(sc->phy_dev);
2652 sc->phy_dev = NULL; 2653 sc->phy_dev = NULL;
2653
2654 mdiobus_unregister(sc->mii_bus);
2655
2656 free_irq(dev->irq, dev); 2654 free_irq(dev->irq, dev);
2657 2655
2658 sbdma_emptyring(&(sc->sbm_txdma)); 2656 sbdma_emptyring(&(sc->sbm_txdma));
@@ -2760,6 +2758,7 @@ static int __exit sbmac_remove(struct platform_device *pldev)
2760 2758
2761 unregister_netdev(dev); 2759 unregister_netdev(dev);
2762 sbmac_uninitctx(sc); 2760 sbmac_uninitctx(sc);
2761 mdiobus_unregister(sc->mii_bus);
2763 mdiobus_free(sc->mii_bus); 2762 mdiobus_free(sc->mii_bus);
2764 iounmap(sc->sbm_base); 2763 iounmap(sc->sbm_base);
2765 free_netdev(dev); 2764 free_netdev(dev);
diff --git a/drivers/net/seeq8005.c b/drivers/net/seeq8005.c
index fe806bd9b95..374832cca11 100644
--- a/drivers/net/seeq8005.c
+++ b/drivers/net/seeq8005.c
@@ -37,7 +37,6 @@ static const char version[] =
37#include <linux/interrupt.h> 37#include <linux/interrupt.h>
38#include <linux/ioport.h> 38#include <linux/ioport.h>
39#include <linux/in.h> 39#include <linux/in.h>
40#include <linux/slab.h>
41#include <linux/string.h> 40#include <linux/string.h>
42#include <linux/init.h> 41#include <linux/init.h>
43#include <linux/delay.h> 42#include <linux/delay.h>
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
index 88f2fb193ab..649a264d6a8 100644
--- a/drivers/net/sfc/efx.c
+++ b/drivers/net/sfc/efx.c
@@ -20,6 +20,7 @@
20#include <linux/crc32.h> 20#include <linux/crc32.h>
21#include <linux/ethtool.h> 21#include <linux/ethtool.h>
22#include <linux/topology.h> 22#include <linux/topology.h>
23#include <linux/gfp.h>
23#include "net_driver.h" 24#include "net_driver.h"
24#include "efx.h" 25#include "efx.h"
25#include "mdio_10g.h" 26#include "mdio_10g.h"
@@ -1860,6 +1861,7 @@ out:
1860 } 1861 }
1861 1862
1862 if (disabled) { 1863 if (disabled) {
1864 dev_close(efx->net_dev);
1863 EFX_ERR(efx, "has been disabled\n"); 1865 EFX_ERR(efx, "has been disabled\n");
1864 efx->state = STATE_DISABLED; 1866 efx->state = STATE_DISABLED;
1865 } else { 1867 } else {
@@ -1883,8 +1885,7 @@ static void efx_reset_work(struct work_struct *data)
1883 } 1885 }
1884 1886
1885 rtnl_lock(); 1887 rtnl_lock();
1886 if (efx_reset(efx, efx->reset_pending)) 1888 (void)efx_reset(efx, efx->reset_pending);
1887 dev_close(efx->net_dev);
1888 rtnl_unlock(); 1889 rtnl_unlock();
1889} 1890}
1890 1891
diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c
index 1b8d83657aa..08278e7302b 100644
--- a/drivers/net/sfc/falcon.c
+++ b/drivers/net/sfc/falcon.c
@@ -15,6 +15,7 @@
15#include <linux/seq_file.h> 15#include <linux/seq_file.h>
16#include <linux/i2c.h> 16#include <linux/i2c.h>
17#include <linux/mii.h> 17#include <linux/mii.h>
18#include <linux/slab.h>
18#include "net_driver.h" 19#include "net_driver.h"
19#include "bitfield.h" 20#include "bitfield.h"
20#include "efx.h" 21#include "efx.h"
@@ -1319,7 +1320,9 @@ static int falcon_probe_nvconfig(struct efx_nic *efx)
1319 1320
1320 EFX_LOG(efx, "PHY is %d phy_id %d\n", efx->phy_type, efx->mdio.prtad); 1321 EFX_LOG(efx, "PHY is %d phy_id %d\n", efx->phy_type, efx->mdio.prtad);
1321 1322
1322 falcon_probe_board(efx, board_rev); 1323 rc = falcon_probe_board(efx, board_rev);
1324 if (rc)
1325 goto fail2;
1323 1326
1324 kfree(nvconfig); 1327 kfree(nvconfig);
1325 return 0; 1328 return 0;
diff --git a/drivers/net/sfc/falcon_boards.c b/drivers/net/sfc/falcon_boards.c
index 5712fddd72f..c7a933a3292 100644
--- a/drivers/net/sfc/falcon_boards.c
+++ b/drivers/net/sfc/falcon_boards.c
@@ -728,15 +728,7 @@ static const struct falcon_board_type board_types[] = {
728 }, 728 },
729}; 729};
730 730
731static const struct falcon_board_type falcon_dummy_board = { 731int falcon_probe_board(struct efx_nic *efx, u16 revision_info)
732 .init = efx_port_dummy_op_int,
733 .init_phy = efx_port_dummy_op_void,
734 .fini = efx_port_dummy_op_void,
735 .set_id_led = efx_port_dummy_op_set_id_led,
736 .monitor = efx_port_dummy_op_int,
737};
738
739void falcon_probe_board(struct efx_nic *efx, u16 revision_info)
740{ 732{
741 struct falcon_board *board = falcon_board(efx); 733 struct falcon_board *board = falcon_board(efx);
742 u8 type_id = FALCON_BOARD_TYPE(revision_info); 734 u8 type_id = FALCON_BOARD_TYPE(revision_info);
@@ -754,8 +746,9 @@ void falcon_probe_board(struct efx_nic *efx, u16 revision_info)
754 (efx->pci_dev->subsystem_vendor == EFX_VENDID_SFC) 746 (efx->pci_dev->subsystem_vendor == EFX_VENDID_SFC)
755 ? board->type->ref_model : board->type->gen_type, 747 ? board->type->ref_model : board->type->gen_type,
756 'A' + board->major, board->minor); 748 'A' + board->major, board->minor);
749 return 0;
757 } else { 750 } else {
758 EFX_ERR(efx, "unknown board type %d\n", type_id); 751 EFX_ERR(efx, "unknown board type %d\n", type_id);
759 board->type = &falcon_dummy_board; 752 return -ENODEV;
760 } 753 }
761} 754}
diff --git a/drivers/net/sfc/mcdi_phy.c b/drivers/net/sfc/mcdi_phy.c
index 34c22fa986e..2f235469666 100644
--- a/drivers/net/sfc/mcdi_phy.c
+++ b/drivers/net/sfc/mcdi_phy.c
@@ -11,6 +11,7 @@
11 * Driver for PHY related operations via MCDI. 11 * Driver for PHY related operations via MCDI.
12 */ 12 */
13 13
14#include <linux/slab.h>
14#include "efx.h" 15#include "efx.h"
15#include "phy.h" 16#include "phy.h"
16#include "mcdi.h" 17#include "mcdi.h"
diff --git a/drivers/net/sfc/mtd.c b/drivers/net/sfc/mtd.c
index 407bbaddfea..f3ac7f30b5e 100644
--- a/drivers/net/sfc/mtd.c
+++ b/drivers/net/sfc/mtd.c
@@ -12,6 +12,7 @@
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/mtd/mtd.h> 13#include <linux/mtd/mtd.h>
14#include <linux/delay.h> 14#include <linux/delay.h>
15#include <linux/slab.h>
15#include <linux/rtnetlink.h> 16#include <linux/rtnetlink.h>
16 17
17#define EFX_DRIVER_NAME "sfc_mtd" 18#define EFX_DRIVER_NAME "sfc_mtd"
diff --git a/drivers/net/sfc/nic.h b/drivers/net/sfc/nic.h
index 9351c0331a4..3166bafdfbe 100644
--- a/drivers/net/sfc/nic.h
+++ b/drivers/net/sfc/nic.h
@@ -156,7 +156,7 @@ extern struct efx_nic_type siena_a0_nic_type;
156 ************************************************************************** 156 **************************************************************************
157 */ 157 */
158 158
159extern void falcon_probe_board(struct efx_nic *efx, u16 revision_info); 159extern int falcon_probe_board(struct efx_nic *efx, u16 revision_info);
160 160
161/* TX data path */ 161/* TX data path */
162extern int efx_nic_probe_tx(struct efx_tx_queue *tx_queue); 162extern int efx_nic_probe_tx(struct efx_tx_queue *tx_queue);
diff --git a/drivers/net/sfc/qt202x_phy.c b/drivers/net/sfc/qt202x_phy.c
index 1bee62c8300..e077bef08a5 100644
--- a/drivers/net/sfc/qt202x_phy.c
+++ b/drivers/net/sfc/qt202x_phy.c
@@ -10,6 +10,7 @@
10 * Driver for AMCC QT202x SFP+ and XFP adapters; see www.amcc.com for details 10 * Driver for AMCC QT202x SFP+ and XFP adapters; see www.amcc.com for details
11 */ 11 */
12 12
13#include <linux/slab.h>
13#include <linux/timer.h> 14#include <linux/timer.h>
14#include <linux/delay.h> 15#include <linux/delay.h>
15#include "efx.h" 16#include "efx.h"
diff --git a/drivers/net/sfc/rx.c b/drivers/net/sfc/rx.c
index a97c923b560..e308818b9f5 100644
--- a/drivers/net/sfc/rx.c
+++ b/drivers/net/sfc/rx.c
@@ -10,6 +10,7 @@
10 10
11#include <linux/socket.h> 11#include <linux/socket.h>
12#include <linux/in.h> 12#include <linux/in.h>
13#include <linux/slab.h>
13#include <linux/ip.h> 14#include <linux/ip.h>
14#include <linux/tcp.h> 15#include <linux/tcp.h>
15#include <linux/udp.h> 16#include <linux/udp.h>
diff --git a/drivers/net/sfc/selftest.c b/drivers/net/sfc/selftest.c
index cf0139a7d9a..0106b1d9aae 100644
--- a/drivers/net/sfc/selftest.c
+++ b/drivers/net/sfc/selftest.c
@@ -18,6 +18,7 @@
18#include <linux/in.h> 18#include <linux/in.h>
19#include <linux/udp.h> 19#include <linux/udp.h>
20#include <linux/rtnetlink.h> 20#include <linux/rtnetlink.h>
21#include <linux/slab.h>
21#include <asm/io.h> 22#include <asm/io.h>
22#include "net_driver.h" 23#include "net_driver.h"
23#include "efx.h" 24#include "efx.h"
diff --git a/drivers/net/sfc/siena.c b/drivers/net/sfc/siena.c
index 1619fb5a64f..e0c46f59d1f 100644
--- a/drivers/net/sfc/siena.c
+++ b/drivers/net/sfc/siena.c
@@ -12,6 +12,7 @@
12#include <linux/delay.h> 12#include <linux/delay.h>
13#include <linux/pci.h> 13#include <linux/pci.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/slab.h>
15#include "net_driver.h" 16#include "net_driver.h"
16#include "bitfield.h" 17#include "bitfield.h"
17#include "efx.h" 18#include "efx.h"
@@ -455,8 +456,17 @@ static int siena_try_update_nic_stats(struct efx_nic *efx)
455 456
456static void siena_update_nic_stats(struct efx_nic *efx) 457static void siena_update_nic_stats(struct efx_nic *efx)
457{ 458{
458 while (siena_try_update_nic_stats(efx) == -EAGAIN) 459 int retry;
459 cpu_relax(); 460
461 /* If we're unlucky enough to read statistics wduring the DMA, wait
462 * up to 10ms for it to finish (typically takes <500us) */
463 for (retry = 0; retry < 100; ++retry) {
464 if (siena_try_update_nic_stats(efx) == 0)
465 return;
466 udelay(100);
467 }
468
469 /* Use the old values instead */
460} 470}
461 471
462static void siena_start_nic_stats(struct efx_nic *efx) 472static void siena_start_nic_stats(struct efx_nic *efx)
diff --git a/drivers/net/sfc/tenxpress.c b/drivers/net/sfc/tenxpress.c
index 10db071bd83..f21efe7bd31 100644
--- a/drivers/net/sfc/tenxpress.c
+++ b/drivers/net/sfc/tenxpress.c
@@ -10,6 +10,7 @@
10#include <linux/delay.h> 10#include <linux/delay.h>
11#include <linux/rtnetlink.h> 11#include <linux/rtnetlink.h>
12#include <linux/seq_file.h> 12#include <linux/seq_file.h>
13#include <linux/slab.h>
13#include "efx.h" 14#include "efx.h"
14#include "mdio_10g.h" 15#include "mdio_10g.h"
15#include "nic.h" 16#include "nic.h"
diff --git a/drivers/net/sfc/tx.c b/drivers/net/sfc/tx.c
index a8b70ef6d81..be0e110a1f7 100644
--- a/drivers/net/sfc/tx.c
+++ b/drivers/net/sfc/tx.c
@@ -13,6 +13,7 @@
13#include <linux/ip.h> 13#include <linux/ip.h>
14#include <linux/in.h> 14#include <linux/in.h>
15#include <linux/ipv6.h> 15#include <linux/ipv6.h>
16#include <linux/slab.h>
16#include <net/ipv6.h> 17#include <net/ipv6.h>
17#include <linux/if_ether.h> 18#include <linux/if_ether.h>
18#include <linux/highmem.h> 19#include <linux/highmem.h>
diff --git a/drivers/net/sgiseeq.c b/drivers/net/sgiseeq.c
index ed999d31f1f..c8fc896fc46 100644
--- a/drivers/net/sgiseeq.c
+++ b/drivers/net/sgiseeq.c
@@ -8,6 +8,7 @@
8 8
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/slab.h>
11#include <linux/errno.h> 12#include <linux/errno.h>
12#include <linux/init.h> 13#include <linux/init.h>
13#include <linux/types.h> 14#include <linux/types.h>
@@ -592,8 +593,10 @@ static int sgiseeq_start_xmit(struct sk_buff *skb, struct net_device *dev)
592 /* Setup... */ 593 /* Setup... */
593 len = skb->len; 594 len = skb->len;
594 if (len < ETH_ZLEN) { 595 if (len < ETH_ZLEN) {
595 if (skb_padto(skb, ETH_ZLEN)) 596 if (skb_padto(skb, ETH_ZLEN)) {
597 spin_unlock_irqrestore(&sp->tx_lock, flags);
596 return NETDEV_TX_OK; 598 return NETDEV_TX_OK;
599 }
597 len = ETH_ZLEN; 600 len = ETH_ZLEN;
598 } 601 }
599 602
diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c
index 42a35f086a9..6242b85d5d1 100644
--- a/drivers/net/sh_eth.c
+++ b/drivers/net/sh_eth.c
@@ -31,6 +31,7 @@
31#include <linux/cache.h> 31#include <linux/cache.h>
32#include <linux/io.h> 32#include <linux/io.h>
33#include <linux/pm_runtime.h> 33#include <linux/pm_runtime.h>
34#include <linux/slab.h>
34#include <asm/cacheflush.h> 35#include <asm/cacheflush.h>
35 36
36#include "sh_eth.h" 37#include "sh_eth.h"
diff --git a/drivers/net/sis190.c b/drivers/net/sis190.c
index 760d9e83a46..b30ce752bbf 100644
--- a/drivers/net/sis190.c
+++ b/drivers/net/sis190.c
@@ -32,6 +32,7 @@
32#include <linux/delay.h> 32#include <linux/delay.h>
33#include <linux/crc32.h> 33#include <linux/crc32.h>
34#include <linux/dma-mapping.h> 34#include <linux/dma-mapping.h>
35#include <linux/slab.h>
35#include <asm/irq.h> 36#include <asm/irq.h>
36 37
37#define PHY_MAX_ADDR 32 38#define PHY_MAX_ADDR 32
diff --git a/drivers/net/skfp/skfddi.c b/drivers/net/skfp/skfddi.c
index 1921a54ea99..d9016b75abc 100644
--- a/drivers/net/skfp/skfddi.c
+++ b/drivers/net/skfp/skfddi.c
@@ -78,13 +78,13 @@ static const char * const boot_msg =
78#include <linux/kernel.h> 78#include <linux/kernel.h>
79#include <linux/errno.h> 79#include <linux/errno.h>
80#include <linux/ioport.h> 80#include <linux/ioport.h>
81#include <linux/slab.h>
82#include <linux/interrupt.h> 81#include <linux/interrupt.h>
83#include <linux/pci.h> 82#include <linux/pci.h>
84#include <linux/netdevice.h> 83#include <linux/netdevice.h>
85#include <linux/fddidevice.h> 84#include <linux/fddidevice.h>
86#include <linux/skbuff.h> 85#include <linux/skbuff.h>
87#include <linux/bitops.h> 86#include <linux/bitops.h>
87#include <linux/gfp.h>
88 88
89#include <asm/byteorder.h> 89#include <asm/byteorder.h>
90#include <asm/io.h> 90#include <asm/io.h>
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index d0058e5bb6a..50eb70609f2 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -42,6 +42,7 @@
42#include <linux/sched.h> 42#include <linux/sched.h>
43#include <linux/seq_file.h> 43#include <linux/seq_file.h>
44#include <linux/mii.h> 44#include <linux/mii.h>
45#include <linux/slab.h>
45#include <asm/irq.h> 46#include <asm/irq.h>
46 47
47#include "skge.h" 48#include "skge.h"
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index d8ec4c11fd4..088c797eb73 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -33,6 +33,7 @@
33#include <linux/ethtool.h> 33#include <linux/ethtool.h>
34#include <linux/pci.h> 34#include <linux/pci.h>
35#include <linux/ip.h> 35#include <linux/ip.h>
36#include <linux/slab.h>
36#include <net/ip.h> 37#include <net/ip.h>
37#include <linux/tcp.h> 38#include <linux/tcp.h>
38#include <linux/in.h> 39#include <linux/in.h>
diff --git a/drivers/net/slhc.c b/drivers/net/slhc.c
index d640c0f5470..140d63f3caf 100644
--- a/drivers/net/slhc.c
+++ b/drivers/net/slhc.c
@@ -51,6 +51,7 @@
51 */ 51 */
52 52
53#include <linux/module.h> 53#include <linux/module.h>
54#include <linux/slab.h>
54#include <linux/types.h> 55#include <linux/types.h>
55#include <linux/string.h> 56#include <linux/string.h>
56#include <linux/errno.h> 57#include <linux/errno.h>
diff --git a/drivers/net/slip.c b/drivers/net/slip.c
index ba5bbc50344..89696156c05 100644
--- a/drivers/net/slip.c
+++ b/drivers/net/slip.c
@@ -83,6 +83,7 @@
83#include <linux/compat.h> 83#include <linux/compat.h>
84#include <linux/delay.h> 84#include <linux/delay.h>
85#include <linux/init.h> 85#include <linux/init.h>
86#include <linux/slab.h>
86#include "slip.h" 87#include "slip.h"
87#ifdef CONFIG_INET 88#ifdef CONFIG_INET
88#include <linux/ip.h> 89#include <linux/ip.h>
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index 9871a2b61f8..635820d42b1 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -59,7 +59,6 @@ static const char version[] =
59#include <linux/module.h> 59#include <linux/module.h>
60#include <linux/kernel.h> 60#include <linux/kernel.h>
61#include <linux/sched.h> 61#include <linux/sched.h>
62#include <linux/slab.h>
63#include <linux/delay.h> 62#include <linux/delay.h>
64#include <linux/interrupt.h> 63#include <linux/interrupt.h>
65#include <linux/errno.h> 64#include <linux/errno.h>
diff --git a/drivers/net/smc9194.c b/drivers/net/smc9194.c
index f9a960e7fc1..3f2f7843aa4 100644
--- a/drivers/net/smc9194.c
+++ b/drivers/net/smc9194.c
@@ -64,7 +64,6 @@ static const char version[] =
64#include <linux/interrupt.h> 64#include <linux/interrupt.h>
65#include <linux/ioport.h> 65#include <linux/ioport.h>
66#include <linux/in.h> 66#include <linux/in.h>
67#include <linux/slab.h>
68#include <linux/string.h> 67#include <linux/string.h>
69#include <linux/init.h> 68#include <linux/init.h>
70#include <linux/crc32.h> 69#include <linux/crc32.h>
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c
index fc1b5a1a358..860339d51d5 100644
--- a/drivers/net/smc91x.c
+++ b/drivers/net/smc91x.c
@@ -70,7 +70,6 @@ static const char version[] =
70#include <linux/module.h> 70#include <linux/module.h>
71#include <linux/kernel.h> 71#include <linux/kernel.h>
72#include <linux/sched.h> 72#include <linux/sched.h>
73#include <linux/slab.h>
74#include <linux/delay.h> 73#include <linux/delay.h>
75#include <linux/interrupt.h> 74#include <linux/interrupt.h>
76#include <linux/errno.h> 75#include <linux/errno.h>
diff --git a/drivers/net/smsc911x.c b/drivers/net/smsc911x.c
index 4fd1d8b3878..cbf520d38ea 100644
--- a/drivers/net/smsc911x.c
+++ b/drivers/net/smsc911x.c
@@ -41,7 +41,6 @@
41#include <linux/netdevice.h> 41#include <linux/netdevice.h>
42#include <linux/platform_device.h> 42#include <linux/platform_device.h>
43#include <linux/sched.h> 43#include <linux/sched.h>
44#include <linux/slab.h>
45#include <linux/timer.h> 44#include <linux/timer.h>
46#include <linux/bug.h> 45#include <linux/bug.h>
47#include <linux/bitops.h> 46#include <linux/bitops.h>
diff --git a/drivers/net/smsc9420.c b/drivers/net/smsc9420.c
index 34fa10d8ad4..aafaebf4574 100644
--- a/drivers/net/smsc9420.c
+++ b/drivers/net/smsc9420.c
@@ -26,6 +26,7 @@
26#include <linux/if_vlan.h> 26#include <linux/if_vlan.h>
27#include <linux/dma-mapping.h> 27#include <linux/dma-mapping.h>
28#include <linux/crc32.h> 28#include <linux/crc32.h>
29#include <linux/slab.h>
29#include <asm/unaligned.h> 30#include <asm/unaligned.h>
30#include "smsc9420.h" 31#include "smsc9420.h"
31 32
diff --git a/drivers/net/sni_82596.c b/drivers/net/sni_82596.c
index 854ccf2b410..6b2a8881747 100644
--- a/drivers/net/sni_82596.c
+++ b/drivers/net/sni_82596.c
@@ -8,7 +8,6 @@
8#include <linux/string.h> 8#include <linux/string.h>
9#include <linux/errno.h> 9#include <linux/errno.h>
10#include <linux/ioport.h> 10#include <linux/ioport.h>
11#include <linux/slab.h>
12#include <linux/interrupt.h> 11#include <linux/interrupt.h>
13#include <linux/delay.h> 12#include <linux/delay.h>
14#include <linux/netdevice.h> 13#include <linux/netdevice.h>
diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c
index 5ba9d989f8f..dd3cb0f2d21 100644
--- a/drivers/net/spider_net.c
+++ b/drivers/net/spider_net.c
@@ -31,6 +31,7 @@
31#include <linux/if_vlan.h> 31#include <linux/if_vlan.h>
32#include <linux/in.h> 32#include <linux/in.h>
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/gfp.h>
34#include <linux/ioport.h> 35#include <linux/ioport.h>
35#include <linux/ip.h> 36#include <linux/ip.h>
36#include <linux/kernel.h> 37#include <linux/kernel.h>
@@ -40,7 +41,6 @@
40#include <linux/device.h> 41#include <linux/device.h>
41#include <linux/pci.h> 42#include <linux/pci.h>
42#include <linux/skbuff.h> 43#include <linux/skbuff.h>
43#include <linux/slab.h>
44#include <linux/tcp.h> 44#include <linux/tcp.h>
45#include <linux/types.h> 45#include <linux/types.h>
46#include <linux/vmalloc.h> 46#include <linux/vmalloc.h>
diff --git a/drivers/net/stmmac/Kconfig b/drivers/net/stmmac/Kconfig
index fb287649a30..eb63d44748a 100644
--- a/drivers/net/stmmac/Kconfig
+++ b/drivers/net/stmmac/Kconfig
@@ -2,6 +2,7 @@ config STMMAC_ETH
2 tristate "STMicroelectronics 10/100/1000 Ethernet driver" 2 tristate "STMicroelectronics 10/100/1000 Ethernet driver"
3 select MII 3 select MII
4 select PHYLIB 4 select PHYLIB
5 select CRC32
5 depends on NETDEVICES && CPU_SUBTYPE_ST40 6 depends on NETDEVICES && CPU_SUBTYPE_ST40
6 help 7 help
7 This is the driver for the Ethernet IPs are built around a 8 This is the driver for the Ethernet IPs are built around a
diff --git a/drivers/net/stmmac/dwmac100.c b/drivers/net/stmmac/dwmac100.c
index 803b0373d84..4cacca614fc 100644
--- a/drivers/net/stmmac/dwmac100.c
+++ b/drivers/net/stmmac/dwmac100.c
@@ -29,6 +29,7 @@
29#include <linux/crc32.h> 29#include <linux/crc32.h>
30#include <linux/mii.h> 30#include <linux/mii.h>
31#include <linux/phy.h> 31#include <linux/phy.h>
32#include <linux/slab.h>
32 33
33#include "common.h" 34#include "common.h"
34#include "dwmac100.h" 35#include "dwmac100.h"
diff --git a/drivers/net/stmmac/dwmac1000_core.c b/drivers/net/stmmac/dwmac1000_core.c
index a6538ae4694..5bd95ebfe49 100644
--- a/drivers/net/stmmac/dwmac1000_core.c
+++ b/drivers/net/stmmac/dwmac1000_core.c
@@ -27,6 +27,7 @@
27*******************************************************************************/ 27*******************************************************************************/
28 28
29#include <linux/crc32.h> 29#include <linux/crc32.h>
30#include <linux/slab.h>
30#include "dwmac1000.h" 31#include "dwmac1000.h"
31 32
32static void dwmac1000_core_init(unsigned long ioaddr) 33static void dwmac1000_core_init(unsigned long ioaddr)
diff --git a/drivers/net/stmmac/stmmac_main.c b/drivers/net/stmmac/stmmac_main.c
index a6733612d64..4111a85ec80 100644
--- a/drivers/net/stmmac/stmmac_main.c
+++ b/drivers/net/stmmac/stmmac_main.c
@@ -44,6 +44,7 @@
44#include <linux/phy.h> 44#include <linux/phy.h>
45#include <linux/if_vlan.h> 45#include <linux/if_vlan.h>
46#include <linux/dma-mapping.h> 46#include <linux/dma-mapping.h>
47#include <linux/slab.h>
47#include "stmmac.h" 48#include "stmmac.h"
48 49
49#define STMMAC_RESOURCE_NAME "stmmaceth" 50#define STMMAC_RESOURCE_NAME "stmmaceth"
@@ -1685,7 +1686,7 @@ static int stmmac_dvr_probe(struct platform_device *pdev)
1685 } 1686 }
1686 pr_info("done!\n"); 1687 pr_info("done!\n");
1687 1688
1688 if (!request_mem_region(res->start, (res->end - res->start), 1689 if (!request_mem_region(res->start, resource_size(res),
1689 pdev->name)) { 1690 pdev->name)) {
1690 pr_err("%s: ERROR: memory allocation failed" 1691 pr_err("%s: ERROR: memory allocation failed"
1691 "cannot get the I/O addr 0x%x\n", 1692 "cannot get the I/O addr 0x%x\n",
@@ -1694,9 +1695,9 @@ static int stmmac_dvr_probe(struct platform_device *pdev)
1694 goto out; 1695 goto out;
1695 } 1696 }
1696 1697
1697 addr = ioremap(res->start, (res->end - res->start)); 1698 addr = ioremap(res->start, resource_size(res));
1698 if (!addr) { 1699 if (!addr) {
1699 pr_err("%s: ERROR: memory mapping failed \n", __func__); 1700 pr_err("%s: ERROR: memory mapping failed\n", __func__);
1700 ret = -ENOMEM; 1701 ret = -ENOMEM;
1701 goto out; 1702 goto out;
1702 } 1703 }
@@ -1774,7 +1775,7 @@ static int stmmac_dvr_probe(struct platform_device *pdev)
1774out: 1775out:
1775 if (ret < 0) { 1776 if (ret < 0) {
1776 platform_set_drvdata(pdev, NULL); 1777 platform_set_drvdata(pdev, NULL);
1777 release_mem_region(res->start, (res->end - res->start)); 1778 release_mem_region(res->start, resource_size(res));
1778 if (addr != NULL) 1779 if (addr != NULL)
1779 iounmap(addr); 1780 iounmap(addr);
1780 } 1781 }
@@ -1812,7 +1813,7 @@ static int stmmac_dvr_remove(struct platform_device *pdev)
1812 1813
1813 iounmap((void *)ndev->base_addr); 1814 iounmap((void *)ndev->base_addr);
1814 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1815 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1815 release_mem_region(res->start, (res->end - res->start)); 1816 release_mem_region(res->start, resource_size(res));
1816 1817
1817 free_netdev(ndev); 1818 free_netdev(ndev);
1818 1819
diff --git a/drivers/net/stmmac/stmmac_mdio.c b/drivers/net/stmmac/stmmac_mdio.c
index fffe1d037fe..40b2c792971 100644
--- a/drivers/net/stmmac/stmmac_mdio.c
+++ b/drivers/net/stmmac/stmmac_mdio.c
@@ -26,6 +26,7 @@
26 26
27#include <linux/mii.h> 27#include <linux/mii.h>
28#include <linux/phy.h> 28#include <linux/phy.h>
29#include <linux/slab.h>
29 30
30#include "stmmac.h" 31#include "stmmac.h"
31 32
diff --git a/drivers/net/sun3_82586.c b/drivers/net/sun3_82586.c
index 2f6a760e5f2..8b28c89a9a7 100644
--- a/drivers/net/sun3_82586.c
+++ b/drivers/net/sun3_82586.c
@@ -33,7 +33,6 @@ static int fifo=0x8; /* don't change */
33#include <linux/string.h> 33#include <linux/string.h>
34#include <linux/errno.h> 34#include <linux/errno.h>
35#include <linux/ioport.h> 35#include <linux/ioport.h>
36#include <linux/slab.h>
37#include <linux/interrupt.h> 36#include <linux/interrupt.h>
38#include <linux/delay.h> 37#include <linux/delay.h>
39#include <linux/init.h> 38#include <linux/init.h>
diff --git a/drivers/net/sun3lance.c b/drivers/net/sun3lance.c
index 99998862c22..1694ca5bfb4 100644
--- a/drivers/net/sun3lance.c
+++ b/drivers/net/sun3lance.c
@@ -28,7 +28,6 @@ static char *version = "sun3lance.c: v1.2 1/12/2001 Sam Creasey (sammy@sammy.ne
28#include <linux/kernel.h> 28#include <linux/kernel.h>
29#include <linux/string.h> 29#include <linux/string.h>
30#include <linux/errno.h> 30#include <linux/errno.h>
31#include <linux/slab.h>
32#include <linux/interrupt.h> 31#include <linux/interrupt.h>
33#include <linux/init.h> 32#include <linux/init.h>
34#include <linux/ioport.h> 33#include <linux/ioport.h>
diff --git a/drivers/net/sunbmac.c b/drivers/net/sunbmac.c
index a0bd361d5ec..ed7865a0b5b 100644
--- a/drivers/net/sunbmac.c
+++ b/drivers/net/sunbmac.c
@@ -11,7 +11,6 @@
11#include <linux/interrupt.h> 11#include <linux/interrupt.h>
12#include <linux/ioport.h> 12#include <linux/ioport.h>
13#include <linux/in.h> 13#include <linux/in.h>
14#include <linux/slab.h>
15#include <linux/string.h> 14#include <linux/string.h>
16#include <linux/delay.h> 15#include <linux/delay.h>
17#include <linux/init.h> 16#include <linux/init.h>
@@ -25,6 +24,7 @@
25#include <linux/dma-mapping.h> 24#include <linux/dma-mapping.h>
26#include <linux/of.h> 25#include <linux/of.h>
27#include <linux/of_device.h> 26#include <linux/of_device.h>
27#include <linux/gfp.h>
28 28
29#include <asm/auxio.h> 29#include <asm/auxio.h>
30#include <asm/byteorder.h> 30#include <asm/byteorder.h>
diff --git a/drivers/net/sundance.c b/drivers/net/sundance.c
index a855934dfc3..8249a394a4e 100644
--- a/drivers/net/sundance.c
+++ b/drivers/net/sundance.c
@@ -84,7 +84,6 @@ static char *media[MAX_UNITS];
84#include <linux/timer.h> 84#include <linux/timer.h>
85#include <linux/errno.h> 85#include <linux/errno.h>
86#include <linux/ioport.h> 86#include <linux/ioport.h>
87#include <linux/slab.h>
88#include <linux/interrupt.h> 87#include <linux/interrupt.h>
89#include <linux/pci.h> 88#include <linux/pci.h>
90#include <linux/netdevice.h> 89#include <linux/netdevice.h>
diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c
index 70196bc5fe6..e6880f1c4e8 100644
--- a/drivers/net/sungem.c
+++ b/drivers/net/sungem.c
@@ -39,7 +39,6 @@
39#include <linux/ioport.h> 39#include <linux/ioport.h>
40#include <linux/in.h> 40#include <linux/in.h>
41#include <linux/sched.h> 41#include <linux/sched.h>
42#include <linux/slab.h>
43#include <linux/string.h> 42#include <linux/string.h>
44#include <linux/delay.h> 43#include <linux/delay.h>
45#include <linux/init.h> 44#include <linux/init.h>
@@ -58,6 +57,7 @@
58#include <linux/bitops.h> 57#include <linux/bitops.h>
59#include <linux/mutex.h> 58#include <linux/mutex.h>
60#include <linux/mm.h> 59#include <linux/mm.h>
60#include <linux/gfp.h>
61 61
62#include <asm/system.h> 62#include <asm/system.h>
63#include <asm/io.h> 63#include <asm/io.h>
diff --git a/drivers/net/sunlance.c b/drivers/net/sunlance.c
index d7c73f478ef..0c21653ff9f 100644
--- a/drivers/net/sunlance.c
+++ b/drivers/net/sunlance.c
@@ -78,7 +78,6 @@ static char lancestr[] = "LANCE";
78#include <linux/interrupt.h> 78#include <linux/interrupt.h>
79#include <linux/ioport.h> 79#include <linux/ioport.h>
80#include <linux/in.h> 80#include <linux/in.h>
81#include <linux/slab.h>
82#include <linux/string.h> 81#include <linux/string.h>
83#include <linux/delay.h> 82#include <linux/delay.h>
84#include <linux/init.h> 83#include <linux/init.h>
@@ -94,6 +93,7 @@ static char lancestr[] = "LANCE";
94#include <linux/dma-mapping.h> 93#include <linux/dma-mapping.h>
95#include <linux/of.h> 94#include <linux/of.h>
96#include <linux/of_device.h> 95#include <linux/of_device.h>
96#include <linux/gfp.h>
97 97
98#include <asm/system.h> 98#include <asm/system.h>
99#include <asm/io.h> 99#include <asm/io.h>
diff --git a/drivers/net/tehuti.h b/drivers/net/tehuti.h
index a19dcf8b6b5..cff98d07cba 100644
--- a/drivers/net/tehuti.h
+++ b/drivers/net/tehuti.h
@@ -32,6 +32,7 @@
32#include <linux/firmware.h> 32#include <linux/firmware.h>
33#include <asm/byteorder.h> 33#include <asm/byteorder.h>
34#include <linux/dma-mapping.h> 34#include <linux/dma-mapping.h>
35#include <linux/slab.h>
35 36
36/* Compile Time Switches */ 37/* Compile Time Switches */
37/* start */ 38/* start */
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 22cf1c446de..ecc41cffb47 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -8633,6 +8633,7 @@ static int tg3_test_msi(struct tg3 *tp)
8633 pci_disable_msi(tp->pdev); 8633 pci_disable_msi(tp->pdev);
8634 8634
8635 tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI; 8635 tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI;
8636 tp->napi[0].irq_vec = tp->pdev->irq;
8636 8637
8637 err = tg3_request_irq(tp, 0); 8638 err = tg3_request_irq(tp, 0);
8638 if (err) 8639 if (err)
diff --git a/drivers/net/tokenring/3c359.c b/drivers/net/tokenring/3c359.c
index 0fb930feea4..7d7f3eef1ab 100644
--- a/drivers/net/tokenring/3c359.c
+++ b/drivers/net/tokenring/3c359.c
@@ -63,6 +63,7 @@
63#include <linux/spinlock.h> 63#include <linux/spinlock.h>
64#include <linux/bitops.h> 64#include <linux/bitops.h>
65#include <linux/firmware.h> 65#include <linux/firmware.h>
66#include <linux/slab.h>
66 67
67#include <net/checksum.h> 68#include <net/checksum.h>
68 69
diff --git a/drivers/net/tokenring/lanstreamer.c b/drivers/net/tokenring/lanstreamer.c
index dd028fee9dc..7a5fbf5a9d7 100644
--- a/drivers/net/tokenring/lanstreamer.c
+++ b/drivers/net/tokenring/lanstreamer.c
@@ -121,6 +121,7 @@
121#include <linux/spinlock.h> 121#include <linux/spinlock.h>
122#include <linux/bitops.h> 122#include <linux/bitops.h>
123#include <linux/jiffies.h> 123#include <linux/jiffies.h>
124#include <linux/slab.h>
124 125
125#include <net/net_namespace.h> 126#include <net/net_namespace.h>
126#include <net/checksum.h> 127#include <net/checksum.h>
diff --git a/drivers/net/tokenring/madgemc.c b/drivers/net/tokenring/madgemc.c
index 456f8bff40b..53f631ebb16 100644
--- a/drivers/net/tokenring/madgemc.c
+++ b/drivers/net/tokenring/madgemc.c
@@ -21,6 +21,7 @@ static const char version[] = "madgemc.c: v0.91 23/01/2000 by Adam Fritzler\n";
21 21
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/mca.h> 23#include <linux/mca.h>
24#include <linux/slab.h>
24#include <linux/kernel.h> 25#include <linux/kernel.h>
25#include <linux/errno.h> 26#include <linux/errno.h>
26#include <linux/init.h> 27#include <linux/init.h>
diff --git a/drivers/net/tokenring/smctr.c b/drivers/net/tokenring/smctr.c
index 5401d86a7be..e40560137c4 100644
--- a/drivers/net/tokenring/smctr.c
+++ b/drivers/net/tokenring/smctr.c
@@ -36,7 +36,6 @@
36#include <linux/ptrace.h> 36#include <linux/ptrace.h>
37#include <linux/ioport.h> 37#include <linux/ioport.h>
38#include <linux/in.h> 38#include <linux/in.h>
39#include <linux/slab.h>
40#include <linux/string.h> 39#include <linux/string.h>
41#include <linux/time.h> 40#include <linux/time.h>
42#include <linux/errno.h> 41#include <linux/errno.h>
diff --git a/drivers/net/tokenring/tms380tr.c b/drivers/net/tokenring/tms380tr.c
index ee71bcfb375..8b508c92241 100644
--- a/drivers/net/tokenring/tms380tr.c
+++ b/drivers/net/tokenring/tms380tr.c
@@ -85,7 +85,6 @@ static const char version[] = "tms380tr.c: v1.10 30/12/2002 by Christoph Goos, A
85#include <linux/ptrace.h> 85#include <linux/ptrace.h>
86#include <linux/ioport.h> 86#include <linux/ioport.h>
87#include <linux/in.h> 87#include <linux/in.h>
88#include <linux/slab.h>
89#include <linux/string.h> 88#include <linux/string.h>
90#include <linux/time.h> 89#include <linux/time.h>
91#include <linux/errno.h> 90#include <linux/errno.h>
diff --git a/drivers/net/tsi108_eth.c b/drivers/net/tsi108_eth.c
index 647cdd1d4e2..5b1fbb3c3b5 100644
--- a/drivers/net/tsi108_eth.c
+++ b/drivers/net/tsi108_eth.c
@@ -38,7 +38,6 @@
38#include <linux/etherdevice.h> 38#include <linux/etherdevice.h>
39#include <linux/ethtool.h> 39#include <linux/ethtool.h>
40#include <linux/skbuff.h> 40#include <linux/skbuff.h>
41#include <linux/slab.h>
42#include <linux/spinlock.h> 41#include <linux/spinlock.h>
43#include <linux/delay.h> 42#include <linux/delay.h>
44#include <linux/crc32.h> 43#include <linux/crc32.h>
@@ -48,6 +47,7 @@
48#include <linux/rtnetlink.h> 47#include <linux/rtnetlink.h>
49#include <linux/timer.h> 48#include <linux/timer.h>
50#include <linux/platform_device.h> 49#include <linux/platform_device.h>
50#include <linux/gfp.h>
51 51
52#include <asm/system.h> 52#include <asm/system.h>
53#include <asm/io.h> 53#include <asm/io.h>
diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
index cb429723b2c..19cafc2b418 100644
--- a/drivers/net/tulip/de2104x.c
+++ b/drivers/net/tulip/de2104x.c
@@ -42,6 +42,7 @@
42#include <linux/compiler.h> 42#include <linux/compiler.h>
43#include <linux/rtnetlink.h> 43#include <linux/rtnetlink.h>
44#include <linux/crc32.h> 44#include <linux/crc32.h>
45#include <linux/slab.h>
45 46
46#include <asm/io.h> 47#include <asm/io.h>
47#include <asm/irq.h> 48#include <asm/irq.h>
diff --git a/drivers/net/tulip/de4x5.c b/drivers/net/tulip/de4x5.c
index c4ecb9a9540..09b57193a16 100644
--- a/drivers/net/tulip/de4x5.c
+++ b/drivers/net/tulip/de4x5.c
@@ -450,7 +450,6 @@
450#include <linux/ptrace.h> 450#include <linux/ptrace.h>
451#include <linux/errno.h> 451#include <linux/errno.h>
452#include <linux/ioport.h> 452#include <linux/ioport.h>
453#include <linux/slab.h>
454#include <linux/pci.h> 453#include <linux/pci.h>
455#include <linux/eisa.h> 454#include <linux/eisa.h>
456#include <linux/delay.h> 455#include <linux/delay.h>
@@ -467,6 +466,7 @@
467#include <linux/dma-mapping.h> 466#include <linux/dma-mapping.h>
468#include <linux/moduleparam.h> 467#include <linux/moduleparam.h>
469#include <linux/bitops.h> 468#include <linux/bitops.h>
469#include <linux/gfp.h>
470 470
471#include <asm/io.h> 471#include <asm/io.h>
472#include <asm/dma.h> 472#include <asm/dma.h>
diff --git a/drivers/net/tulip/dmfe.c b/drivers/net/tulip/dmfe.c
index 95b38d803e9..9568156dea9 100644
--- a/drivers/net/tulip/dmfe.c
+++ b/drivers/net/tulip/dmfe.c
@@ -74,7 +74,6 @@
74#include <linux/ptrace.h> 74#include <linux/ptrace.h>
75#include <linux/errno.h> 75#include <linux/errno.h>
76#include <linux/ioport.h> 76#include <linux/ioport.h>
77#include <linux/slab.h>
78#include <linux/interrupt.h> 77#include <linux/interrupt.h>
79#include <linux/pci.h> 78#include <linux/pci.h>
80#include <linux/dma-mapping.h> 79#include <linux/dma-mapping.h>
diff --git a/drivers/net/tulip/eeprom.c b/drivers/net/tulip/eeprom.c
index 49f05d1431f..6002e651b9e 100644
--- a/drivers/net/tulip/eeprom.c
+++ b/drivers/net/tulip/eeprom.c
@@ -13,6 +13,7 @@
13*/ 13*/
14 14
15#include <linux/pci.h> 15#include <linux/pci.h>
16#include <linux/slab.h>
16#include "tulip.h" 17#include "tulip.h"
17#include <linux/init.h> 18#include <linux/init.h>
18#include <asm/unaligned.h> 19#include <asm/unaligned.h>
diff --git a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c
index 7f544ef2f5f..3810db9dc2d 100644
--- a/drivers/net/tulip/tulip_core.c
+++ b/drivers/net/tulip/tulip_core.c
@@ -24,6 +24,7 @@
24 24
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/pci.h> 26#include <linux/pci.h>
27#include <linux/slab.h>
27#include "tulip.h" 28#include "tulip.h"
28#include <linux/init.h> 29#include <linux/init.h>
29#include <linux/etherdevice.h> 30#include <linux/etherdevice.h>
diff --git a/drivers/net/tulip/uli526x.c b/drivers/net/tulip/uli526x.c
index 0ab05af237e..a589dd34891 100644
--- a/drivers/net/tulip/uli526x.c
+++ b/drivers/net/tulip/uli526x.c
@@ -25,7 +25,6 @@
25#include <linux/timer.h> 25#include <linux/timer.h>
26#include <linux/errno.h> 26#include <linux/errno.h>
27#include <linux/ioport.h> 27#include <linux/ioport.h>
28#include <linux/slab.h>
29#include <linux/interrupt.h> 28#include <linux/interrupt.h>
30#include <linux/pci.h> 29#include <linux/pci.h>
31#include <linux/init.h> 30#include <linux/init.h>
@@ -851,13 +850,15 @@ static void uli526x_rx_packet(struct net_device *dev, struct uli526x_board_info
851 850
852 if ( !(rdes0 & 0x8000) || 851 if ( !(rdes0 & 0x8000) ||
853 ((db->cr6_data & CR6_PM) && (rxlen>6)) ) { 852 ((db->cr6_data & CR6_PM) && (rxlen>6)) ) {
853 struct sk_buff *new_skb = NULL;
854
854 skb = rxptr->rx_skb_ptr; 855 skb = rxptr->rx_skb_ptr;
855 856
856 /* Good packet, send to upper layer */ 857 /* Good packet, send to upper layer */
857 /* Shorst packet used new SKB */ 858 /* Shorst packet used new SKB */
858 if ( (rxlen < RX_COPY_SIZE) && 859 if ((rxlen < RX_COPY_SIZE) &&
859 ( (skb = dev_alloc_skb(rxlen + 2) ) 860 (((new_skb = dev_alloc_skb(rxlen + 2)) != NULL))) {
860 != NULL) ) { 861 skb = new_skb;
861 /* size less than COPY_SIZE, allocate a rxlen SKB */ 862 /* size less than COPY_SIZE, allocate a rxlen SKB */
862 skb_reserve(skb, 2); /* 16byte align */ 863 skb_reserve(skb, 2); /* 16byte align */
863 memcpy(skb_put(skb, rxlen), 864 memcpy(skb_put(skb, rxlen),
diff --git a/drivers/net/tulip/winbond-840.c b/drivers/net/tulip/winbond-840.c
index 304f43866c4..98dbf6cc1d6 100644
--- a/drivers/net/tulip/winbond-840.c
+++ b/drivers/net/tulip/winbond-840.c
@@ -114,7 +114,6 @@ static int full_duplex[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};
114#include <linux/timer.h> 114#include <linux/timer.h>
115#include <linux/errno.h> 115#include <linux/errno.h>
116#include <linux/ioport.h> 116#include <linux/ioport.h>
117#include <linux/slab.h>
118#include <linux/interrupt.h> 117#include <linux/interrupt.h>
119#include <linux/pci.h> 118#include <linux/pci.h>
120#include <linux/dma-mapping.h> 119#include <linux/dma-mapping.h>
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 96c39bddc78..43265207d46 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -387,6 +387,10 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev)
387 } 387 }
388 } 388 }
389 389
390 /* Orphan the skb - required as we might hang on to it
391 * for indefinite time. */
392 skb_orphan(skb);
393
390 /* Enqueue packet */ 394 /* Enqueue packet */
391 skb_queue_tail(&tun->socket.sk->sk_receive_queue, skb); 395 skb_queue_tail(&tun->socket.sk->sk_receive_queue, skb);
392 dev->trans_start = jiffies; 396 dev->trans_start = jiffies;
diff --git a/drivers/net/typhoon.c b/drivers/net/typhoon.c
index cd24e5f2b2a..98d818daa77 100644
--- a/drivers/net/typhoon.c
+++ b/drivers/net/typhoon.c
@@ -109,7 +109,6 @@ static const int multicast_filter_limit = 32;
109#include <linux/timer.h> 109#include <linux/timer.h>
110#include <linux/errno.h> 110#include <linux/errno.h>
111#include <linux/ioport.h> 111#include <linux/ioport.h>
112#include <linux/slab.h>
113#include <linux/interrupt.h> 112#include <linux/interrupt.h>
114#include <linux/pci.h> 113#include <linux/pci.h>
115#include <linux/netdevice.h> 114#include <linux/netdevice.h>
diff --git a/drivers/net/ucc_geth_ethtool.c b/drivers/net/ucc_geth_ethtool.c
index 7075f26e97d..6f92e48f02d 100644
--- a/drivers/net/ucc_geth_ethtool.c
+++ b/drivers/net/ucc_geth_ethtool.c
@@ -18,7 +18,6 @@
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/errno.h> 20#include <linux/errno.h>
21#include <linux/slab.h>
22#include <linux/stddef.h> 21#include <linux/stddef.h>
23#include <linux/interrupt.h> 22#include <linux/interrupt.h>
24#include <linux/netdevice.h> 23#include <linux/netdevice.h>
diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig
index ba56ce4382d..d7b7018a1de 100644
--- a/drivers/net/usb/Kconfig
+++ b/drivers/net/usb/Kconfig
@@ -385,4 +385,25 @@ config USB_CDC_PHONET
385 cellular modem, as found on most Nokia handsets with the 385 cellular modem, as found on most Nokia handsets with the
386 "PC suite" USB profile. 386 "PC suite" USB profile.
387 387
388config USB_IPHETH
389 tristate "Apple iPhone USB Ethernet driver"
390 default n
391 ---help---
392 Module used to share Internet connection (tethering) from your
393 iPhone (Original, 3G and 3GS) to your system.
394 Note that you need userspace libraries and programs that are needed
395 to pair your device with your system and that understand the iPhone
396 protocol.
397
398 For more information: http://giagio.com/wiki/moin.cgi/iPhoneEthernetDriver
399
400config USB_SIERRA_NET
401 tristate "USB-to-WWAN Driver for Sierra Wireless modems"
402 depends on USB_USBNET
403 help
404 Choose this option if you have a Sierra Wireless USB-to-WWAN device.
405
406 To compile this driver as a module, choose M here: the
407 module will be called sierra_net.
408
388endmenu 409endmenu
diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile
index 82ea62955b5..b13a279663b 100644
--- a/drivers/net/usb/Makefile
+++ b/drivers/net/usb/Makefile
@@ -23,4 +23,6 @@ obj-$(CONFIG_USB_NET_MCS7830) += mcs7830.o
23obj-$(CONFIG_USB_USBNET) += usbnet.o 23obj-$(CONFIG_USB_USBNET) += usbnet.o
24obj-$(CONFIG_USB_NET_INT51X1) += int51x1.o 24obj-$(CONFIG_USB_NET_INT51X1) += int51x1.o
25obj-$(CONFIG_USB_CDC_PHONET) += cdc-phonet.o 25obj-$(CONFIG_USB_CDC_PHONET) += cdc-phonet.o
26obj-$(CONFIG_USB_IPHETH) += ipheth.o
27obj-$(CONFIG_USB_SIERRA_NET) += sierra_net.o
26 28
diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
index 9e05639435f..35f56fc8280 100644
--- a/drivers/net/usb/asix.c
+++ b/drivers/net/usb/asix.c
@@ -34,6 +34,7 @@
34#include <linux/usb.h> 34#include <linux/usb.h>
35#include <linux/crc32.h> 35#include <linux/crc32.h>
36#include <linux/usb/usbnet.h> 36#include <linux/usb/usbnet.h>
37#include <linux/slab.h>
37 38
38#define DRIVER_VERSION "14-Jun-2006" 39#define DRIVER_VERSION "14-Jun-2006"
39static const char driver_name [] = "asix"; 40static const char driver_name [] = "asix";
diff --git a/drivers/net/usb/catc.c b/drivers/net/usb/catc.c
index 96f1ebe0d34..602e123b274 100644
--- a/drivers/net/usb/catc.c
+++ b/drivers/net/usb/catc.c
@@ -36,7 +36,6 @@
36#include <linux/module.h> 36#include <linux/module.h>
37#include <linux/kernel.h> 37#include <linux/kernel.h>
38#include <linux/string.h> 38#include <linux/string.h>
39#include <linux/slab.h>
40#include <linux/netdevice.h> 39#include <linux/netdevice.h>
41#include <linux/etherdevice.h> 40#include <linux/etherdevice.h>
42#include <linux/skbuff.h> 41#include <linux/skbuff.h>
@@ -44,6 +43,7 @@
44#include <linux/ethtool.h> 43#include <linux/ethtool.h>
45#include <linux/crc32.h> 44#include <linux/crc32.h>
46#include <linux/bitops.h> 45#include <linux/bitops.h>
46#include <linux/gfp.h>
47#include <asm/uaccess.h> 47#include <asm/uaccess.h>
48 48
49#undef DEBUG 49#undef DEBUG
diff --git a/drivers/net/usb/cdc-phonet.c b/drivers/net/usb/cdc-phonet.c
index 6491c9c00c8..dc9444525b4 100644
--- a/drivers/net/usb/cdc-phonet.c
+++ b/drivers/net/usb/cdc-phonet.c
@@ -22,6 +22,7 @@
22 22
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/gfp.h>
25#include <linux/usb.h> 26#include <linux/usb.h>
26#include <linux/usb/cdc.h> 27#include <linux/usb/cdc.h>
27#include <linux/netdevice.h> 28#include <linux/netdevice.h>
diff --git a/drivers/net/usb/cdc_eem.c b/drivers/net/usb/cdc_eem.c
index a4a85a6ed86..5f3b97668e6 100644
--- a/drivers/net/usb/cdc_eem.c
+++ b/drivers/net/usb/cdc_eem.c
@@ -30,6 +30,7 @@
30#include <linux/crc32.h> 30#include <linux/crc32.h>
31#include <linux/usb/cdc.h> 31#include <linux/usb/cdc.h>
32#include <linux/usb/usbnet.h> 32#include <linux/usb/usbnet.h>
33#include <linux/gfp.h>
33 34
34 35
35/* 36/*
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index c8cdb7f30ad..3547cf13d21 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -431,6 +431,7 @@ static const struct driver_info mbm_info = {
431 .bind = cdc_bind, 431 .bind = cdc_bind,
432 .unbind = usbnet_cdc_unbind, 432 .unbind = usbnet_cdc_unbind,
433 .status = cdc_status, 433 .status = cdc_status,
434 .manage_power = cdc_manage_power,
434}; 435};
435 436
436/*-------------------------------------------------------------------------*/ 437/*-------------------------------------------------------------------------*/
diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c
index 269339769f4..5dfed9297b2 100644
--- a/drivers/net/usb/dm9601.c
+++ b/drivers/net/usb/dm9601.c
@@ -21,6 +21,7 @@
21#include <linux/usb.h> 21#include <linux/usb.h>
22#include <linux/crc32.h> 22#include <linux/crc32.h>
23#include <linux/usb/usbnet.h> 23#include <linux/usb/usbnet.h>
24#include <linux/slab.h>
24 25
25/* datasheet: 26/* datasheet:
26 http://ptm2.cc.utu.fi/ftp/network/cards/DM9601/From_NET/DM9601-DS-P01-930914.pdf 27 http://ptm2.cc.utu.fi/ftp/network/cards/DM9601/From_NET/DM9601-DS-P01-930914.pdf
@@ -239,7 +240,7 @@ static int dm_write_shared_word(struct usbnet *dev, int phy, u8 reg, __le16 valu
239 goto out; 240 goto out;
240 241
241 dm_write_reg(dev, DM_SHARED_ADDR, phy ? (reg | 0x40) : reg); 242 dm_write_reg(dev, DM_SHARED_ADDR, phy ? (reg | 0x40) : reg);
242 dm_write_reg(dev, DM_SHARED_CTRL, phy ? 0x1c : 0x14); 243 dm_write_reg(dev, DM_SHARED_CTRL, phy ? 0x1a : 0x12);
243 244
244 for (i = 0; i < DM_TIMEOUT; i++) { 245 for (i = 0; i < DM_TIMEOUT; i++) {
245 u8 tmp; 246 u8 tmp;
diff --git a/drivers/net/usb/gl620a.c b/drivers/net/usb/gl620a.c
index f7ccfad9384..dcd57c37ef7 100644
--- a/drivers/net/usb/gl620a.c
+++ b/drivers/net/usb/gl620a.c
@@ -30,6 +30,7 @@
30#include <linux/mii.h> 30#include <linux/mii.h>
31#include <linux/usb.h> 31#include <linux/usb.h>
32#include <linux/usb/usbnet.h> 32#include <linux/usb/usbnet.h>
33#include <linux/gfp.h>
33 34
34 35
35/* 36/*
diff --git a/drivers/net/usb/int51x1.c b/drivers/net/usb/int51x1.c
index 3c228df5706..be02a25da71 100644
--- a/drivers/net/usb/int51x1.c
+++ b/drivers/net/usb/int51x1.c
@@ -29,6 +29,7 @@
29#include <linux/netdevice.h> 29#include <linux/netdevice.h>
30#include <linux/etherdevice.h> 30#include <linux/etherdevice.h>
31#include <linux/ethtool.h> 31#include <linux/ethtool.h>
32#include <linux/slab.h>
32#include <linux/mii.h> 33#include <linux/mii.h>
33#include <linux/usb.h> 34#include <linux/usb.h>
34#include <linux/usb/usbnet.h> 35#include <linux/usb/usbnet.h>
diff --git a/drivers/net/usb/ipheth.c b/drivers/net/usb/ipheth.c
new file mode 100644
index 00000000000..418825d26f9
--- /dev/null
+++ b/drivers/net/usb/ipheth.c
@@ -0,0 +1,569 @@
1/*
2 * ipheth.c - Apple iPhone USB Ethernet driver
3 *
4 * Copyright (c) 2009 Diego Giagio <diego@giagio.com>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of GIAGIO.COM nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * Alternatively, provided that this notice is retained in full, this
20 * software may be distributed under the terms of the GNU General
21 * Public License ("GPL") version 2, in which case the provisions of the
22 * GPL apply INSTEAD OF those given above.
23 *
24 * The provided data structures and external interfaces from this code
25 * are not restricted to be used by modules with a GPL compatible license.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
38 * DAMAGE.
39 *
40 *
41 * Attention: iPhone device must be paired, otherwise it won't respond to our
42 * driver. For more info: http://giagio.com/wiki/moin.cgi/iPhoneEthernetDriver
43 *
44 */
45
46#include <linux/kernel.h>
47#include <linux/errno.h>
48#include <linux/init.h>
49#include <linux/slab.h>
50#include <linux/module.h>
51#include <linux/netdevice.h>
52#include <linux/etherdevice.h>
53#include <linux/ethtool.h>
54#include <linux/usb.h>
55#include <linux/workqueue.h>
56
57#define USB_VENDOR_APPLE 0x05ac
58#define USB_PRODUCT_IPHONE 0x1290
59#define USB_PRODUCT_IPHONE_3G 0x1292
60#define USB_PRODUCT_IPHONE_3GS 0x1294
61
62#define IPHETH_USBINTF_CLASS 255
63#define IPHETH_USBINTF_SUBCLASS 253
64#define IPHETH_USBINTF_PROTO 1
65
66#define IPHETH_BUF_SIZE 1516
67#define IPHETH_TX_TIMEOUT (5 * HZ)
68
69#define IPHETH_INTFNUM 2
70#define IPHETH_ALT_INTFNUM 1
71
72#define IPHETH_CTRL_ENDP 0x00
73#define IPHETH_CTRL_BUF_SIZE 0x40
74#define IPHETH_CTRL_TIMEOUT (5 * HZ)
75
76#define IPHETH_CMD_GET_MACADDR 0x00
77#define IPHETH_CMD_CARRIER_CHECK 0x45
78
79#define IPHETH_CARRIER_CHECK_TIMEOUT round_jiffies_relative(1 * HZ)
80#define IPHETH_CARRIER_ON 0x04
81
82static struct usb_device_id ipheth_table[] = {
83 { USB_DEVICE_AND_INTERFACE_INFO(
84 USB_VENDOR_APPLE, USB_PRODUCT_IPHONE,
85 IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
86 IPHETH_USBINTF_PROTO) },
87 { USB_DEVICE_AND_INTERFACE_INFO(
88 USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_3G,
89 IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
90 IPHETH_USBINTF_PROTO) },
91 { USB_DEVICE_AND_INTERFACE_INFO(
92 USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_3GS,
93 IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
94 IPHETH_USBINTF_PROTO) },
95 { }
96};
97MODULE_DEVICE_TABLE(usb, ipheth_table);
98
99struct ipheth_device {
100 struct usb_device *udev;
101 struct usb_interface *intf;
102 struct net_device *net;
103 struct sk_buff *tx_skb;
104 struct urb *tx_urb;
105 struct urb *rx_urb;
106 unsigned char *tx_buf;
107 unsigned char *rx_buf;
108 unsigned char *ctrl_buf;
109 u8 bulk_in;
110 u8 bulk_out;
111 struct delayed_work carrier_work;
112};
113
114static int ipheth_rx_submit(struct ipheth_device *dev, gfp_t mem_flags);
115
116static int ipheth_alloc_urbs(struct ipheth_device *iphone)
117{
118 struct urb *tx_urb = NULL;
119 struct urb *rx_urb = NULL;
120 u8 *tx_buf = NULL;
121 u8 *rx_buf = NULL;
122
123 tx_urb = usb_alloc_urb(0, GFP_KERNEL);
124 if (tx_urb == NULL)
125 goto error_nomem;
126
127 rx_urb = usb_alloc_urb(0, GFP_KERNEL);
128 if (rx_urb == NULL)
129 goto free_tx_urb;
130
131 tx_buf = usb_buffer_alloc(iphone->udev,
132 IPHETH_BUF_SIZE,
133 GFP_KERNEL,
134 &tx_urb->transfer_dma);
135 if (tx_buf == NULL)
136 goto free_rx_urb;
137
138 rx_buf = usb_buffer_alloc(iphone->udev,
139 IPHETH_BUF_SIZE,
140 GFP_KERNEL,
141 &rx_urb->transfer_dma);
142 if (rx_buf == NULL)
143 goto free_tx_buf;
144
145
146 iphone->tx_urb = tx_urb;
147 iphone->rx_urb = rx_urb;
148 iphone->tx_buf = tx_buf;
149 iphone->rx_buf = rx_buf;
150 return 0;
151
152free_tx_buf:
153 usb_buffer_free(iphone->udev, IPHETH_BUF_SIZE, tx_buf,
154 tx_urb->transfer_dma);
155free_rx_urb:
156 usb_free_urb(rx_urb);
157free_tx_urb:
158 usb_free_urb(tx_urb);
159error_nomem:
160 return -ENOMEM;
161}
162
163static void ipheth_free_urbs(struct ipheth_device *iphone)
164{
165 usb_buffer_free(iphone->udev, IPHETH_BUF_SIZE, iphone->rx_buf,
166 iphone->rx_urb->transfer_dma);
167 usb_buffer_free(iphone->udev, IPHETH_BUF_SIZE, iphone->tx_buf,
168 iphone->tx_urb->transfer_dma);
169 usb_free_urb(iphone->rx_urb);
170 usb_free_urb(iphone->tx_urb);
171}
172
173static void ipheth_kill_urbs(struct ipheth_device *dev)
174{
175 usb_kill_urb(dev->tx_urb);
176 usb_kill_urb(dev->rx_urb);
177}
178
179static void ipheth_rcvbulk_callback(struct urb *urb)
180{
181 struct ipheth_device *dev;
182 struct sk_buff *skb;
183 int status;
184 char *buf;
185 int len;
186
187 dev = urb->context;
188 if (dev == NULL)
189 return;
190
191 status = urb->status;
192 switch (status) {
193 case -ENOENT:
194 case -ECONNRESET:
195 case -ESHUTDOWN:
196 return;
197 case 0:
198 break;
199 default:
200 err("%s: urb status: %d", __func__, urb->status);
201 return;
202 }
203
204 len = urb->actual_length;
205 buf = urb->transfer_buffer;
206
207 skb = dev_alloc_skb(NET_IP_ALIGN + len);
208 if (!skb) {
209 err("%s: dev_alloc_skb: -ENOMEM", __func__);
210 dev->net->stats.rx_dropped++;
211 return;
212 }
213
214 skb_reserve(skb, NET_IP_ALIGN);
215 memcpy(skb_put(skb, len), buf + NET_IP_ALIGN, len - NET_IP_ALIGN);
216 skb->dev = dev->net;
217 skb->protocol = eth_type_trans(skb, dev->net);
218
219 dev->net->stats.rx_packets++;
220 dev->net->stats.rx_bytes += len;
221
222 netif_rx(skb);
223 ipheth_rx_submit(dev, GFP_ATOMIC);
224}
225
226static void ipheth_sndbulk_callback(struct urb *urb)
227{
228 struct ipheth_device *dev;
229
230 dev = urb->context;
231 if (dev == NULL)
232 return;
233
234 if (urb->status != 0 &&
235 urb->status != -ENOENT &&
236 urb->status != -ECONNRESET &&
237 urb->status != -ESHUTDOWN)
238 err("%s: urb status: %d", __func__, urb->status);
239
240 dev_kfree_skb_irq(dev->tx_skb);
241 netif_wake_queue(dev->net);
242}
243
244static int ipheth_carrier_set(struct ipheth_device *dev)
245{
246 struct usb_device *udev = dev->udev;
247 int retval;
248
249 retval = usb_control_msg(udev,
250 usb_rcvctrlpipe(udev, IPHETH_CTRL_ENDP),
251 IPHETH_CMD_CARRIER_CHECK, /* request */
252 0xc0, /* request type */
253 0x00, /* value */
254 0x02, /* index */
255 dev->ctrl_buf, IPHETH_CTRL_BUF_SIZE,
256 IPHETH_CTRL_TIMEOUT);
257 if (retval < 0) {
258 err("%s: usb_control_msg: %d", __func__, retval);
259 return retval;
260 }
261
262 if (dev->ctrl_buf[0] == IPHETH_CARRIER_ON)
263 netif_carrier_on(dev->net);
264 else
265 netif_carrier_off(dev->net);
266
267 return 0;
268}
269
270static void ipheth_carrier_check_work(struct work_struct *work)
271{
272 struct ipheth_device *dev = container_of(work, struct ipheth_device,
273 carrier_work.work);
274
275 ipheth_carrier_set(dev);
276 schedule_delayed_work(&dev->carrier_work, IPHETH_CARRIER_CHECK_TIMEOUT);
277}
278
279static int ipheth_get_macaddr(struct ipheth_device *dev)
280{
281 struct usb_device *udev = dev->udev;
282 struct net_device *net = dev->net;
283 int retval;
284
285 retval = usb_control_msg(udev,
286 usb_rcvctrlpipe(udev, IPHETH_CTRL_ENDP),
287 IPHETH_CMD_GET_MACADDR, /* request */
288 0xc0, /* request type */
289 0x00, /* value */
290 0x02, /* index */
291 dev->ctrl_buf,
292 IPHETH_CTRL_BUF_SIZE,
293 IPHETH_CTRL_TIMEOUT);
294 if (retval < 0) {
295 err("%s: usb_control_msg: %d", __func__, retval);
296 } else if (retval < ETH_ALEN) {
297 err("%s: usb_control_msg: short packet: %d bytes",
298 __func__, retval);
299 retval = -EINVAL;
300 } else {
301 memcpy(net->dev_addr, dev->ctrl_buf, ETH_ALEN);
302 retval = 0;
303 }
304
305 return retval;
306}
307
308static int ipheth_rx_submit(struct ipheth_device *dev, gfp_t mem_flags)
309{
310 struct usb_device *udev = dev->udev;
311 int retval;
312
313 usb_fill_bulk_urb(dev->rx_urb, udev,
314 usb_rcvbulkpipe(udev, dev->bulk_in),
315 dev->rx_buf, IPHETH_BUF_SIZE,
316 ipheth_rcvbulk_callback,
317 dev);
318 dev->rx_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
319
320 retval = usb_submit_urb(dev->rx_urb, mem_flags);
321 if (retval)
322 err("%s: usb_submit_urb: %d", __func__, retval);
323 return retval;
324}
325
326static int ipheth_open(struct net_device *net)
327{
328 struct ipheth_device *dev = netdev_priv(net);
329 struct usb_device *udev = dev->udev;
330 int retval = 0;
331
332 usb_set_interface(udev, IPHETH_INTFNUM, IPHETH_ALT_INTFNUM);
333
334 retval = ipheth_carrier_set(dev);
335 if (retval)
336 return retval;
337
338 retval = ipheth_rx_submit(dev, GFP_KERNEL);
339 if (retval)
340 return retval;
341
342 schedule_delayed_work(&dev->carrier_work, IPHETH_CARRIER_CHECK_TIMEOUT);
343 netif_start_queue(net);
344 return retval;
345}
346
347static int ipheth_close(struct net_device *net)
348{
349 struct ipheth_device *dev = netdev_priv(net);
350
351 cancel_delayed_work_sync(&dev->carrier_work);
352 netif_stop_queue(net);
353 return 0;
354}
355
356static int ipheth_tx(struct sk_buff *skb, struct net_device *net)
357{
358 struct ipheth_device *dev = netdev_priv(net);
359 struct usb_device *udev = dev->udev;
360 int retval;
361
362 /* Paranoid */
363 if (skb->len > IPHETH_BUF_SIZE) {
364 WARN(1, "%s: skb too large: %d bytes", __func__, skb->len);
365 dev->net->stats.tx_dropped++;
366 dev_kfree_skb_irq(skb);
367 return NETDEV_TX_OK;
368 }
369
370 memcpy(dev->tx_buf, skb->data, skb->len);
371 if (skb->len < IPHETH_BUF_SIZE)
372 memset(dev->tx_buf + skb->len, 0, IPHETH_BUF_SIZE - skb->len);
373
374 usb_fill_bulk_urb(dev->tx_urb, udev,
375 usb_sndbulkpipe(udev, dev->bulk_out),
376 dev->tx_buf, IPHETH_BUF_SIZE,
377 ipheth_sndbulk_callback,
378 dev);
379 dev->tx_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
380
381 retval = usb_submit_urb(dev->tx_urb, GFP_ATOMIC);
382 if (retval) {
383 err("%s: usb_submit_urb: %d", __func__, retval);
384 dev->net->stats.tx_errors++;
385 dev_kfree_skb_irq(skb);
386 } else {
387 dev->tx_skb = skb;
388
389 dev->net->stats.tx_packets++;
390 dev->net->stats.tx_bytes += skb->len;
391 netif_stop_queue(net);
392 }
393
394 return NETDEV_TX_OK;
395}
396
397static void ipheth_tx_timeout(struct net_device *net)
398{
399 struct ipheth_device *dev = netdev_priv(net);
400
401 err("%s: TX timeout", __func__);
402 dev->net->stats.tx_errors++;
403 usb_unlink_urb(dev->tx_urb);
404}
405
406static struct net_device_stats *ipheth_stats(struct net_device *net)
407{
408 struct ipheth_device *dev = netdev_priv(net);
409 return &dev->net->stats;
410}
411
412static u32 ipheth_ethtool_op_get_link(struct net_device *net)
413{
414 struct ipheth_device *dev = netdev_priv(net);
415 return netif_carrier_ok(dev->net);
416}
417
418static struct ethtool_ops ops = {
419 .get_link = ipheth_ethtool_op_get_link
420};
421
422static const struct net_device_ops ipheth_netdev_ops = {
423 .ndo_open = &ipheth_open,
424 .ndo_stop = &ipheth_close,
425 .ndo_start_xmit = &ipheth_tx,
426 .ndo_tx_timeout = &ipheth_tx_timeout,
427 .ndo_get_stats = &ipheth_stats,
428};
429
430static struct device_type ipheth_type = {
431 .name = "wwan",
432};
433
434static int ipheth_probe(struct usb_interface *intf,
435 const struct usb_device_id *id)
436{
437 struct usb_device *udev = interface_to_usbdev(intf);
438 struct usb_host_interface *hintf;
439 struct usb_endpoint_descriptor *endp;
440 struct ipheth_device *dev;
441 struct net_device *netdev;
442 int i;
443 int retval;
444
445 netdev = alloc_etherdev(sizeof(struct ipheth_device));
446 if (!netdev)
447 return -ENOMEM;
448
449 netdev->netdev_ops = &ipheth_netdev_ops;
450 netdev->watchdog_timeo = IPHETH_TX_TIMEOUT;
451 strcpy(netdev->name, "wwan%d");
452
453 dev = netdev_priv(netdev);
454 dev->udev = udev;
455 dev->net = netdev;
456 dev->intf = intf;
457
458 /* Set up endpoints */
459 hintf = usb_altnum_to_altsetting(intf, IPHETH_ALT_INTFNUM);
460 if (hintf == NULL) {
461 retval = -ENODEV;
462 err("Unable to find alternate settings interface");
463 goto err_endpoints;
464 }
465
466 for (i = 0; i < hintf->desc.bNumEndpoints; i++) {
467 endp = &hintf->endpoint[i].desc;
468 if (usb_endpoint_is_bulk_in(endp))
469 dev->bulk_in = endp->bEndpointAddress;
470 else if (usb_endpoint_is_bulk_out(endp))
471 dev->bulk_out = endp->bEndpointAddress;
472 }
473 if (!(dev->bulk_in && dev->bulk_out)) {
474 retval = -ENODEV;
475 err("Unable to find endpoints");
476 goto err_endpoints;
477 }
478
479 dev->ctrl_buf = kmalloc(IPHETH_CTRL_BUF_SIZE, GFP_KERNEL);
480 if (dev->ctrl_buf == NULL) {
481 retval = -ENOMEM;
482 goto err_alloc_ctrl_buf;
483 }
484
485 retval = ipheth_get_macaddr(dev);
486 if (retval)
487 goto err_get_macaddr;
488
489 INIT_DELAYED_WORK(&dev->carrier_work, ipheth_carrier_check_work);
490
491 retval = ipheth_alloc_urbs(dev);
492 if (retval) {
493 err("error allocating urbs: %d", retval);
494 goto err_alloc_urbs;
495 }
496
497 usb_set_intfdata(intf, dev);
498
499 SET_NETDEV_DEV(netdev, &intf->dev);
500 SET_ETHTOOL_OPS(netdev, &ops);
501 SET_NETDEV_DEVTYPE(netdev, &ipheth_type);
502
503 retval = register_netdev(netdev);
504 if (retval) {
505 err("error registering netdev: %d", retval);
506 retval = -EIO;
507 goto err_register_netdev;
508 }
509
510 dev_info(&intf->dev, "Apple iPhone USB Ethernet device attached\n");
511 return 0;
512
513err_register_netdev:
514 ipheth_free_urbs(dev);
515err_alloc_urbs:
516err_get_macaddr:
517err_alloc_ctrl_buf:
518 kfree(dev->ctrl_buf);
519err_endpoints:
520 free_netdev(netdev);
521 return retval;
522}
523
524static void ipheth_disconnect(struct usb_interface *intf)
525{
526 struct ipheth_device *dev;
527
528 dev = usb_get_intfdata(intf);
529 if (dev != NULL) {
530 unregister_netdev(dev->net);
531 ipheth_kill_urbs(dev);
532 ipheth_free_urbs(dev);
533 kfree(dev->ctrl_buf);
534 free_netdev(dev->net);
535 }
536 usb_set_intfdata(intf, NULL);
537 dev_info(&intf->dev, "Apple iPhone USB Ethernet now disconnected\n");
538}
539
540static struct usb_driver ipheth_driver = {
541 .name = "ipheth",
542 .probe = ipheth_probe,
543 .disconnect = ipheth_disconnect,
544 .id_table = ipheth_table,
545};
546
547static int __init ipheth_init(void)
548{
549 int retval;
550
551 retval = usb_register(&ipheth_driver);
552 if (retval) {
553 err("usb_register failed: %d", retval);
554 return retval;
555 }
556 return 0;
557}
558
559static void __exit ipheth_exit(void)
560{
561 usb_deregister(&ipheth_driver);
562}
563
564module_init(ipheth_init);
565module_exit(ipheth_exit);
566
567MODULE_AUTHOR("Diego Giagio <diego@giagio.com>");
568MODULE_DESCRIPTION("Apple iPhone USB Ethernet driver");
569MODULE_LICENSE("Dual BSD/GPL");
diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c
index 52671ea043a..c4c334d9770 100644
--- a/drivers/net/usb/kaweth.c
+++ b/drivers/net/usb/kaweth.c
@@ -145,6 +145,7 @@ static struct usb_device_id usb_klsi_table[] = {
145 { USB_DEVICE(0x0707, 0x0100) }, /* SMC 2202USB */ 145 { USB_DEVICE(0x0707, 0x0100) }, /* SMC 2202USB */
146 { USB_DEVICE(0x07aa, 0x0001) }, /* Correga K.K. */ 146 { USB_DEVICE(0x07aa, 0x0001) }, /* Correga K.K. */
147 { USB_DEVICE(0x07b8, 0x4000) }, /* D-Link DU-E10 */ 147 { USB_DEVICE(0x07b8, 0x4000) }, /* D-Link DU-E10 */
148 { USB_DEVICE(0x07c9, 0xb010) }, /* Allied Telesyn AT-USB10 USB Ethernet Adapter */
148 { USB_DEVICE(0x0846, 0x1001) }, /* NetGear EA-101 */ 149 { USB_DEVICE(0x0846, 0x1001) }, /* NetGear EA-101 */
149 { USB_DEVICE(0x0846, 0x1002) }, /* NetGear EA-101 */ 150 { USB_DEVICE(0x0846, 0x1002) }, /* NetGear EA-101 */
150 { USB_DEVICE(0x085a, 0x0008) }, /* PortGear Ethernet Adapter */ 151 { USB_DEVICE(0x085a, 0x0008) }, /* PortGear Ethernet Adapter */
diff --git a/drivers/net/usb/mcs7830.c b/drivers/net/usb/mcs7830.c
index 70978219e98..9f24e3f871e 100644
--- a/drivers/net/usb/mcs7830.c
+++ b/drivers/net/usb/mcs7830.c
@@ -44,6 +44,7 @@
44#include <linux/mii.h> 44#include <linux/mii.h>
45#include <linux/module.h> 45#include <linux/module.h>
46#include <linux/netdevice.h> 46#include <linux/netdevice.h>
47#include <linux/slab.h>
47#include <linux/usb.h> 48#include <linux/usb.h>
48#include <linux/usb/usbnet.h> 49#include <linux/usb/usbnet.h>
49 50
diff --git a/drivers/net/usb/net1080.c b/drivers/net/usb/net1080.c
index bdcad45954a..961a8ed38d8 100644
--- a/drivers/net/usb/net1080.c
+++ b/drivers/net/usb/net1080.c
@@ -29,6 +29,7 @@
29#include <linux/mii.h> 29#include <linux/mii.h>
30#include <linux/usb.h> 30#include <linux/usb.h>
31#include <linux/usb/usbnet.h> 31#include <linux/usb/usbnet.h>
32#include <linux/slab.h>
32 33
33#include <asm/unaligned.h> 34#include <asm/unaligned.h>
34 35
diff --git a/drivers/net/usb/rndis_host.c b/drivers/net/usb/rndis_host.c
index 4ce331fb1e1..dd8a4adf48c 100644
--- a/drivers/net/usb/rndis_host.c
+++ b/drivers/net/usb/rndis_host.c
@@ -22,6 +22,7 @@
22#include <linux/etherdevice.h> 22#include <linux/etherdevice.h>
23#include <linux/ethtool.h> 23#include <linux/ethtool.h>
24#include <linux/workqueue.h> 24#include <linux/workqueue.h>
25#include <linux/slab.h>
25#include <linux/mii.h> 26#include <linux/mii.h>
26#include <linux/usb.h> 27#include <linux/usb.h>
27#include <linux/usb/cdc.h> 28#include <linux/usb/cdc.h>
diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
new file mode 100644
index 00000000000..f1942d69a0d
--- /dev/null
+++ b/drivers/net/usb/sierra_net.c
@@ -0,0 +1,1004 @@
1/*
2 * USB-to-WWAN Driver for Sierra Wireless modems
3 *
4 * Copyright (C) 2008, 2009, 2010 Paxton Smith, Matthew Safar, Rory Filer
5 * <linux@sierrawireless.com>
6 *
7 * Portions of this based on the cdc_ether driver by David Brownell (2003-2005)
8 * and Ole Andre Vadla Ravnas (ActiveSync) (2006).
9 *
10 * IMPORTANT DISCLAIMER: This driver is not commercially supported by
11 * Sierra Wireless. Use at your own risk.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 */
27
28#define DRIVER_VERSION "v.2.0"
29#define DRIVER_AUTHOR "Paxton Smith, Matthew Safar, Rory Filer"
30#define DRIVER_DESC "USB-to-WWAN Driver for Sierra Wireless modems"
31static const char driver_name[] = "sierra_net";
32
33/* if defined debug messages enabled */
34/*#define DEBUG*/
35
36#include <linux/module.h>
37#include <linux/etherdevice.h>
38#include <linux/ethtool.h>
39#include <linux/mii.h>
40#include <linux/sched.h>
41#include <linux/timer.h>
42#include <linux/usb.h>
43#include <linux/usb/cdc.h>
44#include <net/ip.h>
45#include <net/udp.h>
46#include <asm/unaligned.h>
47#include <linux/usb/usbnet.h>
48
49#define SWI_USB_REQUEST_GET_FW_ATTR 0x06
50#define SWI_GET_FW_ATTR_MASK 0x08
51
52/* atomic counter partially included in MAC address to make sure 2 devices
53 * do not end up with the same MAC - concept breaks in case of > 255 ifaces
54 */
55static atomic_t iface_counter = ATOMIC_INIT(0);
56
57/*
58 * SYNC Timer Delay definition used to set the expiry time
59 */
60#define SIERRA_NET_SYNCDELAY (2*HZ)
61
62/* Max. MTU supported. The modem buffers are limited to 1500 */
63#define SIERRA_NET_MAX_SUPPORTED_MTU 1500
64
65/* The SIERRA_NET_USBCTL_BUF_LEN defines a buffer size allocated for control
66 * message reception ... and thus the max. received packet.
67 * (May be the cause for parse_hip returning -EINVAL)
68 */
69#define SIERRA_NET_USBCTL_BUF_LEN 1024
70
71/* list of interface numbers - used for constructing interface lists */
72struct sierra_net_iface_info {
73 const u32 infolen; /* number of interface numbers on list */
74 const u8 *ifaceinfo; /* pointer to the array holding the numbers */
75};
76
77struct sierra_net_info_data {
78 u16 rx_urb_size;
79 struct sierra_net_iface_info whitelist;
80};
81
82/* Private data structure */
83struct sierra_net_data {
84
85 u8 ethr_hdr_tmpl[ETH_HLEN]; /* ethernet header template for rx'd pkts */
86
87 u16 link_up; /* air link up or down */
88 u8 tx_hdr_template[4]; /* part of HIP hdr for tx'd packets */
89
90 u8 sync_msg[4]; /* SYNC message */
91 u8 shdwn_msg[4]; /* Shutdown message */
92
93 /* Backpointer to the container */
94 struct usbnet *usbnet;
95
96 u8 ifnum; /* interface number */
97
98/* Bit masks, must be a power of 2 */
99#define SIERRA_NET_EVENT_RESP_AVAIL 0x01
100#define SIERRA_NET_TIMER_EXPIRY 0x02
101 unsigned long kevent_flags;
102 struct work_struct sierra_net_kevent;
103 struct timer_list sync_timer; /* For retrying SYNC sequence */
104};
105
106struct param {
107 int is_present;
108 union {
109 void *ptr;
110 u32 dword;
111 u16 word;
112 u8 byte;
113 };
114};
115
116/* HIP message type */
117#define SIERRA_NET_HIP_EXTENDEDID 0x7F
118#define SIERRA_NET_HIP_HSYNC_ID 0x60 /* Modem -> host */
119#define SIERRA_NET_HIP_RESTART_ID 0x62 /* Modem -> host */
120#define SIERRA_NET_HIP_MSYNC_ID 0x20 /* Host -> modem */
121#define SIERRA_NET_HIP_SHUTD_ID 0x26 /* Host -> modem */
122
123#define SIERRA_NET_HIP_EXT_IP_IN_ID 0x0202
124#define SIERRA_NET_HIP_EXT_IP_OUT_ID 0x0002
125
126/* 3G UMTS Link Sense Indication definitions */
127#define SIERRA_NET_HIP_LSI_UMTSID 0x78
128
129/* Reverse Channel Grant Indication HIP message */
130#define SIERRA_NET_HIP_RCGI 0x64
131
132/* LSI Protocol types */
133#define SIERRA_NET_PROTOCOL_UMTS 0x01
134/* LSI Coverage */
135#define SIERRA_NET_COVERAGE_NONE 0x00
136#define SIERRA_NET_COVERAGE_NOPACKET 0x01
137
138/* LSI Session */
139#define SIERRA_NET_SESSION_IDLE 0x00
140/* LSI Link types */
141#define SIERRA_NET_AS_LINK_TYPE_IPv4 0x00
142
143struct lsi_umts {
144 u8 protocol;
145 u8 unused1;
146 __be16 length;
147 /* eventually use a union for the rest - assume umts for now */
148 u8 coverage;
149 u8 unused2[41];
150 u8 session_state;
151 u8 unused3[33];
152 u8 link_type;
153 u8 pdp_addr_len; /* NW-supplied PDP address len */
154 u8 pdp_addr[16]; /* NW-supplied PDP address (bigendian)) */
155 u8 unused4[23];
156 u8 dns1_addr_len; /* NW-supplied 1st DNS address len (bigendian) */
157 u8 dns1_addr[16]; /* NW-supplied 1st DNS address */
158 u8 dns2_addr_len; /* NW-supplied 2nd DNS address len */
159 u8 dns2_addr[16]; /* NW-supplied 2nd DNS address (bigendian)*/
160 u8 wins1_addr_len; /* NW-supplied 1st Wins address len */
161 u8 wins1_addr[16]; /* NW-supplied 1st Wins address (bigendian)*/
162 u8 wins2_addr_len; /* NW-supplied 2nd Wins address len */
163 u8 wins2_addr[16]; /* NW-supplied 2nd Wins address (bigendian) */
164 u8 unused5[4];
165 u8 gw_addr_len; /* NW-supplied GW address len */
166 u8 gw_addr[16]; /* NW-supplied GW address (bigendian) */
167 u8 reserved[8];
168} __attribute__ ((packed));
169
170#define SIERRA_NET_LSI_COMMON_LEN 4
171#define SIERRA_NET_LSI_UMTS_LEN (sizeof(struct lsi_umts))
172#define SIERRA_NET_LSI_UMTS_STATUS_LEN \
173 (SIERRA_NET_LSI_UMTS_LEN - SIERRA_NET_LSI_COMMON_LEN)
174
175/* Forward definitions */
176static void sierra_sync_timer(unsigned long syncdata);
177static int sierra_net_change_mtu(struct net_device *net, int new_mtu);
178
179/* Our own net device operations structure */
180static const struct net_device_ops sierra_net_device_ops = {
181 .ndo_open = usbnet_open,
182 .ndo_stop = usbnet_stop,
183 .ndo_start_xmit = usbnet_start_xmit,
184 .ndo_tx_timeout = usbnet_tx_timeout,
185 .ndo_change_mtu = sierra_net_change_mtu,
186 .ndo_set_mac_address = eth_mac_addr,
187 .ndo_validate_addr = eth_validate_addr,
188};
189
190/* get private data associated with passed in usbnet device */
191static inline struct sierra_net_data *sierra_net_get_private(struct usbnet *dev)
192{
193 return (struct sierra_net_data *)dev->data[0];
194}
195
196/* set private data associated with passed in usbnet device */
197static inline void sierra_net_set_private(struct usbnet *dev,
198 struct sierra_net_data *priv)
199{
200 dev->data[0] = (unsigned long)priv;
201}
202
203/* is packet IPv4 */
204static inline int is_ip(struct sk_buff *skb)
205{
206 return (skb->protocol == cpu_to_be16(ETH_P_IP));
207}
208
209/*
210 * check passed in packet and make sure that:
211 * - it is linear (no scatter/gather)
212 * - it is ethernet (mac_header properly set)
213 */
214static int check_ethip_packet(struct sk_buff *skb, struct usbnet *dev)
215{
216 skb_reset_mac_header(skb); /* ethernet header */
217
218 if (skb_is_nonlinear(skb)) {
219 netdev_err(dev->net, "Non linear buffer-dropping\n");
220 return 0;
221 }
222
223 if (!pskb_may_pull(skb, ETH_HLEN))
224 return 0;
225 skb->protocol = eth_hdr(skb)->h_proto;
226
227 return 1;
228}
229
230static const u8 *save16bit(struct param *p, const u8 *datap)
231{
232 p->is_present = 1;
233 p->word = get_unaligned_be16(datap);
234 return datap + sizeof(p->word);
235}
236
237static const u8 *save8bit(struct param *p, const u8 *datap)
238{
239 p->is_present = 1;
240 p->byte = *datap;
241 return datap + sizeof(p->byte);
242}
243
244/*----------------------------------------------------------------------------*
245 * BEGIN HIP *
246 *----------------------------------------------------------------------------*/
247/* HIP header */
248#define SIERRA_NET_HIP_HDR_LEN 4
249/* Extended HIP header */
250#define SIERRA_NET_HIP_EXT_HDR_LEN 6
251
252struct hip_hdr {
253 int hdrlen;
254 struct param payload_len;
255 struct param msgid;
256 struct param msgspecific;
257 struct param extmsgid;
258};
259
260static int parse_hip(const u8 *buf, const u32 buflen, struct hip_hdr *hh)
261{
262 const u8 *curp = buf;
263 int padded;
264
265 if (buflen < SIERRA_NET_HIP_HDR_LEN)
266 return -EPROTO;
267
268 curp = save16bit(&hh->payload_len, curp);
269 curp = save8bit(&hh->msgid, curp);
270 curp = save8bit(&hh->msgspecific, curp);
271
272 padded = hh->msgid.byte & 0x80;
273 hh->msgid.byte &= 0x7F; /* 7 bits */
274
275 hh->extmsgid.is_present = (hh->msgid.byte == SIERRA_NET_HIP_EXTENDEDID);
276 if (hh->extmsgid.is_present) {
277 if (buflen < SIERRA_NET_HIP_EXT_HDR_LEN)
278 return -EPROTO;
279
280 hh->payload_len.word &= 0x3FFF; /* 14 bits */
281
282 curp = save16bit(&hh->extmsgid, curp);
283 hh->extmsgid.word &= 0x03FF; /* 10 bits */
284
285 hh->hdrlen = SIERRA_NET_HIP_EXT_HDR_LEN;
286 } else {
287 hh->payload_len.word &= 0x07FF; /* 11 bits */
288 hh->hdrlen = SIERRA_NET_HIP_HDR_LEN;
289 }
290
291 if (padded) {
292 hh->hdrlen++;
293 hh->payload_len.word--;
294 }
295
296 /* if real packet shorter than the claimed length */
297 if (buflen < (hh->hdrlen + hh->payload_len.word))
298 return -EINVAL;
299
300 return 0;
301}
302
303static void build_hip(u8 *buf, const u16 payloadlen,
304 struct sierra_net_data *priv)
305{
306 /* the following doesn't have the full functionality. We
307 * currently build only one kind of header, so it is faster this way
308 */
309 put_unaligned_be16(payloadlen, buf);
310 memcpy(buf+2, priv->tx_hdr_template, sizeof(priv->tx_hdr_template));
311}
312/*----------------------------------------------------------------------------*
313 * END HIP *
314 *----------------------------------------------------------------------------*/
315
316static int sierra_net_send_cmd(struct usbnet *dev,
317 u8 *cmd, int cmdlen, const char * cmd_name)
318{
319 struct sierra_net_data *priv = sierra_net_get_private(dev);
320 int status;
321
322 status = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0),
323 USB_CDC_SEND_ENCAPSULATED_COMMAND,
324 USB_DIR_OUT|USB_TYPE_CLASS|USB_RECIP_INTERFACE, 0,
325 priv->ifnum, cmd, cmdlen, USB_CTRL_SET_TIMEOUT);
326
327 if (status != cmdlen && status != -ENODEV)
328 netdev_err(dev->net, "Submit %s failed %d\n", cmd_name, status);
329
330 return status;
331}
332
333static int sierra_net_send_sync(struct usbnet *dev)
334{
335 int status;
336 struct sierra_net_data *priv = sierra_net_get_private(dev);
337
338 dev_dbg(&dev->udev->dev, "%s", __func__);
339
340 status = sierra_net_send_cmd(dev, priv->sync_msg,
341 sizeof(priv->sync_msg), "SYNC");
342
343 return status;
344}
345
346static void sierra_net_set_ctx_index(struct sierra_net_data *priv, u8 ctx_ix)
347{
348 dev_dbg(&(priv->usbnet->udev->dev), "%s %d", __func__, ctx_ix);
349 priv->tx_hdr_template[0] = 0x3F;
350 priv->tx_hdr_template[1] = ctx_ix;
351 *((u16 *)&priv->tx_hdr_template[2]) =
352 cpu_to_be16(SIERRA_NET_HIP_EXT_IP_OUT_ID);
353}
354
355static inline int sierra_net_is_valid_addrlen(u8 len)
356{
357 return (len == sizeof(struct in_addr));
358}
359
360static int sierra_net_parse_lsi(struct usbnet *dev, char *data, int datalen)
361{
362 struct lsi_umts *lsi = (struct lsi_umts *)data;
363
364 if (datalen < sizeof(struct lsi_umts)) {
365 netdev_err(dev->net, "%s: Data length %d, exp %Zu\n",
366 __func__, datalen,
367 sizeof(struct lsi_umts));
368 return -1;
369 }
370
371 if (lsi->length != cpu_to_be16(SIERRA_NET_LSI_UMTS_STATUS_LEN)) {
372 netdev_err(dev->net, "%s: LSI_UMTS_STATUS_LEN %d, exp %u\n",
373 __func__, be16_to_cpu(lsi->length),
374 (u32)SIERRA_NET_LSI_UMTS_STATUS_LEN);
375 return -1;
376 }
377
378 /* Validate the protocol - only support UMTS for now */
379 if (lsi->protocol != SIERRA_NET_PROTOCOL_UMTS) {
380 netdev_err(dev->net, "Protocol unsupported, 0x%02x\n",
381 lsi->protocol);
382 return -1;
383 }
384
385 /* Validate the link type */
386 if (lsi->link_type != SIERRA_NET_AS_LINK_TYPE_IPv4) {
387 netdev_err(dev->net, "Link type unsupported: 0x%02x\n",
388 lsi->link_type);
389 return -1;
390 }
391
392 /* Validate the coverage */
393 if (lsi->coverage == SIERRA_NET_COVERAGE_NONE
394 || lsi->coverage == SIERRA_NET_COVERAGE_NOPACKET) {
395 netdev_err(dev->net, "No coverage, 0x%02x\n", lsi->coverage);
396 return 0;
397 }
398
399 /* Validate the session state */
400 if (lsi->session_state == SIERRA_NET_SESSION_IDLE) {
401 netdev_err(dev->net, "Session idle, 0x%02x\n",
402 lsi->session_state);
403 return 0;
404 }
405
406 /* Set link_sense true */
407 return 1;
408}
409
410static void sierra_net_handle_lsi(struct usbnet *dev, char *data,
411 struct hip_hdr *hh)
412{
413 struct sierra_net_data *priv = sierra_net_get_private(dev);
414 int link_up;
415
416 link_up = sierra_net_parse_lsi(dev, data + hh->hdrlen,
417 hh->payload_len.word);
418 if (link_up < 0) {
419 netdev_err(dev->net, "Invalid LSI\n");
420 return;
421 }
422 if (link_up) {
423 sierra_net_set_ctx_index(priv, hh->msgspecific.byte);
424 priv->link_up = 1;
425 netif_carrier_on(dev->net);
426 } else {
427 priv->link_up = 0;
428 netif_carrier_off(dev->net);
429 }
430}
431
432static void sierra_net_dosync(struct usbnet *dev)
433{
434 int status;
435 struct sierra_net_data *priv = sierra_net_get_private(dev);
436
437 dev_dbg(&dev->udev->dev, "%s", __func__);
438
439 /* tell modem we are ready */
440 status = sierra_net_send_sync(dev);
441 if (status < 0)
442 netdev_err(dev->net,
443 "Send SYNC failed, status %d\n", status);
444 status = sierra_net_send_sync(dev);
445 if (status < 0)
446 netdev_err(dev->net,
447 "Send SYNC failed, status %d\n", status);
448
449 /* Now, start a timer and make sure we get the Restart Indication */
450 priv->sync_timer.function = sierra_sync_timer;
451 priv->sync_timer.data = (unsigned long) dev;
452 priv->sync_timer.expires = jiffies + SIERRA_NET_SYNCDELAY;
453 add_timer(&priv->sync_timer);
454}
455
456static void sierra_net_kevent(struct work_struct *work)
457{
458 struct sierra_net_data *priv =
459 container_of(work, struct sierra_net_data, sierra_net_kevent);
460 struct usbnet *dev = priv->usbnet;
461 int len;
462 int err;
463 u8 *buf;
464 u8 ifnum;
465
466 if (test_bit(SIERRA_NET_EVENT_RESP_AVAIL, &priv->kevent_flags)) {
467 clear_bit(SIERRA_NET_EVENT_RESP_AVAIL, &priv->kevent_flags);
468
469 /* Query the modem for the LSI message */
470 buf = kzalloc(SIERRA_NET_USBCTL_BUF_LEN, GFP_KERNEL);
471 if (!buf) {
472 netdev_err(dev->net,
473 "failed to allocate buf for LS msg\n");
474 return;
475 }
476 ifnum = priv->ifnum;
477 len = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0),
478 USB_CDC_GET_ENCAPSULATED_RESPONSE,
479 USB_DIR_IN|USB_TYPE_CLASS|USB_RECIP_INTERFACE,
480 0, ifnum, buf, SIERRA_NET_USBCTL_BUF_LEN,
481 USB_CTRL_SET_TIMEOUT);
482
483 if (len < 0) {
484 netdev_err(dev->net,
485 "usb_control_msg failed, status %d\n", len);
486 } else {
487 struct hip_hdr hh;
488
489 dev_dbg(&dev->udev->dev, "%s: Received status message,"
490 " %04x bytes", __func__, len);
491
492 err = parse_hip(buf, len, &hh);
493 if (err) {
494 netdev_err(dev->net, "%s: Bad packet,"
495 " parse result %d\n", __func__, err);
496 kfree(buf);
497 return;
498 }
499
500 /* Validate packet length */
501 if (len != hh.hdrlen + hh.payload_len.word) {
502 netdev_err(dev->net, "%s: Bad packet, received"
503 " %d, expected %d\n", __func__, len,
504 hh.hdrlen + hh.payload_len.word);
505 kfree(buf);
506 return;
507 }
508
509 /* Switch on received message types */
510 switch (hh.msgid.byte) {
511 case SIERRA_NET_HIP_LSI_UMTSID:
512 dev_dbg(&dev->udev->dev, "LSI for ctx:%d",
513 hh.msgspecific.byte);
514 sierra_net_handle_lsi(dev, buf, &hh);
515 break;
516 case SIERRA_NET_HIP_RESTART_ID:
517 dev_dbg(&dev->udev->dev, "Restart reported: %d,"
518 " stopping sync timer",
519 hh.msgspecific.byte);
520 /* Got sync resp - stop timer & clear mask */
521 del_timer_sync(&priv->sync_timer);
522 clear_bit(SIERRA_NET_TIMER_EXPIRY,
523 &priv->kevent_flags);
524 break;
525 case SIERRA_NET_HIP_HSYNC_ID:
526 dev_dbg(&dev->udev->dev, "SYNC received");
527 err = sierra_net_send_sync(dev);
528 if (err < 0)
529 netdev_err(dev->net,
530 "Send SYNC failed %d\n", err);
531 break;
532 case SIERRA_NET_HIP_EXTENDEDID:
533 netdev_err(dev->net, "Unrecognized HIP msg, "
534 "extmsgid 0x%04x\n", hh.extmsgid.word);
535 break;
536 case SIERRA_NET_HIP_RCGI:
537 /* Ignored */
538 break;
539 default:
540 netdev_err(dev->net, "Unrecognized HIP msg, "
541 "msgid 0x%02x\n", hh.msgid.byte);
542 break;
543 }
544 }
545 kfree(buf);
546 }
547 /* The sync timer bit might be set */
548 if (test_bit(SIERRA_NET_TIMER_EXPIRY, &priv->kevent_flags)) {
549 clear_bit(SIERRA_NET_TIMER_EXPIRY, &priv->kevent_flags);
550 dev_dbg(&dev->udev->dev, "Deferred sync timer expiry");
551 sierra_net_dosync(priv->usbnet);
552 }
553
554 if (priv->kevent_flags)
555 dev_dbg(&dev->udev->dev, "sierra_net_kevent done, "
556 "kevent_flags = 0x%lx", priv->kevent_flags);
557}
558
559static void sierra_net_defer_kevent(struct usbnet *dev, int work)
560{
561 struct sierra_net_data *priv = sierra_net_get_private(dev);
562
563 set_bit(work, &priv->kevent_flags);
564 schedule_work(&priv->sierra_net_kevent);
565}
566
567/*
568 * Sync Retransmit Timer Handler. On expiry, kick the work queue
569 */
570void sierra_sync_timer(unsigned long syncdata)
571{
572 struct usbnet *dev = (struct usbnet *)syncdata;
573
574 dev_dbg(&dev->udev->dev, "%s", __func__);
575 /* Kick the tasklet */
576 sierra_net_defer_kevent(dev, SIERRA_NET_TIMER_EXPIRY);
577}
578
579static void sierra_net_status(struct usbnet *dev, struct urb *urb)
580{
581 struct usb_cdc_notification *event;
582
583 dev_dbg(&dev->udev->dev, "%s", __func__);
584
585 if (urb->actual_length < sizeof *event)
586 return;
587
588 /* Add cases to handle other standard notifications. */
589 event = urb->transfer_buffer;
590 switch (event->bNotificationType) {
591 case USB_CDC_NOTIFY_NETWORK_CONNECTION:
592 case USB_CDC_NOTIFY_SPEED_CHANGE:
593 /* USB 305 sends those */
594 break;
595 case USB_CDC_NOTIFY_RESPONSE_AVAILABLE:
596 sierra_net_defer_kevent(dev, SIERRA_NET_EVENT_RESP_AVAIL);
597 break;
598 default:
599 netdev_err(dev->net, ": unexpected notification %02x!\n",
600 event->bNotificationType);
601 break;
602 }
603}
604
605static void sierra_net_get_drvinfo(struct net_device *net,
606 struct ethtool_drvinfo *info)
607{
608 /* Inherit standard device info */
609 usbnet_get_drvinfo(net, info);
610 strncpy(info->driver, driver_name, sizeof info->driver);
611 strncpy(info->version, DRIVER_VERSION, sizeof info->version);
612}
613
614static u32 sierra_net_get_link(struct net_device *net)
615{
616 struct usbnet *dev = netdev_priv(net);
617 /* Report link is down whenever the interface is down */
618 return sierra_net_get_private(dev)->link_up && netif_running(net);
619}
620
621static struct ethtool_ops sierra_net_ethtool_ops = {
622 .get_drvinfo = sierra_net_get_drvinfo,
623 .get_link = sierra_net_get_link,
624 .get_msglevel = usbnet_get_msglevel,
625 .set_msglevel = usbnet_set_msglevel,
626 .get_settings = usbnet_get_settings,
627 .set_settings = usbnet_set_settings,
628 .nway_reset = usbnet_nway_reset,
629};
630
631/* MTU can not be more than 1500 bytes, enforce it. */
632static int sierra_net_change_mtu(struct net_device *net, int new_mtu)
633{
634 if (new_mtu > SIERRA_NET_MAX_SUPPORTED_MTU)
635 return -EINVAL;
636
637 return usbnet_change_mtu(net, new_mtu);
638}
639
640static int is_whitelisted(const u8 ifnum,
641 const struct sierra_net_iface_info *whitelist)
642{
643 if (whitelist) {
644 const u8 *list = whitelist->ifaceinfo;
645 int i;
646
647 for (i = 0; i < whitelist->infolen; i++) {
648 if (list[i] == ifnum)
649 return 1;
650 }
651 }
652 return 0;
653}
654
655static int sierra_net_get_fw_attr(struct usbnet *dev, u16 *datap)
656{
657 int result = 0;
658 u16 *attrdata;
659
660 attrdata = kmalloc(sizeof(*attrdata), GFP_KERNEL);
661 if (!attrdata)
662 return -ENOMEM;
663
664 result = usb_control_msg(
665 dev->udev,
666 usb_rcvctrlpipe(dev->udev, 0),
667 /* _u8 vendor specific request */
668 SWI_USB_REQUEST_GET_FW_ATTR,
669 USB_DIR_IN | USB_TYPE_VENDOR, /* __u8 request type */
670 0x0000, /* __u16 value not used */
671 0x0000, /* __u16 index not used */
672 attrdata, /* char *data */
673 sizeof(*attrdata), /* __u16 size */
674 USB_CTRL_SET_TIMEOUT); /* int timeout */
675
676 if (result < 0) {
677 kfree(attrdata);
678 return -EIO;
679 }
680
681 *datap = *attrdata;
682
683 kfree(attrdata);
684 return result;
685}
686
687/*
688 * collects the bulk endpoints, the status endpoint.
689 */
690static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
691{
692 u8 ifacenum;
693 u8 numendpoints;
694 u16 fwattr = 0;
695 int status;
696 struct ethhdr *eth;
697 struct sierra_net_data *priv;
698 static const u8 sync_tmplate[sizeof(priv->sync_msg)] = {
699 0x00, 0x00, SIERRA_NET_HIP_MSYNC_ID, 0x00};
700 static const u8 shdwn_tmplate[sizeof(priv->shdwn_msg)] = {
701 0x00, 0x00, SIERRA_NET_HIP_SHUTD_ID, 0x00};
702
703 struct sierra_net_info_data *data =
704 (struct sierra_net_info_data *)dev->driver_info->data;
705
706 dev_dbg(&dev->udev->dev, "%s", __func__);
707
708 ifacenum = intf->cur_altsetting->desc.bInterfaceNumber;
709 /* We only accept certain interfaces */
710 if (!is_whitelisted(ifacenum, &data->whitelist)) {
711 dev_dbg(&dev->udev->dev, "Ignoring interface: %d", ifacenum);
712 return -ENODEV;
713 }
714 numendpoints = intf->cur_altsetting->desc.bNumEndpoints;
715 /* We have three endpoints, bulk in and out, and a status */
716 if (numendpoints != 3) {
717 dev_err(&dev->udev->dev, "Expected 3 endpoints, found: %d",
718 numendpoints);
719 return -ENODEV;
720 }
721 /* Status endpoint set in usbnet_get_endpoints() */
722 dev->status = NULL;
723 status = usbnet_get_endpoints(dev, intf);
724 if (status < 0) {
725 dev_err(&dev->udev->dev, "Error in usbnet_get_endpoints (%d)",
726 status);
727 return -ENODEV;
728 }
729 /* Initialize sierra private data */
730 priv = kzalloc(sizeof *priv, GFP_KERNEL);
731 if (!priv) {
732 dev_err(&dev->udev->dev, "No memory");
733 return -ENOMEM;
734 }
735
736 priv->usbnet = dev;
737 priv->ifnum = ifacenum;
738 dev->net->netdev_ops = &sierra_net_device_ops;
739
740 /* change MAC addr to include, ifacenum, and to be unique */
741 dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter);
742 dev->net->dev_addr[ETH_ALEN-1] = ifacenum;
743
744 /* we will have to manufacture ethernet headers, prepare template */
745 eth = (struct ethhdr *)priv->ethr_hdr_tmpl;
746 memcpy(&eth->h_dest, dev->net->dev_addr, ETH_ALEN);
747 eth->h_proto = cpu_to_be16(ETH_P_IP);
748
749 /* prepare shutdown message template */
750 memcpy(priv->shdwn_msg, shdwn_tmplate, sizeof(priv->shdwn_msg));
751 /* set context index initially to 0 - prepares tx hdr template */
752 sierra_net_set_ctx_index(priv, 0);
753
754 /* decrease the rx_urb_size and max_tx_size to 4k on USB 1.1 */
755 dev->rx_urb_size = data->rx_urb_size;
756 if (dev->udev->speed != USB_SPEED_HIGH)
757 dev->rx_urb_size = min_t(size_t, 4096, data->rx_urb_size);
758
759 dev->net->hard_header_len += SIERRA_NET_HIP_EXT_HDR_LEN;
760 dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len;
761
762 /* Set up the netdev */
763 dev->net->flags |= IFF_NOARP;
764 dev->net->ethtool_ops = &sierra_net_ethtool_ops;
765 netif_carrier_off(dev->net);
766
767 sierra_net_set_private(dev, priv);
768
769 priv->kevent_flags = 0;
770
771 /* Use the shared workqueue */
772 INIT_WORK(&priv->sierra_net_kevent, sierra_net_kevent);
773
774 /* Only need to do this once */
775 init_timer(&priv->sync_timer);
776
777 /* verify fw attributes */
778 status = sierra_net_get_fw_attr(dev, &fwattr);
779 dev_dbg(&dev->udev->dev, "Fw attr: %x\n", fwattr);
780
781 /* test whether firmware supports DHCP */
782 if (!(status == sizeof(fwattr) && (fwattr & SWI_GET_FW_ATTR_MASK))) {
783 /* found incompatible firmware version */
784 dev_err(&dev->udev->dev, "Incompatible driver and firmware"
785 " versions\n");
786 kfree(priv);
787 return -ENODEV;
788 }
789 /* prepare sync message from template */
790 memcpy(priv->sync_msg, sync_tmplate, sizeof(priv->sync_msg));
791
792 /* initiate the sync sequence */
793 sierra_net_dosync(dev);
794
795 return 0;
796}
797
798static void sierra_net_unbind(struct usbnet *dev, struct usb_interface *intf)
799{
800 int status;
801 struct sierra_net_data *priv = sierra_net_get_private(dev);
802
803 dev_dbg(&dev->udev->dev, "%s", __func__);
804
805 /* Kill the timer then flush the work queue */
806 del_timer_sync(&priv->sync_timer);
807
808 flush_scheduled_work();
809
810 /* tell modem we are going away */
811 status = sierra_net_send_cmd(dev, priv->shdwn_msg,
812 sizeof(priv->shdwn_msg), "Shutdown");
813 if (status < 0)
814 netdev_err(dev->net,
815 "usb_control_msg failed, status %d\n", status);
816
817 sierra_net_set_private(dev, NULL);
818
819 kfree(priv);
820}
821
822static struct sk_buff *sierra_net_skb_clone(struct usbnet *dev,
823 struct sk_buff *skb, int len)
824{
825 struct sk_buff *new_skb;
826
827 /* clone skb */
828 new_skb = skb_clone(skb, GFP_ATOMIC);
829
830 /* remove len bytes from original */
831 skb_pull(skb, len);
832
833 /* trim next packet to it's length */
834 if (new_skb) {
835 skb_trim(new_skb, len);
836 } else {
837 if (netif_msg_rx_err(dev))
838 netdev_err(dev->net, "failed to get skb\n");
839 dev->net->stats.rx_dropped++;
840 }
841
842 return new_skb;
843}
844
845/* ---------------------------- Receive data path ----------------------*/
846static int sierra_net_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
847{
848 int err;
849 struct hip_hdr hh;
850 struct sk_buff *new_skb;
851
852 dev_dbg(&dev->udev->dev, "%s", __func__);
853
854 /* could contain multiple packets */
855 while (likely(skb->len)) {
856 err = parse_hip(skb->data, skb->len, &hh);
857 if (err) {
858 if (netif_msg_rx_err(dev))
859 netdev_err(dev->net, "Invalid HIP header %d\n",
860 err);
861 /* dev->net->stats.rx_errors incremented by caller */
862 dev->net->stats.rx_length_errors++;
863 return 0;
864 }
865
866 /* Validate Extended HIP header */
867 if (!hh.extmsgid.is_present
868 || hh.extmsgid.word != SIERRA_NET_HIP_EXT_IP_IN_ID) {
869 if (netif_msg_rx_err(dev))
870 netdev_err(dev->net, "HIP/ETH: Invalid pkt\n");
871
872 dev->net->stats.rx_frame_errors++;
873 /* dev->net->stats.rx_errors incremented by caller */;
874 return 0;
875 }
876
877 skb_pull(skb, hh.hdrlen);
878
879 /* We are going to accept this packet, prepare it */
880 memcpy(skb->data, sierra_net_get_private(dev)->ethr_hdr_tmpl,
881 ETH_HLEN);
882
883 /* Last packet in batch handled by usbnet */
884 if (hh.payload_len.word == skb->len)
885 return 1;
886
887 new_skb = sierra_net_skb_clone(dev, skb, hh.payload_len.word);
888 if (new_skb)
889 usbnet_skb_return(dev, new_skb);
890
891 } /* while */
892
893 return 0;
894}
895
896/* ---------------------------- Transmit data path ----------------------*/
897struct sk_buff *sierra_net_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
898 gfp_t flags)
899{
900 struct sierra_net_data *priv = sierra_net_get_private(dev);
901 u16 len;
902 bool need_tail;
903
904 dev_dbg(&dev->udev->dev, "%s", __func__);
905 if (priv->link_up && check_ethip_packet(skb, dev) && is_ip(skb)) {
906 /* enough head room as is? */
907 if (SIERRA_NET_HIP_EXT_HDR_LEN <= skb_headroom(skb)) {
908 /* Save the Eth/IP length and set up HIP hdr */
909 len = skb->len;
910 skb_push(skb, SIERRA_NET_HIP_EXT_HDR_LEN);
911 /* Handle ZLP issue */
912 need_tail = ((len + SIERRA_NET_HIP_EXT_HDR_LEN)
913 % dev->maxpacket == 0);
914 if (need_tail) {
915 if (unlikely(skb_tailroom(skb) == 0)) {
916 netdev_err(dev->net, "tx_fixup:"
917 "no room for packet\n");
918 dev_kfree_skb_any(skb);
919 return NULL;
920 } else {
921 skb->data[skb->len] = 0;
922 __skb_put(skb, 1);
923 len = len + 1;
924 }
925 }
926 build_hip(skb->data, len, priv);
927 return skb;
928 } else {
929 /*
930 * compensate in the future if necessary
931 */
932 netdev_err(dev->net, "tx_fixup: no room for HIP\n");
933 } /* headroom */
934 }
935
936 if (!priv->link_up)
937 dev->net->stats.tx_carrier_errors++;
938
939 /* tx_dropped incremented by usbnet */
940
941 /* filter the packet out, release it */
942 dev_kfree_skb_any(skb);
943 return NULL;
944}
945
946static const u8 sierra_net_ifnum_list[] = { 7, 10, 11 };
947static const struct sierra_net_info_data sierra_net_info_data_68A3 = {
948 .rx_urb_size = 8 * 1024,
949 .whitelist = {
950 .infolen = ARRAY_SIZE(sierra_net_ifnum_list),
951 .ifaceinfo = sierra_net_ifnum_list
952 }
953};
954
955static const struct driver_info sierra_net_info_68A3 = {
956 .description = "Sierra Wireless USB-to-WWAN Modem",
957 .flags = FLAG_WWAN | FLAG_SEND_ZLP,
958 .bind = sierra_net_bind,
959 .unbind = sierra_net_unbind,
960 .status = sierra_net_status,
961 .rx_fixup = sierra_net_rx_fixup,
962 .tx_fixup = sierra_net_tx_fixup,
963 .data = (unsigned long)&sierra_net_info_data_68A3,
964};
965
966static const struct usb_device_id products[] = {
967 {USB_DEVICE(0x1199, 0x68A3), /* Sierra Wireless USB-to-WWAN modem */
968 .driver_info = (unsigned long) &sierra_net_info_68A3},
969
970 {}, /* last item */
971};
972MODULE_DEVICE_TABLE(usb, products);
973
974/* We are based on usbnet, so let it handle the USB driver specifics */
975static struct usb_driver sierra_net_driver = {
976 .name = "sierra_net",
977 .id_table = products,
978 .probe = usbnet_probe,
979 .disconnect = usbnet_disconnect,
980 .suspend = usbnet_suspend,
981 .resume = usbnet_resume,
982 .no_dynamic_id = 1,
983};
984
985static int __init sierra_net_init(void)
986{
987 BUILD_BUG_ON(FIELD_SIZEOF(struct usbnet, data)
988 < sizeof(struct cdc_state));
989
990 return usb_register(&sierra_net_driver);
991}
992
993static void __exit sierra_net_exit(void)
994{
995 usb_deregister(&sierra_net_driver);
996}
997
998module_exit(sierra_net_exit);
999module_init(sierra_net_init);
1000
1001MODULE_AUTHOR(DRIVER_AUTHOR);
1002MODULE_DESCRIPTION(DRIVER_DESC);
1003MODULE_VERSION(DRIVER_VERSION);
1004MODULE_LICENSE("GPL");
diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index 300e3e764fa..35b98b1b79e 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -28,6 +28,7 @@
28#include <linux/usb.h> 28#include <linux/usb.h>
29#include <linux/crc32.h> 29#include <linux/crc32.h>
30#include <linux/usb/usbnet.h> 30#include <linux/usb/usbnet.h>
31#include <linux/slab.h>
31#include "smsc75xx.h" 32#include "smsc75xx.h"
32 33
33#define SMSC_CHIPNAME "smsc75xx" 34#define SMSC_CHIPNAME "smsc75xx"
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index d222d7e2527..3135af63d37 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -28,6 +28,7 @@
28#include <linux/usb.h> 28#include <linux/usb.h>
29#include <linux/crc32.h> 29#include <linux/crc32.h>
30#include <linux/usb/usbnet.h> 30#include <linux/usb/usbnet.h>
31#include <linux/slab.h>
31#include "smsc95xx.h" 32#include "smsc95xx.h"
32 33
33#define SMSC_CHIPNAME "smsc95xx" 34#define SMSC_CHIPNAME "smsc95xx"
@@ -1189,9 +1190,21 @@ static struct sk_buff *smsc95xx_tx_fixup(struct usbnet *dev,
1189 } 1190 }
1190 1191
1191 if (csum) { 1192 if (csum) {
1192 u32 csum_preamble = smsc95xx_calc_csum_preamble(skb); 1193 if (skb->len <= 45) {
1193 skb_push(skb, 4); 1194 /* workaround - hardware tx checksum does not work
1194 memcpy(skb->data, &csum_preamble, 4); 1195 * properly with extremely small packets */
1196 long csstart = skb->csum_start - skb_headroom(skb);
1197 __wsum calc = csum_partial(skb->data + csstart,
1198 skb->len - csstart, 0);
1199 *((__sum16 *)(skb->data + csstart
1200 + skb->csum_offset)) = csum_fold(calc);
1201
1202 csum = false;
1203 } else {
1204 u32 csum_preamble = smsc95xx_calc_csum_preamble(skb);
1205 skb_push(skb, 4);
1206 memcpy(skb->data, &csum_preamble, 4);
1207 }
1195 } 1208 }
1196 1209
1197 skb_push(skb, 4); 1210 skb_push(skb, 4);
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 17b6a62d206..7177abc78dc 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -43,6 +43,7 @@
43#include <linux/mii.h> 43#include <linux/mii.h>
44#include <linux/usb.h> 44#include <linux/usb.h>
45#include <linux/usb/usbnet.h> 45#include <linux/usb/usbnet.h>
46#include <linux/slab.h>
46 47
47#define DRIVER_VERSION "22-Aug-2005" 48#define DRIVER_VERSION "22-Aug-2005"
48 49
diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index b583d4968ad..f9f0730b53d 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -9,6 +9,7 @@
9 */ 9 */
10 10
11#include <linux/netdevice.h> 11#include <linux/netdevice.h>
12#include <linux/slab.h>
12#include <linux/ethtool.h> 13#include <linux/ethtool.h>
13#include <linux/etherdevice.h> 14#include <linux/etherdevice.h>
14 15
diff --git a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c
index 50f881aa393..388751aa66e 100644
--- a/drivers/net/via-rhine.c
+++ b/drivers/net/via-rhine.c
@@ -89,7 +89,6 @@ static const int multicast_filter_limit = 32;
89#include <linux/timer.h> 89#include <linux/timer.h>
90#include <linux/errno.h> 90#include <linux/errno.h>
91#include <linux/ioport.h> 91#include <linux/ioport.h>
92#include <linux/slab.h>
93#include <linux/interrupt.h> 92#include <linux/interrupt.h>
94#include <linux/pci.h> 93#include <linux/pci.h>
95#include <linux/dma-mapping.h> 94#include <linux/dma-mapping.h>
diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c
index 3a486f3bad3..bc278d4ee89 100644
--- a/drivers/net/via-velocity.c
+++ b/drivers/net/via-velocity.c
@@ -812,7 +812,7 @@ static void set_mii_flow_control(struct velocity_info *vptr)
812 812
813 case FLOW_CNTL_TX_RX: 813 case FLOW_CNTL_TX_RX:
814 MII_REG_BITS_ON(ANAR_PAUSE, MII_REG_ANAR, vptr->mac_regs); 814 MII_REG_BITS_ON(ANAR_PAUSE, MII_REG_ANAR, vptr->mac_regs);
815 MII_REG_BITS_ON(ANAR_ASMDIR, MII_REG_ANAR, vptr->mac_regs); 815 MII_REG_BITS_OFF(ANAR_ASMDIR, MII_REG_ANAR, vptr->mac_regs);
816 break; 816 break;
817 817
818 case FLOW_CNTL_DISABLE: 818 case FLOW_CNTL_DISABLE:
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 25dc77ccbf5..b0577dd1a42 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -25,6 +25,7 @@
25#include <linux/virtio_net.h> 25#include <linux/virtio_net.h>
26#include <linux/scatterlist.h> 26#include <linux/scatterlist.h>
27#include <linux/if_vlan.h> 27#include <linux/if_vlan.h>
28#include <linux/slab.h>
28 29
29static int napi_weight = 128; 30static int napi_weight = 128;
30module_param(napi_weight, int, 0444); 31module_param(napi_weight, int, 0444);
@@ -326,6 +327,7 @@ static int add_recvbuf_small(struct virtnet_info *vi, gfp_t gfp)
326 struct scatterlist sg[2]; 327 struct scatterlist sg[2];
327 int err; 328 int err;
328 329
330 sg_init_table(sg, 2);
329 skb = netdev_alloc_skb_ip_align(vi->dev, MAX_PACKET_LEN); 331 skb = netdev_alloc_skb_ip_align(vi->dev, MAX_PACKET_LEN);
330 if (unlikely(!skb)) 332 if (unlikely(!skb))
331 return -ENOMEM; 333 return -ENOMEM;
@@ -351,6 +353,7 @@ static int add_recvbuf_big(struct virtnet_info *vi, gfp_t gfp)
351 char *p; 353 char *p;
352 int i, err, offset; 354 int i, err, offset;
353 355
356 sg_init_table(sg, MAX_SKB_FRAGS + 2);
354 /* page in sg[MAX_SKB_FRAGS + 1] is list tail */ 357 /* page in sg[MAX_SKB_FRAGS + 1] is list tail */
355 for (i = MAX_SKB_FRAGS + 1; i > 1; --i) { 358 for (i = MAX_SKB_FRAGS + 1; i > 1; --i) {
356 first = get_a_page(vi, gfp); 359 first = get_a_page(vi, gfp);
diff --git a/drivers/net/vxge/vxge-config.c b/drivers/net/vxge/vxge-config.c
index 32a75fa935e..a21a25d218b 100644
--- a/drivers/net/vxge/vxge-config.c
+++ b/drivers/net/vxge/vxge-config.c
@@ -15,6 +15,7 @@
15#include <linux/etherdevice.h> 15#include <linux/etherdevice.h>
16#include <linux/pci.h> 16#include <linux/pci.h>
17#include <linux/pci_hotplug.h> 17#include <linux/pci_hotplug.h>
18#include <linux/slab.h>
18 19
19#include "vxge-traffic.h" 20#include "vxge-traffic.h"
20#include "vxge-config.h" 21#include "vxge-config.h"
diff --git a/drivers/net/vxge/vxge-config.h b/drivers/net/vxge/vxge-config.h
index e7877df092f..13f5416307f 100644
--- a/drivers/net/vxge/vxge-config.h
+++ b/drivers/net/vxge/vxge-config.h
@@ -14,6 +14,7 @@
14#ifndef VXGE_CONFIG_H 14#ifndef VXGE_CONFIG_H
15#define VXGE_CONFIG_H 15#define VXGE_CONFIG_H
16#include <linux/list.h> 16#include <linux/list.h>
17#include <linux/slab.h>
17 18
18#ifndef VXGE_CACHE_LINE_SIZE 19#ifndef VXGE_CACHE_LINE_SIZE
19#define VXGE_CACHE_LINE_SIZE 128 20#define VXGE_CACHE_LINE_SIZE 128
diff --git a/drivers/net/vxge/vxge-ethtool.c b/drivers/net/vxge/vxge-ethtool.c
index c6736b97263..aaf374cfd32 100644
--- a/drivers/net/vxge/vxge-ethtool.c
+++ b/drivers/net/vxge/vxge-ethtool.c
@@ -12,6 +12,7 @@
12 * Copyright(c) 2002-2009 Neterion Inc. 12 * Copyright(c) 2002-2009 Neterion Inc.
13 ******************************************************************************/ 13 ******************************************************************************/
14#include<linux/ethtool.h> 14#include<linux/ethtool.h>
15#include <linux/slab.h>
15#include <linux/pci.h> 16#include <linux/pci.h>
16#include <linux/etherdevice.h> 17#include <linux/etherdevice.h>
17 18
diff --git a/drivers/net/vxge/vxge-main.c b/drivers/net/vxge/vxge-main.c
index 46a7c9e689e..ba6d0da78c3 100644
--- a/drivers/net/vxge/vxge-main.c
+++ b/drivers/net/vxge/vxge-main.c
@@ -43,6 +43,7 @@
43 43
44#include <linux/if_vlan.h> 44#include <linux/if_vlan.h>
45#include <linux/pci.h> 45#include <linux/pci.h>
46#include <linux/slab.h>
46#include <linux/tcp.h> 47#include <linux/tcp.h>
47#include <net/ip.h> 48#include <net/ip.h>
48#include <linux/netdevice.h> 49#include <linux/netdevice.h>
diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c
index f88c07c1319..a4859f7a7cc 100644
--- a/drivers/net/wan/dscc4.c
+++ b/drivers/net/wan/dscc4.c
@@ -89,6 +89,7 @@
89#include <linux/pci.h> 89#include <linux/pci.h>
90#include <linux/kernel.h> 90#include <linux/kernel.h>
91#include <linux/mm.h> 91#include <linux/mm.h>
92#include <linux/slab.h>
92 93
93#include <asm/system.h> 94#include <asm/system.h>
94#include <asm/cache.h> 95#include <asm/cache.h>
diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c
index 40d724a8e02..e087b9a6daa 100644
--- a/drivers/net/wan/farsync.c
+++ b/drivers/net/wan/farsync.c
@@ -20,6 +20,7 @@
20#include <linux/version.h> 20#include <linux/version.h>
21#include <linux/pci.h> 21#include <linux/pci.h>
22#include <linux/sched.h> 22#include <linux/sched.h>
23#include <linux/slab.h>
23#include <linux/ioport.h> 24#include <linux/ioport.h>
24#include <linux/init.h> 25#include <linux/init.h>
25#include <linux/if.h> 26#include <linux/if.h>
diff --git a/drivers/net/wan/hd64570.c b/drivers/net/wan/hd64570.c
index 80114c93bae..4dde2ea4a18 100644
--- a/drivers/net/wan/hd64570.c
+++ b/drivers/net/wan/hd64570.c
@@ -37,7 +37,6 @@
37#include <linux/module.h> 37#include <linux/module.h>
38#include <linux/netdevice.h> 38#include <linux/netdevice.h>
39#include <linux/skbuff.h> 39#include <linux/skbuff.h>
40#include <linux/slab.h>
41#include <linux/string.h> 40#include <linux/string.h>
42#include <linux/types.h> 41#include <linux/types.h>
43#include <asm/io.h> 42#include <asm/io.h>
diff --git a/drivers/net/wan/hd64572.c b/drivers/net/wan/hd64572.c
index 84f01373e11..aad9ed45c25 100644
--- a/drivers/net/wan/hd64572.c
+++ b/drivers/net/wan/hd64572.c
@@ -37,7 +37,6 @@
37#include <linux/module.h> 37#include <linux/module.h>
38#include <linux/netdevice.h> 38#include <linux/netdevice.h>
39#include <linux/skbuff.h> 39#include <linux/skbuff.h>
40#include <linux/slab.h>
41#include <linux/string.h> 40#include <linux/string.h>
42#include <linux/types.h> 41#include <linux/types.h>
43#include <asm/io.h> 42#include <asm/io.h>
diff --git a/drivers/net/wan/hdlc_cisco.c b/drivers/net/wan/hdlc_cisco.c
index 1ceccf1ca6c..ee7083fbea5 100644
--- a/drivers/net/wan/hdlc_cisco.c
+++ b/drivers/net/wan/hdlc_cisco.c
@@ -20,7 +20,6 @@
20#include <linux/poll.h> 20#include <linux/poll.h>
21#include <linux/rtnetlink.h> 21#include <linux/rtnetlink.h>
22#include <linux/skbuff.h> 22#include <linux/skbuff.h>
23#include <linux/slab.h>
24 23
25#undef DEBUG_HARD_HEADER 24#undef DEBUG_HARD_HEADER
26 25
diff --git a/drivers/net/wan/hdlc_ppp.c b/drivers/net/wan/hdlc_ppp.c
index b9b9d6b01c0..941f053e650 100644
--- a/drivers/net/wan/hdlc_ppp.c
+++ b/drivers/net/wan/hdlc_ppp.c
@@ -628,9 +628,15 @@ static void ppp_stop(struct net_device *dev)
628 ppp_cp_event(dev, PID_LCP, STOP, 0, 0, 0, NULL); 628 ppp_cp_event(dev, PID_LCP, STOP, 0, 0, 0, NULL);
629} 629}
630 630
631static void ppp_close(struct net_device *dev)
632{
633 ppp_tx_flush();
634}
635
631static struct hdlc_proto proto = { 636static struct hdlc_proto proto = {
632 .start = ppp_start, 637 .start = ppp_start,
633 .stop = ppp_stop, 638 .stop = ppp_stop,
639 .close = ppp_close,
634 .type_trans = ppp_type_trans, 640 .type_trans = ppp_type_trans,
635 .ioctl = ppp_ioctl, 641 .ioctl = ppp_ioctl,
636 .netif_rx = ppp_rx, 642 .netif_rx = ppp_rx,
diff --git a/drivers/net/wan/hdlc_raw.c b/drivers/net/wan/hdlc_raw.c
index 19f51fdd552..5dc153e8a29 100644
--- a/drivers/net/wan/hdlc_raw.c
+++ b/drivers/net/wan/hdlc_raw.c
@@ -20,7 +20,6 @@
20#include <linux/poll.h> 20#include <linux/poll.h>
21#include <linux/rtnetlink.h> 21#include <linux/rtnetlink.h>
22#include <linux/skbuff.h> 22#include <linux/skbuff.h>
23#include <linux/slab.h>
24 23
25 24
26static int raw_ioctl(struct net_device *dev, struct ifreq *ifr); 25static int raw_ioctl(struct net_device *dev, struct ifreq *ifr);
diff --git a/drivers/net/wan/hdlc_raw_eth.c b/drivers/net/wan/hdlc_raw_eth.c
index 1b30fcc2414..05c9b0b9623 100644
--- a/drivers/net/wan/hdlc_raw_eth.c
+++ b/drivers/net/wan/hdlc_raw_eth.c
@@ -11,6 +11,7 @@
11 11
12#include <linux/errno.h> 12#include <linux/errno.h>
13#include <linux/etherdevice.h> 13#include <linux/etherdevice.h>
14#include <linux/gfp.h>
14#include <linux/hdlc.h> 15#include <linux/hdlc.h>
15#include <linux/if_arp.h> 16#include <linux/if_arp.h>
16#include <linux/inetdevice.h> 17#include <linux/inetdevice.h>
@@ -21,7 +22,6 @@
21#include <linux/poll.h> 22#include <linux/poll.h>
22#include <linux/rtnetlink.h> 23#include <linux/rtnetlink.h>
23#include <linux/skbuff.h> 24#include <linux/skbuff.h>
24#include <linux/slab.h>
25 25
26static int raw_eth_ioctl(struct net_device *dev, struct ifreq *ifr); 26static int raw_eth_ioctl(struct net_device *dev, struct ifreq *ifr);
27 27
diff --git a/drivers/net/wan/hdlc_x25.c b/drivers/net/wan/hdlc_x25.c
index 6e1ca256eff..c7adbb79f7c 100644
--- a/drivers/net/wan/hdlc_x25.c
+++ b/drivers/net/wan/hdlc_x25.c
@@ -10,6 +10,7 @@
10 */ 10 */
11 11
12#include <linux/errno.h> 12#include <linux/errno.h>
13#include <linux/gfp.h>
13#include <linux/hdlc.h> 14#include <linux/hdlc.h>
14#include <linux/if_arp.h> 15#include <linux/if_arp.h>
15#include <linux/inetdevice.h> 16#include <linux/inetdevice.h>
@@ -21,7 +22,6 @@
21#include <linux/poll.h> 22#include <linux/poll.h>
22#include <linux/rtnetlink.h> 23#include <linux/rtnetlink.h>
23#include <linux/skbuff.h> 24#include <linux/skbuff.h>
24#include <linux/slab.h>
25#include <net/x25device.h> 25#include <net/x25device.h>
26 26
27static int x25_ioctl(struct net_device *dev, struct ifreq *ifr); 27static int x25_ioctl(struct net_device *dev, struct ifreq *ifr);
diff --git a/drivers/net/wan/hostess_sv11.c b/drivers/net/wan/hostess_sv11.c
index 74164d29524..48edc5f4dac 100644
--- a/drivers/net/wan/hostess_sv11.c
+++ b/drivers/net/wan/hostess_sv11.c
@@ -30,6 +30,7 @@
30#include <linux/delay.h> 30#include <linux/delay.h>
31#include <linux/hdlc.h> 31#include <linux/hdlc.h>
32#include <linux/ioport.h> 32#include <linux/ioport.h>
33#include <linux/slab.h>
33#include <net/arp.h> 34#include <net/arp.h>
34 35
35#include <asm/irq.h> 36#include <asm/irq.h>
diff --git a/drivers/net/wan/ixp4xx_hss.c b/drivers/net/wan/ixp4xx_hss.c
index c705046d861..0c2cdde686a 100644
--- a/drivers/net/wan/ixp4xx_hss.c
+++ b/drivers/net/wan/ixp4xx_hss.c
@@ -18,6 +18,7 @@
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/poll.h> 20#include <linux/poll.h>
21#include <linux/slab.h>
21#include <mach/npe.h> 22#include <mach/npe.h>
22#include <mach/qmgr.h> 23#include <mach/qmgr.h>
23 24
diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c
index d1e3c673e9b..98e2f99903d 100644
--- a/drivers/net/wan/lapbether.c
+++ b/drivers/net/wan/lapbether.c
@@ -24,6 +24,7 @@
24#include <linux/types.h> 24#include <linux/types.h>
25#include <linux/socket.h> 25#include <linux/socket.h>
26#include <linux/in.h> 26#include <linux/in.h>
27#include <linux/slab.h>
27#include <linux/kernel.h> 28#include <linux/kernel.h>
28#include <linux/string.h> 29#include <linux/string.h>
29#include <linux/net.h> 30#include <linux/net.h>
diff --git a/drivers/net/wan/lmc/lmc_media.c b/drivers/net/wan/lmc/lmc_media.c
index f327674fc93..5920c996fcd 100644
--- a/drivers/net/wan/lmc/lmc_media.c
+++ b/drivers/net/wan/lmc/lmc_media.c
@@ -6,7 +6,6 @@
6#include <linux/ptrace.h> 6#include <linux/ptrace.h>
7#include <linux/errno.h> 7#include <linux/errno.h>
8#include <linux/ioport.h> 8#include <linux/ioport.h>
9#include <linux/slab.h>
10#include <linux/interrupt.h> 9#include <linux/interrupt.h>
11#include <linux/in.h> 10#include <linux/in.h>
12#include <linux/if_arp.h> 11#include <linux/if_arp.h>
diff --git a/drivers/net/wan/lmc/lmc_proto.c b/drivers/net/wan/lmc/lmc_proto.c
index 044a48175c4..f600075e84a 100644
--- a/drivers/net/wan/lmc/lmc_proto.c
+++ b/drivers/net/wan/lmc/lmc_proto.c
@@ -25,7 +25,6 @@
25#include <linux/ptrace.h> 25#include <linux/ptrace.h>
26#include <linux/errno.h> 26#include <linux/errno.h>
27#include <linux/ioport.h> 27#include <linux/ioport.h>
28#include <linux/slab.h>
29#include <linux/interrupt.h> 28#include <linux/interrupt.h>
30#include <linux/in.h> 29#include <linux/in.h>
31#include <linux/if_arp.h> 30#include <linux/if_arp.h>
diff --git a/drivers/net/wan/pc300_drv.c b/drivers/net/wan/pc300_drv.c
index f4f1c00d0d2..3f744c64309 100644
--- a/drivers/net/wan/pc300_drv.c
+++ b/drivers/net/wan/pc300_drv.c
@@ -228,6 +228,7 @@ static char rcsid[] =
228#include <linux/etherdevice.h> 228#include <linux/etherdevice.h>
229#include <linux/spinlock.h> 229#include <linux/spinlock.h>
230#include <linux/if.h> 230#include <linux/if.h>
231#include <linux/slab.h>
231#include <net/arp.h> 232#include <net/arp.h>
232 233
233#include <asm/io.h> 234#include <asm/io.h>
diff --git a/drivers/net/wan/sbni.c b/drivers/net/wan/sbni.c
index 25477b5cde4..cff13a9597c 100644
--- a/drivers/net/wan/sbni.c
+++ b/drivers/net/wan/sbni.c
@@ -43,7 +43,6 @@
43#include <linux/fcntl.h> 43#include <linux/fcntl.h>
44#include <linux/ioport.h> 44#include <linux/ioport.h>
45#include <linux/interrupt.h> 45#include <linux/interrupt.h>
46#include <linux/slab.h>
47#include <linux/string.h> 46#include <linux/string.h>
48#include <linux/errno.h> 47#include <linux/errno.h>
49#include <linux/netdevice.h> 48#include <linux/netdevice.h>
diff --git a/drivers/net/wan/sealevel.c b/drivers/net/wan/sealevel.c
index 61249f489e3..e91457d6023 100644
--- a/drivers/net/wan/sealevel.c
+++ b/drivers/net/wan/sealevel.c
@@ -23,6 +23,7 @@
23#include <linux/hdlc.h> 23#include <linux/hdlc.h>
24#include <linux/ioport.h> 24#include <linux/ioport.h>
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/slab.h>
26#include <net/arp.h> 27#include <net/arp.h>
27 28
28#include <asm/irq.h> 29#include <asm/irq.h>
diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c
index b9f520b7db6..80d5c5834a0 100644
--- a/drivers/net/wan/x25_asy.c
+++ b/drivers/net/wan/x25_asy.c
@@ -34,6 +34,7 @@
34#include <linux/init.h> 34#include <linux/init.h>
35#include <linux/rtnetlink.h> 35#include <linux/rtnetlink.h>
36#include <linux/compat.h> 36#include <linux/compat.h>
37#include <linux/slab.h>
37#include "x25_asy.h" 38#include "x25_asy.h"
38 39
39#include <net/x25device.h> 40#include <net/x25device.h>
diff --git a/drivers/net/wan/z85230.c b/drivers/net/wan/z85230.c
index 0be7ec7299d..fbf5e843d48 100644
--- a/drivers/net/wan/z85230.c
+++ b/drivers/net/wan/z85230.c
@@ -47,6 +47,7 @@
47#include <linux/hdlc.h> 47#include <linux/hdlc.h>
48#include <linux/ioport.h> 48#include <linux/ioport.h>
49#include <linux/init.h> 49#include <linux/init.h>
50#include <linux/gfp.h>
50#include <asm/dma.h> 51#include <asm/dma.h>
51#include <asm/io.h> 52#include <asm/io.h>
52#define RT_LOCK 53#define RT_LOCK
diff --git a/drivers/net/wimax/i2400m/control.c b/drivers/net/wimax/i2400m/control.c
index 94494554039..6180772dcc0 100644
--- a/drivers/net/wimax/i2400m/control.c
+++ b/drivers/net/wimax/i2400m/control.c
@@ -76,6 +76,7 @@
76#include <stdarg.h> 76#include <stdarg.h>
77#include "i2400m.h" 77#include "i2400m.h"
78#include <linux/kernel.h> 78#include <linux/kernel.h>
79#include <linux/slab.h>
79#include <linux/wimax/i2400m.h> 80#include <linux/wimax/i2400m.h>
80 81
81 82
diff --git a/drivers/net/wimax/i2400m/driver.c b/drivers/net/wimax/i2400m/driver.c
index 6cead321bc1..94dc83c3969 100644
--- a/drivers/net/wimax/i2400m/driver.c
+++ b/drivers/net/wimax/i2400m/driver.c
@@ -69,6 +69,7 @@
69#include <linux/module.h> 69#include <linux/module.h>
70#include <linux/moduleparam.h> 70#include <linux/moduleparam.h>
71#include <linux/suspend.h> 71#include <linux/suspend.h>
72#include <linux/slab.h>
72 73
73#define D_SUBMODULE driver 74#define D_SUBMODULE driver
74#include "debug-levels.h" 75#include "debug-levels.h"
diff --git a/drivers/net/wimax/i2400m/fw.c b/drivers/net/wimax/i2400m/fw.c
index 25c24f0368d..3f283bff0ff 100644
--- a/drivers/net/wimax/i2400m/fw.c
+++ b/drivers/net/wimax/i2400m/fw.c
@@ -156,6 +156,7 @@
156 */ 156 */
157#include <linux/firmware.h> 157#include <linux/firmware.h>
158#include <linux/sched.h> 158#include <linux/sched.h>
159#include <linux/slab.h>
159#include <linux/usb.h> 160#include <linux/usb.h>
160#include "i2400m.h" 161#include "i2400m.h"
161 162
diff --git a/drivers/net/wimax/i2400m/netdev.c b/drivers/net/wimax/i2400m/netdev.c
index 599aa4eb9ba..b811c2f1f5e 100644
--- a/drivers/net/wimax/i2400m/netdev.c
+++ b/drivers/net/wimax/i2400m/netdev.c
@@ -73,6 +73,7 @@
73 * alloc_netdev. 73 * alloc_netdev.
74 */ 74 */
75#include <linux/if_arp.h> 75#include <linux/if_arp.h>
76#include <linux/slab.h>
76#include <linux/netdevice.h> 77#include <linux/netdevice.h>
77#include <linux/ethtool.h> 78#include <linux/ethtool.h>
78#include "i2400m.h" 79#include "i2400m.h"
diff --git a/drivers/net/wimax/i2400m/op-rfkill.c b/drivers/net/wimax/i2400m/op-rfkill.c
index 43927b5d7ad..035e4cf3e6e 100644
--- a/drivers/net/wimax/i2400m/op-rfkill.c
+++ b/drivers/net/wimax/i2400m/op-rfkill.c
@@ -34,6 +34,7 @@
34 */ 34 */
35#include "i2400m.h" 35#include "i2400m.h"
36#include <linux/wimax/i2400m.h> 36#include <linux/wimax/i2400m.h>
37#include <linux/slab.h>
37 38
38 39
39 40
diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c
index 7ddb173fd4a..fa2e11e5b4b 100644
--- a/drivers/net/wimax/i2400m/rx.c
+++ b/drivers/net/wimax/i2400m/rx.c
@@ -144,6 +144,7 @@
144 * i2400m_msg_size_check 144 * i2400m_msg_size_check
145 * wimax_msg 145 * wimax_msg
146 */ 146 */
147#include <linux/slab.h>
147#include <linux/kernel.h> 148#include <linux/kernel.h>
148#include <linux/if_arp.h> 149#include <linux/if_arp.h>
149#include <linux/netdevice.h> 150#include <linux/netdevice.h>
diff --git a/drivers/net/wimax/i2400m/sdio-rx.c b/drivers/net/wimax/i2400m/sdio-rx.c
index 8adf6c9b6f8..d619da33f20 100644
--- a/drivers/net/wimax/i2400m/sdio-rx.c
+++ b/drivers/net/wimax/i2400m/sdio-rx.c
@@ -65,6 +65,7 @@
65#include <linux/skbuff.h> 65#include <linux/skbuff.h>
66#include <linux/mmc/sdio.h> 66#include <linux/mmc/sdio.h>
67#include <linux/mmc/sdio_func.h> 67#include <linux/mmc/sdio_func.h>
68#include <linux/slab.h>
68#include "i2400m-sdio.h" 69#include "i2400m-sdio.h"
69 70
70#define D_SUBMODULE rx 71#define D_SUBMODULE rx
diff --git a/drivers/net/wimax/i2400m/sdio.c b/drivers/net/wimax/i2400m/sdio.c
index 14f876b1358..7632f80954e 100644
--- a/drivers/net/wimax/i2400m/sdio.c
+++ b/drivers/net/wimax/i2400m/sdio.c
@@ -48,6 +48,7 @@
48 * __i2400ms_send_barker() 48 * __i2400ms_send_barker()
49 */ 49 */
50 50
51#include <linux/slab.h>
51#include <linux/debugfs.h> 52#include <linux/debugfs.h>
52#include <linux/mmc/sdio_ids.h> 53#include <linux/mmc/sdio_ids.h>
53#include <linux/mmc/sdio.h> 54#include <linux/mmc/sdio.h>
diff --git a/drivers/net/wimax/i2400m/tx.c b/drivers/net/wimax/i2400m/tx.c
index 54480e8947f..b0cb90624cf 100644
--- a/drivers/net/wimax/i2400m/tx.c
+++ b/drivers/net/wimax/i2400m/tx.c
@@ -244,6 +244,7 @@
244 * (FIFO empty). 244 * (FIFO empty).
245 */ 245 */
246#include <linux/netdevice.h> 246#include <linux/netdevice.h>
247#include <linux/slab.h>
247#include "i2400m.h" 248#include "i2400m.h"
248 249
249 250
diff --git a/drivers/net/wimax/i2400m/usb-fw.c b/drivers/net/wimax/i2400m/usb-fw.c
index ce6b9938fde..b58ec56b86f 100644
--- a/drivers/net/wimax/i2400m/usb-fw.c
+++ b/drivers/net/wimax/i2400m/usb-fw.c
@@ -73,6 +73,7 @@
73 * i2400m_notif_submit 73 * i2400m_notif_submit
74 */ 74 */
75#include <linux/usb.h> 75#include <linux/usb.h>
76#include <linux/gfp.h>
76#include "i2400m-usb.h" 77#include "i2400m-usb.h"
77 78
78 79
diff --git a/drivers/net/wimax/i2400m/usb-notif.c b/drivers/net/wimax/i2400m/usb-notif.c
index f88d1c6e35c..7b6a1d98bd7 100644
--- a/drivers/net/wimax/i2400m/usb-notif.c
+++ b/drivers/net/wimax/i2400m/usb-notif.c
@@ -56,6 +56,7 @@
56 * i2400mu_rx_kick() 56 * i2400mu_rx_kick()
57 */ 57 */
58#include <linux/usb.h> 58#include <linux/usb.h>
59#include <linux/slab.h>
59#include "i2400m-usb.h" 60#include "i2400m-usb.h"
60 61
61 62
diff --git a/drivers/net/wimax/i2400m/usb-rx.c b/drivers/net/wimax/i2400m/usb-rx.c
index ba1b02362df..a26483a812a 100644
--- a/drivers/net/wimax/i2400m/usb-rx.c
+++ b/drivers/net/wimax/i2400m/usb-rx.c
@@ -83,6 +83,7 @@
83 * i2400mu_rx_release() called from i2400mu_bus_dev_stop() 83 * i2400mu_rx_release() called from i2400mu_bus_dev_stop()
84 */ 84 */
85#include <linux/workqueue.h> 85#include <linux/workqueue.h>
86#include <linux/slab.h>
86#include <linux/usb.h> 87#include <linux/usb.h>
87#include "i2400m-usb.h" 88#include "i2400m-usb.h"
88 89
diff --git a/drivers/net/wimax/i2400m/usb.c b/drivers/net/wimax/i2400m/usb.c
index 99f04c47589..d8c4d6497fd 100644
--- a/drivers/net/wimax/i2400m/usb.c
+++ b/drivers/net/wimax/i2400m/usb.c
@@ -66,6 +66,7 @@
66#include "i2400m-usb.h" 66#include "i2400m-usb.h"
67#include <linux/wimax/i2400m.h> 67#include <linux/wimax/i2400m.h>
68#include <linux/debugfs.h> 68#include <linux/debugfs.h>
69#include <linux/slab.h>
69 70
70 71
71#define D_SUBMODULE usb 72#define D_SUBMODULE usb
diff --git a/drivers/net/wireless/adm8211.c b/drivers/net/wireless/adm8211.c
index 547912e6843..ab61d2b558d 100644
--- a/drivers/net/wireless/adm8211.c
+++ b/drivers/net/wireless/adm8211.c
@@ -18,6 +18,7 @@
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/if.h> 19#include <linux/if.h>
20#include <linux/skbuff.h> 20#include <linux/skbuff.h>
21#include <linux/slab.h>
21#include <linux/etherdevice.h> 22#include <linux/etherdevice.h>
22#include <linux/pci.h> 23#include <linux/pci.h>
23#include <linux/delay.h> 24#include <linux/delay.h>
diff --git a/drivers/net/wireless/ath/ar9170/main.c b/drivers/net/wireless/ath/ar9170/main.c
index 257c734733d..c5369298099 100644
--- a/drivers/net/wireless/ath/ar9170/main.c
+++ b/drivers/net/wireless/ath/ar9170/main.c
@@ -38,6 +38,7 @@
38 */ 38 */
39 39
40#include <linux/init.h> 40#include <linux/init.h>
41#include <linux/slab.h>
41#include <linux/module.h> 42#include <linux/module.h>
42#include <linux/etherdevice.h> 43#include <linux/etherdevice.h>
43#include <net/mac80211.h> 44#include <net/mac80211.h>
diff --git a/drivers/net/wireless/ath/ar9170/usb.c b/drivers/net/wireless/ath/ar9170/usb.c
index 4e30197afff..99a6da464bd 100644
--- a/drivers/net/wireless/ath/ar9170/usb.c
+++ b/drivers/net/wireless/ath/ar9170/usb.c
@@ -38,6 +38,7 @@
38 */ 38 */
39 39
40#include <linux/module.h> 40#include <linux/module.h>
41#include <linux/slab.h>
41#include <linux/usb.h> 42#include <linux/usb.h>
42#include <linux/firmware.h> 43#include <linux/firmware.h>
43#include <linux/etherdevice.h> 44#include <linux/etherdevice.h>
@@ -94,6 +95,8 @@ static struct usb_device_id ar9170_usb_ids[] = {
94 { USB_DEVICE(0x04bb, 0x093f) }, 95 { USB_DEVICE(0x04bb, 0x093f) },
95 /* AVM FRITZ!WLAN USB Stick N */ 96 /* AVM FRITZ!WLAN USB Stick N */
96 { USB_DEVICE(0x057C, 0x8401) }, 97 { USB_DEVICE(0x057C, 0x8401) },
98 /* NEC WL300NU-G */
99 { USB_DEVICE(0x0409, 0x0249) },
97 /* AVM FRITZ!WLAN USB Stick N 2.4 */ 100 /* AVM FRITZ!WLAN USB Stick N 2.4 */
98 { USB_DEVICE(0x057C, 0x8402), .driver_info = AR9170_REQ_FW1_ONLY }, 101 { USB_DEVICE(0x057C, 0x8402), .driver_info = AR9170_REQ_FW1_ONLY },
99 102
@@ -416,7 +419,7 @@ static int ar9170_usb_exec_cmd(struct ar9170 *ar, enum ar9170_cmd cmd,
416 spin_unlock_irqrestore(&aru->common.cmdlock, flags); 419 spin_unlock_irqrestore(&aru->common.cmdlock, flags);
417 420
418 usb_fill_int_urb(urb, aru->udev, 421 usb_fill_int_urb(urb, aru->udev,
419 usb_sndbulkpipe(aru->udev, AR9170_EP_CMD), 422 usb_sndintpipe(aru->udev, AR9170_EP_CMD),
420 aru->common.cmdbuf, plen + 4, 423 aru->common.cmdbuf, plen + 4,
421 ar9170_usb_tx_urb_complete, NULL, 1); 424 ar9170_usb_tx_urb_complete, NULL, 1);
422 425
diff --git a/drivers/net/wireless/ath/ath5k/attach.c b/drivers/net/wireless/ath/ath5k/attach.c
index 42284445b75..dc0786cc263 100644
--- a/drivers/net/wireless/ath/ath5k/attach.c
+++ b/drivers/net/wireless/ath/ath5k/attach.c
@@ -21,6 +21,7 @@
21\*************************************/ 21\*************************************/
22 22
23#include <linux/pci.h> 23#include <linux/pci.h>
24#include <linux/slab.h>
24#include "ath5k.h" 25#include "ath5k.h"
25#include "reg.h" 26#include "reg.h"
26#include "debug.h" 27#include "debug.h"
diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
index 8dce0077b02..3abbe7513ab 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -50,6 +50,7 @@
50#include <linux/pci.h> 50#include <linux/pci.h>
51#include <linux/ethtool.h> 51#include <linux/ethtool.h>
52#include <linux/uaccess.h> 52#include <linux/uaccess.h>
53#include <linux/slab.h>
53 54
54#include <net/ieee80211_radiotap.h> 55#include <net/ieee80211_radiotap.h>
55 56
diff --git a/drivers/net/wireless/ath/ath5k/eeprom.c b/drivers/net/wireless/ath/ath5k/eeprom.c
index 10b52262b23..67665cdc7af 100644
--- a/drivers/net/wireless/ath/ath5k/eeprom.c
+++ b/drivers/net/wireless/ath/ath5k/eeprom.c
@@ -21,6 +21,8 @@
21* EEPROM access functions and helpers * 21* EEPROM access functions and helpers *
22\*************************************/ 22\*************************************/
23 23
24#include <linux/slab.h>
25
24#include "ath5k.h" 26#include "ath5k.h"
25#include "reg.h" 27#include "reg.h"
26#include "debug.h" 28#include "debug.h"
diff --git a/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c
index eff3323efb4..68e2bccd90d 100644
--- a/drivers/net/wireless/ath/ath5k/phy.c
+++ b/drivers/net/wireless/ath/ath5k/phy.c
@@ -23,6 +23,7 @@
23#define _ATH5K_PHY 23#define _ATH5K_PHY
24 24
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/slab.h>
26 27
27#include "ath5k.h" 28#include "ath5k.h"
28#include "reg.h" 29#include "reg.h"
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index 42d2a506845..081e0085ed4 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -14,6 +14,7 @@
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */ 15 */
16 16
17#include <linux/slab.h>
17#include <asm/unaligned.h> 18#include <asm/unaligned.h>
18 19
19#include "ath9k.h" 20#include "ath9k.h"
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 2e767cf22f1..78b571129c9 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -15,6 +15,7 @@
15 */ 15 */
16 16
17#include <linux/io.h> 17#include <linux/io.h>
18#include <linux/slab.h>
18#include <asm/unaligned.h> 19#include <asm/unaligned.h>
19 20
20#include "hw.h" 21#include "hw.h"
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index 623c2f88498..3d4d897add6 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -14,6 +14,8 @@
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */ 15 */
16 16
17#include <linux/slab.h>
18
17#include "ath9k.h" 19#include "ath9k.h"
18 20
19static char *dev_info = "ath9k"; 21static char *dev_info = "ath9k";
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 67ca4e5a601..115e1aeedb5 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -1532,8 +1532,7 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
1532 all_wiphys_idle = ath9k_all_wiphys_idle(sc); 1532 all_wiphys_idle = ath9k_all_wiphys_idle(sc);
1533 ath9k_set_wiphy_idle(aphy, idle); 1533 ath9k_set_wiphy_idle(aphy, idle);
1534 1534
1535 if (!idle && all_wiphys_idle) 1535 enable_radio = (!idle && all_wiphys_idle);
1536 enable_radio = true;
1537 1536
1538 /* 1537 /*
1539 * After we unlock here its possible another wiphy 1538 * After we unlock here its possible another wiphy
diff --git a/drivers/net/wireless/ath/ath9k/phy.c b/drivers/net/wireless/ath/ath9k/phy.c
index c3b59390fe3..2547b3c4a26 100644
--- a/drivers/net/wireless/ath/ath9k/phy.c
+++ b/drivers/net/wireless/ath/ath9k/phy.c
@@ -39,6 +39,8 @@
39 * AR9287 - 11n single-band 1x1 MIMO for USB 39 * AR9287 - 11n single-band 1x1 MIMO for USB
40 */ 40 */
41 41
42#include <linux/slab.h>
43
42#include "hw.h" 44#include "hw.h"
43 45
44/** 46/**
diff --git a/drivers/net/wireless/ath/ath9k/rc.c b/drivers/net/wireless/ath/ath9k/rc.c
index 0e79e58cf4c..244e1c62917 100644
--- a/drivers/net/wireless/ath/ath9k/rc.c
+++ b/drivers/net/wireless/ath/ath9k/rc.c
@@ -15,6 +15,8 @@
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */ 16 */
17 17
18#include <linux/slab.h>
19
18#include "ath9k.h" 20#include "ath9k.h"
19 21
20static const struct ath_rate_table ar5416_11na_ratetable = { 22static const struct ath_rate_table ar5416_11na_ratetable = {
diff --git a/drivers/net/wireless/ath/ath9k/virtual.c b/drivers/net/wireless/ath/ath9k/virtual.c
index a43fbf84dab..00c0e21a4af 100644
--- a/drivers/net/wireless/ath/ath9k/virtual.c
+++ b/drivers/net/wireless/ath/ath9k/virtual.c
@@ -14,6 +14,8 @@
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */ 15 */
16 16
17#include <linux/slab.h>
18
17#include "ath9k.h" 19#include "ath9k.h"
18 20
19struct ath9k_vif_iter_data { 21struct ath9k_vif_iter_data {
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index b2c8207f7bc..294b486bc3e 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -1353,25 +1353,6 @@ static enum ath9k_pkt_type get_hw_packet_type(struct sk_buff *skb)
1353 return htype; 1353 return htype;
1354} 1354}
1355 1355
1356static bool is_pae(struct sk_buff *skb)
1357{
1358 struct ieee80211_hdr *hdr;
1359 __le16 fc;
1360
1361 hdr = (struct ieee80211_hdr *)skb->data;
1362 fc = hdr->frame_control;
1363
1364 if (ieee80211_is_data(fc)) {
1365 if (ieee80211_is_nullfunc(fc) ||
1366 /* Port Access Entity (IEEE 802.1X) */
1367 (skb->protocol == cpu_to_be16(ETH_P_PAE))) {
1368 return true;
1369 }
1370 }
1371
1372 return false;
1373}
1374
1375static int get_hw_crypto_keytype(struct sk_buff *skb) 1356static int get_hw_crypto_keytype(struct sk_buff *skb)
1376{ 1357{
1377 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); 1358 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
@@ -1696,7 +1677,7 @@ static void ath_tx_start_dma(struct ath_softc *sc, struct ath_buf *bf,
1696 goto tx_done; 1677 goto tx_done;
1697 } 1678 }
1698 1679
1699 if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && !is_pae(skb)) { 1680 if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) {
1700 /* 1681 /*
1701 * Try aggregation if it's a unicast data frame 1682 * Try aggregation if it's a unicast data frame
1702 * and the destination is HT capable. 1683 * and the destination is HT capable.
diff --git a/drivers/net/wireless/ath/regd.c b/drivers/net/wireless/ath/regd.c
index 04abd1f556b..00489c40be0 100644
--- a/drivers/net/wireless/ath/regd.c
+++ b/drivers/net/wireless/ath/regd.c
@@ -15,7 +15,6 @@
15 */ 15 */
16 16
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/slab.h>
19#include <net/cfg80211.h> 18#include <net/cfg80211.h>
20#include <net/mac80211.h> 19#include <net/mac80211.h>
21#include "regd.h" 20#include "regd.h"
diff --git a/drivers/net/wireless/b43/dma.c b/drivers/net/wireless/b43/dma.c
index be7abf8916a..fa40fdfea71 100644
--- a/drivers/net/wireless/b43/dma.c
+++ b/drivers/net/wireless/b43/dma.c
@@ -38,6 +38,7 @@
38#include <linux/delay.h> 38#include <linux/delay.h>
39#include <linux/skbuff.h> 39#include <linux/skbuff.h>
40#include <linux/etherdevice.h> 40#include <linux/etherdevice.h>
41#include <linux/slab.h>
41#include <asm/div64.h> 42#include <asm/div64.h>
42 43
43 44
diff --git a/drivers/net/wireless/b43/lo.c b/drivers/net/wireless/b43/lo.c
index 976104f634a..94e4f1378fc 100644
--- a/drivers/net/wireless/b43/lo.c
+++ b/drivers/net/wireless/b43/lo.c
@@ -34,6 +34,7 @@
34 34
35#include <linux/delay.h> 35#include <linux/delay.h>
36#include <linux/sched.h> 36#include <linux/sched.h>
37#include <linux/slab.h>
37 38
38 39
39static struct b43_lo_calib *b43_find_lo_calib(struct b43_txpower_lo_control *lo, 40static struct b43_lo_calib *b43_find_lo_calib(struct b43_txpower_lo_control *lo,
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 1521b1e78d2..9a374ef83a2 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -42,6 +42,7 @@
42#include <linux/skbuff.h> 42#include <linux/skbuff.h>
43#include <linux/io.h> 43#include <linux/io.h>
44#include <linux/dma-mapping.h> 44#include <linux/dma-mapping.h>
45#include <linux/slab.h>
45#include <asm/unaligned.h> 46#include <asm/unaligned.h>
46 47
47#include "b43.h" 48#include "b43.h"
diff --git a/drivers/net/wireless/b43/pcmcia.c b/drivers/net/wireless/b43/pcmcia.c
index 984174bc7b0..609e7051e01 100644
--- a/drivers/net/wireless/b43/pcmcia.c
+++ b/drivers/net/wireless/b43/pcmcia.c
@@ -24,6 +24,7 @@
24#include "pcmcia.h" 24#include "pcmcia.h"
25 25
26#include <linux/ssb/ssb.h> 26#include <linux/ssb/ssb.h>
27#include <linux/slab.h>
27 28
28#include <pcmcia/cs_types.h> 29#include <pcmcia/cs_types.h>
29#include <pcmcia/cs.h> 30#include <pcmcia/cs.h>
diff --git a/drivers/net/wireless/b43/phy_a.c b/drivers/net/wireless/b43/phy_a.c
index d90217c3a70..b6428ec16dd 100644
--- a/drivers/net/wireless/b43/phy_a.c
+++ b/drivers/net/wireless/b43/phy_a.c
@@ -26,6 +26,8 @@
26 26
27*/ 27*/
28 28
29#include <linux/slab.h>
30
29#include "b43.h" 31#include "b43.h"
30#include "phy_a.h" 32#include "phy_a.h"
31#include "phy_common.h" 33#include "phy_common.h"
diff --git a/drivers/net/wireless/b43/phy_g.c b/drivers/net/wireless/b43/phy_g.c
index 382826a8da8..29bf34ced86 100644
--- a/drivers/net/wireless/b43/phy_g.c
+++ b/drivers/net/wireless/b43/phy_g.c
@@ -33,6 +33,7 @@
33#include "main.h" 33#include "main.h"
34 34
35#include <linux/bitrev.h> 35#include <linux/bitrev.h>
36#include <linux/slab.h>
36 37
37 38
38static const s8 b43_tssi2dbm_g_table[] = { 39static const s8 b43_tssi2dbm_g_table[] = {
diff --git a/drivers/net/wireless/b43/phy_lp.c b/drivers/net/wireless/b43/phy_lp.c
index 185219e0a55..c6afe9d9459 100644
--- a/drivers/net/wireless/b43/phy_lp.c
+++ b/drivers/net/wireless/b43/phy_lp.c
@@ -23,6 +23,8 @@
23 23
24*/ 24*/
25 25
26#include <linux/slab.h>
27
26#include "b43.h" 28#include "b43.h"
27#include "main.h" 29#include "main.h"
28#include "phy_lp.h" 30#include "phy_lp.h"
diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index 795bb1e3345..9c7cd282e46 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -23,6 +23,7 @@
23*/ 23*/
24 24
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/slab.h>
26#include <linux/types.h> 27#include <linux/types.h>
27 28
28#include "b43.h" 29#include "b43.h"
diff --git a/drivers/net/wireless/b43/pio.c b/drivers/net/wireless/b43/pio.c
index a6062c3e89a..aa12273ae71 100644
--- a/drivers/net/wireless/b43/pio.c
+++ b/drivers/net/wireless/b43/pio.c
@@ -31,6 +31,7 @@
31 31
32#include <linux/delay.h> 32#include <linux/delay.h>
33#include <linux/sched.h> 33#include <linux/sched.h>
34#include <linux/slab.h>
34 35
35 36
36static u16 generate_cookie(struct b43_pio_txqueue *q, 37static u16 generate_cookie(struct b43_pio_txqueue *q,
diff --git a/drivers/net/wireless/b43/sdio.c b/drivers/net/wireless/b43/sdio.c
index 0d3ac64147a..4e56b7bbceb 100644
--- a/drivers/net/wireless/b43/sdio.c
+++ b/drivers/net/wireless/b43/sdio.c
@@ -16,6 +16,7 @@
16#include <linux/mmc/card.h> 16#include <linux/mmc/card.h>
17#include <linux/mmc/sdio_func.h> 17#include <linux/mmc/sdio_func.h>
18#include <linux/mmc/sdio_ids.h> 18#include <linux/mmc/sdio_ids.h>
19#include <linux/slab.h>
19#include <linux/ssb/ssb.h> 20#include <linux/ssb/ssb.h>
20 21
21#include "sdio.h" 22#include "sdio.h"
diff --git a/drivers/net/wireless/b43legacy/dma.c b/drivers/net/wireless/b43legacy/dma.c
index 8b9387c6ff3..e91520d0312 100644
--- a/drivers/net/wireless/b43legacy/dma.c
+++ b/drivers/net/wireless/b43legacy/dma.c
@@ -37,6 +37,7 @@
37#include <linux/pci.h> 37#include <linux/pci.h>
38#include <linux/delay.h> 38#include <linux/delay.h>
39#include <linux/skbuff.h> 39#include <linux/skbuff.h>
40#include <linux/slab.h>
40#include <net/dst.h> 41#include <net/dst.h>
41 42
42/* 32bit DMA ops. */ 43/* 32bit DMA ops. */
diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c
index 1d070be5a67..bb2dd9329aa 100644
--- a/drivers/net/wireless/b43legacy/main.c
+++ b/drivers/net/wireless/b43legacy/main.c
@@ -40,6 +40,7 @@
40#include <linux/sched.h> 40#include <linux/sched.h>
41#include <linux/skbuff.h> 41#include <linux/skbuff.h>
42#include <linux/dma-mapping.h> 42#include <linux/dma-mapping.h>
43#include <linux/slab.h>
43#include <net/dst.h> 44#include <net/dst.h>
44#include <asm/unaligned.h> 45#include <asm/unaligned.h>
45 46
diff --git a/drivers/net/wireless/b43legacy/phy.c b/drivers/net/wireless/b43legacy/phy.c
index aaf227203a9..35033dd342c 100644
--- a/drivers/net/wireless/b43legacy/phy.c
+++ b/drivers/net/wireless/b43legacy/phy.c
@@ -32,6 +32,7 @@
32#include <linux/delay.h> 32#include <linux/delay.h>
33#include <linux/pci.h> 33#include <linux/pci.h>
34#include <linux/sched.h> 34#include <linux/sched.h>
35#include <linux/slab.h>
35#include <linux/types.h> 36#include <linux/types.h>
36 37
37#include "b43legacy.h" 38#include "b43legacy.h"
diff --git a/drivers/net/wireless/b43legacy/pio.c b/drivers/net/wireless/b43legacy/pio.c
index 017c0e9c37e..b033b0ed4ca 100644
--- a/drivers/net/wireless/b43legacy/pio.c
+++ b/drivers/net/wireless/b43legacy/pio.c
@@ -29,6 +29,7 @@
29#include "xmit.h" 29#include "xmit.h"
30 30
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/slab.h>
32 33
33 34
34static void tx_start(struct b43legacy_pioqueue *queue) 35static void tx_start(struct b43legacy_pioqueue *queue)
diff --git a/drivers/net/wireless/hostap/hostap_80211_rx.c b/drivers/net/wireless/hostap/hostap_80211_rx.c
index 3816df96a66..f4c56121d38 100644
--- a/drivers/net/wireless/hostap/hostap_80211_rx.c
+++ b/drivers/net/wireless/hostap/hostap_80211_rx.c
@@ -1,4 +1,5 @@
1#include <linux/etherdevice.h> 1#include <linux/etherdevice.h>
2#include <linux/slab.h>
2#include <net/lib80211.h> 3#include <net/lib80211.h>
3#include <linux/if_arp.h> 4#include <linux/if_arp.h>
4 5
diff --git a/drivers/net/wireless/hostap/hostap_80211_tx.c b/drivers/net/wireless/hostap/hostap_80211_tx.c
index 90108b698f1..c34a3b7f129 100644
--- a/drivers/net/wireless/hostap/hostap_80211_tx.c
+++ b/drivers/net/wireless/hostap/hostap_80211_tx.c
@@ -1,3 +1,5 @@
1#include <linux/slab.h>
2
1#include "hostap_80211.h" 3#include "hostap_80211.h"
2#include "hostap_common.h" 4#include "hostap_common.h"
3#include "hostap_wlan.h" 5#include "hostap_wlan.h"
diff --git a/drivers/net/wireless/hostap/hostap_ap.c b/drivers/net/wireless/hostap/hostap_ap.c
index a2a203c90ba..7e72ac1de49 100644
--- a/drivers/net/wireless/hostap/hostap_ap.c
+++ b/drivers/net/wireless/hostap/hostap_ap.c
@@ -20,6 +20,7 @@
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include <linux/random.h> 21#include <linux/random.h>
22#include <linux/if_arp.h> 22#include <linux/if_arp.h>
23#include <linux/slab.h>
23 24
24#include "hostap_wlan.h" 25#include "hostap_wlan.h"
25#include "hostap.h" 26#include "hostap.h"
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index d19748d90aa..a36501dbbe0 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -3,6 +3,7 @@
3#include <linux/module.h> 3#include <linux/module.h>
4#include <linux/init.h> 4#include <linux/init.h>
5#include <linux/if.h> 5#include <linux/if.h>
6#include <linux/slab.h>
6#include <linux/wait.h> 7#include <linux/wait.h>
7#include <linux/timer.h> 8#include <linux/timer.h>
8#include <linux/skbuff.h> 9#include <linux/skbuff.h>
diff --git a/drivers/net/wireless/hostap/hostap_info.c b/drivers/net/wireless/hostap/hostap_info.c
index 4dfb40a84c9..d737091cf6a 100644
--- a/drivers/net/wireless/hostap/hostap_info.c
+++ b/drivers/net/wireless/hostap/hostap_info.c
@@ -2,6 +2,7 @@
2 2
3#include <linux/if_arp.h> 3#include <linux/if_arp.h>
4#include <linux/sched.h> 4#include <linux/sched.h>
5#include <linux/slab.h>
5#include "hostap_wlan.h" 6#include "hostap_wlan.h"
6#include "hostap.h" 7#include "hostap.h"
7#include "hostap_ap.h" 8#include "hostap_ap.h"
diff --git a/drivers/net/wireless/hostap/hostap_ioctl.c b/drivers/net/wireless/hostap/hostap_ioctl.c
index 9419cebca8a..9a082308a9d 100644
--- a/drivers/net/wireless/hostap/hostap_ioctl.c
+++ b/drivers/net/wireless/hostap/hostap_ioctl.c
@@ -1,5 +1,6 @@
1/* ioctl() (mostly Linux Wireless Extensions) routines for Host AP driver */ 1/* ioctl() (mostly Linux Wireless Extensions) routines for Host AP driver */
2 2
3#include <linux/slab.h>
3#include <linux/types.h> 4#include <linux/types.h>
4#include <linux/sched.h> 5#include <linux/sched.h>
5#include <linux/ethtool.h> 6#include <linux/ethtool.h>
diff --git a/drivers/net/wireless/hostap/hostap_pci.c b/drivers/net/wireless/hostap/hostap_pci.c
index 4d97ae37499..d24dc7dc072 100644
--- a/drivers/net/wireless/hostap/hostap_pci.c
+++ b/drivers/net/wireless/hostap/hostap_pci.c
@@ -9,6 +9,7 @@
9#include <linux/if.h> 9#include <linux/if.h>
10#include <linux/skbuff.h> 10#include <linux/skbuff.h>
11#include <linux/netdevice.h> 11#include <linux/netdevice.h>
12#include <linux/slab.h>
12#include <linux/workqueue.h> 13#include <linux/workqueue.h>
13#include <linux/wireless.h> 14#include <linux/wireless.h>
14#include <net/iw_handler.h> 15#include <net/iw_handler.h>
diff --git a/drivers/net/wireless/hostap/hostap_plx.c b/drivers/net/wireless/hostap/hostap_plx.c
index fc04ccdc5be..33e79037770 100644
--- a/drivers/net/wireless/hostap/hostap_plx.c
+++ b/drivers/net/wireless/hostap/hostap_plx.c
@@ -12,6 +12,7 @@
12#include <linux/if.h> 12#include <linux/if.h>
13#include <linux/skbuff.h> 13#include <linux/skbuff.h>
14#include <linux/netdevice.h> 14#include <linux/netdevice.h>
15#include <linux/slab.h>
15#include <linux/workqueue.h> 16#include <linux/workqueue.h>
16#include <linux/wireless.h> 17#include <linux/wireless.h>
17#include <net/iw_handler.h> 18#include <net/iw_handler.h>
diff --git a/drivers/net/wireless/ipw2x00/ipw2200.c b/drivers/net/wireless/ipw2x00/ipw2200.c
index 5c7aa1b1eb5..8d72e3d1958 100644
--- a/drivers/net/wireless/ipw2x00/ipw2200.c
+++ b/drivers/net/wireless/ipw2x00/ipw2200.c
@@ -31,6 +31,7 @@
31******************************************************************************/ 31******************************************************************************/
32 32
33#include <linux/sched.h> 33#include <linux/sched.h>
34#include <linux/slab.h>
34#include "ipw2200.h" 35#include "ipw2200.h"
35 36
36 37
diff --git a/drivers/net/wireless/ipw2x00/libipw_geo.c b/drivers/net/wireless/ipw2x00/libipw_geo.c
index 65e8c175a4a..c9fe3c99cb0 100644
--- a/drivers/net/wireless/ipw2x00/libipw_geo.c
+++ b/drivers/net/wireless/ipw2x00/libipw_geo.c
@@ -34,7 +34,6 @@
34#include <linux/netdevice.h> 34#include <linux/netdevice.h>
35#include <linux/proc_fs.h> 35#include <linux/proc_fs.h>
36#include <linux/skbuff.h> 36#include <linux/skbuff.h>
37#include <linux/slab.h>
38#include <linux/tcp.h> 37#include <linux/tcp.h>
39#include <linux/types.h> 38#include <linux/types.h>
40#include <linux/wireless.h> 39#include <linux/wireless.h>
diff --git a/drivers/net/wireless/ipw2x00/libipw_rx.c b/drivers/net/wireless/ipw2x00/libipw_rx.c
index 282b1f7ff1e..39a34da52d5 100644
--- a/drivers/net/wireless/ipw2x00/libipw_rx.c
+++ b/drivers/net/wireless/ipw2x00/libipw_rx.c
@@ -17,6 +17,7 @@
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <linux/if_arp.h> 18#include <linux/if_arp.h>
19#include <linux/in6.h> 19#include <linux/in6.h>
20#include <linux/gfp.h>
20#include <linux/in.h> 21#include <linux/in.h>
21#include <linux/ip.h> 22#include <linux/ip.h>
22#include <linux/kernel.h> 23#include <linux/kernel.h>
@@ -24,7 +25,6 @@
24#include <linux/netdevice.h> 25#include <linux/netdevice.h>
25#include <linux/proc_fs.h> 26#include <linux/proc_fs.h>
26#include <linux/skbuff.h> 27#include <linux/skbuff.h>
27#include <linux/slab.h>
28#include <linux/tcp.h> 28#include <linux/tcp.h>
29#include <linux/types.h> 29#include <linux/types.h>
30#include <linux/wireless.h> 30#include <linux/wireless.h>
diff --git a/drivers/net/wireless/ipw2x00/libipw_wx.c b/drivers/net/wireless/ipw2x00/libipw_wx.c
index 4d89f66f53b..3633c6682e4 100644
--- a/drivers/net/wireless/ipw2x00/libipw_wx.c
+++ b/drivers/net/wireless/ipw2x00/libipw_wx.c
@@ -31,6 +31,7 @@
31******************************************************************************/ 31******************************************************************************/
32 32
33#include <linux/kmod.h> 33#include <linux/kmod.h>
34#include <linux/slab.h>
34#include <linux/module.h> 35#include <linux/module.h>
35#include <linux/jiffies.h> 36#include <linux/jiffies.h>
36 37
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
index 47909f94271..902c4d4293e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
@@ -27,6 +27,7 @@
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/skbuff.h> 29#include <linux/skbuff.h>
30#include <linux/slab.h>
30#include <linux/wireless.h> 31#include <linux/wireless.h>
31#include <net/mac80211.h> 32#include <net/mac80211.h>
32 33
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index e0678d92105..0728054a22d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -27,6 +27,7 @@
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/slab.h>
30#include <linux/pci.h> 31#include <linux/pci.h>
31#include <linux/dma-mapping.h> 32#include <linux/dma-mapping.h>
32#include <linux/delay.h> 33#include <linux/delay.h>
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 1bd2cd83602..8972166386c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -2015,7 +2015,9 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv,
2015 IWL_DEBUG_TX_REPLY(priv, "Retry scheduler reclaim scd_ssn " 2015 IWL_DEBUG_TX_REPLY(priv, "Retry scheduler reclaim scd_ssn "
2016 "%d index %d\n", scd_ssn , index); 2016 "%d index %d\n", scd_ssn , index);
2017 freed = iwl_tx_queue_reclaim(priv, txq_id, index); 2017 freed = iwl_tx_queue_reclaim(priv, txq_id, index);
2018 iwl_free_tfds_in_queue(priv, sta_id, tid, freed); 2018 if (qc)
2019 iwl_free_tfds_in_queue(priv, sta_id,
2020 tid, freed);
2019 2021
2020 if (priv->mac80211_registered && 2022 if (priv->mac80211_registered &&
2021 (iwl_queue_space(&txq->q) > txq->q.low_mark) && 2023 (iwl_queue_space(&txq->q) > txq->q.low_mark) &&
@@ -2042,13 +2044,14 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv,
2042 2044
2043 freed = iwl_tx_queue_reclaim(priv, txq_id, index); 2045 freed = iwl_tx_queue_reclaim(priv, txq_id, index);
2044 if (qc && likely(sta_id != IWL_INVALID_STATION)) 2046 if (qc && likely(sta_id != IWL_INVALID_STATION))
2045 priv->stations[sta_id].tid[tid].tfds_in_queue -= freed; 2047 iwl_free_tfds_in_queue(priv, sta_id, tid, freed);
2048 else if (sta_id == IWL_INVALID_STATION)
2049 IWL_DEBUG_TX_REPLY(priv, "Station not known\n");
2046 2050
2047 if (priv->mac80211_registered && 2051 if (priv->mac80211_registered &&
2048 (iwl_queue_space(&txq->q) > txq->q.low_mark)) 2052 (iwl_queue_space(&txq->q) > txq->q.low_mark))
2049 iwl_wake_queue(priv, txq_id); 2053 iwl_wake_queue(priv, txq_id);
2050 } 2054 }
2051
2052 if (qc && likely(sta_id != IWL_INVALID_STATION)) 2055 if (qc && likely(sta_id != IWL_INVALID_STATION))
2053 iwl_txq_check_empty(priv, sta_id, tid, txq_id); 2056 iwl_txq_check_empty(priv, sta_id, tid, txq_id);
2054 2057
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c
index c4844adff92..92b3e64fc14 100644
--- a/drivers/net/wireless/iwlwifi/iwl-6000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-6000.c
@@ -259,7 +259,7 @@ static struct iwl_lib_ops iwl6000_lib = {
259 EEPROM_5000_REG_BAND_3_CHANNELS, 259 EEPROM_5000_REG_BAND_3_CHANNELS,
260 EEPROM_5000_REG_BAND_4_CHANNELS, 260 EEPROM_5000_REG_BAND_4_CHANNELS,
261 EEPROM_5000_REG_BAND_5_CHANNELS, 261 EEPROM_5000_REG_BAND_5_CHANNELS,
262 EEPROM_5000_REG_BAND_24_HT40_CHANNELS, 262 EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
263 EEPROM_5000_REG_BAND_52_HT40_CHANNELS 263 EEPROM_5000_REG_BAND_52_HT40_CHANNELS
264 }, 264 },
265 .verify_signature = iwlcore_eeprom_verify_signature, 265 .verify_signature = iwlcore_eeprom_verify_signature,
@@ -323,7 +323,7 @@ static struct iwl_lib_ops iwl6050_lib = {
323 EEPROM_5000_REG_BAND_3_CHANNELS, 323 EEPROM_5000_REG_BAND_3_CHANNELS,
324 EEPROM_5000_REG_BAND_4_CHANNELS, 324 EEPROM_5000_REG_BAND_4_CHANNELS,
325 EEPROM_5000_REG_BAND_5_CHANNELS, 325 EEPROM_5000_REG_BAND_5_CHANNELS,
326 EEPROM_5000_REG_BAND_24_HT40_CHANNELS, 326 EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
327 EEPROM_5000_REG_BAND_52_HT40_CHANNELS 327 EEPROM_5000_REG_BAND_52_HT40_CHANNELS
328 }, 328 },
329 .verify_signature = iwlcore_eeprom_verify_signature, 329 .verify_signature = iwlcore_eeprom_verify_signature,
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
index 8bf7c20b9d3..1460116d329 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
@@ -26,6 +26,7 @@
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/skbuff.h> 28#include <linux/skbuff.h>
29#include <linux/slab.h>
29#include <linux/wireless.h> 30#include <linux/wireless.h>
30#include <net/mac80211.h> 31#include <net/mac80211.h>
31 32
@@ -345,6 +346,17 @@ static inline int get_num_of_ant_from_rate(u32 rate_n_flags)
345 !!(rate_n_flags & RATE_MCS_ANT_C_MSK); 346 !!(rate_n_flags & RATE_MCS_ANT_C_MSK);
346} 347}
347 348
349/*
350 * Static function to get the expected throughput from an iwl_scale_tbl_info
351 * that wraps a NULL pointer check
352 */
353static s32 get_expected_tpt(struct iwl_scale_tbl_info *tbl, int rs_index)
354{
355 if (tbl->expected_tpt)
356 return tbl->expected_tpt[rs_index];
357 return 0;
358}
359
348/** 360/**
349 * rs_collect_tx_data - Update the success/failure sliding window 361 * rs_collect_tx_data - Update the success/failure sliding window
350 * 362 *
@@ -352,19 +364,21 @@ static inline int get_num_of_ant_from_rate(u32 rate_n_flags)
352 * at this rate. window->data contains the bitmask of successful 364 * at this rate. window->data contains the bitmask of successful
353 * packets. 365 * packets.
354 */ 366 */
355static int rs_collect_tx_data(struct iwl_rate_scale_data *windows, 367static int rs_collect_tx_data(struct iwl_scale_tbl_info *tbl,
356 int scale_index, s32 tpt, int attempts, 368 int scale_index, int attempts, int successes)
357 int successes)
358{ 369{
359 struct iwl_rate_scale_data *window = NULL; 370 struct iwl_rate_scale_data *window = NULL;
360 static const u64 mask = (((u64)1) << (IWL_RATE_MAX_WINDOW - 1)); 371 static const u64 mask = (((u64)1) << (IWL_RATE_MAX_WINDOW - 1));
361 s32 fail_count; 372 s32 fail_count, tpt;
362 373
363 if (scale_index < 0 || scale_index >= IWL_RATE_COUNT) 374 if (scale_index < 0 || scale_index >= IWL_RATE_COUNT)
364 return -EINVAL; 375 return -EINVAL;
365 376
366 /* Select window for current tx bit rate */ 377 /* Select window for current tx bit rate */
367 window = &(windows[scale_index]); 378 window = &(tbl->win[scale_index]);
379
380 /* Get expected throughput */
381 tpt = get_expected_tpt(tbl, scale_index);
368 382
369 /* 383 /*
370 * Keep track of only the latest 62 tx frame attempts in this rate's 384 * Keep track of only the latest 62 tx frame attempts in this rate's
@@ -738,16 +752,6 @@ static bool table_type_matches(struct iwl_scale_tbl_info *a,
738 return (a->lq_type == b->lq_type) && (a->ant_type == b->ant_type) && 752 return (a->lq_type == b->lq_type) && (a->ant_type == b->ant_type) &&
739 (a->is_SGI == b->is_SGI); 753 (a->is_SGI == b->is_SGI);
740} 754}
741/*
742 * Static function to get the expected throughput from an iwl_scale_tbl_info
743 * that wraps a NULL pointer check
744 */
745static s32 get_expected_tpt(struct iwl_scale_tbl_info *tbl, int rs_index)
746{
747 if (tbl->expected_tpt)
748 return tbl->expected_tpt[rs_index];
749 return 0;
750}
751 755
752/* 756/*
753 * mac80211 sends us Tx status 757 * mac80211 sends us Tx status
@@ -764,12 +768,10 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband,
764 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 768 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
765 struct iwl_priv *priv = (struct iwl_priv *)priv_r; 769 struct iwl_priv *priv = (struct iwl_priv *)priv_r;
766 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 770 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
767 struct iwl_rate_scale_data *window = NULL;
768 enum mac80211_rate_control_flags mac_flags; 771 enum mac80211_rate_control_flags mac_flags;
769 u32 tx_rate; 772 u32 tx_rate;
770 struct iwl_scale_tbl_info tbl_type; 773 struct iwl_scale_tbl_info tbl_type;
771 struct iwl_scale_tbl_info *curr_tbl, *other_tbl; 774 struct iwl_scale_tbl_info *curr_tbl, *other_tbl, *tmp_tbl;
772 s32 tpt = 0;
773 775
774 IWL_DEBUG_RATE_LIMIT(priv, "get frame ack response, update rate scale window\n"); 776 IWL_DEBUG_RATE_LIMIT(priv, "get frame ack response, update rate scale window\n");
775 777
@@ -852,7 +854,6 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband,
852 IWL_DEBUG_RATE(priv, "Neither active nor search matches tx rate\n"); 854 IWL_DEBUG_RATE(priv, "Neither active nor search matches tx rate\n");
853 return; 855 return;
854 } 856 }
855 window = (struct iwl_rate_scale_data *)&(curr_tbl->win[0]);
856 857
857 /* 858 /*
858 * Updating the frame history depends on whether packets were 859 * Updating the frame history depends on whether packets were
@@ -865,8 +866,7 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband,
865 tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); 866 tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags);
866 rs_get_tbl_info_from_mcs(tx_rate, priv->band, &tbl_type, 867 rs_get_tbl_info_from_mcs(tx_rate, priv->band, &tbl_type,
867 &rs_index); 868 &rs_index);
868 tpt = get_expected_tpt(curr_tbl, rs_index); 869 rs_collect_tx_data(curr_tbl, rs_index,
869 rs_collect_tx_data(window, rs_index, tpt,
870 info->status.ampdu_ack_len, 870 info->status.ampdu_ack_len,
871 info->status.ampdu_ack_map); 871 info->status.ampdu_ack_map);
872 872
@@ -896,19 +896,13 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband,
896 * table as active/search. 896 * table as active/search.
897 */ 897 */
898 if (table_type_matches(&tbl_type, curr_tbl)) 898 if (table_type_matches(&tbl_type, curr_tbl))
899 tpt = get_expected_tpt(curr_tbl, rs_index); 899 tmp_tbl = curr_tbl;
900 else if (table_type_matches(&tbl_type, other_tbl)) 900 else if (table_type_matches(&tbl_type, other_tbl))
901 tpt = get_expected_tpt(other_tbl, rs_index); 901 tmp_tbl = other_tbl;
902 else 902 else
903 continue; 903 continue;
904 904 rs_collect_tx_data(tmp_tbl, rs_index, 1,
905 /* Constants mean 1 transmission, 0 successes */ 905 i < retries ? 0 : legacy_success);
906 if (i < retries)
907 rs_collect_tx_data(window, rs_index, tpt, 1,
908 0);
909 else
910 rs_collect_tx_data(window, rs_index, tpt, 1,
911 legacy_success);
912 } 906 }
913 907
914 /* Update success/fail counts if not searching for new mode */ 908 /* Update success/fail counts if not searching for new mode */
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 818367b57ba..bdff56583e1 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -31,6 +31,7 @@
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/pci.h> 33#include <linux/pci.h>
34#include <linux/slab.h>
34#include <linux/dma-mapping.h> 35#include <linux/dma-mapping.h>
35#include <linux/delay.h> 36#include <linux/delay.h>
36#include <linux/sched.h> 37#include <linux/sched.h>
@@ -1258,7 +1259,15 @@ static void iwl_irq_tasklet(struct iwl_priv *priv)
1258 /* Ack/clear/reset pending uCode interrupts. 1259 /* Ack/clear/reset pending uCode interrupts.
1259 * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS, 1260 * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS,
1260 */ 1261 */
1261 iwl_write32(priv, CSR_INT, priv->inta); 1262 /* There is a hardware bug in the interrupt mask function that some
1263 * interrupts (i.e. CSR_INT_BIT_SCD) can still be generated even if
1264 * they are disabled in the CSR_INT_MASK register. Furthermore the
1265 * ICT interrupt handling mechanism has another bug that might cause
1266 * these unmasked interrupts fail to be detected. We workaround the
1267 * hardware bugs here by ACKing all the possible interrupts so that
1268 * interrupt coalescing can still be achieved.
1269 */
1270 iwl_write32(priv, CSR_INT, priv->inta | ~priv->inta_mask);
1262 1271
1263 inta = priv->inta; 1272 inta = priv->inta;
1264 1273
@@ -2644,7 +2653,7 @@ static int iwl_mac_setup_register(struct iwl_priv *priv)
2644 BIT(NL80211_IFTYPE_STATION) | 2653 BIT(NL80211_IFTYPE_STATION) |
2645 BIT(NL80211_IFTYPE_ADHOC); 2654 BIT(NL80211_IFTYPE_ADHOC);
2646 2655
2647 hw->wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY | 2656 hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY |
2648 WIPHY_FLAG_DISABLE_BEACON_HINTS; 2657 WIPHY_FLAG_DISABLE_BEACON_HINTS;
2649 2658
2650 /* 2659 /*
@@ -3322,6 +3331,7 @@ static void iwl_cancel_deferred_work(struct iwl_priv *priv)
3322 3331
3323 cancel_delayed_work_sync(&priv->init_alive_start); 3332 cancel_delayed_work_sync(&priv->init_alive_start);
3324 cancel_delayed_work(&priv->scan_check); 3333 cancel_delayed_work(&priv->scan_check);
3334 cancel_work_sync(&priv->start_internal_scan);
3325 cancel_delayed_work(&priv->alive_start); 3335 cancel_delayed_work(&priv->alive_start);
3326 cancel_work_sync(&priv->beacon_update); 3336 cancel_work_sync(&priv->beacon_update);
3327 del_timer_sync(&priv->statistics_periodic); 3337 del_timer_sync(&priv->statistics_periodic);
diff --git a/drivers/net/wireless/iwlwifi/iwl-calib.c b/drivers/net/wireless/iwlwifi/iwl-calib.c
index 845831ac053..8b516c5ff0b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-calib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-calib.c
@@ -60,6 +60,7 @@
60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61 *****************************************************************************/ 61 *****************************************************************************/
62 62
63#include <linux/slab.h>
63#include <net/mac80211.h> 64#include <net/mac80211.h>
64 65
65#include "iwl-dev.h" 66#include "iwl-dev.h"
@@ -807,6 +808,18 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv,
807 } 808 }
808 } 809 }
809 810
811 /*
812 * The above algorithm sometimes fails when the ucode
813 * reports 0 for all chains. It's not clear why that
814 * happens to start with, but it is then causing trouble
815 * because this can make us enable more chains than the
816 * hardware really has.
817 *
818 * To be safe, simply mask out any chains that we know
819 * are not on the device.
820 */
821 active_chains &= priv->hw_params.valid_rx_ant;
822
810 num_tx_chains = 0; 823 num_tx_chains = 0;
811 for (i = 0; i < NUM_RX_CHAINS; i++) { 824 for (i = 0; i < NUM_RX_CHAINS; i++) {
812 /* loops on all the bits of 825 /* loops on all the bits of
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 112149e9b31..049b652bcb5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -30,6 +30,7 @@
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/etherdevice.h> 31#include <linux/etherdevice.h>
32#include <linux/sched.h> 32#include <linux/sched.h>
33#include <linux/slab.h>
33#include <net/mac80211.h> 34#include <net/mac80211.h>
34 35
35#include "iwl-eeprom.h" 36#include "iwl-eeprom.h"
@@ -307,10 +308,13 @@ int iwl_hw_nic_init(struct iwl_priv *priv)
307 308
308 spin_unlock_irqrestore(&priv->lock, flags); 309 spin_unlock_irqrestore(&priv->lock, flags);
309 310
310 /* Allocate and init all Tx and Command queues */ 311 /* Allocate or reset and init all Tx and Command queues */
311 ret = iwl_txq_ctx_reset(priv); 312 if (!priv->txq) {
312 if (ret) 313 ret = iwl_txq_ctx_alloc(priv);
313 return ret; 314 if (ret)
315 return ret;
316 } else
317 iwl_txq_ctx_reset(priv);
314 318
315 set_bit(STATUS_INIT, &priv->status); 319 set_bit(STATUS_INIT, &priv->status);
316 320
@@ -3354,7 +3358,6 @@ static void iwl_force_rf_reset(struct iwl_priv *priv)
3354 */ 3358 */
3355 IWL_DEBUG_INFO(priv, "perform radio reset.\n"); 3359 IWL_DEBUG_INFO(priv, "perform radio reset.\n");
3356 iwl_internal_short_hw_scan(priv); 3360 iwl_internal_short_hw_scan(priv);
3357 return;
3358} 3361}
3359 3362
3360 3363
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index 4ef7739f9e8..36940a9ec6b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -442,7 +442,8 @@ void iwl_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb);
442/***************************************************** 442/*****************************************************
443* TX 443* TX
444******************************************************/ 444******************************************************/
445int iwl_txq_ctx_reset(struct iwl_priv *priv); 445int iwl_txq_ctx_alloc(struct iwl_priv *priv);
446void iwl_txq_ctx_reset(struct iwl_priv *priv);
446void iwl_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq); 447void iwl_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq);
447int iwl_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, 448int iwl_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv,
448 struct iwl_tx_queue *txq, 449 struct iwl_tx_queue *txq,
@@ -456,6 +457,8 @@ void iwl_free_tfds_in_queue(struct iwl_priv *priv,
456void iwl_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq); 457void iwl_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq);
457int iwl_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq, 458int iwl_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq,
458 int slots_num, u32 txq_id); 459 int slots_num, u32 txq_id);
460void iwl_tx_queue_reset(struct iwl_priv *priv, struct iwl_tx_queue *txq,
461 int slots_num, u32 txq_id);
459void iwl_tx_queue_free(struct iwl_priv *priv, int txq_id); 462void iwl_tx_queue_free(struct iwl_priv *priv, int txq_id);
460int iwl_tx_agg_start(struct iwl_priv *priv, const u8 *ra, u16 tid, u16 *ssn); 463int iwl_tx_agg_start(struct iwl_priv *priv, const u8 *ra, u16 tid, u16 *ssn);
461int iwl_tx_agg_stop(struct iwl_priv *priv , const u8 *ra, u16 tid); 464int iwl_tx_agg_stop(struct iwl_priv *priv , const u8 *ra, u16 tid);
@@ -503,7 +506,7 @@ void iwl_init_scan_params(struct iwl_priv *priv);
503int iwl_scan_cancel(struct iwl_priv *priv); 506int iwl_scan_cancel(struct iwl_priv *priv);
504int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms); 507int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms);
505int iwl_mac_hw_scan(struct ieee80211_hw *hw, struct cfg80211_scan_request *req); 508int iwl_mac_hw_scan(struct ieee80211_hw *hw, struct cfg80211_scan_request *req);
506int iwl_internal_short_hw_scan(struct iwl_priv *priv); 509void iwl_internal_short_hw_scan(struct iwl_priv *priv);
507int iwl_force_reset(struct iwl_priv *priv, int mode); 510int iwl_force_reset(struct iwl_priv *priv, int mode);
508u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame, 511u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame,
509 const u8 *ie, int ie_len, int left); 512 const u8 *ie, int ie_len, int left);
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
index 7bf44f14679..b6e1b0ebe23 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
@@ -26,6 +26,7 @@
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *****************************************************************************/ 27 *****************************************************************************/
28 28
29#include <linux/slab.h>
29#include <linux/kernel.h> 30#include <linux/kernel.h>
30#include <linux/module.h> 31#include <linux/module.h>
31#include <linux/debugfs.h> 32#include <linux/debugfs.h>
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index 6054c5fba0c..ef1720a852e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -1296,6 +1296,7 @@ struct iwl_priv {
1296 struct work_struct tt_work; 1296 struct work_struct tt_work;
1297 struct work_struct ct_enter; 1297 struct work_struct ct_enter;
1298 struct work_struct ct_exit; 1298 struct work_struct ct_exit;
1299 struct work_struct start_internal_scan;
1299 1300
1300 struct tasklet_struct irq_tasklet; 1301 struct tasklet_struct irq_tasklet;
1301 1302
diff --git a/drivers/net/wireless/iwlwifi/iwl-devtrace.c b/drivers/net/wireless/iwlwifi/iwl-devtrace.c
index 36580d8d8b8..2ffc2edbf4f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-devtrace.c
+++ b/drivers/net/wireless/iwlwifi/iwl-devtrace.c
@@ -28,6 +28,8 @@
28 28
29/* sparse doesn't like tracepoint macros */ 29/* sparse doesn't like tracepoint macros */
30#ifndef __CHECKER__ 30#ifndef __CHECKER__
31#include "iwl-dev.h"
32
31#define CREATE_TRACE_POINTS 33#define CREATE_TRACE_POINTS
32#include "iwl-devtrace.h" 34#include "iwl-devtrace.h"
33 35
diff --git a/drivers/net/wireless/iwlwifi/iwl-devtrace.h b/drivers/net/wireless/iwlwifi/iwl-devtrace.h
index ff4d012ce26..ae7319bb3a9 100644
--- a/drivers/net/wireless/iwlwifi/iwl-devtrace.h
+++ b/drivers/net/wireless/iwlwifi/iwl-devtrace.h
@@ -28,7 +28,6 @@
28#define __IWLWIFI_DEVICE_TRACE 28#define __IWLWIFI_DEVICE_TRACE
29 29
30#include <linux/tracepoint.h> 30#include <linux/tracepoint.h>
31#include "iwl-dev.h"
32 31
33#if !defined(CONFIG_IWLWIFI_DEVICE_TRACING) || defined(__CHECKER__) 32#if !defined(CONFIG_IWLWIFI_DEVICE_TRACING) || defined(__CHECKER__)
34#undef TRACE_EVENT 33#undef TRACE_EVENT
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
index fd37152abae..fb5bb487f3b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c
@@ -63,6 +63,7 @@
63 63
64#include <linux/kernel.h> 64#include <linux/kernel.h>
65#include <linux/module.h> 65#include <linux/module.h>
66#include <linux/slab.h>
66#include <linux/init.h> 67#include <linux/init.h>
67 68
68#include <net/mac80211.h> 69#include <net/mac80211.h>
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.h b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
index 4e1ba824dc5..8171c701e4e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.h
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
@@ -203,6 +203,10 @@ struct iwl_eeprom_enhanced_txpwr {
203#define EEPROM_5000_REG_BAND_52_HT40_CHANNELS ((0x92)\ 203#define EEPROM_5000_REG_BAND_52_HT40_CHANNELS ((0x92)\
204 | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 22 bytes */ 204 | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 22 bytes */
205 205
206/* 6000 regulatory - indirect access */
207#define EEPROM_6000_REG_BAND_24_HT40_CHANNELS ((0x80)\
208 | INDIRECT_ADDRESS | INDIRECT_REGULATORY) /* 14 bytes */
209
206/* 6000 and up regulatory tx power - indirect access */ 210/* 6000 and up regulatory tx power - indirect access */
207/* max. elements per section */ 211/* max. elements per section */
208#define EEPROM_MAX_TXPOWER_SECTION_ELEMENTS (8) 212#define EEPROM_MAX_TXPOWER_SECTION_ELEMENTS (8)
diff --git a/drivers/net/wireless/iwlwifi/iwl-io.h b/drivers/net/wireless/iwlwifi/iwl-io.h
index c719baf2585..16eb3ced9b3 100644
--- a/drivers/net/wireless/iwlwifi/iwl-io.h
+++ b/drivers/net/wireless/iwlwifi/iwl-io.h
@@ -31,6 +31,7 @@
31 31
32#include <linux/io.h> 32#include <linux/io.h>
33 33
34#include "iwl-dev.h"
34#include "iwl-debug.h" 35#include "iwl-debug.h"
35#include "iwl-devtrace.h" 36#include "iwl-devtrace.h"
36 37
diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c
index 1a1a9f081cc..548dac2f6a9 100644
--- a/drivers/net/wireless/iwlwifi/iwl-power.c
+++ b/drivers/net/wireless/iwlwifi/iwl-power.c
@@ -29,6 +29,7 @@
29 29
30#include <linux/kernel.h> 30#include <linux/kernel.h>
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/slab.h>
32#include <linux/init.h> 33#include <linux/init.h>
33 34
34#include <net/mac80211.h> 35#include <net/mac80211.h>
diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c
index df257bc15f4..e5eb339107d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-rx.c
@@ -28,6 +28,7 @@
28 *****************************************************************************/ 28 *****************************************************************************/
29 29
30#include <linux/etherdevice.h> 30#include <linux/etherdevice.h>
31#include <linux/slab.h>
31#include <net/mac80211.h> 32#include <net/mac80211.h>
32#include <asm/unaligned.h> 33#include <asm/unaligned.h>
33#include "iwl-eeprom.h" 34#include "iwl-eeprom.h"
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index bd2f7c42056..12e455a4b90 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -25,6 +25,7 @@
25 * Intel Linux Wireless <ilw@linux.intel.com> 25 * Intel Linux Wireless <ilw@linux.intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *****************************************************************************/ 27 *****************************************************************************/
28#include <linux/slab.h>
28#include <linux/types.h> 29#include <linux/types.h>
29#include <linux/etherdevice.h> 30#include <linux/etherdevice.h>
30#include <net/mac80211.h> 31#include <net/mac80211.h>
@@ -469,6 +470,8 @@ EXPORT_SYMBOL(iwl_init_scan_params);
469 470
470static int iwl_scan_initiate(struct iwl_priv *priv) 471static int iwl_scan_initiate(struct iwl_priv *priv)
471{ 472{
473 WARN_ON(!mutex_is_locked(&priv->mutex));
474
472 IWL_DEBUG_INFO(priv, "Starting scan...\n"); 475 IWL_DEBUG_INFO(priv, "Starting scan...\n");
473 set_bit(STATUS_SCANNING, &priv->status); 476 set_bit(STATUS_SCANNING, &priv->status);
474 priv->is_internal_short_scan = false; 477 priv->is_internal_short_scan = false;
@@ -546,24 +549,31 @@ EXPORT_SYMBOL(iwl_mac_hw_scan);
546 * internal short scan, this function should only been called while associated. 549 * internal short scan, this function should only been called while associated.
547 * It will reset and tune the radio to prevent possible RF related problem 550 * It will reset and tune the radio to prevent possible RF related problem
548 */ 551 */
549int iwl_internal_short_hw_scan(struct iwl_priv *priv) 552void iwl_internal_short_hw_scan(struct iwl_priv *priv)
550{ 553{
551 int ret = 0; 554 queue_work(priv->workqueue, &priv->start_internal_scan);
555}
556
557static void iwl_bg_start_internal_scan(struct work_struct *work)
558{
559 struct iwl_priv *priv =
560 container_of(work, struct iwl_priv, start_internal_scan);
561
562 mutex_lock(&priv->mutex);
552 563
553 if (!iwl_is_ready_rf(priv)) { 564 if (!iwl_is_ready_rf(priv)) {
554 ret = -EIO;
555 IWL_DEBUG_SCAN(priv, "not ready or exit pending\n"); 565 IWL_DEBUG_SCAN(priv, "not ready or exit pending\n");
556 goto out; 566 goto unlock;
557 } 567 }
568
558 if (test_bit(STATUS_SCANNING, &priv->status)) { 569 if (test_bit(STATUS_SCANNING, &priv->status)) {
559 IWL_DEBUG_SCAN(priv, "Scan already in progress.\n"); 570 IWL_DEBUG_SCAN(priv, "Scan already in progress.\n");
560 ret = -EAGAIN; 571 goto unlock;
561 goto out;
562 } 572 }
573
563 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { 574 if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) {
564 IWL_DEBUG_SCAN(priv, "Scan request while abort pending\n"); 575 IWL_DEBUG_SCAN(priv, "Scan request while abort pending\n");
565 ret = -EAGAIN; 576 goto unlock;
566 goto out;
567 } 577 }
568 578
569 priv->scan_bands = 0; 579 priv->scan_bands = 0;
@@ -576,9 +586,8 @@ int iwl_internal_short_hw_scan(struct iwl_priv *priv)
576 set_bit(STATUS_SCANNING, &priv->status); 586 set_bit(STATUS_SCANNING, &priv->status);
577 priv->is_internal_short_scan = true; 587 priv->is_internal_short_scan = true;
578 queue_work(priv->workqueue, &priv->request_scan); 588 queue_work(priv->workqueue, &priv->request_scan);
579 589 unlock:
580out: 590 mutex_unlock(&priv->mutex);
581 return ret;
582} 591}
583EXPORT_SYMBOL(iwl_internal_short_hw_scan); 592EXPORT_SYMBOL(iwl_internal_short_hw_scan);
584 593
@@ -964,6 +973,7 @@ void iwl_setup_scan_deferred_work(struct iwl_priv *priv)
964 INIT_WORK(&priv->scan_completed, iwl_bg_scan_completed); 973 INIT_WORK(&priv->scan_completed, iwl_bg_scan_completed);
965 INIT_WORK(&priv->request_scan, iwl_bg_request_scan); 974 INIT_WORK(&priv->request_scan, iwl_bg_request_scan);
966 INIT_WORK(&priv->abort_scan, iwl_bg_abort_scan); 975 INIT_WORK(&priv->abort_scan, iwl_bg_abort_scan);
976 INIT_WORK(&priv->start_internal_scan, iwl_bg_start_internal_scan);
967 INIT_DELAYED_WORK(&priv->scan_check, iwl_bg_scan_check); 977 INIT_DELAYED_WORK(&priv->scan_check, iwl_bg_scan_check);
968} 978}
969EXPORT_SYMBOL(iwl_setup_scan_deferred_work); 979EXPORT_SYMBOL(iwl_setup_scan_deferred_work);
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c
index 1ed5206721e..8dd0c036d54 100644
--- a/drivers/net/wireless/iwlwifi/iwl-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
@@ -29,6 +29,7 @@
29 29
30#include <linux/etherdevice.h> 30#include <linux/etherdevice.h>
31#include <linux/sched.h> 31#include <linux/sched.h>
32#include <linux/slab.h>
32#include <net/mac80211.h> 33#include <net/mac80211.h>
33#include "iwl-eeprom.h" 34#include "iwl-eeprom.h"
34#include "iwl-dev.h" 35#include "iwl-dev.h"
@@ -124,7 +125,7 @@ void iwl_free_tfds_in_queue(struct iwl_priv *priv,
124 if (priv->stations[sta_id].tid[tid].tfds_in_queue >= freed) 125 if (priv->stations[sta_id].tid[tid].tfds_in_queue >= freed)
125 priv->stations[sta_id].tid[tid].tfds_in_queue -= freed; 126 priv->stations[sta_id].tid[tid].tfds_in_queue -= freed;
126 else { 127 else {
127 IWL_ERR(priv, "free more than tfds_in_queue (%u:%d)\n", 128 IWL_DEBUG_TX(priv, "free more than tfds_in_queue (%u:%d)\n",
128 priv->stations[sta_id].tid[tid].tfds_in_queue, 129 priv->stations[sta_id].tid[tid].tfds_in_queue,
129 freed); 130 freed);
130 priv->stations[sta_id].tid[tid].tfds_in_queue = 0; 131 priv->stations[sta_id].tid[tid].tfds_in_queue = 0;
@@ -193,10 +194,34 @@ void iwl_cmd_queue_free(struct iwl_priv *priv)
193 struct iwl_queue *q = &txq->q; 194 struct iwl_queue *q = &txq->q;
194 struct device *dev = &priv->pci_dev->dev; 195 struct device *dev = &priv->pci_dev->dev;
195 int i; 196 int i;
197 bool huge = false;
196 198
197 if (q->n_bd == 0) 199 if (q->n_bd == 0)
198 return; 200 return;
199 201
202 for (; q->read_ptr != q->write_ptr;
203 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) {
204 /* we have no way to tell if it is a huge cmd ATM */
205 i = get_cmd_index(q, q->read_ptr, 0);
206
207 if (txq->meta[i].flags & CMD_SIZE_HUGE) {
208 huge = true;
209 continue;
210 }
211
212 pci_unmap_single(priv->pci_dev,
213 pci_unmap_addr(&txq->meta[i], mapping),
214 pci_unmap_len(&txq->meta[i], len),
215 PCI_DMA_BIDIRECTIONAL);
216 }
217 if (huge) {
218 i = q->n_window;
219 pci_unmap_single(priv->pci_dev,
220 pci_unmap_addr(&txq->meta[i], mapping),
221 pci_unmap_len(&txq->meta[i], len),
222 PCI_DMA_BIDIRECTIONAL);
223 }
224
200 /* De-alloc array of command/tx buffers */ 225 /* De-alloc array of command/tx buffers */
201 for (i = 0; i <= TFD_CMD_SLOTS; i++) 226 for (i = 0; i <= TFD_CMD_SLOTS; i++)
202 kfree(txq->cmd[i]); 227 kfree(txq->cmd[i]);
@@ -409,6 +434,26 @@ out_free_arrays:
409} 434}
410EXPORT_SYMBOL(iwl_tx_queue_init); 435EXPORT_SYMBOL(iwl_tx_queue_init);
411 436
437void iwl_tx_queue_reset(struct iwl_priv *priv, struct iwl_tx_queue *txq,
438 int slots_num, u32 txq_id)
439{
440 int actual_slots = slots_num;
441
442 if (txq_id == IWL_CMD_QUEUE_NUM)
443 actual_slots++;
444
445 memset(txq->meta, 0, sizeof(struct iwl_cmd_meta) * actual_slots);
446
447 txq->need_update = 0;
448
449 /* Initialize queue's high/low-water marks, and head/tail indexes */
450 iwl_queue_init(priv, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id);
451
452 /* Tell device where to find queue */
453 priv->cfg->ops->lib->txq_init(priv, txq);
454}
455EXPORT_SYMBOL(iwl_tx_queue_reset);
456
412/** 457/**
413 * iwl_hw_txq_ctx_free - Free TXQ Context 458 * iwl_hw_txq_ctx_free - Free TXQ Context
414 * 459 *
@@ -420,8 +465,7 @@ void iwl_hw_txq_ctx_free(struct iwl_priv *priv)
420 465
421 /* Tx queues */ 466 /* Tx queues */
422 if (priv->txq) { 467 if (priv->txq) {
423 for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; 468 for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++)
424 txq_id++)
425 if (txq_id == IWL_CMD_QUEUE_NUM) 469 if (txq_id == IWL_CMD_QUEUE_NUM)
426 iwl_cmd_queue_free(priv); 470 iwl_cmd_queue_free(priv);
427 else 471 else
@@ -437,15 +481,15 @@ void iwl_hw_txq_ctx_free(struct iwl_priv *priv)
437EXPORT_SYMBOL(iwl_hw_txq_ctx_free); 481EXPORT_SYMBOL(iwl_hw_txq_ctx_free);
438 482
439/** 483/**
440 * iwl_txq_ctx_reset - Reset TX queue context 484 * iwl_txq_ctx_alloc - allocate TX queue context
441 * Destroys all DMA structures and initialize them again 485 * Allocate all Tx DMA structures and initialize them
442 * 486 *
443 * @param priv 487 * @param priv
444 * @return error code 488 * @return error code
445 */ 489 */
446int iwl_txq_ctx_reset(struct iwl_priv *priv) 490int iwl_txq_ctx_alloc(struct iwl_priv *priv)
447{ 491{
448 int ret = 0; 492 int ret;
449 int txq_id, slots_num; 493 int txq_id, slots_num;
450 unsigned long flags; 494 unsigned long flags;
451 495
@@ -503,8 +547,31 @@ int iwl_txq_ctx_reset(struct iwl_priv *priv)
503 return ret; 547 return ret;
504} 548}
505 549
550void iwl_txq_ctx_reset(struct iwl_priv *priv)
551{
552 int txq_id, slots_num;
553 unsigned long flags;
554
555 spin_lock_irqsave(&priv->lock, flags);
556
557 /* Turn off all Tx DMA fifos */
558 priv->cfg->ops->lib->txq_set_sched(priv, 0);
559
560 /* Tell NIC where to find the "keep warm" buffer */
561 iwl_write_direct32(priv, FH_KW_MEM_ADDR_REG, priv->kw.dma >> 4);
562
563 spin_unlock_irqrestore(&priv->lock, flags);
564
565 /* Alloc and init all Tx queues, including the command queue (#4) */
566 for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) {
567 slots_num = txq_id == IWL_CMD_QUEUE_NUM ?
568 TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS;
569 iwl_tx_queue_reset(priv, &priv->txq[txq_id], slots_num, txq_id);
570 }
571}
572
506/** 573/**
507 * iwl_txq_ctx_stop - Stop all Tx DMA channels, free Tx queue memory 574 * iwl_txq_ctx_stop - Stop all Tx DMA channels
508 */ 575 */
509void iwl_txq_ctx_stop(struct iwl_priv *priv) 576void iwl_txq_ctx_stop(struct iwl_priv *priv)
510{ 577{
@@ -524,9 +591,6 @@ void iwl_txq_ctx_stop(struct iwl_priv *priv)
524 1000); 591 1000);
525 } 592 }
526 spin_unlock_irqrestore(&priv->lock, flags); 593 spin_unlock_irqrestore(&priv->lock, flags);
527
528 /* Deallocate memory for all Tx queues */
529 iwl_hw_txq_ctx_free(priv);
530} 594}
531EXPORT_SYMBOL(iwl_txq_ctx_stop); 595EXPORT_SYMBOL(iwl_txq_ctx_stop);
532 596
@@ -1049,6 +1113,14 @@ int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
1049 1113
1050 spin_lock_irqsave(&priv->hcmd_lock, flags); 1114 spin_lock_irqsave(&priv->hcmd_lock, flags);
1051 1115
1116 /* If this is a huge cmd, mark the huge flag also on the meta.flags
1117 * of the _original_ cmd. This is used for DMA mapping clean up.
1118 */
1119 if (cmd->flags & CMD_SIZE_HUGE) {
1120 idx = get_cmd_index(q, q->write_ptr, 0);
1121 txq->meta[idx].flags = CMD_SIZE_HUGE;
1122 }
1123
1052 idx = get_cmd_index(q, q->write_ptr, cmd->flags & CMD_SIZE_HUGE); 1124 idx = get_cmd_index(q, q->write_ptr, cmd->flags & CMD_SIZE_HUGE);
1053 out_cmd = txq->cmd[idx]; 1125 out_cmd = txq->cmd[idx];
1054 out_meta = &txq->meta[idx]; 1126 out_meta = &txq->meta[idx];
@@ -1226,6 +1298,7 @@ void iwl_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
1226 bool huge = !!(pkt->hdr.sequence & SEQ_HUGE_FRAME); 1298 bool huge = !!(pkt->hdr.sequence & SEQ_HUGE_FRAME);
1227 struct iwl_device_cmd *cmd; 1299 struct iwl_device_cmd *cmd;
1228 struct iwl_cmd_meta *meta; 1300 struct iwl_cmd_meta *meta;
1301 struct iwl_tx_queue *txq = &priv->txq[IWL_CMD_QUEUE_NUM];
1229 1302
1230 /* If a Tx command is being handled and it isn't in the actual 1303 /* If a Tx command is being handled and it isn't in the actual
1231 * command queue then there a command routing bug has been introduced 1304 * command queue then there a command routing bug has been introduced
@@ -1239,9 +1312,17 @@ void iwl_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
1239 return; 1312 return;
1240 } 1313 }
1241 1314
1242 cmd_index = get_cmd_index(&priv->txq[IWL_CMD_QUEUE_NUM].q, index, huge); 1315 /* If this is a huge cmd, clear the huge flag on the meta.flags
1243 cmd = priv->txq[IWL_CMD_QUEUE_NUM].cmd[cmd_index]; 1316 * of the _original_ cmd. So that iwl_cmd_queue_free won't unmap
1244 meta = &priv->txq[IWL_CMD_QUEUE_NUM].meta[cmd_index]; 1317 * the DMA buffer for the scan (huge) command.
1318 */
1319 if (huge) {
1320 cmd_index = get_cmd_index(&txq->q, index, 0);
1321 txq->meta[cmd_index].flags = 0;
1322 }
1323 cmd_index = get_cmd_index(&txq->q, index, huge);
1324 cmd = txq->cmd[cmd_index];
1325 meta = &txq->meta[cmd_index];
1245 1326
1246 pci_unmap_single(priv->pci_dev, 1327 pci_unmap_single(priv->pci_dev,
1247 pci_unmap_addr(meta, mapping), 1328 pci_unmap_addr(meta, mapping),
@@ -1263,6 +1344,7 @@ void iwl_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
1263 get_cmd_string(cmd->hdr.cmd)); 1344 get_cmd_string(cmd->hdr.cmd));
1264 wake_up_interruptible(&priv->wait_command_queue); 1345 wake_up_interruptible(&priv->wait_command_queue);
1265 } 1346 }
1347 meta->flags = 0;
1266} 1348}
1267EXPORT_SYMBOL(iwl_tx_cmd_complete); 1349EXPORT_SYMBOL(iwl_tx_cmd_complete);
1268 1350
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 54daa38ecba..b55e4f39a9e 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -31,6 +31,7 @@
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/pci.h> 33#include <linux/pci.h>
34#include <linux/slab.h>
34#include <linux/dma-mapping.h> 35#include <linux/dma-mapping.h>
35#include <linux/delay.h> 36#include <linux/delay.h>
36#include <linux/sched.h> 37#include <linux/sched.h>
@@ -1955,7 +1956,7 @@ static void iwl3945_init_hw_rates(struct iwl_priv *priv,
1955{ 1956{
1956 int i; 1957 int i;
1957 1958
1958 for (i = 0; i < IWL_RATE_COUNT; i++) { 1959 for (i = 0; i < IWL_RATE_COUNT_LEGACY; i++) {
1959 rates[i].bitrate = iwl3945_rates[i].ieee * 5; 1960 rates[i].bitrate = iwl3945_rates[i].ieee * 5;
1960 rates[i].hw_value = i; /* Rate scaling will work on indexes */ 1961 rates[i].hw_value = i; /* Rate scaling will work on indexes */
1961 rates[i].hw_value_short = i; 1962 rates[i].hw_value_short = i;
@@ -3921,7 +3922,7 @@ static int iwl3945_setup_mac(struct iwl_priv *priv)
3921 BIT(NL80211_IFTYPE_STATION) | 3922 BIT(NL80211_IFTYPE_STATION) |
3922 BIT(NL80211_IFTYPE_ADHOC); 3923 BIT(NL80211_IFTYPE_ADHOC);
3923 3924
3924 hw->wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY | 3925 hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY |
3925 WIPHY_FLAG_DISABLE_BEACON_HINTS; 3926 WIPHY_FLAG_DISABLE_BEACON_HINTS;
3926 3927
3927 hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX_3945; 3928 hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX_3945;
diff --git a/drivers/net/wireless/iwmc3200wifi/cfg80211.c b/drivers/net/wireless/iwmc3200wifi/cfg80211.c
index 7c4f44a9c3e..a1d45cce0eb 100644
--- a/drivers/net/wireless/iwmc3200wifi/cfg80211.c
+++ b/drivers/net/wireless/iwmc3200wifi/cfg80211.c
@@ -27,6 +27,7 @@
27#include <linux/etherdevice.h> 27#include <linux/etherdevice.h>
28#include <linux/wireless.h> 28#include <linux/wireless.h>
29#include <linux/ieee80211.h> 29#include <linux/ieee80211.h>
30#include <linux/slab.h>
30#include <net/cfg80211.h> 31#include <net/cfg80211.h>
31 32
32#include "iwm.h" 33#include "iwm.h"
diff --git a/drivers/net/wireless/iwmc3200wifi/commands.c b/drivers/net/wireless/iwmc3200wifi/commands.c
index 1e41ad0fcad..42df7262f9f 100644
--- a/drivers/net/wireless/iwmc3200wifi/commands.c
+++ b/drivers/net/wireless/iwmc3200wifi/commands.c
@@ -41,6 +41,7 @@
41#include <linux/etherdevice.h> 41#include <linux/etherdevice.h>
42#include <linux/ieee80211.h> 42#include <linux/ieee80211.h>
43#include <linux/sched.h> 43#include <linux/sched.h>
44#include <linux/slab.h>
44 45
45#include "iwm.h" 46#include "iwm.h"
46#include "bus.h" 47#include "bus.h"
diff --git a/drivers/net/wireless/iwmc3200wifi/debugfs.c b/drivers/net/wireless/iwmc3200wifi/debugfs.c
index c29c994de0e..cbb81befdb5 100644
--- a/drivers/net/wireless/iwmc3200wifi/debugfs.c
+++ b/drivers/net/wireless/iwmc3200wifi/debugfs.c
@@ -21,6 +21,7 @@
21 * 21 *
22 */ 22 */
23 23
24#include <linux/slab.h>
24#include <linux/kernel.h> 25#include <linux/kernel.h>
25#include <linux/bitops.h> 26#include <linux/bitops.h>
26#include <linux/debugfs.h> 27#include <linux/debugfs.h>
diff --git a/drivers/net/wireless/iwmc3200wifi/eeprom.c b/drivers/net/wireless/iwmc3200wifi/eeprom.c
index 8091421ee5e..e80e776b74f 100644
--- a/drivers/net/wireless/iwmc3200wifi/eeprom.c
+++ b/drivers/net/wireless/iwmc3200wifi/eeprom.c
@@ -37,6 +37,7 @@
37 */ 37 */
38 38
39#include <linux/kernel.h> 39#include <linux/kernel.h>
40#include <linux/slab.h>
40 41
41#include "iwm.h" 42#include "iwm.h"
42#include "umac.h" 43#include "umac.h"
diff --git a/drivers/net/wireless/iwmc3200wifi/hal.c b/drivers/net/wireless/iwmc3200wifi/hal.c
index d13c8853ee8..229de990379 100644
--- a/drivers/net/wireless/iwmc3200wifi/hal.c
+++ b/drivers/net/wireless/iwmc3200wifi/hal.c
@@ -98,6 +98,7 @@
98 */ 98 */
99#include <linux/kernel.h> 99#include <linux/kernel.h>
100#include <linux/netdevice.h> 100#include <linux/netdevice.h>
101#include <linux/slab.h>
101 102
102#include "iwm.h" 103#include "iwm.h"
103#include "bus.h" 104#include "bus.h"
diff --git a/drivers/net/wireless/iwmc3200wifi/main.c b/drivers/net/wireless/iwmc3200wifi/main.c
index 7f34d6dd3c4..23856d359e1 100644
--- a/drivers/net/wireless/iwmc3200wifi/main.c
+++ b/drivers/net/wireless/iwmc3200wifi/main.c
@@ -41,6 +41,7 @@
41#include <linux/sched.h> 41#include <linux/sched.h>
42#include <linux/ieee80211.h> 42#include <linux/ieee80211.h>
43#include <linux/wireless.h> 43#include <linux/wireless.h>
44#include <linux/slab.h>
44 45
45#include "iwm.h" 46#include "iwm.h"
46#include "debug.h" 47#include "debug.h"
diff --git a/drivers/net/wireless/iwmc3200wifi/netdev.c b/drivers/net/wireless/iwmc3200wifi/netdev.c
index c4c0d23c63e..13a69ebf2a9 100644
--- a/drivers/net/wireless/iwmc3200wifi/netdev.c
+++ b/drivers/net/wireless/iwmc3200wifi/netdev.c
@@ -46,6 +46,7 @@
46 * -> sdio_disable_func() 46 * -> sdio_disable_func()
47 */ 47 */
48#include <linux/netdevice.h> 48#include <linux/netdevice.h>
49#include <linux/slab.h>
49 50
50#include "iwm.h" 51#include "iwm.h"
51#include "commands.h" 52#include "commands.h"
diff --git a/drivers/net/wireless/iwmc3200wifi/rx.c b/drivers/net/wireless/iwmc3200wifi/rx.c
index 8456b4dbd14..3257d4fad83 100644
--- a/drivers/net/wireless/iwmc3200wifi/rx.c
+++ b/drivers/net/wireless/iwmc3200wifi/rx.c
@@ -44,6 +44,7 @@
44#include <linux/ieee80211.h> 44#include <linux/ieee80211.h>
45#include <linux/if_arp.h> 45#include <linux/if_arp.h>
46#include <linux/list.h> 46#include <linux/list.h>
47#include <linux/slab.h>
47#include <net/iw_handler.h> 48#include <net/iw_handler.h>
48 49
49#include "iwm.h" 50#include "iwm.h"
diff --git a/drivers/net/wireless/iwmc3200wifi/sdio.c b/drivers/net/wireless/iwmc3200wifi/sdio.c
index a7ec7eac913..1eafd6dec3f 100644
--- a/drivers/net/wireless/iwmc3200wifi/sdio.c
+++ b/drivers/net/wireless/iwmc3200wifi/sdio.c
@@ -63,6 +63,7 @@
63 */ 63 */
64 64
65#include <linux/kernel.h> 65#include <linux/kernel.h>
66#include <linux/slab.h>
66#include <linux/netdevice.h> 67#include <linux/netdevice.h>
67#include <linux/debugfs.h> 68#include <linux/debugfs.h>
68#include <linux/mmc/sdio_ids.h> 69#include <linux/mmc/sdio_ids.h>
diff --git a/drivers/net/wireless/iwmc3200wifi/tx.c b/drivers/net/wireless/iwmc3200wifi/tx.c
index 55905f02309..f6a02f123f3 100644
--- a/drivers/net/wireless/iwmc3200wifi/tx.c
+++ b/drivers/net/wireless/iwmc3200wifi/tx.c
@@ -64,6 +64,7 @@
64 * (i.e. half of the max size). [iwm_tx_worker] 64 * (i.e. half of the max size). [iwm_tx_worker]
65 */ 65 */
66 66
67#include <linux/slab.h>
67#include <linux/skbuff.h> 68#include <linux/skbuff.h>
68#include <linux/netdevice.h> 69#include <linux/netdevice.h>
69#include <linux/ieee80211.h> 70#include <linux/ieee80211.h>
diff --git a/drivers/net/wireless/libertas/assoc.c b/drivers/net/wireless/libertas/assoc.c
index f03d5e4e59c..12a2ef9dace 100644
--- a/drivers/net/wireless/libertas/assoc.c
+++ b/drivers/net/wireless/libertas/assoc.c
@@ -4,6 +4,7 @@
4#include <linux/etherdevice.h> 4#include <linux/etherdevice.h>
5#include <linux/ieee80211.h> 5#include <linux/ieee80211.h>
6#include <linux/if_arp.h> 6#include <linux/if_arp.h>
7#include <linux/slab.h>
7#include <net/lib80211.h> 8#include <net/lib80211.h>
8 9
9#include "assoc.h" 10#include "assoc.h"
diff --git a/drivers/net/wireless/libertas/cfg.c b/drivers/net/wireless/libertas/cfg.c
index 4396dccd12a..ce7bec402a3 100644
--- a/drivers/net/wireless/libertas/cfg.c
+++ b/drivers/net/wireless/libertas/cfg.c
@@ -6,6 +6,7 @@
6 * 6 *
7 */ 7 */
8 8
9#include <linux/slab.h>
9#include <net/cfg80211.h> 10#include <net/cfg80211.h>
10 11
11#include "cfg.h" 12#include "cfg.h"
@@ -172,6 +173,8 @@ int lbs_cfg_register(struct lbs_private *priv)
172 if (ret < 0) 173 if (ret < 0)
173 lbs_pr_err("cannot register wiphy device\n"); 174 lbs_pr_err("cannot register wiphy device\n");
174 175
176 priv->wiphy_registered = true;
177
175 ret = register_netdev(priv->dev); 178 ret = register_netdev(priv->dev);
176 if (ret) 179 if (ret)
177 lbs_pr_err("cannot register network device\n"); 180 lbs_pr_err("cannot register network device\n");
@@ -190,9 +193,11 @@ void lbs_cfg_free(struct lbs_private *priv)
190 if (!wdev) 193 if (!wdev)
191 return; 194 return;
192 195
193 if (wdev->wiphy) { 196 if (priv->wiphy_registered)
194 wiphy_unregister(wdev->wiphy); 197 wiphy_unregister(wdev->wiphy);
198
199 if (wdev->wiphy)
195 wiphy_free(wdev->wiphy); 200 wiphy_free(wdev->wiphy);
196 } 201
197 kfree(wdev); 202 kfree(wdev);
198} 203}
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index 82371ef3952..cdb9b9650d7 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -5,6 +5,7 @@
5 5
6#include <linux/kfifo.h> 6#include <linux/kfifo.h>
7#include <linux/sched.h> 7#include <linux/sched.h>
8#include <linux/slab.h>
8 9
9#include "host.h" 10#include "host.h"
10#include "decl.h" 11#include "decl.h"
diff --git a/drivers/net/wireless/libertas/cmdresp.c b/drivers/net/wireless/libertas/cmdresp.c
index e7470442f76..88f7131d66e 100644
--- a/drivers/net/wireless/libertas/cmdresp.c
+++ b/drivers/net/wireless/libertas/cmdresp.c
@@ -2,6 +2,7 @@
2 * This file contains the handling of command 2 * This file contains the handling of command
3 * responses as well as events generated by firmware. 3 * responses as well as events generated by firmware.
4 */ 4 */
5#include <linux/slab.h>
5#include <linux/delay.h> 6#include <linux/delay.h>
6#include <linux/sched.h> 7#include <linux/sched.h>
7#include <linux/if_arp.h> 8#include <linux/if_arp.h>
diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
index 587b0cb0088..a48ccaffb28 100644
--- a/drivers/net/wireless/libertas/debugfs.c
+++ b/drivers/net/wireless/libertas/debugfs.c
@@ -4,6 +4,7 @@
4#include <linux/delay.h> 4#include <linux/delay.h>
5#include <linux/mm.h> 5#include <linux/mm.h>
6#include <linux/string.h> 6#include <linux/string.h>
7#include <linux/slab.h>
7#include <net/iw_handler.h> 8#include <net/iw_handler.h>
8#include <net/lib80211.h> 9#include <net/lib80211.h>
9 10
diff --git a/drivers/net/wireless/libertas/dev.h b/drivers/net/wireless/libertas/dev.h
index 6977ee82021..6875e1498bd 100644
--- a/drivers/net/wireless/libertas/dev.h
+++ b/drivers/net/wireless/libertas/dev.h
@@ -36,6 +36,7 @@ struct lbs_private {
36 36
37 /* CFG80211 */ 37 /* CFG80211 */
38 struct wireless_dev *wdev; 38 struct wireless_dev *wdev;
39 bool wiphy_registered;
39 40
40 /* Mesh */ 41 /* Mesh */
41 struct net_device *mesh_dev; /* Virtual device */ 42 struct net_device *mesh_dev; /* Virtual device */
diff --git a/drivers/net/wireless/libertas/if_cs.c b/drivers/net/wireless/libertas/if_cs.c
index 1f6cb58dd66..6d55439a7b9 100644
--- a/drivers/net/wireless/libertas/if_cs.c
+++ b/drivers/net/wireless/libertas/if_cs.c
@@ -22,6 +22,7 @@
22*/ 22*/
23 23
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/slab.h>
25#include <linux/delay.h> 26#include <linux/delay.h>
26#include <linux/moduleparam.h> 27#include <linux/moduleparam.h>
27#include <linux/firmware.h> 28#include <linux/firmware.h>
diff --git a/drivers/net/wireless/libertas/if_sdio.c b/drivers/net/wireless/libertas/if_sdio.c
index 7a73f625273..7d1a3c6b6ce 100644
--- a/drivers/net/wireless/libertas/if_sdio.c
+++ b/drivers/net/wireless/libertas/if_sdio.c
@@ -28,6 +28,7 @@
28 28
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <linux/moduleparam.h> 30#include <linux/moduleparam.h>
31#include <linux/slab.h>
31#include <linux/firmware.h> 32#include <linux/firmware.h>
32#include <linux/netdevice.h> 33#include <linux/netdevice.h>
33#include <linux/delay.h> 34#include <linux/delay.h>
diff --git a/drivers/net/wireless/libertas/if_spi.c b/drivers/net/wireless/libertas/if_spi.c
index 3ea03f259ee..fe3f08028eb 100644
--- a/drivers/net/wireless/libertas/if_spi.c
+++ b/drivers/net/wireless/libertas/if_spi.c
@@ -24,6 +24,7 @@
24#include <linux/list.h> 24#include <linux/list.h>
25#include <linux/netdevice.h> 25#include <linux/netdevice.h>
26#include <linux/semaphore.h> 26#include <linux/semaphore.h>
27#include <linux/slab.h>
27#include <linux/spi/libertas_spi.h> 28#include <linux/spi/libertas_spi.h>
28#include <linux/spi/spi.h> 29#include <linux/spi/spi.h>
29 30
diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c
index 65e174595d1..fcea5741ba6 100644
--- a/drivers/net/wireless/libertas/if_usb.c
+++ b/drivers/net/wireless/libertas/if_usb.c
@@ -5,6 +5,7 @@
5#include <linux/moduleparam.h> 5#include <linux/moduleparam.h>
6#include <linux/firmware.h> 6#include <linux/firmware.h>
7#include <linux/netdevice.h> 7#include <linux/netdevice.h>
8#include <linux/slab.h>
8#include <linux/usb.h> 9#include <linux/usb.h>
9 10
10#ifdef CONFIG_OLPC 11#ifdef CONFIG_OLPC
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index 28a1c9d1627..598080414b1 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -13,6 +13,7 @@
13#include <linux/kfifo.h> 13#include <linux/kfifo.h>
14#include <linux/stddef.h> 14#include <linux/stddef.h>
15#include <linux/ieee80211.h> 15#include <linux/ieee80211.h>
16#include <linux/slab.h>
16#include <net/iw_handler.h> 17#include <net/iw_handler.h>
17#include <net/cfg80211.h> 18#include <net/cfg80211.h>
18 19
diff --git a/drivers/net/wireless/libertas/rx.c b/drivers/net/wireless/libertas/rx.c
index 2daf8ffdb7e..784dae71470 100644
--- a/drivers/net/wireless/libertas/rx.c
+++ b/drivers/net/wireless/libertas/rx.c
@@ -2,6 +2,7 @@
2 * This file contains the handling of RX in wlan driver. 2 * This file contains the handling of RX in wlan driver.
3 */ 3 */
4#include <linux/etherdevice.h> 4#include <linux/etherdevice.h>
5#include <linux/slab.h>
5#include <linux/types.h> 6#include <linux/types.h>
6 7
7#include "host.h" 8#include "host.h"
diff --git a/drivers/net/wireless/libertas/scan.c b/drivers/net/wireless/libertas/scan.c
index 220361e69cd..24cd54b3a80 100644
--- a/drivers/net/wireless/libertas/scan.c
+++ b/drivers/net/wireless/libertas/scan.c
@@ -4,6 +4,7 @@
4 * IOCTL handlers as well as command preperation and response routines 4 * IOCTL handlers as well as command preperation and response routines
5 * for sending scan commands to the firmware. 5 * for sending scan commands to the firmware.
6 */ 6 */
7#include <linux/slab.h>
7#include <linux/types.h> 8#include <linux/types.h>
8#include <linux/kernel.h> 9#include <linux/kernel.h>
9#include <linux/etherdevice.h> 10#include <linux/etherdevice.h>
diff --git a/drivers/net/wireless/libertas/wext.c b/drivers/net/wireless/libertas/wext.c
index 71f88a08e09..9b555884b08 100644
--- a/drivers/net/wireless/libertas/wext.c
+++ b/drivers/net/wireless/libertas/wext.c
@@ -2,6 +2,7 @@
2 * This file contains ioctl functions 2 * This file contains ioctl functions
3 */ 3 */
4#include <linux/ctype.h> 4#include <linux/ctype.h>
5#include <linux/slab.h>
5#include <linux/delay.h> 6#include <linux/delay.h>
6#include <linux/if.h> 7#include <linux/if.h>
7#include <linux/if_arp.h> 8#include <linux/if_arp.h>
diff --git a/drivers/net/wireless/libertas_tf/cmd.c b/drivers/net/wireless/libertas_tf/cmd.c
index 28790e03dc4..b620daf59ef 100644
--- a/drivers/net/wireless/libertas_tf/cmd.c
+++ b/drivers/net/wireless/libertas_tf/cmd.c
@@ -7,6 +7,8 @@
7 * the Free Software Foundation; either version 2 of the License, or (at 7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version. 8 * your option) any later version.
9 */ 9 */
10#include <linux/slab.h>
11
10#include "libertas_tf.h" 12#include "libertas_tf.h"
11 13
12static const struct channel_range channel_ranges[] = { 14static const struct channel_range channel_ranges[] = {
diff --git a/drivers/net/wireless/libertas_tf/if_usb.c b/drivers/net/wireless/libertas_tf/if_usb.c
index 3691c307e67..8cc9db60c14 100644
--- a/drivers/net/wireless/libertas_tf/if_usb.c
+++ b/drivers/net/wireless/libertas_tf/if_usb.c
@@ -11,6 +11,7 @@
11#include <linux/moduleparam.h> 11#include <linux/moduleparam.h>
12#include <linux/firmware.h> 12#include <linux/firmware.h>
13#include <linux/netdevice.h> 13#include <linux/netdevice.h>
14#include <linux/slab.h>
14#include <linux/usb.h> 15#include <linux/usb.h>
15 16
16#define DRV_NAME "lbtf_usb" 17#define DRV_NAME "lbtf_usb"
diff --git a/drivers/net/wireless/libertas_tf/main.c b/drivers/net/wireless/libertas_tf/main.c
index 6ab30033c26..7945ff5aa33 100644
--- a/drivers/net/wireless/libertas_tf/main.c
+++ b/drivers/net/wireless/libertas_tf/main.c
@@ -7,6 +7,8 @@
7 * the Free Software Foundation; either version 2 of the License, or (at 7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version. 8 * your option) any later version.
9 */ 9 */
10#include <linux/slab.h>
11
10#include "libertas_tf.h" 12#include "libertas_tf.h"
11#include "linux/etherdevice.h" 13#include "linux/etherdevice.h"
12 14
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 6ea77e95277..7cd5f56662f 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -14,6 +14,7 @@
14 */ 14 */
15 15
16#include <linux/list.h> 16#include <linux/list.h>
17#include <linux/slab.h>
17#include <linux/spinlock.h> 18#include <linux/spinlock.h>
18#include <net/dst.h> 19#include <net/dst.h>
19#include <net/xfrm.h> 20#include <net/xfrm.h>
diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c
index ac65e13eb0d..12fdcb25fd3 100644
--- a/drivers/net/wireless/mwl8k.c
+++ b/drivers/net/wireless/mwl8k.c
@@ -19,6 +19,7 @@
19#include <linux/delay.h> 19#include <linux/delay.h>
20#include <linux/completion.h> 20#include <linux/completion.h>
21#include <linux/etherdevice.h> 21#include <linux/etherdevice.h>
22#include <linux/slab.h>
22#include <net/mac80211.h> 23#include <net/mac80211.h>
23#include <linux/moduleparam.h> 24#include <linux/moduleparam.h>
24#include <linux/firmware.h> 25#include <linux/firmware.h>
@@ -3851,6 +3852,7 @@ MODULE_FIRMWARE("mwl8k/helper_8366.fw");
3851MODULE_FIRMWARE("mwl8k/fmimage_8366.fw"); 3852MODULE_FIRMWARE("mwl8k/fmimage_8366.fw");
3852 3853
3853static DEFINE_PCI_DEVICE_TABLE(mwl8k_pci_id_table) = { 3854static DEFINE_PCI_DEVICE_TABLE(mwl8k_pci_id_table) = {
3855 { PCI_VDEVICE(MARVELL, 0x2a0a), .driver_data = MWL8363, },
3854 { PCI_VDEVICE(MARVELL, 0x2a0c), .driver_data = MWL8363, }, 3856 { PCI_VDEVICE(MARVELL, 0x2a0c), .driver_data = MWL8363, },
3855 { PCI_VDEVICE(MARVELL, 0x2a24), .driver_data = MWL8363, }, 3857 { PCI_VDEVICE(MARVELL, 0x2a24), .driver_data = MWL8363, },
3856 { PCI_VDEVICE(MARVELL, 0x2a2b), .driver_data = MWL8687, }, 3858 { PCI_VDEVICE(MARVELL, 0x2a2b), .driver_data = MWL8687, },
diff --git a/drivers/net/wireless/orinoco/fw.c b/drivers/net/wireless/orinoco/fw.c
index cfa72962052..5ea0f7cf85b 100644
--- a/drivers/net/wireless/orinoco/fw.c
+++ b/drivers/net/wireless/orinoco/fw.c
@@ -3,6 +3,7 @@
3 * See copyright notice in main.c 3 * See copyright notice in main.c
4 */ 4 */
5#include <linux/kernel.h> 5#include <linux/kernel.h>
6#include <linux/slab.h>
6#include <linux/firmware.h> 7#include <linux/firmware.h>
7#include <linux/device.h> 8#include <linux/device.h>
8 9
diff --git a/drivers/net/wireless/orinoco/main.c b/drivers/net/wireless/orinoco/main.c
index b42634c614b..413e9ab6cab 100644
--- a/drivers/net/wireless/orinoco/main.c
+++ b/drivers/net/wireless/orinoco/main.c
@@ -78,6 +78,7 @@
78 78
79#include <linux/module.h> 79#include <linux/module.h>
80#include <linux/kernel.h> 80#include <linux/kernel.h>
81#include <linux/slab.h>
81#include <linux/init.h> 82#include <linux/init.h>
82#include <linux/delay.h> 83#include <linux/delay.h>
83#include <linux/device.h> 84#include <linux/device.h>
diff --git a/drivers/net/wireless/orinoco/scan.c b/drivers/net/wireless/orinoco/scan.c
index d2f10e9c216..330d42d4533 100644
--- a/drivers/net/wireless/orinoco/scan.c
+++ b/drivers/net/wireless/orinoco/scan.c
@@ -3,6 +3,7 @@
3 * See copyright notice in main.c 3 * See copyright notice in main.c
4 */ 4 */
5 5
6#include <linux/gfp.h>
6#include <linux/kernel.h> 7#include <linux/kernel.h>
7#include <linux/string.h> 8#include <linux/string.h>
8#include <linux/ieee80211.h> 9#include <linux/ieee80211.h>
diff --git a/drivers/net/wireless/orinoco/wext.c b/drivers/net/wireless/orinoco/wext.c
index 31ca241f775..fbcc6e1a2e1 100644
--- a/drivers/net/wireless/orinoco/wext.c
+++ b/drivers/net/wireless/orinoco/wext.c
@@ -2,6 +2,7 @@
2 * 2 *
3 * See copyright notice in main.c 3 * See copyright notice in main.c
4 */ 4 */
5#include <linux/slab.h>
5#include <linux/kernel.h> 6#include <linux/kernel.h>
6#include <linux/if_arp.h> 7#include <linux/if_arp.h>
7#include <linux/wireless.h> 8#include <linux/wireless.h>
diff --git a/drivers/net/wireless/p54/eeprom.c b/drivers/net/wireless/p54/eeprom.c
index 8e3818f6832..187e263b045 100644
--- a/drivers/net/wireless/p54/eeprom.c
+++ b/drivers/net/wireless/p54/eeprom.c
@@ -20,6 +20,7 @@
20#include <linux/firmware.h> 20#include <linux/firmware.h>
21#include <linux/etherdevice.h> 21#include <linux/etherdevice.h>
22#include <linux/sort.h> 22#include <linux/sort.h>
23#include <linux/slab.h>
23 24
24#include <net/mac80211.h> 25#include <net/mac80211.h>
25 26
diff --git a/drivers/net/wireless/p54/fwio.c b/drivers/net/wireless/p54/fwio.c
index e7b9e9cb39f..c43a5d461ab 100644
--- a/drivers/net/wireless/p54/fwio.c
+++ b/drivers/net/wireless/p54/fwio.c
@@ -17,6 +17,7 @@
17 */ 17 */
18 18
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/slab.h>
20#include <linux/firmware.h> 21#include <linux/firmware.h>
21#include <linux/etherdevice.h> 22#include <linux/etherdevice.h>
22 23
diff --git a/drivers/net/wireless/p54/main.c b/drivers/net/wireless/p54/main.c
index 4f752a21495..a7cb9eb759a 100644
--- a/drivers/net/wireless/p54/main.c
+++ b/drivers/net/wireless/p54/main.c
@@ -17,6 +17,7 @@
17 */ 17 */
18 18
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/slab.h>
20#include <linux/firmware.h> 21#include <linux/firmware.h>
21#include <linux/etherdevice.h> 22#include <linux/etherdevice.h>
22 23
diff --git a/drivers/net/wireless/p54/p54pci.c b/drivers/net/wireless/p54/p54pci.c
index ed4bdffdd63..c24067f1a0c 100644
--- a/drivers/net/wireless/p54/p54pci.c
+++ b/drivers/net/wireless/p54/p54pci.c
@@ -15,6 +15,7 @@
15 15
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/pci.h> 17#include <linux/pci.h>
18#include <linux/slab.h>
18#include <linux/firmware.h> 19#include <linux/firmware.h>
19#include <linux/etherdevice.h> 20#include <linux/etherdevice.h>
20#include <linux/delay.h> 21#include <linux/delay.h>
@@ -245,7 +246,7 @@ static void p54p_check_tx_ring(struct ieee80211_hw *dev, u32 *index,
245 u32 idx, i; 246 u32 idx, i;
246 247
247 i = (*index) % ring_limit; 248 i = (*index) % ring_limit;
248 (*index) = idx = le32_to_cpu(ring_control->device_idx[1]); 249 (*index) = idx = le32_to_cpu(ring_control->device_idx[ring_index]);
249 idx %= ring_limit; 250 idx %= ring_limit;
250 251
251 while (i != idx) { 252 while (i != idx) {
diff --git a/drivers/net/wireless/p54/p54spi.c b/drivers/net/wireless/p54/p54spi.c
index afd26bf0664..c8f09da1f84 100644
--- a/drivers/net/wireless/p54/p54spi.c
+++ b/drivers/net/wireless/p54/p54spi.c
@@ -29,6 +29,7 @@
29#include <linux/spi/spi.h> 29#include <linux/spi/spi.h>
30#include <linux/etherdevice.h> 30#include <linux/etherdevice.h>
31#include <linux/gpio.h> 31#include <linux/gpio.h>
32#include <linux/slab.h>
32 33
33#include "p54spi.h" 34#include "p54spi.h"
34#include "p54spi_eeprom.h" 35#include "p54spi_eeprom.h"
diff --git a/drivers/net/wireless/p54/p54usb.c b/drivers/net/wireless/p54/p54usb.c
index b3c4fbd80d8..743a6c68b29 100644
--- a/drivers/net/wireless/p54/p54usb.c
+++ b/drivers/net/wireless/p54/p54usb.c
@@ -15,6 +15,7 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/usb.h> 16#include <linux/usb.h>
17#include <linux/pci.h> 17#include <linux/pci.h>
18#include <linux/slab.h>
18#include <linux/firmware.h> 19#include <linux/firmware.h>
19#include <linux/etherdevice.h> 20#include <linux/etherdevice.h>
20#include <linux/delay.h> 21#include <linux/delay.h>
@@ -35,6 +36,7 @@ MODULE_FIRMWARE("isl3887usb");
35static struct usb_device_id p54u_table[] __devinitdata = { 36static struct usb_device_id p54u_table[] __devinitdata = {
36 /* Version 1 devices (pci chip + net2280) */ 37 /* Version 1 devices (pci chip + net2280) */
37 {USB_DEVICE(0x0506, 0x0a11)}, /* 3COM 3CRWE254G72 */ 38 {USB_DEVICE(0x0506, 0x0a11)}, /* 3COM 3CRWE254G72 */
39 {USB_DEVICE(0x06b9, 0x0120)}, /* Thomson SpeedTouch 120g */
38 {USB_DEVICE(0x0707, 0xee06)}, /* SMC 2862W-G */ 40 {USB_DEVICE(0x0707, 0xee06)}, /* SMC 2862W-G */
39 {USB_DEVICE(0x07aa, 0x001c)}, /* Corega CG-WLUSB2GT */ 41 {USB_DEVICE(0x07aa, 0x001c)}, /* Corega CG-WLUSB2GT */
40 {USB_DEVICE(0x083a, 0x4501)}, /* Accton 802.11g WN4501 USB */ 42 {USB_DEVICE(0x083a, 0x4501)}, /* Accton 802.11g WN4501 USB */
diff --git a/drivers/net/wireless/prism54/isl_ioctl.c b/drivers/net/wireless/prism54/isl_ioctl.c
index f7f5c793514..a45818ebfdf 100644
--- a/drivers/net/wireless/prism54/isl_ioctl.c
+++ b/drivers/net/wireless/prism54/isl_ioctl.c
@@ -23,6 +23,7 @@
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/if_arp.h> 25#include <linux/if_arp.h>
26#include <linux/slab.h>
26#include <linux/pci.h> 27#include <linux/pci.h>
27 28
28#include <asm/uaccess.h> 29#include <asm/uaccess.h>
diff --git a/drivers/net/wireless/prism54/islpci_dev.c b/drivers/net/wireless/prism54/islpci_dev.c
index a3ba3539db0..689d59a13d5 100644
--- a/drivers/net/wireless/prism54/islpci_dev.c
+++ b/drivers/net/wireless/prism54/islpci_dev.c
@@ -19,6 +19,7 @@
19 */ 19 */
20 20
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/slab.h>
22 23
23#include <linux/netdevice.h> 24#include <linux/netdevice.h>
24#include <linux/ethtool.h> 25#include <linux/ethtool.h>
diff --git a/drivers/net/wireless/prism54/islpci_eth.c b/drivers/net/wireless/prism54/islpci_eth.c
index 872b64783e7..ac99eaaeabc 100644
--- a/drivers/net/wireless/prism54/islpci_eth.c
+++ b/drivers/net/wireless/prism54/islpci_eth.c
@@ -17,6 +17,7 @@
17 */ 17 */
18 18
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/gfp.h>
20 21
21#include <linux/pci.h> 22#include <linux/pci.h>
22#include <linux/delay.h> 23#include <linux/delay.h>
diff --git a/drivers/net/wireless/prism54/islpci_mgt.c b/drivers/net/wireless/prism54/islpci_mgt.c
index 69d2f882fd0..adb289723a9 100644
--- a/drivers/net/wireless/prism54/islpci_mgt.c
+++ b/drivers/net/wireless/prism54/islpci_mgt.c
@@ -21,6 +21,7 @@
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/pci.h> 22#include <linux/pci.h>
23#include <linux/sched.h> 23#include <linux/sched.h>
24#include <linux/slab.h>
24 25
25#include <asm/io.h> 26#include <asm/io.h>
26#include <asm/system.h> 27#include <asm/system.h>
diff --git a/drivers/net/wireless/prism54/islpci_mgt.h b/drivers/net/wireless/prism54/islpci_mgt.h
index 87a1734663d..0b27e50fe0d 100644
--- a/drivers/net/wireless/prism54/islpci_mgt.h
+++ b/drivers/net/wireless/prism54/islpci_mgt.h
@@ -22,6 +22,7 @@
22 22
23#include <linux/wireless.h> 23#include <linux/wireless.h>
24#include <linux/skbuff.h> 24#include <linux/skbuff.h>
25#include <linux/slab.h>
25 26
26/* 27/*
27 * Function definitions 28 * Function definitions
diff --git a/drivers/net/wireless/prism54/oid_mgt.c b/drivers/net/wireless/prism54/oid_mgt.c
index 1187e6112a6..d66933d70fb 100644
--- a/drivers/net/wireless/prism54/oid_mgt.c
+++ b/drivers/net/wireless/prism54/oid_mgt.c
@@ -17,6 +17,7 @@
17 */ 17 */
18 18
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/slab.h>
20 21
21#include "prismcompat.h" 22#include "prismcompat.h"
22#include "islpci_dev.h" 23#include "islpci_dev.h"
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index 84c530aa52f..11865ea2187 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -35,7 +35,6 @@
35#include <linux/proc_fs.h> 35#include <linux/proc_fs.h>
36#include <linux/ptrace.h> 36#include <linux/ptrace.h>
37#include <linux/seq_file.h> 37#include <linux/seq_file.h>
38#include <linux/slab.h>
39#include <linux/string.h> 38#include <linux/string.h>
40#include <linux/timer.h> 39#include <linux/timer.h>
41#include <linux/init.h> 40#include <linux/init.h>
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index 2887047069f..1de5b22d3ef 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -41,6 +41,7 @@
41#include <linux/if_arp.h> 41#include <linux/if_arp.h>
42#include <linux/ctype.h> 42#include <linux/ctype.h>
43#include <linux/spinlock.h> 43#include <linux/spinlock.h>
44#include <linux/slab.h>
44#include <net/iw_handler.h> 45#include <net/iw_handler.h>
45#include <net/cfg80211.h> 46#include <net/cfg80211.h>
46#include <linux/usb/usbnet.h> 47#include <linux/usb/usbnet.h>
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c
index c22b04042d5..5f5204b8289 100644
--- a/drivers/net/wireless/rt2x00/rt2400pci.c
+++ b/drivers/net/wireless/rt2x00/rt2400pci.c
@@ -31,6 +31,7 @@
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/pci.h> 32#include <linux/pci.h>
33#include <linux/eeprom_93cx6.h> 33#include <linux/eeprom_93cx6.h>
34#include <linux/slab.h>
34 35
35#include "rt2x00.h" 36#include "rt2x00.h"
36#include "rt2x00pci.h" 37#include "rt2x00pci.h"
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index 52bbcf1bd17..2a73f593aab 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -31,6 +31,7 @@
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/pci.h> 32#include <linux/pci.h>
33#include <linux/eeprom_93cx6.h> 33#include <linux/eeprom_93cx6.h>
34#include <linux/slab.h>
34 35
35#include "rt2x00.h" 36#include "rt2x00.h"
36#include "rt2x00pci.h" 37#include "rt2x00pci.h"
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index 9b04964dece..8ebb705fe10 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -29,6 +29,7 @@
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/kernel.h> 30#include <linux/kernel.h>
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/slab.h>
32#include <linux/usb.h> 33#include <linux/usb.h>
33 34
34#include "rt2x00.h" 35#include "rt2x00.h"
@@ -1643,6 +1644,11 @@ static int rt2500usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
1643 unsigned int i; 1644 unsigned int i;
1644 1645
1645 /* 1646 /*
1647 * Disable powersaving as default.
1648 */
1649 rt2x00dev->hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
1650
1651 /*
1646 * Initialize all hw fields. 1652 * Initialize all hw fields.
1647 */ 1653 */
1648 rt2x00dev->hw->flags = 1654 rt2x00dev->hw->flags =
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 18d4d8e4ae6..c015ce9fdd0 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -35,6 +35,7 @@
35 35
36#include <linux/kernel.h> 36#include <linux/kernel.h>
37#include <linux/module.h> 37#include <linux/module.h>
38#include <linux/slab.h>
38 39
39#include "rt2x00.h" 40#include "rt2x00.h"
40#if defined(CONFIG_RT2X00_LIB_USB) || defined(CONFIG_RT2X00_LIB_USB_MODULE) 41#if defined(CONFIG_RT2X00_LIB_USB) || defined(CONFIG_RT2X00_LIB_USB_MODULE)
@@ -812,9 +813,9 @@ static void rt2800_config_channel_rt3x(struct rt2x00_dev *rt2x00dev,
812 rt2800_rfcsr_write(rt2x00dev, 24, 813 rt2800_rfcsr_write(rt2x00dev, 24,
813 rt2x00dev->calibration[conf_is_ht40(conf)]); 814 rt2x00dev->calibration[conf_is_ht40(conf)]);
814 815
815 rt2800_rfcsr_read(rt2x00dev, 23, &rfcsr); 816 rt2800_rfcsr_read(rt2x00dev, 7, &rfcsr);
816 rt2x00_set_field8(&rfcsr, RFCSR7_RF_TUNING, 1); 817 rt2x00_set_field8(&rfcsr, RFCSR7_RF_TUNING, 1);
817 rt2800_rfcsr_write(rt2x00dev, 23, rfcsr); 818 rt2800_rfcsr_write(rt2x00dev, 7, rfcsr);
818} 819}
819 820
820static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev, 821static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,
diff --git a/drivers/net/wireless/rt2x00/rt2x00debug.c b/drivers/net/wireless/rt2x00/rt2x00debug.c
index 28a1c46ec4e..9569fb4e5bc 100644
--- a/drivers/net/wireless/rt2x00/rt2x00debug.c
+++ b/drivers/net/wireless/rt2x00/rt2x00debug.c
@@ -28,6 +28,7 @@
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/poll.h> 29#include <linux/poll.h>
30#include <linux/sched.h> 30#include <linux/sched.h>
31#include <linux/slab.h>
31#include <linux/uaccess.h> 32#include <linux/uaccess.h>
32 33
33#include "rt2x00.h" 34#include "rt2x00.h"
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index dd5ab8fe232..eda73ba735a 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -25,6 +25,7 @@
25 25
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/slab.h>
28 29
29#include "rt2x00.h" 30#include "rt2x00.h"
30#include "rt2x00lib.h" 31#include "rt2x00lib.h"
diff --git a/drivers/net/wireless/rt2x00/rt2x00pci.c b/drivers/net/wireless/rt2x00/rt2x00pci.c
index 047123b766f..cf3f1c0c438 100644
--- a/drivers/net/wireless/rt2x00/rt2x00pci.c
+++ b/drivers/net/wireless/rt2x00/rt2x00pci.c
@@ -27,6 +27,7 @@
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/pci.h> 29#include <linux/pci.h>
30#include <linux/slab.h>
30 31
31#include "rt2x00.h" 32#include "rt2x00.h"
32#include "rt2x00pci.h" 33#include "rt2x00pci.h"
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
index 5b6b789cad3..a0bd36fc4d2 100644
--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
+++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
@@ -24,6 +24,7 @@
24 Abstract: rt2x00 queue specific routines. 24 Abstract: rt2x00 queue specific routines.
25 */ 25 */
26 26
27#include <linux/slab.h>
27#include <linux/kernel.h> 28#include <linux/kernel.h>
28#include <linux/module.h> 29#include <linux/module.h>
29#include <linux/dma-mapping.h> 30#include <linux/dma-mapping.h>
diff --git a/drivers/net/wireless/rt2x00/rt2x00soc.c b/drivers/net/wireless/rt2x00/rt2x00soc.c
index 111c0ff5c6c..fc98063de71 100644
--- a/drivers/net/wireless/rt2x00/rt2x00soc.c
+++ b/drivers/net/wireless/rt2x00/rt2x00soc.c
@@ -28,6 +28,7 @@
28#include <linux/kernel.h> 28#include <linux/kernel.h>
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/platform_device.h> 30#include <linux/platform_device.h>
31#include <linux/slab.h>
31 32
32#include "rt2x00.h" 33#include "rt2x00.h"
33#include "rt2x00soc.h" 34#include "rt2x00soc.h"
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.c b/drivers/net/wireless/rt2x00/rt2x00usb.c
index 0a751e73aa0..f9a7f8b1741 100644
--- a/drivers/net/wireless/rt2x00/rt2x00usb.c
+++ b/drivers/net/wireless/rt2x00/rt2x00usb.c
@@ -25,6 +25,7 @@
25 25
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/slab.h>
28#include <linux/usb.h> 29#include <linux/usb.h>
29#include <linux/bug.h> 30#include <linux/bug.h>
30 31
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index 17747274217..432e75f960b 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -30,6 +30,7 @@
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/kernel.h> 31#include <linux/kernel.h>
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/slab.h>
33#include <linux/pci.h> 34#include <linux/pci.h>
34#include <linux/eeprom_93cx6.h> 35#include <linux/eeprom_93cx6.h>
35 36
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index 290d70bc5d2..bb58d797fb7 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -30,6 +30,7 @@
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/kernel.h> 31#include <linux/kernel.h>
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/slab.h>
33#include <linux/usb.h> 34#include <linux/usb.h>
34 35
35#include "rt2x00.h" 36#include "rt2x00.h"
diff --git a/drivers/net/wireless/rtl818x/rtl8180_dev.c b/drivers/net/wireless/rtl818x/rtl8180_dev.c
index 2b928ecf47b..2131a442831 100644
--- a/drivers/net/wireless/rtl818x/rtl8180_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8180_dev.c
@@ -17,6 +17,7 @@
17 17
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/pci.h> 19#include <linux/pci.h>
20#include <linux/slab.h>
20#include <linux/delay.h> 21#include <linux/delay.h>
21#include <linux/etherdevice.h> 22#include <linux/etherdevice.h>
22#include <linux/eeprom_93cx6.h> 23#include <linux/eeprom_93cx6.h>
diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c
index 0fb850e0c65..1d30792973f 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c
@@ -22,6 +22,7 @@
22 22
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/usb.h> 24#include <linux/usb.h>
25#include <linux/slab.h>
25#include <linux/delay.h> 26#include <linux/delay.h>
26#include <linux/etherdevice.h> 27#include <linux/etherdevice.h>
27#include <linux/eeprom_93cx6.h> 28#include <linux/eeprom_93cx6.h>
diff --git a/drivers/net/wireless/wl12xx/wl1251_acx.c b/drivers/net/wireless/wl12xx/wl1251_acx.c
index beff084040b..91891f92807 100644
--- a/drivers/net/wireless/wl12xx/wl1251_acx.c
+++ b/drivers/net/wireless/wl12xx/wl1251_acx.c
@@ -1,6 +1,7 @@
1#include "wl1251_acx.h" 1#include "wl1251_acx.h"
2 2
3#include <linux/module.h> 3#include <linux/module.h>
4#include <linux/slab.h>
4#include <linux/crc7.h> 5#include <linux/crc7.h>
5 6
6#include "wl1251.h" 7#include "wl1251.h"
diff --git a/drivers/net/wireless/wl12xx/wl1251_boot.c b/drivers/net/wireless/wl12xx/wl1251_boot.c
index 28a80867408..d5ac79aeaa7 100644
--- a/drivers/net/wireless/wl12xx/wl1251_boot.c
+++ b/drivers/net/wireless/wl12xx/wl1251_boot.c
@@ -22,6 +22,7 @@
22 */ 22 */
23 23
24#include <linux/gpio.h> 24#include <linux/gpio.h>
25#include <linux/slab.h>
25 26
26#include "wl1251_reg.h" 27#include "wl1251_reg.h"
27#include "wl1251_boot.h" 28#include "wl1251_boot.h"
diff --git a/drivers/net/wireless/wl12xx/wl1251_cmd.c b/drivers/net/wireless/wl12xx/wl1251_cmd.c
index 0320b478bb3..a37b30cef48 100644
--- a/drivers/net/wireless/wl12xx/wl1251_cmd.c
+++ b/drivers/net/wireless/wl12xx/wl1251_cmd.c
@@ -1,6 +1,7 @@
1#include "wl1251_cmd.h" 1#include "wl1251_cmd.h"
2 2
3#include <linux/module.h> 3#include <linux/module.h>
4#include <linux/slab.h>
4#include <linux/crc7.h> 5#include <linux/crc7.h>
5 6
6#include "wl1251.h" 7#include "wl1251.h"
diff --git a/drivers/net/wireless/wl12xx/wl1251_debugfs.c b/drivers/net/wireless/wl12xx/wl1251_debugfs.c
index 0ccba57fb9f..5e4465ac08f 100644
--- a/drivers/net/wireless/wl12xx/wl1251_debugfs.c
+++ b/drivers/net/wireless/wl12xx/wl1251_debugfs.c
@@ -24,6 +24,7 @@
24#include "wl1251_debugfs.h" 24#include "wl1251_debugfs.h"
25 25
26#include <linux/skbuff.h> 26#include <linux/skbuff.h>
27#include <linux/slab.h>
27 28
28#include "wl1251.h" 29#include "wl1251.h"
29#include "wl1251_acx.h" 30#include "wl1251_acx.h"
@@ -466,7 +467,8 @@ out:
466 467
467void wl1251_debugfs_reset(struct wl1251 *wl) 468void wl1251_debugfs_reset(struct wl1251 *wl)
468{ 469{
469 memset(wl->stats.fw_stats, 0, sizeof(*wl->stats.fw_stats)); 470 if (wl->stats.fw_stats != NULL)
471 memset(wl->stats.fw_stats, 0, sizeof(*wl->stats.fw_stats));
470 wl->stats.retry_count = 0; 472 wl->stats.retry_count = 0;
471 wl->stats.excessive_retries = 0; 473 wl->stats.excessive_retries = 0;
472} 474}
diff --git a/drivers/net/wireless/wl12xx/wl1251_init.c b/drivers/net/wireless/wl12xx/wl1251_init.c
index 5aad56ea715..b538bdd7b32 100644
--- a/drivers/net/wireless/wl12xx/wl1251_init.c
+++ b/drivers/net/wireless/wl12xx/wl1251_init.c
@@ -23,6 +23,7 @@
23 23
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/slab.h>
26 27
27#include "wl1251_init.h" 28#include "wl1251_init.h"
28#include "wl12xx_80211.h" 29#include "wl12xx_80211.h"
diff --git a/drivers/net/wireless/wl12xx/wl1251_main.c b/drivers/net/wireless/wl12xx/wl1251_main.c
index 24ae6a360ac..1c8226eee40 100644
--- a/drivers/net/wireless/wl12xx/wl1251_main.c
+++ b/drivers/net/wireless/wl12xx/wl1251_main.c
@@ -29,6 +29,7 @@
29#include <linux/crc32.h> 29#include <linux/crc32.h>
30#include <linux/etherdevice.h> 30#include <linux/etherdevice.h>
31#include <linux/vmalloc.h> 31#include <linux/vmalloc.h>
32#include <linux/slab.h>
32 33
33#include "wl1251.h" 34#include "wl1251.h"
34#include "wl12xx_80211.h" 35#include "wl12xx_80211.h"
diff --git a/drivers/net/wireless/wl12xx/wl1251_rx.c b/drivers/net/wireless/wl12xx/wl1251_rx.c
index b56732226cc..6f229e0990f 100644
--- a/drivers/net/wireless/wl12xx/wl1251_rx.c
+++ b/drivers/net/wireless/wl12xx/wl1251_rx.c
@@ -23,6 +23,7 @@
23 */ 23 */
24 24
25#include <linux/skbuff.h> 25#include <linux/skbuff.h>
26#include <linux/gfp.h>
26#include <net/mac80211.h> 27#include <net/mac80211.h>
27 28
28#include "wl1251.h" 29#include "wl1251.h"
diff --git a/drivers/net/wireless/wl12xx/wl1251_spi.c b/drivers/net/wireless/wl12xx/wl1251_spi.c
index 9cc8c323830..3bfb59bd463 100644
--- a/drivers/net/wireless/wl12xx/wl1251_spi.c
+++ b/drivers/net/wireless/wl12xx/wl1251_spi.c
@@ -23,6 +23,7 @@
23 23
24#include <linux/irq.h> 24#include <linux/irq.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/slab.h>
26#include <linux/crc7.h> 27#include <linux/crc7.h>
27#include <linux/spi/spi.h> 28#include <linux/spi/spi.h>
28#include <linux/spi/wl12xx.h> 29#include <linux/spi/wl12xx.h>
diff --git a/drivers/net/wireless/wl12xx/wl1271_acx.c b/drivers/net/wireless/wl12xx/wl1271_acx.c
index 60f10dce480..308782421fc 100644
--- a/drivers/net/wireless/wl12xx/wl1271_acx.c
+++ b/drivers/net/wireless/wl12xx/wl1271_acx.c
@@ -27,6 +27,7 @@
27#include <linux/platform_device.h> 27#include <linux/platform_device.h>
28#include <linux/crc7.h> 28#include <linux/crc7.h>
29#include <linux/spi/spi.h> 29#include <linux/spi/spi.h>
30#include <linux/slab.h>
30 31
31#include "wl1271.h" 32#include "wl1271.h"
32#include "wl12xx_80211.h" 33#include "wl12xx_80211.h"
diff --git a/drivers/net/wireless/wl12xx/wl1271_boot.c b/drivers/net/wireless/wl12xx/wl1271_boot.c
index 2be76ee42bb..02435626306 100644
--- a/drivers/net/wireless/wl12xx/wl1271_boot.c
+++ b/drivers/net/wireless/wl12xx/wl1271_boot.c
@@ -22,6 +22,7 @@
22 */ 22 */
23 23
24#include <linux/gpio.h> 24#include <linux/gpio.h>
25#include <linux/slab.h>
25 26
26#include "wl1271_acx.h" 27#include "wl1271_acx.h"
27#include "wl1271_reg.h" 28#include "wl1271_reg.h"
diff --git a/drivers/net/wireless/wl12xx/wl1271_cmd.c b/drivers/net/wireless/wl12xx/wl1271_cmd.c
index 36a64e06f29..e7832f3318e 100644
--- a/drivers/net/wireless/wl12xx/wl1271_cmd.c
+++ b/drivers/net/wireless/wl12xx/wl1271_cmd.c
@@ -26,6 +26,7 @@
26#include <linux/crc7.h> 26#include <linux/crc7.h>
27#include <linux/spi/spi.h> 27#include <linux/spi/spi.h>
28#include <linux/etherdevice.h> 28#include <linux/etherdevice.h>
29#include <linux/slab.h>
29 30
30#include "wl1271.h" 31#include "wl1271.h"
31#include "wl1271_reg.h" 32#include "wl1271_reg.h"
diff --git a/drivers/net/wireless/wl12xx/wl1271_debugfs.c b/drivers/net/wireless/wl12xx/wl1271_debugfs.c
index 8d7588ca68f..3f7ff8d0cf5 100644
--- a/drivers/net/wireless/wl12xx/wl1271_debugfs.c
+++ b/drivers/net/wireless/wl12xx/wl1271_debugfs.c
@@ -24,6 +24,7 @@
24#include "wl1271_debugfs.h" 24#include "wl1271_debugfs.h"
25 25
26#include <linux/skbuff.h> 26#include <linux/skbuff.h>
27#include <linux/slab.h>
27 28
28#include "wl1271.h" 29#include "wl1271.h"
29#include "wl1271_acx.h" 30#include "wl1271_acx.h"
diff --git a/drivers/net/wireless/wl12xx/wl1271_init.c b/drivers/net/wireless/wl12xx/wl1271_init.c
index 86c30a86a45..d189e8fe05a 100644
--- a/drivers/net/wireless/wl12xx/wl1271_init.c
+++ b/drivers/net/wireless/wl12xx/wl1271_init.c
@@ -23,6 +23,7 @@
23 23
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/slab.h>
26 27
27#include "wl1271_init.h" 28#include "wl1271_init.h"
28#include "wl12xx_80211.h" 29#include "wl12xx_80211.h"
diff --git a/drivers/net/wireless/wl12xx/wl1271_main.c b/drivers/net/wireless/wl12xx/wl1271_main.c
index 2a864b24291..65a1aeba241 100644
--- a/drivers/net/wireless/wl12xx/wl1271_main.c
+++ b/drivers/net/wireless/wl12xx/wl1271_main.c
@@ -33,6 +33,7 @@
33#include <linux/vmalloc.h> 33#include <linux/vmalloc.h>
34#include <linux/spi/wl12xx.h> 34#include <linux/spi/wl12xx.h>
35#include <linux/inetdevice.h> 35#include <linux/inetdevice.h>
36#include <linux/slab.h>
36 37
37#include "wl1271.h" 38#include "wl1271.h"
38#include "wl12xx_80211.h" 39#include "wl12xx_80211.h"
diff --git a/drivers/net/wireless/wl12xx/wl1271_rx.c b/drivers/net/wireless/wl12xx/wl1271_rx.c
index 6730f5b96e7..c723d9c7e13 100644
--- a/drivers/net/wireless/wl12xx/wl1271_rx.c
+++ b/drivers/net/wireless/wl12xx/wl1271_rx.c
@@ -21,6 +21,8 @@
21 * 21 *
22 */ 22 */
23 23
24#include <linux/gfp.h>
25
24#include "wl1271.h" 26#include "wl1271.h"
25#include "wl1271_acx.h" 27#include "wl1271_acx.h"
26#include "wl1271_reg.h" 28#include "wl1271_reg.h"
diff --git a/drivers/net/wireless/wl12xx/wl1271_spi.c b/drivers/net/wireless/wl12xx/wl1271_spi.c
index 67a82934f36..053c84aceb4 100644
--- a/drivers/net/wireless/wl12xx/wl1271_spi.c
+++ b/drivers/net/wireless/wl12xx/wl1271_spi.c
@@ -25,6 +25,7 @@
25#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26#include <linux/crc7.h> 26#include <linux/crc7.h>
27#include <linux/spi/spi.h> 27#include <linux/spi/spi.h>
28#include <linux/slab.h>
28 29
29#include "wl1271.h" 30#include "wl1271.h"
30#include "wl12xx_80211.h" 31#include "wl12xx_80211.h"
diff --git a/drivers/net/wireless/wl12xx/wl1271_testmode.c b/drivers/net/wireless/wl12xx/wl1271_testmode.c
index 3919102e942..5c1c4f565fd 100644
--- a/drivers/net/wireless/wl12xx/wl1271_testmode.c
+++ b/drivers/net/wireless/wl12xx/wl1271_testmode.c
@@ -22,6 +22,7 @@
22 */ 22 */
23#include "wl1271_testmode.h" 23#include "wl1271_testmode.h"
24 24
25#include <linux/slab.h>
25#include <net/genetlink.h> 26#include <net/genetlink.h>
26 27
27#include "wl1271.h" 28#include "wl1271.h"
diff --git a/drivers/net/wireless/zd1201.c b/drivers/net/wireless/zd1201.c
index 6917286edca..9d127787464 100644
--- a/drivers/net/wireless/zd1201.c
+++ b/drivers/net/wireless/zd1201.c
@@ -14,6 +14,7 @@
14 14
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/usb.h> 16#include <linux/usb.h>
17#include <linux/slab.h>
17#include <linux/netdevice.h> 18#include <linux/netdevice.h>
18#include <linux/etherdevice.h> 19#include <linux/etherdevice.h>
19#include <linux/wireless.h> 20#include <linux/wireless.h>
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c
index 7ca95c414fa..b2af3c549bb 100644
--- a/drivers/net/wireless/zd1211rw/zd_chip.c
+++ b/drivers/net/wireless/zd1211rw/zd_chip.c
@@ -25,6 +25,7 @@
25 25
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/errno.h> 27#include <linux/errno.h>
28#include <linux/slab.h>
28 29
29#include "zd_def.h" 30#include "zd_def.h"
30#include "zd_chip.h" 31#include "zd_chip.h"
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index 00e09e26c82..16fa289ad77 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -22,6 +22,7 @@
22 22
23#include <linux/netdevice.h> 23#include <linux/netdevice.h>
24#include <linux/etherdevice.h> 24#include <linux/etherdevice.h>
25#include <linux/slab.h>
25#include <linux/usb.h> 26#include <linux/usb.h>
26#include <linux/jiffies.h> 27#include <linux/jiffies.h>
27#include <net/ieee80211_radiotap.h> 28#include <net/ieee80211_radiotap.h>
diff --git a/drivers/net/wireless/zd1211rw/zd_rf_uw2453.c b/drivers/net/wireless/zd1211rw/zd_rf_uw2453.c
index 439799b8487..9e74eb1b67d 100644
--- a/drivers/net/wireless/zd1211rw/zd_rf_uw2453.c
+++ b/drivers/net/wireless/zd1211rw/zd_rf_uw2453.c
@@ -19,6 +19,7 @@
19 */ 19 */
20 20
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/slab.h>
22 23
23#include "zd_rf.h" 24#include "zd_rf.h"
24#include "zd_usb.h" 25#include "zd_usb.h"
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
index 442fc111732..d91ad1a612a 100644
--- a/drivers/net/wireless/zd1211rw/zd_usb.c
+++ b/drivers/net/wireless/zd1211rw/zd_usb.c
@@ -24,6 +24,7 @@
24#include <linux/firmware.h> 24#include <linux/firmware.h>
25#include <linux/device.h> 25#include <linux/device.h>
26#include <linux/errno.h> 26#include <linux/errno.h>
27#include <linux/slab.h>
27#include <linux/skbuff.h> 28#include <linux/skbuff.h>
28#include <linux/usb.h> 29#include <linux/usb.h>
29#include <linux/workqueue.h> 30#include <linux/workqueue.h>
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index a869b45d3d3..d504e2b6025 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -40,6 +40,7 @@
40#include <linux/udp.h> 40#include <linux/udp.h>
41#include <linux/moduleparam.h> 41#include <linux/moduleparam.h>
42#include <linux/mm.h> 42#include <linux/mm.h>
43#include <linux/slab.h>
43#include <net/ip.h> 44#include <net/ip.h>
44 45
45#include <xen/xen.h> 46#include <xen/xen.h>
diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c
index 1a74594224b..1e783ccc306 100644
--- a/drivers/net/xilinx_emaclite.c
+++ b/drivers/net/xilinx_emaclite.c
@@ -19,6 +19,7 @@
19#include <linux/etherdevice.h> 19#include <linux/etherdevice.h>
20#include <linux/skbuff.h> 20#include <linux/skbuff.h>
21#include <linux/io.h> 21#include <linux/io.h>
22#include <linux/slab.h>
22 23
23#include <linux/of_device.h> 24#include <linux/of_device.h>
24#include <linux/of_platform.h> 25#include <linux/of_platform.h>
diff --git a/drivers/net/xtsonic.c b/drivers/net/xtsonic.c
index 389ba9df712..fdba9cb3a59 100644
--- a/drivers/net/xtsonic.c
+++ b/drivers/net/xtsonic.c
@@ -20,11 +20,11 @@
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/types.h> 21#include <linux/types.h>
22#include <linux/fcntl.h> 22#include <linux/fcntl.h>
23#include <linux/gfp.h>
23#include <linux/interrupt.h> 24#include <linux/interrupt.h>
24#include <linux/init.h> 25#include <linux/init.h>
25#include <linux/ioport.h> 26#include <linux/ioport.h>
26#include <linux/in.h> 27#include <linux/in.h>
27#include <linux/slab.h>
28#include <linux/string.h> 28#include <linux/string.h>
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/errno.h> 30#include <linux/errno.h>
@@ -33,6 +33,7 @@
33#include <linux/skbuff.h> 33#include <linux/skbuff.h>
34#include <linux/platform_device.h> 34#include <linux/platform_device.h>
35#include <linux/dma-mapping.h> 35#include <linux/dma-mapping.h>
36#include <linux/slab.h>
36 37
37#include <asm/io.h> 38#include <asm/io.h>
38#include <asm/pgtable.h> 39#include <asm/pgtable.h>
diff --git a/drivers/net/yellowfin.c b/drivers/net/yellowfin.c
index 7d4107f5eeb..ede5b2436f2 100644
--- a/drivers/net/yellowfin.c
+++ b/drivers/net/yellowfin.c
@@ -90,7 +90,6 @@ static int gx_fix;
90#include <linux/timer.h> 90#include <linux/timer.h>
91#include <linux/errno.h> 91#include <linux/errno.h>
92#include <linux/ioport.h> 92#include <linux/ioport.h>
93#include <linux/slab.h>
94#include <linux/interrupt.h> 93#include <linux/interrupt.h>
95#include <linux/pci.h> 94#include <linux/pci.h>
96#include <linux/init.h> 95#include <linux/init.h>
diff --git a/drivers/net/znet.c b/drivers/net/znet.c
index def49d2ec69..dbfef8d70f2 100644
--- a/drivers/net/znet.c
+++ b/drivers/net/znet.c
@@ -88,6 +88,7 @@
88#include <linux/module.h> 88#include <linux/module.h>
89#include <linux/kernel.h> 89#include <linux/kernel.h>
90#include <linux/string.h> 90#include <linux/string.h>
91#include <linux/slab.h>
91#include <linux/errno.h> 92#include <linux/errno.h>
92#include <linux/interrupt.h> 93#include <linux/interrupt.h>
93#include <linux/ioport.h> 94#include <linux/ioport.h>
diff --git a/drivers/nubus/nubus.c b/drivers/nubus/nubus.c
index f5f75844954..b764ac22d52 100644
--- a/drivers/nubus/nubus.c
+++ b/drivers/nubus/nubus.c
@@ -15,6 +15,7 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/slab.h>
18#include <asm/setup.h> 19#include <asm/setup.h>
19#include <asm/system.h> 20#include <asm/system.h>
20#include <asm/page.h> 21#include <asm/page.h>
diff --git a/drivers/of/base.c b/drivers/of/base.c
index cb96888d142..b5ad9740d8b 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -20,6 +20,7 @@
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/of.h> 21#include <linux/of.h>
22#include <linux/spinlock.h> 22#include <linux/spinlock.h>
23#include <linux/slab.h>
23#include <linux/proc_fs.h> 24#include <linux/proc_fs.h>
24 25
25struct device_node *allnodes; 26struct device_node *allnodes;
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 406757a9d7e..dee4fb56b09 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -376,8 +376,11 @@ unsigned long __init unflatten_dt_node(unsigned long mem,
376 if (!np->type) 376 if (!np->type)
377 np->type = "<NULL>"; 377 np->type = "<NULL>";
378 } 378 }
379 while (tag == OF_DT_BEGIN_NODE) { 379 while (tag == OF_DT_BEGIN_NODE || tag == OF_DT_NOP) {
380 mem = unflatten_dt_node(mem, p, np, allnextpp, fpsize); 380 if (tag == OF_DT_NOP)
381 *p += 4;
382 else
383 mem = unflatten_dt_node(mem, p, np, allnextpp, fpsize);
381 tag = be32_to_cpup((__be32 *)(*p)); 384 tag = be32_to_cpup((__be32 *)(*p));
382 } 385 }
383 if (tag != OF_DT_END_NODE) { 386 if (tag != OF_DT_END_NODE) {
diff --git a/drivers/of/gpio.c b/drivers/of/gpio.c
index 24c3606217f..a1b31a4abae 100644
--- a/drivers/of/gpio.c
+++ b/drivers/of/gpio.c
@@ -15,6 +15,7 @@
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/io.h> 16#include <linux/io.h>
17#include <linux/of.h> 17#include <linux/of.h>
18#include <linux/slab.h>
18#include <linux/of_gpio.h> 19#include <linux/of_gpio.h>
19#include <asm/prom.h> 20#include <asm/prom.h>
20 21
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
index 18ecae4a437..b4748337223 100644
--- a/drivers/of/of_mdio.c
+++ b/drivers/of/of_mdio.c
@@ -69,7 +69,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
69 } 69 }
70 70
71 phy = get_phy_device(mdio, be32_to_cpup(addr)); 71 phy = get_phy_device(mdio, be32_to_cpup(addr));
72 if (!phy) { 72 if (!phy || IS_ERR(phy)) {
73 dev_err(&mdio->dev, "error probing PHY at address %i\n", 73 dev_err(&mdio->dev, "error probing PHY at address %i\n",
74 *addr); 74 *addr);
75 continue; 75 continue;
diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
index c9e2ae90f19..a9352b2c7ac 100644
--- a/drivers/oprofile/buffer_sync.c
+++ b/drivers/oprofile/buffer_sync.c
@@ -30,6 +30,7 @@
30#include <linux/fs.h> 30#include <linux/fs.h>
31#include <linux/oprofile.h> 31#include <linux/oprofile.h>
32#include <linux/sched.h> 32#include <linux/sched.h>
33#include <linux/gfp.h>
33 34
34#include "oprofile_stats.h" 35#include "oprofile_stats.h"
35#include "event_buffer.h" 36#include "event_buffer.h"
diff --git a/drivers/parisc/asp.c b/drivers/parisc/asp.c
index 9ca21098b14..6a1ab2512a5 100644
--- a/drivers/parisc/asp.c
+++ b/drivers/parisc/asp.c
@@ -15,7 +15,6 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/slab.h>
19#include <linux/types.h> 18#include <linux/types.h>
20#include <asm/io.h> 19#include <asm/io.h>
21#include <asm/led.h> 20#include <asm/led.h>
diff --git a/drivers/parisc/ccio-rm-dma.c b/drivers/parisc/ccio-rm-dma.c
index 356b8357bcc..f78f6f1aef4 100644
--- a/drivers/parisc/ccio-rm-dma.c
+++ b/drivers/parisc/ccio-rm-dma.c
@@ -38,6 +38,7 @@
38#include <linux/mm.h> 38#include <linux/mm.h>
39#include <linux/string.h> 39#include <linux/string.h>
40#include <linux/pci.h> 40#include <linux/pci.h>
41#include <linux/gfp.h>
41 42
42#include <asm/uaccess.h> 43#include <asm/uaccess.h>
43 44
diff --git a/drivers/parisc/gsc.c b/drivers/parisc/gsc.c
index c4e1f3c3c2f..20a1bce1a03 100644
--- a/drivers/parisc/gsc.c
+++ b/drivers/parisc/gsc.c
@@ -19,7 +19,6 @@
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#include <linux/ioport.h> 20#include <linux/ioport.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/slab.h>
23#include <linux/types.h> 22#include <linux/types.h>
24 23
25#include <asm/hardware.h> 24#include <asm/hardware.h>
diff --git a/drivers/parport/daisy.c b/drivers/parport/daisy.c
index 3c8f06c3a5a..5bed17f68ef 100644
--- a/drivers/parport/daisy.c
+++ b/drivers/parport/daisy.c
@@ -22,6 +22,7 @@
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/parport.h> 23#include <linux/parport.h>
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/slab.h>
25#include <linux/sched.h> 26#include <linux/sched.h>
26 27
27#include <asm/current.h> 28#include <asm/current.h>
diff --git a/drivers/parport/parport_ax88796.c b/drivers/parport/parport_ax88796.c
index 6938d2e9f18..2c5ac2bf5c5 100644
--- a/drivers/parport/parport_ax88796.c
+++ b/drivers/parport/parport_ax88796.c
@@ -15,6 +15,7 @@
15#include <linux/interrupt.h> 15#include <linux/interrupt.h>
16#include <linux/errno.h> 16#include <linux/errno.h>
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/slab.h>
18 19
19#include <asm/io.h> 20#include <asm/io.h>
20#include <asm/irq.h> 21#include <asm/irq.h>
diff --git a/drivers/parport/parport_ip32.c b/drivers/parport/parport_ip32.c
index 6d58bf895b1..d3d7809af8b 100644
--- a/drivers/parport/parport_ip32.c
+++ b/drivers/parport/parport_ip32.c
@@ -103,6 +103,7 @@
103#include <linux/module.h> 103#include <linux/module.h>
104#include <linux/parport.h> 104#include <linux/parport.h>
105#include <linux/sched.h> 105#include <linux/sched.h>
106#include <linux/slab.h>
106#include <linux/spinlock.h> 107#include <linux/spinlock.h>
107#include <linux/stddef.h> 108#include <linux/stddef.h>
108#include <linux/types.h> 109#include <linux/types.h>
diff --git a/drivers/parport/parport_serial.c b/drivers/parport/parport_serial.c
index c3bb84ac931..40e208d130f 100644
--- a/drivers/parport/parport_serial.c
+++ b/drivers/parport/parport_serial.c
@@ -20,6 +20,7 @@
20#include <linux/types.h> 20#include <linux/types.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/slab.h>
23#include <linux/pci.h> 24#include <linux/pci.h>
24#include <linux/interrupt.h> 25#include <linux/interrupt.h>
25#include <linux/parport.h> 26#include <linux/parport.h>
diff --git a/drivers/parport/probe.c b/drivers/parport/probe.c
index 0f6550719bc..d763bc9e44c 100644
--- a/drivers/parport/probe.c
+++ b/drivers/parport/probe.c
@@ -9,6 +9,7 @@
9#include <linux/parport.h> 9#include <linux/parport.h>
10#include <linux/ctype.h> 10#include <linux/ctype.h>
11#include <linux/string.h> 11#include <linux/string.h>
12#include <linux/slab.h>
12#include <asm/uaccess.h> 13#include <asm/uaccess.h>
13 14
14static const struct { 15static const struct {
diff --git a/drivers/pci/access.c b/drivers/pci/access.c
index db23200c487..2f646fe1260 100644
--- a/drivers/pci/access.c
+++ b/drivers/pci/access.c
@@ -2,6 +2,7 @@
2#include <linux/pci.h> 2#include <linux/pci.h>
3#include <linux/module.h> 3#include <linux/module.h>
4#include <linux/sched.h> 4#include <linux/sched.h>
5#include <linux/slab.h>
5#include <linux/ioport.h> 6#include <linux/ioport.h>
6#include <linux/wait.h> 7#include <linux/wait.h>
7 8
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index 26301cb25e7..628ea20a884 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -14,6 +14,7 @@
14#include <linux/ioport.h> 14#include <linux/ioport.h>
15#include <linux/proc_fs.h> 15#include <linux/proc_fs.h>
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/slab.h>
17 18
18#include "pci.h" 19#include "pci.h"
19 20
diff --git a/drivers/pci/dmar.c b/drivers/pci/dmar.c
index 83aae474759..33ead97f0c4 100644
--- a/drivers/pci/dmar.c
+++ b/drivers/pci/dmar.c
@@ -35,6 +35,7 @@
35#include <linux/interrupt.h> 35#include <linux/interrupt.h>
36#include <linux/tboot.h> 36#include <linux/tboot.h>
37#include <linux/dmi.h> 37#include <linux/dmi.h>
38#include <linux/slab.h>
38 39
39#define PREFIX "DMAR: " 40#define PREFIX "DMAR: "
40 41
diff --git a/drivers/pci/hotplug/acpi_pcihp.c b/drivers/pci/hotplug/acpi_pcihp.c
index 3c76fc67cf0..45fcc1e96df 100644
--- a/drivers/pci/hotplug/acpi_pcihp.c
+++ b/drivers/pci/hotplug/acpi_pcihp.c
@@ -32,6 +32,7 @@
32#include <linux/pci_hotplug.h> 32#include <linux/pci_hotplug.h>
33#include <linux/acpi.h> 33#include <linux/acpi.h>
34#include <linux/pci-acpi.h> 34#include <linux/pci-acpi.h>
35#include <linux/slab.h>
35 36
36#define MY_NAME "acpi_pcihp" 37#define MY_NAME "acpi_pcihp"
37 38
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index b5dad9f3745..cb23aa2ebf9 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -47,6 +47,7 @@
47#include <linux/pci_hotplug.h> 47#include <linux/pci_hotplug.h>
48#include <linux/pci-acpi.h> 48#include <linux/pci-acpi.h>
49#include <linux/mutex.h> 49#include <linux/mutex.h>
50#include <linux/slab.h>
50 51
51#include "../pci.h" 52#include "../pci.h"
52#include "acpiphp.h" 53#include "acpiphp.h"
diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
index aa5df485f8c..6ecbfb27db9 100644
--- a/drivers/pci/hotplug/acpiphp_ibm.c
+++ b/drivers/pci/hotplug/acpiphp_ibm.c
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/slab.h>
29#include <linux/module.h> 30#include <linux/module.h>
30#include <linux/kernel.h> 31#include <linux/kernel.h>
31#include <acpi/acpi_bus.h> 32#include <acpi/acpi_bus.h>
diff --git a/drivers/pci/hotplug/cpqphp_sysfs.c b/drivers/pci/hotplug/cpqphp_sysfs.c
index e6089bdb6e5..56215322930 100644
--- a/drivers/pci/hotplug/cpqphp_sysfs.c
+++ b/drivers/pci/hotplug/cpqphp_sysfs.c
@@ -28,6 +28,7 @@
28 28
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/kernel.h> 30#include <linux/kernel.h>
31#include <linux/slab.h>
31#include <linux/types.h> 32#include <linux/types.h>
32#include <linux/proc_fs.h> 33#include <linux/proc_fs.h>
33#include <linux/workqueue.h> 34#include <linux/workqueue.h>
diff --git a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c
index 0a894efd4b9..5317e4d7d96 100644
--- a/drivers/pci/hotplug/fakephp.c
+++ b/drivers/pci/hotplug/fakephp.c
@@ -19,6 +19,7 @@
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/pci.h> 20#include <linux/pci.h>
21#include <linux/device.h> 21#include <linux/device.h>
22#include <linux/slab.h>
22#include "../pci.h" 23#include "../pci.h"
23 24
24struct legacy_slot { 25struct legacy_slot {
diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
index 728b119f71a..6d2eea93298 100644
--- a/drivers/pci/hotplug/pci_hotplug_core.c
+++ b/drivers/pci/hotplug/pci_hotplug_core.c
@@ -33,7 +33,6 @@
33#include <linux/kobject.h> 33#include <linux/kobject.h>
34#include <linux/sysfs.h> 34#include <linux/sysfs.h>
35#include <linux/pagemap.h> 35#include <linux/pagemap.h>
36#include <linux/slab.h>
37#include <linux/init.h> 36#include <linux/init.h>
38#include <linux/mount.h> 37#include <linux/mount.h>
39#include <linux/namei.h> 38#include <linux/namei.h>
diff --git a/drivers/pci/hotplug/pciehp_acpi.c b/drivers/pci/hotplug/pciehp_acpi.c
index b09b083011d..1f4000a5a10 100644
--- a/drivers/pci/hotplug/pciehp_acpi.c
+++ b/drivers/pci/hotplug/pciehp_acpi.c
@@ -26,6 +26,7 @@
26#include <linux/acpi.h> 26#include <linux/acpi.h>
27#include <linux/pci.h> 27#include <linux/pci.h>
28#include <linux/pci_hotplug.h> 28#include <linux/pci_hotplug.h>
29#include <linux/slab.h>
29#include "pciehp.h" 30#include "pciehp.h"
30 31
31#define PCIEHP_DETECT_PCIE (0) 32#define PCIEHP_DETECT_PCIE (0)
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index 920f820edf8..3588ea61b0d 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -30,6 +30,7 @@
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/moduleparam.h> 31#include <linux/moduleparam.h>
32#include <linux/kernel.h> 32#include <linux/kernel.h>
33#include <linux/slab.h>
33#include <linux/types.h> 34#include <linux/types.h>
34#include <linux/pci.h> 35#include <linux/pci.h>
35#include "pciehp.h" 36#include "pciehp.h"
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
index 9a7f247e8ac..8f58148be04 100644
--- a/drivers/pci/hotplug/pciehp_ctrl.c
+++ b/drivers/pci/hotplug/pciehp_ctrl.c
@@ -30,6 +30,7 @@
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/kernel.h> 31#include <linux/kernel.h>
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/slab.h>
33#include <linux/pci.h> 34#include <linux/pci.h>
34#include <linux/workqueue.h> 35#include <linux/workqueue.h>
35#include "../pci.h" 36#include "../pci.h"
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index 40b48f569b1..0cd42047d89 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -36,6 +36,7 @@
36#include <linux/pci.h> 36#include <linux/pci.h>
37#include <linux/interrupt.h> 37#include <linux/interrupt.h>
38#include <linux/time.h> 38#include <linux/time.h>
39#include <linux/slab.h>
39 40
40#include "../pci.h" 41#include "../pci.h"
41#include "pciehp.h" 42#include "pciehp.h"
@@ -832,9 +833,8 @@ static inline void dbg_ctrl(struct controller *ctrl)
832 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { 833 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
833 if (!pci_resource_len(pdev, i)) 834 if (!pci_resource_len(pdev, i))
834 continue; 835 continue;
835 ctrl_info(ctrl, " PCI resource [%d] : 0x%llx@0x%llx\n", 836 ctrl_info(ctrl, " PCI resource [%d] : %pR\n",
836 i, (unsigned long long)pci_resource_len(pdev, i), 837 i, &pdev->resource[i]);
837 (unsigned long long)pci_resource_start(pdev, i));
838 } 838 }
839 ctrl_info(ctrl, "Slot Capabilities : 0x%08x\n", ctrl->slot_cap); 839 ctrl_info(ctrl, "Slot Capabilities : 0x%08x\n", ctrl->slot_cap);
840 ctrl_info(ctrl, " Physical Slot Number : %d\n", PSN(ctrl)); 840 ctrl_info(ctrl, " Physical Slot Number : %d\n", PSN(ctrl));
diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c
index 4e3e0382c16..083034710fa 100644
--- a/drivers/pci/hotplug/rpadlpar_core.c
+++ b/drivers/pci/hotplug/rpadlpar_core.c
@@ -20,6 +20,7 @@
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/pci.h> 21#include <linux/pci.h>
22#include <linux/string.h> 22#include <linux/string.h>
23#include <linux/vmalloc.h>
23 24
24#include <asm/pci-bridge.h> 25#include <asm/pci-bridge.h>
25#include <linux/mutex.h> 26#include <linux/mutex.h>
@@ -430,6 +431,8 @@ int dlpar_remove_slot(char *drc_name)
430 rc = dlpar_remove_pci_slot(drc_name, dn); 431 rc = dlpar_remove_pci_slot(drc_name, dn);
431 break; 432 break;
432 } 433 }
434 vm_unmap_aliases();
435
433 printk(KERN_INFO "%s: slot %s removed\n", DLPAR_MODULE_NAME, drc_name); 436 printk(KERN_INFO "%s: slot %s removed\n", DLPAR_MODULE_NAME, drc_name);
434exit: 437exit:
435 mutex_unlock(&rpadlpar_mutex); 438 mutex_unlock(&rpadlpar_mutex);
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
index dcaae725fd7..ef7411c660b 100644
--- a/drivers/pci/hotplug/rpaphp_core.c
+++ b/drivers/pci/hotplug/rpaphp_core.c
@@ -27,9 +27,9 @@
27#include <linux/moduleparam.h> 27#include <linux/moduleparam.h>
28#include <linux/pci.h> 28#include <linux/pci.h>
29#include <linux/pci_hotplug.h> 29#include <linux/pci_hotplug.h>
30#include <linux/slab.h>
31#include <linux/smp.h> 30#include <linux/smp.h>
32#include <linux/init.h> 31#include <linux/init.h>
32#include <linux/vmalloc.h>
33#include <asm/eeh.h> /* for eeh_add_device() */ 33#include <asm/eeh.h> /* for eeh_add_device() */
34#include <asm/rtas.h> /* rtas_call */ 34#include <asm/rtas.h> /* rtas_call */
35#include <asm/pci-bridge.h> /* for pci_controller */ 35#include <asm/pci-bridge.h> /* for pci_controller */
@@ -419,6 +419,8 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
419 return -EINVAL; 419 return -EINVAL;
420 420
421 pcibios_remove_pci_devices(slot->bus); 421 pcibios_remove_pci_devices(slot->bus);
422 vm_unmap_aliases();
423
422 slot->state = NOT_CONFIGURED; 424 slot->state = NOT_CONFIGURED;
423 return 0; 425 return 0;
424} 426}
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c
index 8aebe1e9d3d..72d507b6a2a 100644
--- a/drivers/pci/hotplug/sgi_hotplug.c
+++ b/drivers/pci/hotplug/sgi_hotplug.c
@@ -15,6 +15,7 @@
15#include <linux/pci.h> 15#include <linux/pci.h>
16#include <linux/pci_hotplug.h> 16#include <linux/pci_hotplug.h>
17#include <linux/proc_fs.h> 17#include <linux/proc_fs.h>
18#include <linux/slab.h>
18#include <linux/types.h> 19#include <linux/types.h>
19#include <linux/mutex.h> 20#include <linux/mutex.h>
20 21
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c
index a5062297f48..a7bd5048396 100644
--- a/drivers/pci/hotplug/shpchp_core.c
+++ b/drivers/pci/hotplug/shpchp_core.c
@@ -31,6 +31,7 @@
31#include <linux/moduleparam.h> 31#include <linux/moduleparam.h>
32#include <linux/kernel.h> 32#include <linux/kernel.h>
33#include <linux/types.h> 33#include <linux/types.h>
34#include <linux/slab.h>
34#include <linux/pci.h> 35#include <linux/pci.h>
35#include <linux/workqueue.h> 36#include <linux/workqueue.h>
36#include "shpchp.h" 37#include "shpchp.h"
diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
index 3bba0c0888f..3387fbfb0c5 100644
--- a/drivers/pci/hotplug/shpchp_ctrl.c
+++ b/drivers/pci/hotplug/shpchp_ctrl.c
@@ -30,6 +30,7 @@
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/kernel.h> 31#include <linux/kernel.h>
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/slab.h>
33#include <linux/pci.h> 34#include <linux/pci.h>
34#include <linux/workqueue.h> 35#include <linux/workqueue.h>
35#include "../pci.h" 36#include "../pci.h"
diff --git a/drivers/pci/htirq.c b/drivers/pci/htirq.c
index 737a1c44b07..98abf8b9129 100644
--- a/drivers/pci/htirq.c
+++ b/drivers/pci/htirq.c
@@ -10,7 +10,6 @@
10#include <linux/pci.h> 10#include <linux/pci.h>
11#include <linux/spinlock.h> 11#include <linux/spinlock.h>
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/gfp.h>
14#include <linux/htirq.h> 13#include <linux/htirq.h>
15 14
16/* Global ht irq lock. 15/* Global ht irq lock.
diff --git a/drivers/pci/intr_remapping.c b/drivers/pci/intr_remapping.c
index 95b849130ad..6ee98a56946 100644
--- a/drivers/pci/intr_remapping.c
+++ b/drivers/pci/intr_remapping.c
@@ -1,6 +1,7 @@
1#include <linux/interrupt.h> 1#include <linux/interrupt.h>
2#include <linux/dmar.h> 2#include <linux/dmar.h>
3#include <linux/spinlock.h> 3#include <linux/spinlock.h>
4#include <linux/slab.h>
4#include <linux/jiffies.h> 5#include <linux/jiffies.h>
5#include <linux/hpet.h> 6#include <linux/hpet.h>
6#include <linux/pci.h> 7#include <linux/pci.h>
diff --git a/drivers/pci/ioapic.c b/drivers/pci/ioapic.c
index 3e0d7b5dd1b..203508b227b 100644
--- a/drivers/pci/ioapic.c
+++ b/drivers/pci/ioapic.c
@@ -18,6 +18,7 @@
18 18
19#include <linux/pci.h> 19#include <linux/pci.h>
20#include <linux/acpi.h> 20#include <linux/acpi.h>
21#include <linux/slab.h>
21#include <acpi/acpi_bus.h> 22#include <acpi/acpi_bus.h>
22 23
23struct ioapic { 24struct ioapic {
@@ -31,9 +32,9 @@ static int ioapic_probe(struct pci_dev *dev, const struct pci_device_id *ent)
31 acpi_status status; 32 acpi_status status;
32 unsigned long long gsb; 33 unsigned long long gsb;
33 struct ioapic *ioapic; 34 struct ioapic *ioapic;
34 u64 addr;
35 int ret; 35 int ret;
36 char *type; 36 char *type;
37 struct resource *res;
37 38
38 handle = DEVICE_ACPI_HANDLE(&dev->dev); 39 handle = DEVICE_ACPI_HANDLE(&dev->dev);
39 if (!handle) 40 if (!handle)
@@ -69,13 +70,12 @@ static int ioapic_probe(struct pci_dev *dev, const struct pci_device_id *ent)
69 if (pci_request_region(dev, 0, type)) 70 if (pci_request_region(dev, 0, type))
70 goto exit_disable; 71 goto exit_disable;
71 72
72 addr = pci_resource_start(dev, 0); 73 res = &dev->resource[0];
73 if (acpi_register_ioapic(ioapic->handle, addr, ioapic->gsi_base)) 74 if (acpi_register_ioapic(ioapic->handle, res->start, ioapic->gsi_base))
74 goto exit_release; 75 goto exit_release;
75 76
76 pci_set_drvdata(dev, ioapic); 77 pci_set_drvdata(dev, ioapic);
77 dev_info(&dev->dev, "%s at %#llx, GSI %u\n", type, addr, 78 dev_info(&dev->dev, "%s at %pR, GSI %u\n", type, res, ioapic->gsi_base);
78 ioapic->gsi_base);
79 return 0; 79 return 0;
80 80
81exit_release: 81exit_release:
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index 3e5ab2bf6a5..ce6a3666b3d 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -9,6 +9,7 @@
9 */ 9 */
10 10
11#include <linux/pci.h> 11#include <linux/pci.h>
12#include <linux/slab.h>
12#include <linux/mutex.h> 13#include <linux/mutex.h>
13#include <linux/string.h> 14#include <linux/string.h>
14#include <linux/delay.h> 15#include <linux/delay.h>
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index f9cf3173b23..77b68eaf021 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -18,6 +18,7 @@
18#include <linux/smp.h> 18#include <linux/smp.h>
19#include <linux/errno.h> 19#include <linux/errno.h>
20#include <linux/io.h> 20#include <linux/io.h>
21#include <linux/slab.h>
21 22
22#include "pci.h" 23#include "pci.h"
23#include "msi.h" 24#include "msi.h"
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index de296452c95..fad93983bfe 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -23,6 +23,7 @@
23#include <linux/mm.h> 23#include <linux/mm.h>
24#include <linux/capability.h> 24#include <linux/capability.h>
25#include <linux/pci-aspm.h> 25#include <linux/pci-aspm.h>
26#include <linux/slab.h>
26#include "pci.h" 27#include "pci.h"
27 28
28static int sysfs_initialized; /* = 0 */ 29static int sysfs_initialized; /* = 0 */
@@ -655,8 +656,8 @@ void pci_create_legacy_files(struct pci_bus *b)
655 goto legacy_io_err; 656 goto legacy_io_err;
656 657
657 /* Allocated above after the legacy_io struct */ 658 /* Allocated above after the legacy_io struct */
658 sysfs_bin_attr_init(b->legacy_mem);
659 b->legacy_mem = b->legacy_io + 1; 659 b->legacy_mem = b->legacy_io + 1;
660 sysfs_bin_attr_init(b->legacy_mem);
660 b->legacy_mem->attr.name = "legacy_mem"; 661 b->legacy_mem->attr.name = "legacy_mem";
661 b->legacy_mem->size = 1024*1024; 662 b->legacy_mem->size = 1024*1024;
662 b->legacy_mem->attr.mode = S_IRUSR | S_IWUSR; 663 b->legacy_mem->attr.mode = S_IRUSR | S_IWUSR;
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index cb1dd5f4988..37499127c80 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -12,6 +12,7 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/pci.h> 13#include <linux/pci.h>
14#include <linux/pm.h> 14#include <linux/pm.h>
15#include <linux/slab.h>
15#include <linux/module.h> 16#include <linux/module.h>
16#include <linux/spinlock.h> 17#include <linux/spinlock.h>
17#include <linux/string.h> 18#include <linux/string.h>
@@ -678,7 +679,7 @@ static void __pci_start_power_transition(struct pci_dev *dev, pci_power_t state)
678 */ 679 */
679int __pci_complete_power_transition(struct pci_dev *dev, pci_power_t state) 680int __pci_complete_power_transition(struct pci_dev *dev, pci_power_t state)
680{ 681{
681 return state > PCI_D0 ? 682 return state >= PCI_D0 ?
682 pci_platform_power_transition(dev, state) : -EINVAL; 683 pci_platform_power_transition(dev, state) : -EINVAL;
683} 684}
684EXPORT_SYMBOL_GPL(__pci_complete_power_transition); 685EXPORT_SYMBOL_GPL(__pci_complete_power_transition);
@@ -715,10 +716,6 @@ int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
715 */ 716 */
716 return 0; 717 return 0;
717 718
718 /* Check if we're already there */
719 if (dev->current_state == state)
720 return 0;
721
722 __pci_start_power_transition(dev, state); 719 __pci_start_power_transition(dev, state);
723 720
724 /* This device is quirked not to be put into D3, so 721 /* This device is quirked not to be put into D3, so
@@ -2576,18 +2573,17 @@ EXPORT_SYMBOL_GPL(pci_reset_function);
2576 */ 2573 */
2577int pcix_get_max_mmrbc(struct pci_dev *dev) 2574int pcix_get_max_mmrbc(struct pci_dev *dev)
2578{ 2575{
2579 int err, cap; 2576 int cap;
2580 u32 stat; 2577 u32 stat;
2581 2578
2582 cap = pci_find_capability(dev, PCI_CAP_ID_PCIX); 2579 cap = pci_find_capability(dev, PCI_CAP_ID_PCIX);
2583 if (!cap) 2580 if (!cap)
2584 return -EINVAL; 2581 return -EINVAL;
2585 2582
2586 err = pci_read_config_dword(dev, cap + PCI_X_STATUS, &stat); 2583 if (pci_read_config_dword(dev, cap + PCI_X_STATUS, &stat))
2587 if (err)
2588 return -EINVAL; 2584 return -EINVAL;
2589 2585
2590 return (stat & PCI_X_STATUS_MAX_READ) >> 12; 2586 return 512 << ((stat & PCI_X_STATUS_MAX_READ) >> 21);
2591} 2587}
2592EXPORT_SYMBOL(pcix_get_max_mmrbc); 2588EXPORT_SYMBOL(pcix_get_max_mmrbc);
2593 2589
@@ -2600,18 +2596,17 @@ EXPORT_SYMBOL(pcix_get_max_mmrbc);
2600 */ 2596 */
2601int pcix_get_mmrbc(struct pci_dev *dev) 2597int pcix_get_mmrbc(struct pci_dev *dev)
2602{ 2598{
2603 int ret, cap; 2599 int cap;
2604 u32 cmd; 2600 u16 cmd;
2605 2601
2606 cap = pci_find_capability(dev, PCI_CAP_ID_PCIX); 2602 cap = pci_find_capability(dev, PCI_CAP_ID_PCIX);
2607 if (!cap) 2603 if (!cap)
2608 return -EINVAL; 2604 return -EINVAL;
2609 2605
2610 ret = pci_read_config_dword(dev, cap + PCI_X_CMD, &cmd); 2606 if (pci_read_config_word(dev, cap + PCI_X_CMD, &cmd))
2611 if (!ret) 2607 return -EINVAL;
2612 ret = 512 << ((cmd & PCI_X_CMD_MAX_READ) >> 2);
2613 2608
2614 return ret; 2609 return 512 << ((cmd & PCI_X_CMD_MAX_READ) >> 2);
2615} 2610}
2616EXPORT_SYMBOL(pcix_get_mmrbc); 2611EXPORT_SYMBOL(pcix_get_mmrbc);
2617 2612
@@ -2626,28 +2621,27 @@ EXPORT_SYMBOL(pcix_get_mmrbc);
2626 */ 2621 */
2627int pcix_set_mmrbc(struct pci_dev *dev, int mmrbc) 2622int pcix_set_mmrbc(struct pci_dev *dev, int mmrbc)
2628{ 2623{
2629 int cap, err = -EINVAL; 2624 int cap;
2630 u32 stat, cmd, v, o; 2625 u32 stat, v, o;
2626 u16 cmd;
2631 2627
2632 if (mmrbc < 512 || mmrbc > 4096 || !is_power_of_2(mmrbc)) 2628 if (mmrbc < 512 || mmrbc > 4096 || !is_power_of_2(mmrbc))
2633 goto out; 2629 return -EINVAL;
2634 2630
2635 v = ffs(mmrbc) - 10; 2631 v = ffs(mmrbc) - 10;
2636 2632
2637 cap = pci_find_capability(dev, PCI_CAP_ID_PCIX); 2633 cap = pci_find_capability(dev, PCI_CAP_ID_PCIX);
2638 if (!cap) 2634 if (!cap)
2639 goto out; 2635 return -EINVAL;
2640 2636
2641 err = pci_read_config_dword(dev, cap + PCI_X_STATUS, &stat); 2637 if (pci_read_config_dword(dev, cap + PCI_X_STATUS, &stat))
2642 if (err) 2638 return -EINVAL;
2643 goto out;
2644 2639
2645 if (v > (stat & PCI_X_STATUS_MAX_READ) >> 21) 2640 if (v > (stat & PCI_X_STATUS_MAX_READ) >> 21)
2646 return -E2BIG; 2641 return -E2BIG;
2647 2642
2648 err = pci_read_config_dword(dev, cap + PCI_X_CMD, &cmd); 2643 if (pci_read_config_word(dev, cap + PCI_X_CMD, &cmd))
2649 if (err) 2644 return -EINVAL;
2650 goto out;
2651 2645
2652 o = (cmd & PCI_X_CMD_MAX_READ) >> 2; 2646 o = (cmd & PCI_X_CMD_MAX_READ) >> 2;
2653 if (o != v) { 2647 if (o != v) {
@@ -2657,10 +2651,10 @@ int pcix_set_mmrbc(struct pci_dev *dev, int mmrbc)
2657 2651
2658 cmd &= ~PCI_X_CMD_MAX_READ; 2652 cmd &= ~PCI_X_CMD_MAX_READ;
2659 cmd |= v << 2; 2653 cmd |= v << 2;
2660 err = pci_write_config_dword(dev, cap + PCI_X_CMD, cmd); 2654 if (pci_write_config_word(dev, cap + PCI_X_CMD, cmd))
2655 return -EIO;
2661 } 2656 }
2662out: 2657 return 0;
2663 return err;
2664} 2658}
2665EXPORT_SYMBOL(pcix_set_mmrbc); 2659EXPORT_SYMBOL(pcix_set_mmrbc);
2666 2660
@@ -3023,7 +3017,6 @@ EXPORT_SYMBOL(pcim_pin_device);
3023EXPORT_SYMBOL(pci_disable_device); 3017EXPORT_SYMBOL(pci_disable_device);
3024EXPORT_SYMBOL(pci_find_capability); 3018EXPORT_SYMBOL(pci_find_capability);
3025EXPORT_SYMBOL(pci_bus_find_capability); 3019EXPORT_SYMBOL(pci_bus_find_capability);
3026EXPORT_SYMBOL(pci_register_set_vga_state);
3027EXPORT_SYMBOL(pci_release_regions); 3020EXPORT_SYMBOL(pci_release_regions);
3028EXPORT_SYMBOL(pci_request_regions); 3021EXPORT_SYMBOL(pci_request_regions);
3029EXPORT_SYMBOL(pci_request_regions_exclusive); 3022EXPORT_SYMBOL(pci_request_regions_exclusive);
diff --git a/drivers/pci/pcie/aer/aer_inject.c b/drivers/pci/pcie/aer/aer_inject.c
index 223052b7356..f8f425b8731 100644
--- a/drivers/pci/pcie/aer/aer_inject.c
+++ b/drivers/pci/pcie/aer/aer_inject.c
@@ -21,6 +21,7 @@
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/miscdevice.h> 22#include <linux/miscdevice.h>
23#include <linux/pci.h> 23#include <linux/pci.h>
24#include <linux/slab.h>
24#include <linux/fs.h> 25#include <linux/fs.h>
25#include <linux/uaccess.h> 26#include <linux/uaccess.h>
26#include <linux/stddef.h> 27#include <linux/stddef.h>
diff --git a/drivers/pci/pcie/aer/aerdrv.c b/drivers/pci/pcie/aer/aerdrv.c
index 21f215f4daa..7a711ee314b 100644
--- a/drivers/pci/pcie/aer/aerdrv.c
+++ b/drivers/pci/pcie/aer/aerdrv.c
@@ -25,6 +25,7 @@
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/pcieport_if.h> 27#include <linux/pcieport_if.h>
28#include <linux/slab.h>
28 29
29#include "aerdrv.h" 30#include "aerdrv.h"
30#include "../../pci.h" 31#include "../../pci.h"
@@ -243,11 +244,17 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev)
243 244
244 /* Assert Secondary Bus Reset */ 245 /* Assert Secondary Bus Reset */
245 pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &p2p_ctrl); 246 pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &p2p_ctrl);
246 p2p_ctrl |= PCI_CB_BRIDGE_CTL_CB_RESET; 247 p2p_ctrl |= PCI_BRIDGE_CTL_BUS_RESET;
247 pci_write_config_word(dev, PCI_BRIDGE_CONTROL, p2p_ctrl); 248 pci_write_config_word(dev, PCI_BRIDGE_CONTROL, p2p_ctrl);
248 249
250 /*
251 * we should send hot reset message for 2ms to allow it time to
252 * propogate to all downstream ports
253 */
254 msleep(2);
255
249 /* De-assert Secondary Bus Reset */ 256 /* De-assert Secondary Bus Reset */
250 p2p_ctrl &= ~PCI_CB_BRIDGE_CTL_CB_RESET; 257 p2p_ctrl &= ~PCI_BRIDGE_CTL_BUS_RESET;
251 pci_write_config_word(dev, PCI_BRIDGE_CONTROL, p2p_ctrl); 258 pci_write_config_word(dev, PCI_BRIDGE_CONTROL, p2p_ctrl);
252 259
253 /* 260 /*
diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c
index c843a799814..aceb04b67b6 100644
--- a/drivers/pci/pcie/aer/aerdrv_core.c
+++ b/drivers/pci/pcie/aer/aerdrv_core.c
@@ -23,6 +23,7 @@
23#include <linux/pm.h> 23#include <linux/pm.h>
24#include <linux/suspend.h> 24#include <linux/suspend.h>
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/slab.h>
26#include "aerdrv.h" 27#include "aerdrv.h"
27 28
28static int forceload; 29static int forceload;
diff --git a/drivers/pci/pcie/pme/pcie_pme.c b/drivers/pci/pcie/pme/pcie_pme.c
index 7b3cbff547e..aac285a16b6 100644
--- a/drivers/pci/pcie/pme/pcie_pme.c
+++ b/drivers/pci/pcie/pme/pcie_pme.c
@@ -14,6 +14,7 @@
14#include <linux/pci.h> 14#include <linux/pci.h>
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/errno.h> 16#include <linux/errno.h>
17#include <linux/slab.h>
17#include <linux/init.h> 18#include <linux/init.h>
18#include <linux/interrupt.h> 19#include <linux/interrupt.h>
19#include <linux/device.h> 20#include <linux/device.h>
diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c
index 127e8f169d9..3debed25e46 100644
--- a/drivers/pci/pcie/portdrv_pci.c
+++ b/drivers/pci/pcie/portdrv_pci.c
@@ -12,7 +12,6 @@
12#include <linux/errno.h> 12#include <linux/errno.h>
13#include <linux/pm.h> 13#include <linux/pm.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/slab.h>
16#include <linux/pcieport_if.h> 15#include <linux/pcieport_if.h>
17#include <linux/aer.h> 16#include <linux/aer.h>
18#include <linux/dmi.h> 17#include <linux/dmi.h>
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 2a943090a3b..c82548afcd5 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -312,7 +312,7 @@ static void __devinit pci_read_bridge_io(struct pci_bus *child)
312 dev_printk(KERN_DEBUG, &dev->dev, " bridge window %pR\n", res); 312 dev_printk(KERN_DEBUG, &dev->dev, " bridge window %pR\n", res);
313 } else { 313 } else {
314 dev_printk(KERN_DEBUG, &dev->dev, 314 dev_printk(KERN_DEBUG, &dev->dev,
315 " bridge window [io %04lx - %04lx] reg reading\n", 315 " bridge window [io %#06lx-%#06lx] (disabled)\n",
316 base, limit); 316 base, limit);
317 } 317 }
318} 318}
@@ -336,7 +336,7 @@ static void __devinit pci_read_bridge_mmio(struct pci_bus *child)
336 dev_printk(KERN_DEBUG, &dev->dev, " bridge window %pR\n", res); 336 dev_printk(KERN_DEBUG, &dev->dev, " bridge window %pR\n", res);
337 } else { 337 } else {
338 dev_printk(KERN_DEBUG, &dev->dev, 338 dev_printk(KERN_DEBUG, &dev->dev,
339 " bridge window [mem 0x%08lx - 0x%08lx] reg reading\n", 339 " bridge window [mem %#010lx-%#010lx] (disabled)\n",
340 base, limit + 0xfffff); 340 base, limit + 0xfffff);
341 } 341 }
342} 342}
@@ -387,7 +387,7 @@ static void __devinit pci_read_bridge_mmio_pref(struct pci_bus *child)
387 dev_printk(KERN_DEBUG, &dev->dev, " bridge window %pR\n", res); 387 dev_printk(KERN_DEBUG, &dev->dev, " bridge window %pR\n", res);
388 } else { 388 } else {
389 dev_printk(KERN_DEBUG, &dev->dev, 389 dev_printk(KERN_DEBUG, &dev->dev,
390 " bridge window [mem 0x%08lx - %08lx pref] reg reading\n", 390 " bridge window [mem %#010lx-%#010lx pref] (disabled)\n",
391 base, limit + 0xfffff); 391 base, limit + 0xfffff);
392 } 392 }
393} 393}
@@ -673,16 +673,20 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
673 int is_cardbus = (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS); 673 int is_cardbus = (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS);
674 u32 buses, i, j = 0; 674 u32 buses, i, j = 0;
675 u16 bctl; 675 u16 bctl;
676 u8 primary, secondary, subordinate;
676 int broken = 0; 677 int broken = 0;
677 678
678 pci_read_config_dword(dev, PCI_PRIMARY_BUS, &buses); 679 pci_read_config_dword(dev, PCI_PRIMARY_BUS, &buses);
680 primary = buses & 0xFF;
681 secondary = (buses >> 8) & 0xFF;
682 subordinate = (buses >> 16) & 0xFF;
679 683
680 dev_dbg(&dev->dev, "scanning behind bridge, config %06x, pass %d\n", 684 dev_dbg(&dev->dev, "scanning [bus %02x-%02x] behind bridge, pass %d\n",
681 buses & 0xffffff, pass); 685 secondary, subordinate, pass);
682 686
683 /* Check if setup is sensible at all */ 687 /* Check if setup is sensible at all */
684 if (!pass && 688 if (!pass &&
685 ((buses & 0xff) != bus->number || ((buses >> 8) & 0xff) <= bus->number)) { 689 (primary != bus->number || secondary <= bus->number)) {
686 dev_dbg(&dev->dev, "bus configuration invalid, reconfiguring\n"); 690 dev_dbg(&dev->dev, "bus configuration invalid, reconfiguring\n");
687 broken = 1; 691 broken = 1;
688 } 692 }
@@ -693,15 +697,15 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
693 pci_write_config_word(dev, PCI_BRIDGE_CONTROL, 697 pci_write_config_word(dev, PCI_BRIDGE_CONTROL,
694 bctl & ~PCI_BRIDGE_CTL_MASTER_ABORT); 698 bctl & ~PCI_BRIDGE_CTL_MASTER_ABORT);
695 699
696 if ((buses & 0xffff00) && !pcibios_assign_all_busses() && !is_cardbus && !broken) { 700 if ((secondary || subordinate) && !pcibios_assign_all_busses() &&
697 unsigned int cmax, busnr; 701 !is_cardbus && !broken) {
702 unsigned int cmax;
698 /* 703 /*
699 * Bus already configured by firmware, process it in the first 704 * Bus already configured by firmware, process it in the first
700 * pass and just note the configuration. 705 * pass and just note the configuration.
701 */ 706 */
702 if (pass) 707 if (pass)
703 goto out; 708 goto out;
704 busnr = (buses >> 8) & 0xFF;
705 709
706 /* 710 /*
707 * If we already got to this bus through a different bridge, 711 * If we already got to this bus through a different bridge,
@@ -710,13 +714,13 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
710 * However, we continue to descend down the hierarchy and 714 * However, we continue to descend down the hierarchy and
711 * scan remaining child buses. 715 * scan remaining child buses.
712 */ 716 */
713 child = pci_find_bus(pci_domain_nr(bus), busnr); 717 child = pci_find_bus(pci_domain_nr(bus), secondary);
714 if (!child) { 718 if (!child) {
715 child = pci_add_new_bus(bus, dev, busnr); 719 child = pci_add_new_bus(bus, dev, secondary);
716 if (!child) 720 if (!child)
717 goto out; 721 goto out;
718 child->primary = buses & 0xFF; 722 child->primary = primary;
719 child->subordinate = (buses >> 16) & 0xFF; 723 child->subordinate = subordinate;
720 child->bridge_ctl = bctl; 724 child->bridge_ctl = bctl;
721 } 725 }
722 726
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index 593bb844b8d..449e890267a 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -6,6 +6,7 @@
6 6
7#include <linux/init.h> 7#include <linux/init.h>
8#include <linux/pci.h> 8#include <linux/pci.h>
9#include <linux/slab.h>
9#include <linux/module.h> 10#include <linux/module.h>
10#include <linux/proc_fs.h> 11#include <linux/proc_fs.h>
11#include <linux/seq_file.h> 12#include <linux/seq_file.h>
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 81d19d5683a..27c0e6eb713 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -368,8 +368,9 @@ static void __devinit quirk_io_region(struct pci_dev *dev, unsigned region,
368 bus_region.end = res->end; 368 bus_region.end = res->end;
369 pcibios_bus_to_resource(dev, res, &bus_region); 369 pcibios_bus_to_resource(dev, res, &bus_region);
370 370
371 pci_claim_resource(dev, nr); 371 if (pci_claim_resource(dev, nr) == 0)
372 dev_info(&dev->dev, "quirk: %pR claimed by %s\n", res, name); 372 dev_info(&dev->dev, "quirk: %pR claimed by %s\n",
373 res, name);
373 } 374 }
374} 375}
375 376
@@ -1977,11 +1978,25 @@ static void __devinit quirk_via_cx700_pci_parking_caching(struct pci_dev *dev)
1977 /* 1978 /*
1978 * Disable PCI Bus Parking and PCI Master read caching on CX700 1979 * Disable PCI Bus Parking and PCI Master read caching on CX700
1979 * which causes unspecified timing errors with a VT6212L on the PCI 1980 * which causes unspecified timing errors with a VT6212L on the PCI
1980 * bus leading to USB2.0 packet loss. The defaults are that these 1981 * bus leading to USB2.0 packet loss.
1981 * features are turned off but some BIOSes turn them on. 1982 *
1983 * This quirk is only enabled if a second (on the external PCI bus)
1984 * VT6212L is found -- the CX700 core itself also contains a USB
1985 * host controller with the same PCI ID as the VT6212L.
1982 */ 1986 */
1983 1987
1988 /* Count VT6212L instances */
1989 struct pci_dev *p = pci_get_device(PCI_VENDOR_ID_VIA,
1990 PCI_DEVICE_ID_VIA_8235_USB_2, NULL);
1984 uint8_t b; 1991 uint8_t b;
1992
1993 /* p should contain the first (internal) VT6212L -- see if we have
1994 an external one by searching again */
1995 p = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235_USB_2, p);
1996 if (!p)
1997 return;
1998 pci_dev_put(p);
1999
1985 if (pci_read_config_byte(dev, 0x76, &b) == 0) { 2000 if (pci_read_config_byte(dev, 0x76, &b) == 0) {
1986 if (b & 0x40) { 2001 if (b & 0x40) {
1987 /* Turn off PCI Bus Parking */ 2002 /* Turn off PCI Bus Parking */
@@ -2008,7 +2023,7 @@ static void __devinit quirk_via_cx700_pci_parking_caching(struct pci_dev *dev)
2008 } 2023 }
2009 } 2024 }
2010} 2025}
2011DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_VIA, 0x324e, quirk_via_cx700_pci_parking_caching); 2026DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, 0x324e, quirk_via_cx700_pci_parking_caching);
2012 2027
2013/* 2028/*
2014 * For Broadcom 5706, 5708, 5709 rev. A nics, any read beyond the 2029 * For Broadcom 5706, 5708, 5709 rev. A nics, any read beyond the
@@ -2108,6 +2123,10 @@ static void __devinit quirk_disable_msi(struct pci_dev *dev)
2108 } 2123 }
2109} 2124}
2110DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_BRIDGE, quirk_disable_msi); 2125DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_BRIDGE, quirk_disable_msi);
2126DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, 0x9602, quirk_disable_msi);
2127DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ASUSTEK, 0x9602, quirk_disable_msi);
2128DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AI, 0x9602, quirk_disable_msi);
2129DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, 0xa238, quirk_disable_msi);
2111 2130
2112/* Go through the list of Hypertransport capabilities and 2131/* Go through the list of Hypertransport capabilities and
2113 * return 1 if a HT MSI capability is found and enabled */ 2132 * return 1 if a HT MSI capability is found and enabled */
diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index 4a471dc4f4b..20d03f77228 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -9,6 +9,7 @@
9 9
10#include <linux/init.h> 10#include <linux/init.h>
11#include <linux/pci.h> 11#include <linux/pci.h>
12#include <linux/slab.h>
12#include <linux/module.h> 13#include <linux/module.h>
13#include <linux/interrupt.h> 14#include <linux/interrupt.h>
14#include "pci.h" 15#include "pci.h"
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index 7d678bb15ff..17bed18d24a 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -93,8 +93,7 @@ void pci_update_resource(struct pci_dev *dev, int resno)
93int pci_claim_resource(struct pci_dev *dev, int resource) 93int pci_claim_resource(struct pci_dev *dev, int resource)
94{ 94{
95 struct resource *res = &dev->resource[resource]; 95 struct resource *res = &dev->resource[resource];
96 struct resource *root; 96 struct resource *root, *conflict;
97 int err;
98 97
99 root = pci_find_parent_resource(dev, res); 98 root = pci_find_parent_resource(dev, res);
100 if (!root) { 99 if (!root) {
@@ -103,12 +102,15 @@ int pci_claim_resource(struct pci_dev *dev, int resource)
103 return -EINVAL; 102 return -EINVAL;
104 } 103 }
105 104
106 err = request_resource(root, res); 105 conflict = request_resource_conflict(root, res);
107 if (err) 106 if (conflict) {
108 dev_err(&dev->dev, 107 dev_err(&dev->dev,
109 "address space collision: %pR already in use\n", res); 108 "address space collision: %pR conflicts with %s %pR\n",
109 res, conflict->name, conflict);
110 return -EBUSY;
111 }
110 112
111 return err; 113 return 0;
112} 114}
113EXPORT_SYMBOL(pci_claim_resource); 115EXPORT_SYMBOL(pci_claim_resource);
114 116
diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c
index f75a44d37fb..659eaa0fc48 100644
--- a/drivers/pci/slot.c
+++ b/drivers/pci/slot.c
@@ -6,6 +6,7 @@
6 */ 6 */
7 7
8#include <linux/kobject.h> 8#include <linux/kobject.h>
9#include <linux/slab.h>
9#include <linux/pci.h> 10#include <linux/pci.h>
10#include <linux/err.h> 11#include <linux/err.h>
11#include "pci.h" 12#include "pci.h"
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index d189e4743e6..a44733d44ca 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -234,7 +234,8 @@ config PCMCIA_PXA2XX
234 depends on ARM && ARCH_PXA && PCMCIA 234 depends on ARM && ARCH_PXA && PCMCIA
235 depends on (ARCH_LUBBOCK || MACH_MAINSTONE || PXA_SHARPSL \ 235 depends on (ARCH_LUBBOCK || MACH_MAINSTONE || PXA_SHARPSL \
236 || MACH_ARMCORE || ARCH_PXA_PALM || TRIZEPS_PCMCIA \ 236 || MACH_ARMCORE || ARCH_PXA_PALM || TRIZEPS_PCMCIA \
237 || ARCOM_PCMCIA || ARCH_PXA_ESERIES || MACH_STARGATE2) 237 || ARCOM_PCMCIA || ARCH_PXA_ESERIES || MACH_STARGATE2 \
238 || MACH_VPAC270)
238 select PCMCIA_SOC_COMMON 239 select PCMCIA_SOC_COMMON
239 help 240 help
240 Say Y here to include support for the PXA2xx PCMCIA controller 241 Say Y here to include support for the PXA2xx PCMCIA controller
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile
index 381b031d9d7..4dae3613c45 100644
--- a/drivers/pcmcia/Makefile
+++ b/drivers/pcmcia/Makefile
@@ -66,6 +66,7 @@ pxa2xx-obj-$(CONFIG_MACH_PALMTC) += pxa2xx_palmtc.o
66pxa2xx-obj-$(CONFIG_MACH_PALMLD) += pxa2xx_palmld.o 66pxa2xx-obj-$(CONFIG_MACH_PALMLD) += pxa2xx_palmld.o
67pxa2xx-obj-$(CONFIG_MACH_E740) += pxa2xx_e740.o 67pxa2xx-obj-$(CONFIG_MACH_E740) += pxa2xx_e740.o
68pxa2xx-obj-$(CONFIG_MACH_STARGATE2) += pxa2xx_stargate2.o 68pxa2xx-obj-$(CONFIG_MACH_STARGATE2) += pxa2xx_stargate2.o
69pxa2xx-obj-$(CONFIG_MACH_VPAC270) += pxa2xx_vpac270.o
69 70
70obj-$(CONFIG_PCMCIA_PXA2XX) += pxa2xx_base.o $(pxa2xx-obj-y) 71obj-$(CONFIG_PCMCIA_PXA2XX) += pxa2xx_base.o $(pxa2xx-obj-y)
71 72
diff --git a/drivers/pcmcia/at91_cf.c b/drivers/pcmcia/at91_cf.c
index 5d228071ec6..fb33fa42d24 100644
--- a/drivers/pcmcia/at91_cf.c
+++ b/drivers/pcmcia/at91_cf.c
@@ -15,6 +15,7 @@
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/interrupt.h> 17#include <linux/interrupt.h>
18#include <linux/slab.h>
18 19
19#include <pcmcia/ss.h> 20#include <pcmcia/ss.h>
20 21
@@ -361,7 +362,6 @@ static int at91_cf_suspend(struct platform_device *pdev, pm_message_t mesg)
361 struct at91_cf_socket *cf = platform_get_drvdata(pdev); 362 struct at91_cf_socket *cf = platform_get_drvdata(pdev);
362 struct at91_cf_data *board = cf->board; 363 struct at91_cf_data *board = cf->board;
363 364
364 pcmcia_socket_dev_suspend(&pdev->dev);
365 if (device_may_wakeup(&pdev->dev)) { 365 if (device_may_wakeup(&pdev->dev)) {
366 enable_irq_wake(board->det_pin); 366 enable_irq_wake(board->det_pin);
367 if (board->irq_pin) 367 if (board->irq_pin)
@@ -381,7 +381,6 @@ static int at91_cf_resume(struct platform_device *pdev)
381 disable_irq_wake(board->irq_pin); 381 disable_irq_wake(board->irq_pin);
382 } 382 }
383 383
384 pcmcia_socket_dev_resume(&pdev->dev);
385 return 0; 384 return 0;
386} 385}
387 386
diff --git a/drivers/pcmcia/au1000_generic.c b/drivers/pcmcia/au1000_generic.c
index 171c8a65488..88c4c409878 100644
--- a/drivers/pcmcia/au1000_generic.c
+++ b/drivers/pcmcia/au1000_generic.c
@@ -43,6 +43,7 @@
43#include <linux/spinlock.h> 43#include <linux/spinlock.h>
44#include <linux/mutex.h> 44#include <linux/mutex.h>
45#include <linux/platform_device.h> 45#include <linux/platform_device.h>
46#include <linux/slab.h>
46 47
47#include <asm/io.h> 48#include <asm/io.h>
48#include <asm/irq.h> 49#include <asm/irq.h>
@@ -510,17 +511,6 @@ static int au1x00_drv_pcmcia_probe(struct platform_device *dev)
510 return ret; 511 return ret;
511} 512}
512 513
513static int au1x00_drv_pcmcia_suspend(struct platform_device *dev,
514 pm_message_t state)
515{
516 return pcmcia_socket_dev_suspend(&dev->dev);
517}
518
519static int au1x00_drv_pcmcia_resume(struct platform_device *dev)
520{
521 return pcmcia_socket_dev_resume(&dev->dev);
522}
523
524static struct platform_driver au1x00_pcmcia_driver = { 514static struct platform_driver au1x00_pcmcia_driver = {
525 .driver = { 515 .driver = {
526 .name = "au1x00-pcmcia", 516 .name = "au1x00-pcmcia",
@@ -528,8 +518,6 @@ static struct platform_driver au1x00_pcmcia_driver = {
528 }, 518 },
529 .probe = au1x00_drv_pcmcia_probe, 519 .probe = au1x00_drv_pcmcia_probe,
530 .remove = au1x00_drv_pcmcia_remove, 520 .remove = au1x00_drv_pcmcia_remove,
531 .suspend = au1x00_drv_pcmcia_suspend,
532 .resume = au1x00_drv_pcmcia_resume,
533}; 521};
534 522
535 523
diff --git a/drivers/pcmcia/bcm63xx_pcmcia.c b/drivers/pcmcia/bcm63xx_pcmcia.c
index bc88a3b19bb..693577e0fef 100644
--- a/drivers/pcmcia/bcm63xx_pcmcia.c
+++ b/drivers/pcmcia/bcm63xx_pcmcia.c
@@ -11,6 +11,7 @@
11#include <linux/ioport.h> 11#include <linux/ioport.h>
12#include <linux/timer.h> 12#include <linux/timer.h>
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <linux/slab.h>
14#include <linux/delay.h> 15#include <linux/delay.h>
15#include <linux/pci.h> 16#include <linux/pci.h>
16#include <linux/gpio.h> 17#include <linux/gpio.h>
diff --git a/drivers/pcmcia/bfin_cf_pcmcia.c b/drivers/pcmcia/bfin_cf_pcmcia.c
index 2482ce7ac6d..9e84d039de4 100644
--- a/drivers/pcmcia/bfin_cf_pcmcia.c
+++ b/drivers/pcmcia/bfin_cf_pcmcia.c
@@ -31,6 +31,7 @@
31#include <linux/platform_device.h> 31#include <linux/platform_device.h>
32#include <linux/errno.h> 32#include <linux/errno.h>
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/slab.h>
34#include <linux/delay.h> 35#include <linux/delay.h>
35#include <linux/interrupt.h> 36#include <linux/interrupt.h>
36#include <linux/irq.h> 37#include <linux/irq.h>
@@ -300,16 +301,6 @@ static int __devexit bfin_cf_remove(struct platform_device *pdev)
300 return 0; 301 return 0;
301} 302}
302 303
303static int bfin_cf_suspend(struct platform_device *pdev, pm_message_t mesg)
304{
305 return pcmcia_socket_dev_suspend(&pdev->dev);
306}
307
308static int bfin_cf_resume(struct platform_device *pdev)
309{
310 return pcmcia_socket_dev_resume(&pdev->dev);
311}
312
313static struct platform_driver bfin_cf_driver = { 304static struct platform_driver bfin_cf_driver = {
314 .driver = { 305 .driver = {
315 .name = (char *)driver_name, 306 .name = (char *)driver_name,
@@ -317,8 +308,6 @@ static struct platform_driver bfin_cf_driver = {
317 }, 308 },
318 .probe = bfin_cf_probe, 309 .probe = bfin_cf_probe,
319 .remove = __devexit_p(bfin_cf_remove), 310 .remove = __devexit_p(bfin_cf_remove),
320 .suspend = bfin_cf_suspend,
321 .resume = bfin_cf_resume,
322}; 311};
323 312
324static int __init bfin_cf_init(void) 313static int __init bfin_cf_init(void)
diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c
index f230f6543bf..854959cada3 100644
--- a/drivers/pcmcia/cistpl.c
+++ b/drivers/pcmcia/cistpl.c
@@ -1484,6 +1484,11 @@ int pccard_validate_cis(struct pcmcia_socket *s, unsigned int *info)
1484 if (!s) 1484 if (!s)
1485 return -EINVAL; 1485 return -EINVAL;
1486 1486
1487 if (s->functions) {
1488 WARN_ON(1);
1489 return -EINVAL;
1490 }
1491
1487 /* We do not want to validate the CIS cache... */ 1492 /* We do not want to validate the CIS cache... */
1488 mutex_lock(&s->ops_mutex); 1493 mutex_lock(&s->ops_mutex);
1489 destroy_cis_cache(s); 1494 destroy_cis_cache(s);
@@ -1639,7 +1644,7 @@ static ssize_t pccard_show_cis(struct kobject *kobj,
1639 count = 0; 1644 count = 0;
1640 else { 1645 else {
1641 struct pcmcia_socket *s; 1646 struct pcmcia_socket *s;
1642 unsigned int chains; 1647 unsigned int chains = 1;
1643 1648
1644 if (off + count > size) 1649 if (off + count > size)
1645 count = size - off; 1650 count = size - off;
@@ -1648,7 +1653,7 @@ static ssize_t pccard_show_cis(struct kobject *kobj,
1648 1653
1649 if (!(s->state & SOCKET_PRESENT)) 1654 if (!(s->state & SOCKET_PRESENT))
1650 return -ENODEV; 1655 return -ENODEV;
1651 if (pccard_validate_cis(s, &chains)) 1656 if (!s->functions && pccard_validate_cis(s, &chains))
1652 return -EIO; 1657 return -EIO;
1653 if (!chains) 1658 if (!chains)
1654 return -ENODATA; 1659 return -ENODATA;
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index e679e708db6..c3383750e33 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -76,65 +76,6 @@ DECLARE_RWSEM(pcmcia_socket_list_rwsem);
76EXPORT_SYMBOL(pcmcia_socket_list_rwsem); 76EXPORT_SYMBOL(pcmcia_socket_list_rwsem);
77 77
78 78
79/*
80 * Low-level PCMCIA socket drivers need to register with the PCCard
81 * core using pcmcia_register_socket.
82 *
83 * socket drivers are expected to use the following callbacks in their
84 * .drv struct:
85 * - pcmcia_socket_dev_suspend
86 * - pcmcia_socket_dev_resume
87 * These functions check for the appropriate struct pcmcia_soket arrays,
88 * and pass them to the low-level functions pcmcia_{suspend,resume}_socket
89 */
90static int socket_early_resume(struct pcmcia_socket *skt);
91static int socket_late_resume(struct pcmcia_socket *skt);
92static int socket_resume(struct pcmcia_socket *skt);
93static int socket_suspend(struct pcmcia_socket *skt);
94
95static void pcmcia_socket_dev_run(struct device *dev,
96 int (*cb)(struct pcmcia_socket *))
97{
98 struct pcmcia_socket *socket;
99
100 down_read(&pcmcia_socket_list_rwsem);
101 list_for_each_entry(socket, &pcmcia_socket_list, socket_list) {
102 if (socket->dev.parent != dev)
103 continue;
104 mutex_lock(&socket->skt_mutex);
105 cb(socket);
106 mutex_unlock(&socket->skt_mutex);
107 }
108 up_read(&pcmcia_socket_list_rwsem);
109}
110
111int pcmcia_socket_dev_suspend(struct device *dev)
112{
113 pcmcia_socket_dev_run(dev, socket_suspend);
114 return 0;
115}
116EXPORT_SYMBOL(pcmcia_socket_dev_suspend);
117
118void pcmcia_socket_dev_early_resume(struct device *dev)
119{
120 pcmcia_socket_dev_run(dev, socket_early_resume);
121}
122EXPORT_SYMBOL(pcmcia_socket_dev_early_resume);
123
124void pcmcia_socket_dev_late_resume(struct device *dev)
125{
126 pcmcia_socket_dev_run(dev, socket_late_resume);
127}
128EXPORT_SYMBOL(pcmcia_socket_dev_late_resume);
129
130int pcmcia_socket_dev_resume(struct device *dev)
131{
132 pcmcia_socket_dev_run(dev, socket_resume);
133 return 0;
134}
135EXPORT_SYMBOL(pcmcia_socket_dev_resume);
136
137
138struct pcmcia_socket *pcmcia_get_socket(struct pcmcia_socket *skt) 79struct pcmcia_socket *pcmcia_get_socket(struct pcmcia_socket *skt)
139{ 80{
140 struct device *dev = get_device(&skt->dev); 81 struct device *dev = get_device(&skt->dev);
@@ -578,12 +519,18 @@ static int socket_early_resume(struct pcmcia_socket *skt)
578 519
579static int socket_late_resume(struct pcmcia_socket *skt) 520static int socket_late_resume(struct pcmcia_socket *skt)
580{ 521{
522 int ret;
523
581 mutex_lock(&skt->ops_mutex); 524 mutex_lock(&skt->ops_mutex);
582 skt->state &= ~SOCKET_SUSPEND; 525 skt->state &= ~SOCKET_SUSPEND;
583 mutex_unlock(&skt->ops_mutex); 526 mutex_unlock(&skt->ops_mutex);
584 527
585 if (!(skt->state & SOCKET_PRESENT)) 528 if (!(skt->state & SOCKET_PRESENT)) {
586 return socket_insert(skt); 529 ret = socket_insert(skt);
530 if (ret == -ENODEV)
531 ret = 0;
532 return ret;
533 }
587 534
588 if (skt->resume_status) { 535 if (skt->resume_status) {
589 socket_shutdown(skt); 536 socket_shutdown(skt);
@@ -724,20 +671,22 @@ static int pccardd(void *__skt)
724 socket_remove(skt); 671 socket_remove(skt);
725 if (sysfs_events & PCMCIA_UEVENT_INSERT) 672 if (sysfs_events & PCMCIA_UEVENT_INSERT)
726 socket_insert(skt); 673 socket_insert(skt);
727 if ((sysfs_events & PCMCIA_UEVENT_RESUME) &&
728 !(skt->state & SOCKET_CARDBUS)) {
729 ret = socket_resume(skt);
730 if (!ret && skt->callback)
731 skt->callback->resume(skt);
732 }
733 if ((sysfs_events & PCMCIA_UEVENT_SUSPEND) && 674 if ((sysfs_events & PCMCIA_UEVENT_SUSPEND) &&
734 !(skt->state & SOCKET_CARDBUS)) { 675 !(skt->state & SOCKET_CARDBUS)) {
735 if (skt->callback) 676 if (skt->callback)
736 ret = skt->callback->suspend(skt); 677 ret = skt->callback->suspend(skt);
737 else 678 else
738 ret = 0; 679 ret = 0;
739 if (!ret) 680 if (!ret) {
740 socket_suspend(skt); 681 socket_suspend(skt);
682 msleep(100);
683 }
684 }
685 if ((sysfs_events & PCMCIA_UEVENT_RESUME) &&
686 !(skt->state & SOCKET_CARDBUS)) {
687 ret = socket_resume(skt);
688 if (!ret && skt->callback)
689 skt->callback->resume(skt);
741 } 690 }
742 if ((sysfs_events & PCMCIA_UEVENT_REQUERY) && 691 if ((sysfs_events & PCMCIA_UEVENT_REQUERY) &&
743 !(skt->state & SOCKET_CARDBUS)) { 692 !(skt->state & SOCKET_CARDBUS)) {
@@ -919,11 +868,66 @@ static void pcmcia_release_socket_class(struct class *data)
919} 868}
920 869
921 870
871#ifdef CONFIG_PM
872
873static int __pcmcia_pm_op(struct device *dev,
874 int (*callback) (struct pcmcia_socket *skt))
875{
876 struct pcmcia_socket *s = container_of(dev, struct pcmcia_socket, dev);
877 int ret;
878
879 mutex_lock(&s->skt_mutex);
880 ret = callback(s);
881 mutex_unlock(&s->skt_mutex);
882
883 return ret;
884}
885
886static int pcmcia_socket_dev_suspend_noirq(struct device *dev)
887{
888 return __pcmcia_pm_op(dev, socket_suspend);
889}
890
891static int pcmcia_socket_dev_resume_noirq(struct device *dev)
892{
893 return __pcmcia_pm_op(dev, socket_early_resume);
894}
895
896static int pcmcia_socket_dev_resume(struct device *dev)
897{
898 return __pcmcia_pm_op(dev, socket_late_resume);
899}
900
901static const struct dev_pm_ops pcmcia_socket_pm_ops = {
902 /* dev_resume may be called with IRQs enabled */
903 SET_SYSTEM_SLEEP_PM_OPS(NULL,
904 pcmcia_socket_dev_resume)
905
906 /* late suspend must be called with IRQs disabled */
907 .suspend_noirq = pcmcia_socket_dev_suspend_noirq,
908 .freeze_noirq = pcmcia_socket_dev_suspend_noirq,
909 .poweroff_noirq = pcmcia_socket_dev_suspend_noirq,
910
911 /* early resume must be called with IRQs disabled */
912 .resume_noirq = pcmcia_socket_dev_resume_noirq,
913 .thaw_noirq = pcmcia_socket_dev_resume_noirq,
914 .restore_noirq = pcmcia_socket_dev_resume_noirq,
915};
916
917#define PCMCIA_SOCKET_CLASS_PM_OPS (&pcmcia_socket_pm_ops)
918
919#else /* CONFIG_PM */
920
921#define PCMCIA_SOCKET_CLASS_PM_OPS NULL
922
923#endif /* CONFIG_PM */
924
922struct class pcmcia_socket_class = { 925struct class pcmcia_socket_class = {
923 .name = "pcmcia_socket", 926 .name = "pcmcia_socket",
924 .dev_uevent = pcmcia_socket_uevent, 927 .dev_uevent = pcmcia_socket_uevent,
925 .dev_release = pcmcia_release_socket, 928 .dev_release = pcmcia_release_socket,
926 .class_release = pcmcia_release_socket_class, 929 .class_release = pcmcia_release_socket_class,
930 .pm = PCMCIA_SOCKET_CLASS_PM_OPS,
927}; 931};
928EXPORT_SYMBOL(pcmcia_socket_class); 932EXPORT_SYMBOL(pcmcia_socket_class);
929 933
diff --git a/drivers/pcmcia/db1xxx_ss.c b/drivers/pcmcia/db1xxx_ss.c
index 9254ab0b29b..0f4cc3f0002 100644
--- a/drivers/pcmcia/db1xxx_ss.c
+++ b/drivers/pcmcia/db1xxx_ss.c
@@ -26,6 +26,7 @@
26#include <linux/pm.h> 26#include <linux/pm.h>
27#include <linux/platform_device.h> 27#include <linux/platform_device.h>
28#include <linux/resource.h> 28#include <linux/resource.h>
29#include <linux/slab.h>
29#include <linux/spinlock.h> 30#include <linux/spinlock.h>
30 31
31#include <pcmcia/cs_types.h> 32#include <pcmcia/cs_types.h>
@@ -145,7 +146,6 @@ static irqreturn_t db1200_pcmcia_cdirq(int irq, void *data)
145static int db1x_pcmcia_setup_irqs(struct db1x_pcmcia_sock *sock) 146static int db1x_pcmcia_setup_irqs(struct db1x_pcmcia_sock *sock)
146{ 147{
147 int ret; 148 int ret;
148 unsigned long flags;
149 149
150 if (sock->stschg_irq != -1) { 150 if (sock->stschg_irq != -1) {
151 ret = request_irq(sock->stschg_irq, db1000_pcmcia_stschgirq, 151 ret = request_irq(sock->stschg_irq, db1000_pcmcia_stschgirq,
@@ -161,8 +161,6 @@ static int db1x_pcmcia_setup_irqs(struct db1x_pcmcia_sock *sock)
161 * active one disabled. 161 * active one disabled.
162 */ 162 */
163 if (sock->board_type == BOARD_TYPE_DB1200) { 163 if (sock->board_type == BOARD_TYPE_DB1200) {
164 local_irq_save(flags);
165
166 ret = request_irq(sock->insert_irq, db1200_pcmcia_cdirq, 164 ret = request_irq(sock->insert_irq, db1200_pcmcia_cdirq,
167 IRQF_DISABLED, "pcmcia_insert", sock); 165 IRQF_DISABLED, "pcmcia_insert", sock);
168 if (ret) 166 if (ret)
@@ -172,17 +170,14 @@ static int db1x_pcmcia_setup_irqs(struct db1x_pcmcia_sock *sock)
172 IRQF_DISABLED, "pcmcia_eject", sock); 170 IRQF_DISABLED, "pcmcia_eject", sock);
173 if (ret) { 171 if (ret) {
174 free_irq(sock->insert_irq, sock); 172 free_irq(sock->insert_irq, sock);
175 local_irq_restore(flags);
176 goto out1; 173 goto out1;
177 } 174 }
178 175
179 /* disable the currently active one */ 176 /* enable the currently silent one */
180 if (db1200_card_inserted(sock)) 177 if (db1200_card_inserted(sock))
181 disable_irq_nosync(sock->insert_irq); 178 enable_irq(sock->eject_irq);
182 else 179 else
183 disable_irq_nosync(sock->eject_irq); 180 enable_irq(sock->insert_irq);
184
185 local_irq_restore(flags);
186 } else { 181 } else {
187 /* all other (older) Db1x00 boards use a GPIO to show 182 /* all other (older) Db1x00 boards use a GPIO to show
188 * card detection status: use both-edge triggers. 183 * card detection status: use both-edge triggers.
@@ -558,37 +553,10 @@ static int __devexit db1x_pcmcia_socket_remove(struct platform_device *pdev)
558 return 0; 553 return 0;
559} 554}
560 555
561#ifdef CONFIG_PM
562static int db1x_pcmcia_suspend(struct device *dev)
563{
564 return pcmcia_socket_dev_suspend(dev);
565}
566
567static int db1x_pcmcia_resume(struct device *dev)
568{
569 return pcmcia_socket_dev_resume(dev);
570}
571
572static struct dev_pm_ops db1x_pcmcia_pmops = {
573 .resume = db1x_pcmcia_resume,
574 .suspend = db1x_pcmcia_suspend,
575 .thaw = db1x_pcmcia_resume,
576 .freeze = db1x_pcmcia_suspend,
577};
578
579#define DB1XXX_SS_PMOPS &db1x_pcmcia_pmops
580
581#else
582
583#define DB1XXX_SS_PMOPS NULL
584
585#endif
586
587static struct platform_driver db1x_pcmcia_socket_driver = { 556static struct platform_driver db1x_pcmcia_socket_driver = {
588 .driver = { 557 .driver = {
589 .name = "db1xxx_pcmcia", 558 .name = "db1xxx_pcmcia",
590 .owner = THIS_MODULE, 559 .owner = THIS_MODULE,
591 .pm = DB1XXX_SS_PMOPS
592 }, 560 },
593 .probe = db1x_pcmcia_socket_probe, 561 .probe = db1x_pcmcia_socket_probe,
594 .remove = __devexit_p(db1x_pcmcia_socket_remove), 562 .remove = __devexit_p(db1x_pcmcia_socket_remove),
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index ad93ebd7b2a..041eee43fd8 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -24,6 +24,7 @@
24#include <linux/firmware.h> 24#include <linux/firmware.h>
25#include <linux/kref.h> 25#include <linux/kref.h>
26#include <linux/dma-mapping.h> 26#include <linux/dma-mapping.h>
27#include <linux/slab.h>
27 28
28#include <pcmcia/cs_types.h> 29#include <pcmcia/cs_types.h>
29#include <pcmcia/cs.h> 30#include <pcmcia/cs.h>
@@ -334,7 +335,6 @@ static void pcmcia_card_remove(struct pcmcia_socket *s, struct pcmcia_device *le
334 335
335 mutex_lock(&s->ops_mutex); 336 mutex_lock(&s->ops_mutex);
336 list_del(&p_dev->socket_device_list); 337 list_del(&p_dev->socket_device_list);
337 p_dev->_removed = 1;
338 mutex_unlock(&s->ops_mutex); 338 mutex_unlock(&s->ops_mutex);
339 339
340 dev_dbg(&p_dev->dev, "unregistering device\n"); 340 dev_dbg(&p_dev->dev, "unregistering device\n");
@@ -509,8 +509,12 @@ struct pcmcia_device *pcmcia_device_add(struct pcmcia_socket *s, unsigned int fu
509 p_dev->device_no = (s->device_count++); 509 p_dev->device_no = (s->device_count++);
510 mutex_unlock(&s->ops_mutex); 510 mutex_unlock(&s->ops_mutex);
511 511
512 /* max of 2 devices per card */ 512 /* max of 2 PFC devices */
513 if (p_dev->device_no >= 2) 513 if ((p_dev->device_no >= 2) && (function == 0))
514 goto err_free;
515
516 /* max of 4 devices overall */
517 if (p_dev->device_no >= 4)
514 goto err_free; 518 goto err_free;
515 519
516 p_dev->socket = s; 520 p_dev->socket = s;
@@ -649,14 +653,7 @@ static int pcmcia_requery_callback(struct device *dev, void * _data)
649 653
650static void pcmcia_requery(struct pcmcia_socket *s) 654static void pcmcia_requery(struct pcmcia_socket *s)
651{ 655{
652 int present, has_pfc; 656 int has_pfc;
653
654 mutex_lock(&s->ops_mutex);
655 present = s->pcmcia_state.present;
656 mutex_unlock(&s->ops_mutex);
657
658 if (!present)
659 return;
660 657
661 if (s->functions == 0) { 658 if (s->functions == 0) {
662 pcmcia_card_add(s); 659 pcmcia_card_add(s);
@@ -682,12 +679,10 @@ static void pcmcia_requery(struct pcmcia_socket *s)
682 new_funcs = mfc.nfn; 679 new_funcs = mfc.nfn;
683 else 680 else
684 new_funcs = 1; 681 new_funcs = 1;
685 if (old_funcs > new_funcs) { 682 if (old_funcs != new_funcs) {
683 /* we need to re-start */
686 pcmcia_card_remove(s, NULL); 684 pcmcia_card_remove(s, NULL);
687 pcmcia_card_add(s); 685 pcmcia_card_add(s);
688 } else if (new_funcs > old_funcs) {
689 s->functions = new_funcs;
690 pcmcia_device_add(s, 1);
691 } 686 }
692 } 687 }
693 688
@@ -723,6 +718,8 @@ static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
723 struct pcmcia_socket *s = dev->socket; 718 struct pcmcia_socket *s = dev->socket;
724 const struct firmware *fw; 719 const struct firmware *fw;
725 int ret = -ENOMEM; 720 int ret = -ENOMEM;
721 cistpl_longlink_mfc_t mfc;
722 int old_funcs, new_funcs = 1;
726 723
727 if (!filename) 724 if (!filename)
728 return -EINVAL; 725 return -EINVAL;
@@ -745,6 +742,14 @@ static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
745 goto release; 742 goto release;
746 } 743 }
747 744
745 /* we need to re-start if the number of functions changed */
746 old_funcs = s->functions;
747 if (!pccard_read_tuple(s, BIND_FN_ALL, CISTPL_LONGLINK_MFC,
748 &mfc))
749 new_funcs = mfc.nfn;
750
751 if (old_funcs != new_funcs)
752 ret = -EBUSY;
748 753
749 /* update information */ 754 /* update information */
750 pcmcia_device_query(dev); 755 pcmcia_device_query(dev);
@@ -815,11 +820,12 @@ static inline int pcmcia_devmatch(struct pcmcia_device *dev,
815 } 820 }
816 821
817 if (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) { 822 if (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) {
818 if (dev->device_no != did->device_no) 823 dev_dbg(&dev->dev, "this is a pseudo-multi-function device\n");
819 return 0;
820 mutex_lock(&dev->socket->ops_mutex); 824 mutex_lock(&dev->socket->ops_mutex);
821 dev->socket->pcmcia_state.has_pfc = 1; 825 dev->socket->pcmcia_state.has_pfc = 1;
822 mutex_unlock(&dev->socket->ops_mutex); 826 mutex_unlock(&dev->socket->ops_mutex);
827 if (dev->device_no != did->device_no)
828 return 0;
823 } 829 }
824 830
825 if (did->match_flags & PCMCIA_DEV_ID_MATCH_FUNC_ID) { 831 if (did->match_flags & PCMCIA_DEV_ID_MATCH_FUNC_ID) {
@@ -830,7 +836,7 @@ static inline int pcmcia_devmatch(struct pcmcia_device *dev,
830 836
831 /* if this is a pseudo-multi-function device, 837 /* if this is a pseudo-multi-function device,
832 * we need explicit matches */ 838 * we need explicit matches */
833 if (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) 839 if (dev->socket->pcmcia_state.has_pfc)
834 return 0; 840 return 0;
835 if (dev->device_no) 841 if (dev->device_no)
836 return 0; 842 return 0;
@@ -853,10 +859,8 @@ static inline int pcmcia_devmatch(struct pcmcia_device *dev,
853 if (did->match_flags & PCMCIA_DEV_ID_MATCH_FAKE_CIS) { 859 if (did->match_flags & PCMCIA_DEV_ID_MATCH_FAKE_CIS) {
854 dev_dbg(&dev->dev, "device needs a fake CIS\n"); 860 dev_dbg(&dev->dev, "device needs a fake CIS\n");
855 if (!dev->socket->fake_cis) 861 if (!dev->socket->fake_cis)
856 pcmcia_load_firmware(dev, did->cisfile); 862 if (pcmcia_load_firmware(dev, did->cisfile))
857 863 return 0;
858 if (!dev->socket->fake_cis)
859 return 0;
860 } 864 }
861 865
862 if (did->match_flags & PCMCIA_DEV_ID_MATCH_ANONYMOUS) { 866 if (did->match_flags & PCMCIA_DEV_ID_MATCH_ANONYMOUS) {
@@ -1249,9 +1253,7 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority)
1249 1253
1250 switch (event) { 1254 switch (event) {
1251 case CS_EVENT_CARD_REMOVAL: 1255 case CS_EVENT_CARD_REMOVAL:
1252 mutex_lock(&s->ops_mutex); 1256 atomic_set(&skt->present, 0);
1253 s->pcmcia_state.present = 0;
1254 mutex_unlock(&s->ops_mutex);
1255 pcmcia_card_remove(skt, NULL); 1257 pcmcia_card_remove(skt, NULL);
1256 handle_event(skt, event); 1258 handle_event(skt, event);
1257 mutex_lock(&s->ops_mutex); 1259 mutex_lock(&s->ops_mutex);
@@ -1260,9 +1262,9 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority)
1260 break; 1262 break;
1261 1263
1262 case CS_EVENT_CARD_INSERTION: 1264 case CS_EVENT_CARD_INSERTION:
1265 atomic_set(&skt->present, 1);
1263 mutex_lock(&s->ops_mutex); 1266 mutex_lock(&s->ops_mutex);
1264 s->pcmcia_state.has_pfc = 0; 1267 s->pcmcia_state.has_pfc = 0;
1265 s->pcmcia_state.present = 1;
1266 destroy_cis_cache(s); /* to be on the safe side... */ 1268 destroy_cis_cache(s); /* to be on the safe side... */
1267 mutex_unlock(&s->ops_mutex); 1269 mutex_unlock(&s->ops_mutex);
1268 pcmcia_card_add(skt); 1270 pcmcia_card_add(skt);
@@ -1281,6 +1283,7 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority)
1281 destroy_cis_cache(skt); 1283 destroy_cis_cache(skt);
1282 kfree(skt->fake_cis); 1284 kfree(skt->fake_cis);
1283 skt->fake_cis = NULL; 1285 skt->fake_cis = NULL;
1286 s->functions = 0;
1284 mutex_unlock(&s->ops_mutex); 1287 mutex_unlock(&s->ops_mutex);
1285 /* now, add the new card */ 1288 /* now, add the new card */
1286 ds_event(skt, CS_EVENT_CARD_INSERTION, 1289 ds_event(skt, CS_EVENT_CARD_INSERTION,
@@ -1302,7 +1305,13 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority)
1302 return 0; 1305 return 0;
1303} /* ds_event */ 1306} /* ds_event */
1304 1307
1305 1308/*
1309 * NOTE: This is racy. There's no guarantee the card will still be
1310 * physically present, even if the call to this function returns
1311 * non-NULL. Furthermore, the device driver most likely is unbound
1312 * almost immediately, so the timeframe where pcmcia_dev_present
1313 * returns NULL is probably really really small.
1314 */
1306struct pcmcia_device *pcmcia_dev_present(struct pcmcia_device *_p_dev) 1315struct pcmcia_device *pcmcia_dev_present(struct pcmcia_device *_p_dev)
1307{ 1316{
1308 struct pcmcia_device *p_dev; 1317 struct pcmcia_device *p_dev;
@@ -1312,22 +1321,9 @@ struct pcmcia_device *pcmcia_dev_present(struct pcmcia_device *_p_dev)
1312 if (!p_dev) 1321 if (!p_dev)
1313 return NULL; 1322 return NULL;
1314 1323
1315 mutex_lock(&p_dev->socket->ops_mutex); 1324 if (atomic_read(&p_dev->socket->present) != 0)
1316 if (!p_dev->socket->pcmcia_state.present) 1325 ret = p_dev;
1317 goto out;
1318
1319 if (p_dev->socket->pcmcia_state.dead)
1320 goto out;
1321 1326
1322 if (p_dev->_removed)
1323 goto out;
1324
1325 if (p_dev->suspended)
1326 goto out;
1327
1328 ret = p_dev;
1329 out:
1330 mutex_unlock(&p_dev->socket->ops_mutex);
1331 pcmcia_put_dev(p_dev); 1327 pcmcia_put_dev(p_dev);
1332 return ret; 1328 return ret;
1333} 1329}
@@ -1377,6 +1373,8 @@ static int __devinit pcmcia_bus_add_socket(struct device *dev,
1377 return ret; 1373 return ret;
1378 } 1374 }
1379 1375
1376 atomic_set(&socket->present, 0);
1377
1380 return 0; 1378 return 0;
1381} 1379}
1382 1380
@@ -1388,10 +1386,6 @@ static void pcmcia_bus_remove_socket(struct device *dev,
1388 if (!socket) 1386 if (!socket)
1389 return; 1387 return;
1390 1388
1391 mutex_lock(&socket->ops_mutex);
1392 socket->pcmcia_state.dead = 1;
1393 mutex_unlock(&socket->ops_mutex);
1394
1395 pccard_register_pcmcia(socket, NULL); 1389 pccard_register_pcmcia(socket, NULL);
1396 1390
1397 /* unregister any unbound devices */ 1391 /* unregister any unbound devices */
diff --git a/drivers/pcmcia/electra_cf.c b/drivers/pcmcia/electra_cf.c
index 89cfddca089..2e59fe947d2 100644
--- a/drivers/pcmcia/electra_cf.c
+++ b/drivers/pcmcia/electra_cf.c
@@ -31,6 +31,7 @@
31#include <linux/mm.h> 31#include <linux/mm.h>
32#include <linux/vmalloc.h> 32#include <linux/vmalloc.h>
33#include <linux/of_platform.h> 33#include <linux/of_platform.h>
34#include <linux/slab.h>
34 35
35#include <pcmcia/ss.h> 36#include <pcmcia/ss.h>
36 37
diff --git a/drivers/pcmcia/i82092.c b/drivers/pcmcia/i82092.c
index f5da6265331..3003bb3dfcc 100644
--- a/drivers/pcmcia/i82092.c
+++ b/drivers/pcmcia/i82092.c
@@ -39,27 +39,11 @@ static struct pci_device_id i82092aa_pci_ids[] = {
39}; 39};
40MODULE_DEVICE_TABLE(pci, i82092aa_pci_ids); 40MODULE_DEVICE_TABLE(pci, i82092aa_pci_ids);
41 41
42#ifdef CONFIG_PM
43static int i82092aa_socket_suspend (struct pci_dev *dev, pm_message_t state)
44{
45 return pcmcia_socket_dev_suspend(&dev->dev);
46}
47
48static int i82092aa_socket_resume (struct pci_dev *dev)
49{
50 return pcmcia_socket_dev_resume(&dev->dev);
51}
52#endif
53
54static struct pci_driver i82092aa_pci_driver = { 42static struct pci_driver i82092aa_pci_driver = {
55 .name = "i82092aa", 43 .name = "i82092aa",
56 .id_table = i82092aa_pci_ids, 44 .id_table = i82092aa_pci_ids,
57 .probe = i82092aa_pci_probe, 45 .probe = i82092aa_pci_probe,
58 .remove = __devexit_p(i82092aa_pci_remove), 46 .remove = __devexit_p(i82092aa_pci_remove),
59#ifdef CONFIG_PM
60 .suspend = i82092aa_socket_suspend,
61 .resume = i82092aa_socket_resume,
62#endif
63}; 47};
64 48
65 49
diff --git a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c
index c13fd936051..9e2a15628de 100644
--- a/drivers/pcmcia/i82365.c
+++ b/drivers/pcmcia/i82365.c
@@ -40,7 +40,6 @@
40#include <linux/kernel.h> 40#include <linux/kernel.h>
41#include <linux/errno.h> 41#include <linux/errno.h>
42#include <linux/timer.h> 42#include <linux/timer.h>
43#include <linux/slab.h>
44#include <linux/ioport.h> 43#include <linux/ioport.h>
45#include <linux/delay.h> 44#include <linux/delay.h>
46#include <linux/workqueue.h> 45#include <linux/workqueue.h>
@@ -1223,16 +1222,7 @@ static int pcic_init(struct pcmcia_socket *s)
1223 return 0; 1222 return 0;
1224} 1223}
1225 1224
1226static int i82365_drv_pcmcia_suspend(struct platform_device *dev,
1227 pm_message_t state)
1228{
1229 return pcmcia_socket_dev_suspend(&dev->dev);
1230}
1231 1225
1232static int i82365_drv_pcmcia_resume(struct platform_device *dev)
1233{
1234 return pcmcia_socket_dev_resume(&dev->dev);
1235}
1236static struct pccard_operations pcic_operations = { 1226static struct pccard_operations pcic_operations = {
1237 .init = pcic_init, 1227 .init = pcic_init,
1238 .get_status = pcic_get_status, 1228 .get_status = pcic_get_status,
@@ -1248,8 +1238,6 @@ static struct platform_driver i82365_driver = {
1248 .name = "i82365", 1238 .name = "i82365",
1249 .owner = THIS_MODULE, 1239 .owner = THIS_MODULE,
1250 }, 1240 },
1251 .suspend = i82365_drv_pcmcia_suspend,
1252 .resume = i82365_drv_pcmcia_resume,
1253}; 1241};
1254 1242
1255static struct platform_device *i82365_device; 1243static struct platform_device *i82365_device;
diff --git a/drivers/pcmcia/m32r_cfc.c b/drivers/pcmcia/m32r_cfc.c
index 0ece2cd4a85..7e16ed8eb0a 100644
--- a/drivers/pcmcia/m32r_cfc.c
+++ b/drivers/pcmcia/m32r_cfc.c
@@ -16,7 +16,6 @@
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <linux/timer.h> 18#include <linux/timer.h>
19#include <linux/slab.h>
20#include <linux/ioport.h> 19#include <linux/ioport.h>
21#include <linux/delay.h> 20#include <linux/delay.h>
22#include <linux/workqueue.h> 21#include <linux/workqueue.h>
@@ -685,16 +684,7 @@ static struct pccard_operations pcc_operations = {
685 .set_mem_map = pcc_set_mem_map, 684 .set_mem_map = pcc_set_mem_map,
686}; 685};
687 686
688static int cfc_drv_pcmcia_suspend(struct platform_device *dev,
689 pm_message_t state)
690{
691 return pcmcia_socket_dev_suspend(&dev->dev);
692}
693 687
694static int cfc_drv_pcmcia_resume(struct platform_device *dev)
695{
696 return pcmcia_socket_dev_resume(&dev->dev);
697}
698/*====================================================================*/ 688/*====================================================================*/
699 689
700static struct platform_driver pcc_driver = { 690static struct platform_driver pcc_driver = {
@@ -702,8 +692,6 @@ static struct platform_driver pcc_driver = {
702 .name = "cfc", 692 .name = "cfc",
703 .owner = THIS_MODULE, 693 .owner = THIS_MODULE,
704 }, 694 },
705 .suspend = cfc_drv_pcmcia_suspend,
706 .resume = cfc_drv_pcmcia_resume,
707}; 695};
708 696
709static struct platform_device pcc_device = { 697static struct platform_device pcc_device = {
diff --git a/drivers/pcmcia/m32r_pcc.c b/drivers/pcmcia/m32r_pcc.c
index 72844c5a6d0..6c5c3f910d7 100644
--- a/drivers/pcmcia/m32r_pcc.c
+++ b/drivers/pcmcia/m32r_pcc.c
@@ -16,7 +16,6 @@
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <linux/timer.h> 18#include <linux/timer.h>
19#include <linux/slab.h>
20#include <linux/ioport.h> 19#include <linux/ioport.h>
21#include <linux/delay.h> 20#include <linux/delay.h>
22#include <linux/workqueue.h> 21#include <linux/workqueue.h>
@@ -663,16 +662,6 @@ static struct pccard_operations pcc_operations = {
663 .set_mem_map = pcc_set_mem_map, 662 .set_mem_map = pcc_set_mem_map,
664}; 663};
665 664
666static int pcc_drv_pcmcia_suspend(struct platform_device *dev,
667 pm_message_t state)
668{
669 return pcmcia_socket_dev_suspend(&dev->dev);
670}
671
672static int pcc_drv_pcmcia_resume(struct platform_device *dev)
673{
674 return pcmcia_socket_dev_resume(&dev->dev);
675}
676/*====================================================================*/ 665/*====================================================================*/
677 666
678static struct platform_driver pcc_driver = { 667static struct platform_driver pcc_driver = {
@@ -680,8 +669,6 @@ static struct platform_driver pcc_driver = {
680 .name = "pcc", 669 .name = "pcc",
681 .owner = THIS_MODULE, 670 .owner = THIS_MODULE,
682 }, 671 },
683 .suspend = pcc_drv_pcmcia_suspend,
684 .resume = pcc_drv_pcmcia_resume,
685}; 672};
686 673
687static struct platform_device pcc_device = { 674static struct platform_device pcc_device = {
diff --git a/drivers/pcmcia/m8xx_pcmcia.c b/drivers/pcmcia/m8xx_pcmcia.c
index 61c21591812..41cc954a5ff 100644
--- a/drivers/pcmcia/m8xx_pcmcia.c
+++ b/drivers/pcmcia/m8xx_pcmcia.c
@@ -42,7 +42,6 @@
42 42
43#include <linux/kernel.h> 43#include <linux/kernel.h>
44#include <linux/errno.h> 44#include <linux/errno.h>
45#include <linux/slab.h>
46#include <linux/timer.h> 45#include <linux/timer.h>
47#include <linux/ioport.h> 46#include <linux/ioport.h>
48#include <linux/delay.h> 47#include <linux/delay.h>
@@ -1288,21 +1287,6 @@ static int m8xx_remove(struct of_device *ofdev)
1288 return 0; 1287 return 0;
1289} 1288}
1290 1289
1291#ifdef CONFIG_PM
1292static int m8xx_suspend(struct platform_device *pdev, pm_message_t state)
1293{
1294 return pcmcia_socket_dev_suspend(&pdev->dev);
1295}
1296
1297static int m8xx_resume(struct platform_device *pdev)
1298{
1299 return pcmcia_socket_dev_resume(&pdev->dev);
1300}
1301#else
1302#define m8xx_suspend NULL
1303#define m8xx_resume NULL
1304#endif
1305
1306static const struct of_device_id m8xx_pcmcia_match[] = { 1290static const struct of_device_id m8xx_pcmcia_match[] = {
1307 { 1291 {
1308 .type = "pcmcia", 1292 .type = "pcmcia",
@@ -1318,8 +1302,6 @@ static struct of_platform_driver m8xx_pcmcia_driver = {
1318 .match_table = m8xx_pcmcia_match, 1302 .match_table = m8xx_pcmcia_match,
1319 .probe = m8xx_probe, 1303 .probe = m8xx_probe,
1320 .remove = m8xx_remove, 1304 .remove = m8xx_remove,
1321 .suspend = m8xx_suspend,
1322 .resume = m8xx_resume,
1323}; 1305};
1324 1306
1325static int __init m8xx_init(void) 1307static int __init m8xx_init(void)
diff --git a/drivers/pcmcia/omap_cf.c b/drivers/pcmcia/omap_cf.c
index 3ef99155239..a7cfc7964c7 100644
--- a/drivers/pcmcia/omap_cf.c
+++ b/drivers/pcmcia/omap_cf.c
@@ -16,6 +16,7 @@
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/delay.h> 17#include <linux/delay.h>
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/slab.h>
19 20
20#include <pcmcia/ss.h> 21#include <pcmcia/ss.h>
21 22
@@ -330,24 +331,12 @@ static int __exit omap_cf_remove(struct platform_device *pdev)
330 return 0; 331 return 0;
331} 332}
332 333
333static int omap_cf_suspend(struct platform_device *pdev, pm_message_t mesg)
334{
335 return pcmcia_socket_dev_suspend(&pdev->dev);
336}
337
338static int omap_cf_resume(struct platform_device *pdev)
339{
340 return pcmcia_socket_dev_resume(&pdev->dev);
341}
342
343static struct platform_driver omap_cf_driver = { 334static struct platform_driver omap_cf_driver = {
344 .driver = { 335 .driver = {
345 .name = (char *) driver_name, 336 .name = (char *) driver_name,
346 .owner = THIS_MODULE, 337 .owner = THIS_MODULE,
347 }, 338 },
348 .remove = __exit_p(omap_cf_remove), 339 .remove = __exit_p(omap_cf_remove),
349 .suspend = omap_cf_suspend,
350 .resume = omap_cf_resume,
351}; 340};
352 341
353static int __init omap_cf_init(void) 342static int __init omap_cf_init(void)
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c
index 13a7132cf68..7631faa0cad 100644
--- a/drivers/pcmcia/pcmcia_ioctl.c
+++ b/drivers/pcmcia/pcmcia_ioctl.c
@@ -27,6 +27,7 @@
27#include <linux/proc_fs.h> 27#include <linux/proc_fs.h>
28#include <linux/poll.h> 28#include <linux/poll.h>
29#include <linux/pci.h> 29#include <linux/pci.h>
30#include <linux/slab.h>
30#include <linux/seq_file.h> 31#include <linux/seq_file.h>
31#include <linux/smp_lock.h> 32#include <linux/smp_lock.h>
32#include <linux/workqueue.h> 33#include <linux/workqueue.h>
@@ -710,7 +711,7 @@ static int ds_open(struct inode *inode, struct file *file)
710 warning_printed = 1; 711 warning_printed = 1;
711 } 712 }
712 713
713 if (s->pcmcia_state.present) 714 if (atomic_read(&s->present))
714 queue_event(user, CS_EVENT_CARD_INSERTION); 715 queue_event(user, CS_EVENT_CARD_INSERTION);
715out: 716out:
716 unlock_kernel(); 717 unlock_kernel();
@@ -769,9 +770,6 @@ static ssize_t ds_read(struct file *file, char __user *buf,
769 return -EIO; 770 return -EIO;
770 771
771 s = user->socket; 772 s = user->socket;
772 if (s->pcmcia_state.dead)
773 return -EIO;
774
775 ret = wait_event_interruptible(s->queue, !queue_empty(user)); 773 ret = wait_event_interruptible(s->queue, !queue_empty(user));
776 if (ret == 0) 774 if (ret == 0)
777 ret = put_user(get_queued_event(user), (int __user *)buf) ? -EFAULT : 4; 775 ret = put_user(get_queued_event(user), (int __user *)buf) ? -EFAULT : 4;
@@ -837,8 +835,6 @@ static int ds_ioctl(struct inode *inode, struct file *file,
837 return -EIO; 835 return -EIO;
838 836
839 s = user->socket; 837 s = user->socket;
840 if (s->pcmcia_state.dead)
841 return -EIO;
842 838
843 size = (cmd & IOCSIZE_MASK) >> IOCSIZE_SHIFT; 839 size = (cmd & IOCSIZE_MASK) >> IOCSIZE_SHIFT;
844 if (size > sizeof(ds_ioctl_arg_t)) 840 if (size > sizeof(ds_ioctl_arg_t))
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index c4612c52e4c..7c3d03bb4f3 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -21,6 +21,7 @@
21#include <linux/pci.h> 21#include <linux/pci.h>
22#include <linux/device.h> 22#include <linux/device.h>
23#include <linux/netdevice.h> 23#include <linux/netdevice.h>
24#include <linux/slab.h>
24 25
25#include <pcmcia/cs_types.h> 26#include <pcmcia/cs_types.h>
26#include <pcmcia/ss.h> 27#include <pcmcia/ss.h>
@@ -754,12 +755,12 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)
754 else 755 else
755 printk(KERN_WARNING "pcmcia: Driver needs updating to support IRQ sharing.\n"); 756 printk(KERN_WARNING "pcmcia: Driver needs updating to support IRQ sharing.\n");
756 757
757#ifdef CONFIG_PCMCIA_PROBE 758 /* If the interrupt is already assigned, it must be the same */
758 759 if (s->irq.AssignedIRQ != 0)
759 if (s->irq.AssignedIRQ != 0) {
760 /* If the interrupt is already assigned, it must be the same */
761 irq = s->irq.AssignedIRQ; 760 irq = s->irq.AssignedIRQ;
762 } else { 761
762#ifdef CONFIG_PCMCIA_PROBE
763 if (!irq) {
763 int try; 764 int try;
764 u32 mask = s->irq_mask; 765 u32 mask = s->irq_mask;
765 void *data = p_dev; /* something unique to this device */ 766 void *data = p_dev; /* something unique to this device */
diff --git a/drivers/pcmcia/pd6729.c b/drivers/pcmcia/pd6729.c
index 7ba57a565cd..b61a13663a0 100644
--- a/drivers/pcmcia/pd6729.c
+++ b/drivers/pcmcia/pd6729.c
@@ -9,18 +9,19 @@
9 9
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/slab.h>
12#include <linux/pci.h> 13#include <linux/pci.h>
13#include <linux/init.h> 14#include <linux/init.h>
14#include <linux/workqueue.h> 15#include <linux/workqueue.h>
15#include <linux/interrupt.h> 16#include <linux/interrupt.h>
16#include <linux/device.h> 17#include <linux/device.h>
18#include <linux/io.h>
17 19
18#include <pcmcia/cs_types.h> 20#include <pcmcia/cs_types.h>
19#include <pcmcia/ss.h> 21#include <pcmcia/ss.h>
20#include <pcmcia/cs.h> 22#include <pcmcia/cs.h>
21 23
22#include <asm/system.h> 24#include <asm/system.h>
23#include <asm/io.h>
24 25
25#include "pd6729.h" 26#include "pd6729.h"
26#include "i82365.h" 27#include "i82365.h"
@@ -222,9 +223,9 @@ static irqreturn_t pd6729_interrupt(int irq, void *dev)
222 ? SS_READY : 0; 223 ? SS_READY : 0;
223 } 224 }
224 225
225 if (events) { 226 if (events)
226 pcmcia_parse_events(&socket[i].socket, events); 227 pcmcia_parse_events(&socket[i].socket, events);
227 } 228
228 active |= events; 229 active |= events;
229 } 230 }
230 231
@@ -256,9 +257,8 @@ static int pd6729_get_status(struct pcmcia_socket *sock, u_int *value)
256 status = indirect_read(socket, I365_STATUS); 257 status = indirect_read(socket, I365_STATUS);
257 *value = 0; 258 *value = 0;
258 259
259 if ((status & I365_CS_DETECT) == I365_CS_DETECT) { 260 if ((status & I365_CS_DETECT) == I365_CS_DETECT)
260 *value |= SS_DETECT; 261 *value |= SS_DETECT;
261 }
262 262
263 /* 263 /*
264 * IO cards have a different meaning of bits 0,1 264 * IO cards have a different meaning of bits 0,1
@@ -308,7 +308,7 @@ static int pd6729_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
308 socket->card_irq = state->io_irq; 308 socket->card_irq = state->io_irq;
309 309
310 reg = 0; 310 reg = 0;
311 /* The reset bit has "inverse" logic */ 311 /* The reset bit has "inverse" logic */
312 if (!(state->flags & SS_RESET)) 312 if (!(state->flags & SS_RESET))
313 reg |= I365_PC_RESET; 313 reg |= I365_PC_RESET;
314 if (state->flags & SS_IOCARD) 314 if (state->flags & SS_IOCARD)
@@ -380,7 +380,7 @@ static int pd6729_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
380 indirect_write(socket, I365_POWER, reg); 380 indirect_write(socket, I365_POWER, reg);
381 381
382 if (irq_mode == 1) { 382 if (irq_mode == 1) {
383 /* all interrupts are to be done as PCI interrupts */ 383 /* all interrupts are to be done as PCI interrupts */
384 data = PD67_EC1_INV_MGMT_IRQ | PD67_EC1_INV_CARD_IRQ; 384 data = PD67_EC1_INV_MGMT_IRQ | PD67_EC1_INV_CARD_IRQ;
385 } else 385 } else
386 data = 0; 386 data = 0;
@@ -391,9 +391,9 @@ static int pd6729_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
391 /* Enable specific interrupt events */ 391 /* Enable specific interrupt events */
392 392
393 reg = 0x00; 393 reg = 0x00;
394 if (state->csc_mask & SS_DETECT) { 394 if (state->csc_mask & SS_DETECT)
395 reg |= I365_CSC_DETECT; 395 reg |= I365_CSC_DETECT;
396 } 396
397 if (state->flags & SS_IOCARD) { 397 if (state->flags & SS_IOCARD) {
398 if (state->csc_mask & SS_STSCHG) 398 if (state->csc_mask & SS_STSCHG)
399 reg |= I365_CSC_STSCHG; 399 reg |= I365_CSC_STSCHG;
@@ -450,9 +450,12 @@ static int pd6729_set_io_map(struct pcmcia_socket *sock,
450 450
451 ioctl = indirect_read(socket, I365_IOCTL) & ~I365_IOCTL_MASK(map); 451 ioctl = indirect_read(socket, I365_IOCTL) & ~I365_IOCTL_MASK(map);
452 452
453 if (io->flags & MAP_0WS) ioctl |= I365_IOCTL_0WS(map); 453 if (io->flags & MAP_0WS)
454 if (io->flags & MAP_16BIT) ioctl |= I365_IOCTL_16BIT(map); 454 ioctl |= I365_IOCTL_0WS(map);
455 if (io->flags & MAP_AUTOSZ) ioctl |= I365_IOCTL_IOCS16(map); 455 if (io->flags & MAP_16BIT)
456 ioctl |= I365_IOCTL_16BIT(map);
457 if (io->flags & MAP_AUTOSZ)
458 ioctl |= I365_IOCTL_IOCS16(map);
456 459
457 indirect_write(socket, I365_IOCTL, ioctl); 460 indirect_write(socket, I365_IOCTL, ioctl);
458 461
@@ -497,7 +500,7 @@ static int pd6729_set_mem_map(struct pcmcia_socket *sock,
497 500
498 /* write the stop address */ 501 /* write the stop address */
499 502
500 i= (mem->res->end >> 12) & 0x0fff; 503 i = (mem->res->end >> 12) & 0x0fff;
501 switch (to_cycles(mem->speed)) { 504 switch (to_cycles(mem->speed)) {
502 case 0: 505 case 0:
503 break; 506 break;
@@ -563,7 +566,7 @@ static int pd6729_init(struct pcmcia_socket *sock)
563 566
564/* the pccard structure and its functions */ 567/* the pccard structure and its functions */
565static struct pccard_operations pd6729_operations = { 568static struct pccard_operations pd6729_operations = {
566 .init = pd6729_init, 569 .init = pd6729_init,
567 .get_status = pd6729_get_status, 570 .get_status = pd6729_get_status,
568 .set_socket = pd6729_set_socket, 571 .set_socket = pd6729_set_socket,
569 .set_io_map = pd6729_set_io_map, 572 .set_io_map = pd6729_set_io_map,
@@ -578,8 +581,13 @@ static irqreturn_t pd6729_test(int irq, void *dev)
578 581
579static int pd6729_check_irq(int irq) 582static int pd6729_check_irq(int irq)
580{ 583{
581 if (request_irq(irq, pd6729_test, IRQF_PROBE_SHARED, "x", pd6729_test) 584 int ret;
582 != 0) return -1; 585
586 ret = request_irq(irq, pd6729_test, IRQF_PROBE_SHARED, "x",
587 pd6729_test);
588 if (ret)
589 return -1;
590
583 free_irq(irq, pd6729_test); 591 free_irq(irq, pd6729_test);
584 return 0; 592 return 0;
585} 593}
@@ -591,7 +599,7 @@ static u_int __devinit pd6729_isa_scan(void)
591 599
592 if (irq_mode == 1) { 600 if (irq_mode == 1) {
593 printk(KERN_INFO "pd6729: PCI card interrupts, " 601 printk(KERN_INFO "pd6729: PCI card interrupts, "
594 "PCI status changes\n"); 602 "PCI status changes\n");
595 return 0; 603 return 0;
596 } 604 }
597 605
@@ -607,9 +615,10 @@ static u_int __devinit pd6729_isa_scan(void)
607 if (mask & (1<<i)) 615 if (mask & (1<<i))
608 printk("%s%d", ((mask & ((1<<i)-1)) ? "," : ""), i); 616 printk("%s%d", ((mask & ((1<<i)-1)) ? "," : ""), i);
609 617
610 if (mask == 0) printk("none!"); 618 if (mask == 0)
611 619 printk("none!");
612 printk(" polling status changes.\n"); 620 else
621 printk(" polling status changes.\n");
613 622
614 return mask; 623 return mask;
615} 624}
@@ -624,11 +633,16 @@ static int __devinit pd6729_pci_probe(struct pci_dev *dev,
624 633
625 socket = kzalloc(sizeof(struct pd6729_socket) * MAX_SOCKETS, 634 socket = kzalloc(sizeof(struct pd6729_socket) * MAX_SOCKETS,
626 GFP_KERNEL); 635 GFP_KERNEL);
627 if (!socket) 636 if (!socket) {
637 dev_warn(&dev->dev, "failed to kzalloc socket.\n");
628 return -ENOMEM; 638 return -ENOMEM;
639 }
629 640
630 if ((ret = pci_enable_device(dev))) 641 ret = pci_enable_device(dev);
642 if (ret) {
643 dev_warn(&dev->dev, "failed to enable pci_device.\n");
631 goto err_out_free_mem; 644 goto err_out_free_mem;
645 }
632 646
633 if (!pci_resource_start(dev, 0)) { 647 if (!pci_resource_start(dev, 0)) {
634 dev_warn(&dev->dev, "refusing to load the driver as the " 648 dev_warn(&dev->dev, "refusing to load the driver as the "
@@ -639,7 +653,7 @@ static int __devinit pd6729_pci_probe(struct pci_dev *dev,
639 dev_info(&dev->dev, "Cirrus PD6729 PCI to PCMCIA Bridge at 0x%llx " 653 dev_info(&dev->dev, "Cirrus PD6729 PCI to PCMCIA Bridge at 0x%llx "
640 "on irq %d\n", 654 "on irq %d\n",
641 (unsigned long long)pci_resource_start(dev, 0), dev->irq); 655 (unsigned long long)pci_resource_start(dev, 0), dev->irq);
642 /* 656 /*
643 * Since we have no memory BARs some firmware may not 657 * Since we have no memory BARs some firmware may not
644 * have had PCI_COMMAND_MEMORY enabled, yet the device needs it. 658 * have had PCI_COMMAND_MEMORY enabled, yet the device needs it.
645 */ 659 */
@@ -685,8 +699,9 @@ static int __devinit pd6729_pci_probe(struct pci_dev *dev,
685 pci_set_drvdata(dev, socket); 699 pci_set_drvdata(dev, socket);
686 if (irq_mode == 1) { 700 if (irq_mode == 1) {
687 /* Register the interrupt handler */ 701 /* Register the interrupt handler */
688 if ((ret = request_irq(dev->irq, pd6729_interrupt, IRQF_SHARED, 702 ret = request_irq(dev->irq, pd6729_interrupt, IRQF_SHARED,
689 "pd6729", socket))) { 703 "pd6729", socket);
704 if (ret) {
690 dev_err(&dev->dev, "Failed to register irq %d\n", 705 dev_err(&dev->dev, "Failed to register irq %d\n",
691 dev->irq); 706 dev->irq);
692 goto err_out_free_res; 707 goto err_out_free_res;
@@ -750,18 +765,6 @@ static void __devexit pd6729_pci_remove(struct pci_dev *dev)
750 kfree(socket); 765 kfree(socket);
751} 766}
752 767
753#ifdef CONFIG_PM
754static int pd6729_socket_suspend(struct pci_dev *dev, pm_message_t state)
755{
756 return pcmcia_socket_dev_suspend(&dev->dev);
757}
758
759static int pd6729_socket_resume(struct pci_dev *dev)
760{
761 return pcmcia_socket_dev_resume(&dev->dev);
762}
763#endif
764
765static struct pci_device_id pd6729_pci_ids[] = { 768static struct pci_device_id pd6729_pci_ids[] = {
766 { 769 {
767 .vendor = PCI_VENDOR_ID_CIRRUS, 770 .vendor = PCI_VENDOR_ID_CIRRUS,
@@ -778,10 +781,6 @@ static struct pci_driver pd6729_pci_driver = {
778 .id_table = pd6729_pci_ids, 781 .id_table = pd6729_pci_ids,
779 .probe = pd6729_pci_probe, 782 .probe = pd6729_pci_probe,
780 .remove = __devexit_p(pd6729_pci_remove), 783 .remove = __devexit_p(pd6729_pci_remove),
781#ifdef CONFIG_PM
782 .suspend = pd6729_socket_suspend,
783 .resume = pd6729_socket_resume,
784#endif
785}; 784};
786 785
787static int pd6729_module_init(void) 786static int pd6729_module_init(void)
diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c
index 76e640bccde..df4532e91b1 100644
--- a/drivers/pcmcia/pxa2xx_base.c
+++ b/drivers/pcmcia/pxa2xx_base.c
@@ -17,6 +17,7 @@
17 ======================================================================*/ 17 ======================================================================*/
18 18
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/slab.h>
20#include <linux/init.h> 21#include <linux/init.h>
21#include <linux/cpufreq.h> 22#include <linux/cpufreq.h>
22#include <linux/ioport.h> 23#include <linux/ioport.h>
@@ -325,19 +326,13 @@ static int pxa2xx_drv_pcmcia_remove(struct platform_device *dev)
325 return 0; 326 return 0;
326} 327}
327 328
328static int pxa2xx_drv_pcmcia_suspend(struct device *dev)
329{
330 return pcmcia_socket_dev_suspend(dev);
331}
332
333static int pxa2xx_drv_pcmcia_resume(struct device *dev) 329static int pxa2xx_drv_pcmcia_resume(struct device *dev)
334{ 330{
335 pxa2xx_configure_sockets(dev); 331 pxa2xx_configure_sockets(dev);
336 return pcmcia_socket_dev_resume(dev); 332 return 0;
337} 333}
338 334
339static const struct dev_pm_ops pxa2xx_drv_pcmcia_pm_ops = { 335static const struct dev_pm_ops pxa2xx_drv_pcmcia_pm_ops = {
340 .suspend = pxa2xx_drv_pcmcia_suspend,
341 .resume = pxa2xx_drv_pcmcia_resume, 336 .resume = pxa2xx_drv_pcmcia_resume,
342}; 337};
343 338
diff --git a/drivers/pcmcia/pxa2xx_vpac270.c b/drivers/pcmcia/pxa2xx_vpac270.c
new file mode 100644
index 00000000000..55627eccee8
--- /dev/null
+++ b/drivers/pcmcia/pxa2xx_vpac270.c
@@ -0,0 +1,229 @@
1/*
2 * linux/drivers/pcmcia/pxa2xx_vpac270.c
3 *
4 * Driver for Voipac PXA270 PCMCIA and CF sockets
5 *
6 * Copyright (C) 2010
7 * Marek Vasut <marek.vasut@gmail.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 */
14
15#include <linux/module.h>
16#include <linux/platform_device.h>
17
18#include <asm/mach-types.h>
19
20#include <mach/gpio.h>
21#include <mach/vpac270.h>
22
23#include "soc_common.h"
24
25static struct pcmcia_irqs cd_irqs[] = {
26 {
27 .sock = 0,
28 .irq = IRQ_GPIO(GPIO84_VPAC270_PCMCIA_CD),
29 .str = "PCMCIA CD"
30 },
31 {
32 .sock = 1,
33 .irq = IRQ_GPIO(GPIO17_VPAC270_CF_CD),
34 .str = "CF CD"
35 },
36};
37
38static int vpac270_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
39{
40 int ret;
41
42 if (skt->nr == 0) {
43 ret = gpio_request(GPIO84_VPAC270_PCMCIA_CD, "PCMCIA CD");
44 if (ret)
45 goto err1;
46 ret = gpio_direction_input(GPIO84_VPAC270_PCMCIA_CD);
47 if (ret)
48 goto err2;
49
50 ret = gpio_request(GPIO35_VPAC270_PCMCIA_RDY, "PCMCIA RDY");
51 if (ret)
52 goto err2;
53 ret = gpio_direction_input(GPIO35_VPAC270_PCMCIA_RDY);
54 if (ret)
55 goto err3;
56
57 ret = gpio_request(GPIO107_VPAC270_PCMCIA_PPEN, "PCMCIA PPEN");
58 if (ret)
59 goto err3;
60 ret = gpio_direction_output(GPIO107_VPAC270_PCMCIA_PPEN, 0);
61 if (ret)
62 goto err4;
63
64 ret = gpio_request(GPIO11_VPAC270_PCMCIA_RESET, "PCMCIA RESET");
65 if (ret)
66 goto err4;
67 ret = gpio_direction_output(GPIO11_VPAC270_PCMCIA_RESET, 0);
68 if (ret)
69 goto err5;
70
71 skt->socket.pci_irq = gpio_to_irq(GPIO35_VPAC270_PCMCIA_RDY);
72
73 return soc_pcmcia_request_irqs(skt, &cd_irqs[0], 1);
74
75err5:
76 gpio_free(GPIO11_VPAC270_PCMCIA_RESET);
77err4:
78 gpio_free(GPIO107_VPAC270_PCMCIA_PPEN);
79err3:
80 gpio_free(GPIO35_VPAC270_PCMCIA_RDY);
81err2:
82 gpio_free(GPIO84_VPAC270_PCMCIA_CD);
83err1:
84 return ret;
85
86 } else {
87 ret = gpio_request(GPIO17_VPAC270_CF_CD, "CF CD");
88 if (ret)
89 goto err6;
90 ret = gpio_direction_input(GPIO17_VPAC270_CF_CD);
91 if (ret)
92 goto err7;
93
94 ret = gpio_request(GPIO12_VPAC270_CF_RDY, "CF RDY");
95 if (ret)
96 goto err7;
97 ret = gpio_direction_input(GPIO12_VPAC270_CF_RDY);
98 if (ret)
99 goto err8;
100
101 ret = gpio_request(GPIO16_VPAC270_CF_RESET, "CF RESET");
102 if (ret)
103 goto err8;
104 ret = gpio_direction_output(GPIO16_VPAC270_CF_RESET, 0);
105 if (ret)
106 goto err9;
107
108 skt->socket.pci_irq = gpio_to_irq(GPIO12_VPAC270_CF_RDY);
109
110 return soc_pcmcia_request_irqs(skt, &cd_irqs[1], 1);
111
112err9:
113 gpio_free(GPIO16_VPAC270_CF_RESET);
114err8:
115 gpio_free(GPIO12_VPAC270_CF_RDY);
116err7:
117 gpio_free(GPIO17_VPAC270_CF_CD);
118err6:
119 return ret;
120
121 }
122}
123
124static void vpac270_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
125{
126 gpio_free(GPIO11_VPAC270_PCMCIA_RESET);
127 gpio_free(GPIO107_VPAC270_PCMCIA_PPEN);
128 gpio_free(GPIO35_VPAC270_PCMCIA_RDY);
129 gpio_free(GPIO84_VPAC270_PCMCIA_CD);
130 gpio_free(GPIO16_VPAC270_CF_RESET);
131 gpio_free(GPIO12_VPAC270_CF_RDY);
132 gpio_free(GPIO17_VPAC270_CF_CD);
133}
134
135static void vpac270_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
136 struct pcmcia_state *state)
137{
138 if (skt->nr == 0) {
139 state->detect = !gpio_get_value(GPIO84_VPAC270_PCMCIA_CD);
140 state->ready = !!gpio_get_value(GPIO35_VPAC270_PCMCIA_RDY);
141 } else {
142 state->detect = !gpio_get_value(GPIO17_VPAC270_CF_CD);
143 state->ready = !!gpio_get_value(GPIO12_VPAC270_CF_RDY);
144 }
145 state->bvd1 = 1;
146 state->bvd2 = 1;
147 state->wrprot = 0;
148 state->vs_3v = 1;
149 state->vs_Xv = 0;
150}
151
152static int
153vpac270_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
154 const socket_state_t *state)
155{
156 if (skt->nr == 0) {
157 gpio_set_value(GPIO11_VPAC270_PCMCIA_RESET,
158 (state->flags & SS_RESET));
159 gpio_set_value(GPIO107_VPAC270_PCMCIA_PPEN,
160 !(state->Vcc == 33 || state->Vcc == 50));
161 } else {
162 gpio_set_value(GPIO16_VPAC270_CF_RESET,
163 (state->flags & SS_RESET));
164 }
165
166 return 0;
167}
168
169static void vpac270_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
170{
171}
172
173static void vpac270_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
174{
175}
176
177static struct pcmcia_low_level vpac270_pcmcia_ops = {
178 .owner = THIS_MODULE,
179
180 .first = 0,
181 .nr = 2,
182
183 .hw_init = vpac270_pcmcia_hw_init,
184 .hw_shutdown = vpac270_pcmcia_hw_shutdown,
185
186 .socket_state = vpac270_pcmcia_socket_state,
187 .configure_socket = vpac270_pcmcia_configure_socket,
188
189 .socket_init = vpac270_pcmcia_socket_init,
190 .socket_suspend = vpac270_pcmcia_socket_suspend,
191};
192
193static struct platform_device *vpac270_pcmcia_device;
194
195static int __init vpac270_pcmcia_init(void)
196{
197 int ret;
198
199 if (!machine_is_vpac270())
200 return -ENODEV;
201
202 vpac270_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
203 if (!vpac270_pcmcia_device)
204 return -ENOMEM;
205
206 ret = platform_device_add_data(vpac270_pcmcia_device,
207 &vpac270_pcmcia_ops, sizeof(vpac270_pcmcia_ops));
208
209 if (!ret)
210 ret = platform_device_add(vpac270_pcmcia_device);
211
212 if (ret)
213 platform_device_put(vpac270_pcmcia_device);
214
215 return ret;
216}
217
218static void __exit vpac270_pcmcia_exit(void)
219{
220 platform_device_unregister(vpac270_pcmcia_device);
221}
222
223module_init(vpac270_pcmcia_init);
224module_exit(vpac270_pcmcia_exit);
225
226MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>");
227MODULE_DESCRIPTION("PCMCIA support for Voipac PXA270");
228MODULE_ALIAS("platform:pxa2xx-pcmcia");
229MODULE_LICENSE("GPL");
diff --git a/drivers/pcmcia/rsrc_mgr.c b/drivers/pcmcia/rsrc_mgr.c
index 452c83b512c..ffa5f3cae57 100644
--- a/drivers/pcmcia/rsrc_mgr.c
+++ b/drivers/pcmcia/rsrc_mgr.c
@@ -12,6 +12,7 @@
12 * (C) 1999 David A. Hinds 12 * (C) 1999 David A. Hinds
13 */ 13 */
14 14
15#include <linux/slab.h>
15#include <linux/module.h> 16#include <linux/module.h>
16#include <linux/kernel.h> 17#include <linux/kernel.h>
17 18
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c
index 4663b3fa9f9..a6eb7b59ba9 100644
--- a/drivers/pcmcia/rsrc_nonstatic.c
+++ b/drivers/pcmcia/rsrc_nonstatic.c
@@ -214,7 +214,7 @@ static void do_io_probe(struct pcmcia_socket *s, unsigned int base,
214 return; 214 return;
215 } 215 }
216 for (i = base, most = 0; i < base+num; i += 8) { 216 for (i = base, most = 0; i < base+num; i += 8) {
217 res = claim_region(NULL, i, 8, IORESOURCE_IO, "PCMCIA ioprobe"); 217 res = claim_region(s, i, 8, IORESOURCE_IO, "PCMCIA ioprobe");
218 if (!res) 218 if (!res)
219 continue; 219 continue;
220 hole = inb(i); 220 hole = inb(i);
@@ -231,9 +231,14 @@ static void do_io_probe(struct pcmcia_socket *s, unsigned int base,
231 231
232 bad = any = 0; 232 bad = any = 0;
233 for (i = base; i < base+num; i += 8) { 233 for (i = base; i < base+num; i += 8) {
234 res = claim_region(NULL, i, 8, IORESOURCE_IO, "PCMCIA ioprobe"); 234 res = claim_region(s, i, 8, IORESOURCE_IO, "PCMCIA ioprobe");
235 if (!res) 235 if (!res) {
236 if (!any)
237 printk(" excluding");
238 if (!bad)
239 bad = any = i;
236 continue; 240 continue;
241 }
237 for (j = 0; j < 8; j++) 242 for (j = 0; j < 8; j++)
238 if (inb(i+j) != most) 243 if (inb(i+j) != most)
239 break; 244 break;
@@ -253,6 +258,7 @@ static void do_io_probe(struct pcmcia_socket *s, unsigned int base,
253 } 258 }
254 if (bad) { 259 if (bad) {
255 if ((num > 16) && (bad == base) && (i == base+num)) { 260 if ((num > 16) && (bad == base) && (i == base+num)) {
261 sub_interval(&s_data->io_db, bad, i-bad);
256 printk(" nothing: probe failed.\n"); 262 printk(" nothing: probe failed.\n");
257 return; 263 return;
258 } else { 264 } else {
@@ -596,19 +602,17 @@ struct pcmcia_align_data {
596 struct resource_map *map; 602 struct resource_map *map;
597}; 603};
598 604
599static resource_size_t 605static resource_size_t pcmcia_common_align(struct pcmcia_align_data *align_data,
600pcmcia_common_align(void *align_data, const struct resource *res, 606 resource_size_t start)
601 resource_size_t size, resource_size_t align)
602{ 607{
603 struct pcmcia_align_data *data = align_data; 608 resource_size_t ret;
604 resource_size_t start;
605 /* 609 /*
606 * Ensure that we have the correct start address 610 * Ensure that we have the correct start address
607 */ 611 */
608 start = (res->start & ~data->mask) + data->offset; 612 ret = (start & ~align_data->mask) + align_data->offset;
609 if (start < res->start) 613 if (ret < start)
610 start += data->mask + 1; 614 ret += align_data->mask + 1;
611 return start; 615 return ret;
612} 616}
613 617
614static resource_size_t 618static resource_size_t
@@ -619,29 +623,28 @@ pcmcia_align(void *align_data, const struct resource *res,
619 struct resource_map *m; 623 struct resource_map *m;
620 resource_size_t start; 624 resource_size_t start;
621 625
622 start = pcmcia_common_align(data, res, size, align); 626 start = pcmcia_common_align(data, res->start);
623 627
624 for (m = data->map->next; m != data->map; m = m->next) { 628 for (m = data->map->next; m != data->map; m = m->next) {
625 unsigned long start = m->base; 629 unsigned long map_start = m->base;
626 unsigned long end = m->base + m->num - 1; 630 unsigned long map_end = m->base + m->num - 1;
627 631
628 /* 632 /*
629 * If the lower resources are not available, try aligning 633 * If the lower resources are not available, try aligning
630 * to this entry of the resource database to see if it'll 634 * to this entry of the resource database to see if it'll
631 * fit here. 635 * fit here.
632 */ 636 */
633 if (res->start < start) { 637 if (start < map_start)
634 start = pcmcia_common_align(data, res, size, align); 638 start = pcmcia_common_align(data, map_start);
635 }
636 639
637 /* 640 /*
638 * If we're above the area which was passed in, there's 641 * If we're above the area which was passed in, there's
639 * no point proceeding. 642 * no point proceeding.
640 */ 643 */
641 if (res->start >= res->end) 644 if (start >= res->end)
642 break; 645 break;
643 646
644 if ((res->start + size - 1) <= end) 647 if ((start + size - 1) <= map_end)
645 break; 648 break;
646 } 649 }
647 650
@@ -807,9 +810,18 @@ static int adjust_memory(struct pcmcia_socket *s, unsigned int action, unsigned
807static int adjust_io(struct pcmcia_socket *s, unsigned int action, unsigned long start, unsigned long end) 810static int adjust_io(struct pcmcia_socket *s, unsigned int action, unsigned long start, unsigned long end)
808{ 811{
809 struct socket_data *data = s->resource_data; 812 struct socket_data *data = s->resource_data;
810 unsigned long size = end - start + 1; 813 unsigned long size;
811 int ret = 0; 814 int ret = 0;
812 815
816#if defined(CONFIG_X86)
817 /* on x86, avoid anything < 0x100 for it is often used for
818 * legacy platform devices */
819 if (start < 0x100)
820 start = 0x100;
821#endif
822
823 size = end - start + 1;
824
813 if (end < start) 825 if (end < start)
814 return -EINVAL; 826 return -EINVAL;
815 827
@@ -867,10 +879,8 @@ static int nonstatic_autoadd_resources(struct pcmcia_socket *s)
867 if (res == &ioport_resource) 879 if (res == &ioport_resource)
868 continue; 880 continue;
869 dev_printk(KERN_INFO, &s->cb_dev->dev, 881 dev_printk(KERN_INFO, &s->cb_dev->dev,
870 "pcmcia: parent PCI bridge I/O " 882 "pcmcia: parent PCI bridge window: %pR\n",
871 "window: 0x%llx - 0x%llx\n", 883 res);
872 (unsigned long long)res->start,
873 (unsigned long long)res->end);
874 if (!adjust_io(s, ADD_MANAGED_RESOURCE, res->start, res->end)) 884 if (!adjust_io(s, ADD_MANAGED_RESOURCE, res->start, res->end))
875 done |= IORESOURCE_IO; 885 done |= IORESOURCE_IO;
876 886
@@ -880,10 +890,8 @@ static int nonstatic_autoadd_resources(struct pcmcia_socket *s)
880 if (res == &iomem_resource) 890 if (res == &iomem_resource)
881 continue; 891 continue;
882 dev_printk(KERN_INFO, &s->cb_dev->dev, 892 dev_printk(KERN_INFO, &s->cb_dev->dev,
883 "pcmcia: parent PCI bridge Memory " 893 "pcmcia: parent PCI bridge window: %pR\n",
884 "window: 0x%llx - 0x%llx\n", 894 res);
885 (unsigned long long)res->start,
886 (unsigned long long)res->end);
887 if (!adjust_memory(s, ADD_MANAGED_RESOURCE, res->start, res->end)) 895 if (!adjust_memory(s, ADD_MANAGED_RESOURCE, res->start, res->end))
888 done |= IORESOURCE_MEM; 896 done |= IORESOURCE_MEM;
889 } 897 }
diff --git a/drivers/pcmcia/sa1100_generic.c b/drivers/pcmcia/sa1100_generic.c
index 8db86b90c20..edbd8c47262 100644
--- a/drivers/pcmcia/sa1100_generic.c
+++ b/drivers/pcmcia/sa1100_generic.c
@@ -32,6 +32,7 @@
32 32
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/init.h> 34#include <linux/init.h>
35#include <linux/slab.h>
35#include <linux/platform_device.h> 36#include <linux/platform_device.h>
36 37
37#include <pcmcia/cs_types.h> 38#include <pcmcia/cs_types.h>
@@ -95,17 +96,6 @@ static int sa11x0_drv_pcmcia_remove(struct platform_device *dev)
95 return 0; 96 return 0;
96} 97}
97 98
98static int sa11x0_drv_pcmcia_suspend(struct platform_device *dev,
99 pm_message_t state)
100{
101 return pcmcia_socket_dev_suspend(&dev->dev);
102}
103
104static int sa11x0_drv_pcmcia_resume(struct platform_device *dev)
105{
106 return pcmcia_socket_dev_resume(&dev->dev);
107}
108
109static struct platform_driver sa11x0_pcmcia_driver = { 99static struct platform_driver sa11x0_pcmcia_driver = {
110 .driver = { 100 .driver = {
111 .name = "sa11x0-pcmcia", 101 .name = "sa11x0-pcmcia",
@@ -113,8 +103,6 @@ static struct platform_driver sa11x0_pcmcia_driver = {
113 }, 103 },
114 .probe = sa11x0_drv_pcmcia_probe, 104 .probe = sa11x0_drv_pcmcia_probe,
115 .remove = sa11x0_drv_pcmcia_remove, 105 .remove = sa11x0_drv_pcmcia_remove,
116 .suspend = sa11x0_drv_pcmcia_suspend,
117 .resume = sa11x0_drv_pcmcia_resume,
118}; 106};
119 107
120/* sa11x0_pcmcia_init() 108/* sa11x0_pcmcia_init()
diff --git a/drivers/pcmcia/sa1111_generic.c b/drivers/pcmcia/sa1111_generic.c
index db79ca61cf9..59866905ea3 100644
--- a/drivers/pcmcia/sa1111_generic.c
+++ b/drivers/pcmcia/sa1111_generic.c
@@ -12,6 +12,7 @@
12#include <linux/interrupt.h> 12#include <linux/interrupt.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/io.h> 14#include <linux/io.h>
15#include <linux/slab.h>
15 16
16#include <pcmcia/ss.h> 17#include <pcmcia/ss.h>
17 18
@@ -213,16 +214,6 @@ static int __devexit pcmcia_remove(struct sa1111_dev *dev)
213 return 0; 214 return 0;
214} 215}
215 216
216static int pcmcia_suspend(struct sa1111_dev *dev, pm_message_t state)
217{
218 return pcmcia_socket_dev_suspend(&dev->dev);
219}
220
221static int pcmcia_resume(struct sa1111_dev *dev)
222{
223 return pcmcia_socket_dev_resume(&dev->dev);
224}
225
226static struct sa1111_driver pcmcia_driver = { 217static struct sa1111_driver pcmcia_driver = {
227 .drv = { 218 .drv = {
228 .name = "sa1111-pcmcia", 219 .name = "sa1111-pcmcia",
@@ -230,8 +221,6 @@ static struct sa1111_driver pcmcia_driver = {
230 .devid = SA1111_DEVID_PCMCIA, 221 .devid = SA1111_DEVID_PCMCIA,
231 .probe = pcmcia_probe, 222 .probe = pcmcia_probe,
232 .remove = __devexit_p(pcmcia_remove), 223 .remove = __devexit_p(pcmcia_remove),
233 .suspend = pcmcia_suspend,
234 .resume = pcmcia_resume,
235}; 224};
236 225
237static int __init sa1111_drv_pcmcia_init(void) 226static int __init sa1111_drv_pcmcia_init(void)
diff --git a/drivers/pcmcia/sa11xx_base.c b/drivers/pcmcia/sa11xx_base.c
index fc9a6527019..fa28d8911b0 100644
--- a/drivers/pcmcia/sa11xx_base.c
+++ b/drivers/pcmcia/sa11xx_base.c
@@ -37,6 +37,7 @@
37#include <linux/kernel.h> 37#include <linux/kernel.h>
38#include <linux/spinlock.h> 38#include <linux/spinlock.h>
39#include <linux/io.h> 39#include <linux/io.h>
40#include <linux/slab.h>
40 41
41#include <mach/hardware.h> 42#include <mach/hardware.h>
42#include <asm/irq.h> 43#include <asm/irq.h>
diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c
index 08278016e58..80e36bc407d 100644
--- a/drivers/pcmcia/socket_sysfs.c
+++ b/drivers/pcmcia/socket_sysfs.c
@@ -15,7 +15,6 @@
15#include <linux/string.h> 15#include <linux/string.h>
16#include <linux/major.h> 16#include <linux/major.h>
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <linux/slab.h>
19#include <linux/mm.h> 18#include <linux/mm.h>
20#include <linux/interrupt.h> 19#include <linux/interrupt.h>
21#include <linux/timer.h> 20#include <linux/timer.h>
diff --git a/drivers/pcmcia/tcic.c b/drivers/pcmcia/tcic.c
index 12c49ee135e..56004a1b5bb 100644
--- a/drivers/pcmcia/tcic.c
+++ b/drivers/pcmcia/tcic.c
@@ -39,7 +39,6 @@
39#include <linux/string.h> 39#include <linux/string.h>
40#include <linux/errno.h> 40#include <linux/errno.h>
41#include <linux/interrupt.h> 41#include <linux/interrupt.h>
42#include <linux/slab.h>
43#include <linux/timer.h> 42#include <linux/timer.h>
44#include <linux/ioport.h> 43#include <linux/ioport.h>
45#include <linux/delay.h> 44#include <linux/delay.h>
@@ -348,16 +347,6 @@ static int __init get_tcic_id(void)
348 return id; 347 return id;
349} 348}
350 349
351static int tcic_drv_pcmcia_suspend(struct platform_device *dev,
352 pm_message_t state)
353{
354 return pcmcia_socket_dev_suspend(&dev->dev);
355}
356
357static int tcic_drv_pcmcia_resume(struct platform_device *dev)
358{
359 return pcmcia_socket_dev_resume(&dev->dev);
360}
361/*====================================================================*/ 350/*====================================================================*/
362 351
363static struct platform_driver tcic_driver = { 352static struct platform_driver tcic_driver = {
@@ -365,8 +354,6 @@ static struct platform_driver tcic_driver = {
365 .name = "tcic-pcmcia", 354 .name = "tcic-pcmcia",
366 .owner = THIS_MODULE, 355 .owner = THIS_MODULE,
367 }, 356 },
368 .suspend = tcic_drv_pcmcia_suspend,
369 .resume = tcic_drv_pcmcia_resume,
370}; 357};
371 358
372static struct platform_device tcic_device = { 359static struct platform_device tcic_device = {
diff --git a/drivers/pcmcia/vrc4171_card.c b/drivers/pcmcia/vrc4171_card.c
index aaccdb9f4ba..86e4a1a3c64 100644
--- a/drivers/pcmcia/vrc4171_card.c
+++ b/drivers/pcmcia/vrc4171_card.c
@@ -705,24 +705,11 @@ static int __devinit vrc4171_card_setup(char *options)
705 705
706__setup("vrc4171_card=", vrc4171_card_setup); 706__setup("vrc4171_card=", vrc4171_card_setup);
707 707
708static int vrc4171_card_suspend(struct platform_device *dev,
709 pm_message_t state)
710{
711 return pcmcia_socket_dev_suspend(&dev->dev);
712}
713
714static int vrc4171_card_resume(struct platform_device *dev)
715{
716 return pcmcia_socket_dev_resume(&dev->dev);
717}
718
719static struct platform_driver vrc4171_card_driver = { 708static struct platform_driver vrc4171_card_driver = {
720 .driver = { 709 .driver = {
721 .name = vrc4171_card_name, 710 .name = vrc4171_card_name,
722 .owner = THIS_MODULE, 711 .owner = THIS_MODULE,
723 }, 712 },
724 .suspend = vrc4171_card_suspend,
725 .resume = vrc4171_card_resume,
726}; 713};
727 714
728static int __devinit vrc4171_card_init(void) 715static int __devinit vrc4171_card_init(void)
diff --git a/drivers/pcmcia/xxs1500_ss.c b/drivers/pcmcia/xxs1500_ss.c
index f9009d34254..201ccfa1e97 100644
--- a/drivers/pcmcia/xxs1500_ss.c
+++ b/drivers/pcmcia/xxs1500_ss.c
@@ -14,6 +14,7 @@
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/pm.h> 15#include <linux/pm.h>
16#include <linux/resource.h> 16#include <linux/resource.h>
17#include <linux/slab.h>
17#include <linux/spinlock.h> 18#include <linux/spinlock.h>
18 19
19#include <pcmcia/cs_types.h> 20#include <pcmcia/cs_types.h>
diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c
index 418988ab6ed..83ace277426 100644
--- a/drivers/pcmcia/yenta_socket.c
+++ b/drivers/pcmcia/yenta_socket.c
@@ -17,6 +17,7 @@
17#include <linux/delay.h> 17#include <linux/delay.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/io.h> 19#include <linux/io.h>
20#include <linux/slab.h>
20 21
21#include <pcmcia/cs_types.h> 22#include <pcmcia/cs_types.h>
22#include <pcmcia/ss.h> 23#include <pcmcia/ss.h>
@@ -1290,12 +1291,9 @@ static int yenta_dev_suspend_noirq(struct device *dev)
1290{ 1291{
1291 struct pci_dev *pdev = to_pci_dev(dev); 1292 struct pci_dev *pdev = to_pci_dev(dev);
1292 struct yenta_socket *socket = pci_get_drvdata(pdev); 1293 struct yenta_socket *socket = pci_get_drvdata(pdev);
1293 int ret;
1294
1295 ret = pcmcia_socket_dev_suspend(dev);
1296 1294
1297 if (!socket) 1295 if (!socket)
1298 return ret; 1296 return 0;
1299 1297
1300 if (socket->type && socket->type->save_state) 1298 if (socket->type && socket->type->save_state)
1301 socket->type->save_state(socket); 1299 socket->type->save_state(socket);
@@ -1312,7 +1310,7 @@ static int yenta_dev_suspend_noirq(struct device *dev)
1312 */ 1310 */
1313 /* pci_set_power_state(dev, 3); */ 1311 /* pci_set_power_state(dev, 3); */
1314 1312
1315 return ret; 1313 return 0;
1316} 1314}
1317 1315
1318static int yenta_dev_resume_noirq(struct device *dev) 1316static int yenta_dev_resume_noirq(struct device *dev)
@@ -1336,26 +1334,16 @@ static int yenta_dev_resume_noirq(struct device *dev)
1336 if (socket->type && socket->type->restore_state) 1334 if (socket->type && socket->type->restore_state)
1337 socket->type->restore_state(socket); 1335 socket->type->restore_state(socket);
1338 1336
1339 pcmcia_socket_dev_early_resume(dev);
1340 return 0;
1341}
1342
1343static int yenta_dev_resume(struct device *dev)
1344{
1345 pcmcia_socket_dev_late_resume(dev);
1346 return 0; 1337 return 0;
1347} 1338}
1348 1339
1349static const struct dev_pm_ops yenta_pm_ops = { 1340static const struct dev_pm_ops yenta_pm_ops = {
1350 .suspend_noirq = yenta_dev_suspend_noirq, 1341 .suspend_noirq = yenta_dev_suspend_noirq,
1351 .resume_noirq = yenta_dev_resume_noirq, 1342 .resume_noirq = yenta_dev_resume_noirq,
1352 .resume = yenta_dev_resume,
1353 .freeze_noirq = yenta_dev_suspend_noirq, 1343 .freeze_noirq = yenta_dev_suspend_noirq,
1354 .thaw_noirq = yenta_dev_resume_noirq, 1344 .thaw_noirq = yenta_dev_resume_noirq,
1355 .thaw = yenta_dev_resume,
1356 .poweroff_noirq = yenta_dev_suspend_noirq, 1345 .poweroff_noirq = yenta_dev_suspend_noirq,
1357 .restore_noirq = yenta_dev_resume_noirq, 1346 .restore_noirq = yenta_dev_resume_noirq,
1358 .restore = yenta_dev_resume,
1359}; 1347};
1360 1348
1361#define YENTA_PM_OPS (&yenta_pm_ops) 1349#define YENTA_PM_OPS (&yenta_pm_ops)
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index e631dbeafd7..6c3320d7505 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -385,6 +385,17 @@ config EEEPC_LAPTOP
385 385
386 If you have an Eee PC laptop, say Y or M here. 386 If you have an Eee PC laptop, say Y or M here.
387 387
388config EEEPC_WMI
389 tristate "Eee PC WMI Hotkey Driver (EXPERIMENTAL)"
390 depends on ACPI_WMI
391 depends on INPUT
392 depends on EXPERIMENTAL
393 select INPUT_SPARSEKMAP
394 ---help---
395 Say Y here if you want to support WMI-based hotkeys on Eee PC laptops.
396
397 To compile this driver as a module, choose M here: the module will
398 be called eeepc-wmi.
388 399
389config ACPI_WMI 400config ACPI_WMI
390 tristate "WMI" 401 tristate "WMI"
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
index 9cd9fa0a27e..a906490e353 100644
--- a/drivers/platform/x86/Makefile
+++ b/drivers/platform/x86/Makefile
@@ -4,6 +4,7 @@
4# 4#
5obj-$(CONFIG_ASUS_LAPTOP) += asus-laptop.o 5obj-$(CONFIG_ASUS_LAPTOP) += asus-laptop.o
6obj-$(CONFIG_EEEPC_LAPTOP) += eeepc-laptop.o 6obj-$(CONFIG_EEEPC_LAPTOP) += eeepc-laptop.o
7obj-$(CONFIG_EEEPC_WMI) += eeepc-wmi.o
7obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o 8obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o
8obj-$(CONFIG_ACPI_CMPC) += classmate-laptop.o 9obj-$(CONFIG_ACPI_CMPC) += classmate-laptop.o
9obj-$(CONFIG_COMPAL_LAPTOP) += compal-laptop.o 10obj-$(CONFIG_COMPAL_LAPTOP) += compal-laptop.o
diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
index cbca40aa400..1ea6c434d33 100644
--- a/drivers/platform/x86/acer-wmi.c
+++ b/drivers/platform/x86/acer-wmi.c
@@ -36,6 +36,7 @@
36#include <linux/rfkill.h> 36#include <linux/rfkill.h>
37#include <linux/workqueue.h> 37#include <linux/workqueue.h>
38#include <linux/debugfs.h> 38#include <linux/debugfs.h>
39#include <linux/slab.h>
39 40
40#include <acpi/acpi_drivers.h> 41#include <acpi/acpi_drivers.h>
41 42
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
index db5f7db2ba3..efe8f638890 100644
--- a/drivers/platform/x86/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
@@ -49,6 +49,7 @@
49#include <linux/input.h> 49#include <linux/input.h>
50#include <linux/input/sparse-keymap.h> 50#include <linux/input/sparse-keymap.h>
51#include <linux/rfkill.h> 51#include <linux/rfkill.h>
52#include <linux/slab.h>
52#include <acpi/acpi_drivers.h> 53#include <acpi/acpi_drivers.h>
53#include <acpi/acpi_bus.h> 54#include <acpi/acpi_bus.h>
54 55
@@ -78,15 +79,15 @@ static uint wapf = 1;
78module_param(wapf, uint, 0644); 79module_param(wapf, uint, 0644);
79MODULE_PARM_DESC(wapf, "WAPF value"); 80MODULE_PARM_DESC(wapf, "WAPF value");
80 81
81static uint wlan_status = 1; 82static int wlan_status = 1;
82static uint bluetooth_status = 1; 83static int bluetooth_status = 1;
83 84
84module_param(wlan_status, uint, 0644); 85module_param(wlan_status, int, 0644);
85MODULE_PARM_DESC(wlan_status, "Set the wireless status on boot " 86MODULE_PARM_DESC(wlan_status, "Set the wireless status on boot "
86 "(0 = disabled, 1 = enabled, -1 = don't do anything). " 87 "(0 = disabled, 1 = enabled, -1 = don't do anything). "
87 "default is 1"); 88 "default is 1");
88 89
89module_param(bluetooth_status, uint, 0644); 90module_param(bluetooth_status, int, 0644);
90MODULE_PARM_DESC(bluetooth_status, "Set the wireless status on boot " 91MODULE_PARM_DESC(bluetooth_status, "Set the wireless status on boot "
91 "(0 = disabled, 1 = enabled, -1 = don't do anything). " 92 "(0 = disabled, 1 = enabled, -1 = don't do anything). "
92 "default is 1"); 93 "default is 1");
@@ -139,7 +140,7 @@ MODULE_PARM_DESC(bluetooth_status, "Set the wireless status on boot "
139 140
140/* Backlight */ 141/* Backlight */
141static acpi_handle lcd_switch_handle; 142static acpi_handle lcd_switch_handle;
142static const char *lcd_switch_paths[] = { 143static char *lcd_switch_paths[] = {
143 "\\_SB.PCI0.SBRG.EC0._Q10", /* All new models */ 144 "\\_SB.PCI0.SBRG.EC0._Q10", /* All new models */
144 "\\_SB.PCI0.ISA.EC0._Q10", /* A1x */ 145 "\\_SB.PCI0.ISA.EC0._Q10", /* A1x */
145 "\\_SB.PCI0.PX40.ECD0._Q10", /* L3C */ 146 "\\_SB.PCI0.PX40.ECD0._Q10", /* L3C */
@@ -153,7 +154,7 @@ static const char *lcd_switch_paths[] = {
153#define METHOD_SWITCH_DISPLAY "SDSP" 154#define METHOD_SWITCH_DISPLAY "SDSP"
154 155
155static acpi_handle display_get_handle; 156static acpi_handle display_get_handle;
156static const char *display_get_paths[] = { 157static char *display_get_paths[] = {
157 /* A6B, A6K A6R A7D F3JM L4R M6R A3G M6A M6V VX-1 V6J V6V W3Z */ 158 /* A6B, A6K A6R A7D F3JM L4R M6R A3G M6A M6V VX-1 V6J V6V W3Z */
158 "\\_SB.PCI0.P0P1.VGA.GETD", 159 "\\_SB.PCI0.P0P1.VGA.GETD",
159 /* A3E A4K, A4D A4L A6J A7J A8J Z71V M9V S5A M5A z33A W1Jc W2V G1 */ 160 /* A3E A4K, A4D A4L A6J A7J A8J Z71V M9V S5A M5A z33A W1Jc W2V G1 */
diff --git a/drivers/platform/x86/asus_acpi.c b/drivers/platform/x86/asus_acpi.c
index ee520357aba..92fd30c9379 100644
--- a/drivers/platform/x86/asus_acpi.c
+++ b/drivers/platform/x86/asus_acpi.c
@@ -32,6 +32,7 @@
32 32
33#include <linux/kernel.h> 33#include <linux/kernel.h>
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/slab.h>
35#include <linux/init.h> 36#include <linux/init.h>
36#include <linux/types.h> 37#include <linux/types.h>
37#include <linux/proc_fs.h> 38#include <linux/proc_fs.h>
diff --git a/drivers/platform/x86/classmate-laptop.c b/drivers/platform/x86/classmate-laptop.c
index c696cf1c261..7f9e5ddc949 100644
--- a/drivers/platform/x86/classmate-laptop.c
+++ b/drivers/platform/x86/classmate-laptop.c
@@ -19,6 +19,7 @@
19 19
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/slab.h>
22#include <linux/workqueue.h> 23#include <linux/workqueue.h>
23#include <acpi/acpi_drivers.h> 24#include <acpi/acpi_drivers.h>
24#include <linux/backlight.h> 25#include <linux/backlight.h>
diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c
index 46435ac4684..661e3ac4d5b 100644
--- a/drivers/platform/x86/dell-laptop.c
+++ b/drivers/platform/x86/dell-laptop.c
@@ -24,6 +24,7 @@
24#include <linux/acpi.h> 24#include <linux/acpi.h>
25#include <linux/mm.h> 25#include <linux/mm.h>
26#include <linux/i8042.h> 26#include <linux/i8042.h>
27#include <linux/slab.h>
27#include "../../firmware/dcdbas.h" 28#include "../../firmware/dcdbas.h"
28 29
29#define BRIGHTNESS_TOKEN 0x7d 30#define BRIGHTNESS_TOKEN 0x7d
diff --git a/drivers/platform/x86/dell-wmi.c b/drivers/platform/x86/dell-wmi.c
index bed764e3ea2..66f53c3c35e 100644
--- a/drivers/platform/x86/dell-wmi.c
+++ b/drivers/platform/x86/dell-wmi.c
@@ -26,6 +26,7 @@
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/slab.h>
29#include <linux/types.h> 30#include <linux/types.h>
30#include <linux/input.h> 31#include <linux/input.h>
31#include <acpi/acpi_drivers.h> 32#include <acpi/acpi_drivers.h>
@@ -216,6 +217,7 @@ static void dell_wmi_notify(u32 value, void *context)
216 if (dell_new_hk_type && (buffer_entry[1] != 0x10)) { 217 if (dell_new_hk_type && (buffer_entry[1] != 0x10)) {
217 printk(KERN_INFO "dell-wmi: Received unknown WMI event" 218 printk(KERN_INFO "dell-wmi: Received unknown WMI event"
218 " (0x%x)\n", buffer_entry[1]); 219 " (0x%x)\n", buffer_entry[1]);
220 kfree(obj);
219 return; 221 return;
220 } 222 }
221 223
@@ -233,7 +235,7 @@ static void dell_wmi_notify(u32 value, void *context)
233 key->keycode == KEY_BRIGHTNESSDOWN) && acpi_video) { 235 key->keycode == KEY_BRIGHTNESSDOWN) && acpi_video) {
234 /* Don't report brightness notifications that will also 236 /* Don't report brightness notifications that will also
235 * come via ACPI */ 237 * come via ACPI */
236 return; 238 ;
237 } else { 239 } else {
238 input_report_key(dell_wmi_input_dev, key->keycode, 1); 240 input_report_key(dell_wmi_input_dev, key->keycode, 1);
239 input_sync(dell_wmi_input_dev); 241 input_sync(dell_wmi_input_dev);
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index 3fdf21e0052..0306174ba87 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -27,6 +27,7 @@
27#include <linux/fb.h> 27#include <linux/fb.h>
28#include <linux/hwmon.h> 28#include <linux/hwmon.h>
29#include <linux/hwmon-sysfs.h> 29#include <linux/hwmon-sysfs.h>
30#include <linux/slab.h>
30#include <acpi/acpi_drivers.h> 31#include <acpi/acpi_drivers.h>
31#include <acpi/acpi_bus.h> 32#include <acpi/acpi_bus.h>
32#include <linux/uaccess.h> 33#include <linux/uaccess.h>
@@ -168,7 +169,6 @@ struct eeepc_laptop {
168 struct backlight_device *backlight_device; 169 struct backlight_device *backlight_device;
169 170
170 struct input_dev *inputdev; 171 struct input_dev *inputdev;
171 struct key_entry *keymap;
172 172
173 struct rfkill *wlan_rfkill; 173 struct rfkill *wlan_rfkill;
174 struct rfkill *bluetooth_rfkill; 174 struct rfkill *bluetooth_rfkill;
@@ -1203,8 +1203,8 @@ static int eeepc_input_init(struct eeepc_laptop *eeepc)
1203static void eeepc_input_exit(struct eeepc_laptop *eeepc) 1203static void eeepc_input_exit(struct eeepc_laptop *eeepc)
1204{ 1204{
1205 if (eeepc->inputdev) { 1205 if (eeepc->inputdev) {
1206 sparse_keymap_free(eeepc->inputdev);
1206 input_unregister_device(eeepc->inputdev); 1207 input_unregister_device(eeepc->inputdev);
1207 kfree(eeepc->keymap);
1208 } 1208 }
1209} 1209}
1210 1210
diff --git a/drivers/platform/x86/eeepc-wmi.c b/drivers/platform/x86/eeepc-wmi.c
new file mode 100644
index 00000000000..b227eb469f4
--- /dev/null
+++ b/drivers/platform/x86/eeepc-wmi.c
@@ -0,0 +1,413 @@
1/*
2 * Eee PC WMI hotkey driver
3 *
4 * Copyright(C) 2010 Intel Corporation.
5 *
6 * Portions based on wistron_btns.c:
7 * Copyright (C) 2005 Miloslav Trmac <mitr@volny.cz>
8 * Copyright (C) 2005 Bernhard Rosenkraenzer <bero@arklinux.org>
9 * Copyright (C) 2005 Dmitry Torokhov <dtor@mail.ru>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
27
28#include <linux/kernel.h>
29#include <linux/module.h>
30#include <linux/init.h>
31#include <linux/types.h>
32#include <linux/slab.h>
33#include <linux/input.h>
34#include <linux/input/sparse-keymap.h>
35#include <linux/fb.h>
36#include <linux/backlight.h>
37#include <linux/platform_device.h>
38#include <acpi/acpi_bus.h>
39#include <acpi/acpi_drivers.h>
40
41#define EEEPC_WMI_FILE "eeepc-wmi"
42
43MODULE_AUTHOR("Yong Wang <yong.y.wang@intel.com>");
44MODULE_DESCRIPTION("Eee PC WMI Hotkey Driver");
45MODULE_LICENSE("GPL");
46
47#define EEEPC_WMI_EVENT_GUID "ABBC0F72-8EA1-11D1-00A0-C90629100000"
48#define EEEPC_WMI_MGMT_GUID "97845ED0-4E6D-11DE-8A39-0800200C9A66"
49
50MODULE_ALIAS("wmi:"EEEPC_WMI_EVENT_GUID);
51MODULE_ALIAS("wmi:"EEEPC_WMI_MGMT_GUID);
52
53#define NOTIFY_BRNUP_MIN 0x11
54#define NOTIFY_BRNUP_MAX 0x1f
55#define NOTIFY_BRNDOWN_MIN 0x20
56#define NOTIFY_BRNDOWN_MAX 0x2e
57
58#define EEEPC_WMI_METHODID_DEVS 0x53564544
59#define EEEPC_WMI_METHODID_DSTS 0x53544344
60
61#define EEEPC_WMI_DEVID_BACKLIGHT 0x00050012
62
63static const struct key_entry eeepc_wmi_keymap[] = {
64 /* Sleep already handled via generic ACPI code */
65 { KE_KEY, 0x5d, { KEY_WLAN } },
66 { KE_KEY, 0x32, { KEY_MUTE } },
67 { KE_KEY, 0x31, { KEY_VOLUMEDOWN } },
68 { KE_KEY, 0x30, { KEY_VOLUMEUP } },
69 { KE_IGNORE, NOTIFY_BRNDOWN_MIN, { KEY_BRIGHTNESSDOWN } },
70 { KE_IGNORE, NOTIFY_BRNUP_MIN, { KEY_BRIGHTNESSUP } },
71 { KE_KEY, 0xcc, { KEY_SWITCHVIDEOMODE } },
72 { KE_END, 0},
73};
74
75struct bios_args {
76 u32 dev_id;
77 u32 ctrl_param;
78};
79
80struct eeepc_wmi {
81 struct input_dev *inputdev;
82 struct backlight_device *backlight_device;
83};
84
85static struct platform_device *platform_device;
86
87static int eeepc_wmi_input_init(struct eeepc_wmi *eeepc)
88{
89 int err;
90
91 eeepc->inputdev = input_allocate_device();
92 if (!eeepc->inputdev)
93 return -ENOMEM;
94
95 eeepc->inputdev->name = "Eee PC WMI hotkeys";
96 eeepc->inputdev->phys = EEEPC_WMI_FILE "/input0";
97 eeepc->inputdev->id.bustype = BUS_HOST;
98 eeepc->inputdev->dev.parent = &platform_device->dev;
99
100 err = sparse_keymap_setup(eeepc->inputdev, eeepc_wmi_keymap, NULL);
101 if (err)
102 goto err_free_dev;
103
104 err = input_register_device(eeepc->inputdev);
105 if (err)
106 goto err_free_keymap;
107
108 return 0;
109
110err_free_keymap:
111 sparse_keymap_free(eeepc->inputdev);
112err_free_dev:
113 input_free_device(eeepc->inputdev);
114 return err;
115}
116
117static void eeepc_wmi_input_exit(struct eeepc_wmi *eeepc)
118{
119 if (eeepc->inputdev) {
120 sparse_keymap_free(eeepc->inputdev);
121 input_unregister_device(eeepc->inputdev);
122 }
123
124 eeepc->inputdev = NULL;
125}
126
127static acpi_status eeepc_wmi_get_devstate(u32 dev_id, u32 *ctrl_param)
128{
129 struct acpi_buffer input = { (acpi_size)sizeof(u32), &dev_id };
130 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
131 union acpi_object *obj;
132 acpi_status status;
133 u32 tmp;
134
135 status = wmi_evaluate_method(EEEPC_WMI_MGMT_GUID,
136 1, EEEPC_WMI_METHODID_DSTS, &input, &output);
137
138 if (ACPI_FAILURE(status))
139 return status;
140
141 obj = (union acpi_object *)output.pointer;
142 if (obj && obj->type == ACPI_TYPE_INTEGER)
143 tmp = (u32)obj->integer.value;
144 else
145 tmp = 0;
146
147 if (ctrl_param)
148 *ctrl_param = tmp;
149
150 kfree(obj);
151
152 return status;
153
154}
155
156static acpi_status eeepc_wmi_set_devstate(u32 dev_id, u32 ctrl_param)
157{
158 struct bios_args args = {
159 .dev_id = dev_id,
160 .ctrl_param = ctrl_param,
161 };
162 struct acpi_buffer input = { (acpi_size)sizeof(args), &args };
163 acpi_status status;
164
165 status = wmi_evaluate_method(EEEPC_WMI_MGMT_GUID,
166 1, EEEPC_WMI_METHODID_DEVS, &input, NULL);
167
168 return status;
169}
170
171static int read_brightness(struct backlight_device *bd)
172{
173 static u32 ctrl_param;
174 acpi_status status;
175
176 status = eeepc_wmi_get_devstate(EEEPC_WMI_DEVID_BACKLIGHT, &ctrl_param);
177
178 if (ACPI_FAILURE(status))
179 return -1;
180 else
181 return ctrl_param & 0xFF;
182}
183
184static int update_bl_status(struct backlight_device *bd)
185{
186
187 static u32 ctrl_param;
188 acpi_status status;
189
190 ctrl_param = bd->props.brightness;
191
192 status = eeepc_wmi_set_devstate(EEEPC_WMI_DEVID_BACKLIGHT, ctrl_param);
193
194 if (ACPI_FAILURE(status))
195 return -1;
196 else
197 return 0;
198}
199
200static const struct backlight_ops eeepc_wmi_bl_ops = {
201 .get_brightness = read_brightness,
202 .update_status = update_bl_status,
203};
204
205static int eeepc_wmi_backlight_notify(struct eeepc_wmi *eeepc, int code)
206{
207 struct backlight_device *bd = eeepc->backlight_device;
208 int old = bd->props.brightness;
209 int new;
210
211 if (code >= NOTIFY_BRNUP_MIN && code <= NOTIFY_BRNUP_MAX)
212 new = code - NOTIFY_BRNUP_MIN + 1;
213 else if (code >= NOTIFY_BRNDOWN_MIN && code <= NOTIFY_BRNDOWN_MAX)
214 new = code - NOTIFY_BRNDOWN_MIN;
215
216 bd->props.brightness = new;
217 backlight_update_status(bd);
218 backlight_force_update(bd, BACKLIGHT_UPDATE_HOTKEY);
219
220 return old;
221}
222
223static int eeepc_wmi_backlight_init(struct eeepc_wmi *eeepc)
224{
225 struct backlight_device *bd;
226 struct backlight_properties props;
227
228 memset(&props, 0, sizeof(struct backlight_properties));
229 props.max_brightness = 15;
230 bd = backlight_device_register(EEEPC_WMI_FILE,
231 &platform_device->dev, eeepc,
232 &eeepc_wmi_bl_ops, &props);
233 if (IS_ERR(bd)) {
234 pr_err("Could not register backlight device\n");
235 return PTR_ERR(bd);
236 }
237
238 eeepc->backlight_device = bd;
239
240 bd->props.brightness = read_brightness(bd);
241 bd->props.power = FB_BLANK_UNBLANK;
242 backlight_update_status(bd);
243
244 return 0;
245}
246
247static void eeepc_wmi_backlight_exit(struct eeepc_wmi *eeepc)
248{
249 if (eeepc->backlight_device)
250 backlight_device_unregister(eeepc->backlight_device);
251
252 eeepc->backlight_device = NULL;
253}
254
255static void eeepc_wmi_notify(u32 value, void *context)
256{
257 struct eeepc_wmi *eeepc = context;
258 struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
259 union acpi_object *obj;
260 acpi_status status;
261 int code;
262 int orig_code;
263
264 status = wmi_get_event_data(value, &response);
265 if (status != AE_OK) {
266 pr_err("bad event status 0x%x\n", status);
267 return;
268 }
269
270 obj = (union acpi_object *)response.pointer;
271
272 if (obj && obj->type == ACPI_TYPE_INTEGER) {
273 code = obj->integer.value;
274 orig_code = code;
275
276 if (code >= NOTIFY_BRNUP_MIN && code <= NOTIFY_BRNUP_MAX)
277 code = NOTIFY_BRNUP_MIN;
278 else if (code >= NOTIFY_BRNDOWN_MIN &&
279 code <= NOTIFY_BRNDOWN_MAX)
280 code = NOTIFY_BRNDOWN_MIN;
281
282 if (code == NOTIFY_BRNUP_MIN || code == NOTIFY_BRNDOWN_MIN) {
283 if (!acpi_video_backlight_support())
284 eeepc_wmi_backlight_notify(eeepc, orig_code);
285 }
286
287 if (!sparse_keymap_report_event(eeepc->inputdev,
288 code, 1, true))
289 pr_info("Unknown key %x pressed\n", code);
290 }
291
292 kfree(obj);
293}
294
295static int __devinit eeepc_wmi_platform_probe(struct platform_device *device)
296{
297 struct eeepc_wmi *eeepc;
298 int err;
299 acpi_status status;
300
301 eeepc = platform_get_drvdata(device);
302
303 err = eeepc_wmi_input_init(eeepc);
304 if (err)
305 goto error_input;
306
307 if (!acpi_video_backlight_support()) {
308 err = eeepc_wmi_backlight_init(eeepc);
309 if (err)
310 goto error_backlight;
311 } else
312 pr_info("Backlight controlled by ACPI video driver\n");
313
314 status = wmi_install_notify_handler(EEEPC_WMI_EVENT_GUID,
315 eeepc_wmi_notify, eeepc);
316 if (ACPI_FAILURE(status)) {
317 pr_err("Unable to register notify handler - %d\n",
318 status);
319 err = -ENODEV;
320 goto error_wmi;
321 }
322
323 return 0;
324
325error_wmi:
326 eeepc_wmi_backlight_exit(eeepc);
327error_backlight:
328 eeepc_wmi_input_exit(eeepc);
329error_input:
330 return err;
331}
332
333static int __devexit eeepc_wmi_platform_remove(struct platform_device *device)
334{
335 struct eeepc_wmi *eeepc;
336
337 eeepc = platform_get_drvdata(device);
338 wmi_remove_notify_handler(EEEPC_WMI_EVENT_GUID);
339 eeepc_wmi_backlight_exit(eeepc);
340 eeepc_wmi_input_exit(eeepc);
341
342 return 0;
343}
344
345static struct platform_driver platform_driver = {
346 .driver = {
347 .name = EEEPC_WMI_FILE,
348 .owner = THIS_MODULE,
349 },
350 .probe = eeepc_wmi_platform_probe,
351 .remove = __devexit_p(eeepc_wmi_platform_remove),
352};
353
354static int __init eeepc_wmi_init(void)
355{
356 struct eeepc_wmi *eeepc;
357 int err;
358
359 if (!wmi_has_guid(EEEPC_WMI_EVENT_GUID) ||
360 !wmi_has_guid(EEEPC_WMI_MGMT_GUID)) {
361 pr_warning("No known WMI GUID found\n");
362 return -ENODEV;
363 }
364
365 eeepc = kzalloc(sizeof(struct eeepc_wmi), GFP_KERNEL);
366 if (!eeepc)
367 return -ENOMEM;
368
369 platform_device = platform_device_alloc(EEEPC_WMI_FILE, -1);
370 if (!platform_device) {
371 pr_warning("Unable to allocate platform device\n");
372 err = -ENOMEM;
373 goto fail_platform;
374 }
375
376 err = platform_device_add(platform_device);
377 if (err) {
378 pr_warning("Unable to add platform device\n");
379 goto put_dev;
380 }
381
382 platform_set_drvdata(platform_device, eeepc);
383
384 err = platform_driver_register(&platform_driver);
385 if (err) {
386 pr_warning("Unable to register platform driver\n");
387 goto del_dev;
388 }
389
390 return 0;
391
392del_dev:
393 platform_device_del(platform_device);
394put_dev:
395 platform_device_put(platform_device);
396fail_platform:
397 kfree(eeepc);
398
399 return err;
400}
401
402static void __exit eeepc_wmi_exit(void)
403{
404 struct eeepc_wmi *eeepc;
405
406 eeepc = platform_get_drvdata(platform_device);
407 platform_driver_unregister(&platform_driver);
408 platform_device_unregister(platform_device);
409 kfree(eeepc);
410}
411
412module_init(eeepc_wmi_init);
413module_exit(eeepc_wmi_exit);
diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index c1074b32490..47b4fd75aa3 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -66,6 +66,7 @@
66#include <linux/kfifo.h> 66#include <linux/kfifo.h>
67#include <linux/video_output.h> 67#include <linux/video_output.h>
68#include <linux/platform_device.h> 68#include <linux/platform_device.h>
69#include <linux/slab.h>
69#if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE) 70#if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
70#include <linux/leds.h> 71#include <linux/leds.h>
71#endif 72#endif
diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
index 56086363bec..51c07a05a7b 100644
--- a/drivers/platform/x86/hp-wmi.c
+++ b/drivers/platform/x86/hp-wmi.c
@@ -26,6 +26,7 @@
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/slab.h>
29#include <linux/types.h> 30#include <linux/types.h>
30#include <linux/input.h> 31#include <linux/input.h>
31#include <acpi/acpi_drivers.h> 32#include <acpi/acpi_drivers.h>
diff --git a/drivers/platform/x86/intel_menlow.c b/drivers/platform/x86/intel_menlow.c
index f0a90a6bf39..2f795ce2b93 100644
--- a/drivers/platform/x86/intel_menlow.c
+++ b/drivers/platform/x86/intel_menlow.c
@@ -30,6 +30,7 @@
30#include <linux/kernel.h> 30#include <linux/kernel.h>
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/slab.h>
33#include <linux/types.h> 34#include <linux/types.h>
34#include <linux/pci.h> 35#include <linux/pci.h>
35#include <linux/pm.h> 36#include <linux/pm.h>
@@ -396,6 +397,7 @@ static int intel_menlow_add_one_attribute(char *name, int mode, void *show,
396 if (!attr) 397 if (!attr)
397 return -ENOMEM; 398 return -ENOMEM;
398 399
400 sysfs_attr_init(&attr->attr.attr); /* That is consistent naming :D */
399 attr->attr.attr.name = name; 401 attr->attr.attr.name = name;
400 attr->attr.attr.mode = mode; 402 attr->attr.attr.mode = mode;
401 attr->attr.show = show; 403 attr->attr.show = show;
diff --git a/drivers/platform/x86/msi-wmi.c b/drivers/platform/x86/msi-wmi.c
index 367caaae2f3..d1736009636 100644
--- a/drivers/platform/x86/msi-wmi.c
+++ b/drivers/platform/x86/msi-wmi.c
@@ -26,6 +26,7 @@
26#include <linux/input/sparse-keymap.h> 26#include <linux/input/sparse-keymap.h>
27#include <linux/acpi.h> 27#include <linux/acpi.h>
28#include <linux/backlight.h> 28#include <linux/backlight.h>
29#include <linux/slab.h>
29 30
30MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>"); 31MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
31MODULE_DESCRIPTION("MSI laptop WMI hotkeys driver"); 32MODULE_DESCRIPTION("MSI laptop WMI hotkeys driver");
diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c
index 726f02affcb..2fb9a32926f 100644
--- a/drivers/platform/x86/panasonic-laptop.c
+++ b/drivers/platform/x86/panasonic-laptop.c
@@ -124,6 +124,7 @@
124#include <linux/ctype.h> 124#include <linux/ctype.h>
125#include <linux/seq_file.h> 125#include <linux/seq_file.h>
126#include <linux/uaccess.h> 126#include <linux/uaccess.h>
127#include <linux/slab.h>
127#include <acpi/acpi_bus.h> 128#include <acpi/acpi_bus.h>
128#include <acpi/acpi_drivers.h> 129#include <acpi/acpi_drivers.h>
129#include <linux/input.h> 130#include <linux/input.h>
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index 6553b91caaa..1387c5f9c24 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -58,6 +58,7 @@
58#include <linux/kfifo.h> 58#include <linux/kfifo.h>
59#include <linux/workqueue.h> 59#include <linux/workqueue.h>
60#include <linux/acpi.h> 60#include <linux/acpi.h>
61#include <linux/slab.h>
61#include <acpi/acpi_drivers.h> 62#include <acpi/acpi_drivers.h>
62#include <acpi/acpi_bus.h> 63#include <acpi/acpi_bus.h>
63#include <asm/uaccess.h> 64#include <asm/uaccess.h>
diff --git a/drivers/platform/x86/tc1100-wmi.c b/drivers/platform/x86/tc1100-wmi.c
index dd33b51c348..1fe0f1feff7 100644
--- a/drivers/platform/x86/tc1100-wmi.c
+++ b/drivers/platform/x86/tc1100-wmi.c
@@ -27,6 +27,7 @@
27 27
28#include <linux/kernel.h> 28#include <linux/kernel.h>
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/slab.h>
30#include <linux/init.h> 31#include <linux/init.h>
31#include <linux/types.h> 32#include <linux/types.h>
32#include <acpi/acpi.h> 33#include <acpi/acpi.h>
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 770b85327f8..63290b33c87 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -58,6 +58,7 @@
58#include <linux/kthread.h> 58#include <linux/kthread.h>
59#include <linux/freezer.h> 59#include <linux/freezer.h>
60#include <linux/delay.h> 60#include <linux/delay.h>
61#include <linux/slab.h>
61 62
62#include <linux/nvram.h> 63#include <linux/nvram.h>
63#include <linux/proc_fs.h> 64#include <linux/proc_fs.h>
diff --git a/drivers/platform/x86/topstar-laptop.c b/drivers/platform/x86/topstar-laptop.c
index 4d6516fded7..ff4b476f195 100644
--- a/drivers/platform/x86/topstar-laptop.c
+++ b/drivers/platform/x86/topstar-laptop.c
@@ -16,6 +16,7 @@
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/slab.h>
19#include <linux/acpi.h> 20#include <linux/acpi.h>
20#include <linux/input.h> 21#include <linux/input.h>
21 22
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index def4841183b..37aa1479855 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -47,6 +47,7 @@
47#include <linux/platform_device.h> 47#include <linux/platform_device.h>
48#include <linux/rfkill.h> 48#include <linux/rfkill.h>
49#include <linux/input.h> 49#include <linux/input.h>
50#include <linux/slab.h>
50 51
51#include <asm/uaccess.h> 52#include <asm/uaccess.h>
52 53
diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index 09e9918c69c..39ec5b6c2e3 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -33,6 +33,7 @@
33#include <linux/device.h> 33#include <linux/device.h>
34#include <linux/list.h> 34#include <linux/list.h>
35#include <linux/acpi.h> 35#include <linux/acpi.h>
36#include <linux/slab.h>
36#include <acpi/acpi_bus.h> 37#include <acpi/acpi_bus.h>
37#include <acpi/acpi_drivers.h> 38#include <acpi/acpi_drivers.h>
38 39
diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
index e851160e14f..918d5f04486 100644
--- a/drivers/pnp/isapnp/core.c
+++ b/drivers/pnp/isapnp/core.c
@@ -37,7 +37,6 @@
37#include <linux/module.h> 37#include <linux/module.h>
38#include <linux/kernel.h> 38#include <linux/kernel.h>
39#include <linux/errno.h> 39#include <linux/errno.h>
40#include <linux/slab.h>
41#include <linux/delay.h> 40#include <linux/delay.h>
42#include <linux/init.h> 41#include <linux/init.h>
43#include <linux/isapnp.h> 42#include <linux/isapnp.h>
diff --git a/drivers/pnp/manager.c b/drivers/pnp/manager.c
index 00fd3577b98..0a15664eef1 100644
--- a/drivers/pnp/manager.c
+++ b/drivers/pnp/manager.c
@@ -12,7 +12,6 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/pnp.h> 14#include <linux/pnp.h>
15#include <linux/slab.h>
16#include <linux/bitmap.h> 15#include <linux/bitmap.h>
17#include <linux/mutex.h> 16#include <linux/mutex.h>
18#include "base.h" 17#include "base.h"
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index 5314bf630bc..f7ff628b7d9 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -21,6 +21,7 @@
21 21
22#include <linux/acpi.h> 22#include <linux/acpi.h>
23#include <linux/pnp.h> 23#include <linux/pnp.h>
24#include <linux/slab.h>
24#include <linux/mod_devicetable.h> 25#include <linux/mod_devicetable.h>
25#include <acpi/acpi_bus.h> 26#include <acpi/acpi_bus.h>
26 27
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index 54514aa35b0..100e4d9372f 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -24,6 +24,7 @@
24#include <linux/acpi.h> 24#include <linux/acpi.h>
25#include <linux/pci.h> 25#include <linux/pci.h>
26#include <linux/pnp.h> 26#include <linux/pnp.h>
27#include <linux/slab.h>
27#include "../base.h" 28#include "../base.h"
28#include "pnpacpi.h" 29#include "pnpacpi.h"
29 30
@@ -279,6 +280,7 @@ static void pnpacpi_parse_allocated_address_space(struct pnp_dev *dev,
279 struct acpi_resource_address64 addr, *p = &addr; 280 struct acpi_resource_address64 addr, *p = &addr;
280 acpi_status status; 281 acpi_status status;
281 int window; 282 int window;
283 u64 len;
282 284
283 status = acpi_resource_to_address64(res, p); 285 status = acpi_resource_to_address64(res, p);
284 if (!ACPI_SUCCESS(status)) { 286 if (!ACPI_SUCCESS(status)) {
@@ -287,20 +289,19 @@ static void pnpacpi_parse_allocated_address_space(struct pnp_dev *dev,
287 return; 289 return;
288 } 290 }
289 291
292 /* Windows apparently computes length rather than using _LEN */
293 len = p->maximum - p->minimum + 1;
290 window = (p->producer_consumer == ACPI_PRODUCER) ? 1 : 0; 294 window = (p->producer_consumer == ACPI_PRODUCER) ? 1 : 0;
291 295
292 if (p->resource_type == ACPI_MEMORY_RANGE) 296 if (p->resource_type == ACPI_MEMORY_RANGE)
293 pnpacpi_parse_allocated_memresource(dev, 297 pnpacpi_parse_allocated_memresource(dev, p->minimum, len,
294 p->minimum, p->address_length,
295 p->info.mem.write_protect, window); 298 p->info.mem.write_protect, window);
296 else if (p->resource_type == ACPI_IO_RANGE) 299 else if (p->resource_type == ACPI_IO_RANGE)
297 pnpacpi_parse_allocated_ioresource(dev, 300 pnpacpi_parse_allocated_ioresource(dev, p->minimum, len,
298 p->minimum, p->address_length,
299 p->granularity == 0xfff ? ACPI_DECODE_10 : 301 p->granularity == 0xfff ? ACPI_DECODE_10 :
300 ACPI_DECODE_16, window); 302 ACPI_DECODE_16, window);
301 else if (p->resource_type == ACPI_BUS_NUMBER_RANGE) 303 else if (p->resource_type == ACPI_BUS_NUMBER_RANGE)
302 pnpacpi_parse_allocated_busresource(dev, p->minimum, 304 pnpacpi_parse_allocated_busresource(dev, p->minimum, len);
303 p->address_length);
304} 305}
305 306
306static void pnpacpi_parse_allocated_ext_address_space(struct pnp_dev *dev, 307static void pnpacpi_parse_allocated_ext_address_space(struct pnp_dev *dev,
@@ -308,21 +309,21 @@ static void pnpacpi_parse_allocated_ext_address_space(struct pnp_dev *dev,
308{ 309{
309 struct acpi_resource_extended_address64 *p = &res->data.ext_address64; 310 struct acpi_resource_extended_address64 *p = &res->data.ext_address64;
310 int window; 311 int window;
312 u64 len;
311 313
314 /* Windows apparently computes length rather than using _LEN */
315 len = p->maximum - p->minimum + 1;
312 window = (p->producer_consumer == ACPI_PRODUCER) ? 1 : 0; 316 window = (p->producer_consumer == ACPI_PRODUCER) ? 1 : 0;
313 317
314 if (p->resource_type == ACPI_MEMORY_RANGE) 318 if (p->resource_type == ACPI_MEMORY_RANGE)
315 pnpacpi_parse_allocated_memresource(dev, 319 pnpacpi_parse_allocated_memresource(dev, p->minimum, len,
316 p->minimum, p->address_length,
317 p->info.mem.write_protect, window); 320 p->info.mem.write_protect, window);
318 else if (p->resource_type == ACPI_IO_RANGE) 321 else if (p->resource_type == ACPI_IO_RANGE)
319 pnpacpi_parse_allocated_ioresource(dev, 322 pnpacpi_parse_allocated_ioresource(dev, p->minimum, len,
320 p->minimum, p->address_length,
321 p->granularity == 0xfff ? ACPI_DECODE_10 : 323 p->granularity == 0xfff ? ACPI_DECODE_10 :
322 ACPI_DECODE_16, window); 324 ACPI_DECODE_16, window);
323 else if (p->resource_type == ACPI_BUS_NUMBER_RANGE) 325 else if (p->resource_type == ACPI_BUS_NUMBER_RANGE)
324 pnpacpi_parse_allocated_busresource(dev, p->minimum, 326 pnpacpi_parse_allocated_busresource(dev, p->minimum, len);
325 p->address_length);
326} 327}
327 328
328static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, 329static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
index fc83783c3a9..8591f6ab1b3 100644
--- a/drivers/pnp/pnpbios/bioscalls.c
+++ b/drivers/pnp/pnpbios/bioscalls.c
@@ -11,7 +11,6 @@
11#include <linux/pnp.h> 11#include <linux/pnp.h>
12#include <linux/mm.h> 12#include <linux/mm.h>
13#include <linux/smp.h> 13#include <linux/smp.h>
14#include <linux/slab.h>
15#include <linux/kmod.h> 14#include <linux/kmod.h>
16#include <linux/completion.h> 15#include <linux/completion.h>
17#include <linux/spinlock.h> 16#include <linux/spinlock.h>
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c
index a5135ebe5f0..cb1f47bfee9 100644
--- a/drivers/pnp/pnpbios/rsparser.c
+++ b/drivers/pnp/pnpbios/rsparser.c
@@ -5,7 +5,6 @@
5#include <linux/ctype.h> 5#include <linux/ctype.h>
6#include <linux/pnp.h> 6#include <linux/pnp.h>
7#include <linux/string.h> 7#include <linux/string.h>
8#include <linux/slab.h>
9 8
10#ifdef CONFIG_PCI 9#ifdef CONFIG_PCI
11#include <linux/pci.h> 10#include <linux/pci.h>
diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
index 5b277dbaacd..e3446ab8b56 100644
--- a/drivers/pnp/resource.c
+++ b/drivers/pnp/resource.c
@@ -8,6 +8,7 @@
8 */ 8 */
9 9
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/slab.h>
11#include <linux/errno.h> 12#include <linux/errno.h>
12#include <linux/interrupt.h> 13#include <linux/interrupt.h>
13#include <linux/kernel.h> 14#include <linux/kernel.h>
@@ -210,6 +211,8 @@ int pnp_check_port(struct pnp_dev *dev, struct resource *res)
210 if (tres->flags & IORESOURCE_IO) { 211 if (tres->flags & IORESOURCE_IO) {
211 if (cannot_compare(tres->flags)) 212 if (cannot_compare(tres->flags))
212 continue; 213 continue;
214 if (tres->flags & IORESOURCE_WINDOW)
215 continue;
213 tport = &tres->start; 216 tport = &tres->start;
214 tend = &tres->end; 217 tend = &tres->end;
215 if (ranged_conflict(port, end, tport, tend)) 218 if (ranged_conflict(port, end, tport, tend))
@@ -270,6 +273,8 @@ int pnp_check_mem(struct pnp_dev *dev, struct resource *res)
270 if (tres->flags & IORESOURCE_MEM) { 273 if (tres->flags & IORESOURCE_MEM) {
271 if (cannot_compare(tres->flags)) 274 if (cannot_compare(tres->flags))
272 continue; 275 continue;
276 if (tres->flags & IORESOURCE_WINDOW)
277 continue;
273 taddr = &tres->start; 278 taddr = &tres->start;
274 tend = &tres->end; 279 tend = &tres->end;
275 if (ranged_conflict(addr, end, taddr, tend)) 280 if (ranged_conflict(addr, end, taddr, tend))
diff --git a/drivers/power/bq27x00_battery.c b/drivers/power/bq27x00_battery.c
index bece33ed873..3ec9c6a8896 100644
--- a/drivers/power/bq27x00_battery.c
+++ b/drivers/power/bq27x00_battery.c
@@ -24,6 +24,7 @@
24#include <linux/power_supply.h> 24#include <linux/power_supply.h>
25#include <linux/idr.h> 25#include <linux/idr.h>
26#include <linux/i2c.h> 26#include <linux/i2c.h>
27#include <linux/slab.h>
27#include <asm/unaligned.h> 28#include <asm/unaligned.h>
28 29
29#define DRIVER_VERSION "1.1.0" 30#define DRIVER_VERSION "1.1.0"
diff --git a/drivers/power/da9030_battery.c b/drivers/power/da9030_battery.c
index a2e71f7b27f..d2c793cf676 100644
--- a/drivers/power/da9030_battery.c
+++ b/drivers/power/da9030_battery.c
@@ -10,6 +10,7 @@
10 */ 10 */
11 11
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/slab.h>
13#include <linux/init.h> 14#include <linux/init.h>
14#include <linux/types.h> 15#include <linux/types.h>
15#include <linux/device.h> 16#include <linux/device.h>
diff --git a/drivers/power/ds2760_battery.c b/drivers/power/ds2760_battery.c
index 6f1dba5a519..3bf8d1f622e 100644
--- a/drivers/power/ds2760_battery.c
+++ b/drivers/power/ds2760_battery.c
@@ -24,6 +24,7 @@
24#include <linux/jiffies.h> 24#include <linux/jiffies.h>
25#include <linux/workqueue.h> 25#include <linux/workqueue.h>
26#include <linux/pm.h> 26#include <linux/pm.h>
27#include <linux/slab.h>
27#include <linux/platform_device.h> 28#include <linux/platform_device.h>
28#include <linux/power_supply.h> 29#include <linux/power_supply.h>
29 30
diff --git a/drivers/power/ds2782_battery.c b/drivers/power/ds2782_battery.c
index da14f374cb6..99c89976a90 100644
--- a/drivers/power/ds2782_battery.c
+++ b/drivers/power/ds2782_battery.c
@@ -19,6 +19,7 @@
19#include <linux/i2c.h> 19#include <linux/i2c.h>
20#include <linux/idr.h> 20#include <linux/idr.h>
21#include <linux/power_supply.h> 21#include <linux/power_supply.h>
22#include <linux/slab.h>
22 23
23#define DS2782_REG_RARC 0x06 /* Remaining active relative capacity */ 24#define DS2782_REG_RARC 0x06 /* Remaining active relative capacity */
24 25
diff --git a/drivers/power/max17040_battery.c b/drivers/power/max17040_battery.c
index 87b98bf27ae..f3e22c9fe20 100644
--- a/drivers/power/max17040_battery.c
+++ b/drivers/power/max17040_battery.c
@@ -19,6 +19,7 @@
19#include <linux/delay.h> 19#include <linux/delay.h>
20#include <linux/power_supply.h> 20#include <linux/power_supply.h>
21#include <linux/max17040_battery.h> 21#include <linux/max17040_battery.h>
22#include <linux/slab.h>
22 23
23#define MAX17040_VCELL_MSB 0x02 24#define MAX17040_VCELL_MSB 0x02
24#define MAX17040_VCELL_LSB 0x03 25#define MAX17040_VCELL_LSB 0x03
diff --git a/drivers/power/max8925_power.c b/drivers/power/max8925_power.c
index a1b4410544d..8e5aec26086 100644
--- a/drivers/power/max8925_power.c
+++ b/drivers/power/max8925_power.c
@@ -11,6 +11,7 @@
11 11
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/err.h> 13#include <linux/err.h>
14#include <linux/slab.h>
14#include <linux/i2c.h> 15#include <linux/i2c.h>
15#include <linux/interrupt.h> 16#include <linux/interrupt.h>
16#include <linux/platform_device.h> 17#include <linux/platform_device.h>
diff --git a/drivers/power/pcf50633-charger.c b/drivers/power/pcf50633-charger.c
index ea3fdfaca90..066f994e6fe 100644
--- a/drivers/power/pcf50633-charger.c
+++ b/drivers/power/pcf50633-charger.c
@@ -16,6 +16,7 @@
16 16
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/slab.h>
19#include <linux/init.h> 20#include <linux/init.h>
20#include <linux/types.h> 21#include <linux/types.h>
21#include <linux/device.h> 22#include <linux/device.h>
diff --git a/drivers/power/pmu_battery.c b/drivers/power/pmu_battery.c
index 9c87ad56480..023d24993b8 100644
--- a/drivers/power/pmu_battery.c
+++ b/drivers/power/pmu_battery.c
@@ -14,6 +14,7 @@
14#include <linux/power_supply.h> 14#include <linux/power_supply.h>
15#include <linux/adb.h> 15#include <linux/adb.h>
16#include <linux/pmu.h> 16#include <linux/pmu.h>
17#include <linux/slab.h>
17 18
18static struct pmu_battery_dev { 19static struct pmu_battery_dev {
19 struct power_supply bat; 20 struct power_supply bat;
diff --git a/drivers/power/power_supply_leds.c b/drivers/power/power_supply_leds.c
index 2dece40c544..031a554837f 100644
--- a/drivers/power/power_supply_leds.c
+++ b/drivers/power/power_supply_leds.c
@@ -12,6 +12,7 @@
12 12
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/power_supply.h> 14#include <linux/power_supply.h>
15#include <linux/slab.h>
15 16
16#include "power_supply.h" 17#include "power_supply.h"
17 18
diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
index ff05e618976..5b6e352ac7c 100644
--- a/drivers/power/power_supply_sysfs.c
+++ b/drivers/power/power_supply_sysfs.c
@@ -13,6 +13,7 @@
13 13
14#include <linux/ctype.h> 14#include <linux/ctype.h>
15#include <linux/power_supply.h> 15#include <linux/power_supply.h>
16#include <linux/slab.h>
16 17
17#include "power_supply.h" 18#include "power_supply.h"
18 19
diff --git a/drivers/power/wm831x_backup.c b/drivers/power/wm831x_backup.c
index bf4f387a800..0fd130d80f5 100644
--- a/drivers/power/wm831x_backup.c
+++ b/drivers/power/wm831x_backup.c
@@ -12,6 +12,7 @@
12#include <linux/err.h> 12#include <linux/err.h>
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <linux/power_supply.h> 14#include <linux/power_supply.h>
15#include <linux/slab.h>
15 16
16#include <linux/mfd/wm831x/core.h> 17#include <linux/mfd/wm831x/core.h>
17#include <linux/mfd/wm831x/auxadc.h> 18#include <linux/mfd/wm831x/auxadc.h>
diff --git a/drivers/power/wm831x_power.c b/drivers/power/wm831x_power.c
index f85e80b1b40..875c4d0f776 100644
--- a/drivers/power/wm831x_power.c
+++ b/drivers/power/wm831x_power.c
@@ -12,6 +12,7 @@
12#include <linux/err.h> 12#include <linux/err.h>
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <linux/power_supply.h> 14#include <linux/power_supply.h>
15#include <linux/slab.h>
15 16
16#include <linux/mfd/wm831x/core.h> 17#include <linux/mfd/wm831x/core.h>
17#include <linux/mfd/wm831x/auxadc.h> 18#include <linux/mfd/wm831x/auxadc.h>
diff --git a/drivers/power/wm97xx_battery.c b/drivers/power/wm97xx_battery.c
index 23eed356a85..94c70650aaf 100644
--- a/drivers/power/wm97xx_battery.c
+++ b/drivers/power/wm97xx_battery.c
@@ -23,6 +23,7 @@
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/gpio.h> 24#include <linux/gpio.h>
25#include <linux/irq.h> 25#include <linux/irq.h>
26#include <linux/slab.h>
26 27
27static DEFINE_MUTEX(bat_lock); 28static DEFINE_MUTEX(bat_lock);
28static struct work_struct bat_work; 29static struct work_struct bat_work;
diff --git a/drivers/pps/kapi.c b/drivers/pps/kapi.c
index 2d414e23d39..1aa02db3ff4 100644
--- a/drivers/pps/kapi.c
+++ b/drivers/pps/kapi.c
@@ -29,6 +29,7 @@
29#include <linux/idr.h> 29#include <linux/idr.h>
30#include <linux/fs.h> 30#include <linux/fs.h>
31#include <linux/pps_kernel.h> 31#include <linux/pps_kernel.h>
32#include <linux/slab.h>
32 33
33/* 34/*
34 * Global variables 35 * Global variables
diff --git a/drivers/ps3/ps3-lpm.c b/drivers/ps3/ps3-lpm.c
index fe96793e3f0..8000985d0e8 100644
--- a/drivers/ps3/ps3-lpm.c
+++ b/drivers/ps3/ps3-lpm.c
@@ -18,6 +18,7 @@
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20 20
21#include <linux/slab.h>
21#include <linux/kernel.h> 22#include <linux/kernel.h>
22#include <linux/module.h> 23#include <linux/module.h>
23#include <linux/interrupt.h> 24#include <linux/interrupt.h>
diff --git a/drivers/ps3/ps3-vuart.c b/drivers/ps3/ps3-vuart.c
index e4ad5ba5d0a..d9fb729535a 100644
--- a/drivers/ps3/ps3-vuart.c
+++ b/drivers/ps3/ps3-vuart.c
@@ -19,6 +19,7 @@
19 */ 19 */
20 20
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/slab.h>
22#include <linux/module.h> 23#include <linux/module.h>
23#include <linux/interrupt.h> 24#include <linux/interrupt.h>
24#include <linux/workqueue.h> 25#include <linux/workqueue.h>
diff --git a/drivers/ps3/ps3av.c b/drivers/ps3/ps3av.c
index 95a689befc8..a409fa050a1 100644
--- a/drivers/ps3/ps3av.c
+++ b/drivers/ps3/ps3av.c
@@ -24,6 +24,7 @@
24#include <linux/notifier.h> 24#include <linux/notifier.h>
25#include <linux/ioctl.h> 25#include <linux/ioctl.h>
26#include <linux/fb.h> 26#include <linux/fb.h>
27#include <linux/slab.h>
27 28
28#include <asm/firmware.h> 29#include <asm/firmware.h>
29#include <asm/ps3av.h> 30#include <asm/ps3av.h>
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index c7bbe30010f..2b4e40d3119 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -16,6 +16,7 @@
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/device.h> 18#include <linux/device.h>
19#include <linux/slab.h>
19#include <linux/err.h> 20#include <linux/err.h>
20#include <linux/mutex.h> 21#include <linux/mutex.h>
21#include <linux/suspend.h> 22#include <linux/suspend.h>
@@ -1038,6 +1039,7 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
1038 goto overflow_err; 1039 goto overflow_err;
1039 1040
1040 regulator->dev = dev; 1041 regulator->dev = dev;
1042 sysfs_attr_init(&regulator->dev_attr.attr);
1041 regulator->dev_attr.attr.name = kstrdup(buf, GFP_KERNEL); 1043 regulator->dev_attr.attr.name = kstrdup(buf, GFP_KERNEL);
1042 if (regulator->dev_attr.attr.name == NULL) 1044 if (regulator->dev_attr.attr.name == NULL)
1043 goto attr_name_err; 1045 goto attr_name_err;
diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index d11f7622430..2fe9d99c9f2 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -25,6 +25,7 @@
25#include <linux/regulator/fixed.h> 25#include <linux/regulator/fixed.h>
26#include <linux/gpio.h> 26#include <linux/gpio.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/slab.h>
28 29
29struct fixed_voltage_data { 30struct fixed_voltage_data {
30 struct regulator_desc desc; 31 struct regulator_desc desc;
diff --git a/drivers/regulator/lp3971.c b/drivers/regulator/lp3971.c
index f5532ed7927..671a7d1f1f0 100644
--- a/drivers/regulator/lp3971.c
+++ b/drivers/regulator/lp3971.c
@@ -18,6 +18,7 @@
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/regulator/driver.h> 19#include <linux/regulator/driver.h>
20#include <linux/regulator/lp3971.h> 20#include <linux/regulator/lp3971.h>
21#include <linux/slab.h>
21 22
22struct lp3971 { 23struct lp3971 {
23 struct device *dev; 24 struct device *dev;
@@ -45,7 +46,7 @@ static int lp3971_set_bits(struct lp3971 *lp3971, u8 reg, u16 mask, u16 val);
45 LP3971_BUCK2 -> 4 46 LP3971_BUCK2 -> 4
46 LP3971_BUCK3 -> 6 47 LP3971_BUCK3 -> 6
47*/ 48*/
48#define BUCK_VOL_CHANGE_SHIFT(x) (((1 << x) & ~0x01) << 1) 49#define BUCK_VOL_CHANGE_SHIFT(x) (((!!x) << 2) | (x & ~0x01))
49#define BUCK_VOL_CHANGE_FLAG_GO 0x01 50#define BUCK_VOL_CHANGE_FLAG_GO 0x01
50#define BUCK_VOL_CHANGE_FLAG_TARGET 0x02 51#define BUCK_VOL_CHANGE_FLAG_TARGET 0x02
51#define BUCK_VOL_CHANGE_FLAG_MASK 0x03 52#define BUCK_VOL_CHANGE_FLAG_MASK 0x03
@@ -187,7 +188,8 @@ static int lp3971_ldo_set_voltage(struct regulator_dev *dev,
187 return -EINVAL; 188 return -EINVAL;
188 189
189 return lp3971_set_bits(lp3971, LP3971_LDO_VOL_CONTR_REG(ldo), 190 return lp3971_set_bits(lp3971, LP3971_LDO_VOL_CONTR_REG(ldo),
190 LDO_VOL_CONTR_MASK << LDO_VOL_CONTR_SHIFT(ldo), val); 191 LDO_VOL_CONTR_MASK << LDO_VOL_CONTR_SHIFT(ldo),
192 val << LDO_VOL_CONTR_SHIFT(ldo));
191} 193}
192 194
193static struct regulator_ops lp3971_ldo_ops = { 195static struct regulator_ops lp3971_ldo_ops = {
@@ -439,6 +441,10 @@ static int __devinit setup_regulators(struct lp3971 *lp3971,
439 lp3971->num_regulators = pdata->num_regulators; 441 lp3971->num_regulators = pdata->num_regulators;
440 lp3971->rdev = kcalloc(pdata->num_regulators, 442 lp3971->rdev = kcalloc(pdata->num_regulators,
441 sizeof(struct regulator_dev *), GFP_KERNEL); 443 sizeof(struct regulator_dev *), GFP_KERNEL);
444 if (!lp3971->rdev) {
445 err = -ENOMEM;
446 goto err_nomem;
447 }
442 448
443 /* Instantiate the regulators */ 449 /* Instantiate the regulators */
444 for (i = 0; i < pdata->num_regulators; i++) { 450 for (i = 0; i < pdata->num_regulators; i++) {
@@ -461,6 +467,7 @@ error:
461 regulator_unregister(lp3971->rdev[i]); 467 regulator_unregister(lp3971->rdev[i]);
462 kfree(lp3971->rdev); 468 kfree(lp3971->rdev);
463 lp3971->rdev = NULL; 469 lp3971->rdev = NULL;
470err_nomem:
464 return err; 471 return err;
465} 472}
466 473
diff --git a/drivers/regulator/max1586.c b/drivers/regulator/max1586.c
index a49fc952c9a..b3c1afc1688 100644
--- a/drivers/regulator/max1586.c
+++ b/drivers/regulator/max1586.c
@@ -22,6 +22,7 @@
22#include <linux/i2c.h> 22#include <linux/i2c.h>
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/regulator/driver.h> 24#include <linux/regulator/driver.h>
25#include <linux/slab.h>
25#include <linux/regulator/max1586.h> 26#include <linux/regulator/max1586.h>
26 27
27#define MAX1586_V3_MAX_VSEL 31 28#define MAX1586_V3_MAX_VSEL 31
@@ -243,8 +244,8 @@ static int __devexit max1586_pmic_remove(struct i2c_client *client)
243 for (i = 0; i <= MAX1586_V6; i++) 244 for (i = 0; i <= MAX1586_V6; i++)
244 if (rdev[i]) 245 if (rdev[i])
245 regulator_unregister(rdev[i]); 246 regulator_unregister(rdev[i]);
246 kfree(rdev);
247 i2c_set_clientdata(client, NULL); 247 i2c_set_clientdata(client, NULL);
248 kfree(rdev);
248 249
249 return 0; 250 return 0;
250} 251}
diff --git a/drivers/regulator/max8649.c b/drivers/regulator/max8649.c
index 3ebdf698c64..bfc4c5ffdc9 100644
--- a/drivers/regulator/max8649.c
+++ b/drivers/regulator/max8649.c
@@ -14,6 +14,7 @@
14#include <linux/i2c.h> 14#include <linux/i2c.h>
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/regulator/driver.h> 16#include <linux/regulator/driver.h>
17#include <linux/slab.h>
17#include <linux/regulator/max8649.h> 18#include <linux/regulator/max8649.h>
18 19
19#define MAX8649_DCDC_VMIN 750000 /* uV */ 20#define MAX8649_DCDC_VMIN 750000 /* uV */
@@ -356,6 +357,7 @@ static int __devinit max8649_regulator_probe(struct i2c_client *client,
356 dev_info(info->dev, "Max8649 regulator device is detected.\n"); 357 dev_info(info->dev, "Max8649 regulator device is detected.\n");
357 return 0; 358 return 0;
358out: 359out:
360 i2c_set_clientdata(client, NULL);
359 kfree(info); 361 kfree(info);
360 return ret; 362 return ret;
361} 363}
@@ -367,9 +369,9 @@ static int __devexit max8649_regulator_remove(struct i2c_client *client)
367 if (info) { 369 if (info) {
368 if (info->regulator) 370 if (info->regulator)
369 regulator_unregister(info->regulator); 371 regulator_unregister(info->regulator);
372 i2c_set_clientdata(client, NULL);
370 kfree(info); 373 kfree(info);
371 } 374 }
372 i2c_set_clientdata(client, NULL);
373 375
374 return 0; 376 return 0;
375} 377}
diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
index f12f1bb6213..3790b21879f 100644
--- a/drivers/regulator/max8660.c
+++ b/drivers/regulator/max8660.c
@@ -42,6 +42,7 @@
42#include <linux/i2c.h> 42#include <linux/i2c.h>
43#include <linux/platform_device.h> 43#include <linux/platform_device.h>
44#include <linux/regulator/driver.h> 44#include <linux/regulator/driver.h>
45#include <linux/slab.h>
45#include <linux/regulator/max8660.h> 46#include <linux/regulator/max8660.h>
46 47
47#define MAX8660_DCDC_MIN_UV 725000 48#define MAX8660_DCDC_MIN_UV 725000
@@ -470,8 +471,8 @@ static int __devexit max8660_remove(struct i2c_client *client)
470 for (i = 0; i < MAX8660_V_END; i++) 471 for (i = 0; i < MAX8660_V_END; i++)
471 if (rdev[i]) 472 if (rdev[i])
472 regulator_unregister(rdev[i]); 473 regulator_unregister(rdev[i]);
473 kfree(rdev);
474 i2c_set_clientdata(client, NULL); 474 i2c_set_clientdata(client, NULL);
475 kfree(rdev);
475 476
476 return 0; 477 return 0;
477} 478}
diff --git a/drivers/regulator/max8925-regulator.c b/drivers/regulator/max8925-regulator.c
index 67873f08ed4..552cad85ae5 100644
--- a/drivers/regulator/max8925-regulator.c
+++ b/drivers/regulator/max8925-regulator.c
@@ -109,7 +109,7 @@ static int max8925_is_enabled(struct regulator_dev *rdev)
109 struct max8925_regulator_info *info = rdev_get_drvdata(rdev); 109 struct max8925_regulator_info *info = rdev_get_drvdata(rdev);
110 int ret; 110 int ret;
111 111
112 ret = max8925_reg_read(info->i2c, info->vol_reg); 112 ret = max8925_reg_read(info->i2c, info->enable_reg);
113 if (ret < 0) 113 if (ret < 0)
114 return ret; 114 return ret;
115 115
@@ -230,7 +230,7 @@ static struct max8925_regulator_info max8925_regulator_info[] = {
230 MAX8925_LDO(20, 750, 3900, 50), 230 MAX8925_LDO(20, 750, 3900, 50),
231}; 231};
232 232
233static inline struct max8925_regulator_info *find_regulator_info(int id) 233static struct max8925_regulator_info * __devinit find_regulator_info(int id)
234{ 234{
235 struct max8925_regulator_info *ri; 235 struct max8925_regulator_info *ri;
236 int i; 236 int i;
@@ -247,7 +247,7 @@ static int __devinit max8925_regulator_probe(struct platform_device *pdev)
247{ 247{
248 struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent); 248 struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
249 struct max8925_platform_data *pdata = chip->dev->platform_data; 249 struct max8925_platform_data *pdata = chip->dev->platform_data;
250 struct max8925_regulator_info *ri = NULL; 250 struct max8925_regulator_info *ri;
251 struct regulator_dev *rdev; 251 struct regulator_dev *rdev;
252 252
253 ri = find_regulator_info(pdev->id); 253 ri = find_regulator_info(pdev->id);
@@ -274,7 +274,9 @@ static int __devexit max8925_regulator_remove(struct platform_device *pdev)
274{ 274{
275 struct regulator_dev *rdev = platform_get_drvdata(pdev); 275 struct regulator_dev *rdev = platform_get_drvdata(pdev);
276 276
277 platform_set_drvdata(pdev, NULL);
277 regulator_unregister(rdev); 278 regulator_unregister(rdev);
279
278 return 0; 280 return 0;
279} 281}
280 282
diff --git a/drivers/regulator/mc13783-regulator.c b/drivers/regulator/mc13783-regulator.c
index f7b81845a19..ad036dd8da1 100644
--- a/drivers/regulator/mc13783-regulator.c
+++ b/drivers/regulator/mc13783-regulator.c
@@ -14,6 +14,7 @@
14#include <linux/regulator/driver.h> 14#include <linux/regulator/driver.h>
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/slab.h>
17#include <linux/init.h> 18#include <linux/init.h>
18#include <linux/err.h> 19#include <linux/err.h>
19 20
@@ -617,9 +618,12 @@ static int __devexit mc13783_regulator_remove(struct platform_device *pdev)
617 dev_get_platdata(&pdev->dev); 618 dev_get_platdata(&pdev->dev);
618 int i; 619 int i;
619 620
621 platform_set_drvdata(pdev, NULL);
622
620 for (i = 0; i < pdata->num_regulators; i++) 623 for (i = 0; i < pdata->num_regulators; i++)
621 regulator_unregister(priv->regulators[i]); 624 regulator_unregister(priv->regulators[i]);
622 625
626 kfree(priv);
623 return 0; 627 return 0;
624} 628}
625 629
diff --git a/drivers/regulator/tps65023-regulator.c b/drivers/regulator/tps65023-regulator.c
index 1f183543bdb..8e2f2098b00 100644
--- a/drivers/regulator/tps65023-regulator.c
+++ b/drivers/regulator/tps65023-regulator.c
@@ -24,6 +24,7 @@
24#include <linux/regulator/machine.h> 24#include <linux/regulator/machine.h>
25#include <linux/i2c.h> 25#include <linux/i2c.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/slab.h>
27 28
28/* Register definitions */ 29/* Register definitions */
29#define TPS65023_REG_VERSION 0 30#define TPS65023_REG_VERSION 0
diff --git a/drivers/regulator/tps6507x-regulator.c b/drivers/regulator/tps6507x-regulator.c
index c2a9539acd7..74841abcc9c 100644
--- a/drivers/regulator/tps6507x-regulator.c
+++ b/drivers/regulator/tps6507x-regulator.c
@@ -24,6 +24,7 @@
24#include <linux/regulator/machine.h> 24#include <linux/regulator/machine.h>
25#include <linux/i2c.h> 25#include <linux/i2c.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/slab.h>
27 28
28/* Register definitions */ 29/* Register definitions */
29#define TPS6507X_REG_PPATH1 0X01 30#define TPS6507X_REG_PPATH1 0X01
diff --git a/drivers/regulator/userspace-consumer.c b/drivers/regulator/userspace-consumer.c
index 44917da4ac9..9d5ba935759 100644
--- a/drivers/regulator/userspace-consumer.c
+++ b/drivers/regulator/userspace-consumer.c
@@ -21,6 +21,7 @@
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/regulator/consumer.h> 22#include <linux/regulator/consumer.h>
23#include <linux/regulator/userspace-consumer.h> 23#include <linux/regulator/userspace-consumer.h>
24#include <linux/slab.h>
24 25
25struct userspace_consumer_data { 26struct userspace_consumer_data {
26 const char *name; 27 const char *name;
diff --git a/drivers/regulator/virtual.c b/drivers/regulator/virtual.c
index d96cecaac73..69e550f5763 100644
--- a/drivers/regulator/virtual.c
+++ b/drivers/regulator/virtual.c
@@ -15,6 +15,7 @@
15#include <linux/mutex.h> 15#include <linux/mutex.h>
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/regulator/consumer.h> 17#include <linux/regulator/consumer.h>
18#include <linux/slab.h>
18 19
19struct virtual_consumer_data { 20struct virtual_consumer_data {
20 struct mutex lock; 21 struct mutex lock;
diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c
index 6e18e56d850..dbfaf5945e4 100644
--- a/drivers/regulator/wm831x-dcdc.c
+++ b/drivers/regulator/wm831x-dcdc.c
@@ -21,6 +21,7 @@
21#include <linux/regulator/driver.h> 21#include <linux/regulator/driver.h>
22#include <linux/regulator/machine.h> 22#include <linux/regulator/machine.h>
23#include <linux/gpio.h> 23#include <linux/gpio.h>
24#include <linux/slab.h>
24 25
25#include <linux/mfd/wm831x/core.h> 26#include <linux/mfd/wm831x/core.h>
26#include <linux/mfd/wm831x/regulator.h> 27#include <linux/mfd/wm831x/regulator.h>
diff --git a/drivers/regulator/wm831x-isink.c b/drivers/regulator/wm831x-isink.c
index ca0f6b6c384..6c446cd6ad5 100644
--- a/drivers/regulator/wm831x-isink.c
+++ b/drivers/regulator/wm831x-isink.c
@@ -19,6 +19,7 @@
19#include <linux/i2c.h> 19#include <linux/i2c.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/regulator/driver.h> 21#include <linux/regulator/driver.h>
22#include <linux/slab.h>
22 23
23#include <linux/mfd/wm831x/core.h> 24#include <linux/mfd/wm831x/core.h>
24#include <linux/mfd/wm831x/regulator.h> 25#include <linux/mfd/wm831x/regulator.h>
diff --git a/drivers/regulator/wm831x-ldo.c b/drivers/regulator/wm831x-ldo.c
index d2406c1519a..e686cdb61b9 100644
--- a/drivers/regulator/wm831x-ldo.c
+++ b/drivers/regulator/wm831x-ldo.c
@@ -19,6 +19,7 @@
19#include <linux/i2c.h> 19#include <linux/i2c.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/regulator/driver.h> 21#include <linux/regulator/driver.h>
22#include <linux/slab.h>
22 23
23#include <linux/mfd/wm831x/core.h> 24#include <linux/mfd/wm831x/core.h>
24#include <linux/mfd/wm831x/regulator.h> 25#include <linux/mfd/wm831x/regulator.h>
diff --git a/drivers/regulator/wm8994-regulator.c b/drivers/regulator/wm8994-regulator.c
index 95454a4637b..5a1dc8a24d3 100644
--- a/drivers/regulator/wm8994-regulator.c
+++ b/drivers/regulator/wm8994-regulator.c
@@ -19,6 +19,7 @@
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/regulator/driver.h> 20#include <linux/regulator/driver.h>
21#include <linux/gpio.h> 21#include <linux/gpio.h>
22#include <linux/slab.h>
22 23
23#include <linux/mfd/wm8994/core.h> 24#include <linux/mfd/wm8994/core.h>
24#include <linux/mfd/wm8994/registers.h> 25#include <linux/mfd/wm8994/registers.h>
diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
index 40845c7e932..565562ba6ac 100644
--- a/drivers/rtc/class.c
+++ b/drivers/rtc/class.c
@@ -15,6 +15,7 @@
15#include <linux/rtc.h> 15#include <linux/rtc.h>
16#include <linux/kdev_t.h> 16#include <linux/kdev_t.h>
17#include <linux/idr.h> 17#include <linux/idr.h>
18#include <linux/slab.h>
18 19
19#include "rtc-core.h" 20#include "rtc-core.h"
20 21
diff --git a/drivers/rtc/rtc-at32ap700x.c b/drivers/rtc/rtc-at32ap700x.c
index 8825695777d..b2752b6e7a2 100644
--- a/drivers/rtc/rtc-at32ap700x.c
+++ b/drivers/rtc/rtc-at32ap700x.c
@@ -11,6 +11,7 @@
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <linux/slab.h>
14#include <linux/rtc.h> 15#include <linux/rtc.h>
15#include <linux/io.h> 16#include <linux/io.h>
16 17
diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c
index 78a018b5c94..f677e0710ca 100644
--- a/drivers/rtc/rtc-at91sam9.c
+++ b/drivers/rtc/rtc-at91sam9.c
@@ -18,6 +18,7 @@
18#include <linux/rtc.h> 18#include <linux/rtc.h>
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#include <linux/ioctl.h> 20#include <linux/ioctl.h>
21#include <linux/slab.h>
21 22
22#include <mach/board.h> 23#include <mach/board.h>
23#include <mach/at91_rtt.h> 24#include <mach/at91_rtt.h>
diff --git a/drivers/rtc/rtc-bfin.c b/drivers/rtc/rtc-bfin.c
index b11485b9f21..72b2bcc2c22 100644
--- a/drivers/rtc/rtc-bfin.c
+++ b/drivers/rtc/rtc-bfin.c
@@ -51,6 +51,7 @@
51#include <linux/platform_device.h> 51#include <linux/platform_device.h>
52#include <linux/rtc.h> 52#include <linux/rtc.h>
53#include <linux/seq_file.h> 53#include <linux/seq_file.h>
54#include <linux/slab.h>
54 55
55#include <asm/blackfin.h> 56#include <asm/blackfin.h>
56 57
diff --git a/drivers/rtc/rtc-bq4802.c b/drivers/rtc/rtc-bq4802.c
index 280fe48ada0..128270ce355 100644
--- a/drivers/rtc/rtc-bq4802.c
+++ b/drivers/rtc/rtc-bq4802.c
@@ -10,6 +10,7 @@
10#include <linux/platform_device.h> 10#include <linux/platform_device.h>
11#include <linux/rtc.h> 11#include <linux/rtc.h>
12#include <linux/bcd.h> 12#include <linux/bcd.h>
13#include <linux/slab.h>
13 14
14MODULE_AUTHOR("David S. Miller <davem@davemloft.net>"); 15MODULE_AUTHOR("David S. Miller <davem@davemloft.net>");
15MODULE_DESCRIPTION("TI BQ4802 RTC driver"); 16MODULE_DESCRIPTION("TI BQ4802 RTC driver");
diff --git a/drivers/rtc/rtc-coh901331.c b/drivers/rtc/rtc-coh901331.c
index 44c4399ee71..316f484999b 100644
--- a/drivers/rtc/rtc-coh901331.c
+++ b/drivers/rtc/rtc-coh901331.c
@@ -14,6 +14,7 @@
14#include <linux/pm.h> 14#include <linux/pm.h>
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/io.h> 16#include <linux/io.h>
17#include <linux/slab.h>
17 18
18/* 19/*
19 * Registers in the COH 901 331 20 * Registers in the COH 901 331
diff --git a/drivers/rtc/rtc-ds1216.c b/drivers/rtc/rtc-ds1216.c
index 4aedc705518..45cd8c9f5a3 100644
--- a/drivers/rtc/rtc-ds1216.c
+++ b/drivers/rtc/rtc-ds1216.c
@@ -9,6 +9,7 @@
9#include <linux/rtc.h> 9#include <linux/rtc.h>
10#include <linux/platform_device.h> 10#include <linux/platform_device.h>
11#include <linux/bcd.h> 11#include <linux/bcd.h>
12#include <linux/slab.h>
12 13
13#define DRV_VERSION "0.2" 14#define DRV_VERSION "0.2"
14 15
diff --git a/drivers/rtc/rtc-ds1286.c b/drivers/rtc/rtc-ds1286.c
index 4fcb16bbff4..bf430f9091e 100644
--- a/drivers/rtc/rtc-ds1286.c
+++ b/drivers/rtc/rtc-ds1286.c
@@ -18,6 +18,7 @@
18#include <linux/bcd.h> 18#include <linux/bcd.h>
19#include <linux/ds1286.h> 19#include <linux/ds1286.h>
20#include <linux/io.h> 20#include <linux/io.h>
21#include <linux/slab.h>
21 22
22#define DRV_VERSION "1.0" 23#define DRV_VERSION "1.0"
23 24
diff --git a/drivers/rtc/rtc-ds1305.c b/drivers/rtc/rtc-ds1305.c
index 9630e7d3314..7836c9cec55 100644
--- a/drivers/rtc/rtc-ds1305.c
+++ b/drivers/rtc/rtc-ds1305.c
@@ -11,6 +11,7 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/bcd.h> 13#include <linux/bcd.h>
14#include <linux/slab.h>
14#include <linux/rtc.h> 15#include <linux/rtc.h>
15#include <linux/workqueue.h> 16#include <linux/workqueue.h>
16 17
diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
index 5317bbcbc7a..61945734ad0 100644
--- a/drivers/rtc/rtc-ds1374.c
+++ b/drivers/rtc/rtc-ds1374.c
@@ -24,6 +24,7 @@
24#include <linux/rtc.h> 24#include <linux/rtc.h>
25#include <linux/bcd.h> 25#include <linux/bcd.h>
26#include <linux/workqueue.h> 26#include <linux/workqueue.h>
27#include <linux/slab.h>
27 28
28#define DS1374_REG_TOD0 0x00 /* Time of Day */ 29#define DS1374_REG_TOD0 0x00 /* Time of Day */
29#define DS1374_REG_TOD1 0x01 30#define DS1374_REG_TOD1 0x01
diff --git a/drivers/rtc/rtc-ds1390.c b/drivers/rtc/rtc-ds1390.c
index cdb70505709..26a86d23505 100644
--- a/drivers/rtc/rtc-ds1390.c
+++ b/drivers/rtc/rtc-ds1390.c
@@ -19,6 +19,7 @@
19#include <linux/rtc.h> 19#include <linux/rtc.h>
20#include <linux/spi/spi.h> 20#include <linux/spi/spi.h>
21#include <linux/bcd.h> 21#include <linux/bcd.h>
22#include <linux/slab.h>
22 23
23#define DS1390_REG_100THS 0x00 24#define DS1390_REG_100THS 0x00
24#define DS1390_REG_SECONDS 0x01 25#define DS1390_REG_SECONDS 0x01
diff --git a/drivers/rtc/rtc-ds1511.c b/drivers/rtc/rtc-ds1511.c
index 4166b84cb51..06b8566c453 100644
--- a/drivers/rtc/rtc-ds1511.c
+++ b/drivers/rtc/rtc-ds1511.c
@@ -17,6 +17,7 @@
17#include <linux/bcd.h> 17#include <linux/bcd.h>
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/gfp.h>
20#include <linux/delay.h> 21#include <linux/delay.h>
21#include <linux/interrupt.h> 22#include <linux/interrupt.h>
22#include <linux/rtc.h> 23#include <linux/rtc.h>
diff --git a/drivers/rtc/rtc-ds1553.c b/drivers/rtc/rtc-ds1553.c
index ed1ef7c9cc0..244f9994bcb 100644
--- a/drivers/rtc/rtc-ds1553.c
+++ b/drivers/rtc/rtc-ds1553.c
@@ -11,6 +11,7 @@
11#include <linux/bcd.h> 11#include <linux/bcd.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/gfp.h>
14#include <linux/delay.h> 15#include <linux/delay.h>
15#include <linux/jiffies.h> 16#include <linux/jiffies.h>
16#include <linux/interrupt.h> 17#include <linux/interrupt.h>
diff --git a/drivers/rtc/rtc-ds1742.c b/drivers/rtc/rtc-ds1742.c
index cad9ceb89ba..2b4b0bc42d6 100644
--- a/drivers/rtc/rtc-ds1742.c
+++ b/drivers/rtc/rtc-ds1742.c
@@ -15,6 +15,7 @@
15#include <linux/bcd.h> 15#include <linux/bcd.h>
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/gfp.h>
18#include <linux/delay.h> 19#include <linux/delay.h>
19#include <linux/jiffies.h> 20#include <linux/jiffies.h>
20#include <linux/rtc.h> 21#include <linux/rtc.h>
diff --git a/drivers/rtc/rtc-ep93xx.c b/drivers/rtc/rtc-ep93xx.c
index 91bde976bc0..11ae64dcbf3 100644
--- a/drivers/rtc/rtc-ep93xx.c
+++ b/drivers/rtc/rtc-ep93xx.c
@@ -13,6 +13,7 @@
13#include <linux/rtc.h> 13#include <linux/rtc.h>
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/io.h> 15#include <linux/io.h>
16#include <linux/gfp.h>
16 17
17#define EP93XX_RTC_DATA 0x000 18#define EP93XX_RTC_DATA 0x000
18#define EP93XX_RTC_MATCH 0x004 19#define EP93XX_RTC_MATCH 0x004
diff --git a/drivers/rtc/rtc-fm3130.c b/drivers/rtc/rtc-fm3130.c
index 812c6675508..ff6fce61ea4 100644
--- a/drivers/rtc/rtc-fm3130.c
+++ b/drivers/rtc/rtc-fm3130.c
@@ -13,6 +13,7 @@
13#include <linux/i2c.h> 13#include <linux/i2c.h>
14#include <linux/rtc.h> 14#include <linux/rtc.h>
15#include <linux/bcd.h> 15#include <linux/bcd.h>
16#include <linux/slab.h>
16 17
17#define FM3130_RTC_CONTROL (0x0) 18#define FM3130_RTC_CONTROL (0x0)
18#define FM3130_CAL_CONTROL (0x1) 19#define FM3130_CAL_CONTROL (0x1)
diff --git a/drivers/rtc/rtc-m48t35.c b/drivers/rtc/rtc-m48t35.c
index 8cb5b8959e5..7410875e583 100644
--- a/drivers/rtc/rtc-m48t35.c
+++ b/drivers/rtc/rtc-m48t35.c
@@ -16,6 +16,7 @@
16 16
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/rtc.h> 18#include <linux/rtc.h>
19#include <linux/slab.h>
19#include <linux/platform_device.h> 20#include <linux/platform_device.h>
20#include <linux/bcd.h> 21#include <linux/bcd.h>
21#include <linux/io.h> 22#include <linux/io.h>
diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
index ede43b84685..365ff3ac234 100644
--- a/drivers/rtc/rtc-m48t59.c
+++ b/drivers/rtc/rtc-m48t59.c
@@ -19,6 +19,7 @@
19#include <linux/rtc.h> 19#include <linux/rtc.h>
20#include <linux/rtc/m48t59.h> 20#include <linux/rtc/m48t59.h>
21#include <linux/bcd.h> 21#include <linux/bcd.h>
22#include <linux/slab.h>
22 23
23#ifndef NO_IRQ 24#ifndef NO_IRQ
24#define NO_IRQ (-1) 25#define NO_IRQ (-1)
diff --git a/drivers/rtc/rtc-max8925.c b/drivers/rtc/rtc-max8925.c
index acdbb176018..174036dda78 100644
--- a/drivers/rtc/rtc-max8925.c
+++ b/drivers/rtc/rtc-max8925.c
@@ -11,6 +11,7 @@
11 11
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/i2c.h> 13#include <linux/i2c.h>
14#include <linux/slab.h>
14#include <linux/rtc.h> 15#include <linux/rtc.h>
15#include <linux/platform_device.h> 16#include <linux/platform_device.h>
16#include <linux/mfd/max8925.h> 17#include <linux/mfd/max8925.h>
diff --git a/drivers/rtc/rtc-mc13783.c b/drivers/rtc/rtc-mc13783.c
index d60c81b7b69..675bfb51536 100644
--- a/drivers/rtc/rtc-mc13783.c
+++ b/drivers/rtc/rtc-mc13783.c
@@ -13,6 +13,7 @@
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/slab.h>
16#include <linux/rtc.h> 17#include <linux/rtc.h>
17 18
18#define DRIVER_NAME "mc13783-rtc" 19#define DRIVER_NAME "mc13783-rtc"
@@ -319,35 +320,38 @@ static int __devinit mc13783_rtc_probe(struct platform_device *pdev)
319{ 320{
320 int ret; 321 int ret;
321 struct mc13783_rtc *priv; 322 struct mc13783_rtc *priv;
323 struct mc13783 *mc13783;
322 int rtcrst_pending; 324 int rtcrst_pending;
323 325
324 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 326 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
325 if (!priv) 327 if (!priv)
326 return -ENOMEM; 328 return -ENOMEM;
327 329
328 priv->mc13783 = dev_get_drvdata(pdev->dev.parent); 330 mc13783 = dev_get_drvdata(pdev->dev.parent);
331 priv->mc13783 = mc13783;
332
329 platform_set_drvdata(pdev, priv); 333 platform_set_drvdata(pdev, priv);
330 334
331 mc13783_lock(priv->mc13783); 335 mc13783_lock(mc13783);
332 336
333 ret = mc13783_irq_request(priv->mc13783, MC13783_IRQ_RTCRST, 337 ret = mc13783_irq_request(mc13783, MC13783_IRQ_RTCRST,
334 mc13783_rtc_reset_handler, DRIVER_NAME, priv); 338 mc13783_rtc_reset_handler, DRIVER_NAME, priv);
335 if (ret) 339 if (ret)
336 goto err_reset_irq_request; 340 goto err_reset_irq_request;
337 341
338 ret = mc13783_irq_status(priv->mc13783, MC13783_IRQ_RTCRST, 342 ret = mc13783_irq_status(mc13783, MC13783_IRQ_RTCRST,
339 NULL, &rtcrst_pending); 343 NULL, &rtcrst_pending);
340 if (ret) 344 if (ret)
341 goto err_reset_irq_status; 345 goto err_reset_irq_status;
342 346
343 priv->valid = !rtcrst_pending; 347 priv->valid = !rtcrst_pending;
344 348
345 ret = mc13783_irq_request_nounmask(priv->mc13783, MC13783_IRQ_1HZ, 349 ret = mc13783_irq_request_nounmask(mc13783, MC13783_IRQ_1HZ,
346 mc13783_rtc_update_handler, DRIVER_NAME, priv); 350 mc13783_rtc_update_handler, DRIVER_NAME, priv);
347 if (ret) 351 if (ret)
348 goto err_update_irq_request; 352 goto err_update_irq_request;
349 353
350 ret = mc13783_irq_request_nounmask(priv->mc13783, MC13783_IRQ_TODA, 354 ret = mc13783_irq_request_nounmask(mc13783, MC13783_IRQ_TODA,
351 mc13783_rtc_alarm_handler, DRIVER_NAME, priv); 355 mc13783_rtc_alarm_handler, DRIVER_NAME, priv);
352 if (ret) 356 if (ret)
353 goto err_alarm_irq_request; 357 goto err_alarm_irq_request;
@@ -357,22 +361,22 @@ static int __devinit mc13783_rtc_probe(struct platform_device *pdev)
357 if (IS_ERR(priv->rtc)) { 361 if (IS_ERR(priv->rtc)) {
358 ret = PTR_ERR(priv->rtc); 362 ret = PTR_ERR(priv->rtc);
359 363
360 mc13783_irq_free(priv->mc13783, MC13783_IRQ_TODA, priv); 364 mc13783_irq_free(mc13783, MC13783_IRQ_TODA, priv);
361err_alarm_irq_request: 365err_alarm_irq_request:
362 366
363 mc13783_irq_free(priv->mc13783, MC13783_IRQ_1HZ, priv); 367 mc13783_irq_free(mc13783, MC13783_IRQ_1HZ, priv);
364err_update_irq_request: 368err_update_irq_request:
365 369
366err_reset_irq_status: 370err_reset_irq_status:
367 371
368 mc13783_irq_free(priv->mc13783, MC13783_IRQ_RTCRST, priv); 372 mc13783_irq_free(mc13783, MC13783_IRQ_RTCRST, priv);
369err_reset_irq_request: 373err_reset_irq_request:
370 374
371 platform_set_drvdata(pdev, NULL); 375 platform_set_drvdata(pdev, NULL);
372 kfree(priv); 376 kfree(priv);
373 } 377 }
374 378
375 mc13783_unlock(priv->mc13783); 379 mc13783_unlock(mc13783);
376 380
377 return ret; 381 return ret;
378} 382}
diff --git a/drivers/rtc/rtc-mpc5121.c b/drivers/rtc/rtc-mpc5121.c
index 4313ca03a96..f0dbf9cb8f9 100644
--- a/drivers/rtc/rtc-mpc5121.c
+++ b/drivers/rtc/rtc-mpc5121.c
@@ -15,6 +15,7 @@
15#include <linux/of_device.h> 15#include <linux/of_device.h>
16#include <linux/of_platform.h> 16#include <linux/of_platform.h>
17#include <linux/io.h> 17#include <linux/io.h>
18#include <linux/slab.h>
18 19
19struct mpc5121_rtc_regs { 20struct mpc5121_rtc_regs {
20 u8 set_time; /* RTC + 0x00 */ 21 u8 set_time; /* RTC + 0x00 */
diff --git a/drivers/rtc/rtc-msm6242.c b/drivers/rtc/rtc-msm6242.c
index 5f5968a4892..b2fff0ca49f 100644
--- a/drivers/rtc/rtc-msm6242.c
+++ b/drivers/rtc/rtc-msm6242.c
@@ -13,6 +13,7 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/rtc.h> 15#include <linux/rtc.h>
16#include <linux/slab.h>
16 17
17 18
18enum { 19enum {
diff --git a/drivers/rtc/rtc-mv.c b/drivers/rtc/rtc-mv.c
index dc052ce6e63..bcca4729855 100644
--- a/drivers/rtc/rtc-mv.c
+++ b/drivers/rtc/rtc-mv.c
@@ -13,6 +13,7 @@
13#include <linux/io.h> 13#include <linux/io.h>
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/gfp.h>
16 17
17 18
18#define RTC_TIME_REG_OFFS 0 19#define RTC_TIME_REG_OFFS 0
diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c
index 8710f9415d9..d71fe61db1d 100644
--- a/drivers/rtc/rtc-mxc.c
+++ b/drivers/rtc/rtc-mxc.c
@@ -12,6 +12,7 @@
12#include <linux/io.h> 12#include <linux/io.h>
13#include <linux/rtc.h> 13#include <linux/rtc.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/slab.h>
15#include <linux/interrupt.h> 16#include <linux/interrupt.h>
16#include <linux/platform_device.h> 17#include <linux/platform_device.h>
17#include <linux/clk.h> 18#include <linux/clk.h>
@@ -383,21 +384,26 @@ static int __init mxc_rtc_probe(struct platform_device *pdev)
383 struct rtc_device *rtc; 384 struct rtc_device *rtc;
384 struct rtc_plat_data *pdata = NULL; 385 struct rtc_plat_data *pdata = NULL;
385 u32 reg; 386 u32 reg;
386 int ret, rate; 387 unsigned long rate;
388 int ret;
387 389
388 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 390 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
389 if (!res) 391 if (!res)
390 return -ENODEV; 392 return -ENODEV;
391 393
392 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); 394 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
393 if (!pdata) 395 if (!pdata)
394 return -ENOMEM; 396 return -ENOMEM;
395 397
396 pdata->ioaddr = ioremap(res->start, resource_size(res)); 398 if (!devm_request_mem_region(&pdev->dev, res->start,
399 resource_size(res), pdev->name))
400 return -EBUSY;
401
402 pdata->ioaddr = devm_ioremap(&pdev->dev, res->start,
403 resource_size(res));
397 404
398 clk = clk_get(&pdev->dev, "ckil"); 405 clk = clk_get(&pdev->dev, "ckil");
399 if (IS_ERR(clk)) { 406 if (IS_ERR(clk)) {
400 iounmap(pdata->ioaddr);
401 ret = PTR_ERR(clk); 407 ret = PTR_ERR(clk);
402 goto exit_free_pdata; 408 goto exit_free_pdata;
403 } 409 }
@@ -412,8 +418,7 @@ static int __init mxc_rtc_probe(struct platform_device *pdev)
412 else if (rate == 38400) 418 else if (rate == 38400)
413 reg = RTC_INPUT_CLK_38400HZ; 419 reg = RTC_INPUT_CLK_38400HZ;
414 else { 420 else {
415 dev_err(&pdev->dev, "rtc clock is not valid (%lu)\n", 421 dev_err(&pdev->dev, "rtc clock is not valid (%lu)\n", rate);
416 clk_get_rate(clk));
417 ret = -EINVAL; 422 ret = -EINVAL;
418 goto exit_free_pdata; 423 goto exit_free_pdata;
419 } 424 }
@@ -449,8 +454,8 @@ static int __init mxc_rtc_probe(struct platform_device *pdev)
449 pdata->irq = platform_get_irq(pdev, 0); 454 pdata->irq = platform_get_irq(pdev, 0);
450 455
451 if (pdata->irq >= 0 && 456 if (pdata->irq >= 0 &&
452 request_irq(pdata->irq, mxc_rtc_interrupt, IRQF_SHARED, 457 devm_request_irq(&pdev->dev, pdata->irq, mxc_rtc_interrupt,
453 pdev->name, pdev) < 0) { 458 IRQF_SHARED, pdev->name, pdev) < 0) {
454 dev_warn(&pdev->dev, "interrupt not available.\n"); 459 dev_warn(&pdev->dev, "interrupt not available.\n");
455 pdata->irq = -1; 460 pdata->irq = -1;
456 } 461 }
@@ -458,10 +463,10 @@ static int __init mxc_rtc_probe(struct platform_device *pdev)
458 return 0; 463 return 0;
459 464
460exit_put_clk: 465exit_put_clk:
466 clk_disable(pdata->clk);
461 clk_put(pdata->clk); 467 clk_put(pdata->clk);
462 468
463exit_free_pdata: 469exit_free_pdata:
464 kfree(pdata);
465 470
466 return ret; 471 return ret;
467} 472}
@@ -472,12 +477,8 @@ static int __exit mxc_rtc_remove(struct platform_device *pdev)
472 477
473 rtc_device_unregister(pdata->rtc); 478 rtc_device_unregister(pdata->rtc);
474 479
475 if (pdata->irq >= 0)
476 free_irq(pdata->irq, pdev);
477
478 clk_disable(pdata->clk); 480 clk_disable(pdata->clk);
479 clk_put(pdata->clk); 481 clk_put(pdata->clk);
480 kfree(pdata);
481 platform_set_drvdata(pdev, NULL); 482 platform_set_drvdata(pdev, NULL);
482 483
483 return 0; 484 return 0;
diff --git a/drivers/rtc/rtc-nuc900.c b/drivers/rtc/rtc-nuc900.c
index bf59c9c586b..a351bd5d817 100644
--- a/drivers/rtc/rtc-nuc900.c
+++ b/drivers/rtc/rtc-nuc900.c
@@ -12,6 +12,7 @@
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/slab.h>
15#include <linux/rtc.h> 16#include <linux/rtc.h>
16#include <linux/delay.h> 17#include <linux/delay.h>
17#include <linux/io.h> 18#include <linux/io.h>
diff --git a/drivers/rtc/rtc-pcap.c b/drivers/rtc/rtc-pcap.c
index a99c28992d2..25c0b3fd44f 100644
--- a/drivers/rtc/rtc-pcap.c
+++ b/drivers/rtc/rtc-pcap.c
@@ -17,6 +17,7 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/mfd/ezx-pcap.h> 18#include <linux/mfd/ezx-pcap.h>
19#include <linux/rtc.h> 19#include <linux/rtc.h>
20#include <linux/slab.h>
20#include <linux/platform_device.h> 21#include <linux/platform_device.h>
21 22
22struct pcap_rtc { 23struct pcap_rtc {
diff --git a/drivers/rtc/rtc-pcf2123.c b/drivers/rtc/rtc-pcf2123.c
index 2ceb365533b..71bab0ef544 100644
--- a/drivers/rtc/rtc-pcf2123.c
+++ b/drivers/rtc/rtc-pcf2123.c
@@ -39,6 +39,7 @@
39#include <linux/init.h> 39#include <linux/init.h>
40#include <linux/kernel.h> 40#include <linux/kernel.h>
41#include <linux/string.h> 41#include <linux/string.h>
42#include <linux/slab.h>
42#include <linux/rtc.h> 43#include <linux/rtc.h>
43#include <linux/spi/spi.h> 44#include <linux/spi/spi.h>
44 45
diff --git a/drivers/rtc/rtc-pcf50633.c b/drivers/rtc/rtc-pcf50633.c
index 854c3cb365a..16edf94ab42 100644
--- a/drivers/rtc/rtc-pcf50633.c
+++ b/drivers/rtc/rtc-pcf50633.c
@@ -18,6 +18,7 @@
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/device.h> 20#include <linux/device.h>
21#include <linux/slab.h>
21#include <linux/platform_device.h> 22#include <linux/platform_device.h>
22#include <linux/rtc.h> 23#include <linux/rtc.h>
23#include <linux/bcd.h> 24#include <linux/bcd.h>
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index 65f346b2fba..1af42b4a6f5 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -17,6 +17,7 @@
17#include <linux/i2c.h> 17#include <linux/i2c.h>
18#include <linux/bcd.h> 18#include <linux/bcd.h>
19#include <linux/rtc.h> 19#include <linux/rtc.h>
20#include <linux/slab.h>
20 21
21#define DRV_VERSION "0.4.3" 22#define DRV_VERSION "0.4.3"
22 23
diff --git a/drivers/rtc/rtc-pl030.c b/drivers/rtc/rtc-pl030.c
index 457231bb102..bbdb2f02798 100644
--- a/drivers/rtc/rtc-pl030.c
+++ b/drivers/rtc/rtc-pl030.c
@@ -13,6 +13,7 @@
13#include <linux/interrupt.h> 13#include <linux/interrupt.h>
14#include <linux/amba/bus.h> 14#include <linux/amba/bus.h>
15#include <linux/io.h> 15#include <linux/io.h>
16#include <linux/slab.h>
16 17
17#define RTC_DR (0) 18#define RTC_DR (0)
18#define RTC_MR (4) 19#define RTC_MR (4)
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c
index c256aacfa95..3587d9922f2 100644
--- a/drivers/rtc/rtc-pl031.c
+++ b/drivers/rtc/rtc-pl031.c
@@ -24,6 +24,7 @@
24#include <linux/bcd.h> 24#include <linux/bcd.h>
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/version.h> 26#include <linux/version.h>
27#include <linux/slab.h>
27 28
28/* 29/*
29 * Register definitions 30 * Register definitions
diff --git a/drivers/rtc/rtc-pxa.c b/drivers/rtc/rtc-pxa.c
index e6351b743da..e9c6fa03598 100644
--- a/drivers/rtc/rtc-pxa.c
+++ b/drivers/rtc/rtc-pxa.c
@@ -26,6 +26,7 @@
26#include <linux/seq_file.h> 26#include <linux/seq_file.h>
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/io.h> 28#include <linux/io.h>
29#include <linux/slab.h>
29 30
30#include <mach/hardware.h> 31#include <mach/hardware.h>
31 32
diff --git a/drivers/rtc/rtc-rp5c01.c b/drivers/rtc/rtc-rp5c01.c
index e1313feb060..a95f733bb15 100644
--- a/drivers/rtc/rtc-rp5c01.c
+++ b/drivers/rtc/rtc-rp5c01.c
@@ -12,6 +12,7 @@
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <linux/rtc.h> 14#include <linux/rtc.h>
15#include <linux/slab.h>
15 16
16 17
17enum { 18enum {
diff --git a/drivers/rtc/rtc-rs5c348.c b/drivers/rtc/rtc-rs5c348.c
index 2099037cb3e..368d0e63cf8 100644
--- a/drivers/rtc/rtc-rs5c348.c
+++ b/drivers/rtc/rtc-rs5c348.c
@@ -19,6 +19,7 @@
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/kernel.h> 20#include <linux/kernel.h>
21#include <linux/string.h> 21#include <linux/string.h>
22#include <linux/slab.h>
22#include <linux/rtc.h> 23#include <linux/rtc.h>
23#include <linux/workqueue.h> 24#include <linux/workqueue.h>
24#include <linux/spi/spi.h> 25#include <linux/spi/spi.h>
diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c
index 2f2c68d476d..90cf0a6ff23 100644
--- a/drivers/rtc/rtc-rs5c372.c
+++ b/drivers/rtc/rtc-rs5c372.c
@@ -13,6 +13,7 @@
13#include <linux/i2c.h> 13#include <linux/i2c.h>
14#include <linux/rtc.h> 14#include <linux/rtc.h>
15#include <linux/bcd.h> 15#include <linux/bcd.h>
16#include <linux/slab.h>
16 17
17#define DRV_VERSION "0.6" 18#define DRV_VERSION "0.6"
18 19
diff --git a/drivers/rtc/rtc-rx8025.c b/drivers/rtc/rtc-rx8025.c
index b1a29bcfdf1..b65c82f792d 100644
--- a/drivers/rtc/rtc-rx8025.c
+++ b/drivers/rtc/rtc-rx8025.c
@@ -20,6 +20,7 @@
20 */ 20 */
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/slab.h>
23#include <linux/init.h> 24#include <linux/init.h>
24#include <linux/bcd.h> 25#include <linux/bcd.h>
25#include <linux/i2c.h> 26#include <linux/i2c.h>
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index e0d7b999150..4969b6059c8 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -21,6 +21,7 @@
21#include <linux/bcd.h> 21#include <linux/bcd.h>
22#include <linux/clk.h> 22#include <linux/clk.h>
23#include <linux/log2.h> 23#include <linux/log2.h>
24#include <linux/slab.h>
24 25
25#include <mach/hardware.h> 26#include <mach/hardware.h>
26#include <asm/uaccess.h> 27#include <asm/uaccess.h>
diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c
index e95cc6f8d61..5efbd5990ff 100644
--- a/drivers/rtc/rtc-sh.c
+++ b/drivers/rtc/rtc-sh.c
@@ -26,6 +26,7 @@
26#include <linux/io.h> 26#include <linux/io.h>
27#include <linux/log2.h> 27#include <linux/log2.h>
28#include <linux/clk.h> 28#include <linux/clk.h>
29#include <linux/slab.h>
29#include <asm/rtc.h> 30#include <asm/rtc.h>
30 31
31#define DRV_NAME "sh-rtc" 32#define DRV_NAME "sh-rtc"
diff --git a/drivers/rtc/rtc-stk17ta8.c b/drivers/rtc/rtc-stk17ta8.c
index 67700831b5c..875ba099e7a 100644
--- a/drivers/rtc/rtc-stk17ta8.c
+++ b/drivers/rtc/rtc-stk17ta8.c
@@ -14,6 +14,7 @@
14#include <linux/bcd.h> 14#include <linux/bcd.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/gfp.h>
17#include <linux/delay.h> 18#include <linux/delay.h>
18#include <linux/jiffies.h> 19#include <linux/jiffies.h>
19#include <linux/interrupt.h> 20#include <linux/interrupt.h>
diff --git a/drivers/rtc/rtc-stmp3xxx.c b/drivers/rtc/rtc-stmp3xxx.c
index d7ce1a5c857..7e7d0c806f2 100644
--- a/drivers/rtc/rtc-stmp3xxx.c
+++ b/drivers/rtc/rtc-stmp3xxx.c
@@ -22,6 +22,7 @@
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/rtc.h> 24#include <linux/rtc.h>
25#include <linux/slab.h>
25 26
26#include <mach/platform.h> 27#include <mach/platform.h>
27#include <mach/stmp3xxx.h> 28#include <mach/stmp3xxx.h>
diff --git a/drivers/rtc/rtc-tx4939.c b/drivers/rtc/rtc-tx4939.c
index 9ee81d8aa7c..20bfc64a15c 100644
--- a/drivers/rtc/rtc-tx4939.c
+++ b/drivers/rtc/rtc-tx4939.c
@@ -12,6 +12,7 @@
12#include <linux/platform_device.h> 12#include <linux/platform_device.h>
13#include <linux/interrupt.h> 13#include <linux/interrupt.h>
14#include <linux/io.h> 14#include <linux/io.h>
15#include <linux/gfp.h>
15#include <asm/txx9/tx4939.h> 16#include <asm/txx9/tx4939.h>
16 17
17struct tx4939rtc_plat_data { 18struct tx4939rtc_plat_data {
diff --git a/drivers/rtc/rtc-v3020.c b/drivers/rtc/rtc-v3020.c
index bed4cab0704..f71c3ce1803 100644
--- a/drivers/rtc/rtc-v3020.c
+++ b/drivers/rtc/rtc-v3020.c
@@ -28,6 +28,7 @@
28#include <linux/rtc-v3020.h> 28#include <linux/rtc-v3020.h>
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/gpio.h> 30#include <linux/gpio.h>
31#include <linux/slab.h>
31 32
32#include <linux/io.h> 33#include <linux/io.h>
33 34
diff --git a/drivers/rtc/rtc-wm831x.c b/drivers/rtc/rtc-wm831x.c
index 000c7e481e5..b16cfe57a48 100644
--- a/drivers/rtc/rtc-wm831x.c
+++ b/drivers/rtc/rtc-wm831x.c
@@ -16,6 +16,7 @@
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/time.h> 17#include <linux/time.h>
18#include <linux/rtc.h> 18#include <linux/rtc.h>
19#include <linux/slab.h>
19#include <linux/bcd.h> 20#include <linux/bcd.h>
20#include <linux/interrupt.h> 21#include <linux/interrupt.h>
21#include <linux/ioctl.h> 22#include <linux/ioctl.h>
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index bbea90baf98..acf222f91f5 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -1899,7 +1899,8 @@ restart:
1899 /* Process requests that may be recovered */ 1899 /* Process requests that may be recovered */
1900 if (cqr->status == DASD_CQR_NEED_ERP) { 1900 if (cqr->status == DASD_CQR_NEED_ERP) {
1901 erp_fn = base->discipline->erp_action(cqr); 1901 erp_fn = base->discipline->erp_action(cqr);
1902 erp_fn(cqr); 1902 if (IS_ERR(erp_fn(cqr)))
1903 continue;
1903 goto restart; 1904 goto restart;
1904 } 1905 }
1905 1906
diff --git a/drivers/s390/block/dasd_3990_erp.c b/drivers/s390/block/dasd_3990_erp.c
index 51224f76b98..6632649dd6a 100644
--- a/drivers/s390/block/dasd_3990_erp.c
+++ b/drivers/s390/block/dasd_3990_erp.c
@@ -10,7 +10,6 @@
10#define KMSG_COMPONENT "dasd-eckd" 10#define KMSG_COMPONENT "dasd-eckd"
11 11
12#include <linux/timer.h> 12#include <linux/timer.h>
13#include <linux/slab.h>
14#include <asm/idals.h> 13#include <asm/idals.h>
15 14
16#define PRINTK_HEADER "dasd_erp(3990): " 15#define PRINTK_HEADER "dasd_erp(3990): "
@@ -2287,7 +2286,8 @@ static struct dasd_ccw_req *dasd_3990_erp_add_erp(struct dasd_ccw_req *cqr)
2287 2286
2288 if (cqr->cpmode == 1) { 2287 if (cqr->cpmode == 1) {
2289 cplength = 0; 2288 cplength = 0;
2290 datasize = sizeof(struct tcw) + sizeof(struct tsb); 2289 /* TCW needs to be 64 byte aligned, so leave enough room */
2290 datasize = 64 + sizeof(struct tcw) + sizeof(struct tsb);
2291 } else { 2291 } else {
2292 cplength = 2; 2292 cplength = 2;
2293 datasize = 0; 2293 datasize = 0;
@@ -2309,15 +2309,15 @@ static struct dasd_ccw_req *dasd_3990_erp_add_erp(struct dasd_ccw_req *cqr)
2309 cqr->retries); 2309 cqr->retries);
2310 dasd_block_set_timer(device->block, (HZ << 3)); 2310 dasd_block_set_timer(device->block, (HZ << 3));
2311 } 2311 }
2312 return cqr; 2312 return erp;
2313 } 2313 }
2314 2314
2315 ccw = cqr->cpaddr; 2315 ccw = cqr->cpaddr;
2316 if (cqr->cpmode == 1) { 2316 if (cqr->cpmode == 1) {
2317 /* make a shallow copy of the original tcw but set new tsb */ 2317 /* make a shallow copy of the original tcw but set new tsb */
2318 erp->cpmode = 1; 2318 erp->cpmode = 1;
2319 erp->cpaddr = erp->data; 2319 erp->cpaddr = PTR_ALIGN(erp->data, 64);
2320 tcw = erp->data; 2320 tcw = erp->cpaddr;
2321 tsb = (struct tsb *) &tcw[1]; 2321 tsb = (struct tsb *) &tcw[1];
2322 *tcw = *((struct tcw *)cqr->cpaddr); 2322 *tcw = *((struct tcw *)cqr->cpaddr);
2323 tcw->tsb = (long)tsb; 2323 tcw->tsb = (long)tsb;
@@ -2372,6 +2372,9 @@ dasd_3990_erp_additional_erp(struct dasd_ccw_req * cqr)
2372 /* add erp and initialize with default TIC */ 2372 /* add erp and initialize with default TIC */
2373 erp = dasd_3990_erp_add_erp(cqr); 2373 erp = dasd_3990_erp_add_erp(cqr);
2374 2374
2375 if (IS_ERR(erp))
2376 return erp;
2377
2375 /* inspect sense, determine specific ERP if possible */ 2378 /* inspect sense, determine specific ERP if possible */
2376 if (erp != cqr) { 2379 if (erp != cqr) {
2377 2380
@@ -2711,6 +2714,8 @@ dasd_3990_erp_action(struct dasd_ccw_req * cqr)
2711 if (erp == NULL) { 2714 if (erp == NULL) {
2712 /* no matching erp found - set up erp */ 2715 /* no matching erp found - set up erp */
2713 erp = dasd_3990_erp_additional_erp(cqr); 2716 erp = dasd_3990_erp_additional_erp(cqr);
2717 if (IS_ERR(erp))
2718 return erp;
2714 } else { 2719 } else {
2715 /* matching erp found - set all leading erp's to DONE */ 2720 /* matching erp found - set all leading erp's to DONE */
2716 erp = dasd_3990_erp_handle_match_erp(cqr, erp); 2721 erp = dasd_3990_erp_handle_match_erp(cqr, erp);
diff --git a/drivers/s390/block/dasd_alias.c b/drivers/s390/block/dasd_alias.c
index 148b1dd2407..8c4814258e9 100644
--- a/drivers/s390/block/dasd_alias.c
+++ b/drivers/s390/block/dasd_alias.c
@@ -8,6 +8,7 @@
8#define KMSG_COMPONENT "dasd-eckd" 8#define KMSG_COMPONENT "dasd-eckd"
9 9
10#include <linux/list.h> 10#include <linux/list.h>
11#include <linux/slab.h>
11#include <asm/ebcdic.h> 12#include <asm/ebcdic.h>
12#include "dasd_int.h" 13#include "dasd_int.h"
13#include "dasd_eckd.h" 14#include "dasd_eckd.h"
diff --git a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c
index 8e23919c870..eff9c812c5c 100644
--- a/drivers/s390/block/dasd_devmap.c
+++ b/drivers/s390/block/dasd_devmap.c
@@ -18,6 +18,7 @@
18#include <linux/ctype.h> 18#include <linux/ctype.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/slab.h>
21 22
22#include <asm/debug.h> 23#include <asm/debug.h>
23#include <asm/uaccess.h> 24#include <asm/uaccess.h>
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index 01f4e7a34aa..0cb23311685 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -3155,11 +3155,11 @@ static void dasd_eckd_dump_sense_tcw(struct dasd_device *device,
3155 3155
3156 tsb = NULL; 3156 tsb = NULL;
3157 sense = NULL; 3157 sense = NULL;
3158 if (irb->scsw.tm.tcw) 3158 if (irb->scsw.tm.tcw && (irb->scsw.tm.fcxs == 0x01))
3159 tsb = tcw_get_tsb( 3159 tsb = tcw_get_tsb(
3160 (struct tcw *)(unsigned long)irb->scsw.tm.tcw); 3160 (struct tcw *)(unsigned long)irb->scsw.tm.tcw);
3161 3161
3162 if (tsb && (irb->scsw.tm.fcxs == 0x01)) { 3162 if (tsb) {
3163 len += sprintf(page + len, KERN_ERR PRINTK_HEADER 3163 len += sprintf(page + len, KERN_ERR PRINTK_HEADER
3164 " tsb->length %d\n", tsb->length); 3164 " tsb->length %d\n", tsb->length);
3165 len += sprintf(page + len, KERN_ERR PRINTK_HEADER 3165 len += sprintf(page + len, KERN_ERR PRINTK_HEADER
diff --git a/drivers/s390/block/dasd_eer.c b/drivers/s390/block/dasd_eer.c
index 1f3e967aaba..dd88803e489 100644
--- a/drivers/s390/block/dasd_eer.c
+++ b/drivers/s390/block/dasd_eer.c
@@ -19,6 +19,7 @@
19#include <linux/mutex.h> 19#include <linux/mutex.h>
20#include <linux/smp_lock.h> 20#include <linux/smp_lock.h>
21#include <linux/err.h> 21#include <linux/err.h>
22#include <linux/slab.h>
22 23
23#include <asm/uaccess.h> 24#include <asm/uaccess.h>
24#include <asm/atomic.h> 25#include <asm/atomic.h>
diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c
index 3479f8158a1..1557214944f 100644
--- a/drivers/s390/block/dasd_ioctl.c
+++ b/drivers/s390/block/dasd_ioctl.c
@@ -17,6 +17,7 @@
17#include <linux/fs.h> 17#include <linux/fs.h>
18#include <linux/blkpg.h> 18#include <linux/blkpg.h>
19#include <linux/smp_lock.h> 19#include <linux/smp_lock.h>
20#include <linux/slab.h>
20#include <asm/compat.h> 21#include <asm/compat.h>
21#include <asm/ccwdev.h> 22#include <asm/ccwdev.h>
22#include <asm/cmb.h> 23#include <asm/cmb.h>
diff --git a/drivers/s390/block/dasd_proc.c b/drivers/s390/block/dasd_proc.c
index f13a0bdd148..2eb02559280 100644
--- a/drivers/s390/block/dasd_proc.c
+++ b/drivers/s390/block/dasd_proc.c
@@ -14,6 +14,7 @@
14#define KMSG_COMPONENT "dasd" 14#define KMSG_COMPONENT "dasd"
15 15
16#include <linux/ctype.h> 16#include <linux/ctype.h>
17#include <linux/slab.h>
17#include <linux/string.h> 18#include <linux/string.h>
18#include <linux/seq_file.h> 19#include <linux/seq_file.h>
19#include <linux/vmalloc.h> 20#include <linux/vmalloc.h>
diff --git a/drivers/s390/block/xpram.c b/drivers/s390/block/xpram.c
index 118de392af6..c881a14fa5d 100644
--- a/drivers/s390/block/xpram.c
+++ b/drivers/s390/block/xpram.c
@@ -33,7 +33,6 @@
33#include <linux/ctype.h> /* isdigit, isxdigit */ 33#include <linux/ctype.h> /* isdigit, isxdigit */
34#include <linux/errno.h> 34#include <linux/errno.h>
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/slab.h>
37#include <linux/blkdev.h> 36#include <linux/blkdev.h>
38#include <linux/blkpg.h> 37#include <linux/blkpg.h>
39#include <linux/hdreg.h> /* HDIO_GETGEO */ 38#include <linux/hdreg.h> /* HDIO_GETGEO */
@@ -41,6 +40,7 @@
41#include <linux/bio.h> 40#include <linux/bio.h>
42#include <linux/suspend.h> 41#include <linux/suspend.h>
43#include <linux/platform_device.h> 42#include <linux/platform_device.h>
43#include <linux/gfp.h>
44#include <asm/uaccess.h> 44#include <asm/uaccess.h>
45 45
46#define XPRAM_NAME "xpram" 46#define XPRAM_NAME "xpram"
diff --git a/drivers/s390/char/con3270.c b/drivers/s390/char/con3270.c
index 6bca81aea39..bb07577e8fd 100644
--- a/drivers/s390/char/con3270.c
+++ b/drivers/s390/char/con3270.c
@@ -12,6 +12,7 @@
12#include <linux/interrupt.h> 12#include <linux/interrupt.h>
13#include <linux/list.h> 13#include <linux/list.h>
14#include <linux/types.h> 14#include <linux/types.h>
15#include <linux/slab.h>
15#include <linux/err.h> 16#include <linux/err.h>
16#include <linux/reboot.h> 17#include <linux/reboot.h>
17 18
diff --git a/drivers/s390/char/fs3270.c b/drivers/s390/char/fs3270.c
index 31c59b0d6df..0eabcca3c92 100644
--- a/drivers/s390/char/fs3270.c
+++ b/drivers/s390/char/fs3270.c
@@ -12,6 +12,7 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/interrupt.h> 13#include <linux/interrupt.h>
14#include <linux/list.h> 14#include <linux/list.h>
15#include <linux/slab.h>
15#include <linux/types.h> 16#include <linux/types.h>
16#include <linux/smp_lock.h> 17#include <linux/smp_lock.h>
17 18
diff --git a/drivers/s390/char/keyboard.c b/drivers/s390/char/keyboard.c
index cee4d4e4242..cb6bffe7141 100644
--- a/drivers/s390/char/keyboard.c
+++ b/drivers/s390/char/keyboard.c
@@ -9,6 +9,7 @@
9 9
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/sched.h> 11#include <linux/sched.h>
12#include <linux/slab.h>
12#include <linux/sysrq.h> 13#include <linux/sysrq.h>
13 14
14#include <linux/consolemap.h> 15#include <linux/consolemap.h>
diff --git a/drivers/s390/char/monreader.c b/drivers/s390/char/monreader.c
index 33e96484d54..2ed3f82e5c3 100644
--- a/drivers/s390/char/monreader.c
+++ b/drivers/s390/char/monreader.c
@@ -21,6 +21,7 @@
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/poll.h> 22#include <linux/poll.h>
23#include <linux/device.h> 23#include <linux/device.h>
24#include <linux/slab.h>
24#include <net/iucv/iucv.h> 25#include <net/iucv/iucv.h>
25#include <asm/uaccess.h> 26#include <asm/uaccess.h>
26#include <asm/ebcdic.h> 27#include <asm/ebcdic.h>
diff --git a/drivers/s390/char/monwriter.c b/drivers/s390/char/monwriter.c
index 668a0579b26..98a49dfda1d 100644
--- a/drivers/s390/char/monwriter.c
+++ b/drivers/s390/char/monwriter.c
@@ -20,6 +20,7 @@
20#include <linux/poll.h> 20#include <linux/poll.h>
21#include <linux/mutex.h> 21#include <linux/mutex.h>
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/slab.h>
23#include <asm/uaccess.h> 24#include <asm/uaccess.h>
24#include <asm/ebcdic.h> 25#include <asm/ebcdic.h>
25#include <asm/io.h> 26#include <asm/io.h>
diff --git a/drivers/s390/char/sclp_async.c b/drivers/s390/char/sclp_async.c
index 740fe405c39..7ad30e72f86 100644
--- a/drivers/s390/char/sclp_async.c
+++ b/drivers/s390/char/sclp_async.c
@@ -11,6 +11,7 @@
11#include <linux/device.h> 11#include <linux/device.h>
12#include <linux/stat.h> 12#include <linux/stat.h>
13#include <linux/string.h> 13#include <linux/string.h>
14#include <linux/slab.h>
14#include <linux/ctype.h> 15#include <linux/ctype.h>
15#include <linux/kmod.h> 16#include <linux/kmod.h>
16#include <linux/err.h> 17#include <linux/err.h>
@@ -84,6 +85,7 @@ static int proc_handler_callhome(struct ctl_table *ctl, int write,
84 rc = copy_from_user(buf, buffer, sizeof(buf)); 85 rc = copy_from_user(buf, buffer, sizeof(buf));
85 if (rc != 0) 86 if (rc != 0)
86 return -EFAULT; 87 return -EFAULT;
88 buf[sizeof(buf) - 1] = '\0';
87 if (strict_strtoul(buf, 0, &val) != 0) 89 if (strict_strtoul(buf, 0, &val) != 0)
88 return -EINVAL; 90 return -EINVAL;
89 if (val != 0 && val != 1) 91 if (val != 0 && val != 1)
diff --git a/drivers/s390/char/sclp_cmd.c b/drivers/s390/char/sclp_cmd.c
index fc7ae05ce48..4b60ede07f0 100644
--- a/drivers/s390/char/sclp_cmd.c
+++ b/drivers/s390/char/sclp_cmd.c
@@ -308,6 +308,13 @@ struct assign_storage_sccb {
308 u16 rn; 308 u16 rn;
309} __packed; 309} __packed;
310 310
311int arch_get_memory_phys_device(unsigned long start_pfn)
312{
313 if (!rzm)
314 return 0;
315 return PFN_PHYS(start_pfn) >> ilog2(rzm);
316}
317
311static unsigned long long rn2addr(u16 rn) 318static unsigned long long rn2addr(u16 rn)
312{ 319{
313 return (unsigned long long) (rn - 1) * rzm; 320 return (unsigned long long) (rn - 1) * rzm;
@@ -704,13 +711,6 @@ int sclp_chp_deconfigure(struct chp_id chpid)
704 return do_chp_configure(SCLP_CMDW_DECONFIGURE_CHPATH | chpid.id << 8); 711 return do_chp_configure(SCLP_CMDW_DECONFIGURE_CHPATH | chpid.id << 8);
705} 712}
706 713
707int arch_get_memory_phys_device(unsigned long start_pfn)
708{
709 if (!rzm)
710 return 0;
711 return PFN_PHYS(start_pfn) / rzm;
712}
713
714struct chp_info_sccb { 714struct chp_info_sccb {
715 struct sccb_header header; 715 struct sccb_header header;
716 u8 recognized[SCLP_CHP_INFO_MASK_SIZE]; 716 u8 recognized[SCLP_CHP_INFO_MASK_SIZE];
diff --git a/drivers/s390/char/sclp_con.c b/drivers/s390/char/sclp_con.c
index ad698d30cb3..ecf45c54f8c 100644
--- a/drivers/s390/char/sclp_con.c
+++ b/drivers/s390/char/sclp_con.c
@@ -14,6 +14,7 @@
14#include <linux/termios.h> 14#include <linux/termios.h>
15#include <linux/err.h> 15#include <linux/err.h>
16#include <linux/reboot.h> 16#include <linux/reboot.h>
17#include <linux/gfp.h>
17 18
18#include "sclp.h" 19#include "sclp.h"
19#include "sclp_rw.h" 20#include "sclp_rw.h"
diff --git a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c
index 434ba04b130..8258d590505 100644
--- a/drivers/s390/char/sclp_tty.c
+++ b/drivers/s390/char/sclp_tty.c
@@ -13,10 +13,10 @@
13#include <linux/tty.h> 13#include <linux/tty.h>
14#include <linux/tty_driver.h> 14#include <linux/tty_driver.h>
15#include <linux/tty_flip.h> 15#include <linux/tty_flip.h>
16#include <linux/slab.h>
17#include <linux/err.h> 16#include <linux/err.h>
18#include <linux/init.h> 17#include <linux/init.h>
19#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/gfp.h>
20#include <asm/uaccess.h> 20#include <asm/uaccess.h>
21 21
22#include "ctrlchar.h" 22#include "ctrlchar.h"
diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c
index 3796ffdb847..5d706e6c946 100644
--- a/drivers/s390/char/sclp_vt220.c
+++ b/drivers/s390/char/sclp_vt220.c
@@ -23,6 +23,7 @@
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/reboot.h> 25#include <linux/reboot.h>
26#include <linux/slab.h>
26 27
27#include <asm/uaccess.h> 28#include <asm/uaccess.h>
28#include "sclp.h" 29#include "sclp.h"
diff --git a/drivers/s390/char/tape_34xx.c b/drivers/s390/char/tape_34xx.c
index cb70fa1cf53..c17f35b6136 100644
--- a/drivers/s390/char/tape_34xx.c
+++ b/drivers/s390/char/tape_34xx.c
@@ -15,6 +15,7 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/bio.h> 16#include <linux/bio.h>
17#include <linux/workqueue.h> 17#include <linux/workqueue.h>
18#include <linux/slab.h>
18 19
19#define TAPE_DBF_AREA tape_34xx_dbf 20#define TAPE_DBF_AREA tape_34xx_dbf
20 21
diff --git a/drivers/s390/char/tape_3590.c b/drivers/s390/char/tape_3590.c
index 9821c588661..fc993acf99b 100644
--- a/drivers/s390/char/tape_3590.c
+++ b/drivers/s390/char/tape_3590.c
@@ -12,6 +12,7 @@
12#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt 12#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
13 13
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/slab.h>
15#include <linux/init.h> 16#include <linux/init.h>
16#include <linux/bio.h> 17#include <linux/bio.h>
17#include <asm/ebcdic.h> 18#include <asm/ebcdic.h>
diff --git a/drivers/s390/char/tape_class.c b/drivers/s390/char/tape_class.c
index b2864e3edb6..55343df61ed 100644
--- a/drivers/s390/char/tape_class.c
+++ b/drivers/s390/char/tape_class.c
@@ -11,6 +11,8 @@
11#define KMSG_COMPONENT "tape" 11#define KMSG_COMPONENT "tape"
12#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt 12#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
13 13
14#include <linux/slab.h>
15
14#include "tape_class.h" 16#include "tape_class.h"
15 17
16MODULE_AUTHOR("Stefan Bader <shbader@de.ibm.com>"); 18MODULE_AUTHOR("Stefan Bader <shbader@de.ibm.com>");
diff --git a/drivers/s390/char/tape_core.c b/drivers/s390/char/tape_core.c
index 81b094e480e..29c2d73d719 100644
--- a/drivers/s390/char/tape_core.c
+++ b/drivers/s390/char/tape_core.c
@@ -20,6 +20,7 @@
20#include <linux/spinlock.h> // for locks 20#include <linux/spinlock.h> // for locks
21#include <linux/vmalloc.h> 21#include <linux/vmalloc.h>
22#include <linux/list.h> 22#include <linux/list.h>
23#include <linux/slab.h>
23 24
24#include <asm/types.h> // for variable types 25#include <asm/types.h> // for variable types
25 26
diff --git a/drivers/s390/char/vmcp.c b/drivers/s390/char/vmcp.c
index 921dcda7767..5bb59d36a6d 100644
--- a/drivers/s390/char/vmcp.c
+++ b/drivers/s390/char/vmcp.c
@@ -19,6 +19,7 @@
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/miscdevice.h> 20#include <linux/miscdevice.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/slab.h>
22#include <asm/compat.h> 23#include <asm/compat.h>
23#include <asm/cpcmd.h> 24#include <asm/cpcmd.h>
24#include <asm/debug.h> 25#include <asm/debug.h>
diff --git a/drivers/s390/char/vmlogrdr.c b/drivers/s390/char/vmlogrdr.c
index 7dfa5412d5a..e40a1b89286 100644
--- a/drivers/s390/char/vmlogrdr.c
+++ b/drivers/s390/char/vmlogrdr.c
@@ -16,6 +16,7 @@
16 16
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/slab.h>
19#include <linux/errno.h> 20#include <linux/errno.h>
20#include <linux/types.h> 21#include <linux/types.h>
21#include <linux/interrupt.h> 22#include <linux/interrupt.h>
diff --git a/drivers/s390/char/vmur.c b/drivers/s390/char/vmur.c
index cc56fc708ba..1de672f2103 100644
--- a/drivers/s390/char/vmur.c
+++ b/drivers/s390/char/vmur.c
@@ -12,6 +12,7 @@
12#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt 12#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
13 13
14#include <linux/cdev.h> 14#include <linux/cdev.h>
15#include <linux/slab.h>
15#include <linux/smp_lock.h> 16#include <linux/smp_lock.h>
16 17
17#include <asm/uaccess.h> 18#include <asm/uaccess.h>
diff --git a/drivers/s390/char/vmwatchdog.c b/drivers/s390/char/vmwatchdog.c
index c974058e48d..e13508c98b1 100644
--- a/drivers/s390/char/vmwatchdog.c
+++ b/drivers/s390/char/vmwatchdog.c
@@ -17,6 +17,7 @@
17#include <linux/miscdevice.h> 17#include <linux/miscdevice.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/moduleparam.h> 19#include <linux/moduleparam.h>
20#include <linux/slab.h>
20#include <linux/suspend.h> 21#include <linux/suspend.h>
21#include <linux/watchdog.h> 22#include <linux/watchdog.h>
22 23
diff --git a/drivers/s390/char/zcore.c b/drivers/s390/char/zcore.c
index 3438658b66b..7217966f7d3 100644
--- a/drivers/s390/char/zcore.c
+++ b/drivers/s390/char/zcore.c
@@ -13,6 +13,7 @@
13#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt 13#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
14 14
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/slab.h>
16#include <linux/miscdevice.h> 17#include <linux/miscdevice.h>
17#include <linux/debugfs.h> 18#include <linux/debugfs.h>
18#include <asm/asm-offsets.h> 19#include <asm/asm-offsets.h>
@@ -141,33 +142,6 @@ static int memcpy_hsa_kernel(void *dest, unsigned long src, size_t count)
141 return memcpy_hsa(dest, src, count, TO_KERNEL); 142 return memcpy_hsa(dest, src, count, TO_KERNEL);
142} 143}
143 144
144static int memcpy_real(void *dest, unsigned long src, size_t count)
145{
146 unsigned long flags;
147 int rc = -EFAULT;
148 register unsigned long _dest asm("2") = (unsigned long) dest;
149 register unsigned long _len1 asm("3") = (unsigned long) count;
150 register unsigned long _src asm("4") = src;
151 register unsigned long _len2 asm("5") = (unsigned long) count;
152
153 if (count == 0)
154 return 0;
155 flags = __raw_local_irq_stnsm(0xf8UL); /* switch to real mode */
156 asm volatile (
157 "0: mvcle %1,%2,0x0\n"
158 "1: jo 0b\n"
159 " lhi %0,0x0\n"
160 "2:\n"
161 EX_TABLE(1b,2b)
162 : "+d" (rc), "+d" (_dest), "+d" (_src), "+d" (_len1),
163 "+d" (_len2), "=m" (*((long*)dest))
164 : "m" (*((long*)src))
165 : "cc", "memory");
166 __raw_local_irq_ssm(flags);
167
168 return rc;
169}
170
171static int memcpy_real_user(void __user *dest, unsigned long src, size_t count) 145static int memcpy_real_user(void __user *dest, unsigned long src, size_t count)
172{ 146{
173 static char buf[4096]; 147 static char buf[4096];
@@ -175,7 +149,7 @@ static int memcpy_real_user(void __user *dest, unsigned long src, size_t count)
175 149
176 while (offs < count) { 150 while (offs < count) {
177 size = min(sizeof(buf), count - offs); 151 size = min(sizeof(buf), count - offs);
178 if (memcpy_real(buf, src + offs, size)) 152 if (memcpy_real(buf, (void *) src + offs, size))
179 return -EFAULT; 153 return -EFAULT;
180 if (copy_to_user(dest + offs, buf, size)) 154 if (copy_to_user(dest + offs, buf, size))
181 return -EFAULT; 155 return -EFAULT;
@@ -663,12 +637,8 @@ static int __init zcore_reipl_init(void)
663 if (ipib_info.ipib < ZFCPDUMP_HSA_SIZE) 637 if (ipib_info.ipib < ZFCPDUMP_HSA_SIZE)
664 rc = memcpy_hsa_kernel(ipl_block, ipib_info.ipib, PAGE_SIZE); 638 rc = memcpy_hsa_kernel(ipl_block, ipib_info.ipib, PAGE_SIZE);
665 else 639 else
666 rc = memcpy_real(ipl_block, ipib_info.ipib, PAGE_SIZE); 640 rc = memcpy_real(ipl_block, (void *) ipib_info.ipib, PAGE_SIZE);
667 if (rc) { 641 if (rc || csum_partial(ipl_block, ipl_block->hdr.len, 0) !=
668 free_page((unsigned long) ipl_block);
669 return rc;
670 }
671 if (csum_partial(ipl_block, ipl_block->hdr.len, 0) !=
672 ipib_info.checksum) { 642 ipib_info.checksum) {
673 TRACE("Checksum does not match\n"); 643 TRACE("Checksum does not match\n");
674 free_page((unsigned long) ipl_block); 644 free_page((unsigned long) ipl_block);
diff --git a/drivers/s390/cio/blacklist.c b/drivers/s390/cio/blacklist.c
index 7eab9ab9f40..13cb60162e4 100644
--- a/drivers/s390/cio/blacklist.c
+++ b/drivers/s390/cio/blacklist.c
@@ -14,7 +14,6 @@
14 14
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/vmalloc.h> 16#include <linux/vmalloc.h>
17#include <linux/slab.h>
18#include <linux/proc_fs.h> 17#include <linux/proc_fs.h>
19#include <linux/seq_file.h> 18#include <linux/seq_file.h>
20#include <linux/ctype.h> 19#include <linux/ctype.h>
diff --git a/drivers/s390/cio/chp.c b/drivers/s390/cio/chp.c
index c268a2e5b7c..1d16189f2f2 100644
--- a/drivers/s390/cio/chp.c
+++ b/drivers/s390/cio/chp.c
@@ -15,6 +15,7 @@
15#include <linux/wait.h> 15#include <linux/wait.h>
16#include <linux/mutex.h> 16#include <linux/mutex.h>
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <linux/slab.h>
18#include <asm/chpid.h> 19#include <asm/chpid.h>
19#include <asm/sclp.h> 20#include <asm/sclp.h>
20#include <asm/crw.h> 21#include <asm/crw.h>
diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c
index 4038f5b4f14..ce7cb87479f 100644
--- a/drivers/s390/cio/chsc.c
+++ b/drivers/s390/cio/chsc.c
@@ -29,6 +29,7 @@
29#include "chsc.h" 29#include "chsc.h"
30 30
31static void *sei_page; 31static void *sei_page;
32static DEFINE_SPINLOCK(sda_lock);
32 33
33/** 34/**
34 * chsc_error_from_response() - convert a chsc response to an error 35 * chsc_error_from_response() - convert a chsc response to an error
@@ -832,11 +833,10 @@ void __init chsc_free_sei_area(void)
832 kfree(sei_page); 833 kfree(sei_page);
833} 834}
834 835
835int __init 836int chsc_enable_facility(int operation_code)
836chsc_enable_facility(int operation_code)
837{ 837{
838 int ret; 838 int ret;
839 struct { 839 static struct {
840 struct chsc_header request; 840 struct chsc_header request;
841 u8 reserved1:4; 841 u8 reserved1:4;
842 u8 format:4; 842 u8 format:4;
@@ -849,33 +849,32 @@ chsc_enable_facility(int operation_code)
849 u32 reserved5:4; 849 u32 reserved5:4;
850 u32 format2:4; 850 u32 format2:4;
851 u32 reserved6:24; 851 u32 reserved6:24;
852 } __attribute__ ((packed)) *sda_area; 852 } __attribute__ ((packed, aligned(4096))) sda_area;
853 853
854 sda_area = (void *)get_zeroed_page(GFP_KERNEL|GFP_DMA); 854 spin_lock(&sda_lock);
855 if (!sda_area) 855 memset(&sda_area, 0, sizeof(sda_area));
856 return -ENOMEM; 856 sda_area.request.length = 0x0400;
857 sda_area->request.length = 0x0400; 857 sda_area.request.code = 0x0031;
858 sda_area->request.code = 0x0031; 858 sda_area.operation_code = operation_code;
859 sda_area->operation_code = operation_code;
860 859
861 ret = chsc(sda_area); 860 ret = chsc(&sda_area);
862 if (ret > 0) { 861 if (ret > 0) {
863 ret = (ret == 3) ? -ENODEV : -EBUSY; 862 ret = (ret == 3) ? -ENODEV : -EBUSY;
864 goto out; 863 goto out;
865 } 864 }
866 865
867 switch (sda_area->response.code) { 866 switch (sda_area.response.code) {
868 case 0x0101: 867 case 0x0101:
869 ret = -EOPNOTSUPP; 868 ret = -EOPNOTSUPP;
870 break; 869 break;
871 default: 870 default:
872 ret = chsc_error_from_response(sda_area->response.code); 871 ret = chsc_error_from_response(sda_area.response.code);
873 } 872 }
874 if (ret != 0) 873 if (ret != 0)
875 CIO_CRW_EVENT(2, "chsc: sda (oc=%x) failed (rc=%04x)\n", 874 CIO_CRW_EVENT(2, "chsc: sda (oc=%x) failed (rc=%04x)\n",
876 operation_code, sda_area->response.code); 875 operation_code, sda_area.response.code);
877 out: 876 out:
878 free_page((unsigned long)sda_area); 877 spin_unlock(&sda_lock);
879 return ret; 878 return ret;
880} 879}
881 880
diff --git a/drivers/s390/cio/chsc_sch.c b/drivers/s390/cio/chsc_sch.c
index 852612f5dba..3b6f4adc509 100644
--- a/drivers/s390/cio/chsc_sch.c
+++ b/drivers/s390/cio/chsc_sch.c
@@ -7,6 +7,7 @@
7 * 7 *
8 */ 8 */
9 9
10#include <linux/slab.h>
10#include <linux/device.h> 11#include <linux/device.h>
11#include <linux/module.h> 12#include <linux/module.h>
12#include <linux/uaccess.h> 13#include <linux/uaccess.h>
@@ -123,7 +124,7 @@ static int chsc_subchannel_prepare(struct subchannel *sch)
123 * since we don't have a way to clear the subchannel and 124 * since we don't have a way to clear the subchannel and
124 * cannot disable it with a request running. 125 * cannot disable it with a request running.
125 */ 126 */
126 cc = stsch(sch->schid, &schib); 127 cc = stsch_err(sch->schid, &schib);
127 if (!cc && scsw_stctl(&schib.scsw)) 128 if (!cc && scsw_stctl(&schib.scsw))
128 return -EAGAIN; 129 return -EAGAIN;
129 return 0; 130 return 0;
diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c
index f736cdcf08a..5feea1a371e 100644
--- a/drivers/s390/cio/cio.c
+++ b/drivers/s390/cio/cio.c
@@ -361,7 +361,7 @@ int cio_commit_config(struct subchannel *sch)
361 struct schib schib; 361 struct schib schib;
362 int ccode, retry, ret = 0; 362 int ccode, retry, ret = 0;
363 363
364 if (stsch(sch->schid, &schib) || !css_sch_is_valid(&schib)) 364 if (stsch_err(sch->schid, &schib) || !css_sch_is_valid(&schib))
365 return -ENODEV; 365 return -ENODEV;
366 366
367 for (retry = 0; retry < 5; retry++) { 367 for (retry = 0; retry < 5; retry++) {
@@ -372,7 +372,7 @@ int cio_commit_config(struct subchannel *sch)
372 return ccode; 372 return ccode;
373 switch (ccode) { 373 switch (ccode) {
374 case 0: /* successful */ 374 case 0: /* successful */
375 if (stsch(sch->schid, &schib) || 375 if (stsch_err(sch->schid, &schib) ||
376 !css_sch_is_valid(&schib)) 376 !css_sch_is_valid(&schib))
377 return -ENODEV; 377 return -ENODEV;
378 if (cio_check_config(sch, &schib)) { 378 if (cio_check_config(sch, &schib)) {
@@ -404,7 +404,7 @@ int cio_update_schib(struct subchannel *sch)
404{ 404{
405 struct schib schib; 405 struct schib schib;
406 406
407 if (stsch(sch->schid, &schib) || !css_sch_is_valid(&schib)) 407 if (stsch_err(sch->schid, &schib) || !css_sch_is_valid(&schib))
408 return -ENODEV; 408 return -ENODEV;
409 409
410 memcpy(&sch->schib, &schib, sizeof(schib)); 410 memcpy(&sch->schib, &schib, sizeof(schib));
@@ -771,7 +771,7 @@ cio_get_console_sch_no(void)
771 if (console_irq != -1) { 771 if (console_irq != -1) {
772 /* VM provided us with the irq number of the console. */ 772 /* VM provided us with the irq number of the console. */
773 schid.sch_no = console_irq; 773 schid.sch_no = console_irq;
774 if (stsch(schid, &console_subchannel.schib) != 0 || 774 if (stsch_err(schid, &console_subchannel.schib) != 0 ||
775 (console_subchannel.schib.pmcw.st != SUBCHANNEL_TYPE_IO) || 775 (console_subchannel.schib.pmcw.st != SUBCHANNEL_TYPE_IO) ||
776 !console_subchannel.schib.pmcw.dnv) 776 !console_subchannel.schib.pmcw.dnv)
777 return -1; 777 return -1;
@@ -863,10 +863,10 @@ __disable_subchannel_easy(struct subchannel_id schid, struct schib *schib)
863 cc = 0; 863 cc = 0;
864 for (retry=0;retry<3;retry++) { 864 for (retry=0;retry<3;retry++) {
865 schib->pmcw.ena = 0; 865 schib->pmcw.ena = 0;
866 cc = msch(schid, schib); 866 cc = msch_err(schid, schib);
867 if (cc) 867 if (cc)
868 return (cc==3?-ENODEV:-EBUSY); 868 return (cc==3?-ENODEV:-EBUSY);
869 if (stsch(schid, schib) || !css_sch_is_valid(schib)) 869 if (stsch_err(schid, schib) || !css_sch_is_valid(schib))
870 return -ENODEV; 870 return -ENODEV;
871 if (!schib->pmcw.ena) 871 if (!schib->pmcw.ena)
872 return 0; 872 return 0;
@@ -913,7 +913,7 @@ static int stsch_reset(struct subchannel_id schid, struct schib *addr)
913 913
914 pgm_check_occured = 0; 914 pgm_check_occured = 0;
915 s390_base_pgm_handler_fn = cio_reset_pgm_check_handler; 915 s390_base_pgm_handler_fn = cio_reset_pgm_check_handler;
916 rc = stsch(schid, addr); 916 rc = stsch_err(schid, addr);
917 s390_base_pgm_handler_fn = NULL; 917 s390_base_pgm_handler_fn = NULL;
918 918
919 /* The program check handler could have changed pgm_check_occured. */ 919 /* The program check handler could have changed pgm_check_occured. */
@@ -950,7 +950,7 @@ static int __shutdown_subchannel_easy(struct subchannel_id schid, void *data)
950 /* No default clear strategy */ 950 /* No default clear strategy */
951 break; 951 break;
952 } 952 }
953 stsch(schid, &schib); 953 stsch_err(schid, &schib);
954 __disable_subchannel_easy(schid, &schib); 954 __disable_subchannel_easy(schid, &schib);
955 } 955 }
956out: 956out:
@@ -1086,7 +1086,7 @@ int __init cio_get_iplinfo(struct cio_iplinfo *iplinfo)
1086 schid = *(struct subchannel_id *)&S390_lowcore.subchannel_id; 1086 schid = *(struct subchannel_id *)&S390_lowcore.subchannel_id;
1087 if (!schid.one) 1087 if (!schid.one)
1088 return -ENODEV; 1088 return -ENODEV;
1089 if (stsch(schid, &schib)) 1089 if (stsch_err(schid, &schib))
1090 return -ENODEV; 1090 return -ENODEV;
1091 if (schib.pmcw.st != SUBCHANNEL_TYPE_IO) 1091 if (schib.pmcw.st != SUBCHANNEL_TYPE_IO)
1092 return -ENODEV; 1092 return -ENODEV;
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index 2769da54f2b..511649115bd 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -870,15 +870,10 @@ static int __init css_bus_init(void)
870 870
871 /* Try to enable MSS. */ 871 /* Try to enable MSS. */
872 ret = chsc_enable_facility(CHSC_SDA_OC_MSS); 872 ret = chsc_enable_facility(CHSC_SDA_OC_MSS);
873 switch (ret) { 873 if (ret)
874 case 0: /* Success. */
875 max_ssid = __MAX_SSID;
876 break;
877 case -ENOMEM:
878 goto out;
879 default:
880 max_ssid = 0; 874 max_ssid = 0;
881 } 875 else /* Success. */
876 max_ssid = __MAX_SSID;
882 877
883 ret = slow_subchannel_init(); 878 ret = slow_subchannel_init();
884 if (ret) 879 if (ret)
@@ -1048,6 +1043,11 @@ static int __init channel_subsystem_init_sync(void)
1048} 1043}
1049subsys_initcall_sync(channel_subsystem_init_sync); 1044subsys_initcall_sync(channel_subsystem_init_sync);
1050 1045
1046void channel_subsystem_reinit(void)
1047{
1048 chsc_enable_facility(CHSC_SDA_OC_MSS);
1049}
1050
1051#ifdef CONFIG_PROC_FS 1051#ifdef CONFIG_PROC_FS
1052static ssize_t cio_settle_write(struct file *file, const char __user *buf, 1052static ssize_t cio_settle_write(struct file *file, const char __user *buf,
1053 size_t count, loff_t *ppos) 1053 size_t count, loff_t *ppos)
diff --git a/drivers/s390/cio/device_fsm.c b/drivers/s390/cio/device_fsm.c
index c56ab94612f..c9b852647f0 100644
--- a/drivers/s390/cio/device_fsm.c
+++ b/drivers/s390/cio/device_fsm.c
@@ -45,7 +45,7 @@ static void ccw_timeout_log(struct ccw_device *cdev)
45 sch = to_subchannel(cdev->dev.parent); 45 sch = to_subchannel(cdev->dev.parent);
46 private = to_io_private(sch); 46 private = to_io_private(sch);
47 orb = &private->orb; 47 orb = &private->orb;
48 cc = stsch(sch->schid, &schib); 48 cc = stsch_err(sch->schid, &schib);
49 49
50 printk(KERN_WARNING "cio: ccw device timeout occurred at %llx, " 50 printk(KERN_WARNING "cio: ccw device timeout occurred at %llx, "
51 "device information:\n", get_clock()); 51 "device information:\n", get_clock());
diff --git a/drivers/s390/cio/qdio_main.c b/drivers/s390/cio/qdio_main.c
index 4f8f7431177..88be7b9ea6e 100644
--- a/drivers/s390/cio/qdio_main.c
+++ b/drivers/s390/cio/qdio_main.c
@@ -13,6 +13,7 @@
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/timer.h> 14#include <linux/timer.h>
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/gfp.h>
16#include <asm/atomic.h> 17#include <asm/atomic.h>
17#include <asm/debug.h> 18#include <asm/debug.h>
18#include <asm/qdio.h> 19#include <asm/qdio.h>
diff --git a/drivers/s390/cio/qdio_thinint.c b/drivers/s390/cio/qdio_thinint.c
index 9942c1031b2..ce5f8910ff8 100644
--- a/drivers/s390/cio/qdio_thinint.c
+++ b/drivers/s390/cio/qdio_thinint.c
@@ -7,6 +7,7 @@
7 * Jan Glauber <jang@linux.vnet.ibm.com> 7 * Jan Glauber <jang@linux.vnet.ibm.com>
8 */ 8 */
9#include <linux/io.h> 9#include <linux/io.h>
10#include <linux/slab.h>
10#include <asm/atomic.h> 11#include <asm/atomic.h>
11#include <asm/debug.h> 12#include <asm/debug.h>
12#include <asm/qdio.h> 13#include <asm/qdio.h>
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c
index 20836eff88c..91c6028d7b7 100644
--- a/drivers/s390/crypto/ap_bus.c
+++ b/drivers/s390/crypto/ap_bus.c
@@ -33,6 +33,7 @@
33#include <linux/err.h> 33#include <linux/err.h>
34#include <linux/interrupt.h> 34#include <linux/interrupt.h>
35#include <linux/workqueue.h> 35#include <linux/workqueue.h>
36#include <linux/slab.h>
36#include <linux/notifier.h> 37#include <linux/notifier.h>
37#include <linux/kthread.h> 38#include <linux/kthread.h>
38#include <linux/mutex.h> 39#include <linux/mutex.h>
diff --git a/drivers/s390/crypto/zcrypt_api.c b/drivers/s390/crypto/zcrypt_api.c
index ba50fe02e57..304caf54997 100644
--- a/drivers/s390/crypto/zcrypt_api.c
+++ b/drivers/s390/crypto/zcrypt_api.c
@@ -36,6 +36,7 @@
36#include <linux/seq_file.h> 36#include <linux/seq_file.h>
37#include <linux/compat.h> 37#include <linux/compat.h>
38#include <linux/smp_lock.h> 38#include <linux/smp_lock.h>
39#include <linux/slab.h>
39#include <asm/atomic.h> 40#include <asm/atomic.h>
40#include <asm/uaccess.h> 41#include <asm/uaccess.h>
41#include <linux/hw_random.h> 42#include <linux/hw_random.h>
diff --git a/drivers/s390/crypto/zcrypt_cex2a.c b/drivers/s390/crypto/zcrypt_cex2a.c
index c6fb0aa8950..9c409efa1ec 100644
--- a/drivers/s390/crypto/zcrypt_cex2a.c
+++ b/drivers/s390/crypto/zcrypt_cex2a.c
@@ -27,6 +27,7 @@
27 */ 27 */
28 28
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/slab.h>
30#include <linux/init.h> 31#include <linux/init.h>
31#include <linux/err.h> 32#include <linux/err.h>
32#include <asm/atomic.h> 33#include <asm/atomic.h>
diff --git a/drivers/s390/crypto/zcrypt_pcica.c b/drivers/s390/crypto/zcrypt_pcica.c
index e78df3671ca..09e934b295a 100644
--- a/drivers/s390/crypto/zcrypt_pcica.c
+++ b/drivers/s390/crypto/zcrypt_pcica.c
@@ -27,6 +27,7 @@
27 */ 27 */
28 28
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/slab.h>
30#include <linux/init.h> 31#include <linux/init.h>
31#include <linux/err.h> 32#include <linux/err.h>
32#include <asm/atomic.h> 33#include <asm/atomic.h>
diff --git a/drivers/s390/crypto/zcrypt_pcicc.c b/drivers/s390/crypto/zcrypt_pcicc.c
index 142f72a2ca5..9dec5c77cff 100644
--- a/drivers/s390/crypto/zcrypt_pcicc.c
+++ b/drivers/s390/crypto/zcrypt_pcicc.c
@@ -28,6 +28,7 @@
28 28
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/gfp.h>
31#include <linux/err.h> 32#include <linux/err.h>
32#include <asm/atomic.h> 33#include <asm/atomic.h>
33#include <asm/uaccess.h> 34#include <asm/uaccess.h>
diff --git a/drivers/s390/crypto/zcrypt_pcixcc.c b/drivers/s390/crypto/zcrypt_pcixcc.c
index 68f3e6204db..510fab4577d 100644
--- a/drivers/s390/crypto/zcrypt_pcixcc.c
+++ b/drivers/s390/crypto/zcrypt_pcixcc.c
@@ -30,6 +30,7 @@
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/err.h> 31#include <linux/err.h>
32#include <linux/delay.h> 32#include <linux/delay.h>
33#include <linux/slab.h>
33#include <asm/atomic.h> 34#include <asm/atomic.h>
34#include <asm/uaccess.h> 35#include <asm/uaccess.h>
35 36
diff --git a/drivers/s390/kvm/kvm_virtio.c b/drivers/s390/kvm/kvm_virtio.c
index b2fc4fd63f7..4e298bc8949 100644
--- a/drivers/s390/kvm/kvm_virtio.c
+++ b/drivers/s390/kvm/kvm_virtio.c
@@ -15,6 +15,7 @@
15#include <linux/err.h> 15#include <linux/err.h>
16#include <linux/virtio.h> 16#include <linux/virtio.h>
17#include <linux/virtio_config.h> 17#include <linux/virtio_config.h>
18#include <linux/slab.h>
18#include <linux/virtio_console.h> 19#include <linux/virtio_console.h>
19#include <linux/interrupt.h> 20#include <linux/interrupt.h>
20#include <linux/virtio_ring.h> 21#include <linux/virtio_ring.h>
diff --git a/drivers/s390/net/ctcm_dbug.c b/drivers/s390/net/ctcm_dbug.c
index 1ca58f15347..d962fd741a2 100644
--- a/drivers/s390/net/ctcm_dbug.c
+++ b/drivers/s390/net/ctcm_dbug.c
@@ -10,7 +10,6 @@
10#include <linux/string.h> 10#include <linux/string.h>
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/errno.h> 12#include <linux/errno.h>
13#include <linux/slab.h>
14#include <linux/ctype.h> 13#include <linux/ctype.h>
15#include <linux/sysctl.h> 14#include <linux/sysctl.h>
16#include <linux/module.h> 15#include <linux/module.h>
diff --git a/drivers/s390/net/ctcm_sysfs.c b/drivers/s390/net/ctcm_sysfs.c
index 738ad26c74a..2b24550e865 100644
--- a/drivers/s390/net/ctcm_sysfs.c
+++ b/drivers/s390/net/ctcm_sysfs.c
@@ -14,6 +14,7 @@
14#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt 14#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
15 15
16#include <linux/sysfs.h> 16#include <linux/sysfs.h>
17#include <linux/slab.h>
17#include "ctcm_main.h" 18#include "ctcm_main.h"
18 19
19/* 20/*
diff --git a/drivers/s390/net/fsm.c b/drivers/s390/net/fsm.c
index cae48cbc5e9..e5dea67f902 100644
--- a/drivers/s390/net/fsm.c
+++ b/drivers/s390/net/fsm.c
@@ -5,6 +5,7 @@
5 5
6#include "fsm.h" 6#include "fsm.h"
7#include <linux/module.h> 7#include <linux/module.h>
8#include <linux/slab.h>
8#include <linux/timer.h> 9#include <linux/timer.h>
9 10
10MODULE_AUTHOR("(C) 2000 IBM Corp. by Fritz Elfert (felfert@millenux.com)"); 11MODULE_AUTHOR("(C) 2000 IBM Corp. by Fritz Elfert (felfert@millenux.com)");
diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
index f6cc46dc050..9b19ea13b4d 100644
--- a/drivers/s390/net/lcs.c
+++ b/drivers/s390/net/lcs.c
@@ -37,6 +37,7 @@
37#include <linux/igmp.h> 37#include <linux/igmp.h>
38#include <linux/delay.h> 38#include <linux/delay.h>
39#include <linux/kthread.h> 39#include <linux/kthread.h>
40#include <linux/slab.h>
40#include <net/arp.h> 41#include <net/arp.h>
41#include <net/ip.h> 42#include <net/ip.h>
42 43
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
index 3bd4206f347..3ba738b2e27 100644
--- a/drivers/s390/net/qeth_core_main.c
+++ b/drivers/s390/net/qeth_core_main.c
@@ -20,6 +20,7 @@
20#include <linux/tcp.h> 20#include <linux/tcp.h>
21#include <linux/mii.h> 21#include <linux/mii.h>
22#include <linux/kthread.h> 22#include <linux/kthread.h>
23#include <linux/slab.h>
23 24
24#include <asm/ebcdic.h> 25#include <asm/ebcdic.h>
25#include <asm/io.h> 26#include <asm/io.h>
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
index 6f1e3036baf..6a801dc3bf8 100644
--- a/drivers/s390/net/qeth_l2_main.c
+++ b/drivers/s390/net/qeth_l2_main.c
@@ -16,6 +16,7 @@
16#include <linux/string.h> 16#include <linux/string.h>
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/slab.h>
19#include <linux/etherdevice.h> 20#include <linux/etherdevice.h>
20#include <linux/mii.h> 21#include <linux/mii.h>
21#include <linux/ip.h> 22#include <linux/ip.h>
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index b3b6e872d80..fc6ca1da8b9 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -22,6 +22,7 @@
22#include <linux/ipv6.h> 22#include <linux/ipv6.h>
23#include <linux/inetdevice.h> 23#include <linux/inetdevice.h>
24#include <linux/igmp.h> 24#include <linux/igmp.h>
25#include <linux/slab.h>
25 26
26#include <net/ip.h> 27#include <net/ip.h>
27#include <net/arp.h> 28#include <net/arp.h>
diff --git a/drivers/s390/net/qeth_l3_sys.c b/drivers/s390/net/qeth_l3_sys.c
index 3f08b11274a..25b3e7aae44 100644
--- a/drivers/s390/net/qeth_l3_sys.c
+++ b/drivers/s390/net/qeth_l3_sys.c
@@ -8,6 +8,8 @@
8 * Frank Blaschka <frank.blaschka@de.ibm.com> 8 * Frank Blaschka <frank.blaschka@de.ibm.com>
9 */ 9 */
10 10
11#include <linux/slab.h>
12
11#include "qeth_l3.h" 13#include "qeth_l3.h"
12 14
13#define QETH_DEVICE_ATTR(_id, _name, _mode, _show, _store) \ 15#define QETH_DEVICE_ATTR(_id, _name, _mode, _show, _store) \
diff --git a/drivers/s390/net/smsgiucv.c b/drivers/s390/net/smsgiucv.c
index ecef1edee70..70491274da1 100644
--- a/drivers/s390/net/smsgiucv.c
+++ b/drivers/s390/net/smsgiucv.c
@@ -24,6 +24,7 @@
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/errno.h> 25#include <linux/errno.h>
26#include <linux/device.h> 26#include <linux/device.h>
27#include <linux/slab.h>
27#include <net/iucv/iucv.h> 28#include <net/iucv/iucv.h>
28#include <asm/cpcmd.h> 29#include <asm/cpcmd.h>
29#include <asm/ebcdic.h> 30#include <asm/ebcdic.h>
diff --git a/drivers/s390/net/smsgiucv_app.c b/drivers/s390/net/smsgiucv_app.c
index 91579dc6a2b..13768879020 100644
--- a/drivers/s390/net/smsgiucv_app.c
+++ b/drivers/s390/net/smsgiucv_app.c
@@ -18,6 +18,7 @@
18#include <linux/list.h> 18#include <linux/list.h>
19#include <linux/kobject.h> 19#include <linux/kobject.h>
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/slab.h>
21#include <linux/spinlock.h> 22#include <linux/spinlock.h>
22#include <linux/workqueue.h> 23#include <linux/workqueue.h>
23#include <net/iucv/iucv.h> 24#include <net/iucv/iucv.h>
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index 66d6c01fcf3..1e6183a86ce 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -30,6 +30,7 @@
30 30
31#include <linux/miscdevice.h> 31#include <linux/miscdevice.h>
32#include <linux/seq_file.h> 32#include <linux/seq_file.h>
33#include <linux/slab.h>
33#include "zfcp_ext.h" 34#include "zfcp_ext.h"
34#include "zfcp_fc.h" 35#include "zfcp_fc.h"
35#include "zfcp_reqlist.h" 36#include "zfcp_reqlist.h"
diff --git a/drivers/s390/scsi/zfcp_cfdc.c b/drivers/s390/scsi/zfcp_cfdc.c
index 0eb6eefd2c1..25d9e0ae9c5 100644
--- a/drivers/s390/scsi/zfcp_cfdc.c
+++ b/drivers/s390/scsi/zfcp_cfdc.c
@@ -10,6 +10,7 @@
10#define KMSG_COMPONENT "zfcp" 10#define KMSG_COMPONENT "zfcp"
11#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt 11#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
12 12
13#include <linux/slab.h>
13#include <linux/types.h> 14#include <linux/types.h>
14#include <linux/miscdevice.h> 15#include <linux/miscdevice.h>
15#include <asm/compat.h> 16#include <asm/compat.h>
diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c
index 7a149fd85f6..075852f6968 100644
--- a/drivers/s390/scsi/zfcp_dbf.c
+++ b/drivers/s390/scsi/zfcp_dbf.c
@@ -10,6 +10,7 @@
10#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt 10#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
11 11
12#include <linux/ctype.h> 12#include <linux/ctype.h>
13#include <linux/slab.h>
13#include <asm/debug.h> 14#include <asm/debug.h>
14#include "zfcp_dbf.h" 15#include "zfcp_dbf.h"
15#include "zfcp_ext.h" 16#include "zfcp_ext.h"
diff --git a/drivers/s390/scsi/zfcp_fc.c b/drivers/s390/scsi/zfcp_fc.c
index 5219670f0c9..2a1cbb74b99 100644
--- a/drivers/s390/scsi/zfcp_fc.c
+++ b/drivers/s390/scsi/zfcp_fc.c
@@ -10,6 +10,7 @@
10#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt 10#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
11 11
12#include <linux/types.h> 12#include <linux/types.h>
13#include <linux/slab.h>
13#include <scsi/fc/fc_els.h> 14#include <scsi/fc/fc_els.h>
14#include <scsi/libfc.h> 15#include <scsi/libfc.h>
15#include "zfcp_ext.h" 16#include "zfcp_ext.h"
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
index 6538742b421..b3b1d2f7939 100644
--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -10,6 +10,7 @@
10#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt 10#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
11 11
12#include <linux/blktrace_api.h> 12#include <linux/blktrace_api.h>
13#include <linux/slab.h>
13#include <scsi/fc/fc_els.h> 14#include <scsi/fc/fc_els.h>
14#include "zfcp_ext.h" 15#include "zfcp_ext.h"
15#include "zfcp_fc.h" 16#include "zfcp_fc.h"
@@ -2104,7 +2105,8 @@ static void zfcp_fsf_req_trace(struct zfcp_fsf_req *req, struct scsi_cmnd *scsi)
2104 blktrc.inb_usage = req->qdio_req.qdio_inb_usage; 2105 blktrc.inb_usage = req->qdio_req.qdio_inb_usage;
2105 blktrc.outb_usage = req->qdio_req.qdio_outb_usage; 2106 blktrc.outb_usage = req->qdio_req.qdio_outb_usage;
2106 2107
2107 if (req->adapter->adapter_features & FSF_FEATURE_MEASUREMENT_DATA) { 2108 if (req->adapter->adapter_features & FSF_FEATURE_MEASUREMENT_DATA &&
2109 !(req->status & ZFCP_STATUS_FSFREQ_ERROR)) {
2108 blktrc.flags |= ZFCP_BLK_LAT_VALID; 2110 blktrc.flags |= ZFCP_BLK_LAT_VALID;
2109 blktrc.channel_lat = lat_in->channel_lat * ticks; 2111 blktrc.channel_lat = lat_in->channel_lat * ticks;
2110 blktrc.fabric_lat = lat_in->fabric_lat * ticks; 2112 blktrc.fabric_lat = lat_in->fabric_lat * ticks;
@@ -2156,9 +2158,8 @@ static void zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req *req)
2156 fcp_rsp = (struct fcp_resp_with_ext *) &req->qtcb->bottom.io.fcp_rsp; 2158 fcp_rsp = (struct fcp_resp_with_ext *) &req->qtcb->bottom.io.fcp_rsp;
2157 zfcp_fc_eval_fcp_rsp(fcp_rsp, scpnt); 2159 zfcp_fc_eval_fcp_rsp(fcp_rsp, scpnt);
2158 2160
2159 zfcp_fsf_req_trace(req, scpnt);
2160
2161skip_fsfstatus: 2161skip_fsfstatus:
2162 zfcp_fsf_req_trace(req, scpnt);
2162 zfcp_dbf_scsi_result(req->adapter->dbf, scpnt, req); 2163 zfcp_dbf_scsi_result(req->adapter->dbf, scpnt, req);
2163 2164
2164 scpnt->host_scribble = NULL; 2165 scpnt->host_scribble = NULL;
diff --git a/drivers/s390/scsi/zfcp_qdio.c b/drivers/s390/scsi/zfcp_qdio.c
index 6479273a309..dbfa312a7f5 100644
--- a/drivers/s390/scsi/zfcp_qdio.c
+++ b/drivers/s390/scsi/zfcp_qdio.c
@@ -9,6 +9,7 @@
9#define KMSG_COMPONENT "zfcp" 9#define KMSG_COMPONENT "zfcp"
10#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt 10#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
11 11
12#include <linux/slab.h>
12#include "zfcp_ext.h" 13#include "zfcp_ext.h"
13#include "zfcp_qdio.h" 14#include "zfcp_qdio.h"
14 15
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index c3c4178888a..174b6d57d57 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -10,6 +10,7 @@
10#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt 10#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
11 11
12#include <linux/types.h> 12#include <linux/types.h>
13#include <linux/slab.h>
13#include <scsi/fc/fc_fcp.h> 14#include <scsi/fc/fc_fcp.h>
14#include <asm/atomic.h> 15#include <asm/atomic.h>
15#include "zfcp_ext.h" 16#include "zfcp_ext.h"
diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c
index a43035d4bd7..f5f60698dc4 100644
--- a/drivers/s390/scsi/zfcp_sysfs.c
+++ b/drivers/s390/scsi/zfcp_sysfs.c
@@ -9,6 +9,7 @@
9#define KMSG_COMPONENT "zfcp" 9#define KMSG_COMPONENT "zfcp"
10#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt 10#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
11 11
12#include <linux/slab.h>
12#include "zfcp_ext.h" 13#include "zfcp_ext.h"
13 14
14#define ZFCP_DEV_ATTR(_feat, _name, _mode, _show, _store) \ 15#define ZFCP_DEV_ATTR(_feat, _name, _mode, _show, _store) \
diff --git a/drivers/sbus/char/bbc_envctrl.c b/drivers/sbus/char/bbc_envctrl.c
index 28d86f9df83..b4951eb0358 100644
--- a/drivers/sbus/char/bbc_envctrl.c
+++ b/drivers/sbus/char/bbc_envctrl.c
@@ -8,6 +8,7 @@
8#include <linux/kmod.h> 8#include <linux/kmod.h>
9#include <linux/reboot.h> 9#include <linux/reboot.h>
10#include <linux/of.h> 10#include <linux/of.h>
11#include <linux/slab.h>
11#include <linux/of_device.h> 12#include <linux/of_device.h>
12#include <asm/oplib.h> 13#include <asm/oplib.h>
13 14
diff --git a/drivers/sbus/char/display7seg.c b/drivers/sbus/char/display7seg.c
index 4431578d8c4..3e59189f413 100644
--- a/drivers/sbus/char/display7seg.c
+++ b/drivers/sbus/char/display7seg.c
@@ -12,6 +12,7 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/miscdevice.h> 13#include <linux/miscdevice.h>
14#include <linux/ioport.h> /* request_region */ 14#include <linux/ioport.h> /* request_region */
15#include <linux/slab.h>
15#include <linux/smp_lock.h> 16#include <linux/smp_lock.h>
16#include <linux/of.h> 17#include <linux/of.h>
17#include <linux/of_device.h> 18#include <linux/of_device.h>
diff --git a/drivers/sbus/char/envctrl.c b/drivers/sbus/char/envctrl.c
index aa2b60a868b..c6e2eff1940 100644
--- a/drivers/sbus/char/envctrl.c
+++ b/drivers/sbus/char/envctrl.c
@@ -26,6 +26,7 @@
26#include <linux/miscdevice.h> 26#include <linux/miscdevice.h>
27#include <linux/kmod.h> 27#include <linux/kmod.h>
28#include <linux/reboot.h> 28#include <linux/reboot.h>
29#include <linux/slab.h>
29#include <linux/smp_lock.h> 30#include <linux/smp_lock.h>
30#include <linux/of.h> 31#include <linux/of.h>
31#include <linux/of_device.h> 32#include <linux/of_device.h>
diff --git a/drivers/sbus/char/flash.c b/drivers/sbus/char/flash.c
index 41083472ff4..19f255b97c8 100644
--- a/drivers/sbus/char/flash.c
+++ b/drivers/sbus/char/flash.c
@@ -7,7 +7,6 @@
7#include <linux/types.h> 7#include <linux/types.h>
8#include <linux/errno.h> 8#include <linux/errno.h>
9#include <linux/miscdevice.h> 9#include <linux/miscdevice.h>
10#include <linux/slab.h>
11#include <linux/fcntl.h> 10#include <linux/fcntl.h>
12#include <linux/poll.h> 11#include <linux/poll.h>
13#include <linux/init.h> 12#include <linux/init.h>
diff --git a/drivers/sbus/char/jsflash.c b/drivers/sbus/char/jsflash.c
index 869a30b49ed..4942050dc5b 100644
--- a/drivers/sbus/char/jsflash.c
+++ b/drivers/sbus/char/jsflash.c
@@ -31,7 +31,6 @@
31#include <linux/types.h> 31#include <linux/types.h>
32#include <linux/errno.h> 32#include <linux/errno.h>
33#include <linux/miscdevice.h> 33#include <linux/miscdevice.h>
34#include <linux/slab.h>
35#include <linux/fcntl.h> 34#include <linux/fcntl.h>
36#include <linux/poll.h> 35#include <linux/poll.h>
37#include <linux/init.h> 36#include <linux/init.h>
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index 84d3bbaa95e..e9788f55ab1 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -91,6 +91,7 @@
91#include <linux/time.h> 91#include <linux/time.h>
92#include <linux/mutex.h> 92#include <linux/mutex.h>
93#include <linux/smp_lock.h> 93#include <linux/smp_lock.h>
94#include <linux/slab.h>
94#include <asm/io.h> 95#include <asm/io.h>
95#include <asm/irq.h> 96#include <asm/irq.h>
96#include <asm/uaccess.h> 97#include <asm/uaccess.h>
diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c
index 4d314d740de..54c5ffb1eaa 100644
--- a/drivers/scsi/3w-sas.c
+++ b/drivers/scsi/3w-sas.c
@@ -65,6 +65,7 @@
65#include <linux/time.h> 65#include <linux/time.h>
66#include <linux/mutex.h> 66#include <linux/mutex.h>
67#include <linux/smp_lock.h> 67#include <linux/smp_lock.h>
68#include <linux/slab.h>
68#include <asm/io.h> 69#include <asm/io.h>
69#include <asm/irq.h> 70#include <asm/irq.h>
70#include <asm/uaccess.h> 71#include <asm/uaccess.h>
diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c
index f65a1e92340..5faf903ca8c 100644
--- a/drivers/scsi/3w-xxxx.c
+++ b/drivers/scsi/3w-xxxx.c
@@ -205,6 +205,7 @@
205#include <linux/errno.h> 205#include <linux/errno.h>
206#include <linux/types.h> 206#include <linux/types.h>
207#include <linux/delay.h> 207#include <linux/delay.h>
208#include <linux/gfp.h>
208#include <linux/pci.h> 209#include <linux/pci.h>
209#include <linux/time.h> 210#include <linux/time.h>
210#include <linux/mutex.h> 211#include <linux/mutex.h>
diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
index 9f4a911a6d8..80dc3ac12cd 100644
--- a/drivers/scsi/53c700.c
+++ b/drivers/scsi/53c700.c
@@ -117,6 +117,7 @@
117#include <linux/kernel.h> 117#include <linux/kernel.h>
118#include <linux/types.h> 118#include <linux/types.h>
119#include <linux/string.h> 119#include <linux/string.h>
120#include <linux/slab.h>
120#include <linux/ioport.h> 121#include <linux/ioport.h>
121#include <linux/delay.h> 122#include <linux/delay.h>
122#include <linux/spinlock.h> 123#include <linux/spinlock.h>
diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
index 1ddcf4031d4..fc0b4b81d55 100644
--- a/drivers/scsi/BusLogic.c
+++ b/drivers/scsi/BusLogic.c
@@ -42,6 +42,7 @@
42#include <linux/spinlock.h> 42#include <linux/spinlock.h>
43#include <linux/jiffies.h> 43#include <linux/jiffies.h>
44#include <linux/dma-mapping.h> 44#include <linux/dma-mapping.h>
45#include <linux/slab.h>
45#include <scsi/scsicam.h> 46#include <scsi/scsicam.h>
46 47
47#include <asm/dma.h> 48#include <asm/dma.h>
diff --git a/drivers/scsi/NCR_D700.c b/drivers/scsi/NCR_D700.c
index 1cdf09a4779..8647256ad66 100644
--- a/drivers/scsi/NCR_D700.c
+++ b/drivers/scsi/NCR_D700.c
@@ -97,6 +97,7 @@
97#include <linux/kernel.h> 97#include <linux/kernel.h>
98#include <linux/module.h> 98#include <linux/module.h>
99#include <linux/mca.h> 99#include <linux/mca.h>
100#include <linux/slab.h>
100#include <asm/io.h> 101#include <asm/io.h>
101#include <scsi/scsi_host.h> 102#include <scsi/scsi_host.h>
102#include <scsi/scsi_device.h> 103#include <scsi/scsi_device.h>
diff --git a/drivers/scsi/NCR_Q720.c b/drivers/scsi/NCR_Q720.c
index a8bbdc2273b..afdbb9addf1 100644
--- a/drivers/scsi/NCR_Q720.c
+++ b/drivers/scsi/NCR_Q720.c
@@ -10,6 +10,7 @@
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/mca.h> 12#include <linux/mca.h>
13#include <linux/slab.h>
13#include <linux/types.h> 14#include <linux/types.h>
14#include <linux/init.h> 15#include <linux/init.h>
15#include <linux/delay.h> 16#include <linux/delay.h>
diff --git a/drivers/scsi/a100u2w.c b/drivers/scsi/a100u2w.c
index ff5716d5f04..dbbc601948e 100644
--- a/drivers/scsi/a100u2w.c
+++ b/drivers/scsi/a100u2w.c
@@ -69,7 +69,6 @@
69#include <linux/kernel.h> 69#include <linux/kernel.h>
70#include <linux/string.h> 70#include <linux/string.h>
71#include <linux/ioport.h> 71#include <linux/ioport.h>
72#include <linux/slab.h>
73#include <linux/dma-mapping.h> 72#include <linux/dma-mapping.h>
74 73
75#include <asm/io.h> 74#include <asm/io.h>
diff --git a/drivers/scsi/a2091.c b/drivers/scsi/a2091.c
index 4b38c4750f7..d8fe5b76fee 100644
--- a/drivers/scsi/a2091.c
+++ b/drivers/scsi/a2091.c
@@ -1,5 +1,6 @@
1#include <linux/types.h> 1#include <linux/types.h>
2#include <linux/mm.h> 2#include <linux/mm.h>
3#include <linux/slab.h>
3#include <linux/blkdev.h> 4#include <linux/blkdev.h>
4#include <linux/init.h> 5#include <linux/init.h>
5#include <linux/interrupt.h> 6#include <linux/interrupt.h>
diff --git a/drivers/scsi/a3000.c b/drivers/scsi/a3000.c
index 6970ce82c4a..c35fc55f1c9 100644
--- a/drivers/scsi/a3000.c
+++ b/drivers/scsi/a3000.c
@@ -1,5 +1,6 @@
1#include <linux/types.h> 1#include <linux/types.h>
2#include <linux/mm.h> 2#include <linux/mm.h>
3#include <linux/slab.h>
3#include <linux/blkdev.h> 4#include <linux/blkdev.h>
4#include <linux/ioport.h> 5#include <linux/ioport.h>
5#include <linux/init.h> 6#include <linux/init.h>
diff --git a/drivers/scsi/a4000t.c b/drivers/scsi/a4000t.c
index e3519fa5a3b..11ae6be8aea 100644
--- a/drivers/scsi/a4000t.c
+++ b/drivers/scsi/a4000t.c
@@ -12,6 +12,7 @@
12#include <linux/platform_device.h> 12#include <linux/platform_device.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/interrupt.h> 14#include <linux/interrupt.h>
15#include <linux/slab.h>
15#include <asm/amigahw.h> 16#include <asm/amigahw.h>
16#include <asm/amigaints.h> 17#include <asm/amigaints.h>
17#include <scsi/scsi_host.h> 18#include <scsi/scsi_host.h>
diff --git a/drivers/scsi/aacraid/rx.c b/drivers/scsi/aacraid/rx.c
index f70d9f8e79e..04057ab72a8 100644
--- a/drivers/scsi/aacraid/rx.c
+++ b/drivers/scsi/aacraid/rx.c
@@ -33,7 +33,6 @@
33#include <linux/types.h> 33#include <linux/types.h>
34#include <linux/pci.h> 34#include <linux/pci.h>
35#include <linux/spinlock.h> 35#include <linux/spinlock.h>
36#include <linux/slab.h>
37#include <linux/blkdev.h> 36#include <linux/blkdev.h>
38#include <linux/delay.h> 37#include <linux/delay.h>
39#include <linux/completion.h> 38#include <linux/completion.h>
diff --git a/drivers/scsi/aacraid/sa.c b/drivers/scsi/aacraid/sa.c
index b6a3c5c187b..622c21c68e6 100644
--- a/drivers/scsi/aacraid/sa.c
+++ b/drivers/scsi/aacraid/sa.c
@@ -33,7 +33,6 @@
33#include <linux/types.h> 33#include <linux/types.h>
34#include <linux/pci.h> 34#include <linux/pci.h>
35#include <linux/spinlock.h> 35#include <linux/spinlock.h>
36#include <linux/slab.h>
37#include <linux/blkdev.h> 36#include <linux/blkdev.h>
38#include <linux/delay.h> 37#include <linux/delay.h>
39#include <linux/completion.h> 38#include <linux/completion.h>
diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 22626abdb63..7f87979da22 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -4724,6 +4724,10 @@ static ushort AscInitMicroCodeVar(ASC_DVC_VAR *asc_dvc)
4724 BUG_ON((unsigned long)asc_dvc->overrun_buf & 7); 4724 BUG_ON((unsigned long)asc_dvc->overrun_buf & 7);
4725 asc_dvc->overrun_dma = dma_map_single(board->dev, asc_dvc->overrun_buf, 4725 asc_dvc->overrun_dma = dma_map_single(board->dev, asc_dvc->overrun_buf,
4726 ASC_OVERRUN_BSIZE, DMA_FROM_DEVICE); 4726 ASC_OVERRUN_BSIZE, DMA_FROM_DEVICE);
4727 if (dma_mapping_error(board->dev, asc_dvc->overrun_dma)) {
4728 warn_code = -ENOMEM;
4729 goto err_dma_map;
4730 }
4727 phy_addr = cpu_to_le32(asc_dvc->overrun_dma); 4731 phy_addr = cpu_to_le32(asc_dvc->overrun_dma);
4728 AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_PADDR_D, 4732 AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_PADDR_D,
4729 (uchar *)&phy_addr, 1); 4733 (uchar *)&phy_addr, 1);
@@ -4739,14 +4743,23 @@ static ushort AscInitMicroCodeVar(ASC_DVC_VAR *asc_dvc)
4739 AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR); 4743 AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
4740 if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) { 4744 if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
4741 asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR; 4745 asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
4742 return warn_code; 4746 warn_code = UW_ERR;
4747 goto err_mcode_start;
4743 } 4748 }
4744 if (AscStartChip(iop_base) != 1) { 4749 if (AscStartChip(iop_base) != 1) {
4745 asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP; 4750 asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
4746 return warn_code; 4751 warn_code = UW_ERR;
4752 goto err_mcode_start;
4747 } 4753 }
4748 4754
4749 return warn_code; 4755 return warn_code;
4756
4757err_mcode_start:
4758 dma_unmap_single(board->dev, asc_dvc->overrun_dma,
4759 ASC_OVERRUN_BSIZE, DMA_FROM_DEVICE);
4760err_dma_map:
4761 asc_dvc->overrun_dma = 0;
4762 return warn_code;
4750} 4763}
4751 4764
4752static ushort AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc) 4765static ushort AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc)
@@ -4781,12 +4794,14 @@ static ushort AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc)
4781 if (err) { 4794 if (err) {
4782 printk(KERN_ERR "Failed to load image \"%s\" err %d\n", 4795 printk(KERN_ERR "Failed to load image \"%s\" err %d\n",
4783 fwname, err); 4796 fwname, err);
4797 asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
4784 return err; 4798 return err;
4785 } 4799 }
4786 if (fw->size < 4) { 4800 if (fw->size < 4) {
4787 printk(KERN_ERR "Bogus length %zu in image \"%s\"\n", 4801 printk(KERN_ERR "Bogus length %zu in image \"%s\"\n",
4788 fw->size, fwname); 4802 fw->size, fwname);
4789 release_firmware(fw); 4803 release_firmware(fw);
4804 asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
4790 return -EINVAL; 4805 return -EINVAL;
4791 } 4806 }
4792 chksum = (fw->data[3] << 24) | (fw->data[2] << 16) | 4807 chksum = (fw->data[3] << 24) | (fw->data[2] << 16) |
@@ -4800,6 +4815,8 @@ static ushort AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc)
4800 } 4815 }
4801 release_firmware(fw); 4816 release_firmware(fw);
4802 warn_code |= AscInitMicroCodeVar(asc_dvc); 4817 warn_code |= AscInitMicroCodeVar(asc_dvc);
4818 if (!asc_dvc->overrun_dma)
4819 return warn_code;
4803 asc_dvc->init_state |= ASC_INIT_STATE_END_LOAD_MC; 4820 asc_dvc->init_state |= ASC_INIT_STATE_END_LOAD_MC;
4804 AscEnableInterrupt(iop_base); 4821 AscEnableInterrupt(iop_base);
4805 return warn_code; 4822 return warn_code;
@@ -5110,12 +5127,14 @@ static int AdvInitAsc3550Driver(ADV_DVC_VAR *asc_dvc)
5110 if (err) { 5127 if (err) {
5111 printk(KERN_ERR "Failed to load image \"%s\" err %d\n", 5128 printk(KERN_ERR "Failed to load image \"%s\" err %d\n",
5112 fwname, err); 5129 fwname, err);
5130 asc_dvc->err_code = ASC_IERR_MCODE_CHKSUM;
5113 return err; 5131 return err;
5114 } 5132 }
5115 if (fw->size < 4) { 5133 if (fw->size < 4) {
5116 printk(KERN_ERR "Bogus length %zu in image \"%s\"\n", 5134 printk(KERN_ERR "Bogus length %zu in image \"%s\"\n",
5117 fw->size, fwname); 5135 fw->size, fwname);
5118 release_firmware(fw); 5136 release_firmware(fw);
5137 asc_dvc->err_code = ASC_IERR_MCODE_CHKSUM;
5119 return -EINVAL; 5138 return -EINVAL;
5120 } 5139 }
5121 chksum = (fw->data[3] << 24) | (fw->data[2] << 16) | 5140 chksum = (fw->data[3] << 24) | (fw->data[2] << 16) |
@@ -5624,12 +5643,14 @@ static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *asc_dvc)
5624 if (err) { 5643 if (err) {
5625 printk(KERN_ERR "Failed to load image \"%s\" err %d\n", 5644 printk(KERN_ERR "Failed to load image \"%s\" err %d\n",
5626 fwname, err); 5645 fwname, err);
5646 asc_dvc->err_code = ASC_IERR_MCODE_CHKSUM;
5627 return err; 5647 return err;
5628 } 5648 }
5629 if (fw->size < 4) { 5649 if (fw->size < 4) {
5630 printk(KERN_ERR "Bogus length %zu in image \"%s\"\n", 5650 printk(KERN_ERR "Bogus length %zu in image \"%s\"\n",
5631 fw->size, fwname); 5651 fw->size, fwname);
5632 release_firmware(fw); 5652 release_firmware(fw);
5653 asc_dvc->err_code = ASC_IERR_MCODE_CHKSUM;
5633 return -EINVAL; 5654 return -EINVAL;
5634 } 5655 }
5635 chksum = (fw->data[3] << 24) | (fw->data[2] << 16) | 5656 chksum = (fw->data[3] << 24) | (fw->data[2] << 16) |
@@ -6124,12 +6145,14 @@ static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *asc_dvc)
6124 if (err) { 6145 if (err) {
6125 printk(KERN_ERR "Failed to load image \"%s\" err %d\n", 6146 printk(KERN_ERR "Failed to load image \"%s\" err %d\n",
6126 fwname, err); 6147 fwname, err);
6148 asc_dvc->err_code = ASC_IERR_MCODE_CHKSUM;
6127 return err; 6149 return err;
6128 } 6150 }
6129 if (fw->size < 4) { 6151 if (fw->size < 4) {
6130 printk(KERN_ERR "Bogus length %zu in image \"%s\"\n", 6152 printk(KERN_ERR "Bogus length %zu in image \"%s\"\n",
6131 fw->size, fwname); 6153 fw->size, fwname);
6132 release_firmware(fw); 6154 release_firmware(fw);
6155 asc_dvc->err_code = ASC_IERR_MCODE_CHKSUM;
6133 return -EINVAL; 6156 return -EINVAL;
6134 } 6157 }
6135 chksum = (fw->data[3] << 24) | (fw->data[2] << 16) | 6158 chksum = (fw->data[3] << 24) | (fw->data[2] << 16) |
@@ -7970,9 +7993,10 @@ static int advansys_reset(struct scsi_cmnd *scp)
7970 status = AscInitAsc1000Driver(asc_dvc); 7993 status = AscInitAsc1000Driver(asc_dvc);
7971 7994
7972 /* Refer to ASC_IERR_* definitions for meaning of 'err_code'. */ 7995 /* Refer to ASC_IERR_* definitions for meaning of 'err_code'. */
7973 if (asc_dvc->err_code) { 7996 if (asc_dvc->err_code || !asc_dvc->overrun_dma) {
7974 scmd_printk(KERN_INFO, scp, "SCSI bus reset error: " 7997 scmd_printk(KERN_INFO, scp, "SCSI bus reset error: "
7975 "0x%x\n", asc_dvc->err_code); 7998 "0x%x, status: 0x%x\n", asc_dvc->err_code,
7999 status);
7976 ret = FAILED; 8000 ret = FAILED;
7977 } else if (status) { 8001 } else if (status) {
7978 scmd_printk(KERN_INFO, scp, "SCSI bus reset warning: " 8002 scmd_printk(KERN_INFO, scp, "SCSI bus reset warning: "
@@ -12303,7 +12327,7 @@ static int __devinit advansys_board_found(struct Scsi_Host *shost,
12303 asc_dvc_varp->overrun_buf = kzalloc(ASC_OVERRUN_BSIZE, GFP_KERNEL); 12327 asc_dvc_varp->overrun_buf = kzalloc(ASC_OVERRUN_BSIZE, GFP_KERNEL);
12304 if (!asc_dvc_varp->overrun_buf) { 12328 if (!asc_dvc_varp->overrun_buf) {
12305 ret = -ENOMEM; 12329 ret = -ENOMEM;
12306 goto err_free_wide_mem; 12330 goto err_free_irq;
12307 } 12331 }
12308 warn_code = AscInitAsc1000Driver(asc_dvc_varp); 12332 warn_code = AscInitAsc1000Driver(asc_dvc_varp);
12309 12333
@@ -12312,30 +12336,36 @@ static int __devinit advansys_board_found(struct Scsi_Host *shost,
12312 "warn 0x%x, error 0x%x\n", 12336 "warn 0x%x, error 0x%x\n",
12313 asc_dvc_varp->init_state, warn_code, 12337 asc_dvc_varp->init_state, warn_code,
12314 asc_dvc_varp->err_code); 12338 asc_dvc_varp->err_code);
12315 if (asc_dvc_varp->err_code) { 12339 if (!asc_dvc_varp->overrun_dma) {
12316 ret = -ENODEV; 12340 ret = -ENODEV;
12317 kfree(asc_dvc_varp->overrun_buf); 12341 goto err_free_mem;
12318 } 12342 }
12319 } 12343 }
12320 } else { 12344 } else {
12321 if (advansys_wide_init_chip(shost)) 12345 if (advansys_wide_init_chip(shost)) {
12322 ret = -ENODEV; 12346 ret = -ENODEV;
12347 goto err_free_mem;
12348 }
12323 } 12349 }
12324 12350
12325 if (ret)
12326 goto err_free_wide_mem;
12327
12328 ASC_DBG_PRT_SCSI_HOST(2, shost); 12351 ASC_DBG_PRT_SCSI_HOST(2, shost);
12329 12352
12330 ret = scsi_add_host(shost, boardp->dev); 12353 ret = scsi_add_host(shost, boardp->dev);
12331 if (ret) 12354 if (ret)
12332 goto err_free_wide_mem; 12355 goto err_free_mem;
12333 12356
12334 scsi_scan_host(shost); 12357 scsi_scan_host(shost);
12335 return 0; 12358 return 0;
12336 12359
12337 err_free_wide_mem: 12360 err_free_mem:
12338 advansys_wide_free_mem(boardp); 12361 if (ASC_NARROW_BOARD(boardp)) {
12362 if (asc_dvc_varp->overrun_dma)
12363 dma_unmap_single(boardp->dev, asc_dvc_varp->overrun_dma,
12364 ASC_OVERRUN_BSIZE, DMA_FROM_DEVICE);
12365 kfree(asc_dvc_varp->overrun_buf);
12366 } else
12367 advansys_wide_free_mem(boardp);
12368 err_free_irq:
12339 free_irq(boardp->irq, shost); 12369 free_irq(boardp->irq, shost);
12340 err_free_dma: 12370 err_free_dma:
12341#ifdef CONFIG_ISA 12371#ifdef CONFIG_ISA
diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index 1e5478abd90..8eab8587ff2 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -254,6 +254,7 @@
254#include <linux/spinlock.h> 254#include <linux/spinlock.h>
255#include <linux/workqueue.h> 255#include <linux/workqueue.h>
256#include <linux/list.h> 256#include <linux/list.h>
257#include <linux/slab.h>
257#include <scsi/scsicam.h> 258#include <scsi/scsicam.h>
258 259
259#include "scsi.h" 260#include "scsi.h"
diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c
index 80594947c6f..2a8cf137f60 100644
--- a/drivers/scsi/aha1542.c
+++ b/drivers/scsi/aha1542.c
@@ -39,6 +39,7 @@
39#include <linux/blkdev.h> 39#include <linux/blkdev.h>
40#include <linux/mca.h> 40#include <linux/mca.h>
41#include <linux/mca-legacy.h> 41#include <linux/mca-legacy.h>
42#include <linux/slab.h>
42 43
43#include <asm/dma.h> 44#include <asm/dma.h>
44#include <asm/system.h> 45#include <asm/system.h>
diff --git a/drivers/scsi/aha1740.c b/drivers/scsi/aha1740.c
index 538135783aa..0107a4cc333 100644
--- a/drivers/scsi/aha1740.c
+++ b/drivers/scsi/aha1740.c
@@ -50,6 +50,7 @@
50#include <linux/device.h> 50#include <linux/device.h>
51#include <linux/eisa.h> 51#include <linux/eisa.h>
52#include <linux/dma-mapping.h> 52#include <linux/dma-mapping.h>
53#include <linux/gfp.h>
53 54
54#include <asm/dma.h> 55#include <asm/dma.h>
55#include <asm/system.h> 56#include <asm/system.h>
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
index 1222a7ac698..4c41332a354 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
@@ -53,6 +53,7 @@ static struct scsi_transport_template *ahd_linux_transport_template = NULL;
53#include <linux/blkdev.h> /* For block_size() */ 53#include <linux/blkdev.h> /* For block_size() */
54#include <linux/delay.h> /* For ssleep/msleep */ 54#include <linux/delay.h> /* For ssleep/msleep */
55#include <linux/device.h> 55#include <linux/device.h>
56#include <linux/slab.h>
56 57
57/* 58/*
58 * Bucket size for counting good commands in between bad ones. 59 * Bucket size for counting good commands in between bad ones.
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index 8cb05dc8e6a..5e42dac2350 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -129,6 +129,7 @@ static struct scsi_transport_template *ahc_linux_transport_template = NULL;
129#include <linux/mm.h> /* For fetching system memory size */ 129#include <linux/mm.h> /* For fetching system memory size */
130#include <linux/blkdev.h> /* For block_size() */ 130#include <linux/blkdev.h> /* For block_size() */
131#include <linux/delay.h> /* For ssleep/msleep */ 131#include <linux/delay.h> /* For ssleep/msleep */
132#include <linux/slab.h>
132 133
133 134
134/* 135/*
diff --git a/drivers/scsi/aic94xx/aic94xx_hwi.c b/drivers/scsi/aic94xx/aic94xx_hwi.c
index eb9dc3195fd..81b736c76ff 100644
--- a/drivers/scsi/aic94xx/aic94xx_hwi.c
+++ b/drivers/scsi/aic94xx/aic94xx_hwi.c
@@ -25,6 +25,7 @@
25 */ 25 */
26 26
27#include <linux/pci.h> 27#include <linux/pci.h>
28#include <linux/slab.h>
28#include <linux/delay.h> 29#include <linux/delay.h>
29#include <linux/module.h> 30#include <linux/module.h>
30#include <linux/firmware.h> 31#include <linux/firmware.h>
diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c
index 996f7224f90..24ac2315c5c 100644
--- a/drivers/scsi/aic94xx/aic94xx_init.c
+++ b/drivers/scsi/aic94xx/aic94xx_init.c
@@ -30,6 +30,7 @@
30#include <linux/pci.h> 30#include <linux/pci.h>
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/firmware.h> 32#include <linux/firmware.h>
33#include <linux/slab.h>
33 34
34#include <scsi/scsi_host.h> 35#include <scsi/scsi_host.h>
35 36
diff --git a/drivers/scsi/aic94xx/aic94xx_scb.c b/drivers/scsi/aic94xx/aic94xx_scb.c
index ca55013b6ae..c43698b1cb6 100644
--- a/drivers/scsi/aic94xx/aic94xx_scb.c
+++ b/drivers/scsi/aic94xx/aic94xx_scb.c
@@ -24,6 +24,7 @@
24 * 24 *
25 */ 25 */
26 26
27#include <linux/gfp.h>
27#include <scsi/scsi_host.h> 28#include <scsi/scsi_host.h>
28 29
29#include "aic94xx.h" 30#include "aic94xx.h"
diff --git a/drivers/scsi/aic94xx/aic94xx_sds.c b/drivers/scsi/aic94xx/aic94xx_sds.c
index 8630a75b287..edb43fda9f3 100644
--- a/drivers/scsi/aic94xx/aic94xx_sds.c
+++ b/drivers/scsi/aic94xx/aic94xx_sds.c
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28#include <linux/pci.h> 28#include <linux/pci.h>
29#include <linux/slab.h>
29#include <linux/delay.h> 30#include <linux/delay.h>
30 31
31#include "aic94xx.h" 32#include "aic94xx.h"
diff --git a/drivers/scsi/aic94xx/aic94xx_seq.c b/drivers/scsi/aic94xx/aic94xx_seq.c
index 8f98e33155e..d01dcc62b39 100644
--- a/drivers/scsi/aic94xx/aic94xx_seq.c
+++ b/drivers/scsi/aic94xx/aic94xx_seq.c
@@ -27,6 +27,7 @@
27 */ 27 */
28 28
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/gfp.h>
30#include <linux/pci.h> 31#include <linux/pci.h>
31#include <linux/module.h> 32#include <linux/module.h>
32#include <linux/firmware.h> 33#include <linux/firmware.h>
diff --git a/drivers/scsi/aic94xx/aic94xx_tmf.c b/drivers/scsi/aic94xx/aic94xx_tmf.c
index 78eb86fc627..0add73bdf2a 100644
--- a/drivers/scsi/aic94xx/aic94xx_tmf.c
+++ b/drivers/scsi/aic94xx/aic94xx_tmf.c
@@ -25,6 +25,7 @@
25 */ 25 */
26 26
27#include <linux/spinlock.h> 27#include <linux/spinlock.h>
28#include <linux/gfp.h>
28#include "aic94xx.h" 29#include "aic94xx.h"
29#include "aic94xx_sas.h" 30#include "aic94xx_sas.h"
30#include "aic94xx_hwi.h" 31#include "aic94xx_hwi.h"
diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
index 47d5d19f8c9..ffbe2192da3 100644
--- a/drivers/scsi/arcmsr/arcmsr_hba.c
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c
@@ -58,6 +58,7 @@
58#include <linux/timer.h> 58#include <linux/timer.h>
59#include <linux/pci.h> 59#include <linux/pci.h>
60#include <linux/aer.h> 60#include <linux/aer.h>
61#include <linux/slab.h>
61#include <asm/dma.h> 62#include <asm/dma.h>
62#include <asm/io.h> 63#include <asm/io.h>
63#include <asm/system.h> 64#include <asm/system.h>
diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c
index 4240b05aef6..158ebc3644d 100644
--- a/drivers/scsi/atari_NCR5380.c
+++ b/drivers/scsi/atari_NCR5380.c
@@ -651,6 +651,7 @@ static inline void NCR5380_print_phase(struct Scsi_Host *instance)
651 * interrupt or bottom half. 651 * interrupt or bottom half.
652 */ 652 */
653 653
654#include <linux/gfp.h>
654#include <linux/workqueue.h> 655#include <linux/workqueue.h>
655#include <linux/interrupt.h> 656#include <linux/interrupt.h>
656 657
diff --git a/drivers/scsi/atp870u.c b/drivers/scsi/atp870u.c
index b137e561f5b..ab5bdda6903 100644
--- a/drivers/scsi/atp870u.c
+++ b/drivers/scsi/atp870u.c
@@ -29,6 +29,7 @@
29#include <linux/pci.h> 29#include <linux/pci.h>
30#include <linux/blkdev.h> 30#include <linux/blkdev.h>
31#include <linux/dma-mapping.h> 31#include <linux/dma-mapping.h>
32#include <linux/slab.h>
32#include <asm/system.h> 33#include <asm/system.h>
33#include <asm/io.h> 34#include <asm/io.h>
34 35
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index fcfb29e02d8..dd5b105f8f4 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -19,6 +19,7 @@
19 */ 19 */
20#include <linux/reboot.h> 20#include <linux/reboot.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/slab.h>
22#include <linux/interrupt.h> 23#include <linux/interrupt.h>
23#include <linux/blkdev.h> 24#include <linux/blkdev.h>
24#include <linux/pci.h> 25#include <linux/pci.h>
diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c
index 72617b650a7..e641922f20b 100644
--- a/drivers/scsi/be2iscsi/be_mgmt.c
+++ b/drivers/scsi/be2iscsi/be_mgmt.c
@@ -169,6 +169,7 @@ unsigned char mgmt_invalidate_icds(struct beiscsi_hba *phba,
169 SE_DEBUG(DBG_LVL_1, 169 SE_DEBUG(DBG_LVL_1,
170 "Failed to allocate memory for" 170 "Failed to allocate memory for"
171 "mgmt_invalidate_icds \n"); 171 "mgmt_invalidate_icds \n");
172 spin_unlock(&ctrl->mbox_lock);
172 return -1; 173 return -1;
173 } 174 }
174 nonemb_cmd.size = sizeof(struct invalidate_commands_params_in); 175 nonemb_cmd.size = sizeof(struct invalidate_commands_params_in);
diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c
index 6bff08ea402..13f5feb308c 100644
--- a/drivers/scsi/bfa/bfad.c
+++ b/drivers/scsi/bfa/bfad.c
@@ -19,6 +19,7 @@
19 * bfad.c Linux driver PCI interface module. 19 * bfad.c Linux driver PCI interface module.
20 */ 20 */
21 21
22#include <linux/slab.h>
22#include <linux/module.h> 23#include <linux/module.h>
23#include <linux/kthread.h> 24#include <linux/kthread.h>
24#include "bfad_drv.h" 25#include "bfad_drv.h"
diff --git a/drivers/scsi/bfa/bfad_attr.c b/drivers/scsi/bfa/bfad_attr.c
index d97f6919183..6a2efdd5ef2 100644
--- a/drivers/scsi/bfa/bfad_attr.c
+++ b/drivers/scsi/bfa/bfad_attr.c
@@ -19,6 +19,7 @@
19 * bfa_attr.c Linux driver configuration interface module. 19 * bfa_attr.c Linux driver configuration interface module.
20 */ 20 */
21 21
22#include <linux/slab.h>
22#include "bfad_drv.h" 23#include "bfad_drv.h"
23#include "bfad_im.h" 24#include "bfad_im.h"
24#include "bfad_trcmod.h" 25#include "bfad_trcmod.h"
diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c
index f9fc67a25bf..78f42aa5736 100644
--- a/drivers/scsi/bfa/bfad_im.c
+++ b/drivers/scsi/bfa/bfad_im.c
@@ -19,6 +19,7 @@
19 * bfad_im.c Linux driver IM module. 19 * bfad_im.c Linux driver IM module.
20 */ 20 */
21 21
22#include <linux/slab.h>
22#include "bfad_drv.h" 23#include "bfad_drv.h"
23#include "bfad_im.h" 24#include "bfad_im.h"
24#include "bfad_trcmod.h" 25#include "bfad_trcmod.h"
diff --git a/drivers/scsi/bfa/rport.c b/drivers/scsi/bfa/rport.c
index 8e73dd9a625..7b096f2e383 100644
--- a/drivers/scsi/bfa/rport.c
+++ b/drivers/scsi/bfa/rport.c
@@ -19,6 +19,7 @@
19 * rport.c Remote port implementation. 19 * rport.c Remote port implementation.
20 */ 20 */
21 21
22#include <linux/slab.h>
22#include <bfa.h> 23#include <bfa.h>
23#include <bfa_svc.h> 24#include <bfa_svc.h>
24#include "fcbuild.h" 25#include "fcbuild.h"
diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index 6cf9dc37d78..6b624e767d3 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -362,6 +362,7 @@ struct bnx2i_hba {
362 u32 num_ccell; 362 u32 num_ccell;
363 363
364 int ofld_conns_active; 364 int ofld_conns_active;
365 wait_queue_head_t eh_wait;
365 366
366 int max_active_conns; 367 int max_active_conns;
367 struct iscsi_cid_queue cid_que; 368 struct iscsi_cid_queue cid_que;
@@ -381,6 +382,7 @@ struct bnx2i_hba {
381 spinlock_t lock; /* protects hba structure access */ 382 spinlock_t lock; /* protects hba structure access */
382 struct mutex net_dev_lock;/* sync net device access */ 383 struct mutex net_dev_lock;/* sync net device access */
383 384
385 int hba_shutdown_tmo;
384 /* 386 /*
385 * PCI related info. 387 * PCI related info.
386 */ 388 */
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index 1af578dec27..18352ff8210 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -11,6 +11,7 @@
11 * Written by: Anil Veerabhadrappa (anilgv@broadcom.com) 11 * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
12 */ 12 */
13 13
14#include <linux/gfp.h>
14#include <scsi/scsi_tcq.h> 15#include <scsi/scsi_tcq.h>
15#include <scsi/libiscsi.h> 16#include <scsi/libiscsi.h>
16#include "bnx2i.h" 17#include "bnx2i.h"
diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index 6d8172e781c..5d9296c599f 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -177,11 +177,22 @@ void bnx2i_stop(void *handle)
177 struct bnx2i_hba *hba = handle; 177 struct bnx2i_hba *hba = handle;
178 178
179 /* check if cleanup happened in GOING_DOWN context */ 179 /* check if cleanup happened in GOING_DOWN context */
180 clear_bit(ADAPTER_STATE_UP, &hba->adapter_state);
181 if (!test_and_clear_bit(ADAPTER_STATE_GOING_DOWN, 180 if (!test_and_clear_bit(ADAPTER_STATE_GOING_DOWN,
182 &hba->adapter_state)) 181 &hba->adapter_state))
183 iscsi_host_for_each_session(hba->shost, 182 iscsi_host_for_each_session(hba->shost,
184 bnx2i_drop_session); 183 bnx2i_drop_session);
184
185 /* Wait for all endpoints to be torn down, Chip will be reset once
186 * control returns to network driver. So it is required to cleanup and
187 * release all connection resources before returning from this routine.
188 */
189 wait_event_interruptible_timeout(hba->eh_wait,
190 (hba->ofld_conns_active == 0),
191 hba->hba_shutdown_tmo);
192 /* This flag should be cleared last so that ep_disconnect() gracefully
193 * cleans up connection context
194 */
195 clear_bit(ADAPTER_STATE_UP, &hba->adapter_state);
185} 196}
186 197
187/** 198/**
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index cb71dc98479..fa68ab34b99 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -12,6 +12,7 @@
12 * Written by: Anil Veerabhadrappa (anilgv@broadcom.com) 12 * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
13 */ 13 */
14 14
15#include <linux/slab.h>
15#include <scsi/scsi_tcq.h> 16#include <scsi/scsi_tcq.h>
16#include <scsi/libiscsi.h> 17#include <scsi/libiscsi.h>
17#include "bnx2i.h" 18#include "bnx2i.h"
@@ -819,6 +820,11 @@ struct bnx2i_hba *bnx2i_alloc_hba(struct cnic_dev *cnic)
819 820
820 spin_lock_init(&hba->lock); 821 spin_lock_init(&hba->lock);
821 mutex_init(&hba->net_dev_lock); 822 mutex_init(&hba->net_dev_lock);
823 init_waitqueue_head(&hba->eh_wait);
824 if (test_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type))
825 hba->hba_shutdown_tmo = 240 * HZ;
826 else /* 5706/5708/5709 */
827 hba->hba_shutdown_tmo = 30 * HZ;
822 828
823 if (iscsi_host_add(shost, &hba->pcidev->dev)) 829 if (iscsi_host_add(shost, &hba->pcidev->dev))
824 goto free_dump_mem; 830 goto free_dump_mem;
@@ -1657,8 +1663,8 @@ static struct iscsi_endpoint *bnx2i_ep_connect(struct Scsi_Host *shost,
1657 */ 1663 */
1658 hba = bnx2i_check_route(dst_addr); 1664 hba = bnx2i_check_route(dst_addr);
1659 1665
1660 if (!hba) { 1666 if (!hba || test_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state)) {
1661 rc = -ENOMEM; 1667 rc = -EINVAL;
1662 goto check_busy; 1668 goto check_busy;
1663 } 1669 }
1664 1670
@@ -1803,7 +1809,7 @@ static int bnx2i_ep_poll(struct iscsi_endpoint *ep, int timeout_ms)
1803 (bnx2i_ep->state == 1809 (bnx2i_ep->state ==
1804 EP_STATE_CONNECT_COMPL)), 1810 EP_STATE_CONNECT_COMPL)),
1805 msecs_to_jiffies(timeout_ms)); 1811 msecs_to_jiffies(timeout_ms));
1806 if (!rc || (bnx2i_ep->state == EP_STATE_OFLD_FAILED)) 1812 if (bnx2i_ep->state == EP_STATE_OFLD_FAILED)
1807 rc = -1; 1813 rc = -1;
1808 1814
1809 if (rc > 0) 1815 if (rc > 0)
@@ -1956,6 +1962,8 @@ return_bnx2i_ep:
1956 1962
1957 if (!hba->ofld_conns_active) 1963 if (!hba->ofld_conns_active)
1958 bnx2i_unreg_dev_all(); 1964 bnx2i_unreg_dev_all();
1965
1966 wake_up_interruptible(&hba->eh_wait);
1959} 1967}
1960 1968
1961 1969
diff --git a/drivers/scsi/bvme6000_scsi.c b/drivers/scsi/bvme6000_scsi.c
index 5799cb5cba6..d40ea2f5be1 100644
--- a/drivers/scsi/bvme6000_scsi.c
+++ b/drivers/scsi/bvme6000_scsi.c
@@ -12,6 +12,7 @@
12#include <linux/platform_device.h> 12#include <linux/platform_device.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/interrupt.h> 14#include <linux/interrupt.h>
15#include <linux/slab.h>
15#include <asm/bvme6000hw.h> 16#include <asm/bvme6000hw.h>
16#include <scsi/scsi_host.h> 17#include <scsi/scsi_host.h>
17#include <scsi/scsi_device.h> 18#include <scsi/scsi_device.h>
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index fe11c1d4b31..4799d439120 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -23,6 +23,7 @@
23#include <linux/mutex.h> 23#include <linux/mutex.h>
24#include <linux/idr.h> 24#include <linux/idr.h>
25#include <linux/smp_lock.h> 25#include <linux/smp_lock.h>
26#include <linux/slab.h>
26 27
27#include <scsi/scsi.h> 28#include <scsi/scsi.h>
28#include <scsi/scsi_cmnd.h> 29#include <scsi/scsi_cmnd.h>
diff --git a/drivers/scsi/cxgb3i/cxgb3i_ddp.c b/drivers/scsi/cxgb3i/cxgb3i_ddp.c
index 344fd53b995..b58d9134ac1 100644
--- a/drivers/scsi/cxgb3i/cxgb3i_ddp.c
+++ b/drivers/scsi/cxgb3i/cxgb3i_ddp.c
@@ -10,6 +10,7 @@
10 * Written by: Karen Xie (kxie@chelsio.com) 10 * Written by: Karen Xie (kxie@chelsio.com)
11 */ 11 */
12 12
13#include <linux/slab.h>
13#include <linux/skbuff.h> 14#include <linux/skbuff.h>
14#include <linux/scatterlist.h> 15#include <linux/scatterlist.h>
15 16
diff --git a/drivers/scsi/cxgb3i/cxgb3i_ddp.h b/drivers/scsi/cxgb3i/cxgb3i_ddp.h
index 87dd56b422b..6761b329124 100644
--- a/drivers/scsi/cxgb3i/cxgb3i_ddp.h
+++ b/drivers/scsi/cxgb3i/cxgb3i_ddp.h
@@ -13,6 +13,7 @@
13#ifndef __CXGB3I_ULP2_DDP_H__ 13#ifndef __CXGB3I_ULP2_DDP_H__
14#define __CXGB3I_ULP2_DDP_H__ 14#define __CXGB3I_ULP2_DDP_H__
15 15
16#include <linux/slab.h>
16#include <linux/vmalloc.h> 17#include <linux/vmalloc.h>
17 18
18/** 19/**
diff --git a/drivers/scsi/cxgb3i/cxgb3i_iscsi.c b/drivers/scsi/cxgb3i/cxgb3i_iscsi.c
index b7c30585dad..7b686abaae6 100644
--- a/drivers/scsi/cxgb3i/cxgb3i_iscsi.c
+++ b/drivers/scsi/cxgb3i/cxgb3i_iscsi.c
@@ -12,6 +12,7 @@
12 */ 12 */
13 13
14#include <linux/inet.h> 14#include <linux/inet.h>
15#include <linux/slab.h>
15#include <linux/crypto.h> 16#include <linux/crypto.h>
16#include <linux/if_vlan.h> 17#include <linux/if_vlan.h>
17#include <net/dst.h> 18#include <net/dst.h>
diff --git a/drivers/scsi/cxgb3i/cxgb3i_offload.c b/drivers/scsi/cxgb3i/cxgb3i_offload.c
index 3e08c430ff2..a175be9c496 100644
--- a/drivers/scsi/cxgb3i/cxgb3i_offload.c
+++ b/drivers/scsi/cxgb3i/cxgb3i_offload.c
@@ -13,6 +13,7 @@
13 */ 13 */
14 14
15#include <linux/if_vlan.h> 15#include <linux/if_vlan.h>
16#include <linux/slab.h>
16#include <linux/version.h> 17#include <linux/version.h>
17 18
18#include "cxgb3_defs.h" 19#include "cxgb3_defs.h"
diff --git a/drivers/scsi/cxgb3i/cxgb3i_pdu.c b/drivers/scsi/cxgb3i/cxgb3i_pdu.c
index 9c38539557f..dc5e3e77a35 100644
--- a/drivers/scsi/cxgb3i/cxgb3i_pdu.c
+++ b/drivers/scsi/cxgb3i/cxgb3i_pdu.c
@@ -12,6 +12,7 @@
12 * Written by: Karen Xie (kxie@chelsio.com) 12 * Written by: Karen Xie (kxie@chelsio.com)
13 */ 13 */
14 14
15#include <linux/slab.h>
15#include <linux/skbuff.h> 16#include <linux/skbuff.h>
16#include <linux/crypto.h> 17#include <linux/crypto.h>
17#include <scsi/scsi_cmnd.h> 18#include <scsi/scsi_cmnd.h>
diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
index 6c59c02c1ed..bd977be7544 100644
--- a/drivers/scsi/dc395x.c
+++ b/drivers/scsi/dc395x.c
@@ -57,6 +57,7 @@
57#include <linux/pci.h> 57#include <linux/pci.h>
58#include <linux/list.h> 58#include <linux/list.h>
59#include <linux/vmalloc.h> 59#include <linux/vmalloc.h>
60#include <linux/slab.h>
60#include <asm/io.h> 61#include <asm/io.h>
61 62
62#include <scsi/scsi.h> 63#include <scsi/scsi.h>
diff --git a/drivers/scsi/device_handler/scsi_dh.c b/drivers/scsi/device_handler/scsi_dh.c
index e19a1a55270..6fae3d285ae 100644
--- a/drivers/scsi/device_handler/scsi_dh.c
+++ b/drivers/scsi/device_handler/scsi_dh.c
@@ -21,6 +21,7 @@
21 * Mike Anderson <andmike@linux.vnet.ibm.com> 21 * Mike Anderson <andmike@linux.vnet.ibm.com>
22 */ 22 */
23 23
24#include <linux/slab.h>
24#include <scsi/scsi_dh.h> 25#include <scsi/scsi_dh.h>
25#include "../scsi_priv.h" 26#include "../scsi_priv.h"
26 27
diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c
index bc9e94f5915..1a970a76b1b 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -19,6 +19,7 @@
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * 20 *
21 */ 21 */
22#include <linux/slab.h>
22#include <scsi/scsi.h> 23#include <scsi/scsi.h>
23#include <scsi/scsi_eh.h> 24#include <scsi/scsi_eh.h>
24#include <scsi/scsi_dh.h> 25#include <scsi/scsi_dh.h>
diff --git a/drivers/scsi/device_handler/scsi_dh_emc.c b/drivers/scsi/device_handler/scsi_dh_emc.c
index 63032ec3db9..e8a0bc3efd4 100644
--- a/drivers/scsi/device_handler/scsi_dh_emc.c
+++ b/drivers/scsi/device_handler/scsi_dh_emc.c
@@ -20,6 +20,7 @@
20 * along with this program; see the file COPYING. If not, write to 20 * along with this program; see the file COPYING. If not, write to
21 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 21 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 22 */
23#include <linux/slab.h>
23#include <scsi/scsi.h> 24#include <scsi/scsi.h>
24#include <scsi/scsi_eh.h> 25#include <scsi/scsi_eh.h>
25#include <scsi/scsi_dh.h> 26#include <scsi/scsi_dh.h>
diff --git a/drivers/scsi/device_handler/scsi_dh_hp_sw.c b/drivers/scsi/device_handler/scsi_dh_hp_sw.c
index 857fdd6032b..e3916641e62 100644
--- a/drivers/scsi/device_handler/scsi_dh_hp_sw.c
+++ b/drivers/scsi/device_handler/scsi_dh_hp_sw.c
@@ -21,6 +21,7 @@
21 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 21 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 22 */
23 23
24#include <linux/slab.h>
24#include <scsi/scsi.h> 25#include <scsi/scsi.h>
25#include <scsi/scsi_dbg.h> 26#include <scsi/scsi_dbg.h>
26#include <scsi/scsi_eh.h> 27#include <scsi/scsi_eh.h>
diff --git a/drivers/scsi/device_handler/scsi_dh_rdac.c b/drivers/scsi/device_handler/scsi_dh_rdac.c
index 1a660191a90..5b683e42954 100644
--- a/drivers/scsi/device_handler/scsi_dh_rdac.c
+++ b/drivers/scsi/device_handler/scsi_dh_rdac.c
@@ -23,6 +23,7 @@
23#include <scsi/scsi_eh.h> 23#include <scsi/scsi_eh.h>
24#include <scsi/scsi_dh.h> 24#include <scsi/scsi_dh.h>
25#include <linux/workqueue.h> 25#include <linux/workqueue.h>
26#include <linux/slab.h>
26 27
27#define RDAC_NAME "rdac" 28#define RDAC_NAME "rdac"
28#define RDAC_RETRY_COUNT 5 29#define RDAC_RETRY_COUNT 5
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index 496764349c4..0435d044c9d 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -188,7 +188,8 @@ MODULE_DEVICE_TABLE(pci,dptids);
188static int adpt_detect(struct scsi_host_template* sht) 188static int adpt_detect(struct scsi_host_template* sht)
189{ 189{
190 struct pci_dev *pDev = NULL; 190 struct pci_dev *pDev = NULL;
191 adpt_hba* pHba; 191 adpt_hba *pHba;
192 adpt_hba *next;
192 193
193 PINFO("Detecting Adaptec I2O RAID controllers...\n"); 194 PINFO("Detecting Adaptec I2O RAID controllers...\n");
194 195
@@ -206,7 +207,8 @@ static int adpt_detect(struct scsi_host_template* sht)
206 } 207 }
207 208
208 /* In INIT state, Activate IOPs */ 209 /* In INIT state, Activate IOPs */
209 for (pHba = hba_chain; pHba; pHba = pHba->next) { 210 for (pHba = hba_chain; pHba; pHba = next) {
211 next = pHba->next;
210 // Activate does get status , init outbound, and get hrt 212 // Activate does get status , init outbound, and get hrt
211 if (adpt_i2o_activate_hba(pHba) < 0) { 213 if (adpt_i2o_activate_hba(pHba) < 0) {
212 adpt_i2o_delete_hba(pHba); 214 adpt_i2o_delete_hba(pHba);
@@ -243,7 +245,8 @@ rebuild_sys_tab:
243 PDEBUG("HBA's in OPERATIONAL state\n"); 245 PDEBUG("HBA's in OPERATIONAL state\n");
244 246
245 printk("dpti: If you have a lot of devices this could take a few minutes.\n"); 247 printk("dpti: If you have a lot of devices this could take a few minutes.\n");
246 for (pHba = hba_chain; pHba; pHba = pHba->next) { 248 for (pHba = hba_chain; pHba; pHba = next) {
249 next = pHba->next;
247 printk(KERN_INFO"%s: Reading the hardware resource table.\n", pHba->name); 250 printk(KERN_INFO"%s: Reading the hardware resource table.\n", pHba->name);
248 if (adpt_i2o_lct_get(pHba) < 0){ 251 if (adpt_i2o_lct_get(pHba) < 0){
249 adpt_i2o_delete_hba(pHba); 252 adpt_i2o_delete_hba(pHba);
@@ -263,7 +266,8 @@ rebuild_sys_tab:
263 adpt_sysfs_class = NULL; 266 adpt_sysfs_class = NULL;
264 } 267 }
265 268
266 for (pHba = hba_chain; pHba; pHba = pHba->next) { 269 for (pHba = hba_chain; pHba; pHba = next) {
270 next = pHba->next;
267 if (adpt_scsi_host_alloc(pHba, sht) < 0){ 271 if (adpt_scsi_host_alloc(pHba, sht) < 0){
268 adpt_i2o_delete_hba(pHba); 272 adpt_i2o_delete_hba(pHba);
269 continue; 273 continue;
@@ -1229,11 +1233,10 @@ static void adpt_i2o_delete_hba(adpt_hba* pHba)
1229 } 1233 }
1230 } 1234 }
1231 pci_dev_put(pHba->pDev); 1235 pci_dev_put(pHba->pDev);
1232 kfree(pHba);
1233
1234 if (adpt_sysfs_class) 1236 if (adpt_sysfs_class)
1235 device_destroy(adpt_sysfs_class, 1237 device_destroy(adpt_sysfs_class,
1236 MKDEV(DPTI_I2O_MAJOR, pHba->unit)); 1238 MKDEV(DPTI_I2O_MAJOR, pHba->unit));
1239 kfree(pHba);
1237 1240
1238 if(hba_count <= 0){ 1241 if(hba_count <= 0){
1239 unregister_chrdev(DPTI_I2O_MAJOR, DPT_DRIVER); 1242 unregister_chrdev(DPTI_I2O_MAJOR, DPT_DRIVER);
diff --git a/drivers/scsi/eata.c b/drivers/scsi/eata.c
index 3c5abf7cd76..d1c31378f6d 100644
--- a/drivers/scsi/eata.c
+++ b/drivers/scsi/eata.c
@@ -490,6 +490,7 @@
490#include <linux/ctype.h> 490#include <linux/ctype.h>
491#include <linux/spinlock.h> 491#include <linux/spinlock.h>
492#include <linux/dma-mapping.h> 492#include <linux/dma-mapping.h>
493#include <linux/slab.h>
493#include <asm/byteorder.h> 494#include <asm/byteorder.h>
494#include <asm/dma.h> 495#include <asm/dma.h>
495#include <asm/io.h> 496#include <asm/io.h>
diff --git a/drivers/scsi/eata_pio.c b/drivers/scsi/eata_pio.c
index 152dd15db27..60886c19065 100644
--- a/drivers/scsi/eata_pio.c
+++ b/drivers/scsi/eata_pio.c
@@ -50,7 +50,6 @@
50#include <linux/kernel.h> 50#include <linux/kernel.h>
51#include <linux/string.h> 51#include <linux/string.h>
52#include <linux/ioport.h> 52#include <linux/ioport.h>
53#include <linux/slab.h>
54#include <linux/in.h> 53#include <linux/in.h>
55#include <linux/pci.h> 54#include <linux/pci.h>
56#include <linux/proc_fs.h> 55#include <linux/proc_fs.h>
diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index 2f47ae7cce9..f01b9b44e8a 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -26,6 +26,7 @@
26#include <linux/if_ether.h> 26#include <linux/if_ether.h>
27#include <linux/if_vlan.h> 27#include <linux/if_vlan.h>
28#include <linux/crc32.h> 28#include <linux/crc32.h>
29#include <linux/slab.h>
29#include <linux/cpu.h> 30#include <linux/cpu.h>
30#include <linux/fs.h> 31#include <linux/fs.h>
31#include <linux/sysfs.h> 32#include <linux/sysfs.h>
diff --git a/drivers/scsi/fcoe/libfcoe.c b/drivers/scsi/fcoe/libfcoe.c
index 511cb6b371e..3440da48d16 100644
--- a/drivers/scsi/fcoe/libfcoe.c
+++ b/drivers/scsi/fcoe/libfcoe.c
@@ -31,6 +31,7 @@
31#include <linux/if_vlan.h> 31#include <linux/if_vlan.h>
32#include <linux/errno.h> 32#include <linux/errno.h>
33#include <linux/bitops.h> 33#include <linux/bitops.h>
34#include <linux/slab.h>
34#include <net/rtnetlink.h> 35#include <net/rtnetlink.h>
35 36
36#include <scsi/fc/fc_els.h> 37#include <scsi/fc/fc_els.h>
diff --git a/drivers/scsi/fd_mcs.c b/drivers/scsi/fd_mcs.c
index 85bd54c77b5..2ad95aa8f58 100644
--- a/drivers/scsi/fd_mcs.c
+++ b/drivers/scsi/fd_mcs.c
@@ -88,6 +88,7 @@
88#include <linux/delay.h> 88#include <linux/delay.h>
89#include <linux/mca.h> 89#include <linux/mca.h>
90#include <linux/spinlock.h> 90#include <linux/spinlock.h>
91#include <linux/slab.h>
91#include <scsi/scsicam.h> 92#include <scsi/scsicam.h>
92#include <linux/mca-legacy.h> 93#include <linux/mca-legacy.h>
93 94
diff --git a/drivers/scsi/fdomain.c b/drivers/scsi/fdomain.c
index 32eef66114c..e296bcc57d5 100644
--- a/drivers/scsi/fdomain.c
+++ b/drivers/scsi/fdomain.c
@@ -279,6 +279,7 @@
279#include <linux/stat.h> 279#include <linux/stat.h>
280#include <linux/delay.h> 280#include <linux/delay.h>
281#include <linux/io.h> 281#include <linux/io.h>
282#include <linux/slab.h>
282#include <scsi/scsicam.h> 283#include <scsi/scsicam.h>
283 284
284#include <asm/system.h> 285#include <asm/system.h>
diff --git a/drivers/scsi/fnic/fnic_fcs.c b/drivers/scsi/fnic/fnic_fcs.c
index 54f8d0e5407..5259888fbfb 100644
--- a/drivers/scsi/fnic/fnic_fcs.c
+++ b/drivers/scsi/fnic/fnic_fcs.c
@@ -17,6 +17,7 @@
17 */ 17 */
18#include <linux/errno.h> 18#include <linux/errno.h>
19#include <linux/pci.h> 19#include <linux/pci.h>
20#include <linux/slab.h>
20#include <linux/skbuff.h> 21#include <linux/skbuff.h>
21#include <linux/interrupt.h> 22#include <linux/interrupt.h>
22#include <linux/spinlock.h> 23#include <linux/spinlock.h>
diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c
index 507e26c1c29..97b212570bc 100644
--- a/drivers/scsi/fnic/fnic_main.c
+++ b/drivers/scsi/fnic/fnic_main.c
@@ -18,6 +18,7 @@
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/mempool.h> 19#include <linux/mempool.h>
20#include <linux/string.h> 20#include <linux/string.h>
21#include <linux/slab.h>
21#include <linux/errno.h> 22#include <linux/errno.h>
22#include <linux/init.h> 23#include <linux/init.h>
23#include <linux/pci.h> 24#include <linux/pci.h>
diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index 65a39b0f6dc..3cc47c6e1ad 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -26,6 +26,7 @@
26#include <linux/if_ether.h> 26#include <linux/if_ether.h>
27#include <linux/if_vlan.h> 27#include <linux/if_vlan.h>
28#include <linux/delay.h> 28#include <linux/delay.h>
29#include <linux/gfp.h>
29#include <scsi/scsi.h> 30#include <scsi/scsi.h>
30#include <scsi/scsi_host.h> 31#include <scsi/scsi_host.h>
31#include <scsi/scsi_device.h> 32#include <scsi/scsi_device.h>
diff --git a/drivers/scsi/fnic/vnic_dev.c b/drivers/scsi/fnic/vnic_dev.c
index 56677064508..db710148d15 100644
--- a/drivers/scsi/fnic/vnic_dev.c
+++ b/drivers/scsi/fnic/vnic_dev.c
@@ -22,6 +22,7 @@
22#include <linux/pci.h> 22#include <linux/pci.h>
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/if_ether.h> 24#include <linux/if_ether.h>
25#include <linux/slab.h>
25#include "vnic_resource.h" 26#include "vnic_resource.h"
26#include "vnic_devcmd.h" 27#include "vnic_devcmd.h"
27#include "vnic_dev.h" 28#include "vnic_dev.h"
diff --git a/drivers/scsi/fnic/vnic_rq.c b/drivers/scsi/fnic/vnic_rq.c
index bedd0d28563..fd2068f5ae1 100644
--- a/drivers/scsi/fnic/vnic_rq.c
+++ b/drivers/scsi/fnic/vnic_rq.c
@@ -20,6 +20,7 @@
20#include <linux/types.h> 20#include <linux/types.h>
21#include <linux/pci.h> 21#include <linux/pci.h>
22#include <linux/delay.h> 22#include <linux/delay.h>
23#include <linux/slab.h>
23#include "vnic_dev.h" 24#include "vnic_dev.h"
24#include "vnic_rq.h" 25#include "vnic_rq.h"
25 26
diff --git a/drivers/scsi/fnic/vnic_wq.c b/drivers/scsi/fnic/vnic_wq.c
index 1f9ea790d13..a414135460d 100644
--- a/drivers/scsi/fnic/vnic_wq.c
+++ b/drivers/scsi/fnic/vnic_wq.c
@@ -20,6 +20,7 @@
20#include <linux/types.h> 20#include <linux/types.h>
21#include <linux/pci.h> 21#include <linux/pci.h>
22#include <linux/delay.h> 22#include <linux/delay.h>
23#include <linux/slab.h>
23#include "vnic_dev.h" 24#include "vnic_dev.h"
24#include "vnic_wq.h" 25#include "vnic_wq.h"
25 26
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index ba3c94c9c25..35a4b3073ec 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -121,6 +121,7 @@
121#include <linux/dma-mapping.h> 121#include <linux/dma-mapping.h>
122#include <linux/list.h> 122#include <linux/list.h>
123#include <linux/smp_lock.h> 123#include <linux/smp_lock.h>
124#include <linux/slab.h>
124 125
125#ifdef GDTH_RTC 126#ifdef GDTH_RTC
126#include <linux/mc146818rtc.h> 127#include <linux/mc146818rtc.h>
diff --git a/drivers/scsi/gdth_proc.c b/drivers/scsi/gdth_proc.c
index ffb2b21992b..0572b9bf4bd 100644
--- a/drivers/scsi/gdth_proc.c
+++ b/drivers/scsi/gdth_proc.c
@@ -3,6 +3,7 @@
3 */ 3 */
4 4
5#include <linux/completion.h> 5#include <linux/completion.h>
6#include <linux/slab.h>
6 7
7int gdth_proc_info(struct Scsi_Host *host, char *buffer,char **start,off_t offset,int length, 8int gdth_proc_info(struct Scsi_Host *host, char *buffer,char **start,off_t offset,int length,
8 int inout) 9 int inout)
diff --git a/drivers/scsi/gvp11.c b/drivers/scsi/gvp11.c
index 5d1bf7e3d24..48f406850c6 100644
--- a/drivers/scsi/gvp11.c
+++ b/drivers/scsi/gvp11.c
@@ -1,5 +1,6 @@
1#include <linux/types.h> 1#include <linux/types.h>
2#include <linux/mm.h> 2#include <linux/mm.h>
3#include <linux/slab.h>
3#include <linux/blkdev.h> 4#include <linux/blkdev.h>
4#include <linux/init.h> 5#include <linux/init.h>
5#include <linux/interrupt.h> 6#include <linux/interrupt.h>
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 09dbcb847b7..6660fa92ffa 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -24,6 +24,7 @@
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/blkdev.h> 25#include <linux/blkdev.h>
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/slab.h>
27#include <linux/kthread.h> 28#include <linux/kthread.h>
28#include <linux/string.h> 29#include <linux/string.h>
29#include <linux/mm.h> 30#include <linux/mm.h>
diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c
index 4f0556571f8..645f7cdf21a 100644
--- a/drivers/scsi/hptiop.c
+++ b/drivers/scsi/hptiop.c
@@ -25,6 +25,7 @@
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/timer.h> 26#include <linux/timer.h>
27#include <linux/spinlock.h> 27#include <linux/spinlock.h>
28#include <linux/gfp.h>
28#include <asm/uaccess.h> 29#include <asm/uaccess.h>
29#include <asm/io.h> 30#include <asm/io.h>
30#include <asm/div64.h> 31#include <asm/div64.h>
diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
index 4e577e2fee3..c2eea711a5c 100644
--- a/drivers/scsi/ibmvscsi/ibmvfc.c
+++ b/drivers/scsi/ibmvscsi/ibmvfc.c
@@ -28,6 +28,7 @@
28#include <linux/delay.h> 28#include <linux/delay.h>
29#include <linux/interrupt.h> 29#include <linux/interrupt.h>
30#include <linux/kthread.h> 30#include <linux/kthread.h>
31#include <linux/slab.h>
31#include <linux/of.h> 32#include <linux/of.h>
32#include <linux/pm.h> 33#include <linux/pm.h>
33#include <linux/stringify.h> 34#include <linux/stringify.h>
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
index dc1bcbe3b17..88bad0e81bd 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -70,6 +70,7 @@
70#include <linux/moduleparam.h> 70#include <linux/moduleparam.h>
71#include <linux/dma-mapping.h> 71#include <linux/dma-mapping.h>
72#include <linux/delay.h> 72#include <linux/delay.h>
73#include <linux/slab.h>
73#include <linux/of.h> 74#include <linux/of.h>
74#include <linux/pm.h> 75#include <linux/pm.h>
75#include <asm/firmware.h> 76#include <asm/firmware.h>
@@ -322,16 +323,6 @@ static void set_srp_direction(struct scsi_cmnd *cmd,
322 srp_cmd->buf_fmt = fmt; 323 srp_cmd->buf_fmt = fmt;
323} 324}
324 325
325static void unmap_sg_list(int num_entries,
326 struct device *dev,
327 struct srp_direct_buf *md)
328{
329 int i;
330
331 for (i = 0; i < num_entries; ++i)
332 dma_unmap_single(dev, md[i].va, md[i].len, DMA_BIDIRECTIONAL);
333}
334
335/** 326/**
336 * unmap_cmd_data: - Unmap data pointed in srp_cmd based on the format 327 * unmap_cmd_data: - Unmap data pointed in srp_cmd based on the format
337 * @cmd: srp_cmd whose additional_data member will be unmapped 328 * @cmd: srp_cmd whose additional_data member will be unmapped
@@ -349,24 +340,9 @@ static void unmap_cmd_data(struct srp_cmd *cmd,
349 340
350 if (out_fmt == SRP_NO_DATA_DESC && in_fmt == SRP_NO_DATA_DESC) 341 if (out_fmt == SRP_NO_DATA_DESC && in_fmt == SRP_NO_DATA_DESC)
351 return; 342 return;
352 else if (out_fmt == SRP_DATA_DESC_DIRECT ||
353 in_fmt == SRP_DATA_DESC_DIRECT) {
354 struct srp_direct_buf *data =
355 (struct srp_direct_buf *) cmd->add_data;
356 dma_unmap_single(dev, data->va, data->len, DMA_BIDIRECTIONAL);
357 } else {
358 struct srp_indirect_buf *indirect =
359 (struct srp_indirect_buf *) cmd->add_data;
360 int num_mapped = indirect->table_desc.len /
361 sizeof(struct srp_direct_buf);
362 343
363 if (num_mapped <= MAX_INDIRECT_BUFS) { 344 if (evt_struct->cmnd)
364 unmap_sg_list(num_mapped, dev, &indirect->desc_list[0]); 345 scsi_dma_unmap(evt_struct->cmnd);
365 return;
366 }
367
368 unmap_sg_list(num_mapped, dev, evt_struct->ext_list);
369 }
370} 346}
371 347
372static int map_sg_list(struct scsi_cmnd *cmd, int nseg, 348static int map_sg_list(struct scsi_cmnd *cmd, int nseg,
diff --git a/drivers/scsi/ibmvscsi/ibmvstgt.c b/drivers/scsi/ibmvscsi/ibmvstgt.c
index d5eaf972710..e2056d517e9 100644
--- a/drivers/scsi/ibmvscsi/ibmvstgt.c
+++ b/drivers/scsi/ibmvscsi/ibmvstgt.c
@@ -23,6 +23,7 @@
23 */ 23 */
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/slab.h>
26#include <scsi/scsi.h> 27#include <scsi/scsi.h>
27#include <scsi/scsi_host.h> 28#include <scsi/scsi_host.h>
28#include <scsi/scsi_transport_srp.h> 29#include <scsi/scsi_transport_srp.h>
diff --git a/drivers/scsi/ibmvscsi/rpa_vscsi.c b/drivers/scsi/ibmvscsi/rpa_vscsi.c
index 63a30cbbf9d..a864ccc0a34 100644
--- a/drivers/scsi/ibmvscsi/rpa_vscsi.c
+++ b/drivers/scsi/ibmvscsi/rpa_vscsi.c
@@ -32,6 +32,7 @@
32#include <asm/iommu.h> 32#include <asm/iommu.h>
33#include <asm/hvcall.h> 33#include <asm/hvcall.h>
34#include <linux/dma-mapping.h> 34#include <linux/dma-mapping.h>
35#include <linux/gfp.h>
35#include <linux/interrupt.h> 36#include <linux/interrupt.h>
36#include "ibmvscsi.h" 37#include "ibmvscsi.h"
37 38
diff --git a/drivers/scsi/imm.c b/drivers/scsi/imm.c
index c2a9a13d788..4734ab0b3ff 100644
--- a/drivers/scsi/imm.c
+++ b/drivers/scsi/imm.c
@@ -15,6 +15,7 @@
15#include <linux/parport.h> 15#include <linux/parport.h>
16#include <linux/workqueue.h> 16#include <linux/workqueue.h>
17#include <linux/delay.h> 17#include <linux/delay.h>
18#include <linux/slab.h>
18#include <asm/io.h> 19#include <asm/io.h>
19 20
20#include <scsi/scsi.h> 21#include <scsi/scsi.h>
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index c79cd98eb6b..520461b9bc0 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -59,6 +59,7 @@
59#include <linux/types.h> 59#include <linux/types.h>
60#include <linux/errno.h> 60#include <linux/errno.h>
61#include <linux/kernel.h> 61#include <linux/kernel.h>
62#include <linux/slab.h>
62#include <linux/ioport.h> 63#include <linux/ioport.h>
63#include <linux/delay.h> 64#include <linux/delay.h>
64#include <linux/pci.h> 65#include <linux/pci.h>
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 249053a9d4f..02143af7c1a 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -28,6 +28,7 @@
28 28
29#include <linux/types.h> 29#include <linux/types.h>
30#include <linux/inet.h> 30#include <linux/inet.h>
31#include <linux/slab.h>
31#include <linux/file.h> 32#include <linux/file.h>
32#include <linux/blkdev.h> 33#include <linux/blkdev.h>
33#include <linux/crypto.h> 34#include <linux/crypto.h>
@@ -598,7 +599,7 @@ static void iscsi_sw_tcp_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)
598 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx); 599 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx);
599 write_unlock_bh(&tcp_sw_conn->sock->sk->sk_callback_lock); 600 write_unlock_bh(&tcp_sw_conn->sock->sk->sk_callback_lock);
600 601
601 if (sock->sk->sk_sleep && waitqueue_active(sock->sk->sk_sleep)) { 602 if (sock->sk->sk_sleep) {
602 sock->sk->sk_err = EIO; 603 sock->sk->sk_err = EIO;
603 wake_up_interruptible(sock->sk->sk_sleep); 604 wake_up_interruptible(sock->sk->sk_sleep);
604 } 605 }
diff --git a/drivers/scsi/jazz_esp.c b/drivers/scsi/jazz_esp.c
index b2d481dd375..08e26d4e373 100644
--- a/drivers/scsi/jazz_esp.c
+++ b/drivers/scsi/jazz_esp.c
@@ -4,6 +4,7 @@
4 */ 4 */
5 5
6#include <linux/kernel.h> 6#include <linux/kernel.h>
7#include <linux/gfp.h>
7#include <linux/types.h> 8#include <linux/types.h>
8#include <linux/module.h> 9#include <linux/module.h>
9#include <linux/init.h> 10#include <linux/init.h>
diff --git a/drivers/scsi/lasi700.c b/drivers/scsi/lasi700.c
index b3d31315ac3..23880f8fe7e 100644
--- a/drivers/scsi/lasi700.c
+++ b/drivers/scsi/lasi700.c
@@ -40,6 +40,7 @@
40#include <linux/blkdev.h> 40#include <linux/blkdev.h>
41#include <linux/ioport.h> 41#include <linux/ioport.h>
42#include <linux/dma-mapping.h> 42#include <linux/dma-mapping.h>
43#include <linux/slab.h>
43 44
44#include <asm/page.h> 45#include <asm/page.h>
45#include <asm/pgtable.h> 46#include <asm/pgtable.h>
diff --git a/drivers/scsi/libfc/fc_disc.c b/drivers/scsi/libfc/fc_disc.c
index 9b0a5192a96..1087a7f18e8 100644
--- a/drivers/scsi/libfc/fc_disc.c
+++ b/drivers/scsi/libfc/fc_disc.c
@@ -33,6 +33,7 @@
33 */ 33 */
34 34
35#include <linux/timer.h> 35#include <linux/timer.h>
36#include <linux/slab.h>
36#include <linux/err.h> 37#include <linux/err.h>
37#include <asm/unaligned.h> 38#include <asm/unaligned.h>
38 39
diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
index 7f4364770e4..e5df0d4db67 100644
--- a/drivers/scsi/libfc/fc_exch.c
+++ b/drivers/scsi/libfc/fc_exch.c
@@ -24,7 +24,7 @@
24 */ 24 */
25 25
26#include <linux/timer.h> 26#include <linux/timer.h>
27#include <linux/gfp.h> 27#include <linux/slab.h>
28#include <linux/err.h> 28#include <linux/err.h>
29 29
30#include <scsi/fc/fc_fc2.h> 30#include <scsi/fc/fc_fc2.h>
diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c
index 774e7ac837a..17396c708b0 100644
--- a/drivers/scsi/libfc/fc_fcp.c
+++ b/drivers/scsi/libfc/fc_fcp.c
@@ -27,6 +27,7 @@
27#include <linux/scatterlist.h> 27#include <linux/scatterlist.h>
28#include <linux/err.h> 28#include <linux/err.h>
29#include <linux/crc32.h> 29#include <linux/crc32.h>
30#include <linux/slab.h>
30 31
31#include <scsi/scsi_tcq.h> 32#include <scsi/scsi_tcq.h>
32#include <scsi/scsi.h> 33#include <scsi/scsi.h>
diff --git a/drivers/scsi/libfc/fc_frame.c b/drivers/scsi/libfc/fc_frame.c
index 6da01c61696..981329a17c4 100644
--- a/drivers/scsi/libfc/fc_frame.c
+++ b/drivers/scsi/libfc/fc_frame.c
@@ -24,6 +24,7 @@
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/skbuff.h> 25#include <linux/skbuff.h>
26#include <linux/crc32.h> 26#include <linux/crc32.h>
27#include <linux/gfp.h>
27 28
28#include <scsi/fc_frame.h> 29#include <scsi/fc_frame.h>
29 30
diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c
index 7ec8ce75007..d126ecfff70 100644
--- a/drivers/scsi/libfc/fc_lport.c
+++ b/drivers/scsi/libfc/fc_lport.c
@@ -88,6 +88,7 @@
88 */ 88 */
89 89
90#include <linux/timer.h> 90#include <linux/timer.h>
91#include <linux/slab.h>
91#include <asm/unaligned.h> 92#include <asm/unaligned.h>
92 93
93#include <scsi/fc/fc_gs.h> 94#include <scsi/fc/fc_gs.h>
diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c
index 97923bb0776..b37d0ff28b3 100644
--- a/drivers/scsi/libfc/fc_rport.c
+++ b/drivers/scsi/libfc/fc_rport.c
@@ -47,6 +47,7 @@
47#include <linux/kernel.h> 47#include <linux/kernel.h>
48#include <linux/spinlock.h> 48#include <linux/spinlock.h>
49#include <linux/interrupt.h> 49#include <linux/interrupt.h>
50#include <linux/slab.h>
50#include <linux/rcupdate.h> 51#include <linux/rcupdate.h>
51#include <linux/timer.h> 52#include <linux/timer.h>
52#include <linux/workqueue.h> 53#include <linux/workqueue.h>
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 685eaec5321..633e0903635 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -25,6 +25,7 @@
25#include <linux/kfifo.h> 25#include <linux/kfifo.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/log2.h> 27#include <linux/log2.h>
28#include <linux/slab.h>
28#include <asm/unaligned.h> 29#include <asm/unaligned.h>
29#include <net/tcp.h> 30#include <net/tcp.h>
30#include <scsi/scsi_cmnd.h> 31#include <scsi/scsi_cmnd.h>
@@ -470,12 +471,12 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)
470 471
471 WARN_ON(hdrlength >= 256); 472 WARN_ON(hdrlength >= 256);
472 hdr->hlength = hdrlength & 0xFF; 473 hdr->hlength = hdrlength & 0xFF;
474 hdr->cmdsn = task->cmdsn = cpu_to_be32(session->cmdsn);
473 475
474 if (session->tt->init_task && session->tt->init_task(task)) 476 if (session->tt->init_task && session->tt->init_task(task))
475 return -EIO; 477 return -EIO;
476 478
477 task->state = ISCSI_TASK_RUNNING; 479 task->state = ISCSI_TASK_RUNNING;
478 hdr->cmdsn = task->cmdsn = cpu_to_be32(session->cmdsn);
479 session->cmdsn++; 480 session->cmdsn++;
480 481
481 conn->scsicmd_pdus_cnt++; 482 conn->scsicmd_pdus_cnt++;
@@ -3087,14 +3088,15 @@ static void iscsi_start_session_recovery(struct iscsi_session *session,
3087 session->state = ISCSI_STATE_TERMINATE; 3088 session->state = ISCSI_STATE_TERMINATE;
3088 else if (conn->stop_stage != STOP_CONN_RECOVER) 3089 else if (conn->stop_stage != STOP_CONN_RECOVER)
3089 session->state = ISCSI_STATE_IN_RECOVERY; 3090 session->state = ISCSI_STATE_IN_RECOVERY;
3091
3092 old_stop_stage = conn->stop_stage;
3093 conn->stop_stage = flag;
3090 spin_unlock_bh(&session->lock); 3094 spin_unlock_bh(&session->lock);
3091 3095
3092 del_timer_sync(&conn->transport_timer); 3096 del_timer_sync(&conn->transport_timer);
3093 iscsi_suspend_tx(conn); 3097 iscsi_suspend_tx(conn);
3094 3098
3095 spin_lock_bh(&session->lock); 3099 spin_lock_bh(&session->lock);
3096 old_stop_stage = conn->stop_stage;
3097 conn->stop_stage = flag;
3098 conn->c_stage = ISCSI_CONN_STOPPED; 3100 conn->c_stage = ISCSI_CONN_STOPPED;
3099 spin_unlock_bh(&session->lock); 3101 spin_unlock_bh(&session->lock);
3100 3102
diff --git a/drivers/scsi/libiscsi_tcp.c b/drivers/scsi/libiscsi_tcp.c
index 4ad87fd74dd..5c92620292f 100644
--- a/drivers/scsi/libiscsi_tcp.c
+++ b/drivers/scsi/libiscsi_tcp.c
@@ -29,6 +29,7 @@
29#include <linux/types.h> 29#include <linux/types.h>
30#include <linux/list.h> 30#include <linux/list.h>
31#include <linux/inet.h> 31#include <linux/inet.h>
32#include <linux/slab.h>
32#include <linux/file.h> 33#include <linux/file.h>
33#include <linux/blkdev.h> 34#include <linux/blkdev.h>
34#include <linux/crypto.h> 35#include <linux/crypto.h>
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
index e1550117069..88f74467257 100644
--- a/drivers/scsi/libsas/sas_ata.c
+++ b/drivers/scsi/libsas/sas_ata.c
@@ -22,6 +22,7 @@
22 */ 22 */
23 23
24#include <linux/scatterlist.h> 24#include <linux/scatterlist.h>
25#include <linux/slab.h>
25 26
26#include <scsi/sas_ata.h> 27#include <scsi/sas_ata.h>
27#include "sas_internal.h" 28#include "sas_internal.h"
@@ -394,11 +395,15 @@ int sas_ata_init_host_and_port(struct domain_device *found_dev,
394void sas_ata_task_abort(struct sas_task *task) 395void sas_ata_task_abort(struct sas_task *task)
395{ 396{
396 struct ata_queued_cmd *qc = task->uldd_task; 397 struct ata_queued_cmd *qc = task->uldd_task;
398 struct request_queue *q = qc->scsicmd->device->request_queue;
397 struct completion *waiting; 399 struct completion *waiting;
400 unsigned long flags;
398 401
399 /* Bounce SCSI-initiated commands to the SCSI EH */ 402 /* Bounce SCSI-initiated commands to the SCSI EH */
400 if (qc->scsicmd) { 403 if (qc->scsicmd) {
404 spin_lock_irqsave(q->queue_lock, flags);
401 blk_abort_request(qc->scsicmd->request); 405 blk_abort_request(qc->scsicmd->request);
406 spin_unlock_irqrestore(q->queue_lock, flags);
402 scsi_schedule_eh(qc->scsicmd->device->host); 407 scsi_schedule_eh(qc->scsicmd->device->host);
403 return; 408 return;
404 } 409 }
diff --git a/drivers/scsi/libsas/sas_discover.c b/drivers/scsi/libsas/sas_discover.c
index facc5bfcf7d..f5831930df9 100644
--- a/drivers/scsi/libsas/sas_discover.c
+++ b/drivers/scsi/libsas/sas_discover.c
@@ -23,6 +23,7 @@
23 */ 23 */
24 24
25#include <linux/scatterlist.h> 25#include <linux/scatterlist.h>
26#include <linux/slab.h>
26#include <scsi/scsi_host.h> 27#include <scsi/scsi_host.h>
27#include <scsi/scsi_eh.h> 28#include <scsi/scsi_eh.h>
28#include "sas_internal.h" 29#include "sas_internal.h"
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index 33cf988c8c8..c65af02dcfe 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -24,6 +24,7 @@
24 24
25#include <linux/scatterlist.h> 25#include <linux/scatterlist.h>
26#include <linux/blkdev.h> 26#include <linux/blkdev.h>
27#include <linux/slab.h>
27 28
28#include "sas_internal.h" 29#include "sas_internal.h"
29 30
diff --git a/drivers/scsi/libsas/sas_host_smp.c b/drivers/scsi/libsas/sas_host_smp.c
index 1bc3b756799..04ad8dd1a74 100644
--- a/drivers/scsi/libsas/sas_host_smp.c
+++ b/drivers/scsi/libsas/sas_host_smp.c
@@ -10,6 +10,7 @@
10 */ 10 */
11#include <linux/scatterlist.h> 11#include <linux/scatterlist.h>
12#include <linux/blkdev.h> 12#include <linux/blkdev.h>
13#include <linux/slab.h>
13 14
14#include "sas_internal.h" 15#include "sas_internal.h"
15 16
diff --git a/drivers/scsi/libsas/sas_init.c b/drivers/scsi/libsas/sas_init.c
index 9cd5abe9e71..2dc55343f67 100644
--- a/drivers/scsi/libsas/sas_init.c
+++ b/drivers/scsi/libsas/sas_init.c
@@ -24,6 +24,7 @@
24 */ 24 */
25 25
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/slab.h>
27#include <linux/init.h> 28#include <linux/init.h>
28#include <linux/device.h> 29#include <linux/device.h>
29#include <linux/spinlock.h> 30#include <linux/spinlock.h>
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index 14b13196b22..822835055ce 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -44,6 +44,7 @@
44#include <linux/err.h> 44#include <linux/err.h>
45#include <linux/blkdev.h> 45#include <linux/blkdev.h>
46#include <linux/freezer.h> 46#include <linux/freezer.h>
47#include <linux/gfp.h>
47#include <linux/scatterlist.h> 48#include <linux/scatterlist.h>
48#include <linux/libata.h> 49#include <linux/libata.h>
49 50
@@ -1029,6 +1030,8 @@ int __sas_task_abort(struct sas_task *task)
1029void sas_task_abort(struct sas_task *task) 1030void sas_task_abort(struct sas_task *task)
1030{ 1031{
1031 struct scsi_cmnd *sc = task->uldd_task; 1032 struct scsi_cmnd *sc = task->uldd_task;
1033 struct request_queue *q = sc->device->request_queue;
1034 unsigned long flags;
1032 1035
1033 /* Escape for libsas internal commands */ 1036 /* Escape for libsas internal commands */
1034 if (!sc) { 1037 if (!sc) {
@@ -1043,7 +1046,9 @@ void sas_task_abort(struct sas_task *task)
1043 return; 1046 return;
1044 } 1047 }
1045 1048
1049 spin_lock_irqsave(q->queue_lock, flags);
1046 blk_abort_request(sc->request); 1050 blk_abort_request(sc->request);
1051 spin_unlock_irqrestore(q->queue_lock, flags);
1047 scsi_schedule_eh(sc->device->host); 1052 scsi_schedule_eh(sc->device->host);
1048} 1053}
1049 1054
diff --git a/drivers/scsi/libsrp.c b/drivers/scsi/libsrp.c
index 22775165bf6..ff6a28ce9b6 100644
--- a/drivers/scsi/libsrp.c
+++ b/drivers/scsi/libsrp.c
@@ -19,6 +19,7 @@
19 * 02110-1301 USA 19 * 02110-1301 USA
20 */ 20 */
21#include <linux/err.h> 21#include <linux/err.h>
22#include <linux/slab.h>
22#include <linux/kfifo.h> 23#include <linux/kfifo.h>
23#include <linux/scatterlist.h> 24#include <linux/scatterlist.h>
24#include <linux/dma-mapping.h> 25#include <linux/dma-mapping.h>
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 64cd17eedb6..1849e33e68f 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -24,6 +24,7 @@
24#include <linux/pci.h> 24#include <linux/pci.h>
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/aer.h> 26#include <linux/aer.h>
27#include <linux/gfp.h>
27 28
28#include <scsi/scsi.h> 29#include <scsi/scsi.h>
29#include <scsi/scsi_device.h> 30#include <scsi/scsi_device.h>
diff --git a/drivers/scsi/lpfc/lpfc_bsg.c b/drivers/scsi/lpfc/lpfc_bsg.c
index 692c29f6048..d62b3e46792 100644
--- a/drivers/scsi/lpfc/lpfc_bsg.c
+++ b/drivers/scsi/lpfc/lpfc_bsg.c
@@ -21,6 +21,7 @@
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/mempool.h> 22#include <linux/mempool.h>
23#include <linux/pci.h> 23#include <linux/pci.h>
24#include <linux/slab.h>
24#include <linux/delay.h> 25#include <linux/delay.h>
25 26
26#include <scsi/scsi.h> 27#include <scsi/scsi.h>
@@ -432,7 +433,7 @@ lpfc_bsg_rport_els_cmp(struct lpfc_hba *phba,
432 dd_data = cmdiocbq->context1; 433 dd_data = cmdiocbq->context1;
433 /* normal completion and timeout crossed paths, already done */ 434 /* normal completion and timeout crossed paths, already done */
434 if (!dd_data) { 435 if (!dd_data) {
435 spin_unlock_irqrestore(&phba->hbalock, flags); 436 spin_unlock_irqrestore(&phba->ct_ev_lock, flags);
436 return; 437 return;
437 } 438 }
438 439
@@ -1195,7 +1196,7 @@ lpfc_issue_ct_rsp_cmp(struct lpfc_hba *phba,
1195 dd_data = cmdiocbq->context1; 1196 dd_data = cmdiocbq->context1;
1196 /* normal completion and timeout crossed paths, already done */ 1197 /* normal completion and timeout crossed paths, already done */
1197 if (!dd_data) { 1198 if (!dd_data) {
1198 spin_unlock_irqrestore(&phba->hbalock, flags); 1199 spin_unlock_irqrestore(&phba->ct_ev_lock, flags);
1199 return; 1200 return;
1200 } 1201 }
1201 1202
diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
index c7e921973f6..463b74902ac 100644
--- a/drivers/scsi/lpfc/lpfc_ct.c
+++ b/drivers/scsi/lpfc/lpfc_ct.c
@@ -25,6 +25,7 @@
25#include <linux/blkdev.h> 25#include <linux/blkdev.h>
26#include <linux/pci.h> 26#include <linux/pci.h>
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/slab.h>
28#include <linux/utsname.h> 29#include <linux/utsname.h>
29 30
30#include <scsi/scsi.h> 31#include <scsi/scsi.h>
diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
index 391584183d8..a80d938fafc 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.c
+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
@@ -24,6 +24,7 @@
24#include <linux/idr.h> 24#include <linux/idr.h>
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/kthread.h> 26#include <linux/kthread.h>
27#include <linux/slab.h>
27#include <linux/pci.h> 28#include <linux/pci.h>
28#include <linux/spinlock.h> 29#include <linux/spinlock.h>
29#include <linux/ctype.h> 30#include <linux/ctype.h>
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index ee980bd6686..5fbdb22c189 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -21,6 +21,7 @@
21/* See Fibre Channel protocol T11 FC-LS for details */ 21/* See Fibre Channel protocol T11 FC-LS for details */
22#include <linux/blkdev.h> 22#include <linux/blkdev.h>
23#include <linux/pci.h> 23#include <linux/pci.h>
24#include <linux/slab.h>
24#include <linux/interrupt.h> 25#include <linux/interrupt.h>
25 26
26#include <scsi/scsi.h> 27#include <scsi/scsi.h>
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index c555e3b7f20..e1466eec56b 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -20,6 +20,7 @@
20 *******************************************************************/ 20 *******************************************************************/
21 21
22#include <linux/blkdev.h> 22#include <linux/blkdev.h>
23#include <linux/slab.h>
23#include <linux/pci.h> 24#include <linux/pci.h>
24#include <linux/kthread.h> 25#include <linux/kthread.h>
25#include <linux/interrupt.h> 26#include <linux/interrupt.h>
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index ea44239eeb3..774663e8e1f 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -29,6 +29,7 @@
29#include <linux/spinlock.h> 29#include <linux/spinlock.h>
30#include <linux/ctype.h> 30#include <linux/ctype.h>
31#include <linux/aer.h> 31#include <linux/aer.h>
32#include <linux/slab.h>
32 33
33#include <scsi/scsi.h> 34#include <scsi/scsi.h>
34#include <scsi/scsi_device.h> 35#include <scsi/scsi_device.h>
diff --git a/drivers/scsi/lpfc/lpfc_mbox.c b/drivers/scsi/lpfc/lpfc_mbox.c
index 1e61ae3bc4e..72e6adb0643 100644
--- a/drivers/scsi/lpfc/lpfc_mbox.c
+++ b/drivers/scsi/lpfc/lpfc_mbox.c
@@ -21,6 +21,7 @@
21 21
22#include <linux/blkdev.h> 22#include <linux/blkdev.h>
23#include <linux/pci.h> 23#include <linux/pci.h>
24#include <linux/slab.h>
24#include <linux/interrupt.h> 25#include <linux/interrupt.h>
25 26
26#include <scsi/scsi_device.h> 27#include <scsi/scsi_device.h>
diff --git a/drivers/scsi/lpfc/lpfc_mem.c b/drivers/scsi/lpfc/lpfc_mem.c
index a1b6db6016d..8f879e477e9 100644
--- a/drivers/scsi/lpfc/lpfc_mem.c
+++ b/drivers/scsi/lpfc/lpfc_mem.c
@@ -20,6 +20,7 @@
20 *******************************************************************/ 20 *******************************************************************/
21 21
22#include <linux/mempool.h> 22#include <linux/mempool.h>
23#include <linux/slab.h>
23#include <linux/pci.h> 24#include <linux/pci.h>
24#include <linux/interrupt.h> 25#include <linux/interrupt.h>
25 26
diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c
index d20ae6b3b3c..e331204a4d5 100644
--- a/drivers/scsi/lpfc/lpfc_nportdisc.c
+++ b/drivers/scsi/lpfc/lpfc_nportdisc.c
@@ -21,6 +21,7 @@
21 21
22#include <linux/blkdev.h> 22#include <linux/blkdev.h>
23#include <linux/pci.h> 23#include <linux/pci.h>
24#include <linux/slab.h>
24#include <linux/interrupt.h> 25#include <linux/interrupt.h>
25 26
26#include <scsi/scsi.h> 27#include <scsi/scsi.h>
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index b16bb2c9978..dccdb822328 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -19,6 +19,7 @@
19 * included with this package. * 19 * included with this package. *
20 *******************************************************************/ 20 *******************************************************************/
21#include <linux/pci.h> 21#include <linux/pci.h>
22#include <linux/slab.h>
22#include <linux/interrupt.h> 23#include <linux/interrupt.h>
23#include <linux/delay.h> 24#include <linux/delay.h>
24#include <asm/unaligned.h> 25#include <asm/unaligned.h>
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index fe6660ca645..049fb9a17b3 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -23,6 +23,7 @@
23#include <linux/pci.h> 23#include <linux/pci.h>
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/slab.h>
26 27
27#include <scsi/scsi.h> 28#include <scsi/scsi.h>
28#include <scsi/scsi_cmnd.h> 29#include <scsi/scsi_cmnd.h>
diff --git a/drivers/scsi/lpfc/lpfc_vport.c b/drivers/scsi/lpfc/lpfc_vport.c
index 869f76cbc58..ffd575c379f 100644
--- a/drivers/scsi/lpfc/lpfc_vport.c
+++ b/drivers/scsi/lpfc/lpfc_vport.c
@@ -26,6 +26,7 @@
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/kthread.h> 27#include <linux/kthread.h>
28#include <linux/pci.h> 28#include <linux/pci.h>
29#include <linux/slab.h>
29#include <linux/spinlock.h> 30#include <linux/spinlock.h>
30 31
31#include <scsi/scsi.h> 32#include <scsi/scsi.h>
diff --git a/drivers/scsi/mac_esp.c b/drivers/scsi/mac_esp.c
index 4a90eaf7cb6..3893337e3dd 100644
--- a/drivers/scsi/mac_esp.c
+++ b/drivers/scsi/mac_esp.c
@@ -19,6 +19,7 @@
19#include <linux/delay.h> 19#include <linux/delay.h>
20#include <linux/io.h> 20#include <linux/io.h>
21#include <linux/nubus.h> 21#include <linux/nubus.h>
22#include <linux/slab.h>
22 23
23#include <asm/irq.h> 24#include <asm/irq.h>
24#include <asm/dma.h> 25#include <asm/dma.h>
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 49eb0612d5a..4bf7edca9e6 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -47,6 +47,7 @@
47#include <linux/init.h> 47#include <linux/init.h>
48#include <linux/dma-mapping.h> 48#include <linux/dma-mapping.h>
49#include <linux/smp_lock.h> 49#include <linux/smp_lock.h>
50#include <linux/slab.h>
50#include <scsi/scsicam.h> 51#include <scsi/scsicam.h>
51 52
52#include "scsi.h" 53#include "scsi.h"
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c
index 7f977967b88..a7810a106b3 100644
--- a/drivers/scsi/megaraid/megaraid_mbox.c
+++ b/drivers/scsi/megaraid/megaraid_mbox.c
@@ -70,6 +70,7 @@
70 * For history of changes, see Documentation/ChangeLog.megaraid 70 * For history of changes, see Documentation/ChangeLog.megaraid
71 */ 71 */
72 72
73#include <linux/slab.h>
73#include "megaraid_mbox.h" 74#include "megaraid_mbox.h"
74 75
75static int megaraid_init(void); 76static int megaraid_init(void);
diff --git a/drivers/scsi/megaraid/megaraid_mm.c b/drivers/scsi/megaraid/megaraid_mm.c
index f680561d2c6..36e0b7d05c1 100644
--- a/drivers/scsi/megaraid/megaraid_mm.c
+++ b/drivers/scsi/megaraid/megaraid_mm.c
@@ -15,6 +15,7 @@
15 * Common management module 15 * Common management module
16 */ 16 */
17#include <linux/sched.h> 17#include <linux/sched.h>
18#include <linux/slab.h>
18#include <linux/smp_lock.h> 19#include <linux/smp_lock.h>
19#include "megaraid_mm.h" 20#include "megaraid_mm.h"
20 21
diff --git a/drivers/scsi/megaraid/megaraid_sas.c b/drivers/scsi/megaraid/megaraid_sas.c
index 409648f5845..99e4478c3f3 100644
--- a/drivers/scsi/megaraid/megaraid_sas.c
+++ b/drivers/scsi/megaraid/megaraid_sas.c
@@ -35,6 +35,7 @@
35#include <linux/delay.h> 35#include <linux/delay.h>
36#include <linux/smp_lock.h> 36#include <linux/smp_lock.h>
37#include <linux/uio.h> 37#include <linux/uio.h>
38#include <linux/slab.h>
38#include <asm/uaccess.h> 39#include <asm/uaccess.h>
39#include <linux/fs.h> 40#include <linux/fs.h>
40#include <linux/compat.h> 41#include <linux/compat.h>
diff --git a/drivers/scsi/mesh.c b/drivers/scsi/mesh.c
index 11aa917629a..a1c97e88068 100644
--- a/drivers/scsi/mesh.c
+++ b/drivers/scsi/mesh.c
@@ -23,7 +23,6 @@
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/types.h> 24#include <linux/types.h>
25#include <linux/string.h> 25#include <linux/string.h>
26#include <linux/slab.h>
27#include <linux/blkdev.h> 26#include <linux/blkdev.h>
28#include <linux/proc_fs.h> 27#include <linux/proc_fs.h>
29#include <linux/stat.h> 28#include <linux/stat.h>
diff --git a/drivers/scsi/mpt2sas/mpt2sas_config.c b/drivers/scsi/mpt2sas/mpt2sas_config.c
index 411c27d7f78..cf44b355bc9 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_config.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_config.c
@@ -51,6 +51,7 @@
51#include <linux/workqueue.h> 51#include <linux/workqueue.h>
52#include <linux/delay.h> 52#include <linux/delay.h>
53#include <linux/pci.h> 53#include <linux/pci.h>
54#include <linux/slab.h>
54 55
55#include "mpt2sas_base.h" 56#include "mpt2sas_base.h"
56 57
diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
index c7ec3f17478..be171ed682e 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
@@ -53,6 +53,7 @@
53#include <linux/pci.h> 53#include <linux/pci.h>
54#include <linux/interrupt.h> 54#include <linux/interrupt.h>
55#include <linux/raid_class.h> 55#include <linux/raid_class.h>
56#include <linux/slab.h>
56 57
57#include "mpt2sas_base.h" 58#include "mpt2sas_base.h"
58 59
diff --git a/drivers/scsi/mpt2sas/mpt2sas_transport.c b/drivers/scsi/mpt2sas/mpt2sas_transport.c
index 789f9ee7f00..bd7ca2b49f8 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_transport.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_transport.c
@@ -49,6 +49,7 @@
49#include <linux/workqueue.h> 49#include <linux/workqueue.h>
50#include <linux/delay.h> 50#include <linux/delay.h>
51#include <linux/pci.h> 51#include <linux/pci.h>
52#include <linux/slab.h>
52 53
53#include <scsi/scsi.h> 54#include <scsi/scsi.h>
54#include <scsi/scsi_cmnd.h> 55#include <scsi/scsi_cmnd.h>
diff --git a/drivers/scsi/mvme16x_scsi.c b/drivers/scsi/mvme16x_scsi.c
index b5fbfd6ce87..39f554f5f26 100644
--- a/drivers/scsi/mvme16x_scsi.c
+++ b/drivers/scsi/mvme16x_scsi.c
@@ -12,6 +12,7 @@
12#include <linux/platform_device.h> 12#include <linux/platform_device.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/interrupt.h> 14#include <linux/interrupt.h>
15#include <linux/slab.h>
15#include <asm/mvme16xhw.h> 16#include <asm/mvme16xhw.h>
16#include <scsi/scsi_host.h> 17#include <scsi/scsi_host.h>
17#include <scsi/scsi_device.h> 18#include <scsi/scsi_device.h>
diff --git a/drivers/scsi/mvsas/mv_sas.h b/drivers/scsi/mvsas/mv_sas.h
index aa2270af1ba..885858bcc40 100644
--- a/drivers/scsi/mvsas/mv_sas.h
+++ b/drivers/scsi/mvsas/mv_sas.h
@@ -36,6 +36,7 @@
36#include <linux/platform_device.h> 36#include <linux/platform_device.h>
37#include <linux/interrupt.h> 37#include <linux/interrupt.h>
38#include <linux/irq.h> 38#include <linux/irq.h>
39#include <linux/slab.h>
39#include <linux/vmalloc.h> 40#include <linux/vmalloc.h>
40#include <scsi/libsas.h> 41#include <scsi/libsas.h>
41#include <scsi/scsi_tcq.h> 42#include <scsi/scsi_tcq.h>
diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c
index a2d56982830..d013a2aa2fd 100644
--- a/drivers/scsi/ncr53c8xx.c
+++ b/drivers/scsi/ncr53c8xx.c
@@ -98,6 +98,7 @@
98#include <linux/delay.h> 98#include <linux/delay.h>
99#include <linux/dma-mapping.h> 99#include <linux/dma-mapping.h>
100#include <linux/errno.h> 100#include <linux/errno.h>
101#include <linux/gfp.h>
101#include <linux/init.h> 102#include <linux/init.h>
102#include <linux/interrupt.h> 103#include <linux/interrupt.h>
103#include <linux/ioport.h> 104#include <linux/ioport.h>
diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c
index 2c98a6ee973..4c1e5454520 100644
--- a/drivers/scsi/nsp32.c
+++ b/drivers/scsi/nsp32.c
@@ -26,7 +26,6 @@
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/kernel.h> 28#include <linux/kernel.h>
29#include <linux/slab.h>
30#include <linux/string.h> 29#include <linux/string.h>
31#include <linux/timer.h> 30#include <linux/timer.h>
32#include <linux/ioport.h> 31#include <linux/ioport.h>
diff --git a/drivers/scsi/osd/osd_initiator.c b/drivers/scsi/osd/osd_initiator.c
index 60de8509150..ee4b6914667 100644
--- a/drivers/scsi/osd/osd_initiator.c
+++ b/drivers/scsi/osd/osd_initiator.c
@@ -39,6 +39,8 @@
39 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 */ 40 */
41 41
42#include <linux/slab.h>
43
42#include <scsi/osd_initiator.h> 44#include <scsi/osd_initiator.h>
43#include <scsi/osd_sec.h> 45#include <scsi/osd_sec.h>
44#include <scsi/osd_attributes.h> 46#include <scsi/osd_attributes.h>
diff --git a/drivers/scsi/osd/osd_uld.c b/drivers/scsi/osd/osd_uld.c
index 0a90702b3d7..ffdd9fdb999 100644
--- a/drivers/scsi/osd/osd_uld.c
+++ b/drivers/scsi/osd/osd_uld.c
@@ -50,6 +50,7 @@
50#include <linux/idr.h> 50#include <linux/idr.h>
51#include <linux/major.h> 51#include <linux/major.h>
52#include <linux/file.h> 52#include <linux/file.h>
53#include <linux/slab.h>
53 54
54#include <scsi/scsi.h> 55#include <scsi/scsi.h>
55#include <scsi/scsi_driver.h> 56#include <scsi/scsi_driver.h>
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index acb835837ee..b219118f8bd 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -38,6 +38,7 @@ static const char * osst_version = "0.99.4";
38#include <linux/sched.h> 38#include <linux/sched.h>
39#include <linux/proc_fs.h> 39#include <linux/proc_fs.h>
40#include <linux/mm.h> 40#include <linux/mm.h>
41#include <linux/slab.h>
41#include <linux/init.h> 42#include <linux/init.h>
42#include <linux/string.h> 43#include <linux/string.h>
43#include <linux/errno.h> 44#include <linux/errno.h>
diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c
index 14b13acae6d..45bc197bc22 100644
--- a/drivers/scsi/pm8001/pm8001_ctl.c
+++ b/drivers/scsi/pm8001/pm8001_ctl.c
@@ -38,6 +38,7 @@
38 * 38 *
39 */ 39 */
40#include <linux/firmware.h> 40#include <linux/firmware.h>
41#include <linux/slab.h>
41#include "pm8001_sas.h" 42#include "pm8001_sas.h"
42#include "pm8001_ctl.h" 43#include "pm8001_ctl.h"
43 44
diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c
index 7985ae45d68..909c00ec044 100644
--- a/drivers/scsi/pm8001/pm8001_hwi.c
+++ b/drivers/scsi/pm8001/pm8001_hwi.c
@@ -37,6 +37,7 @@
37 * POSSIBILITY OF SUCH DAMAGES. 37 * POSSIBILITY OF SUCH DAMAGES.
38 * 38 *
39 */ 39 */
40 #include <linux/slab.h>
40 #include "pm8001_sas.h" 41 #include "pm8001_sas.h"
41 #include "pm8001_hwi.h" 42 #include "pm8001_hwi.h"
42 #include "pm8001_chips.h" 43 #include "pm8001_chips.h"
diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c
index f80c1da8f6c..f8c86b28f03 100644
--- a/drivers/scsi/pm8001/pm8001_init.c
+++ b/drivers/scsi/pm8001/pm8001_init.c
@@ -38,6 +38,7 @@
38 * 38 *
39 */ 39 */
40 40
41#include <linux/slab.h>
41#include "pm8001_sas.h" 42#include "pm8001_sas.h"
42#include "pm8001_chips.h" 43#include "pm8001_chips.h"
43 44
diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
index 3b2c98fba83..bff4f5139b9 100644
--- a/drivers/scsi/pm8001/pm8001_sas.c
+++ b/drivers/scsi/pm8001/pm8001_sas.c
@@ -38,6 +38,7 @@
38 * 38 *
39 */ 39 */
40 40
41#include <linux/slab.h>
41#include "pm8001_sas.h" 42#include "pm8001_sas.h"
42 43
43/** 44/**
diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index 9b1c1433c26..53aefffbaea 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -41,6 +41,7 @@
41#include <linux/hdreg.h> 41#include <linux/hdreg.h>
42#include <linux/version.h> 42#include <linux/version.h>
43#include <linux/io.h> 43#include <linux/io.h>
44#include <linux/slab.h>
44#include <asm/irq.h> 45#include <asm/irq.h>
45#include <asm/processor.h> 46#include <asm/processor.h>
46#include <linux/libata.h> 47#include <linux/libata.h>
diff --git a/drivers/scsi/ppa.c b/drivers/scsi/ppa.c
index 8aa0bd987e2..7bc2d796e40 100644
--- a/drivers/scsi/ppa.c
+++ b/drivers/scsi/ppa.c
@@ -10,6 +10,7 @@
10 10
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/slab.h>
13#include <linux/module.h> 14#include <linux/module.h>
14#include <linux/blkdev.h> 15#include <linux/blkdev.h>
15#include <linux/parport.h> 16#include <linux/parport.h>
diff --git a/drivers/scsi/ps3rom.c b/drivers/scsi/ps3rom.c
index db90caf43f4..92ffbb51049 100644
--- a/drivers/scsi/ps3rom.c
+++ b/drivers/scsi/ps3rom.c
@@ -20,6 +20,7 @@
20 20
21#include <linux/cdrom.h> 21#include <linux/cdrom.h>
22#include <linux/highmem.h> 22#include <linux/highmem.h>
23#include <linux/slab.h>
23 24
24#include <scsi/scsi.h> 25#include <scsi/scsi.h>
25#include <scsi/scsi_cmnd.h> 26#include <scsi/scsi_cmnd.h>
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index 49ac4148493..b8166ecfd0e 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -17,9 +17,11 @@
17* General Public License for more details. 17* General Public License for more details.
18* 18*
19******************************************************************************/ 19******************************************************************************/
20#define QLA1280_VERSION "3.27" 20#define QLA1280_VERSION "3.27.1"
21/***************************************************************************** 21/*****************************************************************************
22 Revision History: 22 Revision History:
23 Rev 3.27.1, February 8, 2010, Michael Reed
24 - Retain firmware image for error recovery.
23 Rev 3.27, February 10, 2009, Michael Reed 25 Rev 3.27, February 10, 2009, Michael Reed
24 - General code cleanup. 26 - General code cleanup.
25 - Improve error recovery. 27 - Improve error recovery.
@@ -346,7 +348,6 @@
346#include <linux/pci.h> 348#include <linux/pci.h>
347#include <linux/proc_fs.h> 349#include <linux/proc_fs.h>
348#include <linux/stat.h> 350#include <linux/stat.h>
349#include <linux/slab.h>
350#include <linux/pci_ids.h> 351#include <linux/pci_ids.h>
351#include <linux/interrupt.h> 352#include <linux/interrupt.h>
352#include <linux/init.h> 353#include <linux/init.h>
@@ -538,9 +539,9 @@ __setup("qla1280=", qla1280_setup);
538/*****************************************/ 539/*****************************************/
539 540
540struct qla_boards { 541struct qla_boards {
541 unsigned char name[9]; /* Board ID String */ 542 char *name; /* Board ID String */
542 int numPorts; /* Number of SCSI ports */ 543 int numPorts; /* Number of SCSI ports */
543 char *fwname; /* firmware name */ 544 int fw_index; /* index into qla1280_fw_tbl for firmware */
544}; 545};
545 546
546/* NOTE: the last argument in each entry is used to index ql1280_board_tbl */ 547/* NOTE: the last argument in each entry is used to index ql1280_board_tbl */
@@ -561,15 +562,30 @@ static struct pci_device_id qla1280_pci_tbl[] = {
561}; 562};
562MODULE_DEVICE_TABLE(pci, qla1280_pci_tbl); 563MODULE_DEVICE_TABLE(pci, qla1280_pci_tbl);
563 564
565DEFINE_MUTEX(qla1280_firmware_mutex);
566
567struct qla_fw {
568 char *fwname;
569 const struct firmware *fw;
570};
571
572#define QL_NUM_FW_IMAGES 3
573
574struct qla_fw qla1280_fw_tbl[QL_NUM_FW_IMAGES] = {
575 {"qlogic/1040.bin", NULL}, /* image 0 */
576 {"qlogic/1280.bin", NULL}, /* image 1 */
577 {"qlogic/12160.bin", NULL}, /* image 2 */
578};
579
580/* NOTE: Order of boards in this table must match order in qla1280_pci_tbl */
564static struct qla_boards ql1280_board_tbl[] = { 581static struct qla_boards ql1280_board_tbl[] = {
565 /* Name , Number of ports, FW details */ 582 {.name = "QLA12160", .numPorts = 2, .fw_index = 2},
566 {"QLA12160", 2, "qlogic/12160.bin"}, 583 {.name = "QLA1040" , .numPorts = 1, .fw_index = 0},
567 {"QLA1040", 1, "qlogic/1040.bin"}, 584 {.name = "QLA1080" , .numPorts = 1, .fw_index = 1},
568 {"QLA1080", 1, "qlogic/1280.bin"}, 585 {.name = "QLA1240" , .numPorts = 2, .fw_index = 1},
569 {"QLA1240", 2, "qlogic/1280.bin"}, 586 {.name = "QLA1280" , .numPorts = 2, .fw_index = 1},
570 {"QLA1280", 2, "qlogic/1280.bin"}, 587 {.name = "QLA10160", .numPorts = 1, .fw_index = 2},
571 {"QLA10160", 1, "qlogic/12160.bin"}, 588 {.name = " ", .numPorts = 0, .fw_index = -1},
572 {" ", 0, " "},
573}; 589};
574 590
575static int qla1280_verbose = 1; 591static int qla1280_verbose = 1;
@@ -1512,6 +1528,63 @@ qla1280_initialize_adapter(struct scsi_qla_host *ha)
1512} 1528}
1513 1529
1514/* 1530/*
1531 * qla1280_request_firmware
1532 * Acquire firmware for chip. Retain in memory
1533 * for error recovery.
1534 *
1535 * Input:
1536 * ha = adapter block pointer.
1537 *
1538 * Returns:
1539 * Pointer to firmware image or an error code
1540 * cast to pointer via ERR_PTR().
1541 */
1542static const struct firmware *
1543qla1280_request_firmware(struct scsi_qla_host *ha)
1544{
1545 const struct firmware *fw;
1546 int err;
1547 int index;
1548 char *fwname;
1549
1550 spin_unlock_irq(ha->host->host_lock);
1551 mutex_lock(&qla1280_firmware_mutex);
1552
1553 index = ql1280_board_tbl[ha->devnum].fw_index;
1554 fw = qla1280_fw_tbl[index].fw;
1555 if (fw)
1556 goto out;
1557
1558 fwname = qla1280_fw_tbl[index].fwname;
1559 err = request_firmware(&fw, fwname, &ha->pdev->dev);
1560
1561 if (err) {
1562 printk(KERN_ERR "Failed to load image \"%s\" err %d\n",
1563 fwname, err);
1564 fw = ERR_PTR(err);
1565 goto unlock;
1566 }
1567 if ((fw->size % 2) || (fw->size < 6)) {
1568 printk(KERN_ERR "Invalid firmware length %zu in image \"%s\"\n",
1569 fw->size, fwname);
1570 release_firmware(fw);
1571 fw = ERR_PTR(-EINVAL);
1572 goto unlock;
1573 }
1574
1575 qla1280_fw_tbl[index].fw = fw;
1576
1577 out:
1578 ha->fwver1 = fw->data[0];
1579 ha->fwver2 = fw->data[1];
1580 ha->fwver3 = fw->data[2];
1581 unlock:
1582 mutex_unlock(&qla1280_firmware_mutex);
1583 spin_lock_irq(ha->host->host_lock);
1584 return fw;
1585}
1586
1587/*
1515 * Chip diagnostics 1588 * Chip diagnostics
1516 * Test chip for proper operation. 1589 * Test chip for proper operation.
1517 * 1590 *
@@ -1634,30 +1707,18 @@ qla1280_chip_diag(struct scsi_qla_host *ha)
1634static int 1707static int
1635qla1280_load_firmware_pio(struct scsi_qla_host *ha) 1708qla1280_load_firmware_pio(struct scsi_qla_host *ha)
1636{ 1709{
1710 /* enter with host_lock acquired */
1711
1637 const struct firmware *fw; 1712 const struct firmware *fw;
1638 const __le16 *fw_data; 1713 const __le16 *fw_data;
1639 uint16_t risc_address, risc_code_size; 1714 uint16_t risc_address, risc_code_size;
1640 uint16_t mb[MAILBOX_REGISTER_COUNT], i; 1715 uint16_t mb[MAILBOX_REGISTER_COUNT], i;
1641 int err; 1716 int err = 0;
1717
1718 fw = qla1280_request_firmware(ha);
1719 if (IS_ERR(fw))
1720 return PTR_ERR(fw);
1642 1721
1643 spin_unlock_irq(ha->host->host_lock);
1644 err = request_firmware(&fw, ql1280_board_tbl[ha->devnum].fwname,
1645 &ha->pdev->dev);
1646 spin_lock_irq(ha->host->host_lock);
1647 if (err) {
1648 printk(KERN_ERR "Failed to load image \"%s\" err %d\n",
1649 ql1280_board_tbl[ha->devnum].fwname, err);
1650 return err;
1651 }
1652 if ((fw->size % 2) || (fw->size < 6)) {
1653 printk(KERN_ERR "Bogus length %zu in image \"%s\"\n",
1654 fw->size, ql1280_board_tbl[ha->devnum].fwname);
1655 err = -EINVAL;
1656 goto out;
1657 }
1658 ha->fwver1 = fw->data[0];
1659 ha->fwver2 = fw->data[1];
1660 ha->fwver3 = fw->data[2];
1661 fw_data = (const __le16 *)&fw->data[0]; 1722 fw_data = (const __le16 *)&fw->data[0];
1662 ha->fwstart = __le16_to_cpu(fw_data[2]); 1723 ha->fwstart = __le16_to_cpu(fw_data[2]);
1663 1724
@@ -1675,11 +1736,10 @@ qla1280_load_firmware_pio(struct scsi_qla_host *ha)
1675 if (err) { 1736 if (err) {
1676 printk(KERN_ERR "scsi(%li): Failed to load firmware\n", 1737 printk(KERN_ERR "scsi(%li): Failed to load firmware\n",
1677 ha->host_no); 1738 ha->host_no);
1678 goto out; 1739 break;
1679 } 1740 }
1680 } 1741 }
1681out: 1742
1682 release_firmware(fw);
1683 return err; 1743 return err;
1684} 1744}
1685 1745
@@ -1687,6 +1747,7 @@ out:
1687static int 1747static int
1688qla1280_load_firmware_dma(struct scsi_qla_host *ha) 1748qla1280_load_firmware_dma(struct scsi_qla_host *ha)
1689{ 1749{
1750 /* enter with host_lock acquired */
1690 const struct firmware *fw; 1751 const struct firmware *fw;
1691 const __le16 *fw_data; 1752 const __le16 *fw_data;
1692 uint16_t risc_address, risc_code_size; 1753 uint16_t risc_address, risc_code_size;
@@ -1701,24 +1762,10 @@ qla1280_load_firmware_dma(struct scsi_qla_host *ha)
1701 return -ENOMEM; 1762 return -ENOMEM;
1702#endif 1763#endif
1703 1764
1704 spin_unlock_irq(ha->host->host_lock); 1765 fw = qla1280_request_firmware(ha);
1705 err = request_firmware(&fw, ql1280_board_tbl[ha->devnum].fwname, 1766 if (IS_ERR(fw))
1706 &ha->pdev->dev); 1767 return PTR_ERR(fw);
1707 spin_lock_irq(ha->host->host_lock); 1768
1708 if (err) {
1709 printk(KERN_ERR "Failed to load image \"%s\" err %d\n",
1710 ql1280_board_tbl[ha->devnum].fwname, err);
1711 return err;
1712 }
1713 if ((fw->size % 2) || (fw->size < 6)) {
1714 printk(KERN_ERR "Bogus length %zu in image \"%s\"\n",
1715 fw->size, ql1280_board_tbl[ha->devnum].fwname);
1716 err = -EINVAL;
1717 goto out;
1718 }
1719 ha->fwver1 = fw->data[0];
1720 ha->fwver2 = fw->data[1];
1721 ha->fwver3 = fw->data[2];
1722 fw_data = (const __le16 *)&fw->data[0]; 1769 fw_data = (const __le16 *)&fw->data[0];
1723 ha->fwstart = __le16_to_cpu(fw_data[2]); 1770 ha->fwstart = __le16_to_cpu(fw_data[2]);
1724 1771
@@ -1803,7 +1850,6 @@ qla1280_load_firmware_dma(struct scsi_qla_host *ha)
1803#if DUMP_IT_BACK 1850#if DUMP_IT_BACK
1804 pci_free_consistent(ha->pdev, 8000, tbuf, p_tbuf); 1851 pci_free_consistent(ha->pdev, 8000, tbuf, p_tbuf);
1805#endif 1852#endif
1806 release_firmware(fw);
1807 return err; 1853 return err;
1808} 1854}
1809 1855
@@ -1842,6 +1888,7 @@ qla1280_start_firmware(struct scsi_qla_host *ha)
1842static int 1888static int
1843qla1280_load_firmware(struct scsi_qla_host *ha) 1889qla1280_load_firmware(struct scsi_qla_host *ha)
1844{ 1890{
1891 /* enter with host_lock taken */
1845 int err; 1892 int err;
1846 1893
1847 err = qla1280_chip_diag(ha); 1894 err = qla1280_chip_diag(ha);
@@ -4420,7 +4467,16 @@ qla1280_init(void)
4420static void __exit 4467static void __exit
4421qla1280_exit(void) 4468qla1280_exit(void)
4422{ 4469{
4470 int i;
4471
4423 pci_unregister_driver(&qla1280_pci_driver); 4472 pci_unregister_driver(&qla1280_pci_driver);
4473 /* release any allocated firmware images */
4474 for (i = 0; i < QL_NUM_FW_IMAGES; i++) {
4475 if (qla1280_fw_tbl[i].fw) {
4476 release_firmware(qla1280_fw_tbl[i].fw);
4477 qla1280_fw_tbl[i].fw = NULL;
4478 }
4479 }
4424} 4480}
4425 4481
4426module_init(qla1280_init); 4482module_init(qla1280_init);
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 90d1e062ec4..1c7ef55966f 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -8,6 +8,7 @@
8 8
9#include <linux/kthread.h> 9#include <linux/kthread.h>
10#include <linux/vmalloc.h> 10#include <linux/vmalloc.h>
11#include <linux/slab.h>
11#include <linux/delay.h> 12#include <linux/delay.h>
12 13
13static int qla24xx_vport_disable(struct fc_vport *, bool); 14static int qla24xx_vport_disable(struct fc_vport *, bool);
@@ -1274,7 +1275,11 @@ qla2x00_fw_state_show(struct device *dev, struct device_attribute *attr,
1274 int rval = QLA_FUNCTION_FAILED; 1275 int rval = QLA_FUNCTION_FAILED;
1275 uint16_t state[5]; 1276 uint16_t state[5];
1276 1277
1277 if (!vha->hw->flags.eeh_busy) 1278 if (test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) ||
1279 test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags))
1280 DEBUG2_3_11(printk("%s(%ld): isp reset in progress.\n",
1281 __func__, vha->host_no));
1282 else if (!vha->hw->flags.eeh_busy)
1278 rval = qla2x00_get_firmware_state(vha, state); 1283 rval = qla2x00_get_firmware_state(vha, state);
1279 if (rval != QLA_SUCCESS) 1284 if (rval != QLA_SUCCESS)
1280 memset(state, -1, sizeof(state)); 1285 memset(state, -1, sizeof(state));
@@ -2388,6 +2393,7 @@ qla24xx_bsg_timeout(struct fc_bsg_job *bsg_job)
2388 return 0; 2393 return 0;
2389 2394
2390done: 2395done:
2396 spin_unlock_irqrestore(&ha->hardware_lock, flags);
2391 if (bsg_job->request->msgcode == FC_BSG_HST_CT) 2397 if (bsg_job->request->msgcode == FC_BSG_HST_CT)
2392 kfree(sp->fcport); 2398 kfree(sp->fcport);
2393 kfree(sp->ctx); 2399 kfree(sp->ctx);
diff --git a/drivers/scsi/qla2xxx/qla_fw.h b/drivers/scsi/qla2xxx/qla_fw.h
index cebf4f1bb7d..42c5587cc50 100644
--- a/drivers/scsi/qla2xxx/qla_fw.h
+++ b/drivers/scsi/qla2xxx/qla_fw.h
@@ -1592,10 +1592,22 @@ struct nvram_81xx {
1592 1592
1593 /* Offset 384. */ 1593 /* Offset 384. */
1594 uint8_t reserved_21[16]; 1594 uint8_t reserved_21[16];
1595 uint16_t reserved_22[8]; 1595 uint16_t reserved_22[3];
1596
1597 /*
1598 * BIT 0 = Extended BB credits for LR
1599 * BIT 1 = Virtual Fabric Enable
1600 * BIT 2 = Enhanced Features Unused
1601 * BIT 3-7 = Enhanced Features Reserved
1602 */
1603 /* Enhanced Features */
1604 uint8_t enhanced_features;
1605
1606 uint8_t reserved_23;
1607 uint16_t reserved_24[4];
1596 1608
1597 /* Offset 416. */ 1609 /* Offset 416. */
1598 uint16_t reserved_23[32]; 1610 uint16_t reserved_25[32];
1599 1611
1600 /* Offset 480. */ 1612 /* Offset 480. */
1601 uint8_t model_name[16]; 1613 uint8_t model_name[16];
@@ -1603,7 +1615,7 @@ struct nvram_81xx {
1603 /* Offset 496. */ 1615 /* Offset 496. */
1604 uint16_t feature_mask_l; 1616 uint16_t feature_mask_l;
1605 uint16_t feature_mask_h; 1617 uint16_t feature_mask_h;
1606 uint16_t reserved_24[2]; 1618 uint16_t reserved_26[2];
1607 1619
1608 uint16_t subsystem_vendor_id; 1620 uint16_t subsystem_vendor_id;
1609 uint16_t subsystem_device_id; 1621 uint16_t subsystem_device_id;
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index a67b2bafb88..4229bb483c5 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -8,6 +8,7 @@
8#include "qla_gbl.h" 8#include "qla_gbl.h"
9 9
10#include <linux/delay.h> 10#include <linux/delay.h>
11#include <linux/slab.h>
11#include <linux/vmalloc.h> 12#include <linux/vmalloc.h>
12 13
13#include "qla_devtbl.h" 14#include "qla_devtbl.h"
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index ab90329ff2e..db539b0c3da 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -7,6 +7,7 @@
7#include "qla_def.h" 7#include "qla_def.h"
8 8
9#include <linux/delay.h> 9#include <linux/delay.h>
10#include <linux/slab.h>
10#include <scsi/scsi_tcq.h> 11#include <scsi/scsi_tcq.h>
11#include <scsi/scsi_bsg_fc.h> 12#include <scsi/scsi_bsg_fc.h>
12 13
@@ -620,11 +621,10 @@ skip_rio:
620 * vp_idx does not match 621 * vp_idx does not match
621 * Event is not global, vp_idx does not match 622 * Event is not global, vp_idx does not match
622 */ 623 */
623 if ((mb[1] == 0xffff && (mb[3] & 0xff) != 0xff) 624 if (IS_QLA2XXX_MIDTYPE(ha) &&
624 || (mb[1] != 0xffff)) { 625 ((mb[1] == 0xffff && (mb[3] & 0xff) != 0xff) ||
625 if (vha->vp_idx != (mb[3] & 0xff)) 626 (mb[1] != 0xffff)) && vha->vp_idx != (mb[3] & 0xff))
626 break; 627 break;
627 }
628 628
629 /* Global event -- port logout or port unavailable. */ 629 /* Global event -- port logout or port unavailable. */
630 if (mb[1] == 0xffff && mb[2] == 0x7) { 630 if (mb[1] == 0xffff && mb[2] == 0x7) {
@@ -2272,30 +2272,28 @@ qla2x00_request_irqs(struct qla_hw_data *ha, struct rsp_que *rsp)
2272 2272
2273 /* If possible, enable MSI-X. */ 2273 /* If possible, enable MSI-X. */
2274 if (!IS_QLA2432(ha) && !IS_QLA2532(ha) && 2274 if (!IS_QLA2432(ha) && !IS_QLA2532(ha) &&
2275 !IS_QLA8432(ha) && !IS_QLA8001(ha)) 2275 !IS_QLA8432(ha) && !IS_QLA8001(ha))
2276 goto skip_msix; 2276 goto skip_msi;
2277
2278 if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_HP &&
2279 (ha->pdev->subsystem_device == 0x7040 ||
2280 ha->pdev->subsystem_device == 0x7041 ||
2281 ha->pdev->subsystem_device == 0x1705)) {
2282 DEBUG2(qla_printk(KERN_WARNING, ha,
2283 "MSI-X: Unsupported ISP2432 SSVID/SSDID (0x%X,0x%X).\n",
2284 ha->pdev->subsystem_vendor,
2285 ha->pdev->subsystem_device));
2286 goto skip_msi;
2287 }
2277 2288
2278 if (IS_QLA2432(ha) && (ha->pdev->revision < QLA_MSIX_CHIP_REV_24XX || 2289 if (IS_QLA2432(ha) && (ha->pdev->revision < QLA_MSIX_CHIP_REV_24XX ||
2279 !QLA_MSIX_FW_MODE_1(ha->fw_attributes))) { 2290 !QLA_MSIX_FW_MODE_1(ha->fw_attributes))) {
2280 DEBUG2(qla_printk(KERN_WARNING, ha, 2291 DEBUG2(qla_printk(KERN_WARNING, ha,
2281 "MSI-X: Unsupported ISP2432 (0x%X, 0x%X).\n", 2292 "MSI-X: Unsupported ISP2432 (0x%X, 0x%X).\n",
2282 ha->pdev->revision, ha->fw_attributes)); 2293 ha->pdev->revision, ha->fw_attributes));
2283
2284 goto skip_msix; 2294 goto skip_msix;
2285 } 2295 }
2286 2296
2287 if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_HP &&
2288 (ha->pdev->subsystem_device == 0x7040 ||
2289 ha->pdev->subsystem_device == 0x7041 ||
2290 ha->pdev->subsystem_device == 0x1705)) {
2291 DEBUG2(qla_printk(KERN_WARNING, ha,
2292 "MSI-X: Unsupported ISP2432 SSVID/SSDID (0x%X, 0x%X).\n",
2293 ha->pdev->subsystem_vendor,
2294 ha->pdev->subsystem_device));
2295
2296 goto skip_msi;
2297 }
2298
2299 ret = qla24xx_enable_msix(ha, rsp); 2297 ret = qla24xx_enable_msix(ha, rsp);
2300 if (!ret) { 2298 if (!ret) {
2301 DEBUG2(qla_printk(KERN_INFO, ha, 2299 DEBUG2(qla_printk(KERN_INFO, ha,
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 6e53bdbb1da..42eb7ffd594 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -7,6 +7,7 @@
7#include "qla_def.h" 7#include "qla_def.h"
8 8
9#include <linux/delay.h> 9#include <linux/delay.h>
10#include <linux/gfp.h>
10 11
11 12
12/* 13/*
@@ -339,6 +340,7 @@ qla2x00_load_ram(scsi_qla_host_t *vha, dma_addr_t req_dma, uint32_t risc_addr,
339 return rval; 340 return rval;
340} 341}
341 342
343#define EXTENDED_BB_CREDITS BIT_0
342/* 344/*
343 * qla2x00_execute_fw 345 * qla2x00_execute_fw
344 * Start adapter firmware. 346 * Start adapter firmware.
@@ -371,7 +373,12 @@ qla2x00_execute_fw(scsi_qla_host_t *vha, uint32_t risc_addr)
371 mcp->mb[1] = MSW(risc_addr); 373 mcp->mb[1] = MSW(risc_addr);
372 mcp->mb[2] = LSW(risc_addr); 374 mcp->mb[2] = LSW(risc_addr);
373 mcp->mb[3] = 0; 375 mcp->mb[3] = 0;
374 mcp->mb[4] = 0; 376 if (IS_QLA81XX(ha)) {
377 struct nvram_81xx *nv = ha->nvram;
378 mcp->mb[4] = (nv->enhanced_features &
379 EXTENDED_BB_CREDITS);
380 } else
381 mcp->mb[4] = 0;
375 mcp->out_mb |= MBX_4|MBX_3|MBX_2|MBX_1; 382 mcp->out_mb |= MBX_4|MBX_3|MBX_2|MBX_1;
376 mcp->in_mb |= MBX_1; 383 mcp->in_mb |= MBX_1;
377 } else { 384 } else {
diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c
index ff17dee2861..8220e7b9799 100644
--- a/drivers/scsi/qla2xxx/qla_mid.c
+++ b/drivers/scsi/qla2xxx/qla_mid.c
@@ -9,6 +9,7 @@
9 9
10#include <linux/moduleparam.h> 10#include <linux/moduleparam.h>
11#include <linux/vmalloc.h> 11#include <linux/vmalloc.h>
12#include <linux/slab.h>
12#include <linux/list.h> 13#include <linux/list.h>
13 14
14#include <scsi/scsi_tcq.h> 15#include <scsi/scsi_tcq.h>
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 46720b23028..48c37e38ed0 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -12,6 +12,7 @@
12#include <linux/kthread.h> 12#include <linux/kthread.h>
13#include <linux/mutex.h> 13#include <linux/mutex.h>
14#include <linux/kobject.h> 14#include <linux/kobject.h>
15#include <linux/slab.h>
15 16
16#include <scsi/scsi_tcq.h> 17#include <scsi/scsi_tcq.h>
17#include <scsi/scsicam.h> 18#include <scsi/scsicam.h>
@@ -1676,9 +1677,11 @@ skip_pio:
1676 1677
1677 /* Determine queue resources */ 1678 /* Determine queue resources */
1678 ha->max_req_queues = ha->max_rsp_queues = 1; 1679 ha->max_req_queues = ha->max_rsp_queues = 1;
1679 if ((ql2xmaxqueues <= 1 || ql2xmultique_tag < 1) && 1680 if ((ql2xmaxqueues <= 1 && !ql2xmultique_tag) ||
1681 (ql2xmaxqueues > 1 && ql2xmultique_tag) ||
1680 (!IS_QLA25XX(ha) && !IS_QLA81XX(ha))) 1682 (!IS_QLA25XX(ha) && !IS_QLA81XX(ha)))
1681 goto mqiobase_exit; 1683 goto mqiobase_exit;
1684
1682 ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 3), 1685 ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 3),
1683 pci_resource_len(ha->pdev, 3)); 1686 pci_resource_len(ha->pdev, 3));
1684 if (ha->mqiobase) { 1687 if (ha->mqiobase) {
diff --git a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c
index 371dc895972..8b3de4e54c2 100644
--- a/drivers/scsi/qla2xxx/qla_sup.c
+++ b/drivers/scsi/qla2xxx/qla_sup.c
@@ -7,6 +7,7 @@
7#include "qla_def.h" 7#include "qla_def.h"
8 8
9#include <linux/delay.h> 9#include <linux/delay.h>
10#include <linux/slab.h>
10#include <linux/vmalloc.h> 11#include <linux/vmalloc.h>
11#include <asm/uaccess.h> 12#include <asm/uaccess.h>
12 13
diff --git a/drivers/scsi/qla2xxx/qla_version.h b/drivers/scsi/qla2xxx/qla_version.h
index 8d2fc2fa7a6..109068df933 100644
--- a/drivers/scsi/qla2xxx/qla_version.h
+++ b/drivers/scsi/qla2xxx/qla_version.h
@@ -7,9 +7,9 @@
7/* 7/*
8 * Driver version 8 * Driver version
9 */ 9 */
10#define QLA2XXX_VERSION "8.03.02-k1" 10#define QLA2XXX_VERSION "8.03.02-k2"
11 11
12#define QLA_DRIVER_MAJOR_VER 8 12#define QLA_DRIVER_MAJOR_VER 8
13#define QLA_DRIVER_MINOR_VER 3 13#define QLA_DRIVER_MINOR_VER 3
14#define QLA_DRIVER_PATCH_VER 2 14#define QLA_DRIVER_PATCH_VER 2
15#define QLA_DRIVER_BETA_VER 1 15#define QLA_DRIVER_BETA_VER 2
diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c
index 09d6d4b76f3..caeb7d10ae0 100644
--- a/drivers/scsi/qla4xxx/ql4_mbx.c
+++ b/drivers/scsi/qla4xxx/ql4_mbx.c
@@ -467,7 +467,7 @@ int qla4xxx_get_fwddb_entry(struct scsi_qla_host *ha,
467 if (conn_err_detail) 467 if (conn_err_detail)
468 *conn_err_detail = mbox_sts[5]; 468 *conn_err_detail = mbox_sts[5];
469 if (tcp_source_port_num) 469 if (tcp_source_port_num)
470 *tcp_source_port_num = (uint16_t) mbox_sts[6] >> 16; 470 *tcp_source_port_num = (uint16_t) (mbox_sts[6] >> 16);
471 if (connection_id) 471 if (connection_id)
472 *connection_id = (uint16_t) mbox_sts[6] & 0x00FF; 472 *connection_id = (uint16_t) mbox_sts[6] & 0x00FF;
473 status = QLA_SUCCESS; 473 status = QLA_SUCCESS;
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 83c8b5e4fc8..2ccad36bee9 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -5,6 +5,7 @@
5 * See LICENSE.qla4xxx for copyright and licensing details. 5 * See LICENSE.qla4xxx for copyright and licensing details.
6 */ 6 */
7#include <linux/moduleparam.h> 7#include <linux/moduleparam.h>
8#include <linux/slab.h>
8 9
9#include <scsi/scsi_tcq.h> 10#include <scsi/scsi_tcq.h>
10#include <scsi/scsicam.h> 11#include <scsi/scsicam.h>
diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c
index 1b8217076b0..aa406497eeb 100644
--- a/drivers/scsi/qlogicpti.c
+++ b/drivers/scsi/qlogicpti.c
@@ -16,7 +16,7 @@
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/types.h> 17#include <linux/types.h>
18#include <linux/string.h> 18#include <linux/string.h>
19#include <linux/slab.h> 19#include <linux/gfp.h>
20#include <linux/blkdev.h> 20#include <linux/blkdev.h>
21#include <linux/proc_fs.h> 21#include <linux/proc_fs.h>
22#include <linux/stat.h> 22#include <linux/stat.h>
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 0b575c87100..3a5bfd10b2c 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -30,6 +30,7 @@
30#include <linux/kernel.h> 30#include <linux/kernel.h>
31#include <linux/errno.h> 31#include <linux/errno.h>
32#include <linux/timer.h> 32#include <linux/timer.h>
33#include <linux/slab.h>
33#include <linux/types.h> 34#include <linux/types.h>
34#include <linux/string.h> 35#include <linux/string.h>
35#include <linux/genhd.h> 36#include <linux/genhd.h>
@@ -956,7 +957,8 @@ static int resp_start_stop(struct scsi_cmnd * scp,
956static sector_t get_sdebug_capacity(void) 957static sector_t get_sdebug_capacity(void)
957{ 958{
958 if (scsi_debug_virtual_gb > 0) 959 if (scsi_debug_virtual_gb > 0)
959 return 2048 * 1024 * (sector_t)scsi_debug_virtual_gb; 960 return (sector_t)scsi_debug_virtual_gb *
961 (1073741824 / scsi_debug_sector_size);
960 else 962 else
961 return sdebug_store_sectors; 963 return sdebug_store_sectors;
962} 964}
diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
index 37af178b2d1..43fad4c09be 100644
--- a/drivers/scsi/scsi_devinfo.c
+++ b/drivers/scsi/scsi_devinfo.c
@@ -6,6 +6,7 @@
6#include <linux/moduleparam.h> 6#include <linux/moduleparam.h>
7#include <linux/proc_fs.h> 7#include <linux/proc_fs.h>
8#include <linux/seq_file.h> 8#include <linux/seq_file.h>
9#include <linux/slab.h>
9 10
10#include <scsi/scsi_device.h> 11#include <scsi/scsi_device.h>
11#include <scsi/scsi_devinfo.h> 12#include <scsi/scsi_devinfo.h>
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 08ed506e605..7ad53fa4276 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -16,6 +16,7 @@
16 16
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/sched.h> 18#include <linux/sched.h>
19#include <linux/gfp.h>
19#include <linux/timer.h> 20#include <linux/timer.h>
20#include <linux/string.h> 21#include <linux/string.h>
21#include <linux/kernel.h> 22#include <linux/kernel.h>
@@ -301,7 +302,20 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
301 if (scmd->device->allow_restart && 302 if (scmd->device->allow_restart &&
302 (sshdr.asc == 0x04) && (sshdr.ascq == 0x02)) 303 (sshdr.asc == 0x04) && (sshdr.ascq == 0x02))
303 return FAILED; 304 return FAILED;
304 return SUCCESS; 305
306 if (blk_barrier_rq(scmd->request))
307 /*
308 * barrier requests should always retry on UA
309 * otherwise block will get a spurious error
310 */
311 return NEEDS_RETRY;
312 else
313 /*
314 * for normal (non barrier) commands, pass the
315 * UA upwards for a determination in the
316 * completion functions
317 */
318 return SUCCESS;
305 319
306 /* these three are not supported */ 320 /* these three are not supported */
307 case COPY_ABORTED: 321 case COPY_ABORTED:
diff --git a/drivers/scsi/scsi_netlink.c b/drivers/scsi/scsi_netlink.c
index 0fd6ae6911a..d53e6503c6d 100644
--- a/drivers/scsi/scsi_netlink.c
+++ b/drivers/scsi/scsi_netlink.c
@@ -22,6 +22,7 @@
22#include <linux/jiffies.h> 22#include <linux/jiffies.h>
23#include <linux/security.h> 23#include <linux/security.h>
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/slab.h>
25#include <net/sock.h> 26#include <net/sock.h>
26#include <net/netlink.h> 27#include <net/netlink.h>
27 28
diff --git a/drivers/scsi/scsi_proc.c b/drivers/scsi/scsi_proc.c
index 77fbddb507f..c99da926fda 100644
--- a/drivers/scsi/scsi_proc.c
+++ b/drivers/scsi/scsi_proc.c
@@ -20,12 +20,12 @@
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/string.h> 21#include <linux/string.h>
22#include <linux/mm.h> 22#include <linux/mm.h>
23#include <linux/slab.h>
24#include <linux/proc_fs.h> 23#include <linux/proc_fs.h>
25#include <linux/errno.h> 24#include <linux/errno.h>
26#include <linux/blkdev.h> 25#include <linux/blkdev.h>
27#include <linux/seq_file.h> 26#include <linux/seq_file.h>
28#include <linux/mutex.h> 27#include <linux/mutex.h>
28#include <linux/gfp.h>
29#include <asm/uaccess.h> 29#include <asm/uaccess.h>
30 30
31#include <scsi/scsi.h> 31#include <scsi/scsi.h>
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 4bc8b77a2ef..38518b08807 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -33,6 +33,7 @@
33#include <linux/kthread.h> 33#include <linux/kthread.h>
34#include <linux/spinlock.h> 34#include <linux/spinlock.h>
35#include <linux/async.h> 35#include <linux/async.h>
36#include <linux/slab.h>
36 37
37#include <scsi/scsi.h> 38#include <scsi/scsi.h>
38#include <scsi/scsi_cmnd.h> 39#include <scsi/scsi_cmnd.h>
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 19ec9e2d3f3..429c9b73e3e 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -7,6 +7,7 @@
7 */ 7 */
8 8
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/slab.h>
10#include <linux/init.h> 11#include <linux/init.h>
11#include <linux/blkdev.h> 12#include <linux/blkdev.h>
12#include <linux/device.h> 13#include <linux/device.h>
diff --git a/drivers/scsi/scsi_tgt_if.c b/drivers/scsi/scsi_tgt_if.c
index 0e9533f7aab..a87e21c35ef 100644
--- a/drivers/scsi/scsi_tgt_if.c
+++ b/drivers/scsi/scsi_tgt_if.c
@@ -20,6 +20,7 @@
20 * 02110-1301 USA 20 * 02110-1301 USA
21 */ 21 */
22#include <linux/miscdevice.h> 22#include <linux/miscdevice.h>
23#include <linux/gfp.h>
23#include <linux/file.h> 24#include <linux/file.h>
24#include <linux/smp_lock.h> 25#include <linux/smp_lock.h>
25#include <net/tcp.h> 26#include <net/tcp.h>
diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
index 10303272ba4..66241dd525a 100644
--- a/drivers/scsi/scsi_tgt_lib.c
+++ b/drivers/scsi/scsi_tgt_lib.c
@@ -23,6 +23,7 @@
23#include <linux/hash.h> 23#include <linux/hash.h>
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/pagemap.h> 25#include <linux/pagemap.h>
26#include <linux/slab.h>
26#include <scsi/scsi.h> 27#include <scsi/scsi.h>
27#include <scsi/scsi_cmnd.h> 28#include <scsi/scsi_cmnd.h>
28#include <scsi/scsi_device.h> 29#include <scsi/scsi_device.h>
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 1d5b72173dd..6cfffc88022 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -27,6 +27,7 @@
27 */ 27 */
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/slab.h>
30#include <linux/delay.h> 31#include <linux/delay.h>
31#include <scsi/scsi_device.h> 32#include <scsi/scsi_device.h>
32#include <scsi/scsi_host.h> 33#include <scsi/scsi_host.h>
@@ -3852,7 +3853,7 @@ fc_bsg_request_handler(struct request_queue *q, struct Scsi_Host *shost,
3852 if (rport && (rport->port_state != FC_PORTSTATE_ONLINE)) { 3853 if (rport && (rport->port_state != FC_PORTSTATE_ONLINE)) {
3853 req->errors = -ENXIO; 3854 req->errors = -ENXIO;
3854 spin_unlock_irq(q->queue_lock); 3855 spin_unlock_irq(q->queue_lock);
3855 blk_end_request(req, -ENXIO, blk_rq_bytes(req)); 3856 blk_end_request_all(req, -ENXIO);
3856 spin_lock_irq(q->queue_lock); 3857 spin_lock_irq(q->queue_lock);
3857 continue; 3858 continue;
3858 } 3859 }
@@ -3862,7 +3863,7 @@ fc_bsg_request_handler(struct request_queue *q, struct Scsi_Host *shost,
3862 ret = fc_req_to_bsgjob(shost, rport, req); 3863 ret = fc_req_to_bsgjob(shost, rport, req);
3863 if (ret) { 3864 if (ret) {
3864 req->errors = ret; 3865 req->errors = ret;
3865 blk_end_request(req, ret, blk_rq_bytes(req)); 3866 blk_end_request_all(req, ret);
3866 spin_lock_irq(q->queue_lock); 3867 spin_lock_irq(q->queue_lock);
3867 continue; 3868 continue;
3868 } 3869 }
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index ea3892e7e0f..1e6d4793542 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -22,6 +22,7 @@
22 */ 22 */
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/mutex.h> 24#include <linux/mutex.h>
25#include <linux/slab.h>
25#include <net/tcp.h> 26#include <net/tcp.h>
26#include <scsi/scsi.h> 27#include <scsi/scsi.h>
27#include <scsi/scsi_host.h> 28#include <scsi/scsi_host.h>
diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
index c25bd9a34e0..8a172d4f456 100644
--- a/drivers/scsi/scsi_transport_spi.c
+++ b/drivers/scsi/scsi_transport_spi.c
@@ -25,6 +25,7 @@
25#include <linux/blkdev.h> 25#include <linux/blkdev.h>
26#include <linux/mutex.h> 26#include <linux/mutex.h>
27#include <linux/sysfs.h> 27#include <linux/sysfs.h>
28#include <linux/slab.h>
28#include <scsi/scsi.h> 29#include <scsi/scsi.h>
29#include "scsi_priv.h" 30#include "scsi_priv.h"
30#include <scsi/scsi_device.h> 31#include <scsi/scsi_device.h>
diff --git a/drivers/scsi/scsicam.c b/drivers/scsi/scsicam.c
index 3f21bc65e8c..6803b1e26ec 100644
--- a/drivers/scsi/scsicam.c
+++ b/drivers/scsi/scsicam.c
@@ -11,6 +11,7 @@
11 */ 11 */
12 12
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/slab.h>
14#include <linux/fs.h> 15#include <linux/fs.h>
15#include <linux/genhd.h> 16#include <linux/genhd.h>
16#include <linux/kernel.h> 17#include <linux/kernel.h>
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 7b75c8a2a49..de6c60320f6 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -49,6 +49,7 @@
49#include <linux/mutex.h> 49#include <linux/mutex.h>
50#include <linux/string_helpers.h> 50#include <linux/string_helpers.h>
51#include <linux/async.h> 51#include <linux/async.h>
52#include <linux/slab.h>
52#include <asm/uaccess.h> 53#include <asm/uaccess.h>
53#include <asm/unaligned.h> 54#include <asm/unaligned.h>
54 55
@@ -1039,6 +1040,7 @@ static void sd_prepare_flush(struct request_queue *q, struct request *rq)
1039{ 1040{
1040 rq->cmd_type = REQ_TYPE_BLOCK_PC; 1041 rq->cmd_type = REQ_TYPE_BLOCK_PC;
1041 rq->timeout = SD_TIMEOUT; 1042 rq->timeout = SD_TIMEOUT;
1043 rq->retries = SD_MAX_RETRIES;
1042 rq->cmd[0] = SYNCHRONIZE_CACHE; 1044 rq->cmd[0] = SYNCHRONIZE_CACHE;
1043 rq->cmd_len = 10; 1045 rq->cmd_len = 10;
1044} 1046}
@@ -2185,7 +2187,7 @@ static void sd_probe_async(void *data, async_cookie_t cookie)
2185 blk_queue_prep_rq(sdp->request_queue, sd_prep_fn); 2187 blk_queue_prep_rq(sdp->request_queue, sd_prep_fn);
2186 2188
2187 gd->driverfs_dev = &sdp->sdev_gendev; 2189 gd->driverfs_dev = &sdp->sdev_gendev;
2188 gd->flags = GENHD_FL_EXT_DEVT | GENHD_FL_DRIVERFS; 2190 gd->flags = GENHD_FL_EXT_DEVT;
2189 if (sdp->removable) 2191 if (sdp->removable)
2190 gd->flags |= GENHD_FL_REMOVABLE; 2192 gd->flags |= GENHD_FL_REMOVABLE;
2191 2193
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index 0d9d6f7567f..7f5a6a86f82 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -21,6 +21,7 @@
21**----------------------------------------------------------------------------- 21**-----------------------------------------------------------------------------
22*/ 22*/
23 23
24#include <linux/slab.h>
24#include <linux/module.h> 25#include <linux/module.h>
25#include <linux/kernel.h> 26#include <linux/kernel.h>
26#include <linux/enclosure.h> 27#include <linux/enclosure.h>
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index c996d98636f..dee1c96288d 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -38,6 +38,7 @@ static int sg_version_num = 30534; /* 2 digits for each component */
38#include <linux/errno.h> 38#include <linux/errno.h>
39#include <linux/mtio.h> 39#include <linux/mtio.h>
40#include <linux/ioctl.h> 40#include <linux/ioctl.h>
41#include <linux/slab.h>
41#include <linux/fcntl.h> 42#include <linux/fcntl.h>
42#include <linux/init.h> 43#include <linux/init.h>
43#include <linux/poll.h> 44#include <linux/poll.h>
diff --git a/drivers/scsi/sim710.c b/drivers/scsi/sim710.c
index 6dc8b846c11..8ac6ce792b6 100644
--- a/drivers/scsi/sim710.c
+++ b/drivers/scsi/sim710.c
@@ -27,6 +27,7 @@
27 */ 27 */
28 28
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/slab.h>
30 31
31#include <linux/blkdev.h> 32#include <linux/blkdev.h>
32#include <linux/device.h> 33#include <linux/device.h>
diff --git a/drivers/scsi/sni_53c710.c b/drivers/scsi/sni_53c710.c
index 56cf0bb4ed1..9acc2b2a360 100644
--- a/drivers/scsi/sni_53c710.c
+++ b/drivers/scsi/sni_53c710.c
@@ -30,6 +30,7 @@
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/init.h> 31#include <linux/init.h>
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/slab.h>
33#include <linux/stat.h> 34#include <linux/stat.h>
34#include <linux/mm.h> 35#include <linux/mm.h>
35#include <linux/blkdev.h> 36#include <linux/blkdev.h>
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index d6f340f48a3..0a90abc7f14 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -44,6 +44,7 @@
44#include <linux/init.h> 44#include <linux/init.h>
45#include <linux/blkdev.h> 45#include <linux/blkdev.h>
46#include <linux/mutex.h> 46#include <linux/mutex.h>
47#include <linux/slab.h>
47#include <asm/uaccess.h> 48#include <asm/uaccess.h>
48 49
49#include <scsi/scsi.h> 50#include <scsi/scsi.h>
diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c
index 291236e6e43..cbb38c5197f 100644
--- a/drivers/scsi/sr_ioctl.c
+++ b/drivers/scsi/sr_ioctl.c
@@ -7,6 +7,7 @@
7#include <linux/blkpg.h> 7#include <linux/blkpg.h>
8#include <linux/cdrom.h> 8#include <linux/cdrom.h>
9#include <linux/delay.h> 9#include <linux/delay.h>
10#include <linux/slab.h>
10#include <asm/io.h> 11#include <asm/io.h>
11#include <asm/uaccess.h> 12#include <asm/uaccess.h>
12 13
diff --git a/drivers/scsi/sr_vendor.c b/drivers/scsi/sr_vendor.c
index 4ad3e017213..92cc2efb25d 100644
--- a/drivers/scsi/sr_vendor.c
+++ b/drivers/scsi/sr_vendor.c
@@ -39,6 +39,7 @@
39#include <linux/string.h> 39#include <linux/string.h>
40#include <linux/bcd.h> 40#include <linux/bcd.h>
41#include <linux/blkdev.h> 41#include <linux/blkdev.h>
42#include <linux/slab.h>
42 43
43#include <scsi/scsi.h> 44#include <scsi/scsi.h>
44#include <scsi/scsi_cmnd.h> 45#include <scsi/scsi_cmnd.h>
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index f67d1a159aa..3ea1a713ef2 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -27,6 +27,7 @@ static const char *verstr = "20081215";
27#include <linux/mm.h> 27#include <linux/mm.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/string.h> 29#include <linux/string.h>
30#include <linux/slab.h>
30#include <linux/errno.h> 31#include <linux/errno.h>
31#include <linux/mtio.h> 32#include <linux/mtio.h>
32#include <linux/cdrom.h> 33#include <linux/cdrom.h>
diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c
index fd7b15be764..9c73dbda3bb 100644
--- a/drivers/scsi/stex.c
+++ b/drivers/scsi/stex.c
@@ -17,6 +17,7 @@
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/delay.h> 19#include <linux/delay.h>
20#include <linux/slab.h>
20#include <linux/time.h> 21#include <linux/time.h>
21#include <linux/pci.h> 22#include <linux/pci.h>
22#include <linux/blkdev.h> 23#include <linux/blkdev.h>
diff --git a/drivers/scsi/sun3_NCR5380.c b/drivers/scsi/sun3_NCR5380.c
index 75da6e58ce5..b5838d547c6 100644
--- a/drivers/scsi/sun3_NCR5380.c
+++ b/drivers/scsi/sun3_NCR5380.c
@@ -645,6 +645,7 @@ __inline__ void NCR5380_print_phase(struct Scsi_Host *instance) { };
645 * interrupt or bottom half. 645 * interrupt or bottom half.
646 */ 646 */
647 647
648#include <linux/gfp.h>
648#include <linux/workqueue.h> 649#include <linux/workqueue.h>
649#include <linux/interrupt.h> 650#include <linux/interrupt.h>
650 651
diff --git a/drivers/scsi/sun3x_esp.c b/drivers/scsi/sun3x_esp.c
index 34a99620e5b..0621037f027 100644
--- a/drivers/scsi/sun3x_esp.c
+++ b/drivers/scsi/sun3x_esp.c
@@ -4,6 +4,7 @@
4 */ 4 */
5 5
6#include <linux/kernel.h> 6#include <linux/kernel.h>
7#include <linux/gfp.h>
7#include <linux/types.h> 8#include <linux/types.h>
8#include <linux/delay.h> 9#include <linux/delay.h>
9#include <linux/module.h> 10#include <linux/module.h>
diff --git a/drivers/scsi/sun_esp.c b/drivers/scsi/sun_esp.c
index 3d73aad4bc8..fc23d273fb1 100644
--- a/drivers/scsi/sun_esp.c
+++ b/drivers/scsi/sun_esp.c
@@ -12,6 +12,7 @@
12#include <linux/dma-mapping.h> 12#include <linux/dma-mapping.h>
13#include <linux/of.h> 13#include <linux/of.h>
14#include <linux/of_device.h> 14#include <linux/of_device.h>
15#include <linux/gfp.h>
15 16
16#include <asm/irq.h> 17#include <asm/irq.h>
17#include <asm/io.h> 18#include <asm/io.h>
diff --git a/drivers/scsi/tmscsim.c b/drivers/scsi/tmscsim.c
index 9a4273445c0..27866b0adfe 100644
--- a/drivers/scsi/tmscsim.c
+++ b/drivers/scsi/tmscsim.c
@@ -233,6 +233,7 @@
233#include <linux/interrupt.h> 233#include <linux/interrupt.h>
234#include <linux/init.h> 234#include <linux/init.h>
235#include <linux/spinlock.h> 235#include <linux/spinlock.h>
236#include <linux/slab.h>
236#include <asm/io.h> 237#include <asm/io.h>
237 238
238#include <scsi/scsi.h> 239#include <scsi/scsi.h>
diff --git a/drivers/scsi/u14-34f.c b/drivers/scsi/u14-34f.c
index 26e8e0e6b8d..5d9fdeeb231 100644
--- a/drivers/scsi/u14-34f.c
+++ b/drivers/scsi/u14-34f.c
@@ -420,6 +420,7 @@
420#include <linux/init.h> 420#include <linux/init.h>
421#include <linux/ctype.h> 421#include <linux/ctype.h>
422#include <linux/spinlock.h> 422#include <linux/spinlock.h>
423#include <linux/slab.h>
423#include <asm/dma.h> 424#include <asm/dma.h>
424#include <asm/irq.h> 425#include <asm/irq.h>
425 426
diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c
index e4ac5829b63..26894459c37 100644
--- a/drivers/scsi/vmw_pvscsi.c
+++ b/drivers/scsi/vmw_pvscsi.c
@@ -24,6 +24,7 @@
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/slab.h>
27#include <linux/workqueue.h> 28#include <linux/workqueue.h>
28#include <linux/pci.h> 29#include <linux/pci.h>
29 30
diff --git a/drivers/scsi/wd7000.c b/drivers/scsi/wd7000.c
index 2f6e9d8eaf7..333580bf37c 100644
--- a/drivers/scsi/wd7000.c
+++ b/drivers/scsi/wd7000.c
@@ -171,7 +171,6 @@
171#include <linux/kernel.h> 171#include <linux/kernel.h>
172#include <linux/types.h> 172#include <linux/types.h>
173#include <linux/string.h> 173#include <linux/string.h>
174#include <linux/slab.h>
175#include <linux/spinlock.h> 174#include <linux/spinlock.h>
176#include <linux/ioport.h> 175#include <linux/ioport.h>
177#include <linux/proc_fs.h> 176#include <linux/proc_fs.h>
@@ -1588,7 +1587,7 @@ static int wd7000_host_reset(struct scsi_cmnd *SCpnt)
1588{ 1587{
1589 Adapter *host = (Adapter *) SCpnt->device->host->hostdata; 1588 Adapter *host = (Adapter *) SCpnt->device->host->hostdata;
1590 1589
1591 spin_unlock_irq(SCpnt->device->host->host_lock); 1590 spin_lock_irq(SCpnt->device->host->host_lock);
1592 1591
1593 if (wd7000_adapter_reset(host) < 0) { 1592 if (wd7000_adapter_reset(host) < 0) {
1594 spin_unlock_irq(SCpnt->device->host->host_lock); 1593 spin_unlock_irq(SCpnt->device->host->host_lock);
diff --git a/drivers/scsi/zorro7xx.c b/drivers/scsi/zorro7xx.c
index 64d40a2d4d4..105449c15fa 100644
--- a/drivers/scsi/zorro7xx.c
+++ b/drivers/scsi/zorro7xx.c
@@ -13,6 +13,7 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/interrupt.h> 14#include <linux/interrupt.h>
15#include <linux/zorro.h> 15#include <linux/zorro.h>
16#include <linux/slab.h>
16 17
17#include <asm/amigahw.h> 18#include <asm/amigahw.h>
18#include <asm/amigaints.h> 19#include <asm/amigaints.h>
diff --git a/drivers/serial/68328serial.c b/drivers/serial/68328serial.c
index ae0251ef6f4..78ed24bb6a3 100644
--- a/drivers/serial/68328serial.c
+++ b/drivers/serial/68328serial.c
@@ -35,6 +35,7 @@
35#include <linux/pm.h> 35#include <linux/pm.h>
36#include <linux/bitops.h> 36#include <linux/bitops.h>
37#include <linux/delay.h> 37#include <linux/delay.h>
38#include <linux/gfp.h>
38 39
39#include <asm/io.h> 40#include <asm/io.h>
40#include <asm/irq.h> 41#include <asm/irq.h>
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index c3db16b7afa..2b1ea3d4c4f 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -38,6 +38,7 @@
38#include <linux/serial_8250.h> 38#include <linux/serial_8250.h>
39#include <linux/nmi.h> 39#include <linux/nmi.h>
40#include <linux/mutex.h> 40#include <linux/mutex.h>
41#include <linux/slab.h>
41 42
42#include <asm/io.h> 43#include <asm/io.h>
43#include <asm/irq.h> 44#include <asm/irq.h>
diff --git a/drivers/serial/8250_gsc.c b/drivers/serial/8250_gsc.c
index 33149d982e8..d8c0ffbfa6e 100644
--- a/drivers/serial/8250_gsc.c
+++ b/drivers/serial/8250_gsc.c
@@ -16,7 +16,6 @@
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/serial_core.h> 17#include <linux/serial_core.h>
18#include <linux/signal.h> 18#include <linux/signal.h>
19#include <linux/slab.h>
20#include <linux/types.h> 19#include <linux/types.h>
21 20
22#include <asm/hardware.h> 21#include <asm/hardware.h>
diff --git a/drivers/serial/8250_hp300.c b/drivers/serial/8250_hp300.c
index 0e1410f2c03..c13438c9301 100644
--- a/drivers/serial/8250_hp300.c
+++ b/drivers/serial/8250_hp300.c
@@ -15,6 +15,7 @@
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/dio.h> 16#include <linux/dio.h>
17#include <linux/console.h> 17#include <linux/console.h>
18#include <linux/slab.h>
18#include <asm/io.h> 19#include <asm/io.h>
19 20
20#include "8250.h" 21#include "8250.h"
diff --git a/drivers/serial/8250_pnp.c b/drivers/serial/8250_pnp.c
index 24485cc62ff..4822cb50cd0 100644
--- a/drivers/serial/8250_pnp.c
+++ b/drivers/serial/8250_pnp.c
@@ -348,6 +348,8 @@ static const struct pnp_device_id pnp_dev_table[] = {
348 { "FUJ02E6", 0 }, 348 { "FUJ02E6", 0 },
349 /* Fujitsu Wacom 2FGT Tablet PC device */ 349 /* Fujitsu Wacom 2FGT Tablet PC device */
350 { "FUJ02E7", 0 }, 350 { "FUJ02E7", 0 },
351 /* Fujitsu Wacom 1FGT Tablet PC device */
352 { "FUJ02E9", 0 },
351 /* 353 /*
352 * LG C1 EXPRESS DUAL (C1-PB11A3) touch screen (actually a FUJ02E6 in 354 * LG C1 EXPRESS DUAL (C1-PB11A3) touch screen (actually a FUJ02E6 in
353 * disguise) 355 * disguise)
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index f55c49475a8..5f3f03df92e 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -518,12 +518,13 @@ config SERIAL_S3C2412
518 Serial port support for the Samsung S3C2412 and S3C2413 SoC 518 Serial port support for the Samsung S3C2412 and S3C2413 SoC
519 519
520config SERIAL_S3C2440 520config SERIAL_S3C2440
521 tristate "Samsung S3C2440/S3C2442 Serial port support" 521 tristate "Samsung S3C2440/S3C2442/S3C2416 Serial port support"
522 depends on SERIAL_SAMSUNG && (CPU_S3C2440 || CPU_S3C2442) 522 depends on SERIAL_SAMSUNG && (CPU_S3C2440 || CPU_S3C2442 || CPU_S3C2416)
523 default y if CPU_S3C2440 523 default y if CPU_S3C2440
524 default y if CPU_S3C2442 524 default y if CPU_S3C2442
525 select SERIAL_SAMSUNG_UARTS_4 if CPU_S3C2416
525 help 526 help
526 Serial port support for the Samsung S3C2440 and S3C2442 SoC 527 Serial port support for the Samsung S3C2440, S3C2416 and S3C2442 SoC
527 528
528config SERIAL_S3C24A0 529config SERIAL_S3C24A0
529 tristate "Samsung S3C24A0 Serial port support" 530 tristate "Samsung S3C24A0 Serial port support"
diff --git a/drivers/serial/amba-pl010.c b/drivers/serial/amba-pl010.c
index e4b3c2c88bb..b09a638d051 100644
--- a/drivers/serial/amba-pl010.c
+++ b/drivers/serial/amba-pl010.c
@@ -47,6 +47,7 @@
47#include <linux/amba/bus.h> 47#include <linux/amba/bus.h>
48#include <linux/amba/serial.h> 48#include <linux/amba/serial.h>
49#include <linux/clk.h> 49#include <linux/clk.h>
50#include <linux/slab.h>
50 51
51#include <asm/io.h> 52#include <asm/io.h>
52 53
diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c
index ce6c35333ff..743ebf5f16d 100644
--- a/drivers/serial/amba-pl011.c
+++ b/drivers/serial/amba-pl011.c
@@ -47,6 +47,7 @@
47#include <linux/amba/bus.h> 47#include <linux/amba/bus.h>
48#include <linux/amba/serial.h> 48#include <linux/amba/serial.h>
49#include <linux/clk.h> 49#include <linux/clk.h>
50#include <linux/slab.h>
50 51
51#include <asm/io.h> 52#include <asm/io.h>
52#include <asm/sizes.h> 53#include <asm/sizes.h>
diff --git a/drivers/serial/bfin_5xx.c b/drivers/serial/bfin_5xx.c
index fcf273e3f48..96f7e7484fe 100644
--- a/drivers/serial/bfin_5xx.c
+++ b/drivers/serial/bfin_5xx.c
@@ -14,6 +14,7 @@
14 14
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/ioport.h> 16#include <linux/ioport.h>
17#include <linux/gfp.h>
17#include <linux/io.h> 18#include <linux/io.h>
18#include <linux/init.h> 19#include <linux/init.h>
19#include <linux/console.h> 20#include <linux/console.h>
diff --git a/drivers/serial/bfin_sport_uart.c b/drivers/serial/bfin_sport_uart.c
index 7c72888fbf9..c88f8ad3ff8 100644
--- a/drivers/serial/bfin_sport_uart.c
+++ b/drivers/serial/bfin_sport_uart.c
@@ -28,6 +28,7 @@
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/console.h> 29#include <linux/console.h>
30#include <linux/sysrq.h> 30#include <linux/sysrq.h>
31#include <linux/slab.h>
31#include <linux/platform_device.h> 32#include <linux/platform_device.h>
32#include <linux/tty.h> 33#include <linux/tty.h>
33#include <linux/tty_flip.h> 34#include <linux/tty_flip.h>
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm1.c b/drivers/serial/cpm_uart/cpm_uart_cpm1.c
index 1b94c56ec23..3fc1d66e32c 100644
--- a/drivers/serial/cpm_uart/cpm_uart_cpm1.c
+++ b/drivers/serial/cpm_uart/cpm_uart_cpm1.c
@@ -29,6 +29,7 @@
29 29
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/tty.h> 31#include <linux/tty.h>
32#include <linux/gfp.h>
32#include <linux/ioport.h> 33#include <linux/ioport.h>
33#include <linux/init.h> 34#include <linux/init.h>
34#include <linux/serial.h> 35#include <linux/serial.h>
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm2.c b/drivers/serial/cpm_uart/cpm_uart_cpm2.c
index a9802e76b5f..814ac006393 100644
--- a/drivers/serial/cpm_uart/cpm_uart_cpm2.c
+++ b/drivers/serial/cpm_uart/cpm_uart_cpm2.c
@@ -30,6 +30,7 @@
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/tty.h> 31#include <linux/tty.h>
32#include <linux/ioport.h> 32#include <linux/ioport.h>
33#include <linux/slab.h>
33#include <linux/init.h> 34#include <linux/init.h>
34#include <linux/serial.h> 35#include <linux/serial.h>
35#include <linux/console.h> 36#include <linux/console.h>
@@ -61,7 +62,7 @@ void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port,
61 void __iomem *pram; 62 void __iomem *pram;
62 unsigned long offset; 63 unsigned long offset;
63 struct resource res; 64 struct resource res;
64 unsigned long len; 65 resource_size_t len;
65 66
66 /* Don't remap parameter RAM if it has already been initialized 67 /* Don't remap parameter RAM if it has already been initialized
67 * during console setup. 68 * during console setup.
@@ -74,7 +75,7 @@ void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port,
74 if (of_address_to_resource(np, 1, &res)) 75 if (of_address_to_resource(np, 1, &res))
75 return NULL; 76 return NULL;
76 77
77 len = 1 + res.end - res.start; 78 len = resource_size(&res);
78 pram = ioremap(res.start, len); 79 pram = ioremap(res.start, len);
79 if (!pram) 80 if (!pram)
80 return NULL; 81 return NULL;
diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c
index e579d7a1807..4315b23590b 100644
--- a/drivers/serial/imx.c
+++ b/drivers/serial/imx.c
@@ -46,6 +46,7 @@
46#include <linux/clk.h> 46#include <linux/clk.h>
47#include <linux/delay.h> 47#include <linux/delay.h>
48#include <linux/rational.h> 48#include <linux/rational.h>
49#include <linux/slab.h>
49 50
50#include <asm/io.h> 51#include <asm/io.h>
51#include <asm/irq.h> 52#include <asm/irq.h>
diff --git a/drivers/serial/ioc3_serial.c b/drivers/serial/ioc3_serial.c
index 23ba6b40b3a..f164ba4eba0 100644
--- a/drivers/serial/ioc3_serial.c
+++ b/drivers/serial/ioc3_serial.c
@@ -20,6 +20,7 @@
20#include <linux/pci.h> 20#include <linux/pci.h>
21#include <linux/serial_core.h> 21#include <linux/serial_core.h>
22#include <linux/ioc3.h> 22#include <linux/ioc3.h>
23#include <linux/slab.h>
23 24
24/* 25/*
25 * Interesting things about the ioc3 26 * Interesting things about the ioc3
diff --git a/drivers/serial/ioc4_serial.c b/drivers/serial/ioc4_serial.c
index 836d9ab4f72..8ad28fc6492 100644
--- a/drivers/serial/ioc4_serial.c
+++ b/drivers/serial/ioc4_serial.c
@@ -22,6 +22,7 @@
22#include <linux/pci.h> 22#include <linux/pci.h>
23#include <linux/ioc4.h> 23#include <linux/ioc4.h>
24#include <linux/serial_core.h> 24#include <linux/serial_core.h>
25#include <linux/slab.h>
25 26
26/* 27/*
27 * interesting things about the ioc4 28 * interesting things about the ioc4
diff --git a/drivers/serial/jsm/jsm_driver.c b/drivers/serial/jsm/jsm_driver.c
index 12cb5e446a4..eaf54501411 100644
--- a/drivers/serial/jsm/jsm_driver.c
+++ b/drivers/serial/jsm/jsm_driver.c
@@ -26,6 +26,7 @@
26 ***********************************************************************/ 26 ***********************************************************************/
27#include <linux/moduleparam.h> 27#include <linux/moduleparam.h>
28#include <linux/pci.h> 28#include <linux/pci.h>
29#include <linux/slab.h>
29 30
30#include "jsm.h" 31#include "jsm.h"
31 32
diff --git a/drivers/serial/jsm/jsm_tty.c b/drivers/serial/jsm/jsm_tty.c
index 5673ca9dfdc..7a4a914ecff 100644
--- a/drivers/serial/jsm/jsm_tty.c
+++ b/drivers/serial/jsm/jsm_tty.c
@@ -30,6 +30,7 @@
30#include <linux/serial_reg.h> 30#include <linux/serial_reg.h>
31#include <linux/delay.h> /* For udelay */ 31#include <linux/delay.h> /* For udelay */
32#include <linux/pci.h> 32#include <linux/pci.h>
33#include <linux/slab.h>
33 34
34#include "jsm.h" 35#include "jsm.h"
35 36
diff --git a/drivers/serial/max3100.c b/drivers/serial/max3100.c
index 3c30c56aa2e..3351c3bd59e 100644
--- a/drivers/serial/max3100.c
+++ b/drivers/serial/max3100.c
@@ -41,6 +41,7 @@
41#define MAX_MAX3100 4 41#define MAX_MAX3100 4
42 42
43#include <linux/delay.h> 43#include <linux/delay.h>
44#include <linux/slab.h>
44#include <linux/device.h> 45#include <linux/device.h>
45#include <linux/serial_core.h> 46#include <linux/serial_core.h>
46#include <linux/serial.h> 47#include <linux/serial.h>
diff --git a/drivers/serial/mcf.c b/drivers/serial/mcf.c
index 7bb5fee639e..b5aaef965f2 100644
--- a/drivers/serial/mcf.c
+++ b/drivers/serial/mcf.c
@@ -263,6 +263,7 @@ static void mcf_set_termios(struct uart_port *port, struct ktermios *termios,
263 } 263 }
264 264
265 spin_lock_irqsave(&port->lock, flags); 265 spin_lock_irqsave(&port->lock, flags);
266 uart_update_timeout(port, termios->c_cflag, baud);
266 writeb(MCFUART_UCR_CMDRESETRX, port->membase + MCFUART_UCR); 267 writeb(MCFUART_UCR_CMDRESETRX, port->membase + MCFUART_UCR);
267 writeb(MCFUART_UCR_CMDRESETTX, port->membase + MCFUART_UCR); 268 writeb(MCFUART_UCR_CMDRESETTX, port->membase + MCFUART_UCR);
268 writeb(MCFUART_UCR_CMDRESETMRPTR, port->membase + MCFUART_UCR); 269 writeb(MCFUART_UCR_CMDRESETMRPTR, port->membase + MCFUART_UCR);
@@ -379,6 +380,7 @@ static irqreturn_t mcf_interrupt(int irq, void *data)
379static void mcf_config_port(struct uart_port *port, int flags) 380static void mcf_config_port(struct uart_port *port, int flags)
380{ 381{
381 port->type = PORT_MCF; 382 port->type = PORT_MCF;
383 port->fifosize = MCFUART_TXFIFOSIZE;
382 384
383 /* Clear mask, so no surprise interrupts. */ 385 /* Clear mask, so no surprise interrupts. */
384 writeb(0, port->membase + MCFUART_UIMR); 386 writeb(0, port->membase + MCFUART_UIMR);
@@ -424,7 +426,7 @@ static int mcf_verify_port(struct uart_port *port, struct serial_struct *ser)
424/* 426/*
425 * Define the basic serial functions we support. 427 * Define the basic serial functions we support.
426 */ 428 */
427static struct uart_ops mcf_uart_ops = { 429static const struct uart_ops mcf_uart_ops = {
428 .tx_empty = mcf_tx_empty, 430 .tx_empty = mcf_tx_empty,
429 .get_mctrl = mcf_get_mctrl, 431 .get_mctrl = mcf_get_mctrl,
430 .set_mctrl = mcf_set_mctrl, 432 .set_mctrl = mcf_set_mctrl,
@@ -443,7 +445,7 @@ static struct uart_ops mcf_uart_ops = {
443 .verify_port = mcf_verify_port, 445 .verify_port = mcf_verify_port,
444}; 446};
445 447
446static struct mcf_uart mcf_ports[3]; 448static struct mcf_uart mcf_ports[4];
447 449
448#define MCF_MAXPORTS ARRAY_SIZE(mcf_ports) 450#define MCF_MAXPORTS ARRAY_SIZE(mcf_ports)
449 451
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c
index 3119fddaedb..a176ab4bd65 100644
--- a/drivers/serial/mpc52xx_uart.c
+++ b/drivers/serial/mpc52xx_uart.c
@@ -29,39 +29,6 @@
29 * kind, whether express or implied. 29 * kind, whether express or implied.
30 */ 30 */
31 31
32/* Platform device Usage :
33 *
34 * Since PSCs can have multiple function, the correct driver for each one
35 * is selected by calling mpc52xx_match_psc_function(...). The function
36 * handled by this driver is "uart".
37 *
38 * The driver init all necessary registers to place the PSC in uart mode without
39 * DCD. However, the pin multiplexing aren't changed and should be set either
40 * by the bootloader or in the platform init code.
41 *
42 * The idx field must be equal to the PSC index (e.g. 0 for PSC1, 1 for PSC2,
43 * and so on). So the PSC1 is mapped to /dev/ttyPSC0, PSC2 to /dev/ttyPSC1 and
44 * so on. But be warned, it's an ABSOLUTE REQUIREMENT ! This is needed mainly
45 * fpr the console code : without this 1:1 mapping, at early boot time, when we
46 * are parsing the kernel args console=ttyPSC?, we wouldn't know which PSC it
47 * will be mapped to.
48 */
49
50/* OF Platform device Usage :
51 *
52 * This driver is only used for PSCs configured in uart mode. The device
53 * tree will have a node for each PSC with "mpc52xx-psc-uart" in the compatible
54 * list.
55 *
56 * By default, PSC devices are enumerated in the order they are found. However
57 * a particular PSC number can be forces by adding 'device_no = <port#>'
58 * to the device node.
59 *
60 * The driver init all necessary registers to place the PSC in uart mode without
61 * DCD. However, the pin multiplexing aren't changed and should be set either
62 * by the bootloader or in the platform init code.
63 */
64
65#undef DEBUG 32#undef DEBUG
66 33
67#include <linux/device.h> 34#include <linux/device.h>
diff --git a/drivers/serial/mpsc.c b/drivers/serial/mpsc.c
index b5496c28e60..55e113a0be0 100644
--- a/drivers/serial/mpsc.c
+++ b/drivers/serial/mpsc.c
@@ -70,6 +70,7 @@
70#include <linux/dma-mapping.h> 70#include <linux/dma-mapping.h>
71#include <linux/mv643xx.h> 71#include <linux/mv643xx.h>
72#include <linux/platform_device.h> 72#include <linux/platform_device.h>
73#include <linux/gfp.h>
73 74
74#include <asm/io.h> 75#include <asm/io.h>
75#include <asm/irq.h> 76#include <asm/irq.h>
diff --git a/drivers/serial/mux.c b/drivers/serial/mux.c
index 7571aaa138b..9711e06a837 100644
--- a/drivers/serial/mux.c
+++ b/drivers/serial/mux.c
@@ -22,7 +22,6 @@
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/serial.h> 23#include <linux/serial.h>
24#include <linux/console.h> 24#include <linux/console.h>
25#include <linux/slab.h>
26#include <linux/delay.h> /* for udelay */ 25#include <linux/delay.h> /* for udelay */
27#include <linux/device.h> 26#include <linux/device.h>
28#include <asm/io.h> 27#include <asm/io.h>
diff --git a/drivers/serial/of_serial.c b/drivers/serial/of_serial.c
index cdf172eda2e..4abfebdb0fc 100644
--- a/drivers/serial/of_serial.c
+++ b/drivers/serial/of_serial.c
@@ -11,6 +11,7 @@
11 */ 11 */
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/slab.h>
14#include <linux/serial_core.h> 15#include <linux/serial_core.h>
15#include <linux/serial_8250.h> 16#include <linux/serial_8250.h>
16#include <linux/of_platform.h> 17#include <linux/of_platform.h>
diff --git a/drivers/serial/pmac_zilog.c b/drivers/serial/pmac_zilog.c
index f020de1cdd5..700e10833bf 100644
--- a/drivers/serial/pmac_zilog.c
+++ b/drivers/serial/pmac_zilog.c
@@ -54,7 +54,6 @@
54#include <linux/delay.h> 54#include <linux/delay.h>
55#include <linux/init.h> 55#include <linux/init.h>
56#include <linux/console.h> 56#include <linux/console.h>
57#include <linux/slab.h>
58#include <linux/adb.h> 57#include <linux/adb.h>
59#include <linux/pmu.h> 58#include <linux/pmu.h>
60#include <linux/bitops.h> 59#include <linux/bitops.h>
@@ -753,8 +752,10 @@ static void pmz_break_ctl(struct uart_port *port, int break_state)
753 uap->curregs[R5] = new_reg; 752 uap->curregs[R5] = new_reg;
754 753
755 /* NOTE: Not subject to 'transmitter active' rule. */ 754 /* NOTE: Not subject to 'transmitter active' rule. */
756 if (ZS_IS_ASLEEP(uap)) 755 if (ZS_IS_ASLEEP(uap)) {
756 spin_unlock_irqrestore(&port->lock, flags);
757 return; 757 return;
758 }
758 write_zsreg(uap, R5, uap->curregs[R5]); 759 write_zsreg(uap, R5, uap->curregs[R5]);
759 } 760 }
760 761
diff --git a/drivers/serial/pxa.c b/drivers/serial/pxa.c
index 56ee082157a..1102a39b44f 100644
--- a/drivers/serial/pxa.c
+++ b/drivers/serial/pxa.c
@@ -44,6 +44,7 @@
44#include <linux/serial_core.h> 44#include <linux/serial_core.h>
45#include <linux/clk.h> 45#include <linux/clk.h>
46#include <linux/io.h> 46#include <linux/io.h>
47#include <linux/slab.h>
47 48
48struct uart_pxa_port { 49struct uart_pxa_port {
49 struct uart_port port; 50 struct uart_port port;
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c
index e91db4b3801..8cfa5b12ea7 100644
--- a/drivers/serial/serial_cs.c
+++ b/drivers/serial/serial_cs.c
@@ -105,6 +105,10 @@ struct serial_cfg_mem {
105 * manfid 0x0160, 0x0104 105 * manfid 0x0160, 0x0104
106 * This card appears to have a 14.7456MHz clock. 106 * This card appears to have a 14.7456MHz clock.
107 */ 107 */
108/* Generic Modem: MD55x (GPRS/EDGE) have
109 * Elan VPU16551 UART with 14.7456MHz oscillator
110 * manfid 0x015D, 0x4C45
111 */
108static void quirk_setup_brainboxes_0104(struct pcmcia_device *link, struct uart_port *port) 112static void quirk_setup_brainboxes_0104(struct pcmcia_device *link, struct uart_port *port)
109{ 113{
110 port->uartclk = 14745600; 114 port->uartclk = 14745600;
@@ -196,6 +200,11 @@ static const struct serial_quirk quirks[] = {
196 .multi = -1, 200 .multi = -1,
197 .setup = quirk_setup_brainboxes_0104, 201 .setup = quirk_setup_brainboxes_0104,
198 }, { 202 }, {
203 .manfid = 0x015D,
204 .prodid = 0x4C45,
205 .multi = -1,
206 .setup = quirk_setup_brainboxes_0104,
207 }, {
199 .manfid = MANFID_IBM, 208 .manfid = MANFID_IBM,
200 .prodid = ~0, 209 .prodid = ~0,
201 .multi = -1, 210 .multi = -1,
@@ -745,6 +754,7 @@ static struct pcmcia_device_id serial_ids[] = {
745 PCMCIA_PFC_DEVICE_PROD_ID13(1, "Xircom", "REM10", 0x2e3ee845, 0x76df1d29), 754 PCMCIA_PFC_DEVICE_PROD_ID13(1, "Xircom", "REM10", 0x2e3ee845, 0x76df1d29),
746 PCMCIA_PFC_DEVICE_PROD_ID13(1, "Xircom", "XEM5600", 0x2e3ee845, 0xf1403719), 755 PCMCIA_PFC_DEVICE_PROD_ID13(1, "Xircom", "XEM5600", 0x2e3ee845, 0xf1403719),
747 PCMCIA_PFC_DEVICE_PROD_ID12(1, "AnyCom", "Fast Ethernet + 56K COMBO", 0x578ba6e7, 0xb0ac62c4), 756 PCMCIA_PFC_DEVICE_PROD_ID12(1, "AnyCom", "Fast Ethernet + 56K COMBO", 0x578ba6e7, 0xb0ac62c4),
757 PCMCIA_PFC_DEVICE_PROD_ID12(1, "ATKK", "LM33-PCM-T", 0xba9eb7e2, 0x077c174e),
748 PCMCIA_PFC_DEVICE_PROD_ID12(1, "D-Link", "DME336T", 0x1a424a1c, 0xb23897ff), 758 PCMCIA_PFC_DEVICE_PROD_ID12(1, "D-Link", "DME336T", 0x1a424a1c, 0xb23897ff),
749 PCMCIA_PFC_DEVICE_PROD_ID12(1, "Gateway 2000", "XJEM3336", 0xdd9989be, 0x662c394c), 759 PCMCIA_PFC_DEVICE_PROD_ID12(1, "Gateway 2000", "XJEM3336", 0xdd9989be, 0x662c394c),
750 PCMCIA_PFC_DEVICE_PROD_ID12(1, "Grey Cell", "GCS3000", 0x2a151fac, 0x48b932ae), 760 PCMCIA_PFC_DEVICE_PROD_ID12(1, "Grey Cell", "GCS3000", 0x2a151fac, 0x48b932ae),
diff --git a/drivers/serial/serial_ks8695.c b/drivers/serial/serial_ks8695.c
index 2e71bbc04da..b1962025b1a 100644
--- a/drivers/serial/serial_ks8695.c
+++ b/drivers/serial/serial_ks8695.c
@@ -650,6 +650,7 @@ static struct console ks8695_console = {
650 650
651static int __init ks8695_console_init(void) 651static int __init ks8695_console_init(void)
652{ 652{
653 add_preferred_console(SERIAL_KS8695_DEVNAME, 0, NULL);
653 register_console(&ks8695_console); 654 register_console(&ks8695_console);
654 return 0; 655 return 0;
655} 656}
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index 980f39449ee..8eb094c1f61 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -50,7 +50,7 @@
50#include <linux/list.h> 50#include <linux/list.h>
51#include <linux/dmaengine.h> 51#include <linux/dmaengine.h>
52#include <linux/scatterlist.h> 52#include <linux/scatterlist.h>
53#include <linux/timer.h> 53#include <linux/slab.h>
54 54
55#ifdef CONFIG_SUPERH 55#ifdef CONFIG_SUPERH
56#include <asm/sh_bios.h> 56#include <asm/sh_bios.h>
@@ -780,10 +780,6 @@ static irqreturn_t sci_mpxed_interrupt(int irq, void *ptr)
780 if ((ssr_status & SCxSR_BRK(port)) && err_enabled) 780 if ((ssr_status & SCxSR_BRK(port)) && err_enabled)
781 ret = sci_br_interrupt(irq, ptr); 781 ret = sci_br_interrupt(irq, ptr);
782 782
783 WARN_ONCE(ret == IRQ_NONE,
784 "%s: %d IRQ %d, status %x, control %x\n", __func__,
785 irq, port->line, ssr_status, scr_status);
786
787 return ret; 783 return ret;
788} 784}
789 785
diff --git a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h
index fad67d33b0b..f70c49f915f 100644
--- a/drivers/serial/sh-sci.h
+++ b/drivers/serial/sh-sci.h
@@ -31,7 +31,9 @@
31# define SCSCR_INIT(port) (port->mapbase == SCIF2) ? 0xF3 : 0xF0 31# define SCSCR_INIT(port) (port->mapbase == SCIF2) ? 0xF3 : 0xF0
32#elif defined(CONFIG_CPU_SUBTYPE_SH7720) || \ 32#elif defined(CONFIG_CPU_SUBTYPE_SH7720) || \
33 defined(CONFIG_CPU_SUBTYPE_SH7721) || \ 33 defined(CONFIG_CPU_SUBTYPE_SH7721) || \
34 defined(CONFIG_ARCH_SHMOBILE) 34 defined(CONFIG_ARCH_SH7367) || \
35 defined(CONFIG_ARCH_SH7377) || \
36 defined(CONFIG_ARCH_SH7372)
35# define SCSCR_INIT(port) 0x0030 /* TIE=0,RIE=0,TE=1,RE=1 */ 37# define SCSCR_INIT(port) 0x0030 /* TIE=0,RIE=0,TE=1,RE=1 */
36# define PORT_PTCR 0xA405011EUL 38# define PORT_PTCR 0xA405011EUL
37# define PORT_PVCR 0xA4050122UL 39# define PORT_PVCR 0xA4050122UL
@@ -94,7 +96,9 @@
94# define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ 96# define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
95#elif defined(CONFIG_CPU_SUBTYPE_SH7724) 97#elif defined(CONFIG_CPU_SUBTYPE_SH7724)
96# define SCIF_ORER 0x0001 /* overrun error bit */ 98# define SCIF_ORER 0x0001 /* overrun error bit */
97# define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ 99# define SCSCR_INIT(port) ((port)->type == PORT_SCIFA ? \
100 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ : \
101 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ )
98#elif defined(CONFIG_CPU_SUBTYPE_SH4_202) 102#elif defined(CONFIG_CPU_SUBTYPE_SH4_202)
99# define SCSPTR2 0xffe80020 /* 16 bit SCIF */ 103# define SCSPTR2 0xffe80020 /* 16 bit SCIF */
100# define SCIF_ORER 0x0001 /* overrun error bit */ 104# define SCIF_ORER 0x0001 /* overrun error bit */
@@ -197,6 +201,8 @@
197 defined(CONFIG_CPU_SUBTYPE_SH7786) || \ 201 defined(CONFIG_CPU_SUBTYPE_SH7786) || \
198 defined(CONFIG_CPU_SUBTYPE_SHX3) 202 defined(CONFIG_CPU_SUBTYPE_SHX3)
199#define SCI_CTRL_FLAGS_REIE 0x08 /* 7750 SCIF */ 203#define SCI_CTRL_FLAGS_REIE 0x08 /* 7750 SCIF */
204#elif defined(CONFIG_CPU_SUBTYPE_SH7724)
205#define SCI_CTRL_FLAGS_REIE ((port)->type == PORT_SCIFA ? 0 : 8)
200#else 206#else
201#define SCI_CTRL_FLAGS_REIE 0 207#define SCI_CTRL_FLAGS_REIE 0
202#endif 208#endif
@@ -230,7 +236,9 @@
230#if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ 236#if defined(CONFIG_CPU_SUBTYPE_SH7705) || \
231 defined(CONFIG_CPU_SUBTYPE_SH7720) || \ 237 defined(CONFIG_CPU_SUBTYPE_SH7720) || \
232 defined(CONFIG_CPU_SUBTYPE_SH7721) || \ 238 defined(CONFIG_CPU_SUBTYPE_SH7721) || \
233 defined(CONFIG_ARCH_SHMOBILE) 239 defined(CONFIG_ARCH_SH7367) || \
240 defined(CONFIG_ARCH_SH7377) || \
241 defined(CONFIG_ARCH_SH7372)
234# define SCIF_ORER 0x0200 242# define SCIF_ORER 0x0200
235# define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK | SCIF_ORER) 243# define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK | SCIF_ORER)
236# define SCIF_RFDC_MASK 0x007f 244# define SCIF_RFDC_MASK 0x007f
@@ -264,7 +272,9 @@
264#if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ 272#if defined(CONFIG_CPU_SUBTYPE_SH7705) || \
265 defined(CONFIG_CPU_SUBTYPE_SH7720) || \ 273 defined(CONFIG_CPU_SUBTYPE_SH7720) || \
266 defined(CONFIG_CPU_SUBTYPE_SH7721) || \ 274 defined(CONFIG_CPU_SUBTYPE_SH7721) || \
267 defined(CONFIG_ARCH_SHMOBILE) 275 defined(CONFIG_ARCH_SH7367) || \
276 defined(CONFIG_ARCH_SH7377) || \
277 defined(CONFIG_ARCH_SH7372)
268# define SCxSR_RDxF_CLEAR(port) (sci_in(port, SCxSR) & 0xfffc) 278# define SCxSR_RDxF_CLEAR(port) (sci_in(port, SCxSR) & 0xfffc)
269# define SCxSR_ERROR_CLEAR(port) (sci_in(port, SCxSR) & 0xfd73) 279# define SCxSR_ERROR_CLEAR(port) (sci_in(port, SCxSR) & 0xfd73)
270# define SCxSR_TDxE_CLEAR(port) (sci_in(port, SCxSR) & 0xffdf) 280# define SCxSR_TDxE_CLEAR(port) (sci_in(port, SCxSR) & 0xffdf)
@@ -359,7 +369,10 @@
359 SCI_OUT(sci_size, sci_offset, value); \ 369 SCI_OUT(sci_size, sci_offset, value); \
360 } 370 }
361 371
362#if defined(CONFIG_CPU_SH3) || defined(CONFIG_ARCH_SHMOBILE) 372#if defined(CONFIG_CPU_SH3) || \
373 defined(CONFIG_ARCH_SH7367) || \
374 defined(CONFIG_ARCH_SH7377) || \
375 defined(CONFIG_ARCH_SH7372)
363#if defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712) 376#if defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712)
364#define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \ 377#define SCIx_FNS(name, sh3_sci_offset, sh3_sci_size, sh4_sci_offset, sh4_sci_size, \
365 sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \ 378 sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size, \
@@ -370,7 +383,9 @@
370#elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \ 383#elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \
371 defined(CONFIG_CPU_SUBTYPE_SH7720) || \ 384 defined(CONFIG_CPU_SUBTYPE_SH7720) || \
372 defined(CONFIG_CPU_SUBTYPE_SH7721) || \ 385 defined(CONFIG_CPU_SUBTYPE_SH7721) || \
373 defined(CONFIG_ARCH_SHMOBILE) 386 defined(CONFIG_ARCH_SH7367) || \
387 defined(CONFIG_ARCH_SH7377) || \
388 defined(CONFIG_ARCH_SH7372)
374#define SCIF_FNS(name, scif_offset, scif_size) \ 389#define SCIF_FNS(name, scif_offset, scif_size) \
375 CPU_SCIF_FNS(name, scif_offset, scif_size) 390 CPU_SCIF_FNS(name, scif_offset, scif_size)
376#else 391#else
@@ -406,7 +421,9 @@
406#if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ 421#if defined(CONFIG_CPU_SUBTYPE_SH7705) || \
407 defined(CONFIG_CPU_SUBTYPE_SH7720) || \ 422 defined(CONFIG_CPU_SUBTYPE_SH7720) || \
408 defined(CONFIG_CPU_SUBTYPE_SH7721) || \ 423 defined(CONFIG_CPU_SUBTYPE_SH7721) || \
409 defined(CONFIG_ARCH_SHMOBILE) 424 defined(CONFIG_ARCH_SH7367) || \
425 defined(CONFIG_ARCH_SH7377) || \
426 defined(CONFIG_ARCH_SH7372)
410 427
411SCIF_FNS(SCSMR, 0x00, 16) 428SCIF_FNS(SCSMR, 0x00, 16)
412SCIF_FNS(SCBRR, 0x04, 8) 429SCIF_FNS(SCBRR, 0x04, 8)
@@ -589,7 +606,9 @@ static inline int sci_rxd_in(struct uart_port *port)
589#elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \ 606#elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \
590 defined(CONFIG_CPU_SUBTYPE_SH7720) || \ 607 defined(CONFIG_CPU_SUBTYPE_SH7720) || \
591 defined(CONFIG_CPU_SUBTYPE_SH7721) || \ 608 defined(CONFIG_CPU_SUBTYPE_SH7721) || \
592 defined(CONFIG_ARCH_SHMOBILE) 609 defined(CONFIG_ARCH_SH7367) || \
610 defined(CONFIG_ARCH_SH7377) || \
611 defined(CONFIG_ARCH_SH7372)
593#define SCBRR_VALUE(bps, clk) (((clk*2)+16*bps)/(32*bps)-1) 612#define SCBRR_VALUE(bps, clk) (((clk*2)+16*bps)/(32*bps)-1)
594#elif defined(CONFIG_CPU_SUBTYPE_SH7723) ||\ 613#elif defined(CONFIG_CPU_SUBTYPE_SH7723) ||\
595 defined(CONFIG_CPU_SUBTYPE_SH7724) 614 defined(CONFIG_CPU_SUBTYPE_SH7724)
diff --git a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c
index 170d3d68c8f..01f7731e59b 100644
--- a/drivers/serial/sunsu.c
+++ b/drivers/serial/sunsu.c
@@ -29,6 +29,7 @@
29#include <linux/serial.h> 29#include <linux/serial.h>
30#include <linux/sysrq.h> 30#include <linux/sysrq.h>
31#include <linux/console.h> 31#include <linux/console.h>
32#include <linux/slab.h>
32#ifdef CONFIG_SERIO 33#ifdef CONFIG_SERIO
33#include <linux/serio.h> 34#include <linux/serio.h>
34#endif 35#endif
@@ -1453,8 +1454,10 @@ static int __devinit su_probe(struct of_device *op, const struct of_device_id *m
1453 if (up->su_type == SU_PORT_KBD || up->su_type == SU_PORT_MS) { 1454 if (up->su_type == SU_PORT_KBD || up->su_type == SU_PORT_MS) {
1454 err = sunsu_kbd_ms_init(up); 1455 err = sunsu_kbd_ms_init(up);
1455 if (err) { 1456 if (err) {
1457 of_iounmap(&op->resource[0],
1458 up->port.membase, up->reg_size);
1456 kfree(up); 1459 kfree(up);
1457 goto out_unmap; 1460 return err;
1458 } 1461 }
1459 dev_set_drvdata(&op->dev, up); 1462 dev_set_drvdata(&op->dev, up);
1460 1463
diff --git a/drivers/serial/timbuart.c b/drivers/serial/timbuart.c
index 7bf10264a6a..786ba85c170 100644
--- a/drivers/serial/timbuart.c
+++ b/drivers/serial/timbuart.c
@@ -26,6 +26,7 @@
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/platform_device.h> 27#include <linux/platform_device.h>
28#include <linux/ioport.h> 28#include <linux/ioport.h>
29#include <linux/slab.h>
29 30
30#include "timbuart.h" 31#include "timbuart.h"
31 32
diff --git a/drivers/serial/ucc_uart.c b/drivers/serial/ucc_uart.c
index 465f2fae102..074904912f6 100644
--- a/drivers/serial/ucc_uart.c
+++ b/drivers/serial/ucc_uart.c
@@ -20,6 +20,7 @@
20 20
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/serial.h> 22#include <linux/serial.h>
23#include <linux/slab.h>
23#include <linux/serial_core.h> 24#include <linux/serial_core.h>
24#include <linux/io.h> 25#include <linux/io.h>
25#include <linux/of_platform.h> 26#include <linux/of_platform.h>
diff --git a/drivers/sh/intc.c b/drivers/sh/intc.c
index c2750391fd3..94ad6bd86a0 100644
--- a/drivers/sh/intc.c
+++ b/drivers/sh/intc.c
@@ -2,7 +2,7 @@
2 * Shared interrupt handling code for IPR and INTC2 types of IRQs. 2 * Shared interrupt handling code for IPR and INTC2 types of IRQs.
3 * 3 *
4 * Copyright (C) 2007, 2008 Magnus Damm 4 * Copyright (C) 2007, 2008 Magnus Damm
5 * Copyright (C) 2009 Paul Mundt 5 * Copyright (C) 2009, 2010 Paul Mundt
6 * 6 *
7 * Based on intc2.c and ipr.c 7 * Based on intc2.c and ipr.c
8 * 8 *
@@ -20,12 +20,14 @@
20#include <linux/irq.h> 20#include <linux/irq.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/io.h> 22#include <linux/io.h>
23#include <linux/slab.h>
23#include <linux/interrupt.h> 24#include <linux/interrupt.h>
24#include <linux/sh_intc.h> 25#include <linux/sh_intc.h>
25#include <linux/sysdev.h> 26#include <linux/sysdev.h>
26#include <linux/list.h> 27#include <linux/list.h>
27#include <linux/topology.h> 28#include <linux/topology.h>
28#include <linux/bitmap.h> 29#include <linux/bitmap.h>
30#include <linux/cpumask.h>
29 31
30#define _INTC_MK(fn, mode, addr_e, addr_d, width, shift) \ 32#define _INTC_MK(fn, mode, addr_e, addr_d, width, shift) \
31 ((shift) | ((width) << 5) | ((fn) << 9) | ((mode) << 13) | \ 33 ((shift) | ((width) << 5) | ((fn) << 9) | ((mode) << 13) | \
@@ -234,6 +236,10 @@ static inline void _intc_enable(unsigned int irq, unsigned long handle)
234 unsigned int cpu; 236 unsigned int cpu;
235 237
236 for (cpu = 0; cpu < SMP_NR(d, _INTC_ADDR_E(handle)); cpu++) { 238 for (cpu = 0; cpu < SMP_NR(d, _INTC_ADDR_E(handle)); cpu++) {
239#ifdef CONFIG_SMP
240 if (!cpumask_test_cpu(cpu, irq_to_desc(irq)->affinity))
241 continue;
242#endif
237 addr = INTC_REG(d, _INTC_ADDR_E(handle), cpu); 243 addr = INTC_REG(d, _INTC_ADDR_E(handle), cpu);
238 intc_enable_fns[_INTC_MODE(handle)](addr, handle, intc_reg_fns\ 244 intc_enable_fns[_INTC_MODE(handle)](addr, handle, intc_reg_fns\
239 [_INTC_FN(handle)], irq); 245 [_INTC_FN(handle)], irq);
@@ -253,6 +259,10 @@ static void intc_disable(unsigned int irq)
253 unsigned int cpu; 259 unsigned int cpu;
254 260
255 for (cpu = 0; cpu < SMP_NR(d, _INTC_ADDR_D(handle)); cpu++) { 261 for (cpu = 0; cpu < SMP_NR(d, _INTC_ADDR_D(handle)); cpu++) {
262#ifdef CONFIG_SMP
263 if (!cpumask_test_cpu(cpu, irq_to_desc(irq)->affinity))
264 continue;
265#endif
256 addr = INTC_REG(d, _INTC_ADDR_D(handle), cpu); 266 addr = INTC_REG(d, _INTC_ADDR_D(handle), cpu);
257 intc_disable_fns[_INTC_MODE(handle)](addr, handle,intc_reg_fns\ 267 intc_disable_fns[_INTC_MODE(handle)](addr, handle,intc_reg_fns\
258 [_INTC_FN(handle)], irq); 268 [_INTC_FN(handle)], irq);
@@ -301,6 +311,23 @@ static int intc_set_wake(unsigned int irq, unsigned int on)
301 return 0; /* allow wakeup, but setup hardware in intc_suspend() */ 311 return 0; /* allow wakeup, but setup hardware in intc_suspend() */
302} 312}
303 313
314#ifdef CONFIG_SMP
315/*
316 * This is held with the irq desc lock held, so we don't require any
317 * additional locking here at the intc desc level. The affinity mask is
318 * later tested in the enable/disable paths.
319 */
320static int intc_set_affinity(unsigned int irq, const struct cpumask *cpumask)
321{
322 if (!cpumask_intersects(cpumask, cpu_online_mask))
323 return -1;
324
325 cpumask_copy(irq_to_desc(irq)->affinity, cpumask);
326
327 return 0;
328}
329#endif
330
304static void intc_mask_ack(unsigned int irq) 331static void intc_mask_ack(unsigned int irq)
305{ 332{
306 struct intc_desc_int *d = get_intc_desc(irq); 333 struct intc_desc_int *d = get_intc_desc(irq);
@@ -847,6 +874,9 @@ void __init register_intc_controller(struct intc_desc *desc)
847 d->chip.shutdown = intc_disable; 874 d->chip.shutdown = intc_disable;
848 d->chip.set_type = intc_set_sense; 875 d->chip.set_type = intc_set_sense;
849 d->chip.set_wake = intc_set_wake; 876 d->chip.set_wake = intc_set_wake;
877#ifdef CONFIG_SMP
878 d->chip.set_affinity = intc_set_affinity;
879#endif
850 880
851 if (hw->ack_regs) { 881 if (hw->ack_regs) {
852 for (i = 0; i < hw->nr_ack_regs; i++) 882 for (i = 0; i < hw->nr_ack_regs; i++)
diff --git a/drivers/sn/ioc3.c b/drivers/sn/ioc3.c
index 66802a4390c..b3b33fa26ac 100644
--- a/drivers/sn/ioc3.c
+++ b/drivers/sn/ioc3.c
@@ -16,6 +16,7 @@
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/ioc3.h> 17#include <linux/ioc3.h>
18#include <linux/rwsem.h> 18#include <linux/rwsem.h>
19#include <linux/slab.h>
19 20
20#define IOC3_PCI_SIZE 0x100000 21#define IOC3_PCI_SIZE 0x100000
21 22
diff --git a/drivers/spi/amba-pl022.c b/drivers/spi/amba-pl022.c
index 9aeb6811310..e9aeee16d92 100644
--- a/drivers/spi/amba-pl022.c
+++ b/drivers/spi/amba-pl022.c
@@ -44,6 +44,7 @@
44#include <linux/amba/bus.h> 44#include <linux/amba/bus.h>
45#include <linux/amba/pl022.h> 45#include <linux/amba/pl022.h>
46#include <linux/io.h> 46#include <linux/io.h>
47#include <linux/slab.h>
47 48
48/* 49/*
49 * This macro is used to define some register default values. 50 * This macro is used to define some register default values.
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index d21c24eaf0a..c4e04428992 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -18,6 +18,7 @@
18#include <linux/err.h> 18#include <linux/err.h>
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#include <linux/spi/spi.h> 20#include <linux/spi/spi.h>
21#include <linux/slab.h>
21 22
22#include <asm/io.h> 23#include <asm/io.h>
23#include <mach/board.h> 24#include <mach/board.h>
diff --git a/drivers/spi/au1550_spi.c b/drivers/spi/au1550_spi.c
index ba8ac4f599d..3c9ade69643 100644
--- a/drivers/spi/au1550_spi.c
+++ b/drivers/spi/au1550_spi.c
@@ -23,6 +23,7 @@
23 23
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/slab.h>
26#include <linux/errno.h> 27#include <linux/errno.h>
27#include <linux/device.h> 28#include <linux/device.h>
28#include <linux/platform_device.h> 29#include <linux/platform_device.h>
diff --git a/drivers/spi/davinci_spi.c b/drivers/spi/davinci_spi.c
index 225ab60b02c..95afb6b7739 100644
--- a/drivers/spi/davinci_spi.c
+++ b/drivers/spi/davinci_spi.c
@@ -27,6 +27,7 @@
27#include <linux/dma-mapping.h> 27#include <linux/dma-mapping.h>
28#include <linux/spi/spi.h> 28#include <linux/spi/spi.h>
29#include <linux/spi/spi_bitbang.h> 29#include <linux/spi/spi_bitbang.h>
30#include <linux/slab.h>
30 31
31#include <mach/spi.h> 32#include <mach/spi.h>
32#include <mach/edma.h> 33#include <mach/edma.h>
diff --git a/drivers/spi/dw_spi.c b/drivers/spi/dw_spi.c
index 8ed38f1d6c1..d256cb00604 100644
--- a/drivers/spi/dw_spi.c
+++ b/drivers/spi/dw_spi.c
@@ -21,6 +21,7 @@
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/highmem.h> 22#include <linux/highmem.h>
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/slab.h>
24 25
25#include <linux/spi/dw_spi.h> 26#include <linux/spi/dw_spi.h>
26#include <linux/spi/spi.h> 27#include <linux/spi/spi.h>
diff --git a/drivers/spi/dw_spi_mmio.c b/drivers/spi/dw_spi_mmio.c
index e35b45ac517..db35bd9c1b2 100644
--- a/drivers/spi/dw_spi_mmio.c
+++ b/drivers/spi/dw_spi_mmio.c
@@ -11,6 +11,7 @@
11#include <linux/clk.h> 11#include <linux/clk.h>
12#include <linux/interrupt.h> 12#include <linux/interrupt.h>
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <linux/slab.h>
14#include <linux/spi/dw_spi.h> 15#include <linux/spi/dw_spi.h>
15#include <linux/spi/spi.h> 16#include <linux/spi/spi.h>
16 17
diff --git a/drivers/spi/dw_spi_pci.c b/drivers/spi/dw_spi_pci.c
index 1f0735f9cc7..1f52755dc87 100644
--- a/drivers/spi/dw_spi_pci.c
+++ b/drivers/spi/dw_spi_pci.c
@@ -19,6 +19,7 @@
19 19
20#include <linux/interrupt.h> 20#include <linux/interrupt.h>
21#include <linux/pci.h> 21#include <linux/pci.h>
22#include <linux/slab.h>
22#include <linux/spi/dw_spi.h> 23#include <linux/spi/dw_spi.h>
23#include <linux/spi/spi.h> 24#include <linux/spi/spi.h>
24 25
diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c
index 04747868d6c..77d4cc88ede 100644
--- a/drivers/spi/mpc52xx_psc_spi.c
+++ b/drivers/spi/mpc52xx_psc_spi.c
@@ -24,6 +24,7 @@
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/spi/spi.h> 25#include <linux/spi/spi.h>
26#include <linux/fsl_devices.h> 26#include <linux/fsl_devices.h>
27#include <linux/slab.h>
27 28
28#include <asm/mpc52xx.h> 29#include <asm/mpc52xx.h>
29#include <asm/mpc52xx_psc.h> 30#include <asm/mpc52xx_psc.h>
diff --git a/drivers/spi/mpc52xx_spi.c b/drivers/spi/mpc52xx_spi.c
index 6eab46537a0..cd68f1ce5cc 100644
--- a/drivers/spi/mpc52xx_spi.c
+++ b/drivers/spi/mpc52xx_spi.c
@@ -21,6 +21,7 @@
21#include <linux/of_spi.h> 21#include <linux/of_spi.h>
22#include <linux/io.h> 22#include <linux/io.h>
23#include <linux/of_gpio.h> 23#include <linux/of_gpio.h>
24#include <linux/slab.h>
24#include <asm/time.h> 25#include <asm/time.h>
25#include <asm/mpc52xx.h> 26#include <asm/mpc52xx.h>
26 27
diff --git a/drivers/spi/omap2_mcspi.c b/drivers/spi/omap2_mcspi.c
index 4dd786b99b8..e0de0d0eede 100644
--- a/drivers/spi/omap2_mcspi.c
+++ b/drivers/spi/omap2_mcspi.c
@@ -32,6 +32,7 @@
32#include <linux/err.h> 32#include <linux/err.h>
33#include <linux/clk.h> 33#include <linux/clk.h>
34#include <linux/io.h> 34#include <linux/io.h>
35#include <linux/slab.h>
35 36
36#include <linux/spi/spi.h> 37#include <linux/spi/spi.h>
37 38
@@ -203,6 +204,7 @@ static inline void mcspi_write_chconf0(const struct spi_device *spi, u32 val)
203 204
204 cs->chconf0 = val; 205 cs->chconf0 = val;
205 mcspi_write_cs_reg(spi, OMAP2_MCSPI_CHCONF0, val); 206 mcspi_write_cs_reg(spi, OMAP2_MCSPI_CHCONF0, val);
207 mcspi_read_cs_reg(spi, OMAP2_MCSPI_CHCONF0);
206} 208}
207 209
208static void omap2_mcspi_set_dma_req(const struct spi_device *spi, 210static void omap2_mcspi_set_dma_req(const struct spi_device *spi,
@@ -531,7 +533,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
531 goto out; 533 goto out;
532 } 534 }
533#ifdef VERBOSE 535#ifdef VERBOSE
534 dev_dbg(&spi->dev, "write-%d %04x\n", 536 dev_dbg(&spi->dev, "write-%d %08x\n",
535 word_len, *tx); 537 word_len, *tx);
536#endif 538#endif
537 __raw_writel(*tx++, tx_reg); 539 __raw_writel(*tx++, tx_reg);
@@ -549,7 +551,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
549 mcspi_write_chconf0(spi, l); 551 mcspi_write_chconf0(spi, l);
550 *rx++ = __raw_readl(rx_reg); 552 *rx++ = __raw_readl(rx_reg);
551#ifdef VERBOSE 553#ifdef VERBOSE
552 dev_dbg(&spi->dev, "read-%d %04x\n", 554 dev_dbg(&spi->dev, "read-%d %08x\n",
553 word_len, *(rx - 1)); 555 word_len, *(rx - 1));
554#endif 556#endif
555 } 557 }
diff --git a/drivers/spi/omap_spi_100k.c b/drivers/spi/omap_spi_100k.c
index 5355d90d1be..24668b30a52 100644
--- a/drivers/spi/omap_spi_100k.c
+++ b/drivers/spi/omap_spi_100k.c
@@ -33,6 +33,7 @@
33#include <linux/clk.h> 33#include <linux/clk.h>
34#include <linux/io.h> 34#include <linux/io.h>
35#include <linux/gpio.h> 35#include <linux/gpio.h>
36#include <linux/slab.h>
36 37
37#include <linux/spi/spi.h> 38#include <linux/spi/spi.h>
38 39
diff --git a/drivers/spi/omap_uwire.c b/drivers/spi/omap_uwire.c
index 6c3a8557db2..160d3266205 100644
--- a/drivers/spi/omap_uwire.c
+++ b/drivers/spi/omap_uwire.c
@@ -41,6 +41,7 @@
41#include <linux/interrupt.h> 41#include <linux/interrupt.h>
42#include <linux/err.h> 42#include <linux/err.h>
43#include <linux/clk.h> 43#include <linux/clk.h>
44#include <linux/slab.h>
44 45
45#include <linux/spi/spi.h> 46#include <linux/spi/spi.h>
46#include <linux/spi/spi_bitbang.h> 47#include <linux/spi/spi_bitbang.h>
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
index c2f707e5ce7..e76b1afafe0 100644
--- a/drivers/spi/pxa2xx_spi.c
+++ b/drivers/spi/pxa2xx_spi.c
@@ -29,14 +29,14 @@
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/clk.h> 30#include <linux/clk.h>
31#include <linux/gpio.h> 31#include <linux/gpio.h>
32#include <linux/slab.h>
32 33
33#include <asm/io.h> 34#include <asm/io.h>
34#include <asm/irq.h> 35#include <asm/irq.h>
35#include <asm/delay.h> 36#include <asm/delay.h>
36 37
37#include <mach/dma.h> 38#include <mach/dma.h>
38#include <mach/regs-ssp.h> 39#include <plat/ssp.h>
39#include <mach/ssp.h>
40#include <mach/pxa2xx_spi.h> 40#include <mach/pxa2xx_spi.h>
41 41
42MODULE_AUTHOR("Stephen Street"); 42MODULE_AUTHOR("Stephen Street");
@@ -1317,14 +1317,14 @@ static int setup(struct spi_device *spi)
1317 /* NOTE: PXA25x_SSP _could_ use external clocking ... */ 1317 /* NOTE: PXA25x_SSP _could_ use external clocking ... */
1318 if (drv_data->ssp_type != PXA25x_SSP) 1318 if (drv_data->ssp_type != PXA25x_SSP)
1319 dev_dbg(&spi->dev, "%ld Hz actual, %s\n", 1319 dev_dbg(&spi->dev, "%ld Hz actual, %s\n",
1320 clk_get_rate(ssp->clk) 1320 clk_get_rate(ssp->clk)
1321 / (1 + ((chip->cr0 & SSCR0_SCR) >> 8)), 1321 / (1 + ((chip->cr0 & SSCR0_SCR(0xfff)) >> 8)),
1322 chip->enable_dma ? "DMA" : "PIO"); 1322 chip->enable_dma ? "DMA" : "PIO");
1323 else 1323 else
1324 dev_dbg(&spi->dev, "%ld Hz actual, %s\n", 1324 dev_dbg(&spi->dev, "%ld Hz actual, %s\n",
1325 clk_get_rate(ssp->clk) / 2 1325 clk_get_rate(ssp->clk) / 2
1326 / (1 + ((chip->cr0 & SSCR0_SCR) >> 8)), 1326 / (1 + ((chip->cr0 & SSCR0_SCR(0x0ff)) >> 8)),
1327 chip->enable_dma ? "DMA" : "PIO"); 1327 chip->enable_dma ? "DMA" : "PIO");
1328 1328
1329 if (spi->bits_per_word <= 8) { 1329 if (spi->bits_per_word <= 8) {
1330 chip->n_bytes = 1; 1330 chip->n_bytes = 1;
@@ -1465,7 +1465,7 @@ static int __init pxa2xx_spi_probe(struct platform_device *pdev)
1465 1465
1466 platform_info = dev->platform_data; 1466 platform_info = dev->platform_data;
1467 1467
1468 ssp = ssp_request(pdev->id, pdev->name); 1468 ssp = pxa_ssp_request(pdev->id, pdev->name);
1469 if (ssp == NULL) { 1469 if (ssp == NULL) {
1470 dev_err(&pdev->dev, "failed to request SSP%d\n", pdev->id); 1470 dev_err(&pdev->dev, "failed to request SSP%d\n", pdev->id);
1471 return -ENODEV; 1471 return -ENODEV;
@@ -1475,7 +1475,7 @@ static int __init pxa2xx_spi_probe(struct platform_device *pdev)
1475 master = spi_alloc_master(dev, sizeof(struct driver_data) + 16); 1475 master = spi_alloc_master(dev, sizeof(struct driver_data) + 16);
1476 if (!master) { 1476 if (!master) {
1477 dev_err(&pdev->dev, "cannot alloc spi_master\n"); 1477 dev_err(&pdev->dev, "cannot alloc spi_master\n");
1478 ssp_free(ssp); 1478 pxa_ssp_free(ssp);
1479 return -ENOMEM; 1479 return -ENOMEM;
1480 } 1480 }
1481 drv_data = spi_master_get_devdata(master); 1481 drv_data = spi_master_get_devdata(master);
@@ -1557,7 +1557,7 @@ static int __init pxa2xx_spi_probe(struct platform_device *pdev)
1557 write_SSCR1(SSCR1_RxTresh(RX_THRESH_DFLT) | 1557 write_SSCR1(SSCR1_RxTresh(RX_THRESH_DFLT) |
1558 SSCR1_TxTresh(TX_THRESH_DFLT), 1558 SSCR1_TxTresh(TX_THRESH_DFLT),
1559 drv_data->ioaddr); 1559 drv_data->ioaddr);
1560 write_SSCR0(SSCR0_SerClkDiv(2) 1560 write_SSCR0(SSCR0_SCR(2)
1561 | SSCR0_Motorola 1561 | SSCR0_Motorola
1562 | SSCR0_DataSize(8), 1562 | SSCR0_DataSize(8),
1563 drv_data->ioaddr); 1563 drv_data->ioaddr);
@@ -1604,7 +1604,7 @@ out_error_irq_alloc:
1604 1604
1605out_error_master_alloc: 1605out_error_master_alloc:
1606 spi_master_put(master); 1606 spi_master_put(master);
1607 ssp_free(ssp); 1607 pxa_ssp_free(ssp);
1608 return status; 1608 return status;
1609} 1609}
1610 1610
@@ -1648,7 +1648,7 @@ static int pxa2xx_spi_remove(struct platform_device *pdev)
1648 free_irq(ssp->irq, drv_data); 1648 free_irq(ssp->irq, drv_data);
1649 1649
1650 /* Release SSP */ 1650 /* Release SSP */
1651 ssp_free(ssp); 1651 pxa_ssp_free(ssp);
1652 1652
1653 /* Disconnect from the SPI framework */ 1653 /* Disconnect from the SPI framework */
1654 spi_unregister_master(drv_data->master); 1654 spi_unregister_master(drv_data->master);
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index b76f2468a84..b3a1f9259b6 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -23,6 +23,7 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/cache.h> 24#include <linux/cache.h>
25#include <linux/mutex.h> 25#include <linux/mutex.h>
26#include <linux/slab.h>
26#include <linux/mod_devicetable.h> 27#include <linux/mod_devicetable.h>
27#include <linux/spi/spi.h> 28#include <linux/spi/spi.h>
28 29
@@ -40,7 +41,7 @@ static void spidev_release(struct device *dev)
40 spi->master->cleanup(spi); 41 spi->master->cleanup(spi);
41 42
42 spi_master_put(spi->master); 43 spi_master_put(spi->master);
43 kfree(dev); 44 kfree(spi);
44} 45}
45 46
46static ssize_t 47static ssize_t
@@ -256,6 +257,7 @@ int spi_add_device(struct spi_device *spi)
256{ 257{
257 static DEFINE_MUTEX(spi_add_lock); 258 static DEFINE_MUTEX(spi_add_lock);
258 struct device *dev = spi->master->dev.parent; 259 struct device *dev = spi->master->dev.parent;
260 struct device *d;
259 int status; 261 int status;
260 262
261 /* Chipselects are numbered 0..max; validate. */ 263 /* Chipselects are numbered 0..max; validate. */
@@ -277,10 +279,11 @@ int spi_add_device(struct spi_device *spi)
277 */ 279 */
278 mutex_lock(&spi_add_lock); 280 mutex_lock(&spi_add_lock);
279 281
280 if (bus_find_device_by_name(&spi_bus_type, NULL, dev_name(&spi->dev)) 282 d = bus_find_device_by_name(&spi_bus_type, NULL, dev_name(&spi->dev));
281 != NULL) { 283 if (d != NULL) {
282 dev_err(dev, "chipselect %d already in use\n", 284 dev_err(dev, "chipselect %d already in use\n",
283 spi->chip_select); 285 spi->chip_select);
286 put_device(d);
284 status = -EBUSY; 287 status = -EBUSY;
285 goto done; 288 goto done;
286 } 289 }
diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c
index 1d41058bbab..10a6dc3d37a 100644
--- a/drivers/spi/spi_bfin5xx.c
+++ b/drivers/spi/spi_bfin5xx.c
@@ -12,6 +12,7 @@
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/delay.h> 13#include <linux/delay.h>
14#include <linux/device.h> 14#include <linux/device.h>
15#include <linux/slab.h>
15#include <linux/io.h> 16#include <linux/io.h>
16#include <linux/ioport.h> 17#include <linux/ioport.h>
17#include <linux/irq.h> 18#include <linux/irq.h>
diff --git a/drivers/spi/spi_bitbang.c b/drivers/spi/spi_bitbang.c
index f1db395dd88..5265330a528 100644
--- a/drivers/spi/spi_bitbang.c
+++ b/drivers/spi/spi_bitbang.c
@@ -23,6 +23,7 @@
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/errno.h> 24#include <linux/errno.h>
25#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26#include <linux/slab.h>
26 27
27#include <linux/spi/spi.h> 28#include <linux/spi/spi.h>
28#include <linux/spi/spi_bitbang.h> 29#include <linux/spi/spi_bitbang.h>
diff --git a/drivers/spi/spi_imx.c b/drivers/spi/spi_imx.c
index 0ddbbe45e83..7972e907747 100644
--- a/drivers/spi/spi_imx.c
+++ b/drivers/spi/spi_imx.c
@@ -30,6 +30,7 @@
30#include <linux/kernel.h> 30#include <linux/kernel.h>
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/platform_device.h> 32#include <linux/platform_device.h>
33#include <linux/slab.h>
33#include <linux/spi/spi.h> 34#include <linux/spi/spi.h>
34#include <linux/spi/spi_bitbang.h> 35#include <linux/spi/spi_bitbang.h>
35#include <linux/types.h> 36#include <linux/types.h>
diff --git a/drivers/spi/spi_mpc8xxx.c b/drivers/spi/spi_mpc8xxx.c
index 4f0cc9d457e..14d05231650 100644
--- a/drivers/spi/spi_mpc8xxx.c
+++ b/drivers/spi/spi_mpc8xxx.c
@@ -39,6 +39,7 @@
39#include <linux/gpio.h> 39#include <linux/gpio.h>
40#include <linux/of_gpio.h> 40#include <linux/of_gpio.h>
41#include <linux/of_spi.h> 41#include <linux/of_spi.h>
42#include <linux/slab.h>
42 43
43#include <sysdev/fsl_soc.h> 44#include <sysdev/fsl_soc.h>
44#include <asm/cpm.h> 45#include <asm/cpm.h>
diff --git a/drivers/spi/spi_nuc900.c b/drivers/spi/spi_nuc900.c
index b319f9bf9b9..dff63be0d0a 100644
--- a/drivers/spi/spi_nuc900.c
+++ b/drivers/spi/spi_nuc900.c
@@ -21,6 +21,7 @@
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/gpio.h> 22#include <linux/gpio.h>
23#include <linux/io.h> 23#include <linux/io.h>
24#include <linux/slab.h>
24 25
25#include <linux/spi/spi.h> 26#include <linux/spi/spi.h>
26#include <linux/spi/spi_bitbang.h> 27#include <linux/spi/spi_bitbang.h>
diff --git a/drivers/spi/spi_ppc4xx.c b/drivers/spi/spi_ppc4xx.c
index 6d8d4026a07..7cb5ff37f6e 100644
--- a/drivers/spi/spi_ppc4xx.c
+++ b/drivers/spi/spi_ppc4xx.c
@@ -26,6 +26,7 @@
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/sched.h> 28#include <linux/sched.h>
29#include <linux/slab.h>
29#include <linux/errno.h> 30#include <linux/errno.h>
30#include <linux/wait.h> 31#include <linux/wait.h>
31#include <linux/of_platform.h> 32#include <linux/of_platform.h>
diff --git a/drivers/spi/spi_s3c24xx.c b/drivers/spi/spi_s3c24xx.c
index 1fabede9e06..151a95e4065 100644
--- a/drivers/spi/spi_s3c24xx.c
+++ b/drivers/spi/spi_s3c24xx.c
@@ -21,6 +21,7 @@
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/gpio.h> 22#include <linux/gpio.h>
23#include <linux/io.h> 23#include <linux/io.h>
24#include <linux/slab.h>
24 25
25#include <linux/spi/spi.h> 26#include <linux/spi/spi.h>
26#include <linux/spi/spi_bitbang.h> 27#include <linux/spi/spi_bitbang.h>
diff --git a/drivers/spi/tle62x0.c b/drivers/spi/tle62x0.c
index bf9540f5fb9..a3938958147 100644
--- a/drivers/spi/tle62x0.c
+++ b/drivers/spi/tle62x0.c
@@ -11,6 +11,7 @@
11 11
12#include <linux/device.h> 12#include <linux/device.h>
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/slab.h>
14 15
15#include <linux/spi/spi.h> 16#include <linux/spi/spi.h>
16#include <linux/spi/tle62x0.h> 17#include <linux/spi/tle62x0.h>
diff --git a/drivers/spi/xilinx_spi_of.c b/drivers/spi/xilinx_spi_of.c
index ed34a8d419c..748d33a76d2 100644
--- a/drivers/spi/xilinx_spi_of.c
+++ b/drivers/spi/xilinx_spi_of.c
@@ -27,6 +27,7 @@
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/interrupt.h> 28#include <linux/interrupt.h>
29#include <linux/io.h> 29#include <linux/io.h>
30#include <linux/slab.h>
30 31
31#include <linux/of_platform.h> 32#include <linux/of_platform.h>
32#include <linux/of_device.h> 33#include <linux/of_device.h>
diff --git a/drivers/ssb/driver_gige.c b/drivers/ssb/driver_gige.c
index 172f90407b9..5ba92a2719a 100644
--- a/drivers/ssb/driver_gige.c
+++ b/drivers/ssb/driver_gige.c
@@ -12,6 +12,7 @@
12#include <linux/ssb/ssb_driver_gige.h> 12#include <linux/ssb/ssb_driver_gige.h>
13#include <linux/pci.h> 13#include <linux/pci.h>
14#include <linux/pci_regs.h> 14#include <linux/pci_regs.h>
15#include <linux/slab.h>
15 16
16 17
17/* 18/*
diff --git a/drivers/ssb/driver_pcicore.c b/drivers/ssb/driver_pcicore.c
index f1dcd7969a5..0e8d3522461 100644
--- a/drivers/ssb/driver_pcicore.c
+++ b/drivers/ssb/driver_pcicore.c
@@ -246,20 +246,12 @@ static struct pci_controller ssb_pcicore_controller = {
246 .pci_ops = &ssb_pcicore_pciops, 246 .pci_ops = &ssb_pcicore_pciops,
247 .io_resource = &ssb_pcicore_io_resource, 247 .io_resource = &ssb_pcicore_io_resource,
248 .mem_resource = &ssb_pcicore_mem_resource, 248 .mem_resource = &ssb_pcicore_mem_resource,
249 .mem_offset = 0x24000000,
250}; 249};
251 250
252static u32 ssb_pcicore_pcibus_iobase = 0x100;
253static u32 ssb_pcicore_pcibus_membase = SSB_PCI_DMA;
254
255/* This function is called when doing a pci_enable_device(). 251/* This function is called when doing a pci_enable_device().
256 * We must first check if the device is a device on the PCI-core bridge. */ 252 * We must first check if the device is a device on the PCI-core bridge. */
257int ssb_pcicore_plat_dev_init(struct pci_dev *d) 253int ssb_pcicore_plat_dev_init(struct pci_dev *d)
258{ 254{
259 struct resource *res;
260 int pos, size;
261 u32 *base;
262
263 if (d->bus->ops != &ssb_pcicore_pciops) { 255 if (d->bus->ops != &ssb_pcicore_pciops) {
264 /* This is not a device on the PCI-core bridge. */ 256 /* This is not a device on the PCI-core bridge. */
265 return -ENODEV; 257 return -ENODEV;
@@ -268,27 +260,6 @@ int ssb_pcicore_plat_dev_init(struct pci_dev *d)
268 ssb_printk(KERN_INFO "PCI: Fixing up device %s\n", 260 ssb_printk(KERN_INFO "PCI: Fixing up device %s\n",
269 pci_name(d)); 261 pci_name(d));
270 262
271 /* Fix up resource bases */
272 for (pos = 0; pos < 6; pos++) {
273 res = &d->resource[pos];
274 if (res->flags & IORESOURCE_IO)
275 base = &ssb_pcicore_pcibus_iobase;
276 else
277 base = &ssb_pcicore_pcibus_membase;
278 res->flags |= IORESOURCE_PCI_FIXED;
279 if (res->end) {
280 size = res->end - res->start + 1;
281 if (*base & (size - 1))
282 *base = (*base + size) & ~(size - 1);
283 res->start = *base;
284 res->end = res->start + size - 1;
285 *base += size;
286 pci_write_config_dword(d, PCI_BASE_ADDRESS_0 + (pos << 2), res->start);
287 }
288 /* Fix up PCI bridge BAR0 only */
289 if (d->bus->number == 0 && PCI_SLOT(d->devfn) == 0)
290 break;
291 }
292 /* Fix up interrupt lines */ 263 /* Fix up interrupt lines */
293 d->irq = ssb_mips_irq(extpci_core->dev) + 2; 264 d->irq = ssb_mips_irq(extpci_core->dev) + 2;
294 pci_write_config_byte(d, PCI_INTERRUPT_LINE, d->irq); 265 pci_write_config_byte(d, PCI_INTERRUPT_LINE, d->irq);
diff --git a/drivers/ssb/main.c b/drivers/ssb/main.c
index 03dfd27c4bf..80ff7d9e60d 100644
--- a/drivers/ssb/main.c
+++ b/drivers/ssb/main.c
@@ -18,6 +18,7 @@
18#include <linux/dma-mapping.h> 18#include <linux/dma-mapping.h>
19#include <linux/pci.h> 19#include <linux/pci.h>
20#include <linux/mmc/sdio_func.h> 20#include <linux/mmc/sdio_func.h>
21#include <linux/slab.h>
21 22
22#include <pcmcia/cs_types.h> 23#include <pcmcia/cs_types.h>
23#include <pcmcia/cs.h> 24#include <pcmcia/cs.h>
diff --git a/drivers/ssb/pci.c b/drivers/ssb/pci.c
index 9e50896233a..a8dbb06623c 100644
--- a/drivers/ssb/pci.c
+++ b/drivers/ssb/pci.c
@@ -17,6 +17,7 @@
17 17
18#include <linux/ssb/ssb.h> 18#include <linux/ssb/ssb.h>
19#include <linux/ssb/ssb_regs.h> 19#include <linux/ssb/ssb_regs.h>
20#include <linux/slab.h>
20#include <linux/pci.h> 21#include <linux/pci.h>
21#include <linux/delay.h> 22#include <linux/delay.h>
22 23
diff --git a/drivers/ssb/pcihost_wrapper.c b/drivers/ssb/pcihost_wrapper.c
index 26737a010c6..6536a041d90 100644
--- a/drivers/ssb/pcihost_wrapper.c
+++ b/drivers/ssb/pcihost_wrapper.c
@@ -12,6 +12,7 @@
12 */ 12 */
13 13
14#include <linux/pci.h> 14#include <linux/pci.h>
15#include <linux/slab.h>
15#include <linux/ssb/ssb.h> 16#include <linux/ssb/ssb.h>
16 17
17 18
diff --git a/drivers/ssb/sprom.c b/drivers/ssb/sprom.c
index d0e6762fec5..f2f920fef10 100644
--- a/drivers/ssb/sprom.c
+++ b/drivers/ssb/sprom.c
@@ -14,6 +14,7 @@
14#include "ssb_private.h" 14#include "ssb_private.h"
15 15
16#include <linux/ctype.h> 16#include <linux/ctype.h>
17#include <linux/slab.h>
17 18
18 19
19static const struct ssb_sprom *fallback_sprom; 20static const struct ssb_sprom *fallback_sprom;
diff --git a/drivers/staging/batman-adv/device.c b/drivers/staging/batman-adv/device.c
index e7f44215b5f..2f61500186f 100644
--- a/drivers/staging/batman-adv/device.c
+++ b/drivers/staging/batman-adv/device.c
@@ -20,6 +20,7 @@
20 */ 20 */
21 21
22#include <linux/device.h> 22#include <linux/device.h>
23#include <linux/slab.h>
23#include "main.h" 24#include "main.h"
24#include "device.h" 25#include "device.h"
25#include "send.h" 26#include "send.h"
diff --git a/drivers/staging/batman-adv/main.h b/drivers/staging/batman-adv/main.h
index deb41f5beda..2e9bb891a5d 100644
--- a/drivers/staging/batman-adv/main.h
+++ b/drivers/staging/batman-adv/main.h
@@ -109,6 +109,7 @@ extern int bat_debug_type(int type);
109#include <linux/kthread.h> /* kernel threads */ 109#include <linux/kthread.h> /* kernel threads */
110#include <linux/pkt_sched.h> /* schedule types */ 110#include <linux/pkt_sched.h> /* schedule types */
111#include <linux/workqueue.h> /* workqueue */ 111#include <linux/workqueue.h> /* workqueue */
112#include <linux/slab.h>
112#include <net/sock.h> /* struct sock */ 113#include <net/sock.h> /* struct sock */
113#include <linux/jiffies.h> 114#include <linux/jiffies.h>
114#include "types.h" 115#include "types.h"
diff --git a/drivers/staging/batman-adv/soft-interface.c b/drivers/staging/batman-adv/soft-interface.c
index c9b35d9f799..0e2307f3cb9 100644
--- a/drivers/staging/batman-adv/soft-interface.c
+++ b/drivers/staging/batman-adv/soft-interface.c
@@ -26,6 +26,7 @@
26#include "translation-table.h" 26#include "translation-table.h"
27#include "types.h" 27#include "types.h"
28#include "hash.h" 28#include "hash.h"
29#include <linux/slab.h>
29#include <linux/ethtool.h> 30#include <linux/ethtool.h>
30#include <linux/etherdevice.h> 31#include <linux/etherdevice.h>
31 32
diff --git a/drivers/staging/comedi/drivers/8255.c b/drivers/staging/comedi/drivers/8255.c
index 10f488f0e5e..2d54993ffb1 100644
--- a/drivers/staging/comedi/drivers/8255.c
+++ b/drivers/staging/comedi/drivers/8255.c
@@ -81,6 +81,7 @@ I/O port base address can be found in the output of 'lspci -v'.
81#include "../comedidev.h" 81#include "../comedidev.h"
82 82
83#include <linux/ioport.h> 83#include <linux/ioport.h>
84#include <linux/slab.h>
84 85
85#define _8255_SIZE 4 86#define _8255_SIZE 4
86 87
diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.c b/drivers/staging/comedi/drivers/addi-data/addi_common.c
index 8db5ab63e36..6625fdc8e90 100644
--- a/drivers/staging/comedi/drivers/addi-data/addi_common.c
+++ b/drivers/staging/comedi/drivers/addi-data/addi_common.c
@@ -50,7 +50,6 @@ You should also find the complete GPL in the COPYING file accompanying this sour
50#include <linux/module.h> 50#include <linux/module.h>
51#include <linux/sched.h> 51#include <linux/sched.h>
52#include <linux/mm.h> 52#include <linux/mm.h>
53#include <linux/slab.h>
54#include <linux/errno.h> 53#include <linux/errno.h>
55#include <linux/ioport.h> 54#include <linux/ioport.h>
56#include <linux/delay.h> 55#include <linux/delay.h>
@@ -58,6 +57,7 @@ You should also find the complete GPL in the COPYING file accompanying this sour
58#include <linux/timex.h> 57#include <linux/timex.h>
59#include <linux/timer.h> 58#include <linux/timer.h>
60#include <linux/pci.h> 59#include <linux/pci.h>
60#include <linux/gfp.h>
61#include "../../comedidev.h" 61#include "../../comedidev.h"
62#include <asm/io.h> 62#include <asm/io.h>
63#if defined(CONFIG_APCI_1710) || defined(CONFIG_APCI_3200) || defined(CONFIG_APCI_3300) 63#if defined(CONFIG_APCI_1710) || defined(CONFIG_APCI_3200) || defined(CONFIG_APCI_3300)
diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c
index 9934a3cf254..944f20ae5a6 100644
--- a/drivers/staging/comedi/drivers/adl_pci9118.c
+++ b/drivers/staging/comedi/drivers/adl_pci9118.c
@@ -66,6 +66,7 @@ Configuration options:
66#include "../pci_ids.h" 66#include "../pci_ids.h"
67 67
68#include <linux/delay.h> 68#include <linux/delay.h>
69#include <linux/gfp.h>
69#include <linux/interrupt.h> 70#include <linux/interrupt.h>
70 71
71#include "amcc_s5933.h" 72#include "amcc_s5933.h"
diff --git a/drivers/staging/comedi/drivers/amplc_dio200.c b/drivers/staging/comedi/drivers/amplc_dio200.c
index 204f30ef6e9..92bcc205dd4 100644
--- a/drivers/staging/comedi/drivers/amplc_dio200.c
+++ b/drivers/staging/comedi/drivers/amplc_dio200.c
@@ -206,6 +206,7 @@ order they appear in the channel list.
206*/ 206*/
207 207
208#include <linux/interrupt.h> 208#include <linux/interrupt.h>
209#include <linux/slab.h>
209 210
210#include "../comedidev.h" 211#include "../comedidev.h"
211 212
diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c
index b41e5e5963a..c54cca8b256 100644
--- a/drivers/staging/comedi/drivers/amplc_pci224.c
+++ b/drivers/staging/comedi/drivers/amplc_pci224.c
@@ -104,6 +104,7 @@ Caveats:
104*/ 104*/
105 105
106#include <linux/interrupt.h> 106#include <linux/interrupt.h>
107#include <linux/slab.h>
107 108
108#include "../comedidev.h" 109#include "../comedidev.h"
109 110
diff --git a/drivers/staging/comedi/drivers/cb_das16_cs.c b/drivers/staging/comedi/drivers/cb_das16_cs.c
index bc375e73abc..5632991760a 100644
--- a/drivers/staging/comedi/drivers/cb_das16_cs.c
+++ b/drivers/staging/comedi/drivers/cb_das16_cs.c
@@ -32,6 +32,7 @@ Status: experimental
32*/ 32*/
33 33
34#include <linux/interrupt.h> 34#include <linux/interrupt.h>
35#include <linux/slab.h>
35#include "../comedidev.h" 36#include "../comedidev.h"
36#include <linux/delay.h> 37#include <linux/delay.h>
37#include <linux/pci.h> 38#include <linux/pci.h>
diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c
index d7260cc8698..41311d99473 100644
--- a/drivers/staging/comedi/drivers/comedi_bond.c
+++ b/drivers/staging/comedi/drivers/comedi_bond.c
@@ -90,6 +90,7 @@ Configuration Options:
90#include "../comedilib.h" 90#include "../comedilib.h"
91#include "../comedidev.h" 91#include "../comedidev.h"
92#include <linux/string.h> 92#include <linux/string.h>
93#include <linux/slab.h>
93 94
94/* The maxiumum number of channels per subdevice. */ 95/* The maxiumum number of channels per subdevice. */
95#define MAX_CHANS 256 96#define MAX_CHANS 256
diff --git a/drivers/staging/comedi/drivers/das08_cs.c b/drivers/staging/comedi/drivers/das08_cs.c
index f12ef1cd6f5..9164ce158dc 100644
--- a/drivers/staging/comedi/drivers/das08_cs.c
+++ b/drivers/staging/comedi/drivers/das08_cs.c
@@ -43,6 +43,7 @@ Command support does not exist, but could be added for this board.
43 43
44#include <linux/delay.h> 44#include <linux/delay.h>
45#include <linux/pci.h> 45#include <linux/pci.h>
46#include <linux/slab.h>
46 47
47#include "das08.h" 48#include "das08.h"
48 49
diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c
index 10a87e6a809..f2aadda9b24 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -79,6 +79,7 @@ Computer boards manuals also available from their website www.measurementcomputi
79*/ 79*/
80 80
81#include <linux/pci.h> 81#include <linux/pci.h>
82#include <linux/slab.h>
82#include <linux/interrupt.h> 83#include <linux/interrupt.h>
83#include <asm/dma.h> 84#include <asm/dma.h>
84#include "../comedidev.h" 85#include "../comedidev.h"
diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c
index 6ea59cc6b2b..3c3e0455c7c 100644
--- a/drivers/staging/comedi/drivers/das1800.c
+++ b/drivers/staging/comedi/drivers/das1800.c
@@ -101,6 +101,7 @@ TODO:
101*/ 101*/
102 102
103#include <linux/interrupt.h> 103#include <linux/interrupt.h>
104#include <linux/slab.h>
104#include "../comedidev.h" 105#include "../comedidev.h"
105 106
106#include <linux/ioport.h> 107#include <linux/ioport.h>
diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c
index 99ca294b1ec..e548763cf2f 100644
--- a/drivers/staging/comedi/drivers/dt282x.c
+++ b/drivers/staging/comedi/drivers/dt282x.c
@@ -58,6 +58,7 @@ Notes:
58 58
59#include "../comedidev.h" 59#include "../comedidev.h"
60 60
61#include <linux/gfp.h>
61#include <linux/ioport.h> 62#include <linux/ioport.h>
62#include <linux/interrupt.h> 63#include <linux/interrupt.h>
63#include <asm/dma.h> 64#include <asm/dma.h>
diff --git a/drivers/staging/comedi/drivers/jr3_pci.c b/drivers/staging/comedi/drivers/jr3_pci.c
index fe5b4953f7e..d330b188684 100644
--- a/drivers/staging/comedi/drivers/jr3_pci.c
+++ b/drivers/staging/comedi/drivers/jr3_pci.c
@@ -46,6 +46,7 @@ Devices: [JR3] PCI force sensor board (jr3_pci)
46#include <linux/ctype.h> 46#include <linux/ctype.h>
47#include <linux/firmware.h> 47#include <linux/firmware.h>
48#include <linux/jiffies.h> 48#include <linux/jiffies.h>
49#include <linux/slab.h>
49#include <linux/timer.h> 50#include <linux/timer.h>
50#include "comedi_pci.h" 51#include "comedi_pci.h"
51#include "jr3_pci.h" 52#include "jr3_pci.h"
diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/staging/comedi/drivers/ni_65xx.c
index c223f76031f..9a4fffe5655 100644
--- a/drivers/staging/comedi/drivers/ni_65xx.c
+++ b/drivers/staging/comedi/drivers/ni_65xx.c
@@ -52,6 +52,7 @@ except maybe the 6514.
52#define DEBUG 1 52#define DEBUG 1
53#define DEBUG_FLAGS 53#define DEBUG_FLAGS
54#include <linux/interrupt.h> 54#include <linux/interrupt.h>
55#include <linux/slab.h>
55#include "../comedidev.h" 56#include "../comedidev.h"
56 57
57#include "mite.h" 58#include "mite.h"
diff --git a/drivers/staging/comedi/drivers/ni_670x.c b/drivers/staging/comedi/drivers/ni_670x.c
index 1e792d592f7..68221bfba5d 100644
--- a/drivers/staging/comedi/drivers/ni_670x.c
+++ b/drivers/staging/comedi/drivers/ni_670x.c
@@ -42,6 +42,7 @@ Commands are not supported.
42*/ 42*/
43 43
44#include <linux/interrupt.h> 44#include <linux/interrupt.h>
45#include <linux/slab.h>
45#include "../comedidev.h" 46#include "../comedidev.h"
46 47
47#include "mite.h" 48#include "mite.h"
diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c b/drivers/staging/comedi/drivers/ni_at_a2150.c
index dd75dfb3430..9bff34cf06d 100644
--- a/drivers/staging/comedi/drivers/ni_at_a2150.c
+++ b/drivers/staging/comedi/drivers/ni_at_a2150.c
@@ -65,6 +65,7 @@ TRIG_WAKE_EOS
65*/ 65*/
66 66
67#include <linux/interrupt.h> 67#include <linux/interrupt.h>
68#include <linux/slab.h>
68#include "../comedidev.h" 69#include "../comedidev.h"
69 70
70#include <linux/ioport.h> 71#include <linux/ioport.h>
diff --git a/drivers/staging/comedi/drivers/ni_daq_700.c b/drivers/staging/comedi/drivers/ni_daq_700.c
index c9b0395a610..7ea64538e05 100644
--- a/drivers/staging/comedi/drivers/ni_daq_700.c
+++ b/drivers/staging/comedi/drivers/ni_daq_700.c
@@ -42,6 +42,7 @@ IRQ is assigned but not used.
42*/ 42*/
43 43
44#include <linux/interrupt.h> 44#include <linux/interrupt.h>
45#include <linux/slab.h>
45#include "../comedidev.h" 46#include "../comedidev.h"
46 47
47#include <linux/ioport.h> 48#include <linux/ioport.h>
diff --git a/drivers/staging/comedi/drivers/ni_daq_dio24.c b/drivers/staging/comedi/drivers/ni_daq_dio24.c
index 9017be3a92f..ddc312b5d20 100644
--- a/drivers/staging/comedi/drivers/ni_daq_dio24.c
+++ b/drivers/staging/comedi/drivers/ni_daq_dio24.c
@@ -41,6 +41,7 @@ the PCMCIA interface.
41#undef LABPC_DEBUG 41#undef LABPC_DEBUG
42 42
43#include <linux/interrupt.h> 43#include <linux/interrupt.h>
44#include <linux/slab.h>
44#include "../comedidev.h" 45#include "../comedidev.h"
45 46
46#include <linux/ioport.h> 47#include <linux/ioport.h>
diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c
index 3c88caaa9da..558e525fed3 100644
--- a/drivers/staging/comedi/drivers/ni_labpc.c
+++ b/drivers/staging/comedi/drivers/ni_labpc.c
@@ -77,6 +77,7 @@ NI manuals:
77/* #define LABPC_DEBUG enable debugging messages */ 77/* #define LABPC_DEBUG enable debugging messages */
78 78
79#include <linux/interrupt.h> 79#include <linux/interrupt.h>
80#include <linux/slab.h>
80#include "../comedidev.h" 81#include "../comedidev.h"
81 82
82#include <linux/delay.h> 83#include <linux/delay.h>
diff --git a/drivers/staging/comedi/drivers/ni_labpc_cs.c b/drivers/staging/comedi/drivers/ni_labpc_cs.c
index 0b963bb3328..8ad1055a5cc 100644
--- a/drivers/staging/comedi/drivers/ni_labpc_cs.c
+++ b/drivers/staging/comedi/drivers/ni_labpc_cs.c
@@ -64,6 +64,7 @@ NI manuals:
64#include "../comedidev.h" 64#include "../comedidev.h"
65 65
66#include <linux/delay.h> 66#include <linux/delay.h>
67#include <linux/slab.h>
67 68
68#include "8253.h" 69#include "8253.h"
69#include "8255.h" 70#include "8255.h"
diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c
index d4634c4f02d..1ddc19c705a 100644
--- a/drivers/staging/comedi/drivers/pcl812.c
+++ b/drivers/staging/comedi/drivers/pcl812.c
@@ -108,6 +108,7 @@ Options for ACL-8113, ISO-813:
108*/ 108*/
109 109
110#include <linux/interrupt.h> 110#include <linux/interrupt.h>
111#include <linux/gfp.h>
111#include "../comedidev.h" 112#include "../comedidev.h"
112 113
113#include <linux/delay.h> 114#include <linux/delay.h>
diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c
index 9820759ec54..71c2a3aa379 100644
--- a/drivers/staging/comedi/drivers/pcl816.c
+++ b/drivers/staging/comedi/drivers/pcl816.c
@@ -36,6 +36,7 @@ Configuration Options:
36 36
37#include <linux/ioport.h> 37#include <linux/ioport.h>
38#include <linux/mc146818rtc.h> 38#include <linux/mc146818rtc.h>
39#include <linux/gfp.h>
39#include <linux/delay.h> 40#include <linux/delay.h>
40#include <asm/dma.h> 41#include <asm/dma.h>
41 42
diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c
index c9d75385755..9d6aa393ef1 100644
--- a/drivers/staging/comedi/drivers/pcl818.c
+++ b/drivers/staging/comedi/drivers/pcl818.c
@@ -102,6 +102,7 @@ A word or two about DMA. Driver support DMA operations at two ways:
102 102
103#include <linux/ioport.h> 103#include <linux/ioport.h>
104#include <linux/mc146818rtc.h> 104#include <linux/mc146818rtc.h>
105#include <linux/gfp.h>
105#include <linux/delay.h> 106#include <linux/delay.h>
106#include <asm/dma.h> 107#include <asm/dma.h>
107 108
diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c
index 6ca4105610c..025a52e8981 100644
--- a/drivers/staging/comedi/drivers/pcmmio.c
+++ b/drivers/staging/comedi/drivers/pcmmio.c
@@ -77,6 +77,7 @@ Configuration Options:
77*/ 77*/
78 78
79#include <linux/interrupt.h> 79#include <linux/interrupt.h>
80#include <linux/slab.h>
80#include "../comedidev.h" 81#include "../comedidev.h"
81#include "pcm_common.h" 82#include "pcm_common.h"
82#include <linux/pci.h> /* for PCI devices */ 83#include <linux/pci.h> /* for PCI devices */
diff --git a/drivers/staging/comedi/drivers/pcmuio.c b/drivers/staging/comedi/drivers/pcmuio.c
index c1ae20ffb37..5af4c8448a3 100644
--- a/drivers/staging/comedi/drivers/pcmuio.c
+++ b/drivers/staging/comedi/drivers/pcmuio.c
@@ -76,6 +76,7 @@ Configuration Options:
76*/ 76*/
77 77
78#include <linux/interrupt.h> 78#include <linux/interrupt.h>
79#include <linux/slab.h>
79#include "../comedidev.h" 80#include "../comedidev.h"
80#include "pcm_common.h" 81#include "pcm_common.h"
81 82
diff --git a/drivers/staging/comedi/drivers/serial2002.c b/drivers/staging/comedi/drivers/serial2002.c
index dd2b9037279..0792617ebc3 100644
--- a/drivers/staging/comedi/drivers/serial2002.c
+++ b/drivers/staging/comedi/drivers/serial2002.c
@@ -36,6 +36,7 @@ Status: in development
36#include <linux/delay.h> 36#include <linux/delay.h>
37#include <linux/ioport.h> 37#include <linux/ioport.h>
38#include <linux/sched.h> 38#include <linux/sched.h>
39#include <linux/slab.h>
39 40
40#include <asm/termios.h> 41#include <asm/termios.h>
41#include <asm/ioctls.h> 42#include <asm/ioctls.h>
diff --git a/drivers/staging/comedi/drivers/unioxx5.c b/drivers/staging/comedi/drivers/unioxx5.c
index 75a9a62e1a7..be1d83df0de 100644
--- a/drivers/staging/comedi/drivers/unioxx5.c
+++ b/drivers/staging/comedi/drivers/unioxx5.c
@@ -44,6 +44,7 @@ Devices: [Fastwel] UNIOxx-5 (unioxx5),
44 44
45#include "../comedidev.h" 45#include "../comedidev.h"
46#include <linux/ioport.h> 46#include <linux/ioport.h>
47#include <linux/slab.h>
47 48
48#define DRIVER_NAME "unioxx5" 49#define DRIVER_NAME "unioxx5"
49#define UNIOXX5_SIZE 0x10 50#define UNIOXX5_SIZE 0x10
diff --git a/drivers/staging/comedi/kcomedilib/kcomedilib_main.c b/drivers/staging/comedi/kcomedilib/kcomedilib_main.c
index 6552ef6d829..288fef4fcbc 100644
--- a/drivers/staging/comedi/kcomedilib/kcomedilib_main.c
+++ b/drivers/staging/comedi/kcomedilib/kcomedilib_main.c
@@ -31,7 +31,6 @@
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/ioport.h> 32#include <linux/ioport.h>
33#include <linux/mm.h> 33#include <linux/mm.h>
34#include <linux/slab.h>
35#include <asm/io.h> 34#include <asm/io.h>
36 35
37#include "../comedi.h" 36#include "../comedi.h"
diff --git a/drivers/staging/comedi/kcomedilib/ksyms.c b/drivers/staging/comedi/kcomedilib/ksyms.c
index 19293d1f998..8bf4471ce6c 100644
--- a/drivers/staging/comedi/kcomedilib/ksyms.c
+++ b/drivers/staging/comedi/kcomedilib/ksyms.c
@@ -34,7 +34,6 @@
34#include <linux/delay.h> 34#include <linux/delay.h>
35#include <linux/ioport.h> 35#include <linux/ioport.h>
36#include <linux/mm.h> 36#include <linux/mm.h>
37#include <linux/slab.h>
38 37
39/* functions specific to kcomedilib */ 38/* functions specific to kcomedilib */
40 39
diff --git a/drivers/staging/crystalhd/crystalhd_hw.c b/drivers/staging/crystalhd/crystalhd_hw.c
index 01819d34201..c438c489aa9 100644
--- a/drivers/staging/crystalhd/crystalhd_hw.c
+++ b/drivers/staging/crystalhd/crystalhd_hw.c
@@ -23,6 +23,7 @@
23 **********************************************************************/ 23 **********************************************************************/
24 24
25#include <linux/pci.h> 25#include <linux/pci.h>
26#include <linux/slab.h>
26#include <linux/delay.h> 27#include <linux/delay.h>
27#include "crystalhd_hw.h" 28#include "crystalhd_hw.h"
28 29
diff --git a/drivers/staging/crystalhd/crystalhd_lnx.c b/drivers/staging/crystalhd/crystalhd_lnx.c
index 3eac70aa213..54bad652c0c 100644
--- a/drivers/staging/crystalhd/crystalhd_lnx.c
+++ b/drivers/staging/crystalhd/crystalhd_lnx.c
@@ -16,6 +16,7 @@
16***************************************************************************/ 16***************************************************************************/
17 17
18#include <linux/version.h> 18#include <linux/version.h>
19#include <linux/slab.h>
19 20
20#include "crystalhd_lnx.h" 21#include "crystalhd_lnx.h"
21 22
diff --git a/drivers/staging/crystalhd/crystalhd_misc.c b/drivers/staging/crystalhd/crystalhd_misc.c
index 587dcc47786..73593b078b3 100644
--- a/drivers/staging/crystalhd/crystalhd_misc.c
+++ b/drivers/staging/crystalhd/crystalhd_misc.c
@@ -24,6 +24,8 @@
24 * along with this driver. If not, see <http://www.gnu.org/licenses/>. 24 * along with this driver. If not, see <http://www.gnu.org/licenses/>.
25 **********************************************************************/ 25 **********************************************************************/
26 26
27#include <linux/slab.h>
28
27#include "crystalhd_misc.h" 29#include "crystalhd_misc.h"
28#include "crystalhd_lnx.h" 30#include "crystalhd_lnx.h"
29 31
diff --git a/drivers/staging/cx25821/cx25821-alsa.c b/drivers/staging/cx25821/cx25821-alsa.c
index e0eef12759e..061add30ba8 100644
--- a/drivers/staging/cx25821/cx25821-alsa.c
+++ b/drivers/staging/cx25821/cx25821-alsa.c
@@ -27,6 +27,7 @@
27#include <linux/vmalloc.h> 27#include <linux/vmalloc.h>
28#include <linux/dma-mapping.h> 28#include <linux/dma-mapping.h>
29#include <linux/pci.h> 29#include <linux/pci.h>
30#include <linux/slab.h>
30 31
31#include <asm/delay.h> 32#include <asm/delay.h>
32#include <sound/core.h> 33#include <sound/core.h>
diff --git a/drivers/staging/cx25821/cx25821-audio-upstream.c b/drivers/staging/cx25821/cx25821-audio-upstream.c
index ddddf651266..11c56bdb0ce 100644
--- a/drivers/staging/cx25821/cx25821-audio-upstream.c
+++ b/drivers/staging/cx25821/cx25821-audio-upstream.c
@@ -32,6 +32,7 @@
32#include <linux/file.h> 32#include <linux/file.h>
33#include <linux/fcntl.h> 33#include <linux/fcntl.h>
34#include <linux/delay.h> 34#include <linux/delay.h>
35#include <linux/slab.h>
35#include <asm/uaccess.h> 36#include <asm/uaccess.h>
36 37
37MODULE_DESCRIPTION("v4l2 driver module for cx25821 based TV cards"); 38MODULE_DESCRIPTION("v4l2 driver module for cx25821 based TV cards");
diff --git a/drivers/staging/cx25821/cx25821-audups11.c b/drivers/staging/cx25821/cx25821-audups11.c
index 46c7f78bb97..e76451c309f 100644
--- a/drivers/staging/cx25821/cx25821-audups11.c
+++ b/drivers/staging/cx25821/cx25821-audups11.c
@@ -21,6 +21,8 @@
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 22 */
23 23
24#include <linux/slab.h>
25
24#include "cx25821-video.h" 26#include "cx25821-video.h"
25 27
26static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) 28static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
diff --git a/drivers/staging/cx25821/cx25821-core.c b/drivers/staging/cx25821/cx25821-core.c
index 67f689de4da..9e9b8c3c931 100644
--- a/drivers/staging/cx25821/cx25821-core.c
+++ b/drivers/staging/cx25821/cx25821-core.c
@@ -22,6 +22,7 @@
22 */ 22 */
23 23
24#include <linux/i2c.h> 24#include <linux/i2c.h>
25#include <linux/slab.h>
25#include "cx25821.h" 26#include "cx25821.h"
26#include "cx25821-sram.h" 27#include "cx25821-sram.h"
27#include "cx25821-video.h" 28#include "cx25821-video.h"
diff --git a/drivers/staging/cx25821/cx25821-video-upstream-ch2.c b/drivers/staging/cx25821/cx25821-video-upstream-ch2.c
index c8905e0ac50..cc51618cffa 100644
--- a/drivers/staging/cx25821/cx25821-video-upstream-ch2.c
+++ b/drivers/staging/cx25821/cx25821-video-upstream-ch2.c
@@ -31,6 +31,7 @@
31#include <linux/syscalls.h> 31#include <linux/syscalls.h>
32#include <linux/file.h> 32#include <linux/file.h>
33#include <linux/fcntl.h> 33#include <linux/fcntl.h>
34#include <linux/slab.h>
34#include <asm/uaccess.h> 35#include <asm/uaccess.h>
35 36
36MODULE_DESCRIPTION("v4l2 driver module for cx25821 based TV cards"); 37MODULE_DESCRIPTION("v4l2 driver module for cx25821 based TV cards");
diff --git a/drivers/staging/cx25821/cx25821-video-upstream.c b/drivers/staging/cx25821/cx25821-video-upstream.c
index 3d7dd3f6654..6d48a1e26d1 100644
--- a/drivers/staging/cx25821/cx25821-video-upstream.c
+++ b/drivers/staging/cx25821/cx25821-video-upstream.c
@@ -31,6 +31,7 @@
31#include <linux/syscalls.h> 31#include <linux/syscalls.h>
32#include <linux/file.h> 32#include <linux/file.h>
33#include <linux/fcntl.h> 33#include <linux/fcntl.h>
34#include <linux/slab.h>
34#include <asm/uaccess.h> 35#include <asm/uaccess.h>
35 36
36MODULE_DESCRIPTION("v4l2 driver module for cx25821 based TV cards"); 37MODULE_DESCRIPTION("v4l2 driver module for cx25821 based TV cards");
diff --git a/drivers/staging/dream/camera/msm_camera.c b/drivers/staging/dream/camera/msm_camera.c
index dc7c603625c..81bd71fd816 100644
--- a/drivers/staging/dream/camera/msm_camera.c
+++ b/drivers/staging/dream/camera/msm_camera.c
@@ -12,6 +12,7 @@
12 12
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/slab.h>
15#include <linux/init.h> 16#include <linux/init.h>
16#include <linux/sched.h> 17#include <linux/sched.h>
17#include <mach/board.h> 18#include <mach/board.h>
diff --git a/drivers/staging/dream/camera/msm_v4l2.c b/drivers/staging/dream/camera/msm_v4l2.c
index 6a7d46cf11e..c276f2f7583 100644
--- a/drivers/staging/dream/camera/msm_v4l2.c
+++ b/drivers/staging/dream/camera/msm_v4l2.c
@@ -12,6 +12,7 @@
12#include <linux/spinlock.h> 12#include <linux/spinlock.h>
13#include <linux/videodev2.h> 13#include <linux/videodev2.h>
14#include <linux/proc_fs.h> 14#include <linux/proc_fs.h>
15#include <linux/slab.h>
15#include <media/v4l2-dev.h> 16#include <media/v4l2-dev.h>
16#include <media/msm_camera.h> 17#include <media/msm_camera.h>
17#include <mach/camera.h> 18#include <mach/camera.h>
diff --git a/drivers/staging/dream/camera/msm_vfe7x.c b/drivers/staging/dream/camera/msm_vfe7x.c
index 62fd24d632d..198656ac3de 100644
--- a/drivers/staging/dream/camera/msm_vfe7x.c
+++ b/drivers/staging/dream/camera/msm_vfe7x.c
@@ -7,6 +7,7 @@
7#include <linux/fs.h> 7#include <linux/fs.h>
8#include <linux/sched.h> 8#include <linux/sched.h>
9#include <linux/android_pmem.h> 9#include <linux/android_pmem.h>
10#include <linux/slab.h>
10#include <mach/msm_adsp.h> 11#include <mach/msm_adsp.h>
11#include <linux/delay.h> 12#include <linux/delay.h>
12#include <linux/wait.h> 13#include <linux/wait.h>
diff --git a/drivers/staging/dream/camera/msm_vfe8x.c b/drivers/staging/dream/camera/msm_vfe8x.c
index 03de6ec2eb4..e61fdba6283 100644
--- a/drivers/staging/dream/camera/msm_vfe8x.c
+++ b/drivers/staging/dream/camera/msm_vfe8x.c
@@ -1,6 +1,7 @@
1/* 1/*
2 * Copyright (C) 2008-2009 QUALCOMM Incorporated. 2 * Copyright (C) 2008-2009 QUALCOMM Incorporated.
3 */ 3 */
4#include <linux/slab.h>
4#include <linux/uaccess.h> 5#include <linux/uaccess.h>
5#include <linux/interrupt.h> 6#include <linux/interrupt.h>
6#include <mach/irqs.h> 7#include <mach/irqs.h>
diff --git a/drivers/staging/dream/camera/mt9d112.c b/drivers/staging/dream/camera/mt9d112.c
index 4f938f9dfc4..e6f2d512461 100644
--- a/drivers/staging/dream/camera/mt9d112.c
+++ b/drivers/staging/dream/camera/mt9d112.c
@@ -3,6 +3,7 @@
3 */ 3 */
4 4
5#include <linux/delay.h> 5#include <linux/delay.h>
6#include <linux/slab.h>
6#include <linux/types.h> 7#include <linux/types.h>
7#include <linux/i2c.h> 8#include <linux/i2c.h>
8#include <linux/uaccess.h> 9#include <linux/uaccess.h>
diff --git a/drivers/staging/dream/camera/mt9p012_fox.c b/drivers/staging/dream/camera/mt9p012_fox.c
index 70119d5e0ab..791bd6c4061 100644
--- a/drivers/staging/dream/camera/mt9p012_fox.c
+++ b/drivers/staging/dream/camera/mt9p012_fox.c
@@ -4,6 +4,7 @@
4 4
5#include <linux/delay.h> 5#include <linux/delay.h>
6#include <linux/types.h> 6#include <linux/types.h>
7#include <linux/slab.h>
7#include <linux/i2c.h> 8#include <linux/i2c.h>
8#include <linux/uaccess.h> 9#include <linux/uaccess.h>
9#include <linux/miscdevice.h> 10#include <linux/miscdevice.h>
diff --git a/drivers/staging/dream/camera/mt9t013.c b/drivers/staging/dream/camera/mt9t013.c
index 88229f2663b..8fd7727ba23 100644
--- a/drivers/staging/dream/camera/mt9t013.c
+++ b/drivers/staging/dream/camera/mt9t013.c
@@ -4,6 +4,7 @@
4 4
5#include <linux/delay.h> 5#include <linux/delay.h>
6#include <linux/types.h> 6#include <linux/types.h>
7#include <linux/slab.h>
7#include <linux/i2c.h> 8#include <linux/i2c.h>
8#include <linux/uaccess.h> 9#include <linux/uaccess.h>
9#include <linux/miscdevice.h> 10#include <linux/miscdevice.h>
diff --git a/drivers/staging/dream/camera/s5k3e2fx.c b/drivers/staging/dream/camera/s5k3e2fx.c
index 841792e2624..1459903a339 100644
--- a/drivers/staging/dream/camera/s5k3e2fx.c
+++ b/drivers/staging/dream/camera/s5k3e2fx.c
@@ -3,6 +3,7 @@
3 */ 3 */
4 4
5#include <linux/delay.h> 5#include <linux/delay.h>
6#include <linux/slab.h>
6#include <linux/types.h> 7#include <linux/types.h>
7#include <linux/i2c.h> 8#include <linux/i2c.h>
8#include <linux/uaccess.h> 9#include <linux/uaccess.h>
diff --git a/drivers/staging/dream/gpio_axis.c b/drivers/staging/dream/gpio_axis.c
index c801172aa9e..eb54724b1d3 100644
--- a/drivers/staging/dream/gpio_axis.c
+++ b/drivers/staging/dream/gpio_axis.c
@@ -14,6 +14,7 @@
14 */ 14 */
15 15
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/slab.h>
17#include <linux/gpio.h> 18#include <linux/gpio.h>
18#include <linux/gpio_event.h> 19#include <linux/gpio_event.h>
19#include <linux/interrupt.h> 20#include <linux/interrupt.h>
diff --git a/drivers/staging/dream/gpio_event.c b/drivers/staging/dream/gpio_event.c
index e60e2c0db9c..97a511d11f4 100644
--- a/drivers/staging/dream/gpio_event.c
+++ b/drivers/staging/dream/gpio_event.c
@@ -14,6 +14,7 @@
14 */ 14 */
15 15
16 16
17#include <linux/slab.h>
17#include <linux/module.h> 18#include <linux/module.h>
18#include <linux/input.h> 19#include <linux/input.h>
19#include <linux/gpio_event.h> 20#include <linux/gpio_event.h>
diff --git a/drivers/staging/dream/gpio_input.c b/drivers/staging/dream/gpio_input.c
index 0638ec43601..ca29e5eb070 100644
--- a/drivers/staging/dream/gpio_input.c
+++ b/drivers/staging/dream/gpio_input.c
@@ -19,6 +19,7 @@
19#include <linux/hrtimer.h> 19#include <linux/hrtimer.h>
20#include <linux/input.h> 20#include <linux/input.h>
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/slab.h>
22 23
23enum { 24enum {
24 DEBOUNCE_UNSTABLE = BIT(0), /* Got irq, while debouncing */ 25 DEBOUNCE_UNSTABLE = BIT(0), /* Got irq, while debouncing */
diff --git a/drivers/staging/dream/gpio_matrix.c b/drivers/staging/dream/gpio_matrix.c
index 796de4faf85..b377ee1f5a5 100644
--- a/drivers/staging/dream/gpio_matrix.c
+++ b/drivers/staging/dream/gpio_matrix.c
@@ -14,6 +14,7 @@
14 */ 14 */
15 15
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/slab.h>
17#include <linux/gpio.h> 18#include <linux/gpio.h>
18#include <linux/gpio_event.h> 19#include <linux/gpio_event.h>
19#include <linux/hrtimer.h> 20#include <linux/hrtimer.h>
diff --git a/drivers/staging/dream/pmem.c b/drivers/staging/dream/pmem.c
index 503ba212dc9..6edfdd4ef80 100644
--- a/drivers/staging/dream/pmem.c
+++ b/drivers/staging/dream/pmem.c
@@ -23,6 +23,7 @@
23#include <linux/android_pmem.h> 23#include <linux/android_pmem.h>
24#include <linux/mempolicy.h> 24#include <linux/mempolicy.h>
25#include <linux/sched.h> 25#include <linux/sched.h>
26#include <linux/slab.h>
26#include <asm/io.h> 27#include <asm/io.h>
27#include <asm/uaccess.h> 28#include <asm/uaccess.h>
28#include <asm/cacheflush.h> 29#include <asm/cacheflush.h>
diff --git a/drivers/staging/dream/qdsp5/adsp.c b/drivers/staging/dream/qdsp5/adsp.c
index 9069535fcaf..f1e9d81674e 100644
--- a/drivers/staging/dream/qdsp5/adsp.c
+++ b/drivers/staging/dream/qdsp5/adsp.c
@@ -30,6 +30,7 @@
30#include <linux/kernel.h> 30#include <linux/kernel.h>
31#include <linux/kthread.h> 31#include <linux/kthread.h>
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/slab.h>
33#include <linux/uaccess.h> 34#include <linux/uaccess.h>
34#include <linux/wait.h> 35#include <linux/wait.h>
35 36
diff --git a/drivers/staging/dream/qdsp5/adsp_driver.c b/drivers/staging/dream/qdsp5/adsp_driver.c
index e55a0db53a9..8197765aae1 100644
--- a/drivers/staging/dream/qdsp5/adsp_driver.c
+++ b/drivers/staging/dream/qdsp5/adsp_driver.c
@@ -19,6 +19,7 @@
19#include <linux/list.h> 19#include <linux/list.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/sched.h> 21#include <linux/sched.h>
22#include <linux/slab.h>
22#include <linux/uaccess.h> 23#include <linux/uaccess.h>
23 24
24#include "adsp.h" 25#include "adsp.h"
diff --git a/drivers/staging/dream/qdsp5/audio_aac.c b/drivers/staging/dream/qdsp5/audio_aac.c
index ad2390f32a4..a373f352238 100644
--- a/drivers/staging/dream/qdsp5/audio_aac.c
+++ b/drivers/staging/dream/qdsp5/audio_aac.c
@@ -24,6 +24,7 @@
24#include <linux/kthread.h> 24#include <linux/kthread.h>
25#include <linux/wait.h> 25#include <linux/wait.h>
26#include <linux/dma-mapping.h> 26#include <linux/dma-mapping.h>
27#include <linux/gfp.h>
27 28
28#include <linux/delay.h> 29#include <linux/delay.h>
29 30
diff --git a/drivers/staging/dream/qdsp5/audio_amrnb.c b/drivers/staging/dream/qdsp5/audio_amrnb.c
index cd818a526f8..07b79d5836e 100644
--- a/drivers/staging/dream/qdsp5/audio_amrnb.c
+++ b/drivers/staging/dream/qdsp5/audio_amrnb.c
@@ -32,6 +32,7 @@
32#include <linux/kthread.h> 32#include <linux/kthread.h>
33#include <linux/wait.h> 33#include <linux/wait.h>
34#include <linux/dma-mapping.h> 34#include <linux/dma-mapping.h>
35#include <linux/gfp.h>
35 36
36#include <linux/delay.h> 37#include <linux/delay.h>
37 38
diff --git a/drivers/staging/dream/qdsp5/audio_evrc.c b/drivers/staging/dream/qdsp5/audio_evrc.c
index 4b43e183f9e..ad989ee8769 100644
--- a/drivers/staging/dream/qdsp5/audio_evrc.c
+++ b/drivers/staging/dream/qdsp5/audio_evrc.c
@@ -27,6 +27,7 @@
27#include <linux/wait.h> 27#include <linux/wait.h>
28#include <linux/dma-mapping.h> 28#include <linux/dma-mapping.h>
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/gfp.h>
30 31
31#include <asm/atomic.h> 32#include <asm/atomic.h>
32#include <asm/ioctls.h> 33#include <asm/ioctls.h>
diff --git a/drivers/staging/dream/qdsp5/audio_in.c b/drivers/staging/dream/qdsp5/audio_in.c
index 3d950a24589..6ae48e72d14 100644
--- a/drivers/staging/dream/qdsp5/audio_in.c
+++ b/drivers/staging/dream/qdsp5/audio_in.c
@@ -23,6 +23,7 @@
23#include <linux/kthread.h> 23#include <linux/kthread.h>
24#include <linux/wait.h> 24#include <linux/wait.h>
25#include <linux/dma-mapping.h> 25#include <linux/dma-mapping.h>
26#include <linux/gfp.h>
26 27
27#include <linux/delay.h> 28#include <linux/delay.h>
28 29
diff --git a/drivers/staging/dream/qdsp5/audio_mp3.c b/drivers/staging/dream/qdsp5/audio_mp3.c
index 7ed6e261d6c..530e1f35eed 100644
--- a/drivers/staging/dream/qdsp5/audio_mp3.c
+++ b/drivers/staging/dream/qdsp5/audio_mp3.c
@@ -23,6 +23,7 @@
23#include <linux/kthread.h> 23#include <linux/kthread.h>
24#include <linux/wait.h> 24#include <linux/wait.h>
25#include <linux/dma-mapping.h> 25#include <linux/dma-mapping.h>
26#include <linux/gfp.h>
26 27
27#include <linux/delay.h> 28#include <linux/delay.h>
28 29
diff --git a/drivers/staging/dream/qdsp5/audio_out.c b/drivers/staging/dream/qdsp5/audio_out.c
index df87ca337b9..fe7809dd440 100644
--- a/drivers/staging/dream/qdsp5/audio_out.c
+++ b/drivers/staging/dream/qdsp5/audio_out.c
@@ -26,6 +26,7 @@
26#include <linux/debugfs.h> 26#include <linux/debugfs.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/wakelock.h> 28#include <linux/wakelock.h>
29#include <linux/gfp.h>
29 30
30#include <linux/msm_audio.h> 31#include <linux/msm_audio.h>
31 32
diff --git a/drivers/staging/dream/qdsp5/audio_qcelp.c b/drivers/staging/dream/qdsp5/audio_qcelp.c
index f0f50e36805..effa96f34fd 100644
--- a/drivers/staging/dream/qdsp5/audio_qcelp.c
+++ b/drivers/staging/dream/qdsp5/audio_qcelp.c
@@ -29,6 +29,7 @@
29#include <linux/sched.h> 29#include <linux/sched.h>
30#include <linux/wait.h> 30#include <linux/wait.h>
31#include <linux/dma-mapping.h> 31#include <linux/dma-mapping.h>
32#include <linux/gfp.h>
32 33
33#include <asm/ioctls.h> 34#include <asm/ioctls.h>
34#include <mach/msm_adsp.h> 35#include <mach/msm_adsp.h>
diff --git a/drivers/staging/dream/qdsp5/audmgr.c b/drivers/staging/dream/qdsp5/audmgr.c
index 1ad8b82c257..427ae6c0bea 100644
--- a/drivers/staging/dream/qdsp5/audmgr.c
+++ b/drivers/staging/dream/qdsp5/audmgr.c
@@ -18,6 +18,7 @@
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/fs.h> 19#include <linux/fs.h>
20#include <linux/uaccess.h> 20#include <linux/uaccess.h>
21#include <linux/slab.h>
21#include <linux/kthread.h> 22#include <linux/kthread.h>
22#include <linux/wait.h> 23#include <linux/wait.h>
23 24
diff --git a/drivers/staging/dream/smd/smd_rpcrouter.c b/drivers/staging/dream/smd/smd_rpcrouter.c
index 69911a7bc87..8744a6e499c 100644
--- a/drivers/staging/dream/smd/smd_rpcrouter.c
+++ b/drivers/staging/dream/smd/smd_rpcrouter.c
@@ -33,6 +33,7 @@
33#include <linux/err.h> 33#include <linux/err.h>
34#include <linux/sched.h> 34#include <linux/sched.h>
35#include <linux/poll.h> 35#include <linux/poll.h>
36#include <linux/slab.h>
36#include <asm/uaccess.h> 37#include <asm/uaccess.h>
37#include <asm/byteorder.h> 38#include <asm/byteorder.h>
38#include <linux/platform_device.h> 39#include <linux/platform_device.h>
diff --git a/drivers/staging/dream/smd/smd_rpcrouter_device.c b/drivers/staging/dream/smd/smd_rpcrouter_device.c
index cd3910bcc4e..e9c28eddce3 100644
--- a/drivers/staging/dream/smd/smd_rpcrouter_device.c
+++ b/drivers/staging/dream/smd/smd_rpcrouter_device.c
@@ -29,6 +29,7 @@
29#include <linux/poll.h> 29#include <linux/poll.h>
30#include <linux/platform_device.h> 30#include <linux/platform_device.h>
31#include <linux/msm_rpcrouter.h> 31#include <linux/msm_rpcrouter.h>
32#include <linux/slab.h>
32 33
33#include <asm/uaccess.h> 34#include <asm/uaccess.h>
34#include <asm/byteorder.h> 35#include <asm/byteorder.h>
diff --git a/drivers/staging/dream/smd/smd_rpcrouter_servers.c b/drivers/staging/dream/smd/smd_rpcrouter_servers.c
index 2597bbbc6f5..1b152abb278 100644
--- a/drivers/staging/dream/smd/smd_rpcrouter_servers.c
+++ b/drivers/staging/dream/smd/smd_rpcrouter_servers.c
@@ -27,6 +27,7 @@
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/platform_device.h> 28#include <linux/platform_device.h>
29#include <linux/wakelock.h> 29#include <linux/wakelock.h>
30#include <linux/slab.h>
30 31
31#include <linux/msm_rpcrouter.h> 32#include <linux/msm_rpcrouter.h>
32#include <linux/uaccess.h> 33#include <linux/uaccess.h>
diff --git a/drivers/staging/dream/synaptics_i2c_rmi.c b/drivers/staging/dream/synaptics_i2c_rmi.c
index 4de6bc91759..d2ca116a1c2 100644
--- a/drivers/staging/dream/synaptics_i2c_rmi.c
+++ b/drivers/staging/dream/synaptics_i2c_rmi.c
@@ -18,6 +18,7 @@
18 18
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include <linux/slab.h>
21#ifdef CONFIG_HAS_EARLYSUSPEND 22#ifdef CONFIG_HAS_EARLYSUSPEND
22#include <linux/earlysuspend.h> 23#include <linux/earlysuspend.h>
23#endif 24#endif
diff --git a/drivers/staging/dt3155/allocator.c b/drivers/staging/dt3155/allocator.c
index c74234c6689..db382ef9021 100644
--- a/drivers/staging/dt3155/allocator.c
+++ b/drivers/staging/dt3155/allocator.c
@@ -55,6 +55,7 @@
55#include <linux/types.h> 55#include <linux/types.h>
56#include <linux/mm.h> /* PAGE_ALIGN() */ 56#include <linux/mm.h> /* PAGE_ALIGN() */
57#include <linux/io.h> 57#include <linux/io.h>
58#include <linux/slab.h>
58 59
59#include <asm/page.h> 60#include <asm/page.h>
60 61
diff --git a/drivers/staging/dt3155/dt3155_drv.c b/drivers/staging/dt3155/dt3155_drv.c
index a67c622869d..7ac2c6d8e9a 100644
--- a/drivers/staging/dt3155/dt3155_drv.c
+++ b/drivers/staging/dt3155/dt3155_drv.c
@@ -57,19 +57,8 @@ MA 02111-1307 USA
57 57
58extern void printques(int); 58extern void printques(int);
59 59
60#ifdef MODULE
61#include <linux/module.h> 60#include <linux/module.h>
62#include <linux/interrupt.h> 61#include <linux/interrupt.h>
63
64
65MODULE_LICENSE("GPL");
66
67#endif
68
69#ifndef CONFIG_PCI
70#error "DT3155 : Kernel PCI support not enabled (DT3155 drive requires PCI)"
71#endif
72
73#include <linux/pci.h> 62#include <linux/pci.h>
74#include <linux/types.h> 63#include <linux/types.h>
75#include <linux/poll.h> 64#include <linux/poll.h>
@@ -84,6 +73,9 @@ MODULE_LICENSE("GPL");
84#include "dt3155_io.h" 73#include "dt3155_io.h"
85#include "allocator.h" 74#include "allocator.h"
86 75
76
77MODULE_LICENSE("GPL");
78
87/* Error variable. Zero means no error. */ 79/* Error variable. Zero means no error. */
88int dt3155_errno = 0; 80int dt3155_errno = 0;
89 81
@@ -472,9 +464,9 @@ static void dt3155_init_isr(int minor)
472 /* 50/60 Hz should be set before this point but let's make sure it is */ 464 /* 50/60 Hz should be set before this point but let's make sure it is */
473 /* right anyway */ 465 /* right anyway */
474 466
475 ReadI2C(dt3155_lbase[ minor ], CONFIG, &i2c_csr2.reg); 467 ReadI2C(dt3155_lbase[ minor ], CSR2, &i2c_csr2.reg);
476 i2c_csr2.fld.HZ50 = FORMAT50HZ; 468 i2c_csr2.fld.HZ50 = FORMAT50HZ;
477 WriteI2C(dt3155_lbase[ minor ], CONFIG, i2c_config.reg); 469 WriteI2C(dt3155_lbase[ minor ], CSR2, i2c_csr2.reg);
478 470
479 /* enable busmaster chip, clear flags */ 471 /* enable busmaster chip, clear flags */
480 472
diff --git a/drivers/staging/dt3155/dt3155_isr.c b/drivers/staging/dt3155/dt3155_isr.c
index fd7f93d6c33..09d7d9b8272 100644
--- a/drivers/staging/dt3155/dt3155_isr.c
+++ b/drivers/staging/dt3155/dt3155_isr.c
@@ -45,7 +45,7 @@ Purpose: Buffer management routines, and other routines for the ISR
45*/ 45*/
46 46
47#include <asm/system.h> 47#include <asm/system.h>
48#include <linux/slab.h> 48#include <linux/gfp.h>
49#include <linux/sched.h> 49#include <linux/sched.h>
50#include <linux/types.h> 50#include <linux/types.h>
51 51
diff --git a/drivers/staging/et131x/et1310_eeprom.c b/drivers/staging/et131x/et1310_eeprom.c
index 3ca253672ba..e4d095b0b52 100644
--- a/drivers/staging/et131x/et1310_eeprom.c
+++ b/drivers/staging/et131x/et1310_eeprom.c
@@ -66,7 +66,6 @@
66 66
67#include <linux/sched.h> 67#include <linux/sched.h>
68#include <linux/ptrace.h> 68#include <linux/ptrace.h>
69#include <linux/slab.h>
70#include <linux/ctype.h> 69#include <linux/ctype.h>
71#include <linux/string.h> 70#include <linux/string.h>
72#include <linux/timer.h> 71#include <linux/timer.h>
diff --git a/drivers/staging/et131x/et1310_mac.c b/drivers/staging/et131x/et1310_mac.c
index a292b1edc41..16fa13d4821 100644
--- a/drivers/staging/et131x/et1310_mac.c
+++ b/drivers/staging/et131x/et1310_mac.c
@@ -65,7 +65,6 @@
65 65
66#include <linux/sched.h> 66#include <linux/sched.h>
67#include <linux/ptrace.h> 67#include <linux/ptrace.h>
68#include <linux/slab.h>
69#include <linux/ctype.h> 68#include <linux/ctype.h>
70#include <linux/string.h> 69#include <linux/string.h>
71#include <linux/timer.h> 70#include <linux/timer.h>
@@ -226,7 +225,7 @@ void ConfigMACRegs2(struct et131x_adapter *etdev)
226 } 225 }
227 226
228 /* Enable TXMAC */ 227 /* Enable TXMAC */
229 ctl |= 0x05; /* TX mac enable, FC disable */ 228 ctl |= 0x09; /* TX mac enable, FC disable */
230 writel(ctl, &etdev->regs->txmac.ctl); 229 writel(ctl, &etdev->regs->txmac.ctl);
231 230
232 /* Ready to start the RXDMA/TXDMA engine */ 231 /* Ready to start the RXDMA/TXDMA engine */
diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c
index 4a55fbfbd59..34cd5d1b586 100644
--- a/drivers/staging/et131x/et1310_phy.c
+++ b/drivers/staging/et131x/et1310_phy.c
@@ -66,7 +66,6 @@
66 66
67#include <linux/sched.h> 67#include <linux/sched.h>
68#include <linux/ptrace.h> 68#include <linux/ptrace.h>
69#include <linux/slab.h>
70#include <linux/ctype.h> 69#include <linux/ctype.h>
71#include <linux/string.h> 70#include <linux/string.h>
72#include <linux/timer.h> 71#include <linux/timer.h>
diff --git a/drivers/staging/et131x/et1310_pm.c b/drivers/staging/et131x/et1310_pm.c
index 41019e390af..c64bb2c6d0d 100644
--- a/drivers/staging/et131x/et1310_pm.c
+++ b/drivers/staging/et131x/et1310_pm.c
@@ -65,7 +65,6 @@
65 65
66#include <linux/sched.h> 66#include <linux/sched.h>
67#include <linux/ptrace.h> 67#include <linux/ptrace.h>
68#include <linux/slab.h>
69#include <linux/ctype.h> 68#include <linux/ctype.h>
70#include <linux/string.h> 69#include <linux/string.h>
71#include <linux/timer.h> 70#include <linux/timer.h>
diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c
index 5ad7e5a6f63..1dd5fa5b888 100644
--- a/drivers/staging/et131x/et131x_initpci.c
+++ b/drivers/staging/et131x/et131x_initpci.c
@@ -68,7 +68,6 @@
68 68
69#include <linux/sched.h> 69#include <linux/sched.h>
70#include <linux/ptrace.h> 70#include <linux/ptrace.h>
71#include <linux/slab.h>
72#include <linux/ctype.h> 71#include <linux/ctype.h>
73#include <linux/string.h> 72#include <linux/string.h>
74#include <linux/timer.h> 73#include <linux/timer.h>
diff --git a/drivers/staging/et131x/et131x_isr.c b/drivers/staging/et131x/et131x_isr.c
index 8b6e0b7ec56..cb7f6775ce0 100644
--- a/drivers/staging/et131x/et131x_isr.c
+++ b/drivers/staging/et131x/et131x_isr.c
@@ -66,7 +66,6 @@
66 66
67#include <linux/sched.h> 67#include <linux/sched.h>
68#include <linux/ptrace.h> 68#include <linux/ptrace.h>
69#include <linux/slab.h>
70#include <linux/ctype.h> 69#include <linux/ctype.h>
71#include <linux/string.h> 70#include <linux/string.h>
72#include <linux/timer.h> 71#include <linux/timer.h>
diff --git a/drivers/staging/et131x/et131x_netdev.c b/drivers/staging/et131x/et131x_netdev.c
index 40f8954dde4..ab047f2ff72 100644
--- a/drivers/staging/et131x/et131x_netdev.c
+++ b/drivers/staging/et131x/et131x_netdev.c
@@ -65,7 +65,6 @@
65 65
66#include <linux/sched.h> 66#include <linux/sched.h>
67#include <linux/ptrace.h> 67#include <linux/ptrace.h>
68#include <linux/slab.h>
69#include <linux/ctype.h> 68#include <linux/ctype.h>
70#include <linux/string.h> 69#include <linux/string.h>
71#include <linux/timer.h> 70#include <linux/timer.h>
diff --git a/drivers/staging/go7007/go7007-driver.c b/drivers/staging/go7007/go7007-driver.c
index d42ba169699..372a7c6791c 100644
--- a/drivers/staging/go7007/go7007-driver.c
+++ b/drivers/staging/go7007/go7007-driver.c
@@ -29,6 +29,7 @@
29#include <linux/firmware.h> 29#include <linux/firmware.h>
30#include <linux/mutex.h> 30#include <linux/mutex.h>
31#include <linux/uaccess.h> 31#include <linux/uaccess.h>
32#include <linux/slab.h>
32#include <asm/system.h> 33#include <asm/system.h>
33#include <linux/videodev2.h> 34#include <linux/videodev2.h>
34#include <media/tuner.h> 35#include <media/tuner.h>
diff --git a/drivers/staging/go7007/go7007-fw.c b/drivers/staging/go7007/go7007-fw.c
index a8bb264e007..ee622ff1707 100644
--- a/drivers/staging/go7007/go7007-fw.c
+++ b/drivers/staging/go7007/go7007-fw.c
@@ -31,6 +31,7 @@
31#include <linux/device.h> 31#include <linux/device.h>
32#include <linux/i2c.h> 32#include <linux/i2c.h>
33#include <linux/firmware.h> 33#include <linux/firmware.h>
34#include <linux/slab.h>
34#include <asm/byteorder.h> 35#include <asm/byteorder.h>
35 36
36#include "go7007-priv.h" 37#include "go7007-priv.h"
diff --git a/drivers/staging/go7007/go7007-v4l2.c b/drivers/staging/go7007/go7007-v4l2.c
index 3af79242313..723c1a64d87 100644
--- a/drivers/staging/go7007/go7007-v4l2.c
+++ b/drivers/staging/go7007/go7007-v4l2.c
@@ -21,6 +21,7 @@
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/sched.h> 22#include <linux/sched.h>
23#include <linux/spinlock.h> 23#include <linux/spinlock.h>
24#include <linux/slab.h>
24#include <linux/fs.h> 25#include <linux/fs.h>
25#include <linux/unistd.h> 26#include <linux/unistd.h>
26#include <linux/time.h> 27#include <linux/time.h>
diff --git a/drivers/staging/go7007/s2250-board.c b/drivers/staging/go7007/s2250-board.c
index dc89502ea1b..93f26048e3b 100644
--- a/drivers/staging/go7007/s2250-board.c
+++ b/drivers/staging/go7007/s2250-board.c
@@ -20,6 +20,7 @@
20#include <linux/usb.h> 20#include <linux/usb.h>
21#include <linux/i2c.h> 21#include <linux/i2c.h>
22#include <linux/videodev2.h> 22#include <linux/videodev2.h>
23#include <linux/slab.h>
23#include <media/v4l2-device.h> 24#include <media/v4l2-device.h>
24#include <media/v4l2-common.h> 25#include <media/v4l2-common.h>
25#include <media/v4l2-i2c-drv.h> 26#include <media/v4l2-i2c-drv.h>
diff --git a/drivers/staging/go7007/s2250-loader.c b/drivers/staging/go7007/s2250-loader.c
index 1de2dfb16d3..7547a8f7734 100644
--- a/drivers/staging/go7007/s2250-loader.c
+++ b/drivers/staging/go7007/s2250-loader.c
@@ -17,6 +17,7 @@
17 17
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/slab.h>
20#include <linux/smp_lock.h> 21#include <linux/smp_lock.h>
21#include <linux/usb.h> 22#include <linux/usb.h>
22#include <dvb-usb.h> 23#include <dvb-usb.h>
diff --git a/drivers/staging/go7007/snd-go7007.c b/drivers/staging/go7007/snd-go7007.c
index 03c4dfc138a..deac938d850 100644
--- a/drivers/staging/go7007/snd-go7007.c
+++ b/drivers/staging/go7007/snd-go7007.c
@@ -28,6 +28,7 @@
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <linux/mutex.h> 29#include <linux/mutex.h>
30#include <linux/uaccess.h> 30#include <linux/uaccess.h>
31#include <linux/slab.h>
31#include <asm/system.h> 32#include <asm/system.h>
32#include <sound/core.h> 33#include <sound/core.h>
33#include <sound/pcm.h> 34#include <sound/pcm.h>
diff --git a/drivers/staging/go7007/wis-saa7113.c b/drivers/staging/go7007/wis-saa7113.c
index d196e16fe72..5c12b4d3845 100644
--- a/drivers/staging/go7007/wis-saa7113.c
+++ b/drivers/staging/go7007/wis-saa7113.c
@@ -20,6 +20,7 @@
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <linux/videodev2.h> 21#include <linux/videodev2.h>
22#include <linux/ioctl.h> 22#include <linux/ioctl.h>
23#include <linux/slab.h>
23 24
24#include "wis-i2c.h" 25#include "wis-i2c.h"
25 26
diff --git a/drivers/staging/go7007/wis-saa7115.c b/drivers/staging/go7007/wis-saa7115.c
index 0f2b4a0cecc..73f2283a880 100644
--- a/drivers/staging/go7007/wis-saa7115.c
+++ b/drivers/staging/go7007/wis-saa7115.c
@@ -20,6 +20,7 @@
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <linux/videodev2.h> 21#include <linux/videodev2.h>
22#include <linux/ioctl.h> 22#include <linux/ioctl.h>
23#include <linux/slab.h>
23 24
24#include "wis-i2c.h" 25#include "wis-i2c.h"
25 26
diff --git a/drivers/staging/go7007/wis-sony-tuner.c b/drivers/staging/go7007/wis-sony-tuner.c
index c723e4aa714..b1013291190 100644
--- a/drivers/staging/go7007/wis-sony-tuner.c
+++ b/drivers/staging/go7007/wis-sony-tuner.c
@@ -19,6 +19,7 @@
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <linux/videodev2.h> 21#include <linux/videodev2.h>
22#include <linux/slab.h>
22#include <media/tuner.h> 23#include <media/tuner.h>
23#include <media/v4l2-common.h> 24#include <media/v4l2-common.h>
24#include <media/v4l2-ioctl.h> 25#include <media/v4l2-ioctl.h>
diff --git a/drivers/staging/go7007/wis-tw2804.c b/drivers/staging/go7007/wis-tw2804.c
index 1983839f554..315268d130d 100644
--- a/drivers/staging/go7007/wis-tw2804.c
+++ b/drivers/staging/go7007/wis-tw2804.c
@@ -20,6 +20,7 @@
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <linux/videodev2.h> 21#include <linux/videodev2.h>
22#include <linux/ioctl.h> 22#include <linux/ioctl.h>
23#include <linux/slab.h>
23 24
24#include "wis-i2c.h" 25#include "wis-i2c.h"
25 26
diff --git a/drivers/staging/go7007/wis-tw9903.c b/drivers/staging/go7007/wis-tw9903.c
index f97e2be3c0b..3ac6f785c4a 100644
--- a/drivers/staging/go7007/wis-tw9903.c
+++ b/drivers/staging/go7007/wis-tw9903.c
@@ -20,6 +20,7 @@
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <linux/videodev2.h> 21#include <linux/videodev2.h>
22#include <linux/ioctl.h> 22#include <linux/ioctl.h>
23#include <linux/slab.h>
23 24
24#include "wis-i2c.h" 25#include "wis-i2c.h"
25 26
diff --git a/drivers/staging/hv/Channel.c b/drivers/staging/hv/Channel.c
index d46eb145484..e69e9ee704a 100644
--- a/drivers/staging/hv/Channel.c
+++ b/drivers/staging/hv/Channel.c
@@ -20,6 +20,7 @@
20 */ 20 */
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/mm.h> 22#include <linux/mm.h>
23#include <linux/slab.h>
23#include "osd.h" 24#include "osd.h"
24#include "logging.h" 25#include "logging.h"
25#include "VmbusPrivate.h" 26#include "VmbusPrivate.h"
diff --git a/drivers/staging/hv/ChannelMgmt.c b/drivers/staging/hv/ChannelMgmt.c
index ef38467ed4e..5f92c2102ab 100644
--- a/drivers/staging/hv/ChannelMgmt.c
+++ b/drivers/staging/hv/ChannelMgmt.c
@@ -20,6 +20,7 @@
20 */ 20 */
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/mm.h> 22#include <linux/mm.h>
23#include <linux/slab.h>
23#include <linux/list.h> 24#include <linux/list.h>
24#include "osd.h" 25#include "osd.h"
25#include "logging.h" 26#include "logging.h"
diff --git a/drivers/staging/hv/Connection.c b/drivers/staging/hv/Connection.c
index 43c2e685501..e0ea9cf90f0 100644
--- a/drivers/staging/hv/Connection.c
+++ b/drivers/staging/hv/Connection.c
@@ -22,6 +22,7 @@
22 */ 22 */
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/mm.h> 24#include <linux/mm.h>
25#include <linux/slab.h>
25#include <linux/vmalloc.h> 26#include <linux/vmalloc.h>
26#include "osd.h" 27#include "osd.h"
27#include "logging.h" 28#include "logging.h"
diff --git a/drivers/staging/hv/Hv.c b/drivers/staging/hv/Hv.c
index 51149e69f3e..3a1112d29ae 100644
--- a/drivers/staging/hv/Hv.c
+++ b/drivers/staging/hv/Hv.c
@@ -21,6 +21,7 @@
21 */ 21 */
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/mm.h> 23#include <linux/mm.h>
24#include <linux/slab.h>
24#include <linux/vmalloc.h> 25#include <linux/vmalloc.h>
25#include "osd.h" 26#include "osd.h"
26#include "logging.h" 27#include "logging.h"
@@ -305,9 +306,9 @@ void HvCleanup(void)
305 DPRINT_ENTER(VMBUS); 306 DPRINT_ENTER(VMBUS);
306 307
307 if (gHvContext.SignalEventBuffer) { 308 if (gHvContext.SignalEventBuffer) {
309 kfree(gHvContext.SignalEventBuffer);
308 gHvContext.SignalEventBuffer = NULL; 310 gHvContext.SignalEventBuffer = NULL;
309 gHvContext.SignalEventParam = NULL; 311 gHvContext.SignalEventParam = NULL;
310 kfree(gHvContext.SignalEventBuffer);
311 } 312 }
312 313
313 if (gHvContext.HypercallPage) { 314 if (gHvContext.HypercallPage) {
diff --git a/drivers/staging/hv/NetVsc.c b/drivers/staging/hv/NetVsc.c
index 1c717f9a554..e4bf8229750 100644
--- a/drivers/staging/hv/NetVsc.c
+++ b/drivers/staging/hv/NetVsc.c
@@ -22,6 +22,7 @@
22#include <linux/mm.h> 22#include <linux/mm.h>
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/io.h> 24#include <linux/io.h>
25#include <linux/slab.h>
25#include "osd.h" 26#include "osd.h"
26#include "logging.h" 27#include "logging.h"
27#include "NetVsc.h" 28#include "NetVsc.h"
diff --git a/drivers/staging/hv/RndisFilter.c b/drivers/staging/hv/RndisFilter.c
index 1ab7fa97d37..6704f64c93f 100644
--- a/drivers/staging/hv/RndisFilter.c
+++ b/drivers/staging/hv/RndisFilter.c
@@ -20,6 +20,7 @@
20 */ 20 */
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/highmem.h> 22#include <linux/highmem.h>
23#include <linux/slab.h>
23#include <linux/io.h> 24#include <linux/io.h>
24#include "osd.h" 25#include "osd.h"
25#include "logging.h" 26#include "logging.h"
@@ -750,6 +751,7 @@ static int RndisFilterOpenDevice(struct rndis_device *Device)
750 751
751 ret = RndisFilterSetPacketFilter(Device, 752 ret = RndisFilterSetPacketFilter(Device,
752 NDIS_PACKET_TYPE_BROADCAST | 753 NDIS_PACKET_TYPE_BROADCAST |
754 NDIS_PACKET_TYPE_ALL_MULTICAST |
753 NDIS_PACKET_TYPE_DIRECTED); 755 NDIS_PACKET_TYPE_DIRECTED);
754 if (ret == 0) 756 if (ret == 0)
755 Device->State = RNDIS_DEV_DATAINITIALIZED; 757 Device->State = RNDIS_DEV_DATAINITIALIZED;
diff --git a/drivers/staging/hv/StorVsc.c b/drivers/staging/hv/StorVsc.c
index 38ea1407f22..e426a23ca53 100644
--- a/drivers/staging/hv/StorVsc.c
+++ b/drivers/staging/hv/StorVsc.c
@@ -20,6 +20,7 @@
20 */ 20 */
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/string.h> 22#include <linux/string.h>
23#include <linux/slab.h>
23#include <linux/mm.h> 24#include <linux/mm.h>
24#include <linux/delay.h> 25#include <linux/delay.h>
25#include "osd.h" 26#include "osd.h"
diff --git a/drivers/staging/hv/Vmbus.c b/drivers/staging/hv/Vmbus.c
index 3d0a240ed66..2f84bf7c0a9 100644
--- a/drivers/staging/hv/Vmbus.c
+++ b/drivers/staging/hv/Vmbus.c
@@ -21,6 +21,7 @@
21 */ 21 */
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/mm.h> 23#include <linux/mm.h>
24#include <linux/slab.h>
24#include "osd.h" 25#include "osd.h"
25#include "logging.h" 26#include "logging.h"
26#include "VersionInfo.h" 27#include "VersionInfo.h"
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index abeac12c093..8f1fda3256a 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -25,6 +25,7 @@
25#include <linux/major.h> 25#include <linux/major.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/hdreg.h> 27#include <linux/hdreg.h>
28#include <linux/slab.h>
28#include <scsi/scsi.h> 29#include <scsi/scsi.h>
29#include <scsi/scsi_cmnd.h> 30#include <scsi/scsi_cmnd.h>
30#include <scsi/scsi_eh.h> 31#include <scsi/scsi_eh.h>
diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 1af3dcbafd6..ab27d9a4446 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -29,6 +29,7 @@
29#include <linux/etherdevice.h> 29#include <linux/etherdevice.h>
30#include <linux/skbuff.h> 30#include <linux/skbuff.h>
31#include <linux/in.h> 31#include <linux/in.h>
32#include <linux/slab.h>
32#include <net/arp.h> 33#include <net/arp.h>
33#include <net/route.h> 34#include <net/route.h>
34#include <net/sock.h> 35#include <net/sock.h>
@@ -402,8 +403,7 @@ static int netvsc_probe(struct device *device)
402 if (!net_drv_obj->Base.OnDeviceAdd) 403 if (!net_drv_obj->Base.OnDeviceAdd)
403 return -1; 404 return -1;
404 405
405 net = alloc_netdev(sizeof(struct net_device_context), "seth%d", 406 net = alloc_etherdev(sizeof(struct net_device_context));
406 ether_setup);
407 if (!net) 407 if (!net)
408 return -1; 408 return -1;
409 409
diff --git a/drivers/staging/hv/osd.c b/drivers/staging/hv/osd.c
index 3a4793a0fd0..9aea3106729 100644
--- a/drivers/staging/hv/osd.c
+++ b/drivers/staging/hv/osd.c
@@ -40,6 +40,7 @@
40#include <linux/time.h> 40#include <linux/time.h>
41#include <linux/io.h> 41#include <linux/io.h>
42#include <linux/bitops.h> 42#include <linux/bitops.h>
43#include <linux/slab.h>
43#include "osd.h" 44#include "osd.h"
44 45
45struct osd_callback_struct { 46struct osd_callback_struct {
diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
index 3988f4bec1c..8a58272b803 100644
--- a/drivers/staging/hv/storvsc_drv.c
+++ b/drivers/staging/hv/storvsc_drv.c
@@ -19,6 +19,7 @@
19 * Hank Janssen <hjanssen@microsoft.com> 19 * Hank Janssen <hjanssen@microsoft.com>
20 */ 20 */
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/slab.h>
22#include <linux/module.h> 23#include <linux/module.h>
23#include <linux/device.h> 24#include <linux/device.h>
24#include <linux/blkdev.h> 25#include <linux/blkdev.h>
diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c
index 2c906195b9c..3397ef08e0a 100644
--- a/drivers/staging/hv/vmbus_drv.c
+++ b/drivers/staging/hv/vmbus_drv.c
@@ -26,6 +26,7 @@
26#include <linux/sysctl.h> 26#include <linux/sysctl.h>
27#include <linux/pci.h> 27#include <linux/pci.h>
28#include <linux/dmi.h> 28#include <linux/dmi.h>
29#include <linux/slab.h>
29#include "VersionInfo.h" 30#include "VersionInfo.h"
30#include "osd.h" 31#include "osd.h"
31#include "logging.h" 32#include "logging.h"
diff --git a/drivers/staging/iio/accel/kxsd9.c b/drivers/staging/iio/accel/kxsd9.c
index 33d16b6f7b5..db2dd537ffb 100644
--- a/drivers/staging/iio/accel/kxsd9.c
+++ b/drivers/staging/iio/accel/kxsd9.c
@@ -25,6 +25,7 @@
25#include <linux/sysfs.h> 25#include <linux/sysfs.h>
26#include <linux/rtc.h> 26#include <linux/rtc.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/slab.h>
28 29
29#include "../iio.h" 30#include "../iio.h"
30#include "../sysfs.h" 31#include "../sysfs.h"
diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c
index f008837e5a1..82e43588e8a 100644
--- a/drivers/staging/iio/accel/lis3l02dq_core.c
+++ b/drivers/staging/iio/accel/lis3l02dq_core.c
@@ -20,6 +20,7 @@
20#include <linux/device.h> 20#include <linux/device.h>
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/spi/spi.h> 22#include <linux/spi/spi.h>
23#include <linux/slab.h>
23 24
24#include <linux/sysfs.h> 25#include <linux/sysfs.h>
25#include <linux/list.h> 26#include <linux/list.h>
@@ -617,7 +618,7 @@ static int lis3l02dq_thresh_handler_th(struct iio_dev *dev_info,
617static void lis3l02dq_thresh_handler_bh_no_check(struct work_struct *work_s) 618static void lis3l02dq_thresh_handler_bh_no_check(struct work_struct *work_s)
618{ 619{
619 struct iio_work_cont *wc 620 struct iio_work_cont *wc
620 = container_of(work_s, struct iio_work_cont, ws_nocheck); 621 = container_of(work_s, struct iio_work_cont, ws);
621 struct lis3l02dq_state *st = wc->st; 622 struct lis3l02dq_state *st = wc->st;
622 u8 t; 623 u8 t;
623 624
diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c
index a6b7c72a86f..a4d97ea0df3 100644
--- a/drivers/staging/iio/accel/lis3l02dq_ring.c
+++ b/drivers/staging/iio/accel/lis3l02dq_ring.c
@@ -8,6 +8,7 @@
8#include <linux/spi/spi.h> 8#include <linux/spi/spi.h>
9#include <linux/sysfs.h> 9#include <linux/sysfs.h>
10#include <linux/list.h> 10#include <linux/list.h>
11#include <linux/slab.h>
11 12
12#include "../iio.h" 13#include "../iio.h"
13#include "../sysfs.h" 14#include "../sysfs.h"
@@ -492,6 +493,9 @@ int lis3l02dq_probe_trigger(struct iio_dev *indio_dev)
492 struct lis3l02dq_state *state = indio_dev->dev_data; 493 struct lis3l02dq_state *state = indio_dev->dev_data;
493 494
494 state->trig = iio_allocate_trigger(); 495 state->trig = iio_allocate_trigger();
496 if (!state->trig)
497 return -ENOMEM;
498
495 state->trig->name = kmalloc(IIO_TRIGGER_NAME_LENGTH, GFP_KERNEL); 499 state->trig->name = kmalloc(IIO_TRIGGER_NAME_LENGTH, GFP_KERNEL);
496 if (!state->trig->name) { 500 if (!state->trig->name) {
497 ret = -ENOMEM; 501 ret = -ENOMEM;
diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c
index cedcaa2b3d1..1c229869a22 100644
--- a/drivers/staging/iio/accel/sca3000_core.c
+++ b/drivers/staging/iio/accel/sca3000_core.c
@@ -14,6 +14,7 @@
14#include <linux/gpio.h> 14#include <linux/gpio.h>
15#include <linux/fs.h> 15#include <linux/fs.h>
16#include <linux/device.h> 16#include <linux/device.h>
17#include <linux/slab.h>
17#include <linux/kernel.h> 18#include <linux/kernel.h>
18#include <linux/spi/spi.h> 19#include <linux/spi/spi.h>
19#include <linux/sysfs.h> 20#include <linux/sysfs.h>
diff --git a/drivers/staging/iio/accel/sca3000_ring.c b/drivers/staging/iio/accel/sca3000_ring.c
index d5ea237793a..40cbab2a659 100644
--- a/drivers/staging/iio/accel/sca3000_ring.c
+++ b/drivers/staging/iio/accel/sca3000_ring.c
@@ -13,6 +13,7 @@
13#include <linux/gpio.h> 13#include <linux/gpio.h>
14#include <linux/fs.h> 14#include <linux/fs.h>
15#include <linux/device.h> 15#include <linux/device.h>
16#include <linux/slab.h>
16#include <linux/kernel.h> 17#include <linux/kernel.h>
17#include <linux/spi/spi.h> 18#include <linux/spi/spi.h>
18#include <linux/sysfs.h> 19#include <linux/sysfs.h>
diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c
index 9703881cb3f..773f1d1d9c6 100644
--- a/drivers/staging/iio/adc/max1363_core.c
+++ b/drivers/staging/iio/adc/max1363_core.c
@@ -33,6 +33,7 @@
33#include <linux/i2c.h> 33#include <linux/i2c.h>
34#include <linux/rtc.h> 34#include <linux/rtc.h>
35#include <linux/regulator/consumer.h> 35#include <linux/regulator/consumer.h>
36#include <linux/slab.h>
36 37
37#include "../iio.h" 38#include "../iio.h"
38#include "../sysfs.h" 39#include "../sysfs.h"
@@ -556,6 +557,7 @@ error_put_reg:
556 if (!IS_ERR(st->reg)) 557 if (!IS_ERR(st->reg))
557 regulator_put(st->reg); 558 regulator_put(st->reg);
558error_free_st: 559error_free_st:
560 i2c_set_clientdata(client, NULL);
559 kfree(st); 561 kfree(st);
560 562
561error_ret: 563error_ret:
@@ -573,6 +575,7 @@ static int max1363_remove(struct i2c_client *client)
573 regulator_disable(st->reg); 575 regulator_disable(st->reg);
574 regulator_put(st->reg); 576 regulator_put(st->reg);
575 } 577 }
578 i2c_set_clientdata(client, NULL);
576 kfree(st); 579 kfree(st);
577 580
578 return 0; 581 return 0;
diff --git a/drivers/staging/iio/adc/max1363_ring.c b/drivers/staging/iio/adc/max1363_ring.c
index a953eac6fd6..f94fe2d38a9 100644
--- a/drivers/staging/iio/adc/max1363_ring.c
+++ b/drivers/staging/iio/adc/max1363_ring.c
@@ -12,6 +12,7 @@
12#include <linux/gpio.h> 12#include <linux/gpio.h>
13#include <linux/workqueue.h> 13#include <linux/workqueue.h>
14#include <linux/device.h> 14#include <linux/device.h>
15#include <linux/slab.h>
15#include <linux/kernel.h> 16#include <linux/kernel.h>
16#include <linux/sysfs.h> 17#include <linux/sysfs.h>
17#include <linux/list.h> 18#include <linux/list.h>
diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c
index b456dfc8fe2..1d77082c853 100644
--- a/drivers/staging/iio/industrialio-core.c
+++ b/drivers/staging/iio/industrialio-core.c
@@ -21,6 +21,7 @@
21#include <linux/sched.h> 21#include <linux/sched.h>
22#include <linux/wait.h> 22#include <linux/wait.h>
23#include <linux/cdev.h> 23#include <linux/cdev.h>
24#include <linux/slab.h>
24#include "iio.h" 25#include "iio.h"
25#include "trigger_consumer.h" 26#include "trigger_consumer.h"
26 27
@@ -536,6 +537,7 @@ static void iio_device_unregister_sysfs(struct iio_dev *dev_info)
536 sysfs_remove_group(&dev_info->dev.kobj, dev_info->attrs); 537 sysfs_remove_group(&dev_info->dev.kobj, dev_info->attrs);
537} 538}
538 539
540/* Return a negative errno on failure */
539int iio_get_new_idr_val(struct idr *this_idr) 541int iio_get_new_idr_val(struct idr *this_idr)
540{ 542{
541 int ret; 543 int ret;
@@ -659,7 +661,7 @@ static int iio_device_register_eventset(struct iio_dev *dev_info)
659 for (i = 0; i < dev_info->num_interrupt_lines; i++) { 661 for (i = 0; i < dev_info->num_interrupt_lines; i++) {
660 dev_info->event_interfaces[i].owner = dev_info->driver_module; 662 dev_info->event_interfaces[i].owner = dev_info->driver_module;
661 ret = iio_get_new_idr_val(&iio_event_idr); 663 ret = iio_get_new_idr_val(&iio_event_idr);
662 if (ret) 664 if (ret < 0)
663 goto error_free_setup_ev_ints; 665 goto error_free_setup_ev_ints;
664 else 666 else
665 dev_info->event_interfaces[i].id = ret; 667 dev_info->event_interfaces[i].id = ret;
diff --git a/drivers/staging/iio/industrialio-ring.c b/drivers/staging/iio/industrialio-ring.c
index ebe5cccb403..e53e214bfeb 100644
--- a/drivers/staging/iio/industrialio-ring.c
+++ b/drivers/staging/iio/industrialio-ring.c
@@ -21,6 +21,7 @@
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/cdev.h> 22#include <linux/cdev.h>
23#include <linux/idr.h> 23#include <linux/idr.h>
24#include <linux/slab.h>
24 25
25#include "iio.h" 26#include "iio.h"
26#include "ring_generic.h" 27#include "ring_generic.h"
diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c
index 693ebc48597..35ec80ba444 100644
--- a/drivers/staging/iio/industrialio-trigger.c
+++ b/drivers/staging/iio/industrialio-trigger.c
@@ -14,6 +14,7 @@
14#include <linux/device.h> 14#include <linux/device.h>
15#include <linux/interrupt.h> 15#include <linux/interrupt.h>
16#include <linux/list.h> 16#include <linux/list.h>
17#include <linux/slab.h>
17 18
18#include "iio.h" 19#include "iio.h"
19#include "trigger.h" 20#include "trigger.h"
diff --git a/drivers/staging/iio/light/tsl2563.c b/drivers/staging/iio/light/tsl2563.c
index 78b9432c810..8770a00e365 100644
--- a/drivers/staging/iio/light/tsl2563.c
+++ b/drivers/staging/iio/light/tsl2563.c
@@ -34,6 +34,7 @@
34#include <linux/pm.h> 34#include <linux/pm.h>
35#include <linux/hwmon.h> 35#include <linux/hwmon.h>
36#include <linux/err.h> 36#include <linux/err.h>
37#include <linux/slab.h>
37 38
38#include "../iio.h" 39#include "../iio.h"
39#include "tsl2563.h" 40#include "tsl2563.h"
@@ -681,6 +682,7 @@ static int __devinit tsl2563_probe(struct i2c_client *client,
681fail2: 682fail2:
682 iio_device_unregister(chip->indio_dev); 683 iio_device_unregister(chip->indio_dev);
683fail1: 684fail1:
685 i2c_set_clientdata(client, NULL);
684 kfree(chip); 686 kfree(chip);
685 return err; 687 return err;
686} 688}
@@ -691,6 +693,7 @@ static int tsl2563_remove(struct i2c_client *client)
691 693
692 iio_device_unregister(chip->indio_dev); 694 iio_device_unregister(chip->indio_dev);
693 695
696 i2c_set_clientdata(client, NULL);
694 kfree(chip); 697 kfree(chip);
695 return 0; 698 return 0;
696} 699}
diff --git a/drivers/staging/iio/ring_sw.c b/drivers/staging/iio/ring_sw.c
index 6f7f4d5a93f..cf22c091668 100644
--- a/drivers/staging/iio/ring_sw.c
+++ b/drivers/staging/iio/ring_sw.c
@@ -7,6 +7,7 @@
7 * the Free Software Foundation. 7 * the Free Software Foundation.
8 */ 8 */
9 9
10#include <linux/slab.h>
10#include <linux/kernel.h> 11#include <linux/kernel.h>
11#include <linux/module.h> 12#include <linux/module.h>
12#include <linux/device.h> 13#include <linux/device.h>
@@ -292,7 +293,7 @@ again:
292 return -EAGAIN; 293 return -EAGAIN;
293 memcpy(data, last_written_p_copy, ring->buf.bpd); 294 memcpy(data, last_written_p_copy, ring->buf.bpd);
294 295
295 if (unlikely(ring->last_written_p >= last_written_p_copy)) 296 if (unlikely(ring->last_written_p != last_written_p_copy))
296 goto again; 297 goto again;
297 298
298 iio_unmark_sw_rb_in_use(&ring->buf); 299 iio_unmark_sw_rb_in_use(&ring->buf);
diff --git a/drivers/staging/iio/trigger/iio-trig-gpio.c b/drivers/staging/iio/trigger/iio-trig-gpio.c
index 539e4169a02..0c3bad3187f 100644
--- a/drivers/staging/iio/trigger/iio-trig-gpio.c
+++ b/drivers/staging/iio/trigger/iio-trig-gpio.c
@@ -21,6 +21,7 @@
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/interrupt.h> 22#include <linux/interrupt.h>
23#include <linux/gpio.h> 23#include <linux/gpio.h>
24#include <linux/slab.h>
24 25
25#include "../iio.h" 26#include "../iio.h"
26#include "../trigger.h" 27#include "../trigger.h"
diff --git a/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c b/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c
index e310dc00985..4295bbc7b50 100644
--- a/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c
+++ b/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c
@@ -14,6 +14,7 @@
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/slab.h>
17#include <linux/rtc.h> 18#include <linux/rtc.h>
18#include "../iio.h" 19#include "../iio.h"
19#include "../trigger.h" 20#include "../trigger.h"
diff --git a/drivers/staging/line6/capture.c b/drivers/staging/line6/capture.c
index fd4890de8db..ca092247f36 100644
--- a/drivers/staging/line6/capture.c
+++ b/drivers/staging/line6/capture.c
@@ -11,6 +11,8 @@
11 11
12#include "driver.h" 12#include "driver.h"
13 13
14#include <linux/slab.h>
15
14#include <sound/core.h> 16#include <sound/core.h>
15#include <sound/pcm.h> 17#include <sound/pcm.h>
16#include <sound/pcm_params.h> 18#include <sound/pcm_params.h>
diff --git a/drivers/staging/line6/driver.c b/drivers/staging/line6/driver.c
index 0392a4bc8cc..258555417bc 100644
--- a/drivers/staging/line6/driver.c
+++ b/drivers/staging/line6/driver.c
@@ -13,6 +13,7 @@
13 13
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/slab.h>
16#include <linux/usb.h> 17#include <linux/usb.h>
17 18
18#include "audio.h" 19#include "audio.h"
diff --git a/drivers/staging/line6/dumprequest.c b/drivers/staging/line6/dumprequest.c
index decbaa971b6..bb8c9da5803 100644
--- a/drivers/staging/line6/dumprequest.c
+++ b/drivers/staging/line6/dumprequest.c
@@ -10,6 +10,9 @@
10 */ 10 */
11 11
12#include "driver.h" 12#include "driver.h"
13
14#include <linux/slab.h>
15
13#include "dumprequest.h" 16#include "dumprequest.h"
14 17
15 18
diff --git a/drivers/staging/line6/midi.c b/drivers/staging/line6/midi.c
index 6ef4455d87d..32b6ca75cad 100644
--- a/drivers/staging/line6/midi.c
+++ b/drivers/staging/line6/midi.c
@@ -12,6 +12,7 @@
12#include "driver.h" 12#include "driver.h"
13 13
14#include <linux/usb.h> 14#include <linux/usb.h>
15#include <linux/slab.h>
15 16
16#include <sound/core.h> 17#include <sound/core.h>
17#include <sound/rawmidi.h> 18#include <sound/rawmidi.h>
diff --git a/drivers/staging/line6/pcm.c b/drivers/staging/line6/pcm.c
index dd98121eb80..fbe4b083eac 100644
--- a/drivers/staging/line6/pcm.c
+++ b/drivers/staging/line6/pcm.c
@@ -11,6 +11,8 @@
11 11
12#include "driver.h" 12#include "driver.h"
13 13
14#include <linux/slab.h>
15
14#include <sound/core.h> 16#include <sound/core.h>
15#include <sound/control.h> 17#include <sound/control.h>
16#include <sound/pcm.h> 18#include <sound/pcm.h>
diff --git a/drivers/staging/line6/playback.c b/drivers/staging/line6/playback.c
index 3431f5cd285..fbcd6e150aa 100644
--- a/drivers/staging/line6/playback.c
+++ b/drivers/staging/line6/playback.c
@@ -11,6 +11,8 @@
11 11
12#include "driver.h" 12#include "driver.h"
13 13
14#include <linux/slab.h>
15
14#include <sound/core.h> 16#include <sound/core.h>
15#include <sound/pcm.h> 17#include <sound/pcm.h>
16#include <sound/pcm_params.h> 18#include <sound/pcm_params.h>
diff --git a/drivers/staging/line6/pod.c b/drivers/staging/line6/pod.c
index 685c529950e..4983f2b51cf 100644
--- a/drivers/staging/line6/pod.c
+++ b/drivers/staging/line6/pod.c
@@ -11,6 +11,8 @@
11 11
12#include "driver.h" 12#include "driver.h"
13 13
14#include <linux/slab.h>
15
14#include "audio.h" 16#include "audio.h"
15#include "capture.h" 17#include "capture.h"
16#include "control.h" 18#include "control.h"
diff --git a/drivers/staging/line6/variax.c b/drivers/staging/line6/variax.c
index 58fef82c247..28eb89983f3 100644
--- a/drivers/staging/line6/variax.c
+++ b/drivers/staging/line6/variax.c
@@ -11,6 +11,8 @@
11 11
12#include "driver.h" 12#include "driver.h"
13 13
14#include <linux/slab.h>
15
14#include "audio.h" 16#include "audio.h"
15#include "control.h" 17#include "control.h"
16#include "variax.h" 18#include "variax.h"
diff --git a/drivers/staging/netwave/netwave_cs.c b/drivers/staging/netwave/netwave_cs.c
index e936717d1f4..3875a722d12 100644
--- a/drivers/staging/netwave/netwave_cs.c
+++ b/drivers/staging/netwave/netwave_cs.c
@@ -46,7 +46,6 @@
46#include <linux/ptrace.h> 46#include <linux/ptrace.h>
47#include <linux/ioport.h> 47#include <linux/ioport.h>
48#include <linux/in.h> 48#include <linux/in.h>
49#include <linux/slab.h>
50#include <linux/string.h> 49#include <linux/string.h>
51#include <linux/timer.h> 50#include <linux/timer.h>
52#include <linux/errno.h> 51#include <linux/errno.h>
diff --git a/drivers/staging/octeon/cvmx-helper-board.c b/drivers/staging/octeon/cvmx-helper-board.c
index 3085e38a6f9..00a555b8335 100644
--- a/drivers/staging/octeon/cvmx-helper-board.c
+++ b/drivers/staging/octeon/cvmx-helper-board.c
@@ -153,6 +153,14 @@ int cvmx_helper_board_get_mii_address(int ipd_port)
153 * through switch. 153 * through switch.
154 */ 154 */
155 return -1; 155 return -1;
156
157 case CVMX_BOARD_TYPE_CUST_WSX16:
158 if (ipd_port >= 0 && ipd_port <= 3)
159 return ipd_port;
160 else if (ipd_port >= 16 && ipd_port <= 19)
161 return ipd_port - 16 + 4;
162 else
163 return -1;
156 } 164 }
157 165
158 /* Some unknown board. Somebody forgot to update this function... */ 166 /* Some unknown board. Somebody forgot to update this function... */
diff --git a/drivers/staging/octeon/ethernet-mem.c b/drivers/staging/octeon/ethernet-mem.c
index 00cc91df6b4..635bb86cdcf 100644
--- a/drivers/staging/octeon/ethernet-mem.c
+++ b/drivers/staging/octeon/ethernet-mem.c
@@ -26,6 +26,7 @@
26**********************************************************************/ 26**********************************************************************/
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/netdevice.h> 28#include <linux/netdevice.h>
29#include <linux/slab.h>
29 30
30#include <asm/octeon/octeon.h> 31#include <asm/octeon/octeon.h>
31 32
diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
index 4a2161f70c7..e50a17d8070 100644
--- a/drivers/staging/octeon/ethernet.c
+++ b/drivers/staging/octeon/ethernet.c
@@ -30,6 +30,7 @@
30#include <linux/netdevice.h> 30#include <linux/netdevice.h>
31#include <linux/etherdevice.h> 31#include <linux/etherdevice.h>
32#include <linux/phy.h> 32#include <linux/phy.h>
33#include <linux/slab.h>
33 34
34#include <net/dst.h> 35#include <net/dst.h>
35 36
diff --git a/drivers/staging/otus/ioctl.c b/drivers/staging/otus/ioctl.c
index 8c47b1a6862..84be4b2cd69 100644
--- a/drivers/staging/otus/ioctl.c
+++ b/drivers/staging/otus/ioctl.c
@@ -23,6 +23,7 @@
23/* Platform dependent. */ 23/* Platform dependent. */
24/* */ 24/* */
25/************************************************************************/ 25/************************************************************************/
26#include <linux/slab.h>
26#include <linux/module.h> 27#include <linux/module.h>
27#include <linux/if_arp.h> 28#include <linux/if_arp.h>
28#include <linux/uaccess.h> 29#include <linux/uaccess.h>
diff --git a/drivers/staging/otus/usbdrv.c b/drivers/staging/otus/usbdrv.c
index 5e6a12037b1..0ce65b5b945 100644
--- a/drivers/staging/otus/usbdrv.c
+++ b/drivers/staging/otus/usbdrv.c
@@ -38,6 +38,7 @@
38 38
39#include "linux/netlink.h" 39#include "linux/netlink.h"
40#include "linux/rtnetlink.h" 40#include "linux/rtnetlink.h"
41#include "linux/slab.h"
41 42
42#include <net/iw_handler.h> 43#include <net/iw_handler.h>
43 44
diff --git a/drivers/staging/otus/usbdrv.h b/drivers/staging/otus/usbdrv.h
index 330d1b95cb8..7e66c2d72a6 100644
--- a/drivers/staging/otus/usbdrv.h
+++ b/drivers/staging/otus/usbdrv.h
@@ -38,6 +38,7 @@
38#include <linux/uaccess.h> 38#include <linux/uaccess.h>
39#include <linux/wireless.h> 39#include <linux/wireless.h>
40#include <linux/if_arp.h> 40#include <linux/if_arp.h>
41#include <linux/slab.h>
41#include <linux/io.h> 42#include <linux/io.h>
42 43
43#include "zdcompat.h" 44#include "zdcompat.h"
diff --git a/drivers/staging/otus/wrap_mem.c b/drivers/staging/otus/wrap_mem.c
index 47cbce1346a..b0037568e87 100644
--- a/drivers/staging/otus/wrap_mem.c
+++ b/drivers/staging/otus/wrap_mem.c
@@ -27,6 +27,7 @@
27#include "usbdrv.h" 27#include "usbdrv.h"
28 28
29#include <linux/netlink.h> 29#include <linux/netlink.h>
30#include <linux/slab.h>
30#include <net/iw_handler.h> 31#include <net/iw_handler.h>
31 32
32/* Memory management */ 33/* Memory management */
diff --git a/drivers/staging/otus/wrap_pkt.c b/drivers/staging/otus/wrap_pkt.c
index a2f5cb1f529..5ecf38e355a 100644
--- a/drivers/staging/otus/wrap_pkt.c
+++ b/drivers/staging/otus/wrap_pkt.c
@@ -28,6 +28,7 @@
28#include "usbdrv.h" 28#include "usbdrv.h"
29 29
30#include <linux/netlink.h> 30#include <linux/netlink.h>
31#include <linux/gfp.h>
31#include <net/iw_handler.h> 32#include <net/iw_handler.h>
32 33
33 34
diff --git a/drivers/staging/otus/wrap_usb.c b/drivers/staging/otus/wrap_usb.c
index 6b336ede886..93459cadc47 100644
--- a/drivers/staging/otus/wrap_usb.c
+++ b/drivers/staging/otus/wrap_usb.c
@@ -28,6 +28,7 @@
28#include "usbdrv.h" 28#include "usbdrv.h"
29 29
30#include <linux/netlink.h> 30#include <linux/netlink.h>
31#include <linux/slab.h>
31#include <net/iw_handler.h> 32#include <net/iw_handler.h>
32 33
33extern void zfLnxInitUsbTxQ(zdev_t *dev); 34extern void zfLnxInitUsbTxQ(zdev_t *dev);
diff --git a/drivers/staging/otus/wwrap.c b/drivers/staging/otus/wwrap.c
index 53d2a45d55f..a74f7eea56e 100644
--- a/drivers/staging/otus/wwrap.c
+++ b/drivers/staging/otus/wwrap.c
@@ -26,6 +26,7 @@
26#include "usbdrv.h" 26#include "usbdrv.h"
27 27
28#include <linux/netlink.h> 28#include <linux/netlink.h>
29#include <linux/slab.h>
29#include <net/iw_handler.h> 30#include <net/iw_handler.h>
30 31
31extern void zfiRecv80211(zdev_t* dev, zbuf_t* buf, struct zsAdditionInfo* addInfo); 32extern void zfiRecv80211(zdev_t* dev, zbuf_t* buf, struct zsAdditionInfo* addInfo);
diff --git a/drivers/staging/otus/zdusb.c b/drivers/staging/otus/zdusb.c
index 4cd9b7f5a88..bb89d85a4c7 100644
--- a/drivers/staging/otus/zdusb.c
+++ b/drivers/staging/otus/zdusb.c
@@ -29,6 +29,7 @@
29#endif 29#endif
30 30
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/slab.h>
32#include <linux/usb.h> 33#include <linux/usb.h>
33 34
34#include "usbdrv.h" 35#include "usbdrv.h"
diff --git a/drivers/staging/poch/poch.c b/drivers/staging/poch/poch.c
index 9095158fb1b..f940a34c1a0 100644
--- a/drivers/staging/poch/poch.c
+++ b/drivers/staging/poch/poch.c
@@ -21,6 +21,7 @@
21#include <linux/ioctl.h> 21#include <linux/ioctl.h>
22#include <linux/io.h> 22#include <linux/io.h>
23#include <linux/sched.h> 23#include <linux/sched.h>
24#include <linux/slab.h>
24 25
25#include "poch.h" 26#include "poch.h"
26 27
diff --git a/drivers/staging/pohmelfs/config.c b/drivers/staging/pohmelfs/config.c
index 5d04bf5b021..eed0e5545a5 100644
--- a/drivers/staging/pohmelfs/config.c
+++ b/drivers/staging/pohmelfs/config.c
@@ -20,6 +20,7 @@
20#include <linux/mutex.h> 20#include <linux/mutex.h>
21#include <linux/string.h> 21#include <linux/string.h>
22#include <linux/in.h> 22#include <linux/in.h>
23#include <linux/slab.h>
23 24
24#include "netfs.h" 25#include "netfs.h"
25 26
diff --git a/drivers/staging/pohmelfs/dir.c b/drivers/staging/pohmelfs/dir.c
index aacd25bfb0c..79819f07bfb 100644
--- a/drivers/staging/pohmelfs/dir.c
+++ b/drivers/staging/pohmelfs/dir.c
@@ -17,6 +17,7 @@
17#include <linux/fs.h> 17#include <linux/fs.h>
18#include <linux/jhash.h> 18#include <linux/jhash.h>
19#include <linux/namei.h> 19#include <linux/namei.h>
20#include <linux/slab.h>
20#include <linux/pagemap.h> 21#include <linux/pagemap.h>
21 22
22#include "netfs.h" 23#include "netfs.h"
diff --git a/drivers/staging/pohmelfs/lock.c b/drivers/staging/pohmelfs/lock.c
index 22fef18cae9..6710114cd42 100644
--- a/drivers/staging/pohmelfs/lock.c
+++ b/drivers/staging/pohmelfs/lock.c
@@ -17,7 +17,6 @@
17#include <linux/backing-dev.h> 17#include <linux/backing-dev.h>
18#include <linux/fs.h> 18#include <linux/fs.h>
19#include <linux/fsnotify.h> 19#include <linux/fsnotify.h>
20#include <linux/slab.h>
21#include <linux/mempool.h> 20#include <linux/mempool.h>
22 21
23#include "netfs.h" 22#include "netfs.h"
diff --git a/drivers/staging/pohmelfs/net.c b/drivers/staging/pohmelfs/net.c
index af7f262e68c..4a86f0b1ea8 100644
--- a/drivers/staging/pohmelfs/net.c
+++ b/drivers/staging/pohmelfs/net.c
@@ -20,6 +20,7 @@
20#include <linux/kthread.h> 20#include <linux/kthread.h>
21#include <linux/pagemap.h> 21#include <linux/pagemap.h>
22#include <linux/poll.h> 22#include <linux/poll.h>
23#include <linux/slab.h>
23#include <linux/swap.h> 24#include <linux/swap.h>
24#include <linux/syscalls.h> 25#include <linux/syscalls.h>
25#include <linux/vmalloc.h> 26#include <linux/vmalloc.h>
diff --git a/drivers/staging/pohmelfs/path_entry.c b/drivers/staging/pohmelfs/path_entry.c
index 3bad888ced1..cdc4dd50d63 100644
--- a/drivers/staging/pohmelfs/path_entry.c
+++ b/drivers/staging/pohmelfs/path_entry.c
@@ -14,7 +14,6 @@
14 */ 14 */
15 15
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/slab.h>
18#include <linux/fs.h> 17#include <linux/fs.h>
19#include <linux/ktime.h> 18#include <linux/ktime.h>
20#include <linux/fs_struct.h> 19#include <linux/fs_struct.h>
diff --git a/drivers/staging/ramzswap/ramzswap_drv.c b/drivers/staging/ramzswap/ramzswap_drv.c
index 5e422e254ee..ee5eb12b928 100644
--- a/drivers/staging/ramzswap/ramzswap_drv.c
+++ b/drivers/staging/ramzswap/ramzswap_drv.c
@@ -23,6 +23,7 @@
23#include <linux/device.h> 23#include <linux/device.h>
24#include <linux/genhd.h> 24#include <linux/genhd.h>
25#include <linux/highmem.h> 25#include <linux/highmem.h>
26#include <linux/slab.h>
26#include <linux/lzo.h> 27#include <linux/lzo.h>
27#include <linux/string.h> 28#include <linux/string.h>
28#include <linux/swap.h> 29#include <linux/swap.h>
diff --git a/drivers/staging/rt2860/pci_main_dev.c b/drivers/staging/rt2860/pci_main_dev.c
index 6af43041907..e665d862281 100644
--- a/drivers/staging/rt2860/pci_main_dev.c
+++ b/drivers/staging/rt2860/pci_main_dev.c
@@ -37,6 +37,7 @@
37 37
38#include "rt_config.h" 38#include "rt_config.h"
39#include <linux/pci.h> 39#include <linux/pci.h>
40#include <linux/slab.h>
40 41
41/* Following information will be show when you run 'modinfo' */ 42/* Following information will be show when you run 'modinfo' */
42/* *** If you have a solution for the bug in current version of driver, please mail to me. */ 43/* *** If you have a solution for the bug in current version of driver, please mail to me. */
diff --git a/drivers/staging/rt2860/rt_linux.c b/drivers/staging/rt2860/rt_linux.c
index b5c78aecf5e..fd9a2072139 100644
--- a/drivers/staging/rt2860/rt_linux.c
+++ b/drivers/staging/rt2860/rt_linux.c
@@ -27,6 +27,7 @@
27 27
28#include <linux/firmware.h> 28#include <linux/firmware.h>
29#include <linux/sched.h> 29#include <linux/sched.h>
30#include <linux/slab.h>
30#include "rt_config.h" 31#include "rt_config.h"
31 32
32unsigned long RTDebugLevel = RT_DEBUG_ERROR; 33unsigned long RTDebugLevel = RT_DEBUG_ERROR;
diff --git a/drivers/staging/rt2860/usb_main_dev.c b/drivers/staging/rt2860/usb_main_dev.c
index 1873a79bb03..740db0c1ac0 100644
--- a/drivers/staging/rt2860/usb_main_dev.c
+++ b/drivers/staging/rt2860/usb_main_dev.c
@@ -63,6 +63,7 @@ struct usb_device_id rtusb_usb_id[] = {
63 {USB_DEVICE(0x07D1, 0x3C11)}, /* D-Link */ 63 {USB_DEVICE(0x07D1, 0x3C11)}, /* D-Link */
64 {USB_DEVICE(0x14B2, 0x3C07)}, /* AL */ 64 {USB_DEVICE(0x14B2, 0x3C07)}, /* AL */
65 {USB_DEVICE(0x050D, 0x8053)}, /* Belkin */ 65 {USB_DEVICE(0x050D, 0x8053)}, /* Belkin */
66 {USB_DEVICE(0x050D, 0x825B)}, /* Belkin */
66 {USB_DEVICE(0x14B2, 0x3C23)}, /* Airlink */ 67 {USB_DEVICE(0x14B2, 0x3C23)}, /* Airlink */
67 {USB_DEVICE(0x14B2, 0x3C27)}, /* Airlink */ 68 {USB_DEVICE(0x14B2, 0x3C27)}, /* Airlink */
68 {USB_DEVICE(0x07AA, 0x002F)}, /* Corega */ 69 {USB_DEVICE(0x07AA, 0x002F)}, /* Corega */
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
index c2f472ee6eb..be2d17f60c3 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
@@ -18,6 +18,7 @@
18 18
19#include <linux/random.h> 19#include <linux/random.h>
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include <linux/slab.h>
21#include <linux/version.h> 22#include <linux/version.h>
22#include <asm/uaccess.h> 23#include <asm/uaccess.h>
23 24
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c
index bd5e77bf716..c5b80f9c32c 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c
@@ -31,6 +31,7 @@
31******************************************************************************/ 31******************************************************************************/
32#include <linux/wireless.h> 32#include <linux/wireless.h>
33#include <linux/kmod.h> 33#include <linux/kmod.h>
34#include <linux/slab.h>
34#include <linux/module.h> 35#include <linux/module.h>
35 36
36#include "ieee80211.h" 37#include "ieee80211.h"
diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c
index b1757acabed..55d12e3271d 100644
--- a/drivers/staging/rtl8187se/r8180_core.c
+++ b/drivers/staging/rtl8187se/r8180_core.c
@@ -30,6 +30,7 @@
30#undef RX_DONT_PASS_UL 30#undef RX_DONT_PASS_UL
31#undef DUMMY_RX 31#undef DUMMY_RX
32 32
33#include <linux/slab.h>
33#include <linux/syscalls.h> 34#include <linux/syscalls.h>
34#include <linux/eeprom_93cx6.h> 35#include <linux/eeprom_93cx6.h>
35 36
diff --git a/drivers/staging/rtl8192e/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192e/ieee80211/ieee80211_softmac.c
index ea96c495693..d1d7b086675 100644
--- a/drivers/staging/rtl8192e/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8192e/ieee80211/ieee80211_softmac.c
@@ -18,6 +18,7 @@
18 18
19#include <linux/random.h> 19#include <linux/random.h>
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include <linux/slab.h>
21#include <linux/version.h> 22#include <linux/version.h>
22#include <asm/uaccess.h> 23#include <asm/uaccess.h>
23#ifdef ENABLE_DOT11D 24#ifdef ENABLE_DOT11D
diff --git a/drivers/staging/rtl8192e/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192e/ieee80211/ieee80211_wx.c
index a3302d5e01a..de57967b968 100644
--- a/drivers/staging/rtl8192e/ieee80211/ieee80211_wx.c
+++ b/drivers/staging/rtl8192e/ieee80211/ieee80211_wx.c
@@ -32,6 +32,7 @@
32#include <linux/wireless.h> 32#include <linux/wireless.h>
33#include <linux/version.h> 33#include <linux/version.h>
34#include <linux/kmod.h> 34#include <linux/kmod.h>
35#include <linux/slab.h>
35#include <linux/module.h> 36#include <linux/module.h>
36 37
37#include "ieee80211.h" 38#include "ieee80211.h"
diff --git a/drivers/staging/rtl8192e/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192e/ieee80211/rtl819x_TSProc.c
index e2cbfd3aa00..e8699616fad 100644
--- a/drivers/staging/rtl8192e/ieee80211/rtl819x_TSProc.c
+++ b/drivers/staging/rtl8192e/ieee80211/rtl819x_TSProc.c
@@ -1,5 +1,6 @@
1#include "ieee80211.h" 1#include "ieee80211.h"
2#include <linux/etherdevice.h> 2#include <linux/etherdevice.h>
3#include <linux/slab.h>
3#include "rtl819x_TS.h" 4#include "rtl819x_TS.h"
4 5
5#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 6#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
diff --git a/drivers/staging/rtl8192e/r8192E_core.c b/drivers/staging/rtl8192e/r8192E_core.c
index 886105db8b7..bb7e1ef28d3 100644
--- a/drivers/staging/rtl8192e/r8192E_core.c
+++ b/drivers/staging/rtl8192e/r8192E_core.c
@@ -47,6 +47,7 @@
47 47
48//#define CONFIG_RTL8192_IO_MAP 48//#define CONFIG_RTL8192_IO_MAP
49#include <linux/vmalloc.h> 49#include <linux/vmalloc.h>
50#include <linux/slab.h>
50#include <asm/uaccess.h> 51#include <asm/uaccess.h>
51#include "r8192E_hw.h" 52#include "r8192E_hw.h"
52#include "r8192E.h" 53#include "r8192E.h"
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192su/ieee80211/ieee80211_softmac.c
index 9d8cb0e575d..84a4e23b60b 100644
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8192su/ieee80211/ieee80211_softmac.c
@@ -18,6 +18,7 @@
18 18
19#include <linux/random.h> 19#include <linux/random.h>
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include <linux/slab.h>
21#include <linux/version.h> 22#include <linux/version.h>
22#include <asm/uaccess.h> 23#include <asm/uaccess.h>
23#include "dot11d.h" 24#include "dot11d.h"
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192su/ieee80211/ieee80211_wx.c
index 122f8004904..727cc552c5e 100644
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211_wx.c
+++ b/drivers/staging/rtl8192su/ieee80211/ieee80211_wx.c
@@ -31,6 +31,7 @@
31******************************************************************************/ 31******************************************************************************/
32#include <linux/wireless.h> 32#include <linux/wireless.h>
33#include <linux/kmod.h> 33#include <linux/kmod.h>
34#include <linux/slab.h>
34#include <linux/module.h> 35#include <linux/module.h>
35 36
36#include "ieee80211.h" 37#include "ieee80211.h"
diff --git a/drivers/staging/rtl8192su/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192su/ieee80211/rtl819x_TSProc.c
index 60cf1f8781c..38468c53967 100644
--- a/drivers/staging/rtl8192su/ieee80211/rtl819x_TSProc.c
+++ b/drivers/staging/rtl8192su/ieee80211/rtl819x_TSProc.c
@@ -1,5 +1,6 @@
1#include "ieee80211.h" 1#include "ieee80211.h"
2#include <linux/etherdevice.h> 2#include <linux/etherdevice.h>
3#include <linux/slab.h>
3#include "rtl819x_TS.h" 4#include "rtl819x_TS.h"
4 5
5void TsSetupTimeOut(unsigned long data) 6void TsSetupTimeOut(unsigned long data)
diff --git a/drivers/staging/rtl8192su/r8192U_core.c b/drivers/staging/rtl8192su/r8192U_core.c
index 7d0305cc210..04d9b85f3d4 100644
--- a/drivers/staging/rtl8192su/r8192U_core.c
+++ b/drivers/staging/rtl8192su/r8192U_core.c
@@ -25,6 +25,7 @@
25 */ 25 */
26 26
27#include <linux/vmalloc.h> 27#include <linux/vmalloc.h>
28#include <linux/slab.h>
28 29
29#undef LOOP_TEST 30#undef LOOP_TEST
30#undef DUMP_RX 31#undef DUMP_RX
@@ -112,14 +113,17 @@ u32 rt_global_debug_component = \
112 113
113static const struct usb_device_id rtl8192_usb_id_tbl[] = { 114static const struct usb_device_id rtl8192_usb_id_tbl[] = {
114 /* Realtek */ 115 /* Realtek */
116 {USB_DEVICE(0x0bda, 0x8171)},
115 {USB_DEVICE(0x0bda, 0x8192)}, 117 {USB_DEVICE(0x0bda, 0x8192)},
116 {USB_DEVICE(0x0bda, 0x8709)}, 118 {USB_DEVICE(0x0bda, 0x8709)},
117 /* Corega */ 119 /* Corega */
118 {USB_DEVICE(0x07aa, 0x0043)}, 120 {USB_DEVICE(0x07aa, 0x0043)},
119 /* Belkin */ 121 /* Belkin */
120 {USB_DEVICE(0x050d, 0x805E)}, 122 {USB_DEVICE(0x050d, 0x805E)},
123 {USB_DEVICE(0x050d, 0x815F)}, /* Belkin F5D8053 v6 */
121 /* Sitecom */ 124 /* Sitecom */
122 {USB_DEVICE(0x0df6, 0x0031)}, 125 {USB_DEVICE(0x0df6, 0x0031)},
126 {USB_DEVICE(0x0df6, 0x004b)}, /* WL-349 */
123 /* EnGenius */ 127 /* EnGenius */
124 {USB_DEVICE(0x1740, 0x9201)}, 128 {USB_DEVICE(0x1740, 0x9201)},
125 /* Dlink */ 129 /* Dlink */
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
index 27d925712cd..d54e3a77423 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
@@ -18,6 +18,7 @@
18 18
19#include <linux/random.h> 19#include <linux/random.h>
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include <linux/slab.h>
21#include <linux/version.h> 22#include <linux/version.h>
22#include <asm/uaccess.h> 23#include <asm/uaccess.h>
23#ifdef ENABLE_DOT11D 24#ifdef ENABLE_DOT11D
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
index c0b2c02b0ac..750e94e1711 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
@@ -32,6 +32,7 @@
32#include <linux/wireless.h> 32#include <linux/wireless.h>
33#include <linux/version.h> 33#include <linux/version.h>
34#include <linux/kmod.h> 34#include <linux/kmod.h>
35#include <linux/slab.h>
35#include <linux/module.h> 36#include <linux/module.h>
36 37
37#include "ieee80211.h" 38#include "ieee80211.h"
diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
index d1275e887f0..451120ff213 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
@@ -1,5 +1,6 @@
1#include "ieee80211.h" 1#include "ieee80211.h"
2#include <linux/etherdevice.h> 2#include <linux/etherdevice.h>
3#include <linux/slab.h>
3#include "rtl819x_TS.h" 4#include "rtl819x_TS.h"
4 5
5void TsSetupTimeOut(unsigned long data) 6void TsSetupTimeOut(unsigned long data)
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index f1e085ba1cf..68ebb025677 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -70,6 +70,7 @@ double __extendsfdf2(float a) {return a;}
70#include "r8192U_dm.h" 70#include "r8192U_dm.h"
71//#include "r8192xU_phyreg.h" 71//#include "r8192xU_phyreg.h"
72#include <linux/usb.h> 72#include <linux/usb.h>
73#include <linux/slab.h>
73// FIXME: check if 2.6.7 is ok 74// FIXME: check if 2.6.7 is ok
74 75
75#ifdef CONFIG_RTL8192_PM 76#ifdef CONFIG_RTL8192_PM
diff --git a/drivers/staging/sep/sep_driver.c b/drivers/staging/sep/sep_driver.c
index 265de7949a7..88880734921 100644
--- a/drivers/staging/sep/sep_driver.c
+++ b/drivers/staging/sep/sep_driver.c
@@ -42,6 +42,7 @@
42#include <linux/sched.h> 42#include <linux/sched.h>
43#include <linux/pci.h> 43#include <linux/pci.h>
44#include <linux/firmware.h> 44#include <linux/firmware.h>
45#include <linux/slab.h>
45#include <asm/ioctl.h> 46#include <asm/ioctl.h>
46#include <linux/ioport.h> 47#include <linux/ioport.h>
47#include <asm/io.h> 48#include <asm/io.h>
diff --git a/drivers/staging/sm7xx/smtcfb.c b/drivers/staging/sm7xx/smtcfb.c
index 9c82a1a81cc..8d7261c052e 100644
--- a/drivers/staging/sm7xx/smtcfb.c
+++ b/drivers/staging/sm7xx/smtcfb.c
@@ -34,6 +34,7 @@
34#include <linux/fb.h> 34#include <linux/fb.h>
35#include <linux/pci.h> 35#include <linux/pci.h>
36#include <linux/init.h> 36#include <linux/init.h>
37#include <linux/slab.h>
37#include <linux/uaccess.h> 38#include <linux/uaccess.h>
38#include <linux/console.h> 39#include <linux/console.h>
39#include <linux/screen_info.h> 40#include <linux/screen_info.h>
diff --git a/drivers/staging/strip/strip.c b/drivers/staging/strip/strip.c
index 698aade79d4..c976c6b4d28 100644
--- a/drivers/staging/strip/strip.c
+++ b/drivers/staging/strip/strip.c
@@ -107,6 +107,7 @@ static const char StripVersion[] = "1.3A-STUART.CHESHIRE";
107#include <linux/serialP.h> 107#include <linux/serialP.h>
108#include <linux/rcupdate.h> 108#include <linux/rcupdate.h>
109#include <linux/compat.h> 109#include <linux/compat.h>
110#include <linux/slab.h>
110#include <net/arp.h> 111#include <net/arp.h>
111#include <net/net_namespace.h> 112#include <net/net_namespace.h>
112 113
diff --git a/drivers/staging/udlfb/udlfb.c b/drivers/staging/udlfb/udlfb.c
index 8f6223c8303..a78ade0dc68 100644
--- a/drivers/staging/udlfb/udlfb.c
+++ b/drivers/staging/udlfb/udlfb.c
@@ -24,6 +24,7 @@
24#include <linux/mm.h> 24#include <linux/mm.h>
25#include <linux/fb.h> 25#include <linux/fb.h>
26#include <linux/vmalloc.h> 26#include <linux/vmalloc.h>
27#include <linux/slab.h>
27 28
28#include "udlfb.h" 29#include "udlfb.h"
29 30
diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c
index 173b018c56d..3f95605427a 100644
--- a/drivers/staging/usbip/stub_dev.c
+++ b/drivers/staging/usbip/stub_dev.c
@@ -17,6 +17,8 @@
17 * USA. 17 * USA.
18 */ 18 */
19 19
20#include <linux/slab.h>
21
20#include "usbip_common.h" 22#include "usbip_common.h"
21#include "stub.h" 23#include "stub.h"
22 24
diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c
index ba1678fa631..6665cefe573 100644
--- a/drivers/staging/usbip/stub_main.c
+++ b/drivers/staging/usbip/stub_main.c
@@ -17,6 +17,7 @@
17 * USA. 17 * USA.
18 */ 18 */
19 19
20#include <linux/slab.h>
20 21
21#include "usbip_common.h" 22#include "usbip_common.h"
22#include "stub.h" 23#include "stub.h"
diff --git a/drivers/staging/usbip/stub_rx.c b/drivers/staging/usbip/stub_rx.c
index 815fb7cc3b2..bc267408667 100644
--- a/drivers/staging/usbip/stub_rx.c
+++ b/drivers/staging/usbip/stub_rx.c
@@ -17,6 +17,8 @@
17 * USA. 17 * USA.
18 */ 18 */
19 19
20#include <linux/slab.h>
21
20#include "usbip_common.h" 22#include "usbip_common.h"
21#include "stub.h" 23#include "stub.h"
22#include "../../usb/core/hcd.h" 24#include "../../usb/core/hcd.h"
diff --git a/drivers/staging/usbip/stub_tx.c b/drivers/staging/usbip/stub_tx.c
index e2ab4f3fdac..d7136e2c86f 100644
--- a/drivers/staging/usbip/stub_tx.c
+++ b/drivers/staging/usbip/stub_tx.c
@@ -17,6 +17,8 @@
17 * USA. 17 * USA.
18 */ 18 */
19 19
20#include <linux/slab.h>
21
20#include "usbip_common.h" 22#include "usbip_common.h"
21#include "stub.h" 23#include "stub.h"
22 24
diff --git a/drivers/staging/usbip/usbip_common.c b/drivers/staging/usbip/usbip_common.c
index 7a45da8f956..e3fa4216c1c 100644
--- a/drivers/staging/usbip/usbip_common.c
+++ b/drivers/staging/usbip/usbip_common.c
@@ -23,6 +23,7 @@
23#include <linux/tcp.h> 23#include <linux/tcp.h>
24#include <linux/in.h> 24#include <linux/in.h>
25#include <linux/kthread.h> 25#include <linux/kthread.h>
26#include <linux/slab.h>
26#include "usbip_common.h" 27#include "usbip_common.h"
27 28
28/* version information */ 29/* version information */
diff --git a/drivers/staging/usbip/usbip_event.c b/drivers/staging/usbip/usbip_event.c
index 6da1021e8a6..a2566f1075d 100644
--- a/drivers/staging/usbip/usbip_event.c
+++ b/drivers/staging/usbip/usbip_event.c
@@ -117,6 +117,9 @@ void usbip_stop_eh(struct usbip_device *ud)
117{ 117{
118 struct usbip_task *eh = &ud->eh; 118 struct usbip_task *eh = &ud->eh;
119 119
120 if (eh->thread == current)
121 return; /* do not wait for myself */
122
120 wait_for_completion(&eh->thread_done); 123 wait_for_completion(&eh->thread_done);
121 usbip_dbg_eh("usbip_eh has finished\n"); 124 usbip_dbg_eh("usbip_eh has finished\n");
122} 125}
diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
index ef4371358db..0b1766122d3 100644
--- a/drivers/staging/usbip/vhci_hcd.c
+++ b/drivers/staging/usbip/vhci_hcd.c
@@ -17,6 +17,7 @@
17 * USA. 17 * USA.
18 */ 18 */
19 19
20#include <linux/slab.h>
20 21
21#include "usbip_common.h" 22#include "usbip_common.h"
22#include "vhci.h" 23#include "vhci.h"
diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
index 7636d86c238..8147d7202b2 100644
--- a/drivers/staging/usbip/vhci_rx.c
+++ b/drivers/staging/usbip/vhci_rx.c
@@ -17,6 +17,8 @@
17 * USA. 17 * USA.
18 */ 18 */
19 19
20#include <linux/slab.h>
21
20#include "usbip_common.h" 22#include "usbip_common.h"
21#include "vhci.h" 23#include "vhci.h"
22 24
diff --git a/drivers/staging/usbip/vhci_tx.c b/drivers/staging/usbip/vhci_tx.c
index 7a00eb44b79..b71b4c2fbd8 100644
--- a/drivers/staging/usbip/vhci_tx.c
+++ b/drivers/staging/usbip/vhci_tx.c
@@ -17,6 +17,8 @@
17 * USA. 17 * USA.
18 */ 18 */
19 19
20#include <linux/slab.h>
21
20#include "usbip_common.h" 22#include "usbip_common.h"
21#include "vhci.h" 23#include "vhci.h"
22 24
diff --git a/drivers/staging/vme/bridges/vme_ca91cx42.c b/drivers/staging/vme/bridges/vme_ca91cx42.c
index 2795ff2411e..b159ea58adf 100644
--- a/drivers/staging/vme/bridges/vme_ca91cx42.c
+++ b/drivers/staging/vme/bridges/vme_ca91cx42.c
@@ -25,6 +25,7 @@
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/spinlock.h> 26#include <linux/spinlock.h>
27#include <linux/sched.h> 27#include <linux/sched.h>
28#include <linux/slab.h>
28#include <asm/time.h> 29#include <asm/time.h>
29#include <asm/io.h> 30#include <asm/io.h>
30#include <asm/uaccess.h> 31#include <asm/uaccess.h>
diff --git a/drivers/staging/vme/bridges/vme_tsi148.c b/drivers/staging/vme/bridges/vme_tsi148.c
index faf652edb70..783051f59f1 100644
--- a/drivers/staging/vme/bridges/vme_tsi148.c
+++ b/drivers/staging/vme/bridges/vme_tsi148.c
@@ -25,6 +25,7 @@
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/spinlock.h> 26#include <linux/spinlock.h>
27#include <linux/sched.h> 27#include <linux/sched.h>
28#include <linux/slab.h>
28#include <asm/time.h> 29#include <asm/time.h>
29#include <asm/io.h> 30#include <asm/io.h>
30#include <asm/uaccess.h> 31#include <asm/uaccess.h>
@@ -2454,9 +2455,10 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2454 dev_info(&pdev->dev, "VME Write and flush and error check is %s\n", 2455 dev_info(&pdev->dev, "VME Write and flush and error check is %s\n",
2455 err_chk ? "enabled" : "disabled"); 2456 err_chk ? "enabled" : "disabled");
2456 2457
2457 if (tsi148_crcsr_init(tsi148_bridge, pdev)) 2458 if (tsi148_crcsr_init(tsi148_bridge, pdev)) {
2458 dev_err(&pdev->dev, "CR/CSR configuration failed.\n"); 2459 dev_err(&pdev->dev, "CR/CSR configuration failed.\n");
2459 goto err_crcsr; 2460 goto err_crcsr;
2461 }
2460 2462
2461 retval = vme_register_bridge(tsi148_bridge); 2463 retval = vme_register_bridge(tsi148_bridge);
2462 if (retval != 0) { 2464 if (retval != 0) {
diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c
index c60c80fb241..1ab9a985dfb 100644
--- a/drivers/staging/vme/devices/vme_user.c
+++ b/drivers/staging/vme/devices/vme_user.c
@@ -28,6 +28,7 @@
28#include <linux/pagemap.h> 28#include <linux/pagemap.h>
29#include <linux/pci.h> 29#include <linux/pci.h>
30#include <linux/semaphore.h> 30#include <linux/semaphore.h>
31#include <linux/slab.h>
31#include <linux/spinlock.h> 32#include <linux/spinlock.h>
32#include <linux/syscalls.h> 33#include <linux/syscalls.h>
33#include <linux/types.h> 34#include <linux/types.h>
diff --git a/drivers/staging/vme/vme.c b/drivers/staging/vme/vme.c
index d6d84ebeeec..934283a19ca 100644
--- a/drivers/staging/vme/vme.c
+++ b/drivers/staging/vme/vme.c
@@ -29,6 +29,7 @@
29#include <linux/syscalls.h> 29#include <linux/syscalls.h>
30#include <linux/mutex.h> 30#include <linux/mutex.h>
31#include <linux/spinlock.h> 31#include <linux/spinlock.h>
32#include <linux/slab.h>
32 33
33#include "vme.h" 34#include "vme.h"
34#include "vme_bridge.h" 35#include "vme_bridge.h"
diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
index 1d643653a7e..e40a2e990f4 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -84,6 +84,7 @@
84#include "iowpa.h" 84#include "iowpa.h"
85#include <linux/delay.h> 85#include <linux/delay.h>
86#include <linux/kthread.h> 86#include <linux/kthread.h>
87#include <linux/slab.h>
87 88
88//#define DEBUG 89//#define DEBUG
89/*--------------------- Static Definitions -------------------------*/ 90/*--------------------- Static Definitions -------------------------*/
diff --git a/drivers/staging/winbond/wb35reg.c b/drivers/staging/winbond/wb35reg.c
index f5608ad9ed0..1b93547ff5b 100644
--- a/drivers/staging/winbond/wb35reg.c
+++ b/drivers/staging/winbond/wb35reg.c
@@ -2,6 +2,7 @@
2#include "wb35reg_f.h" 2#include "wb35reg_f.h"
3 3
4#include <linux/usb.h> 4#include <linux/usb.h>
5#include <linux/slab.h>
5 6
6extern void phy_calibration_winbond(struct hw_data *phw_data, u32 frequency); 7extern void phy_calibration_winbond(struct hw_data *phw_data, u32 frequency);
7 8
diff --git a/drivers/staging/winbond/wb35rx.c b/drivers/staging/winbond/wb35rx.c
index 4d41f6c3563..d7b57e62db0 100644
--- a/drivers/staging/winbond/wb35rx.c
+++ b/drivers/staging/winbond/wb35rx.c
@@ -9,6 +9,7 @@
9// 9//
10//============================================================================ 10//============================================================================
11#include <linux/usb.h> 11#include <linux/usb.h>
12#include <linux/slab.h>
12 13
13#include "core.h" 14#include "core.h"
14#include "sysdef.h" 15#include "sysdef.h"
diff --git a/drivers/staging/winbond/wb35tx.c b/drivers/staging/winbond/wb35tx.c
index 5869ef473fc..bda7a913edf 100644
--- a/drivers/staging/winbond/wb35tx.c
+++ b/drivers/staging/winbond/wb35tx.c
@@ -9,6 +9,7 @@
9// 9//
10//============================================================================ 10//============================================================================
11#include <linux/usb.h> 11#include <linux/usb.h>
12#include <linux/gfp.h>
12 13
13#include "wb35tx_f.h" 14#include "wb35tx_f.h"
14#include "mds_f.h" 15#include "mds_f.h"
diff --git a/drivers/staging/wlags49_h2/wl_cs.c b/drivers/staging/wlags49_h2/wl_cs.c
index 811a8daa660..9da42e66085 100644
--- a/drivers/staging/wlags49_h2/wl_cs.c
+++ b/drivers/staging/wlags49_h2/wl_cs.c
@@ -67,7 +67,6 @@
67#include <linux/kernel.h> 67#include <linux/kernel.h>
68#include <linux/sched.h> 68#include <linux/sched.h>
69#include <linux/ptrace.h> 69#include <linux/ptrace.h>
70#include <linux/slab.h>
71#include <linux/ctype.h> 70#include <linux/ctype.h>
72#include <linux/string.h> 71#include <linux/string.h>
73#include <linux/timer.h> 72#include <linux/timer.h>
diff --git a/drivers/staging/wlags49_h2/wl_netdev.c b/drivers/staging/wlags49_h2/wl_netdev.c
index fa082d90fca..1db73ebcae2 100644
--- a/drivers/staging/wlags49_h2/wl_netdev.c
+++ b/drivers/staging/wlags49_h2/wl_netdev.c
@@ -65,6 +65,7 @@
65#include <wl_version.h> 65#include <wl_version.h>
66 66
67#include <linux/module.h> 67#include <linux/module.h>
68#include <linux/slab.h>
68#include <linux/types.h> 69#include <linux/types.h>
69#include <linux/kernel.h> 70#include <linux/kernel.h>
70// #include <linux/sched.h> 71// #include <linux/sched.h>
diff --git a/drivers/staging/wlags49_h2/wl_pci.c b/drivers/staging/wlags49_h2/wl_pci.c
index 01e4bec9fd5..6751b4bad2e 100644
--- a/drivers/staging/wlags49_h2/wl_pci.c
+++ b/drivers/staging/wlags49_h2/wl_pci.c
@@ -71,7 +71,6 @@
71#include <linux/init.h> 71#include <linux/init.h>
72#include <linux/sched.h> 72#include <linux/sched.h>
73#include <linux/ptrace.h> 73#include <linux/ptrace.h>
74#include <linux/slab.h>
75#include <linux/ctype.h> 74#include <linux/ctype.h>
76#include <linux/string.h> 75#include <linux/string.h>
77//#include <linux/timer.h> 76//#include <linux/timer.h>
diff --git a/drivers/staging/wlags49_h2/wl_priv.c b/drivers/staging/wlags49_h2/wl_priv.c
index ee610c76457..727ea8a483a 100644
--- a/drivers/staging/wlags49_h2/wl_priv.c
+++ b/drivers/staging/wlags49_h2/wl_priv.c
@@ -65,6 +65,7 @@
65 65
66#include <linux/if_arp.h> 66#include <linux/if_arp.h>
67#include <linux/ioport.h> 67#include <linux/ioport.h>
68#include <linux/slab.h>
68#include <linux/delay.h> 69#include <linux/delay.h>
69#include <asm/uaccess.h> 70#include <asm/uaccess.h>
70 71
diff --git a/drivers/staging/wlan-ng/p80211req.c b/drivers/staging/wlan-ng/p80211req.c
index c2e95f16682..e1e7bf1bf27 100644
--- a/drivers/staging/wlan-ng/p80211req.c
+++ b/drivers/staging/wlan-ng/p80211req.c
@@ -55,7 +55,6 @@
55#include <linux/sched.h> 55#include <linux/sched.h>
56#include <linux/types.h> 56#include <linux/types.h>
57#include <linux/skbuff.h> 57#include <linux/skbuff.h>
58#include <linux/slab.h>
59#include <linux/wireless.h> 58#include <linux/wireless.h>
60#include <linux/netdevice.h> 59#include <linux/netdevice.h>
61#include <linux/etherdevice.h> 60#include <linux/etherdevice.h>
diff --git a/drivers/staging/wlan-ng/p80211wep.c b/drivers/staging/wlan-ng/p80211wep.c
index ecbb15b297a..80c2d3b672b 100644
--- a/drivers/staging/wlan-ng/p80211wep.c
+++ b/drivers/staging/wlan-ng/p80211wep.c
@@ -50,7 +50,6 @@
50 50
51#include <linux/netdevice.h> 51#include <linux/netdevice.h>
52#include <linux/wireless.h> 52#include <linux/wireless.h>
53#include <linux/slab.h>
54#include <linux/random.h> 53#include <linux/random.h>
55#include <linux/kernel.h> 54#include <linux/kernel.h>
56 55
diff --git a/drivers/staging/wlan-ng/p80211wext.c b/drivers/staging/wlan-ng/p80211wext.c
index 2fa1dfa2378..83f1d6cd799 100644
--- a/drivers/staging/wlan-ng/p80211wext.c
+++ b/drivers/staging/wlan-ng/p80211wext.c
@@ -40,7 +40,6 @@
40#include <linux/kernel.h> 40#include <linux/kernel.h>
41#include <linux/sched.h> 41#include <linux/sched.h>
42#include <linux/types.h> 42#include <linux/types.h>
43#include <linux/slab.h>
44#include <linux/netdevice.h> 43#include <linux/netdevice.h>
45#include <linux/etherdevice.h> 44#include <linux/etherdevice.h>
46#include <linux/wireless.h> 45#include <linux/wireless.h>
diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c
index 4be54cea6ad..d383ea85c9b 100644
--- a/drivers/staging/wlan-ng/prism2fw.c
+++ b/drivers/staging/wlan-ng/prism2fw.c
@@ -48,6 +48,7 @@
48/*================================================================*/ 48/*================================================================*/
49/* System Includes */ 49/* System Includes */
50#include <linux/ihex.h> 50#include <linux/ihex.h>
51#include <linux/slab.h>
51 52
52/*================================================================*/ 53/*================================================================*/
53/* Local Constants */ 54/* Local Constants */
diff --git a/drivers/staging/wlan-ng/prism2mgmt.c b/drivers/staging/wlan-ng/prism2mgmt.c
index ad163da72ae..4d1cdfc3542 100644
--- a/drivers/staging/wlan-ng/prism2mgmt.c
+++ b/drivers/staging/wlan-ng/prism2mgmt.c
@@ -63,7 +63,6 @@
63#include <linux/wait.h> 63#include <linux/wait.h>
64#include <linux/sched.h> 64#include <linux/sched.h>
65#include <linux/types.h> 65#include <linux/types.h>
66#include <linux/slab.h>
67#include <linux/wireless.h> 66#include <linux/wireless.h>
68#include <linux/netdevice.h> 67#include <linux/netdevice.h>
69#include <linux/delay.h> 68#include <linux/delay.h>
diff --git a/drivers/staging/wlan-ng/prism2mib.c b/drivers/staging/wlan-ng/prism2mib.c
index 98a5d58c3f5..0b0ec9c59a5 100644
--- a/drivers/staging/wlan-ng/prism2mib.c
+++ b/drivers/staging/wlan-ng/prism2mib.c
@@ -54,7 +54,6 @@
54#include <linux/kernel.h> 54#include <linux/kernel.h>
55#include <linux/sched.h> 55#include <linux/sched.h>
56#include <linux/types.h> 56#include <linux/types.h>
57#include <linux/slab.h>
58#include <linux/wireless.h> 57#include <linux/wireless.h>
59#include <linux/netdevice.h> 58#include <linux/netdevice.h>
60#include <linux/io.h> 59#include <linux/io.h>
diff --git a/drivers/tc/tc.c b/drivers/tc/tc.c
index e5bd4470a57..a8aaf6ac2ae 100644
--- a/drivers/tc/tc.c
+++ b/drivers/tc/tc.c
@@ -16,6 +16,7 @@
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/list.h> 17#include <linux/list.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/slab.h>
19#include <linux/string.h> 20#include <linux/string.h>
20#include <linux/tc.h> 21#include <linux/tc.h>
21#include <linux/types.h> 22#include <linux/types.h>
diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
index 5066de5cfc0..13c72c62932 100644
--- a/drivers/thermal/thermal_sys.c
+++ b/drivers/thermal/thermal_sys.c
@@ -26,6 +26,7 @@
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/device.h> 27#include <linux/device.h>
28#include <linux/err.h> 28#include <linux/err.h>
29#include <linux/slab.h>
29#include <linux/kdev_t.h> 30#include <linux/kdev_t.h>
30#include <linux/idr.h> 31#include <linux/idr.h>
31#include <linux/thermal.h> 32#include <linux/thermal.h>
@@ -505,6 +506,7 @@ thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
505 tz->temp_input.attr.attr.name = tz->temp_input.name; 506 tz->temp_input.attr.attr.name = tz->temp_input.name;
506 tz->temp_input.attr.attr.mode = 0444; 507 tz->temp_input.attr.attr.mode = 0444;
507 tz->temp_input.attr.show = temp_input_show; 508 tz->temp_input.attr.show = temp_input_show;
509 sysfs_attr_init(&tz->temp_input.attr.attr);
508 result = device_create_file(hwmon->device, &tz->temp_input.attr); 510 result = device_create_file(hwmon->device, &tz->temp_input.attr);
509 if (result) 511 if (result)
510 goto unregister_hwmon_device; 512 goto unregister_hwmon_device;
@@ -517,6 +519,7 @@ thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
517 tz->temp_crit.attr.attr.name = tz->temp_crit.name; 519 tz->temp_crit.attr.attr.name = tz->temp_crit.name;
518 tz->temp_crit.attr.attr.mode = 0444; 520 tz->temp_crit.attr.attr.mode = 0444;
519 tz->temp_crit.attr.show = temp_crit_show; 521 tz->temp_crit.attr.show = temp_crit_show;
522 sysfs_attr_init(&tz->temp_crit.attr.attr);
520 result = device_create_file(hwmon->device, 523 result = device_create_file(hwmon->device,
521 &tz->temp_crit.attr); 524 &tz->temp_crit.attr);
522 if (result) 525 if (result)
@@ -725,6 +728,7 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
725 goto release_idr; 728 goto release_idr;
726 729
727 sprintf(dev->attr_name, "cdev%d_trip_point", dev->id); 730 sprintf(dev->attr_name, "cdev%d_trip_point", dev->id);
731 sysfs_attr_init(&dev->attr.attr);
728 dev->attr.attr.name = dev->attr_name; 732 dev->attr.attr.name = dev->attr_name;
729 dev->attr.attr.mode = 0444; 733 dev->attr.attr.mode = 0444;
730 dev->attr.show = thermal_cooling_device_trip_point_show; 734 dev->attr.show = thermal_cooling_device_trip_point_show;
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 4de382acd8f..bff1afbde5a 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -17,6 +17,7 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/poll.h> 18#include <linux/poll.h>
19#include <linux/device.h> 19#include <linux/device.h>
20#include <linux/slab.h>
20#include <linux/mm.h> 21#include <linux/mm.h>
21#include <linux/idr.h> 22#include <linux/idr.h>
22#include <linux/sched.h> 23#include <linux/sched.h>
diff --git a/drivers/uio/uio_aec.c b/drivers/uio/uio_aec.c
index b7830e9a3ba..72b22d44e8b 100644
--- a/drivers/uio/uio_aec.c
+++ b/drivers/uio/uio_aec.c
@@ -27,6 +27,7 @@
27#include <linux/io.h> 27#include <linux/io.h>
28#include <linux/uaccess.h> 28#include <linux/uaccess.h>
29#include <linux/uio_driver.h> 29#include <linux/uio_driver.h>
30#include <linux/slab.h>
30 31
31#define PCI_VENDOR_ID_AEC 0xaecb 32#define PCI_VENDOR_ID_AEC 0xaecb
32#define PCI_DEVICE_ID_AEC_VITCLTC 0x6250 33#define PCI_DEVICE_ID_AEC_VITCLTC 0x6250
diff --git a/drivers/uio/uio_cif.c b/drivers/uio/uio_cif.c
index 28034c81291..371f87f8bc2 100644
--- a/drivers/uio/uio_cif.c
+++ b/drivers/uio/uio_cif.c
@@ -11,6 +11,7 @@
11#include <linux/device.h> 11#include <linux/device.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/pci.h> 13#include <linux/pci.h>
14#include <linux/slab.h>
14#include <linux/uio_driver.h> 15#include <linux/uio_driver.h>
15 16
16#include <asm/io.h> 17#include <asm/io.h>
diff --git a/drivers/uio/uio_netx.c b/drivers/uio/uio_netx.c
index afbf0bd55cc..5a18e9f7b83 100644
--- a/drivers/uio/uio_netx.c
+++ b/drivers/uio/uio_netx.c
@@ -13,6 +13,7 @@
13#include <linux/io.h> 13#include <linux/io.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/pci.h> 15#include <linux/pci.h>
16#include <linux/slab.h>
16#include <linux/uio_driver.h> 17#include <linux/uio_driver.h>
17 18
18#define PCI_VENDOR_ID_HILSCHER 0x15CF 19#define PCI_VENDOR_ID_HILSCHER 0x15CF
diff --git a/drivers/uio/uio_pci_generic.c b/drivers/uio/uio_pci_generic.c
index 313da35984a..85c9884a67f 100644
--- a/drivers/uio/uio_pci_generic.c
+++ b/drivers/uio/uio_pci_generic.c
@@ -22,6 +22,7 @@
22#include <linux/device.h> 22#include <linux/device.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/pci.h> 24#include <linux/pci.h>
25#include <linux/slab.h>
25#include <linux/uio_driver.h> 26#include <linux/uio_driver.h>
26#include <linux/spinlock.h> 27#include <linux/spinlock.h>
27 28
diff --git a/drivers/uio/uio_pdrv.c b/drivers/uio/uio_pdrv.c
index d494ce9288c..7d3e469b990 100644
--- a/drivers/uio/uio_pdrv.c
+++ b/drivers/uio/uio_pdrv.c
@@ -11,6 +11,7 @@
11#include <linux/platform_device.h> 11#include <linux/platform_device.h>
12#include <linux/uio_driver.h> 12#include <linux/uio_driver.h>
13#include <linux/stringify.h> 13#include <linux/stringify.h>
14#include <linux/slab.h>
14 15
15#define DRIVER_NAME "uio_pdrv" 16#define DRIVER_NAME "uio_pdrv"
16 17
diff --git a/drivers/uio/uio_pdrv_genirq.c b/drivers/uio/uio_pdrv_genirq.c
index 1ef3b8fc50b..61e569df2bb 100644
--- a/drivers/uio/uio_pdrv_genirq.c
+++ b/drivers/uio/uio_pdrv_genirq.c
@@ -21,6 +21,7 @@
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/stringify.h> 22#include <linux/stringify.h>
23#include <linux/pm_runtime.h> 23#include <linux/pm_runtime.h>
24#include <linux/slab.h>
24 25
25#define DRIVER_NAME "uio_pdrv_genirq" 26#define DRIVER_NAME "uio_pdrv_genirq"
26 27
diff --git a/drivers/uio/uio_sercos3.c b/drivers/uio/uio_sercos3.c
index a6d1b2bc47f..3d461cd73e6 100644
--- a/drivers/uio/uio_sercos3.c
+++ b/drivers/uio/uio_sercos3.c
@@ -28,6 +28,7 @@
28#include <linux/pci.h> 28#include <linux/pci.h>
29#include <linux/uio_driver.h> 29#include <linux/uio_driver.h>
30#include <linux/io.h> 30#include <linux/io.h>
31#include <linux/slab.h>
31 32
32/* ID's for SERCOS III PCI card (PLX 9030) */ 33/* ID's for SERCOS III PCI card (PLX 9030) */
33#define SERCOS_SUB_VENDOR_ID 0x1971 34#define SERCOS_SUB_VENDOR_ID 0x1971
diff --git a/drivers/usb/atm/speedtch.c b/drivers/usb/atm/speedtch.c
index 3e862401a63..1e9ba4bdffe 100644
--- a/drivers/usb/atm/speedtch.c
+++ b/drivers/usb/atm/speedtch.c
@@ -27,7 +27,6 @@
27#include <linux/device.h> 27#include <linux/device.h>
28#include <linux/errno.h> 28#include <linux/errno.h>
29#include <linux/firmware.h> 29#include <linux/firmware.h>
30#include <linux/gfp.h>
31#include <linux/init.h> 30#include <linux/init.h>
32#include <linux/kernel.h> 31#include <linux/kernel.h>
33#include <linux/module.h> 32#include <linux/module.h>
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index c5395246886..25f01b536f6 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -66,6 +66,7 @@
66#include <linux/kthread.h> 66#include <linux/kthread.h>
67#include <linux/mutex.h> 67#include <linux/mutex.h>
68#include <linux/freezer.h> 68#include <linux/freezer.h>
69#include <linux/slab.h>
69 70
70#include <asm/unaligned.h> 71#include <asm/unaligned.h>
71 72
diff --git a/drivers/usb/c67x00/c67x00-drv.c b/drivers/usb/c67x00/c67x00-drv.c
index 029ee4a8a1f..b6d49234e52 100644
--- a/drivers/usb/c67x00/c67x00-drv.c
+++ b/drivers/usb/c67x00/c67x00-drv.c
@@ -37,6 +37,7 @@
37#include <linux/device.h> 37#include <linux/device.h>
38#include <linux/io.h> 38#include <linux/io.h>
39#include <linux/list.h> 39#include <linux/list.h>
40#include <linux/slab.h>
40#include <linux/usb.h> 41#include <linux/usb.h>
41#include <linux/usb/c67x00.h> 42#include <linux/usb/c67x00.h>
42 43
diff --git a/drivers/usb/c67x00/c67x00-sched.c b/drivers/usb/c67x00/c67x00-sched.c
index 85dfe296566..f6b3c253f3f 100644
--- a/drivers/usb/c67x00/c67x00-sched.c
+++ b/drivers/usb/c67x00/c67x00-sched.c
@@ -22,6 +22,7 @@
22 */ 22 */
23 23
24#include <linux/kthread.h> 24#include <linux/kthread.h>
25#include <linux/slab.h>
25 26
26#include "c67x00.h" 27#include "c67x00.h"
27#include "c67x00-hcd.h" 28#include "c67x00-hcd.h"
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 975d556b478..5e1a253b08a 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1441,7 +1441,7 @@ static int acm_resume(struct usb_interface *intf)
1441 wb = acm->delayed_wb; 1441 wb = acm->delayed_wb;
1442 acm->delayed_wb = NULL; 1442 acm->delayed_wb = NULL;
1443 spin_unlock_irq(&acm->write_lock); 1443 spin_unlock_irq(&acm->write_lock);
1444 acm_start_wb(acm, acm->delayed_wb); 1444 acm_start_wb(acm, wb);
1445 } else { 1445 } else {
1446 spin_unlock_irq(&acm->write_lock); 1446 spin_unlock_irq(&acm->write_lock);
1447 } 1447 }
@@ -1542,6 +1542,9 @@ static const struct usb_device_id acm_ids[] = {
1542 { USB_DEVICE(0x1bbb, 0x0003), /* Alcatel OT-I650 */ 1542 { USB_DEVICE(0x1bbb, 0x0003), /* Alcatel OT-I650 */
1543 .driver_info = NO_UNION_NORMAL, /* reports zero length descriptor */ 1543 .driver_info = NO_UNION_NORMAL, /* reports zero length descriptor */
1544 }, 1544 },
1545 { USB_DEVICE(0x1576, 0x03b1), /* Maretron USB100 */
1546 .driver_info = NO_UNION_NORMAL, /* reports zero length descriptor */
1547 },
1545 1548
1546 /* Nokia S60 phones expose two ACM channels. The first is 1549 /* Nokia S60 phones expose two ACM channels. The first is
1547 * a modem and is picked up by the standard AT-command 1550 * a modem and is picked up by the standard AT-command
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 18aafcb08fc..189141ca4e0 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -52,7 +52,8 @@ MODULE_DEVICE_TABLE (usb, wdm_ids);
52#define WDM_READ 4 52#define WDM_READ 4
53#define WDM_INT_STALL 5 53#define WDM_INT_STALL 5
54#define WDM_POLL_RUNNING 6 54#define WDM_POLL_RUNNING 6
55 55#define WDM_RESPONDING 7
56#define WDM_SUSPENDING 8
56 57
57#define WDM_MAX 16 58#define WDM_MAX 16
58 59
@@ -87,9 +88,7 @@ struct wdm_device {
87 int count; 88 int count;
88 dma_addr_t shandle; 89 dma_addr_t shandle;
89 dma_addr_t ihandle; 90 dma_addr_t ihandle;
90 struct mutex wlock; 91 struct mutex lock;
91 struct mutex rlock;
92 struct mutex plock;
93 wait_queue_head_t wait; 92 wait_queue_head_t wait;
94 struct work_struct rxwork; 93 struct work_struct rxwork;
95 int werr; 94 int werr;
@@ -117,21 +116,22 @@ static void wdm_in_callback(struct urb *urb)
117 int status = urb->status; 116 int status = urb->status;
118 117
119 spin_lock(&desc->iuspin); 118 spin_lock(&desc->iuspin);
119 clear_bit(WDM_RESPONDING, &desc->flags);
120 120
121 if (status) { 121 if (status) {
122 switch (status) { 122 switch (status) {
123 case -ENOENT: 123 case -ENOENT:
124 dev_dbg(&desc->intf->dev, 124 dev_dbg(&desc->intf->dev,
125 "nonzero urb status received: -ENOENT"); 125 "nonzero urb status received: -ENOENT");
126 break; 126 goto skip_error;
127 case -ECONNRESET: 127 case -ECONNRESET:
128 dev_dbg(&desc->intf->dev, 128 dev_dbg(&desc->intf->dev,
129 "nonzero urb status received: -ECONNRESET"); 129 "nonzero urb status received: -ECONNRESET");
130 break; 130 goto skip_error;
131 case -ESHUTDOWN: 131 case -ESHUTDOWN:
132 dev_dbg(&desc->intf->dev, 132 dev_dbg(&desc->intf->dev,
133 "nonzero urb status received: -ESHUTDOWN"); 133 "nonzero urb status received: -ESHUTDOWN");
134 break; 134 goto skip_error;
135 case -EPIPE: 135 case -EPIPE:
136 dev_err(&desc->intf->dev, 136 dev_err(&desc->intf->dev,
137 "nonzero urb status received: -EPIPE\n"); 137 "nonzero urb status received: -EPIPE\n");
@@ -147,6 +147,7 @@ static void wdm_in_callback(struct urb *urb)
147 desc->reslength = urb->actual_length; 147 desc->reslength = urb->actual_length;
148 memmove(desc->ubuf + desc->length, desc->inbuf, desc->reslength); 148 memmove(desc->ubuf + desc->length, desc->inbuf, desc->reslength);
149 desc->length += desc->reslength; 149 desc->length += desc->reslength;
150skip_error:
150 wake_up(&desc->wait); 151 wake_up(&desc->wait);
151 152
152 set_bit(WDM_READ, &desc->flags); 153 set_bit(WDM_READ, &desc->flags);
@@ -229,13 +230,16 @@ static void wdm_int_callback(struct urb *urb)
229 desc->response->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 230 desc->response->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
230 spin_lock(&desc->iuspin); 231 spin_lock(&desc->iuspin);
231 clear_bit(WDM_READ, &desc->flags); 232 clear_bit(WDM_READ, &desc->flags);
232 if (!test_bit(WDM_DISCONNECTING, &desc->flags)) { 233 set_bit(WDM_RESPONDING, &desc->flags);
234 if (!test_bit(WDM_DISCONNECTING, &desc->flags)
235 && !test_bit(WDM_SUSPENDING, &desc->flags)) {
233 rv = usb_submit_urb(desc->response, GFP_ATOMIC); 236 rv = usb_submit_urb(desc->response, GFP_ATOMIC);
234 dev_dbg(&desc->intf->dev, "%s: usb_submit_urb %d", 237 dev_dbg(&desc->intf->dev, "%s: usb_submit_urb %d",
235 __func__, rv); 238 __func__, rv);
236 } 239 }
237 spin_unlock(&desc->iuspin); 240 spin_unlock(&desc->iuspin);
238 if (rv < 0) { 241 if (rv < 0) {
242 clear_bit(WDM_RESPONDING, &desc->flags);
239 if (rv == -EPERM) 243 if (rv == -EPERM)
240 return; 244 return;
241 if (rv == -ENOMEM) { 245 if (rv == -ENOMEM) {
@@ -305,14 +309,38 @@ static ssize_t wdm_write
305 if (we < 0) 309 if (we < 0)
306 return -EIO; 310 return -EIO;
307 311
308 r = mutex_lock_interruptible(&desc->wlock); /* concurrent writes */ 312 desc->outbuf = buf = kmalloc(count, GFP_KERNEL);
313 if (!buf) {
314 rv = -ENOMEM;
315 goto outnl;
316 }
317
318 r = copy_from_user(buf, buffer, count);
319 if (r > 0) {
320 kfree(buf);
321 rv = -EFAULT;
322 goto outnl;
323 }
324
325 /* concurrent writes and disconnect */
326 r = mutex_lock_interruptible(&desc->lock);
309 rv = -ERESTARTSYS; 327 rv = -ERESTARTSYS;
310 if (r) 328 if (r) {
329 kfree(buf);
311 goto outnl; 330 goto outnl;
331 }
332
333 if (test_bit(WDM_DISCONNECTING, &desc->flags)) {
334 kfree(buf);
335 rv = -ENODEV;
336 goto outnp;
337 }
312 338
313 r = usb_autopm_get_interface(desc->intf); 339 r = usb_autopm_get_interface(desc->intf);
314 if (r < 0) 340 if (r < 0) {
341 kfree(buf);
315 goto outnp; 342 goto outnp;
343 }
316 344
317 if (!file->f_flags && O_NONBLOCK) 345 if (!file->f_flags && O_NONBLOCK)
318 r = wait_event_interruptible(desc->wait, !test_bit(WDM_IN_USE, 346 r = wait_event_interruptible(desc->wait, !test_bit(WDM_IN_USE,
@@ -320,24 +348,8 @@ static ssize_t wdm_write
320 else 348 else
321 if (test_bit(WDM_IN_USE, &desc->flags)) 349 if (test_bit(WDM_IN_USE, &desc->flags))
322 r = -EAGAIN; 350 r = -EAGAIN;
323 if (r < 0) 351 if (r < 0) {
324 goto out;
325
326 if (test_bit(WDM_DISCONNECTING, &desc->flags)) {
327 rv = -ENODEV;
328 goto out;
329 }
330
331 desc->outbuf = buf = kmalloc(count, GFP_KERNEL);
332 if (!buf) {
333 rv = -ENOMEM;
334 goto out;
335 }
336
337 r = copy_from_user(buf, buffer, count);
338 if (r > 0) {
339 kfree(buf); 352 kfree(buf);
340 rv = -EFAULT;
341 goto out; 353 goto out;
342 } 354 }
343 355
@@ -374,7 +386,7 @@ static ssize_t wdm_write
374out: 386out:
375 usb_autopm_put_interface(desc->intf); 387 usb_autopm_put_interface(desc->intf);
376outnp: 388outnp:
377 mutex_unlock(&desc->wlock); 389 mutex_unlock(&desc->lock);
378outnl: 390outnl:
379 return rv < 0 ? rv : count; 391 return rv < 0 ? rv : count;
380} 392}
@@ -387,7 +399,7 @@ static ssize_t wdm_read
387 struct wdm_device *desc = file->private_data; 399 struct wdm_device *desc = file->private_data;
388 400
389 401
390 rv = mutex_lock_interruptible(&desc->rlock); /*concurrent reads */ 402 rv = mutex_lock_interruptible(&desc->lock); /*concurrent reads */
391 if (rv < 0) 403 if (rv < 0)
392 return -ERESTARTSYS; 404 return -ERESTARTSYS;
393 405
@@ -424,11 +436,8 @@ retry:
424 spin_lock_irq(&desc->iuspin); 436 spin_lock_irq(&desc->iuspin);
425 437
426 if (desc->rerr) { /* read completed, error happened */ 438 if (desc->rerr) { /* read completed, error happened */
427 int t = desc->rerr;
428 desc->rerr = 0; 439 desc->rerr = 0;
429 spin_unlock_irq(&desc->iuspin); 440 spin_unlock_irq(&desc->iuspin);
430 dev_err(&desc->intf->dev,
431 "reading had resulted in %d\n", t);
432 rv = -EIO; 441 rv = -EIO;
433 goto err; 442 goto err;
434 } 443 }
@@ -465,9 +474,7 @@ retry:
465 rv = cntr; 474 rv = cntr;
466 475
467err: 476err:
468 mutex_unlock(&desc->rlock); 477 mutex_unlock(&desc->lock);
469 if (rv < 0 && rv != -EAGAIN)
470 dev_err(&desc->intf->dev, "wdm_read: exit error\n");
471 return rv; 478 return rv;
472} 479}
473 480
@@ -533,7 +540,7 @@ static int wdm_open(struct inode *inode, struct file *file)
533 } 540 }
534 intf->needs_remote_wakeup = 1; 541 intf->needs_remote_wakeup = 1;
535 542
536 mutex_lock(&desc->plock); 543 mutex_lock(&desc->lock);
537 if (!desc->count++) { 544 if (!desc->count++) {
538 rv = usb_submit_urb(desc->validity, GFP_KERNEL); 545 rv = usb_submit_urb(desc->validity, GFP_KERNEL);
539 if (rv < 0) { 546 if (rv < 0) {
@@ -544,7 +551,7 @@ static int wdm_open(struct inode *inode, struct file *file)
544 } else { 551 } else {
545 rv = 0; 552 rv = 0;
546 } 553 }
547 mutex_unlock(&desc->plock); 554 mutex_unlock(&desc->lock);
548 usb_autopm_put_interface(desc->intf); 555 usb_autopm_put_interface(desc->intf);
549out: 556out:
550 mutex_unlock(&wdm_mutex); 557 mutex_unlock(&wdm_mutex);
@@ -556,9 +563,9 @@ static int wdm_release(struct inode *inode, struct file *file)
556 struct wdm_device *desc = file->private_data; 563 struct wdm_device *desc = file->private_data;
557 564
558 mutex_lock(&wdm_mutex); 565 mutex_lock(&wdm_mutex);
559 mutex_lock(&desc->plock); 566 mutex_lock(&desc->lock);
560 desc->count--; 567 desc->count--;
561 mutex_unlock(&desc->plock); 568 mutex_unlock(&desc->lock);
562 569
563 if (!desc->count) { 570 if (!desc->count) {
564 dev_dbg(&desc->intf->dev, "wdm_release: cleanup"); 571 dev_dbg(&desc->intf->dev, "wdm_release: cleanup");
@@ -655,9 +662,7 @@ next_desc:
655 desc = kzalloc(sizeof(struct wdm_device), GFP_KERNEL); 662 desc = kzalloc(sizeof(struct wdm_device), GFP_KERNEL);
656 if (!desc) 663 if (!desc)
657 goto out; 664 goto out;
658 mutex_init(&desc->wlock); 665 mutex_init(&desc->lock);
659 mutex_init(&desc->rlock);
660 mutex_init(&desc->plock);
661 spin_lock_init(&desc->iuspin); 666 spin_lock_init(&desc->iuspin);
662 init_waitqueue_head(&desc->wait); 667 init_waitqueue_head(&desc->wait);
663 desc->wMaxCommand = maxcom; 668 desc->wMaxCommand = maxcom;
@@ -771,14 +776,17 @@ static void wdm_disconnect(struct usb_interface *intf)
771 /* to terminate pending flushes */ 776 /* to terminate pending flushes */
772 clear_bit(WDM_IN_USE, &desc->flags); 777 clear_bit(WDM_IN_USE, &desc->flags);
773 spin_unlock_irqrestore(&desc->iuspin, flags); 778 spin_unlock_irqrestore(&desc->iuspin, flags);
774 cancel_work_sync(&desc->rxwork); 779 mutex_lock(&desc->lock);
775 kill_urbs(desc); 780 kill_urbs(desc);
781 cancel_work_sync(&desc->rxwork);
782 mutex_unlock(&desc->lock);
776 wake_up_all(&desc->wait); 783 wake_up_all(&desc->wait);
777 if (!desc->count) 784 if (!desc->count)
778 cleanup(desc); 785 cleanup(desc);
779 mutex_unlock(&wdm_mutex); 786 mutex_unlock(&wdm_mutex);
780} 787}
781 788
789#ifdef CONFIG_PM
782static int wdm_suspend(struct usb_interface *intf, pm_message_t message) 790static int wdm_suspend(struct usb_interface *intf, pm_message_t message)
783{ 791{
784 struct wdm_device *desc = usb_get_intfdata(intf); 792 struct wdm_device *desc = usb_get_intfdata(intf);
@@ -786,22 +794,30 @@ static int wdm_suspend(struct usb_interface *intf, pm_message_t message)
786 794
787 dev_dbg(&desc->intf->dev, "wdm%d_suspend\n", intf->minor); 795 dev_dbg(&desc->intf->dev, "wdm%d_suspend\n", intf->minor);
788 796
789 mutex_lock(&desc->plock); 797 /* if this is an autosuspend the caller does the locking */
790#ifdef CONFIG_PM 798 if (!(message.event & PM_EVENT_AUTO))
799 mutex_lock(&desc->lock);
800 spin_lock_irq(&desc->iuspin);
801
791 if ((message.event & PM_EVENT_AUTO) && 802 if ((message.event & PM_EVENT_AUTO) &&
792 test_bit(WDM_IN_USE, &desc->flags)) { 803 (test_bit(WDM_IN_USE, &desc->flags)
804 || test_bit(WDM_RESPONDING, &desc->flags))) {
805 spin_unlock_irq(&desc->iuspin);
793 rv = -EBUSY; 806 rv = -EBUSY;
794 } else { 807 } else {
795#endif 808
796 cancel_work_sync(&desc->rxwork); 809 set_bit(WDM_SUSPENDING, &desc->flags);
810 spin_unlock_irq(&desc->iuspin);
811 /* callback submits work - order is essential */
797 kill_urbs(desc); 812 kill_urbs(desc);
798#ifdef CONFIG_PM 813 cancel_work_sync(&desc->rxwork);
799 } 814 }
800#endif 815 if (!(message.event & PM_EVENT_AUTO))
801 mutex_unlock(&desc->plock); 816 mutex_unlock(&desc->lock);
802 817
803 return rv; 818 return rv;
804} 819}
820#endif
805 821
806static int recover_from_urb_loss(struct wdm_device *desc) 822static int recover_from_urb_loss(struct wdm_device *desc)
807{ 823{
@@ -815,23 +831,27 @@ static int recover_from_urb_loss(struct wdm_device *desc)
815 } 831 }
816 return rv; 832 return rv;
817} 833}
834
835#ifdef CONFIG_PM
818static int wdm_resume(struct usb_interface *intf) 836static int wdm_resume(struct usb_interface *intf)
819{ 837{
820 struct wdm_device *desc = usb_get_intfdata(intf); 838 struct wdm_device *desc = usb_get_intfdata(intf);
821 int rv; 839 int rv;
822 840
823 dev_dbg(&desc->intf->dev, "wdm%d_resume\n", intf->minor); 841 dev_dbg(&desc->intf->dev, "wdm%d_resume\n", intf->minor);
824 mutex_lock(&desc->plock); 842
843 clear_bit(WDM_SUSPENDING, &desc->flags);
825 rv = recover_from_urb_loss(desc); 844 rv = recover_from_urb_loss(desc);
826 mutex_unlock(&desc->plock); 845
827 return rv; 846 return rv;
828} 847}
848#endif
829 849
830static int wdm_pre_reset(struct usb_interface *intf) 850static int wdm_pre_reset(struct usb_interface *intf)
831{ 851{
832 struct wdm_device *desc = usb_get_intfdata(intf); 852 struct wdm_device *desc = usb_get_intfdata(intf);
833 853
834 mutex_lock(&desc->plock); 854 mutex_lock(&desc->lock);
835 return 0; 855 return 0;
836} 856}
837 857
@@ -841,7 +861,7 @@ static int wdm_post_reset(struct usb_interface *intf)
841 int rv; 861 int rv;
842 862
843 rv = recover_from_urb_loss(desc); 863 rv = recover_from_urb_loss(desc);
844 mutex_unlock(&desc->plock); 864 mutex_unlock(&desc->lock);
845 return 0; 865 return 0;
846} 866}
847 867
@@ -849,9 +869,11 @@ static struct usb_driver wdm_driver = {
849 .name = "cdc_wdm", 869 .name = "cdc_wdm",
850 .probe = wdm_probe, 870 .probe = wdm_probe,
851 .disconnect = wdm_disconnect, 871 .disconnect = wdm_disconnect,
872#ifdef CONFIG_PM
852 .suspend = wdm_suspend, 873 .suspend = wdm_suspend,
853 .resume = wdm_resume, 874 .resume = wdm_resume,
854 .reset_resume = wdm_resume, 875 .reset_resume = wdm_resume,
876#endif
855 .pre_reset = wdm_pre_reset, 877 .pre_reset = wdm_pre_reset,
856 .post_reset = wdm_post_reset, 878 .post_reset = wdm_post_reset,
857 .id_table = wdm_ids, 879 .id_table = wdm_ids,
diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index 8588c0937a8..3e7c1b800eb 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -25,6 +25,7 @@
25#include <linux/fs.h> 25#include <linux/fs.h>
26#include <linux/uaccess.h> 26#include <linux/uaccess.h>
27#include <linux/kref.h> 27#include <linux/kref.h>
28#include <linux/slab.h>
28#include <linux/mutex.h> 29#include <linux/mutex.h>
29#include <linux/usb.h> 30#include <linux/usb.h>
30#include <linux/usb/tmc.h> 31#include <linux/usb/tmc.h>
diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig
index 97a819c23ef..7e594449600 100644
--- a/drivers/usb/core/Kconfig
+++ b/drivers/usb/core/Kconfig
@@ -109,7 +109,7 @@ config USB_SUSPEND
109config USB_OTG 109config USB_OTG
110 bool 110 bool
111 depends on USB && EXPERIMENTAL 111 depends on USB && EXPERIMENTAL
112 select USB_SUSPEND 112 depends on USB_SUSPEND
113 default n 113 default n
114 114
115 115
diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
index d41811bfef2..19bc03a9fec 100644
--- a/drivers/usb/core/devices.c
+++ b/drivers/usb/core/devices.c
@@ -50,7 +50,7 @@
50 50
51#include <linux/fs.h> 51#include <linux/fs.h>
52#include <linux/mm.h> 52#include <linux/mm.h>
53#include <linux/slab.h> 53#include <linux/gfp.h>
54#include <linux/poll.h> 54#include <linux/poll.h>
55#include <linux/usb.h> 55#include <linux/usb.h>
56#include <linux/smp_lock.h> 56#include <linux/smp_lock.h>
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index e909ff7b909..3466fdc5bb1 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1207,6 +1207,13 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
1207 free_async(as); 1207 free_async(as);
1208 return -ENOMEM; 1208 return -ENOMEM;
1209 } 1209 }
1210 /* Isochronous input data may end up being discontiguous
1211 * if some of the packets are short. Clear the buffer so
1212 * that the gaps don't leak kernel data to userspace.
1213 */
1214 if (is_in && uurb->type == USBDEVFS_URB_TYPE_ISO)
1215 memset(as->urb->transfer_buffer, 0,
1216 uurb->buffer_length);
1210 } 1217 }
1211 as->urb->dev = ps->dev; 1218 as->urb->dev = ps->dev;
1212 as->urb->pipe = (uurb->type << 30) | 1219 as->urb->pipe = (uurb->type << 30) |
@@ -1345,10 +1352,14 @@ static int processcompl(struct async *as, void __user * __user *arg)
1345 void __user *addr = as->userurb; 1352 void __user *addr = as->userurb;
1346 unsigned int i; 1353 unsigned int i;
1347 1354
1348 if (as->userbuffer && urb->actual_length) 1355 if (as->userbuffer && urb->actual_length) {
1349 if (copy_to_user(as->userbuffer, urb->transfer_buffer, 1356 if (urb->number_of_packets > 0) /* Isochronous */
1350 urb->actual_length)) 1357 i = urb->transfer_buffer_length;
1358 else /* Non-Isoc */
1359 i = urb->actual_length;
1360 if (copy_to_user(as->userbuffer, urb->transfer_buffer, i))
1351 goto err_out; 1361 goto err_out;
1362 }
1352 if (put_user(as->status, &userurb->status)) 1363 if (put_user(as->status, &userurb->status))
1353 goto err_out; 1364 goto err_out;
1354 if (put_user(urb->actual_length, &userurb->actual_length)) 1365 if (put_user(urb->actual_length, &userurb->actual_length))
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index f3c233806fa..2f3dc4cdf79 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -23,6 +23,7 @@
23 */ 23 */
24 24
25#include <linux/device.h> 25#include <linux/device.h>
26#include <linux/slab.h>
26#include <linux/usb.h> 27#include <linux/usb.h>
27#include <linux/usb/quirks.h> 28#include <linux/usb/quirks.h>
28#include <linux/pm_runtime.h> 29#include <linux/pm_runtime.h>
@@ -300,7 +301,7 @@ static int usb_probe_interface(struct device *dev)
300 301
301 intf->condition = USB_INTERFACE_BINDING; 302 intf->condition = USB_INTERFACE_BINDING;
302 303
303 /* Bound interfaces are initially active. They are 304 /* Probed interfaces are initially active. They are
304 * runtime-PM-enabled only if the driver has autosuspend support. 305 * runtime-PM-enabled only if the driver has autosuspend support.
305 * They are sensitive to their children's power states. 306 * They are sensitive to their children's power states.
306 */ 307 */
@@ -436,11 +437,11 @@ int usb_driver_claim_interface(struct usb_driver *driver,
436 437
437 iface->condition = USB_INTERFACE_BOUND; 438 iface->condition = USB_INTERFACE_BOUND;
438 439
439 /* Bound interfaces are initially active. They are 440 /* Claimed interfaces are initially inactive (suspended). They are
440 * runtime-PM-enabled only if the driver has autosuspend support. 441 * runtime-PM-enabled only if the driver has autosuspend support.
441 * They are sensitive to their children's power states. 442 * They are sensitive to their children's power states.
442 */ 443 */
443 pm_runtime_set_active(dev); 444 pm_runtime_set_suspended(dev);
444 pm_suspend_ignore_children(dev, false); 445 pm_suspend_ignore_children(dev, false);
445 if (driver->supports_autosuspend) 446 if (driver->supports_autosuspend)
446 pm_runtime_enable(dev); 447 pm_runtime_enable(dev);
@@ -1169,7 +1170,7 @@ done:
1169static int usb_suspend_both(struct usb_device *udev, pm_message_t msg) 1170static int usb_suspend_both(struct usb_device *udev, pm_message_t msg)
1170{ 1171{
1171 int status = 0; 1172 int status = 0;
1172 int i = 0; 1173 int i = 0, n = 0;
1173 struct usb_interface *intf; 1174 struct usb_interface *intf;
1174 1175
1175 if (udev->state == USB_STATE_NOTATTACHED || 1176 if (udev->state == USB_STATE_NOTATTACHED ||
@@ -1178,7 +1179,8 @@ static int usb_suspend_both(struct usb_device *udev, pm_message_t msg)
1178 1179
1179 /* Suspend all the interfaces and then udev itself */ 1180 /* Suspend all the interfaces and then udev itself */
1180 if (udev->actconfig) { 1181 if (udev->actconfig) {
1181 for (; i < udev->actconfig->desc.bNumInterfaces; i++) { 1182 n = udev->actconfig->desc.bNumInterfaces;
1183 for (i = n - 1; i >= 0; --i) {
1182 intf = udev->actconfig->interface[i]; 1184 intf = udev->actconfig->interface[i];
1183 status = usb_suspend_interface(udev, intf, msg); 1185 status = usb_suspend_interface(udev, intf, msg);
1184 if (status != 0) 1186 if (status != 0)
@@ -1191,7 +1193,7 @@ static int usb_suspend_both(struct usb_device *udev, pm_message_t msg)
1191 /* If the suspend failed, resume interfaces that did get suspended */ 1193 /* If the suspend failed, resume interfaces that did get suspended */
1192 if (status != 0) { 1194 if (status != 0) {
1193 msg.event ^= (PM_EVENT_SUSPEND | PM_EVENT_RESUME); 1195 msg.event ^= (PM_EVENT_SUSPEND | PM_EVENT_RESUME);
1194 while (--i >= 0) { 1196 while (++i < n) {
1195 intf = udev->actconfig->interface[i]; 1197 intf = udev->actconfig->interface[i];
1196 usb_resume_interface(udev, intf, msg, 0); 1198 usb_resume_interface(udev, intf, msg, 0);
1197 } 1199 }
@@ -1262,13 +1264,47 @@ static int usb_resume_both(struct usb_device *udev, pm_message_t msg)
1262 return status; 1264 return status;
1263} 1265}
1264 1266
1267static void choose_wakeup(struct usb_device *udev, pm_message_t msg)
1268{
1269 int w, i;
1270 struct usb_interface *intf;
1271
1272 /* Remote wakeup is needed only when we actually go to sleep.
1273 * For things like FREEZE and QUIESCE, if the device is already
1274 * autosuspended then its current wakeup setting is okay.
1275 */
1276 if (msg.event == PM_EVENT_FREEZE || msg.event == PM_EVENT_QUIESCE) {
1277 if (udev->state != USB_STATE_SUSPENDED)
1278 udev->do_remote_wakeup = 0;
1279 return;
1280 }
1281
1282 /* If remote wakeup is permitted, see whether any interface drivers
1283 * actually want it.
1284 */
1285 w = 0;
1286 if (device_may_wakeup(&udev->dev) && udev->actconfig) {
1287 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) {
1288 intf = udev->actconfig->interface[i];
1289 w |= intf->needs_remote_wakeup;
1290 }
1291 }
1292
1293 /* If the device is autosuspended with the wrong wakeup setting,
1294 * autoresume now so the setting can be changed.
1295 */
1296 if (udev->state == USB_STATE_SUSPENDED && w != udev->do_remote_wakeup)
1297 pm_runtime_resume(&udev->dev);
1298 udev->do_remote_wakeup = w;
1299}
1300
1265/* The device lock is held by the PM core */ 1301/* The device lock is held by the PM core */
1266int usb_suspend(struct device *dev, pm_message_t msg) 1302int usb_suspend(struct device *dev, pm_message_t msg)
1267{ 1303{
1268 struct usb_device *udev = to_usb_device(dev); 1304 struct usb_device *udev = to_usb_device(dev);
1269 1305
1270 do_unbind_rebind(udev, DO_UNBIND); 1306 do_unbind_rebind(udev, DO_UNBIND);
1271 udev->do_remote_wakeup = device_may_wakeup(&udev->dev); 1307 choose_wakeup(udev, msg);
1272 return usb_suspend_both(udev, msg); 1308 return usb_suspend_both(udev, msg);
1273} 1309}
1274 1310
diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c
index d26b9ea981f..4f84a41ee7a 100644
--- a/drivers/usb/core/endpoint.c
+++ b/drivers/usb/core/endpoint.c
@@ -11,6 +11,7 @@
11 11
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/spinlock.h> 13#include <linux/spinlock.h>
14#include <linux/slab.h>
14#include <linux/idr.h> 15#include <linux/idr.h>
15#include <linux/usb.h> 16#include <linux/usb.h>
16#include "usb.h" 17#include "usb.h"
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c
index c3536f151f0..f06f5dbc8cd 100644
--- a/drivers/usb/core/file.c
+++ b/drivers/usb/core/file.c
@@ -18,6 +18,7 @@
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/errno.h> 19#include <linux/errno.h>
20#include <linux/rwsem.h> 20#include <linux/rwsem.h>
21#include <linux/slab.h>
21#include <linux/smp_lock.h> 22#include <linux/smp_lock.h>
22#include <linux/usb.h> 23#include <linux/usb.h>
23 24
diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c
index bdf87a8414a..2c95153c0f2 100644
--- a/drivers/usb/core/generic.c
+++ b/drivers/usb/core/generic.c
@@ -120,7 +120,7 @@ int usb_choose_configuration(struct usb_device *udev)
120 * than a vendor-specific driver. */ 120 * than a vendor-specific driver. */
121 else if (udev->descriptor.bDeviceClass != 121 else if (udev->descriptor.bDeviceClass !=
122 USB_CLASS_VENDOR_SPEC && 122 USB_CLASS_VENDOR_SPEC &&
123 (!desc || desc->bInterfaceClass != 123 (desc && desc->bInterfaceClass !=
124 USB_CLASS_VENDOR_SPEC)) { 124 USB_CLASS_VENDOR_SPEC)) {
125 best = c; 125 best = c;
126 break; 126 break;
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c
index 97b40ce133f..4a6366a4212 100644
--- a/drivers/usb/core/inode.c
+++ b/drivers/usb/core/inode.c
@@ -515,13 +515,13 @@ static int fs_create_by_name (const char *name, mode_t mode,
515 *dentry = NULL; 515 *dentry = NULL;
516 mutex_lock(&parent->d_inode->i_mutex); 516 mutex_lock(&parent->d_inode->i_mutex);
517 *dentry = lookup_one_len(name, parent, strlen(name)); 517 *dentry = lookup_one_len(name, parent, strlen(name));
518 if (!IS_ERR(dentry)) { 518 if (!IS_ERR(*dentry)) {
519 if ((mode & S_IFMT) == S_IFDIR) 519 if ((mode & S_IFMT) == S_IFDIR)
520 error = usbfs_mkdir (parent->d_inode, *dentry, mode); 520 error = usbfs_mkdir (parent->d_inode, *dentry, mode);
521 else 521 else
522 error = usbfs_create (parent->d_inode, *dentry, mode); 522 error = usbfs_create (parent->d_inode, *dentry, mode);
523 } else 523 } else
524 error = PTR_ERR(dentry); 524 error = PTR_ERR(*dentry);
525 mutex_unlock(&parent->d_inode->i_mutex); 525 mutex_unlock(&parent->d_inode->i_mutex);
526 526
527 return error; 527 return error;
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 27080561a1c..45a32dadb40 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -453,6 +453,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
453 if (urb->interval > (1 << 15)) 453 if (urb->interval > (1 << 15))
454 return -EINVAL; 454 return -EINVAL;
455 max = 1 << 15; 455 max = 1 << 15;
456 break;
456 case USB_SPEED_WIRELESS: 457 case USB_SPEED_WIRELESS:
457 if (urb->interval > 16) 458 if (urb->interval > 16)
458 return -EINVAL; 459 return -EINVAL;
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 1297e9b16a5..0561430f2ed 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -718,7 +718,7 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size,
718EXPORT_SYMBOL_GPL(__usb_get_extra_descriptor); 718EXPORT_SYMBOL_GPL(__usb_get_extra_descriptor);
719 719
720/** 720/**
721 * usb_buffer_alloc - allocate dma-consistent buffer for URB_NO_xxx_DMA_MAP 721 * usb_alloc_coherent - allocate dma-consistent buffer for URB_NO_xxx_DMA_MAP
722 * @dev: device the buffer will be used with 722 * @dev: device the buffer will be used with
723 * @size: requested buffer size 723 * @size: requested buffer size
724 * @mem_flags: affect whether allocation may block 724 * @mem_flags: affect whether allocation may block
@@ -737,30 +737,30 @@ EXPORT_SYMBOL_GPL(__usb_get_extra_descriptor);
737 * architectures where CPU caches are not DMA-coherent. On systems without 737 * architectures where CPU caches are not DMA-coherent. On systems without
738 * bus-snooping caches, these buffers are uncached. 738 * bus-snooping caches, these buffers are uncached.
739 * 739 *
740 * When the buffer is no longer used, free it with usb_buffer_free(). 740 * When the buffer is no longer used, free it with usb_free_coherent().
741 */ 741 */
742void *usb_buffer_alloc(struct usb_device *dev, size_t size, gfp_t mem_flags, 742void *usb_alloc_coherent(struct usb_device *dev, size_t size, gfp_t mem_flags,
743 dma_addr_t *dma) 743 dma_addr_t *dma)
744{ 744{
745 if (!dev || !dev->bus) 745 if (!dev || !dev->bus)
746 return NULL; 746 return NULL;
747 return hcd_buffer_alloc(dev->bus, size, mem_flags, dma); 747 return hcd_buffer_alloc(dev->bus, size, mem_flags, dma);
748} 748}
749EXPORT_SYMBOL_GPL(usb_buffer_alloc); 749EXPORT_SYMBOL_GPL(usb_alloc_coherent);
750 750
751/** 751/**
752 * usb_buffer_free - free memory allocated with usb_buffer_alloc() 752 * usb_free_coherent - free memory allocated with usb_alloc_coherent()
753 * @dev: device the buffer was used with 753 * @dev: device the buffer was used with
754 * @size: requested buffer size 754 * @size: requested buffer size
755 * @addr: CPU address of buffer 755 * @addr: CPU address of buffer
756 * @dma: DMA address of buffer 756 * @dma: DMA address of buffer
757 * 757 *
758 * This reclaims an I/O buffer, letting it be reused. The memory must have 758 * This reclaims an I/O buffer, letting it be reused. The memory must have
759 * been allocated using usb_buffer_alloc(), and the parameters must match 759 * been allocated using usb_alloc_coherent(), and the parameters must match
760 * those provided in that allocation request. 760 * those provided in that allocation request.
761 */ 761 */
762void usb_buffer_free(struct usb_device *dev, size_t size, void *addr, 762void usb_free_coherent(struct usb_device *dev, size_t size, void *addr,
763 dma_addr_t dma) 763 dma_addr_t dma)
764{ 764{
765 if (!dev || !dev->bus) 765 if (!dev || !dev->bus)
766 return; 766 return;
@@ -768,7 +768,7 @@ void usb_buffer_free(struct usb_device *dev, size_t size, void *addr,
768 return; 768 return;
769 hcd_buffer_free(dev->bus, size, addr, dma); 769 hcd_buffer_free(dev->bus, size, addr, dma);
770} 770}
771EXPORT_SYMBOL_GPL(usb_buffer_free); 771EXPORT_SYMBOL_GPL(usb_free_coherent);
772 772
773/** 773/**
774 * usb_buffer_map - create DMA mapping(s) for an urb 774 * usb_buffer_map - create DMA mapping(s) for an urb
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 7460cd797f4..11a3e0fa433 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -747,7 +747,7 @@ config USB_MASS_STORAGE
747 which may be used with composite framework. 747 which may be used with composite framework.
748 748
749 Say "y" to link the driver statically, or "m" to build 749 Say "y" to link the driver statically, or "m" to build
750 a dynamically linked module called "g_file_storage". If unsure, 750 a dynamically linked module called "g_mass_storage". If unsure,
751 consider File-backed Storage Gadget. 751 consider File-backed Storage Gadget.
752 752
753config USB_G_SERIAL 753config USB_G_SERIAL
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index b3bd22ef82b..eaa79c8a9b8 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -1377,6 +1377,12 @@ static irqreturn_t at91_udc_irq (int irq, void *_udc)
1377{ 1377{
1378 struct at91_udc *udc = _udc; 1378 struct at91_udc *udc = _udc;
1379 u32 rescans = 5; 1379 u32 rescans = 5;
1380 int disable_clock = 0;
1381
1382 if (!udc->clocked) {
1383 clk_on(udc);
1384 disable_clock = 1;
1385 }
1380 1386
1381 while (rescans--) { 1387 while (rescans--) {
1382 u32 status; 1388 u32 status;
@@ -1465,6 +1471,9 @@ static irqreturn_t at91_udc_irq (int irq, void *_udc)
1465 } 1471 }
1466 } 1472 }
1467 1473
1474 if (disable_clock)
1475 clk_off(udc);
1476
1468 return IRQ_HANDLED; 1477 return IRQ_HANDLED;
1469} 1478}
1470 1479
diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
index f79bdfe4bed..75a256f3d45 100644
--- a/drivers/usb/gadget/atmel_usba_udc.c
+++ b/drivers/usb/gadget/atmel_usba_udc.c
@@ -12,6 +12,7 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/interrupt.h> 13#include <linux/interrupt.h>
14#include <linux/io.h> 14#include <linux/io.h>
15#include <linux/slab.h>
15#include <linux/device.h> 16#include <linux/device.h>
16#include <linux/dma-mapping.h> 17#include <linux/dma-mapping.h>
17#include <linux/list.h> 18#include <linux/list.h>
diff --git a/drivers/usb/gadget/ci13xxx_udc.c b/drivers/usb/gadget/ci13xxx_udc.c
index c7cb87a6fee..699695128e3 100644
--- a/drivers/usb/gadget/ci13xxx_udc.c
+++ b/drivers/usb/gadget/ci13xxx_udc.c
@@ -62,6 +62,7 @@
62#include <linux/kernel.h> 62#include <linux/kernel.h>
63#include <linux/module.h> 63#include <linux/module.h>
64#include <linux/pci.h> 64#include <linux/pci.h>
65#include <linux/slab.h>
65#include <linux/usb/ch9.h> 66#include <linux/usb/ch9.h>
66#include <linux/usb/gadget.h> 67#include <linux/usb/gadget.h>
67 68
diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c
index e1191b9a316..47e8e722682 100644
--- a/drivers/usb/gadget/config.c
+++ b/drivers/usb/gadget/config.c
@@ -19,6 +19,7 @@
19 */ 19 */
20 20
21#include <linux/errno.h> 21#include <linux/errno.h>
22#include <linux/slab.h>
22#include <linux/kernel.h> 23#include <linux/kernel.h>
23#include <linux/list.h> 24#include <linux/list.h>
24#include <linux/string.h> 25#include <linux/string.h>
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index 65a5f94cbc0..3568de210f7 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -266,7 +266,7 @@ struct usb_ep * __init usb_ep_autoconfig (
266 } 266 }
267 267
268#ifdef CONFIG_BLACKFIN 268#ifdef CONFIG_BLACKFIN
269 } else if (gadget_is_musbhsfc(gadget) || gadget_is_musbhdrc(gadget)) { 269 } else if (gadget_is_musbhdrc(gadget)) {
270 if ((USB_ENDPOINT_XFER_BULK == type) || 270 if ((USB_ENDPOINT_XFER_BULK == type) ||
271 (USB_ENDPOINT_XFER_ISOC == type)) { 271 (USB_ENDPOINT_XFER_ISOC == type)) {
272 if (USB_DIR_IN & desc->bEndpointAddress) 272 if (USB_DIR_IN & desc->bEndpointAddress)
diff --git a/drivers/usb/gadget/f_acm.c b/drivers/usb/gadget/f_acm.c
index e49c7325dce..400e1ebe697 100644
--- a/drivers/usb/gadget/f_acm.c
+++ b/drivers/usb/gadget/f_acm.c
@@ -14,6 +14,7 @@
14 14
15/* #define VERBOSE_DEBUG */ 15/* #define VERBOSE_DEBUG */
16 16
17#include <linux/slab.h>
17#include <linux/kernel.h> 18#include <linux/kernel.h>
18#include <linux/device.h> 19#include <linux/device.h>
19 20
diff --git a/drivers/usb/gadget/f_audio.c b/drivers/usb/gadget/f_audio.c
index f1e3aad76c3..43bf44514c4 100644
--- a/drivers/usb/gadget/f_audio.c
+++ b/drivers/usb/gadget/f_audio.c
@@ -9,6 +9,7 @@
9 * Licensed under the GPL-2 or later. 9 * Licensed under the GPL-2 or later.
10 */ 10 */
11 11
12#include <linux/slab.h>
12#include <linux/kernel.h> 13#include <linux/kernel.h>
13#include <linux/device.h> 14#include <linux/device.h>
14#include <asm/atomic.h> 15#include <asm/atomic.h>
diff --git a/drivers/usb/gadget/f_ecm.c b/drivers/usb/gadget/f_ecm.c
index 2fff530efc1..4e595324c61 100644
--- a/drivers/usb/gadget/f_ecm.c
+++ b/drivers/usb/gadget/f_ecm.c
@@ -21,6 +21,7 @@
21 21
22/* #define VERBOSE_DEBUG */ 22/* #define VERBOSE_DEBUG */
23 23
24#include <linux/slab.h>
24#include <linux/kernel.h> 25#include <linux/kernel.h>
25#include <linux/device.h> 26#include <linux/device.h>
26#include <linux/etherdevice.h> 27#include <linux/etherdevice.h>
diff --git a/drivers/usb/gadget/f_eem.c b/drivers/usb/gadget/f_eem.c
index d4f0db58a8a..38226e9a371 100644
--- a/drivers/usb/gadget/f_eem.c
+++ b/drivers/usb/gadget/f_eem.c
@@ -24,6 +24,7 @@
24#include <linux/device.h> 24#include <linux/device.h>
25#include <linux/etherdevice.h> 25#include <linux/etherdevice.h>
26#include <linux/crc32.h> 26#include <linux/crc32.h>
27#include <linux/slab.h>
27 28
28#include "u_ether.h" 29#include "u_ether.h"
29 30
diff --git a/drivers/usb/gadget/f_loopback.c b/drivers/usb/gadget/f_loopback.c
index 6cb29d3df57..e91d1b16d9b 100644
--- a/drivers/usb/gadget/f_loopback.c
+++ b/drivers/usb/gadget/f_loopback.c
@@ -21,6 +21,7 @@
21 21
22/* #define VERBOSE_DEBUG */ 22/* #define VERBOSE_DEBUG */
23 23
24#include <linux/slab.h>
24#include <linux/kernel.h> 25#include <linux/kernel.h>
25#include <linux/device.h> 26#include <linux/device.h>
26 27
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index 5a3cdd08f1d..f4911c09022 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -2910,7 +2910,7 @@ static void fsg_unbind(struct usb_configuration *c, struct usb_function *f)
2910} 2910}
2911 2911
2912 2912
2913static int fsg_bind(struct usb_configuration *c, struct usb_function *f) 2913static int __init fsg_bind(struct usb_configuration *c, struct usb_function *f)
2914{ 2914{
2915 struct fsg_dev *fsg = fsg_from_func(f); 2915 struct fsg_dev *fsg = fsg_from_func(f);
2916 struct usb_gadget *gadget = c->cdev->gadget; 2916 struct usb_gadget *gadget = c->cdev->gadget;
@@ -2954,7 +2954,6 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f)
2954autoconf_fail: 2954autoconf_fail:
2955 ERROR(fsg, "unable to autoconfigure all endpoints\n"); 2955 ERROR(fsg, "unable to autoconfigure all endpoints\n");
2956 rc = -ENOTSUPP; 2956 rc = -ENOTSUPP;
2957 fsg_unbind(c, f);
2958 return rc; 2957 return rc;
2959} 2958}
2960 2959
diff --git a/drivers/usb/gadget/f_obex.c b/drivers/usb/gadget/f_obex.c
index b4a3ba654ea..8f8c6437147 100644
--- a/drivers/usb/gadget/f_obex.c
+++ b/drivers/usb/gadget/f_obex.c
@@ -23,6 +23,7 @@
23 23
24/* #define VERBOSE_DEBUG */ 24/* #define VERBOSE_DEBUG */
25 25
26#include <linux/slab.h>
26#include <linux/kernel.h> 27#include <linux/kernel.h>
27#include <linux/device.h> 28#include <linux/device.h>
28 29
diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c
index d2de10b9dc4..3c6e1a05874 100644
--- a/drivers/usb/gadget/f_phonet.c
+++ b/drivers/usb/gadget/f_phonet.c
@@ -20,6 +20,7 @@
20 * 02110-1301 USA 20 * 02110-1301 USA
21 */ 21 */
22 22
23#include <linux/slab.h>
23#include <linux/kernel.h> 24#include <linux/kernel.h>
24#include <linux/device.h> 25#include <linux/device.h>
25 26
diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c
index a30e60c7f12..56b022150f2 100644
--- a/drivers/usb/gadget/f_rndis.c
+++ b/drivers/usb/gadget/f_rndis.c
@@ -24,6 +24,7 @@
24 24
25/* #define VERBOSE_DEBUG */ 25/* #define VERBOSE_DEBUG */
26 26
27#include <linux/slab.h>
27#include <linux/kernel.h> 28#include <linux/kernel.h>
28#include <linux/device.h> 29#include <linux/device.h>
29#include <linux/etherdevice.h> 30#include <linux/etherdevice.h>
diff --git a/drivers/usb/gadget/f_serial.c b/drivers/usb/gadget/f_serial.c
index db0aa93606e..490b00b01a7 100644
--- a/drivers/usb/gadget/f_serial.c
+++ b/drivers/usb/gadget/f_serial.c
@@ -10,6 +10,7 @@
10 * either version 2 of that License or (at your option) any later version. 10 * either version 2 of that License or (at your option) any later version.
11 */ 11 */
12 12
13#include <linux/slab.h>
13#include <linux/kernel.h> 14#include <linux/kernel.h>
14#include <linux/device.h> 15#include <linux/device.h>
15 16
diff --git a/drivers/usb/gadget/f_sourcesink.c b/drivers/usb/gadget/f_sourcesink.c
index 09cba273d2d..6d3cc443d91 100644
--- a/drivers/usb/gadget/f_sourcesink.c
+++ b/drivers/usb/gadget/f_sourcesink.c
@@ -21,6 +21,7 @@
21 21
22/* #define VERBOSE_DEBUG */ 22/* #define VERBOSE_DEBUG */
23 23
24#include <linux/slab.h>
24#include <linux/kernel.h> 25#include <linux/kernel.h>
25#include <linux/device.h> 26#include <linux/device.h>
26 27
diff --git a/drivers/usb/gadget/f_subset.c b/drivers/usb/gadget/f_subset.c
index a9c98fdb626..8675ca41532 100644
--- a/drivers/usb/gadget/f_subset.c
+++ b/drivers/usb/gadget/f_subset.c
@@ -19,6 +19,7 @@
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 20 */
21 21
22#include <linux/slab.h>
22#include <linux/kernel.h> 23#include <linux/kernel.h>
23#include <linux/device.h> 24#include <linux/device.h>
24#include <linux/etherdevice.h> 25#include <linux/etherdevice.h>
diff --git a/drivers/usb/gadget/gadget_chips.h b/drivers/usb/gadget/gadget_chips.h
index 1edbc12fff1..e511fec9f26 100644
--- a/drivers/usb/gadget/gadget_chips.h
+++ b/drivers/usb/gadget/gadget_chips.h
@@ -136,6 +136,12 @@
136#define gadget_is_r8a66597(g) 0 136#define gadget_is_r8a66597(g) 0
137#endif 137#endif
138 138
139#ifdef CONFIG_USB_S3C_HSOTG
140#define gadget_is_s3c_hsotg(g) (!strcmp("s3c-hsotg", (g)->name))
141#else
142#define gadget_is_s3c_hsotg(g) 0
143#endif
144
139 145
140/** 146/**
141 * usb_gadget_controller_number - support bcdDevice id convention 147 * usb_gadget_controller_number - support bcdDevice id convention
@@ -192,6 +198,8 @@ static inline int usb_gadget_controller_number(struct usb_gadget *gadget)
192 return 0x24; 198 return 0x24;
193 else if (gadget_is_r8a66597(gadget)) 199 else if (gadget_is_r8a66597(gadget))
194 return 0x25; 200 return 0x25;
201 else if (gadget_is_s3c_hsotg(gadget))
202 return 0x26;
195 return -ENOENT; 203 return -ENOENT;
196} 204}
197 205
diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c
index 04f6224b7e0..2b56ce62185 100644
--- a/drivers/usb/gadget/gmidi.c
+++ b/drivers/usb/gadget/gmidi.c
@@ -21,6 +21,7 @@
21/* #define VERBOSE_DEBUG */ 21/* #define VERBOSE_DEBUG */
22 22
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/slab.h>
24#include <linux/utsname.h> 25#include <linux/utsname.h>
25#include <linux/device.h> 26#include <linux/device.h>
26 27
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c
index e8edc640381..1088d08c7ed 100644
--- a/drivers/usb/gadget/goku_udc.c
+++ b/drivers/usb/gadget/goku_udc.c
@@ -1768,7 +1768,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1768 * usb_gadget_driver_{register,unregister}() must change. 1768 * usb_gadget_driver_{register,unregister}() must change.
1769 */ 1769 */
1770 if (the_controller) { 1770 if (the_controller) {
1771 WARNING(dev, "ignoring %s\n", pci_name(pdev)); 1771 pr_warning("ignoring %s\n", pci_name(pdev));
1772 return -EBUSY; 1772 return -EBUSY;
1773 } 1773 }
1774 if (!pdev->irq) { 1774 if (!pdev->irq) {
diff --git a/drivers/usb/gadget/imx_udc.c b/drivers/usb/gadget/imx_udc.c
index 01ee0b9bc95..e743122fcd9 100644
--- a/drivers/usb/gadget/imx_udc.c
+++ b/drivers/usb/gadget/imx_udc.c
@@ -29,6 +29,7 @@
29#include <linux/clk.h> 29#include <linux/clk.h>
30#include <linux/delay.h> 30#include <linux/delay.h>
31#include <linux/timer.h> 31#include <linux/timer.h>
32#include <linux/slab.h>
32 33
33#include <linux/usb/ch9.h> 34#include <linux/usb/ch9.h>
34#include <linux/usb/gadget.h> 35#include <linux/usb/gadget.h>
diff --git a/drivers/usb/gadget/lh7a40x_udc.c b/drivers/usb/gadget/lh7a40x_udc.c
index 6cd3d54f564..fded3fca793 100644
--- a/drivers/usb/gadget/lh7a40x_udc.c
+++ b/drivers/usb/gadget/lh7a40x_udc.c
@@ -22,6 +22,7 @@
22 */ 22 */
23 23
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/slab.h>
25 26
26#include "lh7a40x_udc.h" 27#include "lh7a40x_udc.h"
27 28
diff --git a/drivers/usb/gadget/m66592-udc.c b/drivers/usb/gadget/m66592-udc.c
index a8c8543d1b0..166bf71fd34 100644
--- a/drivers/usb/gadget/m66592-udc.c
+++ b/drivers/usb/gadget/m66592-udc.c
@@ -25,6 +25,7 @@
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/io.h> 26#include <linux/io.h>
27#include <linux/platform_device.h> 27#include <linux/platform_device.h>
28#include <linux/slab.h>
28#include <linux/err.h> 29#include <linux/err.h>
29#include <linux/usb/ch9.h> 30#include <linux/usb/ch9.h>
30#include <linux/usb/gadget.h> 31#include <linux/usb/gadget.h>
diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c
index 76496f5d272..a930d7fd7e7 100644
--- a/drivers/usb/gadget/multi.c
+++ b/drivers/usb/gadget/multi.c
@@ -211,8 +211,6 @@ static int __init cdc_do_config(struct usb_configuration *c)
211 ret = fsg_add(c->cdev, c, fsg_common); 211 ret = fsg_add(c->cdev, c, fsg_common);
212 if (ret < 0) 212 if (ret < 0)
213 return ret; 213 return ret;
214 if (ret < 0)
215 return ret;
216 214
217 return 0; 215 return 0;
218} 216}
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
index 05b892c3d68..85b0d8921ea 100644
--- a/drivers/usb/gadget/pxa27x_udc.c
+++ b/drivers/usb/gadget/pxa27x_udc.c
@@ -31,6 +31,7 @@
31#include <linux/clk.h> 31#include <linux/clk.h>
32#include <linux/irq.h> 32#include <linux/irq.h>
33#include <linux/gpio.h> 33#include <linux/gpio.h>
34#include <linux/slab.h>
34 35
35#include <asm/byteorder.h> 36#include <asm/byteorder.h>
36#include <mach/hardware.h> 37#include <mach/hardware.h>
diff --git a/drivers/usb/gadget/r8a66597-udc.c b/drivers/usb/gadget/r8a66597-udc.c
index 8b45145b913..888d8f166c0 100644
--- a/drivers/usb/gadget/r8a66597-udc.c
+++ b/drivers/usb/gadget/r8a66597-udc.c
@@ -27,6 +27,7 @@
27#include <linux/platform_device.h> 27#include <linux/platform_device.h>
28#include <linux/clk.h> 28#include <linux/clk.h>
29#include <linux/err.h> 29#include <linux/err.h>
30#include <linux/slab.h>
30 31
31#include <linux/usb/ch9.h> 32#include <linux/usb/ch9.h>
32#include <linux/usb/gadget.h> 33#include <linux/usb/gadget.h>
diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c
index 48267bc0b2e..5c0d06c79a8 100644
--- a/drivers/usb/gadget/rndis.c
+++ b/drivers/usb/gadget/rndis.c
@@ -28,6 +28,7 @@
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/list.h> 29#include <linux/list.h>
30#include <linux/proc_fs.h> 30#include <linux/proc_fs.h>
31#include <linux/slab.h>
31#include <linux/seq_file.h> 32#include <linux/seq_file.h>
32#include <linux/netdevice.h> 33#include <linux/netdevice.h>
33 34
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index f742c8e7397..1f73b485732 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -22,6 +22,7 @@
22#include <linux/seq_file.h> 22#include <linux/seq_file.h>
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/io.h> 24#include <linux/io.h>
25#include <linux/slab.h>
25 26
26#include <linux/usb/ch9.h> 27#include <linux/usb/ch9.h>
27#include <linux/usb/gadget.h> 28#include <linux/usb/gadget.h>
@@ -2144,6 +2145,7 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep,
2144 u32 epctrl; 2145 u32 epctrl;
2145 u32 mps; 2146 u32 mps;
2146 int dir_in; 2147 int dir_in;
2148 int ret = 0;
2147 2149
2148 dev_dbg(hsotg->dev, 2150 dev_dbg(hsotg->dev,
2149 "%s: ep %s: a 0x%02x, attr 0x%02x, mps 0x%04x, intr %d\n", 2151 "%s: ep %s: a 0x%02x, attr 0x%02x, mps 0x%04x, intr %d\n",
@@ -2195,7 +2197,8 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep,
2195 switch (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) { 2197 switch (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) {
2196 case USB_ENDPOINT_XFER_ISOC: 2198 case USB_ENDPOINT_XFER_ISOC:
2197 dev_err(hsotg->dev, "no current ISOC support\n"); 2199 dev_err(hsotg->dev, "no current ISOC support\n");
2198 return -EINVAL; 2200 ret = -EINVAL;
2201 goto out;
2199 2202
2200 case USB_ENDPOINT_XFER_BULK: 2203 case USB_ENDPOINT_XFER_BULK:
2201 epctrl |= S3C_DxEPCTL_EPType_Bulk; 2204 epctrl |= S3C_DxEPCTL_EPType_Bulk;
@@ -2234,8 +2237,9 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep,
2234 /* enable the endpoint interrupt */ 2237 /* enable the endpoint interrupt */
2235 s3c_hsotg_ctrl_epint(hsotg, index, dir_in, 1); 2238 s3c_hsotg_ctrl_epint(hsotg, index, dir_in, 1);
2236 2239
2240out:
2237 spin_unlock_irqrestore(&hs_ep->lock, flags); 2241 spin_unlock_irqrestore(&hs_ep->lock, flags);
2238 return 0; 2242 return ret;
2239} 2243}
2240 2244
2241static int s3c_hsotg_ep_disable(struct usb_ep *ep) 2245static int s3c_hsotg_ep_disable(struct usb_ep *ep)
diff --git a/drivers/usb/gadget/u_audio.c b/drivers/usb/gadget/u_audio.c
index 35e0930f5bb..7a86d2c9109 100644
--- a/drivers/usb/gadget/u_audio.c
+++ b/drivers/usb/gadget/u_audio.c
@@ -10,6 +10,7 @@
10 */ 10 */
11 11
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/slab.h>
13#include <linux/device.h> 14#include <linux/device.h>
14#include <linux/delay.h> 15#include <linux/delay.h>
15#include <linux/ctype.h> 16#include <linux/ctype.h>
diff --git a/drivers/usb/gadget/u_ether.c b/drivers/usb/gadget/u_ether.c
index 84ca195c2d1..07f4178ad17 100644
--- a/drivers/usb/gadget/u_ether.c
+++ b/drivers/usb/gadget/u_ether.c
@@ -23,6 +23,7 @@
23/* #define VERBOSE_DEBUG */ 23/* #define VERBOSE_DEBUG */
24 24
25#include <linux/kernel.h> 25#include <linux/kernel.h>
26#include <linux/gfp.h>
26#include <linux/device.h> 27#include <linux/device.h>
27#include <linux/ctype.h> 28#include <linux/ctype.h>
28#include <linux/etherdevice.h> 29#include <linux/etherdevice.h>
diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
index adf8260c3a6..16bdf77f582 100644
--- a/drivers/usb/gadget/u_serial.c
+++ b/drivers/usb/gadget/u_serial.c
@@ -23,6 +23,7 @@
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/tty.h> 24#include <linux/tty.h>
25#include <linux/tty_flip.h> 25#include <linux/tty_flip.h>
26#include <linux/slab.h>
26 27
27#include "u_serial.h" 28#include "u_serial.h"
28 29
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c
index fac81ee193d..807280d069f 100644
--- a/drivers/usb/gadget/zero.c
+++ b/drivers/usb/gadget/zero.c
@@ -50,6 +50,7 @@
50/* #define VERBOSE_DEBUG */ 50/* #define VERBOSE_DEBUG */
51 51
52#include <linux/kernel.h> 52#include <linux/kernel.h>
53#include <linux/slab.h>
53#include <linux/utsname.h> 54#include <linux/utsname.h>
54#include <linux/device.h> 55#include <linux/device.h>
55 56
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 4e0c67f1f51..b6315aa47f7 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -12,7 +12,7 @@ fhci-objs := fhci-hcd.o fhci-hub.o fhci-q.o fhci-mem.o \
12ifeq ($(CONFIG_FHCI_DEBUG),y) 12ifeq ($(CONFIG_FHCI_DEBUG),y)
13fhci-objs += fhci-dbg.o 13fhci-objs += fhci-dbg.o
14endif 14endif
15xhci-objs := xhci-hcd.o xhci-mem.o xhci-pci.o xhci-ring.o xhci-hub.o xhci-dbg.o 15xhci-hcd-objs := xhci.o xhci-mem.o xhci-pci.o xhci-ring.o xhci-hub.o xhci-dbg.o
16 16
17obj-$(CONFIG_USB_WHCI_HCD) += whci/ 17obj-$(CONFIG_USB_WHCI_HCD) += whci/
18 18
@@ -25,7 +25,7 @@ obj-$(CONFIG_USB_ISP1362_HCD) += isp1362-hcd.o
25obj-$(CONFIG_USB_OHCI_HCD) += ohci-hcd.o 25obj-$(CONFIG_USB_OHCI_HCD) += ohci-hcd.o
26obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o 26obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o
27obj-$(CONFIG_USB_FHCI_HCD) += fhci.o 27obj-$(CONFIG_USB_FHCI_HCD) += fhci.o
28obj-$(CONFIG_USB_XHCI_HCD) += xhci.o 28obj-$(CONFIG_USB_XHCI_HCD) += xhci-hcd.o
29obj-$(CONFIG_USB_SL811_HCD) += sl811-hcd.o 29obj-$(CONFIG_USB_SL811_HCD) += sl811-hcd.o
30obj-$(CONFIG_USB_SL811_CS) += sl811_cs.o 30obj-$(CONFIG_USB_SL811_CS) += sl811_cs.o
31obj-$(CONFIG_USB_U132_HCD) += u132-hcd.o 31obj-$(CONFIG_USB_U132_HCD) += u132-hcd.o
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index d8d6d3461d3..13ead00aecd 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -23,7 +23,6 @@
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/ioport.h> 24#include <linux/ioport.h>
25#include <linux/sched.h> 25#include <linux/sched.h>
26#include <linux/slab.h>
27#include <linux/vmalloc.h> 26#include <linux/vmalloc.h>
28#include <linux/errno.h> 27#include <linux/errno.h>
29#include <linux/init.h> 28#include <linux/init.h>
@@ -35,6 +34,7 @@
35#include <linux/moduleparam.h> 34#include <linux/moduleparam.h>
36#include <linux/dma-mapping.h> 35#include <linux/dma-mapping.h>
37#include <linux/debugfs.h> 36#include <linux/debugfs.h>
37#include <linux/slab.h>
38 38
39#include "../core/hcd.h" 39#include "../core/hcd.h"
40 40
@@ -543,6 +543,7 @@ static int ehci_init(struct usb_hcd *hcd)
543 */ 543 */
544 ehci->periodic_size = DEFAULT_I_TDPS; 544 ehci->periodic_size = DEFAULT_I_TDPS;
545 INIT_LIST_HEAD(&ehci->cached_itd_list); 545 INIT_LIST_HEAD(&ehci->cached_itd_list);
546 INIT_LIST_HEAD(&ehci->cached_sitd_list);
546 if ((retval = ehci_mem_init(ehci, GFP_KERNEL)) < 0) 547 if ((retval = ehci_mem_init(ehci, GFP_KERNEL)) < 0)
547 return retval; 548 return retval;
548 549
@@ -995,7 +996,7 @@ rescan:
995 /* endpoints can be iso streams. for now, we don't 996 /* endpoints can be iso streams. for now, we don't
996 * accelerate iso completions ... so spin a while. 997 * accelerate iso completions ... so spin a while.
997 */ 998 */
998 if (qh->hw->hw_info1 == 0) { 999 if (qh->hw == NULL) {
999 ehci_vdbg (ehci, "iso delay\n"); 1000 ehci_vdbg (ehci, "iso delay\n");
1000 goto idle_timeout; 1001 goto idle_timeout;
1001 } 1002 }
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 19372673bf0..c7178bcde67 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -801,7 +801,7 @@ static int ehci_hub_control (
801 * this bit; seems too long to spin routinely... 801 * this bit; seems too long to spin routinely...
802 */ 802 */
803 retval = handshake(ehci, status_reg, 803 retval = handshake(ehci, status_reg,
804 PORT_RESET, 0, 750); 804 PORT_RESET, 0, 1000);
805 if (retval != 0) { 805 if (retval != 0) {
806 ehci_err (ehci, "port %d reset error %d\n", 806 ehci_err (ehci, "port %d reset error %d\n",
807 wIndex + 1, retval); 807 wIndex + 1, retval);
diff --git a/drivers/usb/host/ehci-mem.c b/drivers/usb/host/ehci-mem.c
index aeda96e0af6..1f3f01eacaf 100644
--- a/drivers/usb/host/ehci-mem.c
+++ b/drivers/usb/host/ehci-mem.c
@@ -136,7 +136,7 @@ static inline void qh_put (struct ehci_qh *qh)
136 136
137static void ehci_mem_cleanup (struct ehci_hcd *ehci) 137static void ehci_mem_cleanup (struct ehci_hcd *ehci)
138{ 138{
139 free_cached_itd_list(ehci); 139 free_cached_lists(ehci);
140 if (ehci->async) 140 if (ehci->async)
141 qh_put (ehci->async); 141 qh_put (ehci->async);
142 ehci->async = NULL; 142 ehci->async = NULL;
diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
index 23cd917088b..ead59f42e69 100644
--- a/drivers/usb/host/ehci-mxc.c
+++ b/drivers/usb/host/ehci-mxc.c
@@ -21,6 +21,7 @@
21#include <linux/clk.h> 21#include <linux/clk.h>
22#include <linux/delay.h> 22#include <linux/delay.h>
23#include <linux/usb/otg.h> 23#include <linux/usb/otg.h>
24#include <linux/slab.h>
24 25
25#include <mach/mxc_ehci.h> 26#include <mach/mxc_ehci.h>
26 27
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index f0282d6bb7a..40a85833503 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -37,6 +37,7 @@
37#include <linux/clk.h> 37#include <linux/clk.h>
38#include <linux/gpio.h> 38#include <linux/gpio.h>
39#include <linux/regulator/consumer.h> 39#include <linux/regulator/consumer.h>
40#include <linux/slab.h>
40#include <plat/usb.h> 41#include <plat/usb.h>
41 42
42/* 43/*
@@ -628,11 +629,13 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
628 } 629 }
629 snprintf(supply, sizeof(supply), "hsusb%d", i); 630 snprintf(supply, sizeof(supply), "hsusb%d", i);
630 omap->regulator[i] = regulator_get(omap->dev, supply); 631 omap->regulator[i] = regulator_get(omap->dev, supply);
631 if (IS_ERR(omap->regulator[i])) 632 if (IS_ERR(omap->regulator[i])) {
633 omap->regulator[i] = NULL;
632 dev_dbg(&pdev->dev, 634 dev_dbg(&pdev->dev,
633 "failed to get ehci port%d regulator\n", i); 635 "failed to get ehci port%d regulator\n", i);
634 else 636 } else {
635 regulator_enable(omap->regulator[i]); 637 regulator_enable(omap->regulator[i]);
638 }
636 } 639 }
637 640
638 ret = omap_start_ehc(omap, hcd); 641 ret = omap_start_ehc(omap, hcd);
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index 39340ae00ac..805ec633a65 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -510,7 +510,7 @@ static int disable_periodic (struct ehci_hcd *ehci)
510 ehci_writel(ehci, cmd, &ehci->regs->command); 510 ehci_writel(ehci, cmd, &ehci->regs->command);
511 /* posted write ... */ 511 /* posted write ... */
512 512
513 free_cached_itd_list(ehci); 513 free_cached_lists(ehci);
514 514
515 ehci->next_uframe = -1; 515 ehci->next_uframe = -1;
516 return 0; 516 return 0;
@@ -1123,8 +1123,8 @@ iso_stream_find (struct ehci_hcd *ehci, struct urb *urb)
1123 urb->interval); 1123 urb->interval);
1124 } 1124 }
1125 1125
1126 /* if dev->ep [epnum] is a QH, info1.maxpacket is nonzero */ 1126 /* if dev->ep [epnum] is a QH, hw is set */
1127 } else if (unlikely (stream->hw_info1 != 0)) { 1127 } else if (unlikely (stream->hw != NULL)) {
1128 ehci_dbg (ehci, "dev %s ep%d%s, not iso??\n", 1128 ehci_dbg (ehci, "dev %s ep%d%s, not iso??\n",
1129 urb->dev->devpath, epnum, 1129 urb->dev->devpath, epnum,
1130 usb_pipein(urb->pipe) ? "in" : "out"); 1130 usb_pipein(urb->pipe) ? "in" : "out");
@@ -1565,13 +1565,27 @@ itd_patch(
1565static inline void 1565static inline void
1566itd_link (struct ehci_hcd *ehci, unsigned frame, struct ehci_itd *itd) 1566itd_link (struct ehci_hcd *ehci, unsigned frame, struct ehci_itd *itd)
1567{ 1567{
1568 /* always prepend ITD/SITD ... only QH tree is order-sensitive */ 1568 union ehci_shadow *prev = &ehci->pshadow[frame];
1569 itd->itd_next = ehci->pshadow [frame]; 1569 __hc32 *hw_p = &ehci->periodic[frame];
1570 itd->hw_next = ehci->periodic [frame]; 1570 union ehci_shadow here = *prev;
1571 ehci->pshadow [frame].itd = itd; 1571 __hc32 type = 0;
1572
1573 /* skip any iso nodes which might belong to previous microframes */
1574 while (here.ptr) {
1575 type = Q_NEXT_TYPE(ehci, *hw_p);
1576 if (type == cpu_to_hc32(ehci, Q_TYPE_QH))
1577 break;
1578 prev = periodic_next_shadow(ehci, prev, type);
1579 hw_p = shadow_next_periodic(ehci, &here, type);
1580 here = *prev;
1581 }
1582
1583 itd->itd_next = here;
1584 itd->hw_next = *hw_p;
1585 prev->itd = itd;
1572 itd->frame = frame; 1586 itd->frame = frame;
1573 wmb (); 1587 wmb ();
1574 ehci->periodic[frame] = cpu_to_hc32(ehci, itd->itd_dma | Q_TYPE_ITD); 1588 *hw_p = cpu_to_hc32(ehci, itd->itd_dma | Q_TYPE_ITD);
1575} 1589}
1576 1590
1577/* fit urb's itds into the selected schedule slot; activate as needed */ 1591/* fit urb's itds into the selected schedule slot; activate as needed */
@@ -2125,13 +2139,27 @@ sitd_complete (
2125 (stream->bEndpointAddress & USB_DIR_IN) ? "in" : "out"); 2139 (stream->bEndpointAddress & USB_DIR_IN) ? "in" : "out");
2126 } 2140 }
2127 iso_stream_put (ehci, stream); 2141 iso_stream_put (ehci, stream);
2128 /* OK to recycle this SITD now that its completion callback ran. */ 2142
2129done: 2143done:
2130 sitd->urb = NULL; 2144 sitd->urb = NULL;
2131 sitd->stream = NULL; 2145 if (ehci->clock_frame != sitd->frame) {
2132 list_move(&sitd->sitd_list, &stream->free_list); 2146 /* OK to recycle this SITD now. */
2133 iso_stream_put(ehci, stream); 2147 sitd->stream = NULL;
2134 2148 list_move(&sitd->sitd_list, &stream->free_list);
2149 iso_stream_put(ehci, stream);
2150 } else {
2151 /* HW might remember this SITD, so we can't recycle it yet.
2152 * Move it to a safe place until a new frame starts.
2153 */
2154 list_move(&sitd->sitd_list, &ehci->cached_sitd_list);
2155 if (stream->refcount == 2) {
2156 /* If iso_stream_put() were called here, stream
2157 * would be freed. Instead, just prevent reuse.
2158 */
2159 stream->ep->hcpriv = NULL;
2160 stream->ep = NULL;
2161 }
2162 }
2135 return retval; 2163 return retval;
2136} 2164}
2137 2165
@@ -2197,9 +2225,10 @@ done:
2197 2225
2198/*-------------------------------------------------------------------------*/ 2226/*-------------------------------------------------------------------------*/
2199 2227
2200static void free_cached_itd_list(struct ehci_hcd *ehci) 2228static void free_cached_lists(struct ehci_hcd *ehci)
2201{ 2229{
2202 struct ehci_itd *itd, *n; 2230 struct ehci_itd *itd, *n;
2231 struct ehci_sitd *sitd, *sn;
2203 2232
2204 list_for_each_entry_safe(itd, n, &ehci->cached_itd_list, itd_list) { 2233 list_for_each_entry_safe(itd, n, &ehci->cached_itd_list, itd_list) {
2205 struct ehci_iso_stream *stream = itd->stream; 2234 struct ehci_iso_stream *stream = itd->stream;
@@ -2207,6 +2236,13 @@ static void free_cached_itd_list(struct ehci_hcd *ehci)
2207 list_move(&itd->itd_list, &stream->free_list); 2236 list_move(&itd->itd_list, &stream->free_list);
2208 iso_stream_put(ehci, stream); 2237 iso_stream_put(ehci, stream);
2209 } 2238 }
2239
2240 list_for_each_entry_safe(sitd, sn, &ehci->cached_sitd_list, sitd_list) {
2241 struct ehci_iso_stream *stream = sitd->stream;
2242 sitd->stream = NULL;
2243 list_move(&sitd->sitd_list, &stream->free_list);
2244 iso_stream_put(ehci, stream);
2245 }
2210} 2246}
2211 2247
2212/*-------------------------------------------------------------------------*/ 2248/*-------------------------------------------------------------------------*/
@@ -2233,7 +2269,7 @@ scan_periodic (struct ehci_hcd *ehci)
2233 clock_frame = -1; 2269 clock_frame = -1;
2234 } 2270 }
2235 if (ehci->clock_frame != clock_frame) { 2271 if (ehci->clock_frame != clock_frame) {
2236 free_cached_itd_list(ehci); 2272 free_cached_lists(ehci);
2237 ehci->clock_frame = clock_frame; 2273 ehci->clock_frame = clock_frame;
2238 } 2274 }
2239 clock %= mod; 2275 clock %= mod;
@@ -2400,7 +2436,7 @@ restart:
2400 clock = now; 2436 clock = now;
2401 clock_frame = clock >> 3; 2437 clock_frame = clock >> 3;
2402 if (ehci->clock_frame != clock_frame) { 2438 if (ehci->clock_frame != clock_frame) {
2403 free_cached_itd_list(ehci); 2439 free_cached_lists(ehci);
2404 ehci->clock_frame = clock_frame; 2440 ehci->clock_frame = clock_frame;
2405 } 2441 }
2406 } else { 2442 } else {
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index 2d85e21ff28..556c0b48f3a 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -87,8 +87,9 @@ struct ehci_hcd { /* one per controller */
87 int next_uframe; /* scan periodic, start here */ 87 int next_uframe; /* scan periodic, start here */
88 unsigned periodic_sched; /* periodic activity count */ 88 unsigned periodic_sched; /* periodic activity count */
89 89
90 /* list of itds completed while clock_frame was still active */ 90 /* list of itds & sitds completed while clock_frame was still active */
91 struct list_head cached_itd_list; 91 struct list_head cached_itd_list;
92 struct list_head cached_sitd_list;
92 unsigned clock_frame; 93 unsigned clock_frame;
93 94
94 /* per root hub port */ 95 /* per root hub port */
@@ -195,7 +196,7 @@ timer_action_done (struct ehci_hcd *ehci, enum ehci_timer_action action)
195 clear_bit (action, &ehci->actions); 196 clear_bit (action, &ehci->actions);
196} 197}
197 198
198static void free_cached_itd_list(struct ehci_hcd *ehci); 199static void free_cached_lists(struct ehci_hcd *ehci);
199 200
200/*-------------------------------------------------------------------------*/ 201/*-------------------------------------------------------------------------*/
201 202
@@ -394,9 +395,8 @@ struct ehci_iso_sched {
394 * acts like a qh would, if EHCI had them for ISO. 395 * acts like a qh would, if EHCI had them for ISO.
395 */ 396 */
396struct ehci_iso_stream { 397struct ehci_iso_stream {
397 /* first two fields match QH, but info1 == 0 */ 398 /* first field matches ehci_hq, but is NULL */
398 __hc32 hw_next; 399 struct ehci_qh_hw *hw;
399 __hc32 hw_info1;
400 400
401 u32 refcount; 401 u32 refcount;
402 u8 bEndpointAddress; 402 u8 bEndpointAddress;
diff --git a/drivers/usb/host/fhci-hcd.c b/drivers/usb/host/fhci-hcd.c
index 5dcfb3de994..15379c63614 100644
--- a/drivers/usb/host/fhci-hcd.c
+++ b/drivers/usb/host/fhci-hcd.c
@@ -27,6 +27,7 @@
27#include <linux/usb.h> 27#include <linux/usb.h>
28#include <linux/of_platform.h> 28#include <linux/of_platform.h>
29#include <linux/of_gpio.h> 29#include <linux/of_gpio.h>
30#include <linux/slab.h>
30#include <asm/qe.h> 31#include <asm/qe.h>
31#include <asm/fsl_gtm.h> 32#include <asm/fsl_gtm.h>
32#include "../core/hcd.h" 33#include "../core/hcd.h"
diff --git a/drivers/usb/host/fhci-mem.c b/drivers/usb/host/fhci-mem.c
index 2c0736c9971..5591bfb499d 100644
--- a/drivers/usb/host/fhci-mem.c
+++ b/drivers/usb/host/fhci-mem.c
@@ -18,6 +18,7 @@
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/types.h> 19#include <linux/types.h>
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include <linux/slab.h>
21#include <linux/list.h> 22#include <linux/list.h>
22#include <linux/usb.h> 23#include <linux/usb.h>
23#include "../core/hcd.h" 24#include "../core/hcd.h"
diff --git a/drivers/usb/host/fhci-q.c b/drivers/usb/host/fhci-q.c
index b0a1446ba29..f73c92359be 100644
--- a/drivers/usb/host/fhci-q.c
+++ b/drivers/usb/host/fhci-q.c
@@ -19,6 +19,7 @@
19#include <linux/types.h> 19#include <linux/types.h>
20#include <linux/spinlock.h> 20#include <linux/spinlock.h>
21#include <linux/errno.h> 21#include <linux/errno.h>
22#include <linux/slab.h>
22#include <linux/list.h> 23#include <linux/list.h>
23#include <linux/usb.h> 24#include <linux/usb.h>
24#include "../core/hcd.h" 25#include "../core/hcd.h"
diff --git a/drivers/usb/host/fhci-tds.c b/drivers/usb/host/fhci-tds.c
index e1232890c78..57013479d7f 100644
--- a/drivers/usb/host/fhci-tds.c
+++ b/drivers/usb/host/fhci-tds.c
@@ -18,6 +18,7 @@
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/types.h> 19#include <linux/types.h>
20#include <linux/errno.h> 20#include <linux/errno.h>
21#include <linux/slab.h>
21#include <linux/list.h> 22#include <linux/list.h>
22#include <linux/io.h> 23#include <linux/io.h>
23#include <linux/usb.h> 24#include <linux/usb.h>
diff --git a/drivers/usb/host/hwa-hc.c b/drivers/usb/host/hwa-hc.c
index 88b03214622..35742f8c7cd 100644
--- a/drivers/usb/host/hwa-hc.c
+++ b/drivers/usb/host/hwa-hc.c
@@ -55,6 +55,7 @@
55 */ 55 */
56#include <linux/kernel.h> 56#include <linux/kernel.h>
57#include <linux/init.h> 57#include <linux/init.h>
58#include <linux/slab.h>
58#include <linux/module.h> 59#include <linux/module.h>
59#include <linux/workqueue.h> 60#include <linux/workqueue.h>
60#include <linux/wait.h> 61#include <linux/wait.h>
diff --git a/drivers/usb/host/imx21-hcd.c b/drivers/usb/host/imx21-hcd.c
index 213e270e1c2..8a12f297645 100644
--- a/drivers/usb/host/imx21-hcd.c
+++ b/drivers/usb/host/imx21-hcd.c
@@ -54,6 +54,7 @@
54#include <linux/kernel.h> 54#include <linux/kernel.h>
55#include <linux/list.h> 55#include <linux/list.h>
56#include <linux/platform_device.h> 56#include <linux/platform_device.h>
57#include <linux/slab.h>
57#include <linux/usb.h> 58#include <linux/usb.h>
58 59
59#include "../core/hcd.h" 60#include "../core/hcd.h"
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c
index a2b305477af..92de71dc772 100644
--- a/drivers/usb/host/isp116x-hcd.c
+++ b/drivers/usb/host/isp116x-hcd.c
@@ -62,6 +62,7 @@
62#include <linux/errno.h> 62#include <linux/errno.h>
63#include <linux/init.h> 63#include <linux/init.h>
64#include <linux/list.h> 64#include <linux/list.h>
65#include <linux/slab.h>
65#include <linux/usb.h> 66#include <linux/usb.h>
66#include <linux/usb/isp116x.h> 67#include <linux/usb/isp116x.h>
67#include <linux/platform_device.h> 68#include <linux/platform_device.h>
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 68b83ab7071..944291e10f9 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -331,6 +331,8 @@ ohci_hcd_at91_drv_suspend(struct platform_device *pdev, pm_message_t mesg)
331 */ 331 */
332 if (at91_suspend_entering_slow_clock()) { 332 if (at91_suspend_entering_slow_clock()) {
333 ohci_usb_reset (ohci); 333 ohci_usb_reset (ohci);
334 /* flush the writes */
335 (void) ohci_readl (ohci, &ohci->regs->control);
334 at91_stop_clock(); 336 at91_stop_clock();
335 } 337 }
336 338
diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 4aa08d36d07..d22fb4d577b 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -23,7 +23,7 @@
23#error "This file is DA8xx bus glue. Define CONFIG_ARCH_DAVINCI_DA8XX." 23#error "This file is DA8xx bus glue. Define CONFIG_ARCH_DAVINCI_DA8XX."
24#endif 24#endif
25 25
26#define CFGCHIP2 DA8XX_SYSCFG_VIRT(DA8XX_CFGCHIP2_REG) 26#define CFGCHIP2 DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG)
27 27
28static struct clk *usb11_clk; 28static struct clk *usb11_clk;
29static struct clk *usb20_clk; 29static struct clk *usb20_clk;
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
index 32bbce9718f..65cac8cc892 100644
--- a/drivers/usb/host/ohci-hub.c
+++ b/drivers/usb/host/ohci-hub.c
@@ -697,7 +697,7 @@ static int ohci_hub_control (
697 u16 wLength 697 u16 wLength
698) { 698) {
699 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 699 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
700 int ports = hcd_to_bus (hcd)->root_hub->maxchild; 700 int ports = ohci->num_ports;
701 u32 temp; 701 u32 temp;
702 int retval = 0; 702 int retval = 0;
703 703
diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c
index 35288bcae0d..83094d067e0 100644
--- a/drivers/usb/host/ohci-q.c
+++ b/drivers/usb/host/ohci-q.c
@@ -8,6 +8,7 @@
8 */ 8 */
9 9
10#include <linux/irq.h> 10#include <linux/irq.h>
11#include <linux/slab.h>
11 12
12static void urb_free_priv (struct ohci_hcd *hc, urb_priv_t *urb_priv) 13static void urb_free_priv (struct ohci_hcd *hc, urb_priv_t *urb_priv)
13{ 14{
diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hcd.c
index 50f57f46883..e62b30b3e42 100644
--- a/drivers/usb/host/oxu210hp-hcd.c
+++ b/drivers/usb/host/oxu210hp-hcd.c
@@ -660,13 +660,13 @@ static struct ehci_qh *oxu_qh_alloc(struct oxu_hcd *oxu)
660 if (qh->dummy == NULL) { 660 if (qh->dummy == NULL) {
661 oxu_dbg(oxu, "no dummy td\n"); 661 oxu_dbg(oxu, "no dummy td\n");
662 oxu->qh_used[i] = 0; 662 oxu->qh_used[i] = 0;
663 663 qh = NULL;
664 return NULL; 664 goto unlock;
665 } 665 }
666 666
667 oxu->qh_used[i] = 1; 667 oxu->qh_used[i] = 1;
668 } 668 }
669 669unlock:
670 spin_unlock(&oxu->mem_lock); 670 spin_unlock(&oxu->mem_lock);
671 671
672 return qh; 672 return qh;
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index bee558aed42..d478ffad59b 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -37,6 +37,7 @@
37#include <linux/io.h> 37#include <linux/io.h>
38#include <linux/mm.h> 38#include <linux/mm.h>
39#include <linux/irq.h> 39#include <linux/irq.h>
40#include <linux/slab.h>
40#include <asm/cacheflush.h> 41#include <asm/cacheflush.h>
41 42
42#include "../core/hcd.h" 43#include "../core/hcd.h"
@@ -418,7 +419,7 @@ static u8 alloc_usb_address(struct r8a66597 *r8a66597, struct urb *urb)
418 419
419/* this function must be called with interrupt disabled */ 420/* this function must be called with interrupt disabled */
420static void free_usb_address(struct r8a66597 *r8a66597, 421static void free_usb_address(struct r8a66597 *r8a66597,
421 struct r8a66597_device *dev) 422 struct r8a66597_device *dev, int reset)
422{ 423{
423 int port; 424 int port;
424 425
@@ -430,7 +431,13 @@ static void free_usb_address(struct r8a66597 *r8a66597,
430 dev->state = USB_STATE_DEFAULT; 431 dev->state = USB_STATE_DEFAULT;
431 r8a66597->address_map &= ~(1 << dev->address); 432 r8a66597->address_map &= ~(1 << dev->address);
432 dev->address = 0; 433 dev->address = 0;
433 dev_set_drvdata(&dev->udev->dev, NULL); 434 /*
435 * Only when resetting USB, it is necessary to erase drvdata. When
436 * a usb device with usb hub is disconnect, "dev->udev" is already
437 * freed on usb_desconnect(). So we cannot access the data.
438 */
439 if (reset)
440 dev_set_drvdata(&dev->udev->dev, NULL);
434 list_del(&dev->device_list); 441 list_del(&dev->device_list);
435 kfree(dev); 442 kfree(dev);
436 443
@@ -1069,7 +1076,7 @@ static void r8a66597_usb_disconnect(struct r8a66597 *r8a66597, int port)
1069 struct r8a66597_device *dev = r8a66597->root_hub[port].dev; 1076 struct r8a66597_device *dev = r8a66597->root_hub[port].dev;
1070 1077
1071 disable_r8a66597_pipe_all(r8a66597, dev); 1078 disable_r8a66597_pipe_all(r8a66597, dev);
1072 free_usb_address(r8a66597, dev); 1079 free_usb_address(r8a66597, dev, 0);
1073 1080
1074 start_root_hub_sampling(r8a66597, port, 0); 1081 start_root_hub_sampling(r8a66597, port, 0);
1075} 1082}
@@ -2085,7 +2092,7 @@ static void update_usb_address_map(struct r8a66597 *r8a66597,
2085 spin_lock_irqsave(&r8a66597->lock, flags); 2092 spin_lock_irqsave(&r8a66597->lock, flags);
2086 dev = get_r8a66597_device(r8a66597, addr); 2093 dev = get_r8a66597_device(r8a66597, addr);
2087 disable_r8a66597_pipe_all(r8a66597, dev); 2094 disable_r8a66597_pipe_all(r8a66597, dev);
2088 free_usb_address(r8a66597, dev); 2095 free_usb_address(r8a66597, dev, 0);
2089 put_child_connect_map(r8a66597, addr); 2096 put_child_connect_map(r8a66597, addr);
2090 spin_unlock_irqrestore(&r8a66597->lock, flags); 2097 spin_unlock_irqrestore(&r8a66597->lock, flags);
2091 } 2098 }
@@ -2228,7 +2235,7 @@ static int r8a66597_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
2228 rh->port |= (1 << USB_PORT_FEAT_RESET); 2235 rh->port |= (1 << USB_PORT_FEAT_RESET);
2229 2236
2230 disable_r8a66597_pipe_all(r8a66597, dev); 2237 disable_r8a66597_pipe_all(r8a66597, dev);
2231 free_usb_address(r8a66597, dev); 2238 free_usb_address(r8a66597, dev, 1);
2232 2239
2233 r8a66597_mdfy(r8a66597, USBRST, USBRST | UACT, 2240 r8a66597_mdfy(r8a66597, USBRST, USBRST | UACT,
2234 get_dvstctr_reg(port)); 2241 get_dvstctr_reg(port));
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index e11cc3aa4b8..3b867a8af7b 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -720,10 +720,10 @@ retry:
720 /* port status seems weird until after reset, so 720 /* port status seems weird until after reset, so
721 * force the reset and make khubd clean up later. 721 * force the reset and make khubd clean up later.
722 */ 722 */
723 if (sl811->stat_insrmv & 1) 723 if (irqstat & SL11H_INTMASK_RD)
724 sl811->port1 |= 1 << USB_PORT_FEAT_CONNECTION;
725 else
726 sl811->port1 &= ~(1 << USB_PORT_FEAT_CONNECTION); 724 sl811->port1 &= ~(1 << USB_PORT_FEAT_CONNECTION);
725 else
726 sl811->port1 |= 1 << USB_PORT_FEAT_CONNECTION;
727 727
728 sl811->port1 |= 1 << USB_PORT_FEAT_C_CONNECTION; 728 sl811->port1 |= 1 << USB_PORT_FEAT_C_CONNECTION;
729 729
diff --git a/drivers/usb/host/uhci-debug.c b/drivers/usb/host/uhci-debug.c
index e52b954dda4..98cf0b26b96 100644
--- a/drivers/usb/host/uhci-debug.c
+++ b/drivers/usb/host/uhci-debug.c
@@ -9,6 +9,7 @@
9 * (C) Copyright 1999-2001 Johannes Erdfelt 9 * (C) Copyright 1999-2001 Johannes Erdfelt
10 */ 10 */
11 11
12#include <linux/slab.h>
12#include <linux/kernel.h> 13#include <linux/kernel.h>
13#include <linux/debugfs.h> 14#include <linux/debugfs.h>
14#include <linux/smp_lock.h> 15#include <linux/smp_lock.h>
diff --git a/drivers/usb/host/whci/asl.c b/drivers/usb/host/whci/asl.c
index 562eba10881..77324930603 100644
--- a/drivers/usb/host/whci/asl.c
+++ b/drivers/usb/host/whci/asl.c
@@ -16,6 +16,7 @@
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 17 */
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/gfp.h>
19#include <linux/dma-mapping.h> 20#include <linux/dma-mapping.h>
20#include <linux/uwb/umc.h> 21#include <linux/uwb/umc.h>
21#include <linux/usb.h> 22#include <linux/usb.h>
diff --git a/drivers/usb/host/whci/debug.c b/drivers/usb/host/whci/debug.c
index 8c1c610c951..c5305b599ca 100644
--- a/drivers/usb/host/whci/debug.c
+++ b/drivers/usb/host/whci/debug.c
@@ -15,6 +15,7 @@
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 17 */
18#include <linux/slab.h>
18#include <linux/kernel.h> 19#include <linux/kernel.h>
19#include <linux/debugfs.h> 20#include <linux/debugfs.h>
20#include <linux/seq_file.h> 21#include <linux/seq_file.h>
diff --git a/drivers/usb/host/whci/init.c b/drivers/usb/host/whci/init.c
index 34a783cb013..f7582e8e216 100644
--- a/drivers/usb/host/whci/init.c
+++ b/drivers/usb/host/whci/init.c
@@ -16,6 +16,7 @@
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 17 */
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/gfp.h>
19#include <linux/dma-mapping.h> 20#include <linux/dma-mapping.h>
20#include <linux/uwb/umc.h> 21#include <linux/uwb/umc.h>
21 22
diff --git a/drivers/usb/host/whci/pzl.c b/drivers/usb/host/whci/pzl.c
index 0db3fb2dc03..33c5580b4d2 100644
--- a/drivers/usb/host/whci/pzl.c
+++ b/drivers/usb/host/whci/pzl.c
@@ -16,6 +16,7 @@
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 17 */
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/gfp.h>
19#include <linux/dma-mapping.h> 20#include <linux/dma-mapping.h>
20#include <linux/uwb/umc.h> 21#include <linux/uwb/umc.h>
21#include <linux/usb.h> 22#include <linux/usb.h>
diff --git a/drivers/usb/host/whci/qset.c b/drivers/usb/host/whci/qset.c
index 7d4204db0f6..141d049beb3 100644
--- a/drivers/usb/host/whci/qset.c
+++ b/drivers/usb/host/whci/qset.c
@@ -17,6 +17,7 @@
17 */ 17 */
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/dma-mapping.h> 19#include <linux/dma-mapping.h>
20#include <linux/slab.h>
20#include <linux/uwb/umc.h> 21#include <linux/uwb/umc.h>
21#include <linux/usb.h> 22#include <linux/usb.h>
22 23
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 49f7d72f8b1..d64f5724bfc 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -22,6 +22,7 @@
22 22
23#include <linux/usb.h> 23#include <linux/usb.h>
24#include <linux/pci.h> 24#include <linux/pci.h>
25#include <linux/slab.h>
25#include <linux/dmapool.h> 26#include <linux/dmapool.h>
26 27
27#include "xhci.h" 28#include "xhci.h"
@@ -566,8 +567,13 @@ static inline unsigned int xhci_get_endpoint_interval(struct usb_device *udev,
566 if (interval < 3) 567 if (interval < 3)
567 interval = 3; 568 interval = 3;
568 if ((1 << interval) != 8*ep->desc.bInterval) 569 if ((1 << interval) != 8*ep->desc.bInterval)
569 dev_warn(&udev->dev, "ep %#x - rounding interval to %d microframes\n", 570 dev_warn(&udev->dev,
570 ep->desc.bEndpointAddress, 1 << interval); 571 "ep %#x - rounding interval"
572 " to %d microframes, "
573 "ep desc says %d microframes\n",
574 ep->desc.bEndpointAddress,
575 1 << interval,
576 8*ep->desc.bInterval);
571 } 577 }
572 break; 578 break;
573 default: 579 default:
@@ -576,6 +582,19 @@ static inline unsigned int xhci_get_endpoint_interval(struct usb_device *udev,
576 return EP_INTERVAL(interval); 582 return EP_INTERVAL(interval);
577} 583}
578 584
585/* The "Mult" field in the endpoint context is only set for SuperSpeed devices.
586 * High speed endpoint descriptors can define "the number of additional
587 * transaction opportunities per microframe", but that goes in the Max Burst
588 * endpoint context field.
589 */
590static inline u32 xhci_get_endpoint_mult(struct usb_device *udev,
591 struct usb_host_endpoint *ep)
592{
593 if (udev->speed != USB_SPEED_SUPER || !ep->ss_ep_comp)
594 return 0;
595 return ep->ss_ep_comp->desc.bmAttributes;
596}
597
579static inline u32 xhci_get_endpoint_type(struct usb_device *udev, 598static inline u32 xhci_get_endpoint_type(struct usb_device *udev,
580 struct usb_host_endpoint *ep) 599 struct usb_host_endpoint *ep)
581{ 600{
@@ -606,6 +625,36 @@ static inline u32 xhci_get_endpoint_type(struct usb_device *udev,
606 return type; 625 return type;
607} 626}
608 627
628/* Return the maximum endpoint service interval time (ESIT) payload.
629 * Basically, this is the maxpacket size, multiplied by the burst size
630 * and mult size.
631 */
632static inline u32 xhci_get_max_esit_payload(struct xhci_hcd *xhci,
633 struct usb_device *udev,
634 struct usb_host_endpoint *ep)
635{
636 int max_burst;
637 int max_packet;
638
639 /* Only applies for interrupt or isochronous endpoints */
640 if (usb_endpoint_xfer_control(&ep->desc) ||
641 usb_endpoint_xfer_bulk(&ep->desc))
642 return 0;
643
644 if (udev->speed == USB_SPEED_SUPER) {
645 if (ep->ss_ep_comp)
646 return ep->ss_ep_comp->desc.wBytesPerInterval;
647 xhci_warn(xhci, "WARN no SS endpoint companion descriptor.\n");
648 /* Assume no bursts, no multiple opportunities to send. */
649 return ep->desc.wMaxPacketSize;
650 }
651
652 max_packet = ep->desc.wMaxPacketSize & 0x3ff;
653 max_burst = (ep->desc.wMaxPacketSize & 0x1800) >> 11;
654 /* A 0 in max burst means 1 transfer per ESIT */
655 return max_packet * (max_burst + 1);
656}
657
609int xhci_endpoint_init(struct xhci_hcd *xhci, 658int xhci_endpoint_init(struct xhci_hcd *xhci,
610 struct xhci_virt_device *virt_dev, 659 struct xhci_virt_device *virt_dev,
611 struct usb_device *udev, 660 struct usb_device *udev,
@@ -617,6 +666,7 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,
617 struct xhci_ring *ep_ring; 666 struct xhci_ring *ep_ring;
618 unsigned int max_packet; 667 unsigned int max_packet;
619 unsigned int max_burst; 668 unsigned int max_burst;
669 u32 max_esit_payload;
620 670
621 ep_index = xhci_get_endpoint_index(&ep->desc); 671 ep_index = xhci_get_endpoint_index(&ep->desc);
622 ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index); 672 ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index);
@@ -638,6 +688,7 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,
638 ep_ctx->deq = ep_ring->first_seg->dma | ep_ring->cycle_state; 688 ep_ctx->deq = ep_ring->first_seg->dma | ep_ring->cycle_state;
639 689
640 ep_ctx->ep_info = xhci_get_endpoint_interval(udev, ep); 690 ep_ctx->ep_info = xhci_get_endpoint_interval(udev, ep);
691 ep_ctx->ep_info |= EP_MULT(xhci_get_endpoint_mult(udev, ep));
641 692
642 /* FIXME dig Mult and streams info out of ep companion desc */ 693 /* FIXME dig Mult and streams info out of ep companion desc */
643 694
@@ -683,6 +734,26 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,
683 default: 734 default:
684 BUG(); 735 BUG();
685 } 736 }
737 max_esit_payload = xhci_get_max_esit_payload(xhci, udev, ep);
738 ep_ctx->tx_info = MAX_ESIT_PAYLOAD_FOR_EP(max_esit_payload);
739
740 /*
741 * XXX no idea how to calculate the average TRB buffer length for bulk
742 * endpoints, as the driver gives us no clue how big each scatter gather
743 * list entry (or buffer) is going to be.
744 *
745 * For isochronous and interrupt endpoints, we set it to the max
746 * available, until we have new API in the USB core to allow drivers to
747 * declare how much bandwidth they actually need.
748 *
749 * Normally, it would be calculated by taking the total of the buffer
750 * lengths in the TD and then dividing by the number of TRBs in a TD,
751 * including link TRBs, No-op TRBs, and Event data TRBs. Since we don't
752 * use Event Data TRBs, and we don't chain in a link TRB on short
753 * transfers, we're basically dividing by 1.
754 */
755 ep_ctx->tx_info |= AVG_TRB_LENGTH_FOR_EP(max_esit_payload);
756
686 /* FIXME Debug endpoint context */ 757 /* FIXME Debug endpoint context */
687 return 0; 758 return 0;
688} 759}
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 6ba841bca4a..85d7e8f2085 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -65,6 +65,7 @@
65 */ 65 */
66 66
67#include <linux/scatterlist.h> 67#include <linux/scatterlist.h>
68#include <linux/slab.h>
68#include "xhci.h" 69#include "xhci.h"
69 70
70/* 71/*
diff --git a/drivers/usb/host/xhci-hcd.c b/drivers/usb/host/xhci.c
index 4cb69e0af83..7e427727390 100644
--- a/drivers/usb/host/xhci-hcd.c
+++ b/drivers/usb/host/xhci.c
@@ -23,6 +23,7 @@
23#include <linux/irq.h> 23#include <linux/irq.h>
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/moduleparam.h> 25#include <linux/moduleparam.h>
26#include <linux/slab.h>
26 27
27#include "xhci.h" 28#include "xhci.h"
28 29
@@ -1173,6 +1174,7 @@ static int xhci_configure_endpoint(struct xhci_hcd *xhci,
1173 cmd_completion = &virt_dev->cmd_completion; 1174 cmd_completion = &virt_dev->cmd_completion;
1174 cmd_status = &virt_dev->cmd_status; 1175 cmd_status = &virt_dev->cmd_status;
1175 } 1176 }
1177 init_completion(cmd_completion);
1176 1178
1177 if (!ctx_change) 1179 if (!ctx_change)
1178 ret = xhci_queue_configure_endpoint(xhci, in_ctx->dma, 1180 ret = xhci_queue_configure_endpoint(xhci, in_ctx->dma,
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index e5eb09b2f38..ea389e9a493 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -609,6 +609,10 @@ struct xhci_ep_ctx {
609#define MAX_PACKET_MASK (0xffff << 16) 609#define MAX_PACKET_MASK (0xffff << 16)
610#define MAX_PACKET_DECODED(p) (((p) >> 16) & 0xffff) 610#define MAX_PACKET_DECODED(p) (((p) >> 16) & 0xffff)
611 611
612/* tx_info bitmasks */
613#define AVG_TRB_LENGTH_FOR_EP(p) ((p) & 0xffff)
614#define MAX_ESIT_PAYLOAD_FOR_EP(p) (((p) & 0xffff) << 16)
615
612 616
613/** 617/**
614 * struct xhci_input_control_context 618 * struct xhci_input_control_context
diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
index 3adab041355..094f91cbc57 100644
--- a/drivers/usb/misc/appledisplay.c
+++ b/drivers/usb/misc/appledisplay.c
@@ -24,6 +24,7 @@
24#include <linux/errno.h> 24#include <linux/errno.h>
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/slab.h>
27#include <linux/usb.h> 28#include <linux/usb.h>
28#include <linux/backlight.h> 29#include <linux/backlight.h>
29#include <linux/timer.h> 30#include <linux/timer.h>
diff --git a/drivers/usb/misc/cypress_cy7c63.c b/drivers/usb/misc/cypress_cy7c63.c
index 1547d8cac5f..2f43c57743c 100644
--- a/drivers/usb/misc/cypress_cy7c63.c
+++ b/drivers/usb/misc/cypress_cy7c63.c
@@ -32,6 +32,7 @@
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/kernel.h> 34#include <linux/kernel.h>
35#include <linux/slab.h>
35#include <linux/usb.h> 36#include <linux/usb.h>
36 37
37#define DRIVER_AUTHOR "Oliver Bock (bock@tfh-berlin.de)" 38#define DRIVER_AUTHOR "Oliver Bock (bock@tfh-berlin.de)"
diff --git a/drivers/usb/misc/cytherm.c b/drivers/usb/misc/cytherm.c
index b9cbbbda824..1d7251bc1b5 100644
--- a/drivers/usb/misc/cytherm.c
+++ b/drivers/usb/misc/cytherm.c
@@ -17,6 +17,7 @@
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/errno.h> 18#include <linux/errno.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/slab.h>
20#include <linux/module.h> 21#include <linux/module.h>
21#include <linux/usb.h> 22#include <linux/usb.h>
22 23
diff --git a/drivers/usb/misc/isight_firmware.c b/drivers/usb/misc/isight_firmware.c
index 06e990adc6c..fe1d44319d0 100644
--- a/drivers/usb/misc/isight_firmware.c
+++ b/drivers/usb/misc/isight_firmware.c
@@ -25,6 +25,7 @@
25#include <linux/firmware.h> 25#include <linux/firmware.h>
26#include <linux/errno.h> 26#include <linux/errno.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/slab.h>
28 29
29static const struct usb_device_id id_table[] = { 30static const struct usb_device_id id_table[] = {
30 {USB_DEVICE(0x05ac, 0x8300)}, 31 {USB_DEVICE(0x05ac, 0x8300)},
diff --git a/drivers/usb/misc/sisusbvga/sisusb_con.c b/drivers/usb/misc/sisusbvga/sisusb_con.c
index b624320df90..b271b0557a1 100644
--- a/drivers/usb/misc/sisusbvga/sisusb_con.c
+++ b/drivers/usb/misc/sisusbvga/sisusb_con.c
@@ -58,7 +58,6 @@
58#include <linux/string.h> 58#include <linux/string.h>
59#include <linux/kd.h> 59#include <linux/kd.h>
60#include <linux/init.h> 60#include <linux/init.h>
61#include <linux/slab.h>
62#include <linux/vt_kern.h> 61#include <linux/vt_kern.h>
63#include <linux/selection.h> 62#include <linux/selection.h>
64#include <linux/spinlock.h> 63#include <linux/spinlock.h>
diff --git a/drivers/usb/misc/sisusbvga/sisusb_init.c b/drivers/usb/misc/sisusbvga/sisusb_init.c
index 0ab99074483..cb8a3d91f97 100644
--- a/drivers/usb/misc/sisusbvga/sisusb_init.c
+++ b/drivers/usb/misc/sisusbvga/sisusb_init.c
@@ -41,7 +41,6 @@
41#include <linux/errno.h> 41#include <linux/errno.h>
42#include <linux/poll.h> 42#include <linux/poll.h>
43#include <linux/init.h> 43#include <linux/init.h>
44#include <linux/slab.h>
45#include <linux/spinlock.h> 44#include <linux/spinlock.h>
46 45
47#include "sisusb.h" 46#include "sisusb.h"
diff --git a/drivers/usb/misc/trancevibrator.c b/drivers/usb/misc/trancevibrator.c
index 5da28eaee31..d77aba46ae8 100644
--- a/drivers/usb/misc/trancevibrator.c
+++ b/drivers/usb/misc/trancevibrator.c
@@ -22,6 +22,7 @@
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/errno.h> 23#include <linux/errno.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/slab.h>
25#include <linux/module.h> 26#include <linux/module.h>
26#include <linux/usb.h> 27#include <linux/usb.h>
27 28
diff --git a/drivers/usb/misc/usbsevseg.c b/drivers/usb/misc/usbsevseg.c
index a9555cb901a..de8ef945b53 100644
--- a/drivers/usb/misc/usbsevseg.c
+++ b/drivers/usb/misc/usbsevseg.c
@@ -49,6 +49,7 @@ struct usb_sevsegdev {
49 u16 textlength; 49 u16 textlength;
50 50
51 u8 shadow_power; /* for PM */ 51 u8 shadow_power; /* for PM */
52 u8 has_interface_pm;
52}; 53};
53 54
54/* sysfs_streq can't replace this completely 55/* sysfs_streq can't replace this completely
@@ -68,12 +69,16 @@ static void update_display_powered(struct usb_sevsegdev *mydev)
68{ 69{
69 int rc; 70 int rc;
70 71
71 if (!mydev->shadow_power && mydev->powered) { 72 if (mydev->powered && !mydev->has_interface_pm) {
72 rc = usb_autopm_get_interface(mydev->intf); 73 rc = usb_autopm_get_interface(mydev->intf);
73 if (rc < 0) 74 if (rc < 0)
74 return; 75 return;
76 mydev->has_interface_pm = 1;
75 } 77 }
76 78
79 if (mydev->shadow_power != 1)
80 return;
81
77 rc = usb_control_msg(mydev->udev, 82 rc = usb_control_msg(mydev->udev,
78 usb_sndctrlpipe(mydev->udev, 0), 83 usb_sndctrlpipe(mydev->udev, 0),
79 0x12, 84 0x12,
@@ -86,8 +91,10 @@ static void update_display_powered(struct usb_sevsegdev *mydev)
86 if (rc < 0) 91 if (rc < 0)
87 dev_dbg(&mydev->udev->dev, "power retval = %d\n", rc); 92 dev_dbg(&mydev->udev->dev, "power retval = %d\n", rc);
88 93
89 if (mydev->shadow_power && !mydev->powered) 94 if (!mydev->powered && mydev->has_interface_pm) {
90 usb_autopm_put_interface(mydev->intf); 95 usb_autopm_put_interface(mydev->intf);
96 mydev->has_interface_pm = 0;
97 }
91} 98}
92 99
93static void update_display_mode(struct usb_sevsegdev *mydev) 100static void update_display_mode(struct usb_sevsegdev *mydev)
@@ -351,6 +358,10 @@ static int sevseg_probe(struct usb_interface *interface,
351 mydev->intf = interface; 358 mydev->intf = interface;
352 usb_set_intfdata(interface, mydev); 359 usb_set_intfdata(interface, mydev);
353 360
361 /* PM */
362 mydev->shadow_power = 1; /* currently active */
363 mydev->has_interface_pm = 0; /* have not issued autopm_get */
364
354 /*set defaults */ 365 /*set defaults */
355 mydev->textmode = 0x02; /* ascii mode */ 366 mydev->textmode = 0x02; /* ascii mode */
356 mydev->mode_msb = 0x06; /* 6 characters */ 367 mydev->mode_msb = 0x06; /* 6 characters */
diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c
index f56fed53f2d..796e2f68f74 100644
--- a/drivers/usb/misc/uss720.c
+++ b/drivers/usb/misc/uss720.c
@@ -49,6 +49,7 @@
49#include <linux/delay.h> 49#include <linux/delay.h>
50#include <linux/completion.h> 50#include <linux/completion.h>
51#include <linux/kref.h> 51#include <linux/kref.h>
52#include <linux/slab.h>
52 53
53/* 54/*
54 * Version Information 55 * Version Information
diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c
index 6dd44bc1f5f..ddf7f9a1b33 100644
--- a/drivers/usb/mon/mon_bin.c
+++ b/drivers/usb/mon/mon_bin.c
@@ -17,6 +17,7 @@
17#include <linux/mm.h> 17#include <linux/mm.h>
18#include <linux/smp_lock.h> 18#include <linux/smp_lock.h>
19#include <linux/scatterlist.h> 19#include <linux/scatterlist.h>
20#include <linux/slab.h>
20 21
21#include <asm/uaccess.h> 22#include <asm/uaccess.h>
22 23
diff --git a/drivers/usb/mon/mon_main.c b/drivers/usb/mon/mon_main.c
index e0c2db3b767..e4af18b93c7 100644
--- a/drivers/usb/mon/mon_main.c
+++ b/drivers/usb/mon/mon_main.c
@@ -9,6 +9,7 @@
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/usb.h> 11#include <linux/usb.h>
12#include <linux/slab.h>
12#include <linux/notifier.h> 13#include <linux/notifier.h>
13#include <linux/mutex.h> 14#include <linux/mutex.h>
14 15
diff --git a/drivers/usb/mon/mon_stat.c b/drivers/usb/mon/mon_stat.c
index ac8b0d5ce7f..1becdc3837e 100644
--- a/drivers/usb/mon/mon_stat.c
+++ b/drivers/usb/mon/mon_stat.c
@@ -8,6 +8,7 @@
8 */ 8 */
9 9
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/slab.h>
11#include <linux/usb.h> 12#include <linux/usb.h>
12#include <linux/fs.h> 13#include <linux/fs.h>
13#include <asm/uaccess.h> 14#include <asm/uaccess.h>
diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c
index 31c11888ec6..4d0be130f49 100644
--- a/drivers/usb/mon/mon_text.c
+++ b/drivers/usb/mon/mon_text.c
@@ -7,6 +7,7 @@
7#include <linux/kernel.h> 7#include <linux/kernel.h>
8#include <linux/list.h> 8#include <linux/list.h>
9#include <linux/usb.h> 9#include <linux/usb.h>
10#include <linux/slab.h>
10#include <linux/time.h> 11#include <linux/time.h>
11#include <linux/mutex.h> 12#include <linux/mutex.h>
12#include <linux/debugfs.h> 13#include <linux/debugfs.h>
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index b4c783c284b..07fe490b44d 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -42,7 +42,7 @@ config USB_MUSB_SOC
42 default y if (BF52x && !BF522 && !BF523) 42 default y if (BF52x && !BF522 && !BF523)
43 43
44comment "DaVinci 35x and 644x USB support" 44comment "DaVinci 35x and 644x USB support"
45 depends on USB_MUSB_HDRC && ARCH_DAVINCI 45 depends on USB_MUSB_HDRC && ARCH_DAVINCI_DMx
46 46
47comment "OMAP 243x high speed USB support" 47comment "OMAP 243x high speed USB support"
48 depends on USB_MUSB_HDRC && ARCH_OMAP2430 48 depends on USB_MUSB_HDRC && ARCH_OMAP2430
diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile
index 85710ccc188..3a485dabebb 100644
--- a/drivers/usb/musb/Makefile
+++ b/drivers/usb/musb/Makefile
@@ -6,7 +6,7 @@ musb_hdrc-objs := musb_core.o
6 6
7obj-$(CONFIG_USB_MUSB_HDRC) += musb_hdrc.o 7obj-$(CONFIG_USB_MUSB_HDRC) += musb_hdrc.o
8 8
9ifeq ($(CONFIG_ARCH_DAVINCI),y) 9ifeq ($(CONFIG_ARCH_DAVINCI_DMx),y)
10 musb_hdrc-objs += davinci.o 10 musb_hdrc-objs += davinci.o
11endif 11endif
12 12
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index bcee1339d4f..ec8d324237f 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -11,7 +11,6 @@
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/sched.h> 13#include <linux/sched.h>
14#include <linux/slab.h>
15#include <linux/init.h> 14#include <linux/init.h>
16#include <linux/list.h> 15#include <linux/list.h>
17#include <linux/gpio.h> 16#include <linux/gpio.h>
@@ -173,13 +172,7 @@ static irqreturn_t blackfin_interrupt(int irq, void *__hci)
173 172
174 spin_unlock_irqrestore(&musb->lock, flags); 173 spin_unlock_irqrestore(&musb->lock, flags);
175 174
176 /* REVISIT we sometimes get spurious IRQs on g_ep0 175 return retval;
177 * not clear why... fall in BF54x too.
178 */
179 if (retval != IRQ_HANDLED)
180 DBG(5, "spurious?\n");
181
182 return IRQ_HANDLED;
183} 176}
184 177
185static void musb_conn_timer_handler(unsigned long _musb) 178static void musb_conn_timer_handler(unsigned long _musb)
diff --git a/drivers/usb/musb/cppi_dma.c b/drivers/usb/musb/cppi_dma.c
index 3c69a76ec39..59dc3d351b6 100644
--- a/drivers/usb/musb/cppi_dma.c
+++ b/drivers/usb/musb/cppi_dma.c
@@ -7,6 +7,7 @@
7 */ 7 */
8 8
9#include <linux/platform_device.h> 9#include <linux/platform_device.h>
10#include <linux/slab.h>
10#include <linux/usb.h> 11#include <linux/usb.h>
11 12
12#include "musb_core.h" 13#include "musb_core.h"
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index a883f9dd3f8..ce2e16fee0d 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -24,7 +24,6 @@
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/kernel.h> 25#include <linux/kernel.h>
26#include <linux/sched.h> 26#include <linux/sched.h>
27#include <linux/slab.h>
28#include <linux/init.h> 27#include <linux/init.h>
29#include <linux/list.h> 28#include <linux/list.h>
30#include <linux/delay.h> 29#include <linux/delay.h>
@@ -445,6 +444,8 @@ int __init musb_platform_init(struct musb *musb)
445 return 0; 444 return 0;
446 445
447fail: 446fail:
447 clk_disable(musb->clock);
448
448 usb_nop_xceiv_unregister(); 449 usb_nop_xceiv_unregister();
449 return -ENODEV; 450 return -ENODEV;
450} 451}
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index b4bbf8f2c23..705cc4ad873 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -379,7 +379,6 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
379 u8 devctl, u8 power) 379 u8 devctl, u8 power)
380{ 380{
381 irqreturn_t handled = IRQ_NONE; 381 irqreturn_t handled = IRQ_NONE;
382 void __iomem *mbase = musb->mregs;
383 382
384 DBG(3, "<== Power=%02x, DevCtl=%02x, int_usb=0x%x\n", power, devctl, 383 DBG(3, "<== Power=%02x, DevCtl=%02x, int_usb=0x%x\n", power, devctl,
385 int_usb); 384 int_usb);
@@ -394,6 +393,8 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
394 393
395 if (devctl & MUSB_DEVCTL_HM) { 394 if (devctl & MUSB_DEVCTL_HM) {
396#ifdef CONFIG_USB_MUSB_HDRC_HCD 395#ifdef CONFIG_USB_MUSB_HDRC_HCD
396 void __iomem *mbase = musb->mregs;
397
397 switch (musb->xceiv->state) { 398 switch (musb->xceiv->state) {
398 case OTG_STATE_A_SUSPEND: 399 case OTG_STATE_A_SUSPEND:
399 /* remote wakeup? later, GetPortStatus 400 /* remote wakeup? later, GetPortStatus
@@ -471,6 +472,8 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
471#ifdef CONFIG_USB_MUSB_HDRC_HCD 472#ifdef CONFIG_USB_MUSB_HDRC_HCD
472 /* see manual for the order of the tests */ 473 /* see manual for the order of the tests */
473 if (int_usb & MUSB_INTR_SESSREQ) { 474 if (int_usb & MUSB_INTR_SESSREQ) {
475 void __iomem *mbase = musb->mregs;
476
474 DBG(1, "SESSION_REQUEST (%s)\n", otg_state_string(musb)); 477 DBG(1, "SESSION_REQUEST (%s)\n", otg_state_string(musb));
475 478
476 /* IRQ arrives from ID pin sense or (later, if VBUS power 479 /* IRQ arrives from ID pin sense or (later, if VBUS power
@@ -519,6 +522,8 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
519 case OTG_STATE_A_WAIT_BCON: 522 case OTG_STATE_A_WAIT_BCON:
520 case OTG_STATE_A_WAIT_VRISE: 523 case OTG_STATE_A_WAIT_VRISE:
521 if (musb->vbuserr_retry) { 524 if (musb->vbuserr_retry) {
525 void __iomem *mbase = musb->mregs;
526
522 musb->vbuserr_retry--; 527 musb->vbuserr_retry--;
523 ignore = 1; 528 ignore = 1;
524 devctl |= MUSB_DEVCTL_SESSION; 529 devctl |= MUSB_DEVCTL_SESSION;
@@ -622,6 +627,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
622 627
623 if (int_usb & MUSB_INTR_CONNECT) { 628 if (int_usb & MUSB_INTR_CONNECT) {
624 struct usb_hcd *hcd = musb_to_hcd(musb); 629 struct usb_hcd *hcd = musb_to_hcd(musb);
630 void __iomem *mbase = musb->mregs;
625 631
626 handled = IRQ_HANDLED; 632 handled = IRQ_HANDLED;
627 musb->is_active = 1; 633 musb->is_active = 1;
@@ -959,10 +965,8 @@ static void musb_shutdown(struct platform_device *pdev)
959 spin_lock_irqsave(&musb->lock, flags); 965 spin_lock_irqsave(&musb->lock, flags);
960 musb_platform_disable(musb); 966 musb_platform_disable(musb);
961 musb_generic_disable(musb); 967 musb_generic_disable(musb);
962 if (musb->clock) { 968 if (musb->clock)
963 clk_put(musb->clock); 969 clk_put(musb->clock);
964 musb->clock = NULL;
965 }
966 spin_unlock_irqrestore(&musb->lock, flags); 970 spin_unlock_irqrestore(&musb->lock, flags);
967 971
968 /* FIXME power down */ 972 /* FIXME power down */
@@ -1847,15 +1851,6 @@ static void musb_free(struct musb *musb)
1847 put_device(musb->xceiv->dev); 1851 put_device(musb->xceiv->dev);
1848#endif 1852#endif
1849 1853
1850 musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
1851 musb_platform_exit(musb);
1852 musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
1853
1854 if (musb->clock) {
1855 clk_disable(musb->clock);
1856 clk_put(musb->clock);
1857 }
1858
1859#ifdef CONFIG_USB_MUSB_HDRC_HCD 1854#ifdef CONFIG_USB_MUSB_HDRC_HCD
1860 usb_put_hcd(musb_to_hcd(musb)); 1855 usb_put_hcd(musb_to_hcd(musb));
1861#else 1856#else
@@ -1883,8 +1878,10 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
1883 */ 1878 */
1884 if (!plat) { 1879 if (!plat) {
1885 dev_dbg(dev, "no platform_data?\n"); 1880 dev_dbg(dev, "no platform_data?\n");
1886 return -ENODEV; 1881 status = -ENODEV;
1882 goto fail0;
1887 } 1883 }
1884
1888 switch (plat->mode) { 1885 switch (plat->mode) {
1889 case MUSB_HOST: 1886 case MUSB_HOST:
1890#ifdef CONFIG_USB_MUSB_HDRC_HCD 1887#ifdef CONFIG_USB_MUSB_HDRC_HCD
@@ -1906,13 +1903,16 @@ bad_config:
1906#endif 1903#endif
1907 default: 1904 default:
1908 dev_err(dev, "incompatible Kconfig role setting\n"); 1905 dev_err(dev, "incompatible Kconfig role setting\n");
1909 return -EINVAL; 1906 status = -EINVAL;
1907 goto fail0;
1910 } 1908 }
1911 1909
1912 /* allocate */ 1910 /* allocate */
1913 musb = allocate_instance(dev, plat->config, ctrl); 1911 musb = allocate_instance(dev, plat->config, ctrl);
1914 if (!musb) 1912 if (!musb) {
1915 return -ENOMEM; 1913 status = -ENOMEM;
1914 goto fail0;
1915 }
1916 1916
1917 spin_lock_init(&musb->lock); 1917 spin_lock_init(&musb->lock);
1918 musb->board_mode = plat->mode; 1918 musb->board_mode = plat->mode;
@@ -1930,7 +1930,7 @@ bad_config:
1930 if (IS_ERR(musb->clock)) { 1930 if (IS_ERR(musb->clock)) {
1931 status = PTR_ERR(musb->clock); 1931 status = PTR_ERR(musb->clock);
1932 musb->clock = NULL; 1932 musb->clock = NULL;
1933 goto fail; 1933 goto fail1;
1934 } 1934 }
1935 } 1935 }
1936 1936
@@ -1949,12 +1949,12 @@ bad_config:
1949 */ 1949 */
1950 musb->isr = generic_interrupt; 1950 musb->isr = generic_interrupt;
1951 status = musb_platform_init(musb); 1951 status = musb_platform_init(musb);
1952
1953 if (status < 0) 1952 if (status < 0)
1954 goto fail; 1953 goto fail2;
1954
1955 if (!musb->isr) { 1955 if (!musb->isr) {
1956 status = -ENODEV; 1956 status = -ENODEV;
1957 goto fail2; 1957 goto fail3;
1958 } 1958 }
1959 1959
1960#ifndef CONFIG_MUSB_PIO_ONLY 1960#ifndef CONFIG_MUSB_PIO_ONLY
@@ -1980,7 +1980,7 @@ bad_config:
1980 ? MUSB_CONTROLLER_MHDRC 1980 ? MUSB_CONTROLLER_MHDRC
1981 : MUSB_CONTROLLER_HDRC, musb); 1981 : MUSB_CONTROLLER_HDRC, musb);
1982 if (status < 0) 1982 if (status < 0)
1983 goto fail2; 1983 goto fail3;
1984 1984
1985#ifdef CONFIG_USB_MUSB_OTG 1985#ifdef CONFIG_USB_MUSB_OTG
1986 setup_timer(&musb->otg_timer, musb_otg_timer_func, (unsigned long) musb); 1986 setup_timer(&musb->otg_timer, musb_otg_timer_func, (unsigned long) musb);
@@ -1993,7 +1993,7 @@ bad_config:
1993 if (request_irq(nIrq, musb->isr, 0, dev_name(dev), musb)) { 1993 if (request_irq(nIrq, musb->isr, 0, dev_name(dev), musb)) {
1994 dev_err(dev, "request_irq %d failed!\n", nIrq); 1994 dev_err(dev, "request_irq %d failed!\n", nIrq);
1995 status = -ENODEV; 1995 status = -ENODEV;
1996 goto fail2; 1996 goto fail3;
1997 } 1997 }
1998 musb->nIrq = nIrq; 1998 musb->nIrq = nIrq;
1999/* FIXME this handles wakeup irqs wrong */ 1999/* FIXME this handles wakeup irqs wrong */
@@ -2007,7 +2007,6 @@ bad_config:
2007 /* host side needs more setup */ 2007 /* host side needs more setup */
2008 if (is_host_enabled(musb)) { 2008 if (is_host_enabled(musb)) {
2009 struct usb_hcd *hcd = musb_to_hcd(musb); 2009 struct usb_hcd *hcd = musb_to_hcd(musb);
2010 u8 busctl;
2011 2010
2012 otg_set_host(musb->xceiv, &hcd->self); 2011 otg_set_host(musb->xceiv, &hcd->self);
2013 2012
@@ -2018,9 +2017,9 @@ bad_config:
2018 2017
2019 /* program PHY to use external vBus if required */ 2018 /* program PHY to use external vBus if required */
2020 if (plat->extvbus) { 2019 if (plat->extvbus) {
2021 busctl = musb_readb(musb->mregs, MUSB_ULPI_BUSCONTROL); 2020 u8 busctl = musb_read_ulpi_buscontrol(musb->mregs);
2022 busctl |= MUSB_ULPI_USE_EXTVBUS; 2021 busctl |= MUSB_ULPI_USE_EXTVBUS;
2023 musb_writeb(musb->mregs, MUSB_ULPI_BUSCONTROL, busctl); 2022 musb_write_ulpi_buscontrol(musb->mregs, busctl);
2024 } 2023 }
2025 } 2024 }
2026 2025
@@ -2034,8 +2033,6 @@ bad_config:
2034 musb->xceiv->state = OTG_STATE_A_IDLE; 2033 musb->xceiv->state = OTG_STATE_A_IDLE;
2035 2034
2036 status = usb_add_hcd(musb_to_hcd(musb), -1, 0); 2035 status = usb_add_hcd(musb_to_hcd(musb), -1, 0);
2037 if (status)
2038 goto fail;
2039 2036
2040 DBG(1, "%s mode, status %d, devctl %02x %c\n", 2037 DBG(1, "%s mode, status %d, devctl %02x %c\n",
2041 "HOST", status, 2038 "HOST", status,
@@ -2050,8 +2047,6 @@ bad_config:
2050 musb->xceiv->state = OTG_STATE_B_IDLE; 2047 musb->xceiv->state = OTG_STATE_B_IDLE;
2051 2048
2052 status = musb_gadget_setup(musb); 2049 status = musb_gadget_setup(musb);
2053 if (status)
2054 goto fail;
2055 2050
2056 DBG(1, "%s mode, status %d, dev%02x\n", 2051 DBG(1, "%s mode, status %d, dev%02x\n",
2057 is_otg_enabled(musb) ? "OTG" : "PERIPHERAL", 2052 is_otg_enabled(musb) ? "OTG" : "PERIPHERAL",
@@ -2059,12 +2054,14 @@ bad_config:
2059 musb_readb(musb->mregs, MUSB_DEVCTL)); 2054 musb_readb(musb->mregs, MUSB_DEVCTL));
2060 2055
2061 } 2056 }
2057 if (status < 0)
2058 goto fail3;
2062 2059
2063#ifdef CONFIG_SYSFS 2060#ifdef CONFIG_SYSFS
2064 status = sysfs_create_group(&musb->controller->kobj, &musb_attr_group); 2061 status = sysfs_create_group(&musb->controller->kobj, &musb_attr_group);
2065#endif
2066 if (status) 2062 if (status)
2067 goto fail2; 2063 goto fail4;
2064#endif
2068 2065
2069 dev_info(dev, "USB %s mode controller at %p using %s, IRQ %d\n", 2066 dev_info(dev, "USB %s mode controller at %p using %s, IRQ %d\n",
2070 ({char *s; 2067 ({char *s;
@@ -2080,17 +2077,29 @@ bad_config:
2080 2077
2081 return 0; 2078 return 0;
2082 2079
2083fail2: 2080fail4:
2081 if (!is_otg_enabled(musb) && is_host_enabled(musb))
2082 usb_remove_hcd(musb_to_hcd(musb));
2083 else
2084 musb_gadget_cleanup(musb);
2085
2086fail3:
2087 if (musb->irq_wake)
2088 device_init_wakeup(dev, 0);
2084 musb_platform_exit(musb); 2089 musb_platform_exit(musb);
2085fail:
2086 dev_err(musb->controller,
2087 "musb_init_controller failed with status %d\n", status);
2088 2090
2091fail2:
2089 if (musb->clock) 2092 if (musb->clock)
2090 clk_put(musb->clock); 2093 clk_put(musb->clock);
2091 device_init_wakeup(dev, 0); 2094
2095fail1:
2096 dev_err(musb->controller,
2097 "musb_init_controller failed with status %d\n", status);
2098
2092 musb_free(musb); 2099 musb_free(musb);
2093 2100
2101fail0:
2102
2094 return status; 2103 return status;
2095 2104
2096} 2105}
@@ -2127,7 +2136,6 @@ static int __init musb_probe(struct platform_device *pdev)
2127 /* clobbered by use_dma=n */ 2136 /* clobbered by use_dma=n */
2128 orig_dma_mask = dev->dma_mask; 2137 orig_dma_mask = dev->dma_mask;
2129#endif 2138#endif
2130
2131 status = musb_init_controller(dev, irq, base); 2139 status = musb_init_controller(dev, irq, base);
2132 if (status < 0) 2140 if (status < 0)
2133 iounmap(base); 2141 iounmap(base);
@@ -2150,6 +2158,10 @@ static int __exit musb_remove(struct platform_device *pdev)
2150 if (musb->board_mode == MUSB_HOST) 2158 if (musb->board_mode == MUSB_HOST)
2151 usb_remove_hcd(musb_to_hcd(musb)); 2159 usb_remove_hcd(musb_to_hcd(musb));
2152#endif 2160#endif
2161 musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
2162 musb_platform_exit(musb);
2163 musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
2164
2153 musb_free(musb); 2165 musb_free(musb);
2154 iounmap(ctrl_base); 2166 iounmap(ctrl_base);
2155 device_init_wakeup(&pdev->dev, 0); 2167 device_init_wakeup(&pdev->dev, 0);
@@ -2171,6 +2183,7 @@ void musb_save_context(struct musb *musb)
2171 if (is_host_enabled(musb)) { 2183 if (is_host_enabled(musb)) {
2172 musb_context.frame = musb_readw(musb_base, MUSB_FRAME); 2184 musb_context.frame = musb_readw(musb_base, MUSB_FRAME);
2173 musb_context.testmode = musb_readb(musb_base, MUSB_TESTMODE); 2185 musb_context.testmode = musb_readb(musb_base, MUSB_TESTMODE);
2186 musb_context.busctl = musb_read_ulpi_buscontrol(musb->mregs);
2174 } 2187 }
2175 musb_context.power = musb_readb(musb_base, MUSB_POWER); 2188 musb_context.power = musb_readb(musb_base, MUSB_POWER);
2176 musb_context.intrtxe = musb_readw(musb_base, MUSB_INTRTXE); 2189 musb_context.intrtxe = musb_readw(musb_base, MUSB_INTRTXE);
@@ -2242,6 +2255,7 @@ void musb_restore_context(struct musb *musb)
2242 if (is_host_enabled(musb)) { 2255 if (is_host_enabled(musb)) {
2243 musb_writew(musb_base, MUSB_FRAME, musb_context.frame); 2256 musb_writew(musb_base, MUSB_FRAME, musb_context.frame);
2244 musb_writeb(musb_base, MUSB_TESTMODE, musb_context.testmode); 2257 musb_writeb(musb_base, MUSB_TESTMODE, musb_context.testmode);
2258 musb_write_ulpi_buscontrol(musb->mregs, musb_context.busctl);
2245 } 2259 }
2246 musb_writeb(musb_base, MUSB_POWER, musb_context.power); 2260 musb_writeb(musb_base, MUSB_POWER, musb_context.power);
2247 musb_writew(musb_base, MUSB_INTRTXE, musb_context.intrtxe); 2261 musb_writew(musb_base, MUSB_INTRTXE, musb_context.intrtxe);
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index d849fb81c13..ac17b004909 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -469,7 +469,7 @@ struct musb_csr_regs {
469 469
470struct musb_context_registers { 470struct musb_context_registers {
471 471
472#if defined(CONFIG_ARCH_OMAP34XX) || defined(CONFIG_ARCH_OMAP2430) 472#ifdef CONFIG_PM
473 u32 otg_sysconfig, otg_forcestandby; 473 u32 otg_sysconfig, otg_forcestandby;
474#endif 474#endif
475 u8 power; 475 u8 power;
@@ -478,12 +478,12 @@ struct musb_context_registers {
478 u16 frame; 478 u16 frame;
479 u8 index, testmode; 479 u8 index, testmode;
480 480
481 u8 devctl, misc; 481 u8 devctl, busctl, misc;
482 482
483 struct musb_csr_regs index_regs[MUSB_C_NUM_EPS]; 483 struct musb_csr_regs index_regs[MUSB_C_NUM_EPS];
484}; 484};
485 485
486#if defined(CONFIG_ARCH_OMAP34XX) || defined(CONFIG_ARCH_OMAP2430) 486#ifdef CONFIG_PM
487extern void musb_platform_save_context(struct musb *musb, 487extern void musb_platform_save_context(struct musb *musb,
488 struct musb_context_registers *musb_context); 488 struct musb_context_registers *musb_context);
489extern void musb_platform_restore_context(struct musb *musb, 489extern void musb_platform_restore_context(struct musb *musb,
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index a9f288cd70e..6fca870e957 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -43,6 +43,7 @@
43#include <linux/moduleparam.h> 43#include <linux/moduleparam.h>
44#include <linux/stat.h> 44#include <linux/stat.h>
45#include <linux/dma-mapping.h> 45#include <linux/dma-mapping.h>
46#include <linux/slab.h>
46 47
47#include "musb_core.h" 48#include "musb_core.h"
48 49
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 3421cf9858b..877d20b1dff 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -1689,7 +1689,7 @@ void musb_host_rx(struct musb *musb, u8 epnum)
1689 dma->desired_mode = 1; 1689 dma->desired_mode = 1;
1690 if (rx_count < hw_ep->max_packet_sz_rx) { 1690 if (rx_count < hw_ep->max_packet_sz_rx) {
1691 length = rx_count; 1691 length = rx_count;
1692 dma->bDesiredMode = 0; 1692 dma->desired_mode = 0;
1693 } else { 1693 } else {
1694 length = urb->transfer_buffer_length; 1694 length = urb->transfer_buffer_length;
1695 } 1695 }
@@ -2042,6 +2042,7 @@ static int musb_urb_enqueue(
2042 * odd, rare, error prone, but legal. 2042 * odd, rare, error prone, but legal.
2043 */ 2043 */
2044 kfree(qh); 2044 kfree(qh);
2045 qh = NULL;
2045 ret = 0; 2046 ret = 0;
2046 } else 2047 } else
2047 ret = musb_schedule(musb, qh, 2048 ret = musb_schedule(musb, qh,
diff --git a/drivers/usb/musb/musb_regs.h b/drivers/usb/musb/musb_regs.h
index 8d8062b10e2..fa55aacc385 100644
--- a/drivers/usb/musb/musb_regs.h
+++ b/drivers/usb/musb/musb_regs.h
@@ -326,6 +326,11 @@ static inline void musb_write_rxfifoadd(void __iomem *mbase, u16 c_off)
326 musb_writew(mbase, MUSB_RXFIFOADD, c_off); 326 musb_writew(mbase, MUSB_RXFIFOADD, c_off);
327} 327}
328 328
329static inline void musb_write_ulpi_buscontrol(void __iomem *mbase, u8 val)
330{
331 musb_writeb(mbase, MUSB_ULPI_BUSCONTROL, val);
332}
333
329static inline u8 musb_read_txfifosz(void __iomem *mbase) 334static inline u8 musb_read_txfifosz(void __iomem *mbase)
330{ 335{
331 return musb_readb(mbase, MUSB_TXFIFOSZ); 336 return musb_readb(mbase, MUSB_TXFIFOSZ);
@@ -346,6 +351,11 @@ static inline u16 musb_read_rxfifoadd(void __iomem *mbase)
346 return musb_readw(mbase, MUSB_RXFIFOADD); 351 return musb_readw(mbase, MUSB_RXFIFOADD);
347} 352}
348 353
354static inline u8 musb_read_ulpi_buscontrol(void __iomem *mbase)
355{
356 return musb_readb(mbase, MUSB_ULPI_BUSCONTROL);
357}
358
349static inline u8 musb_read_configdata(void __iomem *mbase) 359static inline u8 musb_read_configdata(void __iomem *mbase)
350{ 360{
351 musb_writeb(mbase, MUSB_INDEX, 0); 361 musb_writeb(mbase, MUSB_INDEX, 0);
@@ -510,20 +520,33 @@ static inline void musb_write_rxfifoadd(void __iomem *mbase, u16 c_off)
510{ 520{
511} 521}
512 522
523static inline void musb_write_ulpi_buscontrol(void __iomem *mbase, u8 val)
524{
525}
526
513static inline u8 musb_read_txfifosz(void __iomem *mbase) 527static inline u8 musb_read_txfifosz(void __iomem *mbase)
514{ 528{
529 return 0;
515} 530}
516 531
517static inline u16 musb_read_txfifoadd(void __iomem *mbase) 532static inline u16 musb_read_txfifoadd(void __iomem *mbase)
518{ 533{
534 return 0;
519} 535}
520 536
521static inline u8 musb_read_rxfifosz(void __iomem *mbase) 537static inline u8 musb_read_rxfifosz(void __iomem *mbase)
522{ 538{
539 return 0;
523} 540}
524 541
525static inline u16 musb_read_rxfifoadd(void __iomem *mbase) 542static inline u16 musb_read_rxfifoadd(void __iomem *mbase)
526{ 543{
544 return 0;
545}
546
547static inline u8 musb_read_ulpi_buscontrol(void __iomem *mbase)
548{
549 return 0;
527} 550}
528 551
529static inline u8 musb_read_configdata(void __iomem *mbase) 552static inline u8 musb_read_configdata(void __iomem *mbase)
@@ -577,22 +600,27 @@ static inline void musb_write_txhubport(void __iomem *mbase, u8 epnum,
577 600
578static inline u8 musb_read_rxfunaddr(void __iomem *mbase, u8 epnum) 601static inline u8 musb_read_rxfunaddr(void __iomem *mbase, u8 epnum)
579{ 602{
603 return 0;
580} 604}
581 605
582static inline u8 musb_read_rxhubaddr(void __iomem *mbase, u8 epnum) 606static inline u8 musb_read_rxhubaddr(void __iomem *mbase, u8 epnum)
583{ 607{
608 return 0;
584} 609}
585 610
586static inline u8 musb_read_rxhubport(void __iomem *mbase, u8 epnum) 611static inline u8 musb_read_rxhubport(void __iomem *mbase, u8 epnum)
587{ 612{
613 return 0;
588} 614}
589 615
590static inline u8 musb_read_txfunaddr(void __iomem *mbase, u8 epnum) 616static inline u8 musb_read_txfunaddr(void __iomem *mbase, u8 epnum)
591{ 617{
618 return 0;
592} 619}
593 620
594static inline u8 musb_read_txhubaddr(void __iomem *mbase, u8 epnum) 621static inline u8 musb_read_txhubaddr(void __iomem *mbase, u8 epnum)
595{ 622{
623 return 0;
596} 624}
597 625
598static inline void musb_read_txhubport(void __iomem *mbase, u8 epnum) 626static inline void musb_read_txhubport(void __iomem *mbase, u8 epnum)
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
index bfe5fe4ebfe..7775e1c0a21 100644
--- a/drivers/usb/musb/musb_virthub.c
+++ b/drivers/usb/musb/musb_virthub.c
@@ -35,7 +35,6 @@
35#include <linux/module.h> 35#include <linux/module.h>
36#include <linux/kernel.h> 36#include <linux/kernel.h>
37#include <linux/sched.h> 37#include <linux/sched.h>
38#include <linux/slab.h>
39#include <linux/errno.h> 38#include <linux/errno.h>
40#include <linux/init.h> 39#include <linux/init.h>
41#include <linux/time.h> 40#include <linux/time.h>
diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
index 2fa7d5c00f3..1008044a3bb 100644
--- a/drivers/usb/musb/musbhsdma.c
+++ b/drivers/usb/musb/musbhsdma.c
@@ -33,6 +33,7 @@
33#include <linux/device.h> 33#include <linux/device.h>
34#include <linux/interrupt.h> 34#include <linux/interrupt.h>
35#include <linux/platform_device.h> 35#include <linux/platform_device.h>
36#include <linux/slab.h>
36#include "musb_core.h" 37#include "musb_core.h"
37#include "musbhsdma.h" 38#include "musbhsdma.h"
38 39
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 3fe16867b5a..82592633502 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -27,7 +27,6 @@
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/kernel.h> 28#include <linux/kernel.h>
29#include <linux/sched.h> 29#include <linux/sched.h>
30#include <linux/slab.h>
31#include <linux/init.h> 30#include <linux/init.h>
32#include <linux/list.h> 31#include <linux/list.h>
33#include <linux/clk.h> 32#include <linux/clk.h>
@@ -332,8 +331,5 @@ int musb_platform_exit(struct musb *musb)
332 331
333 musb_platform_suspend(musb); 332 musb_platform_suspend(musb);
334 333
335 clk_put(musb->clock);
336 musb->clock = NULL;
337
338 return 0; 334 return 0;
339} 335}
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index ab776a8d98c..60d3938cafc 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -29,6 +29,19 @@ static void tusb_source_power(struct musb *musb, int is_on);
29#define TUSB_REV_MAJOR(reg_val) ((reg_val >> 4) & 0xf) 29#define TUSB_REV_MAJOR(reg_val) ((reg_val >> 4) & 0xf)
30#define TUSB_REV_MINOR(reg_val) (reg_val & 0xf) 30#define TUSB_REV_MINOR(reg_val) (reg_val & 0xf)
31 31
32#ifdef CONFIG_PM
33/* REVISIT: These should be only needed if somebody implements off idle */
34void musb_platform_save_context(struct musb *musb,
35 struct musb_context_registers *musb_context)
36{
37}
38
39void musb_platform_restore_context(struct musb *musb,
40 struct musb_context_registers *musb_context)
41{
42}
43#endif
44
32/* 45/*
33 * Checks the revision. We need to use the DMA register as 3.0 does not 46 * Checks the revision. We need to use the DMA register as 3.0 does not
34 * have correct versions for TUSB_PRCM_REV or TUSB_INT_CTRL_REV. 47 * have correct versions for TUSB_PRCM_REV or TUSB_INT_CTRL_REV.
diff --git a/drivers/usb/musb/tusb6010_omap.c b/drivers/usb/musb/tusb6010_omap.c
index 1c868096bd6..c061a88f2b0 100644
--- a/drivers/usb/musb/tusb6010_omap.c
+++ b/drivers/usb/musb/tusb6010_omap.c
@@ -15,6 +15,7 @@
15#include <linux/usb.h> 15#include <linux/usb.h>
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/dma-mapping.h> 17#include <linux/dma-mapping.h>
18#include <linux/slab.h>
18#include <plat/dma.h> 19#include <plat/dma.h>
19#include <plat/mux.h> 20#include <plat/mux.h>
20 21
@@ -38,7 +39,7 @@ struct tusb_omap_dma_ch {
38 39
39 struct tusb_omap_dma *tusb_dma; 40 struct tusb_omap_dma *tusb_dma;
40 41
41 void __iomem *dma_addr; 42 dma_addr_t dma_addr;
42 43
43 u32 len; 44 u32 len;
44 u16 packet_sz; 45 u16 packet_sz;
@@ -125,6 +126,7 @@ static void tusb_omap_dma_cb(int lch, u16 ch_status, void *data)
125 struct tusb_omap_dma_ch *chdat = to_chdat(channel); 126 struct tusb_omap_dma_ch *chdat = to_chdat(channel);
126 struct tusb_omap_dma *tusb_dma = chdat->tusb_dma; 127 struct tusb_omap_dma *tusb_dma = chdat->tusb_dma;
127 struct musb *musb = chdat->musb; 128 struct musb *musb = chdat->musb;
129 struct device *dev = musb->controller;
128 struct musb_hw_ep *hw_ep = chdat->hw_ep; 130 struct musb_hw_ep *hw_ep = chdat->hw_ep;
129 void __iomem *ep_conf = hw_ep->conf; 131 void __iomem *ep_conf = hw_ep->conf;
130 void __iomem *mbase = musb->mregs; 132 void __iomem *mbase = musb->mregs;
@@ -172,13 +174,15 @@ static void tusb_omap_dma_cb(int lch, u16 ch_status, void *data)
172 DBG(3, "Using PIO for remaining %lu bytes\n", pio); 174 DBG(3, "Using PIO for remaining %lu bytes\n", pio);
173 buf = phys_to_virt((u32)chdat->dma_addr) + chdat->transfer_len; 175 buf = phys_to_virt((u32)chdat->dma_addr) + chdat->transfer_len;
174 if (chdat->tx) { 176 if (chdat->tx) {
175 dma_cache_maint(phys_to_virt((u32)chdat->dma_addr), 177 dma_unmap_single(dev, chdat->dma_addr,
176 chdat->transfer_len, DMA_TO_DEVICE); 178 chdat->transfer_len,
179 DMA_TO_DEVICE);
177 musb_write_fifo(hw_ep, pio, buf); 180 musb_write_fifo(hw_ep, pio, buf);
178 } else { 181 } else {
182 dma_unmap_single(dev, chdat->dma_addr,
183 chdat->transfer_len,
184 DMA_FROM_DEVICE);
179 musb_read_fifo(hw_ep, pio, buf); 185 musb_read_fifo(hw_ep, pio, buf);
180 dma_cache_maint(phys_to_virt((u32)chdat->dma_addr),
181 chdat->transfer_len, DMA_FROM_DEVICE);
182 } 186 }
183 channel->actual_len += pio; 187 channel->actual_len += pio;
184 } 188 }
@@ -223,6 +227,7 @@ static int tusb_omap_dma_program(struct dma_channel *channel, u16 packet_sz,
223 struct tusb_omap_dma_ch *chdat = to_chdat(channel); 227 struct tusb_omap_dma_ch *chdat = to_chdat(channel);
224 struct tusb_omap_dma *tusb_dma = chdat->tusb_dma; 228 struct tusb_omap_dma *tusb_dma = chdat->tusb_dma;
225 struct musb *musb = chdat->musb; 229 struct musb *musb = chdat->musb;
230 struct device *dev = musb->controller;
226 struct musb_hw_ep *hw_ep = chdat->hw_ep; 231 struct musb_hw_ep *hw_ep = chdat->hw_ep;
227 void __iomem *mbase = musb->mregs; 232 void __iomem *mbase = musb->mregs;
228 void __iomem *ep_conf = hw_ep->conf; 233 void __iomem *ep_conf = hw_ep->conf;
@@ -298,14 +303,16 @@ static int tusb_omap_dma_program(struct dma_channel *channel, u16 packet_sz,
298 chdat->packet_sz = packet_sz; 303 chdat->packet_sz = packet_sz;
299 chdat->len = len; 304 chdat->len = len;
300 channel->actual_len = 0; 305 channel->actual_len = 0;
301 chdat->dma_addr = (void __iomem *)dma_addr; 306 chdat->dma_addr = dma_addr;
302 channel->status = MUSB_DMA_STATUS_BUSY; 307 channel->status = MUSB_DMA_STATUS_BUSY;
303 308
304 /* Since we're recycling dma areas, we need to clean or invalidate */ 309 /* Since we're recycling dma areas, we need to clean or invalidate */
305 if (chdat->tx) 310 if (chdat->tx)
306 dma_cache_maint(phys_to_virt(dma_addr), len, DMA_TO_DEVICE); 311 dma_map_single(dev, phys_to_virt(dma_addr), len,
312 DMA_TO_DEVICE);
307 else 313 else
308 dma_cache_maint(phys_to_virt(dma_addr), len, DMA_FROM_DEVICE); 314 dma_map_single(dev, phys_to_virt(dma_addr), len,
315 DMA_FROM_DEVICE);
309 316
310 /* Use 16-bit transfer if dma_addr is not 32-bit aligned */ 317 /* Use 16-bit transfer if dma_addr is not 32-bit aligned */
311 if ((dma_addr & 0x3) == 0) { 318 if ((dma_addr & 0x3) == 0) {
diff --git a/drivers/usb/otg/gpio_vbus.c b/drivers/usb/otg/gpio_vbus.c
index 1c26c94513e..221c44444ec 100644
--- a/drivers/usb/otg/gpio_vbus.c
+++ b/drivers/usb/otg/gpio_vbus.c
@@ -11,6 +11,7 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/platform_device.h> 12#include <linux/platform_device.h>
13#include <linux/gpio.h> 13#include <linux/gpio.h>
14#include <linux/slab.h>
14#include <linux/interrupt.h> 15#include <linux/interrupt.h>
15#include <linux/usb.h> 16#include <linux/usb.h>
16#include <linux/workqueue.h> 17#include <linux/workqueue.h>
diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c
index af456b48985..e70014ab097 100644
--- a/drivers/usb/otg/nop-usb-xceiv.c
+++ b/drivers/usb/otg/nop-usb-xceiv.c
@@ -30,6 +30,7 @@
30#include <linux/platform_device.h> 30#include <linux/platform_device.h>
31#include <linux/dma-mapping.h> 31#include <linux/dma-mapping.h>
32#include <linux/usb/otg.h> 32#include <linux/usb/otg.h>
33#include <linux/slab.h>
33 34
34struct nop_usb_xceiv { 35struct nop_usb_xceiv {
35 struct otg_transceiver otg; 36 struct otg_transceiver otg;
diff --git a/drivers/usb/otg/twl4030-usb.c b/drivers/usb/otg/twl4030-usb.c
index 3e4e9f434d7..223cdf46ccb 100644
--- a/drivers/usb/otg/twl4030-usb.c
+++ b/drivers/usb/otg/twl4030-usb.c
@@ -37,6 +37,7 @@
37#include <linux/regulator/consumer.h> 37#include <linux/regulator/consumer.h>
38#include <linux/err.h> 38#include <linux/err.h>
39#include <linux/notifier.h> 39#include <linux/notifier.h>
40#include <linux/slab.h>
40 41
41/* Register defines */ 42/* Register defines */
42 43
diff --git a/drivers/usb/otg/ulpi.c b/drivers/usb/otg/ulpi.c
index 896527456b7..9010225e0d0 100644
--- a/drivers/usb/otg/ulpi.c
+++ b/drivers/usb/otg/ulpi.c
@@ -24,6 +24,7 @@
24 */ 24 */
25 25
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/slab.h>
27#include <linux/usb.h> 28#include <linux/usb.h>
28#include <linux/usb/otg.h> 29#include <linux/usb/otg.h>
29#include <linux/usb/ulpi.h> 30#include <linux/usb/ulpi.h>
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index c78b255e3f8..a0ecb42cb33 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -474,14 +474,14 @@ config USB_SERIAL_OTI6858
474 474
475config USB_SERIAL_QCAUX 475config USB_SERIAL_QCAUX
476 tristate "USB Qualcomm Auxiliary Serial Port Driver" 476 tristate "USB Qualcomm Auxiliary Serial Port Driver"
477 ---help--- 477 help
478 Say Y here if you want to use the auxiliary serial ports provided 478 Say Y here if you want to use the auxiliary serial ports provided
479 by many modems based on Qualcomm chipsets. These ports often use 479 by many modems based on Qualcomm chipsets. These ports often use
480 a proprietary protocol called DM and cannot be used for AT- or 480 a proprietary protocol called DM and cannot be used for AT- or
481 PPP-based communication. 481 PPP-based communication.
482 482
483 To compile this driver as a module, choose M here: the 483 To compile this driver as a module, choose M here: the
484 module will be called moto_modem. If unsure, choose N. 484 module will be called qcaux. If unsure, choose N.
485 485
486config USB_SERIAL_QUALCOMM 486config USB_SERIAL_QUALCOMM
487 tristate "USB Qualcomm Serial modem" 487 tristate "USB Qualcomm Serial modem"
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c
index 365db1097bf..4fd7af98b1a 100644
--- a/drivers/usb/serial/aircable.c
+++ b/drivers/usb/serial/aircable.c
@@ -43,6 +43,7 @@
43 */ 43 */
44 44
45#include <linux/tty.h> 45#include <linux/tty.h>
46#include <linux/slab.h>
46#include <linux/tty_flip.h> 47#include <linux/tty_flip.h>
47#include <linux/circ_buf.h> 48#include <linux/circ_buf.h>
48#include <linux/usb.h> 49#include <linux/usb.h>
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index 547c9448c28..9b66bf19f75 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -26,6 +26,7 @@
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/ioctl.h> 27#include <linux/ioctl.h>
28#include <linux/tty.h> 28#include <linux/tty.h>
29#include <linux/slab.h>
29#include <linux/tty_flip.h> 30#include <linux/tty_flip.h>
30#include <linux/module.h> 31#include <linux/module.h>
31#include <linux/usb.h> 32#include <linux/usb.h>
diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c
index ba555c528cc..7f547dc3a59 100644
--- a/drivers/usb/serial/bus.c
+++ b/drivers/usb/serial/bus.c
@@ -11,6 +11,7 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/errno.h> 12#include <linux/errno.h>
13#include <linux/tty.h> 13#include <linux/tty.h>
14#include <linux/slab.h>
14#include <linux/module.h> 15#include <linux/module.h>
15#include <linux/usb.h> 16#include <linux/usb.h>
16#include <linux/usb/serial.h> 17#include <linux/usb/serial.h>
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c
index 9f4fed1968b..7e8e3981841 100644
--- a/drivers/usb/serial/ch341.c
+++ b/drivers/usb/serial/ch341.c
@@ -19,6 +19,7 @@
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/tty.h> 20#include <linux/tty.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/slab.h>
22#include <linux/usb.h> 23#include <linux/usb.h>
23#include <linux/usb/serial.h> 24#include <linux/usb/serial.h>
24#include <linux/serial.h> 25#include <linux/serial.h>
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
index b22ac325852..f347da2ef00 100644
--- a/drivers/usb/serial/console.c
+++ b/drivers/usb/serial/console.c
@@ -181,6 +181,7 @@ static int usb_console_setup(struct console *co, char *options)
181 /* The console is special in terms of closing the device so 181 /* The console is special in terms of closing the device so
182 * indicate this port is now acting as a system console. */ 182 * indicate this port is now acting as a system console. */
183 port->console = 1; 183 port->console = 1;
184 port->port.console = 1;
184 185
185 mutex_unlock(&serial->disc_mutex); 186 mutex_unlock(&serial->disc_mutex);
186 return retval; 187 return retval;
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index 507382b0a9e..ec9b0449ccf 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -313,11 +313,6 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request,
313 return -EPROTO; 313 return -EPROTO;
314 } 314 }
315 315
316 /* Single data value */
317 result = usb_control_msg(serial->dev,
318 usb_sndctrlpipe(serial->dev, 0),
319 request, REQTYPE_HOST_TO_DEVICE, data[0],
320 0, NULL, 0, 300);
321 return 0; 316 return 0;
322} 317}
323 318
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 6af0dfa5f5a..1d7c4fac02e 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -91,7 +91,7 @@ struct ftdi_private {
91 unsigned long tx_outstanding_bytes; 91 unsigned long tx_outstanding_bytes;
92 unsigned long tx_outstanding_urbs; 92 unsigned long tx_outstanding_urbs;
93 unsigned short max_packet_size; 93 unsigned short max_packet_size;
94 struct mutex cfg_lock; /* Avoid mess by parallel calls of config ioctl() */ 94 struct mutex cfg_lock; /* Avoid mess by parallel calls of config ioctl() and change_speed() */
95}; 95};
96 96
97/* struct ftdi_sio_quirk is used by devices requiring special attention. */ 97/* struct ftdi_sio_quirk is used by devices requiring special attention. */
@@ -658,6 +658,7 @@ static struct usb_device_id id_table_combined [] = {
658 { USB_DEVICE(EVOLUTION_VID, EVOLUTION_ER1_PID) }, 658 { USB_DEVICE(EVOLUTION_VID, EVOLUTION_ER1_PID) },
659 { USB_DEVICE(EVOLUTION_VID, EVO_HYBRID_PID) }, 659 { USB_DEVICE(EVOLUTION_VID, EVO_HYBRID_PID) },
660 { USB_DEVICE(EVOLUTION_VID, EVO_RCM4_PID) }, 660 { USB_DEVICE(EVOLUTION_VID, EVO_RCM4_PID) },
661 { USB_DEVICE(CONTEC_VID, CONTEC_COM1USBH_PID) },
661 { USB_DEVICE(FTDI_VID, FTDI_ARTEMIS_PID) }, 662 { USB_DEVICE(FTDI_VID, FTDI_ARTEMIS_PID) },
662 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16_PID) }, 663 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16_PID) },
663 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16C_PID) }, 664 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16C_PID) },
@@ -1272,8 +1273,8 @@ check_and_exit:
1272 (priv->flags & ASYNC_SPD_MASK)) || 1273 (priv->flags & ASYNC_SPD_MASK)) ||
1273 (((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) && 1274 (((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) &&
1274 (old_priv.custom_divisor != priv->custom_divisor))) { 1275 (old_priv.custom_divisor != priv->custom_divisor))) {
1275 mutex_unlock(&priv->cfg_lock);
1276 change_speed(tty, port); 1276 change_speed(tty, port);
1277 mutex_unlock(&priv->cfg_lock);
1277 } 1278 }
1278 else 1279 else
1279 mutex_unlock(&priv->cfg_lock); 1280 mutex_unlock(&priv->cfg_lock);
@@ -2264,9 +2265,11 @@ static void ftdi_set_termios(struct tty_struct *tty,
2264 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); 2265 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
2265 } else { 2266 } else {
2266 /* set the baudrate determined before */ 2267 /* set the baudrate determined before */
2268 mutex_lock(&priv->cfg_lock);
2267 if (change_speed(tty, port)) 2269 if (change_speed(tty, port))
2268 dev_err(&port->dev, "%s urb failed to set baudrate\n", 2270 dev_err(&port->dev, "%s urb failed to set baudrate\n",
2269 __func__); 2271 __func__);
2272 mutex_unlock(&priv->cfg_lock);
2270 /* Ensure RTS and DTR are raised when baudrate changed from 0 */ 2273 /* Ensure RTS and DTR are raised when baudrate changed from 0 */
2271 if (!old_termios || (old_termios->c_cflag & CBAUD) == B0) 2274 if (!old_termios || (old_termios->c_cflag & CBAUD) == B0)
2272 set_mctrl(port, TIOCM_DTR | TIOCM_RTS); 2275 set_mctrl(port, TIOCM_DTR | TIOCM_RTS);
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
index 0727e198503..75482cbc399 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -501,6 +501,13 @@
501#define CONTEC_COM1USBH_PID 0x8311 /* COM-1(USB)H */ 501#define CONTEC_COM1USBH_PID 0x8311 /* COM-1(USB)H */
502 502
503/* 503/*
504 * Contec products (http://www.contec.com)
505 * Submitted by Daniel Sangorrin
506 */
507#define CONTEC_VID 0x06CE /* Vendor ID */
508#define CONTEC_COM1USBH_PID 0x8311 /* COM-1(USB)H */
509
510/*
504 * Definitions for B&B Electronics products. 511 * Definitions for B&B Electronics products.
505 */ 512 */
506#define BANDB_VID 0x0856 /* B&B Electronics Vendor ID */ 513#define BANDB_VID 0x0856 /* B&B Electronics Vendor ID */
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 89fac36684c..f804acb138e 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -130,7 +130,7 @@ int usb_serial_generic_open(struct tty_struct *tty, struct usb_serial_port *port
130 spin_unlock_irqrestore(&port->lock, flags); 130 spin_unlock_irqrestore(&port->lock, flags);
131 131
132 /* if we have a bulk endpoint, start reading from it */ 132 /* if we have a bulk endpoint, start reading from it */
133 if (serial->num_bulk_in) { 133 if (port->bulk_in_size) {
134 /* Start reading from the device */ 134 /* Start reading from the device */
135 usb_fill_bulk_urb(port->read_urb, serial->dev, 135 usb_fill_bulk_urb(port->read_urb, serial->dev,
136 usb_rcvbulkpipe(serial->dev, 136 usb_rcvbulkpipe(serial->dev,
@@ -159,10 +159,10 @@ static void generic_cleanup(struct usb_serial_port *port)
159 dbg("%s - port %d", __func__, port->number); 159 dbg("%s - port %d", __func__, port->number);
160 160
161 if (serial->dev) { 161 if (serial->dev) {
162 /* shutdown any bulk reads that might be going on */ 162 /* shutdown any bulk transfers that might be going on */
163 if (serial->num_bulk_out) 163 if (port->bulk_out_size)
164 usb_kill_urb(port->write_urb); 164 usb_kill_urb(port->write_urb);
165 if (serial->num_bulk_in) 165 if (port->bulk_in_size)
166 usb_kill_urb(port->read_urb); 166 usb_kill_urb(port->read_urb);
167 } 167 }
168} 168}
@@ -333,15 +333,15 @@ int usb_serial_generic_write(struct tty_struct *tty,
333 333
334 dbg("%s - port %d", __func__, port->number); 334 dbg("%s - port %d", __func__, port->number);
335 335
336 /* only do something if we have a bulk out endpoint */
337 if (!port->bulk_out_size)
338 return -ENODEV;
339
336 if (count == 0) { 340 if (count == 0) {
337 dbg("%s - write request of 0 bytes", __func__); 341 dbg("%s - write request of 0 bytes", __func__);
338 return 0; 342 return 0;
339 } 343 }
340 344
341 /* only do something if we have a bulk out endpoint */
342 if (!serial->num_bulk_out)
343 return 0;
344
345 if (serial->type->max_in_flight_urbs) 345 if (serial->type->max_in_flight_urbs)
346 return usb_serial_multi_urb_write(tty, port, 346 return usb_serial_multi_urb_write(tty, port,
347 buf, count); 347 buf, count);
@@ -364,14 +364,19 @@ int usb_serial_generic_write_room(struct tty_struct *tty)
364 int room = 0; 364 int room = 0;
365 365
366 dbg("%s - port %d", __func__, port->number); 366 dbg("%s - port %d", __func__, port->number);
367
368 if (!port->bulk_out_size)
369 return 0;
370
367 spin_lock_irqsave(&port->lock, flags); 371 spin_lock_irqsave(&port->lock, flags);
368 if (serial->type->max_in_flight_urbs) { 372 if (serial->type->max_in_flight_urbs) {
369 if (port->urbs_in_flight < serial->type->max_in_flight_urbs) 373 if (port->urbs_in_flight < serial->type->max_in_flight_urbs)
370 room = port->bulk_out_size * 374 room = port->bulk_out_size *
371 (serial->type->max_in_flight_urbs - 375 (serial->type->max_in_flight_urbs -
372 port->urbs_in_flight); 376 port->urbs_in_flight);
373 } else if (serial->num_bulk_out) 377 } else {
374 room = kfifo_avail(&port->write_fifo); 378 room = kfifo_avail(&port->write_fifo);
379 }
375 spin_unlock_irqrestore(&port->lock, flags); 380 spin_unlock_irqrestore(&port->lock, flags);
376 381
377 dbg("%s - returns %d", __func__, room); 382 dbg("%s - returns %d", __func__, room);
@@ -382,15 +387,18 @@ int usb_serial_generic_chars_in_buffer(struct tty_struct *tty)
382{ 387{
383 struct usb_serial_port *port = tty->driver_data; 388 struct usb_serial_port *port = tty->driver_data;
384 struct usb_serial *serial = port->serial; 389 struct usb_serial *serial = port->serial;
385 int chars = 0;
386 unsigned long flags; 390 unsigned long flags;
391 int chars;
387 392
388 dbg("%s - port %d", __func__, port->number); 393 dbg("%s - port %d", __func__, port->number);
389 394
395 if (!port->bulk_out_size)
396 return 0;
397
390 spin_lock_irqsave(&port->lock, flags); 398 spin_lock_irqsave(&port->lock, flags);
391 if (serial->type->max_in_flight_urbs) 399 if (serial->type->max_in_flight_urbs)
392 chars = port->tx_bytes_flight; 400 chars = port->tx_bytes_flight;
393 else if (serial->num_bulk_out) 401 else
394 chars = kfifo_len(&port->write_fifo); 402 chars = kfifo_len(&port->write_fifo);
395 spin_unlock_irqrestore(&port->lock, flags); 403 spin_unlock_irqrestore(&port->lock, flags);
396 404
@@ -415,11 +423,13 @@ void usb_serial_generic_resubmit_read_urb(struct usb_serial_port *port,
415 ((serial->type->read_bulk_callback) ? 423 ((serial->type->read_bulk_callback) ?
416 serial->type->read_bulk_callback : 424 serial->type->read_bulk_callback :
417 usb_serial_generic_read_bulk_callback), port); 425 usb_serial_generic_read_bulk_callback), port);
426
418 result = usb_submit_urb(urb, mem_flags); 427 result = usb_submit_urb(urb, mem_flags);
419 if (result) 428 if (result && result != -EPERM) {
420 dev_err(&port->dev, 429 dev_err(&port->dev,
421 "%s - failed resubmitting read urb, error %d\n", 430 "%s - failed resubmitting read urb, error %d\n",
422 __func__, result); 431 __func__, result);
432 }
423} 433}
424EXPORT_SYMBOL_GPL(usb_serial_generic_resubmit_read_urb); 434EXPORT_SYMBOL_GPL(usb_serial_generic_resubmit_read_urb);
425 435
@@ -498,23 +508,18 @@ void usb_serial_generic_write_bulk_callback(struct urb *urb)
498 if (port->urbs_in_flight < 0) 508 if (port->urbs_in_flight < 0)
499 port->urbs_in_flight = 0; 509 port->urbs_in_flight = 0;
500 spin_unlock_irqrestore(&port->lock, flags); 510 spin_unlock_irqrestore(&port->lock, flags);
501
502 if (status) {
503 dbg("%s - nonzero multi-urb write bulk status "
504 "received: %d", __func__, status);
505 return;
506 }
507 } else { 511 } else {
508 port->write_urb_busy = 0; 512 port->write_urb_busy = 0;
509 513
510 if (status) { 514 if (status)
511 dbg("%s - nonzero multi-urb write bulk status "
512 "received: %d", __func__, status);
513 kfifo_reset_out(&port->write_fifo); 515 kfifo_reset_out(&port->write_fifo);
514 } else 516 else
515 usb_serial_generic_write_start(port); 517 usb_serial_generic_write_start(port);
516 } 518 }
517 519
520 if (status)
521 dbg("%s - non-zero urb status: %d", __func__, status);
522
518 usb_serial_port_softint(port); 523 usb_serial_port_softint(port);
519} 524}
520EXPORT_SYMBOL_GPL(usb_serial_generic_write_bulk_callback); 525EXPORT_SYMBOL_GPL(usb_serial_generic_write_bulk_callback);
diff --git a/drivers/usb/serial/navman.c b/drivers/usb/serial/navman.c
index 04a6cbbed2c..a6b207c8491 100644
--- a/drivers/usb/serial/navman.c
+++ b/drivers/usb/serial/navman.c
@@ -12,6 +12,7 @@
12 * flags as the navman is rx only so cannot echo. 12 * flags as the navman is rx only so cannot echo.
13 */ 13 */
14 14
15#include <linux/gfp.h>
15#include <linux/kernel.h> 16#include <linux/kernel.h>
16#include <linux/init.h> 17#include <linux/init.h>
17#include <linux/tty.h> 18#include <linux/tty.h>
diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c
index 701452ae919..ed01f3b2de8 100644
--- a/drivers/usb/serial/opticon.c
+++ b/drivers/usb/serial/opticon.c
@@ -13,6 +13,7 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/tty.h> 14#include <linux/tty.h>
15#include <linux/tty_driver.h> 15#include <linux/tty_driver.h>
16#include <linux/slab.h>
16#include <linux/tty_flip.h> 17#include <linux/tty_flip.h>
17#include <linux/serial.h> 18#include <linux/serial.h>
18#include <linux/module.h> 19#include <linux/module.h>
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 847b805d63a..84d0edad8e4 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -37,6 +37,7 @@
37#include <linux/errno.h> 37#include <linux/errno.h>
38#include <linux/tty.h> 38#include <linux/tty.h>
39#include <linux/tty_flip.h> 39#include <linux/tty_flip.h>
40#include <linux/slab.h>
40#include <linux/module.h> 41#include <linux/module.h>
41#include <linux/bitops.h> 42#include <linux/bitops.h>
42#include <linux/usb.h> 43#include <linux/usb.h>
@@ -288,7 +289,9 @@ static int option_resume(struct usb_serial *serial);
288 289
289#define QUALCOMM_VENDOR_ID 0x05C6 290#define QUALCOMM_VENDOR_ID 0x05C6
290 291
291#define MAXON_VENDOR_ID 0x16d8 292#define CMOTECH_VENDOR_ID 0x16d8
293#define CMOTECH_PRODUCT_6008 0x6008
294#define CMOTECH_PRODUCT_6280 0x6280
292 295
293#define TELIT_VENDOR_ID 0x1bc7 296#define TELIT_VENDOR_ID 0x1bc7
294#define TELIT_PRODUCT_UC864E 0x1003 297#define TELIT_PRODUCT_UC864E 0x1003
@@ -302,6 +305,11 @@ static int option_resume(struct usb_serial *serial);
302#define ZTE_PRODUCT_CDMA_TECH 0xfffe 305#define ZTE_PRODUCT_CDMA_TECH 0xfffe
303#define ZTE_PRODUCT_AC8710 0xfff1 306#define ZTE_PRODUCT_AC8710 0xfff1
304#define ZTE_PRODUCT_AC2726 0xfff5 307#define ZTE_PRODUCT_AC2726 0xfff5
308#define ZTE_PRODUCT_AC8710T 0xffff
309
310/* ZTE PRODUCTS -- alternate vendor ID */
311#define ZTE_VENDOR_ID2 0x1d6b
312#define ZTE_PRODUCT_MF_330 0x0002
305 313
306#define BENQ_VENDOR_ID 0x04a5 314#define BENQ_VENDOR_ID 0x04a5
307#define BENQ_PRODUCT_H10 0x4068 315#define BENQ_PRODUCT_H10 0x4068
@@ -309,6 +317,7 @@ static int option_resume(struct usb_serial *serial);
309#define DLINK_VENDOR_ID 0x1186 317#define DLINK_VENDOR_ID 0x1186
310#define DLINK_PRODUCT_DWM_652 0x3e04 318#define DLINK_PRODUCT_DWM_652 0x3e04
311#define DLINK_PRODUCT_DWM_652_U5 0xce16 319#define DLINK_PRODUCT_DWM_652_U5 0xce16
320#define DLINK_PRODUCT_DWM_652_U5A 0xce1e
312 321
313#define QISDA_VENDOR_ID 0x1da5 322#define QISDA_VENDOR_ID 0x1da5
314#define QISDA_PRODUCT_H21_4512 0x4512 323#define QISDA_PRODUCT_H21_4512 0x4512
@@ -332,6 +341,24 @@ static int option_resume(struct usb_serial *serial);
332#define ALCATEL_VENDOR_ID 0x1bbb 341#define ALCATEL_VENDOR_ID 0x1bbb
333#define ALCATEL_PRODUCT_X060S 0x0000 342#define ALCATEL_PRODUCT_X060S 0x0000
334 343
344#define PIRELLI_VENDOR_ID 0x1266
345#define PIRELLI_PRODUCT_C100_1 0x1002
346#define PIRELLI_PRODUCT_C100_2 0x1003
347#define PIRELLI_PRODUCT_1004 0x1004
348#define PIRELLI_PRODUCT_1005 0x1005
349#define PIRELLI_PRODUCT_1006 0x1006
350#define PIRELLI_PRODUCT_1007 0x1007
351#define PIRELLI_PRODUCT_1008 0x1008
352#define PIRELLI_PRODUCT_1009 0x1009
353#define PIRELLI_PRODUCT_100A 0x100a
354#define PIRELLI_PRODUCT_100B 0x100b
355#define PIRELLI_PRODUCT_100C 0x100c
356#define PIRELLI_PRODUCT_100D 0x100d
357#define PIRELLI_PRODUCT_100E 0x100e
358#define PIRELLI_PRODUCT_100F 0x100f
359#define PIRELLI_PRODUCT_1011 0x1011
360#define PIRELLI_PRODUCT_1012 0x1012
361
335/* Airplus products */ 362/* Airplus products */
336#define AIRPLUS_VENDOR_ID 0x1011 363#define AIRPLUS_VENDOR_ID 0x1011
337#define AIRPLUS_PRODUCT_MCD650 0x3198 364#define AIRPLUS_PRODUCT_MCD650 0x3198
@@ -351,6 +378,8 @@ static int option_resume(struct usb_serial *serial);
351#define HAIER_VENDOR_ID 0x201e 378#define HAIER_VENDOR_ID 0x201e
352#define HAIER_PRODUCT_CE100 0x2009 379#define HAIER_PRODUCT_CE100 0x2009
353 380
381#define CINTERION_VENDOR_ID 0x0681
382
354/* some devices interfaces need special handling due to a number of reasons */ 383/* some devices interfaces need special handling due to a number of reasons */
355enum option_blacklist_reason { 384enum option_blacklist_reason {
356 OPTION_BLACKLIST_NONE = 0, 385 OPTION_BLACKLIST_NONE = 0,
@@ -547,7 +576,8 @@ static const struct usb_device_id option_ids[] = {
547 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) }, 576 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) },
548 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6000)}, /* ZTE AC8700 */ 577 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6000)}, /* ZTE AC8700 */
549 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ 578 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */
550 { USB_DEVICE(MAXON_VENDOR_ID, 0x6280) }, /* BP3-USB & BP3-EXT HSDPA */ 579 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6280) }, /* BP3-USB & BP3-EXT HSDPA */
580 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6008) },
551 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) }, 581 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) },
552 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864G) }, 582 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864G) },
553 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF622, 0xff, 0xff, 0xff) }, /* ZTE WCDMA products */ 583 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF622, 0xff, 0xff, 0xff) }, /* ZTE WCDMA products */
@@ -656,9 +686,12 @@ static const struct usb_device_id option_ids[] = {
656 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH, 0xff, 0xff, 0xff) }, 686 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH, 0xff, 0xff, 0xff) },
657 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC8710, 0xff, 0xff, 0xff) }, 687 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC8710, 0xff, 0xff, 0xff) },
658 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 0xff, 0xff, 0xff) }, 688 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC2726, 0xff, 0xff, 0xff) },
689 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC8710T, 0xff, 0xff, 0xff) },
690 { USB_DEVICE(ZTE_VENDOR_ID2, ZTE_PRODUCT_MF_330) },
659 { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) }, 691 { USB_DEVICE(BENQ_VENDOR_ID, BENQ_PRODUCT_H10) },
660 { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) }, 692 { USB_DEVICE(DLINK_VENDOR_ID, DLINK_PRODUCT_DWM_652) },
661 { USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5) }, /* Yes, ALINK_VENDOR_ID */ 693 { USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5) }, /* Yes, ALINK_VENDOR_ID */
694 { USB_DEVICE(ALINK_VENDOR_ID, DLINK_PRODUCT_DWM_652_U5A) },
662 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4512) }, 695 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4512) },
663 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4523) }, 696 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H21_4523) },
664 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H20_4515) }, 697 { USB_DEVICE(QISDA_VENDOR_ID, QISDA_PRODUCT_H20_4515) },
@@ -666,7 +699,6 @@ static const struct usb_device_id option_ids[] = {
666 { USB_DEVICE(TOSHIBA_VENDOR_ID, TOSHIBA_PRODUCT_G450) }, 699 { USB_DEVICE(TOSHIBA_VENDOR_ID, TOSHIBA_PRODUCT_G450) },
667 { USB_DEVICE(TOSHIBA_VENDOR_ID, TOSHIBA_PRODUCT_HSDPA_MINICARD ) }, /* Toshiba 3G HSDPA == Novatel Expedite EU870D MiniCard */ 700 { USB_DEVICE(TOSHIBA_VENDOR_ID, TOSHIBA_PRODUCT_HSDPA_MINICARD ) }, /* Toshiba 3G HSDPA == Novatel Expedite EU870D MiniCard */
668 { USB_DEVICE(ALINK_VENDOR_ID, 0x9000) }, 701 { USB_DEVICE(ALINK_VENDOR_ID, 0x9000) },
669 { USB_DEVICE(ALINK_VENDOR_ID, 0xce16) },
670 { USB_DEVICE_AND_INTERFACE_INFO(ALINK_VENDOR_ID, ALINK_PRODUCT_3GU, 0xff, 0xff, 0xff) }, 702 { USB_DEVICE_AND_INTERFACE_INFO(ALINK_VENDOR_ID, ALINK_PRODUCT_3GU, 0xff, 0xff, 0xff) },
671 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X060S) }, 703 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X060S) },
672 { USB_DEVICE(AIRPLUS_VENDOR_ID, AIRPLUS_PRODUCT_MCD650) }, 704 { USB_DEVICE(AIRPLUS_VENDOR_ID, AIRPLUS_PRODUCT_MCD650) },
@@ -675,6 +707,25 @@ static const struct usb_device_id option_ids[] = {
675 .driver_info = (kernel_ulong_t)&four_g_w14_blacklist 707 .driver_info = (kernel_ulong_t)&four_g_w14_blacklist
676 }, 708 },
677 { USB_DEVICE(HAIER_VENDOR_ID, HAIER_PRODUCT_CE100) }, 709 { USB_DEVICE(HAIER_VENDOR_ID, HAIER_PRODUCT_CE100) },
710 /* Pirelli */
711 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_1)},
712 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_2)},
713 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1004)},
714 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1005)},
715 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1006)},
716 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1007)},
717 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1008)},
718 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1009)},
719 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100A)},
720 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100B) },
721 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100C) },
722 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100D) },
723 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100E) },
724 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100F) },
725 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1011)},
726 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1012)},
727
728 { USB_DEVICE(CINTERION_VENDOR_ID, 0x0047) },
678 { } /* Terminating entry */ 729 { } /* Terminating entry */
679}; 730};
680MODULE_DEVICE_TABLE(usb, option_ids); 731MODULE_DEVICE_TABLE(usb, option_ids);
@@ -798,12 +849,19 @@ static int option_probe(struct usb_serial *serial,
798 const struct usb_device_id *id) 849 const struct usb_device_id *id)
799{ 850{
800 struct option_intf_private *data; 851 struct option_intf_private *data;
852
801 /* D-Link DWM 652 still exposes CD-Rom emulation interface in modem mode */ 853 /* D-Link DWM 652 still exposes CD-Rom emulation interface in modem mode */
802 if (serial->dev->descriptor.idVendor == DLINK_VENDOR_ID && 854 if (serial->dev->descriptor.idVendor == DLINK_VENDOR_ID &&
803 serial->dev->descriptor.idProduct == DLINK_PRODUCT_DWM_652 && 855 serial->dev->descriptor.idProduct == DLINK_PRODUCT_DWM_652 &&
804 serial->interface->cur_altsetting->desc.bInterfaceClass == 0x8) 856 serial->interface->cur_altsetting->desc.bInterfaceClass == 0x8)
805 return -ENODEV; 857 return -ENODEV;
806 858
859 /* Bandrich modem and AT command interface is 0xff */
860 if ((serial->dev->descriptor.idVendor == BANDRICH_VENDOR_ID ||
861 serial->dev->descriptor.idVendor == PIRELLI_VENDOR_ID) &&
862 serial->interface->cur_altsetting->desc.bInterfaceClass != 0xff)
863 return -ENODEV;
864
807 data = serial->private = kzalloc(sizeof(struct option_intf_private), GFP_KERNEL); 865 data = serial->private = kzalloc(sizeof(struct option_intf_private), GFP_KERNEL);
808 if (!data) 866 if (!data)
809 return -ENOMEM; 867 return -ENOMEM;
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 73d5f346d3e..c28b1607eac 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -59,6 +59,7 @@ static const struct usb_device_id id_table[] = {
59 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_ALDIGA) }, 59 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_ALDIGA) },
60 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_MMX) }, 60 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_MMX) },
61 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_GPRS) }, 61 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_GPRS) },
62 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_HCR331) },
62 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) }, 63 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) },
63 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) }, 64 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) },
64 { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) }, 65 { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) },
@@ -97,6 +98,7 @@ static const struct usb_device_id id_table[] = {
97 { USB_DEVICE(CRESSI_VENDOR_ID, CRESSI_EDY_PRODUCT_ID) }, 98 { USB_DEVICE(CRESSI_VENDOR_ID, CRESSI_EDY_PRODUCT_ID) },
98 { USB_DEVICE(SONY_VENDOR_ID, SONY_QN3USB_PRODUCT_ID) }, 99 { USB_DEVICE(SONY_VENDOR_ID, SONY_QN3USB_PRODUCT_ID) },
99 { USB_DEVICE(SANWA_VENDOR_ID, SANWA_PRODUCT_ID) }, 100 { USB_DEVICE(SANWA_VENDOR_ID, SANWA_PRODUCT_ID) },
101 { USB_DEVICE(ADLINK_VENDOR_ID, ADLINK_ND6530_PRODUCT_ID) },
100 { } /* Terminating entry */ 102 { } /* Terminating entry */
101}; 103};
102 104
diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h
index d640dc95156..23c09b38b9e 100644
--- a/drivers/usb/serial/pl2303.h
+++ b/drivers/usb/serial/pl2303.h
@@ -20,6 +20,7 @@
20#define PL2303_PRODUCT_ID_ALDIGA 0x0611 20#define PL2303_PRODUCT_ID_ALDIGA 0x0611
21#define PL2303_PRODUCT_ID_MMX 0x0612 21#define PL2303_PRODUCT_ID_MMX 0x0612
22#define PL2303_PRODUCT_ID_GPRS 0x0609 22#define PL2303_PRODUCT_ID_GPRS 0x0609
23#define PL2303_PRODUCT_ID_HCR331 0x331a
23 24
24#define ATEN_VENDOR_ID 0x0557 25#define ATEN_VENDOR_ID 0x0557
25#define ATEN_VENDOR_ID2 0x0547 26#define ATEN_VENDOR_ID2 0x0547
@@ -134,3 +135,7 @@
134/* Sanwa KB-USB2 multimeter cable (ID: 11ad:0001) */ 135/* Sanwa KB-USB2 multimeter cable (ID: 11ad:0001) */
135#define SANWA_VENDOR_ID 0x11ad 136#define SANWA_VENDOR_ID 0x11ad
136#define SANWA_PRODUCT_ID 0x0001 137#define SANWA_PRODUCT_ID 0x0001
138
139/* ADLINK ND-6530 RS232,RS485 and RS422 adapter */
140#define ADLINK_VENDOR_ID 0x0b63
141#define ADLINK_ND6530_PRODUCT_ID 0x6530
diff --git a/drivers/usb/serial/qcaux.c b/drivers/usb/serial/qcaux.c
index 0b936206171..7e3bea23600 100644
--- a/drivers/usb/serial/qcaux.c
+++ b/drivers/usb/serial/qcaux.c
@@ -42,6 +42,14 @@
42#define CMOTECH_PRODUCT_CDU550 0x5553 42#define CMOTECH_PRODUCT_CDU550 0x5553
43#define CMOTECH_PRODUCT_CDX650 0x6512 43#define CMOTECH_PRODUCT_CDX650 0x6512
44 44
45/* LG devices */
46#define LG_VENDOR_ID 0x1004
47#define LG_PRODUCT_VX4400_6000 0x6000 /* VX4400/VX6000/Rumor */
48
49/* Sanyo devices */
50#define SANYO_VENDOR_ID 0x0474
51#define SANYO_PRODUCT_KATANA_LX 0x0754 /* SCP-3800 (Katana LX) */
52
45static struct usb_device_id id_table[] = { 53static struct usb_device_id id_table[] = {
46 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, UTSTARCOM_PRODUCT_PC5740, 0xff, 0x00, 0x00) }, 54 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, UTSTARCOM_PRODUCT_PC5740, 0xff, 0x00, 0x00) },
47 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, UTSTARCOM_PRODUCT_PC5750, 0xff, 0x00, 0x00) }, 55 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, UTSTARCOM_PRODUCT_PC5750, 0xff, 0x00, 0x00) },
@@ -51,6 +59,8 @@ static struct usb_device_id id_table[] = {
51 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, UTSTARCOM_PRODUCT_UM175_ALLTEL, 0xff, 0x00, 0x00) }, 59 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, UTSTARCOM_PRODUCT_UM175_ALLTEL, 0xff, 0x00, 0x00) },
52 { USB_DEVICE_AND_INTERFACE_INFO(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CDU550, 0xff, 0xff, 0x00) }, 60 { USB_DEVICE_AND_INTERFACE_INFO(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CDU550, 0xff, 0xff, 0x00) },
53 { USB_DEVICE_AND_INTERFACE_INFO(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CDX650, 0xff, 0xff, 0x00) }, 61 { USB_DEVICE_AND_INTERFACE_INFO(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CDX650, 0xff, 0xff, 0x00) },
62 { USB_DEVICE_AND_INTERFACE_INFO(LG_VENDOR_ID, LG_PRODUCT_VX4400_6000, 0xff, 0xff, 0x00) },
63 { USB_DEVICE_AND_INTERFACE_INFO(SANYO_VENDOR_ID, SANYO_PRODUCT_KATANA_LX, 0xff, 0xff, 0x00) },
54 { }, 64 { },
55}; 65};
56MODULE_DEVICE_TABLE(usb, id_table); 66MODULE_DEVICE_TABLE(usb, id_table);
diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c
index 310ff6ec656..53a2d5a935a 100644
--- a/drivers/usb/serial/qcserial.c
+++ b/drivers/usb/serial/qcserial.c
@@ -47,6 +47,35 @@ static const struct usb_device_id id_table[] = {
47 {USB_DEVICE(0x05c6, 0x9221)}, /* Generic Gobi QDL device */ 47 {USB_DEVICE(0x05c6, 0x9221)}, /* Generic Gobi QDL device */
48 {USB_DEVICE(0x05c6, 0x9231)}, /* Generic Gobi QDL device */ 48 {USB_DEVICE(0x05c6, 0x9231)}, /* Generic Gobi QDL device */
49 {USB_DEVICE(0x1f45, 0x0001)}, /* Unknown Gobi QDL device */ 49 {USB_DEVICE(0x1f45, 0x0001)}, /* Unknown Gobi QDL device */
50 {USB_DEVICE(0x413c, 0x8185)}, /* Dell Gobi 2000 QDL device (N0218, VU936) */
51 {USB_DEVICE(0x413c, 0x8186)}, /* Dell Gobi 2000 Modem device (N0218, VU936) */
52 {USB_DEVICE(0x05c6, 0x9224)}, /* Sony Gobi 2000 QDL device (N0279, VU730) */
53 {USB_DEVICE(0x05c6, 0x9225)}, /* Sony Gobi 2000 Modem device (N0279, VU730) */
54 {USB_DEVICE(0x05c6, 0x9244)}, /* Samsung Gobi 2000 QDL device (VL176) */
55 {USB_DEVICE(0x05c6, 0x9245)}, /* Samsung Gobi 2000 Modem device (VL176) */
56 {USB_DEVICE(0x03f0, 0x241d)}, /* HP Gobi 2000 QDL device (VP412) */
57 {USB_DEVICE(0x03f0, 0x251d)}, /* HP Gobi 2000 Modem device (VP412) */
58 {USB_DEVICE(0x05c6, 0x9214)}, /* Acer Gobi 2000 QDL device (VP413) */
59 {USB_DEVICE(0x05c6, 0x9215)}, /* Acer Gobi 2000 Modem device (VP413) */
60 {USB_DEVICE(0x05c6, 0x9264)}, /* Asus Gobi 2000 QDL device (VR305) */
61 {USB_DEVICE(0x05c6, 0x9265)}, /* Asus Gobi 2000 Modem device (VR305) */
62 {USB_DEVICE(0x05c6, 0x9234)}, /* Top Global Gobi 2000 QDL device (VR306) */
63 {USB_DEVICE(0x05c6, 0x9235)}, /* Top Global Gobi 2000 Modem device (VR306) */
64 {USB_DEVICE(0x05c6, 0x9274)}, /* iRex Technologies Gobi 2000 QDL device (VR307) */
65 {USB_DEVICE(0x05c6, 0x9275)}, /* iRex Technologies Gobi 2000 Modem device (VR307) */
66 {USB_DEVICE(0x1199, 0x9000)}, /* Sierra Wireless Gobi 2000 QDL device (VT773) */
67 {USB_DEVICE(0x1199, 0x9001)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
68 {USB_DEVICE(0x1199, 0x9002)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
69 {USB_DEVICE(0x1199, 0x9003)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
70 {USB_DEVICE(0x1199, 0x9004)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
71 {USB_DEVICE(0x1199, 0x9005)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
72 {USB_DEVICE(0x1199, 0x9006)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
73 {USB_DEVICE(0x1199, 0x9007)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
74 {USB_DEVICE(0x1199, 0x9008)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
75 {USB_DEVICE(0x1199, 0x9009)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
76 {USB_DEVICE(0x1199, 0x900a)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */
77 {USB_DEVICE(0x16d8, 0x8001)}, /* CMDTech Gobi 2000 QDL device (VU922) */
78 {USB_DEVICE(0x16d8, 0x8002)}, /* CMDTech Gobi 2000 Modem device (VU922) */
50 { } /* Terminating entry */ 79 { } /* Terminating entry */
51}; 80};
52MODULE_DEVICE_TABLE(usb, id_table); 81MODULE_DEVICE_TABLE(usb, id_table);
diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c
index 4b463cd140e..43a0cadd578 100644
--- a/drivers/usb/serial/safe_serial.c
+++ b/drivers/usb/serial/safe_serial.c
@@ -64,8 +64,8 @@
64 64
65#include <linux/kernel.h> 65#include <linux/kernel.h>
66#include <linux/errno.h> 66#include <linux/errno.h>
67#include <linux/gfp.h>
67#include <linux/init.h> 68#include <linux/init.h>
68#include <linux/slab.h>
69#include <linux/tty.h> 69#include <linux/tty.h>
70#include <linux/tty_driver.h> 70#include <linux/tty_driver.h>
71#include <linux/tty_flip.h> 71#include <linux/tty_flip.h>
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index 34e6f894cba..ef0bdb08d78 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -26,6 +26,7 @@
26#include <linux/jiffies.h> 26#include <linux/jiffies.h>
27#include <linux/errno.h> 27#include <linux/errno.h>
28#include <linux/tty.h> 28#include <linux/tty.h>
29#include <linux/slab.h>
29#include <linux/tty_flip.h> 30#include <linux/tty_flip.h>
30#include <linux/module.h> 31#include <linux/module.h>
31#include <linux/usb.h> 32#include <linux/usb.h>
@@ -229,6 +230,7 @@ static const struct sierra_iface_info direct_ip_interface_blacklist = {
229static const struct usb_device_id id_table[] = { 230static const struct usb_device_id id_table[] = {
230 { USB_DEVICE(0x0F3D, 0x0112) }, /* Airprime/Sierra PC 5220 */ 231 { USB_DEVICE(0x0F3D, 0x0112) }, /* Airprime/Sierra PC 5220 */
231 { USB_DEVICE(0x03F0, 0x1B1D) }, /* HP ev2200 a.k.a MC5720 */ 232 { USB_DEVICE(0x03F0, 0x1B1D) }, /* HP ev2200 a.k.a MC5720 */
233 { USB_DEVICE(0x03F0, 0x211D) }, /* HP ev2210 a.k.a MC5725 */
232 { USB_DEVICE(0x03F0, 0x1E1D) }, /* HP hs2300 a.k.a MC8775 */ 234 { USB_DEVICE(0x03F0, 0x1E1D) }, /* HP hs2300 a.k.a MC8775 */
233 235
234 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */ 236 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
diff --git a/drivers/usb/serial/symbolserial.c b/drivers/usb/serial/symbolserial.c
index ee190cc1757..d9457bd4fe1 100644
--- a/drivers/usb/serial/symbolserial.c
+++ b/drivers/usb/serial/symbolserial.c
@@ -12,6 +12,7 @@
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/tty.h> 14#include <linux/tty.h>
15#include <linux/slab.h>
15#include <linux/tty_driver.h> 16#include <linux/tty_driver.h>
16#include <linux/tty_flip.h> 17#include <linux/tty_flip.h>
17#include <linux/module.h> 18#include <linux/module.h>
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 0afe5c71c17..e1bfda33f5b 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -172,7 +172,7 @@ static unsigned int product_5052_count;
172/* the array dimension is the number of default entries plus */ 172/* the array dimension is the number of default entries plus */
173/* TI_EXTRA_VID_PID_COUNT user defined entries plus 1 terminating */ 173/* TI_EXTRA_VID_PID_COUNT user defined entries plus 1 terminating */
174/* null entry */ 174/* null entry */
175static struct usb_device_id ti_id_table_3410[10+TI_EXTRA_VID_PID_COUNT+1] = { 175static struct usb_device_id ti_id_table_3410[13+TI_EXTRA_VID_PID_COUNT+1] = {
176 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) }, 176 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
177 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) }, 177 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
178 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) }, 178 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) },
@@ -180,6 +180,9 @@ static struct usb_device_id ti_id_table_3410[10+TI_EXTRA_VID_PID_COUNT+1] = {
180 { USB_DEVICE(MTS_VENDOR_ID, MTS_CDMA_PRODUCT_ID) }, 180 { USB_DEVICE(MTS_VENDOR_ID, MTS_CDMA_PRODUCT_ID) },
181 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_PRODUCT_ID) }, 181 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_PRODUCT_ID) },
182 { USB_DEVICE(MTS_VENDOR_ID, MTS_EDGE_PRODUCT_ID) }, 182 { USB_DEVICE(MTS_VENDOR_ID, MTS_EDGE_PRODUCT_ID) },
183 { USB_DEVICE(MTS_VENDOR_ID, MTS_MT9234MU_PRODUCT_ID) },
184 { USB_DEVICE(MTS_VENDOR_ID, MTS_MT9234ZBA_PRODUCT_ID) },
185 { USB_DEVICE(MTS_VENDOR_ID, MTS_MT9234ZBAOLD_PRODUCT_ID) },
183 { USB_DEVICE(IBM_VENDOR_ID, IBM_4543_PRODUCT_ID) }, 186 { USB_DEVICE(IBM_VENDOR_ID, IBM_4543_PRODUCT_ID) },
184 { USB_DEVICE(IBM_VENDOR_ID, IBM_454B_PRODUCT_ID) }, 187 { USB_DEVICE(IBM_VENDOR_ID, IBM_454B_PRODUCT_ID) },
185 { USB_DEVICE(IBM_VENDOR_ID, IBM_454C_PRODUCT_ID) }, 188 { USB_DEVICE(IBM_VENDOR_ID, IBM_454C_PRODUCT_ID) },
@@ -192,7 +195,7 @@ static struct usb_device_id ti_id_table_5052[5+TI_EXTRA_VID_PID_COUNT+1] = {
192 { USB_DEVICE(TI_VENDOR_ID, TI_5052_FIRMWARE_PRODUCT_ID) }, 195 { USB_DEVICE(TI_VENDOR_ID, TI_5052_FIRMWARE_PRODUCT_ID) },
193}; 196};
194 197
195static struct usb_device_id ti_id_table_combined[14+2*TI_EXTRA_VID_PID_COUNT+1] = { 198static struct usb_device_id ti_id_table_combined[17+2*TI_EXTRA_VID_PID_COUNT+1] = {
196 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) }, 199 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
197 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) }, 200 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
198 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) }, 201 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) },
@@ -200,6 +203,9 @@ static struct usb_device_id ti_id_table_combined[14+2*TI_EXTRA_VID_PID_COUNT+1]
200 { USB_DEVICE(MTS_VENDOR_ID, MTS_CDMA_PRODUCT_ID) }, 203 { USB_DEVICE(MTS_VENDOR_ID, MTS_CDMA_PRODUCT_ID) },
201 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_PRODUCT_ID) }, 204 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_PRODUCT_ID) },
202 { USB_DEVICE(MTS_VENDOR_ID, MTS_EDGE_PRODUCT_ID) }, 205 { USB_DEVICE(MTS_VENDOR_ID, MTS_EDGE_PRODUCT_ID) },
206 { USB_DEVICE(MTS_VENDOR_ID, MTS_MT9234MU_PRODUCT_ID) },
207 { USB_DEVICE(MTS_VENDOR_ID, MTS_MT9234ZBA_PRODUCT_ID) },
208 { USB_DEVICE(MTS_VENDOR_ID, MTS_MT9234ZBAOLD_PRODUCT_ID) },
203 { USB_DEVICE(TI_VENDOR_ID, TI_5052_BOOT_PRODUCT_ID) }, 209 { USB_DEVICE(TI_VENDOR_ID, TI_5052_BOOT_PRODUCT_ID) },
204 { USB_DEVICE(TI_VENDOR_ID, TI_5152_BOOT_PRODUCT_ID) }, 210 { USB_DEVICE(TI_VENDOR_ID, TI_5152_BOOT_PRODUCT_ID) },
205 { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) }, 211 { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) },
@@ -287,6 +293,8 @@ MODULE_FIRMWARE("ti_5052.fw");
287MODULE_FIRMWARE("mts_cdma.fw"); 293MODULE_FIRMWARE("mts_cdma.fw");
288MODULE_FIRMWARE("mts_gsm.fw"); 294MODULE_FIRMWARE("mts_gsm.fw");
289MODULE_FIRMWARE("mts_edge.fw"); 295MODULE_FIRMWARE("mts_edge.fw");
296MODULE_FIRMWARE("mts_mt9234mu.fw");
297MODULE_FIRMWARE("mts_mt9234zba.fw");
290 298
291module_param(debug, bool, S_IRUGO | S_IWUSR); 299module_param(debug, bool, S_IRUGO | S_IWUSR);
292MODULE_PARM_DESC(debug, "Enable debugging, 0=no, 1=yes"); 300MODULE_PARM_DESC(debug, "Enable debugging, 0=no, 1=yes");
@@ -1687,6 +1695,7 @@ static int ti_download_firmware(struct ti_device *tdev)
1687 const struct firmware *fw_p; 1695 const struct firmware *fw_p;
1688 char buf[32]; 1696 char buf[32];
1689 1697
1698 dbg("%s\n", __func__);
1690 /* try ID specific firmware first, then try generic firmware */ 1699 /* try ID specific firmware first, then try generic firmware */
1691 sprintf(buf, "ti_usb-v%04x-p%04x.fw", dev->descriptor.idVendor, 1700 sprintf(buf, "ti_usb-v%04x-p%04x.fw", dev->descriptor.idVendor,
1692 dev->descriptor.idProduct); 1701 dev->descriptor.idProduct);
@@ -1703,7 +1712,15 @@ static int ti_download_firmware(struct ti_device *tdev)
1703 case MTS_EDGE_PRODUCT_ID: 1712 case MTS_EDGE_PRODUCT_ID:
1704 strcpy(buf, "mts_edge.fw"); 1713 strcpy(buf, "mts_edge.fw");
1705 break; 1714 break;
1706 } 1715 case MTS_MT9234MU_PRODUCT_ID:
1716 strcpy(buf, "mts_mt9234mu.fw");
1717 break;
1718 case MTS_MT9234ZBA_PRODUCT_ID:
1719 strcpy(buf, "mts_mt9234zba.fw");
1720 break;
1721 case MTS_MT9234ZBAOLD_PRODUCT_ID:
1722 strcpy(buf, "mts_mt9234zba.fw");
1723 break; }
1707 } 1724 }
1708 if (buf[0] == '\0') { 1725 if (buf[0] == '\0') {
1709 if (tdev->td_is_3410) 1726 if (tdev->td_is_3410)
@@ -1718,7 +1735,7 @@ static int ti_download_firmware(struct ti_device *tdev)
1718 return -ENOENT; 1735 return -ENOENT;
1719 } 1736 }
1720 if (fw_p->size > TI_FIRMWARE_BUF_SIZE) { 1737 if (fw_p->size > TI_FIRMWARE_BUF_SIZE) {
1721 dev_err(&dev->dev, "%s - firmware too large\n", __func__); 1738 dev_err(&dev->dev, "%s - firmware too large %zu\n", __func__, fw_p->size);
1722 return -ENOENT; 1739 return -ENOENT;
1723 } 1740 }
1724 1741
@@ -1730,6 +1747,7 @@ static int ti_download_firmware(struct ti_device *tdev)
1730 status = ti_do_download(dev, pipe, buffer, fw_p->size); 1747 status = ti_do_download(dev, pipe, buffer, fw_p->size);
1731 kfree(buffer); 1748 kfree(buffer);
1732 } else { 1749 } else {
1750 dbg("%s ENOMEM\n", __func__);
1733 status = -ENOMEM; 1751 status = -ENOMEM;
1734 } 1752 }
1735 release_firmware(fw_p); 1753 release_firmware(fw_p);
diff --git a/drivers/usb/serial/ti_usb_3410_5052.h b/drivers/usb/serial/ti_usb_3410_5052.h
index f323c602585..2aac1953993 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.h
+++ b/drivers/usb/serial/ti_usb_3410_5052.h
@@ -45,6 +45,9 @@
45#define MTS_CDMA_PRODUCT_ID 0xF110 45#define MTS_CDMA_PRODUCT_ID 0xF110
46#define MTS_GSM_PRODUCT_ID 0xF111 46#define MTS_GSM_PRODUCT_ID 0xF111
47#define MTS_EDGE_PRODUCT_ID 0xF112 47#define MTS_EDGE_PRODUCT_ID 0xF112
48#define MTS_MT9234MU_PRODUCT_ID 0xF114
49#define MTS_MT9234ZBA_PRODUCT_ID 0xF115
50#define MTS_MT9234ZBAOLD_PRODUCT_ID 0x0319
48 51
49/* Commands */ 52/* Commands */
50#define TI_GET_VERSION 0x01 53#define TI_GET_VERSION 0x01
diff --git a/drivers/usb/serial/usb_debug.c b/drivers/usb/serial/usb_debug.c
index 252cc2d993b..28026b47344 100644
--- a/drivers/usb/serial/usb_debug.c
+++ b/drivers/usb/serial/usb_debug.c
@@ -8,6 +8,7 @@
8 * 2 as published by the Free Software Foundation. 8 * 2 as published by the Free Software Foundation.
9 */ 9 */
10 10
11#include <linux/gfp.h>
11#include <linux/kernel.h> 12#include <linux/kernel.h>
12#include <linux/init.h> 13#include <linux/init.h>
13#include <linux/tty.h> 14#include <linux/tty.h>
diff --git a/drivers/usb/storage/alauda.c b/drivers/usb/storage/alauda.c
index 67edc65acb8..42d0eaed4a0 100644
--- a/drivers/usb/storage/alauda.c
+++ b/drivers/usb/storage/alauda.c
@@ -32,6 +32,7 @@
32 */ 32 */
33 33
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/slab.h>
35 36
36#include <scsi/scsi.h> 37#include <scsi/scsi.h>
37#include <scsi/scsi_cmnd.h> 38#include <scsi/scsi_cmnd.h>
diff --git a/drivers/usb/storage/karma.c b/drivers/usb/storage/karma.c
index 7953d93a773..ba1b7890688 100644
--- a/drivers/usb/storage/karma.c
+++ b/drivers/usb/storage/karma.c
@@ -19,6 +19,7 @@
19 */ 19 */
20 20
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/slab.h>
22 23
23#include <scsi/scsi.h> 24#include <scsi/scsi.h>
24#include <scsi/scsi_cmnd.h> 25#include <scsi/scsi_cmnd.h>
diff --git a/drivers/usb/storage/option_ms.c b/drivers/usb/storage/option_ms.c
index 773a5cd38c5..89460181d12 100644
--- a/drivers/usb/storage/option_ms.c
+++ b/drivers/usb/storage/option_ms.c
@@ -21,6 +21,7 @@
21 */ 21 */
22 22
23#include <linux/usb.h> 23#include <linux/usb.h>
24#include <linux/slab.h>
24 25
25#include "usb.h" 26#include "usb.h"
26#include "transport.h" 27#include "transport.h"
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 4cc035562cc..d8d98cfecad 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -43,7 +43,6 @@
43 * 675 Mass Ave, Cambridge, MA 02139, USA. 43 * 675 Mass Ave, Cambridge, MA 02139, USA.
44 */ 44 */
45 45
46#include <linux/slab.h>
47#include <linux/module.h> 46#include <linux/module.h>
48#include <linux/mutex.h> 47#include <linux/mutex.h>
49 48
diff --git a/drivers/usb/storage/sierra_ms.c b/drivers/usb/storage/sierra_ms.c
index 4395c4100ec..57fc2f532ca 100644
--- a/drivers/usb/storage/sierra_ms.c
+++ b/drivers/usb/storage/sierra_ms.c
@@ -3,6 +3,7 @@
3#include <scsi/scsi_cmnd.h> 3#include <scsi/scsi_cmnd.h>
4#include <scsi/scsi_device.h> 4#include <scsi/scsi_device.h>
5#include <linux/usb.h> 5#include <linux/usb.h>
6#include <linux/slab.h>
6 7
7#include "usb.h" 8#include "usb.h"
8#include "transport.h" 9#include "transport.h"
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index 468038126e5..f253edec3bb 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -44,8 +44,8 @@
44 */ 44 */
45 45
46#include <linux/sched.h> 46#include <linux/sched.h>
47#include <linux/gfp.h>
47#include <linux/errno.h> 48#include <linux/errno.h>
48#include <linux/slab.h>
49 49
50#include <linux/usb/quirks.h> 50#include <linux/usb/quirks.h>
51 51
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 98b549b1cab..ccf1dbbb87e 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -374,6 +374,15 @@ UNUSUAL_DEV( 0x04ce, 0x0002, 0x0074, 0x0074,
374 US_SC_DEVICE, US_PR_DEVICE, NULL, 374 US_SC_DEVICE, US_PR_DEVICE, NULL,
375 US_FL_FIX_INQUIRY), 375 US_FL_FIX_INQUIRY),
376 376
377/* Reported by Ondrej Zary <linux@rainbow-software.org>
378 * The device reports one sector more and breaks when that sector is accessed
379 */
380UNUSUAL_DEV( 0x04ce, 0x0002, 0x026c, 0x026c,
381 "ScanLogic",
382 "SL11R-IDE",
383 US_SC_DEVICE, US_PR_DEVICE, NULL,
384 US_FL_FIX_CAPACITY),
385
377/* Reported by Kriston Fincher <kriston@airmail.net> 386/* Reported by Kriston Fincher <kriston@airmail.net>
378 * Patch submitted by Sean Millichamp <sean@bruenor.org> 387 * Patch submitted by Sean Millichamp <sean@bruenor.org>
379 * This is to support the Panasonic PalmCam PV-SD4090 388 * This is to support the Panasonic PalmCam PV-SD4090
@@ -1380,20 +1389,6 @@ UNUSUAL_DEV( 0x0f19, 0x0105, 0x0100, 0x0100,
1380 US_SC_DEVICE, US_PR_DEVICE, NULL, 1389 US_SC_DEVICE, US_PR_DEVICE, NULL,
1381 US_FL_IGNORE_RESIDUE ), 1390 US_FL_IGNORE_RESIDUE ),
1382 1391
1383/* Jeremy Katz <katzj@redhat.com>:
1384 * The Blackberry Pearl can run in two modes; a usb-storage only mode
1385 * and a mode that allows access via mass storage and to its database.
1386 * The berry_charge module will set the device to dual mode and thus we
1387 * should ignore its native mode if that module is built
1388 */
1389#ifdef CONFIG_USB_BERRY_CHARGE
1390UNUSUAL_DEV( 0x0fca, 0x0006, 0x0001, 0x0001,
1391 "RIM",
1392 "Blackberry Pearl",
1393 US_SC_DEVICE, US_PR_DEVICE, NULL,
1394 US_FL_IGNORE_DEVICE ),
1395#endif
1396
1397/* Reported by Michael Stattmann <michael@stattmann.com> */ 1392/* Reported by Michael Stattmann <michael@stattmann.com> */
1398UNUSUAL_DEV( 0x0fce, 0xd008, 0x0000, 0x0000, 1393UNUSUAL_DEV( 0x0fce, 0xd008, 0x0000, 0x0000,
1399 "Sony Ericsson", 1394 "Sony Ericsson",
diff --git a/drivers/usb/wusbcore/cbaf.c b/drivers/usb/wusbcore/cbaf.c
index 51a8e0d5789..c0c5665e60a 100644
--- a/drivers/usb/wusbcore/cbaf.c
+++ b/drivers/usb/wusbcore/cbaf.c
@@ -92,6 +92,7 @@
92#include <linux/interrupt.h> 92#include <linux/interrupt.h>
93#include <linux/delay.h> 93#include <linux/delay.h>
94#include <linux/random.h> 94#include <linux/random.h>
95#include <linux/slab.h>
95#include <linux/mutex.h> 96#include <linux/mutex.h>
96#include <linux/uwb.h> 97#include <linux/uwb.h>
97#include <linux/usb/wusb.h> 98#include <linux/usb/wusb.h>
diff --git a/drivers/usb/wusbcore/crypto.c b/drivers/usb/wusbcore/crypto.c
index 9579cf4c38b..827c87f10cc 100644
--- a/drivers/usb/wusbcore/crypto.c
+++ b/drivers/usb/wusbcore/crypto.c
@@ -49,6 +49,7 @@
49#include <linux/module.h> 49#include <linux/module.h>
50#include <linux/err.h> 50#include <linux/err.h>
51#include <linux/uwb.h> 51#include <linux/uwb.h>
52#include <linux/slab.h>
52#include <linux/usb/wusb.h> 53#include <linux/usb/wusb.h>
53#include <linux/scatterlist.h> 54#include <linux/scatterlist.h>
54 55
diff --git a/drivers/usb/wusbcore/devconnect.c b/drivers/usb/wusbcore/devconnect.c
index 1c918286159..7ec24e46b34 100644
--- a/drivers/usb/wusbcore/devconnect.c
+++ b/drivers/usb/wusbcore/devconnect.c
@@ -88,6 +88,7 @@
88 88
89#include <linux/jiffies.h> 89#include <linux/jiffies.h>
90#include <linux/ctype.h> 90#include <linux/ctype.h>
91#include <linux/slab.h>
91#include <linux/workqueue.h> 92#include <linux/workqueue.h>
92#include "wusbhc.h" 93#include "wusbhc.h"
93 94
@@ -437,7 +438,7 @@ static void __wusbhc_keep_alive(struct wusbhc *wusbhc)
437 old_keep_alives = ie->hdr.bLength - sizeof(ie->hdr); 438 old_keep_alives = ie->hdr.bLength - sizeof(ie->hdr);
438 keep_alives = 0; 439 keep_alives = 0;
439 for (cnt = 0; 440 for (cnt = 0;
440 keep_alives <= WUIE_ELT_MAX && cnt < wusbhc->ports_max; 441 keep_alives < WUIE_ELT_MAX && cnt < wusbhc->ports_max;
441 cnt++) { 442 cnt++) {
442 unsigned tt = msecs_to_jiffies(wusbhc->trust_timeout); 443 unsigned tt = msecs_to_jiffies(wusbhc->trust_timeout);
443 444
diff --git a/drivers/usb/wusbcore/mmc.c b/drivers/usb/wusbcore/mmc.c
index 2d827397e30..0a57ff0a0b0 100644
--- a/drivers/usb/wusbcore/mmc.c
+++ b/drivers/usb/wusbcore/mmc.c
@@ -37,6 +37,7 @@
37 * - add timers that autoremove intervalled IEs? 37 * - add timers that autoremove intervalled IEs?
38 */ 38 */
39#include <linux/usb/wusb.h> 39#include <linux/usb/wusb.h>
40#include <linux/slab.h>
40#include "wusbhc.h" 41#include "wusbhc.h"
41 42
42/* Initialize the MMCIEs handling mechanism */ 43/* Initialize the MMCIEs handling mechanism */
diff --git a/drivers/usb/wusbcore/rh.c b/drivers/usb/wusbcore/rh.c
index 9fe4246cecb..a68ad7aa0b5 100644
--- a/drivers/usb/wusbcore/rh.c
+++ b/drivers/usb/wusbcore/rh.c
@@ -69,6 +69,7 @@
69 * 69 *
70 * wusbhc_rh_start_port_reset() ??? unimplemented 70 * wusbhc_rh_start_port_reset() ??? unimplemented
71 */ 71 */
72#include <linux/slab.h>
72#include "wusbhc.h" 73#include "wusbhc.h"
73 74
74/* 75/*
diff --git a/drivers/usb/wusbcore/security.c b/drivers/usb/wusbcore/security.c
index edcd2d75603..b60799b811c 100644
--- a/drivers/usb/wusbcore/security.c
+++ b/drivers/usb/wusbcore/security.c
@@ -23,6 +23,7 @@
23 * FIXME: docs 23 * FIXME: docs
24 */ 24 */
25#include <linux/types.h> 25#include <linux/types.h>
26#include <linux/slab.h>
26#include <linux/usb/ch9.h> 27#include <linux/usb/ch9.h>
27#include <linux/random.h> 28#include <linux/random.h>
28#include "wusbhc.h" 29#include "wusbhc.h"
diff --git a/drivers/usb/wusbcore/wa-hc.c b/drivers/usb/wusbcore/wa-hc.c
index 9d04722415b..59a748a0e5d 100644
--- a/drivers/usb/wusbcore/wa-hc.c
+++ b/drivers/usb/wusbcore/wa-hc.c
@@ -22,6 +22,7 @@
22 * 22 *
23 * FIXME: docs 23 * FIXME: docs
24 */ 24 */
25#include <linux/slab.h>
25#include "wusbhc.h" 26#include "wusbhc.h"
26#include "wa-hc.h" 27#include "wa-hc.h"
27 28
diff --git a/drivers/usb/wusbcore/wa-nep.c b/drivers/usb/wusbcore/wa-nep.c
index 17d2626038b..f67f7f1e6df 100644
--- a/drivers/usb/wusbcore/wa-nep.c
+++ b/drivers/usb/wusbcore/wa-nep.c
@@ -51,6 +51,7 @@
51 */ 51 */
52#include <linux/workqueue.h> 52#include <linux/workqueue.h>
53#include <linux/ctype.h> 53#include <linux/ctype.h>
54#include <linux/slab.h>
54 55
55#include "wa-hc.h" 56#include "wa-hc.h"
56#include "wusbhc.h" 57#include "wusbhc.h"
diff --git a/drivers/usb/wusbcore/wa-rpipe.c b/drivers/usb/wusbcore/wa-rpipe.c
index 7369655f69c..c7b1d8108de 100644
--- a/drivers/usb/wusbcore/wa-rpipe.c
+++ b/drivers/usb/wusbcore/wa-rpipe.c
@@ -60,6 +60,7 @@
60#include <linux/init.h> 60#include <linux/init.h>
61#include <asm/atomic.h> 61#include <asm/atomic.h>
62#include <linux/bitmap.h> 62#include <linux/bitmap.h>
63#include <linux/slab.h>
63 64
64#include "wusbhc.h" 65#include "wusbhc.h"
65#include "wa-hc.h" 66#include "wa-hc.h"
diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
index 489b47833e2..112ef7e26f6 100644
--- a/drivers/usb/wusbcore/wa-xfer.c
+++ b/drivers/usb/wusbcore/wa-xfer.c
@@ -81,6 +81,7 @@
81 */ 81 */
82#include <linux/init.h> 82#include <linux/init.h>
83#include <linux/spinlock.h> 83#include <linux/spinlock.h>
84#include <linux/slab.h>
84#include <linux/hash.h> 85#include <linux/hash.h>
85 86
86#include "wa-hc.h" 87#include "wa-hc.h"
diff --git a/drivers/uwb/address.c b/drivers/uwb/address.c
index ad21b1d7218..973321327c4 100644
--- a/drivers/uwb/address.c
+++ b/drivers/uwb/address.c
@@ -23,6 +23,7 @@
23 * FIXME: docs 23 * FIXME: docs
24 */ 24 */
25 25
26#include <linux/slab.h>
26#include <linux/errno.h> 27#include <linux/errno.h>
27#include <linux/module.h> 28#include <linux/module.h>
28#include <linux/device.h> 29#include <linux/device.h>
diff --git a/drivers/uwb/allocator.c b/drivers/uwb/allocator.c
index c13cec7dcbc..436e4f7110c 100644
--- a/drivers/uwb/allocator.c
+++ b/drivers/uwb/allocator.c
@@ -16,6 +16,7 @@
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 17 */
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/slab.h>
19#include <linux/uwb.h> 20#include <linux/uwb.h>
20 21
21#include "uwb-internal.h" 22#include "uwb-internal.h"
diff --git a/drivers/uwb/beacon.c b/drivers/uwb/beacon.c
index 36bc3158006..dcdd59bfcd0 100644
--- a/drivers/uwb/beacon.c
+++ b/drivers/uwb/beacon.c
@@ -28,6 +28,7 @@
28#include <linux/device.h> 28#include <linux/device.h>
29#include <linux/err.h> 29#include <linux/err.h>
30#include <linux/kdev_t.h> 30#include <linux/kdev_t.h>
31#include <linux/slab.h>
31 32
32#include "uwb-internal.h" 33#include "uwb-internal.h"
33 34
diff --git a/drivers/uwb/drp-ie.c b/drivers/uwb/drp-ie.c
index 2840d7bf9e6..520673109a7 100644
--- a/drivers/uwb/drp-ie.c
+++ b/drivers/uwb/drp-ie.c
@@ -18,6 +18,7 @@
18 */ 18 */
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/random.h> 20#include <linux/random.h>
21#include <linux/slab.h>
21#include <linux/uwb.h> 22#include <linux/uwb.h>
22 23
23#include "uwb-internal.h" 24#include "uwb-internal.h"
diff --git a/drivers/uwb/drp.c b/drivers/uwb/drp.c
index 4f5ca99a04b..a8d83e25e3b 100644
--- a/drivers/uwb/drp.c
+++ b/drivers/uwb/drp.c
@@ -20,6 +20,7 @@
20 */ 20 */
21#include <linux/kthread.h> 21#include <linux/kthread.h>
22#include <linux/freezer.h> 22#include <linux/freezer.h>
23#include <linux/slab.h>
23#include <linux/delay.h> 24#include <linux/delay.h>
24#include "uwb-internal.h" 25#include "uwb-internal.h"
25 26
diff --git a/drivers/uwb/est.c b/drivers/uwb/est.c
index 328fcc2b609..a2eaa3c33b0 100644
--- a/drivers/uwb/est.c
+++ b/drivers/uwb/est.c
@@ -40,6 +40,7 @@
40 * uwb_est_get_size() 40 * uwb_est_get_size()
41 */ 41 */
42#include <linux/spinlock.h> 42#include <linux/spinlock.h>
43#include <linux/slab.h>
43 44
44#include "uwb-internal.h" 45#include "uwb-internal.h"
45 46
diff --git a/drivers/uwb/hwa-rc.c b/drivers/uwb/hwa-rc.c
index e7eeb63fab2..2babcd4fbfc 100644
--- a/drivers/uwb/hwa-rc.c
+++ b/drivers/uwb/hwa-rc.c
@@ -53,6 +53,7 @@
53 */ 53 */
54#include <linux/init.h> 54#include <linux/init.h>
55#include <linux/module.h> 55#include <linux/module.h>
56#include <linux/slab.h>
56#include <linux/usb.h> 57#include <linux/usb.h>
57#include <linux/usb/wusb.h> 58#include <linux/usb/wusb.h>
58#include <linux/usb/wusb-wa.h> 59#include <linux/usb/wusb-wa.h>
@@ -891,7 +892,7 @@ static int hwarc_post_reset(struct usb_interface *iface)
891} 892}
892 893
893/** USB device ID's that we handle */ 894/** USB device ID's that we handle */
894static struct usb_device_id hwarc_id_table[] = { 895static const struct usb_device_id hwarc_id_table[] = {
895 /* D-Link DUB-1210 */ 896 /* D-Link DUB-1210 */
896 { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3d02, 0xe0, 0x01, 0x02), 897 { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3d02, 0xe0, 0x01, 0x02),
897 .driver_info = WUSB_QUIRK_WHCI_CMD_EVT }, 898 .driver_info = WUSB_QUIRK_WHCI_CMD_EVT },
diff --git a/drivers/uwb/i1480/dfu/mac.c b/drivers/uwb/i1480/dfu/mac.c
index 694d0daf88a..6ec14f5fcde 100644
--- a/drivers/uwb/i1480/dfu/mac.c
+++ b/drivers/uwb/i1480/dfu/mac.c
@@ -28,6 +28,7 @@
28 */ 28 */
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/firmware.h> 30#include <linux/firmware.h>
31#include <linux/slab.h>
31#include <linux/uwb.h> 32#include <linux/uwb.h>
32#include "i1480-dfu.h" 33#include "i1480-dfu.h"
33 34
diff --git a/drivers/uwb/i1480/dfu/usb.c b/drivers/uwb/i1480/dfu/usb.c
index 0bb665a0c02..ba8664328af 100644
--- a/drivers/uwb/i1480/dfu/usb.c
+++ b/drivers/uwb/i1480/dfu/usb.c
@@ -37,6 +37,7 @@
37#include <linux/module.h> 37#include <linux/module.h>
38#include <linux/usb.h> 38#include <linux/usb.h>
39#include <linux/interrupt.h> 39#include <linux/interrupt.h>
40#include <linux/slab.h>
40#include <linux/delay.h> 41#include <linux/delay.h>
41#include <linux/uwb.h> 42#include <linux/uwb.h>
42#include <linux/usb/wusb.h> 43#include <linux/usb/wusb.h>
@@ -120,8 +121,7 @@ int i1480_usb_write(struct i1480 *i1480, u32 memory_address,
120 result = usb_control_msg( 121 result = usb_control_msg(
121 i1480_usb->usb_dev, usb_sndctrlpipe(i1480_usb->usb_dev, 0), 122 i1480_usb->usb_dev, usb_sndctrlpipe(i1480_usb->usb_dev, 0),
122 0xf0, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 123 0xf0, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
123 cpu_to_le16(memory_address & 0xffff), 124 memory_address, (memory_address >> 16),
124 cpu_to_le16((memory_address >> 16) & 0xffff),
125 i1480->cmd_buf, buffer_size, 100 /* FIXME: arbitrary */); 125 i1480->cmd_buf, buffer_size, 100 /* FIXME: arbitrary */);
126 if (result < 0) 126 if (result < 0)
127 break; 127 break;
@@ -166,8 +166,7 @@ int i1480_usb_read(struct i1480 *i1480, u32 addr, size_t size)
166 result = usb_control_msg( 166 result = usb_control_msg(
167 i1480_usb->usb_dev, usb_rcvctrlpipe(i1480_usb->usb_dev, 0), 167 i1480_usb->usb_dev, usb_rcvctrlpipe(i1480_usb->usb_dev, 0),
168 0xf0, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 168 0xf0, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
169 cpu_to_le16(itr_addr & 0xffff), 169 itr_addr, (itr_addr >> 16),
170 cpu_to_le16((itr_addr >> 16) & 0xffff),
171 i1480->cmd_buf + itr, itr_size, 170 i1480->cmd_buf + itr, itr_size,
172 100 /* FIXME: arbitrary */); 171 100 /* FIXME: arbitrary */);
173 if (result < 0) { 172 if (result < 0) {
@@ -413,6 +412,10 @@ error:
413 return result; 412 return result;
414} 413}
415 414
415MODULE_FIRMWARE("i1480-pre-phy-0.0.bin");
416MODULE_FIRMWARE("i1480-usb-0.0.bin");
417MODULE_FIRMWARE("i1480-phy-0.0.bin");
418
416#define i1480_USB_DEV(v, p) \ 419#define i1480_USB_DEV(v, p) \
417{ \ 420{ \
418 .match_flags = USB_DEVICE_ID_MATCH_DEVICE \ 421 .match_flags = USB_DEVICE_ID_MATCH_DEVICE \
@@ -430,7 +433,7 @@ error:
430 433
431 434
432/** USB device ID's that we handle */ 435/** USB device ID's that we handle */
433static struct usb_device_id i1480_usb_id_table[] = { 436static const struct usb_device_id i1480_usb_id_table[] = {
434 i1480_USB_DEV(0x8086, 0xdf3b), 437 i1480_USB_DEV(0x8086, 0xdf3b),
435 i1480_USB_DEV(0x15a9, 0x0005), 438 i1480_USB_DEV(0x15a9, 0x0005),
436 i1480_USB_DEV(0x07d1, 0x3802), 439 i1480_USB_DEV(0x07d1, 0x3802),
diff --git a/drivers/uwb/i1480/i1480u-wlp/lc.c b/drivers/uwb/i1480/i1480u-wlp/lc.c
index f272dfe54d4..def778cf221 100644
--- a/drivers/uwb/i1480/i1480u-wlp/lc.c
+++ b/drivers/uwb/i1480/i1480u-wlp/lc.c
@@ -55,6 +55,7 @@
55 * is being removed. 55 * is being removed.
56 * i1480u_rm() 56 * i1480u_rm()
57 */ 57 */
58#include <linux/gfp.h>
58#include <linux/if_arp.h> 59#include <linux/if_arp.h>
59#include <linux/etherdevice.h> 60#include <linux/etherdevice.h>
60 61
diff --git a/drivers/uwb/i1480/i1480u-wlp/netdev.c b/drivers/uwb/i1480/i1480u-wlp/netdev.c
index b236e696994..f98f6ce8b9e 100644
--- a/drivers/uwb/i1480/i1480u-wlp/netdev.c
+++ b/drivers/uwb/i1480/i1480u-wlp/netdev.c
@@ -39,6 +39,7 @@
39 * i1480u_set_config(): 39 * i1480u_set_config():
40 */ 40 */
41 41
42#include <linux/slab.h>
42#include <linux/if_arp.h> 43#include <linux/if_arp.h>
43#include <linux/etherdevice.h> 44#include <linux/etherdevice.h>
44 45
diff --git a/drivers/uwb/i1480/i1480u-wlp/rx.c b/drivers/uwb/i1480/i1480u-wlp/rx.c
index 25a2758beb6..d4e51e108aa 100644
--- a/drivers/uwb/i1480/i1480u-wlp/rx.c
+++ b/drivers/uwb/i1480/i1480u-wlp/rx.c
@@ -64,6 +64,7 @@
64 * 64 *
65 */ 65 */
66 66
67#include <linux/gfp.h>
67#include <linux/netdevice.h> 68#include <linux/netdevice.h>
68#include <linux/etherdevice.h> 69#include <linux/etherdevice.h>
69#include "i1480u-wlp.h" 70#include "i1480u-wlp.h"
diff --git a/drivers/uwb/i1480/i1480u-wlp/tx.c b/drivers/uwb/i1480/i1480u-wlp/tx.c
index 3db3449dbda..3c117a36456 100644
--- a/drivers/uwb/i1480/i1480u-wlp/tx.c
+++ b/drivers/uwb/i1480/i1480u-wlp/tx.c
@@ -54,6 +54,7 @@
54 * the times the MTU will be smaller than one page... 54 * the times the MTU will be smaller than one page...
55 */ 55 */
56 56
57#include <linux/slab.h>
57#include "i1480u-wlp.h" 58#include "i1480u-wlp.h"
58 59
59enum { 60enum {
diff --git a/drivers/uwb/ie.c b/drivers/uwb/ie.c
index ab976686175..30acec74042 100644
--- a/drivers/uwb/ie.c
+++ b/drivers/uwb/ie.c
@@ -24,6 +24,7 @@
24 * FIXME: docs 24 * FIXME: docs
25 */ 25 */
26 26
27#include <linux/slab.h>
27#include "uwb-internal.h" 28#include "uwb-internal.h"
28 29
29/** 30/**
diff --git a/drivers/uwb/lc-dev.c b/drivers/uwb/lc-dev.c
index 1097e81b56d..90113bafefc 100644
--- a/drivers/uwb/lc-dev.c
+++ b/drivers/uwb/lc-dev.c
@@ -23,6 +23,7 @@
23 * FIXME: docs 23 * FIXME: docs
24 */ 24 */
25#include <linux/kernel.h> 25#include <linux/kernel.h>
26#include <linux/slab.h>
26#include <linux/device.h> 27#include <linux/device.h>
27#include <linux/err.h> 28#include <linux/err.h>
28#include <linux/kdev_t.h> 29#include <linux/kdev_t.h>
diff --git a/drivers/uwb/lc-rc.c b/drivers/uwb/lc-rc.c
index 9611ef3b787..b0091c771b9 100644
--- a/drivers/uwb/lc-rc.c
+++ b/drivers/uwb/lc-rc.c
@@ -35,6 +35,7 @@
35#include <linux/kdev_t.h> 35#include <linux/kdev_t.h>
36#include <linux/etherdevice.h> 36#include <linux/etherdevice.h>
37#include <linux/usb.h> 37#include <linux/usb.h>
38#include <linux/slab.h>
38 39
39#include "uwb-internal.h" 40#include "uwb-internal.h"
40 41
diff --git a/drivers/uwb/neh.c b/drivers/uwb/neh.c
index 78510a1f410..697e56a5bcd 100644
--- a/drivers/uwb/neh.c
+++ b/drivers/uwb/neh.c
@@ -83,6 +83,7 @@
83 */ 83 */
84#include <linux/kernel.h> 84#include <linux/kernel.h>
85#include <linux/timer.h> 85#include <linux/timer.h>
86#include <linux/slab.h>
86#include <linux/err.h> 87#include <linux/err.h>
87 88
88#include "uwb-internal.h" 89#include "uwb-internal.h"
diff --git a/drivers/uwb/reset.c b/drivers/uwb/reset.c
index 7f0512e43d9..27849292b55 100644
--- a/drivers/uwb/reset.c
+++ b/drivers/uwb/reset.c
@@ -30,6 +30,7 @@
30 */ 30 */
31#include <linux/kernel.h> 31#include <linux/kernel.h>
32#include <linux/err.h> 32#include <linux/err.h>
33#include <linux/slab.h>
33#include <linux/delay.h> 34#include <linux/delay.h>
34 35
35#include "uwb-internal.h" 36#include "uwb-internal.h"
diff --git a/drivers/uwb/rsv.c b/drivers/uwb/rsv.c
index 6b76f4bb4cc..78c892233cf 100644
--- a/drivers/uwb/rsv.c
+++ b/drivers/uwb/rsv.c
@@ -17,6 +17,7 @@
17 */ 17 */
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/uwb.h> 19#include <linux/uwb.h>
20#include <linux/slab.h>
20#include <linux/random.h> 21#include <linux/random.h>
21 22
22#include "uwb-internal.h" 23#include "uwb-internal.h"
diff --git a/drivers/uwb/scan.c b/drivers/uwb/scan.c
index 2d270748f32..76a1a1ed7d3 100644
--- a/drivers/uwb/scan.c
+++ b/drivers/uwb/scan.c
@@ -35,6 +35,7 @@
35 35
36#include <linux/device.h> 36#include <linux/device.h>
37#include <linux/err.h> 37#include <linux/err.h>
38#include <linux/slab.h>
38#include "uwb-internal.h" 39#include "uwb-internal.h"
39 40
40 41
diff --git a/drivers/uwb/umc-dev.c b/drivers/uwb/umc-dev.c
index 1fc7d8270bb..43ea9982e68 100644
--- a/drivers/uwb/umc-dev.c
+++ b/drivers/uwb/umc-dev.c
@@ -6,6 +6,7 @@
6 * This file is released under the GNU GPL v2. 6 * This file is released under the GNU GPL v2.
7 */ 7 */
8#include <linux/kernel.h> 8#include <linux/kernel.h>
9#include <linux/slab.h>
9#include <linux/uwb/umc.h> 10#include <linux/uwb/umc.h>
10 11
11static void umc_device_release(struct device *dev) 12static void umc_device_release(struct device *dev)
diff --git a/drivers/uwb/uwbd.c b/drivers/uwb/uwbd.c
index 6210fe1fd1b..001c8b4020a 100644
--- a/drivers/uwb/uwbd.c
+++ b/drivers/uwb/uwbd.c
@@ -69,6 +69,7 @@
69 * Handler functions are called normally uwbd_evt_handle_*(). 69 * Handler functions are called normally uwbd_evt_handle_*().
70 */ 70 */
71#include <linux/kthread.h> 71#include <linux/kthread.h>
72#include <linux/slab.h>
72#include <linux/module.h> 73#include <linux/module.h>
73#include <linux/freezer.h> 74#include <linux/freezer.h>
74 75
diff --git a/drivers/uwb/whc-rc.c b/drivers/uwb/whc-rc.c
index 01950c62dc8..73495583c44 100644
--- a/drivers/uwb/whc-rc.c
+++ b/drivers/uwb/whc-rc.c
@@ -45,6 +45,7 @@
45#include <linux/sched.h> 45#include <linux/sched.h>
46#include <linux/dma-mapping.h> 46#include <linux/dma-mapping.h>
47#include <linux/interrupt.h> 47#include <linux/interrupt.h>
48#include <linux/slab.h>
48#include <linux/workqueue.h> 49#include <linux/workqueue.h>
49#include <linux/uwb.h> 50#include <linux/uwb.h>
50#include <linux/uwb/whci.h> 51#include <linux/uwb/whci.h>
diff --git a/drivers/uwb/whci.c b/drivers/uwb/whci.c
index 2e2784627ad..b221142446a 100644
--- a/drivers/uwb/whci.c
+++ b/drivers/uwb/whci.c
@@ -9,6 +9,7 @@
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/pci.h> 10#include <linux/pci.h>
11#include <linux/dma-mapping.h> 11#include <linux/dma-mapping.h>
12#include <linux/slab.h>
12#include <linux/uwb/whci.h> 13#include <linux/uwb/whci.h>
13#include <linux/uwb/umc.h> 14#include <linux/uwb/umc.h>
14 15
diff --git a/drivers/uwb/wlp/eda.c b/drivers/uwb/wlp/eda.c
index 69e02003971..086fc0cf940 100644
--- a/drivers/uwb/wlp/eda.c
+++ b/drivers/uwb/wlp/eda.c
@@ -53,6 +53,7 @@
53 53
54#include <linux/netdevice.h> 54#include <linux/netdevice.h>
55#include <linux/etherdevice.h> 55#include <linux/etherdevice.h>
56#include <linux/slab.h>
56#include <linux/wlp.h> 57#include <linux/wlp.h>
57#include "wlp-internal.h" 58#include "wlp-internal.h"
58 59
diff --git a/drivers/uwb/wlp/messages.c b/drivers/uwb/wlp/messages.c
index aa42fcee4c4..3a8e033dce2 100644
--- a/drivers/uwb/wlp/messages.c
+++ b/drivers/uwb/wlp/messages.c
@@ -24,6 +24,7 @@
24 */ 24 */
25 25
26#include <linux/wlp.h> 26#include <linux/wlp.h>
27#include <linux/slab.h>
27 28
28#include "wlp-internal.h" 29#include "wlp-internal.h"
29 30
@@ -259,6 +260,63 @@ out:
259} 260}
260 261
261 262
263static ssize_t wlp_get_attribute(struct wlp *wlp, u16 type_code,
264 struct wlp_attr_hdr *attr_hdr, void *value, ssize_t value_len,
265 ssize_t buflen)
266{
267 struct device *dev = &wlp->rc->uwb_dev.dev;
268 ssize_t attr_len = sizeof(*attr_hdr) + value_len;
269 if (buflen < 0)
270 return -EINVAL;
271 if (buflen < attr_len) {
272 dev_err(dev, "WLP: Not enough space in buffer to parse"
273 " attribute field. Need %d, received %zu\n",
274 (int)attr_len, buflen);
275 return -EIO;
276 }
277 if (wlp_check_attr_hdr(wlp, attr_hdr, type_code, value_len) < 0) {
278 dev_err(dev, "WLP: Header verification failed. \n");
279 return -EINVAL;
280 }
281 memcpy(value, (void *)attr_hdr + sizeof(*attr_hdr), value_len);
282 return attr_len;
283}
284
285static ssize_t wlp_vget_attribute(struct wlp *wlp, u16 type_code,
286 struct wlp_attr_hdr *attr_hdr, void *value, ssize_t max_value_len,
287 ssize_t buflen)
288{
289 struct device *dev = &wlp->rc->uwb_dev.dev;
290 size_t len;
291 if (buflen < 0)
292 return -EINVAL;
293 if (buflen < sizeof(*attr_hdr)) {
294 dev_err(dev, "WLP: Not enough space in buffer to parse"
295 " header.\n");
296 return -EIO;
297 }
298 if (le16_to_cpu(attr_hdr->type) != type_code) {
299 dev_err(dev, "WLP: Unexpected attribute type. Got %u, "
300 "expected %u.\n", le16_to_cpu(attr_hdr->type),
301 type_code);
302 return -EINVAL;
303 }
304 len = le16_to_cpu(attr_hdr->length);
305 if (len > max_value_len) {
306 dev_err(dev, "WLP: Attribute larger than maximum "
307 "allowed. Received %zu, max is %d.\n", len,
308 (int)max_value_len);
309 return -EFBIG;
310 }
311 if (buflen < sizeof(*attr_hdr) + len) {
312 dev_err(dev, "WLP: Not enough space in buffer to parse "
313 "variable data.\n");
314 return -EIO;
315 }
316 memcpy(value, (void *)attr_hdr + sizeof(*attr_hdr), len);
317 return sizeof(*attr_hdr) + len;
318}
319
262/** 320/**
263 * Get value of attribute from fixed size attribute field. 321 * Get value of attribute from fixed size attribute field.
264 * 322 *
@@ -274,22 +332,8 @@ out:
274ssize_t wlp_get_##name(struct wlp *wlp, struct wlp_attr_##name *attr, \ 332ssize_t wlp_get_##name(struct wlp *wlp, struct wlp_attr_##name *attr, \
275 type *value, ssize_t buflen) \ 333 type *value, ssize_t buflen) \
276{ \ 334{ \
277 struct device *dev = &wlp->rc->uwb_dev.dev; \ 335 return wlp_get_attribute(wlp, (type_code), &attr->hdr, \
278 if (buflen < 0) \ 336 value, sizeof(*value), buflen); \
279 return -EINVAL; \
280 if (buflen < sizeof(*attr)) { \
281 dev_err(dev, "WLP: Not enough space in buffer to parse" \
282 " attribute field. Need %d, received %zu\n", \
283 (int)sizeof(*attr), buflen); \
284 return -EIO; \
285 } \
286 if (wlp_check_attr_hdr(wlp, &attr->hdr, type_code, \
287 sizeof(attr->name)) < 0) { \
288 dev_err(dev, "WLP: Header verification failed. \n"); \
289 return -EINVAL; \
290 } \
291 *value = attr->name; \
292 return sizeof(*attr); \
293} 337}
294 338
295#define wlp_get_sparse(type, type_code, name) \ 339#define wlp_get_sparse(type, type_code, name) \
@@ -313,35 +357,8 @@ static ssize_t wlp_get_##name(struct wlp *wlp, \
313 struct wlp_attr_##name *attr, \ 357 struct wlp_attr_##name *attr, \
314 type_val *value, ssize_t buflen) \ 358 type_val *value, ssize_t buflen) \
315{ \ 359{ \
316 struct device *dev = &wlp->rc->uwb_dev.dev; \ 360 return wlp_vget_attribute(wlp, (type_code), &attr->hdr, \
317 size_t len; \ 361 value, (max), buflen); \
318 if (buflen < 0) \
319 return -EINVAL; \
320 if (buflen < sizeof(*attr)) { \
321 dev_err(dev, "WLP: Not enough space in buffer to parse" \
322 " header.\n"); \
323 return -EIO; \
324 } \
325 if (le16_to_cpu(attr->hdr.type) != type_code) { \
326 dev_err(dev, "WLP: Unexpected attribute type. Got %u, " \
327 "expected %u.\n", le16_to_cpu(attr->hdr.type), \
328 type_code); \
329 return -EINVAL; \
330 } \
331 len = le16_to_cpu(attr->hdr.length); \
332 if (len > max) { \
333 dev_err(dev, "WLP: Attribute larger than maximum " \
334 "allowed. Received %zu, max is %d.\n", len, \
335 (int)max); \
336 return -EFBIG; \
337 } \
338 if (buflen < sizeof(*attr) + len) { \
339 dev_err(dev, "WLP: Not enough space in buffer to parse "\
340 "variable data.\n"); \
341 return -EIO; \
342 } \
343 memcpy(value, (void *) attr + sizeof(*attr), len); \
344 return sizeof(*attr) + len; \
345} 362}
346 363
347wlp_get(u8, WLP_ATTR_WLP_VER, version) 364wlp_get(u8, WLP_ATTR_WLP_VER, version)
diff --git a/drivers/uwb/wlp/txrx.c b/drivers/uwb/wlp/txrx.c
index 7350ed6909f..05dde44b359 100644
--- a/drivers/uwb/wlp/txrx.c
+++ b/drivers/uwb/wlp/txrx.c
@@ -25,6 +25,7 @@
25 */ 25 */
26 26
27#include <linux/etherdevice.h> 27#include <linux/etherdevice.h>
28#include <linux/slab.h>
28#include <linux/wlp.h> 29#include <linux/wlp.h>
29 30
30#include "wlp-internal.h" 31#include "wlp-internal.h"
diff --git a/drivers/uwb/wlp/wlp-lc.c b/drivers/uwb/wlp/wlp-lc.c
index 13db739c4e3..7f6a630bf26 100644
--- a/drivers/uwb/wlp/wlp-lc.c
+++ b/drivers/uwb/wlp/wlp-lc.c
@@ -22,6 +22,7 @@
22 * FIXME: docs 22 * FIXME: docs
23 */ 23 */
24#include <linux/wlp.h> 24#include <linux/wlp.h>
25#include <linux/slab.h>
25 26
26#include "wlp-internal.h" 27#include "wlp-internal.h"
27 28
diff --git a/drivers/uwb/wlp/wss-lc.c b/drivers/uwb/wlp/wss-lc.c
index 5913c7a5d92..90accdd54c0 100644
--- a/drivers/uwb/wlp/wss-lc.c
+++ b/drivers/uwb/wlp/wss-lc.c
@@ -45,6 +45,7 @@
45 */ 45 */
46#include <linux/etherdevice.h> /* for is_valid_ether_addr */ 46#include <linux/etherdevice.h> /* for is_valid_ether_addr */
47#include <linux/skbuff.h> 47#include <linux/skbuff.h>
48#include <linux/slab.h>
48#include <linux/wlp.h> 49#include <linux/wlp.h>
49 50
50#include "wlp-internal.h" 51#include "wlp-internal.h"
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index ad37da2b6cb..9777583218f 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -17,6 +17,7 @@
17#include <linux/workqueue.h> 17#include <linux/workqueue.h>
18#include <linux/rcupdate.h> 18#include <linux/rcupdate.h>
19#include <linux/file.h> 19#include <linux/file.h>
20#include <linux/slab.h>
20 21
21#include <linux/net.h> 22#include <linux/net.h>
22#include <linux/if_packet.h> 23#include <linux/if_packet.h>
@@ -125,7 +126,7 @@ static void handle_tx(struct vhost_net *net)
125 mutex_lock(&vq->mutex); 126 mutex_lock(&vq->mutex);
126 vhost_disable_notify(vq); 127 vhost_disable_notify(vq);
127 128
128 if (wmem < sock->sk->sk_sndbuf * 2) 129 if (wmem < sock->sk->sk_sndbuf / 2)
129 tx_poll_stop(net); 130 tx_poll_stop(net);
130 hdr_size = vq->hdr_size; 131 hdr_size = vq->hdr_size;
131 132
@@ -508,12 +509,12 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
508 /* Verify that ring has been setup correctly. */ 509 /* Verify that ring has been setup correctly. */
509 if (!vhost_vq_access_ok(vq)) { 510 if (!vhost_vq_access_ok(vq)) {
510 r = -EFAULT; 511 r = -EFAULT;
511 goto err; 512 goto err_vq;
512 } 513 }
513 sock = get_socket(fd); 514 sock = get_socket(fd);
514 if (IS_ERR(sock)) { 515 if (IS_ERR(sock)) {
515 r = PTR_ERR(sock); 516 r = PTR_ERR(sock);
516 goto err; 517 goto err_vq;
517 } 518 }
518 519
519 /* start polling new socket */ 520 /* start polling new socket */
@@ -524,12 +525,14 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
524 vhost_net_disable_vq(n, vq); 525 vhost_net_disable_vq(n, vq);
525 rcu_assign_pointer(vq->private_data, sock); 526 rcu_assign_pointer(vq->private_data, sock);
526 vhost_net_enable_vq(n, vq); 527 vhost_net_enable_vq(n, vq);
527 mutex_unlock(&vq->mutex);
528done: 528done:
529 if (oldsock) { 529 if (oldsock) {
530 vhost_net_flush_vq(n, index); 530 vhost_net_flush_vq(n, index);
531 fput(oldsock->file); 531 fput(oldsock->file);
532 } 532 }
533
534err_vq:
535 mutex_unlock(&vq->mutex);
533err: 536err:
534 mutex_unlock(&n->dev.mutex); 537 mutex_unlock(&n->dev.mutex);
535 return r; 538 return r;
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 7cd55e07879..e69d238c5af 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -22,6 +22,7 @@
22#include <linux/poll.h> 22#include <linux/poll.h>
23#include <linux/file.h> 23#include <linux/file.h>
24#include <linux/highmem.h> 24#include <linux/highmem.h>
25#include <linux/slab.h>
25 26
26#include <linux/net.h> 27#include <linux/net.h>
27#include <linux/if_packet.h> 28#include <linux/if_packet.h>
@@ -235,6 +236,10 @@ static int vq_memory_access_ok(void __user *log_base, struct vhost_memory *mem,
235 int log_all) 236 int log_all)
236{ 237{
237 int i; 238 int i;
239
240 if (!mem)
241 return 0;
242
238 for (i = 0; i < mem->nregions; ++i) { 243 for (i = 0; i < mem->nregions; ++i) {
239 struct vhost_memory_region *m = mem->regions + i; 244 struct vhost_memory_region *m = mem->regions + i;
240 unsigned long a = m->userspace_addr; 245 unsigned long a = m->userspace_addr;
@@ -476,8 +481,10 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
476 if (r < 0) 481 if (r < 0)
477 break; 482 break;
478 eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd); 483 eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
479 if (IS_ERR(eventfp)) 484 if (IS_ERR(eventfp)) {
480 return PTR_ERR(eventfp); 485 r = PTR_ERR(eventfp);
486 break;
487 }
481 if (eventfp != vq->kick) { 488 if (eventfp != vq->kick) {
482 pollstop = filep = vq->kick; 489 pollstop = filep = vq->kick;
483 pollstart = vq->kick = eventfp; 490 pollstart = vq->kick = eventfp;
@@ -489,8 +496,10 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
489 if (r < 0) 496 if (r < 0)
490 break; 497 break;
491 eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd); 498 eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
492 if (IS_ERR(eventfp)) 499 if (IS_ERR(eventfp)) {
493 return PTR_ERR(eventfp); 500 r = PTR_ERR(eventfp);
501 break;
502 }
494 if (eventfp != vq->call) { 503 if (eventfp != vq->call) {
495 filep = vq->call; 504 filep = vq->call;
496 ctx = vq->call_ctx; 505 ctx = vq->call_ctx;
@@ -505,8 +514,10 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
505 if (r < 0) 514 if (r < 0)
506 break; 515 break;
507 eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd); 516 eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
508 if (IS_ERR(eventfp)) 517 if (IS_ERR(eventfp)) {
509 return PTR_ERR(eventfp); 518 r = PTR_ERR(eventfp);
519 break;
520 }
510 if (eventfp != vq->error) { 521 if (eventfp != vq->error) {
511 filep = vq->error; 522 filep = vq->error;
512 vq->error = eventfp; 523 vq->error = eventfp;
diff --git a/drivers/video/68328fb.c b/drivers/video/68328fb.c
index 2110556f76b..75a39eab70c 100644
--- a/drivers/video/68328fb.c
+++ b/drivers/video/68328fb.c
@@ -32,7 +32,6 @@
32#include <linux/errno.h> 32#include <linux/errno.h>
33#include <linux/string.h> 33#include <linux/string.h>
34#include <linux/mm.h> 34#include <linux/mm.h>
35#include <linux/slab.h>
36#include <linux/vmalloc.h> 35#include <linux/vmalloc.h>
37#include <linux/delay.h> 36#include <linux/delay.h>
38#include <linux/interrupt.h> 37#include <linux/interrupt.h>
diff --git a/drivers/video/acornfb.c b/drivers/video/acornfb.c
index 43d7d506736..82acb8dc4aa 100644
--- a/drivers/video/acornfb.c
+++ b/drivers/video/acornfb.c
@@ -22,13 +22,13 @@
22#include <linux/errno.h> 22#include <linux/errno.h>
23#include <linux/string.h> 23#include <linux/string.h>
24#include <linux/ctype.h> 24#include <linux/ctype.h>
25#include <linux/slab.h>
26#include <linux/mm.h> 25#include <linux/mm.h>
27#include <linux/init.h> 26#include <linux/init.h>
28#include <linux/fb.h> 27#include <linux/fb.h>
29#include <linux/platform_device.h> 28#include <linux/platform_device.h>
30#include <linux/dma-mapping.h> 29#include <linux/dma-mapping.h>
31#include <linux/io.h> 30#include <linux/io.h>
31#include <linux/gfp.h>
32 32
33#include <mach/hardware.h> 33#include <mach/hardware.h>
34#include <asm/irq.h> 34#include <asm/irq.h>
diff --git a/drivers/video/amifb.c b/drivers/video/amifb.c
index 82bedd7f778..dca48df9844 100644
--- a/drivers/video/amifb.c
+++ b/drivers/video/amifb.c
@@ -45,7 +45,6 @@
45#include <linux/errno.h> 45#include <linux/errno.h>
46#include <linux/string.h> 46#include <linux/string.h>
47#include <linux/mm.h> 47#include <linux/mm.h>
48#include <linux/slab.h>
49#include <linux/delay.h> 48#include <linux/delay.h>
50#include <linux/interrupt.h> 49#include <linux/interrupt.h>
51#include <linux/fb.h> 50#include <linux/fb.h>
diff --git a/drivers/video/arcfb.c b/drivers/video/arcfb.c
index 01554d69652..8d406fb689c 100644
--- a/drivers/video/arcfb.c
+++ b/drivers/video/arcfb.c
@@ -39,7 +39,6 @@
39#include <linux/errno.h> 39#include <linux/errno.h>
40#include <linux/string.h> 40#include <linux/string.h>
41#include <linux/mm.h> 41#include <linux/mm.h>
42#include <linux/slab.h>
43#include <linux/vmalloc.h> 42#include <linux/vmalloc.h>
44#include <linux/delay.h> 43#include <linux/delay.h>
45#include <linux/interrupt.h> 44#include <linux/interrupt.h>
diff --git a/drivers/video/asiliantfb.c b/drivers/video/asiliantfb.c
index e70bc225fe3..8cdf88e20b4 100644
--- a/drivers/video/asiliantfb.c
+++ b/drivers/video/asiliantfb.c
@@ -34,7 +34,6 @@
34#include <linux/errno.h> 34#include <linux/errno.h>
35#include <linux/string.h> 35#include <linux/string.h>
36#include <linux/mm.h> 36#include <linux/mm.h>
37#include <linux/slab.h>
38#include <linux/vmalloc.h> 37#include <linux/vmalloc.h>
39#include <linux/delay.h> 38#include <linux/delay.h>
40#include <linux/interrupt.h> 39#include <linux/interrupt.h>
diff --git a/drivers/video/atafb.c b/drivers/video/atafb.c
index b7687c55fe1..f3aada20fa0 100644
--- a/drivers/video/atafb.c
+++ b/drivers/video/atafb.c
@@ -52,7 +52,6 @@
52#include <linux/errno.h> 52#include <linux/errno.h>
53#include <linux/string.h> 53#include <linux/string.h>
54#include <linux/mm.h> 54#include <linux/mm.h>
55#include <linux/slab.h>
56#include <linux/delay.h> 55#include <linux/delay.h>
57#include <linux/init.h> 56#include <linux/init.h>
58#include <linux/interrupt.h> 57#include <linux/interrupt.h>
diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c
index 11de3bfd4e5..8dce2512633 100644
--- a/drivers/video/atmel_lcdfb.c
+++ b/drivers/video/atmel_lcdfb.c
@@ -17,6 +17,7 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/backlight.h> 19#include <linux/backlight.h>
20#include <linux/gfp.h>
20 21
21#include <mach/board.h> 22#include <mach/board.h>
22#include <mach/cpu.h> 23#include <mach/cpu.h>
diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
index a489be0c461..34a0851bcbf 100644
--- a/drivers/video/aty/aty128fb.c
+++ b/drivers/video/aty/aty128fb.c
@@ -52,7 +52,6 @@
52#include <linux/errno.h> 52#include <linux/errno.h>
53#include <linux/string.h> 53#include <linux/string.h>
54#include <linux/mm.h> 54#include <linux/mm.h>
55#include <linux/slab.h>
56#include <linux/vmalloc.h> 55#include <linux/vmalloc.h>
57#include <linux/delay.h> 56#include <linux/delay.h>
58#include <linux/interrupt.h> 57#include <linux/interrupt.h>
diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
index 04c710804bb..2ba8b3c421a 100644
--- a/drivers/video/aty/mach64_cursor.c
+++ b/drivers/video/aty/mach64_cursor.c
@@ -2,7 +2,6 @@
2 * ATI Mach64 CT/VT/GT/LT Cursor Support 2 * ATI Mach64 CT/VT/GT/LT Cursor Support
3 */ 3 */
4 4
5#include <linux/slab.h>
6#include <linux/fb.h> 5#include <linux/fb.h>
7#include <linux/init.h> 6#include <linux/init.h>
8#include <linux/string.h> 7#include <linux/string.h>
diff --git a/drivers/video/aty/radeon_backlight.c b/drivers/video/aty/radeon_backlight.c
index 9fc8c66be3c..256966e9667 100644
--- a/drivers/video/aty/radeon_backlight.c
+++ b/drivers/video/aty/radeon_backlight.c
@@ -12,6 +12,7 @@
12 12
13#include "radeonfb.h" 13#include "radeonfb.h"
14#include <linux/backlight.h> 14#include <linux/backlight.h>
15#include <linux/slab.h>
15 16
16#ifdef CONFIG_PMAC_BACKLIGHT 17#ifdef CONFIG_PMAC_BACKLIGHT
17#include <asm/backlight.h> 18#include <asm/backlight.h>
diff --git a/drivers/video/aty/radeon_monitor.c b/drivers/video/aty/radeon_monitor.c
index b4d4b88afc0..9261c918fde 100644
--- a/drivers/video/aty/radeon_monitor.c
+++ b/drivers/video/aty/radeon_monitor.c
@@ -1,4 +1,7 @@
1#include "radeonfb.h" 1#include "radeonfb.h"
2
3#include <linux/slab.h>
4
2#include "../edid.h" 5#include "../edid.h"
3 6
4static struct fb_var_screeninfo radeonfb_default_var = { 7static struct fb_var_screeninfo radeonfb_default_var = {
diff --git a/drivers/video/au1100fb.c b/drivers/video/au1100fb.c
index a699aab6382..40f61320ce1 100644
--- a/drivers/video/au1100fb.c
+++ b/drivers/video/au1100fb.c
@@ -52,6 +52,7 @@
52#include <linux/ctype.h> 52#include <linux/ctype.h>
53#include <linux/dma-mapping.h> 53#include <linux/dma-mapping.h>
54#include <linux/platform_device.h> 54#include <linux/platform_device.h>
55#include <linux/slab.h>
55 56
56#include <asm/mach-au1x00/au1000.h> 57#include <asm/mach-au1x00/au1000.h>
57 58
diff --git a/drivers/video/au1200fb.c b/drivers/video/au1200fb.c
index 0d96f1d2d4c..e77e8e4280f 100644
--- a/drivers/video/au1200fb.c
+++ b/drivers/video/au1200fb.c
@@ -41,6 +41,7 @@
41#include <linux/interrupt.h> 41#include <linux/interrupt.h>
42#include <linux/ctype.h> 42#include <linux/ctype.h>
43#include <linux/dma-mapping.h> 43#include <linux/dma-mapping.h>
44#include <linux/slab.h>
44 45
45#include <asm/mach-au1x00/au1000.h> 46#include <asm/mach-au1x00/au1000.h>
46#include "au1200fb.h" 47#include "au1200fb.h"
diff --git a/drivers/video/backlight/88pm860x_bl.c b/drivers/video/backlight/88pm860x_bl.c
index 93e25c77aeb..68d2518fada 100644
--- a/drivers/video/backlight/88pm860x_bl.c
+++ b/drivers/video/backlight/88pm860x_bl.c
@@ -16,6 +16,7 @@
16#include <linux/i2c.h> 16#include <linux/i2c.h>
17#include <linux/backlight.h> 17#include <linux/backlight.h>
18#include <linux/mfd/88pm860x.h> 18#include <linux/mfd/88pm860x.h>
19#include <linux/slab.h>
19 20
20#define MAX_BRIGHTNESS (0xFF) 21#define MAX_BRIGHTNESS (0xFF)
21#define MIN_BRIGHTNESS (0) 22#define MIN_BRIGHTNESS (0)
diff --git a/drivers/video/backlight/adp5520_bl.c b/drivers/video/backlight/adp5520_bl.c
index 5183f0e4d31..9f436e014f8 100644
--- a/drivers/video/backlight/adp5520_bl.c
+++ b/drivers/video/backlight/adp5520_bl.c
@@ -12,6 +12,7 @@
12#include <linux/fb.h> 12#include <linux/fb.h>
13#include <linux/backlight.h> 13#include <linux/backlight.h>
14#include <linux/mfd/adp5520.h> 14#include <linux/mfd/adp5520.h>
15#include <linux/slab.h>
15 16
16struct adp5520_bl { 17struct adp5520_bl {
17 struct device *master; 18 struct device *master;
diff --git a/drivers/video/backlight/adx_bl.c b/drivers/video/backlight/adx_bl.c
index b0624b98388..7f4a7c30a98 100644
--- a/drivers/video/backlight/adx_bl.c
+++ b/drivers/video/backlight/adx_bl.c
@@ -12,6 +12,7 @@
12 12
13#include <linux/backlight.h> 13#include <linux/backlight.h>
14#include <linux/fb.h> 14#include <linux/fb.h>
15#include <linux/gfp.h>
15#include <linux/io.h> 16#include <linux/io.h>
16#include <linux/module.h> 17#include <linux/module.h>
17#include <linux/platform_device.h> 18#include <linux/platform_device.h>
diff --git a/drivers/video/backlight/atmel-pwm-bl.c b/drivers/video/backlight/atmel-pwm-bl.c
index 2d9760551a4..e6a66dab088 100644
--- a/drivers/video/backlight/atmel-pwm-bl.c
+++ b/drivers/video/backlight/atmel-pwm-bl.c
@@ -17,6 +17,7 @@
17#include <linux/backlight.h> 17#include <linux/backlight.h>
18#include <linux/atmel_pwm.h> 18#include <linux/atmel_pwm.h>
19#include <linux/atmel-pwm-bl.h> 19#include <linux/atmel-pwm-bl.h>
20#include <linux/slab.h>
20 21
21struct atmel_pwm_bl { 22struct atmel_pwm_bl {
22 const struct atmel_pwm_bl_platform_data *pdata; 23 const struct atmel_pwm_bl_platform_data *pdata;
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index 68bb838b9f1..e207810bba3 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -13,6 +13,7 @@
13#include <linux/ctype.h> 13#include <linux/ctype.h>
14#include <linux/err.h> 14#include <linux/err.h>
15#include <linux/fb.h> 15#include <linux/fb.h>
16#include <linux/slab.h>
16 17
17#ifdef CONFIG_PMAC_BACKLIGHT 18#ifdef CONFIG_PMAC_BACKLIGHT
18#include <asm/backlight.h> 19#include <asm/backlight.h>
diff --git a/drivers/video/backlight/corgi_lcd.c b/drivers/video/backlight/corgi_lcd.c
index 73bdd8454c9..1e71c35083b 100644
--- a/drivers/video/backlight/corgi_lcd.c
+++ b/drivers/video/backlight/corgi_lcd.c
@@ -24,6 +24,7 @@
24#include <linux/lcd.h> 24#include <linux/lcd.h>
25#include <linux/spi/spi.h> 25#include <linux/spi/spi.h>
26#include <linux/spi/corgi_lcd.h> 26#include <linux/spi/corgi_lcd.h>
27#include <linux/slab.h>
27#include <asm/mach/sharpsl_param.h> 28#include <asm/mach/sharpsl_param.h>
28 29
29#define POWER_IS_ON(pwr) ((pwr) <= FB_BLANK_NORMAL) 30#define POWER_IS_ON(pwr) ((pwr) <= FB_BLANK_NORMAL)
diff --git a/drivers/video/backlight/cr_bllcd.c b/drivers/video/backlight/cr_bllcd.c
index 1cce6031bff..a4f4546f0be 100644
--- a/drivers/video/backlight/cr_bllcd.c
+++ b/drivers/video/backlight/cr_bllcd.c
@@ -36,6 +36,7 @@
36#include <linux/backlight.h> 36#include <linux/backlight.h>
37#include <linux/lcd.h> 37#include <linux/lcd.h>
38#include <linux/pci.h> 38#include <linux/pci.h>
39#include <linux/slab.h>
39 40
40/* The LVDS- and panel power controls sits on the 41/* The LVDS- and panel power controls sits on the
41 * GPIO port of the ISA bridge. 42 * GPIO port of the ISA bridge.
diff --git a/drivers/video/backlight/da903x_bl.c b/drivers/video/backlight/da903x_bl.c
index 686e4a78923..87659ed79bd 100644
--- a/drivers/video/backlight/da903x_bl.c
+++ b/drivers/video/backlight/da903x_bl.c
@@ -18,6 +18,7 @@
18#include <linux/fb.h> 18#include <linux/fb.h>
19#include <linux/backlight.h> 19#include <linux/backlight.h>
20#include <linux/mfd/da903x.h> 20#include <linux/mfd/da903x.h>
21#include <linux/slab.h>
21 22
22#define DA9030_WLED_CONTROL 0x25 23#define DA9030_WLED_CONTROL 0x25
23#define DA9030_WLED_CP_EN (1 << 6) 24#define DA9030_WLED_CP_EN (1 << 6)
diff --git a/drivers/video/backlight/ili9320.c b/drivers/video/backlight/ili9320.c
index ba89b41b639..5118a9f029a 100644
--- a/drivers/video/backlight/ili9320.c
+++ b/drivers/video/backlight/ili9320.c
@@ -17,6 +17,7 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/lcd.h> 18#include <linux/lcd.h>
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/slab.h>
20 21
21#include <linux/spi/spi.h> 22#include <linux/spi/spi.h>
22 23
diff --git a/drivers/video/backlight/l4f00242t03.c b/drivers/video/backlight/l4f00242t03.c
index 74abd6994b0..bcdb12c93ef 100644
--- a/drivers/video/backlight/l4f00242t03.c
+++ b/drivers/video/backlight/l4f00242t03.c
@@ -16,6 +16,7 @@
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/gpio.h> 17#include <linux/gpio.h>
18#include <linux/lcd.h> 18#include <linux/lcd.h>
19#include <linux/slab.h>
19#include <linux/regulator/consumer.h> 20#include <linux/regulator/consumer.h>
20 21
21#include <linux/spi/spi.h> 22#include <linux/spi/spi.h>
diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c
index 9b3be74cee5..71a11cadffc 100644
--- a/drivers/video/backlight/lcd.c
+++ b/drivers/video/backlight/lcd.c
@@ -13,6 +13,7 @@
13#include <linux/ctype.h> 13#include <linux/ctype.h>
14#include <linux/err.h> 14#include <linux/err.h>
15#include <linux/fb.h> 15#include <linux/fb.h>
16#include <linux/slab.h>
16 17
17#if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \ 18#if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \
18 defined(CONFIG_LCD_CLASS_DEVICE_MODULE)) 19 defined(CONFIG_LCD_CLASS_DEVICE_MODULE))
diff --git a/drivers/video/backlight/lms283gf05.c b/drivers/video/backlight/lms283gf05.c
index 447b542a20c..abc43a0eb97 100644
--- a/drivers/video/backlight/lms283gf05.c
+++ b/drivers/video/backlight/lms283gf05.c
@@ -11,6 +11,7 @@
11#include <linux/device.h> 11#include <linux/device.h>
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/delay.h> 13#include <linux/delay.h>
14#include <linux/slab.h>
14#include <linux/gpio.h> 15#include <linux/gpio.h>
15#include <linux/lcd.h> 16#include <linux/lcd.h>
16 17
diff --git a/drivers/video/backlight/ltv350qv.c b/drivers/video/backlight/ltv350qv.c
index 4631ca8fa4a..8010aaeb5ad 100644
--- a/drivers/video/backlight/ltv350qv.c
+++ b/drivers/video/backlight/ltv350qv.c
@@ -13,6 +13,7 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/lcd.h> 14#include <linux/lcd.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/slab.h>
16#include <linux/spi/spi.h> 17#include <linux/spi/spi.h>
17 18
18#include "ltv350qv.h" 19#include "ltv350qv.h"
diff --git a/drivers/video/backlight/max8925_bl.c b/drivers/video/backlight/max8925_bl.c
index c91adaf492c..b5accc957ad 100644
--- a/drivers/video/backlight/max8925_bl.c
+++ b/drivers/video/backlight/max8925_bl.c
@@ -16,6 +16,7 @@
16#include <linux/i2c.h> 16#include <linux/i2c.h>
17#include <linux/backlight.h> 17#include <linux/backlight.h>
18#include <linux/mfd/max8925.h> 18#include <linux/mfd/max8925.h>
19#include <linux/slab.h>
19 20
20#define MAX_BRIGHTNESS (0xff) 21#define MAX_BRIGHTNESS (0xff)
21#define MIN_BRIGHTNESS (0) 22#define MIN_BRIGHTNESS (0)
diff --git a/drivers/video/backlight/omap1_bl.c b/drivers/video/backlight/omap1_bl.c
index 333d28e6b06..d3bc56296c8 100644
--- a/drivers/video/backlight/omap1_bl.c
+++ b/drivers/video/backlight/omap1_bl.c
@@ -24,6 +24,7 @@
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/fb.h> 25#include <linux/fb.h>
26#include <linux/backlight.h> 26#include <linux/backlight.h>
27#include <linux/slab.h>
27 28
28#include <mach/hardware.h> 29#include <mach/hardware.h>
29#include <plat/board.h> 30#include <plat/board.h>
diff --git a/drivers/video/backlight/platform_lcd.c b/drivers/video/backlight/platform_lcd.c
index 738694d2388..302330acf62 100644
--- a/drivers/video/backlight/platform_lcd.c
+++ b/drivers/video/backlight/platform_lcd.c
@@ -16,6 +16,7 @@
16#include <linux/fb.h> 16#include <linux/fb.h>
17#include <linux/backlight.h> 17#include <linux/backlight.h>
18#include <linux/lcd.h> 18#include <linux/lcd.h>
19#include <linux/slab.h>
19 20
20#include <video/platform_lcd.h> 21#include <video/platform_lcd.h>
21 22
diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
index b89eebc3f77..55044351889 100644
--- a/drivers/video/backlight/pwm_bl.c
+++ b/drivers/video/backlight/pwm_bl.c
@@ -19,6 +19,7 @@
19#include <linux/err.h> 19#include <linux/err.h>
20#include <linux/pwm.h> 20#include <linux/pwm.h>
21#include <linux/pwm_backlight.h> 21#include <linux/pwm_backlight.h>
22#include <linux/slab.h>
22 23
23struct pwm_bl_data { 24struct pwm_bl_data {
24 struct pwm_device *pwm; 25 struct pwm_device *pwm;
diff --git a/drivers/video/backlight/tdo24m.c b/drivers/video/backlight/tdo24m.c
index 4a3d46e0801..1997e12a105 100644
--- a/drivers/video/backlight/tdo24m.c
+++ b/drivers/video/backlight/tdo24m.c
@@ -17,6 +17,7 @@
17#include <linux/spi/tdo24m.h> 17#include <linux/spi/tdo24m.h>
18#include <linux/fb.h> 18#include <linux/fb.h>
19#include <linux/lcd.h> 19#include <linux/lcd.h>
20#include <linux/slab.h>
20 21
21#define POWER_IS_ON(pwr) ((pwr) <= FB_BLANK_NORMAL) 22#define POWER_IS_ON(pwr) ((pwr) <= FB_BLANK_NORMAL)
22 23
diff --git a/drivers/video/backlight/tosa_bl.c b/drivers/video/backlight/tosa_bl.c
index f57bbf17004..e03e60bbfd8 100644
--- a/drivers/video/backlight/tosa_bl.c
+++ b/drivers/video/backlight/tosa_bl.c
@@ -18,6 +18,7 @@
18#include <linux/gpio.h> 18#include <linux/gpio.h>
19#include <linux/fb.h> 19#include <linux/fb.h>
20#include <linux/backlight.h> 20#include <linux/backlight.h>
21#include <linux/slab.h>
21 22
22#include <asm/mach/sharpsl_param.h> 23#include <asm/mach/sharpsl_param.h>
23 24
diff --git a/drivers/video/backlight/tosa_lcd.c b/drivers/video/backlight/tosa_lcd.c
index fa32b94a454..772f6015219 100644
--- a/drivers/video/backlight/tosa_lcd.c
+++ b/drivers/video/backlight/tosa_lcd.c
@@ -15,6 +15,7 @@
15#include <linux/device.h> 15#include <linux/device.h>
16#include <linux/spi/spi.h> 16#include <linux/spi/spi.h>
17#include <linux/i2c.h> 17#include <linux/i2c.h>
18#include <linux/slab.h>
18#include <linux/gpio.h> 19#include <linux/gpio.h>
19#include <linux/delay.h> 20#include <linux/delay.h>
20#include <linux/lcd.h> 21#include <linux/lcd.h>
diff --git a/drivers/video/backlight/wm831x_bl.c b/drivers/video/backlight/wm831x_bl.c
index a4312709fb1..08fd87f3aec 100644
--- a/drivers/video/backlight/wm831x_bl.c
+++ b/drivers/video/backlight/wm831x_bl.c
@@ -13,6 +13,7 @@
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <linux/fb.h> 14#include <linux/fb.h>
15#include <linux/backlight.h> 15#include <linux/backlight.h>
16#include <linux/slab.h>
16 17
17#include <linux/mfd/wm831x/core.h> 18#include <linux/mfd/wm831x/core.h>
18#include <linux/mfd/wm831x/pdata.h> 19#include <linux/mfd/wm831x/pdata.h>
diff --git a/drivers/video/bfin-lq035q1-fb.c b/drivers/video/bfin-lq035q1-fb.c
index 03872365a36..2baac7cc142 100644
--- a/drivers/video/bfin-lq035q1-fb.c
+++ b/drivers/video/bfin-lq035q1-fb.c
@@ -13,6 +13,7 @@
13#include <linux/errno.h> 13#include <linux/errno.h>
14#include <linux/string.h> 14#include <linux/string.h>
15#include <linux/fb.h> 15#include <linux/fb.h>
16#include <linux/slab.h>
16#include <linux/init.h> 17#include <linux/init.h>
17#include <linux/types.h> 18#include <linux/types.h>
18#include <linux/interrupt.h> 19#include <linux/interrupt.h>
diff --git a/drivers/video/bfin-t350mcqb-fb.c b/drivers/video/bfin-t350mcqb-fb.c
index 31a2dec927b..44e49c28b2a 100644
--- a/drivers/video/bfin-t350mcqb-fb.c
+++ b/drivers/video/bfin-t350mcqb-fb.c
@@ -32,6 +32,7 @@
32#include <linux/kernel.h> 32#include <linux/kernel.h>
33#include <linux/errno.h> 33#include <linux/errno.h>
34#include <linux/string.h> 34#include <linux/string.h>
35#include <linux/gfp.h>
35#include <linux/fb.h> 36#include <linux/fb.h>
36#include <linux/init.h> 37#include <linux/init.h>
37#include <linux/types.h> 38#include <linux/types.h>
diff --git a/drivers/video/bw2.c b/drivers/video/bw2.c
index b0b147cb4cb..43320925c4c 100644
--- a/drivers/video/bw2.c
+++ b/drivers/video/bw2.c
@@ -12,7 +12,6 @@
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/errno.h> 13#include <linux/errno.h>
14#include <linux/string.h> 14#include <linux/string.h>
15#include <linux/slab.h>
16#include <linux/delay.h> 15#include <linux/delay.h>
17#include <linux/init.h> 16#include <linux/init.h>
18#include <linux/fb.h> 17#include <linux/fb.h>
diff --git a/drivers/video/carminefb.c b/drivers/video/carminefb.c
index 0c02f8ec4bf..d8345fcc4fe 100644
--- a/drivers/video/carminefb.c
+++ b/drivers/video/carminefb.c
@@ -11,6 +11,7 @@
11#include <linux/fb.h> 11#include <linux/fb.h>
12#include <linux/interrupt.h> 12#include <linux/interrupt.h>
13#include <linux/pci.h> 13#include <linux/pci.h>
14#include <linux/slab.h>
14 15
15#include "carminefb.h" 16#include "carminefb.h"
16#include "carminefb_regs.h" 17#include "carminefb_regs.h"
diff --git a/drivers/video/cfbcopyarea.c b/drivers/video/cfbcopyarea.c
index 79e5f40e648..bb5a96b1645 100644
--- a/drivers/video/cfbcopyarea.c
+++ b/drivers/video/cfbcopyarea.c
@@ -26,7 +26,6 @@
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/string.h> 27#include <linux/string.h>
28#include <linux/fb.h> 28#include <linux/fb.h>
29#include <linux/slab.h>
30#include <asm/types.h> 29#include <asm/types.h>
31#include <asm/io.h> 30#include <asm/io.h>
32#include "fb_draw.h" 31#include "fb_draw.h"
diff --git a/drivers/video/cg14.c b/drivers/video/cg14.c
index fe45a3b8d0e..77a040af20a 100644
--- a/drivers/video/cg14.c
+++ b/drivers/video/cg14.c
@@ -11,7 +11,6 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/errno.h> 12#include <linux/errno.h>
13#include <linux/string.h> 13#include <linux/string.h>
14#include <linux/slab.h>
15#include <linux/delay.h> 14#include <linux/delay.h>
16#include <linux/init.h> 15#include <linux/init.h>
17#include <linux/fb.h> 16#include <linux/fb.h>
diff --git a/drivers/video/cg3.c b/drivers/video/cg3.c
index b2319fa7286..30eedf79322 100644
--- a/drivers/video/cg3.c
+++ b/drivers/video/cg3.c
@@ -12,7 +12,6 @@
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/errno.h> 13#include <linux/errno.h>
14#include <linux/string.h> 14#include <linux/string.h>
15#include <linux/slab.h>
16#include <linux/delay.h> 15#include <linux/delay.h>
17#include <linux/init.h> 16#include <linux/init.h>
18#include <linux/fb.h> 17#include <linux/fb.h>
diff --git a/drivers/video/cg6.c b/drivers/video/cg6.c
index 0d47c6030e3..6d0fcb43696 100644
--- a/drivers/video/cg6.c
+++ b/drivers/video/cg6.c
@@ -12,7 +12,6 @@
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/errno.h> 13#include <linux/errno.h>
14#include <linux/string.h> 14#include <linux/string.h>
15#include <linux/slab.h>
16#include <linux/delay.h> 15#include <linux/delay.h>
17#include <linux/init.h> 16#include <linux/init.h>
18#include <linux/fb.h> 17#include <linux/fb.h>
diff --git a/drivers/video/chipsfb.c b/drivers/video/chipsfb.c
index 57b9d276497..d637e1f5317 100644
--- a/drivers/video/chipsfb.c
+++ b/drivers/video/chipsfb.c
@@ -19,7 +19,6 @@
19#include <linux/errno.h> 19#include <linux/errno.h>
20#include <linux/string.h> 20#include <linux/string.h>
21#include <linux/mm.h> 21#include <linux/mm.h>
22#include <linux/slab.h>
23#include <linux/vmalloc.h> 22#include <linux/vmalloc.h>
24#include <linux/delay.h> 23#include <linux/delay.h>
25#include <linux/interrupt.h> 24#include <linux/interrupt.h>
diff --git a/drivers/video/cirrusfb.c b/drivers/video/cirrusfb.c
index 4c2bf923418..8d8dfda2f86 100644
--- a/drivers/video/cirrusfb.c
+++ b/drivers/video/cirrusfb.c
@@ -39,7 +39,6 @@
39#include <linux/errno.h> 39#include <linux/errno.h>
40#include <linux/string.h> 40#include <linux/string.h>
41#include <linux/mm.h> 41#include <linux/mm.h>
42#include <linux/slab.h>
43#include <linux/delay.h> 42#include <linux/delay.h>
44#include <linux/fb.h> 43#include <linux/fb.h>
45#include <linux/init.h> 44#include <linux/init.h>
diff --git a/drivers/video/console/bitblit.c b/drivers/video/console/bitblit.c
index 6b7c8fbc549..af88651b073 100644
--- a/drivers/video/console/bitblit.c
+++ b/drivers/video/console/bitblit.c
@@ -11,6 +11,7 @@
11 */ 11 */
12 12
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/slab.h>
14#include <linux/string.h> 15#include <linux/string.h>
15#include <linux/fb.h> 16#include <linux/fb.h>
16#include <linux/vt_kern.h> 17#include <linux/vt_kern.h>
diff --git a/drivers/video/console/fbcon_ccw.c b/drivers/video/console/fbcon_ccw.c
index bdf913ecf00..d135671d996 100644
--- a/drivers/video/console/fbcon_ccw.c
+++ b/drivers/video/console/fbcon_ccw.c
@@ -9,6 +9,7 @@
9 */ 9 */
10 10
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/slab.h>
12#include <linux/string.h> 13#include <linux/string.h>
13#include <linux/fb.h> 14#include <linux/fb.h>
14#include <linux/vt_kern.h> 15#include <linux/vt_kern.h>
diff --git a/drivers/video/console/fbcon_cw.c b/drivers/video/console/fbcon_cw.c
index a6819b9d177..126110f8454 100644
--- a/drivers/video/console/fbcon_cw.c
+++ b/drivers/video/console/fbcon_cw.c
@@ -9,6 +9,7 @@
9 */ 9 */
10 10
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/slab.h>
12#include <linux/string.h> 13#include <linux/string.h>
13#include <linux/fb.h> 14#include <linux/fb.h>
14#include <linux/vt_kern.h> 15#include <linux/vt_kern.h>
diff --git a/drivers/video/console/fbcon_rotate.c b/drivers/video/console/fbcon_rotate.c
index 00884e013f0..db6528f2d3f 100644
--- a/drivers/video/console/fbcon_rotate.c
+++ b/drivers/video/console/fbcon_rotate.c
@@ -9,6 +9,7 @@
9 */ 9 */
10 10
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/slab.h>
12#include <linux/string.h> 13#include <linux/string.h>
13#include <linux/fb.h> 14#include <linux/fb.h>
14#include <linux/vt_kern.h> 15#include <linux/vt_kern.h>
diff --git a/drivers/video/console/fbcon_ud.c b/drivers/video/console/fbcon_ud.c
index d9b5d6eb68a..93a3e7381b5 100644
--- a/drivers/video/console/fbcon_ud.c
+++ b/drivers/video/console/fbcon_ud.c
@@ -9,6 +9,7 @@
9 */ 9 */
10 10
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/slab.h>
12#include <linux/string.h> 13#include <linux/string.h>
13#include <linux/fb.h> 14#include <linux/fb.h>
14#include <linux/vt_kern.h> 15#include <linux/vt_kern.h>
diff --git a/drivers/video/console/mdacon.c b/drivers/video/console/mdacon.c
index dd3eaaad444..0b67866cae1 100644
--- a/drivers/video/console/mdacon.c
+++ b/drivers/video/console/mdacon.c
@@ -33,7 +33,6 @@
33#include <linux/console.h> 33#include <linux/console.h>
34#include <linux/string.h> 34#include <linux/string.h>
35#include <linux/kd.h> 35#include <linux/kd.h>
36#include <linux/slab.h>
37#include <linux/vt_kern.h> 36#include <linux/vt_kern.h>
38#include <linux/vt_buffer.h> 37#include <linux/vt_buffer.h>
39#include <linux/selection.h> 38#include <linux/selection.h>
diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c
index 369a5b3ac64..8d244ba0f60 100644
--- a/drivers/video/da8xx-fb.c
+++ b/drivers/video/da8xx-fb.c
@@ -30,6 +30,7 @@
30#include <linux/clk.h> 30#include <linux/clk.h>
31#include <linux/cpufreq.h> 31#include <linux/cpufreq.h>
32#include <linux/console.h> 32#include <linux/console.h>
33#include <linux/slab.h>
33#include <video/da8xx-fb.h> 34#include <video/da8xx-fb.h>
34 35
35#define DRIVER_NAME "da8xx_lcdc" 36#define DRIVER_NAME "da8xx_lcdc"
diff --git a/drivers/video/display/display-sysfs.c b/drivers/video/display/display-sysfs.c
index 80abbf323b9..f6a09ab0dac 100644
--- a/drivers/video/display/display-sysfs.c
+++ b/drivers/video/display/display-sysfs.c
@@ -27,6 +27,7 @@
27#include <linux/idr.h> 27#include <linux/idr.h>
28#include <linux/err.h> 28#include <linux/err.h>
29#include <linux/kdev_t.h> 29#include <linux/kdev_t.h>
30#include <linux/slab.h>
30 31
31static ssize_t display_show_name(struct device *dev, 32static ssize_t display_show_name(struct device *dev,
32 struct device_attribute *attr, char *buf) 33 struct device_attribute *attr, char *buf)
diff --git a/drivers/video/dnfb.c b/drivers/video/dnfb.c
index 606da043f4b..ec56d2544c7 100644
--- a/drivers/video/dnfb.c
+++ b/drivers/video/dnfb.c
@@ -2,7 +2,6 @@
2#include <linux/errno.h> 2#include <linux/errno.h>
3#include <linux/string.h> 3#include <linux/string.h>
4#include <linux/mm.h> 4#include <linux/mm.h>
5#include <linux/slab.h>
6#include <linux/delay.h> 5#include <linux/delay.h>
7#include <linux/interrupt.h> 6#include <linux/interrupt.h>
8#include <linux/platform_device.h> 7#include <linux/platform_device.h>
diff --git a/drivers/video/efifb.c b/drivers/video/efifb.c
index 581d2dbf675..ecf405562f5 100644
--- a/drivers/video/efifb.c
+++ b/drivers/video/efifb.c
@@ -49,6 +49,7 @@ enum {
49 M_MBP_2, /* MacBook Pro 2nd gen */ 49 M_MBP_2, /* MacBook Pro 2nd gen */
50 M_MBP_SR, /* MacBook Pro (Santa Rosa) */ 50 M_MBP_SR, /* MacBook Pro (Santa Rosa) */
51 M_MBP_4, /* MacBook Pro, 4th gen */ 51 M_MBP_4, /* MacBook Pro, 4th gen */
52 M_MBP_5_1, /* MacBook Pro, 5,1th gen */
52 M_UNKNOWN /* placeholder */ 53 M_UNKNOWN /* placeholder */
53}; 54};
54 55
@@ -70,6 +71,7 @@ static struct efifb_dmi_info {
70 [M_MBP_2] = { "mbp2", 0, 0, 0, 0 }, /* placeholder */ 71 [M_MBP_2] = { "mbp2", 0, 0, 0, 0 }, /* placeholder */
71 [M_MBP_SR] = { "mbp3", 0x80030000, 2048 * 4, 1440, 900 }, 72 [M_MBP_SR] = { "mbp3", 0x80030000, 2048 * 4, 1440, 900 },
72 [M_MBP_4] = { "mbp4", 0xc0060000, 2048 * 4, 1920, 1200 }, 73 [M_MBP_4] = { "mbp4", 0xc0060000, 2048 * 4, 1920, 1200 },
74 [M_MBP_5_1] = { "mbp51", 0xc0010000, 2048 * 4, 1440, 900 },
73 [M_UNKNOWN] = { NULL, 0, 0, 0, 0 } 75 [M_UNKNOWN] = { NULL, 0, 0, 0, 0 }
74}; 76};
75 77
@@ -106,6 +108,7 @@ static struct dmi_system_id __initdata dmi_system_table[] = {
106 EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBookPro3,1", M_MBP_SR), 108 EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "MacBookPro3,1", M_MBP_SR),
107 EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro3,1", M_MBP_SR), 109 EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro3,1", M_MBP_SR),
108 EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro4,1", M_MBP_4), 110 EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro4,1", M_MBP_4),
111 EFIFB_DMI_SYSTEM_ID("Apple Inc.", "MacBookPro5,1", M_MBP_5_1),
109 {}, 112 {},
110}; 113};
111 114
diff --git a/drivers/video/ep93xx-fb.c b/drivers/video/ep93xx-fb.c
index 27aab4a0619..0c99de0562c 100644
--- a/drivers/video/ep93xx-fb.c
+++ b/drivers/video/ep93xx-fb.c
@@ -19,6 +19,7 @@
19 19
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/dma-mapping.h> 21#include <linux/dma-mapping.h>
22#include <linux/slab.h>
22#include <linux/clk.h> 23#include <linux/clk.h>
23#include <linux/fb.h> 24#include <linux/fb.h>
24 25
diff --git a/drivers/video/epson1355fb.c b/drivers/video/epson1355fb.c
index 6d755bb3a2b..db9713b49ce 100644
--- a/drivers/video/epson1355fb.c
+++ b/drivers/video/epson1355fb.c
@@ -48,7 +48,6 @@
48#include <linux/errno.h> 48#include <linux/errno.h>
49#include <linux/string.h> 49#include <linux/string.h>
50#include <linux/mm.h> 50#include <linux/mm.h>
51#include <linux/slab.h>
52#include <linux/delay.h> 51#include <linux/delay.h>
53#include <linux/fb.h> 52#include <linux/fb.h>
54#include <linux/init.h> 53#include <linux/init.h>
diff --git a/drivers/video/fb_ddc.c b/drivers/video/fb_ddc.c
index 0cf96eb8a60..4a874c8d039 100644
--- a/drivers/video/fb_ddc.c
+++ b/drivers/video/fb_ddc.c
@@ -12,6 +12,7 @@
12#include <linux/device.h> 12#include <linux/device.h>
13#include <linux/fb.h> 13#include <linux/fb.h>
14#include <linux/i2c-algo-bit.h> 14#include <linux/i2c-algo-bit.h>
15#include <linux/slab.h>
15 16
16#include "edid.h" 17#include "edid.h"
17 18
diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
index 44ce908a478..6113c47e095 100644
--- a/drivers/video/fb_defio.c
+++ b/drivers/video/fb_defio.c
@@ -13,7 +13,6 @@
13#include <linux/errno.h> 13#include <linux/errno.h>
14#include <linux/string.h> 14#include <linux/string.h>
15#include <linux/mm.h> 15#include <linux/mm.h>
16#include <linux/slab.h>
17#include <linux/vmalloc.h> 16#include <linux/vmalloc.h>
18#include <linux/delay.h> 17#include <linux/delay.h>
19#include <linux/interrupt.h> 18#include <linux/interrupt.h>
diff --git a/drivers/video/fbcvt.c b/drivers/video/fbcvt.c
index 0847c5e72cb..7293eaccd81 100644
--- a/drivers/video/fbcvt.c
+++ b/drivers/video/fbcvt.c
@@ -13,6 +13,7 @@
13 * 13 *
14 */ 14 */
15#include <linux/fb.h> 15#include <linux/fb.h>
16#include <linux/slab.h>
16 17
17#define FB_CVT_CELLSIZE 8 18#define FB_CVT_CELLSIZE 8
18#define FB_CVT_GTF_C 40 19#define FB_CVT_GTF_C 40
diff --git a/drivers/video/fbmon.c b/drivers/video/fbmon.c
index 9ae9cd32bd0..563a98b88e9 100644
--- a/drivers/video/fbmon.c
+++ b/drivers/video/fbmon.c
@@ -29,6 +29,7 @@
29#include <linux/fb.h> 29#include <linux/fb.h>
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/pci.h> 31#include <linux/pci.h>
32#include <linux/slab.h>
32#include <video/edid.h> 33#include <video/edid.h>
33#ifdef CONFIG_PPC_OF 34#ifdef CONFIG_PPC_OF
34#include <asm/prom.h> 35#include <asm/prom.h>
diff --git a/drivers/video/fbsysfs.c b/drivers/video/fbsysfs.c
index d4a2c11d980..81aa3129c17 100644
--- a/drivers/video/fbsysfs.c
+++ b/drivers/video/fbsysfs.c
@@ -16,6 +16,7 @@
16 */ 16 */
17 17
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/slab.h>
19#include <linux/fb.h> 20#include <linux/fb.h>
20#include <linux/console.h> 21#include <linux/console.h>
21#include <linux/module.h> 22#include <linux/module.h>
diff --git a/drivers/video/ffb.c b/drivers/video/ffb.c
index 9dbb9646081..a42fabab69d 100644
--- a/drivers/video/ffb.c
+++ b/drivers/video/ffb.c
@@ -10,7 +10,6 @@
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/errno.h> 11#include <linux/errno.h>
12#include <linux/string.h> 12#include <linux/string.h>
13#include <linux/slab.h>
14#include <linux/delay.h> 13#include <linux/delay.h>
15#include <linux/init.h> 14#include <linux/init.h>
16#include <linux/fb.h> 15#include <linux/fb.h>
diff --git a/drivers/video/fsl-diu-fb.c b/drivers/video/fsl-diu-fb.c
index 4637bcbe03a..994358a4f30 100644
--- a/drivers/video/fsl-diu-fb.c
+++ b/drivers/video/fsl-diu-fb.c
@@ -1536,6 +1536,7 @@ static int __devinit fsl_diu_probe(struct of_device *ofdev,
1536 goto error; 1536 goto error;
1537 } 1537 }
1538 1538
1539 sysfs_attr_init(&machine_data->dev_attr.attr);
1539 machine_data->dev_attr.attr.name = "monitor"; 1540 machine_data->dev_attr.attr.name = "monitor";
1540 machine_data->dev_attr.attr.mode = S_IRUGO|S_IWUSR; 1541 machine_data->dev_attr.attr.mode = S_IRUGO|S_IWUSR;
1541 machine_data->dev_attr.show = show_monitor; 1542 machine_data->dev_attr.show = show_monitor;
diff --git a/drivers/video/g364fb.c b/drivers/video/g364fb.c
index b7655c05da5..d662317d85e 100644
--- a/drivers/video/g364fb.c
+++ b/drivers/video/g364fb.c
@@ -20,7 +20,6 @@
20#include <linux/errno.h> 20#include <linux/errno.h>
21#include <linux/string.h> 21#include <linux/string.h>
22#include <linux/mm.h> 22#include <linux/mm.h>
23#include <linux/slab.h>
24#include <linux/vmalloc.h> 23#include <linux/vmalloc.h>
25#include <linux/delay.h> 24#include <linux/delay.h>
26#include <linux/interrupt.h> 25#include <linux/interrupt.h>
diff --git a/drivers/video/gbefb.c b/drivers/video/gbefb.c
index 5643a35c174..7d8c55d7fd2 100644
--- a/drivers/video/gbefb.c
+++ b/drivers/video/gbefb.c
@@ -13,6 +13,7 @@
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <linux/dma-mapping.h> 14#include <linux/dma-mapping.h>
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/gfp.h>
16#include <linux/fb.h> 17#include <linux/fb.h>
17#include <linux/init.h> 18#include <linux/init.h>
18#include <linux/interrupt.h> 19#include <linux/interrupt.h>
diff --git a/drivers/video/geode/gx1fb_core.c b/drivers/video/geode/gx1fb_core.c
index f20eff8c4a8..c6b554f72c6 100644
--- a/drivers/video/geode/gx1fb_core.c
+++ b/drivers/video/geode/gx1fb_core.c
@@ -15,7 +15,6 @@
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/string.h> 16#include <linux/string.h>
17#include <linux/mm.h> 17#include <linux/mm.h>
18#include <linux/slab.h>
19#include <linux/delay.h> 18#include <linux/delay.h>
20#include <linux/fb.h> 19#include <linux/fb.h>
21#include <linux/init.h> 20#include <linux/init.h>
diff --git a/drivers/video/geode/gxfb_core.c b/drivers/video/geode/gxfb_core.c
index b3e639d1e12..76e7dac6f25 100644
--- a/drivers/video/geode/gxfb_core.c
+++ b/drivers/video/geode/gxfb_core.c
@@ -25,7 +25,6 @@
25#include <linux/errno.h> 25#include <linux/errno.h>
26#include <linux/string.h> 26#include <linux/string.h>
27#include <linux/mm.h> 27#include <linux/mm.h>
28#include <linux/slab.h>
29#include <linux/delay.h> 28#include <linux/delay.h>
30#include <linux/fb.h> 29#include <linux/fb.h>
31#include <linux/console.h> 30#include <linux/console.h>
diff --git a/drivers/video/geode/lxfb.h b/drivers/video/geode/lxfb.h
index cc781c00f75..e4c4d89b786 100644
--- a/drivers/video/geode/lxfb.h
+++ b/drivers/video/geode/lxfb.h
@@ -365,6 +365,8 @@ enum fp_registers {
365 FP_CRC, /* 0x458 */ 365 FP_CRC, /* 0x458 */
366}; 366};
367 367
368#define FP_PT2_HSP (1 << 22)
369#define FP_PT2_VSP (1 << 23)
368#define FP_PT2_SCRC (1 << 27) /* shfclk free */ 370#define FP_PT2_SCRC (1 << 27) /* shfclk free */
369 371
370#define FP_PM_P (1 << 24) /* panel power ctl */ 372#define FP_PM_P (1 << 24) /* panel power ctl */
diff --git a/drivers/video/geode/lxfb_core.c b/drivers/video/geode/lxfb_core.c
index 889cbe39e58..1a18da86d3f 100644
--- a/drivers/video/geode/lxfb_core.c
+++ b/drivers/video/geode/lxfb_core.c
@@ -16,7 +16,6 @@
16#include <linux/string.h> 16#include <linux/string.h>
17#include <linux/console.h> 17#include <linux/console.h>
18#include <linux/mm.h> 18#include <linux/mm.h>
19#include <linux/slab.h>
20#include <linux/suspend.h> 19#include <linux/suspend.h>
21#include <linux/delay.h> 20#include <linux/delay.h>
22#include <linux/fb.h> 21#include <linux/fb.h>
diff --git a/drivers/video/geode/lxfb_ops.c b/drivers/video/geode/lxfb_ops.c
index 0e5d8c7c3eb..bc35a95e59d 100644
--- a/drivers/video/geode/lxfb_ops.c
+++ b/drivers/video/geode/lxfb_ops.c
@@ -274,7 +274,15 @@ static void lx_graphics_enable(struct fb_info *info)
274 u32 msrlo, msrhi; 274 u32 msrlo, msrhi;
275 275
276 write_fp(par, FP_PT1, 0); 276 write_fp(par, FP_PT1, 0);
277 write_fp(par, FP_PT2, FP_PT2_SCRC); 277 temp = FP_PT2_SCRC;
278
279 if (info->var.sync & FB_SYNC_HOR_HIGH_ACT)
280 temp |= FP_PT2_HSP;
281
282 if (info->var.sync & FB_SYNC_VERT_HIGH_ACT)
283 temp |= FP_PT2_VSP;
284
285 write_fp(par, FP_PT2, temp);
278 write_fp(par, FP_DFC, FP_DFC_BC); 286 write_fp(par, FP_DFC, FP_DFC_BC);
279 287
280 msrlo = MSR_LX_MSR_PADSEL_TFT_SEL_LOW; 288 msrlo = MSR_LX_MSR_PADSEL_TFT_SEL_LOW;
diff --git a/drivers/video/hecubafb.c b/drivers/video/hecubafb.c
index f9d77adf035..c77bcc6ab46 100644
--- a/drivers/video/hecubafb.c
+++ b/drivers/video/hecubafb.c
@@ -32,7 +32,6 @@
32#include <linux/errno.h> 32#include <linux/errno.h>
33#include <linux/string.h> 33#include <linux/string.h>
34#include <linux/mm.h> 34#include <linux/mm.h>
35#include <linux/slab.h>
36#include <linux/vmalloc.h> 35#include <linux/vmalloc.h>
37#include <linux/delay.h> 36#include <linux/delay.h>
38#include <linux/interrupt.h> 37#include <linux/interrupt.h>
diff --git a/drivers/video/hgafb.c b/drivers/video/hgafb.c
index db9b785b56e..8bbf251f83d 100644
--- a/drivers/video/hgafb.c
+++ b/drivers/video/hgafb.c
@@ -36,7 +36,6 @@
36#include <linux/spinlock.h> 36#include <linux/spinlock.h>
37#include <linux/string.h> 37#include <linux/string.h>
38#include <linux/mm.h> 38#include <linux/mm.h>
39#include <linux/slab.h>
40#include <linux/delay.h> 39#include <linux/delay.h>
41#include <linux/fb.h> 40#include <linux/fb.h>
42#include <linux/init.h> 41#include <linux/init.h>
diff --git a/drivers/video/hitfb.c b/drivers/video/hitfb.c
index bf78779199c..393f3f3d3df 100644
--- a/drivers/video/hitfb.c
+++ b/drivers/video/hitfb.c
@@ -16,7 +16,6 @@
16#include <linux/errno.h> 16#include <linux/errno.h>
17#include <linux/string.h> 17#include <linux/string.h>
18#include <linux/mm.h> 18#include <linux/mm.h>
19#include <linux/slab.h>
20#include <linux/delay.h> 19#include <linux/delay.h>
21#include <linux/init.h> 20#include <linux/init.h>
22#include <linux/platform_device.h> 21#include <linux/platform_device.h>
diff --git a/drivers/video/hpfb.c b/drivers/video/hpfb.c
index b8ebff1e849..c8e280f1bb0 100644
--- a/drivers/video/hpfb.c
+++ b/drivers/video/hpfb.c
@@ -10,7 +10,6 @@
10#include <linux/errno.h> 10#include <linux/errno.h>
11#include <linux/string.h> 11#include <linux/string.h>
12#include <linux/mm.h> 12#include <linux/mm.h>
13#include <linux/slab.h>
14#include <linux/delay.h> 13#include <linux/delay.h>
15#include <linux/init.h> 14#include <linux/init.h>
16#include <linux/fb.h> 15#include <linux/fb.h>
diff --git a/drivers/video/i810/i810-i2c.c b/drivers/video/i810/i810-i2c.c
index 9dd55e5324a..cd2c728a809 100644
--- a/drivers/video/i810/i810-i2c.c
+++ b/drivers/video/i810/i810-i2c.c
@@ -11,6 +11,7 @@
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/delay.h> 13#include <linux/delay.h>
14#include <linux/gfp.h>
14#include <linux/pci.h> 15#include <linux/pci.h>
15#include <linux/fb.h> 16#include <linux/fb.h>
16#include "i810.h" 17#include "i810.h"
diff --git a/drivers/video/imsttfb.c b/drivers/video/imsttfb.c
index 15d50b9906c..efb2c10656b 100644
--- a/drivers/video/imsttfb.c
+++ b/drivers/video/imsttfb.c
@@ -21,7 +21,6 @@
21#include <linux/errno.h> 21#include <linux/errno.h>
22#include <linux/string.h> 22#include <linux/string.h>
23#include <linux/mm.h> 23#include <linux/mm.h>
24#include <linux/slab.h>
25#include <linux/vmalloc.h> 24#include <linux/vmalloc.h>
26#include <linux/delay.h> 25#include <linux/delay.h>
27#include <linux/interrupt.h> 26#include <linux/interrupt.h>
diff --git a/drivers/video/intelfb/intelfbhw.c b/drivers/video/intelfb/intelfbhw.c
index 81627466804..38065cf94ac 100644
--- a/drivers/video/intelfb/intelfbhw.c
+++ b/drivers/video/intelfb/intelfbhw.c
@@ -24,7 +24,6 @@
24#include <linux/errno.h> 24#include <linux/errno.h>
25#include <linux/string.h> 25#include <linux/string.h>
26#include <linux/mm.h> 26#include <linux/mm.h>
27#include <linux/slab.h>
28#include <linux/delay.h> 27#include <linux/delay.h>
29#include <linux/fb.h> 28#include <linux/fb.h>
30#include <linux/ioport.h> 29#include <linux/ioport.h>
diff --git a/drivers/video/leo.c b/drivers/video/leo.c
index e145e2d16fe..1db55f12849 100644
--- a/drivers/video/leo.c
+++ b/drivers/video/leo.c
@@ -11,7 +11,6 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/errno.h> 12#include <linux/errno.h>
13#include <linux/string.h> 13#include <linux/string.h>
14#include <linux/slab.h>
15#include <linux/delay.h> 14#include <linux/delay.h>
16#include <linux/init.h> 15#include <linux/init.h>
17#include <linux/fb.h> 16#include <linux/fb.h>
diff --git a/drivers/video/matrox/i2c-matroxfb.c b/drivers/video/matrox/i2c-matroxfb.c
index f3728ab262f..403b14445a7 100644
--- a/drivers/video/matrox/i2c-matroxfb.c
+++ b/drivers/video/matrox/i2c-matroxfb.c
@@ -13,6 +13,7 @@
13#include "matroxfb_base.h" 13#include "matroxfb_base.h"
14#include "matroxfb_maven.h" 14#include "matroxfb_maven.h"
15#include <linux/i2c.h> 15#include <linux/i2c.h>
16#include <linux/slab.h>
16#include <linux/i2c-algo-bit.h> 17#include <linux/i2c-algo-bit.h>
17 18
18/* MGA-TVO I2C for G200, G400 */ 19/* MGA-TVO I2C for G200, G400 */
diff --git a/drivers/video/matrox/matroxfb_base.c b/drivers/video/matrox/matroxfb_base.c
index 7064fb4427b..052dd9f0b76 100644
--- a/drivers/video/matrox/matroxfb_base.c
+++ b/drivers/video/matrox/matroxfb_base.c
@@ -113,6 +113,7 @@
113#include "matroxfb_g450.h" 113#include "matroxfb_g450.h"
114#include <linux/matroxfb.h> 114#include <linux/matroxfb.h>
115#include <linux/interrupt.h> 115#include <linux/interrupt.h>
116#include <linux/slab.h>
116#include <linux/uaccess.h> 117#include <linux/uaccess.h>
117 118
118#ifdef CONFIG_PPC_PMAC 119#ifdef CONFIG_PPC_PMAC
diff --git a/drivers/video/matrox/matroxfb_crtc2.c b/drivers/video/matrox/matroxfb_crtc2.c
index 78414baa5a5..d7112c39614 100644
--- a/drivers/video/matrox/matroxfb_crtc2.c
+++ b/drivers/video/matrox/matroxfb_crtc2.c
@@ -15,6 +15,7 @@
15#include "matroxfb_misc.h" 15#include "matroxfb_misc.h"
16#include "matroxfb_DAC1064.h" 16#include "matroxfb_DAC1064.h"
17#include <linux/matroxfb.h> 17#include <linux/matroxfb.h>
18#include <linux/slab.h>
18#include <linux/uaccess.h> 19#include <linux/uaccess.h>
19 20
20/* **************************************************** */ 21/* **************************************************** */
diff --git a/drivers/video/matrox/matroxfb_maven.c b/drivers/video/matrox/matroxfb_maven.c
index 91af9159111..1e3e8f19783 100644
--- a/drivers/video/matrox/matroxfb_maven.c
+++ b/drivers/video/matrox/matroxfb_maven.c
@@ -17,6 +17,7 @@
17#include "matroxfb_DAC1064.h" 17#include "matroxfb_DAC1064.h"
18#include <linux/i2c.h> 18#include <linux/i2c.h>
19#include <linux/matroxfb.h> 19#include <linux/matroxfb.h>
20#include <linux/slab.h>
20#include <asm/div64.h> 21#include <asm/div64.h>
21 22
22#define MGATVO_B 1 23#define MGATVO_B 1
diff --git a/drivers/video/maxinefb.c b/drivers/video/maxinefb.c
index 7854c7a37dc..5cf52d3c8e7 100644
--- a/drivers/video/maxinefb.c
+++ b/drivers/video/maxinefb.c
@@ -28,7 +28,6 @@
28#include <linux/errno.h> 28#include <linux/errno.h>
29#include <linux/string.h> 29#include <linux/string.h>
30#include <linux/mm.h> 30#include <linux/mm.h>
31#include <linux/slab.h>
32#include <linux/delay.h> 31#include <linux/delay.h>
33#include <linux/init.h> 32#include <linux/init.h>
34#include <linux/fb.h> 33#include <linux/fb.h>
diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
index 049256052b1..fe92eed6da7 100644
--- a/drivers/video/mb862xx/mb862xxfb_accel.c
+++ b/drivers/video/mb862xx/mb862xxfb_accel.c
@@ -4,7 +4,7 @@
4 * Fujitsu Carmine/Coral-P(A)/Lime framebuffer driver acceleration support 4 * Fujitsu Carmine/Coral-P(A)/Lime framebuffer driver acceleration support
5 * 5 *
6 * (C) 2007 Alexander Shishkin <virtuoso@slind.org> 6 * (C) 2007 Alexander Shishkin <virtuoso@slind.org>
7 * (C) 2009 Valentin Sitdikov <valentin.sitdikov@siemens.com> 7 * (C) 2009 Valentin Sitdikov <v.sitdikov@gmail.com>
8 * (C) 2009 Siemens AG 8 * (C) 2009 Siemens AG
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
@@ -16,7 +16,9 @@
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/module.h>
19#include <linux/pci.h> 20#include <linux/pci.h>
21#include <linux/slab.h>
20#if defined(CONFIG_OF) 22#if defined(CONFIG_OF)
21#include <linux/of_platform.h> 23#include <linux/of_platform.h>
22#endif 24#endif
@@ -329,3 +331,5 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
329 info->fix.accel = 0xff; /*FIXME: add right define */ 331 info->fix.accel = 0xff; /*FIXME: add right define */
330} 332}
331EXPORT_SYMBOL(mb862xxfb_init_accel); 333EXPORT_SYMBOL(mb862xxfb_init_accel);
334
335MODULE_LICENSE("GPL v2");
diff --git a/drivers/video/mbx/mbxdebugfs.c b/drivers/video/mbx/mbxdebugfs.c
index 15b8b3c4330..ecad9652457 100644
--- a/drivers/video/mbx/mbxdebugfs.c
+++ b/drivers/video/mbx/mbxdebugfs.c
@@ -1,4 +1,5 @@
1#include <linux/debugfs.h> 1#include <linux/debugfs.h>
2#include <linux/slab.h>
2 3
3#define BIG_BUFFER_SIZE (1024) 4#define BIG_BUFFER_SIZE (1024)
4 5
diff --git a/drivers/video/metronomefb.c b/drivers/video/metronomefb.c
index 661bfd20d19..9b3d6e4584c 100644
--- a/drivers/video/metronomefb.c
+++ b/drivers/video/metronomefb.c
@@ -23,7 +23,6 @@
23#include <linux/errno.h> 23#include <linux/errno.h>
24#include <linux/string.h> 24#include <linux/string.h>
25#include <linux/mm.h> 25#include <linux/mm.h>
26#include <linux/slab.h>
27#include <linux/vmalloc.h> 26#include <linux/vmalloc.h>
28#include <linux/delay.h> 27#include <linux/delay.h>
29#include <linux/interrupt.h> 28#include <linux/interrupt.h>
diff --git a/drivers/video/modedb.c b/drivers/video/modedb.c
index b895aae4163..0a4dbdc1693 100644
--- a/drivers/video/modedb.c
+++ b/drivers/video/modedb.c
@@ -12,6 +12,7 @@
12 */ 12 */
13 13
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/slab.h>
15#include <linux/fb.h> 16#include <linux/fb.h>
16#include <linux/kernel.h> 17#include <linux/kernel.h>
17 18
diff --git a/drivers/video/msm/mddi.c b/drivers/video/msm/mddi.c
index 474421fe79a..c1ff271017a 100644
--- a/drivers/video/msm/mddi.c
+++ b/drivers/video/msm/mddi.c
@@ -21,6 +21,7 @@
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/gfp.h>
24#include <linux/spinlock.h> 25#include <linux/spinlock.h>
25#include <linux/clk.h> 26#include <linux/clk.h>
26#include <linux/io.h> 27#include <linux/io.h>
diff --git a/drivers/video/msm/mddi_client_dummy.c b/drivers/video/msm/mddi_client_dummy.c
index ebbae87885b..d2a091cebe2 100644
--- a/drivers/video/msm/mddi_client_dummy.c
+++ b/drivers/video/msm/mddi_client_dummy.c
@@ -15,6 +15,7 @@
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 */ 16 */
17 17
18#include <linux/slab.h>
18#include <linux/module.h> 19#include <linux/module.h>
19#include <linux/kernel.h> 20#include <linux/kernel.h>
20#include <linux/platform_device.h> 21#include <linux/platform_device.h>
diff --git a/drivers/video/msm/mddi_client_nt35399.c b/drivers/video/msm/mddi_client_nt35399.c
index c9e9349451c..f239f4a25e0 100644
--- a/drivers/video/msm/mddi_client_nt35399.c
+++ b/drivers/video/msm/mddi_client_nt35399.c
@@ -21,6 +21,7 @@
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/sched.h> 22#include <linux/sched.h>
23#include <linux/gpio.h> 23#include <linux/gpio.h>
24#include <linux/slab.h>
24#include <mach/msm_fb.h> 25#include <mach/msm_fb.h>
25 26
26static DECLARE_WAIT_QUEUE_HEAD(nt35399_vsync_wait); 27static DECLARE_WAIT_QUEUE_HEAD(nt35399_vsync_wait);
diff --git a/drivers/video/msm/mddi_client_toshiba.c b/drivers/video/msm/mddi_client_toshiba.c
index 71048e78f7f..f9bc932ac46 100644
--- a/drivers/video/msm/mddi_client_toshiba.c
+++ b/drivers/video/msm/mddi_client_toshiba.c
@@ -21,6 +21,7 @@
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/gpio.h> 22#include <linux/gpio.h>
23#include <linux/sched.h> 23#include <linux/sched.h>
24#include <linux/slab.h>
24#include <mach/msm_fb.h> 25#include <mach/msm_fb.h>
25 26
26 27
diff --git a/drivers/video/msm/mdp.c b/drivers/video/msm/mdp.c
index 6c519e2fa2b..19c01c6208e 100644
--- a/drivers/video/msm/mdp.c
+++ b/drivers/video/msm/mdp.c
@@ -23,6 +23,7 @@
23#include <linux/clk.h> 23#include <linux/clk.h>
24#include <linux/file.h> 24#include <linux/file.h>
25#include <linux/major.h> 25#include <linux/major.h>
26#include <linux/slab.h>
26 27
27#include <mach/msm_iomap.h> 28#include <mach/msm_iomap.h>
28#include <mach/msm_fb.h> 29#include <mach/msm_fb.h>
diff --git a/drivers/video/msm/msm_fb.c b/drivers/video/msm/msm_fb.c
index 49101dda45e..debe5933fd2 100644
--- a/drivers/video/msm/msm_fb.c
+++ b/drivers/video/msm/msm_fb.c
@@ -17,6 +17,7 @@
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/fb.h> 19#include <linux/fb.h>
20#include <linux/slab.h>
20#include <linux/delay.h> 21#include <linux/delay.h>
21 22
22#include <linux/freezer.h> 23#include <linux/freezer.h>
diff --git a/drivers/video/nvidia/nv_i2c.c b/drivers/video/nvidia/nv_i2c.c
index 6aaddb4f678..d7994a17324 100644
--- a/drivers/video/nvidia/nv_i2c.c
+++ b/drivers/video/nvidia/nv_i2c.c
@@ -13,6 +13,7 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/gfp.h>
16#include <linux/pci.h> 17#include <linux/pci.h>
17#include <linux/fb.h> 18#include <linux/fb.h>
18 19
diff --git a/drivers/video/nvidia/nv_of.c b/drivers/video/nvidia/nv_of.c
index 73afd7eb997..3bc13df4b12 100644
--- a/drivers/video/nvidia/nv_of.c
+++ b/drivers/video/nvidia/nv_of.c
@@ -13,6 +13,7 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/gfp.h>
16#include <linux/pci.h> 17#include <linux/pci.h>
17#include <linux/fb.h> 18#include <linux/fb.h>
18 19
diff --git a/drivers/video/nvidia/nv_setup.c b/drivers/video/nvidia/nv_setup.c
index eef2bb298d9..2f2e162134f 100644
--- a/drivers/video/nvidia/nv_setup.c
+++ b/drivers/video/nvidia/nv_setup.c
@@ -50,6 +50,7 @@
50#include <video/vga.h> 50#include <video/vga.h>
51#include <linux/delay.h> 51#include <linux/delay.h>
52#include <linux/pci.h> 52#include <linux/pci.h>
53#include <linux/slab.h>
53#include "nv_type.h" 54#include "nv_type.h"
54#include "nv_local.h" 55#include "nv_local.h"
55#include "nv_proto.h" 56#include "nv_proto.h"
diff --git a/drivers/video/offb.c b/drivers/video/offb.c
index b043ac83c41..61f8b8f919b 100644
--- a/drivers/video/offb.c
+++ b/drivers/video/offb.c
@@ -17,7 +17,6 @@
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <linux/string.h> 18#include <linux/string.h>
19#include <linux/mm.h> 19#include <linux/mm.h>
20#include <linux/slab.h>
21#include <linux/vmalloc.h> 20#include <linux/vmalloc.h>
22#include <linux/delay.h> 21#include <linux/delay.h>
23#include <linux/interrupt.h> 22#include <linux/interrupt.h>
diff --git a/drivers/video/omap/dispc.c b/drivers/video/omap/dispc.c
index e192b058a68..529483467ab 100644
--- a/drivers/video/omap/dispc.c
+++ b/drivers/video/omap/dispc.c
@@ -25,6 +25,7 @@
25#include <linux/clk.h> 25#include <linux/clk.h>
26#include <linux/io.h> 26#include <linux/io.h>
27#include <linux/platform_device.h> 27#include <linux/platform_device.h>
28#include <linux/slab.h>
28 29
29#include <plat/sram.h> 30#include <plat/sram.h>
30#include <plat/board.h> 31#include <plat/board.h>
diff --git a/drivers/video/omap/lcd_mipid.c b/drivers/video/omap/lcd_mipid.c
index abe1c76a325..64dcc7439c9 100644
--- a/drivers/video/omap/lcd_mipid.c
+++ b/drivers/video/omap/lcd_mipid.c
@@ -20,6 +20,7 @@
20 */ 20 */
21#include <linux/device.h> 21#include <linux/device.h>
22#include <linux/delay.h> 22#include <linux/delay.h>
23#include <linux/slab.h>
23#include <linux/workqueue.h> 24#include <linux/workqueue.h>
24#include <linux/spi/spi.h> 25#include <linux/spi/spi.h>
25 26
diff --git a/drivers/video/omap/lcdc.c b/drivers/video/omap/lcdc.c
index 9557f963662..43ab7d8b66b 100644
--- a/drivers/video/omap/lcdc.c
+++ b/drivers/video/omap/lcdc.c
@@ -28,6 +28,7 @@
28#include <linux/dma-mapping.h> 28#include <linux/dma-mapping.h>
29#include <linux/vmalloc.h> 29#include <linux/vmalloc.h>
30#include <linux/clk.h> 30#include <linux/clk.h>
31#include <linux/gfp.h>
31 32
32#include <mach/lcdc.h> 33#include <mach/lcdc.h>
33#include <plat/dma.h> 34#include <plat/dma.h>
diff --git a/drivers/video/omap/omapfb_main.c b/drivers/video/omap/omapfb_main.c
index 8ce60e1b220..e264efd0278 100644
--- a/drivers/video/omap/omapfb_main.c
+++ b/drivers/video/omap/omapfb_main.c
@@ -26,6 +26,7 @@
26 */ 26 */
27#include <linux/platform_device.h> 27#include <linux/platform_device.h>
28#include <linux/mm.h> 28#include <linux/mm.h>
29#include <linux/slab.h>
29#include <linux/uaccess.h> 30#include <linux/uaccess.h>
30 31
31#include <plat/dma.h> 32#include <plat/dma.h>
diff --git a/drivers/video/omap2/displays/panel-generic.c b/drivers/video/omap2/displays/panel-generic.c
index c59e4baed8b..300eff5de1b 100644
--- a/drivers/video/omap2/displays/panel-generic.c
+++ b/drivers/video/omap2/displays/panel-generic.c
@@ -116,6 +116,24 @@ static int generic_panel_resume(struct omap_dss_device *dssdev)
116 return 0; 116 return 0;
117} 117}
118 118
119static void generic_panel_set_timings(struct omap_dss_device *dssdev,
120 struct omap_video_timings *timings)
121{
122 dpi_set_timings(dssdev, timings);
123}
124
125static void generic_panel_get_timings(struct omap_dss_device *dssdev,
126 struct omap_video_timings *timings)
127{
128 *timings = dssdev->panel.timings;
129}
130
131static int generic_panel_check_timings(struct omap_dss_device *dssdev,
132 struct omap_video_timings *timings)
133{
134 return dpi_check_timings(dssdev, timings);
135}
136
119static struct omap_dss_driver generic_driver = { 137static struct omap_dss_driver generic_driver = {
120 .probe = generic_panel_probe, 138 .probe = generic_panel_probe,
121 .remove = generic_panel_remove, 139 .remove = generic_panel_remove,
@@ -125,6 +143,10 @@ static struct omap_dss_driver generic_driver = {
125 .suspend = generic_panel_suspend, 143 .suspend = generic_panel_suspend,
126 .resume = generic_panel_resume, 144 .resume = generic_panel_resume,
127 145
146 .set_timings = generic_panel_set_timings,
147 .get_timings = generic_panel_get_timings,
148 .check_timings = generic_panel_check_timings,
149
128 .driver = { 150 .driver = {
129 .name = "generic_panel", 151 .name = "generic_panel",
130 .owner = THIS_MODULE, 152 .owner = THIS_MODULE,
diff --git a/drivers/video/omap2/displays/panel-taal.c b/drivers/video/omap2/displays/panel-taal.c
index 59769e85d41..4f3988a4108 100644
--- a/drivers/video/omap2/displays/panel-taal.c
+++ b/drivers/video/omap2/displays/panel-taal.c
@@ -30,6 +30,7 @@
30#include <linux/gpio.h> 30#include <linux/gpio.h>
31#include <linux/completion.h> 31#include <linux/completion.h>
32#include <linux/workqueue.h> 32#include <linux/workqueue.h>
33#include <linux/slab.h>
33 34
34#include <plat/display.h> 35#include <plat/display.h>
35 36
diff --git a/drivers/video/omap2/displays/panel-tpo-td043mtea1.c b/drivers/video/omap2/displays/panel-tpo-td043mtea1.c
index d578feee355..e866e76b13d 100644
--- a/drivers/video/omap2/displays/panel-tpo-td043mtea1.c
+++ b/drivers/video/omap2/displays/panel-tpo-td043mtea1.c
@@ -15,6 +15,7 @@
15#include <linux/regulator/consumer.h> 15#include <linux/regulator/consumer.h>
16#include <linux/gpio.h> 16#include <linux/gpio.h>
17#include <linux/err.h> 17#include <linux/err.h>
18#include <linux/slab.h>
18 19
19#include <plat/display.h> 20#include <plat/display.h>
20 21
diff --git a/drivers/video/omap2/dss/dss.c b/drivers/video/omap2/dss/dss.c
index 8254a4232a5..54344184dd7 100644
--- a/drivers/video/omap2/dss/dss.c
+++ b/drivers/video/omap2/dss/dss.c
@@ -590,6 +590,9 @@ int dss_init(bool skip_init)
590 } 590 }
591 } 591 }
592 592
593 dss.dsi_clk_source = DSS_SRC_DSS1_ALWON_FCLK;
594 dss.dispc_clk_source = DSS_SRC_DSS1_ALWON_FCLK;
595
593 dss_save_context(); 596 dss_save_context();
594 597
595 rev = dss_read_reg(DSS_REVISION); 598 rev = dss_read_reg(DSS_REVISION);
diff --git a/drivers/video/omap2/dss/manager.c b/drivers/video/omap2/dss/manager.c
index 9acef00c47e..0820986d4a6 100644
--- a/drivers/video/omap2/dss/manager.c
+++ b/drivers/video/omap2/dss/manager.c
@@ -23,6 +23,7 @@
23#define DSS_SUBSYS_NAME "MANAGER" 23#define DSS_SUBSYS_NAME "MANAGER"
24 24
25#include <linux/kernel.h> 25#include <linux/kernel.h>
26#include <linux/slab.h>
26#include <linux/module.h> 27#include <linux/module.h>
27#include <linux/platform_device.h> 28#include <linux/platform_device.h>
28#include <linux/spinlock.h> 29#include <linux/spinlock.h>
diff --git a/drivers/video/omap2/dss/overlay.c b/drivers/video/omap2/dss/overlay.c
index aed3f319434..82336583ade 100644
--- a/drivers/video/omap2/dss/overlay.c
+++ b/drivers/video/omap2/dss/overlay.c
@@ -29,6 +29,7 @@
29#include <linux/kobject.h> 29#include <linux/kobject.h>
30#include <linux/platform_device.h> 30#include <linux/platform_device.h>
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/slab.h>
32 33
33#include <plat/display.h> 34#include <plat/display.h>
34#include <plat/cpu.h> 35#include <plat/cpu.h>
diff --git a/drivers/video/omap2/omapfb/omapfb-main.c b/drivers/video/omap2/omapfb/omapfb-main.c
index 4a76917b7cc..4b4506da96d 100644
--- a/drivers/video/omap2/omapfb/omapfb-main.c
+++ b/drivers/video/omap2/omapfb/omapfb-main.c
@@ -22,6 +22,7 @@
22 22
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/slab.h>
25#include <linux/fb.h> 26#include <linux/fb.h>
26#include <linux/dma-mapping.h> 27#include <linux/dma-mapping.h>
27#include <linux/vmalloc.h> 28#include <linux/vmalloc.h>
diff --git a/drivers/video/omap2/vram.c b/drivers/video/omap2/vram.c
index 55a4de5e5d1..3b1237ad85e 100644
--- a/drivers/video/omap2/vram.c
+++ b/drivers/video/omap2/vram.c
@@ -23,6 +23,7 @@
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/mm.h> 24#include <linux/mm.h>
25#include <linux/list.h> 25#include <linux/list.h>
26#include <linux/slab.h>
26#include <linux/seq_file.h> 27#include <linux/seq_file.h>
27#include <linux/bootmem.h> 28#include <linux/bootmem.h>
28#include <linux/completion.h> 29#include <linux/completion.h>
@@ -511,13 +512,14 @@ static u32 omap_vram_sdram_size __initdata;
511static u32 omap_vram_def_sdram_size __initdata; 512static u32 omap_vram_def_sdram_size __initdata;
512static u32 omap_vram_def_sdram_start __initdata; 513static u32 omap_vram_def_sdram_start __initdata;
513 514
514static void __init omap_vram_early_vram(char **p) 515static int __init omap_vram_early_vram(char *p)
515{ 516{
516 omap_vram_def_sdram_size = memparse(*p, p); 517 omap_vram_def_sdram_size = memparse(p, &p);
517 if (**p == ',') 518 if (*p == ',')
518 omap_vram_def_sdram_start = simple_strtoul((*p) + 1, p, 16); 519 omap_vram_def_sdram_start = simple_strtoul(p + 1, &p, 16);
520 return 0;
519} 521}
520__early_param("vram=", omap_vram_early_vram); 522early_param("vram", omap_vram_early_vram);
521 523
522/* 524/*
523 * Called from map_io. We need to call to this early enough so that we 525 * Called from map_io. We need to call to this early enough so that we
diff --git a/drivers/video/output.c b/drivers/video/output.c
index 5137aa016b8..0d6f2cda936 100644
--- a/drivers/video/output.c
+++ b/drivers/video/output.c
@@ -23,6 +23,7 @@
23 */ 23 */
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/video_output.h> 25#include <linux/video_output.h>
26#include <linux/slab.h>
26#include <linux/err.h> 27#include <linux/err.h>
27#include <linux/ctype.h> 28#include <linux/ctype.h>
28 29
diff --git a/drivers/video/p9100.c b/drivers/video/p9100.c
index 7fa4ab01b0d..81440f2b909 100644
--- a/drivers/video/p9100.c
+++ b/drivers/video/p9100.c
@@ -10,7 +10,6 @@
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/errno.h> 11#include <linux/errno.h>
12#include <linux/string.h> 12#include <linux/string.h>
13#include <linux/slab.h>
14#include <linux/delay.h> 13#include <linux/delay.h>
15#include <linux/init.h> 14#include <linux/init.h>
16#include <linux/fb.h> 15#include <linux/fb.h>
diff --git a/drivers/video/platinumfb.c b/drivers/video/platinumfb.c
index 0a366d86f08..8a204e7a5b5 100644
--- a/drivers/video/platinumfb.c
+++ b/drivers/video/platinumfb.c
@@ -24,7 +24,6 @@
24#include <linux/errno.h> 24#include <linux/errno.h>
25#include <linux/string.h> 25#include <linux/string.h>
26#include <linux/mm.h> 26#include <linux/mm.h>
27#include <linux/slab.h>
28#include <linux/vmalloc.h> 27#include <linux/vmalloc.h>
29#include <linux/delay.h> 28#include <linux/delay.h>
30#include <linux/interrupt.h> 29#include <linux/interrupt.h>
diff --git a/drivers/video/pmag-aa-fb.c b/drivers/video/pmag-aa-fb.c
index 6515ec11c16..838424817de 100644
--- a/drivers/video/pmag-aa-fb.c
+++ b/drivers/video/pmag-aa-fb.c
@@ -28,7 +28,6 @@
28#include <linux/string.h> 28#include <linux/string.h>
29#include <linux/timer.h> 29#include <linux/timer.h>
30#include <linux/mm.h> 30#include <linux/mm.h>
31#include <linux/slab.h>
32#include <linux/delay.h> 31#include <linux/delay.h>
33#include <linux/init.h> 32#include <linux/init.h>
34#include <linux/fb.h> 33#include <linux/fb.h>
diff --git a/drivers/video/pnx4008/pnxrgbfb.c b/drivers/video/pnx4008/pnxrgbfb.c
index 4db6b48a871..b2252fea285 100644
--- a/drivers/video/pnx4008/pnxrgbfb.c
+++ b/drivers/video/pnx4008/pnxrgbfb.c
@@ -18,7 +18,6 @@
18#include <linux/errno.h> 18#include <linux/errno.h>
19#include <linux/string.h> 19#include <linux/string.h>
20#include <linux/mm.h> 20#include <linux/mm.h>
21#include <linux/slab.h>
22#include <linux/vmalloc.h> 21#include <linux/vmalloc.h>
23#include <linux/delay.h> 22#include <linux/delay.h>
24#include <linux/interrupt.h> 23#include <linux/interrupt.h>
diff --git a/drivers/video/pnx4008/sdum.c b/drivers/video/pnx4008/sdum.c
index 2aa09bce394..5ec4f2d439c 100644
--- a/drivers/video/pnx4008/sdum.c
+++ b/drivers/video/pnx4008/sdum.c
@@ -20,7 +20,6 @@
20#include <linux/string.h> 20#include <linux/string.h>
21#include <linux/mm.h> 21#include <linux/mm.h>
22#include <linux/tty.h> 22#include <linux/tty.h>
23#include <linux/slab.h>
24#include <linux/vmalloc.h> 23#include <linux/vmalloc.h>
25#include <linux/delay.h> 24#include <linux/delay.h>
26#include <linux/interrupt.h> 25#include <linux/interrupt.h>
@@ -29,6 +28,7 @@
29#include <linux/init.h> 28#include <linux/init.h>
30#include <linux/dma-mapping.h> 29#include <linux/dma-mapping.h>
31#include <linux/clk.h> 30#include <linux/clk.h>
31#include <linux/gfp.h>
32#include <asm/uaccess.h> 32#include <asm/uaccess.h>
33#include <mach/gpio.h> 33#include <mach/gpio.h>
34 34
diff --git a/drivers/video/pxa168fb.c b/drivers/video/pxa168fb.c
index 75285d3f393..c91a7f70f7b 100644
--- a/drivers/video/pxa168fb.c
+++ b/drivers/video/pxa168fb.c
@@ -668,7 +668,7 @@ static int __init pxa168fb_probe(struct platform_device *pdev)
668 /* 668 /*
669 * Map LCD controller registers. 669 * Map LCD controller registers.
670 */ 670 */
671 fbi->reg_base = ioremap_nocache(res->start, res->end - res->start); 671 fbi->reg_base = ioremap_nocache(res->start, resource_size(res));
672 if (fbi->reg_base == NULL) { 672 if (fbi->reg_base == NULL) {
673 ret = -ENOMEM; 673 ret = -ENOMEM;
674 goto failed; 674 goto failed;
diff --git a/drivers/video/q40fb.c b/drivers/video/q40fb.c
index de40a626dc7..fc32c323a38 100644
--- a/drivers/video/q40fb.c
+++ b/drivers/video/q40fb.c
@@ -14,7 +14,6 @@
14#include <linux/errno.h> 14#include <linux/errno.h>
15#include <linux/string.h> 15#include <linux/string.h>
16#include <linux/mm.h> 16#include <linux/mm.h>
17#include <linux/slab.h>
18#include <linux/delay.h> 17#include <linux/delay.h>
19#include <linux/interrupt.h> 18#include <linux/interrupt.h>
20#include <linux/platform_device.h> 19#include <linux/platform_device.h>
diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
index 7b63429f1a7..a6247fc081a 100644
--- a/drivers/video/s1d13xxxfb.c
+++ b/drivers/video/s1d13xxxfb.c
@@ -31,6 +31,7 @@
31#include <linux/fb.h> 31#include <linux/fb.h>
32#include <linux/spinlock_types.h> 32#include <linux/spinlock_types.h>
33#include <linux/spinlock.h> 33#include <linux/spinlock.h>
34#include <linux/slab.h>
34 35
35#include <asm/io.h> 36#include <asm/io.h>
36 37
diff --git a/drivers/video/s3c-fb.c b/drivers/video/s3c-fb.c
index 53cb722c45a..9682ecc60e1 100644
--- a/drivers/video/s3c-fb.c
+++ b/drivers/video/s3c-fb.c
@@ -16,8 +16,8 @@
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/dma-mapping.h> 18#include <linux/dma-mapping.h>
19#include <linux/slab.h>
19#include <linux/init.h> 20#include <linux/init.h>
20#include <linux/gfp.h>
21#include <linux/clk.h> 21#include <linux/clk.h>
22#include <linux/fb.h> 22#include <linux/fb.h>
23#include <linux/io.h> 23#include <linux/io.h>
diff --git a/drivers/video/s3fb.c b/drivers/video/s3fb.c
index c3fad34309e..d4471b4c037 100644
--- a/drivers/video/s3fb.c
+++ b/drivers/video/s3fb.c
@@ -17,7 +17,6 @@
17#include <linux/string.h> 17#include <linux/string.h>
18#include <linux/mm.h> 18#include <linux/mm.h>
19#include <linux/tty.h> 19#include <linux/tty.h>
20#include <linux/slab.h>
21#include <linux/delay.h> 20#include <linux/delay.h>
22#include <linux/fb.h> 21#include <linux/fb.h>
23#include <linux/svga.h> 22#include <linux/svga.h>
diff --git a/drivers/video/savage/savagefb-i2c.c b/drivers/video/savage/savagefb-i2c.c
index 574b29e9f8f..ed371c868b3 100644
--- a/drivers/video/savage/savagefb-i2c.c
+++ b/drivers/video/savage/savagefb-i2c.c
@@ -13,6 +13,7 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/gfp.h>
16#include <linux/pci.h> 17#include <linux/pci.h>
17#include <linux/fb.h> 18#include <linux/fb.h>
18 19
diff --git a/drivers/video/sh7760fb.c b/drivers/video/sh7760fb.c
index 9f6d6e61f0c..bea38fce247 100644
--- a/drivers/video/sh7760fb.c
+++ b/drivers/video/sh7760fb.c
@@ -26,6 +26,7 @@
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/platform_device.h> 28#include <linux/platform_device.h>
29#include <linux/slab.h>
29 30
30#include <asm/sh7760fb.h> 31#include <asm/sh7760fb.h>
31 32
diff --git a/drivers/video/sh_mobile_lcdcfb.c b/drivers/video/sh_mobile_lcdcfb.c
index bbd1dbf4026..e8c76994481 100644
--- a/drivers/video/sh_mobile_lcdcfb.c
+++ b/drivers/video/sh_mobile_lcdcfb.c
@@ -20,6 +20,7 @@
20#include <linux/interrupt.h> 20#include <linux/interrupt.h>
21#include <linux/vmalloc.h> 21#include <linux/vmalloc.h>
22#include <linux/ioctl.h> 22#include <linux/ioctl.h>
23#include <linux/slab.h>
23#include <video/sh_mobile_lcdc.h> 24#include <video/sh_mobile_lcdc.h>
24#include <asm/atomic.h> 25#include <asm/atomic.h>
25 26
@@ -694,6 +695,7 @@ static int sh_mobile_lcdc_setup_clocks(struct platform_device *pdev,
694 * 1) Enable Runtime PM 695 * 1) Enable Runtime PM
695 * 2) Force Runtime PM Resume since hardware is accessed from probe() 696 * 2) Force Runtime PM Resume since hardware is accessed from probe()
696 */ 697 */
698 priv->dev = &pdev->dev;
697 pm_runtime_enable(priv->dev); 699 pm_runtime_enable(priv->dev);
698 pm_runtime_resume(priv->dev); 700 pm_runtime_resume(priv->dev);
699 return 0; 701 return 0;
@@ -956,25 +958,24 @@ static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev)
956 958
957 if (!pdev->dev.platform_data) { 959 if (!pdev->dev.platform_data) {
958 dev_err(&pdev->dev, "no platform data defined\n"); 960 dev_err(&pdev->dev, "no platform data defined\n");
959 error = -EINVAL; 961 return -EINVAL;
960 goto err0;
961 } 962 }
962 963
963 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 964 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
964 i = platform_get_irq(pdev, 0); 965 i = platform_get_irq(pdev, 0);
965 if (!res || i < 0) { 966 if (!res || i < 0) {
966 dev_err(&pdev->dev, "cannot get platform resources\n"); 967 dev_err(&pdev->dev, "cannot get platform resources\n");
967 error = -ENOENT; 968 return -ENOENT;
968 goto err0;
969 } 969 }
970 970
971 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 971 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
972 if (!priv) { 972 if (!priv) {
973 dev_err(&pdev->dev, "cannot allocate device data\n"); 973 dev_err(&pdev->dev, "cannot allocate device data\n");
974 error = -ENOMEM; 974 return -ENOMEM;
975 goto err0;
976 } 975 }
977 976
977 platform_set_drvdata(pdev, priv);
978
978 error = request_irq(i, sh_mobile_lcdc_irq, IRQF_DISABLED, 979 error = request_irq(i, sh_mobile_lcdc_irq, IRQF_DISABLED,
979 dev_name(&pdev->dev), priv); 980 dev_name(&pdev->dev), priv);
980 if (error) { 981 if (error) {
@@ -983,8 +984,6 @@ static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev)
983 } 984 }
984 985
985 priv->irq = i; 986 priv->irq = i;
986 priv->dev = &pdev->dev;
987 platform_set_drvdata(pdev, priv);
988 pdata = pdev->dev.platform_data; 987 pdata = pdev->dev.platform_data;
989 988
990 j = 0; 989 j = 0;
@@ -1098,9 +1097,9 @@ static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev)
1098 info = ch->info; 1097 info = ch->info;
1099 1098
1100 if (info->fbdefio) { 1099 if (info->fbdefio) {
1101 priv->ch->sglist = vmalloc(sizeof(struct scatterlist) * 1100 ch->sglist = vmalloc(sizeof(struct scatterlist) *
1102 info->fix.smem_len >> PAGE_SHIFT); 1101 info->fix.smem_len >> PAGE_SHIFT);
1103 if (!priv->ch->sglist) { 1102 if (!ch->sglist) {
1104 dev_err(&pdev->dev, "cannot allocate sglist\n"); 1103 dev_err(&pdev->dev, "cannot allocate sglist\n");
1105 goto err1; 1104 goto err1;
1106 } 1105 }
@@ -1125,9 +1124,9 @@ static int __devinit sh_mobile_lcdc_probe(struct platform_device *pdev)
1125 } 1124 }
1126 1125
1127 return 0; 1126 return 0;
1128 err1: 1127err1:
1129 sh_mobile_lcdc_remove(pdev); 1128 sh_mobile_lcdc_remove(pdev);
1130 err0: 1129
1131 return error; 1130 return error;
1132} 1131}
1133 1132
@@ -1138,7 +1137,7 @@ static int sh_mobile_lcdc_remove(struct platform_device *pdev)
1138 int i; 1137 int i;
1139 1138
1140 for (i = 0; i < ARRAY_SIZE(priv->ch); i++) 1139 for (i = 0; i < ARRAY_SIZE(priv->ch); i++)
1141 if (priv->ch[i].info->dev) 1140 if (priv->ch[i].info && priv->ch[i].info->dev)
1142 unregister_framebuffer(priv->ch[i].info); 1141 unregister_framebuffer(priv->ch[i].info);
1143 1142
1144 sh_mobile_lcdc_stop(priv); 1143 sh_mobile_lcdc_stop(priv);
@@ -1161,7 +1160,8 @@ static int sh_mobile_lcdc_remove(struct platform_device *pdev)
1161 if (priv->dot_clk) 1160 if (priv->dot_clk)
1162 clk_put(priv->dot_clk); 1161 clk_put(priv->dot_clk);
1163 1162
1164 pm_runtime_disable(priv->dev); 1163 if (priv->dev)
1164 pm_runtime_disable(priv->dev);
1165 1165
1166 if (priv->base) 1166 if (priv->base)
1167 iounmap(priv->base); 1167 iounmap(priv->base);
diff --git a/drivers/video/sstfb.c b/drivers/video/sstfb.c
index 79840f11fec..dee64c3b1e6 100644
--- a/drivers/video/sstfb.c
+++ b/drivers/video/sstfb.c
@@ -86,7 +86,6 @@
86#include <linux/pci.h> 86#include <linux/pci.h>
87#include <linux/delay.h> 87#include <linux/delay.h>
88#include <linux/init.h> 88#include <linux/init.h>
89#include <linux/slab.h>
90#include <asm/io.h> 89#include <asm/io.h>
91#include <linux/uaccess.h> 90#include <linux/uaccess.h>
92#include <video/sstfb.h> 91#include <video/sstfb.h>
diff --git a/drivers/video/sunxvr1000.c b/drivers/video/sunxvr1000.c
index a8248c0b919..23e69e834a1 100644
--- a/drivers/video/sunxvr1000.c
+++ b/drivers/video/sunxvr1000.c
@@ -5,7 +5,6 @@
5 5
6#include <linux/module.h> 6#include <linux/module.h>
7#include <linux/kernel.h> 7#include <linux/kernel.h>
8#include <linux/slab.h>
9#include <linux/fb.h> 8#include <linux/fb.h>
10#include <linux/init.h> 9#include <linux/init.h>
11#include <linux/of_device.h> 10#include <linux/of_device.h>
diff --git a/drivers/video/sunxvr2500.c b/drivers/video/sunxvr2500.c
index b1dde09e701..5848436c19d 100644
--- a/drivers/video/sunxvr2500.c
+++ b/drivers/video/sunxvr2500.c
@@ -5,7 +5,6 @@
5 5
6#include <linux/module.h> 6#include <linux/module.h>
7#include <linux/kernel.h> 7#include <linux/kernel.h>
8#include <linux/slab.h>
9#include <linux/fb.h> 8#include <linux/fb.h>
10#include <linux/pci.h> 9#include <linux/pci.h>
11#include <linux/init.h> 10#include <linux/init.h>
diff --git a/drivers/video/sunxvr500.c b/drivers/video/sunxvr500.c
index 4cd50497264..b9c2b948d34 100644
--- a/drivers/video/sunxvr500.c
+++ b/drivers/video/sunxvr500.c
@@ -5,7 +5,6 @@
5 5
6#include <linux/module.h> 6#include <linux/module.h>
7#include <linux/kernel.h> 7#include <linux/kernel.h>
8#include <linux/slab.h>
9#include <linux/fb.h> 8#include <linux/fb.h>
10#include <linux/pci.h> 9#include <linux/pci.h>
11#include <linux/init.h> 10#include <linux/init.h>
@@ -242,11 +241,27 @@ static int __devinit e3d_set_fbinfo(struct e3d_info *ep)
242static int __devinit e3d_pci_register(struct pci_dev *pdev, 241static int __devinit e3d_pci_register(struct pci_dev *pdev,
243 const struct pci_device_id *ent) 242 const struct pci_device_id *ent)
244{ 243{
244 struct device_node *of_node;
245 const char *device_type;
245 struct fb_info *info; 246 struct fb_info *info;
246 struct e3d_info *ep; 247 struct e3d_info *ep;
247 unsigned int line_length; 248 unsigned int line_length;
248 int err; 249 int err;
249 250
251 of_node = pci_device_to_OF_node(pdev);
252 if (!of_node) {
253 printk(KERN_ERR "e3d: Cannot find OF node of %s\n",
254 pci_name(pdev));
255 return -ENODEV;
256 }
257
258 device_type = of_get_property(of_node, "device_type", NULL);
259 if (!device_type) {
260 printk(KERN_INFO "e3d: Ignoring secondary output device "
261 "at %s\n", pci_name(pdev));
262 return -ENODEV;
263 }
264
250 err = pci_enable_device(pdev); 265 err = pci_enable_device(pdev);
251 if (err < 0) { 266 if (err < 0) {
252 printk(KERN_ERR "e3d: Cannot enable PCI device %s\n", 267 printk(KERN_ERR "e3d: Cannot enable PCI device %s\n",
@@ -265,13 +280,7 @@ static int __devinit e3d_pci_register(struct pci_dev *pdev,
265 ep->info = info; 280 ep->info = info;
266 ep->pdev = pdev; 281 ep->pdev = pdev;
267 spin_lock_init(&ep->lock); 282 spin_lock_init(&ep->lock);
268 ep->of_node = pci_device_to_OF_node(pdev); 283 ep->of_node = of_node;
269 if (!ep->of_node) {
270 printk(KERN_ERR "e3d: Cannot find OF node of %s\n",
271 pci_name(pdev));
272 err = -ENODEV;
273 goto err_release_fb;
274 }
275 284
276 /* Read the PCI base register of the frame buffer, which we 285 /* Read the PCI base register of the frame buffer, which we
277 * need in order to interpret the RAMDAC_VID_*FB* values in 286 * need in order to interpret the RAMDAC_VID_*FB* values in
diff --git a/drivers/video/svgalib.c b/drivers/video/svgalib.c
index 9c710670157..fdb45674e2f 100644
--- a/drivers/video/svgalib.c
+++ b/drivers/video/svgalib.c
@@ -15,7 +15,6 @@
15#include <linux/string.h> 15#include <linux/string.h>
16#include <linux/fb.h> 16#include <linux/fb.h>
17#include <linux/svga.h> 17#include <linux/svga.h>
18#include <linux/slab.h>
19#include <asm/types.h> 18#include <asm/types.h>
20#include <asm/io.h> 19#include <asm/io.h>
21 20
diff --git a/drivers/video/syscopyarea.c b/drivers/video/syscopyarea.c
index a352d5f46bb..844a32fd38e 100644
--- a/drivers/video/syscopyarea.c
+++ b/drivers/video/syscopyarea.c
@@ -16,7 +16,6 @@
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/string.h> 17#include <linux/string.h>
18#include <linux/fb.h> 18#include <linux/fb.h>
19#include <linux/slab.h>
20#include <asm/types.h> 19#include <asm/types.h>
21#include <asm/io.h> 20#include <asm/io.h>
22#include "fb_draw.h" 21#include "fb_draw.h"
diff --git a/drivers/video/tcx.c b/drivers/video/tcx.c
index 45b883598bf..c0c2b18fcdc 100644
--- a/drivers/video/tcx.c
+++ b/drivers/video/tcx.c
@@ -12,7 +12,6 @@
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/errno.h> 13#include <linux/errno.h>
14#include <linux/string.h> 14#include <linux/string.h>
15#include <linux/slab.h>
16#include <linux/delay.h> 15#include <linux/delay.h>
17#include <linux/init.h> 16#include <linux/init.h>
18#include <linux/fb.h> 17#include <linux/fb.h>
diff --git a/drivers/video/tgafb.c b/drivers/video/tgafb.c
index a86046ff60a..1b3b1c718e8 100644
--- a/drivers/video/tgafb.c
+++ b/drivers/video/tgafb.c
@@ -25,7 +25,6 @@
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/pci.h> 26#include <linux/pci.h>
27#include <linux/selection.h> 27#include <linux/selection.h>
28#include <linux/slab.h>
29#include <linux/string.h> 28#include <linux/string.h>
30#include <linux/tc.h> 29#include <linux/tc.h>
31 30
diff --git a/drivers/video/tridentfb.c b/drivers/video/tridentfb.c
index 03a9c35e9f5..c6c77562839 100644
--- a/drivers/video/tridentfb.c
+++ b/drivers/video/tridentfb.c
@@ -19,6 +19,7 @@
19#include <linux/fb.h> 19#include <linux/fb.h>
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/pci.h> 21#include <linux/pci.h>
22#include <linux/slab.h>
22 23
23#include <linux/delay.h> 24#include <linux/delay.h>
24#include <video/vga.h> 25#include <video/vga.h>
diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
index 54fbb2995a5..7b8839ebf3c 100644
--- a/drivers/video/uvesafb.c
+++ b/drivers/video/uvesafb.c
@@ -18,6 +18,7 @@
18#include <linux/fb.h> 18#include <linux/fb.h>
19#include <linux/io.h> 19#include <linux/io.h>
20#include <linux/mutex.h> 20#include <linux/mutex.h>
21#include <linux/slab.h>
21#include <video/edid.h> 22#include <video/edid.h>
22#include <video/uvesafb.h> 23#include <video/uvesafb.h>
23#ifdef CONFIG_X86 24#ifdef CONFIG_X86
diff --git a/drivers/video/vermilion/vermilion.c b/drivers/video/vermilion/vermilion.c
index c18f1884b55..931a567f9af 100644
--- a/drivers/video/vermilion/vermilion.c
+++ b/drivers/video/vermilion/vermilion.c
@@ -33,6 +33,7 @@
33#include <linux/errno.h> 33#include <linux/errno.h>
34#include <linux/string.h> 34#include <linux/string.h>
35#include <linux/delay.h> 35#include <linux/delay.h>
36#include <linux/slab.h>
36#include <linux/mm.h> 37#include <linux/mm.h>
37#include <linux/fb.h> 38#include <linux/fb.h>
38#include <linux/pci.h> 39#include <linux/pci.h>
diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
index ef4128c8e57..0cadf7aee27 100644
--- a/drivers/video/vesafb.c
+++ b/drivers/video/vesafb.c
@@ -13,7 +13,6 @@
13#include <linux/errno.h> 13#include <linux/errno.h>
14#include <linux/string.h> 14#include <linux/string.h>
15#include <linux/mm.h> 15#include <linux/mm.h>
16#include <linux/slab.h>
17#include <linux/delay.h> 16#include <linux/delay.h>
18#include <linux/fb.h> 17#include <linux/fb.h>
19#include <linux/ioport.h> 18#include <linux/ioport.h>
@@ -226,7 +225,7 @@ static int __init vesafb_setup(char *options)
226 return 0; 225 return 0;
227} 226}
228 227
229static int __devinit vesafb_probe(struct platform_device *dev) 228static int __init vesafb_probe(struct platform_device *dev)
230{ 229{
231 struct fb_info *info; 230 struct fb_info *info;
232 int i, err; 231 int i, err;
@@ -477,7 +476,6 @@ err:
477} 476}
478 477
479static struct platform_driver vesafb_driver = { 478static struct platform_driver vesafb_driver = {
480 .probe = vesafb_probe,
481 .driver = { 479 .driver = {
482 .name = "vesafb", 480 .name = "vesafb",
483 }, 481 },
@@ -493,20 +491,21 @@ static int __init vesafb_init(void)
493 /* ignore error return of fb_get_options */ 491 /* ignore error return of fb_get_options */
494 fb_get_options("vesafb", &option); 492 fb_get_options("vesafb", &option);
495 vesafb_setup(option); 493 vesafb_setup(option);
496 ret = platform_driver_register(&vesafb_driver);
497 494
498 if (!ret) { 495 vesafb_device = platform_device_alloc("vesafb", 0);
499 vesafb_device = platform_device_alloc("vesafb", 0); 496 if (!vesafb_device)
497 return -ENOMEM;
500 498
501 if (vesafb_device) 499 ret = platform_device_add(vesafb_device);
502 ret = platform_device_add(vesafb_device); 500 if (!ret) {
503 else 501 ret = platform_driver_probe(&vesafb_driver, vesafb_probe);
504 ret = -ENOMEM; 502 if (ret)
503 platform_device_del(vesafb_device);
504 }
505 505
506 if (ret) { 506 if (ret) {
507 platform_device_put(vesafb_device); 507 platform_device_put(vesafb_device);
508 platform_driver_unregister(&vesafb_driver); 508 vesafb_device = NULL;
509 }
510 } 509 }
511 510
512 return ret; 511 return ret;
diff --git a/drivers/video/vfb.c b/drivers/video/vfb.c
index b8ab995fbda..9b5532b4de3 100644
--- a/drivers/video/vfb.c
+++ b/drivers/video/vfb.c
@@ -15,7 +15,6 @@
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/string.h> 16#include <linux/string.h>
17#include <linux/mm.h> 17#include <linux/mm.h>
18#include <linux/slab.h>
19#include <linux/vmalloc.h> 18#include <linux/vmalloc.h>
20#include <linux/delay.h> 19#include <linux/delay.h>
21#include <linux/interrupt.h> 20#include <linux/interrupt.h>
diff --git a/drivers/video/vga16fb.c b/drivers/video/vga16fb.c
index 76d8dae5b1b..bf638a47a5b 100644
--- a/drivers/video/vga16fb.c
+++ b/drivers/video/vga16fb.c
@@ -15,7 +15,6 @@
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/string.h> 16#include <linux/string.h>
17#include <linux/mm.h> 17#include <linux/mm.h>
18#include <linux/slab.h>
19#include <linux/delay.h> 18#include <linux/delay.h>
20#include <linux/fb.h> 19#include <linux/fb.h>
21#include <linux/ioport.h> 20#include <linux/ioport.h>
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index ce7783b63f6..777b38a06d4 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -21,6 +21,7 @@
21 21
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/seq_file.h> 23#include <linux/seq_file.h>
24#include <linux/slab.h>
24#include <linux/stat.h> 25#include <linux/stat.h>
25#define _MASTER_FILE 26#define _MASTER_FILE
26 27
diff --git a/drivers/video/vt8623fb.c b/drivers/video/vt8623fb.c
index 65ccd215d49..d31dc96f838 100644
--- a/drivers/video/vt8623fb.c
+++ b/drivers/video/vt8623fb.c
@@ -18,7 +18,6 @@
18#include <linux/string.h> 18#include <linux/string.h>
19#include <linux/mm.h> 19#include <linux/mm.h>
20#include <linux/tty.h> 20#include <linux/tty.h>
21#include <linux/slab.h>
22#include <linux/delay.h> 21#include <linux/delay.h>
23#include <linux/fb.h> 22#include <linux/fb.h>
24#include <linux/svga.h> 23#include <linux/svga.h>
diff --git a/drivers/video/w100fb.c b/drivers/video/w100fb.c
index 5d223959778..31b0e17ed09 100644
--- a/drivers/video/w100fb.c
+++ b/drivers/video/w100fb.c
@@ -30,6 +30,7 @@
30#include <linux/kernel.h> 30#include <linux/kernel.h>
31#include <linux/mm.h> 31#include <linux/mm.h>
32#include <linux/platform_device.h> 32#include <linux/platform_device.h>
33#include <linux/slab.h>
33#include <linux/string.h> 34#include <linux/string.h>
34#include <linux/vmalloc.h> 35#include <linux/vmalloc.h>
35#include <asm/io.h> 36#include <asm/io.h>
diff --git a/drivers/video/xen-fbfront.c b/drivers/video/xen-fbfront.c
index 603598f4dbb..fa97d3e7c21 100644
--- a/drivers/video/xen-fbfront.c
+++ b/drivers/video/xen-fbfront.c
@@ -23,6 +23,7 @@
23#include <linux/errno.h> 23#include <linux/errno.h>
24#include <linux/fb.h> 24#include <linux/fb.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/slab.h>
26#include <linux/vmalloc.h> 27#include <linux/vmalloc.h>
27#include <linux/mm.h> 28#include <linux/mm.h>
28 29
diff --git a/drivers/video/xilinxfb.c b/drivers/video/xilinxfb.c
index ed7c8d0ddcc..3fcb83f0388 100644
--- a/drivers/video/xilinxfb.c
+++ b/drivers/video/xilinxfb.c
@@ -34,6 +34,7 @@
34#include <linux/of_platform.h> 34#include <linux/of_platform.h>
35#include <linux/io.h> 35#include <linux/io.h>
36#include <linux/xilinxfb.h> 36#include <linux/xilinxfb.h>
37#include <linux/slab.h>
37#include <asm/dcr.h> 38#include <asm/dcr.h>
38 39
39#define DRIVER_NAME "xilinxfb" 40#define DRIVER_NAME "xilinxfb"
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index 369f2eebbad..bfec7c29486 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -24,6 +24,7 @@
24#include <linux/kthread.h> 24#include <linux/kthread.h>
25#include <linux/freezer.h> 25#include <linux/freezer.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/slab.h>
27 28
28struct virtio_balloon 29struct virtio_balloon
29{ 30{
@@ -102,7 +103,8 @@ static void fill_balloon(struct virtio_balloon *vb, size_t num)
102 num = min(num, ARRAY_SIZE(vb->pfns)); 103 num = min(num, ARRAY_SIZE(vb->pfns));
103 104
104 for (vb->num_pfns = 0; vb->num_pfns < num; vb->num_pfns++) { 105 for (vb->num_pfns = 0; vb->num_pfns < num; vb->num_pfns++) {
105 struct page *page = alloc_page(GFP_HIGHUSER | __GFP_NORETRY); 106 struct page *page = alloc_page(GFP_HIGHUSER | __GFP_NORETRY |
107 __GFP_NOMEMALLOC | __GFP_NOWARN);
106 if (!page) { 108 if (!page) {
107 if (printk_ratelimit()) 109 if (printk_ratelimit())
108 dev_printk(KERN_INFO, &vb->vdev->dev, 110 dev_printk(KERN_INFO, &vb->vdev->dev,
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
index 625447f645d..24747aef195 100644
--- a/drivers/virtio/virtio_pci.c
+++ b/drivers/virtio/virtio_pci.c
@@ -17,6 +17,7 @@
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/list.h> 18#include <linux/list.h>
19#include <linux/pci.h> 19#include <linux/pci.h>
20#include <linux/slab.h>
20#include <linux/interrupt.h> 21#include <linux/interrupt.h>
21#include <linux/virtio.h> 22#include <linux/virtio.h>
22#include <linux/virtio_config.h> 23#include <linux/virtio_config.h>
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 0db906b3c95..0f90634bcb8 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -20,6 +20,7 @@
20#include <linux/virtio_ring.h> 20#include <linux/virtio_ring.h>
21#include <linux/virtio_config.h> 21#include <linux/virtio_config.h>
22#include <linux/device.h> 22#include <linux/device.h>
23#include <linux/slab.h>
23 24
24/* virtio guest is communicating with a virtual "device" that actually runs on 25/* virtio guest is communicating with a virtual "device" that actually runs on
25 * a host processor. Memory barriers are used to control SMP effects. */ 26 * a host processor. Memory barriers are used to control SMP effects. */
diff --git a/drivers/vlynq/vlynq.c b/drivers/vlynq/vlynq.c
index 9554ad5f9af..f2d9e667972 100644
--- a/drivers/vlynq/vlynq.c
+++ b/drivers/vlynq/vlynq.c
@@ -30,6 +30,7 @@
30#include <linux/interrupt.h> 30#include <linux/interrupt.h>
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/io.h> 32#include <linux/io.h>
33#include <linux/slab.h>
33 34
34#include <linux/vlynq.h> 35#include <linux/vlynq.h>
35 36
diff --git a/drivers/w1/masters/ds1wm.c b/drivers/w1/masters/ds1wm.c
index 37f08c85060..6b85e7fefa4 100644
--- a/drivers/w1/masters/ds1wm.c
+++ b/drivers/w1/masters/ds1wm.c
@@ -20,6 +20,7 @@
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include <linux/mfd/core.h> 21#include <linux/mfd/core.h>
22#include <linux/mfd/ds1wm.h> 22#include <linux/mfd/ds1wm.h>
23#include <linux/slab.h>
23 24
24#include <asm/io.h> 25#include <asm/io.h>
25 26
diff --git a/drivers/w1/masters/ds2490.c b/drivers/w1/masters/ds2490.c
index 59ad6e95af8..02bf7bf7160 100644
--- a/drivers/w1/masters/ds2490.c
+++ b/drivers/w1/masters/ds2490.c
@@ -23,6 +23,7 @@
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/mod_devicetable.h> 24#include <linux/mod_devicetable.h>
25#include <linux/usb.h> 25#include <linux/usb.h>
26#include <linux/slab.h>
26 27
27#include "../w1_int.h" 28#include "../w1_int.h"
28#include "../w1.h" 29#include "../w1.h"
diff --git a/drivers/w1/masters/mxc_w1.c b/drivers/w1/masters/mxc_w1.c
index 492670358cb..a3b6a74c67a 100644
--- a/drivers/w1/masters/mxc_w1.c
+++ b/drivers/w1/masters/mxc_w1.c
@@ -21,6 +21,7 @@
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/clk.h> 23#include <linux/clk.h>
24#include <linux/slab.h>
24#include <linux/delay.h> 25#include <linux/delay.h>
25#include <linux/io.h> 26#include <linux/io.h>
26 27
diff --git a/drivers/w1/masters/omap_hdq.c b/drivers/w1/masters/omap_hdq.c
index 22977d30f89..3a7e9ff8a74 100644
--- a/drivers/w1/masters/omap_hdq.c
+++ b/drivers/w1/masters/omap_hdq.c
@@ -12,9 +12,11 @@
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <linux/interrupt.h> 14#include <linux/interrupt.h>
15#include <linux/slab.h>
15#include <linux/err.h> 16#include <linux/err.h>
16#include <linux/clk.h> 17#include <linux/clk.h>
17#include <linux/io.h> 18#include <linux/io.h>
19#include <linux/sched.h>
18 20
19#include <asm/irq.h> 21#include <asm/irq.h>
20#include <mach/hardware.h> 22#include <mach/hardware.h>
diff --git a/drivers/w1/masters/w1-gpio.c b/drivers/w1/masters/w1-gpio.c
index 6f8866d6a90..fcbe742188a 100644
--- a/drivers/w1/masters/w1-gpio.c
+++ b/drivers/w1/masters/w1-gpio.c
@@ -11,6 +11,7 @@
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <linux/slab.h>
14#include <linux/w1-gpio.h> 15#include <linux/w1-gpio.h>
15 16
16#include "../w1.h" 17#include "../w1.h"
diff --git a/drivers/w1/slaves/w1_ds2433.c b/drivers/w1/slaves/w1_ds2433.c
index 13944714882..d2bf32118a9 100644
--- a/drivers/w1/slaves/w1_ds2433.c
+++ b/drivers/w1/slaves/w1_ds2433.c
@@ -13,6 +13,7 @@
13#include <linux/device.h> 13#include <linux/device.h>
14#include <linux/types.h> 14#include <linux/types.h>
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/slab.h>
16#ifdef CONFIG_W1_SLAVE_DS2433_CRC 17#ifdef CONFIG_W1_SLAVE_DS2433_CRC
17#include <linux/crc16.h> 18#include <linux/crc16.h>
18 19
diff --git a/drivers/w1/slaves/w1_ds2760.c b/drivers/w1/slaves/w1_ds2760.c
index 59f708efe25..6e153343e11 100644
--- a/drivers/w1/slaves/w1_ds2760.c
+++ b/drivers/w1/slaves/w1_ds2760.c
@@ -16,6 +16,7 @@
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/mutex.h> 17#include <linux/mutex.h>
18#include <linux/idr.h> 18#include <linux/idr.h>
19#include <linux/gfp.h>
19 20
20#include "../w1.h" 21#include "../w1.h"
21#include "../w1_int.h" 22#include "../w1_int.h"
diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c
index 1ed3d554e37..17726a05a0a 100644
--- a/drivers/w1/slaves/w1_therm.c
+++ b/drivers/w1/slaves/w1_therm.c
@@ -115,9 +115,8 @@ static struct w1_therm_family_converter w1_therm_families[] = {
115 115
116static inline int w1_DS18B20_convert_temp(u8 rom[9]) 116static inline int w1_DS18B20_convert_temp(u8 rom[9])
117{ 117{
118 int t = ((s16)rom[1] << 8) | rom[0]; 118 s16 t = le16_to_cpup((__le16 *)rom);
119 t = t*1000/16; 119 return t*1000/16;
120 return t;
121} 120}
122 121
123static inline int w1_DS18S20_convert_temp(u8 rom[9]) 122static inline int w1_DS18S20_convert_temp(u8 rom[9])
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index 4a46ed58ece..b50be3f1073 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -23,6 +23,7 @@
23#include <linux/list.h> 23#include <linux/list.h>
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/kthread.h> 25#include <linux/kthread.h>
26#include <linux/slab.h>
26 27
27#include "w1.h" 28#include "w1.h"
28#include "w1_log.h" 29#include "w1_log.h"
diff --git a/drivers/w1/w1_netlink.c b/drivers/w1/w1_netlink.c
index 45c126fea31..7e667bc77ef 100644
--- a/drivers/w1/w1_netlink.c
+++ b/drivers/w1/w1_netlink.c
@@ -19,6 +19,7 @@
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 20 */
21 21
22#include <linux/slab.h>
22#include <linux/skbuff.h> 23#include <linux/skbuff.h>
23#include <linux/netlink.h> 24#include <linux/netlink.h>
24#include <linux/connector.h> 25#include <linux/connector.h>
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index bdcdbd53da8..0bf5020d0d3 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -55,11 +55,6 @@ config SOFT_WATCHDOG
55 To compile this driver as a module, choose M here: the 55 To compile this driver as a module, choose M here: the
56 module will be called softdog. 56 module will be called softdog.
57 57
58config MAX63XX_WATCHDOG
59 tristate "Max63xx watchdog"
60 help
61 Support for memory mapped max63{69,70,71,72,73,74} watchdog timer.
62
63config WM831X_WATCHDOG 58config WM831X_WATCHDOG
64 tristate "WM831x watchdog" 59 tristate "WM831x watchdog"
65 depends on MFD_WM831X 60 depends on MFD_WM831X
@@ -199,10 +194,10 @@ config EP93XX_WATCHDOG
199 194
200config OMAP_WATCHDOG 195config OMAP_WATCHDOG
201 tristate "OMAP Watchdog" 196 tristate "OMAP Watchdog"
202 depends on ARCH_OMAP16XX || ARCH_OMAP2 || ARCH_OMAP3 197 depends on ARCH_OMAP16XX || ARCH_OMAP2PLUS
203 help 198 help
204 Support for TI OMAP1610/OMAP1710/OMAP2420/OMAP3430 watchdog. Say 'Y' 199 Support for TI OMAP1610/OMAP1710/OMAP2420/OMAP3430/OMAP4430 watchdog. Say 'Y'
205 here to enable the OMAP1610/OMAP1710/OMAP2420/OMAP3430 watchdog timer. 200 here to enable the OMAP1610/OMAP1710/OMAP2420/OMAP3430/OMAP4430 watchdog timer.
206 201
207config PNX4008_WATCHDOG 202config PNX4008_WATCHDOG
208 tristate "PNX4008 Watchdog" 203 tristate "PNX4008 Watchdog"
@@ -305,6 +300,12 @@ config TS72XX_WATCHDOG
305 To compile this driver as a module, choose M here: the 300 To compile this driver as a module, choose M here: the
306 module will be called ts72xx_wdt. 301 module will be called ts72xx_wdt.
307 302
303config MAX63XX_WATCHDOG
304 tristate "Max63xx watchdog"
305 depends on ARM && HAS_IOMEM
306 help
307 Support for memory mapped max63{69,70,71,72,73,74} watchdog timer.
308
308# AVR32 Architecture 309# AVR32 Architecture
309 310
310config AT32AP700X_WDT 311config AT32AP700X_WDT
diff --git a/drivers/watchdog/adx_wdt.c b/drivers/watchdog/adx_wdt.c
index a5ca7a6ee13..af6e6b16475 100644
--- a/drivers/watchdog/adx_wdt.c
+++ b/drivers/watchdog/adx_wdt.c
@@ -7,6 +7,7 @@
7 */ 7 */
8 8
9#include <linux/fs.h> 9#include <linux/fs.h>
10#include <linux/gfp.h>
10#include <linux/io.h> 11#include <linux/io.h>
11#include <linux/miscdevice.h> 12#include <linux/miscdevice.h>
12#include <linux/module.h> 13#include <linux/module.h>
diff --git a/drivers/watchdog/at32ap700x_wdt.c b/drivers/watchdog/at32ap700x_wdt.c
index 6873376f986..1cddf92cb9a 100644
--- a/drivers/watchdog/at32ap700x_wdt.c
+++ b/drivers/watchdog/at32ap700x_wdt.c
@@ -32,6 +32,7 @@
32#include <linux/uaccess.h> 32#include <linux/uaccess.h>
33#include <linux/io.h> 33#include <linux/io.h>
34#include <linux/spinlock.h> 34#include <linux/spinlock.h>
35#include <linux/slab.h>
35 36
36#define TIMEOUT_MIN 1 37#define TIMEOUT_MIN 1
37#define TIMEOUT_MAX 2 38#define TIMEOUT_MAX 2
diff --git a/drivers/watchdog/booke_wdt.c b/drivers/watchdog/booke_wdt.c
index 8b724aad682..801ead19149 100644
--- a/drivers/watchdog/booke_wdt.c
+++ b/drivers/watchdog/booke_wdt.c
@@ -44,7 +44,7 @@ u32 booke_wdt_period = WDT_PERIOD_DEFAULT;
44 44
45#ifdef CONFIG_FSL_BOOKE 45#ifdef CONFIG_FSL_BOOKE
46#define WDTP(x) ((((x)&0x3)<<30)|(((x)&0x3c)<<15)) 46#define WDTP(x) ((((x)&0x3)<<30)|(((x)&0x3c)<<15))
47#define WDTP_MASK (WDTP(0)) 47#define WDTP_MASK (WDTP(0x3f))
48#else 48#else
49#define WDTP(x) (TCR_WP(x)) 49#define WDTP(x) (TCR_WP(x))
50#define WDTP_MASK (TCR_WP_MASK) 50#define WDTP_MASK (TCR_WP_MASK)
@@ -121,7 +121,7 @@ static ssize_t booke_wdt_write(struct file *file, const char __user *buf,
121 return count; 121 return count;
122} 122}
123 123
124static const struct watchdog_info ident = { 124static struct watchdog_info ident = {
125 .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING, 125 .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
126 .identity = "PowerPC Book-E Watchdog", 126 .identity = "PowerPC Book-E Watchdog",
127}; 127};
diff --git a/drivers/watchdog/cpwd.c b/drivers/watchdog/cpwd.c
index 37ea052d4de..ba2efce4b40 100644
--- a/drivers/watchdog/cpwd.c
+++ b/drivers/watchdog/cpwd.c
@@ -24,6 +24,7 @@
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/ioport.h> 25#include <linux/ioport.h>
26#include <linux/timer.h> 26#include <linux/timer.h>
27#include <linux/slab.h>
27#include <linux/smp_lock.h> 28#include <linux/smp_lock.h>
28#include <linux/io.h> 29#include <linux/io.h>
29#include <linux/of.h> 30#include <linux/of.h>
diff --git a/drivers/watchdog/davinci_wdt.c b/drivers/watchdog/davinci_wdt.c
index 56162c87f5d..596ba604e78 100644
--- a/drivers/watchdog/davinci_wdt.c
+++ b/drivers/watchdog/davinci_wdt.c
@@ -26,6 +26,7 @@
26#include <linux/io.h> 26#include <linux/io.h>
27#include <linux/device.h> 27#include <linux/device.h>
28#include <linux/clk.h> 28#include <linux/clk.h>
29#include <linux/slab.h>
29 30
30#define MODULE_NAME "DAVINCI-WDT: " 31#define MODULE_NAME "DAVINCI-WDT: "
31 32
diff --git a/drivers/watchdog/ep93xx_wdt.c b/drivers/watchdog/ep93xx_wdt.c
index 88ed54e50f7..59359c9a5e0 100644
--- a/drivers/watchdog/ep93xx_wdt.c
+++ b/drivers/watchdog/ep93xx_wdt.c
@@ -244,7 +244,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started");
244module_param(timeout, int, 0); 244module_param(timeout, int, 0);
245MODULE_PARM_DESC(timeout, 245MODULE_PARM_DESC(timeout,
246 "Watchdog timeout in seconds. (1<=timeout<=3600, default=" 246 "Watchdog timeout in seconds. (1<=timeout<=3600, default="
247 __MODULE_STRING(WATCHDOG_TIMEOUT) ")"); 247 __MODULE_STRING(WDT_TIMEOUT) ")");
248 248
249MODULE_AUTHOR("Ray Lehtiniemi <rayl@mail.com>," 249MODULE_AUTHOR("Ray Lehtiniemi <rayl@mail.com>,"
250 "Alessandro Zummo <a.zummo@towertech.it>"); 250 "Alessandro Zummo <a.zummo@towertech.it>");
diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c
index 70c2c24660d..809e7167a62 100644
--- a/drivers/watchdog/hpwdt.c
+++ b/drivers/watchdog/hpwdt.c
@@ -39,7 +39,6 @@
39#include <linux/efi.h> 39#include <linux/efi.h>
40#include <linux/string.h> 40#include <linux/string.h>
41#include <linux/bootmem.h> 41#include <linux/bootmem.h>
42#include <linux/slab.h>
43#include <asm/desc.h> 42#include <asm/desc.h>
44#include <asm/cacheflush.h> 43#include <asm/cacheflush.h>
45 44
@@ -443,7 +442,7 @@ static void hpwdt_ping(void)
443static int hpwdt_change_timer(int new_margin) 442static int hpwdt_change_timer(int new_margin)
444{ 443{
445 /* Arbitrary, can't find the card's limits */ 444 /* Arbitrary, can't find the card's limits */
446 if (new_margin < 30 || new_margin > 600) { 445 if (new_margin < 5 || new_margin > 600) {
447 printk(KERN_WARNING 446 printk(KERN_WARNING
448 "hpwdt: New value passed in is invalid: %d seconds.\n", 447 "hpwdt: New value passed in is invalid: %d seconds.\n",
449 new_margin); 448 new_margin);
diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c
index 44bc6aa46ed..8da88603537 100644
--- a/drivers/watchdog/iTCO_wdt.c
+++ b/drivers/watchdog/iTCO_wdt.c
@@ -115,8 +115,37 @@ enum iTCO_chipsets {
115 TCO_3420, /* 3420 */ 115 TCO_3420, /* 3420 */
116 TCO_3450, /* 3450 */ 116 TCO_3450, /* 3450 */
117 TCO_EP80579, /* EP80579 */ 117 TCO_EP80579, /* EP80579 */
118 TCO_CPTD, /* CPT Desktop */ 118 TCO_CPT1, /* Cougar Point */
119 TCO_CPTM, /* CPT Mobile */ 119 TCO_CPT2, /* Cougar Point Desktop */
120 TCO_CPT3, /* Cougar Point Mobile */
121 TCO_CPT4, /* Cougar Point */
122 TCO_CPT5, /* Cougar Point */
123 TCO_CPT6, /* Cougar Point */
124 TCO_CPT7, /* Cougar Point */
125 TCO_CPT8, /* Cougar Point */
126 TCO_CPT9, /* Cougar Point */
127 TCO_CPT10, /* Cougar Point */
128 TCO_CPT11, /* Cougar Point */
129 TCO_CPT12, /* Cougar Point */
130 TCO_CPT13, /* Cougar Point */
131 TCO_CPT14, /* Cougar Point */
132 TCO_CPT15, /* Cougar Point */
133 TCO_CPT16, /* Cougar Point */
134 TCO_CPT17, /* Cougar Point */
135 TCO_CPT18, /* Cougar Point */
136 TCO_CPT19, /* Cougar Point */
137 TCO_CPT20, /* Cougar Point */
138 TCO_CPT21, /* Cougar Point */
139 TCO_CPT22, /* Cougar Point */
140 TCO_CPT23, /* Cougar Point */
141 TCO_CPT24, /* Cougar Point */
142 TCO_CPT25, /* Cougar Point */
143 TCO_CPT26, /* Cougar Point */
144 TCO_CPT27, /* Cougar Point */
145 TCO_CPT28, /* Cougar Point */
146 TCO_CPT29, /* Cougar Point */
147 TCO_CPT30, /* Cougar Point */
148 TCO_CPT31, /* Cougar Point */
120}; 149};
121 150
122static struct { 151static struct {
@@ -173,8 +202,37 @@ static struct {
173 {"3420", 2}, 202 {"3420", 2},
174 {"3450", 2}, 203 {"3450", 2},
175 {"EP80579", 2}, 204 {"EP80579", 2},
176 {"CPT Desktop", 2}, 205 {"Cougar Point", 2},
177 {"CPT Mobile", 2}, 206 {"Cougar Point", 2},
207 {"Cougar Point", 2},
208 {"Cougar Point", 2},
209 {"Cougar Point", 2},
210 {"Cougar Point", 2},
211 {"Cougar Point", 2},
212 {"Cougar Point", 2},
213 {"Cougar Point", 2},
214 {"Cougar Point", 2},
215 {"Cougar Point", 2},
216 {"Cougar Point", 2},
217 {"Cougar Point", 2},
218 {"Cougar Point", 2},
219 {"Cougar Point", 2},
220 {"Cougar Point", 2},
221 {"Cougar Point", 2},
222 {"Cougar Point", 2},
223 {"Cougar Point", 2},
224 {"Cougar Point", 2},
225 {"Cougar Point", 2},
226 {"Cougar Point", 2},
227 {"Cougar Point", 2},
228 {"Cougar Point", 2},
229 {"Cougar Point", 2},
230 {"Cougar Point", 2},
231 {"Cougar Point", 2},
232 {"Cougar Point", 2},
233 {"Cougar Point", 2},
234 {"Cougar Point", 2},
235 {"Cougar Point", 2},
178 {NULL, 0} 236 {NULL, 0}
179}; 237};
180 238
@@ -259,8 +317,37 @@ static struct pci_device_id iTCO_wdt_pci_tbl[] = {
259 { ITCO_PCI_DEVICE(0x3b14, TCO_3420)}, 317 { ITCO_PCI_DEVICE(0x3b14, TCO_3420)},
260 { ITCO_PCI_DEVICE(0x3b16, TCO_3450)}, 318 { ITCO_PCI_DEVICE(0x3b16, TCO_3450)},
261 { ITCO_PCI_DEVICE(0x5031, TCO_EP80579)}, 319 { ITCO_PCI_DEVICE(0x5031, TCO_EP80579)},
262 { ITCO_PCI_DEVICE(0x1c42, TCO_CPTD)}, 320 { ITCO_PCI_DEVICE(0x1c41, TCO_CPT1)},
263 { ITCO_PCI_DEVICE(0x1c43, TCO_CPTM)}, 321 { ITCO_PCI_DEVICE(0x1c42, TCO_CPT2)},
322 { ITCO_PCI_DEVICE(0x1c43, TCO_CPT3)},
323 { ITCO_PCI_DEVICE(0x1c44, TCO_CPT4)},
324 { ITCO_PCI_DEVICE(0x1c45, TCO_CPT5)},
325 { ITCO_PCI_DEVICE(0x1c46, TCO_CPT6)},
326 { ITCO_PCI_DEVICE(0x1c47, TCO_CPT7)},
327 { ITCO_PCI_DEVICE(0x1c48, TCO_CPT8)},
328 { ITCO_PCI_DEVICE(0x1c49, TCO_CPT9)},
329 { ITCO_PCI_DEVICE(0x1c4a, TCO_CPT10)},
330 { ITCO_PCI_DEVICE(0x1c4b, TCO_CPT11)},
331 { ITCO_PCI_DEVICE(0x1c4c, TCO_CPT12)},
332 { ITCO_PCI_DEVICE(0x1c4d, TCO_CPT13)},
333 { ITCO_PCI_DEVICE(0x1c4e, TCO_CPT14)},
334 { ITCO_PCI_DEVICE(0x1c4f, TCO_CPT15)},
335 { ITCO_PCI_DEVICE(0x1c50, TCO_CPT16)},
336 { ITCO_PCI_DEVICE(0x1c51, TCO_CPT17)},
337 { ITCO_PCI_DEVICE(0x1c52, TCO_CPT18)},
338 { ITCO_PCI_DEVICE(0x1c53, TCO_CPT19)},
339 { ITCO_PCI_DEVICE(0x1c54, TCO_CPT20)},
340 { ITCO_PCI_DEVICE(0x1c55, TCO_CPT21)},
341 { ITCO_PCI_DEVICE(0x1c56, TCO_CPT22)},
342 { ITCO_PCI_DEVICE(0x1c57, TCO_CPT23)},
343 { ITCO_PCI_DEVICE(0x1c58, TCO_CPT24)},
344 { ITCO_PCI_DEVICE(0x1c59, TCO_CPT25)},
345 { ITCO_PCI_DEVICE(0x1c5a, TCO_CPT26)},
346 { ITCO_PCI_DEVICE(0x1c5b, TCO_CPT27)},
347 { ITCO_PCI_DEVICE(0x1c5c, TCO_CPT28)},
348 { ITCO_PCI_DEVICE(0x1c5d, TCO_CPT29)},
349 { ITCO_PCI_DEVICE(0x1c5e, TCO_CPT30)},
350 { ITCO_PCI_DEVICE(0x1c5f, TCO_CPT31)},
264 { 0, }, /* End of list */ 351 { 0, }, /* End of list */
265}; 352};
266MODULE_DEVICE_TABLE(pci, iTCO_wdt_pci_tbl); 353MODULE_DEVICE_TABLE(pci, iTCO_wdt_pci_tbl);
diff --git a/drivers/watchdog/ibmasr.c b/drivers/watchdog/ibmasr.c
index 89fcefcc851..195e0f798e7 100644
--- a/drivers/watchdog/ibmasr.c
+++ b/drivers/watchdog/ibmasr.c
@@ -12,7 +12,6 @@
12 12
13#include <linux/fs.h> 13#include <linux/fs.h>
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/slab.h>
16#include <linux/module.h> 15#include <linux/module.h>
17#include <linux/pci.h> 16#include <linux/pci.h>
18#include <linux/timer.h> 17#include <linux/timer.h>
diff --git a/drivers/watchdog/max63xx_wdt.c b/drivers/watchdog/max63xx_wdt.c
index 6eb91d75760..3053ff05ca4 100644
--- a/drivers/watchdog/max63xx_wdt.c
+++ b/drivers/watchdog/max63xx_wdt.c
@@ -28,6 +28,7 @@
28#include <linux/uaccess.h> 28#include <linux/uaccess.h>
29#include <linux/io.h> 29#include <linux/io.h>
30#include <linux/device.h> 30#include <linux/device.h>
31#include <linux/slab.h>
31 32
32#define DEFAULT_HEARTBEAT 60 33#define DEFAULT_HEARTBEAT 60
33#define MAX_HEARTBEAT 60 34#define MAX_HEARTBEAT 60
@@ -153,9 +154,14 @@ static void max63xx_wdt_enable(struct max63xx_timeout *entry)
153 154
154static void max63xx_wdt_disable(void) 155static void max63xx_wdt_disable(void)
155{ 156{
157 u8 val;
158
156 spin_lock(&io_lock); 159 spin_lock(&io_lock);
157 160
158 __raw_writeb(3, wdt_base); 161 val = __raw_readb(wdt_base);
162 val &= ~MAX6369_WDSET;
163 val |= 3;
164 __raw_writeb(val, wdt_base);
159 165
160 spin_unlock(&io_lock); 166 spin_unlock(&io_lock);
161 167
diff --git a/drivers/watchdog/mpcore_wdt.c b/drivers/watchdog/mpcore_wdt.c
index b0646dac924..016c6a791ca 100644
--- a/drivers/watchdog/mpcore_wdt.c
+++ b/drivers/watchdog/mpcore_wdt.c
@@ -30,6 +30,7 @@
30#include <linux/interrupt.h> 30#include <linux/interrupt.h>
31#include <linux/platform_device.h> 31#include <linux/platform_device.h>
32#include <linux/uaccess.h> 32#include <linux/uaccess.h>
33#include <linux/slab.h>
33 34
34#include <asm/hardware/arm_twd.h> 35#include <asm/hardware/arm_twd.h>
35 36
diff --git a/drivers/watchdog/nuc900_wdt.c b/drivers/watchdog/nuc900_wdt.c
index adefe3a9d51..6cee33d4b16 100644
--- a/drivers/watchdog/nuc900_wdt.c
+++ b/drivers/watchdog/nuc900_wdt.c
@@ -20,6 +20,7 @@
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/moduleparam.h> 21#include <linux/moduleparam.h>
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/slab.h>
23#include <linux/interrupt.h> 24#include <linux/interrupt.h>
24#include <linux/types.h> 25#include <linux/types.h>
25#include <linux/watchdog.h> 26#include <linux/watchdog.h>
diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index c6aaf284574..76b58abf445 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -42,6 +42,7 @@
42#include <linux/bitops.h> 42#include <linux/bitops.h>
43#include <linux/io.h> 43#include <linux/io.h>
44#include <linux/uaccess.h> 44#include <linux/uaccess.h>
45#include <linux/slab.h>
45#include <mach/hardware.h> 46#include <mach/hardware.h>
46#include <plat/prcm.h> 47#include <plat/prcm.h>
47 48
diff --git a/drivers/watchdog/pika_wdt.c b/drivers/watchdog/pika_wdt.c
index 435ec2aed4f..2d22e996e99 100644
--- a/drivers/watchdog/pika_wdt.c
+++ b/drivers/watchdog/pika_wdt.c
@@ -52,7 +52,7 @@ static struct {
52 struct timer_list timer; /* The timer that pings the watchdog */ 52 struct timer_list timer; /* The timer that pings the watchdog */
53} pikawdt_private; 53} pikawdt_private;
54 54
55static const struct watchdog_info ident = { 55static struct watchdog_info ident = {
56 .identity = DRV_NAME, 56 .identity = DRV_NAME,
57 .options = WDIOF_CARDRESET | 57 .options = WDIOF_CARDRESET |
58 WDIOF_SETTIMEOUT | 58 WDIOF_SETTIMEOUT |
diff --git a/drivers/watchdog/pnx4008_wdt.c b/drivers/watchdog/pnx4008_wdt.c
index c7a9479934a..bf5b97c546e 100644
--- a/drivers/watchdog/pnx4008_wdt.c
+++ b/drivers/watchdog/pnx4008_wdt.c
@@ -30,6 +30,7 @@
30#include <linux/spinlock.h> 30#include <linux/spinlock.h>
31#include <linux/uaccess.h> 31#include <linux/uaccess.h>
32#include <linux/io.h> 32#include <linux/io.h>
33#include <linux/slab.h>
33#include <mach/hardware.h> 34#include <mach/hardware.h>
34 35
35#define MODULE_NAME "PNX4008-WDT: " 36#define MODULE_NAME "PNX4008-WDT: "
diff --git a/drivers/watchdog/riowd.c b/drivers/watchdog/riowd.c
index ae57bf9e1b0..ea7f803f624 100644
--- a/drivers/watchdog/riowd.c
+++ b/drivers/watchdog/riowd.c
@@ -15,6 +15,7 @@
15#include <linux/of_device.h> 15#include <linux/of_device.h>
16#include <linux/io.h> 16#include <linux/io.h>
17#include <linux/uaccess.h> 17#include <linux/uaccess.h>
18#include <linux/slab.h>
18 19
19 20
20/* RIO uses the NatSemi Super I/O power management logical device 21/* RIO uses the NatSemi Super I/O power management logical device
diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c
index 8760a26ab2a..e4cebef5517 100644
--- a/drivers/watchdog/s3c2410_wdt.c
+++ b/drivers/watchdog/s3c2410_wdt.c
@@ -37,6 +37,7 @@
37#include <linux/uaccess.h> 37#include <linux/uaccess.h>
38#include <linux/io.h> 38#include <linux/io.h>
39#include <linux/cpufreq.h> 39#include <linux/cpufreq.h>
40#include <linux/slab.h>
40 41
41#include <mach/map.h> 42#include <mach/map.h>
42 43
diff --git a/drivers/watchdog/sb_wdog.c b/drivers/watchdog/sb_wdog.c
index c8eadd47817..88c83aa5730 100644
--- a/drivers/watchdog/sb_wdog.c
+++ b/drivers/watchdog/sb_wdog.c
@@ -67,8 +67,8 @@ static DEFINE_SPINLOCK(sbwd_lock);
67void sbwdog_set(char __iomem *wdog, unsigned long t) 67void sbwdog_set(char __iomem *wdog, unsigned long t)
68{ 68{
69 spin_lock(&sbwd_lock); 69 spin_lock(&sbwd_lock);
70 __raw_writeb(0, wdog - 0x10); 70 __raw_writeb(0, wdog);
71 __raw_writeq(t & 0x7fffffUL, wdog); 71 __raw_writeq(t & 0x7fffffUL, wdog - 0x10);
72 spin_unlock(&sbwd_lock); 72 spin_unlock(&sbwd_lock);
73} 73}
74 74
diff --git a/drivers/watchdog/sbc_fitpc2_wdt.c b/drivers/watchdog/sbc_fitpc2_wdt.c
index 8d44c9b6fb5..c7d67e9a746 100644
--- a/drivers/watchdog/sbc_fitpc2_wdt.c
+++ b/drivers/watchdog/sbc_fitpc2_wdt.c
@@ -30,7 +30,7 @@
30static int nowayout = WATCHDOG_NOWAYOUT; 30static int nowayout = WATCHDOG_NOWAYOUT;
31static unsigned int margin = 60; /* (secs) Default is 1 minute */ 31static unsigned int margin = 60; /* (secs) Default is 1 minute */
32static unsigned long wdt_status; 32static unsigned long wdt_status;
33static DEFINE_SPINLOCK(wdt_lock); 33static DEFINE_MUTEX(wdt_lock);
34 34
35#define WDT_IN_USE 0 35#define WDT_IN_USE 0
36#define WDT_OK_TO_CLOSE 1 36#define WDT_OK_TO_CLOSE 1
@@ -45,26 +45,26 @@ static DEFINE_SPINLOCK(wdt_lock);
45 45
46static void wdt_send_data(unsigned char command, unsigned char data) 46static void wdt_send_data(unsigned char command, unsigned char data)
47{ 47{
48 outb(command, COMMAND_PORT);
49 msleep(100);
50 outb(data, DATA_PORT); 48 outb(data, DATA_PORT);
51 msleep(200); 49 msleep(200);
50 outb(command, COMMAND_PORT);
51 msleep(100);
52} 52}
53 53
54static void wdt_enable(void) 54static void wdt_enable(void)
55{ 55{
56 spin_lock(&wdt_lock); 56 mutex_lock(&wdt_lock);
57 wdt_send_data(IFACE_ON_COMMAND, 1); 57 wdt_send_data(IFACE_ON_COMMAND, 1);
58 wdt_send_data(REBOOT_COMMAND, margin); 58 wdt_send_data(REBOOT_COMMAND, margin);
59 spin_unlock(&wdt_lock); 59 mutex_unlock(&wdt_lock);
60} 60}
61 61
62static void wdt_disable(void) 62static void wdt_disable(void)
63{ 63{
64 spin_lock(&wdt_lock); 64 mutex_lock(&wdt_lock);
65 wdt_send_data(IFACE_ON_COMMAND, 0); 65 wdt_send_data(IFACE_ON_COMMAND, 0);
66 wdt_send_data(REBOOT_COMMAND, 0); 66 wdt_send_data(REBOOT_COMMAND, 0);
67 spin_unlock(&wdt_lock); 67 mutex_unlock(&wdt_lock);
68} 68}
69 69
70static int fitpc2_wdt_open(struct inode *inode, struct file *file) 70static int fitpc2_wdt_open(struct inode *inode, struct file *file)
diff --git a/drivers/watchdog/ts72xx_wdt.c b/drivers/watchdog/ts72xx_wdt.c
index 565a2c3321e..458c499c122 100644
--- a/drivers/watchdog/ts72xx_wdt.c
+++ b/drivers/watchdog/ts72xx_wdt.c
@@ -20,6 +20,7 @@
20#include <linux/miscdevice.h> 20#include <linux/miscdevice.h>
21#include <linux/mutex.h> 21#include <linux/mutex.h>
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/slab.h>
23#include <linux/watchdog.h> 24#include <linux/watchdog.h>
24#include <linux/uaccess.h> 25#include <linux/uaccess.h>
25 26
diff --git a/drivers/watchdog/twl4030_wdt.c b/drivers/watchdog/twl4030_wdt.c
index 8162a40d152..dcabe77ad14 100644
--- a/drivers/watchdog/twl4030_wdt.c
+++ b/drivers/watchdog/twl4030_wdt.c
@@ -20,6 +20,7 @@
20 20
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/types.h> 22#include <linux/types.h>
23#include <linux/slab.h>
23#include <linux/kernel.h> 24#include <linux/kernel.h>
24#include <linux/fs.h> 25#include <linux/fs.h>
25#include <linux/watchdog.h> 26#include <linux/watchdog.h>
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index f6738d8b02b..1a0d8c2a035 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -43,6 +43,7 @@
43#include <linux/mutex.h> 43#include <linux/mutex.h>
44#include <linux/list.h> 44#include <linux/list.h>
45#include <linux/sysdev.h> 45#include <linux/sysdev.h>
46#include <linux/gfp.h>
46 47
47#include <asm/page.h> 48#include <asm/page.h>
48#include <asm/pgalloc.h> 49#include <asm/pgalloc.h>
diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index 2f8413794d0..db8f506817f 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -27,6 +27,7 @@
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/string.h> 28#include <linux/string.h>
29#include <linux/bootmem.h> 29#include <linux/bootmem.h>
30#include <linux/slab.h>
30 31
31#include <asm/ptrace.h> 32#include <asm/ptrace.h>
32#include <asm/irq.h> 33#include <asm/irq.h>
diff --git a/drivers/xen/evtchn.c b/drivers/xen/evtchn.c
index f70a4f4698c..66e185cfe92 100644
--- a/drivers/xen/evtchn.c
+++ b/drivers/xen/evtchn.c
@@ -45,7 +45,6 @@
45#include <linux/poll.h> 45#include <linux/poll.h>
46#include <linux/irq.h> 46#include <linux/irq.h>
47#include <linux/init.h> 47#include <linux/init.h>
48#include <linux/gfp.h>
49#include <linux/mutex.h> 48#include <linux/mutex.h>
50#include <linux/cpu.h> 49#include <linux/cpu.h>
51 50
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index 4c6c0bd636a..f66db3b91d6 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -34,6 +34,7 @@
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/sched.h> 35#include <linux/sched.h>
36#include <linux/mm.h> 36#include <linux/mm.h>
37#include <linux/slab.h>
37#include <linux/vmalloc.h> 38#include <linux/vmalloc.h>
38#include <linux/uaccess.h> 39#include <linux/uaccess.h>
39 40
diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c
index 5d42d55e299..2ac4440e7b0 100644
--- a/drivers/xen/manage.c
+++ b/drivers/xen/manage.c
@@ -3,6 +3,7 @@
3 */ 3 */
4#include <linux/kernel.h> 4#include <linux/kernel.h>
5#include <linux/err.h> 5#include <linux/err.h>
6#include <linux/slab.h>
6#include <linux/reboot.h> 7#include <linux/reboot.h>
7#include <linux/sysrq.h> 8#include <linux/sysrq.h>
8#include <linux/stop_machine.h> 9#include <linux/stop_machine.h>
diff --git a/drivers/xen/sys-hypervisor.c b/drivers/xen/sys-hypervisor.c
index bb71ab2336c..60f1827a32c 100644
--- a/drivers/xen/sys-hypervisor.c
+++ b/drivers/xen/sys-hypervisor.c
@@ -7,6 +7,7 @@
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 */ 8 */
9 9
10#include <linux/slab.h>
10#include <linux/kernel.h> 11#include <linux/kernel.h>
11#include <linux/module.h> 12#include <linux/module.h>
12#include <linux/kobject.h> 13#include <linux/kobject.h>
diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c
index 92a1ef80a28..7b3e973a1ae 100644
--- a/drivers/xen/xenbus/xenbus_client.c
+++ b/drivers/xen/xenbus/xenbus_client.c
@@ -30,6 +30,7 @@
30 * IN THE SOFTWARE. 30 * IN THE SOFTWARE.
31 */ 31 */
32 32
33#include <linux/slab.h>
33#include <linux/types.h> 34#include <linux/types.h>
34#include <linux/vmalloc.h> 35#include <linux/vmalloc.h>
35#include <asm/xen/hypervisor.h> 36#include <asm/xen/hypervisor.h>
diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c
index 2f7aaa99dc4..3479332113e 100644
--- a/drivers/xen/xenbus/xenbus_probe.c
+++ b/drivers/xen/xenbus/xenbus_probe.c
@@ -45,6 +45,7 @@
45#include <linux/kthread.h> 45#include <linux/kthread.h>
46#include <linux/mutex.h> 46#include <linux/mutex.h>
47#include <linux/io.h> 47#include <linux/io.h>
48#include <linux/slab.h>
48 49
49#include <asm/page.h> 50#include <asm/page.h>
50#include <asm/pgtable.h> 51#include <asm/pgtable.h>
diff --git a/drivers/xen/xencomm.c b/drivers/xen/xencomm.c
index a240b2c20b9..b91f8ff50d0 100644
--- a/drivers/xen/xencomm.c
+++ b/drivers/xen/xencomm.c
@@ -18,8 +18,8 @@
18 * Authors: Hollis Blanchard <hollisb@us.ibm.com> 18 * Authors: Hollis Blanchard <hollisb@us.ibm.com>
19 */ 19 */
20 20
21#include <linux/gfp.h>
22#include <linux/mm.h> 21#include <linux/mm.h>
22#include <linux/slab.h>
23#include <asm/page.h> 23#include <asm/page.h>
24#include <xen/xencomm.h> 24#include <xen/xencomm.h>
25#include <xen/interface/xen.h> 25#include <xen/interface/xen.h>
diff --git a/drivers/xen/xenfs/xenbus.c b/drivers/xen/xenfs/xenbus.c
index 6c4269b836b..f28ece39736 100644
--- a/drivers/xen/xenfs/xenbus.c
+++ b/drivers/xen/xenfs/xenbus.c
@@ -51,6 +51,7 @@
51#include <linux/init.h> 51#include <linux/init.h>
52#include <linux/namei.h> 52#include <linux/namei.h>
53#include <linux/string.h> 53#include <linux/string.h>
54#include <linux/slab.h>
54 55
55#include "xenfs.h" 56#include "xenfs.h"
56#include "../xenbus/xenbus_comms.h" 57#include "../xenbus/xenbus_comms.h"