aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2011-02-04 13:46:43 -0500
committerGrant Likely <grant.likely@secretlab.ca>2011-02-04 13:46:43 -0500
commitc64eae9a73a847c1698f913c893aa4012d2a30b0 (patch)
tree732684b9ffe9dfd6e9a11b1f006eaaefeb0e945b /drivers
parentc9e358dfc4a8cb2227172ef77908c2e0ee17bcb9 (diff)
parentebf53826e105f488f4f628703a108e98940d1dc5 (diff)
Merge commit 'v2.6.38-rc3' into devicetree/next
Diffstat (limited to 'drivers')
-rw-r--r--drivers/Makefile3
-rw-r--r--drivers/acpi/Kconfig2
-rw-r--r--drivers/acpi/acpica/accommon.h2
-rw-r--r--drivers/acpi/acpica/acconfig.h2
-rw-r--r--drivers/acpi/acpica/acdebug.h2
-rw-r--r--drivers/acpi/acpica/acdispat.h2
-rw-r--r--drivers/acpi/acpica/acevents.h2
-rw-r--r--drivers/acpi/acpica/acglobal.h2
-rw-r--r--drivers/acpi/acpica/achware.h2
-rw-r--r--drivers/acpi/acpica/acinterp.h2
-rw-r--r--drivers/acpi/acpica/aclocal.h2
-rw-r--r--drivers/acpi/acpica/acmacros.h2
-rw-r--r--drivers/acpi/acpica/acnamesp.h2
-rw-r--r--drivers/acpi/acpica/acobject.h16
-rw-r--r--drivers/acpi/acpica/acopcode.h2
-rw-r--r--drivers/acpi/acpica/acparser.h2
-rw-r--r--drivers/acpi/acpica/acpredef.h2
-rw-r--r--drivers/acpi/acpica/acresrc.h2
-rw-r--r--drivers/acpi/acpica/acstruct.h2
-rw-r--r--drivers/acpi/acpica/actables.h2
-rw-r--r--drivers/acpi/acpica/acutils.h2
-rw-r--r--drivers/acpi/acpica/amlcode.h10
-rw-r--r--drivers/acpi/acpica/amlresrc.h2
-rw-r--r--drivers/acpi/acpica/dsfield.c2
-rw-r--r--drivers/acpi/acpica/dsinit.c2
-rw-r--r--drivers/acpi/acpica/dsmethod.c64
-rw-r--r--drivers/acpi/acpica/dsmthdat.c2
-rw-r--r--drivers/acpi/acpica/dsobject.c2
-rw-r--r--drivers/acpi/acpica/dsopcode.c2
-rw-r--r--drivers/acpi/acpica/dsutils.c2
-rw-r--r--drivers/acpi/acpica/dswexec.c2
-rw-r--r--drivers/acpi/acpica/dswload.c2
-rw-r--r--drivers/acpi/acpica/dswscope.c2
-rw-r--r--drivers/acpi/acpica/dswstate.c2
-rw-r--r--drivers/acpi/acpica/evevent.c2
-rw-r--r--drivers/acpi/acpica/evgpe.c4
-rw-r--r--drivers/acpi/acpica/evgpeblk.c2
-rw-r--r--drivers/acpi/acpica/evgpeinit.c2
-rw-r--r--drivers/acpi/acpica/evgpeutil.c2
-rw-r--r--drivers/acpi/acpica/evmisc.c2
-rw-r--r--drivers/acpi/acpica/evregion.c2
-rw-r--r--drivers/acpi/acpica/evrgnini.c6
-rw-r--r--drivers/acpi/acpica/evsci.c2
-rw-r--r--drivers/acpi/acpica/evxface.c2
-rw-r--r--drivers/acpi/acpica/evxfevnt.c2
-rw-r--r--drivers/acpi/acpica/evxfgpe.c2
-rw-r--r--drivers/acpi/acpica/evxfregn.c2
-rw-r--r--drivers/acpi/acpica/exconfig.c2
-rw-r--r--drivers/acpi/acpica/exconvrt.c2
-rw-r--r--drivers/acpi/acpica/excreate.c10
-rw-r--r--drivers/acpi/acpica/exdebug.c2
-rw-r--r--drivers/acpi/acpica/exdump.c4
-rw-r--r--drivers/acpi/acpica/exfield.c2
-rw-r--r--drivers/acpi/acpica/exfldio.c2
-rw-r--r--drivers/acpi/acpica/exmisc.c2
-rw-r--r--drivers/acpi/acpica/exmutex.c2
-rw-r--r--drivers/acpi/acpica/exnames.c2
-rw-r--r--drivers/acpi/acpica/exoparg1.c2
-rw-r--r--drivers/acpi/acpica/exoparg2.c2
-rw-r--r--drivers/acpi/acpica/exoparg3.c2
-rw-r--r--drivers/acpi/acpica/exoparg6.c2
-rw-r--r--drivers/acpi/acpica/exprep.c2
-rw-r--r--drivers/acpi/acpica/exregion.c2
-rw-r--r--drivers/acpi/acpica/exresnte.c2
-rw-r--r--drivers/acpi/acpica/exresolv.c2
-rw-r--r--drivers/acpi/acpica/exresop.c2
-rw-r--r--drivers/acpi/acpica/exstore.c2
-rw-r--r--drivers/acpi/acpica/exstoren.c2
-rw-r--r--drivers/acpi/acpica/exstorob.c2
-rw-r--r--drivers/acpi/acpica/exsystem.c2
-rw-r--r--drivers/acpi/acpica/exutils.c2
-rw-r--r--drivers/acpi/acpica/hwacpi.c2
-rw-r--r--drivers/acpi/acpica/hwgpe.c2
-rw-r--r--drivers/acpi/acpica/hwpci.c2
-rw-r--r--drivers/acpi/acpica/hwregs.c2
-rw-r--r--drivers/acpi/acpica/hwsleep.c2
-rw-r--r--drivers/acpi/acpica/hwtimer.c2
-rw-r--r--drivers/acpi/acpica/hwvalid.c2
-rw-r--r--drivers/acpi/acpica/hwxface.c2
-rw-r--r--drivers/acpi/acpica/nsaccess.c8
-rw-r--r--drivers/acpi/acpica/nsalloc.c15
-rw-r--r--drivers/acpi/acpica/nsdump.c17
-rw-r--r--drivers/acpi/acpica/nsdumpdv.c2
-rw-r--r--drivers/acpi/acpica/nseval.c4
-rw-r--r--drivers/acpi/acpica/nsinit.c2
-rw-r--r--drivers/acpi/acpica/nsload.c2
-rw-r--r--drivers/acpi/acpica/nsnames.c2
-rw-r--r--drivers/acpi/acpica/nsobject.c2
-rw-r--r--drivers/acpi/acpica/nsparse.c2
-rw-r--r--drivers/acpi/acpica/nspredef.c2
-rw-r--r--drivers/acpi/acpica/nsrepair.c2
-rw-r--r--drivers/acpi/acpica/nsrepair2.c2
-rw-r--r--drivers/acpi/acpica/nssearch.c2
-rw-r--r--drivers/acpi/acpica/nsutils.c2
-rw-r--r--drivers/acpi/acpica/nswalk.c2
-rw-r--r--drivers/acpi/acpica/nsxfeval.c2
-rw-r--r--drivers/acpi/acpica/nsxfname.c7
-rw-r--r--drivers/acpi/acpica/nsxfobj.c2
-rw-r--r--drivers/acpi/acpica/psargs.c2
-rw-r--r--drivers/acpi/acpica/psloop.c4
-rw-r--r--drivers/acpi/acpica/psopcode.c2
-rw-r--r--drivers/acpi/acpica/psparse.c27
-rw-r--r--drivers/acpi/acpica/psscope.c2
-rw-r--r--drivers/acpi/acpica/pstree.c2
-rw-r--r--drivers/acpi/acpica/psutils.c2
-rw-r--r--drivers/acpi/acpica/pswalk.c2
-rw-r--r--drivers/acpi/acpica/psxface.c9
-rw-r--r--drivers/acpi/acpica/rsaddr.c2
-rw-r--r--drivers/acpi/acpica/rscalc.c2
-rw-r--r--drivers/acpi/acpica/rscreate.c2
-rw-r--r--drivers/acpi/acpica/rsdump.c2
-rw-r--r--drivers/acpi/acpica/rsinfo.c2
-rw-r--r--drivers/acpi/acpica/rsio.c2
-rw-r--r--drivers/acpi/acpica/rsirq.c2
-rw-r--r--drivers/acpi/acpica/rslist.c2
-rw-r--r--drivers/acpi/acpica/rsmemory.c2
-rw-r--r--drivers/acpi/acpica/rsmisc.c2
-rw-r--r--drivers/acpi/acpica/rsutils.c2
-rw-r--r--drivers/acpi/acpica/rsxface.c2
-rw-r--r--drivers/acpi/acpica/tbfadt.c2
-rw-r--r--drivers/acpi/acpica/tbfind.c2
-rw-r--r--drivers/acpi/acpica/tbinstal.c2
-rw-r--r--drivers/acpi/acpica/tbutils.c2
-rw-r--r--drivers/acpi/acpica/tbxface.c2
-rw-r--r--drivers/acpi/acpica/tbxfroot.c2
-rw-r--r--drivers/acpi/acpica/utalloc.c2
-rw-r--r--drivers/acpi/acpica/utcopy.c2
-rw-r--r--drivers/acpi/acpica/utdebug.c2
-rw-r--r--drivers/acpi/acpica/utdelete.c2
-rw-r--r--drivers/acpi/acpica/uteval.c2
-rw-r--r--drivers/acpi/acpica/utglobal.c2
-rw-r--r--drivers/acpi/acpica/utids.c2
-rw-r--r--drivers/acpi/acpica/utinit.c2
-rw-r--r--drivers/acpi/acpica/utlock.c2
-rw-r--r--drivers/acpi/acpica/utmath.c2
-rw-r--r--drivers/acpi/acpica/utmisc.c2
-rw-r--r--drivers/acpi/acpica/utmutex.c2
-rw-r--r--drivers/acpi/acpica/utobject.c2
-rw-r--r--drivers/acpi/acpica/utosi.c2
-rw-r--r--drivers/acpi/acpica/utresrc.c2
-rw-r--r--drivers/acpi/acpica/utstate.c2
-rw-r--r--drivers/acpi/acpica/utxface.c2
-rw-r--r--drivers/acpi/acpica/utxferror.c2
-rw-r--r--drivers/acpi/battery.c1
-rw-r--r--drivers/acpi/nvs.c7
-rw-r--r--drivers/acpi/osl.c12
-rw-r--r--drivers/acpi/sleep.c2
-rw-r--r--drivers/ata/Kconfig2
-rw-r--r--drivers/ata/ahci.c3
-rw-r--r--drivers/ata/libata-core.c1
-rw-r--r--drivers/ata/libata-scsi.c24
-rw-r--r--drivers/ata/pata_hpt366.c6
-rw-r--r--drivers/ata/pata_hpt37x.c112
-rw-r--r--drivers/ata/pata_hpt3x2n.c12
-rw-r--r--drivers/ata/pata_mpc52xx.c2
-rw-r--r--drivers/atm/idt77105.c2
-rw-r--r--drivers/base/Kconfig2
-rw-r--r--drivers/base/power/runtime.c9
-rw-r--r--drivers/bluetooth/ath3k.c75
-rw-r--r--drivers/char/Kconfig12
-rw-r--r--drivers/char/Makefile13
-rw-r--r--drivers/char/agp/intel-gtt.c19
-rw-r--r--drivers/char/bfin_jtag_comm.c8
-rw-r--r--drivers/char/tpm/tpm.c10
-rw-r--r--drivers/char/tpm/tpm_tis.c6
-rw-r--r--drivers/clocksource/acpi_pm.c6
-rw-r--r--drivers/clocksource/tcb_clksrc.c4
-rw-r--r--drivers/cpufreq/Kconfig2
-rw-r--r--drivers/firewire/Kconfig6
-rw-r--r--drivers/firewire/core-card.c11
-rw-r--r--drivers/firewire/net.c9
-rw-r--r--drivers/firmware/Kconfig2
-rw-r--r--drivers/gpio/langwell_gpio.c9
-rw-r--r--drivers/gpu/drm/Kconfig5
-rw-r--r--drivers/gpu/drm/drm_fb_helper.c4
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c35
-rw-r--r--drivers/gpu/drm/i915/i915_drv.c5
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h5
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c12
-rw-r--r--drivers/gpu/drm/i915/i915_gem_execbuffer.c2
-rw-r--r--drivers/gpu/drm/i915/i915_gem_gtt.c4
-rw-r--r--drivers/gpu/drm/i915/i915_irq.c37
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h6
-rw-r--r--drivers/gpu/drm/i915/intel_display.c25
-rw-r--r--drivers/gpu/drm/i915/intel_opregion.c3
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.c82
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.h4
-rw-r--r--drivers/gpu/drm/nouveau/Kconfig2
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bios.c15
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drv.c8
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drv.h3
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_temp.c2
-rw-r--r--drivers/gpu/drm/nouveau/nv50_graph.c3
-rw-r--r--drivers/gpu/drm/nouveau/nv50_vm.c5
-rw-r--r--drivers/gpu/drm/nouveau/nvc0_graph.c23
-rw-r--r--drivers/gpu/drm/nouveau/nvc0_grctx.c2
-rw-r--r--drivers/gpu/drm/radeon/atombios_crtc.c39
-rw-r--r--drivers/gpu/drm/radeon/atombios_dp.c4
-rw-r--r--drivers/gpu/drm/radeon/evergreen.c3
-rw-r--r--drivers/gpu/drm/radeon/evergreen_blit_kms.c39
-rw-r--r--drivers/gpu/drm/radeon/r100.c12
-rw-r--r--drivers/gpu/drm/radeon/r300.c7
-rw-r--r--drivers/gpu/drm/radeon/r420.c2
-rw-r--r--drivers/gpu/drm/radeon/r520.c4
-rw-r--r--drivers/gpu/drm/radeon/r600.c3
-rw-r--r--drivers/gpu/drm/radeon/r600_reg.h6
-rw-r--r--drivers/gpu/drm/radeon/radeon_atombios.c14
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c10
-rw-r--r--drivers/gpu/drm/radeon/radeon_drv.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_encoders.c6
-rw-r--r--drivers/gpu/drm/radeon/radeon_irq_kms.c3
-rw-r--r--drivers/gpu/drm/radeon/radeon_kms.c6
-rw-r--r--drivers/gpu/drm/radeon/radeon_reg.h2
-rw-r--r--drivers/gpu/drm/radeon/rs400.c15
-rw-r--r--drivers/gpu/drm/radeon/rv515.c10
-rw-r--r--drivers/gpu/vga/Kconfig2
-rw-r--r--drivers/gpu/vga/vgaarb.c2
-rw-r--r--drivers/hid/Kconfig64
-rw-r--r--drivers/hid/usbhid/Kconfig2
-rw-r--r--drivers/hwmon/applesmc.c1
-rw-r--r--drivers/hwmon/asus_atk0110.c23
-rw-r--r--drivers/hwmon/lis3lv02d.c2
-rw-r--r--drivers/ide/Kconfig2
-rw-r--r--drivers/idle/intel_idle.c8
-rw-r--r--drivers/infiniband/hw/mthca/Kconfig2
-rw-r--r--drivers/infiniband/ulp/ipoib/Kconfig2
-rw-r--r--drivers/input/Kconfig6
-rw-r--r--drivers/input/keyboard/Kconfig14
-rw-r--r--drivers/input/keyboard/Makefile1
-rw-r--r--drivers/input/keyboard/gpio_keys.c6
-rw-r--r--drivers/input/keyboard/tegra-kbc.c727
-rw-r--r--drivers/input/keyboard/tnetv107x-keypad.c5
-rw-r--r--drivers/input/mouse/Kconfig10
-rw-r--r--drivers/input/mouse/synaptics.c32
-rw-r--r--drivers/input/serio/Kconfig6
-rw-r--r--drivers/input/serio/ct82c710.c8
-rw-r--r--drivers/input/serio/serport.c24
-rw-r--r--drivers/input/sparse-keymap.c1
-rw-r--r--drivers/input/tablet/wacom_wac.c27
-rw-r--r--drivers/input/touchscreen/Kconfig30
-rw-r--r--drivers/input/touchscreen/bu21013_ts.c39
-rw-r--r--drivers/input/touchscreen/tnetv107x-ts.c5
-rw-r--r--drivers/leds/leds-pwm.c1
-rw-r--r--drivers/leds/ledtrig-gpio.c15
-rw-r--r--drivers/lguest/page_tables.c2
-rw-r--r--drivers/lguest/x86/core.c4
-rw-r--r--drivers/macintosh/therm_pm72.c4
-rw-r--r--drivers/media/common/saa7146_core.c2
-rw-r--r--drivers/media/common/saa7146_fops.c8
-rw-r--r--drivers/media/common/saa7146_vbi.c2
-rw-r--r--drivers/media/common/saa7146_video.c20
-rw-r--r--drivers/media/common/tuners/Kconfig2
-rw-r--r--drivers/media/common/tuners/tda8290.c130
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700_core.c6
-rw-r--r--drivers/media/dvb/firewire/firedtv-rc.c9
-rw-r--r--drivers/media/dvb/frontends/Kconfig2
-rw-r--r--drivers/media/dvb/frontends/af9013.c4
-rw-r--r--drivers/media/dvb/frontends/ix2505v.c2
-rw-r--r--drivers/media/dvb/frontends/mb86a20s.c36
-rw-r--r--drivers/media/dvb/ttpci/av7110_ca.c2
-rw-r--r--drivers/media/radio/Kconfig14
-rw-r--r--drivers/media/radio/Makefile1
-rw-r--r--drivers/media/radio/radio-aimslab.c1
-rw-r--r--drivers/media/radio/radio-gemtek-pci.c478
-rw-r--r--drivers/media/radio/radio-maxiradio.c4
-rw-r--r--drivers/media/radio/radio-wl1273.c2
-rw-r--r--drivers/media/radio/si470x/radio-si470x-common.c9
-rw-r--r--drivers/media/rc/ene_ir.c23
-rw-r--r--drivers/media/rc/ene_ir.h2
-rw-r--r--drivers/media/rc/imon.c60
-rw-r--r--drivers/media/rc/ir-raw.c2
-rw-r--r--drivers/media/rc/keymaps/rc-dib0700-nec.c52
-rw-r--r--drivers/media/rc/mceusb.c3
-rw-r--r--drivers/media/rc/rc-main.c28
-rw-r--r--drivers/media/video/Kconfig11
-rw-r--r--drivers/media/video/Makefile1
-rw-r--r--drivers/media/video/adv7175.c11
-rw-r--r--drivers/media/video/bt8xx/bttv-cards.c39
-rw-r--r--drivers/media/video/bt8xx/bttv.h1
-rw-r--r--drivers/media/video/cafe_ccic.c11
-rw-r--r--drivers/media/video/cpia2/cpia2.h2
-rw-r--r--drivers/media/video/cpia2/cpia2_core.c65
-rw-r--r--drivers/media/video/cpia2/cpia2_v4l.c104
-rw-r--r--drivers/media/video/cx18/cx18-driver.c24
-rw-r--r--drivers/media/video/cx18/cx18-driver.h3
-rw-r--r--drivers/media/video/cx18/cx18-streams.h3
-rw-r--r--drivers/media/video/cx231xx/cx231xx-dvb.c5
-rw-r--r--drivers/media/video/cx25840/cx25840-core.c22
-rw-r--r--drivers/media/video/davinci/vpif.c177
-rw-r--r--drivers/media/video/davinci/vpif.h18
-rw-r--r--drivers/media/video/davinci/vpif_capture.c451
-rw-r--r--drivers/media/video/davinci/vpif_capture.h2
-rw-r--r--drivers/media/video/davinci/vpif_display.c474
-rw-r--r--drivers/media/video/davinci/vpif_display.h2
-rw-r--r--drivers/media/video/em28xx/em28xx-cards.c19
-rw-r--r--drivers/media/video/et61x251/et61x251.h24
-rw-r--r--drivers/media/video/gspca/benq.c2
-rw-r--r--drivers/media/video/gspca/conex.c4
-rw-r--r--drivers/media/video/gspca/cpia1.c2
-rw-r--r--drivers/media/video/gspca/etoms.c4
-rw-r--r--drivers/media/video/gspca/finepix.c2
-rw-r--r--drivers/media/video/gspca/gl860/gl860.c2
-rw-r--r--drivers/media/video/gspca/gspca.c210
-rw-r--r--drivers/media/video/gspca/gspca.h2
-rw-r--r--drivers/media/video/gspca/jeilinj.c2
-rw-r--r--drivers/media/video/gspca/jpeg.h4
-rw-r--r--drivers/media/video/gspca/konica.c2
-rw-r--r--drivers/media/video/gspca/m5602/m5602_core.c2
-rw-r--r--drivers/media/video/gspca/mars.c2
-rw-r--r--drivers/media/video/gspca/mr97310a.c2
-rw-r--r--drivers/media/video/gspca/ov519.c8
-rw-r--r--drivers/media/video/gspca/ov534.c29
-rw-r--r--drivers/media/video/gspca/ov534_9.c2
-rw-r--r--drivers/media/video/gspca/pac207.c2
-rw-r--r--drivers/media/video/gspca/pac7302.c4
-rw-r--r--drivers/media/video/gspca/pac7311.c4
-rw-r--r--drivers/media/video/gspca/sn9c2028.c2
-rw-r--r--drivers/media/video/gspca/sn9c20x.c2
-rw-r--r--drivers/media/video/gspca/sonixb.c270
-rw-r--r--drivers/media/video/gspca/sonixj.c155
-rw-r--r--drivers/media/video/gspca/spca1528.c2
-rw-r--r--drivers/media/video/gspca/spca500.c2
-rw-r--r--drivers/media/video/gspca/spca501.c2
-rw-r--r--drivers/media/video/gspca/spca505.c2
-rw-r--r--drivers/media/video/gspca/spca508.c2
-rw-r--r--drivers/media/video/gspca/spca561.c2
-rw-r--r--drivers/media/video/gspca/sq905.c2
-rw-r--r--drivers/media/video/gspca/sq905c.c2
-rw-r--r--drivers/media/video/gspca/sq930x.c2
-rw-r--r--drivers/media/video/gspca/stk014.c2
-rw-r--r--drivers/media/video/gspca/stv0680.c2
-rw-r--r--drivers/media/video/gspca/stv06xx/stv06xx.c2
-rw-r--r--drivers/media/video/gspca/sunplus.c2
-rw-r--r--drivers/media/video/gspca/t613.c2
-rw-r--r--drivers/media/video/gspca/tv8532.c2
-rw-r--r--drivers/media/video/gspca/vc032x.c2
-rw-r--r--drivers/media/video/gspca/xirlink_cit.c2
-rw-r--r--drivers/media/video/gspca/zc3xx.c2
-rw-r--r--drivers/media/video/hdpvr/Makefile4
-rw-r--r--drivers/media/video/hdpvr/hdpvr-core.c10
-rw-r--r--drivers/media/video/hdpvr/hdpvr-i2c.c143
-rw-r--r--drivers/media/video/hdpvr/hdpvr-video.c7
-rw-r--r--drivers/media/video/hdpvr/hdpvr.h5
-rw-r--r--drivers/media/video/ir-kbd-i2c.c12
-rw-r--r--drivers/media/video/ivtv/ivtv-i2c.c9
-rw-r--r--drivers/media/video/mt9v011.c54
-rw-r--r--drivers/media/video/mt9v011.h36
-rw-r--r--drivers/media/video/ov7670.c74
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h2
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-i2c-core.c62
-rw-r--r--drivers/media/video/saa7134/saa7134-cards.c51
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c80
-rw-r--r--drivers/media/video/sn9c102/sn9c102_devtable.h74
-rw-r--r--drivers/media/video/sr030pc30.c10
-rw-r--r--drivers/media/video/tda9875.c411
-rw-r--r--drivers/media/video/tlg2300/pd-video.c13
-rw-r--r--drivers/media/video/v4l2-common.c19
-rw-r--r--drivers/media/video/v4l2-ctrls.c34
-rw-r--r--drivers/media/video/v4l2-dev.c9
-rw-r--r--drivers/media/video/v4l2-device.c16
-rw-r--r--drivers/media/video/v4l2-ioctl.c20
-rw-r--r--drivers/media/video/w9966.c1
-rw-r--r--drivers/media/video/zoran/zoran_card.c2
-rw-r--r--drivers/mmc/host/bfin_sdh.c2
-rw-r--r--drivers/mmc/host/jz4740_mmc.c5
-rw-r--r--drivers/mmc/host/mmci.c109
-rw-r--r--drivers/mmc/host/mmci.h5
-rw-r--r--drivers/mmc/host/msm_sdcc.c52
-rw-r--r--drivers/mmc/host/sdhci-s3c.c36
-rw-r--r--drivers/mmc/host/ushc.c1
-rw-r--r--drivers/mtd/ubi/build.c28
-rw-r--r--drivers/net/Kconfig2
-rw-r--r--drivers/net/arm/ks8695net.c2
-rw-r--r--drivers/net/bnx2.c21
-rw-r--r--drivers/net/bnx2.h1
-rw-r--r--drivers/net/bnx2x/bnx2x.h4
-rw-r--r--drivers/net/bnx2x/bnx2x_hsi.h4
-rw-r--r--drivers/net/bnx2x/bnx2x_link.c173
-rw-r--r--drivers/net/bnx2x/bnx2x_reg.h4
-rw-r--r--drivers/net/bonding/bond_3ad.c4
-rw-r--r--drivers/net/bonding/bond_alb.c4
-rw-r--r--drivers/net/bonding/bond_main.c4
-rw-r--r--drivers/net/can/Kconfig2
-rw-r--r--drivers/net/can/Makefile1
-rw-r--r--drivers/net/can/at91_can.c138
-rw-r--r--drivers/net/can/softing/Kconfig30
-rw-r--r--drivers/net/can/softing/Makefile6
-rw-r--r--drivers/net/can/softing/softing.h167
-rw-r--r--drivers/net/can/softing/softing_cs.c359
-rw-r--r--drivers/net/can/softing/softing_fw.c691
-rw-r--r--drivers/net/can/softing/softing_main.c893
-rw-r--r--drivers/net/can/softing/softing_platform.h40
-rw-r--r--drivers/net/cnic.c12
-rw-r--r--drivers/net/cxgb4/cxgb4_main.c3
-rw-r--r--drivers/net/gianfar.c2
-rw-r--r--drivers/net/irda/sh_irda.c14
-rw-r--r--drivers/net/ns83820.c5
-rw-r--r--drivers/net/pch_gbe/pch_gbe_main.c2
-rw-r--r--drivers/net/tg3.c95
-rw-r--r--drivers/net/tg3.h3
-rw-r--r--drivers/net/usb/cdc_ncm.c19
-rw-r--r--drivers/net/usb/kaweth.c1
-rw-r--r--drivers/net/vmxnet3/vmxnet3_drv.c93
-rw-r--r--drivers/net/vmxnet3/vmxnet3_ethtool.c274
-rw-r--r--drivers/net/vmxnet3/vmxnet3_int.h7
-rw-r--r--drivers/net/wireless/ath/ath5k/base.c4
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9002_calib.c10
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h2
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_hw.c4
-rw-r--r--drivers/net/wireless/ath/ath9k/htc.h2
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_txrx.c8
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c6
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.h1
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c8
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-eeprom.c13
-rw-r--r--drivers/net/wireless/iwmc3200wifi/netdev.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00firmware.c1
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c1
-rw-r--r--drivers/net/wireless/rtlwifi/pci.c11
-rw-r--r--drivers/parport/share.c4
-rw-r--r--drivers/pci/pcie/Kconfig2
-rw-r--r--drivers/pcmcia/Kconfig12
-rw-r--r--drivers/platform/x86/intel_scu_ipc.c8
-rw-r--r--drivers/platform/x86/intel_scu_ipcutil.c2
-rw-r--r--drivers/pps/clients/pps-ktimer.c2
-rw-r--r--drivers/pps/clients/pps_parport.c2
-rw-r--r--drivers/pps/generators/pps_gen_parport.c2
-rw-r--r--drivers/rapidio/rio-scan.c2
-rw-r--r--drivers/rtc/Kconfig12
-rw-r--r--drivers/rtc/interface.c61
-rw-r--r--drivers/s390/net/qeth_l2_main.c18
-rw-r--r--drivers/s390/net/qeth_l3_main.c22
-rw-r--r--drivers/sh/intc/chip.c6
-rw-r--r--drivers/ssb/Kconfig2
-rw-r--r--drivers/staging/ath6kl/miscdrv/ar3kps/ar3kpsconfig.c4
-rw-r--r--drivers/staging/brcm80211/sys/wl_mac80211.c45
-rw-r--r--drivers/staging/brcm80211/sys/wlc_mac80211.c1
-rw-r--r--drivers/staging/comedi/drivers/ni_labpc.c3
-rw-r--r--drivers/staging/hv/blkvsc_drv.c1
-rw-r--r--drivers/staging/hv/netvsc.c2
-rw-r--r--drivers/staging/hv/netvsc_drv.c1
-rw-r--r--drivers/staging/iio/adc/ad7476_core.c2
-rw-r--r--drivers/staging/iio/adc/ad7887_core.c2
-rw-r--r--drivers/staging/iio/adc/ad799x_core.c2
-rw-r--r--drivers/staging/iio/dac/ad5446.c2
-rw-r--r--drivers/staging/lirc/TODO.lirc_zilog36
-rw-r--r--drivers/staging/lirc/lirc_imon.c1
-rw-r--r--drivers/staging/lirc/lirc_it87.c1
-rw-r--r--drivers/staging/lirc/lirc_parallel.c19
-rw-r--r--drivers/staging/lirc/lirc_sasem.c1
-rw-r--r--drivers/staging/lirc/lirc_serial.c3
-rw-r--r--drivers/staging/lirc/lirc_sir.c1
-rw-r--r--drivers/staging/lirc/lirc_zilog.c650
-rw-r--r--drivers/staging/msm/msm_fb.c8
-rw-r--r--drivers/staging/olpc_dcon/olpc_dcon.c10
-rw-r--r--drivers/staging/rt2860/rt_main_dev.c2
-rw-r--r--drivers/staging/rt2860/usb_main_dev.c1
-rw-r--r--drivers/staging/rtl8712/hal_init.c11
-rw-r--r--drivers/staging/rtl8712/usb_intf.c145
-rw-r--r--drivers/staging/sm7xx/smtcfb.c8
-rw-r--r--drivers/staging/speakup/kobjects.c2
-rw-r--r--drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c19
-rw-r--r--drivers/staging/tidspbridge/core/io_sm.c8
-rw-r--r--drivers/staging/tidspbridge/core/tiomap3430.c15
-rw-r--r--drivers/staging/tidspbridge/include/dspbridge/io_sm.h21
-rw-r--r--drivers/staging/tm6000/tm6000-video.c46
-rw-r--r--drivers/staging/usbip/stub.h1
-rw-r--r--drivers/staging/usbip/stub_dev.c18
-rw-r--r--drivers/staging/usbip/stub_rx.c4
-rw-r--r--drivers/staging/usbip/vhci.h6
-rw-r--r--drivers/staging/usbip/vhci_hcd.c54
-rw-r--r--drivers/staging/usbip/vhci_rx.c50
-rw-r--r--drivers/staging/vme/bridges/Module.symvers0
-rw-r--r--drivers/staging/xgifb/vb_setmode.c6
-rw-r--r--drivers/tty/Makefile2
-rw-r--r--drivers/tty/hvc/Makefile13
-rw-r--r--drivers/tty/hvc/hvc_beat.c (renamed from drivers/char/hvc_beat.c)0
-rw-r--r--drivers/tty/hvc/hvc_console.c (renamed from drivers/char/hvc_console.c)0
-rw-r--r--drivers/tty/hvc/hvc_console.h (renamed from drivers/char/hvc_console.h)0
-rw-r--r--drivers/tty/hvc/hvc_dcc.c (renamed from drivers/char/hvc_dcc.c)0
-rw-r--r--drivers/tty/hvc/hvc_irq.c (renamed from drivers/char/hvc_irq.c)0
-rw-r--r--drivers/tty/hvc/hvc_iseries.c (renamed from drivers/char/hvc_iseries.c)0
-rw-r--r--drivers/tty/hvc/hvc_iucv.c (renamed from drivers/char/hvc_iucv.c)0
-rw-r--r--drivers/tty/hvc/hvc_rtas.c (renamed from drivers/char/hvc_rtas.c)0
-rw-r--r--drivers/tty/hvc/hvc_tile.c (renamed from drivers/char/hvc_tile.c)0
-rw-r--r--drivers/tty/hvc/hvc_udbg.c (renamed from drivers/char/hvc_udbg.c)0
-rw-r--r--drivers/tty/hvc/hvc_vio.c (renamed from drivers/char/hvc_vio.c)0
-rw-r--r--drivers/tty/hvc/hvc_xen.c (renamed from drivers/char/hvc_xen.c)0
-rw-r--r--drivers/tty/hvc/hvcs.c (renamed from drivers/char/hvcs.c)0
-rw-r--r--drivers/tty/hvc/hvsi.c (renamed from drivers/char/hvsi.c)0
-rw-r--r--drivers/tty/hvc/virtio_console.c (renamed from drivers/char/virtio_console.c)0
-rw-r--r--drivers/tty/n_hdlc.c90
-rw-r--r--drivers/tty/serial/21285.c (renamed from drivers/serial/21285.c)0
-rw-r--r--drivers/tty/serial/68328serial.c (renamed from drivers/serial/68328serial.c)0
-rw-r--r--drivers/tty/serial/68328serial.h (renamed from drivers/serial/68328serial.h)0
-rw-r--r--drivers/tty/serial/68360serial.c (renamed from drivers/serial/68360serial.c)0
-rw-r--r--drivers/tty/serial/8250.c (renamed from drivers/serial/8250.c)3
-rw-r--r--drivers/tty/serial/8250.h (renamed from drivers/serial/8250.h)0
-rw-r--r--drivers/tty/serial/8250_accent.c (renamed from drivers/serial/8250_accent.c)0
-rw-r--r--drivers/tty/serial/8250_acorn.c (renamed from drivers/serial/8250_acorn.c)0
-rw-r--r--drivers/tty/serial/8250_boca.c (renamed from drivers/serial/8250_boca.c)0
-rw-r--r--drivers/tty/serial/8250_early.c (renamed from drivers/serial/8250_early.c)0
-rw-r--r--drivers/tty/serial/8250_exar_st16c554.c (renamed from drivers/serial/8250_exar_st16c554.c)0
-rw-r--r--drivers/tty/serial/8250_fourport.c (renamed from drivers/serial/8250_fourport.c)0
-rw-r--r--drivers/tty/serial/8250_gsc.c (renamed from drivers/serial/8250_gsc.c)0
-rw-r--r--drivers/tty/serial/8250_hp300.c (renamed from drivers/serial/8250_hp300.c)0
-rw-r--r--drivers/tty/serial/8250_hub6.c (renamed from drivers/serial/8250_hub6.c)0
-rw-r--r--drivers/tty/serial/8250_mca.c (renamed from drivers/serial/8250_mca.c)0
-rw-r--r--drivers/tty/serial/8250_pci.c (renamed from drivers/serial/8250_pci.c)0
-rw-r--r--drivers/tty/serial/8250_pnp.c (renamed from drivers/serial/8250_pnp.c)0
-rw-r--r--drivers/tty/serial/Kconfig (renamed from drivers/serial/Kconfig)5
-rw-r--r--drivers/tty/serial/Makefile (renamed from drivers/serial/Makefile)0
-rw-r--r--drivers/tty/serial/altera_jtaguart.c (renamed from drivers/serial/altera_jtaguart.c)0
-rw-r--r--drivers/tty/serial/altera_uart.c (renamed from drivers/serial/altera_uart.c)0
-rw-r--r--drivers/tty/serial/amba-pl010.c (renamed from drivers/serial/amba-pl010.c)0
-rw-r--r--drivers/tty/serial/amba-pl011.c (renamed from drivers/serial/amba-pl011.c)0
-rw-r--r--drivers/tty/serial/apbuart.c (renamed from drivers/serial/apbuart.c)0
-rw-r--r--drivers/tty/serial/apbuart.h (renamed from drivers/serial/apbuart.h)0
-rw-r--r--drivers/tty/serial/atmel_serial.c (renamed from drivers/serial/atmel_serial.c)0
-rw-r--r--drivers/tty/serial/bcm63xx_uart.c (renamed from drivers/serial/bcm63xx_uart.c)0
-rw-r--r--drivers/tty/serial/bfin_5xx.c (renamed from drivers/serial/bfin_5xx.c)0
-rw-r--r--drivers/tty/serial/bfin_sport_uart.c (renamed from drivers/serial/bfin_sport_uart.c)0
-rw-r--r--drivers/tty/serial/bfin_sport_uart.h (renamed from drivers/serial/bfin_sport_uart.h)0
-rw-r--r--drivers/tty/serial/clps711x.c (renamed from drivers/serial/clps711x.c)0
-rw-r--r--drivers/tty/serial/cpm_uart/Makefile (renamed from drivers/serial/cpm_uart/Makefile)0
-rw-r--r--drivers/tty/serial/cpm_uart/cpm_uart.h (renamed from drivers/serial/cpm_uart/cpm_uart.h)0
-rw-r--r--drivers/tty/serial/cpm_uart/cpm_uart_core.c (renamed from drivers/serial/cpm_uart/cpm_uart_core.c)0
-rw-r--r--drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c (renamed from drivers/serial/cpm_uart/cpm_uart_cpm1.c)0
-rw-r--r--drivers/tty/serial/cpm_uart/cpm_uart_cpm1.h (renamed from drivers/serial/cpm_uart/cpm_uart_cpm1.h)0
-rw-r--r--drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c (renamed from drivers/serial/cpm_uart/cpm_uart_cpm2.c)0
-rw-r--r--drivers/tty/serial/cpm_uart/cpm_uart_cpm2.h (renamed from drivers/serial/cpm_uart/cpm_uart_cpm2.h)0
-rw-r--r--drivers/tty/serial/crisv10.c (renamed from drivers/serial/crisv10.c)0
-rw-r--r--drivers/tty/serial/crisv10.h (renamed from drivers/serial/crisv10.h)0
-rw-r--r--drivers/tty/serial/dz.c (renamed from drivers/serial/dz.c)0
-rw-r--r--drivers/tty/serial/dz.h (renamed from drivers/serial/dz.h)0
-rw-r--r--drivers/tty/serial/icom.c (renamed from drivers/serial/icom.c)0
-rw-r--r--drivers/tty/serial/icom.h (renamed from drivers/serial/icom.h)0
-rw-r--r--drivers/tty/serial/ifx6x60.c (renamed from drivers/serial/ifx6x60.c)0
-rw-r--r--drivers/tty/serial/ifx6x60.h (renamed from drivers/serial/ifx6x60.h)0
-rw-r--r--drivers/tty/serial/imx.c (renamed from drivers/serial/imx.c)0
-rw-r--r--drivers/tty/serial/ioc3_serial.c (renamed from drivers/serial/ioc3_serial.c)0
-rw-r--r--drivers/tty/serial/ioc4_serial.c (renamed from drivers/serial/ioc4_serial.c)0
-rw-r--r--drivers/tty/serial/ip22zilog.c (renamed from drivers/serial/ip22zilog.c)0
-rw-r--r--drivers/tty/serial/ip22zilog.h (renamed from drivers/serial/ip22zilog.h)0
-rw-r--r--drivers/tty/serial/jsm/Makefile (renamed from drivers/serial/jsm/Makefile)0
-rw-r--r--drivers/tty/serial/jsm/jsm.h (renamed from drivers/serial/jsm/jsm.h)0
-rw-r--r--drivers/tty/serial/jsm/jsm_driver.c (renamed from drivers/serial/jsm/jsm_driver.c)0
-rw-r--r--drivers/tty/serial/jsm/jsm_neo.c (renamed from drivers/serial/jsm/jsm_neo.c)0
-rw-r--r--drivers/tty/serial/jsm/jsm_tty.c (renamed from drivers/serial/jsm/jsm_tty.c)0
-rw-r--r--drivers/tty/serial/kgdboc.c (renamed from drivers/serial/kgdboc.c)0
-rw-r--r--drivers/tty/serial/m32r_sio.c (renamed from drivers/serial/m32r_sio.c)0
-rw-r--r--drivers/tty/serial/m32r_sio.h (renamed from drivers/serial/m32r_sio.h)0
-rw-r--r--drivers/tty/serial/m32r_sio_reg.h (renamed from drivers/serial/m32r_sio_reg.h)0
-rw-r--r--drivers/tty/serial/max3100.c (renamed from drivers/serial/max3100.c)0
-rw-r--r--drivers/tty/serial/max3107-aava.c (renamed from drivers/serial/max3107-aava.c)0
-rw-r--r--drivers/tty/serial/max3107.c (renamed from drivers/serial/max3107.c)0
-rw-r--r--drivers/tty/serial/max3107.h (renamed from drivers/serial/max3107.h)0
-rw-r--r--drivers/tty/serial/mcf.c (renamed from drivers/serial/mcf.c)0
-rw-r--r--drivers/tty/serial/mfd.c (renamed from drivers/serial/mfd.c)0
-rw-r--r--drivers/tty/serial/mpc52xx_uart.c (renamed from drivers/serial/mpc52xx_uart.c)0
-rw-r--r--drivers/tty/serial/mpsc.c (renamed from drivers/serial/mpsc.c)0
-rw-r--r--drivers/tty/serial/mrst_max3110.c (renamed from drivers/serial/mrst_max3110.c)0
-rw-r--r--drivers/tty/serial/mrst_max3110.h (renamed from drivers/serial/mrst_max3110.h)0
-rw-r--r--drivers/tty/serial/msm_serial.c (renamed from drivers/serial/msm_serial.c)0
-rw-r--r--drivers/tty/serial/msm_serial.h (renamed from drivers/serial/msm_serial.h)0
-rw-r--r--drivers/tty/serial/mux.c (renamed from drivers/serial/mux.c)0
-rw-r--r--drivers/tty/serial/netx-serial.c (renamed from drivers/serial/netx-serial.c)0
-rw-r--r--drivers/tty/serial/nwpserial.c (renamed from drivers/serial/nwpserial.c)0
-rw-r--r--drivers/tty/serial/of_serial.c (renamed from drivers/serial/of_serial.c)0
-rw-r--r--drivers/tty/serial/omap-serial.c (renamed from drivers/serial/omap-serial.c)0
-rw-r--r--drivers/tty/serial/pch_uart.c (renamed from drivers/serial/pch_uart.c)0
-rw-r--r--drivers/tty/serial/pmac_zilog.c (renamed from drivers/serial/pmac_zilog.c)0
-rw-r--r--drivers/tty/serial/pmac_zilog.h (renamed from drivers/serial/pmac_zilog.h)0
-rw-r--r--drivers/tty/serial/pnx8xxx_uart.c (renamed from drivers/serial/pnx8xxx_uart.c)0
-rw-r--r--drivers/tty/serial/pxa.c (renamed from drivers/serial/pxa.c)0
-rw-r--r--drivers/tty/serial/s3c2400.c (renamed from drivers/serial/s3c2400.c)0
-rw-r--r--drivers/tty/serial/s3c2410.c (renamed from drivers/serial/s3c2410.c)0
-rw-r--r--drivers/tty/serial/s3c2412.c (renamed from drivers/serial/s3c2412.c)0
-rw-r--r--drivers/tty/serial/s3c2440.c (renamed from drivers/serial/s3c2440.c)0
-rw-r--r--drivers/tty/serial/s3c24a0.c (renamed from drivers/serial/s3c24a0.c)0
-rw-r--r--drivers/tty/serial/s3c6400.c (renamed from drivers/serial/s3c6400.c)0
-rw-r--r--drivers/tty/serial/s5pv210.c (renamed from drivers/serial/s5pv210.c)0
-rw-r--r--drivers/tty/serial/sa1100.c (renamed from drivers/serial/sa1100.c)0
-rw-r--r--drivers/tty/serial/samsung.c (renamed from drivers/serial/samsung.c)0
-rw-r--r--drivers/tty/serial/samsung.h (renamed from drivers/serial/samsung.h)0
-rw-r--r--drivers/tty/serial/sb1250-duart.c (renamed from drivers/serial/sb1250-duart.c)2
-rw-r--r--drivers/tty/serial/sc26xx.c (renamed from drivers/serial/sc26xx.c)0
-rw-r--r--drivers/tty/serial/serial_core.c (renamed from drivers/serial/serial_core.c)0
-rw-r--r--drivers/tty/serial/serial_cs.c (renamed from drivers/serial/serial_cs.c)0
-rw-r--r--drivers/tty/serial/serial_ks8695.c (renamed from drivers/serial/serial_ks8695.c)0
-rw-r--r--drivers/tty/serial/serial_lh7a40x.c (renamed from drivers/serial/serial_lh7a40x.c)0
-rw-r--r--drivers/tty/serial/serial_txx9.c (renamed from drivers/serial/serial_txx9.c)0
-rw-r--r--drivers/tty/serial/sh-sci.c (renamed from drivers/serial/sh-sci.c)0
-rw-r--r--drivers/tty/serial/sh-sci.h (renamed from drivers/serial/sh-sci.h)0
-rw-r--r--drivers/tty/serial/sn_console.c (renamed from drivers/serial/sn_console.c)0
-rw-r--r--drivers/tty/serial/suncore.c (renamed from drivers/serial/suncore.c)0
-rw-r--r--drivers/tty/serial/suncore.h (renamed from drivers/serial/suncore.h)0
-rw-r--r--drivers/tty/serial/sunhv.c (renamed from drivers/serial/sunhv.c)0
-rw-r--r--drivers/tty/serial/sunsab.c (renamed from drivers/serial/sunsab.c)0
-rw-r--r--drivers/tty/serial/sunsab.h (renamed from drivers/serial/sunsab.h)0
-rw-r--r--drivers/tty/serial/sunsu.c (renamed from drivers/serial/sunsu.c)0
-rw-r--r--drivers/tty/serial/sunzilog.c (renamed from drivers/serial/sunzilog.c)0
-rw-r--r--drivers/tty/serial/sunzilog.h (renamed from drivers/serial/sunzilog.h)0
-rw-r--r--drivers/tty/serial/timbuart.c (renamed from drivers/serial/timbuart.c)0
-rw-r--r--drivers/tty/serial/timbuart.h (renamed from drivers/serial/timbuart.h)0
-rw-r--r--drivers/tty/serial/uartlite.c (renamed from drivers/serial/uartlite.c)0
-rw-r--r--drivers/tty/serial/ucc_uart.c (renamed from drivers/serial/ucc_uart.c)0
-rw-r--r--drivers/tty/serial/vr41xx_siu.c (renamed from drivers/serial/vr41xx_siu.c)0
-rw-r--r--drivers/tty/serial/vt8500_serial.c (renamed from drivers/serial/vt8500_serial.c)0
-rw-r--r--drivers/tty/serial/zs.c (renamed from drivers/serial/zs.c)0
-rw-r--r--drivers/tty/serial/zs.h (renamed from drivers/serial/zs.h)0
-rw-r--r--drivers/tty/sysrq.c2
-rw-r--r--drivers/tty/tty_io.c8
-rw-r--r--drivers/tty/vt/selection.c4
-rw-r--r--drivers/tty/vt/vc_screen.c16
-rw-r--r--drivers/tty/vt/vt.c135
-rw-r--r--drivers/tty/vt/vt_ioctl.c60
-rw-r--r--drivers/usb/class/cdc-wdm.c2
-rw-r--r--drivers/usb/core/Kconfig6
-rw-r--r--drivers/usb/core/endpoint.c2
-rw-r--r--drivers/usb/core/hcd-pci.c7
-rw-r--r--drivers/usb/core/hub.c21
-rw-r--r--drivers/usb/gadget/Kconfig7
-rw-r--r--drivers/usb/gadget/ci13xxx_udc.c268
-rw-r--r--drivers/usb/gadget/ci13xxx_udc.h9
-rw-r--r--drivers/usb/gadget/composite.c5
-rw-r--r--drivers/usb/gadget/pch_udc.c127
-rw-r--r--drivers/usb/gadget/printer.c19
-rw-r--r--drivers/usb/host/ehci-fsl.c13
-rw-r--r--drivers/usb/host/ehci-fsl.h3
-rw-r--r--drivers/usb/host/ehci-hcd.c19
-rw-r--r--drivers/usb/host/ehci-mxc.c25
-rw-r--r--drivers/usb/host/ehci-pci.c33
-rw-r--r--drivers/usb/host/fsl-mph-dr-of.c11
-rw-r--r--drivers/usb/host/xhci-ring.c91
-rw-r--r--drivers/usb/host/xhci.c60
-rw-r--r--drivers/usb/host/xhci.h16
-rw-r--r--drivers/usb/misc/usbled.c2
-rw-r--r--drivers/usb/misc/uss720.c1
-rw-r--r--drivers/usb/otg/nop-usb-xceiv.c2
-rw-r--r--drivers/usb/otg/ulpi.c2
-rw-r--r--drivers/usb/serial/ch341.c10
-rw-r--r--drivers/usb/serial/cp210x.c16
-rw-r--r--drivers/usb/serial/digi_acceleport.c10
-rw-r--r--drivers/usb/serial/ftdi_sio.c12
-rw-r--r--drivers/usb/serial/ftdi_sio_ids.h22
-rw-r--r--drivers/usb/serial/generic.c20
-rw-r--r--drivers/usb/serial/io_tables.h1
-rw-r--r--drivers/usb/serial/iuu_phoenix.c1
-rw-r--r--drivers/usb/serial/keyspan.h4
-rw-r--r--drivers/usb/serial/keyspan_pda.c17
-rw-r--r--drivers/usb/serial/moto_modem.c1
-rw-r--r--drivers/usb/serial/option.c23
-rw-r--r--drivers/usb/serial/oti6858.c1
-rw-r--r--drivers/usb/serial/pl2303.c12
-rw-r--r--drivers/usb/serial/pl2303.h1
-rw-r--r--drivers/usb/serial/qcaux.c3
-rw-r--r--drivers/usb/serial/siemens_mpi.c1
-rw-r--r--drivers/usb/serial/spcp8x5.c7
-rw-r--r--drivers/usb/serial/usb-serial.c8
-rw-r--r--drivers/usb/serial/usb_debug.c1
-rw-r--r--drivers/usb/storage/unusual_cypress.h5
-rw-r--r--drivers/usb/storage/unusual_devs.h18
-rw-r--r--drivers/video/Kconfig2
-rw-r--r--drivers/video/arkfb.c12
-rw-r--r--drivers/video/aty/aty128fb.c12
-rw-r--r--drivers/video/aty/atyfb_base.c10
-rw-r--r--drivers/video/aty/radeon_pm.c10
-rw-r--r--drivers/video/backlight/88pm860x_bl.c4
-rw-r--r--drivers/video/bf537-lq035.c58
-rw-r--r--drivers/video/chipsfb.c8
-rw-r--r--drivers/video/console/Kconfig2
-rw-r--r--drivers/video/console/fbcon.c42
-rw-r--r--drivers/video/console/vgacon.c6
-rw-r--r--drivers/video/da8xx-fb.c11
-rw-r--r--drivers/video/fbmem.c12
-rw-r--r--drivers/video/fbsysfs.c20
-rw-r--r--drivers/video/geode/gxfb_core.c8
-rw-r--r--drivers/video/geode/lxfb_core.c8
-rw-r--r--drivers/video/i810/i810_main.c8
-rw-r--r--drivers/video/jz4740_fb.c8
-rw-r--r--drivers/video/mx3fb.c8
-rw-r--r--drivers/video/nuc900fb.c6
-rw-r--r--drivers/video/nvidia/nvidia.c8
-rw-r--r--drivers/video/ps3fb.c16
-rw-r--r--drivers/video/pxa168fb.c6
-rw-r--r--drivers/video/pxa3xx-gcu.c4
-rw-r--r--drivers/video/s3fb.c16
-rw-r--r--drivers/video/savage/savagefb_driver.c8
-rw-r--r--drivers/video/sh_mobile_hdmi.c8
-rw-r--r--drivers/video/sh_mobile_lcdcfb.c4
-rw-r--r--drivers/video/sm501fb.c8
-rw-r--r--drivers/video/tmiofb.c10
-rw-r--r--drivers/video/via/viafbdev.c8
-rw-r--r--drivers/video/vt8623fb.c12
-rw-r--r--drivers/video/xen-fbfront.c4
-rw-r--r--drivers/virtio/virtio_pci.c20
-rw-r--r--drivers/xen/xenfs/xenbus.c31
700 files changed, 8375 insertions, 4785 deletions
diff --git a/drivers/Makefile b/drivers/Makefile
index 7eb35f479461..b423bb16c3a8 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -24,7 +24,7 @@ obj-$(CONFIG_XEN) += xen/
24# regulators early, since some subsystems rely on them to initialize 24# regulators early, since some subsystems rely on them to initialize
25obj-$(CONFIG_REGULATOR) += regulator/ 25obj-$(CONFIG_REGULATOR) += regulator/
26 26
27# char/ comes before serial/ etc so that the VT console is the boot-time 27# tty/ comes before char/ so that the VT console is the boot-time
28# default. 28# default.
29obj-y += tty/ 29obj-y += tty/
30obj-y += char/ 30obj-y += char/
@@ -38,7 +38,6 @@ obj-$(CONFIG_CONNECTOR) += connector/
38obj-$(CONFIG_FB_I810) += video/i810/ 38obj-$(CONFIG_FB_I810) += video/i810/
39obj-$(CONFIG_FB_INTEL) += video/intelfb/ 39obj-$(CONFIG_FB_INTEL) += video/intelfb/
40 40
41obj-y += serial/
42obj-$(CONFIG_PARPORT) += parport/ 41obj-$(CONFIG_PARPORT) += parport/
43obj-y += base/ block/ misc/ mfd/ nfc/ 42obj-y += base/ block/ misc/ mfd/ nfc/
44obj-$(CONFIG_NUBUS) += nubus/ 43obj-$(CONFIG_NUBUS) += nubus/
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 10c7ad59c0e1..2aa042a5da6d 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -318,7 +318,7 @@ config ACPI_PCI_SLOT
318 the module will be called pci_slot. 318 the module will be called pci_slot.
319 319
320config X86_PM_TIMER 320config X86_PM_TIMER
321 bool "Power Management Timer Support" if EMBEDDED 321 bool "Power Management Timer Support" if EXPERT
322 depends on X86 322 depends on X86
323 default y 323 default y
324 help 324 help
diff --git a/drivers/acpi/acpica/accommon.h b/drivers/acpi/acpica/accommon.h
index 3e50c74ed4a1..e0ba17f0a7c8 100644
--- a/drivers/acpi/acpica/accommon.h
+++ b/drivers/acpi/acpica/accommon.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acconfig.h b/drivers/acpi/acpica/acconfig.h
index b17d8de9f6ff..ab87396c2c07 100644
--- a/drivers/acpi/acpica/acconfig.h
+++ b/drivers/acpi/acpica/acconfig.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acdebug.h b/drivers/acpi/acpica/acdebug.h
index 72e9d5eb083c..eb0b1f8dee6d 100644
--- a/drivers/acpi/acpica/acdebug.h
+++ b/drivers/acpi/acpica/acdebug.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acdispat.h b/drivers/acpi/acpica/acdispat.h
index 894a0ff2a946..666271b65418 100644
--- a/drivers/acpi/acpica/acdispat.h
+++ b/drivers/acpi/acpica/acdispat.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acevents.h b/drivers/acpi/acpica/acevents.h
index 70e0b28801aa..41d247daf461 100644
--- a/drivers/acpi/acpica/acevents.h
+++ b/drivers/acpi/acpica/acevents.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index 0e4dba0d0325..82a1bd283db8 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/achware.h b/drivers/acpi/acpica/achware.h
index 258d628793ea..e7213beaafc7 100644
--- a/drivers/acpi/acpica/achware.h
+++ b/drivers/acpi/acpica/achware.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acinterp.h b/drivers/acpi/acpica/acinterp.h
index 049e203bd621..3731e1c34b83 100644
--- a/drivers/acpi/acpica/acinterp.h
+++ b/drivers/acpi/acpica/acinterp.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index 74000f5b7dab..54784bb42cec 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h
index 8d5c9e0a495f..b7491ee1fba6 100644
--- a/drivers/acpi/acpica/acmacros.h
+++ b/drivers/acpi/acpica/acmacros.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acnamesp.h b/drivers/acpi/acpica/acnamesp.h
index d44d3bc5b847..79a598c67fe3 100644
--- a/drivers/acpi/acpica/acnamesp.h
+++ b/drivers/acpi/acpica/acnamesp.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acobject.h b/drivers/acpi/acpica/acobject.h
index 962a3ccff6fd..1055769f2f01 100644
--- a/drivers/acpi/acpica/acobject.h
+++ b/drivers/acpi/acpica/acobject.h
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -97,8 +97,6 @@
97#define AOPOBJ_OBJECT_INITIALIZED 0x08 /* Region is initialized, _REG was run */ 97#define AOPOBJ_OBJECT_INITIALIZED 0x08 /* Region is initialized, _REG was run */
98#define AOPOBJ_SETUP_COMPLETE 0x10 /* Region setup is complete */ 98#define AOPOBJ_SETUP_COMPLETE 0x10 /* Region setup is complete */
99#define AOPOBJ_INVALID 0x20 /* Host OS won't allow a Region address */ 99#define AOPOBJ_INVALID 0x20 /* Host OS won't allow a Region address */
100#define AOPOBJ_MODULE_LEVEL 0x40 /* Method is actually module-level code */
101#define AOPOBJ_MODIFIED_NAMESPACE 0x80 /* Method modified the namespace */
102 100
103/****************************************************************************** 101/******************************************************************************
104 * 102 *
@@ -175,7 +173,7 @@ struct acpi_object_region {
175}; 173};
176 174
177struct acpi_object_method { 175struct acpi_object_method {
178 ACPI_OBJECT_COMMON_HEADER u8 method_flags; 176 ACPI_OBJECT_COMMON_HEADER u8 info_flags;
179 u8 param_count; 177 u8 param_count;
180 u8 sync_level; 178 u8 sync_level;
181 union acpi_operand_object *mutex; 179 union acpi_operand_object *mutex;
@@ -183,13 +181,21 @@ struct acpi_object_method {
183 union { 181 union {
184 ACPI_INTERNAL_METHOD implementation; 182 ACPI_INTERNAL_METHOD implementation;
185 union acpi_operand_object *handler; 183 union acpi_operand_object *handler;
186 } extra; 184 } dispatch;
187 185
188 u32 aml_length; 186 u32 aml_length;
189 u8 thread_count; 187 u8 thread_count;
190 acpi_owner_id owner_id; 188 acpi_owner_id owner_id;
191}; 189};
192 190
191/* Flags for info_flags field above */
192
193#define ACPI_METHOD_MODULE_LEVEL 0x01 /* Method is actually module-level code */
194#define ACPI_METHOD_INTERNAL_ONLY 0x02 /* Method is implemented internally (_OSI) */
195#define ACPI_METHOD_SERIALIZED 0x04 /* Method is serialized */
196#define ACPI_METHOD_SERIALIZED_PENDING 0x08 /* Method is to be marked serialized */
197#define ACPI_METHOD_MODIFIED_NAMESPACE 0x10 /* Method modified the namespace */
198
193/****************************************************************************** 199/******************************************************************************
194 * 200 *
195 * Objects that can be notified. All share a common notify_info area. 201 * Objects that can be notified. All share a common notify_info area.
diff --git a/drivers/acpi/acpica/acopcode.h b/drivers/acpi/acpica/acopcode.h
index 8c15ff43f42b..bb2ccfad7376 100644
--- a/drivers/acpi/acpica/acopcode.h
+++ b/drivers/acpi/acpica/acopcode.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acparser.h b/drivers/acpi/acpica/acparser.h
index d0bb0fd3e57a..5ea1e06afa20 100644
--- a/drivers/acpi/acpica/acparser.h
+++ b/drivers/acpi/acpica/acparser.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acpredef.h b/drivers/acpi/acpica/acpredef.h
index 10998d369ad0..94e73c97cf85 100644
--- a/drivers/acpi/acpica/acpredef.h
+++ b/drivers/acpi/acpica/acpredef.h
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acresrc.h b/drivers/acpi/acpica/acresrc.h
index 528bcbaf4ce7..f08b55b7f3a0 100644
--- a/drivers/acpi/acpica/acresrc.h
+++ b/drivers/acpi/acpica/acresrc.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acstruct.h b/drivers/acpi/acpica/acstruct.h
index 6e5dd97949fe..1623b245dde2 100644
--- a/drivers/acpi/acpica/acstruct.h
+++ b/drivers/acpi/acpica/acstruct.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/actables.h b/drivers/acpi/acpica/actables.h
index 62a576e34361..967f08124eba 100644
--- a/drivers/acpi/acpica/actables.h
+++ b/drivers/acpi/acpica/actables.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
index 72e4183c1937..99c140d8e348 100644
--- a/drivers/acpi/acpica/acutils.h
+++ b/drivers/acpi/acpica/acutils.h
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/amlcode.h b/drivers/acpi/acpica/amlcode.h
index 1f484ba228fc..f4f0998d3967 100644
--- a/drivers/acpi/acpica/amlcode.h
+++ b/drivers/acpi/acpica/amlcode.h
@@ -7,7 +7,7 @@
7 *****************************************************************************/ 7 *****************************************************************************/
8 8
9/* 9/*
10 * Copyright (C) 2000 - 2010, Intel Corp. 10 * Copyright (C) 2000 - 2011, Intel Corp.
11 * All rights reserved. 11 * All rights reserved.
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
@@ -480,16 +480,10 @@ typedef enum {
480 AML_FIELD_ATTRIB_SMB_BLOCK_CALL = 0x0D 480 AML_FIELD_ATTRIB_SMB_BLOCK_CALL = 0x0D
481} AML_ACCESS_ATTRIBUTE; 481} AML_ACCESS_ATTRIBUTE;
482 482
483/* Bit fields in method_flags byte */ 483/* Bit fields in the AML method_flags byte */
484 484
485#define AML_METHOD_ARG_COUNT 0x07 485#define AML_METHOD_ARG_COUNT 0x07
486#define AML_METHOD_SERIALIZED 0x08 486#define AML_METHOD_SERIALIZED 0x08
487#define AML_METHOD_SYNC_LEVEL 0xF0 487#define AML_METHOD_SYNC_LEVEL 0xF0
488 488
489/* METHOD_FLAGS_ARG_COUNT is not used internally, define additional flags */
490
491#define AML_METHOD_INTERNAL_ONLY 0x01
492#define AML_METHOD_RESERVED1 0x02
493#define AML_METHOD_RESERVED2 0x04
494
495#endif /* __AMLCODE_H__ */ 489#endif /* __AMLCODE_H__ */
diff --git a/drivers/acpi/acpica/amlresrc.h b/drivers/acpi/acpica/amlresrc.h
index 0e5798fcbb19..59122cde247c 100644
--- a/drivers/acpi/acpica/amlresrc.h
+++ b/drivers/acpi/acpica/amlresrc.h
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dsfield.c b/drivers/acpi/acpica/dsfield.c
index 347bee1726f1..34be60c0e448 100644
--- a/drivers/acpi/acpica/dsfield.c
+++ b/drivers/acpi/acpica/dsfield.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dsinit.c b/drivers/acpi/acpica/dsinit.c
index cc4a38c57558..a7718bf2b9a1 100644
--- a/drivers/acpi/acpica/dsinit.c
+++ b/drivers/acpi/acpica/dsinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dsmethod.c b/drivers/acpi/acpica/dsmethod.c
index d94dd8974b55..5d797751e205 100644
--- a/drivers/acpi/acpica/dsmethod.c
+++ b/drivers/acpi/acpica/dsmethod.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -43,7 +43,6 @@
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include "accommon.h" 45#include "accommon.h"
46#include "amlcode.h"
47#include "acdispat.h" 46#include "acdispat.h"
48#include "acinterp.h" 47#include "acinterp.h"
49#include "acnamesp.h" 48#include "acnamesp.h"
@@ -201,7 +200,7 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node,
201 /* 200 /*
202 * If this method is serialized, we need to acquire the method mutex. 201 * If this method is serialized, we need to acquire the method mutex.
203 */ 202 */
204 if (obj_desc->method.method_flags & AML_METHOD_SERIALIZED) { 203 if (obj_desc->method.info_flags & ACPI_METHOD_SERIALIZED) {
205 /* 204 /*
206 * Create a mutex for the method if it is defined to be Serialized 205 * Create a mutex for the method if it is defined to be Serialized
207 * and a mutex has not already been created. We defer the mutex creation 206 * and a mutex has not already been created. We defer the mutex creation
@@ -413,8 +412,9 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread,
413 412
414 /* Invoke an internal method if necessary */ 413 /* Invoke an internal method if necessary */
415 414
416 if (obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) { 415 if (obj_desc->method.info_flags & ACPI_METHOD_INTERNAL_ONLY) {
417 status = obj_desc->method.extra.implementation(next_walk_state); 416 status =
417 obj_desc->method.dispatch.implementation(next_walk_state);
418 if (status == AE_OK) { 418 if (status == AE_OK) {
419 status = AE_CTRL_TERMINATE; 419 status = AE_CTRL_TERMINATE;
420 } 420 }
@@ -579,11 +579,14 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
579 579
580 /* 580 /*
581 * Delete any namespace objects created anywhere within the 581 * Delete any namespace objects created anywhere within the
582 * namespace by the execution of this method. Unless this method 582 * namespace by the execution of this method. Unless:
583 * is a module-level executable code method, in which case we 583 * 1) This method is a module-level executable code method, in which
584 * want make the objects permanent. 584 * case we want make the objects permanent.
585 * 2) There are other threads executing the method, in which case we
586 * will wait until the last thread has completed.
585 */ 587 */
586 if (!(method_desc->method.flags & AOPOBJ_MODULE_LEVEL)) { 588 if (!(method_desc->method.info_flags & ACPI_METHOD_MODULE_LEVEL)
589 && (method_desc->method.thread_count == 1)) {
587 590
588 /* Delete any direct children of (created by) this method */ 591 /* Delete any direct children of (created by) this method */
589 592
@@ -593,12 +596,17 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
593 /* 596 /*
594 * Delete any objects that were created by this method 597 * Delete any objects that were created by this method
595 * elsewhere in the namespace (if any were created). 598 * elsewhere in the namespace (if any were created).
599 * Use of the ACPI_METHOD_MODIFIED_NAMESPACE optimizes the
600 * deletion such that we don't have to perform an entire
601 * namespace walk for every control method execution.
596 */ 602 */
597 if (method_desc->method. 603 if (method_desc->method.
598 flags & AOPOBJ_MODIFIED_NAMESPACE) { 604 info_flags & ACPI_METHOD_MODIFIED_NAMESPACE) {
599 acpi_ns_delete_namespace_by_owner(method_desc-> 605 acpi_ns_delete_namespace_by_owner(method_desc->
600 method. 606 method.
601 owner_id); 607 owner_id);
608 method_desc->method.info_flags &=
609 ~ACPI_METHOD_MODIFIED_NAMESPACE;
602 } 610 }
603 } 611 }
604 } 612 }
@@ -629,19 +637,43 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
629 * Serialized if it appears that the method is incorrectly written and 637 * Serialized if it appears that the method is incorrectly written and
630 * does not support multiple thread execution. The best example of this 638 * does not support multiple thread execution. The best example of this
631 * is if such a method creates namespace objects and blocks. A second 639 * is if such a method creates namespace objects and blocks. A second
632 * thread will fail with an AE_ALREADY_EXISTS exception 640 * thread will fail with an AE_ALREADY_EXISTS exception.
633 * 641 *
634 * This code is here because we must wait until the last thread exits 642 * This code is here because we must wait until the last thread exits
635 * before creating the synchronization semaphore. 643 * before marking the method as serialized.
636 */ 644 */
637 if ((method_desc->method.method_flags & AML_METHOD_SERIALIZED) 645 if (method_desc->method.
638 && (!method_desc->method.mutex)) { 646 info_flags & ACPI_METHOD_SERIALIZED_PENDING) {
639 (void)acpi_ds_create_method_mutex(method_desc); 647 if (walk_state) {
648 ACPI_INFO((AE_INFO,
649 "Marking method %4.4s as Serialized because of AE_ALREADY_EXISTS error",
650 walk_state->method_node->name.
651 ascii));
652 }
653
654 /*
655 * Method tried to create an object twice and was marked as
656 * "pending serialized". The probable cause is that the method
657 * cannot handle reentrancy.
658 *
659 * The method was created as not_serialized, but it tried to create
660 * a named object and then blocked, causing the second thread
661 * entrance to begin and then fail. Workaround this problem by
662 * marking the method permanently as Serialized when the last
663 * thread exits here.
664 */
665 method_desc->method.info_flags &=
666 ~ACPI_METHOD_SERIALIZED_PENDING;
667 method_desc->method.info_flags |=
668 ACPI_METHOD_SERIALIZED;
669 method_desc->method.sync_level = 0;
640 } 670 }
641 671
642 /* No more threads, we can free the owner_id */ 672 /* No more threads, we can free the owner_id */
643 673
644 if (!(method_desc->method.flags & AOPOBJ_MODULE_LEVEL)) { 674 if (!
675 (method_desc->method.
676 info_flags & ACPI_METHOD_MODULE_LEVEL)) {
645 acpi_ut_release_owner_id(&method_desc->method.owner_id); 677 acpi_ut_release_owner_id(&method_desc->method.owner_id);
646 } 678 }
647 } 679 }
diff --git a/drivers/acpi/acpica/dsmthdat.c b/drivers/acpi/acpica/dsmthdat.c
index 8095306fcd8c..905ce29a92e1 100644
--- a/drivers/acpi/acpica/dsmthdat.c
+++ b/drivers/acpi/acpica/dsmthdat.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dsobject.c b/drivers/acpi/acpica/dsobject.c
index 8e85f54a8e0e..f42e17e5c252 100644
--- a/drivers/acpi/acpica/dsobject.c
+++ b/drivers/acpi/acpica/dsobject.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dsopcode.c b/drivers/acpi/acpica/dsopcode.c
index 7c0e74227171..bbecf293aeeb 100644
--- a/drivers/acpi/acpica/dsopcode.c
+++ b/drivers/acpi/acpica/dsopcode.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dsutils.c b/drivers/acpi/acpica/dsutils.c
index 15135c25aa9b..2c477ce172fa 100644
--- a/drivers/acpi/acpica/dsutils.c
+++ b/drivers/acpi/acpica/dsutils.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dswexec.c b/drivers/acpi/acpica/dswexec.c
index 6b0b5d08d97a..fe40e4c6554f 100644
--- a/drivers/acpi/acpica/dswexec.c
+++ b/drivers/acpi/acpica/dswexec.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dswload.c b/drivers/acpi/acpica/dswload.c
index 140a9d002959..52566ff5e903 100644
--- a/drivers/acpi/acpica/dswload.c
+++ b/drivers/acpi/acpica/dswload.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dswscope.c b/drivers/acpi/acpica/dswscope.c
index d1e701709dac..76a661fc1e09 100644
--- a/drivers/acpi/acpica/dswscope.c
+++ b/drivers/acpi/acpica/dswscope.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/dswstate.c b/drivers/acpi/acpica/dswstate.c
index 83155dd8671e..a6c374ef9914 100644
--- a/drivers/acpi/acpica/dswstate.c
+++ b/drivers/acpi/acpica/dswstate.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evevent.c b/drivers/acpi/acpica/evevent.c
index e5e313c663a5..d458b041e651 100644
--- a/drivers/acpi/acpica/evevent.c
+++ b/drivers/acpi/acpica/evevent.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c
index 7c339d34ab42..14988a86066f 100644
--- a/drivers/acpi/acpica/evgpe.c
+++ b/drivers/acpi/acpica/evgpe.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -471,6 +471,7 @@ static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context)
471 471
472 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); 472 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
473 if (ACPI_FAILURE(status)) { 473 if (ACPI_FAILURE(status)) {
474 ACPI_FREE(local_gpe_event_info);
474 return_VOID; 475 return_VOID;
475 } 476 }
476 477
@@ -478,6 +479,7 @@ static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context)
478 479
479 if (!acpi_ev_valid_gpe_event(gpe_event_info)) { 480 if (!acpi_ev_valid_gpe_event(gpe_event_info)) {
480 status = acpi_ut_release_mutex(ACPI_MTX_EVENTS); 481 status = acpi_ut_release_mutex(ACPI_MTX_EVENTS);
482 ACPI_FREE(local_gpe_event_info);
481 return_VOID; 483 return_VOID;
482 } 484 }
483 485
diff --git a/drivers/acpi/acpica/evgpeblk.c b/drivers/acpi/acpica/evgpeblk.c
index 9acb86958c09..ca2c41a53311 100644
--- a/drivers/acpi/acpica/evgpeblk.c
+++ b/drivers/acpi/acpica/evgpeblk.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evgpeinit.c b/drivers/acpi/acpica/evgpeinit.c
index c59dc2340593..ce9aa9f9a972 100644
--- a/drivers/acpi/acpica/evgpeinit.c
+++ b/drivers/acpi/acpica/evgpeinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evgpeutil.c b/drivers/acpi/acpica/evgpeutil.c
index 10e477494dcf..80a81d0c4a80 100644
--- a/drivers/acpi/acpica/evgpeutil.c
+++ b/drivers/acpi/acpica/evgpeutil.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evmisc.c b/drivers/acpi/acpica/evmisc.c
index 38bba66fcce5..7dc80946f7bd 100644
--- a/drivers/acpi/acpica/evmisc.c
+++ b/drivers/acpi/acpica/evmisc.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evregion.c b/drivers/acpi/acpica/evregion.c
index 98fd210e87b2..785a5ee64585 100644
--- a/drivers/acpi/acpica/evregion.c
+++ b/drivers/acpi/acpica/evregion.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evrgnini.c b/drivers/acpi/acpica/evrgnini.c
index 0b47a6dc9290..9659cee6093e 100644
--- a/drivers/acpi/acpica/evrgnini.c
+++ b/drivers/acpi/acpica/evrgnini.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -590,9 +590,9 @@ acpi_ev_initialize_region(union acpi_operand_object *region_obj,
590 * See acpi_ns_exec_module_code 590 * See acpi_ns_exec_module_code
591 */ 591 */
592 if (obj_desc->method. 592 if (obj_desc->method.
593 flags & AOPOBJ_MODULE_LEVEL) { 593 info_flags & ACPI_METHOD_MODULE_LEVEL) {
594 handler_obj = 594 handler_obj =
595 obj_desc->method.extra.handler; 595 obj_desc->method.dispatch.handler;
596 } 596 }
597 break; 597 break;
598 598
diff --git a/drivers/acpi/acpica/evsci.c b/drivers/acpi/acpica/evsci.c
index 8dfbaa96e422..2ebd40e1a3ef 100644
--- a/drivers/acpi/acpica/evsci.c
+++ b/drivers/acpi/acpica/evsci.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evxface.c b/drivers/acpi/acpica/evxface.c
index 1226689bdb1b..e1141402dbed 100644
--- a/drivers/acpi/acpica/evxface.c
+++ b/drivers/acpi/acpica/evxface.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evxfevnt.c b/drivers/acpi/acpica/evxfevnt.c
index 90488c1e0f3d..c57b5c707a77 100644
--- a/drivers/acpi/acpica/evxfevnt.c
+++ b/drivers/acpi/acpica/evxfevnt.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evxfgpe.c b/drivers/acpi/acpica/evxfgpe.c
index 416845bc9c1f..e9562a7cb2f9 100644
--- a/drivers/acpi/acpica/evxfgpe.c
+++ b/drivers/acpi/acpica/evxfgpe.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/evxfregn.c b/drivers/acpi/acpica/evxfregn.c
index ce9314f79451..eb7386763712 100644
--- a/drivers/acpi/acpica/evxfregn.c
+++ b/drivers/acpi/acpica/evxfregn.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exconfig.c b/drivers/acpi/acpica/exconfig.c
index 18832205b631..745a42b401f5 100644
--- a/drivers/acpi/acpica/exconfig.c
+++ b/drivers/acpi/acpica/exconfig.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exconvrt.c b/drivers/acpi/acpica/exconvrt.c
index b73bc50c5b76..74162a11817d 100644
--- a/drivers/acpi/acpica/exconvrt.c
+++ b/drivers/acpi/acpica/exconvrt.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/excreate.c b/drivers/acpi/acpica/excreate.c
index 3c61b48c73f5..e7b372d17667 100644
--- a/drivers/acpi/acpica/excreate.c
+++ b/drivers/acpi/acpica/excreate.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -482,13 +482,11 @@ acpi_ex_create_method(u8 * aml_start,
482 obj_desc->method.aml_length = aml_length; 482 obj_desc->method.aml_length = aml_length;
483 483
484 /* 484 /*
485 * Disassemble the method flags. Split off the Arg Count 485 * Disassemble the method flags. Split off the arg_count, Serialized
486 * for efficiency 486 * flag, and sync_level for efficiency.
487 */ 487 */
488 method_flags = (u8) operand[1]->integer.value; 488 method_flags = (u8) operand[1]->integer.value;
489 489
490 obj_desc->method.method_flags =
491 (u8) (method_flags & ~AML_METHOD_ARG_COUNT);
492 obj_desc->method.param_count = 490 obj_desc->method.param_count =
493 (u8) (method_flags & AML_METHOD_ARG_COUNT); 491 (u8) (method_flags & AML_METHOD_ARG_COUNT);
494 492
@@ -497,6 +495,8 @@ acpi_ex_create_method(u8 * aml_start,
497 * created for this method when it is parsed. 495 * created for this method when it is parsed.
498 */ 496 */
499 if (method_flags & AML_METHOD_SERIALIZED) { 497 if (method_flags & AML_METHOD_SERIALIZED) {
498 obj_desc->method.info_flags = ACPI_METHOD_SERIALIZED;
499
500 /* 500 /*
501 * ACPI 1.0: sync_level = 0 501 * ACPI 1.0: sync_level = 0
502 * ACPI 2.0: sync_level = sync_level in method declaration 502 * ACPI 2.0: sync_level = sync_level in method declaration
diff --git a/drivers/acpi/acpica/exdebug.c b/drivers/acpi/acpica/exdebug.c
index be8c98b480d7..c7a2f1edd282 100644
--- a/drivers/acpi/acpica/exdebug.c
+++ b/drivers/acpi/acpica/exdebug.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exdump.c b/drivers/acpi/acpica/exdump.c
index f067bbb0d961..61b8c0e8b74d 100644
--- a/drivers/acpi/acpica/exdump.c
+++ b/drivers/acpi/acpica/exdump.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -122,7 +122,7 @@ static struct acpi_exdump_info acpi_ex_dump_event[2] = {
122 122
123static struct acpi_exdump_info acpi_ex_dump_method[9] = { 123static struct acpi_exdump_info acpi_ex_dump_method[9] = {
124 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_method), NULL}, 124 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_method), NULL},
125 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.method_flags), "Method Flags"}, 125 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.info_flags), "Info Flags"},
126 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.param_count), 126 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.param_count),
127 "Parameter Count"}, 127 "Parameter Count"},
128 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.sync_level), "Sync Level"}, 128 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.sync_level), "Sync Level"},
diff --git a/drivers/acpi/acpica/exfield.c b/drivers/acpi/acpica/exfield.c
index f17d2ff0031b..0bde2230c028 100644
--- a/drivers/acpi/acpica/exfield.c
+++ b/drivers/acpi/acpica/exfield.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exfldio.c b/drivers/acpi/acpica/exfldio.c
index 38293fd3e088..6c79c29f082d 100644
--- a/drivers/acpi/acpica/exfldio.c
+++ b/drivers/acpi/acpica/exfldio.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exmisc.c b/drivers/acpi/acpica/exmisc.c
index 95db4be0877b..703d88ed0b3d 100644
--- a/drivers/acpi/acpica/exmisc.c
+++ b/drivers/acpi/acpica/exmisc.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exmutex.c b/drivers/acpi/acpica/exmutex.c
index 6af14e43f839..be1c56ead653 100644
--- a/drivers/acpi/acpica/exmutex.c
+++ b/drivers/acpi/acpica/exmutex.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exnames.c b/drivers/acpi/acpica/exnames.c
index d11e539ef763..49ec049c157e 100644
--- a/drivers/acpi/acpica/exnames.c
+++ b/drivers/acpi/acpica/exnames.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exoparg1.c b/drivers/acpi/acpica/exoparg1.c
index 84e4d185aa25..236ead14b7f7 100644
--- a/drivers/acpi/acpica/exoparg1.c
+++ b/drivers/acpi/acpica/exoparg1.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exoparg2.c b/drivers/acpi/acpica/exoparg2.c
index 10e104cf0fb9..2571b4a310f4 100644
--- a/drivers/acpi/acpica/exoparg2.c
+++ b/drivers/acpi/acpica/exoparg2.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exoparg3.c b/drivers/acpi/acpica/exoparg3.c
index 7a08d23befcd..1b48d9d28c9a 100644
--- a/drivers/acpi/acpica/exoparg3.c
+++ b/drivers/acpi/acpica/exoparg3.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exoparg6.c b/drivers/acpi/acpica/exoparg6.c
index 4b50730cf9a0..f4a2787e8e92 100644
--- a/drivers/acpi/acpica/exoparg6.c
+++ b/drivers/acpi/acpica/exoparg6.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exprep.c b/drivers/acpi/acpica/exprep.c
index 7aae29f73d3f..cc95e2000406 100644
--- a/drivers/acpi/acpica/exprep.c
+++ b/drivers/acpi/acpica/exprep.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exregion.c b/drivers/acpi/acpica/exregion.c
index de17e10da0ed..f0d5e14f1f2c 100644
--- a/drivers/acpi/acpica/exregion.c
+++ b/drivers/acpi/acpica/exregion.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exresnte.c b/drivers/acpi/acpica/exresnte.c
index 1fa4289a687e..55997e46948b 100644
--- a/drivers/acpi/acpica/exresnte.c
+++ b/drivers/acpi/acpica/exresnte.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exresolv.c b/drivers/acpi/acpica/exresolv.c
index 7ca35ea8acea..db502cd7d934 100644
--- a/drivers/acpi/acpica/exresolv.c
+++ b/drivers/acpi/acpica/exresolv.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exresop.c b/drivers/acpi/acpica/exresop.c
index 8c97cfd6a0fd..e3bb00ccdff5 100644
--- a/drivers/acpi/acpica/exresop.c
+++ b/drivers/acpi/acpica/exresop.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exstore.c b/drivers/acpi/acpica/exstore.c
index 1624436ba4c5..c0c8842dd344 100644
--- a/drivers/acpi/acpica/exstore.c
+++ b/drivers/acpi/acpica/exstore.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exstoren.c b/drivers/acpi/acpica/exstoren.c
index d4af684620ca..a979017d56b8 100644
--- a/drivers/acpi/acpica/exstoren.c
+++ b/drivers/acpi/acpica/exstoren.c
@@ -7,7 +7,7 @@
7 *****************************************************************************/ 7 *****************************************************************************/
8 8
9/* 9/*
10 * Copyright (C) 2000 - 2010, Intel Corp. 10 * Copyright (C) 2000 - 2011, Intel Corp.
11 * All rights reserved. 11 * All rights reserved.
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exstorob.c b/drivers/acpi/acpica/exstorob.c
index e972b667b09b..dc665cc554de 100644
--- a/drivers/acpi/acpica/exstorob.c
+++ b/drivers/acpi/acpica/exstorob.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exsystem.c b/drivers/acpi/acpica/exsystem.c
index 675aaa91a770..df66e7b686be 100644
--- a/drivers/acpi/acpica/exsystem.c
+++ b/drivers/acpi/acpica/exsystem.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/exutils.c b/drivers/acpi/acpica/exutils.c
index 4093522eed45..8ad93146dd32 100644
--- a/drivers/acpi/acpica/exutils.c
+++ b/drivers/acpi/acpica/exutils.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwacpi.c b/drivers/acpi/acpica/hwacpi.c
index b44274a0b62c..fc380d3d45ab 100644
--- a/drivers/acpi/acpica/hwacpi.c
+++ b/drivers/acpi/acpica/hwacpi.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwgpe.c b/drivers/acpi/acpica/hwgpe.c
index 85c3cbd4304d..f610d88a66be 100644
--- a/drivers/acpi/acpica/hwgpe.c
+++ b/drivers/acpi/acpica/hwgpe.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwpci.c b/drivers/acpi/acpica/hwpci.c
index ad21c7d8bf4f..050fd227951b 100644
--- a/drivers/acpi/acpica/hwpci.c
+++ b/drivers/acpi/acpica/hwpci.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c
index 5d1273b660ae..55accb7018bb 100644
--- a/drivers/acpi/acpica/hwregs.c
+++ b/drivers/acpi/acpica/hwregs.c
@@ -7,7 +7,7 @@
7 ******************************************************************************/ 7 ******************************************************************************/
8 8
9/* 9/*
10 * Copyright (C) 2000 - 2010, Intel Corp. 10 * Copyright (C) 2000 - 2011, Intel Corp.
11 * All rights reserved. 11 * All rights reserved.
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwsleep.c b/drivers/acpi/acpica/hwsleep.c
index 3796811276ac..2ac28bbe8827 100644
--- a/drivers/acpi/acpica/hwsleep.c
+++ b/drivers/acpi/acpica/hwsleep.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwtimer.c b/drivers/acpi/acpica/hwtimer.c
index 1ef8e0bb250b..9c8eb71a12fb 100644
--- a/drivers/acpi/acpica/hwtimer.c
+++ b/drivers/acpi/acpica/hwtimer.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwvalid.c b/drivers/acpi/acpica/hwvalid.c
index e1d9c777b213..5f1605874655 100644
--- a/drivers/acpi/acpica/hwvalid.c
+++ b/drivers/acpi/acpica/hwvalid.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/hwxface.c b/drivers/acpi/acpica/hwxface.c
index 50cc3be77724..6f98d210e71c 100644
--- a/drivers/acpi/acpica/hwxface.c
+++ b/drivers/acpi/acpica/hwxface.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsaccess.c b/drivers/acpi/acpica/nsaccess.c
index 0cd925be5fc1..d93172fd15a8 100644
--- a/drivers/acpi/acpica/nsaccess.c
+++ b/drivers/acpi/acpica/nsaccess.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -163,9 +163,9 @@ acpi_status acpi_ns_root_initialize(void)
163#else 163#else
164 /* Mark this as a very SPECIAL method */ 164 /* Mark this as a very SPECIAL method */
165 165
166 obj_desc->method.method_flags = 166 obj_desc->method.info_flags =
167 AML_METHOD_INTERNAL_ONLY; 167 ACPI_METHOD_INTERNAL_ONLY;
168 obj_desc->method.extra.implementation = 168 obj_desc->method.dispatch.implementation =
169 acpi_ut_osi_implementation; 169 acpi_ut_osi_implementation;
170#endif 170#endif
171 break; 171 break;
diff --git a/drivers/acpi/acpica/nsalloc.c b/drivers/acpi/acpica/nsalloc.c
index 1e5ff803d9ad..1d0ef15d158f 100644
--- a/drivers/acpi/acpica/nsalloc.c
+++ b/drivers/acpi/acpica/nsalloc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -234,8 +234,8 @@ void acpi_ns_install_node(struct acpi_walk_state *walk_state, struct acpi_namesp
234 * modified the namespace. This is used for cleanup when the 234 * modified the namespace. This is used for cleanup when the
235 * method exits. 235 * method exits.
236 */ 236 */
237 walk_state->method_desc->method.flags |= 237 walk_state->method_desc->method.info_flags |=
238 AOPOBJ_MODIFIED_NAMESPACE; 238 ACPI_METHOD_MODIFIED_NAMESPACE;
239 } 239 }
240 } 240 }
241 241
@@ -341,6 +341,7 @@ void acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_node)
341{ 341{
342 struct acpi_namespace_node *child_node = NULL; 342 struct acpi_namespace_node *child_node = NULL;
343 u32 level = 1; 343 u32 level = 1;
344 acpi_status status;
344 345
345 ACPI_FUNCTION_TRACE(ns_delete_namespace_subtree); 346 ACPI_FUNCTION_TRACE(ns_delete_namespace_subtree);
346 347
@@ -348,6 +349,13 @@ void acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_node)
348 return_VOID; 349 return_VOID;
349 } 350 }
350 351
352 /* Lock namespace for possible update */
353
354 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
355 if (ACPI_FAILURE(status)) {
356 return_VOID;
357 }
358
351 /* 359 /*
352 * Traverse the tree of objects until we bubble back up 360 * Traverse the tree of objects until we bubble back up
353 * to where we started. 361 * to where we started.
@@ -397,6 +405,7 @@ void acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_node)
397 } 405 }
398 } 406 }
399 407
408 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
400 return_VOID; 409 return_VOID;
401} 410}
402 411
diff --git a/drivers/acpi/acpica/nsdump.c b/drivers/acpi/acpica/nsdump.c
index a54dc39e304b..b683cc2ff9d3 100644
--- a/drivers/acpi/acpica/nsdump.c
+++ b/drivers/acpi/acpica/nsdump.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -624,9 +624,22 @@ acpi_ns_dump_objects(acpi_object_type type,
624 acpi_owner_id owner_id, acpi_handle start_handle) 624 acpi_owner_id owner_id, acpi_handle start_handle)
625{ 625{
626 struct acpi_walk_info info; 626 struct acpi_walk_info info;
627 acpi_status status;
627 628
628 ACPI_FUNCTION_ENTRY(); 629 ACPI_FUNCTION_ENTRY();
629 630
631 /*
632 * Just lock the entire namespace for the duration of the dump.
633 * We don't want any changes to the namespace during this time,
634 * especially the temporary nodes since we are going to display
635 * them also.
636 */
637 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
638 if (ACPI_FAILURE(status)) {
639 acpi_os_printf("Could not acquire namespace mutex\n");
640 return;
641 }
642
630 info.debug_level = ACPI_LV_TABLES; 643 info.debug_level = ACPI_LV_TABLES;
631 info.owner_id = owner_id; 644 info.owner_id = owner_id;
632 info.display_type = display_type; 645 info.display_type = display_type;
@@ -636,6 +649,8 @@ acpi_ns_dump_objects(acpi_object_type type,
636 ACPI_NS_WALK_TEMP_NODES, 649 ACPI_NS_WALK_TEMP_NODES,
637 acpi_ns_dump_one_object, NULL, 650 acpi_ns_dump_one_object, NULL,
638 (void *)&info, NULL); 651 (void *)&info, NULL);
652
653 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
639} 654}
640#endif /* ACPI_FUTURE_USAGE */ 655#endif /* ACPI_FUTURE_USAGE */
641 656
diff --git a/drivers/acpi/acpica/nsdumpdv.c b/drivers/acpi/acpica/nsdumpdv.c
index d2a97921e249..2ed294b7a4db 100644
--- a/drivers/acpi/acpica/nsdumpdv.c
+++ b/drivers/acpi/acpica/nsdumpdv.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nseval.c b/drivers/acpi/acpica/nseval.c
index f52829cc294b..c1bd02b1a058 100644
--- a/drivers/acpi/acpica/nseval.c
+++ b/drivers/acpi/acpica/nseval.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -389,7 +389,7 @@ acpi_ns_exec_module_code(union acpi_operand_object *method_obj,
389 * acpi_gbl_root_node->Object is NULL at PASS1. 389 * acpi_gbl_root_node->Object is NULL at PASS1.
390 */ 390 */
391 if ((type == ACPI_TYPE_DEVICE) && parent_node->object) { 391 if ((type == ACPI_TYPE_DEVICE) && parent_node->object) {
392 method_obj->method.extra.handler = 392 method_obj->method.dispatch.handler =
393 parent_node->object->device.handler; 393 parent_node->object->device.handler;
394 } 394 }
395 395
diff --git a/drivers/acpi/acpica/nsinit.c b/drivers/acpi/acpica/nsinit.c
index 0cac7ec0d2ec..fd7c6380e294 100644
--- a/drivers/acpi/acpica/nsinit.c
+++ b/drivers/acpi/acpica/nsinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsload.c b/drivers/acpi/acpica/nsload.c
index df18be94fefe..5f7dc691c183 100644
--- a/drivers/acpi/acpica/nsload.c
+++ b/drivers/acpi/acpica/nsload.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsnames.c b/drivers/acpi/acpica/nsnames.c
index d3104af57e13..d5fa520c3de5 100644
--- a/drivers/acpi/acpica/nsnames.c
+++ b/drivers/acpi/acpica/nsnames.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsobject.c b/drivers/acpi/acpica/nsobject.c
index 41a9213dd5af..3bb8bf105ea2 100644
--- a/drivers/acpi/acpica/nsobject.c
+++ b/drivers/acpi/acpica/nsobject.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsparse.c b/drivers/acpi/acpica/nsparse.c
index 5808c89e9fac..b3234fa795b8 100644
--- a/drivers/acpi/acpica/nsparse.c
+++ b/drivers/acpi/acpica/nsparse.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c
index 7096bcda0c72..9fb03fa8ffde 100644
--- a/drivers/acpi/acpica/nspredef.c
+++ b/drivers/acpi/acpica/nspredef.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsrepair.c b/drivers/acpi/acpica/nsrepair.c
index d1c136692667..1d76ac85b5e7 100644
--- a/drivers/acpi/acpica/nsrepair.c
+++ b/drivers/acpi/acpica/nsrepair.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c
index 4ef9f43ea926..973883babee1 100644
--- a/drivers/acpi/acpica/nsrepair2.c
+++ b/drivers/acpi/acpica/nsrepair2.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nssearch.c b/drivers/acpi/acpica/nssearch.c
index 41102a84272f..28b0d7a62b99 100644
--- a/drivers/acpi/acpica/nssearch.c
+++ b/drivers/acpi/acpica/nssearch.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsutils.c b/drivers/acpi/acpica/nsutils.c
index a7d6ad9c111b..cb1b104a69a2 100644
--- a/drivers/acpi/acpica/nsutils.c
+++ b/drivers/acpi/acpica/nsutils.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nswalk.c b/drivers/acpi/acpica/nswalk.c
index 2cd5be8fe10f..345f0c3c6ad2 100644
--- a/drivers/acpi/acpica/nswalk.c
+++ b/drivers/acpi/acpica/nswalk.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c
index ebef8a7fd707..c53f0040e490 100644
--- a/drivers/acpi/acpica/nsxfeval.c
+++ b/drivers/acpi/acpica/nsxfeval.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/nsxfname.c b/drivers/acpi/acpica/nsxfname.c
index b01e45a415e3..3fd4526f3dba 100644
--- a/drivers/acpi/acpica/nsxfname.c
+++ b/drivers/acpi/acpica/nsxfname.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
@@ -603,10 +603,9 @@ acpi_status acpi_install_method(u8 *buffer)
603 method_obj->method.param_count = (u8) 603 method_obj->method.param_count = (u8)
604 (method_flags & AML_METHOD_ARG_COUNT); 604 (method_flags & AML_METHOD_ARG_COUNT);
605 605
606 method_obj->method.method_flags = (u8)
607 (method_flags & ~AML_METHOD_ARG_COUNT);
608
609 if (method_flags & AML_METHOD_SERIALIZED) { 606 if (method_flags & AML_METHOD_SERIALIZED) {
607 method_obj->method.info_flags = ACPI_METHOD_SERIALIZED;
608
610 method_obj->method.sync_level = (u8) 609 method_obj->method.sync_level = (u8)
611 ((method_flags & AML_METHOD_SYNC_LEVEL) >> 4); 610 ((method_flags & AML_METHOD_SYNC_LEVEL) >> 4);
612 } 611 }
diff --git a/drivers/acpi/acpica/nsxfobj.c b/drivers/acpi/acpica/nsxfobj.c
index a1f04e9b8030..db7660f8b869 100644
--- a/drivers/acpi/acpica/nsxfobj.c
+++ b/drivers/acpi/acpica/nsxfobj.c
@@ -6,7 +6,7 @@
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psargs.c b/drivers/acpi/acpica/psargs.c
index 7df1a4c95274..e1fad0ee0136 100644
--- a/drivers/acpi/acpica/psargs.c
+++ b/drivers/acpi/acpica/psargs.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psloop.c b/drivers/acpi/acpica/psloop.c
index 2f2e7760938c..01dd70d1de51 100644
--- a/drivers/acpi/acpica/psloop.c
+++ b/drivers/acpi/acpica/psloop.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -655,7 +655,7 @@ acpi_ps_link_module_code(union acpi_parse_object *parent_op,
655 method_obj->method.aml_start = aml_start; 655 method_obj->method.aml_start = aml_start;
656 method_obj->method.aml_length = aml_length; 656 method_obj->method.aml_length = aml_length;
657 method_obj->method.owner_id = owner_id; 657 method_obj->method.owner_id = owner_id;
658 method_obj->method.flags |= AOPOBJ_MODULE_LEVEL; 658 method_obj->method.info_flags |= ACPI_METHOD_MODULE_LEVEL;
659 659
660 /* 660 /*
661 * Save the parent node in next_object. This is cheating, but we 661 * Save the parent node in next_object. This is cheating, but we
diff --git a/drivers/acpi/acpica/psopcode.c b/drivers/acpi/acpica/psopcode.c
index 2b0c3be2b1b8..bed08de7528c 100644
--- a/drivers/acpi/acpica/psopcode.c
+++ b/drivers/acpi/acpica/psopcode.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psparse.c b/drivers/acpi/acpica/psparse.c
index 8d81542194d4..9bb0cbd37b5e 100644
--- a/drivers/acpi/acpica/psparse.c
+++ b/drivers/acpi/acpica/psparse.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -55,7 +55,6 @@
55#include "acparser.h" 55#include "acparser.h"
56#include "acdispat.h" 56#include "acdispat.h"
57#include "amlcode.h" 57#include "amlcode.h"
58#include "acnamesp.h"
59#include "acinterp.h" 58#include "acinterp.h"
60 59
61#define _COMPONENT ACPI_PARSER 60#define _COMPONENT ACPI_PARSER
@@ -539,24 +538,16 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
539 /* Check for possible multi-thread reentrancy problem */ 538 /* Check for possible multi-thread reentrancy problem */
540 539
541 if ((status == AE_ALREADY_EXISTS) && 540 if ((status == AE_ALREADY_EXISTS) &&
542 (!walk_state->method_desc->method.mutex)) { 541 (!(walk_state->method_desc->method.
543 ACPI_INFO((AE_INFO, 542 info_flags & ACPI_METHOD_SERIALIZED))) {
544 "Marking method %4.4s as Serialized because of AE_ALREADY_EXISTS error",
545 walk_state->method_node->name.
546 ascii));
547
548 /* 543 /*
549 * Method tried to create an object twice. The probable cause is 544 * Method is not serialized and tried to create an object
550 * that the method cannot handle reentrancy. 545 * twice. The probable cause is that the method cannot
551 * 546 * handle reentrancy. Mark as "pending serialized" now, and
552 * The method is marked not_serialized, but it tried to create 547 * then mark "serialized" when the last thread exits.
553 * a named object, causing the second thread entrance to fail.
554 * Workaround this problem by marking the method permanently
555 * as Serialized.
556 */ 548 */
557 walk_state->method_desc->method.method_flags |= 549 walk_state->method_desc->method.info_flags |=
558 AML_METHOD_SERIALIZED; 550 ACPI_METHOD_SERIALIZED_PENDING;
559 walk_state->method_desc->method.sync_level = 0;
560 } 551 }
561 } 552 }
562 553
diff --git a/drivers/acpi/acpica/psscope.c b/drivers/acpi/acpica/psscope.c
index 40e2b279ea12..a5faa1323a02 100644
--- a/drivers/acpi/acpica/psscope.c
+++ b/drivers/acpi/acpica/psscope.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/pstree.c b/drivers/acpi/acpica/pstree.c
index d4b970c3630b..f1464c03aa42 100644
--- a/drivers/acpi/acpica/pstree.c
+++ b/drivers/acpi/acpica/pstree.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psutils.c b/drivers/acpi/acpica/psutils.c
index fe29eee5adb1..7eda78503422 100644
--- a/drivers/acpi/acpica/psutils.c
+++ b/drivers/acpi/acpica/psutils.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/pswalk.c b/drivers/acpi/acpica/pswalk.c
index 8abb9629443d..3312d6368bf1 100644
--- a/drivers/acpi/acpica/pswalk.c
+++ b/drivers/acpi/acpica/pswalk.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/psxface.c b/drivers/acpi/acpica/psxface.c
index c42f067cff9d..8086805d4494 100644
--- a/drivers/acpi/acpica/psxface.c
+++ b/drivers/acpi/acpica/psxface.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -47,7 +47,6 @@
47#include "acdispat.h" 47#include "acdispat.h"
48#include "acinterp.h" 48#include "acinterp.h"
49#include "actables.h" 49#include "actables.h"
50#include "amlcode.h"
51 50
52#define _COMPONENT ACPI_PARSER 51#define _COMPONENT ACPI_PARSER
53ACPI_MODULE_NAME("psxface") 52ACPI_MODULE_NAME("psxface")
@@ -285,15 +284,15 @@ acpi_status acpi_ps_execute_method(struct acpi_evaluate_info *info)
285 goto cleanup; 284 goto cleanup;
286 } 285 }
287 286
288 if (info->obj_desc->method.flags & AOPOBJ_MODULE_LEVEL) { 287 if (info->obj_desc->method.info_flags & ACPI_METHOD_MODULE_LEVEL) {
289 walk_state->parse_flags |= ACPI_PARSE_MODULE_LEVEL; 288 walk_state->parse_flags |= ACPI_PARSE_MODULE_LEVEL;
290 } 289 }
291 290
292 /* Invoke an internal method if necessary */ 291 /* Invoke an internal method if necessary */
293 292
294 if (info->obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) { 293 if (info->obj_desc->method.info_flags & ACPI_METHOD_INTERNAL_ONLY) {
295 status = 294 status =
296 info->obj_desc->method.extra.implementation(walk_state); 295 info->obj_desc->method.dispatch.implementation(walk_state);
297 info->return_object = walk_state->return_desc; 296 info->return_object = walk_state->return_desc;
298 297
299 /* Cleanup states */ 298 /* Cleanup states */
diff --git a/drivers/acpi/acpica/rsaddr.c b/drivers/acpi/acpica/rsaddr.c
index 226c806ae986..9e66f9078426 100644
--- a/drivers/acpi/acpica/rsaddr.c
+++ b/drivers/acpi/acpica/rsaddr.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rscalc.c b/drivers/acpi/acpica/rscalc.c
index d6ebf7ec622d..3a8a89ec2ca4 100644
--- a/drivers/acpi/acpica/rscalc.c
+++ b/drivers/acpi/acpica/rscalc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rscreate.c b/drivers/acpi/acpica/rscreate.c
index c80a2eea3a01..4ce6e1147e80 100644
--- a/drivers/acpi/acpica/rscreate.c
+++ b/drivers/acpi/acpica/rscreate.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsdump.c b/drivers/acpi/acpica/rsdump.c
index f859b0386fe4..33db7520c74b 100644
--- a/drivers/acpi/acpica/rsdump.c
+++ b/drivers/acpi/acpica/rsdump.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsinfo.c b/drivers/acpi/acpica/rsinfo.c
index 1fd868b964fd..f9ea60872aa4 100644
--- a/drivers/acpi/acpica/rsinfo.c
+++ b/drivers/acpi/acpica/rsinfo.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsio.c b/drivers/acpi/acpica/rsio.c
index 33bff17c0bbc..0c7efef008be 100644
--- a/drivers/acpi/acpica/rsio.c
+++ b/drivers/acpi/acpica/rsio.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsirq.c b/drivers/acpi/acpica/rsirq.c
index 545da40d7fa7..50b8ad211167 100644
--- a/drivers/acpi/acpica/rsirq.c
+++ b/drivers/acpi/acpica/rsirq.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rslist.c b/drivers/acpi/acpica/rslist.c
index 7335f22aac20..1bfcef736c50 100644
--- a/drivers/acpi/acpica/rslist.c
+++ b/drivers/acpi/acpica/rslist.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsmemory.c b/drivers/acpi/acpica/rsmemory.c
index 887b8ba8c432..7cc6d8625f1e 100644
--- a/drivers/acpi/acpica/rsmemory.c
+++ b/drivers/acpi/acpica/rsmemory.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsmisc.c b/drivers/acpi/acpica/rsmisc.c
index f8cd9e87d987..410264b22a29 100644
--- a/drivers/acpi/acpica/rsmisc.c
+++ b/drivers/acpi/acpica/rsmisc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsutils.c b/drivers/acpi/acpica/rsutils.c
index 491191e6cf69..231811e56939 100644
--- a/drivers/acpi/acpica/rsutils.c
+++ b/drivers/acpi/acpica/rsutils.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/rsxface.c b/drivers/acpi/acpica/rsxface.c
index 9f6a6e7e1c8e..2ff657a28f26 100644
--- a/drivers/acpi/acpica/rsxface.c
+++ b/drivers/acpi/acpica/rsxface.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c
index d2ff4325c427..428d44e2d162 100644
--- a/drivers/acpi/acpica/tbfadt.c
+++ b/drivers/acpi/acpica/tbfadt.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbfind.c b/drivers/acpi/acpica/tbfind.c
index 989d5c867864..a55cb2bb5abb 100644
--- a/drivers/acpi/acpica/tbfind.c
+++ b/drivers/acpi/acpica/tbfind.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c
index 83d7af8d0905..48db0944ce4a 100644
--- a/drivers/acpi/acpica/tbinstal.c
+++ b/drivers/acpi/acpica/tbinstal.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c
index 34f9c2bc5e1f..0f2d395feaba 100644
--- a/drivers/acpi/acpica/tbutils.c
+++ b/drivers/acpi/acpica/tbutils.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbxface.c b/drivers/acpi/acpica/tbxface.c
index 4a8b9e6ea57a..4b7085dfc683 100644
--- a/drivers/acpi/acpica/tbxface.c
+++ b/drivers/acpi/acpica/tbxface.c
@@ -6,7 +6,7 @@
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
8/* 8/*
9 * Copyright (C) 2000 - 2010, Intel Corp. 9 * Copyright (C) 2000 - 2011, Intel Corp.
10 * All rights reserved. 10 * All rights reserved.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/tbxfroot.c b/drivers/acpi/acpica/tbxfroot.c
index fd2c07d1d3ac..7eb6c6cc1edf 100644
--- a/drivers/acpi/acpica/tbxfroot.c
+++ b/drivers/acpi/acpica/tbxfroot.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utalloc.c b/drivers/acpi/acpica/utalloc.c
index 8f0896281567..0a697351cf69 100644
--- a/drivers/acpi/acpica/utalloc.c
+++ b/drivers/acpi/acpica/utalloc.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utcopy.c b/drivers/acpi/acpica/utcopy.c
index 6fef83f04bcd..aded299a2fa8 100644
--- a/drivers/acpi/acpica/utcopy.c
+++ b/drivers/acpi/acpica/utcopy.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utdebug.c b/drivers/acpi/acpica/utdebug.c
index f21c486929a5..a9bcd816dc29 100644
--- a/drivers/acpi/acpica/utdebug.c
+++ b/drivers/acpi/acpica/utdebug.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utdelete.c b/drivers/acpi/acpica/utdelete.c
index ed794cd033ea..31f5a7832ef1 100644
--- a/drivers/acpi/acpica/utdelete.c
+++ b/drivers/acpi/acpica/utdelete.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/uteval.c b/drivers/acpi/acpica/uteval.c
index 22f59ef604e0..18f73c9d10bc 100644
--- a/drivers/acpi/acpica/uteval.c
+++ b/drivers/acpi/acpica/uteval.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utglobal.c b/drivers/acpi/acpica/utglobal.c
index 508537f884ac..97dd9bbf055a 100644
--- a/drivers/acpi/acpica/utglobal.c
+++ b/drivers/acpi/acpica/utglobal.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utids.c b/drivers/acpi/acpica/utids.c
index d2906328535d..b679ea693545 100644
--- a/drivers/acpi/acpica/utids.c
+++ b/drivers/acpi/acpica/utids.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utinit.c b/drivers/acpi/acpica/utinit.c
index c1b1c803ea9b..191b6828cce9 100644
--- a/drivers/acpi/acpica/utinit.c
+++ b/drivers/acpi/acpica/utinit.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utlock.c b/drivers/acpi/acpica/utlock.c
index b081cd46a15f..f6bb75c6faf5 100644
--- a/drivers/acpi/acpica/utlock.c
+++ b/drivers/acpi/acpica/utlock.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utmath.c b/drivers/acpi/acpica/utmath.c
index 49cf7b7fd816..ce481da9bb45 100644
--- a/drivers/acpi/acpica/utmath.c
+++ b/drivers/acpi/acpica/utmath.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utmisc.c b/drivers/acpi/acpica/utmisc.c
index c7d0e05ef5a4..c33a852d4f42 100644
--- a/drivers/acpi/acpica/utmisc.c
+++ b/drivers/acpi/acpica/utmisc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utmutex.c b/drivers/acpi/acpica/utmutex.c
index 199528ff7f1d..a946c689f03b 100644
--- a/drivers/acpi/acpica/utmutex.c
+++ b/drivers/acpi/acpica/utmutex.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utobject.c b/drivers/acpi/acpica/utobject.c
index fd1fa2749ea5..188340a017b4 100644
--- a/drivers/acpi/acpica/utobject.c
+++ b/drivers/acpi/acpica/utobject.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utosi.c b/drivers/acpi/acpica/utosi.c
index 18c59a85fdca..1fb10cb8f11d 100644
--- a/drivers/acpi/acpica/utosi.c
+++ b/drivers/acpi/acpica/utosi.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utresrc.c b/drivers/acpi/acpica/utresrc.c
index 7965919000b1..84e051844247 100644
--- a/drivers/acpi/acpica/utresrc.c
+++ b/drivers/acpi/acpica/utresrc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utstate.c b/drivers/acpi/acpica/utstate.c
index d35d109b8da2..30c21e1a9360 100644
--- a/drivers/acpi/acpica/utstate.c
+++ b/drivers/acpi/acpica/utstate.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utxface.c b/drivers/acpi/acpica/utxface.c
index 1f484c9a6888..98ad125e14ff 100644
--- a/drivers/acpi/acpica/utxface.c
+++ b/drivers/acpi/acpica/utxface.c
@@ -5,7 +5,7 @@
5 *****************************************************************************/ 5 *****************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/acpica/utxferror.c b/drivers/acpi/acpica/utxferror.c
index 6f12e314fbae..916ae097c43c 100644
--- a/drivers/acpi/acpica/utxferror.c
+++ b/drivers/acpi/acpica/utxferror.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2010, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 68bc227e7c4c..ac1a599f5147 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -998,7 +998,6 @@ static int acpi_battery_resume(struct acpi_device *device)
998 if (!device) 998 if (!device)
999 return -EINVAL; 999 return -EINVAL;
1000 battery = acpi_driver_data(device); 1000 battery = acpi_driver_data(device);
1001 acpi_battery_refresh(battery);
1002 battery->update_time = 0; 1001 battery->update_time = 0;
1003 acpi_battery_update(battery); 1002 acpi_battery_update(battery);
1004 return 0; 1003 return 0;
diff --git a/drivers/acpi/nvs.c b/drivers/acpi/nvs.c
index 54b6ab8040a6..fa5a1df42b79 100644
--- a/drivers/acpi/nvs.c
+++ b/drivers/acpi/nvs.c
@@ -12,6 +12,7 @@
12#include <linux/mm.h> 12#include <linux/mm.h>
13#include <linux/slab.h> 13#include <linux/slab.h>
14#include <linux/acpi.h> 14#include <linux/acpi.h>
15#include <linux/acpi_io.h>
15#include <acpi/acpiosxf.h> 16#include <acpi/acpiosxf.h>
16 17
17/* 18/*
@@ -80,7 +81,7 @@ void suspend_nvs_free(void)
80 free_page((unsigned long)entry->data); 81 free_page((unsigned long)entry->data);
81 entry->data = NULL; 82 entry->data = NULL;
82 if (entry->kaddr) { 83 if (entry->kaddr) {
83 acpi_os_unmap_memory(entry->kaddr, entry->size); 84 iounmap(entry->kaddr);
84 entry->kaddr = NULL; 85 entry->kaddr = NULL;
85 } 86 }
86 } 87 }
@@ -114,8 +115,8 @@ int suspend_nvs_save(void)
114 115
115 list_for_each_entry(entry, &nvs_list, node) 116 list_for_each_entry(entry, &nvs_list, node)
116 if (entry->data) { 117 if (entry->data) {
117 entry->kaddr = acpi_os_map_memory(entry->phys_start, 118 entry->kaddr = acpi_os_ioremap(entry->phys_start,
118 entry->size); 119 entry->size);
119 if (!entry->kaddr) { 120 if (!entry->kaddr) {
120 suspend_nvs_free(); 121 suspend_nvs_free();
121 return -ENOMEM; 122 return -ENOMEM;
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index e2dd6de5d50c..b0931818cf98 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -38,6 +38,7 @@
38#include <linux/workqueue.h> 38#include <linux/workqueue.h>
39#include <linux/nmi.h> 39#include <linux/nmi.h>
40#include <linux/acpi.h> 40#include <linux/acpi.h>
41#include <linux/acpi_io.h>
41#include <linux/efi.h> 42#include <linux/efi.h>
42#include <linux/ioport.h> 43#include <linux/ioport.h>
43#include <linux/list.h> 44#include <linux/list.h>
@@ -302,9 +303,10 @@ void __iomem *__init_refok
302acpi_os_map_memory(acpi_physical_address phys, acpi_size size) 303acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
303{ 304{
304 struct acpi_ioremap *map, *tmp_map; 305 struct acpi_ioremap *map, *tmp_map;
305 unsigned long flags, pg_sz; 306 unsigned long flags;
306 void __iomem *virt; 307 void __iomem *virt;
307 phys_addr_t pg_off; 308 acpi_physical_address pg_off;
309 acpi_size pg_sz;
308 310
309 if (phys > ULONG_MAX) { 311 if (phys > ULONG_MAX) {
310 printk(KERN_ERR PREFIX "Cannot map memory that high\n"); 312 printk(KERN_ERR PREFIX "Cannot map memory that high\n");
@@ -320,7 +322,7 @@ acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
320 322
321 pg_off = round_down(phys, PAGE_SIZE); 323 pg_off = round_down(phys, PAGE_SIZE);
322 pg_sz = round_up(phys + size, PAGE_SIZE) - pg_off; 324 pg_sz = round_up(phys + size, PAGE_SIZE) - pg_off;
323 virt = ioremap_cache(pg_off, pg_sz); 325 virt = acpi_os_ioremap(pg_off, pg_sz);
324 if (!virt) { 326 if (!virt) {
325 kfree(map); 327 kfree(map);
326 return NULL; 328 return NULL;
@@ -642,7 +644,7 @@ acpi_os_read_memory(acpi_physical_address phys_addr, u32 * value, u32 width)
642 virt_addr = acpi_map_vaddr_lookup(phys_addr, size); 644 virt_addr = acpi_map_vaddr_lookup(phys_addr, size);
643 rcu_read_unlock(); 645 rcu_read_unlock();
644 if (!virt_addr) { 646 if (!virt_addr) {
645 virt_addr = ioremap_cache(phys_addr, size); 647 virt_addr = acpi_os_ioremap(phys_addr, size);
646 unmap = 1; 648 unmap = 1;
647 } 649 }
648 if (!value) 650 if (!value)
@@ -678,7 +680,7 @@ acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width)
678 virt_addr = acpi_map_vaddr_lookup(phys_addr, size); 680 virt_addr = acpi_map_vaddr_lookup(phys_addr, size);
679 rcu_read_unlock(); 681 rcu_read_unlock();
680 if (!virt_addr) { 682 if (!virt_addr) {
681 virt_addr = ioremap_cache(phys_addr, size); 683 virt_addr = acpi_os_ioremap(phys_addr, size);
682 unmap = 1; 684 unmap = 1;
683 } 685 }
684 686
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index fdd3aeeb6def..d6a8cd14de2e 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -166,6 +166,7 @@ static void acpi_pm_finish(void)
166 u32 acpi_state = acpi_target_sleep_state; 166 u32 acpi_state = acpi_target_sleep_state;
167 167
168 acpi_ec_unblock_transactions(); 168 acpi_ec_unblock_transactions();
169 suspend_nvs_free();
169 170
170 if (acpi_state == ACPI_STATE_S0) 171 if (acpi_state == ACPI_STATE_S0)
171 return; 172 return;
@@ -186,7 +187,6 @@ static void acpi_pm_finish(void)
186 */ 187 */
187static void acpi_pm_end(void) 188static void acpi_pm_end(void)
188{ 189{
189 suspend_nvs_free();
190 /* 190 /*
191 * This is necessary in case acpi_pm_finish() is not called during a 191 * This is necessary in case acpi_pm_finish() is not called during a
192 * failing transition to a sleep state. 192 * failing transition to a sleep state.
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index c6b298d4c136..c2328aed0836 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -783,7 +783,7 @@ config PATA_PCMCIA
783 783
784config PATA_PLATFORM 784config PATA_PLATFORM
785 tristate "Generic platform device PATA support" 785 tristate "Generic platform device PATA support"
786 depends on EMBEDDED || PPC || HAVE_PATA_PLATFORM 786 depends on EXPERT || PPC || HAVE_PATA_PLATFORM
787 help 787 help
788 This option enables support for generic directly connected ATA 788 This option enables support for generic directly connected ATA
789 devices commonly found on embedded systems. 789 devices commonly found on embedded systems.
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 328826381a2d..b8d96ce37fc9 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -260,6 +260,7 @@ static const struct pci_device_id ahci_pci_tbl[] = {
260 { PCI_VDEVICE(INTEL, 0x1d02), board_ahci }, /* PBG AHCI */ 260 { PCI_VDEVICE(INTEL, 0x1d02), board_ahci }, /* PBG AHCI */
261 { PCI_VDEVICE(INTEL, 0x1d04), board_ahci }, /* PBG RAID */ 261 { PCI_VDEVICE(INTEL, 0x1d04), board_ahci }, /* PBG RAID */
262 { PCI_VDEVICE(INTEL, 0x1d06), board_ahci }, /* PBG RAID */ 262 { PCI_VDEVICE(INTEL, 0x1d06), board_ahci }, /* PBG RAID */
263 { PCI_VDEVICE(INTEL, 0x2323), board_ahci }, /* DH89xxCC AHCI */
263 264
264 /* JMicron 360/1/3/5/6, match class to avoid IDE function */ 265 /* JMicron 360/1/3/5/6, match class to avoid IDE function */
265 { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 266 { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
@@ -379,6 +380,8 @@ static const struct pci_device_id ahci_pci_tbl[] = {
379 { PCI_VDEVICE(MARVELL, 0x6145), board_ahci_mv }, /* 6145 */ 380 { PCI_VDEVICE(MARVELL, 0x6145), board_ahci_mv }, /* 6145 */
380 { PCI_VDEVICE(MARVELL, 0x6121), board_ahci_mv }, /* 6121 */ 381 { PCI_VDEVICE(MARVELL, 0x6121), board_ahci_mv }, /* 6121 */
381 { PCI_DEVICE(0x1b4b, 0x9123), 382 { PCI_DEVICE(0x1b4b, 0x9123),
383 .class = PCI_CLASS_STORAGE_SATA_AHCI,
384 .class_mask = 0xffffff,
382 .driver_data = board_ahci_yes_fbs }, /* 88se9128 */ 385 .driver_data = board_ahci_yes_fbs }, /* 88se9128 */
383 386
384 /* Promise */ 387 /* Promise */
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index a31fe96f7de6..d4e52e214859 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -4138,6 +4138,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
4138 * device and controller are SATA. 4138 * device and controller are SATA.
4139 */ 4139 */
4140 { "PIONEER DVD-RW DVRTD08", "1.00", ATA_HORKAGE_NOSETXFER }, 4140 { "PIONEER DVD-RW DVRTD08", "1.00", ATA_HORKAGE_NOSETXFER },
4141 { "PIONEER DVD-RW DVR-212D", "1.28", ATA_HORKAGE_NOSETXFER },
4141 4142
4142 /* End Marker */ 4143 /* End Marker */
4143 { } 4144 { }
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 5defc74973d7..600f6353ecf8 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -1099,9 +1099,9 @@ static int ata_scsi_dev_config(struct scsi_device *sdev,
1099 struct request_queue *q = sdev->request_queue; 1099 struct request_queue *q = sdev->request_queue;
1100 void *buf; 1100 void *buf;
1101 1101
1102 /* set the min alignment and padding */ 1102 sdev->sector_size = ATA_SECT_SIZE;
1103 blk_queue_update_dma_alignment(sdev->request_queue, 1103
1104 ATA_DMA_PAD_SZ - 1); 1104 /* set DMA padding */
1105 blk_queue_update_dma_pad(sdev->request_queue, 1105 blk_queue_update_dma_pad(sdev->request_queue,
1106 ATA_DMA_PAD_SZ - 1); 1106 ATA_DMA_PAD_SZ - 1);
1107 1107
@@ -1115,13 +1115,25 @@ static int ata_scsi_dev_config(struct scsi_device *sdev,
1115 1115
1116 blk_queue_dma_drain(q, atapi_drain_needed, buf, ATAPI_MAX_DRAIN); 1116 blk_queue_dma_drain(q, atapi_drain_needed, buf, ATAPI_MAX_DRAIN);
1117 } else { 1117 } else {
1118 /* ATA devices must be sector aligned */
1119 sdev->sector_size = ata_id_logical_sector_size(dev->id); 1118 sdev->sector_size = ata_id_logical_sector_size(dev->id);
1120 blk_queue_update_dma_alignment(sdev->request_queue,
1121 sdev->sector_size - 1);
1122 sdev->manage_start_stop = 1; 1119 sdev->manage_start_stop = 1;
1123 } 1120 }
1124 1121
1122 /*
1123 * ata_pio_sectors() expects buffer for each sector to not cross
1124 * page boundary. Enforce it by requiring buffers to be sector
1125 * aligned, which works iff sector_size is not larger than
1126 * PAGE_SIZE. ATAPI devices also need the alignment as
1127 * IDENTIFY_PACKET is executed as ATA_PROT_PIO.
1128 */
1129 if (sdev->sector_size > PAGE_SIZE)
1130 ata_dev_printk(dev, KERN_WARNING,
1131 "sector_size=%u > PAGE_SIZE, PIO may malfunction\n",
1132 sdev->sector_size);
1133
1134 blk_queue_update_dma_alignment(sdev->request_queue,
1135 sdev->sector_size - 1);
1136
1125 if (dev->flags & ATA_DFLAG_AN) 1137 if (dev->flags & ATA_DFLAG_AN)
1126 set_bit(SDEV_EVT_MEDIA_CHANGE, sdev->supported_events); 1138 set_bit(SDEV_EVT_MEDIA_CHANGE, sdev->supported_events);
1127 1139
diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c
index d7e57db36bc8..538ec38ba995 100644
--- a/drivers/ata/pata_hpt366.c
+++ b/drivers/ata/pata_hpt366.c
@@ -25,7 +25,7 @@
25#include <linux/libata.h> 25#include <linux/libata.h>
26 26
27#define DRV_NAME "pata_hpt366" 27#define DRV_NAME "pata_hpt366"
28#define DRV_VERSION "0.6.9" 28#define DRV_VERSION "0.6.10"
29 29
30struct hpt_clock { 30struct hpt_clock {
31 u8 xfer_mode; 31 u8 xfer_mode;
@@ -160,8 +160,8 @@ static int hpt_dma_blacklisted(const struct ata_device *dev, char *modestr,
160 160
161 while (list[i] != NULL) { 161 while (list[i] != NULL) {
162 if (!strcmp(list[i], model_num)) { 162 if (!strcmp(list[i], model_num)) {
163 printk(KERN_WARNING DRV_NAME ": %s is not supported for %s.\n", 163 pr_warning(DRV_NAME ": %s is not supported for %s.\n",
164 modestr, list[i]); 164 modestr, list[i]);
165 return 1; 165 return 1;
166 } 166 }
167 i++; 167 i++;
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c
index efdd18bc8663..4c5b5183225e 100644
--- a/drivers/ata/pata_hpt37x.c
+++ b/drivers/ata/pata_hpt37x.c
@@ -24,7 +24,7 @@
24#include <linux/libata.h> 24#include <linux/libata.h>
25 25
26#define DRV_NAME "pata_hpt37x" 26#define DRV_NAME "pata_hpt37x"
27#define DRV_VERSION "0.6.18" 27#define DRV_VERSION "0.6.22"
28 28
29struct hpt_clock { 29struct hpt_clock {
30 u8 xfer_speed; 30 u8 xfer_speed;
@@ -229,8 +229,8 @@ static int hpt_dma_blacklisted(const struct ata_device *dev, char *modestr,
229 229
230 while (list[i] != NULL) { 230 while (list[i] != NULL) {
231 if (!strcmp(list[i], model_num)) { 231 if (!strcmp(list[i], model_num)) {
232 printk(KERN_WARNING DRV_NAME ": %s is not supported for %s.\n", 232 pr_warning(DRV_NAME ": %s is not supported for %s.\n",
233 modestr, list[i]); 233 modestr, list[i]);
234 return 1; 234 return 1;
235 } 235 }
236 i++; 236 i++;
@@ -642,7 +642,6 @@ static struct ata_port_operations hpt372_port_ops = {
642static struct ata_port_operations hpt374_fn1_port_ops = { 642static struct ata_port_operations hpt374_fn1_port_ops = {
643 .inherits = &hpt372_port_ops, 643 .inherits = &hpt372_port_ops,
644 .cable_detect = hpt374_fn1_cable_detect, 644 .cable_detect = hpt374_fn1_cable_detect,
645 .prereset = hpt37x_pre_reset,
646}; 645};
647 646
648/** 647/**
@@ -803,7 +802,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
803 .udma_mask = ATA_UDMA6, 802 .udma_mask = ATA_UDMA6,
804 .port_ops = &hpt302_port_ops 803 .port_ops = &hpt302_port_ops
805 }; 804 };
806 /* HPT374 - UDMA100, function 1 uses different prereset method */ 805 /* HPT374 - UDMA100, function 1 uses different cable_detect method */
807 static const struct ata_port_info info_hpt374_fn0 = { 806 static const struct ata_port_info info_hpt374_fn0 = {
808 .flags = ATA_FLAG_SLAVE_POSS, 807 .flags = ATA_FLAG_SLAVE_POSS,
809 .pio_mask = ATA_PIO4, 808 .pio_mask = ATA_PIO4,
@@ -838,7 +837,8 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
838 if (rc) 837 if (rc)
839 return rc; 838 return rc;
840 839
841 if (dev->device == PCI_DEVICE_ID_TTI_HPT366) { 840 switch (dev->device) {
841 case PCI_DEVICE_ID_TTI_HPT366:
842 /* May be a later chip in disguise. Check */ 842 /* May be a later chip in disguise. Check */
843 /* Older chips are in the HPT366 driver. Ignore them */ 843 /* Older chips are in the HPT366 driver. Ignore them */
844 if (rev < 3) 844 if (rev < 3)
@@ -863,54 +863,50 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
863 chip_table = &hpt372; 863 chip_table = &hpt372;
864 break; 864 break;
865 default: 865 default:
866 printk(KERN_ERR "pata_hpt37x: Unknown HPT366 subtype, " 866 pr_err(DRV_NAME ": Unknown HPT366 subtype, "
867 "please report (%d).\n", rev); 867 "please report (%d).\n", rev);
868 return -ENODEV; 868 return -ENODEV;
869 } 869 }
870 } else { 870 break;
871 switch (dev->device) { 871 case PCI_DEVICE_ID_TTI_HPT372:
872 case PCI_DEVICE_ID_TTI_HPT372: 872 /* 372N if rev >= 2 */
873 /* 372N if rev >= 2 */ 873 if (rev >= 2)
874 if (rev >= 2) 874 return -ENODEV;
875 return -ENODEV; 875 ppi[0] = &info_hpt372;
876 ppi[0] = &info_hpt372; 876 chip_table = &hpt372a;
877 chip_table = &hpt372a; 877 break;
878 break; 878 case PCI_DEVICE_ID_TTI_HPT302:
879 case PCI_DEVICE_ID_TTI_HPT302: 879 /* 302N if rev > 1 */
880 /* 302N if rev > 1 */ 880 if (rev > 1)
881 if (rev > 1) 881 return -ENODEV;
882 return -ENODEV; 882 ppi[0] = &info_hpt302;
883 ppi[0] = &info_hpt302; 883 /* Check this */
884 /* Check this */ 884 chip_table = &hpt302;
885 chip_table = &hpt302; 885 break;
886 break; 886 case PCI_DEVICE_ID_TTI_HPT371:
887 case PCI_DEVICE_ID_TTI_HPT371: 887 if (rev > 1)
888 if (rev > 1) 888 return -ENODEV;
889 return -ENODEV; 889 ppi[0] = &info_hpt302;
890 ppi[0] = &info_hpt302; 890 chip_table = &hpt371;
891 chip_table = &hpt371; 891 /*
892 /* 892 * Single channel device, master is not present but the BIOS
893 * Single channel device, master is not present 893 * (or us for non x86) must mark it absent
894 * but the BIOS (or us for non x86) must mark it 894 */
895 * absent 895 pci_read_config_byte(dev, 0x50, &mcr1);
896 */ 896 mcr1 &= ~0x04;
897 pci_read_config_byte(dev, 0x50, &mcr1); 897 pci_write_config_byte(dev, 0x50, mcr1);
898 mcr1 &= ~0x04; 898 break;
899 pci_write_config_byte(dev, 0x50, mcr1); 899 case PCI_DEVICE_ID_TTI_HPT374:
900 break; 900 chip_table = &hpt374;
901 case PCI_DEVICE_ID_TTI_HPT374: 901 if (!(PCI_FUNC(dev->devfn) & 1))
902 chip_table = &hpt374; 902 *ppi = &info_hpt374_fn0;
903 if (!(PCI_FUNC(dev->devfn) & 1)) 903 else
904 *ppi = &info_hpt374_fn0; 904 *ppi = &info_hpt374_fn1;
905 else 905 break;
906 *ppi = &info_hpt374_fn1; 906 default:
907 break; 907 pr_err(DRV_NAME ": PCI table is bogus, please report (%d).\n",
908 default: 908 dev->device);
909 printk(KERN_ERR 909 return -ENODEV;
910 "pata_hpt37x: PCI table is bogus, please report (%d).\n",
911 dev->device);
912 return -ENODEV;
913 }
914 } 910 }
915 /* Ok so this is a chip we support */ 911 /* Ok so this is a chip we support */
916 912
@@ -957,8 +953,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
957 u8 sr; 953 u8 sr;
958 u32 total = 0; 954 u32 total = 0;
959 955
960 printk(KERN_WARNING 956 pr_warning(DRV_NAME ": BIOS has not set timing clocks.\n");
961 "pata_hpt37x: BIOS has not set timing clocks.\n");
962 957
963 /* This is the process the HPT371 BIOS is reported to use */ 958 /* This is the process the HPT371 BIOS is reported to use */
964 for (i = 0; i < 128; i++) { 959 for (i = 0; i < 128; i++) {
@@ -1014,7 +1009,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1014 (f_high << 16) | f_low | 0x100); 1009 (f_high << 16) | f_low | 0x100);
1015 } 1010 }
1016 if (adjust == 8) { 1011 if (adjust == 8) {
1017 printk(KERN_ERR "pata_hpt37x: DPLL did not stabilize!\n"); 1012 pr_err(DRV_NAME ": DPLL did not stabilize!\n");
1018 return -ENODEV; 1013 return -ENODEV;
1019 } 1014 }
1020 if (dpll == 3) 1015 if (dpll == 3)
@@ -1022,8 +1017,8 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1022 else 1017 else
1023 private_data = (void *)hpt37x_timings_50; 1018 private_data = (void *)hpt37x_timings_50;
1024 1019
1025 printk(KERN_INFO "pata_hpt37x: bus clock %dMHz, using %dMHz DPLL.\n", 1020 pr_info(DRV_NAME ": bus clock %dMHz, using %dMHz DPLL.\n",
1026 MHz[clock_slot], MHz[dpll]); 1021 MHz[clock_slot], MHz[dpll]);
1027 } else { 1022 } else {
1028 private_data = (void *)chip_table->clocks[clock_slot]; 1023 private_data = (void *)chip_table->clocks[clock_slot];
1029 /* 1024 /*
@@ -1036,8 +1031,9 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1036 ppi[0] = &info_hpt370_33; 1031 ppi[0] = &info_hpt370_33;
1037 if (clock_slot < 2 && ppi[0] == &info_hpt370a) 1032 if (clock_slot < 2 && ppi[0] == &info_hpt370a)
1038 ppi[0] = &info_hpt370a_33; 1033 ppi[0] = &info_hpt370a_33;
1039 printk(KERN_INFO "pata_hpt37x: %s using %dMHz bus clock.\n", 1034
1040 chip_table->name, MHz[clock_slot]); 1035 pr_info(DRV_NAME ": %s using %dMHz bus clock.\n",
1036 chip_table->name, MHz[clock_slot]);
1041 } 1037 }
1042 1038
1043 /* Now kick off ATA set up */ 1039 /* Now kick off ATA set up */
diff --git a/drivers/ata/pata_hpt3x2n.c b/drivers/ata/pata_hpt3x2n.c
index d2239bbdb798..eca68caf5f46 100644
--- a/drivers/ata/pata_hpt3x2n.c
+++ b/drivers/ata/pata_hpt3x2n.c
@@ -25,7 +25,7 @@
25#include <linux/libata.h> 25#include <linux/libata.h>
26 26
27#define DRV_NAME "pata_hpt3x2n" 27#define DRV_NAME "pata_hpt3x2n"
28#define DRV_VERSION "0.3.13" 28#define DRV_VERSION "0.3.14"
29 29
30enum { 30enum {
31 HPT_PCI_FAST = (1 << 31), 31 HPT_PCI_FAST = (1 << 31),
@@ -418,7 +418,7 @@ static int hpt3x2n_pci_clock(struct pci_dev *pdev)
418 u16 sr; 418 u16 sr;
419 u32 total = 0; 419 u32 total = 0;
420 420
421 printk(KERN_WARNING "pata_hpt3x2n: BIOS clock data not set.\n"); 421 pr_warning(DRV_NAME ": BIOS clock data not set.\n");
422 422
423 /* This is the process the HPT371 BIOS is reported to use */ 423 /* This is the process the HPT371 BIOS is reported to use */
424 for (i = 0; i < 128; i++) { 424 for (i = 0; i < 128; i++) {
@@ -528,8 +528,7 @@ hpt372n:
528 ppi[0] = &info_hpt372n; 528 ppi[0] = &info_hpt372n;
529 break; 529 break;
530 default: 530 default:
531 printk(KERN_ERR 531 pr_err(DRV_NAME ": PCI table is bogus, please report (%d).\n",
532 "pata_hpt3x2n: PCI table is bogus please report (%d).\n",
533 dev->device); 532 dev->device);
534 return -ENODEV; 533 return -ENODEV;
535 } 534 }
@@ -579,12 +578,11 @@ hpt372n:
579 pci_write_config_dword(dev, 0x5C, (f_high << 16) | f_low); 578 pci_write_config_dword(dev, 0x5C, (f_high << 16) | f_low);
580 } 579 }
581 if (adjust == 8) { 580 if (adjust == 8) {
582 printk(KERN_ERR "pata_hpt3x2n: DPLL did not stabilize!\n"); 581 pr_err(DRV_NAME ": DPLL did not stabilize!\n");
583 return -ENODEV; 582 return -ENODEV;
584 } 583 }
585 584
586 printk(KERN_INFO "pata_hpt37x: bus clock %dMHz, using 66MHz DPLL.\n", 585 pr_info(DRV_NAME ": bus clock %dMHz, using 66MHz DPLL.\n", pci_mhz);
587 pci_mhz);
588 586
589 /* 587 /*
590 * Set our private data up. We only need a few flags 588 * Set our private data up. We only need a few flags
diff --git a/drivers/ata/pata_mpc52xx.c b/drivers/ata/pata_mpc52xx.c
index 8cc536e49a0a..d7d8026cde99 100644
--- a/drivers/ata/pata_mpc52xx.c
+++ b/drivers/ata/pata_mpc52xx.c
@@ -610,7 +610,7 @@ static struct scsi_host_template mpc52xx_ata_sht = {
610}; 610};
611 611
612static struct ata_port_operations mpc52xx_ata_port_ops = { 612static struct ata_port_operations mpc52xx_ata_port_ops = {
613 .inherits = &ata_sff_port_ops, 613 .inherits = &ata_bmdma_port_ops,
614 .sff_dev_select = mpc52xx_ata_dev_select, 614 .sff_dev_select = mpc52xx_ata_dev_select,
615 .set_piomode = mpc52xx_ata_set_piomode, 615 .set_piomode = mpc52xx_ata_set_piomode,
616 .set_dmamode = mpc52xx_ata_set_dmamode, 616 .set_dmamode = mpc52xx_ata_set_dmamode,
diff --git a/drivers/atm/idt77105.c b/drivers/atm/idt77105.c
index bca9cb89a118..487a54739854 100644
--- a/drivers/atm/idt77105.c
+++ b/drivers/atm/idt77105.c
@@ -151,7 +151,7 @@ static int fetch_stats(struct atm_dev *dev,struct idt77105_stats __user *arg,int
151 spin_unlock_irqrestore(&idt77105_priv_lock, flags); 151 spin_unlock_irqrestore(&idt77105_priv_lock, flags);
152 if (arg == NULL) 152 if (arg == NULL)
153 return 0; 153 return 0;
154 return copy_to_user(arg, &PRIV(dev)->stats, 154 return copy_to_user(arg, &stats,
155 sizeof(struct idt77105_stats)) ? -EFAULT : 0; 155 sizeof(struct idt77105_stats)) ? -EFAULT : 0;
156} 156}
157 157
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index fd96345bc35c..d57e8d0fb823 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -70,7 +70,7 @@ config PREVENT_FIRMWARE_BUILD
70 If unsure say Y here. 70 If unsure say Y here.
71 71
72config FW_LOADER 72config FW_LOADER
73 tristate "Userspace firmware loading support" if EMBEDDED 73 tristate "Userspace firmware loading support" if EXPERT
74 default y 74 default y
75 ---help--- 75 ---help---
76 This option is provided for the case where no in-kernel-tree modules 76 This option is provided for the case where no in-kernel-tree modules
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index 656493a5e073..42615b419dfb 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -407,12 +407,15 @@ static int rpm_suspend(struct device *dev, int rpmflags)
407 goto out; 407 goto out;
408 } 408 }
409 409
410 /* Maybe the parent is now able to suspend. */
410 if (parent && !parent->power.ignore_children && !dev->power.irq_safe) { 411 if (parent && !parent->power.ignore_children && !dev->power.irq_safe) {
411 spin_unlock_irq(&dev->power.lock); 412 spin_unlock(&dev->power.lock);
412 413
413 pm_request_idle(parent); 414 spin_lock(&parent->power.lock);
415 rpm_idle(parent, RPM_ASYNC);
416 spin_unlock(&parent->power.lock);
414 417
415 spin_lock_irq(&dev->power.lock); 418 spin_lock(&dev->power.lock);
416 } 419 }
417 420
418 out: 421 out:
diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
index 949ed09c6361..a126e614601f 100644
--- a/drivers/bluetooth/ath3k.c
+++ b/drivers/bluetooth/ath3k.c
@@ -47,46 +47,40 @@ MODULE_DEVICE_TABLE(usb, ath3k_table);
47#define USB_REQ_DFU_DNLOAD 1 47#define USB_REQ_DFU_DNLOAD 1
48#define BULK_SIZE 4096 48#define BULK_SIZE 4096
49 49
50struct ath3k_data { 50static int ath3k_load_firmware(struct usb_device *udev,
51 struct usb_device *udev; 51 const struct firmware *firmware)
52 u8 *fw_data;
53 u32 fw_size;
54 u32 fw_sent;
55};
56
57static int ath3k_load_firmware(struct ath3k_data *data,
58 unsigned char *firmware,
59 int count)
60{ 52{
61 u8 *send_buf; 53 u8 *send_buf;
62 int err, pipe, len, size, sent = 0; 54 int err, pipe, len, size, sent = 0;
55 int count = firmware->size;
63 56
64 BT_DBG("ath3k %p udev %p", data, data->udev); 57 BT_DBG("udev %p", udev);
65 58
66 pipe = usb_sndctrlpipe(data->udev, 0); 59 pipe = usb_sndctrlpipe(udev, 0);
67 60
68 if ((usb_control_msg(data->udev, pipe, 61 send_buf = kmalloc(BULK_SIZE, GFP_ATOMIC);
62 if (!send_buf) {
63 BT_ERR("Can't allocate memory chunk for firmware");
64 return -ENOMEM;
65 }
66
67 memcpy(send_buf, firmware->data, 20);
68 if ((err = usb_control_msg(udev, pipe,
69 USB_REQ_DFU_DNLOAD, 69 USB_REQ_DFU_DNLOAD,
70 USB_TYPE_VENDOR, 0, 0, 70 USB_TYPE_VENDOR, 0, 0,
71 firmware, 20, USB_CTRL_SET_TIMEOUT)) < 0) { 71 send_buf, 20, USB_CTRL_SET_TIMEOUT)) < 0) {
72 BT_ERR("Can't change to loading configuration err"); 72 BT_ERR("Can't change to loading configuration err");
73 return -EBUSY; 73 goto error;
74 } 74 }
75 sent += 20; 75 sent += 20;
76 count -= 20; 76 count -= 20;
77 77
78 send_buf = kmalloc(BULK_SIZE, GFP_ATOMIC);
79 if (!send_buf) {
80 BT_ERR("Can't allocate memory chunk for firmware");
81 return -ENOMEM;
82 }
83
84 while (count) { 78 while (count) {
85 size = min_t(uint, count, BULK_SIZE); 79 size = min_t(uint, count, BULK_SIZE);
86 pipe = usb_sndbulkpipe(data->udev, 0x02); 80 pipe = usb_sndbulkpipe(udev, 0x02);
87 memcpy(send_buf, firmware + sent, size); 81 memcpy(send_buf, firmware->data + sent, size);
88 82
89 err = usb_bulk_msg(data->udev, pipe, send_buf, size, 83 err = usb_bulk_msg(udev, pipe, send_buf, size,
90 &len, 3000); 84 &len, 3000);
91 85
92 if (err || (len != size)) { 86 if (err || (len != size)) {
@@ -112,57 +106,28 @@ static int ath3k_probe(struct usb_interface *intf,
112{ 106{
113 const struct firmware *firmware; 107 const struct firmware *firmware;
114 struct usb_device *udev = interface_to_usbdev(intf); 108 struct usb_device *udev = interface_to_usbdev(intf);
115 struct ath3k_data *data;
116 int size;
117 109
118 BT_DBG("intf %p id %p", intf, id); 110 BT_DBG("intf %p id %p", intf, id);
119 111
120 if (intf->cur_altsetting->desc.bInterfaceNumber != 0) 112 if (intf->cur_altsetting->desc.bInterfaceNumber != 0)
121 return -ENODEV; 113 return -ENODEV;
122 114
123 data = kzalloc(sizeof(*data), GFP_KERNEL);
124 if (!data)
125 return -ENOMEM;
126
127 data->udev = udev;
128
129 if (request_firmware(&firmware, "ath3k-1.fw", &udev->dev) < 0) { 115 if (request_firmware(&firmware, "ath3k-1.fw", &udev->dev) < 0) {
130 kfree(data);
131 return -EIO; 116 return -EIO;
132 } 117 }
133 118
134 size = max_t(uint, firmware->size, 4096); 119 if (ath3k_load_firmware(udev, firmware)) {
135 data->fw_data = kmalloc(size, GFP_KERNEL);
136 if (!data->fw_data) {
137 release_firmware(firmware); 120 release_firmware(firmware);
138 kfree(data);
139 return -ENOMEM;
140 }
141
142 memcpy(data->fw_data, firmware->data, firmware->size);
143 data->fw_size = firmware->size;
144 data->fw_sent = 0;
145 release_firmware(firmware);
146
147 usb_set_intfdata(intf, data);
148 if (ath3k_load_firmware(data, data->fw_data, data->fw_size)) {
149 usb_set_intfdata(intf, NULL);
150 kfree(data->fw_data);
151 kfree(data);
152 return -EIO; 121 return -EIO;
153 } 122 }
123 release_firmware(firmware);
154 124
155 return 0; 125 return 0;
156} 126}
157 127
158static void ath3k_disconnect(struct usb_interface *intf) 128static void ath3k_disconnect(struct usb_interface *intf)
159{ 129{
160 struct ath3k_data *data = usb_get_intfdata(intf);
161
162 BT_DBG("ath3k_disconnect intf %p", intf); 130 BT_DBG("ath3k_disconnect intf %p", intf);
163
164 kfree(data->fw_data);
165 kfree(data);
166} 131}
167 132
168static struct usb_driver ath3k_driver = { 133static struct usb_driver ath3k_driver = {
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 0f175a866ef0..b7980a83ce2d 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -5,7 +5,7 @@
5menu "Character devices" 5menu "Character devices"
6 6
7config VT 7config VT
8 bool "Virtual terminal" if EMBEDDED 8 bool "Virtual terminal" if EXPERT
9 depends on !S390 9 depends on !S390
10 select INPUT 10 select INPUT
11 default y 11 default y
@@ -39,13 +39,13 @@ config VT
39config CONSOLE_TRANSLATIONS 39config CONSOLE_TRANSLATIONS
40 depends on VT 40 depends on VT
41 default y 41 default y
42 bool "Enable character translations in console" if EMBEDDED 42 bool "Enable character translations in console" if EXPERT
43 ---help--- 43 ---help---
44 This enables support for font mapping and Unicode translation 44 This enables support for font mapping and Unicode translation
45 on virtual consoles. 45 on virtual consoles.
46 46
47config VT_CONSOLE 47config VT_CONSOLE
48 bool "Support for console on virtual terminal" if EMBEDDED 48 bool "Support for console on virtual terminal" if EXPERT
49 depends on VT 49 depends on VT
50 default y 50 default y
51 ---help--- 51 ---help---
@@ -426,10 +426,10 @@ config SGI_MBCS
426 If you have an SGI Altix with an attached SABrick 426 If you have an SGI Altix with an attached SABrick
427 say Y or M here, otherwise say N. 427 say Y or M here, otherwise say N.
428 428
429source "drivers/serial/Kconfig" 429source "drivers/tty/serial/Kconfig"
430 430
431config UNIX98_PTYS 431config UNIX98_PTYS
432 bool "Unix98 PTY support" if EMBEDDED 432 bool "Unix98 PTY support" if EXPERT
433 default y 433 default y
434 ---help--- 434 ---help---
435 A pseudo terminal (PTY) is a software device consisting of two 435 A pseudo terminal (PTY) is a software device consisting of two
@@ -495,7 +495,7 @@ config LEGACY_PTY_COUNT
495 495
496config TTY_PRINTK 496config TTY_PRINTK
497 bool "TTY driver to output user messages via printk" 497 bool "TTY driver to output user messages via printk"
498 depends on EMBEDDED 498 depends on EXPERT
499 default n 499 default n
500 ---help--- 500 ---help---
501 If you say Y here, the support for writing user messages (i.e. 501 If you say Y here, the support for writing user messages (i.e.
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index 1e9dffb33778..5bc765d4c3ca 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -30,25 +30,12 @@ obj-$(CONFIG_SYNCLINK_GT) += synclink_gt.o
30obj-$(CONFIG_AMIGA_BUILTIN_SERIAL) += amiserial.o 30obj-$(CONFIG_AMIGA_BUILTIN_SERIAL) += amiserial.o
31obj-$(CONFIG_SX) += sx.o generic_serial.o 31obj-$(CONFIG_SX) += sx.o generic_serial.o
32obj-$(CONFIG_RIO) += rio/ generic_serial.o 32obj-$(CONFIG_RIO) += rio/ generic_serial.o
33obj-$(CONFIG_HVC_CONSOLE) += hvc_vio.o hvsi.o
34obj-$(CONFIG_HVC_ISERIES) += hvc_iseries.o
35obj-$(CONFIG_HVC_RTAS) += hvc_rtas.o
36obj-$(CONFIG_HVC_TILE) += hvc_tile.o
37obj-$(CONFIG_HVC_DCC) += hvc_dcc.o
38obj-$(CONFIG_HVC_BEAT) += hvc_beat.o
39obj-$(CONFIG_HVC_DRIVER) += hvc_console.o
40obj-$(CONFIG_HVC_IRQ) += hvc_irq.o
41obj-$(CONFIG_HVC_XEN) += hvc_xen.o
42obj-$(CONFIG_HVC_IUCV) += hvc_iucv.o
43obj-$(CONFIG_HVC_UDBG) += hvc_udbg.o
44obj-$(CONFIG_VIRTIO_CONSOLE) += virtio_console.o
45obj-$(CONFIG_RAW_DRIVER) += raw.o 33obj-$(CONFIG_RAW_DRIVER) += raw.o
46obj-$(CONFIG_SGI_SNSC) += snsc.o snsc_event.o 34obj-$(CONFIG_SGI_SNSC) += snsc.o snsc_event.o
47obj-$(CONFIG_MSPEC) += mspec.o 35obj-$(CONFIG_MSPEC) += mspec.o
48obj-$(CONFIG_MMTIMER) += mmtimer.o 36obj-$(CONFIG_MMTIMER) += mmtimer.o
49obj-$(CONFIG_UV_MMTIMER) += uv_mmtimer.o 37obj-$(CONFIG_UV_MMTIMER) += uv_mmtimer.o
50obj-$(CONFIG_VIOTAPE) += viotape.o 38obj-$(CONFIG_VIOTAPE) += viotape.o
51obj-$(CONFIG_HVCS) += hvcs.o
52obj-$(CONFIG_IBM_BSR) += bsr.o 39obj-$(CONFIG_IBM_BSR) += bsr.o
53obj-$(CONFIG_SGI_MBCS) += mbcs.o 40obj-$(CONFIG_SGI_MBCS) += mbcs.o
54obj-$(CONFIG_BRIQ_PANEL) += briq_panel.o 41obj-$(CONFIG_BRIQ_PANEL) += briq_panel.o
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
index 826ab0939a12..fab3d3265adb 100644
--- a/drivers/char/agp/intel-gtt.c
+++ b/drivers/char/agp/intel-gtt.c
@@ -68,6 +68,7 @@ static struct _intel_private {
68 phys_addr_t gma_bus_addr; 68 phys_addr_t gma_bus_addr;
69 u32 PGETBL_save; 69 u32 PGETBL_save;
70 u32 __iomem *gtt; /* I915G */ 70 u32 __iomem *gtt; /* I915G */
71 bool clear_fake_agp; /* on first access via agp, fill with scratch */
71 int num_dcache_entries; 72 int num_dcache_entries;
72 union { 73 union {
73 void __iomem *i9xx_flush_page; 74 void __iomem *i9xx_flush_page;
@@ -869,21 +870,12 @@ static int intel_fake_agp_free_gatt_table(struct agp_bridge_data *bridge)
869 870
870static int intel_fake_agp_configure(void) 871static int intel_fake_agp_configure(void)
871{ 872{
872 int i;
873
874 if (!intel_enable_gtt()) 873 if (!intel_enable_gtt())
875 return -EIO; 874 return -EIO;
876 875
876 intel_private.clear_fake_agp = true;
877 agp_bridge->gart_bus_addr = intel_private.gma_bus_addr; 877 agp_bridge->gart_bus_addr = intel_private.gma_bus_addr;
878 878
879 for (i = 0; i < intel_private.base.gtt_total_entries; i++) {
880 intel_private.driver->write_entry(intel_private.scratch_page_dma,
881 i, 0);
882 }
883 readl(intel_private.gtt+i-1); /* PCI Posting. */
884
885 global_cache_flush();
886
887 return 0; 879 return 0;
888} 880}
889 881
@@ -945,6 +937,13 @@ static int intel_fake_agp_insert_entries(struct agp_memory *mem,
945{ 937{
946 int ret = -EINVAL; 938 int ret = -EINVAL;
947 939
940 if (intel_private.clear_fake_agp) {
941 int start = intel_private.base.stolen_size / PAGE_SIZE;
942 int end = intel_private.base.gtt_mappable_entries;
943 intel_gtt_clear_range(start, end - start);
944 intel_private.clear_fake_agp = false;
945 }
946
948 if (INTEL_GTT_GEN == 1 && type == AGP_DCACHE_MEMORY) 947 if (INTEL_GTT_GEN == 1 && type == AGP_DCACHE_MEMORY)
949 return i810_insert_dcache_entries(mem, pg_start, type); 948 return i810_insert_dcache_entries(mem, pg_start, type);
950 949
diff --git a/drivers/char/bfin_jtag_comm.c b/drivers/char/bfin_jtag_comm.c
index e397df3ad98e..16402445f2b2 100644
--- a/drivers/char/bfin_jtag_comm.c
+++ b/drivers/char/bfin_jtag_comm.c
@@ -183,16 +183,16 @@ bfin_jc_circ_write(const unsigned char *buf, int count)
183} 183}
184 184
185#ifndef CONFIG_BFIN_JTAG_COMM_CONSOLE 185#ifndef CONFIG_BFIN_JTAG_COMM_CONSOLE
186# define acquire_console_sem() 186# define console_lock()
187# define release_console_sem() 187# define console_unlock()
188#endif 188#endif
189static int 189static int
190bfin_jc_write(struct tty_struct *tty, const unsigned char *buf, int count) 190bfin_jc_write(struct tty_struct *tty, const unsigned char *buf, int count)
191{ 191{
192 int i; 192 int i;
193 acquire_console_sem(); 193 console_lock();
194 i = bfin_jc_circ_write(buf, count); 194 i = bfin_jc_circ_write(buf, count);
195 release_console_sem(); 195 console_unlock();
196 wake_up_process(bfin_jc_kthread); 196 wake_up_process(bfin_jc_kthread);
197 return i; 197 return i;
198} 198}
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index 1f46f1cd9225..36e0fa161c2b 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -364,12 +364,14 @@ unsigned long tpm_calc_ordinal_duration(struct tpm_chip *chip,
364 tpm_protected_ordinal_duration[ordinal & 364 tpm_protected_ordinal_duration[ordinal &
365 TPM_PROTECTED_ORDINAL_MASK]; 365 TPM_PROTECTED_ORDINAL_MASK];
366 366
367 if (duration_idx != TPM_UNDEFINED) 367 if (duration_idx != TPM_UNDEFINED) {
368 duration = chip->vendor.duration[duration_idx]; 368 duration = chip->vendor.duration[duration_idx];
369 if (duration <= 0) 369 /* if duration is 0, it's because chip->vendor.duration wasn't */
370 /* filled yet, so we set the lowest timeout just to give enough */
371 /* time for tpm_get_timeouts() to succeed */
372 return (duration <= 0 ? HZ : duration);
373 } else
370 return 2 * 60 * HZ; 374 return 2 * 60 * HZ;
371 else
372 return duration;
373} 375}
374EXPORT_SYMBOL_GPL(tpm_calc_ordinal_duration); 376EXPORT_SYMBOL_GPL(tpm_calc_ordinal_duration);
375 377
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index c17a305ecb28..dd21df55689d 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -493,9 +493,6 @@ static int tpm_tis_init(struct device *dev, resource_size_t start,
493 "1.2 TPM (device-id 0x%X, rev-id %d)\n", 493 "1.2 TPM (device-id 0x%X, rev-id %d)\n",
494 vendor >> 16, ioread8(chip->vendor.iobase + TPM_RID(0))); 494 vendor >> 16, ioread8(chip->vendor.iobase + TPM_RID(0)));
495 495
496 if (is_itpm(to_pnp_dev(dev)))
497 itpm = 1;
498
499 if (itpm) 496 if (itpm)
500 dev_info(dev, "Intel iTPM workaround enabled\n"); 497 dev_info(dev, "Intel iTPM workaround enabled\n");
501 498
@@ -637,6 +634,9 @@ static int __devinit tpm_tis_pnp_init(struct pnp_dev *pnp_dev,
637 else 634 else
638 interrupts = 0; 635 interrupts = 0;
639 636
637 if (is_itpm(pnp_dev))
638 itpm = 1;
639
640 return tpm_tis_init(&pnp_dev->dev, start, len, irq); 640 return tpm_tis_init(&pnp_dev->dev, start, len, irq);
641} 641}
642 642
diff --git a/drivers/clocksource/acpi_pm.c b/drivers/clocksource/acpi_pm.c
index cfb0f5278415..effe7974aa9a 100644
--- a/drivers/clocksource/acpi_pm.c
+++ b/drivers/clocksource/acpi_pm.c
@@ -202,17 +202,21 @@ static int __init init_acpi_pm_clocksource(void)
202 printk(KERN_INFO "PM-Timer had inconsistent results:" 202 printk(KERN_INFO "PM-Timer had inconsistent results:"
203 " 0x%#llx, 0x%#llx - aborting.\n", 203 " 0x%#llx, 0x%#llx - aborting.\n",
204 value1, value2); 204 value1, value2);
205 pmtmr_ioport = 0;
205 return -EINVAL; 206 return -EINVAL;
206 } 207 }
207 if (i == ACPI_PM_READ_CHECKS) { 208 if (i == ACPI_PM_READ_CHECKS) {
208 printk(KERN_INFO "PM-Timer failed consistency check " 209 printk(KERN_INFO "PM-Timer failed consistency check "
209 " (0x%#llx) - aborting.\n", value1); 210 " (0x%#llx) - aborting.\n", value1);
211 pmtmr_ioport = 0;
210 return -ENODEV; 212 return -ENODEV;
211 } 213 }
212 } 214 }
213 215
214 if (verify_pmtmr_rate() != 0) 216 if (verify_pmtmr_rate() != 0){
217 pmtmr_ioport = 0;
215 return -ENODEV; 218 return -ENODEV;
219 }
216 220
217 return clocksource_register_hz(&clocksource_acpi_pm, 221 return clocksource_register_hz(&clocksource_acpi_pm,
218 PMTMR_TICKS_PER_SEC); 222 PMTMR_TICKS_PER_SEC);
diff --git a/drivers/clocksource/tcb_clksrc.c b/drivers/clocksource/tcb_clksrc.c
index 01b886e68822..79c47e88d5d1 100644
--- a/drivers/clocksource/tcb_clksrc.c
+++ b/drivers/clocksource/tcb_clksrc.c
@@ -196,9 +196,9 @@ static void __init setup_clkevents(struct atmel_tc *tc, int clk32k_divisor_idx)
196 clkevt.clkevt.min_delta_ns = clockevent_delta2ns(1, &clkevt.clkevt) + 1; 196 clkevt.clkevt.min_delta_ns = clockevent_delta2ns(1, &clkevt.clkevt) + 1;
197 clkevt.clkevt.cpumask = cpumask_of(0); 197 clkevt.clkevt.cpumask = cpumask_of(0);
198 198
199 setup_irq(irq, &tc_irqaction);
200
201 clockevents_register_device(&clkevt.clkevt); 199 clockevents_register_device(&clkevt.clkevt);
200
201 setup_irq(irq, &tc_irqaction);
202} 202}
203 203
204#else /* !CONFIG_GENERIC_CLOCKEVENTS */ 204#else /* !CONFIG_GENERIC_CLOCKEVENTS */
diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
index a8c8d9c19d74..ca8ee8093d6c 100644
--- a/drivers/cpufreq/Kconfig
+++ b/drivers/cpufreq/Kconfig
@@ -71,7 +71,7 @@ config CPU_FREQ_DEFAULT_GOV_PERFORMANCE
71 71
72config CPU_FREQ_DEFAULT_GOV_POWERSAVE 72config CPU_FREQ_DEFAULT_GOV_POWERSAVE
73 bool "powersave" 73 bool "powersave"
74 depends on EMBEDDED 74 depends on EXPERT
75 select CPU_FREQ_GOV_POWERSAVE 75 select CPU_FREQ_GOV_POWERSAVE
76 help 76 help
77 Use the CPUFreq governor 'powersave' as default. This sets 77 Use the CPUFreq governor 'powersave' as default. This sets
diff --git a/drivers/firewire/Kconfig b/drivers/firewire/Kconfig
index 68f942cb30f2..0c56989cd907 100644
--- a/drivers/firewire/Kconfig
+++ b/drivers/firewire/Kconfig
@@ -49,15 +49,13 @@ config FIREWIRE_SBP2
49 configuration section. 49 configuration section.
50 50
51config FIREWIRE_NET 51config FIREWIRE_NET
52 tristate "IP networking over 1394 (EXPERIMENTAL)" 52 tristate "IP networking over 1394"
53 depends on FIREWIRE && INET && EXPERIMENTAL 53 depends on FIREWIRE && INET
54 help 54 help
55 This enables IPv4 over IEEE 1394, providing IP connectivity with 55 This enables IPv4 over IEEE 1394, providing IP connectivity with
56 other implementations of RFC 2734 as found on several operating 56 other implementations of RFC 2734 as found on several operating
57 systems. Multicast support is currently limited. 57 systems. Multicast support is currently limited.
58 58
59 NOTE, this driver is not stable yet!
60
61 To compile this driver as a module, say M here: The module will be 59 To compile this driver as a module, say M here: The module will be
62 called firewire-net. 60 called firewire-net.
63 61
diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
index be0492398ef9..24ff35511e2b 100644
--- a/drivers/firewire/core-card.c
+++ b/drivers/firewire/core-card.c
@@ -75,6 +75,8 @@ static size_t config_rom_length = 1 + 4 + 1 + 1;
75#define BIB_IRMC ((1) << 31) 75#define BIB_IRMC ((1) << 31)
76#define NODE_CAPABILITIES 0x0c0083c0 /* per IEEE 1394 clause 8.3.2.6.5.2 */ 76#define NODE_CAPABILITIES 0x0c0083c0 /* per IEEE 1394 clause 8.3.2.6.5.2 */
77 77
78#define CANON_OUI 0x000085
79
78static void generate_config_rom(struct fw_card *card, __be32 *config_rom) 80static void generate_config_rom(struct fw_card *card, __be32 *config_rom)
79{ 81{
80 struct fw_descriptor *desc; 82 struct fw_descriptor *desc;
@@ -284,6 +286,7 @@ static void bm_work(struct work_struct *work)
284 bool root_device_is_running; 286 bool root_device_is_running;
285 bool root_device_is_cmc; 287 bool root_device_is_cmc;
286 bool irm_is_1394_1995_only; 288 bool irm_is_1394_1995_only;
289 bool keep_this_irm;
287 290
288 spin_lock_irq(&card->lock); 291 spin_lock_irq(&card->lock);
289 292
@@ -305,6 +308,10 @@ static void bm_work(struct work_struct *work)
305 irm_is_1394_1995_only = irm_device && irm_device->config_rom && 308 irm_is_1394_1995_only = irm_device && irm_device->config_rom &&
306 (irm_device->config_rom[2] & 0x000000f0) == 0; 309 (irm_device->config_rom[2] & 0x000000f0) == 0;
307 310
311 /* Canon MV5i works unreliably if it is not root node. */
312 keep_this_irm = irm_device && irm_device->config_rom &&
313 irm_device->config_rom[3] >> 8 == CANON_OUI;
314
308 root_id = root_node->node_id; 315 root_id = root_node->node_id;
309 irm_id = card->irm_node->node_id; 316 irm_id = card->irm_node->node_id;
310 local_id = card->local_node->node_id; 317 local_id = card->local_node->node_id;
@@ -333,7 +340,7 @@ static void bm_work(struct work_struct *work)
333 goto pick_me; 340 goto pick_me;
334 } 341 }
335 342
336 if (irm_is_1394_1995_only) { 343 if (irm_is_1394_1995_only && !keep_this_irm) {
337 new_root_id = local_id; 344 new_root_id = local_id;
338 fw_notify("%s, making local node (%02x) root.\n", 345 fw_notify("%s, making local node (%02x) root.\n",
339 "IRM is not 1394a compliant", new_root_id); 346 "IRM is not 1394a compliant", new_root_id);
@@ -382,7 +389,7 @@ static void bm_work(struct work_struct *work)
382 389
383 spin_lock_irq(&card->lock); 390 spin_lock_irq(&card->lock);
384 391
385 if (rcode != RCODE_COMPLETE) { 392 if (rcode != RCODE_COMPLETE && !keep_this_irm) {
386 /* 393 /*
387 * The lock request failed, maybe the IRM 394 * The lock request failed, maybe the IRM
388 * isn't really IRM capable after all. Let's 395 * isn't really IRM capable after all. Let's
diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
index c2e194c58667..7ed08fd1214e 100644
--- a/drivers/firewire/net.c
+++ b/drivers/firewire/net.c
@@ -191,6 +191,7 @@ struct fwnet_peer {
191 struct fwnet_device *dev; 191 struct fwnet_device *dev;
192 u64 guid; 192 u64 guid;
193 u64 fifo; 193 u64 fifo;
194 __be32 ip;
194 195
195 /* guarded by dev->lock */ 196 /* guarded by dev->lock */
196 struct list_head pd_list; /* received partial datagrams */ 197 struct list_head pd_list; /* received partial datagrams */
@@ -570,6 +571,8 @@ static int fwnet_finish_incoming_packet(struct net_device *net,
570 peer->speed = sspd; 571 peer->speed = sspd;
571 if (peer->max_payload > max_payload) 572 if (peer->max_payload > max_payload)
572 peer->max_payload = max_payload; 573 peer->max_payload = max_payload;
574
575 peer->ip = arp1394->sip;
573 } 576 }
574 spin_unlock_irqrestore(&dev->lock, flags); 577 spin_unlock_irqrestore(&dev->lock, flags);
575 578
@@ -1470,6 +1473,7 @@ static int fwnet_add_peer(struct fwnet_device *dev,
1470 peer->dev = dev; 1473 peer->dev = dev;
1471 peer->guid = (u64)device->config_rom[3] << 32 | device->config_rom[4]; 1474 peer->guid = (u64)device->config_rom[3] << 32 | device->config_rom[4];
1472 peer->fifo = FWNET_NO_FIFO_ADDR; 1475 peer->fifo = FWNET_NO_FIFO_ADDR;
1476 peer->ip = 0;
1473 INIT_LIST_HEAD(&peer->pd_list); 1477 INIT_LIST_HEAD(&peer->pd_list);
1474 peer->pdg_size = 0; 1478 peer->pdg_size = 0;
1475 peer->datagram_label = 0; 1479 peer->datagram_label = 0;
@@ -1589,10 +1593,13 @@ static int fwnet_remove(struct device *_dev)
1589 1593
1590 mutex_lock(&fwnet_device_mutex); 1594 mutex_lock(&fwnet_device_mutex);
1591 1595
1596 net = dev->netdev;
1597 if (net && peer->ip)
1598 arp_invalidate(net, peer->ip);
1599
1592 fwnet_remove_peer(peer, dev); 1600 fwnet_remove_peer(peer, dev);
1593 1601
1594 if (list_empty(&dev->peer_list)) { 1602 if (list_empty(&dev->peer_list)) {
1595 net = dev->netdev;
1596 unregister_netdev(net); 1603 unregister_netdev(net);
1597 1604
1598 if (dev->local_fifo != FWNET_NO_FIFO_ADDR) 1605 if (dev->local_fifo != FWNET_NO_FIFO_ADDR)
diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig
index e8b6a13515bd..e710424b59ea 100644
--- a/drivers/firmware/Kconfig
+++ b/drivers/firmware/Kconfig
@@ -27,7 +27,7 @@ config EDD_OFF
27 using the kernel parameter 'edd={on|skipmbr|off}'. 27 using the kernel parameter 'edd={on|skipmbr|off}'.
28 28
29config FIRMWARE_MEMMAP 29config FIRMWARE_MEMMAP
30 bool "Add firmware-provided memory map to sysfs" if EMBEDDED 30 bool "Add firmware-provided memory map to sysfs" if EXPERT
31 default X86 31 default X86
32 help 32 help
33 Add the firmware-provided (unmodified) memory map to /sys/firmware/memmap. 33 Add the firmware-provided (unmodified) memory map to /sys/firmware/memmap.
diff --git a/drivers/gpio/langwell_gpio.c b/drivers/gpio/langwell_gpio.c
index d81cc748e77f..54d70a47afc1 100644
--- a/drivers/gpio/langwell_gpio.c
+++ b/drivers/gpio/langwell_gpio.c
@@ -187,7 +187,7 @@ MODULE_DEVICE_TABLE(pci, lnw_gpio_ids);
187 187
188static void lnw_irq_handler(unsigned irq, struct irq_desc *desc) 188static void lnw_irq_handler(unsigned irq, struct irq_desc *desc)
189{ 189{
190 struct lnw_gpio *lnw = (struct lnw_gpio *)get_irq_data(irq); 190 struct lnw_gpio *lnw = get_irq_data(irq);
191 u32 base, gpio; 191 u32 base, gpio;
192 void __iomem *gedr; 192 void __iomem *gedr;
193 u32 gedr_v; 193 u32 gedr_v;
@@ -206,7 +206,12 @@ static void lnw_irq_handler(unsigned irq, struct irq_desc *desc)
206 /* clear the edge detect status bit */ 206 /* clear the edge detect status bit */
207 writel(gedr_v, gedr); 207 writel(gedr_v, gedr);
208 } 208 }
209 desc->chip->eoi(irq); 209
210 if (desc->chip->irq_eoi)
211 desc->chip->irq_eoi(irq_get_irq_data(irq));
212 else
213 dev_warn(lnw->chip.dev, "missing EOI handler for irq %d\n", irq);
214
210} 215}
211 216
212static int __devinit lnw_gpio_probe(struct pci_dev *pdev, 217static int __devinit lnw_gpio_probe(struct pci_dev *pdev,
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 64828a7db77b..0902d4460039 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -23,7 +23,7 @@ config DRM_KMS_HELPER
23 tristate 23 tristate
24 depends on DRM 24 depends on DRM
25 select FB 25 select FB
26 select FRAMEBUFFER_CONSOLE if !EMBEDDED 26 select FRAMEBUFFER_CONSOLE if !EXPERT
27 help 27 help
28 FB and CRTC helpers for KMS drivers. 28 FB and CRTC helpers for KMS drivers.
29 29
@@ -100,7 +100,10 @@ config DRM_I830
100config DRM_I915 100config DRM_I915
101 tristate "i915 driver" 101 tristate "i915 driver"
102 depends on AGP_INTEL 102 depends on AGP_INTEL
103 # we need shmfs for the swappable backing store, and in particular
104 # the shmem_readpage() which depends upon tmpfs
103 select SHMEM 105 select SHMEM
106 select TMPFS
104 select DRM_KMS_HELPER 107 select DRM_KMS_HELPER
105 select FB_CFB_FILLRECT 108 select FB_CFB_FILLRECT
106 select FB_CFB_COPYAREA 109 select FB_CFB_COPYAREA
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 5c4f9b9ecdc0..6977a1ce9d98 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1533,11 +1533,11 @@ bool drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper)
1533} 1533}
1534EXPORT_SYMBOL(drm_fb_helper_hotplug_event); 1534EXPORT_SYMBOL(drm_fb_helper_hotplug_event);
1535 1535
1536/* The Kconfig DRM_KMS_HELPER selects FRAMEBUFFER_CONSOLE (if !EMBEDDED) 1536/* The Kconfig DRM_KMS_HELPER selects FRAMEBUFFER_CONSOLE (if !EXPERT)
1537 * but the module doesn't depend on any fb console symbols. At least 1537 * but the module doesn't depend on any fb console symbols. At least
1538 * attempt to load fbcon to avoid leaving the system without a usable console. 1538 * attempt to load fbcon to avoid leaving the system without a usable console.
1539 */ 1539 */
1540#if defined(CONFIG_FRAMEBUFFER_CONSOLE_MODULE) && !defined(CONFIG_EMBEDDED) 1540#if defined(CONFIG_FRAMEBUFFER_CONSOLE_MODULE) && !defined(CONFIG_EXPERT)
1541static int __init drm_fb_helper_modinit(void) 1541static int __init drm_fb_helper_modinit(void)
1542{ 1542{
1543 const char *name = "fbcon"; 1543 const char *name = "fbcon";
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 844f3c972b04..17bd766f2081 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -152,7 +152,7 @@ static int i915_initialize(struct drm_device * dev, drm_i915_init_t * init)
152{ 152{
153 drm_i915_private_t *dev_priv = dev->dev_private; 153 drm_i915_private_t *dev_priv = dev->dev_private;
154 struct drm_i915_master_private *master_priv = dev->primary->master->driver_priv; 154 struct drm_i915_master_private *master_priv = dev->primary->master->driver_priv;
155 struct intel_ring_buffer *ring = LP_RING(dev_priv); 155 int ret;
156 156
157 master_priv->sarea = drm_getsarea(dev); 157 master_priv->sarea = drm_getsarea(dev);
158 if (master_priv->sarea) { 158 if (master_priv->sarea) {
@@ -163,33 +163,22 @@ static int i915_initialize(struct drm_device * dev, drm_i915_init_t * init)
163 } 163 }
164 164
165 if (init->ring_size != 0) { 165 if (init->ring_size != 0) {
166 if (ring->obj != NULL) { 166 if (LP_RING(dev_priv)->obj != NULL) {
167 i915_dma_cleanup(dev); 167 i915_dma_cleanup(dev);
168 DRM_ERROR("Client tried to initialize ringbuffer in " 168 DRM_ERROR("Client tried to initialize ringbuffer in "
169 "GEM mode\n"); 169 "GEM mode\n");
170 return -EINVAL; 170 return -EINVAL;
171 } 171 }
172 172
173 ring->size = init->ring_size; 173 ret = intel_render_ring_init_dri(dev,
174 174 init->ring_start,
175 ring->map.offset = init->ring_start; 175 init->ring_size);
176 ring->map.size = init->ring_size; 176 if (ret) {
177 ring->map.type = 0;
178 ring->map.flags = 0;
179 ring->map.mtrr = 0;
180
181 drm_core_ioremap_wc(&ring->map, dev);
182
183 if (ring->map.handle == NULL) {
184 i915_dma_cleanup(dev); 177 i915_dma_cleanup(dev);
185 DRM_ERROR("can not ioremap virtual address for" 178 return ret;
186 " ring buffer\n");
187 return -ENOMEM;
188 } 179 }
189 } 180 }
190 181
191 ring->virtual_start = ring->map.handle;
192
193 dev_priv->cpp = init->cpp; 182 dev_priv->cpp = init->cpp;
194 dev_priv->back_offset = init->back_offset; 183 dev_priv->back_offset = init->back_offset;
195 dev_priv->front_offset = init->front_offset; 184 dev_priv->front_offset = init->front_offset;
@@ -1226,9 +1215,15 @@ static int i915_load_modeset_init(struct drm_device *dev)
1226 if (ret) 1215 if (ret)
1227 DRM_INFO("failed to find VBIOS tables\n"); 1216 DRM_INFO("failed to find VBIOS tables\n");
1228 1217
1229 /* if we have > 1 VGA cards, then disable the radeon VGA resources */ 1218 /* If we have > 1 VGA cards, then we need to arbitrate access
1219 * to the common VGA resources.
1220 *
1221 * If we are a secondary display controller (!PCI_DISPLAY_CLASS_VGA),
1222 * then we do not take part in VGA arbitration and the
1223 * vga_client_register() fails with -ENODEV.
1224 */
1230 ret = vga_client_register(dev->pdev, dev, NULL, i915_vga_set_decode); 1225 ret = vga_client_register(dev->pdev, dev, NULL, i915_vga_set_decode);
1231 if (ret) 1226 if (ret && ret != -ENODEV)
1232 goto cleanup_ringbuffer; 1227 goto cleanup_ringbuffer;
1233 1228
1234 intel_register_dsm_handler(); 1229 intel_register_dsm_handler();
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 72fea2bcfc4f..66796bb82d3e 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -60,7 +60,7 @@ extern int intel_agp_enabled;
60 60
61#define INTEL_VGA_DEVICE(id, info) { \ 61#define INTEL_VGA_DEVICE(id, info) { \
62 .class = PCI_CLASS_DISPLAY_VGA << 8, \ 62 .class = PCI_CLASS_DISPLAY_VGA << 8, \
63 .class_mask = 0xffff00, \ 63 .class_mask = 0xff0000, \
64 .vendor = 0x8086, \ 64 .vendor = 0x8086, \
65 .device = id, \ 65 .device = id, \
66 .subvendor = PCI_ANY_ID, \ 66 .subvendor = PCI_ANY_ID, \
@@ -752,6 +752,9 @@ static int __init i915_init(void)
752 driver.driver_features &= ~DRIVER_MODESET; 752 driver.driver_features &= ~DRIVER_MODESET;
753#endif 753#endif
754 754
755 if (!(driver.driver_features & DRIVER_MODESET))
756 driver.get_vblank_timestamp = NULL;
757
755 return drm_init(&driver); 758 return drm_init(&driver);
756} 759}
757 760
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 5969f46ac2d6..a0149c619cdd 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -543,8 +543,11 @@ typedef struct drm_i915_private {
543 /** List of all objects in gtt_space. Used to restore gtt 543 /** List of all objects in gtt_space. Used to restore gtt
544 * mappings on resume */ 544 * mappings on resume */
545 struct list_head gtt_list; 545 struct list_head gtt_list;
546 /** End of mappable part of GTT */ 546
547 /** Usable portion of the GTT for GEM */
548 unsigned long gtt_start;
547 unsigned long gtt_mappable_end; 549 unsigned long gtt_mappable_end;
550 unsigned long gtt_end;
548 551
549 struct io_mapping *gtt_mapping; 552 struct io_mapping *gtt_mapping;
550 int gtt_mtrr; 553 int gtt_mtrr;
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 3dfc848ff755..cf4f74c7c6fb 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -140,12 +140,16 @@ void i915_gem_do_init(struct drm_device *dev,
140{ 140{
141 drm_i915_private_t *dev_priv = dev->dev_private; 141 drm_i915_private_t *dev_priv = dev->dev_private;
142 142
143 drm_mm_init(&dev_priv->mm.gtt_space, start, 143 drm_mm_init(&dev_priv->mm.gtt_space, start, end - start);
144 end - start);
145 144
145 dev_priv->mm.gtt_start = start;
146 dev_priv->mm.gtt_mappable_end = mappable_end;
147 dev_priv->mm.gtt_end = end;
146 dev_priv->mm.gtt_total = end - start; 148 dev_priv->mm.gtt_total = end - start;
147 dev_priv->mm.mappable_gtt_total = min(end, mappable_end) - start; 149 dev_priv->mm.mappable_gtt_total = min(end, mappable_end) - start;
148 dev_priv->mm.gtt_mappable_end = mappable_end; 150
151 /* Take over this portion of the GTT */
152 intel_gtt_clear_range(start / PAGE_SIZE, (end-start) / PAGE_SIZE);
149} 153}
150 154
151int 155int
@@ -1857,7 +1861,7 @@ i915_gem_retire_requests_ring(struct drm_device *dev,
1857 1861
1858 seqno = ring->get_seqno(ring); 1862 seqno = ring->get_seqno(ring);
1859 1863
1860 for (i = 0; i < I915_NUM_RINGS; i++) 1864 for (i = 0; i < ARRAY_SIZE(ring->sync_seqno); i++)
1861 if (seqno >= ring->sync_seqno[i]) 1865 if (seqno >= ring->sync_seqno[i])
1862 ring->sync_seqno[i] = 0; 1866 ring->sync_seqno[i] = 0;
1863 1867
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index dcfdf4151b6d..d2f445e825f2 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -1175,7 +1175,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
1175 goto err; 1175 goto err;
1176 1176
1177 seqno = i915_gem_next_request_seqno(dev, ring); 1177 seqno = i915_gem_next_request_seqno(dev, ring);
1178 for (i = 0; i < I915_NUM_RINGS-1; i++) { 1178 for (i = 0; i < ARRAY_SIZE(ring->sync_seqno); i++) {
1179 if (seqno < ring->sync_seqno[i]) { 1179 if (seqno < ring->sync_seqno[i]) {
1180 /* The GPU can not handle its semaphore value wrapping, 1180 /* The GPU can not handle its semaphore value wrapping,
1181 * so every billion or so execbuffers, we need to stall 1181 * so every billion or so execbuffers, we need to stall
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 70433ae50ac8..b0abdc64aa9f 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -34,6 +34,10 @@ void i915_gem_restore_gtt_mappings(struct drm_device *dev)
34 struct drm_i915_private *dev_priv = dev->dev_private; 34 struct drm_i915_private *dev_priv = dev->dev_private;
35 struct drm_i915_gem_object *obj; 35 struct drm_i915_gem_object *obj;
36 36
37 /* First fill our portion of the GTT with scratch pages */
38 intel_gtt_clear_range(dev_priv->mm.gtt_start / PAGE_SIZE,
39 (dev_priv->mm.gtt_end - dev_priv->mm.gtt_start) / PAGE_SIZE);
40
37 list_for_each_entry(obj, &dev_priv->mm.gtt_list, gtt_list) { 41 list_for_each_entry(obj, &dev_priv->mm.gtt_list, gtt_list) {
38 i915_gem_clflush_object(obj); 42 i915_gem_clflush_object(obj);
39 43
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index b8e509ae065e..062f353497e6 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -274,24 +274,35 @@ int i915_get_crtc_scanoutpos(struct drm_device *dev, int pipe,
274 return ret; 274 return ret;
275} 275}
276 276
277int i915_get_vblank_timestamp(struct drm_device *dev, int crtc, 277int i915_get_vblank_timestamp(struct drm_device *dev, int pipe,
278 int *max_error, 278 int *max_error,
279 struct timeval *vblank_time, 279 struct timeval *vblank_time,
280 unsigned flags) 280 unsigned flags)
281{ 281{
282 struct drm_crtc *drmcrtc; 282 struct drm_i915_private *dev_priv = dev->dev_private;
283 struct drm_crtc *crtc;
283 284
284 if (crtc < 0 || crtc >= dev->num_crtcs) { 285 if (pipe < 0 || pipe >= dev_priv->num_pipe) {
285 DRM_ERROR("Invalid crtc %d\n", crtc); 286 DRM_ERROR("Invalid crtc %d\n", pipe);
286 return -EINVAL; 287 return -EINVAL;
287 } 288 }
288 289
289 /* Get drm_crtc to timestamp: */ 290 /* Get drm_crtc to timestamp: */
290 drmcrtc = intel_get_crtc_for_pipe(dev, crtc); 291 crtc = intel_get_crtc_for_pipe(dev, pipe);
292 if (crtc == NULL) {
293 DRM_ERROR("Invalid crtc %d\n", pipe);
294 return -EINVAL;
295 }
296
297 if (!crtc->enabled) {
298 DRM_DEBUG_KMS("crtc %d is disabled\n", pipe);
299 return -EBUSY;
300 }
291 301
292 /* Helper routine in DRM core does all the work: */ 302 /* Helper routine in DRM core does all the work: */
293 return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc, max_error, 303 return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,
294 vblank_time, flags, drmcrtc); 304 vblank_time, flags,
305 crtc);
295} 306}
296 307
297/* 308/*
@@ -348,8 +359,12 @@ static void notify_ring(struct drm_device *dev,
348 struct intel_ring_buffer *ring) 359 struct intel_ring_buffer *ring)
349{ 360{
350 struct drm_i915_private *dev_priv = dev->dev_private; 361 struct drm_i915_private *dev_priv = dev->dev_private;
351 u32 seqno = ring->get_seqno(ring); 362 u32 seqno;
352 363
364 if (ring->obj == NULL)
365 return;
366
367 seqno = ring->get_seqno(ring);
353 trace_i915_gem_request_complete(dev, seqno); 368 trace_i915_gem_request_complete(dev, seqno);
354 369
355 ring->irq_seqno = seqno; 370 ring->irq_seqno = seqno;
@@ -831,6 +846,8 @@ static void i915_capture_error_state(struct drm_device *dev)
831 i++; 846 i++;
832 error->pinned_bo_count = i - error->active_bo_count; 847 error->pinned_bo_count = i - error->active_bo_count;
833 848
849 error->active_bo = NULL;
850 error->pinned_bo = NULL;
834 if (i) { 851 if (i) {
835 error->active_bo = kmalloc(sizeof(*error->active_bo)*i, 852 error->active_bo = kmalloc(sizeof(*error->active_bo)*i,
836 GFP_ATOMIC); 853 GFP_ATOMIC);
@@ -1278,12 +1295,12 @@ static int i915_wait_irq(struct drm_device * dev, int irq_nr)
1278 if (master_priv->sarea_priv) 1295 if (master_priv->sarea_priv)
1279 master_priv->sarea_priv->perf_boxes |= I915_BOX_WAIT; 1296 master_priv->sarea_priv->perf_boxes |= I915_BOX_WAIT;
1280 1297
1281 ret = -ENODEV;
1282 if (ring->irq_get(ring)) { 1298 if (ring->irq_get(ring)) {
1283 DRM_WAIT_ON(ret, ring->irq_queue, 3 * DRM_HZ, 1299 DRM_WAIT_ON(ret, ring->irq_queue, 3 * DRM_HZ,
1284 READ_BREADCRUMB(dev_priv) >= irq_nr); 1300 READ_BREADCRUMB(dev_priv) >= irq_nr);
1285 ring->irq_put(ring); 1301 ring->irq_put(ring);
1286 } 1302 } else if (wait_for(READ_BREADCRUMB(dev_priv) >= irq_nr, 3000))
1303 ret = -EBUSY;
1287 1304
1288 if (ret == -EBUSY) { 1305 if (ret == -EBUSY) {
1289 DRM_ERROR("EBUSY -- rec: %d emitted: %d\n", 1306 DRM_ERROR("EBUSY -- rec: %d emitted: %d\n",
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 40a407f41f61..5cfc68940f17 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -513,6 +513,10 @@
513#define GEN6_BLITTER_SYNC_STATUS (1 << 24) 513#define GEN6_BLITTER_SYNC_STATUS (1 << 24)
514#define GEN6_BLITTER_USER_INTERRUPT (1 << 22) 514#define GEN6_BLITTER_USER_INTERRUPT (1 << 22)
515 515
516#define GEN6_BLITTER_ECOSKPD 0x221d0
517#define GEN6_BLITTER_LOCK_SHIFT 16
518#define GEN6_BLITTER_FBC_NOTIFY (1<<3)
519
516#define GEN6_BSD_SLEEP_PSMI_CONTROL 0x12050 520#define GEN6_BSD_SLEEP_PSMI_CONTROL 0x12050
517#define GEN6_BSD_SLEEP_PSMI_CONTROL_RC_ILDL_MESSAGE_MODIFY_MASK (1 << 16) 521#define GEN6_BSD_SLEEP_PSMI_CONTROL_RC_ILDL_MESSAGE_MODIFY_MASK (1 << 16)
518#define GEN6_BSD_SLEEP_PSMI_CONTROL_RC_ILDL_MESSAGE_DISABLE (1 << 0) 522#define GEN6_BSD_SLEEP_PSMI_CONTROL_RC_ILDL_MESSAGE_DISABLE (1 << 0)
@@ -2626,6 +2630,8 @@
2626#define DISPLAY_PORT_PLL_BIOS_2 0x46014 2630#define DISPLAY_PORT_PLL_BIOS_2 0x46014
2627 2631
2628#define PCH_DSPCLK_GATE_D 0x42020 2632#define PCH_DSPCLK_GATE_D 0x42020
2633# define DPFCUNIT_CLOCK_GATE_DISABLE (1 << 9)
2634# define DPFCRUNIT_CLOCK_GATE_DISABLE (1 << 8)
2629# define DPFDUNIT_CLOCK_GATE_DISABLE (1 << 7) 2635# define DPFDUNIT_CLOCK_GATE_DISABLE (1 << 7)
2630# define DPARBUNIT_CLOCK_GATE_DISABLE (1 << 5) 2636# define DPARBUNIT_CLOCK_GATE_DISABLE (1 << 5)
2631 2637
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 98967f3b7724..d7f237deaaf0 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -1213,6 +1213,26 @@ static bool g4x_fbc_enabled(struct drm_device *dev)
1213 return I915_READ(DPFC_CONTROL) & DPFC_CTL_EN; 1213 return I915_READ(DPFC_CONTROL) & DPFC_CTL_EN;
1214} 1214}
1215 1215
1216static void sandybridge_blit_fbc_update(struct drm_device *dev)
1217{
1218 struct drm_i915_private *dev_priv = dev->dev_private;
1219 u32 blt_ecoskpd;
1220
1221 /* Make sure blitter notifies FBC of writes */
1222 __gen6_force_wake_get(dev_priv);
1223 blt_ecoskpd = I915_READ(GEN6_BLITTER_ECOSKPD);
1224 blt_ecoskpd |= GEN6_BLITTER_FBC_NOTIFY <<
1225 GEN6_BLITTER_LOCK_SHIFT;
1226 I915_WRITE(GEN6_BLITTER_ECOSKPD, blt_ecoskpd);
1227 blt_ecoskpd |= GEN6_BLITTER_FBC_NOTIFY;
1228 I915_WRITE(GEN6_BLITTER_ECOSKPD, blt_ecoskpd);
1229 blt_ecoskpd &= ~(GEN6_BLITTER_FBC_NOTIFY <<
1230 GEN6_BLITTER_LOCK_SHIFT);
1231 I915_WRITE(GEN6_BLITTER_ECOSKPD, blt_ecoskpd);
1232 POSTING_READ(GEN6_BLITTER_ECOSKPD);
1233 __gen6_force_wake_put(dev_priv);
1234}
1235
1216static void ironlake_enable_fbc(struct drm_crtc *crtc, unsigned long interval) 1236static void ironlake_enable_fbc(struct drm_crtc *crtc, unsigned long interval)
1217{ 1237{
1218 struct drm_device *dev = crtc->dev; 1238 struct drm_device *dev = crtc->dev;
@@ -1266,6 +1286,7 @@ static void ironlake_enable_fbc(struct drm_crtc *crtc, unsigned long interval)
1266 I915_WRITE(SNB_DPFC_CTL_SA, 1286 I915_WRITE(SNB_DPFC_CTL_SA,
1267 SNB_CPU_FENCE_ENABLE | dev_priv->cfb_fence); 1287 SNB_CPU_FENCE_ENABLE | dev_priv->cfb_fence);
1268 I915_WRITE(DPFC_CPU_FENCE_OFFSET, crtc->y); 1288 I915_WRITE(DPFC_CPU_FENCE_OFFSET, crtc->y);
1289 sandybridge_blit_fbc_update(dev);
1269 } 1290 }
1270 1291
1271 DRM_DEBUG_KMS("enabled fbc on plane %d\n", intel_crtc->plane); 1292 DRM_DEBUG_KMS("enabled fbc on plane %d\n", intel_crtc->plane);
@@ -6286,7 +6307,9 @@ void intel_enable_clock_gating(struct drm_device *dev)
6286 6307
6287 if (IS_GEN5(dev)) { 6308 if (IS_GEN5(dev)) {
6288 /* Required for FBC */ 6309 /* Required for FBC */
6289 dspclk_gate |= DPFDUNIT_CLOCK_GATE_DISABLE; 6310 dspclk_gate |= DPFCUNIT_CLOCK_GATE_DISABLE |
6311 DPFCRUNIT_CLOCK_GATE_DISABLE |
6312 DPFDUNIT_CLOCK_GATE_DISABLE;
6290 /* Required for CxSR */ 6313 /* Required for CxSR */
6291 dspclk_gate |= DPARBUNIT_CLOCK_GATE_DISABLE; 6314 dspclk_gate |= DPARBUNIT_CLOCK_GATE_DISABLE;
6292 6315
diff --git a/drivers/gpu/drm/i915/intel_opregion.c b/drivers/gpu/drm/i915/intel_opregion.c
index f295a7aaadf9..64fd64443ca6 100644
--- a/drivers/gpu/drm/i915/intel_opregion.c
+++ b/drivers/gpu/drm/i915/intel_opregion.c
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28#include <linux/acpi.h> 28#include <linux/acpi.h>
29#include <linux/acpi_io.h>
29#include <acpi/video.h> 30#include <acpi/video.h>
30 31
31#include "drmP.h" 32#include "drmP.h"
@@ -476,7 +477,7 @@ int intel_opregion_setup(struct drm_device *dev)
476 return -ENOTSUPP; 477 return -ENOTSUPP;
477 } 478 }
478 479
479 base = ioremap(asls, OPREGION_SIZE); 480 base = acpi_os_ioremap(asls, OPREGION_SIZE);
480 if (!base) 481 if (!base)
481 return -ENOMEM; 482 return -ENOMEM;
482 483
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 03e337072517..6218fa97aa1e 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -34,6 +34,14 @@
34#include "i915_trace.h" 34#include "i915_trace.h"
35#include "intel_drv.h" 35#include "intel_drv.h"
36 36
37static inline int ring_space(struct intel_ring_buffer *ring)
38{
39 int space = (ring->head & HEAD_ADDR) - (ring->tail + 8);
40 if (space < 0)
41 space += ring->size;
42 return space;
43}
44
37static u32 i915_gem_get_seqno(struct drm_device *dev) 45static u32 i915_gem_get_seqno(struct drm_device *dev)
38{ 46{
39 drm_i915_private_t *dev_priv = dev->dev_private; 47 drm_i915_private_t *dev_priv = dev->dev_private;
@@ -204,11 +212,9 @@ static int init_ring_common(struct intel_ring_buffer *ring)
204 if (!drm_core_check_feature(ring->dev, DRIVER_MODESET)) 212 if (!drm_core_check_feature(ring->dev, DRIVER_MODESET))
205 i915_kernel_lost_context(ring->dev); 213 i915_kernel_lost_context(ring->dev);
206 else { 214 else {
207 ring->head = I915_READ_HEAD(ring) & HEAD_ADDR; 215 ring->head = I915_READ_HEAD(ring);
208 ring->tail = I915_READ_TAIL(ring) & TAIL_ADDR; 216 ring->tail = I915_READ_TAIL(ring) & TAIL_ADDR;
209 ring->space = ring->head - (ring->tail + 8); 217 ring->space = ring_space(ring);
210 if (ring->space < 0)
211 ring->space += ring->size;
212 } 218 }
213 219
214 return 0; 220 return 0;
@@ -921,7 +927,7 @@ static int intel_wrap_ring_buffer(struct intel_ring_buffer *ring)
921 } 927 }
922 928
923 ring->tail = 0; 929 ring->tail = 0;
924 ring->space = ring->head - 8; 930 ring->space = ring_space(ring);
925 931
926 return 0; 932 return 0;
927} 933}
@@ -933,20 +939,22 @@ int intel_wait_ring_buffer(struct intel_ring_buffer *ring, int n)
933 unsigned long end; 939 unsigned long end;
934 u32 head; 940 u32 head;
935 941
942 /* If the reported head position has wrapped or hasn't advanced,
943 * fallback to the slow and accurate path.
944 */
945 head = intel_read_status_page(ring, 4);
946 if (head > ring->head) {
947 ring->head = head;
948 ring->space = ring_space(ring);
949 if (ring->space >= n)
950 return 0;
951 }
952
936 trace_i915_ring_wait_begin (dev); 953 trace_i915_ring_wait_begin (dev);
937 end = jiffies + 3 * HZ; 954 end = jiffies + 3 * HZ;
938 do { 955 do {
939 /* If the reported head position has wrapped or hasn't advanced, 956 ring->head = I915_READ_HEAD(ring);
940 * fallback to the slow and accurate path. 957 ring->space = ring_space(ring);
941 */
942 head = intel_read_status_page(ring, 4);
943 if (head < ring->actual_head)
944 head = I915_READ_HEAD(ring);
945 ring->actual_head = head;
946 ring->head = head & HEAD_ADDR;
947 ring->space = ring->head - (ring->tail + 8);
948 if (ring->space < 0)
949 ring->space += ring->size;
950 if (ring->space >= n) { 958 if (ring->space >= n) {
951 trace_i915_ring_wait_end(dev); 959 trace_i915_ring_wait_end(dev);
952 return 0; 960 return 0;
@@ -1291,6 +1299,48 @@ int intel_init_render_ring_buffer(struct drm_device *dev)
1291 return intel_init_ring_buffer(dev, ring); 1299 return intel_init_ring_buffer(dev, ring);
1292} 1300}
1293 1301
1302int intel_render_ring_init_dri(struct drm_device *dev, u64 start, u32 size)
1303{
1304 drm_i915_private_t *dev_priv = dev->dev_private;
1305 struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
1306
1307 *ring = render_ring;
1308 if (INTEL_INFO(dev)->gen >= 6) {
1309 ring->add_request = gen6_add_request;
1310 ring->irq_get = gen6_render_ring_get_irq;
1311 ring->irq_put = gen6_render_ring_put_irq;
1312 } else if (IS_GEN5(dev)) {
1313 ring->add_request = pc_render_add_request;
1314 ring->get_seqno = pc_render_get_seqno;
1315 }
1316
1317 ring->dev = dev;
1318 INIT_LIST_HEAD(&ring->active_list);
1319 INIT_LIST_HEAD(&ring->request_list);
1320 INIT_LIST_HEAD(&ring->gpu_write_list);
1321
1322 ring->size = size;
1323 ring->effective_size = ring->size;
1324 if (IS_I830(ring->dev))
1325 ring->effective_size -= 128;
1326
1327 ring->map.offset = start;
1328 ring->map.size = size;
1329 ring->map.type = 0;
1330 ring->map.flags = 0;
1331 ring->map.mtrr = 0;
1332
1333 drm_core_ioremap_wc(&ring->map, dev);
1334 if (ring->map.handle == NULL) {
1335 DRM_ERROR("can not ioremap virtual address for"
1336 " ring buffer\n");
1337 return -ENOMEM;
1338 }
1339
1340 ring->virtual_start = (void __force __iomem *)ring->map.handle;
1341 return 0;
1342}
1343
1294int intel_init_bsd_ring_buffer(struct drm_device *dev) 1344int intel_init_bsd_ring_buffer(struct drm_device *dev)
1295{ 1345{
1296 drm_i915_private_t *dev_priv = dev->dev_private; 1346 drm_i915_private_t *dev_priv = dev->dev_private;
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
index be9087e4c9be..6d6fde85a636 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.h
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
@@ -47,7 +47,6 @@ struct intel_ring_buffer {
47 struct drm_device *dev; 47 struct drm_device *dev;
48 struct drm_i915_gem_object *obj; 48 struct drm_i915_gem_object *obj;
49 49
50 u32 actual_head;
51 u32 head; 50 u32 head;
52 u32 tail; 51 u32 tail;
53 int space; 52 int space;
@@ -167,4 +166,7 @@ int intel_init_blt_ring_buffer(struct drm_device *dev);
167u32 intel_ring_get_active_head(struct intel_ring_buffer *ring); 166u32 intel_ring_get_active_head(struct intel_ring_buffer *ring);
168void intel_ring_setup_status_page(struct intel_ring_buffer *ring); 167void intel_ring_setup_status_page(struct intel_ring_buffer *ring);
169 168
169/* DRI warts */
170int intel_render_ring_init_dri(struct drm_device *dev, u64 start, u32 size);
171
170#endif /* _INTEL_RINGBUFFER_H_ */ 172#endif /* _INTEL_RINGBUFFER_H_ */
diff --git a/drivers/gpu/drm/nouveau/Kconfig b/drivers/gpu/drm/nouveau/Kconfig
index 21d6c29c2d21..de70959b9ed5 100644
--- a/drivers/gpu/drm/nouveau/Kconfig
+++ b/drivers/gpu/drm/nouveau/Kconfig
@@ -8,7 +8,7 @@ config DRM_NOUVEAU
8 select FB_CFB_COPYAREA 8 select FB_CFB_COPYAREA
9 select FB_CFB_IMAGEBLIT 9 select FB_CFB_IMAGEBLIT
10 select FB 10 select FB
11 select FRAMEBUFFER_CONSOLE if !EMBEDDED 11 select FRAMEBUFFER_CONSOLE if !EXPERT
12 select FB_BACKLIGHT if DRM_NOUVEAU_BACKLIGHT 12 select FB_BACKLIGHT if DRM_NOUVEAU_BACKLIGHT
13 select ACPI_VIDEO if ACPI && X86 && BACKLIGHT_CLASS_DEVICE && VIDEO_OUTPUT_CONTROL && INPUT 13 select ACPI_VIDEO if ACPI && X86 && BACKLIGHT_CLASS_DEVICE && VIDEO_OUTPUT_CONTROL && INPUT
14 help 14 help
diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
index 2aef5cd3acf5..49e5e99917e2 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bios.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
@@ -6310,6 +6310,9 @@ void merge_like_dcb_entries(struct drm_device *dev, struct dcb_table *dcb)
6310static bool 6310static bool
6311apply_dcb_encoder_quirks(struct drm_device *dev, int idx, u32 *conn, u32 *conf) 6311apply_dcb_encoder_quirks(struct drm_device *dev, int idx, u32 *conn, u32 *conf)
6312{ 6312{
6313 struct drm_nouveau_private *dev_priv = dev->dev_private;
6314 struct dcb_table *dcb = &dev_priv->vbios.dcb;
6315
6313 /* Dell Precision M6300 6316 /* Dell Precision M6300
6314 * DCB entry 2: 02025312 00000010 6317 * DCB entry 2: 02025312 00000010
6315 * DCB entry 3: 02026312 00000020 6318 * DCB entry 3: 02026312 00000020
@@ -6327,6 +6330,18 @@ apply_dcb_encoder_quirks(struct drm_device *dev, int idx, u32 *conn, u32 *conf)
6327 return false; 6330 return false;
6328 } 6331 }
6329 6332
6333 /* GeForce3 Ti 200
6334 *
6335 * DCB reports an LVDS output that should be TMDS:
6336 * DCB entry 1: f2005014 ffffffff
6337 */
6338 if (nv_match_device(dev, 0x0201, 0x1462, 0x8851)) {
6339 if (*conn == 0xf2005014 && *conf == 0xffffffff) {
6340 fabricate_dcb_output(dcb, OUTPUT_TMDS, 1, 1, 1);
6341 return false;
6342 }
6343 }
6344
6330 return true; 6345 return true;
6331} 6346}
6332 6347
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.c b/drivers/gpu/drm/nouveau/nouveau_drv.c
index 13bb672a16f4..f658a04eecf9 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.c
@@ -234,9 +234,9 @@ nouveau_pci_suspend(struct pci_dev *pdev, pm_message_t pm_state)
234 pci_set_power_state(pdev, PCI_D3hot); 234 pci_set_power_state(pdev, PCI_D3hot);
235 } 235 }
236 236
237 acquire_console_sem(); 237 console_lock();
238 nouveau_fbcon_set_suspend(dev, 1); 238 nouveau_fbcon_set_suspend(dev, 1);
239 release_console_sem(); 239 console_unlock();
240 nouveau_fbcon_restore_accel(dev); 240 nouveau_fbcon_restore_accel(dev);
241 return 0; 241 return 0;
242 242
@@ -359,9 +359,9 @@ nouveau_pci_resume(struct pci_dev *pdev)
359 nv_crtc->lut.depth = 0; 359 nv_crtc->lut.depth = 0;
360 } 360 }
361 361
362 acquire_console_sem(); 362 console_lock();
363 nouveau_fbcon_set_suspend(dev, 0); 363 nouveau_fbcon_set_suspend(dev, 0);
364 release_console_sem(); 364 console_unlock();
365 365
366 nouveau_fbcon_zfill_all(dev); 366 nouveau_fbcon_zfill_all(dev);
367 367
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index 01bffc4412d2..9821fcacc3d2 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -848,9 +848,6 @@ extern void nv10_mem_put_tile_region(struct drm_device *dev,
848 struct nouveau_fence *fence); 848 struct nouveau_fence *fence);
849extern const struct ttm_mem_type_manager_func nouveau_vram_manager; 849extern const struct ttm_mem_type_manager_func nouveau_vram_manager;
850 850
851/* nvc0_vram.c */
852extern const struct ttm_mem_type_manager_func nvc0_vram_manager;
853
854/* nouveau_notifier.c */ 851/* nouveau_notifier.c */
855extern int nouveau_notifier_init_channel(struct nouveau_channel *); 852extern int nouveau_notifier_init_channel(struct nouveau_channel *);
856extern void nouveau_notifier_takedown_channel(struct nouveau_channel *); 853extern void nouveau_notifier_takedown_channel(struct nouveau_channel *);
diff --git a/drivers/gpu/drm/nouveau/nouveau_temp.c b/drivers/gpu/drm/nouveau/nouveau_temp.c
index 7ecc4adc1e45..8d9968e1cba8 100644
--- a/drivers/gpu/drm/nouveau/nouveau_temp.c
+++ b/drivers/gpu/drm/nouveau/nouveau_temp.c
@@ -265,8 +265,8 @@ nouveau_temp_probe_i2c(struct drm_device *dev)
265 struct i2c_board_info info[] = { 265 struct i2c_board_info info[] = {
266 { I2C_BOARD_INFO("w83l785ts", 0x2d) }, 266 { I2C_BOARD_INFO("w83l785ts", 0x2d) },
267 { I2C_BOARD_INFO("w83781d", 0x2d) }, 267 { I2C_BOARD_INFO("w83781d", 0x2d) },
268 { I2C_BOARD_INFO("f75375", 0x2e) },
269 { I2C_BOARD_INFO("adt7473", 0x2e) }, 268 { I2C_BOARD_INFO("adt7473", 0x2e) },
269 { I2C_BOARD_INFO("f75375", 0x2e) },
270 { I2C_BOARD_INFO("lm99", 0x4c) }, 270 { I2C_BOARD_INFO("lm99", 0x4c) },
271 { } 271 { }
272 }; 272 };
diff --git a/drivers/gpu/drm/nouveau/nv50_graph.c b/drivers/gpu/drm/nouveau/nv50_graph.c
index 2d7ea75a09d4..37e21d2be95b 100644
--- a/drivers/gpu/drm/nouveau/nv50_graph.c
+++ b/drivers/gpu/drm/nouveau/nv50_graph.c
@@ -256,6 +256,7 @@ nv50_graph_destroy_context(struct nouveau_channel *chan)
256 struct drm_device *dev = chan->dev; 256 struct drm_device *dev = chan->dev;
257 struct drm_nouveau_private *dev_priv = dev->dev_private; 257 struct drm_nouveau_private *dev_priv = dev->dev_private;
258 struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph; 258 struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
259 struct nouveau_fifo_engine *pfifo = &dev_priv->engine.fifo;
259 int i, hdr = (dev_priv->chipset == 0x50) ? 0x200 : 0x20; 260 int i, hdr = (dev_priv->chipset == 0x50) ? 0x200 : 0x20;
260 unsigned long flags; 261 unsigned long flags;
261 262
@@ -265,6 +266,7 @@ nv50_graph_destroy_context(struct nouveau_channel *chan)
265 return; 266 return;
266 267
267 spin_lock_irqsave(&dev_priv->context_switch_lock, flags); 268 spin_lock_irqsave(&dev_priv->context_switch_lock, flags);
269 pfifo->reassign(dev, false);
268 pgraph->fifo_access(dev, false); 270 pgraph->fifo_access(dev, false);
269 271
270 if (pgraph->channel(dev) == chan) 272 if (pgraph->channel(dev) == chan)
@@ -275,6 +277,7 @@ nv50_graph_destroy_context(struct nouveau_channel *chan)
275 dev_priv->engine.instmem.flush(dev); 277 dev_priv->engine.instmem.flush(dev);
276 278
277 pgraph->fifo_access(dev, true); 279 pgraph->fifo_access(dev, true);
280 pfifo->reassign(dev, true);
278 spin_unlock_irqrestore(&dev_priv->context_switch_lock, flags); 281 spin_unlock_irqrestore(&dev_priv->context_switch_lock, flags);
279 282
280 nouveau_gpuobj_ref(NULL, &chan->ramin_grctx); 283 nouveau_gpuobj_ref(NULL, &chan->ramin_grctx);
diff --git a/drivers/gpu/drm/nouveau/nv50_vm.c b/drivers/gpu/drm/nouveau/nv50_vm.c
index 38e523e10995..459ff08241e5 100644
--- a/drivers/gpu/drm/nouveau/nv50_vm.c
+++ b/drivers/gpu/drm/nouveau/nv50_vm.c
@@ -45,11 +45,6 @@ nv50_vm_map_pgt(struct nouveau_gpuobj *pgd, u32 pde,
45 } 45 }
46 46
47 if (phys & 1) { 47 if (phys & 1) {
48 if (dev_priv->vram_sys_base) {
49 phys += dev_priv->vram_sys_base;
50 phys |= 0x30;
51 }
52
53 if (coverage <= 32 * 1024 * 1024) 48 if (coverage <= 32 * 1024 * 1024)
54 phys |= 0x60; 49 phys |= 0x60;
55 else if (coverage <= 64 * 1024 * 1024) 50 else if (coverage <= 64 * 1024 * 1024)
diff --git a/drivers/gpu/drm/nouveau/nvc0_graph.c b/drivers/gpu/drm/nouveau/nvc0_graph.c
index e6ea7d83187f..eb18a7e89f5b 100644
--- a/drivers/gpu/drm/nouveau/nvc0_graph.c
+++ b/drivers/gpu/drm/nouveau/nvc0_graph.c
@@ -31,6 +31,7 @@
31#include "nvc0_graph.h" 31#include "nvc0_graph.h"
32 32
33static void nvc0_graph_isr(struct drm_device *); 33static void nvc0_graph_isr(struct drm_device *);
34static void nvc0_runk140_isr(struct drm_device *);
34static int nvc0_graph_unload_context_to(struct drm_device *dev, u64 chan); 35static int nvc0_graph_unload_context_to(struct drm_device *dev, u64 chan);
35 36
36void 37void
@@ -281,6 +282,7 @@ nvc0_graph_destroy(struct drm_device *dev)
281 return; 282 return;
282 283
283 nouveau_irq_unregister(dev, 12); 284 nouveau_irq_unregister(dev, 12);
285 nouveau_irq_unregister(dev, 25);
284 286
285 nouveau_gpuobj_ref(NULL, &priv->unk4188b8); 287 nouveau_gpuobj_ref(NULL, &priv->unk4188b8);
286 nouveau_gpuobj_ref(NULL, &priv->unk4188b4); 288 nouveau_gpuobj_ref(NULL, &priv->unk4188b4);
@@ -390,6 +392,7 @@ nvc0_graph_create(struct drm_device *dev)
390 } 392 }
391 393
392 nouveau_irq_register(dev, 12, nvc0_graph_isr); 394 nouveau_irq_register(dev, 12, nvc0_graph_isr);
395 nouveau_irq_register(dev, 25, nvc0_runk140_isr);
393 NVOBJ_CLASS(dev, 0x902d, GR); /* 2D */ 396 NVOBJ_CLASS(dev, 0x902d, GR); /* 2D */
394 NVOBJ_CLASS(dev, 0x9039, GR); /* M2MF */ 397 NVOBJ_CLASS(dev, 0x9039, GR); /* M2MF */
395 NVOBJ_CLASS(dev, 0x9097, GR); /* 3D */ 398 NVOBJ_CLASS(dev, 0x9097, GR); /* 3D */
@@ -512,8 +515,8 @@ nvc0_graph_init_gpc_1(struct drm_device *dev)
512 nv_wr32(dev, TP_UNIT(gpc, tp, 0x224), 0xc0000000); 515 nv_wr32(dev, TP_UNIT(gpc, tp, 0x224), 0xc0000000);
513 nv_wr32(dev, TP_UNIT(gpc, tp, 0x48c), 0xc0000000); 516 nv_wr32(dev, TP_UNIT(gpc, tp, 0x48c), 0xc0000000);
514 nv_wr32(dev, TP_UNIT(gpc, tp, 0x084), 0xc0000000); 517 nv_wr32(dev, TP_UNIT(gpc, tp, 0x084), 0xc0000000);
515 nv_wr32(dev, TP_UNIT(gpc, tp, 0xe44), 0x001ffffe); 518 nv_wr32(dev, TP_UNIT(gpc, tp, 0x644), 0x001ffffe);
516 nv_wr32(dev, TP_UNIT(gpc, tp, 0xe4c), 0x0000000f); 519 nv_wr32(dev, TP_UNIT(gpc, tp, 0x64c), 0x0000000f);
517 } 520 }
518 nv_wr32(dev, GPC_UNIT(gpc, 0x2c90), 0xffffffff); 521 nv_wr32(dev, GPC_UNIT(gpc, 0x2c90), 0xffffffff);
519 nv_wr32(dev, GPC_UNIT(gpc, 0x2c94), 0xffffffff); 522 nv_wr32(dev, GPC_UNIT(gpc, 0x2c94), 0xffffffff);
@@ -777,3 +780,19 @@ nvc0_graph_isr(struct drm_device *dev)
777 780
778 nv_wr32(dev, 0x400500, 0x00010001); 781 nv_wr32(dev, 0x400500, 0x00010001);
779} 782}
783
784static void
785nvc0_runk140_isr(struct drm_device *dev)
786{
787 u32 units = nv_rd32(dev, 0x00017c) & 0x1f;
788
789 while (units) {
790 u32 unit = ffs(units) - 1;
791 u32 reg = 0x140000 + unit * 0x2000;
792 u32 st0 = nv_mask(dev, reg + 0x1020, 0, 0);
793 u32 st1 = nv_mask(dev, reg + 0x1420, 0, 0);
794
795 NV_INFO(dev, "PRUNK140: %d 0x%08x 0x%08x\n", unit, st0, st1);
796 units &= ~(1 << unit);
797 }
798}
diff --git a/drivers/gpu/drm/nouveau/nvc0_grctx.c b/drivers/gpu/drm/nouveau/nvc0_grctx.c
index b9e68b2d30aa..f880ff776db8 100644
--- a/drivers/gpu/drm/nouveau/nvc0_grctx.c
+++ b/drivers/gpu/drm/nouveau/nvc0_grctx.c
@@ -1830,7 +1830,7 @@ nvc0_grctx_generate(struct nouveau_channel *chan)
1830 1830
1831 for (tp = 0, id = 0; tp < 4; tp++) { 1831 for (tp = 0, id = 0; tp < 4; tp++) {
1832 for (gpc = 0; gpc < priv->gpc_nr; gpc++) { 1832 for (gpc = 0; gpc < priv->gpc_nr; gpc++) {
1833 if (tp <= priv->tp_nr[gpc]) { 1833 if (tp < priv->tp_nr[gpc]) {
1834 nv_wr32(dev, TP_UNIT(gpc, tp, 0x698), id); 1834 nv_wr32(dev, TP_UNIT(gpc, tp, 0x698), id);
1835 nv_wr32(dev, TP_UNIT(gpc, tp, 0x4e8), id); 1835 nv_wr32(dev, TP_UNIT(gpc, tp, 0x4e8), id);
1836 nv_wr32(dev, GPC_UNIT(gpc, 0x0c10 + tp * 4), id); 1836 nv_wr32(dev, GPC_UNIT(gpc, 0x0c10 + tp * 4), id);
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index b0ab185b86f6..842954fe74c5 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -606,14 +606,9 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc,
606 args.v1.usPixelClock = cpu_to_le16(mode->clock / 10); 606 args.v1.usPixelClock = cpu_to_le16(mode->clock / 10);
607 args.v1.ucTransmitterID = radeon_encoder->encoder_id; 607 args.v1.ucTransmitterID = radeon_encoder->encoder_id;
608 args.v1.ucEncodeMode = encoder_mode; 608 args.v1.ucEncodeMode = encoder_mode;
609 if (encoder_mode == ATOM_ENCODER_MODE_DP) { 609 if (ss_enabled)
610 if (ss_enabled)
611 args.v1.ucConfig |=
612 ADJUST_DISPLAY_CONFIG_SS_ENABLE;
613 } else if (encoder_mode == ATOM_ENCODER_MODE_LVDS) {
614 args.v1.ucConfig |= 610 args.v1.ucConfig |=
615 ADJUST_DISPLAY_CONFIG_SS_ENABLE; 611 ADJUST_DISPLAY_CONFIG_SS_ENABLE;
616 }
617 612
618 atom_execute_table(rdev->mode_info.atom_context, 613 atom_execute_table(rdev->mode_info.atom_context,
619 index, (uint32_t *)&args); 614 index, (uint32_t *)&args);
@@ -624,12 +619,12 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc,
624 args.v3.sInput.ucTransmitterID = radeon_encoder->encoder_id; 619 args.v3.sInput.ucTransmitterID = radeon_encoder->encoder_id;
625 args.v3.sInput.ucEncodeMode = encoder_mode; 620 args.v3.sInput.ucEncodeMode = encoder_mode;
626 args.v3.sInput.ucDispPllConfig = 0; 621 args.v3.sInput.ucDispPllConfig = 0;
622 if (ss_enabled)
623 args.v3.sInput.ucDispPllConfig |=
624 DISPPLL_CONFIG_SS_ENABLE;
627 if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) { 625 if (radeon_encoder->devices & (ATOM_DEVICE_DFP_SUPPORT)) {
628 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; 626 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
629 if (encoder_mode == ATOM_ENCODER_MODE_DP) { 627 if (encoder_mode == ATOM_ENCODER_MODE_DP) {
630 if (ss_enabled)
631 args.v3.sInput.ucDispPllConfig |=
632 DISPPLL_CONFIG_SS_ENABLE;
633 args.v3.sInput.ucDispPllConfig |= 628 args.v3.sInput.ucDispPllConfig |=
634 DISPPLL_CONFIG_COHERENT_MODE; 629 DISPPLL_CONFIG_COHERENT_MODE;
635 /* 16200 or 27000 */ 630 /* 16200 or 27000 */
@@ -649,18 +644,11 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc,
649 } 644 }
650 } else if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { 645 } else if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
651 if (encoder_mode == ATOM_ENCODER_MODE_DP) { 646 if (encoder_mode == ATOM_ENCODER_MODE_DP) {
652 if (ss_enabled)
653 args.v3.sInput.ucDispPllConfig |=
654 DISPPLL_CONFIG_SS_ENABLE;
655 args.v3.sInput.ucDispPllConfig |= 647 args.v3.sInput.ucDispPllConfig |=
656 DISPPLL_CONFIG_COHERENT_MODE; 648 DISPPLL_CONFIG_COHERENT_MODE;
657 /* 16200 or 27000 */ 649 /* 16200 or 27000 */
658 args.v3.sInput.usPixelClock = cpu_to_le16(dp_clock / 10); 650 args.v3.sInput.usPixelClock = cpu_to_le16(dp_clock / 10);
659 } else if (encoder_mode == ATOM_ENCODER_MODE_LVDS) { 651 } else if (encoder_mode != ATOM_ENCODER_MODE_LVDS) {
660 if (ss_enabled)
661 args.v3.sInput.ucDispPllConfig |=
662 DISPPLL_CONFIG_SS_ENABLE;
663 } else {
664 if (mode->clock > 165000) 652 if (mode->clock > 165000)
665 args.v3.sInput.ucDispPllConfig |= 653 args.v3.sInput.ucDispPllConfig |=
666 DISPPLL_CONFIG_DUAL_LINK; 654 DISPPLL_CONFIG_DUAL_LINK;
@@ -1006,6 +994,7 @@ static int evergreen_crtc_do_set_base(struct drm_crtc *crtc,
1006 struct radeon_bo *rbo; 994 struct radeon_bo *rbo;
1007 uint64_t fb_location; 995 uint64_t fb_location;
1008 uint32_t fb_format, fb_pitch_pixels, tiling_flags; 996 uint32_t fb_format, fb_pitch_pixels, tiling_flags;
997 u32 fb_swap = EVERGREEN_GRPH_ENDIAN_SWAP(EVERGREEN_GRPH_ENDIAN_NONE);
1009 int r; 998 int r;
1010 999
1011 /* no fb bound */ 1000 /* no fb bound */
@@ -1057,11 +1046,17 @@ static int evergreen_crtc_do_set_base(struct drm_crtc *crtc,
1057 case 16: 1046 case 16:
1058 fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_16BPP) | 1047 fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_16BPP) |
1059 EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_ARGB565)); 1048 EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_ARGB565));
1049#ifdef __BIG_ENDIAN
1050 fb_swap = EVERGREEN_GRPH_ENDIAN_SWAP(EVERGREEN_GRPH_ENDIAN_8IN16);
1051#endif
1060 break; 1052 break;
1061 case 24: 1053 case 24:
1062 case 32: 1054 case 32:
1063 fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_32BPP) | 1055 fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_32BPP) |
1064 EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_ARGB8888)); 1056 EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_ARGB8888));
1057#ifdef __BIG_ENDIAN
1058 fb_swap = EVERGREEN_GRPH_ENDIAN_SWAP(EVERGREEN_GRPH_ENDIAN_8IN32);
1059#endif
1065 break; 1060 break;
1066 default: 1061 default:
1067 DRM_ERROR("Unsupported screen depth %d\n", 1062 DRM_ERROR("Unsupported screen depth %d\n",
@@ -1106,6 +1101,7 @@ static int evergreen_crtc_do_set_base(struct drm_crtc *crtc,
1106 WREG32(EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS + radeon_crtc->crtc_offset, 1101 WREG32(EVERGREEN_GRPH_SECONDARY_SURFACE_ADDRESS + radeon_crtc->crtc_offset,
1107 (u32) fb_location & EVERGREEN_GRPH_SURFACE_ADDRESS_MASK); 1102 (u32) fb_location & EVERGREEN_GRPH_SURFACE_ADDRESS_MASK);
1108 WREG32(EVERGREEN_GRPH_CONTROL + radeon_crtc->crtc_offset, fb_format); 1103 WREG32(EVERGREEN_GRPH_CONTROL + radeon_crtc->crtc_offset, fb_format);
1104 WREG32(EVERGREEN_GRPH_SWAP_CONTROL + radeon_crtc->crtc_offset, fb_swap);
1109 1105
1110 WREG32(EVERGREEN_GRPH_SURFACE_OFFSET_X + radeon_crtc->crtc_offset, 0); 1106 WREG32(EVERGREEN_GRPH_SURFACE_OFFSET_X + radeon_crtc->crtc_offset, 0);
1111 WREG32(EVERGREEN_GRPH_SURFACE_OFFSET_Y + radeon_crtc->crtc_offset, 0); 1107 WREG32(EVERGREEN_GRPH_SURFACE_OFFSET_Y + radeon_crtc->crtc_offset, 0);
@@ -1162,6 +1158,7 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
1162 struct drm_framebuffer *target_fb; 1158 struct drm_framebuffer *target_fb;
1163 uint64_t fb_location; 1159 uint64_t fb_location;
1164 uint32_t fb_format, fb_pitch_pixels, tiling_flags; 1160 uint32_t fb_format, fb_pitch_pixels, tiling_flags;
1161 u32 fb_swap = R600_D1GRPH_SWAP_ENDIAN_NONE;
1165 int r; 1162 int r;
1166 1163
1167 /* no fb bound */ 1164 /* no fb bound */
@@ -1215,12 +1212,18 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
1215 fb_format = 1212 fb_format =
1216 AVIVO_D1GRPH_CONTROL_DEPTH_16BPP | 1213 AVIVO_D1GRPH_CONTROL_DEPTH_16BPP |
1217 AVIVO_D1GRPH_CONTROL_16BPP_RGB565; 1214 AVIVO_D1GRPH_CONTROL_16BPP_RGB565;
1215#ifdef __BIG_ENDIAN
1216 fb_swap = R600_D1GRPH_SWAP_ENDIAN_16BIT;
1217#endif
1218 break; 1218 break;
1219 case 24: 1219 case 24:
1220 case 32: 1220 case 32:
1221 fb_format = 1221 fb_format =
1222 AVIVO_D1GRPH_CONTROL_DEPTH_32BPP | 1222 AVIVO_D1GRPH_CONTROL_DEPTH_32BPP |
1223 AVIVO_D1GRPH_CONTROL_32BPP_ARGB8888; 1223 AVIVO_D1GRPH_CONTROL_32BPP_ARGB8888;
1224#ifdef __BIG_ENDIAN
1225 fb_swap = R600_D1GRPH_SWAP_ENDIAN_32BIT;
1226#endif
1224 break; 1227 break;
1225 default: 1228 default:
1226 DRM_ERROR("Unsupported screen depth %d\n", 1229 DRM_ERROR("Unsupported screen depth %d\n",
@@ -1260,6 +1263,8 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
1260 WREG32(AVIVO_D1GRPH_SECONDARY_SURFACE_ADDRESS + 1263 WREG32(AVIVO_D1GRPH_SECONDARY_SURFACE_ADDRESS +
1261 radeon_crtc->crtc_offset, (u32) fb_location); 1264 radeon_crtc->crtc_offset, (u32) fb_location);
1262 WREG32(AVIVO_D1GRPH_CONTROL + radeon_crtc->crtc_offset, fb_format); 1265 WREG32(AVIVO_D1GRPH_CONTROL + radeon_crtc->crtc_offset, fb_format);
1266 if (rdev->family >= CHIP_R600)
1267 WREG32(R600_D1GRPH_SWAP_CONTROL + radeon_crtc->crtc_offset, fb_swap);
1263 1268
1264 WREG32(AVIVO_D1GRPH_SURFACE_OFFSET_X + radeon_crtc->crtc_offset, 0); 1269 WREG32(AVIVO_D1GRPH_SURFACE_OFFSET_X + radeon_crtc->crtc_offset, 0);
1265 WREG32(AVIVO_D1GRPH_SURFACE_OFFSET_Y + radeon_crtc->crtc_offset, 0); 1270 WREG32(AVIVO_D1GRPH_SURFACE_OFFSET_Y + radeon_crtc->crtc_offset, 0);
diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c
index 4e7778d44b8d..695de9a38506 100644
--- a/drivers/gpu/drm/radeon/atombios_dp.c
+++ b/drivers/gpu/drm/radeon/atombios_dp.c
@@ -187,9 +187,9 @@ static int dp_link_clock_for_mode_clock(u8 dpcd[DP_DPCD_SIZE], int mode_clock)
187int dp_mode_valid(u8 dpcd[DP_DPCD_SIZE], int mode_clock) 187int dp_mode_valid(u8 dpcd[DP_DPCD_SIZE], int mode_clock)
188{ 188{
189 int lanes = dp_lanes_for_mode_clock(dpcd, mode_clock); 189 int lanes = dp_lanes_for_mode_clock(dpcd, mode_clock);
190 int bw = dp_lanes_for_mode_clock(dpcd, mode_clock); 190 int dp_clock = dp_link_clock_for_mode_clock(dpcd, mode_clock);
191 191
192 if ((lanes == 0) || (bw == 0)) 192 if ((lanes == 0) || (dp_clock == 0))
193 return MODE_CLOCK_HIGH; 193 return MODE_CLOCK_HIGH;
194 194
195 return MODE_OK; 195 return MODE_OK;
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index a8973acb3987..677af91b555c 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -2201,6 +2201,9 @@ static int evergreen_gpu_soft_reset(struct radeon_device *rdev)
2201 struct evergreen_mc_save save; 2201 struct evergreen_mc_save save;
2202 u32 grbm_reset = 0; 2202 u32 grbm_reset = 0;
2203 2203
2204 if (!(RREG32(GRBM_STATUS) & GUI_ACTIVE))
2205 return 0;
2206
2204 dev_info(rdev->dev, "GPU softreset \n"); 2207 dev_info(rdev->dev, "GPU softreset \n");
2205 dev_info(rdev->dev, " GRBM_STATUS=0x%08X\n", 2208 dev_info(rdev->dev, " GRBM_STATUS=0x%08X\n",
2206 RREG32(GRBM_STATUS)); 2209 RREG32(GRBM_STATUS));
diff --git a/drivers/gpu/drm/radeon/evergreen_blit_kms.c b/drivers/gpu/drm/radeon/evergreen_blit_kms.c
index b758dc7f2f2c..d4d4db49a8b8 100644
--- a/drivers/gpu/drm/radeon/evergreen_blit_kms.c
+++ b/drivers/gpu/drm/radeon/evergreen_blit_kms.c
@@ -232,7 +232,7 @@ draw_auto(struct radeon_device *rdev)
232 232
233} 233}
234 234
235/* emits 30 */ 235/* emits 34 */
236static void 236static void
237set_default_state(struct radeon_device *rdev) 237set_default_state(struct radeon_device *rdev)
238{ 238{
@@ -245,6 +245,8 @@ set_default_state(struct radeon_device *rdev)
245 int num_hs_threads, num_ls_threads; 245 int num_hs_threads, num_ls_threads;
246 int num_ps_stack_entries, num_vs_stack_entries, num_gs_stack_entries, num_es_stack_entries; 246 int num_ps_stack_entries, num_vs_stack_entries, num_gs_stack_entries, num_es_stack_entries;
247 int num_hs_stack_entries, num_ls_stack_entries; 247 int num_hs_stack_entries, num_ls_stack_entries;
248 u64 gpu_addr;
249 int dwords;
248 250
249 switch (rdev->family) { 251 switch (rdev->family) {
250 case CHIP_CEDAR: 252 case CHIP_CEDAR:
@@ -497,6 +499,14 @@ set_default_state(struct radeon_device *rdev)
497 radeon_ring_write(rdev, 0x00000000); 499 radeon_ring_write(rdev, 0x00000000);
498 radeon_ring_write(rdev, 0x00000000); 500 radeon_ring_write(rdev, 0x00000000);
499 501
502 /* emit an IB pointing at default state */
503 dwords = ALIGN(rdev->r600_blit.state_len, 0x10);
504 gpu_addr = rdev->r600_blit.shader_gpu_addr + rdev->r600_blit.state_offset;
505 radeon_ring_write(rdev, PACKET3(PACKET3_INDIRECT_BUFFER, 2));
506 radeon_ring_write(rdev, gpu_addr & 0xFFFFFFFC);
507 radeon_ring_write(rdev, upper_32_bits(gpu_addr) & 0xFF);
508 radeon_ring_write(rdev, dwords);
509
500} 510}
501 511
502static inline uint32_t i2f(uint32_t input) 512static inline uint32_t i2f(uint32_t input)
@@ -527,8 +537,10 @@ static inline uint32_t i2f(uint32_t input)
527int evergreen_blit_init(struct radeon_device *rdev) 537int evergreen_blit_init(struct radeon_device *rdev)
528{ 538{
529 u32 obj_size; 539 u32 obj_size;
530 int r; 540 int r, dwords;
531 void *ptr; 541 void *ptr;
542 u32 packet2s[16];
543 int num_packet2s = 0;
532 544
533 /* pin copy shader into vram if already initialized */ 545 /* pin copy shader into vram if already initialized */
534 if (rdev->r600_blit.shader_obj) 546 if (rdev->r600_blit.shader_obj)
@@ -536,8 +548,17 @@ int evergreen_blit_init(struct radeon_device *rdev)
536 548
537 mutex_init(&rdev->r600_blit.mutex); 549 mutex_init(&rdev->r600_blit.mutex);
538 rdev->r600_blit.state_offset = 0; 550 rdev->r600_blit.state_offset = 0;
539 rdev->r600_blit.state_len = 0; 551
540 obj_size = 0; 552 rdev->r600_blit.state_len = evergreen_default_size;
553
554 dwords = rdev->r600_blit.state_len;
555 while (dwords & 0xf) {
556 packet2s[num_packet2s++] = PACKET2(0);
557 dwords++;
558 }
559
560 obj_size = dwords * 4;
561 obj_size = ALIGN(obj_size, 256);
541 562
542 rdev->r600_blit.vs_offset = obj_size; 563 rdev->r600_blit.vs_offset = obj_size;
543 obj_size += evergreen_vs_size * 4; 564 obj_size += evergreen_vs_size * 4;
@@ -567,6 +588,12 @@ int evergreen_blit_init(struct radeon_device *rdev)
567 return r; 588 return r;
568 } 589 }
569 590
591 memcpy_toio(ptr + rdev->r600_blit.state_offset,
592 evergreen_default_state, rdev->r600_blit.state_len * 4);
593
594 if (num_packet2s)
595 memcpy_toio(ptr + rdev->r600_blit.state_offset + (rdev->r600_blit.state_len * 4),
596 packet2s, num_packet2s * 4);
570 memcpy(ptr + rdev->r600_blit.vs_offset, evergreen_vs, evergreen_vs_size * 4); 597 memcpy(ptr + rdev->r600_blit.vs_offset, evergreen_vs, evergreen_vs_size * 4);
571 memcpy(ptr + rdev->r600_blit.ps_offset, evergreen_ps, evergreen_ps_size * 4); 598 memcpy(ptr + rdev->r600_blit.ps_offset, evergreen_ps, evergreen_ps_size * 4);
572 radeon_bo_kunmap(rdev->r600_blit.shader_obj); 599 radeon_bo_kunmap(rdev->r600_blit.shader_obj);
@@ -652,7 +679,7 @@ int evergreen_blit_prepare_copy(struct radeon_device *rdev, int size_bytes)
652 /* calculate number of loops correctly */ 679 /* calculate number of loops correctly */
653 ring_size = num_loops * dwords_per_loop; 680 ring_size = num_loops * dwords_per_loop;
654 /* set default + shaders */ 681 /* set default + shaders */
655 ring_size += 46; /* shaders + def state */ 682 ring_size += 50; /* shaders + def state */
656 ring_size += 10; /* fence emit for VB IB */ 683 ring_size += 10; /* fence emit for VB IB */
657 ring_size += 5; /* done copy */ 684 ring_size += 5; /* done copy */
658 ring_size += 10; /* fence emit for done copy */ 685 ring_size += 10; /* fence emit for done copy */
@@ -660,7 +687,7 @@ int evergreen_blit_prepare_copy(struct radeon_device *rdev, int size_bytes)
660 if (r) 687 if (r)
661 return r; 688 return r;
662 689
663 set_default_state(rdev); /* 30 */ 690 set_default_state(rdev); /* 34 */
664 set_shaders(rdev); /* 16 */ 691 set_shaders(rdev); /* 16 */
665 return 0; 692 return 0;
666} 693}
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index 46da5142b131..5f15820efe12 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -1031,8 +1031,8 @@ int r100_cp_init(struct radeon_device *rdev, unsigned ring_size)
1031 WREG32(RADEON_CP_CSQ_MODE, 1031 WREG32(RADEON_CP_CSQ_MODE,
1032 REG_SET(RADEON_INDIRECT2_START, indirect2_start) | 1032 REG_SET(RADEON_INDIRECT2_START, indirect2_start) |
1033 REG_SET(RADEON_INDIRECT1_START, indirect1_start)); 1033 REG_SET(RADEON_INDIRECT1_START, indirect1_start));
1034 WREG32(0x718, 0); 1034 WREG32(RADEON_CP_RB_WPTR_DELAY, 0);
1035 WREG32(0x744, 0x00004D4D); 1035 WREG32(RADEON_CP_CSQ_MODE, 0x00004D4D);
1036 WREG32(RADEON_CP_CSQ_CNTL, RADEON_CSQ_PRIBM_INDBM); 1036 WREG32(RADEON_CP_CSQ_CNTL, RADEON_CSQ_PRIBM_INDBM);
1037 radeon_ring_start(rdev); 1037 radeon_ring_start(rdev);
1038 r = radeon_ring_test(rdev); 1038 r = radeon_ring_test(rdev);
@@ -2347,10 +2347,10 @@ void r100_vga_set_state(struct radeon_device *rdev, bool state)
2347 2347
2348 temp = RREG32(RADEON_CONFIG_CNTL); 2348 temp = RREG32(RADEON_CONFIG_CNTL);
2349 if (state == false) { 2349 if (state == false) {
2350 temp &= ~(1<<8); 2350 temp &= ~RADEON_CFG_VGA_RAM_EN;
2351 temp |= (1<<9); 2351 temp |= RADEON_CFG_VGA_IO_DIS;
2352 } else { 2352 } else {
2353 temp &= ~(1<<9); 2353 temp &= ~RADEON_CFG_VGA_IO_DIS;
2354 } 2354 }
2355 WREG32(RADEON_CONFIG_CNTL, temp); 2355 WREG32(RADEON_CONFIG_CNTL, temp);
2356} 2356}
@@ -3522,7 +3522,7 @@ int r100_ring_test(struct radeon_device *rdev)
3522 if (i < rdev->usec_timeout) { 3522 if (i < rdev->usec_timeout) {
3523 DRM_INFO("ring test succeeded in %d usecs\n", i); 3523 DRM_INFO("ring test succeeded in %d usecs\n", i);
3524 } else { 3524 } else {
3525 DRM_ERROR("radeon: ring test failed (sracth(0x%04X)=0x%08X)\n", 3525 DRM_ERROR("radeon: ring test failed (scratch(0x%04X)=0x%08X)\n",
3526 scratch, tmp); 3526 scratch, tmp);
3527 r = -EINVAL; 3527 r = -EINVAL;
3528 } 3528 }
diff --git a/drivers/gpu/drm/radeon/r300.c b/drivers/gpu/drm/radeon/r300.c
index cf862ca580bf..55fe5ba7def3 100644
--- a/drivers/gpu/drm/radeon/r300.c
+++ b/drivers/gpu/drm/radeon/r300.c
@@ -69,6 +69,9 @@ void rv370_pcie_gart_tlb_flush(struct radeon_device *rdev)
69 mb(); 69 mb();
70} 70}
71 71
72#define R300_PTE_WRITEABLE (1 << 2)
73#define R300_PTE_READABLE (1 << 3)
74
72int rv370_pcie_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr) 75int rv370_pcie_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr)
73{ 76{
74 void __iomem *ptr = (void *)rdev->gart.table.vram.ptr; 77 void __iomem *ptr = (void *)rdev->gart.table.vram.ptr;
@@ -78,7 +81,7 @@ int rv370_pcie_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr)
78 } 81 }
79 addr = (lower_32_bits(addr) >> 8) | 82 addr = (lower_32_bits(addr) >> 8) |
80 ((upper_32_bits(addr) & 0xff) << 24) | 83 ((upper_32_bits(addr) & 0xff) << 24) |
81 0xc; 84 R300_PTE_WRITEABLE | R300_PTE_READABLE;
82 /* on x86 we want this to be CPU endian, on powerpc 85 /* on x86 we want this to be CPU endian, on powerpc
83 * on powerpc without HW swappers, it'll get swapped on way 86 * on powerpc without HW swappers, it'll get swapped on way
84 * into VRAM - so no need for cpu_to_le32 on VRAM tables */ 87 * into VRAM - so no need for cpu_to_le32 on VRAM tables */
@@ -135,7 +138,7 @@ int rv370_pcie_gart_enable(struct radeon_device *rdev)
135 WREG32_PCIE(RADEON_PCIE_TX_DISCARD_RD_ADDR_LO, rdev->mc.vram_start); 138 WREG32_PCIE(RADEON_PCIE_TX_DISCARD_RD_ADDR_LO, rdev->mc.vram_start);
136 WREG32_PCIE(RADEON_PCIE_TX_DISCARD_RD_ADDR_HI, 0); 139 WREG32_PCIE(RADEON_PCIE_TX_DISCARD_RD_ADDR_HI, 0);
137 /* Clear error */ 140 /* Clear error */
138 WREG32_PCIE(0x18, 0); 141 WREG32_PCIE(RADEON_PCIE_TX_GART_ERROR, 0);
139 tmp = RREG32_PCIE(RADEON_PCIE_TX_GART_CNTL); 142 tmp = RREG32_PCIE(RADEON_PCIE_TX_GART_CNTL);
140 tmp |= RADEON_PCIE_TX_GART_EN; 143 tmp |= RADEON_PCIE_TX_GART_EN;
141 tmp |= RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_DISCARD; 144 tmp |= RADEON_PCIE_TX_GART_UNMAPPED_ACCESS_DISCARD;
diff --git a/drivers/gpu/drm/radeon/r420.c b/drivers/gpu/drm/radeon/r420.c
index c387346f93a9..0b59ed7c7d2c 100644
--- a/drivers/gpu/drm/radeon/r420.c
+++ b/drivers/gpu/drm/radeon/r420.c
@@ -96,7 +96,7 @@ void r420_pipes_init(struct radeon_device *rdev)
96 "programming pipes. Bad things might happen.\n"); 96 "programming pipes. Bad things might happen.\n");
97 } 97 }
98 /* get max number of pipes */ 98 /* get max number of pipes */
99 gb_pipe_select = RREG32(0x402C); 99 gb_pipe_select = RREG32(R400_GB_PIPE_SELECT);
100 num_pipes = ((gb_pipe_select >> 12) & 3) + 1; 100 num_pipes = ((gb_pipe_select >> 12) & 3) + 1;
101 101
102 /* SE chips have 1 pipe */ 102 /* SE chips have 1 pipe */
diff --git a/drivers/gpu/drm/radeon/r520.c b/drivers/gpu/drm/radeon/r520.c
index 3c8677f9e385..2ce80d976568 100644
--- a/drivers/gpu/drm/radeon/r520.c
+++ b/drivers/gpu/drm/radeon/r520.c
@@ -79,8 +79,8 @@ static void r520_gpu_init(struct radeon_device *rdev)
79 WREG32(0x4128, 0xFF); 79 WREG32(0x4128, 0xFF);
80 } 80 }
81 r420_pipes_init(rdev); 81 r420_pipes_init(rdev);
82 gb_pipe_select = RREG32(0x402C); 82 gb_pipe_select = RREG32(R400_GB_PIPE_SELECT);
83 tmp = RREG32(0x170C); 83 tmp = RREG32(R300_DST_PIPE_CONFIG);
84 pipe_select_current = (tmp >> 2) & 3; 84 pipe_select_current = (tmp >> 2) & 3;
85 tmp = (1 << pipe_select_current) | 85 tmp = (1 << pipe_select_current) |
86 (((gb_pipe_select >> 8) & 0xF) << 4); 86 (((gb_pipe_select >> 8) & 0xF) << 4);
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index aca2236268fa..1e10e3e2ba2a 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -1287,6 +1287,9 @@ int r600_gpu_soft_reset(struct radeon_device *rdev)
1287 S_008014_CB2_BUSY(1) | S_008014_CB3_BUSY(1); 1287 S_008014_CB2_BUSY(1) | S_008014_CB3_BUSY(1);
1288 u32 tmp; 1288 u32 tmp;
1289 1289
1290 if (!(RREG32(GRBM_STATUS) & GUI_ACTIVE))
1291 return 0;
1292
1290 dev_info(rdev->dev, "GPU softreset \n"); 1293 dev_info(rdev->dev, "GPU softreset \n");
1291 dev_info(rdev->dev, " R_008010_GRBM_STATUS=0x%08X\n", 1294 dev_info(rdev->dev, " R_008010_GRBM_STATUS=0x%08X\n",
1292 RREG32(R_008010_GRBM_STATUS)); 1295 RREG32(R_008010_GRBM_STATUS));
diff --git a/drivers/gpu/drm/radeon/r600_reg.h b/drivers/gpu/drm/radeon/r600_reg.h
index 33cda016b083..f869897c7456 100644
--- a/drivers/gpu/drm/radeon/r600_reg.h
+++ b/drivers/gpu/drm/radeon/r600_reg.h
@@ -81,7 +81,11 @@
81#define R600_MEDIUM_VID_LOWER_GPIO_CNTL 0x720 81#define R600_MEDIUM_VID_LOWER_GPIO_CNTL 0x720
82#define R600_LOW_VID_LOWER_GPIO_CNTL 0x724 82#define R600_LOW_VID_LOWER_GPIO_CNTL 0x724
83 83
84 84#define R600_D1GRPH_SWAP_CONTROL 0x610C
85# define R600_D1GRPH_SWAP_ENDIAN_NONE (0 << 0)
86# define R600_D1GRPH_SWAP_ENDIAN_16BIT (1 << 0)
87# define R600_D1GRPH_SWAP_ENDIAN_32BIT (2 << 0)
88# define R600_D1GRPH_SWAP_ENDIAN_64BIT (3 << 0)
85 89
86#define R600_HDP_NONSURFACE_BASE 0x2c04 90#define R600_HDP_NONSURFACE_BASE 0x2c04
87 91
diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c
index 1573202a6418..52777902bbcc 100644
--- a/drivers/gpu/drm/radeon/radeon_atombios.c
+++ b/drivers/gpu/drm/radeon/radeon_atombios.c
@@ -387,15 +387,11 @@ static bool radeon_atom_apply_quirks(struct drm_device *dev,
387 *line_mux = 0x90; 387 *line_mux = 0x90;
388 } 388 }
389 389
390 /* mac rv630 */ 390 /* mac rv630, rv730, others */
391 if ((dev->pdev->device == 0x9588) && 391 if ((supported_device == ATOM_DEVICE_TV1_SUPPORT) &&
392 (dev->pdev->subsystem_vendor == 0x106b) && 392 (*connector_type == DRM_MODE_CONNECTOR_DVII)) {
393 (dev->pdev->subsystem_device == 0x00a6)) { 393 *connector_type = DRM_MODE_CONNECTOR_9PinDIN;
394 if ((supported_device == ATOM_DEVICE_TV1_SUPPORT) && 394 *line_mux = CONNECTOR_7PIN_DIN_ENUM_ID1;
395 (*connector_type == DRM_MODE_CONNECTOR_DVII)) {
396 *connector_type = DRM_MODE_CONNECTOR_9PinDIN;
397 *line_mux = CONNECTOR_7PIN_DIN_ENUM_ID1;
398 }
399 } 395 }
400 396
401 /* ASUS HD 3600 XT board lists the DVI port as HDMI */ 397 /* ASUS HD 3600 XT board lists the DVI port as HDMI */
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index 26091d602b84..0d478932b1a9 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -891,9 +891,9 @@ int radeon_suspend_kms(struct drm_device *dev, pm_message_t state)
891 pci_disable_device(dev->pdev); 891 pci_disable_device(dev->pdev);
892 pci_set_power_state(dev->pdev, PCI_D3hot); 892 pci_set_power_state(dev->pdev, PCI_D3hot);
893 } 893 }
894 acquire_console_sem(); 894 console_lock();
895 radeon_fbdev_set_suspend(rdev, 1); 895 radeon_fbdev_set_suspend(rdev, 1);
896 release_console_sem(); 896 console_unlock();
897 return 0; 897 return 0;
898} 898}
899 899
@@ -905,11 +905,11 @@ int radeon_resume_kms(struct drm_device *dev)
905 if (dev->switch_power_state == DRM_SWITCH_POWER_OFF) 905 if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
906 return 0; 906 return 0;
907 907
908 acquire_console_sem(); 908 console_lock();
909 pci_set_power_state(dev->pdev, PCI_D0); 909 pci_set_power_state(dev->pdev, PCI_D0);
910 pci_restore_state(dev->pdev); 910 pci_restore_state(dev->pdev);
911 if (pci_enable_device(dev->pdev)) { 911 if (pci_enable_device(dev->pdev)) {
912 release_console_sem(); 912 console_unlock();
913 return -1; 913 return -1;
914 } 914 }
915 pci_set_master(dev->pdev); 915 pci_set_master(dev->pdev);
@@ -920,7 +920,7 @@ int radeon_resume_kms(struct drm_device *dev)
920 radeon_restore_bios_scratch_regs(rdev); 920 radeon_restore_bios_scratch_regs(rdev);
921 921
922 radeon_fbdev_set_suspend(rdev, 0); 922 radeon_fbdev_set_suspend(rdev, 0);
923 release_console_sem(); 923 console_unlock();
924 924
925 /* reset hpd state */ 925 /* reset hpd state */
926 radeon_hpd_init(rdev); 926 radeon_hpd_init(rdev);
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index d5680a0c87af..275b26a708d6 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -48,7 +48,7 @@
48 * - 2.5.0 - add get accel 2 to work around ddx breakage for evergreen 48 * - 2.5.0 - add get accel 2 to work around ddx breakage for evergreen
49 * - 2.6.0 - add tiling config query (r6xx+), add initial HiZ support (r300->r500) 49 * - 2.6.0 - add tiling config query (r6xx+), add initial HiZ support (r300->r500)
50 * 2.7.0 - fixups for r600 2D tiling support. (no external ABI change), add eg dyn gpr regs 50 * 2.7.0 - fixups for r600 2D tiling support. (no external ABI change), add eg dyn gpr regs
51 * 2.8.0 - pageflip support, r500 US_FORMAT regs. r500 ARGB2101010 colorbuf, r300->r500 CMASK 51 * 2.8.0 - pageflip support, r500 US_FORMAT regs. r500 ARGB2101010 colorbuf, r300->r500 CMASK, clock crystal query
52 */ 52 */
53#define KMS_DRIVER_MAJOR 2 53#define KMS_DRIVER_MAJOR 2
54#define KMS_DRIVER_MINOR 8 54#define KMS_DRIVER_MINOR 8
diff --git a/drivers/gpu/drm/radeon/radeon_encoders.c b/drivers/gpu/drm/radeon/radeon_encoders.c
index 8fd184286c0b..5e90984d5ad2 100644
--- a/drivers/gpu/drm/radeon/radeon_encoders.c
+++ b/drivers/gpu/drm/radeon/radeon_encoders.c
@@ -641,7 +641,7 @@ atombios_get_encoder_mode(struct drm_encoder *encoder)
641 switch (connector->connector_type) { 641 switch (connector->connector_type) {
642 case DRM_MODE_CONNECTOR_DVII: 642 case DRM_MODE_CONNECTOR_DVII:
643 case DRM_MODE_CONNECTOR_HDMIB: /* HDMI-B is basically DL-DVI; analog works fine */ 643 case DRM_MODE_CONNECTOR_HDMIB: /* HDMI-B is basically DL-DVI; analog works fine */
644 if (drm_detect_monitor_audio(radeon_connector->edid)) { 644 if (drm_detect_monitor_audio(radeon_connector->edid) && radeon_audio) {
645 /* fix me */ 645 /* fix me */
646 if (ASIC_IS_DCE4(rdev)) 646 if (ASIC_IS_DCE4(rdev))
647 return ATOM_ENCODER_MODE_DVI; 647 return ATOM_ENCODER_MODE_DVI;
@@ -655,7 +655,7 @@ atombios_get_encoder_mode(struct drm_encoder *encoder)
655 case DRM_MODE_CONNECTOR_DVID: 655 case DRM_MODE_CONNECTOR_DVID:
656 case DRM_MODE_CONNECTOR_HDMIA: 656 case DRM_MODE_CONNECTOR_HDMIA:
657 default: 657 default:
658 if (drm_detect_monitor_audio(radeon_connector->edid)) { 658 if (drm_detect_monitor_audio(radeon_connector->edid) && radeon_audio) {
659 /* fix me */ 659 /* fix me */
660 if (ASIC_IS_DCE4(rdev)) 660 if (ASIC_IS_DCE4(rdev))
661 return ATOM_ENCODER_MODE_DVI; 661 return ATOM_ENCODER_MODE_DVI;
@@ -673,7 +673,7 @@ atombios_get_encoder_mode(struct drm_encoder *encoder)
673 if ((dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) || 673 if ((dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) ||
674 (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP)) 674 (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP))
675 return ATOM_ENCODER_MODE_DP; 675 return ATOM_ENCODER_MODE_DP;
676 else if (drm_detect_monitor_audio(radeon_connector->edid)) { 676 else if (drm_detect_monitor_audio(radeon_connector->edid) && radeon_audio) {
677 /* fix me */ 677 /* fix me */
678 if (ASIC_IS_DCE4(rdev)) 678 if (ASIC_IS_DCE4(rdev))
679 return ATOM_ENCODER_MODE_DVI; 679 return ATOM_ENCODER_MODE_DVI;
diff --git a/drivers/gpu/drm/radeon/radeon_irq_kms.c b/drivers/gpu/drm/radeon/radeon_irq_kms.c
index a289646e8aa4..9ec830c77af0 100644
--- a/drivers/gpu/drm/radeon/radeon_irq_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_irq_kms.c
@@ -110,11 +110,14 @@ void radeon_driver_irq_uninstall_kms(struct drm_device *dev)
110 110
111int radeon_irq_kms_init(struct radeon_device *rdev) 111int radeon_irq_kms_init(struct radeon_device *rdev)
112{ 112{
113 int i;
113 int r = 0; 114 int r = 0;
114 115
115 INIT_WORK(&rdev->hotplug_work, radeon_hotplug_work_func); 116 INIT_WORK(&rdev->hotplug_work, radeon_hotplug_work_func);
116 117
117 spin_lock_init(&rdev->irq.sw_lock); 118 spin_lock_init(&rdev->irq.sw_lock);
119 for (i = 0; i < rdev->num_crtc; i++)
120 spin_lock_init(&rdev->irq.pflip_lock[i]);
118 r = drm_vblank_init(rdev->ddev, rdev->num_crtc); 121 r = drm_vblank_init(rdev->ddev, rdev->num_crtc);
119 if (r) { 122 if (r) {
120 return r; 123 return r;
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
index 28a53e4a925f..8387d32caaa7 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -201,6 +201,10 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
201 } 201 }
202 radeon_set_filp_rights(dev, &rdev->cmask_filp, filp, &value); 202 radeon_set_filp_rights(dev, &rdev->cmask_filp, filp, &value);
203 break; 203 break;
204 case RADEON_INFO_CLOCK_CRYSTAL_FREQ:
205 /* return clock value in KHz */
206 value = rdev->clock.spll.reference_freq * 10;
207 break;
204 default: 208 default:
205 DRM_DEBUG_KMS("Invalid request %d\n", info->request); 209 DRM_DEBUG_KMS("Invalid request %d\n", info->request);
206 return -EINVAL; 210 return -EINVAL;
@@ -243,6 +247,8 @@ void radeon_driver_preclose_kms(struct drm_device *dev,
243 struct radeon_device *rdev = dev->dev_private; 247 struct radeon_device *rdev = dev->dev_private;
244 if (rdev->hyperz_filp == file_priv) 248 if (rdev->hyperz_filp == file_priv)
245 rdev->hyperz_filp = NULL; 249 rdev->hyperz_filp = NULL;
250 if (rdev->cmask_filp == file_priv)
251 rdev->cmask_filp = NULL;
246} 252}
247 253
248/* 254/*
diff --git a/drivers/gpu/drm/radeon/radeon_reg.h b/drivers/gpu/drm/radeon/radeon_reg.h
index 3cd4dace57c7..ec93a75369e6 100644
--- a/drivers/gpu/drm/radeon/radeon_reg.h
+++ b/drivers/gpu/drm/radeon/radeon_reg.h
@@ -375,6 +375,8 @@
375#define RADEON_CONFIG_APER_SIZE 0x0108 375#define RADEON_CONFIG_APER_SIZE 0x0108
376#define RADEON_CONFIG_BONDS 0x00e8 376#define RADEON_CONFIG_BONDS 0x00e8
377#define RADEON_CONFIG_CNTL 0x00e0 377#define RADEON_CONFIG_CNTL 0x00e0
378# define RADEON_CFG_VGA_RAM_EN (1 << 8)
379# define RADEON_CFG_VGA_IO_DIS (1 << 9)
378# define RADEON_CFG_ATI_REV_A11 (0 << 16) 380# define RADEON_CFG_ATI_REV_A11 (0 << 16)
379# define RADEON_CFG_ATI_REV_A12 (1 << 16) 381# define RADEON_CFG_ATI_REV_A12 (1 << 16)
380# define RADEON_CFG_ATI_REV_A13 (2 << 16) 382# define RADEON_CFG_ATI_REV_A13 (2 << 16)
diff --git a/drivers/gpu/drm/radeon/rs400.c b/drivers/gpu/drm/radeon/rs400.c
index 5512e4e5e636..c76283d9eb3d 100644
--- a/drivers/gpu/drm/radeon/rs400.c
+++ b/drivers/gpu/drm/radeon/rs400.c
@@ -203,6 +203,9 @@ void rs400_gart_fini(struct radeon_device *rdev)
203 radeon_gart_table_ram_free(rdev); 203 radeon_gart_table_ram_free(rdev);
204} 204}
205 205
206#define RS400_PTE_WRITEABLE (1 << 2)
207#define RS400_PTE_READABLE (1 << 3)
208
206int rs400_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr) 209int rs400_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr)
207{ 210{
208 uint32_t entry; 211 uint32_t entry;
@@ -213,7 +216,7 @@ int rs400_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr)
213 216
214 entry = (lower_32_bits(addr) & PAGE_MASK) | 217 entry = (lower_32_bits(addr) & PAGE_MASK) |
215 ((upper_32_bits(addr) & 0xff) << 4) | 218 ((upper_32_bits(addr) & 0xff) << 4) |
216 0xc; 219 RS400_PTE_WRITEABLE | RS400_PTE_READABLE;
217 entry = cpu_to_le32(entry); 220 entry = cpu_to_le32(entry);
218 rdev->gart.table.ram.ptr[i] = entry; 221 rdev->gart.table.ram.ptr[i] = entry;
219 return 0; 222 return 0;
@@ -226,8 +229,8 @@ int rs400_mc_wait_for_idle(struct radeon_device *rdev)
226 229
227 for (i = 0; i < rdev->usec_timeout; i++) { 230 for (i = 0; i < rdev->usec_timeout; i++) {
228 /* read MC_STATUS */ 231 /* read MC_STATUS */
229 tmp = RREG32(0x0150); 232 tmp = RREG32(RADEON_MC_STATUS);
230 if (tmp & (1 << 2)) { 233 if (tmp & RADEON_MC_IDLE) {
231 return 0; 234 return 0;
232 } 235 }
233 DRM_UDELAY(1); 236 DRM_UDELAY(1);
@@ -241,7 +244,7 @@ void rs400_gpu_init(struct radeon_device *rdev)
241 r420_pipes_init(rdev); 244 r420_pipes_init(rdev);
242 if (rs400_mc_wait_for_idle(rdev)) { 245 if (rs400_mc_wait_for_idle(rdev)) {
243 printk(KERN_WARNING "rs400: Failed to wait MC idle while " 246 printk(KERN_WARNING "rs400: Failed to wait MC idle while "
244 "programming pipes. Bad things might happen. %08x\n", RREG32(0x150)); 247 "programming pipes. Bad things might happen. %08x\n", RREG32(RADEON_MC_STATUS));
245 } 248 }
246} 249}
247 250
@@ -300,9 +303,9 @@ static int rs400_debugfs_gart_info(struct seq_file *m, void *data)
300 seq_printf(m, "MCCFG_AGP_BASE_2 0x%08x\n", tmp); 303 seq_printf(m, "MCCFG_AGP_BASE_2 0x%08x\n", tmp);
301 tmp = RREG32_MC(RS690_MCCFG_AGP_LOCATION); 304 tmp = RREG32_MC(RS690_MCCFG_AGP_LOCATION);
302 seq_printf(m, "MCCFG_AGP_LOCATION 0x%08x\n", tmp); 305 seq_printf(m, "MCCFG_AGP_LOCATION 0x%08x\n", tmp);
303 tmp = RREG32_MC(0x100); 306 tmp = RREG32_MC(RS690_MCCFG_FB_LOCATION);
304 seq_printf(m, "MCCFG_FB_LOCATION 0x%08x\n", tmp); 307 seq_printf(m, "MCCFG_FB_LOCATION 0x%08x\n", tmp);
305 tmp = RREG32(0x134); 308 tmp = RREG32(RS690_HDP_FB_LOCATION);
306 seq_printf(m, "HDP_FB_LOCATION 0x%08x\n", tmp); 309 seq_printf(m, "HDP_FB_LOCATION 0x%08x\n", tmp);
307 } else { 310 } else {
308 tmp = RREG32(RADEON_AGP_BASE); 311 tmp = RREG32(RADEON_AGP_BASE);
diff --git a/drivers/gpu/drm/radeon/rv515.c b/drivers/gpu/drm/radeon/rv515.c
index 5d569f41f4ae..64b57af93714 100644
--- a/drivers/gpu/drm/radeon/rv515.c
+++ b/drivers/gpu/drm/radeon/rv515.c
@@ -69,13 +69,13 @@ void rv515_ring_start(struct radeon_device *rdev)
69 ISYNC_CPSCRATCH_IDLEGUI); 69 ISYNC_CPSCRATCH_IDLEGUI);
70 radeon_ring_write(rdev, PACKET0(WAIT_UNTIL, 0)); 70 radeon_ring_write(rdev, PACKET0(WAIT_UNTIL, 0));
71 radeon_ring_write(rdev, WAIT_2D_IDLECLEAN | WAIT_3D_IDLECLEAN); 71 radeon_ring_write(rdev, WAIT_2D_IDLECLEAN | WAIT_3D_IDLECLEAN);
72 radeon_ring_write(rdev, PACKET0(0x170C, 0)); 72 radeon_ring_write(rdev, PACKET0(R300_DST_PIPE_CONFIG, 0));
73 radeon_ring_write(rdev, 1 << 31); 73 radeon_ring_write(rdev, R300_PIPE_AUTO_CONFIG);
74 radeon_ring_write(rdev, PACKET0(GB_SELECT, 0)); 74 radeon_ring_write(rdev, PACKET0(GB_SELECT, 0));
75 radeon_ring_write(rdev, 0); 75 radeon_ring_write(rdev, 0);
76 radeon_ring_write(rdev, PACKET0(GB_ENABLE, 0)); 76 radeon_ring_write(rdev, PACKET0(GB_ENABLE, 0));
77 radeon_ring_write(rdev, 0); 77 radeon_ring_write(rdev, 0);
78 radeon_ring_write(rdev, PACKET0(0x42C8, 0)); 78 radeon_ring_write(rdev, PACKET0(R500_SU_REG_DEST, 0));
79 radeon_ring_write(rdev, (1 << rdev->num_gb_pipes) - 1); 79 radeon_ring_write(rdev, (1 << rdev->num_gb_pipes) - 1);
80 radeon_ring_write(rdev, PACKET0(VAP_INDEX_OFFSET, 0)); 80 radeon_ring_write(rdev, PACKET0(VAP_INDEX_OFFSET, 0));
81 radeon_ring_write(rdev, 0); 81 radeon_ring_write(rdev, 0);
@@ -153,8 +153,8 @@ void rv515_gpu_init(struct radeon_device *rdev)
153 } 153 }
154 rv515_vga_render_disable(rdev); 154 rv515_vga_render_disable(rdev);
155 r420_pipes_init(rdev); 155 r420_pipes_init(rdev);
156 gb_pipe_select = RREG32(0x402C); 156 gb_pipe_select = RREG32(R400_GB_PIPE_SELECT);
157 tmp = RREG32(0x170C); 157 tmp = RREG32(R300_DST_PIPE_CONFIG);
158 pipe_select_current = (tmp >> 2) & 3; 158 pipe_select_current = (tmp >> 2) & 3;
159 tmp = (1 << pipe_select_current) | 159 tmp = (1 << pipe_select_current) |
160 (((gb_pipe_select >> 8) & 0xF) << 4); 160 (((gb_pipe_select >> 8) & 0xF) << 4);
diff --git a/drivers/gpu/vga/Kconfig b/drivers/gpu/vga/Kconfig
index 8d0e31a22027..96c83a9a76bb 100644
--- a/drivers/gpu/vga/Kconfig
+++ b/drivers/gpu/vga/Kconfig
@@ -1,5 +1,5 @@
1config VGA_ARB 1config VGA_ARB
2 bool "VGA Arbitration" if EMBEDDED 2 bool "VGA Arbitration" if EXPERT
3 default y 3 default y
4 depends on PCI 4 depends on PCI
5 help 5 help
diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c
index c380c65da417..ace2b1623b21 100644
--- a/drivers/gpu/vga/vgaarb.c
+++ b/drivers/gpu/vga/vgaarb.c
@@ -636,7 +636,7 @@ int vga_client_register(struct pci_dev *pdev, void *cookie,
636 void (*irq_set_state)(void *cookie, bool state), 636 void (*irq_set_state)(void *cookie, bool state),
637 unsigned int (*set_vga_decode)(void *cookie, bool decode)) 637 unsigned int (*set_vga_decode)(void *cookie, bool decode))
638{ 638{
639 int ret = -1; 639 int ret = -ENODEV;
640 struct vga_device *vgadev; 640 struct vga_device *vgadev;
641 unsigned long flags; 641 unsigned long flags;
642 642
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 24cca2f69dfc..2560f01c1a63 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -62,9 +62,9 @@ config HID_3M_PCT
62 Support for 3M PCT touch screens. 62 Support for 3M PCT touch screens.
63 63
64config HID_A4TECH 64config HID_A4TECH
65 tristate "A4 tech mice" if EMBEDDED 65 tristate "A4 tech mice" if EXPERT
66 depends on USB_HID 66 depends on USB_HID
67 default !EMBEDDED 67 default !EXPERT
68 ---help--- 68 ---help---
69 Support for A4 tech X5 and WOP-35 / Trust 450L mice. 69 Support for A4 tech X5 and WOP-35 / Trust 450L mice.
70 70
@@ -77,9 +77,9 @@ config HID_ACRUX_FF
77 game controllers. 77 game controllers.
78 78
79config HID_APPLE 79config HID_APPLE
80 tristate "Apple {i,Power,Mac}Books" if EMBEDDED 80 tristate "Apple {i,Power,Mac}Books" if EXPERT
81 depends on (USB_HID || BT_HIDP) 81 depends on (USB_HID || BT_HIDP)
82 default !EMBEDDED 82 default !EXPERT
83 ---help--- 83 ---help---
84 Support for some Apple devices which less or more break 84 Support for some Apple devices which less or more break
85 HID specification. 85 HID specification.
@@ -88,9 +88,9 @@ config HID_APPLE
88 MacBooks, MacBook Pros and Apple Aluminum. 88 MacBooks, MacBook Pros and Apple Aluminum.
89 89
90config HID_BELKIN 90config HID_BELKIN
91 tristate "Belkin Flip KVM and Wireless keyboard" if EMBEDDED 91 tristate "Belkin Flip KVM and Wireless keyboard" if EXPERT
92 depends on USB_HID 92 depends on USB_HID
93 default !EMBEDDED 93 default !EXPERT
94 ---help--- 94 ---help---
95 Support for Belkin Flip KVM and Wireless keyboard. 95 Support for Belkin Flip KVM and Wireless keyboard.
96 96
@@ -101,16 +101,16 @@ config HID_CANDO
101 Support for Cando dual touch panel. 101 Support for Cando dual touch panel.
102 102
103config HID_CHERRY 103config HID_CHERRY
104 tristate "Cherry Cymotion keyboard" if EMBEDDED 104 tristate "Cherry Cymotion keyboard" if EXPERT
105 depends on USB_HID 105 depends on USB_HID
106 default !EMBEDDED 106 default !EXPERT
107 ---help--- 107 ---help---
108 Support for Cherry Cymotion keyboard. 108 Support for Cherry Cymotion keyboard.
109 109
110config HID_CHICONY 110config HID_CHICONY
111 tristate "Chicony Tactical pad" if EMBEDDED 111 tristate "Chicony Tactical pad" if EXPERT
112 depends on USB_HID 112 depends on USB_HID
113 default !EMBEDDED 113 default !EXPERT
114 ---help--- 114 ---help---
115 Support for Chicony Tactical pad. 115 Support for Chicony Tactical pad.
116 116
@@ -130,9 +130,9 @@ config HID_PRODIKEYS
130 and some additional multimedia keys. 130 and some additional multimedia keys.
131 131
132config HID_CYPRESS 132config HID_CYPRESS
133 tristate "Cypress mouse and barcode readers" if EMBEDDED 133 tristate "Cypress mouse and barcode readers" if EXPERT
134 depends on USB_HID 134 depends on USB_HID
135 default !EMBEDDED 135 default !EXPERT
136 ---help--- 136 ---help---
137 Support for cypress mouse and barcode readers. 137 Support for cypress mouse and barcode readers.
138 138
@@ -174,16 +174,16 @@ config HID_ELECOM
174 Support for the ELECOM BM084 (bluetooth mouse). 174 Support for the ELECOM BM084 (bluetooth mouse).
175 175
176config HID_EZKEY 176config HID_EZKEY
177 tristate "Ezkey BTC 8193 keyboard" if EMBEDDED 177 tristate "Ezkey BTC 8193 keyboard" if EXPERT
178 depends on USB_HID 178 depends on USB_HID
179 default !EMBEDDED 179 default !EXPERT
180 ---help--- 180 ---help---
181 Support for Ezkey BTC 8193 keyboard. 181 Support for Ezkey BTC 8193 keyboard.
182 182
183config HID_KYE 183config HID_KYE
184 tristate "Kye/Genius Ergo Mouse" if EMBEDDED 184 tristate "Kye/Genius Ergo Mouse" if EXPERT
185 depends on USB_HID 185 depends on USB_HID
186 default !EMBEDDED 186 default !EXPERT
187 ---help--- 187 ---help---
188 Support for Kye/Genius Ergo Mouse. 188 Support for Kye/Genius Ergo Mouse.
189 189
@@ -212,16 +212,16 @@ config HID_TWINHAN
212 Support for Twinhan IR remote control. 212 Support for Twinhan IR remote control.
213 213
214config HID_KENSINGTON 214config HID_KENSINGTON
215 tristate "Kensington Slimblade Trackball" if EMBEDDED 215 tristate "Kensington Slimblade Trackball" if EXPERT
216 depends on USB_HID 216 depends on USB_HID
217 default !EMBEDDED 217 default !EXPERT
218 ---help--- 218 ---help---
219 Support for Kensington Slimblade Trackball. 219 Support for Kensington Slimblade Trackball.
220 220
221config HID_LOGITECH 221config HID_LOGITECH
222 tristate "Logitech devices" if EMBEDDED 222 tristate "Logitech devices" if EXPERT
223 depends on USB_HID 223 depends on USB_HID
224 default !EMBEDDED 224 default !EXPERT
225 ---help--- 225 ---help---
226 Support for Logitech devices that are not fully compliant with HID standard. 226 Support for Logitech devices that are not fully compliant with HID standard.
227 227
@@ -276,9 +276,9 @@ config HID_MAGICMOUSE
276 Apple Wireless "Magic" Mouse. 276 Apple Wireless "Magic" Mouse.
277 277
278config HID_MICROSOFT 278config HID_MICROSOFT
279 tristate "Microsoft non-fully HID-compliant devices" if EMBEDDED 279 tristate "Microsoft non-fully HID-compliant devices" if EXPERT
280 depends on USB_HID 280 depends on USB_HID
281 default !EMBEDDED 281 default !EXPERT
282 ---help--- 282 ---help---
283 Support for Microsoft devices that are not fully compliant with HID standard. 283 Support for Microsoft devices that are not fully compliant with HID standard.
284 284
@@ -289,9 +289,9 @@ config HID_MOSART
289 Support for MosArt dual-touch panels. 289 Support for MosArt dual-touch panels.
290 290
291config HID_MONTEREY 291config HID_MONTEREY
292 tristate "Monterey Genius KB29E keyboard" if EMBEDDED 292 tristate "Monterey Genius KB29E keyboard" if EXPERT
293 depends on USB_HID 293 depends on USB_HID
294 default !EMBEDDED 294 default !EXPERT
295 ---help--- 295 ---help---
296 Support for Monterey Genius KB29E. 296 Support for Monterey Genius KB29E.
297 297
@@ -365,8 +365,8 @@ config HID_PICOLCD
365 - IR 365 - IR
366 366
367config HID_PICOLCD_FB 367config HID_PICOLCD_FB
368 bool "Framebuffer support" if EMBEDDED 368 bool "Framebuffer support" if EXPERT
369 default !EMBEDDED 369 default !EXPERT
370 depends on HID_PICOLCD 370 depends on HID_PICOLCD
371 depends on HID_PICOLCD=FB || FB=y 371 depends on HID_PICOLCD=FB || FB=y
372 select FB_DEFERRED_IO 372 select FB_DEFERRED_IO
@@ -379,8 +379,8 @@ config HID_PICOLCD_FB
379 frambuffer device. 379 frambuffer device.
380 380
381config HID_PICOLCD_BACKLIGHT 381config HID_PICOLCD_BACKLIGHT
382 bool "Backlight control" if EMBEDDED 382 bool "Backlight control" if EXPERT
383 default !EMBEDDED 383 default !EXPERT
384 depends on HID_PICOLCD 384 depends on HID_PICOLCD
385 depends on HID_PICOLCD=BACKLIGHT_CLASS_DEVICE || BACKLIGHT_CLASS_DEVICE=y 385 depends on HID_PICOLCD=BACKLIGHT_CLASS_DEVICE || BACKLIGHT_CLASS_DEVICE=y
386 ---help--- 386 ---help---
@@ -388,16 +388,16 @@ config HID_PICOLCD_BACKLIGHT
388 class. 388 class.
389 389
390config HID_PICOLCD_LCD 390config HID_PICOLCD_LCD
391 bool "Contrast control" if EMBEDDED 391 bool "Contrast control" if EXPERT
392 default !EMBEDDED 392 default !EXPERT
393 depends on HID_PICOLCD 393 depends on HID_PICOLCD
394 depends on HID_PICOLCD=LCD_CLASS_DEVICE || LCD_CLASS_DEVICE=y 394 depends on HID_PICOLCD=LCD_CLASS_DEVICE || LCD_CLASS_DEVICE=y
395 ---help--- 395 ---help---
396 Provide access to PicoLCD's LCD contrast via lcd class. 396 Provide access to PicoLCD's LCD contrast via lcd class.
397 397
398config HID_PICOLCD_LEDS 398config HID_PICOLCD_LEDS
399 bool "GPO via leds class" if EMBEDDED 399 bool "GPO via leds class" if EXPERT
400 default !EMBEDDED 400 default !EXPERT
401 depends on HID_PICOLCD 401 depends on HID_PICOLCD
402 depends on HID_PICOLCD=LEDS_CLASS || LEDS_CLASS=y 402 depends on HID_PICOLCD=LEDS_CLASS || LEDS_CLASS=y
403 ---help--- 403 ---help---
diff --git a/drivers/hid/usbhid/Kconfig b/drivers/hid/usbhid/Kconfig
index 4edb3bef94a6..0f20fd17cf06 100644
--- a/drivers/hid/usbhid/Kconfig
+++ b/drivers/hid/usbhid/Kconfig
@@ -45,7 +45,7 @@ config USB_HIDDEV
45 If unsure, say Y. 45 If unsure, say Y.
46 46
47menu "USB HID Boot Protocol drivers" 47menu "USB HID Boot Protocol drivers"
48 depends on USB!=n && USB_HID!=y && EMBEDDED 48 depends on USB!=n && USB_HID!=y && EXPERT
49 49
50config USB_KBD 50config USB_KBD
51 tristate "USB HIDBP Keyboard (simple Boot) support" 51 tristate "USB HIDBP Keyboard (simple Boot) support"
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index ce0372f0615e..4c0743660e9c 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -1072,6 +1072,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
1072 node->sda.dev_attr.show = grp->show; 1072 node->sda.dev_attr.show = grp->show;
1073 node->sda.dev_attr.store = grp->store; 1073 node->sda.dev_attr.store = grp->store;
1074 attr = &node->sda.dev_attr.attr; 1074 attr = &node->sda.dev_attr.attr;
1075 sysfs_attr_init(attr);
1075 attr->name = node->name; 1076 attr->name = node->name;
1076 attr->mode = S_IRUGO | (grp->store ? S_IWUSR : 0); 1077 attr->mode = S_IRUGO | (grp->store ? S_IWUSR : 0);
1077 ret = sysfs_create_file(&pdev->dev.kobj, attr); 1078 ret = sysfs_create_file(&pdev->dev.kobj, attr);
diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
index 2d68cf3c223b..b5e892017e0c 100644
--- a/drivers/hwmon/asus_atk0110.c
+++ b/drivers/hwmon/asus_atk0110.c
@@ -13,6 +13,7 @@
13#include <linux/list.h> 13#include <linux/list.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/dmi.h>
16 17
17#include <acpi/acpi.h> 18#include <acpi/acpi.h>
18#include <acpi/acpixf.h> 19#include <acpi/acpixf.h>
@@ -22,6 +23,21 @@
22 23
23#define ATK_HID "ATK0110" 24#define ATK_HID "ATK0110"
24 25
26static bool new_if;
27module_param(new_if, bool, 0);
28MODULE_PARM_DESC(new_if, "Override detection heuristic and force the use of the new ATK0110 interface");
29
30static const struct dmi_system_id __initconst atk_force_new_if[] = {
31 {
32 /* Old interface has broken MCH temp monitoring */
33 .ident = "Asus Sabertooth X58",
34 .matches = {
35 DMI_MATCH(DMI_BOARD_NAME, "SABERTOOTH X58")
36 }
37 },
38 { }
39};
40
25/* Minimum time between readings, enforced in order to avoid 41/* Minimum time between readings, enforced in order to avoid
26 * hogging the CPU. 42 * hogging the CPU.
27 */ 43 */
@@ -1302,7 +1318,9 @@ static int atk_probe_if(struct atk_data *data)
1302 * analysis of multiple DSDTs indicates that when both interfaces 1318 * analysis of multiple DSDTs indicates that when both interfaces
1303 * are present the new one (GGRP/GITM) is not functional. 1319 * are present the new one (GGRP/GITM) is not functional.
1304 */ 1320 */
1305 if (data->rtmp_handle && data->rvlt_handle && data->rfan_handle) 1321 if (new_if)
1322 dev_info(dev, "Overriding interface detection\n");
1323 if (data->rtmp_handle && data->rvlt_handle && data->rfan_handle && !new_if)
1306 data->old_interface = true; 1324 data->old_interface = true;
1307 else if (data->enumerate_handle && data->read_handle && 1325 else if (data->enumerate_handle && data->read_handle &&
1308 data->write_handle) 1326 data->write_handle)
@@ -1420,6 +1438,9 @@ static int __init atk0110_init(void)
1420 return -EBUSY; 1438 return -EBUSY;
1421 } 1439 }
1422 1440
1441 if (dmi_check_system(atk_force_new_if))
1442 new_if = true;
1443
1423 ret = acpi_bus_register_driver(&atk_driver); 1444 ret = acpi_bus_register_driver(&atk_driver);
1424 if (ret) 1445 if (ret)
1425 pr_info("acpi_bus_register_driver failed: %d\n", ret); 1446 pr_info("acpi_bus_register_driver failed: %d\n", ret);
diff --git a/drivers/hwmon/lis3lv02d.c b/drivers/hwmon/lis3lv02d.c
index 1b674b7d4584..d805e8e57967 100644
--- a/drivers/hwmon/lis3lv02d.c
+++ b/drivers/hwmon/lis3lv02d.c
@@ -957,7 +957,7 @@ int lis3lv02d_init_device(struct lis3lv02d *dev)
957 957
958 /* bail if we did not get an IRQ from the bus layer */ 958 /* bail if we did not get an IRQ from the bus layer */
959 if (!dev->irq) { 959 if (!dev->irq) {
960 pr_err("No IRQ. Disabling /dev/freefall\n"); 960 pr_debug("No IRQ. Disabling /dev/freefall\n");
961 goto out; 961 goto out;
962 } 962 }
963 963
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index 98ccfeb3f5aa..9827c5e686cb 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -134,7 +134,7 @@ config BLK_DEV_IDECD
134 module will be called ide-cd. 134 module will be called ide-cd.
135 135
136config BLK_DEV_IDECD_VERBOSE_ERRORS 136config BLK_DEV_IDECD_VERBOSE_ERRORS
137 bool "Verbose error logging for IDE/ATAPI CDROM driver" if EMBEDDED 137 bool "Verbose error logging for IDE/ATAPI CDROM driver" if EXPERT
138 depends on BLK_DEV_IDECD 138 depends on BLK_DEV_IDECD
139 default y 139 default y
140 help 140 help
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
index 7acb32e7f817..1fa091e05690 100644
--- a/drivers/idle/intel_idle.c
+++ b/drivers/idle/intel_idle.c
@@ -263,7 +263,7 @@ static void __setup_broadcast_timer(void *arg)
263 clockevents_notify(reason, &cpu); 263 clockevents_notify(reason, &cpu);
264} 264}
265 265
266static int __cpuinit setup_broadcast_cpuhp_notify(struct notifier_block *n, 266static int setup_broadcast_cpuhp_notify(struct notifier_block *n,
267 unsigned long action, void *hcpu) 267 unsigned long action, void *hcpu)
268{ 268{
269 int hotcpu = (unsigned long)hcpu; 269 int hotcpu = (unsigned long)hcpu;
@@ -273,15 +273,11 @@ static int __cpuinit setup_broadcast_cpuhp_notify(struct notifier_block *n,
273 smp_call_function_single(hotcpu, __setup_broadcast_timer, 273 smp_call_function_single(hotcpu, __setup_broadcast_timer,
274 (void *)true, 1); 274 (void *)true, 1);
275 break; 275 break;
276 case CPU_DOWN_PREPARE:
277 smp_call_function_single(hotcpu, __setup_broadcast_timer,
278 (void *)false, 1);
279 break;
280 } 276 }
281 return NOTIFY_OK; 277 return NOTIFY_OK;
282} 278}
283 279
284static struct notifier_block __cpuinitdata setup_broadcast_notifier = { 280static struct notifier_block setup_broadcast_notifier = {
285 .notifier_call = setup_broadcast_cpuhp_notify, 281 .notifier_call = setup_broadcast_cpuhp_notify,
286}; 282};
287 283
diff --git a/drivers/infiniband/hw/mthca/Kconfig b/drivers/infiniband/hw/mthca/Kconfig
index 03efc074967e..da314c3fec23 100644
--- a/drivers/infiniband/hw/mthca/Kconfig
+++ b/drivers/infiniband/hw/mthca/Kconfig
@@ -7,7 +7,7 @@ config INFINIBAND_MTHCA
7 ("Tavor") and the MT25208 PCI Express HCA ("Arbel"). 7 ("Tavor") and the MT25208 PCI Express HCA ("Arbel").
8 8
9config INFINIBAND_MTHCA_DEBUG 9config INFINIBAND_MTHCA_DEBUG
10 bool "Verbose debugging output" if EMBEDDED 10 bool "Verbose debugging output" if EXPERT
11 depends on INFINIBAND_MTHCA 11 depends on INFINIBAND_MTHCA
12 default y 12 default y
13 ---help--- 13 ---help---
diff --git a/drivers/infiniband/ulp/ipoib/Kconfig b/drivers/infiniband/ulp/ipoib/Kconfig
index 55855eeabae7..cda8eac55fff 100644
--- a/drivers/infiniband/ulp/ipoib/Kconfig
+++ b/drivers/infiniband/ulp/ipoib/Kconfig
@@ -24,7 +24,7 @@ config INFINIBAND_IPOIB_CM
24 unless you limit mtu for these destinations to 2044. 24 unless you limit mtu for these destinations to 2044.
25 25
26config INFINIBAND_IPOIB_DEBUG 26config INFINIBAND_IPOIB_DEBUG
27 bool "IP-over-InfiniBand debugging" if EMBEDDED 27 bool "IP-over-InfiniBand debugging" if EXPERT
28 depends on INFINIBAND_IPOIB 28 depends on INFINIBAND_IPOIB
29 default y 29 default y
30 ---help--- 30 ---help---
diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
index 07c2cd43109c..1903c0f5b925 100644
--- a/drivers/input/Kconfig
+++ b/drivers/input/Kconfig
@@ -6,7 +6,7 @@ menu "Input device support"
6 depends on !S390 6 depends on !S390
7 7
8config INPUT 8config INPUT
9 tristate "Generic input layer (needed for keyboard, mouse, ...)" if EMBEDDED 9 tristate "Generic input layer (needed for keyboard, mouse, ...)" if EXPERT
10 default y 10 default y
11 help 11 help
12 Say Y here if you have any input device (mouse, keyboard, tablet, 12 Say Y here if you have any input device (mouse, keyboard, tablet,
@@ -67,7 +67,7 @@ config INPUT_SPARSEKMAP
67comment "Userland interfaces" 67comment "Userland interfaces"
68 68
69config INPUT_MOUSEDEV 69config INPUT_MOUSEDEV
70 tristate "Mouse interface" if EMBEDDED 70 tristate "Mouse interface" if EXPERT
71 default y 71 default y
72 help 72 help
73 Say Y here if you want your mouse to be accessible as char devices 73 Say Y here if you want your mouse to be accessible as char devices
@@ -150,7 +150,7 @@ config INPUT_EVBUG
150 module will be called evbug. 150 module will be called evbug.
151 151
152config INPUT_APMPOWER 152config INPUT_APMPOWER
153 tristate "Input Power Event -> APM Bridge" if EMBEDDED 153 tristate "Input Power Event -> APM Bridge" if EXPERT
154 depends on INPUT && APM_EMULATION 154 depends on INPUT && APM_EMULATION
155 help 155 help
156 Say Y here if you want suspend key events to trigger a user 156 Say Y here if you want suspend key events to trigger a user
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index 7b3c0b8fa432..c7a92028f450 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -2,7 +2,7 @@
2# Input core configuration 2# Input core configuration
3# 3#
4menuconfig INPUT_KEYBOARD 4menuconfig INPUT_KEYBOARD
5 bool "Keyboards" if EMBEDDED || !X86 5 bool "Keyboards" if EXPERT || !X86
6 default y 6 default y
7 help 7 help
8 Say Y here, and a list of supported keyboards will be displayed. 8 Say Y here, and a list of supported keyboards will be displayed.
@@ -57,7 +57,7 @@ config KEYBOARD_ATARI
57 module will be called atakbd. 57 module will be called atakbd.
58 58
59config KEYBOARD_ATKBD 59config KEYBOARD_ATKBD
60 tristate "AT keyboard" if EMBEDDED || !X86 60 tristate "AT keyboard" if EXPERT || !X86
61 default y 61 default y
62 select SERIO 62 select SERIO
63 select SERIO_LIBPS2 63 select SERIO_LIBPS2
@@ -343,6 +343,16 @@ config KEYBOARD_NOMADIK
343 To compile this driver as a module, choose M here: the 343 To compile this driver as a module, choose M here: the
344 module will be called nmk-ske-keypad. 344 module will be called nmk-ske-keypad.
345 345
346config KEYBOARD_TEGRA
347 tristate "NVIDIA Tegra internal matrix keyboard controller support"
348 depends on ARCH_TEGRA
349 help
350 Say Y here if you want to use a matrix keyboard connected directly
351 to the internal keyboard controller on Tegra SoCs.
352
353 To compile this driver as a module, choose M here: the
354 module will be called tegra-kbc.
355
346config KEYBOARD_OPENCORES 356config KEYBOARD_OPENCORES
347 tristate "OpenCores Keyboard Controller" 357 tristate "OpenCores Keyboard Controller"
348 help 358 help
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 4e5571b72cda..468c627a2844 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -42,6 +42,7 @@ obj-$(CONFIG_KEYBOARD_STMPE) += stmpe-keypad.o
42obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o 42obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o
43obj-$(CONFIG_KEYBOARD_SUNKBD) += sunkbd.o 43obj-$(CONFIG_KEYBOARD_SUNKBD) += sunkbd.o
44obj-$(CONFIG_KEYBOARD_TC3589X) += tc3589x-keypad.o 44obj-$(CONFIG_KEYBOARD_TC3589X) += tc3589x-keypad.o
45obj-$(CONFIG_KEYBOARD_TEGRA) += tegra-kbc.o
45obj-$(CONFIG_KEYBOARD_TNETV107X) += tnetv107x-keypad.o 46obj-$(CONFIG_KEYBOARD_TNETV107X) += tnetv107x-keypad.o
46obj-$(CONFIG_KEYBOARD_TWL4030) += twl4030_keypad.o 47obj-$(CONFIG_KEYBOARD_TWL4030) += twl4030_keypad.o
47obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o 48obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 6069abe31e42..eb3006361ee4 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -322,7 +322,7 @@ static void gpio_keys_report_event(struct gpio_button_data *bdata)
322 struct gpio_keys_button *button = bdata->button; 322 struct gpio_keys_button *button = bdata->button;
323 struct input_dev *input = bdata->input; 323 struct input_dev *input = bdata->input;
324 unsigned int type = button->type ?: EV_KEY; 324 unsigned int type = button->type ?: EV_KEY;
325 int state = (gpio_get_value(button->gpio) ? 1 : 0) ^ button->active_low; 325 int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^ button->active_low;
326 326
327 input_event(input, type, button->code, !!state); 327 input_event(input, type, button->code, !!state);
328 input_sync(input); 328 input_sync(input);
@@ -410,8 +410,8 @@ static int __devinit gpio_keys_setup_key(struct platform_device *pdev,
410 if (!button->can_disable) 410 if (!button->can_disable)
411 irqflags |= IRQF_SHARED; 411 irqflags |= IRQF_SHARED;
412 412
413 error = request_irq(irq, gpio_keys_isr, irqflags, desc, bdata); 413 error = request_any_context_irq(irq, gpio_keys_isr, irqflags, desc, bdata);
414 if (error) { 414 if (error < 0) {
415 dev_err(dev, "Unable to claim irq %d; error %d\n", 415 dev_err(dev, "Unable to claim irq %d; error %d\n",
416 irq, error); 416 irq, error);
417 goto fail3; 417 goto fail3;
diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c
new file mode 100644
index 000000000000..ac471b77c18e
--- /dev/null
+++ b/drivers/input/keyboard/tegra-kbc.c
@@ -0,0 +1,727 @@
1/*
2 * Keyboard class input driver for the NVIDIA Tegra SoC internal matrix
3 * keyboard controller
4 *
5 * Copyright (c) 2009-2011, NVIDIA Corporation.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 */
21
22#include <linux/module.h>
23#include <linux/input.h>
24#include <linux/platform_device.h>
25#include <linux/delay.h>
26#include <linux/io.h>
27#include <linux/interrupt.h>
28#include <linux/clk.h>
29#include <linux/slab.h>
30#include <mach/clk.h>
31#include <mach/kbc.h>
32
33#define KBC_MAX_DEBOUNCE_CNT 0x3ffu
34
35/* KBC row scan time and delay for beginning the row scan. */
36#define KBC_ROW_SCAN_TIME 16
37#define KBC_ROW_SCAN_DLY 5
38
39/* KBC uses a 32KHz clock so a cycle = 1/32Khz */
40#define KBC_CYCLE_USEC 32
41
42/* KBC Registers */
43
44/* KBC Control Register */
45#define KBC_CONTROL_0 0x0
46#define KBC_FIFO_TH_CNT_SHIFT(cnt) (cnt << 14)
47#define KBC_DEBOUNCE_CNT_SHIFT(cnt) (cnt << 4)
48#define KBC_CONTROL_FIFO_CNT_INT_EN (1 << 3)
49#define KBC_CONTROL_KBC_EN (1 << 0)
50
51/* KBC Interrupt Register */
52#define KBC_INT_0 0x4
53#define KBC_INT_FIFO_CNT_INT_STATUS (1 << 2)
54
55#define KBC_ROW_CFG0_0 0x8
56#define KBC_COL_CFG0_0 0x18
57#define KBC_INIT_DLY_0 0x28
58#define KBC_RPT_DLY_0 0x2c
59#define KBC_KP_ENT0_0 0x30
60#define KBC_KP_ENT1_0 0x34
61#define KBC_ROW0_MASK_0 0x38
62
63#define KBC_ROW_SHIFT 3
64
65struct tegra_kbc {
66 void __iomem *mmio;
67 struct input_dev *idev;
68 unsigned int irq;
69 unsigned int wake_enable_rows;
70 unsigned int wake_enable_cols;
71 spinlock_t lock;
72 unsigned int repoll_dly;
73 unsigned long cp_dly_jiffies;
74 const struct tegra_kbc_platform_data *pdata;
75 unsigned short keycode[KBC_MAX_KEY];
76 unsigned short current_keys[KBC_MAX_KPENT];
77 unsigned int num_pressed_keys;
78 struct timer_list timer;
79 struct clk *clk;
80};
81
82static const u32 tegra_kbc_default_keymap[] = {
83 KEY(0, 2, KEY_W),
84 KEY(0, 3, KEY_S),
85 KEY(0, 4, KEY_A),
86 KEY(0, 5, KEY_Z),
87 KEY(0, 7, KEY_FN),
88
89 KEY(1, 7, KEY_LEFTMETA),
90
91 KEY(2, 6, KEY_RIGHTALT),
92 KEY(2, 7, KEY_LEFTALT),
93
94 KEY(3, 0, KEY_5),
95 KEY(3, 1, KEY_4),
96 KEY(3, 2, KEY_R),
97 KEY(3, 3, KEY_E),
98 KEY(3, 4, KEY_F),
99 KEY(3, 5, KEY_D),
100 KEY(3, 6, KEY_X),
101
102 KEY(4, 0, KEY_7),
103 KEY(4, 1, KEY_6),
104 KEY(4, 2, KEY_T),
105 KEY(4, 3, KEY_H),
106 KEY(4, 4, KEY_G),
107 KEY(4, 5, KEY_V),
108 KEY(4, 6, KEY_C),
109 KEY(4, 7, KEY_SPACE),
110
111 KEY(5, 0, KEY_9),
112 KEY(5, 1, KEY_8),
113 KEY(5, 2, KEY_U),
114 KEY(5, 3, KEY_Y),
115 KEY(5, 4, KEY_J),
116 KEY(5, 5, KEY_N),
117 KEY(5, 6, KEY_B),
118 KEY(5, 7, KEY_BACKSLASH),
119
120 KEY(6, 0, KEY_MINUS),
121 KEY(6, 1, KEY_0),
122 KEY(6, 2, KEY_O),
123 KEY(6, 3, KEY_I),
124 KEY(6, 4, KEY_L),
125 KEY(6, 5, KEY_K),
126 KEY(6, 6, KEY_COMMA),
127 KEY(6, 7, KEY_M),
128
129 KEY(7, 1, KEY_EQUAL),
130 KEY(7, 2, KEY_RIGHTBRACE),
131 KEY(7, 3, KEY_ENTER),
132 KEY(7, 7, KEY_MENU),
133
134 KEY(8, 4, KEY_RIGHTSHIFT),
135 KEY(8, 5, KEY_LEFTSHIFT),
136
137 KEY(9, 5, KEY_RIGHTCTRL),
138 KEY(9, 7, KEY_LEFTCTRL),
139
140 KEY(11, 0, KEY_LEFTBRACE),
141 KEY(11, 1, KEY_P),
142 KEY(11, 2, KEY_APOSTROPHE),
143 KEY(11, 3, KEY_SEMICOLON),
144 KEY(11, 4, KEY_SLASH),
145 KEY(11, 5, KEY_DOT),
146
147 KEY(12, 0, KEY_F10),
148 KEY(12, 1, KEY_F9),
149 KEY(12, 2, KEY_BACKSPACE),
150 KEY(12, 3, KEY_3),
151 KEY(12, 4, KEY_2),
152 KEY(12, 5, KEY_UP),
153 KEY(12, 6, KEY_PRINT),
154 KEY(12, 7, KEY_PAUSE),
155
156 KEY(13, 0, KEY_INSERT),
157 KEY(13, 1, KEY_DELETE),
158 KEY(13, 3, KEY_PAGEUP),
159 KEY(13, 4, KEY_PAGEDOWN),
160 KEY(13, 5, KEY_RIGHT),
161 KEY(13, 6, KEY_DOWN),
162 KEY(13, 7, KEY_LEFT),
163
164 KEY(14, 0, KEY_F11),
165 KEY(14, 1, KEY_F12),
166 KEY(14, 2, KEY_F8),
167 KEY(14, 3, KEY_Q),
168 KEY(14, 4, KEY_F4),
169 KEY(14, 5, KEY_F3),
170 KEY(14, 6, KEY_1),
171 KEY(14, 7, KEY_F7),
172
173 KEY(15, 0, KEY_ESC),
174 KEY(15, 1, KEY_GRAVE),
175 KEY(15, 2, KEY_F5),
176 KEY(15, 3, KEY_TAB),
177 KEY(15, 4, KEY_F1),
178 KEY(15, 5, KEY_F2),
179 KEY(15, 6, KEY_CAPSLOCK),
180 KEY(15, 7, KEY_F6),
181};
182
183static const struct matrix_keymap_data tegra_kbc_default_keymap_data = {
184 .keymap = tegra_kbc_default_keymap,
185 .keymap_size = ARRAY_SIZE(tegra_kbc_default_keymap),
186};
187
188static void tegra_kbc_report_released_keys(struct input_dev *input,
189 unsigned short old_keycodes[],
190 unsigned int old_num_keys,
191 unsigned short new_keycodes[],
192 unsigned int new_num_keys)
193{
194 unsigned int i, j;
195
196 for (i = 0; i < old_num_keys; i++) {
197 for (j = 0; j < new_num_keys; j++)
198 if (old_keycodes[i] == new_keycodes[j])
199 break;
200
201 if (j == new_num_keys)
202 input_report_key(input, old_keycodes[i], 0);
203 }
204}
205
206static void tegra_kbc_report_pressed_keys(struct input_dev *input,
207 unsigned char scancodes[],
208 unsigned short keycodes[],
209 unsigned int num_pressed_keys)
210{
211 unsigned int i;
212
213 for (i = 0; i < num_pressed_keys; i++) {
214 input_event(input, EV_MSC, MSC_SCAN, scancodes[i]);
215 input_report_key(input, keycodes[i], 1);
216 }
217}
218
219static void tegra_kbc_report_keys(struct tegra_kbc *kbc)
220{
221 unsigned char scancodes[KBC_MAX_KPENT];
222 unsigned short keycodes[KBC_MAX_KPENT];
223 u32 val = 0;
224 unsigned int i;
225 unsigned int num_down = 0;
226 unsigned long flags;
227
228 spin_lock_irqsave(&kbc->lock, flags);
229 for (i = 0; i < KBC_MAX_KPENT; i++) {
230 if ((i % 4) == 0)
231 val = readl(kbc->mmio + KBC_KP_ENT0_0 + i);
232
233 if (val & 0x80) {
234 unsigned int col = val & 0x07;
235 unsigned int row = (val >> 3) & 0x0f;
236 unsigned char scancode =
237 MATRIX_SCAN_CODE(row, col, KBC_ROW_SHIFT);
238
239 scancodes[num_down] = scancode;
240 keycodes[num_down++] = kbc->keycode[scancode];
241 }
242
243 val >>= 8;
244 }
245 spin_unlock_irqrestore(&kbc->lock, flags);
246
247 tegra_kbc_report_released_keys(kbc->idev,
248 kbc->current_keys, kbc->num_pressed_keys,
249 keycodes, num_down);
250 tegra_kbc_report_pressed_keys(kbc->idev, scancodes, keycodes, num_down);
251 input_sync(kbc->idev);
252
253 memcpy(kbc->current_keys, keycodes, sizeof(kbc->current_keys));
254 kbc->num_pressed_keys = num_down;
255}
256
257static void tegra_kbc_keypress_timer(unsigned long data)
258{
259 struct tegra_kbc *kbc = (struct tegra_kbc *)data;
260 unsigned long flags;
261 u32 val;
262 unsigned int i;
263
264 val = (readl(kbc->mmio + KBC_INT_0) >> 4) & 0xf;
265 if (val) {
266 unsigned long dly;
267
268 tegra_kbc_report_keys(kbc);
269
270 /*
271 * If more than one keys are pressed we need not wait
272 * for the repoll delay.
273 */
274 dly = (val == 1) ? kbc->repoll_dly : 1;
275 mod_timer(&kbc->timer, jiffies + msecs_to_jiffies(dly));
276 } else {
277 /* Release any pressed keys and exit the polling loop */
278 for (i = 0; i < kbc->num_pressed_keys; i++)
279 input_report_key(kbc->idev, kbc->current_keys[i], 0);
280 input_sync(kbc->idev);
281
282 kbc->num_pressed_keys = 0;
283
284 /* All keys are released so enable the keypress interrupt */
285 spin_lock_irqsave(&kbc->lock, flags);
286 val = readl(kbc->mmio + KBC_CONTROL_0);
287 val |= KBC_CONTROL_FIFO_CNT_INT_EN;
288 writel(val, kbc->mmio + KBC_CONTROL_0);
289 spin_unlock_irqrestore(&kbc->lock, flags);
290 }
291}
292
293static irqreturn_t tegra_kbc_isr(int irq, void *args)
294{
295 struct tegra_kbc *kbc = args;
296 u32 val, ctl;
297
298 /*
299 * Until all keys are released, defer further processing to
300 * the polling loop in tegra_kbc_keypress_timer
301 */
302 ctl = readl(kbc->mmio + KBC_CONTROL_0);
303 ctl &= ~KBC_CONTROL_FIFO_CNT_INT_EN;
304 writel(ctl, kbc->mmio + KBC_CONTROL_0);
305
306 /*
307 * Quickly bail out & reenable interrupts if the fifo threshold
308 * count interrupt wasn't the interrupt source
309 */
310 val = readl(kbc->mmio + KBC_INT_0);
311 writel(val, kbc->mmio + KBC_INT_0);
312
313 if (val & KBC_INT_FIFO_CNT_INT_STATUS) {
314 /*
315 * Schedule timer to run when hardware is in continuous
316 * polling mode.
317 */
318 mod_timer(&kbc->timer, jiffies + kbc->cp_dly_jiffies);
319 } else {
320 ctl |= KBC_CONTROL_FIFO_CNT_INT_EN;
321 writel(ctl, kbc->mmio + KBC_CONTROL_0);
322 }
323
324 return IRQ_HANDLED;
325}
326
327static void tegra_kbc_setup_wakekeys(struct tegra_kbc *kbc, bool filter)
328{
329 const struct tegra_kbc_platform_data *pdata = kbc->pdata;
330 int i;
331 unsigned int rst_val;
332
333 BUG_ON(pdata->wake_cnt > KBC_MAX_KEY);
334 rst_val = (filter && pdata->wake_cnt) ? ~0 : 0;
335
336 for (i = 0; i < KBC_MAX_ROW; i++)
337 writel(rst_val, kbc->mmio + KBC_ROW0_MASK_0 + i * 4);
338
339 if (filter) {
340 for (i = 0; i < pdata->wake_cnt; i++) {
341 u32 val, addr;
342 addr = pdata->wake_cfg[i].row * 4 + KBC_ROW0_MASK_0;
343 val = readl(kbc->mmio + addr);
344 val &= ~(1 << pdata->wake_cfg[i].col);
345 writel(val, kbc->mmio + addr);
346 }
347 }
348}
349
350static void tegra_kbc_config_pins(struct tegra_kbc *kbc)
351{
352 const struct tegra_kbc_platform_data *pdata = kbc->pdata;
353 int i;
354
355 for (i = 0; i < KBC_MAX_GPIO; i++) {
356 u32 r_shft = 5 * (i % 6);
357 u32 c_shft = 4 * (i % 8);
358 u32 r_mask = 0x1f << r_shft;
359 u32 c_mask = 0x0f << c_shft;
360 u32 r_offs = (i / 6) * 4 + KBC_ROW_CFG0_0;
361 u32 c_offs = (i / 8) * 4 + KBC_COL_CFG0_0;
362 u32 row_cfg = readl(kbc->mmio + r_offs);
363 u32 col_cfg = readl(kbc->mmio + c_offs);
364
365 row_cfg &= ~r_mask;
366 col_cfg &= ~c_mask;
367
368 if (pdata->pin_cfg[i].is_row)
369 row_cfg |= ((pdata->pin_cfg[i].num << 1) | 1) << r_shft;
370 else
371 col_cfg |= ((pdata->pin_cfg[i].num << 1) | 1) << c_shft;
372
373 writel(row_cfg, kbc->mmio + r_offs);
374 writel(col_cfg, kbc->mmio + c_offs);
375 }
376}
377
378static int tegra_kbc_start(struct tegra_kbc *kbc)
379{
380 const struct tegra_kbc_platform_data *pdata = kbc->pdata;
381 unsigned long flags;
382 unsigned int debounce_cnt;
383 u32 val = 0;
384
385 clk_enable(kbc->clk);
386
387 /* Reset the KBC controller to clear all previous status.*/
388 tegra_periph_reset_assert(kbc->clk);
389 udelay(100);
390 tegra_periph_reset_deassert(kbc->clk);
391 udelay(100);
392
393 tegra_kbc_config_pins(kbc);
394 tegra_kbc_setup_wakekeys(kbc, false);
395
396 writel(pdata->repeat_cnt, kbc->mmio + KBC_RPT_DLY_0);
397
398 /* Keyboard debounce count is maximum of 12 bits. */
399 debounce_cnt = min(pdata->debounce_cnt, KBC_MAX_DEBOUNCE_CNT);
400 val = KBC_DEBOUNCE_CNT_SHIFT(debounce_cnt);
401 val |= KBC_FIFO_TH_CNT_SHIFT(1); /* set fifo interrupt threshold to 1 */
402 val |= KBC_CONTROL_FIFO_CNT_INT_EN; /* interrupt on FIFO threshold */
403 val |= KBC_CONTROL_KBC_EN; /* enable */
404 writel(val, kbc->mmio + KBC_CONTROL_0);
405
406 /*
407 * Compute the delay(ns) from interrupt mode to continuous polling
408 * mode so the timer routine is scheduled appropriately.
409 */
410 val = readl(kbc->mmio + KBC_INIT_DLY_0);
411 kbc->cp_dly_jiffies = usecs_to_jiffies((val & 0xfffff) * 32);
412
413 kbc->num_pressed_keys = 0;
414
415 /*
416 * Atomically clear out any remaining entries in the key FIFO
417 * and enable keyboard interrupts.
418 */
419 spin_lock_irqsave(&kbc->lock, flags);
420 while (1) {
421 val = readl(kbc->mmio + KBC_INT_0);
422 val >>= 4;
423 if (!val)
424 break;
425
426 val = readl(kbc->mmio + KBC_KP_ENT0_0);
427 val = readl(kbc->mmio + KBC_KP_ENT1_0);
428 }
429 writel(0x7, kbc->mmio + KBC_INT_0);
430 spin_unlock_irqrestore(&kbc->lock, flags);
431
432 enable_irq(kbc->irq);
433
434 return 0;
435}
436
437static void tegra_kbc_stop(struct tegra_kbc *kbc)
438{
439 unsigned long flags;
440 u32 val;
441
442 spin_lock_irqsave(&kbc->lock, flags);
443 val = readl(kbc->mmio + KBC_CONTROL_0);
444 val &= ~1;
445 writel(val, kbc->mmio + KBC_CONTROL_0);
446 spin_unlock_irqrestore(&kbc->lock, flags);
447
448 disable_irq(kbc->irq);
449 del_timer_sync(&kbc->timer);
450
451 clk_disable(kbc->clk);
452}
453
454static int tegra_kbc_open(struct input_dev *dev)
455{
456 struct tegra_kbc *kbc = input_get_drvdata(dev);
457
458 return tegra_kbc_start(kbc);
459}
460
461static void tegra_kbc_close(struct input_dev *dev)
462{
463 struct tegra_kbc *kbc = input_get_drvdata(dev);
464
465 return tegra_kbc_stop(kbc);
466}
467
468static bool __devinit
469tegra_kbc_check_pin_cfg(const struct tegra_kbc_platform_data *pdata,
470 struct device *dev, unsigned int *num_rows)
471{
472 int i;
473
474 *num_rows = 0;
475
476 for (i = 0; i < KBC_MAX_GPIO; i++) {
477 const struct tegra_kbc_pin_cfg *pin_cfg = &pdata->pin_cfg[i];
478
479 if (pin_cfg->is_row) {
480 if (pin_cfg->num >= KBC_MAX_ROW) {
481 dev_err(dev,
482 "pin_cfg[%d]: invalid row number %d\n",
483 i, pin_cfg->num);
484 return false;
485 }
486 (*num_rows)++;
487 } else {
488 if (pin_cfg->num >= KBC_MAX_COL) {
489 dev_err(dev,
490 "pin_cfg[%d]: invalid column number %d\n",
491 i, pin_cfg->num);
492 return false;
493 }
494 }
495 }
496
497 return true;
498}
499
500static int __devinit tegra_kbc_probe(struct platform_device *pdev)
501{
502 const struct tegra_kbc_platform_data *pdata = pdev->dev.platform_data;
503 const struct matrix_keymap_data *keymap_data;
504 struct tegra_kbc *kbc;
505 struct input_dev *input_dev;
506 struct resource *res;
507 int irq;
508 int err;
509 int i;
510 int num_rows = 0;
511 unsigned int debounce_cnt;
512 unsigned int scan_time_rows;
513
514 if (!pdata)
515 return -EINVAL;
516
517 if (!tegra_kbc_check_pin_cfg(pdata, &pdev->dev, &num_rows))
518 return -EINVAL;
519
520 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
521 if (!res) {
522 dev_err(&pdev->dev, "failed to get I/O memory\n");
523 return -ENXIO;
524 }
525
526 irq = platform_get_irq(pdev, 0);
527 if (irq < 0) {
528 dev_err(&pdev->dev, "failed to get keyboard IRQ\n");
529 return -ENXIO;
530 }
531
532 kbc = kzalloc(sizeof(*kbc), GFP_KERNEL);
533 input_dev = input_allocate_device();
534 if (!kbc || !input_dev) {
535 err = -ENOMEM;
536 goto err_free_mem;
537 }
538
539 kbc->pdata = pdata;
540 kbc->idev = input_dev;
541 kbc->irq = irq;
542 spin_lock_init(&kbc->lock);
543 setup_timer(&kbc->timer, tegra_kbc_keypress_timer, (unsigned long)kbc);
544
545 res = request_mem_region(res->start, resource_size(res), pdev->name);
546 if (!res) {
547 dev_err(&pdev->dev, "failed to request I/O memory\n");
548 err = -EBUSY;
549 goto err_free_mem;
550 }
551
552 kbc->mmio = ioremap(res->start, resource_size(res));
553 if (!kbc->mmio) {
554 dev_err(&pdev->dev, "failed to remap I/O memory\n");
555 err = -ENXIO;
556 goto err_free_mem_region;
557 }
558
559 kbc->clk = clk_get(&pdev->dev, NULL);
560 if (IS_ERR(kbc->clk)) {
561 dev_err(&pdev->dev, "failed to get keyboard clock\n");
562 err = PTR_ERR(kbc->clk);
563 goto err_iounmap;
564 }
565
566 kbc->wake_enable_rows = 0;
567 kbc->wake_enable_cols = 0;
568 for (i = 0; i < pdata->wake_cnt; i++) {
569 kbc->wake_enable_rows |= (1 << pdata->wake_cfg[i].row);
570 kbc->wake_enable_cols |= (1 << pdata->wake_cfg[i].col);
571 }
572
573 /*
574 * The time delay between two consecutive reads of the FIFO is
575 * the sum of the repeat time and the time taken for scanning
576 * the rows. There is an additional delay before the row scanning
577 * starts. The repoll delay is computed in milliseconds.
578 */
579 debounce_cnt = min(pdata->debounce_cnt, KBC_MAX_DEBOUNCE_CNT);
580 scan_time_rows = (KBC_ROW_SCAN_TIME + debounce_cnt) * num_rows;
581 kbc->repoll_dly = KBC_ROW_SCAN_DLY + scan_time_rows + pdata->repeat_cnt;
582 kbc->repoll_dly = ((kbc->repoll_dly * KBC_CYCLE_USEC) + 999) / 1000;
583
584 input_dev->name = pdev->name;
585 input_dev->id.bustype = BUS_HOST;
586 input_dev->dev.parent = &pdev->dev;
587 input_dev->open = tegra_kbc_open;
588 input_dev->close = tegra_kbc_close;
589
590 input_set_drvdata(input_dev, kbc);
591
592 input_dev->evbit[0] = BIT_MASK(EV_KEY);
593 input_set_capability(input_dev, EV_MSC, MSC_SCAN);
594
595 input_dev->keycode = kbc->keycode;
596 input_dev->keycodesize = sizeof(kbc->keycode[0]);
597 input_dev->keycodemax = ARRAY_SIZE(kbc->keycode);
598
599 keymap_data = pdata->keymap_data ?: &tegra_kbc_default_keymap_data;
600 matrix_keypad_build_keymap(keymap_data, KBC_ROW_SHIFT,
601 input_dev->keycode, input_dev->keybit);
602
603 err = request_irq(kbc->irq, tegra_kbc_isr, IRQF_TRIGGER_HIGH,
604 pdev->name, kbc);
605 if (err) {
606 dev_err(&pdev->dev, "failed to request keyboard IRQ\n");
607 goto err_put_clk;
608 }
609
610 disable_irq(kbc->irq);
611
612 err = input_register_device(kbc->idev);
613 if (err) {
614 dev_err(&pdev->dev, "failed to register input device\n");
615 goto err_free_irq;
616 }
617
618 platform_set_drvdata(pdev, kbc);
619 device_init_wakeup(&pdev->dev, pdata->wakeup);
620
621 return 0;
622
623err_free_irq:
624 free_irq(kbc->irq, pdev);
625err_put_clk:
626 clk_put(kbc->clk);
627err_iounmap:
628 iounmap(kbc->mmio);
629err_free_mem_region:
630 release_mem_region(res->start, resource_size(res));
631err_free_mem:
632 input_free_device(kbc->idev);
633 kfree(kbc);
634
635 return err;
636}
637
638static int __devexit tegra_kbc_remove(struct platform_device *pdev)
639{
640 struct tegra_kbc *kbc = platform_get_drvdata(pdev);
641 struct resource *res;
642
643 free_irq(kbc->irq, pdev);
644 clk_put(kbc->clk);
645
646 input_unregister_device(kbc->idev);
647 iounmap(kbc->mmio);
648 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
649 release_mem_region(res->start, resource_size(res));
650
651 kfree(kbc);
652
653 platform_set_drvdata(pdev, NULL);
654
655 return 0;
656}
657
658#ifdef CONFIG_PM_SLEEP
659static int tegra_kbc_suspend(struct device *dev)
660{
661 struct platform_device *pdev = to_platform_device(dev);
662 struct tegra_kbc *kbc = platform_get_drvdata(pdev);
663
664 if (device_may_wakeup(&pdev->dev)) {
665 tegra_kbc_setup_wakekeys(kbc, true);
666 enable_irq_wake(kbc->irq);
667 /* Forcefully clear the interrupt status */
668 writel(0x7, kbc->mmio + KBC_INT_0);
669 msleep(30);
670 } else {
671 mutex_lock(&kbc->idev->mutex);
672 if (kbc->idev->users)
673 tegra_kbc_stop(kbc);
674 mutex_unlock(&kbc->idev->mutex);
675 }
676
677 return 0;
678}
679
680static int tegra_kbc_resume(struct device *dev)
681{
682 struct platform_device *pdev = to_platform_device(dev);
683 struct tegra_kbc *kbc = platform_get_drvdata(pdev);
684 int err = 0;
685
686 if (device_may_wakeup(&pdev->dev)) {
687 disable_irq_wake(kbc->irq);
688 tegra_kbc_setup_wakekeys(kbc, false);
689 } else {
690 mutex_lock(&kbc->idev->mutex);
691 if (kbc->idev->users)
692 err = tegra_kbc_start(kbc);
693 mutex_unlock(&kbc->idev->mutex);
694 }
695
696 return err;
697}
698#endif
699
700static SIMPLE_DEV_PM_OPS(tegra_kbc_pm_ops, tegra_kbc_suspend, tegra_kbc_resume);
701
702static struct platform_driver tegra_kbc_driver = {
703 .probe = tegra_kbc_probe,
704 .remove = __devexit_p(tegra_kbc_remove),
705 .driver = {
706 .name = "tegra-kbc",
707 .owner = THIS_MODULE,
708 .pm = &tegra_kbc_pm_ops,
709 },
710};
711
712static void __exit tegra_kbc_exit(void)
713{
714 platform_driver_unregister(&tegra_kbc_driver);
715}
716module_exit(tegra_kbc_exit);
717
718static int __init tegra_kbc_init(void)
719{
720 return platform_driver_register(&tegra_kbc_driver);
721}
722module_init(tegra_kbc_init);
723
724MODULE_LICENSE("GPL");
725MODULE_AUTHOR("Rakesh Iyer <riyer@nvidia.com>");
726MODULE_DESCRIPTION("Tegra matrix keyboard controller driver");
727MODULE_ALIAS("platform:tegra-kbc");
diff --git a/drivers/input/keyboard/tnetv107x-keypad.c b/drivers/input/keyboard/tnetv107x-keypad.c
index b4a81ebfab92..c8f097a15d89 100644
--- a/drivers/input/keyboard/tnetv107x-keypad.c
+++ b/drivers/input/keyboard/tnetv107x-keypad.c
@@ -14,6 +14,7 @@
14 */ 14 */
15 15
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/err.h>
17#include <linux/errno.h> 18#include <linux/errno.h>
18#include <linux/input.h> 19#include <linux/input.h>
19#include <linux/platform_device.h> 20#include <linux/platform_device.h>
@@ -219,9 +220,9 @@ static int __devinit keypad_probe(struct platform_device *pdev)
219 } 220 }
220 221
221 kp->clk = clk_get(dev, NULL); 222 kp->clk = clk_get(dev, NULL);
222 if (!kp->clk) { 223 if (IS_ERR(kp->clk)) {
223 dev_err(dev, "cannot claim device clock\n"); 224 dev_err(dev, "cannot claim device clock\n");
224 error = -EINVAL; 225 error = PTR_ERR(kp->clk);
225 goto error_clk; 226 goto error_clk;
226 } 227 }
227 228
diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig
index bf5fd7f6a313..9c1e6ee83531 100644
--- a/drivers/input/mouse/Kconfig
+++ b/drivers/input/mouse/Kconfig
@@ -39,7 +39,7 @@ config MOUSE_PS2
39 module will be called psmouse. 39 module will be called psmouse.
40 40
41config MOUSE_PS2_ALPS 41config MOUSE_PS2_ALPS
42 bool "ALPS PS/2 mouse protocol extension" if EMBEDDED 42 bool "ALPS PS/2 mouse protocol extension" if EXPERT
43 default y 43 default y
44 depends on MOUSE_PS2 44 depends on MOUSE_PS2
45 help 45 help
@@ -49,7 +49,7 @@ config MOUSE_PS2_ALPS
49 If unsure, say Y. 49 If unsure, say Y.
50 50
51config MOUSE_PS2_LOGIPS2PP 51config MOUSE_PS2_LOGIPS2PP
52 bool "Logitech PS/2++ mouse protocol extension" if EMBEDDED 52 bool "Logitech PS/2++ mouse protocol extension" if EXPERT
53 default y 53 default y
54 depends on MOUSE_PS2 54 depends on MOUSE_PS2
55 help 55 help
@@ -59,7 +59,7 @@ config MOUSE_PS2_LOGIPS2PP
59 If unsure, say Y. 59 If unsure, say Y.
60 60
61config MOUSE_PS2_SYNAPTICS 61config MOUSE_PS2_SYNAPTICS
62 bool "Synaptics PS/2 mouse protocol extension" if EMBEDDED 62 bool "Synaptics PS/2 mouse protocol extension" if EXPERT
63 default y 63 default y
64 depends on MOUSE_PS2 64 depends on MOUSE_PS2
65 help 65 help
@@ -69,7 +69,7 @@ config MOUSE_PS2_SYNAPTICS
69 If unsure, say Y. 69 If unsure, say Y.
70 70
71config MOUSE_PS2_LIFEBOOK 71config MOUSE_PS2_LIFEBOOK
72 bool "Fujitsu Lifebook PS/2 mouse protocol extension" if EMBEDDED 72 bool "Fujitsu Lifebook PS/2 mouse protocol extension" if EXPERT
73 default y 73 default y
74 depends on MOUSE_PS2 && X86 && DMI 74 depends on MOUSE_PS2 && X86 && DMI
75 help 75 help
@@ -79,7 +79,7 @@ config MOUSE_PS2_LIFEBOOK
79 If unsure, say Y. 79 If unsure, say Y.
80 80
81config MOUSE_PS2_TRACKPOINT 81config MOUSE_PS2_TRACKPOINT
82 bool "IBM Trackpoint PS/2 mouse protocol extension" if EMBEDDED 82 bool "IBM Trackpoint PS/2 mouse protocol extension" if EXPERT
83 default y 83 default y
84 depends on MOUSE_PS2 84 depends on MOUSE_PS2
85 help 85 help
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index da392c22fc6c..aa186cf6c514 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -755,23 +755,26 @@ static int synaptics_reconnect(struct psmouse *psmouse)
755{ 755{
756 struct synaptics_data *priv = psmouse->private; 756 struct synaptics_data *priv = psmouse->private;
757 struct synaptics_data old_priv = *priv; 757 struct synaptics_data old_priv = *priv;
758 int retry = 0;
759 int error;
758 760
759 psmouse_reset(psmouse); 761 do {
762 psmouse_reset(psmouse);
763 error = synaptics_detect(psmouse, 0);
764 } while (error && ++retry < 3);
760 765
761 if (synaptics_detect(psmouse, 0)) 766 if (error)
762 return -1; 767 return -1;
763 768
769 if (retry > 1)
770 printk(KERN_DEBUG "Synaptics reconnected after %d tries\n",
771 retry);
772
764 if (synaptics_query_hardware(psmouse)) { 773 if (synaptics_query_hardware(psmouse)) {
765 printk(KERN_ERR "Unable to query Synaptics hardware.\n"); 774 printk(KERN_ERR "Unable to query Synaptics hardware.\n");
766 return -1; 775 return -1;
767 } 776 }
768 777
769 if (old_priv.identity != priv->identity ||
770 old_priv.model_id != priv->model_id ||
771 old_priv.capabilities != priv->capabilities ||
772 old_priv.ext_cap != priv->ext_cap)
773 return -1;
774
775 if (synaptics_set_absolute_mode(psmouse)) { 778 if (synaptics_set_absolute_mode(psmouse)) {
776 printk(KERN_ERR "Unable to initialize Synaptics hardware.\n"); 779 printk(KERN_ERR "Unable to initialize Synaptics hardware.\n");
777 return -1; 780 return -1;
@@ -782,6 +785,19 @@ static int synaptics_reconnect(struct psmouse *psmouse)
782 return -1; 785 return -1;
783 } 786 }
784 787
788 if (old_priv.identity != priv->identity ||
789 old_priv.model_id != priv->model_id ||
790 old_priv.capabilities != priv->capabilities ||
791 old_priv.ext_cap != priv->ext_cap) {
792 printk(KERN_ERR "Synaptics hardware appears to be different: "
793 "id(%ld-%ld), model(%ld-%ld), caps(%lx-%lx), ext(%lx-%lx).\n",
794 old_priv.identity, priv->identity,
795 old_priv.model_id, priv->model_id,
796 old_priv.capabilities, priv->capabilities,
797 old_priv.ext_cap, priv->ext_cap);
798 return -1;
799 }
800
785 return 0; 801 return 0;
786} 802}
787 803
diff --git a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig
index 307eef77a172..55f2c2293ec6 100644
--- a/drivers/input/serio/Kconfig
+++ b/drivers/input/serio/Kconfig
@@ -2,7 +2,7 @@
2# Input core configuration 2# Input core configuration
3# 3#
4config SERIO 4config SERIO
5 tristate "Serial I/O support" if EMBEDDED || !X86 5 tristate "Serial I/O support" if EXPERT || !X86
6 default y 6 default y
7 help 7 help
8 Say Yes here if you have any input device that uses serial I/O to 8 Say Yes here if you have any input device that uses serial I/O to
@@ -19,7 +19,7 @@ config SERIO
19if SERIO 19if SERIO
20 20
21config SERIO_I8042 21config SERIO_I8042
22 tristate "i8042 PC Keyboard controller" if EMBEDDED || !X86 22 tristate "i8042 PC Keyboard controller" if EXPERT || !X86
23 default y 23 default y
24 depends on !PARISC && (!ARM || ARCH_SHARK || FOOTBRIDGE_HOST) && \ 24 depends on !PARISC && (!ARM || ARCH_SHARK || FOOTBRIDGE_HOST) && \
25 (!SUPERH || SH_CAYMAN) && !M68K && !BLACKFIN 25 (!SUPERH || SH_CAYMAN) && !M68K && !BLACKFIN
@@ -168,7 +168,7 @@ config SERIO_MACEPS2
168 module will be called maceps2. 168 module will be called maceps2.
169 169
170config SERIO_LIBPS2 170config SERIO_LIBPS2
171 tristate "PS/2 driver library" if EMBEDDED 171 tristate "PS/2 driver library" if EXPERT
172 depends on SERIO_I8042 || SERIO_I8042=n 172 depends on SERIO_I8042 || SERIO_I8042=n
173 help 173 help
174 Say Y here if you are using a driver for device connected 174 Say Y here if you are using a driver for device connected
diff --git a/drivers/input/serio/ct82c710.c b/drivers/input/serio/ct82c710.c
index 448c7724beb9..852816567241 100644
--- a/drivers/input/serio/ct82c710.c
+++ b/drivers/input/serio/ct82c710.c
@@ -111,9 +111,11 @@ static void ct82c710_close(struct serio *serio)
111static int ct82c710_open(struct serio *serio) 111static int ct82c710_open(struct serio *serio)
112{ 112{
113 unsigned char status; 113 unsigned char status;
114 int err;
114 115
115 if (request_irq(CT82C710_IRQ, ct82c710_interrupt, 0, "ct82c710", NULL)) 116 err = request_irq(CT82C710_IRQ, ct82c710_interrupt, 0, "ct82c710", NULL);
116 return -1; 117 if (err)
118 return err;
117 119
118 status = inb_p(CT82C710_STATUS); 120 status = inb_p(CT82C710_STATUS);
119 121
@@ -131,7 +133,7 @@ static int ct82c710_open(struct serio *serio)
131 status &= ~(CT82C710_ENABLE | CT82C710_INTS_ON); 133 status &= ~(CT82C710_ENABLE | CT82C710_INTS_ON);
132 outb_p(status, CT82C710_STATUS); 134 outb_p(status, CT82C710_STATUS);
133 free_irq(CT82C710_IRQ, NULL); 135 free_irq(CT82C710_IRQ, NULL);
134 return -1; 136 return -EBUSY;
135 } 137 }
136 138
137 return 0; 139 return 0;
diff --git a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c
index 6e362de3f412..8755f5f3ad37 100644
--- a/drivers/input/serio/serport.c
+++ b/drivers/input/serio/serport.c
@@ -116,14 +116,15 @@ static void serport_ldisc_close(struct tty_struct *tty)
116 116
117/* 117/*
118 * serport_ldisc_receive() is called by the low level tty driver when characters 118 * serport_ldisc_receive() is called by the low level tty driver when characters
119 * are ready for us. We forward the characters, one by one to the 'interrupt' 119 * are ready for us. We forward the characters and flags, one by one to the
120 * routine. 120 * 'interrupt' routine.
121 */ 121 */
122 122
123static void serport_ldisc_receive(struct tty_struct *tty, const unsigned char *cp, char *fp, int count) 123static void serport_ldisc_receive(struct tty_struct *tty, const unsigned char *cp, char *fp, int count)
124{ 124{
125 struct serport *serport = (struct serport*) tty->disc_data; 125 struct serport *serport = (struct serport*) tty->disc_data;
126 unsigned long flags; 126 unsigned long flags;
127 unsigned int ch_flags;
127 int i; 128 int i;
128 129
129 spin_lock_irqsave(&serport->lock, flags); 130 spin_lock_irqsave(&serport->lock, flags);
@@ -131,8 +132,23 @@ static void serport_ldisc_receive(struct tty_struct *tty, const unsigned char *c
131 if (!test_bit(SERPORT_ACTIVE, &serport->flags)) 132 if (!test_bit(SERPORT_ACTIVE, &serport->flags))
132 goto out; 133 goto out;
133 134
134 for (i = 0; i < count; i++) 135 for (i = 0; i < count; i++) {
135 serio_interrupt(serport->serio, cp[i], 0); 136 switch (fp[i]) {
137 case TTY_FRAME:
138 ch_flags = SERIO_FRAME;
139 break;
140
141 case TTY_PARITY:
142 ch_flags = SERIO_PARITY;
143 break;
144
145 default:
146 ch_flags = 0;
147 break;
148 }
149
150 serio_interrupt(serport->serio, cp[i], ch_flags);
151 }
136 152
137out: 153out:
138 spin_unlock_irqrestore(&serport->lock, flags); 154 spin_unlock_irqrestore(&serport->lock, flags);
diff --git a/drivers/input/sparse-keymap.c b/drivers/input/sparse-keymap.c
index a29a7812bd46..7729e547ba65 100644
--- a/drivers/input/sparse-keymap.c
+++ b/drivers/input/sparse-keymap.c
@@ -201,6 +201,7 @@ int sparse_keymap_setup(struct input_dev *dev,
201 break; 201 break;
202 202
203 case KE_SW: 203 case KE_SW:
204 case KE_VSW:
204 __set_bit(EV_SW, dev->evbit); 205 __set_bit(EV_SW, dev->evbit);
205 __set_bit(entry->sw.code, dev->swbit); 206 __set_bit(entry->sw.code, dev->swbit);
206 break; 207 break;
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index 518782999fea..367fa82a607e 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -1101,6 +1101,13 @@ void wacom_setup_device_quirks(struct wacom_features *features)
1101 } 1101 }
1102} 1102}
1103 1103
1104static unsigned int wacom_calculate_touch_res(unsigned int logical_max,
1105 unsigned int physical_max)
1106{
1107 /* Touch physical dimensions are in 100th of mm */
1108 return (logical_max * 100) / physical_max;
1109}
1110
1104void wacom_setup_input_capabilities(struct input_dev *input_dev, 1111void wacom_setup_input_capabilities(struct input_dev *input_dev,
1105 struct wacom_wac *wacom_wac) 1112 struct wacom_wac *wacom_wac)
1106{ 1113{
@@ -1228,8 +1235,12 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev,
1228 case TABLETPC: 1235 case TABLETPC:
1229 if (features->device_type == BTN_TOOL_DOUBLETAP || 1236 if (features->device_type == BTN_TOOL_DOUBLETAP ||
1230 features->device_type == BTN_TOOL_TRIPLETAP) { 1237 features->device_type == BTN_TOOL_TRIPLETAP) {
1231 input_set_abs_params(input_dev, ABS_RX, 0, features->x_phy, 0, 0); 1238 input_abs_set_res(input_dev, ABS_X,
1232 input_set_abs_params(input_dev, ABS_RY, 0, features->y_phy, 0, 0); 1239 wacom_calculate_touch_res(features->x_max,
1240 features->x_phy));
1241 input_abs_set_res(input_dev, ABS_Y,
1242 wacom_calculate_touch_res(features->y_max,
1243 features->y_phy));
1233 __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); 1244 __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
1234 } 1245 }
1235 1246
@@ -1272,6 +1283,12 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev,
1272 input_set_abs_params(input_dev, ABS_MT_PRESSURE, 1283 input_set_abs_params(input_dev, ABS_MT_PRESSURE,
1273 0, features->pressure_max, 1284 0, features->pressure_max,
1274 features->pressure_fuzz, 0); 1285 features->pressure_fuzz, 0);
1286 input_abs_set_res(input_dev, ABS_X,
1287 wacom_calculate_touch_res(features->x_max,
1288 features->x_phy));
1289 input_abs_set_res(input_dev, ABS_Y,
1290 wacom_calculate_touch_res(features->y_max,
1291 features->y_phy));
1275 } else if (features->device_type == BTN_TOOL_PEN) { 1292 } else if (features->device_type == BTN_TOOL_PEN) {
1276 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); 1293 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1277 __set_bit(BTN_TOOL_PEN, input_dev->keybit); 1294 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
@@ -1426,6 +1443,10 @@ static struct wacom_features wacom_features_0xD3 =
1426 { "Wacom Bamboo 2FG 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023, 63, BAMBOO_PT }; 1443 { "Wacom Bamboo 2FG 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023, 63, BAMBOO_PT };
1427static const struct wacom_features wacom_features_0xD4 = 1444static const struct wacom_features wacom_features_0xD4 =
1428 { "Wacom Bamboo Pen", WACOM_PKGLEN_BBFUN, 14720, 9200, 255, 63, BAMBOO_PT }; 1445 { "Wacom Bamboo Pen", WACOM_PKGLEN_BBFUN, 14720, 9200, 255, 63, BAMBOO_PT };
1446static struct wacom_features wacom_features_0xD6 =
1447 { "Wacom BambooPT 2FG 4x5", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT };
1448static struct wacom_features wacom_features_0xD7 =
1449 { "Wacom BambooPT 2FG Small", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT };
1429static struct wacom_features wacom_features_0xD8 = 1450static struct wacom_features wacom_features_0xD8 =
1430 { "Wacom Bamboo Comic 2FG", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023, 63, BAMBOO_PT }; 1451 { "Wacom Bamboo Comic 2FG", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023, 63, BAMBOO_PT };
1431static struct wacom_features wacom_features_0xDA = 1452static struct wacom_features wacom_features_0xDA =
@@ -1507,6 +1528,8 @@ const struct usb_device_id wacom_ids[] = {
1507 { USB_DEVICE_WACOM(0xD2) }, 1528 { USB_DEVICE_WACOM(0xD2) },
1508 { USB_DEVICE_WACOM(0xD3) }, 1529 { USB_DEVICE_WACOM(0xD3) },
1509 { USB_DEVICE_WACOM(0xD4) }, 1530 { USB_DEVICE_WACOM(0xD4) },
1531 { USB_DEVICE_WACOM(0xD6) },
1532 { USB_DEVICE_WACOM(0xD7) },
1510 { USB_DEVICE_WACOM(0xD8) }, 1533 { USB_DEVICE_WACOM(0xD8) },
1511 { USB_DEVICE_WACOM(0xDA) }, 1534 { USB_DEVICE_WACOM(0xDA) },
1512 { USB_DEVICE_WACOM(0xDB) }, 1535 { USB_DEVICE_WACOM(0xDB) },
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 0c9f4b158ff0..61834ae282e1 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -540,62 +540,62 @@ config TOUCHSCREEN_MC13783
540 540
541config TOUCHSCREEN_USB_EGALAX 541config TOUCHSCREEN_USB_EGALAX
542 default y 542 default y
543 bool "eGalax, eTurboTouch CT-410/510/700 device support" if EMBEDDED 543 bool "eGalax, eTurboTouch CT-410/510/700 device support" if EXPERT
544 depends on TOUCHSCREEN_USB_COMPOSITE 544 depends on TOUCHSCREEN_USB_COMPOSITE
545 545
546config TOUCHSCREEN_USB_PANJIT 546config TOUCHSCREEN_USB_PANJIT
547 default y 547 default y
548 bool "PanJit device support" if EMBEDDED 548 bool "PanJit device support" if EXPERT
549 depends on TOUCHSCREEN_USB_COMPOSITE 549 depends on TOUCHSCREEN_USB_COMPOSITE
550 550
551config TOUCHSCREEN_USB_3M 551config TOUCHSCREEN_USB_3M
552 default y 552 default y
553 bool "3M/Microtouch EX II series device support" if EMBEDDED 553 bool "3M/Microtouch EX II series device support" if EXPERT
554 depends on TOUCHSCREEN_USB_COMPOSITE 554 depends on TOUCHSCREEN_USB_COMPOSITE
555 555
556config TOUCHSCREEN_USB_ITM 556config TOUCHSCREEN_USB_ITM
557 default y 557 default y
558 bool "ITM device support" if EMBEDDED 558 bool "ITM device support" if EXPERT
559 depends on TOUCHSCREEN_USB_COMPOSITE 559 depends on TOUCHSCREEN_USB_COMPOSITE
560 560
561config TOUCHSCREEN_USB_ETURBO 561config TOUCHSCREEN_USB_ETURBO
562 default y 562 default y
563 bool "eTurboTouch (non-eGalax compatible) device support" if EMBEDDED 563 bool "eTurboTouch (non-eGalax compatible) device support" if EXPERT
564 depends on TOUCHSCREEN_USB_COMPOSITE 564 depends on TOUCHSCREEN_USB_COMPOSITE
565 565
566config TOUCHSCREEN_USB_GUNZE 566config TOUCHSCREEN_USB_GUNZE
567 default y 567 default y
568 bool "Gunze AHL61 device support" if EMBEDDED 568 bool "Gunze AHL61 device support" if EXPERT
569 depends on TOUCHSCREEN_USB_COMPOSITE 569 depends on TOUCHSCREEN_USB_COMPOSITE
570 570
571config TOUCHSCREEN_USB_DMC_TSC10 571config TOUCHSCREEN_USB_DMC_TSC10
572 default y 572 default y
573 bool "DMC TSC-10/25 device support" if EMBEDDED 573 bool "DMC TSC-10/25 device support" if EXPERT
574 depends on TOUCHSCREEN_USB_COMPOSITE 574 depends on TOUCHSCREEN_USB_COMPOSITE
575 575
576config TOUCHSCREEN_USB_IRTOUCH 576config TOUCHSCREEN_USB_IRTOUCH
577 default y 577 default y
578 bool "IRTOUCHSYSTEMS/UNITOP device support" if EMBEDDED 578 bool "IRTOUCHSYSTEMS/UNITOP device support" if EXPERT
579 depends on TOUCHSCREEN_USB_COMPOSITE 579 depends on TOUCHSCREEN_USB_COMPOSITE
580 580
581config TOUCHSCREEN_USB_IDEALTEK 581config TOUCHSCREEN_USB_IDEALTEK
582 default y 582 default y
583 bool "IdealTEK URTC1000 device support" if EMBEDDED 583 bool "IdealTEK URTC1000 device support" if EXPERT
584 depends on TOUCHSCREEN_USB_COMPOSITE 584 depends on TOUCHSCREEN_USB_COMPOSITE
585 585
586config TOUCHSCREEN_USB_GENERAL_TOUCH 586config TOUCHSCREEN_USB_GENERAL_TOUCH
587 default y 587 default y
588 bool "GeneralTouch Touchscreen device support" if EMBEDDED 588 bool "GeneralTouch Touchscreen device support" if EXPERT
589 depends on TOUCHSCREEN_USB_COMPOSITE 589 depends on TOUCHSCREEN_USB_COMPOSITE
590 590
591config TOUCHSCREEN_USB_GOTOP 591config TOUCHSCREEN_USB_GOTOP
592 default y 592 default y
593 bool "GoTop Super_Q2/GogoPen/PenPower tablet device support" if EMBEDDED 593 bool "GoTop Super_Q2/GogoPen/PenPower tablet device support" if EXPERT
594 depends on TOUCHSCREEN_USB_COMPOSITE 594 depends on TOUCHSCREEN_USB_COMPOSITE
595 595
596config TOUCHSCREEN_USB_JASTEC 596config TOUCHSCREEN_USB_JASTEC
597 default y 597 default y
598 bool "JASTEC/DigiTech DTR-02U USB touch controller device support" if EMBEDDED 598 bool "JASTEC/DigiTech DTR-02U USB touch controller device support" if EXPERT
599 depends on TOUCHSCREEN_USB_COMPOSITE 599 depends on TOUCHSCREEN_USB_COMPOSITE
600 600
601config TOUCHSCREEN_USB_E2I 601config TOUCHSCREEN_USB_E2I
@@ -605,17 +605,17 @@ config TOUCHSCREEN_USB_E2I
605 605
606config TOUCHSCREEN_USB_ZYTRONIC 606config TOUCHSCREEN_USB_ZYTRONIC
607 default y 607 default y
608 bool "Zytronic controller" if EMBEDDED 608 bool "Zytronic controller" if EXPERT
609 depends on TOUCHSCREEN_USB_COMPOSITE 609 depends on TOUCHSCREEN_USB_COMPOSITE
610 610
611config TOUCHSCREEN_USB_ETT_TC45USB 611config TOUCHSCREEN_USB_ETT_TC45USB
612 default y 612 default y
613 bool "ET&T USB series TC4UM/TC5UH touchscreen controller support" if EMBEDDED 613 bool "ET&T USB series TC4UM/TC5UH touchscreen controller support" if EXPERT
614 depends on TOUCHSCREEN_USB_COMPOSITE 614 depends on TOUCHSCREEN_USB_COMPOSITE
615 615
616config TOUCHSCREEN_USB_NEXIO 616config TOUCHSCREEN_USB_NEXIO
617 default y 617 default y
618 bool "NEXIO/iNexio device support" if EMBEDDED 618 bool "NEXIO/iNexio device support" if EXPERT
619 depends on TOUCHSCREEN_USB_COMPOSITE 619 depends on TOUCHSCREEN_USB_COMPOSITE
620 620
621config TOUCHSCREEN_TOUCHIT213 621config TOUCHSCREEN_TOUCHIT213
diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
index f7fa9ef4cd65..1507ce108d5b 100644
--- a/drivers/input/touchscreen/bu21013_ts.c
+++ b/drivers/input/touchscreen/bu21013_ts.c
@@ -12,6 +12,7 @@
12#include <linux/input.h> 12#include <linux/input.h>
13#include <linux/input/bu21013.h> 13#include <linux/input/bu21013.h>
14#include <linux/slab.h> 14#include <linux/slab.h>
15#include <linux/regulator/consumer.h>
15 16
16#define PEN_DOWN_INTR 0 17#define PEN_DOWN_INTR 0
17#define MAX_FINGERS 2 18#define MAX_FINGERS 2
@@ -139,6 +140,7 @@
139 * @chip: pointer to the touch panel controller 140 * @chip: pointer to the touch panel controller
140 * @in_dev: pointer to the input device structure 141 * @in_dev: pointer to the input device structure
141 * @intr_pin: interrupt pin value 142 * @intr_pin: interrupt pin value
143 * @regulator: pointer to the Regulator used for touch screen
142 * 144 *
143 * Touch panel device data structure 145 * Touch panel device data structure
144 */ 146 */
@@ -149,6 +151,7 @@ struct bu21013_ts_data {
149 const struct bu21013_platform_device *chip; 151 const struct bu21013_platform_device *chip;
150 struct input_dev *in_dev; 152 struct input_dev *in_dev;
151 unsigned int intr_pin; 153 unsigned int intr_pin;
154 struct regulator *regulator;
152}; 155};
153 156
154/** 157/**
@@ -456,6 +459,20 @@ static int __devinit bu21013_probe(struct i2c_client *client,
456 bu21013_data->in_dev = in_dev; 459 bu21013_data->in_dev = in_dev;
457 bu21013_data->chip = pdata; 460 bu21013_data->chip = pdata;
458 bu21013_data->client = client; 461 bu21013_data->client = client;
462
463 bu21013_data->regulator = regulator_get(&client->dev, "V-TOUCH");
464 if (IS_ERR(bu21013_data->regulator)) {
465 dev_err(&client->dev, "regulator_get failed\n");
466 error = PTR_ERR(bu21013_data->regulator);
467 goto err_free_mem;
468 }
469
470 error = regulator_enable(bu21013_data->regulator);
471 if (error < 0) {
472 dev_err(&client->dev, "regulator enable failed\n");
473 goto err_put_regulator;
474 }
475
459 bu21013_data->touch_stopped = false; 476 bu21013_data->touch_stopped = false;
460 init_waitqueue_head(&bu21013_data->wait); 477 init_waitqueue_head(&bu21013_data->wait);
461 478
@@ -464,7 +481,7 @@ static int __devinit bu21013_probe(struct i2c_client *client,
464 error = pdata->cs_en(pdata->cs_pin); 481 error = pdata->cs_en(pdata->cs_pin);
465 if (error < 0) { 482 if (error < 0) {
466 dev_err(&client->dev, "chip init failed\n"); 483 dev_err(&client->dev, "chip init failed\n");
467 goto err_free_mem; 484 goto err_disable_regulator;
468 } 485 }
469 } 486 }
470 487
@@ -485,9 +502,9 @@ static int __devinit bu21013_probe(struct i2c_client *client,
485 __set_bit(EV_ABS, in_dev->evbit); 502 __set_bit(EV_ABS, in_dev->evbit);
486 503
487 input_set_abs_params(in_dev, ABS_MT_POSITION_X, 0, 504 input_set_abs_params(in_dev, ABS_MT_POSITION_X, 0,
488 pdata->x_max_res, 0, 0); 505 pdata->touch_x_max, 0, 0);
489 input_set_abs_params(in_dev, ABS_MT_POSITION_Y, 0, 506 input_set_abs_params(in_dev, ABS_MT_POSITION_Y, 0,
490 pdata->y_max_res, 0, 0); 507 pdata->touch_y_max, 0, 0);
491 input_set_drvdata(in_dev, bu21013_data); 508 input_set_drvdata(in_dev, bu21013_data);
492 509
493 error = request_threaded_irq(pdata->irq, NULL, bu21013_gpio_irq, 510 error = request_threaded_irq(pdata->irq, NULL, bu21013_gpio_irq,
@@ -513,6 +530,10 @@ err_free_irq:
513 bu21013_free_irq(bu21013_data); 530 bu21013_free_irq(bu21013_data);
514err_cs_disable: 531err_cs_disable:
515 pdata->cs_dis(pdata->cs_pin); 532 pdata->cs_dis(pdata->cs_pin);
533err_disable_regulator:
534 regulator_disable(bu21013_data->regulator);
535err_put_regulator:
536 regulator_put(bu21013_data->regulator);
516err_free_mem: 537err_free_mem:
517 input_free_device(in_dev); 538 input_free_device(in_dev);
518 kfree(bu21013_data); 539 kfree(bu21013_data);
@@ -535,6 +556,10 @@ static int __devexit bu21013_remove(struct i2c_client *client)
535 bu21013_data->chip->cs_dis(bu21013_data->chip->cs_pin); 556 bu21013_data->chip->cs_dis(bu21013_data->chip->cs_pin);
536 557
537 input_unregister_device(bu21013_data->in_dev); 558 input_unregister_device(bu21013_data->in_dev);
559
560 regulator_disable(bu21013_data->regulator);
561 regulator_put(bu21013_data->regulator);
562
538 kfree(bu21013_data); 563 kfree(bu21013_data);
539 564
540 device_init_wakeup(&client->dev, false); 565 device_init_wakeup(&client->dev, false);
@@ -561,6 +586,8 @@ static int bu21013_suspend(struct device *dev)
561 else 586 else
562 disable_irq(bu21013_data->chip->irq); 587 disable_irq(bu21013_data->chip->irq);
563 588
589 regulator_disable(bu21013_data->regulator);
590
564 return 0; 591 return 0;
565} 592}
566 593
@@ -577,6 +604,12 @@ static int bu21013_resume(struct device *dev)
577 struct i2c_client *client = bu21013_data->client; 604 struct i2c_client *client = bu21013_data->client;
578 int retval; 605 int retval;
579 606
607 retval = regulator_enable(bu21013_data->regulator);
608 if (retval < 0) {
609 dev_err(&client->dev, "bu21013 regulator enable failed\n");
610 return retval;
611 }
612
580 retval = bu21013_init_chip(bu21013_data); 613 retval = bu21013_init_chip(bu21013_data);
581 if (retval < 0) { 614 if (retval < 0) {
582 dev_err(&client->dev, "bu21013 controller config failed\n"); 615 dev_err(&client->dev, "bu21013 controller config failed\n");
diff --git a/drivers/input/touchscreen/tnetv107x-ts.c b/drivers/input/touchscreen/tnetv107x-ts.c
index cf1dba2e267c..22a3411e93c5 100644
--- a/drivers/input/touchscreen/tnetv107x-ts.c
+++ b/drivers/input/touchscreen/tnetv107x-ts.c
@@ -14,6 +14,7 @@
14 */ 14 */
15 15
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/err.h>
17#include <linux/errno.h> 18#include <linux/errno.h>
18#include <linux/input.h> 19#include <linux/input.h>
19#include <linux/platform_device.h> 20#include <linux/platform_device.h>
@@ -289,9 +290,9 @@ static int __devinit tsc_probe(struct platform_device *pdev)
289 } 290 }
290 291
291 ts->clk = clk_get(dev, NULL); 292 ts->clk = clk_get(dev, NULL);
292 if (!ts->clk) { 293 if (IS_ERR(ts->clk)) {
293 dev_err(dev, "cannot claim device clock\n"); 294 dev_err(dev, "cannot claim device clock\n");
294 error = -EINVAL; 295 error = PTR_ERR(ts->clk);
295 goto error_clk; 296 goto error_clk;
296 } 297 }
297 298
diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
index da3fa8dcdf5b..666daf77872e 100644
--- a/drivers/leds/leds-pwm.c
+++ b/drivers/leds/leds-pwm.c
@@ -69,6 +69,7 @@ static int led_pwm_probe(struct platform_device *pdev)
69 led_dat->pwm = pwm_request(cur_led->pwm_id, 69 led_dat->pwm = pwm_request(cur_led->pwm_id,
70 cur_led->name); 70 cur_led->name);
71 if (IS_ERR(led_dat->pwm)) { 71 if (IS_ERR(led_dat->pwm)) {
72 ret = PTR_ERR(led_dat->pwm);
72 dev_err(&pdev->dev, "unable to request PWM %d\n", 73 dev_err(&pdev->dev, "unable to request PWM %d\n",
73 cur_led->pwm_id); 74 cur_led->pwm_id);
74 goto err; 75 goto err;
diff --git a/drivers/leds/ledtrig-gpio.c b/drivers/leds/ledtrig-gpio.c
index 991d93be0f44..ecc4bf3f37a9 100644
--- a/drivers/leds/ledtrig-gpio.c
+++ b/drivers/leds/ledtrig-gpio.c
@@ -99,7 +99,7 @@ static ssize_t gpio_trig_inverted_show(struct device *dev,
99 struct led_classdev *led = dev_get_drvdata(dev); 99 struct led_classdev *led = dev_get_drvdata(dev);
100 struct gpio_trig_data *gpio_data = led->trigger_data; 100 struct gpio_trig_data *gpio_data = led->trigger_data;
101 101
102 return sprintf(buf, "%s\n", gpio_data->inverted ? "yes" : "no"); 102 return sprintf(buf, "%u\n", gpio_data->inverted);
103} 103}
104 104
105static ssize_t gpio_trig_inverted_store(struct device *dev, 105static ssize_t gpio_trig_inverted_store(struct device *dev,
@@ -107,16 +107,17 @@ static ssize_t gpio_trig_inverted_store(struct device *dev,
107{ 107{
108 struct led_classdev *led = dev_get_drvdata(dev); 108 struct led_classdev *led = dev_get_drvdata(dev);
109 struct gpio_trig_data *gpio_data = led->trigger_data; 109 struct gpio_trig_data *gpio_data = led->trigger_data;
110 unsigned inverted; 110 unsigned long inverted;
111 int ret; 111 int ret;
112 112
113 ret = sscanf(buf, "%u", &inverted); 113 ret = strict_strtoul(buf, 10, &inverted);
114 if (ret < 1) { 114 if (ret < 0)
115 dev_err(dev, "invalid value\n"); 115 return ret;
116
117 if (inverted > 1)
116 return -EINVAL; 118 return -EINVAL;
117 }
118 119
119 gpio_data->inverted = !!inverted; 120 gpio_data->inverted = inverted;
120 121
121 /* After inverting, we need to update the LED. */ 122 /* After inverting, we need to update the LED. */
122 schedule_work(&gpio_data->work); 123 schedule_work(&gpio_data->work);
diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
index 04b22128a474..d21578ee95de 100644
--- a/drivers/lguest/page_tables.c
+++ b/drivers/lguest/page_tables.c
@@ -1137,7 +1137,7 @@ void free_guest_pagetable(struct lguest *lg)
1137 */ 1137 */
1138void map_switcher_in_guest(struct lg_cpu *cpu, struct lguest_pages *pages) 1138void map_switcher_in_guest(struct lg_cpu *cpu, struct lguest_pages *pages)
1139{ 1139{
1140 pte_t *switcher_pte_page = __get_cpu_var(switcher_pte_pages); 1140 pte_t *switcher_pte_page = __this_cpu_read(switcher_pte_pages);
1141 pte_t regs_pte; 1141 pte_t regs_pte;
1142 1142
1143#ifdef CONFIG_X86_PAE 1143#ifdef CONFIG_X86_PAE
diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
index b4eb675a807e..9f1659c3d1f3 100644
--- a/drivers/lguest/x86/core.c
+++ b/drivers/lguest/x86/core.c
@@ -90,8 +90,8 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
90 * meanwhile). If that's not the case, we pretend everything in the 90 * meanwhile). If that's not the case, we pretend everything in the
91 * Guest has changed. 91 * Guest has changed.
92 */ 92 */
93 if (__get_cpu_var(lg_last_cpu) != cpu || cpu->last_pages != pages) { 93 if (__this_cpu_read(lg_last_cpu) != cpu || cpu->last_pages != pages) {
94 __get_cpu_var(lg_last_cpu) = cpu; 94 __this_cpu_write(lg_last_cpu, cpu);
95 cpu->last_pages = pages; 95 cpu->last_pages = pages;
96 cpu->changed = CHANGED_ALL; 96 cpu->changed = CHANGED_ALL;
97 } 97 }
diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c
index 2e041fd0a00c..f3a29f264db9 100644
--- a/drivers/macintosh/therm_pm72.c
+++ b/drivers/macintosh/therm_pm72.c
@@ -443,7 +443,7 @@ static int fan_read_reg(int reg, unsigned char *buf, int nb)
443 tries = 0; 443 tries = 0;
444 for (;;) { 444 for (;;) {
445 nr = i2c_master_recv(fcu, buf, nb); 445 nr = i2c_master_recv(fcu, buf, nb);
446 if (nr > 0 || (nr < 0 && nr != ENODEV) || tries >= 100) 446 if (nr > 0 || (nr < 0 && nr != -ENODEV) || tries >= 100)
447 break; 447 break;
448 msleep(10); 448 msleep(10);
449 ++tries; 449 ++tries;
@@ -464,7 +464,7 @@ static int fan_write_reg(int reg, const unsigned char *ptr, int nb)
464 tries = 0; 464 tries = 0;
465 for (;;) { 465 for (;;) {
466 nw = i2c_master_send(fcu, buf, nb); 466 nw = i2c_master_send(fcu, buf, nb);
467 if (nw > 0 || (nw < 0 && nw != EIO) || tries >= 100) 467 if (nw > 0 || (nw < 0 && nw != -EIO) || tries >= 100)
468 break; 468 break;
469 msleep(10); 469 msleep(10);
470 ++tries; 470 ++tries;
diff --git a/drivers/media/common/saa7146_core.c b/drivers/media/common/saa7146_core.c
index 982f000a57ff..9f47e383c57a 100644
--- a/drivers/media/common/saa7146_core.c
+++ b/drivers/media/common/saa7146_core.c
@@ -452,7 +452,7 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent
452 INFO(("found saa7146 @ mem %p (revision %d, irq %d) (0x%04x,0x%04x).\n", dev->mem, dev->revision, pci->irq, pci->subsystem_vendor, pci->subsystem_device)); 452 INFO(("found saa7146 @ mem %p (revision %d, irq %d) (0x%04x,0x%04x).\n", dev->mem, dev->revision, pci->irq, pci->subsystem_vendor, pci->subsystem_device));
453 dev->ext = ext; 453 dev->ext = ext;
454 454
455 mutex_init(&dev->lock); 455 mutex_init(&dev->v4l2_lock);
456 spin_lock_init(&dev->int_slock); 456 spin_lock_init(&dev->int_slock);
457 spin_lock_init(&dev->slock); 457 spin_lock_init(&dev->slock);
458 458
diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c
index e3fedc60fe77..1bd3dd762c6b 100644
--- a/drivers/media/common/saa7146_fops.c
+++ b/drivers/media/common/saa7146_fops.c
@@ -15,18 +15,15 @@ int saa7146_res_get(struct saa7146_fh *fh, unsigned int bit)
15 } 15 }
16 16
17 /* is it free? */ 17 /* is it free? */
18 mutex_lock(&dev->lock);
19 if (vv->resources & bit) { 18 if (vv->resources & bit) {
20 DEB_D(("locked! vv->resources:0x%02x, we want:0x%02x\n",vv->resources,bit)); 19 DEB_D(("locked! vv->resources:0x%02x, we want:0x%02x\n",vv->resources,bit));
21 /* no, someone else uses it */ 20 /* no, someone else uses it */
22 mutex_unlock(&dev->lock);
23 return 0; 21 return 0;
24 } 22 }
25 /* it's free, grab it */ 23 /* it's free, grab it */
26 fh->resources |= bit; 24 fh->resources |= bit;
27 vv->resources |= bit; 25 vv->resources |= bit;
28 DEB_D(("res: get 0x%02x, cur:0x%02x\n",bit,vv->resources)); 26 DEB_D(("res: get 0x%02x, cur:0x%02x\n",bit,vv->resources));
29 mutex_unlock(&dev->lock);
30 return 1; 27 return 1;
31} 28}
32 29
@@ -37,11 +34,9 @@ void saa7146_res_free(struct saa7146_fh *fh, unsigned int bits)
37 34
38 BUG_ON((fh->resources & bits) != bits); 35 BUG_ON((fh->resources & bits) != bits);
39 36
40 mutex_lock(&dev->lock);
41 fh->resources &= ~bits; 37 fh->resources &= ~bits;
42 vv->resources &= ~bits; 38 vv->resources &= ~bits;
43 DEB_D(("res: put 0x%02x, cur:0x%02x\n",bits,vv->resources)); 39 DEB_D(("res: put 0x%02x, cur:0x%02x\n",bits,vv->resources));
44 mutex_unlock(&dev->lock);
45} 40}
46 41
47 42
@@ -396,7 +391,7 @@ static const struct v4l2_file_operations video_fops =
396 .write = fops_write, 391 .write = fops_write,
397 .poll = fops_poll, 392 .poll = fops_poll,
398 .mmap = fops_mmap, 393 .mmap = fops_mmap,
399 .ioctl = video_ioctl2, 394 .unlocked_ioctl = video_ioctl2,
400}; 395};
401 396
402static void vv_callback(struct saa7146_dev *dev, unsigned long status) 397static void vv_callback(struct saa7146_dev *dev, unsigned long status)
@@ -505,6 +500,7 @@ int saa7146_register_device(struct video_device **vid, struct saa7146_dev* dev,
505 vfd->fops = &video_fops; 500 vfd->fops = &video_fops;
506 vfd->ioctl_ops = &dev->ext_vv_data->ops; 501 vfd->ioctl_ops = &dev->ext_vv_data->ops;
507 vfd->release = video_device_release; 502 vfd->release = video_device_release;
503 vfd->lock = &dev->v4l2_lock;
508 vfd->tvnorms = 0; 504 vfd->tvnorms = 0;
509 for (i = 0; i < dev->ext_vv_data->num_stds; i++) 505 for (i = 0; i < dev->ext_vv_data->num_stds; i++)
510 vfd->tvnorms |= dev->ext_vv_data->stds[i].id; 506 vfd->tvnorms |= dev->ext_vv_data->stds[i].id;
diff --git a/drivers/media/common/saa7146_vbi.c b/drivers/media/common/saa7146_vbi.c
index 2d4533ab22b7..afe85801d6ca 100644
--- a/drivers/media/common/saa7146_vbi.c
+++ b/drivers/media/common/saa7146_vbi.c
@@ -412,7 +412,7 @@ static int vbi_open(struct saa7146_dev *dev, struct file *file)
412 V4L2_BUF_TYPE_VBI_CAPTURE, 412 V4L2_BUF_TYPE_VBI_CAPTURE,
413 V4L2_FIELD_SEQ_TB, // FIXME: does this really work? 413 V4L2_FIELD_SEQ_TB, // FIXME: does this really work?
414 sizeof(struct saa7146_buf), 414 sizeof(struct saa7146_buf),
415 file, NULL); 415 file, &dev->v4l2_lock);
416 416
417 init_timer(&fh->vbi_read_timeout); 417 init_timer(&fh->vbi_read_timeout);
418 fh->vbi_read_timeout.function = vbi_read_timeout; 418 fh->vbi_read_timeout.function = vbi_read_timeout;
diff --git a/drivers/media/common/saa7146_video.c b/drivers/media/common/saa7146_video.c
index 0ac5c619aecf..9aafa4e969a8 100644
--- a/drivers/media/common/saa7146_video.c
+++ b/drivers/media/common/saa7146_video.c
@@ -553,8 +553,6 @@ static int vidioc_s_fbuf(struct file *file, void *fh, struct v4l2_framebuffer *f
553 } 553 }
554 } 554 }
555 555
556 mutex_lock(&dev->lock);
557
558 /* ok, accept it */ 556 /* ok, accept it */
559 vv->ov_fb = *fb; 557 vv->ov_fb = *fb;
560 vv->ov_fmt = fmt; 558 vv->ov_fmt = fmt;
@@ -563,8 +561,6 @@ static int vidioc_s_fbuf(struct file *file, void *fh, struct v4l2_framebuffer *f
563 vv->ov_fb.fmt.bytesperline = vv->ov_fb.fmt.width * fmt->depth / 8; 561 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)); 562 DEB_D(("setting bytesperline to %d\n", vv->ov_fb.fmt.bytesperline));
565 } 563 }
566
567 mutex_unlock(&dev->lock);
568 return 0; 564 return 0;
569} 565}
570 566
@@ -649,8 +645,6 @@ static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *c)
649 return -EINVAL; 645 return -EINVAL;
650 } 646 }
651 647
652 mutex_lock(&dev->lock);
653
654 switch (ctrl->type) { 648 switch (ctrl->type) {
655 case V4L2_CTRL_TYPE_BOOLEAN: 649 case V4L2_CTRL_TYPE_BOOLEAN:
656 case V4L2_CTRL_TYPE_MENU: 650 case V4L2_CTRL_TYPE_MENU:
@@ -693,7 +687,6 @@ static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *c)
693 /* fixme: we can support changing VFLIP and HFLIP here... */ 687 /* fixme: we can support changing VFLIP and HFLIP here... */
694 if (IS_CAPTURE_ACTIVE(fh) != 0) { 688 if (IS_CAPTURE_ACTIVE(fh) != 0) {
695 DEB_D(("V4L2_CID_HFLIP while active capture.\n")); 689 DEB_D(("V4L2_CID_HFLIP while active capture.\n"));
696 mutex_unlock(&dev->lock);
697 return -EBUSY; 690 return -EBUSY;
698 } 691 }
699 vv->hflip = c->value; 692 vv->hflip = c->value;
@@ -701,16 +694,13 @@ static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *c)
701 case V4L2_CID_VFLIP: 694 case V4L2_CID_VFLIP:
702 if (IS_CAPTURE_ACTIVE(fh) != 0) { 695 if (IS_CAPTURE_ACTIVE(fh) != 0) {
703 DEB_D(("V4L2_CID_VFLIP while active capture.\n")); 696 DEB_D(("V4L2_CID_VFLIP while active capture.\n"));
704 mutex_unlock(&dev->lock);
705 return -EBUSY; 697 return -EBUSY;
706 } 698 }
707 vv->vflip = c->value; 699 vv->vflip = c->value;
708 break; 700 break;
709 default: 701 default:
710 mutex_unlock(&dev->lock);
711 return -EINVAL; 702 return -EINVAL;
712 } 703 }
713 mutex_unlock(&dev->lock);
714 704
715 if (IS_OVERLAY_ACTIVE(fh) != 0) { 705 if (IS_OVERLAY_ACTIVE(fh) != 0) {
716 saa7146_stop_preview(fh); 706 saa7146_stop_preview(fh);
@@ -902,22 +892,18 @@ static int vidioc_s_fmt_vid_overlay(struct file *file, void *__fh, struct v4l2_f
902 err = vidioc_try_fmt_vid_overlay(file, fh, f); 892 err = vidioc_try_fmt_vid_overlay(file, fh, f);
903 if (0 != err) 893 if (0 != err)
904 return err; 894 return err;
905 mutex_lock(&dev->lock);
906 fh->ov.win = f->fmt.win; 895 fh->ov.win = f->fmt.win;
907 fh->ov.nclips = f->fmt.win.clipcount; 896 fh->ov.nclips = f->fmt.win.clipcount;
908 if (fh->ov.nclips > 16) 897 if (fh->ov.nclips > 16)
909 fh->ov.nclips = 16; 898 fh->ov.nclips = 16;
910 if (copy_from_user(fh->ov.clips, f->fmt.win.clips, 899 if (copy_from_user(fh->ov.clips, f->fmt.win.clips,
911 sizeof(struct v4l2_clip) * fh->ov.nclips)) { 900 sizeof(struct v4l2_clip) * fh->ov.nclips)) {
912 mutex_unlock(&dev->lock);
913 return -EFAULT; 901 return -EFAULT;
914 } 902 }
915 903
916 /* fh->ov.fh is used to indicate that we have valid overlay informations, too */ 904 /* fh->ov.fh is used to indicate that we have valid overlay informations, too */
917 fh->ov.fh = fh; 905 fh->ov.fh = fh;
918 906
919 mutex_unlock(&dev->lock);
920
921 /* check if our current overlay is active */ 907 /* check if our current overlay is active */
922 if (IS_OVERLAY_ACTIVE(fh) != 0) { 908 if (IS_OVERLAY_ACTIVE(fh) != 0) {
923 saa7146_stop_preview(fh); 909 saa7146_stop_preview(fh);
@@ -976,8 +962,6 @@ static int vidioc_s_std(struct file *file, void *fh, v4l2_std_id *id)
976 } 962 }
977 } 963 }
978 964
979 mutex_lock(&dev->lock);
980
981 for (i = 0; i < dev->ext_vv_data->num_stds; i++) 965 for (i = 0; i < dev->ext_vv_data->num_stds; i++)
982 if (*id & dev->ext_vv_data->stds[i].id) 966 if (*id & dev->ext_vv_data->stds[i].id)
983 break; 967 break;
@@ -988,8 +972,6 @@ static int vidioc_s_std(struct file *file, void *fh, v4l2_std_id *id)
988 found = 1; 972 found = 1;
989 } 973 }
990 974
991 mutex_unlock(&dev->lock);
992
993 if (vv->ov_suspend != NULL) { 975 if (vv->ov_suspend != NULL) {
994 saa7146_start_preview(vv->ov_suspend); 976 saa7146_start_preview(vv->ov_suspend);
995 vv->ov_suspend = NULL; 977 vv->ov_suspend = NULL;
@@ -1354,7 +1336,7 @@ static int video_open(struct saa7146_dev *dev, struct file *file)
1354 V4L2_BUF_TYPE_VIDEO_CAPTURE, 1336 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1355 V4L2_FIELD_INTERLACED, 1337 V4L2_FIELD_INTERLACED,
1356 sizeof(struct saa7146_buf), 1338 sizeof(struct saa7146_buf),
1357 file, NULL); 1339 file, &dev->v4l2_lock);
1358 1340
1359 return 0; 1341 return 0;
1360} 1342}
diff --git a/drivers/media/common/tuners/Kconfig b/drivers/media/common/tuners/Kconfig
index 78b089526e02..6fc79f15dcbc 100644
--- a/drivers/media/common/tuners/Kconfig
+++ b/drivers/media/common/tuners/Kconfig
@@ -34,7 +34,7 @@ config MEDIA_TUNER
34config MEDIA_TUNER_CUSTOMISE 34config MEDIA_TUNER_CUSTOMISE
35 bool "Customize analog and hybrid tuner modules to build" 35 bool "Customize analog and hybrid tuner modules to build"
36 depends on MEDIA_TUNER 36 depends on MEDIA_TUNER
37 default y if EMBEDDED 37 default y if EXPERT
38 help 38 help
39 This allows the user to deselect tuner drivers unnecessary 39 This allows the user to deselect tuner drivers unnecessary
40 for their hardware from the build. Use this option with care 40 for their hardware from the build. Use this option with care
diff --git a/drivers/media/common/tuners/tda8290.c b/drivers/media/common/tuners/tda8290.c
index c9062ceddc71..bc6a67768af1 100644
--- a/drivers/media/common/tuners/tda8290.c
+++ b/drivers/media/common/tuners/tda8290.c
@@ -95,8 +95,7 @@ static int tda8295_i2c_bridge(struct dvb_frontend *fe, int close)
95 msleep(20); 95 msleep(20);
96 } else { 96 } else {
97 msg = disable; 97 msg = disable;
98 tuner_i2c_xfer_send(&priv->i2c_props, msg, 1); 98 tuner_i2c_xfer_send_recv(&priv->i2c_props, msg, 1, &msg[1], 1);
99 tuner_i2c_xfer_recv(&priv->i2c_props, &msg[1], 1);
100 99
101 buf[2] = msg[1]; 100 buf[2] = msg[1];
102 buf[2] &= ~0x04; 101 buf[2] &= ~0x04;
@@ -233,19 +232,22 @@ static void tda8290_set_params(struct dvb_frontend *fe,
233 tuner_i2c_xfer_send(&priv->i2c_props, pll_bw_nom, 2); 232 tuner_i2c_xfer_send(&priv->i2c_props, pll_bw_nom, 2);
234 } 233 }
235 234
235
236 tda8290_i2c_bridge(fe, 1); 236 tda8290_i2c_bridge(fe, 1);
237 237
238 if (fe->ops.tuner_ops.set_analog_params) 238 if (fe->ops.tuner_ops.set_analog_params)
239 fe->ops.tuner_ops.set_analog_params(fe, params); 239 fe->ops.tuner_ops.set_analog_params(fe, params);
240 240
241 for (i = 0; i < 3; i++) { 241 for (i = 0; i < 3; i++) {
242 tuner_i2c_xfer_send(&priv->i2c_props, &addr_pll_stat, 1); 242 tuner_i2c_xfer_send_recv(&priv->i2c_props,
243 tuner_i2c_xfer_recv(&priv->i2c_props, &pll_stat, 1); 243 &addr_pll_stat, 1, &pll_stat, 1);
244 if (pll_stat & 0x80) { 244 if (pll_stat & 0x80) {
245 tuner_i2c_xfer_send(&priv->i2c_props, &addr_adc_sat, 1); 245 tuner_i2c_xfer_send_recv(&priv->i2c_props,
246 tuner_i2c_xfer_recv(&priv->i2c_props, &adc_sat, 1); 246 &addr_adc_sat, 1,
247 tuner_i2c_xfer_send(&priv->i2c_props, &addr_agc_stat, 1); 247 &adc_sat, 1);
248 tuner_i2c_xfer_recv(&priv->i2c_props, &agc_stat, 1); 248 tuner_i2c_xfer_send_recv(&priv->i2c_props,
249 &addr_agc_stat, 1,
250 &agc_stat, 1);
249 tuner_dbg("tda8290 is locked, AGC: %d\n", agc_stat); 251 tuner_dbg("tda8290 is locked, AGC: %d\n", agc_stat);
250 break; 252 break;
251 } else { 253 } else {
@@ -259,20 +261,22 @@ static void tda8290_set_params(struct dvb_frontend *fe,
259 agc_stat, adc_sat, pll_stat & 0x80); 261 agc_stat, adc_sat, pll_stat & 0x80);
260 tuner_i2c_xfer_send(&priv->i2c_props, gainset_2, 2); 262 tuner_i2c_xfer_send(&priv->i2c_props, gainset_2, 2);
261 msleep(100); 263 msleep(100);
262 tuner_i2c_xfer_send(&priv->i2c_props, &addr_agc_stat, 1); 264 tuner_i2c_xfer_send_recv(&priv->i2c_props,
263 tuner_i2c_xfer_recv(&priv->i2c_props, &agc_stat, 1); 265 &addr_agc_stat, 1, &agc_stat, 1);
264 tuner_i2c_xfer_send(&priv->i2c_props, &addr_pll_stat, 1); 266 tuner_i2c_xfer_send_recv(&priv->i2c_props,
265 tuner_i2c_xfer_recv(&priv->i2c_props, &pll_stat, 1); 267 &addr_pll_stat, 1, &pll_stat, 1);
266 if ((agc_stat > 115) || !(pll_stat & 0x80)) { 268 if ((agc_stat > 115) || !(pll_stat & 0x80)) {
267 tuner_dbg("adjust gain, step 2. Agc: %d, lock: %d\n", 269 tuner_dbg("adjust gain, step 2. Agc: %d, lock: %d\n",
268 agc_stat, pll_stat & 0x80); 270 agc_stat, pll_stat & 0x80);
269 if (priv->cfg.agcf) 271 if (priv->cfg.agcf)
270 priv->cfg.agcf(fe); 272 priv->cfg.agcf(fe);
271 msleep(100); 273 msleep(100);
272 tuner_i2c_xfer_send(&priv->i2c_props, &addr_agc_stat, 1); 274 tuner_i2c_xfer_send_recv(&priv->i2c_props,
273 tuner_i2c_xfer_recv(&priv->i2c_props, &agc_stat, 1); 275 &addr_agc_stat, 1,
274 tuner_i2c_xfer_send(&priv->i2c_props, &addr_pll_stat, 1); 276 &agc_stat, 1);
275 tuner_i2c_xfer_recv(&priv->i2c_props, &pll_stat, 1); 277 tuner_i2c_xfer_send_recv(&priv->i2c_props,
278 &addr_pll_stat, 1,
279 &pll_stat, 1);
276 if((agc_stat > 115) || !(pll_stat & 0x80)) { 280 if((agc_stat > 115) || !(pll_stat & 0x80)) {
277 tuner_dbg("adjust gain, step 3. Agc: %d\n", agc_stat); 281 tuner_dbg("adjust gain, step 3. Agc: %d\n", agc_stat);
278 tuner_i2c_xfer_send(&priv->i2c_props, adc_head_12, 2); 282 tuner_i2c_xfer_send(&priv->i2c_props, adc_head_12, 2);
@@ -284,10 +288,12 @@ static void tda8290_set_params(struct dvb_frontend *fe,
284 288
285 /* l/ l' deadlock? */ 289 /* l/ l' deadlock? */
286 if(priv->tda8290_easy_mode & 0x60) { 290 if(priv->tda8290_easy_mode & 0x60) {
287 tuner_i2c_xfer_send(&priv->i2c_props, &addr_adc_sat, 1); 291 tuner_i2c_xfer_send_recv(&priv->i2c_props,
288 tuner_i2c_xfer_recv(&priv->i2c_props, &adc_sat, 1); 292 &addr_adc_sat, 1,
289 tuner_i2c_xfer_send(&priv->i2c_props, &addr_pll_stat, 1); 293 &adc_sat, 1);
290 tuner_i2c_xfer_recv(&priv->i2c_props, &pll_stat, 1); 294 tuner_i2c_xfer_send_recv(&priv->i2c_props,
295 &addr_pll_stat, 1,
296 &pll_stat, 1);
291 if ((adc_sat > 20) || !(pll_stat & 0x80)) { 297 if ((adc_sat > 20) || !(pll_stat & 0x80)) {
292 tuner_dbg("trying to resolve SECAM L deadlock\n"); 298 tuner_dbg("trying to resolve SECAM L deadlock\n");
293 tuner_i2c_xfer_send(&priv->i2c_props, agc_rst_on, 2); 299 tuner_i2c_xfer_send(&priv->i2c_props, agc_rst_on, 2);
@@ -307,8 +313,7 @@ static void tda8295_power(struct dvb_frontend *fe, int enable)
307 struct tda8290_priv *priv = fe->analog_demod_priv; 313 struct tda8290_priv *priv = fe->analog_demod_priv;
308 unsigned char buf[] = { 0x30, 0x00 }; /* clb_stdbt */ 314 unsigned char buf[] = { 0x30, 0x00 }; /* clb_stdbt */
309 315
310 tuner_i2c_xfer_send(&priv->i2c_props, &buf[0], 1); 316 tuner_i2c_xfer_send_recv(&priv->i2c_props, &buf[0], 1, &buf[1], 1);
311 tuner_i2c_xfer_recv(&priv->i2c_props, &buf[1], 1);
312 317
313 if (enable) 318 if (enable)
314 buf[1] = 0x01; 319 buf[1] = 0x01;
@@ -323,8 +328,7 @@ static void tda8295_set_easy_mode(struct dvb_frontend *fe, int enable)
323 struct tda8290_priv *priv = fe->analog_demod_priv; 328 struct tda8290_priv *priv = fe->analog_demod_priv;
324 unsigned char buf[] = { 0x01, 0x00 }; 329 unsigned char buf[] = { 0x01, 0x00 };
325 330
326 tuner_i2c_xfer_send(&priv->i2c_props, &buf[0], 1); 331 tuner_i2c_xfer_send_recv(&priv->i2c_props, &buf[0], 1, &buf[1], 1);
327 tuner_i2c_xfer_recv(&priv->i2c_props, &buf[1], 1);
328 332
329 if (enable) 333 if (enable)
330 buf[1] = 0x01; /* rising edge sets regs 0x02 - 0x23 */ 334 buf[1] = 0x01; /* rising edge sets regs 0x02 - 0x23 */
@@ -353,8 +357,7 @@ static void tda8295_agc1_out(struct dvb_frontend *fe, int enable)
353 struct tda8290_priv *priv = fe->analog_demod_priv; 357 struct tda8290_priv *priv = fe->analog_demod_priv;
354 unsigned char buf[] = { 0x02, 0x00 }; /* DIV_FUNC */ 358 unsigned char buf[] = { 0x02, 0x00 }; /* DIV_FUNC */
355 359
356 tuner_i2c_xfer_send(&priv->i2c_props, &buf[0], 1); 360 tuner_i2c_xfer_send_recv(&priv->i2c_props, &buf[0], 1, &buf[1], 1);
357 tuner_i2c_xfer_recv(&priv->i2c_props, &buf[1], 1);
358 361
359 if (enable) 362 if (enable)
360 buf[1] &= ~0x40; 363 buf[1] &= ~0x40;
@@ -370,10 +373,10 @@ static void tda8295_agc2_out(struct dvb_frontend *fe, int enable)
370 unsigned char set_gpio_cf[] = { 0x44, 0x00 }; 373 unsigned char set_gpio_cf[] = { 0x44, 0x00 };
371 unsigned char set_gpio_val[] = { 0x46, 0x00 }; 374 unsigned char set_gpio_val[] = { 0x46, 0x00 };
372 375
373 tuner_i2c_xfer_send(&priv->i2c_props, &set_gpio_cf[0], 1); 376 tuner_i2c_xfer_send_recv(&priv->i2c_props,
374 tuner_i2c_xfer_recv(&priv->i2c_props, &set_gpio_cf[1], 1); 377 &set_gpio_cf[0], 1, &set_gpio_cf[1], 1);
375 tuner_i2c_xfer_send(&priv->i2c_props, &set_gpio_val[0], 1); 378 tuner_i2c_xfer_send_recv(&priv->i2c_props,
376 tuner_i2c_xfer_recv(&priv->i2c_props, &set_gpio_val[1], 1); 379 &set_gpio_val[0], 1, &set_gpio_val[1], 1);
377 380
378 set_gpio_cf[1] &= 0xf0; /* clear GPIO_0 bits 3-0 */ 381 set_gpio_cf[1] &= 0xf0; /* clear GPIO_0 bits 3-0 */
379 382
@@ -392,8 +395,7 @@ static int tda8295_has_signal(struct dvb_frontend *fe)
392 unsigned char hvpll_stat = 0x26; 395 unsigned char hvpll_stat = 0x26;
393 unsigned char ret; 396 unsigned char ret;
394 397
395 tuner_i2c_xfer_send(&priv->i2c_props, &hvpll_stat, 1); 398 tuner_i2c_xfer_send_recv(&priv->i2c_props, &hvpll_stat, 1, &ret, 1);
396 tuner_i2c_xfer_recv(&priv->i2c_props, &ret, 1);
397 return (ret & 0x01) ? 65535 : 0; 399 return (ret & 0x01) ? 65535 : 0;
398} 400}
399 401
@@ -413,8 +415,8 @@ static void tda8295_set_params(struct dvb_frontend *fe,
413 tda8295_power(fe, 1); 415 tda8295_power(fe, 1);
414 tda8295_agc1_out(fe, 1); 416 tda8295_agc1_out(fe, 1);
415 417
416 tuner_i2c_xfer_send(&priv->i2c_props, &blanking_mode[0], 1); 418 tuner_i2c_xfer_send_recv(&priv->i2c_props,
417 tuner_i2c_xfer_recv(&priv->i2c_props, &blanking_mode[1], 1); 419 &blanking_mode[0], 1, &blanking_mode[1], 1);
418 420
419 tda8295_set_video_std(fe); 421 tda8295_set_video_std(fe);
420 422
@@ -447,8 +449,8 @@ static int tda8290_has_signal(struct dvb_frontend *fe)
447 unsigned char i2c_get_afc[1] = { 0x1B }; 449 unsigned char i2c_get_afc[1] = { 0x1B };
448 unsigned char afc = 0; 450 unsigned char afc = 0;
449 451
450 tuner_i2c_xfer_send(&priv->i2c_props, i2c_get_afc, ARRAY_SIZE(i2c_get_afc)); 452 tuner_i2c_xfer_send_recv(&priv->i2c_props,
451 tuner_i2c_xfer_recv(&priv->i2c_props, &afc, 1); 453 i2c_get_afc, ARRAY_SIZE(i2c_get_afc), &afc, 1);
452 return (afc & 0x80)? 65535:0; 454 return (afc & 0x80)? 65535:0;
453} 455}
454 456
@@ -654,20 +656,26 @@ static int tda829x_find_tuner(struct dvb_frontend *fe)
654static int tda8290_probe(struct tuner_i2c_props *i2c_props) 656static int tda8290_probe(struct tuner_i2c_props *i2c_props)
655{ 657{
656#define TDA8290_ID 0x89 658#define TDA8290_ID 0x89
657 unsigned char tda8290_id[] = { 0x1f, 0x00 }; 659 u8 reg = 0x1f, id;
660 struct i2c_msg msg_read[] = {
661 { .addr = 0x4b, .flags = 0, .len = 1, .buf = &reg },
662 { .addr = 0x4b, .flags = I2C_M_RD, .len = 1, .buf = &id },
663 };
658 664
659 /* detect tda8290 */ 665 /* detect tda8290 */
660 tuner_i2c_xfer_send(i2c_props, &tda8290_id[0], 1); 666 if (i2c_transfer(i2c_props->adap, msg_read, 2) != 2) {
661 tuner_i2c_xfer_recv(i2c_props, &tda8290_id[1], 1); 667 printk(KERN_WARNING "%s: tda8290 couldn't read register 0x%02x\n",
668 __func__, reg);
669 return -ENODEV;
670 }
662 671
663 if (tda8290_id[1] == TDA8290_ID) { 672 if (id == TDA8290_ID) {
664 if (debug) 673 if (debug)
665 printk(KERN_DEBUG "%s: tda8290 detected @ %d-%04x\n", 674 printk(KERN_DEBUG "%s: tda8290 detected @ %d-%04x\n",
666 __func__, i2c_adapter_id(i2c_props->adap), 675 __func__, i2c_adapter_id(i2c_props->adap),
667 i2c_props->addr); 676 i2c_props->addr);
668 return 0; 677 return 0;
669 } 678 }
670
671 return -ENODEV; 679 return -ENODEV;
672} 680}
673 681
@@ -675,16 +683,23 @@ static int tda8295_probe(struct tuner_i2c_props *i2c_props)
675{ 683{
676#define TDA8295_ID 0x8a 684#define TDA8295_ID 0x8a
677#define TDA8295C2_ID 0x8b 685#define TDA8295C2_ID 0x8b
678 unsigned char tda8295_id[] = { 0x2f, 0x00 }; 686 u8 reg = 0x2f, id;
687 struct i2c_msg msg_read[] = {
688 { .addr = 0x4b, .flags = 0, .len = 1, .buf = &reg },
689 { .addr = 0x4b, .flags = I2C_M_RD, .len = 1, .buf = &id },
690 };
679 691
680 /* detect tda8295 */ 692 /* detect tda8290 */
681 tuner_i2c_xfer_send(i2c_props, &tda8295_id[0], 1); 693 if (i2c_transfer(i2c_props->adap, msg_read, 2) != 2) {
682 tuner_i2c_xfer_recv(i2c_props, &tda8295_id[1], 1); 694 printk(KERN_WARNING "%s: tda8290 couldn't read register 0x%02x\n",
695 __func__, reg);
696 return -ENODEV;
697 }
683 698
684 if ((tda8295_id[1] & 0xfe) == TDA8295_ID) { 699 if ((id & 0xfe) == TDA8295_ID) {
685 if (debug) 700 if (debug)
686 printk(KERN_DEBUG "%s: %s detected @ %d-%04x\n", 701 printk(KERN_DEBUG "%s: %s detected @ %d-%04x\n",
687 __func__, (tda8295_id[1] == TDA8295_ID) ? 702 __func__, (id == TDA8295_ID) ?
688 "tda8295c1" : "tda8295c2", 703 "tda8295c1" : "tda8295c2",
689 i2c_adapter_id(i2c_props->adap), 704 i2c_adapter_id(i2c_props->adap),
690 i2c_props->addr); 705 i2c_props->addr);
@@ -740,9 +755,11 @@ struct dvb_frontend *tda829x_attach(struct dvb_frontend *fe,
740 sizeof(struct analog_demod_ops)); 755 sizeof(struct analog_demod_ops));
741 } 756 }
742 757
743 if ((!(cfg) || (TDA829X_PROBE_TUNER == cfg->probe_tuner)) && 758 if (!(cfg) || (TDA829X_PROBE_TUNER == cfg->probe_tuner)) {
744 (tda829x_find_tuner(fe) < 0)) 759 tda8295_power(fe, 1);
745 goto fail; 760 if (tda829x_find_tuner(fe) < 0)
761 goto fail;
762 }
746 763
747 switch (priv->ver) { 764 switch (priv->ver) {
748 case TDA8290: 765 case TDA8290:
@@ -786,6 +803,8 @@ struct dvb_frontend *tda829x_attach(struct dvb_frontend *fe,
786 return fe; 803 return fe;
787 804
788fail: 805fail:
806 memset(&fe->ops.analog_ops, 0, sizeof(struct analog_demod_ops));
807
789 tda829x_release(fe); 808 tda829x_release(fe);
790 return NULL; 809 return NULL;
791} 810}
@@ -809,8 +828,8 @@ int tda829x_probe(struct i2c_adapter *i2c_adap, u8 i2c_addr)
809 int i; 828 int i;
810 829
811 /* rule out tda9887, which would return the same byte repeatedly */ 830 /* rule out tda9887, which would return the same byte repeatedly */
812 tuner_i2c_xfer_send(&i2c_props, soft_reset, 1); 831 tuner_i2c_xfer_send_recv(&i2c_props,
813 tuner_i2c_xfer_recv(&i2c_props, buf, PROBE_BUFFER_SIZE); 832 soft_reset, 1, buf, PROBE_BUFFER_SIZE);
814 for (i = 1; i < PROBE_BUFFER_SIZE; i++) { 833 for (i = 1; i < PROBE_BUFFER_SIZE; i++) {
815 if (buf[i] != buf[0]) 834 if (buf[i] != buf[0])
816 break; 835 break;
@@ -827,13 +846,12 @@ int tda829x_probe(struct i2c_adapter *i2c_adap, u8 i2c_addr)
827 /* fall back to old probing method */ 846 /* fall back to old probing method */
828 tuner_i2c_xfer_send(&i2c_props, easy_mode_b, 2); 847 tuner_i2c_xfer_send(&i2c_props, easy_mode_b, 2);
829 tuner_i2c_xfer_send(&i2c_props, soft_reset, 2); 848 tuner_i2c_xfer_send(&i2c_props, soft_reset, 2);
830 tuner_i2c_xfer_send(&i2c_props, &addr_dto_lsb, 1); 849 tuner_i2c_xfer_send_recv(&i2c_props, &addr_dto_lsb, 1, &data, 1);
831 tuner_i2c_xfer_recv(&i2c_props, &data, 1);
832 if (data == 0) { 850 if (data == 0) {
833 tuner_i2c_xfer_send(&i2c_props, easy_mode_g, 2); 851 tuner_i2c_xfer_send(&i2c_props, easy_mode_g, 2);
834 tuner_i2c_xfer_send(&i2c_props, soft_reset, 2); 852 tuner_i2c_xfer_send(&i2c_props, soft_reset, 2);
835 tuner_i2c_xfer_send(&i2c_props, &addr_dto_lsb, 1); 853 tuner_i2c_xfer_send_recv(&i2c_props,
836 tuner_i2c_xfer_recv(&i2c_props, &data, 1); 854 &addr_dto_lsb, 1, &data, 1);
837 if (data == 0x7b) { 855 if (data == 0x7b) {
838 return 0; 856 return 0;
839 } 857 }
diff --git a/drivers/media/dvb/dvb-usb/dib0700_core.c b/drivers/media/dvb/dvb-usb/dib0700_core.c
index 8ca48f76dfa9..98ffb40728e3 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_core.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_core.c
@@ -514,8 +514,8 @@ struct dib0700_rc_response {
514 union { 514 union {
515 u16 system16; 515 u16 system16;
516 struct { 516 struct {
517 u8 system;
518 u8 not_system; 517 u8 not_system;
518 u8 system;
519 }; 519 };
520 }; 520 };
521 u8 data; 521 u8 data;
@@ -575,7 +575,7 @@ static void dib0700_rc_urb_completion(struct urb *purb)
575 if ((poll_reply->system ^ poll_reply->not_system) != 0xff) { 575 if ((poll_reply->system ^ poll_reply->not_system) != 0xff) {
576 deb_data("NEC extended protocol\n"); 576 deb_data("NEC extended protocol\n");
577 /* NEC extended code - 24 bits */ 577 /* NEC extended code - 24 bits */
578 keycode = poll_reply->system16 << 8 | poll_reply->data; 578 keycode = be16_to_cpu(poll_reply->system16) << 8 | poll_reply->data;
579 } else { 579 } else {
580 deb_data("NEC normal protocol\n"); 580 deb_data("NEC normal protocol\n");
581 /* normal NEC code - 16 bits */ 581 /* normal NEC code - 16 bits */
@@ -587,7 +587,7 @@ static void dib0700_rc_urb_completion(struct urb *purb)
587 deb_data("RC5 protocol\n"); 587 deb_data("RC5 protocol\n");
588 /* RC5 Protocol */ 588 /* RC5 Protocol */
589 toggle = poll_reply->report_id; 589 toggle = poll_reply->report_id;
590 keycode = poll_reply->system16 << 8 | poll_reply->data; 590 keycode = poll_reply->system << 8 | poll_reply->data;
591 591
592 break; 592 break;
593 } 593 }
diff --git a/drivers/media/dvb/firewire/firedtv-rc.c b/drivers/media/dvb/firewire/firedtv-rc.c
index fcf3828472b8..f82d4a93feb3 100644
--- a/drivers/media/dvb/firewire/firedtv-rc.c
+++ b/drivers/media/dvb/firewire/firedtv-rc.c
@@ -172,7 +172,8 @@ void fdtv_unregister_rc(struct firedtv *fdtv)
172 172
173void fdtv_handle_rc(struct firedtv *fdtv, unsigned int code) 173void fdtv_handle_rc(struct firedtv *fdtv, unsigned int code)
174{ 174{
175 u16 *keycode = fdtv->remote_ctrl_dev->keycode; 175 struct input_dev *idev = fdtv->remote_ctrl_dev;
176 u16 *keycode = idev->keycode;
176 177
177 if (code >= 0x0300 && code <= 0x031f) 178 if (code >= 0x0300 && code <= 0x031f)
178 code = keycode[code - 0x0300]; 179 code = keycode[code - 0x0300];
@@ -188,6 +189,8 @@ void fdtv_handle_rc(struct firedtv *fdtv, unsigned int code)
188 return; 189 return;
189 } 190 }
190 191
191 input_report_key(fdtv->remote_ctrl_dev, code, 1); 192 input_report_key(idev, code, 1);
192 input_report_key(fdtv->remote_ctrl_dev, code, 0); 193 input_sync(idev);
194 input_report_key(idev, code, 0);
195 input_sync(idev);
193} 196}
diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig
index ef3e43a03199..b8519ba511e5 100644
--- a/drivers/media/dvb/frontends/Kconfig
+++ b/drivers/media/dvb/frontends/Kconfig
@@ -1,7 +1,7 @@
1config DVB_FE_CUSTOMISE 1config DVB_FE_CUSTOMISE
2 bool "Customise the frontend modules to build" 2 bool "Customise the frontend modules to build"
3 depends on DVB_CORE 3 depends on DVB_CORE
4 default y if EMBEDDED 4 default y if EXPERT
5 help 5 help
6 This allows the user to select/deselect frontend drivers for their 6 This allows the user to select/deselect frontend drivers for their
7 hardware from the build. 7 hardware from the build.
diff --git a/drivers/media/dvb/frontends/af9013.c b/drivers/media/dvb/frontends/af9013.c
index ce222055526d..ba25fa0b0fc2 100644
--- a/drivers/media/dvb/frontends/af9013.c
+++ b/drivers/media/dvb/frontends/af9013.c
@@ -334,11 +334,11 @@ static int af9013_set_freq_ctrl(struct af9013_state *state, fe_bandwidth_t bw)
334 if_sample_freq = 3300000; /* 3.3 MHz */ 334 if_sample_freq = 3300000; /* 3.3 MHz */
335 break; 335 break;
336 case BANDWIDTH_7_MHZ: 336 case BANDWIDTH_7_MHZ:
337 if_sample_freq = 3800000; /* 3.8 MHz */ 337 if_sample_freq = 3500000; /* 3.5 MHz */
338 break; 338 break;
339 case BANDWIDTH_8_MHZ: 339 case BANDWIDTH_8_MHZ:
340 default: 340 default:
341 if_sample_freq = 4300000; /* 4.3 MHz */ 341 if_sample_freq = 4000000; /* 4.0 MHz */
342 break; 342 break;
343 } 343 }
344 } else if (state->config.tuner == AF9013_TUNER_TDA18218) { 344 } else if (state->config.tuner == AF9013_TUNER_TDA18218) {
diff --git a/drivers/media/dvb/frontends/ix2505v.c b/drivers/media/dvb/frontends/ix2505v.c
index 6360c681ded9..6c2e929bd79f 100644
--- a/drivers/media/dvb/frontends/ix2505v.c
+++ b/drivers/media/dvb/frontends/ix2505v.c
@@ -311,7 +311,7 @@ struct dvb_frontend *ix2505v_attach(struct dvb_frontend *fe,
311 return fe; 311 return fe;
312 312
313error: 313error:
314 ix2505v_release(fe); 314 kfree(state);
315 return NULL; 315 return NULL;
316} 316}
317EXPORT_SYMBOL(ix2505v_attach); 317EXPORT_SYMBOL(ix2505v_attach);
diff --git a/drivers/media/dvb/frontends/mb86a20s.c b/drivers/media/dvb/frontends/mb86a20s.c
index d3ad3e75a35a..cc4acd2f920d 100644
--- a/drivers/media/dvb/frontends/mb86a20s.c
+++ b/drivers/media/dvb/frontends/mb86a20s.c
@@ -43,6 +43,8 @@ struct mb86a20s_state {
43 const struct mb86a20s_config *config; 43 const struct mb86a20s_config *config;
44 44
45 struct dvb_frontend frontend; 45 struct dvb_frontend frontend;
46
47 bool need_init;
46}; 48};
47 49
48struct regdata { 50struct regdata {
@@ -318,7 +320,7 @@ static int mb86a20s_i2c_writereg(struct mb86a20s_state *state,
318 320
319 rc = i2c_transfer(state->i2c, &msg, 1); 321 rc = i2c_transfer(state->i2c, &msg, 1);
320 if (rc != 1) { 322 if (rc != 1) {
321 printk("%s: writereg rcor(rc == %i, reg == 0x%02x," 323 printk("%s: writereg error (rc == %i, reg == 0x%02x,"
322 " data == 0x%02x)\n", __func__, rc, reg, data); 324 " data == 0x%02x)\n", __func__, rc, reg, data);
323 return rc; 325 return rc;
324 } 326 }
@@ -353,7 +355,7 @@ static int mb86a20s_i2c_readreg(struct mb86a20s_state *state,
353 rc = i2c_transfer(state->i2c, msg, 2); 355 rc = i2c_transfer(state->i2c, msg, 2);
354 356
355 if (rc != 2) { 357 if (rc != 2) {
356 rc("%s: reg=0x%x (rcor=%d)\n", __func__, reg, rc); 358 rc("%s: reg=0x%x (error=%d)\n", __func__, reg, rc);
357 return rc; 359 return rc;
358 } 360 }
359 361
@@ -382,23 +384,31 @@ static int mb86a20s_initfe(struct dvb_frontend *fe)
382 /* Initialize the frontend */ 384 /* Initialize the frontend */
383 rc = mb86a20s_writeregdata(state, mb86a20s_init); 385 rc = mb86a20s_writeregdata(state, mb86a20s_init);
384 if (rc < 0) 386 if (rc < 0)
385 return rc; 387 goto err;
386 388
387 if (!state->config->is_serial) { 389 if (!state->config->is_serial) {
388 regD5 &= ~1; 390 regD5 &= ~1;
389 391
390 rc = mb86a20s_writereg(state, 0x50, 0xd5); 392 rc = mb86a20s_writereg(state, 0x50, 0xd5);
391 if (rc < 0) 393 if (rc < 0)
392 return rc; 394 goto err;
393 rc = mb86a20s_writereg(state, 0x51, regD5); 395 rc = mb86a20s_writereg(state, 0x51, regD5);
394 if (rc < 0) 396 if (rc < 0)
395 return rc; 397 goto err;
396 } 398 }
397 399
398 if (fe->ops.i2c_gate_ctrl) 400 if (fe->ops.i2c_gate_ctrl)
399 fe->ops.i2c_gate_ctrl(fe, 1); 401 fe->ops.i2c_gate_ctrl(fe, 1);
400 402
401 return 0; 403err:
404 if (rc < 0) {
405 state->need_init = true;
406 printk(KERN_INFO "mb86a20s: Init failed. Will try again later\n");
407 } else {
408 state->need_init = false;
409 dprintk("Initialization succeded.\n");
410 }
411 return rc;
402} 412}
403 413
404static int mb86a20s_read_signal_strength(struct dvb_frontend *fe, u16 *strength) 414static int mb86a20s_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
@@ -485,8 +495,22 @@ static int mb86a20s_set_frontend(struct dvb_frontend *fe,
485 495
486 if (fe->ops.i2c_gate_ctrl) 496 if (fe->ops.i2c_gate_ctrl)
487 fe->ops.i2c_gate_ctrl(fe, 1); 497 fe->ops.i2c_gate_ctrl(fe, 1);
498 dprintk("Calling tuner set parameters\n");
488 fe->ops.tuner_ops.set_params(fe, p); 499 fe->ops.tuner_ops.set_params(fe, p);
489 500
501 /*
502 * Make it more reliable: if, for some reason, the initial
503 * device initialization doesn't happen, initialize it when
504 * a SBTVD parameters are adjusted.
505 *
506 * Unfortunately, due to a hard to track bug at tda829x/tda18271,
507 * the agc callback logic is not called during DVB attach time,
508 * causing mb86a20s to not be initialized with Kworld SBTVD.
509 * So, this hack is needed, in order to make Kworld SBTVD to work.
510 */
511 if (state->need_init)
512 mb86a20s_initfe(fe);
513
490 if (fe->ops.i2c_gate_ctrl) 514 if (fe->ops.i2c_gate_ctrl)
491 fe->ops.i2c_gate_ctrl(fe, 0); 515 fe->ops.i2c_gate_ctrl(fe, 0);
492 rc = mb86a20s_writeregdata(state, mb86a20s_reset_reception); 516 rc = mb86a20s_writeregdata(state, mb86a20s_reset_reception);
diff --git a/drivers/media/dvb/ttpci/av7110_ca.c b/drivers/media/dvb/ttpci/av7110_ca.c
index 122c72806916..9fc1dd0ba4c3 100644
--- a/drivers/media/dvb/ttpci/av7110_ca.c
+++ b/drivers/media/dvb/ttpci/av7110_ca.c
@@ -277,7 +277,7 @@ static int dvb_ca_ioctl(struct file *file, unsigned int cmd, void *parg)
277 { 277 {
278 ca_slot_info_t *info=(ca_slot_info_t *)parg; 278 ca_slot_info_t *info=(ca_slot_info_t *)parg;
279 279
280 if (info->num > 1) 280 if (info->num < 0 || info->num > 1)
281 return -EINVAL; 281 return -EINVAL;
282 av7110->ci_slot[info->num].num = info->num; 282 av7110->ci_slot[info->num].num = info->num;
283 av7110->ci_slot[info->num].type = FW_CI_LL_SUPPORT(av7110->arm_app) ? 283 av7110->ci_slot[info->num].type = FW_CI_LL_SUPPORT(av7110->arm_app) ?
diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index 3c5a4739ed70..ecdffa6aac66 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -151,20 +151,6 @@ config RADIO_GEMTEK_PROBE
151 following ports will be probed: 0x20c, 0x30c, 0x24c, 0x34c, 0x248 and 151 following ports will be probed: 0x20c, 0x30c, 0x24c, 0x34c, 0x248 and
152 0x28c. 152 0x28c.
153 153
154config RADIO_GEMTEK_PCI
155 tristate "GemTek PCI Radio Card support"
156 depends on VIDEO_V4L2 && PCI
157 ---help---
158 Choose Y here if you have this PCI FM radio card.
159
160 In order to control your radio card, you will need to use programs
161 that are compatible with the Video for Linux API. Information on
162 this API and pointers to "v4l" programs may be found at
163 <file:Documentation/video4linux/API.html>.
164
165 To compile this driver as a module, choose M here: the
166 module will be called radio-gemtek-pci.
167
168config RADIO_MAXIRADIO 154config RADIO_MAXIRADIO
169 tristate "Guillemot MAXI Radio FM 2000 radio" 155 tristate "Guillemot MAXI Radio FM 2000 radio"
170 depends on VIDEO_V4L2 && PCI 156 depends on VIDEO_V4L2 && PCI
diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile
index d2970748a69f..717656d2f749 100644
--- a/drivers/media/radio/Makefile
+++ b/drivers/media/radio/Makefile
@@ -13,7 +13,6 @@ obj-$(CONFIG_RADIO_MAXIRADIO) += radio-maxiradio.o
13obj-$(CONFIG_RADIO_RTRACK) += radio-aimslab.o 13obj-$(CONFIG_RADIO_RTRACK) += radio-aimslab.o
14obj-$(CONFIG_RADIO_ZOLTRIX) += radio-zoltrix.o 14obj-$(CONFIG_RADIO_ZOLTRIX) += radio-zoltrix.o
15obj-$(CONFIG_RADIO_GEMTEK) += radio-gemtek.o 15obj-$(CONFIG_RADIO_GEMTEK) += radio-gemtek.o
16obj-$(CONFIG_RADIO_GEMTEK_PCI) += radio-gemtek-pci.o
17obj-$(CONFIG_RADIO_TRUST) += radio-trust.o 16obj-$(CONFIG_RADIO_TRUST) += radio-trust.o
18obj-$(CONFIG_I2C_SI4713) += si4713-i2c.o 17obj-$(CONFIG_I2C_SI4713) += si4713-i2c.o
19obj-$(CONFIG_RADIO_SI4713) += radio-si4713.o 18obj-$(CONFIG_RADIO_SI4713) += radio-si4713.o
diff --git a/drivers/media/radio/radio-aimslab.c b/drivers/media/radio/radio-aimslab.c
index 6cc5d130fbc8..4ce10dbeadd8 100644
--- a/drivers/media/radio/radio-aimslab.c
+++ b/drivers/media/radio/radio-aimslab.c
@@ -31,6 +31,7 @@
31#include <linux/module.h> /* Modules */ 31#include <linux/module.h> /* Modules */
32#include <linux/init.h> /* Initdata */ 32#include <linux/init.h> /* Initdata */
33#include <linux/ioport.h> /* request_region */ 33#include <linux/ioport.h> /* request_region */
34#include <linux/delay.h> /* msleep */
34#include <linux/videodev2.h> /* kernel radio structs */ 35#include <linux/videodev2.h> /* kernel radio structs */
35#include <linux/version.h> /* for KERNEL_VERSION MACRO */ 36#include <linux/version.h> /* for KERNEL_VERSION MACRO */
36#include <linux/io.h> /* outb, outb_p */ 37#include <linux/io.h> /* outb, outb_p */
diff --git a/drivers/media/radio/radio-gemtek-pci.c b/drivers/media/radio/radio-gemtek-pci.c
deleted file mode 100644
index 28fa85ba2087..000000000000
--- a/drivers/media/radio/radio-gemtek-pci.c
+++ /dev/null
@@ -1,478 +0,0 @@
1/*
2 ***************************************************************************
3 *
4 * radio-gemtek-pci.c - Gemtek PCI Radio driver
5 * (C) 2001 Vladimir Shebordaev <vshebordaev@mail.ru>
6 *
7 ***************************************************************************
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public
20 * License along with this program; if not, write to the Free
21 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
22 * USA.
23 *
24 ***************************************************************************
25 *
26 * Gemtek Corp still silently refuses to release any specifications
27 * of their multimedia devices, so the protocol still has to be
28 * reverse engineered.
29 *
30 * The v4l code was inspired by Jonas Munsin's Gemtek serial line
31 * radio device driver.
32 *
33 * Please, let me know if this piece of code was useful :)
34 *
35 * TODO: multiple device support and portability were not tested
36 *
37 * Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org>
38 *
39 ***************************************************************************
40 */
41
42#include <linux/types.h>
43#include <linux/list.h>
44#include <linux/module.h>
45#include <linux/init.h>
46#include <linux/pci.h>
47#include <linux/videodev2.h>
48#include <linux/errno.h>
49#include <linux/version.h> /* for KERNEL_VERSION MACRO */
50#include <linux/io.h>
51#include <linux/slab.h>
52#include <media/v4l2-device.h>
53#include <media/v4l2-ioctl.h>
54
55MODULE_AUTHOR("Vladimir Shebordaev <vshebordaev@mail.ru>");
56MODULE_DESCRIPTION("The video4linux driver for the Gemtek PCI Radio Card");
57MODULE_LICENSE("GPL");
58
59static int nr_radio = -1;
60static int mx = 1;
61
62module_param(mx, bool, 0);
63MODULE_PARM_DESC(mx, "single digit: 1 - turn off the turner upon module exit (default), 0 - do not");
64module_param(nr_radio, int, 0);
65MODULE_PARM_DESC(nr_radio, "video4linux device number to use");
66
67#define RADIO_VERSION KERNEL_VERSION(0, 0, 2)
68
69#ifndef PCI_VENDOR_ID_GEMTEK
70#define PCI_VENDOR_ID_GEMTEK 0x5046
71#endif
72
73#ifndef PCI_DEVICE_ID_GEMTEK_PR103
74#define PCI_DEVICE_ID_GEMTEK_PR103 0x1001
75#endif
76
77#ifndef GEMTEK_PCI_RANGE_LOW
78#define GEMTEK_PCI_RANGE_LOW (87*16000)
79#endif
80
81#ifndef GEMTEK_PCI_RANGE_HIGH
82#define GEMTEK_PCI_RANGE_HIGH (108*16000)
83#endif
84
85struct gemtek_pci {
86 struct v4l2_device v4l2_dev;
87 struct video_device vdev;
88 struct mutex lock;
89 struct pci_dev *pdev;
90
91 u32 iobase;
92 u32 length;
93
94 u32 current_frequency;
95 u8 mute;
96};
97
98static inline struct gemtek_pci *to_gemtek_pci(struct v4l2_device *v4l2_dev)
99{
100 return container_of(v4l2_dev, struct gemtek_pci, v4l2_dev);
101}
102
103static inline u8 gemtek_pci_out(u16 value, u32 port)
104{
105 outw(value, port);
106
107 return (u8)value;
108}
109
110#define _b0(v) (*((u8 *)&v))
111
112static void __gemtek_pci_cmd(u16 value, u32 port, u8 *last_byte, int keep)
113{
114 u8 byte = *last_byte;
115
116 if (!value) {
117 if (!keep)
118 value = (u16)port;
119 byte &= 0xfd;
120 } else
121 byte |= 2;
122
123 _b0(value) = byte;
124 outw(value, port);
125 byte |= 1;
126 _b0(value) = byte;
127 outw(value, port);
128 byte &= 0xfe;
129 _b0(value) = byte;
130 outw(value, port);
131
132 *last_byte = byte;
133}
134
135static inline void gemtek_pci_nil(u32 port, u8 *last_byte)
136{
137 __gemtek_pci_cmd(0x00, port, last_byte, false);
138}
139
140static inline void gemtek_pci_cmd(u16 cmd, u32 port, u8 *last_byte)
141{
142 __gemtek_pci_cmd(cmd, port, last_byte, true);
143}
144
145static void gemtek_pci_setfrequency(struct gemtek_pci *card, unsigned long frequency)
146{
147 int i;
148 u32 value = frequency / 200 + 856;
149 u16 mask = 0x8000;
150 u8 last_byte;
151 u32 port = card->iobase;
152
153 mutex_lock(&card->lock);
154 card->current_frequency = frequency;
155 last_byte = gemtek_pci_out(0x06, port);
156
157 i = 0;
158 do {
159 gemtek_pci_nil(port, &last_byte);
160 i++;
161 } while (i < 9);
162
163 i = 0;
164 do {
165 gemtek_pci_cmd(value & mask, port, &last_byte);
166 mask >>= 1;
167 i++;
168 } while (i < 16);
169
170 outw(0x10, port);
171 mutex_unlock(&card->lock);
172}
173
174
175static void gemtek_pci_mute(struct gemtek_pci *card)
176{
177 mutex_lock(&card->lock);
178 outb(0x1f, card->iobase);
179 card->mute = true;
180 mutex_unlock(&card->lock);
181}
182
183static void gemtek_pci_unmute(struct gemtek_pci *card)
184{
185 if (card->mute) {
186 gemtek_pci_setfrequency(card, card->current_frequency);
187 card->mute = false;
188 }
189}
190
191static int gemtek_pci_getsignal(struct gemtek_pci *card)
192{
193 int sig;
194
195 mutex_lock(&card->lock);
196 sig = (inb(card->iobase) & 0x08) ? 0 : 1;
197 mutex_unlock(&card->lock);
198 return sig;
199}
200
201static int vidioc_querycap(struct file *file, void *priv,
202 struct v4l2_capability *v)
203{
204 struct gemtek_pci *card = video_drvdata(file);
205
206 strlcpy(v->driver, "radio-gemtek-pci", sizeof(v->driver));
207 strlcpy(v->card, "GemTek PCI Radio", sizeof(v->card));
208 snprintf(v->bus_info, sizeof(v->bus_info), "PCI:%s", pci_name(card->pdev));
209 v->version = RADIO_VERSION;
210 v->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO;
211 return 0;
212}
213
214static int vidioc_g_tuner(struct file *file, void *priv,
215 struct v4l2_tuner *v)
216{
217 struct gemtek_pci *card = video_drvdata(file);
218
219 if (v->index > 0)
220 return -EINVAL;
221
222 strlcpy(v->name, "FM", sizeof(v->name));
223 v->type = V4L2_TUNER_RADIO;
224 v->rangelow = GEMTEK_PCI_RANGE_LOW;
225 v->rangehigh = GEMTEK_PCI_RANGE_HIGH;
226 v->rxsubchans = V4L2_TUNER_SUB_MONO;
227 v->capability = V4L2_TUNER_CAP_LOW;
228 v->audmode = V4L2_TUNER_MODE_MONO;
229 v->signal = 0xffff * gemtek_pci_getsignal(card);
230 return 0;
231}
232
233static int vidioc_s_tuner(struct file *file, void *priv,
234 struct v4l2_tuner *v)
235{
236 return v->index ? -EINVAL : 0;
237}
238
239static int vidioc_s_frequency(struct file *file, void *priv,
240 struct v4l2_frequency *f)
241{
242 struct gemtek_pci *card = video_drvdata(file);
243
244 if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
245 return -EINVAL;
246 if (f->frequency < GEMTEK_PCI_RANGE_LOW ||
247 f->frequency > GEMTEK_PCI_RANGE_HIGH)
248 return -EINVAL;
249 gemtek_pci_setfrequency(card, f->frequency);
250 card->mute = false;
251 return 0;
252}
253
254static int vidioc_g_frequency(struct file *file, void *priv,
255 struct v4l2_frequency *f)
256{
257 struct gemtek_pci *card = video_drvdata(file);
258
259 if (f->tuner != 0)
260 return -EINVAL;
261 f->type = V4L2_TUNER_RADIO;
262 f->frequency = card->current_frequency;
263 return 0;
264}
265
266static int vidioc_queryctrl(struct file *file, void *priv,
267 struct v4l2_queryctrl *qc)
268{
269 switch (qc->id) {
270 case V4L2_CID_AUDIO_MUTE:
271 return v4l2_ctrl_query_fill(qc, 0, 1, 1, 1);
272 case V4L2_CID_AUDIO_VOLUME:
273 return v4l2_ctrl_query_fill(qc, 0, 65535, 65535, 65535);
274 }
275 return -EINVAL;
276}
277
278static int vidioc_g_ctrl(struct file *file, void *priv,
279 struct v4l2_control *ctrl)
280{
281 struct gemtek_pci *card = video_drvdata(file);
282
283 switch (ctrl->id) {
284 case V4L2_CID_AUDIO_MUTE:
285 ctrl->value = card->mute;
286 return 0;
287 case V4L2_CID_AUDIO_VOLUME:
288 if (card->mute)
289 ctrl->value = 0;
290 else
291 ctrl->value = 65535;
292 return 0;
293 }
294 return -EINVAL;
295}
296
297static int vidioc_s_ctrl(struct file *file, void *priv,
298 struct v4l2_control *ctrl)
299{
300 struct gemtek_pci *card = video_drvdata(file);
301
302 switch (ctrl->id) {
303 case V4L2_CID_AUDIO_MUTE:
304 if (ctrl->value)
305 gemtek_pci_mute(card);
306 else
307 gemtek_pci_unmute(card);
308 return 0;
309 case V4L2_CID_AUDIO_VOLUME:
310 if (ctrl->value)
311 gemtek_pci_unmute(card);
312 else
313 gemtek_pci_mute(card);
314 return 0;
315 }
316 return -EINVAL;
317}
318
319static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i)
320{
321 *i = 0;
322 return 0;
323}
324
325static int vidioc_s_input(struct file *filp, void *priv, unsigned int i)
326{
327 return i ? -EINVAL : 0;
328}
329
330static int vidioc_g_audio(struct file *file, void *priv,
331 struct v4l2_audio *a)
332{
333 a->index = 0;
334 strlcpy(a->name, "Radio", sizeof(a->name));
335 a->capability = V4L2_AUDCAP_STEREO;
336 return 0;
337}
338
339static int vidioc_s_audio(struct file *file, void *priv,
340 struct v4l2_audio *a)
341{
342 return a->index ? -EINVAL : 0;
343}
344
345enum {
346 GEMTEK_PR103
347};
348
349static char *card_names[] __devinitdata = {
350 "GEMTEK_PR103"
351};
352
353static struct pci_device_id gemtek_pci_id[] =
354{
355 { PCI_VENDOR_ID_GEMTEK, PCI_DEVICE_ID_GEMTEK_PR103,
356 PCI_ANY_ID, PCI_ANY_ID, 0, 0, GEMTEK_PR103 },
357 { 0 }
358};
359
360MODULE_DEVICE_TABLE(pci, gemtek_pci_id);
361
362static const struct v4l2_file_operations gemtek_pci_fops = {
363 .owner = THIS_MODULE,
364 .unlocked_ioctl = video_ioctl2,
365};
366
367static const struct v4l2_ioctl_ops gemtek_pci_ioctl_ops = {
368 .vidioc_querycap = vidioc_querycap,
369 .vidioc_g_tuner = vidioc_g_tuner,
370 .vidioc_s_tuner = vidioc_s_tuner,
371 .vidioc_g_audio = vidioc_g_audio,
372 .vidioc_s_audio = vidioc_s_audio,
373 .vidioc_g_input = vidioc_g_input,
374 .vidioc_s_input = vidioc_s_input,
375 .vidioc_g_frequency = vidioc_g_frequency,
376 .vidioc_s_frequency = vidioc_s_frequency,
377 .vidioc_queryctrl = vidioc_queryctrl,
378 .vidioc_g_ctrl = vidioc_g_ctrl,
379 .vidioc_s_ctrl = vidioc_s_ctrl,
380};
381
382static int __devinit gemtek_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
383{
384 struct gemtek_pci *card;
385 struct v4l2_device *v4l2_dev;
386 int res;
387
388 card = kzalloc(sizeof(struct gemtek_pci), GFP_KERNEL);
389 if (card == NULL) {
390 dev_err(&pdev->dev, "out of memory\n");
391 return -ENOMEM;
392 }
393
394 v4l2_dev = &card->v4l2_dev;
395 mutex_init(&card->lock);
396 card->pdev = pdev;
397
398 strlcpy(v4l2_dev->name, "gemtek_pci", sizeof(v4l2_dev->name));
399
400 res = v4l2_device_register(&pdev->dev, v4l2_dev);
401 if (res < 0) {
402 v4l2_err(v4l2_dev, "Could not register v4l2_device\n");
403 kfree(card);
404 return res;
405 }
406
407 if (pci_enable_device(pdev))
408 goto err_pci;
409
410 card->iobase = pci_resource_start(pdev, 0);
411 card->length = pci_resource_len(pdev, 0);
412
413 if (request_region(card->iobase, card->length, card_names[pci_id->driver_data]) == NULL) {
414 v4l2_err(v4l2_dev, "i/o port already in use\n");
415 goto err_pci;
416 }
417
418 strlcpy(card->vdev.name, v4l2_dev->name, sizeof(card->vdev.name));
419 card->vdev.v4l2_dev = v4l2_dev;
420 card->vdev.fops = &gemtek_pci_fops;
421 card->vdev.ioctl_ops = &gemtek_pci_ioctl_ops;
422 card->vdev.release = video_device_release_empty;
423 video_set_drvdata(&card->vdev, card);
424
425 gemtek_pci_mute(card);
426
427 if (video_register_device(&card->vdev, VFL_TYPE_RADIO, nr_radio) < 0)
428 goto err_video;
429
430 v4l2_info(v4l2_dev, "Gemtek PCI Radio (rev. %d) found at 0x%04x-0x%04x.\n",
431 pdev->revision, card->iobase, card->iobase + card->length - 1);
432
433 return 0;
434
435err_video:
436 release_region(card->iobase, card->length);
437
438err_pci:
439 v4l2_device_unregister(v4l2_dev);
440 kfree(card);
441 return -ENODEV;
442}
443
444static void __devexit gemtek_pci_remove(struct pci_dev *pdev)
445{
446 struct v4l2_device *v4l2_dev = dev_get_drvdata(&pdev->dev);
447 struct gemtek_pci *card = to_gemtek_pci(v4l2_dev);
448
449 video_unregister_device(&card->vdev);
450 v4l2_device_unregister(v4l2_dev);
451
452 release_region(card->iobase, card->length);
453
454 if (mx)
455 gemtek_pci_mute(card);
456
457 kfree(card);
458}
459
460static struct pci_driver gemtek_pci_driver = {
461 .name = "gemtek_pci",
462 .id_table = gemtek_pci_id,
463 .probe = gemtek_pci_probe,
464 .remove = __devexit_p(gemtek_pci_remove),
465};
466
467static int __init gemtek_pci_init(void)
468{
469 return pci_register_driver(&gemtek_pci_driver);
470}
471
472static void __exit gemtek_pci_exit(void)
473{
474 pci_unregister_driver(&gemtek_pci_driver);
475}
476
477module_init(gemtek_pci_init);
478module_exit(gemtek_pci_exit);
diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
index 6459a220b0dd..5c2a9058c09f 100644
--- a/drivers/media/radio/radio-maxiradio.c
+++ b/drivers/media/radio/radio-maxiradio.c
@@ -77,8 +77,8 @@ MODULE_PARM_DESC(debug, "activates debug info");
77/* TEA5757 pin mappings */ 77/* TEA5757 pin mappings */
78static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16; 78static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16;
79 79
80#define FREQ_LO (50 * 16000) 80#define FREQ_LO (87 * 16000)
81#define FREQ_HI (150 * 16000) 81#define FREQ_HI (108 * 16000)
82 82
83#define FREQ_IF 171200 /* 10.7*16000 */ 83#define FREQ_IF 171200 /* 10.7*16000 */
84#define FREQ_STEP 200 /* 12.5*16 */ 84#define FREQ_STEP 200 /* 12.5*16 */
diff --git a/drivers/media/radio/radio-wl1273.c b/drivers/media/radio/radio-wl1273.c
index dd6bd364efa0..7ecc8e657663 100644
--- a/drivers/media/radio/radio-wl1273.c
+++ b/drivers/media/radio/radio-wl1273.c
@@ -1407,7 +1407,7 @@ static const struct v4l2_file_operations wl1273_fops = {
1407 .read = wl1273_fm_fops_read, 1407 .read = wl1273_fm_fops_read,
1408 .write = wl1273_fm_fops_write, 1408 .write = wl1273_fm_fops_write,
1409 .poll = wl1273_fm_fops_poll, 1409 .poll = wl1273_fm_fops_poll,
1410 .ioctl = video_ioctl2, 1410 .unlocked_ioctl = video_ioctl2,
1411 .open = wl1273_fm_fops_open, 1411 .open = wl1273_fm_fops_open,
1412 .release = wl1273_fm_fops_release, 1412 .release = wl1273_fm_fops_release,
1413}; 1413};
diff --git a/drivers/media/radio/si470x/radio-si470x-common.c b/drivers/media/radio/si470x/radio-si470x-common.c
index ac76dfe5b3fa..60c176fe328e 100644
--- a/drivers/media/radio/si470x/radio-si470x-common.c
+++ b/drivers/media/radio/si470x/radio-si470x-common.c
@@ -357,7 +357,8 @@ int si470x_start(struct si470x_device *radio)
357 goto done; 357 goto done;
358 358
359 /* sysconfig 1 */ 359 /* sysconfig 1 */
360 radio->registers[SYSCONFIG1] = SYSCONFIG1_DE; 360 radio->registers[SYSCONFIG1] =
361 (de << 11) & SYSCONFIG1_DE; /* DE*/
361 retval = si470x_set_register(radio, SYSCONFIG1); 362 retval = si470x_set_register(radio, SYSCONFIG1);
362 if (retval < 0) 363 if (retval < 0)
363 goto done; 364 goto done;
@@ -687,12 +688,8 @@ static int si470x_vidioc_g_tuner(struct file *file, void *priv,
687 /* driver constants */ 688 /* driver constants */
688 strcpy(tuner->name, "FM"); 689 strcpy(tuner->name, "FM");
689 tuner->type = V4L2_TUNER_RADIO; 690 tuner->type = V4L2_TUNER_RADIO;
690#if defined(CONFIG_USB_SI470X) || defined(CONFIG_USB_SI470X_MODULE)
691 tuner->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO | 691 tuner->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO |
692 V4L2_TUNER_CAP_RDS | V4L2_TUNER_CAP_RDS_BLOCK_IO; 692 V4L2_TUNER_CAP_RDS | V4L2_TUNER_CAP_RDS_BLOCK_IO;
693#else
694 tuner->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO;
695#endif
696 693
697 /* range limits */ 694 /* range limits */
698 switch ((radio->registers[SYSCONFIG2] & SYSCONFIG2_BAND) >> 6) { 695 switch ((radio->registers[SYSCONFIG2] & SYSCONFIG2_BAND) >> 6) {
@@ -718,12 +715,10 @@ static int si470x_vidioc_g_tuner(struct file *file, void *priv,
718 tuner->rxsubchans = V4L2_TUNER_SUB_MONO; 715 tuner->rxsubchans = V4L2_TUNER_SUB_MONO;
719 else 716 else
720 tuner->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO; 717 tuner->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO;
721#if defined(CONFIG_USB_SI470X) || defined(CONFIG_USB_SI470X_MODULE)
722 /* If there is a reliable method of detecting an RDS channel, 718 /* If there is a reliable method of detecting an RDS channel,
723 then this code should check for that before setting this 719 then this code should check for that before setting this
724 RDS subchannel. */ 720 RDS subchannel. */
725 tuner->rxsubchans |= V4L2_TUNER_SUB_RDS; 721 tuner->rxsubchans |= V4L2_TUNER_SUB_RDS;
726#endif
727 722
728 /* mono/stereo selector */ 723 /* mono/stereo selector */
729 if ((radio->registers[POWERCFG] & POWERCFG_MONO) == 0) 724 if ((radio->registers[POWERCFG] & POWERCFG_MONO) == 0)
diff --git a/drivers/media/rc/ene_ir.c b/drivers/media/rc/ene_ir.c
index 80b3c319f698..1ac49139158d 100644
--- a/drivers/media/rc/ene_ir.c
+++ b/drivers/media/rc/ene_ir.c
@@ -446,27 +446,27 @@ static void ene_rx_setup(struct ene_device *dev)
446 446
447select_timeout: 447select_timeout:
448 if (dev->rx_fan_input_inuse) { 448 if (dev->rx_fan_input_inuse) {
449 dev->rdev->rx_resolution = MS_TO_NS(ENE_FW_SAMPLE_PERIOD_FAN); 449 dev->rdev->rx_resolution = US_TO_NS(ENE_FW_SAMPLE_PERIOD_FAN);
450 450
451 /* Fan input doesn't support timeouts, it just ends the 451 /* Fan input doesn't support timeouts, it just ends the
452 input with a maximum sample */ 452 input with a maximum sample */
453 dev->rdev->min_timeout = dev->rdev->max_timeout = 453 dev->rdev->min_timeout = dev->rdev->max_timeout =
454 MS_TO_NS(ENE_FW_SMPL_BUF_FAN_MSK * 454 US_TO_NS(ENE_FW_SMPL_BUF_FAN_MSK *
455 ENE_FW_SAMPLE_PERIOD_FAN); 455 ENE_FW_SAMPLE_PERIOD_FAN);
456 } else { 456 } else {
457 dev->rdev->rx_resolution = MS_TO_NS(sample_period); 457 dev->rdev->rx_resolution = US_TO_NS(sample_period);
458 458
459 /* Theoreticly timeout is unlimited, but we cap it 459 /* Theoreticly timeout is unlimited, but we cap it
460 * because it was seen that on one device, it 460 * because it was seen that on one device, it
461 * would stop sending spaces after around 250 msec. 461 * would stop sending spaces after around 250 msec.
462 * Besides, this is close to 2^32 anyway and timeout is u32. 462 * Besides, this is close to 2^32 anyway and timeout is u32.
463 */ 463 */
464 dev->rdev->min_timeout = MS_TO_NS(127 * sample_period); 464 dev->rdev->min_timeout = US_TO_NS(127 * sample_period);
465 dev->rdev->max_timeout = MS_TO_NS(200000); 465 dev->rdev->max_timeout = US_TO_NS(200000);
466 } 466 }
467 467
468 if (dev->hw_learning_and_tx_capable) 468 if (dev->hw_learning_and_tx_capable)
469 dev->rdev->tx_resolution = MS_TO_NS(sample_period); 469 dev->rdev->tx_resolution = US_TO_NS(sample_period);
470 470
471 if (dev->rdev->timeout > dev->rdev->max_timeout) 471 if (dev->rdev->timeout > dev->rdev->max_timeout)
472 dev->rdev->timeout = dev->rdev->max_timeout; 472 dev->rdev->timeout = dev->rdev->max_timeout;
@@ -801,7 +801,7 @@ static irqreturn_t ene_isr(int irq, void *data)
801 801
802 dbg("RX: %d (%s)", hw_sample, pulse ? "pulse" : "space"); 802 dbg("RX: %d (%s)", hw_sample, pulse ? "pulse" : "space");
803 803
804 ev.duration = MS_TO_NS(hw_sample); 804 ev.duration = US_TO_NS(hw_sample);
805 ev.pulse = pulse; 805 ev.pulse = pulse;
806 ir_raw_event_store_with_filter(dev->rdev, &ev); 806 ir_raw_event_store_with_filter(dev->rdev, &ev);
807 } 807 }
@@ -821,7 +821,7 @@ static void ene_setup_default_settings(struct ene_device *dev)
821 dev->learning_mode_enabled = learning_mode_force; 821 dev->learning_mode_enabled = learning_mode_force;
822 822
823 /* Set reasonable default timeout */ 823 /* Set reasonable default timeout */
824 dev->rdev->timeout = MS_TO_NS(150000); 824 dev->rdev->timeout = US_TO_NS(150000);
825} 825}
826 826
827/* Upload all hardware settings at once. Used at load and resume time */ 827/* Upload all hardware settings at once. Used at load and resume time */
@@ -1004,6 +1004,10 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
1004 /* validate resources */ 1004 /* validate resources */
1005 error = -ENODEV; 1005 error = -ENODEV;
1006 1006
1007 /* init these to -1, as 0 is valid for both */
1008 dev->hw_io = -1;
1009 dev->irq = -1;
1010
1007 if (!pnp_port_valid(pnp_dev, 0) || 1011 if (!pnp_port_valid(pnp_dev, 0) ||
1008 pnp_port_len(pnp_dev, 0) < ENE_IO_SIZE) 1012 pnp_port_len(pnp_dev, 0) < ENE_IO_SIZE)
1009 goto error; 1013 goto error;
@@ -1072,6 +1076,8 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
1072 rdev->input_name = "ENE eHome Infrared Remote Transceiver"; 1076 rdev->input_name = "ENE eHome Infrared Remote Transceiver";
1073 } 1077 }
1074 1078
1079 dev->rdev = rdev;
1080
1075 ene_rx_setup_hw_buffer(dev); 1081 ene_rx_setup_hw_buffer(dev);
1076 ene_setup_default_settings(dev); 1082 ene_setup_default_settings(dev);
1077 ene_setup_hw_settings(dev); 1083 ene_setup_hw_settings(dev);
@@ -1083,7 +1089,6 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)
1083 if (error < 0) 1089 if (error < 0)
1084 goto error; 1090 goto error;
1085 1091
1086 dev->rdev = rdev;
1087 ene_notice("driver has been succesfully loaded"); 1092 ene_notice("driver has been succesfully loaded");
1088 return 0; 1093 return 0;
1089error: 1094error:
diff --git a/drivers/media/rc/ene_ir.h b/drivers/media/rc/ene_ir.h
index c179baf34cb4..337a41d4450b 100644
--- a/drivers/media/rc/ene_ir.h
+++ b/drivers/media/rc/ene_ir.h
@@ -201,8 +201,6 @@
201#define dbg_verbose(format, ...) __dbg(2, format, ## __VA_ARGS__) 201#define dbg_verbose(format, ...) __dbg(2, format, ## __VA_ARGS__)
202#define dbg_regs(format, ...) __dbg(3, format, ## __VA_ARGS__) 202#define dbg_regs(format, ...) __dbg(3, format, ## __VA_ARGS__)
203 203
204#define MS_TO_NS(msec) ((msec) * 1000)
205
206struct ene_device { 204struct ene_device {
207 struct pnp_dev *pnp_dev; 205 struct pnp_dev *pnp_dev;
208 struct rc_dev *rdev; 206 struct rc_dev *rdev;
diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
index 6811512b4e83..e7dc6b46fdfa 100644
--- a/drivers/media/rc/imon.c
+++ b/drivers/media/rc/imon.c
@@ -988,7 +988,6 @@ static int imon_ir_change_protocol(struct rc_dev *rc, u64 rc_type)
988 int retval; 988 int retval;
989 struct imon_context *ictx = rc->priv; 989 struct imon_context *ictx = rc->priv;
990 struct device *dev = ictx->dev; 990 struct device *dev = ictx->dev;
991 bool pad_mouse;
992 unsigned char ir_proto_packet[] = { 991 unsigned char ir_proto_packet[] = {
993 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86 }; 992 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86 };
994 993
@@ -1000,29 +999,20 @@ static int imon_ir_change_protocol(struct rc_dev *rc, u64 rc_type)
1000 case RC_TYPE_RC6: 999 case RC_TYPE_RC6:
1001 dev_dbg(dev, "Configuring IR receiver for MCE protocol\n"); 1000 dev_dbg(dev, "Configuring IR receiver for MCE protocol\n");
1002 ir_proto_packet[0] = 0x01; 1001 ir_proto_packet[0] = 0x01;
1003 pad_mouse = false;
1004 break; 1002 break;
1005 case RC_TYPE_UNKNOWN: 1003 case RC_TYPE_UNKNOWN:
1006 case RC_TYPE_OTHER: 1004 case RC_TYPE_OTHER:
1007 dev_dbg(dev, "Configuring IR receiver for iMON protocol\n"); 1005 dev_dbg(dev, "Configuring IR receiver for iMON protocol\n");
1008 if (pad_stabilize && !nomouse) 1006 if (!pad_stabilize)
1009 pad_mouse = true;
1010 else {
1011 dev_dbg(dev, "PAD stabilize functionality disabled\n"); 1007 dev_dbg(dev, "PAD stabilize functionality disabled\n");
1012 pad_mouse = false;
1013 }
1014 /* ir_proto_packet[0] = 0x00; // already the default */ 1008 /* ir_proto_packet[0] = 0x00; // already the default */
1015 rc_type = RC_TYPE_OTHER; 1009 rc_type = RC_TYPE_OTHER;
1016 break; 1010 break;
1017 default: 1011 default:
1018 dev_warn(dev, "Unsupported IR protocol specified, overriding " 1012 dev_warn(dev, "Unsupported IR protocol specified, overriding "
1019 "to iMON IR protocol\n"); 1013 "to iMON IR protocol\n");
1020 if (pad_stabilize && !nomouse) 1014 if (!pad_stabilize)
1021 pad_mouse = true;
1022 else {
1023 dev_dbg(dev, "PAD stabilize functionality disabled\n"); 1015 dev_dbg(dev, "PAD stabilize functionality disabled\n");
1024 pad_mouse = false;
1025 }
1026 /* ir_proto_packet[0] = 0x00; // already the default */ 1016 /* ir_proto_packet[0] = 0x00; // already the default */
1027 rc_type = RC_TYPE_OTHER; 1017 rc_type = RC_TYPE_OTHER;
1028 break; 1018 break;
@@ -1035,7 +1025,7 @@ static int imon_ir_change_protocol(struct rc_dev *rc, u64 rc_type)
1035 goto out; 1025 goto out;
1036 1026
1037 ictx->rc_type = rc_type; 1027 ictx->rc_type = rc_type;
1038 ictx->pad_mouse = pad_mouse; 1028 ictx->pad_mouse = false;
1039 1029
1040out: 1030out:
1041 return retval; 1031 return retval;
@@ -1517,7 +1507,7 @@ static void imon_incoming_packet(struct imon_context *ictx,
1517 spin_unlock_irqrestore(&ictx->kc_lock, flags); 1507 spin_unlock_irqrestore(&ictx->kc_lock, flags);
1518 return; 1508 return;
1519 } else { 1509 } else {
1520 ictx->pad_mouse = 0; 1510 ictx->pad_mouse = false;
1521 dev_dbg(dev, "mouse mode disabled, passing key value\n"); 1511 dev_dbg(dev, "mouse mode disabled, passing key value\n");
1522 } 1512 }
1523 } 1513 }
@@ -1756,7 +1746,6 @@ static void imon_get_ffdc_type(struct imon_context *ictx)
1756 printk(KERN_CONT " (id 0x%02x)\n", ffdc_cfg_byte); 1746 printk(KERN_CONT " (id 0x%02x)\n", ffdc_cfg_byte);
1757 1747
1758 ictx->display_type = detected_display_type; 1748 ictx->display_type = detected_display_type;
1759 ictx->rdev->allowed_protos = allowed_protos;
1760 ictx->rc_type = allowed_protos; 1749 ictx->rc_type = allowed_protos;
1761} 1750}
1762 1751
@@ -1839,10 +1828,6 @@ static struct rc_dev *imon_init_rdev(struct imon_context *ictx)
1839 rdev->allowed_protos = RC_TYPE_OTHER | RC_TYPE_RC6; /* iMON PAD or MCE */ 1828 rdev->allowed_protos = RC_TYPE_OTHER | RC_TYPE_RC6; /* iMON PAD or MCE */
1840 rdev->change_protocol = imon_ir_change_protocol; 1829 rdev->change_protocol = imon_ir_change_protocol;
1841 rdev->driver_name = MOD_NAME; 1830 rdev->driver_name = MOD_NAME;
1842 if (ictx->rc_type == RC_TYPE_RC6)
1843 rdev->map_name = RC_MAP_IMON_MCE;
1844 else
1845 rdev->map_name = RC_MAP_IMON_PAD;
1846 1831
1847 /* Enable front-panel buttons and/or knobs */ 1832 /* Enable front-panel buttons and/or knobs */
1848 memcpy(ictx->usb_tx_buf, &fp_packet, sizeof(fp_packet)); 1833 memcpy(ictx->usb_tx_buf, &fp_packet, sizeof(fp_packet));
@@ -1851,11 +1836,18 @@ static struct rc_dev *imon_init_rdev(struct imon_context *ictx)
1851 if (ret) 1836 if (ret)
1852 dev_info(ictx->dev, "panel buttons/knobs setup failed\n"); 1837 dev_info(ictx->dev, "panel buttons/knobs setup failed\n");
1853 1838
1854 if (ictx->product == 0xffdc) 1839 if (ictx->product == 0xffdc) {
1855 imon_get_ffdc_type(ictx); 1840 imon_get_ffdc_type(ictx);
1841 rdev->allowed_protos = ictx->rc_type;
1842 }
1856 1843
1857 imon_set_display_type(ictx); 1844 imon_set_display_type(ictx);
1858 1845
1846 if (ictx->rc_type == RC_TYPE_RC6)
1847 rdev->map_name = RC_MAP_IMON_MCE;
1848 else
1849 rdev->map_name = RC_MAP_IMON_PAD;
1850
1859 ret = rc_register_device(rdev); 1851 ret = rc_register_device(rdev);
1860 if (ret < 0) { 1852 if (ret < 0) {
1861 dev_err(ictx->dev, "remote input dev register failed\n"); 1853 dev_err(ictx->dev, "remote input dev register failed\n");
@@ -2108,18 +2100,6 @@ static struct imon_context *imon_init_intf0(struct usb_interface *intf)
2108 goto find_endpoint_failed; 2100 goto find_endpoint_failed;
2109 } 2101 }
2110 2102
2111 ictx->idev = imon_init_idev(ictx);
2112 if (!ictx->idev) {
2113 dev_err(dev, "%s: input device setup failed\n", __func__);
2114 goto idev_setup_failed;
2115 }
2116
2117 ictx->rdev = imon_init_rdev(ictx);
2118 if (!ictx->rdev) {
2119 dev_err(dev, "%s: rc device setup failed\n", __func__);
2120 goto rdev_setup_failed;
2121 }
2122
2123 usb_fill_int_urb(ictx->rx_urb_intf0, ictx->usbdev_intf0, 2103 usb_fill_int_urb(ictx->rx_urb_intf0, ictx->usbdev_intf0,
2124 usb_rcvintpipe(ictx->usbdev_intf0, 2104 usb_rcvintpipe(ictx->usbdev_intf0,
2125 ictx->rx_endpoint_intf0->bEndpointAddress), 2105 ictx->rx_endpoint_intf0->bEndpointAddress),
@@ -2133,13 +2113,25 @@ static struct imon_context *imon_init_intf0(struct usb_interface *intf)
2133 goto urb_submit_failed; 2113 goto urb_submit_failed;
2134 } 2114 }
2135 2115
2116 ictx->idev = imon_init_idev(ictx);
2117 if (!ictx->idev) {
2118 dev_err(dev, "%s: input device setup failed\n", __func__);
2119 goto idev_setup_failed;
2120 }
2121
2122 ictx->rdev = imon_init_rdev(ictx);
2123 if (!ictx->rdev) {
2124 dev_err(dev, "%s: rc device setup failed\n", __func__);
2125 goto rdev_setup_failed;
2126 }
2127
2136 return ictx; 2128 return ictx;
2137 2129
2138urb_submit_failed:
2139 rc_unregister_device(ictx->rdev);
2140rdev_setup_failed: 2130rdev_setup_failed:
2141 input_unregister_device(ictx->idev); 2131 input_unregister_device(ictx->idev);
2142idev_setup_failed: 2132idev_setup_failed:
2133 usb_kill_urb(ictx->rx_urb_intf0);
2134urb_submit_failed:
2143find_endpoint_failed: 2135find_endpoint_failed:
2144 mutex_unlock(&ictx->lock); 2136 mutex_unlock(&ictx->lock);
2145 usb_free_urb(tx_urb); 2137 usb_free_urb(tx_urb);
diff --git a/drivers/media/rc/ir-raw.c b/drivers/media/rc/ir-raw.c
index 185baddcbf14..73230ff93b8a 100644
--- a/drivers/media/rc/ir-raw.c
+++ b/drivers/media/rc/ir-raw.c
@@ -233,7 +233,7 @@ EXPORT_SYMBOL_GPL(ir_raw_event_handle);
233 233
234/* used internally by the sysfs interface */ 234/* used internally by the sysfs interface */
235u64 235u64
236ir_raw_get_allowed_protocols() 236ir_raw_get_allowed_protocols(void)
237{ 237{
238 u64 protocols; 238 u64 protocols;
239 mutex_lock(&ir_raw_handler_lock); 239 mutex_lock(&ir_raw_handler_lock);
diff --git a/drivers/media/rc/keymaps/rc-dib0700-nec.c b/drivers/media/rc/keymaps/rc-dib0700-nec.c
index c59851b203da..7a5f5300caf9 100644
--- a/drivers/media/rc/keymaps/rc-dib0700-nec.c
+++ b/drivers/media/rc/keymaps/rc-dib0700-nec.c
@@ -19,35 +19,35 @@
19 19
20static struct rc_map_table dib0700_nec_table[] = { 20static struct rc_map_table dib0700_nec_table[] = {
21 /* Key codes for the Pixelview SBTVD remote */ 21 /* Key codes for the Pixelview SBTVD remote */
22 { 0x8613, KEY_MUTE }, 22 { 0x866b13, KEY_MUTE },
23 { 0x8612, KEY_POWER }, 23 { 0x866b12, KEY_POWER },
24 { 0x8601, KEY_1 }, 24 { 0x866b01, KEY_1 },
25 { 0x8602, KEY_2 }, 25 { 0x866b02, KEY_2 },
26 { 0x8603, KEY_3 }, 26 { 0x866b03, KEY_3 },
27 { 0x8604, KEY_4 }, 27 { 0x866b04, KEY_4 },
28 { 0x8605, KEY_5 }, 28 { 0x866b05, KEY_5 },
29 { 0x8606, KEY_6 }, 29 { 0x866b06, KEY_6 },
30 { 0x8607, KEY_7 }, 30 { 0x866b07, KEY_7 },
31 { 0x8608, KEY_8 }, 31 { 0x866b08, KEY_8 },
32 { 0x8609, KEY_9 }, 32 { 0x866b09, KEY_9 },
33 { 0x8600, KEY_0 }, 33 { 0x866b00, KEY_0 },
34 { 0x860d, KEY_CHANNELUP }, 34 { 0x866b0d, KEY_CHANNELUP },
35 { 0x8619, KEY_CHANNELDOWN }, 35 { 0x866b19, KEY_CHANNELDOWN },
36 { 0x8610, KEY_VOLUMEUP }, 36 { 0x866b10, KEY_VOLUMEUP },
37 { 0x860c, KEY_VOLUMEDOWN }, 37 { 0x866b0c, KEY_VOLUMEDOWN },
38 38
39 { 0x860a, KEY_CAMERA }, 39 { 0x866b0a, KEY_CAMERA },
40 { 0x860b, KEY_ZOOM }, 40 { 0x866b0b, KEY_ZOOM },
41 { 0x861b, KEY_BACKSPACE }, 41 { 0x866b1b, KEY_BACKSPACE },
42 { 0x8615, KEY_ENTER }, 42 { 0x866b15, KEY_ENTER },
43 43
44 { 0x861d, KEY_UP }, 44 { 0x866b1d, KEY_UP },
45 { 0x861e, KEY_DOWN }, 45 { 0x866b1e, KEY_DOWN },
46 { 0x860e, KEY_LEFT }, 46 { 0x866b0e, KEY_LEFT },
47 { 0x860f, KEY_RIGHT }, 47 { 0x866b0f, KEY_RIGHT },
48 48
49 { 0x8618, KEY_RECORD }, 49 { 0x866b18, KEY_RECORD },
50 { 0x861a, KEY_STOP }, 50 { 0x866b1a, KEY_STOP },
51 51
52 /* Key codes for the EvolutePC TVWay+ remote */ 52 /* Key codes for the EvolutePC TVWay+ remote */
53 { 0x7a00, KEY_MENU }, 53 { 0x7a00, KEY_MENU },
diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c
index 0fef6efad537..079353e5d558 100644
--- a/drivers/media/rc/mceusb.c
+++ b/drivers/media/rc/mceusb.c
@@ -48,7 +48,6 @@
48#define USB_BUFLEN 32 /* USB reception buffer length */ 48#define USB_BUFLEN 32 /* USB reception buffer length */
49#define USB_CTRL_MSG_SZ 2 /* Size of usb ctrl msg on gen1 hw */ 49#define USB_CTRL_MSG_SZ 2 /* Size of usb ctrl msg on gen1 hw */
50#define MCE_G1_INIT_MSGS 40 /* Init messages on gen1 hw to throw out */ 50#define MCE_G1_INIT_MSGS 40 /* Init messages on gen1 hw to throw out */
51#define MS_TO_NS(msec) ((msec) * 1000)
52 51
53/* MCE constants */ 52/* MCE constants */
54#define MCE_CMDBUF_SIZE 384 /* MCE Command buffer length */ 53#define MCE_CMDBUF_SIZE 384 /* MCE Command buffer length */
@@ -858,7 +857,7 @@ static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len)
858 ir->rem--; 857 ir->rem--;
859 rawir.pulse = ((ir->buf_in[i] & MCE_PULSE_BIT) != 0); 858 rawir.pulse = ((ir->buf_in[i] & MCE_PULSE_BIT) != 0);
860 rawir.duration = (ir->buf_in[i] & MCE_PULSE_MASK) 859 rawir.duration = (ir->buf_in[i] & MCE_PULSE_MASK)
861 * MS_TO_NS(MCE_TIME_UNIT); 860 * MS_TO_US(MCE_TIME_UNIT);
862 861
863 dev_dbg(ir->dev, "Storing %s with duration %d\n", 862 dev_dbg(ir->dev, "Storing %s with duration %d\n",
864 rawir.pulse ? "pulse" : "space", 863 rawir.pulse ? "pulse" : "space",
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 72be8a02118c..512a2f4ada0e 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -458,21 +458,27 @@ static int ir_getkeycode(struct input_dev *idev,
458 index = ir_lookup_by_scancode(rc_map, scancode); 458 index = ir_lookup_by_scancode(rc_map, scancode);
459 } 459 }
460 460
461 if (index >= rc_map->len) { 461 if (index < rc_map->len) {
462 if (!(ke->flags & INPUT_KEYMAP_BY_INDEX)) 462 entry = &rc_map->scan[index];
463 IR_dprintk(1, "unknown key for scancode 0x%04x\n", 463
464 scancode); 464 ke->index = index;
465 ke->keycode = entry->keycode;
466 ke->len = sizeof(entry->scancode);
467 memcpy(ke->scancode, &entry->scancode, sizeof(entry->scancode));
468
469 } else if (!(ke->flags & INPUT_KEYMAP_BY_INDEX)) {
470 /*
471 * We do not really know the valid range of scancodes
472 * so let's respond with KEY_RESERVED to anything we
473 * do not have mapping for [yet].
474 */
475 ke->index = index;
476 ke->keycode = KEY_RESERVED;
477 } else {
465 retval = -EINVAL; 478 retval = -EINVAL;
466 goto out; 479 goto out;
467 } 480 }
468 481
469 entry = &rc_map->scan[index];
470
471 ke->index = index;
472 ke->keycode = entry->keycode;
473 ke->len = sizeof(entry->scancode);
474 memcpy(ke->scancode, &entry->scancode, sizeof(entry->scancode));
475
476 retval = 0; 482 retval = 0;
477 483
478out: 484out:
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index eb875af05e79..aa021600e9df 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -78,7 +78,7 @@ config VIDEO_FIXED_MINOR_RANGES
78 78
79config VIDEO_HELPER_CHIPS_AUTO 79config VIDEO_HELPER_CHIPS_AUTO
80 bool "Autoselect pertinent encoders/decoders and other helper chips" 80 bool "Autoselect pertinent encoders/decoders and other helper chips"
81 default y if !EMBEDDED 81 default y if !EXPERT
82 ---help--- 82 ---help---
83 Most video cards may require additional modules to encode or 83 Most video cards may require additional modules to encode or
84 decode audio/video standards. This option will autoselect 84 decode audio/video standards. This option will autoselect
@@ -141,15 +141,6 @@ config VIDEO_TDA9840
141 To compile this driver as a module, choose M here: the 141 To compile this driver as a module, choose M here: the
142 module will be called tda9840. 142 module will be called tda9840.
143 143
144config VIDEO_TDA9875
145 tristate "Philips TDA9875 audio processor"
146 depends on VIDEO_V4L2 && I2C
147 ---help---
148 Support for tda9875 audio decoder chip found on some bt8xx boards.
149
150 To compile this driver as a module, choose M here: the
151 module will be called tda9875.
152
153config VIDEO_TEA6415C 144config VIDEO_TEA6415C
154 tristate "Philips TEA6415C audio processor" 145 tristate "Philips TEA6415C audio processor"
155 depends on I2C 146 depends on I2C
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index 81e38cb0b846..a509d317e258 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -27,7 +27,6 @@ obj-$(CONFIG_VIDEO_V4L2_COMMON) += v4l2-common.o
27obj-$(CONFIG_VIDEO_TUNER) += tuner.o 27obj-$(CONFIG_VIDEO_TUNER) += tuner.o
28obj-$(CONFIG_VIDEO_TVAUDIO) += tvaudio.o 28obj-$(CONFIG_VIDEO_TVAUDIO) += tvaudio.o
29obj-$(CONFIG_VIDEO_TDA7432) += tda7432.o 29obj-$(CONFIG_VIDEO_TDA7432) += tda7432.o
30obj-$(CONFIG_VIDEO_TDA9875) += tda9875.o
31obj-$(CONFIG_VIDEO_SAA6588) += saa6588.o 30obj-$(CONFIG_VIDEO_SAA6588) += saa6588.o
32obj-$(CONFIG_VIDEO_TDA9840) += tda9840.o 31obj-$(CONFIG_VIDEO_TDA9840) += tda9840.o
33obj-$(CONFIG_VIDEO_TEA6415C) += tea6415c.o 32obj-$(CONFIG_VIDEO_TEA6415C) += tea6415c.o
diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c
index f318b51448b3..d2327dbb473f 100644
--- a/drivers/media/video/adv7175.c
+++ b/drivers/media/video/adv7175.c
@@ -303,11 +303,22 @@ static int adv7175_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ide
303 return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_ADV7175, 0); 303 return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_ADV7175, 0);
304} 304}
305 305
306static int adv7175_s_power(struct v4l2_subdev *sd, int on)
307{
308 if (on)
309 adv7175_write(sd, 0x01, 0x00);
310 else
311 adv7175_write(sd, 0x01, 0x78);
312
313 return 0;
314}
315
306/* ----------------------------------------------------------------------- */ 316/* ----------------------------------------------------------------------- */
307 317
308static const struct v4l2_subdev_core_ops adv7175_core_ops = { 318static const struct v4l2_subdev_core_ops adv7175_core_ops = {
309 .g_chip_ident = adv7175_g_chip_ident, 319 .g_chip_ident = adv7175_g_chip_ident,
310 .init = adv7175_init, 320 .init = adv7175_init,
321 .s_power = adv7175_s_power,
311}; 322};
312 323
313static const struct v4l2_subdev_video_ops adv7175_video_ops = { 324static const struct v4l2_subdev_video_ops adv7175_video_ops = {
diff --git a/drivers/media/video/bt8xx/bttv-cards.c b/drivers/media/video/bt8xx/bttv-cards.c
index 49efcf660ba6..7f58756d72c8 100644
--- a/drivers/media/video/bt8xx/bttv-cards.c
+++ b/drivers/media/video/bt8xx/bttv-cards.c
@@ -1373,7 +1373,6 @@ struct tvcard bttv_tvcards[] = {
1373 .gpiomute = 0x1800, 1373 .gpiomute = 0x1800,
1374 .audio_mode_gpio= fv2000s_audio, 1374 .audio_mode_gpio= fv2000s_audio,
1375 .no_msp34xx = 1, 1375 .no_msp34xx = 1,
1376 .no_tda9875 = 1,
1377 .needs_tvaudio = 1, 1376 .needs_tvaudio = 1,
1378 .pll = PLL_28, 1377 .pll = PLL_28,
1379 .tuner_type = TUNER_PHILIPS_PAL, 1378 .tuner_type = TUNER_PHILIPS_PAL,
@@ -1511,7 +1510,6 @@ struct tvcard bttv_tvcards[] = {
1511 .gpiomute = 0x09, 1510 .gpiomute = 0x09,
1512 .needs_tvaudio = 1, 1511 .needs_tvaudio = 1,
1513 .no_msp34xx = 1, 1512 .no_msp34xx = 1,
1514 .no_tda9875 = 1,
1515 .pll = PLL_28, 1513 .pll = PLL_28,
1516 .tuner_type = TUNER_PHILIPS_PAL, 1514 .tuner_type = TUNER_PHILIPS_PAL,
1517 .tuner_addr = ADDR_UNSET, 1515 .tuner_addr = ADDR_UNSET,
@@ -1550,7 +1548,6 @@ struct tvcard bttv_tvcards[] = {
1550 .gpiomask2 = 0x07ff, 1548 .gpiomask2 = 0x07ff,
1551 .muxsel = MUXSEL(3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3), 1549 .muxsel = MUXSEL(3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3),
1552 .no_msp34xx = 1, 1550 .no_msp34xx = 1,
1553 .no_tda9875 = 1,
1554 .tuner_type = TUNER_ABSENT, 1551 .tuner_type = TUNER_ABSENT,
1555 .tuner_addr = ADDR_UNSET, 1552 .tuner_addr = ADDR_UNSET,
1556 .muxsel_hook = rv605_muxsel, 1553 .muxsel_hook = rv605_muxsel,
@@ -1686,7 +1683,6 @@ struct tvcard bttv_tvcards[] = {
1686 .tuner_type = TUNER_ABSENT, 1683 .tuner_type = TUNER_ABSENT,
1687 .tuner_addr = ADDR_UNSET, 1684 .tuner_addr = ADDR_UNSET,
1688 .no_msp34xx = 1, 1685 .no_msp34xx = 1,
1689 .no_tda9875 = 1,
1690 .no_tda7432 = 1, 1686 .no_tda7432 = 1,
1691 }, 1687 },
1692 [BTTV_BOARD_OSPREY1x0_848] = { 1688 [BTTV_BOARD_OSPREY1x0_848] = {
@@ -1699,7 +1695,6 @@ struct tvcard bttv_tvcards[] = {
1699 .tuner_type = TUNER_ABSENT, 1695 .tuner_type = TUNER_ABSENT,
1700 .tuner_addr = ADDR_UNSET, 1696 .tuner_addr = ADDR_UNSET,
1701 .no_msp34xx = 1, 1697 .no_msp34xx = 1,
1702 .no_tda9875 = 1,
1703 .no_tda7432 = 1, 1698 .no_tda7432 = 1,
1704 }, 1699 },
1705 1700
@@ -1714,7 +1709,6 @@ struct tvcard bttv_tvcards[] = {
1714 .tuner_type = TUNER_ABSENT, 1709 .tuner_type = TUNER_ABSENT,
1715 .tuner_addr = ADDR_UNSET, 1710 .tuner_addr = ADDR_UNSET,
1716 .no_msp34xx = 1, 1711 .no_msp34xx = 1,
1717 .no_tda9875 = 1,
1718 .no_tda7432 = 1, 1712 .no_tda7432 = 1,
1719 }, 1713 },
1720 [BTTV_BOARD_OSPREY1x1] = { 1714 [BTTV_BOARD_OSPREY1x1] = {
@@ -1727,7 +1721,6 @@ struct tvcard bttv_tvcards[] = {
1727 .tuner_type = TUNER_ABSENT, 1721 .tuner_type = TUNER_ABSENT,
1728 .tuner_addr = ADDR_UNSET, 1722 .tuner_addr = ADDR_UNSET,
1729 .no_msp34xx = 1, 1723 .no_msp34xx = 1,
1730 .no_tda9875 = 1,
1731 .no_tda7432 = 1, 1724 .no_tda7432 = 1,
1732 }, 1725 },
1733 [BTTV_BOARD_OSPREY1x1_SVID] = { 1726 [BTTV_BOARD_OSPREY1x1_SVID] = {
@@ -1740,7 +1733,6 @@ struct tvcard bttv_tvcards[] = {
1740 .tuner_type = TUNER_ABSENT, 1733 .tuner_type = TUNER_ABSENT,
1741 .tuner_addr = ADDR_UNSET, 1734 .tuner_addr = ADDR_UNSET,
1742 .no_msp34xx = 1, 1735 .no_msp34xx = 1,
1743 .no_tda9875 = 1,
1744 .no_tda7432 = 1, 1736 .no_tda7432 = 1,
1745 }, 1737 },
1746 [BTTV_BOARD_OSPREY2xx] = { 1738 [BTTV_BOARD_OSPREY2xx] = {
@@ -1753,7 +1745,6 @@ struct tvcard bttv_tvcards[] = {
1753 .tuner_type = TUNER_ABSENT, 1745 .tuner_type = TUNER_ABSENT,
1754 .tuner_addr = ADDR_UNSET, 1746 .tuner_addr = ADDR_UNSET,
1755 .no_msp34xx = 1, 1747 .no_msp34xx = 1,
1756 .no_tda9875 = 1,
1757 .no_tda7432 = 1, 1748 .no_tda7432 = 1,
1758 }, 1749 },
1759 1750
@@ -1768,7 +1759,6 @@ struct tvcard bttv_tvcards[] = {
1768 .tuner_type = TUNER_ABSENT, 1759 .tuner_type = TUNER_ABSENT,
1769 .tuner_addr = ADDR_UNSET, 1760 .tuner_addr = ADDR_UNSET,
1770 .no_msp34xx = 1, 1761 .no_msp34xx = 1,
1771 .no_tda9875 = 1,
1772 .no_tda7432 = 1, 1762 .no_tda7432 = 1,
1773 }, 1763 },
1774 [BTTV_BOARD_OSPREY2x0] = { 1764 [BTTV_BOARD_OSPREY2x0] = {
@@ -1781,7 +1771,6 @@ struct tvcard bttv_tvcards[] = {
1781 .tuner_type = TUNER_ABSENT, 1771 .tuner_type = TUNER_ABSENT,
1782 .tuner_addr = ADDR_UNSET, 1772 .tuner_addr = ADDR_UNSET,
1783 .no_msp34xx = 1, 1773 .no_msp34xx = 1,
1784 .no_tda9875 = 1,
1785 .no_tda7432 = 1, 1774 .no_tda7432 = 1,
1786 }, 1775 },
1787 [BTTV_BOARD_OSPREY500] = { 1776 [BTTV_BOARD_OSPREY500] = {
@@ -1794,7 +1783,6 @@ struct tvcard bttv_tvcards[] = {
1794 .tuner_type = TUNER_ABSENT, 1783 .tuner_type = TUNER_ABSENT,
1795 .tuner_addr = ADDR_UNSET, 1784 .tuner_addr = ADDR_UNSET,
1796 .no_msp34xx = 1, 1785 .no_msp34xx = 1,
1797 .no_tda9875 = 1,
1798 .no_tda7432 = 1, 1786 .no_tda7432 = 1,
1799 }, 1787 },
1800 [BTTV_BOARD_OSPREY540] = { 1788 [BTTV_BOARD_OSPREY540] = {
@@ -1805,7 +1793,6 @@ struct tvcard bttv_tvcards[] = {
1805 .tuner_type = TUNER_ABSENT, 1793 .tuner_type = TUNER_ABSENT,
1806 .tuner_addr = ADDR_UNSET, 1794 .tuner_addr = ADDR_UNSET,
1807 .no_msp34xx = 1, 1795 .no_msp34xx = 1,
1808 .no_tda9875 = 1,
1809 .no_tda7432 = 1, 1796 .no_tda7432 = 1,
1810 }, 1797 },
1811 1798
@@ -1820,7 +1807,6 @@ struct tvcard bttv_tvcards[] = {
1820 .tuner_type = TUNER_ABSENT, 1807 .tuner_type = TUNER_ABSENT,
1821 .tuner_addr = ADDR_UNSET, 1808 .tuner_addr = ADDR_UNSET,
1822 .no_msp34xx = 1, 1809 .no_msp34xx = 1,
1823 .no_tda9875 = 1,
1824 .no_tda7432 = 1, /* must avoid, conflicts with the bt860 */ 1810 .no_tda7432 = 1, /* must avoid, conflicts with the bt860 */
1825 }, 1811 },
1826 [BTTV_BOARD_IDS_EAGLE] = { 1812 [BTTV_BOARD_IDS_EAGLE] = {
@@ -1835,7 +1821,6 @@ struct tvcard bttv_tvcards[] = {
1835 .muxsel = MUXSEL(2, 2, 2, 2), 1821 .muxsel = MUXSEL(2, 2, 2, 2),
1836 .muxsel_hook = eagle_muxsel, 1822 .muxsel_hook = eagle_muxsel,
1837 .no_msp34xx = 1, 1823 .no_msp34xx = 1,
1838 .no_tda9875 = 1,
1839 .pll = PLL_28, 1824 .pll = PLL_28,
1840 }, 1825 },
1841 [BTTV_BOARD_PINNACLESAT] = { 1826 [BTTV_BOARD_PINNACLESAT] = {
@@ -1846,7 +1831,6 @@ struct tvcard bttv_tvcards[] = {
1846 .tuner_type = TUNER_ABSENT, 1831 .tuner_type = TUNER_ABSENT,
1847 .tuner_addr = ADDR_UNSET, 1832 .tuner_addr = ADDR_UNSET,
1848 .no_msp34xx = 1, 1833 .no_msp34xx = 1,
1849 .no_tda9875 = 1,
1850 .no_tda7432 = 1, 1834 .no_tda7432 = 1,
1851 .muxsel = MUXSEL(3, 1), 1835 .muxsel = MUXSEL(3, 1),
1852 .pll = PLL_28, 1836 .pll = PLL_28,
@@ -1897,7 +1881,6 @@ struct tvcard bttv_tvcards[] = {
1897 .svhs = 2, 1881 .svhs = 2,
1898 .gpiomask = 0, 1882 .gpiomask = 0,
1899 .no_msp34xx = 1, 1883 .no_msp34xx = 1,
1900 .no_tda9875 = 1,
1901 .no_tda7432 = 1, 1884 .no_tda7432 = 1,
1902 .muxsel = MUXSEL(2, 0, 1), 1885 .muxsel = MUXSEL(2, 0, 1),
1903 .pll = PLL_28, 1886 .pll = PLL_28,
@@ -1970,7 +1953,6 @@ struct tvcard bttv_tvcards[] = {
1970 /* Tuner, CVid, SVid, CVid over SVid connector */ 1953 /* Tuner, CVid, SVid, CVid over SVid connector */
1971 .muxsel = MUXSEL(2, 3, 1, 1), 1954 .muxsel = MUXSEL(2, 3, 1, 1),
1972 .gpiomask = 0, 1955 .gpiomask = 0,
1973 .no_tda9875 = 1,
1974 .no_tda7432 = 1, 1956 .no_tda7432 = 1,
1975 .tuner_type = TUNER_PHILIPS_PAL_I, 1957 .tuner_type = TUNER_PHILIPS_PAL_I,
1976 .tuner_addr = ADDR_UNSET, 1958 .tuner_addr = ADDR_UNSET,
@@ -2017,7 +1999,6 @@ struct tvcard bttv_tvcards[] = {
2017 .muxsel = MUXSEL(2,2,2,2, 3,3,3,3, 1,1,1,1, 0,0,0,0), 1999 .muxsel = MUXSEL(2,2,2,2, 3,3,3,3, 1,1,1,1, 0,0,0,0),
2018 .muxsel_hook = xguard_muxsel, 2000 .muxsel_hook = xguard_muxsel,
2019 .no_msp34xx = 1, 2001 .no_msp34xx = 1,
2020 .no_tda9875 = 1,
2021 .no_tda7432 = 1, 2002 .no_tda7432 = 1,
2022 .pll = PLL_28, 2003 .pll = PLL_28,
2023 }, 2004 },
@@ -2029,7 +2010,6 @@ struct tvcard bttv_tvcards[] = {
2029 .svhs = NO_SVHS, 2010 .svhs = NO_SVHS,
2030 .muxsel = MUXSEL(2, 3, 1, 0), 2011 .muxsel = MUXSEL(2, 3, 1, 0),
2031 .no_msp34xx = 1, 2012 .no_msp34xx = 1,
2032 .no_tda9875 = 1,
2033 .no_tda7432 = 1, 2013 .no_tda7432 = 1,
2034 .pll = PLL_28, 2014 .pll = PLL_28,
2035 .tuner_type = TUNER_ABSENT, 2015 .tuner_type = TUNER_ABSENT,
@@ -2134,7 +2114,6 @@ struct tvcard bttv_tvcards[] = {
2134 .svhs = NO_SVHS, /* card has no svhs */ 2114 .svhs = NO_SVHS, /* card has no svhs */
2135 .needs_tvaudio = 0, 2115 .needs_tvaudio = 0,
2136 .no_msp34xx = 1, 2116 .no_msp34xx = 1,
2137 .no_tda9875 = 1,
2138 .no_tda7432 = 1, 2117 .no_tda7432 = 1,
2139 .gpiomask = 0x00, 2118 .gpiomask = 0x00,
2140 .muxsel = MUXSEL(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), 2119 .muxsel = MUXSEL(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
@@ -2156,7 +2135,6 @@ struct tvcard bttv_tvcards[] = {
2156 [BTTV_BOARD_TWINHAN_DST] = { 2135 [BTTV_BOARD_TWINHAN_DST] = {
2157 .name = "Twinhan DST + clones", 2136 .name = "Twinhan DST + clones",
2158 .no_msp34xx = 1, 2137 .no_msp34xx = 1,
2159 .no_tda9875 = 1,
2160 .no_tda7432 = 1, 2138 .no_tda7432 = 1,
2161 .tuner_type = TUNER_ABSENT, 2139 .tuner_type = TUNER_ABSENT,
2162 .tuner_addr = ADDR_UNSET, 2140 .tuner_addr = ADDR_UNSET,
@@ -2171,7 +2149,6 @@ struct tvcard bttv_tvcards[] = {
2171 /* Vid In, SVid In, Vid over SVid in connector */ 2149 /* Vid In, SVid In, Vid over SVid in connector */
2172 .muxsel = MUXSEL(3, 1, 1, 3), 2150 .muxsel = MUXSEL(3, 1, 1, 3),
2173 .no_msp34xx = 1, 2151 .no_msp34xx = 1,
2174 .no_tda9875 = 1,
2175 .no_tda7432 = 1, 2152 .no_tda7432 = 1,
2176 .tuner_type = TUNER_ABSENT, 2153 .tuner_type = TUNER_ABSENT,
2177 .tuner_addr = ADDR_UNSET, 2154 .tuner_addr = ADDR_UNSET,
@@ -2226,7 +2203,6 @@ struct tvcard bttv_tvcards[] = {
2226 .svhs = NO_SVHS, 2203 .svhs = NO_SVHS,
2227 .muxsel = MUXSEL(2, 3, 1, 0), 2204 .muxsel = MUXSEL(2, 3, 1, 0),
2228 .no_msp34xx = 1, 2205 .no_msp34xx = 1,
2229 .no_tda9875 = 1,
2230 .no_tda7432 = 1, 2206 .no_tda7432 = 1,
2231 .needs_tvaudio = 0, 2207 .needs_tvaudio = 0,
2232 .tuner_type = TUNER_ABSENT, 2208 .tuner_type = TUNER_ABSENT,
@@ -2278,7 +2254,6 @@ struct tvcard bttv_tvcards[] = {
2278 .gpiomask = 0, 2254 .gpiomask = 0,
2279 .gpiomask2 = 0x3C<<16,/*Set the GPIO[18]->GPIO[21] as output pin.==> drive the video inputs through analog multiplexers*/ 2255 .gpiomask2 = 0x3C<<16,/*Set the GPIO[18]->GPIO[21] as output pin.==> drive the video inputs through analog multiplexers*/
2280 .no_msp34xx = 1, 2256 .no_msp34xx = 1,
2281 .no_tda9875 = 1,
2282 .no_tda7432 = 1, 2257 .no_tda7432 = 1,
2283 /*878A input is always MUX0, see above.*/ 2258 /*878A input is always MUX0, see above.*/
2284 .muxsel = MUXSEL(2, 2, 2, 2), 2259 .muxsel = MUXSEL(2, 2, 2, 2),
@@ -2302,7 +2277,6 @@ struct tvcard bttv_tvcards[] = {
2302 .tuner_type = TUNER_TEMIC_PAL, 2277 .tuner_type = TUNER_TEMIC_PAL,
2303 .tuner_addr = ADDR_UNSET, 2278 .tuner_addr = ADDR_UNSET,
2304 .no_msp34xx = 1, 2279 .no_msp34xx = 1,
2305 .no_tda9875 = 1,
2306 }, 2280 },
2307 [BTTV_BOARD_AVDVBT_771] = { 2281 [BTTV_BOARD_AVDVBT_771] = {
2308 /* Wolfram Joost <wojo@frokaschwei.de> */ 2282 /* Wolfram Joost <wojo@frokaschwei.de> */
@@ -2313,7 +2287,6 @@ struct tvcard bttv_tvcards[] = {
2313 .tuner_addr = ADDR_UNSET, 2287 .tuner_addr = ADDR_UNSET,
2314 .muxsel = MUXSEL(3, 3), 2288 .muxsel = MUXSEL(3, 3),
2315 .no_msp34xx = 1, 2289 .no_msp34xx = 1,
2316 .no_tda9875 = 1,
2317 .no_tda7432 = 1, 2290 .no_tda7432 = 1,
2318 .pll = PLL_28, 2291 .pll = PLL_28,
2319 .has_dvb = 1, 2292 .has_dvb = 1,
@@ -2329,7 +2302,6 @@ struct tvcard bttv_tvcards[] = {
2329 .svhs = 1, 2302 .svhs = 1,
2330 .muxsel = MUXSEL(3, 1, 2, 0), /* Comp0, S-Video, ?, ? */ 2303 .muxsel = MUXSEL(3, 1, 2, 0), /* Comp0, S-Video, ?, ? */
2331 .no_msp34xx = 1, 2304 .no_msp34xx = 1,
2332 .no_tda9875 = 1,
2333 .no_tda7432 = 1, 2305 .no_tda7432 = 1,
2334 .pll = PLL_28, 2306 .pll = PLL_28,
2335 .tuner_type = TUNER_ABSENT, 2307 .tuner_type = TUNER_ABSENT,
@@ -2393,7 +2365,6 @@ struct tvcard bttv_tvcards[] = {
2393 /* Chris Pascoe <c.pascoe@itee.uq.edu.au> */ 2365 /* Chris Pascoe <c.pascoe@itee.uq.edu.au> */
2394 .name = "DViCO FusionHDTV DVB-T Lite", 2366 .name = "DViCO FusionHDTV DVB-T Lite",
2395 .no_msp34xx = 1, 2367 .no_msp34xx = 1,
2396 .no_tda9875 = 1,
2397 .no_tda7432 = 1, 2368 .no_tda7432 = 1,
2398 .pll = PLL_28, 2369 .pll = PLL_28,
2399 .no_video = 1, 2370 .no_video = 1,
@@ -2440,7 +2411,6 @@ struct tvcard bttv_tvcards[] = {
2440 .muxsel = MUXSEL(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2), 2411 .muxsel = MUXSEL(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2),
2441 .pll = PLL_28, 2412 .pll = PLL_28,
2442 .no_msp34xx = 1, 2413 .no_msp34xx = 1,
2443 .no_tda9875 = 1,
2444 .no_tda7432 = 1, 2414 .no_tda7432 = 1,
2445 .tuner_type = TUNER_ABSENT, 2415 .tuner_type = TUNER_ABSENT,
2446 .tuner_addr = ADDR_UNSET, 2416 .tuner_addr = ADDR_UNSET,
@@ -2478,7 +2448,6 @@ struct tvcard bttv_tvcards[] = {
2478 .pll = PLL_28, 2448 .pll = PLL_28,
2479 .no_msp34xx = 1, 2449 .no_msp34xx = 1,
2480 .no_tda7432 = 1, 2450 .no_tda7432 = 1,
2481 .no_tda9875 = 1,
2482 .muxsel_hook = kodicom4400r_muxsel, 2451 .muxsel_hook = kodicom4400r_muxsel,
2483 }, 2452 },
2484 [BTTV_BOARD_KODICOM_4400R_SL] = { 2453 [BTTV_BOARD_KODICOM_4400R_SL] = {
@@ -2500,7 +2469,6 @@ struct tvcard bttv_tvcards[] = {
2500 .pll = PLL_28, 2469 .pll = PLL_28,
2501 .no_msp34xx = 1, 2470 .no_msp34xx = 1,
2502 .no_tda7432 = 1, 2471 .no_tda7432 = 1,
2503 .no_tda9875 = 1,
2504 .muxsel_hook = kodicom4400r_muxsel, 2472 .muxsel_hook = kodicom4400r_muxsel,
2505 }, 2473 },
2506 /* ---- card 0x86---------------------------------- */ 2474 /* ---- card 0x86---------------------------------- */
@@ -2530,7 +2498,6 @@ struct tvcard bttv_tvcards[] = {
2530 .gpiomux = { 0x00400005, 0, 0x00000001, 0 }, 2498 .gpiomux = { 0x00400005, 0, 0x00000001, 0 },
2531 .gpiomute = 0x00c00007, 2499 .gpiomute = 0x00c00007,
2532 .no_msp34xx = 1, 2500 .no_msp34xx = 1,
2533 .no_tda9875 = 1,
2534 .no_tda7432 = 1, 2501 .no_tda7432 = 1,
2535 .has_dvb = 1, 2502 .has_dvb = 1,
2536 }, 2503 },
@@ -2630,7 +2597,6 @@ struct tvcard bttv_tvcards[] = {
2630 .tuner_type = TUNER_ABSENT, 2597 .tuner_type = TUNER_ABSENT,
2631 .tuner_addr = ADDR_UNSET, 2598 .tuner_addr = ADDR_UNSET,
2632 .no_msp34xx = 1, 2599 .no_msp34xx = 1,
2633 .no_tda9875 = 1,
2634 .no_tda7432 = 1, 2600 .no_tda7432 = 1,
2635 }, 2601 },
2636 /* ---- card 0x8d ---------------------------------- */ 2602 /* ---- card 0x8d ---------------------------------- */
@@ -2658,7 +2624,6 @@ struct tvcard bttv_tvcards[] = {
2658 .muxsel = MUXSEL(2, 3, 1, 1), 2624 .muxsel = MUXSEL(2, 3, 1, 1),
2659 .gpiomux = { 100000, 100002, 100002, 100000 }, 2625 .gpiomux = { 100000, 100002, 100002, 100000 },
2660 .no_msp34xx = 1, 2626 .no_msp34xx = 1,
2661 .no_tda9875 = 1,
2662 .no_tda7432 = 1, 2627 .no_tda7432 = 1,
2663 .pll = PLL_28, 2628 .pll = PLL_28,
2664 .tuner_type = TUNER_TNF_5335MF, 2629 .tuner_type = TUNER_TNF_5335MF,
@@ -2674,7 +2639,6 @@ struct tvcard bttv_tvcards[] = {
2674 .gpiomask = 0x0f, /* old: 7 */ 2639 .gpiomask = 0x0f, /* old: 7 */
2675 .muxsel = MUXSEL(0, 1, 3, 2), /* Composite 0-3 */ 2640 .muxsel = MUXSEL(0, 1, 3, 2), /* Composite 0-3 */
2676 .no_msp34xx = 1, 2641 .no_msp34xx = 1,
2677 .no_tda9875 = 1,
2678 .no_tda7432 = 1, 2642 .no_tda7432 = 1,
2679 .tuner_type = TUNER_ABSENT, 2643 .tuner_type = TUNER_ABSENT,
2680 .tuner_addr = ADDR_UNSET, 2644 .tuner_addr = ADDR_UNSET,
@@ -2732,7 +2696,6 @@ struct tvcard bttv_tvcards[] = {
2732 .gpiomux = { 0x00400005, 0, 0x00000001, 0 }, 2696 .gpiomux = { 0x00400005, 0, 0x00000001, 0 },
2733 .gpiomute = 0x00c00007, 2697 .gpiomute = 0x00c00007,
2734 .no_msp34xx = 1, 2698 .no_msp34xx = 1,
2735 .no_tda9875 = 1,
2736 .no_tda7432 = 1, 2699 .no_tda7432 = 1,
2737 }, 2700 },
2738 /* ---- card 0x95---------------------------------- */ 2701 /* ---- card 0x95---------------------------------- */
@@ -2874,7 +2837,6 @@ struct tvcard bttv_tvcards[] = {
2874 .pll = PLL_28, 2837 .pll = PLL_28,
2875 .no_msp34xx = 1, 2838 .no_msp34xx = 1,
2876 .no_tda7432 = 1, 2839 .no_tda7432 = 1,
2877 .no_tda9875 = 1,
2878 .muxsel_hook = gv800s_muxsel, 2840 .muxsel_hook = gv800s_muxsel,
2879 }, 2841 },
2880 [BTTV_BOARD_GEOVISION_GV800S_SL] = { 2842 [BTTV_BOARD_GEOVISION_GV800S_SL] = {
@@ -2899,7 +2861,6 @@ struct tvcard bttv_tvcards[] = {
2899 .pll = PLL_28, 2861 .pll = PLL_28,
2900 .no_msp34xx = 1, 2862 .no_msp34xx = 1,
2901 .no_tda7432 = 1, 2863 .no_tda7432 = 1,
2902 .no_tda9875 = 1,
2903 .muxsel_hook = gv800s_muxsel, 2864 .muxsel_hook = gv800s_muxsel,
2904 }, 2865 },
2905 [BTTV_BOARD_PV183] = { 2866 [BTTV_BOARD_PV183] = {
diff --git a/drivers/media/video/bt8xx/bttv.h b/drivers/media/video/bt8xx/bttv.h
index fd62bf15d779..c6333595c6b9 100644
--- a/drivers/media/video/bt8xx/bttv.h
+++ b/drivers/media/video/bt8xx/bttv.h
@@ -234,7 +234,6 @@ struct tvcard {
234 234
235 /* i2c audio flags */ 235 /* i2c audio flags */
236 unsigned int no_msp34xx:1; 236 unsigned int no_msp34xx:1;
237 unsigned int no_tda9875:1;
238 unsigned int no_tda7432:1; 237 unsigned int no_tda7432:1;
239 unsigned int needs_tvaudio:1; 238 unsigned int needs_tvaudio:1;
240 unsigned int msp34xx_alt:1; 239 unsigned int msp34xx_alt:1;
diff --git a/drivers/media/video/cafe_ccic.c b/drivers/media/video/cafe_ccic.c
index 49f1b8f1418e..55ffd60ffa7f 100644
--- a/drivers/media/video/cafe_ccic.c
+++ b/drivers/media/video/cafe_ccic.c
@@ -2001,6 +2001,11 @@ static int cafe_pci_probe(struct pci_dev *pdev,
2001 .min_width = 320, 2001 .min_width = 320,
2002 .min_height = 240, 2002 .min_height = 240,
2003 }; 2003 };
2004 struct i2c_board_info ov7670_info = {
2005 .type = "ov7670",
2006 .addr = 0x42,
2007 .platform_data = &sensor_cfg,
2008 };
2004 2009
2005 /* 2010 /*
2006 * Start putting together one of our big camera structures. 2011 * Start putting together one of our big camera structures.
@@ -2062,9 +2067,9 @@ static int cafe_pci_probe(struct pci_dev *pdev,
2062 if (dmi_check_system(olpc_xo1_dmi)) 2067 if (dmi_check_system(olpc_xo1_dmi))
2063 sensor_cfg.clock_speed = 45; 2068 sensor_cfg.clock_speed = 45;
2064 2069
2065 cam->sensor_addr = 0x42; 2070 cam->sensor_addr = ov7670_info.addr;
2066 cam->sensor = v4l2_i2c_new_subdev_cfg(&cam->v4l2_dev, &cam->i2c_adapter, 2071 cam->sensor = v4l2_i2c_new_subdev_board(&cam->v4l2_dev, &cam->i2c_adapter,
2067 "ov7670", 0, &sensor_cfg, cam->sensor_addr, NULL); 2072 &ov7670_info, NULL);
2068 if (cam->sensor == NULL) { 2073 if (cam->sensor == NULL) {
2069 ret = -ENODEV; 2074 ret = -ENODEV;
2070 goto out_smbus; 2075 goto out_smbus;
diff --git a/drivers/media/video/cpia2/cpia2.h b/drivers/media/video/cpia2/cpia2.h
index 916c13d5cf7d..6d6d1843791c 100644
--- a/drivers/media/video/cpia2/cpia2.h
+++ b/drivers/media/video/cpia2/cpia2.h
@@ -378,7 +378,7 @@ struct cpia2_fh {
378 378
379struct camera_data { 379struct camera_data {
380 /* locks */ 380 /* locks */
381 struct mutex busy_lock; /* guard against SMP multithreading */ 381 struct mutex v4l2_lock; /* serialize file operations */
382 struct v4l2_prio_state prio; 382 struct v4l2_prio_state prio;
383 383
384 /* camera status */ 384 /* camera status */
diff --git a/drivers/media/video/cpia2/cpia2_core.c b/drivers/media/video/cpia2/cpia2_core.c
index 9606bc01b803..aaffca8e13fd 100644
--- a/drivers/media/video/cpia2/cpia2_core.c
+++ b/drivers/media/video/cpia2/cpia2_core.c
@@ -2247,7 +2247,7 @@ struct camera_data *cpia2_init_camera_struct(void)
2247 2247
2248 2248
2249 cam->present = 1; 2249 cam->present = 1;
2250 mutex_init(&cam->busy_lock); 2250 mutex_init(&cam->v4l2_lock);
2251 init_waitqueue_head(&cam->wq_stream); 2251 init_waitqueue_head(&cam->wq_stream);
2252 2252
2253 return cam; 2253 return cam;
@@ -2365,9 +2365,9 @@ long cpia2_read(struct camera_data *cam,
2365 char __user *buf, unsigned long count, int noblock) 2365 char __user *buf, unsigned long count, int noblock)
2366{ 2366{
2367 struct framebuf *frame; 2367 struct framebuf *frame;
2368 if (!count) { 2368
2369 if (!count)
2369 return 0; 2370 return 0;
2370 }
2371 2371
2372 if (!buf) { 2372 if (!buf) {
2373 ERR("%s: buffer NULL\n",__func__); 2373 ERR("%s: buffer NULL\n",__func__);
@@ -2379,17 +2379,12 @@ long cpia2_read(struct camera_data *cam,
2379 return -EINVAL; 2379 return -EINVAL;
2380 } 2380 }
2381 2381
2382 /* make this _really_ smp and multithread-safe */
2383 if (mutex_lock_interruptible(&cam->busy_lock))
2384 return -ERESTARTSYS;
2385
2386 if (!cam->present) { 2382 if (!cam->present) {
2387 LOG("%s: camera removed\n",__func__); 2383 LOG("%s: camera removed\n",__func__);
2388 mutex_unlock(&cam->busy_lock);
2389 return 0; /* EOF */ 2384 return 0; /* EOF */
2390 } 2385 }
2391 2386
2392 if(!cam->streaming) { 2387 if (!cam->streaming) {
2393 /* Start streaming */ 2388 /* Start streaming */
2394 cpia2_usb_stream_start(cam, 2389 cpia2_usb_stream_start(cam,
2395 cam->params.camera_state.stream_mode); 2390 cam->params.camera_state.stream_mode);
@@ -2398,42 +2393,31 @@ long cpia2_read(struct camera_data *cam,
2398 /* Copy cam->curbuff in case it changes while we're processing */ 2393 /* Copy cam->curbuff in case it changes while we're processing */
2399 frame = cam->curbuff; 2394 frame = cam->curbuff;
2400 if (noblock && frame->status != FRAME_READY) { 2395 if (noblock && frame->status != FRAME_READY) {
2401 mutex_unlock(&cam->busy_lock);
2402 return -EAGAIN; 2396 return -EAGAIN;
2403 } 2397 }
2404 2398
2405 if(frame->status != FRAME_READY) { 2399 if (frame->status != FRAME_READY) {
2406 mutex_unlock(&cam->busy_lock); 2400 mutex_unlock(&cam->v4l2_lock);
2407 wait_event_interruptible(cam->wq_stream, 2401 wait_event_interruptible(cam->wq_stream,
2408 !cam->present || 2402 !cam->present ||
2409 (frame = cam->curbuff)->status == FRAME_READY); 2403 (frame = cam->curbuff)->status == FRAME_READY);
2404 mutex_lock(&cam->v4l2_lock);
2410 if (signal_pending(current)) 2405 if (signal_pending(current))
2411 return -ERESTARTSYS; 2406 return -ERESTARTSYS;
2412 /* make this _really_ smp and multithread-safe */ 2407 if (!cam->present)
2413 if (mutex_lock_interruptible(&cam->busy_lock)) {
2414 return -ERESTARTSYS;
2415 }
2416 if(!cam->present) {
2417 mutex_unlock(&cam->busy_lock);
2418 return 0; 2408 return 0;
2419 }
2420 } 2409 }
2421 2410
2422 /* copy data to user space */ 2411 /* copy data to user space */
2423 if (frame->length > count) { 2412 if (frame->length > count)
2424 mutex_unlock(&cam->busy_lock);
2425 return -EFAULT; 2413 return -EFAULT;
2426 } 2414 if (copy_to_user(buf, frame->data, frame->length))
2427 if (copy_to_user(buf, frame->data, frame->length)) {
2428 mutex_unlock(&cam->busy_lock);
2429 return -EFAULT; 2415 return -EFAULT;
2430 }
2431 2416
2432 count = frame->length; 2417 count = frame->length;
2433 2418
2434 frame->status = FRAME_EMPTY; 2419 frame->status = FRAME_EMPTY;
2435 2420
2436 mutex_unlock(&cam->busy_lock);
2437 return count; 2421 return count;
2438} 2422}
2439 2423
@@ -2447,17 +2431,13 @@ unsigned int cpia2_poll(struct camera_data *cam, struct file *filp,
2447{ 2431{
2448 unsigned int status=0; 2432 unsigned int status=0;
2449 2433
2450 if(!cam) { 2434 if (!cam) {
2451 ERR("%s: Internal error, camera_data not found!\n",__func__); 2435 ERR("%s: Internal error, camera_data not found!\n",__func__);
2452 return POLLERR; 2436 return POLLERR;
2453 } 2437 }
2454 2438
2455 mutex_lock(&cam->busy_lock); 2439 if (!cam->present)
2456
2457 if(!cam->present) {
2458 mutex_unlock(&cam->busy_lock);
2459 return POLLHUP; 2440 return POLLHUP;
2460 }
2461 2441
2462 if(!cam->streaming) { 2442 if(!cam->streaming) {
2463 /* Start streaming */ 2443 /* Start streaming */
@@ -2465,16 +2445,13 @@ unsigned int cpia2_poll(struct camera_data *cam, struct file *filp,
2465 cam->params.camera_state.stream_mode); 2445 cam->params.camera_state.stream_mode);
2466 } 2446 }
2467 2447
2468 mutex_unlock(&cam->busy_lock);
2469 poll_wait(filp, &cam->wq_stream, wait); 2448 poll_wait(filp, &cam->wq_stream, wait);
2470 mutex_lock(&cam->busy_lock);
2471 2449
2472 if(!cam->present) 2450 if(!cam->present)
2473 status = POLLHUP; 2451 status = POLLHUP;
2474 else if(cam->curbuff->status == FRAME_READY) 2452 else if(cam->curbuff->status == FRAME_READY)
2475 status = POLLIN | POLLRDNORM; 2453 status = POLLIN | POLLRDNORM;
2476 2454
2477 mutex_unlock(&cam->busy_lock);
2478 return status; 2455 return status;
2479} 2456}
2480 2457
@@ -2496,29 +2473,19 @@ int cpia2_remap_buffer(struct camera_data *cam, struct vm_area_struct *vma)
2496 2473
2497 DBG("mmap offset:%ld size:%ld\n", start_offset, size); 2474 DBG("mmap offset:%ld size:%ld\n", start_offset, size);
2498 2475
2499 /* make this _really_ smp-safe */ 2476 if (!cam->present)
2500 if (mutex_lock_interruptible(&cam->busy_lock))
2501 return -ERESTARTSYS;
2502
2503 if (!cam->present) {
2504 mutex_unlock(&cam->busy_lock);
2505 return -ENODEV; 2477 return -ENODEV;
2506 }
2507 2478
2508 if (size > cam->frame_size*cam->num_frames || 2479 if (size > cam->frame_size*cam->num_frames ||
2509 (start_offset % cam->frame_size) != 0 || 2480 (start_offset % cam->frame_size) != 0 ||
2510 (start_offset+size > cam->frame_size*cam->num_frames)) { 2481 (start_offset+size > cam->frame_size*cam->num_frames))
2511 mutex_unlock(&cam->busy_lock);
2512 return -EINVAL; 2482 return -EINVAL;
2513 }
2514 2483
2515 pos = ((unsigned long) (cam->frame_buffer)) + start_offset; 2484 pos = ((unsigned long) (cam->frame_buffer)) + start_offset;
2516 while (size > 0) { 2485 while (size > 0) {
2517 page = kvirt_to_pa(pos); 2486 page = kvirt_to_pa(pos);
2518 if (remap_pfn_range(vma, start, page >> PAGE_SHIFT, PAGE_SIZE, PAGE_SHARED)) { 2487 if (remap_pfn_range(vma, start, page >> PAGE_SHIFT, PAGE_SIZE, PAGE_SHARED))
2519 mutex_unlock(&cam->busy_lock);
2520 return -EAGAIN; 2488 return -EAGAIN;
2521 }
2522 start += PAGE_SIZE; 2489 start += PAGE_SIZE;
2523 pos += PAGE_SIZE; 2490 pos += PAGE_SIZE;
2524 if (size > PAGE_SIZE) 2491 if (size > PAGE_SIZE)
@@ -2528,7 +2495,5 @@ int cpia2_remap_buffer(struct camera_data *cam, struct vm_area_struct *vma)
2528 } 2495 }
2529 2496
2530 cam->mmapped = true; 2497 cam->mmapped = true;
2531 mutex_unlock(&cam->busy_lock);
2532 return 0; 2498 return 0;
2533} 2499}
2534
diff --git a/drivers/media/video/cpia2/cpia2_v4l.c b/drivers/media/video/cpia2/cpia2_v4l.c
index 7edf80b0d01a..9bad39842936 100644
--- a/drivers/media/video/cpia2/cpia2_v4l.c
+++ b/drivers/media/video/cpia2/cpia2_v4l.c
@@ -238,59 +238,40 @@ static struct v4l2_queryctrl controls[] = {
238static int cpia2_open(struct file *file) 238static int cpia2_open(struct file *file)
239{ 239{
240 struct camera_data *cam = video_drvdata(file); 240 struct camera_data *cam = video_drvdata(file);
241 int retval = 0; 241 struct cpia2_fh *fh;
242 242
243 if (!cam) { 243 if (!cam) {
244 ERR("Internal error, camera_data not found!\n"); 244 ERR("Internal error, camera_data not found!\n");
245 return -ENODEV; 245 return -ENODEV;
246 } 246 }
247 247
248 if(mutex_lock_interruptible(&cam->busy_lock)) 248 if (!cam->present)
249 return -ERESTARTSYS; 249 return -ENODEV;
250
251 if(!cam->present) {
252 retval = -ENODEV;
253 goto err_return;
254 }
255 250
256 if (cam->open_count > 0) { 251 if (cam->open_count == 0) {
257 goto skip_init; 252 if (cpia2_allocate_buffers(cam))
258 } 253 return -ENOMEM;
259 254
260 if (cpia2_allocate_buffers(cam)) { 255 /* reset the camera */
261 retval = -ENOMEM; 256 if (cpia2_reset_camera(cam) < 0)
262 goto err_return; 257 return -EIO;
263 }
264 258
265 /* reset the camera */ 259 cam->APP_len = 0;
266 if (cpia2_reset_camera(cam) < 0) { 260 cam->COM_len = 0;
267 retval = -EIO;
268 goto err_return;
269 } 261 }
270 262
271 cam->APP_len = 0; 263 fh = kmalloc(sizeof(*fh), GFP_KERNEL);
272 cam->COM_len = 0; 264 if (!fh)
273 265 return -ENOMEM;
274skip_init: 266 file->private_data = fh;
275 { 267 fh->prio = V4L2_PRIORITY_UNSET;
276 struct cpia2_fh *fh = kmalloc(sizeof(*fh),GFP_KERNEL); 268 v4l2_prio_open(&cam->prio, &fh->prio);
277 if(!fh) { 269 fh->mmapped = 0;
278 retval = -ENOMEM;
279 goto err_return;
280 }
281 file->private_data = fh;
282 fh->prio = V4L2_PRIORITY_UNSET;
283 v4l2_prio_open(&cam->prio, &fh->prio);
284 fh->mmapped = 0;
285 }
286 270
287 ++cam->open_count; 271 ++cam->open_count;
288 272
289 cpia2_dbg_dump_registers(cam); 273 cpia2_dbg_dump_registers(cam);
290 274 return 0;
291err_return:
292 mutex_unlock(&cam->busy_lock);
293 return retval;
294} 275}
295 276
296/****************************************************************************** 277/******************************************************************************
@@ -304,15 +285,11 @@ static int cpia2_close(struct file *file)
304 struct camera_data *cam = video_get_drvdata(dev); 285 struct camera_data *cam = video_get_drvdata(dev);
305 struct cpia2_fh *fh = file->private_data; 286 struct cpia2_fh *fh = file->private_data;
306 287
307 mutex_lock(&cam->busy_lock);
308
309 if (cam->present && 288 if (cam->present &&
310 (cam->open_count == 1 289 (cam->open_count == 1 || fh->prio == V4L2_PRIORITY_RECORD)) {
311 || fh->prio == V4L2_PRIORITY_RECORD
312 )) {
313 cpia2_usb_stream_stop(cam); 290 cpia2_usb_stream_stop(cam);
314 291
315 if(cam->open_count == 1) { 292 if (cam->open_count == 1) {
316 /* save camera state for later open */ 293 /* save camera state for later open */
317 cpia2_save_camera_state(cam); 294 cpia2_save_camera_state(cam);
318 295
@@ -321,26 +298,21 @@ static int cpia2_close(struct file *file)
321 } 298 }
322 } 299 }
323 300
324 { 301 if (fh->mmapped)
325 if(fh->mmapped) 302 cam->mmapped = 0;
326 cam->mmapped = 0; 303 v4l2_prio_close(&cam->prio, fh->prio);
327 v4l2_prio_close(&cam->prio, fh->prio); 304 file->private_data = NULL;
328 file->private_data = NULL; 305 kfree(fh);
329 kfree(fh);
330 }
331 306
332 if (--cam->open_count == 0) { 307 if (--cam->open_count == 0) {
333 cpia2_free_buffers(cam); 308 cpia2_free_buffers(cam);
334 if (!cam->present) { 309 if (!cam->present) {
335 video_unregister_device(dev); 310 video_unregister_device(dev);
336 mutex_unlock(&cam->busy_lock);
337 kfree(cam); 311 kfree(cam);
338 return 0; 312 return 0;
339 } 313 }
340 } 314 }
341 315
342 mutex_unlock(&cam->busy_lock);
343
344 return 0; 316 return 0;
345} 317}
346 318
@@ -405,11 +377,11 @@ static int sync(struct camera_data *cam, int frame_nr)
405 return 0; 377 return 0;
406 } 378 }
407 379
408 mutex_unlock(&cam->busy_lock); 380 mutex_unlock(&cam->v4l2_lock);
409 wait_event_interruptible(cam->wq_stream, 381 wait_event_interruptible(cam->wq_stream,
410 !cam->streaming || 382 !cam->streaming ||
411 frame->status == FRAME_READY); 383 frame->status == FRAME_READY);
412 mutex_lock(&cam->busy_lock); 384 mutex_lock(&cam->v4l2_lock);
413 if (signal_pending(current)) 385 if (signal_pending(current))
414 return -ERESTARTSYS; 386 return -ERESTARTSYS;
415 if(!cam->present) 387 if(!cam->present)
@@ -1293,11 +1265,11 @@ static int ioctl_dqbuf(void *arg,struct camera_data *cam, struct file *file)
1293 if(frame < 0) { 1265 if(frame < 0) {
1294 /* Wait for a frame to become available */ 1266 /* Wait for a frame to become available */
1295 struct framebuf *cb=cam->curbuff; 1267 struct framebuf *cb=cam->curbuff;
1296 mutex_unlock(&cam->busy_lock); 1268 mutex_unlock(&cam->v4l2_lock);
1297 wait_event_interruptible(cam->wq_stream, 1269 wait_event_interruptible(cam->wq_stream,
1298 !cam->present || 1270 !cam->present ||
1299 (cb=cam->curbuff)->status == FRAME_READY); 1271 (cb=cam->curbuff)->status == FRAME_READY);
1300 mutex_lock(&cam->busy_lock); 1272 mutex_lock(&cam->v4l2_lock);
1301 if (signal_pending(current)) 1273 if (signal_pending(current))
1302 return -ERESTARTSYS; 1274 return -ERESTARTSYS;
1303 if(!cam->present) 1275 if(!cam->present)
@@ -1337,14 +1309,8 @@ static long cpia2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
1337 if (!cam) 1309 if (!cam)
1338 return -ENOTTY; 1310 return -ENOTTY;
1339 1311
1340 /* make this _really_ smp-safe */ 1312 if (!cam->present)
1341 if (mutex_lock_interruptible(&cam->busy_lock))
1342 return -ERESTARTSYS;
1343
1344 if (!cam->present) {
1345 mutex_unlock(&cam->busy_lock);
1346 return -ENODEV; 1313 return -ENODEV;
1347 }
1348 1314
1349 /* Priority check */ 1315 /* Priority check */
1350 switch (cmd) { 1316 switch (cmd) {
@@ -1352,10 +1318,8 @@ static long cpia2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
1352 { 1318 {
1353 struct cpia2_fh *fh = file->private_data; 1319 struct cpia2_fh *fh = file->private_data;
1354 retval = v4l2_prio_check(&cam->prio, fh->prio); 1320 retval = v4l2_prio_check(&cam->prio, fh->prio);
1355 if(retval) { 1321 if (retval)
1356 mutex_unlock(&cam->busy_lock);
1357 return retval; 1322 return retval;
1358 }
1359 break; 1323 break;
1360 } 1324 }
1361 default: 1325 default:
@@ -1529,7 +1493,6 @@ static long cpia2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
1529 break; 1493 break;
1530 } 1494 }
1531 1495
1532 mutex_unlock(&cam->busy_lock);
1533 return retval; 1496 return retval;
1534} 1497}
1535 1498
@@ -1596,7 +1559,7 @@ static const struct v4l2_file_operations cpia2_fops = {
1596 .release = cpia2_close, 1559 .release = cpia2_close,
1597 .read = cpia2_v4l_read, 1560 .read = cpia2_v4l_read,
1598 .poll = cpia2_v4l_poll, 1561 .poll = cpia2_v4l_poll,
1599 .ioctl = cpia2_ioctl, 1562 .unlocked_ioctl = cpia2_ioctl,
1600 .mmap = cpia2_mmap, 1563 .mmap = cpia2_mmap,
1601}; 1564};
1602 1565
@@ -1620,6 +1583,7 @@ int cpia2_register_camera(struct camera_data *cam)
1620 1583
1621 memcpy(cam->vdev, &cpia2_template, sizeof(cpia2_template)); 1584 memcpy(cam->vdev, &cpia2_template, sizeof(cpia2_template));
1622 video_set_drvdata(cam->vdev, cam); 1585 video_set_drvdata(cam->vdev, cam);
1586 cam->vdev->lock = &cam->v4l2_lock;
1623 1587
1624 reset_camera_struct_v4l(cam); 1588 reset_camera_struct_v4l(cam);
1625 1589
diff --git a/drivers/media/video/cx18/cx18-driver.c b/drivers/media/video/cx18/cx18-driver.c
index 133ec2bac180..944af8adbe0c 100644
--- a/drivers/media/video/cx18/cx18-driver.c
+++ b/drivers/media/video/cx18/cx18-driver.c
@@ -664,7 +664,7 @@ static int __devinit cx18_create_in_workq(struct cx18 *cx)
664{ 664{
665 snprintf(cx->in_workq_name, sizeof(cx->in_workq_name), "%s-in", 665 snprintf(cx->in_workq_name, sizeof(cx->in_workq_name), "%s-in",
666 cx->v4l2_dev.name); 666 cx->v4l2_dev.name);
667 cx->in_work_queue = create_singlethread_workqueue(cx->in_workq_name); 667 cx->in_work_queue = alloc_ordered_workqueue(cx->in_workq_name, 0);
668 if (cx->in_work_queue == NULL) { 668 if (cx->in_work_queue == NULL) {
669 CX18_ERR("Unable to create incoming mailbox handler thread\n"); 669 CX18_ERR("Unable to create incoming mailbox handler thread\n");
670 return -ENOMEM; 670 return -ENOMEM;
@@ -672,18 +672,6 @@ static int __devinit cx18_create_in_workq(struct cx18 *cx)
672 return 0; 672 return 0;
673} 673}
674 674
675static int __devinit cx18_create_out_workq(struct cx18 *cx)
676{
677 snprintf(cx->out_workq_name, sizeof(cx->out_workq_name), "%s-out",
678 cx->v4l2_dev.name);
679 cx->out_work_queue = create_workqueue(cx->out_workq_name);
680 if (cx->out_work_queue == NULL) {
681 CX18_ERR("Unable to create outgoing mailbox handler threads\n");
682 return -ENOMEM;
683 }
684 return 0;
685}
686
687static void __devinit cx18_init_in_work_orders(struct cx18 *cx) 675static void __devinit cx18_init_in_work_orders(struct cx18 *cx)
688{ 676{
689 int i; 677 int i;
@@ -710,15 +698,9 @@ static int __devinit cx18_init_struct1(struct cx18 *cx)
710 mutex_init(&cx->epu2apu_mb_lock); 698 mutex_init(&cx->epu2apu_mb_lock);
711 mutex_init(&cx->epu2cpu_mb_lock); 699 mutex_init(&cx->epu2cpu_mb_lock);
712 700
713 ret = cx18_create_out_workq(cx);
714 if (ret)
715 return ret;
716
717 ret = cx18_create_in_workq(cx); 701 ret = cx18_create_in_workq(cx);
718 if (ret) { 702 if (ret)
719 destroy_workqueue(cx->out_work_queue);
720 return ret; 703 return ret;
721 }
722 704
723 cx18_init_in_work_orders(cx); 705 cx18_init_in_work_orders(cx);
724 706
@@ -1107,7 +1089,6 @@ free_mem:
1107 release_mem_region(cx->base_addr, CX18_MEM_SIZE); 1089 release_mem_region(cx->base_addr, CX18_MEM_SIZE);
1108free_workqueues: 1090free_workqueues:
1109 destroy_workqueue(cx->in_work_queue); 1091 destroy_workqueue(cx->in_work_queue);
1110 destroy_workqueue(cx->out_work_queue);
1111err: 1092err:
1112 if (retval == 0) 1093 if (retval == 0)
1113 retval = -ENODEV; 1094 retval = -ENODEV;
@@ -1259,7 +1240,6 @@ static void cx18_remove(struct pci_dev *pci_dev)
1259 cx18_halt_firmware(cx); 1240 cx18_halt_firmware(cx);
1260 1241
1261 destroy_workqueue(cx->in_work_queue); 1242 destroy_workqueue(cx->in_work_queue);
1262 destroy_workqueue(cx->out_work_queue);
1263 1243
1264 cx18_streams_cleanup(cx, 1); 1244 cx18_streams_cleanup(cx, 1);
1265 1245
diff --git a/drivers/media/video/cx18/cx18-driver.h b/drivers/media/video/cx18/cx18-driver.h
index f6f3e50d4bdf..306caac6d3fc 100644
--- a/drivers/media/video/cx18/cx18-driver.h
+++ b/drivers/media/video/cx18/cx18-driver.h
@@ -617,9 +617,6 @@ struct cx18 {
617 struct cx18_in_work_order in_work_order[CX18_MAX_IN_WORK_ORDERS]; 617 struct cx18_in_work_order in_work_order[CX18_MAX_IN_WORK_ORDERS];
618 char epu_debug_str[256]; /* CX18_EPU_DEBUG is rare: use shared space */ 618 char epu_debug_str[256]; /* CX18_EPU_DEBUG is rare: use shared space */
619 619
620 struct workqueue_struct *out_work_queue;
621 char out_workq_name[12]; /* "cx18-NN-out" */
622
623 /* i2c */ 620 /* i2c */
624 struct i2c_adapter i2c_adap[2]; 621 struct i2c_adapter i2c_adap[2];
625 struct i2c_algo_bit_data i2c_algo[2]; 622 struct i2c_algo_bit_data i2c_algo[2];
diff --git a/drivers/media/video/cx18/cx18-streams.h b/drivers/media/video/cx18/cx18-streams.h
index 51765eb12d39..713b0e61536d 100644
--- a/drivers/media/video/cx18/cx18-streams.h
+++ b/drivers/media/video/cx18/cx18-streams.h
@@ -42,8 +42,7 @@ static inline bool cx18_stream_enabled(struct cx18_stream *s)
42/* Related to submission of mdls to firmware */ 42/* Related to submission of mdls to firmware */
43static inline void cx18_stream_load_fw_queue(struct cx18_stream *s) 43static inline void cx18_stream_load_fw_queue(struct cx18_stream *s)
44{ 44{
45 struct cx18 *cx = s->cx; 45 schedule_work(&s->out_work_order);
46 queue_work(cx->out_work_queue, &s->out_work_order);
47} 46}
48 47
49static inline void cx18_stream_put_mdl_fw(struct cx18_stream *s, 48static inline void cx18_stream_put_mdl_fw(struct cx18_stream *s,
diff --git a/drivers/media/video/cx231xx/cx231xx-dvb.c b/drivers/media/video/cx231xx/cx231xx-dvb.c
index fe59a1c3f064..363aa6004221 100644
--- a/drivers/media/video/cx231xx/cx231xx-dvb.c
+++ b/drivers/media/video/cx231xx/cx231xx-dvb.c
@@ -28,7 +28,6 @@
28#include <media/videobuf-vmalloc.h> 28#include <media/videobuf-vmalloc.h>
29 29
30#include "xc5000.h" 30#include "xc5000.h"
31#include "dvb_dummy_fe.h"
32#include "s5h1432.h" 31#include "s5h1432.h"
33#include "tda18271.h" 32#include "tda18271.h"
34#include "s5h1411.h" 33#include "s5h1411.h"
@@ -619,7 +618,7 @@ static int dvb_init(struct cx231xx *dev)
619 618
620 if (dev->dvb->frontend == NULL) { 619 if (dev->dvb->frontend == NULL) {
621 printk(DRIVER_NAME 620 printk(DRIVER_NAME
622 ": Failed to attach dummy front end\n"); 621 ": Failed to attach s5h1411 front end\n");
623 result = -EINVAL; 622 result = -EINVAL;
624 goto out_free; 623 goto out_free;
625 } 624 }
@@ -665,7 +664,7 @@ static int dvb_init(struct cx231xx *dev)
665 664
666 if (dev->dvb->frontend == NULL) { 665 if (dev->dvb->frontend == NULL) {
667 printk(DRIVER_NAME 666 printk(DRIVER_NAME
668 ": Failed to attach dummy front end\n"); 667 ": Failed to attach s5h1411 front end\n");
669 result = -EINVAL; 668 result = -EINVAL;
670 goto out_free; 669 goto out_free;
671 } 670 }
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c
index f16461844c5c..6fc09dd41b9d 100644
--- a/drivers/media/video/cx25840/cx25840-core.c
+++ b/drivers/media/video/cx25840/cx25840-core.c
@@ -1682,20 +1682,6 @@ static int cx25840_log_status(struct v4l2_subdev *sd)
1682 return 0; 1682 return 0;
1683} 1683}
1684 1684
1685static int cx25840_s_config(struct v4l2_subdev *sd, int irq, void *platform_data)
1686{
1687 struct cx25840_state *state = to_state(sd);
1688 struct i2c_client *client = v4l2_get_subdevdata(sd);
1689
1690 if (platform_data) {
1691 struct cx25840_platform_data *pdata = platform_data;
1692
1693 state->pvr150_workaround = pdata->pvr150_workaround;
1694 set_input(client, state->vid_input, state->aud_input);
1695 }
1696 return 0;
1697}
1698
1699static int cx23885_irq_handler(struct v4l2_subdev *sd, u32 status, 1685static int cx23885_irq_handler(struct v4l2_subdev *sd, u32 status,
1700 bool *handled) 1686 bool *handled)
1701{ 1687{
@@ -1787,7 +1773,6 @@ static const struct v4l2_ctrl_ops cx25840_ctrl_ops = {
1787 1773
1788static const struct v4l2_subdev_core_ops cx25840_core_ops = { 1774static const struct v4l2_subdev_core_ops cx25840_core_ops = {
1789 .log_status = cx25840_log_status, 1775 .log_status = cx25840_log_status,
1790 .s_config = cx25840_s_config,
1791 .g_chip_ident = cx25840_g_chip_ident, 1776 .g_chip_ident = cx25840_g_chip_ident,
1792 .g_ctrl = v4l2_subdev_g_ctrl, 1777 .g_ctrl = v4l2_subdev_g_ctrl,
1793 .s_ctrl = v4l2_subdev_s_ctrl, 1778 .s_ctrl = v4l2_subdev_s_ctrl,
@@ -1974,7 +1959,6 @@ static int cx25840_probe(struct i2c_client *client,
1974 state->vid_input = CX25840_COMPOSITE7; 1959 state->vid_input = CX25840_COMPOSITE7;
1975 state->aud_input = CX25840_AUDIO8; 1960 state->aud_input = CX25840_AUDIO8;
1976 state->audclk_freq = 48000; 1961 state->audclk_freq = 48000;
1977 state->pvr150_workaround = 0;
1978 state->audmode = V4L2_TUNER_MODE_LANG1; 1962 state->audmode = V4L2_TUNER_MODE_LANG1;
1979 state->vbi_line_offset = 8; 1963 state->vbi_line_offset = 8;
1980 state->id = id; 1964 state->id = id;
@@ -2034,6 +2018,12 @@ static int cx25840_probe(struct i2c_client *client,
2034 v4l2_ctrl_cluster(2, &state->volume); 2018 v4l2_ctrl_cluster(2, &state->volume);
2035 v4l2_ctrl_handler_setup(&state->hdl); 2019 v4l2_ctrl_handler_setup(&state->hdl);
2036 2020
2021 if (client->dev.platform_data) {
2022 struct cx25840_platform_data *pdata = client->dev.platform_data;
2023
2024 state->pvr150_workaround = pdata->pvr150_workaround;
2025 }
2026
2037 cx25840_ir_probe(sd); 2027 cx25840_ir_probe(sd);
2038 return 0; 2028 return 0;
2039} 2029}
diff --git a/drivers/media/video/davinci/vpif.c b/drivers/media/video/davinci/vpif.c
index 1f532e31cd49..9f3bfc1eb240 100644
--- a/drivers/media/video/davinci/vpif.c
+++ b/drivers/media/video/davinci/vpif.c
@@ -41,6 +41,183 @@ spinlock_t vpif_lock;
41 41
42void __iomem *vpif_base; 42void __iomem *vpif_base;
43 43
44/**
45 * ch_params: video standard configuration parameters for vpif
46 * The table must include all presets from supported subdevices.
47 */
48const struct vpif_channel_config_params ch_params[] = {
49 /* HDTV formats */
50 {
51 .name = "480p59_94",
52 .width = 720,
53 .height = 480,
54 .frm_fmt = 1,
55 .ycmux_mode = 0,
56 .eav2sav = 138-8,
57 .sav2eav = 720,
58 .l1 = 1,
59 .l3 = 43,
60 .l5 = 523,
61 .vsize = 525,
62 .capture_format = 0,
63 .vbi_supported = 0,
64 .hd_sd = 1,
65 .dv_preset = V4L2_DV_480P59_94,
66 },
67 {
68 .name = "576p50",
69 .width = 720,
70 .height = 576,
71 .frm_fmt = 1,
72 .ycmux_mode = 0,
73 .eav2sav = 144-8,
74 .sav2eav = 720,
75 .l1 = 1,
76 .l3 = 45,
77 .l5 = 621,
78 .vsize = 625,
79 .capture_format = 0,
80 .vbi_supported = 0,
81 .hd_sd = 1,
82 .dv_preset = V4L2_DV_576P50,
83 },
84 {
85 .name = "720p50",
86 .width = 1280,
87 .height = 720,
88 .frm_fmt = 1,
89 .ycmux_mode = 0,
90 .eav2sav = 700-8,
91 .sav2eav = 1280,
92 .l1 = 1,
93 .l3 = 26,
94 .l5 = 746,
95 .vsize = 750,
96 .capture_format = 0,
97 .vbi_supported = 0,
98 .hd_sd = 1,
99 .dv_preset = V4L2_DV_720P50,
100 },
101 {
102 .name = "720p60",
103 .width = 1280,
104 .height = 720,
105 .frm_fmt = 1,
106 .ycmux_mode = 0,
107 .eav2sav = 370 - 8,
108 .sav2eav = 1280,
109 .l1 = 1,
110 .l3 = 26,
111 .l5 = 746,
112 .vsize = 750,
113 .capture_format = 0,
114 .vbi_supported = 0,
115 .hd_sd = 1,
116 .dv_preset = V4L2_DV_720P60,
117 },
118 {
119 .name = "1080I50",
120 .width = 1920,
121 .height = 1080,
122 .frm_fmt = 0,
123 .ycmux_mode = 0,
124 .eav2sav = 720 - 8,
125 .sav2eav = 1920,
126 .l1 = 1,
127 .l3 = 21,
128 .l5 = 561,
129 .l7 = 563,
130 .l9 = 584,
131 .l11 = 1124,
132 .vsize = 1125,
133 .capture_format = 0,
134 .vbi_supported = 0,
135 .hd_sd = 1,
136 .dv_preset = V4L2_DV_1080I50,
137 },
138 {
139 .name = "1080I60",
140 .width = 1920,
141 .height = 1080,
142 .frm_fmt = 0,
143 .ycmux_mode = 0,
144 .eav2sav = 280 - 8,
145 .sav2eav = 1920,
146 .l1 = 1,
147 .l3 = 21,
148 .l5 = 561,
149 .l7 = 563,
150 .l9 = 584,
151 .l11 = 1124,
152 .vsize = 1125,
153 .capture_format = 0,
154 .vbi_supported = 0,
155 .hd_sd = 1,
156 .dv_preset = V4L2_DV_1080I60,
157 },
158 {
159 .name = "1080p60",
160 .width = 1920,
161 .height = 1080,
162 .frm_fmt = 1,
163 .ycmux_mode = 0,
164 .eav2sav = 280 - 8,
165 .sav2eav = 1920,
166 .l1 = 1,
167 .l3 = 42,
168 .l5 = 1122,
169 .vsize = 1125,
170 .capture_format = 0,
171 .vbi_supported = 0,
172 .hd_sd = 1,
173 .dv_preset = V4L2_DV_1080P60,
174 },
175
176 /* SDTV formats */
177 {
178 .name = "NTSC_M",
179 .width = 720,
180 .height = 480,
181 .frm_fmt = 0,
182 .ycmux_mode = 1,
183 .eav2sav = 268,
184 .sav2eav = 1440,
185 .l1 = 1,
186 .l3 = 23,
187 .l5 = 263,
188 .l7 = 266,
189 .l9 = 286,
190 .l11 = 525,
191 .vsize = 525,
192 .capture_format = 0,
193 .vbi_supported = 1,
194 .hd_sd = 0,
195 .stdid = V4L2_STD_525_60,
196 },
197 {
198 .name = "PAL_BDGHIK",
199 .width = 720,
200 .height = 576,
201 .frm_fmt = 0,
202 .ycmux_mode = 1,
203 .eav2sav = 280,
204 .sav2eav = 1440,
205 .l1 = 1,
206 .l3 = 23,
207 .l5 = 311,
208 .l7 = 313,
209 .l9 = 336,
210 .l11 = 624,
211 .vsize = 625,
212 .capture_format = 0,
213 .vbi_supported = 1,
214 .hd_sd = 0,
215 .stdid = V4L2_STD_625_50,
216 },
217};
218
219const unsigned int vpif_ch_params_count = ARRAY_SIZE(ch_params);
220
44static inline void vpif_wr_bit(u32 reg, u32 bit, u32 val) 221static inline void vpif_wr_bit(u32 reg, u32 bit, u32 val)
45{ 222{
46 if (val) 223 if (val)
diff --git a/drivers/media/video/davinci/vpif.h b/drivers/media/video/davinci/vpif.h
index ebd5c4338ebb..10550bd93b06 100644
--- a/drivers/media/video/davinci/vpif.h
+++ b/drivers/media/video/davinci/vpif.h
@@ -577,12 +577,10 @@ struct vpif_channel_config_params {
577 char name[VPIF_MAX_NAME]; /* Name of the mode */ 577 char name[VPIF_MAX_NAME]; /* Name of the mode */
578 u16 width; /* Indicates width of the image */ 578 u16 width; /* Indicates width of the image */
579 u16 height; /* Indicates height of the image */ 579 u16 height; /* Indicates height of the image */
580 u8 fps; 580 u8 frm_fmt; /* Interlaced (0) or progressive (1) */
581 u8 frm_fmt; /* Indicates whether this is interlaced 581 u8 ycmux_mode; /* This mode requires one (0) or two (1)
582 * or progressive format */ 582 channels */
583 u8 ycmux_mode; /* Indicates whether this mode requires 583 u16 eav2sav; /* length of eav 2 sav */
584 * single or two channels */
585 u16 eav2sav; /* length of sav 2 eav */
586 u16 sav2eav; /* length of sav 2 eav */ 584 u16 sav2eav; /* length of sav 2 eav */
587 u16 l1, l3, l5, l7, l9, l11; /* Other parameter configurations */ 585 u16 l1, l3, l5, l7, l9, l11; /* Other parameter configurations */
588 u16 vsize; /* Vertical size of the image */ 586 u16 vsize; /* Vertical size of the image */
@@ -590,10 +588,14 @@ struct vpif_channel_config_params {
590 * is in BT or in CCD/CMOS */ 588 * is in BT or in CCD/CMOS */
591 u8 vbi_supported; /* Indicates whether this mode 589 u8 vbi_supported; /* Indicates whether this mode
592 * supports capturing vbi or not */ 590 * supports capturing vbi or not */
593 u8 hd_sd; 591 u8 hd_sd; /* HDTV (1) or SDTV (0) format */
594 v4l2_std_id stdid; 592 v4l2_std_id stdid; /* SDTV format */
593 u32 dv_preset; /* HDTV format */
595}; 594};
596 595
596extern const unsigned int vpif_ch_params_count;
597extern const struct vpif_channel_config_params ch_params[];
598
597struct vpif_video_params; 599struct vpif_video_params;
598struct vpif_params; 600struct vpif_params;
599struct vpif_vbi_params; 601struct vpif_vbi_params;
diff --git a/drivers/media/video/davinci/vpif_capture.c b/drivers/media/video/davinci/vpif_capture.c
index 193abab6b355..d93ad74a34c5 100644
--- a/drivers/media/video/davinci/vpif_capture.c
+++ b/drivers/media/video/davinci/vpif_capture.c
@@ -37,6 +37,7 @@
37#include <linux/slab.h> 37#include <linux/slab.h>
38#include <media/v4l2-device.h> 38#include <media/v4l2-device.h>
39#include <media/v4l2-ioctl.h> 39#include <media/v4l2-ioctl.h>
40#include <media/v4l2-chip-ident.h>
40 41
41#include "vpif_capture.h" 42#include "vpif_capture.h"
42#include "vpif.h" 43#include "vpif.h"
@@ -81,20 +82,6 @@ static struct vpif_device vpif_obj = { {NULL} };
81static struct device *vpif_dev; 82static struct device *vpif_dev;
82 83
83/** 84/**
84 * ch_params: video standard configuration parameters for vpif
85 */
86static const struct vpif_channel_config_params ch_params[] = {
87 {
88 "NTSC_M", 720, 480, 30, 0, 1, 268, 1440, 1, 23, 263, 266,
89 286, 525, 525, 0, 1, 0, V4L2_STD_525_60,
90 },
91 {
92 "PAL_BDGHIK", 720, 576, 25, 0, 1, 280, 1440, 1, 23, 311, 313,
93 336, 624, 625, 0, 1, 0, V4L2_STD_625_50,
94 },
95};
96
97/**
98 * vpif_uservirt_to_phys : translate user/virtual address to phy address 85 * vpif_uservirt_to_phys : translate user/virtual address to phy address
99 * @virtp: user/virtual address 86 * @virtp: user/virtual address
100 * 87 *
@@ -342,7 +329,7 @@ static void vpif_schedule_next_buffer(struct common_obj *common)
342 * @dev_id: dev_id ptr 329 * @dev_id: dev_id ptr
343 * 330 *
344 * It changes status of the captured buffer, takes next buffer from the queue 331 * It changes status of the captured buffer, takes next buffer from the queue
345 * and sets its address in VPIF registers 332 * and sets its address in VPIF registers
346 */ 333 */
347static irqreturn_t vpif_channel_isr(int irq, void *dev_id) 334static irqreturn_t vpif_channel_isr(int irq, void *dev_id)
348{ 335{
@@ -435,24 +422,31 @@ static int vpif_update_std_info(struct channel_obj *ch)
435 struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; 422 struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX];
436 struct vpif_params *vpifparams = &ch->vpifparams; 423 struct vpif_params *vpifparams = &ch->vpifparams;
437 const struct vpif_channel_config_params *config; 424 const struct vpif_channel_config_params *config;
438 struct vpif_channel_config_params *std_info; 425 struct vpif_channel_config_params *std_info = &vpifparams->std_info;
439 struct video_obj *vid_ch = &ch->video; 426 struct video_obj *vid_ch = &ch->video;
440 int index; 427 int index;
441 428
442 vpif_dbg(2, debug, "vpif_update_std_info\n"); 429 vpif_dbg(2, debug, "vpif_update_std_info\n");
443 430
444 std_info = &vpifparams->std_info; 431 for (index = 0; index < vpif_ch_params_count; index++) {
445
446 for (index = 0; index < ARRAY_SIZE(ch_params); index++) {
447 config = &ch_params[index]; 432 config = &ch_params[index];
448 if (config->stdid & vid_ch->stdid) { 433 if (config->hd_sd == 0) {
449 memcpy(std_info, config, sizeof(*config)); 434 vpif_dbg(2, debug, "SD format\n");
450 break; 435 if (config->stdid & vid_ch->stdid) {
436 memcpy(std_info, config, sizeof(*config));
437 break;
438 }
439 } else {
440 vpif_dbg(2, debug, "HD format\n");
441 if (config->dv_preset == vid_ch->dv_preset) {
442 memcpy(std_info, config, sizeof(*config));
443 break;
444 }
451 } 445 }
452 } 446 }
453 447
454 /* standard not found */ 448 /* standard not found */
455 if (index == ARRAY_SIZE(ch_params)) 449 if (index == vpif_ch_params_count)
456 return -EINVAL; 450 return -EINVAL;
457 451
458 common->fmt.fmt.pix.width = std_info->width; 452 common->fmt.fmt.pix.width = std_info->width;
@@ -462,6 +456,7 @@ static int vpif_update_std_info(struct channel_obj *ch)
462 common->fmt.fmt.pix.bytesperline = std_info->width; 456 common->fmt.fmt.pix.bytesperline = std_info->width;
463 vpifparams->video_params.hpitch = std_info->width; 457 vpifparams->video_params.hpitch = std_info->width;
464 vpifparams->video_params.storage_mode = std_info->frm_fmt; 458 vpifparams->video_params.storage_mode = std_info->frm_fmt;
459
465 return 0; 460 return 0;
466} 461}
467 462
@@ -757,7 +752,7 @@ static int vpif_open(struct file *filep)
757 struct video_obj *vid_ch; 752 struct video_obj *vid_ch;
758 struct channel_obj *ch; 753 struct channel_obj *ch;
759 struct vpif_fh *fh; 754 struct vpif_fh *fh;
760 int i, ret = 0; 755 int i;
761 756
762 vpif_dbg(2, debug, "vpif_open\n"); 757 vpif_dbg(2, debug, "vpif_open\n");
763 758
@@ -766,9 +761,6 @@ static int vpif_open(struct file *filep)
766 vid_ch = &ch->video; 761 vid_ch = &ch->video;
767 common = &ch->common[VPIF_VIDEO_INDEX]; 762 common = &ch->common[VPIF_VIDEO_INDEX];
768 763
769 if (mutex_lock_interruptible(&common->lock))
770 return -ERESTARTSYS;
771
772 if (NULL == ch->curr_subdev_info) { 764 if (NULL == ch->curr_subdev_info) {
773 /** 765 /**
774 * search through the sub device to see a registered 766 * search through the sub device to see a registered
@@ -785,8 +777,7 @@ static int vpif_open(struct file *filep)
785 } 777 }
786 if (i == config->subdev_count) { 778 if (i == config->subdev_count) {
787 vpif_err("No sub device registered\n"); 779 vpif_err("No sub device registered\n");
788 ret = -ENOENT; 780 return -ENOENT;
789 goto exit;
790 } 781 }
791 } 782 }
792 783
@@ -794,8 +785,7 @@ static int vpif_open(struct file *filep)
794 fh = kzalloc(sizeof(struct vpif_fh), GFP_KERNEL); 785 fh = kzalloc(sizeof(struct vpif_fh), GFP_KERNEL);
795 if (NULL == fh) { 786 if (NULL == fh) {
796 vpif_err("unable to allocate memory for file handle object\n"); 787 vpif_err("unable to allocate memory for file handle object\n");
797 ret = -ENOMEM; 788 return -ENOMEM;
798 goto exit;
799 } 789 }
800 790
801 /* store pointer to fh in private_data member of filep */ 791 /* store pointer to fh in private_data member of filep */
@@ -815,9 +805,7 @@ static int vpif_open(struct file *filep)
815 /* Initialize priority of this instance to default priority */ 805 /* Initialize priority of this instance to default priority */
816 fh->prio = V4L2_PRIORITY_UNSET; 806 fh->prio = V4L2_PRIORITY_UNSET;
817 v4l2_prio_open(&ch->prio, &fh->prio); 807 v4l2_prio_open(&ch->prio, &fh->prio);
818exit: 808 return 0;
819 mutex_unlock(&common->lock);
820 return ret;
821} 809}
822 810
823/** 811/**
@@ -837,9 +825,6 @@ static int vpif_release(struct file *filep)
837 825
838 common = &ch->common[VPIF_VIDEO_INDEX]; 826 common = &ch->common[VPIF_VIDEO_INDEX];
839 827
840 if (mutex_lock_interruptible(&common->lock))
841 return -ERESTARTSYS;
842
843 /* if this instance is doing IO */ 828 /* if this instance is doing IO */
844 if (fh->io_allowed[VPIF_VIDEO_INDEX]) { 829 if (fh->io_allowed[VPIF_VIDEO_INDEX]) {
845 /* Reset io_usrs member of channel object */ 830 /* Reset io_usrs member of channel object */
@@ -863,9 +848,6 @@ static int vpif_release(struct file *filep)
863 /* Decrement channel usrs counter */ 848 /* Decrement channel usrs counter */
864 ch->usrs--; 849 ch->usrs--;
865 850
866 /* unlock mutex on channel object */
867 mutex_unlock(&common->lock);
868
869 /* Close the priority */ 851 /* Close the priority */
870 v4l2_prio_close(&ch->prio, fh->prio); 852 v4l2_prio_close(&ch->prio, fh->prio);
871 853
@@ -890,7 +872,6 @@ static int vpif_reqbufs(struct file *file, void *priv,
890 struct channel_obj *ch = fh->channel; 872 struct channel_obj *ch = fh->channel;
891 struct common_obj *common; 873 struct common_obj *common;
892 u8 index = 0; 874 u8 index = 0;
893 int ret = 0;
894 875
895 vpif_dbg(2, debug, "vpif_reqbufs\n"); 876 vpif_dbg(2, debug, "vpif_reqbufs\n");
896 877
@@ -913,13 +894,8 @@ static int vpif_reqbufs(struct file *file, void *priv,
913 894
914 common = &ch->common[index]; 895 common = &ch->common[index];
915 896
916 if (mutex_lock_interruptible(&common->lock)) 897 if (0 != common->io_usrs)
917 return -ERESTARTSYS; 898 return -EBUSY;
918
919 if (0 != common->io_usrs) {
920 ret = -EBUSY;
921 goto reqbuf_exit;
922 }
923 899
924 /* Initialize videobuf queue as per the buffer type */ 900 /* Initialize videobuf queue as per the buffer type */
925 videobuf_queue_dma_contig_init(&common->buffer_queue, 901 videobuf_queue_dma_contig_init(&common->buffer_queue,
@@ -928,7 +904,7 @@ static int vpif_reqbufs(struct file *file, void *priv,
928 reqbuf->type, 904 reqbuf->type,
929 common->fmt.fmt.pix.field, 905 common->fmt.fmt.pix.field,
930 sizeof(struct videobuf_buffer), fh, 906 sizeof(struct videobuf_buffer), fh,
931 NULL); 907 &common->lock);
932 908
933 /* Set io allowed member of file handle to TRUE */ 909 /* Set io allowed member of file handle to TRUE */
934 fh->io_allowed[index] = 1; 910 fh->io_allowed[index] = 1;
@@ -939,11 +915,7 @@ static int vpif_reqbufs(struct file *file, void *priv,
939 INIT_LIST_HEAD(&common->dma_queue); 915 INIT_LIST_HEAD(&common->dma_queue);
940 916
941 /* Allocate buffers */ 917 /* Allocate buffers */
942 ret = videobuf_reqbufs(&common->buffer_queue, reqbuf); 918 return videobuf_reqbufs(&common->buffer_queue, reqbuf);
943
944reqbuf_exit:
945 mutex_unlock(&common->lock);
946 return ret;
947} 919}
948 920
949/** 921/**
@@ -1157,11 +1129,6 @@ static int vpif_streamon(struct file *file, void *priv,
1157 return ret; 1129 return ret;
1158 } 1130 }
1159 1131
1160 if (mutex_lock_interruptible(&common->lock)) {
1161 ret = -ERESTARTSYS;
1162 goto streamoff_exit;
1163 }
1164
1165 /* If buffer queue is empty, return error */ 1132 /* If buffer queue is empty, return error */
1166 if (list_empty(&common->dma_queue)) { 1133 if (list_empty(&common->dma_queue)) {
1167 vpif_dbg(1, debug, "buffer queue is empty\n"); 1134 vpif_dbg(1, debug, "buffer queue is empty\n");
@@ -1240,13 +1207,10 @@ static int vpif_streamon(struct file *file, void *priv,
1240 enable_channel1(1); 1207 enable_channel1(1);
1241 } 1208 }
1242 channel_first_int[VPIF_VIDEO_INDEX][ch->channel_id] = 1; 1209 channel_first_int[VPIF_VIDEO_INDEX][ch->channel_id] = 1;
1243 mutex_unlock(&common->lock);
1244 return ret; 1210 return ret;
1245 1211
1246exit: 1212exit:
1247 mutex_unlock(&common->lock); 1213 videobuf_streamoff(&common->buffer_queue);
1248streamoff_exit:
1249 ret = videobuf_streamoff(&common->buffer_queue);
1250 return ret; 1214 return ret;
1251} 1215}
1252 1216
@@ -1284,9 +1248,6 @@ static int vpif_streamoff(struct file *file, void *priv,
1284 return -EINVAL; 1248 return -EINVAL;
1285 } 1249 }
1286 1250
1287 if (mutex_lock_interruptible(&common->lock))
1288 return -ERESTARTSYS;
1289
1290 /* disable channel */ 1251 /* disable channel */
1291 if (VPIF_CHANNEL0_VIDEO == ch->channel_id) { 1252 if (VPIF_CHANNEL0_VIDEO == ch->channel_id) {
1292 enable_channel0(0); 1253 enable_channel0(0);
@@ -1304,8 +1265,6 @@ static int vpif_streamoff(struct file *file, void *priv,
1304 if (ret && (ret != -ENOIOCTLCMD)) 1265 if (ret && (ret != -ENOIOCTLCMD))
1305 vpif_dbg(1, debug, "stream off failed in subdev\n"); 1266 vpif_dbg(1, debug, "stream off failed in subdev\n");
1306 1267
1307 mutex_unlock(&common->lock);
1308
1309 return videobuf_streamoff(&common->buffer_queue); 1268 return videobuf_streamoff(&common->buffer_queue);
1310} 1269}
1311 1270
@@ -1381,21 +1340,16 @@ static int vpif_querystd(struct file *file, void *priv, v4l2_std_id *std_id)
1381{ 1340{
1382 struct vpif_fh *fh = priv; 1341 struct vpif_fh *fh = priv;
1383 struct channel_obj *ch = fh->channel; 1342 struct channel_obj *ch = fh->channel;
1384 struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX];
1385 int ret = 0; 1343 int ret = 0;
1386 1344
1387 vpif_dbg(2, debug, "vpif_querystd\n"); 1345 vpif_dbg(2, debug, "vpif_querystd\n");
1388 1346
1389 if (mutex_lock_interruptible(&common->lock))
1390 return -ERESTARTSYS;
1391
1392 /* Call querystd function of decoder device */ 1347 /* Call querystd function of decoder device */
1393 ret = v4l2_subdev_call(vpif_obj.sd[ch->curr_sd_index], video, 1348 ret = v4l2_subdev_call(vpif_obj.sd[ch->curr_sd_index], video,
1394 querystd, std_id); 1349 querystd, std_id);
1395 if (ret < 0) 1350 if (ret < 0)
1396 vpif_dbg(1, debug, "Failed to set standard for sub devices\n"); 1351 vpif_dbg(1, debug, "Failed to set standard for sub devices\n");
1397 1352
1398 mutex_unlock(&common->lock);
1399 return ret; 1353 return ret;
1400} 1354}
1401 1355
@@ -1451,16 +1405,14 @@ static int vpif_s_std(struct file *file, void *priv, v4l2_std_id *std_id)
1451 fh->initialized = 1; 1405 fh->initialized = 1;
1452 1406
1453 /* Call encoder subdevice function to set the standard */ 1407 /* Call encoder subdevice function to set the standard */
1454 if (mutex_lock_interruptible(&common->lock))
1455 return -ERESTARTSYS;
1456
1457 ch->video.stdid = *std_id; 1408 ch->video.stdid = *std_id;
1409 ch->video.dv_preset = V4L2_DV_INVALID;
1410 memset(&ch->video.bt_timings, 0, sizeof(ch->video.bt_timings));
1458 1411
1459 /* Get the information about the standard */ 1412 /* Get the information about the standard */
1460 if (vpif_update_std_info(ch)) { 1413 if (vpif_update_std_info(ch)) {
1461 ret = -EINVAL;
1462 vpif_err("Error getting the standard info\n"); 1414 vpif_err("Error getting the standard info\n");
1463 goto s_std_exit; 1415 return -EINVAL;
1464 } 1416 }
1465 1417
1466 /* Configure the default format information */ 1418 /* Configure the default format information */
@@ -1471,9 +1423,6 @@ static int vpif_s_std(struct file *file, void *priv, v4l2_std_id *std_id)
1471 s_std, *std_id); 1423 s_std, *std_id);
1472 if (ret < 0) 1424 if (ret < 0)
1473 vpif_dbg(1, debug, "Failed to set standard for sub devices\n"); 1425 vpif_dbg(1, debug, "Failed to set standard for sub devices\n");
1474
1475s_std_exit:
1476 mutex_unlock(&common->lock);
1477 return ret; 1426 return ret;
1478} 1427}
1479 1428
@@ -1567,9 +1516,6 @@ static int vpif_s_input(struct file *file, void *priv, unsigned int index)
1567 return -EINVAL; 1516 return -EINVAL;
1568 } 1517 }
1569 1518
1570 if (mutex_lock_interruptible(&common->lock))
1571 return -ERESTARTSYS;
1572
1573 /* first setup input path from sub device to vpif */ 1519 /* first setup input path from sub device to vpif */
1574 if (config->setup_input_path) { 1520 if (config->setup_input_path) {
1575 ret = config->setup_input_path(ch->channel_id, 1521 ret = config->setup_input_path(ch->channel_id,
@@ -1578,7 +1524,7 @@ static int vpif_s_input(struct file *file, void *priv, unsigned int index)
1578 vpif_dbg(1, debug, "couldn't setup input path for the" 1524 vpif_dbg(1, debug, "couldn't setup input path for the"
1579 " sub device %s, for input index %d\n", 1525 " sub device %s, for input index %d\n",
1580 subdev_info->name, index); 1526 subdev_info->name, index);
1581 goto exit; 1527 return ret;
1582 } 1528 }
1583 } 1529 }
1584 1530
@@ -1589,7 +1535,7 @@ static int vpif_s_input(struct file *file, void *priv, unsigned int index)
1589 input, output, 0); 1535 input, output, 0);
1590 if (ret < 0) { 1536 if (ret < 0) {
1591 vpif_dbg(1, debug, "Failed to set input\n"); 1537 vpif_dbg(1, debug, "Failed to set input\n");
1592 goto exit; 1538 return ret;
1593 } 1539 }
1594 } 1540 }
1595 vid_ch->input_idx = index; 1541 vid_ch->input_idx = index;
@@ -1600,9 +1546,6 @@ static int vpif_s_input(struct file *file, void *priv, unsigned int index)
1600 1546
1601 /* update tvnorms from the sub device input info */ 1547 /* update tvnorms from the sub device input info */
1602 ch->video_dev->tvnorms = chan_cfg->inputs[index].input.std; 1548 ch->video_dev->tvnorms = chan_cfg->inputs[index].input.std;
1603
1604exit:
1605 mutex_unlock(&common->lock);
1606 return ret; 1549 return ret;
1607} 1550}
1608 1551
@@ -1671,11 +1614,7 @@ static int vpif_g_fmt_vid_cap(struct file *file, void *priv,
1671 return -EINVAL; 1614 return -EINVAL;
1672 1615
1673 /* Fill in the information about format */ 1616 /* Fill in the information about format */
1674 if (mutex_lock_interruptible(&common->lock))
1675 return -ERESTARTSYS;
1676
1677 *fmt = common->fmt; 1617 *fmt = common->fmt;
1678 mutex_unlock(&common->lock);
1679 return 0; 1618 return 0;
1680} 1619}
1681 1620
@@ -1694,7 +1633,7 @@ static int vpif_s_fmt_vid_cap(struct file *file, void *priv,
1694 struct v4l2_pix_format *pixfmt; 1633 struct v4l2_pix_format *pixfmt;
1695 int ret = 0; 1634 int ret = 0;
1696 1635
1697 vpif_dbg(2, debug, "VIDIOC_S_FMT\n"); 1636 vpif_dbg(2, debug, "%s\n", __func__);
1698 1637
1699 /* If streaming is started, return error */ 1638 /* If streaming is started, return error */
1700 if (common->started) { 1639 if (common->started) {
@@ -1723,12 +1662,7 @@ static int vpif_s_fmt_vid_cap(struct file *file, void *priv,
1723 if (ret) 1662 if (ret)
1724 return ret; 1663 return ret;
1725 /* store the format in the channel object */ 1664 /* store the format in the channel object */
1726 if (mutex_lock_interruptible(&common->lock))
1727 return -ERESTARTSYS;
1728
1729 common->fmt = *fmt; 1665 common->fmt = *fmt;
1730 mutex_unlock(&common->lock);
1731
1732 return 0; 1666 return 0;
1733} 1667}
1734 1668
@@ -1807,6 +1741,306 @@ static int vpif_cropcap(struct file *file, void *priv,
1807 return 0; 1741 return 0;
1808} 1742}
1809 1743
1744/**
1745 * vpif_enum_dv_presets() - ENUM_DV_PRESETS handler
1746 * @file: file ptr
1747 * @priv: file handle
1748 * @preset: input preset
1749 */
1750static int vpif_enum_dv_presets(struct file *file, void *priv,
1751 struct v4l2_dv_enum_preset *preset)
1752{
1753 struct vpif_fh *fh = priv;
1754 struct channel_obj *ch = fh->channel;
1755
1756 return v4l2_subdev_call(vpif_obj.sd[ch->curr_sd_index],
1757 video, enum_dv_presets, preset);
1758}
1759
1760/**
1761 * vpif_query_dv_presets() - QUERY_DV_PRESET handler
1762 * @file: file ptr
1763 * @priv: file handle
1764 * @preset: input preset
1765 */
1766static int vpif_query_dv_preset(struct file *file, void *priv,
1767 struct v4l2_dv_preset *preset)
1768{
1769 struct vpif_fh *fh = priv;
1770 struct channel_obj *ch = fh->channel;
1771
1772 return v4l2_subdev_call(vpif_obj.sd[ch->curr_sd_index],
1773 video, query_dv_preset, preset);
1774}
1775/**
1776 * vpif_s_dv_presets() - S_DV_PRESETS handler
1777 * @file: file ptr
1778 * @priv: file handle
1779 * @preset: input preset
1780 */
1781static int vpif_s_dv_preset(struct file *file, void *priv,
1782 struct v4l2_dv_preset *preset)
1783{
1784 struct vpif_fh *fh = priv;
1785 struct channel_obj *ch = fh->channel;
1786 struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX];
1787 int ret = 0;
1788
1789 if (common->started) {
1790 vpif_dbg(1, debug, "streaming in progress\n");
1791 return -EBUSY;
1792 }
1793
1794 if ((VPIF_CHANNEL0_VIDEO == ch->channel_id) ||
1795 (VPIF_CHANNEL1_VIDEO == ch->channel_id)) {
1796 if (!fh->initialized) {
1797 vpif_dbg(1, debug, "Channel Busy\n");
1798 return -EBUSY;
1799 }
1800 }
1801
1802 ret = v4l2_prio_check(&ch->prio, fh->prio);
1803 if (ret)
1804 return ret;
1805
1806 fh->initialized = 1;
1807
1808 /* Call encoder subdevice function to set the standard */
1809 if (mutex_lock_interruptible(&common->lock))
1810 return -ERESTARTSYS;
1811
1812 ch->video.dv_preset = preset->preset;
1813 ch->video.stdid = V4L2_STD_UNKNOWN;
1814 memset(&ch->video.bt_timings, 0, sizeof(ch->video.bt_timings));
1815
1816 /* Get the information about the standard */
1817 if (vpif_update_std_info(ch)) {
1818 vpif_dbg(1, debug, "Error getting the standard info\n");
1819 ret = -EINVAL;
1820 } else {
1821 /* Configure the default format information */
1822 vpif_config_format(ch);
1823
1824 ret = v4l2_subdev_call(vpif_obj.sd[ch->curr_sd_index],
1825 video, s_dv_preset, preset);
1826 }
1827
1828 mutex_unlock(&common->lock);
1829
1830 return ret;
1831}
1832/**
1833 * vpif_g_dv_presets() - G_DV_PRESETS handler
1834 * @file: file ptr
1835 * @priv: file handle
1836 * @preset: input preset
1837 */
1838static int vpif_g_dv_preset(struct file *file, void *priv,
1839 struct v4l2_dv_preset *preset)
1840{
1841 struct vpif_fh *fh = priv;
1842 struct channel_obj *ch = fh->channel;
1843
1844 preset->preset = ch->video.dv_preset;
1845
1846 return 0;
1847}
1848
1849/**
1850 * vpif_s_dv_timings() - S_DV_TIMINGS handler
1851 * @file: file ptr
1852 * @priv: file handle
1853 * @timings: digital video timings
1854 */
1855static int vpif_s_dv_timings(struct file *file, void *priv,
1856 struct v4l2_dv_timings *timings)
1857{
1858 struct vpif_fh *fh = priv;
1859 struct channel_obj *ch = fh->channel;
1860 struct vpif_params *vpifparams = &ch->vpifparams;
1861 struct vpif_channel_config_params *std_info = &vpifparams->std_info;
1862 struct video_obj *vid_ch = &ch->video;
1863 struct v4l2_bt_timings *bt = &vid_ch->bt_timings;
1864 int ret;
1865
1866 if (timings->type != V4L2_DV_BT_656_1120) {
1867 vpif_dbg(2, debug, "Timing type not defined\n");
1868 return -EINVAL;
1869 }
1870
1871 /* Configure subdevice timings, if any */
1872 ret = v4l2_subdev_call(vpif_obj.sd[ch->curr_sd_index],
1873 video, s_dv_timings, timings);
1874 if (ret == -ENOIOCTLCMD) {
1875 vpif_dbg(2, debug, "Custom DV timings not supported by "
1876 "subdevice\n");
1877 return -EINVAL;
1878 }
1879 if (ret < 0) {
1880 vpif_dbg(2, debug, "Error setting custom DV timings\n");
1881 return ret;
1882 }
1883
1884 if (!(timings->bt.width && timings->bt.height &&
1885 (timings->bt.hbackporch ||
1886 timings->bt.hfrontporch ||
1887 timings->bt.hsync) &&
1888 timings->bt.vfrontporch &&
1889 (timings->bt.vbackporch ||
1890 timings->bt.vsync))) {
1891 vpif_dbg(2, debug, "Timings for width, height, "
1892 "horizontal back porch, horizontal sync, "
1893 "horizontal front porch, vertical back porch, "
1894 "vertical sync and vertical back porch "
1895 "must be defined\n");
1896 return -EINVAL;
1897 }
1898
1899 *bt = timings->bt;
1900
1901 /* Configure video port timings */
1902
1903 std_info->eav2sav = bt->hbackporch + bt->hfrontporch +
1904 bt->hsync - 8;
1905 std_info->sav2eav = bt->width;
1906
1907 std_info->l1 = 1;
1908 std_info->l3 = bt->vsync + bt->vbackporch + 1;
1909
1910 if (bt->interlaced) {
1911 if (bt->il_vbackporch || bt->il_vfrontporch || bt->il_vsync) {
1912 std_info->vsize = bt->height * 2 +
1913 bt->vfrontporch + bt->vsync + bt->vbackporch +
1914 bt->il_vfrontporch + bt->il_vsync +
1915 bt->il_vbackporch;
1916 std_info->l5 = std_info->vsize/2 -
1917 (bt->vfrontporch - 1);
1918 std_info->l7 = std_info->vsize/2 + 1;
1919 std_info->l9 = std_info->l7 + bt->il_vsync +
1920 bt->il_vbackporch + 1;
1921 std_info->l11 = std_info->vsize -
1922 (bt->il_vfrontporch - 1);
1923 } else {
1924 vpif_dbg(2, debug, "Required timing values for "
1925 "interlaced BT format missing\n");
1926 return -EINVAL;
1927 }
1928 } else {
1929 std_info->vsize = bt->height + bt->vfrontporch +
1930 bt->vsync + bt->vbackporch;
1931 std_info->l5 = std_info->vsize - (bt->vfrontporch - 1);
1932 }
1933 strncpy(std_info->name, "Custom timings BT656/1120", VPIF_MAX_NAME);
1934 std_info->width = bt->width;
1935 std_info->height = bt->height;
1936 std_info->frm_fmt = bt->interlaced ? 0 : 1;
1937 std_info->ycmux_mode = 0;
1938 std_info->capture_format = 0;
1939 std_info->vbi_supported = 0;
1940 std_info->hd_sd = 1;
1941 std_info->stdid = 0;
1942 std_info->dv_preset = V4L2_DV_INVALID;
1943
1944 vid_ch->stdid = 0;
1945 vid_ch->dv_preset = V4L2_DV_INVALID;
1946 return 0;
1947}
1948
1949/**
1950 * vpif_g_dv_timings() - G_DV_TIMINGS handler
1951 * @file: file ptr
1952 * @priv: file handle
1953 * @timings: digital video timings
1954 */
1955static int vpif_g_dv_timings(struct file *file, void *priv,
1956 struct v4l2_dv_timings *timings)
1957{
1958 struct vpif_fh *fh = priv;
1959 struct channel_obj *ch = fh->channel;
1960 struct video_obj *vid_ch = &ch->video;
1961 struct v4l2_bt_timings *bt = &vid_ch->bt_timings;
1962
1963 timings->bt = *bt;
1964
1965 return 0;
1966}
1967
1968/*
1969 * vpif_g_chip_ident() - Identify the chip
1970 * @file: file ptr
1971 * @priv: file handle
1972 * @chip: chip identity
1973 *
1974 * Returns zero or -EINVAL if read operations fails.
1975 */
1976static int vpif_g_chip_ident(struct file *file, void *priv,
1977 struct v4l2_dbg_chip_ident *chip)
1978{
1979 chip->ident = V4L2_IDENT_NONE;
1980 chip->revision = 0;
1981 if (chip->match.type != V4L2_CHIP_MATCH_I2C_DRIVER &&
1982 chip->match.type != V4L2_CHIP_MATCH_I2C_ADDR) {
1983 vpif_dbg(2, debug, "match_type is invalid.\n");
1984 return -EINVAL;
1985 }
1986
1987 return v4l2_device_call_until_err(&vpif_obj.v4l2_dev, 0, core,
1988 g_chip_ident, chip);
1989}
1990
1991#ifdef CONFIG_VIDEO_ADV_DEBUG
1992/*
1993 * vpif_dbg_g_register() - Read register
1994 * @file: file ptr
1995 * @priv: file handle
1996 * @reg: register to be read
1997 *
1998 * Debugging only
1999 * Returns zero or -EINVAL if read operations fails.
2000 */
2001static int vpif_dbg_g_register(struct file *file, void *priv,
2002 struct v4l2_dbg_register *reg){
2003 struct vpif_fh *fh = priv;
2004 struct channel_obj *ch = fh->channel;
2005
2006 return v4l2_subdev_call(vpif_obj.sd[ch->curr_sd_index], core,
2007 g_register, reg);
2008}
2009
2010/*
2011 * vpif_dbg_s_register() - Write to register
2012 * @file: file ptr
2013 * @priv: file handle
2014 * @reg: register to be modified
2015 *
2016 * Debugging only
2017 * Returns zero or -EINVAL if write operations fails.
2018 */
2019static int vpif_dbg_s_register(struct file *file, void *priv,
2020 struct v4l2_dbg_register *reg){
2021 struct vpif_fh *fh = priv;
2022 struct channel_obj *ch = fh->channel;
2023
2024 return v4l2_subdev_call(vpif_obj.sd[ch->curr_sd_index], core,
2025 s_register, reg);
2026}
2027#endif
2028
2029/*
2030 * vpif_log_status() - Status information
2031 * @file: file ptr
2032 * @priv: file handle
2033 *
2034 * Returns zero.
2035 */
2036static int vpif_log_status(struct file *filep, void *priv)
2037{
2038 /* status for sub devices */
2039 v4l2_device_call_all(&vpif_obj.v4l2_dev, 0, core, log_status);
2040
2041 return 0;
2042}
2043
1810/* vpif capture ioctl operations */ 2044/* vpif capture ioctl operations */
1811static const struct v4l2_ioctl_ops vpif_ioctl_ops = { 2045static const struct v4l2_ioctl_ops vpif_ioctl_ops = {
1812 .vidioc_querycap = vpif_querycap, 2046 .vidioc_querycap = vpif_querycap,
@@ -1829,6 +2063,18 @@ static const struct v4l2_ioctl_ops vpif_ioctl_ops = {
1829 .vidioc_streamon = vpif_streamon, 2063 .vidioc_streamon = vpif_streamon,
1830 .vidioc_streamoff = vpif_streamoff, 2064 .vidioc_streamoff = vpif_streamoff,
1831 .vidioc_cropcap = vpif_cropcap, 2065 .vidioc_cropcap = vpif_cropcap,
2066 .vidioc_enum_dv_presets = vpif_enum_dv_presets,
2067 .vidioc_s_dv_preset = vpif_s_dv_preset,
2068 .vidioc_g_dv_preset = vpif_g_dv_preset,
2069 .vidioc_query_dv_preset = vpif_query_dv_preset,
2070 .vidioc_s_dv_timings = vpif_s_dv_timings,
2071 .vidioc_g_dv_timings = vpif_g_dv_timings,
2072 .vidioc_g_chip_ident = vpif_g_chip_ident,
2073#ifdef CONFIG_VIDEO_ADV_DEBUG
2074 .vidioc_g_register = vpif_dbg_g_register,
2075 .vidioc_s_register = vpif_dbg_s_register,
2076#endif
2077 .vidioc_log_status = vpif_log_status,
1832}; 2078};
1833 2079
1834/* vpif file operations */ 2080/* vpif file operations */
@@ -1836,7 +2082,7 @@ static struct v4l2_file_operations vpif_fops = {
1836 .owner = THIS_MODULE, 2082 .owner = THIS_MODULE,
1837 .open = vpif_open, 2083 .open = vpif_open,
1838 .release = vpif_release, 2084 .release = vpif_release,
1839 .ioctl = video_ioctl2, 2085 .unlocked_ioctl = video_ioctl2,
1840 .mmap = vpif_mmap, 2086 .mmap = vpif_mmap,
1841 .poll = vpif_poll 2087 .poll = vpif_poll
1842}; 2088};
@@ -1979,6 +2225,7 @@ static __init int vpif_probe(struct platform_device *pdev)
1979 common = &(ch->common[VPIF_VIDEO_INDEX]); 2225 common = &(ch->common[VPIF_VIDEO_INDEX]);
1980 spin_lock_init(&common->irqlock); 2226 spin_lock_init(&common->irqlock);
1981 mutex_init(&common->lock); 2227 mutex_init(&common->lock);
2228 ch->video_dev->lock = &common->lock;
1982 /* Initialize prio member of channel object */ 2229 /* Initialize prio member of channel object */
1983 v4l2_prio_init(&ch->prio); 2230 v4l2_prio_init(&ch->prio);
1984 err = video_register_device(ch->video_dev, 2231 err = video_register_device(ch->video_dev,
@@ -2026,9 +2273,9 @@ static __init int vpif_probe(struct platform_device *pdev)
2026 if (vpif_obj.sd[i]) 2273 if (vpif_obj.sd[i])
2027 vpif_obj.sd[i]->grp_id = 1 << i; 2274 vpif_obj.sd[i]->grp_id = 1 << i;
2028 } 2275 }
2029 v4l2_info(&vpif_obj.v4l2_dev, "DM646x VPIF Capture driver"
2030 " initialized\n");
2031 2276
2277 v4l2_info(&vpif_obj.v4l2_dev,
2278 "DM646x VPIF capture driver initialized\n");
2032 return 0; 2279 return 0;
2033 2280
2034probe_subdev_out: 2281probe_subdev_out:
diff --git a/drivers/media/video/davinci/vpif_capture.h b/drivers/media/video/davinci/vpif_capture.h
index 4e12ec8cac6f..7a4196dfdce1 100644
--- a/drivers/media/video/davinci/vpif_capture.h
+++ b/drivers/media/video/davinci/vpif_capture.h
@@ -59,6 +59,8 @@ struct video_obj {
59 enum v4l2_field buf_field; 59 enum v4l2_field buf_field;
60 /* Currently selected or default standard */ 60 /* Currently selected or default standard */
61 v4l2_std_id stdid; 61 v4l2_std_id stdid;
62 u32 dv_preset;
63 struct v4l2_bt_timings bt_timings;
62 /* This is to track the last input that is passed to application */ 64 /* This is to track the last input that is passed to application */
63 u32 input_idx; 65 u32 input_idx;
64}; 66};
diff --git a/drivers/media/video/davinci/vpif_display.c b/drivers/media/video/davinci/vpif_display.c
index 412c65d54fe1..cdf659abdc2a 100644
--- a/drivers/media/video/davinci/vpif_display.c
+++ b/drivers/media/video/davinci/vpif_display.c
@@ -38,6 +38,7 @@
38#include <media/adv7343.h> 38#include <media/adv7343.h>
39#include <media/v4l2-device.h> 39#include <media/v4l2-device.h>
40#include <media/v4l2-ioctl.h> 40#include <media/v4l2-ioctl.h>
41#include <media/v4l2-chip-ident.h>
41 42
42#include <mach/dm646x.h> 43#include <mach/dm646x.h>
43 44
@@ -84,17 +85,6 @@ static struct vpif_config_params config_params = {
84static struct vpif_device vpif_obj = { {NULL} }; 85static struct vpif_device vpif_obj = { {NULL} };
85static struct device *vpif_dev; 86static struct device *vpif_dev;
86 87
87static const struct vpif_channel_config_params ch_params[] = {
88 {
89 "NTSC", 720, 480, 30, 0, 1, 268, 1440, 1, 23, 263, 266,
90 286, 525, 525, 0, 1, 0, V4L2_STD_525_60,
91 },
92 {
93 "PAL", 720, 576, 25, 0, 1, 280, 1440, 1, 23, 311, 313,
94 336, 624, 625, 0, 1, 0, V4L2_STD_625_50,
95 },
96};
97
98/* 88/*
99 * vpif_uservirt_to_phys: This function is used to convert user 89 * vpif_uservirt_to_phys: This function is used to convert user
100 * space virtual address to physical address. 90 * space virtual address to physical address.
@@ -373,30 +363,54 @@ static irqreturn_t vpif_channel_isr(int irq, void *dev_id)
373 return IRQ_HANDLED; 363 return IRQ_HANDLED;
374} 364}
375 365
376static int vpif_get_std_info(struct channel_obj *ch) 366static int vpif_update_std_info(struct channel_obj *ch)
377{ 367{
378 struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX];
379 struct video_obj *vid_ch = &ch->video; 368 struct video_obj *vid_ch = &ch->video;
380 struct vpif_params *vpifparams = &ch->vpifparams; 369 struct vpif_params *vpifparams = &ch->vpifparams;
381 struct vpif_channel_config_params *std_info = &vpifparams->std_info; 370 struct vpif_channel_config_params *std_info = &vpifparams->std_info;
382 const struct vpif_channel_config_params *config; 371 const struct vpif_channel_config_params *config;
383 372
384 int index; 373 int i;
385
386 std_info->stdid = vid_ch->stdid;
387 if (!std_info->stdid)
388 return -1;
389 374
390 for (index = 0; index < ARRAY_SIZE(ch_params); index++) { 375 for (i = 0; i < vpif_ch_params_count; i++) {
391 config = &ch_params[index]; 376 config = &ch_params[i];
392 if (config->stdid & std_info->stdid) { 377 if (config->hd_sd == 0) {
393 memcpy(std_info, config, sizeof(*config)); 378 vpif_dbg(2, debug, "SD format\n");
394 break; 379 if (config->stdid & vid_ch->stdid) {
380 memcpy(std_info, config, sizeof(*config));
381 break;
382 }
383 } else {
384 vpif_dbg(2, debug, "HD format\n");
385 if (config->dv_preset == vid_ch->dv_preset) {
386 memcpy(std_info, config, sizeof(*config));
387 break;
388 }
395 } 389 }
396 } 390 }
397 391
398 if (index == ARRAY_SIZE(ch_params)) 392 if (i == vpif_ch_params_count) {
399 return -1; 393 vpif_dbg(1, debug, "Format not found\n");
394 return -EINVAL;
395 }
396
397 return 0;
398}
399
400static int vpif_update_resolution(struct channel_obj *ch)
401{
402 struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX];
403 struct video_obj *vid_ch = &ch->video;
404 struct vpif_params *vpifparams = &ch->vpifparams;
405 struct vpif_channel_config_params *std_info = &vpifparams->std_info;
406
407 if (!vid_ch->stdid && !vid_ch->dv_preset && !vid_ch->bt_timings.height)
408 return -EINVAL;
409
410 if (vid_ch->stdid || vid_ch->dv_preset) {
411 if (vpif_update_std_info(ch))
412 return -EINVAL;
413 }
400 414
401 common->fmt.fmt.pix.width = std_info->width; 415 common->fmt.fmt.pix.width = std_info->width;
402 common->fmt.fmt.pix.height = std_info->height; 416 common->fmt.fmt.pix.height = std_info->height;
@@ -404,8 +418,8 @@ static int vpif_get_std_info(struct channel_obj *ch)
404 common->fmt.fmt.pix.width, common->fmt.fmt.pix.height); 418 common->fmt.fmt.pix.width, common->fmt.fmt.pix.height);
405 419
406 /* Set height and width paramateres */ 420 /* Set height and width paramateres */
407 ch->common[VPIF_VIDEO_INDEX].height = std_info->height; 421 common->height = std_info->height;
408 ch->common[VPIF_VIDEO_INDEX].width = std_info->width; 422 common->width = std_info->width;
409 423
410 return 0; 424 return 0;
411} 425}
@@ -516,10 +530,8 @@ static int vpif_check_format(struct channel_obj *ch,
516 else 530 else
517 sizeimage = config_params.channel_bufsize[ch->channel_id]; 531 sizeimage = config_params.channel_bufsize[ch->channel_id];
518 532
519 if (vpif_get_std_info(ch)) { 533 if (vpif_update_resolution(ch))
520 vpif_err("Error getting the standard info\n");
521 return -EINVAL; 534 return -EINVAL;
522 }
523 535
524 hpitch = pixfmt->bytesperline; 536 hpitch = pixfmt->bytesperline;
525 vpitch = sizeimage / (hpitch * 2); 537 vpitch = sizeimage / (hpitch * 2);
@@ -568,7 +580,10 @@ static void vpif_config_addr(struct channel_obj *ch, int muxmode)
568static int vpif_mmap(struct file *filep, struct vm_area_struct *vma) 580static int vpif_mmap(struct file *filep, struct vm_area_struct *vma)
569{ 581{
570 struct vpif_fh *fh = filep->private_data; 582 struct vpif_fh *fh = filep->private_data;
571 struct common_obj *common = &fh->channel->common[VPIF_VIDEO_INDEX]; 583 struct channel_obj *ch = fh->channel;
584 struct common_obj *common = &(ch->common[VPIF_VIDEO_INDEX]);
585
586 vpif_dbg(2, debug, "vpif_mmap\n");
572 587
573 return videobuf_mmap_mapper(&common->buffer_queue, vma); 588 return videobuf_mmap_mapper(&common->buffer_queue, vma);
574} 589}
@@ -637,9 +652,6 @@ static int vpif_release(struct file *filep)
637 struct channel_obj *ch = fh->channel; 652 struct channel_obj *ch = fh->channel;
638 struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; 653 struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX];
639 654
640 if (mutex_lock_interruptible(&common->lock))
641 return -ERESTARTSYS;
642
643 /* if this instance is doing IO */ 655 /* if this instance is doing IO */
644 if (fh->io_allowed[VPIF_VIDEO_INDEX]) { 656 if (fh->io_allowed[VPIF_VIDEO_INDEX]) {
645 /* Reset io_usrs member of channel object */ 657 /* Reset io_usrs member of channel object */
@@ -662,8 +674,6 @@ static int vpif_release(struct file *filep)
662 config_params.numbuffers[ch->channel_id]; 674 config_params.numbuffers[ch->channel_id];
663 } 675 }
664 676
665 mutex_unlock(&common->lock);
666
667 /* Decrement channel usrs counter */ 677 /* Decrement channel usrs counter */
668 atomic_dec(&ch->usrs); 678 atomic_dec(&ch->usrs);
669 /* If this file handle has initialize encoder device, reset it */ 679 /* If this file handle has initialize encoder device, reset it */
@@ -680,7 +690,12 @@ static int vpif_release(struct file *filep)
680} 690}
681 691
682/* functions implementing ioctls */ 692/* functions implementing ioctls */
683 693/**
694 * vpif_querycap() - QUERYCAP handler
695 * @file: file ptr
696 * @priv: file handle
697 * @cap: ptr to v4l2_capability structure
698 */
684static int vpif_querycap(struct file *file, void *priv, 699static int vpif_querycap(struct file *file, void *priv,
685 struct v4l2_capability *cap) 700 struct v4l2_capability *cap)
686{ 701{
@@ -722,17 +737,9 @@ static int vpif_g_fmt_vid_out(struct file *file, void *priv,
722 if (common->fmt.type != fmt->type) 737 if (common->fmt.type != fmt->type)
723 return -EINVAL; 738 return -EINVAL;
724 739
725 /* Fill in the information about format */ 740 if (vpif_update_resolution(ch))
726 if (mutex_lock_interruptible(&common->lock))
727 return -ERESTARTSYS;
728
729 if (vpif_get_std_info(ch)) {
730 vpif_err("Error getting the standard info\n");
731 return -EINVAL; 741 return -EINVAL;
732 }
733
734 *fmt = common->fmt; 742 *fmt = common->fmt;
735 mutex_unlock(&common->lock);
736 return 0; 743 return 0;
737} 744}
738 745
@@ -773,12 +780,7 @@ static int vpif_s_fmt_vid_out(struct file *file, void *priv,
773 /* store the pix format in the channel object */ 780 /* store the pix format in the channel object */
774 common->fmt.fmt.pix = *pixfmt; 781 common->fmt.fmt.pix = *pixfmt;
775 /* store the format in the channel object */ 782 /* store the format in the channel object */
776 if (mutex_lock_interruptible(&common->lock))
777 return -ERESTARTSYS;
778
779 common->fmt = *fmt; 783 common->fmt = *fmt;
780 mutex_unlock(&common->lock);
781
782 return 0; 784 return 0;
783} 785}
784 786
@@ -808,7 +810,6 @@ static int vpif_reqbufs(struct file *file, void *priv,
808 struct common_obj *common; 810 struct common_obj *common;
809 enum v4l2_field field; 811 enum v4l2_field field;
810 u8 index = 0; 812 u8 index = 0;
811 int ret = 0;
812 813
813 /* This file handle has not initialized the channel, 814 /* This file handle has not initialized the channel,
814 It is not allowed to do settings */ 815 It is not allowed to do settings */
@@ -826,18 +827,12 @@ static int vpif_reqbufs(struct file *file, void *priv,
826 index = VPIF_VIDEO_INDEX; 827 index = VPIF_VIDEO_INDEX;
827 828
828 common = &ch->common[index]; 829 common = &ch->common[index];
829 if (mutex_lock_interruptible(&common->lock))
830 return -ERESTARTSYS;
831 830
832 if (common->fmt.type != reqbuf->type) { 831 if (common->fmt.type != reqbuf->type)
833 ret = -EINVAL; 832 return -EINVAL;
834 goto reqbuf_exit;
835 }
836 833
837 if (0 != common->io_usrs) { 834 if (0 != common->io_usrs)
838 ret = -EBUSY; 835 return -EBUSY;
839 goto reqbuf_exit;
840 }
841 836
842 if (reqbuf->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { 837 if (reqbuf->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
843 if (common->fmt.fmt.pix.field == V4L2_FIELD_ANY) 838 if (common->fmt.fmt.pix.field == V4L2_FIELD_ANY)
@@ -854,7 +849,7 @@ static int vpif_reqbufs(struct file *file, void *priv,
854 &common->irqlock, 849 &common->irqlock,
855 reqbuf->type, field, 850 reqbuf->type, field,
856 sizeof(struct videobuf_buffer), fh, 851 sizeof(struct videobuf_buffer), fh,
857 NULL); 852 &common->lock);
858 853
859 /* Set io allowed member of file handle to TRUE */ 854 /* Set io allowed member of file handle to TRUE */
860 fh->io_allowed[index] = 1; 855 fh->io_allowed[index] = 1;
@@ -865,11 +860,7 @@ static int vpif_reqbufs(struct file *file, void *priv,
865 INIT_LIST_HEAD(&common->dma_queue); 860 INIT_LIST_HEAD(&common->dma_queue);
866 861
867 /* Allocate buffers */ 862 /* Allocate buffers */
868 ret = videobuf_reqbufs(&common->buffer_queue, reqbuf); 863 return videobuf_reqbufs(&common->buffer_queue, reqbuf);
869
870reqbuf_exit:
871 mutex_unlock(&common->lock);
872 return ret;
873} 864}
874 865
875static int vpif_querybuf(struct file *file, void *priv, 866static int vpif_querybuf(struct file *file, void *priv,
@@ -990,22 +981,19 @@ static int vpif_s_std(struct file *file, void *priv, v4l2_std_id *std_id)
990 } 981 }
991 982
992 /* Call encoder subdevice function to set the standard */ 983 /* Call encoder subdevice function to set the standard */
993 if (mutex_lock_interruptible(&common->lock))
994 return -ERESTARTSYS;
995
996 ch->video.stdid = *std_id; 984 ch->video.stdid = *std_id;
985 ch->video.dv_preset = V4L2_DV_INVALID;
986 memset(&ch->video.bt_timings, 0, sizeof(ch->video.bt_timings));
987
997 /* Get the information about the standard */ 988 /* Get the information about the standard */
998 if (vpif_get_std_info(ch)) { 989 if (vpif_update_resolution(ch))
999 vpif_err("Error getting the standard info\n");
1000 return -EINVAL; 990 return -EINVAL;
1001 }
1002 991
1003 if ((ch->vpifparams.std_info.width * 992 if ((ch->vpifparams.std_info.width *
1004 ch->vpifparams.std_info.height * 2) > 993 ch->vpifparams.std_info.height * 2) >
1005 config_params.channel_bufsize[ch->channel_id]) { 994 config_params.channel_bufsize[ch->channel_id]) {
1006 vpif_err("invalid std for this size\n"); 995 vpif_err("invalid std for this size\n");
1007 ret = -EINVAL; 996 return -EINVAL;
1008 goto s_std_exit;
1009 } 997 }
1010 998
1011 common->fmt.fmt.pix.bytesperline = common->fmt.fmt.pix.width; 999 common->fmt.fmt.pix.bytesperline = common->fmt.fmt.pix.width;
@@ -1016,16 +1004,13 @@ static int vpif_s_std(struct file *file, void *priv, v4l2_std_id *std_id)
1016 s_std_output, *std_id); 1004 s_std_output, *std_id);
1017 if (ret < 0) { 1005 if (ret < 0) {
1018 vpif_err("Failed to set output standard\n"); 1006 vpif_err("Failed to set output standard\n");
1019 goto s_std_exit; 1007 return ret;
1020 } 1008 }
1021 1009
1022 ret = v4l2_device_call_until_err(&vpif_obj.v4l2_dev, 1, core, 1010 ret = v4l2_device_call_until_err(&vpif_obj.v4l2_dev, 1, core,
1023 s_std, *std_id); 1011 s_std, *std_id);
1024 if (ret < 0) 1012 if (ret < 0)
1025 vpif_err("Failed to set standard for sub devices\n"); 1013 vpif_err("Failed to set standard for sub devices\n");
1026
1027s_std_exit:
1028 mutex_unlock(&common->lock);
1029 return ret; 1014 return ret;
1030} 1015}
1031 1016
@@ -1090,21 +1075,17 @@ static int vpif_streamon(struct file *file, void *priv,
1090 if (ret < 0) 1075 if (ret < 0)
1091 return ret; 1076 return ret;
1092 1077
1093 /* Call videobuf_streamon to start streaming in videobuf */ 1078 /* Call videobuf_streamon to start streaming in videobuf */
1094 ret = videobuf_streamon(&common->buffer_queue); 1079 ret = videobuf_streamon(&common->buffer_queue);
1095 if (ret < 0) { 1080 if (ret < 0) {
1096 vpif_err("videobuf_streamon\n"); 1081 vpif_err("videobuf_streamon\n");
1097 return ret; 1082 return ret;
1098 } 1083 }
1099 1084
1100 if (mutex_lock_interruptible(&common->lock))
1101 return -ERESTARTSYS;
1102
1103 /* If buffer queue is empty, return error */ 1085 /* If buffer queue is empty, return error */
1104 if (list_empty(&common->dma_queue)) { 1086 if (list_empty(&common->dma_queue)) {
1105 vpif_err("buffer queue is empty\n"); 1087 vpif_err("buffer queue is empty\n");
1106 ret = -EIO; 1088 return -EIO;
1107 goto streamon_exit;
1108 } 1089 }
1109 1090
1110 /* Get the next frame from the buffer queue */ 1091 /* Get the next frame from the buffer queue */
@@ -1130,8 +1111,7 @@ static int vpif_streamon(struct file *file, void *priv,
1130 || (!ch->vpifparams.std_info.frm_fmt 1111 || (!ch->vpifparams.std_info.frm_fmt
1131 && (common->fmt.fmt.pix.field == V4L2_FIELD_NONE))) { 1112 && (common->fmt.fmt.pix.field == V4L2_FIELD_NONE))) {
1132 vpif_err("conflict in field format and std format\n"); 1113 vpif_err("conflict in field format and std format\n");
1133 ret = -EINVAL; 1114 return -EINVAL;
1134 goto streamon_exit;
1135 } 1115 }
1136 1116
1137 /* clock settings */ 1117 /* clock settings */
@@ -1140,13 +1120,13 @@ static int vpif_streamon(struct file *file, void *priv,
1140 ch->vpifparams.std_info.hd_sd); 1120 ch->vpifparams.std_info.hd_sd);
1141 if (ret < 0) { 1121 if (ret < 0) {
1142 vpif_err("can't set clock\n"); 1122 vpif_err("can't set clock\n");
1143 goto streamon_exit; 1123 return ret;
1144 } 1124 }
1145 1125
1146 /* set the parameters and addresses */ 1126 /* set the parameters and addresses */
1147 ret = vpif_set_video_params(vpif, ch->channel_id + 2); 1127 ret = vpif_set_video_params(vpif, ch->channel_id + 2);
1148 if (ret < 0) 1128 if (ret < 0)
1149 goto streamon_exit; 1129 return ret;
1150 1130
1151 common->started = ret; 1131 common->started = ret;
1152 vpif_config_addr(ch, ret); 1132 vpif_config_addr(ch, ret);
@@ -1171,9 +1151,6 @@ static int vpif_streamon(struct file *file, void *priv,
1171 } 1151 }
1172 channel_first_int[VPIF_VIDEO_INDEX][ch->channel_id] = 1; 1152 channel_first_int[VPIF_VIDEO_INDEX][ch->channel_id] = 1;
1173 } 1153 }
1174
1175streamon_exit:
1176 mutex_unlock(&common->lock);
1177 return ret; 1154 return ret;
1178} 1155}
1179 1156
@@ -1199,9 +1176,6 @@ static int vpif_streamoff(struct file *file, void *priv,
1199 return -EINVAL; 1176 return -EINVAL;
1200 } 1177 }
1201 1178
1202 if (mutex_lock_interruptible(&common->lock))
1203 return -ERESTARTSYS;
1204
1205 if (buftype == V4L2_BUF_TYPE_VIDEO_OUTPUT) { 1179 if (buftype == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
1206 /* disable channel */ 1180 /* disable channel */
1207 if (VPIF_CHANNEL2_VIDEO == ch->channel_id) { 1181 if (VPIF_CHANNEL2_VIDEO == ch->channel_id) {
@@ -1216,8 +1190,6 @@ static int vpif_streamoff(struct file *file, void *priv,
1216 } 1190 }
1217 1191
1218 common->started = 0; 1192 common->started = 0;
1219 mutex_unlock(&common->lock);
1220
1221 return videobuf_streamoff(&common->buffer_queue); 1193 return videobuf_streamoff(&common->buffer_queue);
1222} 1194}
1223 1195
@@ -1264,13 +1236,9 @@ static int vpif_s_output(struct file *file, void *priv, unsigned int i)
1264 struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; 1236 struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX];
1265 int ret = 0; 1237 int ret = 0;
1266 1238
1267 if (mutex_lock_interruptible(&common->lock))
1268 return -ERESTARTSYS;
1269
1270 if (common->started) { 1239 if (common->started) {
1271 vpif_err("Streaming in progress\n"); 1240 vpif_err("Streaming in progress\n");
1272 ret = -EBUSY; 1241 return -EBUSY;
1273 goto s_output_exit;
1274 } 1242 }
1275 1243
1276 ret = v4l2_device_call_until_err(&vpif_obj.v4l2_dev, 1, video, 1244 ret = v4l2_device_call_until_err(&vpif_obj.v4l2_dev, 1, video,
@@ -1280,9 +1248,6 @@ static int vpif_s_output(struct file *file, void *priv, unsigned int i)
1280 vpif_err("Failed to set output standard\n"); 1248 vpif_err("Failed to set output standard\n");
1281 1249
1282 vid_ch->output_id = i; 1250 vid_ch->output_id = i;
1283
1284s_output_exit:
1285 mutex_unlock(&common->lock);
1286 return ret; 1251 return ret;
1287} 1252}
1288 1253
@@ -1315,6 +1280,287 @@ static int vpif_s_priority(struct file *file, void *priv, enum v4l2_priority p)
1315 return v4l2_prio_change(&ch->prio, &fh->prio, p); 1280 return v4l2_prio_change(&ch->prio, &fh->prio, p);
1316} 1281}
1317 1282
1283/**
1284 * vpif_enum_dv_presets() - ENUM_DV_PRESETS handler
1285 * @file: file ptr
1286 * @priv: file handle
1287 * @preset: input preset
1288 */
1289static int vpif_enum_dv_presets(struct file *file, void *priv,
1290 struct v4l2_dv_enum_preset *preset)
1291{
1292 struct vpif_fh *fh = priv;
1293 struct channel_obj *ch = fh->channel;
1294 struct video_obj *vid_ch = &ch->video;
1295
1296 return v4l2_subdev_call(vpif_obj.sd[vid_ch->output_id],
1297 video, enum_dv_presets, preset);
1298}
1299
1300/**
1301 * vpif_s_dv_presets() - S_DV_PRESETS handler
1302 * @file: file ptr
1303 * @priv: file handle
1304 * @preset: input preset
1305 */
1306static int vpif_s_dv_preset(struct file *file, void *priv,
1307 struct v4l2_dv_preset *preset)
1308{
1309 struct vpif_fh *fh = priv;
1310 struct channel_obj *ch = fh->channel;
1311 struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX];
1312 struct video_obj *vid_ch = &ch->video;
1313 int ret = 0;
1314
1315 if (common->started) {
1316 vpif_dbg(1, debug, "streaming in progress\n");
1317 return -EBUSY;
1318 }
1319
1320 ret = v4l2_prio_check(&ch->prio, fh->prio);
1321 if (ret != 0)
1322 return ret;
1323
1324 fh->initialized = 1;
1325
1326 /* Call encoder subdevice function to set the standard */
1327 if (mutex_lock_interruptible(&common->lock))
1328 return -ERESTARTSYS;
1329
1330 ch->video.dv_preset = preset->preset;
1331 ch->video.stdid = V4L2_STD_UNKNOWN;
1332 memset(&ch->video.bt_timings, 0, sizeof(ch->video.bt_timings));
1333
1334 /* Get the information about the standard */
1335 if (vpif_update_resolution(ch)) {
1336 ret = -EINVAL;
1337 } else {
1338 /* Configure the default format information */
1339 vpif_config_format(ch);
1340
1341 ret = v4l2_subdev_call(vpif_obj.sd[vid_ch->output_id],
1342 video, s_dv_preset, preset);
1343 }
1344
1345 mutex_unlock(&common->lock);
1346
1347 return ret;
1348}
1349/**
1350 * vpif_g_dv_presets() - G_DV_PRESETS handler
1351 * @file: file ptr
1352 * @priv: file handle
1353 * @preset: input preset
1354 */
1355static int vpif_g_dv_preset(struct file *file, void *priv,
1356 struct v4l2_dv_preset *preset)
1357{
1358 struct vpif_fh *fh = priv;
1359 struct channel_obj *ch = fh->channel;
1360
1361 preset->preset = ch->video.dv_preset;
1362
1363 return 0;
1364}
1365/**
1366 * vpif_s_dv_timings() - S_DV_TIMINGS handler
1367 * @file: file ptr
1368 * @priv: file handle
1369 * @timings: digital video timings
1370 */
1371static int vpif_s_dv_timings(struct file *file, void *priv,
1372 struct v4l2_dv_timings *timings)
1373{
1374 struct vpif_fh *fh = priv;
1375 struct channel_obj *ch = fh->channel;
1376 struct vpif_params *vpifparams = &ch->vpifparams;
1377 struct vpif_channel_config_params *std_info = &vpifparams->std_info;
1378 struct video_obj *vid_ch = &ch->video;
1379 struct v4l2_bt_timings *bt = &vid_ch->bt_timings;
1380 int ret;
1381
1382 if (timings->type != V4L2_DV_BT_656_1120) {
1383 vpif_dbg(2, debug, "Timing type not defined\n");
1384 return -EINVAL;
1385 }
1386
1387 /* Configure subdevice timings, if any */
1388 ret = v4l2_subdev_call(vpif_obj.sd[vid_ch->output_id],
1389 video, s_dv_timings, timings);
1390 if (ret == -ENOIOCTLCMD) {
1391 vpif_dbg(2, debug, "Custom DV timings not supported by "
1392 "subdevice\n");
1393 return -EINVAL;
1394 }
1395 if (ret < 0) {
1396 vpif_dbg(2, debug, "Error setting custom DV timings\n");
1397 return ret;
1398 }
1399
1400 if (!(timings->bt.width && timings->bt.height &&
1401 (timings->bt.hbackporch ||
1402 timings->bt.hfrontporch ||
1403 timings->bt.hsync) &&
1404 timings->bt.vfrontporch &&
1405 (timings->bt.vbackporch ||
1406 timings->bt.vsync))) {
1407 vpif_dbg(2, debug, "Timings for width, height, "
1408 "horizontal back porch, horizontal sync, "
1409 "horizontal front porch, vertical back porch, "
1410 "vertical sync and vertical back porch "
1411 "must be defined\n");
1412 return -EINVAL;
1413 }
1414
1415 *bt = timings->bt;
1416
1417 /* Configure video port timings */
1418
1419 std_info->eav2sav = bt->hbackporch + bt->hfrontporch +
1420 bt->hsync - 8;
1421 std_info->sav2eav = bt->width;
1422
1423 std_info->l1 = 1;
1424 std_info->l3 = bt->vsync + bt->vbackporch + 1;
1425
1426 if (bt->interlaced) {
1427 if (bt->il_vbackporch || bt->il_vfrontporch || bt->il_vsync) {
1428 std_info->vsize = bt->height * 2 +
1429 bt->vfrontporch + bt->vsync + bt->vbackporch +
1430 bt->il_vfrontporch + bt->il_vsync +
1431 bt->il_vbackporch;
1432 std_info->l5 = std_info->vsize/2 -
1433 (bt->vfrontporch - 1);
1434 std_info->l7 = std_info->vsize/2 + 1;
1435 std_info->l9 = std_info->l7 + bt->il_vsync +
1436 bt->il_vbackporch + 1;
1437 std_info->l11 = std_info->vsize -
1438 (bt->il_vfrontporch - 1);
1439 } else {
1440 vpif_dbg(2, debug, "Required timing values for "
1441 "interlaced BT format missing\n");
1442 return -EINVAL;
1443 }
1444 } else {
1445 std_info->vsize = bt->height + bt->vfrontporch +
1446 bt->vsync + bt->vbackporch;
1447 std_info->l5 = std_info->vsize - (bt->vfrontporch - 1);
1448 }
1449 strncpy(std_info->name, "Custom timings BT656/1120",
1450 VPIF_MAX_NAME);
1451 std_info->width = bt->width;
1452 std_info->height = bt->height;
1453 std_info->frm_fmt = bt->interlaced ? 0 : 1;
1454 std_info->ycmux_mode = 0;
1455 std_info->capture_format = 0;
1456 std_info->vbi_supported = 0;
1457 std_info->hd_sd = 1;
1458 std_info->stdid = 0;
1459 std_info->dv_preset = V4L2_DV_INVALID;
1460
1461 vid_ch->stdid = 0;
1462 vid_ch->dv_preset = V4L2_DV_INVALID;
1463
1464 return 0;
1465}
1466
1467/**
1468 * vpif_g_dv_timings() - G_DV_TIMINGS handler
1469 * @file: file ptr
1470 * @priv: file handle
1471 * @timings: digital video timings
1472 */
1473static int vpif_g_dv_timings(struct file *file, void *priv,
1474 struct v4l2_dv_timings *timings)
1475{
1476 struct vpif_fh *fh = priv;
1477 struct channel_obj *ch = fh->channel;
1478 struct video_obj *vid_ch = &ch->video;
1479 struct v4l2_bt_timings *bt = &vid_ch->bt_timings;
1480
1481 timings->bt = *bt;
1482
1483 return 0;
1484}
1485
1486/*
1487 * vpif_g_chip_ident() - Identify the chip
1488 * @file: file ptr
1489 * @priv: file handle
1490 * @chip: chip identity
1491 *
1492 * Returns zero or -EINVAL if read operations fails.
1493 */
1494static int vpif_g_chip_ident(struct file *file, void *priv,
1495 struct v4l2_dbg_chip_ident *chip)
1496{
1497 chip->ident = V4L2_IDENT_NONE;
1498 chip->revision = 0;
1499 if (chip->match.type != V4L2_CHIP_MATCH_I2C_DRIVER &&
1500 chip->match.type != V4L2_CHIP_MATCH_I2C_ADDR) {
1501 vpif_dbg(2, debug, "match_type is invalid.\n");
1502 return -EINVAL;
1503 }
1504
1505 return v4l2_device_call_until_err(&vpif_obj.v4l2_dev, 0, core,
1506 g_chip_ident, chip);
1507}
1508
1509#ifdef CONFIG_VIDEO_ADV_DEBUG
1510/*
1511 * vpif_dbg_g_register() - Read register
1512 * @file: file ptr
1513 * @priv: file handle
1514 * @reg: register to be read
1515 *
1516 * Debugging only
1517 * Returns zero or -EINVAL if read operations fails.
1518 */
1519static int vpif_dbg_g_register(struct file *file, void *priv,
1520 struct v4l2_dbg_register *reg){
1521 struct vpif_fh *fh = priv;
1522 struct channel_obj *ch = fh->channel;
1523 struct video_obj *vid_ch = &ch->video;
1524
1525 return v4l2_subdev_call(vpif_obj.sd[vid_ch->output_id], core,
1526 g_register, reg);
1527}
1528
1529/*
1530 * vpif_dbg_s_register() - Write to register
1531 * @file: file ptr
1532 * @priv: file handle
1533 * @reg: register to be modified
1534 *
1535 * Debugging only
1536 * Returns zero or -EINVAL if write operations fails.
1537 */
1538static int vpif_dbg_s_register(struct file *file, void *priv,
1539 struct v4l2_dbg_register *reg){
1540 struct vpif_fh *fh = priv;
1541 struct channel_obj *ch = fh->channel;
1542 struct video_obj *vid_ch = &ch->video;
1543
1544 return v4l2_subdev_call(vpif_obj.sd[vid_ch->output_id], core,
1545 s_register, reg);
1546}
1547#endif
1548
1549/*
1550 * vpif_log_status() - Status information
1551 * @file: file ptr
1552 * @priv: file handle
1553 *
1554 * Returns zero.
1555 */
1556static int vpif_log_status(struct file *filep, void *priv)
1557{
1558 /* status for sub devices */
1559 v4l2_device_call_all(&vpif_obj.v4l2_dev, 0, core, log_status);
1560
1561 return 0;
1562}
1563
1318/* vpif display ioctl operations */ 1564/* vpif display ioctl operations */
1319static const struct v4l2_ioctl_ops vpif_ioctl_ops = { 1565static const struct v4l2_ioctl_ops vpif_ioctl_ops = {
1320 .vidioc_querycap = vpif_querycap, 1566 .vidioc_querycap = vpif_querycap,
@@ -1336,13 +1582,24 @@ static const struct v4l2_ioctl_ops vpif_ioctl_ops = {
1336 .vidioc_s_output = vpif_s_output, 1582 .vidioc_s_output = vpif_s_output,
1337 .vidioc_g_output = vpif_g_output, 1583 .vidioc_g_output = vpif_g_output,
1338 .vidioc_cropcap = vpif_cropcap, 1584 .vidioc_cropcap = vpif_cropcap,
1585 .vidioc_enum_dv_presets = vpif_enum_dv_presets,
1586 .vidioc_s_dv_preset = vpif_s_dv_preset,
1587 .vidioc_g_dv_preset = vpif_g_dv_preset,
1588 .vidioc_s_dv_timings = vpif_s_dv_timings,
1589 .vidioc_g_dv_timings = vpif_g_dv_timings,
1590 .vidioc_g_chip_ident = vpif_g_chip_ident,
1591#ifdef CONFIG_VIDEO_ADV_DEBUG
1592 .vidioc_g_register = vpif_dbg_g_register,
1593 .vidioc_s_register = vpif_dbg_s_register,
1594#endif
1595 .vidioc_log_status = vpif_log_status,
1339}; 1596};
1340 1597
1341static const struct v4l2_file_operations vpif_fops = { 1598static const struct v4l2_file_operations vpif_fops = {
1342 .owner = THIS_MODULE, 1599 .owner = THIS_MODULE,
1343 .open = vpif_open, 1600 .open = vpif_open,
1344 .release = vpif_release, 1601 .release = vpif_release,
1345 .ioctl = video_ioctl2, 1602 .unlocked_ioctl = video_ioctl2,
1346 .mmap = vpif_mmap, 1603 .mmap = vpif_mmap,
1347 .poll = vpif_poll 1604 .poll = vpif_poll
1348}; 1605};
@@ -1526,6 +1783,7 @@ static __init int vpif_probe(struct platform_device *pdev)
1526 v4l2_prio_init(&ch->prio); 1783 v4l2_prio_init(&ch->prio);
1527 ch->common[VPIF_VIDEO_INDEX].fmt.type = 1784 ch->common[VPIF_VIDEO_INDEX].fmt.type =
1528 V4L2_BUF_TYPE_VIDEO_OUTPUT; 1785 V4L2_BUF_TYPE_VIDEO_OUTPUT;
1786 ch->video_dev->lock = &common->lock;
1529 1787
1530 /* register video device */ 1788 /* register video device */
1531 vpif_dbg(1, debug, "channel=%x,channel->video_dev=%x\n", 1789 vpif_dbg(1, debug, "channel=%x,channel->video_dev=%x\n",
@@ -1565,6 +1823,8 @@ static __init int vpif_probe(struct platform_device *pdev)
1565 vpif_obj.sd[i]->grp_id = 1 << i; 1823 vpif_obj.sd[i]->grp_id = 1 << i;
1566 } 1824 }
1567 1825
1826 v4l2_info(&vpif_obj.v4l2_dev,
1827 "DM646x VPIF display driver initialized\n");
1568 return 0; 1828 return 0;
1569 1829
1570probe_subdev_out: 1830probe_subdev_out:
diff --git a/drivers/media/video/davinci/vpif_display.h b/drivers/media/video/davinci/vpif_display.h
index a2a7cd166bbf..b53aaa883075 100644
--- a/drivers/media/video/davinci/vpif_display.h
+++ b/drivers/media/video/davinci/vpif_display.h
@@ -67,6 +67,8 @@ struct video_obj {
67 * most recent displayed frame only */ 67 * most recent displayed frame only */
68 v4l2_std_id stdid; /* Currently selected or default 68 v4l2_std_id stdid; /* Currently selected or default
69 * standard */ 69 * standard */
70 u32 dv_preset;
71 struct v4l2_bt_timings bt_timings;
70 u32 output_id; /* Current output id */ 72 u32 output_id; /* Current output id */
71}; 73};
72 74
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index 099d5df8c572..87f77a34eeab 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -33,6 +33,7 @@
33#include <media/saa7115.h> 33#include <media/saa7115.h>
34#include <media/tvp5150.h> 34#include <media/tvp5150.h>
35#include <media/tvaudio.h> 35#include <media/tvaudio.h>
36#include <media/mt9v011.h>
36#include <media/i2c-addr.h> 37#include <media/i2c-addr.h>
37#include <media/tveeprom.h> 38#include <media/tveeprom.h>
38#include <media/v4l2-common.h> 39#include <media/v4l2-common.h>
@@ -1917,11 +1918,6 @@ static unsigned short tvp5150_addrs[] = {
1917 I2C_CLIENT_END 1918 I2C_CLIENT_END
1918}; 1919};
1919 1920
1920static unsigned short mt9v011_addrs[] = {
1921 0xba >> 1,
1922 I2C_CLIENT_END
1923};
1924
1925static unsigned short msp3400_addrs[] = { 1921static unsigned short msp3400_addrs[] = {
1926 0x80 >> 1, 1922 0x80 >> 1,
1927 0x88 >> 1, 1923 0x88 >> 1,
@@ -2437,6 +2433,7 @@ void em28xx_register_i2c_ir(struct em28xx *dev)
2437 dev->init_data.ir_codes = RC_MAP_RC5_HAUPPAUGE_NEW; 2433 dev->init_data.ir_codes = RC_MAP_RC5_HAUPPAUGE_NEW;
2438 dev->init_data.get_key = em28xx_get_key_em_haup; 2434 dev->init_data.get_key = em28xx_get_key_em_haup;
2439 dev->init_data.name = "i2c IR (EM2840 Hauppauge)"; 2435 dev->init_data.name = "i2c IR (EM2840 Hauppauge)";
2436 break;
2440 case EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE: 2437 case EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE:
2441 dev->init_data.ir_codes = RC_MAP_WINFAST_USBII_DELUXE; 2438 dev->init_data.ir_codes = RC_MAP_WINFAST_USBII_DELUXE;
2442 dev->init_data.get_key = em28xx_get_key_winfast_usbii_deluxe; 2439 dev->init_data.get_key = em28xx_get_key_winfast_usbii_deluxe;
@@ -2623,11 +2620,17 @@ void em28xx_card_setup(struct em28xx *dev)
2623 "tvp5150", 0, tvp5150_addrs); 2620 "tvp5150", 0, tvp5150_addrs);
2624 2621
2625 if (dev->em28xx_sensor == EM28XX_MT9V011) { 2622 if (dev->em28xx_sensor == EM28XX_MT9V011) {
2623 struct mt9v011_platform_data pdata;
2624 struct i2c_board_info mt9v011_info = {
2625 .type = "mt9v011",
2626 .addr = 0xba >> 1,
2627 .platform_data = &pdata,
2628 };
2626 struct v4l2_subdev *sd; 2629 struct v4l2_subdev *sd;
2627 2630
2628 sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, 2631 pdata.xtal = dev->sensor_xtal;
2629 &dev->i2c_adap, "mt9v011", 0, mt9v011_addrs); 2632 sd = v4l2_i2c_new_subdev_board(&dev->v4l2_dev, &dev->i2c_adap,
2630 v4l2_subdev_call(sd, core, s_config, 0, &dev->sensor_xtal); 2633 &mt9v011_info, NULL);
2631 } 2634 }
2632 2635
2633 2636
diff --git a/drivers/media/video/et61x251/et61x251.h b/drivers/media/video/et61x251/et61x251.h
index cc77d144df3c..bf66189cb26d 100644
--- a/drivers/media/video/et61x251/et61x251.h
+++ b/drivers/media/video/et61x251/et61x251.h
@@ -59,31 +59,7 @@
59/*****************************************************************************/ 59/*****************************************************************************/
60 60
61static const struct usb_device_id et61x251_id_table[] = { 61static const struct usb_device_id et61x251_id_table[] = {
62 { USB_DEVICE(0x102c, 0x6151), },
63 { USB_DEVICE(0x102c, 0x6251), }, 62 { USB_DEVICE(0x102c, 0x6251), },
64 { USB_DEVICE(0x102c, 0x6253), },
65 { USB_DEVICE(0x102c, 0x6254), },
66 { USB_DEVICE(0x102c, 0x6255), },
67 { USB_DEVICE(0x102c, 0x6256), },
68 { USB_DEVICE(0x102c, 0x6257), },
69 { USB_DEVICE(0x102c, 0x6258), },
70 { USB_DEVICE(0x102c, 0x6259), },
71 { USB_DEVICE(0x102c, 0x625a), },
72 { USB_DEVICE(0x102c, 0x625b), },
73 { USB_DEVICE(0x102c, 0x625c), },
74 { USB_DEVICE(0x102c, 0x625d), },
75 { USB_DEVICE(0x102c, 0x625e), },
76 { USB_DEVICE(0x102c, 0x625f), },
77 { USB_DEVICE(0x102c, 0x6260), },
78 { USB_DEVICE(0x102c, 0x6261), },
79 { USB_DEVICE(0x102c, 0x6262), },
80 { USB_DEVICE(0x102c, 0x6263), },
81 { USB_DEVICE(0x102c, 0x6264), },
82 { USB_DEVICE(0x102c, 0x6265), },
83 { USB_DEVICE(0x102c, 0x6266), },
84 { USB_DEVICE(0x102c, 0x6267), },
85 { USB_DEVICE(0x102c, 0x6268), },
86 { USB_DEVICE(0x102c, 0x6269), },
87 { } 63 { }
88}; 64};
89 65
diff --git a/drivers/media/video/gspca/benq.c b/drivers/media/video/gspca/benq.c
index 629043933501..a09c4709d613 100644
--- a/drivers/media/video/gspca/benq.c
+++ b/drivers/media/video/gspca/benq.c
@@ -276,7 +276,7 @@ static const struct sd_desc sd_desc = {
276}; 276};
277 277
278/* -- module initialisation -- */ 278/* -- module initialisation -- */
279static const __devinitdata struct usb_device_id device_table[] = { 279static const struct usb_device_id device_table[] = {
280 {USB_DEVICE(0x04a5, 0x3035)}, 280 {USB_DEVICE(0x04a5, 0x3035)},
281 {} 281 {}
282}; 282};
diff --git a/drivers/media/video/gspca/conex.c b/drivers/media/video/gspca/conex.c
index 1eacb6c7926d..8b398493f96b 100644
--- a/drivers/media/video/gspca/conex.c
+++ b/drivers/media/video/gspca/conex.c
@@ -1040,14 +1040,14 @@ static const struct sd_desc sd_desc = {
1040}; 1040};
1041 1041
1042/* -- module initialisation -- */ 1042/* -- module initialisation -- */
1043static const struct usb_device_id device_table[] __devinitconst = { 1043static const struct usb_device_id device_table[] = {
1044 {USB_DEVICE(0x0572, 0x0041)}, 1044 {USB_DEVICE(0x0572, 0x0041)},
1045 {} 1045 {}
1046}; 1046};
1047MODULE_DEVICE_TABLE(usb, device_table); 1047MODULE_DEVICE_TABLE(usb, device_table);
1048 1048
1049/* -- device connect -- */ 1049/* -- device connect -- */
1050static int __devinit sd_probe(struct usb_interface *intf, 1050static int sd_probe(struct usb_interface *intf,
1051 const struct usb_device_id *id) 1051 const struct usb_device_id *id)
1052{ 1052{
1053 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd), 1053 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
diff --git a/drivers/media/video/gspca/cpia1.c b/drivers/media/video/gspca/cpia1.c
index c1ae05f4661f..4bf2cab98d64 100644
--- a/drivers/media/video/gspca/cpia1.c
+++ b/drivers/media/video/gspca/cpia1.c
@@ -2088,7 +2088,7 @@ static const struct sd_desc sd_desc = {
2088}; 2088};
2089 2089
2090/* -- module initialisation -- */ 2090/* -- module initialisation -- */
2091static const __devinitdata struct usb_device_id device_table[] = { 2091static const struct usb_device_id device_table[] = {
2092 {USB_DEVICE(0x0553, 0x0002)}, 2092 {USB_DEVICE(0x0553, 0x0002)},
2093 {USB_DEVICE(0x0813, 0x0001)}, 2093 {USB_DEVICE(0x0813, 0x0001)},
2094 {} 2094 {}
diff --git a/drivers/media/video/gspca/etoms.c b/drivers/media/video/gspca/etoms.c
index a594b36d6199..4b2c483fce6f 100644
--- a/drivers/media/video/gspca/etoms.c
+++ b/drivers/media/video/gspca/etoms.c
@@ -864,7 +864,7 @@ static const struct sd_desc sd_desc = {
864}; 864};
865 865
866/* -- module initialisation -- */ 866/* -- module initialisation -- */
867static const struct usb_device_id device_table[] __devinitconst = { 867static const struct usb_device_id device_table[] = {
868 {USB_DEVICE(0x102c, 0x6151), .driver_info = SENSOR_PAS106}, 868 {USB_DEVICE(0x102c, 0x6151), .driver_info = SENSOR_PAS106},
869#if !defined CONFIG_USB_ET61X251 && !defined CONFIG_USB_ET61X251_MODULE 869#if !defined CONFIG_USB_ET61X251 && !defined CONFIG_USB_ET61X251_MODULE
870 {USB_DEVICE(0x102c, 0x6251), .driver_info = SENSOR_TAS5130CXX}, 870 {USB_DEVICE(0x102c, 0x6251), .driver_info = SENSOR_TAS5130CXX},
@@ -875,7 +875,7 @@ static const struct usb_device_id device_table[] __devinitconst = {
875MODULE_DEVICE_TABLE(usb, device_table); 875MODULE_DEVICE_TABLE(usb, device_table);
876 876
877/* -- device connect -- */ 877/* -- device connect -- */
878static int __devinit sd_probe(struct usb_interface *intf, 878static int sd_probe(struct usb_interface *intf,
879 const struct usb_device_id *id) 879 const struct usb_device_id *id)
880{ 880{
881 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd), 881 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
diff --git a/drivers/media/video/gspca/finepix.c b/drivers/media/video/gspca/finepix.c
index d78226455d1f..987b4b69d7ab 100644
--- a/drivers/media/video/gspca/finepix.c
+++ b/drivers/media/video/gspca/finepix.c
@@ -229,7 +229,7 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
229} 229}
230 230
231/* Table of supported USB devices */ 231/* Table of supported USB devices */
232static const __devinitdata struct usb_device_id device_table[] = { 232static const struct usb_device_id device_table[] = {
233 {USB_DEVICE(0x04cb, 0x0104)}, 233 {USB_DEVICE(0x04cb, 0x0104)},
234 {USB_DEVICE(0x04cb, 0x0109)}, 234 {USB_DEVICE(0x04cb, 0x0109)},
235 {USB_DEVICE(0x04cb, 0x010b)}, 235 {USB_DEVICE(0x04cb, 0x010b)},
diff --git a/drivers/media/video/gspca/gl860/gl860.c b/drivers/media/video/gspca/gl860/gl860.c
index b05bec7321b5..99083038cec3 100644
--- a/drivers/media/video/gspca/gl860/gl860.c
+++ b/drivers/media/video/gspca/gl860/gl860.c
@@ -488,7 +488,7 @@ static void sd_callback(struct gspca_dev *gspca_dev)
488 488
489/*=================== USB driver structure initialisation ==================*/ 489/*=================== USB driver structure initialisation ==================*/
490 490
491static const __devinitdata struct usb_device_id device_table[] = { 491static const struct usb_device_id device_table[] = {
492 {USB_DEVICE(0x05e3, 0x0503)}, 492 {USB_DEVICE(0x05e3, 0x0503)},
493 {USB_DEVICE(0x05e3, 0xf191)}, 493 {USB_DEVICE(0x05e3, 0xf191)},
494 {} 494 {}
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c
index 442970073e8a..f21f2a258ae0 100644
--- a/drivers/media/video/gspca/gspca.c
+++ b/drivers/media/video/gspca/gspca.c
@@ -55,7 +55,7 @@ MODULE_AUTHOR("Jean-François Moine <http://moinejf.free.fr>");
55MODULE_DESCRIPTION("GSPCA USB Camera Driver"); 55MODULE_DESCRIPTION("GSPCA USB Camera Driver");
56MODULE_LICENSE("GPL"); 56MODULE_LICENSE("GPL");
57 57
58#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 11, 0) 58#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 12, 0)
59 59
60#ifdef GSPCA_DEBUG 60#ifdef GSPCA_DEBUG
61int gspca_debug = D_ERR | D_PROBE; 61int gspca_debug = D_ERR | D_PROBE;
@@ -508,8 +508,8 @@ static int gspca_is_compressed(__u32 format)
508 return 0; 508 return 0;
509} 509}
510 510
511static int frame_alloc(struct gspca_dev *gspca_dev, 511static int frame_alloc(struct gspca_dev *gspca_dev, struct file *file,
512 unsigned int count) 512 enum v4l2_memory memory, unsigned int count)
513{ 513{
514 struct gspca_frame *frame; 514 struct gspca_frame *frame;
515 unsigned int frsz; 515 unsigned int frsz;
@@ -519,7 +519,6 @@ static int frame_alloc(struct gspca_dev *gspca_dev,
519 frsz = gspca_dev->cam.cam_mode[i].sizeimage; 519 frsz = gspca_dev->cam.cam_mode[i].sizeimage;
520 PDEBUG(D_STREAM, "frame alloc frsz: %d", frsz); 520 PDEBUG(D_STREAM, "frame alloc frsz: %d", frsz);
521 frsz = PAGE_ALIGN(frsz); 521 frsz = PAGE_ALIGN(frsz);
522 gspca_dev->frsz = frsz;
523 if (count >= GSPCA_MAX_FRAMES) 522 if (count >= GSPCA_MAX_FRAMES)
524 count = GSPCA_MAX_FRAMES - 1; 523 count = GSPCA_MAX_FRAMES - 1;
525 gspca_dev->frbuf = vmalloc_32(frsz * count); 524 gspca_dev->frbuf = vmalloc_32(frsz * count);
@@ -527,6 +526,9 @@ static int frame_alloc(struct gspca_dev *gspca_dev,
527 err("frame alloc failed"); 526 err("frame alloc failed");
528 return -ENOMEM; 527 return -ENOMEM;
529 } 528 }
529 gspca_dev->capt_file = file;
530 gspca_dev->memory = memory;
531 gspca_dev->frsz = frsz;
530 gspca_dev->nframes = count; 532 gspca_dev->nframes = count;
531 for (i = 0; i < count; i++) { 533 for (i = 0; i < count; i++) {
532 frame = &gspca_dev->frame[i]; 534 frame = &gspca_dev->frame[i];
@@ -535,7 +537,7 @@ static int frame_alloc(struct gspca_dev *gspca_dev,
535 frame->v4l2_buf.flags = 0; 537 frame->v4l2_buf.flags = 0;
536 frame->v4l2_buf.field = V4L2_FIELD_NONE; 538 frame->v4l2_buf.field = V4L2_FIELD_NONE;
537 frame->v4l2_buf.length = frsz; 539 frame->v4l2_buf.length = frsz;
538 frame->v4l2_buf.memory = gspca_dev->memory; 540 frame->v4l2_buf.memory = memory;
539 frame->v4l2_buf.sequence = 0; 541 frame->v4l2_buf.sequence = 0;
540 frame->data = gspca_dev->frbuf + i * frsz; 542 frame->data = gspca_dev->frbuf + i * frsz;
541 frame->v4l2_buf.m.offset = i * frsz; 543 frame->v4l2_buf.m.offset = i * frsz;
@@ -558,6 +560,9 @@ static void frame_free(struct gspca_dev *gspca_dev)
558 gspca_dev->frame[i].data = NULL; 560 gspca_dev->frame[i].data = NULL;
559 } 561 }
560 gspca_dev->nframes = 0; 562 gspca_dev->nframes = 0;
563 gspca_dev->frsz = 0;
564 gspca_dev->capt_file = NULL;
565 gspca_dev->memory = GSPCA_MEMORY_NO;
561} 566}
562 567
563static void destroy_urbs(struct gspca_dev *gspca_dev) 568static void destroy_urbs(struct gspca_dev *gspca_dev)
@@ -1210,29 +1215,15 @@ static void gspca_release(struct video_device *vfd)
1210static int dev_open(struct file *file) 1215static int dev_open(struct file *file)
1211{ 1216{
1212 struct gspca_dev *gspca_dev; 1217 struct gspca_dev *gspca_dev;
1213 int ret;
1214 1218
1215 PDEBUG(D_STREAM, "[%s] open", current->comm); 1219 PDEBUG(D_STREAM, "[%s] open", current->comm);
1216 gspca_dev = (struct gspca_dev *) video_devdata(file); 1220 gspca_dev = (struct gspca_dev *) video_devdata(file);
1217 if (mutex_lock_interruptible(&gspca_dev->queue_lock)) 1221 if (!gspca_dev->present)
1218 return -ERESTARTSYS; 1222 return -ENODEV;
1219 if (!gspca_dev->present) {
1220 ret = -ENODEV;
1221 goto out;
1222 }
1223
1224 if (gspca_dev->users > 4) { /* (arbitrary value) */
1225 ret = -EBUSY;
1226 goto out;
1227 }
1228 1223
1229 /* protect the subdriver against rmmod */ 1224 /* protect the subdriver against rmmod */
1230 if (!try_module_get(gspca_dev->module)) { 1225 if (!try_module_get(gspca_dev->module))
1231 ret = -ENODEV; 1226 return -ENODEV;
1232 goto out;
1233 }
1234
1235 gspca_dev->users++;
1236 1227
1237 file->private_data = gspca_dev; 1228 file->private_data = gspca_dev;
1238#ifdef GSPCA_DEBUG 1229#ifdef GSPCA_DEBUG
@@ -1244,14 +1235,7 @@ static int dev_open(struct file *file)
1244 gspca_dev->vdev.debug &= ~(V4L2_DEBUG_IOCTL 1235 gspca_dev->vdev.debug &= ~(V4L2_DEBUG_IOCTL
1245 | V4L2_DEBUG_IOCTL_ARG); 1236 | V4L2_DEBUG_IOCTL_ARG);
1246#endif 1237#endif
1247 ret = 0; 1238 return 0;
1248out:
1249 mutex_unlock(&gspca_dev->queue_lock);
1250 if (ret != 0)
1251 PDEBUG(D_ERR|D_STREAM, "open failed err %d", ret);
1252 else
1253 PDEBUG(D_STREAM, "open done");
1254 return ret;
1255} 1239}
1256 1240
1257static int dev_close(struct file *file) 1241static int dev_close(struct file *file)
@@ -1261,7 +1245,6 @@ static int dev_close(struct file *file)
1261 PDEBUG(D_STREAM, "[%s] close", current->comm); 1245 PDEBUG(D_STREAM, "[%s] close", current->comm);
1262 if (mutex_lock_interruptible(&gspca_dev->queue_lock)) 1246 if (mutex_lock_interruptible(&gspca_dev->queue_lock))
1263 return -ERESTARTSYS; 1247 return -ERESTARTSYS;
1264 gspca_dev->users--;
1265 1248
1266 /* if the file did the capture, free the streaming resources */ 1249 /* if the file did the capture, free the streaming resources */
1267 if (gspca_dev->capt_file == file) { 1250 if (gspca_dev->capt_file == file) {
@@ -1272,8 +1255,6 @@ static int dev_close(struct file *file)
1272 mutex_unlock(&gspca_dev->usb_lock); 1255 mutex_unlock(&gspca_dev->usb_lock);
1273 } 1256 }
1274 frame_free(gspca_dev); 1257 frame_free(gspca_dev);
1275 gspca_dev->capt_file = NULL;
1276 gspca_dev->memory = GSPCA_MEMORY_NO;
1277 } 1258 }
1278 file->private_data = NULL; 1259 file->private_data = NULL;
1279 module_put(gspca_dev->module); 1260 module_put(gspca_dev->module);
@@ -1516,6 +1497,7 @@ static int vidioc_reqbufs(struct file *file, void *priv,
1516 return -ERESTARTSYS; 1497 return -ERESTARTSYS;
1517 1498
1518 if (gspca_dev->memory != GSPCA_MEMORY_NO 1499 if (gspca_dev->memory != GSPCA_MEMORY_NO
1500 && gspca_dev->memory != GSPCA_MEMORY_READ
1519 && gspca_dev->memory != rb->memory) { 1501 && gspca_dev->memory != rb->memory) {
1520 ret = -EBUSY; 1502 ret = -EBUSY;
1521 goto out; 1503 goto out;
@@ -1544,19 +1526,18 @@ static int vidioc_reqbufs(struct file *file, void *priv,
1544 gspca_stream_off(gspca_dev); 1526 gspca_stream_off(gspca_dev);
1545 mutex_unlock(&gspca_dev->usb_lock); 1527 mutex_unlock(&gspca_dev->usb_lock);
1546 } 1528 }
1529 /* Don't restart the stream when switching from read to mmap mode */
1530 if (gspca_dev->memory == GSPCA_MEMORY_READ)
1531 streaming = 0;
1547 1532
1548 /* free the previous allocated buffers, if any */ 1533 /* free the previous allocated buffers, if any */
1549 if (gspca_dev->nframes != 0) { 1534 if (gspca_dev->nframes != 0)
1550 frame_free(gspca_dev); 1535 frame_free(gspca_dev);
1551 gspca_dev->capt_file = NULL;
1552 }
1553 if (rb->count == 0) /* unrequest */ 1536 if (rb->count == 0) /* unrequest */
1554 goto out; 1537 goto out;
1555 gspca_dev->memory = rb->memory; 1538 ret = frame_alloc(gspca_dev, file, rb->memory, rb->count);
1556 ret = frame_alloc(gspca_dev, rb->count);
1557 if (ret == 0) { 1539 if (ret == 0) {
1558 rb->count = gspca_dev->nframes; 1540 rb->count = gspca_dev->nframes;
1559 gspca_dev->capt_file = file;
1560 if (streaming) 1541 if (streaming)
1561 ret = gspca_init_transfer(gspca_dev); 1542 ret = gspca_init_transfer(gspca_dev);
1562 } 1543 }
@@ -1630,11 +1611,15 @@ static int vidioc_streamoff(struct file *file, void *priv,
1630 1611
1631 if (buf_type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 1612 if (buf_type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1632 return -EINVAL; 1613 return -EINVAL;
1633 if (!gspca_dev->streaming) 1614
1634 return 0;
1635 if (mutex_lock_interruptible(&gspca_dev->queue_lock)) 1615 if (mutex_lock_interruptible(&gspca_dev->queue_lock))
1636 return -ERESTARTSYS; 1616 return -ERESTARTSYS;
1637 1617
1618 if (!gspca_dev->streaming) {
1619 ret = 0;
1620 goto out;
1621 }
1622
1638 /* check the capture file */ 1623 /* check the capture file */
1639 if (gspca_dev->capt_file != file) { 1624 if (gspca_dev->capt_file != file) {
1640 ret = -EBUSY; 1625 ret = -EBUSY;
@@ -1649,6 +1634,8 @@ static int vidioc_streamoff(struct file *file, void *priv,
1649 gspca_dev->usb_err = 0; 1634 gspca_dev->usb_err = 0;
1650 gspca_stream_off(gspca_dev); 1635 gspca_stream_off(gspca_dev);
1651 mutex_unlock(&gspca_dev->usb_lock); 1636 mutex_unlock(&gspca_dev->usb_lock);
1637 /* In case another thread is waiting in dqbuf */
1638 wake_up_interruptible(&gspca_dev->wq);
1652 1639
1653 /* empty the transfer queues */ 1640 /* empty the transfer queues */
1654 atomic_set(&gspca_dev->fr_q, 0); 1641 atomic_set(&gspca_dev->fr_q, 0);
@@ -1827,33 +1814,77 @@ out:
1827 return ret; 1814 return ret;
1828} 1815}
1829 1816
1817static int frame_ready_nolock(struct gspca_dev *gspca_dev, struct file *file,
1818 enum v4l2_memory memory)
1819{
1820 if (!gspca_dev->present)
1821 return -ENODEV;
1822 if (gspca_dev->capt_file != file || gspca_dev->memory != memory ||
1823 !gspca_dev->streaming)
1824 return -EINVAL;
1825
1826 /* check if a frame is ready */
1827 return gspca_dev->fr_o != atomic_read(&gspca_dev->fr_i);
1828}
1829
1830static int frame_ready(struct gspca_dev *gspca_dev, struct file *file,
1831 enum v4l2_memory memory)
1832{
1833 int ret;
1834
1835 if (mutex_lock_interruptible(&gspca_dev->queue_lock))
1836 return -ERESTARTSYS;
1837 ret = frame_ready_nolock(gspca_dev, file, memory);
1838 mutex_unlock(&gspca_dev->queue_lock);
1839 return ret;
1840}
1841
1830/* 1842/*
1831 * wait for a video frame 1843 * dequeue a video buffer
1832 * 1844 *
1833 * If a frame is ready, its index is returned. 1845 * If nonblock_ing is false, block until a buffer is available.
1834 */ 1846 */
1835static int frame_wait(struct gspca_dev *gspca_dev, 1847static int vidioc_dqbuf(struct file *file, void *priv,
1836 int nonblock_ing) 1848 struct v4l2_buffer *v4l2_buf)
1837{ 1849{
1838 int i, ret; 1850 struct gspca_dev *gspca_dev = priv;
1851 struct gspca_frame *frame;
1852 int i, j, ret;
1839 1853
1840 /* check if a frame is ready */ 1854 PDEBUG(D_FRAM, "dqbuf");
1841 i = gspca_dev->fr_o; 1855
1842 if (i == atomic_read(&gspca_dev->fr_i)) { 1856 if (mutex_lock_interruptible(&gspca_dev->queue_lock))
1843 if (nonblock_ing) 1857 return -ERESTARTSYS;
1858
1859 for (;;) {
1860 ret = frame_ready_nolock(gspca_dev, file, v4l2_buf->memory);
1861 if (ret < 0)
1862 goto out;
1863 if (ret > 0)
1864 break;
1865
1866 mutex_unlock(&gspca_dev->queue_lock);
1867
1868 if (file->f_flags & O_NONBLOCK)
1844 return -EAGAIN; 1869 return -EAGAIN;
1845 1870
1846 /* wait till a frame is ready */ 1871 /* wait till a frame is ready */
1847 ret = wait_event_interruptible_timeout(gspca_dev->wq, 1872 ret = wait_event_interruptible_timeout(gspca_dev->wq,
1848 i != atomic_read(&gspca_dev->fr_i) || 1873 frame_ready(gspca_dev, file, v4l2_buf->memory),
1849 !gspca_dev->streaming || !gspca_dev->present,
1850 msecs_to_jiffies(3000)); 1874 msecs_to_jiffies(3000));
1851 if (ret < 0) 1875 if (ret < 0)
1852 return ret; 1876 return ret;
1853 if (ret == 0 || !gspca_dev->streaming || !gspca_dev->present) 1877 if (ret == 0)
1854 return -EIO; 1878 return -EIO;
1879
1880 if (mutex_lock_interruptible(&gspca_dev->queue_lock))
1881 return -ERESTARTSYS;
1855 } 1882 }
1856 1883
1884 i = gspca_dev->fr_o;
1885 j = gspca_dev->fr_queue[i];
1886 frame = &gspca_dev->frame[j];
1887
1857 gspca_dev->fr_o = (i + 1) % GSPCA_MAX_FRAMES; 1888 gspca_dev->fr_o = (i + 1) % GSPCA_MAX_FRAMES;
1858 1889
1859 if (gspca_dev->sd_desc->dq_callback) { 1890 if (gspca_dev->sd_desc->dq_callback) {
@@ -1863,46 +1894,12 @@ static int frame_wait(struct gspca_dev *gspca_dev,
1863 gspca_dev->sd_desc->dq_callback(gspca_dev); 1894 gspca_dev->sd_desc->dq_callback(gspca_dev);
1864 mutex_unlock(&gspca_dev->usb_lock); 1895 mutex_unlock(&gspca_dev->usb_lock);
1865 } 1896 }
1866 return gspca_dev->fr_queue[i];
1867}
1868
1869/*
1870 * dequeue a video buffer
1871 *
1872 * If nonblock_ing is false, block until a buffer is available.
1873 */
1874static int vidioc_dqbuf(struct file *file, void *priv,
1875 struct v4l2_buffer *v4l2_buf)
1876{
1877 struct gspca_dev *gspca_dev = priv;
1878 struct gspca_frame *frame;
1879 int i, ret;
1880
1881 PDEBUG(D_FRAM, "dqbuf");
1882 if (v4l2_buf->memory != gspca_dev->memory)
1883 return -EINVAL;
1884
1885 if (!gspca_dev->present)
1886 return -ENODEV;
1887
1888 /* if not streaming, be sure the application will not loop forever */
1889 if (!(file->f_flags & O_NONBLOCK)
1890 && !gspca_dev->streaming && gspca_dev->users == 1)
1891 return -EINVAL;
1892 1897
1893 /* only the capturing file may dequeue */ 1898 frame->v4l2_buf.flags &= ~V4L2_BUF_FLAG_DONE;
1894 if (gspca_dev->capt_file != file) 1899 memcpy(v4l2_buf, &frame->v4l2_buf, sizeof *v4l2_buf);
1895 return -EINVAL; 1900 PDEBUG(D_FRAM, "dqbuf %d", j);
1896 1901 ret = 0;
1897 /* only one dequeue / read at a time */
1898 if (mutex_lock_interruptible(&gspca_dev->read_lock))
1899 return -ERESTARTSYS;
1900 1902
1901 ret = frame_wait(gspca_dev, file->f_flags & O_NONBLOCK);
1902 if (ret < 0)
1903 goto out;
1904 i = ret; /* frame index */
1905 frame = &gspca_dev->frame[i];
1906 if (gspca_dev->memory == V4L2_MEMORY_USERPTR) { 1903 if (gspca_dev->memory == V4L2_MEMORY_USERPTR) {
1907 if (copy_to_user((__u8 __user *) frame->v4l2_buf.m.userptr, 1904 if (copy_to_user((__u8 __user *) frame->v4l2_buf.m.userptr,
1908 frame->data, 1905 frame->data,
@@ -1910,15 +1907,10 @@ static int vidioc_dqbuf(struct file *file, void *priv,
1910 PDEBUG(D_ERR|D_STREAM, 1907 PDEBUG(D_ERR|D_STREAM,
1911 "dqbuf cp to user failed"); 1908 "dqbuf cp to user failed");
1912 ret = -EFAULT; 1909 ret = -EFAULT;
1913 goto out;
1914 } 1910 }
1915 } 1911 }
1916 frame->v4l2_buf.flags &= ~V4L2_BUF_FLAG_DONE;
1917 memcpy(v4l2_buf, &frame->v4l2_buf, sizeof *v4l2_buf);
1918 PDEBUG(D_FRAM, "dqbuf %d", i);
1919 ret = 0;
1920out: 1912out:
1921 mutex_unlock(&gspca_dev->read_lock); 1913 mutex_unlock(&gspca_dev->queue_lock);
1922 return ret; 1914 return ret;
1923} 1915}
1924 1916
@@ -2033,9 +2025,7 @@ static unsigned int dev_poll(struct file *file, poll_table *wait)
2033 poll_wait(file, &gspca_dev->wq, wait); 2025 poll_wait(file, &gspca_dev->wq, wait);
2034 2026
2035 /* if reqbufs is not done, the user would use read() */ 2027 /* if reqbufs is not done, the user would use read() */
2036 if (gspca_dev->nframes == 0) { 2028 if (gspca_dev->memory == GSPCA_MEMORY_NO) {
2037 if (gspca_dev->memory != GSPCA_MEMORY_NO)
2038 return POLLERR; /* not the 1st time */
2039 ret = read_alloc(gspca_dev, file); 2029 ret = read_alloc(gspca_dev, file);
2040 if (ret != 0) 2030 if (ret != 0)
2041 return POLLERR; 2031 return POLLERR;
@@ -2067,18 +2057,10 @@ static ssize_t dev_read(struct file *file, char __user *data,
2067 PDEBUG(D_FRAM, "read (%zd)", count); 2057 PDEBUG(D_FRAM, "read (%zd)", count);
2068 if (!gspca_dev->present) 2058 if (!gspca_dev->present)
2069 return -ENODEV; 2059 return -ENODEV;
2070 switch (gspca_dev->memory) { 2060 if (gspca_dev->memory == GSPCA_MEMORY_NO) { /* first time ? */
2071 case GSPCA_MEMORY_NO: /* first time */
2072 ret = read_alloc(gspca_dev, file); 2061 ret = read_alloc(gspca_dev, file);
2073 if (ret != 0) 2062 if (ret != 0)
2074 return ret; 2063 return ret;
2075 break;
2076 case GSPCA_MEMORY_READ:
2077 if (gspca_dev->capt_file == file)
2078 break;
2079 /* fall thru */
2080 default:
2081 return -EINVAL;
2082 } 2064 }
2083 2065
2084 /* get a frame */ 2066 /* get a frame */
@@ -2266,7 +2248,6 @@ int gspca_dev_probe2(struct usb_interface *intf,
2266 goto out; 2248 goto out;
2267 2249
2268 mutex_init(&gspca_dev->usb_lock); 2250 mutex_init(&gspca_dev->usb_lock);
2269 mutex_init(&gspca_dev->read_lock);
2270 mutex_init(&gspca_dev->queue_lock); 2251 mutex_init(&gspca_dev->queue_lock);
2271 init_waitqueue_head(&gspca_dev->wq); 2252 init_waitqueue_head(&gspca_dev->wq);
2272 2253
@@ -2341,12 +2322,11 @@ void gspca_disconnect(struct usb_interface *intf)
2341 PDEBUG(D_PROBE, "%s disconnect", 2322 PDEBUG(D_PROBE, "%s disconnect",
2342 video_device_node_name(&gspca_dev->vdev)); 2323 video_device_node_name(&gspca_dev->vdev));
2343 mutex_lock(&gspca_dev->usb_lock); 2324 mutex_lock(&gspca_dev->usb_lock);
2325
2344 gspca_dev->present = 0; 2326 gspca_dev->present = 0;
2327 wake_up_interruptible(&gspca_dev->wq);
2345 2328
2346 if (gspca_dev->streaming) { 2329 destroy_urbs(gspca_dev);
2347 destroy_urbs(gspca_dev);
2348 wake_up_interruptible(&gspca_dev->wq);
2349 }
2350 2330
2351#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) 2331#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
2352 gspca_input_destroy_urb(gspca_dev); 2332 gspca_input_destroy_urb(gspca_dev);
diff --git a/drivers/media/video/gspca/gspca.h b/drivers/media/video/gspca/gspca.h
index 97b77a26a2eb..41755226d389 100644
--- a/drivers/media/video/gspca/gspca.h
+++ b/drivers/media/video/gspca/gspca.h
@@ -205,14 +205,12 @@ struct gspca_dev {
205 205
206 wait_queue_head_t wq; /* wait queue */ 206 wait_queue_head_t wq; /* wait queue */
207 struct mutex usb_lock; /* usb exchange protection */ 207 struct mutex usb_lock; /* usb exchange protection */
208 struct mutex read_lock; /* read protection */
209 struct mutex queue_lock; /* ISOC queue protection */ 208 struct mutex queue_lock; /* ISOC queue protection */
210 int usb_err; /* USB error - protected by usb_lock */ 209 int usb_err; /* USB error - protected by usb_lock */
211 u16 pkt_size; /* ISOC packet size */ 210 u16 pkt_size; /* ISOC packet size */
212#ifdef CONFIG_PM 211#ifdef CONFIG_PM
213 char frozen; /* suspend - resume */ 212 char frozen; /* suspend - resume */
214#endif 213#endif
215 char users; /* number of opens */
216 char present; /* device connected */ 214 char present; /* device connected */
217 char nbufread; /* number of buffers for read() */ 215 char nbufread; /* number of buffers for read() */
218 char memory; /* memory type (V4L2_MEMORY_xxx) */ 216 char memory; /* memory type (V4L2_MEMORY_xxx) */
diff --git a/drivers/media/video/gspca/jeilinj.c b/drivers/media/video/gspca/jeilinj.c
index a35e87bb0388..06b777f5379e 100644
--- a/drivers/media/video/gspca/jeilinj.c
+++ b/drivers/media/video/gspca/jeilinj.c
@@ -314,7 +314,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
314} 314}
315 315
316/* Table of supported USB devices */ 316/* Table of supported USB devices */
317static const __devinitdata struct usb_device_id device_table[] = { 317static const struct usb_device_id device_table[] = {
318 {USB_DEVICE(0x0979, 0x0280)}, 318 {USB_DEVICE(0x0979, 0x0280)},
319 {} 319 {}
320}; 320};
diff --git a/drivers/media/video/gspca/jpeg.h b/drivers/media/video/gspca/jpeg.h
index de63c36806c0..ab54910418b4 100644
--- a/drivers/media/video/gspca/jpeg.h
+++ b/drivers/media/video/gspca/jpeg.h
@@ -141,9 +141,9 @@ static void jpeg_define(u8 *jpeg_hdr,
141 memcpy(jpeg_hdr, jpeg_head, sizeof jpeg_head); 141 memcpy(jpeg_hdr, jpeg_head, sizeof jpeg_head);
142#ifndef CONEX_CAM 142#ifndef CONEX_CAM
143 jpeg_hdr[JPEG_HEIGHT_OFFSET + 0] = height >> 8; 143 jpeg_hdr[JPEG_HEIGHT_OFFSET + 0] = height >> 8;
144 jpeg_hdr[JPEG_HEIGHT_OFFSET + 1] = height & 0xff; 144 jpeg_hdr[JPEG_HEIGHT_OFFSET + 1] = height;
145 jpeg_hdr[JPEG_HEIGHT_OFFSET + 2] = width >> 8; 145 jpeg_hdr[JPEG_HEIGHT_OFFSET + 2] = width >> 8;
146 jpeg_hdr[JPEG_HEIGHT_OFFSET + 3] = width & 0xff; 146 jpeg_hdr[JPEG_HEIGHT_OFFSET + 3] = width;
147 jpeg_hdr[JPEG_HEIGHT_OFFSET + 6] = samplesY; 147 jpeg_hdr[JPEG_HEIGHT_OFFSET + 6] = samplesY;
148#endif 148#endif
149} 149}
diff --git a/drivers/media/video/gspca/konica.c b/drivers/media/video/gspca/konica.c
index d2ce65dcbfdc..5964691c0e95 100644
--- a/drivers/media/video/gspca/konica.c
+++ b/drivers/media/video/gspca/konica.c
@@ -607,7 +607,7 @@ static const struct sd_desc sd_desc = {
607}; 607};
608 608
609/* -- module initialisation -- */ 609/* -- module initialisation -- */
610static const __devinitdata struct usb_device_id device_table[] = { 610static const struct usb_device_id device_table[] = {
611 {USB_DEVICE(0x04c8, 0x0720)}, /* Intel YC 76 */ 611 {USB_DEVICE(0x04c8, 0x0720)}, /* Intel YC 76 */
612 {} 612 {}
613}; 613};
diff --git a/drivers/media/video/gspca/m5602/m5602_core.c b/drivers/media/video/gspca/m5602/m5602_core.c
index c872b93a3351..a7722b1aef9b 100644
--- a/drivers/media/video/gspca/m5602/m5602_core.c
+++ b/drivers/media/video/gspca/m5602/m5602_core.c
@@ -28,7 +28,7 @@ int force_sensor;
28static int dump_bridge; 28static int dump_bridge;
29int dump_sensor; 29int dump_sensor;
30 30
31static const __devinitdata struct usb_device_id m5602_table[] = { 31static const struct usb_device_id m5602_table[] = {
32 {USB_DEVICE(0x0402, 0x5602)}, 32 {USB_DEVICE(0x0402, 0x5602)},
33 {} 33 {}
34}; 34};
diff --git a/drivers/media/video/gspca/mars.c b/drivers/media/video/gspca/mars.c
index a81536e78698..cb4d0bf0d784 100644
--- a/drivers/media/video/gspca/mars.c
+++ b/drivers/media/video/gspca/mars.c
@@ -490,7 +490,7 @@ static const struct sd_desc sd_desc = {
490}; 490};
491 491
492/* -- module initialisation -- */ 492/* -- module initialisation -- */
493static const __devinitdata struct usb_device_id device_table[] = { 493static const struct usb_device_id device_table[] = {
494 {USB_DEVICE(0x093a, 0x050f)}, 494 {USB_DEVICE(0x093a, 0x050f)},
495 {} 495 {}
496}; 496};
diff --git a/drivers/media/video/gspca/mr97310a.c b/drivers/media/video/gspca/mr97310a.c
index 7607a288b51c..3884c9d300c5 100644
--- a/drivers/media/video/gspca/mr97310a.c
+++ b/drivers/media/video/gspca/mr97310a.c
@@ -1229,7 +1229,7 @@ static const struct sd_desc sd_desc = {
1229}; 1229};
1230 1230
1231/* -- module initialisation -- */ 1231/* -- module initialisation -- */
1232static const __devinitdata struct usb_device_id device_table[] = { 1232static const struct usb_device_id device_table[] = {
1233 {USB_DEVICE(0x08ca, 0x0110)}, /* Trust Spyc@m 100 */ 1233 {USB_DEVICE(0x08ca, 0x0110)}, /* Trust Spyc@m 100 */
1234 {USB_DEVICE(0x08ca, 0x0111)}, /* Aiptek Pencam VGA+ */ 1234 {USB_DEVICE(0x08ca, 0x0111)}, /* Aiptek Pencam VGA+ */
1235 {USB_DEVICE(0x093a, 0x010f)}, /* All other known MR97310A VGA cams */ 1235 {USB_DEVICE(0x093a, 0x010f)}, /* All other known MR97310A VGA cams */
diff --git a/drivers/media/video/gspca/ov519.c b/drivers/media/video/gspca/ov519.c
index e1c3b9328ace..8ab2c452c25e 100644
--- a/drivers/media/video/gspca/ov519.c
+++ b/drivers/media/video/gspca/ov519.c
@@ -488,7 +488,6 @@ static const struct v4l2_pix_format ovfx2_ov3610_mode[] = {
488#define R511_SNAP_PXDIV 0x1c 488#define R511_SNAP_PXDIV 0x1c
489#define R511_SNAP_LNDIV 0x1d 489#define R511_SNAP_LNDIV 0x1d
490#define R511_SNAP_UV_EN 0x1e 490#define R511_SNAP_UV_EN 0x1e
491#define R511_SNAP_UV_EN 0x1e
492#define R511_SNAP_OPTS 0x1f 491#define R511_SNAP_OPTS 0x1f
493 492
494#define R511_DRAM_FLOW_CTL 0x20 493#define R511_DRAM_FLOW_CTL 0x20
@@ -1847,8 +1846,7 @@ static const struct ov_i2c_regvals norm_7670[] = {
1847 { 0x6c, 0x0a }, 1846 { 0x6c, 0x0a },
1848 { 0x6d, 0x55 }, 1847 { 0x6d, 0x55 },
1849 { 0x6e, 0x11 }, 1848 { 0x6e, 0x11 },
1850 { 0x6f, 0x9f }, 1849 { 0x6f, 0x9f }, /* "9e for advance AWB" */
1851 /* "9e for advance AWB" */
1852 { 0x6a, 0x40 }, 1850 { 0x6a, 0x40 },
1853 { OV7670_R01_BLUE, 0x40 }, 1851 { OV7670_R01_BLUE, 0x40 },
1854 { OV7670_R02_RED, 0x60 }, 1852 { OV7670_R02_RED, 0x60 },
@@ -3054,7 +3052,7 @@ static void ov519_configure(struct sd *sd)
3054{ 3052{
3055 static const struct ov_regvals init_519[] = { 3053 static const struct ov_regvals init_519[] = {
3056 { 0x5a, 0x6d }, /* EnableSystem */ 3054 { 0x5a, 0x6d }, /* EnableSystem */
3057 { 0x53, 0x9b }, 3055 { 0x53, 0x9b }, /* don't enable the microcontroller */
3058 { OV519_R54_EN_CLK1, 0xff }, /* set bit2 to enable jpeg */ 3056 { OV519_R54_EN_CLK1, 0xff }, /* set bit2 to enable jpeg */
3059 { 0x5d, 0x03 }, 3057 { 0x5d, 0x03 },
3060 { 0x49, 0x01 }, 3058 { 0x49, 0x01 },
@@ -4747,7 +4745,7 @@ static const struct sd_desc sd_desc = {
4747}; 4745};
4748 4746
4749/* -- module initialisation -- */ 4747/* -- module initialisation -- */
4750static const __devinitdata struct usb_device_id device_table[] = { 4748static const struct usb_device_id device_table[] = {
4751 {USB_DEVICE(0x041e, 0x4003), .driver_info = BRIDGE_W9968CF }, 4749 {USB_DEVICE(0x041e, 0x4003), .driver_info = BRIDGE_W9968CF },
4752 {USB_DEVICE(0x041e, 0x4052), .driver_info = BRIDGE_OV519 }, 4750 {USB_DEVICE(0x041e, 0x4052), .driver_info = BRIDGE_OV519 },
4753 {USB_DEVICE(0x041e, 0x405f), .driver_info = BRIDGE_OV519 }, 4751 {USB_DEVICE(0x041e, 0x405f), .driver_info = BRIDGE_OV519 },
diff --git a/drivers/media/video/gspca/ov534.c b/drivers/media/video/gspca/ov534.c
index 0edf93973b1c..04da22802736 100644
--- a/drivers/media/video/gspca/ov534.c
+++ b/drivers/media/video/gspca/ov534.c
@@ -479,15 +479,20 @@ static void ov534_reg_write(struct gspca_dev *gspca_dev, u16 reg, u8 val)
479 struct usb_device *udev = gspca_dev->dev; 479 struct usb_device *udev = gspca_dev->dev;
480 int ret; 480 int ret;
481 481
482 PDEBUG(D_USBO, "reg=0x%04x, val=0%02x", reg, val); 482 if (gspca_dev->usb_err < 0)
483 return;
484
485 PDEBUG(D_USBO, "SET 01 0000 %04x %02x", reg, val);
483 gspca_dev->usb_buf[0] = val; 486 gspca_dev->usb_buf[0] = val;
484 ret = usb_control_msg(udev, 487 ret = usb_control_msg(udev,
485 usb_sndctrlpipe(udev, 0), 488 usb_sndctrlpipe(udev, 0),
486 0x01, 489 0x01,
487 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 490 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
488 0x00, reg, gspca_dev->usb_buf, 1, CTRL_TIMEOUT); 491 0x00, reg, gspca_dev->usb_buf, 1, CTRL_TIMEOUT);
489 if (ret < 0) 492 if (ret < 0) {
490 err("write failed %d", ret); 493 err("write failed %d", ret);
494 gspca_dev->usb_err = ret;
495 }
491} 496}
492 497
493static u8 ov534_reg_read(struct gspca_dev *gspca_dev, u16 reg) 498static u8 ov534_reg_read(struct gspca_dev *gspca_dev, u16 reg)
@@ -495,14 +500,18 @@ static u8 ov534_reg_read(struct gspca_dev *gspca_dev, u16 reg)
495 struct usb_device *udev = gspca_dev->dev; 500 struct usb_device *udev = gspca_dev->dev;
496 int ret; 501 int ret;
497 502
503 if (gspca_dev->usb_err < 0)
504 return 0;
498 ret = usb_control_msg(udev, 505 ret = usb_control_msg(udev,
499 usb_rcvctrlpipe(udev, 0), 506 usb_rcvctrlpipe(udev, 0),
500 0x01, 507 0x01,
501 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 508 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
502 0x00, reg, gspca_dev->usb_buf, 1, CTRL_TIMEOUT); 509 0x00, reg, gspca_dev->usb_buf, 1, CTRL_TIMEOUT);
503 PDEBUG(D_USBI, "reg=0x%04x, data=0x%02x", reg, gspca_dev->usb_buf[0]); 510 PDEBUG(D_USBI, "GET 01 0000 %04x %02x", reg, gspca_dev->usb_buf[0]);
504 if (ret < 0) 511 if (ret < 0) {
505 err("read failed %d", ret); 512 err("read failed %d", ret);
513 gspca_dev->usb_err = ret;
514 }
506 return gspca_dev->usb_buf[0]; 515 return gspca_dev->usb_buf[0];
507} 516}
508 517
@@ -558,13 +567,15 @@ static int sccb_check_status(struct gspca_dev *gspca_dev)
558 567
559static void sccb_reg_write(struct gspca_dev *gspca_dev, u8 reg, u8 val) 568static void sccb_reg_write(struct gspca_dev *gspca_dev, u8 reg, u8 val)
560{ 569{
561 PDEBUG(D_USBO, "reg: 0x%02x, val: 0x%02x", reg, val); 570 PDEBUG(D_USBO, "sccb write: %02x %02x", reg, val);
562 ov534_reg_write(gspca_dev, OV534_REG_SUBADDR, reg); 571 ov534_reg_write(gspca_dev, OV534_REG_SUBADDR, reg);
563 ov534_reg_write(gspca_dev, OV534_REG_WRITE, val); 572 ov534_reg_write(gspca_dev, OV534_REG_WRITE, val);
564 ov534_reg_write(gspca_dev, OV534_REG_OPERATION, OV534_OP_WRITE_3); 573 ov534_reg_write(gspca_dev, OV534_REG_OPERATION, OV534_OP_WRITE_3);
565 574
566 if (!sccb_check_status(gspca_dev)) 575 if (!sccb_check_status(gspca_dev)) {
567 err("sccb_reg_write failed"); 576 err("sccb_reg_write failed");
577 gspca_dev->usb_err = -EIO;
578 }
568} 579}
569 580
570static u8 sccb_reg_read(struct gspca_dev *gspca_dev, u16 reg) 581static u8 sccb_reg_read(struct gspca_dev *gspca_dev, u16 reg)
@@ -885,7 +896,7 @@ static int sd_init(struct gspca_dev *gspca_dev)
885 ov534_set_led(gspca_dev, 0); 896 ov534_set_led(gspca_dev, 0);
886 set_frame_rate(gspca_dev); 897 set_frame_rate(gspca_dev);
887 898
888 return 0; 899 return gspca_dev->usb_err;
889} 900}
890 901
891static int sd_start(struct gspca_dev *gspca_dev) 902static int sd_start(struct gspca_dev *gspca_dev)
@@ -920,7 +931,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
920 931
921 ov534_set_led(gspca_dev, 1); 932 ov534_set_led(gspca_dev, 1);
922 ov534_reg_write(gspca_dev, 0xe0, 0x00); 933 ov534_reg_write(gspca_dev, 0xe0, 0x00);
923 return 0; 934 return gspca_dev->usb_err;
924} 935}
925 936
926static void sd_stopN(struct gspca_dev *gspca_dev) 937static void sd_stopN(struct gspca_dev *gspca_dev)
@@ -1289,7 +1300,7 @@ static const struct sd_desc sd_desc = {
1289}; 1300};
1290 1301
1291/* -- module initialisation -- */ 1302/* -- module initialisation -- */
1292static const __devinitdata struct usb_device_id device_table[] = { 1303static const struct usb_device_id device_table[] = {
1293 {USB_DEVICE(0x1415, 0x2000)}, 1304 {USB_DEVICE(0x1415, 0x2000)},
1294 {} 1305 {}
1295}; 1306};
diff --git a/drivers/media/video/gspca/ov534_9.c b/drivers/media/video/gspca/ov534_9.c
index c5244b4b4777..aaf5428c57f5 100644
--- a/drivers/media/video/gspca/ov534_9.c
+++ b/drivers/media/video/gspca/ov534_9.c
@@ -1429,7 +1429,7 @@ static const struct sd_desc sd_desc = {
1429}; 1429};
1430 1430
1431/* -- module initialisation -- */ 1431/* -- module initialisation -- */
1432static const __devinitdata struct usb_device_id device_table[] = { 1432static const struct usb_device_id device_table[] = {
1433 {USB_DEVICE(0x06f8, 0x3003)}, 1433 {USB_DEVICE(0x06f8, 0x3003)},
1434 {} 1434 {}
1435}; 1435};
diff --git a/drivers/media/video/gspca/pac207.c b/drivers/media/video/gspca/pac207.c
index 96f9986305b4..81739a2f205e 100644
--- a/drivers/media/video/gspca/pac207.c
+++ b/drivers/media/video/gspca/pac207.c
@@ -530,7 +530,7 @@ static const struct sd_desc sd_desc = {
530}; 530};
531 531
532/* -- module initialisation -- */ 532/* -- module initialisation -- */
533static const __devinitdata struct usb_device_id device_table[] = { 533static const struct usb_device_id device_table[] = {
534 {USB_DEVICE(0x041e, 0x4028)}, 534 {USB_DEVICE(0x041e, 0x4028)},
535 {USB_DEVICE(0x093a, 0x2460)}, 535 {USB_DEVICE(0x093a, 0x2460)},
536 {USB_DEVICE(0x093a, 0x2461)}, 536 {USB_DEVICE(0x093a, 0x2461)},
diff --git a/drivers/media/video/gspca/pac7302.c b/drivers/media/video/gspca/pac7302.c
index 2700975abce5..5615d7bd8304 100644
--- a/drivers/media/video/gspca/pac7302.c
+++ b/drivers/media/video/gspca/pac7302.c
@@ -1184,7 +1184,7 @@ static const struct sd_desc sd_desc = {
1184}; 1184};
1185 1185
1186/* -- module initialisation -- */ 1186/* -- module initialisation -- */
1187static const struct usb_device_id device_table[] __devinitconst = { 1187static const struct usb_device_id device_table[] = {
1188 {USB_DEVICE(0x06f8, 0x3009)}, 1188 {USB_DEVICE(0x06f8, 0x3009)},
1189 {USB_DEVICE(0x093a, 0x2620)}, 1189 {USB_DEVICE(0x093a, 0x2620)},
1190 {USB_DEVICE(0x093a, 0x2621)}, 1190 {USB_DEVICE(0x093a, 0x2621)},
@@ -1201,7 +1201,7 @@ static const struct usb_device_id device_table[] __devinitconst = {
1201MODULE_DEVICE_TABLE(usb, device_table); 1201MODULE_DEVICE_TABLE(usb, device_table);
1202 1202
1203/* -- device connect -- */ 1203/* -- device connect -- */
1204static int __devinit sd_probe(struct usb_interface *intf, 1204static int sd_probe(struct usb_interface *intf,
1205 const struct usb_device_id *id) 1205 const struct usb_device_id *id)
1206{ 1206{
1207 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd), 1207 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
diff --git a/drivers/media/video/gspca/pac7311.c b/drivers/media/video/gspca/pac7311.c
index 6820f5d58b19..f8801b50e64f 100644
--- a/drivers/media/video/gspca/pac7311.c
+++ b/drivers/media/video/gspca/pac7311.c
@@ -837,7 +837,7 @@ static const struct sd_desc sd_desc = {
837}; 837};
838 838
839/* -- module initialisation -- */ 839/* -- module initialisation -- */
840static const struct usb_device_id device_table[] __devinitconst = { 840static const struct usb_device_id device_table[] = {
841 {USB_DEVICE(0x093a, 0x2600)}, 841 {USB_DEVICE(0x093a, 0x2600)},
842 {USB_DEVICE(0x093a, 0x2601)}, 842 {USB_DEVICE(0x093a, 0x2601)},
843 {USB_DEVICE(0x093a, 0x2603)}, 843 {USB_DEVICE(0x093a, 0x2603)},
@@ -849,7 +849,7 @@ static const struct usb_device_id device_table[] __devinitconst = {
849MODULE_DEVICE_TABLE(usb, device_table); 849MODULE_DEVICE_TABLE(usb, device_table);
850 850
851/* -- device connect -- */ 851/* -- device connect -- */
852static int __devinit sd_probe(struct usb_interface *intf, 852static int sd_probe(struct usb_interface *intf,
853 const struct usb_device_id *id) 853 const struct usb_device_id *id)
854{ 854{
855 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd), 855 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
diff --git a/drivers/media/video/gspca/sn9c2028.c b/drivers/media/video/gspca/sn9c2028.c
index 40a06680502d..4271f86dfe01 100644
--- a/drivers/media/video/gspca/sn9c2028.c
+++ b/drivers/media/video/gspca/sn9c2028.c
@@ -703,7 +703,7 @@ static const struct sd_desc sd_desc = {
703}; 703};
704 704
705/* -- module initialisation -- */ 705/* -- module initialisation -- */
706static const __devinitdata struct usb_device_id device_table[] = { 706static const struct usb_device_id device_table[] = {
707 {USB_DEVICE(0x0458, 0x7005)}, /* Genius Smart 300, version 2 */ 707 {USB_DEVICE(0x0458, 0x7005)}, /* Genius Smart 300, version 2 */
708 /* The Genius Smart is untested. I can't find an owner ! */ 708 /* The Genius Smart is untested. I can't find an owner ! */
709 /* {USB_DEVICE(0x0c45, 0x8000)}, DC31VC, Don't know this camera */ 709 /* {USB_DEVICE(0x0c45, 0x8000)}, DC31VC, Don't know this camera */
diff --git a/drivers/media/video/gspca/sn9c20x.c b/drivers/media/video/gspca/sn9c20x.c
index cb08d00d0a31..fcf29897b713 100644
--- a/drivers/media/video/gspca/sn9c20x.c
+++ b/drivers/media/video/gspca/sn9c20x.c
@@ -2470,7 +2470,7 @@ static const struct sd_desc sd_desc = {
2470 | (SENSOR_ ## sensor << 8) \ 2470 | (SENSOR_ ## sensor << 8) \
2471 | (i2c_addr) 2471 | (i2c_addr)
2472 2472
2473static const __devinitdata struct usb_device_id device_table[] = { 2473static const struct usb_device_id device_table[] = {
2474 {USB_DEVICE(0x0c45, 0x6240), SN9C20X(MT9M001, 0x5d, 0)}, 2474 {USB_DEVICE(0x0c45, 0x6240), SN9C20X(MT9M001, 0x5d, 0)},
2475 {USB_DEVICE(0x0c45, 0x6242), SN9C20X(MT9M111, 0x5d, 0)}, 2475 {USB_DEVICE(0x0c45, 0x6242), SN9C20X(MT9M111, 0x5d, 0)},
2476 {USB_DEVICE(0x0c45, 0x6248), SN9C20X(OV9655, 0x30, 0)}, 2476 {USB_DEVICE(0x0c45, 0x6248), SN9C20X(OV9655, 0x30, 0)},
diff --git a/drivers/media/video/gspca/sonixb.c b/drivers/media/video/gspca/sonixb.c
index 73504a3f87b7..c6cd68d66b53 100644
--- a/drivers/media/video/gspca/sonixb.c
+++ b/drivers/media/video/gspca/sonixb.c
@@ -23,8 +23,15 @@
23/* Some documentation on known sonixb registers: 23/* Some documentation on known sonixb registers:
24 24
25Reg Use 25Reg Use
26sn9c101 / sn9c102:
260x10 high nibble red gain low nibble blue gain 270x10 high nibble red gain low nibble blue gain
270x11 low nibble green gain 280x11 low nibble green gain
29sn9c103:
300x05 red gain 0-127
310x06 blue gain 0-127
320x07 green gain 0-127
33all:
340x08-0x0f i2c / 3wire registers
280x12 hstart 350x12 hstart
290x13 vstart 360x13 vstart
300x15 hsize (hsize = register-value * 16) 370x15 hsize (hsize = register-value * 16)
@@ -88,12 +95,9 @@ struct sd {
88typedef const __u8 sensor_init_t[8]; 95typedef const __u8 sensor_init_t[8];
89 96
90struct sensor_data { 97struct sensor_data {
91 const __u8 *bridge_init[2]; 98 const __u8 *bridge_init;
92 int bridge_init_size[2];
93 sensor_init_t *sensor_init; 99 sensor_init_t *sensor_init;
94 int sensor_init_size; 100 int sensor_init_size;
95 sensor_init_t *sensor_bridge_init[2];
96 int sensor_bridge_init_size[2];
97 int flags; 101 int flags;
98 unsigned ctrl_dis; 102 unsigned ctrl_dis;
99 __u8 sensor_addr; 103 __u8 sensor_addr;
@@ -114,7 +118,6 @@ struct sensor_data {
114#define NO_FREQ (1 << FREQ_IDX) 118#define NO_FREQ (1 << FREQ_IDX)
115#define NO_BRIGHTNESS (1 << BRIGHTNESS_IDX) 119#define NO_BRIGHTNESS (1 << BRIGHTNESS_IDX)
116 120
117#define COMP2 0x8f
118#define COMP 0xc7 /* 0x87 //0x07 */ 121#define COMP 0xc7 /* 0x87 //0x07 */
119#define COMP1 0xc9 /* 0x89 //0x09 */ 122#define COMP1 0xc9 /* 0x89 //0x09 */
120 123
@@ -123,15 +126,11 @@ struct sensor_data {
123 126
124#define SYS_CLK 0x04 127#define SYS_CLK 0x04
125 128
126#define SENS(bridge_1, bridge_3, sensor, sensor_1, \ 129#define SENS(bridge, sensor, _flags, _ctrl_dis, _sensor_addr) \
127 sensor_3, _flags, _ctrl_dis, _sensor_addr) \
128{ \ 130{ \
129 .bridge_init = { bridge_1, bridge_3 }, \ 131 .bridge_init = bridge, \
130 .bridge_init_size = { sizeof(bridge_1), sizeof(bridge_3) }, \
131 .sensor_init = sensor, \ 132 .sensor_init = sensor, \
132 .sensor_init_size = sizeof(sensor), \ 133 .sensor_init_size = sizeof(sensor), \
133 .sensor_bridge_init = { sensor_1, sensor_3,}, \
134 .sensor_bridge_init_size = { sizeof(sensor_1), sizeof(sensor_3)}, \
135 .flags = _flags, .ctrl_dis = _ctrl_dis, .sensor_addr = _sensor_addr \ 134 .flags = _flags, .ctrl_dis = _ctrl_dis, .sensor_addr = _sensor_addr \
136} 135}
137 136
@@ -311,7 +310,6 @@ static const __u8 initHv7131d[] = {
311 0x00, 0x00, 310 0x00, 0x00,
312 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 311 0x00, 0x00, 0x00, 0x02, 0x02, 0x00,
313 0x28, 0x1e, 0x60, 0x8e, 0x42, 312 0x28, 0x1e, 0x60, 0x8e, 0x42,
314 0x1d, 0x10, 0x02, 0x03, 0x0f, 0x0c
315}; 313};
316static const __u8 hv7131d_sensor_init[][8] = { 314static const __u8 hv7131d_sensor_init[][8] = {
317 {0xa0, 0x11, 0x01, 0x04, 0x00, 0x00, 0x00, 0x17}, 315 {0xa0, 0x11, 0x01, 0x04, 0x00, 0x00, 0x00, 0x17},
@@ -326,7 +324,6 @@ static const __u8 initHv7131r[] = {
326 0x00, 0x00, 324 0x00, 0x00,
327 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 325 0x00, 0x00, 0x00, 0x02, 0x01, 0x00,
328 0x28, 0x1e, 0x60, 0x8a, 0x20, 326 0x28, 0x1e, 0x60, 0x8a, 0x20,
329 0x1d, 0x10, 0x02, 0x03, 0x0f, 0x0c
330}; 327};
331static const __u8 hv7131r_sensor_init[][8] = { 328static const __u8 hv7131r_sensor_init[][8] = {
332 {0xc0, 0x11, 0x31, 0x38, 0x2a, 0x2e, 0x00, 0x10}, 329 {0xc0, 0x11, 0x31, 0x38, 0x2a, 0x2e, 0x00, 0x10},
@@ -339,7 +336,7 @@ static const __u8 initOv6650[] = {
339 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 336 0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
340 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 337 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
341 0x00, 0x01, 0x01, 0x0a, 0x16, 0x12, 0x68, 0x8b, 338 0x00, 0x01, 0x01, 0x0a, 0x16, 0x12, 0x68, 0x8b,
342 0x10, 0x1d, 0x10, 0x02, 0x02, 0x09, 0x07 339 0x10,
343}; 340};
344static const __u8 ov6650_sensor_init[][8] = { 341static const __u8 ov6650_sensor_init[][8] = {
345 /* Bright, contrast, etc are set through SCBB interface. 342 /* Bright, contrast, etc are set through SCBB interface.
@@ -378,24 +375,13 @@ static const __u8 initOv7630[] = {
378 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* r09 .. r10 */ 375 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* r09 .. r10 */
379 0x00, 0x01, 0x01, 0x0a, /* r11 .. r14 */ 376 0x00, 0x01, 0x01, 0x0a, /* r11 .. r14 */
380 0x28, 0x1e, /* H & V sizes r15 .. r16 */ 377 0x28, 0x1e, /* H & V sizes r15 .. r16 */
381 0x68, COMP2, MCK_INIT1, /* r17 .. r19 */
382 0x1d, 0x10, 0x02, 0x03, 0x0f, 0x0c /* r1a .. r1f */
383};
384static const __u8 initOv7630_3[] = {
385 0x44, 0x44, 0x00, 0x1a, 0x20, 0x20, 0x20, 0x80, /* r01 .. r08 */
386 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* r09 .. r10 */
387 0x00, 0x02, 0x01, 0x0a, /* r11 .. r14 */
388 0x28, 0x1e, /* H & V sizes r15 .. r16 */
389 0x68, 0x8f, MCK_INIT1, /* r17 .. r19 */ 378 0x68, 0x8f, MCK_INIT1, /* r17 .. r19 */
390 0x1d, 0x10, 0x02, 0x03, 0x0f, 0x0c, 0x00, /* r1a .. r20 */
391 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, /* r21 .. r28 */
392 0x90, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0, 0xff /* r29 .. r30 */
393}; 379};
394static const __u8 ov7630_sensor_init[][8] = { 380static const __u8 ov7630_sensor_init[][8] = {
395 {0xa0, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, 381 {0xa0, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10},
396 {0xb0, 0x21, 0x01, 0x77, 0x3a, 0x00, 0x00, 0x10}, 382 {0xb0, 0x21, 0x01, 0x77, 0x3a, 0x00, 0x00, 0x10},
397/* {0xd0, 0x21, 0x12, 0x7c, 0x01, 0x80, 0x34, 0x10}, jfm */ 383/* {0xd0, 0x21, 0x12, 0x7c, 0x01, 0x80, 0x34, 0x10}, jfm */
398 {0xd0, 0x21, 0x12, 0x1c, 0x00, 0x80, 0x34, 0x10}, /* jfm */ 384 {0xd0, 0x21, 0x12, 0x5c, 0x00, 0x80, 0x34, 0x10}, /* jfm */
399 {0xa0, 0x21, 0x1b, 0x04, 0x00, 0x80, 0x34, 0x10}, 385 {0xa0, 0x21, 0x1b, 0x04, 0x00, 0x80, 0x34, 0x10},
400 {0xa0, 0x21, 0x20, 0x44, 0x00, 0x80, 0x34, 0x10}, 386 {0xa0, 0x21, 0x20, 0x44, 0x00, 0x80, 0x34, 0x10},
401 {0xa0, 0x21, 0x23, 0xee, 0x00, 0x80, 0x34, 0x10}, 387 {0xa0, 0x21, 0x23, 0xee, 0x00, 0x80, 0x34, 0x10},
@@ -413,16 +399,11 @@ static const __u8 ov7630_sensor_init[][8] = {
413 {0xd0, 0x21, 0x17, 0x1c, 0xbd, 0x06, 0xf6, 0x10}, 399 {0xd0, 0x21, 0x17, 0x1c, 0xbd, 0x06, 0xf6, 0x10},
414}; 400};
415 401
416static const __u8 ov7630_sensor_init_3[][8] = {
417 {0xa0, 0x21, 0x13, 0x80, 0x00, 0x00, 0x00, 0x10},
418};
419
420static const __u8 initPas106[] = { 402static const __u8 initPas106[] = {
421 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x40, 0x00, 0x00, 0x00, 403 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x40, 0x00, 0x00, 0x00,
422 0x00, 0x00, 404 0x00, 0x00,
423 0x00, 0x00, 0x00, 0x04, 0x01, 0x00, 405 0x00, 0x00, 0x00, 0x04, 0x01, 0x00,
424 0x16, 0x12, 0x24, COMP1, MCK_INIT1, 406 0x16, 0x12, 0x24, COMP1, MCK_INIT1,
425 0x18, 0x10, 0x02, 0x02, 0x09, 0x07
426}; 407};
427/* compression 0x86 mckinit1 0x2b */ 408/* compression 0x86 mckinit1 0x2b */
428 409
@@ -496,7 +477,6 @@ static const __u8 initPas202[] = {
496 0x00, 0x00, 477 0x00, 0x00,
497 0x00, 0x00, 0x00, 0x06, 0x03, 0x0a, 478 0x00, 0x00, 0x00, 0x06, 0x03, 0x0a,
498 0x28, 0x1e, 0x20, 0x89, 0x20, 479 0x28, 0x1e, 0x20, 0x89, 0x20,
499 0x00, 0x00, 0x02, 0x03, 0x0f, 0x0c
500}; 480};
501 481
502/* "Known" PAS202BCB registers: 482/* "Known" PAS202BCB registers:
@@ -537,7 +517,6 @@ static const __u8 initTas5110c[] = {
537 0x00, 0x00, 517 0x00, 0x00,
538 0x00, 0x00, 0x00, 0x45, 0x09, 0x0a, 518 0x00, 0x00, 0x00, 0x45, 0x09, 0x0a,
539 0x16, 0x12, 0x60, 0x86, 0x2b, 519 0x16, 0x12, 0x60, 0x86, 0x2b,
540 0x14, 0x0a, 0x02, 0x02, 0x09, 0x07
541}; 520};
542/* Same as above, except a different hstart */ 521/* Same as above, except a different hstart */
543static const __u8 initTas5110d[] = { 522static const __u8 initTas5110d[] = {
@@ -545,12 +524,19 @@ static const __u8 initTas5110d[] = {
545 0x00, 0x00, 524 0x00, 0x00,
546 0x00, 0x00, 0x00, 0x41, 0x09, 0x0a, 525 0x00, 0x00, 0x00, 0x41, 0x09, 0x0a,
547 0x16, 0x12, 0x60, 0x86, 0x2b, 526 0x16, 0x12, 0x60, 0x86, 0x2b,
548 0x14, 0x0a, 0x02, 0x02, 0x09, 0x07
549}; 527};
550static const __u8 tas5110_sensor_init[][8] = { 528/* tas5110c is 3 wire, tas5110d is 2 wire (regular i2c) */
529static const __u8 tas5110c_sensor_init[][8] = {
551 {0x30, 0x11, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x10}, 530 {0x30, 0x11, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x10},
552 {0x30, 0x11, 0x02, 0x20, 0xa9, 0x00, 0x00, 0x10}, 531 {0x30, 0x11, 0x02, 0x20, 0xa9, 0x00, 0x00, 0x10},
553 {0xa0, 0x61, 0x9a, 0xca, 0x00, 0x00, 0x00, 0x17}, 532};
533/* Known TAS5110D registers
534 * reg02: gain, bit order reversed!! 0 == max gain, 255 == min gain
535 * reg03: bit3: vflip, bit4: ~hflip, bit7: ~gainboost (~ == inverted)
536 * Note: writing reg03 seems to only work when written together with 02
537 */
538static const __u8 tas5110d_sensor_init[][8] = {
539 {0xa0, 0x61, 0x9a, 0xca, 0x00, 0x00, 0x00, 0x17}, /* reset */
554}; 540};
555 541
556static const __u8 initTas5130[] = { 542static const __u8 initTas5130[] = {
@@ -558,7 +544,6 @@ static const __u8 initTas5130[] = {
558 0x00, 0x00, 544 0x00, 0x00,
559 0x00, 0x00, 0x00, 0x68, 0x0c, 0x0a, 545 0x00, 0x00, 0x00, 0x68, 0x0c, 0x0a,
560 0x28, 0x1e, 0x60, COMP, MCK_INIT, 546 0x28, 0x1e, 0x60, COMP, MCK_INIT,
561 0x18, 0x10, 0x04, 0x03, 0x11, 0x0c
562}; 547};
563static const __u8 tas5130_sensor_init[][8] = { 548static const __u8 tas5130_sensor_init[][8] = {
564/* {0x30, 0x11, 0x00, 0x40, 0x47, 0x00, 0x00, 0x10}, 549/* {0x30, 0x11, 0x00, 0x40, 0x47, 0x00, 0x00, 0x10},
@@ -569,21 +554,18 @@ static const __u8 tas5130_sensor_init[][8] = {
569}; 554};
570 555
571static struct sensor_data sensor_data[] = { 556static struct sensor_data sensor_data[] = {
572SENS(initHv7131d, NULL, hv7131d_sensor_init, NULL, NULL, F_GAIN, NO_BRIGHTNESS|NO_FREQ, 0), 557SENS(initHv7131d, hv7131d_sensor_init, F_GAIN, NO_BRIGHTNESS|NO_FREQ, 0),
573SENS(initHv7131r, NULL, hv7131r_sensor_init, NULL, NULL, 0, NO_BRIGHTNESS|NO_EXPO|NO_FREQ, 0), 558SENS(initHv7131r, hv7131r_sensor_init, 0, NO_BRIGHTNESS|NO_EXPO|NO_FREQ, 0),
574SENS(initOv6650, NULL, ov6650_sensor_init, NULL, NULL, F_GAIN|F_SIF, 0, 0x60), 559SENS(initOv6650, ov6650_sensor_init, F_GAIN|F_SIF, 0, 0x60),
575SENS(initOv7630, initOv7630_3, ov7630_sensor_init, NULL, ov7630_sensor_init_3, 560SENS(initOv7630, ov7630_sensor_init, F_GAIN, 0, 0x21),
576 F_GAIN, 0, 0x21), 561SENS(initPas106, pas106_sensor_init, F_GAIN|F_SIF, NO_FREQ, 0),
577SENS(initPas106, NULL, pas106_sensor_init, NULL, NULL, F_GAIN|F_SIF, NO_FREQ, 562SENS(initPas202, pas202_sensor_init, F_GAIN, NO_FREQ, 0),
578 0), 563SENS(initTas5110c, tas5110c_sensor_init, F_GAIN|F_SIF|F_COARSE_EXPO,
579SENS(initPas202, initPas202, pas202_sensor_init, NULL, NULL, F_GAIN, 564 NO_BRIGHTNESS|NO_FREQ, 0),
580 NO_FREQ, 0), 565SENS(initTas5110d, tas5110d_sensor_init, F_GAIN|F_SIF|F_COARSE_EXPO,
581SENS(initTas5110c, NULL, tas5110_sensor_init, NULL, NULL, 566 NO_BRIGHTNESS|NO_FREQ, 0),
582 F_GAIN|F_SIF|F_COARSE_EXPO, NO_BRIGHTNESS|NO_FREQ, 0), 567SENS(initTas5130, tas5130_sensor_init, F_GAIN,
583SENS(initTas5110d, NULL, tas5110_sensor_init, NULL, NULL, 568 NO_BRIGHTNESS|NO_EXPO|NO_FREQ, 0),
584 F_GAIN|F_SIF|F_COARSE_EXPO, NO_BRIGHTNESS|NO_FREQ, 0),
585SENS(initTas5130, NULL, tas5130_sensor_init, NULL, NULL, 0, NO_EXPO|NO_FREQ,
586 0),
587}; 569};
588 570
589/* get one byte in gspca_dev->usb_buf */ 571/* get one byte in gspca_dev->usb_buf */
@@ -655,7 +637,6 @@ static void i2c_w_vector(struct gspca_dev *gspca_dev,
655static void setbrightness(struct gspca_dev *gspca_dev) 637static void setbrightness(struct gspca_dev *gspca_dev)
656{ 638{
657 struct sd *sd = (struct sd *) gspca_dev; 639 struct sd *sd = (struct sd *) gspca_dev;
658 __u8 value;
659 640
660 switch (sd->sensor) { 641 switch (sd->sensor) {
661 case SENSOR_OV6650: 642 case SENSOR_OV6650:
@@ -697,17 +678,6 @@ static void setbrightness(struct gspca_dev *gspca_dev)
697 goto err; 678 goto err;
698 break; 679 break;
699 } 680 }
700 case SENSOR_TAS5130CXX: {
701 __u8 i2c[] =
702 {0x30, 0x11, 0x02, 0x20, 0x70, 0x00, 0x00, 0x10};
703
704 value = 0xff - sd->brightness;
705 i2c[4] = value;
706 PDEBUG(D_CONF, "brightness %d : %d", value, i2c[4]);
707 if (i2c_w(gspca_dev, i2c) < 0)
708 goto err;
709 break;
710 }
711 } 681 }
712 return; 682 return;
713err: 683err:
@@ -733,7 +703,7 @@ static void setsensorgain(struct gspca_dev *gspca_dev)
733 break; 703 break;
734 } 704 }
735 case SENSOR_TAS5110C: 705 case SENSOR_TAS5110C:
736 case SENSOR_TAS5110D: { 706 case SENSOR_TAS5130CXX: {
737 __u8 i2c[] = 707 __u8 i2c[] =
738 {0x30, 0x11, 0x02, 0x20, 0x70, 0x00, 0x00, 0x10}; 708 {0x30, 0x11, 0x02, 0x20, 0x70, 0x00, 0x00, 0x10};
739 709
@@ -742,6 +712,23 @@ static void setsensorgain(struct gspca_dev *gspca_dev)
742 goto err; 712 goto err;
743 break; 713 break;
744 } 714 }
715 case SENSOR_TAS5110D: {
716 __u8 i2c[] = {
717 0xb0, 0x61, 0x02, 0x00, 0x10, 0x00, 0x00, 0x17 };
718 gain = 255 - gain;
719 /* The bits in the register are the wrong way around!! */
720 i2c[3] |= (gain & 0x80) >> 7;
721 i2c[3] |= (gain & 0x40) >> 5;
722 i2c[3] |= (gain & 0x20) >> 3;
723 i2c[3] |= (gain & 0x10) >> 1;
724 i2c[3] |= (gain & 0x08) << 1;
725 i2c[3] |= (gain & 0x04) << 3;
726 i2c[3] |= (gain & 0x02) << 5;
727 i2c[3] |= (gain & 0x01) << 7;
728 if (i2c_w(gspca_dev, i2c) < 0)
729 goto err;
730 break;
731 }
745 732
746 case SENSOR_OV6650: 733 case SENSOR_OV6650:
747 gain >>= 1; 734 gain >>= 1;
@@ -796,7 +783,7 @@ static void setgain(struct gspca_dev *gspca_dev)
796{ 783{
797 struct sd *sd = (struct sd *) gspca_dev; 784 struct sd *sd = (struct sd *) gspca_dev;
798 __u8 gain; 785 __u8 gain;
799 __u8 buf[2] = { 0, 0 }; 786 __u8 buf[3] = { 0, 0, 0 };
800 787
801 if (sensor_data[sd->sensor].flags & F_GAIN) { 788 if (sensor_data[sd->sensor].flags & F_GAIN) {
802 /* Use the sensor gain to do the actual gain */ 789 /* Use the sensor gain to do the actual gain */
@@ -804,13 +791,18 @@ static void setgain(struct gspca_dev *gspca_dev)
804 return; 791 return;
805 } 792 }
806 793
807 gain = sd->gain >> 4; 794 if (sd->bridge == BRIDGE_103) {
808 795 gain = sd->gain >> 1;
809 /* red and blue gain */ 796 buf[0] = gain; /* Red */
810 buf[0] = gain << 4 | gain; 797 buf[1] = gain; /* Green */
811 /* green gain */ 798 buf[2] = gain; /* Blue */
812 buf[1] = gain; 799 reg_w(gspca_dev, 0x05, buf, 3);
813 reg_w(gspca_dev, 0x10, buf, 2); 800 } else {
801 gain = sd->gain >> 4;
802 buf[0] = gain << 4 | gain; /* Red and blue */
803 buf[1] = gain; /* Green */
804 reg_w(gspca_dev, 0x10, buf, 2);
805 }
814} 806}
815 807
816static void setexposure(struct gspca_dev *gspca_dev) 808static void setexposure(struct gspca_dev *gspca_dev)
@@ -1049,7 +1041,7 @@ static void do_autogain(struct gspca_dev *gspca_dev)
1049 desired_avg_lum = 5000; 1041 desired_avg_lum = 5000;
1050 } else { 1042 } else {
1051 deadzone = 1500; 1043 deadzone = 1500;
1052 desired_avg_lum = 18000; 1044 desired_avg_lum = 13000;
1053 } 1045 }
1054 1046
1055 if (sensor_data[sd->sensor].flags & F_COARSE_EXPO) 1047 if (sensor_data[sd->sensor].flags & F_COARSE_EXPO)
@@ -1127,53 +1119,91 @@ static int sd_start(struct gspca_dev *gspca_dev)
1127{ 1119{
1128 struct sd *sd = (struct sd *) gspca_dev; 1120 struct sd *sd = (struct sd *) gspca_dev;
1129 struct cam *cam = &gspca_dev->cam; 1121 struct cam *cam = &gspca_dev->cam;
1130 int mode, l; 1122 int i, mode;
1131 const __u8 *sn9c10x; 1123 __u8 regs[0x31];
1132 __u8 reg12_19[8];
1133 1124
1134 mode = cam->cam_mode[gspca_dev->curr_mode].priv & 0x07; 1125 mode = cam->cam_mode[gspca_dev->curr_mode].priv & 0x07;
1135 sn9c10x = sensor_data[sd->sensor].bridge_init[sd->bridge]; 1126 /* Copy registers 0x01 - 0x19 from the template */
1136 l = sensor_data[sd->sensor].bridge_init_size[sd->bridge]; 1127 memcpy(&regs[0x01], sensor_data[sd->sensor].bridge_init, 0x19);
1137 memcpy(reg12_19, &sn9c10x[0x12 - 1], 8); 1128 /* Set the mode */
1138 reg12_19[6] = sn9c10x[0x18 - 1] | (mode << 4); 1129 regs[0x18] |= mode << 4;
1139 /* Special cases where reg 17 and or 19 value depends on mode */ 1130
1131 /* Set bridge gain to 1.0 */
1132 if (sd->bridge == BRIDGE_103) {
1133 regs[0x05] = 0x20; /* Red */
1134 regs[0x06] = 0x20; /* Green */
1135 regs[0x07] = 0x20; /* Blue */
1136 } else {
1137 regs[0x10] = 0x00; /* Red and blue */
1138 regs[0x11] = 0x00; /* Green */
1139 }
1140
1141 /* Setup pixel numbers and auto exposure window */
1142 if (sensor_data[sd->sensor].flags & F_SIF) {
1143 regs[0x1a] = 0x14; /* HO_SIZE 640, makes no sense */
1144 regs[0x1b] = 0x0a; /* VO_SIZE 320, makes no sense */
1145 regs[0x1c] = 0x02; /* AE H-start 64 */
1146 regs[0x1d] = 0x02; /* AE V-start 64 */
1147 regs[0x1e] = 0x09; /* AE H-end 288 */
1148 regs[0x1f] = 0x07; /* AE V-end 224 */
1149 } else {
1150 regs[0x1a] = 0x1d; /* HO_SIZE 960, makes no sense */
1151 regs[0x1b] = 0x10; /* VO_SIZE 512, makes no sense */
1152 regs[0x1c] = 0x05; /* AE H-start 160 */
1153 regs[0x1d] = 0x03; /* AE V-start 96 */
1154 regs[0x1e] = 0x0f; /* AE H-end 480 */
1155 regs[0x1f] = 0x0c; /* AE V-end 384 */
1156 }
1157
1158 /* Setup the gamma table (only used with the sn9c103 bridge) */
1159 for (i = 0; i < 16; i++)
1160 regs[0x20 + i] = i * 16;
1161 regs[0x20 + i] = 255;
1162
1163 /* Special cases where some regs depend on mode or bridge */
1140 switch (sd->sensor) { 1164 switch (sd->sensor) {
1141 case SENSOR_TAS5130CXX: 1165 case SENSOR_TAS5130CXX:
1142 /* probably not mode specific at all most likely the upper 1166 /* FIXME / TESTME
1167 probably not mode specific at all most likely the upper
1143 nibble of 0x19 is exposure (clock divider) just as with 1168 nibble of 0x19 is exposure (clock divider) just as with
1144 the tas5110, we need someone to test this. */ 1169 the tas5110, we need someone to test this. */
1145 reg12_19[7] = mode ? 0x23 : 0x43; 1170 regs[0x19] = mode ? 0x23 : 0x43;
1146 break; 1171 break;
1172 case SENSOR_OV7630:
1173 /* FIXME / TESTME for some reason with the 101/102 bridge the
1174 clock is set to 12 Mhz (reg1 == 0x04), rather then 24.
1175 Also the hstart needs to go from 1 to 2 when using a 103,
1176 which is likely related. This does not seem right. */
1177 if (sd->bridge == BRIDGE_103) {
1178 regs[0x01] = 0x44; /* Select 24 Mhz clock */
1179 regs[0x12] = 0x02; /* Set hstart to 2 */
1180 }
1147 } 1181 }
1148 /* Disable compression when the raw bayer format has been selected */ 1182 /* Disable compression when the raw bayer format has been selected */
1149 if (cam->cam_mode[gspca_dev->curr_mode].priv & MODE_RAW) 1183 if (cam->cam_mode[gspca_dev->curr_mode].priv & MODE_RAW)
1150 reg12_19[6] &= ~0x80; 1184 regs[0x18] &= ~0x80;
1151 1185
1152 /* Vga mode emulation on SIF sensor? */ 1186 /* Vga mode emulation on SIF sensor? */
1153 if (cam->cam_mode[gspca_dev->curr_mode].priv & MODE_REDUCED_SIF) { 1187 if (cam->cam_mode[gspca_dev->curr_mode].priv & MODE_REDUCED_SIF) {
1154 reg12_19[0] += 16; /* 0x12: hstart adjust */ 1188 regs[0x12] += 16; /* hstart adjust */
1155 reg12_19[1] += 24; /* 0x13: vstart adjust */ 1189 regs[0x13] += 24; /* vstart adjust */
1156 reg12_19[3] = 320 / 16; /* 0x15: hsize */ 1190 regs[0x15] = 320 / 16; /* hsize */
1157 reg12_19[4] = 240 / 16; /* 0x16: vsize */ 1191 regs[0x16] = 240 / 16; /* vsize */
1158 } 1192 }
1159 1193
1160 /* reg 0x01 bit 2 video transfert on */ 1194 /* reg 0x01 bit 2 video transfert on */
1161 reg_w(gspca_dev, 0x01, &sn9c10x[0x01 - 1], 1); 1195 reg_w(gspca_dev, 0x01, &regs[0x01], 1);
1162 /* reg 0x17 SensorClk enable inv Clk 0x60 */ 1196 /* reg 0x17 SensorClk enable inv Clk 0x60 */
1163 reg_w(gspca_dev, 0x17, &sn9c10x[0x17 - 1], 1); 1197 reg_w(gspca_dev, 0x17, &regs[0x17], 1);
1164 /* Set the registers from the template */ 1198 /* Set the registers from the template */
1165 reg_w(gspca_dev, 0x01, sn9c10x, l); 1199 reg_w(gspca_dev, 0x01, &regs[0x01],
1200 (sd->bridge == BRIDGE_103) ? 0x30 : 0x1f);
1166 1201
1167 /* Init the sensor */ 1202 /* Init the sensor */
1168 i2c_w_vector(gspca_dev, sensor_data[sd->sensor].sensor_init, 1203 i2c_w_vector(gspca_dev, sensor_data[sd->sensor].sensor_init,
1169 sensor_data[sd->sensor].sensor_init_size); 1204 sensor_data[sd->sensor].sensor_init_size);
1170 if (sensor_data[sd->sensor].sensor_bridge_init[sd->bridge])
1171 i2c_w_vector(gspca_dev,
1172 sensor_data[sd->sensor].sensor_bridge_init[sd->bridge],
1173 sensor_data[sd->sensor].sensor_bridge_init_size[
1174 sd->bridge]);
1175 1205
1176 /* Mode specific sensor setup */ 1206 /* Mode / bridge specific sensor setup */
1177 switch (sd->sensor) { 1207 switch (sd->sensor) {
1178 case SENSOR_PAS202: { 1208 case SENSOR_PAS202: {
1179 const __u8 i2cpclockdiv[] = 1209 const __u8 i2cpclockdiv[] =
@@ -1181,27 +1211,37 @@ static int sd_start(struct gspca_dev *gspca_dev)
1181 /* clockdiv from 4 to 3 (7.5 -> 10 fps) when in low res mode */ 1211 /* clockdiv from 4 to 3 (7.5 -> 10 fps) when in low res mode */
1182 if (mode) 1212 if (mode)
1183 i2c_w(gspca_dev, i2cpclockdiv); 1213 i2c_w(gspca_dev, i2cpclockdiv);
1214 break;
1184 } 1215 }
1216 case SENSOR_OV7630:
1217 /* FIXME / TESTME We should be able to handle this identical
1218 for the 101/102 and the 103 case */
1219 if (sd->bridge == BRIDGE_103) {
1220 const __u8 i2c[] = { 0xa0, 0x21, 0x13,
1221 0x80, 0x00, 0x00, 0x00, 0x10 };
1222 i2c_w(gspca_dev, i2c);
1223 }
1224 break;
1185 } 1225 }
1186 /* H_size V_size 0x28, 0x1e -> 640x480. 0x16, 0x12 -> 352x288 */ 1226 /* H_size V_size 0x28, 0x1e -> 640x480. 0x16, 0x12 -> 352x288 */
1187 reg_w(gspca_dev, 0x15, &reg12_19[3], 2); 1227 reg_w(gspca_dev, 0x15, &regs[0x15], 2);
1188 /* compression register */ 1228 /* compression register */
1189 reg_w(gspca_dev, 0x18, &reg12_19[6], 1); 1229 reg_w(gspca_dev, 0x18, &regs[0x18], 1);
1190 /* H_start */ 1230 /* H_start */
1191 reg_w(gspca_dev, 0x12, &reg12_19[0], 1); 1231 reg_w(gspca_dev, 0x12, &regs[0x12], 1);
1192 /* V_START */ 1232 /* V_START */
1193 reg_w(gspca_dev, 0x13, &reg12_19[1], 1); 1233 reg_w(gspca_dev, 0x13, &regs[0x13], 1);
1194 /* reset 0x17 SensorClk enable inv Clk 0x60 */ 1234 /* reset 0x17 SensorClk enable inv Clk 0x60 */
1195 /*fixme: ov7630 [17]=68 8f (+20 if 102)*/ 1235 /*fixme: ov7630 [17]=68 8f (+20 if 102)*/
1196 reg_w(gspca_dev, 0x17, &reg12_19[5], 1); 1236 reg_w(gspca_dev, 0x17, &regs[0x17], 1);
1197 /*MCKSIZE ->3 */ /*fixme: not ov7630*/ 1237 /*MCKSIZE ->3 */ /*fixme: not ov7630*/
1198 reg_w(gspca_dev, 0x19, &reg12_19[7], 1); 1238 reg_w(gspca_dev, 0x19, &regs[0x19], 1);
1199 /* AE_STRX AE_STRY AE_ENDX AE_ENDY */ 1239 /* AE_STRX AE_STRY AE_ENDX AE_ENDY */
1200 reg_w(gspca_dev, 0x1c, &sn9c10x[0x1c - 1], 4); 1240 reg_w(gspca_dev, 0x1c, &regs[0x1c], 4);
1201 /* Enable video transfert */ 1241 /* Enable video transfert */
1202 reg_w(gspca_dev, 0x01, &sn9c10x[0], 1); 1242 reg_w(gspca_dev, 0x01, &regs[0x01], 1);
1203 /* Compression */ 1243 /* Compression */
1204 reg_w(gspca_dev, 0x18, &reg12_19[6], 2); 1244 reg_w(gspca_dev, 0x18, &regs[0x18], 2);
1205 msleep(20); 1245 msleep(20);
1206 1246
1207 sd->reg11 = -1; 1247 sd->reg11 = -1;
@@ -1525,15 +1565,15 @@ static const struct sd_desc sd_desc = {
1525 .driver_info = (SENSOR_ ## sensor << 8) | BRIDGE_ ## bridge 1565 .driver_info = (SENSOR_ ## sensor << 8) | BRIDGE_ ## bridge
1526 1566
1527 1567
1528static const struct usb_device_id device_table[] __devinitconst = { 1568static const struct usb_device_id device_table[] = {
1529 {USB_DEVICE(0x0c45, 0x6001), SB(TAS5110C, 102)}, /* TAS5110C1B */ 1569 {USB_DEVICE(0x0c45, 0x6001), SB(TAS5110C, 102)}, /* TAS5110C1B */
1530 {USB_DEVICE(0x0c45, 0x6005), SB(TAS5110C, 101)}, /* TAS5110C1B */ 1570 {USB_DEVICE(0x0c45, 0x6005), SB(TAS5110C, 101)}, /* TAS5110C1B */
1531 {USB_DEVICE(0x0c45, 0x6007), SB(TAS5110D, 101)}, /* TAS5110D */ 1571 {USB_DEVICE(0x0c45, 0x6007), SB(TAS5110D, 101)}, /* TAS5110D */
1532 {USB_DEVICE(0x0c45, 0x6009), SB(PAS106, 101)}, 1572 {USB_DEVICE(0x0c45, 0x6009), SB(PAS106, 101)},
1533 {USB_DEVICE(0x0c45, 0x600d), SB(PAS106, 101)}, 1573 {USB_DEVICE(0x0c45, 0x600d), SB(PAS106, 101)},
1534 {USB_DEVICE(0x0c45, 0x6011), SB(OV6650, 101)}, 1574 {USB_DEVICE(0x0c45, 0x6011), SB(OV6650, 101)},
1535#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
1536 {USB_DEVICE(0x0c45, 0x6019), SB(OV7630, 101)}, 1575 {USB_DEVICE(0x0c45, 0x6019), SB(OV7630, 101)},
1576#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
1537 {USB_DEVICE(0x0c45, 0x6024), SB(TAS5130CXX, 102)}, 1577 {USB_DEVICE(0x0c45, 0x6024), SB(TAS5130CXX, 102)},
1538 {USB_DEVICE(0x0c45, 0x6025), SB(TAS5130CXX, 102)}, 1578 {USB_DEVICE(0x0c45, 0x6025), SB(TAS5130CXX, 102)},
1539#endif 1579#endif
@@ -1544,18 +1584,22 @@ static const struct usb_device_id device_table[] __devinitconst = {
1544 {USB_DEVICE(0x0c45, 0x602c), SB(OV7630, 102)}, 1584 {USB_DEVICE(0x0c45, 0x602c), SB(OV7630, 102)},
1545 {USB_DEVICE(0x0c45, 0x602d), SB(HV7131R, 102)}, 1585 {USB_DEVICE(0x0c45, 0x602d), SB(HV7131R, 102)},
1546 {USB_DEVICE(0x0c45, 0x602e), SB(OV7630, 102)}, 1586 {USB_DEVICE(0x0c45, 0x602e), SB(OV7630, 102)},
1547 /* {USB_DEVICE(0x0c45, 0x602b), SB(MI03XX, 102)}, */ /* MI0343 MI0360 MI0330 */ 1587 /* {USB_DEVICE(0x0c45, 0x6030), SB(MI03XX, 102)}, */ /* MI0343 MI0360 MI0330 */
1588 /* {USB_DEVICE(0x0c45, 0x6082), SB(MI03XX, 103)}, */ /* MI0343 MI0360 */
1589 {USB_DEVICE(0x0c45, 0x6083), SB(HV7131D, 103)},
1590 {USB_DEVICE(0x0c45, 0x608c), SB(HV7131R, 103)},
1591 /* {USB_DEVICE(0x0c45, 0x608e), SB(CISVF10, 103)}, */
1548 {USB_DEVICE(0x0c45, 0x608f), SB(OV7630, 103)}, 1592 {USB_DEVICE(0x0c45, 0x608f), SB(OV7630, 103)},
1549#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE 1593 {USB_DEVICE(0x0c45, 0x60a8), SB(PAS106, 103)},
1594 {USB_DEVICE(0x0c45, 0x60aa), SB(TAS5130CXX, 103)},
1550 {USB_DEVICE(0x0c45, 0x60af), SB(PAS202, 103)}, 1595 {USB_DEVICE(0x0c45, 0x60af), SB(PAS202, 103)},
1551#endif
1552 {USB_DEVICE(0x0c45, 0x60b0), SB(OV7630, 103)}, 1596 {USB_DEVICE(0x0c45, 0x60b0), SB(OV7630, 103)},
1553 {} 1597 {}
1554}; 1598};
1555MODULE_DEVICE_TABLE(usb, device_table); 1599MODULE_DEVICE_TABLE(usb, device_table);
1556 1600
1557/* -- device connect -- */ 1601/* -- device connect -- */
1558static int __devinit sd_probe(struct usb_interface *intf, 1602static int sd_probe(struct usb_interface *intf,
1559 const struct usb_device_id *id) 1603 const struct usb_device_id *id)
1560{ 1604{
1561 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd), 1605 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c
index 2d0bb17a30a2..d6f39ce1b7e1 100644
--- a/drivers/media/video/gspca/sonixj.c
+++ b/drivers/media/video/gspca/sonixj.c
@@ -25,12 +25,12 @@
25#include "gspca.h" 25#include "gspca.h"
26#include "jpeg.h" 26#include "jpeg.h"
27 27
28#define V4L2_CID_INFRARED (V4L2_CID_PRIVATE_BASE + 0)
29
30MODULE_AUTHOR("Jean-François Moine <http://moinejf.free.fr>"); 28MODULE_AUTHOR("Jean-François Moine <http://moinejf.free.fr>");
31MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver"); 29MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver");
32MODULE_LICENSE("GPL"); 30MODULE_LICENSE("GPL");
33 31
32static int starcam;
33
34/* controls */ 34/* controls */
35enum e_ctrl { 35enum e_ctrl {
36 BRIGHTNESS, 36 BRIGHTNESS,
@@ -43,7 +43,7 @@ enum e_ctrl {
43 HFLIP, 43 HFLIP,
44 VFLIP, 44 VFLIP,
45 SHARPNESS, 45 SHARPNESS,
46 INFRARED, 46 ILLUM,
47 FREQ, 47 FREQ,
48 NCTRLS /* number of controls */ 48 NCTRLS /* number of controls */
49}; 49};
@@ -100,7 +100,8 @@ enum sensors {
100}; 100};
101 101
102/* device flags */ 102/* device flags */
103#define PDN_INV 1 /* inverse pin S_PWR_DN / sn_xxx tables */ 103#define F_PDN_INV 0x01 /* inverse pin S_PWR_DN / sn_xxx tables */
104#define F_ILLUM 0x02 /* presence of illuminator */
104 105
105/* sn9c1xx definitions */ 106/* sn9c1xx definitions */
106/* register 0x01 */ 107/* register 0x01 */
@@ -124,7 +125,7 @@ static void setgamma(struct gspca_dev *gspca_dev);
124static void setautogain(struct gspca_dev *gspca_dev); 125static void setautogain(struct gspca_dev *gspca_dev);
125static void sethvflip(struct gspca_dev *gspca_dev); 126static void sethvflip(struct gspca_dev *gspca_dev);
126static void setsharpness(struct gspca_dev *gspca_dev); 127static void setsharpness(struct gspca_dev *gspca_dev);
127static void setinfrared(struct gspca_dev *gspca_dev); 128static void setillum(struct gspca_dev *gspca_dev);
128static void setfreq(struct gspca_dev *gspca_dev); 129static void setfreq(struct gspca_dev *gspca_dev);
129 130
130static const struct ctrl sd_ctrls[NCTRLS] = { 131static const struct ctrl sd_ctrls[NCTRLS] = {
@@ -251,18 +252,17 @@ static const struct ctrl sd_ctrls[NCTRLS] = {
251 }, 252 },
252 .set_control = setsharpness 253 .set_control = setsharpness
253 }, 254 },
254/* mt9v111 only */ 255[ILLUM] = {
255[INFRARED] = {
256 { 256 {
257 .id = V4L2_CID_INFRARED, 257 .id = V4L2_CID_ILLUMINATORS_1,
258 .type = V4L2_CTRL_TYPE_BOOLEAN, 258 .type = V4L2_CTRL_TYPE_BOOLEAN,
259 .name = "Infrared", 259 .name = "Illuminator / infrared",
260 .minimum = 0, 260 .minimum = 0,
261 .maximum = 1, 261 .maximum = 1,
262 .step = 1, 262 .step = 1,
263 .default_value = 0, 263 .default_value = 0,
264 }, 264 },
265 .set_control = setinfrared 265 .set_control = setillum
266 }, 266 },
267/* ov7630/ov7648/ov7660 only */ 267/* ov7630/ov7648/ov7660 only */
268[FREQ] = { 268[FREQ] = {
@@ -282,32 +282,26 @@ static const struct ctrl sd_ctrls[NCTRLS] = {
282/* table of the disabled controls */ 282/* table of the disabled controls */
283static const __u32 ctrl_dis[] = { 283static const __u32 ctrl_dis[] = {
284[SENSOR_ADCM1700] = (1 << AUTOGAIN) | 284[SENSOR_ADCM1700] = (1 << AUTOGAIN) |
285 (1 << INFRARED) |
286 (1 << HFLIP) | 285 (1 << HFLIP) |
287 (1 << VFLIP) | 286 (1 << VFLIP) |
288 (1 << FREQ), 287 (1 << FREQ),
289 288
290[SENSOR_GC0307] = (1 << INFRARED) | 289[SENSOR_GC0307] = (1 << HFLIP) |
291 (1 << HFLIP) |
292 (1 << VFLIP) | 290 (1 << VFLIP) |
293 (1 << FREQ), 291 (1 << FREQ),
294 292
295[SENSOR_HV7131R] = (1 << INFRARED) | 293[SENSOR_HV7131R] = (1 << HFLIP) |
296 (1 << HFLIP) |
297 (1 << FREQ), 294 (1 << FREQ),
298 295
299[SENSOR_MI0360] = (1 << INFRARED) | 296[SENSOR_MI0360] = (1 << HFLIP) |
300 (1 << HFLIP) |
301 (1 << VFLIP) | 297 (1 << VFLIP) |
302 (1 << FREQ), 298 (1 << FREQ),
303 299
304[SENSOR_MI0360B] = (1 << INFRARED) | 300[SENSOR_MI0360B] = (1 << HFLIP) |
305 (1 << HFLIP) |
306 (1 << VFLIP) | 301 (1 << VFLIP) |
307 (1 << FREQ), 302 (1 << FREQ),
308 303
309[SENSOR_MO4000] = (1 << INFRARED) | 304[SENSOR_MO4000] = (1 << HFLIP) |
310 (1 << HFLIP) |
311 (1 << VFLIP) | 305 (1 << VFLIP) |
312 (1 << FREQ), 306 (1 << FREQ),
313 307
@@ -315,40 +309,32 @@ static const __u32 ctrl_dis[] = {
315 (1 << VFLIP) | 309 (1 << VFLIP) |
316 (1 << FREQ), 310 (1 << FREQ),
317 311
318[SENSOR_OM6802] = (1 << INFRARED) | 312[SENSOR_OM6802] = (1 << HFLIP) |
319 (1 << HFLIP) |
320 (1 << VFLIP) | 313 (1 << VFLIP) |
321 (1 << FREQ), 314 (1 << FREQ),
322 315
323[SENSOR_OV7630] = (1 << INFRARED) | 316[SENSOR_OV7630] = (1 << HFLIP),
324 (1 << HFLIP),
325 317
326[SENSOR_OV7648] = (1 << INFRARED) | 318[SENSOR_OV7648] = (1 << HFLIP),
327 (1 << HFLIP),
328 319
329[SENSOR_OV7660] = (1 << AUTOGAIN) | 320[SENSOR_OV7660] = (1 << AUTOGAIN) |
330 (1 << INFRARED) |
331 (1 << HFLIP) | 321 (1 << HFLIP) |
332 (1 << VFLIP), 322 (1 << VFLIP),
333 323
334[SENSOR_PO1030] = (1 << AUTOGAIN) | 324[SENSOR_PO1030] = (1 << AUTOGAIN) |
335 (1 << INFRARED) |
336 (1 << HFLIP) | 325 (1 << HFLIP) |
337 (1 << VFLIP) | 326 (1 << VFLIP) |
338 (1 << FREQ), 327 (1 << FREQ),
339 328
340[SENSOR_PO2030N] = (1 << AUTOGAIN) | 329[SENSOR_PO2030N] = (1 << AUTOGAIN) |
341 (1 << INFRARED) |
342 (1 << FREQ), 330 (1 << FREQ),
343 331
344[SENSOR_SOI768] = (1 << AUTOGAIN) | 332[SENSOR_SOI768] = (1 << AUTOGAIN) |
345 (1 << INFRARED) |
346 (1 << HFLIP) | 333 (1 << HFLIP) |
347 (1 << VFLIP) | 334 (1 << VFLIP) |
348 (1 << FREQ), 335 (1 << FREQ),
349 336
350[SENSOR_SP80708] = (1 << AUTOGAIN) | 337[SENSOR_SP80708] = (1 << AUTOGAIN) |
351 (1 << INFRARED) |
352 (1 << HFLIP) | 338 (1 << HFLIP) |
353 (1 << VFLIP) | 339 (1 << VFLIP) |
354 (1 << FREQ), 340 (1 << FREQ),
@@ -1822,44 +1808,46 @@ static int sd_init(struct gspca_dev *gspca_dev)
1822 PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1); 1808 PDEBUG(D_PROBE, "Sonix chip id: %02x", regF1);
1823 switch (sd->bridge) { 1809 switch (sd->bridge) {
1824 case BRIDGE_SN9C102P: 1810 case BRIDGE_SN9C102P:
1811 case BRIDGE_SN9C105:
1825 if (regF1 != 0x11) 1812 if (regF1 != 0x11)
1826 return -ENODEV; 1813 return -ENODEV;
1814 break;
1815 default:
1816/* case BRIDGE_SN9C110: */
1817/* case BRIDGE_SN9C120: */
1818 if (regF1 != 0x12)
1819 return -ENODEV;
1820 }
1821
1822 switch (sd->sensor) {
1823 case SENSOR_MI0360:
1824 mi0360_probe(gspca_dev);
1825 break;
1826 case SENSOR_OV7630:
1827 ov7630_probe(gspca_dev);
1828 break;
1829 case SENSOR_OV7648:
1830 ov7648_probe(gspca_dev);
1831 break;
1832 case SENSOR_PO2030N:
1833 po2030n_probe(gspca_dev);
1834 break;
1835 }
1836
1837 switch (sd->bridge) {
1838 case BRIDGE_SN9C102P:
1827 reg_w1(gspca_dev, 0x02, regGpio[1]); 1839 reg_w1(gspca_dev, 0x02, regGpio[1]);
1828 break; 1840 break;
1829 case BRIDGE_SN9C105: 1841 case BRIDGE_SN9C105:
1830 if (regF1 != 0x11)
1831 return -ENODEV;
1832 if (sd->sensor == SENSOR_MI0360)
1833 mi0360_probe(gspca_dev);
1834 reg_w(gspca_dev, 0x01, regGpio, 2); 1842 reg_w(gspca_dev, 0x01, regGpio, 2);
1835 break; 1843 break;
1844 case BRIDGE_SN9C110:
1845 reg_w1(gspca_dev, 0x02, 0x62);
1846 break;
1836 case BRIDGE_SN9C120: 1847 case BRIDGE_SN9C120:
1837 if (regF1 != 0x12)
1838 return -ENODEV;
1839 switch (sd->sensor) {
1840 case SENSOR_MI0360:
1841 mi0360_probe(gspca_dev);
1842 break;
1843 case SENSOR_OV7630:
1844 ov7630_probe(gspca_dev);
1845 break;
1846 case SENSOR_OV7648:
1847 ov7648_probe(gspca_dev);
1848 break;
1849 case SENSOR_PO2030N:
1850 po2030n_probe(gspca_dev);
1851 break;
1852 }
1853 regGpio[1] = 0x70; /* no audio */ 1848 regGpio[1] = 0x70; /* no audio */
1854 reg_w(gspca_dev, 0x01, regGpio, 2); 1849 reg_w(gspca_dev, 0x01, regGpio, 2);
1855 break; 1850 break;
1856 default:
1857/* case BRIDGE_SN9C110: */
1858/* case BRIDGE_SN9C325: */
1859 if (regF1 != 0x12)
1860 return -ENODEV;
1861 reg_w1(gspca_dev, 0x02, 0x62);
1862 break;
1863 } 1851 }
1864 1852
1865 if (sd->sensor == SENSOR_OM6802) 1853 if (sd->sensor == SENSOR_OM6802)
@@ -1874,6 +1862,8 @@ static int sd_init(struct gspca_dev *gspca_dev)
1874 sd->i2c_addr = sn9c1xx[9]; 1862 sd->i2c_addr = sn9c1xx[9];
1875 1863
1876 gspca_dev->ctrl_dis = ctrl_dis[sd->sensor]; 1864 gspca_dev->ctrl_dis = ctrl_dis[sd->sensor];
1865 if (!(sd->flags & F_ILLUM))
1866 gspca_dev->ctrl_dis |= (1 << ILLUM);
1877 1867
1878 return gspca_dev->usb_err; 1868 return gspca_dev->usb_err;
1879} 1869}
@@ -2197,16 +2187,28 @@ static void setsharpness(struct gspca_dev *gspca_dev)
2197 reg_w1(gspca_dev, 0x99, sd->ctrls[SHARPNESS].val); 2187 reg_w1(gspca_dev, 0x99, sd->ctrls[SHARPNESS].val);
2198} 2188}
2199 2189
2200static void setinfrared(struct gspca_dev *gspca_dev) 2190static void setillum(struct gspca_dev *gspca_dev)
2201{ 2191{
2202 struct sd *sd = (struct sd *) gspca_dev; 2192 struct sd *sd = (struct sd *) gspca_dev;
2203 2193
2204 if (gspca_dev->ctrl_dis & (1 << INFRARED)) 2194 if (gspca_dev->ctrl_dis & (1 << ILLUM))
2205 return; 2195 return;
2206/*fixme: different sequence for StarCam Clip and StarCam 370i */ 2196 switch (sd->sensor) {
2207/* Clip */ 2197 case SENSOR_ADCM1700:
2208 i2c_w1(gspca_dev, 0x02, /* gpio */ 2198 reg_w1(gspca_dev, 0x02, /* gpio */
2209 sd->ctrls[INFRARED].val ? 0x66 : 0x64); 2199 sd->ctrls[ILLUM].val ? 0x64 : 0x60);
2200 break;
2201 case SENSOR_MT9V111:
2202 if (starcam)
2203 reg_w1(gspca_dev, 0x02,
2204 sd->ctrls[ILLUM].val ?
2205 0x55 : 0x54); /* 370i */
2206 else
2207 reg_w1(gspca_dev, 0x02,
2208 sd->ctrls[ILLUM].val ?
2209 0x66 : 0x64); /* Clip */
2210 break;
2211 }
2210} 2212}
2211 2213
2212static void setfreq(struct gspca_dev *gspca_dev) 2214static void setfreq(struct gspca_dev *gspca_dev)
@@ -2344,7 +2346,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
2344 /* sensor clock already enabled in sd_init */ 2346 /* sensor clock already enabled in sd_init */
2345 /* reg_w1(gspca_dev, 0xf1, 0x00); */ 2347 /* reg_w1(gspca_dev, 0xf1, 0x00); */
2346 reg01 = sn9c1xx[1]; 2348 reg01 = sn9c1xx[1];
2347 if (sd->flags & PDN_INV) 2349 if (sd->flags & F_PDN_INV)
2348 reg01 ^= S_PDN_INV; /* power down inverted */ 2350 reg01 ^= S_PDN_INV; /* power down inverted */
2349 reg_w1(gspca_dev, 0x01, reg01); 2351 reg_w1(gspca_dev, 0x01, reg01);
2350 2352
@@ -2907,13 +2909,11 @@ static const struct sd_desc sd_desc = {
2907 .driver_info = (BRIDGE_ ## bridge << 16) \ 2909 .driver_info = (BRIDGE_ ## bridge << 16) \
2908 | (SENSOR_ ## sensor << 8) \ 2910 | (SENSOR_ ## sensor << 8) \
2909 | (flags) 2911 | (flags)
2910static const __devinitdata struct usb_device_id device_table[] = { 2912static const struct usb_device_id device_table[] = {
2911#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
2912 {USB_DEVICE(0x0458, 0x7025), BS(SN9C120, MI0360)}, 2913 {USB_DEVICE(0x0458, 0x7025), BS(SN9C120, MI0360)},
2913 {USB_DEVICE(0x0458, 0x702e), BS(SN9C120, OV7660)}, 2914 {USB_DEVICE(0x0458, 0x702e), BS(SN9C120, OV7660)},
2914#endif 2915 {USB_DEVICE(0x045e, 0x00f5), BSF(SN9C105, OV7660, F_PDN_INV)},
2915 {USB_DEVICE(0x045e, 0x00f5), BSF(SN9C105, OV7660, PDN_INV)}, 2916 {USB_DEVICE(0x045e, 0x00f7), BSF(SN9C105, OV7660, F_PDN_INV)},
2916 {USB_DEVICE(0x045e, 0x00f7), BSF(SN9C105, OV7660, PDN_INV)},
2917 {USB_DEVICE(0x0471, 0x0327), BS(SN9C105, MI0360)}, 2917 {USB_DEVICE(0x0471, 0x0327), BS(SN9C105, MI0360)},
2918 {USB_DEVICE(0x0471, 0x0328), BS(SN9C105, MI0360)}, 2918 {USB_DEVICE(0x0471, 0x0328), BS(SN9C105, MI0360)},
2919 {USB_DEVICE(0x0471, 0x0330), BS(SN9C105, MI0360)}, 2919 {USB_DEVICE(0x0471, 0x0330), BS(SN9C105, MI0360)},
@@ -2925,7 +2925,7 @@ static const __devinitdata struct usb_device_id device_table[] = {
2925/* {USB_DEVICE(0x0c45, 0x607b), BS(SN9C102P, OV7660)}, */ 2925/* {USB_DEVICE(0x0c45, 0x607b), BS(SN9C102P, OV7660)}, */
2926 {USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)}, 2926 {USB_DEVICE(0x0c45, 0x607c), BS(SN9C102P, HV7131R)},
2927/* {USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */ 2927/* {USB_DEVICE(0x0c45, 0x607e), BS(SN9C102P, OV7630)}, */
2928 {USB_DEVICE(0x0c45, 0x60c0), BS(SN9C105, MI0360)}, 2928 {USB_DEVICE(0x0c45, 0x60c0), BSF(SN9C105, MI0360, F_ILLUM)},
2929 /* or MT9V111 */ 2929 /* or MT9V111 */
2930/* {USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */ 2930/* {USB_DEVICE(0x0c45, 0x60c2), BS(SN9C105, P1030xC)}, */
2931/* {USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */ 2931/* {USB_DEVICE(0x0c45, 0x60c8), BS(SN9C105, OM6802)}, */
@@ -2936,10 +2936,8 @@ static const __devinitdata struct usb_device_id device_table[] = {
2936/* {USB_DEVICE(0x0c45, 0x60fa), BS(SN9C105, OV7648)}, */ 2936/* {USB_DEVICE(0x0c45, 0x60fa), BS(SN9C105, OV7648)}, */
2937/* {USB_DEVICE(0x0c45, 0x60f2), BS(SN9C105, OV7660)}, */ 2937/* {USB_DEVICE(0x0c45, 0x60f2), BS(SN9C105, OV7660)}, */
2938 {USB_DEVICE(0x0c45, 0x60fb), BS(SN9C105, OV7660)}, 2938 {USB_DEVICE(0x0c45, 0x60fb), BS(SN9C105, OV7660)},
2939#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
2940 {USB_DEVICE(0x0c45, 0x60fc), BS(SN9C105, HV7131R)}, 2939 {USB_DEVICE(0x0c45, 0x60fc), BS(SN9C105, HV7131R)},
2941 {USB_DEVICE(0x0c45, 0x60fe), BS(SN9C105, OV7630)}, 2940 {USB_DEVICE(0x0c45, 0x60fe), BS(SN9C105, OV7630)},
2942#endif
2943 {USB_DEVICE(0x0c45, 0x6100), BS(SN9C120, MI0360)}, /*sn9c128*/ 2941 {USB_DEVICE(0x0c45, 0x6100), BS(SN9C120, MI0360)}, /*sn9c128*/
2944 {USB_DEVICE(0x0c45, 0x6102), BS(SN9C120, PO2030N)}, /* /GC0305*/ 2942 {USB_DEVICE(0x0c45, 0x6102), BS(SN9C120, PO2030N)}, /* /GC0305*/
2945/* {USB_DEVICE(0x0c45, 0x6108), BS(SN9C120, OM6802)}, */ 2943/* {USB_DEVICE(0x0c45, 0x6108), BS(SN9C120, OM6802)}, */
@@ -2962,16 +2960,15 @@ static const __devinitdata struct usb_device_id device_table[] = {
2962/* {USB_DEVICE(0x0c45, 0x6132), BS(SN9C120, OV7670)}, */ 2960/* {USB_DEVICE(0x0c45, 0x6132), BS(SN9C120, OV7670)}, */
2963 {USB_DEVICE(0x0c45, 0x6138), BS(SN9C120, MO4000)}, 2961 {USB_DEVICE(0x0c45, 0x6138), BS(SN9C120, MO4000)},
2964 {USB_DEVICE(0x0c45, 0x613a), BS(SN9C120, OV7648)}, 2962 {USB_DEVICE(0x0c45, 0x613a), BS(SN9C120, OV7648)},
2965#if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
2966 {USB_DEVICE(0x0c45, 0x613b), BS(SN9C120, OV7660)}, 2963 {USB_DEVICE(0x0c45, 0x613b), BS(SN9C120, OV7660)},
2967#endif
2968 {USB_DEVICE(0x0c45, 0x613c), BS(SN9C120, HV7131R)}, 2964 {USB_DEVICE(0x0c45, 0x613c), BS(SN9C120, HV7131R)},
2969 {USB_DEVICE(0x0c45, 0x613e), BS(SN9C120, OV7630)}, 2965 {USB_DEVICE(0x0c45, 0x613e), BS(SN9C120, OV7630)},
2970 {USB_DEVICE(0x0c45, 0x6142), BS(SN9C120, PO2030N)}, /*sn9c120b*/ 2966 {USB_DEVICE(0x0c45, 0x6142), BS(SN9C120, PO2030N)}, /*sn9c120b*/
2971 /* or GC0305 / GC0307 */ 2967 /* or GC0305 / GC0307 */
2972 {USB_DEVICE(0x0c45, 0x6143), BS(SN9C120, SP80708)}, /*sn9c120b*/ 2968 {USB_DEVICE(0x0c45, 0x6143), BS(SN9C120, SP80708)}, /*sn9c120b*/
2973 {USB_DEVICE(0x0c45, 0x6148), BS(SN9C120, OM6802)}, /*sn9c120b*/ 2969 {USB_DEVICE(0x0c45, 0x6148), BS(SN9C120, OM6802)}, /*sn9c120b*/
2974 {USB_DEVICE(0x0c45, 0x614a), BS(SN9C120, ADCM1700)}, /*sn9c120b*/ 2970 {USB_DEVICE(0x0c45, 0x614a), BSF(SN9C120, ADCM1700, F_ILLUM)},
2971/* {USB_DEVICE(0x0c45, 0x614c), BS(SN9C120, GC0306)}, */ /*sn9c120b*/
2975 {} 2972 {}
2976}; 2973};
2977MODULE_DEVICE_TABLE(usb, device_table); 2974MODULE_DEVICE_TABLE(usb, device_table);
@@ -3007,3 +3004,7 @@ static void __exit sd_mod_exit(void)
3007 3004
3008module_init(sd_mod_init); 3005module_init(sd_mod_init);
3009module_exit(sd_mod_exit); 3006module_exit(sd_mod_exit);
3007
3008module_param(starcam, int, 0644);
3009MODULE_PARM_DESC(starcam,
3010 "StarCam model. 0: Clip, 1: 370i");
diff --git a/drivers/media/video/gspca/spca1528.c b/drivers/media/video/gspca/spca1528.c
index e64338664410..76c006b2bc83 100644
--- a/drivers/media/video/gspca/spca1528.c
+++ b/drivers/media/video/gspca/spca1528.c
@@ -555,7 +555,7 @@ static const struct sd_desc sd_desc = {
555}; 555};
556 556
557/* -- module initialisation -- */ 557/* -- module initialisation -- */
558static const __devinitdata struct usb_device_id device_table[] = { 558static const struct usb_device_id device_table[] = {
559 {USB_DEVICE(0x04fc, 0x1528)}, 559 {USB_DEVICE(0x04fc, 0x1528)},
560 {} 560 {}
561}; 561};
diff --git a/drivers/media/video/gspca/spca500.c b/drivers/media/video/gspca/spca500.c
index 8e202b9039f1..45552c3ff8d9 100644
--- a/drivers/media/video/gspca/spca500.c
+++ b/drivers/media/video/gspca/spca500.c
@@ -1051,7 +1051,7 @@ static const struct sd_desc sd_desc = {
1051}; 1051};
1052 1052
1053/* -- module initialisation -- */ 1053/* -- module initialisation -- */
1054static const __devinitdata struct usb_device_id device_table[] = { 1054static const struct usb_device_id device_table[] = {
1055 {USB_DEVICE(0x040a, 0x0300), .driver_info = KodakEZ200}, 1055 {USB_DEVICE(0x040a, 0x0300), .driver_info = KodakEZ200},
1056 {USB_DEVICE(0x041e, 0x400a), .driver_info = CreativePCCam300}, 1056 {USB_DEVICE(0x041e, 0x400a), .driver_info = CreativePCCam300},
1057 {USB_DEVICE(0x046d, 0x0890), .driver_info = LogitechTraveler}, 1057 {USB_DEVICE(0x046d, 0x0890), .driver_info = LogitechTraveler},
diff --git a/drivers/media/video/gspca/spca501.c b/drivers/media/video/gspca/spca501.c
index 642839a11e8d..f7ef282cc600 100644
--- a/drivers/media/video/gspca/spca501.c
+++ b/drivers/media/video/gspca/spca501.c
@@ -2155,7 +2155,7 @@ static const struct sd_desc sd_desc = {
2155}; 2155};
2156 2156
2157/* -- module initialisation -- */ 2157/* -- module initialisation -- */
2158static const __devinitdata struct usb_device_id device_table[] = { 2158static const struct usb_device_id device_table[] = {
2159 {USB_DEVICE(0x040a, 0x0002), .driver_info = KodakDVC325}, 2159 {USB_DEVICE(0x040a, 0x0002), .driver_info = KodakDVC325},
2160 {USB_DEVICE(0x0497, 0xc001), .driver_info = SmileIntlCamera}, 2160 {USB_DEVICE(0x0497, 0xc001), .driver_info = SmileIntlCamera},
2161 {USB_DEVICE(0x0506, 0x00df), .driver_info = ThreeComHomeConnectLite}, 2161 {USB_DEVICE(0x0506, 0x00df), .driver_info = ThreeComHomeConnectLite},
diff --git a/drivers/media/video/gspca/spca505.c b/drivers/media/video/gspca/spca505.c
index bc9dd9034ab4..e5bf865147d7 100644
--- a/drivers/media/video/gspca/spca505.c
+++ b/drivers/media/video/gspca/spca505.c
@@ -786,7 +786,7 @@ static const struct sd_desc sd_desc = {
786}; 786};
787 787
788/* -- module initialisation -- */ 788/* -- module initialisation -- */
789static const __devinitdata struct usb_device_id device_table[] = { 789static const struct usb_device_id device_table[] = {
790 {USB_DEVICE(0x041e, 0x401d), .driver_info = Nxultra}, 790 {USB_DEVICE(0x041e, 0x401d), .driver_info = Nxultra},
791 {USB_DEVICE(0x0733, 0x0430), .driver_info = IntelPCCameraPro}, 791 {USB_DEVICE(0x0733, 0x0430), .driver_info = IntelPCCameraPro},
792/*fixme: may be UsbGrabberPV321 BRIDGE_SPCA506 SENSOR_SAA7113 */ 792/*fixme: may be UsbGrabberPV321 BRIDGE_SPCA506 SENSOR_SAA7113 */
diff --git a/drivers/media/video/gspca/spca508.c b/drivers/media/video/gspca/spca508.c
index 7307638ac91d..348319371523 100644
--- a/drivers/media/video/gspca/spca508.c
+++ b/drivers/media/video/gspca/spca508.c
@@ -1509,7 +1509,7 @@ static const struct sd_desc sd_desc = {
1509}; 1509};
1510 1510
1511/* -- module initialisation -- */ 1511/* -- module initialisation -- */
1512static const __devinitdata struct usb_device_id device_table[] = { 1512static const struct usb_device_id device_table[] = {
1513 {USB_DEVICE(0x0130, 0x0130), .driver_info = HamaUSBSightcam}, 1513 {USB_DEVICE(0x0130, 0x0130), .driver_info = HamaUSBSightcam},
1514 {USB_DEVICE(0x041e, 0x4018), .driver_info = CreativeVista}, 1514 {USB_DEVICE(0x041e, 0x4018), .driver_info = CreativeVista},
1515 {USB_DEVICE(0x0733, 0x0110), .driver_info = ViewQuestVQ110}, 1515 {USB_DEVICE(0x0733, 0x0110), .driver_info = ViewQuestVQ110},
diff --git a/drivers/media/video/gspca/spca561.c b/drivers/media/video/gspca/spca561.c
index 3a162c6d5466..e836e778dfb6 100644
--- a/drivers/media/video/gspca/spca561.c
+++ b/drivers/media/video/gspca/spca561.c
@@ -1061,7 +1061,7 @@ static const struct sd_desc *sd_desc[2] = {
1061}; 1061};
1062 1062
1063/* -- module initialisation -- */ 1063/* -- module initialisation -- */
1064static const __devinitdata struct usb_device_id device_table[] = { 1064static const struct usb_device_id device_table[] = {
1065 {USB_DEVICE(0x041e, 0x401a), .driver_info = Rev072A}, 1065 {USB_DEVICE(0x041e, 0x401a), .driver_info = Rev072A},
1066 {USB_DEVICE(0x041e, 0x403b), .driver_info = Rev012A}, 1066 {USB_DEVICE(0x041e, 0x403b), .driver_info = Rev012A},
1067 {USB_DEVICE(0x0458, 0x7004), .driver_info = Rev072A}, 1067 {USB_DEVICE(0x0458, 0x7004), .driver_info = Rev072A},
diff --git a/drivers/media/video/gspca/sq905.c b/drivers/media/video/gspca/sq905.c
index 404067745775..2e9c06175192 100644
--- a/drivers/media/video/gspca/sq905.c
+++ b/drivers/media/video/gspca/sq905.c
@@ -396,7 +396,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
396} 396}
397 397
398/* Table of supported USB devices */ 398/* Table of supported USB devices */
399static const __devinitdata struct usb_device_id device_table[] = { 399static const struct usb_device_id device_table[] = {
400 {USB_DEVICE(0x2770, 0x9120)}, 400 {USB_DEVICE(0x2770, 0x9120)},
401 {} 401 {}
402}; 402};
diff --git a/drivers/media/video/gspca/sq905c.c b/drivers/media/video/gspca/sq905c.c
index 8ba199543856..457563b7a71b 100644
--- a/drivers/media/video/gspca/sq905c.c
+++ b/drivers/media/video/gspca/sq905c.c
@@ -298,7 +298,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
298} 298}
299 299
300/* Table of supported USB devices */ 300/* Table of supported USB devices */
301static const __devinitdata struct usb_device_id device_table[] = { 301static const struct usb_device_id device_table[] = {
302 {USB_DEVICE(0x2770, 0x905c)}, 302 {USB_DEVICE(0x2770, 0x905c)},
303 {USB_DEVICE(0x2770, 0x9050)}, 303 {USB_DEVICE(0x2770, 0x9050)},
304 {USB_DEVICE(0x2770, 0x9051)}, 304 {USB_DEVICE(0x2770, 0x9051)},
diff --git a/drivers/media/video/gspca/sq930x.c b/drivers/media/video/gspca/sq930x.c
index a4a98811b9e3..8215d5dcd456 100644
--- a/drivers/media/video/gspca/sq930x.c
+++ b/drivers/media/video/gspca/sq930x.c
@@ -1163,7 +1163,7 @@ static const struct sd_desc sd_desc = {
1163#define ST(sensor, type) \ 1163#define ST(sensor, type) \
1164 .driver_info = (SENSOR_ ## sensor << 8) \ 1164 .driver_info = (SENSOR_ ## sensor << 8) \
1165 | (type) 1165 | (type)
1166static const __devinitdata struct usb_device_id device_table[] = { 1166static const struct usb_device_id device_table[] = {
1167 {USB_DEVICE(0x041e, 0x4038), ST(MI0360, 0)}, 1167 {USB_DEVICE(0x041e, 0x4038), ST(MI0360, 0)},
1168 {USB_DEVICE(0x041e, 0x403c), ST(LZ24BP, 0)}, 1168 {USB_DEVICE(0x041e, 0x403c), ST(LZ24BP, 0)},
1169 {USB_DEVICE(0x041e, 0x403d), ST(LZ24BP, 0)}, 1169 {USB_DEVICE(0x041e, 0x403d), ST(LZ24BP, 0)},
diff --git a/drivers/media/video/gspca/stk014.c b/drivers/media/video/gspca/stk014.c
index 11a192b95ed4..87be52b5e1e3 100644
--- a/drivers/media/video/gspca/stk014.c
+++ b/drivers/media/video/gspca/stk014.c
@@ -495,7 +495,7 @@ static const struct sd_desc sd_desc = {
495}; 495};
496 496
497/* -- module initialisation -- */ 497/* -- module initialisation -- */
498static const __devinitdata struct usb_device_id device_table[] = { 498static const struct usb_device_id device_table[] = {
499 {USB_DEVICE(0x05e1, 0x0893)}, 499 {USB_DEVICE(0x05e1, 0x0893)},
500 {} 500 {}
501}; 501};
diff --git a/drivers/media/video/gspca/stv0680.c b/drivers/media/video/gspca/stv0680.c
index b199ad4666bd..e2ef41cf72d7 100644
--- a/drivers/media/video/gspca/stv0680.c
+++ b/drivers/media/video/gspca/stv0680.c
@@ -327,7 +327,7 @@ static const struct sd_desc sd_desc = {
327}; 327};
328 328
329/* -- module initialisation -- */ 329/* -- module initialisation -- */
330static const __devinitdata struct usb_device_id device_table[] = { 330static const struct usb_device_id device_table[] = {
331 {USB_DEVICE(0x0553, 0x0202)}, 331 {USB_DEVICE(0x0553, 0x0202)},
332 {USB_DEVICE(0x041e, 0x4007)}, 332 {USB_DEVICE(0x041e, 0x4007)},
333 {} 333 {}
diff --git a/drivers/media/video/gspca/stv06xx/stv06xx.c b/drivers/media/video/gspca/stv06xx/stv06xx.c
index 28ea4175b80e..7e0661429293 100644
--- a/drivers/media/video/gspca/stv06xx/stv06xx.c
+++ b/drivers/media/video/gspca/stv06xx/stv06xx.c
@@ -564,7 +564,7 @@ static int stv06xx_config(struct gspca_dev *gspca_dev,
564 564
565 565
566/* -- module initialisation -- */ 566/* -- module initialisation -- */
567static const __devinitdata struct usb_device_id device_table[] = { 567static const struct usb_device_id device_table[] = {
568 /* QuickCam Express */ 568 /* QuickCam Express */
569 {USB_DEVICE(0x046d, 0x0840), .driver_info = BRIDGE_STV600 }, 569 {USB_DEVICE(0x046d, 0x0840), .driver_info = BRIDGE_STV600 },
570 /* LEGO cam / QuickCam Web */ 570 /* LEGO cam / QuickCam Web */
diff --git a/drivers/media/video/gspca/sunplus.c b/drivers/media/video/gspca/sunplus.c
index a9cbcd6011d9..543542af2720 100644
--- a/drivers/media/video/gspca/sunplus.c
+++ b/drivers/media/video/gspca/sunplus.c
@@ -1162,7 +1162,7 @@ static const struct sd_desc sd_desc = {
1162#define BS(bridge, subtype) \ 1162#define BS(bridge, subtype) \
1163 .driver_info = (BRIDGE_ ## bridge << 8) \ 1163 .driver_info = (BRIDGE_ ## bridge << 8) \
1164 | (subtype) 1164 | (subtype)
1165static const __devinitdata struct usb_device_id device_table[] = { 1165static const struct usb_device_id device_table[] = {
1166 {USB_DEVICE(0x041e, 0x400b), BS(SPCA504C, 0)}, 1166 {USB_DEVICE(0x041e, 0x400b), BS(SPCA504C, 0)},
1167 {USB_DEVICE(0x041e, 0x4012), BS(SPCA504C, 0)}, 1167 {USB_DEVICE(0x041e, 0x4012), BS(SPCA504C, 0)},
1168 {USB_DEVICE(0x041e, 0x4013), BS(SPCA504C, 0)}, 1168 {USB_DEVICE(0x041e, 0x4013), BS(SPCA504C, 0)},
diff --git a/drivers/media/video/gspca/t613.c b/drivers/media/video/gspca/t613.c
index 8f0c33116e0d..a3eccd815766 100644
--- a/drivers/media/video/gspca/t613.c
+++ b/drivers/media/video/gspca/t613.c
@@ -1416,7 +1416,7 @@ static const struct sd_desc sd_desc = {
1416}; 1416};
1417 1417
1418/* -- module initialisation -- */ 1418/* -- module initialisation -- */
1419static const __devinitdata struct usb_device_id device_table[] = { 1419static const struct usb_device_id device_table[] = {
1420 {USB_DEVICE(0x17a1, 0x0128)}, 1420 {USB_DEVICE(0x17a1, 0x0128)},
1421 {} 1421 {}
1422}; 1422};
diff --git a/drivers/media/video/gspca/tv8532.c b/drivers/media/video/gspca/tv8532.c
index 38c22f0a4263..933ef2ca658c 100644
--- a/drivers/media/video/gspca/tv8532.c
+++ b/drivers/media/video/gspca/tv8532.c
@@ -388,7 +388,7 @@ static const struct sd_desc sd_desc = {
388}; 388};
389 389
390/* -- module initialisation -- */ 390/* -- module initialisation -- */
391static const __devinitdata struct usb_device_id device_table[] = { 391static const struct usb_device_id device_table[] = {
392 {USB_DEVICE(0x046d, 0x0920)}, 392 {USB_DEVICE(0x046d, 0x0920)},
393 {USB_DEVICE(0x046d, 0x0921)}, 393 {USB_DEVICE(0x046d, 0x0921)},
394 {USB_DEVICE(0x0545, 0x808b)}, 394 {USB_DEVICE(0x0545, 0x808b)},
diff --git a/drivers/media/video/gspca/vc032x.c b/drivers/media/video/gspca/vc032x.c
index 9b2ae1b6cc75..6caed734a06a 100644
--- a/drivers/media/video/gspca/vc032x.c
+++ b/drivers/media/video/gspca/vc032x.c
@@ -4192,7 +4192,7 @@ static const struct sd_desc sd_desc = {
4192#define BF(bridge, flags) \ 4192#define BF(bridge, flags) \
4193 .driver_info = (BRIDGE_ ## bridge << 8) \ 4193 .driver_info = (BRIDGE_ ## bridge << 8) \
4194 | (flags) 4194 | (flags)
4195static const __devinitdata struct usb_device_id device_table[] = { 4195static const struct usb_device_id device_table[] = {
4196 {USB_DEVICE(0x041e, 0x405b), BF(VC0323, FL_VFLIP)}, 4196 {USB_DEVICE(0x041e, 0x405b), BF(VC0323, FL_VFLIP)},
4197 {USB_DEVICE(0x046d, 0x0892), BF(VC0321, 0)}, 4197 {USB_DEVICE(0x046d, 0x0892), BF(VC0321, 0)},
4198 {USB_DEVICE(0x046d, 0x0896), BF(VC0321, 0)}, 4198 {USB_DEVICE(0x046d, 0x0896), BF(VC0321, 0)},
diff --git a/drivers/media/video/gspca/xirlink_cit.c b/drivers/media/video/gspca/xirlink_cit.c
index 5b5039a02031..c089a0f6f1d0 100644
--- a/drivers/media/video/gspca/xirlink_cit.c
+++ b/drivers/media/video/gspca/xirlink_cit.c
@@ -3270,7 +3270,7 @@ static const struct sd_desc sd_desc_isoc_nego = {
3270}; 3270};
3271 3271
3272/* -- module initialisation -- */ 3272/* -- module initialisation -- */
3273static const __devinitdata struct usb_device_id device_table[] = { 3273static const struct usb_device_id device_table[] = {
3274 { USB_DEVICE_VER(0x0545, 0x8080, 0x0001, 0x0001), .driver_info = CIT_MODEL0 }, 3274 { USB_DEVICE_VER(0x0545, 0x8080, 0x0001, 0x0001), .driver_info = CIT_MODEL0 },
3275 { USB_DEVICE_VER(0x0545, 0x8080, 0x0002, 0x0002), .driver_info = CIT_MODEL1 }, 3275 { USB_DEVICE_VER(0x0545, 0x8080, 0x0002, 0x0002), .driver_info = CIT_MODEL1 },
3276 { USB_DEVICE_VER(0x0545, 0x8080, 0x030a, 0x030a), .driver_info = CIT_MODEL2 }, 3276 { USB_DEVICE_VER(0x0545, 0x8080, 0x030a, 0x030a), .driver_info = CIT_MODEL2 },
diff --git a/drivers/media/video/gspca/zc3xx.c b/drivers/media/video/gspca/zc3xx.c
index 14b85d483163..865216e9362c 100644
--- a/drivers/media/video/gspca/zc3xx.c
+++ b/drivers/media/video/gspca/zc3xx.c
@@ -6909,7 +6909,7 @@ static const struct sd_desc sd_desc = {
6909#endif 6909#endif
6910}; 6910};
6911 6911
6912static const __devinitdata struct usb_device_id device_table[] = { 6912static const struct usb_device_id device_table[] = {
6913 {USB_DEVICE(0x041e, 0x041e)}, 6913 {USB_DEVICE(0x041e, 0x041e)},
6914 {USB_DEVICE(0x041e, 0x4017)}, 6914 {USB_DEVICE(0x041e, 0x4017)},
6915 {USB_DEVICE(0x041e, 0x401c), .driver_info = SENSOR_PAS106}, 6915 {USB_DEVICE(0x041e, 0x401c), .driver_info = SENSOR_PAS106},
diff --git a/drivers/media/video/hdpvr/Makefile b/drivers/media/video/hdpvr/Makefile
index e0230fcb2e36..3baa9f613ca3 100644
--- a/drivers/media/video/hdpvr/Makefile
+++ b/drivers/media/video/hdpvr/Makefile
@@ -1,6 +1,4 @@
1hdpvr-objs := hdpvr-control.o hdpvr-core.o hdpvr-video.o 1hdpvr-objs := hdpvr-control.o hdpvr-core.o hdpvr-video.o hdpvr-i2c.o
2
3hdpvr-$(CONFIG_I2C) += hdpvr-i2c.o
4 2
5obj-$(CONFIG_VIDEO_HDPVR) += hdpvr.o 3obj-$(CONFIG_VIDEO_HDPVR) += hdpvr.o
6 4
diff --git a/drivers/media/video/hdpvr/hdpvr-core.c b/drivers/media/video/hdpvr/hdpvr-core.c
index f7d1ee55185a..a6572e5ae369 100644
--- a/drivers/media/video/hdpvr/hdpvr-core.c
+++ b/drivers/media/video/hdpvr/hdpvr-core.c
@@ -378,19 +378,17 @@ static int hdpvr_probe(struct usb_interface *interface,
378 goto error; 378 goto error;
379 } 379 }
380 380
381#ifdef CONFIG_I2C 381#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
382 /* until i2c is working properly */ 382 retval = hdpvr_register_i2c_adapter(dev);
383 retval = 0; /* hdpvr_register_i2c_adapter(dev); */
384 if (retval < 0) { 383 if (retval < 0) {
385 v4l2_err(&dev->v4l2_dev, "registering i2c adapter failed\n"); 384 v4l2_err(&dev->v4l2_dev, "registering i2c adapter failed\n");
386 goto error; 385 goto error;
387 } 386 }
388 387
389 /* until i2c is working properly */ 388 retval = hdpvr_register_i2c_ir(dev);
390 retval = 0; /* hdpvr_register_i2c_ir(dev); */
391 if (retval < 0) 389 if (retval < 0)
392 v4l2_err(&dev->v4l2_dev, "registering i2c IR devices failed\n"); 390 v4l2_err(&dev->v4l2_dev, "registering i2c IR devices failed\n");
393#endif /* CONFIG_I2C */ 391#endif
394 392
395 /* let the user know what node this device is now attached to */ 393 /* let the user know what node this device is now attached to */
396 v4l2_info(&dev->v4l2_dev, "device now attached to %s\n", 394 v4l2_info(&dev->v4l2_dev, "device now attached to %s\n",
diff --git a/drivers/media/video/hdpvr/hdpvr-i2c.c b/drivers/media/video/hdpvr/hdpvr-i2c.c
index 24966aa02a70..89b71faeaac2 100644
--- a/drivers/media/video/hdpvr/hdpvr-i2c.c
+++ b/drivers/media/video/hdpvr/hdpvr-i2c.c
@@ -13,6 +13,8 @@
13 * 13 *
14 */ 14 */
15 15
16#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
17
16#include <linux/i2c.h> 18#include <linux/i2c.h>
17#include <linux/slab.h> 19#include <linux/slab.h>
18 20
@@ -28,106 +30,78 @@
28#define Z8F0811_IR_TX_I2C_ADDR 0x70 30#define Z8F0811_IR_TX_I2C_ADDR 0x70
29#define Z8F0811_IR_RX_I2C_ADDR 0x71 31#define Z8F0811_IR_RX_I2C_ADDR 0x71
30 32
31static const u8 ir_i2c_addrs[] = {
32 Z8F0811_IR_TX_I2C_ADDR,
33 Z8F0811_IR_RX_I2C_ADDR,
34};
35 33
36static const char * const ir_devicenames[] = { 34static struct i2c_board_info hdpvr_i2c_board_info = {
37 "ir_tx_z8f0811_hdpvr", 35 I2C_BOARD_INFO("ir_tx_z8f0811_hdpvr", Z8F0811_IR_TX_I2C_ADDR),
38 "ir_rx_z8f0811_hdpvr", 36 I2C_BOARD_INFO("ir_rx_z8f0811_hdpvr", Z8F0811_IR_RX_I2C_ADDR),
39}; 37};
40 38
41static int hdpvr_new_i2c_ir(struct hdpvr_device *dev, struct i2c_adapter *adap, 39int hdpvr_register_i2c_ir(struct hdpvr_device *dev)
42 const char *type, u8 addr)
43{ 40{
44 struct i2c_board_info info; 41 struct i2c_client *c;
45 struct IR_i2c_init_data *init_data = &dev->ir_i2c_init_data; 42 struct IR_i2c_init_data *init_data = &dev->ir_i2c_init_data;
46 unsigned short addr_list[2] = { addr, I2C_CLIENT_END };
47
48 memset(&info, 0, sizeof(struct i2c_board_info));
49 strlcpy(info.type, type, I2C_NAME_SIZE);
50 43
51 /* Our default information for ir-kbd-i2c.c to use */ 44 /* Our default information for ir-kbd-i2c.c to use */
52 switch (addr) { 45 init_data->ir_codes = RC_MAP_HAUPPAUGE_NEW;
53 case Z8F0811_IR_RX_I2C_ADDR: 46 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR;
54 init_data->ir_codes = RC_MAP_HAUPPAUGE_NEW; 47 init_data->type = RC_TYPE_RC5;
55 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR; 48 init_data->name = "HD PVR";
56 init_data->type = RC_TYPE_RC5; 49 hdpvr_i2c_board_info.platform_data = init_data;
57 init_data->name = "HD PVR";
58 info.platform_data = init_data;
59 break;
60 }
61 50
62 return i2c_new_probed_device(adap, &info, addr_list, NULL) == NULL ? 51 c = i2c_new_device(&dev->i2c_adapter, &hdpvr_i2c_board_info);
63 -1 : 0;
64}
65 52
66int hdpvr_register_i2c_ir(struct hdpvr_device *dev) 53 return (c == NULL) ? -ENODEV : 0;
67{
68 int i;
69 int ret = 0;
70
71 for (i = 0; i < ARRAY_SIZE(ir_i2c_addrs); i++)
72 ret += hdpvr_new_i2c_ir(dev, dev->i2c_adapter,
73 ir_devicenames[i], ir_i2c_addrs[i]);
74
75 return ret;
76} 54}
77 55
78static int hdpvr_i2c_read(struct hdpvr_device *dev, unsigned char addr, 56static int hdpvr_i2c_read(struct hdpvr_device *dev, int bus,
79 char *data, int len) 57 unsigned char addr, char *data, int len)
80{ 58{
81 int ret; 59 int ret;
82 char *buf = kmalloc(len, GFP_KERNEL); 60
83 if (!buf) 61 if (len > sizeof(dev->i2c_buf))
84 return -ENOMEM; 62 return -EINVAL;
85 63
86 ret = usb_control_msg(dev->udev, 64 ret = usb_control_msg(dev->udev,
87 usb_rcvctrlpipe(dev->udev, 0), 65 usb_rcvctrlpipe(dev->udev, 0),
88 REQTYPE_I2C_READ, CTRL_READ_REQUEST, 66 REQTYPE_I2C_READ, CTRL_READ_REQUEST,
89 0x100|addr, 0, buf, len, 1000); 67 (bus << 8) | addr, 0, &dev->i2c_buf, len, 1000);
90 68
91 if (ret == len) { 69 if (ret == len) {
92 memcpy(data, buf, len); 70 memcpy(data, &dev->i2c_buf, len);
93 ret = 0; 71 ret = 0;
94 } else if (ret >= 0) 72 } else if (ret >= 0)
95 ret = -EIO; 73 ret = -EIO;
96 74
97 kfree(buf);
98
99 return ret; 75 return ret;
100} 76}
101 77
102static int hdpvr_i2c_write(struct hdpvr_device *dev, unsigned char addr, 78static int hdpvr_i2c_write(struct hdpvr_device *dev, int bus,
103 char *data, int len) 79 unsigned char addr, char *data, int len)
104{ 80{
105 int ret; 81 int ret;
106 char *buf = kmalloc(len, GFP_KERNEL);
107 if (!buf)
108 return -ENOMEM;
109 82
110 memcpy(buf, data, len); 83 if (len > sizeof(dev->i2c_buf))
84 return -EINVAL;
85
86 memcpy(&dev->i2c_buf, data, len);
111 ret = usb_control_msg(dev->udev, 87 ret = usb_control_msg(dev->udev,
112 usb_sndctrlpipe(dev->udev, 0), 88 usb_sndctrlpipe(dev->udev, 0),
113 REQTYPE_I2C_WRITE, CTRL_WRITE_REQUEST, 89 REQTYPE_I2C_WRITE, CTRL_WRITE_REQUEST,
114 0x100|addr, 0, buf, len, 1000); 90 (bus << 8) | addr, 0, &dev->i2c_buf, len, 1000);
115 91
116 if (ret < 0) 92 if (ret < 0)
117 goto error; 93 return ret;
118 94
119 ret = usb_control_msg(dev->udev, 95 ret = usb_control_msg(dev->udev,
120 usb_rcvctrlpipe(dev->udev, 0), 96 usb_rcvctrlpipe(dev->udev, 0),
121 REQTYPE_I2C_WRITE_STATT, CTRL_READ_REQUEST, 97 REQTYPE_I2C_WRITE_STATT, CTRL_READ_REQUEST,
122 0, 0, buf, 2, 1000); 98 0, 0, &dev->i2c_buf, 2, 1000);
123 99
124 if (ret == 2) 100 if ((ret == 2) && (dev->i2c_buf[1] == (len - 1)))
125 ret = 0; 101 ret = 0;
126 else if (ret >= 0) 102 else if (ret >= 0)
127 ret = -EIO; 103 ret = -EIO;
128 104
129error:
130 kfree(buf);
131 return ret; 105 return ret;
132} 106}
133 107
@@ -146,10 +120,10 @@ static int hdpvr_transfer(struct i2c_adapter *i2c_adapter, struct i2c_msg *msgs,
146 addr = msgs[i].addr << 1; 120 addr = msgs[i].addr << 1;
147 121
148 if (msgs[i].flags & I2C_M_RD) 122 if (msgs[i].flags & I2C_M_RD)
149 retval = hdpvr_i2c_read(dev, addr, msgs[i].buf, 123 retval = hdpvr_i2c_read(dev, 1, addr, msgs[i].buf,
150 msgs[i].len); 124 msgs[i].len);
151 else 125 else
152 retval = hdpvr_i2c_write(dev, addr, msgs[i].buf, 126 retval = hdpvr_i2c_write(dev, 1, addr, msgs[i].buf,
153 msgs[i].len); 127 msgs[i].len);
154 } 128 }
155 129
@@ -168,30 +142,47 @@ static struct i2c_algorithm hdpvr_algo = {
168 .functionality = hdpvr_functionality, 142 .functionality = hdpvr_functionality,
169}; 143};
170 144
145static struct i2c_adapter hdpvr_i2c_adapter_template = {
146 .name = "Hauppage HD PVR I2C",
147 .owner = THIS_MODULE,
148 .algo = &hdpvr_algo,
149};
150
151static int hdpvr_activate_ir(struct hdpvr_device *dev)
152{
153 char buffer[8];
154
155 mutex_lock(&dev->i2c_mutex);
156
157 hdpvr_i2c_read(dev, 0, 0x54, buffer, 1);
158
159 buffer[0] = 0;
160 buffer[1] = 0x8;
161 hdpvr_i2c_write(dev, 1, 0x54, buffer, 2);
162
163 buffer[1] = 0x18;
164 hdpvr_i2c_write(dev, 1, 0x54, buffer, 2);
165
166 mutex_unlock(&dev->i2c_mutex);
167
168 return 0;
169}
170
171int hdpvr_register_i2c_adapter(struct hdpvr_device *dev) 171int hdpvr_register_i2c_adapter(struct hdpvr_device *dev)
172{ 172{
173 struct i2c_adapter *i2c_adap;
174 int retval = -ENOMEM; 173 int retval = -ENOMEM;
175 174
176 i2c_adap = kzalloc(sizeof(struct i2c_adapter), GFP_KERNEL); 175 hdpvr_activate_ir(dev);
177 if (i2c_adap == NULL)
178 goto error;
179
180 strlcpy(i2c_adap->name, "Hauppauge HD PVR I2C",
181 sizeof(i2c_adap->name));
182 i2c_adap->algo = &hdpvr_algo;
183 i2c_adap->owner = THIS_MODULE;
184 i2c_adap->dev.parent = &dev->udev->dev;
185 176
186 i2c_set_adapdata(i2c_adap, dev); 177 memcpy(&dev->i2c_adapter, &hdpvr_i2c_adapter_template,
178 sizeof(struct i2c_adapter));
179 dev->i2c_adapter.dev.parent = &dev->udev->dev;
187 180
188 retval = i2c_add_adapter(i2c_adap); 181 i2c_set_adapdata(&dev->i2c_adapter, dev);
189 182
190 if (!retval) 183 retval = i2c_add_adapter(&dev->i2c_adapter);
191 dev->i2c_adapter = i2c_adap;
192 else
193 kfree(i2c_adap);
194 184
195error:
196 return retval; 185 return retval;
197} 186}
187
188#endif
diff --git a/drivers/media/video/hdpvr/hdpvr-video.c b/drivers/media/video/hdpvr/hdpvr-video.c
index d38fe1043e47..514aea76eaa5 100644
--- a/drivers/media/video/hdpvr/hdpvr-video.c
+++ b/drivers/media/video/hdpvr/hdpvr-video.c
@@ -1220,12 +1220,9 @@ static void hdpvr_device_release(struct video_device *vdev)
1220 v4l2_device_unregister(&dev->v4l2_dev); 1220 v4l2_device_unregister(&dev->v4l2_dev);
1221 1221
1222 /* deregister I2C adapter */ 1222 /* deregister I2C adapter */
1223#ifdef CONFIG_I2C 1223#if defined(CONFIG_I2C) || (CONFIG_I2C_MODULE)
1224 mutex_lock(&dev->i2c_mutex); 1224 mutex_lock(&dev->i2c_mutex);
1225 if (dev->i2c_adapter) 1225 i2c_del_adapter(&dev->i2c_adapter);
1226 i2c_del_adapter(dev->i2c_adapter);
1227 kfree(dev->i2c_adapter);
1228 dev->i2c_adapter = NULL;
1229 mutex_unlock(&dev->i2c_mutex); 1226 mutex_unlock(&dev->i2c_mutex);
1230#endif /* CONFIG_I2C */ 1227#endif /* CONFIG_I2C */
1231 1228
diff --git a/drivers/media/video/hdpvr/hdpvr.h b/drivers/media/video/hdpvr/hdpvr.h
index 37f1e4c7675d..ee74e3be9a6a 100644
--- a/drivers/media/video/hdpvr/hdpvr.h
+++ b/drivers/media/video/hdpvr/hdpvr.h
@@ -25,6 +25,7 @@
25 KERNEL_VERSION(HDPVR_MAJOR_VERSION, HDPVR_MINOR_VERSION, HDPVR_RELEASE) 25 KERNEL_VERSION(HDPVR_MAJOR_VERSION, HDPVR_MINOR_VERSION, HDPVR_RELEASE)
26 26
27#define HDPVR_MAX 8 27#define HDPVR_MAX 8
28#define HDPVR_I2C_MAX_SIZE 128
28 29
29/* Define these values to match your devices */ 30/* Define these values to match your devices */
30#define HD_PVR_VENDOR_ID 0x2040 31#define HD_PVR_VENDOR_ID 0x2040
@@ -106,9 +107,11 @@ struct hdpvr_device {
106 struct work_struct worker; 107 struct work_struct worker;
107 108
108 /* I2C adapter */ 109 /* I2C adapter */
109 struct i2c_adapter *i2c_adapter; 110 struct i2c_adapter i2c_adapter;
110 /* I2C lock */ 111 /* I2C lock */
111 struct mutex i2c_mutex; 112 struct mutex i2c_mutex;
113 /* I2C message buffer space */
114 char i2c_buf[HDPVR_I2C_MAX_SIZE];
112 115
113 /* For passing data to ir-kbd-i2c */ 116 /* For passing data to ir-kbd-i2c */
114 struct IR_i2c_init_data ir_i2c_init_data; 117 struct IR_i2c_init_data ir_i2c_init_data;
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c
index c87b6bc45555..d2b20ad383a3 100644
--- a/drivers/media/video/ir-kbd-i2c.c
+++ b/drivers/media/video/ir-kbd-i2c.c
@@ -244,15 +244,17 @@ static void ir_key_poll(struct IR_i2c *ir)
244 static u32 ir_key, ir_raw; 244 static u32 ir_key, ir_raw;
245 int rc; 245 int rc;
246 246
247 dprintk(2,"ir_poll_key\n"); 247 dprintk(3, "%s\n", __func__);
248 rc = ir->get_key(ir, &ir_key, &ir_raw); 248 rc = ir->get_key(ir, &ir_key, &ir_raw);
249 if (rc < 0) { 249 if (rc < 0) {
250 dprintk(2,"error\n"); 250 dprintk(2,"error\n");
251 return; 251 return;
252 } 252 }
253 253
254 if (rc) 254 if (rc) {
255 dprintk(1, "%s: keycode = 0x%04x\n", __func__, ir_key);
255 rc_keydown(ir->rc, ir_key, 0); 256 rc_keydown(ir->rc, ir_key, 0);
257 }
256} 258}
257 259
258static void ir_work(struct work_struct *work) 260static void ir_work(struct work_struct *work)
@@ -321,6 +323,12 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
321 rc_type = RC_TYPE_OTHER; 323 rc_type = RC_TYPE_OTHER;
322 ir_codes = RC_MAP_AVERMEDIA_CARDBUS; 324 ir_codes = RC_MAP_AVERMEDIA_CARDBUS;
323 break; 325 break;
326 case 0x71:
327 name = "Hauppauge/Zilog Z8";
328 ir->get_key = get_key_haup_xvr;
329 rc_type = RC_TYPE_RC5;
330 ir_codes = hauppauge ? RC_MAP_HAUPPAUGE_NEW : RC_MAP_RC5_TV;
331 break;
324 } 332 }
325 333
326 /* Let the caller override settings */ 334 /* Let the caller override settings */
diff --git a/drivers/media/video/ivtv/ivtv-i2c.c b/drivers/media/video/ivtv/ivtv-i2c.c
index e103b8fc7452..9fb86a081c0f 100644
--- a/drivers/media/video/ivtv/ivtv-i2c.c
+++ b/drivers/media/video/ivtv/ivtv-i2c.c
@@ -300,10 +300,15 @@ int ivtv_i2c_register(struct ivtv *itv, unsigned idx)
300 adap, type, 0, I2C_ADDRS(hw_addrs[idx])); 300 adap, type, 0, I2C_ADDRS(hw_addrs[idx]));
301 } else if (hw == IVTV_HW_CX25840) { 301 } else if (hw == IVTV_HW_CX25840) {
302 struct cx25840_platform_data pdata; 302 struct cx25840_platform_data pdata;
303 struct i2c_board_info cx25840_info = {
304 .type = "cx25840",
305 .addr = hw_addrs[idx],
306 .platform_data = &pdata,
307 };
303 308
304 pdata.pvr150_workaround = itv->pvr150_workaround; 309 pdata.pvr150_workaround = itv->pvr150_workaround;
305 sd = v4l2_i2c_new_subdev_cfg(&itv->v4l2_dev, 310 sd = v4l2_i2c_new_subdev_board(&itv->v4l2_dev, adap,
306 adap, type, 0, &pdata, hw_addrs[idx], NULL); 311 &cx25840_info, NULL);
307 } else { 312 } else {
308 sd = v4l2_i2c_new_subdev(&itv->v4l2_dev, 313 sd = v4l2_i2c_new_subdev(&itv->v4l2_dev,
309 adap, type, hw_addrs[idx], NULL); 314 adap, type, hw_addrs[idx], NULL);
diff --git a/drivers/media/video/mt9v011.c b/drivers/media/video/mt9v011.c
index 209ff97261a9..4904d25f689f 100644
--- a/drivers/media/video/mt9v011.c
+++ b/drivers/media/video/mt9v011.c
@@ -12,17 +12,41 @@
12#include <asm/div64.h> 12#include <asm/div64.h>
13#include <media/v4l2-device.h> 13#include <media/v4l2-device.h>
14#include <media/v4l2-chip-ident.h> 14#include <media/v4l2-chip-ident.h>
15#include "mt9v011.h" 15#include <media/mt9v011.h>
16 16
17MODULE_DESCRIPTION("Micron mt9v011 sensor driver"); 17MODULE_DESCRIPTION("Micron mt9v011 sensor driver");
18MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); 18MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>");
19MODULE_LICENSE("GPL"); 19MODULE_LICENSE("GPL");
20 20
21
22static int debug; 21static int debug;
23module_param(debug, int, 0); 22module_param(debug, int, 0);
24MODULE_PARM_DESC(debug, "Debug level (0-2)"); 23MODULE_PARM_DESC(debug, "Debug level (0-2)");
25 24
25#define R00_MT9V011_CHIP_VERSION 0x00
26#define R01_MT9V011_ROWSTART 0x01
27#define R02_MT9V011_COLSTART 0x02
28#define R03_MT9V011_HEIGHT 0x03
29#define R04_MT9V011_WIDTH 0x04
30#define R05_MT9V011_HBLANK 0x05
31#define R06_MT9V011_VBLANK 0x06
32#define R07_MT9V011_OUT_CTRL 0x07
33#define R09_MT9V011_SHUTTER_WIDTH 0x09
34#define R0A_MT9V011_CLK_SPEED 0x0a
35#define R0B_MT9V011_RESTART 0x0b
36#define R0C_MT9V011_SHUTTER_DELAY 0x0c
37#define R0D_MT9V011_RESET 0x0d
38#define R1E_MT9V011_DIGITAL_ZOOM 0x1e
39#define R20_MT9V011_READ_MODE 0x20
40#define R2B_MT9V011_GREEN_1_GAIN 0x2b
41#define R2C_MT9V011_BLUE_GAIN 0x2c
42#define R2D_MT9V011_RED_GAIN 0x2d
43#define R2E_MT9V011_GREEN_2_GAIN 0x2e
44#define R35_MT9V011_GLOBAL_GAIN 0x35
45#define RF1_MT9V011_CHIP_ENABLE 0xf1
46
47#define MT9V011_VERSION 0x8232
48#define MT9V011_REV_B_VERSION 0x8243
49
26/* supported controls */ 50/* supported controls */
27static struct v4l2_queryctrl mt9v011_qctrl[] = { 51static struct v4l2_queryctrl mt9v011_qctrl[] = {
28 { 52 {
@@ -469,23 +493,6 @@ static int mt9v011_s_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt
469 return 0; 493 return 0;
470} 494}
471 495
472static int mt9v011_s_config(struct v4l2_subdev *sd, int dumb, void *data)
473{
474 struct mt9v011 *core = to_mt9v011(sd);
475 unsigned *xtal = data;
476
477 v4l2_dbg(1, debug, sd, "s_config called\n");
478
479 if (xtal) {
480 core->xtal = *xtal;
481 v4l2_dbg(1, debug, sd, "xtal set to %d.%03d MHz\n",
482 *xtal / 1000000, (*xtal / 1000) % 1000);
483 }
484
485 return 0;
486}
487
488
489#ifdef CONFIG_VIDEO_ADV_DEBUG 496#ifdef CONFIG_VIDEO_ADV_DEBUG
490static int mt9v011_g_register(struct v4l2_subdev *sd, 497static int mt9v011_g_register(struct v4l2_subdev *sd,
491 struct v4l2_dbg_register *reg) 498 struct v4l2_dbg_register *reg)
@@ -536,7 +543,6 @@ static const struct v4l2_subdev_core_ops mt9v011_core_ops = {
536 .g_ctrl = mt9v011_g_ctrl, 543 .g_ctrl = mt9v011_g_ctrl,
537 .s_ctrl = mt9v011_s_ctrl, 544 .s_ctrl = mt9v011_s_ctrl,
538 .reset = mt9v011_reset, 545 .reset = mt9v011_reset,
539 .s_config = mt9v011_s_config,
540 .g_chip_ident = mt9v011_g_chip_ident, 546 .g_chip_ident = mt9v011_g_chip_ident,
541#ifdef CONFIG_VIDEO_ADV_DEBUG 547#ifdef CONFIG_VIDEO_ADV_DEBUG
542 .g_register = mt9v011_g_register, 548 .g_register = mt9v011_g_register,
@@ -596,6 +602,14 @@ static int mt9v011_probe(struct i2c_client *c,
596 core->height = 480; 602 core->height = 480;
597 core->xtal = 27000000; /* Hz */ 603 core->xtal = 27000000; /* Hz */
598 604
605 if (c->dev.platform_data) {
606 struct mt9v011_platform_data *pdata = c->dev.platform_data;
607
608 core->xtal = pdata->xtal;
609 v4l2_dbg(1, debug, sd, "xtal set to %d.%03d MHz\n",
610 core->xtal / 1000000, (core->xtal / 1000) % 1000);
611 }
612
599 v4l_info(c, "chip found @ 0x%02x (%s - chip version 0x%04x)\n", 613 v4l_info(c, "chip found @ 0x%02x (%s - chip version 0x%04x)\n",
600 c->addr << 1, c->adapter->name, version); 614 c->addr << 1, c->adapter->name, version);
601 615
diff --git a/drivers/media/video/mt9v011.h b/drivers/media/video/mt9v011.h
deleted file mode 100644
index 3350fd6083c3..000000000000
--- a/drivers/media/video/mt9v011.h
+++ /dev/null
@@ -1,36 +0,0 @@
1/*
2 * mt9v011 -Micron 1/4-Inch VGA Digital Image Sensor
3 *
4 * Copyright (c) 2009 Mauro Carvalho Chehab (mchehab@redhat.com)
5 * This code is placed under the terms of the GNU General Public License v2
6 */
7
8#ifndef MT9V011_H_
9#define MT9V011_H_
10
11#define R00_MT9V011_CHIP_VERSION 0x00
12#define R01_MT9V011_ROWSTART 0x01
13#define R02_MT9V011_COLSTART 0x02
14#define R03_MT9V011_HEIGHT 0x03
15#define R04_MT9V011_WIDTH 0x04
16#define R05_MT9V011_HBLANK 0x05
17#define R06_MT9V011_VBLANK 0x06
18#define R07_MT9V011_OUT_CTRL 0x07
19#define R09_MT9V011_SHUTTER_WIDTH 0x09
20#define R0A_MT9V011_CLK_SPEED 0x0a
21#define R0B_MT9V011_RESTART 0x0b
22#define R0C_MT9V011_SHUTTER_DELAY 0x0c
23#define R0D_MT9V011_RESET 0x0d
24#define R1E_MT9V011_DIGITAL_ZOOM 0x1e
25#define R20_MT9V011_READ_MODE 0x20
26#define R2B_MT9V011_GREEN_1_GAIN 0x2b
27#define R2C_MT9V011_BLUE_GAIN 0x2c
28#define R2D_MT9V011_RED_GAIN 0x2d
29#define R2E_MT9V011_GREEN_2_GAIN 0x2e
30#define R35_MT9V011_GLOBAL_GAIN 0x35
31#define RF1_MT9V011_CHIP_ENABLE 0xf1
32
33#define MT9V011_VERSION 0x8232
34#define MT9V011_REV_B_VERSION 0x8243
35
36#endif
diff --git a/drivers/media/video/ov7670.c b/drivers/media/video/ov7670.c
index c881a64b41fd..d4e7c11553c3 100644
--- a/drivers/media/video/ov7670.c
+++ b/drivers/media/video/ov7670.c
@@ -1449,47 +1449,6 @@ static int ov7670_g_chip_ident(struct v4l2_subdev *sd,
1449 return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_OV7670, 0); 1449 return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_OV7670, 0);
1450} 1450}
1451 1451
1452static int ov7670_s_config(struct v4l2_subdev *sd, int dumb, void *data)
1453{
1454 struct i2c_client *client = v4l2_get_subdevdata(sd);
1455 struct ov7670_config *config = data;
1456 struct ov7670_info *info = to_state(sd);
1457 int ret;
1458
1459 info->clock_speed = 30; /* default: a guess */
1460
1461 /*
1462 * Must apply configuration before initializing device, because it
1463 * selects I/O method.
1464 */
1465 if (config) {
1466 info->min_width = config->min_width;
1467 info->min_height = config->min_height;
1468 info->use_smbus = config->use_smbus;
1469
1470 if (config->clock_speed)
1471 info->clock_speed = config->clock_speed;
1472 }
1473
1474 /* Make sure it's an ov7670 */
1475 ret = ov7670_detect(sd);
1476 if (ret) {
1477 v4l_dbg(1, debug, client,
1478 "chip found @ 0x%x (%s) is not an ov7670 chip.\n",
1479 client->addr << 1, client->adapter->name);
1480 kfree(info);
1481 return ret;
1482 }
1483 v4l_info(client, "chip found @ 0x%02x (%s)\n",
1484 client->addr << 1, client->adapter->name);
1485
1486 info->fmt = &ov7670_formats[0];
1487 info->sat = 128; /* Review this */
1488 info->clkrc = info->clock_speed / 30;
1489
1490 return 0;
1491}
1492
1493#ifdef CONFIG_VIDEO_ADV_DEBUG 1452#ifdef CONFIG_VIDEO_ADV_DEBUG
1494static int ov7670_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) 1453static int ov7670_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
1495{ 1454{
@@ -1528,7 +1487,6 @@ static const struct v4l2_subdev_core_ops ov7670_core_ops = {
1528 .s_ctrl = ov7670_s_ctrl, 1487 .s_ctrl = ov7670_s_ctrl,
1529 .queryctrl = ov7670_queryctrl, 1488 .queryctrl = ov7670_queryctrl,
1530 .reset = ov7670_reset, 1489 .reset = ov7670_reset,
1531 .s_config = ov7670_s_config,
1532 .init = ov7670_init, 1490 .init = ov7670_init,
1533#ifdef CONFIG_VIDEO_ADV_DEBUG 1491#ifdef CONFIG_VIDEO_ADV_DEBUG
1534 .g_register = ov7670_g_register, 1492 .g_register = ov7670_g_register,
@@ -1558,6 +1516,7 @@ static int ov7670_probe(struct i2c_client *client,
1558{ 1516{
1559 struct v4l2_subdev *sd; 1517 struct v4l2_subdev *sd;
1560 struct ov7670_info *info; 1518 struct ov7670_info *info;
1519 int ret;
1561 1520
1562 info = kzalloc(sizeof(struct ov7670_info), GFP_KERNEL); 1521 info = kzalloc(sizeof(struct ov7670_info), GFP_KERNEL);
1563 if (info == NULL) 1522 if (info == NULL)
@@ -1565,6 +1524,37 @@ static int ov7670_probe(struct i2c_client *client,
1565 sd = &info->sd; 1524 sd = &info->sd;
1566 v4l2_i2c_subdev_init(sd, client, &ov7670_ops); 1525 v4l2_i2c_subdev_init(sd, client, &ov7670_ops);
1567 1526
1527 info->clock_speed = 30; /* default: a guess */
1528 if (client->dev.platform_data) {
1529 struct ov7670_config *config = client->dev.platform_data;
1530
1531 /*
1532 * Must apply configuration before initializing device, because it
1533 * selects I/O method.
1534 */
1535 info->min_width = config->min_width;
1536 info->min_height = config->min_height;
1537 info->use_smbus = config->use_smbus;
1538
1539 if (config->clock_speed)
1540 info->clock_speed = config->clock_speed;
1541 }
1542
1543 /* Make sure it's an ov7670 */
1544 ret = ov7670_detect(sd);
1545 if (ret) {
1546 v4l_dbg(1, debug, client,
1547 "chip found @ 0x%x (%s) is not an ov7670 chip.\n",
1548 client->addr << 1, client->adapter->name);
1549 kfree(info);
1550 return ret;
1551 }
1552 v4l_info(client, "chip found @ 0x%02x (%s)\n",
1553 client->addr << 1, client->adapter->name);
1554
1555 info->fmt = &ov7670_formats[0];
1556 info->sat = 128; /* Review this */
1557 info->clkrc = info->clock_speed / 30;
1568 return 0; 1558 return 0;
1569} 1559}
1570 1560
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
index ac94a8bf883e..305e6aaa844a 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
@@ -40,6 +40,7 @@
40#include "pvrusb2-io.h" 40#include "pvrusb2-io.h"
41#include <media/v4l2-device.h> 41#include <media/v4l2-device.h>
42#include <media/cx2341x.h> 42#include <media/cx2341x.h>
43#include <media/ir-kbd-i2c.h>
43#include "pvrusb2-devattr.h" 44#include "pvrusb2-devattr.h"
44 45
45/* Legal values for PVR2_CID_HSM */ 46/* Legal values for PVR2_CID_HSM */
@@ -202,6 +203,7 @@ struct pvr2_hdw {
202 203
203 /* IR related */ 204 /* IR related */
204 unsigned int ir_scheme_active; /* IR scheme as seen from the outside */ 205 unsigned int ir_scheme_active; /* IR scheme as seen from the outside */
206 struct IR_i2c_init_data ir_init_data; /* params passed to IR modules */
205 207
206 /* Frequency table */ 208 /* Frequency table */
207 unsigned int freqTable[FREQTABLE_SIZE]; 209 unsigned int freqTable[FREQTABLE_SIZE];
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
index 7cbe18c4ca95..ccc884948f34 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
@@ -19,6 +19,7 @@
19 */ 19 */
20 20
21#include <linux/i2c.h> 21#include <linux/i2c.h>
22#include <media/ir-kbd-i2c.h>
22#include "pvrusb2-i2c-core.h" 23#include "pvrusb2-i2c-core.h"
23#include "pvrusb2-hdw-internal.h" 24#include "pvrusb2-hdw-internal.h"
24#include "pvrusb2-debug.h" 25#include "pvrusb2-debug.h"
@@ -48,13 +49,6 @@ module_param_named(disable_autoload_ir_video, pvr2_disable_ir_video,
48MODULE_PARM_DESC(disable_autoload_ir_video, 49MODULE_PARM_DESC(disable_autoload_ir_video,
49 "1=do not try to autoload ir_video IR receiver"); 50 "1=do not try to autoload ir_video IR receiver");
50 51
51/* Mapping of IR schemes to known I2C addresses - if any */
52static const unsigned char ir_video_addresses[] = {
53 [PVR2_IR_SCHEME_ZILOG] = 0x71,
54 [PVR2_IR_SCHEME_29XXX] = 0x18,
55 [PVR2_IR_SCHEME_24XXX] = 0x18,
56};
57
58static int pvr2_i2c_write(struct pvr2_hdw *hdw, /* Context */ 52static int pvr2_i2c_write(struct pvr2_hdw *hdw, /* Context */
59 u8 i2c_addr, /* I2C address we're talking to */ 53 u8 i2c_addr, /* I2C address we're talking to */
60 u8 *data, /* Data to write */ 54 u8 *data, /* Data to write */
@@ -574,26 +568,56 @@ static void do_i2c_scan(struct pvr2_hdw *hdw)
574static void pvr2_i2c_register_ir(struct pvr2_hdw *hdw) 568static void pvr2_i2c_register_ir(struct pvr2_hdw *hdw)
575{ 569{
576 struct i2c_board_info info; 570 struct i2c_board_info info;
577 unsigned char addr = 0; 571 struct IR_i2c_init_data *init_data = &hdw->ir_init_data;
578 if (pvr2_disable_ir_video) { 572 if (pvr2_disable_ir_video) {
579 pvr2_trace(PVR2_TRACE_INFO, 573 pvr2_trace(PVR2_TRACE_INFO,
580 "Automatic binding of ir_video has been disabled."); 574 "Automatic binding of ir_video has been disabled.");
581 return; 575 return;
582 } 576 }
583 if (hdw->ir_scheme_active < ARRAY_SIZE(ir_video_addresses)) { 577 memset(&info, 0, sizeof(struct i2c_board_info));
584 addr = ir_video_addresses[hdw->ir_scheme_active]; 578 switch (hdw->ir_scheme_active) {
585 } 579 case PVR2_IR_SCHEME_24XXX: /* FX2-controlled IR */
586 if (!addr) { 580 case PVR2_IR_SCHEME_29XXX: /* Original 29xxx device */
581 init_data->ir_codes = RC_MAP_HAUPPAUGE_NEW;
582 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP;
583 init_data->type = RC_TYPE_RC5;
584 init_data->name = hdw->hdw_desc->description;
585 init_data->polling_interval = 100; /* ms From ir-kbd-i2c */
586 /* IR Receiver */
587 info.addr = 0x18;
588 info.platform_data = init_data;
589 strlcpy(info.type, "ir_video", I2C_NAME_SIZE);
590 pvr2_trace(PVR2_TRACE_INFO, "Binding %s to i2c address 0x%02x.",
591 info.type, info.addr);
592 i2c_new_device(&hdw->i2c_adap, &info);
593 break;
594 case PVR2_IR_SCHEME_ZILOG: /* HVR-1950 style */
595 case PVR2_IR_SCHEME_24XXX_MCE: /* 24xxx MCE device */
596 init_data->ir_codes = RC_MAP_HAUPPAUGE_NEW;
597 init_data->internal_get_key_func = IR_KBD_GET_KEY_HAUP_XVR;
598 init_data->type = RC_TYPE_RC5;
599 init_data->name = hdw->hdw_desc->description;
600 init_data->polling_interval = 260; /* ms From lirc_zilog */
601 /* IR Receiver */
602 info.addr = 0x71;
603 info.platform_data = init_data;
604 strlcpy(info.type, "ir_rx_z8f0811_haup", I2C_NAME_SIZE);
605 pvr2_trace(PVR2_TRACE_INFO, "Binding %s to i2c address 0x%02x.",
606 info.type, info.addr);
607 i2c_new_device(&hdw->i2c_adap, &info);
608 /* IR Trasmitter */
609 info.addr = 0x70;
610 info.platform_data = init_data;
611 strlcpy(info.type, "ir_tx_z8f0811_haup", I2C_NAME_SIZE);
612 pvr2_trace(PVR2_TRACE_INFO, "Binding %s to i2c address 0x%02x.",
613 info.type, info.addr);
614 i2c_new_device(&hdw->i2c_adap, &info);
615 break;
616 default:
587 /* The device either doesn't support I2C-based IR or we 617 /* The device either doesn't support I2C-based IR or we
588 don't know (yet) how to operate IR on the device. */ 618 don't know (yet) how to operate IR on the device. */
589 return; 619 break;
590 } 620 }
591 pvr2_trace(PVR2_TRACE_INFO,
592 "Binding ir_video to i2c address 0x%02x.", addr);
593 memset(&info, 0, sizeof(struct i2c_board_info));
594 strlcpy(info.type, "ir_video", I2C_NAME_SIZE);
595 info.addr = addr;
596 i2c_new_device(&hdw->i2c_adap, &info);
597} 621}
598 622
599void pvr2_i2c_core_init(struct pvr2_hdw *hdw) 623void pvr2_i2c_core_init(struct pvr2_hdw *hdw)
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c
index e7aa588c6c5a..deb8fcf4aa49 100644
--- a/drivers/media/video/saa7134/saa7134-cards.c
+++ b/drivers/media/video/saa7134/saa7134-cards.c
@@ -5179,18 +5179,8 @@ struct saa7134_board saa7134_boards[] = {
5179 [SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG] = { 5179 [SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG] = {
5180 .name = "Kworld PCI SBTVD/ISDB-T Full-Seg Hybrid", 5180 .name = "Kworld PCI SBTVD/ISDB-T Full-Seg Hybrid",
5181 .audio_clock = 0x00187de7, 5181 .audio_clock = 0x00187de7,
5182#if 0 5182 .tuner_type = TUNER_PHILIPS_TDA8290,
5183 /*
5184 * FIXME: Analog mode doesn't work, if digital is enabled. The proper
5185 * fix is to use tda8290 driver, but Kworld seems to use an
5186 * unsupported version of tda8295.
5187 */
5188 .tuner_type = TUNER_NXP_TDA18271, /* TUNER_PHILIPS_TDA8290 */
5189 .tuner_addr = 0x60,
5190#else
5191 .tuner_type = UNSET,
5192 .tuner_addr = ADDR_UNSET, 5183 .tuner_addr = ADDR_UNSET,
5193#endif
5194 .radio_type = UNSET, 5184 .radio_type = UNSET,
5195 .radio_addr = ADDR_UNSET, 5185 .radio_addr = ADDR_UNSET,
5196 .gpiomask = 0x8e054000, 5186 .gpiomask = 0x8e054000,
@@ -6932,10 +6922,17 @@ static inline int saa7134_kworld_sbtvd_toggle_agc(struct saa7134_dev *dev,
6932 /* toggle AGC switch through GPIO 27 */ 6922 /* toggle AGC switch through GPIO 27 */
6933 switch (mode) { 6923 switch (mode) {
6934 case TDA18271_ANALOG: 6924 case TDA18271_ANALOG:
6935 saa7134_set_gpio(dev, 27, 0); 6925 saa_writel(SAA7134_GPIO_GPMODE0 >> 2, 0x4000);
6926 saa_writel(SAA7134_GPIO_GPSTATUS0 >> 2, 0x4000);
6927 msleep(20);
6936 break; 6928 break;
6937 case TDA18271_DIGITAL: 6929 case TDA18271_DIGITAL:
6938 saa7134_set_gpio(dev, 27, 1); 6930 saa_writel(SAA7134_GPIO_GPMODE0 >> 2, 0x14000);
6931 saa_writel(SAA7134_GPIO_GPSTATUS0 >> 2, 0x14000);
6932 msleep(20);
6933 saa_writel(SAA7134_GPIO_GPMODE0 >> 2, 0x54000);
6934 saa_writel(SAA7134_GPIO_GPSTATUS0 >> 2, 0x54000);
6935 msleep(30);
6939 break; 6936 break;
6940 default: 6937 default:
6941 return -EINVAL; 6938 return -EINVAL;
@@ -6993,6 +6990,7 @@ static int saa7134_tda8290_callback(struct saa7134_dev *dev,
6993int saa7134_tuner_callback(void *priv, int component, int command, int arg) 6990int saa7134_tuner_callback(void *priv, int component, int command, int arg)
6994{ 6991{
6995 struct saa7134_dev *dev = priv; 6992 struct saa7134_dev *dev = priv;
6993
6996 if (dev != NULL) { 6994 if (dev != NULL) {
6997 switch (dev->tuner_type) { 6995 switch (dev->tuner_type) {
6998 case TUNER_PHILIPS_TDA8290: 6996 case TUNER_PHILIPS_TDA8290:
@@ -7659,36 +7657,11 @@ int saa7134_board_init2(struct saa7134_dev *dev)
7659 break; 7657 break;
7660 } 7658 }
7661 case SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG: 7659 case SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG:
7662 {
7663 struct i2c_msg msg = { .addr = 0x4b, .flags = 0 };
7664 int i;
7665 static u8 buffer[][2] = {
7666 {0x30, 0x31},
7667 {0xff, 0x00},
7668 {0x41, 0x03},
7669 {0x41, 0x1a},
7670 {0xff, 0x02},
7671 {0x34, 0x00},
7672 {0x45, 0x97},
7673 {0x45, 0xc1},
7674 };
7675 saa_writel(SAA7134_GPIO_GPMODE0 >> 2, 0x4000); 7660 saa_writel(SAA7134_GPIO_GPMODE0 >> 2, 0x4000);
7676 saa_writel(SAA7134_GPIO_GPSTATUS0 >> 2, 0x4000); 7661 saa_writel(SAA7134_GPIO_GPSTATUS0 >> 2, 0x4000);
7677 7662
7678 /* 7663 saa7134_set_gpio(dev, 27, 0);
7679 * FIXME: identify what device is at addr 0x4b and what means
7680 * this initialization
7681 */
7682 for (i = 0; i < ARRAY_SIZE(buffer); i++) {
7683 msg.buf = &buffer[i][0];
7684 msg.len = ARRAY_SIZE(buffer[0]);
7685 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
7686 printk(KERN_WARNING
7687 "%s: Unable to enable tuner(%i).\n",
7688 dev->name, i);
7689 }
7690 break; 7664 break;
7691 }
7692 } /* switch() */ 7665 } /* switch() */
7693 7666
7694 /* initialize tuner */ 7667 /* initialize tuner */
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index 3315a48a848b..f65cad287b83 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -237,12 +237,39 @@ static struct tda18271_std_map mb86a20s_tda18271_std_map = {
237static struct tda18271_config kworld_tda18271_config = { 237static struct tda18271_config kworld_tda18271_config = {
238 .std_map = &mb86a20s_tda18271_std_map, 238 .std_map = &mb86a20s_tda18271_std_map,
239 .gate = TDA18271_GATE_DIGITAL, 239 .gate = TDA18271_GATE_DIGITAL,
240 .config = 3, /* Use tuner callback for AGC */
241
240}; 242};
241 243
242static const struct mb86a20s_config kworld_mb86a20s_config = { 244static const struct mb86a20s_config kworld_mb86a20s_config = {
243 .demod_address = 0x10, 245 .demod_address = 0x10,
244}; 246};
245 247
248static int kworld_sbtvd_gate_ctrl(struct dvb_frontend* fe, int enable)
249{
250 struct saa7134_dev *dev = fe->dvb->priv;
251
252 unsigned char initmsg[] = {0x45, 0x97};
253 unsigned char msg_enable[] = {0x45, 0xc1};
254 unsigned char msg_disable[] = {0x45, 0x81};
255 struct i2c_msg msg = {.addr = 0x4b, .flags = 0, .buf = initmsg, .len = 2};
256
257 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
258 wprintk("could not access the I2C gate\n");
259 return -EIO;
260 }
261 if (enable)
262 msg.buf = msg_enable;
263 else
264 msg.buf = msg_disable;
265 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
266 wprintk("could not access the I2C gate\n");
267 return -EIO;
268 }
269 msleep(20);
270 return 0;
271}
272
246/* ================================================================== 273/* ==================================================================
247 * tda1004x based DVB-T cards, helper functions 274 * tda1004x based DVB-T cards, helper functions
248 */ 275 */
@@ -623,37 +650,6 @@ static struct tda827x_config tda827x_cfg_2_sw42 = {
623 650
624/* ------------------------------------------------------------------ */ 651/* ------------------------------------------------------------------ */
625 652
626static int __kworld_sbtvd_i2c_gate_ctrl(struct saa7134_dev *dev, int enable)
627{
628 unsigned char initmsg[] = {0x45, 0x97};
629 unsigned char msg_enable[] = {0x45, 0xc1};
630 unsigned char msg_disable[] = {0x45, 0x81};
631 struct i2c_msg msg = {.addr = 0x4b, .flags = 0, .buf = initmsg, .len = 2};
632
633 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
634 wprintk("could not access the I2C gate\n");
635 return -EIO;
636 }
637 if (enable)
638 msg.buf = msg_enable;
639 else
640 msg.buf = msg_disable;
641 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
642 wprintk("could not access the I2C gate\n");
643 return -EIO;
644 }
645 msleep(20);
646 return 0;
647}
648static int kworld_sbtvd_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
649{
650 struct saa7134_dev *dev = fe->dvb->priv;
651
652 return __kworld_sbtvd_i2c_gate_ctrl(dev, enable);
653}
654
655/* ------------------------------------------------------------------ */
656
657static struct tda1004x_config tda827x_lifeview_config = { 653static struct tda1004x_config tda827x_lifeview_config = {
658 .demod_address = 0x08, 654 .demod_address = 0x08,
659 .invert = 1, 655 .invert = 1,
@@ -1660,27 +1656,23 @@ static int dvb_init(struct saa7134_dev *dev)
1660 } 1656 }
1661 break; 1657 break;
1662 case SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG: 1658 case SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG:
1663 __kworld_sbtvd_i2c_gate_ctrl(dev, 0); 1659 /* Switch to digital mode */
1664 saa_writel(SAA7134_GPIO_GPMODE0 >> 2, 0x14000); 1660 saa7134_tuner_callback(dev, 0,
1665 saa_writel(SAA7134_GPIO_GPSTATUS0 >> 2, 0x14000); 1661 TDA18271_CALLBACK_CMD_AGC_ENABLE, 1);
1666 msleep(20);
1667 saa_writel(SAA7134_GPIO_GPMODE0 >> 2, 0x54000);
1668 saa_writel(SAA7134_GPIO_GPSTATUS0 >> 2, 0x54000);
1669 msleep(20);
1670 fe0->dvb.frontend = dvb_attach(mb86a20s_attach, 1662 fe0->dvb.frontend = dvb_attach(mb86a20s_attach,
1671 &kworld_mb86a20s_config, 1663 &kworld_mb86a20s_config,
1672 &dev->i2c_adap); 1664 &dev->i2c_adap);
1673 __kworld_sbtvd_i2c_gate_ctrl(dev, 1);
1674 if (fe0->dvb.frontend != NULL) { 1665 if (fe0->dvb.frontend != NULL) {
1666 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1667 &dev->i2c_adap, 0x4b,
1668 &tda829x_no_probe);
1675 dvb_attach(tda18271_attach, fe0->dvb.frontend, 1669 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1676 0x60, &dev->i2c_adap, 1670 0x60, &dev->i2c_adap,
1677 &kworld_tda18271_config); 1671 &kworld_tda18271_config);
1678 /* 1672 fe0->dvb.frontend->ops.i2c_gate_ctrl = kworld_sbtvd_gate_ctrl;
1679 * Only after success, it can initialize the gate, otherwise
1680 * an OOPS will hit, due to kfree(fe0->dvb.frontend)
1681 */
1682 fe0->dvb.frontend->ops.i2c_gate_ctrl = kworld_sbtvd_i2c_gate_ctrl;
1683 } 1673 }
1674
1675 /* mb86a20s need to use the I2C gateway */
1684 break; 1676 break;
1685 default: 1677 default:
1686 wprintk("Huh? unknown DVB card?\n"); 1678 wprintk("Huh? unknown DVB card?\n");
diff --git a/drivers/media/video/sn9c102/sn9c102_devtable.h b/drivers/media/video/sn9c102/sn9c102_devtable.h
index 41064c7b5ef8..b3d2cc729657 100644
--- a/drivers/media/video/sn9c102/sn9c102_devtable.h
+++ b/drivers/media/video/sn9c102/sn9c102_devtable.h
@@ -47,8 +47,8 @@ static const struct usb_device_id sn9c102_id_table[] = {
47 { SN9C102_USB_DEVICE(0x0c45, 0x6009, BRIDGE_SN9C102), }, 47 { SN9C102_USB_DEVICE(0x0c45, 0x6009, BRIDGE_SN9C102), },
48 { SN9C102_USB_DEVICE(0x0c45, 0x600d, BRIDGE_SN9C102), }, 48 { SN9C102_USB_DEVICE(0x0c45, 0x600d, BRIDGE_SN9C102), },
49/* { SN9C102_USB_DEVICE(0x0c45, 0x6011, BRIDGE_SN9C102), }, OV6650 */ 49/* { SN9C102_USB_DEVICE(0x0c45, 0x6011, BRIDGE_SN9C102), }, OV6650 */
50#endif
51 { SN9C102_USB_DEVICE(0x0c45, 0x6019, BRIDGE_SN9C102), }, 50 { SN9C102_USB_DEVICE(0x0c45, 0x6019, BRIDGE_SN9C102), },
51#endif
52 { SN9C102_USB_DEVICE(0x0c45, 0x6024, BRIDGE_SN9C102), }, 52 { SN9C102_USB_DEVICE(0x0c45, 0x6024, BRIDGE_SN9C102), },
53 { SN9C102_USB_DEVICE(0x0c45, 0x6025, BRIDGE_SN9C102), }, 53 { SN9C102_USB_DEVICE(0x0c45, 0x6025, BRIDGE_SN9C102), },
54#if !defined CONFIG_USB_GSPCA_SONIXB && !defined CONFIG_USB_GSPCA_SONIXB_MODULE 54#if !defined CONFIG_USB_GSPCA_SONIXB && !defined CONFIG_USB_GSPCA_SONIXB_MODULE
@@ -56,78 +56,68 @@ static const struct usb_device_id sn9c102_id_table[] = {
56 { SN9C102_USB_DEVICE(0x0c45, 0x6029, BRIDGE_SN9C102), }, 56 { SN9C102_USB_DEVICE(0x0c45, 0x6029, BRIDGE_SN9C102), },
57 { SN9C102_USB_DEVICE(0x0c45, 0x602a, BRIDGE_SN9C102), }, 57 { SN9C102_USB_DEVICE(0x0c45, 0x602a, BRIDGE_SN9C102), },
58#endif 58#endif
59 { SN9C102_USB_DEVICE(0x0c45, 0x602b, BRIDGE_SN9C102), }, 59 { SN9C102_USB_DEVICE(0x0c45, 0x602b, BRIDGE_SN9C102), }, /* not in sonixb */
60#if !defined CONFIG_USB_GSPCA_SONIXB && !defined CONFIG_USB_GSPCA_SONIXB_MODULE 60#if !defined CONFIG_USB_GSPCA_SONIXB && !defined CONFIG_USB_GSPCA_SONIXB_MODULE
61 { SN9C102_USB_DEVICE(0x0c45, 0x602c, BRIDGE_SN9C102), }, 61 { SN9C102_USB_DEVICE(0x0c45, 0x602c, BRIDGE_SN9C102), },
62/* { SN9C102_USB_DEVICE(0x0c45, 0x602d, BRIDGE_SN9C102), }, HV7131R */ 62/* { SN9C102_USB_DEVICE(0x0c45, 0x602d, BRIDGE_SN9C102), }, HV7131R */
63 { SN9C102_USB_DEVICE(0x0c45, 0x602e, BRIDGE_SN9C102), }, 63 { SN9C102_USB_DEVICE(0x0c45, 0x602e, BRIDGE_SN9C102), },
64#endif 64#endif
65 { SN9C102_USB_DEVICE(0x0c45, 0x6030, BRIDGE_SN9C102), }, 65 { SN9C102_USB_DEVICE(0x0c45, 0x6030, BRIDGE_SN9C102), }, /* not in sonixb */
66 /* SN9C103 */ 66 /* SN9C103 */
67 { SN9C102_USB_DEVICE(0x0c45, 0x6080, BRIDGE_SN9C103), }, 67/* { SN9C102_USB_DEVICE(0x0c45, 0x6080, BRIDGE_SN9C103), }, non existent ? */
68 { SN9C102_USB_DEVICE(0x0c45, 0x6082, BRIDGE_SN9C103), }, 68 { SN9C102_USB_DEVICE(0x0c45, 0x6082, BRIDGE_SN9C103), }, /* not in sonixb */
69#if !defined CONFIG_USB_GSPCA_SONIXB && !defined CONFIG_USB_GSPCA_SONIXB_MODULE
69/* { SN9C102_USB_DEVICE(0x0c45, 0x6083, BRIDGE_SN9C103), }, HY7131D/E */ 70/* { SN9C102_USB_DEVICE(0x0c45, 0x6083, BRIDGE_SN9C103), }, HY7131D/E */
70 { SN9C102_USB_DEVICE(0x0c45, 0x6088, BRIDGE_SN9C103), }, 71/* { SN9C102_USB_DEVICE(0x0c45, 0x6088, BRIDGE_SN9C103), }, non existent ? */
71 { SN9C102_USB_DEVICE(0x0c45, 0x608a, BRIDGE_SN9C103), }, 72/* { SN9C102_USB_DEVICE(0x0c45, 0x608a, BRIDGE_SN9C103), }, non existent ? */
72 { SN9C102_USB_DEVICE(0x0c45, 0x608b, BRIDGE_SN9C103), }, 73/* { SN9C102_USB_DEVICE(0x0c45, 0x608b, BRIDGE_SN9C103), }, non existent ? */
73 { SN9C102_USB_DEVICE(0x0c45, 0x608c, BRIDGE_SN9C103), }, 74 { SN9C102_USB_DEVICE(0x0c45, 0x608c, BRIDGE_SN9C103), },
74/* { SN9C102_USB_DEVICE(0x0c45, 0x608e, BRIDGE_SN9C103), }, CISVF10 */ 75/* { SN9C102_USB_DEVICE(0x0c45, 0x608e, BRIDGE_SN9C103), }, CISVF10 */
75#if !defined CONFIG_USB_GSPCA_SONIXB && !defined CONFIG_USB_GSPCA_SONIXB_MODULE
76 { SN9C102_USB_DEVICE(0x0c45, 0x608f, BRIDGE_SN9C103), }, 76 { SN9C102_USB_DEVICE(0x0c45, 0x608f, BRIDGE_SN9C103), },
77#endif 77/* { SN9C102_USB_DEVICE(0x0c45, 0x60a0, BRIDGE_SN9C103), }, non existent ? */
78 { SN9C102_USB_DEVICE(0x0c45, 0x60a0, BRIDGE_SN9C103), }, 78/* { SN9C102_USB_DEVICE(0x0c45, 0x60a2, BRIDGE_SN9C103), }, non existent ? */
79 { SN9C102_USB_DEVICE(0x0c45, 0x60a2, BRIDGE_SN9C103), }, 79/* { SN9C102_USB_DEVICE(0x0c45, 0x60a3, BRIDGE_SN9C103), }, non existent ? */
80 { SN9C102_USB_DEVICE(0x0c45, 0x60a3, BRIDGE_SN9C103), },
81/* { SN9C102_USB_DEVICE(0x0c45, 0x60a8, BRIDGE_SN9C103), }, PAS106 */ 80/* { SN9C102_USB_DEVICE(0x0c45, 0x60a8, BRIDGE_SN9C103), }, PAS106 */
82/* { SN9C102_USB_DEVICE(0x0c45, 0x60aa, BRIDGE_SN9C103), }, TAS5130 */ 81/* { SN9C102_USB_DEVICE(0x0c45, 0x60aa, BRIDGE_SN9C103), }, TAS5130 */
83/* { SN9C102_USB_DEVICE(0x0c45, 0x60ab, BRIDGE_SN9C103), }, TAS5130 */ 82/* { SN9C102_USB_DEVICE(0x0c45, 0x60ab, BRIDGE_SN9C103), }, TAS5110, non existent */
84 { SN9C102_USB_DEVICE(0x0c45, 0x60ac, BRIDGE_SN9C103), }, 83/* { SN9C102_USB_DEVICE(0x0c45, 0x60ac, BRIDGE_SN9C103), }, non existent ? */
85 { SN9C102_USB_DEVICE(0x0c45, 0x60ae, BRIDGE_SN9C103), }, 84/* { SN9C102_USB_DEVICE(0x0c45, 0x60ae, BRIDGE_SN9C103), }, non existent ? */
86 { SN9C102_USB_DEVICE(0x0c45, 0x60af, BRIDGE_SN9C103), }, 85 { SN9C102_USB_DEVICE(0x0c45, 0x60af, BRIDGE_SN9C103), },
87#if !defined CONFIG_USB_GSPCA_SONIXB && !defined CONFIG_USB_GSPCA_SONIXB_MODULE
88 { SN9C102_USB_DEVICE(0x0c45, 0x60b0, BRIDGE_SN9C103), }, 86 { SN9C102_USB_DEVICE(0x0c45, 0x60b0, BRIDGE_SN9C103), },
87/* { SN9C102_USB_DEVICE(0x0c45, 0x60b2, BRIDGE_SN9C103), }, non existent ? */
88/* { SN9C102_USB_DEVICE(0x0c45, 0x60b3, BRIDGE_SN9C103), }, non existent ? */
89/* { SN9C102_USB_DEVICE(0x0c45, 0x60b8, BRIDGE_SN9C103), }, non existent ? */
90/* { SN9C102_USB_DEVICE(0x0c45, 0x60ba, BRIDGE_SN9C103), }, non existent ? */
91/* { SN9C102_USB_DEVICE(0x0c45, 0x60bb, BRIDGE_SN9C103), }, non existent ? */
92/* { SN9C102_USB_DEVICE(0x0c45, 0x60bc, BRIDGE_SN9C103), }, non existent ? */
93/* { SN9C102_USB_DEVICE(0x0c45, 0x60be, BRIDGE_SN9C103), }, non existent ? */
89#endif 94#endif
90 { SN9C102_USB_DEVICE(0x0c45, 0x60b2, BRIDGE_SN9C103), },
91 { SN9C102_USB_DEVICE(0x0c45, 0x60b3, BRIDGE_SN9C103), },
92 { SN9C102_USB_DEVICE(0x0c45, 0x60b8, BRIDGE_SN9C103), },
93 { SN9C102_USB_DEVICE(0x0c45, 0x60ba, BRIDGE_SN9C103), },
94 { SN9C102_USB_DEVICE(0x0c45, 0x60bb, BRIDGE_SN9C103), },
95 { SN9C102_USB_DEVICE(0x0c45, 0x60bc, BRIDGE_SN9C103), },
96 { SN9C102_USB_DEVICE(0x0c45, 0x60be, BRIDGE_SN9C103), },
97 /* SN9C105 */ 95 /* SN9C105 */
98#if !defined CONFIG_USB_GSPCA_SONIXJ && !defined CONFIG_USB_GSPCA_SONIXJ_MODULE 96#if !defined CONFIG_USB_GSPCA_SONIXJ && !defined CONFIG_USB_GSPCA_SONIXJ_MODULE
99 { SN9C102_USB_DEVICE(0x045e, 0x00f5, BRIDGE_SN9C105), }, 97 { SN9C102_USB_DEVICE(0x045e, 0x00f5, BRIDGE_SN9C105), },
100 { SN9C102_USB_DEVICE(0x045e, 0x00f7, BRIDGE_SN9C105), }, 98 { SN9C102_USB_DEVICE(0x045e, 0x00f7, BRIDGE_SN9C105), },
101 { SN9C102_USB_DEVICE(0x0471, 0x0327, BRIDGE_SN9C105), }, 99 { SN9C102_USB_DEVICE(0x0471, 0x0327, BRIDGE_SN9C105), },
102 { SN9C102_USB_DEVICE(0x0471, 0x0328, BRIDGE_SN9C105), }, 100 { SN9C102_USB_DEVICE(0x0471, 0x0328, BRIDGE_SN9C105), },
103#endif
104 { SN9C102_USB_DEVICE(0x0c45, 0x60c0, BRIDGE_SN9C105), }, 101 { SN9C102_USB_DEVICE(0x0c45, 0x60c0, BRIDGE_SN9C105), },
105 { SN9C102_USB_DEVICE(0x0c45, 0x60c2, BRIDGE_SN9C105), }, 102/* { SN9C102_USB_DEVICE(0x0c45, 0x60c2, BRIDGE_SN9C105), }, PO1030 */
106 { SN9C102_USB_DEVICE(0x0c45, 0x60c8, BRIDGE_SN9C105), }, 103/* { SN9C102_USB_DEVICE(0x0c45, 0x60c8, BRIDGE_SN9C105), }, OM6801 */
107 { SN9C102_USB_DEVICE(0x0c45, 0x60cc, BRIDGE_SN9C105), }, 104/* { SN9C102_USB_DEVICE(0x0c45, 0x60cc, BRIDGE_SN9C105), }, HV7131GP */
108 { SN9C102_USB_DEVICE(0x0c45, 0x60ea, BRIDGE_SN9C105), }, 105/* { SN9C102_USB_DEVICE(0x0c45, 0x60ea, BRIDGE_SN9C105), }, non existent ? */
109 { SN9C102_USB_DEVICE(0x0c45, 0x60ec, BRIDGE_SN9C105), }, 106/* { SN9C102_USB_DEVICE(0x0c45, 0x60ec, BRIDGE_SN9C105), }, MO4000 */
110 { SN9C102_USB_DEVICE(0x0c45, 0x60ef, BRIDGE_SN9C105), }, 107/* { SN9C102_USB_DEVICE(0x0c45, 0x60ef, BRIDGE_SN9C105), }, ICM105C */
111 { SN9C102_USB_DEVICE(0x0c45, 0x60fa, BRIDGE_SN9C105), }, 108/* { SN9C102_USB_DEVICE(0x0c45, 0x60fa, BRIDGE_SN9C105), }, OV7648 */
112 { SN9C102_USB_DEVICE(0x0c45, 0x60fb, BRIDGE_SN9C105), }, 109 { SN9C102_USB_DEVICE(0x0c45, 0x60fb, BRIDGE_SN9C105), },
113 { SN9C102_USB_DEVICE(0x0c45, 0x60fc, BRIDGE_SN9C105), }, 110 { SN9C102_USB_DEVICE(0x0c45, 0x60fc, BRIDGE_SN9C105), },
114 { SN9C102_USB_DEVICE(0x0c45, 0x60fe, BRIDGE_SN9C105), }, 111 { SN9C102_USB_DEVICE(0x0c45, 0x60fe, BRIDGE_SN9C105), },
115 /* SN9C120 */ 112 /* SN9C120 */
116 { SN9C102_USB_DEVICE(0x0458, 0x7025, BRIDGE_SN9C120), }, 113 { SN9C102_USB_DEVICE(0x0458, 0x7025, BRIDGE_SN9C120), },
117#if !defined CONFIG_USB_GSPCA_SONIXJ && !defined CONFIG_USB_GSPCA_SONIXJ_MODULE 114/* { SN9C102_USB_DEVICE(0x0c45, 0x6102, BRIDGE_SN9C120), }, po2030 */
118 { SN9C102_USB_DEVICE(0x0c45, 0x6102, BRIDGE_SN9C120), }, 115/* { SN9C102_USB_DEVICE(0x0c45, 0x6108, BRIDGE_SN9C120), }, om6801 */
119#endif 116/* { SN9C102_USB_DEVICE(0x0c45, 0x610f, BRIDGE_SN9C120), }, S5K53BEB */
120 { SN9C102_USB_DEVICE(0x0c45, 0x6108, BRIDGE_SN9C120), },
121 { SN9C102_USB_DEVICE(0x0c45, 0x610f, BRIDGE_SN9C120), },
122#if !defined CONFIG_USB_GSPCA_SONIXJ && !defined CONFIG_USB_GSPCA_SONIXJ_MODULE
123 { SN9C102_USB_DEVICE(0x0c45, 0x6130, BRIDGE_SN9C120), }, 117 { SN9C102_USB_DEVICE(0x0c45, 0x6130, BRIDGE_SN9C120), },
124#endif
125/* { SN9C102_USB_DEVICE(0x0c45, 0x6138, BRIDGE_SN9C120), }, MO8000 */ 118/* { SN9C102_USB_DEVICE(0x0c45, 0x6138, BRIDGE_SN9C120), }, MO8000 */
126#if !defined CONFIG_USB_GSPCA_SONIXJ && !defined CONFIG_USB_GSPCA_SONIXJ_MODULE
127 { SN9C102_USB_DEVICE(0x0c45, 0x613a, BRIDGE_SN9C120), }, 119 { SN9C102_USB_DEVICE(0x0c45, 0x613a, BRIDGE_SN9C120), },
128#endif
129 { SN9C102_USB_DEVICE(0x0c45, 0x613b, BRIDGE_SN9C120), }, 120 { SN9C102_USB_DEVICE(0x0c45, 0x613b, BRIDGE_SN9C120), },
130#if !defined CONFIG_USB_GSPCA_SONIXJ && !defined CONFIG_USB_GSPCA_SONIXJ_MODULE
131 { SN9C102_USB_DEVICE(0x0c45, 0x613c, BRIDGE_SN9C120), }, 121 { SN9C102_USB_DEVICE(0x0c45, 0x613c, BRIDGE_SN9C120), },
132 { SN9C102_USB_DEVICE(0x0c45, 0x613e, BRIDGE_SN9C120), }, 122 { SN9C102_USB_DEVICE(0x0c45, 0x613e, BRIDGE_SN9C120), },
133#endif 123#endif
diff --git a/drivers/media/video/sr030pc30.c b/drivers/media/video/sr030pc30.c
index 864696b7a006..c901721a1db3 100644
--- a/drivers/media/video/sr030pc30.c
+++ b/drivers/media/video/sr030pc30.c
@@ -714,15 +714,6 @@ static int sr030pc30_base_config(struct v4l2_subdev *sd)
714 return ret; 714 return ret;
715} 715}
716 716
717static int sr030pc30_s_config(struct v4l2_subdev *sd,
718 int irq, void *platform_data)
719{
720 struct sr030pc30_info *info = to_sr030pc30(sd);
721
722 info->pdata = platform_data;
723 return 0;
724}
725
726static int sr030pc30_s_stream(struct v4l2_subdev *sd, int enable) 717static int sr030pc30_s_stream(struct v4l2_subdev *sd, int enable)
727{ 718{
728 return 0; 719 return 0;
@@ -763,7 +754,6 @@ static int sr030pc30_s_power(struct v4l2_subdev *sd, int on)
763} 754}
764 755
765static const struct v4l2_subdev_core_ops sr030pc30_core_ops = { 756static const struct v4l2_subdev_core_ops sr030pc30_core_ops = {
766 .s_config = sr030pc30_s_config,
767 .s_power = sr030pc30_s_power, 757 .s_power = sr030pc30_s_power,
768 .queryctrl = sr030pc30_queryctrl, 758 .queryctrl = sr030pc30_queryctrl,
769 .s_ctrl = sr030pc30_s_ctrl, 759 .s_ctrl = sr030pc30_s_ctrl,
diff --git a/drivers/media/video/tda9875.c b/drivers/media/video/tda9875.c
deleted file mode 100644
index 35b6ff5db319..000000000000
--- a/drivers/media/video/tda9875.c
+++ /dev/null
@@ -1,411 +0,0 @@
1/*
2 * For the TDA9875 chip
3 * (The TDA9875 is used on the Diamond DTV2000 french version
4 * Other cards probably use these chips as well.)
5 * This driver will not complain if used with any
6 * other i2c device with the same address.
7 *
8 * Copyright (c) 2000 Guillaume Delvit based on Gerd Knorr source and
9 * Eric Sandeen
10 * Copyright (c) 2006 Mauro Carvalho Chehab <mchehab@infradead.org>
11 * This code is placed under the terms of the GNU General Public License
12 * Based on tda9855.c by Steve VanDeBogart (vandebo@uclink.berkeley.edu)
13 * Which was based on tda8425.c by Greg Alexander (c) 1998
14 *
15 * OPTIONS:
16 * debug - set to 1 if you'd like to see debug messages
17 *
18 * Revision: 0.1 - original version
19 */
20
21#include <linux/module.h>
22#include <linux/kernel.h>
23#include <linux/string.h>
24#include <linux/timer.h>
25#include <linux/delay.h>
26#include <linux/errno.h>
27#include <linux/slab.h>
28#include <linux/i2c.h>
29#include <linux/videodev2.h>
30#include <media/v4l2-device.h>
31#include <media/i2c-addr.h>
32
33static int debug; /* insmod parameter */
34module_param(debug, int, S_IRUGO | S_IWUSR);
35MODULE_LICENSE("GPL");
36
37
38/* This is a superset of the TDA9875 */
39struct tda9875 {
40 struct v4l2_subdev sd;
41 int rvol, lvol;
42 int bass, treble;
43};
44
45static inline struct tda9875 *to_state(struct v4l2_subdev *sd)
46{
47 return container_of(sd, struct tda9875, sd);
48}
49
50#define dprintk if (debug) printk
51
52/* The TDA9875 is made by Philips Semiconductor
53 * http://www.semiconductors.philips.com
54 * TDA9875: I2C-bus controlled DSP audio processor, FM demodulator
55 *
56 */
57
58 /* subaddresses for TDA9875 */
59#define TDA9875_MUT 0x12 /*General mute (value --> 0b11001100*/
60#define TDA9875_CFG 0x01 /* Config register (value --> 0b00000000 */
61#define TDA9875_DACOS 0x13 /*DAC i/o select (ADC) 0b0000100*/
62#define TDA9875_LOSR 0x16 /*Line output select regirter 0b0100 0001*/
63
64#define TDA9875_CH1V 0x0c /*Channel 1 volume (mute)*/
65#define TDA9875_CH2V 0x0d /*Channel 2 volume (mute)*/
66#define TDA9875_SC1 0x14 /*SCART 1 in (mono)*/
67#define TDA9875_SC2 0x15 /*SCART 2 in (mono)*/
68
69#define TDA9875_ADCIS 0x17 /*ADC input select (mono) 0b0110 000*/
70#define TDA9875_AER 0x19 /*Audio effect (AVL+Pseudo) 0b0000 0110*/
71#define TDA9875_MCS 0x18 /*Main channel select (DAC) 0b0000100*/
72#define TDA9875_MVL 0x1a /* Main volume gauche */
73#define TDA9875_MVR 0x1b /* Main volume droite */
74#define TDA9875_MBA 0x1d /* Main Basse */
75#define TDA9875_MTR 0x1e /* Main treble */
76#define TDA9875_ACS 0x1f /* Auxilary channel select (FM) 0b0000000*/
77#define TDA9875_AVL 0x20 /* Auxilary volume gauche */
78#define TDA9875_AVR 0x21 /* Auxilary volume droite */
79#define TDA9875_ABA 0x22 /* Auxilary Basse */
80#define TDA9875_ATR 0x23 /* Auxilary treble */
81
82#define TDA9875_MSR 0x02 /* Monitor select register */
83#define TDA9875_C1MSB 0x03 /* Carrier 1 (FM) frequency register MSB */
84#define TDA9875_C1MIB 0x04 /* Carrier 1 (FM) frequency register (16-8]b */
85#define TDA9875_C1LSB 0x05 /* Carrier 1 (FM) frequency register LSB */
86#define TDA9875_C2MSB 0x06 /* Carrier 2 (nicam) frequency register MSB */
87#define TDA9875_C2MIB 0x07 /* Carrier 2 (nicam) frequency register (16-8]b */
88#define TDA9875_C2LSB 0x08 /* Carrier 2 (nicam) frequency register LSB */
89#define TDA9875_DCR 0x09 /* Demodulateur configuration regirter*/
90#define TDA9875_DEEM 0x0a /* FM de-emphasis regirter*/
91#define TDA9875_FMAT 0x0b /* FM Matrix regirter*/
92
93/* values */
94#define TDA9875_MUTE_ON 0xff /* general mute */
95#define TDA9875_MUTE_OFF 0xcc /* general no mute */
96
97
98
99/* Begin code */
100
101static int tda9875_write(struct v4l2_subdev *sd, int subaddr, unsigned char val)
102{
103 struct i2c_client *client = v4l2_get_subdevdata(sd);
104 unsigned char buffer[2];
105
106 v4l2_dbg(1, debug, sd, "Writing %d 0x%x\n", subaddr, val);
107 buffer[0] = subaddr;
108 buffer[1] = val;
109 if (2 != i2c_master_send(client, buffer, 2)) {
110 v4l2_warn(sd, "I/O error, trying (write %d 0x%x)\n",
111 subaddr, val);
112 return -1;
113 }
114 return 0;
115}
116
117
118static int i2c_read_register(struct i2c_client *client, int addr, int reg)
119{
120 unsigned char write[1];
121 unsigned char read[1];
122 struct i2c_msg msgs[2] = {
123 { addr, 0, 1, write },
124 { addr, I2C_M_RD, 1, read }
125 };
126
127 write[0] = reg;
128
129 if (2 != i2c_transfer(client->adapter, msgs, 2)) {
130 v4l_warn(client, "I/O error (read2)\n");
131 return -1;
132 }
133 v4l_dbg(1, debug, client, "chip_read2: reg%d=0x%x\n", reg, read[0]);
134 return read[0];
135}
136
137static void tda9875_set(struct v4l2_subdev *sd)
138{
139 struct tda9875 *tda = to_state(sd);
140 unsigned char a;
141
142 v4l2_dbg(1, debug, sd, "tda9875_set(%04x,%04x,%04x,%04x)\n",
143 tda->lvol, tda->rvol, tda->bass, tda->treble);
144
145 a = tda->lvol & 0xff;
146 tda9875_write(sd, TDA9875_MVL, a);
147 a =tda->rvol & 0xff;
148 tda9875_write(sd, TDA9875_MVR, a);
149 a =tda->bass & 0xff;
150 tda9875_write(sd, TDA9875_MBA, a);
151 a =tda->treble & 0xff;
152 tda9875_write(sd, TDA9875_MTR, a);
153}
154
155static void do_tda9875_init(struct v4l2_subdev *sd)
156{
157 struct tda9875 *t = to_state(sd);
158
159 v4l2_dbg(1, debug, sd, "In tda9875_init\n");
160 tda9875_write(sd, TDA9875_CFG, 0xd0); /*reg de config 0 (reset)*/
161 tda9875_write(sd, TDA9875_MSR, 0x03); /* Monitor 0b00000XXX*/
162 tda9875_write(sd, TDA9875_C1MSB, 0x00); /*Car1(FM) MSB XMHz*/
163 tda9875_write(sd, TDA9875_C1MIB, 0x00); /*Car1(FM) MIB XMHz*/
164 tda9875_write(sd, TDA9875_C1LSB, 0x00); /*Car1(FM) LSB XMHz*/
165 tda9875_write(sd, TDA9875_C2MSB, 0x00); /*Car2(NICAM) MSB XMHz*/
166 tda9875_write(sd, TDA9875_C2MIB, 0x00); /*Car2(NICAM) MIB XMHz*/
167 tda9875_write(sd, TDA9875_C2LSB, 0x00); /*Car2(NICAM) LSB XMHz*/
168 tda9875_write(sd, TDA9875_DCR, 0x00); /*Demod config 0x00*/
169 tda9875_write(sd, TDA9875_DEEM, 0x44); /*DE-Emph 0b0100 0100*/
170 tda9875_write(sd, TDA9875_FMAT, 0x00); /*FM Matrix reg 0x00*/
171 tda9875_write(sd, TDA9875_SC1, 0x00); /* SCART 1 (SC1)*/
172 tda9875_write(sd, TDA9875_SC2, 0x01); /* SCART 2 (sc2)*/
173
174 tda9875_write(sd, TDA9875_CH1V, 0x10); /* Channel volume 1 mute*/
175 tda9875_write(sd, TDA9875_CH2V, 0x10); /* Channel volume 2 mute */
176 tda9875_write(sd, TDA9875_DACOS, 0x02); /* sig DAC i/o(in:nicam)*/
177 tda9875_write(sd, TDA9875_ADCIS, 0x6f); /* sig ADC input(in:mono)*/
178 tda9875_write(sd, TDA9875_LOSR, 0x00); /* line out (in:mono)*/
179 tda9875_write(sd, TDA9875_AER, 0x00); /*06 Effect (AVL+PSEUDO) */
180 tda9875_write(sd, TDA9875_MCS, 0x44); /* Main ch select (DAC) */
181 tda9875_write(sd, TDA9875_MVL, 0x03); /* Vol Main left 10dB */
182 tda9875_write(sd, TDA9875_MVR, 0x03); /* Vol Main right 10dB*/
183 tda9875_write(sd, TDA9875_MBA, 0x00); /* Main Bass Main 0dB*/
184 tda9875_write(sd, TDA9875_MTR, 0x00); /* Main Treble Main 0dB*/
185 tda9875_write(sd, TDA9875_ACS, 0x44); /* Aux chan select (dac)*/
186 tda9875_write(sd, TDA9875_AVL, 0x00); /* Vol Aux left 0dB*/
187 tda9875_write(sd, TDA9875_AVR, 0x00); /* Vol Aux right 0dB*/
188 tda9875_write(sd, TDA9875_ABA, 0x00); /* Aux Bass Main 0dB*/
189 tda9875_write(sd, TDA9875_ATR, 0x00); /* Aux Aigus Main 0dB*/
190
191 tda9875_write(sd, TDA9875_MUT, 0xcc); /* General mute */
192
193 t->lvol = t->rvol = 0; /* 0dB */
194 t->bass = 0; /* 0dB */
195 t->treble = 0; /* 0dB */
196 tda9875_set(sd);
197}
198
199
200static int tda9875_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
201{
202 struct tda9875 *t = to_state(sd);
203
204 switch (ctrl->id) {
205 case V4L2_CID_AUDIO_VOLUME:
206 {
207 int left = (t->lvol+84)*606;
208 int right = (t->rvol+84)*606;
209
210 ctrl->value=max(left,right);
211 return 0;
212 }
213 case V4L2_CID_AUDIO_BALANCE:
214 {
215 int left = (t->lvol+84)*606;
216 int right = (t->rvol+84)*606;
217 int volume = max(left,right);
218 int balance = (32768*min(left,right))/
219 (volume ? volume : 1);
220 ctrl->value=(left<right)?
221 (65535-balance) : balance;
222 return 0;
223 }
224 case V4L2_CID_AUDIO_BASS:
225 ctrl->value = (t->bass+12)*2427; /* min -12 max +15 */
226 return 0;
227 case V4L2_CID_AUDIO_TREBLE:
228 ctrl->value = (t->treble+12)*2730;/* min -12 max +12 */
229 return 0;
230 }
231 return -EINVAL;
232}
233
234static int tda9875_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
235{
236 struct tda9875 *t = to_state(sd);
237 int chvol = 0, volume = 0, balance = 0, left, right;
238
239 switch (ctrl->id) {
240 case V4L2_CID_AUDIO_VOLUME:
241 left = (t->lvol+84)*606;
242 right = (t->rvol+84)*606;
243
244 volume = max(left,right);
245 balance = (32768*min(left,right))/
246 (volume ? volume : 1);
247 balance =(left<right)?
248 (65535-balance) : balance;
249
250 volume = ctrl->value;
251
252 chvol=1;
253 break;
254 case V4L2_CID_AUDIO_BALANCE:
255 left = (t->lvol+84)*606;
256 right = (t->rvol+84)*606;
257
258 volume=max(left,right);
259
260 balance = ctrl->value;
261
262 chvol=1;
263 break;
264 case V4L2_CID_AUDIO_BASS:
265 t->bass = ((ctrl->value/2400)-12) & 0xff;
266 if (t->bass > 15)
267 t->bass = 15;
268 if (t->bass < -12)
269 t->bass = -12 & 0xff;
270 break;
271 case V4L2_CID_AUDIO_TREBLE:
272 t->treble = ((ctrl->value/2700)-12) & 0xff;
273 if (t->treble > 12)
274 t->treble = 12;
275 if (t->treble < -12)
276 t->treble = -12 & 0xff;
277 break;
278 default:
279 return -EINVAL;
280 }
281
282 if (chvol) {
283 left = (min(65536 - balance,32768) *
284 volume) / 32768;
285 right = (min(balance,32768) *
286 volume) / 32768;
287 t->lvol = ((left/606)-84) & 0xff;
288 if (t->lvol > 24)
289 t->lvol = 24;
290 if (t->lvol < -84)
291 t->lvol = -84 & 0xff;
292
293 t->rvol = ((right/606)-84) & 0xff;
294 if (t->rvol > 24)
295 t->rvol = 24;
296 if (t->rvol < -84)
297 t->rvol = -84 & 0xff;
298 }
299
300 tda9875_set(sd);
301 return 0;
302}
303
304static int tda9875_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc)
305{
306 switch (qc->id) {
307 case V4L2_CID_AUDIO_VOLUME:
308 return v4l2_ctrl_query_fill(qc, 0, 65535, 65535 / 100, 58880);
309 case V4L2_CID_AUDIO_BASS:
310 case V4L2_CID_AUDIO_TREBLE:
311 return v4l2_ctrl_query_fill(qc, 0, 65535, 65535 / 100, 32768);
312 }
313 return -EINVAL;
314}
315
316/* ----------------------------------------------------------------------- */
317
318static const struct v4l2_subdev_core_ops tda9875_core_ops = {
319 .queryctrl = tda9875_queryctrl,
320 .g_ctrl = tda9875_g_ctrl,
321 .s_ctrl = tda9875_s_ctrl,
322};
323
324static const struct v4l2_subdev_ops tda9875_ops = {
325 .core = &tda9875_core_ops,
326};
327
328/* ----------------------------------------------------------------------- */
329
330
331/* *********************** *
332 * i2c interface functions *
333 * *********************** */
334
335static int tda9875_checkit(struct i2c_client *client, int addr)
336{
337 int dic, rev;
338
339 dic = i2c_read_register(client, addr, 254);
340 rev = i2c_read_register(client, addr, 255);
341
342 if (dic == 0 || dic == 2) { /* tda9875 and tda9875A */
343 v4l_info(client, "tda9875%s rev. %d detected at 0x%02x\n",
344 dic == 0 ? "" : "A", rev, addr << 1);
345 return 1;
346 }
347 v4l_info(client, "no such chip at 0x%02x (dic=0x%x rev=0x%x)\n",
348 addr << 1, dic, rev);
349 return 0;
350}
351
352static int tda9875_probe(struct i2c_client *client,
353 const struct i2c_device_id *id)
354{
355 struct tda9875 *t;
356 struct v4l2_subdev *sd;
357
358 v4l_info(client, "chip found @ 0x%02x (%s)\n",
359 client->addr << 1, client->adapter->name);
360
361 if (!tda9875_checkit(client, client->addr))
362 return -ENODEV;
363
364 t = kzalloc(sizeof(*t), GFP_KERNEL);
365 if (!t)
366 return -ENOMEM;
367 sd = &t->sd;
368 v4l2_i2c_subdev_init(sd, client, &tda9875_ops);
369
370 do_tda9875_init(sd);
371 return 0;
372}
373
374static int tda9875_remove(struct i2c_client *client)
375{
376 struct v4l2_subdev *sd = i2c_get_clientdata(client);
377
378 do_tda9875_init(sd);
379 v4l2_device_unregister_subdev(sd);
380 kfree(to_state(sd));
381 return 0;
382}
383
384static const struct i2c_device_id tda9875_id[] = {
385 { "tda9875", 0 },
386 { }
387};
388MODULE_DEVICE_TABLE(i2c, tda9875_id);
389
390static struct i2c_driver tda9875_driver = {
391 .driver = {
392 .owner = THIS_MODULE,
393 .name = "tda9875",
394 },
395 .probe = tda9875_probe,
396 .remove = tda9875_remove,
397 .id_table = tda9875_id,
398};
399
400static __init int init_tda9875(void)
401{
402 return i2c_add_driver(&tda9875_driver);
403}
404
405static __exit void exit_tda9875(void)
406{
407 i2c_del_driver(&tda9875_driver);
408}
409
410module_init(init_tda9875);
411module_exit(exit_tda9875);
diff --git a/drivers/media/video/tlg2300/pd-video.c b/drivers/media/video/tlg2300/pd-video.c
index a1ffe18640fe..df33a1d188bb 100644
--- a/drivers/media/video/tlg2300/pd-video.c
+++ b/drivers/media/video/tlg2300/pd-video.c
@@ -512,19 +512,20 @@ int alloc_bulk_urbs_generic(struct urb **urb_array, int num,
512 int buf_size, gfp_t gfp_flags, 512 int buf_size, gfp_t gfp_flags,
513 usb_complete_t complete_fn, void *context) 513 usb_complete_t complete_fn, void *context)
514{ 514{
515 struct urb *urb; 515 int i = 0;
516 void *mem;
517 int i;
518 516
519 for (i = 0; i < num; i++) { 517 for (; i < num; i++) {
520 urb = usb_alloc_urb(0, gfp_flags); 518 void *mem;
519 struct urb *urb = usb_alloc_urb(0, gfp_flags);
521 if (urb == NULL) 520 if (urb == NULL)
522 return i; 521 return i;
523 522
524 mem = usb_alloc_coherent(udev, buf_size, gfp_flags, 523 mem = usb_alloc_coherent(udev, buf_size, gfp_flags,
525 &urb->transfer_dma); 524 &urb->transfer_dma);
526 if (mem == NULL) 525 if (mem == NULL) {
526 usb_free_urb(urb);
527 return i; 527 return i;
528 }
528 529
529 usb_fill_bulk_urb(urb, udev, usb_rcvbulkpipe(udev, ep_addr), 530 usb_fill_bulk_urb(urb, udev, usb_rcvbulkpipe(udev, ep_addr),
530 mem, buf_size, complete_fn, context); 531 mem, buf_size, complete_fn, context);
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c
index 3f0871b550ad..810eef43c216 100644
--- a/drivers/media/video/v4l2-common.c
+++ b/drivers/media/video/v4l2-common.c
@@ -407,18 +407,6 @@ struct v4l2_subdev *v4l2_i2c_new_subdev_board(struct v4l2_device *v4l2_dev,
407 /* Decrease the module use count to match the first try_module_get. */ 407 /* Decrease the module use count to match the first try_module_get. */
408 module_put(client->driver->driver.owner); 408 module_put(client->driver->driver.owner);
409 409
410 if (sd) {
411 /* We return errors from v4l2_subdev_call only if we have the
412 callback as the .s_config is not mandatory */
413 int err = v4l2_subdev_call(sd, core, s_config,
414 info->irq, info->platform_data);
415
416 if (err && err != -ENOIOCTLCMD) {
417 v4l2_device_unregister_subdev(sd);
418 sd = NULL;
419 }
420 }
421
422error: 410error:
423 /* If we have a client but no subdev, then something went wrong and 411 /* If we have a client but no subdev, then something went wrong and
424 we must unregister the client. */ 412 we must unregister the client. */
@@ -428,9 +416,8 @@ error:
428} 416}
429EXPORT_SYMBOL_GPL(v4l2_i2c_new_subdev_board); 417EXPORT_SYMBOL_GPL(v4l2_i2c_new_subdev_board);
430 418
431struct v4l2_subdev *v4l2_i2c_new_subdev_cfg(struct v4l2_device *v4l2_dev, 419struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev,
432 struct i2c_adapter *adapter, const char *client_type, 420 struct i2c_adapter *adapter, const char *client_type,
433 int irq, void *platform_data,
434 u8 addr, const unsigned short *probe_addrs) 421 u8 addr, const unsigned short *probe_addrs)
435{ 422{
436 struct i2c_board_info info; 423 struct i2c_board_info info;
@@ -440,12 +427,10 @@ struct v4l2_subdev *v4l2_i2c_new_subdev_cfg(struct v4l2_device *v4l2_dev,
440 memset(&info, 0, sizeof(info)); 427 memset(&info, 0, sizeof(info));
441 strlcpy(info.type, client_type, sizeof(info.type)); 428 strlcpy(info.type, client_type, sizeof(info.type));
442 info.addr = addr; 429 info.addr = addr;
443 info.irq = irq;
444 info.platform_data = platform_data;
445 430
446 return v4l2_i2c_new_subdev_board(v4l2_dev, adapter, &info, probe_addrs); 431 return v4l2_i2c_new_subdev_board(v4l2_dev, adapter, &info, probe_addrs);
447} 432}
448EXPORT_SYMBOL_GPL(v4l2_i2c_new_subdev_cfg); 433EXPORT_SYMBOL_GPL(v4l2_i2c_new_subdev);
449 434
450/* Return i2c client address of v4l2_subdev. */ 435/* Return i2c client address of v4l2_subdev. */
451unsigned short v4l2_i2c_subdev_addr(struct v4l2_subdev *sd) 436unsigned short v4l2_i2c_subdev_addr(struct v4l2_subdev *sd)
diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index 8f81efcfcf56..ef66d2af0c57 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -569,7 +569,7 @@ static int user_to_new(struct v4l2_ext_control *c,
569 int ret; 569 int ret;
570 u32 size; 570 u32 size;
571 571
572 ctrl->has_new = 1; 572 ctrl->is_new = 1;
573 switch (ctrl->type) { 573 switch (ctrl->type) {
574 case V4L2_CTRL_TYPE_INTEGER64: 574 case V4L2_CTRL_TYPE_INTEGER64:
575 ctrl->val64 = c->value64; 575 ctrl->val64 = c->value64;
@@ -1280,8 +1280,12 @@ int v4l2_ctrl_handler_setup(struct v4l2_ctrl_handler *hdl)
1280 if (ctrl->done) 1280 if (ctrl->done)
1281 continue; 1281 continue;
1282 1282
1283 for (i = 0; i < master->ncontrols; i++) 1283 for (i = 0; i < master->ncontrols; i++) {
1284 cur_to_new(master->cluster[i]); 1284 if (master->cluster[i]) {
1285 cur_to_new(master->cluster[i]);
1286 master->cluster[i]->is_new = 1;
1287 }
1288 }
1285 1289
1286 /* Skip button controls and read-only controls. */ 1290 /* Skip button controls and read-only controls. */
1287 if (ctrl->type == V4L2_CTRL_TYPE_BUTTON || 1291 if (ctrl->type == V4L2_CTRL_TYPE_BUTTON ||
@@ -1340,12 +1344,15 @@ int v4l2_queryctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_queryctrl *qc)
1340 1344
1341 ctrl = ref->ctrl; 1345 ctrl = ref->ctrl;
1342 memset(qc, 0, sizeof(*qc)); 1346 memset(qc, 0, sizeof(*qc));
1343 qc->id = ctrl->id; 1347 if (id >= V4L2_CID_PRIVATE_BASE)
1348 qc->id = id;
1349 else
1350 qc->id = ctrl->id;
1344 strlcpy(qc->name, ctrl->name, sizeof(qc->name)); 1351 strlcpy(qc->name, ctrl->name, sizeof(qc->name));
1345 qc->minimum = ctrl->minimum; 1352 qc->minimum = ctrl->minimum;
1346 qc->maximum = ctrl->maximum; 1353 qc->maximum = ctrl->maximum;
1347 qc->default_value = ctrl->default_value; 1354 qc->default_value = ctrl->default_value;
1348 if (qc->type == V4L2_CTRL_TYPE_MENU) 1355 if (ctrl->type == V4L2_CTRL_TYPE_MENU)
1349 qc->step = 1; 1356 qc->step = 1;
1350 else 1357 else
1351 qc->step = ctrl->step; 1358 qc->step = ctrl->step;
@@ -1645,7 +1652,7 @@ static int try_or_set_control_cluster(struct v4l2_ctrl *master, bool set)
1645 if (ctrl == NULL) 1652 if (ctrl == NULL)
1646 continue; 1653 continue;
1647 1654
1648 if (ctrl->has_new) { 1655 if (ctrl->is_new) {
1649 /* Double check this: it may have changed since the 1656 /* Double check this: it may have changed since the
1650 last check in try_or_set_ext_ctrls(). */ 1657 last check in try_or_set_ext_ctrls(). */
1651 if (set && (ctrl->flags & V4L2_CTRL_FLAG_GRABBED)) 1658 if (set && (ctrl->flags & V4L2_CTRL_FLAG_GRABBED))
@@ -1719,13 +1726,13 @@ static int try_or_set_ext_ctrls(struct v4l2_ctrl_handler *hdl,
1719 1726
1720 v4l2_ctrl_lock(ctrl); 1727 v4l2_ctrl_lock(ctrl);
1721 1728
1722 /* Reset the 'has_new' flags of the cluster */ 1729 /* Reset the 'is_new' flags of the cluster */
1723 for (j = 0; j < master->ncontrols; j++) 1730 for (j = 0; j < master->ncontrols; j++)
1724 if (master->cluster[j]) 1731 if (master->cluster[j])
1725 master->cluster[j]->has_new = 0; 1732 master->cluster[j]->is_new = 0;
1726 1733
1727 /* Copy the new caller-supplied control values. 1734 /* Copy the new caller-supplied control values.
1728 user_to_new() sets 'has_new' to 1. */ 1735 user_to_new() sets 'is_new' to 1. */
1729 ret = cluster_walk(i, cs, helpers, user_to_new); 1736 ret = cluster_walk(i, cs, helpers, user_to_new);
1730 1737
1731 if (!ret) 1738 if (!ret)
@@ -1820,15 +1827,18 @@ static int set_ctrl(struct v4l2_ctrl *ctrl, s32 *val)
1820 int ret; 1827 int ret;
1821 int i; 1828 int i;
1822 1829
1830 if (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY)
1831 return -EACCES;
1832
1823 v4l2_ctrl_lock(ctrl); 1833 v4l2_ctrl_lock(ctrl);
1824 1834
1825 /* Reset the 'has_new' flags of the cluster */ 1835 /* Reset the 'is_new' flags of the cluster */
1826 for (i = 0; i < master->ncontrols; i++) 1836 for (i = 0; i < master->ncontrols; i++)
1827 if (master->cluster[i]) 1837 if (master->cluster[i])
1828 master->cluster[i]->has_new = 0; 1838 master->cluster[i]->is_new = 0;
1829 1839
1830 ctrl->val = *val; 1840 ctrl->val = *val;
1831 ctrl->has_new = 1; 1841 ctrl->is_new = 1;
1832 ret = try_or_set_control_cluster(master, false); 1842 ret = try_or_set_control_cluster(master, false);
1833 if (!ret) 1843 if (!ret)
1834 ret = try_or_set_control_cluster(master, true); 1844 ret = try_or_set_control_cluster(master, true);
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
index 359e23290a7e..341764a3a990 100644
--- a/drivers/media/video/v4l2-dev.c
+++ b/drivers/media/video/v4l2-dev.c
@@ -419,6 +419,10 @@ static int get_index(struct video_device *vdev)
419 * The registration code assigns minor numbers and device node numbers 419 * The registration code assigns minor numbers and device node numbers
420 * based on the requested type and registers the new device node with 420 * based on the requested type and registers the new device node with
421 * the kernel. 421 * the kernel.
422 *
423 * This function assumes that struct video_device was zeroed when it
424 * was allocated and does not contain any stale date.
425 *
422 * An error is returned if no free minor or device node number could be 426 * An error is returned if no free minor or device node number could be
423 * found, or if the registration of the device node failed. 427 * found, or if the registration of the device node failed.
424 * 428 *
@@ -440,7 +444,6 @@ static int __video_register_device(struct video_device *vdev, int type, int nr,
440 int minor_offset = 0; 444 int minor_offset = 0;
441 int minor_cnt = VIDEO_NUM_DEVICES; 445 int minor_cnt = VIDEO_NUM_DEVICES;
442 const char *name_base; 446 const char *name_base;
443 void *priv = vdev->dev.p;
444 447
445 /* A minor value of -1 marks this video device as never 448 /* A minor value of -1 marks this video device as never
446 having been registered */ 449 having been registered */
@@ -559,10 +562,6 @@ static int __video_register_device(struct video_device *vdev, int type, int nr,
559 } 562 }
560 563
561 /* Part 4: register the device with sysfs */ 564 /* Part 4: register the device with sysfs */
562 memset(&vdev->dev, 0, sizeof(vdev->dev));
563 /* The memset above cleared the device's device_private, so
564 put back the copy we made earlier. */
565 vdev->dev.p = priv;
566 vdev->dev.class = &video_class; 565 vdev->dev.class = &video_class;
567 vdev->dev.devt = MKDEV(VIDEO_MAJOR, vdev->minor); 566 vdev->dev.devt = MKDEV(VIDEO_MAJOR, vdev->minor);
568 if (vdev->parent) 567 if (vdev->parent)
diff --git a/drivers/media/video/v4l2-device.c b/drivers/media/video/v4l2-device.c
index 7fe6f92af480..ce64fe16bc60 100644
--- a/drivers/media/video/v4l2-device.c
+++ b/drivers/media/video/v4l2-device.c
@@ -100,6 +100,7 @@ void v4l2_device_unregister(struct v4l2_device *v4l2_dev)
100 is a platform bus, then it is never deleted. */ 100 is a platform bus, then it is never deleted. */
101 if (client) 101 if (client)
102 i2c_unregister_device(client); 102 i2c_unregister_device(client);
103 continue;
103 } 104 }
104#endif 105#endif
105#if defined(CONFIG_SPI) 106#if defined(CONFIG_SPI)
@@ -108,6 +109,7 @@ void v4l2_device_unregister(struct v4l2_device *v4l2_dev)
108 109
109 if (spi) 110 if (spi)
110 spi_unregister_device(spi); 111 spi_unregister_device(spi);
112 continue;
111 } 113 }
112#endif 114#endif
113 } 115 }
@@ -126,11 +128,19 @@ int v4l2_device_register_subdev(struct v4l2_device *v4l2_dev,
126 WARN_ON(sd->v4l2_dev != NULL); 128 WARN_ON(sd->v4l2_dev != NULL);
127 if (!try_module_get(sd->owner)) 129 if (!try_module_get(sd->owner))
128 return -ENODEV; 130 return -ENODEV;
131 sd->v4l2_dev = v4l2_dev;
132 if (sd->internal_ops && sd->internal_ops->registered) {
133 err = sd->internal_ops->registered(sd);
134 if (err)
135 return err;
136 }
129 /* This just returns 0 if either of the two args is NULL */ 137 /* This just returns 0 if either of the two args is NULL */
130 err = v4l2_ctrl_add_handler(v4l2_dev->ctrl_handler, sd->ctrl_handler); 138 err = v4l2_ctrl_add_handler(v4l2_dev->ctrl_handler, sd->ctrl_handler);
131 if (err) 139 if (err) {
140 if (sd->internal_ops && sd->internal_ops->unregistered)
141 sd->internal_ops->unregistered(sd);
132 return err; 142 return err;
133 sd->v4l2_dev = v4l2_dev; 143 }
134 spin_lock(&v4l2_dev->lock); 144 spin_lock(&v4l2_dev->lock);
135 list_add_tail(&sd->list, &v4l2_dev->subdevs); 145 list_add_tail(&sd->list, &v4l2_dev->subdevs);
136 spin_unlock(&v4l2_dev->lock); 146 spin_unlock(&v4l2_dev->lock);
@@ -146,6 +156,8 @@ void v4l2_device_unregister_subdev(struct v4l2_subdev *sd)
146 spin_lock(&sd->v4l2_dev->lock); 156 spin_lock(&sd->v4l2_dev->lock);
147 list_del(&sd->list); 157 list_del(&sd->list);
148 spin_unlock(&sd->v4l2_dev->lock); 158 spin_unlock(&sd->v4l2_dev->lock);
159 if (sd->internal_ops && sd->internal_ops->unregistered)
160 sd->internal_ops->unregistered(sd);
149 sd->v4l2_dev = NULL; 161 sd->v4l2_dev = NULL;
150 module_put(sd->owner); 162 module_put(sd->owner);
151} 163}
diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c
index 7e47f15f350d..f51327ef6757 100644
--- a/drivers/media/video/v4l2-ioctl.c
+++ b/drivers/media/video/v4l2-ioctl.c
@@ -1659,20 +1659,24 @@ static long __video_do_ioctl(struct file *file,
1659 { 1659 {
1660 struct v4l2_dbg_register *p = arg; 1660 struct v4l2_dbg_register *p = arg;
1661 1661
1662 if (!capable(CAP_SYS_ADMIN)) 1662 if (ops->vidioc_g_register) {
1663 ret = -EPERM; 1663 if (!capable(CAP_SYS_ADMIN))
1664 else if (ops->vidioc_g_register) 1664 ret = -EPERM;
1665 ret = ops->vidioc_g_register(file, fh, p); 1665 else
1666 ret = ops->vidioc_g_register(file, fh, p);
1667 }
1666 break; 1668 break;
1667 } 1669 }
1668 case VIDIOC_DBG_S_REGISTER: 1670 case VIDIOC_DBG_S_REGISTER:
1669 { 1671 {
1670 struct v4l2_dbg_register *p = arg; 1672 struct v4l2_dbg_register *p = arg;
1671 1673
1672 if (!capable(CAP_SYS_ADMIN)) 1674 if (ops->vidioc_s_register) {
1673 ret = -EPERM; 1675 if (!capable(CAP_SYS_ADMIN))
1674 else if (ops->vidioc_s_register) 1676 ret = -EPERM;
1675 ret = ops->vidioc_s_register(file, fh, p); 1677 else
1678 ret = ops->vidioc_s_register(file, fh, p);
1679 }
1676 break; 1680 break;
1677 } 1681 }
1678#endif 1682#endif
diff --git a/drivers/media/video/w9966.c b/drivers/media/video/w9966.c
index 019ee206cbee..fa35639d0c15 100644
--- a/drivers/media/video/w9966.c
+++ b/drivers/media/video/w9966.c
@@ -937,6 +937,7 @@ static void w9966_term(struct w9966 *cam)
937 parport_unregister_device(cam->pdev); 937 parport_unregister_device(cam->pdev);
938 w9966_set_state(cam, W9966_STATE_PDEV, 0); 938 w9966_set_state(cam, W9966_STATE_PDEV, 0);
939 } 939 }
940 memset(cam, 0, sizeof(*cam));
940} 941}
941 942
942 943
diff --git a/drivers/media/video/zoran/zoran_card.c b/drivers/media/video/zoran/zoran_card.c
index 9cdc3bb15b15..9f2bac519647 100644
--- a/drivers/media/video/zoran/zoran_card.c
+++ b/drivers/media/video/zoran/zoran_card.c
@@ -1041,7 +1041,7 @@ zr36057_init (struct zoran *zr)
1041 /* allocate memory *before* doing anything to the hardware 1041 /* allocate memory *before* doing anything to the hardware
1042 * in case allocation fails */ 1042 * in case allocation fails */
1043 zr->stat_com = kzalloc(BUZ_NUM_STAT_COM * 4, GFP_KERNEL); 1043 zr->stat_com = kzalloc(BUZ_NUM_STAT_COM * 4, GFP_KERNEL);
1044 zr->video_dev = kmalloc(sizeof(struct video_device), GFP_KERNEL); 1044 zr->video_dev = video_device_alloc();
1045 if (!zr->stat_com || !zr->video_dev) { 1045 if (!zr->stat_com || !zr->video_dev) {
1046 dprintk(1, 1046 dprintk(1,
1047 KERN_ERR 1047 KERN_ERR
diff --git a/drivers/mmc/host/bfin_sdh.c b/drivers/mmc/host/bfin_sdh.c
index bac7d62866b7..0371bf502249 100644
--- a/drivers/mmc/host/bfin_sdh.c
+++ b/drivers/mmc/host/bfin_sdh.c
@@ -462,7 +462,7 @@ static int __devinit sdh_probe(struct platform_device *pdev)
462 goto out; 462 goto out;
463 } 463 }
464 464
465 mmc = mmc_alloc_host(sizeof(*mmc), &pdev->dev); 465 mmc = mmc_alloc_host(sizeof(struct sdh_host), &pdev->dev);
466 if (!mmc) { 466 if (!mmc) {
467 ret = -ENOMEM; 467 ret = -ENOMEM;
468 goto out; 468 goto out;
diff --git a/drivers/mmc/host/jz4740_mmc.c b/drivers/mmc/host/jz4740_mmc.c
index b3a0ab0e4c2b..74218ad677e4 100644
--- a/drivers/mmc/host/jz4740_mmc.c
+++ b/drivers/mmc/host/jz4740_mmc.c
@@ -14,6 +14,7 @@
14 */ 14 */
15 15
16#include <linux/mmc/host.h> 16#include <linux/mmc/host.h>
17#include <linux/err.h>
17#include <linux/io.h> 18#include <linux/io.h>
18#include <linux/irq.h> 19#include <linux/irq.h>
19#include <linux/interrupt.h> 20#include <linux/interrupt.h>
@@ -827,8 +828,8 @@ static int __devinit jz4740_mmc_probe(struct platform_device* pdev)
827 } 828 }
828 829
829 host->clk = clk_get(&pdev->dev, "mmc"); 830 host->clk = clk_get(&pdev->dev, "mmc");
830 if (!host->clk) { 831 if (IS_ERR(host->clk)) {
831 ret = -ENOENT; 832 ret = PTR_ERR(host->clk);
832 dev_err(&pdev->dev, "Failed to get mmc clock\n"); 833 dev_err(&pdev->dev, "Failed to get mmc clock\n");
833 goto err_free_host; 834 goto err_free_host;
834 } 835 }
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 563022825667..2d6de3e03e2d 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -14,6 +14,7 @@
14#include <linux/ioport.h> 14#include <linux/ioport.h>
15#include <linux/device.h> 15#include <linux/device.h>
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/kernel.h>
17#include <linux/delay.h> 18#include <linux/delay.h>
18#include <linux/err.h> 19#include <linux/err.h>
19#include <linux/highmem.h> 20#include <linux/highmem.h>
@@ -46,10 +47,6 @@ static unsigned int fmax = 515633;
46 * is asserted (likewise for RX) 47 * is asserted (likewise for RX)
47 * @fifohalfsize: number of bytes that can be written when MCI_TXFIFOHALFEMPTY 48 * @fifohalfsize: number of bytes that can be written when MCI_TXFIFOHALFEMPTY
48 * is asserted (likewise for RX) 49 * is asserted (likewise for RX)
49 * @broken_blockend: the MCI_DATABLOCKEND is broken on the hardware
50 * and will not work at all.
51 * @broken_blockend_dma: the MCI_DATABLOCKEND is broken on the hardware when
52 * using DMA.
53 * @sdio: variant supports SDIO 50 * @sdio: variant supports SDIO
54 * @st_clkdiv: true if using a ST-specific clock divider algorithm 51 * @st_clkdiv: true if using a ST-specific clock divider algorithm
55 */ 52 */
@@ -59,8 +56,6 @@ struct variant_data {
59 unsigned int datalength_bits; 56 unsigned int datalength_bits;
60 unsigned int fifosize; 57 unsigned int fifosize;
61 unsigned int fifohalfsize; 58 unsigned int fifohalfsize;
62 bool broken_blockend;
63 bool broken_blockend_dma;
64 bool sdio; 59 bool sdio;
65 bool st_clkdiv; 60 bool st_clkdiv;
66}; 61};
@@ -76,7 +71,6 @@ static struct variant_data variant_u300 = {
76 .fifohalfsize = 8 * 4, 71 .fifohalfsize = 8 * 4,
77 .clkreg_enable = 1 << 13, /* HWFCEN */ 72 .clkreg_enable = 1 << 13, /* HWFCEN */
78 .datalength_bits = 16, 73 .datalength_bits = 16,
79 .broken_blockend_dma = true,
80 .sdio = true, 74 .sdio = true,
81}; 75};
82 76
@@ -86,7 +80,6 @@ static struct variant_data variant_ux500 = {
86 .clkreg = MCI_CLK_ENABLE, 80 .clkreg = MCI_CLK_ENABLE,
87 .clkreg_enable = 1 << 14, /* HWFCEN */ 81 .clkreg_enable = 1 << 14, /* HWFCEN */
88 .datalength_bits = 24, 82 .datalength_bits = 24,
89 .broken_blockend = true,
90 .sdio = true, 83 .sdio = true,
91 .st_clkdiv = true, 84 .st_clkdiv = true,
92}; 85};
@@ -210,8 +203,6 @@ static void mmci_start_data(struct mmci_host *host, struct mmc_data *data)
210 host->data = data; 203 host->data = data;
211 host->size = data->blksz * data->blocks; 204 host->size = data->blksz * data->blocks;
212 host->data_xfered = 0; 205 host->data_xfered = 0;
213 host->blockend = false;
214 host->dataend = false;
215 206
216 mmci_init_sg(host, data); 207 mmci_init_sg(host, data);
217 208
@@ -288,21 +279,26 @@ static void
288mmci_data_irq(struct mmci_host *host, struct mmc_data *data, 279mmci_data_irq(struct mmci_host *host, struct mmc_data *data,
289 unsigned int status) 280 unsigned int status)
290{ 281{
291 struct variant_data *variant = host->variant;
292
293 /* First check for errors */ 282 /* First check for errors */
294 if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_TXUNDERRUN|MCI_RXOVERRUN)) { 283 if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_TXUNDERRUN|MCI_RXOVERRUN)) {
284 u32 remain, success;
285
286 /* Calculate how far we are into the transfer */
287 remain = readl(host->base + MMCIDATACNT);
288 success = data->blksz * data->blocks - remain;
289
295 dev_dbg(mmc_dev(host->mmc), "MCI ERROR IRQ (status %08x)\n", status); 290 dev_dbg(mmc_dev(host->mmc), "MCI ERROR IRQ (status %08x)\n", status);
296 if (status & MCI_DATACRCFAIL) 291 if (status & MCI_DATACRCFAIL) {
292 /* Last block was not successful */
293 host->data_xfered = round_down(success - 1, data->blksz);
297 data->error = -EILSEQ; 294 data->error = -EILSEQ;
298 else if (status & MCI_DATATIMEOUT) 295 } else if (status & MCI_DATATIMEOUT) {
296 host->data_xfered = round_down(success, data->blksz);
299 data->error = -ETIMEDOUT; 297 data->error = -ETIMEDOUT;
300 else if (status & (MCI_TXUNDERRUN|MCI_RXOVERRUN)) 298 } else if (status & (MCI_TXUNDERRUN|MCI_RXOVERRUN)) {
299 host->data_xfered = round_down(success, data->blksz);
301 data->error = -EIO; 300 data->error = -EIO;
302 301 }
303 /* Force-complete the transaction */
304 host->blockend = true;
305 host->dataend = true;
306 302
307 /* 303 /*
308 * We hit an error condition. Ensure that any data 304 * We hit an error condition. Ensure that any data
@@ -321,61 +317,14 @@ mmci_data_irq(struct mmci_host *host, struct mmc_data *data,
321 } 317 }
322 } 318 }
323 319
324 /* 320 if (status & MCI_DATABLOCKEND)
325 * On ARM variants in PIO mode, MCI_DATABLOCKEND 321 dev_err(mmc_dev(host->mmc), "stray MCI_DATABLOCKEND interrupt\n");
326 * is always sent first, and we increase the
327 * transfered number of bytes for that IRQ. Then
328 * MCI_DATAEND follows and we conclude the transaction.
329 *
330 * On the Ux500 single-IRQ variant MCI_DATABLOCKEND
331 * doesn't seem to immediately clear from the status,
332 * so we can't use it keep count when only one irq is
333 * used because the irq will hit for other reasons, and
334 * then the flag is still up. So we use the MCI_DATAEND
335 * IRQ at the end of the entire transfer because
336 * MCI_DATABLOCKEND is broken.
337 *
338 * In the U300, the IRQs can arrive out-of-order,
339 * e.g. MCI_DATABLOCKEND sometimes arrives after MCI_DATAEND,
340 * so for this case we use the flags "blockend" and
341 * "dataend" to make sure both IRQs have arrived before
342 * concluding the transaction. (This does not apply
343 * to the Ux500 which doesn't fire MCI_DATABLOCKEND
344 * at all.) In DMA mode it suffers from the same problem
345 * as the Ux500.
346 */
347 if (status & MCI_DATABLOCKEND) {
348 /*
349 * Just being a little over-cautious, we do not
350 * use this progressive update if the hardware blockend
351 * flag is unreliable: since it can stay high between
352 * IRQs it will corrupt the transfer counter.
353 */
354 if (!variant->broken_blockend)
355 host->data_xfered += data->blksz;
356 host->blockend = true;
357 }
358
359 if (status & MCI_DATAEND)
360 host->dataend = true;
361 322
362 /* 323 if (status & MCI_DATAEND || data->error) {
363 * On variants with broken blockend we shall only wait for dataend,
364 * on others we must sync with the blockend signal since they can
365 * appear out-of-order.
366 */
367 if (host->dataend && (host->blockend || variant->broken_blockend)) {
368 mmci_stop_data(host); 324 mmci_stop_data(host);
369 325
370 /* Reset these flags */ 326 if (!data->error)
371 host->blockend = false; 327 /* The error clause is handled above, success! */
372 host->dataend = false;
373
374 /*
375 * Variants with broken blockend flags need to handle the
376 * end of the entire transfer here.
377 */
378 if (variant->broken_blockend && !data->error)
379 host->data_xfered += data->blksz * data->blocks; 328 host->data_xfered += data->blksz * data->blocks;
380 329
381 if (!data->stop) { 330 if (!data->stop) {
@@ -394,15 +343,15 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,
394 343
395 host->cmd = NULL; 344 host->cmd = NULL;
396 345
397 cmd->resp[0] = readl(base + MMCIRESPONSE0);
398 cmd->resp[1] = readl(base + MMCIRESPONSE1);
399 cmd->resp[2] = readl(base + MMCIRESPONSE2);
400 cmd->resp[3] = readl(base + MMCIRESPONSE3);
401
402 if (status & MCI_CMDTIMEOUT) { 346 if (status & MCI_CMDTIMEOUT) {
403 cmd->error = -ETIMEDOUT; 347 cmd->error = -ETIMEDOUT;
404 } else if (status & MCI_CMDCRCFAIL && cmd->flags & MMC_RSP_CRC) { 348 } else if (status & MCI_CMDCRCFAIL && cmd->flags & MMC_RSP_CRC) {
405 cmd->error = -EILSEQ; 349 cmd->error = -EILSEQ;
350 } else {
351 cmd->resp[0] = readl(base + MMCIRESPONSE0);
352 cmd->resp[1] = readl(base + MMCIRESPONSE1);
353 cmd->resp[2] = readl(base + MMCIRESPONSE2);
354 cmd->resp[3] = readl(base + MMCIRESPONSE3);
406 } 355 }
407 356
408 if (!cmd->data || cmd->error) { 357 if (!cmd->data || cmd->error) {
@@ -770,7 +719,6 @@ static int __devinit mmci_probe(struct amba_device *dev, struct amba_id *id)
770 struct variant_data *variant = id->data; 719 struct variant_data *variant = id->data;
771 struct mmci_host *host; 720 struct mmci_host *host;
772 struct mmc_host *mmc; 721 struct mmc_host *mmc;
773 unsigned int mask;
774 int ret; 722 int ret;
775 723
776 /* must have platform data */ 724 /* must have platform data */
@@ -951,12 +899,7 @@ static int __devinit mmci_probe(struct amba_device *dev, struct amba_id *id)
951 goto irq0_free; 899 goto irq0_free;
952 } 900 }
953 901
954 mask = MCI_IRQENABLE; 902 writel(MCI_IRQENABLE, host->base + MMCIMASK0);
955 /* Don't use the datablockend flag if it's broken */
956 if (variant->broken_blockend)
957 mask &= ~MCI_DATABLOCKEND;
958
959 writel(mask, host->base + MMCIMASK0);
960 903
961 amba_set_drvdata(dev, mmc); 904 amba_set_drvdata(dev, mmc);
962 905
diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
index df06f01aac89..c1df7b82d36c 100644
--- a/drivers/mmc/host/mmci.h
+++ b/drivers/mmc/host/mmci.h
@@ -137,7 +137,7 @@
137#define MCI_IRQENABLE \ 137#define MCI_IRQENABLE \
138 (MCI_CMDCRCFAILMASK|MCI_DATACRCFAILMASK|MCI_CMDTIMEOUTMASK| \ 138 (MCI_CMDCRCFAILMASK|MCI_DATACRCFAILMASK|MCI_CMDTIMEOUTMASK| \
139 MCI_DATATIMEOUTMASK|MCI_TXUNDERRUNMASK|MCI_RXOVERRUNMASK| \ 139 MCI_DATATIMEOUTMASK|MCI_TXUNDERRUNMASK|MCI_RXOVERRUNMASK| \
140 MCI_CMDRESPENDMASK|MCI_CMDSENTMASK|MCI_DATABLOCKENDMASK) 140 MCI_CMDRESPENDMASK|MCI_CMDSENTMASK)
141 141
142/* These interrupts are directed to IRQ1 when two IRQ lines are available */ 142/* These interrupts are directed to IRQ1 when two IRQ lines are available */
143#define MCI_IRQ1MASK \ 143#define MCI_IRQ1MASK \
@@ -177,9 +177,6 @@ struct mmci_host {
177 struct timer_list timer; 177 struct timer_list timer;
178 unsigned int oldstat; 178 unsigned int oldstat;
179 179
180 bool blockend;
181 bool dataend;
182
183 /* pio stuff */ 180 /* pio stuff */
184 struct sg_mapping_iter sg_miter; 181 struct sg_mapping_iter sg_miter;
185 unsigned int size; 182 unsigned int size;
diff --git a/drivers/mmc/host/msm_sdcc.c b/drivers/mmc/host/msm_sdcc.c
index 5decfd0bd61d..153ab977a013 100644
--- a/drivers/mmc/host/msm_sdcc.c
+++ b/drivers/mmc/host/msm_sdcc.c
@@ -383,14 +383,30 @@ static int msmsdcc_config_dma(struct msmsdcc_host *host, struct mmc_data *data)
383 host->curr.user_pages = 0; 383 host->curr.user_pages = 0;
384 384
385 box = &nc->cmd[0]; 385 box = &nc->cmd[0];
386 for (i = 0; i < host->dma.num_ents; i++) {
387 box->cmd = CMD_MODE_BOX;
388 386
389 /* Initialize sg dma address */ 387 /* location of command block must be 64 bit aligned */
390 sg->dma_address = page_to_dma(mmc_dev(host->mmc), sg_page(sg)) 388 BUG_ON(host->dma.cmd_busaddr & 0x07);
391 + sg->offset;
392 389
393 if (i == (host->dma.num_ents - 1)) 390 nc->cmdptr = (host->dma.cmd_busaddr >> 3) | CMD_PTR_LP;
391 host->dma.hdr.cmdptr = DMOV_CMD_PTR_LIST |
392 DMOV_CMD_ADDR(host->dma.cmdptr_busaddr);
393 host->dma.hdr.complete_func = msmsdcc_dma_complete_func;
394
395 n = dma_map_sg(mmc_dev(host->mmc), host->dma.sg,
396 host->dma.num_ents, host->dma.dir);
397 if (n == 0) {
398 printk(KERN_ERR "%s: Unable to map in all sg elements\n",
399 mmc_hostname(host->mmc));
400 host->dma.sg = NULL;
401 host->dma.num_ents = 0;
402 return -ENOMEM;
403 }
404
405 for_each_sg(host->dma.sg, sg, n, i) {
406
407 box->cmd = CMD_MODE_BOX;
408
409 if (i == n - 1)
394 box->cmd |= CMD_LC; 410 box->cmd |= CMD_LC;
395 rows = (sg_dma_len(sg) % MCI_FIFOSIZE) ? 411 rows = (sg_dma_len(sg) % MCI_FIFOSIZE) ?
396 (sg_dma_len(sg) / MCI_FIFOSIZE) + 1 : 412 (sg_dma_len(sg) / MCI_FIFOSIZE) + 1 :
@@ -418,27 +434,6 @@ static int msmsdcc_config_dma(struct msmsdcc_host *host, struct mmc_data *data)
418 box->cmd |= CMD_DST_CRCI(crci); 434 box->cmd |= CMD_DST_CRCI(crci);
419 } 435 }
420 box++; 436 box++;
421 sg++;
422 }
423
424 /* location of command block must be 64 bit aligned */
425 BUG_ON(host->dma.cmd_busaddr & 0x07);
426
427 nc->cmdptr = (host->dma.cmd_busaddr >> 3) | CMD_PTR_LP;
428 host->dma.hdr.cmdptr = DMOV_CMD_PTR_LIST |
429 DMOV_CMD_ADDR(host->dma.cmdptr_busaddr);
430 host->dma.hdr.complete_func = msmsdcc_dma_complete_func;
431
432 n = dma_map_sg(mmc_dev(host->mmc), host->dma.sg,
433 host->dma.num_ents, host->dma.dir);
434/* dsb inside dma_map_sg will write nc out to mem as well */
435
436 if (n != host->dma.num_ents) {
437 printk(KERN_ERR "%s: Unable to map in all sg elements\n",
438 mmc_hostname(host->mmc));
439 host->dma.sg = NULL;
440 host->dma.num_ents = 0;
441 return -ENOMEM;
442 } 437 }
443 438
444 return 0; 439 return 0;
@@ -1331,9 +1326,6 @@ msmsdcc_probe(struct platform_device *pdev)
1331 if (host->timer.function) 1326 if (host->timer.function)
1332 pr_info("%s: Polling status mode enabled\n", mmc_hostname(mmc)); 1327 pr_info("%s: Polling status mode enabled\n", mmc_hostname(mmc));
1333 1328
1334#if BUSCLK_PWRSAVE
1335 msmsdcc_disable_clocks(host, 1);
1336#endif
1337 return 0; 1329 return 0;
1338 cmd_irq_free: 1330 cmd_irq_free:
1339 free_irq(cmd_irqres->start, host); 1331 free_irq(cmd_irqres->start, host);
diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index 17203586305c..5309ab95aada 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -277,10 +277,43 @@ static void sdhci_cmu_set_clock(struct sdhci_host *host, unsigned int clock)
277 host->clock = clock; 277 host->clock = clock;
278} 278}
279 279
280/**
281 * sdhci_s3c_platform_8bit_width - support 8bit buswidth
282 * @host: The SDHCI host being queried
283 * @width: MMC_BUS_WIDTH_ macro for the bus width being requested
284 *
285 * We have 8-bit width support but is not a v3 controller.
286 * So we add platform_8bit_width() and support 8bit width.
287 */
288static int sdhci_s3c_platform_8bit_width(struct sdhci_host *host, int width)
289{
290 u8 ctrl;
291
292 ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
293
294 switch (width) {
295 case MMC_BUS_WIDTH_8:
296 ctrl |= SDHCI_CTRL_8BITBUS;
297 ctrl &= ~SDHCI_CTRL_4BITBUS;
298 break;
299 case MMC_BUS_WIDTH_4:
300 ctrl |= SDHCI_CTRL_4BITBUS;
301 ctrl &= ~SDHCI_CTRL_8BITBUS;
302 break;
303 default:
304 break;
305 }
306
307 sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
308
309 return 0;
310}
311
280static struct sdhci_ops sdhci_s3c_ops = { 312static struct sdhci_ops sdhci_s3c_ops = {
281 .get_max_clock = sdhci_s3c_get_max_clk, 313 .get_max_clock = sdhci_s3c_get_max_clk,
282 .set_clock = sdhci_s3c_set_clock, 314 .set_clock = sdhci_s3c_set_clock,
283 .get_min_clock = sdhci_s3c_get_min_clock, 315 .get_min_clock = sdhci_s3c_get_min_clock,
316 .platform_8bit_width = sdhci_s3c_platform_8bit_width,
284}; 317};
285 318
286static void sdhci_s3c_notify_change(struct platform_device *dev, int state) 319static void sdhci_s3c_notify_change(struct platform_device *dev, int state)
@@ -473,6 +506,9 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
473 if (pdata->cd_type == S3C_SDHCI_CD_PERMANENT) 506 if (pdata->cd_type == S3C_SDHCI_CD_PERMANENT)
474 host->mmc->caps = MMC_CAP_NONREMOVABLE; 507 host->mmc->caps = MMC_CAP_NONREMOVABLE;
475 508
509 if (pdata->host_caps)
510 host->mmc->caps |= pdata->host_caps;
511
476 host->quirks |= (SDHCI_QUIRK_32BIT_DMA_ADDR | 512 host->quirks |= (SDHCI_QUIRK_32BIT_DMA_ADDR |
477 SDHCI_QUIRK_32BIT_DMA_SIZE); 513 SDHCI_QUIRK_32BIT_DMA_SIZE);
478 514
diff --git a/drivers/mmc/host/ushc.c b/drivers/mmc/host/ushc.c
index f8f65df9b017..f08f944ac53c 100644
--- a/drivers/mmc/host/ushc.c
+++ b/drivers/mmc/host/ushc.c
@@ -19,7 +19,6 @@
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/usb.h> 20#include <linux/usb.h>
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/usb.h>
23#include <linux/slab.h> 22#include <linux/slab.h>
24#include <linux/dma-mapping.h> 23#include <linux/dma-mapping.h>
25#include <linux/mmc/host.h> 24#include <linux/mmc/host.h>
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index f49e49dc5928..5ebe280225d6 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -672,33 +672,7 @@ static int io_init(struct ubi_device *ubi)
672 ubi->nor_flash = 1; 672 ubi->nor_flash = 1;
673 } 673 }
674 674
675 /* 675 ubi->min_io_size = ubi->mtd->writesize;
676 * Set UBI min. I/O size (@ubi->min_io_size). We use @mtd->writebufsize
677 * for these purposes, not @mtd->writesize. At the moment this does not
678 * matter for NAND, because currently @mtd->writebufsize is equivalent to
679 * @mtd->writesize for all NANDs. However, some CFI NOR flashes may
680 * have @mtd->writebufsize which is multiple of @mtd->writesize.
681 *
682 * The reason we use @mtd->writebufsize for @ubi->min_io_size is that
683 * UBI and UBIFS recovery algorithms rely on the fact that if there was
684 * an unclean power cut, then we can find offset of the last corrupted
685 * node, align the offset to @ubi->min_io_size, read the rest of the
686 * eraseblock starting from this offset, and check whether there are
687 * only 0xFF bytes. If yes, then we are probably dealing with a
688 * corruption caused by a power cut, if not, then this is probably some
689 * severe corruption.
690 *
691 * Thus, we have to use the maximum write unit size of the flash, which
692 * is @mtd->writebufsize, because @mtd->writesize is the minimum write
693 * size, not the maximum.
694 */
695 if (ubi->mtd->type == MTD_NANDFLASH)
696 ubi_assert(ubi->mtd->writebufsize == ubi->mtd->writesize);
697 else if (ubi->mtd->type == MTD_NORFLASH)
698 ubi_assert(ubi->mtd->writebufsize % ubi->mtd->writesize == 0);
699
700 ubi->min_io_size = ubi->mtd->writebufsize;
701
702 ubi->hdrs_min_io_size = ubi->mtd->writesize >> ubi->mtd->subpage_sft; 676 ubi->hdrs_min_io_size = ubi->mtd->writesize >> ubi->mtd->subpage_sft;
703 677
704 /* 678 /*
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 16fe4f9b719b..03823327db25 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2864,7 +2864,7 @@ config MLX4_CORE
2864 default n 2864 default n
2865 2865
2866config MLX4_DEBUG 2866config MLX4_DEBUG
2867 bool "Verbose debugging output" if (MLX4_CORE && EMBEDDED) 2867 bool "Verbose debugging output" if (MLX4_CORE && EXPERT)
2868 depends on MLX4_CORE 2868 depends on MLX4_CORE
2869 default y 2869 default y
2870 ---help--- 2870 ---help---
diff --git a/drivers/net/arm/ks8695net.c b/drivers/net/arm/ks8695net.c
index 62d6f88cbab5..aa07657744c3 100644
--- a/drivers/net/arm/ks8695net.c
+++ b/drivers/net/arm/ks8695net.c
@@ -1644,7 +1644,7 @@ ks8695_cleanup(void)
1644module_init(ks8695_init); 1644module_init(ks8695_init);
1645module_exit(ks8695_cleanup); 1645module_exit(ks8695_cleanup);
1646 1646
1647MODULE_AUTHOR("Simtec Electronics") 1647MODULE_AUTHOR("Simtec Electronics");
1648MODULE_DESCRIPTION("Micrel KS8695 (Centaur) Ethernet driver"); 1648MODULE_DESCRIPTION("Micrel KS8695 (Centaur) Ethernet driver");
1649MODULE_LICENSE("GPL"); 1649MODULE_LICENSE("GPL");
1650MODULE_ALIAS("platform:" MODULENAME); 1650MODULE_ALIAS("platform:" MODULENAME);
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index df99edf3464a..0ba59d5aeb7f 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -7553,6 +7553,10 @@ bnx2_set_flags(struct net_device *dev, u32 data)
7553 !(data & ETH_FLAG_RXVLAN)) 7553 !(data & ETH_FLAG_RXVLAN))
7554 return -EINVAL; 7554 return -EINVAL;
7555 7555
7556 /* TSO with VLAN tag won't work with current firmware */
7557 if (!(data & ETH_FLAG_TXVLAN))
7558 return -EINVAL;
7559
7556 rc = ethtool_op_set_flags(dev, data, ETH_FLAG_RXHASH | ETH_FLAG_RXVLAN | 7560 rc = ethtool_op_set_flags(dev, data, ETH_FLAG_RXHASH | ETH_FLAG_RXVLAN |
7557 ETH_FLAG_TXVLAN); 7561 ETH_FLAG_TXVLAN);
7558 if (rc) 7562 if (rc)
@@ -7962,11 +7966,8 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
7962 7966
7963 /* AER (Advanced Error Reporting) hooks */ 7967 /* AER (Advanced Error Reporting) hooks */
7964 err = pci_enable_pcie_error_reporting(pdev); 7968 err = pci_enable_pcie_error_reporting(pdev);
7965 if (err) { 7969 if (!err)
7966 dev_err(&pdev->dev, "pci_enable_pcie_error_reporting " 7970 bp->flags |= BNX2_FLAG_AER_ENABLED;
7967 "failed 0x%x\n", err);
7968 /* non-fatal, continue */
7969 }
7970 7971
7971 } else { 7972 } else {
7972 bp->pcix_cap = pci_find_capability(pdev, PCI_CAP_ID_PCIX); 7973 bp->pcix_cap = pci_find_capability(pdev, PCI_CAP_ID_PCIX);
@@ -8229,8 +8230,10 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
8229 return 0; 8230 return 0;
8230 8231
8231err_out_unmap: 8232err_out_unmap:
8232 if (bp->flags & BNX2_FLAG_PCIE) 8233 if (bp->flags & BNX2_FLAG_AER_ENABLED) {
8233 pci_disable_pcie_error_reporting(pdev); 8234 pci_disable_pcie_error_reporting(pdev);
8235 bp->flags &= ~BNX2_FLAG_AER_ENABLED;
8236 }
8234 8237
8235 if (bp->regview) { 8238 if (bp->regview) {
8236 iounmap(bp->regview); 8239 iounmap(bp->regview);
@@ -8418,8 +8421,10 @@ bnx2_remove_one(struct pci_dev *pdev)
8418 8421
8419 kfree(bp->temp_stats_blk); 8422 kfree(bp->temp_stats_blk);
8420 8423
8421 if (bp->flags & BNX2_FLAG_PCIE) 8424 if (bp->flags & BNX2_FLAG_AER_ENABLED) {
8422 pci_disable_pcie_error_reporting(pdev); 8425 pci_disable_pcie_error_reporting(pdev);
8426 bp->flags &= ~BNX2_FLAG_AER_ENABLED;
8427 }
8423 8428
8424 free_netdev(dev); 8429 free_netdev(dev);
8425 8430
@@ -8535,7 +8540,7 @@ static pci_ers_result_t bnx2_io_slot_reset(struct pci_dev *pdev)
8535 } 8540 }
8536 rtnl_unlock(); 8541 rtnl_unlock();
8537 8542
8538 if (!(bp->flags & BNX2_FLAG_PCIE)) 8543 if (!(bp->flags & BNX2_FLAG_AER_ENABLED))
8539 return result; 8544 return result;
8540 8545
8541 err = pci_cleanup_aer_uncorrect_error_status(pdev); 8546 err = pci_cleanup_aer_uncorrect_error_status(pdev);
diff --git a/drivers/net/bnx2.h b/drivers/net/bnx2.h
index 5488a2e82fe9..f459fb2f9add 100644
--- a/drivers/net/bnx2.h
+++ b/drivers/net/bnx2.h
@@ -6741,6 +6741,7 @@ struct bnx2 {
6741#define BNX2_FLAG_JUMBO_BROKEN 0x00000800 6741#define BNX2_FLAG_JUMBO_BROKEN 0x00000800
6742#define BNX2_FLAG_CAN_KEEP_VLAN 0x00001000 6742#define BNX2_FLAG_CAN_KEEP_VLAN 0x00001000
6743#define BNX2_FLAG_BROKEN_STATS 0x00002000 6743#define BNX2_FLAG_BROKEN_STATS 0x00002000
6744#define BNX2_FLAG_AER_ENABLED 0x00004000
6744 6745
6745 struct bnx2_napi bnx2_napi[BNX2_MAX_MSIX_VEC]; 6746 struct bnx2_napi bnx2_napi[BNX2_MAX_MSIX_VEC];
6746 6747
diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h
index a6cd335c9436..8e4183717d91 100644
--- a/drivers/net/bnx2x/bnx2x.h
+++ b/drivers/net/bnx2x/bnx2x.h
@@ -22,8 +22,8 @@
22 * (you will need to reboot afterwards) */ 22 * (you will need to reboot afterwards) */
23/* #define BNX2X_STOP_ON_ERROR */ 23/* #define BNX2X_STOP_ON_ERROR */
24 24
25#define DRV_MODULE_VERSION "1.62.00-3" 25#define DRV_MODULE_VERSION "1.62.00-4"
26#define DRV_MODULE_RELDATE "2010/12/21" 26#define DRV_MODULE_RELDATE "2011/01/18"
27#define BNX2X_BC_VER 0x040200 27#define BNX2X_BC_VER 0x040200
28 28
29#define BNX2X_MULTI_QUEUE 29#define BNX2X_MULTI_QUEUE
diff --git a/drivers/net/bnx2x/bnx2x_hsi.h b/drivers/net/bnx2x/bnx2x_hsi.h
index 6238d4f63989..548f5631c0dc 100644
--- a/drivers/net/bnx2x/bnx2x_hsi.h
+++ b/drivers/net/bnx2x/bnx2x_hsi.h
@@ -352,6 +352,10 @@ struct port_hw_cfg { /* port 0: 0x12c port 1: 0x2bc */
352#define PORT_HW_CFG_LANE_SWAP_CFG_31203120 0x0000d8d8 352#define PORT_HW_CFG_LANE_SWAP_CFG_31203120 0x0000d8d8
353 /* forced only */ 353 /* forced only */
354#define PORT_HW_CFG_LANE_SWAP_CFG_32103210 0x0000e4e4 354#define PORT_HW_CFG_LANE_SWAP_CFG_32103210 0x0000e4e4
355 /* Indicate whether to swap the external phy polarity */
356#define PORT_HW_CFG_SWAP_PHY_POLARITY_MASK 0x00010000
357#define PORT_HW_CFG_SWAP_PHY_POLARITY_DISABLED 0x00000000
358#define PORT_HW_CFG_SWAP_PHY_POLARITY_ENABLED 0x00010000
355 359
356 u32 external_phy_config; 360 u32 external_phy_config;
357#define PORT_HW_CFG_SERDES_EXT_PHY_TYPE_MASK 0xff000000 361#define PORT_HW_CFG_SERDES_EXT_PHY_TYPE_MASK 0xff000000
diff --git a/drivers/net/bnx2x/bnx2x_link.c b/drivers/net/bnx2x/bnx2x_link.c
index 43b0de24f391..7160ec51093e 100644
--- a/drivers/net/bnx2x/bnx2x_link.c
+++ b/drivers/net/bnx2x/bnx2x_link.c
@@ -1573,7 +1573,7 @@ static void bnx2x_set_aer_mmd_xgxs(struct link_params *params,
1573 1573
1574 offset = phy->addr + ser_lane; 1574 offset = phy->addr + ser_lane;
1575 if (CHIP_IS_E2(bp)) 1575 if (CHIP_IS_E2(bp))
1576 aer_val = 0x2800 + offset - 1; 1576 aer_val = 0x3800 + offset - 1;
1577 else 1577 else
1578 aer_val = 0x3800 + offset; 1578 aer_val = 0x3800 + offset;
1579 CL45_WR_OVER_CL22(bp, phy, 1579 CL45_WR_OVER_CL22(bp, phy,
@@ -3166,7 +3166,23 @@ u8 bnx2x_set_led(struct link_params *params,
3166 if (!vars->link_up) 3166 if (!vars->link_up)
3167 break; 3167 break;
3168 case LED_MODE_ON: 3168 case LED_MODE_ON:
3169 if (SINGLE_MEDIA_DIRECT(params)) { 3169 if (params->phy[EXT_PHY1].type ==
3170 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727 &&
3171 CHIP_IS_E2(bp) && params->num_phys == 2) {
3172 /**
3173 * This is a work-around for E2+8727 Configurations
3174 */
3175 if (mode == LED_MODE_ON ||
3176 speed == SPEED_10000){
3177 REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, 0);
3178 REG_WR(bp, NIG_REG_LED_10G_P0 + port*4, 1);
3179
3180 tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED);
3181 EMAC_WR(bp, EMAC_REG_EMAC_LED,
3182 (tmp | EMAC_LED_OVERRIDE));
3183 return rc;
3184 }
3185 } else if (SINGLE_MEDIA_DIRECT(params)) {
3170 /** 3186 /**
3171 * This is a work-around for HW issue found when link 3187 * This is a work-around for HW issue found when link
3172 * is up in CL73 3188 * is up in CL73
@@ -3854,11 +3870,14 @@ static void bnx2x_8073_resolve_fc(struct bnx2x_phy *phy,
3854 pause_result); 3870 pause_result);
3855 } 3871 }
3856} 3872}
3857 3873static u8 bnx2x_8073_8727_external_rom_boot(struct bnx2x *bp,
3858static void bnx2x_8073_8727_external_rom_boot(struct bnx2x *bp,
3859 struct bnx2x_phy *phy, 3874 struct bnx2x_phy *phy,
3860 u8 port) 3875 u8 port)
3861{ 3876{
3877 u32 count = 0;
3878 u16 fw_ver1, fw_msgout;
3879 u8 rc = 0;
3880
3862 /* Boot port from external ROM */ 3881 /* Boot port from external ROM */
3863 /* EDC grst */ 3882 /* EDC grst */
3864 bnx2x_cl45_write(bp, phy, 3883 bnx2x_cl45_write(bp, phy,
@@ -3888,14 +3907,45 @@ static void bnx2x_8073_8727_external_rom_boot(struct bnx2x *bp,
3888 MDIO_PMA_REG_GEN_CTRL, 3907 MDIO_PMA_REG_GEN_CTRL,
3889 MDIO_PMA_REG_GEN_CTRL_ROM_RESET_INTERNAL_MP); 3908 MDIO_PMA_REG_GEN_CTRL_ROM_RESET_INTERNAL_MP);
3890 3909
3891 /* wait for 120ms for code download via SPI port */ 3910 /* Delay 100ms per the PHY specifications */
3892 msleep(120); 3911 msleep(100);
3912
3913 /* 8073 sometimes taking longer to download */
3914 do {
3915 count++;
3916 if (count > 300) {
3917 DP(NETIF_MSG_LINK,
3918 "bnx2x_8073_8727_external_rom_boot port %x:"
3919 "Download failed. fw version = 0x%x\n",
3920 port, fw_ver1);
3921 rc = -EINVAL;
3922 break;
3923 }
3924
3925 bnx2x_cl45_read(bp, phy,
3926 MDIO_PMA_DEVAD,
3927 MDIO_PMA_REG_ROM_VER1, &fw_ver1);
3928 bnx2x_cl45_read(bp, phy,
3929 MDIO_PMA_DEVAD,
3930 MDIO_PMA_REG_M8051_MSGOUT_REG, &fw_msgout);
3931
3932 msleep(1);
3933 } while (fw_ver1 == 0 || fw_ver1 == 0x4321 ||
3934 ((fw_msgout & 0xff) != 0x03 && (phy->type ==
3935 PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8073)));
3893 3936
3894 /* Clear ser_boot_ctl bit */ 3937 /* Clear ser_boot_ctl bit */
3895 bnx2x_cl45_write(bp, phy, 3938 bnx2x_cl45_write(bp, phy,
3896 MDIO_PMA_DEVAD, 3939 MDIO_PMA_DEVAD,
3897 MDIO_PMA_REG_MISC_CTRL1, 0x0000); 3940 MDIO_PMA_REG_MISC_CTRL1, 0x0000);
3898 bnx2x_save_bcm_spirom_ver(bp, phy, port); 3941 bnx2x_save_bcm_spirom_ver(bp, phy, port);
3942
3943 DP(NETIF_MSG_LINK,
3944 "bnx2x_8073_8727_external_rom_boot port %x:"
3945 "Download complete. fw version = 0x%x\n",
3946 port, fw_ver1);
3947
3948 return rc;
3899} 3949}
3900 3950
3901static void bnx2x_8073_set_xaui_low_power_mode(struct bnx2x *bp, 3951static void bnx2x_8073_set_xaui_low_power_mode(struct bnx2x *bp,
@@ -4108,6 +4158,25 @@ static u8 bnx2x_8073_config_init(struct bnx2x_phy *phy,
4108 4158
4109 DP(NETIF_MSG_LINK, "Before rom RX_ALARM(port1): 0x%x\n", tmp1); 4159 DP(NETIF_MSG_LINK, "Before rom RX_ALARM(port1): 0x%x\n", tmp1);
4110 4160
4161 /**
4162 * If this is forced speed, set to KR or KX (all other are not
4163 * supported)
4164 */
4165 /* Swap polarity if required - Must be done only in non-1G mode */
4166 if (params->lane_config & PORT_HW_CFG_SWAP_PHY_POLARITY_ENABLED) {
4167 /* Configure the 8073 to swap _P and _N of the KR lines */
4168 DP(NETIF_MSG_LINK, "Swapping polarity for the 8073\n");
4169 /* 10G Rx/Tx and 1G Tx signal polarity swap */
4170 bnx2x_cl45_read(bp, phy,
4171 MDIO_PMA_DEVAD,
4172 MDIO_PMA_REG_8073_OPT_DIGITAL_CTRL, &val);
4173 bnx2x_cl45_write(bp, phy,
4174 MDIO_PMA_DEVAD,
4175 MDIO_PMA_REG_8073_OPT_DIGITAL_CTRL,
4176 (val | (3<<9)));
4177 }
4178
4179
4111 /* Enable CL37 BAM */ 4180 /* Enable CL37 BAM */
4112 if (REG_RD(bp, params->shmem_base + 4181 if (REG_RD(bp, params->shmem_base +
4113 offsetof(struct shmem_region, dev_info. 4182 offsetof(struct shmem_region, dev_info.
@@ -4314,8 +4383,32 @@ static u8 bnx2x_8073_read_status(struct bnx2x_phy *phy,
4314 } 4383 }
4315 4384
4316 if (link_up) { 4385 if (link_up) {
4386 /* Swap polarity if required */
4387 if (params->lane_config &
4388 PORT_HW_CFG_SWAP_PHY_POLARITY_ENABLED) {
4389 /* Configure the 8073 to swap P and N of the KR lines */
4390 bnx2x_cl45_read(bp, phy,
4391 MDIO_XS_DEVAD,
4392 MDIO_XS_REG_8073_RX_CTRL_PCIE, &val1);
4393 /**
4394 * Set bit 3 to invert Rx in 1G mode and clear this bit
4395 * when it`s in 10G mode.
4396 */
4397 if (vars->line_speed == SPEED_1000) {
4398 DP(NETIF_MSG_LINK, "Swapping 1G polarity for"
4399 "the 8073\n");
4400 val1 |= (1<<3);
4401 } else
4402 val1 &= ~(1<<3);
4403
4404 bnx2x_cl45_write(bp, phy,
4405 MDIO_XS_DEVAD,
4406 MDIO_XS_REG_8073_RX_CTRL_PCIE,
4407 val1);
4408 }
4317 bnx2x_ext_phy_10G_an_resolve(bp, phy, vars); 4409 bnx2x_ext_phy_10G_an_resolve(bp, phy, vars);
4318 bnx2x_8073_resolve_fc(phy, params, vars); 4410 bnx2x_8073_resolve_fc(phy, params, vars);
4411 vars->duplex = DUPLEX_FULL;
4319 } 4412 }
4320 return link_up; 4413 return link_up;
4321} 4414}
@@ -5062,6 +5155,7 @@ static u8 bnx2x_8706_8726_read_status(struct bnx2x_phy *phy,
5062 else 5155 else
5063 vars->line_speed = SPEED_10000; 5156 vars->line_speed = SPEED_10000;
5064 bnx2x_ext_phy_resolve_fc(phy, params, vars); 5157 bnx2x_ext_phy_resolve_fc(phy, params, vars);
5158 vars->duplex = DUPLEX_FULL;
5065 } 5159 }
5066 return link_up; 5160 return link_up;
5067} 5161}
@@ -5758,8 +5852,11 @@ static u8 bnx2x_8727_read_status(struct bnx2x_phy *phy,
5758 DP(NETIF_MSG_LINK, "port %x: External link is down\n", 5852 DP(NETIF_MSG_LINK, "port %x: External link is down\n",
5759 params->port); 5853 params->port);
5760 } 5854 }
5761 if (link_up) 5855 if (link_up) {
5762 bnx2x_ext_phy_resolve_fc(phy, params, vars); 5856 bnx2x_ext_phy_resolve_fc(phy, params, vars);
5857 vars->duplex = DUPLEX_FULL;
5858 DP(NETIF_MSG_LINK, "duplex = 0x%x\n", vars->duplex);
5859 }
5763 5860
5764 if ((DUAL_MEDIA(params)) && 5861 if ((DUAL_MEDIA(params)) &&
5765 (phy->req_line_speed == SPEED_1000)) { 5862 (phy->req_line_speed == SPEED_1000)) {
@@ -5875,10 +5972,26 @@ static void bnx2x_848xx_set_led(struct bnx2x *bp,
5875 MDIO_PMA_REG_8481_LED2_MASK, 5972 MDIO_PMA_REG_8481_LED2_MASK,
5876 0x18); 5973 0x18);
5877 5974
5975 /* Select activity source by Tx and Rx, as suggested by PHY AE */
5878 bnx2x_cl45_write(bp, phy, 5976 bnx2x_cl45_write(bp, phy,
5879 MDIO_PMA_DEVAD, 5977 MDIO_PMA_DEVAD,
5880 MDIO_PMA_REG_8481_LED3_MASK, 5978 MDIO_PMA_REG_8481_LED3_MASK,
5881 0x0040); 5979 0x0006);
5980
5981 /* Select the closest activity blink rate to that in 10/100/1000 */
5982 bnx2x_cl45_write(bp, phy,
5983 MDIO_PMA_DEVAD,
5984 MDIO_PMA_REG_8481_LED3_BLINK,
5985 0);
5986
5987 bnx2x_cl45_read(bp, phy,
5988 MDIO_PMA_DEVAD,
5989 MDIO_PMA_REG_84823_CTL_LED_CTL_1, &val);
5990 val |= MDIO_PMA_REG_84823_LED3_STRETCH_EN; /* stretch_en for LED3*/
5991
5992 bnx2x_cl45_write(bp, phy,
5993 MDIO_PMA_DEVAD,
5994 MDIO_PMA_REG_84823_CTL_LED_CTL_1, val);
5882 5995
5883 /* 'Interrupt Mask' */ 5996 /* 'Interrupt Mask' */
5884 bnx2x_cl45_write(bp, phy, 5997 bnx2x_cl45_write(bp, phy,
@@ -6126,6 +6239,7 @@ static u8 bnx2x_848xx_read_status(struct bnx2x_phy *phy,
6126 /* Check link 10G */ 6239 /* Check link 10G */
6127 if (val2 & (1<<11)) { 6240 if (val2 & (1<<11)) {
6128 vars->line_speed = SPEED_10000; 6241 vars->line_speed = SPEED_10000;
6242 vars->duplex = DUPLEX_FULL;
6129 link_up = 1; 6243 link_up = 1;
6130 bnx2x_ext_phy_10G_an_resolve(bp, phy, vars); 6244 bnx2x_ext_phy_10G_an_resolve(bp, phy, vars);
6131 } else { /* Check Legacy speed link */ 6245 } else { /* Check Legacy speed link */
@@ -6489,6 +6603,7 @@ static u8 bnx2x_7101_read_status(struct bnx2x_phy *phy,
6489 MDIO_AN_DEVAD, MDIO_AN_REG_MASTER_STATUS, 6603 MDIO_AN_DEVAD, MDIO_AN_REG_MASTER_STATUS,
6490 &val2); 6604 &val2);
6491 vars->line_speed = SPEED_10000; 6605 vars->line_speed = SPEED_10000;
6606 vars->duplex = DUPLEX_FULL;
6492 DP(NETIF_MSG_LINK, "SFX7101 AN status 0x%x->Master=%x\n", 6607 DP(NETIF_MSG_LINK, "SFX7101 AN status 0x%x->Master=%x\n",
6493 val2, (val2 & (1<<14))); 6608 val2, (val2 & (1<<14)));
6494 bnx2x_ext_phy_10G_an_resolve(bp, phy, vars); 6609 bnx2x_ext_phy_10G_an_resolve(bp, phy, vars);
@@ -7663,7 +7778,6 @@ static u8 bnx2x_8073_common_init_phy(struct bnx2x *bp,
7663 7778
7664 /* PART2 - Download firmware to both phys */ 7779 /* PART2 - Download firmware to both phys */
7665 for (port = PORT_MAX - 1; port >= PORT_0; port--) { 7780 for (port = PORT_MAX - 1; port >= PORT_0; port--) {
7666 u16 fw_ver1;
7667 if (CHIP_IS_E2(bp)) 7781 if (CHIP_IS_E2(bp))
7668 port_of_path = 0; 7782 port_of_path = 0;
7669 else 7783 else
@@ -7671,19 +7785,9 @@ static u8 bnx2x_8073_common_init_phy(struct bnx2x *bp,
7671 7785
7672 DP(NETIF_MSG_LINK, "Loading spirom for phy address 0x%x\n", 7786 DP(NETIF_MSG_LINK, "Loading spirom for phy address 0x%x\n",
7673 phy_blk[port]->addr); 7787 phy_blk[port]->addr);
7674 bnx2x_8073_8727_external_rom_boot(bp, phy_blk[port], 7788 if (bnx2x_8073_8727_external_rom_boot(bp, phy_blk[port],
7675 port_of_path); 7789 port_of_path))
7676
7677 bnx2x_cl45_read(bp, phy_blk[port],
7678 MDIO_PMA_DEVAD,
7679 MDIO_PMA_REG_ROM_VER1, &fw_ver1);
7680 if (fw_ver1 == 0 || fw_ver1 == 0x4321) {
7681 DP(NETIF_MSG_LINK,
7682 "bnx2x_8073_common_init_phy port %x:"
7683 "Download failed. fw version = 0x%x\n",
7684 port, fw_ver1);
7685 return -EINVAL; 7790 return -EINVAL;
7686 }
7687 7791
7688 /* Only set bit 10 = 1 (Tx power down) */ 7792 /* Only set bit 10 = 1 (Tx power down) */
7689 bnx2x_cl45_read(bp, phy_blk[port], 7793 bnx2x_cl45_read(bp, phy_blk[port],
@@ -7848,27 +7952,17 @@ static u8 bnx2x_8727_common_init_phy(struct bnx2x *bp,
7848 } 7952 }
7849 /* PART2 - Download firmware to both phys */ 7953 /* PART2 - Download firmware to both phys */
7850 for (port = PORT_MAX - 1; port >= PORT_0; port--) { 7954 for (port = PORT_MAX - 1; port >= PORT_0; port--) {
7851 u16 fw_ver1;
7852 if (CHIP_IS_E2(bp)) 7955 if (CHIP_IS_E2(bp))
7853 port_of_path = 0; 7956 port_of_path = 0;
7854 else 7957 else
7855 port_of_path = port; 7958 port_of_path = port;
7856 DP(NETIF_MSG_LINK, "Loading spirom for phy address 0x%x\n", 7959 DP(NETIF_MSG_LINK, "Loading spirom for phy address 0x%x\n",
7857 phy_blk[port]->addr); 7960 phy_blk[port]->addr);
7858 bnx2x_8073_8727_external_rom_boot(bp, phy_blk[port], 7961 if (bnx2x_8073_8727_external_rom_boot(bp, phy_blk[port],
7859 port_of_path); 7962 port_of_path))
7860 bnx2x_cl45_read(bp, phy_blk[port],
7861 MDIO_PMA_DEVAD,
7862 MDIO_PMA_REG_ROM_VER1, &fw_ver1);
7863 if (fw_ver1 == 0 || fw_ver1 == 0x4321) {
7864 DP(NETIF_MSG_LINK,
7865 "bnx2x_8727_common_init_phy port %x:"
7866 "Download failed. fw version = 0x%x\n",
7867 port, fw_ver1);
7868 return -EINVAL; 7963 return -EINVAL;
7869 }
7870 }
7871 7964
7965 }
7872 return 0; 7966 return 0;
7873} 7967}
7874 7968
@@ -7916,6 +8010,7 @@ u8 bnx2x_common_init_phy(struct bnx2x *bp, u32 shmem_base_path[],
7916 u32 shmem2_base_path[], u32 chip_id) 8010 u32 shmem2_base_path[], u32 chip_id)
7917{ 8011{
7918 u8 rc = 0; 8012 u8 rc = 0;
8013 u32 phy_ver;
7919 u8 phy_index; 8014 u8 phy_index;
7920 u32 ext_phy_type, ext_phy_config; 8015 u32 ext_phy_type, ext_phy_config;
7921 DP(NETIF_MSG_LINK, "Begin common phy init\n"); 8016 DP(NETIF_MSG_LINK, "Begin common phy init\n");
@@ -7923,6 +8018,16 @@ u8 bnx2x_common_init_phy(struct bnx2x *bp, u32 shmem_base_path[],
7923 if (CHIP_REV_IS_EMUL(bp)) 8018 if (CHIP_REV_IS_EMUL(bp))
7924 return 0; 8019 return 0;
7925 8020
8021 /* Check if common init was already done */
8022 phy_ver = REG_RD(bp, shmem_base_path[0] +
8023 offsetof(struct shmem_region,
8024 port_mb[PORT_0].ext_phy_fw_version));
8025 if (phy_ver) {
8026 DP(NETIF_MSG_LINK, "Not doing common init; phy ver is 0x%x\n",
8027 phy_ver);
8028 return 0;
8029 }
8030
7926 /* Read the ext_phy_type for arbitrary port(0) */ 8031 /* Read the ext_phy_type for arbitrary port(0) */
7927 for (phy_index = EXT_PHY1; phy_index < MAX_PHYS; 8032 for (phy_index = EXT_PHY1; phy_index < MAX_PHYS;
7928 phy_index++) { 8033 phy_index++) {
diff --git a/drivers/net/bnx2x/bnx2x_reg.h b/drivers/net/bnx2x/bnx2x_reg.h
index c939683e3d61..e01330bb36c7 100644
--- a/drivers/net/bnx2x/bnx2x_reg.h
+++ b/drivers/net/bnx2x/bnx2x_reg.h
@@ -6194,7 +6194,11 @@ Theotherbitsarereservedandshouldbezero*/
6194#define MDIO_CTL_REG_84823_MEDIA_PRIORITY_COPPER 0x0000 6194#define MDIO_CTL_REG_84823_MEDIA_PRIORITY_COPPER 0x0000
6195#define MDIO_CTL_REG_84823_MEDIA_PRIORITY_FIBER 0x0100 6195#define MDIO_CTL_REG_84823_MEDIA_PRIORITY_FIBER 0x0100
6196#define MDIO_CTL_REG_84823_MEDIA_FIBER_1G 0x1000 6196#define MDIO_CTL_REG_84823_MEDIA_FIBER_1G 0x1000
6197#define MDIO_CTL_REG_84823_USER_CTRL_REG 0x4005
6198#define MDIO_CTL_REG_84823_USER_CTRL_CMS 0x0080
6197 6199
6200#define MDIO_PMA_REG_84823_CTL_LED_CTL_1 0xa8e3
6201#define MDIO_PMA_REG_84823_LED3_STRETCH_EN 0x0080
6198 6202
6199#define IGU_FUNC_BASE 0x0400 6203#define IGU_FUNC_BASE 0x0400
6200 6204
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index 171782e2bb39..1024ae158227 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -2470,6 +2470,10 @@ int bond_3ad_lacpdu_recv(struct sk_buff *skb, struct net_device *dev, struct pac
2470 if (!(dev->flags & IFF_MASTER)) 2470 if (!(dev->flags & IFF_MASTER))
2471 goto out; 2471 goto out;
2472 2472
2473 skb = skb_share_check(skb, GFP_ATOMIC);
2474 if (!skb)
2475 goto out;
2476
2473 if (!pskb_may_pull(skb, sizeof(struct lacpdu))) 2477 if (!pskb_may_pull(skb, sizeof(struct lacpdu)))
2474 goto out; 2478 goto out;
2475 2479
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index f4e638c65129..5c6fba802f2b 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -326,6 +326,10 @@ static int rlb_arp_recv(struct sk_buff *skb, struct net_device *bond_dev, struct
326 goto out; 326 goto out;
327 } 327 }
328 328
329 skb = skb_share_check(skb, GFP_ATOMIC);
330 if (!skb)
331 goto out;
332
329 if (!pskb_may_pull(skb, arp_hdr_len(bond_dev))) 333 if (!pskb_may_pull(skb, arp_hdr_len(bond_dev)))
330 goto out; 334 goto out;
331 335
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index b1025b85acf1..163e0b06eaa5 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -2733,6 +2733,10 @@ static int bond_arp_rcv(struct sk_buff *skb, struct net_device *dev, struct pack
2733 if (!slave || !slave_do_arp_validate(bond, slave)) 2733 if (!slave || !slave_do_arp_validate(bond, slave))
2734 goto out_unlock; 2734 goto out_unlock;
2735 2735
2736 skb = skb_share_check(skb, GFP_ATOMIC);
2737 if (!skb)
2738 goto out_unlock;
2739
2736 if (!pskb_may_pull(skb, arp_hdr_len(dev))) 2740 if (!pskb_may_pull(skb, arp_hdr_len(dev)))
2737 goto out_unlock; 2741 goto out_unlock;
2738 2742
diff --git a/drivers/net/can/Kconfig b/drivers/net/can/Kconfig
index d5a9db60ade9..986195eaa57c 100644
--- a/drivers/net/can/Kconfig
+++ b/drivers/net/can/Kconfig
@@ -117,6 +117,8 @@ source "drivers/net/can/sja1000/Kconfig"
117 117
118source "drivers/net/can/usb/Kconfig" 118source "drivers/net/can/usb/Kconfig"
119 119
120source "drivers/net/can/softing/Kconfig"
121
120config CAN_DEBUG_DEVICES 122config CAN_DEBUG_DEVICES
121 bool "CAN devices debugging messages" 123 bool "CAN devices debugging messages"
122 depends on CAN 124 depends on CAN
diff --git a/drivers/net/can/Makefile b/drivers/net/can/Makefile
index 07ca159ba3f9..53c82a71778e 100644
--- a/drivers/net/can/Makefile
+++ b/drivers/net/can/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_CAN_DEV) += can-dev.o
9can-dev-y := dev.o 9can-dev-y := dev.o
10 10
11obj-y += usb/ 11obj-y += usb/
12obj-y += softing/
12 13
13obj-$(CONFIG_CAN_SJA1000) += sja1000/ 14obj-$(CONFIG_CAN_SJA1000) += sja1000/
14obj-$(CONFIG_CAN_MSCAN) += mscan/ 15obj-$(CONFIG_CAN_MSCAN) += mscan/
diff --git a/drivers/net/can/at91_can.c b/drivers/net/can/at91_can.c
index 7ef83d06f7ed..2532b9631538 100644
--- a/drivers/net/can/at91_can.c
+++ b/drivers/net/can/at91_can.c
@@ -2,7 +2,7 @@
2 * at91_can.c - CAN network driver for AT91 SoC CAN controller 2 * at91_can.c - CAN network driver for AT91 SoC CAN controller
3 * 3 *
4 * (C) 2007 by Hans J. Koch <hjk@hansjkoch.de> 4 * (C) 2007 by Hans J. Koch <hjk@hansjkoch.de>
5 * (C) 2008, 2009, 2010 by Marc Kleine-Budde <kernel@pengutronix.de> 5 * (C) 2008, 2009, 2010, 2011 by Marc Kleine-Budde <kernel@pengutronix.de>
6 * 6 *
7 * This software may be distributed under the terms of the GNU General 7 * This software may be distributed under the terms of the GNU General
8 * Public License ("GPL") version 2 as distributed in the 'COPYING' 8 * Public License ("GPL") version 2 as distributed in the 'COPYING'
@@ -30,6 +30,7 @@
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/netdevice.h> 31#include <linux/netdevice.h>
32#include <linux/platform_device.h> 32#include <linux/platform_device.h>
33#include <linux/rtnetlink.h>
33#include <linux/skbuff.h> 34#include <linux/skbuff.h>
34#include <linux/spinlock.h> 35#include <linux/spinlock.h>
35#include <linux/string.h> 36#include <linux/string.h>
@@ -40,22 +41,23 @@
40 41
41#include <mach/board.h> 42#include <mach/board.h>
42 43
43#define AT91_NAPI_WEIGHT 12 44#define AT91_NAPI_WEIGHT 11
44 45
45/* 46/*
46 * RX/TX Mailbox split 47 * RX/TX Mailbox split
47 * don't dare to touch 48 * don't dare to touch
48 */ 49 */
49#define AT91_MB_RX_NUM 12 50#define AT91_MB_RX_NUM 11
50#define AT91_MB_TX_SHIFT 2 51#define AT91_MB_TX_SHIFT 2
51 52
52#define AT91_MB_RX_FIRST 0 53#define AT91_MB_RX_FIRST 1
53#define AT91_MB_RX_LAST (AT91_MB_RX_FIRST + AT91_MB_RX_NUM - 1) 54#define AT91_MB_RX_LAST (AT91_MB_RX_FIRST + AT91_MB_RX_NUM - 1)
54 55
55#define AT91_MB_RX_MASK(i) ((1 << (i)) - 1) 56#define AT91_MB_RX_MASK(i) ((1 << (i)) - 1)
56#define AT91_MB_RX_SPLIT 8 57#define AT91_MB_RX_SPLIT 8
57#define AT91_MB_RX_LOW_LAST (AT91_MB_RX_SPLIT - 1) 58#define AT91_MB_RX_LOW_LAST (AT91_MB_RX_SPLIT - 1)
58#define AT91_MB_RX_LOW_MASK (AT91_MB_RX_MASK(AT91_MB_RX_SPLIT)) 59#define AT91_MB_RX_LOW_MASK (AT91_MB_RX_MASK(AT91_MB_RX_SPLIT) & \
60 ~AT91_MB_RX_MASK(AT91_MB_RX_FIRST))
59 61
60#define AT91_MB_TX_NUM (1 << AT91_MB_TX_SHIFT) 62#define AT91_MB_TX_NUM (1 << AT91_MB_TX_SHIFT)
61#define AT91_MB_TX_FIRST (AT91_MB_RX_LAST + 1) 63#define AT91_MB_TX_FIRST (AT91_MB_RX_LAST + 1)
@@ -168,6 +170,8 @@ struct at91_priv {
168 170
169 struct clk *clk; 171 struct clk *clk;
170 struct at91_can_data *pdata; 172 struct at91_can_data *pdata;
173
174 canid_t mb0_id;
171}; 175};
172 176
173static struct can_bittiming_const at91_bittiming_const = { 177static struct can_bittiming_const at91_bittiming_const = {
@@ -220,6 +224,18 @@ static inline void set_mb_mode(const struct at91_priv *priv, unsigned int mb,
220 set_mb_mode_prio(priv, mb, mode, 0); 224 set_mb_mode_prio(priv, mb, mode, 0);
221} 225}
222 226
227static inline u32 at91_can_id_to_reg_mid(canid_t can_id)
228{
229 u32 reg_mid;
230
231 if (can_id & CAN_EFF_FLAG)
232 reg_mid = (can_id & CAN_EFF_MASK) | AT91_MID_MIDE;
233 else
234 reg_mid = (can_id & CAN_SFF_MASK) << 18;
235
236 return reg_mid;
237}
238
223/* 239/*
224 * Swtich transceiver on or off 240 * Swtich transceiver on or off
225 */ 241 */
@@ -233,12 +249,22 @@ static void at91_setup_mailboxes(struct net_device *dev)
233{ 249{
234 struct at91_priv *priv = netdev_priv(dev); 250 struct at91_priv *priv = netdev_priv(dev);
235 unsigned int i; 251 unsigned int i;
252 u32 reg_mid;
236 253
237 /* 254 /*
238 * The first 12 mailboxes are used as a reception FIFO. The 255 * Due to a chip bug (errata 50.2.6.3 & 50.3.5.3) the first
239 * last mailbox is configured with overwrite option. The 256 * mailbox is disabled. The next 11 mailboxes are used as a
240 * overwrite flag indicates a FIFO overflow. 257 * reception FIFO. The last mailbox is configured with
258 * overwrite option. The overwrite flag indicates a FIFO
259 * overflow.
241 */ 260 */
261 reg_mid = at91_can_id_to_reg_mid(priv->mb0_id);
262 for (i = 0; i < AT91_MB_RX_FIRST; i++) {
263 set_mb_mode(priv, i, AT91_MB_MODE_DISABLED);
264 at91_write(priv, AT91_MID(i), reg_mid);
265 at91_write(priv, AT91_MCR(i), 0x0); /* clear dlc */
266 }
267
242 for (i = AT91_MB_RX_FIRST; i < AT91_MB_RX_LAST; i++) 268 for (i = AT91_MB_RX_FIRST; i < AT91_MB_RX_LAST; i++)
243 set_mb_mode(priv, i, AT91_MB_MODE_RX); 269 set_mb_mode(priv, i, AT91_MB_MODE_RX);
244 set_mb_mode(priv, AT91_MB_RX_LAST, AT91_MB_MODE_RX_OVRWR); 270 set_mb_mode(priv, AT91_MB_RX_LAST, AT91_MB_MODE_RX_OVRWR);
@@ -254,7 +280,8 @@ static void at91_setup_mailboxes(struct net_device *dev)
254 set_mb_mode_prio(priv, i, AT91_MB_MODE_TX, 0); 280 set_mb_mode_prio(priv, i, AT91_MB_MODE_TX, 0);
255 281
256 /* Reset tx and rx helper pointers */ 282 /* Reset tx and rx helper pointers */
257 priv->tx_next = priv->tx_echo = priv->rx_next = 0; 283 priv->tx_next = priv->tx_echo = 0;
284 priv->rx_next = AT91_MB_RX_FIRST;
258} 285}
259 286
260static int at91_set_bittiming(struct net_device *dev) 287static int at91_set_bittiming(struct net_device *dev)
@@ -372,12 +399,7 @@ static netdev_tx_t at91_start_xmit(struct sk_buff *skb, struct net_device *dev)
372 netdev_err(dev, "BUG! TX buffer full when queue awake!\n"); 399 netdev_err(dev, "BUG! TX buffer full when queue awake!\n");
373 return NETDEV_TX_BUSY; 400 return NETDEV_TX_BUSY;
374 } 401 }
375 402 reg_mid = at91_can_id_to_reg_mid(cf->can_id);
376 if (cf->can_id & CAN_EFF_FLAG)
377 reg_mid = (cf->can_id & CAN_EFF_MASK) | AT91_MID_MIDE;
378 else
379 reg_mid = (cf->can_id & CAN_SFF_MASK) << 18;
380
381 reg_mcr = ((cf->can_id & CAN_RTR_FLAG) ? AT91_MCR_MRTR : 0) | 403 reg_mcr = ((cf->can_id & CAN_RTR_FLAG) ? AT91_MCR_MRTR : 0) |
382 (cf->can_dlc << 16) | AT91_MCR_MTCR; 404 (cf->can_dlc << 16) | AT91_MCR_MTCR;
383 405
@@ -539,27 +561,31 @@ static void at91_read_msg(struct net_device *dev, unsigned int mb)
539 * 561 *
540 * Theory of Operation: 562 * Theory of Operation:
541 * 563 *
542 * 12 of the 16 mailboxes on the chip are reserved for RX. we split 564 * 11 of the 16 mailboxes on the chip are reserved for RX. we split
543 * them into 2 groups. The lower group holds 8 and upper 4 mailboxes. 565 * them into 2 groups. The lower group holds 7 and upper 4 mailboxes.
544 * 566 *
545 * Like it or not, but the chip always saves a received CAN message 567 * Like it or not, but the chip always saves a received CAN message
546 * into the first free mailbox it finds (starting with the 568 * into the first free mailbox it finds (starting with the
547 * lowest). This makes it very difficult to read the messages in the 569 * lowest). This makes it very difficult to read the messages in the
548 * right order from the chip. This is how we work around that problem: 570 * right order from the chip. This is how we work around that problem:
549 * 571 *
550 * The first message goes into mb nr. 0 and issues an interrupt. All 572 * The first message goes into mb nr. 1 and issues an interrupt. All
551 * rx ints are disabled in the interrupt handler and a napi poll is 573 * rx ints are disabled in the interrupt handler and a napi poll is
552 * scheduled. We read the mailbox, but do _not_ reenable the mb (to 574 * scheduled. We read the mailbox, but do _not_ reenable the mb (to
553 * receive another message). 575 * receive another message).
554 * 576 *
555 * lower mbxs upper 577 * lower mbxs upper
556 * ______^______ __^__ 578 * ____^______ __^__
557 * / \ / \ 579 * / \ / \
558 * +-+-+-+-+-+-+-+-++-+-+-+-+ 580 * +-+-+-+-+-+-+-+-++-+-+-+-+
559 * |x|x|x|x|x|x|x|x|| | | | | 581 * | |x|x|x|x|x|x|x|| | | | |
560 * +-+-+-+-+-+-+-+-++-+-+-+-+ 582 * +-+-+-+-+-+-+-+-++-+-+-+-+
561 * 0 0 0 0 0 0 0 0 0 0 1 1 \ mail 583 * 0 0 0 0 0 0 0 0 0 0 1 1 \ mail
562 * 0 1 2 3 4 5 6 7 8 9 0 1 / box 584 * 0 1 2 3 4 5 6 7 8 9 0 1 / box
585 * ^
586 * |
587 * \
588 * unused, due to chip bug
563 * 589 *
564 * The variable priv->rx_next points to the next mailbox to read a 590 * The variable priv->rx_next points to the next mailbox to read a
565 * message from. As long we're in the lower mailboxes we just read the 591 * message from. As long we're in the lower mailboxes we just read the
@@ -590,10 +616,10 @@ static int at91_poll_rx(struct net_device *dev, int quota)
590 "order of incoming frames cannot be guaranteed\n"); 616 "order of incoming frames cannot be guaranteed\n");
591 617
592 again: 618 again:
593 for (mb = find_next_bit(addr, AT91_MB_RX_NUM, priv->rx_next); 619 for (mb = find_next_bit(addr, AT91_MB_RX_LAST + 1, priv->rx_next);
594 mb < AT91_MB_RX_NUM && quota > 0; 620 mb < AT91_MB_RX_LAST + 1 && quota > 0;
595 reg_sr = at91_read(priv, AT91_SR), 621 reg_sr = at91_read(priv, AT91_SR),
596 mb = find_next_bit(addr, AT91_MB_RX_NUM, ++priv->rx_next)) { 622 mb = find_next_bit(addr, AT91_MB_RX_LAST + 1, ++priv->rx_next)) {
597 at91_read_msg(dev, mb); 623 at91_read_msg(dev, mb);
598 624
599 /* reactivate mailboxes */ 625 /* reactivate mailboxes */
@@ -610,8 +636,8 @@ static int at91_poll_rx(struct net_device *dev, int quota)
610 636
611 /* upper group completed, look again in lower */ 637 /* upper group completed, look again in lower */
612 if (priv->rx_next > AT91_MB_RX_LOW_LAST && 638 if (priv->rx_next > AT91_MB_RX_LOW_LAST &&
613 quota > 0 && mb >= AT91_MB_RX_NUM) { 639 quota > 0 && mb > AT91_MB_RX_LAST) {
614 priv->rx_next = 0; 640 priv->rx_next = AT91_MB_RX_FIRST;
615 goto again; 641 goto again;
616 } 642 }
617 643
@@ -1037,6 +1063,64 @@ static const struct net_device_ops at91_netdev_ops = {
1037 .ndo_start_xmit = at91_start_xmit, 1063 .ndo_start_xmit = at91_start_xmit,
1038}; 1064};
1039 1065
1066static ssize_t at91_sysfs_show_mb0_id(struct device *dev,
1067 struct device_attribute *attr, char *buf)
1068{
1069 struct at91_priv *priv = netdev_priv(to_net_dev(dev));
1070
1071 if (priv->mb0_id & CAN_EFF_FLAG)
1072 return snprintf(buf, PAGE_SIZE, "0x%08x\n", priv->mb0_id);
1073 else
1074 return snprintf(buf, PAGE_SIZE, "0x%03x\n", priv->mb0_id);
1075}
1076
1077static ssize_t at91_sysfs_set_mb0_id(struct device *dev,
1078 struct device_attribute *attr, const char *buf, size_t count)
1079{
1080 struct net_device *ndev = to_net_dev(dev);
1081 struct at91_priv *priv = netdev_priv(ndev);
1082 unsigned long can_id;
1083 ssize_t ret;
1084 int err;
1085
1086 rtnl_lock();
1087
1088 if (ndev->flags & IFF_UP) {
1089 ret = -EBUSY;
1090 goto out;
1091 }
1092
1093 err = strict_strtoul(buf, 0, &can_id);
1094 if (err) {
1095 ret = err;
1096 goto out;
1097 }
1098
1099 if (can_id & CAN_EFF_FLAG)
1100 can_id &= CAN_EFF_MASK | CAN_EFF_FLAG;
1101 else
1102 can_id &= CAN_SFF_MASK;
1103
1104 priv->mb0_id = can_id;
1105 ret = count;
1106
1107 out:
1108 rtnl_unlock();
1109 return ret;
1110}
1111
1112static DEVICE_ATTR(mb0_id, S_IWUGO | S_IRUGO,
1113 at91_sysfs_show_mb0_id, at91_sysfs_set_mb0_id);
1114
1115static struct attribute *at91_sysfs_attrs[] = {
1116 &dev_attr_mb0_id.attr,
1117 NULL,
1118};
1119
1120static struct attribute_group at91_sysfs_attr_group = {
1121 .attrs = at91_sysfs_attrs,
1122};
1123
1040static int __devinit at91_can_probe(struct platform_device *pdev) 1124static int __devinit at91_can_probe(struct platform_device *pdev)
1041{ 1125{
1042 struct net_device *dev; 1126 struct net_device *dev;
@@ -1082,6 +1166,7 @@ static int __devinit at91_can_probe(struct platform_device *pdev)
1082 dev->netdev_ops = &at91_netdev_ops; 1166 dev->netdev_ops = &at91_netdev_ops;
1083 dev->irq = irq; 1167 dev->irq = irq;
1084 dev->flags |= IFF_ECHO; 1168 dev->flags |= IFF_ECHO;
1169 dev->sysfs_groups[0] = &at91_sysfs_attr_group;
1085 1170
1086 priv = netdev_priv(dev); 1171 priv = netdev_priv(dev);
1087 priv->can.clock.freq = clk_get_rate(clk); 1172 priv->can.clock.freq = clk_get_rate(clk);
@@ -1093,6 +1178,7 @@ static int __devinit at91_can_probe(struct platform_device *pdev)
1093 priv->dev = dev; 1178 priv->dev = dev;
1094 priv->clk = clk; 1179 priv->clk = clk;
1095 priv->pdata = pdev->dev.platform_data; 1180 priv->pdata = pdev->dev.platform_data;
1181 priv->mb0_id = 0x7ff;
1096 1182
1097 netif_napi_add(dev, &priv->napi, at91_poll, AT91_NAPI_WEIGHT); 1183 netif_napi_add(dev, &priv->napi, at91_poll, AT91_NAPI_WEIGHT);
1098 1184
diff --git a/drivers/net/can/softing/Kconfig b/drivers/net/can/softing/Kconfig
new file mode 100644
index 000000000000..92bd6bdde5e3
--- /dev/null
+++ b/drivers/net/can/softing/Kconfig
@@ -0,0 +1,30 @@
1config CAN_SOFTING
2 tristate "Softing Gmbh CAN generic support"
3 depends on CAN_DEV
4 ---help---
5 Support for CAN cards from Softing Gmbh & some cards
6 from Vector Gmbh.
7 Softing Gmbh CAN cards come with 1 or 2 physical busses.
8 Those cards typically use Dual Port RAM to communicate
9 with the host CPU. The interface is then identical for PCI
10 and PCMCIA cards. This driver operates on a platform device,
11 which has been created by softing_cs or softing_pci driver.
12 Warning:
13 The API of the card does not allow fine control per bus, but
14 controls the 2 busses on the card together.
15 As such, some actions (start/stop/busoff recovery) on 1 bus
16 must bring down the other bus too temporarily.
17
18config CAN_SOFTING_CS
19 tristate "Softing Gmbh CAN pcmcia cards"
20 depends on PCMCIA
21 select CAN_SOFTING
22 ---help---
23 Support for PCMCIA cards from Softing Gmbh & some cards
24 from Vector Gmbh.
25 You need firmware for these, which you can get at
26 http://developer.berlios.de/projects/socketcan/
27 This version of the driver is written against
28 firmware version 4.6 (softing-fw-4.6-binaries.tar.gz)
29 In order to use the card as CAN device, you need the Softing generic
30 support too.
diff --git a/drivers/net/can/softing/Makefile b/drivers/net/can/softing/Makefile
new file mode 100644
index 000000000000..c5e5016c742e
--- /dev/null
+++ b/drivers/net/can/softing/Makefile
@@ -0,0 +1,6 @@
1
2softing-y := softing_main.o softing_fw.o
3obj-$(CONFIG_CAN_SOFTING) += softing.o
4obj-$(CONFIG_CAN_SOFTING_CS) += softing_cs.o
5
6ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG
diff --git a/drivers/net/can/softing/softing.h b/drivers/net/can/softing/softing.h
new file mode 100644
index 000000000000..7ec9f4db3d52
--- /dev/null
+++ b/drivers/net/can/softing/softing.h
@@ -0,0 +1,167 @@
1/*
2 * softing common interfaces
3 *
4 * by Kurt Van Dijck, 2008-2010
5 */
6
7#include <linux/atomic.h>
8#include <linux/netdevice.h>
9#include <linux/ktime.h>
10#include <linux/mutex.h>
11#include <linux/spinlock.h>
12#include <linux/can.h>
13#include <linux/can/dev.h>
14
15#include "softing_platform.h"
16
17struct softing;
18
19struct softing_priv {
20 struct can_priv can; /* must be the first member! */
21 struct net_device *netdev;
22 struct softing *card;
23 struct {
24 int pending;
25 /* variables wich hold the circular buffer */
26 int echo_put;
27 int echo_get;
28 } tx;
29 struct can_bittiming_const btr_const;
30 int index;
31 uint8_t output;
32 uint16_t chip;
33};
34#define netdev2softing(netdev) ((struct softing_priv *)netdev_priv(netdev))
35
36struct softing {
37 const struct softing_platform_data *pdat;
38 struct platform_device *pdev;
39 struct net_device *net[2];
40 spinlock_t spin; /* protect this structure & DPRAM access */
41 ktime_t ts_ref;
42 ktime_t ts_overflow; /* timestamp overflow value, in ktime */
43
44 struct {
45 /* indication of firmware status */
46 int up;
47 /* protection of the 'up' variable */
48 struct mutex lock;
49 } fw;
50 struct {
51 int nr;
52 int requested;
53 int svc_count;
54 unsigned int dpram_position;
55 } irq;
56 struct {
57 int pending;
58 int last_bus;
59 /*
60 * keep the bus that last tx'd a message,
61 * in order to let every netdev queue resume
62 */
63 } tx;
64 __iomem uint8_t *dpram;
65 unsigned long dpram_phys;
66 unsigned long dpram_size;
67 struct {
68 uint16_t fw_version, hw_version, license, serial;
69 uint16_t chip[2];
70 unsigned int freq; /* remote cpu's operating frequency */
71 } id;
72};
73
74extern int softing_default_output(struct net_device *netdev);
75
76extern ktime_t softing_raw2ktime(struct softing *card, u32 raw);
77
78extern int softing_chip_poweron(struct softing *card);
79
80extern int softing_bootloader_command(struct softing *card, int16_t cmd,
81 const char *msg);
82
83/* Load firmware after reset */
84extern int softing_load_fw(const char *file, struct softing *card,
85 __iomem uint8_t *virt, unsigned int size, int offset);
86
87/* Load final application firmware after bootloader */
88extern int softing_load_app_fw(const char *file, struct softing *card);
89
90/*
91 * enable or disable irq
92 * only called with fw.lock locked
93 */
94extern int softing_enable_irq(struct softing *card, int enable);
95
96/* start/stop 1 bus on card */
97extern int softing_startstop(struct net_device *netdev, int up);
98
99/* netif_rx() */
100extern int softing_netdev_rx(struct net_device *netdev,
101 const struct can_frame *msg, ktime_t ktime);
102
103/* SOFTING DPRAM mappings */
104#define DPRAM_RX 0x0000
105 #define DPRAM_RX_SIZE 32
106 #define DPRAM_RX_CNT 16
107#define DPRAM_RX_RD 0x0201 /* uint8_t */
108#define DPRAM_RX_WR 0x0205 /* uint8_t */
109#define DPRAM_RX_LOST 0x0207 /* uint8_t */
110
111#define DPRAM_FCT_PARAM 0x0300 /* int16_t [20] */
112#define DPRAM_FCT_RESULT 0x0328 /* int16_t */
113#define DPRAM_FCT_HOST 0x032b /* uint16_t */
114
115#define DPRAM_INFO_BUSSTATE 0x0331 /* uint16_t */
116#define DPRAM_INFO_BUSSTATE2 0x0335 /* uint16_t */
117#define DPRAM_INFO_ERRSTATE 0x0339 /* uint16_t */
118#define DPRAM_INFO_ERRSTATE2 0x033d /* uint16_t */
119#define DPRAM_RESET 0x0341 /* uint16_t */
120#define DPRAM_CLR_RECV_FIFO 0x0345 /* uint16_t */
121#define DPRAM_RESET_TIME 0x034d /* uint16_t */
122#define DPRAM_TIME 0x0350 /* uint64_t */
123#define DPRAM_WR_START 0x0358 /* uint8_t */
124#define DPRAM_WR_END 0x0359 /* uint8_t */
125#define DPRAM_RESET_RX_FIFO 0x0361 /* uint16_t */
126#define DPRAM_RESET_TX_FIFO 0x0364 /* uint8_t */
127#define DPRAM_READ_FIFO_LEVEL 0x0365 /* uint8_t */
128#define DPRAM_RX_FIFO_LEVEL 0x0366 /* uint16_t */
129#define DPRAM_TX_FIFO_LEVEL 0x0366 /* uint16_t */
130
131#define DPRAM_TX 0x0400 /* uint16_t */
132 #define DPRAM_TX_SIZE 16
133 #define DPRAM_TX_CNT 32
134#define DPRAM_TX_RD 0x0601 /* uint8_t */
135#define DPRAM_TX_WR 0x0605 /* uint8_t */
136
137#define DPRAM_COMMAND 0x07e0 /* uint16_t */
138#define DPRAM_RECEIPT 0x07f0 /* uint16_t */
139#define DPRAM_IRQ_TOHOST 0x07fe /* uint8_t */
140#define DPRAM_IRQ_TOCARD 0x07ff /* uint8_t */
141
142#define DPRAM_V2_RESET 0x0e00 /* uint8_t */
143#define DPRAM_V2_IRQ_TOHOST 0x0e02 /* uint8_t */
144
145#define TXMAX (DPRAM_TX_CNT - 1)
146
147/* DPRAM return codes */
148#define RES_NONE 0
149#define RES_OK 1
150#define RES_NOK 2
151#define RES_UNKNOWN 3
152/* DPRAM flags */
153#define CMD_TX 0x01
154#define CMD_ACK 0x02
155#define CMD_XTD 0x04
156#define CMD_RTR 0x08
157#define CMD_ERR 0x10
158#define CMD_BUS2 0x80
159
160/* returned fifo entry bus state masks */
161#define SF_MASK_BUSOFF 0x80
162#define SF_MASK_EPASSIVE 0x60
163
164/* bus states */
165#define STATE_BUSOFF 2
166#define STATE_EPASSIVE 1
167#define STATE_EACTIVE 0
diff --git a/drivers/net/can/softing/softing_cs.c b/drivers/net/can/softing/softing_cs.c
new file mode 100644
index 000000000000..300fe75dd1a7
--- /dev/null
+++ b/drivers/net/can/softing/softing_cs.c
@@ -0,0 +1,359 @@
1/*
2 * Copyright (C) 2008-2010
3 *
4 * - Kurt Van Dijck, EIA Electronics
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the version 2 of the GNU General Public License
8 * as published by the Free Software Foundation
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#include <linux/module.h>
21#include <linux/kernel.h>
22
23#include <pcmcia/cistpl.h>
24#include <pcmcia/ds.h>
25
26#include "softing_platform.h"
27
28static int softingcs_index;
29static spinlock_t softingcs_index_lock;
30
31static int softingcs_reset(struct platform_device *pdev, int v);
32static int softingcs_enable_irq(struct platform_device *pdev, int v);
33
34/*
35 * platform_data descriptions
36 */
37#define MHZ (1000*1000)
38static const struct softing_platform_data softingcs_platform_data[] = {
39{
40 .name = "CANcard",
41 .manf = 0x0168, .prod = 0x001,
42 .generation = 1,
43 .nbus = 2,
44 .freq = 16 * MHZ, .max_brp = 32, .max_sjw = 4,
45 .dpram_size = 0x0800,
46 .boot = {0x0000, 0x000000, fw_dir "bcard.bin",},
47 .load = {0x0120, 0x00f600, fw_dir "ldcard.bin",},
48 .app = {0x0010, 0x0d0000, fw_dir "cancard.bin",},
49 .reset = softingcs_reset,
50 .enable_irq = softingcs_enable_irq,
51}, {
52 .name = "CANcard-NEC",
53 .manf = 0x0168, .prod = 0x002,
54 .generation = 1,
55 .nbus = 2,
56 .freq = 16 * MHZ, .max_brp = 32, .max_sjw = 4,
57 .dpram_size = 0x0800,
58 .boot = {0x0000, 0x000000, fw_dir "bcard.bin",},
59 .load = {0x0120, 0x00f600, fw_dir "ldcard.bin",},
60 .app = {0x0010, 0x0d0000, fw_dir "cancard.bin",},
61 .reset = softingcs_reset,
62 .enable_irq = softingcs_enable_irq,
63}, {
64 .name = "CANcard-SJA",
65 .manf = 0x0168, .prod = 0x004,
66 .generation = 1,
67 .nbus = 2,
68 .freq = 20 * MHZ, .max_brp = 32, .max_sjw = 4,
69 .dpram_size = 0x0800,
70 .boot = {0x0000, 0x000000, fw_dir "bcard.bin",},
71 .load = {0x0120, 0x00f600, fw_dir "ldcard.bin",},
72 .app = {0x0010, 0x0d0000, fw_dir "cansja.bin",},
73 .reset = softingcs_reset,
74 .enable_irq = softingcs_enable_irq,
75}, {
76 .name = "CANcard-2",
77 .manf = 0x0168, .prod = 0x005,
78 .generation = 2,
79 .nbus = 2,
80 .freq = 24 * MHZ, .max_brp = 64, .max_sjw = 4,
81 .dpram_size = 0x1000,
82 .boot = {0x0000, 0x000000, fw_dir "bcard2.bin",},
83 .load = {0x0120, 0x00f600, fw_dir "ldcard2.bin",},
84 .app = {0x0010, 0x0d0000, fw_dir "cancrd2.bin",},
85 .reset = softingcs_reset,
86 .enable_irq = NULL,
87}, {
88 .name = "Vector-CANcard",
89 .manf = 0x0168, .prod = 0x081,
90 .generation = 1,
91 .nbus = 2,
92 .freq = 16 * MHZ, .max_brp = 64, .max_sjw = 4,
93 .dpram_size = 0x0800,
94 .boot = {0x0000, 0x000000, fw_dir "bcard.bin",},
95 .load = {0x0120, 0x00f600, fw_dir "ldcard.bin",},
96 .app = {0x0010, 0x0d0000, fw_dir "cancard.bin",},
97 .reset = softingcs_reset,
98 .enable_irq = softingcs_enable_irq,
99}, {
100 .name = "Vector-CANcard-SJA",
101 .manf = 0x0168, .prod = 0x084,
102 .generation = 1,
103 .nbus = 2,
104 .freq = 20 * MHZ, .max_brp = 32, .max_sjw = 4,
105 .dpram_size = 0x0800,
106 .boot = {0x0000, 0x000000, fw_dir "bcard.bin",},
107 .load = {0x0120, 0x00f600, fw_dir "ldcard.bin",},
108 .app = {0x0010, 0x0d0000, fw_dir "cansja.bin",},
109 .reset = softingcs_reset,
110 .enable_irq = softingcs_enable_irq,
111}, {
112 .name = "Vector-CANcard-2",
113 .manf = 0x0168, .prod = 0x085,
114 .generation = 2,
115 .nbus = 2,
116 .freq = 24 * MHZ, .max_brp = 64, .max_sjw = 4,
117 .dpram_size = 0x1000,
118 .boot = {0x0000, 0x000000, fw_dir "bcard2.bin",},
119 .load = {0x0120, 0x00f600, fw_dir "ldcard2.bin",},
120 .app = {0x0010, 0x0d0000, fw_dir "cancrd2.bin",},
121 .reset = softingcs_reset,
122 .enable_irq = NULL,
123}, {
124 .name = "EDICcard-NEC",
125 .manf = 0x0168, .prod = 0x102,
126 .generation = 1,
127 .nbus = 2,
128 .freq = 16 * MHZ, .max_brp = 64, .max_sjw = 4,
129 .dpram_size = 0x0800,
130 .boot = {0x0000, 0x000000, fw_dir "bcard.bin",},
131 .load = {0x0120, 0x00f600, fw_dir "ldcard.bin",},
132 .app = {0x0010, 0x0d0000, fw_dir "cancard.bin",},
133 .reset = softingcs_reset,
134 .enable_irq = softingcs_enable_irq,
135}, {
136 .name = "EDICcard-2",
137 .manf = 0x0168, .prod = 0x105,
138 .generation = 2,
139 .nbus = 2,
140 .freq = 24 * MHZ, .max_brp = 64, .max_sjw = 4,
141 .dpram_size = 0x1000,
142 .boot = {0x0000, 0x000000, fw_dir "bcard2.bin",},
143 .load = {0x0120, 0x00f600, fw_dir "ldcard2.bin",},
144 .app = {0x0010, 0x0d0000, fw_dir "cancrd2.bin",},
145 .reset = softingcs_reset,
146 .enable_irq = NULL,
147}, {
148 0, 0,
149},
150};
151
152MODULE_FIRMWARE(fw_dir "bcard.bin");
153MODULE_FIRMWARE(fw_dir "ldcard.bin");
154MODULE_FIRMWARE(fw_dir "cancard.bin");
155MODULE_FIRMWARE(fw_dir "cansja.bin");
156
157MODULE_FIRMWARE(fw_dir "bcard2.bin");
158MODULE_FIRMWARE(fw_dir "ldcard2.bin");
159MODULE_FIRMWARE(fw_dir "cancrd2.bin");
160
161static __devinit const struct softing_platform_data
162*softingcs_find_platform_data(unsigned int manf, unsigned int prod)
163{
164 const struct softing_platform_data *lp;
165
166 for (lp = softingcs_platform_data; lp->manf; ++lp) {
167 if ((lp->manf == manf) && (lp->prod == prod))
168 return lp;
169 }
170 return NULL;
171}
172
173/*
174 * platformdata callbacks
175 */
176static int softingcs_reset(struct platform_device *pdev, int v)
177{
178 struct pcmcia_device *pcmcia = to_pcmcia_dev(pdev->dev.parent);
179
180 dev_dbg(&pdev->dev, "pcmcia config [2] %02x\n", v ? 0 : 0x20);
181 return pcmcia_write_config_byte(pcmcia, 2, v ? 0 : 0x20);
182}
183
184static int softingcs_enable_irq(struct platform_device *pdev, int v)
185{
186 struct pcmcia_device *pcmcia = to_pcmcia_dev(pdev->dev.parent);
187
188 dev_dbg(&pdev->dev, "pcmcia config [0] %02x\n", v ? 0x60 : 0);
189 return pcmcia_write_config_byte(pcmcia, 0, v ? 0x60 : 0);
190}
191
192/*
193 * pcmcia check
194 */
195static __devinit int softingcs_probe_config(struct pcmcia_device *pcmcia,
196 void *priv_data)
197{
198 struct softing_platform_data *pdat = priv_data;
199 struct resource *pres;
200 int memspeed = 0;
201
202 WARN_ON(!pdat);
203 pres = pcmcia->resource[PCMCIA_IOMEM_0];
204 if (resource_size(pres) < 0x1000)
205 return -ERANGE;
206
207 pres->flags |= WIN_MEMORY_TYPE_CM | WIN_ENABLE;
208 if (pdat->generation < 2) {
209 pres->flags |= WIN_USE_WAIT | WIN_DATA_WIDTH_8;
210 memspeed = 3;
211 } else {
212 pres->flags |= WIN_DATA_WIDTH_16;
213 }
214 return pcmcia_request_window(pcmcia, pres, memspeed);
215}
216
217static __devexit void softingcs_remove(struct pcmcia_device *pcmcia)
218{
219 struct platform_device *pdev = pcmcia->priv;
220
221 /* free bits */
222 platform_device_unregister(pdev);
223 /* release pcmcia stuff */
224 pcmcia_disable_device(pcmcia);
225}
226
227/*
228 * platform_device wrapper
229 * pdev->resource has 2 entries: io & irq
230 */
231static void softingcs_pdev_release(struct device *dev)
232{
233 struct platform_device *pdev = to_platform_device(dev);
234 kfree(pdev);
235}
236
237static __devinit int softingcs_probe(struct pcmcia_device *pcmcia)
238{
239 int ret;
240 struct platform_device *pdev;
241 const struct softing_platform_data *pdat;
242 struct resource *pres;
243 struct dev {
244 struct platform_device pdev;
245 struct resource res[2];
246 } *dev;
247
248 /* find matching platform_data */
249 pdat = softingcs_find_platform_data(pcmcia->manf_id, pcmcia->card_id);
250 if (!pdat)
251 return -ENOTTY;
252
253 /* setup pcmcia device */
254 pcmcia->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IOMEM |
255 CONF_AUTO_SET_VPP | CONF_AUTO_CHECK_VCC;
256 ret = pcmcia_loop_config(pcmcia, softingcs_probe_config, (void *)pdat);
257 if (ret)
258 goto pcmcia_failed;
259
260 ret = pcmcia_enable_device(pcmcia);
261 if (ret < 0)
262 goto pcmcia_failed;
263
264 pres = pcmcia->resource[PCMCIA_IOMEM_0];
265 if (!pres) {
266 ret = -EBADF;
267 goto pcmcia_bad;
268 }
269
270 /* create softing platform device */
271 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
272 if (!dev) {
273 ret = -ENOMEM;
274 goto mem_failed;
275 }
276 dev->pdev.resource = dev->res;
277 dev->pdev.num_resources = ARRAY_SIZE(dev->res);
278 dev->pdev.dev.release = softingcs_pdev_release;
279
280 pdev = &dev->pdev;
281 pdev->dev.platform_data = (void *)pdat;
282 pdev->dev.parent = &pcmcia->dev;
283 pcmcia->priv = pdev;
284
285 /* platform device resources */
286 pdev->resource[0].flags = IORESOURCE_MEM;
287 pdev->resource[0].start = pres->start;
288 pdev->resource[0].end = pres->end;
289
290 pdev->resource[1].flags = IORESOURCE_IRQ;
291 pdev->resource[1].start = pcmcia->irq;
292 pdev->resource[1].end = pdev->resource[1].start;
293
294 /* platform device setup */
295 spin_lock(&softingcs_index_lock);
296 pdev->id = softingcs_index++;
297 spin_unlock(&softingcs_index_lock);
298 pdev->name = "softing";
299 dev_set_name(&pdev->dev, "softingcs.%i", pdev->id);
300 ret = platform_device_register(pdev);
301 if (ret < 0)
302 goto platform_failed;
303
304 dev_info(&pcmcia->dev, "created %s\n", dev_name(&pdev->dev));
305 return 0;
306
307platform_failed:
308 kfree(dev);
309mem_failed:
310pcmcia_bad:
311pcmcia_failed:
312 pcmcia_disable_device(pcmcia);
313 pcmcia->priv = NULL;
314 return ret ?: -ENODEV;
315}
316
317static /*const*/ struct pcmcia_device_id softingcs_ids[] = {
318 /* softing */
319 PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0001),
320 PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0002),
321 PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0004),
322 PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0005),
323 /* vector, manufacturer? */
324 PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0081),
325 PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0084),
326 PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0085),
327 /* EDIC */
328 PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0102),
329 PCMCIA_DEVICE_MANF_CARD(0x0168, 0x0105),
330 PCMCIA_DEVICE_NULL,
331};
332
333MODULE_DEVICE_TABLE(pcmcia, softingcs_ids);
334
335static struct pcmcia_driver softingcs_driver = {
336 .owner = THIS_MODULE,
337 .name = "softingcs",
338 .id_table = softingcs_ids,
339 .probe = softingcs_probe,
340 .remove = __devexit_p(softingcs_remove),
341};
342
343static int __init softingcs_start(void)
344{
345 spin_lock_init(&softingcs_index_lock);
346 return pcmcia_register_driver(&softingcs_driver);
347}
348
349static void __exit softingcs_stop(void)
350{
351 pcmcia_unregister_driver(&softingcs_driver);
352}
353
354module_init(softingcs_start);
355module_exit(softingcs_stop);
356
357MODULE_DESCRIPTION("softing CANcard driver"
358 ", links PCMCIA card to softing driver");
359MODULE_LICENSE("GPL v2");
diff --git a/drivers/net/can/softing/softing_fw.c b/drivers/net/can/softing/softing_fw.c
new file mode 100644
index 000000000000..b520784fb197
--- /dev/null
+++ b/drivers/net/can/softing/softing_fw.c
@@ -0,0 +1,691 @@
1/*
2 * Copyright (C) 2008-2010
3 *
4 * - Kurt Van Dijck, EIA Electronics
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the version 2 of the GNU General Public License
8 * as published by the Free Software Foundation
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#include <linux/firmware.h>
21#include <linux/sched.h>
22#include <asm/div64.h>
23
24#include "softing.h"
25
26/*
27 * low level DPRAM command.
28 * Make sure that card->dpram[DPRAM_FCT_HOST] is preset
29 */
30static int _softing_fct_cmd(struct softing *card, int16_t cmd, uint16_t vector,
31 const char *msg)
32{
33 int ret;
34 unsigned long stamp;
35
36 iowrite16(cmd, &card->dpram[DPRAM_FCT_PARAM]);
37 iowrite8(vector >> 8, &card->dpram[DPRAM_FCT_HOST + 1]);
38 iowrite8(vector, &card->dpram[DPRAM_FCT_HOST]);
39 /* be sure to flush this to the card */
40 wmb();
41 stamp = jiffies + 1 * HZ;
42 /* wait for card */
43 do {
44 /* DPRAM_FCT_HOST is _not_ aligned */
45 ret = ioread8(&card->dpram[DPRAM_FCT_HOST]) +
46 (ioread8(&card->dpram[DPRAM_FCT_HOST + 1]) << 8);
47 /* don't have any cached variables */
48 rmb();
49 if (ret == RES_OK)
50 /* read return-value now */
51 return ioread16(&card->dpram[DPRAM_FCT_RESULT]);
52
53 if ((ret != vector) || time_after(jiffies, stamp))
54 break;
55 /* process context => relax */
56 usleep_range(500, 10000);
57 } while (1);
58
59 ret = (ret == RES_NONE) ? -ETIMEDOUT : -ECANCELED;
60 dev_alert(&card->pdev->dev, "firmware %s failed (%i)\n", msg, ret);
61 return ret;
62}
63
64static int softing_fct_cmd(struct softing *card, int16_t cmd, const char *msg)
65{
66 int ret;
67
68 ret = _softing_fct_cmd(card, cmd, 0, msg);
69 if (ret > 0) {
70 dev_alert(&card->pdev->dev, "%s returned %u\n", msg, ret);
71 ret = -EIO;
72 }
73 return ret;
74}
75
76int softing_bootloader_command(struct softing *card, int16_t cmd,
77 const char *msg)
78{
79 int ret;
80 unsigned long stamp;
81
82 iowrite16(RES_NONE, &card->dpram[DPRAM_RECEIPT]);
83 iowrite16(cmd, &card->dpram[DPRAM_COMMAND]);
84 /* be sure to flush this to the card */
85 wmb();
86 stamp = jiffies + 3 * HZ;
87 /* wait for card */
88 do {
89 ret = ioread16(&card->dpram[DPRAM_RECEIPT]);
90 /* don't have any cached variables */
91 rmb();
92 if (ret == RES_OK)
93 return 0;
94 if (time_after(jiffies, stamp))
95 break;
96 /* process context => relax */
97 usleep_range(500, 10000);
98 } while (!signal_pending(current));
99
100 ret = (ret == RES_NONE) ? -ETIMEDOUT : -ECANCELED;
101 dev_alert(&card->pdev->dev, "bootloader %s failed (%i)\n", msg, ret);
102 return ret;
103}
104
105static int fw_parse(const uint8_t **pmem, uint16_t *ptype, uint32_t *paddr,
106 uint16_t *plen, const uint8_t **pdat)
107{
108 uint16_t checksum[2];
109 const uint8_t *mem;
110 const uint8_t *end;
111
112 /*
113 * firmware records are a binary, unaligned stream composed of:
114 * uint16_t type;
115 * uint32_t addr;
116 * uint16_t len;
117 * uint8_t dat[len];
118 * uint16_t checksum;
119 * all values in little endian.
120 * We could define a struct for this, with __attribute__((packed)),
121 * but would that solve the alignment in _all_ cases (cfr. the
122 * struct itself may be an odd address)?
123 *
124 * I chose to use leXX_to_cpup() since this solves both
125 * endianness & alignment.
126 */
127 mem = *pmem;
128 *ptype = le16_to_cpup((void *)&mem[0]);
129 *paddr = le32_to_cpup((void *)&mem[2]);
130 *plen = le16_to_cpup((void *)&mem[6]);
131 *pdat = &mem[8];
132 /* verify checksum */
133 end = &mem[8 + *plen];
134 checksum[0] = le16_to_cpup((void *)end);
135 for (checksum[1] = 0; mem < end; ++mem)
136 checksum[1] += *mem;
137 if (checksum[0] != checksum[1])
138 return -EINVAL;
139 /* increment */
140 *pmem += 10 + *plen;
141 return 0;
142}
143
144int softing_load_fw(const char *file, struct softing *card,
145 __iomem uint8_t *dpram, unsigned int size, int offset)
146{
147 const struct firmware *fw;
148 int ret;
149 const uint8_t *mem, *end, *dat;
150 uint16_t type, len;
151 uint32_t addr;
152 uint8_t *buf = NULL;
153 int buflen = 0;
154 int8_t type_end = 0;
155
156 ret = request_firmware(&fw, file, &card->pdev->dev);
157 if (ret < 0)
158 return ret;
159 dev_dbg(&card->pdev->dev, "%s, firmware(%s) got %u bytes"
160 ", offset %c0x%04x\n",
161 card->pdat->name, file, (unsigned int)fw->size,
162 (offset >= 0) ? '+' : '-', (unsigned int)abs(offset));
163 /* parse the firmware */
164 mem = fw->data;
165 end = &mem[fw->size];
166 /* look for header record */
167 ret = fw_parse(&mem, &type, &addr, &len, &dat);
168 if (ret < 0)
169 goto failed;
170 if (type != 0xffff)
171 goto failed;
172 if (strncmp("Structured Binary Format, Softing GmbH" , dat, len)) {
173 ret = -EINVAL;
174 goto failed;
175 }
176 /* ok, we had a header */
177 while (mem < end) {
178 ret = fw_parse(&mem, &type, &addr, &len, &dat);
179 if (ret < 0)
180 goto failed;
181 if (type == 3) {
182 /* start address, not used here */
183 continue;
184 } else if (type == 1) {
185 /* eof */
186 type_end = 1;
187 break;
188 } else if (type != 0) {
189 ret = -EINVAL;
190 goto failed;
191 }
192
193 if ((addr + len + offset) > size)
194 goto failed;
195 memcpy_toio(&dpram[addr + offset], dat, len);
196 /* be sure to flush caches from IO space */
197 mb();
198 if (len > buflen) {
199 /* align buflen */
200 buflen = (len + (1024-1)) & ~(1024-1);
201 buf = krealloc(buf, buflen, GFP_KERNEL);
202 if (!buf) {
203 ret = -ENOMEM;
204 goto failed;
205 }
206 }
207 /* verify record data */
208 memcpy_fromio(buf, &dpram[addr + offset], len);
209 if (memcmp(buf, dat, len)) {
210 /* is not ok */
211 dev_alert(&card->pdev->dev, "DPRAM readback failed\n");
212 ret = -EIO;
213 goto failed;
214 }
215 }
216 if (!type_end)
217 /* no end record seen */
218 goto failed;
219 ret = 0;
220failed:
221 kfree(buf);
222 release_firmware(fw);
223 if (ret < 0)
224 dev_info(&card->pdev->dev, "firmware %s failed\n", file);
225 return ret;
226}
227
228int softing_load_app_fw(const char *file, struct softing *card)
229{
230 const struct firmware *fw;
231 const uint8_t *mem, *end, *dat;
232 int ret, j;
233 uint16_t type, len;
234 uint32_t addr, start_addr = 0;
235 unsigned int sum, rx_sum;
236 int8_t type_end = 0, type_entrypoint = 0;
237
238 ret = request_firmware(&fw, file, &card->pdev->dev);
239 if (ret) {
240 dev_alert(&card->pdev->dev, "request_firmware(%s) got %i\n",
241 file, ret);
242 return ret;
243 }
244 dev_dbg(&card->pdev->dev, "firmware(%s) got %lu bytes\n",
245 file, (unsigned long)fw->size);
246 /* parse the firmware */
247 mem = fw->data;
248 end = &mem[fw->size];
249 /* look for header record */
250 ret = fw_parse(&mem, &type, &addr, &len, &dat);
251 if (ret)
252 goto failed;
253 ret = -EINVAL;
254 if (type != 0xffff) {
255 dev_alert(&card->pdev->dev, "firmware starts with type 0x%x\n",
256 type);
257 goto failed;
258 }
259 if (strncmp("Structured Binary Format, Softing GmbH", dat, len)) {
260 dev_alert(&card->pdev->dev, "firmware string '%.*s' fault\n",
261 len, dat);
262 goto failed;
263 }
264 /* ok, we had a header */
265 while (mem < end) {
266 ret = fw_parse(&mem, &type, &addr, &len, &dat);
267 if (ret)
268 goto failed;
269
270 if (type == 3) {
271 /* start address */
272 start_addr = addr;
273 type_entrypoint = 1;
274 continue;
275 } else if (type == 1) {
276 /* eof */
277 type_end = 1;
278 break;
279 } else if (type != 0) {
280 dev_alert(&card->pdev->dev,
281 "unknown record type 0x%04x\n", type);
282 ret = -EINVAL;
283 goto failed;
284 }
285
286 /* regualar data */
287 for (sum = 0, j = 0; j < len; ++j)
288 sum += dat[j];
289 /* work in 16bit (target) */
290 sum &= 0xffff;
291
292 memcpy_toio(&card->dpram[card->pdat->app.offs], dat, len);
293 iowrite32(card->pdat->app.offs + card->pdat->app.addr,
294 &card->dpram[DPRAM_COMMAND + 2]);
295 iowrite32(addr, &card->dpram[DPRAM_COMMAND + 6]);
296 iowrite16(len, &card->dpram[DPRAM_COMMAND + 10]);
297 iowrite8(1, &card->dpram[DPRAM_COMMAND + 12]);
298 ret = softing_bootloader_command(card, 1, "loading app.");
299 if (ret < 0)
300 goto failed;
301 /* verify checksum */
302 rx_sum = ioread16(&card->dpram[DPRAM_RECEIPT + 2]);
303 if (rx_sum != sum) {
304 dev_alert(&card->pdev->dev, "SRAM seems to be damaged"
305 ", wanted 0x%04x, got 0x%04x\n", sum, rx_sum);
306 ret = -EIO;
307 goto failed;
308 }
309 }
310 if (!type_end || !type_entrypoint)
311 goto failed;
312 /* start application in card */
313 iowrite32(start_addr, &card->dpram[DPRAM_COMMAND + 2]);
314 iowrite8(1, &card->dpram[DPRAM_COMMAND + 6]);
315 ret = softing_bootloader_command(card, 3, "start app.");
316 if (ret < 0)
317 goto failed;
318 ret = 0;
319failed:
320 release_firmware(fw);
321 if (ret < 0)
322 dev_info(&card->pdev->dev, "firmware %s failed\n", file);
323 return ret;
324}
325
326static int softing_reset_chip(struct softing *card)
327{
328 int ret;
329
330 do {
331 /* reset chip */
332 iowrite8(0, &card->dpram[DPRAM_RESET_RX_FIFO]);
333 iowrite8(0, &card->dpram[DPRAM_RESET_RX_FIFO+1]);
334 iowrite8(1, &card->dpram[DPRAM_RESET]);
335 iowrite8(0, &card->dpram[DPRAM_RESET+1]);
336
337 ret = softing_fct_cmd(card, 0, "reset_can");
338 if (!ret)
339 break;
340 if (signal_pending(current))
341 /* don't wait any longer */
342 break;
343 } while (1);
344 card->tx.pending = 0;
345 return ret;
346}
347
348int softing_chip_poweron(struct softing *card)
349{
350 int ret;
351 /* sync */
352 ret = _softing_fct_cmd(card, 99, 0x55, "sync-a");
353 if (ret < 0)
354 goto failed;
355
356 ret = _softing_fct_cmd(card, 99, 0xaa, "sync-b");
357 if (ret < 0)
358 goto failed;
359
360 ret = softing_reset_chip(card);
361 if (ret < 0)
362 goto failed;
363 /* get_serial */
364 ret = softing_fct_cmd(card, 43, "get_serial_number");
365 if (ret < 0)
366 goto failed;
367 card->id.serial = ioread32(&card->dpram[DPRAM_FCT_PARAM]);
368 /* get_version */
369 ret = softing_fct_cmd(card, 12, "get_version");
370 if (ret < 0)
371 goto failed;
372 card->id.fw_version = ioread16(&card->dpram[DPRAM_FCT_PARAM + 2]);
373 card->id.hw_version = ioread16(&card->dpram[DPRAM_FCT_PARAM + 4]);
374 card->id.license = ioread16(&card->dpram[DPRAM_FCT_PARAM + 6]);
375 card->id.chip[0] = ioread16(&card->dpram[DPRAM_FCT_PARAM + 8]);
376 card->id.chip[1] = ioread16(&card->dpram[DPRAM_FCT_PARAM + 10]);
377 return 0;
378failed:
379 return ret;
380}
381
382static void softing_initialize_timestamp(struct softing *card)
383{
384 uint64_t ovf;
385
386 card->ts_ref = ktime_get();
387
388 /* 16MHz is the reference */
389 ovf = 0x100000000ULL * 16;
390 do_div(ovf, card->pdat->freq ?: 16);
391
392 card->ts_overflow = ktime_add_us(ktime_set(0, 0), ovf);
393}
394
395ktime_t softing_raw2ktime(struct softing *card, u32 raw)
396{
397 uint64_t rawl;
398 ktime_t now, real_offset;
399 ktime_t target;
400 ktime_t tmp;
401
402 now = ktime_get();
403 real_offset = ktime_sub(ktime_get_real(), now);
404
405 /* find nsec from card */
406 rawl = raw * 16;
407 do_div(rawl, card->pdat->freq ?: 16);
408 target = ktime_add_us(card->ts_ref, rawl);
409 /* test for overflows */
410 tmp = ktime_add(target, card->ts_overflow);
411 while (unlikely(ktime_to_ns(tmp) > ktime_to_ns(now))) {
412 card->ts_ref = ktime_add(card->ts_ref, card->ts_overflow);
413 target = tmp;
414 tmp = ktime_add(target, card->ts_overflow);
415 }
416 return ktime_add(target, real_offset);
417}
418
419static inline int softing_error_reporting(struct net_device *netdev)
420{
421 struct softing_priv *priv = netdev_priv(netdev);
422
423 return (priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING)
424 ? 1 : 0;
425}
426
427int softing_startstop(struct net_device *dev, int up)
428{
429 int ret;
430 struct softing *card;
431 struct softing_priv *priv;
432 struct net_device *netdev;
433 int bus_bitmask_start;
434 int j, error_reporting;
435 struct can_frame msg;
436 const struct can_bittiming *bt;
437
438 priv = netdev_priv(dev);
439 card = priv->card;
440
441 if (!card->fw.up)
442 return -EIO;
443
444 ret = mutex_lock_interruptible(&card->fw.lock);
445 if (ret)
446 return ret;
447
448 bus_bitmask_start = 0;
449 if (dev && up)
450 /* prepare to start this bus as well */
451 bus_bitmask_start |= (1 << priv->index);
452 /* bring netdevs down */
453 for (j = 0; j < ARRAY_SIZE(card->net); ++j) {
454 netdev = card->net[j];
455 if (!netdev)
456 continue;
457 priv = netdev_priv(netdev);
458
459 if (dev != netdev)
460 netif_stop_queue(netdev);
461
462 if (netif_running(netdev)) {
463 if (dev != netdev)
464 bus_bitmask_start |= (1 << j);
465 priv->tx.pending = 0;
466 priv->tx.echo_put = 0;
467 priv->tx.echo_get = 0;
468 /*
469 * this bus' may just have called open_candev()
470 * which is rather stupid to call close_candev()
471 * already
472 * but we may come here from busoff recovery too
473 * in which case the echo_skb _needs_ flushing too.
474 * just be sure to call open_candev() again
475 */
476 close_candev(netdev);
477 }
478 priv->can.state = CAN_STATE_STOPPED;
479 }
480 card->tx.pending = 0;
481
482 softing_enable_irq(card, 0);
483 ret = softing_reset_chip(card);
484 if (ret)
485 goto failed;
486 if (!bus_bitmask_start)
487 /* no busses to be brought up */
488 goto card_done;
489
490 if ((bus_bitmask_start & 1) && (bus_bitmask_start & 2)
491 && (softing_error_reporting(card->net[0])
492 != softing_error_reporting(card->net[1]))) {
493 dev_alert(&card->pdev->dev,
494 "err_reporting flag differs for busses\n");
495 goto invalid;
496 }
497 error_reporting = 0;
498 if (bus_bitmask_start & 1) {
499 netdev = card->net[0];
500 priv = netdev_priv(netdev);
501 error_reporting += softing_error_reporting(netdev);
502 /* init chip 1 */
503 bt = &priv->can.bittiming;
504 iowrite16(bt->brp, &card->dpram[DPRAM_FCT_PARAM + 2]);
505 iowrite16(bt->sjw, &card->dpram[DPRAM_FCT_PARAM + 4]);
506 iowrite16(bt->phase_seg1 + bt->prop_seg,
507 &card->dpram[DPRAM_FCT_PARAM + 6]);
508 iowrite16(bt->phase_seg2, &card->dpram[DPRAM_FCT_PARAM + 8]);
509 iowrite16((priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES) ? 1 : 0,
510 &card->dpram[DPRAM_FCT_PARAM + 10]);
511 ret = softing_fct_cmd(card, 1, "initialize_chip[0]");
512 if (ret < 0)
513 goto failed;
514 /* set mode */
515 iowrite16(0, &card->dpram[DPRAM_FCT_PARAM + 2]);
516 iowrite16(0, &card->dpram[DPRAM_FCT_PARAM + 4]);
517 ret = softing_fct_cmd(card, 3, "set_mode[0]");
518 if (ret < 0)
519 goto failed;
520 /* set filter */
521 /* 11bit id & mask */
522 iowrite16(0x0000, &card->dpram[DPRAM_FCT_PARAM + 2]);
523 iowrite16(0x07ff, &card->dpram[DPRAM_FCT_PARAM + 4]);
524 /* 29bit id.lo & mask.lo & id.hi & mask.hi */
525 iowrite16(0x0000, &card->dpram[DPRAM_FCT_PARAM + 6]);
526 iowrite16(0xffff, &card->dpram[DPRAM_FCT_PARAM + 8]);
527 iowrite16(0x0000, &card->dpram[DPRAM_FCT_PARAM + 10]);
528 iowrite16(0x1fff, &card->dpram[DPRAM_FCT_PARAM + 12]);
529 ret = softing_fct_cmd(card, 7, "set_filter[0]");
530 if (ret < 0)
531 goto failed;
532 /* set output control */
533 iowrite16(priv->output, &card->dpram[DPRAM_FCT_PARAM + 2]);
534 ret = softing_fct_cmd(card, 5, "set_output[0]");
535 if (ret < 0)
536 goto failed;
537 }
538 if (bus_bitmask_start & 2) {
539 netdev = card->net[1];
540 priv = netdev_priv(netdev);
541 error_reporting += softing_error_reporting(netdev);
542 /* init chip2 */
543 bt = &priv->can.bittiming;
544 iowrite16(bt->brp, &card->dpram[DPRAM_FCT_PARAM + 2]);
545 iowrite16(bt->sjw, &card->dpram[DPRAM_FCT_PARAM + 4]);
546 iowrite16(bt->phase_seg1 + bt->prop_seg,
547 &card->dpram[DPRAM_FCT_PARAM + 6]);
548 iowrite16(bt->phase_seg2, &card->dpram[DPRAM_FCT_PARAM + 8]);
549 iowrite16((priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES) ? 1 : 0,
550 &card->dpram[DPRAM_FCT_PARAM + 10]);
551 ret = softing_fct_cmd(card, 2, "initialize_chip[1]");
552 if (ret < 0)
553 goto failed;
554 /* set mode2 */
555 iowrite16(0, &card->dpram[DPRAM_FCT_PARAM + 2]);
556 iowrite16(0, &card->dpram[DPRAM_FCT_PARAM + 4]);
557 ret = softing_fct_cmd(card, 4, "set_mode[1]");
558 if (ret < 0)
559 goto failed;
560 /* set filter2 */
561 /* 11bit id & mask */
562 iowrite16(0x0000, &card->dpram[DPRAM_FCT_PARAM + 2]);
563 iowrite16(0x07ff, &card->dpram[DPRAM_FCT_PARAM + 4]);
564 /* 29bit id.lo & mask.lo & id.hi & mask.hi */
565 iowrite16(0x0000, &card->dpram[DPRAM_FCT_PARAM + 6]);
566 iowrite16(0xffff, &card->dpram[DPRAM_FCT_PARAM + 8]);
567 iowrite16(0x0000, &card->dpram[DPRAM_FCT_PARAM + 10]);
568 iowrite16(0x1fff, &card->dpram[DPRAM_FCT_PARAM + 12]);
569 ret = softing_fct_cmd(card, 8, "set_filter[1]");
570 if (ret < 0)
571 goto failed;
572 /* set output control2 */
573 iowrite16(priv->output, &card->dpram[DPRAM_FCT_PARAM + 2]);
574 ret = softing_fct_cmd(card, 6, "set_output[1]");
575 if (ret < 0)
576 goto failed;
577 }
578 /* enable_error_frame */
579 /*
580 * Error reporting is switched off at the moment since
581 * the receiving of them is not yet 100% verified
582 * This should be enabled sooner or later
583 *
584 if (error_reporting) {
585 ret = softing_fct_cmd(card, 51, "enable_error_frame");
586 if (ret < 0)
587 goto failed;
588 }
589 */
590 /* initialize interface */
591 iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 2]);
592 iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 4]);
593 iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 6]);
594 iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 8]);
595 iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 10]);
596 iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 12]);
597 iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 14]);
598 iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 16]);
599 iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 18]);
600 iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 20]);
601 ret = softing_fct_cmd(card, 17, "initialize_interface");
602 if (ret < 0)
603 goto failed;
604 /* enable_fifo */
605 ret = softing_fct_cmd(card, 36, "enable_fifo");
606 if (ret < 0)
607 goto failed;
608 /* enable fifo tx ack */
609 ret = softing_fct_cmd(card, 13, "fifo_tx_ack[0]");
610 if (ret < 0)
611 goto failed;
612 /* enable fifo tx ack2 */
613 ret = softing_fct_cmd(card, 14, "fifo_tx_ack[1]");
614 if (ret < 0)
615 goto failed;
616 /* start_chip */
617 ret = softing_fct_cmd(card, 11, "start_chip");
618 if (ret < 0)
619 goto failed;
620 iowrite8(0, &card->dpram[DPRAM_INFO_BUSSTATE]);
621 iowrite8(0, &card->dpram[DPRAM_INFO_BUSSTATE2]);
622 if (card->pdat->generation < 2) {
623 iowrite8(0, &card->dpram[DPRAM_V2_IRQ_TOHOST]);
624 /* flush the DPRAM caches */
625 wmb();
626 }
627
628 softing_initialize_timestamp(card);
629
630 /*
631 * do socketcan notifications/status changes
632 * from here, no errors should occur, or the failed: part
633 * must be reviewed
634 */
635 memset(&msg, 0, sizeof(msg));
636 msg.can_id = CAN_ERR_FLAG | CAN_ERR_RESTARTED;
637 msg.can_dlc = CAN_ERR_DLC;
638 for (j = 0; j < ARRAY_SIZE(card->net); ++j) {
639 if (!(bus_bitmask_start & (1 << j)))
640 continue;
641 netdev = card->net[j];
642 if (!netdev)
643 continue;
644 priv = netdev_priv(netdev);
645 priv->can.state = CAN_STATE_ERROR_ACTIVE;
646 open_candev(netdev);
647 if (dev != netdev) {
648 /* notify other busses on the restart */
649 softing_netdev_rx(netdev, &msg, ktime_set(0, 0));
650 ++priv->can.can_stats.restarts;
651 }
652 netif_wake_queue(netdev);
653 }
654
655 /* enable interrupts */
656 ret = softing_enable_irq(card, 1);
657 if (ret)
658 goto failed;
659card_done:
660 mutex_unlock(&card->fw.lock);
661 return 0;
662invalid:
663 ret = -EINVAL;
664failed:
665 softing_enable_irq(card, 0);
666 softing_reset_chip(card);
667 mutex_unlock(&card->fw.lock);
668 /* bring all other interfaces down */
669 for (j = 0; j < ARRAY_SIZE(card->net); ++j) {
670 netdev = card->net[j];
671 if (!netdev)
672 continue;
673 dev_close(netdev);
674 }
675 return ret;
676}
677
678int softing_default_output(struct net_device *netdev)
679{
680 struct softing_priv *priv = netdev_priv(netdev);
681 struct softing *card = priv->card;
682
683 switch (priv->chip) {
684 case 1000:
685 return (card->pdat->generation < 2) ? 0xfb : 0xfa;
686 case 5:
687 return 0x60;
688 default:
689 return 0x40;
690 }
691}
diff --git a/drivers/net/can/softing/softing_main.c b/drivers/net/can/softing/softing_main.c
new file mode 100644
index 000000000000..5157e15e96eb
--- /dev/null
+++ b/drivers/net/can/softing/softing_main.c
@@ -0,0 +1,893 @@
1/*
2 * Copyright (C) 2008-2010
3 *
4 * - Kurt Van Dijck, EIA Electronics
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the version 2 of the GNU General Public License
8 * as published by the Free Software Foundation
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#include <linux/version.h>
21#include <linux/module.h>
22#include <linux/init.h>
23#include <linux/interrupt.h>
24
25#include "softing.h"
26
27#define TX_ECHO_SKB_MAX (((TXMAX+1)/2)-1)
28
29/*
30 * test is a specific CAN netdev
31 * is online (ie. up 'n running, not sleeping, not busoff
32 */
33static inline int canif_is_active(struct net_device *netdev)
34{
35 struct can_priv *can = netdev_priv(netdev);
36
37 if (!netif_running(netdev))
38 return 0;
39 return (can->state <= CAN_STATE_ERROR_PASSIVE);
40}
41
42/* reset DPRAM */
43static inline void softing_set_reset_dpram(struct softing *card)
44{
45 if (card->pdat->generation >= 2) {
46 spin_lock_bh(&card->spin);
47 iowrite8(ioread8(&card->dpram[DPRAM_V2_RESET]) & ~1,
48 &card->dpram[DPRAM_V2_RESET]);
49 spin_unlock_bh(&card->spin);
50 }
51}
52
53static inline void softing_clr_reset_dpram(struct softing *card)
54{
55 if (card->pdat->generation >= 2) {
56 spin_lock_bh(&card->spin);
57 iowrite8(ioread8(&card->dpram[DPRAM_V2_RESET]) | 1,
58 &card->dpram[DPRAM_V2_RESET]);
59 spin_unlock_bh(&card->spin);
60 }
61}
62
63/* trigger the tx queue-ing */
64static netdev_tx_t softing_netdev_start_xmit(struct sk_buff *skb,
65 struct net_device *dev)
66{
67 struct softing_priv *priv = netdev_priv(dev);
68 struct softing *card = priv->card;
69 int ret;
70 uint8_t *ptr;
71 uint8_t fifo_wr, fifo_rd;
72 struct can_frame *cf = (struct can_frame *)skb->data;
73 uint8_t buf[DPRAM_TX_SIZE];
74
75 if (can_dropped_invalid_skb(dev, skb))
76 return NETDEV_TX_OK;
77
78 spin_lock(&card->spin);
79
80 ret = NETDEV_TX_BUSY;
81 if (!card->fw.up ||
82 (card->tx.pending >= TXMAX) ||
83 (priv->tx.pending >= TX_ECHO_SKB_MAX))
84 goto xmit_done;
85 fifo_wr = ioread8(&card->dpram[DPRAM_TX_WR]);
86 fifo_rd = ioread8(&card->dpram[DPRAM_TX_RD]);
87 if (fifo_wr == fifo_rd)
88 /* fifo full */
89 goto xmit_done;
90 memset(buf, 0, sizeof(buf));
91 ptr = buf;
92 *ptr = CMD_TX;
93 if (cf->can_id & CAN_RTR_FLAG)
94 *ptr |= CMD_RTR;
95 if (cf->can_id & CAN_EFF_FLAG)
96 *ptr |= CMD_XTD;
97 if (priv->index)
98 *ptr |= CMD_BUS2;
99 ++ptr;
100 *ptr++ = cf->can_dlc;
101 *ptr++ = (cf->can_id >> 0);
102 *ptr++ = (cf->can_id >> 8);
103 if (cf->can_id & CAN_EFF_FLAG) {
104 *ptr++ = (cf->can_id >> 16);
105 *ptr++ = (cf->can_id >> 24);
106 } else {
107 /* increment 1, not 2 as you might think */
108 ptr += 1;
109 }
110 if (!(cf->can_id & CAN_RTR_FLAG))
111 memcpy(ptr, &cf->data[0], cf->can_dlc);
112 memcpy_toio(&card->dpram[DPRAM_TX + DPRAM_TX_SIZE * fifo_wr],
113 buf, DPRAM_TX_SIZE);
114 if (++fifo_wr >= DPRAM_TX_CNT)
115 fifo_wr = 0;
116 iowrite8(fifo_wr, &card->dpram[DPRAM_TX_WR]);
117 card->tx.last_bus = priv->index;
118 ++card->tx.pending;
119 ++priv->tx.pending;
120 can_put_echo_skb(skb, dev, priv->tx.echo_put);
121 ++priv->tx.echo_put;
122 if (priv->tx.echo_put >= TX_ECHO_SKB_MAX)
123 priv->tx.echo_put = 0;
124 /* can_put_echo_skb() saves the skb, safe to return TX_OK */
125 ret = NETDEV_TX_OK;
126xmit_done:
127 spin_unlock(&card->spin);
128 if (card->tx.pending >= TXMAX) {
129 int j;
130 for (j = 0; j < ARRAY_SIZE(card->net); ++j) {
131 if (card->net[j])
132 netif_stop_queue(card->net[j]);
133 }
134 }
135 if (ret != NETDEV_TX_OK)
136 netif_stop_queue(dev);
137
138 return ret;
139}
140
141/*
142 * shortcut for skb delivery
143 */
144int softing_netdev_rx(struct net_device *netdev, const struct can_frame *msg,
145 ktime_t ktime)
146{
147 struct sk_buff *skb;
148 struct can_frame *cf;
149
150 skb = alloc_can_skb(netdev, &cf);
151 if (!skb)
152 return -ENOMEM;
153 memcpy(cf, msg, sizeof(*msg));
154 skb->tstamp = ktime;
155 return netif_rx(skb);
156}
157
158/*
159 * softing_handle_1
160 * pop 1 entry from the DPRAM queue, and process
161 */
162static int softing_handle_1(struct softing *card)
163{
164 struct net_device *netdev;
165 struct softing_priv *priv;
166 ktime_t ktime;
167 struct can_frame msg;
168 int cnt = 0, lost_msg;
169 uint8_t fifo_rd, fifo_wr, cmd;
170 uint8_t *ptr;
171 uint32_t tmp_u32;
172 uint8_t buf[DPRAM_RX_SIZE];
173
174 memset(&msg, 0, sizeof(msg));
175 /* test for lost msgs */
176 lost_msg = ioread8(&card->dpram[DPRAM_RX_LOST]);
177 if (lost_msg) {
178 int j;
179 /* reset condition */
180 iowrite8(0, &card->dpram[DPRAM_RX_LOST]);
181 /* prepare msg */
182 msg.can_id = CAN_ERR_FLAG | CAN_ERR_CRTL;
183 msg.can_dlc = CAN_ERR_DLC;
184 msg.data[1] = CAN_ERR_CRTL_RX_OVERFLOW;
185 /*
186 * service to all busses, we don't know which it was applicable
187 * but only service busses that are online
188 */
189 for (j = 0; j < ARRAY_SIZE(card->net); ++j) {
190 netdev = card->net[j];
191 if (!netdev)
192 continue;
193 if (!canif_is_active(netdev))
194 /* a dead bus has no overflows */
195 continue;
196 ++netdev->stats.rx_over_errors;
197 softing_netdev_rx(netdev, &msg, ktime_set(0, 0));
198 }
199 /* prepare for other use */
200 memset(&msg, 0, sizeof(msg));
201 ++cnt;
202 }
203
204 fifo_rd = ioread8(&card->dpram[DPRAM_RX_RD]);
205 fifo_wr = ioread8(&card->dpram[DPRAM_RX_WR]);
206
207 if (++fifo_rd >= DPRAM_RX_CNT)
208 fifo_rd = 0;
209 if (fifo_wr == fifo_rd)
210 return cnt;
211
212 memcpy_fromio(buf, &card->dpram[DPRAM_RX + DPRAM_RX_SIZE*fifo_rd],
213 DPRAM_RX_SIZE);
214 mb();
215 /* trigger dual port RAM */
216 iowrite8(fifo_rd, &card->dpram[DPRAM_RX_RD]);
217
218 ptr = buf;
219 cmd = *ptr++;
220 if (cmd == 0xff)
221 /* not quite usefull, probably the card has got out */
222 return 0;
223 netdev = card->net[0];
224 if (cmd & CMD_BUS2)
225 netdev = card->net[1];
226 priv = netdev_priv(netdev);
227
228 if (cmd & CMD_ERR) {
229 uint8_t can_state, state;
230
231 state = *ptr++;
232
233 msg.can_id = CAN_ERR_FLAG;
234 msg.can_dlc = CAN_ERR_DLC;
235
236 if (state & SF_MASK_BUSOFF) {
237 can_state = CAN_STATE_BUS_OFF;
238 msg.can_id |= CAN_ERR_BUSOFF;
239 state = STATE_BUSOFF;
240 } else if (state & SF_MASK_EPASSIVE) {
241 can_state = CAN_STATE_ERROR_PASSIVE;
242 msg.can_id |= CAN_ERR_CRTL;
243 msg.data[1] = CAN_ERR_CRTL_TX_PASSIVE;
244 state = STATE_EPASSIVE;
245 } else {
246 can_state = CAN_STATE_ERROR_ACTIVE;
247 msg.can_id |= CAN_ERR_CRTL;
248 state = STATE_EACTIVE;
249 }
250 /* update DPRAM */
251 iowrite8(state, &card->dpram[priv->index ?
252 DPRAM_INFO_BUSSTATE2 : DPRAM_INFO_BUSSTATE]);
253 /* timestamp */
254 tmp_u32 = le32_to_cpup((void *)ptr);
255 ptr += 4;
256 ktime = softing_raw2ktime(card, tmp_u32);
257
258 ++netdev->stats.rx_errors;
259 /* update internal status */
260 if (can_state != priv->can.state) {
261 priv->can.state = can_state;
262 if (can_state == CAN_STATE_ERROR_PASSIVE)
263 ++priv->can.can_stats.error_passive;
264 else if (can_state == CAN_STATE_BUS_OFF) {
265 /* this calls can_close_cleanup() */
266 can_bus_off(netdev);
267 netif_stop_queue(netdev);
268 }
269 /* trigger socketcan */
270 softing_netdev_rx(netdev, &msg, ktime);
271 }
272
273 } else {
274 if (cmd & CMD_RTR)
275 msg.can_id |= CAN_RTR_FLAG;
276 msg.can_dlc = get_can_dlc(*ptr++);
277 if (cmd & CMD_XTD) {
278 msg.can_id |= CAN_EFF_FLAG;
279 msg.can_id |= le32_to_cpup((void *)ptr);
280 ptr += 4;
281 } else {
282 msg.can_id |= le16_to_cpup((void *)ptr);
283 ptr += 2;
284 }
285 /* timestamp */
286 tmp_u32 = le32_to_cpup((void *)ptr);
287 ptr += 4;
288 ktime = softing_raw2ktime(card, tmp_u32);
289 if (!(msg.can_id & CAN_RTR_FLAG))
290 memcpy(&msg.data[0], ptr, 8);
291 ptr += 8;
292 /* update socket */
293 if (cmd & CMD_ACK) {
294 /* acknowledge, was tx msg */
295 struct sk_buff *skb;
296 skb = priv->can.echo_skb[priv->tx.echo_get];
297 if (skb)
298 skb->tstamp = ktime;
299 can_get_echo_skb(netdev, priv->tx.echo_get);
300 ++priv->tx.echo_get;
301 if (priv->tx.echo_get >= TX_ECHO_SKB_MAX)
302 priv->tx.echo_get = 0;
303 if (priv->tx.pending)
304 --priv->tx.pending;
305 if (card->tx.pending)
306 --card->tx.pending;
307 ++netdev->stats.tx_packets;
308 if (!(msg.can_id & CAN_RTR_FLAG))
309 netdev->stats.tx_bytes += msg.can_dlc;
310 } else {
311 int ret;
312
313 ret = softing_netdev_rx(netdev, &msg, ktime);
314 if (ret == NET_RX_SUCCESS) {
315 ++netdev->stats.rx_packets;
316 if (!(msg.can_id & CAN_RTR_FLAG))
317 netdev->stats.rx_bytes += msg.can_dlc;
318 } else {
319 ++netdev->stats.rx_dropped;
320 }
321 }
322 }
323 ++cnt;
324 return cnt;
325}
326
327/*
328 * real interrupt handler
329 */
330static irqreturn_t softing_irq_thread(int irq, void *dev_id)
331{
332 struct softing *card = (struct softing *)dev_id;
333 struct net_device *netdev;
334 struct softing_priv *priv;
335 int j, offset, work_done;
336
337 work_done = 0;
338 spin_lock_bh(&card->spin);
339 while (softing_handle_1(card) > 0) {
340 ++card->irq.svc_count;
341 ++work_done;
342 }
343 spin_unlock_bh(&card->spin);
344 /* resume tx queue's */
345 offset = card->tx.last_bus;
346 for (j = 0; j < ARRAY_SIZE(card->net); ++j) {
347 if (card->tx.pending >= TXMAX)
348 break;
349 netdev = card->net[(j + offset + 1) % card->pdat->nbus];
350 if (!netdev)
351 continue;
352 priv = netdev_priv(netdev);
353 if (!canif_is_active(netdev))
354 /* it makes no sense to wake dead busses */
355 continue;
356 if (priv->tx.pending >= TX_ECHO_SKB_MAX)
357 continue;
358 ++work_done;
359 netif_wake_queue(netdev);
360 }
361 return work_done ? IRQ_HANDLED : IRQ_NONE;
362}
363
364/*
365 * interrupt routines:
366 * schedule the 'real interrupt handler'
367 */
368static irqreturn_t softing_irq_v2(int irq, void *dev_id)
369{
370 struct softing *card = (struct softing *)dev_id;
371 uint8_t ir;
372
373 ir = ioread8(&card->dpram[DPRAM_V2_IRQ_TOHOST]);
374 iowrite8(0, &card->dpram[DPRAM_V2_IRQ_TOHOST]);
375 return (1 == ir) ? IRQ_WAKE_THREAD : IRQ_NONE;
376}
377
378static irqreturn_t softing_irq_v1(int irq, void *dev_id)
379{
380 struct softing *card = (struct softing *)dev_id;
381 uint8_t ir;
382
383 ir = ioread8(&card->dpram[DPRAM_IRQ_TOHOST]);
384 iowrite8(0, &card->dpram[DPRAM_IRQ_TOHOST]);
385 return ir ? IRQ_WAKE_THREAD : IRQ_NONE;
386}
387
388/*
389 * netdev/candev inter-operability
390 */
391static int softing_netdev_open(struct net_device *ndev)
392{
393 int ret;
394
395 /* check or determine and set bittime */
396 ret = open_candev(ndev);
397 if (!ret)
398 ret = softing_startstop(ndev, 1);
399 return ret;
400}
401
402static int softing_netdev_stop(struct net_device *ndev)
403{
404 int ret;
405
406 netif_stop_queue(ndev);
407
408 /* softing cycle does close_candev() */
409 ret = softing_startstop(ndev, 0);
410 return ret;
411}
412
413static int softing_candev_set_mode(struct net_device *ndev, enum can_mode mode)
414{
415 int ret;
416
417 switch (mode) {
418 case CAN_MODE_START:
419 /* softing_startstop does close_candev() */
420 ret = softing_startstop(ndev, 1);
421 return ret;
422 case CAN_MODE_STOP:
423 case CAN_MODE_SLEEP:
424 return -EOPNOTSUPP;
425 }
426 return 0;
427}
428
429/*
430 * Softing device management helpers
431 */
432int softing_enable_irq(struct softing *card, int enable)
433{
434 int ret;
435
436 if (!card->irq.nr) {
437 return 0;
438 } else if (card->irq.requested && !enable) {
439 free_irq(card->irq.nr, card);
440 card->irq.requested = 0;
441 } else if (!card->irq.requested && enable) {
442 ret = request_threaded_irq(card->irq.nr,
443 (card->pdat->generation >= 2) ?
444 softing_irq_v2 : softing_irq_v1,
445 softing_irq_thread, IRQF_SHARED,
446 dev_name(&card->pdev->dev), card);
447 if (ret) {
448 dev_alert(&card->pdev->dev,
449 "request_threaded_irq(%u) failed\n",
450 card->irq.nr);
451 return ret;
452 }
453 card->irq.requested = 1;
454 }
455 return 0;
456}
457
458static void softing_card_shutdown(struct softing *card)
459{
460 int fw_up = 0;
461
462 if (mutex_lock_interruptible(&card->fw.lock))
463 /* return -ERESTARTSYS */;
464 fw_up = card->fw.up;
465 card->fw.up = 0;
466
467 if (card->irq.requested && card->irq.nr) {
468 free_irq(card->irq.nr, card);
469 card->irq.requested = 0;
470 }
471 if (fw_up) {
472 if (card->pdat->enable_irq)
473 card->pdat->enable_irq(card->pdev, 0);
474 softing_set_reset_dpram(card);
475 if (card->pdat->reset)
476 card->pdat->reset(card->pdev, 1);
477 }
478 mutex_unlock(&card->fw.lock);
479}
480
481static __devinit int softing_card_boot(struct softing *card)
482{
483 int ret, j;
484 static const uint8_t stream[] = {
485 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, };
486 unsigned char back[sizeof(stream)];
487
488 if (mutex_lock_interruptible(&card->fw.lock))
489 return -ERESTARTSYS;
490 if (card->fw.up) {
491 mutex_unlock(&card->fw.lock);
492 return 0;
493 }
494 /* reset board */
495 if (card->pdat->enable_irq)
496 card->pdat->enable_irq(card->pdev, 1);
497 /* boot card */
498 softing_set_reset_dpram(card);
499 if (card->pdat->reset)
500 card->pdat->reset(card->pdev, 1);
501 for (j = 0; (j + sizeof(stream)) < card->dpram_size;
502 j += sizeof(stream)) {
503
504 memcpy_toio(&card->dpram[j], stream, sizeof(stream));
505 /* flush IO cache */
506 mb();
507 memcpy_fromio(back, &card->dpram[j], sizeof(stream));
508
509 if (!memcmp(back, stream, sizeof(stream)))
510 continue;
511 /* memory is not equal */
512 dev_alert(&card->pdev->dev, "dpram failed at 0x%04x\n", j);
513 ret = -EIO;
514 goto failed;
515 }
516 wmb();
517 /* load boot firmware */
518 ret = softing_load_fw(card->pdat->boot.fw, card, card->dpram,
519 card->dpram_size,
520 card->pdat->boot.offs - card->pdat->boot.addr);
521 if (ret < 0)
522 goto failed;
523 /* load loader firmware */
524 ret = softing_load_fw(card->pdat->load.fw, card, card->dpram,
525 card->dpram_size,
526 card->pdat->load.offs - card->pdat->load.addr);
527 if (ret < 0)
528 goto failed;
529
530 if (card->pdat->reset)
531 card->pdat->reset(card->pdev, 0);
532 softing_clr_reset_dpram(card);
533 ret = softing_bootloader_command(card, 0, "card boot");
534 if (ret < 0)
535 goto failed;
536 ret = softing_load_app_fw(card->pdat->app.fw, card);
537 if (ret < 0)
538 goto failed;
539
540 ret = softing_chip_poweron(card);
541 if (ret < 0)
542 goto failed;
543
544 card->fw.up = 1;
545 mutex_unlock(&card->fw.lock);
546 return 0;
547failed:
548 card->fw.up = 0;
549 if (card->pdat->enable_irq)
550 card->pdat->enable_irq(card->pdev, 0);
551 softing_set_reset_dpram(card);
552 if (card->pdat->reset)
553 card->pdat->reset(card->pdev, 1);
554 mutex_unlock(&card->fw.lock);
555 return ret;
556}
557
558/*
559 * netdev sysfs
560 */
561static ssize_t show_channel(struct device *dev, struct device_attribute *attr,
562 char *buf)
563{
564 struct net_device *ndev = to_net_dev(dev);
565 struct softing_priv *priv = netdev2softing(ndev);
566
567 return sprintf(buf, "%i\n", priv->index);
568}
569
570static ssize_t show_chip(struct device *dev, struct device_attribute *attr,
571 char *buf)
572{
573 struct net_device *ndev = to_net_dev(dev);
574 struct softing_priv *priv = netdev2softing(ndev);
575
576 return sprintf(buf, "%i\n", priv->chip);
577}
578
579static ssize_t show_output(struct device *dev, struct device_attribute *attr,
580 char *buf)
581{
582 struct net_device *ndev = to_net_dev(dev);
583 struct softing_priv *priv = netdev2softing(ndev);
584
585 return sprintf(buf, "0x%02x\n", priv->output);
586}
587
588static ssize_t store_output(struct device *dev, struct device_attribute *attr,
589 const char *buf, size_t count)
590{
591 struct net_device *ndev = to_net_dev(dev);
592 struct softing_priv *priv = netdev2softing(ndev);
593 struct softing *card = priv->card;
594 unsigned long val;
595 int ret;
596
597 ret = strict_strtoul(buf, 0, &val);
598 if (ret < 0)
599 return ret;
600 val &= 0xFF;
601
602 ret = mutex_lock_interruptible(&card->fw.lock);
603 if (ret)
604 return -ERESTARTSYS;
605 if (netif_running(ndev)) {
606 mutex_unlock(&card->fw.lock);
607 return -EBUSY;
608 }
609 priv->output = val;
610 mutex_unlock(&card->fw.lock);
611 return count;
612}
613
614static const DEVICE_ATTR(channel, S_IRUGO, show_channel, NULL);
615static const DEVICE_ATTR(chip, S_IRUGO, show_chip, NULL);
616static const DEVICE_ATTR(output, S_IRUGO | S_IWUSR, show_output, store_output);
617
618static const struct attribute *const netdev_sysfs_attrs[] = {
619 &dev_attr_channel.attr,
620 &dev_attr_chip.attr,
621 &dev_attr_output.attr,
622 NULL,
623};
624static const struct attribute_group netdev_sysfs_group = {
625 .name = NULL,
626 .attrs = (struct attribute **)netdev_sysfs_attrs,
627};
628
629static const struct net_device_ops softing_netdev_ops = {
630 .ndo_open = softing_netdev_open,
631 .ndo_stop = softing_netdev_stop,
632 .ndo_start_xmit = softing_netdev_start_xmit,
633};
634
635static const struct can_bittiming_const softing_btr_const = {
636 .tseg1_min = 1,
637 .tseg1_max = 16,
638 .tseg2_min = 1,
639 .tseg2_max = 8,
640 .sjw_max = 4, /* overruled */
641 .brp_min = 1,
642 .brp_max = 32, /* overruled */
643 .brp_inc = 1,
644};
645
646
647static __devinit struct net_device *softing_netdev_create(struct softing *card,
648 uint16_t chip_id)
649{
650 struct net_device *netdev;
651 struct softing_priv *priv;
652
653 netdev = alloc_candev(sizeof(*priv), TX_ECHO_SKB_MAX);
654 if (!netdev) {
655 dev_alert(&card->pdev->dev, "alloc_candev failed\n");
656 return NULL;
657 }
658 priv = netdev_priv(netdev);
659 priv->netdev = netdev;
660 priv->card = card;
661 memcpy(&priv->btr_const, &softing_btr_const, sizeof(priv->btr_const));
662 priv->btr_const.brp_max = card->pdat->max_brp;
663 priv->btr_const.sjw_max = card->pdat->max_sjw;
664 priv->can.bittiming_const = &priv->btr_const;
665 priv->can.clock.freq = 8000000;
666 priv->chip = chip_id;
667 priv->output = softing_default_output(netdev);
668 SET_NETDEV_DEV(netdev, &card->pdev->dev);
669
670 netdev->flags |= IFF_ECHO;
671 netdev->netdev_ops = &softing_netdev_ops;
672 priv->can.do_set_mode = softing_candev_set_mode;
673 priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES;
674
675 return netdev;
676}
677
678static __devinit int softing_netdev_register(struct net_device *netdev)
679{
680 int ret;
681
682 netdev->sysfs_groups[0] = &netdev_sysfs_group;
683 ret = register_candev(netdev);
684 if (ret) {
685 dev_alert(&netdev->dev, "register failed\n");
686 return ret;
687 }
688 return 0;
689}
690
691static void softing_netdev_cleanup(struct net_device *netdev)
692{
693 unregister_candev(netdev);
694 free_candev(netdev);
695}
696
697/*
698 * sysfs for Platform device
699 */
700#define DEV_ATTR_RO(name, member) \
701static ssize_t show_##name(struct device *dev, \
702 struct device_attribute *attr, char *buf) \
703{ \
704 struct softing *card = platform_get_drvdata(to_platform_device(dev)); \
705 return sprintf(buf, "%u\n", card->member); \
706} \
707static DEVICE_ATTR(name, 0444, show_##name, NULL)
708
709#define DEV_ATTR_RO_STR(name, member) \
710static ssize_t show_##name(struct device *dev, \
711 struct device_attribute *attr, char *buf) \
712{ \
713 struct softing *card = platform_get_drvdata(to_platform_device(dev)); \
714 return sprintf(buf, "%s\n", card->member); \
715} \
716static DEVICE_ATTR(name, 0444, show_##name, NULL)
717
718DEV_ATTR_RO(serial, id.serial);
719DEV_ATTR_RO_STR(firmware, pdat->app.fw);
720DEV_ATTR_RO(firmware_version, id.fw_version);
721DEV_ATTR_RO_STR(hardware, pdat->name);
722DEV_ATTR_RO(hardware_version, id.hw_version);
723DEV_ATTR_RO(license, id.license);
724DEV_ATTR_RO(frequency, id.freq);
725DEV_ATTR_RO(txpending, tx.pending);
726
727static struct attribute *softing_pdev_attrs[] = {
728 &dev_attr_serial.attr,
729 &dev_attr_firmware.attr,
730 &dev_attr_firmware_version.attr,
731 &dev_attr_hardware.attr,
732 &dev_attr_hardware_version.attr,
733 &dev_attr_license.attr,
734 &dev_attr_frequency.attr,
735 &dev_attr_txpending.attr,
736 NULL,
737};
738
739static const struct attribute_group softing_pdev_group = {
740 .name = NULL,
741 .attrs = softing_pdev_attrs,
742};
743
744/*
745 * platform driver
746 */
747static __devexit int softing_pdev_remove(struct platform_device *pdev)
748{
749 struct softing *card = platform_get_drvdata(pdev);
750 int j;
751
752 /* first, disable card*/
753 softing_card_shutdown(card);
754
755 for (j = 0; j < ARRAY_SIZE(card->net); ++j) {
756 if (!card->net[j])
757 continue;
758 softing_netdev_cleanup(card->net[j]);
759 card->net[j] = NULL;
760 }
761 sysfs_remove_group(&pdev->dev.kobj, &softing_pdev_group);
762
763 iounmap(card->dpram);
764 kfree(card);
765 return 0;
766}
767
768static __devinit int softing_pdev_probe(struct platform_device *pdev)
769{
770 const struct softing_platform_data *pdat = pdev->dev.platform_data;
771 struct softing *card;
772 struct net_device *netdev;
773 struct softing_priv *priv;
774 struct resource *pres;
775 int ret;
776 int j;
777
778 if (!pdat) {
779 dev_warn(&pdev->dev, "no platform data\n");
780 return -EINVAL;
781 }
782 if (pdat->nbus > ARRAY_SIZE(card->net)) {
783 dev_warn(&pdev->dev, "%u nets??\n", pdat->nbus);
784 return -EINVAL;
785 }
786
787 card = kzalloc(sizeof(*card), GFP_KERNEL);
788 if (!card)
789 return -ENOMEM;
790 card->pdat = pdat;
791 card->pdev = pdev;
792 platform_set_drvdata(pdev, card);
793 mutex_init(&card->fw.lock);
794 spin_lock_init(&card->spin);
795
796 ret = -EINVAL;
797 pres = platform_get_resource(pdev, IORESOURCE_MEM, 0);
798 if (!pres)
799 goto platform_resource_failed;;
800 card->dpram_phys = pres->start;
801 card->dpram_size = pres->end - pres->start + 1;
802 card->dpram = ioremap_nocache(card->dpram_phys, card->dpram_size);
803 if (!card->dpram) {
804 dev_alert(&card->pdev->dev, "dpram ioremap failed\n");
805 goto ioremap_failed;
806 }
807
808 pres = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
809 if (pres)
810 card->irq.nr = pres->start;
811
812 /* reset card */
813 ret = softing_card_boot(card);
814 if (ret < 0) {
815 dev_alert(&pdev->dev, "failed to boot\n");
816 goto boot_failed;
817 }
818
819 /* only now, the chip's are known */
820 card->id.freq = card->pdat->freq;
821
822 ret = sysfs_create_group(&pdev->dev.kobj, &softing_pdev_group);
823 if (ret < 0) {
824 dev_alert(&card->pdev->dev, "sysfs failed\n");
825 goto sysfs_failed;
826 }
827
828 ret = -ENOMEM;
829 for (j = 0; j < ARRAY_SIZE(card->net); ++j) {
830 card->net[j] = netdev =
831 softing_netdev_create(card, card->id.chip[j]);
832 if (!netdev) {
833 dev_alert(&pdev->dev, "failed to make can[%i]", j);
834 goto netdev_failed;
835 }
836 priv = netdev_priv(card->net[j]);
837 priv->index = j;
838 ret = softing_netdev_register(netdev);
839 if (ret) {
840 free_candev(netdev);
841 card->net[j] = NULL;
842 dev_alert(&card->pdev->dev,
843 "failed to register can[%i]\n", j);
844 goto netdev_failed;
845 }
846 }
847 dev_info(&card->pdev->dev, "%s ready.\n", card->pdat->name);
848 return 0;
849
850netdev_failed:
851 for (j = 0; j < ARRAY_SIZE(card->net); ++j) {
852 if (!card->net[j])
853 continue;
854 softing_netdev_cleanup(card->net[j]);
855 }
856 sysfs_remove_group(&pdev->dev.kobj, &softing_pdev_group);
857sysfs_failed:
858 softing_card_shutdown(card);
859boot_failed:
860 iounmap(card->dpram);
861ioremap_failed:
862platform_resource_failed:
863 kfree(card);
864 return ret;
865}
866
867static struct platform_driver softing_driver = {
868 .driver = {
869 .name = "softing",
870 .owner = THIS_MODULE,
871 },
872 .probe = softing_pdev_probe,
873 .remove = __devexit_p(softing_pdev_remove),
874};
875
876MODULE_ALIAS("platform:softing");
877
878static int __init softing_start(void)
879{
880 return platform_driver_register(&softing_driver);
881}
882
883static void __exit softing_stop(void)
884{
885 platform_driver_unregister(&softing_driver);
886}
887
888module_init(softing_start);
889module_exit(softing_stop);
890
891MODULE_DESCRIPTION("Softing DPRAM CAN driver");
892MODULE_AUTHOR("Kurt Van Dijck <kurt.van.dijck@eia.be>");
893MODULE_LICENSE("GPL v2");
diff --git a/drivers/net/can/softing/softing_platform.h b/drivers/net/can/softing/softing_platform.h
new file mode 100644
index 000000000000..ebbf69815623
--- /dev/null
+++ b/drivers/net/can/softing/softing_platform.h
@@ -0,0 +1,40 @@
1
2#include <linux/platform_device.h>
3
4#ifndef _SOFTING_DEVICE_H_
5#define _SOFTING_DEVICE_H_
6
7/* softing firmware directory prefix */
8#define fw_dir "softing-4.6/"
9
10struct softing_platform_data {
11 unsigned int manf;
12 unsigned int prod;
13 /*
14 * generation
15 * 1st with NEC or SJA1000
16 * 8bit, exclusive interrupt, ...
17 * 2nd only SJA1000
18 * 16bit, shared interrupt
19 */
20 int generation;
21 int nbus; /* # busses on device */
22 unsigned int freq; /* operating frequency in Hz */
23 unsigned int max_brp;
24 unsigned int max_sjw;
25 unsigned long dpram_size;
26 const char *name;
27 struct {
28 unsigned long offs;
29 unsigned long addr;
30 const char *fw;
31 } boot, load, app;
32 /*
33 * reset() function
34 * bring pdev in or out of reset, depending on value
35 */
36 int (*reset)(struct platform_device *pdev, int value);
37 int (*enable_irq)(struct platform_device *pdev, int value);
38};
39
40#endif
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c
index 263a2944566f..7ff170cbc7dc 100644
--- a/drivers/net/cnic.c
+++ b/drivers/net/cnic.c
@@ -699,13 +699,13 @@ static void cnic_free_dma(struct cnic_dev *dev, struct cnic_dma *dma)
699static void cnic_setup_page_tbl(struct cnic_dev *dev, struct cnic_dma *dma) 699static void cnic_setup_page_tbl(struct cnic_dev *dev, struct cnic_dma *dma)
700{ 700{
701 int i; 701 int i;
702 u32 *page_table = dma->pgtbl; 702 __le32 *page_table = (__le32 *) dma->pgtbl;
703 703
704 for (i = 0; i < dma->num_pages; i++) { 704 for (i = 0; i < dma->num_pages; i++) {
705 /* Each entry needs to be in big endian format. */ 705 /* Each entry needs to be in big endian format. */
706 *page_table = (u32) ((u64) dma->pg_map_arr[i] >> 32); 706 *page_table = cpu_to_le32((u64) dma->pg_map_arr[i] >> 32);
707 page_table++; 707 page_table++;
708 *page_table = (u32) dma->pg_map_arr[i]; 708 *page_table = cpu_to_le32(dma->pg_map_arr[i] & 0xffffffff);
709 page_table++; 709 page_table++;
710 } 710 }
711} 711}
@@ -713,13 +713,13 @@ static void cnic_setup_page_tbl(struct cnic_dev *dev, struct cnic_dma *dma)
713static void cnic_setup_page_tbl_le(struct cnic_dev *dev, struct cnic_dma *dma) 713static void cnic_setup_page_tbl_le(struct cnic_dev *dev, struct cnic_dma *dma)
714{ 714{
715 int i; 715 int i;
716 u32 *page_table = dma->pgtbl; 716 __le32 *page_table = (__le32 *) dma->pgtbl;
717 717
718 for (i = 0; i < dma->num_pages; i++) { 718 for (i = 0; i < dma->num_pages; i++) {
719 /* Each entry needs to be in little endian format. */ 719 /* Each entry needs to be in little endian format. */
720 *page_table = dma->pg_map_arr[i] & 0xffffffff; 720 *page_table = cpu_to_le32(dma->pg_map_arr[i] & 0xffffffff);
721 page_table++; 721 page_table++;
722 *page_table = (u32) ((u64) dma->pg_map_arr[i] >> 32); 722 *page_table = cpu_to_le32((u64) dma->pg_map_arr[i] >> 32);
723 page_table++; 723 page_table++;
724 } 724 }
725} 725}
diff --git a/drivers/net/cxgb4/cxgb4_main.c b/drivers/net/cxgb4/cxgb4_main.c
index 059c1eec8c3f..ec35d458102c 100644
--- a/drivers/net/cxgb4/cxgb4_main.c
+++ b/drivers/net/cxgb4/cxgb4_main.c
@@ -2710,6 +2710,8 @@ static int cxgb_open(struct net_device *dev)
2710 struct port_info *pi = netdev_priv(dev); 2710 struct port_info *pi = netdev_priv(dev);
2711 struct adapter *adapter = pi->adapter; 2711 struct adapter *adapter = pi->adapter;
2712 2712
2713 netif_carrier_off(dev);
2714
2713 if (!(adapter->flags & FULL_INIT_DONE)) { 2715 if (!(adapter->flags & FULL_INIT_DONE)) {
2714 err = cxgb_up(adapter); 2716 err = cxgb_up(adapter);
2715 if (err < 0) 2717 if (err < 0)
@@ -3661,7 +3663,6 @@ static int __devinit init_one(struct pci_dev *pdev,
3661 pi->xact_addr_filt = -1; 3663 pi->xact_addr_filt = -1;
3662 pi->rx_offload = RX_CSO; 3664 pi->rx_offload = RX_CSO;
3663 pi->port_id = i; 3665 pi->port_id = i;
3664 netif_carrier_off(netdev);
3665 netdev->irq = pdev->irq; 3666 netdev->irq = pdev->irq;
3666 3667
3667 netdev->features |= NETIF_F_SG | TSO_FLAGS; 3668 netdev->features |= NETIF_F_SG | TSO_FLAGS;
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 119aa2000c24..5ed8f9f9419f 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -1920,7 +1920,7 @@ int startup_gfar(struct net_device *ndev)
1920 if (err) { 1920 if (err) {
1921 for (j = 0; j < i; j++) 1921 for (j = 0; j < i; j++)
1922 free_grp_irqs(&priv->gfargrp[j]); 1922 free_grp_irqs(&priv->gfargrp[j]);
1923 goto irq_fail; 1923 goto irq_fail;
1924 } 1924 }
1925 } 1925 }
1926 1926
diff --git a/drivers/net/irda/sh_irda.c b/drivers/net/irda/sh_irda.c
index 9e3f4f54281d..4488bd581eca 100644
--- a/drivers/net/irda/sh_irda.c
+++ b/drivers/net/irda/sh_irda.c
@@ -635,7 +635,7 @@ static int sh_irda_hard_xmit(struct sk_buff *skb, struct net_device *ndev)
635 635
636 ret = sh_irda_set_baudrate(self, speed); 636 ret = sh_irda_set_baudrate(self, speed);
637 if (ret < 0) 637 if (ret < 0)
638 return ret; 638 goto sh_irda_hard_xmit_end;
639 639
640 self->tx_buff.len = 0; 640 self->tx_buff.len = 0;
641 if (skb->len) { 641 if (skb->len) {
@@ -652,11 +652,21 @@ static int sh_irda_hard_xmit(struct sk_buff *skb, struct net_device *ndev)
652 652
653 sh_irda_write(self, IRTFLR, self->tx_buff.len); 653 sh_irda_write(self, IRTFLR, self->tx_buff.len);
654 sh_irda_write(self, IRTCTR, ARMOD | TE); 654 sh_irda_write(self, IRTCTR, ARMOD | TE);
655 } 655 } else
656 goto sh_irda_hard_xmit_end;
656 657
657 dev_kfree_skb(skb); 658 dev_kfree_skb(skb);
658 659
659 return 0; 660 return 0;
661
662sh_irda_hard_xmit_end:
663 sh_irda_set_baudrate(self, 9600);
664 netif_wake_queue(self->ndev);
665 sh_irda_rcv_ctrl(self, 1);
666 dev_kfree_skb(skb);
667
668 return ret;
669
660} 670}
661 671
662static int sh_irda_ioctl(struct net_device *ndev, struct ifreq *ifreq, int cmd) 672static int sh_irda_ioctl(struct net_device *ndev, struct ifreq *ifreq, int cmd)
diff --git a/drivers/net/ns83820.c b/drivers/net/ns83820.c
index 84134c766f3a..a41b2cf4d917 100644
--- a/drivers/net/ns83820.c
+++ b/drivers/net/ns83820.c
@@ -1988,12 +1988,11 @@ static int __devinit ns83820_init_one(struct pci_dev *pci_dev,
1988 } 1988 }
1989 1989
1990 ndev = alloc_etherdev(sizeof(struct ns83820)); 1990 ndev = alloc_etherdev(sizeof(struct ns83820));
1991 dev = PRIV(ndev);
1992
1993 err = -ENOMEM; 1991 err = -ENOMEM;
1994 if (!dev) 1992 if (!ndev)
1995 goto out; 1993 goto out;
1996 1994
1995 dev = PRIV(ndev);
1997 dev->ndev = ndev; 1996 dev->ndev = ndev;
1998 1997
1999 spin_lock_init(&dev->rx_info.lock); 1998 spin_lock_init(&dev->rx_info.lock);
diff --git a/drivers/net/pch_gbe/pch_gbe_main.c b/drivers/net/pch_gbe/pch_gbe_main.c
index d7355306a738..1bf12339441b 100644
--- a/drivers/net/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/pch_gbe/pch_gbe_main.c
@@ -2247,7 +2247,7 @@ static void pch_gbe_remove(struct pci_dev *pdev)
2247 struct net_device *netdev = pci_get_drvdata(pdev); 2247 struct net_device *netdev = pci_get_drvdata(pdev);
2248 struct pch_gbe_adapter *adapter = netdev_priv(netdev); 2248 struct pch_gbe_adapter *adapter = netdev_priv(netdev);
2249 2249
2250 flush_scheduled_work(); 2250 cancel_work_sync(&adapter->reset_task);
2251 unregister_netdev(netdev); 2251 unregister_netdev(netdev);
2252 2252
2253 pch_gbe_hal_phy_hw_reset(&adapter->hw); 2253 pch_gbe_hal_phy_hw_reset(&adapter->hw);
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 7841a8f69998..93b32d366611 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -60,12 +60,6 @@
60#define BAR_0 0 60#define BAR_0 0
61#define BAR_2 2 61#define BAR_2 2
62 62
63#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
64#define TG3_VLAN_TAG_USED 1
65#else
66#define TG3_VLAN_TAG_USED 0
67#endif
68
69#include "tg3.h" 63#include "tg3.h"
70 64
71#define DRV_MODULE_NAME "tg3" 65#define DRV_MODULE_NAME "tg3"
@@ -134,9 +128,6 @@
134 TG3_TX_RING_SIZE) 128 TG3_TX_RING_SIZE)
135#define NEXT_TX(N) (((N) + 1) & (TG3_TX_RING_SIZE - 1)) 129#define NEXT_TX(N) (((N) + 1) & (TG3_TX_RING_SIZE - 1))
136 130
137#define TG3_RX_DMA_ALIGN 16
138#define TG3_RX_HEADROOM ALIGN(VLAN_HLEN, TG3_RX_DMA_ALIGN)
139
140#define TG3_DMA_BYTE_ENAB 64 131#define TG3_DMA_BYTE_ENAB 64
141 132
142#define TG3_RX_STD_DMA_SZ 1536 133#define TG3_RX_STD_DMA_SZ 1536
@@ -4722,8 +4713,6 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget)
4722 struct sk_buff *skb; 4713 struct sk_buff *skb;
4723 dma_addr_t dma_addr; 4714 dma_addr_t dma_addr;
4724 u32 opaque_key, desc_idx, *post_ptr; 4715 u32 opaque_key, desc_idx, *post_ptr;
4725 bool hw_vlan __maybe_unused = false;
4726 u16 vtag __maybe_unused = 0;
4727 4716
4728 desc_idx = desc->opaque & RXD_OPAQUE_INDEX_MASK; 4717 desc_idx = desc->opaque & RXD_OPAQUE_INDEX_MASK;
4729 opaque_key = desc->opaque & RXD_OPAQUE_RING_MASK; 4718 opaque_key = desc->opaque & RXD_OPAQUE_RING_MASK;
@@ -4782,12 +4771,12 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget)
4782 tg3_recycle_rx(tnapi, tpr, opaque_key, 4771 tg3_recycle_rx(tnapi, tpr, opaque_key,
4783 desc_idx, *post_ptr); 4772 desc_idx, *post_ptr);
4784 4773
4785 copy_skb = netdev_alloc_skb(tp->dev, len + VLAN_HLEN + 4774 copy_skb = netdev_alloc_skb(tp->dev, len +
4786 TG3_RAW_IP_ALIGN); 4775 TG3_RAW_IP_ALIGN);
4787 if (copy_skb == NULL) 4776 if (copy_skb == NULL)
4788 goto drop_it_no_recycle; 4777 goto drop_it_no_recycle;
4789 4778
4790 skb_reserve(copy_skb, TG3_RAW_IP_ALIGN + VLAN_HLEN); 4779 skb_reserve(copy_skb, TG3_RAW_IP_ALIGN);
4791 skb_put(copy_skb, len); 4780 skb_put(copy_skb, len);
4792 pci_dma_sync_single_for_cpu(tp->pdev, dma_addr, len, PCI_DMA_FROMDEVICE); 4781 pci_dma_sync_single_for_cpu(tp->pdev, dma_addr, len, PCI_DMA_FROMDEVICE);
4793 skb_copy_from_linear_data(skb, copy_skb->data, len); 4782 skb_copy_from_linear_data(skb, copy_skb->data, len);
@@ -4814,30 +4803,11 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget)
4814 } 4803 }
4815 4804
4816 if (desc->type_flags & RXD_FLAG_VLAN && 4805 if (desc->type_flags & RXD_FLAG_VLAN &&
4817 !(tp->rx_mode & RX_MODE_KEEP_VLAN_TAG)) { 4806 !(tp->rx_mode & RX_MODE_KEEP_VLAN_TAG))
4818 vtag = desc->err_vlan & RXD_VLAN_MASK; 4807 __vlan_hwaccel_put_tag(skb,
4819#if TG3_VLAN_TAG_USED 4808 desc->err_vlan & RXD_VLAN_MASK);
4820 if (tp->vlgrp)
4821 hw_vlan = true;
4822 else
4823#endif
4824 {
4825 struct vlan_ethhdr *ve = (struct vlan_ethhdr *)
4826 __skb_push(skb, VLAN_HLEN);
4827
4828 memmove(ve, skb->data + VLAN_HLEN,
4829 ETH_ALEN * 2);
4830 ve->h_vlan_proto = htons(ETH_P_8021Q);
4831 ve->h_vlan_TCI = htons(vtag);
4832 }
4833 }
4834 4809
4835#if TG3_VLAN_TAG_USED 4810 napi_gro_receive(&tnapi->napi, skb);
4836 if (hw_vlan)
4837 vlan_gro_receive(&tnapi->napi, tp->vlgrp, vtag, skb);
4838 else
4839#endif
4840 napi_gro_receive(&tnapi->napi, skb);
4841 4811
4842 received++; 4812 received++;
4843 budget--; 4813 budget--;
@@ -5740,11 +5710,9 @@ static netdev_tx_t tg3_start_xmit(struct sk_buff *skb,
5740 base_flags |= TXD_FLAG_TCPUDP_CSUM; 5710 base_flags |= TXD_FLAG_TCPUDP_CSUM;
5741 } 5711 }
5742 5712
5743#if TG3_VLAN_TAG_USED
5744 if (vlan_tx_tag_present(skb)) 5713 if (vlan_tx_tag_present(skb))
5745 base_flags |= (TXD_FLAG_VLAN | 5714 base_flags |= (TXD_FLAG_VLAN |
5746 (vlan_tx_tag_get(skb) << 16)); 5715 (vlan_tx_tag_get(skb) << 16));
5747#endif
5748 5716
5749 len = skb_headlen(skb); 5717 len = skb_headlen(skb);
5750 5718
@@ -5986,11 +5954,10 @@ static netdev_tx_t tg3_start_xmit_dma_bug(struct sk_buff *skb,
5986 } 5954 }
5987 } 5955 }
5988 } 5956 }
5989#if TG3_VLAN_TAG_USED 5957
5990 if (vlan_tx_tag_present(skb)) 5958 if (vlan_tx_tag_present(skb))
5991 base_flags |= (TXD_FLAG_VLAN | 5959 base_flags |= (TXD_FLAG_VLAN |
5992 (vlan_tx_tag_get(skb) << 16)); 5960 (vlan_tx_tag_get(skb) << 16));
5993#endif
5994 5961
5995 if ((tp->tg3_flags3 & TG3_FLG3_USE_JUMBO_BDFLAG) && 5962 if ((tp->tg3_flags3 & TG3_FLG3_USE_JUMBO_BDFLAG) &&
5996 !mss && skb->len > VLAN_ETH_FRAME_LEN) 5963 !mss && skb->len > VLAN_ETH_FRAME_LEN)
@@ -9532,17 +9499,10 @@ static void __tg3_set_rx_mode(struct net_device *dev)
9532 rx_mode = tp->rx_mode & ~(RX_MODE_PROMISC | 9499 rx_mode = tp->rx_mode & ~(RX_MODE_PROMISC |
9533 RX_MODE_KEEP_VLAN_TAG); 9500 RX_MODE_KEEP_VLAN_TAG);
9534 9501
9502#if !defined(CONFIG_VLAN_8021Q) && !defined(CONFIG_VLAN_8021Q_MODULE)
9535 /* When ASF is in use, we always keep the RX_MODE_KEEP_VLAN_TAG 9503 /* When ASF is in use, we always keep the RX_MODE_KEEP_VLAN_TAG
9536 * flag clear. 9504 * flag clear.
9537 */ 9505 */
9538#if TG3_VLAN_TAG_USED
9539 if (!tp->vlgrp &&
9540 !(tp->tg3_flags & TG3_FLAG_ENABLE_ASF))
9541 rx_mode |= RX_MODE_KEEP_VLAN_TAG;
9542#else
9543 /* By definition, VLAN is disabled always in this
9544 * case.
9545 */
9546 if (!(tp->tg3_flags & TG3_FLAG_ENABLE_ASF)) 9506 if (!(tp->tg3_flags & TG3_FLAG_ENABLE_ASF))
9547 rx_mode |= RX_MODE_KEEP_VLAN_TAG; 9507 rx_mode |= RX_MODE_KEEP_VLAN_TAG;
9548#endif 9508#endif
@@ -11230,31 +11190,6 @@ static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
11230 return -EOPNOTSUPP; 11190 return -EOPNOTSUPP;
11231} 11191}
11232 11192
11233#if TG3_VLAN_TAG_USED
11234static void tg3_vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
11235{
11236 struct tg3 *tp = netdev_priv(dev);
11237
11238 if (!netif_running(dev)) {
11239 tp->vlgrp = grp;
11240 return;
11241 }
11242
11243 tg3_netif_stop(tp);
11244
11245 tg3_full_lock(tp, 0);
11246
11247 tp->vlgrp = grp;
11248
11249 /* Update RX_MODE_KEEP_VLAN_TAG bit in RX_MODE register. */
11250 __tg3_set_rx_mode(dev);
11251
11252 tg3_netif_start(tp);
11253
11254 tg3_full_unlock(tp);
11255}
11256#endif
11257
11258static int tg3_get_coalesce(struct net_device *dev, struct ethtool_coalesce *ec) 11193static int tg3_get_coalesce(struct net_device *dev, struct ethtool_coalesce *ec)
11259{ 11194{
11260 struct tg3 *tp = netdev_priv(dev); 11195 struct tg3 *tp = netdev_priv(dev);
@@ -13066,9 +13001,7 @@ static struct pci_dev * __devinit tg3_find_peer(struct tg3 *);
13066 13001
13067static void inline vlan_features_add(struct net_device *dev, unsigned long flags) 13002static void inline vlan_features_add(struct net_device *dev, unsigned long flags)
13068{ 13003{
13069#if TG3_VLAN_TAG_USED
13070 dev->vlan_features |= flags; 13004 dev->vlan_features |= flags;
13071#endif
13072} 13005}
13073 13006
13074static inline u32 tg3_rx_ret_ring_size(struct tg3 *tp) 13007static inline u32 tg3_rx_ret_ring_size(struct tg3 *tp)
@@ -13861,11 +13794,11 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
13861 else 13794 else
13862 tp->tg3_flags &= ~TG3_FLAG_POLL_SERDES; 13795 tp->tg3_flags &= ~TG3_FLAG_POLL_SERDES;
13863 13796
13864 tp->rx_offset = NET_IP_ALIGN + TG3_RX_HEADROOM; 13797 tp->rx_offset = NET_IP_ALIGN;
13865 tp->rx_copy_thresh = TG3_RX_COPY_THRESHOLD; 13798 tp->rx_copy_thresh = TG3_RX_COPY_THRESHOLD;
13866 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701 && 13799 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701 &&
13867 (tp->tg3_flags & TG3_FLAG_PCIX_MODE) != 0) { 13800 (tp->tg3_flags & TG3_FLAG_PCIX_MODE) != 0) {
13868 tp->rx_offset -= NET_IP_ALIGN; 13801 tp->rx_offset = 0;
13869#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS 13802#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
13870 tp->rx_copy_thresh = ~(u16)0; 13803 tp->rx_copy_thresh = ~(u16)0;
13871#endif 13804#endif
@@ -14629,9 +14562,6 @@ static const struct net_device_ops tg3_netdev_ops = {
14629 .ndo_do_ioctl = tg3_ioctl, 14562 .ndo_do_ioctl = tg3_ioctl,
14630 .ndo_tx_timeout = tg3_tx_timeout, 14563 .ndo_tx_timeout = tg3_tx_timeout,
14631 .ndo_change_mtu = tg3_change_mtu, 14564 .ndo_change_mtu = tg3_change_mtu,
14632#if TG3_VLAN_TAG_USED
14633 .ndo_vlan_rx_register = tg3_vlan_rx_register,
14634#endif
14635#ifdef CONFIG_NET_POLL_CONTROLLER 14565#ifdef CONFIG_NET_POLL_CONTROLLER
14636 .ndo_poll_controller = tg3_poll_controller, 14566 .ndo_poll_controller = tg3_poll_controller,
14637#endif 14567#endif
@@ -14648,9 +14578,6 @@ static const struct net_device_ops tg3_netdev_ops_dma_bug = {
14648 .ndo_do_ioctl = tg3_ioctl, 14578 .ndo_do_ioctl = tg3_ioctl,
14649 .ndo_tx_timeout = tg3_tx_timeout, 14579 .ndo_tx_timeout = tg3_tx_timeout,
14650 .ndo_change_mtu = tg3_change_mtu, 14580 .ndo_change_mtu = tg3_change_mtu,
14651#if TG3_VLAN_TAG_USED
14652 .ndo_vlan_rx_register = tg3_vlan_rx_register,
14653#endif
14654#ifdef CONFIG_NET_POLL_CONTROLLER 14581#ifdef CONFIG_NET_POLL_CONTROLLER
14655 .ndo_poll_controller = tg3_poll_controller, 14582 .ndo_poll_controller = tg3_poll_controller,
14656#endif 14583#endif
@@ -14700,9 +14627,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
14700 14627
14701 SET_NETDEV_DEV(dev, &pdev->dev); 14628 SET_NETDEV_DEV(dev, &pdev->dev);
14702 14629
14703#if TG3_VLAN_TAG_USED
14704 dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; 14630 dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
14705#endif
14706 14631
14707 tp = netdev_priv(dev); 14632 tp = netdev_priv(dev);
14708 tp->pdev = pdev; 14633 tp->pdev = pdev;
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index d62c8d937c82..f528243e1a4f 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -2808,9 +2808,6 @@ struct tg3 {
2808 u32 rx_std_max_post; 2808 u32 rx_std_max_post;
2809 u32 rx_offset; 2809 u32 rx_offset;
2810 u32 rx_pkt_map_sz; 2810 u32 rx_pkt_map_sz;
2811#if TG3_VLAN_TAG_USED
2812 struct vlan_group *vlgrp;
2813#endif
2814 2811
2815 2812
2816 /* begin "everything else" cacheline(s) section */ 2813 /* begin "everything else" cacheline(s) section */
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index d776c4a8d3c1..04e8ce14a1d0 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -54,7 +54,7 @@
54#include <linux/usb/usbnet.h> 54#include <linux/usb/usbnet.h>
55#include <linux/usb/cdc.h> 55#include <linux/usb/cdc.h>
56 56
57#define DRIVER_VERSION "30-Nov-2010" 57#define DRIVER_VERSION "17-Jan-2011"
58 58
59/* CDC NCM subclass 3.2.1 */ 59/* CDC NCM subclass 3.2.1 */
60#define USB_CDC_NCM_NDP16_LENGTH_MIN 0x10 60#define USB_CDC_NCM_NDP16_LENGTH_MIN 0x10
@@ -868,15 +868,19 @@ static void cdc_ncm_tx_timeout(unsigned long arg)
868 if (ctx->tx_timer_pending != 0) { 868 if (ctx->tx_timer_pending != 0) {
869 ctx->tx_timer_pending--; 869 ctx->tx_timer_pending--;
870 restart = 1; 870 restart = 1;
871 } else 871 } else {
872 restart = 0; 872 restart = 0;
873 }
873 874
874 spin_unlock(&ctx->mtx); 875 spin_unlock(&ctx->mtx);
875 876
876 if (restart) 877 if (restart) {
878 spin_lock(&ctx->mtx);
877 cdc_ncm_tx_timeout_start(ctx); 879 cdc_ncm_tx_timeout_start(ctx);
878 else if (ctx->netdev != NULL) 880 spin_unlock(&ctx->mtx);
881 } else if (ctx->netdev != NULL) {
879 usbnet_start_xmit(NULL, ctx->netdev); 882 usbnet_start_xmit(NULL, ctx->netdev);
883 }
880} 884}
881 885
882static struct sk_buff * 886static struct sk_buff *
@@ -900,7 +904,6 @@ cdc_ncm_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
900 skb_out = cdc_ncm_fill_tx_frame(ctx, skb); 904 skb_out = cdc_ncm_fill_tx_frame(ctx, skb);
901 if (ctx->tx_curr_skb != NULL) 905 if (ctx->tx_curr_skb != NULL)
902 need_timer = 1; 906 need_timer = 1;
903 spin_unlock(&ctx->mtx);
904 907
905 /* Start timer, if there is a remaining skb */ 908 /* Start timer, if there is a remaining skb */
906 if (need_timer) 909 if (need_timer)
@@ -908,6 +911,8 @@ cdc_ncm_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
908 911
909 if (skb_out) 912 if (skb_out)
910 dev->net->stats.tx_packets += ctx->tx_curr_frame_num; 913 dev->net->stats.tx_packets += ctx->tx_curr_frame_num;
914
915 spin_unlock(&ctx->mtx);
911 return skb_out; 916 return skb_out;
912 917
913error: 918error:
@@ -1020,8 +1025,8 @@ static int cdc_ncm_rx_fixup(struct usbnet *dev, struct sk_buff *skb_in)
1020 if (((offset + temp) > actlen) || 1025 if (((offset + temp) > actlen) ||
1021 (temp > CDC_NCM_MAX_DATAGRAM_SIZE) || (temp < ETH_HLEN)) { 1026 (temp > CDC_NCM_MAX_DATAGRAM_SIZE) || (temp < ETH_HLEN)) {
1022 pr_debug("invalid frame detected (ignored)" 1027 pr_debug("invalid frame detected (ignored)"
1023 "offset[%u]=%u, length=%u, skb=%p\n", 1028 "offset[%u]=%u, length=%u, skb=%p\n",
1024 x, offset, temp, skb_in); 1029 x, offset, temp, skb_in);
1025 if (!x) 1030 if (!x)
1026 goto error; 1031 goto error;
1027 break; 1032 break;
diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c
index 5e98643a4a21..7dc84971f26f 100644
--- a/drivers/net/usb/kaweth.c
+++ b/drivers/net/usb/kaweth.c
@@ -406,6 +406,7 @@ static int kaweth_download_firmware(struct kaweth_device *kaweth,
406 406
407 if (fw->size > KAWETH_FIRMWARE_BUF_SIZE) { 407 if (fw->size > KAWETH_FIRMWARE_BUF_SIZE) {
408 err("Firmware too big: %zu", fw->size); 408 err("Firmware too big: %zu", fw->size);
409 release_firmware(fw);
409 return -ENOSPC; 410 return -ENOSPC;
410 } 411 }
411 data_len = fw->size; 412 data_len = fw->size;
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
index d143e8b72b5b..cc14b4a75048 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -48,6 +48,9 @@ static atomic_t devices_found;
48static int enable_mq = 1; 48static int enable_mq = 1;
49static int irq_share_mode; 49static int irq_share_mode;
50 50
51static void
52vmxnet3_write_mac_addr(struct vmxnet3_adapter *adapter, u8 *mac);
53
51/* 54/*
52 * Enable/Disable the given intr 55 * Enable/Disable the given intr
53 */ 56 */
@@ -139,9 +142,13 @@ vmxnet3_check_link(struct vmxnet3_adapter *adapter, bool affectTxQueue)
139{ 142{
140 u32 ret; 143 u32 ret;
141 int i; 144 int i;
145 unsigned long flags;
142 146
147 spin_lock_irqsave(&adapter->cmd_lock, flags);
143 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_GET_LINK); 148 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_GET_LINK);
144 ret = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD); 149 ret = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD);
150 spin_unlock_irqrestore(&adapter->cmd_lock, flags);
151
145 adapter->link_speed = ret >> 16; 152 adapter->link_speed = ret >> 16;
146 if (ret & 1) { /* Link is up. */ 153 if (ret & 1) { /* Link is up. */
147 printk(KERN_INFO "%s: NIC Link is Up %d Mbps\n", 154 printk(KERN_INFO "%s: NIC Link is Up %d Mbps\n",
@@ -183,8 +190,10 @@ vmxnet3_process_events(struct vmxnet3_adapter *adapter)
183 190
184 /* Check if there is an error on xmit/recv queues */ 191 /* Check if there is an error on xmit/recv queues */
185 if (events & (VMXNET3_ECR_TQERR | VMXNET3_ECR_RQERR)) { 192 if (events & (VMXNET3_ECR_TQERR | VMXNET3_ECR_RQERR)) {
193 spin_lock(&adapter->cmd_lock);
186 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, 194 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
187 VMXNET3_CMD_GET_QUEUE_STATUS); 195 VMXNET3_CMD_GET_QUEUE_STATUS);
196 spin_unlock(&adapter->cmd_lock);
188 197
189 for (i = 0; i < adapter->num_tx_queues; i++) 198 for (i = 0; i < adapter->num_tx_queues; i++)
190 if (adapter->tqd_start[i].status.stopped) 199 if (adapter->tqd_start[i].status.stopped)
@@ -804,30 +813,25 @@ vmxnet3_parse_and_copy_hdr(struct sk_buff *skb, struct vmxnet3_tx_queue *tq,
804 skb_transport_header(skb))->doff * 4; 813 skb_transport_header(skb))->doff * 4;
805 ctx->copy_size = ctx->eth_ip_hdr_size + ctx->l4_hdr_size; 814 ctx->copy_size = ctx->eth_ip_hdr_size + ctx->l4_hdr_size;
806 } else { 815 } else {
807 unsigned int pull_size;
808
809 if (skb->ip_summed == CHECKSUM_PARTIAL) { 816 if (skb->ip_summed == CHECKSUM_PARTIAL) {
810 ctx->eth_ip_hdr_size = skb_checksum_start_offset(skb); 817 ctx->eth_ip_hdr_size = skb_checksum_start_offset(skb);
811 818
812 if (ctx->ipv4) { 819 if (ctx->ipv4) {
813 struct iphdr *iph = (struct iphdr *) 820 struct iphdr *iph = (struct iphdr *)
814 skb_network_header(skb); 821 skb_network_header(skb);
815 if (iph->protocol == IPPROTO_TCP) { 822 if (iph->protocol == IPPROTO_TCP)
816 pull_size = ctx->eth_ip_hdr_size +
817 sizeof(struct tcphdr);
818
819 if (unlikely(!pskb_may_pull(skb,
820 pull_size))) {
821 goto err;
822 }
823 ctx->l4_hdr_size = ((struct tcphdr *) 823 ctx->l4_hdr_size = ((struct tcphdr *)
824 skb_transport_header(skb))->doff * 4; 824 skb_transport_header(skb))->doff * 4;
825 } else if (iph->protocol == IPPROTO_UDP) { 825 else if (iph->protocol == IPPROTO_UDP)
826 /*
827 * Use tcp header size so that bytes to
828 * be copied are more than required by
829 * the device.
830 */
826 ctx->l4_hdr_size = 831 ctx->l4_hdr_size =
827 sizeof(struct udphdr); 832 sizeof(struct tcphdr);
828 } else { 833 else
829 ctx->l4_hdr_size = 0; 834 ctx->l4_hdr_size = 0;
830 }
831 } else { 835 } else {
832 /* for simplicity, don't copy L4 headers */ 836 /* for simplicity, don't copy L4 headers */
833 ctx->l4_hdr_size = 0; 837 ctx->l4_hdr_size = 0;
@@ -1859,18 +1863,14 @@ vmxnet3_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
1859 struct vmxnet3_adapter *adapter = netdev_priv(netdev); 1863 struct vmxnet3_adapter *adapter = netdev_priv(netdev);
1860 struct Vmxnet3_DriverShared *shared = adapter->shared; 1864 struct Vmxnet3_DriverShared *shared = adapter->shared;
1861 u32 *vfTable = adapter->shared->devRead.rxFilterConf.vfTable; 1865 u32 *vfTable = adapter->shared->devRead.rxFilterConf.vfTable;
1866 unsigned long flags;
1862 1867
1863 if (grp) { 1868 if (grp) {
1864 /* add vlan rx stripping. */ 1869 /* add vlan rx stripping. */
1865 if (adapter->netdev->features & NETIF_F_HW_VLAN_RX) { 1870 if (adapter->netdev->features & NETIF_F_HW_VLAN_RX) {
1866 int i; 1871 int i;
1867 struct Vmxnet3_DSDevRead *devRead = &shared->devRead;
1868 adapter->vlan_grp = grp; 1872 adapter->vlan_grp = grp;
1869 1873
1870 /* update FEATURES to device */
1871 devRead->misc.uptFeatures |= UPT1_F_RXVLAN;
1872 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
1873 VMXNET3_CMD_UPDATE_FEATURE);
1874 /* 1874 /*
1875 * Clear entire vfTable; then enable untagged pkts. 1875 * Clear entire vfTable; then enable untagged pkts.
1876 * Note: setting one entry in vfTable to non-zero turns 1876 * Note: setting one entry in vfTable to non-zero turns
@@ -1880,8 +1880,10 @@ vmxnet3_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
1880 vfTable[i] = 0; 1880 vfTable[i] = 0;
1881 1881
1882 VMXNET3_SET_VFTABLE_ENTRY(vfTable, 0); 1882 VMXNET3_SET_VFTABLE_ENTRY(vfTable, 0);
1883 spin_lock_irqsave(&adapter->cmd_lock, flags);
1883 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, 1884 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
1884 VMXNET3_CMD_UPDATE_VLAN_FILTERS); 1885 VMXNET3_CMD_UPDATE_VLAN_FILTERS);
1886 spin_unlock_irqrestore(&adapter->cmd_lock, flags);
1885 } else { 1887 } else {
1886 printk(KERN_ERR "%s: vlan_rx_register when device has " 1888 printk(KERN_ERR "%s: vlan_rx_register when device has "
1887 "no NETIF_F_HW_VLAN_RX\n", netdev->name); 1889 "no NETIF_F_HW_VLAN_RX\n", netdev->name);
@@ -1900,13 +1902,10 @@ vmxnet3_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
1900 */ 1902 */
1901 vfTable[i] = 0; 1903 vfTable[i] = 0;
1902 } 1904 }
1905 spin_lock_irqsave(&adapter->cmd_lock, flags);
1903 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, 1906 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
1904 VMXNET3_CMD_UPDATE_VLAN_FILTERS); 1907 VMXNET3_CMD_UPDATE_VLAN_FILTERS);
1905 1908 spin_unlock_irqrestore(&adapter->cmd_lock, flags);
1906 /* update FEATURES to device */
1907 devRead->misc.uptFeatures &= ~UPT1_F_RXVLAN;
1908 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
1909 VMXNET3_CMD_UPDATE_FEATURE);
1910 } 1909 }
1911 } 1910 }
1912} 1911}
@@ -1939,10 +1938,13 @@ vmxnet3_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
1939{ 1938{
1940 struct vmxnet3_adapter *adapter = netdev_priv(netdev); 1939 struct vmxnet3_adapter *adapter = netdev_priv(netdev);
1941 u32 *vfTable = adapter->shared->devRead.rxFilterConf.vfTable; 1940 u32 *vfTable = adapter->shared->devRead.rxFilterConf.vfTable;
1941 unsigned long flags;
1942 1942
1943 VMXNET3_SET_VFTABLE_ENTRY(vfTable, vid); 1943 VMXNET3_SET_VFTABLE_ENTRY(vfTable, vid);
1944 spin_lock_irqsave(&adapter->cmd_lock, flags);
1944 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, 1945 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
1945 VMXNET3_CMD_UPDATE_VLAN_FILTERS); 1946 VMXNET3_CMD_UPDATE_VLAN_FILTERS);
1947 spin_unlock_irqrestore(&adapter->cmd_lock, flags);
1946} 1948}
1947 1949
1948 1950
@@ -1951,10 +1953,13 @@ vmxnet3_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
1951{ 1953{
1952 struct vmxnet3_adapter *adapter = netdev_priv(netdev); 1954 struct vmxnet3_adapter *adapter = netdev_priv(netdev);
1953 u32 *vfTable = adapter->shared->devRead.rxFilterConf.vfTable; 1955 u32 *vfTable = adapter->shared->devRead.rxFilterConf.vfTable;
1956 unsigned long flags;
1954 1957
1955 VMXNET3_CLEAR_VFTABLE_ENTRY(vfTable, vid); 1958 VMXNET3_CLEAR_VFTABLE_ENTRY(vfTable, vid);
1959 spin_lock_irqsave(&adapter->cmd_lock, flags);
1956 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, 1960 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
1957 VMXNET3_CMD_UPDATE_VLAN_FILTERS); 1961 VMXNET3_CMD_UPDATE_VLAN_FILTERS);
1962 spin_unlock_irqrestore(&adapter->cmd_lock, flags);
1958} 1963}
1959 1964
1960 1965
@@ -1985,6 +1990,7 @@ static void
1985vmxnet3_set_mc(struct net_device *netdev) 1990vmxnet3_set_mc(struct net_device *netdev)
1986{ 1991{
1987 struct vmxnet3_adapter *adapter = netdev_priv(netdev); 1992 struct vmxnet3_adapter *adapter = netdev_priv(netdev);
1993 unsigned long flags;
1988 struct Vmxnet3_RxFilterConf *rxConf = 1994 struct Vmxnet3_RxFilterConf *rxConf =
1989 &adapter->shared->devRead.rxFilterConf; 1995 &adapter->shared->devRead.rxFilterConf;
1990 u8 *new_table = NULL; 1996 u8 *new_table = NULL;
@@ -2020,6 +2026,7 @@ vmxnet3_set_mc(struct net_device *netdev)
2020 rxConf->mfTablePA = 0; 2026 rxConf->mfTablePA = 0;
2021 } 2027 }
2022 2028
2029 spin_lock_irqsave(&adapter->cmd_lock, flags);
2023 if (new_mode != rxConf->rxMode) { 2030 if (new_mode != rxConf->rxMode) {
2024 rxConf->rxMode = cpu_to_le32(new_mode); 2031 rxConf->rxMode = cpu_to_le32(new_mode);
2025 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, 2032 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
@@ -2028,6 +2035,7 @@ vmxnet3_set_mc(struct net_device *netdev)
2028 2035
2029 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, 2036 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
2030 VMXNET3_CMD_UPDATE_MAC_FILTERS); 2037 VMXNET3_CMD_UPDATE_MAC_FILTERS);
2038 spin_unlock_irqrestore(&adapter->cmd_lock, flags);
2031 2039
2032 kfree(new_table); 2040 kfree(new_table);
2033} 2041}
@@ -2080,10 +2088,8 @@ vmxnet3_setup_driver_shared(struct vmxnet3_adapter *adapter)
2080 devRead->misc.uptFeatures |= UPT1_F_LRO; 2088 devRead->misc.uptFeatures |= UPT1_F_LRO;
2081 devRead->misc.maxNumRxSG = cpu_to_le16(1 + MAX_SKB_FRAGS); 2089 devRead->misc.maxNumRxSG = cpu_to_le16(1 + MAX_SKB_FRAGS);
2082 } 2090 }
2083 if ((adapter->netdev->features & NETIF_F_HW_VLAN_RX) && 2091 if (adapter->netdev->features & NETIF_F_HW_VLAN_RX)
2084 adapter->vlan_grp) {
2085 devRead->misc.uptFeatures |= UPT1_F_RXVLAN; 2092 devRead->misc.uptFeatures |= UPT1_F_RXVLAN;
2086 }
2087 2093
2088 devRead->misc.mtu = cpu_to_le32(adapter->netdev->mtu); 2094 devRead->misc.mtu = cpu_to_le32(adapter->netdev->mtu);
2089 devRead->misc.queueDescPA = cpu_to_le64(adapter->queue_desc_pa); 2095 devRead->misc.queueDescPA = cpu_to_le64(adapter->queue_desc_pa);
@@ -2168,6 +2174,8 @@ vmxnet3_setup_driver_shared(struct vmxnet3_adapter *adapter)
2168 /* rx filter settings */ 2174 /* rx filter settings */
2169 devRead->rxFilterConf.rxMode = 0; 2175 devRead->rxFilterConf.rxMode = 0;
2170 vmxnet3_restore_vlan(adapter); 2176 vmxnet3_restore_vlan(adapter);
2177 vmxnet3_write_mac_addr(adapter, adapter->netdev->dev_addr);
2178
2171 /* the rest are already zeroed */ 2179 /* the rest are already zeroed */
2172} 2180}
2173 2181
@@ -2177,6 +2185,7 @@ vmxnet3_activate_dev(struct vmxnet3_adapter *adapter)
2177{ 2185{
2178 int err, i; 2186 int err, i;
2179 u32 ret; 2187 u32 ret;
2188 unsigned long flags;
2180 2189
2181 dev_dbg(&adapter->netdev->dev, "%s: skb_buf_size %d, rx_buf_per_pkt %d," 2190 dev_dbg(&adapter->netdev->dev, "%s: skb_buf_size %d, rx_buf_per_pkt %d,"
2182 " ring sizes %u %u %u\n", adapter->netdev->name, 2191 " ring sizes %u %u %u\n", adapter->netdev->name,
@@ -2206,9 +2215,11 @@ vmxnet3_activate_dev(struct vmxnet3_adapter *adapter)
2206 adapter->shared_pa)); 2215 adapter->shared_pa));
2207 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_DSAH, VMXNET3_GET_ADDR_HI( 2216 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_DSAH, VMXNET3_GET_ADDR_HI(
2208 adapter->shared_pa)); 2217 adapter->shared_pa));
2218 spin_lock_irqsave(&adapter->cmd_lock, flags);
2209 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, 2219 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
2210 VMXNET3_CMD_ACTIVATE_DEV); 2220 VMXNET3_CMD_ACTIVATE_DEV);
2211 ret = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD); 2221 ret = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD);
2222 spin_unlock_irqrestore(&adapter->cmd_lock, flags);
2212 2223
2213 if (ret != 0) { 2224 if (ret != 0) {
2214 printk(KERN_ERR "Failed to activate dev %s: error %u\n", 2225 printk(KERN_ERR "Failed to activate dev %s: error %u\n",
@@ -2255,7 +2266,10 @@ rq_err:
2255void 2266void
2256vmxnet3_reset_dev(struct vmxnet3_adapter *adapter) 2267vmxnet3_reset_dev(struct vmxnet3_adapter *adapter)
2257{ 2268{
2269 unsigned long flags;
2270 spin_lock_irqsave(&adapter->cmd_lock, flags);
2258 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_RESET_DEV); 2271 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_RESET_DEV);
2272 spin_unlock_irqrestore(&adapter->cmd_lock, flags);
2259} 2273}
2260 2274
2261 2275
@@ -2263,12 +2277,15 @@ int
2263vmxnet3_quiesce_dev(struct vmxnet3_adapter *adapter) 2277vmxnet3_quiesce_dev(struct vmxnet3_adapter *adapter)
2264{ 2278{
2265 int i; 2279 int i;
2280 unsigned long flags;
2266 if (test_and_set_bit(VMXNET3_STATE_BIT_QUIESCED, &adapter->state)) 2281 if (test_and_set_bit(VMXNET3_STATE_BIT_QUIESCED, &adapter->state))
2267 return 0; 2282 return 0;
2268 2283
2269 2284
2285 spin_lock_irqsave(&adapter->cmd_lock, flags);
2270 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, 2286 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
2271 VMXNET3_CMD_QUIESCE_DEV); 2287 VMXNET3_CMD_QUIESCE_DEV);
2288 spin_unlock_irqrestore(&adapter->cmd_lock, flags);
2272 vmxnet3_disable_all_intrs(adapter); 2289 vmxnet3_disable_all_intrs(adapter);
2273 2290
2274 for (i = 0; i < adapter->num_rx_queues; i++) 2291 for (i = 0; i < adapter->num_rx_queues; i++)
@@ -2426,7 +2443,7 @@ vmxnet3_adjust_rx_ring_size(struct vmxnet3_adapter *adapter)
2426 sz = adapter->rx_buf_per_pkt * VMXNET3_RING_SIZE_ALIGN; 2443 sz = adapter->rx_buf_per_pkt * VMXNET3_RING_SIZE_ALIGN;
2427 ring0_size = adapter->rx_queue[0].rx_ring[0].size; 2444 ring0_size = adapter->rx_queue[0].rx_ring[0].size;
2428 ring0_size = (ring0_size + sz - 1) / sz * sz; 2445 ring0_size = (ring0_size + sz - 1) / sz * sz;
2429 ring0_size = min_t(u32, rq->rx_ring[0].size, VMXNET3_RX_RING_MAX_SIZE / 2446 ring0_size = min_t(u32, ring0_size, VMXNET3_RX_RING_MAX_SIZE /
2430 sz * sz); 2447 sz * sz);
2431 ring1_size = adapter->rx_queue[0].rx_ring[1].size; 2448 ring1_size = adapter->rx_queue[0].rx_ring[1].size;
2432 comp_size = ring0_size + ring1_size; 2449 comp_size = ring0_size + ring1_size;
@@ -2695,7 +2712,7 @@ vmxnet3_acquire_msix_vectors(struct vmxnet3_adapter *adapter,
2695 break; 2712 break;
2696 } else { 2713 } else {
2697 /* If fails to enable required number of MSI-x vectors 2714 /* If fails to enable required number of MSI-x vectors
2698 * try enabling 3 of them. One each for rx, tx and event 2715 * try enabling minimum number of vectors required.
2699 */ 2716 */
2700 vectors = vector_threshold; 2717 vectors = vector_threshold;
2701 printk(KERN_ERR "Failed to enable %d MSI-X for %s, try" 2718 printk(KERN_ERR "Failed to enable %d MSI-X for %s, try"
@@ -2718,9 +2735,11 @@ vmxnet3_alloc_intr_resources(struct vmxnet3_adapter *adapter)
2718 u32 cfg; 2735 u32 cfg;
2719 2736
2720 /* intr settings */ 2737 /* intr settings */
2738 spin_lock(&adapter->cmd_lock);
2721 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, 2739 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
2722 VMXNET3_CMD_GET_CONF_INTR); 2740 VMXNET3_CMD_GET_CONF_INTR);
2723 cfg = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD); 2741 cfg = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD);
2742 spin_unlock(&adapter->cmd_lock);
2724 adapter->intr.type = cfg & 0x3; 2743 adapter->intr.type = cfg & 0x3;
2725 adapter->intr.mask_mode = (cfg >> 2) & 0x3; 2744 adapter->intr.mask_mode = (cfg >> 2) & 0x3;
2726 2745
@@ -2755,7 +2774,7 @@ vmxnet3_alloc_intr_resources(struct vmxnet3_adapter *adapter)
2755 */ 2774 */
2756 if (err == VMXNET3_LINUX_MIN_MSIX_VECT) { 2775 if (err == VMXNET3_LINUX_MIN_MSIX_VECT) {
2757 if (adapter->share_intr != VMXNET3_INTR_BUDDYSHARE 2776 if (adapter->share_intr != VMXNET3_INTR_BUDDYSHARE
2758 || adapter->num_rx_queues != 2) { 2777 || adapter->num_rx_queues != 1) {
2759 adapter->share_intr = VMXNET3_INTR_TXSHARE; 2778 adapter->share_intr = VMXNET3_INTR_TXSHARE;
2760 printk(KERN_ERR "Number of rx queues : 1\n"); 2779 printk(KERN_ERR "Number of rx queues : 1\n");
2761 adapter->num_rx_queues = 1; 2780 adapter->num_rx_queues = 1;
@@ -2905,6 +2924,7 @@ vmxnet3_probe_device(struct pci_dev *pdev,
2905 adapter->netdev = netdev; 2924 adapter->netdev = netdev;
2906 adapter->pdev = pdev; 2925 adapter->pdev = pdev;
2907 2926
2927 spin_lock_init(&adapter->cmd_lock);
2908 adapter->shared = pci_alloc_consistent(adapter->pdev, 2928 adapter->shared = pci_alloc_consistent(adapter->pdev,
2909 sizeof(struct Vmxnet3_DriverShared), 2929 sizeof(struct Vmxnet3_DriverShared),
2910 &adapter->shared_pa); 2930 &adapter->shared_pa);
@@ -3108,11 +3128,15 @@ vmxnet3_suspend(struct device *device)
3108 u8 *arpreq; 3128 u8 *arpreq;
3109 struct in_device *in_dev; 3129 struct in_device *in_dev;
3110 struct in_ifaddr *ifa; 3130 struct in_ifaddr *ifa;
3131 unsigned long flags;
3111 int i = 0; 3132 int i = 0;
3112 3133
3113 if (!netif_running(netdev)) 3134 if (!netif_running(netdev))
3114 return 0; 3135 return 0;
3115 3136
3137 for (i = 0; i < adapter->num_rx_queues; i++)
3138 napi_disable(&adapter->rx_queue[i].napi);
3139
3116 vmxnet3_disable_all_intrs(adapter); 3140 vmxnet3_disable_all_intrs(adapter);
3117 vmxnet3_free_irqs(adapter); 3141 vmxnet3_free_irqs(adapter);
3118 vmxnet3_free_intr_resources(adapter); 3142 vmxnet3_free_intr_resources(adapter);
@@ -3188,8 +3212,10 @@ skip_arp:
3188 adapter->shared->devRead.pmConfDesc.confPA = cpu_to_le64(virt_to_phys( 3212 adapter->shared->devRead.pmConfDesc.confPA = cpu_to_le64(virt_to_phys(
3189 pmConf)); 3213 pmConf));
3190 3214
3215 spin_lock_irqsave(&adapter->cmd_lock, flags);
3191 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, 3216 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
3192 VMXNET3_CMD_UPDATE_PMCFG); 3217 VMXNET3_CMD_UPDATE_PMCFG);
3218 spin_unlock_irqrestore(&adapter->cmd_lock, flags);
3193 3219
3194 pci_save_state(pdev); 3220 pci_save_state(pdev);
3195 pci_enable_wake(pdev, pci_choose_state(pdev, PMSG_SUSPEND), 3221 pci_enable_wake(pdev, pci_choose_state(pdev, PMSG_SUSPEND),
@@ -3204,7 +3230,8 @@ skip_arp:
3204static int 3230static int
3205vmxnet3_resume(struct device *device) 3231vmxnet3_resume(struct device *device)
3206{ 3232{
3207 int err; 3233 int err, i = 0;
3234 unsigned long flags;
3208 struct pci_dev *pdev = to_pci_dev(device); 3235 struct pci_dev *pdev = to_pci_dev(device);
3209 struct net_device *netdev = pci_get_drvdata(pdev); 3236 struct net_device *netdev = pci_get_drvdata(pdev);
3210 struct vmxnet3_adapter *adapter = netdev_priv(netdev); 3237 struct vmxnet3_adapter *adapter = netdev_priv(netdev);
@@ -3232,10 +3259,14 @@ vmxnet3_resume(struct device *device)
3232 3259
3233 pci_enable_wake(pdev, PCI_D0, 0); 3260 pci_enable_wake(pdev, PCI_D0, 0);
3234 3261
3262 spin_lock_irqsave(&adapter->cmd_lock, flags);
3235 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, 3263 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
3236 VMXNET3_CMD_UPDATE_PMCFG); 3264 VMXNET3_CMD_UPDATE_PMCFG);
3265 spin_unlock_irqrestore(&adapter->cmd_lock, flags);
3237 vmxnet3_alloc_intr_resources(adapter); 3266 vmxnet3_alloc_intr_resources(adapter);
3238 vmxnet3_request_irqs(adapter); 3267 vmxnet3_request_irqs(adapter);
3268 for (i = 0; i < adapter->num_rx_queues; i++)
3269 napi_enable(&adapter->rx_queue[i].napi);
3239 vmxnet3_enable_all_intrs(adapter); 3270 vmxnet3_enable_all_intrs(adapter);
3240 3271
3241 return 0; 3272 return 0;
diff --git a/drivers/net/vmxnet3/vmxnet3_ethtool.c b/drivers/net/vmxnet3/vmxnet3_ethtool.c
index 8e17fc8a7fe7..81254be85b92 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethtool.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethtool.c
@@ -45,6 +45,7 @@ static int
45vmxnet3_set_rx_csum(struct net_device *netdev, u32 val) 45vmxnet3_set_rx_csum(struct net_device *netdev, u32 val)
46{ 46{
47 struct vmxnet3_adapter *adapter = netdev_priv(netdev); 47 struct vmxnet3_adapter *adapter = netdev_priv(netdev);
48 unsigned long flags;
48 49
49 if (adapter->rxcsum != val) { 50 if (adapter->rxcsum != val) {
50 adapter->rxcsum = val; 51 adapter->rxcsum = val;
@@ -56,8 +57,10 @@ vmxnet3_set_rx_csum(struct net_device *netdev, u32 val)
56 adapter->shared->devRead.misc.uptFeatures &= 57 adapter->shared->devRead.misc.uptFeatures &=
57 ~UPT1_F_RXCSUM; 58 ~UPT1_F_RXCSUM;
58 59
60 spin_lock_irqsave(&adapter->cmd_lock, flags);
59 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, 61 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
60 VMXNET3_CMD_UPDATE_FEATURE); 62 VMXNET3_CMD_UPDATE_FEATURE);
63 spin_unlock_irqrestore(&adapter->cmd_lock, flags);
61 } 64 }
62 } 65 }
63 return 0; 66 return 0;
@@ -68,76 +71,78 @@ vmxnet3_set_rx_csum(struct net_device *netdev, u32 val)
68static const struct vmxnet3_stat_desc 71static const struct vmxnet3_stat_desc
69vmxnet3_tq_dev_stats[] = { 72vmxnet3_tq_dev_stats[] = {
70 /* description, offset */ 73 /* description, offset */
71 { "TSO pkts tx", offsetof(struct UPT1_TxStats, TSOPktsTxOK) }, 74 { "Tx Queue#", 0 },
72 { "TSO bytes tx", offsetof(struct UPT1_TxStats, TSOBytesTxOK) }, 75 { " TSO pkts tx", offsetof(struct UPT1_TxStats, TSOPktsTxOK) },
73 { "ucast pkts tx", offsetof(struct UPT1_TxStats, ucastPktsTxOK) }, 76 { " TSO bytes tx", offsetof(struct UPT1_TxStats, TSOBytesTxOK) },
74 { "ucast bytes tx", offsetof(struct UPT1_TxStats, ucastBytesTxOK) }, 77 { " ucast pkts tx", offsetof(struct UPT1_TxStats, ucastPktsTxOK) },
75 { "mcast pkts tx", offsetof(struct UPT1_TxStats, mcastPktsTxOK) }, 78 { " ucast bytes tx", offsetof(struct UPT1_TxStats, ucastBytesTxOK) },
76 { "mcast bytes tx", offsetof(struct UPT1_TxStats, mcastBytesTxOK) }, 79 { " mcast pkts tx", offsetof(struct UPT1_TxStats, mcastPktsTxOK) },
77 { "bcast pkts tx", offsetof(struct UPT1_TxStats, bcastPktsTxOK) }, 80 { " mcast bytes tx", offsetof(struct UPT1_TxStats, mcastBytesTxOK) },
78 { "bcast bytes tx", offsetof(struct UPT1_TxStats, bcastBytesTxOK) }, 81 { " bcast pkts tx", offsetof(struct UPT1_TxStats, bcastPktsTxOK) },
79 { "pkts tx err", offsetof(struct UPT1_TxStats, pktsTxError) }, 82 { " bcast bytes tx", offsetof(struct UPT1_TxStats, bcastBytesTxOK) },
80 { "pkts tx discard", offsetof(struct UPT1_TxStats, pktsTxDiscard) }, 83 { " pkts tx err", offsetof(struct UPT1_TxStats, pktsTxError) },
84 { " pkts tx discard", offsetof(struct UPT1_TxStats, pktsTxDiscard) },
81}; 85};
82 86
83/* per tq stats maintained by the driver */ 87/* per tq stats maintained by the driver */
84static const struct vmxnet3_stat_desc 88static const struct vmxnet3_stat_desc
85vmxnet3_tq_driver_stats[] = { 89vmxnet3_tq_driver_stats[] = {
86 /* description, offset */ 90 /* description, offset */
87 {"drv dropped tx total", offsetof(struct vmxnet3_tq_driver_stats, 91 {" drv dropped tx total", offsetof(struct vmxnet3_tq_driver_stats,
88 drop_total) }, 92 drop_total) },
89 { " too many frags", offsetof(struct vmxnet3_tq_driver_stats, 93 { " too many frags", offsetof(struct vmxnet3_tq_driver_stats,
90 drop_too_many_frags) }, 94 drop_too_many_frags) },
91 { " giant hdr", offsetof(struct vmxnet3_tq_driver_stats, 95 { " giant hdr", offsetof(struct vmxnet3_tq_driver_stats,
92 drop_oversized_hdr) }, 96 drop_oversized_hdr) },
93 { " hdr err", offsetof(struct vmxnet3_tq_driver_stats, 97 { " hdr err", offsetof(struct vmxnet3_tq_driver_stats,
94 drop_hdr_inspect_err) }, 98 drop_hdr_inspect_err) },
95 { " tso", offsetof(struct vmxnet3_tq_driver_stats, 99 { " tso", offsetof(struct vmxnet3_tq_driver_stats,
96 drop_tso) }, 100 drop_tso) },
97 { "ring full", offsetof(struct vmxnet3_tq_driver_stats, 101 { " ring full", offsetof(struct vmxnet3_tq_driver_stats,
98 tx_ring_full) }, 102 tx_ring_full) },
99 { "pkts linearized", offsetof(struct vmxnet3_tq_driver_stats, 103 { " pkts linearized", offsetof(struct vmxnet3_tq_driver_stats,
100 linearized) }, 104 linearized) },
101 { "hdr cloned", offsetof(struct vmxnet3_tq_driver_stats, 105 { " hdr cloned", offsetof(struct vmxnet3_tq_driver_stats,
102 copy_skb_header) }, 106 copy_skb_header) },
103 { "giant hdr", offsetof(struct vmxnet3_tq_driver_stats, 107 { " giant hdr", offsetof(struct vmxnet3_tq_driver_stats,
104 oversized_hdr) }, 108 oversized_hdr) },
105}; 109};
106 110
107/* per rq stats maintained by the device */ 111/* per rq stats maintained by the device */
108static const struct vmxnet3_stat_desc 112static const struct vmxnet3_stat_desc
109vmxnet3_rq_dev_stats[] = { 113vmxnet3_rq_dev_stats[] = {
110 { "LRO pkts rx", offsetof(struct UPT1_RxStats, LROPktsRxOK) }, 114 { "Rx Queue#", 0 },
111 { "LRO byte rx", offsetof(struct UPT1_RxStats, LROBytesRxOK) }, 115 { " LRO pkts rx", offsetof(struct UPT1_RxStats, LROPktsRxOK) },
112 { "ucast pkts rx", offsetof(struct UPT1_RxStats, ucastPktsRxOK) }, 116 { " LRO byte rx", offsetof(struct UPT1_RxStats, LROBytesRxOK) },
113 { "ucast bytes rx", offsetof(struct UPT1_RxStats, ucastBytesRxOK) }, 117 { " ucast pkts rx", offsetof(struct UPT1_RxStats, ucastPktsRxOK) },
114 { "mcast pkts rx", offsetof(struct UPT1_RxStats, mcastPktsRxOK) }, 118 { " ucast bytes rx", offsetof(struct UPT1_RxStats, ucastBytesRxOK) },
115 { "mcast bytes rx", offsetof(struct UPT1_RxStats, mcastBytesRxOK) }, 119 { " mcast pkts rx", offsetof(struct UPT1_RxStats, mcastPktsRxOK) },
116 { "bcast pkts rx", offsetof(struct UPT1_RxStats, bcastPktsRxOK) }, 120 { " mcast bytes rx", offsetof(struct UPT1_RxStats, mcastBytesRxOK) },
117 { "bcast bytes rx", offsetof(struct UPT1_RxStats, bcastBytesRxOK) }, 121 { " bcast pkts rx", offsetof(struct UPT1_RxStats, bcastPktsRxOK) },
118 { "pkts rx out of buf", offsetof(struct UPT1_RxStats, pktsRxOutOfBuf) }, 122 { " bcast bytes rx", offsetof(struct UPT1_RxStats, bcastBytesRxOK) },
119 { "pkts rx err", offsetof(struct UPT1_RxStats, pktsRxError) }, 123 { " pkts rx OOB", offsetof(struct UPT1_RxStats, pktsRxOutOfBuf) },
124 { " pkts rx err", offsetof(struct UPT1_RxStats, pktsRxError) },
120}; 125};
121 126
122/* per rq stats maintained by the driver */ 127/* per rq stats maintained by the driver */
123static const struct vmxnet3_stat_desc 128static const struct vmxnet3_stat_desc
124vmxnet3_rq_driver_stats[] = { 129vmxnet3_rq_driver_stats[] = {
125 /* description, offset */ 130 /* description, offset */
126 { "drv dropped rx total", offsetof(struct vmxnet3_rq_driver_stats, 131 { " drv dropped rx total", offsetof(struct vmxnet3_rq_driver_stats,
127 drop_total) }, 132 drop_total) },
128 { " err", offsetof(struct vmxnet3_rq_driver_stats, 133 { " err", offsetof(struct vmxnet3_rq_driver_stats,
129 drop_err) }, 134 drop_err) },
130 { " fcs", offsetof(struct vmxnet3_rq_driver_stats, 135 { " fcs", offsetof(struct vmxnet3_rq_driver_stats,
131 drop_fcs) }, 136 drop_fcs) },
132 { "rx buf alloc fail", offsetof(struct vmxnet3_rq_driver_stats, 137 { " rx buf alloc fail", offsetof(struct vmxnet3_rq_driver_stats,
133 rx_buf_alloc_failure) }, 138 rx_buf_alloc_failure) },
134}; 139};
135 140
136/* gloabl stats maintained by the driver */ 141/* gloabl stats maintained by the driver */
137static const struct vmxnet3_stat_desc 142static const struct vmxnet3_stat_desc
138vmxnet3_global_stats[] = { 143vmxnet3_global_stats[] = {
139 /* description, offset */ 144 /* description, offset */
140 { "tx timeout count", offsetof(struct vmxnet3_adapter, 145 { "tx timeout count", offsetof(struct vmxnet3_adapter,
141 tx_timeout_count) } 146 tx_timeout_count) }
142}; 147};
143 148
@@ -151,12 +156,15 @@ vmxnet3_get_stats(struct net_device *netdev)
151 struct UPT1_TxStats *devTxStats; 156 struct UPT1_TxStats *devTxStats;
152 struct UPT1_RxStats *devRxStats; 157 struct UPT1_RxStats *devRxStats;
153 struct net_device_stats *net_stats = &netdev->stats; 158 struct net_device_stats *net_stats = &netdev->stats;
159 unsigned long flags;
154 int i; 160 int i;
155 161
156 adapter = netdev_priv(netdev); 162 adapter = netdev_priv(netdev);
157 163
158 /* Collect the dev stats into the shared area */ 164 /* Collect the dev stats into the shared area */
165 spin_lock_irqsave(&adapter->cmd_lock, flags);
159 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_GET_STATS); 166 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_GET_STATS);
167 spin_unlock_irqrestore(&adapter->cmd_lock, flags);
160 168
161 memset(net_stats, 0, sizeof(*net_stats)); 169 memset(net_stats, 0, sizeof(*net_stats));
162 for (i = 0; i < adapter->num_tx_queues; i++) { 170 for (i = 0; i < adapter->num_tx_queues; i++) {
@@ -193,12 +201,15 @@ vmxnet3_get_stats(struct net_device *netdev)
193static int 201static int
194vmxnet3_get_sset_count(struct net_device *netdev, int sset) 202vmxnet3_get_sset_count(struct net_device *netdev, int sset)
195{ 203{
204 struct vmxnet3_adapter *adapter = netdev_priv(netdev);
196 switch (sset) { 205 switch (sset) {
197 case ETH_SS_STATS: 206 case ETH_SS_STATS:
198 return ARRAY_SIZE(vmxnet3_tq_dev_stats) + 207 return (ARRAY_SIZE(vmxnet3_tq_dev_stats) +
199 ARRAY_SIZE(vmxnet3_tq_driver_stats) + 208 ARRAY_SIZE(vmxnet3_tq_driver_stats)) *
200 ARRAY_SIZE(vmxnet3_rq_dev_stats) + 209 adapter->num_tx_queues +
201 ARRAY_SIZE(vmxnet3_rq_driver_stats) + 210 (ARRAY_SIZE(vmxnet3_rq_dev_stats) +
211 ARRAY_SIZE(vmxnet3_rq_driver_stats)) *
212 adapter->num_rx_queues +
202 ARRAY_SIZE(vmxnet3_global_stats); 213 ARRAY_SIZE(vmxnet3_global_stats);
203 default: 214 default:
204 return -EOPNOTSUPP; 215 return -EOPNOTSUPP;
@@ -206,10 +217,16 @@ vmxnet3_get_sset_count(struct net_device *netdev, int sset)
206} 217}
207 218
208 219
220/* Should be multiple of 4 */
221#define NUM_TX_REGS 8
222#define NUM_RX_REGS 12
223
209static int 224static int
210vmxnet3_get_regs_len(struct net_device *netdev) 225vmxnet3_get_regs_len(struct net_device *netdev)
211{ 226{
212 return 20 * sizeof(u32); 227 struct vmxnet3_adapter *adapter = netdev_priv(netdev);
228 return (adapter->num_tx_queues * NUM_TX_REGS * sizeof(u32) +
229 adapter->num_rx_queues * NUM_RX_REGS * sizeof(u32));
213} 230}
214 231
215 232
@@ -240,29 +257,37 @@ vmxnet3_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo)
240static void 257static void
241vmxnet3_get_strings(struct net_device *netdev, u32 stringset, u8 *buf) 258vmxnet3_get_strings(struct net_device *netdev, u32 stringset, u8 *buf)
242{ 259{
260 struct vmxnet3_adapter *adapter = netdev_priv(netdev);
243 if (stringset == ETH_SS_STATS) { 261 if (stringset == ETH_SS_STATS) {
244 int i; 262 int i, j;
245 263 for (j = 0; j < adapter->num_tx_queues; j++) {
246 for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_dev_stats); i++) { 264 for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_dev_stats); i++) {
247 memcpy(buf, vmxnet3_tq_dev_stats[i].desc, 265 memcpy(buf, vmxnet3_tq_dev_stats[i].desc,
248 ETH_GSTRING_LEN); 266 ETH_GSTRING_LEN);
249 buf += ETH_GSTRING_LEN; 267 buf += ETH_GSTRING_LEN;
250 } 268 }
251 for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_driver_stats); i++) { 269 for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_driver_stats);
252 memcpy(buf, vmxnet3_tq_driver_stats[i].desc, 270 i++) {
253 ETH_GSTRING_LEN); 271 memcpy(buf, vmxnet3_tq_driver_stats[i].desc,
254 buf += ETH_GSTRING_LEN; 272 ETH_GSTRING_LEN);
255 } 273 buf += ETH_GSTRING_LEN;
256 for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_dev_stats); i++) { 274 }
257 memcpy(buf, vmxnet3_rq_dev_stats[i].desc,
258 ETH_GSTRING_LEN);
259 buf += ETH_GSTRING_LEN;
260 } 275 }
261 for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_driver_stats); i++) { 276
262 memcpy(buf, vmxnet3_rq_driver_stats[i].desc, 277 for (j = 0; j < adapter->num_rx_queues; j++) {
263 ETH_GSTRING_LEN); 278 for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_dev_stats); i++) {
264 buf += ETH_GSTRING_LEN; 279 memcpy(buf, vmxnet3_rq_dev_stats[i].desc,
280 ETH_GSTRING_LEN);
281 buf += ETH_GSTRING_LEN;
282 }
283 for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_driver_stats);
284 i++) {
285 memcpy(buf, vmxnet3_rq_driver_stats[i].desc,
286 ETH_GSTRING_LEN);
287 buf += ETH_GSTRING_LEN;
288 }
265 } 289 }
290
266 for (i = 0; i < ARRAY_SIZE(vmxnet3_global_stats); i++) { 291 for (i = 0; i < ARRAY_SIZE(vmxnet3_global_stats); i++) {
267 memcpy(buf, vmxnet3_global_stats[i].desc, 292 memcpy(buf, vmxnet3_global_stats[i].desc,
268 ETH_GSTRING_LEN); 293 ETH_GSTRING_LEN);
@@ -277,6 +302,7 @@ vmxnet3_set_flags(struct net_device *netdev, u32 data)
277 struct vmxnet3_adapter *adapter = netdev_priv(netdev); 302 struct vmxnet3_adapter *adapter = netdev_priv(netdev);
278 u8 lro_requested = (data & ETH_FLAG_LRO) == 0 ? 0 : 1; 303 u8 lro_requested = (data & ETH_FLAG_LRO) == 0 ? 0 : 1;
279 u8 lro_present = (netdev->features & NETIF_F_LRO) == 0 ? 0 : 1; 304 u8 lro_present = (netdev->features & NETIF_F_LRO) == 0 ? 0 : 1;
305 unsigned long flags;
280 306
281 if (data & ~ETH_FLAG_LRO) 307 if (data & ~ETH_FLAG_LRO)
282 return -EOPNOTSUPP; 308 return -EOPNOTSUPP;
@@ -292,8 +318,10 @@ vmxnet3_set_flags(struct net_device *netdev, u32 data)
292 else 318 else
293 adapter->shared->devRead.misc.uptFeatures &= 319 adapter->shared->devRead.misc.uptFeatures &=
294 ~UPT1_F_LRO; 320 ~UPT1_F_LRO;
321 spin_lock_irqsave(&adapter->cmd_lock, flags);
295 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, 322 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
296 VMXNET3_CMD_UPDATE_FEATURE); 323 VMXNET3_CMD_UPDATE_FEATURE);
324 spin_unlock_irqrestore(&adapter->cmd_lock, flags);
297 } 325 }
298 return 0; 326 return 0;
299} 327}
@@ -303,30 +331,41 @@ vmxnet3_get_ethtool_stats(struct net_device *netdev,
303 struct ethtool_stats *stats, u64 *buf) 331 struct ethtool_stats *stats, u64 *buf)
304{ 332{
305 struct vmxnet3_adapter *adapter = netdev_priv(netdev); 333 struct vmxnet3_adapter *adapter = netdev_priv(netdev);
334 unsigned long flags;
306 u8 *base; 335 u8 *base;
307 int i; 336 int i;
308 int j = 0; 337 int j = 0;
309 338
339 spin_lock_irqsave(&adapter->cmd_lock, flags);
310 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_GET_STATS); 340 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_GET_STATS);
341 spin_unlock_irqrestore(&adapter->cmd_lock, flags);
311 342
312 /* this does assume each counter is 64-bit wide */ 343 /* this does assume each counter is 64-bit wide */
313/* TODO change this for multiple queues */ 344 for (j = 0; j < adapter->num_tx_queues; j++) {
314 345 base = (u8 *)&adapter->tqd_start[j].stats;
315 base = (u8 *)&adapter->tqd_start[j].stats; 346 *buf++ = (u64)j;
316 for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_dev_stats); i++) 347 for (i = 1; i < ARRAY_SIZE(vmxnet3_tq_dev_stats); i++)
317 *buf++ = *(u64 *)(base + vmxnet3_tq_dev_stats[i].offset); 348 *buf++ = *(u64 *)(base +
318 349 vmxnet3_tq_dev_stats[i].offset);
319 base = (u8 *)&adapter->tx_queue[j].stats; 350
320 for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_driver_stats); i++) 351 base = (u8 *)&adapter->tx_queue[j].stats;
321 *buf++ = *(u64 *)(base + vmxnet3_tq_driver_stats[i].offset); 352 for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_driver_stats); i++)
322 353 *buf++ = *(u64 *)(base +
323 base = (u8 *)&adapter->rqd_start[j].stats; 354 vmxnet3_tq_driver_stats[i].offset);
324 for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_dev_stats); i++) 355 }
325 *buf++ = *(u64 *)(base + vmxnet3_rq_dev_stats[i].offset);
326 356
327 base = (u8 *)&adapter->rx_queue[j].stats; 357 for (j = 0; j < adapter->num_tx_queues; j++) {
328 for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_driver_stats); i++) 358 base = (u8 *)&adapter->rqd_start[j].stats;
329 *buf++ = *(u64 *)(base + vmxnet3_rq_driver_stats[i].offset); 359 *buf++ = (u64) j;
360 for (i = 1; i < ARRAY_SIZE(vmxnet3_rq_dev_stats); i++)
361 *buf++ = *(u64 *)(base +
362 vmxnet3_rq_dev_stats[i].offset);
363
364 base = (u8 *)&adapter->rx_queue[j].stats;
365 for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_driver_stats); i++)
366 *buf++ = *(u64 *)(base +
367 vmxnet3_rq_driver_stats[i].offset);
368 }
330 369
331 base = (u8 *)adapter; 370 base = (u8 *)adapter;
332 for (i = 0; i < ARRAY_SIZE(vmxnet3_global_stats); i++) 371 for (i = 0; i < ARRAY_SIZE(vmxnet3_global_stats); i++)
@@ -339,7 +378,7 @@ vmxnet3_get_regs(struct net_device *netdev, struct ethtool_regs *regs, void *p)
339{ 378{
340 struct vmxnet3_adapter *adapter = netdev_priv(netdev); 379 struct vmxnet3_adapter *adapter = netdev_priv(netdev);
341 u32 *buf = p; 380 u32 *buf = p;
342 int i = 0; 381 int i = 0, j = 0;
343 382
344 memset(p, 0, vmxnet3_get_regs_len(netdev)); 383 memset(p, 0, vmxnet3_get_regs_len(netdev));
345 384
@@ -348,31 +387,35 @@ vmxnet3_get_regs(struct net_device *netdev, struct ethtool_regs *regs, void *p)
348 /* Update vmxnet3_get_regs_len if we want to dump more registers */ 387 /* Update vmxnet3_get_regs_len if we want to dump more registers */
349 388
350 /* make each ring use multiple of 16 bytes */ 389 /* make each ring use multiple of 16 bytes */
351/* TODO change this for multiple queues */ 390 for (i = 0; i < adapter->num_tx_queues; i++) {
352 buf[0] = adapter->tx_queue[i].tx_ring.next2fill; 391 buf[j++] = adapter->tx_queue[i].tx_ring.next2fill;
353 buf[1] = adapter->tx_queue[i].tx_ring.next2comp; 392 buf[j++] = adapter->tx_queue[i].tx_ring.next2comp;
354 buf[2] = adapter->tx_queue[i].tx_ring.gen; 393 buf[j++] = adapter->tx_queue[i].tx_ring.gen;
355 buf[3] = 0; 394 buf[j++] = 0;
356 395
357 buf[4] = adapter->tx_queue[i].comp_ring.next2proc; 396 buf[j++] = adapter->tx_queue[i].comp_ring.next2proc;
358 buf[5] = adapter->tx_queue[i].comp_ring.gen; 397 buf[j++] = adapter->tx_queue[i].comp_ring.gen;
359 buf[6] = adapter->tx_queue[i].stopped; 398 buf[j++] = adapter->tx_queue[i].stopped;
360 buf[7] = 0; 399 buf[j++] = 0;
361 400 }
362 buf[8] = adapter->rx_queue[i].rx_ring[0].next2fill; 401
363 buf[9] = adapter->rx_queue[i].rx_ring[0].next2comp; 402 for (i = 0; i < adapter->num_rx_queues; i++) {
364 buf[10] = adapter->rx_queue[i].rx_ring[0].gen; 403 buf[j++] = adapter->rx_queue[i].rx_ring[0].next2fill;
365 buf[11] = 0; 404 buf[j++] = adapter->rx_queue[i].rx_ring[0].next2comp;
366 405 buf[j++] = adapter->rx_queue[i].rx_ring[0].gen;
367 buf[12] = adapter->rx_queue[i].rx_ring[1].next2fill; 406 buf[j++] = 0;
368 buf[13] = adapter->rx_queue[i].rx_ring[1].next2comp; 407
369 buf[14] = adapter->rx_queue[i].rx_ring[1].gen; 408 buf[j++] = adapter->rx_queue[i].rx_ring[1].next2fill;
370 buf[15] = 0; 409 buf[j++] = adapter->rx_queue[i].rx_ring[1].next2comp;
371 410 buf[j++] = adapter->rx_queue[i].rx_ring[1].gen;
372 buf[16] = adapter->rx_queue[i].comp_ring.next2proc; 411 buf[j++] = 0;
373 buf[17] = adapter->rx_queue[i].comp_ring.gen; 412
374 buf[18] = 0; 413 buf[j++] = adapter->rx_queue[i].comp_ring.next2proc;
375 buf[19] = 0; 414 buf[j++] = adapter->rx_queue[i].comp_ring.gen;
415 buf[j++] = 0;
416 buf[j++] = 0;
417 }
418
376} 419}
377 420
378 421
@@ -574,6 +617,7 @@ vmxnet3_set_rss_indir(struct net_device *netdev,
574 const struct ethtool_rxfh_indir *p) 617 const struct ethtool_rxfh_indir *p)
575{ 618{
576 unsigned int i; 619 unsigned int i;
620 unsigned long flags;
577 struct vmxnet3_adapter *adapter = netdev_priv(netdev); 621 struct vmxnet3_adapter *adapter = netdev_priv(netdev);
578 struct UPT1_RSSConf *rssConf = adapter->rss_conf; 622 struct UPT1_RSSConf *rssConf = adapter->rss_conf;
579 623
@@ -592,8 +636,10 @@ vmxnet3_set_rss_indir(struct net_device *netdev,
592 for (i = 0; i < rssConf->indTableSize; i++) 636 for (i = 0; i < rssConf->indTableSize; i++)
593 rssConf->indTable[i] = p->ring_index[i]; 637 rssConf->indTable[i] = p->ring_index[i];
594 638
639 spin_lock_irqsave(&adapter->cmd_lock, flags);
595 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, 640 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
596 VMXNET3_CMD_UPDATE_RSSIDT); 641 VMXNET3_CMD_UPDATE_RSSIDT);
642 spin_unlock_irqrestore(&adapter->cmd_lock, flags);
597 643
598 return 0; 644 return 0;
599 645
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h b/drivers/net/vmxnet3/vmxnet3_int.h
index 7fadeed37f03..fb5d245ac878 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -68,10 +68,10 @@
68/* 68/*
69 * Version numbers 69 * Version numbers
70 */ 70 */
71#define VMXNET3_DRIVER_VERSION_STRING "1.0.16.0-k" 71#define VMXNET3_DRIVER_VERSION_STRING "1.0.25.0-k"
72 72
73/* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */ 73/* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
74#define VMXNET3_DRIVER_VERSION_NUM 0x01001000 74#define VMXNET3_DRIVER_VERSION_NUM 0x01001900
75 75
76#if defined(CONFIG_PCI_MSI) 76#if defined(CONFIG_PCI_MSI)
77 /* RSS only makes sense if MSI-X is supported. */ 77 /* RSS only makes sense if MSI-X is supported. */
@@ -289,7 +289,7 @@ struct vmxnet3_rx_queue {
289 289
290#define VMXNET3_LINUX_MAX_MSIX_VECT (VMXNET3_DEVICE_MAX_TX_QUEUES + \ 290#define VMXNET3_LINUX_MAX_MSIX_VECT (VMXNET3_DEVICE_MAX_TX_QUEUES + \
291 VMXNET3_DEVICE_MAX_RX_QUEUES + 1) 291 VMXNET3_DEVICE_MAX_RX_QUEUES + 1)
292#define VMXNET3_LINUX_MIN_MSIX_VECT 3 /* 1 for each : tx, rx and event */ 292#define VMXNET3_LINUX_MIN_MSIX_VECT 2 /* 1 for tx-rx pair and 1 for event */
293 293
294 294
295struct vmxnet3_intr { 295struct vmxnet3_intr {
@@ -317,6 +317,7 @@ struct vmxnet3_adapter {
317 struct vmxnet3_rx_queue rx_queue[VMXNET3_DEVICE_MAX_RX_QUEUES]; 317 struct vmxnet3_rx_queue rx_queue[VMXNET3_DEVICE_MAX_RX_QUEUES];
318 struct vlan_group *vlan_grp; 318 struct vlan_group *vlan_grp;
319 struct vmxnet3_intr intr; 319 struct vmxnet3_intr intr;
320 spinlock_t cmd_lock;
320 struct Vmxnet3_DriverShared *shared; 321 struct Vmxnet3_DriverShared *shared;
321 struct Vmxnet3_PMConf *pm_conf; 322 struct Vmxnet3_PMConf *pm_conf;
322 struct Vmxnet3_TxQueueDesc *tqd_start; /* all tx queue desc */ 323 struct Vmxnet3_TxQueueDesc *tqd_start; /* all tx queue desc */
diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
index 019a74d533a6..09ae4ef0fd51 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -2294,6 +2294,8 @@ ath5k_tx_complete_poll_work(struct work_struct *work)
2294 int i; 2294 int i;
2295 bool needreset = false; 2295 bool needreset = false;
2296 2296
2297 mutex_lock(&sc->lock);
2298
2297 for (i = 0; i < ARRAY_SIZE(sc->txqs); i++) { 2299 for (i = 0; i < ARRAY_SIZE(sc->txqs); i++) {
2298 if (sc->txqs[i].setup) { 2300 if (sc->txqs[i].setup) {
2299 txq = &sc->txqs[i]; 2301 txq = &sc->txqs[i];
@@ -2321,6 +2323,8 @@ ath5k_tx_complete_poll_work(struct work_struct *work)
2321 ath5k_reset(sc, NULL, true); 2323 ath5k_reset(sc, NULL, true);
2322 } 2324 }
2323 2325
2326 mutex_unlock(&sc->lock);
2327
2324 ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 2328 ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work,
2325 msecs_to_jiffies(ATH5K_TX_COMPLETE_POLL_INT)); 2329 msecs_to_jiffies(ATH5K_TX_COMPLETE_POLL_INT));
2326} 2330}
diff --git a/drivers/net/wireless/ath/ath9k/ar9002_calib.c b/drivers/net/wireless/ath/ath9k/ar9002_calib.c
index ea2e7d714bda..5e300bd3d264 100644
--- a/drivers/net/wireless/ath/ath9k/ar9002_calib.c
+++ b/drivers/net/wireless/ath/ath9k/ar9002_calib.c
@@ -679,10 +679,6 @@ static bool ar9002_hw_calibrate(struct ath_hw *ah,
679 679
680 /* Do NF cal only at longer intervals */ 680 /* Do NF cal only at longer intervals */
681 if (longcal || nfcal_pending) { 681 if (longcal || nfcal_pending) {
682 /* Do periodic PAOffset Cal */
683 ar9002_hw_pa_cal(ah, false);
684 ar9002_hw_olc_temp_compensation(ah);
685
686 /* 682 /*
687 * Get the value from the previous NF cal and update 683 * Get the value from the previous NF cal and update
688 * history buffer. 684 * history buffer.
@@ -697,8 +693,12 @@ static bool ar9002_hw_calibrate(struct ath_hw *ah,
697 ath9k_hw_loadnf(ah, ah->curchan); 693 ath9k_hw_loadnf(ah, ah->curchan);
698 } 694 }
699 695
700 if (longcal) 696 if (longcal) {
701 ath9k_hw_start_nfcal(ah, false); 697 ath9k_hw_start_nfcal(ah, false);
698 /* Do periodic PAOffset Cal */
699 ar9002_hw_pa_cal(ah, false);
700 ar9002_hw_olc_temp_compensation(ah);
701 }
702 } 702 }
703 703
704 return iscaldone; 704 return iscaldone;
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h b/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
index 81f9cf294dec..9ecca93392e8 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
@@ -1842,7 +1842,7 @@ static const u32 ar9300_2p2_soc_preamble[][2] = {
1842 1842
1843static const u32 ar9300PciePhy_pll_on_clkreq_disable_L1_2p2[][2] = { 1843static const u32 ar9300PciePhy_pll_on_clkreq_disable_L1_2p2[][2] = {
1844 /* Addr allmodes */ 1844 /* Addr allmodes */
1845 {0x00004040, 0x08212e5e}, 1845 {0x00004040, 0x0821265e},
1846 {0x00004040, 0x0008003b}, 1846 {0x00004040, 0x0008003b},
1847 {0x00004044, 0x00000000}, 1847 {0x00004044, 0x00000000},
1848}; 1848};
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_hw.c b/drivers/net/wireless/ath/ath9k/ar9003_hw.c
index 6137634e46ca..06fb2c850535 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_hw.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_hw.c
@@ -146,8 +146,8 @@ static void ar9003_hw_init_mode_regs(struct ath_hw *ah)
146 /* Sleep Setting */ 146 /* Sleep Setting */
147 147
148 INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower, 148 INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
149 ar9300PciePhy_clkreq_enable_L1_2p2, 149 ar9300PciePhy_pll_on_clkreq_disable_L1_2p2,
150 ARRAY_SIZE(ar9300PciePhy_clkreq_enable_L1_2p2), 150 ARRAY_SIZE(ar9300PciePhy_pll_on_clkreq_disable_L1_2p2),
151 2); 151 2);
152 152
153 /* Fast clock modal settings */ 153 /* Fast clock modal settings */
diff --git a/drivers/net/wireless/ath/ath9k/htc.h b/drivers/net/wireless/ath/ath9k/htc.h
index 1ce506f23110..780ac5eac501 100644
--- a/drivers/net/wireless/ath/ath9k/htc.h
+++ b/drivers/net/wireless/ath/ath9k/htc.h
@@ -78,7 +78,7 @@ struct tx_frame_hdr {
78 u8 node_idx; 78 u8 node_idx;
79 u8 vif_idx; 79 u8 vif_idx;
80 u8 tidno; 80 u8 tidno;
81 u32 flags; /* ATH9K_HTC_TX_* */ 81 __be32 flags; /* ATH9K_HTC_TX_* */
82 u8 key_type; 82 u8 key_type;
83 u8 keyix; 83 u8 keyix;
84 u8 reserved[26]; 84 u8 reserved[26];
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
index 33f36029fa4f..7a5ffca21958 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
@@ -113,6 +113,7 @@ int ath9k_htc_tx_start(struct ath9k_htc_priv *priv, struct sk_buff *skb)
113 113
114 if (ieee80211_is_data(fc)) { 114 if (ieee80211_is_data(fc)) {
115 struct tx_frame_hdr tx_hdr; 115 struct tx_frame_hdr tx_hdr;
116 u32 flags = 0;
116 u8 *qc; 117 u8 *qc;
117 118
118 memset(&tx_hdr, 0, sizeof(struct tx_frame_hdr)); 119 memset(&tx_hdr, 0, sizeof(struct tx_frame_hdr));
@@ -136,13 +137,14 @@ int ath9k_htc_tx_start(struct ath9k_htc_priv *priv, struct sk_buff *skb)
136 /* Check for RTS protection */ 137 /* Check for RTS protection */
137 if (priv->hw->wiphy->rts_threshold != (u32) -1) 138 if (priv->hw->wiphy->rts_threshold != (u32) -1)
138 if (skb->len > priv->hw->wiphy->rts_threshold) 139 if (skb->len > priv->hw->wiphy->rts_threshold)
139 tx_hdr.flags |= ATH9K_HTC_TX_RTSCTS; 140 flags |= ATH9K_HTC_TX_RTSCTS;
140 141
141 /* CTS-to-self */ 142 /* CTS-to-self */
142 if (!(tx_hdr.flags & ATH9K_HTC_TX_RTSCTS) && 143 if (!(flags & ATH9K_HTC_TX_RTSCTS) &&
143 (priv->op_flags & OP_PROTECT_ENABLE)) 144 (priv->op_flags & OP_PROTECT_ENABLE))
144 tx_hdr.flags |= ATH9K_HTC_TX_CTSONLY; 145 flags |= ATH9K_HTC_TX_CTSONLY;
145 146
147 tx_hdr.flags = cpu_to_be32(flags);
146 tx_hdr.key_type = ath9k_cmn_get_hw_crypto_keytype(skb); 148 tx_hdr.key_type = ath9k_cmn_get_hw_crypto_keytype(skb);
147 if (tx_hdr.key_type == ATH9K_KEY_TYPE_CLEAR) 149 if (tx_hdr.key_type == ATH9K_KEY_TYPE_CLEAR)
148 tx_hdr.keyix = (u8) ATH9K_TXKEYIX_INVALID; 150 tx_hdr.keyix = (u8) ATH9K_TXKEYIX_INVALID;
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 1afb8bb85756..9f01e50d5cda 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -369,6 +369,9 @@ static void ath9k_hw_init_config(struct ath_hw *ah)
369 else 369 else
370 ah->config.ht_enable = 0; 370 ah->config.ht_enable = 0;
371 371
372 /* PAPRD needs some more work to be enabled */
373 ah->config.paprd_disable = 1;
374
372 ah->config.rx_intr_mitigation = true; 375 ah->config.rx_intr_mitigation = true;
373 ah->config.pcieSerDesWrite = true; 376 ah->config.pcieSerDesWrite = true;
374 377
@@ -1933,7 +1936,8 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)
1933 pCap->rx_status_len = sizeof(struct ar9003_rxs); 1936 pCap->rx_status_len = sizeof(struct ar9003_rxs);
1934 pCap->tx_desc_len = sizeof(struct ar9003_txc); 1937 pCap->tx_desc_len = sizeof(struct ar9003_txc);
1935 pCap->txs_len = sizeof(struct ar9003_txs); 1938 pCap->txs_len = sizeof(struct ar9003_txs);
1936 if (ah->eep_ops->get_eeprom(ah, EEP_PAPRD)) 1939 if (!ah->config.paprd_disable &&
1940 ah->eep_ops->get_eeprom(ah, EEP_PAPRD))
1937 pCap->hw_caps |= ATH9K_HW_CAP_PAPRD; 1941 pCap->hw_caps |= ATH9K_HW_CAP_PAPRD;
1938 } else { 1942 } else {
1939 pCap->tx_desc_len = sizeof(struct ath_desc); 1943 pCap->tx_desc_len = sizeof(struct ath_desc);
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 5a3dfec45e96..ea9fde670646 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -225,6 +225,7 @@ struct ath9k_ops_config {
225 u32 pcie_waen; 225 u32 pcie_waen;
226 u8 analog_shiftreg; 226 u8 analog_shiftreg;
227 u8 ht_enable; 227 u8 ht_enable;
228 u8 paprd_disable;
228 u32 ofdm_trig_low; 229 u32 ofdm_trig_low;
229 u32 ofdm_trig_high; 230 u32 ofdm_trig_high;
230 u32 cck_trig_high; 231 u32 cck_trig_high;
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index f90a6ca94a76..c79c97be6cd4 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -592,14 +592,12 @@ void ath9k_tasklet(unsigned long data)
592 u32 status = sc->intrstatus; 592 u32 status = sc->intrstatus;
593 u32 rxmask; 593 u32 rxmask;
594 594
595 ath9k_ps_wakeup(sc);
596
597 if (status & ATH9K_INT_FATAL) { 595 if (status & ATH9K_INT_FATAL) {
598 ath_reset(sc, true); 596 ath_reset(sc, true);
599 ath9k_ps_restore(sc);
600 return; 597 return;
601 } 598 }
602 599
600 ath9k_ps_wakeup(sc);
603 spin_lock(&sc->sc_pcu_lock); 601 spin_lock(&sc->sc_pcu_lock);
604 602
605 if (!ath9k_hw_check_alive(ah)) 603 if (!ath9k_hw_check_alive(ah))
@@ -969,6 +967,7 @@ int ath_reset(struct ath_softc *sc, bool retry_tx)
969 /* Stop ANI */ 967 /* Stop ANI */
970 del_timer_sync(&common->ani.timer); 968 del_timer_sync(&common->ani.timer);
971 969
970 ath9k_ps_wakeup(sc);
972 spin_lock_bh(&sc->sc_pcu_lock); 971 spin_lock_bh(&sc->sc_pcu_lock);
973 972
974 ieee80211_stop_queues(hw); 973 ieee80211_stop_queues(hw);
@@ -1015,6 +1014,7 @@ int ath_reset(struct ath_softc *sc, bool retry_tx)
1015 1014
1016 /* Start ANI */ 1015 /* Start ANI */
1017 ath_start_ani(common); 1016 ath_start_ani(common);
1017 ath9k_ps_restore(sc);
1018 1018
1019 return r; 1019 return r;
1020} 1020}
@@ -1701,7 +1701,9 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
1701skip_chan_change: 1701skip_chan_change:
1702 if (changed & IEEE80211_CONF_CHANGE_POWER) { 1702 if (changed & IEEE80211_CONF_CHANGE_POWER) {
1703 sc->config.txpowlimit = 2 * conf->power_level; 1703 sc->config.txpowlimit = 2 * conf->power_level;
1704 ath9k_ps_wakeup(sc);
1704 ath_update_txpow(sc); 1705 ath_update_txpow(sc);
1706 ath9k_ps_restore(sc);
1705 } 1707 }
1706 1708
1707 spin_lock_bh(&sc->wiphy_lock); 1709 spin_lock_bh(&sc->wiphy_lock);
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index 332d1feb5c18..33a37edbaf79 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -2113,9 +2113,7 @@ static void ath_tx_complete_poll_work(struct work_struct *work)
2113 if (needreset) { 2113 if (needreset) {
2114 ath_dbg(ath9k_hw_common(sc->sc_ah), ATH_DBG_RESET, 2114 ath_dbg(ath9k_hw_common(sc->sc_ah), ATH_DBG_RESET,
2115 "tx hung, resetting the chip\n"); 2115 "tx hung, resetting the chip\n");
2116 ath9k_ps_wakeup(sc);
2117 ath_reset(sc, true); 2116 ath_reset(sc, true);
2118 ath9k_ps_restore(sc);
2119 } 2117 }
2120 2118
2121 ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 2119 ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work,
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 3f1e5f1bf847..91a9f5253469 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -2624,6 +2624,7 @@ struct iwl_cfg iwl4965_agn_cfg = {
2624 .fw_name_pre = IWL4965_FW_PRE, 2624 .fw_name_pre = IWL4965_FW_PRE,
2625 .ucode_api_max = IWL4965_UCODE_API_MAX, 2625 .ucode_api_max = IWL4965_UCODE_API_MAX,
2626 .ucode_api_min = IWL4965_UCODE_API_MIN, 2626 .ucode_api_min = IWL4965_UCODE_API_MIN,
2627 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
2627 .valid_tx_ant = ANT_AB, 2628 .valid_tx_ant = ANT_AB,
2628 .valid_rx_ant = ANT_ABC, 2629 .valid_rx_ant = ANT_ABC,
2629 .eeprom_ver = EEPROM_4965_EEPROM_VERSION, 2630 .eeprom_ver = EEPROM_4965_EEPROM_VERSION,
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-agn-eeprom.c
index 97906dd442e6..27b5a3eec9dc 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-eeprom.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-eeprom.c
@@ -152,11 +152,14 @@ int iwl_eeprom_check_sku(struct iwl_priv *priv)
152 152
153 eeprom_sku = iwl_eeprom_query16(priv, EEPROM_SKU_CAP); 153 eeprom_sku = iwl_eeprom_query16(priv, EEPROM_SKU_CAP);
154 154
155 priv->cfg->sku = ((eeprom_sku & EEPROM_SKU_CAP_BAND_SELECTION) >> 155 if (!priv->cfg->sku) {
156 /* not using sku overwrite */
157 priv->cfg->sku =
158 ((eeprom_sku & EEPROM_SKU_CAP_BAND_SELECTION) >>
156 EEPROM_SKU_CAP_BAND_POS); 159 EEPROM_SKU_CAP_BAND_POS);
157 if (eeprom_sku & EEPROM_SKU_CAP_11N_ENABLE) 160 if (eeprom_sku & EEPROM_SKU_CAP_11N_ENABLE)
158 priv->cfg->sku |= IWL_SKU_N; 161 priv->cfg->sku |= IWL_SKU_N;
159 162 }
160 if (!priv->cfg->sku) { 163 if (!priv->cfg->sku) {
161 IWL_ERR(priv, "Invalid device sku\n"); 164 IWL_ERR(priv, "Invalid device sku\n");
162 return -EINVAL; 165 return -EINVAL;
@@ -168,7 +171,7 @@ int iwl_eeprom_check_sku(struct iwl_priv *priv)
168 /* not using .cfg overwrite */ 171 /* not using .cfg overwrite */
169 radio_cfg = iwl_eeprom_query16(priv, EEPROM_RADIO_CONFIG); 172 radio_cfg = iwl_eeprom_query16(priv, EEPROM_RADIO_CONFIG);
170 priv->cfg->valid_tx_ant = EEPROM_RF_CFG_TX_ANT_MSK(radio_cfg); 173 priv->cfg->valid_tx_ant = EEPROM_RF_CFG_TX_ANT_MSK(radio_cfg);
171 priv->cfg->valid_rx_ant = EEPROM_RF_CFG_TX_ANT_MSK(radio_cfg); 174 priv->cfg->valid_rx_ant = EEPROM_RF_CFG_RX_ANT_MSK(radio_cfg);
172 if (!priv->cfg->valid_tx_ant || !priv->cfg->valid_rx_ant) { 175 if (!priv->cfg->valid_tx_ant || !priv->cfg->valid_rx_ant) {
173 IWL_ERR(priv, "Invalid chain (0X%x, 0X%x)\n", 176 IWL_ERR(priv, "Invalid chain (0X%x, 0X%x)\n",
174 priv->cfg->valid_tx_ant, 177 priv->cfg->valid_tx_ant,
diff --git a/drivers/net/wireless/iwmc3200wifi/netdev.c b/drivers/net/wireless/iwmc3200wifi/netdev.c
index 13a69ebf2a94..5091d77e02ce 100644
--- a/drivers/net/wireless/iwmc3200wifi/netdev.c
+++ b/drivers/net/wireless/iwmc3200wifi/netdev.c
@@ -126,6 +126,7 @@ void *iwm_if_alloc(int sizeof_bus, struct device *dev,
126 ndev = alloc_netdev_mq(0, "wlan%d", ether_setup, IWM_TX_QUEUES); 126 ndev = alloc_netdev_mq(0, "wlan%d", ether_setup, IWM_TX_QUEUES);
127 if (!ndev) { 127 if (!ndev) {
128 dev_err(dev, "no memory for network device instance\n"); 128 dev_err(dev, "no memory for network device instance\n");
129 ret = -ENOMEM;
129 goto out_priv; 130 goto out_priv;
130 } 131 }
131 132
@@ -138,6 +139,7 @@ void *iwm_if_alloc(int sizeof_bus, struct device *dev,
138 GFP_KERNEL); 139 GFP_KERNEL);
139 if (!iwm->umac_profile) { 140 if (!iwm->umac_profile) {
140 dev_err(dev, "Couldn't alloc memory for profile\n"); 141 dev_err(dev, "Couldn't alloc memory for profile\n");
142 ret = -ENOMEM;
141 goto out_profile; 143 goto out_profile;
142 } 144 }
143 145
diff --git a/drivers/net/wireless/rt2x00/rt2x00firmware.c b/drivers/net/wireless/rt2x00/rt2x00firmware.c
index f0e1eb72befc..be0ff78c1b16 100644
--- a/drivers/net/wireless/rt2x00/rt2x00firmware.c
+++ b/drivers/net/wireless/rt2x00/rt2x00firmware.c
@@ -58,6 +58,7 @@ static int rt2x00lib_request_firmware(struct rt2x00_dev *rt2x00dev)
58 58
59 if (!fw || !fw->size || !fw->data) { 59 if (!fw || !fw->size || !fw->data) {
60 ERROR(rt2x00dev, "Failed to read Firmware.\n"); 60 ERROR(rt2x00dev, "Failed to read Firmware.\n");
61 release_firmware(fw);
61 return -ENOENT; 62 return -ENOENT;
62 } 63 }
63 64
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index 0b4e8590cbb7..029be3c6c030 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -2446,6 +2446,7 @@ static struct usb_device_id rt73usb_device_table[] = {
2446 { USB_DEVICE(0x04bb, 0x093d), USB_DEVICE_DATA(&rt73usb_ops) }, 2446 { USB_DEVICE(0x04bb, 0x093d), USB_DEVICE_DATA(&rt73usb_ops) },
2447 { USB_DEVICE(0x148f, 0x2573), USB_DEVICE_DATA(&rt73usb_ops) }, 2447 { USB_DEVICE(0x148f, 0x2573), USB_DEVICE_DATA(&rt73usb_ops) },
2448 { USB_DEVICE(0x148f, 0x2671), USB_DEVICE_DATA(&rt73usb_ops) }, 2448 { USB_DEVICE(0x148f, 0x2671), USB_DEVICE_DATA(&rt73usb_ops) },
2449 { USB_DEVICE(0x0812, 0x3101), USB_DEVICE_DATA(&rt73usb_ops) },
2449 /* Qcom */ 2450 /* Qcom */
2450 { USB_DEVICE(0x18e8, 0x6196), USB_DEVICE_DATA(&rt73usb_ops) }, 2451 { USB_DEVICE(0x18e8, 0x6196), USB_DEVICE_DATA(&rt73usb_ops) },
2451 { USB_DEVICE(0x18e8, 0x6229), USB_DEVICE_DATA(&rt73usb_ops) }, 2452 { USB_DEVICE(0x18e8, 0x6229), USB_DEVICE_DATA(&rt73usb_ops) },
diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
index 0fa36aa6701a..1758d4463247 100644
--- a/drivers/net/wireless/rtlwifi/pci.c
+++ b/drivers/net/wireless/rtlwifi/pci.c
@@ -619,6 +619,13 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
619 struct sk_buff *uskb = NULL; 619 struct sk_buff *uskb = NULL;
620 u8 *pdata; 620 u8 *pdata;
621 uskb = dev_alloc_skb(skb->len + 128); 621 uskb = dev_alloc_skb(skb->len + 128);
622 if (!uskb) {
623 RT_TRACE(rtlpriv,
624 (COMP_INTR | COMP_RECV),
625 DBG_EMERG,
626 ("can't alloc rx skb\n"));
627 goto done;
628 }
622 memcpy(IEEE80211_SKB_RXCB(uskb), 629 memcpy(IEEE80211_SKB_RXCB(uskb),
623 &rx_status, 630 &rx_status,
624 sizeof(rx_status)); 631 sizeof(rx_status));
@@ -641,7 +648,7 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
641 new_skb = dev_alloc_skb(rtlpci->rxbuffersize); 648 new_skb = dev_alloc_skb(rtlpci->rxbuffersize);
642 if (unlikely(!new_skb)) { 649 if (unlikely(!new_skb)) {
643 RT_TRACE(rtlpriv, (COMP_INTR | COMP_RECV), 650 RT_TRACE(rtlpriv, (COMP_INTR | COMP_RECV),
644 DBG_DMESG, 651 DBG_EMERG,
645 ("can't alloc skb for rx\n")); 652 ("can't alloc skb for rx\n"));
646 goto done; 653 goto done;
647 } 654 }
@@ -1066,9 +1073,9 @@ static int _rtl_pci_init_rx_ring(struct ieee80211_hw *hw)
1066 struct sk_buff *skb = 1073 struct sk_buff *skb =
1067 dev_alloc_skb(rtlpci->rxbuffersize); 1074 dev_alloc_skb(rtlpci->rxbuffersize);
1068 u32 bufferaddress; 1075 u32 bufferaddress;
1069 entry = &rtlpci->rx_ring[rx_queue_idx].desc[i];
1070 if (!skb) 1076 if (!skb)
1071 return 0; 1077 return 0;
1078 entry = &rtlpci->rx_ring[rx_queue_idx].desc[i];
1072 1079
1073 /*skb->dev = dev; */ 1080 /*skb->dev = dev; */
1074 1081
diff --git a/drivers/parport/share.c b/drivers/parport/share.c
index a2d9d1e59260..a848e02e6be3 100644
--- a/drivers/parport/share.c
+++ b/drivers/parport/share.c
@@ -678,7 +678,7 @@ void parport_unregister_device(struct pardevice *dev)
678 678
679 /* Make sure we haven't left any pointers around in the wait 679 /* Make sure we haven't left any pointers around in the wait
680 * list. */ 680 * list. */
681 spin_lock (&port->waitlist_lock); 681 spin_lock_irq(&port->waitlist_lock);
682 if (dev->waitprev || dev->waitnext || port->waithead == dev) { 682 if (dev->waitprev || dev->waitnext || port->waithead == dev) {
683 if (dev->waitprev) 683 if (dev->waitprev)
684 dev->waitprev->waitnext = dev->waitnext; 684 dev->waitprev->waitnext = dev->waitnext;
@@ -689,7 +689,7 @@ void parport_unregister_device(struct pardevice *dev)
689 else 689 else
690 port->waittail = dev->waitprev; 690 port->waittail = dev->waitprev;
691 } 691 }
692 spin_unlock (&port->waitlist_lock); 692 spin_unlock_irq(&port->waitlist_lock);
693 693
694 kfree(dev->state); 694 kfree(dev->state);
695 kfree(dev); 695 kfree(dev);
diff --git a/drivers/pci/pcie/Kconfig b/drivers/pci/pcie/Kconfig
index dda70981b7a6..dc29348264c6 100644
--- a/drivers/pci/pcie/Kconfig
+++ b/drivers/pci/pcie/Kconfig
@@ -31,7 +31,7 @@ source "drivers/pci/pcie/aer/Kconfig"
31# PCI Express ASPM 31# PCI Express ASPM
32# 32#
33config PCIEASPM 33config PCIEASPM
34 bool "PCI Express ASPM control" if EMBEDDED 34 bool "PCI Express ASPM control" if EXPERT
35 depends on PCI && PCIEPORTBUS 35 depends on PCI && PCIEPORTBUS
36 default y 36 default y
37 help 37 help
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index de886f3dfd39..6e318ce41136 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -69,7 +69,7 @@ comment "PC-card bridges"
69config YENTA 69config YENTA
70 tristate "CardBus yenta-compatible bridge support" 70 tristate "CardBus yenta-compatible bridge support"
71 depends on PCI 71 depends on PCI
72 select CARDBUS if !EMBEDDED 72 select CARDBUS if !EXPERT
73 select PCCARD_NONSTATIC if PCMCIA != n 73 select PCCARD_NONSTATIC if PCMCIA != n
74 ---help--- 74 ---help---
75 This option enables support for CardBus host bridges. Virtually 75 This option enables support for CardBus host bridges. Virtually
@@ -84,27 +84,27 @@ config YENTA
84 84
85config YENTA_O2 85config YENTA_O2
86 default y 86 default y
87 bool "Special initialization for O2Micro bridges" if EMBEDDED 87 bool "Special initialization for O2Micro bridges" if EXPERT
88 depends on YENTA 88 depends on YENTA
89 89
90config YENTA_RICOH 90config YENTA_RICOH
91 default y 91 default y
92 bool "Special initialization for Ricoh bridges" if EMBEDDED 92 bool "Special initialization for Ricoh bridges" if EXPERT
93 depends on YENTA 93 depends on YENTA
94 94
95config YENTA_TI 95config YENTA_TI
96 default y 96 default y
97 bool "Special initialization for TI and EnE bridges" if EMBEDDED 97 bool "Special initialization for TI and EnE bridges" if EXPERT
98 depends on YENTA 98 depends on YENTA
99 99
100config YENTA_ENE_TUNE 100config YENTA_ENE_TUNE
101 default y 101 default y
102 bool "Auto-tune EnE bridges for CB cards" if EMBEDDED 102 bool "Auto-tune EnE bridges for CB cards" if EXPERT
103 depends on YENTA_TI && CARDBUS 103 depends on YENTA_TI && CARDBUS
104 104
105config YENTA_TOSHIBA 105config YENTA_TOSHIBA
106 default y 106 default y
107 bool "Special initialization for Toshiba ToPIC bridges" if EMBEDDED 107 bool "Special initialization for Toshiba ToPIC bridges" if EXPERT
108 depends on YENTA 108 depends on YENTA
109 109
110config PD6729 110config PD6729
diff --git a/drivers/platform/x86/intel_scu_ipc.c b/drivers/platform/x86/intel_scu_ipc.c
index 1752ef006d26..a91d510a798b 100644
--- a/drivers/platform/x86/intel_scu_ipc.c
+++ b/drivers/platform/x86/intel_scu_ipc.c
@@ -26,7 +26,6 @@
26#include <linux/sfi.h> 26#include <linux/sfi.h>
27#include <asm/mrst.h> 27#include <asm/mrst.h>
28#include <asm/intel_scu_ipc.h> 28#include <asm/intel_scu_ipc.h>
29#include <asm/mrst.h>
30 29
31/* IPC defines the following message types */ 30/* IPC defines the following message types */
32#define IPCMSG_WATCHDOG_TIMER 0xF8 /* Set Kernel Watchdog Threshold */ 31#define IPCMSG_WATCHDOG_TIMER 0xF8 /* Set Kernel Watchdog Threshold */
@@ -161,7 +160,7 @@ static int pwr_reg_rdwr(u16 *addr, u8 *data, u32 count, u32 op, u32 id)
161{ 160{
162 int i, nc, bytes, d; 161 int i, nc, bytes, d;
163 u32 offset = 0; 162 u32 offset = 0;
164 u32 err = 0; 163 int err;
165 u8 cbuf[IPC_WWBUF_SIZE] = { }; 164 u8 cbuf[IPC_WWBUF_SIZE] = { };
166 u32 *wbuf = (u32 *)&cbuf; 165 u32 *wbuf = (u32 *)&cbuf;
167 166
@@ -404,7 +403,7 @@ EXPORT_SYMBOL(intel_scu_ipc_update_register);
404 */ 403 */
405int intel_scu_ipc_simple_command(int cmd, int sub) 404int intel_scu_ipc_simple_command(int cmd, int sub)
406{ 405{
407 u32 err = 0; 406 int err;
408 407
409 mutex_lock(&ipclock); 408 mutex_lock(&ipclock);
410 if (ipcdev.pdev == NULL) { 409 if (ipcdev.pdev == NULL) {
@@ -434,8 +433,7 @@ EXPORT_SYMBOL(intel_scu_ipc_simple_command);
434int intel_scu_ipc_command(int cmd, int sub, u32 *in, int inlen, 433int intel_scu_ipc_command(int cmd, int sub, u32 *in, int inlen,
435 u32 *out, int outlen) 434 u32 *out, int outlen)
436{ 435{
437 u32 err = 0; 436 int i, err;
438 int i = 0;
439 437
440 mutex_lock(&ipclock); 438 mutex_lock(&ipclock);
441 if (ipcdev.pdev == NULL) { 439 if (ipcdev.pdev == NULL) {
diff --git a/drivers/platform/x86/intel_scu_ipcutil.c b/drivers/platform/x86/intel_scu_ipcutil.c
index ba3231d0819e..b93a03259c16 100644
--- a/drivers/platform/x86/intel_scu_ipcutil.c
+++ b/drivers/platform/x86/intel_scu_ipcutil.c
@@ -128,6 +128,6 @@ static void __exit ipc_module_exit(void)
128module_init(ipc_module_init); 128module_init(ipc_module_init);
129module_exit(ipc_module_exit); 129module_exit(ipc_module_exit);
130 130
131MODULE_LICENSE("GPL V2"); 131MODULE_LICENSE("GPL v2");
132MODULE_DESCRIPTION("Utility driver for intel scu ipc"); 132MODULE_DESCRIPTION("Utility driver for intel scu ipc");
133MODULE_AUTHOR("Sreedhara <sreedhara.ds@intel.com>"); 133MODULE_AUTHOR("Sreedhara <sreedhara.ds@intel.com>");
diff --git a/drivers/pps/clients/pps-ktimer.c b/drivers/pps/clients/pps-ktimer.c
index 2728469d3884..82583b0ff82d 100644
--- a/drivers/pps/clients/pps-ktimer.c
+++ b/drivers/pps/clients/pps-ktimer.c
@@ -46,8 +46,6 @@ static void pps_ktimer_event(unsigned long ptr)
46 /* First of all we get the time stamp... */ 46 /* First of all we get the time stamp... */
47 pps_get_ts(&ts); 47 pps_get_ts(&ts);
48 48
49 dev_info(pps->dev, "PPS event at %lu\n", jiffies);
50
51 pps_event(pps, &ts, PPS_CAPTUREASSERT, NULL); 49 pps_event(pps, &ts, PPS_CAPTUREASSERT, NULL);
52 50
53 mod_timer(&ktimer, jiffies + HZ); 51 mod_timer(&ktimer, jiffies + HZ);
diff --git a/drivers/pps/clients/pps_parport.c b/drivers/pps/clients/pps_parport.c
index 32221efd9ca9..c571d6dd8f61 100644
--- a/drivers/pps/clients/pps_parport.c
+++ b/drivers/pps/clients/pps_parport.c
@@ -163,7 +163,7 @@ static void parport_attach(struct parport *port)
163 } 163 }
164 164
165 device->pardev = parport_register_device(port, KBUILD_MODNAME, 165 device->pardev = parport_register_device(port, KBUILD_MODNAME,
166 NULL, NULL, parport_irq, 0, device); 166 NULL, NULL, parport_irq, PARPORT_FLAG_EXCL, device);
167 if (!device->pardev) { 167 if (!device->pardev) {
168 pr_err("couldn't register with %s\n", port->name); 168 pr_err("couldn't register with %s\n", port->name);
169 goto err_free; 169 goto err_free;
diff --git a/drivers/pps/generators/pps_gen_parport.c b/drivers/pps/generators/pps_gen_parport.c
index 5c32f8dacf56..b93af3ebb5ba 100644
--- a/drivers/pps/generators/pps_gen_parport.c
+++ b/drivers/pps/generators/pps_gen_parport.c
@@ -198,7 +198,7 @@ static void parport_attach(struct parport *port)
198 } 198 }
199 199
200 device.pardev = parport_register_device(port, KBUILD_MODNAME, 200 device.pardev = parport_register_device(port, KBUILD_MODNAME,
201 NULL, NULL, NULL, 0, &device); 201 NULL, NULL, NULL, PARPORT_FLAG_EXCL, &device);
202 if (!device.pardev) { 202 if (!device.pardev) {
203 pr_err("couldn't register with %s\n", port->name); 203 pr_err("couldn't register with %s\n", port->name);
204 return; 204 return;
diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c
index 467e82bd0929..a50391b6ba2a 100644
--- a/drivers/rapidio/rio-scan.c
+++ b/drivers/rapidio/rio-scan.c
@@ -943,6 +943,8 @@ static int rio_enum_complete(struct rio_mport *port)
943 * @port: Master port to send transactions 943 * @port: Master port to send transactions
944 * @destid: Current destination ID in network 944 * @destid: Current destination ID in network
945 * @hopcount: Number of hops into the network 945 * @hopcount: Number of hops into the network
946 * @prev: previous rio_dev
947 * @prev_port: previous port number
946 * 948 *
947 * Recursively discovers a RIO network. Transactions are sent via the 949 * Recursively discovers a RIO network. Transactions are sent via the
948 * master port passed in @port. 950 * master port passed in @port.
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 4941cade319f..cdd97192dc69 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -97,18 +97,6 @@ config RTC_INTF_DEV
97 97
98 If unsure, say Y. 98 If unsure, say Y.
99 99
100config RTC_INTF_DEV_UIE_EMUL
101 bool "RTC UIE emulation on dev interface"
102 depends on RTC_INTF_DEV
103 help
104 Provides an emulation for RTC_UIE if the underlying rtc chip
105 driver does not expose RTC_UIE ioctls. Those requests generate
106 once-per-second update interrupts, used for synchronization.
107
108 The emulation code will read the time from the hardware
109 clock several times per second, please enable this option
110 only if you know that you really need it.
111
112config RTC_DRV_TEST 100config RTC_DRV_TEST
113 tristate "Test driver/device" 101 tristate "Test driver/device"
114 help 102 help
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index 90384b9f6b2c..925006d33109 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -16,6 +16,9 @@
16#include <linux/log2.h> 16#include <linux/log2.h>
17#include <linux/workqueue.h> 17#include <linux/workqueue.h>
18 18
19static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer);
20static void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer);
21
19static int __rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm) 22static int __rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm)
20{ 23{
21 int err; 24 int err;
@@ -120,12 +123,18 @@ int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
120 err = mutex_lock_interruptible(&rtc->ops_lock); 123 err = mutex_lock_interruptible(&rtc->ops_lock);
121 if (err) 124 if (err)
122 return err; 125 return err;
123 alarm->enabled = rtc->aie_timer.enabled; 126 if (rtc->ops == NULL)
124 if (alarm->enabled) 127 err = -ENODEV;
128 else if (!rtc->ops->read_alarm)
129 err = -EINVAL;
130 else {
131 memset(alarm, 0, sizeof(struct rtc_wkalrm));
132 alarm->enabled = rtc->aie_timer.enabled;
125 alarm->time = rtc_ktime_to_tm(rtc->aie_timer.node.expires); 133 alarm->time = rtc_ktime_to_tm(rtc->aie_timer.node.expires);
134 }
126 mutex_unlock(&rtc->ops_lock); 135 mutex_unlock(&rtc->ops_lock);
127 136
128 return 0; 137 return err;
129} 138}
130EXPORT_SYMBOL_GPL(rtc_read_alarm); 139EXPORT_SYMBOL_GPL(rtc_read_alarm);
131 140
@@ -175,16 +184,14 @@ int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
175 return err; 184 return err;
176 if (rtc->aie_timer.enabled) { 185 if (rtc->aie_timer.enabled) {
177 rtc_timer_remove(rtc, &rtc->aie_timer); 186 rtc_timer_remove(rtc, &rtc->aie_timer);
178 rtc->aie_timer.enabled = 0;
179 } 187 }
180 rtc->aie_timer.node.expires = rtc_tm_to_ktime(alarm->time); 188 rtc->aie_timer.node.expires = rtc_tm_to_ktime(alarm->time);
181 rtc->aie_timer.period = ktime_set(0, 0); 189 rtc->aie_timer.period = ktime_set(0, 0);
182 if (alarm->enabled) { 190 if (alarm->enabled) {
183 rtc->aie_timer.enabled = 1; 191 err = rtc_timer_enqueue(rtc, &rtc->aie_timer);
184 rtc_timer_enqueue(rtc, &rtc->aie_timer);
185 } 192 }
186 mutex_unlock(&rtc->ops_lock); 193 mutex_unlock(&rtc->ops_lock);
187 return 0; 194 return err;
188} 195}
189EXPORT_SYMBOL_GPL(rtc_set_alarm); 196EXPORT_SYMBOL_GPL(rtc_set_alarm);
190 197
@@ -195,15 +202,15 @@ int rtc_alarm_irq_enable(struct rtc_device *rtc, unsigned int enabled)
195 return err; 202 return err;
196 203
197 if (rtc->aie_timer.enabled != enabled) { 204 if (rtc->aie_timer.enabled != enabled) {
198 if (enabled) { 205 if (enabled)
199 rtc->aie_timer.enabled = 1; 206 err = rtc_timer_enqueue(rtc, &rtc->aie_timer);
200 rtc_timer_enqueue(rtc, &rtc->aie_timer); 207 else
201 } else {
202 rtc_timer_remove(rtc, &rtc->aie_timer); 208 rtc_timer_remove(rtc, &rtc->aie_timer);
203 rtc->aie_timer.enabled = 0;
204 }
205 } 209 }
206 210
211 if (err)
212 return err;
213
207 if (!rtc->ops) 214 if (!rtc->ops)
208 err = -ENODEV; 215 err = -ENODEV;
209 else if (!rtc->ops->alarm_irq_enable) 216 else if (!rtc->ops->alarm_irq_enable)
@@ -235,12 +242,9 @@ int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled)
235 now = rtc_tm_to_ktime(tm); 242 now = rtc_tm_to_ktime(tm);
236 rtc->uie_rtctimer.node.expires = ktime_add(now, onesec); 243 rtc->uie_rtctimer.node.expires = ktime_add(now, onesec);
237 rtc->uie_rtctimer.period = ktime_set(1, 0); 244 rtc->uie_rtctimer.period = ktime_set(1, 0);
238 rtc->uie_rtctimer.enabled = 1; 245 err = rtc_timer_enqueue(rtc, &rtc->uie_rtctimer);
239 rtc_timer_enqueue(rtc, &rtc->uie_rtctimer); 246 } else
240 } else {
241 rtc_timer_remove(rtc, &rtc->uie_rtctimer); 247 rtc_timer_remove(rtc, &rtc->uie_rtctimer);
242 rtc->uie_rtctimer.enabled = 0;
243 }
244 248
245out: 249out:
246 mutex_unlock(&rtc->ops_lock); 250 mutex_unlock(&rtc->ops_lock);
@@ -488,10 +492,13 @@ EXPORT_SYMBOL_GPL(rtc_irq_set_freq);
488 * Enqueues a timer onto the rtc devices timerqueue and sets 492 * Enqueues a timer onto the rtc devices timerqueue and sets
489 * the next alarm event appropriately. 493 * the next alarm event appropriately.
490 * 494 *
495 * Sets the enabled bit on the added timer.
496 *
491 * Must hold ops_lock for proper serialization of timerqueue 497 * Must hold ops_lock for proper serialization of timerqueue
492 */ 498 */
493void rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer) 499static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer)
494{ 500{
501 timer->enabled = 1;
495 timerqueue_add(&rtc->timerqueue, &timer->node); 502 timerqueue_add(&rtc->timerqueue, &timer->node);
496 if (&timer->node == timerqueue_getnext(&rtc->timerqueue)) { 503 if (&timer->node == timerqueue_getnext(&rtc->timerqueue)) {
497 struct rtc_wkalrm alarm; 504 struct rtc_wkalrm alarm;
@@ -501,7 +508,13 @@ void rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer)
501 err = __rtc_set_alarm(rtc, &alarm); 508 err = __rtc_set_alarm(rtc, &alarm);
502 if (err == -ETIME) 509 if (err == -ETIME)
503 schedule_work(&rtc->irqwork); 510 schedule_work(&rtc->irqwork);
511 else if (err) {
512 timerqueue_del(&rtc->timerqueue, &timer->node);
513 timer->enabled = 0;
514 return err;
515 }
504 } 516 }
517 return 0;
505} 518}
506 519
507/** 520/**
@@ -512,13 +525,15 @@ void rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer)
512 * Removes a timer onto the rtc devices timerqueue and sets 525 * Removes a timer onto the rtc devices timerqueue and sets
513 * the next alarm event appropriately. 526 * the next alarm event appropriately.
514 * 527 *
528 * Clears the enabled bit on the removed timer.
529 *
515 * Must hold ops_lock for proper serialization of timerqueue 530 * Must hold ops_lock for proper serialization of timerqueue
516 */ 531 */
517void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer) 532static void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer)
518{ 533{
519 struct timerqueue_node *next = timerqueue_getnext(&rtc->timerqueue); 534 struct timerqueue_node *next = timerqueue_getnext(&rtc->timerqueue);
520 timerqueue_del(&rtc->timerqueue, &timer->node); 535 timerqueue_del(&rtc->timerqueue, &timer->node);
521 536 timer->enabled = 0;
522 if (next == &timer->node) { 537 if (next == &timer->node) {
523 struct rtc_wkalrm alarm; 538 struct rtc_wkalrm alarm;
524 int err; 539 int err;
@@ -626,8 +641,7 @@ int rtc_timer_start(struct rtc_device *rtc, struct rtc_timer* timer,
626 timer->node.expires = expires; 641 timer->node.expires = expires;
627 timer->period = period; 642 timer->period = period;
628 643
629 timer->enabled = 1; 644 ret = rtc_timer_enqueue(rtc, timer);
630 rtc_timer_enqueue(rtc, timer);
631 645
632 mutex_unlock(&rtc->ops_lock); 646 mutex_unlock(&rtc->ops_lock);
633 return ret; 647 return ret;
@@ -645,7 +659,6 @@ int rtc_timer_cancel(struct rtc_device *rtc, struct rtc_timer* timer)
645 mutex_lock(&rtc->ops_lock); 659 mutex_lock(&rtc->ops_lock);
646 if (timer->enabled) 660 if (timer->enabled)
647 rtc_timer_remove(rtc, timer); 661 rtc_timer_remove(rtc, timer);
648 timer->enabled = 0;
649 mutex_unlock(&rtc->ops_lock); 662 mutex_unlock(&rtc->ops_lock);
650 return ret; 663 return ret;
651} 664}
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
index 7a7a1b664781..2ac8f6aff5a4 100644
--- a/drivers/s390/net/qeth_l2_main.c
+++ b/drivers/s390/net/qeth_l2_main.c
@@ -831,12 +831,14 @@ tx_drop:
831 return NETDEV_TX_OK; 831 return NETDEV_TX_OK;
832} 832}
833 833
834static int qeth_l2_open(struct net_device *dev) 834static int __qeth_l2_open(struct net_device *dev)
835{ 835{
836 struct qeth_card *card = dev->ml_priv; 836 struct qeth_card *card = dev->ml_priv;
837 int rc = 0; 837 int rc = 0;
838 838
839 QETH_CARD_TEXT(card, 4, "qethopen"); 839 QETH_CARD_TEXT(card, 4, "qethopen");
840 if (card->state == CARD_STATE_UP)
841 return rc;
840 if (card->state != CARD_STATE_SOFTSETUP) 842 if (card->state != CARD_STATE_SOFTSETUP)
841 return -ENODEV; 843 return -ENODEV;
842 844
@@ -857,6 +859,18 @@ static int qeth_l2_open(struct net_device *dev)
857 return rc; 859 return rc;
858} 860}
859 861
862static int qeth_l2_open(struct net_device *dev)
863{
864 struct qeth_card *card = dev->ml_priv;
865
866 QETH_CARD_TEXT(card, 5, "qethope_");
867 if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) {
868 QETH_CARD_TEXT(card, 3, "openREC");
869 return -ERESTARTSYS;
870 }
871 return __qeth_l2_open(dev);
872}
873
860static int qeth_l2_stop(struct net_device *dev) 874static int qeth_l2_stop(struct net_device *dev)
861{ 875{
862 struct qeth_card *card = dev->ml_priv; 876 struct qeth_card *card = dev->ml_priv;
@@ -1046,7 +1060,7 @@ contin:
1046 if (recover_flag == CARD_STATE_RECOVER) { 1060 if (recover_flag == CARD_STATE_RECOVER) {
1047 if (recovery_mode && 1061 if (recovery_mode &&
1048 card->info.type != QETH_CARD_TYPE_OSN) { 1062 card->info.type != QETH_CARD_TYPE_OSN) {
1049 qeth_l2_open(card->dev); 1063 __qeth_l2_open(card->dev);
1050 } else { 1064 } else {
1051 rtnl_lock(); 1065 rtnl_lock();
1052 dev_open(card->dev); 1066 dev_open(card->dev);
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index e227e465bfc4..d09b0c44fc3d 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -2998,7 +2998,9 @@ static inline void qeth_l3_hdr_csum(struct qeth_card *card,
2998 */ 2998 */
2999 if (iph->protocol == IPPROTO_UDP) 2999 if (iph->protocol == IPPROTO_UDP)
3000 hdr->hdr.l3.ext_flags |= QETH_HDR_EXT_UDP; 3000 hdr->hdr.l3.ext_flags |= QETH_HDR_EXT_UDP;
3001 hdr->hdr.l3.ext_flags |= QETH_HDR_EXT_CSUM_TRANSP_REQ; 3001 hdr->hdr.l3.ext_flags |= QETH_HDR_EXT_CSUM_TRANSP_REQ |
3002 QETH_HDR_EXT_CSUM_HDR_REQ;
3003 iph->check = 0;
3002 if (card->options.performance_stats) 3004 if (card->options.performance_stats)
3003 card->perf_stats.tx_csum++; 3005 card->perf_stats.tx_csum++;
3004} 3006}
@@ -3240,12 +3242,14 @@ tx_drop:
3240 return NETDEV_TX_OK; 3242 return NETDEV_TX_OK;
3241} 3243}
3242 3244
3243static int qeth_l3_open(struct net_device *dev) 3245static int __qeth_l3_open(struct net_device *dev)
3244{ 3246{
3245 struct qeth_card *card = dev->ml_priv; 3247 struct qeth_card *card = dev->ml_priv;
3246 int rc = 0; 3248 int rc = 0;
3247 3249
3248 QETH_CARD_TEXT(card, 4, "qethopen"); 3250 QETH_CARD_TEXT(card, 4, "qethopen");
3251 if (card->state == CARD_STATE_UP)
3252 return rc;
3249 if (card->state != CARD_STATE_SOFTSETUP) 3253 if (card->state != CARD_STATE_SOFTSETUP)
3250 return -ENODEV; 3254 return -ENODEV;
3251 card->data.state = CH_STATE_UP; 3255 card->data.state = CH_STATE_UP;
@@ -3260,6 +3264,18 @@ static int qeth_l3_open(struct net_device *dev)
3260 return rc; 3264 return rc;
3261} 3265}
3262 3266
3267static int qeth_l3_open(struct net_device *dev)
3268{
3269 struct qeth_card *card = dev->ml_priv;
3270
3271 QETH_CARD_TEXT(card, 5, "qethope_");
3272 if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) {
3273 QETH_CARD_TEXT(card, 3, "openREC");
3274 return -ERESTARTSYS;
3275 }
3276 return __qeth_l3_open(dev);
3277}
3278
3263static int qeth_l3_stop(struct net_device *dev) 3279static int qeth_l3_stop(struct net_device *dev)
3264{ 3280{
3265 struct qeth_card *card = dev->ml_priv; 3281 struct qeth_card *card = dev->ml_priv;
@@ -3564,7 +3580,7 @@ contin:
3564 netif_carrier_off(card->dev); 3580 netif_carrier_off(card->dev);
3565 if (recover_flag == CARD_STATE_RECOVER) { 3581 if (recover_flag == CARD_STATE_RECOVER) {
3566 if (recovery_mode) 3582 if (recovery_mode)
3567 qeth_l3_open(card->dev); 3583 __qeth_l3_open(card->dev);
3568 else { 3584 else {
3569 rtnl_lock(); 3585 rtnl_lock();
3570 dev_open(card->dev); 3586 dev_open(card->dev);
diff --git a/drivers/sh/intc/chip.c b/drivers/sh/intc/chip.c
index de885a0f917a..f33e2dd97934 100644
--- a/drivers/sh/intc/chip.c
+++ b/drivers/sh/intc/chip.c
@@ -173,7 +173,8 @@ int intc_set_priority(unsigned int irq, unsigned int prio)
173 return 0; 173 return 0;
174} 174}
175 175
176#define VALID(x) (x | 0x80) 176#define SENSE_VALID_FLAG 0x80
177#define VALID(x) (x | SENSE_VALID_FLAG)
177 178
178static unsigned char intc_irq_sense_table[IRQ_TYPE_SENSE_MASK + 1] = { 179static unsigned char intc_irq_sense_table[IRQ_TYPE_SENSE_MASK + 1] = {
179 [IRQ_TYPE_EDGE_FALLING] = VALID(0), 180 [IRQ_TYPE_EDGE_FALLING] = VALID(0),
@@ -201,7 +202,8 @@ static int intc_set_type(struct irq_data *data, unsigned int type)
201 ihp = intc_find_irq(d->sense, d->nr_sense, irq); 202 ihp = intc_find_irq(d->sense, d->nr_sense, irq);
202 if (ihp) { 203 if (ihp) {
203 addr = INTC_REG(d, _INTC_ADDR_E(ihp->handle), 0); 204 addr = INTC_REG(d, _INTC_ADDR_E(ihp->handle), 0);
204 intc_reg_fns[_INTC_FN(ihp->handle)](addr, ihp->handle, value); 205 intc_reg_fns[_INTC_FN(ihp->handle)](addr, ihp->handle,
206 value & ~SENSE_VALID_FLAG);
205 } 207 }
206 208
207 return 0; 209 return 0;
diff --git a/drivers/ssb/Kconfig b/drivers/ssb/Kconfig
index 2d8cc455dbc7..42cdaa9a4d8a 100644
--- a/drivers/ssb/Kconfig
+++ b/drivers/ssb/Kconfig
@@ -82,7 +82,7 @@ config SSB_SDIOHOST
82 82
83config SSB_SILENT 83config SSB_SILENT
84 bool "No SSB kernel messages" 84 bool "No SSB kernel messages"
85 depends on SSB && EMBEDDED 85 depends on SSB && EXPERT
86 help 86 help
87 This option turns off all Sonics Silicon Backplane printks. 87 This option turns off all Sonics Silicon Backplane printks.
88 Note that you won't be able to identify problems, once 88 Note that you won't be able to identify problems, once
diff --git a/drivers/staging/ath6kl/miscdrv/ar3kps/ar3kpsconfig.c b/drivers/staging/ath6kl/miscdrv/ar3kps/ar3kpsconfig.c
index 0e298dba9fc8..29b8ab44ea47 100644
--- a/drivers/staging/ath6kl/miscdrv/ar3kps/ar3kpsconfig.c
+++ b/drivers/staging/ath6kl/miscdrv/ar3kps/ar3kpsconfig.c
@@ -360,8 +360,8 @@ int PSSendOps(void *arg)
360 status = 1; 360 status = 1;
361 goto complete; 361 goto complete;
362 } 362 }
363 len = (firmware->size > MAX_BDADDR_FORMAT_LENGTH)? MAX_BDADDR_FORMAT_LENGTH: firmware->size; 363 len = min(firmware->size, MAX_BDADDR_FORMAT_LENGTH - 1);
364 memcpy(config_bdaddr, firmware->data,len); 364 memcpy(config_bdaddr, firmware->data, len);
365 config_bdaddr[len] = '\0'; 365 config_bdaddr[len] = '\0';
366 write_bdaddr(hdev,config_bdaddr,BDADDR_TYPE_STRING); 366 write_bdaddr(hdev,config_bdaddr,BDADDR_TYPE_STRING);
367 A_RELEASE_FIRMWARE(firmware); 367 A_RELEASE_FIRMWARE(firmware);
diff --git a/drivers/staging/brcm80211/sys/wl_mac80211.c b/drivers/staging/brcm80211/sys/wl_mac80211.c
index bdd629d72a75..f1235884cc5d 100644
--- a/drivers/staging/brcm80211/sys/wl_mac80211.c
+++ b/drivers/staging/brcm80211/sys/wl_mac80211.c
@@ -209,11 +209,8 @@ static void wl_ops_stop(struct ieee80211_hw *hw)
209 struct wl_info *wl = hw->priv; 209 struct wl_info *wl = hw->priv;
210 ASSERT(wl); 210 ASSERT(wl);
211 WL_LOCK(wl); 211 WL_LOCK(wl);
212 wl_down(wl);
213 ieee80211_stop_queues(hw); 212 ieee80211_stop_queues(hw);
214 WL_UNLOCK(wl); 213 WL_UNLOCK(wl);
215
216 return;
217} 214}
218 215
219static int 216static int
@@ -246,7 +243,14 @@ wl_ops_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
246static void 243static void
247wl_ops_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) 244wl_ops_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
248{ 245{
249 return; 246 struct wl_info *wl;
247
248 wl = HW_TO_WL(hw);
249
250 /* put driver in down state */
251 WL_LOCK(wl);
252 wl_down(wl);
253 WL_UNLOCK(wl);
250} 254}
251 255
252static int 256static int
@@ -779,7 +783,7 @@ static struct wl_info *wl_attach(u16 vendor, u16 device, unsigned long regs,
779 wl_found++; 783 wl_found++;
780 return wl; 784 return wl;
781 785
782 fail: 786fail:
783 wl_free(wl); 787 wl_free(wl);
784fail1: 788fail1:
785 return NULL; 789 return NULL;
@@ -1090,7 +1094,6 @@ wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1090 return 0; 1094 return 0;
1091} 1095}
1092 1096
1093#ifdef LINUXSTA_PS
1094static int wl_suspend(struct pci_dev *pdev, pm_message_t state) 1097static int wl_suspend(struct pci_dev *pdev, pm_message_t state)
1095{ 1098{
1096 struct wl_info *wl; 1099 struct wl_info *wl;
@@ -1105,11 +1108,12 @@ static int wl_suspend(struct pci_dev *pdev, pm_message_t state)
1105 return -ENODEV; 1108 return -ENODEV;
1106 } 1109 }
1107 1110
1111 /* only need to flag hw is down for proper resume */
1108 WL_LOCK(wl); 1112 WL_LOCK(wl);
1109 wl_down(wl);
1110 wl->pub->hw_up = false; 1113 wl->pub->hw_up = false;
1111 WL_UNLOCK(wl); 1114 WL_UNLOCK(wl);
1112 pci_save_state(pdev, wl->pci_psstate); 1115
1116 pci_save_state(pdev);
1113 pci_disable_device(pdev); 1117 pci_disable_device(pdev);
1114 return pci_set_power_state(pdev, PCI_D3hot); 1118 return pci_set_power_state(pdev, PCI_D3hot);
1115} 1119}
@@ -1133,7 +1137,7 @@ static int wl_resume(struct pci_dev *pdev)
1133 if (err) 1137 if (err)
1134 return err; 1138 return err;
1135 1139
1136 pci_restore_state(pdev, wl->pci_psstate); 1140 pci_restore_state(pdev);
1137 1141
1138 err = pci_enable_device(pdev); 1142 err = pci_enable_device(pdev);
1139 if (err) 1143 if (err)
@@ -1145,13 +1149,12 @@ static int wl_resume(struct pci_dev *pdev)
1145 if ((val & 0x0000ff00) != 0) 1149 if ((val & 0x0000ff00) != 0)
1146 pci_write_config_dword(pdev, 0x40, val & 0xffff00ff); 1150 pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
1147 1151
1148 WL_LOCK(wl); 1152 /*
1149 err = wl_up(wl); 1153 * done. driver will be put in up state
1150 WL_UNLOCK(wl); 1154 * in wl_ops_add_interface() call.
1151 1155 */
1152 return err; 1156 return err;
1153} 1157}
1154#endif /* LINUXSTA_PS */
1155 1158
1156static void wl_remove(struct pci_dev *pdev) 1159static void wl_remove(struct pci_dev *pdev)
1157{ 1160{
@@ -1184,14 +1187,12 @@ static void wl_remove(struct pci_dev *pdev)
1184} 1187}
1185 1188
1186static struct pci_driver wl_pci_driver = { 1189static struct pci_driver wl_pci_driver = {
1187 .name = "brcm80211", 1190 .name = "brcm80211",
1188 .probe = wl_pci_probe, 1191 .probe = wl_pci_probe,
1189#ifdef LINUXSTA_PS 1192 .suspend = wl_suspend,
1190 .suspend = wl_suspend, 1193 .resume = wl_resume,
1191 .resume = wl_resume, 1194 .remove = __devexit_p(wl_remove),
1192#endif /* LINUXSTA_PS */ 1195 .id_table = wl_id_table,
1193 .remove = __devexit_p(wl_remove),
1194 .id_table = wl_id_table,
1195}; 1196};
1196 1197
1197/** 1198/**
diff --git a/drivers/staging/brcm80211/sys/wlc_mac80211.c b/drivers/staging/brcm80211/sys/wlc_mac80211.c
index 1d5d01ac0a9b..a1303863686c 100644
--- a/drivers/staging/brcm80211/sys/wlc_mac80211.c
+++ b/drivers/staging/brcm80211/sys/wlc_mac80211.c
@@ -5126,7 +5126,6 @@ wlc_sendpkt_mac80211(struct wlc_info *wlc, struct sk_buff *sdu,
5126 fifo = prio2fifo[prio]; 5126 fifo = prio2fifo[prio];
5127 5127
5128 ASSERT((uint) skb_headroom(sdu) >= TXOFF); 5128 ASSERT((uint) skb_headroom(sdu) >= TXOFF);
5129 ASSERT(!(sdu->cloned));
5130 ASSERT(!(sdu->next)); 5129 ASSERT(!(sdu->next));
5131 ASSERT(!(sdu->prev)); 5130 ASSERT(!(sdu->prev));
5132 ASSERT(fifo < NFIFO); 5131 ASSERT(fifo < NFIFO);
diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c
index 4d1868d04bac..0728c3c0cb0e 100644
--- a/drivers/staging/comedi/drivers/ni_labpc.c
+++ b/drivers/staging/comedi/drivers/ni_labpc.c
@@ -575,7 +575,8 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase,
575 /* grab our IRQ */ 575 /* grab our IRQ */
576 if (irq) { 576 if (irq) {
577 isr_flags = 0; 577 isr_flags = 0;
578 if (thisboard->bustype == pci_bustype) 578 if (thisboard->bustype == pci_bustype
579 || thisboard->bustype == pcmcia_bustype)
579 isr_flags |= IRQF_SHARED; 580 isr_flags |= IRQF_SHARED;
580 if (request_irq(irq, labpc_interrupt, isr_flags, 581 if (request_irq(irq, labpc_interrupt, isr_flags,
581 driver_labpc.driver_name, dev)) { 582 driver_labpc.driver_name, dev)) {
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index b3d05fcfe6d2..4fb809485d9e 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -368,6 +368,7 @@ static int blkvsc_probe(struct device *device)
368 blkdev->gd->first_minor = 0; 368 blkdev->gd->first_minor = 0;
369 blkdev->gd->fops = &block_ops; 369 blkdev->gd->fops = &block_ops;
370 blkdev->gd->private_data = blkdev; 370 blkdev->gd->private_data = blkdev;
371 blkdev->gd->driverfs_dev = &(blkdev->device_ctx->device);
371 sprintf(blkdev->gd->disk_name, "hd%c", 'a' + devnum); 372 sprintf(blkdev->gd->disk_name, "hd%c", 'a' + devnum);
372 373
373 blkvsc_do_inquiry(blkdev); 374 blkvsc_do_inquiry(blkdev);
diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
index df9cd131e953..0edbe7483a4c 100644
--- a/drivers/staging/hv/netvsc.c
+++ b/drivers/staging/hv/netvsc.c
@@ -1279,7 +1279,7 @@ static void netvsc_channel_cb(void *context)
1279 /* ASSERT(device); */ 1279 /* ASSERT(device); */
1280 1280
1281 packet = kzalloc(NETVSC_PACKET_SIZE * sizeof(unsigned char), 1281 packet = kzalloc(NETVSC_PACKET_SIZE * sizeof(unsigned char),
1282 GFP_KERNEL); 1282 GFP_ATOMIC);
1283 if (!packet) 1283 if (!packet)
1284 return; 1284 return;
1285 buffer = packet; 1285 buffer = packet;
diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index 0147b407512c..54706a16dc0a 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -358,7 +358,6 @@ static int netvsc_probe(struct device *device)
358 358
359 /* Set initial state */ 359 /* Set initial state */
360 netif_carrier_off(net); 360 netif_carrier_off(net);
361 netif_stop_queue(net);
362 361
363 net_device_ctx = netdev_priv(net); 362 net_device_ctx = netdev_priv(net);
364 net_device_ctx->device_ctx = device_ctx; 363 net_device_ctx->device_ctx = device_ctx;
diff --git a/drivers/staging/iio/adc/ad7476_core.c b/drivers/staging/iio/adc/ad7476_core.c
index deb68c8a6e18..b8b54da67c63 100644
--- a/drivers/staging/iio/adc/ad7476_core.c
+++ b/drivers/staging/iio/adc/ad7476_core.c
@@ -68,7 +68,7 @@ static ssize_t ad7476_show_scale(struct device *dev,
68 /* Corresponds to Vref / 2^(bits) */ 68 /* Corresponds to Vref / 2^(bits) */
69 unsigned int scale_uv = (st->int_vref_mv * 1000) >> st->chip_info->bits; 69 unsigned int scale_uv = (st->int_vref_mv * 1000) >> st->chip_info->bits;
70 70
71 return sprintf(buf, "%d.%d\n", scale_uv / 1000, scale_uv % 1000); 71 return sprintf(buf, "%d.%03d\n", scale_uv / 1000, scale_uv % 1000);
72} 72}
73static IIO_DEVICE_ATTR(in_scale, S_IRUGO, ad7476_show_scale, NULL, 0); 73static IIO_DEVICE_ATTR(in_scale, S_IRUGO, ad7476_show_scale, NULL, 0);
74 74
diff --git a/drivers/staging/iio/adc/ad7887_core.c b/drivers/staging/iio/adc/ad7887_core.c
index 685908995d49..5d85efab658c 100644
--- a/drivers/staging/iio/adc/ad7887_core.c
+++ b/drivers/staging/iio/adc/ad7887_core.c
@@ -68,7 +68,7 @@ static ssize_t ad7887_show_scale(struct device *dev,
68 /* Corresponds to Vref / 2^(bits) */ 68 /* Corresponds to Vref / 2^(bits) */
69 unsigned int scale_uv = (st->int_vref_mv * 1000) >> st->chip_info->bits; 69 unsigned int scale_uv = (st->int_vref_mv * 1000) >> st->chip_info->bits;
70 70
71 return sprintf(buf, "%d.%d\n", scale_uv / 1000, scale_uv % 1000); 71 return sprintf(buf, "%d.%03d\n", scale_uv / 1000, scale_uv % 1000);
72} 72}
73static IIO_DEVICE_ATTR(in_scale, S_IRUGO, ad7887_show_scale, NULL, 0); 73static IIO_DEVICE_ATTR(in_scale, S_IRUGO, ad7887_show_scale, NULL, 0);
74 74
diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c
index 6309d521a864..89ccf375a188 100644
--- a/drivers/staging/iio/adc/ad799x_core.c
+++ b/drivers/staging/iio/adc/ad799x_core.c
@@ -432,7 +432,7 @@ static ssize_t ad799x_show_scale(struct device *dev,
432 /* Corresponds to Vref / 2^(bits) */ 432 /* Corresponds to Vref / 2^(bits) */
433 unsigned int scale_uv = (st->int_vref_mv * 1000) >> st->chip_info->bits; 433 unsigned int scale_uv = (st->int_vref_mv * 1000) >> st->chip_info->bits;
434 434
435 return sprintf(buf, "%d.%d\n", scale_uv / 1000, scale_uv % 1000); 435 return sprintf(buf, "%d.%03d\n", scale_uv / 1000, scale_uv % 1000);
436} 436}
437 437
438static IIO_DEVICE_ATTR(in_scale, S_IRUGO, ad799x_show_scale, NULL, 0); 438static IIO_DEVICE_ATTR(in_scale, S_IRUGO, ad799x_show_scale, NULL, 0);
diff --git a/drivers/staging/iio/dac/ad5446.c b/drivers/staging/iio/dac/ad5446.c
index e3387cd31145..0f87ecac82fc 100644
--- a/drivers/staging/iio/dac/ad5446.c
+++ b/drivers/staging/iio/dac/ad5446.c
@@ -87,7 +87,7 @@ static ssize_t ad5446_show_scale(struct device *dev,
87 /* Corresponds to Vref / 2^(bits) */ 87 /* Corresponds to Vref / 2^(bits) */
88 unsigned int scale_uv = (st->vref_mv * 1000) >> st->chip_info->bits; 88 unsigned int scale_uv = (st->vref_mv * 1000) >> st->chip_info->bits;
89 89
90 return sprintf(buf, "%d.%d\n", scale_uv / 1000, scale_uv % 1000); 90 return sprintf(buf, "%d.%03d\n", scale_uv / 1000, scale_uv % 1000);
91} 91}
92static IIO_DEVICE_ATTR(out_scale, S_IRUGO, ad5446_show_scale, NULL, 0); 92static IIO_DEVICE_ATTR(out_scale, S_IRUGO, ad5446_show_scale, NULL, 0);
93 93
diff --git a/drivers/staging/lirc/TODO.lirc_zilog b/drivers/staging/lirc/TODO.lirc_zilog
index 6aa312df4018..2d0263f07937 100644
--- a/drivers/staging/lirc/TODO.lirc_zilog
+++ b/drivers/staging/lirc/TODO.lirc_zilog
@@ -1,13 +1,37 @@
1The binding between hdpvr and lirc_zilog is currently disabled, 11. Both ir-kbd-i2c and lirc_zilog provide support for RX events.
2The 'tx_only' lirc_zilog module parameter will allow ir-kbd-i2c
3and lirc_zilog to coexist in the kernel, if the user requires such a set-up.
4However the IR unit will not work well without coordination between the
5two modules. A shared mutex, for transceiver access locking, needs to be
6supplied by bridge drivers, in struct IR_i2_init_data, to both ir-kbd-i2c
7and lirc_zilog, before they will coexist usefully. This should be fixed
8before moving out of staging.
9
102. References and locking need careful examination. For cx18 and ivtv PCI
11cards, which are not easily "hot unplugged", the imperfect state of reference
12counting and locking is acceptable if not correct. For USB connected units
13like HD PVR, PVR USB2, HVR-1900, and HVR1950, the likelyhood of an Ooops on
14unplug is probably great. Proper reference counting and locking needs to be
15implemented before this module is moved out of staging.
16
173. The binding between hdpvr and lirc_zilog is currently disabled,
2due to an OOPS reported a few years ago when both the hdpvr and cx18 18due to an OOPS reported a few years ago when both the hdpvr and cx18
3drivers were loaded in his system. More details can be seen at: 19drivers were loaded in his system. More details can be seen at:
4 http://www.mail-archive.com/linux-media@vger.kernel.org/msg09163.html 20 http://www.mail-archive.com/linux-media@vger.kernel.org/msg09163.html
5More tests need to be done, in order to fix the reported issue. 21More tests need to be done, in order to fix the reported issue.
6 22
7There's a conflict between ir-kbd-i2c: Both provide support for RX events. 234. In addition to providing a shared mutex for transceiver access
8Such conflict needs to be fixed, before moving it out of staging. 24locking, bridge drivers, if able, should provide a chip reset() callback
25to lirc_zilog via struct IR_i2c_init_data. cx18 and ivtv already have routines
26to perform Z8 chip resets via GPIO manipulations. This will allow lirc_zilog
27to bring the chip back to normal when it hangs, in the same places the
28original lirc_pvr150 driver code does. This is not strictly needed, so it
29is not required to move lirc_zilog out of staging.
30
315. Both lirc_zilog and ir-kbd-i2c support the Zilog Z8 for IR, as programmed
32and installed on Hauppauge products. When working on either module, developers
33must consider at least the following bridge drivers which mention an IR Rx unit
34at address 0x71 (indicative of a Z8):
9 35
10The way I2C probe works, it will try to register the driver twice, one 36 ivtv cx18 hdpvr pvrusb2 bt8xx cx88 saa7134
11for RX and another for TX. The logic needs to be fixed to avoid such
12issue.
13 37
diff --git a/drivers/staging/lirc/lirc_imon.c b/drivers/staging/lirc/lirc_imon.c
index 0da6b9518af9..235cab0eb087 100644
--- a/drivers/staging/lirc/lirc_imon.c
+++ b/drivers/staging/lirc/lirc_imon.c
@@ -447,6 +447,7 @@ static ssize_t vfd_write(struct file *file, const char *buf,
447 447
448exit: 448exit:
449 mutex_unlock(&context->ctx_lock); 449 mutex_unlock(&context->ctx_lock);
450 kfree(data_buf);
450 451
451 return (!retval) ? n_bytes : retval; 452 return (!retval) ? n_bytes : retval;
452} 453}
diff --git a/drivers/staging/lirc/lirc_it87.c b/drivers/staging/lirc/lirc_it87.c
index 929ae5795467..5938616f3e8f 100644
--- a/drivers/staging/lirc/lirc_it87.c
+++ b/drivers/staging/lirc/lirc_it87.c
@@ -232,6 +232,7 @@ static ssize_t lirc_write(struct file *file, const char *buf,
232 i++; 232 i++;
233 } 233 }
234 terminate_send(tx_buf[i - 1]); 234 terminate_send(tx_buf[i - 1]);
235 kfree(tx_buf);
235 return n; 236 return n;
236} 237}
237 238
diff --git a/drivers/staging/lirc/lirc_parallel.c b/drivers/staging/lirc/lirc_parallel.c
index dfd2c447e67d..3a9c09881b2b 100644
--- a/drivers/staging/lirc/lirc_parallel.c
+++ b/drivers/staging/lirc/lirc_parallel.c
@@ -376,6 +376,7 @@ static ssize_t lirc_write(struct file *filep, const char *buf, size_t n,
376 unsigned long flags; 376 unsigned long flags;
377 int counttimer; 377 int counttimer;
378 int *wbuf; 378 int *wbuf;
379 ssize_t ret;
379 380
380 if (!is_claimed) 381 if (!is_claimed)
381 return -EBUSY; 382 return -EBUSY;
@@ -393,8 +394,10 @@ static ssize_t lirc_write(struct file *filep, const char *buf, size_t n,
393 if (timer == 0) { 394 if (timer == 0) {
394 /* try again if device is ready */ 395 /* try again if device is ready */
395 timer = init_lirc_timer(); 396 timer = init_lirc_timer();
396 if (timer == 0) 397 if (timer == 0) {
397 return -EIO; 398 ret = -EIO;
399 goto out;
400 }
398 } 401 }
399 402
400 /* adjust values from usecs */ 403 /* adjust values from usecs */
@@ -420,7 +423,8 @@ static ssize_t lirc_write(struct file *filep, const char *buf, size_t n,
420 if (check_pselecd && (in(1) & LP_PSELECD)) { 423 if (check_pselecd && (in(1) & LP_PSELECD)) {
421 lirc_off(); 424 lirc_off();
422 local_irq_restore(flags); 425 local_irq_restore(flags);
423 return -EIO; 426 ret = -EIO;
427 goto out;
424 } 428 }
425 } while (counttimer < wbuf[i]); 429 } while (counttimer < wbuf[i]);
426 i++; 430 i++;
@@ -436,7 +440,8 @@ static ssize_t lirc_write(struct file *filep, const char *buf, size_t n,
436 level = newlevel; 440 level = newlevel;
437 if (check_pselecd && (in(1) & LP_PSELECD)) { 441 if (check_pselecd && (in(1) & LP_PSELECD)) {
438 local_irq_restore(flags); 442 local_irq_restore(flags);
439 return -EIO; 443 ret = -EIO;
444 goto out;
440 } 445 }
441 } while (counttimer < wbuf[i]); 446 } while (counttimer < wbuf[i]);
442 i++; 447 i++;
@@ -445,7 +450,11 @@ static ssize_t lirc_write(struct file *filep, const char *buf, size_t n,
445#else 450#else
446 /* place code that handles write without external timer here */ 451 /* place code that handles write without external timer here */
447#endif 452#endif
448 return n; 453 ret = n;
454out:
455 kfree(wbuf);
456
457 return ret;
449} 458}
450 459
451static unsigned int lirc_poll(struct file *file, poll_table *wait) 460static unsigned int lirc_poll(struct file *file, poll_table *wait)
diff --git a/drivers/staging/lirc/lirc_sasem.c b/drivers/staging/lirc/lirc_sasem.c
index 998485ebdbce..925eabe14854 100644
--- a/drivers/staging/lirc/lirc_sasem.c
+++ b/drivers/staging/lirc/lirc_sasem.c
@@ -448,6 +448,7 @@ static ssize_t vfd_write(struct file *file, const char *buf,
448exit: 448exit:
449 449
450 mutex_unlock(&context->ctx_lock); 450 mutex_unlock(&context->ctx_lock);
451 kfree(data_buf);
451 452
452 return (!retval) ? n_bytes : retval; 453 return (!retval) ? n_bytes : retval;
453} 454}
diff --git a/drivers/staging/lirc/lirc_serial.c b/drivers/staging/lirc/lirc_serial.c
index 9bcf149c4260..1c3099b388e0 100644
--- a/drivers/staging/lirc/lirc_serial.c
+++ b/drivers/staging/lirc/lirc_serial.c
@@ -966,7 +966,7 @@ static ssize_t lirc_write(struct file *file, const char *buf,
966 if (n % sizeof(int) || count % 2 == 0) 966 if (n % sizeof(int) || count % 2 == 0)
967 return -EINVAL; 967 return -EINVAL;
968 wbuf = memdup_user(buf, n); 968 wbuf = memdup_user(buf, n);
969 if (PTR_ERR(wbuf)) 969 if (IS_ERR(wbuf))
970 return PTR_ERR(wbuf); 970 return PTR_ERR(wbuf);
971 spin_lock_irqsave(&hardware[type].lock, flags); 971 spin_lock_irqsave(&hardware[type].lock, flags);
972 if (type == LIRC_IRDEO) { 972 if (type == LIRC_IRDEO) {
@@ -981,6 +981,7 @@ static ssize_t lirc_write(struct file *file, const char *buf,
981 } 981 }
982 off(); 982 off();
983 spin_unlock_irqrestore(&hardware[type].lock, flags); 983 spin_unlock_irqrestore(&hardware[type].lock, flags);
984 kfree(wbuf);
984 return n; 985 return n;
985} 986}
986 987
diff --git a/drivers/staging/lirc/lirc_sir.c b/drivers/staging/lirc/lirc_sir.c
index c553ab626238..76be7b8c6209 100644
--- a/drivers/staging/lirc/lirc_sir.c
+++ b/drivers/staging/lirc/lirc_sir.c
@@ -330,6 +330,7 @@ static ssize_t lirc_write(struct file *file, const char *buf, size_t n,
330 /* enable receiver */ 330 /* enable receiver */
331 Ser2UTCR3 = UTCR3_RXE|UTCR3_RIE; 331 Ser2UTCR3 = UTCR3_RXE|UTCR3_RIE;
332#endif 332#endif
333 kfree(tx_buf);
333 return count; 334 return count;
334} 335}
335 336
diff --git a/drivers/staging/lirc/lirc_zilog.c b/drivers/staging/lirc/lirc_zilog.c
index ad29bb1275ab..3fe5f4160194 100644
--- a/drivers/staging/lirc/lirc_zilog.c
+++ b/drivers/staging/lirc/lirc_zilog.c
@@ -20,6 +20,9 @@
20 * 20 *
21 * parts are cut&pasted from the lirc_i2c.c driver 21 * parts are cut&pasted from the lirc_i2c.c driver
22 * 22 *
23 * Numerous changes updating lirc_zilog.c in kernel 2.6.38 and later are
24 * Copyright (C) 2011 Andy Walls <awalls@md.metrocast.net>
25 *
23 * This program is free software; you can redistribute it and/or modify 26 * This program is free software; you can redistribute it and/or modify
24 * it under the terms of the GNU General Public License as published by 27 * it under the terms of the GNU General Public License as published by
25 * the Free Software Foundation; either version 2 of the License, or 28 * the Free Software Foundation; either version 2 of the License, or
@@ -60,38 +63,44 @@
60#include <media/lirc_dev.h> 63#include <media/lirc_dev.h>
61#include <media/lirc.h> 64#include <media/lirc.h>
62 65
63struct IR { 66struct IR_rx {
64 struct lirc_driver l;
65
66 /* Device info */
67 struct mutex ir_lock;
68 int open;
69 bool is_hdpvr;
70
71 /* RX device */ 67 /* RX device */
72 struct i2c_client c_rx; 68 struct i2c_client *c;
73 int have_rx;
74 69
75 /* RX device buffer & lock */ 70 /* RX device buffer & lock */
76 struct lirc_buffer buf; 71 struct lirc_buffer buf;
77 struct mutex buf_lock; 72 struct mutex buf_lock;
78 73
79 /* RX polling thread data */ 74 /* RX polling thread data */
80 struct completion *t_notify;
81 struct completion *t_notify2;
82 int shutdown;
83 struct task_struct *task; 75 struct task_struct *task;
84 76
85 /* RX read data */ 77 /* RX read data */
86 unsigned char b[3]; 78 unsigned char b[3];
79 bool hdpvr_data_fmt;
80};
87 81
82struct IR_tx {
88 /* TX device */ 83 /* TX device */
89 struct i2c_client c_tx; 84 struct i2c_client *c;
85
86 /* TX additional actions needed */
90 int need_boot; 87 int need_boot;
91 int have_tx; 88 bool post_tx_ready_poll;
89};
90
91struct IR {
92 struct lirc_driver l;
93
94 struct mutex ir_lock;
95 int open;
96
97 struct i2c_adapter *adapter;
98 struct IR_rx *rx;
99 struct IR_tx *tx;
92}; 100};
93 101
94/* Minor -> data mapping */ 102/* Minor -> data mapping */
103static struct mutex ir_devices_lock;
95static struct IR *ir_devices[MAX_IRCTL_DEVICES]; 104static struct IR *ir_devices[MAX_IRCTL_DEVICES];
96 105
97/* Block size for IR transmitter */ 106/* Block size for IR transmitter */
@@ -124,14 +133,11 @@ static struct mutex tx_data_lock;
124#define zilog_notify(s, args...) printk(KERN_NOTICE KBUILD_MODNAME ": " s, \ 133#define zilog_notify(s, args...) printk(KERN_NOTICE KBUILD_MODNAME ": " s, \
125 ## args) 134 ## args)
126#define zilog_error(s, args...) printk(KERN_ERR KBUILD_MODNAME ": " s, ## args) 135#define zilog_error(s, args...) printk(KERN_ERR KBUILD_MODNAME ": " s, ## args)
127 136#define zilog_info(s, args...) printk(KERN_INFO KBUILD_MODNAME ": " s, ## args)
128#define ZILOG_HAUPPAUGE_IR_RX_NAME "Zilog/Hauppauge IR RX"
129#define ZILOG_HAUPPAUGE_IR_TX_NAME "Zilog/Hauppauge IR TX"
130 137
131/* module parameters */ 138/* module parameters */
132static int debug; /* debug output */ 139static int debug; /* debug output */
133static int disable_rx; /* disable RX device */ 140static int tx_only; /* only handle the IR Tx function */
134static int disable_tx; /* disable TX device */
135static int minor = -1; /* minor number */ 141static int minor = -1; /* minor number */
136 142
137#define dprintk(fmt, args...) \ 143#define dprintk(fmt, args...) \
@@ -150,8 +156,12 @@ static int add_to_buf(struct IR *ir)
150 int ret; 156 int ret;
151 int failures = 0; 157 int failures = 0;
152 unsigned char sendbuf[1] = { 0 }; 158 unsigned char sendbuf[1] = { 0 };
159 struct IR_rx *rx = ir->rx;
153 160
154 if (lirc_buffer_full(&ir->buf)) { 161 if (rx == NULL)
162 return -ENXIO;
163
164 if (lirc_buffer_full(&rx->buf)) {
155 dprintk("buffer overflow\n"); 165 dprintk("buffer overflow\n");
156 return -EOVERFLOW; 166 return -EOVERFLOW;
157 } 167 }
@@ -161,17 +171,25 @@ static int add_to_buf(struct IR *ir)
161 * data and we have space 171 * data and we have space
162 */ 172 */
163 do { 173 do {
174 if (kthread_should_stop())
175 return -ENODATA;
176
164 /* 177 /*
165 * Lock i2c bus for the duration. RX/TX chips interfere so 178 * Lock i2c bus for the duration. RX/TX chips interfere so
166 * this is worth it 179 * this is worth it
167 */ 180 */
168 mutex_lock(&ir->ir_lock); 181 mutex_lock(&ir->ir_lock);
169 182
183 if (kthread_should_stop()) {
184 mutex_unlock(&ir->ir_lock);
185 return -ENODATA;
186 }
187
170 /* 188 /*
171 * Send random "poll command" (?) Windows driver does this 189 * Send random "poll command" (?) Windows driver does this
172 * and it is a good point to detect chip failure. 190 * and it is a good point to detect chip failure.
173 */ 191 */
174 ret = i2c_master_send(&ir->c_rx, sendbuf, 1); 192 ret = i2c_master_send(rx->c, sendbuf, 1);
175 if (ret != 1) { 193 if (ret != 1) {
176 zilog_error("i2c_master_send failed with %d\n", ret); 194 zilog_error("i2c_master_send failed with %d\n", ret);
177 if (failures >= 3) { 195 if (failures >= 3) {
@@ -186,45 +204,53 @@ static int add_to_buf(struct IR *ir)
186 "trying reset\n"); 204 "trying reset\n");
187 205
188 set_current_state(TASK_UNINTERRUPTIBLE); 206 set_current_state(TASK_UNINTERRUPTIBLE);
207 if (kthread_should_stop()) {
208 mutex_unlock(&ir->ir_lock);
209 return -ENODATA;
210 }
189 schedule_timeout((100 * HZ + 999) / 1000); 211 schedule_timeout((100 * HZ + 999) / 1000);
190 ir->need_boot = 1; 212 ir->tx->need_boot = 1;
191 213
192 ++failures; 214 ++failures;
193 mutex_unlock(&ir->ir_lock); 215 mutex_unlock(&ir->ir_lock);
194 continue; 216 continue;
195 } 217 }
196 218
197 ret = i2c_master_recv(&ir->c_rx, keybuf, sizeof(keybuf)); 219 if (kthread_should_stop()) {
220 mutex_unlock(&ir->ir_lock);
221 return -ENODATA;
222 }
223 ret = i2c_master_recv(rx->c, keybuf, sizeof(keybuf));
198 mutex_unlock(&ir->ir_lock); 224 mutex_unlock(&ir->ir_lock);
199 if (ret != sizeof(keybuf)) { 225 if (ret != sizeof(keybuf)) {
200 zilog_error("i2c_master_recv failed with %d -- " 226 zilog_error("i2c_master_recv failed with %d -- "
201 "keeping last read buffer\n", ret); 227 "keeping last read buffer\n", ret);
202 } else { 228 } else {
203 ir->b[0] = keybuf[3]; 229 rx->b[0] = keybuf[3];
204 ir->b[1] = keybuf[4]; 230 rx->b[1] = keybuf[4];
205 ir->b[2] = keybuf[5]; 231 rx->b[2] = keybuf[5];
206 dprintk("key (0x%02x/0x%02x)\n", ir->b[0], ir->b[1]); 232 dprintk("key (0x%02x/0x%02x)\n", rx->b[0], rx->b[1]);
207 } 233 }
208 234
209 /* key pressed ? */ 235 /* key pressed ? */
210 if (ir->is_hdpvr) { 236 if (rx->hdpvr_data_fmt) {
211 if (got_data && (keybuf[0] == 0x80)) 237 if (got_data && (keybuf[0] == 0x80))
212 return 0; 238 return 0;
213 else if (got_data && (keybuf[0] == 0x00)) 239 else if (got_data && (keybuf[0] == 0x00))
214 return -ENODATA; 240 return -ENODATA;
215 } else if ((ir->b[0] & 0x80) == 0) 241 } else if ((rx->b[0] & 0x80) == 0)
216 return got_data ? 0 : -ENODATA; 242 return got_data ? 0 : -ENODATA;
217 243
218 /* look what we have */ 244 /* look what we have */
219 code = (((__u16)ir->b[0] & 0x7f) << 6) | (ir->b[1] >> 2); 245 code = (((__u16)rx->b[0] & 0x7f) << 6) | (rx->b[1] >> 2);
220 246
221 codes[0] = (code >> 8) & 0xff; 247 codes[0] = (code >> 8) & 0xff;
222 codes[1] = code & 0xff; 248 codes[1] = code & 0xff;
223 249
224 /* return it */ 250 /* return it */
225 lirc_buffer_write(&ir->buf, codes); 251 lirc_buffer_write(&rx->buf, codes);
226 ++got_data; 252 ++got_data;
227 } while (!lirc_buffer_full(&ir->buf)); 253 } while (!lirc_buffer_full(&rx->buf));
228 254
229 return 0; 255 return 0;
230} 256}
@@ -242,46 +268,35 @@ static int add_to_buf(struct IR *ir)
242static int lirc_thread(void *arg) 268static int lirc_thread(void *arg)
243{ 269{
244 struct IR *ir = arg; 270 struct IR *ir = arg;
245 271 struct IR_rx *rx = ir->rx;
246 if (ir->t_notify != NULL)
247 complete(ir->t_notify);
248 272
249 dprintk("poll thread started\n"); 273 dprintk("poll thread started\n");
250 274
251 do { 275 while (!kthread_should_stop()) {
252 if (ir->open) { 276 set_current_state(TASK_INTERRUPTIBLE);
253 set_current_state(TASK_INTERRUPTIBLE);
254 277
255 /* 278 /* if device not opened, we can sleep half a second */
256 * This is ~113*2 + 24 + jitter (2*repeat gap + 279 if (!ir->open) {
257 * code length). We use this interval as the chip
258 * resets every time you poll it (bad!). This is
259 * therefore just sufficient to catch all of the
260 * button presses. It makes the remote much more
261 * responsive. You can see the difference by
262 * running irw and holding down a button. With
263 * 100ms, the old polling interval, you'll notice
264 * breaks in the repeat sequence corresponding to
265 * lost keypresses.
266 */
267 schedule_timeout((260 * HZ) / 1000);
268 if (ir->shutdown)
269 break;
270 if (!add_to_buf(ir))
271 wake_up_interruptible(&ir->buf.wait_poll);
272 } else {
273 /* if device not opened so we can sleep half a second */
274 set_current_state(TASK_INTERRUPTIBLE);
275 schedule_timeout(HZ/2); 280 schedule_timeout(HZ/2);
281 continue;
276 } 282 }
277 } while (!ir->shutdown);
278
279 if (ir->t_notify2 != NULL)
280 wait_for_completion(ir->t_notify2);
281 283
282 ir->task = NULL; 284 /*
283 if (ir->t_notify != NULL) 285 * This is ~113*2 + 24 + jitter (2*repeat gap + code length).
284 complete(ir->t_notify); 286 * We use this interval as the chip resets every time you poll
287 * it (bad!). This is therefore just sufficient to catch all
288 * of the button presses. It makes the remote much more
289 * responsive. You can see the difference by running irw and
290 * holding down a button. With 100ms, the old polling
291 * interval, you'll notice breaks in the repeat sequence
292 * corresponding to lost keypresses.
293 */
294 schedule_timeout((260 * HZ) / 1000);
295 if (kthread_should_stop())
296 break;
297 if (!add_to_buf(ir))
298 wake_up_interruptible(&rx->buf.wait_poll);
299 }
285 300
286 dprintk("poll thread ended\n"); 301 dprintk("poll thread ended\n");
287 return 0; 302 return 0;
@@ -299,10 +314,10 @@ static int set_use_inc(void *data)
299 * this is completely broken code. lirc_unregister_driver() 314 * this is completely broken code. lirc_unregister_driver()
300 * must be possible even when the device is open 315 * must be possible even when the device is open
301 */ 316 */
302 if (ir->c_rx.addr) 317 if (ir->rx != NULL)
303 i2c_use_client(&ir->c_rx); 318 i2c_use_client(ir->rx->c);
304 if (ir->c_tx.addr) 319 if (ir->tx != NULL)
305 i2c_use_client(&ir->c_tx); 320 i2c_use_client(ir->tx->c);
306 321
307 return 0; 322 return 0;
308} 323}
@@ -311,10 +326,10 @@ static void set_use_dec(void *data)
311{ 326{
312 struct IR *ir = data; 327 struct IR *ir = data;
313 328
314 if (ir->c_rx.addr) 329 if (ir->rx)
315 i2c_release_client(&ir->c_rx); 330 i2c_release_client(ir->rx->c);
316 if (ir->c_tx.addr) 331 if (ir->tx)
317 i2c_release_client(&ir->c_tx); 332 i2c_release_client(ir->tx->c);
318 if (ir->l.owner != NULL) 333 if (ir->l.owner != NULL)
319 module_put(ir->l.owner); 334 module_put(ir->l.owner);
320} 335}
@@ -453,7 +468,7 @@ corrupt:
453} 468}
454 469
455/* send a block of data to the IR TX device */ 470/* send a block of data to the IR TX device */
456static int send_data_block(struct IR *ir, unsigned char *data_block) 471static int send_data_block(struct IR_tx *tx, unsigned char *data_block)
457{ 472{
458 int i, j, ret; 473 int i, j, ret;
459 unsigned char buf[5]; 474 unsigned char buf[5];
@@ -467,7 +482,7 @@ static int send_data_block(struct IR *ir, unsigned char *data_block)
467 buf[1 + j] = data_block[i + j]; 482 buf[1 + j] = data_block[i + j];
468 dprintk("%02x %02x %02x %02x %02x", 483 dprintk("%02x %02x %02x %02x %02x",
469 buf[0], buf[1], buf[2], buf[3], buf[4]); 484 buf[0], buf[1], buf[2], buf[3], buf[4]);
470 ret = i2c_master_send(&ir->c_tx, buf, tosend + 1); 485 ret = i2c_master_send(tx->c, buf, tosend + 1);
471 if (ret != tosend + 1) { 486 if (ret != tosend + 1) {
472 zilog_error("i2c_master_send failed with %d\n", ret); 487 zilog_error("i2c_master_send failed with %d\n", ret);
473 return ret < 0 ? ret : -EFAULT; 488 return ret < 0 ? ret : -EFAULT;
@@ -478,32 +493,32 @@ static int send_data_block(struct IR *ir, unsigned char *data_block)
478} 493}
479 494
480/* send boot data to the IR TX device */ 495/* send boot data to the IR TX device */
481static int send_boot_data(struct IR *ir) 496static int send_boot_data(struct IR_tx *tx)
482{ 497{
483 int ret; 498 int ret;
484 unsigned char buf[4]; 499 unsigned char buf[4];
485 500
486 /* send the boot block */ 501 /* send the boot block */
487 ret = send_data_block(ir, tx_data->boot_data); 502 ret = send_data_block(tx, tx_data->boot_data);
488 if (ret != 0) 503 if (ret != 0)
489 return ret; 504 return ret;
490 505
491 /* kick it off? */ 506 /* kick it off? */
492 buf[0] = 0x00; 507 buf[0] = 0x00;
493 buf[1] = 0x20; 508 buf[1] = 0x20;
494 ret = i2c_master_send(&ir->c_tx, buf, 2); 509 ret = i2c_master_send(tx->c, buf, 2);
495 if (ret != 2) { 510 if (ret != 2) {
496 zilog_error("i2c_master_send failed with %d\n", ret); 511 zilog_error("i2c_master_send failed with %d\n", ret);
497 return ret < 0 ? ret : -EFAULT; 512 return ret < 0 ? ret : -EFAULT;
498 } 513 }
499 ret = i2c_master_send(&ir->c_tx, buf, 1); 514 ret = i2c_master_send(tx->c, buf, 1);
500 if (ret != 1) { 515 if (ret != 1) {
501 zilog_error("i2c_master_send failed with %d\n", ret); 516 zilog_error("i2c_master_send failed with %d\n", ret);
502 return ret < 0 ? ret : -EFAULT; 517 return ret < 0 ? ret : -EFAULT;
503 } 518 }
504 519
505 /* Here comes the firmware version... (hopefully) */ 520 /* Here comes the firmware version... (hopefully) */
506 ret = i2c_master_recv(&ir->c_tx, buf, 4); 521 ret = i2c_master_recv(tx->c, buf, 4);
507 if (ret != 4) { 522 if (ret != 4) {
508 zilog_error("i2c_master_recv failed with %d\n", ret); 523 zilog_error("i2c_master_recv failed with %d\n", ret);
509 return 0; 524 return 0;
@@ -543,7 +558,7 @@ static void fw_unload(void)
543} 558}
544 559
545/* load "firmware" for the IR TX device */ 560/* load "firmware" for the IR TX device */
546static int fw_load(struct IR *ir) 561static int fw_load(struct IR_tx *tx)
547{ 562{
548 int ret; 563 int ret;
549 unsigned int i; 564 unsigned int i;
@@ -558,7 +573,7 @@ static int fw_load(struct IR *ir)
558 } 573 }
559 574
560 /* Request codeset data file */ 575 /* Request codeset data file */
561 ret = request_firmware(&fw_entry, "haup-ir-blaster.bin", &ir->c_tx.dev); 576 ret = request_firmware(&fw_entry, "haup-ir-blaster.bin", &tx->c->dev);
562 if (ret != 0) { 577 if (ret != 0) {
563 zilog_error("firmware haup-ir-blaster.bin not available " 578 zilog_error("firmware haup-ir-blaster.bin not available "
564 "(%d)\n", ret); 579 "(%d)\n", ret);
@@ -685,20 +700,20 @@ out:
685} 700}
686 701
687/* initialise the IR TX device */ 702/* initialise the IR TX device */
688static int tx_init(struct IR *ir) 703static int tx_init(struct IR_tx *tx)
689{ 704{
690 int ret; 705 int ret;
691 706
692 /* Load 'firmware' */ 707 /* Load 'firmware' */
693 ret = fw_load(ir); 708 ret = fw_load(tx);
694 if (ret != 0) 709 if (ret != 0)
695 return ret; 710 return ret;
696 711
697 /* Send boot block */ 712 /* Send boot block */
698 ret = send_boot_data(ir); 713 ret = send_boot_data(tx);
699 if (ret != 0) 714 if (ret != 0)
700 return ret; 715 return ret;
701 ir->need_boot = 0; 716 tx->need_boot = 0;
702 717
703 /* Looks good */ 718 /* Looks good */
704 return 0; 719 return 0;
@@ -714,20 +729,20 @@ static loff_t lseek(struct file *filep, loff_t offset, int orig)
714static ssize_t read(struct file *filep, char *outbuf, size_t n, loff_t *ppos) 729static ssize_t read(struct file *filep, char *outbuf, size_t n, loff_t *ppos)
715{ 730{
716 struct IR *ir = filep->private_data; 731 struct IR *ir = filep->private_data;
717 unsigned char buf[ir->buf.chunk_size]; 732 struct IR_rx *rx = ir->rx;
718 int ret = 0, written = 0; 733 int ret = 0, written = 0;
719 DECLARE_WAITQUEUE(wait, current); 734 DECLARE_WAITQUEUE(wait, current);
720 735
721 dprintk("read called\n"); 736 dprintk("read called\n");
722 if (ir->c_rx.addr == 0) 737 if (rx == NULL)
723 return -ENODEV; 738 return -ENODEV;
724 739
725 if (mutex_lock_interruptible(&ir->buf_lock)) 740 if (mutex_lock_interruptible(&rx->buf_lock))
726 return -ERESTARTSYS; 741 return -ERESTARTSYS;
727 742
728 if (n % ir->buf.chunk_size) { 743 if (n % rx->buf.chunk_size) {
729 dprintk("read result = -EINVAL\n"); 744 dprintk("read result = -EINVAL\n");
730 mutex_unlock(&ir->buf_lock); 745 mutex_unlock(&rx->buf_lock);
731 return -EINVAL; 746 return -EINVAL;
732 } 747 }
733 748
@@ -736,7 +751,7 @@ static ssize_t read(struct file *filep, char *outbuf, size_t n, loff_t *ppos)
736 * to avoid losing scan code (in case when queue is awaken somewhere 751 * to avoid losing scan code (in case when queue is awaken somewhere
737 * between while condition checking and scheduling) 752 * between while condition checking and scheduling)
738 */ 753 */
739 add_wait_queue(&ir->buf.wait_poll, &wait); 754 add_wait_queue(&rx->buf.wait_poll, &wait);
740 set_current_state(TASK_INTERRUPTIBLE); 755 set_current_state(TASK_INTERRUPTIBLE);
741 756
742 /* 757 /*
@@ -744,7 +759,7 @@ static ssize_t read(struct file *filep, char *outbuf, size_t n, loff_t *ppos)
744 * mode and 'copy_to_user' is happy, wait for data. 759 * mode and 'copy_to_user' is happy, wait for data.
745 */ 760 */
746 while (written < n && ret == 0) { 761 while (written < n && ret == 0) {
747 if (lirc_buffer_empty(&ir->buf)) { 762 if (lirc_buffer_empty(&rx->buf)) {
748 /* 763 /*
749 * According to the read(2) man page, 'written' can be 764 * According to the read(2) man page, 'written' can be
750 * returned as less than 'n', instead of blocking 765 * returned as less than 'n', instead of blocking
@@ -764,16 +779,17 @@ static ssize_t read(struct file *filep, char *outbuf, size_t n, loff_t *ppos)
764 schedule(); 779 schedule();
765 set_current_state(TASK_INTERRUPTIBLE); 780 set_current_state(TASK_INTERRUPTIBLE);
766 } else { 781 } else {
767 lirc_buffer_read(&ir->buf, buf); 782 unsigned char buf[rx->buf.chunk_size];
783 lirc_buffer_read(&rx->buf, buf);
768 ret = copy_to_user((void *)outbuf+written, buf, 784 ret = copy_to_user((void *)outbuf+written, buf,
769 ir->buf.chunk_size); 785 rx->buf.chunk_size);
770 written += ir->buf.chunk_size; 786 written += rx->buf.chunk_size;
771 } 787 }
772 } 788 }
773 789
774 remove_wait_queue(&ir->buf.wait_poll, &wait); 790 remove_wait_queue(&rx->buf.wait_poll, &wait);
775 set_current_state(TASK_RUNNING); 791 set_current_state(TASK_RUNNING);
776 mutex_unlock(&ir->buf_lock); 792 mutex_unlock(&rx->buf_lock);
777 793
778 dprintk("read result = %s (%d)\n", 794 dprintk("read result = %s (%d)\n",
779 ret ? "-EFAULT" : "OK", ret); 795 ret ? "-EFAULT" : "OK", ret);
@@ -782,7 +798,7 @@ static ssize_t read(struct file *filep, char *outbuf, size_t n, loff_t *ppos)
782} 798}
783 799
784/* send a keypress to the IR TX device */ 800/* send a keypress to the IR TX device */
785static int send_code(struct IR *ir, unsigned int code, unsigned int key) 801static int send_code(struct IR_tx *tx, unsigned int code, unsigned int key)
786{ 802{
787 unsigned char data_block[TX_BLOCK_SIZE]; 803 unsigned char data_block[TX_BLOCK_SIZE];
788 unsigned char buf[2]; 804 unsigned char buf[2];
@@ -799,26 +815,26 @@ static int send_code(struct IR *ir, unsigned int code, unsigned int key)
799 return ret; 815 return ret;
800 816
801 /* Send the data block */ 817 /* Send the data block */
802 ret = send_data_block(ir, data_block); 818 ret = send_data_block(tx, data_block);
803 if (ret != 0) 819 if (ret != 0)
804 return ret; 820 return ret;
805 821
806 /* Send data block length? */ 822 /* Send data block length? */
807 buf[0] = 0x00; 823 buf[0] = 0x00;
808 buf[1] = 0x40; 824 buf[1] = 0x40;
809 ret = i2c_master_send(&ir->c_tx, buf, 2); 825 ret = i2c_master_send(tx->c, buf, 2);
810 if (ret != 2) { 826 if (ret != 2) {
811 zilog_error("i2c_master_send failed with %d\n", ret); 827 zilog_error("i2c_master_send failed with %d\n", ret);
812 return ret < 0 ? ret : -EFAULT; 828 return ret < 0 ? ret : -EFAULT;
813 } 829 }
814 ret = i2c_master_send(&ir->c_tx, buf, 1); 830 ret = i2c_master_send(tx->c, buf, 1);
815 if (ret != 1) { 831 if (ret != 1) {
816 zilog_error("i2c_master_send failed with %d\n", ret); 832 zilog_error("i2c_master_send failed with %d\n", ret);
817 return ret < 0 ? ret : -EFAULT; 833 return ret < 0 ? ret : -EFAULT;
818 } 834 }
819 835
820 /* Send finished download? */ 836 /* Send finished download? */
821 ret = i2c_master_recv(&ir->c_tx, buf, 1); 837 ret = i2c_master_recv(tx->c, buf, 1);
822 if (ret != 1) { 838 if (ret != 1) {
823 zilog_error("i2c_master_recv failed with %d\n", ret); 839 zilog_error("i2c_master_recv failed with %d\n", ret);
824 return ret < 0 ? ret : -EFAULT; 840 return ret < 0 ? ret : -EFAULT;
@@ -832,7 +848,7 @@ static int send_code(struct IR *ir, unsigned int code, unsigned int key)
832 /* Send prepare command? */ 848 /* Send prepare command? */
833 buf[0] = 0x00; 849 buf[0] = 0x00;
834 buf[1] = 0x80; 850 buf[1] = 0x80;
835 ret = i2c_master_send(&ir->c_tx, buf, 2); 851 ret = i2c_master_send(tx->c, buf, 2);
836 if (ret != 2) { 852 if (ret != 2) {
837 zilog_error("i2c_master_send failed with %d\n", ret); 853 zilog_error("i2c_master_send failed with %d\n", ret);
838 return ret < 0 ? ret : -EFAULT; 854 return ret < 0 ? ret : -EFAULT;
@@ -843,7 +859,7 @@ static int send_code(struct IR *ir, unsigned int code, unsigned int key)
843 * last i2c_master_recv always fails with a -5, so for now, we're 859 * last i2c_master_recv always fails with a -5, so for now, we're
844 * going to skip this whole mess and say we're done on the HD PVR 860 * going to skip this whole mess and say we're done on the HD PVR
845 */ 861 */
846 if (ir->is_hdpvr) { 862 if (!tx->post_tx_ready_poll) {
847 dprintk("sent code %u, key %u\n", code, key); 863 dprintk("sent code %u, key %u\n", code, key);
848 return 0; 864 return 0;
849 } 865 }
@@ -857,7 +873,7 @@ static int send_code(struct IR *ir, unsigned int code, unsigned int key)
857 for (i = 0; i < 20; ++i) { 873 for (i = 0; i < 20; ++i) {
858 set_current_state(TASK_UNINTERRUPTIBLE); 874 set_current_state(TASK_UNINTERRUPTIBLE);
859 schedule_timeout((50 * HZ + 999) / 1000); 875 schedule_timeout((50 * HZ + 999) / 1000);
860 ret = i2c_master_send(&ir->c_tx, buf, 1); 876 ret = i2c_master_send(tx->c, buf, 1);
861 if (ret == 1) 877 if (ret == 1)
862 break; 878 break;
863 dprintk("NAK expected: i2c_master_send " 879 dprintk("NAK expected: i2c_master_send "
@@ -870,7 +886,7 @@ static int send_code(struct IR *ir, unsigned int code, unsigned int key)
870 } 886 }
871 887
872 /* Seems to be an 'ok' response */ 888 /* Seems to be an 'ok' response */
873 i = i2c_master_recv(&ir->c_tx, buf, 1); 889 i = i2c_master_recv(tx->c, buf, 1);
874 if (i != 1) { 890 if (i != 1) {
875 zilog_error("i2c_master_recv failed with %d\n", ret); 891 zilog_error("i2c_master_recv failed with %d\n", ret);
876 return -EFAULT; 892 return -EFAULT;
@@ -895,10 +911,11 @@ static ssize_t write(struct file *filep, const char *buf, size_t n,
895 loff_t *ppos) 911 loff_t *ppos)
896{ 912{
897 struct IR *ir = filep->private_data; 913 struct IR *ir = filep->private_data;
914 struct IR_tx *tx = ir->tx;
898 size_t i; 915 size_t i;
899 int failures = 0; 916 int failures = 0;
900 917
901 if (ir->c_tx.addr == 0) 918 if (tx == NULL)
902 return -ENODEV; 919 return -ENODEV;
903 920
904 /* Validate user parameters */ 921 /* Validate user parameters */
@@ -919,15 +936,15 @@ static ssize_t write(struct file *filep, const char *buf, size_t n,
919 } 936 }
920 937
921 /* Send boot data first if required */ 938 /* Send boot data first if required */
922 if (ir->need_boot == 1) { 939 if (tx->need_boot == 1) {
923 ret = send_boot_data(ir); 940 ret = send_boot_data(tx);
924 if (ret == 0) 941 if (ret == 0)
925 ir->need_boot = 0; 942 tx->need_boot = 0;
926 } 943 }
927 944
928 /* Send the code */ 945 /* Send the code */
929 if (ret == 0) { 946 if (ret == 0) {
930 ret = send_code(ir, (unsigned)command >> 16, 947 ret = send_code(tx, (unsigned)command >> 16,
931 (unsigned)command & 0xFFFF); 948 (unsigned)command & 0xFFFF);
932 if (ret == -EPROTO) { 949 if (ret == -EPROTO) {
933 mutex_unlock(&ir->ir_lock); 950 mutex_unlock(&ir->ir_lock);
@@ -952,7 +969,7 @@ static ssize_t write(struct file *filep, const char *buf, size_t n,
952 } 969 }
953 set_current_state(TASK_UNINTERRUPTIBLE); 970 set_current_state(TASK_UNINTERRUPTIBLE);
954 schedule_timeout((100 * HZ + 999) / 1000); 971 schedule_timeout((100 * HZ + 999) / 1000);
955 ir->need_boot = 1; 972 tx->need_boot = 1;
956 ++failures; 973 ++failures;
957 } else 974 } else
958 i += sizeof(int); 975 i += sizeof(int);
@@ -969,22 +986,23 @@ static ssize_t write(struct file *filep, const char *buf, size_t n,
969static unsigned int poll(struct file *filep, poll_table *wait) 986static unsigned int poll(struct file *filep, poll_table *wait)
970{ 987{
971 struct IR *ir = filep->private_data; 988 struct IR *ir = filep->private_data;
989 struct IR_rx *rx = ir->rx;
972 unsigned int ret; 990 unsigned int ret;
973 991
974 dprintk("poll called\n"); 992 dprintk("poll called\n");
975 if (ir->c_rx.addr == 0) 993 if (rx == NULL)
976 return -ENODEV; 994 return -ENODEV;
977 995
978 mutex_lock(&ir->buf_lock); 996 mutex_lock(&rx->buf_lock);
979 997
980 poll_wait(filep, &ir->buf.wait_poll, wait); 998 poll_wait(filep, &rx->buf.wait_poll, wait);
981 999
982 dprintk("poll result = %s\n", 1000 dprintk("poll result = %s\n",
983 lirc_buffer_empty(&ir->buf) ? "0" : "POLLIN|POLLRDNORM"); 1001 lirc_buffer_empty(&rx->buf) ? "0" : "POLLIN|POLLRDNORM");
984 1002
985 ret = lirc_buffer_empty(&ir->buf) ? 0 : (POLLIN|POLLRDNORM); 1003 ret = lirc_buffer_empty(&rx->buf) ? 0 : (POLLIN|POLLRDNORM);
986 1004
987 mutex_unlock(&ir->buf_lock); 1005 mutex_unlock(&rx->buf_lock);
988 return ret; 1006 return ret;
989} 1007}
990 1008
@@ -994,10 +1012,9 @@ static long ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
994 int result; 1012 int result;
995 unsigned long mode, features = 0; 1013 unsigned long mode, features = 0;
996 1014
997 if (ir->c_rx.addr != 0) 1015 features |= LIRC_CAN_SEND_PULSE;
1016 if (ir->rx != NULL)
998 features |= LIRC_CAN_REC_LIRCCODE; 1017 features |= LIRC_CAN_REC_LIRCCODE;
999 if (ir->c_tx.addr != 0)
1000 features |= LIRC_CAN_SEND_PULSE;
1001 1018
1002 switch (cmd) { 1019 switch (cmd) {
1003 case LIRC_GET_LENGTH: 1020 case LIRC_GET_LENGTH:
@@ -1024,15 +1041,9 @@ static long ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
1024 result = -EINVAL; 1041 result = -EINVAL;
1025 break; 1042 break;
1026 case LIRC_GET_SEND_MODE: 1043 case LIRC_GET_SEND_MODE:
1027 if (!(features&LIRC_CAN_SEND_MASK))
1028 return -ENOSYS;
1029
1030 result = put_user(LIRC_MODE_PULSE, (unsigned long *) arg); 1044 result = put_user(LIRC_MODE_PULSE, (unsigned long *) arg);
1031 break; 1045 break;
1032 case LIRC_SET_SEND_MODE: 1046 case LIRC_SET_SEND_MODE:
1033 if (!(features&LIRC_CAN_SEND_MASK))
1034 return -ENOSYS;
1035
1036 result = get_user(mode, (unsigned long *) arg); 1047 result = get_user(mode, (unsigned long *) arg);
1037 if (!result && mode != LIRC_MODE_PULSE) 1048 if (!result && mode != LIRC_MODE_PULSE)
1038 return -EINVAL; 1049 return -EINVAL;
@@ -1043,6 +1054,15 @@ static long ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
1043 return result; 1054 return result;
1044} 1055}
1045 1056
1057/* ir_devices_lock must be held */
1058static struct IR *find_ir_device_by_minor(unsigned int minor)
1059{
1060 if (minor >= MAX_IRCTL_DEVICES)
1061 return NULL;
1062
1063 return ir_devices[minor];
1064}
1065
1046/* 1066/*
1047 * Open the IR device. Get hold of our IR structure and 1067 * Open the IR device. Get hold of our IR structure and
1048 * stash it in private_data for the file 1068 * stash it in private_data for the file
@@ -1051,15 +1071,15 @@ static int open(struct inode *node, struct file *filep)
1051{ 1071{
1052 struct IR *ir; 1072 struct IR *ir;
1053 int ret; 1073 int ret;
1074 unsigned int minor = MINOR(node->i_rdev);
1054 1075
1055 /* find our IR struct */ 1076 /* find our IR struct */
1056 unsigned minor = MINOR(node->i_rdev); 1077 mutex_lock(&ir_devices_lock);
1057 if (minor >= MAX_IRCTL_DEVICES) { 1078 ir = find_ir_device_by_minor(minor);
1058 dprintk("minor %d: open result = -ENODEV\n", 1079 mutex_unlock(&ir_devices_lock);
1059 minor); 1080
1081 if (ir == NULL)
1060 return -ENODEV; 1082 return -ENODEV;
1061 }
1062 ir = ir_devices[minor];
1063 1083
1064 /* increment in use count */ 1084 /* increment in use count */
1065 mutex_lock(&ir->ir_lock); 1085 mutex_lock(&ir->ir_lock);
@@ -1106,7 +1126,6 @@ static struct lirc_driver lirc_template = {
1106 1126
1107static int ir_remove(struct i2c_client *client); 1127static int ir_remove(struct i2c_client *client);
1108static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id); 1128static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id);
1109static int ir_command(struct i2c_client *client, unsigned int cmd, void *arg);
1110 1129
1111#define ID_FLAG_TX 0x01 1130#define ID_FLAG_TX 0x01
1112#define ID_FLAG_HDPVR 0x02 1131#define ID_FLAG_HDPVR 0x02
@@ -1126,7 +1145,6 @@ static struct i2c_driver driver = {
1126 }, 1145 },
1127 .probe = ir_probe, 1146 .probe = ir_probe,
1128 .remove = ir_remove, 1147 .remove = ir_remove,
1129 .command = ir_command,
1130 .id_table = ir_transceiver_id, 1148 .id_table = ir_transceiver_id,
1131}; 1149};
1132 1150
@@ -1144,214 +1162,253 @@ static const struct file_operations lirc_fops = {
1144 .release = close 1162 .release = close
1145}; 1163};
1146 1164
1147static int ir_remove(struct i2c_client *client) 1165static void destroy_rx_kthread(struct IR_rx *rx)
1148{ 1166{
1149 struct IR *ir = i2c_get_clientdata(client); 1167 /* end up polling thread */
1168 if (rx != NULL && !IS_ERR_OR_NULL(rx->task)) {
1169 kthread_stop(rx->task);
1170 rx->task = NULL;
1171 }
1172}
1150 1173
1151 mutex_lock(&ir->ir_lock); 1174/* ir_devices_lock must be held */
1175static int add_ir_device(struct IR *ir)
1176{
1177 int i;
1152 1178
1153 if (ir->have_rx || ir->have_tx) { 1179 for (i = 0; i < MAX_IRCTL_DEVICES; i++)
1154 DECLARE_COMPLETION(tn); 1180 if (ir_devices[i] == NULL) {
1155 DECLARE_COMPLETION(tn2); 1181 ir_devices[i] = ir;
1156 1182 break;
1157 /* end up polling thread */
1158 if (ir->task && !IS_ERR(ir->task)) {
1159 ir->t_notify = &tn;
1160 ir->t_notify2 = &tn2;
1161 ir->shutdown = 1;
1162 wake_up_process(ir->task);
1163 complete(&tn2);
1164 wait_for_completion(&tn);
1165 ir->t_notify = NULL;
1166 ir->t_notify2 = NULL;
1167 } 1183 }
1168 1184
1169 } else { 1185 return i == MAX_IRCTL_DEVICES ? -ENOMEM : i;
1170 mutex_unlock(&ir->ir_lock); 1186}
1171 zilog_error("%s: detached from something we didn't " 1187
1172 "attach to\n", __func__); 1188/* ir_devices_lock must be held */
1173 return -ENODEV; 1189static void del_ir_device(struct IR *ir)
1190{
1191 int i;
1192
1193 for (i = 0; i < MAX_IRCTL_DEVICES; i++)
1194 if (ir_devices[i] == ir) {
1195 ir_devices[i] = NULL;
1196 break;
1197 }
1198}
1199
1200static int ir_remove(struct i2c_client *client)
1201{
1202 struct IR *ir = i2c_get_clientdata(client);
1203
1204 mutex_lock(&ir_devices_lock);
1205
1206 if (ir == NULL) {
1207 /* We destroyed everything when the first client came through */
1208 mutex_unlock(&ir_devices_lock);
1209 return 0;
1174 } 1210 }
1175 1211
1176 /* unregister lirc driver */ 1212 /* Good-bye LIRC */
1177 if (ir->l.minor >= 0 && ir->l.minor < MAX_IRCTL_DEVICES) { 1213 lirc_unregister_driver(ir->l.minor);
1178 lirc_unregister_driver(ir->l.minor); 1214
1179 ir_devices[ir->l.minor] = NULL; 1215 /* Good-bye Rx */
1216 destroy_rx_kthread(ir->rx);
1217 if (ir->rx != NULL) {
1218 if (ir->rx->buf.fifo_initialized)
1219 lirc_buffer_free(&ir->rx->buf);
1220 i2c_set_clientdata(ir->rx->c, NULL);
1221 kfree(ir->rx);
1180 } 1222 }
1181 1223
1182 /* free memory */ 1224 /* Good-bye Tx */
1183 lirc_buffer_free(&ir->buf); 1225 i2c_set_clientdata(ir->tx->c, NULL);
1184 mutex_unlock(&ir->ir_lock); 1226 kfree(ir->tx);
1227
1228 /* Good-bye IR */
1229 del_ir_device(ir);
1185 kfree(ir); 1230 kfree(ir);
1186 1231
1232 mutex_unlock(&ir_devices_lock);
1187 return 0; 1233 return 0;
1188} 1234}
1189 1235
1190static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) 1236
1237/* ir_devices_lock must be held */
1238static struct IR *find_ir_device_by_adapter(struct i2c_adapter *adapter)
1191{ 1239{
1240 int i;
1192 struct IR *ir = NULL; 1241 struct IR *ir = NULL;
1242
1243 for (i = 0; i < MAX_IRCTL_DEVICES; i++)
1244 if (ir_devices[i] != NULL &&
1245 ir_devices[i]->adapter == adapter) {
1246 ir = ir_devices[i];
1247 break;
1248 }
1249
1250 return ir;
1251}
1252
1253static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
1254{
1255 struct IR *ir;
1193 struct i2c_adapter *adap = client->adapter; 1256 struct i2c_adapter *adap = client->adapter;
1194 char buf;
1195 int ret; 1257 int ret;
1196 int have_rx = 0, have_tx = 0; 1258 bool tx_probe = false;
1197 1259
1198 dprintk("%s: adapter name (%s) nr %d, i2c_device_id name (%s), " 1260 dprintk("%s: %s on i2c-%d (%s), client addr=0x%02x\n",
1199 "client addr=0x%02x\n", 1261 __func__, id->name, adap->nr, adap->name, client->addr);
1200 __func__, adap->name, adap->nr, id->name, client->addr);
1201 1262
1202 /* 1263 /*
1203 * FIXME - This probe function probes both the Tx and Rx 1264 * The IR receiver is at i2c address 0x71.
1204 * addresses of the IR microcontroller. 1265 * The IR transmitter is at i2c address 0x70.
1205 *
1206 * However, the I2C subsystem is passing along one I2C client at a
1207 * time, based on matches to the ir_transceiver_id[] table above.
1208 * The expectation is that each i2c_client address will be probed
1209 * individually by drivers so the I2C subsystem can mark all client
1210 * addresses as claimed or not.
1211 *
1212 * This probe routine causes only one of the client addresses, TX or RX,
1213 * to be claimed. This will cause a problem if the I2C subsystem is
1214 * subsequently triggered to probe unclaimed clients again.
1215 */ 1266 */
1216 /*
1217 * The external IR receiver is at i2c address 0x71.
1218 * The IR transmitter is at 0x70.
1219 */
1220 client->addr = 0x70;
1221 1267
1222 if (!disable_tx) { 1268 if (id->driver_data & ID_FLAG_TX)
1223 if (i2c_master_recv(client, &buf, 1) == 1) 1269 tx_probe = true;
1224 have_tx = 1; 1270 else if (tx_only) /* module option */
1225 dprintk("probe 0x70 @ %s: %s\n", 1271 return -ENXIO;
1226 adap->name, have_tx ? "success" : "failed");
1227 }
1228 1272
1229 if (!disable_rx) { 1273 zilog_info("probing IR %s on %s (i2c-%d)\n",
1230 client->addr = 0x71; 1274 tx_probe ? "Tx" : "Rx", adap->name, adap->nr);
1231 if (i2c_master_recv(client, &buf, 1) == 1)
1232 have_rx = 1;
1233 dprintk("probe 0x71 @ %s: %s\n",
1234 adap->name, have_rx ? "success" : "failed");
1235 }
1236 1275
1237 if (!(have_rx || have_tx)) { 1276 mutex_lock(&ir_devices_lock);
1238 zilog_error("%s: no devices found\n", adap->name);
1239 goto out_nodev;
1240 }
1241 1277
1242 printk(KERN_INFO "lirc_zilog: chip found with %s\n", 1278 /* Use a single struct IR instance for both the Rx and Tx functions */
1243 have_rx && have_tx ? "RX and TX" : 1279 ir = find_ir_device_by_adapter(adap);
1244 have_rx ? "RX only" : "TX only"); 1280 if (ir == NULL) {
1281 ir = kzalloc(sizeof(struct IR), GFP_KERNEL);
1282 if (ir == NULL) {
1283 ret = -ENOMEM;
1284 goto out_no_ir;
1285 }
1286 /* store for use in ir_probe() again, and open() later on */
1287 ret = add_ir_device(ir);
1288 if (ret)
1289 goto out_free_ir;
1290
1291 ir->adapter = adap;
1292 mutex_init(&ir->ir_lock);
1293
1294 /* set lirc_dev stuff */
1295 memcpy(&ir->l, &lirc_template, sizeof(struct lirc_driver));
1296 ir->l.minor = minor; /* module option */
1297 ir->l.code_length = 13;
1298 ir->l.rbuf = NULL;
1299 ir->l.fops = &lirc_fops;
1300 ir->l.data = ir;
1301 ir->l.dev = &adap->dev;
1302 ir->l.sample_rate = 0;
1303 }
1245 1304
1246 ir = kzalloc(sizeof(struct IR), GFP_KERNEL); 1305 if (tx_probe) {
1306 /* Set up a struct IR_tx instance */
1307 ir->tx = kzalloc(sizeof(struct IR_tx), GFP_KERNEL);
1308 if (ir->tx == NULL) {
1309 ret = -ENOMEM;
1310 goto out_free_xx;
1311 }
1247 1312
1248 if (!ir) 1313 ir->tx->c = client;
1249 goto out_nomem; 1314 ir->tx->need_boot = 1;
1315 ir->tx->post_tx_ready_poll =
1316 (id->driver_data & ID_FLAG_HDPVR) ? false : true;
1317 } else {
1318 /* Set up a struct IR_rx instance */
1319 ir->rx = kzalloc(sizeof(struct IR_rx), GFP_KERNEL);
1320 if (ir->rx == NULL) {
1321 ret = -ENOMEM;
1322 goto out_free_xx;
1323 }
1250 1324
1251 ret = lirc_buffer_init(&ir->buf, 2, BUFLEN / 2); 1325 ret = lirc_buffer_init(&ir->rx->buf, 2, BUFLEN / 2);
1252 if (ret) 1326 if (ret)
1253 goto out_nomem; 1327 goto out_free_xx;
1254 1328
1255 mutex_init(&ir->ir_lock); 1329 mutex_init(&ir->rx->buf_lock);
1256 mutex_init(&ir->buf_lock); 1330 ir->rx->c = client;
1257 ir->need_boot = 1; 1331 ir->rx->hdpvr_data_fmt =
1258 ir->is_hdpvr = (id->driver_data & ID_FLAG_HDPVR) ? true : false; 1332 (id->driver_data & ID_FLAG_HDPVR) ? true : false;
1259 1333
1260 memcpy(&ir->l, &lirc_template, sizeof(struct lirc_driver)); 1334 /* set lirc_dev stuff */
1261 ir->l.minor = -1; 1335 ir->l.rbuf = &ir->rx->buf;
1336 }
1262 1337
1263 /* I2C attach to device */
1264 i2c_set_clientdata(client, ir); 1338 i2c_set_clientdata(client, ir);
1265 1339
1266 /* initialise RX device */ 1340 /* Proceed only if we have the required Tx and Rx clients ready to go */
1267 if (have_rx) { 1341 if (ir->tx == NULL ||
1268 DECLARE_COMPLETION(tn); 1342 (ir->rx == NULL && !tx_only)) {
1269 memcpy(&ir->c_rx, client, sizeof(struct i2c_client)); 1343 zilog_info("probe of IR %s on %s (i2c-%d) done. Waiting on "
1270 1344 "IR %s.\n", tx_probe ? "Tx" : "Rx", adap->name,
1271 ir->c_rx.addr = 0x71; 1345 adap->nr, tx_probe ? "Rx" : "Tx");
1272 strlcpy(ir->c_rx.name, ZILOG_HAUPPAUGE_IR_RX_NAME, 1346 goto out_ok;
1273 I2C_NAME_SIZE); 1347 }
1274 1348
1349 /* initialise RX device */
1350 if (ir->rx != NULL) {
1275 /* try to fire up polling thread */ 1351 /* try to fire up polling thread */
1276 ir->t_notify = &tn; 1352 ir->rx->task = kthread_run(lirc_thread, ir,
1277 ir->task = kthread_run(lirc_thread, ir, "lirc_zilog"); 1353 "zilog-rx-i2c-%d", adap->nr);
1278 if (IS_ERR(ir->task)) { 1354 if (IS_ERR(ir->rx->task)) {
1279 ret = PTR_ERR(ir->task); 1355 ret = PTR_ERR(ir->rx->task);
1280 zilog_error("lirc_register_driver: cannot run " 1356 zilog_error("%s: could not start IR Rx polling thread"
1281 "poll thread %d\n", ret); 1357 "\n", __func__);
1282 goto err; 1358 goto out_free_xx;
1283 } 1359 }
1284 wait_for_completion(&tn);
1285 ir->t_notify = NULL;
1286 ir->have_rx = 1;
1287 }
1288
1289 /* initialise TX device */
1290 if (have_tx) {
1291 memcpy(&ir->c_tx, client, sizeof(struct i2c_client));
1292 ir->c_tx.addr = 0x70;
1293 strlcpy(ir->c_tx.name, ZILOG_HAUPPAUGE_IR_TX_NAME,
1294 I2C_NAME_SIZE);
1295 ir->have_tx = 1;
1296 } 1360 }
1297 1361
1298 /* set lirc_dev stuff */
1299 ir->l.code_length = 13;
1300 ir->l.rbuf = &ir->buf;
1301 ir->l.fops = &lirc_fops;
1302 ir->l.data = ir;
1303 ir->l.minor = minor;
1304 ir->l.dev = &adap->dev;
1305 ir->l.sample_rate = 0;
1306
1307 /* register with lirc */ 1362 /* register with lirc */
1308 ir->l.minor = lirc_register_driver(&ir->l); 1363 ir->l.minor = lirc_register_driver(&ir->l);
1309 if (ir->l.minor < 0 || ir->l.minor >= MAX_IRCTL_DEVICES) { 1364 if (ir->l.minor < 0 || ir->l.minor >= MAX_IRCTL_DEVICES) {
1310 zilog_error("ir_attach: \"minor\" must be between 0 and %d " 1365 zilog_error("%s: \"minor\" must be between 0 and %d (%d)!\n",
1311 "(%d)!\n", MAX_IRCTL_DEVICES-1, ir->l.minor); 1366 __func__, MAX_IRCTL_DEVICES-1, ir->l.minor);
1312 ret = -EBADRQC; 1367 ret = -EBADRQC;
1313 goto err; 1368 goto out_free_thread;
1314 } 1369 }
1315 1370
1316 /* store this for getting back in open() later on */
1317 ir_devices[ir->l.minor] = ir;
1318
1319 /* 1371 /*
1320 * if we have the tx device, load the 'firmware'. We do this 1372 * if we have the tx device, load the 'firmware'. We do this
1321 * after registering with lirc as otherwise hotplug seems to take 1373 * after registering with lirc as otherwise hotplug seems to take
1322 * 10s to create the lirc device. 1374 * 10s to create the lirc device.
1323 */ 1375 */
1324 if (have_tx) { 1376 ret = tx_init(ir->tx);
1325 /* Special TX init */ 1377 if (ret != 0)
1326 ret = tx_init(ir); 1378 goto out_unregister;
1327 if (ret != 0)
1328 goto err;
1329 }
1330 1379
1380 zilog_info("probe of IR %s on %s (i2c-%d) done. IR unit ready.\n",
1381 tx_probe ? "Tx" : "Rx", adap->name, adap->nr);
1382out_ok:
1383 mutex_unlock(&ir_devices_lock);
1331 return 0; 1384 return 0;
1332 1385
1333err: 1386out_unregister:
1334 /* undo everything, hopefully... */ 1387 lirc_unregister_driver(ir->l.minor);
1335 if (ir->c_rx.addr) 1388out_free_thread:
1336 ir_remove(&ir->c_rx); 1389 destroy_rx_kthread(ir->rx);
1337 if (ir->c_tx.addr) 1390out_free_xx:
1338 ir_remove(&ir->c_tx); 1391 if (ir->rx != NULL) {
1339 return ret; 1392 if (ir->rx->buf.fifo_initialized)
1340 1393 lirc_buffer_free(&ir->rx->buf);
1341out_nodev: 1394 if (ir->rx->c != NULL)
1342 zilog_error("no device found\n"); 1395 i2c_set_clientdata(ir->rx->c, NULL);
1343 return -ENODEV; 1396 kfree(ir->rx);
1344 1397 }
1345out_nomem: 1398 if (ir->tx != NULL) {
1346 zilog_error("memory allocation failure\n"); 1399 if (ir->tx->c != NULL)
1400 i2c_set_clientdata(ir->tx->c, NULL);
1401 kfree(ir->tx);
1402 }
1403out_free_ir:
1404 del_ir_device(ir);
1347 kfree(ir); 1405 kfree(ir);
1348 return -ENOMEM; 1406out_no_ir:
1349} 1407 zilog_error("%s: probing IR %s on %s (i2c-%d) failed with %d\n",
1350 1408 __func__, tx_probe ? "Tx" : "Rx", adap->name, adap->nr,
1351static int ir_command(struct i2c_client *client, unsigned int cmd, void *arg) 1409 ret);
1352{ 1410 mutex_unlock(&ir_devices_lock);
1353 /* nothing */ 1411 return ret;
1354 return 0;
1355} 1412}
1356 1413
1357static int __init zilog_init(void) 1414static int __init zilog_init(void)
@@ -1361,6 +1418,7 @@ static int __init zilog_init(void)
1361 zilog_notify("Zilog/Hauppauge IR driver initializing\n"); 1418 zilog_notify("Zilog/Hauppauge IR driver initializing\n");
1362 1419
1363 mutex_init(&tx_data_lock); 1420 mutex_init(&tx_data_lock);
1421 mutex_init(&ir_devices_lock);
1364 1422
1365 request_module("firmware_class"); 1423 request_module("firmware_class");
1366 1424
@@ -1386,7 +1444,8 @@ module_exit(zilog_exit);
1386 1444
1387MODULE_DESCRIPTION("Zilog/Hauppauge infrared transmitter driver (i2c stack)"); 1445MODULE_DESCRIPTION("Zilog/Hauppauge infrared transmitter driver (i2c stack)");
1388MODULE_AUTHOR("Gerd Knorr, Michal Kochanowicz, Christoph Bartelmus, " 1446MODULE_AUTHOR("Gerd Knorr, Michal Kochanowicz, Christoph Bartelmus, "
1389 "Ulrich Mueller, Stefan Jahn, Jerome Brock, Mark Weaver"); 1447 "Ulrich Mueller, Stefan Jahn, Jerome Brock, Mark Weaver, "
1448 "Andy Walls");
1390MODULE_LICENSE("GPL"); 1449MODULE_LICENSE("GPL");
1391/* for compat with old name, which isn't all that accurate anymore */ 1450/* for compat with old name, which isn't all that accurate anymore */
1392MODULE_ALIAS("lirc_pvr150"); 1451MODULE_ALIAS("lirc_pvr150");
@@ -1397,8 +1456,5 @@ MODULE_PARM_DESC(minor, "Preferred minor device number");
1397module_param(debug, bool, 0644); 1456module_param(debug, bool, 0644);
1398MODULE_PARM_DESC(debug, "Enable debugging messages"); 1457MODULE_PARM_DESC(debug, "Enable debugging messages");
1399 1458
1400module_param(disable_rx, bool, 0644); 1459module_param(tx_only, bool, 0644);
1401MODULE_PARM_DESC(disable_rx, "Disable the IR receiver device"); 1460MODULE_PARM_DESC(tx_only, "Only handle the IR transmit function");
1402
1403module_param(disable_tx, bool, 0644);
1404MODULE_PARM_DESC(disable_tx, "Disable the IR transmitter device");
diff --git a/drivers/staging/msm/msm_fb.c b/drivers/staging/msm/msm_fb.c
index 23fa049b51f2..a2f29d464051 100644
--- a/drivers/staging/msm/msm_fb.c
+++ b/drivers/staging/msm/msm_fb.c
@@ -347,7 +347,7 @@ static int msm_fb_suspend(struct platform_device *pdev, pm_message_t state)
347 if ((!mfd) || (mfd->key != MFD_KEY)) 347 if ((!mfd) || (mfd->key != MFD_KEY))
348 return 0; 348 return 0;
349 349
350 acquire_console_sem(); 350 console_lock();
351 fb_set_suspend(mfd->fbi, 1); 351 fb_set_suspend(mfd->fbi, 1);
352 352
353 ret = msm_fb_suspend_sub(mfd); 353 ret = msm_fb_suspend_sub(mfd);
@@ -358,7 +358,7 @@ static int msm_fb_suspend(struct platform_device *pdev, pm_message_t state)
358 pdev->dev.power.power_state = state; 358 pdev->dev.power.power_state = state;
359 } 359 }
360 360
361 release_console_sem(); 361 console_unlock();
362 return ret; 362 return ret;
363} 363}
364#else 364#else
@@ -431,11 +431,11 @@ static int msm_fb_resume(struct platform_device *pdev)
431 if ((!mfd) || (mfd->key != MFD_KEY)) 431 if ((!mfd) || (mfd->key != MFD_KEY))
432 return 0; 432 return 0;
433 433
434 acquire_console_sem(); 434 console_lock();
435 ret = msm_fb_resume_sub(mfd); 435 ret = msm_fb_resume_sub(mfd);
436 pdev->dev.power.power_state = PMSG_ON; 436 pdev->dev.power.power_state = PMSG_ON;
437 fb_set_suspend(mfd->fbi, 1); 437 fb_set_suspend(mfd->fbi, 1);
438 release_console_sem(); 438 console_unlock();
439 439
440 return ret; 440 return ret;
441} 441}
diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c b/drivers/staging/olpc_dcon/olpc_dcon.c
index 9f26dc9408bb..56a283d1a74d 100644
--- a/drivers/staging/olpc_dcon/olpc_dcon.c
+++ b/drivers/staging/olpc_dcon/olpc_dcon.c
@@ -373,17 +373,17 @@ static void dcon_source_switch(struct work_struct *work)
373 * 373 *
374 * For now, we just hope.. 374 * For now, we just hope..
375 */ 375 */
376 acquire_console_sem(); 376 console_lock();
377 ignore_fb_events = 1; 377 ignore_fb_events = 1;
378 if (fb_blank(fbinfo, FB_BLANK_UNBLANK)) { 378 if (fb_blank(fbinfo, FB_BLANK_UNBLANK)) {
379 ignore_fb_events = 0; 379 ignore_fb_events = 0;
380 release_console_sem(); 380 console_unlock();
381 printk(KERN_ERR "olpc-dcon: Failed to enter CPU mode\n"); 381 printk(KERN_ERR "olpc-dcon: Failed to enter CPU mode\n");
382 dcon_pending = DCON_SOURCE_DCON; 382 dcon_pending = DCON_SOURCE_DCON;
383 return; 383 return;
384 } 384 }
385 ignore_fb_events = 0; 385 ignore_fb_events = 0;
386 release_console_sem(); 386 console_unlock();
387 387
388 /* And turn off the DCON */ 388 /* And turn off the DCON */
389 pdata->set_dconload(1); 389 pdata->set_dconload(1);
@@ -435,12 +435,12 @@ static void dcon_source_switch(struct work_struct *work)
435 } 435 }
436 } 436 }
437 437
438 acquire_console_sem(); 438 console_lock();
439 ignore_fb_events = 1; 439 ignore_fb_events = 1;
440 if (fb_blank(fbinfo, FB_BLANK_POWERDOWN)) 440 if (fb_blank(fbinfo, FB_BLANK_POWERDOWN))
441 printk(KERN_ERR "olpc-dcon: couldn't blank fb!\n"); 441 printk(KERN_ERR "olpc-dcon: couldn't blank fb!\n");
442 ignore_fb_events = 0; 442 ignore_fb_events = 0;
443 release_console_sem(); 443 console_unlock();
444 444
445 printk(KERN_INFO "olpc-dcon: The DCON has control\n"); 445 printk(KERN_INFO "olpc-dcon: The DCON has control\n");
446 break; 446 break;
diff --git a/drivers/staging/rt2860/rt_main_dev.c b/drivers/staging/rt2860/rt_main_dev.c
index 701561d6b6fd..236dd36d349a 100644
--- a/drivers/staging/rt2860/rt_main_dev.c
+++ b/drivers/staging/rt2860/rt_main_dev.c
@@ -484,8 +484,6 @@ struct net_device *RtmpPhyNetDevInit(struct rt_rtmp_adapter *pAd,
484 net_dev->ml_priv = (void *)pAd; 484 net_dev->ml_priv = (void *)pAd;
485 pAd->net_dev = net_dev; 485 pAd->net_dev = net_dev;
486 486
487 netif_stop_queue(net_dev);
488
489 return net_dev; 487 return net_dev;
490 488
491} 489}
diff --git a/drivers/staging/rt2860/usb_main_dev.c b/drivers/staging/rt2860/usb_main_dev.c
index ee68d51caa4e..322bf49ee906 100644
--- a/drivers/staging/rt2860/usb_main_dev.c
+++ b/drivers/staging/rt2860/usb_main_dev.c
@@ -106,6 +106,7 @@ struct usb_device_id rtusb_usb_id[] = {
106 {USB_DEVICE(0x0411, 0x016f)}, /* MelCo.,Inc. WLI-UC-G301N */ 106 {USB_DEVICE(0x0411, 0x016f)}, /* MelCo.,Inc. WLI-UC-G301N */
107 {USB_DEVICE(0x1737, 0x0070)}, /* Linksys WUSB100 */ 107 {USB_DEVICE(0x1737, 0x0070)}, /* Linksys WUSB100 */
108 {USB_DEVICE(0x1737, 0x0071)}, /* Linksys WUSB600N */ 108 {USB_DEVICE(0x1737, 0x0071)}, /* Linksys WUSB600N */
109 {USB_DEVICE(0x1737, 0x0078)}, /* Linksys WUSB100v2 */
109 {USB_DEVICE(0x0411, 0x00e8)}, /* Buffalo WLI-UC-G300N */ 110 {USB_DEVICE(0x0411, 0x00e8)}, /* Buffalo WLI-UC-G300N */
110 {USB_DEVICE(0x050d, 0x815c)}, /* Belkin F5D8053 */ 111 {USB_DEVICE(0x050d, 0x815c)}, /* Belkin F5D8053 */
111 {USB_DEVICE(0x100D, 0x9031)}, /* Motorola 2770 */ 112 {USB_DEVICE(0x100D, 0x9031)}, /* Motorola 2770 */
diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c
index 32088a641eba..84be383abec3 100644
--- a/drivers/staging/rtl8712/hal_init.c
+++ b/drivers/staging/rtl8712/hal_init.c
@@ -128,12 +128,13 @@ static u8 rtl8712_dl_fw(struct _adapter *padapter)
128 u8 *ptmpchar = NULL, *ppayload, *ptr; 128 u8 *ptmpchar = NULL, *ppayload, *ptr;
129 struct tx_desc *ptx_desc; 129 struct tx_desc *ptx_desc;
130 u32 txdscp_sz = sizeof(struct tx_desc); 130 u32 txdscp_sz = sizeof(struct tx_desc);
131 u8 ret = _FAIL;
131 132
132 ulfilelength = rtl871x_open_fw(padapter, &phfwfile_hdl, &pmappedfw); 133 ulfilelength = rtl871x_open_fw(padapter, &phfwfile_hdl, &pmappedfw);
133 if (pmappedfw && (ulfilelength > 0)) { 134 if (pmappedfw && (ulfilelength > 0)) {
134 update_fwhdr(&fwhdr, pmappedfw); 135 update_fwhdr(&fwhdr, pmappedfw);
135 if (chk_fwhdr(&fwhdr, ulfilelength) == _FAIL) 136 if (chk_fwhdr(&fwhdr, ulfilelength) == _FAIL)
136 goto exit_fail; 137 goto firmware_rel;
137 fill_fwpriv(padapter, &fwhdr.fwpriv); 138 fill_fwpriv(padapter, &fwhdr.fwpriv);
138 /* firmware check ok */ 139 /* firmware check ok */
139 maxlen = (fwhdr.img_IMEM_size > fwhdr.img_SRAM_size) ? 140 maxlen = (fwhdr.img_IMEM_size > fwhdr.img_SRAM_size) ?
@@ -141,7 +142,7 @@ static u8 rtl8712_dl_fw(struct _adapter *padapter)
141 maxlen += txdscp_sz; 142 maxlen += txdscp_sz;
142 ptmpchar = _malloc(maxlen + FWBUFF_ALIGN_SZ); 143 ptmpchar = _malloc(maxlen + FWBUFF_ALIGN_SZ);
143 if (ptmpchar == NULL) 144 if (ptmpchar == NULL)
144 return _FAIL; 145 goto firmware_rel;
145 146
146 ptx_desc = (struct tx_desc *)(ptmpchar + FWBUFF_ALIGN_SZ - 147 ptx_desc = (struct tx_desc *)(ptmpchar + FWBUFF_ALIGN_SZ -
147 ((addr_t)(ptmpchar) & (FWBUFF_ALIGN_SZ - 1))); 148 ((addr_t)(ptmpchar) & (FWBUFF_ALIGN_SZ - 1)));
@@ -273,11 +274,13 @@ static u8 rtl8712_dl_fw(struct _adapter *padapter)
273 goto exit_fail; 274 goto exit_fail;
274 } else 275 } else
275 goto exit_fail; 276 goto exit_fail;
276 return _SUCCESS; 277 ret = _SUCCESS;
277 278
278exit_fail: 279exit_fail:
279 kfree(ptmpchar); 280 kfree(ptmpchar);
280 return _FAIL; 281firmware_rel:
282 release_firmware((struct firmware *)phfwfile_hdl);
283 return ret;
281} 284}
282 285
283uint rtl8712_hal_init(struct _adapter *padapter) 286uint rtl8712_hal_init(struct _adapter *padapter)
diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c
index a692ee88b9e9..21ce2af447b5 100644
--- a/drivers/staging/rtl8712/usb_intf.c
+++ b/drivers/staging/rtl8712/usb_intf.c
@@ -47,54 +47,123 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf,
47static void r871xu_dev_remove(struct usb_interface *pusb_intf); 47static void r871xu_dev_remove(struct usb_interface *pusb_intf);
48 48
49static struct usb_device_id rtl871x_usb_id_tbl[] = { 49static struct usb_device_id rtl871x_usb_id_tbl[] = {
50 /*92SU 50
51 * Realtek */ 51/* RTL8188SU */
52 {USB_DEVICE(0x0bda, 0x8171)}, 52 /* Realtek */
53 {USB_DEVICE(0x0bda, 0x8172)}, 53 {USB_DEVICE(0x0BDA, 0x8171)},
54 {USB_DEVICE(0x0bda, 0x8173)}, 54 {USB_DEVICE(0x0bda, 0x8173)},
55 {USB_DEVICE(0x0bda, 0x8174)},
56 {USB_DEVICE(0x0bda, 0x8712)}, 55 {USB_DEVICE(0x0bda, 0x8712)},
57 {USB_DEVICE(0x0bda, 0x8713)}, 56 {USB_DEVICE(0x0bda, 0x8713)},
58 {USB_DEVICE(0x0bda, 0xC512)}, 57 {USB_DEVICE(0x0bda, 0xC512)},
59 /* Abocom */ 58 /* Abocom */
60 {USB_DEVICE(0x07B8, 0x8188)}, 59 {USB_DEVICE(0x07B8, 0x8188)},
60 /* ASUS */
61 {USB_DEVICE(0x0B05, 0x1786)},
62 {USB_DEVICE(0x0B05, 0x1791)}, /* 11n mode disable */
63 /* Belkin */
64 {USB_DEVICE(0x050D, 0x945A)},
61 /* Corega */ 65 /* Corega */
62 {USB_DEVICE(0x07aa, 0x0047)}, 66 {USB_DEVICE(0x07AA, 0x0047)},
63 /* Dlink */ 67 /* D-Link */
64 {USB_DEVICE(0x07d1, 0x3303)}, 68 {USB_DEVICE(0x2001, 0x3306)},
65 {USB_DEVICE(0x07d1, 0x3302)}, 69 {USB_DEVICE(0x07D1, 0x3306)}, /* 11n mode disable */
66 {USB_DEVICE(0x07d1, 0x3300)}, 70 /* Edimax */
67 /* Dlink for Skyworth */ 71 {USB_DEVICE(0x7392, 0x7611)},
68 {USB_DEVICE(0x14b2, 0x3300)},
69 {USB_DEVICE(0x14b2, 0x3301)},
70 {USB_DEVICE(0x14b2, 0x3302)},
71 /* EnGenius */ 72 /* EnGenius */
72 {USB_DEVICE(0x1740, 0x9603)}, 73 {USB_DEVICE(0x1740, 0x9603)},
73 {USB_DEVICE(0x1740, 0x9605)}, 74 /* Hawking */
75 {USB_DEVICE(0x0E66, 0x0016)},
76 /* Hercules */
77 {USB_DEVICE(0x06F8, 0xE034)},
78 {USB_DEVICE(0x06F8, 0xE032)},
79 /* Logitec */
80 {USB_DEVICE(0x0789, 0x0167)},
81 /* PCI */
82 {USB_DEVICE(0x2019, 0xAB28)},
83 {USB_DEVICE(0x2019, 0xED16)},
84 /* Sitecom */
85 {USB_DEVICE(0x0DF6, 0x0057)},
86 {USB_DEVICE(0x0DF6, 0x0045)},
87 {USB_DEVICE(0x0DF6, 0x0059)}, /* 11n mode disable */
88 {USB_DEVICE(0x0DF6, 0x004B)},
89 {USB_DEVICE(0x0DF6, 0x0063)},
90 /* Sweex */
91 {USB_DEVICE(0x177F, 0x0154)},
92 /* Thinkware */
93 {USB_DEVICE(0x0BDA, 0x5077)},
94 /* Toshiba */
95 {USB_DEVICE(0x1690, 0x0752)},
96 /* - */
97 {USB_DEVICE(0x20F4, 0x646B)},
98 {USB_DEVICE(0x083A, 0xC512)},
99
100/* RTL8191SU */
101 /* Realtek */
102 {USB_DEVICE(0x0BDA, 0x8172)},
103 /* Amigo */
104 {USB_DEVICE(0x0EB0, 0x9061)},
105 /* ASUS/EKB */
106 {USB_DEVICE(0x0BDA, 0x8172)},
107 {USB_DEVICE(0x13D3, 0x3323)},
108 {USB_DEVICE(0x13D3, 0x3311)}, /* 11n mode disable */
109 {USB_DEVICE(0x13D3, 0x3342)},
110 /* ASUS/EKBLenovo */
111 {USB_DEVICE(0x13D3, 0x3333)},
112 {USB_DEVICE(0x13D3, 0x3334)},
113 {USB_DEVICE(0x13D3, 0x3335)}, /* 11n mode disable */
114 {USB_DEVICE(0x13D3, 0x3336)}, /* 11n mode disable */
115 /* ASUS/Media BOX */
116 {USB_DEVICE(0x13D3, 0x3309)},
74 /* Belkin */ 117 /* Belkin */
75 {USB_DEVICE(0x050d, 0x815F)}, 118 {USB_DEVICE(0x050D, 0x815F)},
76 {USB_DEVICE(0x050d, 0x945A)}, 119 /* D-Link */
77 {USB_DEVICE(0x050d, 0x845A)}, 120 {USB_DEVICE(0x07D1, 0x3302)},
78 /* Guillemot */ 121 {USB_DEVICE(0x07D1, 0x3300)},
79 {USB_DEVICE(0x06f8, 0xe031)}, 122 {USB_DEVICE(0x07D1, 0x3303)},
80 /* Edimax */ 123 /* Edimax */
81 {USB_DEVICE(0x7392, 0x7611)},
82 {USB_DEVICE(0x7392, 0x7612)}, 124 {USB_DEVICE(0x7392, 0x7612)},
83 {USB_DEVICE(0x7392, 0x7622)}, 125 /* EnGenius */
84 /* Sitecom */ 126 {USB_DEVICE(0x1740, 0x9605)},
85 {USB_DEVICE(0x0DF6, 0x0045)}, 127 /* Guillemot */
128 {USB_DEVICE(0x06F8, 0xE031)},
86 /* Hawking */ 129 /* Hawking */
87 {USB_DEVICE(0x0E66, 0x0015)}, 130 {USB_DEVICE(0x0E66, 0x0015)},
88 {USB_DEVICE(0x0E66, 0x0016)}, 131 /* Mediao */
89 {USB_DEVICE(0x0b05, 0x1786)},
90 {USB_DEVICE(0x0b05, 0x1791)}, /* 11n mode disable */
91
92 {USB_DEVICE(0x13D3, 0x3306)}, 132 {USB_DEVICE(0x13D3, 0x3306)},
93 {USB_DEVICE(0x13D3, 0x3309)}, 133 /* PCI */
134 {USB_DEVICE(0x2019, 0xED18)},
135 {USB_DEVICE(0x2019, 0x4901)},
136 /* Sitecom */
137 {USB_DEVICE(0x0DF6, 0x0058)},
138 {USB_DEVICE(0x0DF6, 0x0049)},
139 {USB_DEVICE(0x0DF6, 0x004C)},
140 {USB_DEVICE(0x0DF6, 0x0064)},
141 /* Skyworth */
142 {USB_DEVICE(0x14b2, 0x3300)},
143 {USB_DEVICE(0x14b2, 0x3301)},
144 {USB_DEVICE(0x14B2, 0x3302)},
145 /* - */
146 {USB_DEVICE(0x04F2, 0xAFF2)},
147 {USB_DEVICE(0x04F2, 0xAFF5)},
148 {USB_DEVICE(0x04F2, 0xAFF6)},
149 {USB_DEVICE(0x13D3, 0x3339)},
150 {USB_DEVICE(0x13D3, 0x3340)}, /* 11n mode disable */
151 {USB_DEVICE(0x13D3, 0x3341)}, /* 11n mode disable */
94 {USB_DEVICE(0x13D3, 0x3310)}, 152 {USB_DEVICE(0x13D3, 0x3310)},
95 {USB_DEVICE(0x13D3, 0x3311)}, /* 11n mode disable */
96 {USB_DEVICE(0x13D3, 0x3325)}, 153 {USB_DEVICE(0x13D3, 0x3325)},
97 {USB_DEVICE(0x083A, 0xC512)}, 154
155/* RTL8192SU */
156 /* Realtek */
157 {USB_DEVICE(0x0BDA, 0x8174)},
158 {USB_DEVICE(0x0BDA, 0x8174)},
159 /* Belkin */
160 {USB_DEVICE(0x050D, 0x845A)},
161 /* Corega */
162 {USB_DEVICE(0x07AA, 0x0051)},
163 /* Edimax */
164 {USB_DEVICE(0x7392, 0x7622)},
165 /* NEC */
166 {USB_DEVICE(0x0409, 0x02B6)},
98 {} 167 {}
99}; 168};
100 169
@@ -103,8 +172,20 @@ MODULE_DEVICE_TABLE(usb, rtl871x_usb_id_tbl);
103static struct specific_device_id specific_device_id_tbl[] = { 172static struct specific_device_id specific_device_id_tbl[] = {
104 {.idVendor = 0x0b05, .idProduct = 0x1791, 173 {.idVendor = 0x0b05, .idProduct = 0x1791,
105 .flags = SPEC_DEV_ID_DISABLE_HT}, 174 .flags = SPEC_DEV_ID_DISABLE_HT},
175 {.idVendor = 0x0df6, .idProduct = 0x0059,
176 .flags = SPEC_DEV_ID_DISABLE_HT},
177 {.idVendor = 0x13d3, .idProduct = 0x3306,
178 .flags = SPEC_DEV_ID_DISABLE_HT},
106 {.idVendor = 0x13D3, .idProduct = 0x3311, 179 {.idVendor = 0x13D3, .idProduct = 0x3311,
107 .flags = SPEC_DEV_ID_DISABLE_HT}, 180 .flags = SPEC_DEV_ID_DISABLE_HT},
181 {.idVendor = 0x13d3, .idProduct = 0x3335,
182 .flags = SPEC_DEV_ID_DISABLE_HT},
183 {.idVendor = 0x13d3, .idProduct = 0x3336,
184 .flags = SPEC_DEV_ID_DISABLE_HT},
185 {.idVendor = 0x13d3, .idProduct = 0x3340,
186 .flags = SPEC_DEV_ID_DISABLE_HT},
187 {.idVendor = 0x13d3, .idProduct = 0x3341,
188 .flags = SPEC_DEV_ID_DISABLE_HT},
108 {} 189 {}
109}; 190};
110 191
diff --git a/drivers/staging/sm7xx/smtcfb.c b/drivers/staging/sm7xx/smtcfb.c
index 0bc113c44d39..d007e4a12c14 100644
--- a/drivers/staging/sm7xx/smtcfb.c
+++ b/drivers/staging/sm7xx/smtcfb.c
@@ -1044,9 +1044,9 @@ static int __maybe_unused smtcfb_suspend(struct pci_dev *pdev, pm_message_t msg)
1044 1044
1045 /* when doing suspend, call fb apis and pci apis */ 1045 /* when doing suspend, call fb apis and pci apis */
1046 if (msg.event == PM_EVENT_SUSPEND) { 1046 if (msg.event == PM_EVENT_SUSPEND) {
1047 acquire_console_sem(); 1047 console_lock();
1048 fb_set_suspend(&sfb->fb, 1); 1048 fb_set_suspend(&sfb->fb, 1);
1049 release_console_sem(); 1049 console_unlock();
1050 retv = pci_save_state(pdev); 1050 retv = pci_save_state(pdev);
1051 pci_disable_device(pdev); 1051 pci_disable_device(pdev);
1052 retv = pci_choose_state(pdev, msg); 1052 retv = pci_choose_state(pdev, msg);
@@ -1105,9 +1105,9 @@ static int __maybe_unused smtcfb_resume(struct pci_dev *pdev)
1105 1105
1106 smtcfb_setmode(sfb); 1106 smtcfb_setmode(sfb);
1107 1107
1108 acquire_console_sem(); 1108 console_lock();
1109 fb_set_suspend(&sfb->fb, 0); 1109 fb_set_suspend(&sfb->fb, 0);
1110 release_console_sem(); 1110 console_unlock();
1111 1111
1112 return 0; 1112 return 0;
1113} 1113}
diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c
index 408bb9b3303e..07a7f5432597 100644
--- a/drivers/staging/speakup/kobjects.c
+++ b/drivers/staging/speakup/kobjects.c
@@ -332,7 +332,7 @@ static ssize_t silent_store(struct kobject *kobj, struct kobj_attribute *attr,
332 unsigned long flags; 332 unsigned long flags;
333 333
334 len = strlen(buf); 334 len = strlen(buf);
335 if (len > 0 || len < 3) { 335 if (len > 0 && len < 3) {
336 ch = buf[0]; 336 ch = buf[0];
337 if (ch == '\n') 337 if (ch == '\n')
338 ch = '0'; 338 ch = '0';
diff --git a/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c b/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c
index e8f047e86a32..80183a7e6624 100644
--- a/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c
+++ b/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c
@@ -986,12 +986,6 @@ static int __devinit synaptics_rmi4_probe
986 input_set_abs_params(rmi4_data->input_dev, ABS_MT_TOUCH_MAJOR, 0, 986 input_set_abs_params(rmi4_data->input_dev, ABS_MT_TOUCH_MAJOR, 0,
987 MAX_TOUCH_MAJOR, 0, 0); 987 MAX_TOUCH_MAJOR, 0, 0);
988 988
989 retval = input_register_device(rmi4_data->input_dev);
990 if (retval) {
991 dev_err(&client->dev, "%s:input register failed\n", __func__);
992 goto err_input_register;
993 }
994
995 /* Clear interrupts */ 989 /* Clear interrupts */
996 synaptics_rmi4_i2c_block_read(rmi4_data, 990 synaptics_rmi4_i2c_block_read(rmi4_data,
997 rmi4_data->fn01_data_base_addr + 1, intr_status, 991 rmi4_data->fn01_data_base_addr + 1, intr_status,
@@ -1003,15 +997,20 @@ static int __devinit synaptics_rmi4_probe
1003 if (retval) { 997 if (retval) {
1004 dev_err(&client->dev, "%s:Unable to get attn irq %d\n", 998 dev_err(&client->dev, "%s:Unable to get attn irq %d\n",
1005 __func__, platformdata->irq_number); 999 __func__, platformdata->irq_number);
1006 goto err_request_irq; 1000 goto err_unset_clientdata;
1001 }
1002
1003 retval = input_register_device(rmi4_data->input_dev);
1004 if (retval) {
1005 dev_err(&client->dev, "%s:input register failed\n", __func__);
1006 goto err_free_irq;
1007 } 1007 }
1008 1008
1009 return retval; 1009 return retval;
1010 1010
1011err_request_irq: 1011err_free_irq:
1012 free_irq(platformdata->irq_number, rmi4_data); 1012 free_irq(platformdata->irq_number, rmi4_data);
1013 input_unregister_device(rmi4_data->input_dev); 1013err_unset_clientdata:
1014err_input_register:
1015 i2c_set_clientdata(client, NULL); 1014 i2c_set_clientdata(client, NULL);
1016err_query_dev: 1015err_query_dev:
1017 if (platformdata->regulator_en) { 1016 if (platformdata->regulator_en) {
diff --git a/drivers/staging/tidspbridge/core/io_sm.c b/drivers/staging/tidspbridge/core/io_sm.c
index 571864555ddd..27e0aa81a584 100644
--- a/drivers/staging/tidspbridge/core/io_sm.c
+++ b/drivers/staging/tidspbridge/core/io_sm.c
@@ -949,7 +949,7 @@ func_end:
949 * Calls the Bridge's CHNL_ISR to determine if this interrupt is ours, then 949 * Calls the Bridge's CHNL_ISR to determine if this interrupt is ours, then
950 * schedules a DPC to dispatch I/O. 950 * schedules a DPC to dispatch I/O.
951 */ 951 */
952void io_mbox_msg(u32 msg) 952int io_mbox_msg(struct notifier_block *self, unsigned long len, void *msg)
953{ 953{
954 struct io_mgr *pio_mgr; 954 struct io_mgr *pio_mgr;
955 struct dev_object *dev_obj; 955 struct dev_object *dev_obj;
@@ -959,9 +959,9 @@ void io_mbox_msg(u32 msg)
959 dev_get_io_mgr(dev_obj, &pio_mgr); 959 dev_get_io_mgr(dev_obj, &pio_mgr);
960 960
961 if (!pio_mgr) 961 if (!pio_mgr)
962 return; 962 return NOTIFY_BAD;
963 963
964 pio_mgr->intr_val = (u16)msg; 964 pio_mgr->intr_val = (u16)((u32)msg);
965 if (pio_mgr->intr_val & MBX_PM_CLASS) 965 if (pio_mgr->intr_val & MBX_PM_CLASS)
966 io_dispatch_pm(pio_mgr); 966 io_dispatch_pm(pio_mgr);
967 967
@@ -973,7 +973,7 @@ void io_mbox_msg(u32 msg)
973 spin_unlock_irqrestore(&pio_mgr->dpc_lock, flags); 973 spin_unlock_irqrestore(&pio_mgr->dpc_lock, flags);
974 tasklet_schedule(&pio_mgr->dpc_tasklet); 974 tasklet_schedule(&pio_mgr->dpc_tasklet);
975 } 975 }
976 return; 976 return NOTIFY_OK;
977} 977}
978 978
979/* 979/*
diff --git a/drivers/staging/tidspbridge/core/tiomap3430.c b/drivers/staging/tidspbridge/core/tiomap3430.c
index a3b0a183d570..a3f69f6f505f 100644
--- a/drivers/staging/tidspbridge/core/tiomap3430.c
+++ b/drivers/staging/tidspbridge/core/tiomap3430.c
@@ -223,6 +223,10 @@ static struct bridge_drv_interface drv_interface_fxns = {
223 bridge_msg_set_queue_id, 223 bridge_msg_set_queue_id,
224}; 224};
225 225
226static struct notifier_block dsp_mbox_notifier = {
227 .notifier_call = io_mbox_msg,
228};
229
226static inline void flush_all(struct bridge_dev_context *dev_context) 230static inline void flush_all(struct bridge_dev_context *dev_context)
227{ 231{
228 if (dev_context->dw_brd_state == BRD_DSP_HIBERNATION || 232 if (dev_context->dw_brd_state == BRD_DSP_HIBERNATION ||
@@ -553,7 +557,7 @@ static int bridge_brd_start(struct bridge_dev_context *dev_ctxt,
553 * Enable Mailbox events and also drain any pending 557 * Enable Mailbox events and also drain any pending
554 * stale messages. 558 * stale messages.
555 */ 559 */
556 dev_context->mbox = omap_mbox_get("dsp"); 560 dev_context->mbox = omap_mbox_get("dsp", &dsp_mbox_notifier);
557 if (IS_ERR(dev_context->mbox)) { 561 if (IS_ERR(dev_context->mbox)) {
558 dev_context->mbox = NULL; 562 dev_context->mbox = NULL;
559 pr_err("%s: Failed to get dsp mailbox handle\n", 563 pr_err("%s: Failed to get dsp mailbox handle\n",
@@ -563,8 +567,6 @@ static int bridge_brd_start(struct bridge_dev_context *dev_ctxt,
563 567
564 } 568 }
565 if (!status) { 569 if (!status) {
566 dev_context->mbox->rxq->callback = (int (*)(void *))io_mbox_msg;
567
568/*PM_IVA2GRPSEL_PER = 0xC0;*/ 570/*PM_IVA2GRPSEL_PER = 0xC0;*/
569 temp = readl(resources->dw_per_pm_base + 0xA8); 571 temp = readl(resources->dw_per_pm_base + 0xA8);
570 temp = (temp & 0xFFFFFF30) | 0xC0; 572 temp = (temp & 0xFFFFFF30) | 0xC0;
@@ -685,7 +687,7 @@ static int bridge_brd_stop(struct bridge_dev_context *dev_ctxt)
685 /* Disable the mailbox interrupts */ 687 /* Disable the mailbox interrupts */
686 if (dev_context->mbox) { 688 if (dev_context->mbox) {
687 omap_mbox_disable_irq(dev_context->mbox, IRQ_RX); 689 omap_mbox_disable_irq(dev_context->mbox, IRQ_RX);
688 omap_mbox_put(dev_context->mbox); 690 omap_mbox_put(dev_context->mbox, &dsp_mbox_notifier);
689 dev_context->mbox = NULL; 691 dev_context->mbox = NULL;
690 } 692 }
691 /* Reset IVA2 clocks*/ 693 /* Reset IVA2 clocks*/
@@ -786,10 +788,7 @@ static int bridge_dev_create(struct bridge_dev_context
786 788
787 pt_attrs = kzalloc(sizeof(struct pg_table_attrs), GFP_KERNEL); 789 pt_attrs = kzalloc(sizeof(struct pg_table_attrs), GFP_KERNEL);
788 if (pt_attrs != NULL) { 790 if (pt_attrs != NULL) {
789 /* Assuming that we use only DSP's memory map 791 pt_attrs->l1_size = SZ_16K; /* 4096 entries of 32 bits */
790 * until 0x4000:0000 , we would need only 1024
791 * L1 enties i.e L1 size = 4K */
792 pt_attrs->l1_size = 0x1000;
793 align_size = pt_attrs->l1_size; 792 align_size = pt_attrs->l1_size;
794 /* Align sizes are expected to be power of 2 */ 793 /* Align sizes are expected to be power of 2 */
795 /* we like to get aligned on L1 table size */ 794 /* we like to get aligned on L1 table size */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/io_sm.h b/drivers/staging/tidspbridge/include/dspbridge/io_sm.h
index 18aec55d8647..8242c70e09dd 100644
--- a/drivers/staging/tidspbridge/include/dspbridge/io_sm.h
+++ b/drivers/staging/tidspbridge/include/dspbridge/io_sm.h
@@ -72,22 +72,17 @@ extern void io_dpc(unsigned long ref_data);
72/* 72/*
73 * ======== io_mbox_msg ======== 73 * ======== io_mbox_msg ========
74 * Purpose: 74 * Purpose:
75 * Main interrupt handler for the shared memory Bridge channel manager. 75 * Main message handler for the shared memory Bridge channel manager.
76 * Calls the Bridge's chnlsm_isr to determine if this interrupt is ours, 76 * Determine if this message is ours, then schedules a DPC to
77 * then schedules a DPC to dispatch I/O. 77 * dispatch I/O.
78 * Parameters: 78 * Parameters:
79 * ref_data: Pointer to the channel manager object for this board. 79 * self: Pointer to its own notifier_block struct.
80 * Set in an initial call to ISR_Install(). 80 * len: Length of message.
81 * msg: Message code received.
81 * Returns: 82 * Returns:
82 * TRUE if interrupt handled; FALSE otherwise. 83 * NOTIFY_OK if handled; NOTIFY_BAD otherwise.
83 * Requires:
84 * Must be in locked memory if executing in kernel mode.
85 * Must only call functions which are in locked memory if Kernel mode.
86 * Must only call asynchronous services.
87 * Interrupts are disabled and EOI for this interrupt has been sent.
88 * Ensures:
89 */ 84 */
90void io_mbox_msg(u32 msg); 85int io_mbox_msg(struct notifier_block *self, unsigned long len, void *msg);
91 86
92/* 87/*
93 * ======== io_request_chnl ======== 88 * ======== io_request_chnl ========
diff --git a/drivers/staging/tm6000/tm6000-video.c b/drivers/staging/tm6000/tm6000-video.c
index 8fe017c3721f..eb9b9f1bc138 100644
--- a/drivers/staging/tm6000/tm6000-video.c
+++ b/drivers/staging/tm6000/tm6000-video.c
@@ -1450,29 +1450,55 @@ static struct video_device tm6000_template = {
1450 * ------------------------------------------------------------------ 1450 * ------------------------------------------------------------------
1451 */ 1451 */
1452 1452
1453int tm6000_v4l2_register(struct tm6000_core *dev) 1453static struct video_device *vdev_init(struct tm6000_core *dev,
1454 const struct video_device
1455 *template, const char *type_name)
1454{ 1456{
1455 int ret = -1;
1456 struct video_device *vfd; 1457 struct video_device *vfd;
1457 1458
1458 vfd = video_device_alloc(); 1459 vfd = video_device_alloc();
1459 if(!vfd) { 1460 if (NULL == vfd)
1461 return NULL;
1462
1463 *vfd = *template;
1464 vfd->v4l2_dev = &dev->v4l2_dev;
1465 vfd->release = video_device_release;
1466 vfd->debug = tm6000_debug;
1467 vfd->lock = &dev->lock;
1468
1469 snprintf(vfd->name, sizeof(vfd->name), "%s %s", dev->name, type_name);
1470
1471 video_set_drvdata(vfd, dev);
1472 return vfd;
1473}
1474
1475int tm6000_v4l2_register(struct tm6000_core *dev)
1476{
1477 int ret = -1;
1478
1479 dev->vfd = vdev_init(dev, &tm6000_template, "video");
1480
1481 if (!dev->vfd) {
1482 printk(KERN_INFO "%s: can't register video device\n",
1483 dev->name);
1460 return -ENOMEM; 1484 return -ENOMEM;
1461 } 1485 }
1462 dev->vfd = vfd;
1463 1486
1464 /* init video dma queues */ 1487 /* init video dma queues */
1465 INIT_LIST_HEAD(&dev->vidq.active); 1488 INIT_LIST_HEAD(&dev->vidq.active);
1466 INIT_LIST_HEAD(&dev->vidq.queued); 1489 INIT_LIST_HEAD(&dev->vidq.queued);
1467 1490
1468 memcpy(dev->vfd, &tm6000_template, sizeof(*(dev->vfd))); 1491 ret = video_register_device(dev->vfd, VFL_TYPE_GRABBER, video_nr);
1469 dev->vfd->debug = tm6000_debug;
1470 dev->vfd->lock = &dev->lock;
1471 1492
1472 vfd->v4l2_dev = &dev->v4l2_dev; 1493 if (ret < 0) {
1473 video_set_drvdata(vfd, dev); 1494 printk(KERN_INFO "%s: can't register video device\n",
1495 dev->name);
1496 return ret;
1497 }
1498
1499 printk(KERN_INFO "%s: registered device %s\n",
1500 dev->name, video_device_node_name(dev->vfd));
1474 1501
1475 ret = video_register_device(dev->vfd, VFL_TYPE_GRABBER, video_nr);
1476 printk(KERN_INFO "Trident TVMaster TM5600/TM6000/TM6010 USB2 board (Load status: %d)\n", ret); 1502 printk(KERN_INFO "Trident TVMaster TM5600/TM6000/TM6010 USB2 board (Load status: %d)\n", ret);
1477 return ret; 1503 return ret;
1478} 1504}
diff --git a/drivers/staging/usbip/stub.h b/drivers/staging/usbip/stub.h
index 30dbfb6d16f2..d73267961ef4 100644
--- a/drivers/staging/usbip/stub.h
+++ b/drivers/staging/usbip/stub.h
@@ -32,6 +32,7 @@
32 32
33struct stub_device { 33struct stub_device {
34 struct usb_interface *interface; 34 struct usb_interface *interface;
35 struct usb_device *udev;
35 struct list_head list; 36 struct list_head list;
36 37
37 struct usbip_device ud; 38 struct usbip_device ud;
diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c
index b186b5fed2b9..a7ce51cc8909 100644
--- a/drivers/staging/usbip/stub_dev.c
+++ b/drivers/staging/usbip/stub_dev.c
@@ -258,10 +258,11 @@ static void stub_shutdown_connection(struct usbip_device *ud)
258static void stub_device_reset(struct usbip_device *ud) 258static void stub_device_reset(struct usbip_device *ud)
259{ 259{
260 struct stub_device *sdev = container_of(ud, struct stub_device, ud); 260 struct stub_device *sdev = container_of(ud, struct stub_device, ud);
261 struct usb_device *udev = interface_to_usbdev(sdev->interface); 261 struct usb_device *udev = sdev->udev;
262 int ret; 262 int ret;
263 263
264 usbip_udbg("device reset"); 264 usbip_udbg("device reset");
265
265 ret = usb_lock_device_for_reset(udev, sdev->interface); 266 ret = usb_lock_device_for_reset(udev, sdev->interface);
266 if (ret < 0) { 267 if (ret < 0) {
267 dev_err(&udev->dev, "lock for reset\n"); 268 dev_err(&udev->dev, "lock for reset\n");
@@ -309,7 +310,8 @@ static void stub_device_unusable(struct usbip_device *ud)
309 * 310 *
310 * Allocates and initializes a new stub_device struct. 311 * Allocates and initializes a new stub_device struct.
311 */ 312 */
312static struct stub_device *stub_device_alloc(struct usb_interface *interface) 313static struct stub_device *stub_device_alloc(struct usb_device *udev,
314 struct usb_interface *interface)
313{ 315{
314 struct stub_device *sdev; 316 struct stub_device *sdev;
315 int busnum = interface_to_busnum(interface); 317 int busnum = interface_to_busnum(interface);
@@ -324,7 +326,8 @@ static struct stub_device *stub_device_alloc(struct usb_interface *interface)
324 return NULL; 326 return NULL;
325 } 327 }
326 328
327 sdev->interface = interface; 329 sdev->interface = usb_get_intf(interface);
330 sdev->udev = usb_get_dev(udev);
328 331
329 /* 332 /*
330 * devid is defined with devnum when this driver is first allocated. 333 * devid is defined with devnum when this driver is first allocated.
@@ -450,11 +453,12 @@ static int stub_probe(struct usb_interface *interface,
450 return err; 453 return err;
451 } 454 }
452 455
456 usb_get_intf(interface);
453 return 0; 457 return 0;
454 } 458 }
455 459
456 /* ok. this is my device. */ 460 /* ok. this is my device. */
457 sdev = stub_device_alloc(interface); 461 sdev = stub_device_alloc(udev, interface);
458 if (!sdev) 462 if (!sdev)
459 return -ENOMEM; 463 return -ENOMEM;
460 464
@@ -476,6 +480,8 @@ static int stub_probe(struct usb_interface *interface,
476 dev_err(&interface->dev, "create sysfs files for %s\n", 480 dev_err(&interface->dev, "create sysfs files for %s\n",
477 udev_busid); 481 udev_busid);
478 usb_set_intfdata(interface, NULL); 482 usb_set_intfdata(interface, NULL);
483 usb_put_intf(interface);
484
479 busid_priv->interf_count = 0; 485 busid_priv->interf_count = 0;
480 486
481 busid_priv->sdev = NULL; 487 busid_priv->sdev = NULL;
@@ -545,6 +551,7 @@ static void stub_disconnect(struct usb_interface *interface)
545 if (busid_priv->interf_count > 1) { 551 if (busid_priv->interf_count > 1) {
546 busid_priv->interf_count--; 552 busid_priv->interf_count--;
547 shutdown_busid(busid_priv); 553 shutdown_busid(busid_priv);
554 usb_put_intf(interface);
548 return; 555 return;
549 } 556 }
550 557
@@ -554,6 +561,9 @@ static void stub_disconnect(struct usb_interface *interface)
554 /* 1. shutdown the current connection */ 561 /* 1. shutdown the current connection */
555 shutdown_busid(busid_priv); 562 shutdown_busid(busid_priv);
556 563
564 usb_put_dev(sdev->udev);
565 usb_put_intf(interface);
566
557 /* 3. free sdev */ 567 /* 3. free sdev */
558 busid_priv->sdev = NULL; 568 busid_priv->sdev = NULL;
559 stub_device_free(sdev); 569 stub_device_free(sdev);
diff --git a/drivers/staging/usbip/stub_rx.c b/drivers/staging/usbip/stub_rx.c
index 3de6fd2539dc..ae6ac82754a4 100644
--- a/drivers/staging/usbip/stub_rx.c
+++ b/drivers/staging/usbip/stub_rx.c
@@ -364,7 +364,7 @@ static struct stub_priv *stub_priv_alloc(struct stub_device *sdev,
364 364
365static int get_pipe(struct stub_device *sdev, int epnum, int dir) 365static int get_pipe(struct stub_device *sdev, int epnum, int dir)
366{ 366{
367 struct usb_device *udev = interface_to_usbdev(sdev->interface); 367 struct usb_device *udev = sdev->udev;
368 struct usb_host_endpoint *ep; 368 struct usb_host_endpoint *ep;
369 struct usb_endpoint_descriptor *epd = NULL; 369 struct usb_endpoint_descriptor *epd = NULL;
370 370
@@ -484,7 +484,7 @@ static void stub_recv_cmd_submit(struct stub_device *sdev,
484 int ret; 484 int ret;
485 struct stub_priv *priv; 485 struct stub_priv *priv;
486 struct usbip_device *ud = &sdev->ud; 486 struct usbip_device *ud = &sdev->ud;
487 struct usb_device *udev = interface_to_usbdev(sdev->interface); 487 struct usb_device *udev = sdev->udev;
488 int pipe = get_pipe(sdev, pdu->base.ep, pdu->base.direction); 488 int pipe = get_pipe(sdev, pdu->base.ep, pdu->base.direction);
489 489
490 490
diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
index 41a1fe5138f4..afc3b1a71881 100644
--- a/drivers/staging/usbip/vhci.h
+++ b/drivers/staging/usbip/vhci.h
@@ -100,9 +100,6 @@ struct vhci_hcd {
100 * But, the index of this array begins from 0. 100 * But, the index of this array begins from 0.
101 */ 101 */
102 struct vhci_device vdev[VHCI_NPORTS]; 102 struct vhci_device vdev[VHCI_NPORTS];
103
104 /* vhci_device which has not been assiged its address yet */
105 int pending_port;
106}; 103};
107 104
108 105
@@ -119,6 +116,9 @@ void rh_port_disconnect(int rhport);
119void vhci_rx_loop(struct usbip_task *ut); 116void vhci_rx_loop(struct usbip_task *ut);
120void vhci_tx_loop(struct usbip_task *ut); 117void vhci_tx_loop(struct usbip_task *ut);
121 118
119struct urb *pickup_urb_and_free_priv(struct vhci_device *vdev,
120 __u32 seqnum);
121
122#define hardware (&the_controller->pdev.dev) 122#define hardware (&the_controller->pdev.dev)
123 123
124static inline struct vhci_device *port_to_vdev(__u32 port) 124static inline struct vhci_device *port_to_vdev(__u32 port)
diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
index 08bd26a245d5..a35fe61268de 100644
--- a/drivers/staging/usbip/vhci_hcd.c
+++ b/drivers/staging/usbip/vhci_hcd.c
@@ -138,8 +138,6 @@ void rh_port_connect(int rhport, enum usb_device_speed speed)
138 * the_controller->vdev[rhport].ud.status = VDEV_CONNECT; 138 * the_controller->vdev[rhport].ud.status = VDEV_CONNECT;
139 * spin_unlock(&the_controller->vdev[rhport].ud.lock); */ 139 * spin_unlock(&the_controller->vdev[rhport].ud.lock); */
140 140
141 the_controller->pending_port = rhport;
142
143 spin_unlock_irqrestore(&the_controller->lock, flags); 141 spin_unlock_irqrestore(&the_controller->lock, flags);
144 142
145 usb_hcd_poll_rh_status(vhci_to_hcd(the_controller)); 143 usb_hcd_poll_rh_status(vhci_to_hcd(the_controller));
@@ -559,6 +557,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
559 struct device *dev = &urb->dev->dev; 557 struct device *dev = &urb->dev->dev;
560 int ret = 0; 558 int ret = 0;
561 unsigned long flags; 559 unsigned long flags;
560 struct vhci_device *vdev;
562 561
563 usbip_dbg_vhci_hc("enter, usb_hcd %p urb %p mem_flags %d\n", 562 usbip_dbg_vhci_hc("enter, usb_hcd %p urb %p mem_flags %d\n",
564 hcd, urb, mem_flags); 563 hcd, urb, mem_flags);
@@ -574,6 +573,18 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
574 return urb->status; 573 return urb->status;
575 } 574 }
576 575
576 vdev = port_to_vdev(urb->dev->portnum-1);
577
578 /* refuse enqueue for dead connection */
579 spin_lock(&vdev->ud.lock);
580 if (vdev->ud.status == VDEV_ST_NULL || vdev->ud.status == VDEV_ST_ERROR) {
581 usbip_uerr("enqueue for inactive port %d\n", vdev->rhport);
582 spin_unlock(&vdev->ud.lock);
583 spin_unlock_irqrestore(&the_controller->lock, flags);
584 return -ENODEV;
585 }
586 spin_unlock(&vdev->ud.lock);
587
577 ret = usb_hcd_link_urb_to_ep(hcd, urb); 588 ret = usb_hcd_link_urb_to_ep(hcd, urb);
578 if (ret) 589 if (ret)
579 goto no_need_unlink; 590 goto no_need_unlink;
@@ -592,8 +603,6 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
592 __u8 type = usb_pipetype(urb->pipe); 603 __u8 type = usb_pipetype(urb->pipe);
593 struct usb_ctrlrequest *ctrlreq = 604 struct usb_ctrlrequest *ctrlreq =
594 (struct usb_ctrlrequest *) urb->setup_packet; 605 (struct usb_ctrlrequest *) urb->setup_packet;
595 struct vhci_device *vdev =
596 port_to_vdev(the_controller->pending_port);
597 606
598 if (type != PIPE_CONTROL || !ctrlreq) { 607 if (type != PIPE_CONTROL || !ctrlreq) {
599 dev_err(dev, "invalid request to devnum 0\n"); 608 dev_err(dev, "invalid request to devnum 0\n");
@@ -607,7 +616,9 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
607 dev_info(dev, "SetAddress Request (%d) to port %d\n", 616 dev_info(dev, "SetAddress Request (%d) to port %d\n",
608 ctrlreq->wValue, vdev->rhport); 617 ctrlreq->wValue, vdev->rhport);
609 618
610 vdev->udev = urb->dev; 619 if (vdev->udev)
620 usb_put_dev(vdev->udev);
621 vdev->udev = usb_get_dev(urb->dev);
611 622
612 spin_lock(&vdev->ud.lock); 623 spin_lock(&vdev->ud.lock);
613 vdev->ud.status = VDEV_ST_USED; 624 vdev->ud.status = VDEV_ST_USED;
@@ -627,8 +638,9 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
627 "Get_Descriptor to device 0 " 638 "Get_Descriptor to device 0 "
628 "(get max pipe size)\n"); 639 "(get max pipe size)\n");
629 640
630 /* FIXME: reference count? (usb_get_dev()) */ 641 if (vdev->udev)
631 vdev->udev = urb->dev; 642 usb_put_dev(vdev->udev);
643 vdev->udev = usb_get_dev(urb->dev);
632 goto out; 644 goto out;
633 645
634 default: 646 default:
@@ -805,7 +817,6 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
805 return 0; 817 return 0;
806} 818}
807 819
808
809static void vhci_device_unlink_cleanup(struct vhci_device *vdev) 820static void vhci_device_unlink_cleanup(struct vhci_device *vdev)
810{ 821{
811 struct vhci_unlink *unlink, *tmp; 822 struct vhci_unlink *unlink, *tmp;
@@ -813,11 +824,34 @@ static void vhci_device_unlink_cleanup(struct vhci_device *vdev)
813 spin_lock(&vdev->priv_lock); 824 spin_lock(&vdev->priv_lock);
814 825
815 list_for_each_entry_safe(unlink, tmp, &vdev->unlink_tx, list) { 826 list_for_each_entry_safe(unlink, tmp, &vdev->unlink_tx, list) {
827 usbip_uinfo("unlink cleanup tx %lu\n", unlink->unlink_seqnum);
816 list_del(&unlink->list); 828 list_del(&unlink->list);
817 kfree(unlink); 829 kfree(unlink);
818 } 830 }
819 831
820 list_for_each_entry_safe(unlink, tmp, &vdev->unlink_rx, list) { 832 list_for_each_entry_safe(unlink, tmp, &vdev->unlink_rx, list) {
833 struct urb *urb;
834
835 /* give back URB of unanswered unlink request */
836 usbip_uinfo("unlink cleanup rx %lu\n", unlink->unlink_seqnum);
837
838 urb = pickup_urb_and_free_priv(vdev, unlink->unlink_seqnum);
839 if (!urb) {
840 usbip_uinfo("the urb (seqnum %lu) was already given back\n",
841 unlink->unlink_seqnum);
842 list_del(&unlink->list);
843 kfree(unlink);
844 continue;
845 }
846
847 urb->status = -ENODEV;
848
849 spin_lock(&the_controller->lock);
850 usb_hcd_unlink_urb_from_ep(vhci_to_hcd(the_controller), urb);
851 spin_unlock(&the_controller->lock);
852
853 usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb, urb->status);
854
821 list_del(&unlink->list); 855 list_del(&unlink->list);
822 kfree(unlink); 856 kfree(unlink);
823 } 857 }
@@ -887,6 +921,10 @@ static void vhci_device_reset(struct usbip_device *ud)
887 vdev->speed = 0; 921 vdev->speed = 0;
888 vdev->devid = 0; 922 vdev->devid = 0;
889 923
924 if (vdev->udev)
925 usb_put_dev(vdev->udev);
926 vdev->udev = NULL;
927
890 ud->tcp_socket = NULL; 928 ud->tcp_socket = NULL;
891 929
892 ud->status = VDEV_ST_NULL; 930 ud->status = VDEV_ST_NULL;
diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
index 8147d7202b2d..bf6991470941 100644
--- a/drivers/staging/usbip/vhci_rx.c
+++ b/drivers/staging/usbip/vhci_rx.c
@@ -23,16 +23,14 @@
23#include "vhci.h" 23#include "vhci.h"
24 24
25 25
26/* get URB from transmitted urb queue */ 26/* get URB from transmitted urb queue. caller must hold vdev->priv_lock */
27static struct urb *pickup_urb_and_free_priv(struct vhci_device *vdev, 27struct urb *pickup_urb_and_free_priv(struct vhci_device *vdev,
28 __u32 seqnum) 28 __u32 seqnum)
29{ 29{
30 struct vhci_priv *priv, *tmp; 30 struct vhci_priv *priv, *tmp;
31 struct urb *urb = NULL; 31 struct urb *urb = NULL;
32 int status; 32 int status;
33 33
34 spin_lock(&vdev->priv_lock);
35
36 list_for_each_entry_safe(priv, tmp, &vdev->priv_rx, list) { 34 list_for_each_entry_safe(priv, tmp, &vdev->priv_rx, list) {
37 if (priv->seqnum == seqnum) { 35 if (priv->seqnum == seqnum) {
38 urb = priv->urb; 36 urb = priv->urb;
@@ -63,8 +61,6 @@ static struct urb *pickup_urb_and_free_priv(struct vhci_device *vdev,
63 } 61 }
64 } 62 }
65 63
66 spin_unlock(&vdev->priv_lock);
67
68 return urb; 64 return urb;
69} 65}
70 66
@@ -74,9 +70,11 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
74 struct usbip_device *ud = &vdev->ud; 70 struct usbip_device *ud = &vdev->ud;
75 struct urb *urb; 71 struct urb *urb;
76 72
73 spin_lock(&vdev->priv_lock);
77 74
78 urb = pickup_urb_and_free_priv(vdev, pdu->base.seqnum); 75 urb = pickup_urb_and_free_priv(vdev, pdu->base.seqnum);
79 76
77 spin_unlock(&vdev->priv_lock);
80 78
81 if (!urb) { 79 if (!urb) {
82 usbip_uerr("cannot find a urb of seqnum %u\n", 80 usbip_uerr("cannot find a urb of seqnum %u\n",
@@ -161,7 +159,12 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev,
161 return; 159 return;
162 } 160 }
163 161
162 spin_lock(&vdev->priv_lock);
163
164 urb = pickup_urb_and_free_priv(vdev, unlink->unlink_seqnum); 164 urb = pickup_urb_and_free_priv(vdev, unlink->unlink_seqnum);
165
166 spin_unlock(&vdev->priv_lock);
167
165 if (!urb) { 168 if (!urb) {
166 /* 169 /*
167 * I get the result of a unlink request. But, it seems that I 170 * I get the result of a unlink request. But, it seems that I
@@ -190,6 +193,19 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev,
190 return; 193 return;
191} 194}
192 195
196static int vhci_priv_tx_empty(struct vhci_device *vdev)
197{
198 int empty = 0;
199
200 spin_lock(&vdev->priv_lock);
201
202 empty = list_empty(&vdev->priv_rx);
203
204 spin_unlock(&vdev->priv_lock);
205
206 return empty;
207}
208
193/* recv a pdu */ 209/* recv a pdu */
194static void vhci_rx_pdu(struct usbip_device *ud) 210static void vhci_rx_pdu(struct usbip_device *ud)
195{ 211{
@@ -202,11 +218,29 @@ static void vhci_rx_pdu(struct usbip_device *ud)
202 218
203 memset(&pdu, 0, sizeof(pdu)); 219 memset(&pdu, 0, sizeof(pdu));
204 220
205
206 /* 1. receive a pdu header */ 221 /* 1. receive a pdu header */
207 ret = usbip_xmit(0, ud->tcp_socket, (char *) &pdu, sizeof(pdu), 0); 222 ret = usbip_xmit(0, ud->tcp_socket, (char *) &pdu, sizeof(pdu), 0);
223 if (ret < 0) {
224 if (ret == -ECONNRESET)
225 usbip_uinfo("connection reset by peer\n");
226 else if (ret == -EAGAIN) {
227 /* ignore if connection was idle */
228 if (vhci_priv_tx_empty(vdev))
229 return;
230 usbip_uinfo("connection timed out with pending urbs\n");
231 } else if (ret != -ERESTARTSYS)
232 usbip_uinfo("xmit failed %d\n", ret);
233
234 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
235 return;
236 }
237 if (ret == 0) {
238 usbip_uinfo("connection closed");
239 usbip_event_add(ud, VDEV_EVENT_DOWN);
240 return;
241 }
208 if (ret != sizeof(pdu)) { 242 if (ret != sizeof(pdu)) {
209 usbip_uerr("receiving pdu failed! size is %d, should be %d\n", 243 usbip_uerr("received pdu size is %d, should be %d\n",
210 ret, (unsigned int)sizeof(pdu)); 244 ret, (unsigned int)sizeof(pdu));
211 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP); 245 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
212 return; 246 return;
diff --git a/drivers/staging/vme/bridges/Module.symvers b/drivers/staging/vme/bridges/Module.symvers
deleted file mode 100644
index e69de29bb2d1..000000000000
--- a/drivers/staging/vme/bridges/Module.symvers
+++ /dev/null
diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c
index 7016fdd2509f..e19b932492e1 100644
--- a/drivers/staging/xgifb/vb_setmode.c
+++ b/drivers/staging/xgifb/vb_setmode.c
@@ -3954,8 +3954,8 @@ void XGI_GetCRT2ResInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
3954unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo) 3954unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo)
3955{ 3955{
3956 3956
3957 if ((((pVBInfo->VBInfo & SetCRT2ToLCD) | SetCRT2ToLCDA)) 3957 if ((pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) &&
3958 && (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */ 3958 (pVBInfo->LCDInfo & SetLCDDualLink)) /* shampoo0129 */
3959 return 1; 3959 return 1;
3960 3960
3961 return 0; 3961 return 0;
@@ -8773,7 +8773,7 @@ unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
8773 8773
8774 if (pVBInfo->IF_DEF_LVDS == 0) { 8774 if (pVBInfo->IF_DEF_LVDS == 0) {
8775 CRT2Index = CRT2Index >> 6; /* for LCD */ 8775 CRT2Index = CRT2Index >> 6; /* for LCD */
8776 if (((pVBInfo->VBInfo & SetCRT2ToLCD) | SetCRT2ToLCDA)) { /*301b*/ 8776 if (pVBInfo->VBInfo & (SetCRT2ToLCD | SetCRT2ToLCDA)) { /*301b*/
8777 if (pVBInfo->LCDResInfo != Panel1024x768) 8777 if (pVBInfo->LCDResInfo != Panel1024x768)
8778 VCLKIndex = LCDXlat2VCLK[CRT2Index]; 8778 VCLKIndex = LCDXlat2VCLK[CRT2Index];
8779 else 8779 else
diff --git a/drivers/tty/Makefile b/drivers/tty/Makefile
index c43ef48b1a0f..396277216e4f 100644
--- a/drivers/tty/Makefile
+++ b/drivers/tty/Makefile
@@ -9,3 +9,5 @@ obj-$(CONFIG_N_GSM) += n_gsm.o
9obj-$(CONFIG_R3964) += n_r3964.o 9obj-$(CONFIG_R3964) += n_r3964.o
10 10
11obj-y += vt/ 11obj-y += vt/
12obj-$(CONFIG_HVC_DRIVER) += hvc/
13obj-y += serial/
diff --git a/drivers/tty/hvc/Makefile b/drivers/tty/hvc/Makefile
new file mode 100644
index 000000000000..e6bed5f177ff
--- /dev/null
+++ b/drivers/tty/hvc/Makefile
@@ -0,0 +1,13 @@
1obj-$(CONFIG_HVC_CONSOLE) += hvc_vio.o hvsi.o
2obj-$(CONFIG_HVC_ISERIES) += hvc_iseries.o
3obj-$(CONFIG_HVC_RTAS) += hvc_rtas.o
4obj-$(CONFIG_HVC_TILE) += hvc_tile.o
5obj-$(CONFIG_HVC_DCC) += hvc_dcc.o
6obj-$(CONFIG_HVC_BEAT) += hvc_beat.o
7obj-$(CONFIG_HVC_DRIVER) += hvc_console.o
8obj-$(CONFIG_HVC_IRQ) += hvc_irq.o
9obj-$(CONFIG_HVC_XEN) += hvc_xen.o
10obj-$(CONFIG_HVC_IUCV) += hvc_iucv.o
11obj-$(CONFIG_HVC_UDBG) += hvc_udbg.o
12obj-$(CONFIG_HVCS) += hvcs.o
13obj-$(CONFIG_VIRTIO_CONSOLE) += virtio_console.o
diff --git a/drivers/char/hvc_beat.c b/drivers/tty/hvc/hvc_beat.c
index 5fe4631e2a61..5fe4631e2a61 100644
--- a/drivers/char/hvc_beat.c
+++ b/drivers/tty/hvc/hvc_beat.c
diff --git a/drivers/char/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index e9cba13ee800..e9cba13ee800 100644
--- a/drivers/char/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
diff --git a/drivers/char/hvc_console.h b/drivers/tty/hvc/hvc_console.h
index 54381eba4e4a..54381eba4e4a 100644
--- a/drivers/char/hvc_console.h
+++ b/drivers/tty/hvc/hvc_console.h
diff --git a/drivers/char/hvc_dcc.c b/drivers/tty/hvc/hvc_dcc.c
index 6470f63deb4b..6470f63deb4b 100644
--- a/drivers/char/hvc_dcc.c
+++ b/drivers/tty/hvc/hvc_dcc.c
diff --git a/drivers/char/hvc_irq.c b/drivers/tty/hvc/hvc_irq.c
index 2623e177e8d6..2623e177e8d6 100644
--- a/drivers/char/hvc_irq.c
+++ b/drivers/tty/hvc/hvc_irq.c
diff --git a/drivers/char/hvc_iseries.c b/drivers/tty/hvc/hvc_iseries.c
index 21c54955084e..21c54955084e 100644
--- a/drivers/char/hvc_iseries.c
+++ b/drivers/tty/hvc/hvc_iseries.c
diff --git a/drivers/char/hvc_iucv.c b/drivers/tty/hvc/hvc_iucv.c
index c3425bb3a1f6..c3425bb3a1f6 100644
--- a/drivers/char/hvc_iucv.c
+++ b/drivers/tty/hvc/hvc_iucv.c
diff --git a/drivers/char/hvc_rtas.c b/drivers/tty/hvc/hvc_rtas.c
index 61c4a61558d9..61c4a61558d9 100644
--- a/drivers/char/hvc_rtas.c
+++ b/drivers/tty/hvc/hvc_rtas.c
diff --git a/drivers/char/hvc_tile.c b/drivers/tty/hvc/hvc_tile.c
index 7a84a0595477..7a84a0595477 100644
--- a/drivers/char/hvc_tile.c
+++ b/drivers/tty/hvc/hvc_tile.c
diff --git a/drivers/char/hvc_udbg.c b/drivers/tty/hvc/hvc_udbg.c
index b0957e61a7be..b0957e61a7be 100644
--- a/drivers/char/hvc_udbg.c
+++ b/drivers/tty/hvc/hvc_udbg.c
diff --git a/drivers/char/hvc_vio.c b/drivers/tty/hvc/hvc_vio.c
index 5e2f52b33327..5e2f52b33327 100644
--- a/drivers/char/hvc_vio.c
+++ b/drivers/tty/hvc/hvc_vio.c
diff --git a/drivers/char/hvc_xen.c b/drivers/tty/hvc/hvc_xen.c
index 3740e327f180..3740e327f180 100644
--- a/drivers/char/hvc_xen.c
+++ b/drivers/tty/hvc/hvc_xen.c
diff --git a/drivers/char/hvcs.c b/drivers/tty/hvc/hvcs.c
index bedc6c1b6fa5..bedc6c1b6fa5 100644
--- a/drivers/char/hvcs.c
+++ b/drivers/tty/hvc/hvcs.c
diff --git a/drivers/char/hvsi.c b/drivers/tty/hvc/hvsi.c
index 67a75a502c01..67a75a502c01 100644
--- a/drivers/char/hvsi.c
+++ b/drivers/tty/hvc/hvsi.c
diff --git a/drivers/char/virtio_console.c b/drivers/tty/hvc/virtio_console.c
index 896a2ced1d27..896a2ced1d27 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/tty/hvc/virtio_console.c
diff --git a/drivers/tty/n_hdlc.c b/drivers/tty/n_hdlc.c
index 47d32281032c..52fc0c9a6364 100644
--- a/drivers/tty/n_hdlc.c
+++ b/drivers/tty/n_hdlc.c
@@ -581,8 +581,9 @@ static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
581 __u8 __user *buf, size_t nr) 581 __u8 __user *buf, size_t nr)
582{ 582{
583 struct n_hdlc *n_hdlc = tty2n_hdlc(tty); 583 struct n_hdlc *n_hdlc = tty2n_hdlc(tty);
584 int ret; 584 int ret = 0;
585 struct n_hdlc_buf *rbuf; 585 struct n_hdlc_buf *rbuf;
586 DECLARE_WAITQUEUE(wait, current);
586 587
587 if (debuglevel >= DEBUG_LEVEL_INFO) 588 if (debuglevel >= DEBUG_LEVEL_INFO)
588 printk("%s(%d)n_hdlc_tty_read() called\n",__FILE__,__LINE__); 589 printk("%s(%d)n_hdlc_tty_read() called\n",__FILE__,__LINE__);
@@ -598,57 +599,55 @@ static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
598 return -EFAULT; 599 return -EFAULT;
599 } 600 }
600 601
601 tty_lock(); 602 add_wait_queue(&tty->read_wait, &wait);
602 603
603 for (;;) { 604 for (;;) {
604 if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) { 605 if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) {
605 tty_unlock(); 606 ret = -EIO;
606 return -EIO; 607 break;
607 } 608 }
609 if (tty_hung_up_p(file))
610 break;
608 611
609 n_hdlc = tty2n_hdlc (tty); 612 set_current_state(TASK_INTERRUPTIBLE);
610 if (!n_hdlc || n_hdlc->magic != HDLC_MAGIC ||
611 tty != n_hdlc->tty) {
612 tty_unlock();
613 return 0;
614 }
615 613
616 rbuf = n_hdlc_buf_get(&n_hdlc->rx_buf_list); 614 rbuf = n_hdlc_buf_get(&n_hdlc->rx_buf_list);
617 if (rbuf) 615 if (rbuf) {
616 if (rbuf->count > nr) {
617 /* too large for caller's buffer */
618 ret = -EOVERFLOW;
619 } else {
620 if (copy_to_user(buf, rbuf->buf, rbuf->count))
621 ret = -EFAULT;
622 else
623 ret = rbuf->count;
624 }
625
626 if (n_hdlc->rx_free_buf_list.count >
627 DEFAULT_RX_BUF_COUNT)
628 kfree(rbuf);
629 else
630 n_hdlc_buf_put(&n_hdlc->rx_free_buf_list, rbuf);
618 break; 631 break;
632 }
619 633
620 /* no data */ 634 /* no data */
621 if (file->f_flags & O_NONBLOCK) { 635 if (file->f_flags & O_NONBLOCK) {
622 tty_unlock(); 636 ret = -EAGAIN;
623 return -EAGAIN; 637 break;
624 } 638 }
625 639
626 interruptible_sleep_on (&tty->read_wait); 640 schedule();
641
627 if (signal_pending(current)) { 642 if (signal_pending(current)) {
628 tty_unlock(); 643 ret = -EINTR;
629 return -EINTR; 644 break;
630 } 645 }
631 } 646 }
632 647
633 if (rbuf->count > nr) 648 remove_wait_queue(&tty->read_wait, &wait);
634 /* frame too large for caller's buffer (discard frame) */ 649 __set_current_state(TASK_RUNNING);
635 ret = -EOVERFLOW; 650
636 else {
637 /* Copy the data to the caller's buffer */
638 if (copy_to_user(buf, rbuf->buf, rbuf->count))
639 ret = -EFAULT;
640 else
641 ret = rbuf->count;
642 }
643
644 /* return HDLC buffer to free list unless the free list */
645 /* count has exceeded the default value, in which case the */
646 /* buffer is freed back to the OS to conserve memory */
647 if (n_hdlc->rx_free_buf_list.count > DEFAULT_RX_BUF_COUNT)
648 kfree(rbuf);
649 else
650 n_hdlc_buf_put(&n_hdlc->rx_free_buf_list,rbuf);
651 tty_unlock();
652 return ret; 651 return ret;
653 652
654} /* end of n_hdlc_tty_read() */ 653} /* end of n_hdlc_tty_read() */
@@ -691,14 +690,15 @@ static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
691 count = maxframe; 690 count = maxframe;
692 } 691 }
693 692
694 tty_lock();
695
696 add_wait_queue(&tty->write_wait, &wait); 693 add_wait_queue(&tty->write_wait, &wait);
697 set_current_state(TASK_INTERRUPTIBLE); 694
695 for (;;) {
696 set_current_state(TASK_INTERRUPTIBLE);
698 697
699 /* Allocate transmit buffer */ 698 tbuf = n_hdlc_buf_get(&n_hdlc->tx_free_buf_list);
700 /* sleep until transmit buffer available */ 699 if (tbuf)
701 while (!(tbuf = n_hdlc_buf_get(&n_hdlc->tx_free_buf_list))) { 700 break;
701
702 if (file->f_flags & O_NONBLOCK) { 702 if (file->f_flags & O_NONBLOCK) {
703 error = -EAGAIN; 703 error = -EAGAIN;
704 break; 704 break;
@@ -719,7 +719,7 @@ static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
719 } 719 }
720 } 720 }
721 721
722 set_current_state(TASK_RUNNING); 722 __set_current_state(TASK_RUNNING);
723 remove_wait_queue(&tty->write_wait, &wait); 723 remove_wait_queue(&tty->write_wait, &wait);
724 724
725 if (!error) { 725 if (!error) {
@@ -731,7 +731,7 @@ static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
731 n_hdlc_buf_put(&n_hdlc->tx_buf_list,tbuf); 731 n_hdlc_buf_put(&n_hdlc->tx_buf_list,tbuf);
732 n_hdlc_send_frames(n_hdlc,tty); 732 n_hdlc_send_frames(n_hdlc,tty);
733 } 733 }
734 tty_unlock(); 734
735 return error; 735 return error;
736 736
737} /* end of n_hdlc_tty_write() */ 737} /* end of n_hdlc_tty_write() */
diff --git a/drivers/serial/21285.c b/drivers/tty/serial/21285.c
index d89aa38c5cf0..d89aa38c5cf0 100644
--- a/drivers/serial/21285.c
+++ b/drivers/tty/serial/21285.c
diff --git a/drivers/serial/68328serial.c b/drivers/tty/serial/68328serial.c
index be0ebce36e54..be0ebce36e54 100644
--- a/drivers/serial/68328serial.c
+++ b/drivers/tty/serial/68328serial.c
diff --git a/drivers/serial/68328serial.h b/drivers/tty/serial/68328serial.h
index 664ceb0a158c..664ceb0a158c 100644
--- a/drivers/serial/68328serial.h
+++ b/drivers/tty/serial/68328serial.h
diff --git a/drivers/serial/68360serial.c b/drivers/tty/serial/68360serial.c
index 88b13356ec10..88b13356ec10 100644
--- a/drivers/serial/68360serial.c
+++ b/drivers/tty/serial/68360serial.c
diff --git a/drivers/serial/8250.c b/drivers/tty/serial/8250.c
index b25e6e490530..3975df6f7fdb 100644
--- a/drivers/serial/8250.c
+++ b/drivers/tty/serial/8250.c
@@ -236,7 +236,8 @@ static const struct serial8250_config uart_config[] = {
236 .fifo_size = 128, 236 .fifo_size = 128,
237 .tx_loadsz = 128, 237 .tx_loadsz = 128,
238 .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10, 238 .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10,
239 .flags = UART_CAP_FIFO | UART_CAP_EFR | UART_CAP_SLEEP, 239 /* UART_CAP_EFR breaks billionon CF bluetooth card. */
240 .flags = UART_CAP_FIFO | UART_CAP_SLEEP,
240 }, 241 },
241 [PORT_16654] = { 242 [PORT_16654] = {
242 .name = "ST16654", 243 .name = "ST16654",
diff --git a/drivers/serial/8250.h b/drivers/tty/serial/8250.h
index 6e19ea3e48d5..6e19ea3e48d5 100644
--- a/drivers/serial/8250.h
+++ b/drivers/tty/serial/8250.h
diff --git a/drivers/serial/8250_accent.c b/drivers/tty/serial/8250_accent.c
index 9c10262f2469..9c10262f2469 100644
--- a/drivers/serial/8250_accent.c
+++ b/drivers/tty/serial/8250_accent.c
diff --git a/drivers/serial/8250_acorn.c b/drivers/tty/serial/8250_acorn.c
index b0ce8c56f1a4..b0ce8c56f1a4 100644
--- a/drivers/serial/8250_acorn.c
+++ b/drivers/tty/serial/8250_acorn.c
diff --git a/drivers/serial/8250_boca.c b/drivers/tty/serial/8250_boca.c
index 3bfe0f7b26fb..3bfe0f7b26fb 100644
--- a/drivers/serial/8250_boca.c
+++ b/drivers/tty/serial/8250_boca.c
diff --git a/drivers/serial/8250_early.c b/drivers/tty/serial/8250_early.c
index eaafb98debed..eaafb98debed 100644
--- a/drivers/serial/8250_early.c
+++ b/drivers/tty/serial/8250_early.c
diff --git a/drivers/serial/8250_exar_st16c554.c b/drivers/tty/serial/8250_exar_st16c554.c
index 567143ace159..567143ace159 100644
--- a/drivers/serial/8250_exar_st16c554.c
+++ b/drivers/tty/serial/8250_exar_st16c554.c
diff --git a/drivers/serial/8250_fourport.c b/drivers/tty/serial/8250_fourport.c
index 6375d68b7913..6375d68b7913 100644
--- a/drivers/serial/8250_fourport.c
+++ b/drivers/tty/serial/8250_fourport.c
diff --git a/drivers/serial/8250_gsc.c b/drivers/tty/serial/8250_gsc.c
index d8c0ffbfa6e3..d8c0ffbfa6e3 100644
--- a/drivers/serial/8250_gsc.c
+++ b/drivers/tty/serial/8250_gsc.c
diff --git a/drivers/serial/8250_hp300.c b/drivers/tty/serial/8250_hp300.c
index c13438c93012..c13438c93012 100644
--- a/drivers/serial/8250_hp300.c
+++ b/drivers/tty/serial/8250_hp300.c
diff --git a/drivers/serial/8250_hub6.c b/drivers/tty/serial/8250_hub6.c
index 7609150e7d5e..7609150e7d5e 100644
--- a/drivers/serial/8250_hub6.c
+++ b/drivers/tty/serial/8250_hub6.c
diff --git a/drivers/serial/8250_mca.c b/drivers/tty/serial/8250_mca.c
index d10be944ad44..d10be944ad44 100644
--- a/drivers/serial/8250_mca.c
+++ b/drivers/tty/serial/8250_mca.c
diff --git a/drivers/serial/8250_pci.c b/drivers/tty/serial/8250_pci.c
index 8b8930f700b5..8b8930f700b5 100644
--- a/drivers/serial/8250_pci.c
+++ b/drivers/tty/serial/8250_pci.c
diff --git a/drivers/serial/8250_pnp.c b/drivers/tty/serial/8250_pnp.c
index 4822cb50cd0f..4822cb50cd0f 100644
--- a/drivers/serial/8250_pnp.c
+++ b/drivers/tty/serial/8250_pnp.c
diff --git a/drivers/serial/Kconfig b/drivers/tty/serial/Kconfig
index c1df7676a73d..2b8334601c8b 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -81,7 +81,7 @@ config SERIAL_8250_GSC
81 default SERIAL_8250 81 default SERIAL_8250
82 82
83config SERIAL_8250_PCI 83config SERIAL_8250_PCI
84 tristate "8250/16550 PCI device support" if EMBEDDED 84 tristate "8250/16550 PCI device support" if EXPERT
85 depends on SERIAL_8250 && PCI 85 depends on SERIAL_8250 && PCI
86 default SERIAL_8250 86 default SERIAL_8250
87 help 87 help
@@ -90,7 +90,7 @@ config SERIAL_8250_PCI
90 Saves about 9K. 90 Saves about 9K.
91 91
92config SERIAL_8250_PNP 92config SERIAL_8250_PNP
93 tristate "8250/16550 PNP device support" if EMBEDDED 93 tristate "8250/16550 PNP device support" if EXPERT
94 depends on SERIAL_8250 && PNP 94 depends on SERIAL_8250 && PNP
95 default SERIAL_8250 95 default SERIAL_8250
96 help 96 help
@@ -1518,6 +1518,7 @@ config SERIAL_BCM63XX_CONSOLE
1518config SERIAL_GRLIB_GAISLER_APBUART 1518config SERIAL_GRLIB_GAISLER_APBUART
1519 tristate "GRLIB APBUART serial support" 1519 tristate "GRLIB APBUART serial support"
1520 depends on OF 1520 depends on OF
1521 select SERIAL_CORE
1521 ---help--- 1522 ---help---
1522 Add support for the GRLIB APBUART serial port. 1523 Add support for the GRLIB APBUART serial port.
1523 1524
diff --git a/drivers/serial/Makefile b/drivers/tty/serial/Makefile
index 8ea92e9c73b0..8ea92e9c73b0 100644
--- a/drivers/serial/Makefile
+++ b/drivers/tty/serial/Makefile
diff --git a/drivers/serial/altera_jtaguart.c b/drivers/tty/serial/altera_jtaguart.c
index f9b49b5ff5e1..f9b49b5ff5e1 100644
--- a/drivers/serial/altera_jtaguart.c
+++ b/drivers/tty/serial/altera_jtaguart.c
diff --git a/drivers/serial/altera_uart.c b/drivers/tty/serial/altera_uart.c
index 721216292a50..721216292a50 100644
--- a/drivers/serial/altera_uart.c
+++ b/drivers/tty/serial/altera_uart.c
diff --git a/drivers/serial/amba-pl010.c b/drivers/tty/serial/amba-pl010.c
index 2904aa044126..2904aa044126 100644
--- a/drivers/serial/amba-pl010.c
+++ b/drivers/tty/serial/amba-pl010.c
diff --git a/drivers/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index e76d7d000128..e76d7d000128 100644
--- a/drivers/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
diff --git a/drivers/serial/apbuart.c b/drivers/tty/serial/apbuart.c
index 095a5d562618..095a5d562618 100644
--- a/drivers/serial/apbuart.c
+++ b/drivers/tty/serial/apbuart.c
diff --git a/drivers/serial/apbuart.h b/drivers/tty/serial/apbuart.h
index 5faf87c8d2bc..5faf87c8d2bc 100644
--- a/drivers/serial/apbuart.h
+++ b/drivers/tty/serial/apbuart.h
diff --git a/drivers/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index 2a1d52fb4936..2a1d52fb4936 100644
--- a/drivers/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
diff --git a/drivers/serial/bcm63xx_uart.c b/drivers/tty/serial/bcm63xx_uart.c
index a1a0e55d0807..a1a0e55d0807 100644
--- a/drivers/serial/bcm63xx_uart.c
+++ b/drivers/tty/serial/bcm63xx_uart.c
diff --git a/drivers/serial/bfin_5xx.c b/drivers/tty/serial/bfin_5xx.c
index e381b895b04d..e381b895b04d 100644
--- a/drivers/serial/bfin_5xx.c
+++ b/drivers/tty/serial/bfin_5xx.c
diff --git a/drivers/serial/bfin_sport_uart.c b/drivers/tty/serial/bfin_sport_uart.c
index e95c524d9d18..e95c524d9d18 100644
--- a/drivers/serial/bfin_sport_uart.c
+++ b/drivers/tty/serial/bfin_sport_uart.c
diff --git a/drivers/serial/bfin_sport_uart.h b/drivers/tty/serial/bfin_sport_uart.h
index 6d06ce1d5675..6d06ce1d5675 100644
--- a/drivers/serial/bfin_sport_uart.h
+++ b/drivers/tty/serial/bfin_sport_uart.h
diff --git a/drivers/serial/clps711x.c b/drivers/tty/serial/clps711x.c
index b6acd19b458e..b6acd19b458e 100644
--- a/drivers/serial/clps711x.c
+++ b/drivers/tty/serial/clps711x.c
diff --git a/drivers/serial/cpm_uart/Makefile b/drivers/tty/serial/cpm_uart/Makefile
index e072724ea754..e072724ea754 100644
--- a/drivers/serial/cpm_uart/Makefile
+++ b/drivers/tty/serial/cpm_uart/Makefile
diff --git a/drivers/serial/cpm_uart/cpm_uart.h b/drivers/tty/serial/cpm_uart/cpm_uart.h
index b754dcf0fda5..b754dcf0fda5 100644
--- a/drivers/serial/cpm_uart/cpm_uart.h
+++ b/drivers/tty/serial/cpm_uart/cpm_uart.h
diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
index 8692ff98fc07..8692ff98fc07 100644
--- a/drivers/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm1.c b/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c
index 3fc1d66e32c6..3fc1d66e32c6 100644
--- a/drivers/serial/cpm_uart/cpm_uart_cpm1.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm1.h b/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.h
index 10eecd6af6d4..10eecd6af6d4 100644
--- a/drivers/serial/cpm_uart/cpm_uart_cpm1.h
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.h
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm2.c b/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c
index 814ac006393f..814ac006393f 100644
--- a/drivers/serial/cpm_uart/cpm_uart_cpm2.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm2.h b/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.h
index 7194c63dcf5f..7194c63dcf5f 100644
--- a/drivers/serial/cpm_uart/cpm_uart_cpm2.h
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.h
diff --git a/drivers/serial/crisv10.c b/drivers/tty/serial/crisv10.c
index bcc31f2140ac..bcc31f2140ac 100644
--- a/drivers/serial/crisv10.c
+++ b/drivers/tty/serial/crisv10.c
diff --git a/drivers/serial/crisv10.h b/drivers/tty/serial/crisv10.h
index ea0beb46a10d..ea0beb46a10d 100644
--- a/drivers/serial/crisv10.h
+++ b/drivers/tty/serial/crisv10.h
diff --git a/drivers/serial/dz.c b/drivers/tty/serial/dz.c
index 57421d776329..57421d776329 100644
--- a/drivers/serial/dz.c
+++ b/drivers/tty/serial/dz.c
diff --git a/drivers/serial/dz.h b/drivers/tty/serial/dz.h
index faf169ed27b3..faf169ed27b3 100644
--- a/drivers/serial/dz.h
+++ b/drivers/tty/serial/dz.h
diff --git a/drivers/serial/icom.c b/drivers/tty/serial/icom.c
index 53a468227056..53a468227056 100644
--- a/drivers/serial/icom.c
+++ b/drivers/tty/serial/icom.c
diff --git a/drivers/serial/icom.h b/drivers/tty/serial/icom.h
index c8029e0025c9..c8029e0025c9 100644
--- a/drivers/serial/icom.h
+++ b/drivers/tty/serial/icom.h
diff --git a/drivers/serial/ifx6x60.c b/drivers/tty/serial/ifx6x60.c
index ab93763862d5..ab93763862d5 100644
--- a/drivers/serial/ifx6x60.c
+++ b/drivers/tty/serial/ifx6x60.c
diff --git a/drivers/serial/ifx6x60.h b/drivers/tty/serial/ifx6x60.h
index deb7b8d977dc..deb7b8d977dc 100644
--- a/drivers/serial/ifx6x60.h
+++ b/drivers/tty/serial/ifx6x60.h
diff --git a/drivers/serial/imx.c b/drivers/tty/serial/imx.c
index dfcf4b1878aa..dfcf4b1878aa 100644
--- a/drivers/serial/imx.c
+++ b/drivers/tty/serial/imx.c
diff --git a/drivers/serial/ioc3_serial.c b/drivers/tty/serial/ioc3_serial.c
index ee43efc7bdcc..ee43efc7bdcc 100644
--- a/drivers/serial/ioc3_serial.c
+++ b/drivers/tty/serial/ioc3_serial.c
diff --git a/drivers/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
index fcfe82653ac8..fcfe82653ac8 100644
--- a/drivers/serial/ioc4_serial.c
+++ b/drivers/tty/serial/ioc4_serial.c
diff --git a/drivers/serial/ip22zilog.c b/drivers/tty/serial/ip22zilog.c
index ebff4a1d4bcc..ebff4a1d4bcc 100644
--- a/drivers/serial/ip22zilog.c
+++ b/drivers/tty/serial/ip22zilog.c
diff --git a/drivers/serial/ip22zilog.h b/drivers/tty/serial/ip22zilog.h
index a59a9a8341d2..a59a9a8341d2 100644
--- a/drivers/serial/ip22zilog.h
+++ b/drivers/tty/serial/ip22zilog.h
diff --git a/drivers/serial/jsm/Makefile b/drivers/tty/serial/jsm/Makefile
index e46b6e0f8b18..e46b6e0f8b18 100644
--- a/drivers/serial/jsm/Makefile
+++ b/drivers/tty/serial/jsm/Makefile
diff --git a/drivers/serial/jsm/jsm.h b/drivers/tty/serial/jsm/jsm.h
index 38a509c684cd..38a509c684cd 100644
--- a/drivers/serial/jsm/jsm.h
+++ b/drivers/tty/serial/jsm/jsm.h
diff --git a/drivers/serial/jsm/jsm_driver.c b/drivers/tty/serial/jsm/jsm_driver.c
index 18f548449c63..18f548449c63 100644
--- a/drivers/serial/jsm/jsm_driver.c
+++ b/drivers/tty/serial/jsm/jsm_driver.c
diff --git a/drivers/serial/jsm/jsm_neo.c b/drivers/tty/serial/jsm/jsm_neo.c
index 7960d9633c15..7960d9633c15 100644
--- a/drivers/serial/jsm/jsm_neo.c
+++ b/drivers/tty/serial/jsm/jsm_neo.c
diff --git a/drivers/serial/jsm/jsm_tty.c b/drivers/tty/serial/jsm/jsm_tty.c
index 7a4a914ecff0..7a4a914ecff0 100644
--- a/drivers/serial/jsm/jsm_tty.c
+++ b/drivers/tty/serial/jsm/jsm_tty.c
diff --git a/drivers/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
index 25a8bc565f40..25a8bc565f40 100644
--- a/drivers/serial/kgdboc.c
+++ b/drivers/tty/serial/kgdboc.c
diff --git a/drivers/serial/m32r_sio.c b/drivers/tty/serial/m32r_sio.c
index bea5c215460c..bea5c215460c 100644
--- a/drivers/serial/m32r_sio.c
+++ b/drivers/tty/serial/m32r_sio.c
diff --git a/drivers/serial/m32r_sio.h b/drivers/tty/serial/m32r_sio.h
index e9b7e11793b1..e9b7e11793b1 100644
--- a/drivers/serial/m32r_sio.h
+++ b/drivers/tty/serial/m32r_sio.h
diff --git a/drivers/serial/m32r_sio_reg.h b/drivers/tty/serial/m32r_sio_reg.h
index 4671473793e3..4671473793e3 100644
--- a/drivers/serial/m32r_sio_reg.h
+++ b/drivers/tty/serial/m32r_sio_reg.h
diff --git a/drivers/serial/max3100.c b/drivers/tty/serial/max3100.c
index beb1afa27d8d..beb1afa27d8d 100644
--- a/drivers/serial/max3100.c
+++ b/drivers/tty/serial/max3100.c
diff --git a/drivers/serial/max3107-aava.c b/drivers/tty/serial/max3107-aava.c
index a1fe304f2f52..a1fe304f2f52 100644
--- a/drivers/serial/max3107-aava.c
+++ b/drivers/tty/serial/max3107-aava.c
diff --git a/drivers/serial/max3107.c b/drivers/tty/serial/max3107.c
index 910870edf708..910870edf708 100644
--- a/drivers/serial/max3107.c
+++ b/drivers/tty/serial/max3107.c
diff --git a/drivers/serial/max3107.h b/drivers/tty/serial/max3107.h
index 7ab632392502..7ab632392502 100644
--- a/drivers/serial/max3107.h
+++ b/drivers/tty/serial/max3107.h
diff --git a/drivers/serial/mcf.c b/drivers/tty/serial/mcf.c
index 3394b7cc1722..3394b7cc1722 100644
--- a/drivers/serial/mcf.c
+++ b/drivers/tty/serial/mcf.c
diff --git a/drivers/serial/mfd.c b/drivers/tty/serial/mfd.c
index d40010a22ecd..d40010a22ecd 100644
--- a/drivers/serial/mfd.c
+++ b/drivers/tty/serial/mfd.c
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/tty/serial/mpc52xx_uart.c
index 126ec7f568ec..126ec7f568ec 100644
--- a/drivers/serial/mpc52xx_uart.c
+++ b/drivers/tty/serial/mpc52xx_uart.c
diff --git a/drivers/serial/mpsc.c b/drivers/tty/serial/mpsc.c
index 6a9c6605666a..6a9c6605666a 100644
--- a/drivers/serial/mpsc.c
+++ b/drivers/tty/serial/mpsc.c
diff --git a/drivers/serial/mrst_max3110.c b/drivers/tty/serial/mrst_max3110.c
index b62857bf2fdb..b62857bf2fdb 100644
--- a/drivers/serial/mrst_max3110.c
+++ b/drivers/tty/serial/mrst_max3110.c
diff --git a/drivers/serial/mrst_max3110.h b/drivers/tty/serial/mrst_max3110.h
index d1ef43af397c..d1ef43af397c 100644
--- a/drivers/serial/mrst_max3110.h
+++ b/drivers/tty/serial/mrst_max3110.h
diff --git a/drivers/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
index 8e43a7b69e64..8e43a7b69e64 100644
--- a/drivers/serial/msm_serial.c
+++ b/drivers/tty/serial/msm_serial.c
diff --git a/drivers/serial/msm_serial.h b/drivers/tty/serial/msm_serial.h
index f6ca9ca79e98..f6ca9ca79e98 100644
--- a/drivers/serial/msm_serial.h
+++ b/drivers/tty/serial/msm_serial.h
diff --git a/drivers/serial/mux.c b/drivers/tty/serial/mux.c
index 9711e06a8374..9711e06a8374 100644
--- a/drivers/serial/mux.c
+++ b/drivers/tty/serial/mux.c
diff --git a/drivers/serial/netx-serial.c b/drivers/tty/serial/netx-serial.c
index 7735c9f35fa0..7735c9f35fa0 100644
--- a/drivers/serial/netx-serial.c
+++ b/drivers/tty/serial/netx-serial.c
diff --git a/drivers/serial/nwpserial.c b/drivers/tty/serial/nwpserial.c
index de173671e3d0..de173671e3d0 100644
--- a/drivers/serial/nwpserial.c
+++ b/drivers/tty/serial/nwpserial.c
diff --git a/drivers/serial/of_serial.c b/drivers/tty/serial/of_serial.c
index 5c7abe4c94dd..5c7abe4c94dd 100644
--- a/drivers/serial/of_serial.c
+++ b/drivers/tty/serial/of_serial.c
diff --git a/drivers/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 7f2f01058789..7f2f01058789 100644
--- a/drivers/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
diff --git a/drivers/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
index 70a61458ec42..70a61458ec42 100644
--- a/drivers/serial/pch_uart.c
+++ b/drivers/tty/serial/pch_uart.c
diff --git a/drivers/serial/pmac_zilog.c b/drivers/tty/serial/pmac_zilog.c
index 5b9cde79e4ea..5b9cde79e4ea 100644
--- a/drivers/serial/pmac_zilog.c
+++ b/drivers/tty/serial/pmac_zilog.c
diff --git a/drivers/serial/pmac_zilog.h b/drivers/tty/serial/pmac_zilog.h
index cbc34fbb1b20..cbc34fbb1b20 100644
--- a/drivers/serial/pmac_zilog.h
+++ b/drivers/tty/serial/pmac_zilog.h
diff --git a/drivers/serial/pnx8xxx_uart.c b/drivers/tty/serial/pnx8xxx_uart.c
index 0aa75a97531c..0aa75a97531c 100644
--- a/drivers/serial/pnx8xxx_uart.c
+++ b/drivers/tty/serial/pnx8xxx_uart.c
diff --git a/drivers/serial/pxa.c b/drivers/tty/serial/pxa.c
index 1102a39b44f5..1102a39b44f5 100644
--- a/drivers/serial/pxa.c
+++ b/drivers/tty/serial/pxa.c
diff --git a/drivers/serial/s3c2400.c b/drivers/tty/serial/s3c2400.c
index fed1a9a1ffb4..fed1a9a1ffb4 100644
--- a/drivers/serial/s3c2400.c
+++ b/drivers/tty/serial/s3c2400.c
diff --git a/drivers/serial/s3c2410.c b/drivers/tty/serial/s3c2410.c
index 73f089d3efd6..73f089d3efd6 100644
--- a/drivers/serial/s3c2410.c
+++ b/drivers/tty/serial/s3c2410.c
diff --git a/drivers/serial/s3c2412.c b/drivers/tty/serial/s3c2412.c
index 1700b1a2fb7e..1700b1a2fb7e 100644
--- a/drivers/serial/s3c2412.c
+++ b/drivers/tty/serial/s3c2412.c
diff --git a/drivers/serial/s3c2440.c b/drivers/tty/serial/s3c2440.c
index 094cc3904b13..094cc3904b13 100644
--- a/drivers/serial/s3c2440.c
+++ b/drivers/tty/serial/s3c2440.c
diff --git a/drivers/serial/s3c24a0.c b/drivers/tty/serial/s3c24a0.c
index fad6083ca427..fad6083ca427 100644
--- a/drivers/serial/s3c24a0.c
+++ b/drivers/tty/serial/s3c24a0.c
diff --git a/drivers/serial/s3c6400.c b/drivers/tty/serial/s3c6400.c
index 4be92ab50058..4be92ab50058 100644
--- a/drivers/serial/s3c6400.c
+++ b/drivers/tty/serial/s3c6400.c
diff --git a/drivers/serial/s5pv210.c b/drivers/tty/serial/s5pv210.c
index 6ebccd70a707..6ebccd70a707 100644
--- a/drivers/serial/s5pv210.c
+++ b/drivers/tty/serial/s5pv210.c
diff --git a/drivers/serial/sa1100.c b/drivers/tty/serial/sa1100.c
index 2199d819a987..2199d819a987 100644
--- a/drivers/serial/sa1100.c
+++ b/drivers/tty/serial/sa1100.c
diff --git a/drivers/serial/samsung.c b/drivers/tty/serial/samsung.c
index 2335edafe903..2335edafe903 100644
--- a/drivers/serial/samsung.c
+++ b/drivers/tty/serial/samsung.c
diff --git a/drivers/serial/samsung.h b/drivers/tty/serial/samsung.h
index 0ac06a07d25f..0ac06a07d25f 100644
--- a/drivers/serial/samsung.h
+++ b/drivers/tty/serial/samsung.h
diff --git a/drivers/serial/sb1250-duart.c b/drivers/tty/serial/sb1250-duart.c
index a2f2b3254499..602d9845c52f 100644
--- a/drivers/serial/sb1250-duart.c
+++ b/drivers/tty/serial/sb1250-duart.c
@@ -829,7 +829,7 @@ static void __init sbd_probe_duarts(void)
829#ifdef CONFIG_SERIAL_SB1250_DUART_CONSOLE 829#ifdef CONFIG_SERIAL_SB1250_DUART_CONSOLE
830/* 830/*
831 * Serial console stuff. Very basic, polling driver for doing serial 831 * Serial console stuff. Very basic, polling driver for doing serial
832 * console output. The console_sem is held by the caller, so we 832 * console output. The console_lock is held by the caller, so we
833 * shouldn't be interrupted for more console activity. 833 * shouldn't be interrupted for more console activity.
834 */ 834 */
835static void sbd_console_putchar(struct uart_port *uport, int ch) 835static void sbd_console_putchar(struct uart_port *uport, int ch)
diff --git a/drivers/serial/sc26xx.c b/drivers/tty/serial/sc26xx.c
index 75038ad2b242..75038ad2b242 100644
--- a/drivers/serial/sc26xx.c
+++ b/drivers/tty/serial/sc26xx.c
diff --git a/drivers/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 460a72d91bb7..460a72d91bb7 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
diff --git a/drivers/serial/serial_cs.c b/drivers/tty/serial/serial_cs.c
index 93760b2ea172..93760b2ea172 100644
--- a/drivers/serial/serial_cs.c
+++ b/drivers/tty/serial/serial_cs.c
diff --git a/drivers/serial/serial_ks8695.c b/drivers/tty/serial/serial_ks8695.c
index b1962025b1aa..b1962025b1aa 100644
--- a/drivers/serial/serial_ks8695.c
+++ b/drivers/tty/serial/serial_ks8695.c
diff --git a/drivers/serial/serial_lh7a40x.c b/drivers/tty/serial/serial_lh7a40x.c
index ea744707c4d6..ea744707c4d6 100644
--- a/drivers/serial/serial_lh7a40x.c
+++ b/drivers/tty/serial/serial_lh7a40x.c
diff --git a/drivers/serial/serial_txx9.c b/drivers/tty/serial/serial_txx9.c
index c50e9fbbf743..c50e9fbbf743 100644
--- a/drivers/serial/serial_txx9.c
+++ b/drivers/tty/serial/serial_txx9.c
diff --git a/drivers/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 92c91c83edde..92c91c83edde 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
diff --git a/drivers/serial/sh-sci.h b/drivers/tty/serial/sh-sci.h
index b223d6cbf33a..b223d6cbf33a 100644
--- a/drivers/serial/sh-sci.h
+++ b/drivers/tty/serial/sh-sci.h
diff --git a/drivers/serial/sn_console.c b/drivers/tty/serial/sn_console.c
index cff9a306660f..cff9a306660f 100644
--- a/drivers/serial/sn_console.c
+++ b/drivers/tty/serial/sn_console.c
diff --git a/drivers/serial/suncore.c b/drivers/tty/serial/suncore.c
index 6381a0282ee7..6381a0282ee7 100644
--- a/drivers/serial/suncore.c
+++ b/drivers/tty/serial/suncore.c
diff --git a/drivers/serial/suncore.h b/drivers/tty/serial/suncore.h
index db2057936c31..db2057936c31 100644
--- a/drivers/serial/suncore.h
+++ b/drivers/tty/serial/suncore.h
diff --git a/drivers/serial/sunhv.c b/drivers/tty/serial/sunhv.c
index c9014868297d..c9014868297d 100644
--- a/drivers/serial/sunhv.c
+++ b/drivers/tty/serial/sunhv.c
diff --git a/drivers/serial/sunsab.c b/drivers/tty/serial/sunsab.c
index 5b246b18f42f..5b246b18f42f 100644
--- a/drivers/serial/sunsab.c
+++ b/drivers/tty/serial/sunsab.c
diff --git a/drivers/serial/sunsab.h b/drivers/tty/serial/sunsab.h
index b78e1f7b8050..b78e1f7b8050 100644
--- a/drivers/serial/sunsab.h
+++ b/drivers/tty/serial/sunsab.h
diff --git a/drivers/serial/sunsu.c b/drivers/tty/serial/sunsu.c
index 551ebfe3ccbb..551ebfe3ccbb 100644
--- a/drivers/serial/sunsu.c
+++ b/drivers/tty/serial/sunsu.c
diff --git a/drivers/serial/sunzilog.c b/drivers/tty/serial/sunzilog.c
index c1967ac1c07f..c1967ac1c07f 100644
--- a/drivers/serial/sunzilog.c
+++ b/drivers/tty/serial/sunzilog.c
diff --git a/drivers/serial/sunzilog.h b/drivers/tty/serial/sunzilog.h
index 5dec7b47cc38..5dec7b47cc38 100644
--- a/drivers/serial/sunzilog.h
+++ b/drivers/tty/serial/sunzilog.h
diff --git a/drivers/serial/timbuart.c b/drivers/tty/serial/timbuart.c
index 1f36b7eb7351..1f36b7eb7351 100644
--- a/drivers/serial/timbuart.c
+++ b/drivers/tty/serial/timbuart.c
diff --git a/drivers/serial/timbuart.h b/drivers/tty/serial/timbuart.h
index 7e566766bc43..7e566766bc43 100644
--- a/drivers/serial/timbuart.h
+++ b/drivers/tty/serial/timbuart.h
diff --git a/drivers/serial/uartlite.c b/drivers/tty/serial/uartlite.c
index d2fce865b731..d2fce865b731 100644
--- a/drivers/serial/uartlite.c
+++ b/drivers/tty/serial/uartlite.c
diff --git a/drivers/serial/ucc_uart.c b/drivers/tty/serial/ucc_uart.c
index 3f4848e2174a..3f4848e2174a 100644
--- a/drivers/serial/ucc_uart.c
+++ b/drivers/tty/serial/ucc_uart.c
diff --git a/drivers/serial/vr41xx_siu.c b/drivers/tty/serial/vr41xx_siu.c
index 3beb6ab4fa68..3beb6ab4fa68 100644
--- a/drivers/serial/vr41xx_siu.c
+++ b/drivers/tty/serial/vr41xx_siu.c
diff --git a/drivers/serial/vt8500_serial.c b/drivers/tty/serial/vt8500_serial.c
index 322bf56c0d89..322bf56c0d89 100644
--- a/drivers/serial/vt8500_serial.c
+++ b/drivers/tty/serial/vt8500_serial.c
diff --git a/drivers/serial/zs.c b/drivers/tty/serial/zs.c
index 1a7fd3e70315..1a7fd3e70315 100644
--- a/drivers/serial/zs.c
+++ b/drivers/tty/serial/zs.c
diff --git a/drivers/serial/zs.h b/drivers/tty/serial/zs.h
index aa921b57d827..aa921b57d827 100644
--- a/drivers/serial/zs.h
+++ b/drivers/tty/serial/zs.h
diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index c556ed9db13d..8e0dd254eb11 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -46,7 +46,7 @@
46#include <asm/irq_regs.h> 46#include <asm/irq_regs.h>
47 47
48/* Whether we react on sysrq keys or just ignore them */ 48/* Whether we react on sysrq keys or just ignore them */
49static int __read_mostly sysrq_enabled = 1; 49static int __read_mostly sysrq_enabled = SYSRQ_DEFAULT_ENABLE;
50static bool __read_mostly sysrq_always_enabled; 50static bool __read_mostly sysrq_always_enabled;
51 51
52static bool sysrq_on(void) 52static bool sysrq_on(void)
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 464d09d97873..0065da4b11c1 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -3256,8 +3256,8 @@ static ssize_t show_cons_active(struct device *dev,
3256 struct console *c; 3256 struct console *c;
3257 ssize_t count = 0; 3257 ssize_t count = 0;
3258 3258
3259 acquire_console_sem(); 3259 console_lock();
3260 for (c = console_drivers; c; c = c->next) { 3260 for_each_console(c) {
3261 if (!c->device) 3261 if (!c->device)
3262 continue; 3262 continue;
3263 if (!c->write) 3263 if (!c->write)
@@ -3271,7 +3271,7 @@ static ssize_t show_cons_active(struct device *dev,
3271 while (i--) 3271 while (i--)
3272 count += sprintf(buf + count, "%s%d%c", 3272 count += sprintf(buf + count, "%s%d%c",
3273 cs[i]->name, cs[i]->index, i ? ' ':'\n'); 3273 cs[i]->name, cs[i]->index, i ? ' ':'\n');
3274 release_console_sem(); 3274 console_unlock();
3275 3275
3276 return count; 3276 return count;
3277} 3277}
@@ -3306,7 +3306,7 @@ int __init tty_init(void)
3306 if (IS_ERR(consdev)) 3306 if (IS_ERR(consdev))
3307 consdev = NULL; 3307 consdev = NULL;
3308 else 3308 else
3309 device_create_file(consdev, &dev_attr_active); 3309 WARN_ON(device_create_file(consdev, &dev_attr_active) < 0);
3310 3310
3311#ifdef CONFIG_VT 3311#ifdef CONFIG_VT
3312 vty_init(&console_fops); 3312 vty_init(&console_fops);
diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c
index ebae344ce910..c956ed6c83a3 100644
--- a/drivers/tty/vt/selection.c
+++ b/drivers/tty/vt/selection.c
@@ -316,9 +316,9 @@ int paste_selection(struct tty_struct *tty)
316 /* always called with BTM from vt_ioctl */ 316 /* always called with BTM from vt_ioctl */
317 WARN_ON(!tty_locked()); 317 WARN_ON(!tty_locked());
318 318
319 acquire_console_sem(); 319 console_lock();
320 poke_blanked_console(); 320 poke_blanked_console();
321 release_console_sem(); 321 console_unlock();
322 322
323 ld = tty_ldisc_ref(tty); 323 ld = tty_ldisc_ref(tty);
324 if (!ld) { 324 if (!ld) {
diff --git a/drivers/tty/vt/vc_screen.c b/drivers/tty/vt/vc_screen.c
index eab3a1ff99e4..a672ed192d33 100644
--- a/drivers/tty/vt/vc_screen.c
+++ b/drivers/tty/vt/vc_screen.c
@@ -202,7 +202,7 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
202 /* Select the proper current console and verify 202 /* Select the proper current console and verify
203 * sanity of the situation under the console lock. 203 * sanity of the situation under the console lock.
204 */ 204 */
205 acquire_console_sem(); 205 console_lock();
206 206
207 attr = (currcons & 128); 207 attr = (currcons & 128);
208 currcons = (currcons & 127); 208 currcons = (currcons & 127);
@@ -336,9 +336,9 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
336 * the pagefault handling code may want to call printk(). 336 * the pagefault handling code may want to call printk().
337 */ 337 */
338 338
339 release_console_sem(); 339 console_unlock();
340 ret = copy_to_user(buf, con_buf_start, orig_count); 340 ret = copy_to_user(buf, con_buf_start, orig_count);
341 acquire_console_sem(); 341 console_lock();
342 342
343 if (ret) { 343 if (ret) {
344 read += (orig_count - ret); 344 read += (orig_count - ret);
@@ -354,7 +354,7 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
354 if (read) 354 if (read)
355 ret = read; 355 ret = read;
356unlock_out: 356unlock_out:
357 release_console_sem(); 357 console_unlock();
358 mutex_unlock(&con_buf_mtx); 358 mutex_unlock(&con_buf_mtx);
359 return ret; 359 return ret;
360} 360}
@@ -379,7 +379,7 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
379 /* Select the proper current console and verify 379 /* Select the proper current console and verify
380 * sanity of the situation under the console lock. 380 * sanity of the situation under the console lock.
381 */ 381 */
382 acquire_console_sem(); 382 console_lock();
383 383
384 attr = (currcons & 128); 384 attr = (currcons & 128);
385 currcons = (currcons & 127); 385 currcons = (currcons & 127);
@@ -414,9 +414,9 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
414 /* Temporarily drop the console lock so that we can read 414 /* Temporarily drop the console lock so that we can read
415 * in the write data from userspace safely. 415 * in the write data from userspace safely.
416 */ 416 */
417 release_console_sem(); 417 console_unlock();
418 ret = copy_from_user(con_buf, buf, this_round); 418 ret = copy_from_user(con_buf, buf, this_round);
419 acquire_console_sem(); 419 console_lock();
420 420
421 if (ret) { 421 if (ret) {
422 this_round -= ret; 422 this_round -= ret;
@@ -542,7 +542,7 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
542 vcs_scr_updated(vc); 542 vcs_scr_updated(vc);
543 543
544unlock_out: 544unlock_out:
545 release_console_sem(); 545 console_unlock();
546 546
547 mutex_unlock(&con_buf_mtx); 547 mutex_unlock(&con_buf_mtx);
548 548
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 76407eca9ab0..147ede3423df 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -1003,9 +1003,9 @@ static int vt_resize(struct tty_struct *tty, struct winsize *ws)
1003 struct vc_data *vc = tty->driver_data; 1003 struct vc_data *vc = tty->driver_data;
1004 int ret; 1004 int ret;
1005 1005
1006 acquire_console_sem(); 1006 console_lock();
1007 ret = vc_do_resize(tty, vc, ws->ws_col, ws->ws_row); 1007 ret = vc_do_resize(tty, vc, ws->ws_col, ws->ws_row);
1008 release_console_sem(); 1008 console_unlock();
1009 return ret; 1009 return ret;
1010} 1010}
1011 1011
@@ -1271,7 +1271,7 @@ static void default_attr(struct vc_data *vc)
1271 vc->vc_color = vc->vc_def_color; 1271 vc->vc_color = vc->vc_def_color;
1272} 1272}
1273 1273
1274/* console_sem is held */ 1274/* console_lock is held */
1275static void csi_m(struct vc_data *vc) 1275static void csi_m(struct vc_data *vc)
1276{ 1276{
1277 int i; 1277 int i;
@@ -1415,7 +1415,7 @@ int mouse_reporting(void)
1415 return vc_cons[fg_console].d->vc_report_mouse; 1415 return vc_cons[fg_console].d->vc_report_mouse;
1416} 1416}
1417 1417
1418/* console_sem is held */ 1418/* console_lock is held */
1419static void set_mode(struct vc_data *vc, int on_off) 1419static void set_mode(struct vc_data *vc, int on_off)
1420{ 1420{
1421 int i; 1421 int i;
@@ -1485,7 +1485,7 @@ static void set_mode(struct vc_data *vc, int on_off)
1485 } 1485 }
1486} 1486}
1487 1487
1488/* console_sem is held */ 1488/* console_lock is held */
1489static void setterm_command(struct vc_data *vc) 1489static void setterm_command(struct vc_data *vc)
1490{ 1490{
1491 switch(vc->vc_par[0]) { 1491 switch(vc->vc_par[0]) {
@@ -1545,7 +1545,7 @@ static void setterm_command(struct vc_data *vc)
1545 } 1545 }
1546} 1546}
1547 1547
1548/* console_sem is held */ 1548/* console_lock is held */
1549static void csi_at(struct vc_data *vc, unsigned int nr) 1549static void csi_at(struct vc_data *vc, unsigned int nr)
1550{ 1550{
1551 if (nr > vc->vc_cols - vc->vc_x) 1551 if (nr > vc->vc_cols - vc->vc_x)
@@ -1555,7 +1555,7 @@ static void csi_at(struct vc_data *vc, unsigned int nr)
1555 insert_char(vc, nr); 1555 insert_char(vc, nr);
1556} 1556}
1557 1557
1558/* console_sem is held */ 1558/* console_lock is held */
1559static void csi_L(struct vc_data *vc, unsigned int nr) 1559static void csi_L(struct vc_data *vc, unsigned int nr)
1560{ 1560{
1561 if (nr > vc->vc_rows - vc->vc_y) 1561 if (nr > vc->vc_rows - vc->vc_y)
@@ -1566,7 +1566,7 @@ static void csi_L(struct vc_data *vc, unsigned int nr)
1566 vc->vc_need_wrap = 0; 1566 vc->vc_need_wrap = 0;
1567} 1567}
1568 1568
1569/* console_sem is held */ 1569/* console_lock is held */
1570static void csi_P(struct vc_data *vc, unsigned int nr) 1570static void csi_P(struct vc_data *vc, unsigned int nr)
1571{ 1571{
1572 if (nr > vc->vc_cols - vc->vc_x) 1572 if (nr > vc->vc_cols - vc->vc_x)
@@ -1576,7 +1576,7 @@ static void csi_P(struct vc_data *vc, unsigned int nr)
1576 delete_char(vc, nr); 1576 delete_char(vc, nr);
1577} 1577}
1578 1578
1579/* console_sem is held */ 1579/* console_lock is held */
1580static void csi_M(struct vc_data *vc, unsigned int nr) 1580static void csi_M(struct vc_data *vc, unsigned int nr)
1581{ 1581{
1582 if (nr > vc->vc_rows - vc->vc_y) 1582 if (nr > vc->vc_rows - vc->vc_y)
@@ -1587,7 +1587,7 @@ static void csi_M(struct vc_data *vc, unsigned int nr)
1587 vc->vc_need_wrap = 0; 1587 vc->vc_need_wrap = 0;
1588} 1588}
1589 1589
1590/* console_sem is held (except via vc_init->reset_terminal */ 1590/* console_lock is held (except via vc_init->reset_terminal */
1591static void save_cur(struct vc_data *vc) 1591static void save_cur(struct vc_data *vc)
1592{ 1592{
1593 vc->vc_saved_x = vc->vc_x; 1593 vc->vc_saved_x = vc->vc_x;
@@ -1603,7 +1603,7 @@ static void save_cur(struct vc_data *vc)
1603 vc->vc_saved_G1 = vc->vc_G1_charset; 1603 vc->vc_saved_G1 = vc->vc_G1_charset;
1604} 1604}
1605 1605
1606/* console_sem is held */ 1606/* console_lock is held */
1607static void restore_cur(struct vc_data *vc) 1607static void restore_cur(struct vc_data *vc)
1608{ 1608{
1609 gotoxy(vc, vc->vc_saved_x, vc->vc_saved_y); 1609 gotoxy(vc, vc->vc_saved_x, vc->vc_saved_y);
@@ -1625,7 +1625,7 @@ enum { ESnormal, ESesc, ESsquare, ESgetpars, ESgotpars, ESfunckey,
1625 EShash, ESsetG0, ESsetG1, ESpercent, ESignore, ESnonstd, 1625 EShash, ESsetG0, ESsetG1, ESpercent, ESignore, ESnonstd,
1626 ESpalette }; 1626 ESpalette };
1627 1627
1628/* console_sem is held (except via vc_init()) */ 1628/* console_lock is held (except via vc_init()) */
1629static void reset_terminal(struct vc_data *vc, int do_clear) 1629static void reset_terminal(struct vc_data *vc, int do_clear)
1630{ 1630{
1631 vc->vc_top = 0; 1631 vc->vc_top = 0;
@@ -1685,7 +1685,7 @@ static void reset_terminal(struct vc_data *vc, int do_clear)
1685 csi_J(vc, 2); 1685 csi_J(vc, 2);
1686} 1686}
1687 1687
1688/* console_sem is held */ 1688/* console_lock is held */
1689static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) 1689static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c)
1690{ 1690{
1691 /* 1691 /*
@@ -2119,7 +2119,7 @@ static int is_double_width(uint32_t ucs)
2119 return bisearch(ucs, double_width, ARRAY_SIZE(double_width) - 1); 2119 return bisearch(ucs, double_width, ARRAY_SIZE(double_width) - 1);
2120} 2120}
2121 2121
2122/* acquires console_sem */ 2122/* acquires console_lock */
2123static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int count) 2123static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int count)
2124{ 2124{
2125#ifdef VT_BUF_VRAM_ONLY 2125#ifdef VT_BUF_VRAM_ONLY
@@ -2147,11 +2147,11 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co
2147 2147
2148 might_sleep(); 2148 might_sleep();
2149 2149
2150 acquire_console_sem(); 2150 console_lock();
2151 vc = tty->driver_data; 2151 vc = tty->driver_data;
2152 if (vc == NULL) { 2152 if (vc == NULL) {
2153 printk(KERN_ERR "vt: argh, driver_data is NULL !\n"); 2153 printk(KERN_ERR "vt: argh, driver_data is NULL !\n");
2154 release_console_sem(); 2154 console_unlock();
2155 return 0; 2155 return 0;
2156 } 2156 }
2157 2157
@@ -2159,7 +2159,7 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co
2159 if (!vc_cons_allocated(currcons)) { 2159 if (!vc_cons_allocated(currcons)) {
2160 /* could this happen? */ 2160 /* could this happen? */
2161 printk_once("con_write: tty %d not allocated\n", currcons+1); 2161 printk_once("con_write: tty %d not allocated\n", currcons+1);
2162 release_console_sem(); 2162 console_unlock();
2163 return 0; 2163 return 0;
2164 } 2164 }
2165 2165
@@ -2375,7 +2375,7 @@ rescan_last_byte:
2375 } 2375 }
2376 FLUSH 2376 FLUSH
2377 console_conditional_schedule(); 2377 console_conditional_schedule();
2378 release_console_sem(); 2378 console_unlock();
2379 notify_update(vc); 2379 notify_update(vc);
2380 return n; 2380 return n;
2381#undef FLUSH 2381#undef FLUSH
@@ -2388,11 +2388,11 @@ rescan_last_byte:
2388 * us to do the switches asynchronously (needed when we want 2388 * us to do the switches asynchronously (needed when we want
2389 * to switch due to a keyboard interrupt). Synchronization 2389 * to switch due to a keyboard interrupt). Synchronization
2390 * with other console code and prevention of re-entrancy is 2390 * with other console code and prevention of re-entrancy is
2391 * ensured with console_sem. 2391 * ensured with console_lock.
2392 */ 2392 */
2393static void console_callback(struct work_struct *ignored) 2393static void console_callback(struct work_struct *ignored)
2394{ 2394{
2395 acquire_console_sem(); 2395 console_lock();
2396 2396
2397 if (want_console >= 0) { 2397 if (want_console >= 0) {
2398 if (want_console != fg_console && 2398 if (want_console != fg_console &&
@@ -2422,7 +2422,7 @@ static void console_callback(struct work_struct *ignored)
2422 } 2422 }
2423 notify_update(vc_cons[fg_console].d); 2423 notify_update(vc_cons[fg_console].d);
2424 2424
2425 release_console_sem(); 2425 console_unlock();
2426} 2426}
2427 2427
2428int set_console(int nr) 2428int set_console(int nr)
@@ -2603,7 +2603,7 @@ static struct console vt_console_driver = {
2603 */ 2603 */
2604 2604
2605/* 2605/*
2606 * Generally a bit racy with respect to console_sem(). 2606 * Generally a bit racy with respect to console_lock();.
2607 * 2607 *
2608 * There are some functions which don't need it. 2608 * There are some functions which don't need it.
2609 * 2609 *
@@ -2629,17 +2629,17 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
2629 switch (type) 2629 switch (type)
2630 { 2630 {
2631 case TIOCL_SETSEL: 2631 case TIOCL_SETSEL:
2632 acquire_console_sem(); 2632 console_lock();
2633 ret = set_selection((struct tiocl_selection __user *)(p+1), tty); 2633 ret = set_selection((struct tiocl_selection __user *)(p+1), tty);
2634 release_console_sem(); 2634 console_unlock();
2635 break; 2635 break;
2636 case TIOCL_PASTESEL: 2636 case TIOCL_PASTESEL:
2637 ret = paste_selection(tty); 2637 ret = paste_selection(tty);
2638 break; 2638 break;
2639 case TIOCL_UNBLANKSCREEN: 2639 case TIOCL_UNBLANKSCREEN:
2640 acquire_console_sem(); 2640 console_lock();
2641 unblank_screen(); 2641 unblank_screen();
2642 release_console_sem(); 2642 console_unlock();
2643 break; 2643 break;
2644 case TIOCL_SELLOADLUT: 2644 case TIOCL_SELLOADLUT:
2645 ret = sel_loadlut(p); 2645 ret = sel_loadlut(p);
@@ -2688,10 +2688,10 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
2688 } 2688 }
2689 break; 2689 break;
2690 case TIOCL_BLANKSCREEN: /* until explicitly unblanked, not only poked */ 2690 case TIOCL_BLANKSCREEN: /* until explicitly unblanked, not only poked */
2691 acquire_console_sem(); 2691 console_lock();
2692 ignore_poke = 1; 2692 ignore_poke = 1;
2693 do_blank_screen(0); 2693 do_blank_screen(0);
2694 release_console_sem(); 2694 console_unlock();
2695 break; 2695 break;
2696 case TIOCL_BLANKEDSCREEN: 2696 case TIOCL_BLANKEDSCREEN:
2697 ret = console_blanked; 2697 ret = console_blanked;
@@ -2790,11 +2790,11 @@ static void con_flush_chars(struct tty_struct *tty)
2790 return; 2790 return;
2791 2791
2792 /* if we race with con_close(), vt may be null */ 2792 /* if we race with con_close(), vt may be null */
2793 acquire_console_sem(); 2793 console_lock();
2794 vc = tty->driver_data; 2794 vc = tty->driver_data;
2795 if (vc) 2795 if (vc)
2796 set_cursor(vc); 2796 set_cursor(vc);
2797 release_console_sem(); 2797 console_unlock();
2798} 2798}
2799 2799
2800/* 2800/*
@@ -2805,7 +2805,7 @@ static int con_open(struct tty_struct *tty, struct file *filp)
2805 unsigned int currcons = tty->index; 2805 unsigned int currcons = tty->index;
2806 int ret = 0; 2806 int ret = 0;
2807 2807
2808 acquire_console_sem(); 2808 console_lock();
2809 if (tty->driver_data == NULL) { 2809 if (tty->driver_data == NULL) {
2810 ret = vc_allocate(currcons); 2810 ret = vc_allocate(currcons);
2811 if (ret == 0) { 2811 if (ret == 0) {
@@ -2813,7 +2813,7 @@ static int con_open(struct tty_struct *tty, struct file *filp)
2813 2813
2814 /* Still being freed */ 2814 /* Still being freed */
2815 if (vc->port.tty) { 2815 if (vc->port.tty) {
2816 release_console_sem(); 2816 console_unlock();
2817 return -ERESTARTSYS; 2817 return -ERESTARTSYS;
2818 } 2818 }
2819 tty->driver_data = vc; 2819 tty->driver_data = vc;
@@ -2827,11 +2827,11 @@ static int con_open(struct tty_struct *tty, struct file *filp)
2827 tty->termios->c_iflag |= IUTF8; 2827 tty->termios->c_iflag |= IUTF8;
2828 else 2828 else
2829 tty->termios->c_iflag &= ~IUTF8; 2829 tty->termios->c_iflag &= ~IUTF8;
2830 release_console_sem(); 2830 console_unlock();
2831 return ret; 2831 return ret;
2832 } 2832 }
2833 } 2833 }
2834 release_console_sem(); 2834 console_unlock();
2835 return ret; 2835 return ret;
2836} 2836}
2837 2837
@@ -2844,9 +2844,9 @@ static void con_shutdown(struct tty_struct *tty)
2844{ 2844{
2845 struct vc_data *vc = tty->driver_data; 2845 struct vc_data *vc = tty->driver_data;
2846 BUG_ON(vc == NULL); 2846 BUG_ON(vc == NULL);
2847 acquire_console_sem(); 2847 console_lock();
2848 vc->port.tty = NULL; 2848 vc->port.tty = NULL;
2849 release_console_sem(); 2849 console_unlock();
2850 tty_shutdown(tty); 2850 tty_shutdown(tty);
2851} 2851}
2852 2852
@@ -2893,13 +2893,13 @@ static int __init con_init(void)
2893 struct vc_data *vc; 2893 struct vc_data *vc;
2894 unsigned int currcons = 0, i; 2894 unsigned int currcons = 0, i;
2895 2895
2896 acquire_console_sem(); 2896 console_lock();
2897 2897
2898 if (conswitchp) 2898 if (conswitchp)
2899 display_desc = conswitchp->con_startup(); 2899 display_desc = conswitchp->con_startup();
2900 if (!display_desc) { 2900 if (!display_desc) {
2901 fg_console = 0; 2901 fg_console = 0;
2902 release_console_sem(); 2902 console_unlock();
2903 return 0; 2903 return 0;
2904 } 2904 }
2905 2905
@@ -2946,7 +2946,7 @@ static int __init con_init(void)
2946 printable = 1; 2946 printable = 1;
2947 printk("\n"); 2947 printk("\n");
2948 2948
2949 release_console_sem(); 2949 console_unlock();
2950 2950
2951#ifdef CONFIG_VT_CONSOLE 2951#ifdef CONFIG_VT_CONSOLE
2952 register_console(&vt_console_driver); 2952 register_console(&vt_console_driver);
@@ -2994,7 +2994,7 @@ int __init vty_init(const struct file_operations *console_fops)
2994 if (IS_ERR(tty0dev)) 2994 if (IS_ERR(tty0dev))
2995 tty0dev = NULL; 2995 tty0dev = NULL;
2996 else 2996 else
2997 device_create_file(tty0dev, &dev_attr_active); 2997 WARN_ON(device_create_file(tty0dev, &dev_attr_active) < 0);
2998 2998
2999 vcs_init(); 2999 vcs_init();
3000 3000
@@ -3037,7 +3037,7 @@ static int bind_con_driver(const struct consw *csw, int first, int last,
3037 if (!try_module_get(owner)) 3037 if (!try_module_get(owner))
3038 return -ENODEV; 3038 return -ENODEV;
3039 3039
3040 acquire_console_sem(); 3040 console_lock();
3041 3041
3042 /* check if driver is registered */ 3042 /* check if driver is registered */
3043 for (i = 0; i < MAX_NR_CON_DRIVER; i++) { 3043 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
@@ -3122,7 +3122,7 @@ static int bind_con_driver(const struct consw *csw, int first, int last,
3122 3122
3123 retval = 0; 3123 retval = 0;
3124err: 3124err:
3125 release_console_sem(); 3125 console_unlock();
3126 module_put(owner); 3126 module_put(owner);
3127 return retval; 3127 return retval;
3128}; 3128};
@@ -3171,7 +3171,7 @@ int unbind_con_driver(const struct consw *csw, int first, int last, int deflt)
3171 if (!try_module_get(owner)) 3171 if (!try_module_get(owner))
3172 return -ENODEV; 3172 return -ENODEV;
3173 3173
3174 acquire_console_sem(); 3174 console_lock();
3175 3175
3176 /* check if driver is registered and if it is unbindable */ 3176 /* check if driver is registered and if it is unbindable */
3177 for (i = 0; i < MAX_NR_CON_DRIVER; i++) { 3177 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
@@ -3185,7 +3185,7 @@ int unbind_con_driver(const struct consw *csw, int first, int last, int deflt)
3185 } 3185 }
3186 3186
3187 if (retval) { 3187 if (retval) {
3188 release_console_sem(); 3188 console_unlock();
3189 goto err; 3189 goto err;
3190 } 3190 }
3191 3191
@@ -3204,12 +3204,12 @@ int unbind_con_driver(const struct consw *csw, int first, int last, int deflt)
3204 } 3204 }
3205 3205
3206 if (retval) { 3206 if (retval) {
3207 release_console_sem(); 3207 console_unlock();
3208 goto err; 3208 goto err;
3209 } 3209 }
3210 3210
3211 if (!con_is_bound(csw)) { 3211 if (!con_is_bound(csw)) {
3212 release_console_sem(); 3212 console_unlock();
3213 goto err; 3213 goto err;
3214 } 3214 }
3215 3215
@@ -3238,7 +3238,7 @@ int unbind_con_driver(const struct consw *csw, int first, int last, int deflt)
3238 if (!con_is_bound(csw)) 3238 if (!con_is_bound(csw))
3239 con_driver->flag &= ~CON_DRIVER_FLAG_INIT; 3239 con_driver->flag &= ~CON_DRIVER_FLAG_INIT;
3240 3240
3241 release_console_sem(); 3241 console_unlock();
3242 /* ignore return value, binding should not fail */ 3242 /* ignore return value, binding should not fail */
3243 bind_con_driver(defcsw, first, last, deflt); 3243 bind_con_driver(defcsw, first, last, deflt);
3244err: 3244err:
@@ -3538,14 +3538,14 @@ int register_con_driver(const struct consw *csw, int first, int last)
3538 if (!try_module_get(owner)) 3538 if (!try_module_get(owner))
3539 return -ENODEV; 3539 return -ENODEV;
3540 3540
3541 acquire_console_sem(); 3541 console_lock();
3542 3542
3543 for (i = 0; i < MAX_NR_CON_DRIVER; i++) { 3543 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
3544 con_driver = &registered_con_driver[i]; 3544 con_driver = &registered_con_driver[i];
3545 3545
3546 /* already registered */ 3546 /* already registered */
3547 if (con_driver->con == csw) 3547 if (con_driver->con == csw)
3548 retval = -EINVAL; 3548 retval = -EBUSY;
3549 } 3549 }
3550 3550
3551 if (retval) 3551 if (retval)
@@ -3592,7 +3592,7 @@ int register_con_driver(const struct consw *csw, int first, int last)
3592 } 3592 }
3593 3593
3594err: 3594err:
3595 release_console_sem(); 3595 console_unlock();
3596 module_put(owner); 3596 module_put(owner);
3597 return retval; 3597 return retval;
3598} 3598}
@@ -3613,7 +3613,7 @@ int unregister_con_driver(const struct consw *csw)
3613{ 3613{
3614 int i, retval = -ENODEV; 3614 int i, retval = -ENODEV;
3615 3615
3616 acquire_console_sem(); 3616 console_lock();
3617 3617
3618 /* cannot unregister a bound driver */ 3618 /* cannot unregister a bound driver */
3619 if (con_is_bound(csw)) 3619 if (con_is_bound(csw))
@@ -3639,7 +3639,7 @@ int unregister_con_driver(const struct consw *csw)
3639 } 3639 }
3640 } 3640 }
3641err: 3641err:
3642 release_console_sem(); 3642 console_unlock();
3643 return retval; 3643 return retval;
3644} 3644}
3645EXPORT_SYMBOL(unregister_con_driver); 3645EXPORT_SYMBOL(unregister_con_driver);
@@ -3656,7 +3656,12 @@ int take_over_console(const struct consw *csw, int first, int last, int deflt)
3656 int err; 3656 int err;
3657 3657
3658 err = register_con_driver(csw, first, last); 3658 err = register_con_driver(csw, first, last);
3659 3659 /* if we get an busy error we still want to bind the console driver
3660 * and return success, as we may have unbound the console driver
3661  * but not unregistered it.
3662 */
3663 if (err == -EBUSY)
3664 err = 0;
3660 if (!err) 3665 if (!err)
3661 bind_con_driver(csw, first, last, deflt); 3666 bind_con_driver(csw, first, last, deflt);
3662 3667
@@ -3934,9 +3939,9 @@ int con_set_cmap(unsigned char __user *arg)
3934{ 3939{
3935 int rc; 3940 int rc;
3936 3941
3937 acquire_console_sem(); 3942 console_lock();
3938 rc = set_get_cmap (arg,1); 3943 rc = set_get_cmap (arg,1);
3939 release_console_sem(); 3944 console_unlock();
3940 3945
3941 return rc; 3946 return rc;
3942} 3947}
@@ -3945,9 +3950,9 @@ int con_get_cmap(unsigned char __user *arg)
3945{ 3950{
3946 int rc; 3951 int rc;
3947 3952
3948 acquire_console_sem(); 3953 console_lock();
3949 rc = set_get_cmap (arg,0); 3954 rc = set_get_cmap (arg,0);
3950 release_console_sem(); 3955 console_unlock();
3951 3956
3952 return rc; 3957 return rc;
3953} 3958}
@@ -3994,12 +3999,12 @@ static int con_font_get(struct vc_data *vc, struct console_font_op *op)
3994 } else 3999 } else
3995 font.data = NULL; 4000 font.data = NULL;
3996 4001
3997 acquire_console_sem(); 4002 console_lock();
3998 if (vc->vc_sw->con_font_get) 4003 if (vc->vc_sw->con_font_get)
3999 rc = vc->vc_sw->con_font_get(vc, &font); 4004 rc = vc->vc_sw->con_font_get(vc, &font);
4000 else 4005 else
4001 rc = -ENOSYS; 4006 rc = -ENOSYS;
4002 release_console_sem(); 4007 console_unlock();
4003 4008
4004 if (rc) 4009 if (rc)
4005 goto out; 4010 goto out;
@@ -4076,12 +4081,12 @@ static int con_font_set(struct vc_data *vc, struct console_font_op *op)
4076 font.data = memdup_user(op->data, size); 4081 font.data = memdup_user(op->data, size);
4077 if (IS_ERR(font.data)) 4082 if (IS_ERR(font.data))
4078 return PTR_ERR(font.data); 4083 return PTR_ERR(font.data);
4079 acquire_console_sem(); 4084 console_lock();
4080 if (vc->vc_sw->con_font_set) 4085 if (vc->vc_sw->con_font_set)
4081 rc = vc->vc_sw->con_font_set(vc, &font, op->flags); 4086 rc = vc->vc_sw->con_font_set(vc, &font, op->flags);
4082 else 4087 else
4083 rc = -ENOSYS; 4088 rc = -ENOSYS;
4084 release_console_sem(); 4089 console_unlock();
4085 kfree(font.data); 4090 kfree(font.data);
4086 return rc; 4091 return rc;
4087} 4092}
@@ -4103,12 +4108,12 @@ static int con_font_default(struct vc_data *vc, struct console_font_op *op)
4103 else 4108 else
4104 name[MAX_FONT_NAME - 1] = 0; 4109 name[MAX_FONT_NAME - 1] = 0;
4105 4110
4106 acquire_console_sem(); 4111 console_lock();
4107 if (vc->vc_sw->con_font_default) 4112 if (vc->vc_sw->con_font_default)
4108 rc = vc->vc_sw->con_font_default(vc, &font, s); 4113 rc = vc->vc_sw->con_font_default(vc, &font, s);
4109 else 4114 else
4110 rc = -ENOSYS; 4115 rc = -ENOSYS;
4111 release_console_sem(); 4116 console_unlock();
4112 if (!rc) { 4117 if (!rc) {
4113 op->width = font.width; 4118 op->width = font.width;
4114 op->height = font.height; 4119 op->height = font.height;
@@ -4124,7 +4129,7 @@ static int con_font_copy(struct vc_data *vc, struct console_font_op *op)
4124 if (vc->vc_mode != KD_TEXT) 4129 if (vc->vc_mode != KD_TEXT)
4125 return -EINVAL; 4130 return -EINVAL;
4126 4131
4127 acquire_console_sem(); 4132 console_lock();
4128 if (!vc->vc_sw->con_font_copy) 4133 if (!vc->vc_sw->con_font_copy)
4129 rc = -ENOSYS; 4134 rc = -ENOSYS;
4130 else if (con < 0 || !vc_cons_allocated(con)) 4135 else if (con < 0 || !vc_cons_allocated(con))
@@ -4133,7 +4138,7 @@ static int con_font_copy(struct vc_data *vc, struct console_font_op *op)
4133 rc = 0; 4138 rc = 0;
4134 else 4139 else
4135 rc = vc->vc_sw->con_font_copy(vc, con); 4140 rc = vc->vc_sw->con_font_copy(vc, con);
4136 release_console_sem(); 4141 console_unlock();
4137 return rc; 4142 return rc;
4138} 4143}
4139 4144
diff --git a/drivers/tty/vt/vt_ioctl.c b/drivers/tty/vt/vt_ioctl.c
index 6b68a0fb4611..1235ebda6e1c 100644
--- a/drivers/tty/vt/vt_ioctl.c
+++ b/drivers/tty/vt/vt_ioctl.c
@@ -649,12 +649,12 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
649 /* 649 /*
650 * explicitly blank/unblank the screen if switching modes 650 * explicitly blank/unblank the screen if switching modes
651 */ 651 */
652 acquire_console_sem(); 652 console_lock();
653 if (arg == KD_TEXT) 653 if (arg == KD_TEXT)
654 do_unblank_screen(1); 654 do_unblank_screen(1);
655 else 655 else
656 do_blank_screen(1); 656 do_blank_screen(1);
657 release_console_sem(); 657 console_unlock();
658 break; 658 break;
659 659
660 case KDGETMODE: 660 case KDGETMODE:
@@ -893,7 +893,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
893 ret = -EINVAL; 893 ret = -EINVAL;
894 goto out; 894 goto out;
895 } 895 }
896 acquire_console_sem(); 896 console_lock();
897 vc->vt_mode = tmp; 897 vc->vt_mode = tmp;
898 /* the frsig is ignored, so we set it to 0 */ 898 /* the frsig is ignored, so we set it to 0 */
899 vc->vt_mode.frsig = 0; 899 vc->vt_mode.frsig = 0;
@@ -901,7 +901,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
901 vc->vt_pid = get_pid(task_pid(current)); 901 vc->vt_pid = get_pid(task_pid(current));
902 /* no switch is required -- saw@shade.msu.ru */ 902 /* no switch is required -- saw@shade.msu.ru */
903 vc->vt_newvt = -1; 903 vc->vt_newvt = -1;
904 release_console_sem(); 904 console_unlock();
905 break; 905 break;
906 } 906 }
907 907
@@ -910,9 +910,9 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
910 struct vt_mode tmp; 910 struct vt_mode tmp;
911 int rc; 911 int rc;
912 912
913 acquire_console_sem(); 913 console_lock();
914 memcpy(&tmp, &vc->vt_mode, sizeof(struct vt_mode)); 914 memcpy(&tmp, &vc->vt_mode, sizeof(struct vt_mode));
915 release_console_sem(); 915 console_unlock();
916 916
917 rc = copy_to_user(up, &tmp, sizeof(struct vt_mode)); 917 rc = copy_to_user(up, &tmp, sizeof(struct vt_mode));
918 if (rc) 918 if (rc)
@@ -965,9 +965,9 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
965 ret = -ENXIO; 965 ret = -ENXIO;
966 else { 966 else {
967 arg--; 967 arg--;
968 acquire_console_sem(); 968 console_lock();
969 ret = vc_allocate(arg); 969 ret = vc_allocate(arg);
970 release_console_sem(); 970 console_unlock();
971 if (ret) 971 if (ret)
972 break; 972 break;
973 set_console(arg); 973 set_console(arg);
@@ -990,7 +990,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
990 ret = -ENXIO; 990 ret = -ENXIO;
991 else { 991 else {
992 vsa.console--; 992 vsa.console--;
993 acquire_console_sem(); 993 console_lock();
994 ret = vc_allocate(vsa.console); 994 ret = vc_allocate(vsa.console);
995 if (ret == 0) { 995 if (ret == 0) {
996 struct vc_data *nvc; 996 struct vc_data *nvc;
@@ -1003,7 +1003,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
1003 put_pid(nvc->vt_pid); 1003 put_pid(nvc->vt_pid);
1004 nvc->vt_pid = get_pid(task_pid(current)); 1004 nvc->vt_pid = get_pid(task_pid(current));
1005 } 1005 }
1006 release_console_sem(); 1006 console_unlock();
1007 if (ret) 1007 if (ret)
1008 break; 1008 break;
1009 /* Commence switch and lock */ 1009 /* Commence switch and lock */
@@ -1044,7 +1044,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
1044 /* 1044 /*
1045 * Switching-from response 1045 * Switching-from response
1046 */ 1046 */
1047 acquire_console_sem(); 1047 console_lock();
1048 if (vc->vt_newvt >= 0) { 1048 if (vc->vt_newvt >= 0) {
1049 if (arg == 0) 1049 if (arg == 0)
1050 /* 1050 /*
@@ -1063,7 +1063,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
1063 vc->vt_newvt = -1; 1063 vc->vt_newvt = -1;
1064 ret = vc_allocate(newvt); 1064 ret = vc_allocate(newvt);
1065 if (ret) { 1065 if (ret) {
1066 release_console_sem(); 1066 console_unlock();
1067 break; 1067 break;
1068 } 1068 }
1069 /* 1069 /*
@@ -1083,7 +1083,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
1083 if (arg != VT_ACKACQ) 1083 if (arg != VT_ACKACQ)
1084 ret = -EINVAL; 1084 ret = -EINVAL;
1085 } 1085 }
1086 release_console_sem(); 1086 console_unlock();
1087 break; 1087 break;
1088 1088
1089 /* 1089 /*
@@ -1096,20 +1096,20 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
1096 } 1096 }
1097 if (arg == 0) { 1097 if (arg == 0) {
1098 /* deallocate all unused consoles, but leave 0 */ 1098 /* deallocate all unused consoles, but leave 0 */
1099 acquire_console_sem(); 1099 console_lock();
1100 for (i=1; i<MAX_NR_CONSOLES; i++) 1100 for (i=1; i<MAX_NR_CONSOLES; i++)
1101 if (! VT_BUSY(i)) 1101 if (! VT_BUSY(i))
1102 vc_deallocate(i); 1102 vc_deallocate(i);
1103 release_console_sem(); 1103 console_unlock();
1104 } else { 1104 } else {
1105 /* deallocate a single console, if possible */ 1105 /* deallocate a single console, if possible */
1106 arg--; 1106 arg--;
1107 if (VT_BUSY(arg)) 1107 if (VT_BUSY(arg))
1108 ret = -EBUSY; 1108 ret = -EBUSY;
1109 else if (arg) { /* leave 0 */ 1109 else if (arg) { /* leave 0 */
1110 acquire_console_sem(); 1110 console_lock();
1111 vc_deallocate(arg); 1111 vc_deallocate(arg);
1112 release_console_sem(); 1112 console_unlock();
1113 } 1113 }
1114 } 1114 }
1115 break; 1115 break;
@@ -1126,7 +1126,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
1126 get_user(cc, &vtsizes->v_cols)) 1126 get_user(cc, &vtsizes->v_cols))
1127 ret = -EFAULT; 1127 ret = -EFAULT;
1128 else { 1128 else {
1129 acquire_console_sem(); 1129 console_lock();
1130 for (i = 0; i < MAX_NR_CONSOLES; i++) { 1130 for (i = 0; i < MAX_NR_CONSOLES; i++) {
1131 vc = vc_cons[i].d; 1131 vc = vc_cons[i].d;
1132 1132
@@ -1135,7 +1135,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
1135 vc_resize(vc_cons[i].d, cc, ll); 1135 vc_resize(vc_cons[i].d, cc, ll);
1136 } 1136 }
1137 } 1137 }
1138 release_console_sem(); 1138 console_unlock();
1139 } 1139 }
1140 break; 1140 break;
1141 } 1141 }
@@ -1187,14 +1187,14 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
1187 for (i = 0; i < MAX_NR_CONSOLES; i++) { 1187 for (i = 0; i < MAX_NR_CONSOLES; i++) {
1188 if (!vc_cons[i].d) 1188 if (!vc_cons[i].d)
1189 continue; 1189 continue;
1190 acquire_console_sem(); 1190 console_lock();
1191 if (vlin) 1191 if (vlin)
1192 vc_cons[i].d->vc_scan_lines = vlin; 1192 vc_cons[i].d->vc_scan_lines = vlin;
1193 if (clin) 1193 if (clin)
1194 vc_cons[i].d->vc_font.height = clin; 1194 vc_cons[i].d->vc_font.height = clin;
1195 vc_cons[i].d->vc_resize_user = 1; 1195 vc_cons[i].d->vc_resize_user = 1;
1196 vc_resize(vc_cons[i].d, cc, ll); 1196 vc_resize(vc_cons[i].d, cc, ll);
1197 release_console_sem(); 1197 console_unlock();
1198 } 1198 }
1199 break; 1199 break;
1200 } 1200 }
@@ -1367,7 +1367,7 @@ void vc_SAK(struct work_struct *work)
1367 struct vc_data *vc; 1367 struct vc_data *vc;
1368 struct tty_struct *tty; 1368 struct tty_struct *tty;
1369 1369
1370 acquire_console_sem(); 1370 console_lock();
1371 vc = vc_con->d; 1371 vc = vc_con->d;
1372 if (vc) { 1372 if (vc) {
1373 tty = vc->port.tty; 1373 tty = vc->port.tty;
@@ -1379,7 +1379,7 @@ void vc_SAK(struct work_struct *work)
1379 __do_SAK(tty); 1379 __do_SAK(tty);
1380 reset_vc(vc); 1380 reset_vc(vc);
1381 } 1381 }
1382 release_console_sem(); 1382 console_unlock();
1383} 1383}
1384 1384
1385#ifdef CONFIG_COMPAT 1385#ifdef CONFIG_COMPAT
@@ -1737,10 +1737,10 @@ int vt_move_to_console(unsigned int vt, int alloc)
1737{ 1737{
1738 int prev; 1738 int prev;
1739 1739
1740 acquire_console_sem(); 1740 console_lock();
1741 /* Graphics mode - up to X */ 1741 /* Graphics mode - up to X */
1742 if (disable_vt_switch) { 1742 if (disable_vt_switch) {
1743 release_console_sem(); 1743 console_unlock();
1744 return 0; 1744 return 0;
1745 } 1745 }
1746 prev = fg_console; 1746 prev = fg_console;
@@ -1748,7 +1748,7 @@ int vt_move_to_console(unsigned int vt, int alloc)
1748 if (alloc && vc_allocate(vt)) { 1748 if (alloc && vc_allocate(vt)) {
1749 /* we can't have a free VC for now. Too bad, 1749 /* we can't have a free VC for now. Too bad,
1750 * we don't want to mess the screen for now. */ 1750 * we don't want to mess the screen for now. */
1751 release_console_sem(); 1751 console_unlock();
1752 return -ENOSPC; 1752 return -ENOSPC;
1753 } 1753 }
1754 1754
@@ -1758,10 +1758,10 @@ int vt_move_to_console(unsigned int vt, int alloc)
1758 * Let the calling function know so it can decide 1758 * Let the calling function know so it can decide
1759 * what to do. 1759 * what to do.
1760 */ 1760 */
1761 release_console_sem(); 1761 console_unlock();
1762 return -EIO; 1762 return -EIO;
1763 } 1763 }
1764 release_console_sem(); 1764 console_unlock();
1765 tty_lock(); 1765 tty_lock();
1766 if (vt_waitactive(vt + 1)) { 1766 if (vt_waitactive(vt + 1)) {
1767 pr_debug("Suspend: Can't switch VCs."); 1767 pr_debug("Suspend: Can't switch VCs.");
@@ -1781,8 +1781,8 @@ int vt_move_to_console(unsigned int vt, int alloc)
1781 */ 1781 */
1782void pm_set_vt_switch(int do_switch) 1782void pm_set_vt_switch(int do_switch)
1783{ 1783{
1784 acquire_console_sem(); 1784 console_lock();
1785 disable_vt_switch = !do_switch; 1785 disable_vt_switch = !do_switch;
1786 release_console_sem(); 1786 console_unlock();
1787} 1787}
1788EXPORT_SYMBOL(pm_set_vt_switch); 1788EXPORT_SYMBOL(pm_set_vt_switch);
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 6ee4451bfe2d..47085e5879ab 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -342,7 +342,7 @@ static ssize_t wdm_write
342 goto outnp; 342 goto outnp;
343 } 343 }
344 344
345 if (!file->f_flags && O_NONBLOCK) 345 if (!(file->f_flags & O_NONBLOCK))
346 r = wait_event_interruptible(desc->wait, !test_bit(WDM_IN_USE, 346 r = wait_event_interruptible(desc->wait, !test_bit(WDM_IN_USE,
347 &desc->flags)); 347 &desc->flags));
348 else 348 else
diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig
index bcc24779ba0e..18d02e32a3d5 100644
--- a/drivers/usb/core/Kconfig
+++ b/drivers/usb/core/Kconfig
@@ -123,9 +123,9 @@ config USB_OTG
123 123
124config USB_OTG_WHITELIST 124config USB_OTG_WHITELIST
125 bool "Rely on OTG Targeted Peripherals List" 125 bool "Rely on OTG Targeted Peripherals List"
126 depends on USB_OTG || EMBEDDED 126 depends on USB_OTG || EXPERT
127 default y if USB_OTG 127 default y if USB_OTG
128 default n if EMBEDDED 128 default n if EXPERT
129 help 129 help
130 If you say Y here, the "otg_whitelist.h" file will be used as a 130 If you say Y here, the "otg_whitelist.h" file will be used as a
131 product whitelist, so USB peripherals not listed there will be 131 product whitelist, so USB peripherals not listed there will be
@@ -141,7 +141,7 @@ config USB_OTG_WHITELIST
141 141
142config USB_OTG_BLACKLIST_HUB 142config USB_OTG_BLACKLIST_HUB
143 bool "Disable external hubs" 143 bool "Disable external hubs"
144 depends on USB_OTG || EMBEDDED 144 depends on USB_OTG || EXPERT
145 help 145 help
146 If you say Y here, then Linux will refuse to enumerate 146 If you say Y here, then Linux will refuse to enumerate
147 external hubs. OTG hosts are allowed to reduce hardware 147 external hubs. OTG hosts are allowed to reduce hardware
diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c
index 9da250563027..df502a98d0df 100644
--- a/drivers/usb/core/endpoint.c
+++ b/drivers/usb/core/endpoint.c
@@ -192,12 +192,12 @@ int usb_create_ep_devs(struct device *parent,
192 ep_dev->dev.parent = parent; 192 ep_dev->dev.parent = parent;
193 ep_dev->dev.release = ep_device_release; 193 ep_dev->dev.release = ep_device_release;
194 dev_set_name(&ep_dev->dev, "ep_%02x", endpoint->desc.bEndpointAddress); 194 dev_set_name(&ep_dev->dev, "ep_%02x", endpoint->desc.bEndpointAddress);
195 device_enable_async_suspend(&ep_dev->dev);
196 195
197 retval = device_register(&ep_dev->dev); 196 retval = device_register(&ep_dev->dev);
198 if (retval) 197 if (retval)
199 goto error_register; 198 goto error_register;
200 199
200 device_enable_async_suspend(&ep_dev->dev);
201 endpoint->ep_dev = ep_dev; 201 endpoint->ep_dev = ep_dev;
202 return retval; 202 return retval;
203 203
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
index b55d46070a25..f71e8e307e0f 100644
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -405,7 +405,12 @@ static int suspend_common(struct device *dev, bool do_wakeup)
405 return retval; 405 return retval;
406 } 406 }
407 407
408 synchronize_irq(pci_dev->irq); 408 /* If MSI-X is enabled, the driver will have synchronized all vectors
409 * in pci_suspend(). If MSI or legacy PCI is enabled, that will be
410 * synchronized here.
411 */
412 if (!hcd->msix_enabled)
413 synchronize_irq(pci_dev->irq);
409 414
410 /* Downstream ports from this root hub should already be quiesced, so 415 /* Downstream ports from this root hub should already be quiesced, so
411 * there will be no DMA activity. Now we can shut down the upstream 416 * there will be no DMA activity. Now we can shut down the upstream
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index b98efae6a1cf..4310cc4b1cb5 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -676,6 +676,8 @@ static void hub_init_func3(struct work_struct *ws);
676static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) 676static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
677{ 677{
678 struct usb_device *hdev = hub->hdev; 678 struct usb_device *hdev = hub->hdev;
679 struct usb_hcd *hcd;
680 int ret;
679 int port1; 681 int port1;
680 int status; 682 int status;
681 bool need_debounce_delay = false; 683 bool need_debounce_delay = false;
@@ -714,6 +716,25 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
714 usb_autopm_get_interface_no_resume( 716 usb_autopm_get_interface_no_resume(
715 to_usb_interface(hub->intfdev)); 717 to_usb_interface(hub->intfdev));
716 return; /* Continues at init2: below */ 718 return; /* Continues at init2: below */
719 } else if (type == HUB_RESET_RESUME) {
720 /* The internal host controller state for the hub device
721 * may be gone after a host power loss on system resume.
722 * Update the device's info so the HW knows it's a hub.
723 */
724 hcd = bus_to_hcd(hdev->bus);
725 if (hcd->driver->update_hub_device) {
726 ret = hcd->driver->update_hub_device(hcd, hdev,
727 &hub->tt, GFP_NOIO);
728 if (ret < 0) {
729 dev_err(hub->intfdev, "Host not "
730 "accepting hub info "
731 "update.\n");
732 dev_err(hub->intfdev, "LS/FS devices "
733 "and hubs may not work "
734 "under this hub\n.");
735 }
736 }
737 hub_power_on(hub, true);
717 } else { 738 } else {
718 hub_power_on(hub, true); 739 hub_power_on(hub, true);
719 } 740 }
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 1dc9739277b4..06bb9d4587e9 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -509,7 +509,7 @@ config USB_LANGWELL
509 select USB_GADGET_SELECTED 509 select USB_GADGET_SELECTED
510 510
511config USB_GADGET_EG20T 511config USB_GADGET_EG20T
512 boolean "Intel EG20T(Topcliff) USB Device controller" 512 boolean "Intel EG20T PCH/OKI SEMICONDUCTOR ML7213 IOH UDC"
513 depends on PCI 513 depends on PCI
514 select USB_GADGET_DUALSPEED 514 select USB_GADGET_DUALSPEED
515 help 515 help
@@ -525,6 +525,11 @@ config USB_GADGET_EG20T
525 This driver dose not support interrupt transfer or isochronous 525 This driver dose not support interrupt transfer or isochronous
526 transfer modes. 526 transfer modes.
527 527
528 This driver also can be used for OKI SEMICONDUCTOR's ML7213 which is
529 for IVI(In-Vehicle Infotainment) use.
530 ML7213 is companion chip for Intel Atom E6xx series.
531 ML7213 is completely compatible for Intel EG20T PCH.
532
528config USB_EG20T 533config USB_EG20T
529 tristate 534 tristate
530 depends on USB_GADGET_EG20T 535 depends on USB_GADGET_EG20T
diff --git a/drivers/usb/gadget/ci13xxx_udc.c b/drivers/usb/gadget/ci13xxx_udc.c
index 31656a2b4ab4..a1c67ae1572a 100644
--- a/drivers/usb/gadget/ci13xxx_udc.c
+++ b/drivers/usb/gadget/ci13xxx_udc.c
@@ -76,10 +76,21 @@ static DEFINE_SPINLOCK(udc_lock);
76 76
77/* control endpoint description */ 77/* control endpoint description */
78static const struct usb_endpoint_descriptor 78static const struct usb_endpoint_descriptor
79ctrl_endpt_desc = { 79ctrl_endpt_out_desc = {
80 .bLength = USB_DT_ENDPOINT_SIZE, 80 .bLength = USB_DT_ENDPOINT_SIZE,
81 .bDescriptorType = USB_DT_ENDPOINT, 81 .bDescriptorType = USB_DT_ENDPOINT,
82 82
83 .bEndpointAddress = USB_DIR_OUT,
84 .bmAttributes = USB_ENDPOINT_XFER_CONTROL,
85 .wMaxPacketSize = cpu_to_le16(CTRL_PAYLOAD_MAX),
86};
87
88static const struct usb_endpoint_descriptor
89ctrl_endpt_in_desc = {
90 .bLength = USB_DT_ENDPOINT_SIZE,
91 .bDescriptorType = USB_DT_ENDPOINT,
92
93 .bEndpointAddress = USB_DIR_IN,
83 .bmAttributes = USB_ENDPOINT_XFER_CONTROL, 94 .bmAttributes = USB_ENDPOINT_XFER_CONTROL,
84 .wMaxPacketSize = cpu_to_le16(CTRL_PAYLOAD_MAX), 95 .wMaxPacketSize = cpu_to_le16(CTRL_PAYLOAD_MAX),
85}; 96};
@@ -265,10 +276,10 @@ static int hw_device_init(void __iomem *base)
265 hw_bank.size /= sizeof(u32); 276 hw_bank.size /= sizeof(u32);
266 277
267 reg = hw_aread(ABS_DCCPARAMS, DCCPARAMS_DEN) >> ffs_nr(DCCPARAMS_DEN); 278 reg = hw_aread(ABS_DCCPARAMS, DCCPARAMS_DEN) >> ffs_nr(DCCPARAMS_DEN);
268 if (reg == 0 || reg > ENDPT_MAX) 279 hw_ep_max = reg * 2; /* cache hw ENDPT_MAX */
269 return -ENODEV;
270 280
271 hw_ep_max = reg; /* cache hw ENDPT_MAX */ 281 if (hw_ep_max == 0 || hw_ep_max > ENDPT_MAX)
282 return -ENODEV;
272 283
273 /* setup lock mode ? */ 284 /* setup lock mode ? */
274 285
@@ -1197,16 +1208,17 @@ static ssize_t show_qheads(struct device *dev, struct device_attribute *attr,
1197 } 1208 }
1198 1209
1199 spin_lock_irqsave(udc->lock, flags); 1210 spin_lock_irqsave(udc->lock, flags);
1200 for (i = 0; i < hw_ep_max; i++) { 1211 for (i = 0; i < hw_ep_max/2; i++) {
1201 struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[i]; 1212 struct ci13xxx_ep *mEpRx = &udc->ci13xxx_ep[i];
1213 struct ci13xxx_ep *mEpTx = &udc->ci13xxx_ep[i + hw_ep_max/2];
1202 n += scnprintf(buf + n, PAGE_SIZE - n, 1214 n += scnprintf(buf + n, PAGE_SIZE - n,
1203 "EP=%02i: RX=%08X TX=%08X\n", 1215 "EP=%02i: RX=%08X TX=%08X\n",
1204 i, (u32)mEp->qh[RX].dma, (u32)mEp->qh[TX].dma); 1216 i, (u32)mEpRx->qh.dma, (u32)mEpTx->qh.dma);
1205 for (j = 0; j < (sizeof(struct ci13xxx_qh)/sizeof(u32)); j++) { 1217 for (j = 0; j < (sizeof(struct ci13xxx_qh)/sizeof(u32)); j++) {
1206 n += scnprintf(buf + n, PAGE_SIZE - n, 1218 n += scnprintf(buf + n, PAGE_SIZE - n,
1207 " %04X: %08X %08X\n", j, 1219 " %04X: %08X %08X\n", j,
1208 *((u32 *)mEp->qh[RX].ptr + j), 1220 *((u32 *)mEpRx->qh.ptr + j),
1209 *((u32 *)mEp->qh[TX].ptr + j)); 1221 *((u32 *)mEpTx->qh.ptr + j));
1210 } 1222 }
1211 } 1223 }
1212 spin_unlock_irqrestore(udc->lock, flags); 1224 spin_unlock_irqrestore(udc->lock, flags);
@@ -1293,7 +1305,7 @@ static ssize_t show_requests(struct device *dev, struct device_attribute *attr,
1293 unsigned long flags; 1305 unsigned long flags;
1294 struct list_head *ptr = NULL; 1306 struct list_head *ptr = NULL;
1295 struct ci13xxx_req *req = NULL; 1307 struct ci13xxx_req *req = NULL;
1296 unsigned i, j, k, n = 0, qSize = sizeof(struct ci13xxx_td)/sizeof(u32); 1308 unsigned i, j, n = 0, qSize = sizeof(struct ci13xxx_td)/sizeof(u32);
1297 1309
1298 dbg_trace("[%s] %p\n", __func__, buf); 1310 dbg_trace("[%s] %p\n", __func__, buf);
1299 if (attr == NULL || buf == NULL) { 1311 if (attr == NULL || buf == NULL) {
@@ -1303,22 +1315,20 @@ static ssize_t show_requests(struct device *dev, struct device_attribute *attr,
1303 1315
1304 spin_lock_irqsave(udc->lock, flags); 1316 spin_lock_irqsave(udc->lock, flags);
1305 for (i = 0; i < hw_ep_max; i++) 1317 for (i = 0; i < hw_ep_max; i++)
1306 for (k = RX; k <= TX; k++) 1318 list_for_each(ptr, &udc->ci13xxx_ep[i].qh.queue)
1307 list_for_each(ptr, &udc->ci13xxx_ep[i].qh[k].queue) 1319 {
1308 { 1320 req = list_entry(ptr, struct ci13xxx_req, queue);
1309 req = list_entry(ptr, 1321
1310 struct ci13xxx_req, queue); 1322 n += scnprintf(buf + n, PAGE_SIZE - n,
1323 "EP=%02i: TD=%08X %s\n",
1324 i % hw_ep_max/2, (u32)req->dma,
1325 ((i < hw_ep_max/2) ? "RX" : "TX"));
1311 1326
1327 for (j = 0; j < qSize; j++)
1312 n += scnprintf(buf + n, PAGE_SIZE - n, 1328 n += scnprintf(buf + n, PAGE_SIZE - n,
1313 "EP=%02i: TD=%08X %s\n", 1329 " %04X: %08X\n", j,
1314 i, (u32)req->dma, 1330 *((u32 *)req->ptr + j));
1315 ((k == RX) ? "RX" : "TX")); 1331 }
1316
1317 for (j = 0; j < qSize; j++)
1318 n += scnprintf(buf + n, PAGE_SIZE - n,
1319 " %04X: %08X\n", j,
1320 *((u32 *)req->ptr + j));
1321 }
1322 spin_unlock_irqrestore(udc->lock, flags); 1332 spin_unlock_irqrestore(udc->lock, flags);
1323 1333
1324 return n; 1334 return n;
@@ -1467,12 +1477,12 @@ static int _hardware_enqueue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq)
1467 * At this point it's guaranteed exclusive access to qhead 1477 * At this point it's guaranteed exclusive access to qhead
1468 * (endpt is not primed) so it's no need to use tripwire 1478 * (endpt is not primed) so it's no need to use tripwire
1469 */ 1479 */
1470 mEp->qh[mEp->dir].ptr->td.next = mReq->dma; /* TERMINATE = 0 */ 1480 mEp->qh.ptr->td.next = mReq->dma; /* TERMINATE = 0 */
1471 mEp->qh[mEp->dir].ptr->td.token &= ~TD_STATUS; /* clear status */ 1481 mEp->qh.ptr->td.token &= ~TD_STATUS; /* clear status */
1472 if (mReq->req.zero == 0) 1482 if (mReq->req.zero == 0)
1473 mEp->qh[mEp->dir].ptr->cap |= QH_ZLT; 1483 mEp->qh.ptr->cap |= QH_ZLT;
1474 else 1484 else
1475 mEp->qh[mEp->dir].ptr->cap &= ~QH_ZLT; 1485 mEp->qh.ptr->cap &= ~QH_ZLT;
1476 1486
1477 wmb(); /* synchronize before ep prime */ 1487 wmb(); /* synchronize before ep prime */
1478 1488
@@ -1542,11 +1552,11 @@ __acquires(mEp->lock)
1542 1552
1543 hw_ep_flush(mEp->num, mEp->dir); 1553 hw_ep_flush(mEp->num, mEp->dir);
1544 1554
1545 while (!list_empty(&mEp->qh[mEp->dir].queue)) { 1555 while (!list_empty(&mEp->qh.queue)) {
1546 1556
1547 /* pop oldest request */ 1557 /* pop oldest request */
1548 struct ci13xxx_req *mReq = \ 1558 struct ci13xxx_req *mReq = \
1549 list_entry(mEp->qh[mEp->dir].queue.next, 1559 list_entry(mEp->qh.queue.next,
1550 struct ci13xxx_req, queue); 1560 struct ci13xxx_req, queue);
1551 list_del_init(&mReq->queue); 1561 list_del_init(&mReq->queue);
1552 mReq->req.status = -ESHUTDOWN; 1562 mReq->req.status = -ESHUTDOWN;
@@ -1571,8 +1581,6 @@ static int _gadget_stop_activity(struct usb_gadget *gadget)
1571{ 1581{
1572 struct usb_ep *ep; 1582 struct usb_ep *ep;
1573 struct ci13xxx *udc = container_of(gadget, struct ci13xxx, gadget); 1583 struct ci13xxx *udc = container_of(gadget, struct ci13xxx, gadget);
1574 struct ci13xxx_ep *mEp = container_of(gadget->ep0,
1575 struct ci13xxx_ep, ep);
1576 1584
1577 trace("%p", gadget); 1585 trace("%p", gadget);
1578 1586
@@ -1583,7 +1591,8 @@ static int _gadget_stop_activity(struct usb_gadget *gadget)
1583 gadget_for_each_ep(ep, gadget) { 1591 gadget_for_each_ep(ep, gadget) {
1584 usb_ep_fifo_flush(ep); 1592 usb_ep_fifo_flush(ep);
1585 } 1593 }
1586 usb_ep_fifo_flush(gadget->ep0); 1594 usb_ep_fifo_flush(&udc->ep0out.ep);
1595 usb_ep_fifo_flush(&udc->ep0in.ep);
1587 1596
1588 udc->driver->disconnect(gadget); 1597 udc->driver->disconnect(gadget);
1589 1598
@@ -1591,11 +1600,12 @@ static int _gadget_stop_activity(struct usb_gadget *gadget)
1591 gadget_for_each_ep(ep, gadget) { 1600 gadget_for_each_ep(ep, gadget) {
1592 usb_ep_disable(ep); 1601 usb_ep_disable(ep);
1593 } 1602 }
1594 usb_ep_disable(gadget->ep0); 1603 usb_ep_disable(&udc->ep0out.ep);
1604 usb_ep_disable(&udc->ep0in.ep);
1595 1605
1596 if (mEp->status != NULL) { 1606 if (udc->status != NULL) {
1597 usb_ep_free_request(gadget->ep0, mEp->status); 1607 usb_ep_free_request(&udc->ep0in.ep, udc->status);
1598 mEp->status = NULL; 1608 udc->status = NULL;
1599 } 1609 }
1600 1610
1601 return 0; 1611 return 0;
@@ -1614,7 +1624,6 @@ static void isr_reset_handler(struct ci13xxx *udc)
1614__releases(udc->lock) 1624__releases(udc->lock)
1615__acquires(udc->lock) 1625__acquires(udc->lock)
1616{ 1626{
1617 struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[0];
1618 int retval; 1627 int retval;
1619 1628
1620 trace("%p", udc); 1629 trace("%p", udc);
@@ -1635,11 +1644,15 @@ __acquires(udc->lock)
1635 if (retval) 1644 if (retval)
1636 goto done; 1645 goto done;
1637 1646
1638 retval = usb_ep_enable(&mEp->ep, &ctrl_endpt_desc); 1647 retval = usb_ep_enable(&udc->ep0out.ep, &ctrl_endpt_out_desc);
1648 if (retval)
1649 goto done;
1650
1651 retval = usb_ep_enable(&udc->ep0in.ep, &ctrl_endpt_in_desc);
1639 if (!retval) { 1652 if (!retval) {
1640 mEp->status = usb_ep_alloc_request(&mEp->ep, GFP_ATOMIC); 1653 udc->status = usb_ep_alloc_request(&udc->ep0in.ep, GFP_ATOMIC);
1641 if (mEp->status == NULL) { 1654 if (udc->status == NULL) {
1642 usb_ep_disable(&mEp->ep); 1655 usb_ep_disable(&udc->ep0out.ep);
1643 retval = -ENOMEM; 1656 retval = -ENOMEM;
1644 } 1657 }
1645 } 1658 }
@@ -1672,16 +1685,17 @@ static void isr_get_status_complete(struct usb_ep *ep, struct usb_request *req)
1672 1685
1673/** 1686/**
1674 * isr_get_status_response: get_status request response 1687 * isr_get_status_response: get_status request response
1675 * @ep: endpoint 1688 * @udc: udc struct
1676 * @setup: setup request packet 1689 * @setup: setup request packet
1677 * 1690 *
1678 * This function returns an error code 1691 * This function returns an error code
1679 */ 1692 */
1680static int isr_get_status_response(struct ci13xxx_ep *mEp, 1693static int isr_get_status_response(struct ci13xxx *udc,
1681 struct usb_ctrlrequest *setup) 1694 struct usb_ctrlrequest *setup)
1682__releases(mEp->lock) 1695__releases(mEp->lock)
1683__acquires(mEp->lock) 1696__acquires(mEp->lock)
1684{ 1697{
1698 struct ci13xxx_ep *mEp = &udc->ep0in;
1685 struct usb_request *req = NULL; 1699 struct usb_request *req = NULL;
1686 gfp_t gfp_flags = GFP_ATOMIC; 1700 gfp_t gfp_flags = GFP_ATOMIC;
1687 int dir, num, retval; 1701 int dir, num, retval;
@@ -1736,27 +1750,23 @@ __acquires(mEp->lock)
1736 1750
1737/** 1751/**
1738 * isr_setup_status_phase: queues the status phase of a setup transation 1752 * isr_setup_status_phase: queues the status phase of a setup transation
1739 * @mEp: endpoint 1753 * @udc: udc struct
1740 * 1754 *
1741 * This function returns an error code 1755 * This function returns an error code
1742 */ 1756 */
1743static int isr_setup_status_phase(struct ci13xxx_ep *mEp) 1757static int isr_setup_status_phase(struct ci13xxx *udc)
1744__releases(mEp->lock) 1758__releases(mEp->lock)
1745__acquires(mEp->lock) 1759__acquires(mEp->lock)
1746{ 1760{
1747 int retval; 1761 int retval;
1762 struct ci13xxx_ep *mEp;
1748 1763
1749 trace("%p", mEp); 1764 trace("%p", udc);
1750
1751 /* mEp is always valid & configured */
1752
1753 if (mEp->type == USB_ENDPOINT_XFER_CONTROL)
1754 mEp->dir = (mEp->dir == TX) ? RX : TX;
1755 1765
1756 mEp->status->no_interrupt = 1; 1766 mEp = (udc->ep0_dir == TX) ? &udc->ep0out : &udc->ep0in;
1757 1767
1758 spin_unlock(mEp->lock); 1768 spin_unlock(mEp->lock);
1759 retval = usb_ep_queue(&mEp->ep, mEp->status, GFP_ATOMIC); 1769 retval = usb_ep_queue(&mEp->ep, udc->status, GFP_ATOMIC);
1760 spin_lock(mEp->lock); 1770 spin_lock(mEp->lock);
1761 1771
1762 return retval; 1772 return retval;
@@ -1778,11 +1788,11 @@ __acquires(mEp->lock)
1778 1788
1779 trace("%p", mEp); 1789 trace("%p", mEp);
1780 1790
1781 if (list_empty(&mEp->qh[mEp->dir].queue)) 1791 if (list_empty(&mEp->qh.queue))
1782 return -EINVAL; 1792 return -EINVAL;
1783 1793
1784 /* pop oldest request */ 1794 /* pop oldest request */
1785 mReq = list_entry(mEp->qh[mEp->dir].queue.next, 1795 mReq = list_entry(mEp->qh.queue.next,
1786 struct ci13xxx_req, queue); 1796 struct ci13xxx_req, queue);
1787 list_del_init(&mReq->queue); 1797 list_del_init(&mReq->queue);
1788 1798
@@ -1794,10 +1804,10 @@ __acquires(mEp->lock)
1794 1804
1795 dbg_done(_usb_addr(mEp), mReq->ptr->token, retval); 1805 dbg_done(_usb_addr(mEp), mReq->ptr->token, retval);
1796 1806
1797 if (!list_empty(&mEp->qh[mEp->dir].queue)) { 1807 if (!list_empty(&mEp->qh.queue)) {
1798 struct ci13xxx_req* mReqEnq; 1808 struct ci13xxx_req* mReqEnq;
1799 1809
1800 mReqEnq = list_entry(mEp->qh[mEp->dir].queue.next, 1810 mReqEnq = list_entry(mEp->qh.queue.next,
1801 struct ci13xxx_req, queue); 1811 struct ci13xxx_req, queue);
1802 _hardware_enqueue(mEp, mReqEnq); 1812 _hardware_enqueue(mEp, mReqEnq);
1803 } 1813 }
@@ -1836,16 +1846,14 @@ __acquires(udc->lock)
1836 int type, num, err = -EINVAL; 1846 int type, num, err = -EINVAL;
1837 struct usb_ctrlrequest req; 1847 struct usb_ctrlrequest req;
1838 1848
1839
1840 if (mEp->desc == NULL) 1849 if (mEp->desc == NULL)
1841 continue; /* not configured */ 1850 continue; /* not configured */
1842 1851
1843 if ((mEp->dir == RX && hw_test_and_clear_complete(i)) || 1852 if (hw_test_and_clear_complete(i)) {
1844 (mEp->dir == TX && hw_test_and_clear_complete(i + 16))) {
1845 err = isr_tr_complete_low(mEp); 1853 err = isr_tr_complete_low(mEp);
1846 if (mEp->type == USB_ENDPOINT_XFER_CONTROL) { 1854 if (mEp->type == USB_ENDPOINT_XFER_CONTROL) {
1847 if (err > 0) /* needs status phase */ 1855 if (err > 0) /* needs status phase */
1848 err = isr_setup_status_phase(mEp); 1856 err = isr_setup_status_phase(udc);
1849 if (err < 0) { 1857 if (err < 0) {
1850 dbg_event(_usb_addr(mEp), 1858 dbg_event(_usb_addr(mEp),
1851 "ERROR", err); 1859 "ERROR", err);
@@ -1866,15 +1874,22 @@ __acquires(udc->lock)
1866 continue; 1874 continue;
1867 } 1875 }
1868 1876
1877 /*
1878 * Flush data and handshake transactions of previous
1879 * setup packet.
1880 */
1881 _ep_nuke(&udc->ep0out);
1882 _ep_nuke(&udc->ep0in);
1883
1869 /* read_setup_packet */ 1884 /* read_setup_packet */
1870 do { 1885 do {
1871 hw_test_and_set_setup_guard(); 1886 hw_test_and_set_setup_guard();
1872 memcpy(&req, &mEp->qh[RX].ptr->setup, sizeof(req)); 1887 memcpy(&req, &mEp->qh.ptr->setup, sizeof(req));
1873 } while (!hw_test_and_clear_setup_guard()); 1888 } while (!hw_test_and_clear_setup_guard());
1874 1889
1875 type = req.bRequestType; 1890 type = req.bRequestType;
1876 1891
1877 mEp->dir = (type & USB_DIR_IN) ? TX : RX; 1892 udc->ep0_dir = (type & USB_DIR_IN) ? TX : RX;
1878 1893
1879 dbg_setup(_usb_addr(mEp), &req); 1894 dbg_setup(_usb_addr(mEp), &req);
1880 1895
@@ -1895,7 +1910,7 @@ __acquires(udc->lock)
1895 if (err) 1910 if (err)
1896 break; 1911 break;
1897 } 1912 }
1898 err = isr_setup_status_phase(mEp); 1913 err = isr_setup_status_phase(udc);
1899 break; 1914 break;
1900 case USB_REQ_GET_STATUS: 1915 case USB_REQ_GET_STATUS:
1901 if (type != (USB_DIR_IN|USB_RECIP_DEVICE) && 1916 if (type != (USB_DIR_IN|USB_RECIP_DEVICE) &&
@@ -1905,7 +1920,7 @@ __acquires(udc->lock)
1905 if (le16_to_cpu(req.wLength) != 2 || 1920 if (le16_to_cpu(req.wLength) != 2 ||
1906 le16_to_cpu(req.wValue) != 0) 1921 le16_to_cpu(req.wValue) != 0)
1907 break; 1922 break;
1908 err = isr_get_status_response(mEp, &req); 1923 err = isr_get_status_response(udc, &req);
1909 break; 1924 break;
1910 case USB_REQ_SET_ADDRESS: 1925 case USB_REQ_SET_ADDRESS:
1911 if (type != (USB_DIR_OUT|USB_RECIP_DEVICE)) 1926 if (type != (USB_DIR_OUT|USB_RECIP_DEVICE))
@@ -1916,7 +1931,7 @@ __acquires(udc->lock)
1916 err = hw_usb_set_address((u8)le16_to_cpu(req.wValue)); 1931 err = hw_usb_set_address((u8)le16_to_cpu(req.wValue));
1917 if (err) 1932 if (err)
1918 break; 1933 break;
1919 err = isr_setup_status_phase(mEp); 1934 err = isr_setup_status_phase(udc);
1920 break; 1935 break;
1921 case USB_REQ_SET_FEATURE: 1936 case USB_REQ_SET_FEATURE:
1922 if (type != (USB_DIR_OUT|USB_RECIP_ENDPOINT) && 1937 if (type != (USB_DIR_OUT|USB_RECIP_ENDPOINT) &&
@@ -1932,12 +1947,12 @@ __acquires(udc->lock)
1932 spin_lock(udc->lock); 1947 spin_lock(udc->lock);
1933 if (err) 1948 if (err)
1934 break; 1949 break;
1935 err = isr_setup_status_phase(mEp); 1950 err = isr_setup_status_phase(udc);
1936 break; 1951 break;
1937 default: 1952 default:
1938delegate: 1953delegate:
1939 if (req.wLength == 0) /* no data phase */ 1954 if (req.wLength == 0) /* no data phase */
1940 mEp->dir = TX; 1955 udc->ep0_dir = TX;
1941 1956
1942 spin_unlock(udc->lock); 1957 spin_unlock(udc->lock);
1943 err = udc->driver->setup(&udc->gadget, &req); 1958 err = udc->driver->setup(&udc->gadget, &req);
@@ -1968,7 +1983,7 @@ static int ep_enable(struct usb_ep *ep,
1968 const struct usb_endpoint_descriptor *desc) 1983 const struct usb_endpoint_descriptor *desc)
1969{ 1984{
1970 struct ci13xxx_ep *mEp = container_of(ep, struct ci13xxx_ep, ep); 1985 struct ci13xxx_ep *mEp = container_of(ep, struct ci13xxx_ep, ep);
1971 int direction, retval = 0; 1986 int retval = 0;
1972 unsigned long flags; 1987 unsigned long flags;
1973 1988
1974 trace("%p, %p", ep, desc); 1989 trace("%p, %p", ep, desc);
@@ -1982,7 +1997,7 @@ static int ep_enable(struct usb_ep *ep,
1982 1997
1983 mEp->desc = desc; 1998 mEp->desc = desc;
1984 1999
1985 if (!list_empty(&mEp->qh[mEp->dir].queue)) 2000 if (!list_empty(&mEp->qh.queue))
1986 warn("enabling a non-empty endpoint!"); 2001 warn("enabling a non-empty endpoint!");
1987 2002
1988 mEp->dir = usb_endpoint_dir_in(desc) ? TX : RX; 2003 mEp->dir = usb_endpoint_dir_in(desc) ? TX : RX;
@@ -1991,29 +2006,22 @@ static int ep_enable(struct usb_ep *ep,
1991 2006
1992 mEp->ep.maxpacket = __constant_le16_to_cpu(desc->wMaxPacketSize); 2007 mEp->ep.maxpacket = __constant_le16_to_cpu(desc->wMaxPacketSize);
1993 2008
1994 direction = mEp->dir; 2009 dbg_event(_usb_addr(mEp), "ENABLE", 0);
1995 do {
1996 dbg_event(_usb_addr(mEp), "ENABLE", 0);
1997 2010
1998 mEp->qh[mEp->dir].ptr->cap = 0; 2011 mEp->qh.ptr->cap = 0;
1999 2012
2000 if (mEp->type == USB_ENDPOINT_XFER_CONTROL) 2013 if (mEp->type == USB_ENDPOINT_XFER_CONTROL)
2001 mEp->qh[mEp->dir].ptr->cap |= QH_IOS; 2014 mEp->qh.ptr->cap |= QH_IOS;
2002 else if (mEp->type == USB_ENDPOINT_XFER_ISOC) 2015 else if (mEp->type == USB_ENDPOINT_XFER_ISOC)
2003 mEp->qh[mEp->dir].ptr->cap &= ~QH_MULT; 2016 mEp->qh.ptr->cap &= ~QH_MULT;
2004 else 2017 else
2005 mEp->qh[mEp->dir].ptr->cap &= ~QH_ZLT; 2018 mEp->qh.ptr->cap &= ~QH_ZLT;
2006
2007 mEp->qh[mEp->dir].ptr->cap |=
2008 (mEp->ep.maxpacket << ffs_nr(QH_MAX_PKT)) & QH_MAX_PKT;
2009 mEp->qh[mEp->dir].ptr->td.next |= TD_TERMINATE; /* needed? */
2010
2011 retval |= hw_ep_enable(mEp->num, mEp->dir, mEp->type);
2012 2019
2013 if (mEp->type == USB_ENDPOINT_XFER_CONTROL) 2020 mEp->qh.ptr->cap |=
2014 mEp->dir = (mEp->dir == TX) ? RX : TX; 2021 (mEp->ep.maxpacket << ffs_nr(QH_MAX_PKT)) & QH_MAX_PKT;
2022 mEp->qh.ptr->td.next |= TD_TERMINATE; /* needed? */
2015 2023
2016 } while (mEp->dir != direction); 2024 retval |= hw_ep_enable(mEp->num, mEp->dir, mEp->type);
2017 2025
2018 spin_unlock_irqrestore(mEp->lock, flags); 2026 spin_unlock_irqrestore(mEp->lock, flags);
2019 return retval; 2027 return retval;
@@ -2146,7 +2154,7 @@ static int ep_queue(struct usb_ep *ep, struct usb_request *req,
2146 spin_lock_irqsave(mEp->lock, flags); 2154 spin_lock_irqsave(mEp->lock, flags);
2147 2155
2148 if (mEp->type == USB_ENDPOINT_XFER_CONTROL && 2156 if (mEp->type == USB_ENDPOINT_XFER_CONTROL &&
2149 !list_empty(&mEp->qh[mEp->dir].queue)) { 2157 !list_empty(&mEp->qh.queue)) {
2150 _ep_nuke(mEp); 2158 _ep_nuke(mEp);
2151 retval = -EOVERFLOW; 2159 retval = -EOVERFLOW;
2152 warn("endpoint ctrl %X nuked", _usb_addr(mEp)); 2160 warn("endpoint ctrl %X nuked", _usb_addr(mEp));
@@ -2170,9 +2178,9 @@ static int ep_queue(struct usb_ep *ep, struct usb_request *req,
2170 /* push request */ 2178 /* push request */
2171 mReq->req.status = -EINPROGRESS; 2179 mReq->req.status = -EINPROGRESS;
2172 mReq->req.actual = 0; 2180 mReq->req.actual = 0;
2173 list_add_tail(&mReq->queue, &mEp->qh[mEp->dir].queue); 2181 list_add_tail(&mReq->queue, &mEp->qh.queue);
2174 2182
2175 if (list_is_singular(&mEp->qh[mEp->dir].queue)) 2183 if (list_is_singular(&mEp->qh.queue))
2176 retval = _hardware_enqueue(mEp, mReq); 2184 retval = _hardware_enqueue(mEp, mReq);
2177 2185
2178 if (retval == -EALREADY) { 2186 if (retval == -EALREADY) {
@@ -2199,7 +2207,7 @@ static int ep_dequeue(struct usb_ep *ep, struct usb_request *req)
2199 trace("%p, %p", ep, req); 2207 trace("%p, %p", ep, req);
2200 2208
2201 if (ep == NULL || req == NULL || mEp->desc == NULL || 2209 if (ep == NULL || req == NULL || mEp->desc == NULL ||
2202 list_empty(&mReq->queue) || list_empty(&mEp->qh[mEp->dir].queue)) 2210 list_empty(&mReq->queue) || list_empty(&mEp->qh.queue))
2203 return -EINVAL; 2211 return -EINVAL;
2204 2212
2205 spin_lock_irqsave(mEp->lock, flags); 2213 spin_lock_irqsave(mEp->lock, flags);
@@ -2244,7 +2252,7 @@ static int ep_set_halt(struct usb_ep *ep, int value)
2244#ifndef STALL_IN 2252#ifndef STALL_IN
2245 /* g_file_storage MS compliant but g_zero fails chapter 9 compliance */ 2253 /* g_file_storage MS compliant but g_zero fails chapter 9 compliance */
2246 if (value && mEp->type == USB_ENDPOINT_XFER_BULK && mEp->dir == TX && 2254 if (value && mEp->type == USB_ENDPOINT_XFER_BULK && mEp->dir == TX &&
2247 !list_empty(&mEp->qh[mEp->dir].queue)) { 2255 !list_empty(&mEp->qh.queue)) {
2248 spin_unlock_irqrestore(mEp->lock, flags); 2256 spin_unlock_irqrestore(mEp->lock, flags);
2249 return -EAGAIN; 2257 return -EAGAIN;
2250 } 2258 }
@@ -2355,7 +2363,7 @@ static int ci13xxx_vbus_session(struct usb_gadget *_gadget, int is_active)
2355 if (is_active) { 2363 if (is_active) {
2356 pm_runtime_get_sync(&_gadget->dev); 2364 pm_runtime_get_sync(&_gadget->dev);
2357 hw_device_reset(udc); 2365 hw_device_reset(udc);
2358 hw_device_state(udc->ci13xxx_ep[0].qh[RX].dma); 2366 hw_device_state(udc->ep0out.qh.dma);
2359 } else { 2367 } else {
2360 hw_device_state(0); 2368 hw_device_state(0);
2361 if (udc->udc_driver->notify_event) 2369 if (udc->udc_driver->notify_event)
@@ -2390,7 +2398,8 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
2390 int (*bind)(struct usb_gadget *)) 2398 int (*bind)(struct usb_gadget *))
2391{ 2399{
2392 struct ci13xxx *udc = _udc; 2400 struct ci13xxx *udc = _udc;
2393 unsigned long i, k, flags; 2401 unsigned long flags;
2402 int i, j;
2394 int retval = -ENOMEM; 2403 int retval = -ENOMEM;
2395 2404
2396 trace("%p", driver); 2405 trace("%p", driver);
@@ -2427,45 +2436,46 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
2427 2436
2428 info("hw_ep_max = %d", hw_ep_max); 2437 info("hw_ep_max = %d", hw_ep_max);
2429 2438
2430 udc->driver = driver;
2431 udc->gadget.dev.driver = NULL; 2439 udc->gadget.dev.driver = NULL;
2432 2440
2433 retval = 0; 2441 retval = 0;
2434 for (i = 0; i < hw_ep_max; i++) { 2442 for (i = 0; i < hw_ep_max/2; i++) {
2435 struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[i]; 2443 for (j = RX; j <= TX; j++) {
2444 int k = i + j * hw_ep_max/2;
2445 struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[k];
2436 2446
2437 scnprintf(mEp->name, sizeof(mEp->name), "ep%i", (int)i); 2447 scnprintf(mEp->name, sizeof(mEp->name), "ep%i%s", i,
2448 (j == TX) ? "in" : "out");
2438 2449
2439 mEp->lock = udc->lock; 2450 mEp->lock = udc->lock;
2440 mEp->device = &udc->gadget.dev; 2451 mEp->device = &udc->gadget.dev;
2441 mEp->td_pool = udc->td_pool; 2452 mEp->td_pool = udc->td_pool;
2442 2453
2443 mEp->ep.name = mEp->name; 2454 mEp->ep.name = mEp->name;
2444 mEp->ep.ops = &usb_ep_ops; 2455 mEp->ep.ops = &usb_ep_ops;
2445 mEp->ep.maxpacket = CTRL_PAYLOAD_MAX; 2456 mEp->ep.maxpacket = CTRL_PAYLOAD_MAX;
2446 2457
2447 /* this allocation cannot be random */ 2458 INIT_LIST_HEAD(&mEp->qh.queue);
2448 for (k = RX; k <= TX; k++) {
2449 INIT_LIST_HEAD(&mEp->qh[k].queue);
2450 spin_unlock_irqrestore(udc->lock, flags); 2459 spin_unlock_irqrestore(udc->lock, flags);
2451 mEp->qh[k].ptr = dma_pool_alloc(udc->qh_pool, 2460 mEp->qh.ptr = dma_pool_alloc(udc->qh_pool, GFP_KERNEL,
2452 GFP_KERNEL, 2461 &mEp->qh.dma);
2453 &mEp->qh[k].dma);
2454 spin_lock_irqsave(udc->lock, flags); 2462 spin_lock_irqsave(udc->lock, flags);
2455 if (mEp->qh[k].ptr == NULL) 2463 if (mEp->qh.ptr == NULL)
2456 retval = -ENOMEM; 2464 retval = -ENOMEM;
2457 else 2465 else
2458 memset(mEp->qh[k].ptr, 0, 2466 memset(mEp->qh.ptr, 0, sizeof(*mEp->qh.ptr));
2459 sizeof(*mEp->qh[k].ptr)); 2467
2460 } 2468 /* skip ep0 out and in endpoints */
2461 if (i == 0) 2469 if (i == 0)
2462 udc->gadget.ep0 = &mEp->ep; 2470 continue;
2463 else 2471
2464 list_add_tail(&mEp->ep.ep_list, &udc->gadget.ep_list); 2472 list_add_tail(&mEp->ep.ep_list, &udc->gadget.ep_list);
2473 }
2465 } 2474 }
2466 if (retval) 2475 if (retval)
2467 goto done; 2476 goto done;
2468 2477
2478 udc->gadget.ep0 = &udc->ep0in.ep;
2469 /* bind gadget */ 2479 /* bind gadget */
2470 driver->driver.bus = NULL; 2480 driver->driver.bus = NULL;
2471 udc->gadget.dev.driver = &driver->driver; 2481 udc->gadget.dev.driver = &driver->driver;
@@ -2479,6 +2489,7 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
2479 goto done; 2489 goto done;
2480 } 2490 }
2481 2491
2492 udc->driver = driver;
2482 pm_runtime_get_sync(&udc->gadget.dev); 2493 pm_runtime_get_sync(&udc->gadget.dev);
2483 if (udc->udc_driver->flags & CI13XXX_PULLUP_ON_VBUS) { 2494 if (udc->udc_driver->flags & CI13XXX_PULLUP_ON_VBUS) {
2484 if (udc->vbus_active) { 2495 if (udc->vbus_active) {
@@ -2490,14 +2501,12 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
2490 } 2501 }
2491 } 2502 }
2492 2503
2493 retval = hw_device_state(udc->ci13xxx_ep[0].qh[RX].dma); 2504 retval = hw_device_state(udc->ep0out.qh.dma);
2494 if (retval) 2505 if (retval)
2495 pm_runtime_put_sync(&udc->gadget.dev); 2506 pm_runtime_put_sync(&udc->gadget.dev);
2496 2507
2497 done: 2508 done:
2498 spin_unlock_irqrestore(udc->lock, flags); 2509 spin_unlock_irqrestore(udc->lock, flags);
2499 if (retval)
2500 usb_gadget_unregister_driver(driver);
2501 return retval; 2510 return retval;
2502} 2511}
2503EXPORT_SYMBOL(usb_gadget_probe_driver); 2512EXPORT_SYMBOL(usb_gadget_probe_driver);
@@ -2510,7 +2519,7 @@ EXPORT_SYMBOL(usb_gadget_probe_driver);
2510int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) 2519int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
2511{ 2520{
2512 struct ci13xxx *udc = _udc; 2521 struct ci13xxx *udc = _udc;
2513 unsigned long i, k, flags; 2522 unsigned long i, flags;
2514 2523
2515 trace("%p", driver); 2524 trace("%p", driver);
2516 2525
@@ -2546,17 +2555,14 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
2546 for (i = 0; i < hw_ep_max; i++) { 2555 for (i = 0; i < hw_ep_max; i++) {
2547 struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[i]; 2556 struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[i];
2548 2557
2549 if (i == 0) 2558 if (!list_empty(&mEp->ep.ep_list))
2550 udc->gadget.ep0 = NULL;
2551 else if (!list_empty(&mEp->ep.ep_list))
2552 list_del_init(&mEp->ep.ep_list); 2559 list_del_init(&mEp->ep.ep_list);
2553 2560
2554 for (k = RX; k <= TX; k++) 2561 if (mEp->qh.ptr != NULL)
2555 if (mEp->qh[k].ptr != NULL) 2562 dma_pool_free(udc->qh_pool, mEp->qh.ptr, mEp->qh.dma);
2556 dma_pool_free(udc->qh_pool,
2557 mEp->qh[k].ptr, mEp->qh[k].dma);
2558 } 2563 }
2559 2564
2565 udc->gadget.ep0 = NULL;
2560 udc->driver = NULL; 2566 udc->driver = NULL;
2561 2567
2562 spin_unlock_irqrestore(udc->lock, flags); 2568 spin_unlock_irqrestore(udc->lock, flags);
diff --git a/drivers/usb/gadget/ci13xxx_udc.h b/drivers/usb/gadget/ci13xxx_udc.h
index f61fed07f76b..a2492b65f98c 100644
--- a/drivers/usb/gadget/ci13xxx_udc.h
+++ b/drivers/usb/gadget/ci13xxx_udc.h
@@ -20,7 +20,7 @@
20 * DEFINE 20 * DEFINE
21 *****************************************************************************/ 21 *****************************************************************************/
22#define CI13XXX_PAGE_SIZE 4096ul /* page size for TD's */ 22#define CI13XXX_PAGE_SIZE 4096ul /* page size for TD's */
23#define ENDPT_MAX (16) 23#define ENDPT_MAX (32)
24#define CTRL_PAYLOAD_MAX (64) 24#define CTRL_PAYLOAD_MAX (64)
25#define RX (0) /* similar to USB_DIR_OUT but can be used as an index */ 25#define RX (0) /* similar to USB_DIR_OUT but can be used as an index */
26#define TX (1) /* similar to USB_DIR_IN but can be used as an index */ 26#define TX (1) /* similar to USB_DIR_IN but can be used as an index */
@@ -88,8 +88,7 @@ struct ci13xxx_ep {
88 struct list_head queue; 88 struct list_head queue;
89 struct ci13xxx_qh *ptr; 89 struct ci13xxx_qh *ptr;
90 dma_addr_t dma; 90 dma_addr_t dma;
91 } qh[2]; 91 } qh;
92 struct usb_request *status;
93 int wedge; 92 int wedge;
94 93
95 /* global resources */ 94 /* global resources */
@@ -119,9 +118,13 @@ struct ci13xxx {
119 118
120 struct dma_pool *qh_pool; /* DMA pool for queue heads */ 119 struct dma_pool *qh_pool; /* DMA pool for queue heads */
121 struct dma_pool *td_pool; /* DMA pool for transfer descs */ 120 struct dma_pool *td_pool; /* DMA pool for transfer descs */
121 struct usb_request *status; /* ep0 status request */
122 122
123 struct usb_gadget gadget; /* USB slave device */ 123 struct usb_gadget gadget; /* USB slave device */
124 struct ci13xxx_ep ci13xxx_ep[ENDPT_MAX]; /* extended endpts */ 124 struct ci13xxx_ep ci13xxx_ep[ENDPT_MAX]; /* extended endpts */
125 u32 ep0_dir; /* ep0 direction */
126#define ep0out ci13xxx_ep[0]
127#define ep0in ci13xxx_ep[16]
125 128
126 struct usb_gadget_driver *driver; /* 3rd party gadget driver */ 129 struct usb_gadget_driver *driver; /* 3rd party gadget driver */
127 struct ci13xxx_udc_driver *udc_driver; /* device controller driver */ 130 struct ci13xxx_udc_driver *udc_driver; /* device controller driver */
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index f6ff8456d52d..1ba4befe336b 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -928,8 +928,9 @@ unknown:
928 */ 928 */
929 switch (ctrl->bRequestType & USB_RECIP_MASK) { 929 switch (ctrl->bRequestType & USB_RECIP_MASK) {
930 case USB_RECIP_INTERFACE: 930 case USB_RECIP_INTERFACE:
931 if (cdev->config) 931 if (!cdev->config || w_index >= MAX_CONFIG_INTERFACES)
932 f = cdev->config->interface[intf]; 932 break;
933 f = cdev->config->interface[intf];
933 break; 934 break;
934 935
935 case USB_RECIP_ENDPOINT: 936 case USB_RECIP_ENDPOINT:
diff --git a/drivers/usb/gadget/pch_udc.c b/drivers/usb/gadget/pch_udc.c
index 0c8dd81dddca..b120dbb64d0f 100644
--- a/drivers/usb/gadget/pch_udc.c
+++ b/drivers/usb/gadget/pch_udc.c
@@ -198,10 +198,10 @@
198#define PCH_UDC_BRLEN 0x0F /* Burst length */ 198#define PCH_UDC_BRLEN 0x0F /* Burst length */
199#define PCH_UDC_THLEN 0x1F /* Threshold length */ 199#define PCH_UDC_THLEN 0x1F /* Threshold length */
200/* Value of EP Buffer Size */ 200/* Value of EP Buffer Size */
201#define UDC_EP0IN_BUFF_SIZE 64 201#define UDC_EP0IN_BUFF_SIZE 16
202#define UDC_EPIN_BUFF_SIZE 512 202#define UDC_EPIN_BUFF_SIZE 256
203#define UDC_EP0OUT_BUFF_SIZE 64 203#define UDC_EP0OUT_BUFF_SIZE 16
204#define UDC_EPOUT_BUFF_SIZE 512 204#define UDC_EPOUT_BUFF_SIZE 256
205/* Value of EP maximum packet size */ 205/* Value of EP maximum packet size */
206#define UDC_EP0IN_MAX_PKT_SIZE 64 206#define UDC_EP0IN_MAX_PKT_SIZE 64
207#define UDC_EP0OUT_MAX_PKT_SIZE 64 207#define UDC_EP0OUT_MAX_PKT_SIZE 64
@@ -351,7 +351,7 @@ struct pch_udc_dev {
351 struct pci_pool *data_requests; 351 struct pci_pool *data_requests;
352 struct pci_pool *stp_requests; 352 struct pci_pool *stp_requests;
353 dma_addr_t dma_addr; 353 dma_addr_t dma_addr;
354 unsigned long ep0out_buf[64]; 354 void *ep0out_buf;
355 struct usb_ctrlrequest setup_data; 355 struct usb_ctrlrequest setup_data;
356 unsigned long phys_addr; 356 unsigned long phys_addr;
357 void __iomem *base_addr; 357 void __iomem *base_addr;
@@ -361,6 +361,8 @@ struct pch_udc_dev {
361 361
362#define PCH_UDC_PCI_BAR 1 362#define PCH_UDC_PCI_BAR 1
363#define PCI_DEVICE_ID_INTEL_EG20T_UDC 0x8808 363#define PCI_DEVICE_ID_INTEL_EG20T_UDC 0x8808
364#define PCI_VENDOR_ID_ROHM 0x10DB
365#define PCI_DEVICE_ID_ML7213_IOH_UDC 0x801D
364 366
365static const char ep0_string[] = "ep0in"; 367static const char ep0_string[] = "ep0in";
366static DEFINE_SPINLOCK(udc_stall_spinlock); /* stall spin lock */ 368static DEFINE_SPINLOCK(udc_stall_spinlock); /* stall spin lock */
@@ -1219,11 +1221,11 @@ static void complete_req(struct pch_udc_ep *ep, struct pch_udc_request *req,
1219 dev = ep->dev; 1221 dev = ep->dev;
1220 if (req->dma_mapped) { 1222 if (req->dma_mapped) {
1221 if (ep->in) 1223 if (ep->in)
1222 pci_unmap_single(dev->pdev, req->req.dma, 1224 dma_unmap_single(&dev->pdev->dev, req->req.dma,
1223 req->req.length, PCI_DMA_TODEVICE); 1225 req->req.length, DMA_TO_DEVICE);
1224 else 1226 else
1225 pci_unmap_single(dev->pdev, req->req.dma, 1227 dma_unmap_single(&dev->pdev->dev, req->req.dma,
1226 req->req.length, PCI_DMA_FROMDEVICE); 1228 req->req.length, DMA_FROM_DEVICE);
1227 req->dma_mapped = 0; 1229 req->dma_mapped = 0;
1228 req->req.dma = DMA_ADDR_INVALID; 1230 req->req.dma = DMA_ADDR_INVALID;
1229 } 1231 }
@@ -1414,7 +1416,6 @@ static void pch_udc_start_rxrequest(struct pch_udc_ep *ep,
1414 1416
1415 pch_udc_clear_dma(ep->dev, DMA_DIR_RX); 1417 pch_udc_clear_dma(ep->dev, DMA_DIR_RX);
1416 td_data = req->td_data; 1418 td_data = req->td_data;
1417 ep->td_data = req->td_data;
1418 /* Set the status bits for all descriptors */ 1419 /* Set the status bits for all descriptors */
1419 while (1) { 1420 while (1) {
1420 td_data->status = (td_data->status & ~PCH_UDC_BUFF_STS) | 1421 td_data->status = (td_data->status & ~PCH_UDC_BUFF_STS) |
@@ -1613,15 +1614,19 @@ static int pch_udc_pcd_queue(struct usb_ep *usbep, struct usb_request *usbreq,
1613 if (usbreq->length && 1614 if (usbreq->length &&
1614 ((usbreq->dma == DMA_ADDR_INVALID) || !usbreq->dma)) { 1615 ((usbreq->dma == DMA_ADDR_INVALID) || !usbreq->dma)) {
1615 if (ep->in) 1616 if (ep->in)
1616 usbreq->dma = pci_map_single(dev->pdev, usbreq->buf, 1617 usbreq->dma = dma_map_single(&dev->pdev->dev,
1617 usbreq->length, PCI_DMA_TODEVICE); 1618 usbreq->buf,
1619 usbreq->length,
1620 DMA_TO_DEVICE);
1618 else 1621 else
1619 usbreq->dma = pci_map_single(dev->pdev, usbreq->buf, 1622 usbreq->dma = dma_map_single(&dev->pdev->dev,
1620 usbreq->length, PCI_DMA_FROMDEVICE); 1623 usbreq->buf,
1624 usbreq->length,
1625 DMA_FROM_DEVICE);
1621 req->dma_mapped = 1; 1626 req->dma_mapped = 1;
1622 } 1627 }
1623 if (usbreq->length > 0) { 1628 if (usbreq->length > 0) {
1624 retval = prepare_dma(ep, req, gfp); 1629 retval = prepare_dma(ep, req, GFP_ATOMIC);
1625 if (retval) 1630 if (retval)
1626 goto probe_end; 1631 goto probe_end;
1627 } 1632 }
@@ -1646,7 +1651,6 @@ static int pch_udc_pcd_queue(struct usb_ep *usbep, struct usb_request *usbreq,
1646 pch_udc_wait_ep_stall(ep); 1651 pch_udc_wait_ep_stall(ep);
1647 pch_udc_ep_clear_nak(ep); 1652 pch_udc_ep_clear_nak(ep);
1648 pch_udc_enable_ep_interrupts(ep->dev, (1 << ep->num)); 1653 pch_udc_enable_ep_interrupts(ep->dev, (1 << ep->num));
1649 pch_udc_set_dma(dev, DMA_DIR_TX);
1650 } 1654 }
1651 } 1655 }
1652 /* Now add this request to the ep's pending requests */ 1656 /* Now add this request to the ep's pending requests */
@@ -1926,6 +1930,7 @@ static void pch_udc_complete_receiver(struct pch_udc_ep *ep)
1926 PCH_UDC_BS_DMA_DONE) 1930 PCH_UDC_BS_DMA_DONE)
1927 return; 1931 return;
1928 pch_udc_clear_dma(ep->dev, DMA_DIR_RX); 1932 pch_udc_clear_dma(ep->dev, DMA_DIR_RX);
1933 pch_udc_ep_set_ddptr(ep, 0);
1929 if ((req->td_data_last->status & PCH_UDC_RXTX_STS) != 1934 if ((req->td_data_last->status & PCH_UDC_RXTX_STS) !=
1930 PCH_UDC_RTS_SUCC) { 1935 PCH_UDC_RTS_SUCC) {
1931 dev_err(&dev->pdev->dev, "Invalid RXTX status (0x%08x) " 1936 dev_err(&dev->pdev->dev, "Invalid RXTX status (0x%08x) "
@@ -1963,7 +1968,7 @@ static void pch_udc_svc_data_in(struct pch_udc_dev *dev, int ep_num)
1963 u32 epsts; 1968 u32 epsts;
1964 struct pch_udc_ep *ep; 1969 struct pch_udc_ep *ep;
1965 1970
1966 ep = &dev->ep[2*ep_num]; 1971 ep = &dev->ep[UDC_EPIN_IDX(ep_num)];
1967 epsts = ep->epsts; 1972 epsts = ep->epsts;
1968 ep->epsts = 0; 1973 ep->epsts = 0;
1969 1974
@@ -2008,7 +2013,7 @@ static void pch_udc_svc_data_out(struct pch_udc_dev *dev, int ep_num)
2008 struct pch_udc_ep *ep; 2013 struct pch_udc_ep *ep;
2009 struct pch_udc_request *req = NULL; 2014 struct pch_udc_request *req = NULL;
2010 2015
2011 ep = &dev->ep[2*ep_num + 1]; 2016 ep = &dev->ep[UDC_EPOUT_IDX(ep_num)];
2012 epsts = ep->epsts; 2017 epsts = ep->epsts;
2013 ep->epsts = 0; 2018 ep->epsts = 0;
2014 2019
@@ -2025,10 +2030,11 @@ static void pch_udc_svc_data_out(struct pch_udc_dev *dev, int ep_num)
2025 } 2030 }
2026 if (epsts & UDC_EPSTS_HE) 2031 if (epsts & UDC_EPSTS_HE)
2027 return; 2032 return;
2028 if (epsts & UDC_EPSTS_RSS) 2033 if (epsts & UDC_EPSTS_RSS) {
2029 pch_udc_ep_set_stall(ep); 2034 pch_udc_ep_set_stall(ep);
2030 pch_udc_enable_ep_interrupts(ep->dev, 2035 pch_udc_enable_ep_interrupts(ep->dev,
2031 PCH_UDC_EPINT(ep->in, ep->num)); 2036 PCH_UDC_EPINT(ep->in, ep->num));
2037 }
2032 if (epsts & UDC_EPSTS_RCS) { 2038 if (epsts & UDC_EPSTS_RCS) {
2033 if (!dev->prot_stall) { 2039 if (!dev->prot_stall) {
2034 pch_udc_ep_clear_stall(ep); 2040 pch_udc_ep_clear_stall(ep);
@@ -2060,8 +2066,10 @@ static void pch_udc_svc_control_in(struct pch_udc_dev *dev)
2060{ 2066{
2061 u32 epsts; 2067 u32 epsts;
2062 struct pch_udc_ep *ep; 2068 struct pch_udc_ep *ep;
2069 struct pch_udc_ep *ep_out;
2063 2070
2064 ep = &dev->ep[UDC_EP0IN_IDX]; 2071 ep = &dev->ep[UDC_EP0IN_IDX];
2072 ep_out = &dev->ep[UDC_EP0OUT_IDX];
2065 epsts = ep->epsts; 2073 epsts = ep->epsts;
2066 ep->epsts = 0; 2074 ep->epsts = 0;
2067 2075
@@ -2073,8 +2081,16 @@ static void pch_udc_svc_control_in(struct pch_udc_dev *dev)
2073 return; 2081 return;
2074 if (epsts & UDC_EPSTS_HE) 2082 if (epsts & UDC_EPSTS_HE)
2075 return; 2083 return;
2076 if ((epsts & UDC_EPSTS_TDC) && (!dev->stall)) 2084 if ((epsts & UDC_EPSTS_TDC) && (!dev->stall)) {
2077 pch_udc_complete_transfer(ep); 2085 pch_udc_complete_transfer(ep);
2086 pch_udc_clear_dma(dev, DMA_DIR_RX);
2087 ep_out->td_data->status = (ep_out->td_data->status &
2088 ~PCH_UDC_BUFF_STS) |
2089 PCH_UDC_BS_HST_RDY;
2090 pch_udc_ep_clear_nak(ep_out);
2091 pch_udc_set_dma(dev, DMA_DIR_RX);
2092 pch_udc_ep_set_rrdy(ep_out);
2093 }
2078 /* On IN interrupt, provide data if we have any */ 2094 /* On IN interrupt, provide data if we have any */
2079 if ((epsts & UDC_EPSTS_IN) && !(epsts & UDC_EPSTS_TDC) && 2095 if ((epsts & UDC_EPSTS_IN) && !(epsts & UDC_EPSTS_TDC) &&
2080 !(epsts & UDC_EPSTS_TXEMPTY)) 2096 !(epsts & UDC_EPSTS_TXEMPTY))
@@ -2102,11 +2118,9 @@ static void pch_udc_svc_control_out(struct pch_udc_dev *dev)
2102 dev->stall = 0; 2118 dev->stall = 0;
2103 dev->ep[UDC_EP0IN_IDX].halted = 0; 2119 dev->ep[UDC_EP0IN_IDX].halted = 0;
2104 dev->ep[UDC_EP0OUT_IDX].halted = 0; 2120 dev->ep[UDC_EP0OUT_IDX].halted = 0;
2105 /* In data not ready */
2106 pch_udc_ep_set_nak(&(dev->ep[UDC_EP0IN_IDX]));
2107 dev->setup_data = ep->td_stp->request; 2121 dev->setup_data = ep->td_stp->request;
2108 pch_udc_init_setup_buff(ep->td_stp); 2122 pch_udc_init_setup_buff(ep->td_stp);
2109 pch_udc_clear_dma(dev, DMA_DIR_TX); 2123 pch_udc_clear_dma(dev, DMA_DIR_RX);
2110 pch_udc_ep_fifo_flush(&(dev->ep[UDC_EP0IN_IDX]), 2124 pch_udc_ep_fifo_flush(&(dev->ep[UDC_EP0IN_IDX]),
2111 dev->ep[UDC_EP0IN_IDX].in); 2125 dev->ep[UDC_EP0IN_IDX].in);
2112 if ((dev->setup_data.bRequestType & USB_DIR_IN)) 2126 if ((dev->setup_data.bRequestType & USB_DIR_IN))
@@ -2122,14 +2136,23 @@ static void pch_udc_svc_control_out(struct pch_udc_dev *dev)
2122 setup_supported = dev->driver->setup(&dev->gadget, 2136 setup_supported = dev->driver->setup(&dev->gadget,
2123 &dev->setup_data); 2137 &dev->setup_data);
2124 spin_lock(&dev->lock); 2138 spin_lock(&dev->lock);
2139
2140 if (dev->setup_data.bRequestType & USB_DIR_IN) {
2141 ep->td_data->status = (ep->td_data->status &
2142 ~PCH_UDC_BUFF_STS) |
2143 PCH_UDC_BS_HST_RDY;
2144 pch_udc_ep_set_ddptr(ep, ep->td_data_phys);
2145 }
2125 /* ep0 in returns data on IN phase */ 2146 /* ep0 in returns data on IN phase */
2126 if (setup_supported >= 0 && setup_supported < 2147 if (setup_supported >= 0 && setup_supported <
2127 UDC_EP0IN_MAX_PKT_SIZE) { 2148 UDC_EP0IN_MAX_PKT_SIZE) {
2128 pch_udc_ep_clear_nak(&(dev->ep[UDC_EP0IN_IDX])); 2149 pch_udc_ep_clear_nak(&(dev->ep[UDC_EP0IN_IDX]));
2129 /* Gadget would have queued a request when 2150 /* Gadget would have queued a request when
2130 * we called the setup */ 2151 * we called the setup */
2131 pch_udc_set_dma(dev, DMA_DIR_RX); 2152 if (!(dev->setup_data.bRequestType & USB_DIR_IN)) {
2132 pch_udc_ep_clear_nak(ep); 2153 pch_udc_set_dma(dev, DMA_DIR_RX);
2154 pch_udc_ep_clear_nak(ep);
2155 }
2133 } else if (setup_supported < 0) { 2156 } else if (setup_supported < 0) {
2134 /* if unsupported request, then stall */ 2157 /* if unsupported request, then stall */
2135 pch_udc_ep_set_stall(&(dev->ep[UDC_EP0IN_IDX])); 2158 pch_udc_ep_set_stall(&(dev->ep[UDC_EP0IN_IDX]));
@@ -2142,22 +2165,13 @@ static void pch_udc_svc_control_out(struct pch_udc_dev *dev)
2142 } 2165 }
2143 } else if ((((stat & UDC_EPSTS_OUT_MASK) >> UDC_EPSTS_OUT_SHIFT) == 2166 } else if ((((stat & UDC_EPSTS_OUT_MASK) >> UDC_EPSTS_OUT_SHIFT) ==
2144 UDC_EPSTS_OUT_DATA) && !dev->stall) { 2167 UDC_EPSTS_OUT_DATA) && !dev->stall) {
2145 if (list_empty(&ep->queue)) { 2168 pch_udc_clear_dma(dev, DMA_DIR_RX);
2146 dev_err(&dev->pdev->dev, "%s: No request\n", __func__); 2169 pch_udc_ep_set_ddptr(ep, 0);
2147 ep->td_data->status = (ep->td_data->status & 2170 if (!list_empty(&ep->queue)) {
2148 ~PCH_UDC_BUFF_STS) |
2149 PCH_UDC_BS_HST_RDY;
2150 pch_udc_set_dma(dev, DMA_DIR_RX);
2151 } else {
2152 /* control write */
2153 /* next function will pickuo an clear the status */
2154 ep->epsts = stat; 2171 ep->epsts = stat;
2155 2172 pch_udc_svc_data_out(dev, PCH_UDC_EP0);
2156 pch_udc_svc_data_out(dev, 0);
2157 /* re-program desc. pointer for possible ZLPs */
2158 pch_udc_ep_set_ddptr(ep, ep->td_data_phys);
2159 pch_udc_set_dma(dev, DMA_DIR_RX);
2160 } 2173 }
2174 pch_udc_set_dma(dev, DMA_DIR_RX);
2161 } 2175 }
2162 pch_udc_ep_set_rrdy(ep); 2176 pch_udc_ep_set_rrdy(ep);
2163} 2177}
@@ -2174,7 +2188,7 @@ static void pch_udc_postsvc_epinters(struct pch_udc_dev *dev, int ep_num)
2174 struct pch_udc_ep *ep; 2188 struct pch_udc_ep *ep;
2175 struct pch_udc_request *req; 2189 struct pch_udc_request *req;
2176 2190
2177 ep = &dev->ep[2*ep_num]; 2191 ep = &dev->ep[UDC_EPIN_IDX(ep_num)];
2178 if (!list_empty(&ep->queue)) { 2192 if (!list_empty(&ep->queue)) {
2179 req = list_entry(ep->queue.next, struct pch_udc_request, queue); 2193 req = list_entry(ep->queue.next, struct pch_udc_request, queue);
2180 pch_udc_enable_ep_interrupts(ep->dev, 2194 pch_udc_enable_ep_interrupts(ep->dev,
@@ -2196,13 +2210,13 @@ static void pch_udc_read_all_epstatus(struct pch_udc_dev *dev, u32 ep_intr)
2196 for (i = 0; i < PCH_UDC_USED_EP_NUM; i++) { 2210 for (i = 0; i < PCH_UDC_USED_EP_NUM; i++) {
2197 /* IN */ 2211 /* IN */
2198 if (ep_intr & (0x1 << i)) { 2212 if (ep_intr & (0x1 << i)) {
2199 ep = &dev->ep[2*i]; 2213 ep = &dev->ep[UDC_EPIN_IDX(i)];
2200 ep->epsts = pch_udc_read_ep_status(ep); 2214 ep->epsts = pch_udc_read_ep_status(ep);
2201 pch_udc_clear_ep_status(ep, ep->epsts); 2215 pch_udc_clear_ep_status(ep, ep->epsts);
2202 } 2216 }
2203 /* OUT */ 2217 /* OUT */
2204 if (ep_intr & (0x10000 << i)) { 2218 if (ep_intr & (0x10000 << i)) {
2205 ep = &dev->ep[2*i+1]; 2219 ep = &dev->ep[UDC_EPOUT_IDX(i)];
2206 ep->epsts = pch_udc_read_ep_status(ep); 2220 ep->epsts = pch_udc_read_ep_status(ep);
2207 pch_udc_clear_ep_status(ep, ep->epsts); 2221 pch_udc_clear_ep_status(ep, ep->epsts);
2208 } 2222 }
@@ -2563,9 +2577,6 @@ static void pch_udc_pcd_reinit(struct pch_udc_dev *dev)
2563 dev->ep[UDC_EP0IN_IDX].ep.maxpacket = UDC_EP0IN_MAX_PKT_SIZE; 2577 dev->ep[UDC_EP0IN_IDX].ep.maxpacket = UDC_EP0IN_MAX_PKT_SIZE;
2564 dev->ep[UDC_EP0OUT_IDX].ep.maxpacket = UDC_EP0OUT_MAX_PKT_SIZE; 2578 dev->ep[UDC_EP0OUT_IDX].ep.maxpacket = UDC_EP0OUT_MAX_PKT_SIZE;
2565 2579
2566 dev->dma_addr = pci_map_single(dev->pdev, dev->ep0out_buf, 256,
2567 PCI_DMA_FROMDEVICE);
2568
2569 /* remove ep0 in and out from the list. They have own pointer */ 2580 /* remove ep0 in and out from the list. They have own pointer */
2570 list_del_init(&dev->ep[UDC_EP0IN_IDX].ep.ep_list); 2581 list_del_init(&dev->ep[UDC_EP0IN_IDX].ep.ep_list);
2571 list_del_init(&dev->ep[UDC_EP0OUT_IDX].ep.ep_list); 2582 list_del_init(&dev->ep[UDC_EP0OUT_IDX].ep.ep_list);
@@ -2637,6 +2648,13 @@ static int init_dma_pools(struct pch_udc_dev *dev)
2637 dev->ep[UDC_EP0IN_IDX].td_stp_phys = 0; 2648 dev->ep[UDC_EP0IN_IDX].td_stp_phys = 0;
2638 dev->ep[UDC_EP0IN_IDX].td_data = NULL; 2649 dev->ep[UDC_EP0IN_IDX].td_data = NULL;
2639 dev->ep[UDC_EP0IN_IDX].td_data_phys = 0; 2650 dev->ep[UDC_EP0IN_IDX].td_data_phys = 0;
2651
2652 dev->ep0out_buf = kzalloc(UDC_EP0OUT_BUFF_SIZE * 4, GFP_KERNEL);
2653 if (!dev->ep0out_buf)
2654 return -ENOMEM;
2655 dev->dma_addr = dma_map_single(&dev->pdev->dev, dev->ep0out_buf,
2656 UDC_EP0OUT_BUFF_SIZE * 4,
2657 DMA_FROM_DEVICE);
2640 return 0; 2658 return 0;
2641} 2659}
2642 2660
@@ -2700,7 +2718,8 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
2700 2718
2701 pch_udc_disable_interrupts(dev, UDC_DEVINT_MSK); 2719 pch_udc_disable_interrupts(dev, UDC_DEVINT_MSK);
2702 2720
2703 /* Assues that there are no pending requets with this driver */ 2721 /* Assures that there are no pending requests with this driver */
2722 driver->disconnect(&dev->gadget);
2704 driver->unbind(&dev->gadget); 2723 driver->unbind(&dev->gadget);
2705 dev->gadget.dev.driver = NULL; 2724 dev->gadget.dev.driver = NULL;
2706 dev->driver = NULL; 2725 dev->driver = NULL;
@@ -2750,6 +2769,11 @@ static void pch_udc_remove(struct pci_dev *pdev)
2750 pci_pool_destroy(dev->stp_requests); 2769 pci_pool_destroy(dev->stp_requests);
2751 } 2770 }
2752 2771
2772 if (dev->dma_addr)
2773 dma_unmap_single(&dev->pdev->dev, dev->dma_addr,
2774 UDC_EP0OUT_BUFF_SIZE * 4, DMA_FROM_DEVICE);
2775 kfree(dev->ep0out_buf);
2776
2753 pch_udc_exit(dev); 2777 pch_udc_exit(dev);
2754 2778
2755 if (dev->irq_registered) 2779 if (dev->irq_registered)
@@ -2792,11 +2816,7 @@ static int pch_udc_resume(struct pci_dev *pdev)
2792 int ret; 2816 int ret;
2793 2817
2794 pci_set_power_state(pdev, PCI_D0); 2818 pci_set_power_state(pdev, PCI_D0);
2795 ret = pci_restore_state(pdev); 2819 pci_restore_state(pdev);
2796 if (ret) {
2797 dev_err(&pdev->dev, "%s: pci_restore_state failed\n", __func__);
2798 return ret;
2799 }
2800 ret = pci_enable_device(pdev); 2820 ret = pci_enable_device(pdev);
2801 if (ret) { 2821 if (ret) {
2802 dev_err(&pdev->dev, "%s: pci_enable_device failed\n", __func__); 2822 dev_err(&pdev->dev, "%s: pci_enable_device failed\n", __func__);
@@ -2914,6 +2934,11 @@ static DEFINE_PCI_DEVICE_TABLE(pch_udc_pcidev_id) = {
2914 .class = (PCI_CLASS_SERIAL_USB << 8) | 0xfe, 2934 .class = (PCI_CLASS_SERIAL_USB << 8) | 0xfe,
2915 .class_mask = 0xffffffff, 2935 .class_mask = 0xffffffff,
2916 }, 2936 },
2937 {
2938 PCI_DEVICE(PCI_VENDOR_ID_ROHM, PCI_DEVICE_ID_ML7213_IOH_UDC),
2939 .class = (PCI_CLASS_SERIAL_USB << 8) | 0xfe,
2940 .class_mask = 0xffffffff,
2941 },
2917 { 0 }, 2942 { 0 },
2918}; 2943};
2919 2944
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c
index 2fc8636316c5..12ff6cffedc9 100644
--- a/drivers/usb/gadget/printer.c
+++ b/drivers/usb/gadget/printer.c
@@ -131,31 +131,31 @@ static struct printer_dev usb_printer_gadget;
131 * parameters are in UTF-8 (superset of ASCII's 7 bit characters). 131 * parameters are in UTF-8 (superset of ASCII's 7 bit characters).
132 */ 132 */
133 133
134static ushort __initdata idVendor; 134static ushort idVendor;
135module_param(idVendor, ushort, S_IRUGO); 135module_param(idVendor, ushort, S_IRUGO);
136MODULE_PARM_DESC(idVendor, "USB Vendor ID"); 136MODULE_PARM_DESC(idVendor, "USB Vendor ID");
137 137
138static ushort __initdata idProduct; 138static ushort idProduct;
139module_param(idProduct, ushort, S_IRUGO); 139module_param(idProduct, ushort, S_IRUGO);
140MODULE_PARM_DESC(idProduct, "USB Product ID"); 140MODULE_PARM_DESC(idProduct, "USB Product ID");
141 141
142static ushort __initdata bcdDevice; 142static ushort bcdDevice;
143module_param(bcdDevice, ushort, S_IRUGO); 143module_param(bcdDevice, ushort, S_IRUGO);
144MODULE_PARM_DESC(bcdDevice, "USB Device version (BCD)"); 144MODULE_PARM_DESC(bcdDevice, "USB Device version (BCD)");
145 145
146static char *__initdata iManufacturer; 146static char *iManufacturer;
147module_param(iManufacturer, charp, S_IRUGO); 147module_param(iManufacturer, charp, S_IRUGO);
148MODULE_PARM_DESC(iManufacturer, "USB Manufacturer string"); 148MODULE_PARM_DESC(iManufacturer, "USB Manufacturer string");
149 149
150static char *__initdata iProduct; 150static char *iProduct;
151module_param(iProduct, charp, S_IRUGO); 151module_param(iProduct, charp, S_IRUGO);
152MODULE_PARM_DESC(iProduct, "USB Product string"); 152MODULE_PARM_DESC(iProduct, "USB Product string");
153 153
154static char *__initdata iSerialNum; 154static char *iSerialNum;
155module_param(iSerialNum, charp, S_IRUGO); 155module_param(iSerialNum, charp, S_IRUGO);
156MODULE_PARM_DESC(iSerialNum, "1"); 156MODULE_PARM_DESC(iSerialNum, "1");
157 157
158static char *__initdata iPNPstring; 158static char *iPNPstring;
159module_param(iPNPstring, charp, S_IRUGO); 159module_param(iPNPstring, charp, S_IRUGO);
160MODULE_PARM_DESC(iPNPstring, "MFG:linux;MDL:g_printer;CLS:PRINTER;SN:1;"); 160MODULE_PARM_DESC(iPNPstring, "MFG:linux;MDL:g_printer;CLS:PRINTER;SN:1;");
161 161
@@ -1596,13 +1596,12 @@ cleanup(void)
1596 int status; 1596 int status;
1597 1597
1598 mutex_lock(&usb_printer_gadget.lock_printer_io); 1598 mutex_lock(&usb_printer_gadget.lock_printer_io);
1599 class_destroy(usb_gadget_class);
1600 unregister_chrdev_region(g_printer_devno, 2);
1601
1602 status = usb_gadget_unregister_driver(&printer_driver); 1599 status = usb_gadget_unregister_driver(&printer_driver);
1603 if (status) 1600 if (status)
1604 ERROR(dev, "usb_gadget_unregister_driver %x\n", status); 1601 ERROR(dev, "usb_gadget_unregister_driver %x\n", status);
1605 1602
1603 unregister_chrdev_region(g_printer_devno, 2);
1604 class_destroy(usb_gadget_class);
1606 mutex_unlock(&usb_printer_gadget.lock_printer_io); 1605 mutex_unlock(&usb_printer_gadget.lock_printer_io);
1607} 1606}
1608module_exit(cleanup); 1607module_exit(cleanup);
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 86e42892016d..5c761df7fa83 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -52,7 +52,6 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver,
52 struct resource *res; 52 struct resource *res;
53 int irq; 53 int irq;
54 int retval; 54 int retval;
55 unsigned int temp;
56 55
57 pr_debug("initializing FSL-SOC USB Controller\n"); 56 pr_debug("initializing FSL-SOC USB Controller\n");
58 57
@@ -126,18 +125,6 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver,
126 goto err3; 125 goto err3;
127 } 126 }
128 127
129 /*
130 * Check if it is MPC5121 SoC, otherwise set pdata->have_sysif_regs
131 * flag for 83xx or 8536 system interface registers.
132 */
133 if (pdata->big_endian_mmio)
134 temp = in_be32(hcd->regs + FSL_SOC_USB_ID);
135 else
136 temp = in_le32(hcd->regs + FSL_SOC_USB_ID);
137
138 if ((temp & ID_MSK) != (~((temp & NID_MSK) >> 8) & ID_MSK))
139 pdata->have_sysif_regs = 1;
140
141 /* Enable USB controller, 83xx or 8536 */ 128 /* Enable USB controller, 83xx or 8536 */
142 if (pdata->have_sysif_regs) 129 if (pdata->have_sysif_regs)
143 setbits32(hcd->regs + FSL_SOC_USB_CTRL, 0x4); 130 setbits32(hcd->regs + FSL_SOC_USB_CTRL, 0x4);
diff --git a/drivers/usb/host/ehci-fsl.h b/drivers/usb/host/ehci-fsl.h
index 2c8353795226..3fabed33d940 100644
--- a/drivers/usb/host/ehci-fsl.h
+++ b/drivers/usb/host/ehci-fsl.h
@@ -19,9 +19,6 @@
19#define _EHCI_FSL_H 19#define _EHCI_FSL_H
20 20
21/* offsets for the non-ehci registers in the FSL SOC USB controller */ 21/* offsets for the non-ehci registers in the FSL SOC USB controller */
22#define FSL_SOC_USB_ID 0x0
23#define ID_MSK 0x3f
24#define NID_MSK 0x3f00
25#define FSL_SOC_USB_ULPIVP 0x170 22#define FSL_SOC_USB_ULPIVP 0x170
26#define FSL_SOC_USB_PORTSC1 0x184 23#define FSL_SOC_USB_PORTSC1 0x184
27#define PORT_PTS_MSK (3<<30) 24#define PORT_PTS_MSK (3<<30)
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 6fee3cd58efe..74dcf49bd015 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -572,6 +572,8 @@ static int ehci_init(struct usb_hcd *hcd)
572 ehci->iaa_watchdog.function = ehci_iaa_watchdog; 572 ehci->iaa_watchdog.function = ehci_iaa_watchdog;
573 ehci->iaa_watchdog.data = (unsigned long) ehci; 573 ehci->iaa_watchdog.data = (unsigned long) ehci;
574 574
575 hcc_params = ehci_readl(ehci, &ehci->caps->hcc_params);
576
575 /* 577 /*
576 * hw default: 1K periodic list heads, one per frame. 578 * hw default: 1K periodic list heads, one per frame.
577 * periodic_size can shrink by USBCMD update if hcc_params allows. 579 * periodic_size can shrink by USBCMD update if hcc_params allows.
@@ -579,11 +581,20 @@ static int ehci_init(struct usb_hcd *hcd)
579 ehci->periodic_size = DEFAULT_I_TDPS; 581 ehci->periodic_size = DEFAULT_I_TDPS;
580 INIT_LIST_HEAD(&ehci->cached_itd_list); 582 INIT_LIST_HEAD(&ehci->cached_itd_list);
581 INIT_LIST_HEAD(&ehci->cached_sitd_list); 583 INIT_LIST_HEAD(&ehci->cached_sitd_list);
584
585 if (HCC_PGM_FRAMELISTLEN(hcc_params)) {
586 /* periodic schedule size can be smaller than default */
587 switch (EHCI_TUNE_FLS) {
588 case 0: ehci->periodic_size = 1024; break;
589 case 1: ehci->periodic_size = 512; break;
590 case 2: ehci->periodic_size = 256; break;
591 default: BUG();
592 }
593 }
582 if ((retval = ehci_mem_init(ehci, GFP_KERNEL)) < 0) 594 if ((retval = ehci_mem_init(ehci, GFP_KERNEL)) < 0)
583 return retval; 595 return retval;
584 596
585 /* controllers may cache some of the periodic schedule ... */ 597 /* controllers may cache some of the periodic schedule ... */
586 hcc_params = ehci_readl(ehci, &ehci->caps->hcc_params);
587 if (HCC_ISOC_CACHE(hcc_params)) // full frame cache 598 if (HCC_ISOC_CACHE(hcc_params)) // full frame cache
588 ehci->i_thresh = 2 + 8; 599 ehci->i_thresh = 2 + 8;
589 else // N microframes cached 600 else // N microframes cached
@@ -637,12 +648,6 @@ static int ehci_init(struct usb_hcd *hcd)
637 /* periodic schedule size can be smaller than default */ 648 /* periodic schedule size can be smaller than default */
638 temp &= ~(3 << 2); 649 temp &= ~(3 << 2);
639 temp |= (EHCI_TUNE_FLS << 2); 650 temp |= (EHCI_TUNE_FLS << 2);
640 switch (EHCI_TUNE_FLS) {
641 case 0: ehci->periodic_size = 1024; break;
642 case 1: ehci->periodic_size = 512; break;
643 case 2: ehci->periodic_size = 256; break;
644 default: BUG();
645 }
646 } 651 }
647 if (HCC_LPM(hcc_params)) { 652 if (HCC_LPM(hcc_params)) {
648 /* support link power management EHCI 1.1 addendum */ 653 /* support link power management EHCI 1.1 addendum */
diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
index fa59b26fc5bc..c8e360d7d975 100644
--- a/drivers/usb/host/ehci-mxc.c
+++ b/drivers/usb/host/ehci-mxc.c
@@ -21,10 +21,13 @@
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/usb/ulpi.h>
24#include <linux/slab.h> 25#include <linux/slab.h>
25 26
26#include <mach/mxc_ehci.h> 27#include <mach/mxc_ehci.h>
27 28
29#include <asm/mach-types.h>
30
28#define ULPI_VIEWPORT_OFFSET 0x170 31#define ULPI_VIEWPORT_OFFSET 0x170
29 32
30struct ehci_mxc_priv { 33struct ehci_mxc_priv {
@@ -114,6 +117,7 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
114 struct usb_hcd *hcd; 117 struct usb_hcd *hcd;
115 struct resource *res; 118 struct resource *res;
116 int irq, ret; 119 int irq, ret;
120 unsigned int flags;
117 struct ehci_mxc_priv *priv; 121 struct ehci_mxc_priv *priv;
118 struct device *dev = &pdev->dev; 122 struct device *dev = &pdev->dev;
119 struct ehci_hcd *ehci; 123 struct ehci_hcd *ehci;
@@ -177,8 +181,8 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
177 clk_enable(priv->ahbclk); 181 clk_enable(priv->ahbclk);
178 } 182 }
179 183
180 /* "dr" device has its own clock */ 184 /* "dr" device has its own clock on i.MX51 */
181 if (pdev->id == 0) { 185 if (cpu_is_mx51() && (pdev->id == 0)) {
182 priv->phy1clk = clk_get(dev, "usb_phy1"); 186 priv->phy1clk = clk_get(dev, "usb_phy1");
183 if (IS_ERR(priv->phy1clk)) { 187 if (IS_ERR(priv->phy1clk)) {
184 ret = PTR_ERR(priv->phy1clk); 188 ret = PTR_ERR(priv->phy1clk);
@@ -240,6 +244,23 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
240 if (ret) 244 if (ret)
241 goto err_add; 245 goto err_add;
242 246
247 if (pdata->otg) {
248 /*
249 * efikamx and efikasb have some hardware bug which is
250 * preventing usb to work unless CHRGVBUS is set.
251 * It's in violation of USB specs
252 */
253 if (machine_is_mx51_efikamx() || machine_is_mx51_efikasb()) {
254 flags = otg_io_read(pdata->otg, ULPI_OTG_CTRL);
255 flags |= ULPI_OTG_CTRL_CHRGVBUS;
256 ret = otg_io_write(pdata->otg, flags, ULPI_OTG_CTRL);
257 if (ret) {
258 dev_err(dev, "unable to set CHRVBUS\n");
259 goto err_add;
260 }
261 }
262 }
263
243 return 0; 264 return 0;
244 265
245err_add: 266err_add:
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 76179c39c0e3..bed07d4aab06 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -44,28 +44,35 @@ static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev)
44 return 0; 44 return 0;
45} 45}
46 46
47static int ehci_quirk_amd_SB800(struct ehci_hcd *ehci) 47static int ehci_quirk_amd_hudson(struct ehci_hcd *ehci)
48{ 48{
49 struct pci_dev *amd_smbus_dev; 49 struct pci_dev *amd_smbus_dev;
50 u8 rev = 0; 50 u8 rev = 0;
51 51
52 amd_smbus_dev = pci_get_device(PCI_VENDOR_ID_ATI, 0x4385, NULL); 52 amd_smbus_dev = pci_get_device(PCI_VENDOR_ID_ATI, 0x4385, NULL);
53 if (!amd_smbus_dev) 53 if (amd_smbus_dev) {
54 return 0; 54 pci_read_config_byte(amd_smbus_dev, PCI_REVISION_ID, &rev);
55 55 if (rev < 0x40) {
56 pci_read_config_byte(amd_smbus_dev, PCI_REVISION_ID, &rev); 56 pci_dev_put(amd_smbus_dev);
57 if (rev < 0x40) { 57 amd_smbus_dev = NULL;
58 pci_dev_put(amd_smbus_dev); 58 return 0;
59 amd_smbus_dev = NULL; 59 }
60 return 0; 60 } else {
61 amd_smbus_dev = pci_get_device(PCI_VENDOR_ID_AMD, 0x780b, NULL);
62 if (!amd_smbus_dev)
63 return 0;
64 pci_read_config_byte(amd_smbus_dev, PCI_REVISION_ID, &rev);
65 if (rev < 0x11 || rev > 0x18) {
66 pci_dev_put(amd_smbus_dev);
67 amd_smbus_dev = NULL;
68 return 0;
69 }
61 } 70 }
62 71
63 if (!amd_nb_dev) 72 if (!amd_nb_dev)
64 amd_nb_dev = pci_get_device(PCI_VENDOR_ID_AMD, 0x1510, NULL); 73 amd_nb_dev = pci_get_device(PCI_VENDOR_ID_AMD, 0x1510, NULL);
65 if (!amd_nb_dev)
66 ehci_err(ehci, "QUIRK: unable to get AMD NB device\n");
67 74
68 ehci_info(ehci, "QUIRK: Enable AMD SB800 L1 fix\n"); 75 ehci_info(ehci, "QUIRK: Enable exception for AMD Hudson ASPM\n");
69 76
70 pci_dev_put(amd_smbus_dev); 77 pci_dev_put(amd_smbus_dev);
71 amd_smbus_dev = NULL; 78 amd_smbus_dev = NULL;
@@ -131,7 +138,7 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
131 /* cache this readonly data; minimize chip reads */ 138 /* cache this readonly data; minimize chip reads */
132 ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); 139 ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
133 140
134 if (ehci_quirk_amd_SB800(ehci)) 141 if (ehci_quirk_amd_hudson(ehci))
135 ehci->amd_l1_fix = 1; 142 ehci->amd_l1_fix = 1;
136 143
137 retval = ehci_halt(ehci); 144 retval = ehci_halt(ehci);
diff --git a/drivers/usb/host/fsl-mph-dr-of.c b/drivers/usb/host/fsl-mph-dr-of.c
index 574b99ea0700..79a66d622f9c 100644
--- a/drivers/usb/host/fsl-mph-dr-of.c
+++ b/drivers/usb/host/fsl-mph-dr-of.c
@@ -262,19 +262,24 @@ static void fsl_usb2_mpc5121_exit(struct platform_device *pdev)
262 } 262 }
263} 263}
264 264
265struct fsl_usb2_platform_data fsl_usb2_mpc5121_pd = { 265static struct fsl_usb2_platform_data fsl_usb2_mpc5121_pd = {
266 .big_endian_desc = 1, 266 .big_endian_desc = 1,
267 .big_endian_mmio = 1, 267 .big_endian_mmio = 1,
268 .es = 1, 268 .es = 1,
269 .have_sysif_regs = 0,
269 .le_setup_buf = 1, 270 .le_setup_buf = 1,
270 .init = fsl_usb2_mpc5121_init, 271 .init = fsl_usb2_mpc5121_init,
271 .exit = fsl_usb2_mpc5121_exit, 272 .exit = fsl_usb2_mpc5121_exit,
272}; 273};
273#endif /* CONFIG_PPC_MPC512x */ 274#endif /* CONFIG_PPC_MPC512x */
274 275
276static struct fsl_usb2_platform_data fsl_usb2_mpc8xxx_pd = {
277 .have_sysif_regs = 1,
278};
279
275static const struct of_device_id fsl_usb2_mph_dr_of_match[] = { 280static const struct of_device_id fsl_usb2_mph_dr_of_match[] = {
276 { .compatible = "fsl-usb2-mph", }, 281 { .compatible = "fsl-usb2-mph", .data = &fsl_usb2_mpc8xxx_pd, },
277 { .compatible = "fsl-usb2-dr", }, 282 { .compatible = "fsl-usb2-dr", .data = &fsl_usb2_mpc8xxx_pd, },
278#ifdef CONFIG_PPC_MPC512x 283#ifdef CONFIG_PPC_MPC512x
279 { .compatible = "fsl,mpc5121-usb2-dr", .data = &fsl_usb2_mpc5121_pd, }, 284 { .compatible = "fsl,mpc5121-usb2-dr", .data = &fsl_usb2_mpc5121_pd, },
280#endif 285#endif
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index df558f6f84e3..3e8211c1ce5a 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -308,11 +308,8 @@ static int room_on_ring(struct xhci_hcd *xhci, struct xhci_ring *ring,
308/* Ring the host controller doorbell after placing a command on the ring */ 308/* Ring the host controller doorbell after placing a command on the ring */
309void xhci_ring_cmd_db(struct xhci_hcd *xhci) 309void xhci_ring_cmd_db(struct xhci_hcd *xhci)
310{ 310{
311 u32 temp;
312
313 xhci_dbg(xhci, "// Ding dong!\n"); 311 xhci_dbg(xhci, "// Ding dong!\n");
314 temp = xhci_readl(xhci, &xhci->dba->doorbell[0]) & DB_MASK; 312 xhci_writel(xhci, DB_VALUE_HOST, &xhci->dba->doorbell[0]);
315 xhci_writel(xhci, temp | DB_TARGET_HOST, &xhci->dba->doorbell[0]);
316 /* Flush PCI posted writes */ 313 /* Flush PCI posted writes */
317 xhci_readl(xhci, &xhci->dba->doorbell[0]); 314 xhci_readl(xhci, &xhci->dba->doorbell[0]);
318} 315}
@@ -322,26 +319,24 @@ void xhci_ring_ep_doorbell(struct xhci_hcd *xhci,
322 unsigned int ep_index, 319 unsigned int ep_index,
323 unsigned int stream_id) 320 unsigned int stream_id)
324{ 321{
325 struct xhci_virt_ep *ep;
326 unsigned int ep_state;
327 u32 field;
328 __u32 __iomem *db_addr = &xhci->dba->doorbell[slot_id]; 322 __u32 __iomem *db_addr = &xhci->dba->doorbell[slot_id];
323 struct xhci_virt_ep *ep = &xhci->devs[slot_id]->eps[ep_index];
324 unsigned int ep_state = ep->ep_state;
329 325
330 ep = &xhci->devs[slot_id]->eps[ep_index];
331 ep_state = ep->ep_state;
332 /* Don't ring the doorbell for this endpoint if there are pending 326 /* Don't ring the doorbell for this endpoint if there are pending
333 * cancellations because the we don't want to interrupt processing. 327 * cancellations because we don't want to interrupt processing.
334 * We don't want to restart any stream rings if there's a set dequeue 328 * We don't want to restart any stream rings if there's a set dequeue
335 * pointer command pending because the device can choose to start any 329 * pointer command pending because the device can choose to start any
336 * stream once the endpoint is on the HW schedule. 330 * stream once the endpoint is on the HW schedule.
337 * FIXME - check all the stream rings for pending cancellations. 331 * FIXME - check all the stream rings for pending cancellations.
338 */ 332 */
339 if (!(ep_state & EP_HALT_PENDING) && !(ep_state & SET_DEQ_PENDING) 333 if ((ep_state & EP_HALT_PENDING) || (ep_state & SET_DEQ_PENDING) ||
340 && !(ep_state & EP_HALTED)) { 334 (ep_state & EP_HALTED))
341 field = xhci_readl(xhci, db_addr) & DB_MASK; 335 return;
342 field |= EPI_TO_DB(ep_index) | STREAM_ID_TO_DB(stream_id); 336 xhci_writel(xhci, DB_VALUE(ep_index, stream_id), db_addr);
343 xhci_writel(xhci, field, db_addr); 337 /* The CPU has better things to do at this point than wait for a
344 } 338 * write-posting flush. It'll get there soon enough.
339 */
345} 340}
346 341
347/* Ring the doorbell for any rings with pending URBs */ 342/* Ring the doorbell for any rings with pending URBs */
@@ -1188,7 +1183,7 @@ static void handle_port_status(struct xhci_hcd *xhci,
1188 1183
1189 addr = &xhci->op_regs->port_status_base + NUM_PORT_REGS * (port_id - 1); 1184 addr = &xhci->op_regs->port_status_base + NUM_PORT_REGS * (port_id - 1);
1190 temp = xhci_readl(xhci, addr); 1185 temp = xhci_readl(xhci, addr);
1191 if ((temp & PORT_CONNECT) && (hcd->state == HC_STATE_SUSPENDED)) { 1186 if (hcd->state == HC_STATE_SUSPENDED) {
1192 xhci_dbg(xhci, "resume root hub\n"); 1187 xhci_dbg(xhci, "resume root hub\n");
1193 usb_hcd_resume_root_hub(hcd); 1188 usb_hcd_resume_root_hub(hcd);
1194 } 1189 }
@@ -1710,8 +1705,7 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td,
1710 /* Others already handled above */ 1705 /* Others already handled above */
1711 break; 1706 break;
1712 } 1707 }
1713 dev_dbg(&td->urb->dev->dev, 1708 xhci_dbg(xhci, "ep %#x - asked for %d bytes, "
1714 "ep %#x - asked for %d bytes, "
1715 "%d bytes untransferred\n", 1709 "%d bytes untransferred\n",
1716 td->urb->ep->desc.bEndpointAddress, 1710 td->urb->ep->desc.bEndpointAddress,
1717 td->urb->transfer_buffer_length, 1711 td->urb->transfer_buffer_length,
@@ -2389,7 +2383,8 @@ static unsigned int count_sg_trbs_needed(struct xhci_hcd *xhci, struct urb *urb)
2389 } 2383 }
2390 xhci_dbg(xhci, "\n"); 2384 xhci_dbg(xhci, "\n");
2391 if (!in_interrupt()) 2385 if (!in_interrupt())
2392 dev_dbg(&urb->dev->dev, "ep %#x - urb len = %d, sglist used, num_trbs = %d\n", 2386 xhci_dbg(xhci, "ep %#x - urb len = %d, sglist used, "
2387 "num_trbs = %d\n",
2393 urb->ep->desc.bEndpointAddress, 2388 urb->ep->desc.bEndpointAddress,
2394 urb->transfer_buffer_length, 2389 urb->transfer_buffer_length,
2395 num_trbs); 2390 num_trbs);
@@ -2414,14 +2409,17 @@ static void check_trb_math(struct urb *urb, int num_trbs, int running_total)
2414 2409
2415static void giveback_first_trb(struct xhci_hcd *xhci, int slot_id, 2410static void giveback_first_trb(struct xhci_hcd *xhci, int slot_id,
2416 unsigned int ep_index, unsigned int stream_id, int start_cycle, 2411 unsigned int ep_index, unsigned int stream_id, int start_cycle,
2417 struct xhci_generic_trb *start_trb, struct xhci_td *td) 2412 struct xhci_generic_trb *start_trb)
2418{ 2413{
2419 /* 2414 /*
2420 * Pass all the TRBs to the hardware at once and make sure this write 2415 * Pass all the TRBs to the hardware at once and make sure this write
2421 * isn't reordered. 2416 * isn't reordered.
2422 */ 2417 */
2423 wmb(); 2418 wmb();
2424 start_trb->field[3] |= start_cycle; 2419 if (start_cycle)
2420 start_trb->field[3] |= start_cycle;
2421 else
2422 start_trb->field[3] &= ~0x1;
2425 xhci_ring_ep_doorbell(xhci, slot_id, ep_index, stream_id); 2423 xhci_ring_ep_doorbell(xhci, slot_id, ep_index, stream_id);
2426} 2424}
2427 2425
@@ -2449,7 +2447,7 @@ int xhci_queue_intr_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
2449 * to set the polling interval (once the API is added). 2447 * to set the polling interval (once the API is added).
2450 */ 2448 */
2451 if (xhci_interval != ep_interval) { 2449 if (xhci_interval != ep_interval) {
2452 if (!printk_ratelimit()) 2450 if (printk_ratelimit())
2453 dev_dbg(&urb->dev->dev, "Driver uses different interval" 2451 dev_dbg(&urb->dev->dev, "Driver uses different interval"
2454 " (%d microframe%s) than xHCI " 2452 " (%d microframe%s) than xHCI "
2455 "(%d microframe%s)\n", 2453 "(%d microframe%s)\n",
@@ -2551,9 +2549,11 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
2551 u32 remainder = 0; 2549 u32 remainder = 0;
2552 2550
2553 /* Don't change the cycle bit of the first TRB until later */ 2551 /* Don't change the cycle bit of the first TRB until later */
2554 if (first_trb) 2552 if (first_trb) {
2555 first_trb = false; 2553 first_trb = false;
2556 else 2554 if (start_cycle == 0)
2555 field |= 0x1;
2556 } else
2557 field |= ep_ring->cycle_state; 2557 field |= ep_ring->cycle_state;
2558 2558
2559 /* Chain all the TRBs together; clear the chain bit in the last 2559 /* Chain all the TRBs together; clear the chain bit in the last
@@ -2625,7 +2625,7 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
2625 2625
2626 check_trb_math(urb, num_trbs, running_total); 2626 check_trb_math(urb, num_trbs, running_total);
2627 giveback_first_trb(xhci, slot_id, ep_index, urb->stream_id, 2627 giveback_first_trb(xhci, slot_id, ep_index, urb->stream_id,
2628 start_cycle, start_trb, td); 2628 start_cycle, start_trb);
2629 return 0; 2629 return 0;
2630} 2630}
2631 2631
@@ -2671,7 +2671,8 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
2671 /* FIXME: this doesn't deal with URB_ZERO_PACKET - need one more */ 2671 /* FIXME: this doesn't deal with URB_ZERO_PACKET - need one more */
2672 2672
2673 if (!in_interrupt()) 2673 if (!in_interrupt())
2674 dev_dbg(&urb->dev->dev, "ep %#x - urb len = %#x (%d), addr = %#llx, num_trbs = %d\n", 2674 xhci_dbg(xhci, "ep %#x - urb len = %#x (%d), "
2675 "addr = %#llx, num_trbs = %d\n",
2675 urb->ep->desc.bEndpointAddress, 2676 urb->ep->desc.bEndpointAddress,
2676 urb->transfer_buffer_length, 2677 urb->transfer_buffer_length,
2677 urb->transfer_buffer_length, 2678 urb->transfer_buffer_length,
@@ -2711,9 +2712,11 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
2711 field = 0; 2712 field = 0;
2712 2713
2713 /* Don't change the cycle bit of the first TRB until later */ 2714 /* Don't change the cycle bit of the first TRB until later */
2714 if (first_trb) 2715 if (first_trb) {
2715 first_trb = false; 2716 first_trb = false;
2716 else 2717 if (start_cycle == 0)
2718 field |= 0x1;
2719 } else
2717 field |= ep_ring->cycle_state; 2720 field |= ep_ring->cycle_state;
2718 2721
2719 /* Chain all the TRBs together; clear the chain bit in the last 2722 /* Chain all the TRBs together; clear the chain bit in the last
@@ -2757,7 +2760,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
2757 2760
2758 check_trb_math(urb, num_trbs, running_total); 2761 check_trb_math(urb, num_trbs, running_total);
2759 giveback_first_trb(xhci, slot_id, ep_index, urb->stream_id, 2762 giveback_first_trb(xhci, slot_id, ep_index, urb->stream_id,
2760 start_cycle, start_trb, td); 2763 start_cycle, start_trb);
2761 return 0; 2764 return 0;
2762} 2765}
2763 2766
@@ -2818,13 +2821,17 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
2818 /* Queue setup TRB - see section 6.4.1.2.1 */ 2821 /* Queue setup TRB - see section 6.4.1.2.1 */
2819 /* FIXME better way to translate setup_packet into two u32 fields? */ 2822 /* FIXME better way to translate setup_packet into two u32 fields? */
2820 setup = (struct usb_ctrlrequest *) urb->setup_packet; 2823 setup = (struct usb_ctrlrequest *) urb->setup_packet;
2824 field = 0;
2825 field |= TRB_IDT | TRB_TYPE(TRB_SETUP);
2826 if (start_cycle == 0)
2827 field |= 0x1;
2821 queue_trb(xhci, ep_ring, false, true, 2828 queue_trb(xhci, ep_ring, false, true,
2822 /* FIXME endianness is probably going to bite my ass here. */ 2829 /* FIXME endianness is probably going to bite my ass here. */
2823 setup->bRequestType | setup->bRequest << 8 | setup->wValue << 16, 2830 setup->bRequestType | setup->bRequest << 8 | setup->wValue << 16,
2824 setup->wIndex | setup->wLength << 16, 2831 setup->wIndex | setup->wLength << 16,
2825 TRB_LEN(8) | TRB_INTR_TARGET(0), 2832 TRB_LEN(8) | TRB_INTR_TARGET(0),
2826 /* Immediate data in pointer */ 2833 /* Immediate data in pointer */
2827 TRB_IDT | TRB_TYPE(TRB_SETUP)); 2834 field);
2828 2835
2829 /* If there's data, queue data TRBs */ 2836 /* If there's data, queue data TRBs */
2830 field = 0; 2837 field = 0;
@@ -2859,7 +2866,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
2859 field | TRB_IOC | TRB_TYPE(TRB_STATUS) | ep_ring->cycle_state); 2866 field | TRB_IOC | TRB_TYPE(TRB_STATUS) | ep_ring->cycle_state);
2860 2867
2861 giveback_first_trb(xhci, slot_id, ep_index, 0, 2868 giveback_first_trb(xhci, slot_id, ep_index, 0,
2862 start_cycle, start_trb, td); 2869 start_cycle, start_trb);
2863 return 0; 2870 return 0;
2864} 2871}
2865 2872
@@ -2900,6 +2907,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
2900 int running_total, trb_buff_len, td_len, td_remain_len, ret; 2907 int running_total, trb_buff_len, td_len, td_remain_len, ret;
2901 u64 start_addr, addr; 2908 u64 start_addr, addr;
2902 int i, j; 2909 int i, j;
2910 bool more_trbs_coming;
2903 2911
2904 ep_ring = xhci->devs[slot_id]->eps[ep_index].ring; 2912 ep_ring = xhci->devs[slot_id]->eps[ep_index].ring;
2905 2913
@@ -2910,7 +2918,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
2910 } 2918 }
2911 2919
2912 if (!in_interrupt()) 2920 if (!in_interrupt())
2913 dev_dbg(&urb->dev->dev, "ep %#x - urb len = %#x (%d)," 2921 xhci_dbg(xhci, "ep %#x - urb len = %#x (%d),"
2914 " addr = %#llx, num_tds = %d\n", 2922 " addr = %#llx, num_tds = %d\n",
2915 urb->ep->desc.bEndpointAddress, 2923 urb->ep->desc.bEndpointAddress,
2916 urb->transfer_buffer_length, 2924 urb->transfer_buffer_length,
@@ -2950,7 +2958,10 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
2950 field |= TRB_TYPE(TRB_ISOC); 2958 field |= TRB_TYPE(TRB_ISOC);
2951 /* Assume URB_ISO_ASAP is set */ 2959 /* Assume URB_ISO_ASAP is set */
2952 field |= TRB_SIA; 2960 field |= TRB_SIA;
2953 if (i > 0) 2961 if (i == 0) {
2962 if (start_cycle == 0)
2963 field |= 0x1;
2964 } else
2954 field |= ep_ring->cycle_state; 2965 field |= ep_ring->cycle_state;
2955 first_trb = false; 2966 first_trb = false;
2956 } else { 2967 } else {
@@ -2965,9 +2976,11 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
2965 */ 2976 */
2966 if (j < trbs_per_td - 1) { 2977 if (j < trbs_per_td - 1) {
2967 field |= TRB_CHAIN; 2978 field |= TRB_CHAIN;
2979 more_trbs_coming = true;
2968 } else { 2980 } else {
2969 td->last_trb = ep_ring->enqueue; 2981 td->last_trb = ep_ring->enqueue;
2970 field |= TRB_IOC; 2982 field |= TRB_IOC;
2983 more_trbs_coming = false;
2971 } 2984 }
2972 2985
2973 /* Calculate TRB length */ 2986 /* Calculate TRB length */
@@ -2980,7 +2993,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
2980 length_field = TRB_LEN(trb_buff_len) | 2993 length_field = TRB_LEN(trb_buff_len) |
2981 remainder | 2994 remainder |
2982 TRB_INTR_TARGET(0); 2995 TRB_INTR_TARGET(0);
2983 queue_trb(xhci, ep_ring, false, false, 2996 queue_trb(xhci, ep_ring, false, more_trbs_coming,
2984 lower_32_bits(addr), 2997 lower_32_bits(addr),
2985 upper_32_bits(addr), 2998 upper_32_bits(addr),
2986 length_field, 2999 length_field,
@@ -3003,10 +3016,8 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
3003 } 3016 }
3004 } 3017 }
3005 3018
3006 wmb(); 3019 giveback_first_trb(xhci, slot_id, ep_index, urb->stream_id,
3007 start_trb->field[3] |= start_cycle; 3020 start_cycle, start_trb);
3008
3009 xhci_ring_ep_doorbell(xhci, slot_id, ep_index, urb->stream_id);
3010 return 0; 3021 return 0;
3011} 3022}
3012 3023
@@ -3064,7 +3075,7 @@ int xhci_queue_isoc_tx_prepare(struct xhci_hcd *xhci, gfp_t mem_flags,
3064 * to set the polling interval (once the API is added). 3075 * to set the polling interval (once the API is added).
3065 */ 3076 */
3066 if (xhci_interval != ep_interval) { 3077 if (xhci_interval != ep_interval) {
3067 if (!printk_ratelimit()) 3078 if (printk_ratelimit())
3068 dev_dbg(&urb->dev->dev, "Driver uses different interval" 3079 dev_dbg(&urb->dev->dev, "Driver uses different interval"
3069 " (%d microframe%s) than xHCI " 3080 " (%d microframe%s) than xHCI "
3070 "(%d microframe%s)\n", 3081 "(%d microframe%s)\n",
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 45e4a3108cc3..34cf4e165877 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -226,7 +226,8 @@ static int xhci_setup_msi(struct xhci_hcd *xhci)
226static int xhci_setup_msix(struct xhci_hcd *xhci) 226static int xhci_setup_msix(struct xhci_hcd *xhci)
227{ 227{
228 int i, ret = 0; 228 int i, ret = 0;
229 struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); 229 struct usb_hcd *hcd = xhci_to_hcd(xhci);
230 struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
230 231
231 /* 232 /*
232 * calculate number of msi-x vectors supported. 233 * calculate number of msi-x vectors supported.
@@ -265,6 +266,7 @@ static int xhci_setup_msix(struct xhci_hcd *xhci)
265 goto disable_msix; 266 goto disable_msix;
266 } 267 }
267 268
269 hcd->msix_enabled = 1;
268 return ret; 270 return ret;
269 271
270disable_msix: 272disable_msix:
@@ -280,7 +282,8 @@ free_entries:
280/* Free any IRQs and disable MSI-X */ 282/* Free any IRQs and disable MSI-X */
281static void xhci_cleanup_msix(struct xhci_hcd *xhci) 283static void xhci_cleanup_msix(struct xhci_hcd *xhci)
282{ 284{
283 struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); 285 struct usb_hcd *hcd = xhci_to_hcd(xhci);
286 struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
284 287
285 xhci_free_irq(xhci); 288 xhci_free_irq(xhci);
286 289
@@ -292,6 +295,7 @@ static void xhci_cleanup_msix(struct xhci_hcd *xhci)
292 pci_disable_msi(pdev); 295 pci_disable_msi(pdev);
293 } 296 }
294 297
298 hcd->msix_enabled = 0;
295 return; 299 return;
296} 300}
297 301
@@ -508,9 +512,10 @@ void xhci_stop(struct usb_hcd *hcd)
508 spin_lock_irq(&xhci->lock); 512 spin_lock_irq(&xhci->lock);
509 xhci_halt(xhci); 513 xhci_halt(xhci);
510 xhci_reset(xhci); 514 xhci_reset(xhci);
511 xhci_cleanup_msix(xhci);
512 spin_unlock_irq(&xhci->lock); 515 spin_unlock_irq(&xhci->lock);
513 516
517 xhci_cleanup_msix(xhci);
518
514#ifdef CONFIG_USB_XHCI_HCD_DEBUGGING 519#ifdef CONFIG_USB_XHCI_HCD_DEBUGGING
515 /* Tell the event ring poll function not to reschedule */ 520 /* Tell the event ring poll function not to reschedule */
516 xhci->zombie = 1; 521 xhci->zombie = 1;
@@ -544,9 +549,10 @@ void xhci_shutdown(struct usb_hcd *hcd)
544 549
545 spin_lock_irq(&xhci->lock); 550 spin_lock_irq(&xhci->lock);
546 xhci_halt(xhci); 551 xhci_halt(xhci);
547 xhci_cleanup_msix(xhci);
548 spin_unlock_irq(&xhci->lock); 552 spin_unlock_irq(&xhci->lock);
549 553
554 xhci_cleanup_msix(xhci);
555
550 xhci_dbg(xhci, "xhci_shutdown completed - status = %x\n", 556 xhci_dbg(xhci, "xhci_shutdown completed - status = %x\n",
551 xhci_readl(xhci, &xhci->op_regs->status)); 557 xhci_readl(xhci, &xhci->op_regs->status));
552} 558}
@@ -647,6 +653,7 @@ int xhci_suspend(struct xhci_hcd *xhci)
647 int rc = 0; 653 int rc = 0;
648 struct usb_hcd *hcd = xhci_to_hcd(xhci); 654 struct usb_hcd *hcd = xhci_to_hcd(xhci);
649 u32 command; 655 u32 command;
656 int i;
650 657
651 spin_lock_irq(&xhci->lock); 658 spin_lock_irq(&xhci->lock);
652 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); 659 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
@@ -677,10 +684,15 @@ int xhci_suspend(struct xhci_hcd *xhci)
677 spin_unlock_irq(&xhci->lock); 684 spin_unlock_irq(&xhci->lock);
678 return -ETIMEDOUT; 685 return -ETIMEDOUT;
679 } 686 }
680 /* step 5: remove core well power */
681 xhci_cleanup_msix(xhci);
682 spin_unlock_irq(&xhci->lock); 687 spin_unlock_irq(&xhci->lock);
683 688
689 /* step 5: remove core well power */
690 /* synchronize irq when using MSI-X */
691 if (xhci->msix_entries) {
692 for (i = 0; i < xhci->msix_count; i++)
693 synchronize_irq(xhci->msix_entries[i].vector);
694 }
695
684 return rc; 696 return rc;
685} 697}
686 698
@@ -694,7 +706,6 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
694{ 706{
695 u32 command, temp = 0; 707 u32 command, temp = 0;
696 struct usb_hcd *hcd = xhci_to_hcd(xhci); 708 struct usb_hcd *hcd = xhci_to_hcd(xhci);
697 struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
698 int old_state, retval; 709 int old_state, retval;
699 710
700 old_state = hcd->state; 711 old_state = hcd->state;
@@ -729,9 +740,8 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
729 xhci_dbg(xhci, "Stop HCD\n"); 740 xhci_dbg(xhci, "Stop HCD\n");
730 xhci_halt(xhci); 741 xhci_halt(xhci);
731 xhci_reset(xhci); 742 xhci_reset(xhci);
732 if (hibernated)
733 xhci_cleanup_msix(xhci);
734 spin_unlock_irq(&xhci->lock); 743 spin_unlock_irq(&xhci->lock);
744 xhci_cleanup_msix(xhci);
735 745
736#ifdef CONFIG_USB_XHCI_HCD_DEBUGGING 746#ifdef CONFIG_USB_XHCI_HCD_DEBUGGING
737 /* Tell the event ring poll function not to reschedule */ 747 /* Tell the event ring poll function not to reschedule */
@@ -765,30 +775,6 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
765 return retval; 775 return retval;
766 } 776 }
767 777
768 spin_unlock_irq(&xhci->lock);
769 /* Re-setup MSI-X */
770 if (hcd->irq)
771 free_irq(hcd->irq, hcd);
772 hcd->irq = -1;
773
774 retval = xhci_setup_msix(xhci);
775 if (retval)
776 /* fall back to msi*/
777 retval = xhci_setup_msi(xhci);
778
779 if (retval) {
780 /* fall back to legacy interrupt*/
781 retval = request_irq(pdev->irq, &usb_hcd_irq, IRQF_SHARED,
782 hcd->irq_descr, hcd);
783 if (retval) {
784 xhci_err(xhci, "request interrupt %d failed\n",
785 pdev->irq);
786 return retval;
787 }
788 hcd->irq = pdev->irq;
789 }
790
791 spin_lock_irq(&xhci->lock);
792 /* step 4: set Run/Stop bit */ 778 /* step 4: set Run/Stop bit */
793 command = xhci_readl(xhci, &xhci->op_regs->command); 779 command = xhci_readl(xhci, &xhci->op_regs->command);
794 command |= CMD_RUN; 780 command |= CMD_RUN;
@@ -2445,8 +2431,12 @@ int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev)
2445 xhci_err(xhci, "Error while assigning device slot ID\n"); 2431 xhci_err(xhci, "Error while assigning device slot ID\n");
2446 return 0; 2432 return 0;
2447 } 2433 }
2448 /* xhci_alloc_virt_device() does not touch rings; no need to lock */ 2434 /* xhci_alloc_virt_device() does not touch rings; no need to lock.
2449 if (!xhci_alloc_virt_device(xhci, xhci->slot_id, udev, GFP_KERNEL)) { 2435 * Use GFP_NOIO, since this function can be called from
2436 * xhci_discover_or_reset_device(), which may be called as part of
2437 * mass storage driver error handling.
2438 */
2439 if (!xhci_alloc_virt_device(xhci, xhci->slot_id, udev, GFP_NOIO)) {
2450 /* Disable slot, if we can do it without mem alloc */ 2440 /* Disable slot, if we can do it without mem alloc */
2451 xhci_warn(xhci, "Could not allocate xHCI USB device data structures\n"); 2441 xhci_warn(xhci, "Could not allocate xHCI USB device data structures\n");
2452 spin_lock_irqsave(&xhci->lock, flags); 2442 spin_lock_irqsave(&xhci->lock, flags);
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 170c367112d2..7f236fd22015 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -436,22 +436,18 @@ struct xhci_run_regs {
436/** 436/**
437 * struct doorbell_array 437 * struct doorbell_array
438 * 438 *
439 * Bits 0 - 7: Endpoint target
440 * Bits 8 - 15: RsvdZ
441 * Bits 16 - 31: Stream ID
442 *
439 * Section 5.6 443 * Section 5.6
440 */ 444 */
441struct xhci_doorbell_array { 445struct xhci_doorbell_array {
442 u32 doorbell[256]; 446 u32 doorbell[256];
443}; 447};
444 448
445#define DB_TARGET_MASK 0xFFFFFF00 449#define DB_VALUE(ep, stream) ((((ep) + 1) & 0xff) | ((stream) << 16))
446#define DB_STREAM_ID_MASK 0x0000FFFF 450#define DB_VALUE_HOST 0x00000000
447#define DB_TARGET_HOST 0x0
448#define DB_STREAM_ID_HOST 0x0
449#define DB_MASK (0xff << 8)
450
451/* Endpoint Target - bits 0:7 */
452#define EPI_TO_DB(p) (((p) + 1) & 0xff)
453#define STREAM_ID_TO_DB(p) (((p) & 0xffff) << 16)
454
455 451
456/** 452/**
457 * struct xhci_protocol_caps 453 * struct xhci_protocol_caps
diff --git a/drivers/usb/misc/usbled.c b/drivers/usb/misc/usbled.c
index 1732d9bc097e..1616ad1793a4 100644
--- a/drivers/usb/misc/usbled.c
+++ b/drivers/usb/misc/usbled.c
@@ -45,7 +45,7 @@ struct usb_led {
45 45
46static void change_color(struct usb_led *led) 46static void change_color(struct usb_led *led)
47{ 47{
48 int retval; 48 int retval = 0;
49 unsigned char *buffer; 49 unsigned char *buffer;
50 50
51 buffer = kmalloc(8, GFP_KERNEL); 51 buffer = kmalloc(8, GFP_KERNEL);
diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c
index 4ff21587ab03..f7a205738032 100644
--- a/drivers/usb/misc/uss720.c
+++ b/drivers/usb/misc/uss720.c
@@ -776,7 +776,6 @@ static const struct usb_device_id uss720_table[] = {
776 { USB_DEVICE(0x0557, 0x2001) }, 776 { USB_DEVICE(0x0557, 0x2001) },
777 { USB_DEVICE(0x0729, 0x1284) }, 777 { USB_DEVICE(0x0729, 0x1284) },
778 { USB_DEVICE(0x1293, 0x0002) }, 778 { USB_DEVICE(0x1293, 0x0002) },
779 { USB_DEVICE(0x1293, 0x0002) },
780 { USB_DEVICE(0x050d, 0x0002) }, 779 { USB_DEVICE(0x050d, 0x0002) },
781 { } /* Terminating entry */ 780 { } /* Terminating entry */
782}; 781};
diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c
index e70014ab0976..8acf165fe13b 100644
--- a/drivers/usb/otg/nop-usb-xceiv.c
+++ b/drivers/usb/otg/nop-usb-xceiv.c
@@ -132,6 +132,8 @@ static int __devinit nop_usb_xceiv_probe(struct platform_device *pdev)
132 132
133 platform_set_drvdata(pdev, nop); 133 platform_set_drvdata(pdev, nop);
134 134
135 BLOCKING_INIT_NOTIFIER_HEAD(&nop->otg.notifier);
136
135 return 0; 137 return 0;
136exit: 138exit:
137 kfree(nop); 139 kfree(nop);
diff --git a/drivers/usb/otg/ulpi.c b/drivers/usb/otg/ulpi.c
index 059d9ac0ab5b..770d799d5afb 100644
--- a/drivers/usb/otg/ulpi.c
+++ b/drivers/usb/otg/ulpi.c
@@ -45,7 +45,7 @@ struct ulpi_info {
45/* ULPI hardcoded IDs, used for probing */ 45/* ULPI hardcoded IDs, used for probing */
46static struct ulpi_info ulpi_ids[] = { 46static struct ulpi_info ulpi_ids[] = {
47 ULPI_INFO(ULPI_ID(0x04cc, 0x1504), "NXP ISP1504"), 47 ULPI_INFO(ULPI_ID(0x04cc, 0x1504), "NXP ISP1504"),
48 ULPI_INFO(ULPI_ID(0x0424, 0x0006), "SMSC USB3319"), 48 ULPI_INFO(ULPI_ID(0x0424, 0x0006), "SMSC USB331x"),
49}; 49};
50 50
51static int ulpi_set_otg_flags(struct otg_transceiver *otg) 51static int ulpi_set_otg_flags(struct otg_transceiver *otg)
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c
index 63f7cc45bcac..7b8815ddf368 100644
--- a/drivers/usb/serial/ch341.c
+++ b/drivers/usb/serial/ch341.c
@@ -486,12 +486,22 @@ static void ch341_read_int_callback(struct urb *urb)
486 if (actual_length >= 4) { 486 if (actual_length >= 4) {
487 struct ch341_private *priv = usb_get_serial_port_data(port); 487 struct ch341_private *priv = usb_get_serial_port_data(port);
488 unsigned long flags; 488 unsigned long flags;
489 u8 prev_line_status = priv->line_status;
489 490
490 spin_lock_irqsave(&priv->lock, flags); 491 spin_lock_irqsave(&priv->lock, flags);
491 priv->line_status = (~(data[2])) & CH341_BITS_MODEM_STAT; 492 priv->line_status = (~(data[2])) & CH341_BITS_MODEM_STAT;
492 if ((data[1] & CH341_MULT_STAT)) 493 if ((data[1] & CH341_MULT_STAT))
493 priv->multi_status_change = 1; 494 priv->multi_status_change = 1;
494 spin_unlock_irqrestore(&priv->lock, flags); 495 spin_unlock_irqrestore(&priv->lock, flags);
496
497 if ((priv->line_status ^ prev_line_status) & CH341_BIT_DCD) {
498 struct tty_struct *tty = tty_port_tty_get(&port->port);
499 if (tty)
500 usb_serial_handle_dcd_change(port, tty,
501 priv->line_status & CH341_BIT_DCD);
502 tty_kref_put(tty);
503 }
504
495 wake_up_interruptible(&priv->delta_msr_wait); 505 wake_up_interruptible(&priv->delta_msr_wait);
496 } 506 }
497 507
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index 8d7731dbf478..735ea03157ab 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -49,7 +49,6 @@ static int cp210x_tiocmset_port(struct usb_serial_port *port, struct file *,
49static void cp210x_break_ctl(struct tty_struct *, int); 49static void cp210x_break_ctl(struct tty_struct *, int);
50static int cp210x_startup(struct usb_serial *); 50static int cp210x_startup(struct usb_serial *);
51static void cp210x_dtr_rts(struct usb_serial_port *p, int on); 51static void cp210x_dtr_rts(struct usb_serial_port *p, int on);
52static int cp210x_carrier_raised(struct usb_serial_port *p);
53 52
54static int debug; 53static int debug;
55 54
@@ -87,7 +86,6 @@ static const struct usb_device_id id_table[] = {
87 { USB_DEVICE(0x10C4, 0x8115) }, /* Arygon NFC/Mifare Reader */ 86 { USB_DEVICE(0x10C4, 0x8115) }, /* Arygon NFC/Mifare Reader */
88 { USB_DEVICE(0x10C4, 0x813D) }, /* Burnside Telecom Deskmobile */ 87 { USB_DEVICE(0x10C4, 0x813D) }, /* Burnside Telecom Deskmobile */
89 { USB_DEVICE(0x10C4, 0x813F) }, /* Tams Master Easy Control */ 88 { USB_DEVICE(0x10C4, 0x813F) }, /* Tams Master Easy Control */
90 { USB_DEVICE(0x10C4, 0x8149) }, /* West Mountain Radio Computerized Battery Analyzer */
91 { USB_DEVICE(0x10C4, 0x814A) }, /* West Mountain Radio RIGblaster P&P */ 89 { USB_DEVICE(0x10C4, 0x814A) }, /* West Mountain Radio RIGblaster P&P */
92 { USB_DEVICE(0x10C4, 0x814B) }, /* West Mountain Radio RIGtalk */ 90 { USB_DEVICE(0x10C4, 0x814B) }, /* West Mountain Radio RIGtalk */
93 { USB_DEVICE(0x10C4, 0x8156) }, /* B&G H3000 link cable */ 91 { USB_DEVICE(0x10C4, 0x8156) }, /* B&G H3000 link cable */
@@ -110,7 +108,9 @@ static const struct usb_device_id id_table[] = {
110 { USB_DEVICE(0x10C4, 0x8341) }, /* Siemens MC35PU GPRS Modem */ 108 { USB_DEVICE(0x10C4, 0x8341) }, /* Siemens MC35PU GPRS Modem */
111 { USB_DEVICE(0x10C4, 0x8382) }, /* Cygnal Integrated Products, Inc. */ 109 { USB_DEVICE(0x10C4, 0x8382) }, /* Cygnal Integrated Products, Inc. */
112 { USB_DEVICE(0x10C4, 0x83A8) }, /* Amber Wireless AMB2560 */ 110 { USB_DEVICE(0x10C4, 0x83A8) }, /* Amber Wireless AMB2560 */
111 { USB_DEVICE(0x10C4, 0x83D8) }, /* DekTec DTA Plus VHF/UHF Booster/Attenuator */
113 { USB_DEVICE(0x10C4, 0x8411) }, /* Kyocera GPS Module */ 112 { USB_DEVICE(0x10C4, 0x8411) }, /* Kyocera GPS Module */
113 { USB_DEVICE(0x10C4, 0x8418) }, /* IRZ Automation Teleport SG-10 GSM/GPRS Modem */
114 { USB_DEVICE(0x10C4, 0x846E) }, /* BEI USB Sensor Interface (VCP) */ 114 { USB_DEVICE(0x10C4, 0x846E) }, /* BEI USB Sensor Interface (VCP) */
115 { USB_DEVICE(0x10C4, 0x8477) }, /* Balluff RFID */ 115 { USB_DEVICE(0x10C4, 0x8477) }, /* Balluff RFID */
116 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ 116 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */
@@ -165,8 +165,7 @@ static struct usb_serial_driver cp210x_device = {
165 .tiocmget = cp210x_tiocmget, 165 .tiocmget = cp210x_tiocmget,
166 .tiocmset = cp210x_tiocmset, 166 .tiocmset = cp210x_tiocmset,
167 .attach = cp210x_startup, 167 .attach = cp210x_startup,
168 .dtr_rts = cp210x_dtr_rts, 168 .dtr_rts = cp210x_dtr_rts
169 .carrier_raised = cp210x_carrier_raised
170}; 169};
171 170
172/* Config request types */ 171/* Config request types */
@@ -765,15 +764,6 @@ static int cp210x_tiocmget (struct tty_struct *tty, struct file *file)
765 return result; 764 return result;
766} 765}
767 766
768static int cp210x_carrier_raised(struct usb_serial_port *p)
769{
770 unsigned int control;
771 cp210x_get_config(p, CP210X_GET_MDMSTS, &control, 1);
772 if (control & CONTROL_DCD)
773 return 1;
774 return 0;
775}
776
777static void cp210x_break_ctl (struct tty_struct *tty, int break_state) 767static void cp210x_break_ctl (struct tty_struct *tty, int break_state)
778{ 768{
779 struct usb_serial_port *port = tty->driver_data; 769 struct usb_serial_port *port = tty->driver_data;
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index b92070c103cd..666e5a6edd82 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -455,7 +455,6 @@ static int digi_write_room(struct tty_struct *tty);
455static int digi_chars_in_buffer(struct tty_struct *tty); 455static int digi_chars_in_buffer(struct tty_struct *tty);
456static int digi_open(struct tty_struct *tty, struct usb_serial_port *port); 456static int digi_open(struct tty_struct *tty, struct usb_serial_port *port);
457static void digi_close(struct usb_serial_port *port); 457static void digi_close(struct usb_serial_port *port);
458static int digi_carrier_raised(struct usb_serial_port *port);
459static void digi_dtr_rts(struct usb_serial_port *port, int on); 458static void digi_dtr_rts(struct usb_serial_port *port, int on);
460static int digi_startup_device(struct usb_serial *serial); 459static int digi_startup_device(struct usb_serial *serial);
461static int digi_startup(struct usb_serial *serial); 460static int digi_startup(struct usb_serial *serial);
@@ -511,7 +510,6 @@ static struct usb_serial_driver digi_acceleport_2_device = {
511 .open = digi_open, 510 .open = digi_open,
512 .close = digi_close, 511 .close = digi_close,
513 .dtr_rts = digi_dtr_rts, 512 .dtr_rts = digi_dtr_rts,
514 .carrier_raised = digi_carrier_raised,
515 .write = digi_write, 513 .write = digi_write,
516 .write_room = digi_write_room, 514 .write_room = digi_write_room,
517 .write_bulk_callback = digi_write_bulk_callback, 515 .write_bulk_callback = digi_write_bulk_callback,
@@ -1339,14 +1337,6 @@ static void digi_dtr_rts(struct usb_serial_port *port, int on)
1339 digi_set_modem_signals(port, on * (TIOCM_DTR|TIOCM_RTS), 1); 1337 digi_set_modem_signals(port, on * (TIOCM_DTR|TIOCM_RTS), 1);
1340} 1338}
1341 1339
1342static int digi_carrier_raised(struct usb_serial_port *port)
1343{
1344 struct digi_port *priv = usb_get_serial_port_data(port);
1345 if (priv->dp_modem_signals & TIOCM_CD)
1346 return 1;
1347 return 0;
1348}
1349
1350static int digi_open(struct tty_struct *tty, struct usb_serial_port *port) 1340static int digi_open(struct tty_struct *tty, struct usb_serial_port *port)
1351{ 1341{
1352 int ret; 1342 int ret;
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index a2668d089260..4787c0cd063f 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -676,7 +676,17 @@ static struct usb_device_id id_table_combined [] = {
676 { USB_DEVICE(FTDI_VID, FTDI_PCDJ_DAC2_PID) }, 676 { USB_DEVICE(FTDI_VID, FTDI_PCDJ_DAC2_PID) },
677 { USB_DEVICE(FTDI_VID, FTDI_RRCIRKITS_LOCOBUFFER_PID) }, 677 { USB_DEVICE(FTDI_VID, FTDI_RRCIRKITS_LOCOBUFFER_PID) },
678 { USB_DEVICE(FTDI_VID, FTDI_ASK_RDR400_PID) }, 678 { USB_DEVICE(FTDI_VID, FTDI_ASK_RDR400_PID) },
679 { USB_DEVICE(ICOM_ID1_VID, ICOM_ID1_PID) }, 679 { USB_DEVICE(ICOM_VID, ICOM_ID_1_PID) },
680 { USB_DEVICE(ICOM_VID, ICOM_OPC_U_UC_PID) },
681 { USB_DEVICE(ICOM_VID, ICOM_ID_RP2C1_PID) },
682 { USB_DEVICE(ICOM_VID, ICOM_ID_RP2C2_PID) },
683 { USB_DEVICE(ICOM_VID, ICOM_ID_RP2D_PID) },
684 { USB_DEVICE(ICOM_VID, ICOM_ID_RP2VT_PID) },
685 { USB_DEVICE(ICOM_VID, ICOM_ID_RP2VR_PID) },
686 { USB_DEVICE(ICOM_VID, ICOM_ID_RP4KVT_PID) },
687 { USB_DEVICE(ICOM_VID, ICOM_ID_RP4KVR_PID) },
688 { USB_DEVICE(ICOM_VID, ICOM_ID_RP2KVT_PID) },
689 { USB_DEVICE(ICOM_VID, ICOM_ID_RP2KVR_PID) },
680 { USB_DEVICE(FTDI_VID, FTDI_ACG_HFDUAL_PID) }, 690 { USB_DEVICE(FTDI_VID, FTDI_ACG_HFDUAL_PID) },
681 { USB_DEVICE(FTDI_VID, FTDI_YEI_SERVOCENTER31_PID) }, 691 { USB_DEVICE(FTDI_VID, FTDI_YEI_SERVOCENTER31_PID) },
682 { USB_DEVICE(FTDI_VID, FTDI_THORLABS_PID) }, 692 { USB_DEVICE(FTDI_VID, FTDI_THORLABS_PID) },
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
index bf0867285481..ed160def8584 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -569,11 +569,23 @@
569#define OCT_US101_PID 0x0421 /* OCT US101 USB to RS-232 */ 569#define OCT_US101_PID 0x0421 /* OCT US101 USB to RS-232 */
570 570
571/* 571/*
572 * Icom ID-1 digital transceiver 572 * Definitions for Icom Inc. devices
573 */ 573 */
574 574#define ICOM_VID 0x0C26 /* Icom vendor ID */
575#define ICOM_ID1_VID 0x0C26 575/* Note: ID-1 is a communications tranceiver for HAM-radio operators */
576#define ICOM_ID1_PID 0x0004 576#define ICOM_ID_1_PID 0x0004 /* ID-1 USB to RS-232 */
577/* Note: OPC is an Optional cable to connect an Icom Tranceiver */
578#define ICOM_OPC_U_UC_PID 0x0018 /* OPC-478UC, OPC-1122U cloning cable */
579/* Note: ID-RP* devices are Icom Repeater Devices for HAM-radio */
580#define ICOM_ID_RP2C1_PID 0x0009 /* ID-RP2C Asset 1 to RS-232 */
581#define ICOM_ID_RP2C2_PID 0x000A /* ID-RP2C Asset 2 to RS-232 */
582#define ICOM_ID_RP2D_PID 0x000B /* ID-RP2D configuration port*/
583#define ICOM_ID_RP2VT_PID 0x000C /* ID-RP2V Transmit config port */
584#define ICOM_ID_RP2VR_PID 0x000D /* ID-RP2V Receive config port */
585#define ICOM_ID_RP4KVT_PID 0x0010 /* ID-RP4000V Transmit config port */
586#define ICOM_ID_RP4KVR_PID 0x0011 /* ID-RP4000V Receive config port */
587#define ICOM_ID_RP2KVT_PID 0x0012 /* ID-RP2000V Transmit config port */
588#define ICOM_ID_RP2KVR_PID 0x0013 /* ID-RP2000V Receive config port */
577 589
578/* 590/*
579 * GN Otometrics (http://www.otometrics.com) 591 * GN Otometrics (http://www.otometrics.com)
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index e6833e216fc9..e4db5ad2bc55 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -479,6 +479,26 @@ int usb_serial_handle_break(struct usb_serial_port *port)
479} 479}
480EXPORT_SYMBOL_GPL(usb_serial_handle_break); 480EXPORT_SYMBOL_GPL(usb_serial_handle_break);
481 481
482/**
483 * usb_serial_handle_dcd_change - handle a change of carrier detect state
484 * @port: usb_serial_port structure for the open port
485 * @tty: tty_struct structure for the port
486 * @status: new carrier detect status, nonzero if active
487 */
488void usb_serial_handle_dcd_change(struct usb_serial_port *usb_port,
489 struct tty_struct *tty, unsigned int status)
490{
491 struct tty_port *port = &usb_port->port;
492
493 dbg("%s - port %d, status %d", __func__, usb_port->number, status);
494
495 if (status)
496 wake_up_interruptible(&port->open_wait);
497 else if (tty && !C_CLOCAL(tty))
498 tty_hangup(tty);
499}
500EXPORT_SYMBOL_GPL(usb_serial_handle_dcd_change);
501
482int usb_serial_generic_resume(struct usb_serial *serial) 502int usb_serial_generic_resume(struct usb_serial *serial)
483{ 503{
484 struct usb_serial_port *port; 504 struct usb_serial_port *port;
diff --git a/drivers/usb/serial/io_tables.h b/drivers/usb/serial/io_tables.h
index 6ab2a3f97fe8..178b22eb32b1 100644
--- a/drivers/usb/serial/io_tables.h
+++ b/drivers/usb/serial/io_tables.h
@@ -199,6 +199,7 @@ static struct usb_serial_driver epic_device = {
199 .name = "epic", 199 .name = "epic",
200 }, 200 },
201 .description = "EPiC device", 201 .description = "EPiC device",
202 .usb_driver = &io_driver,
202 .id_table = Epic_port_id_table, 203 .id_table = Epic_port_id_table,
203 .num_ports = 1, 204 .num_ports = 1,
204 .open = edge_open, 205 .open = edge_open,
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c
index 12ed594f5f80..99b97c04896f 100644
--- a/drivers/usb/serial/iuu_phoenix.c
+++ b/drivers/usb/serial/iuu_phoenix.c
@@ -1275,6 +1275,7 @@ static struct usb_serial_driver iuu_device = {
1275 .name = "iuu_phoenix", 1275 .name = "iuu_phoenix",
1276 }, 1276 },
1277 .id_table = id_table, 1277 .id_table = id_table,
1278 .usb_driver = &iuu_driver,
1278 .num_ports = 1, 1279 .num_ports = 1,
1279 .bulk_in_size = 512, 1280 .bulk_in_size = 512,
1280 .bulk_out_size = 512, 1281 .bulk_out_size = 512,
diff --git a/drivers/usb/serial/keyspan.h b/drivers/usb/serial/keyspan.h
index 2d8baf6ac472..ce134dc28ddf 100644
--- a/drivers/usb/serial/keyspan.h
+++ b/drivers/usb/serial/keyspan.h
@@ -546,6 +546,7 @@ static struct usb_serial_driver keyspan_pre_device = {
546 .name = "keyspan_no_firm", 546 .name = "keyspan_no_firm",
547 }, 547 },
548 .description = "Keyspan - (without firmware)", 548 .description = "Keyspan - (without firmware)",
549 .usb_driver = &keyspan_driver,
549 .id_table = keyspan_pre_ids, 550 .id_table = keyspan_pre_ids,
550 .num_ports = 1, 551 .num_ports = 1,
551 .attach = keyspan_fake_startup, 552 .attach = keyspan_fake_startup,
@@ -557,6 +558,7 @@ static struct usb_serial_driver keyspan_1port_device = {
557 .name = "keyspan_1", 558 .name = "keyspan_1",
558 }, 559 },
559 .description = "Keyspan 1 port adapter", 560 .description = "Keyspan 1 port adapter",
561 .usb_driver = &keyspan_driver,
560 .id_table = keyspan_1port_ids, 562 .id_table = keyspan_1port_ids,
561 .num_ports = 1, 563 .num_ports = 1,
562 .open = keyspan_open, 564 .open = keyspan_open,
@@ -579,6 +581,7 @@ static struct usb_serial_driver keyspan_2port_device = {
579 .name = "keyspan_2", 581 .name = "keyspan_2",
580 }, 582 },
581 .description = "Keyspan 2 port adapter", 583 .description = "Keyspan 2 port adapter",
584 .usb_driver = &keyspan_driver,
582 .id_table = keyspan_2port_ids, 585 .id_table = keyspan_2port_ids,
583 .num_ports = 2, 586 .num_ports = 2,
584 .open = keyspan_open, 587 .open = keyspan_open,
@@ -601,6 +604,7 @@ static struct usb_serial_driver keyspan_4port_device = {
601 .name = "keyspan_4", 604 .name = "keyspan_4",
602 }, 605 },
603 .description = "Keyspan 4 port adapter", 606 .description = "Keyspan 4 port adapter",
607 .usb_driver = &keyspan_driver,
604 .id_table = keyspan_4port_ids, 608 .id_table = keyspan_4port_ids,
605 .num_ports = 4, 609 .num_ports = 4,
606 .open = keyspan_open, 610 .open = keyspan_open,
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index a10dd5676ccc..554a8693a463 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -679,22 +679,6 @@ static void keyspan_pda_dtr_rts(struct usb_serial_port *port, int on)
679 } 679 }
680} 680}
681 681
682static int keyspan_pda_carrier_raised(struct usb_serial_port *port)
683{
684 struct usb_serial *serial = port->serial;
685 unsigned char modembits;
686
687 /* If we can read the modem status and the DCD is low then
688 carrier is not raised yet */
689 if (keyspan_pda_get_modem_info(serial, &modembits) >= 0) {
690 if (!(modembits & (1>>6)))
691 return 0;
692 }
693 /* Carrier raised, or we failed (eg disconnected) so
694 progress accordingly */
695 return 1;
696}
697
698 682
699static int keyspan_pda_open(struct tty_struct *tty, 683static int keyspan_pda_open(struct tty_struct *tty,
700 struct usb_serial_port *port) 684 struct usb_serial_port *port)
@@ -881,7 +865,6 @@ static struct usb_serial_driver keyspan_pda_device = {
881 .id_table = id_table_std, 865 .id_table = id_table_std,
882 .num_ports = 1, 866 .num_ports = 1,
883 .dtr_rts = keyspan_pda_dtr_rts, 867 .dtr_rts = keyspan_pda_dtr_rts,
884 .carrier_raised = keyspan_pda_carrier_raised,
885 .open = keyspan_pda_open, 868 .open = keyspan_pda_open,
886 .close = keyspan_pda_close, 869 .close = keyspan_pda_close,
887 .write = keyspan_pda_write, 870 .write = keyspan_pda_write,
diff --git a/drivers/usb/serial/moto_modem.c b/drivers/usb/serial/moto_modem.c
index cf1718394e18..653465f61d4a 100644
--- a/drivers/usb/serial/moto_modem.c
+++ b/drivers/usb/serial/moto_modem.c
@@ -44,6 +44,7 @@ static struct usb_serial_driver moto_device = {
44 .name = "moto-modem", 44 .name = "moto-modem",
45 }, 45 },
46 .id_table = id_table, 46 .id_table = id_table,
47 .usb_driver = &moto_driver,
47 .num_ports = 1, 48 .num_ports = 1,
48}; 49};
49 50
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 748778288d94..5f46838dfee5 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -382,7 +382,16 @@ static void option_instat_callback(struct urb *urb);
382#define HAIER_VENDOR_ID 0x201e 382#define HAIER_VENDOR_ID 0x201e
383#define HAIER_PRODUCT_CE100 0x2009 383#define HAIER_PRODUCT_CE100 0x2009
384 384
385#define CINTERION_VENDOR_ID 0x0681 385/* Cinterion (formerly Siemens) products */
386#define SIEMENS_VENDOR_ID 0x0681
387#define CINTERION_VENDOR_ID 0x1e2d
388#define CINTERION_PRODUCT_HC25_MDM 0x0047
389#define CINTERION_PRODUCT_HC25_MDMNET 0x0040
390#define CINTERION_PRODUCT_HC28_MDM 0x004C
391#define CINTERION_PRODUCT_HC28_MDMNET 0x004A /* same for HC28J */
392#define CINTERION_PRODUCT_EU3_E 0x0051
393#define CINTERION_PRODUCT_EU3_P 0x0052
394#define CINTERION_PRODUCT_PH8 0x0053
386 395
387/* Olivetti products */ 396/* Olivetti products */
388#define OLIVETTI_VENDOR_ID 0x0b3c 397#define OLIVETTI_VENDOR_ID 0x0b3c
@@ -944,7 +953,17 @@ static const struct usb_device_id option_ids[] = {
944 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100F) }, 953 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100F) },
945 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1011)}, 954 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1011)},
946 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1012)}, 955 { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1012)},
947 { USB_DEVICE(CINTERION_VENDOR_ID, 0x0047) }, 956 /* Cinterion */
957 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_EU3_E) },
958 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_EU3_P) },
959 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PH8) },
960 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDM) },
961 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDMNET) },
962 { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC25_MDM) },
963 { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC25_MDMNET) },
964 { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC28_MDM) }, /* HC28 enumerates with Siemens or Cinterion VID depending on FW revision */
965 { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC28_MDMNET) },
966
948 { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD100) }, 967 { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD100) },
949 { USB_DEVICE(CELOT_VENDOR_ID, CELOT_PRODUCT_CT680M) }, /* CT-650 CDMA 450 1xEVDO modem */ 968 { USB_DEVICE(CELOT_VENDOR_ID, CELOT_PRODUCT_CT680M) }, /* CT-650 CDMA 450 1xEVDO modem */
950 { USB_DEVICE(ONDA_VENDOR_ID, ONDA_MT825UP) }, /* ONDA MT825UP modem */ 969 { USB_DEVICE(ONDA_VENDOR_ID, ONDA_MT825UP) }, /* ONDA MT825UP modem */
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c
index 5be866bb7a41..73613205be7a 100644
--- a/drivers/usb/serial/oti6858.c
+++ b/drivers/usb/serial/oti6858.c
@@ -157,6 +157,7 @@ static struct usb_serial_driver oti6858_device = {
157 .name = "oti6858", 157 .name = "oti6858",
158 }, 158 },
159 .id_table = id_table, 159 .id_table = id_table,
160 .usb_driver = &oti6858_driver,
160 .num_ports = 1, 161 .num_ports = 1,
161 .open = oti6858_open, 162 .open = oti6858_open,
162 .close = oti6858_close, 163 .close = oti6858_close,
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 8ae4c6cbc38a..08c9181b8e48 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -50,6 +50,7 @@ static const struct usb_device_id id_table[] = {
50 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_MMX) }, 50 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_MMX) },
51 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_GPRS) }, 51 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_GPRS) },
52 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_HCR331) }, 52 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_HCR331) },
53 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_MOTOROLA) },
53 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) }, 54 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) },
54 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) }, 55 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) },
55 { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) }, 56 { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) },
@@ -677,9 +678,11 @@ static void pl2303_update_line_status(struct usb_serial_port *port,
677{ 678{
678 679
679 struct pl2303_private *priv = usb_get_serial_port_data(port); 680 struct pl2303_private *priv = usb_get_serial_port_data(port);
681 struct tty_struct *tty;
680 unsigned long flags; 682 unsigned long flags;
681 u8 status_idx = UART_STATE; 683 u8 status_idx = UART_STATE;
682 u8 length = UART_STATE + 1; 684 u8 length = UART_STATE + 1;
685 u8 prev_line_status;
683 u16 idv, idp; 686 u16 idv, idp;
684 687
685 idv = le16_to_cpu(port->serial->dev->descriptor.idVendor); 688 idv = le16_to_cpu(port->serial->dev->descriptor.idVendor);
@@ -701,11 +704,20 @@ static void pl2303_update_line_status(struct usb_serial_port *port,
701 704
702 /* Save off the uart status for others to look at */ 705 /* Save off the uart status for others to look at */
703 spin_lock_irqsave(&priv->lock, flags); 706 spin_lock_irqsave(&priv->lock, flags);
707 prev_line_status = priv->line_status;
704 priv->line_status = data[status_idx]; 708 priv->line_status = data[status_idx];
705 spin_unlock_irqrestore(&priv->lock, flags); 709 spin_unlock_irqrestore(&priv->lock, flags);
706 if (priv->line_status & UART_BREAK_ERROR) 710 if (priv->line_status & UART_BREAK_ERROR)
707 usb_serial_handle_break(port); 711 usb_serial_handle_break(port);
708 wake_up_interruptible(&priv->delta_msr_wait); 712 wake_up_interruptible(&priv->delta_msr_wait);
713
714 tty = tty_port_tty_get(&port->port);
715 if (!tty)
716 return;
717 if ((priv->line_status ^ prev_line_status) & UART_DCD)
718 usb_serial_handle_dcd_change(port, tty,
719 priv->line_status & UART_DCD);
720 tty_kref_put(tty);
709} 721}
710 722
711static void pl2303_read_int_callback(struct urb *urb) 723static void pl2303_read_int_callback(struct urb *urb)
diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h
index 43eb9bdad422..1b025f75dafd 100644
--- a/drivers/usb/serial/pl2303.h
+++ b/drivers/usb/serial/pl2303.h
@@ -21,6 +21,7 @@
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#define PL2303_PRODUCT_ID_HCR331 0x331a
24#define PL2303_PRODUCT_ID_MOTOROLA 0x0307
24 25
25#define ATEN_VENDOR_ID 0x0557 26#define ATEN_VENDOR_ID 0x0557
26#define ATEN_VENDOR_ID2 0x0547 27#define ATEN_VENDOR_ID2 0x0547
diff --git a/drivers/usb/serial/qcaux.c b/drivers/usb/serial/qcaux.c
index 214a3e504292..30b73e68a904 100644
--- a/drivers/usb/serial/qcaux.c
+++ b/drivers/usb/serial/qcaux.c
@@ -36,6 +36,7 @@
36#define UTSTARCOM_PRODUCT_UM175_V1 0x3712 36#define UTSTARCOM_PRODUCT_UM175_V1 0x3712
37#define UTSTARCOM_PRODUCT_UM175_V2 0x3714 37#define UTSTARCOM_PRODUCT_UM175_V2 0x3714
38#define UTSTARCOM_PRODUCT_UM175_ALLTEL 0x3715 38#define UTSTARCOM_PRODUCT_UM175_ALLTEL 0x3715
39#define PANTECH_PRODUCT_UML290_VZW 0x3718
39 40
40/* CMOTECH devices */ 41/* CMOTECH devices */
41#define CMOTECH_VENDOR_ID 0x16d8 42#define CMOTECH_VENDOR_ID 0x16d8
@@ -66,6 +67,7 @@ static struct usb_device_id id_table[] = {
66 { USB_DEVICE_AND_INTERFACE_INFO(LG_VENDOR_ID, LG_PRODUCT_VX4400_6000, 0xff, 0xff, 0x00) }, 67 { USB_DEVICE_AND_INTERFACE_INFO(LG_VENDOR_ID, LG_PRODUCT_VX4400_6000, 0xff, 0xff, 0x00) },
67 { USB_DEVICE_AND_INTERFACE_INFO(SANYO_VENDOR_ID, SANYO_PRODUCT_KATANA_LX, 0xff, 0xff, 0x00) }, 68 { USB_DEVICE_AND_INTERFACE_INFO(SANYO_VENDOR_ID, SANYO_PRODUCT_KATANA_LX, 0xff, 0xff, 0x00) },
68 { USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_U520, 0xff, 0x00, 0x00) }, 69 { USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_U520, 0xff, 0x00, 0x00) },
70 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML290_VZW, 0xff, 0xff, 0xff) },
69 { }, 71 { },
70}; 72};
71MODULE_DEVICE_TABLE(usb, id_table); 73MODULE_DEVICE_TABLE(usb, id_table);
@@ -84,6 +86,7 @@ static struct usb_serial_driver qcaux_device = {
84 .name = "qcaux", 86 .name = "qcaux",
85 }, 87 },
86 .id_table = id_table, 88 .id_table = id_table,
89 .usb_driver = &qcaux_driver,
87 .num_ports = 1, 90 .num_ports = 1,
88}; 91};
89 92
diff --git a/drivers/usb/serial/siemens_mpi.c b/drivers/usb/serial/siemens_mpi.c
index cb8195cabfde..74cd4ccdb3fc 100644
--- a/drivers/usb/serial/siemens_mpi.c
+++ b/drivers/usb/serial/siemens_mpi.c
@@ -42,6 +42,7 @@ static struct usb_serial_driver siemens_usb_mpi_device = {
42 .name = "siemens_mpi", 42 .name = "siemens_mpi",
43 }, 43 },
44 .id_table = id_table, 44 .id_table = id_table,
45 .usb_driver = &siemens_usb_mpi_driver,
45 .num_ports = 1, 46 .num_ports = 1,
46}; 47};
47 48
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c
index 765aa983bf58..cbfb70bffdd0 100644
--- a/drivers/usb/serial/spcp8x5.c
+++ b/drivers/usb/serial/spcp8x5.c
@@ -133,7 +133,7 @@ struct spcp8x5_usb_ctrl_arg {
133 133
134/* how come ??? */ 134/* how come ??? */
135#define UART_STATE 0x08 135#define UART_STATE 0x08
136#define UART_STATE_TRANSIENT_MASK 0x74 136#define UART_STATE_TRANSIENT_MASK 0x75
137#define UART_DCD 0x01 137#define UART_DCD 0x01
138#define UART_DSR 0x02 138#define UART_DSR 0x02
139#define UART_BREAK_ERROR 0x04 139#define UART_BREAK_ERROR 0x04
@@ -525,6 +525,10 @@ static void spcp8x5_process_read_urb(struct urb *urb)
525 /* overrun is special, not associated with a char */ 525 /* overrun is special, not associated with a char */
526 if (status & UART_OVERRUN_ERROR) 526 if (status & UART_OVERRUN_ERROR)
527 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 527 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
528
529 if (status & UART_DCD)
530 usb_serial_handle_dcd_change(port, tty,
531 priv->line_status & MSR_STATUS_LINE_DCD);
528 } 532 }
529 533
530 tty_insert_flip_string_fixed_flag(tty, data, tty_flag, 534 tty_insert_flip_string_fixed_flag(tty, data, tty_flag,
@@ -645,6 +649,7 @@ static struct usb_serial_driver spcp8x5_device = {
645 .name = "SPCP8x5", 649 .name = "SPCP8x5",
646 }, 650 },
647 .id_table = id_table, 651 .id_table = id_table,
652 .usb_driver = &spcp8x5_driver,
648 .num_ports = 1, 653 .num_ports = 1,
649 .open = spcp8x5_open, 654 .open = spcp8x5_open,
650 .dtr_rts = spcp8x5_dtr_rts, 655 .dtr_rts = spcp8x5_dtr_rts,
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 6954de50c0ff..546a52179bec 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -1344,11 +1344,15 @@ int usb_serial_register(struct usb_serial_driver *driver)
1344 return -ENODEV; 1344 return -ENODEV;
1345 1345
1346 fixup_generic(driver); 1346 fixup_generic(driver);
1347 if (driver->usb_driver)
1348 driver->usb_driver->supports_autosuspend = 1;
1349 1347
1350 if (!driver->description) 1348 if (!driver->description)
1351 driver->description = driver->driver.name; 1349 driver->description = driver->driver.name;
1350 if (!driver->usb_driver) {
1351 WARN(1, "Serial driver %s has no usb_driver\n",
1352 driver->description);
1353 return -EINVAL;
1354 }
1355 driver->usb_driver->supports_autosuspend = 1;
1352 1356
1353 /* Add this device to our list of devices */ 1357 /* Add this device to our list of devices */
1354 mutex_lock(&table_lock); 1358 mutex_lock(&table_lock);
diff --git a/drivers/usb/serial/usb_debug.c b/drivers/usb/serial/usb_debug.c
index f2ed6a31be77..95a82148ee81 100644
--- a/drivers/usb/serial/usb_debug.c
+++ b/drivers/usb/serial/usb_debug.c
@@ -75,6 +75,7 @@ static struct usb_serial_driver debug_device = {
75 .name = "debug", 75 .name = "debug",
76 }, 76 },
77 .id_table = id_table, 77 .id_table = id_table,
78 .usb_driver = &debug_driver,
78 .num_ports = 1, 79 .num_ports = 1,
79 .bulk_out_size = USB_DEBUG_MAX_PACKET_SIZE, 80 .bulk_out_size = USB_DEBUG_MAX_PACKET_SIZE,
80 .break_ctl = usb_debug_break_ctl, 81 .break_ctl = usb_debug_break_ctl,
diff --git a/drivers/usb/storage/unusual_cypress.h b/drivers/usb/storage/unusual_cypress.h
index c854fdebe0ae..2c8553026222 100644
--- a/drivers/usb/storage/unusual_cypress.h
+++ b/drivers/usb/storage/unusual_cypress.h
@@ -31,4 +31,9 @@ UNUSUAL_DEV( 0x04b4, 0x6831, 0x0000, 0x9999,
31 "Cypress ISD-300LP", 31 "Cypress ISD-300LP",
32 USB_SC_CYP_ATACB, USB_PR_DEVICE, NULL, 0), 32 USB_SC_CYP_ATACB, USB_PR_DEVICE, NULL, 0),
33 33
34UNUSUAL_DEV( 0x14cd, 0x6116, 0x0000, 0x9999,
35 "Super Top",
36 "USB 2.0 SATA BRIDGE",
37 USB_SC_CYP_ATACB, USB_PR_DEVICE, NULL, 0),
38
34#endif /* defined(CONFIG_USB_STORAGE_CYPRESS_ATACB) || ... */ 39#endif /* defined(CONFIG_USB_STORAGE_CYPRESS_ATACB) || ... */
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index fcc1e32ce256..24bd5d7c3deb 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -1044,6 +1044,15 @@ UNUSUAL_DEV( 0x084d, 0x0011, 0x0110, 0x0110,
1044 USB_SC_DEVICE, USB_PR_DEVICE, NULL, 1044 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1045 US_FL_BULK32), 1045 US_FL_BULK32),
1046 1046
1047/* Reported by <ttkspam@free.fr>
1048 * The device reports a vendor-specific device class, requiring an
1049 * explicit vendor/product match.
1050 */
1051UNUSUAL_DEV( 0x0851, 0x1542, 0x0002, 0x0002,
1052 "MagicPixel",
1053 "FW_Omega2",
1054 USB_SC_DEVICE, USB_PR_DEVICE, NULL, 0),
1055
1047/* Andrew Lunn <andrew@lunn.ch> 1056/* Andrew Lunn <andrew@lunn.ch>
1048 * PanDigital Digital Picture Frame. Does not like ALLOW_MEDIUM_REMOVAL 1057 * PanDigital Digital Picture Frame. Does not like ALLOW_MEDIUM_REMOVAL
1049 * on LUN 4. 1058 * on LUN 4.
@@ -1872,6 +1881,15 @@ UNUSUAL_DEV( 0x1908, 0x3335, 0x0200, 0x0200,
1872 USB_SC_DEVICE, USB_PR_DEVICE, NULL, 1881 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1873 US_FL_NO_READ_DISC_INFO ), 1882 US_FL_NO_READ_DISC_INFO ),
1874 1883
1884/* Patch by Richard Schütz <r.schtz@t-online.de>
1885 * This external hard drive enclosure uses a JMicron chip which
1886 * needs the US_FL_IGNORE_RESIDUE flag to work properly. */
1887UNUSUAL_DEV( 0x1e68, 0x001b, 0x0000, 0x0000,
1888 "TrekStor GmbH & Co. KG",
1889 "DataStation maxi g.u",
1890 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1891 US_FL_IGNORE_RESIDUE | US_FL_SANE_SENSE ),
1892
1875UNUSUAL_DEV( 0x2116, 0x0320, 0x0001, 0x0001, 1893UNUSUAL_DEV( 0x2116, 0x0320, 0x0001, 0x0001,
1876 "ST", 1894 "ST",
1877 "2A", 1895 "2A",
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index d916ac04abab..6bafb51bb437 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -1227,7 +1227,7 @@ config FB_CARILLO_RANCH
1227 1227
1228config FB_INTEL 1228config FB_INTEL
1229 tristate "Intel 830M/845G/852GM/855GM/865G/915G/945G/945GM/965G/965GM support (EXPERIMENTAL)" 1229 tristate "Intel 830M/845G/852GM/855GM/865G/915G/945G/945GM/965G/965GM support (EXPERIMENTAL)"
1230 depends on EXPERIMENTAL && FB && PCI && X86 && AGP_INTEL && EMBEDDED 1230 depends on EXPERIMENTAL && FB && PCI && X86 && AGP_INTEL && EXPERT
1231 select FB_MODE_HELPERS 1231 select FB_MODE_HELPERS
1232 select FB_CFB_FILLRECT 1232 select FB_CFB_FILLRECT
1233 select FB_CFB_COPYAREA 1233 select FB_CFB_COPYAREA
diff --git a/drivers/video/arkfb.c b/drivers/video/arkfb.c
index d583bea608fd..391ac939f011 100644
--- a/drivers/video/arkfb.c
+++ b/drivers/video/arkfb.c
@@ -23,7 +23,7 @@
23#include <linux/svga.h> 23#include <linux/svga.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/pci.h> 25#include <linux/pci.h>
26#include <linux/console.h> /* Why should fb driver call console functions? because acquire_console_sem() */ 26#include <linux/console.h> /* Why should fb driver call console functions? because console_lock() */
27#include <video/vga.h> 27#include <video/vga.h>
28 28
29#ifdef CONFIG_MTRR 29#ifdef CONFIG_MTRR
@@ -1091,12 +1091,12 @@ static int ark_pci_suspend (struct pci_dev* dev, pm_message_t state)
1091 1091
1092 dev_info(info->device, "suspend\n"); 1092 dev_info(info->device, "suspend\n");
1093 1093
1094 acquire_console_sem(); 1094 console_lock();
1095 mutex_lock(&(par->open_lock)); 1095 mutex_lock(&(par->open_lock));
1096 1096
1097 if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) { 1097 if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) {
1098 mutex_unlock(&(par->open_lock)); 1098 mutex_unlock(&(par->open_lock));
1099 release_console_sem(); 1099 console_unlock();
1100 return 0; 1100 return 0;
1101 } 1101 }
1102 1102
@@ -1107,7 +1107,7 @@ static int ark_pci_suspend (struct pci_dev* dev, pm_message_t state)
1107 pci_set_power_state(dev, pci_choose_state(dev, state)); 1107 pci_set_power_state(dev, pci_choose_state(dev, state));
1108 1108
1109 mutex_unlock(&(par->open_lock)); 1109 mutex_unlock(&(par->open_lock));
1110 release_console_sem(); 1110 console_unlock();
1111 1111
1112 return 0; 1112 return 0;
1113} 1113}
@@ -1122,7 +1122,7 @@ static int ark_pci_resume (struct pci_dev* dev)
1122 1122
1123 dev_info(info->device, "resume\n"); 1123 dev_info(info->device, "resume\n");
1124 1124
1125 acquire_console_sem(); 1125 console_lock();
1126 mutex_lock(&(par->open_lock)); 1126 mutex_lock(&(par->open_lock));
1127 1127
1128 if (par->ref_count == 0) 1128 if (par->ref_count == 0)
@@ -1141,7 +1141,7 @@ static int ark_pci_resume (struct pci_dev* dev)
1141 1141
1142fail: 1142fail:
1143 mutex_unlock(&(par->open_lock)); 1143 mutex_unlock(&(par->open_lock));
1144 release_console_sem(); 1144 console_unlock();
1145 return 0; 1145 return 0;
1146} 1146}
1147#else 1147#else
diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
index dd9de2e80580..4cb6a576c567 100644
--- a/drivers/video/aty/aty128fb.c
+++ b/drivers/video/aty/aty128fb.c
@@ -1860,11 +1860,11 @@ static void aty128_early_resume(void *data)
1860{ 1860{
1861 struct aty128fb_par *par = data; 1861 struct aty128fb_par *par = data;
1862 1862
1863 if (try_acquire_console_sem()) 1863 if (!console_trylock())
1864 return; 1864 return;
1865 pci_restore_state(par->pdev); 1865 pci_restore_state(par->pdev);
1866 aty128_do_resume(par->pdev); 1866 aty128_do_resume(par->pdev);
1867 release_console_sem(); 1867 console_unlock();
1868} 1868}
1869#endif /* CONFIG_PPC_PMAC */ 1869#endif /* CONFIG_PPC_PMAC */
1870 1870
@@ -2438,7 +2438,7 @@ static int aty128_pci_suspend(struct pci_dev *pdev, pm_message_t state)
2438 2438
2439 printk(KERN_DEBUG "aty128fb: suspending...\n"); 2439 printk(KERN_DEBUG "aty128fb: suspending...\n");
2440 2440
2441 acquire_console_sem(); 2441 console_lock();
2442 2442
2443 fb_set_suspend(info, 1); 2443 fb_set_suspend(info, 1);
2444 2444
@@ -2470,7 +2470,7 @@ static int aty128_pci_suspend(struct pci_dev *pdev, pm_message_t state)
2470 if (state.event != PM_EVENT_ON) 2470 if (state.event != PM_EVENT_ON)
2471 aty128_set_suspend(par, 1); 2471 aty128_set_suspend(par, 1);
2472 2472
2473 release_console_sem(); 2473 console_unlock();
2474 2474
2475 pdev->dev.power.power_state = state; 2475 pdev->dev.power.power_state = state;
2476 2476
@@ -2527,9 +2527,9 @@ static int aty128_pci_resume(struct pci_dev *pdev)
2527{ 2527{
2528 int rc; 2528 int rc;
2529 2529
2530 acquire_console_sem(); 2530 console_lock();
2531 rc = aty128_do_resume(pdev); 2531 rc = aty128_do_resume(pdev);
2532 release_console_sem(); 2532 console_unlock();
2533 2533
2534 return rc; 2534 return rc;
2535} 2535}
diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
index 767ab4fb1a05..94e293fce1d2 100644
--- a/drivers/video/aty/atyfb_base.c
+++ b/drivers/video/aty/atyfb_base.c
@@ -2069,7 +2069,7 @@ static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
2069 if (state.event == pdev->dev.power.power_state.event) 2069 if (state.event == pdev->dev.power.power_state.event)
2070 return 0; 2070 return 0;
2071 2071
2072 acquire_console_sem(); 2072 console_lock();
2073 2073
2074 fb_set_suspend(info, 1); 2074 fb_set_suspend(info, 1);
2075 2075
@@ -2097,14 +2097,14 @@ static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
2097 par->lock_blank = 0; 2097 par->lock_blank = 0;
2098 atyfb_blank(FB_BLANK_UNBLANK, info); 2098 atyfb_blank(FB_BLANK_UNBLANK, info);
2099 fb_set_suspend(info, 0); 2099 fb_set_suspend(info, 0);
2100 release_console_sem(); 2100 console_unlock();
2101 return -EIO; 2101 return -EIO;
2102 } 2102 }
2103#else 2103#else
2104 pci_set_power_state(pdev, pci_choose_state(pdev, state)); 2104 pci_set_power_state(pdev, pci_choose_state(pdev, state));
2105#endif 2105#endif
2106 2106
2107 release_console_sem(); 2107 console_unlock();
2108 2108
2109 pdev->dev.power.power_state = state; 2109 pdev->dev.power.power_state = state;
2110 2110
@@ -2133,7 +2133,7 @@ static int atyfb_pci_resume(struct pci_dev *pdev)
2133 if (pdev->dev.power.power_state.event == PM_EVENT_ON) 2133 if (pdev->dev.power.power_state.event == PM_EVENT_ON)
2134 return 0; 2134 return 0;
2135 2135
2136 acquire_console_sem(); 2136 console_lock();
2137 2137
2138 /* 2138 /*
2139 * PCI state will have been restored by the core, so 2139 * PCI state will have been restored by the core, so
@@ -2161,7 +2161,7 @@ static int atyfb_pci_resume(struct pci_dev *pdev)
2161 par->lock_blank = 0; 2161 par->lock_blank = 0;
2162 atyfb_blank(FB_BLANK_UNBLANK, info); 2162 atyfb_blank(FB_BLANK_UNBLANK, info);
2163 2163
2164 release_console_sem(); 2164 console_unlock();
2165 2165
2166 pdev->dev.power.power_state = PMSG_ON; 2166 pdev->dev.power.power_state = PMSG_ON;
2167 2167
diff --git a/drivers/video/aty/radeon_pm.c b/drivers/video/aty/radeon_pm.c
index c4e17642d9c5..92bda5848516 100644
--- a/drivers/video/aty/radeon_pm.c
+++ b/drivers/video/aty/radeon_pm.c
@@ -2626,7 +2626,7 @@ int radeonfb_pci_suspend(struct pci_dev *pdev, pm_message_t mesg)
2626 goto done; 2626 goto done;
2627 } 2627 }
2628 2628
2629 acquire_console_sem(); 2629 console_lock();
2630 2630
2631 fb_set_suspend(info, 1); 2631 fb_set_suspend(info, 1);
2632 2632
@@ -2690,7 +2690,7 @@ int radeonfb_pci_suspend(struct pci_dev *pdev, pm_message_t mesg)
2690 if (rinfo->pm_mode & radeon_pm_d2) 2690 if (rinfo->pm_mode & radeon_pm_d2)
2691 radeon_set_suspend(rinfo, 1); 2691 radeon_set_suspend(rinfo, 1);
2692 2692
2693 release_console_sem(); 2693 console_unlock();
2694 2694
2695 done: 2695 done:
2696 pdev->dev.power.power_state = mesg; 2696 pdev->dev.power.power_state = mesg;
@@ -2715,10 +2715,10 @@ int radeonfb_pci_resume(struct pci_dev *pdev)
2715 return 0; 2715 return 0;
2716 2716
2717 if (rinfo->no_schedule) { 2717 if (rinfo->no_schedule) {
2718 if (try_acquire_console_sem()) 2718 if (!console_trylock())
2719 return 0; 2719 return 0;
2720 } else 2720 } else
2721 acquire_console_sem(); 2721 console_lock();
2722 2722
2723 printk(KERN_DEBUG "radeonfb (%s): resuming from state: %d...\n", 2723 printk(KERN_DEBUG "radeonfb (%s): resuming from state: %d...\n",
2724 pci_name(pdev), pdev->dev.power.power_state.event); 2724 pci_name(pdev), pdev->dev.power.power_state.event);
@@ -2783,7 +2783,7 @@ int radeonfb_pci_resume(struct pci_dev *pdev)
2783 pdev->dev.power.power_state = PMSG_ON; 2783 pdev->dev.power.power_state = PMSG_ON;
2784 2784
2785 bail: 2785 bail:
2786 release_console_sem(); 2786 console_unlock();
2787 2787
2788 return rc; 2788 return rc;
2789} 2789}
diff --git a/drivers/video/backlight/88pm860x_bl.c b/drivers/video/backlight/88pm860x_bl.c
index c789c46e38af..b224396b86d5 100644
--- a/drivers/video/backlight/88pm860x_bl.c
+++ b/drivers/video/backlight/88pm860x_bl.c
@@ -21,7 +21,7 @@
21#define MAX_BRIGHTNESS (0xFF) 21#define MAX_BRIGHTNESS (0xFF)
22#define MIN_BRIGHTNESS (0) 22#define MIN_BRIGHTNESS (0)
23 23
24#define CURRENT_MASK (0x1F << 1) 24#define CURRENT_BITMASK (0x1F << 1)
25 25
26struct pm860x_backlight_data { 26struct pm860x_backlight_data {
27 struct pm860x_chip *chip; 27 struct pm860x_chip *chip;
@@ -85,7 +85,7 @@ static int pm860x_backlight_set(struct backlight_device *bl, int brightness)
85 if ((data->current_brightness == 0) && brightness) { 85 if ((data->current_brightness == 0) && brightness) {
86 if (data->iset) { 86 if (data->iset) {
87 ret = pm860x_set_bits(data->i2c, wled_idc(data->port), 87 ret = pm860x_set_bits(data->i2c, wled_idc(data->port),
88 CURRENT_MASK, data->iset); 88 CURRENT_BITMASK, data->iset);
89 if (ret < 0) 89 if (ret < 0)
90 goto out; 90 goto out;
91 } 91 }
diff --git a/drivers/video/bf537-lq035.c b/drivers/video/bf537-lq035.c
index 18c507874ff1..47c21fb2c82f 100644
--- a/drivers/video/bf537-lq035.c
+++ b/drivers/video/bf537-lq035.c
@@ -696,6 +696,7 @@ static int __devinit bfin_lq035_probe(struct platform_device *pdev)
696{ 696{
697 struct backlight_properties props; 697 struct backlight_properties props;
698 dma_addr_t dma_handle; 698 dma_addr_t dma_handle;
699 int ret;
699 700
700 if (request_dma(CH_PPI, KBUILD_MODNAME)) { 701 if (request_dma(CH_PPI, KBUILD_MODNAME)) {
701 pr_err("couldn't request PPI DMA\n"); 702 pr_err("couldn't request PPI DMA\n");
@@ -704,17 +705,16 @@ static int __devinit bfin_lq035_probe(struct platform_device *pdev)
704 705
705 if (request_ports()) { 706 if (request_ports()) {
706 pr_err("couldn't request gpio port\n"); 707 pr_err("couldn't request gpio port\n");
707 free_dma(CH_PPI); 708 ret = -EFAULT;
708 return -EFAULT; 709 goto out_ports;
709 } 710 }
710 711
711 fb_buffer = dma_alloc_coherent(NULL, TOTAL_VIDEO_MEM_SIZE, 712 fb_buffer = dma_alloc_coherent(NULL, TOTAL_VIDEO_MEM_SIZE,
712 &dma_handle, GFP_KERNEL); 713 &dma_handle, GFP_KERNEL);
713 if (fb_buffer == NULL) { 714 if (fb_buffer == NULL) {
714 pr_err("couldn't allocate dma buffer\n"); 715 pr_err("couldn't allocate dma buffer\n");
715 free_dma(CH_PPI); 716 ret = -ENOMEM;
716 free_ports(); 717 goto out_dma_coherent;
717 return -ENOMEM;
718 } 718 }
719 719
720 if (L1_DATA_A_LENGTH) 720 if (L1_DATA_A_LENGTH)
@@ -725,10 +725,8 @@ static int __devinit bfin_lq035_probe(struct platform_device *pdev)
725 725
726 if (dma_desc_table == NULL) { 726 if (dma_desc_table == NULL) {
727 pr_err("couldn't allocate dma descriptor\n"); 727 pr_err("couldn't allocate dma descriptor\n");
728 free_dma(CH_PPI); 728 ret = -ENOMEM;
729 free_ports(); 729 goto out_table;
730 dma_free_coherent(NULL, TOTAL_VIDEO_MEM_SIZE, fb_buffer, 0);
731 return -ENOMEM;
732 } 730 }
733 731
734 bfin_lq035_fb.screen_base = (void *)fb_buffer; 732 bfin_lq035_fb.screen_base = (void *)fb_buffer;
@@ -771,31 +769,21 @@ static int __devinit bfin_lq035_probe(struct platform_device *pdev)
771 bfin_lq035_fb.pseudo_palette = kzalloc(sizeof(u32) * 16, GFP_KERNEL); 769 bfin_lq035_fb.pseudo_palette = kzalloc(sizeof(u32) * 16, GFP_KERNEL);
772 if (bfin_lq035_fb.pseudo_palette == NULL) { 770 if (bfin_lq035_fb.pseudo_palette == NULL) {
773 pr_err("failed to allocate pseudo_palette\n"); 771 pr_err("failed to allocate pseudo_palette\n");
774 free_dma(CH_PPI); 772 ret = -ENOMEM;
775 free_ports(); 773 goto out_palette;
776 dma_free_coherent(NULL, TOTAL_VIDEO_MEM_SIZE, fb_buffer, 0);
777 return -ENOMEM;
778 } 774 }
779 775
780 if (fb_alloc_cmap(&bfin_lq035_fb.cmap, NBR_PALETTE, 0) < 0) { 776 if (fb_alloc_cmap(&bfin_lq035_fb.cmap, NBR_PALETTE, 0) < 0) {
781 pr_err("failed to allocate colormap (%d entries)\n", 777 pr_err("failed to allocate colormap (%d entries)\n",
782 NBR_PALETTE); 778 NBR_PALETTE);
783 free_dma(CH_PPI); 779 ret = -EFAULT;
784 free_ports(); 780 goto out_cmap;
785 dma_free_coherent(NULL, TOTAL_VIDEO_MEM_SIZE, fb_buffer, 0);
786 kfree(bfin_lq035_fb.pseudo_palette);
787 return -EFAULT;
788 } 781 }
789 782
790 if (register_framebuffer(&bfin_lq035_fb) < 0) { 783 if (register_framebuffer(&bfin_lq035_fb) < 0) {
791 pr_err("unable to register framebuffer\n"); 784 pr_err("unable to register framebuffer\n");
792 free_dma(CH_PPI); 785 ret = -EINVAL;
793 free_ports(); 786 goto out_reg;
794 dma_free_coherent(NULL, TOTAL_VIDEO_MEM_SIZE, fb_buffer, 0);
795 fb_buffer = NULL;
796 kfree(bfin_lq035_fb.pseudo_palette);
797 fb_dealloc_cmap(&bfin_lq035_fb.cmap);
798 return -EINVAL;
799 } 787 }
800 788
801 i2c_add_driver(&ad5280_driver); 789 i2c_add_driver(&ad5280_driver);
@@ -807,11 +795,31 @@ static int __devinit bfin_lq035_probe(struct platform_device *pdev)
807 795
808 lcd_dev = lcd_device_register(KBUILD_MODNAME, &pdev->dev, NULL, 796 lcd_dev = lcd_device_register(KBUILD_MODNAME, &pdev->dev, NULL,
809 &bfin_lcd_ops); 797 &bfin_lcd_ops);
798 if (IS_ERR(lcd_dev)) {
799 pr_err("unable to register lcd\n");
800 ret = PTR_ERR(lcd_dev);
801 goto out_lcd;
802 }
810 lcd_dev->props.max_contrast = 255, 803 lcd_dev->props.max_contrast = 255,
811 804
812 pr_info("initialized"); 805 pr_info("initialized");
813 806
814 return 0; 807 return 0;
808out_lcd:
809 unregister_framebuffer(&bfin_lq035_fb);
810out_reg:
811 fb_dealloc_cmap(&bfin_lq035_fb.cmap);
812out_cmap:
813 kfree(bfin_lq035_fb.pseudo_palette);
814out_palette:
815out_table:
816 dma_free_coherent(NULL, TOTAL_VIDEO_MEM_SIZE, fb_buffer, 0);
817 fb_buffer = NULL;
818out_dma_coherent:
819 free_ports();
820out_ports:
821 free_dma(CH_PPI);
822 return ret;
815} 823}
816 824
817static int __devexit bfin_lq035_remove(struct platform_device *pdev) 825static int __devexit bfin_lq035_remove(struct platform_device *pdev)
diff --git a/drivers/video/chipsfb.c b/drivers/video/chipsfb.c
index d637e1f53172..cff742abdc5d 100644
--- a/drivers/video/chipsfb.c
+++ b/drivers/video/chipsfb.c
@@ -460,10 +460,10 @@ static int chipsfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
460 if (!(state.event & PM_EVENT_SLEEP)) 460 if (!(state.event & PM_EVENT_SLEEP))
461 goto done; 461 goto done;
462 462
463 acquire_console_sem(); 463 console_lock();
464 chipsfb_blank(1, p); 464 chipsfb_blank(1, p);
465 fb_set_suspend(p, 1); 465 fb_set_suspend(p, 1);
466 release_console_sem(); 466 console_unlock();
467 done: 467 done:
468 pdev->dev.power.power_state = state; 468 pdev->dev.power.power_state = state;
469 return 0; 469 return 0;
@@ -473,10 +473,10 @@ static int chipsfb_pci_resume(struct pci_dev *pdev)
473{ 473{
474 struct fb_info *p = pci_get_drvdata(pdev); 474 struct fb_info *p = pci_get_drvdata(pdev);
475 475
476 acquire_console_sem(); 476 console_lock();
477 fb_set_suspend(p, 0); 477 fb_set_suspend(p, 0);
478 chipsfb_blank(0, p); 478 chipsfb_blank(0, p);
479 release_console_sem(); 479 console_unlock();
480 480
481 pdev->dev.power.power_state = PMSG_ON; 481 pdev->dev.power.power_state = PMSG_ON;
482 return 0; 482 return 0;
diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig
index 5a35f22372b9..2209e354f531 100644
--- a/drivers/video/console/Kconfig
+++ b/drivers/video/console/Kconfig
@@ -5,7 +5,7 @@
5menu "Console display driver support" 5menu "Console display driver support"
6 6
7config VGA_CONSOLE 7config VGA_CONSOLE
8 bool "VGA text console" if EMBEDDED || !X86 8 bool "VGA text console" if EXPERT || !X86
9 depends on !4xx && !8xx && !SPARC && !M68K && !PARISC && !FRV && !SUPERH && !BLACKFIN && !AVR32 && !MN10300 && (!ARM || ARCH_FOOTBRIDGE || ARCH_INTEGRATOR || ARCH_NETWINDER) 9 depends on !4xx && !8xx && !SPARC && !M68K && !PARISC && !FRV && !SUPERH && !BLACKFIN && !AVR32 && !MN10300 && (!ARM || ARCH_FOOTBRIDGE || ARCH_INTEGRATOR || ARCH_NETWINDER)
10 default y 10 default y
11 help 11 help
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 7ccc967831f0..9c092b8d64e6 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -375,14 +375,14 @@ static void fb_flashcursor(struct work_struct *work)
375 int c; 375 int c;
376 int mode; 376 int mode;
377 377
378 acquire_console_sem(); 378 console_lock();
379 if (ops && ops->currcon != -1) 379 if (ops && ops->currcon != -1)
380 vc = vc_cons[ops->currcon].d; 380 vc = vc_cons[ops->currcon].d;
381 381
382 if (!vc || !CON_IS_VISIBLE(vc) || 382 if (!vc || !CON_IS_VISIBLE(vc) ||
383 registered_fb[con2fb_map[vc->vc_num]] != info || 383 registered_fb[con2fb_map[vc->vc_num]] != info ||
384 vc->vc_deccm != 1) { 384 vc->vc_deccm != 1) {
385 release_console_sem(); 385 console_unlock();
386 return; 386 return;
387 } 387 }
388 388
@@ -392,7 +392,7 @@ static void fb_flashcursor(struct work_struct *work)
392 CM_ERASE : CM_DRAW; 392 CM_ERASE : CM_DRAW;
393 ops->cursor(vc, info, mode, softback_lines, get_color(vc, info, c, 1), 393 ops->cursor(vc, info, mode, softback_lines, get_color(vc, info, c, 1),
394 get_color(vc, info, c, 0)); 394 get_color(vc, info, c, 0));
395 release_console_sem(); 395 console_unlock();
396} 396}
397 397
398static void cursor_timer_handler(unsigned long dev_addr) 398static void cursor_timer_handler(unsigned long dev_addr)
@@ -836,7 +836,7 @@ static int set_con2fb_map(int unit, int newidx, int user)
836 836
837 found = search_fb_in_map(newidx); 837 found = search_fb_in_map(newidx);
838 838
839 acquire_console_sem(); 839 console_lock();
840 con2fb_map[unit] = newidx; 840 con2fb_map[unit] = newidx;
841 if (!err && !found) 841 if (!err && !found)
842 err = con2fb_acquire_newinfo(vc, info, unit, oldidx); 842 err = con2fb_acquire_newinfo(vc, info, unit, oldidx);
@@ -863,7 +863,7 @@ static int set_con2fb_map(int unit, int newidx, int user)
863 if (!search_fb_in_map(info_idx)) 863 if (!search_fb_in_map(info_idx))
864 info_idx = newidx; 864 info_idx = newidx;
865 865
866 release_console_sem(); 866 console_unlock();
867 return err; 867 return err;
868} 868}
869 869
@@ -3321,7 +3321,7 @@ static ssize_t store_rotate(struct device *device,
3321 if (fbcon_has_exited) 3321 if (fbcon_has_exited)
3322 return count; 3322 return count;
3323 3323
3324 acquire_console_sem(); 3324 console_lock();
3325 idx = con2fb_map[fg_console]; 3325 idx = con2fb_map[fg_console];
3326 3326
3327 if (idx == -1 || registered_fb[idx] == NULL) 3327 if (idx == -1 || registered_fb[idx] == NULL)
@@ -3331,7 +3331,7 @@ static ssize_t store_rotate(struct device *device,
3331 rotate = simple_strtoul(buf, last, 0); 3331 rotate = simple_strtoul(buf, last, 0);
3332 fbcon_rotate(info, rotate); 3332 fbcon_rotate(info, rotate);
3333err: 3333err:
3334 release_console_sem(); 3334 console_unlock();
3335 return count; 3335 return count;
3336} 3336}
3337 3337
@@ -3346,7 +3346,7 @@ static ssize_t store_rotate_all(struct device *device,
3346 if (fbcon_has_exited) 3346 if (fbcon_has_exited)
3347 return count; 3347 return count;
3348 3348
3349 acquire_console_sem(); 3349 console_lock();
3350 idx = con2fb_map[fg_console]; 3350 idx = con2fb_map[fg_console];
3351 3351
3352 if (idx == -1 || registered_fb[idx] == NULL) 3352 if (idx == -1 || registered_fb[idx] == NULL)
@@ -3356,7 +3356,7 @@ static ssize_t store_rotate_all(struct device *device,
3356 rotate = simple_strtoul(buf, last, 0); 3356 rotate = simple_strtoul(buf, last, 0);
3357 fbcon_rotate_all(info, rotate); 3357 fbcon_rotate_all(info, rotate);
3358err: 3358err:
3359 release_console_sem(); 3359 console_unlock();
3360 return count; 3360 return count;
3361} 3361}
3362 3362
@@ -3369,7 +3369,7 @@ static ssize_t show_rotate(struct device *device,
3369 if (fbcon_has_exited) 3369 if (fbcon_has_exited)
3370 return 0; 3370 return 0;
3371 3371
3372 acquire_console_sem(); 3372 console_lock();
3373 idx = con2fb_map[fg_console]; 3373 idx = con2fb_map[fg_console];
3374 3374
3375 if (idx == -1 || registered_fb[idx] == NULL) 3375 if (idx == -1 || registered_fb[idx] == NULL)
@@ -3378,7 +3378,7 @@ static ssize_t show_rotate(struct device *device,
3378 info = registered_fb[idx]; 3378 info = registered_fb[idx];
3379 rotate = fbcon_get_rotate(info); 3379 rotate = fbcon_get_rotate(info);
3380err: 3380err:
3381 release_console_sem(); 3381 console_unlock();
3382 return snprintf(buf, PAGE_SIZE, "%d\n", rotate); 3382 return snprintf(buf, PAGE_SIZE, "%d\n", rotate);
3383} 3383}
3384 3384
@@ -3392,7 +3392,7 @@ static ssize_t show_cursor_blink(struct device *device,
3392 if (fbcon_has_exited) 3392 if (fbcon_has_exited)
3393 return 0; 3393 return 0;
3394 3394
3395 acquire_console_sem(); 3395 console_lock();
3396 idx = con2fb_map[fg_console]; 3396 idx = con2fb_map[fg_console];
3397 3397
3398 if (idx == -1 || registered_fb[idx] == NULL) 3398 if (idx == -1 || registered_fb[idx] == NULL)
@@ -3406,7 +3406,7 @@ static ssize_t show_cursor_blink(struct device *device,
3406 3406
3407 blink = (ops->flags & FBCON_FLAGS_CURSOR_TIMER) ? 1 : 0; 3407 blink = (ops->flags & FBCON_FLAGS_CURSOR_TIMER) ? 1 : 0;
3408err: 3408err:
3409 release_console_sem(); 3409 console_unlock();
3410 return snprintf(buf, PAGE_SIZE, "%d\n", blink); 3410 return snprintf(buf, PAGE_SIZE, "%d\n", blink);
3411} 3411}
3412 3412
@@ -3421,7 +3421,7 @@ static ssize_t store_cursor_blink(struct device *device,
3421 if (fbcon_has_exited) 3421 if (fbcon_has_exited)
3422 return count; 3422 return count;
3423 3423
3424 acquire_console_sem(); 3424 console_lock();
3425 idx = con2fb_map[fg_console]; 3425 idx = con2fb_map[fg_console];
3426 3426
3427 if (idx == -1 || registered_fb[idx] == NULL) 3427 if (idx == -1 || registered_fb[idx] == NULL)
@@ -3443,7 +3443,7 @@ static ssize_t store_cursor_blink(struct device *device,
3443 } 3443 }
3444 3444
3445err: 3445err:
3446 release_console_sem(); 3446 console_unlock();
3447 return count; 3447 return count;
3448} 3448}
3449 3449
@@ -3482,7 +3482,7 @@ static void fbcon_start(void)
3482 if (num_registered_fb) { 3482 if (num_registered_fb) {
3483 int i; 3483 int i;
3484 3484
3485 acquire_console_sem(); 3485 console_lock();
3486 3486
3487 for (i = 0; i < FB_MAX; i++) { 3487 for (i = 0; i < FB_MAX; i++) {
3488 if (registered_fb[i] != NULL) { 3488 if (registered_fb[i] != NULL) {
@@ -3491,7 +3491,7 @@ static void fbcon_start(void)
3491 } 3491 }
3492 } 3492 }
3493 3493
3494 release_console_sem(); 3494 console_unlock();
3495 fbcon_takeover(0); 3495 fbcon_takeover(0);
3496 } 3496 }
3497} 3497}
@@ -3552,7 +3552,7 @@ static int __init fb_console_init(void)
3552{ 3552{
3553 int i; 3553 int i;
3554 3554
3555 acquire_console_sem(); 3555 console_lock();
3556 fb_register_client(&fbcon_event_notifier); 3556 fb_register_client(&fbcon_event_notifier);
3557 fbcon_device = device_create(fb_class, NULL, MKDEV(0, 0), NULL, 3557 fbcon_device = device_create(fb_class, NULL, MKDEV(0, 0), NULL,
3558 "fbcon"); 3558 "fbcon");
@@ -3568,7 +3568,7 @@ static int __init fb_console_init(void)
3568 for (i = 0; i < MAX_NR_CONSOLES; i++) 3568 for (i = 0; i < MAX_NR_CONSOLES; i++)
3569 con2fb_map[i] = -1; 3569 con2fb_map[i] = -1;
3570 3570
3571 release_console_sem(); 3571 console_unlock();
3572 fbcon_start(); 3572 fbcon_start();
3573 return 0; 3573 return 0;
3574} 3574}
@@ -3591,12 +3591,12 @@ static void __exit fbcon_deinit_device(void)
3591 3591
3592static void __exit fb_console_exit(void) 3592static void __exit fb_console_exit(void)
3593{ 3593{
3594 acquire_console_sem(); 3594 console_lock();
3595 fb_unregister_client(&fbcon_event_notifier); 3595 fb_unregister_client(&fbcon_event_notifier);
3596 fbcon_deinit_device(); 3596 fbcon_deinit_device();
3597 device_destroy(fb_class, MKDEV(0, 0)); 3597 device_destroy(fb_class, MKDEV(0, 0));
3598 fbcon_exit(); 3598 fbcon_exit();
3599 release_console_sem(); 3599 console_unlock();
3600 unregister_con_driver(&fb_con); 3600 unregister_con_driver(&fb_con);
3601} 3601}
3602 3602
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index c97491b8b39b..915fd74da7a2 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -202,11 +202,7 @@ static void vgacon_scrollback_init(int pitch)
202 } 202 }
203} 203}
204 204
205/* 205static void vgacon_scrollback_startup(void)
206 * Called only duing init so call of alloc_bootmen is ok.
207 * Marked __init_refok to silence modpost.
208 */
209static void __init_refok vgacon_scrollback_startup(void)
210{ 206{
211 vgacon_scrollback = kcalloc(CONFIG_VGACON_SOFT_SCROLLBACK_SIZE, 1024, GFP_NOWAIT); 207 vgacon_scrollback = kcalloc(CONFIG_VGACON_SOFT_SCROLLBACK_SIZE, 1024, GFP_NOWAIT);
212 vgacon_scrollback_init(vga_video_num_columns * 2); 208 vgacon_scrollback_init(vga_video_num_columns * 2);
diff --git a/drivers/video/da8xx-fb.c b/drivers/video/da8xx-fb.c
index c265aed09e04..8d61ef96eedd 100644
--- a/drivers/video/da8xx-fb.c
+++ b/drivers/video/da8xx-fb.c
@@ -1092,9 +1092,10 @@ static int __init fb_probe(struct platform_device *device)
1092 1092
1093irq_freq: 1093irq_freq:
1094#ifdef CONFIG_CPU_FREQ 1094#ifdef CONFIG_CPU_FREQ
1095 lcd_da8xx_cpufreq_deregister(par);
1096#endif
1095err_cpu_freq: 1097err_cpu_freq:
1096 unregister_framebuffer(da8xx_fb_info); 1098 unregister_framebuffer(da8xx_fb_info);
1097#endif
1098 1099
1099err_dealloc_cmap: 1100err_dealloc_cmap:
1100 fb_dealloc_cmap(&da8xx_fb_info->cmap); 1101 fb_dealloc_cmap(&da8xx_fb_info->cmap);
@@ -1130,14 +1131,14 @@ static int fb_suspend(struct platform_device *dev, pm_message_t state)
1130 struct fb_info *info = platform_get_drvdata(dev); 1131 struct fb_info *info = platform_get_drvdata(dev);
1131 struct da8xx_fb_par *par = info->par; 1132 struct da8xx_fb_par *par = info->par;
1132 1133
1133 acquire_console_sem(); 1134 console_lock();
1134 if (par->panel_power_ctrl) 1135 if (par->panel_power_ctrl)
1135 par->panel_power_ctrl(0); 1136 par->panel_power_ctrl(0);
1136 1137
1137 fb_set_suspend(info, 1); 1138 fb_set_suspend(info, 1);
1138 lcd_disable_raster(); 1139 lcd_disable_raster();
1139 clk_disable(par->lcdc_clk); 1140 clk_disable(par->lcdc_clk);
1140 release_console_sem(); 1141 console_unlock();
1141 1142
1142 return 0; 1143 return 0;
1143} 1144}
@@ -1146,14 +1147,14 @@ static int fb_resume(struct platform_device *dev)
1146 struct fb_info *info = platform_get_drvdata(dev); 1147 struct fb_info *info = platform_get_drvdata(dev);
1147 struct da8xx_fb_par *par = info->par; 1148 struct da8xx_fb_par *par = info->par;
1148 1149
1149 acquire_console_sem(); 1150 console_lock();
1150 if (par->panel_power_ctrl) 1151 if (par->panel_power_ctrl)
1151 par->panel_power_ctrl(1); 1152 par->panel_power_ctrl(1);
1152 1153
1153 clk_enable(par->lcdc_clk); 1154 clk_enable(par->lcdc_clk);
1154 lcd_enable_raster(); 1155 lcd_enable_raster();
1155 fb_set_suspend(info, 0); 1156 fb_set_suspend(info, 0);
1156 release_console_sem(); 1157 console_unlock();
1157 1158
1158 return 0; 1159 return 0;
1159} 1160}
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 4ac1201ad6c2..e2bf95370e40 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1036,11 +1036,11 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
1036 return -EFAULT; 1036 return -EFAULT;
1037 if (!lock_fb_info(info)) 1037 if (!lock_fb_info(info))
1038 return -ENODEV; 1038 return -ENODEV;
1039 acquire_console_sem(); 1039 console_lock();
1040 info->flags |= FBINFO_MISC_USEREVENT; 1040 info->flags |= FBINFO_MISC_USEREVENT;
1041 ret = fb_set_var(info, &var); 1041 ret = fb_set_var(info, &var);
1042 info->flags &= ~FBINFO_MISC_USEREVENT; 1042 info->flags &= ~FBINFO_MISC_USEREVENT;
1043 release_console_sem(); 1043 console_unlock();
1044 unlock_fb_info(info); 1044 unlock_fb_info(info);
1045 if (!ret && copy_to_user(argp, &var, sizeof(var))) 1045 if (!ret && copy_to_user(argp, &var, sizeof(var)))
1046 ret = -EFAULT; 1046 ret = -EFAULT;
@@ -1072,9 +1072,9 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
1072 return -EFAULT; 1072 return -EFAULT;
1073 if (!lock_fb_info(info)) 1073 if (!lock_fb_info(info))
1074 return -ENODEV; 1074 return -ENODEV;
1075 acquire_console_sem(); 1075 console_lock();
1076 ret = fb_pan_display(info, &var); 1076 ret = fb_pan_display(info, &var);
1077 release_console_sem(); 1077 console_unlock();
1078 unlock_fb_info(info); 1078 unlock_fb_info(info);
1079 if (ret == 0 && copy_to_user(argp, &var, sizeof(var))) 1079 if (ret == 0 && copy_to_user(argp, &var, sizeof(var)))
1080 return -EFAULT; 1080 return -EFAULT;
@@ -1119,11 +1119,11 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
1119 case FBIOBLANK: 1119 case FBIOBLANK:
1120 if (!lock_fb_info(info)) 1120 if (!lock_fb_info(info))
1121 return -ENODEV; 1121 return -ENODEV;
1122 acquire_console_sem(); 1122 console_lock();
1123 info->flags |= FBINFO_MISC_USEREVENT; 1123 info->flags |= FBINFO_MISC_USEREVENT;
1124 ret = fb_blank(info, arg); 1124 ret = fb_blank(info, arg);
1125 info->flags &= ~FBINFO_MISC_USEREVENT; 1125 info->flags &= ~FBINFO_MISC_USEREVENT;
1126 release_console_sem(); 1126 console_unlock();
1127 unlock_fb_info(info); 1127 unlock_fb_info(info);
1128 break; 1128 break;
1129 default: 1129 default:
diff --git a/drivers/video/fbsysfs.c b/drivers/video/fbsysfs.c
index 0a08f1341227..f4a32779168b 100644
--- a/drivers/video/fbsysfs.c
+++ b/drivers/video/fbsysfs.c
@@ -90,11 +90,11 @@ static int activate(struct fb_info *fb_info, struct fb_var_screeninfo *var)
90 int err; 90 int err;
91 91
92 var->activate |= FB_ACTIVATE_FORCE; 92 var->activate |= FB_ACTIVATE_FORCE;
93 acquire_console_sem(); 93 console_lock();
94 fb_info->flags |= FBINFO_MISC_USEREVENT; 94 fb_info->flags |= FBINFO_MISC_USEREVENT;
95 err = fb_set_var(fb_info, var); 95 err = fb_set_var(fb_info, var);
96 fb_info->flags &= ~FBINFO_MISC_USEREVENT; 96 fb_info->flags &= ~FBINFO_MISC_USEREVENT;
97 release_console_sem(); 97 console_unlock();
98 if (err) 98 if (err)
99 return err; 99 return err;
100 return 0; 100 return 0;
@@ -175,7 +175,7 @@ static ssize_t store_modes(struct device *device,
175 if (i * sizeof(struct fb_videomode) != count) 175 if (i * sizeof(struct fb_videomode) != count)
176 return -EINVAL; 176 return -EINVAL;
177 177
178 acquire_console_sem(); 178 console_lock();
179 list_splice(&fb_info->modelist, &old_list); 179 list_splice(&fb_info->modelist, &old_list);
180 fb_videomode_to_modelist((const struct fb_videomode *)buf, i, 180 fb_videomode_to_modelist((const struct fb_videomode *)buf, i,
181 &fb_info->modelist); 181 &fb_info->modelist);
@@ -185,7 +185,7 @@ static ssize_t store_modes(struct device *device,
185 } else 185 } else
186 fb_destroy_modelist(&old_list); 186 fb_destroy_modelist(&old_list);
187 187
188 release_console_sem(); 188 console_unlock();
189 189
190 return 0; 190 return 0;
191} 191}
@@ -301,11 +301,11 @@ static ssize_t store_blank(struct device *device,
301 char *last = NULL; 301 char *last = NULL;
302 int err; 302 int err;
303 303
304 acquire_console_sem(); 304 console_lock();
305 fb_info->flags |= FBINFO_MISC_USEREVENT; 305 fb_info->flags |= FBINFO_MISC_USEREVENT;
306 err = fb_blank(fb_info, simple_strtoul(buf, &last, 0)); 306 err = fb_blank(fb_info, simple_strtoul(buf, &last, 0));
307 fb_info->flags &= ~FBINFO_MISC_USEREVENT; 307 fb_info->flags &= ~FBINFO_MISC_USEREVENT;
308 release_console_sem(); 308 console_unlock();
309 if (err < 0) 309 if (err < 0)
310 return err; 310 return err;
311 return count; 311 return count;
@@ -364,9 +364,9 @@ static ssize_t store_pan(struct device *device,
364 return -EINVAL; 364 return -EINVAL;
365 var.yoffset = simple_strtoul(last, &last, 0); 365 var.yoffset = simple_strtoul(last, &last, 0);
366 366
367 acquire_console_sem(); 367 console_lock();
368 err = fb_pan_display(fb_info, &var); 368 err = fb_pan_display(fb_info, &var);
369 release_console_sem(); 369 console_unlock();
370 370
371 if (err < 0) 371 if (err < 0)
372 return err; 372 return err;
@@ -399,9 +399,9 @@ static ssize_t store_fbstate(struct device *device,
399 399
400 state = simple_strtoul(buf, &last, 0); 400 state = simple_strtoul(buf, &last, 0);
401 401
402 acquire_console_sem(); 402 console_lock();
403 fb_set_suspend(fb_info, (int)state); 403 fb_set_suspend(fb_info, (int)state);
404 release_console_sem(); 404 console_unlock();
405 405
406 return count; 406 return count;
407} 407}
diff --git a/drivers/video/geode/gxfb_core.c b/drivers/video/geode/gxfb_core.c
index 70b1d9d51c96..b4f19db9bb54 100644
--- a/drivers/video/geode/gxfb_core.c
+++ b/drivers/video/geode/gxfb_core.c
@@ -344,10 +344,10 @@ static int gxfb_suspend(struct pci_dev *pdev, pm_message_t state)
344 struct fb_info *info = pci_get_drvdata(pdev); 344 struct fb_info *info = pci_get_drvdata(pdev);
345 345
346 if (state.event == PM_EVENT_SUSPEND) { 346 if (state.event == PM_EVENT_SUSPEND) {
347 acquire_console_sem(); 347 console_lock();
348 gx_powerdown(info); 348 gx_powerdown(info);
349 fb_set_suspend(info, 1); 349 fb_set_suspend(info, 1);
350 release_console_sem(); 350 console_unlock();
351 } 351 }
352 352
353 /* there's no point in setting PCI states; we emulate PCI, so 353 /* there's no point in setting PCI states; we emulate PCI, so
@@ -361,7 +361,7 @@ static int gxfb_resume(struct pci_dev *pdev)
361 struct fb_info *info = pci_get_drvdata(pdev); 361 struct fb_info *info = pci_get_drvdata(pdev);
362 int ret; 362 int ret;
363 363
364 acquire_console_sem(); 364 console_lock();
365 ret = gx_powerup(info); 365 ret = gx_powerup(info);
366 if (ret) { 366 if (ret) {
367 printk(KERN_ERR "gxfb: power up failed!\n"); 367 printk(KERN_ERR "gxfb: power up failed!\n");
@@ -369,7 +369,7 @@ static int gxfb_resume(struct pci_dev *pdev)
369 } 369 }
370 370
371 fb_set_suspend(info, 0); 371 fb_set_suspend(info, 0);
372 release_console_sem(); 372 console_unlock();
373 return 0; 373 return 0;
374} 374}
375#endif 375#endif
diff --git a/drivers/video/geode/lxfb_core.c b/drivers/video/geode/lxfb_core.c
index 39bdbedf43b4..416851ca8754 100644
--- a/drivers/video/geode/lxfb_core.c
+++ b/drivers/video/geode/lxfb_core.c
@@ -465,10 +465,10 @@ static int lxfb_suspend(struct pci_dev *pdev, pm_message_t state)
465 struct fb_info *info = pci_get_drvdata(pdev); 465 struct fb_info *info = pci_get_drvdata(pdev);
466 466
467 if (state.event == PM_EVENT_SUSPEND) { 467 if (state.event == PM_EVENT_SUSPEND) {
468 acquire_console_sem(); 468 console_lock();
469 lx_powerdown(info); 469 lx_powerdown(info);
470 fb_set_suspend(info, 1); 470 fb_set_suspend(info, 1);
471 release_console_sem(); 471 console_unlock();
472 } 472 }
473 473
474 /* there's no point in setting PCI states; we emulate PCI, so 474 /* there's no point in setting PCI states; we emulate PCI, so
@@ -482,7 +482,7 @@ static int lxfb_resume(struct pci_dev *pdev)
482 struct fb_info *info = pci_get_drvdata(pdev); 482 struct fb_info *info = pci_get_drvdata(pdev);
483 int ret; 483 int ret;
484 484
485 acquire_console_sem(); 485 console_lock();
486 ret = lx_powerup(info); 486 ret = lx_powerup(info);
487 if (ret) { 487 if (ret) {
488 printk(KERN_ERR "lxfb: power up failed!\n"); 488 printk(KERN_ERR "lxfb: power up failed!\n");
@@ -490,7 +490,7 @@ static int lxfb_resume(struct pci_dev *pdev)
490 } 490 }
491 491
492 fb_set_suspend(info, 0); 492 fb_set_suspend(info, 0);
493 release_console_sem(); 493 console_unlock();
494 return 0; 494 return 0;
495} 495}
496#else 496#else
diff --git a/drivers/video/i810/i810_main.c b/drivers/video/i810/i810_main.c
index 5743ea25e818..318f6fb895b2 100644
--- a/drivers/video/i810/i810_main.c
+++ b/drivers/video/i810/i810_main.c
@@ -1574,7 +1574,7 @@ static int i810fb_suspend(struct pci_dev *dev, pm_message_t mesg)
1574 return 0; 1574 return 0;
1575 } 1575 }
1576 1576
1577 acquire_console_sem(); 1577 console_lock();
1578 fb_set_suspend(info, 1); 1578 fb_set_suspend(info, 1);
1579 1579
1580 if (info->fbops->fb_sync) 1580 if (info->fbops->fb_sync)
@@ -1587,7 +1587,7 @@ static int i810fb_suspend(struct pci_dev *dev, pm_message_t mesg)
1587 pci_save_state(dev); 1587 pci_save_state(dev);
1588 pci_disable_device(dev); 1588 pci_disable_device(dev);
1589 pci_set_power_state(dev, pci_choose_state(dev, mesg)); 1589 pci_set_power_state(dev, pci_choose_state(dev, mesg));
1590 release_console_sem(); 1590 console_unlock();
1591 1591
1592 return 0; 1592 return 0;
1593} 1593}
@@ -1605,7 +1605,7 @@ static int i810fb_resume(struct pci_dev *dev)
1605 return 0; 1605 return 0;
1606 } 1606 }
1607 1607
1608 acquire_console_sem(); 1608 console_lock();
1609 pci_set_power_state(dev, PCI_D0); 1609 pci_set_power_state(dev, PCI_D0);
1610 pci_restore_state(dev); 1610 pci_restore_state(dev);
1611 1611
@@ -1621,7 +1621,7 @@ static int i810fb_resume(struct pci_dev *dev)
1621 fb_set_suspend (info, 0); 1621 fb_set_suspend (info, 0);
1622 info->fbops->fb_blank(VESA_NO_BLANKING, info); 1622 info->fbops->fb_blank(VESA_NO_BLANKING, info);
1623fail: 1623fail:
1624 release_console_sem(); 1624 console_unlock();
1625 return 0; 1625 return 0;
1626} 1626}
1627/*********************************************************************** 1627/***********************************************************************
diff --git a/drivers/video/jz4740_fb.c b/drivers/video/jz4740_fb.c
index 670ecaa0385a..de366937c933 100644
--- a/drivers/video/jz4740_fb.c
+++ b/drivers/video/jz4740_fb.c
@@ -778,9 +778,9 @@ static int jzfb_suspend(struct device *dev)
778{ 778{
779 struct jzfb *jzfb = dev_get_drvdata(dev); 779 struct jzfb *jzfb = dev_get_drvdata(dev);
780 780
781 acquire_console_sem(); 781 console_lock();
782 fb_set_suspend(jzfb->fb, 1); 782 fb_set_suspend(jzfb->fb, 1);
783 release_console_sem(); 783 console_unlock();
784 784
785 mutex_lock(&jzfb->lock); 785 mutex_lock(&jzfb->lock);
786 if (jzfb->is_enabled) 786 if (jzfb->is_enabled)
@@ -800,9 +800,9 @@ static int jzfb_resume(struct device *dev)
800 jzfb_enable(jzfb); 800 jzfb_enable(jzfb);
801 mutex_unlock(&jzfb->lock); 801 mutex_unlock(&jzfb->lock);
802 802
803 acquire_console_sem(); 803 console_lock();
804 fb_set_suspend(jzfb->fb, 0); 804 fb_set_suspend(jzfb->fb, 0);
805 release_console_sem(); 805 console_unlock();
806 806
807 return 0; 807 return 0;
808} 808}
diff --git a/drivers/video/mx3fb.c b/drivers/video/mx3fb.c
index cb013919e9ce..7e3a490e8d76 100644
--- a/drivers/video/mx3fb.c
+++ b/drivers/video/mx3fb.c
@@ -1177,9 +1177,9 @@ static int mx3fb_suspend(struct platform_device *pdev, pm_message_t state)
1177 struct mx3fb_data *mx3fb = platform_get_drvdata(pdev); 1177 struct mx3fb_data *mx3fb = platform_get_drvdata(pdev);
1178 struct mx3fb_info *mx3_fbi = mx3fb->fbi->par; 1178 struct mx3fb_info *mx3_fbi = mx3fb->fbi->par;
1179 1179
1180 acquire_console_sem(); 1180 console_lock();
1181 fb_set_suspend(mx3fb->fbi, 1); 1181 fb_set_suspend(mx3fb->fbi, 1);
1182 release_console_sem(); 1182 console_unlock();
1183 1183
1184 if (mx3_fbi->blank == FB_BLANK_UNBLANK) { 1184 if (mx3_fbi->blank == FB_BLANK_UNBLANK) {
1185 sdc_disable_channel(mx3_fbi); 1185 sdc_disable_channel(mx3_fbi);
@@ -1202,9 +1202,9 @@ static int mx3fb_resume(struct platform_device *pdev)
1202 sdc_set_brightness(mx3fb, mx3fb->backlight_level); 1202 sdc_set_brightness(mx3fb, mx3fb->backlight_level);
1203 } 1203 }
1204 1204
1205 acquire_console_sem(); 1205 console_lock();
1206 fb_set_suspend(mx3fb->fbi, 0); 1206 fb_set_suspend(mx3fb->fbi, 0);
1207 release_console_sem(); 1207 console_unlock();
1208 1208
1209 return 0; 1209 return 0;
1210} 1210}
diff --git a/drivers/video/nuc900fb.c b/drivers/video/nuc900fb.c
index 62498bd662fc..f838d9e277f0 100644
--- a/drivers/video/nuc900fb.c
+++ b/drivers/video/nuc900fb.c
@@ -696,6 +696,8 @@ static int nuc900fb_remove(struct platform_device *pdev)
696 nuc900fb_stop_lcd(fbinfo); 696 nuc900fb_stop_lcd(fbinfo);
697 msleep(1); 697 msleep(1);
698 698
699 unregister_framebuffer(fbinfo);
700 nuc900fb_cpufreq_deregister(fbi);
699 nuc900fb_unmap_video_memory(fbinfo); 701 nuc900fb_unmap_video_memory(fbinfo);
700 702
701 iounmap(fbi->io); 703 iounmap(fbi->io);
@@ -723,7 +725,7 @@ static int nuc900fb_suspend(struct platform_device *dev, pm_message_t state)
723 struct fb_info *fbinfo = platform_get_drvdata(dev); 725 struct fb_info *fbinfo = platform_get_drvdata(dev);
724 struct nuc900fb_info *info = fbinfo->par; 726 struct nuc900fb_info *info = fbinfo->par;
725 727
726 nuc900fb_stop_lcd(); 728 nuc900fb_stop_lcd(fbinfo);
727 msleep(1); 729 msleep(1);
728 clk_disable(info->clk); 730 clk_disable(info->clk);
729 return 0; 731 return 0;
@@ -740,7 +742,7 @@ static int nuc900fb_resume(struct platform_device *dev)
740 msleep(1); 742 msleep(1);
741 743
742 nuc900fb_init_registers(fbinfo); 744 nuc900fb_init_registers(fbinfo);
743 nuc900fb_activate_var(bfinfo); 745 nuc900fb_activate_var(fbinfo);
744 746
745 return 0; 747 return 0;
746} 748}
diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
index efe10ff86d63..081dc4745274 100644
--- a/drivers/video/nvidia/nvidia.c
+++ b/drivers/video/nvidia/nvidia.c
@@ -1057,7 +1057,7 @@ static int nvidiafb_suspend(struct pci_dev *dev, pm_message_t mesg)
1057 1057
1058 if (mesg.event == PM_EVENT_PRETHAW) 1058 if (mesg.event == PM_EVENT_PRETHAW)
1059 mesg.event = PM_EVENT_FREEZE; 1059 mesg.event = PM_EVENT_FREEZE;
1060 acquire_console_sem(); 1060 console_lock();
1061 par->pm_state = mesg.event; 1061 par->pm_state = mesg.event;
1062 1062
1063 if (mesg.event & PM_EVENT_SLEEP) { 1063 if (mesg.event & PM_EVENT_SLEEP) {
@@ -1070,7 +1070,7 @@ static int nvidiafb_suspend(struct pci_dev *dev, pm_message_t mesg)
1070 } 1070 }
1071 dev->dev.power.power_state = mesg; 1071 dev->dev.power.power_state = mesg;
1072 1072
1073 release_console_sem(); 1073 console_unlock();
1074 return 0; 1074 return 0;
1075} 1075}
1076 1076
@@ -1079,7 +1079,7 @@ static int nvidiafb_resume(struct pci_dev *dev)
1079 struct fb_info *info = pci_get_drvdata(dev); 1079 struct fb_info *info = pci_get_drvdata(dev);
1080 struct nvidia_par *par = info->par; 1080 struct nvidia_par *par = info->par;
1081 1081
1082 acquire_console_sem(); 1082 console_lock();
1083 pci_set_power_state(dev, PCI_D0); 1083 pci_set_power_state(dev, PCI_D0);
1084 1084
1085 if (par->pm_state != PM_EVENT_FREEZE) { 1085 if (par->pm_state != PM_EVENT_FREEZE) {
@@ -1097,7 +1097,7 @@ static int nvidiafb_resume(struct pci_dev *dev)
1097 nvidiafb_blank(FB_BLANK_UNBLANK, info); 1097 nvidiafb_blank(FB_BLANK_UNBLANK, info);
1098 1098
1099fail: 1099fail:
1100 release_console_sem(); 1100 console_unlock();
1101 return 0; 1101 return 0;
1102} 1102}
1103#else 1103#else
diff --git a/drivers/video/ps3fb.c b/drivers/video/ps3fb.c
index 9c0144ee7ae5..65560a1a0439 100644
--- a/drivers/video/ps3fb.c
+++ b/drivers/video/ps3fb.c
@@ -513,9 +513,9 @@ static int ps3fb_release(struct fb_info *info, int user)
513 if (atomic_dec_and_test(&ps3fb.f_count)) { 513 if (atomic_dec_and_test(&ps3fb.f_count)) {
514 if (atomic_read(&ps3fb.ext_flip)) { 514 if (atomic_read(&ps3fb.ext_flip)) {
515 atomic_set(&ps3fb.ext_flip, 0); 515 atomic_set(&ps3fb.ext_flip, 0);
516 if (!try_acquire_console_sem()) { 516 if (console_trylock()) {
517 ps3fb_sync(info, 0); /* single buffer */ 517 ps3fb_sync(info, 0); /* single buffer */
518 release_console_sem(); 518 console_unlock();
519 } 519 }
520 } 520 }
521 } 521 }
@@ -830,14 +830,14 @@ static int ps3fb_ioctl(struct fb_info *info, unsigned int cmd,
830 if (vmode) { 830 if (vmode) {
831 var = info->var; 831 var = info->var;
832 fb_videomode_to_var(&var, vmode); 832 fb_videomode_to_var(&var, vmode);
833 acquire_console_sem(); 833 console_lock();
834 info->flags |= FBINFO_MISC_USEREVENT; 834 info->flags |= FBINFO_MISC_USEREVENT;
835 /* Force, in case only special bits changed */ 835 /* Force, in case only special bits changed */
836 var.activate |= FB_ACTIVATE_FORCE; 836 var.activate |= FB_ACTIVATE_FORCE;
837 par->new_mode_id = val; 837 par->new_mode_id = val;
838 retval = fb_set_var(info, &var); 838 retval = fb_set_var(info, &var);
839 info->flags &= ~FBINFO_MISC_USEREVENT; 839 info->flags &= ~FBINFO_MISC_USEREVENT;
840 release_console_sem(); 840 console_unlock();
841 } 841 }
842 break; 842 break;
843 } 843 }
@@ -881,9 +881,9 @@ static int ps3fb_ioctl(struct fb_info *info, unsigned int cmd,
881 break; 881 break;
882 882
883 dev_dbg(info->device, "PS3FB_IOCTL_FSEL:%d\n", val); 883 dev_dbg(info->device, "PS3FB_IOCTL_FSEL:%d\n", val);
884 acquire_console_sem(); 884 console_lock();
885 retval = ps3fb_sync(info, val); 885 retval = ps3fb_sync(info, val);
886 release_console_sem(); 886 console_unlock();
887 break; 887 break;
888 888
889 default: 889 default:
@@ -903,9 +903,9 @@ static int ps3fbd(void *arg)
903 set_current_state(TASK_INTERRUPTIBLE); 903 set_current_state(TASK_INTERRUPTIBLE);
904 if (ps3fb.is_kicked) { 904 if (ps3fb.is_kicked) {
905 ps3fb.is_kicked = 0; 905 ps3fb.is_kicked = 0;
906 acquire_console_sem(); 906 console_lock();
907 ps3fb_sync(info, 0); /* single buffer */ 907 ps3fb_sync(info, 0); /* single buffer */
908 release_console_sem(); 908 console_unlock();
909 } 909 }
910 schedule(); 910 schedule();
911 } 911 }
diff --git a/drivers/video/pxa168fb.c b/drivers/video/pxa168fb.c
index cea6403ae71c..35f61dd0cb3a 100644
--- a/drivers/video/pxa168fb.c
+++ b/drivers/video/pxa168fb.c
@@ -701,16 +701,12 @@ static int __devinit pxa168fb_probe(struct platform_device *pdev)
701 */ 701 */
702 pxa168fb_init_mode(info, mi); 702 pxa168fb_init_mode(info, mi);
703 703
704 ret = pxa168fb_check_var(&info->var, info);
705 if (ret)
706 goto failed_free_fbmem;
707
708 /* 704 /*
709 * Fill in sane defaults. 705 * Fill in sane defaults.
710 */ 706 */
711 ret = pxa168fb_check_var(&info->var, info); 707 ret = pxa168fb_check_var(&info->var, info);
712 if (ret) 708 if (ret)
713 goto failed; 709 goto failed_free_fbmem;
714 710
715 /* 711 /*
716 * enable controller clock 712 * enable controller clock
diff --git a/drivers/video/pxa3xx-gcu.c b/drivers/video/pxa3xx-gcu.c
index b81168df253d..cf4beb9dc9bb 100644
--- a/drivers/video/pxa3xx-gcu.c
+++ b/drivers/video/pxa3xx-gcu.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * pxa3xx-gc.c - Linux kernel module for PXA3xx graphics controllers 2 * pxa3xx-gcu.c - Linux kernel module for PXA3xx graphics controllers
3 * 3 *
4 * This driver needs a DirectFB counterpart in user space, communication 4 * This driver needs a DirectFB counterpart in user space, communication
5 * is handled via mmap()ed memory areas and an ioctl. 5 * is handled via mmap()ed memory areas and an ioctl.
@@ -421,7 +421,7 @@ pxa3xx_gcu_misc_write(struct file *filp, const char *buff,
421 buffer->next = priv->free; 421 buffer->next = priv->free;
422 priv->free = buffer; 422 priv->free = buffer;
423 spin_unlock_irqrestore(&priv->spinlock, flags); 423 spin_unlock_irqrestore(&priv->spinlock, flags);
424 return ret; 424 return -EFAULT;
425 } 425 }
426 426
427 buffer->length = words; 427 buffer->length = words;
diff --git a/drivers/video/s3fb.c b/drivers/video/s3fb.c
index dce8c97b4333..75738a928610 100644
--- a/drivers/video/s3fb.c
+++ b/drivers/video/s3fb.c
@@ -22,7 +22,7 @@
22#include <linux/svga.h> 22#include <linux/svga.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/pci.h> 24#include <linux/pci.h>
25#include <linux/console.h> /* Why should fb driver call console functions? because acquire_console_sem() */ 25#include <linux/console.h> /* Why should fb driver call console functions? because console_lock() */
26#include <video/vga.h> 26#include <video/vga.h>
27 27
28#ifdef CONFIG_MTRR 28#ifdef CONFIG_MTRR
@@ -1113,12 +1113,12 @@ static int s3_pci_suspend(struct pci_dev* dev, pm_message_t state)
1113 1113
1114 dev_info(info->device, "suspend\n"); 1114 dev_info(info->device, "suspend\n");
1115 1115
1116 acquire_console_sem(); 1116 console_lock();
1117 mutex_lock(&(par->open_lock)); 1117 mutex_lock(&(par->open_lock));
1118 1118
1119 if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) { 1119 if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) {
1120 mutex_unlock(&(par->open_lock)); 1120 mutex_unlock(&(par->open_lock));
1121 release_console_sem(); 1121 console_unlock();
1122 return 0; 1122 return 0;
1123 } 1123 }
1124 1124
@@ -1129,7 +1129,7 @@ static int s3_pci_suspend(struct pci_dev* dev, pm_message_t state)
1129 pci_set_power_state(dev, pci_choose_state(dev, state)); 1129 pci_set_power_state(dev, pci_choose_state(dev, state));
1130 1130
1131 mutex_unlock(&(par->open_lock)); 1131 mutex_unlock(&(par->open_lock));
1132 release_console_sem(); 1132 console_unlock();
1133 1133
1134 return 0; 1134 return 0;
1135} 1135}
@@ -1145,12 +1145,12 @@ static int s3_pci_resume(struct pci_dev* dev)
1145 1145
1146 dev_info(info->device, "resume\n"); 1146 dev_info(info->device, "resume\n");
1147 1147
1148 acquire_console_sem(); 1148 console_lock();
1149 mutex_lock(&(par->open_lock)); 1149 mutex_lock(&(par->open_lock));
1150 1150
1151 if (par->ref_count == 0) { 1151 if (par->ref_count == 0) {
1152 mutex_unlock(&(par->open_lock)); 1152 mutex_unlock(&(par->open_lock));
1153 release_console_sem(); 1153 console_unlock();
1154 return 0; 1154 return 0;
1155 } 1155 }
1156 1156
@@ -1159,7 +1159,7 @@ static int s3_pci_resume(struct pci_dev* dev)
1159 err = pci_enable_device(dev); 1159 err = pci_enable_device(dev);
1160 if (err) { 1160 if (err) {
1161 mutex_unlock(&(par->open_lock)); 1161 mutex_unlock(&(par->open_lock));
1162 release_console_sem(); 1162 console_unlock();
1163 dev_err(info->device, "error %d enabling device for resume\n", err); 1163 dev_err(info->device, "error %d enabling device for resume\n", err);
1164 return err; 1164 return err;
1165 } 1165 }
@@ -1169,7 +1169,7 @@ static int s3_pci_resume(struct pci_dev* dev)
1169 fb_set_suspend(info, 0); 1169 fb_set_suspend(info, 0);
1170 1170
1171 mutex_unlock(&(par->open_lock)); 1171 mutex_unlock(&(par->open_lock));
1172 release_console_sem(); 1172 console_unlock();
1173 1173
1174 return 0; 1174 return 0;
1175} 1175}
diff --git a/drivers/video/savage/savagefb_driver.c b/drivers/video/savage/savagefb_driver.c
index 842d157e1025..487911e2926c 100644
--- a/drivers/video/savage/savagefb_driver.c
+++ b/drivers/video/savage/savagefb_driver.c
@@ -2373,7 +2373,7 @@ static int savagefb_suspend(struct pci_dev *dev, pm_message_t mesg)
2373 if (mesg.event == PM_EVENT_FREEZE) 2373 if (mesg.event == PM_EVENT_FREEZE)
2374 return 0; 2374 return 0;
2375 2375
2376 acquire_console_sem(); 2376 console_lock();
2377 fb_set_suspend(info, 1); 2377 fb_set_suspend(info, 1);
2378 2378
2379 if (info->fbops->fb_sync) 2379 if (info->fbops->fb_sync)
@@ -2385,7 +2385,7 @@ static int savagefb_suspend(struct pci_dev *dev, pm_message_t mesg)
2385 pci_save_state(dev); 2385 pci_save_state(dev);
2386 pci_disable_device(dev); 2386 pci_disable_device(dev);
2387 pci_set_power_state(dev, pci_choose_state(dev, mesg)); 2387 pci_set_power_state(dev, pci_choose_state(dev, mesg));
2388 release_console_sem(); 2388 console_unlock();
2389 2389
2390 return 0; 2390 return 0;
2391} 2391}
@@ -2409,7 +2409,7 @@ static int savagefb_resume(struct pci_dev* dev)
2409 return 0; 2409 return 0;
2410 } 2410 }
2411 2411
2412 acquire_console_sem(); 2412 console_lock();
2413 2413
2414 pci_set_power_state(dev, PCI_D0); 2414 pci_set_power_state(dev, PCI_D0);
2415 pci_restore_state(dev); 2415 pci_restore_state(dev);
@@ -2423,7 +2423,7 @@ static int savagefb_resume(struct pci_dev* dev)
2423 savagefb_set_par(info); 2423 savagefb_set_par(info);
2424 fb_set_suspend(info, 0); 2424 fb_set_suspend(info, 0);
2425 savagefb_blank(FB_BLANK_UNBLANK, info); 2425 savagefb_blank(FB_BLANK_UNBLANK, info);
2426 release_console_sem(); 2426 console_unlock();
2427 2427
2428 return 0; 2428 return 0;
2429} 2429}
diff --git a/drivers/video/sh_mobile_hdmi.c b/drivers/video/sh_mobile_hdmi.c
index 74d9f546a2e8..2b9e56a6bde4 100644
--- a/drivers/video/sh_mobile_hdmi.c
+++ b/drivers/video/sh_mobile_hdmi.c
@@ -1151,7 +1151,7 @@ static void sh_hdmi_edid_work_fn(struct work_struct *work)
1151 1151
1152 ch = info->par; 1152 ch = info->par;
1153 1153
1154 acquire_console_sem(); 1154 console_lock();
1155 1155
1156 /* HDMI plug in */ 1156 /* HDMI plug in */
1157 if (!sh_hdmi_must_reconfigure(hdmi) && 1157 if (!sh_hdmi_must_reconfigure(hdmi) &&
@@ -1171,7 +1171,7 @@ static void sh_hdmi_edid_work_fn(struct work_struct *work)
1171 fb_set_suspend(info, 0); 1171 fb_set_suspend(info, 0);
1172 } 1172 }
1173 1173
1174 release_console_sem(); 1174 console_unlock();
1175 } else { 1175 } else {
1176 ret = 0; 1176 ret = 0;
1177 if (!hdmi->info) 1177 if (!hdmi->info)
@@ -1181,12 +1181,12 @@ static void sh_hdmi_edid_work_fn(struct work_struct *work)
1181 fb_destroy_modedb(hdmi->monspec.modedb); 1181 fb_destroy_modedb(hdmi->monspec.modedb);
1182 hdmi->monspec.modedb = NULL; 1182 hdmi->monspec.modedb = NULL;
1183 1183
1184 acquire_console_sem(); 1184 console_lock();
1185 1185
1186 /* HDMI disconnect */ 1186 /* HDMI disconnect */
1187 fb_set_suspend(hdmi->info, 1); 1187 fb_set_suspend(hdmi->info, 1);
1188 1188
1189 release_console_sem(); 1189 console_unlock();
1190 pm_runtime_put(hdmi->dev); 1190 pm_runtime_put(hdmi->dev);
1191 } 1191 }
1192 1192
diff --git a/drivers/video/sh_mobile_lcdcfb.c b/drivers/video/sh_mobile_lcdcfb.c
index bd4840a8a6b7..bf12e53aed5c 100644
--- a/drivers/video/sh_mobile_lcdcfb.c
+++ b/drivers/video/sh_mobile_lcdcfb.c
@@ -912,9 +912,9 @@ static int sh_mobile_release(struct fb_info *info, int user)
912 912
913 /* Nothing to reconfigure, when called from fbcon */ 913 /* Nothing to reconfigure, when called from fbcon */
914 if (user) { 914 if (user) {
915 acquire_console_sem(); 915 console_lock();
916 sh_mobile_fb_reconfig(info); 916 sh_mobile_fb_reconfig(info);
917 release_console_sem(); 917 console_unlock();
918 } 918 }
919 919
920 mutex_unlock(&ch->open_lock); 920 mutex_unlock(&ch->open_lock);
diff --git a/drivers/video/sm501fb.c b/drivers/video/sm501fb.c
index b7dc1800efa9..bcb44a594ebc 100644
--- a/drivers/video/sm501fb.c
+++ b/drivers/video/sm501fb.c
@@ -2010,9 +2010,9 @@ static int sm501fb_suspend_fb(struct sm501fb_info *info,
2010 2010
2011 /* tell console/fb driver we are suspending */ 2011 /* tell console/fb driver we are suspending */
2012 2012
2013 acquire_console_sem(); 2013 console_lock();
2014 fb_set_suspend(fbi, 1); 2014 fb_set_suspend(fbi, 1);
2015 release_console_sem(); 2015 console_unlock();
2016 2016
2017 /* backup copies in case chip is powered down over suspend */ 2017 /* backup copies in case chip is powered down over suspend */
2018 2018
@@ -2069,9 +2069,9 @@ static void sm501fb_resume_fb(struct sm501fb_info *info,
2069 memcpy_toio(par->cursor.k_addr, par->store_cursor, 2069 memcpy_toio(par->cursor.k_addr, par->store_cursor,
2070 par->cursor.size); 2070 par->cursor.size);
2071 2071
2072 acquire_console_sem(); 2072 console_lock();
2073 fb_set_suspend(fbi, 0); 2073 fb_set_suspend(fbi, 0);
2074 release_console_sem(); 2074 console_unlock();
2075 2075
2076 vfree(par->store_fb); 2076 vfree(par->store_fb);
2077 vfree(par->store_cursor); 2077 vfree(par->store_cursor);
diff --git a/drivers/video/tmiofb.c b/drivers/video/tmiofb.c
index 6913fe168c25..dfef88c803d4 100644
--- a/drivers/video/tmiofb.c
+++ b/drivers/video/tmiofb.c
@@ -25,7 +25,7 @@
25#include <linux/fb.h> 25#include <linux/fb.h>
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28/* Why should fb driver call console functions? because acquire_console_sem() */ 28/* Why should fb driver call console functions? because console_lock() */
29#include <linux/console.h> 29#include <linux/console.h>
30#include <linux/mfd/core.h> 30#include <linux/mfd/core.h>
31#include <linux/mfd/tmio.h> 31#include <linux/mfd/tmio.h>
@@ -944,7 +944,7 @@ static int tmiofb_suspend(struct platform_device *dev, pm_message_t state)
944 struct mfd_cell *cell = dev->dev.platform_data; 944 struct mfd_cell *cell = dev->dev.platform_data;
945 int retval = 0; 945 int retval = 0;
946 946
947 acquire_console_sem(); 947 console_lock();
948 948
949 fb_set_suspend(info, 1); 949 fb_set_suspend(info, 1);
950 950
@@ -965,7 +965,7 @@ static int tmiofb_suspend(struct platform_device *dev, pm_message_t state)
965 if (cell->suspend) 965 if (cell->suspend)
966 retval = cell->suspend(dev); 966 retval = cell->suspend(dev);
967 967
968 release_console_sem(); 968 console_unlock();
969 969
970 return retval; 970 return retval;
971} 971}
@@ -976,7 +976,7 @@ static int tmiofb_resume(struct platform_device *dev)
976 struct mfd_cell *cell = dev->dev.platform_data; 976 struct mfd_cell *cell = dev->dev.platform_data;
977 int retval = 0; 977 int retval = 0;
978 978
979 acquire_console_sem(); 979 console_lock();
980 980
981 if (cell->resume) { 981 if (cell->resume) {
982 retval = cell->resume(dev); 982 retval = cell->resume(dev);
@@ -992,7 +992,7 @@ static int tmiofb_resume(struct platform_device *dev)
992 992
993 fb_set_suspend(info, 0); 993 fb_set_suspend(info, 0);
994out: 994out:
995 release_console_sem(); 995 console_unlock();
996 return retval; 996 return retval;
997} 997}
998#else 998#else
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index 289edd519527..4e66349e4366 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -1674,17 +1674,17 @@ static int parse_mode(const char *str, u32 *xres, u32 *yres)
1674#ifdef CONFIG_PM 1674#ifdef CONFIG_PM
1675static int viafb_suspend(void *unused) 1675static int viafb_suspend(void *unused)
1676{ 1676{
1677 acquire_console_sem(); 1677 console_lock();
1678 fb_set_suspend(viafbinfo, 1); 1678 fb_set_suspend(viafbinfo, 1);
1679 viafb_sync(viafbinfo); 1679 viafb_sync(viafbinfo);
1680 release_console_sem(); 1680 console_unlock();
1681 1681
1682 return 0; 1682 return 0;
1683} 1683}
1684 1684
1685static int viafb_resume(void *unused) 1685static int viafb_resume(void *unused)
1686{ 1686{
1687 acquire_console_sem(); 1687 console_lock();
1688 if (viaparinfo->shared->vdev->engine_mmio) 1688 if (viaparinfo->shared->vdev->engine_mmio)
1689 viafb_reset_engine(viaparinfo); 1689 viafb_reset_engine(viaparinfo);
1690 viafb_set_par(viafbinfo); 1690 viafb_set_par(viafbinfo);
@@ -1692,7 +1692,7 @@ static int viafb_resume(void *unused)
1692 viafb_set_par(viafbinfo1); 1692 viafb_set_par(viafbinfo1);
1693 fb_set_suspend(viafbinfo, 0); 1693 fb_set_suspend(viafbinfo, 0);
1694 1694
1695 release_console_sem(); 1695 console_unlock();
1696 return 0; 1696 return 0;
1697} 1697}
1698 1698
diff --git a/drivers/video/vt8623fb.c b/drivers/video/vt8623fb.c
index 85d76ec4c63e..a2965ab92cfb 100644
--- a/drivers/video/vt8623fb.c
+++ b/drivers/video/vt8623fb.c
@@ -23,7 +23,7 @@
23#include <linux/svga.h> 23#include <linux/svga.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/pci.h> 25#include <linux/pci.h>
26#include <linux/console.h> /* Why should fb driver call console functions? because acquire_console_sem() */ 26#include <linux/console.h> /* Why should fb driver call console functions? because console_lock() */
27#include <video/vga.h> 27#include <video/vga.h>
28 28
29#ifdef CONFIG_MTRR 29#ifdef CONFIG_MTRR
@@ -819,12 +819,12 @@ static int vt8623_pci_suspend(struct pci_dev* dev, pm_message_t state)
819 819
820 dev_info(info->device, "suspend\n"); 820 dev_info(info->device, "suspend\n");
821 821
822 acquire_console_sem(); 822 console_lock();
823 mutex_lock(&(par->open_lock)); 823 mutex_lock(&(par->open_lock));
824 824
825 if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) { 825 if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) {
826 mutex_unlock(&(par->open_lock)); 826 mutex_unlock(&(par->open_lock));
827 release_console_sem(); 827 console_unlock();
828 return 0; 828 return 0;
829 } 829 }
830 830
@@ -835,7 +835,7 @@ static int vt8623_pci_suspend(struct pci_dev* dev, pm_message_t state)
835 pci_set_power_state(dev, pci_choose_state(dev, state)); 835 pci_set_power_state(dev, pci_choose_state(dev, state));
836 836
837 mutex_unlock(&(par->open_lock)); 837 mutex_unlock(&(par->open_lock));
838 release_console_sem(); 838 console_unlock();
839 839
840 return 0; 840 return 0;
841} 841}
@@ -850,7 +850,7 @@ static int vt8623_pci_resume(struct pci_dev* dev)
850 850
851 dev_info(info->device, "resume\n"); 851 dev_info(info->device, "resume\n");
852 852
853 acquire_console_sem(); 853 console_lock();
854 mutex_lock(&(par->open_lock)); 854 mutex_lock(&(par->open_lock));
855 855
856 if (par->ref_count == 0) 856 if (par->ref_count == 0)
@@ -869,7 +869,7 @@ static int vt8623_pci_resume(struct pci_dev* dev)
869 869
870fail: 870fail:
871 mutex_unlock(&(par->open_lock)); 871 mutex_unlock(&(par->open_lock));
872 release_console_sem(); 872 console_unlock();
873 873
874 return 0; 874 return 0;
875} 875}
diff --git a/drivers/video/xen-fbfront.c b/drivers/video/xen-fbfront.c
index 3e6934d4bea8..a20218c2fda8 100644
--- a/drivers/video/xen-fbfront.c
+++ b/drivers/video/xen-fbfront.c
@@ -491,12 +491,12 @@ xenfb_make_preferred_console(void)
491 if (console_set_on_cmdline) 491 if (console_set_on_cmdline)
492 return; 492 return;
493 493
494 acquire_console_sem(); 494 console_lock();
495 for_each_console(c) { 495 for_each_console(c) {
496 if (!strcmp(c->name, "tty") && c->index == 0) 496 if (!strcmp(c->name, "tty") && c->index == 0)
497 break; 497 break;
498 } 498 }
499 release_console_sem(); 499 console_unlock();
500 if (c) { 500 if (c) {
501 unregister_console(c); 501 unregister_console(c);
502 c->flags |= CON_CONSDEV; 502 c->flags |= CON_CONSDEV;
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
index ef8d9d558fc7..4fb5b2bf2348 100644
--- a/drivers/virtio/virtio_pci.c
+++ b/drivers/virtio/virtio_pci.c
@@ -96,11 +96,6 @@ static struct pci_device_id virtio_pci_id_table[] = {
96 96
97MODULE_DEVICE_TABLE(pci, virtio_pci_id_table); 97MODULE_DEVICE_TABLE(pci, virtio_pci_id_table);
98 98
99/* A PCI device has it's own struct device and so does a virtio device so
100 * we create a place for the virtio devices to show up in sysfs. I think it
101 * would make more sense for virtio to not insist on having it's own device. */
102static struct device *virtio_pci_root;
103
104/* Convert a generic virtio device to our structure */ 99/* Convert a generic virtio device to our structure */
105static struct virtio_pci_device *to_vp_device(struct virtio_device *vdev) 100static struct virtio_pci_device *to_vp_device(struct virtio_device *vdev)
106{ 101{
@@ -629,7 +624,7 @@ static int __devinit virtio_pci_probe(struct pci_dev *pci_dev,
629 if (vp_dev == NULL) 624 if (vp_dev == NULL)
630 return -ENOMEM; 625 return -ENOMEM;
631 626
632 vp_dev->vdev.dev.parent = virtio_pci_root; 627 vp_dev->vdev.dev.parent = &pci_dev->dev;
633 vp_dev->vdev.dev.release = virtio_pci_release_dev; 628 vp_dev->vdev.dev.release = virtio_pci_release_dev;
634 vp_dev->vdev.config = &virtio_pci_config_ops; 629 vp_dev->vdev.config = &virtio_pci_config_ops;
635 vp_dev->pci_dev = pci_dev; 630 vp_dev->pci_dev = pci_dev;
@@ -717,17 +712,7 @@ static struct pci_driver virtio_pci_driver = {
717 712
718static int __init virtio_pci_init(void) 713static int __init virtio_pci_init(void)
719{ 714{
720 int err; 715 return pci_register_driver(&virtio_pci_driver);
721
722 virtio_pci_root = root_device_register("virtio-pci");
723 if (IS_ERR(virtio_pci_root))
724 return PTR_ERR(virtio_pci_root);
725
726 err = pci_register_driver(&virtio_pci_driver);
727 if (err)
728 root_device_unregister(virtio_pci_root);
729
730 return err;
731} 716}
732 717
733module_init(virtio_pci_init); 718module_init(virtio_pci_init);
@@ -735,7 +720,6 @@ module_init(virtio_pci_init);
735static void __exit virtio_pci_exit(void) 720static void __exit virtio_pci_exit(void)
736{ 721{
737 pci_unregister_driver(&virtio_pci_driver); 722 pci_unregister_driver(&virtio_pci_driver);
738 root_device_unregister(virtio_pci_root);
739} 723}
740 724
741module_exit(virtio_pci_exit); 725module_exit(virtio_pci_exit);
diff --git a/drivers/xen/xenfs/xenbus.c b/drivers/xen/xenfs/xenbus.c
index 1c1236087f78..bbd000f88af7 100644
--- a/drivers/xen/xenfs/xenbus.c
+++ b/drivers/xen/xenfs/xenbus.c
@@ -122,6 +122,7 @@ static ssize_t xenbus_file_read(struct file *filp,
122 int ret; 122 int ret;
123 123
124 mutex_lock(&u->reply_mutex); 124 mutex_lock(&u->reply_mutex);
125again:
125 while (list_empty(&u->read_buffers)) { 126 while (list_empty(&u->read_buffers)) {
126 mutex_unlock(&u->reply_mutex); 127 mutex_unlock(&u->reply_mutex);
127 if (filp->f_flags & O_NONBLOCK) 128 if (filp->f_flags & O_NONBLOCK)
@@ -144,7 +145,7 @@ static ssize_t xenbus_file_read(struct file *filp,
144 i += sz - ret; 145 i += sz - ret;
145 rb->cons += sz - ret; 146 rb->cons += sz - ret;
146 147
147 if (ret != sz) { 148 if (ret != 0) {
148 if (i == 0) 149 if (i == 0)
149 i = -EFAULT; 150 i = -EFAULT;
150 goto out; 151 goto out;
@@ -160,6 +161,8 @@ static ssize_t xenbus_file_read(struct file *filp,
160 struct read_buffer, list); 161 struct read_buffer, list);
161 } 162 }
162 } 163 }
164 if (i == 0)
165 goto again;
163 166
164out: 167out:
165 mutex_unlock(&u->reply_mutex); 168 mutex_unlock(&u->reply_mutex);
@@ -407,6 +410,7 @@ static int xenbus_write_watch(unsigned msg_type, struct xenbus_file_priv *u)
407 410
408 mutex_lock(&u->reply_mutex); 411 mutex_lock(&u->reply_mutex);
409 rc = queue_reply(&u->read_buffers, &reply, sizeof(reply)); 412 rc = queue_reply(&u->read_buffers, &reply, sizeof(reply));
413 wake_up(&u->read_waitq);
410 mutex_unlock(&u->reply_mutex); 414 mutex_unlock(&u->reply_mutex);
411 } 415 }
412 416
@@ -455,7 +459,7 @@ static ssize_t xenbus_file_write(struct file *filp,
455 459
456 ret = copy_from_user(u->u.buffer + u->len, ubuf, len); 460 ret = copy_from_user(u->u.buffer + u->len, ubuf, len);
457 461
458 if (ret == len) { 462 if (ret != 0) {
459 rc = -EFAULT; 463 rc = -EFAULT;
460 goto out; 464 goto out;
461 } 465 }
@@ -488,21 +492,6 @@ static ssize_t xenbus_file_write(struct file *filp,
488 msg_type = u->u.msg.type; 492 msg_type = u->u.msg.type;
489 493
490 switch (msg_type) { 494 switch (msg_type) {
491 case XS_TRANSACTION_START:
492 case XS_TRANSACTION_END:
493 case XS_DIRECTORY:
494 case XS_READ:
495 case XS_GET_PERMS:
496 case XS_RELEASE:
497 case XS_GET_DOMAIN_PATH:
498 case XS_WRITE:
499 case XS_MKDIR:
500 case XS_RM:
501 case XS_SET_PERMS:
502 /* Send out a transaction */
503 ret = xenbus_write_transaction(msg_type, u);
504 break;
505
506 case XS_WATCH: 495 case XS_WATCH:
507 case XS_UNWATCH: 496 case XS_UNWATCH:
508 /* (Un)Ask for some path to be watched for changes */ 497 /* (Un)Ask for some path to be watched for changes */
@@ -510,7 +499,8 @@ static ssize_t xenbus_file_write(struct file *filp,
510 break; 499 break;
511 500
512 default: 501 default:
513 ret = -EINVAL; 502 /* Send out a transaction */
503 ret = xenbus_write_transaction(msg_type, u);
514 break; 504 break;
515 } 505 }
516 if (ret != 0) 506 if (ret != 0)
@@ -555,6 +545,7 @@ static int xenbus_file_release(struct inode *inode, struct file *filp)
555 struct xenbus_file_priv *u = filp->private_data; 545 struct xenbus_file_priv *u = filp->private_data;
556 struct xenbus_transaction_holder *trans, *tmp; 546 struct xenbus_transaction_holder *trans, *tmp;
557 struct watch_adapter *watch, *tmp_watch; 547 struct watch_adapter *watch, *tmp_watch;
548 struct read_buffer *rb, *tmp_rb;
558 549
559 /* 550 /*
560 * No need for locking here because there are no other users, 551 * No need for locking here because there are no other users,
@@ -573,6 +564,10 @@ static int xenbus_file_release(struct inode *inode, struct file *filp)
573 free_watch_adapter(watch); 564 free_watch_adapter(watch);
574 } 565 }
575 566
567 list_for_each_entry_safe(rb, tmp_rb, &u->read_buffers, list) {
568 list_del(&rb->list);
569 kfree(rb);
570 }
576 kfree(u); 571 kfree(u);
577 572
578 return 0; 573 return 0;