aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/DocBook/drm.tmpl1
-rw-r--r--Documentation/x86/x86_64/kernel-stacks6
-rw-r--r--arch/arm/kernel/etm.c1
-rw-r--r--arch/arm/mach-msm/last_radio_log.c3
-rw-r--r--arch/arm/mach-msm/smd_debug.c1
-rw-r--r--arch/arm/plat-mxc/audmux-v2.c1
-rw-r--r--arch/arm/plat-omap/iommu-debug.c2
-rw-r--r--arch/avr32/boards/mimc200/fram.c1
-rw-r--r--arch/blackfin/kernel/kgdb_test.c1
-rw-r--r--arch/blackfin/mach-bf561/coreb.c1
-rw-r--r--arch/cris/arch-v10/drivers/ds1302.c8
-rw-r--r--arch/cris/arch-v10/drivers/gpio.c1
-rw-r--r--arch/cris/arch-v10/drivers/i2c.c1
-rw-r--r--arch/cris/arch-v10/drivers/pcf8563.c7
-rw-r--r--arch/cris/arch-v10/drivers/sync_serial.c14
-rw-r--r--arch/cris/arch-v32/drivers/cryptocop.c7
-rw-r--r--arch/cris/arch-v32/drivers/i2c.c1
-rw-r--r--arch/cris/arch-v32/drivers/mach-a3/gpio.c12
-rw-r--r--arch/cris/arch-v32/drivers/mach-fs/gpio.c12
-rw-r--r--arch/cris/arch-v32/drivers/pcf8563.c7
-rw-r--r--arch/cris/arch-v32/drivers/sync_serial.c14
-rw-r--r--arch/cris/kernel/profile.c1
-rw-r--r--arch/ia64/kernel/salinfo.c2
-rw-r--r--arch/ia64/sn/kernel/sn2/sn_hwperf.c1
-rw-r--r--arch/m68k/bvme6000/rtc.c1
-rw-r--r--arch/m68k/mvme16x/rtc.c1
-rw-r--r--arch/mips/kernel/rtlx.c3
-rw-r--r--arch/mips/kernel/vpe.c3
-rw-r--r--arch/mips/sibyte/common/sb_tbprof.c1
-rw-r--r--arch/parisc/kernel/perf.c4
-rw-r--r--arch/powerpc/kernel/lparcfg.c1
-rw-r--r--arch/powerpc/kernel/rtas_flash.c3
-rw-r--r--arch/powerpc/kernel/rtasd.c1
-rw-r--r--arch/powerpc/platforms/iseries/mf.c1
-rw-r--r--arch/powerpc/platforms/pseries/reconfig.c3
-rw-r--r--arch/powerpc/platforms/pseries/scanlog.c1
-rw-r--r--arch/s390/crypto/prng.c1
-rw-r--r--arch/s390/hypfs/hypfs_diag.c1
-rw-r--r--arch/s390/hypfs/hypfs_vm.c1
-rw-r--r--arch/s390/hypfs/inode.c1
-rw-r--r--arch/s390/kernel/debug.c1
-rw-r--r--arch/sh/boards/mach-landisk/gio.c1
-rw-r--r--arch/sparc/kernel/apc.c1
-rw-r--r--arch/sparc/kernel/mdesc.c1
-rw-r--r--arch/tile/include/asm/bitops.h1
-rw-r--r--arch/tile/kernel/hardwall.c1
-rw-r--r--arch/um/drivers/harddog_kern.c14
-rw-r--r--arch/um/drivers/hostaudio_kern.c12
-rw-r--r--arch/um/drivers/mconsole_kern.c1
-rw-r--r--arch/um/drivers/mmapper_kern.c1
-rw-r--r--arch/um/drivers/random.c1
-rw-r--r--arch/um/drivers/ubd_kern.c11
-rw-r--r--arch/um/kernel/exec.c2
-rw-r--r--arch/x86/Kconfig.debug10
-rw-r--r--arch/x86/include/asm/bitops.h2
-rw-r--r--arch/x86/include/asm/irq.h12
-rw-r--r--arch/x86/include/asm/module.h7
-rw-r--r--arch/x86/include/asm/page_32_types.h4
-rw-r--r--arch/x86/kernel/apm_32.c1
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce-severity.c1
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce.c1
-rw-r--r--arch/x86/kernel/hpet.c51
-rw-r--r--arch/x86/kernel/irq_32.c12
-rw-r--r--arch/x86/kernel/kdebugfs.c1
-rw-r--r--arch/x86/kernel/microcode_core.c1
-rw-r--r--arch/x86/kernel/tlb_uv.c1
-rw-r--r--arch/x86/kernel/vmlinux.lds.S2
-rw-r--r--arch/x86/xen/debugfs.c1
-rw-r--r--block/bsg.c4
-rw-r--r--drivers/acpi/apei/erst-dbg.c1
-rw-r--r--drivers/acpi/debugfs.c1
-rw-r--r--drivers/acpi/ec_sys.c1
-rw-r--r--drivers/acpi/event.c1
-rw-r--r--drivers/block/DAC960.c14
-rw-r--r--drivers/block/amiflop.c19
-rw-r--r--drivers/block/aoe/aoeblk.c9
-rw-r--r--drivers/block/aoe/aoechr.c10
-rw-r--r--drivers/block/ataflop.c15
-rw-r--r--drivers/block/brd.c7
-rw-r--r--drivers/block/cciss.c14
-rw-r--r--drivers/block/cpqarray.c15
-rw-r--r--drivers/block/drbd/drbd_main.c11
-rw-r--r--drivers/block/floppy.c16
-rw-r--r--drivers/block/loop.c11
-rw-r--r--drivers/block/nbd.c7
-rw-r--r--drivers/block/paride/pcd.c15
-rw-r--r--drivers/block/paride/pd.c15
-rw-r--r--drivers/block/paride/pf.c17
-rw-r--r--drivers/block/paride/pg.c8
-rw-r--r--drivers/block/paride/pt.c20
-rw-r--r--drivers/block/pktcdvd.c17
-rw-r--r--drivers/block/swim.c15
-rw-r--r--drivers/block/swim3.c15
-rw-r--r--drivers/block/ub.c15
-rw-r--r--drivers/block/viodasd.c11
-rw-r--r--drivers/block/xd.c7
-rw-r--r--drivers/block/xen-blkfront.c11
-rw-r--r--drivers/block/xsysace.c11
-rw-r--r--drivers/block/z2ram.c15
-rw-r--r--drivers/bluetooth/btmrvl_debugfs.c10
-rw-r--r--drivers/bluetooth/hci_ldisc.c7
-rw-r--r--drivers/bluetooth/hci_vhci.c1
-rw-r--r--drivers/cdrom/gdrom.c15
-rw-r--r--drivers/cdrom/viocd.c15
-rw-r--r--drivers/char/apm-emulation.c12
-rw-r--r--drivers/char/applicom.c9
-rw-r--r--drivers/char/bfin-otp.c1
-rw-r--r--drivers/char/briq_panel.c1
-rw-r--r--drivers/char/bsr.c1
-rw-r--r--drivers/char/cs5535_gpio.c3
-rw-r--r--drivers/char/ds1302.c16
-rw-r--r--drivers/char/ds1620.c9
-rw-r--r--drivers/char/dsp56k.c28
-rw-r--r--drivers/char/dtlk.c9
-rw-r--r--drivers/char/generic_nvram.c7
-rw-r--r--drivers/char/genrtc.c14
-rw-r--r--drivers/char/hpet.c98
-rw-r--r--drivers/char/hw_random/core.c1
-rw-r--r--drivers/char/i8k.c7
-rw-r--r--drivers/char/ip2/ip2main.c9
-rw-r--r--drivers/char/ipmi/ipmi_devintf.c15
-rw-r--r--drivers/char/ipmi/ipmi_watchdog.c9
-rw-r--r--drivers/char/istallion.c1
-rw-r--r--drivers/char/lp.c16
-rw-r--r--drivers/char/mbcs.c8
-rw-r--r--drivers/char/mem.c3
-rw-r--r--drivers/char/misc.c1
-rw-r--r--drivers/char/mmtimer.c8
-rw-r--r--drivers/char/mspec.c9
-rw-r--r--drivers/char/mwave/mwavedd.c47
-rw-r--r--drivers/char/nvram.c11
-rw-r--r--drivers/char/nwbutton.c1
-rw-r--r--drivers/char/nwflash.c12
-rw-r--r--drivers/char/pc8736x_gpio.c1
-rw-r--r--drivers/char/pcmcia/cm4000_cs.c13
-rw-r--r--drivers/char/pcmcia/cm4040_cs.c9
-rw-r--r--drivers/char/ppdev.c8
-rw-r--r--drivers/char/random.c2
-rw-r--r--drivers/char/raw.c245
-rw-r--r--drivers/char/rio/rio_linux.c8
-rw-r--r--drivers/char/scx200_gpio.c1
-rw-r--r--drivers/char/snsc.c10
-rw-r--r--drivers/char/stallion.c1
-rw-r--r--drivers/char/sx.c1
-rw-r--r--drivers/char/sysrq.c1
-rw-r--r--drivers/char/tb0219.c1
-rw-r--r--drivers/char/tlclk.c7
-rw-r--r--drivers/char/toshiba.c10
-rw-r--r--drivers/char/uv_mmtimer.c1
-rw-r--r--drivers/char/viotape.c12
-rw-r--r--drivers/char/xilinx_hwicap/xilinx_hwicap.c7
-rw-r--r--drivers/dma/coh901318.c1
-rw-r--r--drivers/firewire/nosy.c1
-rw-r--r--drivers/gpu/drm/Kconfig5
-rw-r--r--drivers/gpu/drm/drm_drv.c3
-rw-r--r--drivers/gpu/drm/i810/i810_dma.c1
-rw-r--r--drivers/gpu/drm/i810/i810_drv.c1
-rw-r--r--drivers/gpu/drm/i830/i830_dma.c1
-rw-r--r--drivers/gpu/drm/i830/i830_drv.c1
-rw-r--r--drivers/gpu/drm/i915/i915_debugfs.c1
-rw-r--r--drivers/gpu/drm/i915/i915_drv.c1
-rw-r--r--drivers/gpu/drm/mga/mga_drv.c1
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drv.c1
-rw-r--r--drivers/gpu/drm/r128/r128_drv.c1
-rw-r--r--drivers/gpu/drm/radeon/radeon_drv.c1
-rw-r--r--drivers/gpu/drm/savage/savage_drv.c1
-rw-r--r--drivers/gpu/drm/sis/sis_drv.c1
-rw-r--r--drivers/gpu/drm/tdfx/tdfx_drv.c1
-rw-r--r--drivers/gpu/drm/via/via_drv.c1
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_drv.c1
-rw-r--r--drivers/gpu/vga/vgaarb.c1
-rw-r--r--drivers/hid/hid-debug.c1
-rw-r--r--drivers/hid/hid-roccat.c1
-rw-r--r--drivers/hid/hidraw.c1
-rw-r--r--drivers/hid/usbhid/hiddev.c1
-rw-r--r--drivers/hwmon/asus_atk0110.c1
-rw-r--r--drivers/hwmon/fschmd.c6
-rw-r--r--drivers/hwmon/w83793.c6
-rw-r--r--drivers/ide/ide-cd.c14
-rw-r--r--drivers/ide/ide-disk_ioctl.c7
-rw-r--r--drivers/ide/ide-floppy_ioctl.c7
-rw-r--r--drivers/ide/ide-gd.c10
-rw-r--r--drivers/ide/ide-tape.c20
-rw-r--r--drivers/idle/i7300_idle.c1
-rw-r--r--drivers/infiniband/hw/ipath/ipath_diag.c4
-rw-r--r--drivers/infiniband/hw/ipath/ipath_file_ops.c3
-rw-r--r--drivers/infiniband/hw/ipath/ipath_fs.c3
-rw-r--r--drivers/infiniband/hw/qib/qib_diag.c4
-rw-r--r--drivers/infiniband/hw/qib/qib_file_ops.c3
-rw-r--r--drivers/infiniband/hw/qib/qib_fs.c1
-rw-r--r--drivers/input/evdev.c3
-rw-r--r--drivers/input/input.c1
-rw-r--r--drivers/input/joydev.c1
-rw-r--r--drivers/input/misc/hp_sdc_rtc.c7
-rw-r--r--drivers/input/misc/uinput.c1
-rw-r--r--drivers/input/mousedev.c1
-rw-r--r--drivers/input/serio/serio_raw.c1
-rw-r--r--drivers/isdn/mISDN/timerdev.c1
-rw-r--r--drivers/lguest/lguest_user.c1
-rw-r--r--drivers/macintosh/adb.c10
-rw-r--r--drivers/macintosh/ans-lcd.c1
-rw-r--r--drivers/macintosh/smu.c6
-rw-r--r--drivers/macintosh/via-pmu.c12
-rw-r--r--drivers/md/dm-ioctl.c1
-rw-r--r--drivers/md/dm.c10
-rw-r--r--drivers/md/md.c13
-rw-r--r--drivers/media/IR/imon.c6
-rw-r--r--drivers/media/IR/ir-lirc-codec.c1
-rw-r--r--drivers/media/IR/lirc_dev.c3
-rw-r--r--drivers/media/Kconfig1
-rw-r--r--drivers/media/dvb/bt8xx/dst_ca.c10
-rw-r--r--drivers/media/dvb/dvb-core/dmxdev.c19
-rw-r--r--drivers/media/dvb/dvb-core/dvb_ca_en50221.c9
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c3
-rw-r--r--drivers/media/dvb/dvb-core/dvb_net.c10
-rw-r--r--drivers/media/dvb/dvb-core/dvbdev.c18
-rw-r--r--drivers/media/dvb/firewire/firedtv-ci.c1
-rw-r--r--drivers/media/dvb/ttpci/av7110.c1
-rw-r--r--drivers/media/dvb/ttpci/av7110_av.c2
-rw-r--r--drivers/media/dvb/ttpci/av7110_ca.c1
-rw-r--r--drivers/media/dvb/ttpci/av7110_ir.c1
-rw-r--r--drivers/media/video/dabusb.c18
-rw-r--r--drivers/memstick/core/mspro_block.c11
-rw-r--r--drivers/message/fusion/mptctl.c15
-rw-r--r--drivers/message/i2o/i2o_block.c15
-rw-r--r--drivers/message/i2o/i2o_config.c23
-rw-r--r--drivers/mfd/ab3100-core.c1
-rw-r--r--drivers/misc/hpilo.c1
-rw-r--r--drivers/misc/ibmasm/ibmasmfs.c4
-rw-r--r--drivers/misc/iwmc3200top/debugfs.c3
-rw-r--r--drivers/misc/lkdtm.c9
-rw-r--r--drivers/misc/phantom.c12
-rw-r--r--drivers/misc/sgi-gru/grufile.c1
-rw-r--r--drivers/mmc/card/block.c10
-rw-r--r--drivers/mmc/core/debugfs.c1
-rw-r--r--drivers/mtd/mtd_blkdevs.c14
-rw-r--r--drivers/mtd/mtdchar.c15
-rw-r--r--drivers/mtd/ubi/cdev.c1
-rw-r--r--drivers/net/appletalk/Kconfig1
-rw-r--r--drivers/net/caif/caif_spi.c6
-rw-r--r--drivers/net/cxgb4/cxgb4_main.c1
-rw-r--r--drivers/net/ppp_generic.c3
-rw-r--r--drivers/net/wimax/i2400m/debugfs.c2
-rw-r--r--drivers/net/wireless/airo.c24
-rw-r--r--drivers/net/wireless/ath/ath5k/debug.c7
-rw-r--r--drivers/net/wireless/ath/ath9k/debug.c33
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_main.c9
-rw-r--r--drivers/net/wireless/b43/debugfs.c1
-rw-r--r--drivers/net/wireless/b43legacy/debugfs.c1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-rs.c1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.c3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debugfs.c3
-rw-r--r--drivers/net/wireless/iwmc3200wifi/debugfs.c4
-rw-r--r--drivers/net/wireless/iwmc3200wifi/sdio.c1
-rw-r--r--drivers/net/wireless/libertas/debugfs.c2
-rw-r--r--drivers/net/wireless/ray_cs.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00debug.c5
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_debugfs.c4
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_debugfs.c6
-rw-r--r--drivers/oprofile/oprofile_files.c8
-rw-r--r--drivers/oprofile/oprofilefs.c3
-rw-r--r--drivers/pci/hotplug/cpqphp_sysfs.c13
-rw-r--r--drivers/pci/pcie/aer/aer_inject.c1
-rw-r--r--drivers/platform/x86/sony-laptop.c1
-rw-r--r--drivers/pnp/isapnp/proc.c15
-rw-r--r--drivers/rtc/rtc-m41t80.c14
-rw-r--r--drivers/s390/block/dasd.c6
-rw-r--r--drivers/s390/block/dasd_eer.c1
-rw-r--r--drivers/s390/block/dasd_ioctl.c17
-rw-r--r--drivers/s390/block/dcssblk.c5
-rw-r--r--drivers/s390/char/fs3270.c1
-rw-r--r--drivers/s390/char/monreader.c1
-rw-r--r--drivers/s390/char/monwriter.c1
-rw-r--r--drivers/s390/char/tape_block.c13
-rw-r--r--drivers/s390/char/tape_char.c1
-rw-r--r--drivers/s390/char/vmcp.c1
-rw-r--r--drivers/s390/char/vmlogrdr.c1
-rw-r--r--drivers/s390/char/vmwatchdog.c1
-rw-r--r--drivers/s390/char/zcore.c2
-rw-r--r--drivers/s390/cio/chsc_sch.c1
-rw-r--r--drivers/s390/cio/css.c1
-rw-r--r--drivers/s390/crypto/zcrypt_api.c3
-rw-r--r--drivers/s390/scsi/zfcp_cfdc.c3
-rw-r--r--drivers/sbus/char/display7seg.c1
-rw-r--r--drivers/sbus/char/envctrl.c1
-rw-r--r--drivers/sbus/char/jsflash.c24
-rw-r--r--drivers/scsi/3w-9xxx.c10
-rw-r--r--drivers/scsi/3w-sas.c10
-rw-r--r--drivers/scsi/3w-xxxx.c12
-rw-r--r--drivers/scsi/aacraid/linit.c16
-rw-r--r--drivers/scsi/ch.c9
-rw-r--r--drivers/scsi/dpt_i2o.c19
-rw-r--r--drivers/scsi/gdth.c12
-rw-r--r--drivers/scsi/megaraid.c9
-rw-r--r--drivers/scsi/megaraid/megaraid_mm.c9
-rw-r--r--drivers/scsi/megaraid/megaraid_sas.c3
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_ctl.c12
-rw-r--r--drivers/scsi/osd/osd_uld.c1
-rw-r--r--drivers/scsi/osst.c15
-rw-r--r--drivers/scsi/pmcraid.c1
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c1
-rw-r--r--drivers/scsi/scsi_tgt_if.c3
-rw-r--r--drivers/scsi/sg.c13
-rw-r--r--drivers/scsi/sr.c14
-rw-r--r--drivers/scsi/st.c12
-rw-r--r--drivers/serial/mfd.c2
-rw-r--r--drivers/spi/dw_spi.c1
-rw-r--r--drivers/spi/spidev.c1
-rw-r--r--drivers/staging/comedi/comedi_fops.c1
-rw-r--r--drivers/staging/crystalhd/crystalhd_lnx.c1
-rw-r--r--drivers/staging/cx25821/Kconfig1
-rw-r--r--drivers/staging/dream/camera/msm_camera.c3
-rw-r--r--drivers/staging/dream/pmem.c2
-rw-r--r--drivers/staging/dream/qdsp5/adsp_driver.c1
-rw-r--r--drivers/staging/dream/qdsp5/audio_aac.c1
-rw-r--r--drivers/staging/dream/qdsp5/audio_amrnb.c1
-rw-r--r--drivers/staging/dream/qdsp5/audio_evrc.c1
-rw-r--r--drivers/staging/dream/qdsp5/audio_in.c2
-rw-r--r--drivers/staging/dream/qdsp5/audio_mp3.c1
-rw-r--r--drivers/staging/dream/qdsp5/audio_out.c2
-rw-r--r--drivers/staging/dream/qdsp5/audio_qcelp.c1
-rw-r--r--drivers/staging/dream/qdsp5/evlog.h1
-rw-r--r--drivers/staging/dream/qdsp5/snd.c1
-rw-r--r--drivers/staging/easycap/Kconfig1
-rw-r--r--drivers/staging/frontier/alphatrack.c1
-rw-r--r--drivers/staging/frontier/tranzport.c1
-rw-r--r--drivers/staging/go7007/Kconfig1
-rw-r--r--drivers/staging/hv/blkvsc_drv.c11
-rw-r--r--drivers/staging/iio/industrialio-core.c1
-rw-r--r--drivers/staging/iio/industrialio-ring.c1
-rw-r--r--drivers/staging/lirc/lirc_imon.c3
-rw-r--r--drivers/staging/lirc/lirc_it87.c1
-rw-r--r--drivers/staging/lirc/lirc_sasem.c1
-rw-r--r--drivers/staging/lirc/lirc_serial.c1
-rw-r--r--drivers/staging/lirc/lirc_sir.c1
-rw-r--r--drivers/staging/memrar/memrar_handler.c1
-rw-r--r--drivers/staging/panel/panel.c1
-rw-r--r--drivers/staging/spectra/ffsport.c7
-rw-r--r--drivers/staging/tidspbridge/rmgr/drv_interface.c1
-rw-r--r--drivers/staging/usbip/Kconfig2
-rw-r--r--drivers/telephony/ixj.c10
-rw-r--r--drivers/telephony/phonedev.c1
-rw-r--r--drivers/uio/uio.c1
-rw-r--r--drivers/usb/class/cdc-wdm.c3
-rw-r--r--drivers/usb/class/usblp.c1
-rw-r--r--drivers/usb/class/usbtmc.c1
-rw-r--r--drivers/usb/core/file.c1
-rw-r--r--drivers/usb/gadget/f_hid.c1
-rw-r--r--drivers/usb/gadget/inode.c1
-rw-r--r--drivers/usb/gadget/printer.c3
-rw-r--r--drivers/usb/host/ehci-dbg.c4
-rw-r--r--drivers/usb/host/ohci-dbg.c3
-rw-r--r--drivers/usb/image/mdc800.c1
-rw-r--r--drivers/usb/misc/adutux.c1
-rw-r--r--drivers/usb/misc/idmouse.c1
-rw-r--r--drivers/usb/misc/iowarrior.c1
-rw-r--r--drivers/usb/misc/ldusb.c1
-rw-r--r--drivers/usb/misc/rio500.c1
-rw-r--r--drivers/usb/misc/usblcd.c1
-rw-r--r--drivers/usb/usb-skeleton.c1
-rw-r--r--drivers/vhost/net.c1
-rw-r--r--drivers/video/fbmem.c1
-rw-r--r--drivers/video/mbx/mbxdebugfs.c6
-rw-r--r--drivers/watchdog/ar7_wdt.c1
-rw-r--r--drivers/watchdog/cpwd.c16
-rw-r--r--drivers/watchdog/ep93xx_wdt.c1
-rw-r--r--drivers/watchdog/omap_wdt.c1
-rw-r--r--drivers/xen/evtchn.c1
-rw-r--r--drivers/xen/xenfs/super.c1
-rw-r--r--drivers/xen/xenfs/xenbus.c1
-rw-r--r--fs/Kconfig1
-rw-r--r--fs/adfs/Kconfig1
-rw-r--r--fs/adfs/super.c8
-rw-r--r--fs/affs/super.c14
-rw-r--r--fs/afs/flock.c5
-rw-r--r--fs/afs/mntpt.c1
-rw-r--r--fs/afs/super.c5
-rw-r--r--fs/autofs/Kconfig1
-rw-r--r--fs/autofs/root.c2
-rw-r--r--fs/autofs4/dev-ioctl.c1
-rw-r--r--fs/autofs4/root.c14
-rw-r--r--fs/bfs/inode.c5
-rw-r--r--fs/binfmt_misc.c3
-rw-r--r--fs/btrfs/super.c1
-rw-r--r--fs/cachefiles/daemon.c1
-rw-r--r--fs/char_dev.c1
-rw-r--r--fs/cifs/cifsfs.c13
-rw-r--r--fs/coda/inode.c8
-rw-r--r--fs/coda/pioctl.c1
-rw-r--r--fs/coda/psdev.c1
-rw-r--r--fs/compat_ioctl.c70
-rw-r--r--fs/debugfs/file.c3
-rw-r--r--fs/dlm/debug_fs.c3
-rw-r--r--fs/dlm/plock.c3
-rw-r--r--fs/dlm/user.c3
-rw-r--r--fs/ecryptfs/file.c4
-rw-r--r--fs/ecryptfs/miscdev.c1
-rw-r--r--fs/eventfd.c1
-rw-r--r--fs/eventpoll.c3
-rw-r--r--fs/ext2/super.c6
-rw-r--r--fs/ext3/super.c13
-rw-r--r--fs/ext4/super.c11
-rw-r--r--fs/fat/inode.c5
-rw-r--r--fs/fat/namei_msdos.c6
-rw-r--r--fs/fat/namei_vfat.c6
-rw-r--r--fs/fifo.c1
-rw-r--r--fs/freevxfs/vxfs_lookup.c14
-rw-r--r--fs/freevxfs/vxfs_super.c7
-rw-r--r--fs/fuse/control.c4
-rw-r--r--fs/fuse/cuse.c1
-rw-r--r--fs/gfs2/file.c4
-rw-r--r--fs/hfs/super.c6
-rw-r--r--fs/hpfs/Kconfig1
-rw-r--r--fs/hpfs/super.c8
-rw-r--r--fs/hppfs/hppfs.c1
-rw-r--r--fs/hugetlbfs/inode.c1
-rw-r--r--fs/isofs/dir.c6
-rw-r--r--fs/isofs/inode.c9
-rw-r--r--fs/isofs/isofs.h1
-rw-r--r--fs/isofs/namei.c8
-rw-r--r--fs/isofs/rock.c10
-rw-r--r--fs/jffs2/fs.c4
-rw-r--r--fs/jffs2/super.c9
-rw-r--r--fs/jfs/super.c23
-rw-r--r--fs/locks.c112
-rw-r--r--fs/logfs/dir.c1
-rw-r--r--fs/namespace.c2
-rw-r--r--fs/ncpfs/dir.c221
-rw-r--r--fs/ncpfs/file.c25
-rw-r--r--fs/ncpfs/inode.c55
-rw-r--r--fs/ncpfs/ioctl.c470
-rw-r--r--fs/ncpfs/ncplib_kernel.c101
-rw-r--r--fs/ncpfs/ncplib_kernel.h15
-rw-r--r--fs/ncpfs/ncpsign_kernel.c10
-rw-r--r--fs/ncpfs/sock.c1
-rw-r--r--fs/nfs/Kconfig1
-rw-r--r--fs/nfs/delegation.c10
-rw-r--r--fs/nfs/nfs4state.c10
-rw-r--r--fs/nfsd/Kconfig1
-rw-r--r--fs/nfsd/nfs4state.c6
-rw-r--r--fs/nfsd/nfsctl.c1
-rw-r--r--fs/nilfs2/ioctl.c1
-rw-r--r--fs/nilfs2/super.c10
-rw-r--r--fs/no-block.c1
-rw-r--r--fs/notify/fanotify/fanotify_user.c1
-rw-r--r--fs/notify/inotify/inotify_user.c1
-rw-r--r--fs/ntfs/super.c24
-rw-r--r--fs/ocfs2/dlmfs/dlmfs.c1
-rw-r--r--fs/ocfs2/stack_user.c4
-rw-r--r--fs/ocfs2/super.c7
-rw-r--r--fs/proc/base.c8
-rw-r--r--fs/proc/proc_sysctl.c1
-rw-r--r--fs/proc/root.c1
-rw-r--r--fs/proc/task_mmu.c1
-rw-r--r--fs/qnx4/dir.c4
-rw-r--r--fs/qnx4/inode.c6
-rw-r--r--fs/qnx4/namei.c4
-rw-r--r--fs/read_write.c5
-rw-r--r--fs/romfs/super.c1
-rw-r--r--fs/signalfd.c1
-rw-r--r--fs/smbfs/Kconfig1
-rw-r--r--fs/smbfs/inode.c5
-rw-r--r--fs/squashfs/dir.c3
-rw-r--r--fs/squashfs/super.c5
-rw-r--r--fs/timerfd.c1
-rw-r--r--fs/ubifs/debug.c1
-rw-r--r--fs/udf/Kconfig1
-rw-r--r--fs/udf/super.c8
-rw-r--r--fs/ufs/Kconfig1
-rw-r--r--fs/ufs/super.c5
-rw-r--r--include/asm-generic/atomic.h34
-rw-r--r--include/asm-generic/bitops/find.h39
-rw-r--r--include/asm-generic/fcntl.h2
-rw-r--r--include/asm-generic/io.h26
-rw-r--r--include/asm-generic/kdebug.h2
-rw-r--r--include/asm-generic/system.h20
-rw-r--r--include/linux/bitops.h45
-rw-r--r--include/linux/fs.h15
-rw-r--r--include/linux/ncp_fs.h28
-rw-r--r--include/linux/ncp_fs_sb.h4
-rw-r--r--include/linux/percpu-defs.h12
-rw-r--r--include/linux/smp_lock.h7
-rw-r--r--init/Kconfig2
-rw-r--r--init/main.c2
-rw-r--r--ipc/mqueue.c1
-rw-r--r--ipc/shm.c2
-rw-r--r--kernel/cgroup.c4
-rw-r--r--kernel/configs.c1
-rw-r--r--kernel/gcov/fs.c1
-rw-r--r--kernel/kprobes.c1
-rw-r--r--kernel/pm_qos_params.c1
-rw-r--r--kernel/profile.c1
-rw-r--r--kernel/rtmutex-tester.c6
-rw-r--r--kernel/trace/blktrace.c16
-rw-r--r--kernel/trace/ftrace.c2
-rw-r--r--kernel/trace/ring_buffer.c1
-rw-r--r--kernel/trace/trace_events.c6
-rw-r--r--kernel/trace/trace_stack.c1
-rw-r--r--lib/Kconfig.debug9
-rw-r--r--lib/dma-debug.c1
-rw-r--r--net/atm/proc.c1
-rw-r--r--net/dccp/probe.c1
-rw-r--r--net/ipv4/tcp_probe.c1
-rw-r--r--net/ipx/Kconfig1
-rw-r--r--net/mac80211/debugfs.c21
-rw-r--r--net/mac80211/debugfs_key.c2
-rw-r--r--net/mac80211/debugfs_netdev.c1
-rw-r--r--net/mac80211/debugfs_sta.c2
-rw-r--r--net/mac80211/rate.c1
-rw-r--r--net/mac80211/rc80211_minstrel_debugfs.c1
-rw-r--r--net/mac80211/rc80211_minstrel_ht_debugfs.c3
-rw-r--r--net/mac80211/rc80211_pid_debugfs.c1
-rw-r--r--net/netfilter/xt_recent.c1
-rw-r--r--net/nonet.c1
-rw-r--r--net/rfkill/core.c1
-rw-r--r--net/sctp/probe.c1
-rw-r--r--net/socket.c1
-rw-r--r--net/sunrpc/cache.c17
-rw-r--r--net/sunrpc/rpc_pipe.c26
-rw-r--r--net/wireless/debugfs.c2
-rw-r--r--net/x25/Kconfig1
-rw-r--r--samples/kfifo/bytestream-example.c1
-rw-r--r--samples/kfifo/inttype-example.c1
-rw-r--r--samples/kfifo/record-example.c1
-rw-r--r--samples/tracepoints/tracepoint-sample.c1
-rw-r--r--security/apparmor/apparmorfs.c9
-rw-r--r--security/inode.c1
-rw-r--r--security/smack/smackfs.c5
-rw-r--r--sound/core/seq/oss/seq_oss.c1
-rw-r--r--sound/core/sound.c3
-rw-r--r--sound/oss/msnd_pinnacle.c1
-rw-r--r--sound/soc/soc-core.c1
-rw-r--r--sound/soc/soc-dapm.c1
-rw-r--r--sound/sound_core.c1
-rw-r--r--virt/kvm/kvm_main.c3
535 files changed, 2392 insertions, 1901 deletions
diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
index 910c923a9b86..2861055afd7a 100644
--- a/Documentation/DocBook/drm.tmpl
+++ b/Documentation/DocBook/drm.tmpl
@@ -136,6 +136,7 @@
136#ifdef CONFIG_COMPAT 136#ifdef CONFIG_COMPAT
137 .compat_ioctl = i915_compat_ioctl, 137 .compat_ioctl = i915_compat_ioctl,
138#endif 138#endif
139 .llseek = noop_llseek,
139 }, 140 },
140 .pci_driver = { 141 .pci_driver = {
141 .name = DRIVER_NAME, 142 .name = DRIVER_NAME,
diff --git a/Documentation/x86/x86_64/kernel-stacks b/Documentation/x86/x86_64/kernel-stacks
index 5ad65d51fb95..a01eec5d1d0b 100644
--- a/Documentation/x86/x86_64/kernel-stacks
+++ b/Documentation/x86/x86_64/kernel-stacks
@@ -18,9 +18,9 @@ specialized stacks contain no useful data. The main CPU stacks are:
18 Used for external hardware interrupts. If this is the first external 18 Used for external hardware interrupts. If this is the first external
19 hardware interrupt (i.e. not a nested hardware interrupt) then the 19 hardware interrupt (i.e. not a nested hardware interrupt) then the
20 kernel switches from the current task to the interrupt stack. Like 20 kernel switches from the current task to the interrupt stack. Like
21 the split thread and interrupt stacks on i386 (with CONFIG_4KSTACKS), 21 the split thread and interrupt stacks on i386, this gives more room
22 this gives more room for kernel interrupt processing without having 22 for kernel interrupt processing without having to increase the size
23 to increase the size of every per thread stack. 23 of every per thread stack.
24 24
25 The interrupt stack is also used when processing a softirq. 25 The interrupt stack is also used when processing a softirq.
26 26
diff --git a/arch/arm/kernel/etm.c b/arch/arm/kernel/etm.c
index a48d51257988..11db62806a1a 100644
--- a/arch/arm/kernel/etm.c
+++ b/arch/arm/kernel/etm.c
@@ -329,6 +329,7 @@ static const struct file_operations etb_fops = {
329 .read = etb_read, 329 .read = etb_read,
330 .open = etb_open, 330 .open = etb_open,
331 .release = etb_release, 331 .release = etb_release,
332 .llseek = no_llseek,
332}; 333};
333 334
334static struct miscdevice etb_miscdev = { 335static struct miscdevice etb_miscdev = {
diff --git a/arch/arm/mach-msm/last_radio_log.c b/arch/arm/mach-msm/last_radio_log.c
index b64ba5a98686..1e243f46a969 100644
--- a/arch/arm/mach-msm/last_radio_log.c
+++ b/arch/arm/mach-msm/last_radio_log.c
@@ -48,7 +48,8 @@ static ssize_t last_radio_log_read(struct file *file, char __user *buf,
48} 48}
49 49
50static struct file_operations last_radio_log_fops = { 50static struct file_operations last_radio_log_fops = {
51 .read = last_radio_log_read 51 .read = last_radio_log_read,
52 .llseek = default_llseek,
52}; 53};
53 54
54void msm_init_last_radio_log(struct module *owner) 55void msm_init_last_radio_log(struct module *owner)
diff --git a/arch/arm/mach-msm/smd_debug.c b/arch/arm/mach-msm/smd_debug.c
index 3b2dd717b788..f91c3b7bc655 100644
--- a/arch/arm/mach-msm/smd_debug.c
+++ b/arch/arm/mach-msm/smd_debug.c
@@ -212,6 +212,7 @@ static int debug_open(struct inode *inode, struct file *file)
212static const struct file_operations debug_ops = { 212static const struct file_operations debug_ops = {
213 .read = debug_read, 213 .read = debug_read,
214 .open = debug_open, 214 .open = debug_open,
215 .llseek = default_llseek,
215}; 216};
216 217
217static void debug_create(const char *name, mode_t mode, 218static void debug_create(const char *name, mode_t mode,
diff --git a/arch/arm/plat-mxc/audmux-v2.c b/arch/arm/plat-mxc/audmux-v2.c
index 62920490c0d6..0be1ac7f421b 100644
--- a/arch/arm/plat-mxc/audmux-v2.c
+++ b/arch/arm/plat-mxc/audmux-v2.c
@@ -137,6 +137,7 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf,
137static const struct file_operations audmux_debugfs_fops = { 137static const struct file_operations audmux_debugfs_fops = {
138 .open = audmux_open_file, 138 .open = audmux_open_file,
139 .read = audmux_read_file, 139 .read = audmux_read_file,
140 .llseek = default_llseek,
140}; 141};
141 142
142static void audmux_debugfs_init(void) 143static void audmux_debugfs_init(void)
diff --git a/arch/arm/plat-omap/iommu-debug.c b/arch/arm/plat-omap/iommu-debug.c
index e6c0d536899c..f07cf2f08e09 100644
--- a/arch/arm/plat-omap/iommu-debug.c
+++ b/arch/arm/plat-omap/iommu-debug.c
@@ -328,12 +328,14 @@ static int debug_open_generic(struct inode *inode, struct file *file)
328 .open = debug_open_generic, \ 328 .open = debug_open_generic, \
329 .read = debug_read_##name, \ 329 .read = debug_read_##name, \
330 .write = debug_write_##name, \ 330 .write = debug_write_##name, \
331 .llseek = generic_file_llseek, \
331 }; 332 };
332 333
333#define DEBUG_FOPS_RO(name) \ 334#define DEBUG_FOPS_RO(name) \
334 static const struct file_operations debug_##name##_fops = { \ 335 static const struct file_operations debug_##name##_fops = { \
335 .open = debug_open_generic, \ 336 .open = debug_open_generic, \
336 .read = debug_read_##name, \ 337 .read = debug_read_##name, \
338 .llseek = generic_file_llseek, \
337 }; 339 };
338 340
339DEBUG_FOPS_RO(ver); 341DEBUG_FOPS_RO(ver);
diff --git a/arch/avr32/boards/mimc200/fram.c b/arch/avr32/boards/mimc200/fram.c
index 54fbd95cee9b..9764a1a1073e 100644
--- a/arch/avr32/boards/mimc200/fram.c
+++ b/arch/avr32/boards/mimc200/fram.c
@@ -41,6 +41,7 @@ static int fram_mmap(struct file *filp, struct vm_area_struct *vma)
41static const struct file_operations fram_fops = { 41static const struct file_operations fram_fops = {
42 .owner = THIS_MODULE, 42 .owner = THIS_MODULE,
43 .mmap = fram_mmap, 43 .mmap = fram_mmap,
44 .llseek = noop_llseek,
44}; 45};
45 46
46#define FRAM_MINOR 0 47#define FRAM_MINOR 0
diff --git a/arch/blackfin/kernel/kgdb_test.c b/arch/blackfin/kernel/kgdb_test.c
index 9a4b07594389..08c0236acf3c 100644
--- a/arch/blackfin/kernel/kgdb_test.c
+++ b/arch/blackfin/kernel/kgdb_test.c
@@ -88,6 +88,7 @@ static const struct file_operations kgdb_test_proc_fops = {
88 .owner = THIS_MODULE, 88 .owner = THIS_MODULE,
89 .read = kgdb_test_proc_read, 89 .read = kgdb_test_proc_read,
90 .write = kgdb_test_proc_write, 90 .write = kgdb_test_proc_write,
91 .llseek = noop_llseek,
91}; 92};
92 93
93static int __init kgdbtest_init(void) 94static int __init kgdbtest_init(void)
diff --git a/arch/blackfin/mach-bf561/coreb.c b/arch/blackfin/mach-bf561/coreb.c
index deb2271d09a3..c6a4c8f2d37b 100644
--- a/arch/blackfin/mach-bf561/coreb.c
+++ b/arch/blackfin/mach-bf561/coreb.c
@@ -51,6 +51,7 @@ coreb_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
51static const struct file_operations coreb_fops = { 51static const struct file_operations coreb_fops = {
52 .owner = THIS_MODULE, 52 .owner = THIS_MODULE,
53 .unlocked_ioctl = coreb_ioctl, 53 .unlocked_ioctl = coreb_ioctl,
54 .llseek = noop_llseek,
54}; 55};
55 56
56static struct miscdevice coreb_dev = { 57static struct miscdevice coreb_dev = {
diff --git a/arch/cris/arch-v10/drivers/ds1302.c b/arch/cris/arch-v10/drivers/ds1302.c
index 884275629ef7..3d655dcc65da 100644
--- a/arch/cris/arch-v10/drivers/ds1302.c
+++ b/arch/cris/arch-v10/drivers/ds1302.c
@@ -19,7 +19,7 @@
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/miscdevice.h> 20#include <linux/miscdevice.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/smp_lock.h> 22#include <linux/mutex.h>
23#include <linux/bcd.h> 23#include <linux/bcd.h>
24#include <linux/capability.h> 24#include <linux/capability.h>
25 25
@@ -34,6 +34,7 @@
34 34
35#define RTC_MAJOR_NR 121 /* local major, change later */ 35#define RTC_MAJOR_NR 121 /* local major, change later */
36 36
37static DEFINE_MUTEX(ds1302_mutex);
37static const char ds1302_name[] = "ds1302"; 38static const char ds1302_name[] = "ds1302";
38 39
39/* The DS1302 might be connected to different bits on different products. 40/* The DS1302 might be connected to different bits on different products.
@@ -357,9 +358,9 @@ static long rtc_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned lon
357{ 358{
358 int ret; 359 int ret;
359 360
360 lock_kernel(); 361 mutex_lock(&ds1302_mutex);
361 ret = rtc_ioctl(file, cmd, arg); 362 ret = rtc_ioctl(file, cmd, arg);
362 unlock_kernel(); 363 mutex_unlock(&ds1302_mutex);
363 364
364 return ret; 365 return ret;
365} 366}
@@ -387,6 +388,7 @@ print_rtc_status(void)
387static const struct file_operations rtc_fops = { 388static const struct file_operations rtc_fops = {
388 .owner = THIS_MODULE, 389 .owner = THIS_MODULE,
389 .unlocked_ioctl = rtc_unlocked_ioctl, 390 .unlocked_ioctl = rtc_unlocked_ioctl,
391 .llseek = noop_llseek,
390}; 392};
391 393
392/* Probe for the chip by writing something to its RAM and try reading it back. */ 394/* Probe for the chip by writing something to its RAM and try reading it back. */
diff --git a/arch/cris/arch-v10/drivers/gpio.c b/arch/cris/arch-v10/drivers/gpio.c
index a07b6d25b0c7..a276f0811731 100644
--- a/arch/cris/arch-v10/drivers/gpio.c
+++ b/arch/cris/arch-v10/drivers/gpio.c
@@ -745,6 +745,7 @@ static const struct file_operations gpio_fops = {
745 .write = gpio_write, 745 .write = gpio_write,
746 .open = gpio_open, 746 .open = gpio_open,
747 .release = gpio_release, 747 .release = gpio_release,
748 .llseek = noop_llseek,
748}; 749};
749 750
750static void ioif_watcher(const unsigned int gpio_in_available, 751static void ioif_watcher(const unsigned int gpio_in_available,
diff --git a/arch/cris/arch-v10/drivers/i2c.c b/arch/cris/arch-v10/drivers/i2c.c
index 77a941813819..c413539d4205 100644
--- a/arch/cris/arch-v10/drivers/i2c.c
+++ b/arch/cris/arch-v10/drivers/i2c.c
@@ -617,6 +617,7 @@ static const struct file_operations i2c_fops = {
617 .unlocked_ioctl = i2c_ioctl, 617 .unlocked_ioctl = i2c_ioctl,
618 .open = i2c_open, 618 .open = i2c_open,
619 .release = i2c_release, 619 .release = i2c_release,
620 .llseek = noop_llseek,
620}; 621};
621 622
622int __init 623int __init
diff --git a/arch/cris/arch-v10/drivers/pcf8563.c b/arch/cris/arch-v10/drivers/pcf8563.c
index 7dcb1f85f42b..ea69faba9b62 100644
--- a/arch/cris/arch-v10/drivers/pcf8563.c
+++ b/arch/cris/arch-v10/drivers/pcf8563.c
@@ -27,7 +27,6 @@
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/bcd.h> 28#include <linux/bcd.h>
29#include <linux/mutex.h> 29#include <linux/mutex.h>
30#include <linux/smp_lock.h>
31 30
32#include <asm/uaccess.h> 31#include <asm/uaccess.h>
33#include <asm/system.h> 32#include <asm/system.h>
@@ -49,6 +48,7 @@
49#define rtc_read(x) i2c_readreg(RTC_I2C_READ, x) 48#define rtc_read(x) i2c_readreg(RTC_I2C_READ, x)
50#define rtc_write(x,y) i2c_writereg(RTC_I2C_WRITE, x, y) 49#define rtc_write(x,y) i2c_writereg(RTC_I2C_WRITE, x, y)
51 50
51static DEFINE_MUTEX(pcf8563_mutex);
52static DEFINE_MUTEX(rtc_lock); /* Protect state etc */ 52static DEFINE_MUTEX(rtc_lock); /* Protect state etc */
53 53
54static const unsigned char days_in_month[] = 54static const unsigned char days_in_month[] =
@@ -64,6 +64,7 @@ static int voltage_low;
64static const struct file_operations pcf8563_fops = { 64static const struct file_operations pcf8563_fops = {
65 .owner = THIS_MODULE, 65 .owner = THIS_MODULE,
66 .unlocked_ioctl = pcf8563_unlocked_ioctl, 66 .unlocked_ioctl = pcf8563_unlocked_ioctl,
67 .llseek = noop_llseek,
67}; 68};
68 69
69unsigned char 70unsigned char
@@ -343,9 +344,9 @@ static long pcf8563_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned
343{ 344{
344 int ret; 345 int ret;
345 346
346 lock_kernel(); 347 mutex_lock(&pcf8563_mutex);
347 return pcf8563_ioctl(filp, cmd, arg); 348 return pcf8563_ioctl(filp, cmd, arg);
348 unlock_kernel(); 349 mutex_unlock(&pcf8563_mutex);
349 350
350 return ret; 351 return ret;
351} 352}
diff --git a/arch/cris/arch-v10/drivers/sync_serial.c b/arch/cris/arch-v10/drivers/sync_serial.c
index ee2dd4323daf..399dc1ec8e6f 100644
--- a/arch/cris/arch-v10/drivers/sync_serial.c
+++ b/arch/cris/arch-v10/drivers/sync_serial.c
@@ -20,7 +20,7 @@
20#include <linux/interrupt.h> 20#include <linux/interrupt.h>
21#include <linux/poll.h> 21#include <linux/poll.h>
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/smp_lock.h> 23#include <linux/mutex.h>
24#include <linux/timer.h> 24#include <linux/timer.h>
25#include <asm/irq.h> 25#include <asm/irq.h>
26#include <asm/dma.h> 26#include <asm/dma.h>
@@ -149,6 +149,7 @@ struct sync_port {
149}; 149};
150 150
151 151
152static DEFINE_MUTEX(sync_serial_mutex);
152static int etrax_sync_serial_init(void); 153static int etrax_sync_serial_init(void);
153static void initialize_port(int portnbr); 154static void initialize_port(int portnbr);
154static inline int sync_data_avail(struct sync_port *port); 155static inline int sync_data_avail(struct sync_port *port);
@@ -250,7 +251,8 @@ static const struct file_operations sync_serial_fops = {
250 .poll = sync_serial_poll, 251 .poll = sync_serial_poll,
251 .unlocked_ioctl = sync_serial_ioctl, 252 .unlocked_ioctl = sync_serial_ioctl,
252 .open = sync_serial_open, 253 .open = sync_serial_open,
253 .release = sync_serial_release 254 .release = sync_serial_release,
255 .llseek = noop_llseek,
254}; 256};
255 257
256static int __init etrax_sync_serial_init(void) 258static int __init etrax_sync_serial_init(void)
@@ -445,7 +447,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
445 int mode; 447 int mode;
446 int err = -EBUSY; 448 int err = -EBUSY;
447 449
448 lock_kernel(); 450 mutex_lock(&sync_serial_mutex);
449 DEBUG(printk(KERN_DEBUG "Open sync serial port %d\n", dev)); 451 DEBUG(printk(KERN_DEBUG "Open sync serial port %d\n", dev));
450 452
451 if (dev < 0 || dev >= NUMBER_OF_PORTS || !ports[dev].enabled) { 453 if (dev < 0 || dev >= NUMBER_OF_PORTS || !ports[dev].enabled) {
@@ -626,7 +628,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
626 ret = 0; 628 ret = 0;
627 629
628out: 630out:
629 unlock_kernel(); 631 mutex_unlock(&sync_serial_mutex);
630 return ret; 632 return ret;
631} 633}
632 634
@@ -961,9 +963,9 @@ static long sync_serial_ioctl(struct file *file,
961{ 963{
962 long ret; 964 long ret;
963 965
964 lock_kernel(); 966 mutex_lock(&sync_serial_mutex);
965 ret = sync_serial_ioctl_unlocked(file, cmd, arg); 967 ret = sync_serial_ioctl_unlocked(file, cmd, arg);
966 unlock_kernel(); 968 mutex_unlock(&sync_serial_mutex);
967 969
968 return ret; 970 return ret;
969} 971}
diff --git a/arch/cris/arch-v32/drivers/cryptocop.c b/arch/cris/arch-v32/drivers/cryptocop.c
index b07646a30509..c03bc3bc30c2 100644
--- a/arch/cris/arch-v32/drivers/cryptocop.c
+++ b/arch/cris/arch-v32/drivers/cryptocop.c
@@ -281,7 +281,8 @@ const struct file_operations cryptocop_fops = {
281 .owner = THIS_MODULE, 281 .owner = THIS_MODULE,
282 .open = cryptocop_open, 282 .open = cryptocop_open,
283 .release = cryptocop_release, 283 .release = cryptocop_release,
284 .unlocked_ioctl = cryptocop_ioctl 284 .unlocked_ioctl = cryptocop_ioctl,
285 .llseek = noop_llseek,
285}; 286};
286 287
287 288
@@ -3139,9 +3140,9 @@ cryptocop_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3139 struct inode *inode = file->f_path.dentry->d_inode; 3140 struct inode *inode = file->f_path.dentry->d_inode;
3140 long ret; 3141 long ret;
3141 3142
3142 lock_kernel(); 3143 mutex_lock(&cryptocop_mutex);
3143 ret = cryptocop_ioctl_unlocked(inode, filp, cmd, arg); 3144 ret = cryptocop_ioctl_unlocked(inode, filp, cmd, arg);
3144 unlock_kernel(); 3145 mutex_unlock(&cryptocop_mutex);
3145 3146
3146 return ret; 3147 return ret;
3147} 3148}
diff --git a/arch/cris/arch-v32/drivers/i2c.c b/arch/cris/arch-v32/drivers/i2c.c
index 5a3e900c9a78..ddb23996f11a 100644
--- a/arch/cris/arch-v32/drivers/i2c.c
+++ b/arch/cris/arch-v32/drivers/i2c.c
@@ -698,6 +698,7 @@ static const struct file_operations i2c_fops = {
698 .unlocked_ioctl = i2c_ioctl, 698 .unlocked_ioctl = i2c_ioctl,
699 .open = i2c_open, 699 .open = i2c_open,
700 .release = i2c_release, 700 .release = i2c_release,
701 .llseek = noop_llseek,
701}; 702};
702 703
703static int __init i2c_init(void) 704static int __init i2c_init(void)
diff --git a/arch/cris/arch-v32/drivers/mach-a3/gpio.c b/arch/cris/arch-v32/drivers/mach-a3/gpio.c
index 2dcd27adbad4..c845831e2225 100644
--- a/arch/cris/arch-v32/drivers/mach-a3/gpio.c
+++ b/arch/cris/arch-v32/drivers/mach-a3/gpio.c
@@ -23,7 +23,7 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/spinlock.h> 25#include <linux/spinlock.h>
26#include <linux/smp_lock.h> 26#include <linux/mutex.h>
27 27
28#include <asm/etraxgpio.h> 28#include <asm/etraxgpio.h>
29#include <hwregs/reg_map.h> 29#include <hwregs/reg_map.h>
@@ -66,6 +66,7 @@ static int dp_cnt;
66#define DP(x) 66#define DP(x)
67#endif 67#endif
68 68
69static DEFINE_MUTEX(gpio_mutex);
69static char gpio_name[] = "etrax gpio"; 70static char gpio_name[] = "etrax gpio";
70 71
71#ifdef CONFIG_ETRAX_VIRTUAL_GPIO 72#ifdef CONFIG_ETRAX_VIRTUAL_GPIO
@@ -391,7 +392,7 @@ static int gpio_open(struct inode *inode, struct file *filp)
391 if (!priv) 392 if (!priv)
392 return -ENOMEM; 393 return -ENOMEM;
393 394
394 lock_kernel(); 395 mutex_lock(&gpio_mutex);
395 memset(priv, 0, sizeof(*priv)); 396 memset(priv, 0, sizeof(*priv));
396 397
397 priv->minor = p; 398 priv->minor = p;
@@ -414,7 +415,7 @@ static int gpio_open(struct inode *inode, struct file *filp)
414 spin_unlock_irq(&gpio_lock); 415 spin_unlock_irq(&gpio_lock);
415 } 416 }
416 417
417 unlock_kernel(); 418 mutex_unlock(&gpio_mutex);
418 return 0; 419 return 0;
419} 420}
420 421
@@ -667,9 +668,9 @@ static long gpio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
667{ 668{
668 long ret; 669 long ret;
669 670
670 lock_kernel(); 671 mutex_lock(&gpio_mutex);
671 ret = gpio_ioctl_unlocked(file, cmd, arg); 672 ret = gpio_ioctl_unlocked(file, cmd, arg);
672 unlock_kernel(); 673 mutex_unlock(&gpio_mutex);
673 674
674 return ret; 675 return ret;
675} 676}
@@ -893,6 +894,7 @@ static const struct file_operations gpio_fops = {
893 .write = gpio_write, 894 .write = gpio_write,
894 .open = gpio_open, 895 .open = gpio_open,
895 .release = gpio_release, 896 .release = gpio_release,
897 .llseek = noop_llseek,
896}; 898};
897 899
898#ifdef CONFIG_ETRAX_VIRTUAL_GPIO 900#ifdef CONFIG_ETRAX_VIRTUAL_GPIO
diff --git a/arch/cris/arch-v32/drivers/mach-fs/gpio.c b/arch/cris/arch-v32/drivers/mach-fs/gpio.c
index 5ec8a7d4e7d7..ee90d2659be7 100644
--- a/arch/cris/arch-v32/drivers/mach-fs/gpio.c
+++ b/arch/cris/arch-v32/drivers/mach-fs/gpio.c
@@ -22,7 +22,7 @@
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/spinlock.h> 24#include <linux/spinlock.h>
25#include <linux/smp_lock.h> 25#include <linux/mutex.h>
26 26
27#include <asm/etraxgpio.h> 27#include <asm/etraxgpio.h>
28#include <hwregs/reg_map.h> 28#include <hwregs/reg_map.h>
@@ -64,6 +64,7 @@ static int dp_cnt;
64#define DP(x) 64#define DP(x)
65#endif 65#endif
66 66
67static DEFINE_MUTEX(gpio_mutex);
67static char gpio_name[] = "etrax gpio"; 68static char gpio_name[] = "etrax gpio";
68 69
69#if 0 70#if 0
@@ -429,7 +430,7 @@ gpio_open(struct inode *inode, struct file *filp)
429 if (!priv) 430 if (!priv)
430 return -ENOMEM; 431 return -ENOMEM;
431 432
432 lock_kernel(); 433 mutex_lock(&gpio_mutex);
433 memset(priv, 0, sizeof(*priv)); 434 memset(priv, 0, sizeof(*priv));
434 435
435 priv->minor = p; 436 priv->minor = p;
@@ -450,7 +451,7 @@ gpio_open(struct inode *inode, struct file *filp)
450 alarmlist = priv; 451 alarmlist = priv;
451 spin_unlock_irq(&alarm_lock); 452 spin_unlock_irq(&alarm_lock);
452 453
453 unlock_kernel(); 454 mutex_unlock(&gpio_mutex);
454 return 0; 455 return 0;
455} 456}
456 457
@@ -708,9 +709,9 @@ static long gpio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
708{ 709{
709 long ret; 710 long ret;
710 711
711 lock_kernel(); 712 mutex_lock(&gpio_mutex);
712 ret = gpio_ioctl_unlocked(file, cmd, arg); 713 ret = gpio_ioctl_unlocked(file, cmd, arg);
713 unlock_kernel(); 714 mutex_unlock(&gpio_mutex);
714 715
715 return ret; 716 return ret;
716} 717}
@@ -870,6 +871,7 @@ static const struct file_operations gpio_fops = {
870 .write = gpio_write, 871 .write = gpio_write,
871 .open = gpio_open, 872 .open = gpio_open,
872 .release = gpio_release, 873 .release = gpio_release,
874 .llseek = noop_llseek,
873}; 875};
874 876
875#ifdef CONFIG_ETRAX_VIRTUAL_GPIO 877#ifdef CONFIG_ETRAX_VIRTUAL_GPIO
diff --git a/arch/cris/arch-v32/drivers/pcf8563.c b/arch/cris/arch-v32/drivers/pcf8563.c
index bef6eb53b153..b6e4fc0aad42 100644
--- a/arch/cris/arch-v32/drivers/pcf8563.c
+++ b/arch/cris/arch-v32/drivers/pcf8563.c
@@ -24,7 +24,6 @@
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/fs.h> 25#include <linux/fs.h>
26#include <linux/ioctl.h> 26#include <linux/ioctl.h>
27#include <linux/smp_lock.h>
28#include <linux/delay.h> 27#include <linux/delay.h>
29#include <linux/bcd.h> 28#include <linux/bcd.h>
30#include <linux/mutex.h> 29#include <linux/mutex.h>
@@ -45,6 +44,7 @@
45#define rtc_read(x) i2c_readreg(RTC_I2C_READ, x) 44#define rtc_read(x) i2c_readreg(RTC_I2C_READ, x)
46#define rtc_write(x,y) i2c_writereg(RTC_I2C_WRITE, x, y) 45#define rtc_write(x,y) i2c_writereg(RTC_I2C_WRITE, x, y)
47 46
47static DEFINE_MUTEX(pcf8563_mutex);
48static DEFINE_MUTEX(rtc_lock); /* Protect state etc */ 48static DEFINE_MUTEX(rtc_lock); /* Protect state etc */
49 49
50static const unsigned char days_in_month[] = 50static const unsigned char days_in_month[] =
@@ -60,6 +60,7 @@ static int voltage_low;
60static const struct file_operations pcf8563_fops = { 60static const struct file_operations pcf8563_fops = {
61 .owner = THIS_MODULE, 61 .owner = THIS_MODULE,
62 .unlocked_ioctl = pcf8563_unlocked_ioctl, 62 .unlocked_ioctl = pcf8563_unlocked_ioctl,
63 .llseek = noop_llseek,
63}; 64};
64 65
65unsigned char 66unsigned char
@@ -339,9 +340,9 @@ static long pcf8563_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned
339{ 340{
340 int ret; 341 int ret;
341 342
342 lock_kernel(); 343 mutex_lock(&pcf8563_mutex);
343 return pcf8563_ioctl(filp, cmd, arg); 344 return pcf8563_ioctl(filp, cmd, arg);
344 unlock_kernel(); 345 mutex_unlock(&pcf8563_mutex);
345 346
346 return ret; 347 return ret;
347} 348}
diff --git a/arch/cris/arch-v32/drivers/sync_serial.c b/arch/cris/arch-v32/drivers/sync_serial.c
index ca248f3adb80..c8637a9195ea 100644
--- a/arch/cris/arch-v32/drivers/sync_serial.c
+++ b/arch/cris/arch-v32/drivers/sync_serial.c
@@ -13,7 +13,7 @@
13#include <linux/errno.h> 13#include <linux/errno.h>
14#include <linux/major.h> 14#include <linux/major.h>
15#include <linux/sched.h> 15#include <linux/sched.h>
16#include <linux/smp_lock.h> 16#include <linux/mutex.h>
17#include <linux/interrupt.h> 17#include <linux/interrupt.h>
18#include <linux/poll.h> 18#include <linux/poll.h>
19#include <linux/init.h> 19#include <linux/init.h>
@@ -145,6 +145,7 @@ typedef struct sync_port
145 spinlock_t lock; 145 spinlock_t lock;
146} sync_port; 146} sync_port;
147 147
148static DEFINE_MUTEX(sync_serial_mutex);
148static int etrax_sync_serial_init(void); 149static int etrax_sync_serial_init(void);
149static void initialize_port(int portnbr); 150static void initialize_port(int portnbr);
150static inline int sync_data_avail(struct sync_port *port); 151static inline int sync_data_avail(struct sync_port *port);
@@ -247,7 +248,8 @@ static const struct file_operations sync_serial_fops = {
247 .poll = sync_serial_poll, 248 .poll = sync_serial_poll,
248 .unlocked_ioctl = sync_serial_ioctl, 249 .unlocked_ioctl = sync_serial_ioctl,
249 .open = sync_serial_open, 250 .open = sync_serial_open,
250 .release = sync_serial_release 251 .release = sync_serial_release,
252 .llseek = noop_llseek,
251}; 253};
252 254
253static int __init etrax_sync_serial_init(void) 255static int __init etrax_sync_serial_init(void)
@@ -434,7 +436,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
434 reg_dma_rw_cfg cfg = {.en = regk_dma_yes}; 436 reg_dma_rw_cfg cfg = {.en = regk_dma_yes};
435 reg_dma_rw_intr_mask intr_mask = {.data = regk_dma_yes}; 437 reg_dma_rw_intr_mask intr_mask = {.data = regk_dma_yes};
436 438
437 lock_kernel(); 439 mutex_lock(&sync_serial_mutex);
438 DEBUG(printk(KERN_DEBUG "Open sync serial port %d\n", dev)); 440 DEBUG(printk(KERN_DEBUG "Open sync serial port %d\n", dev));
439 441
440 if (dev < 0 || dev >= NBR_PORTS || !ports[dev].enabled) 442 if (dev < 0 || dev >= NBR_PORTS || !ports[dev].enabled)
@@ -583,7 +585,7 @@ static int sync_serial_open(struct inode *inode, struct file *file)
583 port->busy++; 585 port->busy++;
584 ret = 0; 586 ret = 0;
585out: 587out:
586 unlock_kernel(); 588 mutex_unlock(&sync_serial_mutex);
587 return ret; 589 return ret;
588} 590}
589 591
@@ -966,9 +968,9 @@ static long sync_serial_ioctl(struct file *file,
966{ 968{
967 long ret; 969 long ret;
968 970
969 lock_kernel(); 971 mutex_lock(&sync_serial_mutex);
970 ret = sync_serial_ioctl_unlocked(file, cmd, arg); 972 ret = sync_serial_ioctl_unlocked(file, cmd, arg);
971 unlock_kernel(); 973 mutex_unlock(&sync_serial_mutex);
972 974
973 return ret; 975 return ret;
974} 976}
diff --git a/arch/cris/kernel/profile.c b/arch/cris/kernel/profile.c
index 195ec5fa0dd2..b82e08615d1b 100644
--- a/arch/cris/kernel/profile.c
+++ b/arch/cris/kernel/profile.c
@@ -59,6 +59,7 @@ write_cris_profile(struct file *file, const char __user *buf,
59static const struct file_operations cris_proc_profile_operations = { 59static const struct file_operations cris_proc_profile_operations = {
60 .read = read_cris_profile, 60 .read = read_cris_profile,
61 .write = write_cris_profile, 61 .write = write_cris_profile,
62 .llseek = default_llseek,
62}; 63};
63 64
64static int __init init_cris_profile(void) 65static int __init init_cris_profile(void)
diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
index 45d7543b69cc..79802e540e53 100644
--- a/arch/ia64/kernel/salinfo.c
+++ b/arch/ia64/kernel/salinfo.c
@@ -354,6 +354,7 @@ retry:
354static const struct file_operations salinfo_event_fops = { 354static const struct file_operations salinfo_event_fops = {
355 .open = salinfo_event_open, 355 .open = salinfo_event_open,
356 .read = salinfo_event_read, 356 .read = salinfo_event_read,
357 .llseek = noop_llseek,
357}; 358};
358 359
359static int 360static int
@@ -571,6 +572,7 @@ static const struct file_operations salinfo_data_fops = {
571 .release = salinfo_log_release, 572 .release = salinfo_log_release,
572 .read = salinfo_log_read, 573 .read = salinfo_log_read,
573 .write = salinfo_log_write, 574 .write = salinfo_log_write,
575 .llseek = default_llseek,
574}; 576};
575 577
576static int __cpuinit 578static int __cpuinit
diff --git a/arch/ia64/sn/kernel/sn2/sn_hwperf.c b/arch/ia64/sn/kernel/sn2/sn_hwperf.c
index fa1eceed0d23..30862c0358cd 100644
--- a/arch/ia64/sn/kernel/sn2/sn_hwperf.c
+++ b/arch/ia64/sn/kernel/sn2/sn_hwperf.c
@@ -860,6 +860,7 @@ error:
860 860
861static const struct file_operations sn_hwperf_fops = { 861static const struct file_operations sn_hwperf_fops = {
862 .unlocked_ioctl = sn_hwperf_ioctl, 862 .unlocked_ioctl = sn_hwperf_ioctl,
863 .llseek = noop_llseek,
863}; 864};
864 865
865static struct miscdevice sn_hwperf_dev = { 866static struct miscdevice sn_hwperf_dev = {
diff --git a/arch/m68k/bvme6000/rtc.c b/arch/m68k/bvme6000/rtc.c
index cb8617bb194b..1c4d4c7bf4d4 100644
--- a/arch/m68k/bvme6000/rtc.c
+++ b/arch/m68k/bvme6000/rtc.c
@@ -155,6 +155,7 @@ static const struct file_operations rtc_fops = {
155 .unlocked_ioctl = rtc_ioctl, 155 .unlocked_ioctl = rtc_ioctl,
156 .open = rtc_open, 156 .open = rtc_open,
157 .release = rtc_release, 157 .release = rtc_release,
158 .llseek = noop_llseek,
158}; 159};
159 160
160static struct miscdevice rtc_dev = { 161static struct miscdevice rtc_dev = {
diff --git a/arch/m68k/mvme16x/rtc.c b/arch/m68k/mvme16x/rtc.c
index 11ac6f63967a..39c79ebcd18a 100644
--- a/arch/m68k/mvme16x/rtc.c
+++ b/arch/m68k/mvme16x/rtc.c
@@ -144,6 +144,7 @@ static const struct file_operations rtc_fops = {
144 .unlocked_ioctl = rtc_ioctl, 144 .unlocked_ioctl = rtc_ioctl,
145 .open = rtc_open, 145 .open = rtc_open,
146 .release = rtc_release, 146 .release = rtc_release,
147 .llseek = noop_llseek,
147}; 148};
148 149
149static struct miscdevice rtc_dev= 150static struct miscdevice rtc_dev=
diff --git a/arch/mips/kernel/rtlx.c b/arch/mips/kernel/rtlx.c
index 26f9b9ab19cc..557ef72472e0 100644
--- a/arch/mips/kernel/rtlx.c
+++ b/arch/mips/kernel/rtlx.c
@@ -468,7 +468,8 @@ static const struct file_operations rtlx_fops = {
468 .release = file_release, 468 .release = file_release,
469 .write = file_write, 469 .write = file_write,
470 .read = file_read, 470 .read = file_read,
471 .poll = file_poll 471 .poll = file_poll,
472 .llseek = noop_llseek,
472}; 473};
473 474
474static struct irqaction rtlx_irq = { 475static struct irqaction rtlx_irq = {
diff --git a/arch/mips/kernel/vpe.c b/arch/mips/kernel/vpe.c
index 2bd2151c586a..3eb3cde2f661 100644
--- a/arch/mips/kernel/vpe.c
+++ b/arch/mips/kernel/vpe.c
@@ -1192,7 +1192,8 @@ static const struct file_operations vpe_fops = {
1192 .owner = THIS_MODULE, 1192 .owner = THIS_MODULE,
1193 .open = vpe_open, 1193 .open = vpe_open,
1194 .release = vpe_release, 1194 .release = vpe_release,
1195 .write = vpe_write 1195 .write = vpe_write,
1196 .llseek = noop_llseek,
1196}; 1197};
1197 1198
1198/* module wrapper entry points */ 1199/* module wrapper entry points */
diff --git a/arch/mips/sibyte/common/sb_tbprof.c b/arch/mips/sibyte/common/sb_tbprof.c
index d4ed7a9156f5..ca35b730d189 100644
--- a/arch/mips/sibyte/common/sb_tbprof.c
+++ b/arch/mips/sibyte/common/sb_tbprof.c
@@ -545,6 +545,7 @@ static const struct file_operations sbprof_tb_fops = {
545 .unlocked_ioctl = sbprof_tb_ioctl, 545 .unlocked_ioctl = sbprof_tb_ioctl,
546 .compat_ioctl = sbprof_tb_ioctl, 546 .compat_ioctl = sbprof_tb_ioctl,
547 .mmap = NULL, 547 .mmap = NULL,
548 .llseek = default_llseek,
548}; 549};
549 550
550static struct class *tb_class; 551static struct class *tb_class;
diff --git a/arch/parisc/kernel/perf.c b/arch/parisc/kernel/perf.c
index f9f6783e4bdd..ba0c053e25ae 100644
--- a/arch/parisc/kernel/perf.c
+++ b/arch/parisc/kernel/perf.c
@@ -46,7 +46,6 @@
46#include <linux/init.h> 46#include <linux/init.h>
47#include <linux/proc_fs.h> 47#include <linux/proc_fs.h>
48#include <linux/miscdevice.h> 48#include <linux/miscdevice.h>
49#include <linux/smp_lock.h>
50#include <linux/spinlock.h> 49#include <linux/spinlock.h>
51 50
52#include <asm/uaccess.h> 51#include <asm/uaccess.h>
@@ -261,16 +260,13 @@ printk("Preparing to start counters\n");
261 */ 260 */
262static int perf_open(struct inode *inode, struct file *file) 261static int perf_open(struct inode *inode, struct file *file)
263{ 262{
264 lock_kernel();
265 spin_lock(&perf_lock); 263 spin_lock(&perf_lock);
266 if (perf_enabled) { 264 if (perf_enabled) {
267 spin_unlock(&perf_lock); 265 spin_unlock(&perf_lock);
268 unlock_kernel();
269 return -EBUSY; 266 return -EBUSY;
270 } 267 }
271 perf_enabled = 1; 268 perf_enabled = 1;
272 spin_unlock(&perf_lock); 269 spin_unlock(&perf_lock);
273 unlock_kernel();
274 270
275 return 0; 271 return 0;
276} 272}
diff --git a/arch/powerpc/kernel/lparcfg.c b/arch/powerpc/kernel/lparcfg.c
index 8d9e3b9cda64..16468362ad57 100644
--- a/arch/powerpc/kernel/lparcfg.c
+++ b/arch/powerpc/kernel/lparcfg.c
@@ -780,6 +780,7 @@ static const struct file_operations lparcfg_fops = {
780 .write = lparcfg_write, 780 .write = lparcfg_write,
781 .open = lparcfg_open, 781 .open = lparcfg_open,
782 .release = single_release, 782 .release = single_release,
783 .llseek = seq_lseek,
783}; 784};
784 785
785static int __init lparcfg_init(void) 786static int __init lparcfg_init(void)
diff --git a/arch/powerpc/kernel/rtas_flash.c b/arch/powerpc/kernel/rtas_flash.c
index 67a84d8f118d..2b442e6c21e6 100644
--- a/arch/powerpc/kernel/rtas_flash.c
+++ b/arch/powerpc/kernel/rtas_flash.c
@@ -716,6 +716,7 @@ static const struct file_operations rtas_flash_operations = {
716 .write = rtas_flash_write, 716 .write = rtas_flash_write,
717 .open = rtas_excl_open, 717 .open = rtas_excl_open,
718 .release = rtas_flash_release, 718 .release = rtas_flash_release,
719 .llseek = default_llseek,
719}; 720};
720 721
721static const struct file_operations manage_flash_operations = { 722static const struct file_operations manage_flash_operations = {
@@ -724,6 +725,7 @@ static const struct file_operations manage_flash_operations = {
724 .write = manage_flash_write, 725 .write = manage_flash_write,
725 .open = rtas_excl_open, 726 .open = rtas_excl_open,
726 .release = rtas_excl_release, 727 .release = rtas_excl_release,
728 .llseek = default_llseek,
727}; 729};
728 730
729static const struct file_operations validate_flash_operations = { 731static const struct file_operations validate_flash_operations = {
@@ -732,6 +734,7 @@ static const struct file_operations validate_flash_operations = {
732 .write = validate_flash_write, 734 .write = validate_flash_write,
733 .open = rtas_excl_open, 735 .open = rtas_excl_open,
734 .release = validate_flash_release, 736 .release = validate_flash_release,
737 .llseek = default_llseek,
735}; 738};
736 739
737static int __init rtas_flash_init(void) 740static int __init rtas_flash_init(void)
diff --git a/arch/powerpc/kernel/rtasd.c b/arch/powerpc/kernel/rtasd.c
index 638883e23e3a..0438f819fe6b 100644
--- a/arch/powerpc/kernel/rtasd.c
+++ b/arch/powerpc/kernel/rtasd.c
@@ -354,6 +354,7 @@ static const struct file_operations proc_rtas_log_operations = {
354 .poll = rtas_log_poll, 354 .poll = rtas_log_poll,
355 .open = rtas_log_open, 355 .open = rtas_log_open,
356 .release = rtas_log_release, 356 .release = rtas_log_release,
357 .llseek = noop_llseek,
357}; 358};
358 359
359static int enable_surveillance(int timeout) 360static int enable_surveillance(int timeout)
diff --git a/arch/powerpc/platforms/iseries/mf.c b/arch/powerpc/platforms/iseries/mf.c
index 33e5fc7334fc..42d0a886de05 100644
--- a/arch/powerpc/platforms/iseries/mf.c
+++ b/arch/powerpc/platforms/iseries/mf.c
@@ -1249,6 +1249,7 @@ out:
1249 1249
1250static const struct file_operations proc_vmlinux_operations = { 1250static const struct file_operations proc_vmlinux_operations = {
1251 .write = proc_mf_change_vmlinux, 1251 .write = proc_mf_change_vmlinux,
1252 .llseek = default_llseek,
1252}; 1253};
1253 1254
1254static int __init mf_proc_init(void) 1255static int __init mf_proc_init(void)
diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c
index 57ddbb43b33a..1de2cbb92303 100644
--- a/arch/powerpc/platforms/pseries/reconfig.c
+++ b/arch/powerpc/platforms/pseries/reconfig.c
@@ -539,7 +539,8 @@ out:
539} 539}
540 540
541static const struct file_operations ofdt_fops = { 541static const struct file_operations ofdt_fops = {
542 .write = ofdt_write 542 .write = ofdt_write,
543 .llseek = noop_llseek,
543}; 544};
544 545
545/* create /proc/powerpc/ofdt write-only by root */ 546/* create /proc/powerpc/ofdt write-only by root */
diff --git a/arch/powerpc/platforms/pseries/scanlog.c b/arch/powerpc/platforms/pseries/scanlog.c
index 80e9e7652a4d..554457294a2b 100644
--- a/arch/powerpc/platforms/pseries/scanlog.c
+++ b/arch/powerpc/platforms/pseries/scanlog.c
@@ -170,6 +170,7 @@ const struct file_operations scanlog_fops = {
170 .write = scanlog_write, 170 .write = scanlog_write,
171 .open = scanlog_open, 171 .open = scanlog_open,
172 .release = scanlog_release, 172 .release = scanlog_release,
173 .llseek = noop_llseek,
173}; 174};
174 175
175static int __init scanlog_init(void) 176static int __init scanlog_init(void)
diff --git a/arch/s390/crypto/prng.c b/arch/s390/crypto/prng.c
index aa819dac2360..975e3ab13cb5 100644
--- a/arch/s390/crypto/prng.c
+++ b/arch/s390/crypto/prng.c
@@ -152,6 +152,7 @@ static const struct file_operations prng_fops = {
152 .open = &prng_open, 152 .open = &prng_open,
153 .release = NULL, 153 .release = NULL,
154 .read = &prng_read, 154 .read = &prng_read,
155 .llseek = noop_llseek,
155}; 156};
156 157
157static struct miscdevice prng_dev = { 158static struct miscdevice prng_dev = {
diff --git a/arch/s390/hypfs/hypfs_diag.c b/arch/s390/hypfs/hypfs_diag.c
index 1211bb1d2f24..020e51c063d2 100644
--- a/arch/s390/hypfs/hypfs_diag.c
+++ b/arch/s390/hypfs/hypfs_diag.c
@@ -618,6 +618,7 @@ static const struct file_operations dbfs_d204_ops = {
618 .open = dbfs_d204_open, 618 .open = dbfs_d204_open,
619 .read = dbfs_d204_read, 619 .read = dbfs_d204_read,
620 .release = dbfs_d204_release, 620 .release = dbfs_d204_release,
621 .llseek = no_llseek,
621}; 622};
622 623
623static int hypfs_dbfs_init(void) 624static int hypfs_dbfs_init(void)
diff --git a/arch/s390/hypfs/hypfs_vm.c b/arch/s390/hypfs/hypfs_vm.c
index ee5ab1a578e7..26cf177f6a3a 100644
--- a/arch/s390/hypfs/hypfs_vm.c
+++ b/arch/s390/hypfs/hypfs_vm.c
@@ -275,6 +275,7 @@ static const struct file_operations dbfs_d2fc_ops = {
275 .open = dbfs_d2fc_open, 275 .open = dbfs_d2fc_open,
276 .read = dbfs_d2fc_read, 276 .read = dbfs_d2fc_read,
277 .release = dbfs_d2fc_release, 277 .release = dbfs_d2fc_release,
278 .llseek = no_llseek,
278}; 279};
279 280
280int hypfs_vm_init(void) 281int hypfs_vm_init(void)
diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c
index 98a4a4c267a7..74d98670be27 100644
--- a/arch/s390/hypfs/inode.c
+++ b/arch/s390/hypfs/inode.c
@@ -449,6 +449,7 @@ static const struct file_operations hypfs_file_ops = {
449 .write = do_sync_write, 449 .write = do_sync_write,
450 .aio_read = hypfs_aio_read, 450 .aio_read = hypfs_aio_read,
451 .aio_write = hypfs_aio_write, 451 .aio_write = hypfs_aio_write,
452 .llseek = no_llseek,
452}; 453};
453 454
454static struct file_system_type hypfs_type = { 455static struct file_system_type hypfs_type = {
diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
index 98192261491d..5ad6bc078bfd 100644
--- a/arch/s390/kernel/debug.c
+++ b/arch/s390/kernel/debug.c
@@ -174,6 +174,7 @@ static const struct file_operations debug_file_ops = {
174 .write = debug_input, 174 .write = debug_input,
175 .open = debug_open, 175 .open = debug_open,
176 .release = debug_close, 176 .release = debug_close,
177 .llseek = no_llseek,
177}; 178};
178 179
179static struct dentry *debug_debugfs_root_entry; 180static struct dentry *debug_debugfs_root_entry;
diff --git a/arch/sh/boards/mach-landisk/gio.c b/arch/sh/boards/mach-landisk/gio.c
index 01e6abb769b9..8132dff078fb 100644
--- a/arch/sh/boards/mach-landisk/gio.c
+++ b/arch/sh/boards/mach-landisk/gio.c
@@ -128,6 +128,7 @@ static const struct file_operations gio_fops = {
128 .open = gio_open, /* open */ 128 .open = gio_open, /* open */
129 .release = gio_close, /* release */ 129 .release = gio_close, /* release */
130 .unlocked_ioctl = gio_ioctl, 130 .unlocked_ioctl = gio_ioctl,
131 .llseek = noop_llseek,
131}; 132};
132 133
133static int __init gio_init(void) 134static int __init gio_init(void)
diff --git a/arch/sparc/kernel/apc.c b/arch/sparc/kernel/apc.c
index 2c0046ecc715..52de4a9424e8 100644
--- a/arch/sparc/kernel/apc.c
+++ b/arch/sparc/kernel/apc.c
@@ -132,6 +132,7 @@ static const struct file_operations apc_fops = {
132 .unlocked_ioctl = apc_ioctl, 132 .unlocked_ioctl = apc_ioctl,
133 .open = apc_open, 133 .open = apc_open,
134 .release = apc_release, 134 .release = apc_release,
135 .llseek = noop_llseek,
135}; 136};
136 137
137static struct miscdevice apc_miscdev = { APC_MINOR, APC_DEVNAME, &apc_fops }; 138static struct miscdevice apc_miscdev = { APC_MINOR, APC_DEVNAME, &apc_fops };
diff --git a/arch/sparc/kernel/mdesc.c b/arch/sparc/kernel/mdesc.c
index 83e85c2e802a..6addb914fcc8 100644
--- a/arch/sparc/kernel/mdesc.c
+++ b/arch/sparc/kernel/mdesc.c
@@ -890,6 +890,7 @@ static ssize_t mdesc_read(struct file *file, char __user *buf,
890static const struct file_operations mdesc_fops = { 890static const struct file_operations mdesc_fops = {
891 .read = mdesc_read, 891 .read = mdesc_read,
892 .owner = THIS_MODULE, 892 .owner = THIS_MODULE,
893 .llseek = noop_llseek,
893}; 894};
894 895
895static struct miscdevice mdesc_misc = { 896static struct miscdevice mdesc_misc = {
diff --git a/arch/tile/include/asm/bitops.h b/arch/tile/include/asm/bitops.h
index 6832b4be8990..6d4f0ff2c68c 100644
--- a/arch/tile/include/asm/bitops.h
+++ b/arch/tile/include/asm/bitops.h
@@ -120,6 +120,7 @@ static inline unsigned long __arch_hweight64(__u64 w)
120 120
121#include <asm-generic/bitops/const_hweight.h> 121#include <asm-generic/bitops/const_hweight.h>
122#include <asm-generic/bitops/lock.h> 122#include <asm-generic/bitops/lock.h>
123#include <asm-generic/bitops/find.h>
123#include <asm-generic/bitops/sched.h> 124#include <asm-generic/bitops/sched.h>
124#include <asm-generic/bitops/ext2-non-atomic.h> 125#include <asm-generic/bitops/ext2-non-atomic.h>
125#include <asm-generic/bitops/minix.h> 126#include <asm-generic/bitops/minix.h>
diff --git a/arch/tile/kernel/hardwall.c b/arch/tile/kernel/hardwall.c
index 584b965dc824..1e54a7843410 100644
--- a/arch/tile/kernel/hardwall.c
+++ b/arch/tile/kernel/hardwall.c
@@ -774,6 +774,7 @@ static const struct file_operations dev_hardwall_fops = {
774#endif 774#endif
775 .flush = hardwall_flush, 775 .flush = hardwall_flush,
776 .release = hardwall_release, 776 .release = hardwall_release,
777 .llseek = noop_llseek,
777}; 778};
778 779
779static struct cdev hardwall_dev; 780static struct cdev hardwall_dev;
diff --git a/arch/um/drivers/harddog_kern.c b/arch/um/drivers/harddog_kern.c
index cfcac1ff4cf2..2d0266d0254d 100644
--- a/arch/um/drivers/harddog_kern.c
+++ b/arch/um/drivers/harddog_kern.c
@@ -42,7 +42,7 @@
42#include <linux/miscdevice.h> 42#include <linux/miscdevice.h>
43#include <linux/watchdog.h> 43#include <linux/watchdog.h>
44#include <linux/reboot.h> 44#include <linux/reboot.h>
45#include <linux/smp_lock.h> 45#include <linux/mutex.h>
46#include <linux/init.h> 46#include <linux/init.h>
47#include <linux/spinlock.h> 47#include <linux/spinlock.h>
48#include <asm/uaccess.h> 48#include <asm/uaccess.h>
@@ -50,6 +50,7 @@
50 50
51MODULE_LICENSE("GPL"); 51MODULE_LICENSE("GPL");
52 52
53static DEFINE_MUTEX(harddog_mutex);
53static DEFINE_SPINLOCK(lock); 54static DEFINE_SPINLOCK(lock);
54static int timer_alive; 55static int timer_alive;
55static int harddog_in_fd = -1; 56static int harddog_in_fd = -1;
@@ -66,7 +67,7 @@ static int harddog_open(struct inode *inode, struct file *file)
66 int err = -EBUSY; 67 int err = -EBUSY;
67 char *sock = NULL; 68 char *sock = NULL;
68 69
69 lock_kernel(); 70 mutex_lock(&harddog_mutex);
70 spin_lock(&lock); 71 spin_lock(&lock);
71 if(timer_alive) 72 if(timer_alive)
72 goto err; 73 goto err;
@@ -83,11 +84,11 @@ static int harddog_open(struct inode *inode, struct file *file)
83 84
84 timer_alive = 1; 85 timer_alive = 1;
85 spin_unlock(&lock); 86 spin_unlock(&lock);
86 unlock_kernel(); 87 mutex_unlock(&harddog_mutex);
87 return nonseekable_open(inode, file); 88 return nonseekable_open(inode, file);
88err: 89err:
89 spin_unlock(&lock); 90 spin_unlock(&lock);
90 unlock_kernel(); 91 mutex_unlock(&harddog_mutex);
91 return err; 92 return err;
92} 93}
93 94
@@ -153,9 +154,9 @@ static long harddog_ioctl(struct file *file,
153{ 154{
154 long ret; 155 long ret;
155 156
156 lock_kernel(); 157 mutex_lock(&harddog_mutex);
157 ret = harddog_ioctl_unlocked(file, cmd, arg); 158 ret = harddog_ioctl_unlocked(file, cmd, arg);
158 unlock_kernel(); 159 mutex_unlock(&harddog_mutex);
159 160
160 return ret; 161 return ret;
161} 162}
@@ -166,6 +167,7 @@ static const struct file_operations harddog_fops = {
166 .unlocked_ioctl = harddog_ioctl, 167 .unlocked_ioctl = harddog_ioctl,
167 .open = harddog_open, 168 .open = harddog_open,
168 .release = harddog_release, 169 .release = harddog_release,
170 .llseek = no_llseek,
169}; 171};
170 172
171static struct miscdevice harddog_miscdev = { 173static struct miscdevice harddog_miscdev = {
diff --git a/arch/um/drivers/hostaudio_kern.c b/arch/um/drivers/hostaudio_kern.c
index 63c740a85b4c..f9f6a4e20590 100644
--- a/arch/um/drivers/hostaudio_kern.c
+++ b/arch/um/drivers/hostaudio_kern.c
@@ -8,7 +8,7 @@
8#include "linux/slab.h" 8#include "linux/slab.h"
9#include "linux/sound.h" 9#include "linux/sound.h"
10#include "linux/soundcard.h" 10#include "linux/soundcard.h"
11#include "linux/smp_lock.h" 11#include "linux/mutex.h"
12#include "asm/uaccess.h" 12#include "asm/uaccess.h"
13#include "init.h" 13#include "init.h"
14#include "os.h" 14#include "os.h"
@@ -63,6 +63,8 @@ static int set_mixer(char *name, int *add)
63__uml_setup("mixer=", set_mixer, "mixer=<mixer device>\n" MIXER_HELP); 63__uml_setup("mixer=", set_mixer, "mixer=<mixer device>\n" MIXER_HELP);
64#endif 64#endif
65 65
66static DEFINE_MUTEX(hostaudio_mutex);
67
66/* /dev/dsp file operations */ 68/* /dev/dsp file operations */
67 69
68static ssize_t hostaudio_read(struct file *file, char __user *buffer, 70static ssize_t hostaudio_read(struct file *file, char __user *buffer,
@@ -198,9 +200,9 @@ static int hostaudio_open(struct inode *inode, struct file *file)
198 w = 1; 200 w = 1;
199 201
200 kparam_block_sysfs_write(dsp); 202 kparam_block_sysfs_write(dsp);
201 lock_kernel(); 203 mutex_lock(&hostaudio_mutex);
202 ret = os_open_file(dsp, of_set_rw(OPENFLAGS(), r, w), 0); 204 ret = os_open_file(dsp, of_set_rw(OPENFLAGS(), r, w), 0);
203 unlock_kernel(); 205 mutex_unlock(&hostaudio_mutex);
204 kparam_unblock_sysfs_write(dsp); 206 kparam_unblock_sysfs_write(dsp);
205 207
206 if (ret < 0) { 208 if (ret < 0) {
@@ -259,9 +261,9 @@ static int hostmixer_open_mixdev(struct inode *inode, struct file *file)
259 w = 1; 261 w = 1;
260 262
261 kparam_block_sysfs_write(mixer); 263 kparam_block_sysfs_write(mixer);
262 lock_kernel(); 264 mutex_lock(&hostaudio_mutex);
263 ret = os_open_file(mixer, of_set_rw(OPENFLAGS(), r, w), 0); 265 ret = os_open_file(mixer, of_set_rw(OPENFLAGS(), r, w), 0);
264 unlock_kernel(); 266 mutex_unlock(&hostaudio_mutex);
265 kparam_unblock_sysfs_write(mixer); 267 kparam_unblock_sysfs_write(mixer);
266 268
267 if (ret < 0) { 269 if (ret < 0) {
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index ebc680717e59..975613b23dcf 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -843,6 +843,7 @@ static ssize_t mconsole_proc_write(struct file *file,
843static const struct file_operations mconsole_proc_fops = { 843static const struct file_operations mconsole_proc_fops = {
844 .owner = THIS_MODULE, 844 .owner = THIS_MODULE,
845 .write = mconsole_proc_write, 845 .write = mconsole_proc_write,
846 .llseek = noop_llseek,
846}; 847};
847 848
848static int create_proc_mconsole(void) 849static int create_proc_mconsole(void)
diff --git a/arch/um/drivers/mmapper_kern.c b/arch/um/drivers/mmapper_kern.c
index 7158393b6793..8501e7d0015c 100644
--- a/arch/um/drivers/mmapper_kern.c
+++ b/arch/um/drivers/mmapper_kern.c
@@ -93,6 +93,7 @@ static const struct file_operations mmapper_fops = {
93 .mmap = mmapper_mmap, 93 .mmap = mmapper_mmap,
94 .open = mmapper_open, 94 .open = mmapper_open,
95 .release = mmapper_release, 95 .release = mmapper_release,
96 .llseek = default_llseek,
96}; 97};
97 98
98/* 99/*
diff --git a/arch/um/drivers/random.c b/arch/um/drivers/random.c
index 4949044773ba..981085a93f30 100644
--- a/arch/um/drivers/random.c
+++ b/arch/um/drivers/random.c
@@ -100,6 +100,7 @@ static const struct file_operations rng_chrdev_ops = {
100 .owner = THIS_MODULE, 100 .owner = THIS_MODULE,
101 .open = rng_dev_open, 101 .open = rng_dev_open,
102 .read = rng_dev_read, 102 .read = rng_dev_read,
103 .llseek = noop_llseek,
103}; 104};
104 105
105/* rng_init shouldn't be called more than once at boot time */ 106/* rng_init shouldn't be called more than once at boot time */
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 9734994cba1e..ba4a98ba39c0 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -33,7 +33,7 @@
33#include "linux/mm.h" 33#include "linux/mm.h"
34#include "linux/slab.h" 34#include "linux/slab.h"
35#include "linux/vmalloc.h" 35#include "linux/vmalloc.h"
36#include "linux/smp_lock.h" 36#include "linux/mutex.h"
37#include "linux/blkpg.h" 37#include "linux/blkpg.h"
38#include "linux/genhd.h" 38#include "linux/genhd.h"
39#include "linux/spinlock.h" 39#include "linux/spinlock.h"
@@ -100,6 +100,7 @@ static inline void ubd_set_bit(__u64 bit, unsigned char *data)
100#define DRIVER_NAME "uml-blkdev" 100#define DRIVER_NAME "uml-blkdev"
101 101
102static DEFINE_MUTEX(ubd_lock); 102static DEFINE_MUTEX(ubd_lock);
103static DEFINE_MUTEX(ubd_mutex); /* replaces BKL, might not be needed */
103 104
104static int ubd_open(struct block_device *bdev, fmode_t mode); 105static int ubd_open(struct block_device *bdev, fmode_t mode);
105static int ubd_release(struct gendisk *disk, fmode_t mode); 106static int ubd_release(struct gendisk *disk, fmode_t mode);
@@ -1101,7 +1102,7 @@ static int ubd_open(struct block_device *bdev, fmode_t mode)
1101 struct ubd *ubd_dev = disk->private_data; 1102 struct ubd *ubd_dev = disk->private_data;
1102 int err = 0; 1103 int err = 0;
1103 1104
1104 lock_kernel(); 1105 mutex_lock(&ubd_mutex);
1105 if(ubd_dev->count == 0){ 1106 if(ubd_dev->count == 0){
1106 err = ubd_open_dev(ubd_dev); 1107 err = ubd_open_dev(ubd_dev);
1107 if(err){ 1108 if(err){
@@ -1120,7 +1121,7 @@ static int ubd_open(struct block_device *bdev, fmode_t mode)
1120 err = -EROFS; 1121 err = -EROFS;
1121 }*/ 1122 }*/
1122out: 1123out:
1123 unlock_kernel(); 1124 mutex_unlock(&ubd_mutex);
1124 return err; 1125 return err;
1125} 1126}
1126 1127
@@ -1128,10 +1129,10 @@ static int ubd_release(struct gendisk *disk, fmode_t mode)
1128{ 1129{
1129 struct ubd *ubd_dev = disk->private_data; 1130 struct ubd *ubd_dev = disk->private_data;
1130 1131
1131 lock_kernel(); 1132 mutex_lock(&ubd_mutex);
1132 if(--ubd_dev->count == 0) 1133 if(--ubd_dev->count == 0)
1133 ubd_close_dev(ubd_dev); 1134 ubd_close_dev(ubd_dev);
1134 unlock_kernel(); 1135 mutex_unlock(&ubd_mutex);
1135 return 0; 1136 return 0;
1136} 1137}
1137 1138
diff --git a/arch/um/kernel/exec.c b/arch/um/kernel/exec.c
index 49b5e1eb3262..340268be00b5 100644
--- a/arch/um/kernel/exec.c
+++ b/arch/um/kernel/exec.c
@@ -78,13 +78,11 @@ long sys_execve(const char __user *file, const char __user *const __user *argv,
78 long error; 78 long error;
79 char *filename; 79 char *filename;
80 80
81 lock_kernel();
82 filename = getname(file); 81 filename = getname(file);
83 error = PTR_ERR(filename); 82 error = PTR_ERR(filename);
84 if (IS_ERR(filename)) goto out; 83 if (IS_ERR(filename)) goto out;
85 error = execve1(filename, argv, env); 84 error = execve1(filename, argv, env);
86 putname(filename); 85 putname(filename);
87 out: 86 out:
88 unlock_kernel();
89 return error; 87 return error;
90} 88}
diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
index e5bb96b10f1a..b59ee765414e 100644
--- a/arch/x86/Kconfig.debug
+++ b/arch/x86/Kconfig.debug
@@ -125,16 +125,6 @@ config DEBUG_NX_TEST
125 and the software setup of this feature. 125 and the software setup of this feature.
126 If in doubt, say "N" 126 If in doubt, say "N"
127 127
128config 4KSTACKS
129 bool "Use 4Kb for kernel stacks instead of 8Kb"
130 depends on X86_32
131 ---help---
132 If you say Y here the kernel will use a 4Kb stacksize for the
133 kernel stack attached to each process/thread. This facilitates
134 running more threads on a system and also reduces the pressure
135 on the VM subsystem for higher order allocations. This option
136 will also use IRQ stacks to compensate for the reduced stackspace.
137
138config DOUBLEFAULT 128config DOUBLEFAULT
139 default y 129 default y
140 bool "Enable doublefault exception handler" if EMBEDDED 130 bool "Enable doublefault exception handler" if EMBEDDED
diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
index bafd80defa43..903683b07e42 100644
--- a/arch/x86/include/asm/bitops.h
+++ b/arch/x86/include/asm/bitops.h
@@ -440,6 +440,8 @@ static inline int fls(int x)
440 440
441#ifdef __KERNEL__ 441#ifdef __KERNEL__
442 442
443#include <asm-generic/bitops/find.h>
444
443#include <asm-generic/bitops/sched.h> 445#include <asm-generic/bitops/sched.h>
444 446
445#define ARCH_HAS_FAST_MULTIPLIER 1 447#define ARCH_HAS_FAST_MULTIPLIER 1
diff --git a/arch/x86/include/asm/irq.h b/arch/x86/include/asm/irq.h
index 5458380b6ef8..0bf5b0083650 100644
--- a/arch/x86/include/asm/irq.h
+++ b/arch/x86/include/asm/irq.h
@@ -19,18 +19,16 @@ static inline int irq_canonicalize(int irq)
19# define ARCH_HAS_NMI_WATCHDOG 19# define ARCH_HAS_NMI_WATCHDOG
20#endif 20#endif
21 21
22#ifdef CONFIG_4KSTACKS 22#ifdef CONFIG_X86_32
23 extern void irq_ctx_init(int cpu); 23extern void irq_ctx_init(int cpu);
24 extern void irq_ctx_exit(int cpu); 24extern void irq_ctx_exit(int cpu);
25# define __ARCH_HAS_DO_SOFTIRQ
26#else 25#else
27# define irq_ctx_init(cpu) do { } while (0) 26# define irq_ctx_init(cpu) do { } while (0)
28# define irq_ctx_exit(cpu) do { } while (0) 27# define irq_ctx_exit(cpu) do { } while (0)
29# ifdef CONFIG_X86_64
30# define __ARCH_HAS_DO_SOFTIRQ
31# endif
32#endif 28#endif
33 29
30#define __ARCH_HAS_DO_SOFTIRQ
31
34#ifdef CONFIG_HOTPLUG_CPU 32#ifdef CONFIG_HOTPLUG_CPU
35#include <linux/cpumask.h> 33#include <linux/cpumask.h>
36extern void fixup_irqs(void); 34extern void fixup_irqs(void);
diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
index 3e2ce58a31a3..67763c5d8b4e 100644
--- a/arch/x86/include/asm/module.h
+++ b/arch/x86/include/asm/module.h
@@ -60,12 +60,7 @@
60#endif 60#endif
61 61
62#ifdef CONFIG_X86_32 62#ifdef CONFIG_X86_32
63# ifdef CONFIG_4KSTACKS 63# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
64# define MODULE_STACKSIZE "4KSTACKS "
65# else
66# define MODULE_STACKSIZE ""
67# endif
68# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_STACKSIZE
69#endif 64#endif
70 65
71#endif /* _ASM_X86_MODULE_H */ 66#endif /* _ASM_X86_MODULE_H */
diff --git a/arch/x86/include/asm/page_32_types.h b/arch/x86/include/asm/page_32_types.h
index 6f1b7331313f..ade619ff9e2a 100644
--- a/arch/x86/include/asm/page_32_types.h
+++ b/arch/x86/include/asm/page_32_types.h
@@ -15,11 +15,7 @@
15 */ 15 */
16#define __PAGE_OFFSET _AC(CONFIG_PAGE_OFFSET, UL) 16#define __PAGE_OFFSET _AC(CONFIG_PAGE_OFFSET, UL)
17 17
18#ifdef CONFIG_4KSTACKS
19#define THREAD_ORDER 0
20#else
21#define THREAD_ORDER 1 18#define THREAD_ORDER 1
22#endif
23#define THREAD_SIZE (PAGE_SIZE << THREAD_ORDER) 19#define THREAD_SIZE (PAGE_SIZE << THREAD_ORDER)
24 20
25#define STACKFAULT_STACK 0 21#define STACKFAULT_STACK 0
diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
index 4c9c67bf09b7..fbbc4dadecc4 100644
--- a/arch/x86/kernel/apm_32.c
+++ b/arch/x86/kernel/apm_32.c
@@ -1926,6 +1926,7 @@ static const struct file_operations apm_bios_fops = {
1926 .unlocked_ioctl = do_ioctl, 1926 .unlocked_ioctl = do_ioctl,
1927 .open = do_open, 1927 .open = do_open,
1928 .release = do_release, 1928 .release = do_release,
1929 .llseek = noop_llseek,
1929}; 1930};
1930 1931
1931static struct miscdevice apm_device = { 1932static struct miscdevice apm_device = {
diff --git a/arch/x86/kernel/cpu/mcheck/mce-severity.c b/arch/x86/kernel/cpu/mcheck/mce-severity.c
index 8a85dd1b1aa1..1e8d66c1336a 100644
--- a/arch/x86/kernel/cpu/mcheck/mce-severity.c
+++ b/arch/x86/kernel/cpu/mcheck/mce-severity.c
@@ -192,6 +192,7 @@ static const struct file_operations severities_coverage_fops = {
192 .release = seq_release, 192 .release = seq_release,
193 .read = seq_read, 193 .read = seq_read,
194 .write = severities_coverage_write, 194 .write = severities_coverage_write,
195 .llseek = seq_lseek,
195}; 196};
196 197
197static int __init severities_debugfs_init(void) 198static int __init severities_debugfs_init(void)
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index ed41562909fe..7a35b72d7c03 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -1665,6 +1665,7 @@ struct file_operations mce_chrdev_ops = {
1665 .read = mce_read, 1665 .read = mce_read,
1666 .poll = mce_poll, 1666 .poll = mce_poll,
1667 .unlocked_ioctl = mce_ioctl, 1667 .unlocked_ioctl = mce_ioctl,
1668 .llseek = no_llseek,
1668}; 1669};
1669EXPORT_SYMBOL_GPL(mce_chrdev_ops); 1670EXPORT_SYMBOL_GPL(mce_chrdev_ops);
1670 1671
diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
index efaf906daf93..aff0b3c27509 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -380,44 +380,35 @@ static int hpet_next_event(unsigned long delta,
380 struct clock_event_device *evt, int timer) 380 struct clock_event_device *evt, int timer)
381{ 381{
382 u32 cnt; 382 u32 cnt;
383 s32 res;
383 384
384 cnt = hpet_readl(HPET_COUNTER); 385 cnt = hpet_readl(HPET_COUNTER);
385 cnt += (u32) delta; 386 cnt += (u32) delta;
386 hpet_writel(cnt, HPET_Tn_CMP(timer)); 387 hpet_writel(cnt, HPET_Tn_CMP(timer));
387 388
388 /* 389 /*
389 * We need to read back the CMP register on certain HPET 390 * HPETs are a complete disaster. The compare register is
390 * implementations (ATI chipsets) which seem to delay the 391 * based on a equal comparison and neither provides a less
391 * transfer of the compare register into the internal compare 392 * than or equal functionality (which would require to take
392 * logic. With small deltas this might actually be too late as 393 * the wraparound into account) nor a simple count down event
393 * the counter could already be higher than the compare value 394 * mode. Further the write to the comparator register is
394 * at that point and we would wait for the next hpet interrupt 395 * delayed internally up to two HPET clock cycles in certain
395 * forever. We found out that reading the CMP register back 396 * chipsets (ATI, ICH9,10). We worked around that by reading
396 * forces the transfer so we can rely on the comparison with 397 * back the compare register, but that required another
397 * the counter register below. If the read back from the 398 * workaround for ICH9,10 chips where the first readout after
398 * compare register does not match the value we programmed 399 * write can return the old stale value. We already have a
399 * then we might have a real hardware problem. We can not do 400 * minimum delta of 5us enforced, but a NMI or SMI hitting
400 * much about it here, but at least alert the user/admin with 401 * between the counter readout and the comparator write can
401 * a prominent warning. 402 * move us behind that point easily. Now instead of reading
402 * 403 * the compare register back several times, we make the ETIME
403 * An erratum on some chipsets (ICH9,..), results in 404 * decision based on the following: Return ETIME if the
404 * comparator read immediately following a write returning old 405 * counter value after the write is less than 8 HPET cycles
405 * value. Workaround for this is to read this value second 406 * away from the event or if the counter is already ahead of
406 * time, when first read returns old value. 407 * the event.
407 *
408 * In fact the write to the comparator register is delayed up
409 * to two HPET cycles so the workaround we tried to restrict
410 * the readback to those known to be borked ATI chipsets
411 * failed miserably. So we give up on optimizations forever
412 * and penalize all HPET incarnations unconditionally.
413 */ 408 */
414 if (unlikely((u32)hpet_readl(HPET_Tn_CMP(timer)) != cnt)) { 409 res = (s32)(cnt - hpet_readl(HPET_COUNTER));
415 if (hpet_readl(HPET_Tn_CMP(timer)) != cnt)
416 printk_once(KERN_WARNING
417 "hpet: compare register read back failed.\n");
418 }
419 410
420 return (s32)(hpet_readl(HPET_COUNTER) - cnt) >= 0 ? -ETIME : 0; 411 return res < 8 ? -ETIME : 0;
421} 412}
422 413
423static void hpet_legacy_set_mode(enum clock_event_mode mode, 414static void hpet_legacy_set_mode(enum clock_event_mode mode,
diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
index 10709f29d166..50fbbe60e507 100644
--- a/arch/x86/kernel/irq_32.c
+++ b/arch/x86/kernel/irq_32.c
@@ -49,20 +49,19 @@ static inline int check_stack_overflow(void) { return 0; }
49static inline void print_stack_overflow(void) { } 49static inline void print_stack_overflow(void) { }
50#endif 50#endif
51 51
52#ifdef CONFIG_4KSTACKS
53/* 52/*
54 * per-CPU IRQ handling contexts (thread information and stack) 53 * per-CPU IRQ handling contexts (thread information and stack)
55 */ 54 */
56union irq_ctx { 55union irq_ctx {
57 struct thread_info tinfo; 56 struct thread_info tinfo;
58 u32 stack[THREAD_SIZE/sizeof(u32)]; 57 u32 stack[THREAD_SIZE/sizeof(u32)];
59} __attribute__((aligned(PAGE_SIZE))); 58} __attribute__((aligned(THREAD_SIZE)));
60 59
61static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx); 60static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
62static DEFINE_PER_CPU(union irq_ctx *, softirq_ctx); 61static DEFINE_PER_CPU(union irq_ctx *, softirq_ctx);
63 62
64static DEFINE_PER_CPU_PAGE_ALIGNED(union irq_ctx, hardirq_stack); 63static DEFINE_PER_CPU_MULTIPAGE_ALIGNED(union irq_ctx, hardirq_stack, THREAD_SIZE);
65static DEFINE_PER_CPU_PAGE_ALIGNED(union irq_ctx, softirq_stack); 64static DEFINE_PER_CPU_MULTIPAGE_ALIGNED(union irq_ctx, softirq_stack, THREAD_SIZE);
66 65
67static void call_on_stack(void *func, void *stack) 66static void call_on_stack(void *func, void *stack)
68{ 67{
@@ -187,11 +186,6 @@ asmlinkage void do_softirq(void)
187 local_irq_restore(flags); 186 local_irq_restore(flags);
188} 187}
189 188
190#else
191static inline int
192execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq) { return 0; }
193#endif
194
195bool handle_irq(unsigned irq, struct pt_regs *regs) 189bool handle_irq(unsigned irq, struct pt_regs *regs)
196{ 190{
197 struct irq_desc *desc; 191 struct irq_desc *desc;
diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
index 8afd9f321f10..90fcf62854bb 100644
--- a/arch/x86/kernel/kdebugfs.c
+++ b/arch/x86/kernel/kdebugfs.c
@@ -78,6 +78,7 @@ static int setup_data_open(struct inode *inode, struct file *file)
78static const struct file_operations fops_setup_data = { 78static const struct file_operations fops_setup_data = {
79 .read = setup_data_read, 79 .read = setup_data_read,
80 .open = setup_data_open, 80 .open = setup_data_open,
81 .llseek = default_llseek,
81}; 82};
82 83
83static int __init 84static int __init
diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
index fa6551d36c10..0b3d37e83606 100644
--- a/arch/x86/kernel/microcode_core.c
+++ b/arch/x86/kernel/microcode_core.c
@@ -232,6 +232,7 @@ static const struct file_operations microcode_fops = {
232 .owner = THIS_MODULE, 232 .owner = THIS_MODULE,
233 .write = microcode_write, 233 .write = microcode_write,
234 .open = microcode_open, 234 .open = microcode_open,
235 .llseek = no_llseek,
235}; 236};
236 237
237static struct miscdevice microcode_dev = { 238static struct miscdevice microcode_dev = {
diff --git a/arch/x86/kernel/tlb_uv.c b/arch/x86/kernel/tlb_uv.c
index 312ef0292815..50ac949c7f1c 100644
--- a/arch/x86/kernel/tlb_uv.c
+++ b/arch/x86/kernel/tlb_uv.c
@@ -1285,6 +1285,7 @@ static const struct file_operations tunables_fops = {
1285 .open = tunables_open, 1285 .open = tunables_open,
1286 .read = tunables_read, 1286 .read = tunables_read,
1287 .write = tunables_write, 1287 .write = tunables_write,
1288 .llseek = default_llseek,
1288}; 1289};
1289 1290
1290static int __init uv_ptc_init(void) 1291static int __init uv_ptc_init(void)
diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
index 38e2b67807e1..e03530aebfd0 100644
--- a/arch/x86/kernel/vmlinux.lds.S
+++ b/arch/x86/kernel/vmlinux.lds.S
@@ -301,7 +301,7 @@ SECTIONS
301 } 301 }
302 302
303#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP) 303#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
304 PERCPU(PAGE_SIZE) 304 PERCPU(THREAD_SIZE)
305#endif 305#endif
306 306
307 . = ALIGN(PAGE_SIZE); 307 . = ALIGN(PAGE_SIZE);
diff --git a/arch/x86/xen/debugfs.c b/arch/x86/xen/debugfs.c
index 1304bcec8ee5..7c0fedd98ea0 100644
--- a/arch/x86/xen/debugfs.c
+++ b/arch/x86/xen/debugfs.c
@@ -106,6 +106,7 @@ static const struct file_operations u32_array_fops = {
106 .open = u32_array_open, 106 .open = u32_array_open,
107 .release= xen_array_release, 107 .release= xen_array_release,
108 .read = u32_array_read, 108 .read = u32_array_read,
109 .llseek = no_llseek,
109}; 110};
110 111
111struct dentry *xen_debugfs_create_u32_array(const char *name, mode_t mode, 112struct dentry *xen_debugfs_create_u32_array(const char *name, mode_t mode,
diff --git a/block/bsg.c b/block/bsg.c
index 0c00870553a3..f20d6a789d48 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -20,7 +20,6 @@
20#include <linux/uio.h> 20#include <linux/uio.h>
21#include <linux/idr.h> 21#include <linux/idr.h>
22#include <linux/bsg.h> 22#include <linux/bsg.h>
23#include <linux/smp_lock.h>
24#include <linux/slab.h> 23#include <linux/slab.h>
25 24
26#include <scsi/scsi.h> 25#include <scsi/scsi.h>
@@ -843,9 +842,7 @@ static int bsg_open(struct inode *inode, struct file *file)
843{ 842{
844 struct bsg_device *bd; 843 struct bsg_device *bd;
845 844
846 lock_kernel();
847 bd = bsg_get_device(inode, file); 845 bd = bsg_get_device(inode, file);
848 unlock_kernel();
849 846
850 if (IS_ERR(bd)) 847 if (IS_ERR(bd))
851 return PTR_ERR(bd); 848 return PTR_ERR(bd);
@@ -968,6 +965,7 @@ static const struct file_operations bsg_fops = {
968 .release = bsg_release, 965 .release = bsg_release,
969 .unlocked_ioctl = bsg_ioctl, 966 .unlocked_ioctl = bsg_ioctl,
970 .owner = THIS_MODULE, 967 .owner = THIS_MODULE,
968 .llseek = default_llseek,
971}; 969};
972 970
973void bsg_unregister_queue(struct request_queue *q) 971void bsg_unregister_queue(struct request_queue *q)
diff --git a/drivers/acpi/apei/erst-dbg.c b/drivers/acpi/apei/erst-dbg.c
index da1228a9a544..de73caf3cebc 100644
--- a/drivers/acpi/apei/erst-dbg.c
+++ b/drivers/acpi/apei/erst-dbg.c
@@ -184,6 +184,7 @@ static const struct file_operations erst_dbg_ops = {
184 .read = erst_dbg_read, 184 .read = erst_dbg_read,
185 .write = erst_dbg_write, 185 .write = erst_dbg_write,
186 .unlocked_ioctl = erst_dbg_ioctl, 186 .unlocked_ioctl = erst_dbg_ioctl,
187 .llseek = no_llseek,
187}; 188};
188 189
189static struct miscdevice erst_dbg_dev = { 190static struct miscdevice erst_dbg_dev = {
diff --git a/drivers/acpi/debugfs.c b/drivers/acpi/debugfs.c
index 7de27d49c4b9..6355b575ee5a 100644
--- a/drivers/acpi/debugfs.c
+++ b/drivers/acpi/debugfs.c
@@ -69,6 +69,7 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf,
69 69
70static const struct file_operations cm_fops = { 70static const struct file_operations cm_fops = {
71 .write = cm_write, 71 .write = cm_write,
72 .llseek = default_llseek,
72}; 73};
73 74
74int __init acpi_debugfs_init(void) 75int __init acpi_debugfs_init(void)
diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
index 0e869b3f81ca..411620ef84c2 100644
--- a/drivers/acpi/ec_sys.c
+++ b/drivers/acpi/ec_sys.c
@@ -101,6 +101,7 @@ static struct file_operations acpi_ec_io_ops = {
101 .open = acpi_ec_open_io, 101 .open = acpi_ec_open_io,
102 .read = acpi_ec_read_io, 102 .read = acpi_ec_read_io,
103 .write = acpi_ec_write_io, 103 .write = acpi_ec_write_io,
104 .llseek = default_llseek,
104}; 105};
105 106
106int acpi_ec_add_debugfs(struct acpi_ec *ec, unsigned int ec_device_count) 107int acpi_ec_add_debugfs(struct acpi_ec *ec, unsigned int ec_device_count)
diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c
index d439314a75d8..85d908993809 100644
--- a/drivers/acpi/event.c
+++ b/drivers/acpi/event.c
@@ -110,6 +110,7 @@ static const struct file_operations acpi_system_event_ops = {
110 .read = acpi_system_read_event, 110 .read = acpi_system_read_event,
111 .release = acpi_system_close_event, 111 .release = acpi_system_close_event,
112 .poll = acpi_system_poll_event, 112 .poll = acpi_system_poll_event,
113 .llseek = default_llseek,
113}; 114};
114#endif /* CONFIG_ACPI_PROC_EVENT */ 115#endif /* CONFIG_ACPI_PROC_EVENT */
115 116
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
index 4e2c367fec11..1f286ab461d3 100644
--- a/drivers/block/DAC960.c
+++ b/drivers/block/DAC960.c
@@ -36,7 +36,7 @@
36#include <linux/ioport.h> 36#include <linux/ioport.h>
37#include <linux/mm.h> 37#include <linux/mm.h>
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/smp_lock.h> 39#include <linux/mutex.h>
40#include <linux/proc_fs.h> 40#include <linux/proc_fs.h>
41#include <linux/seq_file.h> 41#include <linux/seq_file.h>
42#include <linux/reboot.h> 42#include <linux/reboot.h>
@@ -54,6 +54,7 @@
54#define DAC960_GAM_MINOR 252 54#define DAC960_GAM_MINOR 252
55 55
56 56
57static DEFINE_MUTEX(DAC960_mutex);
57static DAC960_Controller_T *DAC960_Controllers[DAC960_MaxControllers]; 58static DAC960_Controller_T *DAC960_Controllers[DAC960_MaxControllers];
58static int DAC960_ControllerCount; 59static int DAC960_ControllerCount;
59static struct proc_dir_entry *DAC960_ProcDirectoryEntry; 60static struct proc_dir_entry *DAC960_ProcDirectoryEntry;
@@ -81,7 +82,7 @@ static int DAC960_open(struct block_device *bdev, fmode_t mode)
81 int drive_nr = (long)disk->private_data; 82 int drive_nr = (long)disk->private_data;
82 int ret = -ENXIO; 83 int ret = -ENXIO;
83 84
84 lock_kernel(); 85 mutex_lock(&DAC960_mutex);
85 if (p->FirmwareType == DAC960_V1_Controller) { 86 if (p->FirmwareType == DAC960_V1_Controller) {
86 if (p->V1.LogicalDriveInformation[drive_nr]. 87 if (p->V1.LogicalDriveInformation[drive_nr].
87 LogicalDriveState == DAC960_V1_LogicalDrive_Offline) 88 LogicalDriveState == DAC960_V1_LogicalDrive_Offline)
@@ -99,7 +100,7 @@ static int DAC960_open(struct block_device *bdev, fmode_t mode)
99 goto out; 100 goto out;
100 ret = 0; 101 ret = 0;
101out: 102out:
102 unlock_kernel(); 103 mutex_unlock(&DAC960_mutex);
103 return ret; 104 return ret;
104} 105}
105 106
@@ -6625,7 +6626,7 @@ static long DAC960_gam_ioctl(struct file *file, unsigned int Request,
6625 long ErrorCode = 0; 6626 long ErrorCode = 0;
6626 if (!capable(CAP_SYS_ADMIN)) return -EACCES; 6627 if (!capable(CAP_SYS_ADMIN)) return -EACCES;
6627 6628
6628 lock_kernel(); 6629 mutex_lock(&DAC960_mutex);
6629 switch (Request) 6630 switch (Request)
6630 { 6631 {
6631 case DAC960_IOCTL_GET_CONTROLLER_COUNT: 6632 case DAC960_IOCTL_GET_CONTROLLER_COUNT:
@@ -7056,13 +7057,14 @@ static long DAC960_gam_ioctl(struct file *file, unsigned int Request,
7056 default: 7057 default:
7057 ErrorCode = -ENOTTY; 7058 ErrorCode = -ENOTTY;
7058 } 7059 }
7059 unlock_kernel(); 7060 mutex_unlock(&DAC960_mutex);
7060 return ErrorCode; 7061 return ErrorCode;
7061} 7062}
7062 7063
7063static const struct file_operations DAC960_gam_fops = { 7064static const struct file_operations DAC960_gam_fops = {
7064 .owner = THIS_MODULE, 7065 .owner = THIS_MODULE,
7065 .unlocked_ioctl = DAC960_gam_ioctl 7066 .unlocked_ioctl = DAC960_gam_ioctl,
7067 .llseek = noop_llseek,
7066}; 7068};
7067 7069
7068static struct miscdevice DAC960_gam_dev = { 7070static struct miscdevice DAC960_gam_dev = {
diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c
index 76f114f0bba3..4b852c962266 100644
--- a/drivers/block/amiflop.c
+++ b/drivers/block/amiflop.c
@@ -60,7 +60,7 @@
60#include <linux/hdreg.h> 60#include <linux/hdreg.h>
61#include <linux/delay.h> 61#include <linux/delay.h>
62#include <linux/init.h> 62#include <linux/init.h>
63#include <linux/smp_lock.h> 63#include <linux/mutex.h>
64#include <linux/amifdreg.h> 64#include <linux/amifdreg.h>
65#include <linux/amifd.h> 65#include <linux/amifd.h>
66#include <linux/buffer_head.h> 66#include <linux/buffer_head.h>
@@ -109,6 +109,7 @@
109#define FD_HD_3 0x55555555 /* high-density 3.5" (1760K) drive */ 109#define FD_HD_3 0x55555555 /* high-density 3.5" (1760K) drive */
110#define FD_DD_5 0xaaaaaaaa /* double-density 5.25" (440K) drive */ 110#define FD_DD_5 0xaaaaaaaa /* double-density 5.25" (440K) drive */
111 111
112static DEFINE_MUTEX(amiflop_mutex);
112static unsigned long int fd_def_df0 = FD_DD_3; /* default for df0 if it doesn't identify */ 113static unsigned long int fd_def_df0 = FD_DD_3; /* default for df0 if it doesn't identify */
113 114
114module_param(fd_def_df0, ulong, 0); 115module_param(fd_def_df0, ulong, 0);
@@ -1506,9 +1507,9 @@ static int fd_ioctl(struct block_device *bdev, fmode_t mode,
1506{ 1507{
1507 int ret; 1508 int ret;
1508 1509
1509 lock_kernel(); 1510 mutex_lock(&amiflop_mutex);
1510 ret = fd_locked_ioctl(bdev, mode, cmd, param); 1511 ret = fd_locked_ioctl(bdev, mode, cmd, param);
1511 unlock_kernel(); 1512 mutex_unlock(&amiflop_mutex);
1512 1513
1513 return ret; 1514 return ret;
1514} 1515}
@@ -1555,11 +1556,11 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
1555 int old_dev; 1556 int old_dev;
1556 unsigned long flags; 1557 unsigned long flags;
1557 1558
1558 lock_kernel(); 1559 mutex_lock(&amiflop_mutex);
1559 old_dev = fd_device[drive]; 1560 old_dev = fd_device[drive];
1560 1561
1561 if (fd_ref[drive] && old_dev != system) { 1562 if (fd_ref[drive] && old_dev != system) {
1562 unlock_kernel(); 1563 mutex_unlock(&amiflop_mutex);
1563 return -EBUSY; 1564 return -EBUSY;
1564 } 1565 }
1565 1566
@@ -1575,7 +1576,7 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
1575 rel_fdc(); 1576 rel_fdc();
1576 1577
1577 if (wrprot) { 1578 if (wrprot) {
1578 unlock_kernel(); 1579 mutex_unlock(&amiflop_mutex);
1579 return -EROFS; 1580 return -EROFS;
1580 } 1581 }
1581 } 1582 }
@@ -1594,7 +1595,7 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
1594 printk(KERN_INFO "fd%d: accessing %s-disk with %s-layout\n",drive, 1595 printk(KERN_INFO "fd%d: accessing %s-disk with %s-layout\n",drive,
1595 unit[drive].type->name, data_types[system].name); 1596 unit[drive].type->name, data_types[system].name);
1596 1597
1597 unlock_kernel(); 1598 mutex_unlock(&amiflop_mutex);
1598 return 0; 1599 return 0;
1599} 1600}
1600 1601
@@ -1603,7 +1604,7 @@ static int floppy_release(struct gendisk *disk, fmode_t mode)
1603 struct amiga_floppy_struct *p = disk->private_data; 1604 struct amiga_floppy_struct *p = disk->private_data;
1604 int drive = p - unit; 1605 int drive = p - unit;
1605 1606
1606 lock_kernel(); 1607 mutex_lock(&amiflop_mutex);
1607 if (unit[drive].dirty == 1) { 1608 if (unit[drive].dirty == 1) {
1608 del_timer (flush_track_timer + drive); 1609 del_timer (flush_track_timer + drive);
1609 non_int_flush_track (drive); 1610 non_int_flush_track (drive);
@@ -1617,7 +1618,7 @@ static int floppy_release(struct gendisk *disk, fmode_t mode)
1617/* the mod_use counter is handled this way */ 1618/* the mod_use counter is handled this way */
1618 floppy_off (drive | 0x40000000); 1619 floppy_off (drive | 0x40000000);
1619#endif 1620#endif
1620 unlock_kernel(); 1621 mutex_unlock(&amiflop_mutex);
1621 return 0; 1622 return 0;
1622} 1623}
1623 1624
diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
index a946929735a5..f21c237a9e5e 100644
--- a/drivers/block/aoe/aoeblk.c
+++ b/drivers/block/aoe/aoeblk.c
@@ -12,9 +12,10 @@
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/genhd.h> 13#include <linux/genhd.h>
14#include <linux/netdevice.h> 14#include <linux/netdevice.h>
15#include <linux/smp_lock.h> 15#include <linux/mutex.h>
16#include "aoe.h" 16#include "aoe.h"
17 17
18static DEFINE_MUTEX(aoeblk_mutex);
18static struct kmem_cache *buf_pool_cache; 19static struct kmem_cache *buf_pool_cache;
19 20
20static ssize_t aoedisk_show_state(struct device *dev, 21static ssize_t aoedisk_show_state(struct device *dev,
@@ -125,16 +126,16 @@ aoeblk_open(struct block_device *bdev, fmode_t mode)
125 struct aoedev *d = bdev->bd_disk->private_data; 126 struct aoedev *d = bdev->bd_disk->private_data;
126 ulong flags; 127 ulong flags;
127 128
128 lock_kernel(); 129 mutex_lock(&aoeblk_mutex);
129 spin_lock_irqsave(&d->lock, flags); 130 spin_lock_irqsave(&d->lock, flags);
130 if (d->flags & DEVFL_UP) { 131 if (d->flags & DEVFL_UP) {
131 d->nopen++; 132 d->nopen++;
132 spin_unlock_irqrestore(&d->lock, flags); 133 spin_unlock_irqrestore(&d->lock, flags);
133 unlock_kernel(); 134 mutex_unlock(&aoeblk_mutex);
134 return 0; 135 return 0;
135 } 136 }
136 spin_unlock_irqrestore(&d->lock, flags); 137 spin_unlock_irqrestore(&d->lock, flags);
137 unlock_kernel(); 138 mutex_unlock(&aoeblk_mutex);
138 return -ENODEV; 139 return -ENODEV;
139} 140}
140 141
diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c
index 4a1b9e7464aa..146296ca4965 100644
--- a/drivers/block/aoe/aoechr.c
+++ b/drivers/block/aoe/aoechr.c
@@ -9,7 +9,7 @@
9#include <linux/completion.h> 9#include <linux/completion.h>
10#include <linux/delay.h> 10#include <linux/delay.h>
11#include <linux/slab.h> 11#include <linux/slab.h>
12#include <linux/smp_lock.h> 12#include <linux/mutex.h>
13#include <linux/skbuff.h> 13#include <linux/skbuff.h>
14#include "aoe.h" 14#include "aoe.h"
15 15
@@ -37,6 +37,7 @@ struct ErrMsg {
37 char *msg; 37 char *msg;
38}; 38};
39 39
40static DEFINE_MUTEX(aoechr_mutex);
40static struct ErrMsg emsgs[NMSG]; 41static struct ErrMsg emsgs[NMSG];
41static int emsgs_head_idx, emsgs_tail_idx; 42static int emsgs_head_idx, emsgs_tail_idx;
42static struct completion emsgs_comp; 43static struct completion emsgs_comp;
@@ -183,16 +184,16 @@ aoechr_open(struct inode *inode, struct file *filp)
183{ 184{
184 int n, i; 185 int n, i;
185 186
186 lock_kernel(); 187 mutex_lock(&aoechr_mutex);
187 n = iminor(inode); 188 n = iminor(inode);
188 filp->private_data = (void *) (unsigned long) n; 189 filp->private_data = (void *) (unsigned long) n;
189 190
190 for (i = 0; i < ARRAY_SIZE(chardevs); ++i) 191 for (i = 0; i < ARRAY_SIZE(chardevs); ++i)
191 if (chardevs[i].minor == n) { 192 if (chardevs[i].minor == n) {
192 unlock_kernel(); 193 mutex_unlock(&aoechr_mutex);
193 return 0; 194 return 0;
194 } 195 }
195 unlock_kernel(); 196 mutex_unlock(&aoechr_mutex);
196 return -EINVAL; 197 return -EINVAL;
197} 198}
198 199
@@ -265,6 +266,7 @@ static const struct file_operations aoe_fops = {
265 .open = aoechr_open, 266 .open = aoechr_open,
266 .release = aoechr_rel, 267 .release = aoechr_rel,
267 .owner = THIS_MODULE, 268 .owner = THIS_MODULE,
269 .llseek = noop_llseek,
268}; 270};
269 271
270static char *aoe_devnode(struct device *dev, mode_t *mode) 272static char *aoe_devnode(struct device *dev, mode_t *mode)
diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c
index aceb96476524..8c021bb7a991 100644
--- a/drivers/block/ataflop.c
+++ b/drivers/block/ataflop.c
@@ -67,7 +67,7 @@
67#include <linux/delay.h> 67#include <linux/delay.h>
68#include <linux/init.h> 68#include <linux/init.h>
69#include <linux/blkdev.h> 69#include <linux/blkdev.h>
70#include <linux/smp_lock.h> 70#include <linux/mutex.h>
71 71
72#include <asm/atafd.h> 72#include <asm/atafd.h>
73#include <asm/atafdreg.h> 73#include <asm/atafdreg.h>
@@ -79,6 +79,7 @@
79 79
80#undef DEBUG 80#undef DEBUG
81 81
82static DEFINE_MUTEX(ataflop_mutex);
82static struct request_queue *floppy_queue; 83static struct request_queue *floppy_queue;
83static struct request *fd_request; 84static struct request *fd_request;
84 85
@@ -1671,9 +1672,9 @@ static int fd_ioctl(struct block_device *bdev, fmode_t mode,
1671{ 1672{
1672 int ret; 1673 int ret;
1673 1674
1674 lock_kernel(); 1675 mutex_lock(&ataflop_mutex);
1675 ret = fd_locked_ioctl(bdev, mode, cmd, arg); 1676 ret = fd_locked_ioctl(bdev, mode, cmd, arg);
1676 unlock_kernel(); 1677 mutex_unlock(&ataflop_mutex);
1677 1678
1678 return ret; 1679 return ret;
1679} 1680}
@@ -1854,9 +1855,9 @@ static int floppy_unlocked_open(struct block_device *bdev, fmode_t mode)
1854{ 1855{
1855 int ret; 1856 int ret;
1856 1857
1857 lock_kernel(); 1858 mutex_lock(&ataflop_mutex);
1858 ret = floppy_open(bdev, mode); 1859 ret = floppy_open(bdev, mode);
1859 unlock_kernel(); 1860 mutex_unlock(&ataflop_mutex);
1860 1861
1861 return ret; 1862 return ret;
1862} 1863}
@@ -1864,14 +1865,14 @@ static int floppy_unlocked_open(struct block_device *bdev, fmode_t mode)
1864static int floppy_release(struct gendisk *disk, fmode_t mode) 1865static int floppy_release(struct gendisk *disk, fmode_t mode)
1865{ 1866{
1866 struct atari_floppy_struct *p = disk->private_data; 1867 struct atari_floppy_struct *p = disk->private_data;
1867 lock_kernel(); 1868 mutex_lock(&ataflop_mutex);
1868 if (p->ref < 0) 1869 if (p->ref < 0)
1869 p->ref = 0; 1870 p->ref = 0;
1870 else if (!p->ref--) { 1871 else if (!p->ref--) {
1871 printk(KERN_ERR "floppy_release with fd_ref == 0"); 1872 printk(KERN_ERR "floppy_release with fd_ref == 0");
1872 p->ref = 0; 1873 p->ref = 0;
1873 } 1874 }
1874 unlock_kernel(); 1875 mutex_unlock(&ataflop_mutex);
1875 return 0; 1876 return 0;
1876} 1877}
1877 1878
diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index 1c7f63792ff8..82bfd5bb4a97 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -15,7 +15,7 @@
15#include <linux/blkdev.h> 15#include <linux/blkdev.h>
16#include <linux/bio.h> 16#include <linux/bio.h>
17#include <linux/highmem.h> 17#include <linux/highmem.h>
18#include <linux/smp_lock.h> 18#include <linux/mutex.h>
19#include <linux/radix-tree.h> 19#include <linux/radix-tree.h>
20#include <linux/buffer_head.h> /* invalidate_bh_lrus() */ 20#include <linux/buffer_head.h> /* invalidate_bh_lrus() */
21#include <linux/slab.h> 21#include <linux/slab.h>
@@ -55,6 +55,7 @@ struct brd_device {
55/* 55/*
56 * Look up and return a brd's page for a given sector. 56 * Look up and return a brd's page for a given sector.
57 */ 57 */
58static DEFINE_MUTEX(brd_mutex);
58static struct page *brd_lookup_page(struct brd_device *brd, sector_t sector) 59static struct page *brd_lookup_page(struct brd_device *brd, sector_t sector)
59{ 60{
60 pgoff_t idx; 61 pgoff_t idx;
@@ -402,7 +403,7 @@ static int brd_ioctl(struct block_device *bdev, fmode_t mode,
402 * ram device BLKFLSBUF has special semantics, we want to actually 403 * ram device BLKFLSBUF has special semantics, we want to actually
403 * release and destroy the ramdisk data. 404 * release and destroy the ramdisk data.
404 */ 405 */
405 lock_kernel(); 406 mutex_lock(&brd_mutex);
406 mutex_lock(&bdev->bd_mutex); 407 mutex_lock(&bdev->bd_mutex);
407 error = -EBUSY; 408 error = -EBUSY;
408 if (bdev->bd_openers <= 1) { 409 if (bdev->bd_openers <= 1) {
@@ -419,7 +420,7 @@ static int brd_ioctl(struct block_device *bdev, fmode_t mode,
419 error = 0; 420 error = 0;
420 } 421 }
421 mutex_unlock(&bdev->bd_mutex); 422 mutex_unlock(&bdev->bd_mutex);
422 unlock_kernel(); 423 mutex_unlock(&brd_mutex);
423 424
424 return error; 425 return error;
425} 426}
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 5e4fadcdece9..c484c96e22a6 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -26,7 +26,6 @@
26#include <linux/pci.h> 26#include <linux/pci.h>
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/smp_lock.h>
30#include <linux/delay.h> 29#include <linux/delay.h>
31#include <linux/major.h> 30#include <linux/major.h>
32#include <linux/fs.h> 31#include <linux/fs.h>
@@ -66,6 +65,7 @@ MODULE_SUPPORTED_DEVICE("HP Smart Array Controllers");
66MODULE_VERSION("3.6.26"); 65MODULE_VERSION("3.6.26");
67MODULE_LICENSE("GPL"); 66MODULE_LICENSE("GPL");
68 67
68static DEFINE_MUTEX(cciss_mutex);
69static int cciss_allow_hpsa; 69static int cciss_allow_hpsa;
70module_param(cciss_allow_hpsa, int, S_IRUGO|S_IWUSR); 70module_param(cciss_allow_hpsa, int, S_IRUGO|S_IWUSR);
71MODULE_PARM_DESC(cciss_allow_hpsa, 71MODULE_PARM_DESC(cciss_allow_hpsa,
@@ -1059,9 +1059,9 @@ static int cciss_unlocked_open(struct block_device *bdev, fmode_t mode)
1059{ 1059{
1060 int ret; 1060 int ret;
1061 1061
1062 lock_kernel(); 1062 mutex_lock(&cciss_mutex);
1063 ret = cciss_open(bdev, mode); 1063 ret = cciss_open(bdev, mode);
1064 unlock_kernel(); 1064 mutex_unlock(&cciss_mutex);
1065 1065
1066 return ret; 1066 return ret;
1067} 1067}
@@ -1074,13 +1074,13 @@ static int cciss_release(struct gendisk *disk, fmode_t mode)
1074 ctlr_info_t *h; 1074 ctlr_info_t *h;
1075 drive_info_struct *drv; 1075 drive_info_struct *drv;
1076 1076
1077 lock_kernel(); 1077 mutex_lock(&cciss_mutex);
1078 h = get_host(disk); 1078 h = get_host(disk);
1079 drv = get_drv(disk); 1079 drv = get_drv(disk);
1080 dev_dbg(&h->pdev->dev, "cciss_release %s\n", disk->disk_name); 1080 dev_dbg(&h->pdev->dev, "cciss_release %s\n", disk->disk_name);
1081 drv->usage_count--; 1081 drv->usage_count--;
1082 h->usage_count--; 1082 h->usage_count--;
1083 unlock_kernel(); 1083 mutex_unlock(&cciss_mutex);
1084 return 0; 1084 return 0;
1085} 1085}
1086 1086
@@ -1088,9 +1088,9 @@ static int do_ioctl(struct block_device *bdev, fmode_t mode,
1088 unsigned cmd, unsigned long arg) 1088 unsigned cmd, unsigned long arg)
1089{ 1089{
1090 int ret; 1090 int ret;
1091 lock_kernel(); 1091 mutex_lock(&cciss_mutex);
1092 ret = cciss_ioctl(bdev, mode, cmd, arg); 1092 ret = cciss_ioctl(bdev, mode, cmd, arg);
1093 unlock_kernel(); 1093 mutex_unlock(&cciss_mutex);
1094 return ret; 1094 return ret;
1095} 1095}
1096 1096
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
index d53b0291c44b..946dad4caef3 100644
--- a/drivers/block/cpqarray.c
+++ b/drivers/block/cpqarray.c
@@ -35,7 +35,7 @@
35#include <linux/seq_file.h> 35#include <linux/seq_file.h>
36#include <linux/init.h> 36#include <linux/init.h>
37#include <linux/hdreg.h> 37#include <linux/hdreg.h>
38#include <linux/smp_lock.h> 38#include <linux/mutex.h>
39#include <linux/spinlock.h> 39#include <linux/spinlock.h>
40#include <linux/blkdev.h> 40#include <linux/blkdev.h>
41#include <linux/genhd.h> 41#include <linux/genhd.h>
@@ -68,6 +68,7 @@ MODULE_LICENSE("GPL");
68 68
69#define CPQARRAY_DMA_MASK 0xFFFFFFFF /* 32 bit DMA */ 69#define CPQARRAY_DMA_MASK 0xFFFFFFFF /* 32 bit DMA */
70 70
71static DEFINE_MUTEX(cpqarray_mutex);
71static int nr_ctlr; 72static int nr_ctlr;
72static ctlr_info_t *hba[MAX_CTLR]; 73static ctlr_info_t *hba[MAX_CTLR];
73 74
@@ -845,9 +846,9 @@ static int ida_unlocked_open(struct block_device *bdev, fmode_t mode)
845{ 846{
846 int ret; 847 int ret;
847 848
848 lock_kernel(); 849 mutex_lock(&cpqarray_mutex);
849 ret = ida_open(bdev, mode); 850 ret = ida_open(bdev, mode);
850 unlock_kernel(); 851 mutex_unlock(&cpqarray_mutex);
851 852
852 return ret; 853 return ret;
853} 854}
@@ -859,10 +860,10 @@ static int ida_release(struct gendisk *disk, fmode_t mode)
859{ 860{
860 ctlr_info_t *host; 861 ctlr_info_t *host;
861 862
862 lock_kernel(); 863 mutex_lock(&cpqarray_mutex);
863 host = get_host(disk); 864 host = get_host(disk);
864 host->usage_count--; 865 host->usage_count--;
865 unlock_kernel(); 866 mutex_unlock(&cpqarray_mutex);
866 867
867 return 0; 868 return 0;
868} 869}
@@ -1217,9 +1218,9 @@ static int ida_ioctl(struct block_device *bdev, fmode_t mode,
1217{ 1218{
1218 int ret; 1219 int ret;
1219 1220
1220 lock_kernel(); 1221 mutex_lock(&cpqarray_mutex);
1221 ret = ida_locked_ioctl(bdev, mode, cmd, param); 1222 ret = ida_locked_ioctl(bdev, mode, cmd, param);
1222 unlock_kernel(); 1223 mutex_unlock(&cpqarray_mutex);
1223 1224
1224 return ret; 1225 return ret;
1225} 1226}
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index fa650dd85b90..e4b56119866e 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -32,7 +32,7 @@
32#include <asm/types.h> 32#include <asm/types.h>
33#include <net/sock.h> 33#include <net/sock.h>
34#include <linux/ctype.h> 34#include <linux/ctype.h>
35#include <linux/smp_lock.h> 35#include <linux/mutex.h>
36#include <linux/fs.h> 36#include <linux/fs.h>
37#include <linux/file.h> 37#include <linux/file.h>
38#include <linux/proc_fs.h> 38#include <linux/proc_fs.h>
@@ -64,6 +64,7 @@ struct after_state_chg_work {
64 struct completion *done; 64 struct completion *done;
65}; 65};
66 66
67static DEFINE_MUTEX(drbd_main_mutex);
67int drbdd_init(struct drbd_thread *); 68int drbdd_init(struct drbd_thread *);
68int drbd_worker(struct drbd_thread *); 69int drbd_worker(struct drbd_thread *);
69int drbd_asender(struct drbd_thread *); 70int drbd_asender(struct drbd_thread *);
@@ -2536,7 +2537,7 @@ static int drbd_open(struct block_device *bdev, fmode_t mode)
2536 unsigned long flags; 2537 unsigned long flags;
2537 int rv = 0; 2538 int rv = 0;
2538 2539
2539 lock_kernel(); 2540 mutex_lock(&drbd_main_mutex);
2540 spin_lock_irqsave(&mdev->req_lock, flags); 2541 spin_lock_irqsave(&mdev->req_lock, flags);
2541 /* to have a stable mdev->state.role 2542 /* to have a stable mdev->state.role
2542 * and no race with updating open_cnt */ 2543 * and no race with updating open_cnt */
@@ -2551,7 +2552,7 @@ static int drbd_open(struct block_device *bdev, fmode_t mode)
2551 if (!rv) 2552 if (!rv)
2552 mdev->open_cnt++; 2553 mdev->open_cnt++;
2553 spin_unlock_irqrestore(&mdev->req_lock, flags); 2554 spin_unlock_irqrestore(&mdev->req_lock, flags);
2554 unlock_kernel(); 2555 mutex_unlock(&drbd_main_mutex);
2555 2556
2556 return rv; 2557 return rv;
2557} 2558}
@@ -2559,9 +2560,9 @@ static int drbd_open(struct block_device *bdev, fmode_t mode)
2559static int drbd_release(struct gendisk *gd, fmode_t mode) 2560static int drbd_release(struct gendisk *gd, fmode_t mode)
2560{ 2561{
2561 struct drbd_conf *mdev = gd->private_data; 2562 struct drbd_conf *mdev = gd->private_data;
2562 lock_kernel(); 2563 mutex_lock(&drbd_main_mutex);
2563 mdev->open_cnt--; 2564 mdev->open_cnt--;
2564 unlock_kernel(); 2565 mutex_unlock(&drbd_main_mutex);
2565 return 0; 2566 return 0;
2566} 2567}
2567 2568
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index cf04c1b234ed..3b57459bb745 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -178,7 +178,6 @@ static int print_unex = 1;
178#include <linux/slab.h> 178#include <linux/slab.h>
179#include <linux/mm.h> 179#include <linux/mm.h>
180#include <linux/bio.h> 180#include <linux/bio.h>
181#include <linux/smp_lock.h>
182#include <linux/string.h> 181#include <linux/string.h>
183#include <linux/jiffies.h> 182#include <linux/jiffies.h>
184#include <linux/fcntl.h> 183#include <linux/fcntl.h>
@@ -199,6 +198,7 @@ static int print_unex = 1;
199 * It's been recommended that take about 1/4 of the default speed 198 * It's been recommended that take about 1/4 of the default speed
200 * in some more extreme cases. 199 * in some more extreme cases.
201 */ 200 */
201static DEFINE_MUTEX(floppy_mutex);
202static int slow_floppy; 202static int slow_floppy;
203 203
204#include <asm/dma.h> 204#include <asm/dma.h>
@@ -3553,9 +3553,9 @@ static int fd_ioctl(struct block_device *bdev, fmode_t mode,
3553{ 3553{
3554 int ret; 3554 int ret;
3555 3555
3556 lock_kernel(); 3556 mutex_lock(&floppy_mutex);
3557 ret = fd_locked_ioctl(bdev, mode, cmd, param); 3557 ret = fd_locked_ioctl(bdev, mode, cmd, param);
3558 unlock_kernel(); 3558 mutex_unlock(&floppy_mutex);
3559 3559
3560 return ret; 3560 return ret;
3561} 3561}
@@ -3616,7 +3616,7 @@ static int floppy_release(struct gendisk *disk, fmode_t mode)
3616{ 3616{
3617 int drive = (long)disk->private_data; 3617 int drive = (long)disk->private_data;
3618 3618
3619 lock_kernel(); 3619 mutex_lock(&floppy_mutex);
3620 mutex_lock(&open_lock); 3620 mutex_lock(&open_lock);
3621 if (UDRS->fd_ref < 0) 3621 if (UDRS->fd_ref < 0)
3622 UDRS->fd_ref = 0; 3622 UDRS->fd_ref = 0;
@@ -3627,7 +3627,7 @@ static int floppy_release(struct gendisk *disk, fmode_t mode)
3627 if (!UDRS->fd_ref) 3627 if (!UDRS->fd_ref)
3628 opened_bdev[drive] = NULL; 3628 opened_bdev[drive] = NULL;
3629 mutex_unlock(&open_lock); 3629 mutex_unlock(&open_lock);
3630 unlock_kernel(); 3630 mutex_unlock(&floppy_mutex);
3631 3631
3632 return 0; 3632 return 0;
3633} 3633}
@@ -3645,7 +3645,7 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
3645 int res = -EBUSY; 3645 int res = -EBUSY;
3646 char *tmp; 3646 char *tmp;
3647 3647
3648 lock_kernel(); 3648 mutex_lock(&floppy_mutex);
3649 mutex_lock(&open_lock); 3649 mutex_lock(&open_lock);
3650 old_dev = UDRS->fd_device; 3650 old_dev = UDRS->fd_device;
3651 if (opened_bdev[drive] && opened_bdev[drive] != bdev) 3651 if (opened_bdev[drive] && opened_bdev[drive] != bdev)
@@ -3722,7 +3722,7 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
3722 goto out; 3722 goto out;
3723 } 3723 }
3724 mutex_unlock(&open_lock); 3724 mutex_unlock(&open_lock);
3725 unlock_kernel(); 3725 mutex_unlock(&floppy_mutex);
3726 return 0; 3726 return 0;
3727out: 3727out:
3728 if (UDRS->fd_ref < 0) 3728 if (UDRS->fd_ref < 0)
@@ -3733,7 +3733,7 @@ out:
3733 opened_bdev[drive] = NULL; 3733 opened_bdev[drive] = NULL;
3734out2: 3734out2:
3735 mutex_unlock(&open_lock); 3735 mutex_unlock(&open_lock);
3736 unlock_kernel(); 3736 mutex_unlock(&floppy_mutex);
3737 return res; 3737 return res;
3738} 3738}
3739 3739
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 91797bbbe702..a10c8c9b6b78 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -67,7 +67,7 @@
67#include <linux/compat.h> 67#include <linux/compat.h>
68#include <linux/suspend.h> 68#include <linux/suspend.h>
69#include <linux/freezer.h> 69#include <linux/freezer.h>
70#include <linux/smp_lock.h> 70#include <linux/mutex.h>
71#include <linux/writeback.h> 71#include <linux/writeback.h>
72#include <linux/buffer_head.h> /* for invalidate_bdev() */ 72#include <linux/buffer_head.h> /* for invalidate_bdev() */
73#include <linux/completion.h> 73#include <linux/completion.h>
@@ -77,6 +77,7 @@
77 77
78#include <asm/uaccess.h> 78#include <asm/uaccess.h>
79 79
80static DEFINE_MUTEX(loop_mutex);
80static LIST_HEAD(loop_devices); 81static LIST_HEAD(loop_devices);
81static DEFINE_MUTEX(loop_devices_mutex); 82static DEFINE_MUTEX(loop_devices_mutex);
82 83
@@ -1409,11 +1410,11 @@ static int lo_open(struct block_device *bdev, fmode_t mode)
1409{ 1410{
1410 struct loop_device *lo = bdev->bd_disk->private_data; 1411 struct loop_device *lo = bdev->bd_disk->private_data;
1411 1412
1412 lock_kernel(); 1413 mutex_lock(&loop_mutex);
1413 mutex_lock(&lo->lo_ctl_mutex); 1414 mutex_lock(&lo->lo_ctl_mutex);
1414 lo->lo_refcnt++; 1415 lo->lo_refcnt++;
1415 mutex_unlock(&lo->lo_ctl_mutex); 1416 mutex_unlock(&lo->lo_ctl_mutex);
1416 unlock_kernel(); 1417 mutex_unlock(&loop_mutex);
1417 1418
1418 return 0; 1419 return 0;
1419} 1420}
@@ -1423,7 +1424,7 @@ static int lo_release(struct gendisk *disk, fmode_t mode)
1423 struct loop_device *lo = disk->private_data; 1424 struct loop_device *lo = disk->private_data;
1424 int err; 1425 int err;
1425 1426
1426 lock_kernel(); 1427 mutex_lock(&loop_mutex);
1427 mutex_lock(&lo->lo_ctl_mutex); 1428 mutex_lock(&lo->lo_ctl_mutex);
1428 1429
1429 if (--lo->lo_refcnt) 1430 if (--lo->lo_refcnt)
@@ -1448,7 +1449,7 @@ static int lo_release(struct gendisk *disk, fmode_t mode)
1448out: 1449out:
1449 mutex_unlock(&lo->lo_ctl_mutex); 1450 mutex_unlock(&lo->lo_ctl_mutex);
1450out_unlocked: 1451out_unlocked:
1451 lock_kernel(); 1452 mutex_unlock(&loop_mutex);
1452 return 0; 1453 return 0;
1453} 1454}
1454 1455
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 0daa422aa281..a32fb41246f8 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -24,7 +24,7 @@
24#include <linux/errno.h> 24#include <linux/errno.h>
25#include <linux/file.h> 25#include <linux/file.h>
26#include <linux/ioctl.h> 26#include <linux/ioctl.h>
27#include <linux/smp_lock.h> 27#include <linux/mutex.h>
28#include <linux/compiler.h> 28#include <linux/compiler.h>
29#include <linux/err.h> 29#include <linux/err.h>
30#include <linux/kernel.h> 30#include <linux/kernel.h>
@@ -53,6 +53,7 @@
53#define DBG_BLKDEV 0x0100 53#define DBG_BLKDEV 0x0100
54#define DBG_RX 0x0200 54#define DBG_RX 0x0200
55#define DBG_TX 0x0400 55#define DBG_TX 0x0400
56static DEFINE_MUTEX(nbd_mutex);
56static unsigned int debugflags; 57static unsigned int debugflags;
57#endif /* NDEBUG */ 58#endif /* NDEBUG */
58 59
@@ -717,11 +718,11 @@ static int nbd_ioctl(struct block_device *bdev, fmode_t mode,
717 dprintk(DBG_IOCTL, "%s: nbd_ioctl cmd=%s(0x%x) arg=%lu\n", 718 dprintk(DBG_IOCTL, "%s: nbd_ioctl cmd=%s(0x%x) arg=%lu\n",
718 lo->disk->disk_name, ioctl_cmd_to_ascii(cmd), cmd, arg); 719 lo->disk->disk_name, ioctl_cmd_to_ascii(cmd), cmd, arg);
719 720
720 lock_kernel(); 721 mutex_lock(&nbd_mutex);
721 mutex_lock(&lo->tx_lock); 722 mutex_lock(&lo->tx_lock);
722 error = __nbd_ioctl(bdev, lo, cmd, arg); 723 error = __nbd_ioctl(bdev, lo, cmd, arg);
723 mutex_unlock(&lo->tx_lock); 724 mutex_unlock(&lo->tx_lock);
724 unlock_kernel(); 725 mutex_unlock(&nbd_mutex);
725 726
726 return error; 727 return error;
727} 728}
diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c
index 76f8565e1e8d..62cec6afd7ad 100644
--- a/drivers/block/paride/pcd.c
+++ b/drivers/block/paride/pcd.c
@@ -138,9 +138,10 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_SLV, D_DLY};
138#include <linux/cdrom.h> 138#include <linux/cdrom.h>
139#include <linux/spinlock.h> 139#include <linux/spinlock.h>
140#include <linux/blkdev.h> 140#include <linux/blkdev.h>
141#include <linux/smp_lock.h> 141#include <linux/mutex.h>
142#include <asm/uaccess.h> 142#include <asm/uaccess.h>
143 143
144static DEFINE_MUTEX(pcd_mutex);
144static DEFINE_SPINLOCK(pcd_lock); 145static DEFINE_SPINLOCK(pcd_lock);
145 146
146module_param(verbose, bool, 0644); 147module_param(verbose, bool, 0644);
@@ -227,9 +228,9 @@ static int pcd_block_open(struct block_device *bdev, fmode_t mode)
227 struct pcd_unit *cd = bdev->bd_disk->private_data; 228 struct pcd_unit *cd = bdev->bd_disk->private_data;
228 int ret; 229 int ret;
229 230
230 lock_kernel(); 231 mutex_lock(&pcd_mutex);
231 ret = cdrom_open(&cd->info, bdev, mode); 232 ret = cdrom_open(&cd->info, bdev, mode);
232 unlock_kernel(); 233 mutex_unlock(&pcd_mutex);
233 234
234 return ret; 235 return ret;
235} 236}
@@ -237,9 +238,9 @@ static int pcd_block_open(struct block_device *bdev, fmode_t mode)
237static int pcd_block_release(struct gendisk *disk, fmode_t mode) 238static int pcd_block_release(struct gendisk *disk, fmode_t mode)
238{ 239{
239 struct pcd_unit *cd = disk->private_data; 240 struct pcd_unit *cd = disk->private_data;
240 lock_kernel(); 241 mutex_lock(&pcd_mutex);
241 cdrom_release(&cd->info, mode); 242 cdrom_release(&cd->info, mode);
242 unlock_kernel(); 243 mutex_unlock(&pcd_mutex);
243 return 0; 244 return 0;
244} 245}
245 246
@@ -249,9 +250,9 @@ static int pcd_block_ioctl(struct block_device *bdev, fmode_t mode,
249 struct pcd_unit *cd = bdev->bd_disk->private_data; 250 struct pcd_unit *cd = bdev->bd_disk->private_data;
250 int ret; 251 int ret;
251 252
252 lock_kernel(); 253 mutex_lock(&pcd_mutex);
253 ret = cdrom_ioctl(&cd->info, bdev, mode, cmd, arg); 254 ret = cdrom_ioctl(&cd->info, bdev, mode, cmd, arg);
254 unlock_kernel(); 255 mutex_unlock(&pcd_mutex);
255 256
256 return ret; 257 return ret;
257} 258}
diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c
index 985f0d4f1d1e..c0ee1558b9bb 100644
--- a/drivers/block/paride/pd.c
+++ b/drivers/block/paride/pd.c
@@ -153,10 +153,11 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_GEO, D_SBY, D_DLY, D_SLV};
153#include <linux/blkdev.h> 153#include <linux/blkdev.h>
154#include <linux/blkpg.h> 154#include <linux/blkpg.h>
155#include <linux/kernel.h> 155#include <linux/kernel.h>
156#include <linux/smp_lock.h> 156#include <linux/mutex.h>
157#include <asm/uaccess.h> 157#include <asm/uaccess.h>
158#include <linux/workqueue.h> 158#include <linux/workqueue.h>
159 159
160static DEFINE_MUTEX(pd_mutex);
160static DEFINE_SPINLOCK(pd_lock); 161static DEFINE_SPINLOCK(pd_lock);
161 162
162module_param(verbose, bool, 0); 163module_param(verbose, bool, 0);
@@ -736,14 +737,14 @@ static int pd_open(struct block_device *bdev, fmode_t mode)
736{ 737{
737 struct pd_unit *disk = bdev->bd_disk->private_data; 738 struct pd_unit *disk = bdev->bd_disk->private_data;
738 739
739 lock_kernel(); 740 mutex_lock(&pd_mutex);
740 disk->access++; 741 disk->access++;
741 742
742 if (disk->removable) { 743 if (disk->removable) {
743 pd_special_command(disk, pd_media_check); 744 pd_special_command(disk, pd_media_check);
744 pd_special_command(disk, pd_door_lock); 745 pd_special_command(disk, pd_door_lock);
745 } 746 }
746 unlock_kernel(); 747 mutex_unlock(&pd_mutex);
747 return 0; 748 return 0;
748} 749}
749 750
@@ -771,10 +772,10 @@ static int pd_ioctl(struct block_device *bdev, fmode_t mode,
771 772
772 switch (cmd) { 773 switch (cmd) {
773 case CDROMEJECT: 774 case CDROMEJECT:
774 lock_kernel(); 775 mutex_lock(&pd_mutex);
775 if (disk->access == 1) 776 if (disk->access == 1)
776 pd_special_command(disk, pd_eject); 777 pd_special_command(disk, pd_eject);
777 unlock_kernel(); 778 mutex_unlock(&pd_mutex);
778 return 0; 779 return 0;
779 default: 780 default:
780 return -EINVAL; 781 return -EINVAL;
@@ -785,10 +786,10 @@ static int pd_release(struct gendisk *p, fmode_t mode)
785{ 786{
786 struct pd_unit *disk = p->private_data; 787 struct pd_unit *disk = p->private_data;
787 788
788 lock_kernel(); 789 mutex_lock(&pd_mutex);
789 if (!--disk->access && disk->removable) 790 if (!--disk->access && disk->removable)
790 pd_special_command(disk, pd_door_unlock); 791 pd_special_command(disk, pd_door_unlock);
791 unlock_kernel(); 792 mutex_unlock(&pd_mutex);
792 793
793 return 0; 794 return 0;
794} 795}
diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c
index 4457b494882a..635f25dd9e10 100644
--- a/drivers/block/paride/pf.c
+++ b/drivers/block/paride/pf.c
@@ -152,9 +152,10 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_SLV, D_LUN, D_DLY};
152#include <linux/spinlock.h> 152#include <linux/spinlock.h>
153#include <linux/blkdev.h> 153#include <linux/blkdev.h>
154#include <linux/blkpg.h> 154#include <linux/blkpg.h>
155#include <linux/smp_lock.h> 155#include <linux/mutex.h>
156#include <asm/uaccess.h> 156#include <asm/uaccess.h>
157 157
158static DEFINE_MUTEX(pf_mutex);
158static DEFINE_SPINLOCK(pf_spin_lock); 159static DEFINE_SPINLOCK(pf_spin_lock);
159 160
160module_param(verbose, bool, 0644); 161module_param(verbose, bool, 0644);
@@ -302,7 +303,7 @@ static int pf_open(struct block_device *bdev, fmode_t mode)
302 struct pf_unit *pf = bdev->bd_disk->private_data; 303 struct pf_unit *pf = bdev->bd_disk->private_data;
303 int ret; 304 int ret;
304 305
305 lock_kernel(); 306 mutex_lock(&pf_mutex);
306 pf_identify(pf); 307 pf_identify(pf);
307 308
308 ret = -ENODEV; 309 ret = -ENODEV;
@@ -318,7 +319,7 @@ static int pf_open(struct block_device *bdev, fmode_t mode)
318 if (pf->removable) 319 if (pf->removable)
319 pf_lock(pf, 1); 320 pf_lock(pf, 1);
320out: 321out:
321 unlock_kernel(); 322 mutex_unlock(&pf_mutex);
322 return ret; 323 return ret;
323} 324}
324 325
@@ -349,9 +350,9 @@ static int pf_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, u
349 350
350 if (pf->access != 1) 351 if (pf->access != 1)
351 return -EBUSY; 352 return -EBUSY;
352 lock_kernel(); 353 mutex_lock(&pf_mutex);
353 pf_eject(pf); 354 pf_eject(pf);
354 unlock_kernel(); 355 mutex_unlock(&pf_mutex);
355 356
356 return 0; 357 return 0;
357} 358}
@@ -360,9 +361,9 @@ static int pf_release(struct gendisk *disk, fmode_t mode)
360{ 361{
361 struct pf_unit *pf = disk->private_data; 362 struct pf_unit *pf = disk->private_data;
362 363
363 lock_kernel(); 364 mutex_lock(&pf_mutex);
364 if (pf->access <= 0) { 365 if (pf->access <= 0) {
365 unlock_kernel(); 366 mutex_unlock(&pf_mutex);
366 return -EINVAL; 367 return -EINVAL;
367 } 368 }
368 369
@@ -371,7 +372,7 @@ static int pf_release(struct gendisk *disk, fmode_t mode)
371 if (!pf->access && pf->removable) 372 if (!pf->access && pf->removable)
372 pf_lock(pf, 0); 373 pf_lock(pf, 0);
373 374
374 unlock_kernel(); 375 mutex_unlock(&pf_mutex);
375 return 0; 376 return 0;
376 377
377} 378}
diff --git a/drivers/block/paride/pg.c b/drivers/block/paride/pg.c
index c397b3ddba9b..6b9a2000d56a 100644
--- a/drivers/block/paride/pg.c
+++ b/drivers/block/paride/pg.c
@@ -162,7 +162,7 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_SLV, D_DLY};
162#include <linux/pg.h> 162#include <linux/pg.h>
163#include <linux/device.h> 163#include <linux/device.h>
164#include <linux/sched.h> /* current, TASK_* */ 164#include <linux/sched.h> /* current, TASK_* */
165#include <linux/smp_lock.h> 165#include <linux/mutex.h>
166#include <linux/jiffies.h> 166#include <linux/jiffies.h>
167 167
168#include <asm/uaccess.h> 168#include <asm/uaccess.h>
@@ -193,6 +193,7 @@ module_param_array(drive3, int, NULL, 0);
193 193
194#define ATAPI_IDENTIFY 0x12 194#define ATAPI_IDENTIFY 0x12
195 195
196static DEFINE_MUTEX(pg_mutex);
196static int pg_open(struct inode *inode, struct file *file); 197static int pg_open(struct inode *inode, struct file *file);
197static int pg_release(struct inode *inode, struct file *file); 198static int pg_release(struct inode *inode, struct file *file);
198static ssize_t pg_read(struct file *filp, char __user *buf, 199static ssize_t pg_read(struct file *filp, char __user *buf,
@@ -234,6 +235,7 @@ static const struct file_operations pg_fops = {
234 .write = pg_write, 235 .write = pg_write,
235 .open = pg_open, 236 .open = pg_open,
236 .release = pg_release, 237 .release = pg_release,
238 .llseek = noop_llseek,
237}; 239};
238 240
239static void pg_init_units(void) 241static void pg_init_units(void)
@@ -518,7 +520,7 @@ static int pg_open(struct inode *inode, struct file *file)
518 struct pg *dev = &devices[unit]; 520 struct pg *dev = &devices[unit];
519 int ret = 0; 521 int ret = 0;
520 522
521 lock_kernel(); 523 mutex_lock(&pg_mutex);
522 if ((unit >= PG_UNITS) || (!dev->present)) { 524 if ((unit >= PG_UNITS) || (!dev->present)) {
523 ret = -ENODEV; 525 ret = -ENODEV;
524 goto out; 526 goto out;
@@ -547,7 +549,7 @@ static int pg_open(struct inode *inode, struct file *file)
547 file->private_data = dev; 549 file->private_data = dev;
548 550
549out: 551out:
550 unlock_kernel(); 552 mutex_unlock(&pg_mutex);
551 return ret; 553 return ret;
552} 554}
553 555
diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c
index bc5825fdeaab..7179f79d7468 100644
--- a/drivers/block/paride/pt.c
+++ b/drivers/block/paride/pt.c
@@ -146,7 +146,7 @@ static int (*drives[4])[6] = {&drive0, &drive1, &drive2, &drive3};
146#include <linux/mtio.h> 146#include <linux/mtio.h>
147#include <linux/device.h> 147#include <linux/device.h>
148#include <linux/sched.h> /* current, TASK_*, schedule_timeout() */ 148#include <linux/sched.h> /* current, TASK_*, schedule_timeout() */
149#include <linux/smp_lock.h> 149#include <linux/mutex.h>
150 150
151#include <asm/uaccess.h> 151#include <asm/uaccess.h>
152 152
@@ -189,6 +189,7 @@ module_param_array(drive3, int, NULL, 0);
189#define ATAPI_MODE_SENSE 0x1a 189#define ATAPI_MODE_SENSE 0x1a
190#define ATAPI_LOG_SENSE 0x4d 190#define ATAPI_LOG_SENSE 0x4d
191 191
192static DEFINE_MUTEX(pt_mutex);
192static int pt_open(struct inode *inode, struct file *file); 193static int pt_open(struct inode *inode, struct file *file);
193static long pt_ioctl(struct file *file, unsigned int cmd, unsigned long arg); 194static long pt_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
194static int pt_release(struct inode *inode, struct file *file); 195static int pt_release(struct inode *inode, struct file *file);
@@ -239,6 +240,7 @@ static const struct file_operations pt_fops = {
239 .unlocked_ioctl = pt_ioctl, 240 .unlocked_ioctl = pt_ioctl,
240 .open = pt_open, 241 .open = pt_open,
241 .release = pt_release, 242 .release = pt_release,
243 .llseek = noop_llseek,
242}; 244};
243 245
244/* sysfs class support */ 246/* sysfs class support */
@@ -650,9 +652,9 @@ static int pt_open(struct inode *inode, struct file *file)
650 struct pt_unit *tape = pt + unit; 652 struct pt_unit *tape = pt + unit;
651 int err; 653 int err;
652 654
653 lock_kernel(); 655 mutex_lock(&pt_mutex);
654 if (unit >= PT_UNITS || (!tape->present)) { 656 if (unit >= PT_UNITS || (!tape->present)) {
655 unlock_kernel(); 657 mutex_unlock(&pt_mutex);
656 return -ENODEV; 658 return -ENODEV;
657 } 659 }
658 660
@@ -681,12 +683,12 @@ static int pt_open(struct inode *inode, struct file *file)
681 } 683 }
682 684
683 file->private_data = tape; 685 file->private_data = tape;
684 unlock_kernel(); 686 mutex_unlock(&pt_mutex);
685 return 0; 687 return 0;
686 688
687out: 689out:
688 atomic_inc(&tape->available); 690 atomic_inc(&tape->available);
689 unlock_kernel(); 691 mutex_unlock(&pt_mutex);
690 return err; 692 return err;
691} 693}
692 694
@@ -704,15 +706,15 @@ static long pt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
704 switch (mtop.mt_op) { 706 switch (mtop.mt_op) {
705 707
706 case MTREW: 708 case MTREW:
707 lock_kernel(); 709 mutex_lock(&pt_mutex);
708 pt_rewind(tape); 710 pt_rewind(tape);
709 unlock_kernel(); 711 mutex_unlock(&pt_mutex);
710 return 0; 712 return 0;
711 713
712 case MTWEOF: 714 case MTWEOF:
713 lock_kernel(); 715 mutex_lock(&pt_mutex);
714 pt_write_fm(tape); 716 pt_write_fm(tape);
715 unlock_kernel(); 717 mutex_unlock(&pt_mutex);
716 return 0; 718 return 0;
717 719
718 default: 720 default:
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 37a2bb595076..ef58fccadad3 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -57,7 +57,6 @@
57#include <linux/seq_file.h> 57#include <linux/seq_file.h>
58#include <linux/miscdevice.h> 58#include <linux/miscdevice.h>
59#include <linux/freezer.h> 59#include <linux/freezer.h>
60#include <linux/smp_lock.h>
61#include <linux/mutex.h> 60#include <linux/mutex.h>
62#include <linux/slab.h> 61#include <linux/slab.h>
63#include <scsi/scsi_cmnd.h> 62#include <scsi/scsi_cmnd.h>
@@ -86,6 +85,7 @@
86 85
87#define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1)) 86#define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1))
88 87
88static DEFINE_MUTEX(pktcdvd_mutex);
89static struct pktcdvd_device *pkt_devs[MAX_WRITERS]; 89static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
90static struct proc_dir_entry *pkt_proc; 90static struct proc_dir_entry *pkt_proc;
91static int pktdev_major; 91static int pktdev_major;
@@ -2383,7 +2383,7 @@ static int pkt_open(struct block_device *bdev, fmode_t mode)
2383 2383
2384 VPRINTK(DRIVER_NAME": entering open\n"); 2384 VPRINTK(DRIVER_NAME": entering open\n");
2385 2385
2386 lock_kernel(); 2386 mutex_lock(&pktcdvd_mutex);
2387 mutex_lock(&ctl_mutex); 2387 mutex_lock(&ctl_mutex);
2388 pd = pkt_find_dev_from_minor(MINOR(bdev->bd_dev)); 2388 pd = pkt_find_dev_from_minor(MINOR(bdev->bd_dev));
2389 if (!pd) { 2389 if (!pd) {
@@ -2411,7 +2411,7 @@ static int pkt_open(struct block_device *bdev, fmode_t mode)
2411 } 2411 }
2412 2412
2413 mutex_unlock(&ctl_mutex); 2413 mutex_unlock(&ctl_mutex);
2414 unlock_kernel(); 2414 mutex_unlock(&pktcdvd_mutex);
2415 return 0; 2415 return 0;
2416 2416
2417out_dec: 2417out_dec:
@@ -2419,7 +2419,7 @@ out_dec:
2419out: 2419out:
2420 VPRINTK(DRIVER_NAME": failed open (%d)\n", ret); 2420 VPRINTK(DRIVER_NAME": failed open (%d)\n", ret);
2421 mutex_unlock(&ctl_mutex); 2421 mutex_unlock(&ctl_mutex);
2422 unlock_kernel(); 2422 mutex_unlock(&pktcdvd_mutex);
2423 return ret; 2423 return ret;
2424} 2424}
2425 2425
@@ -2428,7 +2428,7 @@ static int pkt_close(struct gendisk *disk, fmode_t mode)
2428 struct pktcdvd_device *pd = disk->private_data; 2428 struct pktcdvd_device *pd = disk->private_data;
2429 int ret = 0; 2429 int ret = 0;
2430 2430
2431 lock_kernel(); 2431 mutex_lock(&pktcdvd_mutex);
2432 mutex_lock(&ctl_mutex); 2432 mutex_lock(&ctl_mutex);
2433 pd->refcnt--; 2433 pd->refcnt--;
2434 BUG_ON(pd->refcnt < 0); 2434 BUG_ON(pd->refcnt < 0);
@@ -2437,7 +2437,7 @@ static int pkt_close(struct gendisk *disk, fmode_t mode)
2437 pkt_release_dev(pd, flush); 2437 pkt_release_dev(pd, flush);
2438 } 2438 }
2439 mutex_unlock(&ctl_mutex); 2439 mutex_unlock(&ctl_mutex);
2440 unlock_kernel(); 2440 mutex_unlock(&pktcdvd_mutex);
2441 return ret; 2441 return ret;
2442} 2442}
2443 2443
@@ -2773,7 +2773,7 @@ static int pkt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd,
2773 VPRINTK("pkt_ioctl: cmd %x, dev %d:%d\n", cmd, 2773 VPRINTK("pkt_ioctl: cmd %x, dev %d:%d\n", cmd,
2774 MAJOR(bdev->bd_dev), MINOR(bdev->bd_dev)); 2774 MAJOR(bdev->bd_dev), MINOR(bdev->bd_dev));
2775 2775
2776 lock_kernel(); 2776 mutex_lock(&pktcdvd_mutex);
2777 switch (cmd) { 2777 switch (cmd) {
2778 case CDROMEJECT: 2778 case CDROMEJECT:
2779 /* 2779 /*
@@ -2798,7 +2798,7 @@ static int pkt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd,
2798 VPRINTK(DRIVER_NAME": Unknown ioctl for %s (%x)\n", pd->name, cmd); 2798 VPRINTK(DRIVER_NAME": Unknown ioctl for %s (%x)\n", pd->name, cmd);
2799 ret = -ENOTTY; 2799 ret = -ENOTTY;
2800 } 2800 }
2801 unlock_kernel(); 2801 mutex_unlock(&pktcdvd_mutex);
2802 2802
2803 return ret; 2803 return ret;
2804} 2804}
@@ -3046,6 +3046,7 @@ static const struct file_operations pkt_ctl_fops = {
3046 .compat_ioctl = pkt_ctl_compat_ioctl, 3046 .compat_ioctl = pkt_ctl_compat_ioctl,
3047#endif 3047#endif
3048 .owner = THIS_MODULE, 3048 .owner = THIS_MODULE,
3049 .llseek = no_llseek,
3049}; 3050};
3050 3051
3051static struct miscdevice pkt_misc = { 3052static struct miscdevice pkt_misc = {
diff --git a/drivers/block/swim.c b/drivers/block/swim.c
index 2e46815876df..75333d0a3327 100644
--- a/drivers/block/swim.c
+++ b/drivers/block/swim.c
@@ -20,7 +20,7 @@
20#include <linux/fd.h> 20#include <linux/fd.h>
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/blkdev.h> 22#include <linux/blkdev.h>
23#include <linux/smp_lock.h> 23#include <linux/mutex.h>
24#include <linux/hdreg.h> 24#include <linux/hdreg.h>
25#include <linux/kernel.h> 25#include <linux/kernel.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
@@ -222,6 +222,7 @@ extern int swim_read_sector_header(struct swim __iomem *base,
222extern int swim_read_sector_data(struct swim __iomem *base, 222extern int swim_read_sector_data(struct swim __iomem *base,
223 unsigned char *data); 223 unsigned char *data);
224 224
225static DEFINE_MUTEX(swim_mutex);
225static inline void set_swim_mode(struct swim __iomem *base, int enable) 226static inline void set_swim_mode(struct swim __iomem *base, int enable)
226{ 227{
227 struct iwm __iomem *iwm_base; 228 struct iwm __iomem *iwm_base;
@@ -666,9 +667,9 @@ static int floppy_unlocked_open(struct block_device *bdev, fmode_t mode)
666{ 667{
667 int ret; 668 int ret;
668 669
669 lock_kernel(); 670 mutex_lock(&swim_mutex);
670 ret = floppy_open(bdev, mode); 671 ret = floppy_open(bdev, mode);
671 unlock_kernel(); 672 mutex_unlock(&swim_mutex);
672 673
673 return ret; 674 return ret;
674} 675}
@@ -678,7 +679,7 @@ static int floppy_release(struct gendisk *disk, fmode_t mode)
678 struct floppy_state *fs = disk->private_data; 679 struct floppy_state *fs = disk->private_data;
679 struct swim __iomem *base = fs->swd->base; 680 struct swim __iomem *base = fs->swd->base;
680 681
681 lock_kernel(); 682 mutex_lock(&swim_mutex);
682 if (fs->ref_count < 0) 683 if (fs->ref_count < 0)
683 fs->ref_count = 0; 684 fs->ref_count = 0;
684 else if (fs->ref_count > 0) 685 else if (fs->ref_count > 0)
@@ -686,7 +687,7 @@ static int floppy_release(struct gendisk *disk, fmode_t mode)
686 687
687 if (fs->ref_count == 0) 688 if (fs->ref_count == 0)
688 swim_motor(base, OFF); 689 swim_motor(base, OFF);
689 unlock_kernel(); 690 mutex_unlock(&swim_mutex);
690 691
691 return 0; 692 return 0;
692} 693}
@@ -704,9 +705,9 @@ static int floppy_ioctl(struct block_device *bdev, fmode_t mode,
704 case FDEJECT: 705 case FDEJECT:
705 if (fs->ref_count != 1) 706 if (fs->ref_count != 1)
706 return -EBUSY; 707 return -EBUSY;
707 lock_kernel(); 708 mutex_lock(&swim_mutex);
708 err = floppy_eject(fs); 709 err = floppy_eject(fs);
709 unlock_kernel(); 710 mutex_unlock(&swim_mutex);
710 return err; 711 return err;
711 712
712 case FDGETPRM: 713 case FDGETPRM:
diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c
index cc6a3864822c..bf3a5b859299 100644
--- a/drivers/block/swim3.c
+++ b/drivers/block/swim3.c
@@ -25,7 +25,7 @@
25#include <linux/ioctl.h> 25#include <linux/ioctl.h>
26#include <linux/blkdev.h> 26#include <linux/blkdev.h>
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/smp_lock.h> 28#include <linux/mutex.h>
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/spinlock.h> 30#include <linux/spinlock.h>
31#include <asm/io.h> 31#include <asm/io.h>
@@ -36,6 +36,7 @@
36#include <asm/machdep.h> 36#include <asm/machdep.h>
37#include <asm/pmac_feature.h> 37#include <asm/pmac_feature.h>
38 38
39static DEFINE_MUTEX(swim3_mutex);
39static struct request_queue *swim3_queue; 40static struct request_queue *swim3_queue;
40static struct gendisk *disks[2]; 41static struct gendisk *disks[2];
41static struct request *fd_req; 42static struct request *fd_req;
@@ -873,9 +874,9 @@ static int floppy_ioctl(struct block_device *bdev, fmode_t mode,
873{ 874{
874 int ret; 875 int ret;
875 876
876 lock_kernel(); 877 mutex_lock(&swim3_mutex);
877 ret = floppy_locked_ioctl(bdev, mode, cmd, param); 878 ret = floppy_locked_ioctl(bdev, mode, cmd, param);
878 unlock_kernel(); 879 mutex_unlock(&swim3_mutex);
879 880
880 return ret; 881 return ret;
881} 882}
@@ -953,9 +954,9 @@ static int floppy_unlocked_open(struct block_device *bdev, fmode_t mode)
953{ 954{
954 int ret; 955 int ret;
955 956
956 lock_kernel(); 957 mutex_lock(&swim3_mutex);
957 ret = floppy_open(bdev, mode); 958 ret = floppy_open(bdev, mode);
958 unlock_kernel(); 959 mutex_unlock(&swim3_mutex);
959 960
960 return ret; 961 return ret;
961} 962}
@@ -964,13 +965,13 @@ static int floppy_release(struct gendisk *disk, fmode_t mode)
964{ 965{
965 struct floppy_state *fs = disk->private_data; 966 struct floppy_state *fs = disk->private_data;
966 struct swim3 __iomem *sw = fs->swim3; 967 struct swim3 __iomem *sw = fs->swim3;
967 lock_kernel(); 968 mutex_lock(&swim3_mutex);
968 if (fs->ref_count > 0 && --fs->ref_count == 0) { 969 if (fs->ref_count > 0 && --fs->ref_count == 0) {
969 swim3_action(fs, MOTOR_OFF); 970 swim3_action(fs, MOTOR_OFF);
970 out_8(&sw->control_bic, 0xff); 971 out_8(&sw->control_bic, 0xff);
971 swim3_select(fs, RELAX); 972 swim3_select(fs, RELAX);
972 } 973 }
973 unlock_kernel(); 974 mutex_unlock(&swim3_mutex);
974 return 0; 975 return 0;
975} 976}
976 977
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index c48e14878582..b5690a045a01 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -28,7 +28,7 @@
28#include <linux/timer.h> 28#include <linux/timer.h>
29#include <linux/scatterlist.h> 29#include <linux/scatterlist.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/smp_lock.h> 31#include <linux/mutex.h>
32#include <scsi/scsi.h> 32#include <scsi/scsi.h>
33 33
34#define DRV_NAME "ub" 34#define DRV_NAME "ub"
@@ -248,6 +248,7 @@ struct ub_completion {
248 spinlock_t lock; 248 spinlock_t lock;
249}; 249};
250 250
251static DEFINE_MUTEX(ub_mutex);
251static inline void ub_init_completion(struct ub_completion *x) 252static inline void ub_init_completion(struct ub_completion *x)
252{ 253{
253 x->done = 0; 254 x->done = 0;
@@ -1715,9 +1716,9 @@ static int ub_bd_unlocked_open(struct block_device *bdev, fmode_t mode)
1715{ 1716{
1716 int ret; 1717 int ret;
1717 1718
1718 lock_kernel(); 1719 mutex_lock(&ub_mutex);
1719 ret = ub_bd_open(bdev, mode); 1720 ret = ub_bd_open(bdev, mode);
1720 unlock_kernel(); 1721 mutex_unlock(&ub_mutex);
1721 1722
1722 return ret; 1723 return ret;
1723} 1724}
@@ -1730,9 +1731,9 @@ static int ub_bd_release(struct gendisk *disk, fmode_t mode)
1730 struct ub_lun *lun = disk->private_data; 1731 struct ub_lun *lun = disk->private_data;
1731 struct ub_dev *sc = lun->udev; 1732 struct ub_dev *sc = lun->udev;
1732 1733
1733 lock_kernel(); 1734 mutex_lock(&ub_mutex);
1734 ub_put(sc); 1735 ub_put(sc);
1735 unlock_kernel(); 1736 mutex_unlock(&ub_mutex);
1736 1737
1737 return 0; 1738 return 0;
1738} 1739}
@@ -1747,9 +1748,9 @@ static int ub_bd_ioctl(struct block_device *bdev, fmode_t mode,
1747 void __user *usermem = (void __user *) arg; 1748 void __user *usermem = (void __user *) arg;
1748 int ret; 1749 int ret;
1749 1750
1750 lock_kernel(); 1751 mutex_lock(&ub_mutex);
1751 ret = scsi_cmd_ioctl(disk->queue, disk, mode, cmd, usermem); 1752 ret = scsi_cmd_ioctl(disk->queue, disk, mode, cmd, usermem);
1752 unlock_kernel(); 1753 mutex_unlock(&ub_mutex);
1753 1754
1754 return ret; 1755 return ret;
1755} 1756}
diff --git a/drivers/block/viodasd.c b/drivers/block/viodasd.c
index f651e51a3319..e2ff697697c2 100644
--- a/drivers/block/viodasd.c
+++ b/drivers/block/viodasd.c
@@ -41,7 +41,7 @@
41#include <linux/errno.h> 41#include <linux/errno.h>
42#include <linux/init.h> 42#include <linux/init.h>
43#include <linux/string.h> 43#include <linux/string.h>
44#include <linux/smp_lock.h> 44#include <linux/mutex.h>
45#include <linux/dma-mapping.h> 45#include <linux/dma-mapping.h>
46#include <linux/completion.h> 46#include <linux/completion.h>
47#include <linux/device.h> 47#include <linux/device.h>
@@ -73,6 +73,7 @@ enum {
73 MAX_DISK_NAME = FIELD_SIZEOF(struct gendisk, disk_name) 73 MAX_DISK_NAME = FIELD_SIZEOF(struct gendisk, disk_name)
74}; 74};
75 75
76static DEFINE_MUTEX(viodasd_mutex);
76static DEFINE_SPINLOCK(viodasd_spinlock); 77static DEFINE_SPINLOCK(viodasd_spinlock);
77 78
78#define VIOMAXREQ 16 79#define VIOMAXREQ 16
@@ -180,9 +181,9 @@ static int viodasd_unlocked_open(struct block_device *bdev, fmode_t mode)
180{ 181{
181 int ret; 182 int ret;
182 183
183 lock_kernel(); 184 mutex_lock(&viodasd_mutex);
184 ret = viodasd_open(bdev, mode); 185 ret = viodasd_open(bdev, mode);
185 unlock_kernel(); 186 mutex_unlock(&viodasd_mutex);
186 187
187 return ret; 188 return ret;
188} 189}
@@ -196,7 +197,7 @@ static int viodasd_release(struct gendisk *disk, fmode_t mode)
196 struct viodasd_device *d = disk->private_data; 197 struct viodasd_device *d = disk->private_data;
197 HvLpEvent_Rc hvrc; 198 HvLpEvent_Rc hvrc;
198 199
199 lock_kernel(); 200 mutex_lock(&viodasd_mutex);
200 /* Send the event to OS/400. We DON'T expect a response */ 201 /* Send the event to OS/400. We DON'T expect a response */
201 hvrc = HvCallEvent_signalLpEventFast(viopath_hostLp, 202 hvrc = HvCallEvent_signalLpEventFast(viopath_hostLp,
202 HvLpEvent_Type_VirtualIo, 203 HvLpEvent_Type_VirtualIo,
@@ -210,7 +211,7 @@ static int viodasd_release(struct gendisk *disk, fmode_t mode)
210 if (hvrc != 0) 211 if (hvrc != 0)
211 pr_warning("HV close call failed %d\n", (int)hvrc); 212 pr_warning("HV close call failed %d\n", (int)hvrc);
212 213
213 unlock_kernel(); 214 mutex_unlock(&viodasd_mutex);
214 215
215 return 0; 216 return 0;
216} 217}
diff --git a/drivers/block/xd.c b/drivers/block/xd.c
index d5a3cd750561..4abd2bcd20fb 100644
--- a/drivers/block/xd.c
+++ b/drivers/block/xd.c
@@ -46,7 +46,7 @@
46#include <linux/init.h> 46#include <linux/init.h>
47#include <linux/wait.h> 47#include <linux/wait.h>
48#include <linux/blkdev.h> 48#include <linux/blkdev.h>
49#include <linux/smp_lock.h> 49#include <linux/mutex.h>
50#include <linux/blkpg.h> 50#include <linux/blkpg.h>
51#include <linux/delay.h> 51#include <linux/delay.h>
52#include <linux/io.h> 52#include <linux/io.h>
@@ -58,6 +58,7 @@
58 58
59#include "xd.h" 59#include "xd.h"
60 60
61static DEFINE_MUTEX(xd_mutex);
61static void __init do_xd_setup (int *integers); 62static void __init do_xd_setup (int *integers);
62#ifdef MODULE 63#ifdef MODULE
63static int xd[5] = { -1,-1,-1,-1, }; 64static int xd[5] = { -1,-1,-1,-1, };
@@ -381,9 +382,9 @@ static int xd_ioctl(struct block_device *bdev, fmode_t mode,
381{ 382{
382 int ret; 383 int ret;
383 384
384 lock_kernel(); 385 mutex_lock(&xd_mutex);
385 ret = xd_locked_ioctl(bdev, mode, cmd, param); 386 ret = xd_locked_ioctl(bdev, mode, cmd, param);
386 unlock_kernel(); 387 mutex_unlock(&xd_mutex);
387 388
388 return ret; 389 return ret;
389} 390}
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index ab735a605cf3..3ff06f475eef 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -41,7 +41,7 @@
41#include <linux/cdrom.h> 41#include <linux/cdrom.h>
42#include <linux/module.h> 42#include <linux/module.h>
43#include <linux/slab.h> 43#include <linux/slab.h>
44#include <linux/smp_lock.h> 44#include <linux/mutex.h>
45#include <linux/scatterlist.h> 45#include <linux/scatterlist.h>
46 46
47#include <xen/xen.h> 47#include <xen/xen.h>
@@ -69,6 +69,7 @@ struct blk_shadow {
69 unsigned long frame[BLKIF_MAX_SEGMENTS_PER_REQUEST]; 69 unsigned long frame[BLKIF_MAX_SEGMENTS_PER_REQUEST];
70}; 70};
71 71
72static DEFINE_MUTEX(blkfront_mutex);
72static const struct block_device_operations xlvbd_block_fops; 73static const struct block_device_operations xlvbd_block_fops;
73 74
74#define BLK_RING_SIZE __RING_SIZE((struct blkif_sring *)0, PAGE_SIZE) 75#define BLK_RING_SIZE __RING_SIZE((struct blkif_sring *)0, PAGE_SIZE)
@@ -1201,7 +1202,7 @@ static int blkif_open(struct block_device *bdev, fmode_t mode)
1201 struct blkfront_info *info; 1202 struct blkfront_info *info;
1202 int err = 0; 1203 int err = 0;
1203 1204
1204 lock_kernel(); 1205 mutex_lock(&blkfront_mutex);
1205 1206
1206 info = disk->private_data; 1207 info = disk->private_data;
1207 if (!info) { 1208 if (!info) {
@@ -1219,7 +1220,7 @@ static int blkif_open(struct block_device *bdev, fmode_t mode)
1219 mutex_unlock(&info->mutex); 1220 mutex_unlock(&info->mutex);
1220 1221
1221out: 1222out:
1222 unlock_kernel(); 1223 mutex_unlock(&blkfront_mutex);
1223 return err; 1224 return err;
1224} 1225}
1225 1226
@@ -1229,7 +1230,7 @@ static int blkif_release(struct gendisk *disk, fmode_t mode)
1229 struct block_device *bdev; 1230 struct block_device *bdev;
1230 struct xenbus_device *xbdev; 1231 struct xenbus_device *xbdev;
1231 1232
1232 lock_kernel(); 1233 mutex_lock(&blkfront_mutex);
1233 1234
1234 bdev = bdget_disk(disk, 0); 1235 bdev = bdget_disk(disk, 0);
1235 bdput(bdev); 1236 bdput(bdev);
@@ -1263,7 +1264,7 @@ static int blkif_release(struct gendisk *disk, fmode_t mode)
1263 } 1264 }
1264 1265
1265out: 1266out:
1266 unlock_kernel(); 1267 mutex_unlock(&blkfront_mutex);
1267 return 0; 1268 return 0;
1268} 1269}
1269 1270
diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c
index 057413bb16e2..6e968cd4893c 100644
--- a/drivers/block/xsysace.c
+++ b/drivers/block/xsysace.c
@@ -89,7 +89,7 @@
89#include <linux/delay.h> 89#include <linux/delay.h>
90#include <linux/slab.h> 90#include <linux/slab.h>
91#include <linux/blkdev.h> 91#include <linux/blkdev.h>
92#include <linux/smp_lock.h> 92#include <linux/mutex.h>
93#include <linux/ata.h> 93#include <linux/ata.h>
94#include <linux/hdreg.h> 94#include <linux/hdreg.h>
95#include <linux/platform_device.h> 95#include <linux/platform_device.h>
@@ -214,6 +214,7 @@ struct ace_device {
214 u16 cf_id[ATA_ID_WORDS]; 214 u16 cf_id[ATA_ID_WORDS];
215}; 215};
216 216
217static DEFINE_MUTEX(xsysace_mutex);
217static int ace_major; 218static int ace_major;
218 219
219/* --------------------------------------------------------------------- 220/* ---------------------------------------------------------------------
@@ -903,13 +904,13 @@ static int ace_open(struct block_device *bdev, fmode_t mode)
903 904
904 dev_dbg(ace->dev, "ace_open() users=%i\n", ace->users + 1); 905 dev_dbg(ace->dev, "ace_open() users=%i\n", ace->users + 1);
905 906
906 lock_kernel(); 907 mutex_lock(&xsysace_mutex);
907 spin_lock_irqsave(&ace->lock, flags); 908 spin_lock_irqsave(&ace->lock, flags);
908 ace->users++; 909 ace->users++;
909 spin_unlock_irqrestore(&ace->lock, flags); 910 spin_unlock_irqrestore(&ace->lock, flags);
910 911
911 check_disk_change(bdev); 912 check_disk_change(bdev);
912 unlock_kernel(); 913 mutex_unlock(&xsysace_mutex);
913 914
914 return 0; 915 return 0;
915} 916}
@@ -922,7 +923,7 @@ static int ace_release(struct gendisk *disk, fmode_t mode)
922 923
923 dev_dbg(ace->dev, "ace_release() users=%i\n", ace->users - 1); 924 dev_dbg(ace->dev, "ace_release() users=%i\n", ace->users - 1);
924 925
925 lock_kernel(); 926 mutex_lock(&xsysace_mutex);
926 spin_lock_irqsave(&ace->lock, flags); 927 spin_lock_irqsave(&ace->lock, flags);
927 ace->users--; 928 ace->users--;
928 if (ace->users == 0) { 929 if (ace->users == 0) {
@@ -930,7 +931,7 @@ static int ace_release(struct gendisk *disk, fmode_t mode)
930 ace_out(ace, ACE_CTRL, val & ~ACE_CTRL_LOCKREQ); 931 ace_out(ace, ACE_CTRL, val & ~ACE_CTRL_LOCKREQ);
931 } 932 }
932 spin_unlock_irqrestore(&ace->lock, flags); 933 spin_unlock_irqrestore(&ace->lock, flags);
933 unlock_kernel(); 934 mutex_unlock(&xsysace_mutex);
934 return 0; 935 return 0;
935} 936}
936 937
diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c
index d75b2bb601ad..dcd4cfcf4126 100644
--- a/drivers/block/z2ram.c
+++ b/drivers/block/z2ram.c
@@ -33,7 +33,7 @@
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/blkdev.h> 34#include <linux/blkdev.h>
35#include <linux/bitops.h> 35#include <linux/bitops.h>
36#include <linux/smp_lock.h> 36#include <linux/mutex.h>
37#include <linux/slab.h> 37#include <linux/slab.h>
38 38
39#include <asm/setup.h> 39#include <asm/setup.h>
@@ -57,6 +57,7 @@ extern struct mem_info m68k_memory[NUM_MEMINFO];
57 57
58#define Z2RAM_CHUNK1024 ( Z2RAM_CHUNKSIZE >> 10 ) 58#define Z2RAM_CHUNK1024 ( Z2RAM_CHUNKSIZE >> 10 )
59 59
60static DEFINE_MUTEX(z2ram_mutex);
60static u_long *z2ram_map = NULL; 61static u_long *z2ram_map = NULL;
61static u_long z2ram_size = 0; 62static u_long z2ram_size = 0;
62static int z2_count = 0; 63static int z2_count = 0;
@@ -154,7 +155,7 @@ static int z2_open(struct block_device *bdev, fmode_t mode)
154 155
155 device = MINOR(bdev->bd_dev); 156 device = MINOR(bdev->bd_dev);
156 157
157 lock_kernel(); 158 mutex_lock(&z2ram_mutex);
158 if ( current_device != -1 && current_device != device ) 159 if ( current_device != -1 && current_device != device )
159 { 160 {
160 rc = -EBUSY; 161 rc = -EBUSY;
@@ -296,25 +297,25 @@ static int z2_open(struct block_device *bdev, fmode_t mode)
296 set_capacity(z2ram_gendisk, z2ram_size >> 9); 297 set_capacity(z2ram_gendisk, z2ram_size >> 9);
297 } 298 }
298 299
299 unlock_kernel(); 300 mutex_unlock(&z2ram_mutex);
300 return 0; 301 return 0;
301 302
302err_out_kfree: 303err_out_kfree:
303 kfree(z2ram_map); 304 kfree(z2ram_map);
304err_out: 305err_out:
305 unlock_kernel(); 306 mutex_unlock(&z2ram_mutex);
306 return rc; 307 return rc;
307} 308}
308 309
309static int 310static int
310z2_release(struct gendisk *disk, fmode_t mode) 311z2_release(struct gendisk *disk, fmode_t mode)
311{ 312{
312 lock_kernel(); 313 mutex_lock(&z2ram_mutex);
313 if ( current_device == -1 ) { 314 if ( current_device == -1 ) {
314 unlock_kernel(); 315 mutex_unlock(&z2ram_mutex);
315 return 0; 316 return 0;
316 } 317 }
317 unlock_kernel(); 318 mutex_unlock(&z2ram_mutex);
318 /* 319 /*
319 * FIXME: unmap memory 320 * FIXME: unmap memory
320 */ 321 */
diff --git a/drivers/bluetooth/btmrvl_debugfs.c b/drivers/bluetooth/btmrvl_debugfs.c
index 54739b08c308..fd6305bf953e 100644
--- a/drivers/bluetooth/btmrvl_debugfs.c
+++ b/drivers/bluetooth/btmrvl_debugfs.c
@@ -92,6 +92,7 @@ static const struct file_operations btmrvl_hscfgcmd_fops = {
92 .read = btmrvl_hscfgcmd_read, 92 .read = btmrvl_hscfgcmd_read,
93 .write = btmrvl_hscfgcmd_write, 93 .write = btmrvl_hscfgcmd_write,
94 .open = btmrvl_open_generic, 94 .open = btmrvl_open_generic,
95 .llseek = default_llseek,
95}; 96};
96 97
97static ssize_t btmrvl_psmode_write(struct file *file, const char __user *ubuf, 98static ssize_t btmrvl_psmode_write(struct file *file, const char __user *ubuf,
@@ -130,6 +131,7 @@ static const struct file_operations btmrvl_psmode_fops = {
130 .read = btmrvl_psmode_read, 131 .read = btmrvl_psmode_read,
131 .write = btmrvl_psmode_write, 132 .write = btmrvl_psmode_write,
132 .open = btmrvl_open_generic, 133 .open = btmrvl_open_generic,
134 .llseek = default_llseek,
133}; 135};
134 136
135static ssize_t btmrvl_pscmd_write(struct file *file, const char __user *ubuf, 137static ssize_t btmrvl_pscmd_write(struct file *file, const char __user *ubuf,
@@ -173,6 +175,7 @@ static const struct file_operations btmrvl_pscmd_fops = {
173 .read = btmrvl_pscmd_read, 175 .read = btmrvl_pscmd_read,
174 .write = btmrvl_pscmd_write, 176 .write = btmrvl_pscmd_write,
175 .open = btmrvl_open_generic, 177 .open = btmrvl_open_generic,
178 .llseek = default_llseek,
176}; 179};
177 180
178static ssize_t btmrvl_gpiogap_write(struct file *file, const char __user *ubuf, 181static ssize_t btmrvl_gpiogap_write(struct file *file, const char __user *ubuf,
@@ -211,6 +214,7 @@ static const struct file_operations btmrvl_gpiogap_fops = {
211 .read = btmrvl_gpiogap_read, 214 .read = btmrvl_gpiogap_read,
212 .write = btmrvl_gpiogap_write, 215 .write = btmrvl_gpiogap_write,
213 .open = btmrvl_open_generic, 216 .open = btmrvl_open_generic,
217 .llseek = default_llseek,
214}; 218};
215 219
216static ssize_t btmrvl_hscmd_write(struct file *file, const char __user *ubuf, 220static ssize_t btmrvl_hscmd_write(struct file *file, const char __user *ubuf,
@@ -252,6 +256,7 @@ static const struct file_operations btmrvl_hscmd_fops = {
252 .read = btmrvl_hscmd_read, 256 .read = btmrvl_hscmd_read,
253 .write = btmrvl_hscmd_write, 257 .write = btmrvl_hscmd_write,
254 .open = btmrvl_open_generic, 258 .open = btmrvl_open_generic,
259 .llseek = default_llseek,
255}; 260};
256 261
257static ssize_t btmrvl_hsmode_write(struct file *file, const char __user *ubuf, 262static ssize_t btmrvl_hsmode_write(struct file *file, const char __user *ubuf,
@@ -289,6 +294,7 @@ static const struct file_operations btmrvl_hsmode_fops = {
289 .read = btmrvl_hsmode_read, 294 .read = btmrvl_hsmode_read,
290 .write = btmrvl_hsmode_write, 295 .write = btmrvl_hsmode_write,
291 .open = btmrvl_open_generic, 296 .open = btmrvl_open_generic,
297 .llseek = default_llseek,
292}; 298};
293 299
294static ssize_t btmrvl_curpsmode_read(struct file *file, char __user *userbuf, 300static ssize_t btmrvl_curpsmode_read(struct file *file, char __user *userbuf,
@@ -306,6 +312,7 @@ static ssize_t btmrvl_curpsmode_read(struct file *file, char __user *userbuf,
306static const struct file_operations btmrvl_curpsmode_fops = { 312static const struct file_operations btmrvl_curpsmode_fops = {
307 .read = btmrvl_curpsmode_read, 313 .read = btmrvl_curpsmode_read,
308 .open = btmrvl_open_generic, 314 .open = btmrvl_open_generic,
315 .llseek = default_llseek,
309}; 316};
310 317
311static ssize_t btmrvl_psstate_read(struct file *file, char __user * userbuf, 318static ssize_t btmrvl_psstate_read(struct file *file, char __user * userbuf,
@@ -323,6 +330,7 @@ static ssize_t btmrvl_psstate_read(struct file *file, char __user * userbuf,
323static const struct file_operations btmrvl_psstate_fops = { 330static const struct file_operations btmrvl_psstate_fops = {
324 .read = btmrvl_psstate_read, 331 .read = btmrvl_psstate_read,
325 .open = btmrvl_open_generic, 332 .open = btmrvl_open_generic,
333 .llseek = default_llseek,
326}; 334};
327 335
328static ssize_t btmrvl_hsstate_read(struct file *file, char __user *userbuf, 336static ssize_t btmrvl_hsstate_read(struct file *file, char __user *userbuf,
@@ -340,6 +348,7 @@ static ssize_t btmrvl_hsstate_read(struct file *file, char __user *userbuf,
340static const struct file_operations btmrvl_hsstate_fops = { 348static const struct file_operations btmrvl_hsstate_fops = {
341 .read = btmrvl_hsstate_read, 349 .read = btmrvl_hsstate_read,
342 .open = btmrvl_open_generic, 350 .open = btmrvl_open_generic,
351 .llseek = default_llseek,
343}; 352};
344 353
345static ssize_t btmrvl_txdnldready_read(struct file *file, char __user *userbuf, 354static ssize_t btmrvl_txdnldready_read(struct file *file, char __user *userbuf,
@@ -358,6 +367,7 @@ static ssize_t btmrvl_txdnldready_read(struct file *file, char __user *userbuf,
358static const struct file_operations btmrvl_txdnldready_fops = { 367static const struct file_operations btmrvl_txdnldready_fops = {
359 .read = btmrvl_txdnldready_read, 368 .read = btmrvl_txdnldready_read,
360 .open = btmrvl_open_generic, 369 .open = btmrvl_open_generic,
370 .llseek = default_llseek,
361}; 371};
362 372
363void btmrvl_debugfs_init(struct hci_dev *hdev) 373void btmrvl_debugfs_init(struct hci_dev *hdev)
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index 998833d93c13..17361bad46dd 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -256,9 +256,16 @@ static int hci_uart_tty_open(struct tty_struct *tty)
256 256
257 BT_DBG("tty %p", tty); 257 BT_DBG("tty %p", tty);
258 258
259 /* FIXME: This btw is bogus, nothing requires the old ldisc to clear
260 the pointer */
259 if (hu) 261 if (hu)
260 return -EEXIST; 262 return -EEXIST;
261 263
264 /* Error if the tty has no write op instead of leaving an exploitable
265 hole */
266 if (tty->ops->write == NULL)
267 return -EOPNOTSUPP;
268
262 if (!(hu = kzalloc(sizeof(struct hci_uart), GFP_KERNEL))) { 269 if (!(hu = kzalloc(sizeof(struct hci_uart), GFP_KERNEL))) {
263 BT_ERR("Can't allocate control structure"); 270 BT_ERR("Can't allocate control structure");
264 return -ENFILE; 271 return -ENFILE;
diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
index 3aa7b2a54b6f..67c180c2c1e0 100644
--- a/drivers/bluetooth/hci_vhci.c
+++ b/drivers/bluetooth/hci_vhci.c
@@ -282,6 +282,7 @@ static const struct file_operations vhci_fops = {
282 .poll = vhci_poll, 282 .poll = vhci_poll,
283 .open = vhci_open, 283 .open = vhci_open,
284 .release = vhci_release, 284 .release = vhci_release,
285 .llseek = no_llseek,
285}; 286};
286 287
287static struct miscdevice vhci_miscdev= { 288static struct miscdevice vhci_miscdev= {
diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
index 261107d1457c..3af6516919b7 100644
--- a/drivers/cdrom/gdrom.c
+++ b/drivers/cdrom/gdrom.c
@@ -34,7 +34,7 @@
34#include <linux/blkdev.h> 34#include <linux/blkdev.h>
35#include <linux/interrupt.h> 35#include <linux/interrupt.h>
36#include <linux/device.h> 36#include <linux/device.h>
37#include <linux/smp_lock.h> 37#include <linux/mutex.h>
38#include <linux/wait.h> 38#include <linux/wait.h>
39#include <linux/workqueue.h> 39#include <linux/workqueue.h>
40#include <linux/platform_device.h> 40#include <linux/platform_device.h>
@@ -81,6 +81,7 @@
81 81
82#define GDROM_DEFAULT_TIMEOUT (HZ * 7) 82#define GDROM_DEFAULT_TIMEOUT (HZ * 7)
83 83
84static DEFINE_MUTEX(gdrom_mutex);
84static const struct { 85static const struct {
85 int sense_key; 86 int sense_key;
86 const char * const text; 87 const char * const text;
@@ -494,17 +495,17 @@ static struct cdrom_device_ops gdrom_ops = {
494static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode) 495static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
495{ 496{
496 int ret; 497 int ret;
497 lock_kernel(); 498 mutex_lock(&gdrom_mutex);
498 ret = cdrom_open(gd.cd_info, bdev, mode); 499 ret = cdrom_open(gd.cd_info, bdev, mode);
499 unlock_kernel(); 500 mutex_unlock(&gdrom_mutex);
500 return ret; 501 return ret;
501} 502}
502 503
503static int gdrom_bdops_release(struct gendisk *disk, fmode_t mode) 504static int gdrom_bdops_release(struct gendisk *disk, fmode_t mode)
504{ 505{
505 lock_kernel(); 506 mutex_lock(&gdrom_mutex);
506 cdrom_release(gd.cd_info, mode); 507 cdrom_release(gd.cd_info, mode);
507 unlock_kernel(); 508 mutex_unlock(&gdrom_mutex);
508 return 0; 509 return 0;
509} 510}
510 511
@@ -518,9 +519,9 @@ static int gdrom_bdops_ioctl(struct block_device *bdev, fmode_t mode,
518{ 519{
519 int ret; 520 int ret;
520 521
521 lock_kernel(); 522 mutex_lock(&gdrom_mutex);
522 ret = cdrom_ioctl(gd.cd_info, bdev, mode, cmd, arg); 523 ret = cdrom_ioctl(gd.cd_info, bdev, mode, cmd, arg);
523 unlock_kernel(); 524 mutex_unlock(&gdrom_mutex);
524 525
525 return ret; 526 return ret;
526} 527}
diff --git a/drivers/cdrom/viocd.c b/drivers/cdrom/viocd.c
index 56bf9f44700c..be73a9b493a6 100644
--- a/drivers/cdrom/viocd.c
+++ b/drivers/cdrom/viocd.c
@@ -42,7 +42,7 @@
42#include <linux/module.h> 42#include <linux/module.h>
43#include <linux/completion.h> 43#include <linux/completion.h>
44#include <linux/proc_fs.h> 44#include <linux/proc_fs.h>
45#include <linux/smp_lock.h> 45#include <linux/mutex.h>
46#include <linux/seq_file.h> 46#include <linux/seq_file.h>
47#include <linux/scatterlist.h> 47#include <linux/scatterlist.h>
48 48
@@ -61,6 +61,7 @@
61 */ 61 */
62#define VIOCD_MAX_CD HVMAXARCHITECTEDVIRTUALCDROMS 62#define VIOCD_MAX_CD HVMAXARCHITECTEDVIRTUALCDROMS
63 63
64static DEFINE_MUTEX(viocd_mutex);
64static const struct vio_error_entry viocd_err_table[] = { 65static const struct vio_error_entry viocd_err_table[] = {
65 {0x0201, EINVAL, "Invalid Range"}, 66 {0x0201, EINVAL, "Invalid Range"},
66 {0x0202, EINVAL, "Invalid Token"}, 67 {0x0202, EINVAL, "Invalid Token"},
@@ -156,9 +157,9 @@ static int viocd_blk_open(struct block_device *bdev, fmode_t mode)
156 struct disk_info *di = bdev->bd_disk->private_data; 157 struct disk_info *di = bdev->bd_disk->private_data;
157 int ret; 158 int ret;
158 159
159 lock_kernel(); 160 mutex_lock(&viocd_mutex);
160 ret = cdrom_open(&di->viocd_info, bdev, mode); 161 ret = cdrom_open(&di->viocd_info, bdev, mode);
161 unlock_kernel(); 162 mutex_unlock(&viocd_mutex);
162 163
163 return ret; 164 return ret;
164} 165}
@@ -166,9 +167,9 @@ static int viocd_blk_open(struct block_device *bdev, fmode_t mode)
166static int viocd_blk_release(struct gendisk *disk, fmode_t mode) 167static int viocd_blk_release(struct gendisk *disk, fmode_t mode)
167{ 168{
168 struct disk_info *di = disk->private_data; 169 struct disk_info *di = disk->private_data;
169 lock_kernel(); 170 mutex_lock(&viocd_mutex);
170 cdrom_release(&di->viocd_info, mode); 171 cdrom_release(&di->viocd_info, mode);
171 unlock_kernel(); 172 mutex_unlock(&viocd_mutex);
172 return 0; 173 return 0;
173} 174}
174 175
@@ -178,9 +179,9 @@ static int viocd_blk_ioctl(struct block_device *bdev, fmode_t mode,
178 struct disk_info *di = bdev->bd_disk->private_data; 179 struct disk_info *di = bdev->bd_disk->private_data;
179 int ret; 180 int ret;
180 181
181 lock_kernel(); 182 mutex_lock(&viocd_mutex);
182 ret = cdrom_ioctl(&di->viocd_info, bdev, mode, cmd, arg); 183 ret = cdrom_ioctl(&di->viocd_info, bdev, mode, cmd, arg);
183 unlock_kernel(); 184 mutex_unlock(&viocd_mutex);
184 185
185 return ret; 186 return ret;
186} 187}
diff --git a/drivers/char/apm-emulation.c b/drivers/char/apm-emulation.c
index 033e1505fca9..3022801669b1 100644
--- a/drivers/char/apm-emulation.c
+++ b/drivers/char/apm-emulation.c
@@ -13,7 +13,7 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/poll.h> 14#include <linux/poll.h>
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/smp_lock.h> 16#include <linux/mutex.h>
17#include <linux/proc_fs.h> 17#include <linux/proc_fs.h>
18#include <linux/seq_file.h> 18#include <linux/seq_file.h>
19#include <linux/miscdevice.h> 19#include <linux/miscdevice.h>
@@ -126,6 +126,7 @@ struct apm_user {
126/* 126/*
127 * Local variables 127 * Local variables
128 */ 128 */
129static DEFINE_MUTEX(apm_mutex);
129static atomic_t suspend_acks_pending = ATOMIC_INIT(0); 130static atomic_t suspend_acks_pending = ATOMIC_INIT(0);
130static atomic_t userspace_notification_inhibit = ATOMIC_INIT(0); 131static atomic_t userspace_notification_inhibit = ATOMIC_INIT(0);
131static int apm_disabled; 132static int apm_disabled;
@@ -274,7 +275,7 @@ apm_ioctl(struct file *filp, u_int cmd, u_long arg)
274 if (!as->suser || !as->writer) 275 if (!as->suser || !as->writer)
275 return -EPERM; 276 return -EPERM;
276 277
277 lock_kernel(); 278 mutex_lock(&apm_mutex);
278 switch (cmd) { 279 switch (cmd) {
279 case APM_IOC_SUSPEND: 280 case APM_IOC_SUSPEND:
280 mutex_lock(&state_lock); 281 mutex_lock(&state_lock);
@@ -335,7 +336,7 @@ apm_ioctl(struct file *filp, u_int cmd, u_long arg)
335 mutex_unlock(&state_lock); 336 mutex_unlock(&state_lock);
336 break; 337 break;
337 } 338 }
338 unlock_kernel(); 339 mutex_unlock(&apm_mutex);
339 340
340 return err; 341 return err;
341} 342}
@@ -370,7 +371,7 @@ static int apm_open(struct inode * inode, struct file * filp)
370{ 371{
371 struct apm_user *as; 372 struct apm_user *as;
372 373
373 lock_kernel(); 374 mutex_lock(&apm_mutex);
374 as = kzalloc(sizeof(*as), GFP_KERNEL); 375 as = kzalloc(sizeof(*as), GFP_KERNEL);
375 if (as) { 376 if (as) {
376 /* 377 /*
@@ -390,7 +391,7 @@ static int apm_open(struct inode * inode, struct file * filp)
390 391
391 filp->private_data = as; 392 filp->private_data = as;
392 } 393 }
393 unlock_kernel(); 394 mutex_unlock(&apm_mutex);
394 395
395 return as ? 0 : -ENOMEM; 396 return as ? 0 : -ENOMEM;
396} 397}
@@ -402,6 +403,7 @@ static const struct file_operations apm_bios_fops = {
402 .unlocked_ioctl = apm_ioctl, 403 .unlocked_ioctl = apm_ioctl,
403 .open = apm_open, 404 .open = apm_open,
404 .release = apm_release, 405 .release = apm_release,
406 .llseek = noop_llseek,
405}; 407};
406 408
407static struct miscdevice apm_device = { 409static struct miscdevice apm_device = {
diff --git a/drivers/char/applicom.c b/drivers/char/applicom.c
index f4ae0e0fb631..e7ba774beda6 100644
--- a/drivers/char/applicom.c
+++ b/drivers/char/applicom.c
@@ -26,7 +26,7 @@
26#include <linux/sched.h> 26#include <linux/sched.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/errno.h> 28#include <linux/errno.h>
29#include <linux/smp_lock.h> 29#include <linux/mutex.h>
30#include <linux/miscdevice.h> 30#include <linux/miscdevice.h>
31#include <linux/pci.h> 31#include <linux/pci.h>
32#include <linux/wait.h> 32#include <linux/wait.h>
@@ -60,6 +60,7 @@
60#define PCI_DEVICE_ID_APPLICOM_PCI2000PFB 0x0003 60#define PCI_DEVICE_ID_APPLICOM_PCI2000PFB 0x0003
61#endif 61#endif
62 62
63static DEFINE_MUTEX(ac_mutex);
63static char *applicom_pci_devnames[] = { 64static char *applicom_pci_devnames[] = {
64 "PCI board", 65 "PCI board",
65 "PCI2000IBS / PCI2000CAN", 66 "PCI2000IBS / PCI2000CAN",
@@ -707,7 +708,7 @@ static long ac_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
707 if (IS_ERR(adgl)) 708 if (IS_ERR(adgl))
708 return PTR_ERR(adgl); 709 return PTR_ERR(adgl);
709 710
710 lock_kernel(); 711 mutex_lock(&ac_mutex);
711 IndexCard = adgl->num_card-1; 712 IndexCard = adgl->num_card-1;
712 713
713 if(cmd != 6 && ((IndexCard >= MAX_BOARD) || !apbs[IndexCard].RamIO)) { 714 if(cmd != 6 && ((IndexCard >= MAX_BOARD) || !apbs[IndexCard].RamIO)) {
@@ -717,7 +718,7 @@ static long ac_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
717 warncount--; 718 warncount--;
718 } 719 }
719 kfree(adgl); 720 kfree(adgl);
720 unlock_kernel(); 721 mutex_unlock(&ac_mutex);
721 return -EINVAL; 722 return -EINVAL;
722 } 723 }
723 724
@@ -835,7 +836,7 @@ static long ac_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
835 } 836 }
836 Dummy = readb(apbs[IndexCard].RamIO + VERS); 837 Dummy = readb(apbs[IndexCard].RamIO + VERS);
837 kfree(adgl); 838 kfree(adgl);
838 unlock_kernel(); 839 mutex_unlock(&ac_mutex);
839 return 0; 840 return 0;
840} 841}
841 842
diff --git a/drivers/char/bfin-otp.c b/drivers/char/bfin-otp.c
index 836d4f0a876f..44660f1c4849 100644
--- a/drivers/char/bfin-otp.c
+++ b/drivers/char/bfin-otp.c
@@ -222,6 +222,7 @@ static const struct file_operations bfin_otp_fops = {
222 .unlocked_ioctl = bfin_otp_ioctl, 222 .unlocked_ioctl = bfin_otp_ioctl,
223 .read = bfin_otp_read, 223 .read = bfin_otp_read,
224 .write = bfin_otp_write, 224 .write = bfin_otp_write,
225 .llseek = default_llseek,
225}; 226};
226 227
227static struct miscdevice bfin_otp_misc_device = { 228static struct miscdevice bfin_otp_misc_device = {
diff --git a/drivers/char/briq_panel.c b/drivers/char/briq_panel.c
index d5fa113afe37..f6718f05dad4 100644
--- a/drivers/char/briq_panel.c
+++ b/drivers/char/briq_panel.c
@@ -186,6 +186,7 @@ static const struct file_operations briq_panel_fops = {
186 .write = briq_panel_write, 186 .write = briq_panel_write,
187 .open = briq_panel_open, 187 .open = briq_panel_open,
188 .release = briq_panel_release, 188 .release = briq_panel_release,
189 .llseek = noop_llseek,
189}; 190};
190 191
191static struct miscdevice briq_panel_miscdev = { 192static struct miscdevice briq_panel_miscdev = {
diff --git a/drivers/char/bsr.c b/drivers/char/bsr.c
index 91917133ae0a..a4a6c2f044b5 100644
--- a/drivers/char/bsr.c
+++ b/drivers/char/bsr.c
@@ -155,6 +155,7 @@ static const struct file_operations bsr_fops = {
155 .owner = THIS_MODULE, 155 .owner = THIS_MODULE,
156 .mmap = bsr_mmap, 156 .mmap = bsr_mmap,
157 .open = bsr_open, 157 .open = bsr_open,
158 .llseek = noop_llseek,
158}; 159};
159 160
160static void bsr_cleanup_devs(void) 161static void bsr_cleanup_devs(void)
diff --git a/drivers/char/cs5535_gpio.c b/drivers/char/cs5535_gpio.c
index 4d830dc482ef..0cf1e5fad9ab 100644
--- a/drivers/char/cs5535_gpio.c
+++ b/drivers/char/cs5535_gpio.c
@@ -169,7 +169,8 @@ static const struct file_operations cs5535_gpio_fops = {
169 .owner = THIS_MODULE, 169 .owner = THIS_MODULE,
170 .write = cs5535_gpio_write, 170 .write = cs5535_gpio_write,
171 .read = cs5535_gpio_read, 171 .read = cs5535_gpio_read,
172 .open = cs5535_gpio_open 172 .open = cs5535_gpio_open,
173 .llseek = no_llseek,
173}; 174};
174 175
175static int __init cs5535_gpio_init(void) 176static int __init cs5535_gpio_init(void)
diff --git a/drivers/char/ds1302.c b/drivers/char/ds1302.c
index 170693c93c73..ed8303f9890c 100644
--- a/drivers/char/ds1302.c
+++ b/drivers/char/ds1302.c
@@ -20,7 +20,7 @@
20#include <linux/miscdevice.h> 20#include <linux/miscdevice.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/bcd.h> 22#include <linux/bcd.h>
23#include <linux/smp_lock.h> 23#include <linux/mutex.h>
24#include <linux/uaccess.h> 24#include <linux/uaccess.h>
25#include <linux/io.h> 25#include <linux/io.h>
26 26
@@ -32,6 +32,7 @@
32 32
33#define RTC_MAJOR_NR 121 /* local major, change later */ 33#define RTC_MAJOR_NR 121 /* local major, change later */
34 34
35static DEFINE_MUTEX(rtc_mutex);
35static const char ds1302_name[] = "ds1302"; 36static const char ds1302_name[] = "ds1302";
36 37
37/* Send 8 bits. */ 38/* Send 8 bits. */
@@ -164,9 +165,9 @@ static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
164 struct rtc_time rtc_tm; 165 struct rtc_time rtc_tm;
165 166
166 memset(&rtc_tm, 0, sizeof (struct rtc_time)); 167 memset(&rtc_tm, 0, sizeof (struct rtc_time));
167 lock_kernel(); 168 mutex_lock(&rtc_mutex);
168 get_rtc_time(&rtc_tm); 169 get_rtc_time(&rtc_tm);
169 unlock_kernel(); 170 mutex_unlock(&rtc_mutex);
170 if (copy_to_user((struct rtc_time*)arg, &rtc_tm, sizeof(struct rtc_time))) 171 if (copy_to_user((struct rtc_time*)arg, &rtc_tm, sizeof(struct rtc_time)))
171 return -EFAULT; 172 return -EFAULT;
172 return 0; 173 return 0;
@@ -218,7 +219,7 @@ static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
218 mon = bin2bcd(mon); 219 mon = bin2bcd(mon);
219 yrs = bin2bcd(yrs); 220 yrs = bin2bcd(yrs);
220 221
221 lock_kernel(); 222 mutex_lock(&rtc_mutex);
222 local_irq_save(flags); 223 local_irq_save(flags);
223 CMOS_WRITE(yrs, RTC_YEAR); 224 CMOS_WRITE(yrs, RTC_YEAR);
224 CMOS_WRITE(mon, RTC_MONTH); 225 CMOS_WRITE(mon, RTC_MONTH);
@@ -227,7 +228,7 @@ static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
227 CMOS_WRITE(min, RTC_MINUTES); 228 CMOS_WRITE(min, RTC_MINUTES);
228 CMOS_WRITE(sec, RTC_SECONDS); 229 CMOS_WRITE(sec, RTC_SECONDS);
229 local_irq_restore(flags); 230 local_irq_restore(flags);
230 unlock_kernel(); 231 mutex_unlock(&rtc_mutex);
231 232
232 /* Notice that at this point, the RTC is updated but 233 /* Notice that at this point, the RTC is updated but
233 * the kernel is still running with the old time. 234 * the kernel is still running with the old time.
@@ -247,10 +248,10 @@ static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
247 if(copy_from_user(&tcs_val, (int*)arg, sizeof(int))) 248 if(copy_from_user(&tcs_val, (int*)arg, sizeof(int)))
248 return -EFAULT; 249 return -EFAULT;
249 250
250 lock_kernel(); 251 mutex_lock(&rtc_mutex);
251 tcs_val = RTC_TCR_PATTERN | (tcs_val & 0x0F); 252 tcs_val = RTC_TCR_PATTERN | (tcs_val & 0x0F);
252 ds1302_writereg(RTC_TRICKLECHARGER, tcs_val); 253 ds1302_writereg(RTC_TRICKLECHARGER, tcs_val);
253 unlock_kernel(); 254 mutex_unlock(&rtc_mutex);
254 return 0; 255 return 0;
255 } 256 }
256 default: 257 default:
@@ -288,6 +289,7 @@ get_rtc_status(char *buf)
288static const struct file_operations rtc_fops = { 289static const struct file_operations rtc_fops = {
289 .owner = THIS_MODULE, 290 .owner = THIS_MODULE,
290 .unlocked_ioctl = rtc_ioctl, 291 .unlocked_ioctl = rtc_ioctl,
292 .llseek = noop_llseek,
291}; 293};
292 294
293/* Probe for the chip by writing something to its RAM and try reading it back. */ 295/* Probe for the chip by writing something to its RAM and try reading it back. */
diff --git a/drivers/char/ds1620.c b/drivers/char/ds1620.c
index dbee8688f75c..aab9605f0b43 100644
--- a/drivers/char/ds1620.c
+++ b/drivers/char/ds1620.c
@@ -8,7 +8,7 @@
8#include <linux/proc_fs.h> 8#include <linux/proc_fs.h>
9#include <linux/capability.h> 9#include <linux/capability.h>
10#include <linux/init.h> 10#include <linux/init.h>
11#include <linux/smp_lock.h> 11#include <linux/mutex.h>
12 12
13#include <mach/hardware.h> 13#include <mach/hardware.h>
14#include <asm/mach-types.h> 14#include <asm/mach-types.h>
@@ -34,6 +34,7 @@
34#define CFG_CPU 2 34#define CFG_CPU 2
35#define CFG_1SHOT 1 35#define CFG_1SHOT 1
36 36
37static DEFINE_MUTEX(ds1620_mutex);
37static const char *fan_state[] = { "off", "on", "on (hardwired)" }; 38static const char *fan_state[] = { "off", "on", "on (hardwired)" };
38 39
39/* 40/*
@@ -210,7 +211,6 @@ static void ds1620_read_state(struct therm *therm)
210 211
211static int ds1620_open(struct inode *inode, struct file *file) 212static int ds1620_open(struct inode *inode, struct file *file)
212{ 213{
213 cycle_kernel_lock();
214 return nonseekable_open(inode, file); 214 return nonseekable_open(inode, file);
215} 215}
216 216
@@ -321,9 +321,9 @@ ds1620_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
321{ 321{
322 int ret; 322 int ret;
323 323
324 lock_kernel(); 324 mutex_lock(&ds1620_mutex);
325 ret = ds1620_ioctl(file, cmd, arg); 325 ret = ds1620_ioctl(file, cmd, arg);
326 unlock_kernel(); 326 mutex_unlock(&ds1620_mutex);
327 327
328 return ret; 328 return ret;
329} 329}
@@ -357,6 +357,7 @@ static const struct file_operations ds1620_fops = {
357 .open = ds1620_open, 357 .open = ds1620_open,
358 .read = ds1620_read, 358 .read = ds1620_read,
359 .unlocked_ioctl = ds1620_unlocked_ioctl, 359 .unlocked_ioctl = ds1620_unlocked_ioctl,
360 .llseek = no_llseek,
360}; 361};
361 362
362static struct miscdevice ds1620_miscdev = { 363static struct miscdevice ds1620_miscdev = {
diff --git a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c
index 8a1b28a10ef0..052797b32bd3 100644
--- a/drivers/char/dsp56k.c
+++ b/drivers/char/dsp56k.c
@@ -32,7 +32,7 @@
32#include <linux/mm.h> 32#include <linux/mm.h>
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/device.h> 34#include <linux/device.h>
35#include <linux/smp_lock.h> 35#include <linux/mutex.h>
36#include <linux/firmware.h> 36#include <linux/firmware.h>
37#include <linux/platform_device.h> 37#include <linux/platform_device.h>
38#include <linux/uaccess.h> /* For put_user and get_user */ 38#include <linux/uaccess.h> /* For put_user and get_user */
@@ -94,6 +94,7 @@
94 } \ 94 } \
95} 95}
96 96
97static DEFINE_MUTEX(dsp56k_mutex);
97static struct dsp56k_device { 98static struct dsp56k_device {
98 unsigned long in_use; 99 unsigned long in_use;
99 long maxio, timeout; 100 long maxio, timeout;
@@ -330,9 +331,9 @@ static long dsp56k_ioctl(struct file *file, unsigned int cmd,
330 if (len > DSP56K_MAX_BINARY_LENGTH) { 331 if (len > DSP56K_MAX_BINARY_LENGTH) {
331 return -EINVAL; 332 return -EINVAL;
332 } 333 }
333 lock_kernel(); 334 mutex_lock(&dsp56k_mutex);
334 r = dsp56k_upload(bin, len); 335 r = dsp56k_upload(bin, len);
335 unlock_kernel(); 336 mutex_unlock(&dsp56k_mutex);
336 if (r < 0) { 337 if (r < 0) {
337 return r; 338 return r;
338 } 339 }
@@ -342,16 +343,16 @@ static long dsp56k_ioctl(struct file *file, unsigned int cmd,
342 case DSP56K_SET_TX_WSIZE: 343 case DSP56K_SET_TX_WSIZE:
343 if (arg > 4 || arg < 1) 344 if (arg > 4 || arg < 1)
344 return -EINVAL; 345 return -EINVAL;
345 lock_kernel(); 346 mutex_lock(&dsp56k_mutex);
346 dsp56k.tx_wsize = (int) arg; 347 dsp56k.tx_wsize = (int) arg;
347 unlock_kernel(); 348 mutex_unlock(&dsp56k_mutex);
348 break; 349 break;
349 case DSP56K_SET_RX_WSIZE: 350 case DSP56K_SET_RX_WSIZE:
350 if (arg > 4 || arg < 1) 351 if (arg > 4 || arg < 1)
351 return -EINVAL; 352 return -EINVAL;
352 lock_kernel(); 353 mutex_lock(&dsp56k_mutex);
353 dsp56k.rx_wsize = (int) arg; 354 dsp56k.rx_wsize = (int) arg;
354 unlock_kernel(); 355 mutex_unlock(&dsp56k_mutex);
355 break; 356 break;
356 case DSP56K_HOST_FLAGS: 357 case DSP56K_HOST_FLAGS:
357 { 358 {
@@ -363,7 +364,7 @@ static long dsp56k_ioctl(struct file *file, unsigned int cmd,
363 if(get_user(out, &hf->out) < 0) 364 if(get_user(out, &hf->out) < 0)
364 return -EFAULT; 365 return -EFAULT;
365 366
366 lock_kernel(); 367 mutex_lock(&dsp56k_mutex);
367 if ((dir & 0x1) && (out & 0x1)) 368 if ((dir & 0x1) && (out & 0x1))
368 dsp56k_host_interface.icr |= DSP56K_ICR_HF0; 369 dsp56k_host_interface.icr |= DSP56K_ICR_HF0;
369 else if (dir & 0x1) 370 else if (dir & 0x1)
@@ -378,16 +379,16 @@ static long dsp56k_ioctl(struct file *file, unsigned int cmd,
378 if (dsp56k_host_interface.icr & DSP56K_ICR_HF1) status |= 0x2; 379 if (dsp56k_host_interface.icr & DSP56K_ICR_HF1) status |= 0x2;
379 if (dsp56k_host_interface.isr & DSP56K_ISR_HF2) status |= 0x4; 380 if (dsp56k_host_interface.isr & DSP56K_ISR_HF2) status |= 0x4;
380 if (dsp56k_host_interface.isr & DSP56K_ISR_HF3) status |= 0x8; 381 if (dsp56k_host_interface.isr & DSP56K_ISR_HF3) status |= 0x8;
381 unlock_kernel(); 382 mutex_unlock(&dsp56k_mutex);
382 return put_user(status, &hf->status); 383 return put_user(status, &hf->status);
383 } 384 }
384 case DSP56K_HOST_CMD: 385 case DSP56K_HOST_CMD:
385 if (arg > 31 || arg < 0) 386 if (arg > 31 || arg < 0)
386 return -EINVAL; 387 return -EINVAL;
387 lock_kernel(); 388 mutex_lock(&dsp56k_mutex);
388 dsp56k_host_interface.cvr = (u_char)((arg & DSP56K_CVR_HV_MASK) | 389 dsp56k_host_interface.cvr = (u_char)((arg & DSP56K_CVR_HV_MASK) |
389 DSP56K_CVR_HC); 390 DSP56K_CVR_HC);
390 unlock_kernel(); 391 mutex_unlock(&dsp56k_mutex);
391 break; 392 break;
392 default: 393 default:
393 return -EINVAL; 394 return -EINVAL;
@@ -427,7 +428,7 @@ static int dsp56k_open(struct inode *inode, struct file *file)
427 int dev = iminor(inode) & 0x0f; 428 int dev = iminor(inode) & 0x0f;
428 int ret = 0; 429 int ret = 0;
429 430
430 lock_kernel(); 431 mutex_lock(&dsp56k_mutex);
431 switch(dev) 432 switch(dev)
432 { 433 {
433 case DSP56K_DEV_56001: 434 case DSP56K_DEV_56001:
@@ -454,7 +455,7 @@ static int dsp56k_open(struct inode *inode, struct file *file)
454 ret = -ENODEV; 455 ret = -ENODEV;
455 } 456 }
456out: 457out:
457 unlock_kernel(); 458 mutex_unlock(&dsp56k_mutex);
458 return ret; 459 return ret;
459} 460}
460 461
@@ -482,6 +483,7 @@ static const struct file_operations dsp56k_fops = {
482 .unlocked_ioctl = dsp56k_ioctl, 483 .unlocked_ioctl = dsp56k_ioctl,
483 .open = dsp56k_open, 484 .open = dsp56k_open,
484 .release = dsp56k_release, 485 .release = dsp56k_release,
486 .llseek = noop_llseek,
485}; 487};
486 488
487 489
diff --git a/drivers/char/dtlk.c b/drivers/char/dtlk.c
index e3859d4eaead..85156dd0caee 100644
--- a/drivers/char/dtlk.c
+++ b/drivers/char/dtlk.c
@@ -57,7 +57,7 @@
57#include <linux/ioport.h> /* for request_region */ 57#include <linux/ioport.h> /* for request_region */
58#include <linux/delay.h> /* for loops_per_jiffy */ 58#include <linux/delay.h> /* for loops_per_jiffy */
59#include <linux/sched.h> 59#include <linux/sched.h>
60#include <linux/smp_lock.h> /* cycle_kernel_lock() */ 60#include <linux/mutex.h>
61#include <asm/io.h> /* for inb_p, outb_p, inb, outb, etc. */ 61#include <asm/io.h> /* for inb_p, outb_p, inb, outb, etc. */
62#include <asm/uaccess.h> /* for get_user, etc. */ 62#include <asm/uaccess.h> /* for get_user, etc. */
63#include <linux/wait.h> /* for wait_queue */ 63#include <linux/wait.h> /* for wait_queue */
@@ -73,6 +73,7 @@
73#define TRACE_RET ((void) 0) 73#define TRACE_RET ((void) 0)
74#endif /* TRACING */ 74#endif /* TRACING */
75 75
76static DEFINE_MUTEX(dtlk_mutex);
76static void dtlk_timer_tick(unsigned long data); 77static void dtlk_timer_tick(unsigned long data);
77 78
78static int dtlk_major; 79static int dtlk_major;
@@ -105,6 +106,7 @@ static const struct file_operations dtlk_fops =
105 .unlocked_ioctl = dtlk_ioctl, 106 .unlocked_ioctl = dtlk_ioctl,
106 .open = dtlk_open, 107 .open = dtlk_open,
107 .release = dtlk_release, 108 .release = dtlk_release,
109 .llseek = no_llseek,
108}; 110};
109 111
110/* local prototypes */ 112/* local prototypes */
@@ -275,9 +277,9 @@ static long dtlk_ioctl(struct file *file,
275 switch (cmd) { 277 switch (cmd) {
276 278
277 case DTLK_INTERROGATE: 279 case DTLK_INTERROGATE:
278 lock_kernel(); 280 mutex_lock(&dtlk_mutex);
279 sp = dtlk_interrogate(); 281 sp = dtlk_interrogate();
280 unlock_kernel(); 282 mutex_unlock(&dtlk_mutex);
281 if (copy_to_user(argp, sp, sizeof(struct dtlk_settings))) 283 if (copy_to_user(argp, sp, sizeof(struct dtlk_settings)))
282 return -EINVAL; 284 return -EINVAL;
283 return 0; 285 return 0;
@@ -296,7 +298,6 @@ static int dtlk_open(struct inode *inode, struct file *file)
296{ 298{
297 TRACE_TEXT("(dtlk_open"); 299 TRACE_TEXT("(dtlk_open");
298 300
299 cycle_kernel_lock();
300 nonseekable_open(inode, file); 301 nonseekable_open(inode, file);
301 switch (iminor(inode)) { 302 switch (iminor(inode)) {
302 case DTLK_MINOR: 303 case DTLK_MINOR:
diff --git a/drivers/char/generic_nvram.c b/drivers/char/generic_nvram.c
index 82b5a88a82d7..0e941b57482e 100644
--- a/drivers/char/generic_nvram.c
+++ b/drivers/char/generic_nvram.c
@@ -19,7 +19,7 @@
19#include <linux/miscdevice.h> 19#include <linux/miscdevice.h>
20#include <linux/fcntl.h> 20#include <linux/fcntl.h>
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/smp_lock.h> 22#include <linux/mutex.h>
23#include <asm/uaccess.h> 23#include <asm/uaccess.h>
24#include <asm/nvram.h> 24#include <asm/nvram.h>
25#ifdef CONFIG_PPC_PMAC 25#ifdef CONFIG_PPC_PMAC
@@ -28,6 +28,7 @@
28 28
29#define NVRAM_SIZE 8192 29#define NVRAM_SIZE 8192
30 30
31static DEFINE_MUTEX(nvram_mutex);
31static ssize_t nvram_len; 32static ssize_t nvram_len;
32 33
33static loff_t nvram_llseek(struct file *file, loff_t offset, int origin) 34static loff_t nvram_llseek(struct file *file, loff_t offset, int origin)
@@ -120,9 +121,9 @@ static long nvram_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned l
120{ 121{
121 int ret; 122 int ret;
122 123
123 lock_kernel(); 124 mutex_lock(&nvram_mutex);
124 ret = nvram_ioctl(file, cmd, arg); 125 ret = nvram_ioctl(file, cmd, arg);
125 unlock_kernel(); 126 mutex_unlock(&nvram_mutex);
126 127
127 return ret; 128 return ret;
128} 129}
diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
index b6c2cc167c11..f773a9dd14f3 100644
--- a/drivers/char/genrtc.c
+++ b/drivers/char/genrtc.c
@@ -52,7 +52,7 @@
52#include <linux/init.h> 52#include <linux/init.h>
53#include <linux/poll.h> 53#include <linux/poll.h>
54#include <linux/proc_fs.h> 54#include <linux/proc_fs.h>
55#include <linux/smp_lock.h> 55#include <linux/mutex.h>
56#include <linux/workqueue.h> 56#include <linux/workqueue.h>
57 57
58#include <asm/uaccess.h> 58#include <asm/uaccess.h>
@@ -66,6 +66,7 @@
66 * ioctls. 66 * ioctls.
67 */ 67 */
68 68
69static DEFINE_MUTEX(gen_rtc_mutex);
69static DECLARE_WAIT_QUEUE_HEAD(gen_rtc_wait); 70static DECLARE_WAIT_QUEUE_HEAD(gen_rtc_wait);
70 71
71/* 72/*
@@ -337,9 +338,9 @@ static long gen_rtc_unlocked_ioctl(struct file *file, unsigned int cmd,
337{ 338{
338 int ret; 339 int ret;
339 340
340 lock_kernel(); 341 mutex_lock(&gen_rtc_mutex);
341 ret = gen_rtc_ioctl(file, cmd, arg); 342 ret = gen_rtc_ioctl(file, cmd, arg);
342 unlock_kernel(); 343 mutex_unlock(&gen_rtc_mutex);
343 344
344 return ret; 345 return ret;
345} 346}
@@ -352,16 +353,16 @@ static long gen_rtc_unlocked_ioctl(struct file *file, unsigned int cmd,
352 353
353static int gen_rtc_open(struct inode *inode, struct file *file) 354static int gen_rtc_open(struct inode *inode, struct file *file)
354{ 355{
355 lock_kernel(); 356 mutex_lock(&gen_rtc_mutex);
356 if (gen_rtc_status & RTC_IS_OPEN) { 357 if (gen_rtc_status & RTC_IS_OPEN) {
357 unlock_kernel(); 358 mutex_unlock(&gen_rtc_mutex);
358 return -EBUSY; 359 return -EBUSY;
359 } 360 }
360 361
361 gen_rtc_status |= RTC_IS_OPEN; 362 gen_rtc_status |= RTC_IS_OPEN;
362 gen_rtc_irq_data = 0; 363 gen_rtc_irq_data = 0;
363 irq_active = 0; 364 irq_active = 0;
364 unlock_kernel(); 365 mutex_unlock(&gen_rtc_mutex);
365 366
366 return 0; 367 return 0;
367} 368}
@@ -497,6 +498,7 @@ static const struct file_operations gen_rtc_fops = {
497 .unlocked_ioctl = gen_rtc_unlocked_ioctl, 498 .unlocked_ioctl = gen_rtc_unlocked_ioctl,
498 .open = gen_rtc_open, 499 .open = gen_rtc_open,
499 .release = gen_rtc_release, 500 .release = gen_rtc_release,
501 .llseek = noop_llseek,
500}; 502};
501 503
502static struct miscdevice rtc_gen_dev = 504static struct miscdevice rtc_gen_dev =
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index a0a1829d3198..a4eee324eb1e 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -30,6 +30,7 @@
30#include <linux/bcd.h> 30#include <linux/bcd.h>
31#include <linux/seq_file.h> 31#include <linux/seq_file.h>
32#include <linux/bitops.h> 32#include <linux/bitops.h>
33#include <linux/compat.h>
33#include <linux/clocksource.h> 34#include <linux/clocksource.h>
34#include <linux/slab.h> 35#include <linux/slab.h>
35 36
@@ -67,6 +68,7 @@
67#define read_counter(MC) readl(MC) 68#define read_counter(MC) readl(MC)
68#endif 69#endif
69 70
71static DEFINE_MUTEX(hpet_mutex); /* replaces BKL */
70static u32 hpet_nhpet, hpet_max_freq = HPET_USER_FREQ; 72static u32 hpet_nhpet, hpet_max_freq = HPET_USER_FREQ;
71 73
72/* This clocksource driver currently only works on ia64 */ 74/* This clocksource driver currently only works on ia64 */
@@ -250,7 +252,7 @@ static int hpet_open(struct inode *inode, struct file *file)
250 if (file->f_mode & FMODE_WRITE) 252 if (file->f_mode & FMODE_WRITE)
251 return -EINVAL; 253 return -EINVAL;
252 254
253 lock_kernel(); 255 mutex_lock(&hpet_mutex);
254 spin_lock_irq(&hpet_lock); 256 spin_lock_irq(&hpet_lock);
255 257
256 for (devp = NULL, hpetp = hpets; hpetp && !devp; hpetp = hpetp->hp_next) 258 for (devp = NULL, hpetp = hpets; hpetp && !devp; hpetp = hpetp->hp_next)
@@ -264,7 +266,7 @@ static int hpet_open(struct inode *inode, struct file *file)
264 266
265 if (!devp) { 267 if (!devp) {
266 spin_unlock_irq(&hpet_lock); 268 spin_unlock_irq(&hpet_lock);
267 unlock_kernel(); 269 mutex_unlock(&hpet_mutex);
268 return -EBUSY; 270 return -EBUSY;
269 } 271 }
270 272
@@ -272,7 +274,7 @@ static int hpet_open(struct inode *inode, struct file *file)
272 devp->hd_irqdata = 0; 274 devp->hd_irqdata = 0;
273 devp->hd_flags |= HPET_OPEN; 275 devp->hd_flags |= HPET_OPEN;
274 spin_unlock_irq(&hpet_lock); 276 spin_unlock_irq(&hpet_lock);
275 unlock_kernel(); 277 mutex_unlock(&hpet_mutex);
276 278
277 hpet_timer_set_irq(devp); 279 hpet_timer_set_irq(devp);
278 280
@@ -429,22 +431,6 @@ static int hpet_release(struct inode *inode, struct file *file)
429 return 0; 431 return 0;
430} 432}
431 433
432static int hpet_ioctl_common(struct hpet_dev *, int, unsigned long, int);
433
434static long hpet_ioctl(struct file *file, unsigned int cmd,
435 unsigned long arg)
436{
437 struct hpet_dev *devp;
438 int ret;
439
440 devp = file->private_data;
441 lock_kernel();
442 ret = hpet_ioctl_common(devp, cmd, arg, 0);
443 unlock_kernel();
444
445 return ret;
446}
447
448static int hpet_ioctl_ieon(struct hpet_dev *devp) 434static int hpet_ioctl_ieon(struct hpet_dev *devp)
449{ 435{
450 struct hpet_timer __iomem *timer; 436 struct hpet_timer __iomem *timer;
@@ -553,7 +539,8 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
553} 539}
554 540
555static int 541static int
556hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg, int kernel) 542hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
543 struct hpet_info *info)
557{ 544{
558 struct hpet_timer __iomem *timer; 545 struct hpet_timer __iomem *timer;
559 struct hpet __iomem *hpet; 546 struct hpet __iomem *hpet;
@@ -594,23 +581,15 @@ hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg, int kernel)
594 break; 581 break;
595 case HPET_INFO: 582 case HPET_INFO:
596 { 583 {
597 struct hpet_info info;
598
599 if (devp->hd_ireqfreq) 584 if (devp->hd_ireqfreq)
600 info.hi_ireqfreq = 585 info->hi_ireqfreq =
601 hpet_time_div(hpetp, devp->hd_ireqfreq); 586 hpet_time_div(hpetp, devp->hd_ireqfreq);
602 else 587 else
603 info.hi_ireqfreq = 0; 588 info->hi_ireqfreq = 0;
604 info.hi_flags = 589 info->hi_flags =
605 readq(&timer->hpet_config) & Tn_PER_INT_CAP_MASK; 590 readq(&timer->hpet_config) & Tn_PER_INT_CAP_MASK;
606 info.hi_hpet = hpetp->hp_which; 591 info->hi_hpet = hpetp->hp_which;
607 info.hi_timer = devp - hpetp->hp_dev; 592 info->hi_timer = devp - hpetp->hp_dev;
608 if (kernel)
609 memcpy((void *)arg, &info, sizeof(info));
610 else
611 if (copy_to_user((void __user *)arg, &info,
612 sizeof(info)))
613 err = -EFAULT;
614 break; 593 break;
615 } 594 }
616 case HPET_EPI: 595 case HPET_EPI:
@@ -636,7 +615,7 @@ hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg, int kernel)
636 devp->hd_flags &= ~HPET_PERIODIC; 615 devp->hd_flags &= ~HPET_PERIODIC;
637 break; 616 break;
638 case HPET_IRQFREQ: 617 case HPET_IRQFREQ:
639 if (!kernel && (arg > hpet_max_freq) && 618 if ((arg > hpet_max_freq) &&
640 !capable(CAP_SYS_RESOURCE)) { 619 !capable(CAP_SYS_RESOURCE)) {
641 err = -EACCES; 620 err = -EACCES;
642 break; 621 break;
@@ -653,12 +632,63 @@ hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg, int kernel)
653 return err; 632 return err;
654} 633}
655 634
635static long
636hpet_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
637{
638 struct hpet_info info;
639 int err;
640
641 mutex_lock(&hpet_mutex);
642 err = hpet_ioctl_common(file->private_data, cmd, arg, &info);
643 mutex_unlock(&hpet_mutex);
644
645 if ((cmd == HPET_INFO) && !err &&
646 (copy_to_user((void __user *)arg, &info, sizeof(info))))
647 err = -EFAULT;
648
649 return err;
650}
651
652#ifdef CONFIG_COMPAT
653struct compat_hpet_info {
654 compat_ulong_t hi_ireqfreq; /* Hz */
655 compat_ulong_t hi_flags; /* information */
656 unsigned short hi_hpet;
657 unsigned short hi_timer;
658};
659
660static long
661hpet_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
662{
663 struct hpet_info info;
664 int err;
665
666 mutex_lock(&hpet_mutex);
667 err = hpet_ioctl_common(file->private_data, cmd, arg, &info);
668 mutex_unlock(&hpet_mutex);
669
670 if ((cmd == HPET_INFO) && !err) {
671 struct compat_hpet_info __user *u = compat_ptr(arg);
672 if (put_user(info.hi_ireqfreq, &u->hi_ireqfreq) ||
673 put_user(info.hi_flags, &u->hi_flags) ||
674 put_user(info.hi_hpet, &u->hi_hpet) ||
675 put_user(info.hi_timer, &u->hi_timer))
676 err = -EFAULT;
677 }
678
679 return err;
680}
681#endif
682
656static const struct file_operations hpet_fops = { 683static const struct file_operations hpet_fops = {
657 .owner = THIS_MODULE, 684 .owner = THIS_MODULE,
658 .llseek = no_llseek, 685 .llseek = no_llseek,
659 .read = hpet_read, 686 .read = hpet_read,
660 .poll = hpet_poll, 687 .poll = hpet_poll,
661 .unlocked_ioctl = hpet_ioctl, 688 .unlocked_ioctl = hpet_ioctl,
689#ifdef CONFIG_COMPAT
690 .compat_ioctl = hpet_compat_ioctl,
691#endif
662 .open = hpet_open, 692 .open = hpet_open,
663 .release = hpet_release, 693 .release = hpet_release,
664 .fasync = hpet_fasync, 694 .fasync = hpet_fasync,
diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index 3d9c61e5acbf..788da05190cc 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -170,6 +170,7 @@ static const struct file_operations rng_chrdev_ops = {
170 .owner = THIS_MODULE, 170 .owner = THIS_MODULE,
171 .open = rng_dev_open, 171 .open = rng_dev_open,
172 .read = rng_dev_read, 172 .read = rng_dev_read,
173 .llseek = noop_llseek,
173}; 174};
174 175
175static struct miscdevice rng_miscdev = { 176static struct miscdevice rng_miscdev = {
diff --git a/drivers/char/i8k.c b/drivers/char/i8k.c
index 4cd8b227c11f..3bc0eef88717 100644
--- a/drivers/char/i8k.c
+++ b/drivers/char/i8k.c
@@ -23,7 +23,7 @@
23#include <linux/seq_file.h> 23#include <linux/seq_file.h>
24#include <linux/dmi.h> 24#include <linux/dmi.h>
25#include <linux/capability.h> 25#include <linux/capability.h>
26#include <linux/smp_lock.h> 26#include <linux/mutex.h>
27#include <asm/uaccess.h> 27#include <asm/uaccess.h>
28#include <asm/io.h> 28#include <asm/io.h>
29 29
@@ -56,6 +56,7 @@
56 56
57#define I8K_TEMPERATURE_BUG 1 57#define I8K_TEMPERATURE_BUG 1
58 58
59static DEFINE_MUTEX(i8k_mutex);
59static char bios_version[4]; 60static char bios_version[4];
60 61
61MODULE_AUTHOR("Massimo Dal Zotto (dz@debian.org)"); 62MODULE_AUTHOR("Massimo Dal Zotto (dz@debian.org)");
@@ -399,9 +400,9 @@ static long i8k_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
399{ 400{
400 long ret; 401 long ret;
401 402
402 lock_kernel(); 403 mutex_lock(&i8k_mutex);
403 ret = i8k_ioctl_unlocked(fp, cmd, arg); 404 ret = i8k_ioctl_unlocked(fp, cmd, arg);
404 unlock_kernel(); 405 mutex_unlock(&i8k_mutex);
405 406
406 return ret; 407 return ret;
407} 408}
diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c
index d4b71e8d0d23..64a439ce2f89 100644
--- a/drivers/char/ip2/ip2main.c
+++ b/drivers/char/ip2/ip2main.c
@@ -98,7 +98,7 @@
98#include <linux/major.h> 98#include <linux/major.h>
99#include <linux/wait.h> 99#include <linux/wait.h>
100#include <linux/device.h> 100#include <linux/device.h>
101#include <linux/smp_lock.h> 101#include <linux/mutex.h>
102#include <linux/firmware.h> 102#include <linux/firmware.h>
103#include <linux/platform_device.h> 103#include <linux/platform_device.h>
104 104
@@ -138,6 +138,7 @@
138#include <linux/proc_fs.h> 138#include <linux/proc_fs.h>
139#include <linux/seq_file.h> 139#include <linux/seq_file.h>
140 140
141static DEFINE_MUTEX(ip2_mutex);
141static const struct file_operations ip2mem_proc_fops; 142static const struct file_operations ip2mem_proc_fops;
142static const struct file_operations ip2_proc_fops; 143static const struct file_operations ip2_proc_fops;
143 144
@@ -236,6 +237,7 @@ static const struct file_operations ip2_ipl = {
236 .write = ip2_ipl_write, 237 .write = ip2_ipl_write,
237 .unlocked_ioctl = ip2_ipl_ioctl, 238 .unlocked_ioctl = ip2_ipl_ioctl,
238 .open = ip2_ipl_open, 239 .open = ip2_ipl_open,
240 .llseek = noop_llseek,
239}; 241};
240 242
241static unsigned long irq_counter; 243static unsigned long irq_counter;
@@ -2897,7 +2899,7 @@ ip2_ipl_ioctl (struct file *pFile, UINT cmd, ULONG arg )
2897 printk (KERN_DEBUG "IP2IPL: ioctl cmd %d, arg %ld\n", cmd, arg ); 2899 printk (KERN_DEBUG "IP2IPL: ioctl cmd %d, arg %ld\n", cmd, arg );
2898#endif 2900#endif
2899 2901
2900 lock_kernel(); 2902 mutex_lock(&ip2_mutex);
2901 2903
2902 switch ( iplminor ) { 2904 switch ( iplminor ) {
2903 case 0: // IPL device 2905 case 0: // IPL device
@@ -2961,7 +2963,7 @@ ip2_ipl_ioctl (struct file *pFile, UINT cmd, ULONG arg )
2961 rc = -ENODEV; 2963 rc = -ENODEV;
2962 break; 2964 break;
2963 } 2965 }
2964 unlock_kernel(); 2966 mutex_unlock(&ip2_mutex);
2965 return rc; 2967 return rc;
2966} 2968}
2967 2969
@@ -2982,7 +2984,6 @@ ip2_ipl_open( struct inode *pInode, struct file *pFile )
2982#ifdef IP2DEBUG_IPL 2984#ifdef IP2DEBUG_IPL
2983 printk (KERN_DEBUG "IP2IPL: open\n" ); 2985 printk (KERN_DEBUG "IP2IPL: open\n" );
2984#endif 2986#endif
2985 cycle_kernel_lock();
2986 return 0; 2987 return 0;
2987} 2988}
2988 2989
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c
index d8ec92a38980..1fc8876af1f5 100644
--- a/drivers/char/ipmi/ipmi_devintf.c
+++ b/drivers/char/ipmi/ipmi_devintf.c
@@ -44,7 +44,6 @@
44#include <linux/init.h> 44#include <linux/init.h>
45#include <linux/device.h> 45#include <linux/device.h>
46#include <linux/compat.h> 46#include <linux/compat.h>
47#include <linux/smp_lock.h>
48 47
49struct ipmi_file_private 48struct ipmi_file_private
50{ 49{
@@ -59,6 +58,7 @@ struct ipmi_file_private
59 unsigned int default_retry_time_ms; 58 unsigned int default_retry_time_ms;
60}; 59};
61 60
61static DEFINE_MUTEX(ipmi_mutex);
62static void file_receive_handler(struct ipmi_recv_msg *msg, 62static void file_receive_handler(struct ipmi_recv_msg *msg,
63 void *handler_data) 63 void *handler_data)
64{ 64{
@@ -102,9 +102,9 @@ static int ipmi_fasync(int fd, struct file *file, int on)
102 struct ipmi_file_private *priv = file->private_data; 102 struct ipmi_file_private *priv = file->private_data;
103 int result; 103 int result;
104 104
105 lock_kernel(); /* could race against open() otherwise */ 105 mutex_lock(&ipmi_mutex); /* could race against open() otherwise */
106 result = fasync_helper(fd, file, on, &priv->fasync_queue); 106 result = fasync_helper(fd, file, on, &priv->fasync_queue);
107 unlock_kernel(); 107 mutex_unlock(&ipmi_mutex);
108 108
109 return (result); 109 return (result);
110} 110}
@@ -125,7 +125,7 @@ static int ipmi_open(struct inode *inode, struct file *file)
125 if (!priv) 125 if (!priv)
126 return -ENOMEM; 126 return -ENOMEM;
127 127
128 lock_kernel(); 128 mutex_lock(&ipmi_mutex);
129 priv->file = file; 129 priv->file = file;
130 130
131 rv = ipmi_create_user(if_num, 131 rv = ipmi_create_user(if_num,
@@ -150,7 +150,7 @@ static int ipmi_open(struct inode *inode, struct file *file)
150 priv->default_retry_time_ms = 0; 150 priv->default_retry_time_ms = 0;
151 151
152out: 152out:
153 unlock_kernel(); 153 mutex_unlock(&ipmi_mutex);
154 return rv; 154 return rv;
155} 155}
156 156
@@ -639,9 +639,9 @@ static long ipmi_unlocked_ioctl(struct file *file,
639{ 639{
640 int ret; 640 int ret;
641 641
642 lock_kernel(); 642 mutex_lock(&ipmi_mutex);
643 ret = ipmi_ioctl(file, cmd, data); 643 ret = ipmi_ioctl(file, cmd, data);
644 unlock_kernel(); 644 mutex_unlock(&ipmi_mutex);
645 645
646 return ret; 646 return ret;
647} 647}
@@ -850,6 +850,7 @@ static const struct file_operations ipmi_fops = {
850 .release = ipmi_release, 850 .release = ipmi_release,
851 .fasync = ipmi_fasync, 851 .fasync = ipmi_fasync,
852 .poll = ipmi_poll, 852 .poll = ipmi_poll,
853 .llseek = noop_llseek,
853}; 854};
854 855
855#define DEVICE_NAME "ipmidev" 856#define DEVICE_NAME "ipmidev"
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
index 654d566ca57c..f4d334f2536e 100644
--- a/drivers/char/ipmi/ipmi_watchdog.c
+++ b/drivers/char/ipmi/ipmi_watchdog.c
@@ -35,7 +35,7 @@
35#include <linux/moduleparam.h> 35#include <linux/moduleparam.h>
36#include <linux/ipmi.h> 36#include <linux/ipmi.h>
37#include <linux/ipmi_smi.h> 37#include <linux/ipmi_smi.h>
38#include <linux/smp_lock.h> 38#include <linux/mutex.h>
39#include <linux/watchdog.h> 39#include <linux/watchdog.h>
40#include <linux/miscdevice.h> 40#include <linux/miscdevice.h>
41#include <linux/init.h> 41#include <linux/init.h>
@@ -149,6 +149,7 @@
149#define WDIOC_GET_PRETIMEOUT _IOW(WATCHDOG_IOCTL_BASE, 22, int) 149#define WDIOC_GET_PRETIMEOUT _IOW(WATCHDOG_IOCTL_BASE, 22, int)
150#endif 150#endif
151 151
152static DEFINE_MUTEX(ipmi_watchdog_mutex);
152static int nowayout = WATCHDOG_NOWAYOUT; 153static int nowayout = WATCHDOG_NOWAYOUT;
153 154
154static ipmi_user_t watchdog_user; 155static ipmi_user_t watchdog_user;
@@ -748,9 +749,9 @@ static long ipmi_unlocked_ioctl(struct file *file,
748{ 749{
749 int ret; 750 int ret;
750 751
751 lock_kernel(); 752 mutex_lock(&ipmi_watchdog_mutex);
752 ret = ipmi_ioctl(file, cmd, arg); 753 ret = ipmi_ioctl(file, cmd, arg);
753 unlock_kernel(); 754 mutex_unlock(&ipmi_watchdog_mutex);
754 755
755 return ret; 756 return ret;
756} 757}
@@ -844,7 +845,6 @@ static int ipmi_open(struct inode *ino, struct file *filep)
844 if (test_and_set_bit(0, &ipmi_wdog_open)) 845 if (test_and_set_bit(0, &ipmi_wdog_open))
845 return -EBUSY; 846 return -EBUSY;
846 847
847 cycle_kernel_lock();
848 848
849 /* 849 /*
850 * Don't start the timer now, let it start on the 850 * Don't start the timer now, let it start on the
@@ -909,6 +909,7 @@ static const struct file_operations ipmi_wdog_fops = {
909 .open = ipmi_open, 909 .open = ipmi_open,
910 .release = ipmi_close, 910 .release = ipmi_close,
911 .fasync = ipmi_fasync, 911 .fasync = ipmi_fasync,
912 .llseek = no_llseek,
912}; 913};
913 914
914static struct miscdevice ipmi_wdog_miscdev = { 915static struct miscdevice ipmi_wdog_miscdev = {
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index be28391adb79..667abd23ad6a 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -704,6 +704,7 @@ static const struct file_operations stli_fsiomem = {
704 .read = stli_memread, 704 .read = stli_memread,
705 .write = stli_memwrite, 705 .write = stli_memwrite,
706 .unlocked_ioctl = stli_memioctl, 706 .unlocked_ioctl = stli_memioctl,
707 .llseek = default_llseek,
707}; 708};
708 709
709/*****************************************************************************/ 710/*****************************************************************************/
diff --git a/drivers/char/lp.c b/drivers/char/lp.c
index 938a3a273886..97c3edb95ae7 100644
--- a/drivers/char/lp.c
+++ b/drivers/char/lp.c
@@ -126,7 +126,7 @@
126#include <linux/device.h> 126#include <linux/device.h>
127#include <linux/wait.h> 127#include <linux/wait.h>
128#include <linux/jiffies.h> 128#include <linux/jiffies.h>
129#include <linux/smp_lock.h> 129#include <linux/mutex.h>
130#include <linux/compat.h> 130#include <linux/compat.h>
131 131
132#include <linux/parport.h> 132#include <linux/parport.h>
@@ -140,6 +140,7 @@
140/* if you have more than 8 printers, remember to increase LP_NO */ 140/* if you have more than 8 printers, remember to increase LP_NO */
141#define LP_NO 8 141#define LP_NO 8
142 142
143static DEFINE_MUTEX(lp_mutex);
143static struct lp_struct lp_table[LP_NO]; 144static struct lp_struct lp_table[LP_NO];
144 145
145static unsigned int lp_count = 0; 146static unsigned int lp_count = 0;
@@ -493,7 +494,7 @@ static int lp_open(struct inode * inode, struct file * file)
493 unsigned int minor = iminor(inode); 494 unsigned int minor = iminor(inode);
494 int ret = 0; 495 int ret = 0;
495 496
496 lock_kernel(); 497 mutex_lock(&lp_mutex);
497 if (minor >= LP_NO) { 498 if (minor >= LP_NO) {
498 ret = -ENXIO; 499 ret = -ENXIO;
499 goto out; 500 goto out;
@@ -554,7 +555,7 @@ static int lp_open(struct inode * inode, struct file * file)
554 lp_release_parport (&lp_table[minor]); 555 lp_release_parport (&lp_table[minor]);
555 lp_table[minor].current_mode = IEEE1284_MODE_COMPAT; 556 lp_table[minor].current_mode = IEEE1284_MODE_COMPAT;
556out: 557out:
557 unlock_kernel(); 558 mutex_unlock(&lp_mutex);
558 return ret; 559 return ret;
559} 560}
560 561
@@ -680,7 +681,7 @@ static long lp_ioctl(struct file *file, unsigned int cmd,
680 int ret; 681 int ret;
681 682
682 minor = iminor(file->f_path.dentry->d_inode); 683 minor = iminor(file->f_path.dentry->d_inode);
683 lock_kernel(); 684 mutex_lock(&lp_mutex);
684 switch (cmd) { 685 switch (cmd) {
685 case LPSETTIMEOUT: 686 case LPSETTIMEOUT:
686 if (copy_from_user(&par_timeout, (void __user *)arg, 687 if (copy_from_user(&par_timeout, (void __user *)arg,
@@ -694,7 +695,7 @@ static long lp_ioctl(struct file *file, unsigned int cmd,
694 ret = lp_do_ioctl(minor, cmd, arg, (void __user *)arg); 695 ret = lp_do_ioctl(minor, cmd, arg, (void __user *)arg);
695 break; 696 break;
696 } 697 }
697 unlock_kernel(); 698 mutex_unlock(&lp_mutex);
698 699
699 return ret; 700 return ret;
700} 701}
@@ -709,7 +710,7 @@ static long lp_compat_ioctl(struct file *file, unsigned int cmd,
709 int ret; 710 int ret;
710 711
711 minor = iminor(file->f_path.dentry->d_inode); 712 minor = iminor(file->f_path.dentry->d_inode);
712 lock_kernel(); 713 mutex_lock(&lp_mutex);
713 switch (cmd) { 714 switch (cmd) {
714 case LPSETTIMEOUT: 715 case LPSETTIMEOUT:
715 tc = compat_ptr(arg); 716 tc = compat_ptr(arg);
@@ -730,7 +731,7 @@ static long lp_compat_ioctl(struct file *file, unsigned int cmd,
730 ret = lp_do_ioctl(minor, cmd, arg, compat_ptr(arg)); 731 ret = lp_do_ioctl(minor, cmd, arg, compat_ptr(arg));
731 break; 732 break;
732 } 733 }
733 unlock_kernel(); 734 mutex_unlock(&lp_mutex);
734 735
735 return ret; 736 return ret;
736} 737}
@@ -748,6 +749,7 @@ static const struct file_operations lp_fops = {
748#ifdef CONFIG_PARPORT_1284 749#ifdef CONFIG_PARPORT_1284
749 .read = lp_read, 750 .read = lp_read,
750#endif 751#endif
752 .llseek = noop_llseek,
751}; 753};
752 754
753/* --- support for console on the line printer ----------------- */ 755/* --- support for console on the line printer ----------------- */
diff --git a/drivers/char/mbcs.c b/drivers/char/mbcs.c
index 83bef4efe376..1aeaaba680d2 100644
--- a/drivers/char/mbcs.c
+++ b/drivers/char/mbcs.c
@@ -25,7 +25,6 @@
25#include <linux/mm.h> 25#include <linux/mm.h>
26#include <linux/uio.h> 26#include <linux/uio.h>
27#include <linux/mutex.h> 27#include <linux/mutex.h>
28#include <linux/smp_lock.h>
29#include <linux/slab.h> 28#include <linux/slab.h>
30#include <asm/io.h> 29#include <asm/io.h>
31#include <asm/uaccess.h> 30#include <asm/uaccess.h>
@@ -42,6 +41,7 @@
42#else 41#else
43#define DBG(fmt...) 42#define DBG(fmt...)
44#endif 43#endif
44static DEFINE_MUTEX(mbcs_mutex);
45static int mbcs_major; 45static int mbcs_major;
46 46
47static LIST_HEAD(soft_list); 47static LIST_HEAD(soft_list);
@@ -385,19 +385,19 @@ static int mbcs_open(struct inode *ip, struct file *fp)
385 struct mbcs_soft *soft; 385 struct mbcs_soft *soft;
386 int minor; 386 int minor;
387 387
388 lock_kernel(); 388 mutex_lock(&mbcs_mutex);
389 minor = iminor(ip); 389 minor = iminor(ip);
390 390
391 /* Nothing protects access to this list... */ 391 /* Nothing protects access to this list... */
392 list_for_each_entry(soft, &soft_list, list) { 392 list_for_each_entry(soft, &soft_list, list) {
393 if (soft->nasid == minor) { 393 if (soft->nasid == minor) {
394 fp->private_data = soft->cxdev; 394 fp->private_data = soft->cxdev;
395 unlock_kernel(); 395 mutex_unlock(&mbcs_mutex);
396 return 0; 396 return 0;
397 } 397 }
398 } 398 }
399 399
400 unlock_kernel(); 400 mutex_unlock(&mbcs_mutex);
401 return -ENODEV; 401 return -ENODEV;
402} 402}
403 403
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 1f528fad3516..e985b1c2730e 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -805,6 +805,7 @@ static const struct file_operations full_fops = {
805static const struct file_operations oldmem_fops = { 805static const struct file_operations oldmem_fops = {
806 .read = read_oldmem, 806 .read = read_oldmem,
807 .open = open_oldmem, 807 .open = open_oldmem,
808 .llseek = default_llseek,
808}; 809};
809#endif 810#endif
810 811
@@ -831,6 +832,7 @@ static ssize_t kmsg_write(struct file *file, const char __user *buf,
831 832
832static const struct file_operations kmsg_fops = { 833static const struct file_operations kmsg_fops = {
833 .write = kmsg_write, 834 .write = kmsg_write,
835 .llseek = noop_llseek,
834}; 836};
835 837
836static const struct memdev { 838static const struct memdev {
@@ -882,6 +884,7 @@ static int memory_open(struct inode *inode, struct file *filp)
882 884
883static const struct file_operations memory_fops = { 885static const struct file_operations memory_fops = {
884 .open = memory_open, 886 .open = memory_open,
887 .llseek = noop_llseek,
885}; 888};
886 889
887static char *mem_devnode(struct device *dev, mode_t *mode) 890static char *mem_devnode(struct device *dev, mode_t *mode)
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index abdafd488980..778273c93242 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -162,6 +162,7 @@ static struct class *misc_class;
162static const struct file_operations misc_fops = { 162static const struct file_operations misc_fops = {
163 .owner = THIS_MODULE, 163 .owner = THIS_MODULE,
164 .open = misc_open, 164 .open = misc_open,
165 .llseek = noop_llseek,
165}; 166};
166 167
167/** 168/**
diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index ea7c99fa978f..c070b53984e4 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -32,7 +32,7 @@
32#include <linux/interrupt.h> 32#include <linux/interrupt.h>
33#include <linux/time.h> 33#include <linux/time.h>
34#include <linux/math64.h> 34#include <linux/math64.h>
35#include <linux/smp_lock.h> 35#include <linux/mutex.h>
36#include <linux/slab.h> 36#include <linux/slab.h>
37 37
38#include <asm/uaccess.h> 38#include <asm/uaccess.h>
@@ -59,6 +59,7 @@ extern unsigned long sn_rtc_cycles_per_second;
59 59
60#define rtc_time() (*RTC_COUNTER_ADDR) 60#define rtc_time() (*RTC_COUNTER_ADDR)
61 61
62static DEFINE_MUTEX(mmtimer_mutex);
62static long mmtimer_ioctl(struct file *file, unsigned int cmd, 63static long mmtimer_ioctl(struct file *file, unsigned int cmd,
63 unsigned long arg); 64 unsigned long arg);
64static int mmtimer_mmap(struct file *file, struct vm_area_struct *vma); 65static int mmtimer_mmap(struct file *file, struct vm_area_struct *vma);
@@ -72,6 +73,7 @@ static const struct file_operations mmtimer_fops = {
72 .owner = THIS_MODULE, 73 .owner = THIS_MODULE,
73 .mmap = mmtimer_mmap, 74 .mmap = mmtimer_mmap,
74 .unlocked_ioctl = mmtimer_ioctl, 75 .unlocked_ioctl = mmtimer_ioctl,
76 .llseek = noop_llseek,
75}; 77};
76 78
77/* 79/*
@@ -371,7 +373,7 @@ static long mmtimer_ioctl(struct file *file, unsigned int cmd,
371{ 373{
372 int ret = 0; 374 int ret = 0;
373 375
374 lock_kernel(); 376 mutex_lock(&mmtimer_mutex);
375 377
376 switch (cmd) { 378 switch (cmd) {
377 case MMTIMER_GETOFFSET: /* offset of the counter */ 379 case MMTIMER_GETOFFSET: /* offset of the counter */
@@ -414,7 +416,7 @@ static long mmtimer_ioctl(struct file *file, unsigned int cmd,
414 ret = -ENOTTY; 416 ret = -ENOTTY;
415 break; 417 break;
416 } 418 }
417 unlock_kernel(); 419 mutex_unlock(&mmtimer_mutex);
418 return ret; 420 return ret;
419} 421}
420 422
diff --git a/drivers/char/mspec.c b/drivers/char/mspec.c
index ecb89d798e35..966a95bc974b 100644
--- a/drivers/char/mspec.c
+++ b/drivers/char/mspec.c
@@ -316,7 +316,8 @@ uncached_mmap(struct file *file, struct vm_area_struct *vma)
316 316
317static const struct file_operations fetchop_fops = { 317static const struct file_operations fetchop_fops = {
318 .owner = THIS_MODULE, 318 .owner = THIS_MODULE,
319 .mmap = fetchop_mmap 319 .mmap = fetchop_mmap,
320 .llseek = noop_llseek,
320}; 321};
321 322
322static struct miscdevice fetchop_miscdev = { 323static struct miscdevice fetchop_miscdev = {
@@ -327,7 +328,8 @@ static struct miscdevice fetchop_miscdev = {
327 328
328static const struct file_operations cached_fops = { 329static const struct file_operations cached_fops = {
329 .owner = THIS_MODULE, 330 .owner = THIS_MODULE,
330 .mmap = cached_mmap 331 .mmap = cached_mmap,
332 .llseek = noop_llseek,
331}; 333};
332 334
333static struct miscdevice cached_miscdev = { 335static struct miscdevice cached_miscdev = {
@@ -338,7 +340,8 @@ static struct miscdevice cached_miscdev = {
338 340
339static const struct file_operations uncached_fops = { 341static const struct file_operations uncached_fops = {
340 .owner = THIS_MODULE, 342 .owner = THIS_MODULE,
341 .mmap = uncached_mmap 343 .mmap = uncached_mmap,
344 .llseek = noop_llseek,
342}; 345};
343 346
344static struct miscdevice uncached_miscdev = { 347static struct miscdevice uncached_miscdev = {
diff --git a/drivers/char/mwave/mwavedd.c b/drivers/char/mwave/mwavedd.c
index a4ec50c95072..1d82d5838f0c 100644
--- a/drivers/char/mwave/mwavedd.c
+++ b/drivers/char/mwave/mwavedd.c
@@ -56,7 +56,7 @@
56#include <linux/serial.h> 56#include <linux/serial.h>
57#include <linux/sched.h> 57#include <linux/sched.h>
58#include <linux/spinlock.h> 58#include <linux/spinlock.h>
59#include <linux/smp_lock.h> 59#include <linux/mutex.h>
60#include <linux/delay.h> 60#include <linux/delay.h>
61#include <linux/serial_8250.h> 61#include <linux/serial_8250.h>
62#include "smapi.h" 62#include "smapi.h"
@@ -73,6 +73,7 @@ MODULE_LICENSE("GPL");
73* checks are made against other devices (ie. superio) for conflicts. 73* checks are made against other devices (ie. superio) for conflicts.
74* We'll depend on users using the tpctl utility to do that for now 74* We'll depend on users using the tpctl utility to do that for now
75*/ 75*/
76static DEFINE_MUTEX(mwave_mutex);
76int mwave_debug = 0; 77int mwave_debug = 0;
77int mwave_3780i_irq = 0; 78int mwave_3780i_irq = 0;
78int mwave_3780i_io = 0; 79int mwave_3780i_io = 0;
@@ -101,7 +102,6 @@ static int mwave_open(struct inode *inode, struct file *file)
101 PRINTK_2(TRACE_MWAVE, 102 PRINTK_2(TRACE_MWAVE,
102 "mwavedd::mwave_open, exit return retval %x\n", retval); 103 "mwavedd::mwave_open, exit return retval %x\n", retval);
103 104
104 cycle_kernel_lock();
105 return retval; 105 return retval;
106} 106}
107 107
@@ -136,9 +136,9 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd,
136 PRINTK_1(TRACE_MWAVE, 136 PRINTK_1(TRACE_MWAVE,
137 "mwavedd::mwave_ioctl, IOCTL_MW_RESET" 137 "mwavedd::mwave_ioctl, IOCTL_MW_RESET"
138 " calling tp3780I_ResetDSP\n"); 138 " calling tp3780I_ResetDSP\n");
139 lock_kernel(); 139 mutex_lock(&mwave_mutex);
140 retval = tp3780I_ResetDSP(&pDrvData->rBDData); 140 retval = tp3780I_ResetDSP(&pDrvData->rBDData);
141 unlock_kernel(); 141 mutex_unlock(&mwave_mutex);
142 PRINTK_2(TRACE_MWAVE, 142 PRINTK_2(TRACE_MWAVE,
143 "mwavedd::mwave_ioctl, IOCTL_MW_RESET" 143 "mwavedd::mwave_ioctl, IOCTL_MW_RESET"
144 " retval %x from tp3780I_ResetDSP\n", 144 " retval %x from tp3780I_ResetDSP\n",
@@ -149,9 +149,9 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd,
149 PRINTK_1(TRACE_MWAVE, 149 PRINTK_1(TRACE_MWAVE,
150 "mwavedd::mwave_ioctl, IOCTL_MW_RUN" 150 "mwavedd::mwave_ioctl, IOCTL_MW_RUN"
151 " calling tp3780I_StartDSP\n"); 151 " calling tp3780I_StartDSP\n");
152 lock_kernel(); 152 mutex_lock(&mwave_mutex);
153 retval = tp3780I_StartDSP(&pDrvData->rBDData); 153 retval = tp3780I_StartDSP(&pDrvData->rBDData);
154 unlock_kernel(); 154 mutex_unlock(&mwave_mutex);
155 PRINTK_2(TRACE_MWAVE, 155 PRINTK_2(TRACE_MWAVE,
156 "mwavedd::mwave_ioctl, IOCTL_MW_RUN" 156 "mwavedd::mwave_ioctl, IOCTL_MW_RUN"
157 " retval %x from tp3780I_StartDSP\n", 157 " retval %x from tp3780I_StartDSP\n",
@@ -165,10 +165,10 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd,
165 "mwavedd::mwave_ioctl," 165 "mwavedd::mwave_ioctl,"
166 " IOCTL_MW_DSP_ABILITIES calling" 166 " IOCTL_MW_DSP_ABILITIES calling"
167 " tp3780I_QueryAbilities\n"); 167 " tp3780I_QueryAbilities\n");
168 lock_kernel(); 168 mutex_lock(&mwave_mutex);
169 retval = tp3780I_QueryAbilities(&pDrvData->rBDData, 169 retval = tp3780I_QueryAbilities(&pDrvData->rBDData,
170 &rAbilities); 170 &rAbilities);
171 unlock_kernel(); 171 mutex_unlock(&mwave_mutex);
172 PRINTK_2(TRACE_MWAVE, 172 PRINTK_2(TRACE_MWAVE,
173 "mwavedd::mwave_ioctl, IOCTL_MW_DSP_ABILITIES" 173 "mwavedd::mwave_ioctl, IOCTL_MW_DSP_ABILITIES"
174 " retval %x from tp3780I_QueryAbilities\n", 174 " retval %x from tp3780I_QueryAbilities\n",
@@ -199,13 +199,13 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd,
199 "mwavedd::mwave_ioctl IOCTL_MW_READ_DATA," 199 "mwavedd::mwave_ioctl IOCTL_MW_READ_DATA,"
200 " size %lx, ioarg %lx pusBuffer %p\n", 200 " size %lx, ioarg %lx pusBuffer %p\n",
201 rReadData.ulDataLength, ioarg, pusBuffer); 201 rReadData.ulDataLength, ioarg, pusBuffer);
202 lock_kernel(); 202 mutex_lock(&mwave_mutex);
203 retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, 203 retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData,
204 iocmd, 204 iocmd,
205 pusBuffer, 205 pusBuffer,
206 rReadData.ulDataLength, 206 rReadData.ulDataLength,
207 rReadData.usDspAddress); 207 rReadData.usDspAddress);
208 unlock_kernel(); 208 mutex_unlock(&mwave_mutex);
209 } 209 }
210 break; 210 break;
211 211
@@ -223,12 +223,12 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd,
223 " size %lx, ioarg %lx pusBuffer %p\n", 223 " size %lx, ioarg %lx pusBuffer %p\n",
224 rReadData.ulDataLength / 2, ioarg, 224 rReadData.ulDataLength / 2, ioarg,
225 pusBuffer); 225 pusBuffer);
226 lock_kernel(); 226 mutex_lock(&mwave_mutex);
227 retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, 227 retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData,
228 iocmd, pusBuffer, 228 iocmd, pusBuffer,
229 rReadData.ulDataLength / 2, 229 rReadData.ulDataLength / 2,
230 rReadData.usDspAddress); 230 rReadData.usDspAddress);
231 unlock_kernel(); 231 mutex_unlock(&mwave_mutex);
232 } 232 }
233 break; 233 break;
234 234
@@ -246,12 +246,12 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd,
246 " size %lx, ioarg %lx pusBuffer %p\n", 246 " size %lx, ioarg %lx pusBuffer %p\n",
247 rWriteData.ulDataLength, ioarg, 247 rWriteData.ulDataLength, ioarg,
248 pusBuffer); 248 pusBuffer);
249 lock_kernel(); 249 mutex_lock(&mwave_mutex);
250 retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, 250 retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData,
251 iocmd, pusBuffer, 251 iocmd, pusBuffer,
252 rWriteData.ulDataLength, 252 rWriteData.ulDataLength,
253 rWriteData.usDspAddress); 253 rWriteData.usDspAddress);
254 unlock_kernel(); 254 mutex_unlock(&mwave_mutex);
255 } 255 }
256 break; 256 break;
257 257
@@ -269,12 +269,12 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd,
269 " size %lx, ioarg %lx pusBuffer %p\n", 269 " size %lx, ioarg %lx pusBuffer %p\n",
270 rWriteData.ulDataLength, ioarg, 270 rWriteData.ulDataLength, ioarg,
271 pusBuffer); 271 pusBuffer);
272 lock_kernel(); 272 mutex_lock(&mwave_mutex);
273 retval = tp3780I_ReadWriteDspIStore(&pDrvData->rBDData, 273 retval = tp3780I_ReadWriteDspIStore(&pDrvData->rBDData,
274 iocmd, pusBuffer, 274 iocmd, pusBuffer,
275 rWriteData.ulDataLength, 275 rWriteData.ulDataLength,
276 rWriteData.usDspAddress); 276 rWriteData.usDspAddress);
277 unlock_kernel(); 277 mutex_unlock(&mwave_mutex);
278 } 278 }
279 break; 279 break;
280 280
@@ -295,10 +295,10 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd,
295 ipcnum, 295 ipcnum,
296 pDrvData->IPCs[ipcnum].usIntCount); 296 pDrvData->IPCs[ipcnum].usIntCount);
297 297
298 lock_kernel(); 298 mutex_lock(&mwave_mutex);
299 pDrvData->IPCs[ipcnum].bIsHere = FALSE; 299 pDrvData->IPCs[ipcnum].bIsHere = FALSE;
300 pDrvData->IPCs[ipcnum].bIsEnabled = TRUE; 300 pDrvData->IPCs[ipcnum].bIsEnabled = TRUE;
301 unlock_kernel(); 301 mutex_unlock(&mwave_mutex);
302 302
303 PRINTK_2(TRACE_MWAVE, 303 PRINTK_2(TRACE_MWAVE,
304 "mwavedd::mwave_ioctl IOCTL_MW_REGISTER_IPC" 304 "mwavedd::mwave_ioctl IOCTL_MW_REGISTER_IPC"
@@ -323,7 +323,7 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd,
323 ipcnum, 323 ipcnum,
324 pDrvData->IPCs[ipcnum].usIntCount); 324 pDrvData->IPCs[ipcnum].usIntCount);
325 325
326 lock_kernel(); 326 mutex_lock(&mwave_mutex);
327 if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) { 327 if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) {
328 DECLARE_WAITQUEUE(wait, current); 328 DECLARE_WAITQUEUE(wait, current);
329 329
@@ -364,7 +364,7 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd,
364 " processing\n", 364 " processing\n",
365 ipcnum); 365 ipcnum);
366 } 366 }
367 unlock_kernel(); 367 mutex_unlock(&mwave_mutex);
368 } 368 }
369 break; 369 break;
370 370
@@ -383,14 +383,14 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd,
383 ipcnum); 383 ipcnum);
384 return -EINVAL; 384 return -EINVAL;
385 } 385 }
386 lock_kernel(); 386 mutex_lock(&mwave_mutex);
387 if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) { 387 if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) {
388 pDrvData->IPCs[ipcnum].bIsEnabled = FALSE; 388 pDrvData->IPCs[ipcnum].bIsEnabled = FALSE;
389 if (pDrvData->IPCs[ipcnum].bIsHere == TRUE) { 389 if (pDrvData->IPCs[ipcnum].bIsHere == TRUE) {
390 wake_up_interruptible(&pDrvData->IPCs[ipcnum].ipc_wait_queue); 390 wake_up_interruptible(&pDrvData->IPCs[ipcnum].ipc_wait_queue);
391 } 391 }
392 } 392 }
393 unlock_kernel(); 393 mutex_unlock(&mwave_mutex);
394 } 394 }
395 break; 395 break;
396 396
@@ -479,7 +479,8 @@ static const struct file_operations mwave_fops = {
479 .write = mwave_write, 479 .write = mwave_write,
480 .unlocked_ioctl = mwave_ioctl, 480 .unlocked_ioctl = mwave_ioctl,
481 .open = mwave_open, 481 .open = mwave_open,
482 .release = mwave_close 482 .release = mwave_close,
483 .llseek = default_llseek,
483}; 484};
484 485
485 486
diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
index 66d2917b003f..166f1e7aaa7e 100644
--- a/drivers/char/nvram.c
+++ b/drivers/char/nvram.c
@@ -109,10 +109,11 @@
109#include <linux/spinlock.h> 109#include <linux/spinlock.h>
110#include <linux/io.h> 110#include <linux/io.h>
111#include <linux/uaccess.h> 111#include <linux/uaccess.h>
112#include <linux/smp_lock.h> 112#include <linux/mutex.h>
113 113
114#include <asm/system.h> 114#include <asm/system.h>
115 115
116static DEFINE_MUTEX(nvram_mutex);
116static DEFINE_SPINLOCK(nvram_state_lock); 117static DEFINE_SPINLOCK(nvram_state_lock);
117static int nvram_open_cnt; /* #times opened */ 118static int nvram_open_cnt; /* #times opened */
118static int nvram_open_mode; /* special open modes */ 119static int nvram_open_mode; /* special open modes */
@@ -308,7 +309,7 @@ static long nvram_ioctl(struct file *file, unsigned int cmd,
308 if (!capable(CAP_SYS_ADMIN)) 309 if (!capable(CAP_SYS_ADMIN))
309 return -EACCES; 310 return -EACCES;
310 311
311 lock_kernel(); 312 mutex_lock(&nvram_mutex);
312 spin_lock_irq(&rtc_lock); 313 spin_lock_irq(&rtc_lock);
313 314
314 for (i = 0; i < NVRAM_BYTES; ++i) 315 for (i = 0; i < NVRAM_BYTES; ++i)
@@ -316,7 +317,7 @@ static long nvram_ioctl(struct file *file, unsigned int cmd,
316 __nvram_set_checksum(); 317 __nvram_set_checksum();
317 318
318 spin_unlock_irq(&rtc_lock); 319 spin_unlock_irq(&rtc_lock);
319 unlock_kernel(); 320 mutex_unlock(&nvram_mutex);
320 return 0; 321 return 0;
321 322
322 case NVRAM_SETCKS: 323 case NVRAM_SETCKS:
@@ -325,11 +326,11 @@ static long nvram_ioctl(struct file *file, unsigned int cmd,
325 if (!capable(CAP_SYS_ADMIN)) 326 if (!capable(CAP_SYS_ADMIN))
326 return -EACCES; 327 return -EACCES;
327 328
328 lock_kernel(); 329 mutex_lock(&nvram_mutex);
329 spin_lock_irq(&rtc_lock); 330 spin_lock_irq(&rtc_lock);
330 __nvram_set_checksum(); 331 __nvram_set_checksum();
331 spin_unlock_irq(&rtc_lock); 332 spin_unlock_irq(&rtc_lock);
332 unlock_kernel(); 333 mutex_unlock(&nvram_mutex);
333 return 0; 334 return 0;
334 335
335 default: 336 default:
diff --git a/drivers/char/nwbutton.c b/drivers/char/nwbutton.c
index 2604246501e4..8994ce32e6c7 100644
--- a/drivers/char/nwbutton.c
+++ b/drivers/char/nwbutton.c
@@ -182,6 +182,7 @@ static int button_read (struct file *filp, char __user *buffer,
182static const struct file_operations button_fops = { 182static const struct file_operations button_fops = {
183 .owner = THIS_MODULE, 183 .owner = THIS_MODULE,
184 .read = button_read, 184 .read = button_read,
185 .llseek = noop_llseek,
185}; 186};
186 187
187/* 188/*
diff --git a/drivers/char/nwflash.c b/drivers/char/nwflash.c
index 043a1c7b86be..a12f52400dbc 100644
--- a/drivers/char/nwflash.c
+++ b/drivers/char/nwflash.c
@@ -25,7 +25,6 @@
25#include <linux/spinlock.h> 25#include <linux/spinlock.h>
26#include <linux/rwsem.h> 26#include <linux/rwsem.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/smp_lock.h>
29#include <linux/mutex.h> 28#include <linux/mutex.h>
30#include <linux/jiffies.h> 29#include <linux/jiffies.h>
31 30
@@ -41,6 +40,7 @@
41 40
42#define NWFLASH_VERSION "6.4" 41#define NWFLASH_VERSION "6.4"
43 42
43static DEFINE_MUTEX(flash_mutex);
44static void kick_open(void); 44static void kick_open(void);
45static int get_flash_id(void); 45static int get_flash_id(void);
46static int erase_block(int nBlock); 46static int erase_block(int nBlock);
@@ -96,7 +96,7 @@ static int get_flash_id(void)
96 96
97static long flash_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) 97static long flash_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
98{ 98{
99 lock_kernel(); 99 mutex_lock(&flash_mutex);
100 switch (cmd) { 100 switch (cmd) {
101 case CMD_WRITE_DISABLE: 101 case CMD_WRITE_DISABLE:
102 gbWriteBase64Enable = 0; 102 gbWriteBase64Enable = 0;
@@ -114,10 +114,10 @@ static long flash_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
114 default: 114 default:
115 gbWriteBase64Enable = 0; 115 gbWriteBase64Enable = 0;
116 gbWriteEnable = 0; 116 gbWriteEnable = 0;
117 unlock_kernel(); 117 mutex_unlock(&flash_mutex);
118 return -EINVAL; 118 return -EINVAL;
119 } 119 }
120 unlock_kernel(); 120 mutex_unlock(&flash_mutex);
121 return 0; 121 return 0;
122} 122}
123 123
@@ -282,7 +282,7 @@ static loff_t flash_llseek(struct file *file, loff_t offset, int orig)
282{ 282{
283 loff_t ret; 283 loff_t ret;
284 284
285 lock_kernel(); 285 mutex_lock(&flash_mutex);
286 if (flashdebug) 286 if (flashdebug)
287 printk(KERN_DEBUG "flash_llseek: offset=0x%X, orig=0x%X.\n", 287 printk(KERN_DEBUG "flash_llseek: offset=0x%X, orig=0x%X.\n",
288 (unsigned int) offset, orig); 288 (unsigned int) offset, orig);
@@ -317,7 +317,7 @@ static loff_t flash_llseek(struct file *file, loff_t offset, int orig)
317 default: 317 default:
318 ret = -EINVAL; 318 ret = -EINVAL;
319 } 319 }
320 unlock_kernel(); 320 mutex_unlock(&flash_mutex);
321 return ret; 321 return ret;
322} 322}
323 323
diff --git a/drivers/char/pc8736x_gpio.c b/drivers/char/pc8736x_gpio.c
index 8ecbcc174c15..b304ec052501 100644
--- a/drivers/char/pc8736x_gpio.c
+++ b/drivers/char/pc8736x_gpio.c
@@ -234,6 +234,7 @@ static const struct file_operations pc8736x_gpio_fileops = {
234 .open = pc8736x_gpio_open, 234 .open = pc8736x_gpio_open,
235 .write = nsc_gpio_write, 235 .write = nsc_gpio_write,
236 .read = nsc_gpio_read, 236 .read = nsc_gpio_read,
237 .llseek = no_llseek,
237}; 238};
238 239
239static void __init pc8736x_init_shadow(void) 240static void __init pc8736x_init_shadow(void)
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index c7b482d15e2a..6835c23e9a51 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -30,7 +30,7 @@
30#include <linux/fs.h> 30#include <linux/fs.h>
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/bitrev.h> 32#include <linux/bitrev.h>
33#include <linux/smp_lock.h> 33#include <linux/mutex.h>
34#include <linux/uaccess.h> 34#include <linux/uaccess.h>
35#include <linux/io.h> 35#include <linux/io.h>
36 36
@@ -54,6 +54,8 @@
54 __func__ , ## args); \ 54 __func__ , ## args); \
55 } while (0) 55 } while (0)
56 56
57static DEFINE_MUTEX(cmm_mutex);
58
57#define T_1SEC (HZ) 59#define T_1SEC (HZ)
58#define T_10MSEC msecs_to_jiffies(10) 60#define T_10MSEC msecs_to_jiffies(10)
59#define T_20MSEC msecs_to_jiffies(20) 61#define T_20MSEC msecs_to_jiffies(20)
@@ -1415,7 +1417,7 @@ static long cmm_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
1415 iminor(inode), ioctl_names[_IOC_NR(cmd)]); 1417 iminor(inode), ioctl_names[_IOC_NR(cmd)]);
1416#endif 1418#endif
1417 1419
1418 lock_kernel(); 1420 mutex_lock(&cmm_mutex);
1419 rc = -ENODEV; 1421 rc = -ENODEV;
1420 link = dev_table[iminor(inode)]; 1422 link = dev_table[iminor(inode)];
1421 if (!pcmcia_dev_present(link)) { 1423 if (!pcmcia_dev_present(link)) {
@@ -1623,7 +1625,7 @@ static long cmm_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
1623 rc = -ENOTTY; 1625 rc = -ENOTTY;
1624 } 1626 }
1625out: 1627out:
1626 unlock_kernel(); 1628 mutex_unlock(&cmm_mutex);
1627 return rc; 1629 return rc;
1628} 1630}
1629 1631
@@ -1637,7 +1639,7 @@ static int cmm_open(struct inode *inode, struct file *filp)
1637 if (minor >= CM4000_MAX_DEV) 1639 if (minor >= CM4000_MAX_DEV)
1638 return -ENODEV; 1640 return -ENODEV;
1639 1641
1640 lock_kernel(); 1642 mutex_lock(&cmm_mutex);
1641 link = dev_table[minor]; 1643 link = dev_table[minor];
1642 if (link == NULL || !pcmcia_dev_present(link)) { 1644 if (link == NULL || !pcmcia_dev_present(link)) {
1643 ret = -ENODEV; 1645 ret = -ENODEV;
@@ -1682,7 +1684,7 @@ static int cmm_open(struct inode *inode, struct file *filp)
1682 DEBUGP(2, dev, "<- cmm_open\n"); 1684 DEBUGP(2, dev, "<- cmm_open\n");
1683 ret = nonseekable_open(inode, filp); 1685 ret = nonseekable_open(inode, filp);
1684out: 1686out:
1685 unlock_kernel(); 1687 mutex_unlock(&cmm_mutex);
1686 return ret; 1688 return ret;
1687} 1689}
1688 1690
@@ -1864,6 +1866,7 @@ static const struct file_operations cm4000_fops = {
1864 .unlocked_ioctl = cmm_ioctl, 1866 .unlocked_ioctl = cmm_ioctl,
1865 .open = cmm_open, 1867 .open = cmm_open,
1866 .release= cmm_close, 1868 .release= cmm_close,
1869 .llseek = no_llseek,
1867}; 1870};
1868 1871
1869static struct pcmcia_device_id cm4000_ids[] = { 1872static struct pcmcia_device_id cm4000_ids[] = {
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
index bf2f046fc2c1..5d8d59e865f4 100644
--- a/drivers/char/pcmcia/cm4040_cs.c
+++ b/drivers/char/pcmcia/cm4040_cs.c
@@ -24,7 +24,7 @@
24#include <linux/fs.h> 24#include <linux/fs.h>
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/poll.h> 26#include <linux/poll.h>
27#include <linux/smp_lock.h> 27#include <linux/mutex.h>
28#include <linux/wait.h> 28#include <linux/wait.h>
29#include <asm/uaccess.h> 29#include <asm/uaccess.h>
30#include <asm/io.h> 30#include <asm/io.h>
@@ -48,6 +48,8 @@
48 __func__ , ## args); \ 48 __func__ , ## args); \
49 } while (0) 49 } while (0)
50 50
51static DEFINE_MUTEX(cm4040_mutex);
52
51#define CCID_DRIVER_BULK_DEFAULT_TIMEOUT (150*HZ) 53#define CCID_DRIVER_BULK_DEFAULT_TIMEOUT (150*HZ)
52#define CCID_DRIVER_ASYNC_POWERUP_TIMEOUT (35*HZ) 54#define CCID_DRIVER_ASYNC_POWERUP_TIMEOUT (35*HZ)
53#define CCID_DRIVER_MINIMUM_TIMEOUT (3*HZ) 55#define CCID_DRIVER_MINIMUM_TIMEOUT (3*HZ)
@@ -440,7 +442,7 @@ static int cm4040_open(struct inode *inode, struct file *filp)
440 if (minor >= CM_MAX_DEV) 442 if (minor >= CM_MAX_DEV)
441 return -ENODEV; 443 return -ENODEV;
442 444
443 lock_kernel(); 445 mutex_lock(&cm4040_mutex);
444 link = dev_table[minor]; 446 link = dev_table[minor];
445 if (link == NULL || !pcmcia_dev_present(link)) { 447 if (link == NULL || !pcmcia_dev_present(link)) {
446 ret = -ENODEV; 448 ret = -ENODEV;
@@ -469,7 +471,7 @@ static int cm4040_open(struct inode *inode, struct file *filp)
469 DEBUGP(2, dev, "<- cm4040_open (successfully)\n"); 471 DEBUGP(2, dev, "<- cm4040_open (successfully)\n");
470 ret = nonseekable_open(inode, filp); 472 ret = nonseekable_open(inode, filp);
471out: 473out:
472 unlock_kernel(); 474 mutex_unlock(&cm4040_mutex);
473 return ret; 475 return ret;
474} 476}
475 477
@@ -628,6 +630,7 @@ static const struct file_operations reader_fops = {
628 .open = cm4040_open, 630 .open = cm4040_open,
629 .release = cm4040_close, 631 .release = cm4040_close,
630 .poll = cm4040_poll, 632 .poll = cm4040_poll,
633 .llseek = no_llseek,
631}; 634};
632 635
633static struct pcmcia_device_id cm4040_ids[] = { 636static struct pcmcia_device_id cm4040_ids[] = {
diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
index 02abfddce45a..723152d978a9 100644
--- a/drivers/char/ppdev.c
+++ b/drivers/char/ppdev.c
@@ -67,7 +67,7 @@
67#include <linux/slab.h> 67#include <linux/slab.h>
68#include <linux/major.h> 68#include <linux/major.h>
69#include <linux/ppdev.h> 69#include <linux/ppdev.h>
70#include <linux/smp_lock.h> 70#include <linux/mutex.h>
71#include <linux/uaccess.h> 71#include <linux/uaccess.h>
72 72
73#define PP_VERSION "ppdev: user-space parallel port driver" 73#define PP_VERSION "ppdev: user-space parallel port driver"
@@ -97,6 +97,7 @@ struct pp_struct {
97/* ROUND_UP macro from fs/select.c */ 97/* ROUND_UP macro from fs/select.c */
98#define ROUND_UP(x,y) (((x)+(y)-1)/(y)) 98#define ROUND_UP(x,y) (((x)+(y)-1)/(y))
99 99
100static DEFINE_MUTEX(pp_do_mutex);
100static inline void pp_enable_irq (struct pp_struct *pp) 101static inline void pp_enable_irq (struct pp_struct *pp)
101{ 102{
102 struct parport *port = pp->pdev->port; 103 struct parport *port = pp->pdev->port;
@@ -630,9 +631,9 @@ static int pp_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
630static long pp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 631static long pp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
631{ 632{
632 long ret; 633 long ret;
633 lock_kernel(); 634 mutex_lock(&pp_do_mutex);
634 ret = pp_do_ioctl(file, cmd, arg); 635 ret = pp_do_ioctl(file, cmd, arg);
635 unlock_kernel(); 636 mutex_unlock(&pp_do_mutex);
636 return ret; 637 return ret;
637} 638}
638 639
@@ -641,7 +642,6 @@ static int pp_open (struct inode * inode, struct file * file)
641 unsigned int minor = iminor(inode); 642 unsigned int minor = iminor(inode);
642 struct pp_struct *pp; 643 struct pp_struct *pp;
643 644
644 cycle_kernel_lock();
645 if (minor >= PARPORT_MAX) 645 if (minor >= PARPORT_MAX)
646 return -ENXIO; 646 return -ENXIO;
647 647
diff --git a/drivers/char/random.c b/drivers/char/random.c
index caef35a46890..5a1aa64f4e76 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1165,6 +1165,7 @@ const struct file_operations random_fops = {
1165 .poll = random_poll, 1165 .poll = random_poll,
1166 .unlocked_ioctl = random_ioctl, 1166 .unlocked_ioctl = random_ioctl,
1167 .fasync = random_fasync, 1167 .fasync = random_fasync,
1168 .llseek = noop_llseek,
1168}; 1169};
1169 1170
1170const struct file_operations urandom_fops = { 1171const struct file_operations urandom_fops = {
@@ -1172,6 +1173,7 @@ const struct file_operations urandom_fops = {
1172 .write = random_write, 1173 .write = random_write,
1173 .unlocked_ioctl = random_ioctl, 1174 .unlocked_ioctl = random_ioctl,
1174 .fasync = random_fasync, 1175 .fasync = random_fasync,
1176 .llseek = noop_llseek,
1175}; 1177};
1176 1178
1177/*************************************************************** 1179/***************************************************************
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index b38942f6bf31..bfe25ea9766b 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -19,8 +19,8 @@
19#include <linux/cdev.h> 19#include <linux/cdev.h>
20#include <linux/device.h> 20#include <linux/device.h>
21#include <linux/mutex.h> 21#include <linux/mutex.h>
22#include <linux/smp_lock.h>
23#include <linux/gfp.h> 22#include <linux/gfp.h>
23#include <linux/compat.h>
24 24
25#include <asm/uaccess.h> 25#include <asm/uaccess.h>
26 26
@@ -55,7 +55,6 @@ static int raw_open(struct inode *inode, struct file *filp)
55 return 0; 55 return 0;
56 } 56 }
57 57
58 lock_kernel();
59 mutex_lock(&raw_mutex); 58 mutex_lock(&raw_mutex);
60 59
61 /* 60 /*
@@ -82,7 +81,6 @@ static int raw_open(struct inode *inode, struct file *filp)
82 bdev->bd_inode->i_mapping; 81 bdev->bd_inode->i_mapping;
83 filp->private_data = bdev; 82 filp->private_data = bdev;
84 mutex_unlock(&raw_mutex); 83 mutex_unlock(&raw_mutex);
85 unlock_kernel();
86 return 0; 84 return 0;
87 85
88out2: 86out2:
@@ -91,7 +89,6 @@ out1:
91 blkdev_put(bdev, filp->f_mode); 89 blkdev_put(bdev, filp->f_mode);
92out: 90out:
93 mutex_unlock(&raw_mutex); 91 mutex_unlock(&raw_mutex);
94 unlock_kernel();
95 return err; 92 return err;
96} 93}
97 94
@@ -125,20 +122,84 @@ static long
125raw_ioctl(struct file *filp, unsigned int command, unsigned long arg) 122raw_ioctl(struct file *filp, unsigned int command, unsigned long arg)
126{ 123{
127 struct block_device *bdev = filp->private_data; 124 struct block_device *bdev = filp->private_data;
128 int ret; 125 return blkdev_ioctl(bdev, 0, command, arg);
126}
127
128static int bind_set(int number, u64 major, u64 minor)
129{
130 dev_t dev = MKDEV(major, minor);
131 struct raw_device_data *rawdev;
132 int err = 0;
129 133
130 lock_kernel(); 134 if (number <= 0 || number >= MAX_RAW_MINORS)
131 ret = blkdev_ioctl(bdev, 0, command, arg); 135 return -EINVAL;
132 unlock_kernel();
133 136
134 return ret; 137 if (MAJOR(dev) != major || MINOR(dev) != minor)
138 return -EINVAL;
139
140 rawdev = &raw_devices[number];
141
142 /*
143 * This is like making block devices, so demand the
144 * same capability
145 */
146 if (!capable(CAP_SYS_ADMIN))
147 return -EPERM;
148
149 /*
150 * For now, we don't need to check that the underlying
151 * block device is present or not: we can do that when
152 * the raw device is opened. Just check that the
153 * major/minor numbers make sense.
154 */
155
156 if (MAJOR(dev) == 0 && dev != 0)
157 return -EINVAL;
158
159 mutex_lock(&raw_mutex);
160 if (rawdev->inuse) {
161 mutex_unlock(&raw_mutex);
162 return -EBUSY;
163 }
164 if (rawdev->binding) {
165 bdput(rawdev->binding);
166 module_put(THIS_MODULE);
167 }
168 if (!dev) {
169 /* unbind */
170 rawdev->binding = NULL;
171 device_destroy(raw_class, MKDEV(RAW_MAJOR, number));
172 } else {
173 rawdev->binding = bdget(dev);
174 if (rawdev->binding == NULL) {
175 err = -ENOMEM;
176 } else {
177 dev_t raw = MKDEV(RAW_MAJOR, number);
178 __module_get(THIS_MODULE);
179 device_destroy(raw_class, raw);
180 device_create(raw_class, NULL, raw, NULL,
181 "raw%d", number);
182 }
183 }
184 mutex_unlock(&raw_mutex);
185 return err;
135} 186}
136 187
137static void bind_device(struct raw_config_request *rq) 188static int bind_get(int number, dev_t *dev)
138{ 189{
139 device_destroy(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor)); 190 struct raw_device_data *rawdev;
140 device_create(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor), NULL, 191 struct block_device *bdev;
141 "raw%d", rq->raw_minor); 192
193 if (number <= 0 || number >= MAX_RAW_MINORS)
194 return -EINVAL;
195
196 rawdev = &raw_devices[number];
197
198 mutex_lock(&raw_mutex);
199 bdev = rawdev->binding;
200 *dev = bdev ? bdev->bd_dev : 0;
201 mutex_unlock(&raw_mutex);
202 return 0;
142} 203}
143 204
144/* 205/*
@@ -149,105 +210,78 @@ static long raw_ctl_ioctl(struct file *filp, unsigned int command,
149 unsigned long arg) 210 unsigned long arg)
150{ 211{
151 struct raw_config_request rq; 212 struct raw_config_request rq;
152 struct raw_device_data *rawdev; 213 dev_t dev;
153 int err = 0; 214 int err;
154 215
155 lock_kernel();
156 switch (command) { 216 switch (command) {
157 case RAW_SETBIND: 217 case RAW_SETBIND:
218 if (copy_from_user(&rq, (void __user *) arg, sizeof(rq)))
219 return -EFAULT;
220
221 return bind_set(rq.raw_minor, rq.block_major, rq.block_minor);
222
158 case RAW_GETBIND: 223 case RAW_GETBIND:
224 if (copy_from_user(&rq, (void __user *) arg, sizeof(rq)))
225 return -EFAULT;
159 226
160 /* First, find out which raw minor we want */ 227 err = bind_get(rq.raw_minor, &dev);
228 if (err)
229 return err;
161 230
162 if (copy_from_user(&rq, (void __user *) arg, sizeof(rq))) { 231 rq.block_major = MAJOR(dev);
163 err = -EFAULT; 232 rq.block_minor = MINOR(dev);
164 goto out;
165 }
166 233
167 if (rq.raw_minor <= 0 || rq.raw_minor >= MAX_RAW_MINORS) { 234 if (copy_to_user((void __user *)arg, &rq, sizeof(rq)))
168 err = -EINVAL; 235 return -EFAULT;
169 goto out; 236
170 } 237 return 0;
171 rawdev = &raw_devices[rq.raw_minor];
172
173 if (command == RAW_SETBIND) {
174 dev_t dev;
175
176 /*
177 * This is like making block devices, so demand the
178 * same capability
179 */
180 if (!capable(CAP_SYS_ADMIN)) {
181 err = -EPERM;
182 goto out;
183 }
184
185 /*
186 * For now, we don't need to check that the underlying
187 * block device is present or not: we can do that when
188 * the raw device is opened. Just check that the
189 * major/minor numbers make sense.
190 */
191
192 dev = MKDEV(rq.block_major, rq.block_minor);
193 if ((rq.block_major == 0 && rq.block_minor != 0) ||
194 MAJOR(dev) != rq.block_major ||
195 MINOR(dev) != rq.block_minor) {
196 err = -EINVAL;
197 goto out;
198 }
199
200 mutex_lock(&raw_mutex);
201 if (rawdev->inuse) {
202 mutex_unlock(&raw_mutex);
203 err = -EBUSY;
204 goto out;
205 }
206 if (rawdev->binding) {
207 bdput(rawdev->binding);
208 module_put(THIS_MODULE);
209 }
210 if (rq.block_major == 0 && rq.block_minor == 0) {
211 /* unbind */
212 rawdev->binding = NULL;
213 device_destroy(raw_class,
214 MKDEV(RAW_MAJOR, rq.raw_minor));
215 } else {
216 rawdev->binding = bdget(dev);
217 if (rawdev->binding == NULL)
218 err = -ENOMEM;
219 else {
220 __module_get(THIS_MODULE);
221 bind_device(&rq);
222 }
223 }
224 mutex_unlock(&raw_mutex);
225 } else {
226 struct block_device *bdev;
227
228 mutex_lock(&raw_mutex);
229 bdev = rawdev->binding;
230 if (bdev) {
231 rq.block_major = MAJOR(bdev->bd_dev);
232 rq.block_minor = MINOR(bdev->bd_dev);
233 } else {
234 rq.block_major = rq.block_minor = 0;
235 }
236 mutex_unlock(&raw_mutex);
237 if (copy_to_user((void __user *)arg, &rq, sizeof(rq))) {
238 err = -EFAULT;
239 goto out;
240 }
241 }
242 break;
243 default:
244 err = -EINVAL;
245 break;
246 } 238 }
247out: 239
248 unlock_kernel(); 240 return -EINVAL;
249 return err; 241}
242
243#ifdef CONFIG_COMPAT
244struct raw32_config_request {
245 compat_int_t raw_minor;
246 compat_u64 block_major;
247 compat_u64 block_minor;
248};
249
250static long raw_ctl_compat_ioctl(struct file *file, unsigned int cmd,
251 unsigned long arg)
252{
253 struct raw32_config_request __user *user_req = compat_ptr(arg);
254 struct raw32_config_request rq;
255 dev_t dev;
256 int err = 0;
257
258 switch (cmd) {
259 case RAW_SETBIND:
260 if (copy_from_user(&rq, user_req, sizeof(rq)))
261 return -EFAULT;
262
263 return bind_set(rq.raw_minor, rq.block_major, rq.block_minor);
264
265 case RAW_GETBIND:
266 if (copy_from_user(&rq, user_req, sizeof(rq)))
267 return -EFAULT;
268
269 err = bind_get(rq.raw_minor, &dev);
270 if (err)
271 return err;
272
273 rq.block_major = MAJOR(dev);
274 rq.block_minor = MINOR(dev);
275
276 if (copy_to_user(user_req, &rq, sizeof(rq)))
277 return -EFAULT;
278
279 return 0;
280 }
281
282 return -EINVAL;
250} 283}
284#endif
251 285
252static const struct file_operations raw_fops = { 286static const struct file_operations raw_fops = {
253 .read = do_sync_read, 287 .read = do_sync_read,
@@ -258,13 +292,18 @@ static const struct file_operations raw_fops = {
258 .open = raw_open, 292 .open = raw_open,
259 .release = raw_release, 293 .release = raw_release,
260 .unlocked_ioctl = raw_ioctl, 294 .unlocked_ioctl = raw_ioctl,
295 .llseek = default_llseek,
261 .owner = THIS_MODULE, 296 .owner = THIS_MODULE,
262}; 297};
263 298
264static const struct file_operations raw_ctl_fops = { 299static const struct file_operations raw_ctl_fops = {
265 .unlocked_ioctl = raw_ctl_ioctl, 300 .unlocked_ioctl = raw_ctl_ioctl,
301#ifdef CONFIG_COMPAT
302 .compat_ioctl = raw_ctl_compat_ioctl,
303#endif
266 .open = raw_open, 304 .open = raw_open,
267 .owner = THIS_MODULE, 305 .owner = THIS_MODULE,
306 .llseek = noop_llseek,
268}; 307};
269 308
270static struct cdev raw_cdev; 309static struct cdev raw_cdev;
diff --git a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c
index d58c2eb07f07..5e33293d24e3 100644
--- a/drivers/char/rio/rio_linux.c
+++ b/drivers/char/rio/rio_linux.c
@@ -44,7 +44,7 @@
44#include <linux/delay.h> 44#include <linux/delay.h>
45#include <linux/pci.h> 45#include <linux/pci.h>
46#include <linux/slab.h> 46#include <linux/slab.h>
47#include <linux/smp_lock.h> 47#include <linux/mutex.h>
48#include <linux/miscdevice.h> 48#include <linux/miscdevice.h>
49#include <linux/init.h> 49#include <linux/init.h>
50 50
@@ -122,6 +122,7 @@ more than 512 ports.... */
122 122
123 123
124/* These constants are derived from SCO Source */ 124/* These constants are derived from SCO Source */
125static DEFINE_MUTEX(rio_fw_mutex);
125static struct Conf 126static struct Conf
126 RIOConf = { 127 RIOConf = {
127 /* locator */ "RIO Config here", 128 /* locator */ "RIO Config here",
@@ -241,6 +242,7 @@ static struct real_driver rio_real_driver = {
241static const struct file_operations rio_fw_fops = { 242static const struct file_operations rio_fw_fops = {
242 .owner = THIS_MODULE, 243 .owner = THIS_MODULE,
243 .unlocked_ioctl = rio_fw_ioctl, 244 .unlocked_ioctl = rio_fw_ioctl,
245 .llseek = noop_llseek,
244}; 246};
245 247
246static struct miscdevice rio_fw_device = { 248static struct miscdevice rio_fw_device = {
@@ -566,9 +568,9 @@ static long rio_fw_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
566 func_enter(); 568 func_enter();
567 569
568 /* The "dev" argument isn't used. */ 570 /* The "dev" argument isn't used. */
569 lock_kernel(); 571 mutex_lock(&rio_fw_mutex);
570 rc = riocontrol(p, 0, cmd, arg, capable(CAP_SYS_ADMIN)); 572 rc = riocontrol(p, 0, cmd, arg, capable(CAP_SYS_ADMIN));
571 unlock_kernel(); 573 mutex_unlock(&rio_fw_mutex);
572 574
573 func_exit(); 575 func_exit();
574 return rc; 576 return rc;
diff --git a/drivers/char/scx200_gpio.c b/drivers/char/scx200_gpio.c
index 99e5272e3c53..0bc135b9b16f 100644
--- a/drivers/char/scx200_gpio.c
+++ b/drivers/char/scx200_gpio.c
@@ -67,6 +67,7 @@ static const struct file_operations scx200_gpio_fileops = {
67 .read = nsc_gpio_read, 67 .read = nsc_gpio_read,
68 .open = scx200_gpio_open, 68 .open = scx200_gpio_open,
69 .release = scx200_gpio_release, 69 .release = scx200_gpio_release,
70 .llseek = no_llseek,
70}; 71};
71 72
72static struct cdev scx200_gpio_cdev; /* use 1 cdev for all pins */ 73static struct cdev scx200_gpio_cdev; /* use 1 cdev for all pins */
diff --git a/drivers/char/snsc.c b/drivers/char/snsc.c
index 32b74de18f5f..5816b39ff5a9 100644
--- a/drivers/char/snsc.c
+++ b/drivers/char/snsc.c
@@ -21,7 +21,7 @@
21#include <linux/poll.h> 21#include <linux/poll.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/smp_lock.h> 24#include <linux/mutex.h>
25#include <asm/sn/io.h> 25#include <asm/sn/io.h>
26#include <asm/sn/sn_sal.h> 26#include <asm/sn/sn_sal.h>
27#include <asm/sn/module.h> 27#include <asm/sn/module.h>
@@ -34,6 +34,7 @@
34#define SCDRV_BUFSZ 2048 34#define SCDRV_BUFSZ 2048
35#define SCDRV_TIMEOUT 1000 35#define SCDRV_TIMEOUT 1000
36 36
37static DEFINE_MUTEX(scdrv_mutex);
37static irqreturn_t 38static irqreturn_t
38scdrv_interrupt(int irq, void *subch_data) 39scdrv_interrupt(int irq, void *subch_data)
39{ 40{
@@ -105,7 +106,7 @@ scdrv_open(struct inode *inode, struct file *file)
105 file->private_data = sd; 106 file->private_data = sd;
106 107
107 /* hook this subchannel up to the system controller interrupt */ 108 /* hook this subchannel up to the system controller interrupt */
108 lock_kernel(); 109 mutex_lock(&scdrv_mutex);
109 rv = request_irq(SGI_UART_VECTOR, scdrv_interrupt, 110 rv = request_irq(SGI_UART_VECTOR, scdrv_interrupt,
110 IRQF_SHARED | IRQF_DISABLED, 111 IRQF_SHARED | IRQF_DISABLED,
111 SYSCTL_BASENAME, sd); 112 SYSCTL_BASENAME, sd);
@@ -113,10 +114,10 @@ scdrv_open(struct inode *inode, struct file *file)
113 ia64_sn_irtr_close(sd->sd_nasid, sd->sd_subch); 114 ia64_sn_irtr_close(sd->sd_nasid, sd->sd_subch);
114 kfree(sd); 115 kfree(sd);
115 printk("%s: irq request failed (%d)\n", __func__, rv); 116 printk("%s: irq request failed (%d)\n", __func__, rv);
116 unlock_kernel(); 117 mutex_unlock(&scdrv_mutex);
117 return -EBUSY; 118 return -EBUSY;
118 } 119 }
119 unlock_kernel(); 120 mutex_unlock(&scdrv_mutex);
120 return 0; 121 return 0;
121} 122}
122 123
@@ -357,6 +358,7 @@ static const struct file_operations scdrv_fops = {
357 .poll = scdrv_poll, 358 .poll = scdrv_poll,
358 .open = scdrv_open, 359 .open = scdrv_open,
359 .release = scdrv_release, 360 .release = scdrv_release,
361 .llseek = noop_llseek,
360}; 362};
361 363
362static struct class *snsc_class; 364static struct class *snsc_class;
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index f2167f8e5aab..8ef16490810c 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -608,6 +608,7 @@ static unsigned int sc26198_baudtable[] = {
608static const struct file_operations stl_fsiomem = { 608static const struct file_operations stl_fsiomem = {
609 .owner = THIS_MODULE, 609 .owner = THIS_MODULE,
610 .unlocked_ioctl = stl_memioctl, 610 .unlocked_ioctl = stl_memioctl,
611 .llseek = noop_llseek,
611}; 612};
612 613
613static struct class *stallion_class; 614static struct class *stallion_class;
diff --git a/drivers/char/sx.c b/drivers/char/sx.c
index 5b24db4ff7f1..e53f16865397 100644
--- a/drivers/char/sx.c
+++ b/drivers/char/sx.c
@@ -397,6 +397,7 @@ static struct real_driver sx_real_driver = {
397static const struct file_operations sx_fw_fops = { 397static const struct file_operations sx_fw_fops = {
398 .owner = THIS_MODULE, 398 .owner = THIS_MODULE,
399 .unlocked_ioctl = sx_fw_ioctl, 399 .unlocked_ioctl = sx_fw_ioctl,
400 .llseek = noop_llseek,
400}; 401};
401 402
402static struct miscdevice sx_fw_device = { 403static struct miscdevice sx_fw_device = {
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c
index ef31bb81e843..f3019f53e875 100644
--- a/drivers/char/sysrq.c
+++ b/drivers/char/sysrq.c
@@ -772,6 +772,7 @@ static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
772 772
773static const struct file_operations proc_sysrq_trigger_operations = { 773static const struct file_operations proc_sysrq_trigger_operations = {
774 .write = write_sysrq_trigger, 774 .write = write_sysrq_trigger,
775 .llseek = noop_llseek,
775}; 776};
776 777
777static void sysrq_init_procfs(void) 778static void sysrq_init_procfs(void)
diff --git a/drivers/char/tb0219.c b/drivers/char/tb0219.c
index cad4eb65f13d..ad264185eb10 100644
--- a/drivers/char/tb0219.c
+++ b/drivers/char/tb0219.c
@@ -261,6 +261,7 @@ static const struct file_operations tb0219_fops = {
261 .write = tanbac_tb0219_write, 261 .write = tanbac_tb0219_write,
262 .open = tanbac_tb0219_open, 262 .open = tanbac_tb0219_open,
263 .release = tanbac_tb0219_release, 263 .release = tanbac_tb0219_release,
264 .llseek = no_llseek,
264}; 265};
265 266
266static void tb0219_restart(char *command) 267static void tb0219_restart(char *command)
diff --git a/drivers/char/tlclk.c b/drivers/char/tlclk.c
index 80ea6bcfffdc..0c964cdcc223 100644
--- a/drivers/char/tlclk.c
+++ b/drivers/char/tlclk.c
@@ -37,7 +37,7 @@
37#include <linux/ioport.h> 37#include <linux/ioport.h>
38#include <linux/interrupt.h> 38#include <linux/interrupt.h>
39#include <linux/spinlock.h> 39#include <linux/spinlock.h>
40#include <linux/smp_lock.h> 40#include <linux/mutex.h>
41#include <linux/timer.h> 41#include <linux/timer.h>
42#include <linux/sysfs.h> 42#include <linux/sysfs.h>
43#include <linux/device.h> 43#include <linux/device.h>
@@ -206,7 +206,7 @@ static int tlclk_open(struct inode *inode, struct file *filp)
206{ 206{
207 int result; 207 int result;
208 208
209 lock_kernel(); 209 mutex_lock(&tlclk_mutex);
210 if (test_and_set_bit(0, &useflags)) { 210 if (test_and_set_bit(0, &useflags)) {
211 result = -EBUSY; 211 result = -EBUSY;
212 /* this legacy device is always one per system and it doesn't 212 /* this legacy device is always one per system and it doesn't
@@ -229,7 +229,7 @@ static int tlclk_open(struct inode *inode, struct file *filp)
229 inb(TLCLK_REG6); /* Clear interrupt events */ 229 inb(TLCLK_REG6); /* Clear interrupt events */
230 230
231out: 231out:
232 unlock_kernel(); 232 mutex_unlock(&tlclk_mutex);
233 return result; 233 return result;
234} 234}
235 235
@@ -267,6 +267,7 @@ static const struct file_operations tlclk_fops = {
267 .read = tlclk_read, 267 .read = tlclk_read,
268 .open = tlclk_open, 268 .open = tlclk_open,
269 .release = tlclk_release, 269 .release = tlclk_release,
270 .llseek = noop_llseek,
270 271
271}; 272};
272 273
diff --git a/drivers/char/toshiba.c b/drivers/char/toshiba.c
index f8bc79f6de34..014c9d90d297 100644
--- a/drivers/char/toshiba.c
+++ b/drivers/char/toshiba.c
@@ -68,7 +68,7 @@
68#include <linux/stat.h> 68#include <linux/stat.h>
69#include <linux/proc_fs.h> 69#include <linux/proc_fs.h>
70#include <linux/seq_file.h> 70#include <linux/seq_file.h>
71#include <linux/smp_lock.h> 71#include <linux/mutex.h>
72#include <linux/toshiba.h> 72#include <linux/toshiba.h>
73 73
74#define TOSH_MINOR_DEV 181 74#define TOSH_MINOR_DEV 181
@@ -78,6 +78,7 @@ MODULE_AUTHOR("Jonathan Buzzard <jonathan@buzzard.org.uk>");
78MODULE_DESCRIPTION("Toshiba laptop SMM driver"); 78MODULE_DESCRIPTION("Toshiba laptop SMM driver");
79MODULE_SUPPORTED_DEVICE("toshiba"); 79MODULE_SUPPORTED_DEVICE("toshiba");
80 80
81static DEFINE_MUTEX(tosh_mutex);
81static int tosh_fn; 82static int tosh_fn;
82module_param_named(fn, tosh_fn, int, 0); 83module_param_named(fn, tosh_fn, int, 0);
83MODULE_PARM_DESC(fn, "User specified Fn key detection port"); 84MODULE_PARM_DESC(fn, "User specified Fn key detection port");
@@ -95,6 +96,7 @@ static long tosh_ioctl(struct file *, unsigned int,
95static const struct file_operations tosh_fops = { 96static const struct file_operations tosh_fops = {
96 .owner = THIS_MODULE, 97 .owner = THIS_MODULE,
97 .unlocked_ioctl = tosh_ioctl, 98 .unlocked_ioctl = tosh_ioctl,
99 .llseek = noop_llseek,
98}; 100};
99 101
100static struct miscdevice tosh_device = { 102static struct miscdevice tosh_device = {
@@ -274,16 +276,16 @@ static long tosh_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
274 return -EINVAL; 276 return -EINVAL;
275 277
276 /* do we need to emulate the fan ? */ 278 /* do we need to emulate the fan ? */
277 lock_kernel(); 279 mutex_lock(&tosh_mutex);
278 if (tosh_fan==1) { 280 if (tosh_fan==1) {
279 if (((ax==0xf300) || (ax==0xf400)) && (bx==0x0004)) { 281 if (((ax==0xf300) || (ax==0xf400)) && (bx==0x0004)) {
280 err = tosh_emulate_fan(&regs); 282 err = tosh_emulate_fan(&regs);
281 unlock_kernel(); 283 mutex_unlock(&tosh_mutex);
282 break; 284 break;
283 } 285 }
284 } 286 }
285 err = tosh_smm(&regs); 287 err = tosh_smm(&regs);
286 unlock_kernel(); 288 mutex_unlock(&tosh_mutex);
287 break; 289 break;
288 default: 290 default:
289 return -EINVAL; 291 return -EINVAL;
diff --git a/drivers/char/uv_mmtimer.c b/drivers/char/uv_mmtimer.c
index c7072ba14f48..493b47a0d511 100644
--- a/drivers/char/uv_mmtimer.c
+++ b/drivers/char/uv_mmtimer.c
@@ -52,6 +52,7 @@ static const struct file_operations uv_mmtimer_fops = {
52 .owner = THIS_MODULE, 52 .owner = THIS_MODULE,
53 .mmap = uv_mmtimer_mmap, 53 .mmap = uv_mmtimer_mmap,
54 .unlocked_ioctl = uv_mmtimer_ioctl, 54 .unlocked_ioctl = uv_mmtimer_ioctl,
55 .llseek = noop_llseek,
55}; 56};
56 57
57/** 58/**
diff --git a/drivers/char/viotape.c b/drivers/char/viotape.c
index 42f7fa442ff8..ad6e64a2912d 100644
--- a/drivers/char/viotape.c
+++ b/drivers/char/viotape.c
@@ -46,7 +46,7 @@
46#include <linux/completion.h> 46#include <linux/completion.h>
47#include <linux/proc_fs.h> 47#include <linux/proc_fs.h>
48#include <linux/seq_file.h> 48#include <linux/seq_file.h>
49#include <linux/smp_lock.h> 49#include <linux/mutex.h>
50#include <linux/slab.h> 50#include <linux/slab.h>
51 51
52#include <asm/uaccess.h> 52#include <asm/uaccess.h>
@@ -64,6 +64,7 @@
64#define VIOTAPE_KERN_WARN KERN_WARNING "viotape: " 64#define VIOTAPE_KERN_WARN KERN_WARNING "viotape: "
65#define VIOTAPE_KERN_INFO KERN_INFO "viotape: " 65#define VIOTAPE_KERN_INFO KERN_INFO "viotape: "
66 66
67static DEFINE_MUTEX(proc_viotape_mutex);
67static int viotape_numdev; 68static int viotape_numdev;
68 69
69/* 70/*
@@ -684,9 +685,9 @@ static long viotap_unlocked_ioctl(struct file *file,
684{ 685{
685 long rc; 686 long rc;
686 687
687 lock_kernel(); 688 mutex_lock(&proc_viotape_mutex);
688 rc = viotap_ioctl(file->f_path.dentry->d_inode, file, cmd, arg); 689 rc = viotap_ioctl(file->f_path.dentry->d_inode, file, cmd, arg);
689 unlock_kernel(); 690 mutex_unlock(&proc_viotape_mutex);
690 return rc; 691 return rc;
691} 692}
692 693
@@ -700,7 +701,7 @@ static int viotap_open(struct inode *inode, struct file *file)
700 if (op == NULL) 701 if (op == NULL)
701 return -ENOMEM; 702 return -ENOMEM;
702 703
703 lock_kernel(); 704 mutex_lock(&proc_viotape_mutex);
704 get_dev_info(file->f_path.dentry->d_inode, &devi); 705 get_dev_info(file->f_path.dentry->d_inode, &devi);
705 706
706 /* Note: We currently only support one mode! */ 707 /* Note: We currently only support one mode! */
@@ -731,7 +732,7 @@ static int viotap_open(struct inode *inode, struct file *file)
731 732
732free_op: 733free_op:
733 free_op_struct(op); 734 free_op_struct(op);
734 unlock_kernel(); 735 mutex_unlock(&proc_viotape_mutex);
735 return ret; 736 return ret;
736} 737}
737 738
@@ -804,6 +805,7 @@ const struct file_operations viotap_fops = {
804 .unlocked_ioctl = viotap_unlocked_ioctl, 805 .unlocked_ioctl = viotap_unlocked_ioctl,
805 .open = viotap_open, 806 .open = viotap_open,
806 .release = viotap_release, 807 .release = viotap_release,
808 .llseek = noop_llseek,
807}; 809};
808 810
809/* Handle interrupt events for tape */ 811/* Handle interrupt events for tape */
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
index b663d573aad9..9f2272e6de1c 100644
--- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c
+++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
@@ -81,7 +81,6 @@
81#include <linux/poll.h> 81#include <linux/poll.h>
82#include <linux/proc_fs.h> 82#include <linux/proc_fs.h>
83#include <linux/mutex.h> 83#include <linux/mutex.h>
84#include <linux/smp_lock.h>
85#include <linux/sysctl.h> 84#include <linux/sysctl.h>
86#include <linux/fs.h> 85#include <linux/fs.h>
87#include <linux/cdev.h> 86#include <linux/cdev.h>
@@ -112,6 +111,7 @@
112#define HWICAP_DEVICES 1 111#define HWICAP_DEVICES 1
113 112
114/* An array, which is set to true when the device is registered. */ 113/* An array, which is set to true when the device is registered. */
114static DEFINE_MUTEX(hwicap_mutex);
115static bool probed_devices[HWICAP_DEVICES]; 115static bool probed_devices[HWICAP_DEVICES];
116static struct mutex icap_sem; 116static struct mutex icap_sem;
117 117
@@ -502,7 +502,7 @@ static int hwicap_open(struct inode *inode, struct file *file)
502 struct hwicap_drvdata *drvdata; 502 struct hwicap_drvdata *drvdata;
503 int status; 503 int status;
504 504
505 lock_kernel(); 505 mutex_lock(&hwicap_mutex);
506 drvdata = container_of(inode->i_cdev, struct hwicap_drvdata, cdev); 506 drvdata = container_of(inode->i_cdev, struct hwicap_drvdata, cdev);
507 507
508 status = mutex_lock_interruptible(&drvdata->sem); 508 status = mutex_lock_interruptible(&drvdata->sem);
@@ -528,7 +528,7 @@ static int hwicap_open(struct inode *inode, struct file *file)
528 error: 528 error:
529 mutex_unlock(&drvdata->sem); 529 mutex_unlock(&drvdata->sem);
530 out: 530 out:
531 unlock_kernel(); 531 mutex_unlock(&hwicap_mutex);
532 return status; 532 return status;
533} 533}
534 534
@@ -567,6 +567,7 @@ static const struct file_operations hwicap_fops = {
567 .read = hwicap_read, 567 .read = hwicap_read,
568 .open = hwicap_open, 568 .open = hwicap_open,
569 .release = hwicap_release, 569 .release = hwicap_release,
570 .llseek = noop_llseek,
570}; 571};
571 572
572static int __devinit hwicap_setup(struct device *dev, int id, 573static int __devinit hwicap_setup(struct device *dev, int id,
diff --git a/drivers/dma/coh901318.c b/drivers/dma/coh901318.c
index 557e2272e5b3..ae2b8714d190 100644
--- a/drivers/dma/coh901318.c
+++ b/drivers/dma/coh901318.c
@@ -157,6 +157,7 @@ static const struct file_operations coh901318_debugfs_status_operations = {
157 .owner = THIS_MODULE, 157 .owner = THIS_MODULE,
158 .open = coh901318_debugfs_open, 158 .open = coh901318_debugfs_open,
159 .read = coh901318_debugfs_read, 159 .read = coh901318_debugfs_read,
160 .llseek = default_llseek,
160}; 161};
161 162
162 163
diff --git a/drivers/firewire/nosy.c b/drivers/firewire/nosy.c
index 8528b10763ed..bf184fb59a5e 100644
--- a/drivers/firewire/nosy.c
+++ b/drivers/firewire/nosy.c
@@ -405,6 +405,7 @@ static const struct file_operations nosy_ops = {
405 .poll = nosy_poll, 405 .poll = nosy_poll,
406 .open = nosy_open, 406 .open = nosy_open,
407 .release = nosy_release, 407 .release = nosy_release,
408 .llseek = noop_llseek,
408}; 409};
409 410
410#define PHY_PACKET_SIZE 12 /* 1 payload, 1 inverse, 1 ack = 3 quadlets */ 411#define PHY_PACKET_SIZE 12 /* 1 payload, 1 inverse, 1 ack = 3 quadlets */
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 4cab0c6397e3..7af443672626 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -73,7 +73,8 @@ source "drivers/gpu/drm/radeon/Kconfig"
73 73
74config DRM_I810 74config DRM_I810
75 tristate "Intel I810" 75 tristate "Intel I810"
76 depends on DRM && AGP && AGP_INTEL 76 # BKL usage in order to avoid AB-BA deadlocks, may become BROKEN_ON_SMP
77 depends on DRM && AGP && AGP_INTEL && BKL
77 help 78 help
78 Choose this option if you have an Intel I810 graphics card. If M is 79 Choose this option if you have an Intel I810 graphics card. If M is
79 selected, the module will be called i810. AGP support is required 80 selected, the module will be called i810. AGP support is required
@@ -86,6 +87,8 @@ choice
86 87
87config DRM_I830 88config DRM_I830
88 tristate "i830 driver" 89 tristate "i830 driver"
90 # BKL usage in order to avoid AB-BA deadlocks, i830 may get removed
91 depends on BKL
89 help 92 help
90 Choose this option if you have a system that has Intel 830M, 845G, 93 Choose this option if you have a system that has Intel 830M, 845G,
91 852GM, 855GM or 865G integrated graphics. If M is selected, the 94 852GM, 855GM or 865G integrated graphics. If M is selected, the
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 84da748555bc..ff6690f4fc87 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -284,7 +284,8 @@ EXPORT_SYMBOL(drm_exit);
284/** File operations structure */ 284/** File operations structure */
285static const struct file_operations drm_stub_fops = { 285static const struct file_operations drm_stub_fops = {
286 .owner = THIS_MODULE, 286 .owner = THIS_MODULE,
287 .open = drm_stub_open 287 .open = drm_stub_open,
288 .llseek = noop_llseek,
288}; 289};
289 290
290static int __init drm_core_init(void) 291static int __init drm_core_init(void)
diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
index fb07e73581e8..ff33e53bbbf8 100644
--- a/drivers/gpu/drm/i810/i810_dma.c
+++ b/drivers/gpu/drm/i810/i810_dma.c
@@ -119,6 +119,7 @@ static const struct file_operations i810_buffer_fops = {
119 .unlocked_ioctl = i810_ioctl, 119 .unlocked_ioctl = i810_ioctl,
120 .mmap = i810_mmap_buffers, 120 .mmap = i810_mmap_buffers,
121 .fasync = drm_fasync, 121 .fasync = drm_fasync,
122 .llseek = noop_llseek,
122}; 123};
123 124
124static int i810_map_buffer(struct drm_buf *buf, struct drm_file *file_priv) 125static int i810_map_buffer(struct drm_buf *buf, struct drm_file *file_priv)
diff --git a/drivers/gpu/drm/i810/i810_drv.c b/drivers/gpu/drm/i810/i810_drv.c
index b4250b2cac1f..fe69914ce507 100644
--- a/drivers/gpu/drm/i810/i810_drv.c
+++ b/drivers/gpu/drm/i810/i810_drv.c
@@ -63,6 +63,7 @@ static struct drm_driver driver = {
63 .mmap = drm_mmap, 63 .mmap = drm_mmap,
64 .poll = drm_poll, 64 .poll = drm_poll,
65 .fasync = drm_fasync, 65 .fasync = drm_fasync,
66 .llseek = noop_llseek,
66 }, 67 },
67 68
68 .pci_driver = { 69 .pci_driver = {
diff --git a/drivers/gpu/drm/i830/i830_dma.c b/drivers/gpu/drm/i830/i830_dma.c
index cc92c7e6236f..ca6f31ff0eec 100644
--- a/drivers/gpu/drm/i830/i830_dma.c
+++ b/drivers/gpu/drm/i830/i830_dma.c
@@ -121,6 +121,7 @@ static const struct file_operations i830_buffer_fops = {
121 .unlocked_ioctl = i830_ioctl, 121 .unlocked_ioctl = i830_ioctl,
122 .mmap = i830_mmap_buffers, 122 .mmap = i830_mmap_buffers,
123 .fasync = drm_fasync, 123 .fasync = drm_fasync,
124 .llseek = noop_llseek,
124}; 125};
125 126
126static int i830_map_buffer(struct drm_buf *buf, struct drm_file *file_priv) 127static int i830_map_buffer(struct drm_buf *buf, struct drm_file *file_priv)
diff --git a/drivers/gpu/drm/i830/i830_drv.c b/drivers/gpu/drm/i830/i830_drv.c
index a5c66aa82f0c..5b6298b24e24 100644
--- a/drivers/gpu/drm/i830/i830_drv.c
+++ b/drivers/gpu/drm/i830/i830_drv.c
@@ -74,6 +74,7 @@ static struct drm_driver driver = {
74 .mmap = drm_mmap, 74 .mmap = drm_mmap,
75 .poll = drm_poll, 75 .poll = drm_poll,
76 .fasync = drm_fasync, 76 .fasync = drm_fasync,
77 .llseek = noop_llseek,
77 }, 78 },
78 79
79 .pci_driver = { 80 .pci_driver = {
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 5e43d7076789..048149748fdc 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -782,6 +782,7 @@ static const struct file_operations i915_wedged_fops = {
782 .open = i915_wedged_open, 782 .open = i915_wedged_open,
783 .read = i915_wedged_read, 783 .read = i915_wedged_read,
784 .write = i915_wedged_write, 784 .write = i915_wedged_write,
785 .llseek = default_llseek,
785}; 786};
786 787
787/* As the drm_debugfs_init() routines are called before dev->dev_private is 788/* As the drm_debugfs_init() routines are called before dev->dev_private is
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 6dbe14cc4f74..895ab896e336 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -548,6 +548,7 @@ static struct drm_driver driver = {
548#ifdef CONFIG_COMPAT 548#ifdef CONFIG_COMPAT
549 .compat_ioctl = i915_compat_ioctl, 549 .compat_ioctl = i915_compat_ioctl,
550#endif 550#endif
551 .llseek = noop_llseek,
551 }, 552 },
552 553
553 .pci_driver = { 554 .pci_driver = {
diff --git a/drivers/gpu/drm/mga/mga_drv.c b/drivers/gpu/drm/mga/mga_drv.c
index 26d0d8ced80d..ac64f0b0392e 100644
--- a/drivers/gpu/drm/mga/mga_drv.c
+++ b/drivers/gpu/drm/mga/mga_drv.c
@@ -75,6 +75,7 @@ static struct drm_driver driver = {
75#ifdef CONFIG_COMPAT 75#ifdef CONFIG_COMPAT
76 .compat_ioctl = mga_compat_ioctl, 76 .compat_ioctl = mga_compat_ioctl,
77#endif 77#endif
78 .llseek = noop_llseek,
78 }, 79 },
79 .pci_driver = { 80 .pci_driver = {
80 .name = DRIVER_NAME, 81 .name = DRIVER_NAME,
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.c b/drivers/gpu/drm/nouveau/nouveau_drv.c
index 1de5eb53e016..eb15345162a0 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.c
@@ -393,6 +393,7 @@ static struct drm_driver driver = {
393#if defined(CONFIG_COMPAT) 393#if defined(CONFIG_COMPAT)
394 .compat_ioctl = nouveau_compat_ioctl, 394 .compat_ioctl = nouveau_compat_ioctl,
395#endif 395#endif
396 .llseek = noop_llseek,
396 }, 397 },
397 .pci_driver = { 398 .pci_driver = {
398 .name = DRIVER_NAME, 399 .name = DRIVER_NAME,
diff --git a/drivers/gpu/drm/r128/r128_drv.c b/drivers/gpu/drm/r128/r128_drv.c
index 1e2971f13aa1..d42c76c23714 100644
--- a/drivers/gpu/drm/r128/r128_drv.c
+++ b/drivers/gpu/drm/r128/r128_drv.c
@@ -71,6 +71,7 @@ static struct drm_driver driver = {
71#ifdef CONFIG_COMPAT 71#ifdef CONFIG_COMPAT
72 .compat_ioctl = r128_compat_ioctl, 72 .compat_ioctl = r128_compat_ioctl,
73#endif 73#endif
74 .llseek = noop_llseek,
74 }, 75 },
75 .pci_driver = { 76 .pci_driver = {
76 .name = DRIVER_NAME, 77 .name = DRIVER_NAME,
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 795403b0e2cd..29c1237c2e7b 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -219,6 +219,7 @@ static struct drm_driver driver_old = {
219#ifdef CONFIG_COMPAT 219#ifdef CONFIG_COMPAT
220 .compat_ioctl = radeon_compat_ioctl, 220 .compat_ioctl = radeon_compat_ioctl,
221#endif 221#endif
222 .llseek = noop_llseek,
222 }, 223 },
223 224
224 .pci_driver = { 225 .pci_driver = {
diff --git a/drivers/gpu/drm/savage/savage_drv.c b/drivers/gpu/drm/savage/savage_drv.c
index 021de44c15ab..2a2830f5a840 100644
--- a/drivers/gpu/drm/savage/savage_drv.c
+++ b/drivers/gpu/drm/savage/savage_drv.c
@@ -54,6 +54,7 @@ static struct drm_driver driver = {
54 .mmap = drm_mmap, 54 .mmap = drm_mmap,
55 .poll = drm_poll, 55 .poll = drm_poll,
56 .fasync = drm_fasync, 56 .fasync = drm_fasync,
57 .llseek = noop_llseek,
57 }, 58 },
58 59
59 .pci_driver = { 60 .pci_driver = {
diff --git a/drivers/gpu/drm/sis/sis_drv.c b/drivers/gpu/drm/sis/sis_drv.c
index 776bf9e9ea1a..4bb10ef6676a 100644
--- a/drivers/gpu/drm/sis/sis_drv.c
+++ b/drivers/gpu/drm/sis/sis_drv.c
@@ -83,6 +83,7 @@ static struct drm_driver driver = {
83 .mmap = drm_mmap, 83 .mmap = drm_mmap,
84 .poll = drm_poll, 84 .poll = drm_poll,
85 .fasync = drm_fasync, 85 .fasync = drm_fasync,
86 .llseek = noop_llseek,
86 }, 87 },
87 .pci_driver = { 88 .pci_driver = {
88 .name = DRIVER_NAME, 89 .name = DRIVER_NAME,
diff --git a/drivers/gpu/drm/tdfx/tdfx_drv.c b/drivers/gpu/drm/tdfx/tdfx_drv.c
index ec5a43e65722..640567ef713d 100644
--- a/drivers/gpu/drm/tdfx/tdfx_drv.c
+++ b/drivers/gpu/drm/tdfx/tdfx_drv.c
@@ -52,6 +52,7 @@ static struct drm_driver driver = {
52 .mmap = drm_mmap, 52 .mmap = drm_mmap,
53 .poll = drm_poll, 53 .poll = drm_poll,
54 .fasync = drm_fasync, 54 .fasync = drm_fasync,
55 .llseek = noop_llseek,
55 }, 56 },
56 .pci_driver = { 57 .pci_driver = {
57 .name = DRIVER_NAME, 58 .name = DRIVER_NAME,
diff --git a/drivers/gpu/drm/via/via_drv.c b/drivers/gpu/drm/via/via_drv.c
index 7a1b210401e0..b8984a5ae521 100644
--- a/drivers/gpu/drm/via/via_drv.c
+++ b/drivers/gpu/drm/via/via_drv.c
@@ -62,6 +62,7 @@ static struct drm_driver driver = {
62 .mmap = drm_mmap, 62 .mmap = drm_mmap,
63 .poll = drm_poll, 63 .poll = drm_poll,
64 .fasync = drm_fasync, 64 .fasync = drm_fasync,
65 .llseek = noop_llseek,
65 }, 66 },
66 .pci_driver = { 67 .pci_driver = {
67 .name = DRIVER_NAME, 68 .name = DRIVER_NAME,
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index a96ed6d9d010..2ef93df9e8ae 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -820,6 +820,7 @@ static struct drm_driver driver = {
820#if defined(CONFIG_COMPAT) 820#if defined(CONFIG_COMPAT)
821 .compat_ioctl = drm_compat_ioctl, 821 .compat_ioctl = drm_compat_ioctl,
822#endif 822#endif
823 .llseek = noop_llseek,
823 }, 824 },
824 .pci_driver = { 825 .pci_driver = {
825 .name = VMWGFX_DRIVER_NAME, 826 .name = VMWGFX_DRIVER_NAME,
diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c
index f366f968155a..c380c65da417 100644
--- a/drivers/gpu/vga/vgaarb.c
+++ b/drivers/gpu/vga/vgaarb.c
@@ -1211,6 +1211,7 @@ static const struct file_operations vga_arb_device_fops = {
1211 .poll = vga_arb_fpoll, 1211 .poll = vga_arb_fpoll,
1212 .open = vga_arb_open, 1212 .open = vga_arb_open,
1213 .release = vga_arb_release, 1213 .release = vga_arb_release,
1214 .llseek = noop_llseek,
1214}; 1215};
1215 1216
1216static struct miscdevice vga_arb_device = { 1217static struct miscdevice vga_arb_device = {
diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 850d02a7a925..61a3e572224a 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -1051,6 +1051,7 @@ static const struct file_operations hid_debug_events_fops = {
1051 .read = hid_debug_events_read, 1051 .read = hid_debug_events_read,
1052 .poll = hid_debug_events_poll, 1052 .poll = hid_debug_events_poll,
1053 .release = hid_debug_events_release, 1053 .release = hid_debug_events_release,
1054 .llseek = noop_llseek,
1054}; 1055};
1055 1056
1056 1057
diff --git a/drivers/hid/hid-roccat.c b/drivers/hid/hid-roccat.c
index f6e80c7ca61e..5a6879e235ac 100644
--- a/drivers/hid/hid-roccat.c
+++ b/drivers/hid/hid-roccat.c
@@ -384,6 +384,7 @@ static const struct file_operations roccat_ops = {
384 .poll = roccat_poll, 384 .poll = roccat_poll,
385 .open = roccat_open, 385 .open = roccat_open,
386 .release = roccat_release, 386 .release = roccat_release,
387 .llseek = noop_llseek,
387}; 388};
388 389
389static int __init roccat_init(void) 390static int __init roccat_init(void)
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index a3866b5c0c43..925992f549f0 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -340,6 +340,7 @@ static const struct file_operations hidraw_ops = {
340 .open = hidraw_open, 340 .open = hidraw_open,
341 .release = hidraw_release, 341 .release = hidraw_release,
342 .unlocked_ioctl = hidraw_ioctl, 342 .unlocked_ioctl = hidraw_ioctl,
343 .llseek = noop_llseek,
343}; 344};
344 345
345void hidraw_report_event(struct hid_device *hid, u8 *data, int len) 346void hidraw_report_event(struct hid_device *hid, u8 *data, int len)
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index 681e620eb95b..dfcb27613ec5 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -847,6 +847,7 @@ static const struct file_operations hiddev_fops = {
847#ifdef CONFIG_COMPAT 847#ifdef CONFIG_COMPAT
848 .compat_ioctl = hiddev_compat_ioctl, 848 .compat_ioctl = hiddev_compat_ioctl,
849#endif 849#endif
850 .llseek = noop_llseek,
850}; 851};
851 852
852static char *hiddev_devnode(struct device *dev, mode_t *mode) 853static char *hiddev_devnode(struct device *dev, mode_t *mode)
diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
index 653db1bda934..23b8555215d2 100644
--- a/drivers/hwmon/asus_atk0110.c
+++ b/drivers/hwmon/asus_atk0110.c
@@ -762,6 +762,7 @@ static const struct file_operations atk_debugfs_ggrp_fops = {
762 .read = atk_debugfs_ggrp_read, 762 .read = atk_debugfs_ggrp_read,
763 .open = atk_debugfs_ggrp_open, 763 .open = atk_debugfs_ggrp_open,
764 .release = atk_debugfs_ggrp_release, 764 .release = atk_debugfs_ggrp_release,
765 .llseek = no_llseek,
765}; 766};
766 767
767static void atk_debugfs_init(struct atk_data *data) 768static void atk_debugfs_init(struct atk_data *data)
diff --git a/drivers/hwmon/fschmd.c b/drivers/hwmon/fschmd.c
index b7ca2a9676cf..d4d4ca65d371 100644
--- a/drivers/hwmon/fschmd.c
+++ b/drivers/hwmon/fschmd.c
@@ -38,7 +38,6 @@
38#include <linux/i2c.h> 38#include <linux/i2c.h>
39#include <linux/hwmon.h> 39#include <linux/hwmon.h>
40#include <linux/hwmon-sysfs.h> 40#include <linux/hwmon-sysfs.h>
41#include <linux/smp_lock.h>
42#include <linux/err.h> 41#include <linux/err.h>
43#include <linux/mutex.h> 42#include <linux/mutex.h>
44#include <linux/sysfs.h> 43#include <linux/sysfs.h>
@@ -50,6 +49,7 @@
50#include <linux/kref.h> 49#include <linux/kref.h>
51 50
52/* Addresses to scan */ 51/* Addresses to scan */
52static DEFINE_MUTEX(watchdog_mutex);
53static const unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END }; 53static const unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END };
54 54
55/* Insmod parameters */ 55/* Insmod parameters */
@@ -858,7 +858,7 @@ static long watchdog_ioctl(struct file *filp, unsigned int cmd, unsigned long ar
858 int i, ret = 0; 858 int i, ret = 0;
859 struct fschmd_data *data = filp->private_data; 859 struct fschmd_data *data = filp->private_data;
860 860
861 lock_kernel(); 861 mutex_lock(&watchdog_mutex);
862 switch (cmd) { 862 switch (cmd) {
863 case WDIOC_GETSUPPORT: 863 case WDIOC_GETSUPPORT:
864 ident.firmware_version = data->revision; 864 ident.firmware_version = data->revision;
@@ -915,7 +915,7 @@ static long watchdog_ioctl(struct file *filp, unsigned int cmd, unsigned long ar
915 default: 915 default:
916 ret = -ENOTTY; 916 ret = -ENOTTY;
917 } 917 }
918 unlock_kernel(); 918 mutex_unlock(&watchdog_mutex);
919 return ret; 919 return ret;
920} 920}
921 921
diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c
index 697202e27891..8e540ada47d2 100644
--- a/drivers/hwmon/w83793.c
+++ b/drivers/hwmon/w83793.c
@@ -35,7 +35,6 @@
35#include <linux/slab.h> 35#include <linux/slab.h>
36#include <linux/i2c.h> 36#include <linux/i2c.h>
37#include <linux/hwmon.h> 37#include <linux/hwmon.h>
38#include <linux/smp_lock.h>
39#include <linux/hwmon-vid.h> 38#include <linux/hwmon-vid.h>
40#include <linux/hwmon-sysfs.h> 39#include <linux/hwmon-sysfs.h>
41#include <linux/err.h> 40#include <linux/err.h>
@@ -52,6 +51,7 @@
52#define WATCHDOG_TIMEOUT 2 /* 2 minute default timeout */ 51#define WATCHDOG_TIMEOUT 2 /* 2 minute default timeout */
53 52
54/* Addresses to scan */ 53/* Addresses to scan */
54static DEFINE_MUTEX(watchdog_mutex);
55static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, 55static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f,
56 I2C_CLIENT_END }; 56 I2C_CLIENT_END };
57 57
@@ -1333,7 +1333,7 @@ static long watchdog_ioctl(struct file *filp, unsigned int cmd,
1333 int val, ret = 0; 1333 int val, ret = 0;
1334 struct w83793_data *data = filp->private_data; 1334 struct w83793_data *data = filp->private_data;
1335 1335
1336 lock_kernel(); 1336 mutex_lock(&watchdog_mutex);
1337 switch (cmd) { 1337 switch (cmd) {
1338 case WDIOC_GETSUPPORT: 1338 case WDIOC_GETSUPPORT:
1339 if (!nowayout) 1339 if (!nowayout)
@@ -1387,7 +1387,7 @@ static long watchdog_ioctl(struct file *filp, unsigned int cmd,
1387 default: 1387 default:
1388 ret = -ENOTTY; 1388 ret = -ENOTTY;
1389 } 1389 }
1390 unlock_kernel(); 1390 mutex_unlock(&watchdog_mutex);
1391 return ret; 1391 return ret;
1392} 1392}
1393 1393
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 31fc76960a8f..0c73fe39a236 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -31,7 +31,6 @@
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/timer.h> 32#include <linux/timer.h>
33#include <linux/seq_file.h> 33#include <linux/seq_file.h>
34#include <linux/smp_lock.h>
35#include <linux/slab.h> 34#include <linux/slab.h>
36#include <linux/interrupt.h> 35#include <linux/interrupt.h>
37#include <linux/errno.h> 36#include <linux/errno.h>
@@ -52,6 +51,7 @@
52 51
53#include "ide-cd.h" 52#include "ide-cd.h"
54 53
54static DEFINE_MUTEX(ide_cd_mutex);
55static DEFINE_MUTEX(idecd_ref_mutex); 55static DEFINE_MUTEX(idecd_ref_mutex);
56 56
57static void ide_cd_release(struct device *); 57static void ide_cd_release(struct device *);
@@ -1602,7 +1602,7 @@ static int idecd_open(struct block_device *bdev, fmode_t mode)
1602 struct cdrom_info *info; 1602 struct cdrom_info *info;
1603 int rc = -ENXIO; 1603 int rc = -ENXIO;
1604 1604
1605 lock_kernel(); 1605 mutex_lock(&ide_cd_mutex);
1606 info = ide_cd_get(bdev->bd_disk); 1606 info = ide_cd_get(bdev->bd_disk);
1607 if (!info) 1607 if (!info)
1608 goto out; 1608 goto out;
@@ -1611,7 +1611,7 @@ static int idecd_open(struct block_device *bdev, fmode_t mode)
1611 if (rc < 0) 1611 if (rc < 0)
1612 ide_cd_put(info); 1612 ide_cd_put(info);
1613out: 1613out:
1614 unlock_kernel(); 1614 mutex_unlock(&ide_cd_mutex);
1615 return rc; 1615 return rc;
1616} 1616}
1617 1617
@@ -1619,11 +1619,11 @@ static int idecd_release(struct gendisk *disk, fmode_t mode)
1619{ 1619{
1620 struct cdrom_info *info = ide_drv_g(disk, cdrom_info); 1620 struct cdrom_info *info = ide_drv_g(disk, cdrom_info);
1621 1621
1622 lock_kernel(); 1622 mutex_lock(&ide_cd_mutex);
1623 cdrom_release(&info->devinfo, mode); 1623 cdrom_release(&info->devinfo, mode);
1624 1624
1625 ide_cd_put(info); 1625 ide_cd_put(info);
1626 unlock_kernel(); 1626 mutex_unlock(&ide_cd_mutex);
1627 1627
1628 return 0; 1628 return 0;
1629} 1629}
@@ -1694,9 +1694,9 @@ static int idecd_ioctl(struct block_device *bdev, fmode_t mode,
1694{ 1694{
1695 int ret; 1695 int ret;
1696 1696
1697 lock_kernel(); 1697 mutex_lock(&ide_cd_mutex);
1698 ret = idecd_locked_ioctl(bdev, mode, cmd, arg); 1698 ret = idecd_locked_ioctl(bdev, mode, cmd, arg);
1699 unlock_kernel(); 1699 mutex_unlock(&ide_cd_mutex);
1700 1700
1701 return ret; 1701 return ret;
1702} 1702}
diff --git a/drivers/ide/ide-disk_ioctl.c b/drivers/ide/ide-disk_ioctl.c
index ec94c66918f6..da36f729ff32 100644
--- a/drivers/ide/ide-disk_ioctl.c
+++ b/drivers/ide/ide-disk_ioctl.c
@@ -1,10 +1,11 @@
1#include <linux/kernel.h> 1#include <linux/kernel.h>
2#include <linux/ide.h> 2#include <linux/ide.h>
3#include <linux/hdreg.h> 3#include <linux/hdreg.h>
4#include <linux/smp_lock.h> 4#include <linux/mutex.h>
5 5
6#include "ide-disk.h" 6#include "ide-disk.h"
7 7
8static DEFINE_MUTEX(ide_disk_ioctl_mutex);
8static const struct ide_ioctl_devset ide_disk_ioctl_settings[] = { 9static const struct ide_ioctl_devset ide_disk_ioctl_settings[] = {
9{ HDIO_GET_ADDRESS, HDIO_SET_ADDRESS, &ide_devset_address }, 10{ HDIO_GET_ADDRESS, HDIO_SET_ADDRESS, &ide_devset_address },
10{ HDIO_GET_MULTCOUNT, HDIO_SET_MULTCOUNT, &ide_devset_multcount }, 11{ HDIO_GET_MULTCOUNT, HDIO_SET_MULTCOUNT, &ide_devset_multcount },
@@ -19,13 +20,13 @@ int ide_disk_ioctl(ide_drive_t *drive, struct block_device *bdev, fmode_t mode,
19{ 20{
20 int err; 21 int err;
21 22
22 lock_kernel(); 23 mutex_lock(&ide_disk_ioctl_mutex);
23 err = ide_setting_ioctl(drive, bdev, cmd, arg, ide_disk_ioctl_settings); 24 err = ide_setting_ioctl(drive, bdev, cmd, arg, ide_disk_ioctl_settings);
24 if (err != -EOPNOTSUPP) 25 if (err != -EOPNOTSUPP)
25 goto out; 26 goto out;
26 27
27 err = generic_ide_ioctl(drive, bdev, cmd, arg); 28 err = generic_ide_ioctl(drive, bdev, cmd, arg);
28out: 29out:
29 unlock_kernel(); 30 mutex_unlock(&ide_disk_ioctl_mutex);
30 return err; 31 return err;
31} 32}
diff --git a/drivers/ide/ide-floppy_ioctl.c b/drivers/ide/ide-floppy_ioctl.c
index fd3d05ab3417..d267b7affad6 100644
--- a/drivers/ide/ide-floppy_ioctl.c
+++ b/drivers/ide/ide-floppy_ioctl.c
@@ -5,7 +5,7 @@
5#include <linux/kernel.h> 5#include <linux/kernel.h>
6#include <linux/ide.h> 6#include <linux/ide.h>
7#include <linux/cdrom.h> 7#include <linux/cdrom.h>
8#include <linux/smp_lock.h> 8#include <linux/mutex.h>
9 9
10#include <asm/unaligned.h> 10#include <asm/unaligned.h>
11 11
@@ -32,6 +32,7 @@
32 * On exit we set nformats to the number of records we've actually initialized. 32 * On exit we set nformats to the number of records we've actually initialized.
33 */ 33 */
34 34
35static DEFINE_MUTEX(ide_floppy_ioctl_mutex);
35static int ide_floppy_get_format_capacities(ide_drive_t *drive, 36static int ide_floppy_get_format_capacities(ide_drive_t *drive,
36 struct ide_atapi_pc *pc, 37 struct ide_atapi_pc *pc,
37 int __user *arg) 38 int __user *arg)
@@ -276,7 +277,7 @@ int ide_floppy_ioctl(ide_drive_t *drive, struct block_device *bdev,
276 void __user *argp = (void __user *)arg; 277 void __user *argp = (void __user *)arg;
277 int err; 278 int err;
278 279
279 lock_kernel(); 280 mutex_lock(&ide_floppy_ioctl_mutex);
280 if (cmd == CDROMEJECT || cmd == CDROM_LOCKDOOR) { 281 if (cmd == CDROMEJECT || cmd == CDROM_LOCKDOOR) {
281 err = ide_floppy_lockdoor(drive, &pc, arg, cmd); 282 err = ide_floppy_lockdoor(drive, &pc, arg, cmd);
282 goto out; 283 goto out;
@@ -298,6 +299,6 @@ int ide_floppy_ioctl(ide_drive_t *drive, struct block_device *bdev,
298 err = generic_ide_ioctl(drive, bdev, cmd, arg); 299 err = generic_ide_ioctl(drive, bdev, cmd, arg);
299 300
300out: 301out:
301 unlock_kernel(); 302 mutex_unlock(&ide_floppy_ioctl_mutex);
302 return err; 303 return err;
303} 304}
diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c
index 70aeeb18833e..35c4b43585e3 100644
--- a/drivers/ide/ide-gd.c
+++ b/drivers/ide/ide-gd.c
@@ -1,4 +1,3 @@
1#include <linux/smp_lock.h>
2#include <linux/module.h> 1#include <linux/module.h>
3#include <linux/types.h> 2#include <linux/types.h>
4#include <linux/string.h> 3#include <linux/string.h>
@@ -23,6 +22,7 @@
23#define IDE_GD_VERSION "1.18" 22#define IDE_GD_VERSION "1.18"
24 23
25/* module parameters */ 24/* module parameters */
25static DEFINE_MUTEX(ide_gd_mutex);
26static unsigned long debug_mask; 26static unsigned long debug_mask;
27module_param(debug_mask, ulong, 0644); 27module_param(debug_mask, ulong, 0644);
28 28
@@ -242,9 +242,9 @@ static int ide_gd_unlocked_open(struct block_device *bdev, fmode_t mode)
242{ 242{
243 int ret; 243 int ret;
244 244
245 lock_kernel(); 245 mutex_lock(&ide_gd_mutex);
246 ret = ide_gd_open(bdev, mode); 246 ret = ide_gd_open(bdev, mode);
247 unlock_kernel(); 247 mutex_unlock(&ide_gd_mutex);
248 248
249 return ret; 249 return ret;
250} 250}
@@ -257,7 +257,7 @@ static int ide_gd_release(struct gendisk *disk, fmode_t mode)
257 257
258 ide_debug_log(IDE_DBG_FUNC, "enter"); 258 ide_debug_log(IDE_DBG_FUNC, "enter");
259 259
260 lock_kernel(); 260 mutex_lock(&ide_gd_mutex);
261 if (idkp->openers == 1) 261 if (idkp->openers == 1)
262 drive->disk_ops->flush(drive); 262 drive->disk_ops->flush(drive);
263 263
@@ -269,7 +269,7 @@ static int ide_gd_release(struct gendisk *disk, fmode_t mode)
269 idkp->openers--; 269 idkp->openers--;
270 270
271 ide_disk_put(idkp); 271 ide_disk_put(idkp);
272 unlock_kernel(); 272 mutex_unlock(&ide_gd_mutex);
273 273
274 return 0; 274 return 0;
275} 275}
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 6d622cb5ac81..7ecb1ade8874 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -32,11 +32,9 @@
32#include <linux/errno.h> 32#include <linux/errno.h>
33#include <linux/genhd.h> 33#include <linux/genhd.h>
34#include <linux/seq_file.h> 34#include <linux/seq_file.h>
35#include <linux/smp_lock.h>
36#include <linux/slab.h> 35#include <linux/slab.h>
37#include <linux/pci.h> 36#include <linux/pci.h>
38#include <linux/ide.h> 37#include <linux/ide.h>
39#include <linux/smp_lock.h>
40#include <linux/completion.h> 38#include <linux/completion.h>
41#include <linux/bitops.h> 39#include <linux/bitops.h>
42#include <linux/mutex.h> 40#include <linux/mutex.h>
@@ -220,6 +218,7 @@ typedef struct ide_tape_obj {
220 char write_prot; 218 char write_prot;
221} idetape_tape_t; 219} idetape_tape_t;
222 220
221static DEFINE_MUTEX(ide_tape_mutex);
223static DEFINE_MUTEX(idetape_ref_mutex); 222static DEFINE_MUTEX(idetape_ref_mutex);
224 223
225static DEFINE_MUTEX(idetape_chrdev_mutex); 224static DEFINE_MUTEX(idetape_chrdev_mutex);
@@ -1426,9 +1425,9 @@ static long idetape_chrdev_ioctl(struct file *file,
1426 unsigned int cmd, unsigned long arg) 1425 unsigned int cmd, unsigned long arg)
1427{ 1426{
1428 long ret; 1427 long ret;
1429 lock_kernel(); 1428 mutex_lock(&ide_tape_mutex);
1430 ret = do_idetape_chrdev_ioctl(file, cmd, arg); 1429 ret = do_idetape_chrdev_ioctl(file, cmd, arg);
1431 unlock_kernel(); 1430 mutex_unlock(&ide_tape_mutex);
1432 return ret; 1431 return ret;
1433} 1432}
1434 1433
@@ -1903,15 +1902,16 @@ static const struct file_operations idetape_fops = {
1903 .unlocked_ioctl = idetape_chrdev_ioctl, 1902 .unlocked_ioctl = idetape_chrdev_ioctl,
1904 .open = idetape_chrdev_open, 1903 .open = idetape_chrdev_open,
1905 .release = idetape_chrdev_release, 1904 .release = idetape_chrdev_release,
1905 .llseek = noop_llseek,
1906}; 1906};
1907 1907
1908static int idetape_open(struct block_device *bdev, fmode_t mode) 1908static int idetape_open(struct block_device *bdev, fmode_t mode)
1909{ 1909{
1910 struct ide_tape_obj *tape; 1910 struct ide_tape_obj *tape;
1911 1911
1912 lock_kernel(); 1912 mutex_lock(&ide_tape_mutex);
1913 tape = ide_tape_get(bdev->bd_disk, false, 0); 1913 tape = ide_tape_get(bdev->bd_disk, false, 0);
1914 unlock_kernel(); 1914 mutex_unlock(&ide_tape_mutex);
1915 1915
1916 if (!tape) 1916 if (!tape)
1917 return -ENXIO; 1917 return -ENXIO;
@@ -1923,9 +1923,9 @@ static int idetape_release(struct gendisk *disk, fmode_t mode)
1923{ 1923{
1924 struct ide_tape_obj *tape = ide_drv_g(disk, ide_tape_obj); 1924 struct ide_tape_obj *tape = ide_drv_g(disk, ide_tape_obj);
1925 1925
1926 lock_kernel(); 1926 mutex_lock(&ide_tape_mutex);
1927 ide_tape_put(tape); 1927 ide_tape_put(tape);
1928 unlock_kernel(); 1928 mutex_unlock(&ide_tape_mutex);
1929 1929
1930 return 0; 1930 return 0;
1931} 1931}
@@ -1937,11 +1937,11 @@ static int idetape_ioctl(struct block_device *bdev, fmode_t mode,
1937 ide_drive_t *drive = tape->drive; 1937 ide_drive_t *drive = tape->drive;
1938 int err; 1938 int err;
1939 1939
1940 lock_kernel(); 1940 mutex_lock(&ide_tape_mutex);
1941 err = generic_ide_ioctl(drive, bdev, cmd, arg); 1941 err = generic_ide_ioctl(drive, bdev, cmd, arg);
1942 if (err == -EINVAL) 1942 if (err == -EINVAL)
1943 err = idetape_blkdev_ioctl(drive, cmd, arg); 1943 err = idetape_blkdev_ioctl(drive, cmd, arg);
1944 unlock_kernel(); 1944 mutex_unlock(&ide_tape_mutex);
1945 1945
1946 return err; 1946 return err;
1947} 1947}
diff --git a/drivers/idle/i7300_idle.c b/drivers/idle/i7300_idle.c
index 15341fc1c68b..c976285d313e 100644
--- a/drivers/idle/i7300_idle.c
+++ b/drivers/idle/i7300_idle.c
@@ -536,6 +536,7 @@ static ssize_t stats_read_ul(struct file *fp, char __user *ubuf, size_t count,
536static const struct file_operations idle_fops = { 536static const struct file_operations idle_fops = {
537 .open = stats_open_generic, 537 .open = stats_open_generic,
538 .read = stats_read_ul, 538 .read = stats_read_ul,
539 .llseek = default_llseek,
539}; 540};
540 541
541struct debugfs_file_info { 542struct debugfs_file_info {
diff --git a/drivers/infiniband/hw/ipath/ipath_diag.c b/drivers/infiniband/hw/ipath/ipath_diag.c
index d4ce8b63e19e..daef61d5e5bb 100644
--- a/drivers/infiniband/hw/ipath/ipath_diag.c
+++ b/drivers/infiniband/hw/ipath/ipath_diag.c
@@ -65,7 +65,8 @@ static const struct file_operations diag_file_ops = {
65 .write = ipath_diag_write, 65 .write = ipath_diag_write,
66 .read = ipath_diag_read, 66 .read = ipath_diag_read,
67 .open = ipath_diag_open, 67 .open = ipath_diag_open,
68 .release = ipath_diag_release 68 .release = ipath_diag_release,
69 .llseek = default_llseek,
69}; 70};
70 71
71static ssize_t ipath_diagpkt_write(struct file *fp, 72static ssize_t ipath_diagpkt_write(struct file *fp,
@@ -75,6 +76,7 @@ static ssize_t ipath_diagpkt_write(struct file *fp,
75static const struct file_operations diagpkt_file_ops = { 76static const struct file_operations diagpkt_file_ops = {
76 .owner = THIS_MODULE, 77 .owner = THIS_MODULE,
77 .write = ipath_diagpkt_write, 78 .write = ipath_diagpkt_write,
79 .llseek = noop_llseek,
78}; 80};
79 81
80static atomic_t diagpkt_count = ATOMIC_INIT(0); 82static atomic_t diagpkt_count = ATOMIC_INIT(0);
diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c
index 65eb8929db22..6078992da3f0 100644
--- a/drivers/infiniband/hw/ipath/ipath_file_ops.c
+++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c
@@ -63,7 +63,8 @@ static const struct file_operations ipath_file_ops = {
63 .open = ipath_open, 63 .open = ipath_open,
64 .release = ipath_close, 64 .release = ipath_close,
65 .poll = ipath_poll, 65 .poll = ipath_poll,
66 .mmap = ipath_mmap 66 .mmap = ipath_mmap,
67 .llseek = noop_llseek,
67}; 68};
68 69
69/* 70/*
diff --git a/drivers/infiniband/hw/ipath/ipath_fs.c b/drivers/infiniband/hw/ipath/ipath_fs.c
index 2fca70836dae..d13e72685dcf 100644
--- a/drivers/infiniband/hw/ipath/ipath_fs.c
+++ b/drivers/infiniband/hw/ipath/ipath_fs.c
@@ -103,6 +103,7 @@ static ssize_t atomic_stats_read(struct file *file, char __user *buf,
103 103
104static const struct file_operations atomic_stats_ops = { 104static const struct file_operations atomic_stats_ops = {
105 .read = atomic_stats_read, 105 .read = atomic_stats_read,
106 .llseek = default_llseek,
106}; 107};
107 108
108static ssize_t atomic_counters_read(struct file *file, char __user *buf, 109static ssize_t atomic_counters_read(struct file *file, char __user *buf,
@@ -120,6 +121,7 @@ static ssize_t atomic_counters_read(struct file *file, char __user *buf,
120 121
121static const struct file_operations atomic_counters_ops = { 122static const struct file_operations atomic_counters_ops = {
122 .read = atomic_counters_read, 123 .read = atomic_counters_read,
124 .llseek = default_llseek,
123}; 125};
124 126
125static ssize_t flash_read(struct file *file, char __user *buf, 127static ssize_t flash_read(struct file *file, char __user *buf,
@@ -224,6 +226,7 @@ bail:
224static const struct file_operations flash_ops = { 226static const struct file_operations flash_ops = {
225 .read = flash_read, 227 .read = flash_read,
226 .write = flash_write, 228 .write = flash_write,
229 .llseek = default_llseek,
227}; 230};
228 231
229static int create_device_files(struct super_block *sb, 232static int create_device_files(struct super_block *sb,
diff --git a/drivers/infiniband/hw/qib/qib_diag.c b/drivers/infiniband/hw/qib/qib_diag.c
index 05dcf0d9a7d3..204c4dd9dce0 100644
--- a/drivers/infiniband/hw/qib/qib_diag.c
+++ b/drivers/infiniband/hw/qib/qib_diag.c
@@ -136,7 +136,8 @@ static const struct file_operations diag_file_ops = {
136 .write = qib_diag_write, 136 .write = qib_diag_write,
137 .read = qib_diag_read, 137 .read = qib_diag_read,
138 .open = qib_diag_open, 138 .open = qib_diag_open,
139 .release = qib_diag_release 139 .release = qib_diag_release,
140 .llseek = default_llseek,
140}; 141};
141 142
142static atomic_t diagpkt_count = ATOMIC_INIT(0); 143static atomic_t diagpkt_count = ATOMIC_INIT(0);
@@ -149,6 +150,7 @@ static ssize_t qib_diagpkt_write(struct file *fp, const char __user *data,
149static const struct file_operations diagpkt_file_ops = { 150static const struct file_operations diagpkt_file_ops = {
150 .owner = THIS_MODULE, 151 .owner = THIS_MODULE,
151 .write = qib_diagpkt_write, 152 .write = qib_diagpkt_write,
153 .llseek = noop_llseek,
152}; 154};
153 155
154int qib_diag_add(struct qib_devdata *dd) 156int qib_diag_add(struct qib_devdata *dd)
diff --git a/drivers/infiniband/hw/qib/qib_file_ops.c b/drivers/infiniband/hw/qib/qib_file_ops.c
index 6b11645edf35..aa2be214270f 100644
--- a/drivers/infiniband/hw/qib/qib_file_ops.c
+++ b/drivers/infiniband/hw/qib/qib_file_ops.c
@@ -63,7 +63,8 @@ static const struct file_operations qib_file_ops = {
63 .open = qib_open, 63 .open = qib_open,
64 .release = qib_close, 64 .release = qib_close,
65 .poll = qib_poll, 65 .poll = qib_poll,
66 .mmap = qib_mmapf 66 .mmap = qib_mmapf,
67 .llseek = noop_llseek,
67}; 68};
68 69
69/* 70/*
diff --git a/drivers/infiniband/hw/qib/qib_fs.c b/drivers/infiniband/hw/qib/qib_fs.c
index 9f989c0ba9d3..a0e6613e8be6 100644
--- a/drivers/infiniband/hw/qib/qib_fs.c
+++ b/drivers/infiniband/hw/qib/qib_fs.c
@@ -367,6 +367,7 @@ bail:
367static const struct file_operations flash_ops = { 367static const struct file_operations flash_ops = {
368 .read = flash_read, 368 .read = flash_read,
369 .write = flash_write, 369 .write = flash_write,
370 .llseek = default_llseek,
370}; 371};
371 372
372static int add_cntr_files(struct super_block *sb, struct qib_devdata *dd) 373static int add_cntr_files(struct super_block *sb, struct qib_devdata *dd)
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index af9ee313c10b..535fea4fe67f 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -767,7 +767,8 @@ static const struct file_operations evdev_fops = {
767 .compat_ioctl = evdev_ioctl_compat, 767 .compat_ioctl = evdev_ioctl_compat,
768#endif 768#endif
769 .fasync = evdev_fasync, 769 .fasync = evdev_fasync,
770 .flush = evdev_flush 770 .flush = evdev_flush,
771 .llseek = no_llseek,
771}; 772};
772 773
773static int evdev_install_chrdev(struct evdev *evdev) 774static int evdev_install_chrdev(struct evdev *evdev)
diff --git a/drivers/input/input.c b/drivers/input/input.c
index ab6982056518..7919c2537225 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -2047,6 +2047,7 @@ out:
2047static const struct file_operations input_fops = { 2047static const struct file_operations input_fops = {
2048 .owner = THIS_MODULE, 2048 .owner = THIS_MODULE,
2049 .open = input_open_file, 2049 .open = input_open_file,
2050 .llseek = noop_llseek,
2050}; 2051};
2051 2052
2052static int __init input_init(void) 2053static int __init input_init(void)
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index 22239e988498..9d424cebfd2c 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -739,6 +739,7 @@ static const struct file_operations joydev_fops = {
739 .compat_ioctl = joydev_compat_ioctl, 739 .compat_ioctl = joydev_compat_ioctl,
740#endif 740#endif
741 .fasync = joydev_fasync, 741 .fasync = joydev_fasync,
742 .llseek = no_llseek,
742}; 743};
743 744
744static int joydev_install_chrdev(struct joydev *joydev) 745static int joydev_install_chrdev(struct joydev *joydev)
diff --git a/drivers/input/misc/hp_sdc_rtc.c b/drivers/input/misc/hp_sdc_rtc.c
index 7e2c12a5b839..0b4f54265f62 100644
--- a/drivers/input/misc/hp_sdc_rtc.c
+++ b/drivers/input/misc/hp_sdc_rtc.c
@@ -43,7 +43,7 @@
43#include <linux/proc_fs.h> 43#include <linux/proc_fs.h>
44#include <linux/poll.h> 44#include <linux/poll.h>
45#include <linux/rtc.h> 45#include <linux/rtc.h>
46#include <linux/smp_lock.h> 46#include <linux/mutex.h>
47#include <linux/semaphore.h> 47#include <linux/semaphore.h>
48 48
49MODULE_AUTHOR("Brian S. Julin <bri@calyx.com>"); 49MODULE_AUTHOR("Brian S. Julin <bri@calyx.com>");
@@ -52,6 +52,7 @@ MODULE_LICENSE("Dual BSD/GPL");
52 52
53#define RTC_VERSION "1.10d" 53#define RTC_VERSION "1.10d"
54 54
55static DEFINE_MUTEX(hp_sdc_rtc_mutex);
55static unsigned long epoch = 2000; 56static unsigned long epoch = 2000;
56 57
57static struct semaphore i8042tregs; 58static struct semaphore i8042tregs;
@@ -665,9 +666,9 @@ static long hp_sdc_rtc_unlocked_ioctl(struct file *file,
665{ 666{
666 int ret; 667 int ret;
667 668
668 lock_kernel(); 669 mutex_lock(&hp_sdc_rtc_mutex);
669 ret = hp_sdc_rtc_ioctl(file, cmd, arg); 670 ret = hp_sdc_rtc_ioctl(file, cmd, arg);
670 unlock_kernel(); 671 mutex_unlock(&hp_sdc_rtc_mutex);
671 672
672 return ret; 673 return ret;
673} 674}
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
index 360698553eb5..b9410784e6a1 100644
--- a/drivers/input/misc/uinput.c
+++ b/drivers/input/misc/uinput.c
@@ -811,6 +811,7 @@ static const struct file_operations uinput_fops = {
811#ifdef CONFIG_COMPAT 811#ifdef CONFIG_COMPAT
812 .compat_ioctl = uinput_compat_ioctl, 812 .compat_ioctl = uinput_compat_ioctl,
813#endif 813#endif
814 .llseek = no_llseek,
814}; 815};
815 816
816static struct miscdevice uinput_misc = { 817static struct miscdevice uinput_misc = {
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
index d528a2dba064..31ec7265aac6 100644
--- a/drivers/input/mousedev.c
+++ b/drivers/input/mousedev.c
@@ -792,6 +792,7 @@ static const struct file_operations mousedev_fops = {
792 .open = mousedev_open, 792 .open = mousedev_open,
793 .release = mousedev_release, 793 .release = mousedev_release,
794 .fasync = mousedev_fasync, 794 .fasync = mousedev_fasync,
795 .llseek = noop_llseek,
795}; 796};
796 797
797static int mousedev_install_chrdev(struct mousedev *mousedev) 798static int mousedev_install_chrdev(struct mousedev *mousedev)
diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
index 998664854440..cd82bb125915 100644
--- a/drivers/input/serio/serio_raw.c
+++ b/drivers/input/serio/serio_raw.c
@@ -243,6 +243,7 @@ static const struct file_operations serio_raw_fops = {
243 .write = serio_raw_write, 243 .write = serio_raw_write,
244 .poll = serio_raw_poll, 244 .poll = serio_raw_poll,
245 .fasync = serio_raw_fasync, 245 .fasync = serio_raw_fasync,
246 .llseek = noop_llseek,
246}; 247};
247 248
248 249
diff --git a/drivers/isdn/mISDN/timerdev.c b/drivers/isdn/mISDN/timerdev.c
index de43c8c70ad0..859c81e9483b 100644
--- a/drivers/isdn/mISDN/timerdev.c
+++ b/drivers/isdn/mISDN/timerdev.c
@@ -267,6 +267,7 @@ static const struct file_operations mISDN_fops = {
267 .unlocked_ioctl = mISDN_ioctl, 267 .unlocked_ioctl = mISDN_ioctl,
268 .open = mISDN_open, 268 .open = mISDN_open,
269 .release = mISDN_close, 269 .release = mISDN_close,
270 .llseek = no_llseek,
270}; 271};
271 272
272static struct miscdevice mISDNtimer = { 273static struct miscdevice mISDNtimer = {
diff --git a/drivers/lguest/lguest_user.c b/drivers/lguest/lguest_user.c
index 85b714df8eae..3c781cdddda9 100644
--- a/drivers/lguest/lguest_user.c
+++ b/drivers/lguest/lguest_user.c
@@ -514,6 +514,7 @@ static const struct file_operations lguest_fops = {
514 .release = close, 514 .release = close,
515 .write = write, 515 .write = write,
516 .read = read, 516 .read = read,
517 .llseek = default_llseek,
517}; 518};
518 519
519/* 520/*
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index bf64e49d996a..75049e765191 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -24,7 +24,6 @@
24#include <linux/fs.h> 24#include <linux/fs.h>
25#include <linux/mm.h> 25#include <linux/mm.h>
26#include <linux/sched.h> 26#include <linux/sched.h>
27#include <linux/smp_lock.h>
28#include <linux/adb.h> 27#include <linux/adb.h>
29#include <linux/cuda.h> 28#include <linux/cuda.h>
30#include <linux/pmu.h> 29#include <linux/pmu.h>
@@ -55,6 +54,7 @@ extern struct adb_driver adb_iop_driver;
55extern struct adb_driver via_pmu_driver; 54extern struct adb_driver via_pmu_driver;
56extern struct adb_driver macio_adb_driver; 55extern struct adb_driver macio_adb_driver;
57 56
57static DEFINE_MUTEX(adb_mutex);
58static struct adb_driver *adb_driver_list[] = { 58static struct adb_driver *adb_driver_list[] = {
59#ifdef CONFIG_ADB_MACII 59#ifdef CONFIG_ADB_MACII
60 &via_macii_driver, 60 &via_macii_driver,
@@ -647,7 +647,7 @@ static int adb_open(struct inode *inode, struct file *file)
647 struct adbdev_state *state; 647 struct adbdev_state *state;
648 int ret = 0; 648 int ret = 0;
649 649
650 lock_kernel(); 650 mutex_lock(&adb_mutex);
651 if (iminor(inode) > 0 || adb_controller == NULL) { 651 if (iminor(inode) > 0 || adb_controller == NULL) {
652 ret = -ENXIO; 652 ret = -ENXIO;
653 goto out; 653 goto out;
@@ -665,7 +665,7 @@ static int adb_open(struct inode *inode, struct file *file)
665 state->inuse = 1; 665 state->inuse = 1;
666 666
667out: 667out:
668 unlock_kernel(); 668 mutex_unlock(&adb_mutex);
669 return ret; 669 return ret;
670} 670}
671 671
@@ -674,7 +674,7 @@ static int adb_release(struct inode *inode, struct file *file)
674 struct adbdev_state *state = file->private_data; 674 struct adbdev_state *state = file->private_data;
675 unsigned long flags; 675 unsigned long flags;
676 676
677 lock_kernel(); 677 mutex_lock(&adb_mutex);
678 if (state) { 678 if (state) {
679 file->private_data = NULL; 679 file->private_data = NULL;
680 spin_lock_irqsave(&state->lock, flags); 680 spin_lock_irqsave(&state->lock, flags);
@@ -687,7 +687,7 @@ static int adb_release(struct inode *inode, struct file *file)
687 spin_unlock_irqrestore(&state->lock, flags); 687 spin_unlock_irqrestore(&state->lock, flags);
688 } 688 }
689 } 689 }
690 unlock_kernel(); 690 mutex_unlock(&adb_mutex);
691 return 0; 691 return 0;
692} 692}
693 693
diff --git a/drivers/macintosh/ans-lcd.c b/drivers/macintosh/ans-lcd.c
index a3d25da2f275..1a57e88a38f7 100644
--- a/drivers/macintosh/ans-lcd.c
+++ b/drivers/macintosh/ans-lcd.c
@@ -137,6 +137,7 @@ const struct file_operations anslcd_fops = {
137 .write = anslcd_write, 137 .write = anslcd_write,
138 .unlocked_ioctl = anslcd_ioctl, 138 .unlocked_ioctl = anslcd_ioctl,
139 .open = anslcd_open, 139 .open = anslcd_open,
140 .llseek = default_llseek,
140}; 141};
141 142
142static struct miscdevice anslcd_dev = { 143static struct miscdevice anslcd_dev = {
diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c
index e58c3d33e035..290cb325a94c 100644
--- a/drivers/macintosh/smu.c
+++ b/drivers/macintosh/smu.c
@@ -19,7 +19,6 @@
19 * the userland interface 19 * the userland interface
20 */ 20 */
21 21
22#include <linux/smp_lock.h>
23#include <linux/types.h> 22#include <linux/types.h>
24#include <linux/kernel.h> 23#include <linux/kernel.h>
25#include <linux/device.h> 24#include <linux/device.h>
@@ -97,6 +96,7 @@ struct smu_device {
97 * I don't think there will ever be more than one SMU, so 96 * I don't think there will ever be more than one SMU, so
98 * for now, just hard code that 97 * for now, just hard code that
99 */ 98 */
99static DEFINE_MUTEX(smu_mutex);
100static struct smu_device *smu; 100static struct smu_device *smu;
101static DEFINE_MUTEX(smu_part_access); 101static DEFINE_MUTEX(smu_part_access);
102static int smu_irq_inited; 102static int smu_irq_inited;
@@ -1095,12 +1095,12 @@ static int smu_open(struct inode *inode, struct file *file)
1095 pp->mode = smu_file_commands; 1095 pp->mode = smu_file_commands;
1096 init_waitqueue_head(&pp->wait); 1096 init_waitqueue_head(&pp->wait);
1097 1097
1098 lock_kernel(); 1098 mutex_lock(&smu_mutex);
1099 spin_lock_irqsave(&smu_clist_lock, flags); 1099 spin_lock_irqsave(&smu_clist_lock, flags);
1100 list_add(&pp->list, &smu_clist); 1100 list_add(&pp->list, &smu_clist);
1101 spin_unlock_irqrestore(&smu_clist_lock, flags); 1101 spin_unlock_irqrestore(&smu_clist_lock, flags);
1102 file->private_data = pp; 1102 file->private_data = pp;
1103 unlock_kernel(); 1103 mutex_unlock(&smu_mutex);
1104 1104
1105 return 0; 1105 return 0;
1106} 1106}
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index 2d17e76066bd..cd29c8248386 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -18,7 +18,7 @@
18 * 18 *
19 */ 19 */
20#include <stdarg.h> 20#include <stdarg.h>
21#include <linux/smp_lock.h> 21#include <linux/mutex.h>
22#include <linux/types.h> 22#include <linux/types.h>
23#include <linux/errno.h> 23#include <linux/errno.h>
24#include <linux/kernel.h> 24#include <linux/kernel.h>
@@ -73,6 +73,7 @@
73/* How many iterations between battery polls */ 73/* How many iterations between battery polls */
74#define BATTERY_POLLING_COUNT 2 74#define BATTERY_POLLING_COUNT 2
75 75
76static DEFINE_MUTEX(pmu_info_proc_mutex);
76static volatile unsigned char __iomem *via; 77static volatile unsigned char __iomem *via;
77 78
78/* VIA registers - spaced 0x200 bytes apart */ 79/* VIA registers - spaced 0x200 bytes apart */
@@ -2078,7 +2079,7 @@ pmu_open(struct inode *inode, struct file *file)
2078 pp->rb_get = pp->rb_put = 0; 2079 pp->rb_get = pp->rb_put = 0;
2079 spin_lock_init(&pp->lock); 2080 spin_lock_init(&pp->lock);
2080 init_waitqueue_head(&pp->wait); 2081 init_waitqueue_head(&pp->wait);
2081 lock_kernel(); 2082 mutex_lock(&pmu_info_proc_mutex);
2082 spin_lock_irqsave(&all_pvt_lock, flags); 2083 spin_lock_irqsave(&all_pvt_lock, flags);
2083#if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) 2084#if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT)
2084 pp->backlight_locker = 0; 2085 pp->backlight_locker = 0;
@@ -2086,7 +2087,7 @@ pmu_open(struct inode *inode, struct file *file)
2086 list_add(&pp->list, &all_pmu_pvt); 2087 list_add(&pp->list, &all_pmu_pvt);
2087 spin_unlock_irqrestore(&all_pvt_lock, flags); 2088 spin_unlock_irqrestore(&all_pvt_lock, flags);
2088 file->private_data = pp; 2089 file->private_data = pp;
2089 unlock_kernel(); 2090 mutex_unlock(&pmu_info_proc_mutex);
2090 return 0; 2091 return 0;
2091} 2092}
2092 2093
@@ -2343,9 +2344,9 @@ static long pmu_unlocked_ioctl(struct file *filp,
2343{ 2344{
2344 int ret; 2345 int ret;
2345 2346
2346 lock_kernel(); 2347 mutex_lock(&pmu_info_proc_mutex);
2347 ret = pmu_ioctl(filp, cmd, arg); 2348 ret = pmu_ioctl(filp, cmd, arg);
2348 unlock_kernel(); 2349 mutex_unlock(&pmu_info_proc_mutex);
2349 2350
2350 return ret; 2351 return ret;
2351} 2352}
@@ -2398,6 +2399,7 @@ static const struct file_operations pmu_device_fops = {
2398#endif 2399#endif
2399 .open = pmu_open, 2400 .open = pmu_open,
2400 .release = pmu_release, 2401 .release = pmu_release,
2402 .llseek = noop_llseek,
2401}; 2403};
2402 2404
2403static struct miscdevice pmu_device = { 2405static struct miscdevice pmu_device = {
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 3e39193e5036..4b54618b4159 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -1596,6 +1596,7 @@ static const struct file_operations _ctl_fops = {
1596 .unlocked_ioctl = dm_ctl_ioctl, 1596 .unlocked_ioctl = dm_ctl_ioctl,
1597 .compat_ioctl = dm_compat_ctl_ioctl, 1597 .compat_ioctl = dm_compat_ctl_ioctl,
1598 .owner = THIS_MODULE, 1598 .owner = THIS_MODULE,
1599 .llseek = noop_llseek,
1599}; 1600};
1600 1601
1601static struct miscdevice _dm_misc = { 1602static struct miscdevice _dm_misc = {
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index ac384b2a6a33..7967eca5a2d5 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -15,7 +15,6 @@
15#include <linux/blkpg.h> 15#include <linux/blkpg.h>
16#include <linux/bio.h> 16#include <linux/bio.h>
17#include <linux/buffer_head.h> 17#include <linux/buffer_head.h>
18#include <linux/smp_lock.h>
19#include <linux/mempool.h> 18#include <linux/mempool.h>
20#include <linux/slab.h> 19#include <linux/slab.h>
21#include <linux/idr.h> 20#include <linux/idr.h>
@@ -33,6 +32,7 @@
33#define DM_COOKIE_ENV_VAR_NAME "DM_COOKIE" 32#define DM_COOKIE_ENV_VAR_NAME "DM_COOKIE"
34#define DM_COOKIE_LENGTH 24 33#define DM_COOKIE_LENGTH 24
35 34
35static DEFINE_MUTEX(dm_mutex);
36static const char *_name = DM_NAME; 36static const char *_name = DM_NAME;
37 37
38static unsigned int major = 0; 38static unsigned int major = 0;
@@ -344,7 +344,7 @@ static int dm_blk_open(struct block_device *bdev, fmode_t mode)
344{ 344{
345 struct mapped_device *md; 345 struct mapped_device *md;
346 346
347 lock_kernel(); 347 mutex_lock(&dm_mutex);
348 spin_lock(&_minor_lock); 348 spin_lock(&_minor_lock);
349 349
350 md = bdev->bd_disk->private_data; 350 md = bdev->bd_disk->private_data;
@@ -362,7 +362,7 @@ static int dm_blk_open(struct block_device *bdev, fmode_t mode)
362 362
363out: 363out:
364 spin_unlock(&_minor_lock); 364 spin_unlock(&_minor_lock);
365 unlock_kernel(); 365 mutex_unlock(&dm_mutex);
366 366
367 return md ? 0 : -ENXIO; 367 return md ? 0 : -ENXIO;
368} 368}
@@ -371,10 +371,10 @@ static int dm_blk_close(struct gendisk *disk, fmode_t mode)
371{ 371{
372 struct mapped_device *md = disk->private_data; 372 struct mapped_device *md = disk->private_data;
373 373
374 lock_kernel(); 374 mutex_lock(&dm_mutex);
375 atomic_dec(&md->open_count); 375 atomic_dec(&md->open_count);
376 dm_put(md); 376 dm_put(md);
377 unlock_kernel(); 377 mutex_unlock(&dm_mutex);
378 378
379 return 0; 379 return 0;
380} 380}
diff --git a/drivers/md/md.c b/drivers/md/md.c
index f20d13e717d5..dbf822df942a 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -36,7 +36,7 @@
36#include <linux/blkdev.h> 36#include <linux/blkdev.h>
37#include <linux/sysctl.h> 37#include <linux/sysctl.h>
38#include <linux/seq_file.h> 38#include <linux/seq_file.h>
39#include <linux/smp_lock.h> 39#include <linux/mutex.h>
40#include <linux/buffer_head.h> /* for invalidate_bdev */ 40#include <linux/buffer_head.h> /* for invalidate_bdev */
41#include <linux/poll.h> 41#include <linux/poll.h>
42#include <linux/ctype.h> 42#include <linux/ctype.h>
@@ -57,6 +57,7 @@
57#define DEBUG 0 57#define DEBUG 0
58#define dprintk(x...) ((void)(DEBUG && printk(x))) 58#define dprintk(x...) ((void)(DEBUG && printk(x)))
59 59
60static DEFINE_MUTEX(md_mutex);
60 61
61#ifndef MODULE 62#ifndef MODULE
62static void autostart_arrays(int part); 63static void autostart_arrays(int part);
@@ -5951,7 +5952,7 @@ static int md_open(struct block_device *bdev, fmode_t mode)
5951 mddev_t *mddev = mddev_find(bdev->bd_dev); 5952 mddev_t *mddev = mddev_find(bdev->bd_dev);
5952 int err; 5953 int err;
5953 5954
5954 lock_kernel(); 5955 mutex_lock(&md_mutex);
5955 if (mddev->gendisk != bdev->bd_disk) { 5956 if (mddev->gendisk != bdev->bd_disk) {
5956 /* we are racing with mddev_put which is discarding this 5957 /* we are racing with mddev_put which is discarding this
5957 * bd_disk. 5958 * bd_disk.
@@ -5960,7 +5961,7 @@ static int md_open(struct block_device *bdev, fmode_t mode)
5960 /* Wait until bdev->bd_disk is definitely gone */ 5961 /* Wait until bdev->bd_disk is definitely gone */
5961 flush_scheduled_work(); 5962 flush_scheduled_work();
5962 /* Then retry the open from the top */ 5963 /* Then retry the open from the top */
5963 unlock_kernel(); 5964 mutex_unlock(&md_mutex);
5964 return -ERESTARTSYS; 5965 return -ERESTARTSYS;
5965 } 5966 }
5966 BUG_ON(mddev != bdev->bd_disk->private_data); 5967 BUG_ON(mddev != bdev->bd_disk->private_data);
@@ -5974,7 +5975,7 @@ static int md_open(struct block_device *bdev, fmode_t mode)
5974 5975
5975 check_disk_size_change(mddev->gendisk, bdev); 5976 check_disk_size_change(mddev->gendisk, bdev);
5976 out: 5977 out:
5977 unlock_kernel(); 5978 mutex_unlock(&md_mutex);
5978 return err; 5979 return err;
5979} 5980}
5980 5981
@@ -5983,10 +5984,10 @@ static int md_release(struct gendisk *disk, fmode_t mode)
5983 mddev_t *mddev = disk->private_data; 5984 mddev_t *mddev = disk->private_data;
5984 5985
5985 BUG_ON(!mddev); 5986 BUG_ON(!mddev);
5986 lock_kernel(); 5987 mutex_lock(&md_mutex);
5987 atomic_dec(&mddev->openers); 5988 atomic_dec(&mddev->openers);
5988 mddev_put(mddev); 5989 mddev_put(mddev);
5989 unlock_kernel(); 5990 mutex_unlock(&md_mutex);
5990 5991
5991 return 0; 5992 return 0;
5992} 5993}
diff --git a/drivers/media/IR/imon.c b/drivers/media/IR/imon.c
index c185422ef28c..faed5a332c71 100644
--- a/drivers/media/IR/imon.c
+++ b/drivers/media/IR/imon.c
@@ -151,7 +151,8 @@ static const struct file_operations vfd_fops = {
151 .owner = THIS_MODULE, 151 .owner = THIS_MODULE,
152 .open = &display_open, 152 .open = &display_open,
153 .write = &vfd_write, 153 .write = &vfd_write,
154 .release = &display_close 154 .release = &display_close,
155 .llseek = noop_llseek,
155}; 156};
156 157
157/* lcd character device file operations */ 158/* lcd character device file operations */
@@ -159,7 +160,8 @@ static const struct file_operations lcd_fops = {
159 .owner = THIS_MODULE, 160 .owner = THIS_MODULE,
160 .open = &display_open, 161 .open = &display_open,
161 .write = &lcd_write, 162 .write = &lcd_write,
162 .release = &display_close 163 .release = &display_close,
164 .llseek = noop_llseek,
163}; 165};
164 166
165enum { 167enum {
diff --git a/drivers/media/IR/ir-lirc-codec.c b/drivers/media/IR/ir-lirc-codec.c
index e63f757d5d72..1983cd3f3994 100644
--- a/drivers/media/IR/ir-lirc-codec.c
+++ b/drivers/media/IR/ir-lirc-codec.c
@@ -235,6 +235,7 @@ static struct file_operations lirc_fops = {
235 .poll = lirc_dev_fop_poll, 235 .poll = lirc_dev_fop_poll,
236 .open = lirc_dev_fop_open, 236 .open = lirc_dev_fop_open,
237 .release = lirc_dev_fop_close, 237 .release = lirc_dev_fop_close,
238 .llseek = no_llseek,
238}; 239};
239 240
240static int ir_lirc_register(struct input_dev *input_dev) 241static int ir_lirc_register(struct input_dev *input_dev)
diff --git a/drivers/media/IR/lirc_dev.c b/drivers/media/IR/lirc_dev.c
index 899891bec352..0acf6396e068 100644
--- a/drivers/media/IR/lirc_dev.c
+++ b/drivers/media/IR/lirc_dev.c
@@ -163,6 +163,7 @@ static struct file_operations fops = {
163 .unlocked_ioctl = lirc_dev_fop_ioctl, 163 .unlocked_ioctl = lirc_dev_fop_ioctl,
164 .open = lirc_dev_fop_open, 164 .open = lirc_dev_fop_open,
165 .release = lirc_dev_fop_close, 165 .release = lirc_dev_fop_close,
166 .llseek = noop_llseek,
166}; 167};
167 168
168static int lirc_cdev_add(struct irctl *ir) 169static int lirc_cdev_add(struct irctl *ir)
@@ -460,6 +461,8 @@ error:
460 461
461 mutex_unlock(&lirc_dev_lock); 462 mutex_unlock(&lirc_dev_lock);
462 463
464 nonseekable_open(inode, file);
465
463 return retval; 466 return retval;
464} 467}
465EXPORT_SYMBOL(lirc_dev_fop_open); 468EXPORT_SYMBOL(lirc_dev_fop_open);
diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig
index a28541b2b1a2..bad2cedb8d96 100644
--- a/drivers/media/Kconfig
+++ b/drivers/media/Kconfig
@@ -19,6 +19,7 @@ comment "Multimedia core support"
19 19
20config VIDEO_DEV 20config VIDEO_DEV
21 tristate "Video For Linux" 21 tristate "Video For Linux"
22 depends on BKL # used in many drivers for ioctl handling, need to kill
22 ---help--- 23 ---help---
23 V4L core support for video capture and overlay devices, webcams and 24 V4L core support for video capture and overlay devices, webcams and
24 AM/FM radio cards. 25 AM/FM radio cards.
diff --git a/drivers/media/dvb/bt8xx/dst_ca.c b/drivers/media/dvb/bt8xx/dst_ca.c
index cf8705162845..48e48e8af55a 100644
--- a/drivers/media/dvb/bt8xx/dst_ca.c
+++ b/drivers/media/dvb/bt8xx/dst_ca.c
@@ -22,7 +22,7 @@
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/smp_lock.h> 25#include <linux/mutex.h>
26#include <linux/string.h> 26#include <linux/string.h>
27#include <linux/dvb/ca.h> 27#include <linux/dvb/ca.h>
28#include "dvbdev.h" 28#include "dvbdev.h"
@@ -52,6 +52,7 @@
52} while(0) 52} while(0)
53 53
54 54
55static DEFINE_MUTEX(dst_ca_mutex);
55static unsigned int verbose = 5; 56static unsigned int verbose = 5;
56module_param(verbose, int, 0644); 57module_param(verbose, int, 0644);
57MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)"); 58MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)");
@@ -564,7 +565,7 @@ static long dst_ca_ioctl(struct file *file, unsigned int cmd, unsigned long ioct
564 void __user *arg = (void __user *)ioctl_arg; 565 void __user *arg = (void __user *)ioctl_arg;
565 int result = 0; 566 int result = 0;
566 567
567 lock_kernel(); 568 mutex_lock(&dst_ca_mutex);
568 dvbdev = file->private_data; 569 dvbdev = file->private_data;
569 state = (struct dst_state *)dvbdev->priv; 570 state = (struct dst_state *)dvbdev->priv;
570 p_ca_message = kmalloc(sizeof (struct ca_msg), GFP_KERNEL); 571 p_ca_message = kmalloc(sizeof (struct ca_msg), GFP_KERNEL);
@@ -652,7 +653,7 @@ static long dst_ca_ioctl(struct file *file, unsigned int cmd, unsigned long ioct
652 kfree (p_ca_slot_info); 653 kfree (p_ca_slot_info);
653 kfree (p_ca_caps); 654 kfree (p_ca_caps);
654 655
655 unlock_kernel(); 656 mutex_unlock(&dst_ca_mutex);
656 return result; 657 return result;
657} 658}
658 659
@@ -694,7 +695,8 @@ static const struct file_operations dst_ca_fops = {
694 .open = dst_ca_open, 695 .open = dst_ca_open,
695 .release = dst_ca_release, 696 .release = dst_ca_release,
696 .read = dst_ca_read, 697 .read = dst_ca_read,
697 .write = dst_ca_write 698 .write = dst_ca_write,
699 .llseek = noop_llseek,
698}; 700};
699 701
700static struct dvb_device dvbdev_ca = { 702static struct dvb_device dvbdev_ca = {
diff --git a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c
index 0042306ea11b..ad1f61d301e1 100644
--- a/drivers/media/dvb/dvb-core/dmxdev.c
+++ b/drivers/media/dvb/dvb-core/dmxdev.c
@@ -25,7 +25,6 @@
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/vmalloc.h> 26#include <linux/vmalloc.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/smp_lock.h>
29#include <linux/poll.h> 28#include <linux/poll.h>
30#include <linux/ioctl.h> 29#include <linux/ioctl.h>
31#include <linux/wait.h> 30#include <linux/wait.h>
@@ -1088,13 +1087,7 @@ static int dvb_demux_do_ioctl(struct file *file,
1088static long dvb_demux_ioctl(struct file *file, unsigned int cmd, 1087static long dvb_demux_ioctl(struct file *file, unsigned int cmd,
1089 unsigned long arg) 1088 unsigned long arg)
1090{ 1089{
1091 int ret; 1090 return dvb_usercopy(file, cmd, arg, dvb_demux_do_ioctl);
1092
1093 lock_kernel();
1094 ret = dvb_usercopy(file, cmd, arg, dvb_demux_do_ioctl);
1095 unlock_kernel();
1096
1097 return ret;
1098} 1091}
1099 1092
1100static unsigned int dvb_demux_poll(struct file *file, poll_table *wait) 1093static unsigned int dvb_demux_poll(struct file *file, poll_table *wait)
@@ -1150,6 +1143,7 @@ static const struct file_operations dvb_demux_fops = {
1150 .open = dvb_demux_open, 1143 .open = dvb_demux_open,
1151 .release = dvb_demux_release, 1144 .release = dvb_demux_release,
1152 .poll = dvb_demux_poll, 1145 .poll = dvb_demux_poll,
1146 .llseek = default_llseek,
1153}; 1147};
1154 1148
1155static struct dvb_device dvbdev_demux = { 1149static struct dvb_device dvbdev_demux = {
@@ -1186,13 +1180,7 @@ static int dvb_dvr_do_ioctl(struct file *file,
1186static long dvb_dvr_ioctl(struct file *file, 1180static long dvb_dvr_ioctl(struct file *file,
1187 unsigned int cmd, unsigned long arg) 1181 unsigned int cmd, unsigned long arg)
1188{ 1182{
1189 int ret; 1183 return dvb_usercopy(file, cmd, arg, dvb_dvr_do_ioctl);
1190
1191 lock_kernel();
1192 ret = dvb_usercopy(file, cmd, arg, dvb_dvr_do_ioctl);
1193 unlock_kernel();
1194
1195 return ret;
1196} 1184}
1197 1185
1198static unsigned int dvb_dvr_poll(struct file *file, poll_table *wait) 1186static unsigned int dvb_dvr_poll(struct file *file, poll_table *wait)
@@ -1225,6 +1213,7 @@ static const struct file_operations dvb_dvr_fops = {
1225 .open = dvb_dvr_open, 1213 .open = dvb_dvr_open,
1226 .release = dvb_dvr_release, 1214 .release = dvb_dvr_release,
1227 .poll = dvb_dvr_poll, 1215 .poll = dvb_dvr_poll,
1216 .llseek = default_llseek,
1228}; 1217};
1229 1218
1230static struct dvb_device dvbdev_dvr = { 1219static struct dvb_device dvbdev_dvr = {
diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
index cb97e6b85432..4d0646da6087 100644
--- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
@@ -1259,13 +1259,7 @@ static int dvb_ca_en50221_io_do_ioctl(struct file *file,
1259static long dvb_ca_en50221_io_ioctl(struct file *file, 1259static long dvb_ca_en50221_io_ioctl(struct file *file,
1260 unsigned int cmd, unsigned long arg) 1260 unsigned int cmd, unsigned long arg)
1261{ 1261{
1262 int ret; 1262 return dvb_usercopy(file, cmd, arg, dvb_ca_en50221_io_do_ioctl);
1263
1264 lock_kernel();
1265 ret = dvb_usercopy(file, cmd, arg, dvb_ca_en50221_io_do_ioctl);
1266 unlock_kernel();
1267
1268 return ret;
1269} 1263}
1270 1264
1271 1265
@@ -1628,6 +1622,7 @@ static const struct file_operations dvb_ca_fops = {
1628 .open = dvb_ca_en50221_io_open, 1622 .open = dvb_ca_en50221_io_open,
1629 .release = dvb_ca_en50221_io_release, 1623 .release = dvb_ca_en50221_io_release,
1630 .poll = dvb_ca_en50221_io_poll, 1624 .poll = dvb_ca_en50221_io_poll,
1625 .llseek = noop_llseek,
1631}; 1626};
1632 1627
1633static struct dvb_device dvbdev_ca = { 1628static struct dvb_device dvbdev_ca = {
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index 4d45b7d6b3fb..970c9b8882d4 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -2034,7 +2034,8 @@ static const struct file_operations dvb_frontend_fops = {
2034 .unlocked_ioctl = dvb_generic_ioctl, 2034 .unlocked_ioctl = dvb_generic_ioctl,
2035 .poll = dvb_frontend_poll, 2035 .poll = dvb_frontend_poll,
2036 .open = dvb_frontend_open, 2036 .open = dvb_frontend_open,
2037 .release = dvb_frontend_release 2037 .release = dvb_frontend_release,
2038 .llseek = noop_llseek,
2038}; 2039};
2039 2040
2040int dvb_register_frontend(struct dvb_adapter* dvb, 2041int dvb_register_frontend(struct dvb_adapter* dvb,
diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c
index 6c3a8a06ccab..4df42aaae7f7 100644
--- a/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/drivers/media/dvb/dvb-core/dvb_net.c
@@ -59,7 +59,6 @@
59#include <linux/netdevice.h> 59#include <linux/netdevice.h>
60#include <linux/etherdevice.h> 60#include <linux/etherdevice.h>
61#include <linux/dvb/net.h> 61#include <linux/dvb/net.h>
62#include <linux/smp_lock.h>
63#include <linux/uio.h> 62#include <linux/uio.h>
64#include <asm/uaccess.h> 63#include <asm/uaccess.h>
65#include <linux/crc32.h> 64#include <linux/crc32.h>
@@ -1445,13 +1444,7 @@ static int dvb_net_do_ioctl(struct file *file,
1445static long dvb_net_ioctl(struct file *file, 1444static long dvb_net_ioctl(struct file *file,
1446 unsigned int cmd, unsigned long arg) 1445 unsigned int cmd, unsigned long arg)
1447{ 1446{
1448 int ret; 1447 return dvb_usercopy(file, cmd, arg, dvb_net_do_ioctl);
1449
1450 lock_kernel();
1451 ret = dvb_usercopy(file, cmd, arg, dvb_net_do_ioctl);
1452 unlock_kernel();
1453
1454 return ret;
1455} 1448}
1456 1449
1457static int dvb_net_close(struct inode *inode, struct file *file) 1450static int dvb_net_close(struct inode *inode, struct file *file)
@@ -1475,6 +1468,7 @@ static const struct file_operations dvb_net_fops = {
1475 .unlocked_ioctl = dvb_net_ioctl, 1468 .unlocked_ioctl = dvb_net_ioctl,
1476 .open = dvb_generic_open, 1469 .open = dvb_generic_open,
1477 .release = dvb_net_close, 1470 .release = dvb_net_close,
1471 .llseek = noop_llseek,
1478}; 1472};
1479 1473
1480static struct dvb_device dvbdev_net = { 1474static struct dvb_device dvbdev_net = {
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
index b915c39d782f..f73287775953 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.c
+++ b/drivers/media/dvb/dvb-core/dvbdev.c
@@ -32,9 +32,9 @@
32#include <linux/fs.h> 32#include <linux/fs.h>
33#include <linux/cdev.h> 33#include <linux/cdev.h>
34#include <linux/mutex.h> 34#include <linux/mutex.h>
35#include <linux/smp_lock.h>
36#include "dvbdev.h" 35#include "dvbdev.h"
37 36
37static DEFINE_MUTEX(dvbdev_mutex);
38static int dvbdev_debug; 38static int dvbdev_debug;
39 39
40module_param(dvbdev_debug, int, 0644); 40module_param(dvbdev_debug, int, 0644);
@@ -68,7 +68,7 @@ static int dvb_device_open(struct inode *inode, struct file *file)
68{ 68{
69 struct dvb_device *dvbdev; 69 struct dvb_device *dvbdev;
70 70
71 lock_kernel(); 71 mutex_lock(&dvbdev_mutex);
72 down_read(&minor_rwsem); 72 down_read(&minor_rwsem);
73 dvbdev = dvb_minors[iminor(inode)]; 73 dvbdev = dvb_minors[iminor(inode)];
74 74
@@ -91,12 +91,12 @@ static int dvb_device_open(struct inode *inode, struct file *file)
91 } 91 }
92 fops_put(old_fops); 92 fops_put(old_fops);
93 up_read(&minor_rwsem); 93 up_read(&minor_rwsem);
94 unlock_kernel(); 94 mutex_unlock(&dvbdev_mutex);
95 return err; 95 return err;
96 } 96 }
97fail: 97fail:
98 up_read(&minor_rwsem); 98 up_read(&minor_rwsem);
99 unlock_kernel(); 99 mutex_unlock(&dvbdev_mutex);
100 return -ENODEV; 100 return -ENODEV;
101} 101}
102 102
@@ -105,6 +105,7 @@ static const struct file_operations dvb_device_fops =
105{ 105{
106 .owner = THIS_MODULE, 106 .owner = THIS_MODULE,
107 .open = dvb_device_open, 107 .open = dvb_device_open,
108 .llseek = noop_llseek,
108}; 109};
109 110
110static struct cdev dvb_device_cdev; 111static struct cdev dvb_device_cdev;
@@ -158,7 +159,6 @@ long dvb_generic_ioctl(struct file *file,
158 unsigned int cmd, unsigned long arg) 159 unsigned int cmd, unsigned long arg)
159{ 160{
160 struct dvb_device *dvbdev = file->private_data; 161 struct dvb_device *dvbdev = file->private_data;
161 int ret;
162 162
163 if (!dvbdev) 163 if (!dvbdev)
164 return -ENODEV; 164 return -ENODEV;
@@ -166,11 +166,7 @@ long dvb_generic_ioctl(struct file *file,
166 if (!dvbdev->kernel_ioctl) 166 if (!dvbdev->kernel_ioctl)
167 return -EINVAL; 167 return -EINVAL;
168 168
169 lock_kernel(); 169 return dvb_usercopy(file, cmd, arg, dvbdev->kernel_ioctl);
170 ret = dvb_usercopy(file, cmd, arg, dvbdev->kernel_ioctl);
171 unlock_kernel();
172
173 return ret;
174} 170}
175EXPORT_SYMBOL(dvb_generic_ioctl); 171EXPORT_SYMBOL(dvb_generic_ioctl);
176 172
@@ -421,8 +417,10 @@ int dvb_usercopy(struct file *file,
421 } 417 }
422 418
423 /* call driver */ 419 /* call driver */
420 mutex_lock(&dvbdev_mutex);
424 if ((err = func(file, cmd, parg)) == -ENOIOCTLCMD) 421 if ((err = func(file, cmd, parg)) == -ENOIOCTLCMD)
425 err = -EINVAL; 422 err = -EINVAL;
423 mutex_unlock(&dvbdev_mutex);
426 424
427 if (err < 0) 425 if (err < 0)
428 goto out; 426 goto out;
diff --git a/drivers/media/dvb/firewire/firedtv-ci.c b/drivers/media/dvb/firewire/firedtv-ci.c
index d3c2cf60de76..8ffb565f0704 100644
--- a/drivers/media/dvb/firewire/firedtv-ci.c
+++ b/drivers/media/dvb/firewire/firedtv-ci.c
@@ -220,6 +220,7 @@ static const struct file_operations fdtv_ca_fops = {
220 .open = dvb_generic_open, 220 .open = dvb_generic_open,
221 .release = dvb_generic_release, 221 .release = dvb_generic_release,
222 .poll = fdtv_ca_io_poll, 222 .poll = fdtv_ca_io_poll,
223 .llseek = noop_llseek,
223}; 224};
224 225
225static struct dvb_device fdtv_ca = { 226static struct dvb_device fdtv_ca = {
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
index a6be529eec5c..893fbc57c72f 100644
--- a/drivers/media/dvb/ttpci/av7110.c
+++ b/drivers/media/dvb/ttpci/av7110.c
@@ -730,6 +730,7 @@ static const struct file_operations dvb_osd_fops = {
730 .unlocked_ioctl = dvb_generic_ioctl, 730 .unlocked_ioctl = dvb_generic_ioctl,
731 .open = dvb_generic_open, 731 .open = dvb_generic_open,
732 .release = dvb_generic_release, 732 .release = dvb_generic_release,
733 .llseek = noop_llseek,
733}; 734};
734 735
735static struct dvb_device dvbdev_osd = { 736static struct dvb_device dvbdev_osd = {
diff --git a/drivers/media/dvb/ttpci/av7110_av.c b/drivers/media/dvb/ttpci/av7110_av.c
index 13efba942dac..6ef3996565ad 100644
--- a/drivers/media/dvb/ttpci/av7110_av.c
+++ b/drivers/media/dvb/ttpci/av7110_av.c
@@ -1521,6 +1521,7 @@ static const struct file_operations dvb_video_fops = {
1521 .open = dvb_video_open, 1521 .open = dvb_video_open,
1522 .release = dvb_video_release, 1522 .release = dvb_video_release,
1523 .poll = dvb_video_poll, 1523 .poll = dvb_video_poll,
1524 .llseek = noop_llseek,
1524}; 1525};
1525 1526
1526static struct dvb_device dvbdev_video = { 1527static struct dvb_device dvbdev_video = {
@@ -1539,6 +1540,7 @@ static const struct file_operations dvb_audio_fops = {
1539 .open = dvb_audio_open, 1540 .open = dvb_audio_open,
1540 .release = dvb_audio_release, 1541 .release = dvb_audio_release,
1541 .poll = dvb_audio_poll, 1542 .poll = dvb_audio_poll,
1543 .llseek = noop_llseek,
1542}; 1544};
1543 1545
1544static struct dvb_device dvbdev_audio = { 1546static struct dvb_device dvbdev_audio = {
diff --git a/drivers/media/dvb/ttpci/av7110_ca.c b/drivers/media/dvb/ttpci/av7110_ca.c
index 4eba35a018e3..43f61f2eca98 100644
--- a/drivers/media/dvb/ttpci/av7110_ca.c
+++ b/drivers/media/dvb/ttpci/av7110_ca.c
@@ -353,6 +353,7 @@ static const struct file_operations dvb_ca_fops = {
353 .open = dvb_ca_open, 353 .open = dvb_ca_open,
354 .release = dvb_generic_release, 354 .release = dvb_generic_release,
355 .poll = dvb_ca_poll, 355 .poll = dvb_ca_poll,
356 .llseek = default_llseek,
356}; 357};
357 358
358static struct dvb_device dvbdev_ca = { 359static struct dvb_device dvbdev_ca = {
diff --git a/drivers/media/dvb/ttpci/av7110_ir.c b/drivers/media/dvb/ttpci/av7110_ir.c
index b070e88d8c6b..908f272fe26c 100644
--- a/drivers/media/dvb/ttpci/av7110_ir.c
+++ b/drivers/media/dvb/ttpci/av7110_ir.c
@@ -312,6 +312,7 @@ static ssize_t av7110_ir_proc_write(struct file *file, const char __user *buffer
312static const struct file_operations av7110_ir_proc_fops = { 312static const struct file_operations av7110_ir_proc_fops = {
313 .owner = THIS_MODULE, 313 .owner = THIS_MODULE,
314 .write = av7110_ir_proc_write, 314 .write = av7110_ir_proc_write,
315 .llseek = noop_llseek,
315}; 316};
316 317
317/* interrupt handler */ 318/* interrupt handler */
diff --git a/drivers/media/video/dabusb.c b/drivers/media/video/dabusb.c
index 5b176bd7afdb..f3e25e91366d 100644
--- a/drivers/media/video/dabusb.c
+++ b/drivers/media/video/dabusb.c
@@ -32,7 +32,6 @@
32#include <linux/list.h> 32#include <linux/list.h>
33#include <linux/vmalloc.h> 33#include <linux/vmalloc.h>
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/smp_lock.h>
36#include <linux/init.h> 35#include <linux/init.h>
37#include <asm/uaccess.h> 36#include <asm/uaccess.h>
38#include <asm/atomic.h> 37#include <asm/atomic.h>
@@ -621,7 +620,6 @@ static int dabusb_open (struct inode *inode, struct file *file)
621 if (devnum < DABUSB_MINOR || devnum >= (DABUSB_MINOR + NRDABUSB)) 620 if (devnum < DABUSB_MINOR || devnum >= (DABUSB_MINOR + NRDABUSB))
622 return -EIO; 621 return -EIO;
623 622
624 lock_kernel();
625 s = &dabusb[devnum - DABUSB_MINOR]; 623 s = &dabusb[devnum - DABUSB_MINOR];
626 624
627 dbg("dabusb_open"); 625 dbg("dabusb_open");
@@ -630,21 +628,17 @@ static int dabusb_open (struct inode *inode, struct file *file)
630 while (!s->usbdev || s->opened) { 628 while (!s->usbdev || s->opened) {
631 mutex_unlock(&s->mutex); 629 mutex_unlock(&s->mutex);
632 630
633 if (file->f_flags & O_NONBLOCK) { 631 if (file->f_flags & O_NONBLOCK)
634 return -EBUSY; 632 return -EBUSY;
635 }
636 msleep_interruptible(500); 633 msleep_interruptible(500);
637 634
638 if (signal_pending (current)) { 635 if (signal_pending (current))
639 unlock_kernel();
640 return -EAGAIN; 636 return -EAGAIN;
641 }
642 mutex_lock(&s->mutex); 637 mutex_lock(&s->mutex);
643 } 638 }
644 if (usb_set_interface (s->usbdev, _DABUSB_IF, 1) < 0) { 639 if (usb_set_interface (s->usbdev, _DABUSB_IF, 1) < 0) {
645 mutex_unlock(&s->mutex); 640 mutex_unlock(&s->mutex);
646 dev_err(&s->usbdev->dev, "set_interface failed\n"); 641 dev_err(&s->usbdev->dev, "set_interface failed\n");
647 unlock_kernel();
648 return -EINVAL; 642 return -EINVAL;
649 } 643 }
650 s->opened = 1; 644 s->opened = 1;
@@ -654,7 +648,6 @@ static int dabusb_open (struct inode *inode, struct file *file)
654 file->private_data = s; 648 file->private_data = s;
655 649
656 r = nonseekable_open(inode, file); 650 r = nonseekable_open(inode, file);
657 unlock_kernel();
658 return r; 651 return r;
659} 652}
660 653
@@ -689,17 +682,13 @@ static long dabusb_ioctl (struct file *file, unsigned int cmd, unsigned long arg
689 682
690 dbg("dabusb_ioctl"); 683 dbg("dabusb_ioctl");
691 684
692 lock_kernel(); 685 if (s->remove_pending)
693 if (s->remove_pending) {
694 unlock_kernel();
695 return -EIO; 686 return -EIO;
696 }
697 687
698 mutex_lock(&s->mutex); 688 mutex_lock(&s->mutex);
699 689
700 if (!s->usbdev) { 690 if (!s->usbdev) {
701 mutex_unlock(&s->mutex); 691 mutex_unlock(&s->mutex);
702 unlock_kernel();
703 return -EIO; 692 return -EIO;
704 } 693 }
705 694
@@ -735,7 +724,6 @@ static long dabusb_ioctl (struct file *file, unsigned int cmd, unsigned long arg
735 break; 724 break;
736 } 725 }
737 mutex_unlock(&s->mutex); 726 mutex_unlock(&s->mutex);
738 unlock_kernel();
739 return ret; 727 return ret;
740} 728}
741 729
diff --git a/drivers/memstick/core/mspro_block.c b/drivers/memstick/core/mspro_block.c
index d3f1a087eced..02362eccc588 100644
--- a/drivers/memstick/core/mspro_block.c
+++ b/drivers/memstick/core/mspro_block.c
@@ -18,11 +18,12 @@
18#include <linux/kthread.h> 18#include <linux/kthread.h>
19#include <linux/delay.h> 19#include <linux/delay.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/smp_lock.h> 21#include <linux/mutex.h>
22#include <linux/memstick.h> 22#include <linux/memstick.h>
23 23
24#define DRIVER_NAME "mspro_block" 24#define DRIVER_NAME "mspro_block"
25 25
26static DEFINE_MUTEX(mspro_block_mutex);
26static int major; 27static int major;
27module_param(major, int, 0644); 28module_param(major, int, 0644);
28 29
@@ -180,7 +181,7 @@ static int mspro_block_bd_open(struct block_device *bdev, fmode_t mode)
180 struct mspro_block_data *msb = disk->private_data; 181 struct mspro_block_data *msb = disk->private_data;
181 int rc = -ENXIO; 182 int rc = -ENXIO;
182 183
183 lock_kernel(); 184 mutex_lock(&mspro_block_mutex);
184 mutex_lock(&mspro_block_disk_lock); 185 mutex_lock(&mspro_block_disk_lock);
185 186
186 if (msb && msb->card) { 187 if (msb && msb->card) {
@@ -192,7 +193,7 @@ static int mspro_block_bd_open(struct block_device *bdev, fmode_t mode)
192 } 193 }
193 194
194 mutex_unlock(&mspro_block_disk_lock); 195 mutex_unlock(&mspro_block_disk_lock);
195 unlock_kernel(); 196 mutex_unlock(&mspro_block_mutex);
196 197
197 return rc; 198 return rc;
198} 199}
@@ -225,9 +226,9 @@ static int mspro_block_disk_release(struct gendisk *disk)
225static int mspro_block_bd_release(struct gendisk *disk, fmode_t mode) 226static int mspro_block_bd_release(struct gendisk *disk, fmode_t mode)
226{ 227{
227 int ret; 228 int ret;
228 lock_kernel(); 229 mutex_lock(&mspro_block_mutex);
229 ret = mspro_block_disk_release(disk); 230 ret = mspro_block_disk_release(disk);
230 unlock_kernel(); 231 mutex_unlock(&mspro_block_mutex);
231 return ret; 232 return ret;
232} 233}
233 234
diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c
index d8ddfdf8be14..a3856ed90aef 100644
--- a/drivers/message/fusion/mptctl.c
+++ b/drivers/message/fusion/mptctl.c
@@ -54,7 +54,7 @@
54#include <linux/pci.h> 54#include <linux/pci.h>
55#include <linux/delay.h> /* for mdelay */ 55#include <linux/delay.h> /* for mdelay */
56#include <linux/miscdevice.h> 56#include <linux/miscdevice.h>
57#include <linux/smp_lock.h> 57#include <linux/mutex.h>
58#include <linux/compat.h> 58#include <linux/compat.h>
59 59
60#include <asm/io.h> 60#include <asm/io.h>
@@ -83,6 +83,7 @@ MODULE_VERSION(my_VERSION);
83 83
84/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 84/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
85 85
86static DEFINE_MUTEX(mpctl_mutex);
86static u8 mptctl_id = MPT_MAX_PROTOCOL_DRIVERS; 87static u8 mptctl_id = MPT_MAX_PROTOCOL_DRIVERS;
87static u8 mptctl_taskmgmt_id = MPT_MAX_PROTOCOL_DRIVERS; 88static u8 mptctl_taskmgmt_id = MPT_MAX_PROTOCOL_DRIVERS;
88 89
@@ -601,12 +602,12 @@ mptctl_fasync(int fd, struct file *filep, int mode)
601 MPT_ADAPTER *ioc; 602 MPT_ADAPTER *ioc;
602 int ret; 603 int ret;
603 604
604 lock_kernel(); 605 mutex_lock(&mpctl_mutex);
605 list_for_each_entry(ioc, &ioc_list, list) 606 list_for_each_entry(ioc, &ioc_list, list)
606 ioc->aen_event_read_flag=0; 607 ioc->aen_event_read_flag=0;
607 608
608 ret = fasync_helper(fd, filep, mode, &async_queue); 609 ret = fasync_helper(fd, filep, mode, &async_queue);
609 unlock_kernel(); 610 mutex_unlock(&mpctl_mutex);
610 return ret; 611 return ret;
611} 612}
612 613
@@ -698,9 +699,9 @@ static long
698mptctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 699mptctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
699{ 700{
700 long ret; 701 long ret;
701 lock_kernel(); 702 mutex_lock(&mpctl_mutex);
702 ret = __mptctl_ioctl(file, cmd, arg); 703 ret = __mptctl_ioctl(file, cmd, arg);
703 unlock_kernel(); 704 mutex_unlock(&mpctl_mutex);
704 return ret; 705 return ret;
705} 706}
706 707
@@ -2926,7 +2927,7 @@ compat_mpt_command(struct file *filp, unsigned int cmd,
2926static long compat_mpctl_ioctl(struct file *f, unsigned int cmd, unsigned long arg) 2927static long compat_mpctl_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
2927{ 2928{
2928 long ret; 2929 long ret;
2929 lock_kernel(); 2930 mutex_lock(&mpctl_mutex);
2930 switch (cmd) { 2931 switch (cmd) {
2931 case MPTIOCINFO: 2932 case MPTIOCINFO:
2932 case MPTIOCINFO1: 2933 case MPTIOCINFO1:
@@ -2951,7 +2952,7 @@ static long compat_mpctl_ioctl(struct file *f, unsigned int cmd, unsigned long a
2951 ret = -ENOIOCTLCMD; 2952 ret = -ENOIOCTLCMD;
2952 break; 2953 break;
2953 } 2954 }
2954 unlock_kernel(); 2955 mutex_unlock(&mpctl_mutex);
2955 return ret; 2956 return ret;
2956} 2957}
2957 2958
diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c
index f0f1e667000f..f87a9d405a5e 100644
--- a/drivers/message/i2o/i2o_block.c
+++ b/drivers/message/i2o/i2o_block.c
@@ -53,7 +53,7 @@
53#include <linux/module.h> 53#include <linux/module.h>
54#include <linux/slab.h> 54#include <linux/slab.h>
55#include <linux/i2o.h> 55#include <linux/i2o.h>
56#include <linux/smp_lock.h> 56#include <linux/mutex.h>
57 57
58#include <linux/mempool.h> 58#include <linux/mempool.h>
59 59
@@ -69,6 +69,7 @@
69#define OSM_VERSION "1.325" 69#define OSM_VERSION "1.325"
70#define OSM_DESCRIPTION "I2O Block Device OSM" 70#define OSM_DESCRIPTION "I2O Block Device OSM"
71 71
72static DEFINE_MUTEX(i2o_block_mutex);
72static struct i2o_driver i2o_block_driver; 73static struct i2o_driver i2o_block_driver;
73 74
74/* global Block OSM request mempool */ 75/* global Block OSM request mempool */
@@ -578,7 +579,7 @@ static int i2o_block_open(struct block_device *bdev, fmode_t mode)
578 if (!dev->i2o_dev) 579 if (!dev->i2o_dev)
579 return -ENODEV; 580 return -ENODEV;
580 581
581 lock_kernel(); 582 mutex_lock(&i2o_block_mutex);
582 if (dev->power > 0x1f) 583 if (dev->power > 0x1f)
583 i2o_block_device_power(dev, 0x02); 584 i2o_block_device_power(dev, 0x02);
584 585
@@ -587,7 +588,7 @@ static int i2o_block_open(struct block_device *bdev, fmode_t mode)
587 i2o_block_device_lock(dev->i2o_dev, -1); 588 i2o_block_device_lock(dev->i2o_dev, -1);
588 589
589 osm_debug("Ready.\n"); 590 osm_debug("Ready.\n");
590 unlock_kernel(); 591 mutex_unlock(&i2o_block_mutex);
591 592
592 return 0; 593 return 0;
593}; 594};
@@ -618,7 +619,7 @@ static int i2o_block_release(struct gendisk *disk, fmode_t mode)
618 if (!dev->i2o_dev) 619 if (!dev->i2o_dev)
619 return 0; 620 return 0;
620 621
621 lock_kernel(); 622 mutex_lock(&i2o_block_mutex);
622 i2o_block_device_flush(dev->i2o_dev); 623 i2o_block_device_flush(dev->i2o_dev);
623 624
624 i2o_block_device_unlock(dev->i2o_dev, -1); 625 i2o_block_device_unlock(dev->i2o_dev, -1);
@@ -629,7 +630,7 @@ static int i2o_block_release(struct gendisk *disk, fmode_t mode)
629 operation = 0x24; 630 operation = 0x24;
630 631
631 i2o_block_device_power(dev, operation); 632 i2o_block_device_power(dev, operation);
632 unlock_kernel(); 633 mutex_unlock(&i2o_block_mutex);
633 634
634 return 0; 635 return 0;
635} 636}
@@ -664,7 +665,7 @@ static int i2o_block_ioctl(struct block_device *bdev, fmode_t mode,
664 if (!capable(CAP_SYS_ADMIN)) 665 if (!capable(CAP_SYS_ADMIN))
665 return -EPERM; 666 return -EPERM;
666 667
667 lock_kernel(); 668 mutex_lock(&i2o_block_mutex);
668 switch (cmd) { 669 switch (cmd) {
669 case BLKI2OGRSTRAT: 670 case BLKI2OGRSTRAT:
670 ret = put_user(dev->rcache, (int __user *)arg); 671 ret = put_user(dev->rcache, (int __user *)arg);
@@ -688,7 +689,7 @@ static int i2o_block_ioctl(struct block_device *bdev, fmode_t mode,
688 ret = 0; 689 ret = 0;
689 break; 690 break;
690 } 691 }
691 unlock_kernel(); 692 mutex_unlock(&i2o_block_mutex);
692 693
693 return ret; 694 return ret;
694}; 695};
diff --git a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c
index 068ba0785bb4..7d3cc575c361 100644
--- a/drivers/message/i2o/i2o_config.c
+++ b/drivers/message/i2o/i2o_config.c
@@ -31,7 +31,7 @@
31 */ 31 */
32 32
33#include <linux/miscdevice.h> 33#include <linux/miscdevice.h>
34#include <linux/smp_lock.h> 34#include <linux/mutex.h>
35#include <linux/compat.h> 35#include <linux/compat.h>
36#include <linux/slab.h> 36#include <linux/slab.h>
37 37
@@ -41,6 +41,7 @@
41 41
42#define SG_TABLESIZE 30 42#define SG_TABLESIZE 30
43 43
44static DEFINE_MUTEX(i2o_cfg_mutex);
44static long i2o_cfg_ioctl(struct file *, unsigned int, unsigned long); 45static long i2o_cfg_ioctl(struct file *, unsigned int, unsigned long);
45 46
46static spinlock_t i2o_config_lock; 47static spinlock_t i2o_config_lock;
@@ -741,7 +742,7 @@ static long i2o_cfg_compat_ioctl(struct file *file, unsigned cmd,
741 unsigned long arg) 742 unsigned long arg)
742{ 743{
743 int ret; 744 int ret;
744 lock_kernel(); 745 mutex_lock(&i2o_cfg_mutex);
745 switch (cmd) { 746 switch (cmd) {
746 case I2OGETIOPS: 747 case I2OGETIOPS:
747 ret = i2o_cfg_ioctl(file, cmd, arg); 748 ret = i2o_cfg_ioctl(file, cmd, arg);
@@ -753,7 +754,7 @@ static long i2o_cfg_compat_ioctl(struct file *file, unsigned cmd,
753 ret = -ENOIOCTLCMD; 754 ret = -ENOIOCTLCMD;
754 break; 755 break;
755 } 756 }
756 unlock_kernel(); 757 mutex_unlock(&i2o_cfg_mutex);
757 return ret; 758 return ret;
758} 759}
759 760
@@ -981,7 +982,7 @@ static long i2o_cfg_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
981{ 982{
982 int ret; 983 int ret;
983 984
984 lock_kernel(); 985 mutex_lock(&i2o_cfg_mutex);
985 switch (cmd) { 986 switch (cmd) {
986 case I2OGETIOPS: 987 case I2OGETIOPS:
987 ret = i2o_cfg_getiops(arg); 988 ret = i2o_cfg_getiops(arg);
@@ -1037,7 +1038,7 @@ static long i2o_cfg_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
1037 osm_debug("unknown ioctl called!\n"); 1038 osm_debug("unknown ioctl called!\n");
1038 ret = -EINVAL; 1039 ret = -EINVAL;
1039 } 1040 }
1040 unlock_kernel(); 1041 mutex_unlock(&i2o_cfg_mutex);
1041 return ret; 1042 return ret;
1042} 1043}
1043 1044
@@ -1051,7 +1052,7 @@ static int cfg_open(struct inode *inode, struct file *file)
1051 if (!tmp) 1052 if (!tmp)
1052 return -ENOMEM; 1053 return -ENOMEM;
1053 1054
1054 lock_kernel(); 1055 mutex_lock(&i2o_cfg_mutex);
1055 file->private_data = (void *)(i2o_cfg_info_id++); 1056 file->private_data = (void *)(i2o_cfg_info_id++);
1056 tmp->fp = file; 1057 tmp->fp = file;
1057 tmp->fasync = NULL; 1058 tmp->fasync = NULL;
@@ -1065,7 +1066,7 @@ static int cfg_open(struct inode *inode, struct file *file)
1065 spin_lock_irqsave(&i2o_config_lock, flags); 1066 spin_lock_irqsave(&i2o_config_lock, flags);
1066 open_files = tmp; 1067 open_files = tmp;
1067 spin_unlock_irqrestore(&i2o_config_lock, flags); 1068 spin_unlock_irqrestore(&i2o_config_lock, flags);
1068 unlock_kernel(); 1069 mutex_unlock(&i2o_cfg_mutex);
1069 1070
1070 return 0; 1071 return 0;
1071} 1072}
@@ -1076,14 +1077,14 @@ static int cfg_fasync(int fd, struct file *fp, int on)
1076 struct i2o_cfg_info *p; 1077 struct i2o_cfg_info *p;
1077 int ret = -EBADF; 1078 int ret = -EBADF;
1078 1079
1079 lock_kernel(); 1080 mutex_lock(&i2o_cfg_mutex);
1080 for (p = open_files; p; p = p->next) 1081 for (p = open_files; p; p = p->next)
1081 if (p->q_id == id) 1082 if (p->q_id == id)
1082 break; 1083 break;
1083 1084
1084 if (p) 1085 if (p)
1085 ret = fasync_helper(fd, fp, on, &p->fasync); 1086 ret = fasync_helper(fd, fp, on, &p->fasync);
1086 unlock_kernel(); 1087 mutex_unlock(&i2o_cfg_mutex);
1087 return ret; 1088 return ret;
1088} 1089}
1089 1090
@@ -1093,7 +1094,7 @@ static int cfg_release(struct inode *inode, struct file *file)
1093 struct i2o_cfg_info *p, **q; 1094 struct i2o_cfg_info *p, **q;
1094 unsigned long flags; 1095 unsigned long flags;
1095 1096
1096 lock_kernel(); 1097 mutex_lock(&i2o_cfg_mutex);
1097 spin_lock_irqsave(&i2o_config_lock, flags); 1098 spin_lock_irqsave(&i2o_config_lock, flags);
1098 for (q = &open_files; (p = *q) != NULL; q = &p->next) { 1099 for (q = &open_files; (p = *q) != NULL; q = &p->next) {
1099 if (p->q_id == id) { 1100 if (p->q_id == id) {
@@ -1103,7 +1104,7 @@ static int cfg_release(struct inode *inode, struct file *file)
1103 } 1104 }
1104 } 1105 }
1105 spin_unlock_irqrestore(&i2o_config_lock, flags); 1106 spin_unlock_irqrestore(&i2o_config_lock, flags);
1106 unlock_kernel(); 1107 mutex_unlock(&i2o_cfg_mutex);
1107 1108
1108 return 0; 1109 return 0;
1109} 1110}
diff --git a/drivers/mfd/ab3100-core.c b/drivers/mfd/ab3100-core.c
index 66379b413906..b048ecc56db9 100644
--- a/drivers/mfd/ab3100-core.c
+++ b/drivers/mfd/ab3100-core.c
@@ -583,6 +583,7 @@ static ssize_t ab3100_get_set_reg(struct file *file,
583static const struct file_operations ab3100_get_set_reg_fops = { 583static const struct file_operations ab3100_get_set_reg_fops = {
584 .open = ab3100_get_set_reg_open_file, 584 .open = ab3100_get_set_reg_open_file,
585 .write = ab3100_get_set_reg, 585 .write = ab3100_get_set_reg,
586 .llseek = noop_llseek,
586}; 587};
587 588
588static struct dentry *ab3100_dir; 589static struct dentry *ab3100_dir;
diff --git a/drivers/misc/hpilo.c b/drivers/misc/hpilo.c
index 557a8c2a7336..69c1f2fca141 100644
--- a/drivers/misc/hpilo.c
+++ b/drivers/misc/hpilo.c
@@ -640,6 +640,7 @@ static const struct file_operations ilo_fops = {
640 .poll = ilo_poll, 640 .poll = ilo_poll,
641 .open = ilo_open, 641 .open = ilo_open,
642 .release = ilo_close, 642 .release = ilo_close,
643 .llseek = noop_llseek,
643}; 644};
644 645
645static irqreturn_t ilo_isr(int irq, void *data) 646static irqreturn_t ilo_isr(int irq, void *data)
diff --git a/drivers/misc/ibmasm/ibmasmfs.c b/drivers/misc/ibmasm/ibmasmfs.c
index 8844a3f45381..af2497ae5fe3 100644
--- a/drivers/misc/ibmasm/ibmasmfs.c
+++ b/drivers/misc/ibmasm/ibmasmfs.c
@@ -584,6 +584,7 @@ static const struct file_operations command_fops = {
584 .release = command_file_close, 584 .release = command_file_close,
585 .read = command_file_read, 585 .read = command_file_read,
586 .write = command_file_write, 586 .write = command_file_write,
587 .llseek = generic_file_llseek,
587}; 588};
588 589
589static const struct file_operations event_fops = { 590static const struct file_operations event_fops = {
@@ -591,6 +592,7 @@ static const struct file_operations event_fops = {
591 .release = event_file_close, 592 .release = event_file_close,
592 .read = event_file_read, 593 .read = event_file_read,
593 .write = event_file_write, 594 .write = event_file_write,
595 .llseek = generic_file_llseek,
594}; 596};
595 597
596static const struct file_operations r_heartbeat_fops = { 598static const struct file_operations r_heartbeat_fops = {
@@ -598,6 +600,7 @@ static const struct file_operations r_heartbeat_fops = {
598 .release = r_heartbeat_file_close, 600 .release = r_heartbeat_file_close,
599 .read = r_heartbeat_file_read, 601 .read = r_heartbeat_file_read,
600 .write = r_heartbeat_file_write, 602 .write = r_heartbeat_file_write,
603 .llseek = generic_file_llseek,
601}; 604};
602 605
603static const struct file_operations remote_settings_fops = { 606static const struct file_operations remote_settings_fops = {
@@ -605,6 +608,7 @@ static const struct file_operations remote_settings_fops = {
605 .release = remote_settings_file_close, 608 .release = remote_settings_file_close,
606 .read = remote_settings_file_read, 609 .read = remote_settings_file_read,
607 .write = remote_settings_file_write, 610 .write = remote_settings_file_write,
611 .llseek = generic_file_llseek,
608}; 612};
609 613
610 614
diff --git a/drivers/misc/iwmc3200top/debugfs.c b/drivers/misc/iwmc3200top/debugfs.c
index e9eda471f6e0..62fbaec48207 100644
--- a/drivers/misc/iwmc3200top/debugfs.c
+++ b/drivers/misc/iwmc3200top/debugfs.c
@@ -71,6 +71,7 @@ ssize_t iwmct_dbgfs_##name##_write(struct file *file, \
71 static const struct file_operations iwmct_dbgfs_##name##_ops = { \ 71 static const struct file_operations iwmct_dbgfs_##name##_ops = { \
72 .read = iwmct_dbgfs_##name##_read, \ 72 .read = iwmct_dbgfs_##name##_read, \
73 .open = iwmct_dbgfs_open_file_generic, \ 73 .open = iwmct_dbgfs_open_file_generic, \
74 .llseek = generic_file_llseek, \
74 }; 75 };
75 76
76#define DEBUGFS_WRITE_FILE_OPS(name) \ 77#define DEBUGFS_WRITE_FILE_OPS(name) \
@@ -78,6 +79,7 @@ ssize_t iwmct_dbgfs_##name##_write(struct file *file, \
78 static const struct file_operations iwmct_dbgfs_##name##_ops = { \ 79 static const struct file_operations iwmct_dbgfs_##name##_ops = { \
79 .write = iwmct_dbgfs_##name##_write, \ 80 .write = iwmct_dbgfs_##name##_write, \
80 .open = iwmct_dbgfs_open_file_generic, \ 81 .open = iwmct_dbgfs_open_file_generic, \
82 .llseek = generic_file_llseek, \
81 }; 83 };
82 84
83#define DEBUGFS_READ_WRITE_FILE_OPS(name) \ 85#define DEBUGFS_READ_WRITE_FILE_OPS(name) \
@@ -87,6 +89,7 @@ ssize_t iwmct_dbgfs_##name##_write(struct file *file, \
87 .write = iwmct_dbgfs_##name##_write, \ 89 .write = iwmct_dbgfs_##name##_write, \
88 .read = iwmct_dbgfs_##name##_read, \ 90 .read = iwmct_dbgfs_##name##_read, \
89 .open = iwmct_dbgfs_open_file_generic, \ 91 .open = iwmct_dbgfs_open_file_generic, \
92 .llseek = generic_file_llseek, \
90 }; 93 };
91 94
92 95
diff --git a/drivers/misc/lkdtm.c b/drivers/misc/lkdtm.c
index ef34de7a8026..343b5d8ea697 100644
--- a/drivers/misc/lkdtm.c
+++ b/drivers/misc/lkdtm.c
@@ -575,30 +575,39 @@ struct crash_entry {
575 575
576static const struct crash_entry crash_entries[] = { 576static const struct crash_entry crash_entries[] = {
577 {"DIRECT", {.read = lkdtm_debugfs_read, 577 {"DIRECT", {.read = lkdtm_debugfs_read,
578 .llseek = generic_file_llseek,
578 .open = lkdtm_debugfs_open, 579 .open = lkdtm_debugfs_open,
579 .write = direct_entry} }, 580 .write = direct_entry} },
580 {"INT_HARDWARE_ENTRY", {.read = lkdtm_debugfs_read, 581 {"INT_HARDWARE_ENTRY", {.read = lkdtm_debugfs_read,
582 .llseek = generic_file_llseek,
581 .open = lkdtm_debugfs_open, 583 .open = lkdtm_debugfs_open,
582 .write = int_hardware_entry} }, 584 .write = int_hardware_entry} },
583 {"INT_HW_IRQ_EN", {.read = lkdtm_debugfs_read, 585 {"INT_HW_IRQ_EN", {.read = lkdtm_debugfs_read,
586 .llseek = generic_file_llseek,
584 .open = lkdtm_debugfs_open, 587 .open = lkdtm_debugfs_open,
585 .write = int_hw_irq_en} }, 588 .write = int_hw_irq_en} },
586 {"INT_TASKLET_ENTRY", {.read = lkdtm_debugfs_read, 589 {"INT_TASKLET_ENTRY", {.read = lkdtm_debugfs_read,
590 .llseek = generic_file_llseek,
587 .open = lkdtm_debugfs_open, 591 .open = lkdtm_debugfs_open,
588 .write = int_tasklet_entry} }, 592 .write = int_tasklet_entry} },
589 {"FS_DEVRW", {.read = lkdtm_debugfs_read, 593 {"FS_DEVRW", {.read = lkdtm_debugfs_read,
594 .llseek = generic_file_llseek,
590 .open = lkdtm_debugfs_open, 595 .open = lkdtm_debugfs_open,
591 .write = fs_devrw_entry} }, 596 .write = fs_devrw_entry} },
592 {"MEM_SWAPOUT", {.read = lkdtm_debugfs_read, 597 {"MEM_SWAPOUT", {.read = lkdtm_debugfs_read,
598 .llseek = generic_file_llseek,
593 .open = lkdtm_debugfs_open, 599 .open = lkdtm_debugfs_open,
594 .write = mem_swapout_entry} }, 600 .write = mem_swapout_entry} },
595 {"TIMERADD", {.read = lkdtm_debugfs_read, 601 {"TIMERADD", {.read = lkdtm_debugfs_read,
602 .llseek = generic_file_llseek,
596 .open = lkdtm_debugfs_open, 603 .open = lkdtm_debugfs_open,
597 .write = timeradd_entry} }, 604 .write = timeradd_entry} },
598 {"SCSI_DISPATCH_CMD", {.read = lkdtm_debugfs_read, 605 {"SCSI_DISPATCH_CMD", {.read = lkdtm_debugfs_read,
606 .llseek = generic_file_llseek,
599 .open = lkdtm_debugfs_open, 607 .open = lkdtm_debugfs_open,
600 .write = scsi_dispatch_cmd_entry} }, 608 .write = scsi_dispatch_cmd_entry} },
601 {"IDE_CORE_CP", {.read = lkdtm_debugfs_read, 609 {"IDE_CORE_CP", {.read = lkdtm_debugfs_read,
610 .llseek = generic_file_llseek,
602 .open = lkdtm_debugfs_open, 611 .open = lkdtm_debugfs_open,
603 .write = ide_core_cp_entry} }, 612 .write = ide_core_cp_entry} },
604}; 613};
diff --git a/drivers/misc/phantom.c b/drivers/misc/phantom.c
index 75ee0d3f6f45..4197a3cb26ba 100644
--- a/drivers/misc/phantom.c
+++ b/drivers/misc/phantom.c
@@ -24,7 +24,7 @@
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/phantom.h> 25#include <linux/phantom.h>
26#include <linux/sched.h> 26#include <linux/sched.h>
27#include <linux/smp_lock.h> 27#include <linux/mutex.h>
28 28
29#include <asm/atomic.h> 29#include <asm/atomic.h>
30#include <asm/io.h> 30#include <asm/io.h>
@@ -38,6 +38,7 @@
38#define PHB_RUNNING 1 38#define PHB_RUNNING 1
39#define PHB_NOT_OH 2 39#define PHB_NOT_OH 2
40 40
41static DEFINE_MUTEX(phantom_mutex);
41static struct class *phantom_class; 42static struct class *phantom_class;
42static int phantom_major; 43static int phantom_major;
43 44
@@ -215,17 +216,17 @@ static int phantom_open(struct inode *inode, struct file *file)
215 struct phantom_device *dev = container_of(inode->i_cdev, 216 struct phantom_device *dev = container_of(inode->i_cdev,
216 struct phantom_device, cdev); 217 struct phantom_device, cdev);
217 218
218 lock_kernel(); 219 mutex_lock(&phantom_mutex);
219 nonseekable_open(inode, file); 220 nonseekable_open(inode, file);
220 221
221 if (mutex_lock_interruptible(&dev->open_lock)) { 222 if (mutex_lock_interruptible(&dev->open_lock)) {
222 unlock_kernel(); 223 mutex_unlock(&phantom_mutex);
223 return -ERESTARTSYS; 224 return -ERESTARTSYS;
224 } 225 }
225 226
226 if (dev->opened) { 227 if (dev->opened) {
227 mutex_unlock(&dev->open_lock); 228 mutex_unlock(&dev->open_lock);
228 unlock_kernel(); 229 mutex_unlock(&phantom_mutex);
229 return -EINVAL; 230 return -EINVAL;
230 } 231 }
231 232
@@ -236,7 +237,7 @@ static int phantom_open(struct inode *inode, struct file *file)
236 atomic_set(&dev->counter, 0); 237 atomic_set(&dev->counter, 0);
237 dev->opened++; 238 dev->opened++;
238 mutex_unlock(&dev->open_lock); 239 mutex_unlock(&dev->open_lock);
239 unlock_kernel(); 240 mutex_unlock(&phantom_mutex);
240 return 0; 241 return 0;
241} 242}
242 243
@@ -279,6 +280,7 @@ static const struct file_operations phantom_file_ops = {
279 .unlocked_ioctl = phantom_ioctl, 280 .unlocked_ioctl = phantom_ioctl,
280 .compat_ioctl = phantom_compat_ioctl, 281 .compat_ioctl = phantom_compat_ioctl,
281 .poll = phantom_poll, 282 .poll = phantom_poll,
283 .llseek = no_llseek,
282}; 284};
283 285
284static irqreturn_t phantom_isr(int irq, void *data) 286static irqreturn_t phantom_isr(int irq, void *data)
diff --git a/drivers/misc/sgi-gru/grufile.c b/drivers/misc/sgi-gru/grufile.c
index cb3b4d228475..28852dfa310d 100644
--- a/drivers/misc/sgi-gru/grufile.c
+++ b/drivers/misc/sgi-gru/grufile.c
@@ -587,6 +587,7 @@ static const struct file_operations gru_fops = {
587 .owner = THIS_MODULE, 587 .owner = THIS_MODULE,
588 .unlocked_ioctl = gru_file_unlocked_ioctl, 588 .unlocked_ioctl = gru_file_unlocked_ioctl,
589 .mmap = gru_file_mmap, 589 .mmap = gru_file_mmap,
590 .llseek = noop_llseek,
590}; 591};
591 592
592static struct miscdevice gru_miscdev = { 593static struct miscdevice gru_miscdev = {
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index d545f79f6000..00073b7c0368 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -29,7 +29,6 @@
29#include <linux/kdev_t.h> 29#include <linux/kdev_t.h>
30#include <linux/blkdev.h> 30#include <linux/blkdev.h>
31#include <linux/mutex.h> 31#include <linux/mutex.h>
32#include <linux/smp_lock.h>
33#include <linux/scatterlist.h> 32#include <linux/scatterlist.h>
34#include <linux/string_helpers.h> 33#include <linux/string_helpers.h>
35 34
@@ -51,6 +50,7 @@ MODULE_ALIAS("mmc:block");
51#define MMC_SHIFT 3 50#define MMC_SHIFT 3
52#define MMC_NUM_MINORS (256 >> MMC_SHIFT) 51#define MMC_NUM_MINORS (256 >> MMC_SHIFT)
53 52
53static DEFINE_MUTEX(block_mutex);
54static DECLARE_BITMAP(dev_use, MMC_NUM_MINORS); 54static DECLARE_BITMAP(dev_use, MMC_NUM_MINORS);
55 55
56/* 56/*
@@ -108,7 +108,7 @@ static int mmc_blk_open(struct block_device *bdev, fmode_t mode)
108 struct mmc_blk_data *md = mmc_blk_get(bdev->bd_disk); 108 struct mmc_blk_data *md = mmc_blk_get(bdev->bd_disk);
109 int ret = -ENXIO; 109 int ret = -ENXIO;
110 110
111 lock_kernel(); 111 mutex_lock(&block_mutex);
112 if (md) { 112 if (md) {
113 if (md->usage == 2) 113 if (md->usage == 2)
114 check_disk_change(bdev); 114 check_disk_change(bdev);
@@ -119,7 +119,7 @@ static int mmc_blk_open(struct block_device *bdev, fmode_t mode)
119 ret = -EROFS; 119 ret = -EROFS;
120 } 120 }
121 } 121 }
122 unlock_kernel(); 122 mutex_unlock(&block_mutex);
123 123
124 return ret; 124 return ret;
125} 125}
@@ -128,9 +128,9 @@ static int mmc_blk_release(struct gendisk *disk, fmode_t mode)
128{ 128{
129 struct mmc_blk_data *md = disk->private_data; 129 struct mmc_blk_data *md = disk->private_data;
130 130
131 lock_kernel(); 131 mutex_lock(&block_mutex);
132 mmc_blk_put(md); 132 mmc_blk_put(md);
133 unlock_kernel(); 133 mutex_unlock(&block_mutex);
134 return 0; 134 return 0;
135} 135}
136 136
diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c
index 53cb380c0987..46bc6d7551a3 100644
--- a/drivers/mmc/core/debugfs.c
+++ b/drivers/mmc/core/debugfs.c
@@ -245,6 +245,7 @@ static const struct file_operations mmc_dbg_ext_csd_fops = {
245 .open = mmc_ext_csd_open, 245 .open = mmc_ext_csd_open,
246 .read = mmc_ext_csd_read, 246 .read = mmc_ext_csd_read,
247 .release = mmc_ext_csd_release, 247 .release = mmc_ext_csd_release,
248 .llseek = default_llseek,
248}; 249};
249 250
250void mmc_add_card_debugfs(struct mmc_card *card) 251void mmc_add_card_debugfs(struct mmc_card *card)
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index 62e68707b07f..50ab431b24eb 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -29,7 +29,6 @@
29#include <linux/blkdev.h> 29#include <linux/blkdev.h>
30#include <linux/blkpg.h> 30#include <linux/blkpg.h>
31#include <linux/spinlock.h> 31#include <linux/spinlock.h>
32#include <linux/smp_lock.h>
33#include <linux/hdreg.h> 32#include <linux/hdreg.h>
34#include <linux/init.h> 33#include <linux/init.h>
35#include <linux/mutex.h> 34#include <linux/mutex.h>
@@ -38,6 +37,7 @@
38 37
39#include "mtdcore.h" 38#include "mtdcore.h"
40 39
40static DEFINE_MUTEX(mtd_blkdevs_mutex);
41static LIST_HEAD(blktrans_majors); 41static LIST_HEAD(blktrans_majors);
42static DEFINE_MUTEX(blktrans_ref_mutex); 42static DEFINE_MUTEX(blktrans_ref_mutex);
43 43
@@ -181,7 +181,7 @@ static int blktrans_open(struct block_device *bdev, fmode_t mode)
181 if (!dev) 181 if (!dev)
182 return -ERESTARTSYS; /* FIXME: busy loop! -arnd*/ 182 return -ERESTARTSYS; /* FIXME: busy loop! -arnd*/
183 183
184 lock_kernel(); 184 mutex_lock(&mtd_blkdevs_mutex);
185 mutex_lock(&dev->lock); 185 mutex_lock(&dev->lock);
186 186
187 if (!dev->mtd) { 187 if (!dev->mtd) {
@@ -198,7 +198,7 @@ static int blktrans_open(struct block_device *bdev, fmode_t mode)
198unlock: 198unlock:
199 mutex_unlock(&dev->lock); 199 mutex_unlock(&dev->lock);
200 blktrans_dev_put(dev); 200 blktrans_dev_put(dev);
201 unlock_kernel(); 201 mutex_unlock(&mtd_blkdevs_mutex);
202 return ret; 202 return ret;
203} 203}
204 204
@@ -210,7 +210,7 @@ static int blktrans_release(struct gendisk *disk, fmode_t mode)
210 if (!dev) 210 if (!dev)
211 return ret; 211 return ret;
212 212
213 lock_kernel(); 213 mutex_lock(&mtd_blkdevs_mutex);
214 mutex_lock(&dev->lock); 214 mutex_lock(&dev->lock);
215 215
216 /* Release one reference, we sure its not the last one here*/ 216 /* Release one reference, we sure its not the last one here*/
@@ -223,7 +223,7 @@ static int blktrans_release(struct gendisk *disk, fmode_t mode)
223unlock: 223unlock:
224 mutex_unlock(&dev->lock); 224 mutex_unlock(&dev->lock);
225 blktrans_dev_put(dev); 225 blktrans_dev_put(dev);
226 unlock_kernel(); 226 mutex_unlock(&mtd_blkdevs_mutex);
227 return ret; 227 return ret;
228} 228}
229 229
@@ -256,7 +256,7 @@ static int blktrans_ioctl(struct block_device *bdev, fmode_t mode,
256 if (!dev) 256 if (!dev)
257 return ret; 257 return ret;
258 258
259 lock_kernel(); 259 mutex_lock(&mtd_blkdevs_mutex);
260 mutex_lock(&dev->lock); 260 mutex_lock(&dev->lock);
261 261
262 if (!dev->mtd) 262 if (!dev->mtd)
@@ -271,7 +271,7 @@ static int blktrans_ioctl(struct block_device *bdev, fmode_t mode,
271 } 271 }
272unlock: 272unlock:
273 mutex_unlock(&dev->lock); 273 mutex_unlock(&dev->lock);
274 unlock_kernel(); 274 mutex_unlock(&mtd_blkdevs_mutex);
275 blktrans_dev_put(dev); 275 blktrans_dev_put(dev);
276 return ret; 276 return ret;
277} 277}
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index a825002123c8..5ef45487b65f 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -26,7 +26,7 @@
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/sched.h> 28#include <linux/sched.h>
29#include <linux/smp_lock.h> 29#include <linux/mutex.h>
30#include <linux/backing-dev.h> 30#include <linux/backing-dev.h>
31#include <linux/compat.h> 31#include <linux/compat.h>
32#include <linux/mount.h> 32#include <linux/mount.h>
@@ -37,6 +37,7 @@
37#include <asm/uaccess.h> 37#include <asm/uaccess.h>
38 38
39#define MTD_INODE_FS_MAGIC 0x11307854 39#define MTD_INODE_FS_MAGIC 0x11307854
40static DEFINE_MUTEX(mtd_mutex);
40static struct vfsmount *mtd_inode_mnt __read_mostly; 41static struct vfsmount *mtd_inode_mnt __read_mostly;
41 42
42/* 43/*
@@ -90,7 +91,7 @@ static int mtd_open(struct inode *inode, struct file *file)
90 if ((file->f_mode & FMODE_WRITE) && (minor & 1)) 91 if ((file->f_mode & FMODE_WRITE) && (minor & 1))
91 return -EACCES; 92 return -EACCES;
92 93
93 lock_kernel(); 94 mutex_lock(&mtd_mutex);
94 mtd = get_mtd_device(NULL, devnum); 95 mtd = get_mtd_device(NULL, devnum);
95 96
96 if (IS_ERR(mtd)) { 97 if (IS_ERR(mtd)) {
@@ -138,7 +139,7 @@ static int mtd_open(struct inode *inode, struct file *file)
138 file->private_data = mfi; 139 file->private_data = mfi;
139 140
140out: 141out:
141 unlock_kernel(); 142 mutex_unlock(&mtd_mutex);
142 return ret; 143 return ret;
143} /* mtd_open */ 144} /* mtd_open */
144 145
@@ -866,9 +867,9 @@ static long mtd_unlocked_ioctl(struct file *file, u_int cmd, u_long arg)
866{ 867{
867 int ret; 868 int ret;
868 869
869 lock_kernel(); 870 mutex_lock(&mtd_mutex);
870 ret = mtd_ioctl(file, cmd, arg); 871 ret = mtd_ioctl(file, cmd, arg);
871 unlock_kernel(); 872 mutex_unlock(&mtd_mutex);
872 873
873 return ret; 874 return ret;
874} 875}
@@ -892,7 +893,7 @@ static long mtd_compat_ioctl(struct file *file, unsigned int cmd,
892 void __user *argp = compat_ptr(arg); 893 void __user *argp = compat_ptr(arg);
893 int ret = 0; 894 int ret = 0;
894 895
895 lock_kernel(); 896 mutex_lock(&mtd_mutex);
896 897
897 switch (cmd) { 898 switch (cmd) {
898 case MEMWRITEOOB32: 899 case MEMWRITEOOB32:
@@ -927,7 +928,7 @@ static long mtd_compat_ioctl(struct file *file, unsigned int cmd,
927 ret = mtd_ioctl(file, cmd, (unsigned long)argp); 928 ret = mtd_ioctl(file, cmd, (unsigned long)argp);
928 } 929 }
929 930
930 unlock_kernel(); 931 mutex_unlock(&mtd_mutex);
931 932
932 return ret; 933 return ret;
933} 934}
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
index 3d2d1a69e9a0..af9fb0ff8210 100644
--- a/drivers/mtd/ubi/cdev.c
+++ b/drivers/mtd/ubi/cdev.c
@@ -1100,4 +1100,5 @@ const struct file_operations ubi_ctrl_cdev_operations = {
1100 .owner = THIS_MODULE, 1100 .owner = THIS_MODULE,
1101 .unlocked_ioctl = ctrl_cdev_ioctl, 1101 .unlocked_ioctl = ctrl_cdev_ioctl,
1102 .compat_ioctl = ctrl_cdev_compat_ioctl, 1102 .compat_ioctl = ctrl_cdev_compat_ioctl,
1103 .llseek = noop_llseek,
1103}; 1104};
diff --git a/drivers/net/appletalk/Kconfig b/drivers/net/appletalk/Kconfig
index 0a0e0cd81a23..20f97e7017ce 100644
--- a/drivers/net/appletalk/Kconfig
+++ b/drivers/net/appletalk/Kconfig
@@ -3,6 +3,7 @@
3# 3#
4config ATALK 4config ATALK
5 tristate "Appletalk protocol support" 5 tristate "Appletalk protocol support"
6 depends on BKL # waiting to be removed from net/appletalk/ddp.c
6 select LLC 7 select LLC
7 ---help--- 8 ---help---
8 AppleTalk is the protocol that Apple computers can use to communicate 9 AppleTalk is the protocol that Apple computers can use to communicate
diff --git a/drivers/net/caif/caif_spi.c b/drivers/net/caif/caif_spi.c
index f5058ff2b210..8427533fe313 100644
--- a/drivers/net/caif/caif_spi.c
+++ b/drivers/net/caif/caif_spi.c
@@ -240,13 +240,15 @@ static ssize_t dbgfs_frame(struct file *file, char __user *user_buf,
240static const struct file_operations dbgfs_state_fops = { 240static const struct file_operations dbgfs_state_fops = {
241 .open = dbgfs_open, 241 .open = dbgfs_open,
242 .read = dbgfs_state, 242 .read = dbgfs_state,
243 .owner = THIS_MODULE 243 .owner = THIS_MODULE,
244 .llseek = default_llseek,
244}; 245};
245 246
246static const struct file_operations dbgfs_frame_fops = { 247static const struct file_operations dbgfs_frame_fops = {
247 .open = dbgfs_open, 248 .open = dbgfs_open,
248 .read = dbgfs_frame, 249 .read = dbgfs_frame,
249 .owner = THIS_MODULE 250 .owner = THIS_MODULE,
251 .llseek = default_llseek,
250}; 252};
251 253
252static inline void dev_debugfs_add(struct cfspi *cfspi) 254static inline void dev_debugfs_add(struct cfspi *cfspi)
diff --git a/drivers/net/cxgb4/cxgb4_main.c b/drivers/net/cxgb4/cxgb4_main.c
index c327527fbbc8..e2bf10d90add 100644
--- a/drivers/net/cxgb4/cxgb4_main.c
+++ b/drivers/net/cxgb4/cxgb4_main.c
@@ -2026,6 +2026,7 @@ static const struct file_operations mem_debugfs_fops = {
2026 .owner = THIS_MODULE, 2026 .owner = THIS_MODULE,
2027 .open = mem_open, 2027 .open = mem_open,
2028 .read = mem_read, 2028 .read = mem_read,
2029 .llseek = default_llseek,
2029}; 2030};
2030 2031
2031static void __devinit add_debugfs_mem(struct adapter *adap, const char *name, 2032static void __devinit add_debugfs_mem(struct adapter *adap, const char *name,
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index 736b91703b3e..4bddb2afdd15 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -856,7 +856,8 @@ static const struct file_operations ppp_device_fops = {
856 .poll = ppp_poll, 856 .poll = ppp_poll,
857 .unlocked_ioctl = ppp_ioctl, 857 .unlocked_ioctl = ppp_ioctl,
858 .open = ppp_open, 858 .open = ppp_open,
859 .release = ppp_release 859 .release = ppp_release,
860 .llseek = noop_llseek,
860}; 861};
861 862
862static __net_init int ppp_init_net(struct net *net) 863static __net_init int ppp_init_net(struct net *net)
diff --git a/drivers/net/wimax/i2400m/debugfs.c b/drivers/net/wimax/i2400m/debugfs.c
index b1aec3e1892f..9c70b5fa3f51 100644
--- a/drivers/net/wimax/i2400m/debugfs.c
+++ b/drivers/net/wimax/i2400m/debugfs.c
@@ -119,6 +119,7 @@ const struct file_operations i2400m_rx_stats_fops = {
119 .open = i2400m_stats_open, 119 .open = i2400m_stats_open,
120 .read = i2400m_rx_stats_read, 120 .read = i2400m_rx_stats_read,
121 .write = i2400m_rx_stats_write, 121 .write = i2400m_rx_stats_write,
122 .llseek = default_llseek,
122}; 123};
123 124
124 125
@@ -171,6 +172,7 @@ const struct file_operations i2400m_tx_stats_fops = {
171 .open = i2400m_stats_open, 172 .open = i2400m_stats_open,
172 .read = i2400m_tx_stats_read, 173 .read = i2400m_tx_stats_read,
173 .write = i2400m_tx_stats_write, 174 .write = i2400m_tx_stats_write,
175 .llseek = default_llseek,
174}; 176};
175 177
176 178
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 1d05445d4ba3..ce77575e88b3 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -4430,21 +4430,24 @@ static const struct file_operations proc_statsdelta_ops = {
4430 .owner = THIS_MODULE, 4430 .owner = THIS_MODULE,
4431 .read = proc_read, 4431 .read = proc_read,
4432 .open = proc_statsdelta_open, 4432 .open = proc_statsdelta_open,
4433 .release = proc_close 4433 .release = proc_close,
4434 .llseek = default_llseek,
4434}; 4435};
4435 4436
4436static const struct file_operations proc_stats_ops = { 4437static const struct file_operations proc_stats_ops = {
4437 .owner = THIS_MODULE, 4438 .owner = THIS_MODULE,
4438 .read = proc_read, 4439 .read = proc_read,
4439 .open = proc_stats_open, 4440 .open = proc_stats_open,
4440 .release = proc_close 4441 .release = proc_close,
4442 .llseek = default_llseek,
4441}; 4443};
4442 4444
4443static const struct file_operations proc_status_ops = { 4445static const struct file_operations proc_status_ops = {
4444 .owner = THIS_MODULE, 4446 .owner = THIS_MODULE,
4445 .read = proc_read, 4447 .read = proc_read,
4446 .open = proc_status_open, 4448 .open = proc_status_open,
4447 .release = proc_close 4449 .release = proc_close,
4450 .llseek = default_llseek,
4448}; 4451};
4449 4452
4450static const struct file_operations proc_SSID_ops = { 4453static const struct file_operations proc_SSID_ops = {
@@ -4452,7 +4455,8 @@ static const struct file_operations proc_SSID_ops = {
4452 .read = proc_read, 4455 .read = proc_read,
4453 .write = proc_write, 4456 .write = proc_write,
4454 .open = proc_SSID_open, 4457 .open = proc_SSID_open,
4455 .release = proc_close 4458 .release = proc_close,
4459 .llseek = default_llseek,
4456}; 4460};
4457 4461
4458static const struct file_operations proc_BSSList_ops = { 4462static const struct file_operations proc_BSSList_ops = {
@@ -4460,7 +4464,8 @@ static const struct file_operations proc_BSSList_ops = {
4460 .read = proc_read, 4464 .read = proc_read,
4461 .write = proc_write, 4465 .write = proc_write,
4462 .open = proc_BSSList_open, 4466 .open = proc_BSSList_open,
4463 .release = proc_close 4467 .release = proc_close,
4468 .llseek = default_llseek,
4464}; 4469};
4465 4470
4466static const struct file_operations proc_APList_ops = { 4471static const struct file_operations proc_APList_ops = {
@@ -4468,7 +4473,8 @@ static const struct file_operations proc_APList_ops = {
4468 .read = proc_read, 4473 .read = proc_read,
4469 .write = proc_write, 4474 .write = proc_write,
4470 .open = proc_APList_open, 4475 .open = proc_APList_open,
4471 .release = proc_close 4476 .release = proc_close,
4477 .llseek = default_llseek,
4472}; 4478};
4473 4479
4474static const struct file_operations proc_config_ops = { 4480static const struct file_operations proc_config_ops = {
@@ -4476,7 +4482,8 @@ static const struct file_operations proc_config_ops = {
4476 .read = proc_read, 4482 .read = proc_read,
4477 .write = proc_write, 4483 .write = proc_write,
4478 .open = proc_config_open, 4484 .open = proc_config_open,
4479 .release = proc_close 4485 .release = proc_close,
4486 .llseek = default_llseek,
4480}; 4487};
4481 4488
4482static const struct file_operations proc_wepkey_ops = { 4489static const struct file_operations proc_wepkey_ops = {
@@ -4484,7 +4491,8 @@ static const struct file_operations proc_wepkey_ops = {
4484 .read = proc_read, 4491 .read = proc_read,
4485 .write = proc_write, 4492 .write = proc_write,
4486 .open = proc_wepkey_open, 4493 .open = proc_wepkey_open,
4487 .release = proc_close 4494 .release = proc_close,
4495 .llseek = default_llseek,
4488}; 4496};
4489 4497
4490static struct proc_dir_entry *airo_entry; 4498static struct proc_dir_entry *airo_entry;
diff --git a/drivers/net/wireless/ath/ath5k/debug.c b/drivers/net/wireless/ath/ath5k/debug.c
index 4cccc29964f6..fb339c3852ee 100644
--- a/drivers/net/wireless/ath/ath5k/debug.c
+++ b/drivers/net/wireless/ath/ath5k/debug.c
@@ -271,6 +271,7 @@ static const struct file_operations fops_beacon = {
271 .write = write_file_beacon, 271 .write = write_file_beacon,
272 .open = ath5k_debugfs_open, 272 .open = ath5k_debugfs_open,
273 .owner = THIS_MODULE, 273 .owner = THIS_MODULE,
274 .llseek = default_llseek,
274}; 275};
275 276
276 277
@@ -290,6 +291,7 @@ static const struct file_operations fops_reset = {
290 .write = write_file_reset, 291 .write = write_file_reset,
291 .open = ath5k_debugfs_open, 292 .open = ath5k_debugfs_open,
292 .owner = THIS_MODULE, 293 .owner = THIS_MODULE,
294 .llseek = noop_llseek,
293}; 295};
294 296
295 297
@@ -369,6 +371,7 @@ static const struct file_operations fops_debug = {
369 .write = write_file_debug, 371 .write = write_file_debug,
370 .open = ath5k_debugfs_open, 372 .open = ath5k_debugfs_open,
371 .owner = THIS_MODULE, 373 .owner = THIS_MODULE,
374 .llseek = default_llseek,
372}; 375};
373 376
374 377
@@ -480,6 +483,7 @@ static const struct file_operations fops_antenna = {
480 .write = write_file_antenna, 483 .write = write_file_antenna,
481 .open = ath5k_debugfs_open, 484 .open = ath5k_debugfs_open,
482 .owner = THIS_MODULE, 485 .owner = THIS_MODULE,
486 .llseek = default_llseek,
483}; 487};
484 488
485 489
@@ -591,6 +595,7 @@ static const struct file_operations fops_frameerrors = {
591 .write = write_file_frameerrors, 595 .write = write_file_frameerrors,
592 .open = ath5k_debugfs_open, 596 .open = ath5k_debugfs_open,
593 .owner = THIS_MODULE, 597 .owner = THIS_MODULE,
598 .llseek = default_llseek,
594}; 599};
595 600
596 601
@@ -748,6 +753,7 @@ static const struct file_operations fops_ani = {
748 .write = write_file_ani, 753 .write = write_file_ani,
749 .open = ath5k_debugfs_open, 754 .open = ath5k_debugfs_open,
750 .owner = THIS_MODULE, 755 .owner = THIS_MODULE,
756 .llseek = default_llseek,
751}; 757};
752 758
753 759
@@ -811,6 +817,7 @@ static const struct file_operations fops_queue = {
811 .write = write_file_queue, 817 .write = write_file_queue,
812 .open = ath5k_debugfs_open, 818 .open = ath5k_debugfs_open,
813 .owner = THIS_MODULE, 819 .owner = THIS_MODULE,
820 .llseek = default_llseek,
814}; 821};
815 822
816 823
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index 54aae931424e..cf500bf25ad5 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -71,7 +71,8 @@ static const struct file_operations fops_debug = {
71 .read = read_file_debug, 71 .read = read_file_debug,
72 .write = write_file_debug, 72 .write = write_file_debug,
73 .open = ath9k_debugfs_open, 73 .open = ath9k_debugfs_open,
74 .owner = THIS_MODULE 74 .owner = THIS_MODULE,
75 .llseek = default_llseek,
75}; 76};
76 77
77#endif 78#endif
@@ -116,7 +117,8 @@ static const struct file_operations fops_tx_chainmask = {
116 .read = read_file_tx_chainmask, 117 .read = read_file_tx_chainmask,
117 .write = write_file_tx_chainmask, 118 .write = write_file_tx_chainmask,
118 .open = ath9k_debugfs_open, 119 .open = ath9k_debugfs_open,
119 .owner = THIS_MODULE 120 .owner = THIS_MODULE,
121 .llseek = default_llseek,
120}; 122};
121 123
122 124
@@ -158,7 +160,8 @@ static const struct file_operations fops_rx_chainmask = {
158 .read = read_file_rx_chainmask, 160 .read = read_file_rx_chainmask,
159 .write = write_file_rx_chainmask, 161 .write = write_file_rx_chainmask,
160 .open = ath9k_debugfs_open, 162 .open = ath9k_debugfs_open,
161 .owner = THIS_MODULE 163 .owner = THIS_MODULE,
164 .llseek = default_llseek,
162}; 165};
163 166
164 167
@@ -259,7 +262,8 @@ static ssize_t read_file_dma(struct file *file, char __user *user_buf,
259static const struct file_operations fops_dma = { 262static const struct file_operations fops_dma = {
260 .read = read_file_dma, 263 .read = read_file_dma,
261 .open = ath9k_debugfs_open, 264 .open = ath9k_debugfs_open,
262 .owner = THIS_MODULE 265 .owner = THIS_MODULE,
266 .llseek = default_llseek,
263}; 267};
264 268
265 269
@@ -375,7 +379,8 @@ static ssize_t read_file_interrupt(struct file *file, char __user *user_buf,
375static const struct file_operations fops_interrupt = { 379static const struct file_operations fops_interrupt = {
376 .read = read_file_interrupt, 380 .read = read_file_interrupt,
377 .open = ath9k_debugfs_open, 381 .open = ath9k_debugfs_open,
378 .owner = THIS_MODULE 382 .owner = THIS_MODULE,
383 .llseek = default_llseek,
379}; 384};
380 385
381void ath_debug_stat_rc(struct ath_softc *sc, int final_rate) 386void ath_debug_stat_rc(struct ath_softc *sc, int final_rate)
@@ -464,7 +469,8 @@ static ssize_t read_file_rcstat(struct file *file, char __user *user_buf,
464static const struct file_operations fops_rcstat = { 469static const struct file_operations fops_rcstat = {
465 .read = read_file_rcstat, 470 .read = read_file_rcstat,
466 .open = ath9k_debugfs_open, 471 .open = ath9k_debugfs_open,
467 .owner = THIS_MODULE 472 .owner = THIS_MODULE,
473 .llseek = default_llseek,
468}; 474};
469 475
470static const char * ath_wiphy_state_str(enum ath_wiphy_state state) 476static const char * ath_wiphy_state_str(enum ath_wiphy_state state)
@@ -623,7 +629,8 @@ static const struct file_operations fops_wiphy = {
623 .read = read_file_wiphy, 629 .read = read_file_wiphy,
624 .write = write_file_wiphy, 630 .write = write_file_wiphy,
625 .open = ath9k_debugfs_open, 631 .open = ath9k_debugfs_open,
626 .owner = THIS_MODULE 632 .owner = THIS_MODULE,
633 .llseek = default_llseek,
627}; 634};
628 635
629#define PR(str, elem) \ 636#define PR(str, elem) \
@@ -702,7 +709,8 @@ void ath_debug_stat_tx(struct ath_softc *sc, struct ath_txq *txq,
702static const struct file_operations fops_xmit = { 709static const struct file_operations fops_xmit = {
703 .read = read_file_xmit, 710 .read = read_file_xmit,
704 .open = ath9k_debugfs_open, 711 .open = ath9k_debugfs_open,
705 .owner = THIS_MODULE 712 .owner = THIS_MODULE,
713 .llseek = default_llseek,
706}; 714};
707 715
708static ssize_t read_file_recv(struct file *file, char __user *user_buf, 716static ssize_t read_file_recv(struct file *file, char __user *user_buf,
@@ -814,7 +822,8 @@ void ath_debug_stat_rx(struct ath_softc *sc, struct ath_rx_status *rs)
814static const struct file_operations fops_recv = { 822static const struct file_operations fops_recv = {
815 .read = read_file_recv, 823 .read = read_file_recv,
816 .open = ath9k_debugfs_open, 824 .open = ath9k_debugfs_open,
817 .owner = THIS_MODULE 825 .owner = THIS_MODULE,
826 .llseek = default_llseek,
818}; 827};
819 828
820static ssize_t read_file_regidx(struct file *file, char __user *user_buf, 829static ssize_t read_file_regidx(struct file *file, char __user *user_buf,
@@ -852,7 +861,8 @@ static const struct file_operations fops_regidx = {
852 .read = read_file_regidx, 861 .read = read_file_regidx,
853 .write = write_file_regidx, 862 .write = write_file_regidx,
854 .open = ath9k_debugfs_open, 863 .open = ath9k_debugfs_open,
855 .owner = THIS_MODULE 864 .owner = THIS_MODULE,
865 .llseek = default_llseek,
856}; 866};
857 867
858static ssize_t read_file_regval(struct file *file, char __user *user_buf, 868static ssize_t read_file_regval(struct file *file, char __user *user_buf,
@@ -894,7 +904,8 @@ static const struct file_operations fops_regval = {
894 .read = read_file_regval, 904 .read = read_file_regval,
895 .write = write_file_regval, 905 .write = write_file_regval,
896 .open = ath9k_debugfs_open, 906 .open = ath9k_debugfs_open,
897 .owner = THIS_MODULE 907 .owner = THIS_MODULE,
908 .llseek = default_llseek,
898}; 909};
899 910
900int ath9k_init_debug(struct ath_hw *ah) 911int ath9k_init_debug(struct ath_hw *ah)
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
index 7d09b4b17bbd..bc2ca7d898e9 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
@@ -536,7 +536,8 @@ static ssize_t read_file_tgt_stats(struct file *file, char __user *user_buf,
536static const struct file_operations fops_tgt_stats = { 536static const struct file_operations fops_tgt_stats = {
537 .read = read_file_tgt_stats, 537 .read = read_file_tgt_stats,
538 .open = ath9k_debugfs_open, 538 .open = ath9k_debugfs_open,
539 .owner = THIS_MODULE 539 .owner = THIS_MODULE,
540 .llseek = default_llseek,
540}; 541};
541 542
542static ssize_t read_file_xmit(struct file *file, char __user *user_buf, 543static ssize_t read_file_xmit(struct file *file, char __user *user_buf,
@@ -584,7 +585,8 @@ static ssize_t read_file_xmit(struct file *file, char __user *user_buf,
584static const struct file_operations fops_xmit = { 585static const struct file_operations fops_xmit = {
585 .read = read_file_xmit, 586 .read = read_file_xmit,
586 .open = ath9k_debugfs_open, 587 .open = ath9k_debugfs_open,
587 .owner = THIS_MODULE 588 .owner = THIS_MODULE,
589 .llseek = default_llseek,
588}; 590};
589 591
590static ssize_t read_file_recv(struct file *file, char __user *user_buf, 592static ssize_t read_file_recv(struct file *file, char __user *user_buf,
@@ -613,7 +615,8 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf,
613static const struct file_operations fops_recv = { 615static const struct file_operations fops_recv = {
614 .read = read_file_recv, 616 .read = read_file_recv,
615 .open = ath9k_debugfs_open, 617 .open = ath9k_debugfs_open,
616 .owner = THIS_MODULE 618 .owner = THIS_MODULE,
619 .llseek = default_llseek,
617}; 620};
618 621
619int ath9k_htc_init_debug(struct ath_hw *ah) 622int ath9k_htc_init_debug(struct ath_hw *ah)
diff --git a/drivers/net/wireless/b43/debugfs.c b/drivers/net/wireless/b43/debugfs.c
index 80b19a44a407..59f59fa40334 100644
--- a/drivers/net/wireless/b43/debugfs.c
+++ b/drivers/net/wireless/b43/debugfs.c
@@ -627,6 +627,7 @@ out_unlock:
627 .open = b43_debugfs_open, \ 627 .open = b43_debugfs_open, \
628 .read = b43_debugfs_read, \ 628 .read = b43_debugfs_read, \
629 .write = b43_debugfs_write, \ 629 .write = b43_debugfs_write, \
630 .llseek = generic_file_llseek, \
630 }, \ 631 }, \
631 .file_struct_offset = offsetof(struct b43_dfsentry, \ 632 .file_struct_offset = offsetof(struct b43_dfsentry, \
632 file_##name), \ 633 file_##name), \
diff --git a/drivers/net/wireless/b43legacy/debugfs.c b/drivers/net/wireless/b43legacy/debugfs.c
index 1f85ac569fec..f232618f2cd1 100644
--- a/drivers/net/wireless/b43legacy/debugfs.c
+++ b/drivers/net/wireless/b43legacy/debugfs.c
@@ -334,6 +334,7 @@ out_unlock:
334 .open = b43legacy_debugfs_open, \ 334 .open = b43legacy_debugfs_open, \
335 .read = b43legacy_debugfs_read, \ 335 .read = b43legacy_debugfs_read, \
336 .write = b43legacy_debugfs_write, \ 336 .write = b43legacy_debugfs_write, \
337 .llseek = generic_file_llseek, \
337 }, \ 338 }, \
338 .file_struct_offset = offsetof(struct b43legacy_dfsentry, \ 339 .file_struct_offset = offsetof(struct b43legacy_dfsentry, \
339 file_##name), \ 340 file_##name), \
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
index 8e84a08ff951..293e1dbc166c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c
@@ -873,6 +873,7 @@ static ssize_t iwl3945_sta_dbgfs_stats_table_read(struct file *file,
873static const struct file_operations rs_sta_dbgfs_stats_table_ops = { 873static const struct file_operations rs_sta_dbgfs_stats_table_ops = {
874 .read = iwl3945_sta_dbgfs_stats_table_read, 874 .read = iwl3945_sta_dbgfs_stats_table_read,
875 .open = iwl3945_open_file_generic, 875 .open = iwl3945_open_file_generic,
876 .llseek = default_llseek,
876}; 877};
877 878
878static void iwl3945_add_debugfs(void *priv, void *priv_sta, 879static void iwl3945_add_debugfs(void *priv, void *priv_sta,
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
index 23e5c42e7d7e..a4378ba31ef6 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
@@ -2873,6 +2873,7 @@ static const struct file_operations rs_sta_dbgfs_scale_table_ops = {
2873 .write = rs_sta_dbgfs_scale_table_write, 2873 .write = rs_sta_dbgfs_scale_table_write,
2874 .read = rs_sta_dbgfs_scale_table_read, 2874 .read = rs_sta_dbgfs_scale_table_read,
2875 .open = open_file_generic, 2875 .open = open_file_generic,
2876 .llseek = default_llseek,
2876}; 2877};
2877static ssize_t rs_sta_dbgfs_stats_table_read(struct file *file, 2878static ssize_t rs_sta_dbgfs_stats_table_read(struct file *file,
2878 char __user *user_buf, size_t count, loff_t *ppos) 2879 char __user *user_buf, size_t count, loff_t *ppos)
@@ -2915,6 +2916,7 @@ static ssize_t rs_sta_dbgfs_stats_table_read(struct file *file,
2915static const struct file_operations rs_sta_dbgfs_stats_table_ops = { 2916static const struct file_operations rs_sta_dbgfs_stats_table_ops = {
2916 .read = rs_sta_dbgfs_stats_table_read, 2917 .read = rs_sta_dbgfs_stats_table_read,
2917 .open = open_file_generic, 2918 .open = open_file_generic,
2919 .llseek = default_llseek,
2918}; 2920};
2919 2921
2920static ssize_t rs_sta_dbgfs_rate_scale_data_read(struct file *file, 2922static ssize_t rs_sta_dbgfs_rate_scale_data_read(struct file *file,
@@ -2946,6 +2948,7 @@ static ssize_t rs_sta_dbgfs_rate_scale_data_read(struct file *file,
2946static const struct file_operations rs_sta_dbgfs_rate_scale_data_ops = { 2948static const struct file_operations rs_sta_dbgfs_rate_scale_data_ops = {
2947 .read = rs_sta_dbgfs_rate_scale_data_read, 2949 .read = rs_sta_dbgfs_rate_scale_data_read,
2948 .open = open_file_generic, 2950 .open = open_file_generic,
2951 .llseek = default_llseek,
2949}; 2952};
2950 2953
2951static void rs_add_debugfs(void *priv, void *priv_sta, 2954static void rs_add_debugfs(void *priv, void *priv_sta,
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
index e96a1bb12783..a32d5d337649 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
@@ -87,6 +87,7 @@ static int iwl_dbgfs_open_file_generic(struct inode *inode, struct file *file)
87static const struct file_operations iwl_dbgfs_##name##_ops = { \ 87static const struct file_operations iwl_dbgfs_##name##_ops = { \
88 .read = iwl_dbgfs_##name##_read, \ 88 .read = iwl_dbgfs_##name##_read, \
89 .open = iwl_dbgfs_open_file_generic, \ 89 .open = iwl_dbgfs_open_file_generic, \
90 .llseek = generic_file_llseek, \
90}; 91};
91 92
92#define DEBUGFS_WRITE_FILE_OPS(name) \ 93#define DEBUGFS_WRITE_FILE_OPS(name) \
@@ -94,6 +95,7 @@ static const struct file_operations iwl_dbgfs_##name##_ops = { \
94static const struct file_operations iwl_dbgfs_##name##_ops = { \ 95static const struct file_operations iwl_dbgfs_##name##_ops = { \
95 .write = iwl_dbgfs_##name##_write, \ 96 .write = iwl_dbgfs_##name##_write, \
96 .open = iwl_dbgfs_open_file_generic, \ 97 .open = iwl_dbgfs_open_file_generic, \
98 .llseek = generic_file_llseek, \
97}; 99};
98 100
99 101
@@ -104,6 +106,7 @@ static const struct file_operations iwl_dbgfs_##name##_ops = { \
104 .write = iwl_dbgfs_##name##_write, \ 106 .write = iwl_dbgfs_##name##_write, \
105 .read = iwl_dbgfs_##name##_read, \ 107 .read = iwl_dbgfs_##name##_read, \
106 .open = iwl_dbgfs_open_file_generic, \ 108 .open = iwl_dbgfs_open_file_generic, \
109 .llseek = generic_file_llseek, \
107}; 110};
108 111
109static ssize_t iwl_dbgfs_tx_statistics_read(struct file *file, 112static ssize_t iwl_dbgfs_tx_statistics_read(struct file *file,
diff --git a/drivers/net/wireless/iwmc3200wifi/debugfs.c b/drivers/net/wireless/iwmc3200wifi/debugfs.c
index 53b0b7711f02..0a0cc9667cd6 100644
--- a/drivers/net/wireless/iwmc3200wifi/debugfs.c
+++ b/drivers/net/wireless/iwmc3200wifi/debugfs.c
@@ -402,24 +402,28 @@ static const struct file_operations iwm_debugfs_txq_fops = {
402 .owner = THIS_MODULE, 402 .owner = THIS_MODULE,
403 .open = iwm_generic_open, 403 .open = iwm_generic_open,
404 .read = iwm_debugfs_txq_read, 404 .read = iwm_debugfs_txq_read,
405 .llseek = default_llseek,
405}; 406};
406 407
407static const struct file_operations iwm_debugfs_tx_credit_fops = { 408static const struct file_operations iwm_debugfs_tx_credit_fops = {
408 .owner = THIS_MODULE, 409 .owner = THIS_MODULE,
409 .open = iwm_generic_open, 410 .open = iwm_generic_open,
410 .read = iwm_debugfs_tx_credit_read, 411 .read = iwm_debugfs_tx_credit_read,
412 .llseek = default_llseek,
411}; 413};
412 414
413static const struct file_operations iwm_debugfs_rx_ticket_fops = { 415static const struct file_operations iwm_debugfs_rx_ticket_fops = {
414 .owner = THIS_MODULE, 416 .owner = THIS_MODULE,
415 .open = iwm_generic_open, 417 .open = iwm_generic_open,
416 .read = iwm_debugfs_rx_ticket_read, 418 .read = iwm_debugfs_rx_ticket_read,
419 .llseek = default_llseek,
417}; 420};
418 421
419static const struct file_operations iwm_debugfs_fw_err_fops = { 422static const struct file_operations iwm_debugfs_fw_err_fops = {
420 .owner = THIS_MODULE, 423 .owner = THIS_MODULE,
421 .open = iwm_generic_open, 424 .open = iwm_generic_open,
422 .read = iwm_debugfs_fw_err_read, 425 .read = iwm_debugfs_fw_err_read,
426 .llseek = default_llseek,
423}; 427};
424 428
425void iwm_debugfs_init(struct iwm_priv *iwm) 429void iwm_debugfs_init(struct iwm_priv *iwm)
diff --git a/drivers/net/wireless/iwmc3200wifi/sdio.c b/drivers/net/wireless/iwmc3200wifi/sdio.c
index edcb52330cf5..56383e7be835 100644
--- a/drivers/net/wireless/iwmc3200wifi/sdio.c
+++ b/drivers/net/wireless/iwmc3200wifi/sdio.c
@@ -364,6 +364,7 @@ static const struct file_operations iwm_debugfs_sdio_fops = {
364 .owner = THIS_MODULE, 364 .owner = THIS_MODULE,
365 .open = iwm_debugfs_sdio_open, 365 .open = iwm_debugfs_sdio_open,
366 .read = iwm_debugfs_sdio_read, 366 .read = iwm_debugfs_sdio_read,
367 .llseek = default_llseek,
367}; 368};
368 369
369static void if_sdio_debugfs_init(struct iwm_priv *iwm, struct dentry *parent_dir) 370static void if_sdio_debugfs_init(struct iwm_priv *iwm, struct dentry *parent_dir)
diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
index 651a79c8de8a..fbf3b0332bb7 100644
--- a/drivers/net/wireless/libertas/debugfs.c
+++ b/drivers/net/wireless/libertas/debugfs.c
@@ -696,6 +696,7 @@ out_unlock:
696 .open = open_file_generic, \ 696 .open = open_file_generic, \
697 .read = (fread), \ 697 .read = (fread), \
698 .write = (fwrite), \ 698 .write = (fwrite), \
699 .llseek = generic_file_llseek, \
699} 700}
700 701
701struct lbs_debugfs_files { 702struct lbs_debugfs_files {
@@ -961,6 +962,7 @@ static const struct file_operations lbs_debug_fops = {
961 .open = open_file_generic, 962 .open = open_file_generic,
962 .write = lbs_debugfs_write, 963 .write = lbs_debugfs_write,
963 .read = lbs_debugfs_read, 964 .read = lbs_debugfs_read,
965 .llseek = default_llseek,
964}; 966};
965 967
966/** 968/**
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index af5b17ce5a15..46da03753fd5 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -2765,6 +2765,7 @@ static ssize_t ray_cs_essid_proc_write(struct file *file,
2765static const struct file_operations ray_cs_essid_proc_fops = { 2765static const struct file_operations ray_cs_essid_proc_fops = {
2766 .owner = THIS_MODULE, 2766 .owner = THIS_MODULE,
2767 .write = ray_cs_essid_proc_write, 2767 .write = ray_cs_essid_proc_write,
2768 .llseek = noop_llseek,
2768}; 2769};
2769 2770
2770static ssize_t int_proc_write(struct file *file, const char __user *buffer, 2771static ssize_t int_proc_write(struct file *file, const char __user *buffer,
@@ -2798,6 +2799,7 @@ static ssize_t int_proc_write(struct file *file, const char __user *buffer,
2798static const struct file_operations int_proc_fops = { 2799static const struct file_operations int_proc_fops = {
2799 .owner = THIS_MODULE, 2800 .owner = THIS_MODULE,
2800 .write = int_proc_write, 2801 .write = int_proc_write,
2802 .llseek = noop_llseek,
2801}; 2803};
2802#endif 2804#endif
2803 2805
diff --git a/drivers/net/wireless/rt2x00/rt2x00debug.c b/drivers/net/wireless/rt2x00/rt2x00debug.c
index b0498e7e7aae..cea81e4c5c82 100644
--- a/drivers/net/wireless/rt2x00/rt2x00debug.c
+++ b/drivers/net/wireless/rt2x00/rt2x00debug.c
@@ -315,6 +315,7 @@ static const struct file_operations rt2x00debug_fop_queue_dump = {
315 .poll = rt2x00debug_poll_queue_dump, 315 .poll = rt2x00debug_poll_queue_dump,
316 .open = rt2x00debug_open_queue_dump, 316 .open = rt2x00debug_open_queue_dump,
317 .release = rt2x00debug_release_queue_dump, 317 .release = rt2x00debug_release_queue_dump,
318 .llseek = default_llseek,
318}; 319};
319 320
320static ssize_t rt2x00debug_read_queue_stats(struct file *file, 321static ssize_t rt2x00debug_read_queue_stats(struct file *file,
@@ -371,6 +372,7 @@ static const struct file_operations rt2x00debug_fop_queue_stats = {
371 .read = rt2x00debug_read_queue_stats, 372 .read = rt2x00debug_read_queue_stats,
372 .open = rt2x00debug_file_open, 373 .open = rt2x00debug_file_open,
373 .release = rt2x00debug_file_release, 374 .release = rt2x00debug_file_release,
375 .llseek = default_llseek,
374}; 376};
375 377
376#ifdef CONFIG_RT2X00_LIB_CRYPTO 378#ifdef CONFIG_RT2X00_LIB_CRYPTO
@@ -423,6 +425,7 @@ static const struct file_operations rt2x00debug_fop_crypto_stats = {
423 .read = rt2x00debug_read_crypto_stats, 425 .read = rt2x00debug_read_crypto_stats,
424 .open = rt2x00debug_file_open, 426 .open = rt2x00debug_file_open,
425 .release = rt2x00debug_file_release, 427 .release = rt2x00debug_file_release,
428 .llseek = default_llseek,
426}; 429};
427#endif 430#endif
428 431
@@ -509,6 +512,7 @@ static const struct file_operations rt2x00debug_fop_##__name = {\
509 .write = rt2x00debug_write_##__name, \ 512 .write = rt2x00debug_write_##__name, \
510 .open = rt2x00debug_file_open, \ 513 .open = rt2x00debug_file_open, \
511 .release = rt2x00debug_file_release, \ 514 .release = rt2x00debug_file_release, \
515 .llseek = generic_file_llseek, \
512}; 516};
513 517
514RT2X00DEBUGFS_OPS(csr, "0x%.8x\n", u32); 518RT2X00DEBUGFS_OPS(csr, "0x%.8x\n", u32);
@@ -542,6 +546,7 @@ static const struct file_operations rt2x00debug_fop_dev_flags = {
542 .read = rt2x00debug_read_dev_flags, 546 .read = rt2x00debug_read_dev_flags,
543 .open = rt2x00debug_file_open, 547 .open = rt2x00debug_file_open,
544 .release = rt2x00debug_file_release, 548 .release = rt2x00debug_file_release,
549 .llseek = default_llseek,
545}; 550};
546 551
547static struct dentry *rt2x00debug_create_file_driver(const char *name, 552static struct dentry *rt2x00debug_create_file_driver(const char *name,
diff --git a/drivers/net/wireless/wl12xx/wl1251_debugfs.c b/drivers/net/wireless/wl12xx/wl1251_debugfs.c
index 5e4465ac08fa..fa620a5e5303 100644
--- a/drivers/net/wireless/wl12xx/wl1251_debugfs.c
+++ b/drivers/net/wireless/wl12xx/wl1251_debugfs.c
@@ -50,6 +50,7 @@ static ssize_t name## _read(struct file *file, char __user *userbuf, \
50static const struct file_operations name## _ops = { \ 50static const struct file_operations name## _ops = { \
51 .read = name## _read, \ 51 .read = name## _read, \
52 .open = wl1251_open_file_generic, \ 52 .open = wl1251_open_file_generic, \
53 .llseek = generic_file_llseek, \
53}; 54};
54 55
55#define DEBUGFS_ADD(name, parent) \ 56#define DEBUGFS_ADD(name, parent) \
@@ -86,6 +87,7 @@ static ssize_t sub## _ ##name## _read(struct file *file, \
86static const struct file_operations sub## _ ##name## _ops = { \ 87static const struct file_operations sub## _ ##name## _ops = { \
87 .read = sub## _ ##name## _read, \ 88 .read = sub## _ ##name## _read, \
88 .open = wl1251_open_file_generic, \ 89 .open = wl1251_open_file_generic, \
90 .llseek = generic_file_llseek, \
89}; 91};
90 92
91#define DEBUGFS_FWSTATS_ADD(sub, name) \ 93#define DEBUGFS_FWSTATS_ADD(sub, name) \
@@ -236,6 +238,7 @@ static ssize_t tx_queue_len_read(struct file *file, char __user *userbuf,
236static const struct file_operations tx_queue_len_ops = { 238static const struct file_operations tx_queue_len_ops = {
237 .read = tx_queue_len_read, 239 .read = tx_queue_len_read,
238 .open = wl1251_open_file_generic, 240 .open = wl1251_open_file_generic,
241 .llseek = generic_file_llseek,
239}; 242};
240 243
241static ssize_t tx_queue_status_read(struct file *file, char __user *userbuf, 244static ssize_t tx_queue_status_read(struct file *file, char __user *userbuf,
@@ -257,6 +260,7 @@ static ssize_t tx_queue_status_read(struct file *file, char __user *userbuf,
257static const struct file_operations tx_queue_status_ops = { 260static const struct file_operations tx_queue_status_ops = {
258 .read = tx_queue_status_read, 261 .read = tx_queue_status_read,
259 .open = wl1251_open_file_generic, 262 .open = wl1251_open_file_generic,
263 .llseek = generic_file_llseek,
260}; 264};
261 265
262static void wl1251_debugfs_delete_files(struct wl1251 *wl) 266static void wl1251_debugfs_delete_files(struct wl1251 *wl)
diff --git a/drivers/net/wireless/wl12xx/wl1271_debugfs.c b/drivers/net/wireless/wl12xx/wl1271_debugfs.c
index c239ef4d0b8d..66c2b90ddfd4 100644
--- a/drivers/net/wireless/wl12xx/wl1271_debugfs.c
+++ b/drivers/net/wireless/wl12xx/wl1271_debugfs.c
@@ -51,6 +51,7 @@ static ssize_t name## _read(struct file *file, char __user *userbuf, \
51static const struct file_operations name## _ops = { \ 51static const struct file_operations name## _ops = { \
52 .read = name## _read, \ 52 .read = name## _read, \
53 .open = wl1271_open_file_generic, \ 53 .open = wl1271_open_file_generic, \
54 .llseek = generic_file_llseek, \
54}; 55};
55 56
56#define DEBUGFS_ADD(name, parent) \ 57#define DEBUGFS_ADD(name, parent) \
@@ -87,6 +88,7 @@ static ssize_t sub## _ ##name## _read(struct file *file, \
87static const struct file_operations sub## _ ##name## _ops = { \ 88static const struct file_operations sub## _ ##name## _ops = { \
88 .read = sub## _ ##name## _read, \ 89 .read = sub## _ ##name## _read, \
89 .open = wl1271_open_file_generic, \ 90 .open = wl1271_open_file_generic, \
91 .llseek = generic_file_llseek, \
90}; 92};
91 93
92#define DEBUGFS_FWSTATS_ADD(sub, name) \ 94#define DEBUGFS_FWSTATS_ADD(sub, name) \
@@ -237,6 +239,7 @@ static ssize_t tx_queue_len_read(struct file *file, char __user *userbuf,
237static const struct file_operations tx_queue_len_ops = { 239static const struct file_operations tx_queue_len_ops = {
238 .read = tx_queue_len_read, 240 .read = tx_queue_len_read,
239 .open = wl1271_open_file_generic, 241 .open = wl1271_open_file_generic,
242 .llseek = default_llseek,
240}; 243};
241 244
242static ssize_t gpio_power_read(struct file *file, char __user *user_buf, 245static ssize_t gpio_power_read(struct file *file, char __user *user_buf,
@@ -291,7 +294,8 @@ out:
291static const struct file_operations gpio_power_ops = { 294static const struct file_operations gpio_power_ops = {
292 .read = gpio_power_read, 295 .read = gpio_power_read,
293 .write = gpio_power_write, 296 .write = gpio_power_write,
294 .open = wl1271_open_file_generic 297 .open = wl1271_open_file_generic,
298 .llseek = default_llseek,
295}; 299};
296 300
297static void wl1271_debugfs_delete_files(struct wl1271 *wl) 301static void wl1271_debugfs_delete_files(struct wl1271 *wl)
diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
index ccf099e684a4..89f63456646f 100644
--- a/drivers/oprofile/oprofile_files.c
+++ b/drivers/oprofile/oprofile_files.c
@@ -59,6 +59,7 @@ static ssize_t timeout_write(struct file *file, char const __user *buf,
59static const struct file_operations timeout_fops = { 59static const struct file_operations timeout_fops = {
60 .read = timeout_read, 60 .read = timeout_read,
61 .write = timeout_write, 61 .write = timeout_write,
62 .llseek = default_llseek,
62}; 63};
63 64
64#endif 65#endif
@@ -96,7 +97,8 @@ static ssize_t depth_write(struct file *file, char const __user *buf, size_t cou
96 97
97static const struct file_operations depth_fops = { 98static const struct file_operations depth_fops = {
98 .read = depth_read, 99 .read = depth_read,
99 .write = depth_write 100 .write = depth_write,
101 .llseek = default_llseek,
100}; 102};
101 103
102 104
@@ -108,6 +110,7 @@ static ssize_t pointer_size_read(struct file *file, char __user *buf, size_t cou
108 110
109static const struct file_operations pointer_size_fops = { 111static const struct file_operations pointer_size_fops = {
110 .read = pointer_size_read, 112 .read = pointer_size_read,
113 .llseek = default_llseek,
111}; 114};
112 115
113 116
@@ -119,6 +122,7 @@ static ssize_t cpu_type_read(struct file *file, char __user *buf, size_t count,
119 122
120static const struct file_operations cpu_type_fops = { 123static const struct file_operations cpu_type_fops = {
121 .read = cpu_type_read, 124 .read = cpu_type_read,
125 .llseek = default_llseek,
122}; 126};
123 127
124 128
@@ -154,6 +158,7 @@ static ssize_t enable_write(struct file *file, char const __user *buf, size_t co
154static const struct file_operations enable_fops = { 158static const struct file_operations enable_fops = {
155 .read = enable_read, 159 .read = enable_read,
156 .write = enable_write, 160 .write = enable_write,
161 .llseek = default_llseek,
157}; 162};
158 163
159 164
@@ -166,6 +171,7 @@ static ssize_t dump_write(struct file *file, char const __user *buf, size_t coun
166 171
167static const struct file_operations dump_fops = { 172static const struct file_operations dump_fops = {
168 .write = dump_write, 173 .write = dump_write,
174 .llseek = noop_llseek,
169}; 175};
170 176
171void oprofile_create_files(struct super_block *sb, struct dentry *root) 177void oprofile_create_files(struct super_block *sb, struct dentry *root)
diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
index 1944621930d9..95f711b251ad 100644
--- a/drivers/oprofile/oprofilefs.c
+++ b/drivers/oprofile/oprofilefs.c
@@ -121,12 +121,14 @@ static const struct file_operations ulong_fops = {
121 .read = ulong_read_file, 121 .read = ulong_read_file,
122 .write = ulong_write_file, 122 .write = ulong_write_file,
123 .open = default_open, 123 .open = default_open,
124 .llseek = default_llseek,
124}; 125};
125 126
126 127
127static const struct file_operations ulong_ro_fops = { 128static const struct file_operations ulong_ro_fops = {
128 .read = ulong_read_file, 129 .read = ulong_read_file,
129 .open = default_open, 130 .open = default_open,
131 .llseek = default_llseek,
130}; 132};
131 133
132 134
@@ -178,6 +180,7 @@ static ssize_t atomic_read_file(struct file *file, char __user *buf, size_t coun
178static const struct file_operations atomic_ro_fops = { 180static const struct file_operations atomic_ro_fops = {
179 .read = atomic_read_file, 181 .read = atomic_read_file,
180 .open = default_open, 182 .open = default_open,
183 .llseek = default_llseek,
181}; 184};
182 185
183 186
diff --git a/drivers/pci/hotplug/cpqphp_sysfs.c b/drivers/pci/hotplug/cpqphp_sysfs.c
index 56215322930a..4cb30447a486 100644
--- a/drivers/pci/hotplug/cpqphp_sysfs.c
+++ b/drivers/pci/hotplug/cpqphp_sysfs.c
@@ -34,10 +34,11 @@
34#include <linux/workqueue.h> 34#include <linux/workqueue.h>
35#include <linux/pci.h> 35#include <linux/pci.h>
36#include <linux/pci_hotplug.h> 36#include <linux/pci_hotplug.h>
37#include <linux/smp_lock.h> 37#include <linux/mutex.h>
38#include <linux/debugfs.h> 38#include <linux/debugfs.h>
39#include "cpqphp.h" 39#include "cpqphp.h"
40 40
41static DEFINE_MUTEX(cpqphp_mutex);
41static int show_ctrl (struct controller *ctrl, char *buf) 42static int show_ctrl (struct controller *ctrl, char *buf)
42{ 43{
43 char *out = buf; 44 char *out = buf;
@@ -147,7 +148,7 @@ static int open(struct inode *inode, struct file *file)
147 struct ctrl_dbg *dbg; 148 struct ctrl_dbg *dbg;
148 int retval = -ENOMEM; 149 int retval = -ENOMEM;
149 150
150 lock_kernel(); 151 mutex_lock(&cpqphp_mutex);
151 dbg = kmalloc(sizeof(*dbg), GFP_KERNEL); 152 dbg = kmalloc(sizeof(*dbg), GFP_KERNEL);
152 if (!dbg) 153 if (!dbg)
153 goto exit; 154 goto exit;
@@ -160,7 +161,7 @@ static int open(struct inode *inode, struct file *file)
160 file->private_data = dbg; 161 file->private_data = dbg;
161 retval = 0; 162 retval = 0;
162exit: 163exit:
163 unlock_kernel(); 164 mutex_unlock(&cpqphp_mutex);
164 return retval; 165 return retval;
165} 166}
166 167
@@ -169,7 +170,7 @@ static loff_t lseek(struct file *file, loff_t off, int whence)
169 struct ctrl_dbg *dbg; 170 struct ctrl_dbg *dbg;
170 loff_t new = -1; 171 loff_t new = -1;
171 172
172 lock_kernel(); 173 mutex_lock(&cpqphp_mutex);
173 dbg = file->private_data; 174 dbg = file->private_data;
174 175
175 switch (whence) { 176 switch (whence) {
@@ -181,10 +182,10 @@ static loff_t lseek(struct file *file, loff_t off, int whence)
181 break; 182 break;
182 } 183 }
183 if (new < 0 || new > dbg->size) { 184 if (new < 0 || new > dbg->size) {
184 unlock_kernel(); 185 mutex_unlock(&cpqphp_mutex);
185 return -EINVAL; 186 return -EINVAL;
186 } 187 }
187 unlock_kernel(); 188 mutex_unlock(&cpqphp_mutex);
188 return (file->f_pos = new); 189 return (file->f_pos = new);
189} 190}
190 191
diff --git a/drivers/pci/pcie/aer/aer_inject.c b/drivers/pci/pcie/aer/aer_inject.c
index 909924692b8a..b3cf6223f63a 100644
--- a/drivers/pci/pcie/aer/aer_inject.c
+++ b/drivers/pci/pcie/aer/aer_inject.c
@@ -472,6 +472,7 @@ static ssize_t aer_inject_write(struct file *filp, const char __user *ubuf,
472static const struct file_operations aer_inject_fops = { 472static const struct file_operations aer_inject_fops = {
473 .write = aer_inject_write, 473 .write = aer_inject_write,
474 .owner = THIS_MODULE, 474 .owner = THIS_MODULE,
475 .llseek = noop_llseek,
475}; 476};
476 477
477static struct miscdevice aer_inject_device = { 478static struct miscdevice aer_inject_device = {
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index e3154ff7a39f..f200677851b8 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -2360,6 +2360,7 @@ static const struct file_operations sonypi_misc_fops = {
2360 .release = sonypi_misc_release, 2360 .release = sonypi_misc_release,
2361 .fasync = sonypi_misc_fasync, 2361 .fasync = sonypi_misc_fasync,
2362 .unlocked_ioctl = sonypi_misc_ioctl, 2362 .unlocked_ioctl = sonypi_misc_ioctl,
2363 .llseek = noop_llseek,
2363}; 2364};
2364 2365
2365static struct miscdevice sonypi_misc_device = { 2366static struct miscdevice sonypi_misc_device = {
diff --git a/drivers/pnp/isapnp/proc.c b/drivers/pnp/isapnp/proc.c
index 3f94edab25fa..e73ebefdf3e0 100644
--- a/drivers/pnp/isapnp/proc.c
+++ b/drivers/pnp/isapnp/proc.c
@@ -31,8 +31,9 @@ static struct proc_dir_entry *isapnp_proc_bus_dir = NULL;
31static loff_t isapnp_proc_bus_lseek(struct file *file, loff_t off, int whence) 31static loff_t isapnp_proc_bus_lseek(struct file *file, loff_t off, int whence)
32{ 32{
33 loff_t new = -1; 33 loff_t new = -1;
34 struct inode *inode = file->f_path.dentry->d_inode;
34 35
35 lock_kernel(); 36 mutex_lock(&inode->i_mutex);
36 switch (whence) { 37 switch (whence) {
37 case 0: 38 case 0:
38 new = off; 39 new = off;
@@ -44,12 +45,12 @@ static loff_t isapnp_proc_bus_lseek(struct file *file, loff_t off, int whence)
44 new = 256 + off; 45 new = 256 + off;
45 break; 46 break;
46 } 47 }
47 if (new < 0 || new > 256) { 48 if (new < 0 || new > 256)
48 unlock_kernel(); 49 new = -EINVAL;
49 return -EINVAL; 50 else
50 } 51 file->f_pos = new;
51 unlock_kernel(); 52 mutex_unlock(&inode->i_mutex);
52 return (file->f_pos = new); 53 return new;
53} 54}
54 55
55static ssize_t isapnp_proc_bus_read(struct file *file, char __user * buf, 56static ssize_t isapnp_proc_bus_read(struct file *file, char __user * buf,
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index d60557cae8ef..5a8daa358066 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -20,7 +20,7 @@
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/rtc.h> 21#include <linux/rtc.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/smp_lock.h> 23#include <linux/mutex.h>
24#include <linux/string.h> 24#include <linux/string.h>
25#ifdef CONFIG_RTC_DRV_M41T80_WDT 25#ifdef CONFIG_RTC_DRV_M41T80_WDT
26#include <linux/fs.h> 26#include <linux/fs.h>
@@ -68,6 +68,7 @@
68 68
69#define DRV_VERSION "0.05" 69#define DRV_VERSION "0.05"
70 70
71static DEFINE_MUTEX(m41t80_rtc_mutex);
71static const struct i2c_device_id m41t80_id[] = { 72static const struct i2c_device_id m41t80_id[] = {
72 { "m41t62", M41T80_FEATURE_SQ | M41T80_FEATURE_SQ_ALT }, 73 { "m41t62", M41T80_FEATURE_SQ | M41T80_FEATURE_SQ_ALT },
73 { "m41t65", M41T80_FEATURE_HT | M41T80_FEATURE_WD }, 74 { "m41t65", M41T80_FEATURE_HT | M41T80_FEATURE_WD },
@@ -677,9 +678,9 @@ static long wdt_unlocked_ioctl(struct file *file, unsigned int cmd,
677{ 678{
678 int ret; 679 int ret;
679 680
680 lock_kernel(); 681 mutex_lock(&m41t80_rtc_mutex);
681 ret = wdt_ioctl(file, cmd, arg); 682 ret = wdt_ioctl(file, cmd, arg);
682 unlock_kernel(); 683 mutex_unlock(&m41t80_rtc_mutex);
683 684
684 return ret; 685 return ret;
685} 686}
@@ -693,16 +694,16 @@ static long wdt_unlocked_ioctl(struct file *file, unsigned int cmd,
693static int wdt_open(struct inode *inode, struct file *file) 694static int wdt_open(struct inode *inode, struct file *file)
694{ 695{
695 if (MINOR(inode->i_rdev) == WATCHDOG_MINOR) { 696 if (MINOR(inode->i_rdev) == WATCHDOG_MINOR) {
696 lock_kernel(); 697 mutex_lock(&m41t80_rtc_mutex);
697 if (test_and_set_bit(0, &wdt_is_open)) { 698 if (test_and_set_bit(0, &wdt_is_open)) {
698 unlock_kernel(); 699 mutex_unlock(&m41t80_rtc_mutex);
699 return -EBUSY; 700 return -EBUSY;
700 } 701 }
701 /* 702 /*
702 * Activate 703 * Activate
703 */ 704 */
704 wdt_is_open = 1; 705 wdt_is_open = 1;
705 unlock_kernel(); 706 mutex_unlock(&m41t80_rtc_mutex);
706 return nonseekable_open(inode, file); 707 return nonseekable_open(inode, file);
707 } 708 }
708 return -ENODEV; 709 return -ENODEV;
@@ -748,6 +749,7 @@ static const struct file_operations wdt_fops = {
748 .write = wdt_write, 749 .write = wdt_write,
749 .open = wdt_open, 750 .open = wdt_open,
750 .release = wdt_release, 751 .release = wdt_release,
752 .llseek = no_llseek,
751}; 753};
752 754
753static struct miscdevice wdt_dev = { 755static struct miscdevice wdt_dev = {
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 8373ca0de8e0..38e6fa9a2012 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -21,7 +21,6 @@
21#include <linux/hdreg.h> 21#include <linux/hdreg.h>
22#include <linux/async.h> 22#include <linux/async.h>
23#include <linux/mutex.h> 23#include <linux/mutex.h>
24#include <linux/smp_lock.h>
25 24
26#include <asm/ccwdev.h> 25#include <asm/ccwdev.h>
27#include <asm/ebcdic.h> 26#include <asm/ebcdic.h>
@@ -2236,7 +2235,6 @@ static int dasd_open(struct block_device *bdev, fmode_t mode)
2236 if (!block) 2235 if (!block)
2237 return -ENODEV; 2236 return -ENODEV;
2238 2237
2239 lock_kernel();
2240 base = block->base; 2238 base = block->base;
2241 atomic_inc(&block->open_count); 2239 atomic_inc(&block->open_count);
2242 if (test_bit(DASD_FLAG_OFFLINE, &base->flags)) { 2240 if (test_bit(DASD_FLAG_OFFLINE, &base->flags)) {
@@ -2271,14 +2269,12 @@ static int dasd_open(struct block_device *bdev, fmode_t mode)
2271 goto out; 2269 goto out;
2272 } 2270 }
2273 2271
2274 unlock_kernel();
2275 return 0; 2272 return 0;
2276 2273
2277out: 2274out:
2278 module_put(base->discipline->owner); 2275 module_put(base->discipline->owner);
2279unlock: 2276unlock:
2280 atomic_dec(&block->open_count); 2277 atomic_dec(&block->open_count);
2281 unlock_kernel();
2282 return rc; 2278 return rc;
2283} 2279}
2284 2280
@@ -2286,10 +2282,8 @@ static int dasd_release(struct gendisk *disk, fmode_t mode)
2286{ 2282{
2287 struct dasd_block *block = disk->private_data; 2283 struct dasd_block *block = disk->private_data;
2288 2284
2289 lock_kernel();
2290 atomic_dec(&block->open_count); 2285 atomic_dec(&block->open_count);
2291 module_put(block->base->discipline->owner); 2286 module_put(block->base->discipline->owner);
2292 unlock_kernel();
2293 return 0; 2287 return 0;
2294} 2288}
2295 2289
diff --git a/drivers/s390/block/dasd_eer.c b/drivers/s390/block/dasd_eer.c
index 7158f9528ecc..c71d89dba302 100644
--- a/drivers/s390/block/dasd_eer.c
+++ b/drivers/s390/block/dasd_eer.c
@@ -670,6 +670,7 @@ static const struct file_operations dasd_eer_fops = {
670 .read = &dasd_eer_read, 670 .read = &dasd_eer_read,
671 .poll = &dasd_eer_poll, 671 .poll = &dasd_eer_poll,
672 .owner = THIS_MODULE, 672 .owner = THIS_MODULE,
673 .llseek = noop_llseek,
673}; 674};
674 675
675static struct miscdevice *dasd_eer_dev = NULL; 676static struct miscdevice *dasd_eer_dev = NULL;
diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c
index 1557214944f7..26075e95b1ba 100644
--- a/drivers/s390/block/dasd_ioctl.c
+++ b/drivers/s390/block/dasd_ioctl.c
@@ -16,7 +16,6 @@
16#include <linux/major.h> 16#include <linux/major.h>
17#include <linux/fs.h> 17#include <linux/fs.h>
18#include <linux/blkpg.h> 18#include <linux/blkpg.h>
19#include <linux/smp_lock.h>
20#include <linux/slab.h> 19#include <linux/slab.h>
21#include <asm/compat.h> 20#include <asm/compat.h>
22#include <asm/ccwdev.h> 21#include <asm/ccwdev.h>
@@ -370,9 +369,8 @@ static int dasd_ioctl_readall_cmb(struct dasd_block *block, unsigned int cmd,
370 return ret; 369 return ret;
371} 370}
372 371
373static int 372int dasd_ioctl(struct block_device *bdev, fmode_t mode,
374dasd_do_ioctl(struct block_device *bdev, fmode_t mode, 373 unsigned int cmd, unsigned long arg)
375 unsigned int cmd, unsigned long arg)
376{ 374{
377 struct dasd_block *block = bdev->bd_disk->private_data; 375 struct dasd_block *block = bdev->bd_disk->private_data;
378 void __user *argp; 376 void __user *argp;
@@ -430,14 +428,3 @@ dasd_do_ioctl(struct block_device *bdev, fmode_t mode,
430 return -EINVAL; 428 return -EINVAL;
431 } 429 }
432} 430}
433
434int dasd_ioctl(struct block_device *bdev, fmode_t mode,
435 unsigned int cmd, unsigned long arg)
436{
437 int rc;
438
439 lock_kernel();
440 rc = dasd_do_ioctl(bdev, mode, cmd, arg);
441 unlock_kernel();
442 return rc;
443}
diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c
index 2bd72aa34c59..9b43ae94beba 100644
--- a/drivers/s390/block/dcssblk.c
+++ b/drivers/s390/block/dcssblk.c
@@ -14,7 +14,6 @@
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/blkdev.h> 16#include <linux/blkdev.h>
17#include <linux/smp_lock.h>
18#include <linux/completion.h> 17#include <linux/completion.h>
19#include <linux/interrupt.h> 18#include <linux/interrupt.h>
20#include <linux/platform_device.h> 19#include <linux/platform_device.h>
@@ -776,7 +775,6 @@ dcssblk_open(struct block_device *bdev, fmode_t mode)
776 struct dcssblk_dev_info *dev_info; 775 struct dcssblk_dev_info *dev_info;
777 int rc; 776 int rc;
778 777
779 lock_kernel();
780 dev_info = bdev->bd_disk->private_data; 778 dev_info = bdev->bd_disk->private_data;
781 if (NULL == dev_info) { 779 if (NULL == dev_info) {
782 rc = -ENODEV; 780 rc = -ENODEV;
@@ -786,7 +784,6 @@ dcssblk_open(struct block_device *bdev, fmode_t mode)
786 bdev->bd_block_size = 4096; 784 bdev->bd_block_size = 4096;
787 rc = 0; 785 rc = 0;
788out: 786out:
789 unlock_kernel();
790 return rc; 787 return rc;
791} 788}
792 789
@@ -797,7 +794,6 @@ dcssblk_release(struct gendisk *disk, fmode_t mode)
797 struct segment_info *entry; 794 struct segment_info *entry;
798 int rc; 795 int rc;
799 796
800 lock_kernel();
801 if (!dev_info) { 797 if (!dev_info) {
802 rc = -ENODEV; 798 rc = -ENODEV;
803 goto out; 799 goto out;
@@ -815,7 +811,6 @@ dcssblk_release(struct gendisk *disk, fmode_t mode)
815 up_write(&dcssblk_devices_sem); 811 up_write(&dcssblk_devices_sem);
816 rc = 0; 812 rc = 0;
817out: 813out:
818 unlock_kernel();
819 return rc; 814 return rc;
820} 815}
821 816
diff --git a/drivers/s390/char/fs3270.c b/drivers/s390/char/fs3270.c
index 857dfcb7b359..eb28fb01a38a 100644
--- a/drivers/s390/char/fs3270.c
+++ b/drivers/s390/char/fs3270.c
@@ -520,6 +520,7 @@ static const struct file_operations fs3270_fops = {
520 .compat_ioctl = fs3270_ioctl, /* ioctl */ 520 .compat_ioctl = fs3270_ioctl, /* ioctl */
521 .open = fs3270_open, /* open */ 521 .open = fs3270_open, /* open */
522 .release = fs3270_close, /* release */ 522 .release = fs3270_close, /* release */
523 .llseek = no_llseek,
523}; 524};
524 525
525/* 526/*
diff --git a/drivers/s390/char/monreader.c b/drivers/s390/char/monreader.c
index e021ec663ef9..5b8b8592d311 100644
--- a/drivers/s390/char/monreader.c
+++ b/drivers/s390/char/monreader.c
@@ -447,6 +447,7 @@ static const struct file_operations mon_fops = {
447 .release = &mon_close, 447 .release = &mon_close,
448 .read = &mon_read, 448 .read = &mon_read,
449 .poll = &mon_poll, 449 .poll = &mon_poll,
450 .llseek = noop_llseek,
450}; 451};
451 452
452static struct miscdevice mon_dev = { 453static struct miscdevice mon_dev = {
diff --git a/drivers/s390/char/monwriter.c b/drivers/s390/char/monwriter.c
index 572a1e7fd099..e0702d3ea33b 100644
--- a/drivers/s390/char/monwriter.c
+++ b/drivers/s390/char/monwriter.c
@@ -274,6 +274,7 @@ static const struct file_operations monwrite_fops = {
274 .open = &monwrite_open, 274 .open = &monwrite_open,
275 .release = &monwrite_close, 275 .release = &monwrite_close,
276 .write = &monwrite_write, 276 .write = &monwrite_write,
277 .llseek = noop_llseek,
277}; 278};
278 279
279static struct miscdevice mon_dev = { 280static struct miscdevice mon_dev = {
diff --git a/drivers/s390/char/tape_block.c b/drivers/s390/char/tape_block.c
index 85cf607fc78f..f0fa9ca5cb2c 100644
--- a/drivers/s390/char/tape_block.c
+++ b/drivers/s390/char/tape_block.c
@@ -16,7 +16,7 @@
16#include <linux/fs.h> 16#include <linux/fs.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/blkdev.h> 18#include <linux/blkdev.h>
19#include <linux/smp_lock.h> 19#include <linux/mutex.h>
20#include <linux/interrupt.h> 20#include <linux/interrupt.h>
21#include <linux/buffer_head.h> 21#include <linux/buffer_head.h>
22#include <linux/kernel.h> 22#include <linux/kernel.h>
@@ -45,6 +45,7 @@
45/* 45/*
46 * file operation structure for tape block frontend 46 * file operation structure for tape block frontend
47 */ 47 */
48static DEFINE_MUTEX(tape_block_mutex);
48static int tapeblock_open(struct block_device *, fmode_t); 49static int tapeblock_open(struct block_device *, fmode_t);
49static int tapeblock_release(struct gendisk *, fmode_t); 50static int tapeblock_release(struct gendisk *, fmode_t);
50static int tapeblock_medium_changed(struct gendisk *); 51static int tapeblock_medium_changed(struct gendisk *);
@@ -361,7 +362,7 @@ tapeblock_open(struct block_device *bdev, fmode_t mode)
361 struct tape_device * device; 362 struct tape_device * device;
362 int rc; 363 int rc;
363 364
364 lock_kernel(); 365 mutex_lock(&tape_block_mutex);
365 device = tape_get_device(disk->private_data); 366 device = tape_get_device(disk->private_data);
366 367
367 if (device->required_tapemarks) { 368 if (device->required_tapemarks) {
@@ -385,14 +386,14 @@ tapeblock_open(struct block_device *bdev, fmode_t mode)
385 * is called. 386 * is called.
386 */ 387 */
387 tape_state_set(device, TS_BLKUSE); 388 tape_state_set(device, TS_BLKUSE);
388 unlock_kernel(); 389 mutex_unlock(&tape_block_mutex);
389 return 0; 390 return 0;
390 391
391release: 392release:
392 tape_release(device); 393 tape_release(device);
393 put_device: 394 put_device:
394 tape_put_device(device); 395 tape_put_device(device);
395 unlock_kernel(); 396 mutex_unlock(&tape_block_mutex);
396 return rc; 397 return rc;
397} 398}
398 399
@@ -407,11 +408,11 @@ tapeblock_release(struct gendisk *disk, fmode_t mode)
407{ 408{
408 struct tape_device *device = disk->private_data; 409 struct tape_device *device = disk->private_data;
409 410
410 lock_kernel(); 411 mutex_lock(&tape_block_mutex);
411 tape_state_set(device, TS_IN_USE); 412 tape_state_set(device, TS_IN_USE);
412 tape_release(device); 413 tape_release(device);
413 tape_put_device(device); 414 tape_put_device(device);
414 unlock_kernel(); 415 mutex_unlock(&tape_block_mutex);
415 416
416 return 0; 417 return 0;
417} 418}
diff --git a/drivers/s390/char/tape_char.c b/drivers/s390/char/tape_char.c
index 539045acaad4..883e2db02bd3 100644
--- a/drivers/s390/char/tape_char.c
+++ b/drivers/s390/char/tape_char.c
@@ -53,6 +53,7 @@ static const struct file_operations tape_fops =
53#endif 53#endif
54 .open = tapechar_open, 54 .open = tapechar_open,
55 .release = tapechar_release, 55 .release = tapechar_release,
56 .llseek = no_llseek,
56}; 57};
57 58
58static int tapechar_major = TAPECHAR_MAJOR; 59static int tapechar_major = TAPECHAR_MAJOR;
diff --git a/drivers/s390/char/vmcp.c b/drivers/s390/char/vmcp.c
index 04e532eec032..0e7cb1a84151 100644
--- a/drivers/s390/char/vmcp.c
+++ b/drivers/s390/char/vmcp.c
@@ -177,6 +177,7 @@ static const struct file_operations vmcp_fops = {
177 .write = vmcp_write, 177 .write = vmcp_write,
178 .unlocked_ioctl = vmcp_ioctl, 178 .unlocked_ioctl = vmcp_ioctl,
179 .compat_ioctl = vmcp_ioctl, 179 .compat_ioctl = vmcp_ioctl,
180 .llseek = no_llseek,
180}; 181};
181 182
182static struct miscdevice vmcp_dev = { 183static struct miscdevice vmcp_dev = {
diff --git a/drivers/s390/char/vmlogrdr.c b/drivers/s390/char/vmlogrdr.c
index e40a1b892866..0d6dc4b92cc2 100644
--- a/drivers/s390/char/vmlogrdr.c
+++ b/drivers/s390/char/vmlogrdr.c
@@ -97,6 +97,7 @@ static const struct file_operations vmlogrdr_fops = {
97 .open = vmlogrdr_open, 97 .open = vmlogrdr_open,
98 .release = vmlogrdr_release, 98 .release = vmlogrdr_release,
99 .read = vmlogrdr_read, 99 .read = vmlogrdr_read,
100 .llseek = no_llseek,
100}; 101};
101 102
102 103
diff --git a/drivers/s390/char/vmwatchdog.c b/drivers/s390/char/vmwatchdog.c
index e13508c98b1a..12ef9121d4f0 100644
--- a/drivers/s390/char/vmwatchdog.c
+++ b/drivers/s390/char/vmwatchdog.c
@@ -297,6 +297,7 @@ static const struct file_operations vmwdt_fops = {
297 .unlocked_ioctl = &vmwdt_ioctl, 297 .unlocked_ioctl = &vmwdt_ioctl,
298 .write = &vmwdt_write, 298 .write = &vmwdt_write,
299 .owner = THIS_MODULE, 299 .owner = THIS_MODULE,
300 .llseek = noop_llseek,
300}; 301};
301 302
302static struct miscdevice vmwdt_dev = { 303static struct miscdevice vmwdt_dev = {
diff --git a/drivers/s390/char/zcore.c b/drivers/s390/char/zcore.c
index f5ea3384a4b9..3b94044027c2 100644
--- a/drivers/s390/char/zcore.c
+++ b/drivers/s390/char/zcore.c
@@ -459,6 +459,7 @@ static const struct file_operations zcore_memmap_fops = {
459 .read = zcore_memmap_read, 459 .read = zcore_memmap_read,
460 .open = zcore_memmap_open, 460 .open = zcore_memmap_open,
461 .release = zcore_memmap_release, 461 .release = zcore_memmap_release,
462 .llseek = no_llseek,
462}; 463};
463 464
464static ssize_t zcore_reipl_write(struct file *filp, const char __user *buf, 465static ssize_t zcore_reipl_write(struct file *filp, const char __user *buf,
@@ -486,6 +487,7 @@ static const struct file_operations zcore_reipl_fops = {
486 .write = zcore_reipl_write, 487 .write = zcore_reipl_write,
487 .open = zcore_reipl_open, 488 .open = zcore_reipl_open,
488 .release = zcore_reipl_release, 489 .release = zcore_reipl_release,
490 .llseek = no_llseek,
489}; 491};
490 492
491#ifdef CONFIG_32BIT 493#ifdef CONFIG_32BIT
diff --git a/drivers/s390/cio/chsc_sch.c b/drivers/s390/cio/chsc_sch.c
index a83877c664a6..f2b77e7bfc6f 100644
--- a/drivers/s390/cio/chsc_sch.c
+++ b/drivers/s390/cio/chsc_sch.c
@@ -806,6 +806,7 @@ static const struct file_operations chsc_fops = {
806 .open = nonseekable_open, 806 .open = nonseekable_open,
807 .unlocked_ioctl = chsc_ioctl, 807 .unlocked_ioctl = chsc_ioctl,
808 .compat_ioctl = chsc_ioctl, 808 .compat_ioctl = chsc_ioctl,
809 .llseek = no_llseek,
809}; 810};
810 811
811static struct miscdevice chsc_misc_device = { 812static struct miscdevice chsc_misc_device = {
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index ac94ac751459..ca8e1c240c3c 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -1067,6 +1067,7 @@ static ssize_t cio_settle_write(struct file *file, const char __user *buf,
1067static const struct file_operations cio_settle_proc_fops = { 1067static const struct file_operations cio_settle_proc_fops = {
1068 .open = nonseekable_open, 1068 .open = nonseekable_open,
1069 .write = cio_settle_write, 1069 .write = cio_settle_write,
1070 .llseek = no_llseek,
1070}; 1071};
1071 1072
1072static int __init cio_settle_init(void) 1073static int __init cio_settle_init(void)
diff --git a/drivers/s390/crypto/zcrypt_api.c b/drivers/s390/crypto/zcrypt_api.c
index 41e0aaefafd5..f5221749d180 100644
--- a/drivers/s390/crypto/zcrypt_api.c
+++ b/drivers/s390/crypto/zcrypt_api.c
@@ -897,7 +897,8 @@ static const struct file_operations zcrypt_fops = {
897 .compat_ioctl = zcrypt_compat_ioctl, 897 .compat_ioctl = zcrypt_compat_ioctl,
898#endif 898#endif
899 .open = zcrypt_open, 899 .open = zcrypt_open,
900 .release = zcrypt_release 900 .release = zcrypt_release,
901 .llseek = no_llseek,
901}; 902};
902 903
903/* 904/*
diff --git a/drivers/s390/scsi/zfcp_cfdc.c b/drivers/s390/scsi/zfcp_cfdc.c
index fcbd2b756da4..1838cda68ba8 100644
--- a/drivers/s390/scsi/zfcp_cfdc.c
+++ b/drivers/s390/scsi/zfcp_cfdc.c
@@ -251,8 +251,9 @@ static const struct file_operations zfcp_cfdc_fops = {
251 .open = nonseekable_open, 251 .open = nonseekable_open,
252 .unlocked_ioctl = zfcp_cfdc_dev_ioctl, 252 .unlocked_ioctl = zfcp_cfdc_dev_ioctl,
253#ifdef CONFIG_COMPAT 253#ifdef CONFIG_COMPAT
254 .compat_ioctl = zfcp_cfdc_dev_ioctl 254 .compat_ioctl = zfcp_cfdc_dev_ioctl,
255#endif 255#endif
256 .llseek = no_llseek,
256}; 257};
257 258
258struct miscdevice zfcp_cfdc_misc = { 259struct miscdevice zfcp_cfdc_misc = {
diff --git a/drivers/sbus/char/display7seg.c b/drivers/sbus/char/display7seg.c
index 1690e53fb84a..55f71ea9c418 100644
--- a/drivers/sbus/char/display7seg.c
+++ b/drivers/sbus/char/display7seg.c
@@ -162,6 +162,7 @@ static const struct file_operations d7s_fops = {
162 .compat_ioctl = d7s_ioctl, 162 .compat_ioctl = d7s_ioctl,
163 .open = d7s_open, 163 .open = d7s_open,
164 .release = d7s_release, 164 .release = d7s_release,
165 .llseek = noop_llseek,
165}; 166};
166 167
167static struct miscdevice d7s_miscdev = { 168static struct miscdevice d7s_miscdev = {
diff --git a/drivers/sbus/char/envctrl.c b/drivers/sbus/char/envctrl.c
index 078e5f4520ef..8ce414e39489 100644
--- a/drivers/sbus/char/envctrl.c
+++ b/drivers/sbus/char/envctrl.c
@@ -720,6 +720,7 @@ static const struct file_operations envctrl_fops = {
720#endif 720#endif
721 .open = envctrl_open, 721 .open = envctrl_open,
722 .release = envctrl_release, 722 .release = envctrl_release,
723 .llseek = noop_llseek,
723}; 724};
724 725
725static struct miscdevice envctrl_dev = { 726static struct miscdevice envctrl_dev = {
diff --git a/drivers/sbus/char/jsflash.c b/drivers/sbus/char/jsflash.c
index 4942050dc5b6..13f48e28a1e1 100644
--- a/drivers/sbus/char/jsflash.c
+++ b/drivers/sbus/char/jsflash.c
@@ -27,7 +27,7 @@
27 */ 27 */
28 28
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/smp_lock.h> 30#include <linux/mutex.h>
31#include <linux/types.h> 31#include <linux/types.h>
32#include <linux/errno.h> 32#include <linux/errno.h>
33#include <linux/miscdevice.h> 33#include <linux/miscdevice.h>
@@ -68,6 +68,8 @@
68#define JSF_PART_BITS 2 /* 2 bits of minors to cover JSF_NPART */ 68#define JSF_PART_BITS 2 /* 2 bits of minors to cover JSF_NPART */
69#define JSF_PART_MASK 0x3 /* 2 bits mask */ 69#define JSF_PART_MASK 0x3 /* 2 bits mask */
70 70
71static DEFINE_MUTEX(jsf_mutex);
72
71/* 73/*
72 * Access functions. 74 * Access functions.
73 * We could ioremap(), but it's easier this way. 75 * We could ioremap(), but it's easier this way.
@@ -225,7 +227,7 @@ static loff_t jsf_lseek(struct file * file, loff_t offset, int orig)
225{ 227{
226 loff_t ret; 228 loff_t ret;
227 229
228 lock_kernel(); 230 mutex_lock(&jsf_mutex);
229 switch (orig) { 231 switch (orig) {
230 case 0: 232 case 0:
231 file->f_pos = offset; 233 file->f_pos = offset;
@@ -238,7 +240,7 @@ static loff_t jsf_lseek(struct file * file, loff_t offset, int orig)
238 default: 240 default:
239 ret = -EINVAL; 241 ret = -EINVAL;
240 } 242 }
241 unlock_kernel(); 243 mutex_unlock(&jsf_mutex);
242 return ret; 244 return ret;
243} 245}
244 246
@@ -384,18 +386,18 @@ static int jsf_ioctl_program(void __user *arg)
384 386
385static long jsf_ioctl(struct file *f, unsigned int cmd, unsigned long arg) 387static long jsf_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
386{ 388{
387 lock_kernel(); 389 mutex_lock(&jsf_mutex);
388 int error = -ENOTTY; 390 int error = -ENOTTY;
389 void __user *argp = (void __user *)arg; 391 void __user *argp = (void __user *)arg;
390 392
391 if (!capable(CAP_SYS_ADMIN)) { 393 if (!capable(CAP_SYS_ADMIN)) {
392 unlock_kernel(); 394 mutex_unlock(&jsf_mutex);
393 return -EPERM; 395 return -EPERM;
394 } 396 }
395 switch (cmd) { 397 switch (cmd) {
396 case JSFLASH_IDENT: 398 case JSFLASH_IDENT:
397 if (copy_to_user(argp, &jsf0.id, JSFIDSZ)) { 399 if (copy_to_user(argp, &jsf0.id, JSFIDSZ)) {
398 unlock_kernel(); 400 mutex_unlock(&jsf_mutex);
399 return -EFAULT; 401 return -EFAULT;
400 } 402 }
401 break; 403 break;
@@ -407,7 +409,7 @@ static long jsf_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
407 break; 409 break;
408 } 410 }
409 411
410 unlock_kernel(); 412 mutex_unlock(&jsf_mutex);
411 return error; 413 return error;
412} 414}
413 415
@@ -418,17 +420,17 @@ static int jsf_mmap(struct file * file, struct vm_area_struct * vma)
418 420
419static int jsf_open(struct inode * inode, struct file * filp) 421static int jsf_open(struct inode * inode, struct file * filp)
420{ 422{
421 lock_kernel(); 423 mutex_lock(&jsf_mutex);
422 if (jsf0.base == 0) { 424 if (jsf0.base == 0) {
423 unlock_kernel(); 425 mutex_unlock(&jsf_mutex);
424 return -ENXIO; 426 return -ENXIO;
425 } 427 }
426 if (test_and_set_bit(0, (void *)&jsf0.busy) != 0) { 428 if (test_and_set_bit(0, (void *)&jsf0.busy) != 0) {
427 unlock_kernel(); 429 mutex_unlock(&jsf_mutex);
428 return -EBUSY; 430 return -EBUSY;
429 } 431 }
430 432
431 unlock_kernel(); 433 mutex_unlock(&jsf_mutex);
432 return 0; /* XXX What security? */ 434 return 0; /* XXX What security? */
433} 435}
434 436
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index e20b7bdd4c78..fcf08b3f52c1 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -92,7 +92,6 @@
92#include <linux/pci.h> 92#include <linux/pci.h>
93#include <linux/time.h> 93#include <linux/time.h>
94#include <linux/mutex.h> 94#include <linux/mutex.h>
95#include <linux/smp_lock.h>
96#include <linux/slab.h> 95#include <linux/slab.h>
97#include <asm/io.h> 96#include <asm/io.h>
98#include <asm/irq.h> 97#include <asm/irq.h>
@@ -105,6 +104,7 @@
105 104
106/* Globals */ 105/* Globals */
107#define TW_DRIVER_VERSION "2.26.02.014" 106#define TW_DRIVER_VERSION "2.26.02.014"
107static DEFINE_MUTEX(twa_chrdev_mutex);
108static TW_Device_Extension *twa_device_extension_list[TW_MAX_SLOT]; 108static TW_Device_Extension *twa_device_extension_list[TW_MAX_SLOT];
109static unsigned int twa_device_extension_count; 109static unsigned int twa_device_extension_count;
110static int twa_major = -1; 110static int twa_major = -1;
@@ -222,7 +222,8 @@ static const struct file_operations twa_fops = {
222 .owner = THIS_MODULE, 222 .owner = THIS_MODULE,
223 .unlocked_ioctl = twa_chrdev_ioctl, 223 .unlocked_ioctl = twa_chrdev_ioctl,
224 .open = twa_chrdev_open, 224 .open = twa_chrdev_open,
225 .release = NULL 225 .release = NULL,
226 .llseek = noop_llseek,
226}; 227};
227 228
228/* This function will complete an aen request from the isr */ 229/* This function will complete an aen request from the isr */
@@ -658,7 +659,7 @@ static long twa_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long
658 int retval = TW_IOCTL_ERROR_OS_EFAULT; 659 int retval = TW_IOCTL_ERROR_OS_EFAULT;
659 void __user *argp = (void __user *)arg; 660 void __user *argp = (void __user *)arg;
660 661
661 lock_kernel(); 662 mutex_lock(&twa_chrdev_mutex);
662 663
663 /* Only let one of these through at a time */ 664 /* Only let one of these through at a time */
664 if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) { 665 if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) {
@@ -879,7 +880,7 @@ out3:
879out2: 880out2:
880 mutex_unlock(&tw_dev->ioctl_lock); 881 mutex_unlock(&tw_dev->ioctl_lock);
881out: 882out:
882 unlock_kernel(); 883 mutex_unlock(&twa_chrdev_mutex);
883 return retval; 884 return retval;
884} /* End twa_chrdev_ioctl() */ 885} /* End twa_chrdev_ioctl() */
885 886
@@ -890,7 +891,6 @@ static int twa_chrdev_open(struct inode *inode, struct file *file)
890 unsigned int minor_number; 891 unsigned int minor_number;
891 int retval = TW_IOCTL_ERROR_OS_ENODEV; 892 int retval = TW_IOCTL_ERROR_OS_ENODEV;
892 893
893 cycle_kernel_lock();
894 minor_number = iminor(inode); 894 minor_number = iminor(inode);
895 if (minor_number >= twa_device_extension_count) 895 if (minor_number >= twa_device_extension_count)
896 goto out; 896 goto out;
diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c
index f481e734aad4..6a95d111d207 100644
--- a/drivers/scsi/3w-sas.c
+++ b/drivers/scsi/3w-sas.c
@@ -64,7 +64,6 @@
64#include <linux/pci.h> 64#include <linux/pci.h>
65#include <linux/time.h> 65#include <linux/time.h>
66#include <linux/mutex.h> 66#include <linux/mutex.h>
67#include <linux/smp_lock.h>
68#include <linux/slab.h> 67#include <linux/slab.h>
69#include <asm/io.h> 68#include <asm/io.h>
70#include <asm/irq.h> 69#include <asm/irq.h>
@@ -77,6 +76,7 @@
77 76
78/* Globals */ 77/* Globals */
79#define TW_DRIVER_VERSION "3.26.02.000" 78#define TW_DRIVER_VERSION "3.26.02.000"
79static DEFINE_MUTEX(twl_chrdev_mutex);
80static TW_Device_Extension *twl_device_extension_list[TW_MAX_SLOT]; 80static TW_Device_Extension *twl_device_extension_list[TW_MAX_SLOT];
81static unsigned int twl_device_extension_count; 81static unsigned int twl_device_extension_count;
82static int twl_major = -1; 82static int twl_major = -1;
@@ -764,7 +764,7 @@ static long twl_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long
764 int retval = -EFAULT; 764 int retval = -EFAULT;
765 void __user *argp = (void __user *)arg; 765 void __user *argp = (void __user *)arg;
766 766
767 lock_kernel(); 767 mutex_lock(&twl_chrdev_mutex);
768 768
769 /* Only let one of these through at a time */ 769 /* Only let one of these through at a time */
770 if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) { 770 if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) {
@@ -861,7 +861,7 @@ out3:
861out2: 861out2:
862 mutex_unlock(&tw_dev->ioctl_lock); 862 mutex_unlock(&tw_dev->ioctl_lock);
863out: 863out:
864 unlock_kernel(); 864 mutex_unlock(&twl_chrdev_mutex);
865 return retval; 865 return retval;
866} /* End twl_chrdev_ioctl() */ 866} /* End twl_chrdev_ioctl() */
867 867
@@ -876,7 +876,6 @@ static int twl_chrdev_open(struct inode *inode, struct file *file)
876 goto out; 876 goto out;
877 } 877 }
878 878
879 cycle_kernel_lock();
880 minor_number = iminor(inode); 879 minor_number = iminor(inode);
881 if (minor_number >= twl_device_extension_count) 880 if (minor_number >= twl_device_extension_count)
882 goto out; 881 goto out;
@@ -890,7 +889,8 @@ static const struct file_operations twl_fops = {
890 .owner = THIS_MODULE, 889 .owner = THIS_MODULE,
891 .unlocked_ioctl = twl_chrdev_ioctl, 890 .unlocked_ioctl = twl_chrdev_ioctl,
892 .open = twl_chrdev_open, 891 .open = twl_chrdev_open,
893 .release = NULL 892 .release = NULL,
893 .llseek = noop_llseek,
894}; 894};
895 895
896/* This function passes sense data from firmware to scsi layer */ 896/* This function passes sense data from firmware to scsi layer */
diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c
index 30d735ad35b5..b1125341f4c8 100644
--- a/drivers/scsi/3w-xxxx.c
+++ b/drivers/scsi/3w-xxxx.c
@@ -199,7 +199,6 @@
199 199
200#include <linux/module.h> 200#include <linux/module.h>
201#include <linux/reboot.h> 201#include <linux/reboot.h>
202#include <linux/smp_lock.h>
203#include <linux/spinlock.h> 202#include <linux/spinlock.h>
204#include <linux/interrupt.h> 203#include <linux/interrupt.h>
205#include <linux/moduleparam.h> 204#include <linux/moduleparam.h>
@@ -221,6 +220,7 @@
221 220
222/* Globals */ 221/* Globals */
223#define TW_DRIVER_VERSION "1.26.02.003" 222#define TW_DRIVER_VERSION "1.26.02.003"
223static DEFINE_MUTEX(tw_mutex);
224static TW_Device_Extension *tw_device_extension_list[TW_MAX_SLOT]; 224static TW_Device_Extension *tw_device_extension_list[TW_MAX_SLOT];
225static int tw_device_extension_count = 0; 225static int tw_device_extension_count = 0;
226static int twe_major = -1; 226static int twe_major = -1;
@@ -900,10 +900,10 @@ static long tw_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long a
900 900
901 dprintk(KERN_WARNING "3w-xxxx: tw_chrdev_ioctl()\n"); 901 dprintk(KERN_WARNING "3w-xxxx: tw_chrdev_ioctl()\n");
902 902
903 lock_kernel(); 903 mutex_lock(&tw_mutex);
904 /* Only let one of these through at a time */ 904 /* Only let one of these through at a time */
905 if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) { 905 if (mutex_lock_interruptible(&tw_dev->ioctl_lock)) {
906 unlock_kernel(); 906 mutex_unlock(&tw_mutex);
907 return -EINTR; 907 return -EINTR;
908 } 908 }
909 909
@@ -1034,7 +1034,7 @@ out2:
1034 dma_free_coherent(&tw_dev->tw_pci_dev->dev, data_buffer_length_adjusted+sizeof(TW_New_Ioctl) - 1, cpu_addr, dma_handle); 1034 dma_free_coherent(&tw_dev->tw_pci_dev->dev, data_buffer_length_adjusted+sizeof(TW_New_Ioctl) - 1, cpu_addr, dma_handle);
1035out: 1035out:
1036 mutex_unlock(&tw_dev->ioctl_lock); 1036 mutex_unlock(&tw_dev->ioctl_lock);
1037 unlock_kernel(); 1037 mutex_unlock(&tw_mutex);
1038 return retval; 1038 return retval;
1039} /* End tw_chrdev_ioctl() */ 1039} /* End tw_chrdev_ioctl() */
1040 1040
@@ -1044,7 +1044,6 @@ static int tw_chrdev_open(struct inode *inode, struct file *file)
1044{ 1044{
1045 unsigned int minor_number; 1045 unsigned int minor_number;
1046 1046
1047 cycle_kernel_lock();
1048 dprintk(KERN_WARNING "3w-xxxx: tw_ioctl_open()\n"); 1047 dprintk(KERN_WARNING "3w-xxxx: tw_ioctl_open()\n");
1049 1048
1050 minor_number = iminor(inode); 1049 minor_number = iminor(inode);
@@ -1059,7 +1058,8 @@ static const struct file_operations tw_fops = {
1059 .owner = THIS_MODULE, 1058 .owner = THIS_MODULE,
1060 .unlocked_ioctl = tw_chrdev_ioctl, 1059 .unlocked_ioctl = tw_chrdev_ioctl,
1061 .open = tw_chrdev_open, 1060 .open = tw_chrdev_open,
1062 .release = NULL 1061 .release = NULL,
1062 .llseek = noop_llseek,
1063}; 1063};
1064 1064
1065/* This function will free up device extension resources */ 1065/* This function will free up device extension resources */
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index cad6f9abaeb9..dae46d779c7b 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -38,7 +38,7 @@
38#include <linux/moduleparam.h> 38#include <linux/moduleparam.h>
39#include <linux/pci.h> 39#include <linux/pci.h>
40#include <linux/slab.h> 40#include <linux/slab.h>
41#include <linux/smp_lock.h> 41#include <linux/mutex.h>
42#include <linux/spinlock.h> 42#include <linux/spinlock.h>
43#include <linux/syscalls.h> 43#include <linux/syscalls.h>
44#include <linux/delay.h> 44#include <linux/delay.h>
@@ -76,6 +76,7 @@ MODULE_DESCRIPTION("Dell PERC2, 2/Si, 3/Si, 3/Di, "
76MODULE_LICENSE("GPL"); 76MODULE_LICENSE("GPL");
77MODULE_VERSION(AAC_DRIVER_FULL_VERSION); 77MODULE_VERSION(AAC_DRIVER_FULL_VERSION);
78 78
79static DEFINE_MUTEX(aac_mutex);
79static LIST_HEAD(aac_devices); 80static LIST_HEAD(aac_devices);
80static int aac_cfg_major = -1; 81static int aac_cfg_major = -1;
81char aac_driver_version[] = AAC_DRIVER_FULL_VERSION; 82char aac_driver_version[] = AAC_DRIVER_FULL_VERSION;
@@ -678,7 +679,7 @@ static int aac_cfg_open(struct inode *inode, struct file *file)
678 unsigned minor_number = iminor(inode); 679 unsigned minor_number = iminor(inode);
679 int err = -ENODEV; 680 int err = -ENODEV;
680 681
681 lock_kernel(); /* BKL pushdown: nothing else protects this list */ 682 mutex_lock(&aac_mutex); /* BKL pushdown: nothing else protects this list */
682 list_for_each_entry(aac, &aac_devices, entry) { 683 list_for_each_entry(aac, &aac_devices, entry) {
683 if (aac->id == minor_number) { 684 if (aac->id == minor_number) {
684 file->private_data = aac; 685 file->private_data = aac;
@@ -686,7 +687,7 @@ static int aac_cfg_open(struct inode *inode, struct file *file)
686 break; 687 break;
687 } 688 }
688 } 689 }
689 unlock_kernel(); 690 mutex_unlock(&aac_mutex);
690 691
691 return err; 692 return err;
692} 693}
@@ -711,9 +712,9 @@ static long aac_cfg_ioctl(struct file *file,
711 int ret; 712 int ret;
712 if (!capable(CAP_SYS_RAWIO)) 713 if (!capable(CAP_SYS_RAWIO))
713 return -EPERM; 714 return -EPERM;
714 lock_kernel(); 715 mutex_lock(&aac_mutex);
715 ret = aac_do_ioctl(file->private_data, cmd, (void __user *)arg); 716 ret = aac_do_ioctl(file->private_data, cmd, (void __user *)arg);
716 unlock_kernel(); 717 mutex_unlock(&aac_mutex);
717 718
718 return ret; 719 return ret;
719} 720}
@@ -722,7 +723,7 @@ static long aac_cfg_ioctl(struct file *file,
722static long aac_compat_do_ioctl(struct aac_dev *dev, unsigned cmd, unsigned long arg) 723static long aac_compat_do_ioctl(struct aac_dev *dev, unsigned cmd, unsigned long arg)
723{ 724{
724 long ret; 725 long ret;
725 lock_kernel(); 726 mutex_lock(&aac_mutex);
726 switch (cmd) { 727 switch (cmd) {
727 case FSACTL_MINIPORT_REV_CHECK: 728 case FSACTL_MINIPORT_REV_CHECK:
728 case FSACTL_SENDFIB: 729 case FSACTL_SENDFIB:
@@ -756,7 +757,7 @@ static long aac_compat_do_ioctl(struct aac_dev *dev, unsigned cmd, unsigned long
756 ret = -ENOIOCTLCMD; 757 ret = -ENOIOCTLCMD;
757 break; 758 break;
758 } 759 }
759 unlock_kernel(); 760 mutex_unlock(&aac_mutex);
760 return ret; 761 return ret;
761} 762}
762 763
@@ -1039,6 +1040,7 @@ static const struct file_operations aac_cfg_fops = {
1039 .compat_ioctl = aac_compat_cfg_ioctl, 1040 .compat_ioctl = aac_compat_cfg_ioctl,
1040#endif 1041#endif
1041 .open = aac_cfg_open, 1042 .open = aac_cfg_open,
1043 .llseek = noop_llseek,
1042}; 1044};
1043 1045
1044static struct scsi_host_template aac_driver_template = { 1046static struct scsi_host_template aac_driver_template = {
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index d6532187f616..a15474eef5f7 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -22,7 +22,6 @@
22#include <linux/chio.h> /* here are all the ioctls */ 22#include <linux/chio.h> /* here are all the ioctls */
23#include <linux/mutex.h> 23#include <linux/mutex.h>
24#include <linux/idr.h> 24#include <linux/idr.h>
25#include <linux/smp_lock.h>
26#include <linux/slab.h> 25#include <linux/slab.h>
27 26
28#include <scsi/scsi.h> 27#include <scsi/scsi.h>
@@ -44,6 +43,7 @@ MODULE_LICENSE("GPL");
44MODULE_ALIAS_CHARDEV_MAJOR(SCSI_CHANGER_MAJOR); 43MODULE_ALIAS_CHARDEV_MAJOR(SCSI_CHANGER_MAJOR);
45MODULE_ALIAS_SCSI_DEVICE(TYPE_MEDIUM_CHANGER); 44MODULE_ALIAS_SCSI_DEVICE(TYPE_MEDIUM_CHANGER);
46 45
46static DEFINE_MUTEX(ch_mutex);
47static int init = 1; 47static int init = 1;
48module_param(init, int, 0444); 48module_param(init, int, 0444);
49MODULE_PARM_DESC(init, \ 49MODULE_PARM_DESC(init, \
@@ -581,19 +581,19 @@ ch_open(struct inode *inode, struct file *file)
581 scsi_changer *ch; 581 scsi_changer *ch;
582 int minor = iminor(inode); 582 int minor = iminor(inode);
583 583
584 lock_kernel(); 584 mutex_lock(&ch_mutex);
585 spin_lock(&ch_index_lock); 585 spin_lock(&ch_index_lock);
586 ch = idr_find(&ch_index_idr, minor); 586 ch = idr_find(&ch_index_idr, minor);
587 587
588 if (NULL == ch || scsi_device_get(ch->device)) { 588 if (NULL == ch || scsi_device_get(ch->device)) {
589 spin_unlock(&ch_index_lock); 589 spin_unlock(&ch_index_lock);
590 unlock_kernel(); 590 mutex_unlock(&ch_mutex);
591 return -ENXIO; 591 return -ENXIO;
592 } 592 }
593 spin_unlock(&ch_index_lock); 593 spin_unlock(&ch_index_lock);
594 594
595 file->private_data = ch; 595 file->private_data = ch;
596 unlock_kernel(); 596 mutex_unlock(&ch_mutex);
597 return 0; 597 return 0;
598} 598}
599 599
@@ -981,6 +981,7 @@ static const struct file_operations changer_fops = {
981#ifdef CONFIG_COMPAT 981#ifdef CONFIG_COMPAT
982 .compat_ioctl = ch_ioctl_compat, 982 .compat_ioctl = ch_ioctl_compat,
983#endif 983#endif
984 .llseek = noop_llseek,
984}; 985};
985 986
986static int __init init_ch_module(void) 987static int __init init_ch_module(void)
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index ffc1edf5e80d..23dec0063385 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -49,7 +49,6 @@ MODULE_DESCRIPTION("Adaptec I2O RAID Driver");
49#include <linux/kernel.h> /* for printk */ 49#include <linux/kernel.h> /* for printk */
50#include <linux/sched.h> 50#include <linux/sched.h>
51#include <linux/reboot.h> 51#include <linux/reboot.h>
52#include <linux/smp_lock.h>
53#include <linux/spinlock.h> 52#include <linux/spinlock.h>
54#include <linux/dma-mapping.h> 53#include <linux/dma-mapping.h>
55 54
@@ -76,6 +75,7 @@ MODULE_DESCRIPTION("Adaptec I2O RAID Driver");
76 * Needed for our management apps 75 * Needed for our management apps
77 *============================================================================ 76 *============================================================================
78 */ 77 */
78static DEFINE_MUTEX(adpt_mutex);
79static dpt_sig_S DPTI_sig = { 79static dpt_sig_S DPTI_sig = {
80 {'d', 'P', 't', 'S', 'i', 'G'}, SIG_VERSION, 80 {'d', 'P', 't', 'S', 'i', 'G'}, SIG_VERSION,
81#ifdef __i386__ 81#ifdef __i386__
@@ -126,6 +126,7 @@ static const struct file_operations adpt_fops = {
126#ifdef CONFIG_COMPAT 126#ifdef CONFIG_COMPAT
127 .compat_ioctl = compat_adpt_ioctl, 127 .compat_ioctl = compat_adpt_ioctl,
128#endif 128#endif
129 .llseek = noop_llseek,
129}; 130};
130 131
131/* Structures and definitions for synchronous message posting. 132/* Structures and definitions for synchronous message posting.
@@ -1732,12 +1733,12 @@ static int adpt_open(struct inode *inode, struct file *file)
1732 int minor; 1733 int minor;
1733 adpt_hba* pHba; 1734 adpt_hba* pHba;
1734 1735
1735 lock_kernel(); 1736 mutex_lock(&adpt_mutex);
1736 //TODO check for root access 1737 //TODO check for root access
1737 // 1738 //
1738 minor = iminor(inode); 1739 minor = iminor(inode);
1739 if (minor >= hba_count) { 1740 if (minor >= hba_count) {
1740 unlock_kernel(); 1741 mutex_unlock(&adpt_mutex);
1741 return -ENXIO; 1742 return -ENXIO;
1742 } 1743 }
1743 mutex_lock(&adpt_configuration_lock); 1744 mutex_lock(&adpt_configuration_lock);
@@ -1748,7 +1749,7 @@ static int adpt_open(struct inode *inode, struct file *file)
1748 } 1749 }
1749 if (pHba == NULL) { 1750 if (pHba == NULL) {
1750 mutex_unlock(&adpt_configuration_lock); 1751 mutex_unlock(&adpt_configuration_lock);
1751 unlock_kernel(); 1752 mutex_unlock(&adpt_mutex);
1752 return -ENXIO; 1753 return -ENXIO;
1753 } 1754 }
1754 1755
@@ -1759,7 +1760,7 @@ static int adpt_open(struct inode *inode, struct file *file)
1759 1760
1760 pHba->in_use = 1; 1761 pHba->in_use = 1;
1761 mutex_unlock(&adpt_configuration_lock); 1762 mutex_unlock(&adpt_configuration_lock);
1762 unlock_kernel(); 1763 mutex_unlock(&adpt_mutex);
1763 1764
1764 return 0; 1765 return 0;
1765} 1766}
@@ -2160,9 +2161,9 @@ static long adpt_unlocked_ioctl(struct file *file, uint cmd, ulong arg)
2160 2161
2161 inode = file->f_dentry->d_inode; 2162 inode = file->f_dentry->d_inode;
2162 2163
2163 lock_kernel(); 2164 mutex_lock(&adpt_mutex);
2164 ret = adpt_ioctl(inode, file, cmd, arg); 2165 ret = adpt_ioctl(inode, file, cmd, arg);
2165 unlock_kernel(); 2166 mutex_unlock(&adpt_mutex);
2166 2167
2167 return ret; 2168 return ret;
2168} 2169}
@@ -2176,7 +2177,7 @@ static long compat_adpt_ioctl(struct file *file,
2176 2177
2177 inode = file->f_dentry->d_inode; 2178 inode = file->f_dentry->d_inode;
2178 2179
2179 lock_kernel(); 2180 mutex_lock(&adpt_mutex);
2180 2181
2181 switch(cmd) { 2182 switch(cmd) {
2182 case DPT_SIGNATURE: 2183 case DPT_SIGNATURE:
@@ -2194,7 +2195,7 @@ static long compat_adpt_ioctl(struct file *file,
2194 ret = -ENOIOCTLCMD; 2195 ret = -ENOIOCTLCMD;
2195 } 2196 }
2196 2197
2197 unlock_kernel(); 2198 mutex_unlock(&adpt_mutex);
2198 2199
2199 return ret; 2200 return ret;
2200} 2201}
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index b860d650a563..5a3f93101017 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -120,7 +120,7 @@
120#include <linux/timer.h> 120#include <linux/timer.h>
121#include <linux/dma-mapping.h> 121#include <linux/dma-mapping.h>
122#include <linux/list.h> 122#include <linux/list.h>
123#include <linux/smp_lock.h> 123#include <linux/mutex.h>
124#include <linux/slab.h> 124#include <linux/slab.h>
125 125
126#ifdef GDTH_RTC 126#ifdef GDTH_RTC
@@ -140,6 +140,7 @@
140#include <scsi/scsi_host.h> 140#include <scsi/scsi_host.h>
141#include "gdth.h" 141#include "gdth.h"
142 142
143static DEFINE_MUTEX(gdth_mutex);
143static void gdth_delay(int milliseconds); 144static void gdth_delay(int milliseconds);
144static void gdth_eval_mapping(u32 size, u32 *cyls, int *heads, int *secs); 145static void gdth_eval_mapping(u32 size, u32 *cyls, int *heads, int *secs);
145static irqreturn_t gdth_interrupt(int irq, void *dev_id); 146static irqreturn_t gdth_interrupt(int irq, void *dev_id);
@@ -372,6 +373,7 @@ static const struct file_operations gdth_fops = {
372 .unlocked_ioctl = gdth_unlocked_ioctl, 373 .unlocked_ioctl = gdth_unlocked_ioctl,
373 .open = gdth_open, 374 .open = gdth_open,
374 .release = gdth_close, 375 .release = gdth_close,
376 .llseek = noop_llseek,
375}; 377};
376 378
377#include "gdth_proc.h" 379#include "gdth_proc.h"
@@ -4042,12 +4044,12 @@ static int gdth_open(struct inode *inode, struct file *filep)
4042{ 4044{
4043 gdth_ha_str *ha; 4045 gdth_ha_str *ha;
4044 4046
4045 lock_kernel(); 4047 mutex_lock(&gdth_mutex);
4046 list_for_each_entry(ha, &gdth_instances, list) { 4048 list_for_each_entry(ha, &gdth_instances, list) {
4047 if (!ha->sdev) 4049 if (!ha->sdev)
4048 ha->sdev = scsi_get_host_dev(ha->shost); 4050 ha->sdev = scsi_get_host_dev(ha->shost);
4049 } 4051 }
4050 unlock_kernel(); 4052 mutex_unlock(&gdth_mutex);
4051 4053
4052 TRACE(("gdth_open()\n")); 4054 TRACE(("gdth_open()\n"));
4053 return 0; 4055 return 0;
@@ -4615,9 +4617,9 @@ static long gdth_unlocked_ioctl(struct file *file, unsigned int cmd,
4615{ 4617{
4616 int ret; 4618 int ret;
4617 4619
4618 lock_kernel(); 4620 mutex_lock(&gdth_mutex);
4619 ret = gdth_ioctl(file, cmd, arg); 4621 ret = gdth_ioctl(file, cmd, arg);
4620 unlock_kernel(); 4622 mutex_unlock(&gdth_mutex);
4621 4623
4622 return ret; 4624 return ret;
4623} 4625}
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 0b6e3228610a..7ceb5cf12c6b 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -46,7 +46,7 @@
46#include <linux/pci.h> 46#include <linux/pci.h>
47#include <linux/init.h> 47#include <linux/init.h>
48#include <linux/dma-mapping.h> 48#include <linux/dma-mapping.h>
49#include <linux/smp_lock.h> 49#include <linux/mutex.h>
50#include <linux/slab.h> 50#include <linux/slab.h>
51#include <scsi/scsicam.h> 51#include <scsi/scsicam.h>
52 52
@@ -62,6 +62,7 @@ MODULE_DESCRIPTION ("LSI Logic MegaRAID legacy driver");
62MODULE_LICENSE ("GPL"); 62MODULE_LICENSE ("GPL");
63MODULE_VERSION(MEGARAID_MODULE_VERSION); 63MODULE_VERSION(MEGARAID_MODULE_VERSION);
64 64
65static DEFINE_MUTEX(megadev_mutex);
65static unsigned int max_cmd_per_lun = DEF_CMD_PER_LUN; 66static unsigned int max_cmd_per_lun = DEF_CMD_PER_LUN;
66module_param(max_cmd_per_lun, uint, 0); 67module_param(max_cmd_per_lun, uint, 0);
67MODULE_PARM_DESC(max_cmd_per_lun, "Maximum number of commands which can be issued to a single LUN (default=DEF_CMD_PER_LUN=63)"); 68MODULE_PARM_DESC(max_cmd_per_lun, "Maximum number of commands which can be issued to a single LUN (default=DEF_CMD_PER_LUN=63)");
@@ -101,6 +102,7 @@ static const struct file_operations megadev_fops = {
101 .owner = THIS_MODULE, 102 .owner = THIS_MODULE,
102 .unlocked_ioctl = megadev_unlocked_ioctl, 103 .unlocked_ioctl = megadev_unlocked_ioctl,
103 .open = megadev_open, 104 .open = megadev_open,
105 .llseek = noop_llseek,
104}; 106};
105 107
106/* 108/*
@@ -3282,7 +3284,6 @@ mega_init_scb(adapter_t *adapter)
3282static int 3284static int
3283megadev_open (struct inode *inode, struct file *filep) 3285megadev_open (struct inode *inode, struct file *filep)
3284{ 3286{
3285 cycle_kernel_lock();
3286 /* 3287 /*
3287 * Only allow superuser to access private ioctl interface 3288 * Only allow superuser to access private ioctl interface
3288 */ 3289 */
@@ -3701,9 +3702,9 @@ megadev_unlocked_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
3701{ 3702{
3702 int ret; 3703 int ret;
3703 3704
3704 lock_kernel(); 3705 mutex_lock(&megadev_mutex);
3705 ret = megadev_ioctl(filep, cmd, arg); 3706 ret = megadev_ioctl(filep, cmd, arg);
3706 unlock_kernel(); 3707 mutex_unlock(&megadev_mutex);
3707 3708
3708 return ret; 3709 return ret;
3709} 3710}
diff --git a/drivers/scsi/megaraid/megaraid_mm.c b/drivers/scsi/megaraid/megaraid_mm.c
index 41f82f76d884..a7008c0c24f9 100644
--- a/drivers/scsi/megaraid/megaraid_mm.c
+++ b/drivers/scsi/megaraid/megaraid_mm.c
@@ -16,11 +16,12 @@
16 */ 16 */
17#include <linux/sched.h> 17#include <linux/sched.h>
18#include <linux/slab.h> 18#include <linux/slab.h>
19#include <linux/smp_lock.h> 19#include <linux/mutex.h>
20#include "megaraid_mm.h" 20#include "megaraid_mm.h"
21 21
22 22
23// Entry points for char node driver 23// Entry points for char node driver
24static DEFINE_MUTEX(mraid_mm_mutex);
24static int mraid_mm_open(struct inode *, struct file *); 25static int mraid_mm_open(struct inode *, struct file *);
25static long mraid_mm_unlocked_ioctl(struct file *, uint, unsigned long); 26static long mraid_mm_unlocked_ioctl(struct file *, uint, unsigned long);
26 27
@@ -75,6 +76,7 @@ static const struct file_operations lsi_fops = {
75 .compat_ioctl = mraid_mm_compat_ioctl, 76 .compat_ioctl = mraid_mm_compat_ioctl,
76#endif 77#endif
77 .owner = THIS_MODULE, 78 .owner = THIS_MODULE,
79 .llseek = noop_llseek,
78}; 80};
79 81
80static struct miscdevice megaraid_mm_dev = { 82static struct miscdevice megaraid_mm_dev = {
@@ -98,7 +100,6 @@ mraid_mm_open(struct inode *inode, struct file *filep)
98 */ 100 */
99 if (!capable(CAP_SYS_ADMIN)) return (-EACCES); 101 if (!capable(CAP_SYS_ADMIN)) return (-EACCES);
100 102
101 cycle_kernel_lock();
102 return 0; 103 return 0;
103} 104}
104 105
@@ -224,9 +225,9 @@ mraid_mm_unlocked_ioctl(struct file *filep, unsigned int cmd,
224 int err; 225 int err;
225 226
226 /* inconsistant: mraid_mm_compat_ioctl doesn't take the BKL */ 227 /* inconsistant: mraid_mm_compat_ioctl doesn't take the BKL */
227 lock_kernel(); 228 mutex_lock(&mraid_mm_mutex);
228 err = mraid_mm_ioctl(filep, cmd, arg); 229 err = mraid_mm_ioctl(filep, cmd, arg);
229 unlock_kernel(); 230 mutex_unlock(&mraid_mm_mutex);
230 231
231 return err; 232 return err;
232} 233}
diff --git a/drivers/scsi/megaraid/megaraid_sas.c b/drivers/scsi/megaraid/megaraid_sas.c
index 99e4478c3f3e..51e2579a743a 100644
--- a/drivers/scsi/megaraid/megaraid_sas.c
+++ b/drivers/scsi/megaraid/megaraid_sas.c
@@ -33,7 +33,6 @@
33#include <linux/spinlock.h> 33#include <linux/spinlock.h>
34#include <linux/interrupt.h> 34#include <linux/interrupt.h>
35#include <linux/delay.h> 35#include <linux/delay.h>
36#include <linux/smp_lock.h>
37#include <linux/uio.h> 36#include <linux/uio.h>
38#include <linux/slab.h> 37#include <linux/slab.h>
39#include <asm/uaccess.h> 38#include <asm/uaccess.h>
@@ -3557,7 +3556,6 @@ static void megasas_shutdown(struct pci_dev *pdev)
3557 */ 3556 */
3558static int megasas_mgmt_open(struct inode *inode, struct file *filep) 3557static int megasas_mgmt_open(struct inode *inode, struct file *filep)
3559{ 3558{
3560 cycle_kernel_lock();
3561 /* 3559 /*
3562 * Allow only those users with admin rights 3560 * Allow only those users with admin rights
3563 */ 3561 */
@@ -3957,6 +3955,7 @@ static const struct file_operations megasas_mgmt_fops = {
3957#ifdef CONFIG_COMPAT 3955#ifdef CONFIG_COMPAT
3958 .compat_ioctl = megasas_mgmt_compat_ioctl, 3956 .compat_ioctl = megasas_mgmt_compat_ioctl,
3959#endif 3957#endif
3958 .llseek = noop_llseek,
3960}; 3959};
3961 3960
3962/* 3961/*
diff --git a/drivers/scsi/mpt2sas/mpt2sas_ctl.c b/drivers/scsi/mpt2sas/mpt2sas_ctl.c
index b774973f0765..40cb8aeb21b1 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_ctl.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_ctl.c
@@ -51,7 +51,7 @@
51#include <linux/types.h> 51#include <linux/types.h>
52#include <linux/pci.h> 52#include <linux/pci.h>
53#include <linux/delay.h> 53#include <linux/delay.h>
54#include <linux/smp_lock.h> 54#include <linux/mutex.h>
55#include <linux/compat.h> 55#include <linux/compat.h>
56#include <linux/poll.h> 56#include <linux/poll.h>
57 57
@@ -61,6 +61,7 @@
61#include "mpt2sas_base.h" 61#include "mpt2sas_base.h"
62#include "mpt2sas_ctl.h" 62#include "mpt2sas_ctl.h"
63 63
64static DEFINE_MUTEX(_ctl_mutex);
64static struct fasync_struct *async_queue; 65static struct fasync_struct *async_queue;
65static DECLARE_WAIT_QUEUE_HEAD(ctl_poll_wait); 66static DECLARE_WAIT_QUEUE_HEAD(ctl_poll_wait);
66 67
@@ -2238,9 +2239,9 @@ _ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
2238{ 2239{
2239 long ret; 2240 long ret;
2240 2241
2241 lock_kernel(); 2242 mutex_lock(&_ctl_mutex);
2242 ret = _ctl_ioctl_main(file, cmd, (void __user *)arg); 2243 ret = _ctl_ioctl_main(file, cmd, (void __user *)arg);
2243 unlock_kernel(); 2244 mutex_unlock(&_ctl_mutex);
2244 return ret; 2245 return ret;
2245} 2246}
2246 2247
@@ -2309,12 +2310,12 @@ _ctl_ioctl_compat(struct file *file, unsigned cmd, unsigned long arg)
2309{ 2310{
2310 long ret; 2311 long ret;
2311 2312
2312 lock_kernel(); 2313 mutex_lock(&_ctl_mutex);
2313 if (cmd == MPT2COMMAND32) 2314 if (cmd == MPT2COMMAND32)
2314 ret = _ctl_compat_mpt_command(file, cmd, arg); 2315 ret = _ctl_compat_mpt_command(file, cmd, arg);
2315 else 2316 else
2316 ret = _ctl_ioctl_main(file, cmd, (void __user *)arg); 2317 ret = _ctl_ioctl_main(file, cmd, (void __user *)arg);
2317 unlock_kernel(); 2318 mutex_unlock(&_ctl_mutex);
2318 return ret; 2319 return ret;
2319} 2320}
2320#endif 2321#endif
@@ -2952,6 +2953,7 @@ static const struct file_operations ctl_fops = {
2952#ifdef CONFIG_COMPAT 2953#ifdef CONFIG_COMPAT
2953 .compat_ioctl = _ctl_ioctl_compat, 2954 .compat_ioctl = _ctl_ioctl_compat,
2954#endif 2955#endif
2956 .llseek = noop_llseek,
2955}; 2957};
2956 2958
2957static struct miscdevice ctl_dev = { 2959static struct miscdevice ctl_dev = {
diff --git a/drivers/scsi/osd/osd_uld.c b/drivers/scsi/osd/osd_uld.c
index ffdd9fdb9995..b31a8e3841d7 100644
--- a/drivers/scsi/osd/osd_uld.c
+++ b/drivers/scsi/osd/osd_uld.c
@@ -182,6 +182,7 @@ static const struct file_operations osd_fops = {
182 .open = osd_uld_open, 182 .open = osd_uld_open,
183 .release = osd_uld_release, 183 .release = osd_uld_release,
184 .unlocked_ioctl = osd_uld_ioctl, 184 .unlocked_ioctl = osd_uld_ioctl,
185 .llseek = noop_llseek,
185}; 186};
186 187
187struct osd_dev *osduld_path_lookup(const char *name) 188struct osd_dev *osduld_path_lookup(const char *name)
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index 278b352ae78d..54de1d1af1a7 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -51,7 +51,7 @@ static const char * osst_version = "0.99.4";
51#include <linux/moduleparam.h> 51#include <linux/moduleparam.h>
52#include <linux/delay.h> 52#include <linux/delay.h>
53#include <linux/jiffies.h> 53#include <linux/jiffies.h>
54#include <linux/smp_lock.h> 54#include <linux/mutex.h>
55#include <asm/uaccess.h> 55#include <asm/uaccess.h>
56#include <asm/dma.h> 56#include <asm/dma.h>
57#include <asm/system.h> 57#include <asm/system.h>
@@ -80,6 +80,7 @@ static const char * osst_version = "0.99.4";
80#include "osst_options.h" 80#include "osst_options.h"
81#include "osst_detect.h" 81#include "osst_detect.h"
82 82
83static DEFINE_MUTEX(osst_int_mutex);
83static int max_dev = 0; 84static int max_dev = 0;
84static int write_threshold_kbs = 0; 85static int write_threshold_kbs = 0;
85static int max_sg_segs = 0; 86static int max_sg_segs = 0;
@@ -4807,9 +4808,9 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp)
4807{ 4808{
4808 int ret; 4809 int ret;
4809 4810
4810 lock_kernel(); 4811 mutex_lock(&osst_int_mutex);
4811 ret = __os_scsi_tape_open(inode, filp); 4812 ret = __os_scsi_tape_open(inode, filp);
4812 unlock_kernel(); 4813 mutex_unlock(&osst_int_mutex);
4813 return ret; 4814 return ret;
4814} 4815}
4815 4816
@@ -4943,9 +4944,9 @@ static long osst_ioctl(struct file * file,
4943 char * name = tape_name(STp); 4944 char * name = tape_name(STp);
4944 void __user * p = (void __user *)arg; 4945 void __user * p = (void __user *)arg;
4945 4946
4946 lock_kernel(); 4947 mutex_lock(&osst_int_mutex);
4947 if (mutex_lock_interruptible(&STp->lock)) { 4948 if (mutex_lock_interruptible(&STp->lock)) {
4948 unlock_kernel(); 4949 mutex_unlock(&osst_int_mutex);
4949 return -ERESTARTSYS; 4950 return -ERESTARTSYS;
4950 } 4951 }
4951 4952
@@ -5260,14 +5261,14 @@ static long osst_ioctl(struct file * file,
5260 mutex_unlock(&STp->lock); 5261 mutex_unlock(&STp->lock);
5261 5262
5262 retval = scsi_ioctl(STp->device, cmd_in, p); 5263 retval = scsi_ioctl(STp->device, cmd_in, p);
5263 unlock_kernel(); 5264 mutex_unlock(&osst_int_mutex);
5264 return retval; 5265 return retval;
5265 5266
5266out: 5267out:
5267 if (SRpnt) osst_release_request(SRpnt); 5268 if (SRpnt) osst_release_request(SRpnt);
5268 5269
5269 mutex_unlock(&STp->lock); 5270 mutex_unlock(&STp->lock);
5270 unlock_kernel(); 5271 mutex_unlock(&osst_int_mutex);
5271 5272
5272 return retval; 5273 return retval;
5273} 5274}
diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index ecc45c8b4e6b..4b8765785aeb 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -4165,6 +4165,7 @@ static const struct file_operations pmcraid_fops = {
4165#ifdef CONFIG_COMPAT 4165#ifdef CONFIG_COMPAT
4166 .compat_ioctl = pmcraid_chr_ioctl, 4166 .compat_ioctl = pmcraid_chr_ioctl,
4167#endif 4167#endif
4168 .llseek = noop_llseek,
4168}; 4169};
4169 4170
4170 4171
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 1e4bff695254..9946fac54255 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -3948,6 +3948,7 @@ static struct pci_driver qla2xxx_pci_driver = {
3948 3948
3949static struct file_operations apidev_fops = { 3949static struct file_operations apidev_fops = {
3950 .owner = THIS_MODULE, 3950 .owner = THIS_MODULE,
3951 .llseek = noop_llseek,
3951}; 3952};
3952 3953
3953/** 3954/**
diff --git a/drivers/scsi/scsi_tgt_if.c b/drivers/scsi/scsi_tgt_if.c
index a87e21c35ef2..0172de197008 100644
--- a/drivers/scsi/scsi_tgt_if.c
+++ b/drivers/scsi/scsi_tgt_if.c
@@ -22,7 +22,6 @@
22#include <linux/miscdevice.h> 22#include <linux/miscdevice.h>
23#include <linux/gfp.h> 23#include <linux/gfp.h>
24#include <linux/file.h> 24#include <linux/file.h>
25#include <linux/smp_lock.h>
26#include <net/tcp.h> 25#include <net/tcp.h>
27#include <scsi/scsi.h> 26#include <scsi/scsi.h>
28#include <scsi/scsi_cmnd.h> 27#include <scsi/scsi_cmnd.h>
@@ -323,7 +322,6 @@ static int tgt_open(struct inode *inode, struct file *file)
323{ 322{
324 tx_ring.tr_idx = rx_ring.tr_idx = 0; 323 tx_ring.tr_idx = rx_ring.tr_idx = 0;
325 324
326 cycle_kernel_lock();
327 return 0; 325 return 0;
328} 326}
329 327
@@ -333,6 +331,7 @@ static const struct file_operations tgt_fops = {
333 .poll = tgt_poll, 331 .poll = tgt_poll,
334 .write = tgt_write, 332 .write = tgt_write,
335 .mmap = tgt_mmap, 333 .mmap = tgt_mmap,
334 .llseek = noop_llseek,
336}; 335};
337 336
338static struct miscdevice tgt_miscdev = { 337static struct miscdevice tgt_miscdev = {
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 78d616315d8e..58ec8f4efcc2 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -49,7 +49,7 @@ static int sg_version_num = 30534; /* 2 digits for each component */
49#include <linux/blkdev.h> 49#include <linux/blkdev.h>
50#include <linux/delay.h> 50#include <linux/delay.h>
51#include <linux/blktrace_api.h> 51#include <linux/blktrace_api.h>
52#include <linux/smp_lock.h> 52#include <linux/mutex.h>
53 53
54#include "scsi.h" 54#include "scsi.h"
55#include <scsi/scsi_dbg.h> 55#include <scsi/scsi_dbg.h>
@@ -103,6 +103,8 @@ static int scatter_elem_sz_prev = SG_SCATTER_SZ;
103static int sg_add(struct device *, struct class_interface *); 103static int sg_add(struct device *, struct class_interface *);
104static void sg_remove(struct device *, struct class_interface *); 104static void sg_remove(struct device *, struct class_interface *);
105 105
106static DEFINE_MUTEX(sg_mutex);
107
106static DEFINE_IDR(sg_index_idr); 108static DEFINE_IDR(sg_index_idr);
107static DEFINE_RWLOCK(sg_index_lock); /* Also used to lock 109static DEFINE_RWLOCK(sg_index_lock); /* Also used to lock
108 file descriptor list for device */ 110 file descriptor list for device */
@@ -229,7 +231,7 @@ sg_open(struct inode *inode, struct file *filp)
229 int res; 231 int res;
230 int retval; 232 int retval;
231 233
232 lock_kernel(); 234 mutex_lock(&sg_mutex);
233 nonseekable_open(inode, filp); 235 nonseekable_open(inode, filp);
234 SCSI_LOG_TIMEOUT(3, printk("sg_open: dev=%d, flags=0x%x\n", dev, flags)); 236 SCSI_LOG_TIMEOUT(3, printk("sg_open: dev=%d, flags=0x%x\n", dev, flags));
235 sdp = sg_get_dev(dev); 237 sdp = sg_get_dev(dev);
@@ -314,7 +316,7 @@ sdp_put:
314sg_put: 316sg_put:
315 if (sdp) 317 if (sdp)
316 sg_put_dev(sdp); 318 sg_put_dev(sdp);
317 unlock_kernel(); 319 mutex_unlock(&sg_mutex);
318 return retval; 320 return retval;
319} 321}
320 322
@@ -1092,9 +1094,9 @@ sg_unlocked_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
1092{ 1094{
1093 int ret; 1095 int ret;
1094 1096
1095 lock_kernel(); 1097 mutex_lock(&sg_mutex);
1096 ret = sg_ioctl(filp, cmd_in, arg); 1098 ret = sg_ioctl(filp, cmd_in, arg);
1097 unlock_kernel(); 1099 mutex_unlock(&sg_mutex);
1098 1100
1099 return ret; 1101 return ret;
1100} 1102}
@@ -1351,6 +1353,7 @@ static const struct file_operations sg_fops = {
1351 .mmap = sg_mmap, 1353 .mmap = sg_mmap,
1352 .release = sg_release, 1354 .release = sg_release,
1353 .fasync = sg_fasync, 1355 .fasync = sg_fasync,
1356 .llseek = no_llseek,
1354}; 1357};
1355 1358
1356static struct class *sg_sysfs_class; 1359static struct class *sg_sysfs_class;
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index ba9c3e0387ce..e148341079b5 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -44,7 +44,6 @@
44#include <linux/init.h> 44#include <linux/init.h>
45#include <linux/blkdev.h> 45#include <linux/blkdev.h>
46#include <linux/mutex.h> 46#include <linux/mutex.h>
47#include <linux/smp_lock.h>
48#include <linux/slab.h> 47#include <linux/slab.h>
49#include <asm/uaccess.h> 48#include <asm/uaccess.h>
50 49
@@ -76,6 +75,7 @@ MODULE_ALIAS_SCSI_DEVICE(TYPE_WORM);
76 CDC_CD_R|CDC_CD_RW|CDC_DVD|CDC_DVD_R|CDC_DVD_RAM|CDC_GENERIC_PACKET| \ 75 CDC_CD_R|CDC_CD_RW|CDC_DVD|CDC_DVD_R|CDC_DVD_RAM|CDC_GENERIC_PACKET| \
77 CDC_MRW|CDC_MRW_W|CDC_RAM) 76 CDC_MRW|CDC_MRW_W|CDC_RAM)
78 77
78static DEFINE_MUTEX(sr_mutex);
79static int sr_probe(struct device *); 79static int sr_probe(struct device *);
80static int sr_remove(struct device *); 80static int sr_remove(struct device *);
81static int sr_done(struct scsi_cmnd *); 81static int sr_done(struct scsi_cmnd *);
@@ -470,24 +470,24 @@ static int sr_block_open(struct block_device *bdev, fmode_t mode)
470 struct scsi_cd *cd; 470 struct scsi_cd *cd;
471 int ret = -ENXIO; 471 int ret = -ENXIO;
472 472
473 lock_kernel(); 473 mutex_lock(&sr_mutex);
474 cd = scsi_cd_get(bdev->bd_disk); 474 cd = scsi_cd_get(bdev->bd_disk);
475 if (cd) { 475 if (cd) {
476 ret = cdrom_open(&cd->cdi, bdev, mode); 476 ret = cdrom_open(&cd->cdi, bdev, mode);
477 if (ret) 477 if (ret)
478 scsi_cd_put(cd); 478 scsi_cd_put(cd);
479 } 479 }
480 unlock_kernel(); 480 mutex_unlock(&sr_mutex);
481 return ret; 481 return ret;
482} 482}
483 483
484static int sr_block_release(struct gendisk *disk, fmode_t mode) 484static int sr_block_release(struct gendisk *disk, fmode_t mode)
485{ 485{
486 struct scsi_cd *cd = scsi_cd(disk); 486 struct scsi_cd *cd = scsi_cd(disk);
487 lock_kernel(); 487 mutex_lock(&sr_mutex);
488 cdrom_release(&cd->cdi, mode); 488 cdrom_release(&cd->cdi, mode);
489 scsi_cd_put(cd); 489 scsi_cd_put(cd);
490 unlock_kernel(); 490 mutex_unlock(&sr_mutex);
491 return 0; 491 return 0;
492} 492}
493 493
@@ -499,7 +499,7 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
499 void __user *argp = (void __user *)arg; 499 void __user *argp = (void __user *)arg;
500 int ret; 500 int ret;
501 501
502 lock_kernel(); 502 mutex_lock(&sr_mutex);
503 503
504 /* 504 /*
505 * Send SCSI addressing ioctls directly to mid level, send other 505 * Send SCSI addressing ioctls directly to mid level, send other
@@ -529,7 +529,7 @@ static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
529 ret = scsi_ioctl(sdev, cmd, argp); 529 ret = scsi_ioctl(sdev, cmd, argp);
530 530
531out: 531out:
532 unlock_kernel(); 532 mutex_unlock(&sr_mutex);
533 return ret; 533 return ret;
534} 534}
535 535
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 24211d0efa6d..afdc3f5d915c 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -39,7 +39,6 @@ static const char *verstr = "20081215";
39#include <linux/cdev.h> 39#include <linux/cdev.h>
40#include <linux/delay.h> 40#include <linux/delay.h>
41#include <linux/mutex.h> 41#include <linux/mutex.h>
42#include <linux/smp_lock.h>
43 42
44#include <asm/uaccess.h> 43#include <asm/uaccess.h>
45#include <asm/dma.h> 44#include <asm/dma.h>
@@ -76,6 +75,7 @@ static const char *verstr = "20081215";
76#include "st_options.h" 75#include "st_options.h"
77#include "st.h" 76#include "st.h"
78 77
78static DEFINE_MUTEX(st_mutex);
79static int buffer_kbs; 79static int buffer_kbs;
80static int max_sg_segs; 80static int max_sg_segs;
81static int try_direct_io = TRY_DIRECT_IO; 81static int try_direct_io = TRY_DIRECT_IO;
@@ -1180,7 +1180,7 @@ static int st_open(struct inode *inode, struct file *filp)
1180 int dev = TAPE_NR(inode); 1180 int dev = TAPE_NR(inode);
1181 char *name; 1181 char *name;
1182 1182
1183 lock_kernel(); 1183 mutex_lock(&st_mutex);
1184 /* 1184 /*
1185 * We really want to do nonseekable_open(inode, filp); here, but some 1185 * We really want to do nonseekable_open(inode, filp); here, but some
1186 * versions of tar incorrectly call lseek on tapes and bail out if that 1186 * versions of tar incorrectly call lseek on tapes and bail out if that
@@ -1189,7 +1189,7 @@ static int st_open(struct inode *inode, struct file *filp)
1189 filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE); 1189 filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE);
1190 1190
1191 if (!(STp = scsi_tape_get(dev))) { 1191 if (!(STp = scsi_tape_get(dev))) {
1192 unlock_kernel(); 1192 mutex_unlock(&st_mutex);
1193 return -ENXIO; 1193 return -ENXIO;
1194 } 1194 }
1195 1195
@@ -1200,7 +1200,7 @@ static int st_open(struct inode *inode, struct file *filp)
1200 if (STp->in_use) { 1200 if (STp->in_use) {
1201 write_unlock(&st_dev_arr_lock); 1201 write_unlock(&st_dev_arr_lock);
1202 scsi_tape_put(STp); 1202 scsi_tape_put(STp);
1203 unlock_kernel(); 1203 mutex_unlock(&st_mutex);
1204 DEB( printk(ST_DEB_MSG "%s: Device already in use.\n", name); ) 1204 DEB( printk(ST_DEB_MSG "%s: Device already in use.\n", name); )
1205 return (-EBUSY); 1205 return (-EBUSY);
1206 } 1206 }
@@ -1249,14 +1249,14 @@ static int st_open(struct inode *inode, struct file *filp)
1249 retval = (-EIO); 1249 retval = (-EIO);
1250 goto err_out; 1250 goto err_out;
1251 } 1251 }
1252 unlock_kernel(); 1252 mutex_unlock(&st_mutex);
1253 return 0; 1253 return 0;
1254 1254
1255 err_out: 1255 err_out:
1256 normalize_buffer(STp->buffer); 1256 normalize_buffer(STp->buffer);
1257 STp->in_use = 0; 1257 STp->in_use = 0;
1258 scsi_tape_put(STp); 1258 scsi_tape_put(STp);
1259 unlock_kernel(); 1259 mutex_unlock(&st_mutex);
1260 return retval; 1260 return retval;
1261 1261
1262} 1262}
diff --git a/drivers/serial/mfd.c b/drivers/serial/mfd.c
index 5dff45c76d32..dc0967fb9ea6 100644
--- a/drivers/serial/mfd.c
+++ b/drivers/serial/mfd.c
@@ -228,12 +228,14 @@ static const struct file_operations port_regs_ops = {
228 .owner = THIS_MODULE, 228 .owner = THIS_MODULE,
229 .open = hsu_show_regs_open, 229 .open = hsu_show_regs_open,
230 .read = port_show_regs, 230 .read = port_show_regs,
231 .llseek = default_llseek,
231}; 232};
232 233
233static const struct file_operations dma_regs_ops = { 234static const struct file_operations dma_regs_ops = {
234 .owner = THIS_MODULE, 235 .owner = THIS_MODULE,
235 .open = hsu_show_regs_open, 236 .open = hsu_show_regs_open,
236 .read = dma_show_regs, 237 .read = dma_show_regs,
238 .llseek = default_llseek,
237}; 239};
238 240
239static int hsu_debugfs_init(struct hsu_port *hsu) 241static int hsu_debugfs_init(struct hsu_port *hsu)
diff --git a/drivers/spi/dw_spi.c b/drivers/spi/dw_spi.c
index 56247853c298..90439314cf67 100644
--- a/drivers/spi/dw_spi.c
+++ b/drivers/spi/dw_spi.c
@@ -131,6 +131,7 @@ static const struct file_operations mrst_spi_regs_ops = {
131 .owner = THIS_MODULE, 131 .owner = THIS_MODULE,
132 .open = spi_show_regs_open, 132 .open = spi_show_regs_open,
133 .read = spi_show_regs, 133 .read = spi_show_regs,
134 .llseek = default_llseek,
134}; 135};
135 136
136static int mrst_spi_debugfs_init(struct dw_spi *dws) 137static int mrst_spi_debugfs_init(struct dw_spi *dws)
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index ea1bec3c9a13..4e6245e67995 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -545,6 +545,7 @@ static const struct file_operations spidev_fops = {
545 .unlocked_ioctl = spidev_ioctl, 545 .unlocked_ioctl = spidev_ioctl,
546 .open = spidev_open, 546 .open = spidev_open,
547 .release = spidev_release, 547 .release = spidev_release,
548 .llseek = no_llseek,
548}; 549};
549 550
550/*-------------------------------------------------------------------------*/ 551/*-------------------------------------------------------------------------*/
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index 14091313cebb..fecb89e8c663 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -1922,6 +1922,7 @@ const struct file_operations comedi_fops = {
1922 .mmap = comedi_mmap, 1922 .mmap = comedi_mmap,
1923 .poll = comedi_poll, 1923 .poll = comedi_poll,
1924 .fasync = comedi_fasync, 1924 .fasync = comedi_fasync,
1925 .llseek = noop_llseek,
1925}; 1926};
1926 1927
1927struct class *comedi_class; 1928struct class *comedi_class;
diff --git a/drivers/staging/crystalhd/crystalhd_lnx.c b/drivers/staging/crystalhd/crystalhd_lnx.c
index fbb80f09a3d9..af258991fe7f 100644
--- a/drivers/staging/crystalhd/crystalhd_lnx.c
+++ b/drivers/staging/crystalhd/crystalhd_lnx.c
@@ -351,6 +351,7 @@ static const struct file_operations chd_dec_fops = {
351 .unlocked_ioctl = chd_dec_ioctl, 351 .unlocked_ioctl = chd_dec_ioctl,
352 .open = chd_dec_open, 352 .open = chd_dec_open,
353 .release = chd_dec_close, 353 .release = chd_dec_close,
354 .llseek = noop_llseek,
354}; 355};
355 356
356static int __devinit chd_dec_init_chdev(struct crystalhd_adp *adp) 357static int __devinit chd_dec_init_chdev(struct crystalhd_adp *adp)
diff --git a/drivers/staging/cx25821/Kconfig b/drivers/staging/cx25821/Kconfig
index df7756a95fad..813cb355ac01 100644
--- a/drivers/staging/cx25821/Kconfig
+++ b/drivers/staging/cx25821/Kconfig
@@ -1,6 +1,7 @@
1config VIDEO_CX25821 1config VIDEO_CX25821
2 tristate "Conexant cx25821 support" 2 tristate "Conexant cx25821 support"
3 depends on DVB_CORE && VIDEO_DEV && PCI && I2C && INPUT 3 depends on DVB_CORE && VIDEO_DEV && PCI && I2C && INPUT
4 depends on BKL # please fix
4 select I2C_ALGOBIT 5 select I2C_ALGOBIT
5 select VIDEO_BTCX 6 select VIDEO_BTCX
6 select VIDEO_TVEEPROM 7 select VIDEO_TVEEPROM
diff --git a/drivers/staging/dream/camera/msm_camera.c b/drivers/staging/dream/camera/msm_camera.c
index 81bd71fd816e..de4ab61efd4b 100644
--- a/drivers/staging/dream/camera/msm_camera.c
+++ b/drivers/staging/dream/camera/msm_camera.c
@@ -1941,6 +1941,7 @@ static const struct file_operations msm_fops_config = {
1941 .open = msm_open, 1941 .open = msm_open,
1942 .unlocked_ioctl = msm_ioctl_config, 1942 .unlocked_ioctl = msm_ioctl_config,
1943 .release = msm_release_config, 1943 .release = msm_release_config,
1944 .llseek = no_llseek,
1944}; 1945};
1945 1946
1946static const struct file_operations msm_fops_control = { 1947static const struct file_operations msm_fops_control = {
@@ -1948,6 +1949,7 @@ static const struct file_operations msm_fops_control = {
1948 .open = msm_open_control, 1949 .open = msm_open_control,
1949 .unlocked_ioctl = msm_ioctl_control, 1950 .unlocked_ioctl = msm_ioctl_control,
1950 .release = msm_release_control, 1951 .release = msm_release_control,
1952 .llseek = no_llseek,
1951}; 1953};
1952 1954
1953static const struct file_operations msm_fops_frame = { 1955static const struct file_operations msm_fops_frame = {
@@ -1956,6 +1958,7 @@ static const struct file_operations msm_fops_frame = {
1956 .unlocked_ioctl = msm_ioctl_frame, 1958 .unlocked_ioctl = msm_ioctl_frame,
1957 .release = msm_release_frame, 1959 .release = msm_release_frame,
1958 .poll = msm_poll_frame, 1960 .poll = msm_poll_frame,
1961 .llseek = no_llseek,
1959}; 1962};
1960 1963
1961static int msm_setup_cdev(struct msm_device *msm, 1964static int msm_setup_cdev(struct msm_device *msm,
diff --git a/drivers/staging/dream/pmem.c b/drivers/staging/dream/pmem.c
index 7d6bbadd7fc7..3640d1f2376d 100644
--- a/drivers/staging/dream/pmem.c
+++ b/drivers/staging/dream/pmem.c
@@ -180,6 +180,7 @@ const struct file_operations pmem_fops = {
180 .mmap = pmem_mmap, 180 .mmap = pmem_mmap,
181 .open = pmem_open, 181 .open = pmem_open,
182 .unlocked_ioctl = pmem_ioctl, 182 .unlocked_ioctl = pmem_ioctl,
183 .llseek = noop_llseek,
183}; 184};
184 185
185static int get_id(struct file *file) 186static int get_id(struct file *file)
@@ -1204,6 +1205,7 @@ static ssize_t debug_read(struct file *file, char __user *buf, size_t count,
1204static struct file_operations debug_fops = { 1205static struct file_operations debug_fops = {
1205 .read = debug_read, 1206 .read = debug_read,
1206 .open = debug_open, 1207 .open = debug_open,
1208 .llseek = default_llseek,
1207}; 1209};
1208#endif 1210#endif
1209 1211
diff --git a/drivers/staging/dream/qdsp5/adsp_driver.c b/drivers/staging/dream/qdsp5/adsp_driver.c
index 8197765aae1e..28a6f8da9477 100644
--- a/drivers/staging/dream/qdsp5/adsp_driver.c
+++ b/drivers/staging/dream/qdsp5/adsp_driver.c
@@ -582,6 +582,7 @@ static struct file_operations adsp_fops = {
582 .open = adsp_open, 582 .open = adsp_open,
583 .unlocked_ioctl = adsp_ioctl, 583 .unlocked_ioctl = adsp_ioctl,
584 .release = adsp_release, 584 .release = adsp_release,
585 .llseek = no_llseek,
585}; 586};
586 587
587static void adsp_create(struct adsp_device *adev, const char *name, 588static void adsp_create(struct adsp_device *adev, const char *name,
diff --git a/drivers/staging/dream/qdsp5/audio_aac.c b/drivers/staging/dream/qdsp5/audio_aac.c
index a373f3522384..45f4c78ab6e7 100644
--- a/drivers/staging/dream/qdsp5/audio_aac.c
+++ b/drivers/staging/dream/qdsp5/audio_aac.c
@@ -1030,6 +1030,7 @@ static struct file_operations audio_aac_fops = {
1030 .read = audio_read, 1030 .read = audio_read,
1031 .write = audio_write, 1031 .write = audio_write,
1032 .unlocked_ioctl = audio_ioctl, 1032 .unlocked_ioctl = audio_ioctl,
1033 .llseek = noop_llseek,
1033}; 1034};
1034 1035
1035struct miscdevice audio_aac_misc = { 1036struct miscdevice audio_aac_misc = {
diff --git a/drivers/staging/dream/qdsp5/audio_amrnb.c b/drivers/staging/dream/qdsp5/audio_amrnb.c
index 07b79d5836e5..402bbc13281a 100644
--- a/drivers/staging/dream/qdsp5/audio_amrnb.c
+++ b/drivers/staging/dream/qdsp5/audio_amrnb.c
@@ -841,6 +841,7 @@ static struct file_operations audio_amrnb_fops = {
841 .read = audamrnb_read, 841 .read = audamrnb_read,
842 .write = audamrnb_write, 842 .write = audamrnb_write,
843 .unlocked_ioctl = audamrnb_ioctl, 843 .unlocked_ioctl = audamrnb_ioctl,
844 .llseek = noop_llseek,
844}; 845};
845 846
846struct miscdevice audio_amrnb_misc = { 847struct miscdevice audio_amrnb_misc = {
diff --git a/drivers/staging/dream/qdsp5/audio_evrc.c b/drivers/staging/dream/qdsp5/audio_evrc.c
index ad989ee87690..24a892647370 100644
--- a/drivers/staging/dream/qdsp5/audio_evrc.c
+++ b/drivers/staging/dream/qdsp5/audio_evrc.c
@@ -813,6 +813,7 @@ static struct file_operations audio_evrc_fops = {
813 .read = audevrc_read, 813 .read = audevrc_read,
814 .write = audevrc_write, 814 .write = audevrc_write,
815 .unlocked_ioctl = audevrc_ioctl, 815 .unlocked_ioctl = audevrc_ioctl,
816 .llseek = noop_llseek,
816}; 817};
817 818
818struct miscdevice audio_evrc_misc = { 819struct miscdevice audio_evrc_misc = {
diff --git a/drivers/staging/dream/qdsp5/audio_in.c b/drivers/staging/dream/qdsp5/audio_in.c
index 6ae48e72d145..b51fa096074e 100644
--- a/drivers/staging/dream/qdsp5/audio_in.c
+++ b/drivers/staging/dream/qdsp5/audio_in.c
@@ -921,12 +921,14 @@ static struct file_operations audio_fops = {
921 .read = audio_in_read, 921 .read = audio_in_read,
922 .write = audio_in_write, 922 .write = audio_in_write,
923 .unlocked_ioctl = audio_in_ioctl, 923 .unlocked_ioctl = audio_in_ioctl,
924 .llseek = noop_llseek,
924}; 925};
925 926
926static struct file_operations audpre_fops = { 927static struct file_operations audpre_fops = {
927 .owner = THIS_MODULE, 928 .owner = THIS_MODULE,
928 .open = audpre_open, 929 .open = audpre_open,
929 .unlocked_ioctl = audpre_ioctl, 930 .unlocked_ioctl = audpre_ioctl,
931 .llseek = noop_llseek,
930}; 932};
931 933
932struct miscdevice audio_in_misc = { 934struct miscdevice audio_in_misc = {
diff --git a/drivers/staging/dream/qdsp5/audio_mp3.c b/drivers/staging/dream/qdsp5/audio_mp3.c
index 530e1f35eed3..409a19ce6039 100644
--- a/drivers/staging/dream/qdsp5/audio_mp3.c
+++ b/drivers/staging/dream/qdsp5/audio_mp3.c
@@ -948,6 +948,7 @@ static struct file_operations audio_mp3_fops = {
948 .read = audio_read, 948 .read = audio_read,
949 .write = audio_write, 949 .write = audio_write,
950 .unlocked_ioctl = audio_ioctl, 950 .unlocked_ioctl = audio_ioctl,
951 .llseek = noop_llseek,
951}; 952};
952 953
953struct miscdevice audio_mp3_misc = { 954struct miscdevice audio_mp3_misc = {
diff --git a/drivers/staging/dream/qdsp5/audio_out.c b/drivers/staging/dream/qdsp5/audio_out.c
index 76d7fa5667d5..d20e89541567 100644
--- a/drivers/staging/dream/qdsp5/audio_out.c
+++ b/drivers/staging/dream/qdsp5/audio_out.c
@@ -807,12 +807,14 @@ static struct file_operations audio_fops = {
807 .read = audio_read, 807 .read = audio_read,
808 .write = audio_write, 808 .write = audio_write,
809 .unlocked_ioctl = audio_ioctl, 809 .unlocked_ioctl = audio_ioctl,
810 .llseek = noop_llseek,
810}; 811};
811 812
812static struct file_operations audpp_fops = { 813static struct file_operations audpp_fops = {
813 .owner = THIS_MODULE, 814 .owner = THIS_MODULE,
814 .open = audpp_open, 815 .open = audpp_open,
815 .unlocked_ioctl = audpp_ioctl, 816 .unlocked_ioctl = audpp_ioctl,
817 .llseek = noop_llseek,
816}; 818};
817 819
818struct miscdevice audio_misc = { 820struct miscdevice audio_misc = {
diff --git a/drivers/staging/dream/qdsp5/audio_qcelp.c b/drivers/staging/dream/qdsp5/audio_qcelp.c
index effa96f34fdc..911bab416b85 100644
--- a/drivers/staging/dream/qdsp5/audio_qcelp.c
+++ b/drivers/staging/dream/qdsp5/audio_qcelp.c
@@ -824,6 +824,7 @@ static struct file_operations audio_qcelp_fops = {
824 .read = audqcelp_read, 824 .read = audqcelp_read,
825 .write = audqcelp_write, 825 .write = audqcelp_write,
826 .unlocked_ioctl = audqcelp_ioctl, 826 .unlocked_ioctl = audqcelp_ioctl,
827 .llseek = noop_llseek,
827}; 828};
828 829
829struct miscdevice audio_qcelp_misc = { 830struct miscdevice audio_qcelp_misc = {
diff --git a/drivers/staging/dream/qdsp5/evlog.h b/drivers/staging/dream/qdsp5/evlog.h
index 922ce670a32a..e5ab86b9dd7c 100644
--- a/drivers/staging/dream/qdsp5/evlog.h
+++ b/drivers/staging/dream/qdsp5/evlog.h
@@ -123,6 +123,7 @@ static int ev_log_open(struct inode *inode, struct file *file)
123static const struct file_operations ev_log_ops = { 123static const struct file_operations ev_log_ops = {
124 .read = ev_log_read, 124 .read = ev_log_read,
125 .open = ev_log_open, 125 .open = ev_log_open,
126 .llseek = default_llseek,
126}; 127};
127 128
128static int ev_log_init(struct ev_log *log) 129static int ev_log_init(struct ev_log *log)
diff --git a/drivers/staging/dream/qdsp5/snd.c b/drivers/staging/dream/qdsp5/snd.c
index 037d7ffb7e67..e0f2f7bca29e 100644
--- a/drivers/staging/dream/qdsp5/snd.c
+++ b/drivers/staging/dream/qdsp5/snd.c
@@ -247,6 +247,7 @@ static struct file_operations snd_fops = {
247 .open = snd_open, 247 .open = snd_open,
248 .release = snd_release, 248 .release = snd_release,
249 .unlocked_ioctl = snd_ioctl, 249 .unlocked_ioctl = snd_ioctl,
250 .llseek = noop_llseek,
250}; 251};
251 252
252struct miscdevice snd_misc = { 253struct miscdevice snd_misc = {
diff --git a/drivers/staging/easycap/Kconfig b/drivers/staging/easycap/Kconfig
index bd96f39f2735..9d5fe4ddc30a 100644
--- a/drivers/staging/easycap/Kconfig
+++ b/drivers/staging/easycap/Kconfig
@@ -1,6 +1,7 @@
1config EASYCAP 1config EASYCAP
2 tristate "EasyCAP USB ID 05e1:0408 support" 2 tristate "EasyCAP USB ID 05e1:0408 support"
3 depends on USB && VIDEO_DEV 3 depends on USB && VIDEO_DEV
4 depends on BKL # please fix
4 5
5 ---help--- 6 ---help---
6 This is an integrated audio/video driver for EasyCAP cards with 7 This is an integrated audio/video driver for EasyCAP cards with
diff --git a/drivers/staging/frontier/alphatrack.c b/drivers/staging/frontier/alphatrack.c
index 4e52105e6070..689099b57fd2 100644
--- a/drivers/staging/frontier/alphatrack.c
+++ b/drivers/staging/frontier/alphatrack.c
@@ -641,6 +641,7 @@ static const struct file_operations usb_alphatrack_fops = {
641 .open = usb_alphatrack_open, 641 .open = usb_alphatrack_open,
642 .release = usb_alphatrack_release, 642 .release = usb_alphatrack_release,
643 .poll = usb_alphatrack_poll, 643 .poll = usb_alphatrack_poll,
644 .llseek = no_llseek,
644}; 645};
645 646
646/* 647/*
diff --git a/drivers/staging/frontier/tranzport.c b/drivers/staging/frontier/tranzport.c
index eed74f0fe0b6..3d12c1737edc 100644
--- a/drivers/staging/frontier/tranzport.c
+++ b/drivers/staging/frontier/tranzport.c
@@ -767,6 +767,7 @@ static const struct file_operations usb_tranzport_fops = {
767 .open = usb_tranzport_open, 767 .open = usb_tranzport_open,
768 .release = usb_tranzport_release, 768 .release = usb_tranzport_release,
769 .poll = usb_tranzport_poll, 769 .poll = usb_tranzport_poll,
770 .llseek = no_llseek,
770}; 771};
771 772
772/* 773/*
diff --git a/drivers/staging/go7007/Kconfig b/drivers/staging/go7007/Kconfig
index e47f683a323e..75fa46805527 100644
--- a/drivers/staging/go7007/Kconfig
+++ b/drivers/staging/go7007/Kconfig
@@ -1,6 +1,7 @@
1config VIDEO_GO7007 1config VIDEO_GO7007
2 tristate "WIS GO7007 MPEG encoder support" 2 tristate "WIS GO7007 MPEG encoder support"
3 depends on VIDEO_DEV && PCI && I2C && INPUT 3 depends on VIDEO_DEV && PCI && I2C && INPUT
4 depends on BKL # please fix
4 depends on SND 5 depends on SND
5 select VIDEOBUF_DMA_SG 6 select VIDEOBUF_DMA_SG
6 select VIDEO_IR 7 select VIDEO_IR
diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c
index ff1d24720f11..8284297b30e9 100644
--- a/drivers/staging/hv/blkvsc_drv.c
+++ b/drivers/staging/hv/blkvsc_drv.c
@@ -25,7 +25,7 @@
25#include <linux/major.h> 25#include <linux/major.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/hdreg.h> 27#include <linux/hdreg.h>
28#include <linux/smp_lock.h> 28#include <linux/mutex.h>
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <scsi/scsi.h> 30#include <scsi/scsi.h>
31#include <scsi/scsi_cmnd.h> 31#include <scsi/scsi_cmnd.h>
@@ -124,6 +124,7 @@ struct blkvsc_driver_context {
124}; 124};
125 125
126/* Static decl */ 126/* Static decl */
127static DEFINE_MUTEX(blkvsc_mutex);
127static int blkvsc_probe(struct device *dev); 128static int blkvsc_probe(struct device *dev);
128static int blkvsc_remove(struct device *device); 129static int blkvsc_remove(struct device *device);
129static void blkvsc_shutdown(struct device *device); 130static void blkvsc_shutdown(struct device *device);
@@ -1309,7 +1310,7 @@ static int blkvsc_open(struct block_device *bdev, fmode_t mode)
1309 DPRINT_DBG(BLKVSC_DRV, "- users %d disk %s\n", blkdev->users, 1310 DPRINT_DBG(BLKVSC_DRV, "- users %d disk %s\n", blkdev->users,
1310 blkdev->gd->disk_name); 1311 blkdev->gd->disk_name);
1311 1312
1312 lock_kernel(); 1313 mutex_lock(&blkvsc_mutex);
1313 spin_lock(&blkdev->lock); 1314 spin_lock(&blkdev->lock);
1314 1315
1315 if (!blkdev->users && blkdev->device_type == DVD_TYPE) { 1316 if (!blkdev->users && blkdev->device_type == DVD_TYPE) {
@@ -1321,7 +1322,7 @@ static int blkvsc_open(struct block_device *bdev, fmode_t mode)
1321 blkdev->users++; 1322 blkdev->users++;
1322 1323
1323 spin_unlock(&blkdev->lock); 1324 spin_unlock(&blkdev->lock);
1324 unlock_kernel(); 1325 mutex_unlock(&blkvsc_mutex);
1325 return 0; 1326 return 0;
1326} 1327}
1327 1328
@@ -1332,7 +1333,7 @@ static int blkvsc_release(struct gendisk *disk, fmode_t mode)
1332 DPRINT_DBG(BLKVSC_DRV, "- users %d disk %s\n", blkdev->users, 1333 DPRINT_DBG(BLKVSC_DRV, "- users %d disk %s\n", blkdev->users,
1333 blkdev->gd->disk_name); 1334 blkdev->gd->disk_name);
1334 1335
1335 lock_kernel(); 1336 mutex_lock(&blkvsc_mutex);
1336 spin_lock(&blkdev->lock); 1337 spin_lock(&blkdev->lock);
1337 if (blkdev->users == 1) { 1338 if (blkdev->users == 1) {
1338 spin_unlock(&blkdev->lock); 1339 spin_unlock(&blkdev->lock);
@@ -1343,7 +1344,7 @@ static int blkvsc_release(struct gendisk *disk, fmode_t mode)
1343 blkdev->users--; 1344 blkdev->users--;
1344 1345
1345 spin_unlock(&blkdev->lock); 1346 spin_unlock(&blkdev->lock);
1346 unlock_kernel(); 1347 mutex_unlock(&blkvsc_mutex);
1347 return 0; 1348 return 0;
1348} 1349}
1349 1350
diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c
index dd4d87a8bcaf..92a212f064bd 100644
--- a/drivers/staging/iio/industrialio-core.c
+++ b/drivers/staging/iio/industrialio-core.c
@@ -349,6 +349,7 @@ static const struct file_operations iio_event_chrdev_fileops = {
349 .release = iio_event_chrdev_release, 349 .release = iio_event_chrdev_release,
350 .open = iio_event_chrdev_open, 350 .open = iio_event_chrdev_open,
351 .owner = THIS_MODULE, 351 .owner = THIS_MODULE,
352 .llseek = noop_llseek,
352}; 353};
353 354
354static void iio_event_dev_release(struct device *dev) 355static void iio_event_dev_release(struct device *dev)
diff --git a/drivers/staging/iio/industrialio-ring.c b/drivers/staging/iio/industrialio-ring.c
index 6ab578e4f5f3..1c5f67253b82 100644
--- a/drivers/staging/iio/industrialio-ring.c
+++ b/drivers/staging/iio/industrialio-ring.c
@@ -133,6 +133,7 @@ static const struct file_operations iio_ring_fileops = {
133 .release = iio_ring_release, 133 .release = iio_ring_release,
134 .open = iio_ring_open, 134 .open = iio_ring_open,
135 .owner = THIS_MODULE, 135 .owner = THIS_MODULE,
136 .llseek = noop_llseek,
136}; 137};
137 138
138/** 139/**
diff --git a/drivers/staging/lirc/lirc_imon.c b/drivers/staging/lirc/lirc_imon.c
index 66493253042e..ed5c5fe022c9 100644
--- a/drivers/staging/lirc/lirc_imon.c
+++ b/drivers/staging/lirc/lirc_imon.c
@@ -115,7 +115,8 @@ static const struct file_operations display_fops = {
115 .owner = THIS_MODULE, 115 .owner = THIS_MODULE,
116 .open = &display_open, 116 .open = &display_open,
117 .write = &vfd_write, 117 .write = &vfd_write,
118 .release = &display_close 118 .release = &display_close,
119 .llseek = noop_llseek,
119}; 120};
120 121
121/* 122/*
diff --git a/drivers/staging/lirc/lirc_it87.c b/drivers/staging/lirc/lirc_it87.c
index ec11c0e949a0..543c5c3bf907 100644
--- a/drivers/staging/lirc/lirc_it87.c
+++ b/drivers/staging/lirc/lirc_it87.c
@@ -342,6 +342,7 @@ static const struct file_operations lirc_fops = {
342 .unlocked_ioctl = lirc_ioctl, 342 .unlocked_ioctl = lirc_ioctl,
343 .open = lirc_open, 343 .open = lirc_open,
344 .release = lirc_close, 344 .release = lirc_close,
345 .llseek = noop_llseek,
345}; 346};
346 347
347static int set_use_inc(void *data) 348static int set_use_inc(void *data)
diff --git a/drivers/staging/lirc/lirc_sasem.c b/drivers/staging/lirc/lirc_sasem.c
index 73166c3f581f..8f72a84f34ec 100644
--- a/drivers/staging/lirc/lirc_sasem.c
+++ b/drivers/staging/lirc/lirc_sasem.c
@@ -125,6 +125,7 @@ static const struct file_operations vfd_fops = {
125 .write = &vfd_write, 125 .write = &vfd_write,
126 .unlocked_ioctl = &vfd_ioctl, 126 .unlocked_ioctl = &vfd_ioctl,
127 .release = &vfd_close, 127 .release = &vfd_close,
128 .llseek = noop_llseek,
128}; 129};
129 130
130/* USB Device ID for Sasem USB Control Board */ 131/* USB Device ID for Sasem USB Control Board */
diff --git a/drivers/staging/lirc/lirc_serial.c b/drivers/staging/lirc/lirc_serial.c
index 9456f8e3f9ef..8da382492612 100644
--- a/drivers/staging/lirc/lirc_serial.c
+++ b/drivers/staging/lirc/lirc_serial.c
@@ -1058,6 +1058,7 @@ static const struct file_operations lirc_fops = {
1058 .poll = lirc_dev_fop_poll, 1058 .poll = lirc_dev_fop_poll,
1059 .open = lirc_dev_fop_open, 1059 .open = lirc_dev_fop_open,
1060 .release = lirc_dev_fop_close, 1060 .release = lirc_dev_fop_close,
1061 .llseek = no_llseek,
1061}; 1062};
1062 1063
1063static struct lirc_driver driver = { 1064static struct lirc_driver driver = {
diff --git a/drivers/staging/lirc/lirc_sir.c b/drivers/staging/lirc/lirc_sir.c
index eb08fa7138ba..2478871bd95e 100644
--- a/drivers/staging/lirc/lirc_sir.c
+++ b/drivers/staging/lirc/lirc_sir.c
@@ -459,6 +459,7 @@ static const struct file_operations lirc_fops = {
459 .unlocked_ioctl = lirc_ioctl, 459 .unlocked_ioctl = lirc_ioctl,
460 .open = lirc_dev_fop_open, 460 .open = lirc_dev_fop_open,
461 .release = lirc_dev_fop_close, 461 .release = lirc_dev_fop_close,
462 .llseek = no_llseek,
462}; 463};
463 464
464static int set_use_inc(void *data) 465static int set_use_inc(void *data)
diff --git a/drivers/staging/memrar/memrar_handler.c b/drivers/staging/memrar/memrar_handler.c
index a98b3f1f11e0..cfcaa8e5b8e6 100644
--- a/drivers/staging/memrar/memrar_handler.c
+++ b/drivers/staging/memrar/memrar_handler.c
@@ -890,6 +890,7 @@ static const struct file_operations memrar_fops = {
890 .mmap = memrar_mmap, 890 .mmap = memrar_mmap,
891 .open = memrar_open, 891 .open = memrar_open,
892 .release = memrar_release, 892 .release = memrar_release,
893 .llseek = no_llseek,
893}; 894};
894 895
895static struct miscdevice memrar_miscdev = { 896static struct miscdevice memrar_miscdev = {
diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
index 3221814a856e..6885f9a46609 100644
--- a/drivers/staging/panel/panel.c
+++ b/drivers/staging/panel/panel.c
@@ -1631,6 +1631,7 @@ static const struct file_operations keypad_fops = {
1631 .read = keypad_read, /* read */ 1631 .read = keypad_read, /* read */
1632 .open = keypad_open, /* open */ 1632 .open = keypad_open, /* open */
1633 .release = keypad_release, /* close */ 1633 .release = keypad_release, /* close */
1634 .llseek = default_llseek,
1634}; 1635};
1635 1636
1636static struct miscdevice keypad_dev = { 1637static struct miscdevice keypad_dev = {
diff --git a/drivers/staging/spectra/ffsport.c b/drivers/staging/spectra/ffsport.c
index fa21a0fd8e84..c7932da03c56 100644
--- a/drivers/staging/spectra/ffsport.c
+++ b/drivers/staging/spectra/ffsport.c
@@ -27,7 +27,6 @@
27#include <linux/kthread.h> 27#include <linux/kthread.h>
28#include <linux/log2.h> 28#include <linux/log2.h>
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/smp_lock.h>
31#include <linux/slab.h> 30#include <linux/slab.h>
32 31
33/**** Helper functions used for Div, Remainder operation on u64 ****/ 32/**** Helper functions used for Div, Remainder operation on u64 ****/
@@ -590,14 +589,16 @@ int GLOB_SBD_ioctl(struct block_device *bdev, fmode_t mode,
590 return -ENOTTY; 589 return -ENOTTY;
591} 590}
592 591
592static DEFINE_MUTEX(ffsport_mutex);
593
593int GLOB_SBD_unlocked_ioctl(struct block_device *bdev, fmode_t mode, 594int GLOB_SBD_unlocked_ioctl(struct block_device *bdev, fmode_t mode,
594 unsigned int cmd, unsigned long arg) 595 unsigned int cmd, unsigned long arg)
595{ 596{
596 int ret; 597 int ret;
597 598
598 lock_kernel(); 599 mutex_lock(&ffsport_mutex);
599 ret = GLOB_SBD_ioctl(bdev, mode, cmd, arg); 600 ret = GLOB_SBD_ioctl(bdev, mode, cmd, arg);
600 unlock_kernel(); 601 mutex_unlock(&ffsport_mutex);
601 602
602 return ret; 603 return ret;
603} 604}
diff --git a/drivers/staging/tidspbridge/rmgr/drv_interface.c b/drivers/staging/tidspbridge/rmgr/drv_interface.c
index 7ee89492a755..7b3a7d04a109 100644
--- a/drivers/staging/tidspbridge/rmgr/drv_interface.c
+++ b/drivers/staging/tidspbridge/rmgr/drv_interface.c
@@ -144,6 +144,7 @@ static const struct file_operations bridge_fops = {
144 .release = bridge_release, 144 .release = bridge_release,
145 .unlocked_ioctl = bridge_ioctl, 145 .unlocked_ioctl = bridge_ioctl,
146 .mmap = bridge_mmap, 146 .mmap = bridge_mmap,
147 .llseek = noop_llseek,
147}; 148};
148 149
149#ifdef CONFIG_PM 150#ifdef CONFIG_PM
diff --git a/drivers/staging/usbip/Kconfig b/drivers/staging/usbip/Kconfig
index 2c1d10acb8b5..b11ec379b5c2 100644
--- a/drivers/staging/usbip/Kconfig
+++ b/drivers/staging/usbip/Kconfig
@@ -1,6 +1,6 @@
1config USB_IP_COMMON 1config USB_IP_COMMON
2 tristate "USB IP support (EXPERIMENTAL)" 2 tristate "USB IP support (EXPERIMENTAL)"
3 depends on USB && NET && EXPERIMENTAL 3 depends on USB && NET && EXPERIMENTAL && BKL
4 default N 4 default N
5 ---help--- 5 ---help---
6 This enables pushing USB packets over IP to allow remote 6 This enables pushing USB packets over IP to allow remote
diff --git a/drivers/telephony/ixj.c b/drivers/telephony/ixj.c
index b53deee25d74..0d236f4bb8c2 100644
--- a/drivers/telephony/ixj.c
+++ b/drivers/telephony/ixj.c
@@ -257,7 +257,7 @@
257#include <linux/fs.h> /* everything... */ 257#include <linux/fs.h> /* everything... */
258#include <linux/errno.h> /* error codes */ 258#include <linux/errno.h> /* error codes */
259#include <linux/slab.h> 259#include <linux/slab.h>
260#include <linux/smp_lock.h> 260#include <linux/mutex.h>
261#include <linux/mm.h> 261#include <linux/mm.h>
262#include <linux/ioport.h> 262#include <linux/ioport.h>
263#include <linux/interrupt.h> 263#include <linux/interrupt.h>
@@ -277,6 +277,7 @@
277#define TYPE(inode) (iminor(inode) >> 4) 277#define TYPE(inode) (iminor(inode) >> 4)
278#define NUM(inode) (iminor(inode) & 0xf) 278#define NUM(inode) (iminor(inode) & 0xf)
279 279
280static DEFINE_MUTEX(ixj_mutex);
280static int ixjdebug; 281static int ixjdebug;
281static int hertz = HZ; 282static int hertz = HZ;
282static int samplerate = 100; 283static int samplerate = 100;
@@ -6655,9 +6656,9 @@ static long do_ixj_ioctl(struct file *file_p, unsigned int cmd, unsigned long ar
6655static long ixj_ioctl(struct file *file_p, unsigned int cmd, unsigned long arg) 6656static long ixj_ioctl(struct file *file_p, unsigned int cmd, unsigned long arg)
6656{ 6657{
6657 long ret; 6658 long ret;
6658 lock_kernel(); 6659 mutex_lock(&ixj_mutex);
6659 ret = do_ixj_ioctl(file_p, cmd, arg); 6660 ret = do_ixj_ioctl(file_p, cmd, arg);
6660 unlock_kernel(); 6661 mutex_unlock(&ixj_mutex);
6661 return ret; 6662 return ret;
6662} 6663}
6663 6664
@@ -6676,7 +6677,8 @@ static const struct file_operations ixj_fops =
6676 .poll = ixj_poll, 6677 .poll = ixj_poll,
6677 .unlocked_ioctl = ixj_ioctl, 6678 .unlocked_ioctl = ixj_ioctl,
6678 .release = ixj_release, 6679 .release = ixj_release,
6679 .fasync = ixj_fasync 6680 .fasync = ixj_fasync,
6681 .llseek = default_llseek,
6680}; 6682};
6681 6683
6682static int ixj_linetest(IXJ *j) 6684static int ixj_linetest(IXJ *j)
diff --git a/drivers/telephony/phonedev.c b/drivers/telephony/phonedev.c
index f3873f650bb4..1915af201175 100644
--- a/drivers/telephony/phonedev.c
+++ b/drivers/telephony/phonedev.c
@@ -130,6 +130,7 @@ static const struct file_operations phone_fops =
130{ 130{
131 .owner = THIS_MODULE, 131 .owner = THIS_MODULE,
132 .open = phone_open, 132 .open = phone_open,
133 .llseek = noop_llseek,
133}; 134};
134 135
135/* 136/*
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index bff1afbde5a4..4d3a6fd1a152 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -740,6 +740,7 @@ static const struct file_operations uio_fops = {
740 .mmap = uio_mmap, 740 .mmap = uio_mmap,
741 .poll = uio_poll, 741 .poll = uio_poll,
742 .fasync = uio_fasync, 742 .fasync = uio_fasync,
743 .llseek = noop_llseek,
743}; 744};
744 745
745static int uio_major_init(void) 746static int uio_major_init(void)
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 094c76b5de17..6ee4451bfe2d 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -584,7 +584,8 @@ static const struct file_operations wdm_fops = {
584 .open = wdm_open, 584 .open = wdm_open,
585 .flush = wdm_flush, 585 .flush = wdm_flush,
586 .release = wdm_release, 586 .release = wdm_release,
587 .poll = wdm_poll 587 .poll = wdm_poll,
588 .llseek = noop_llseek,
588}; 589};
589 590
590static struct usb_class_driver wdm_class = { 591static struct usb_class_driver wdm_class = {
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index e325162859b0..9eca4053312e 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -1043,6 +1043,7 @@ static const struct file_operations usblp_fops = {
1043 .compat_ioctl = usblp_ioctl, 1043 .compat_ioctl = usblp_ioctl,
1044 .open = usblp_open, 1044 .open = usblp_open,
1045 .release = usblp_release, 1045 .release = usblp_release,
1046 .llseek = noop_llseek,
1046}; 1047};
1047 1048
1048static char *usblp_devnode(struct device *dev, mode_t *mode) 1049static char *usblp_devnode(struct device *dev, mode_t *mode)
diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index 3e7c1b800ebb..6a54634ab823 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -987,6 +987,7 @@ static const struct file_operations fops = {
987 .open = usbtmc_open, 987 .open = usbtmc_open,
988 .release = usbtmc_release, 988 .release = usbtmc_release,
989 .unlocked_ioctl = usbtmc_ioctl, 989 .unlocked_ioctl = usbtmc_ioctl,
990 .llseek = default_llseek,
990}; 991};
991 992
992static struct usb_class_driver usbtmc_class = { 993static struct usb_class_driver usbtmc_class = {
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c
index 1e6ccef2cf0c..9fe34fb78ef1 100644
--- a/drivers/usb/core/file.c
+++ b/drivers/usb/core/file.c
@@ -59,6 +59,7 @@ static int usb_open(struct inode * inode, struct file * file)
59static const struct file_operations usb_fops = { 59static const struct file_operations usb_fops = {
60 .owner = THIS_MODULE, 60 .owner = THIS_MODULE,
61 .open = usb_open, 61 .open = usb_open,
62 .llseek = noop_llseek,
62}; 63};
63 64
64static struct usb_class { 65static struct usb_class {
diff --git a/drivers/usb/gadget/f_hid.c b/drivers/usb/gadget/f_hid.c
index 53e120208e99..2b98bd26364b 100644
--- a/drivers/usb/gadget/f_hid.c
+++ b/drivers/usb/gadget/f_hid.c
@@ -451,6 +451,7 @@ const struct file_operations f_hidg_fops = {
451 .write = f_hidg_write, 451 .write = f_hidg_write,
452 .read = f_hidg_read, 452 .read = f_hidg_read,
453 .poll = f_hidg_poll, 453 .poll = f_hidg_poll,
454 .llseek = noop_llseek,
454}; 455};
455 456
456static int __init hidg_bind(struct usb_configuration *c, struct usb_function *f) 457static int __init hidg_bind(struct usb_configuration *c, struct usb_function *f)
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index fc35406fc80c..3f1d771c8be5 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -33,7 +33,6 @@
33#include <linux/sched.h> 33#include <linux/sched.h>
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/poll.h> 35#include <linux/poll.h>
36#include <linux/smp_lock.h>
37 36
38#include <linux/device.h> 37#include <linux/device.h>
39#include <linux/moduleparam.h> 38#include <linux/moduleparam.h>
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c
index cf241c371a71..327a92a137b4 100644
--- a/drivers/usb/gadget/printer.c
+++ b/drivers/usb/gadget/printer.c
@@ -884,7 +884,8 @@ static const struct file_operations printer_io_operations = {
884 .fsync = printer_fsync, 884 .fsync = printer_fsync,
885 .poll = printer_poll, 885 .poll = printer_poll,
886 .unlocked_ioctl = printer_ioctl, 886 .unlocked_ioctl = printer_ioctl,
887 .release = printer_close 887 .release = printer_close,
888 .llseek = noop_llseek,
888}; 889};
889 890
890/*-------------------------------------------------------------------------*/ 891/*-------------------------------------------------------------------------*/
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index 76b7fd2d838a..86afdc73322f 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -369,18 +369,21 @@ static const struct file_operations debug_async_fops = {
369 .open = debug_async_open, 369 .open = debug_async_open,
370 .read = debug_output, 370 .read = debug_output,
371 .release = debug_close, 371 .release = debug_close,
372 .llseek = default_llseek,
372}; 373};
373static const struct file_operations debug_periodic_fops = { 374static const struct file_operations debug_periodic_fops = {
374 .owner = THIS_MODULE, 375 .owner = THIS_MODULE,
375 .open = debug_periodic_open, 376 .open = debug_periodic_open,
376 .read = debug_output, 377 .read = debug_output,
377 .release = debug_close, 378 .release = debug_close,
379 .llseek = default_llseek,
378}; 380};
379static const struct file_operations debug_registers_fops = { 381static const struct file_operations debug_registers_fops = {
380 .owner = THIS_MODULE, 382 .owner = THIS_MODULE,
381 .open = debug_registers_open, 383 .open = debug_registers_open,
382 .read = debug_output, 384 .read = debug_output,
383 .release = debug_close, 385 .release = debug_close,
386 .llseek = default_llseek,
384}; 387};
385static const struct file_operations debug_lpm_fops = { 388static const struct file_operations debug_lpm_fops = {
386 .owner = THIS_MODULE, 389 .owner = THIS_MODULE,
@@ -388,6 +391,7 @@ static const struct file_operations debug_lpm_fops = {
388 .read = debug_lpm_read, 391 .read = debug_lpm_read,
389 .write = debug_lpm_write, 392 .write = debug_lpm_write,
390 .release = debug_lpm_close, 393 .release = debug_lpm_close,
394 .llseek = noop_llseek,
391}; 395};
392 396
393static struct dentry *ehci_debug_root; 397static struct dentry *ehci_debug_root;
diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c
index 36abd2baa3ea..d7d34492934a 100644
--- a/drivers/usb/host/ohci-dbg.c
+++ b/drivers/usb/host/ohci-dbg.c
@@ -413,18 +413,21 @@ static const struct file_operations debug_async_fops = {
413 .open = debug_async_open, 413 .open = debug_async_open,
414 .read = debug_output, 414 .read = debug_output,
415 .release = debug_close, 415 .release = debug_close,
416 .llseek = default_llseek,
416}; 417};
417static const struct file_operations debug_periodic_fops = { 418static const struct file_operations debug_periodic_fops = {
418 .owner = THIS_MODULE, 419 .owner = THIS_MODULE,
419 .open = debug_periodic_open, 420 .open = debug_periodic_open,
420 .read = debug_output, 421 .read = debug_output,
421 .release = debug_close, 422 .release = debug_close,
423 .llseek = default_llseek,
422}; 424};
423static const struct file_operations debug_registers_fops = { 425static const struct file_operations debug_registers_fops = {
424 .owner = THIS_MODULE, 426 .owner = THIS_MODULE,
425 .open = debug_registers_open, 427 .open = debug_registers_open,
426 .read = debug_output, 428 .read = debug_output,
427 .release = debug_close, 429 .release = debug_close,
430 .llseek = default_llseek,
428}; 431};
429 432
430static struct dentry *ohci_debug_root; 433static struct dentry *ohci_debug_root;
diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c
index e192e8f7c560..575b56c79e97 100644
--- a/drivers/usb/image/mdc800.c
+++ b/drivers/usb/image/mdc800.c
@@ -963,6 +963,7 @@ static const struct file_operations mdc800_device_ops =
963 .write = mdc800_device_write, 963 .write = mdc800_device_write,
964 .open = mdc800_device_open, 964 .open = mdc800_device_open,
965 .release = mdc800_device_release, 965 .release = mdc800_device_release,
966 .llseek = noop_llseek,
966}; 967};
967 968
968 969
diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c
index 801324af9470..44f8b9225054 100644
--- a/drivers/usb/misc/adutux.c
+++ b/drivers/usb/misc/adutux.c
@@ -679,6 +679,7 @@ static const struct file_operations adu_fops = {
679 .write = adu_write, 679 .write = adu_write,
680 .open = adu_open, 680 .open = adu_open,
681 .release = adu_release, 681 .release = adu_release,
682 .llseek = noop_llseek,
682}; 683};
683 684
684/* 685/*
diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c
index a54c3cb804ce..c6184b4d1695 100644
--- a/drivers/usb/misc/idmouse.c
+++ b/drivers/usb/misc/idmouse.c
@@ -105,6 +105,7 @@ static const struct file_operations idmouse_fops = {
105 .read = idmouse_read, 105 .read = idmouse_read,
106 .open = idmouse_open, 106 .open = idmouse_open,
107 .release = idmouse_release, 107 .release = idmouse_release,
108 .llseek = default_llseek,
108}; 109};
109 110
110/* class driver information */ 111/* class driver information */
diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index bc88c79875a1..9b50db257019 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -730,6 +730,7 @@ static const struct file_operations iowarrior_fops = {
730 .open = iowarrior_open, 730 .open = iowarrior_open,
731 .release = iowarrior_release, 731 .release = iowarrior_release,
732 .poll = iowarrior_poll, 732 .poll = iowarrior_poll,
733 .llseek = noop_llseek,
733}; 734};
734 735
735static char *iowarrior_devnode(struct device *dev, mode_t *mode) 736static char *iowarrior_devnode(struct device *dev, mode_t *mode)
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c
index dd41d8710043..edffef642337 100644
--- a/drivers/usb/misc/ldusb.c
+++ b/drivers/usb/misc/ldusb.c
@@ -613,6 +613,7 @@ static const struct file_operations ld_usb_fops = {
613 .open = ld_usb_open, 613 .open = ld_usb_open,
614 .release = ld_usb_release, 614 .release = ld_usb_release,
615 .poll = ld_usb_poll, 615 .poll = ld_usb_poll,
616 .llseek = no_llseek,
616}; 617};
617 618
618/* 619/*
diff --git a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c
index cc13ae61712a..4e23d3841b43 100644
--- a/drivers/usb/misc/rio500.c
+++ b/drivers/usb/misc/rio500.c
@@ -439,6 +439,7 @@ static const struct file_operations usb_rio_fops = {
439 .unlocked_ioctl = ioctl_rio, 439 .unlocked_ioctl = ioctl_rio,
440 .open = open_rio, 440 .open = open_rio,
441 .release = close_rio, 441 .release = close_rio,
442 .llseek = noop_llseek,
442}; 443};
443 444
444static struct usb_class_driver usb_rio_class = { 445static struct usb_class_driver usb_rio_class = {
diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c
index d00dde19194c..51648154bb44 100644
--- a/drivers/usb/misc/usblcd.c
+++ b/drivers/usb/misc/usblcd.c
@@ -282,6 +282,7 @@ static const struct file_operations lcd_fops = {
282 .open = lcd_open, 282 .open = lcd_open,
283 .unlocked_ioctl = lcd_ioctl, 283 .unlocked_ioctl = lcd_ioctl,
284 .release = lcd_release, 284 .release = lcd_release,
285 .llseek = noop_llseek,
285}; 286};
286 287
287/* 288/*
diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c
index 552679b8dbd1..e24ce3123071 100644
--- a/drivers/usb/usb-skeleton.c
+++ b/drivers/usb/usb-skeleton.c
@@ -507,6 +507,7 @@ static const struct file_operations skel_fops = {
507 .open = skel_open, 507 .open = skel_open,
508 .release = skel_release, 508 .release = skel_release,
509 .flush = skel_flush, 509 .flush = skel_flush,
510 .llseek = noop_llseek,
510}; 511};
511 512
512/* 513/*
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 17927b1f9334..861af4a8b79c 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -877,6 +877,7 @@ static const struct file_operations vhost_net_fops = {
877 .compat_ioctl = vhost_net_compat_ioctl, 877 .compat_ioctl = vhost_net_compat_ioctl,
878#endif 878#endif
879 .open = vhost_net_open, 879 .open = vhost_net_open,
880 .llseek = noop_llseek,
880}; 881};
881 882
882static struct miscdevice vhost_net_misc = { 883static struct miscdevice vhost_net_misc = {
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index b06647517c0e..42e303ff862a 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1439,6 +1439,7 @@ static const struct file_operations fb_fops = {
1439#ifdef CONFIG_FB_DEFERRED_IO 1439#ifdef CONFIG_FB_DEFERRED_IO
1440 .fsync = fb_deferred_io_fsync, 1440 .fsync = fb_deferred_io_fsync,
1441#endif 1441#endif
1442 .llseek = default_llseek,
1442}; 1443};
1443 1444
1444struct class *fb_class; 1445struct class *fb_class;
diff --git a/drivers/video/mbx/mbxdebugfs.c b/drivers/video/mbx/mbxdebugfs.c
index ecad96524570..12dec7634c55 100644
--- a/drivers/video/mbx/mbxdebugfs.c
+++ b/drivers/video/mbx/mbxdebugfs.c
@@ -175,36 +175,42 @@ static const struct file_operations sysconf_fops = {
175 .read = sysconf_read_file, 175 .read = sysconf_read_file,
176 .write = write_file_dummy, 176 .write = write_file_dummy,
177 .open = open_file_generic, 177 .open = open_file_generic,
178 .llseek = default_llseek,
178}; 179};
179 180
180static const struct file_operations clock_fops = { 181static const struct file_operations clock_fops = {
181 .read = clock_read_file, 182 .read = clock_read_file,
182 .write = write_file_dummy, 183 .write = write_file_dummy,
183 .open = open_file_generic, 184 .open = open_file_generic,
185 .llseek = default_llseek,
184}; 186};
185 187
186static const struct file_operations display_fops = { 188static const struct file_operations display_fops = {
187 .read = display_read_file, 189 .read = display_read_file,
188 .write = write_file_dummy, 190 .write = write_file_dummy,
189 .open = open_file_generic, 191 .open = open_file_generic,
192 .llseek = default_llseek,
190}; 193};
191 194
192static const struct file_operations gsctl_fops = { 195static const struct file_operations gsctl_fops = {
193 .read = gsctl_read_file, 196 .read = gsctl_read_file,
194 .write = write_file_dummy, 197 .write = write_file_dummy,
195 .open = open_file_generic, 198 .open = open_file_generic,
199 .llseek = default_llseek,
196}; 200};
197 201
198static const struct file_operations sdram_fops = { 202static const struct file_operations sdram_fops = {
199 .read = sdram_read_file, 203 .read = sdram_read_file,
200 .write = write_file_dummy, 204 .write = write_file_dummy,
201 .open = open_file_generic, 205 .open = open_file_generic,
206 .llseek = default_llseek,
202}; 207};
203 208
204static const struct file_operations misc_fops = { 209static const struct file_operations misc_fops = {
205 .read = misc_read_file, 210 .read = misc_read_file,
206 .write = write_file_dummy, 211 .write = write_file_dummy,
207 .open = open_file_generic, 212 .open = open_file_generic,
213 .llseek = default_llseek,
208}; 214};
209 215
210static void __devinit mbxfb_debugfs_init(struct fb_info *fbi) 216static void __devinit mbxfb_debugfs_init(struct fb_info *fbi)
diff --git a/drivers/watchdog/ar7_wdt.c b/drivers/watchdog/ar7_wdt.c
index c764c52412e4..b29221783598 100644
--- a/drivers/watchdog/ar7_wdt.c
+++ b/drivers/watchdog/ar7_wdt.c
@@ -267,6 +267,7 @@ static const struct file_operations ar7_wdt_fops = {
267 .unlocked_ioctl = ar7_wdt_ioctl, 267 .unlocked_ioctl = ar7_wdt_ioctl,
268 .open = ar7_wdt_open, 268 .open = ar7_wdt_open,
269 .release = ar7_wdt_release, 269 .release = ar7_wdt_release,
270 .llseek = no_llseek,
270}; 271};
271 272
272static struct miscdevice ar7_wdt_miscdev = { 273static struct miscdevice ar7_wdt_miscdev = {
diff --git a/drivers/watchdog/cpwd.c b/drivers/watchdog/cpwd.c
index 566343b3c131..eca855a55c0d 100644
--- a/drivers/watchdog/cpwd.c
+++ b/drivers/watchdog/cpwd.c
@@ -25,7 +25,7 @@
25#include <linux/ioport.h> 25#include <linux/ioport.h>
26#include <linux/timer.h> 26#include <linux/timer.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/smp_lock.h> 28#include <linux/mutex.h>
29#include <linux/io.h> 29#include <linux/io.h>
30#include <linux/of.h> 30#include <linux/of.h>
31#include <linux/of_device.h> 31#include <linux/of_device.h>
@@ -89,6 +89,7 @@ struct cpwd {
89 } devs[WD_NUMDEVS]; 89 } devs[WD_NUMDEVS];
90}; 90};
91 91
92static DEFINE_MUTEX(cpwd_mutex);
92static struct cpwd *cpwd_device; 93static struct cpwd *cpwd_device;
93 94
94/* Sun uses Altera PLD EPF8820ATC144-4 95/* Sun uses Altera PLD EPF8820ATC144-4
@@ -368,7 +369,7 @@ static int cpwd_open(struct inode *inode, struct file *f)
368{ 369{
369 struct cpwd *p = cpwd_device; 370 struct cpwd *p = cpwd_device;
370 371
371 lock_kernel(); 372 mutex_lock(&cpwd_mutex);
372 switch (iminor(inode)) { 373 switch (iminor(inode)) {
373 case WD0_MINOR: 374 case WD0_MINOR:
374 case WD1_MINOR: 375 case WD1_MINOR:
@@ -376,7 +377,7 @@ static int cpwd_open(struct inode *inode, struct file *f)
376 break; 377 break;
377 378
378 default: 379 default:
379 unlock_kernel(); 380 mutex_unlock(&cpwd_mutex);
380 return -ENODEV; 381 return -ENODEV;
381 } 382 }
382 383
@@ -386,13 +387,13 @@ static int cpwd_open(struct inode *inode, struct file *f)
386 IRQF_SHARED, DRIVER_NAME, p)) { 387 IRQF_SHARED, DRIVER_NAME, p)) {
387 printk(KERN_ERR PFX "Cannot register IRQ %d\n", 388 printk(KERN_ERR PFX "Cannot register IRQ %d\n",
388 p->irq); 389 p->irq);
389 unlock_kernel(); 390 mutex_unlock(&cpwd_mutex);
390 return -EBUSY; 391 return -EBUSY;
391 } 392 }
392 p->initialized = true; 393 p->initialized = true;
393 } 394 }
394 395
395 unlock_kernel(); 396 mutex_unlock(&cpwd_mutex);
396 397
397 return nonseekable_open(inode, f); 398 return nonseekable_open(inode, f);
398} 399}
@@ -482,9 +483,9 @@ static long cpwd_compat_ioctl(struct file *file, unsigned int cmd,
482 case WIOCSTART: 483 case WIOCSTART:
483 case WIOCSTOP: 484 case WIOCSTOP:
484 case WIOCGSTAT: 485 case WIOCGSTAT:
485 lock_kernel(); 486 mutex_lock(&cpwd_mutex);
486 rval = cpwd_ioctl(file, cmd, arg); 487 rval = cpwd_ioctl(file, cmd, arg);
487 unlock_kernel(); 488 mutex_unlock(&cpwd_mutex);
488 break; 489 break;
489 490
490 /* everything else is handled by the generic compat layer */ 491 /* everything else is handled by the generic compat layer */
@@ -524,6 +525,7 @@ static const struct file_operations cpwd_fops = {
524 .write = cpwd_write, 525 .write = cpwd_write,
525 .read = cpwd_read, 526 .read = cpwd_read,
526 .release = cpwd_release, 527 .release = cpwd_release,
528 .llseek = no_llseek,
527}; 529};
528 530
529static int __devinit cpwd_probe(struct platform_device *op, 531static int __devinit cpwd_probe(struct platform_device *op,
diff --git a/drivers/watchdog/ep93xx_wdt.c b/drivers/watchdog/ep93xx_wdt.c
index 59359c9a5e01..726b7df61fd0 100644
--- a/drivers/watchdog/ep93xx_wdt.c
+++ b/drivers/watchdog/ep93xx_wdt.c
@@ -188,6 +188,7 @@ static const struct file_operations ep93xx_wdt_fops = {
188 .unlocked_ioctl = ep93xx_wdt_ioctl, 188 .unlocked_ioctl = ep93xx_wdt_ioctl,
189 .open = ep93xx_wdt_open, 189 .open = ep93xx_wdt_open,
190 .release = ep93xx_wdt_release, 190 .release = ep93xx_wdt_release,
191 .llseek = no_llseek,
191}; 192};
192 193
193static struct miscdevice ep93xx_wdt_miscdev = { 194static struct miscdevice ep93xx_wdt_miscdev = {
diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index 76b58abf4451..81e3d6100894 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -258,6 +258,7 @@ static const struct file_operations omap_wdt_fops = {
258 .unlocked_ioctl = omap_wdt_ioctl, 258 .unlocked_ioctl = omap_wdt_ioctl,
259 .open = omap_wdt_open, 259 .open = omap_wdt_open,
260 .release = omap_wdt_release, 260 .release = omap_wdt_release,
261 .llseek = no_llseek,
261}; 262};
262 263
263static int __devinit omap_wdt_probe(struct platform_device *pdev) 264static int __devinit omap_wdt_probe(struct platform_device *pdev)
diff --git a/drivers/xen/evtchn.c b/drivers/xen/evtchn.c
index 66e185cfe92f..fec6ba3c08a8 100644
--- a/drivers/xen/evtchn.c
+++ b/drivers/xen/evtchn.c
@@ -467,6 +467,7 @@ static const struct file_operations evtchn_fops = {
467 .fasync = evtchn_fasync, 467 .fasync = evtchn_fasync,
468 .open = evtchn_open, 468 .open = evtchn_open,
469 .release = evtchn_release, 469 .release = evtchn_release,
470 .llseek = noop_llseek,
470}; 471};
471 472
472static struct miscdevice evtchn_miscdev = { 473static struct miscdevice evtchn_miscdev = {
diff --git a/drivers/xen/xenfs/super.c b/drivers/xen/xenfs/super.c
index 78bfab0700ba..bd96340063c1 100644
--- a/drivers/xen/xenfs/super.c
+++ b/drivers/xen/xenfs/super.c
@@ -35,6 +35,7 @@ static ssize_t capabilities_read(struct file *file, char __user *buf,
35 35
36static const struct file_operations capabilities_file_ops = { 36static const struct file_operations capabilities_file_ops = {
37 .read = capabilities_read, 37 .read = capabilities_read,
38 .llseek = default_llseek,
38}; 39};
39 40
40static int xenfs_fill_super(struct super_block *sb, void *data, int silent) 41static int xenfs_fill_super(struct super_block *sb, void *data, int silent)
diff --git a/drivers/xen/xenfs/xenbus.c b/drivers/xen/xenfs/xenbus.c
index 3b39c3752e21..1c1236087f78 100644
--- a/drivers/xen/xenfs/xenbus.c
+++ b/drivers/xen/xenfs/xenbus.c
@@ -594,4 +594,5 @@ const struct file_operations xenbus_file_ops = {
594 .open = xenbus_file_open, 594 .open = xenbus_file_open,
595 .release = xenbus_file_release, 595 .release = xenbus_file_release,
596 .poll = xenbus_file_poll, 596 .poll = xenbus_file_poll,
597 .llseek = no_llseek,
597}; 598};
diff --git a/fs/Kconfig b/fs/Kconfig
index 3d185308ec88..65781de44fc0 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -50,6 +50,7 @@ endif # BLOCK
50config FILE_LOCKING 50config FILE_LOCKING
51 bool "Enable POSIX file locking API" if EMBEDDED 51 bool "Enable POSIX file locking API" if EMBEDDED
52 default y 52 default y
53 select BKL # while lockd still uses it.
53 help 54 help
54 This option enables standard file locking support, required 55 This option enables standard file locking support, required
55 for filesystems like NFS and for the flock() system 56 for filesystems like NFS and for the flock() system
diff --git a/fs/adfs/Kconfig b/fs/adfs/Kconfig
index e55182a74605..1dd5f34b3cf2 100644
--- a/fs/adfs/Kconfig
+++ b/fs/adfs/Kconfig
@@ -1,6 +1,7 @@
1config ADFS_FS 1config ADFS_FS
2 tristate "ADFS file system support (EXPERIMENTAL)" 2 tristate "ADFS file system support (EXPERIMENTAL)"
3 depends on BLOCK && EXPERIMENTAL 3 depends on BLOCK && EXPERIMENTAL
4 depends on BKL # need to fix
4 help 5 help
5 The Acorn Disc Filing System is the standard file system of the 6 The Acorn Disc Filing System is the standard file system of the
6 RiscOS operating system which runs on Acorn's ARM-based Risc PC 7 RiscOS operating system which runs on Acorn's ARM-based Risc PC
diff --git a/fs/adfs/super.c b/fs/adfs/super.c
index 4a3af7075c1d..d9803f73236f 100644
--- a/fs/adfs/super.c
+++ b/fs/adfs/super.c
@@ -352,11 +352,15 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
352 struct adfs_sb_info *asb; 352 struct adfs_sb_info *asb;
353 struct inode *root; 353 struct inode *root;
354 354
355 lock_kernel();
356
355 sb->s_flags |= MS_NODIRATIME; 357 sb->s_flags |= MS_NODIRATIME;
356 358
357 asb = kzalloc(sizeof(*asb), GFP_KERNEL); 359 asb = kzalloc(sizeof(*asb), GFP_KERNEL);
358 if (!asb) 360 if (!asb) {
361 unlock_kernel();
359 return -ENOMEM; 362 return -ENOMEM;
363 }
360 sb->s_fs_info = asb; 364 sb->s_fs_info = asb;
361 365
362 /* set default options */ 366 /* set default options */
@@ -474,6 +478,7 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
474 goto error; 478 goto error;
475 } else 479 } else
476 sb->s_root->d_op = &adfs_dentry_operations; 480 sb->s_root->d_op = &adfs_dentry_operations;
481 unlock_kernel();
477 return 0; 482 return 0;
478 483
479error_free_bh: 484error_free_bh:
@@ -481,6 +486,7 @@ error_free_bh:
481error: 486error:
482 sb->s_fs_info = NULL; 487 sb->s_fs_info = NULL;
483 kfree(asb); 488 kfree(asb);
489 unlock_kernel();
484 return -EINVAL; 490 return -EINVAL;
485} 491}
486 492
diff --git a/fs/affs/super.c b/fs/affs/super.c
index 9581ea94d5a1..fa4fbe1e238a 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -16,7 +16,6 @@
16#include <linux/parser.h> 16#include <linux/parser.h>
17#include <linux/magic.h> 17#include <linux/magic.h>
18#include <linux/sched.h> 18#include <linux/sched.h>
19#include <linux/smp_lock.h>
20#include <linux/slab.h> 19#include <linux/slab.h>
21#include "affs.h" 20#include "affs.h"
22 21
@@ -46,8 +45,6 @@ affs_put_super(struct super_block *sb)
46 struct affs_sb_info *sbi = AFFS_SB(sb); 45 struct affs_sb_info *sbi = AFFS_SB(sb);
47 pr_debug("AFFS: put_super()\n"); 46 pr_debug("AFFS: put_super()\n");
48 47
49 lock_kernel();
50
51 if (!(sb->s_flags & MS_RDONLY) && sb->s_dirt) 48 if (!(sb->s_flags & MS_RDONLY) && sb->s_dirt)
52 affs_commit_super(sb, 1, 1); 49 affs_commit_super(sb, 1, 1);
53 50
@@ -56,8 +53,6 @@ affs_put_super(struct super_block *sb)
56 affs_brelse(sbi->s_root_bh); 53 affs_brelse(sbi->s_root_bh);
57 kfree(sbi); 54 kfree(sbi);
58 sb->s_fs_info = NULL; 55 sb->s_fs_info = NULL;
59
60 unlock_kernel();
61} 56}
62 57
63static void 58static void
@@ -302,6 +297,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)
302 sbi = kzalloc(sizeof(struct affs_sb_info), GFP_KERNEL); 297 sbi = kzalloc(sizeof(struct affs_sb_info), GFP_KERNEL);
303 if (!sbi) 298 if (!sbi)
304 return -ENOMEM; 299 return -ENOMEM;
300
305 sb->s_fs_info = sbi; 301 sb->s_fs_info = sbi;
306 mutex_init(&sbi->s_bmlock); 302 mutex_init(&sbi->s_bmlock);
307 spin_lock_init(&sbi->symlink_lock); 303 spin_lock_init(&sbi->symlink_lock);
@@ -527,7 +523,7 @@ affs_remount(struct super_block *sb, int *flags, char *data)
527 kfree(new_opts); 523 kfree(new_opts);
528 return -EINVAL; 524 return -EINVAL;
529 } 525 }
530 lock_kernel(); 526
531 replace_mount_options(sb, new_opts); 527 replace_mount_options(sb, new_opts);
532 528
533 sbi->s_flags = mount_flags; 529 sbi->s_flags = mount_flags;
@@ -543,17 +539,15 @@ affs_remount(struct super_block *sb, int *flags, char *data)
543 memcpy(sbi->s_volume, volume, 32); 539 memcpy(sbi->s_volume, volume, 32);
544 spin_unlock(&sbi->symlink_lock); 540 spin_unlock(&sbi->symlink_lock);
545 541
546 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) { 542 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
547 unlock_kernel();
548 return 0; 543 return 0;
549 } 544
550 if (*flags & MS_RDONLY) { 545 if (*flags & MS_RDONLY) {
551 affs_write_super(sb); 546 affs_write_super(sb);
552 affs_free_bitmap(sb); 547 affs_free_bitmap(sb);
553 } else 548 } else
554 res = affs_init_bitmap(sb, flags); 549 res = affs_init_bitmap(sb, flags);
555 550
556 unlock_kernel();
557 return res; 551 return res;
558} 552}
559 553
diff --git a/fs/afs/flock.c b/fs/afs/flock.c
index 0931bc1325eb..757d664575dd 100644
--- a/fs/afs/flock.c
+++ b/fs/afs/flock.c
@@ -9,7 +9,6 @@
9 * 2 of the License, or (at your option) any later version. 9 * 2 of the License, or (at your option) any later version.
10 */ 10 */
11 11
12#include <linux/smp_lock.h>
13#include "internal.h" 12#include "internal.h"
14 13
15#define AFS_LOCK_GRANTED 0 14#define AFS_LOCK_GRANTED 0
@@ -274,7 +273,7 @@ static int afs_do_setlk(struct file *file, struct file_lock *fl)
274 273
275 type = (fl->fl_type == F_RDLCK) ? AFS_LOCK_READ : AFS_LOCK_WRITE; 274 type = (fl->fl_type == F_RDLCK) ? AFS_LOCK_READ : AFS_LOCK_WRITE;
276 275
277 lock_kernel(); 276 lock_flocks();
278 277
279 /* make sure we've got a callback on this file and that our view of the 278 /* make sure we've got a callback on this file and that our view of the
280 * data version is up to date */ 279 * data version is up to date */
@@ -421,7 +420,7 @@ given_lock:
421 afs_vnode_fetch_status(vnode, NULL, key); 420 afs_vnode_fetch_status(vnode, NULL, key);
422 421
423error: 422error:
424 unlock_kernel(); 423 unlock_flocks();
425 _leave(" = %d", ret); 424 _leave(" = %d", ret);
426 return ret; 425 return ret;
427 426
diff --git a/fs/afs/mntpt.c b/fs/afs/mntpt.c
index 6d552686c498..6153417caf57 100644
--- a/fs/afs/mntpt.c
+++ b/fs/afs/mntpt.c
@@ -29,6 +29,7 @@ static void afs_mntpt_expiry_timed_out(struct work_struct *work);
29 29
30const struct file_operations afs_mntpt_file_operations = { 30const struct file_operations afs_mntpt_file_operations = {
31 .open = afs_mntpt_open, 31 .open = afs_mntpt_open,
32 .llseek = noop_llseek,
32}; 33};
33 34
34const struct inode_operations afs_mntpt_inode_operations = { 35const struct inode_operations afs_mntpt_inode_operations = {
diff --git a/fs/afs/super.c b/fs/afs/super.c
index 77e1e5a61154..eacf76d98ae0 100644
--- a/fs/afs/super.c
+++ b/fs/afs/super.c
@@ -19,7 +19,6 @@
19#include <linux/mount.h> 19#include <linux/mount.h>
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/smp_lock.h>
23#include <linux/fs.h> 22#include <linux/fs.h>
24#include <linux/pagemap.h> 23#include <linux/pagemap.h>
25#include <linux/parser.h> 24#include <linux/parser.h>
@@ -453,12 +452,8 @@ static void afs_put_super(struct super_block *sb)
453 452
454 _enter(""); 453 _enter("");
455 454
456 lock_kernel();
457
458 afs_put_volume(as->volume); 455 afs_put_volume(as->volume);
459 456
460 unlock_kernel();
461
462 _leave(""); 457 _leave("");
463} 458}
464 459
diff --git a/fs/autofs/Kconfig b/fs/autofs/Kconfig
index 5f3bea90911e..480e210c83ab 100644
--- a/fs/autofs/Kconfig
+++ b/fs/autofs/Kconfig
@@ -1,5 +1,6 @@
1config AUTOFS_FS 1config AUTOFS_FS
2 tristate "Kernel automounter support" 2 tristate "Kernel automounter support"
3 depends on BKL # unfixable, just use autofs4
3 help 4 help
4 The automounter is a tool to automatically mount remote file systems 5 The automounter is a tool to automatically mount remote file systems
5 on demand. This implementation is partially kernel-based to reduce 6 on demand. This implementation is partially kernel-based to reduce
diff --git a/fs/autofs/root.c b/fs/autofs/root.c
index 11b1ea786d00..0c4ca81aeaeb 100644
--- a/fs/autofs/root.c
+++ b/fs/autofs/root.c
@@ -27,7 +27,9 @@ static int autofs_root_unlink(struct inode *,struct dentry *);
27static int autofs_root_rmdir(struct inode *,struct dentry *); 27static int autofs_root_rmdir(struct inode *,struct dentry *);
28static int autofs_root_mkdir(struct inode *,struct dentry *,int); 28static int autofs_root_mkdir(struct inode *,struct dentry *,int);
29static long autofs_root_ioctl(struct file *,unsigned int,unsigned long); 29static long autofs_root_ioctl(struct file *,unsigned int,unsigned long);
30#ifdef CONFIG_COMPAT
30static long autofs_root_compat_ioctl(struct file *,unsigned int,unsigned long); 31static long autofs_root_compat_ioctl(struct file *,unsigned int,unsigned long);
32#endif
31 33
32const struct file_operations autofs_root_operations = { 34const struct file_operations autofs_root_operations = {
33 .llseek = generic_file_llseek, 35 .llseek = generic_file_llseek,
diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c
index ba4a38b9c22f..eff9a419469a 100644
--- a/fs/autofs4/dev-ioctl.c
+++ b/fs/autofs4/dev-ioctl.c
@@ -724,6 +724,7 @@ static const struct file_operations _dev_ioctl_fops = {
724 .unlocked_ioctl = autofs_dev_ioctl, 724 .unlocked_ioctl = autofs_dev_ioctl,
725 .compat_ioctl = autofs_dev_ioctl_compat, 725 .compat_ioctl = autofs_dev_ioctl_compat,
726 .owner = THIS_MODULE, 726 .owner = THIS_MODULE,
727 .llseek = noop_llseek,
727}; 728};
728 729
729static struct miscdevice _autofs_dev_ioctl_misc = { 730static struct miscdevice _autofs_dev_ioctl_misc = {
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index cb1bd38dc08c..d5c1401f0031 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -19,7 +19,7 @@
19#include <linux/param.h> 19#include <linux/param.h>
20#include <linux/time.h> 20#include <linux/time.h>
21#include <linux/compat.h> 21#include <linux/compat.h>
22#include <linux/smp_lock.h> 22#include <linux/mutex.h>
23 23
24#include "autofs_i.h" 24#include "autofs_i.h"
25 25
@@ -28,7 +28,9 @@ static int autofs4_dir_unlink(struct inode *,struct dentry *);
28static int autofs4_dir_rmdir(struct inode *,struct dentry *); 28static int autofs4_dir_rmdir(struct inode *,struct dentry *);
29static int autofs4_dir_mkdir(struct inode *,struct dentry *,int); 29static int autofs4_dir_mkdir(struct inode *,struct dentry *,int);
30static long autofs4_root_ioctl(struct file *,unsigned int,unsigned long); 30static long autofs4_root_ioctl(struct file *,unsigned int,unsigned long);
31#ifdef CONFIG_COMPAT
31static long autofs4_root_compat_ioctl(struct file *,unsigned int,unsigned long); 32static long autofs4_root_compat_ioctl(struct file *,unsigned int,unsigned long);
33#endif
32static int autofs4_dir_open(struct inode *inode, struct file *file); 34static int autofs4_dir_open(struct inode *inode, struct file *file);
33static struct dentry *autofs4_lookup(struct inode *,struct dentry *, struct nameidata *); 35static struct dentry *autofs4_lookup(struct inode *,struct dentry *, struct nameidata *);
34static void *autofs4_follow_link(struct dentry *, struct nameidata *); 36static void *autofs4_follow_link(struct dentry *, struct nameidata *);
@@ -978,15 +980,17 @@ static int autofs4_root_ioctl_unlocked(struct inode *inode, struct file *filp,
978 } 980 }
979} 981}
980 982
983static DEFINE_MUTEX(autofs4_ioctl_mutex);
984
981static long autofs4_root_ioctl(struct file *filp, 985static long autofs4_root_ioctl(struct file *filp,
982 unsigned int cmd, unsigned long arg) 986 unsigned int cmd, unsigned long arg)
983{ 987{
984 long ret; 988 long ret;
985 struct inode *inode = filp->f_dentry->d_inode; 989 struct inode *inode = filp->f_dentry->d_inode;
986 990
987 lock_kernel(); 991 mutex_lock(&autofs4_ioctl_mutex);
988 ret = autofs4_root_ioctl_unlocked(inode, filp, cmd, arg); 992 ret = autofs4_root_ioctl_unlocked(inode, filp, cmd, arg);
989 unlock_kernel(); 993 mutex_unlock(&autofs4_ioctl_mutex);
990 994
991 return ret; 995 return ret;
992} 996}
@@ -998,13 +1002,13 @@ static long autofs4_root_compat_ioctl(struct file *filp,
998 struct inode *inode = filp->f_path.dentry->d_inode; 1002 struct inode *inode = filp->f_path.dentry->d_inode;
999 int ret; 1003 int ret;
1000 1004
1001 lock_kernel(); 1005 mutex_lock(&autofs4_ioctl_mutex);
1002 if (cmd == AUTOFS_IOC_READY || cmd == AUTOFS_IOC_FAIL) 1006 if (cmd == AUTOFS_IOC_READY || cmd == AUTOFS_IOC_FAIL)
1003 ret = autofs4_root_ioctl_unlocked(inode, filp, cmd, arg); 1007 ret = autofs4_root_ioctl_unlocked(inode, filp, cmd, arg);
1004 else 1008 else
1005 ret = autofs4_root_ioctl_unlocked(inode, filp, cmd, 1009 ret = autofs4_root_ioctl_unlocked(inode, filp, cmd,
1006 (unsigned long)compat_ptr(arg)); 1010 (unsigned long)compat_ptr(arg));
1007 unlock_kernel(); 1011 mutex_unlock(&autofs4_ioctl_mutex);
1008 1012
1009 return ret; 1013 return ret;
1010} 1014}
diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c
index c4daf0f5fc02..883e77acd5a8 100644
--- a/fs/bfs/inode.c
+++ b/fs/bfs/inode.c
@@ -12,7 +12,6 @@
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/fs.h> 14#include <linux/fs.h>
15#include <linux/smp_lock.h>
16#include <linux/buffer_head.h> 15#include <linux/buffer_head.h>
17#include <linux/vfs.h> 16#include <linux/vfs.h>
18#include <linux/writeback.h> 17#include <linux/writeback.h>
@@ -215,14 +214,10 @@ static void bfs_put_super(struct super_block *s)
215 if (!info) 214 if (!info)
216 return; 215 return;
217 216
218 lock_kernel();
219
220 mutex_destroy(&info->bfs_lock); 217 mutex_destroy(&info->bfs_lock);
221 kfree(info->si_imap); 218 kfree(info->si_imap);
222 kfree(info); 219 kfree(info);
223 s->s_fs_info = NULL; 220 s->s_fs_info = NULL;
224
225 unlock_kernel();
226} 221}
227 222
228static int bfs_statfs(struct dentry *dentry, struct kstatfs *buf) 223static int bfs_statfs(struct dentry *dentry, struct kstatfs *buf)
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index fd0cc0bf9a40..139fc8083f53 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -576,6 +576,7 @@ static ssize_t bm_entry_write(struct file *file, const char __user *buffer,
576static const struct file_operations bm_entry_operations = { 576static const struct file_operations bm_entry_operations = {
577 .read = bm_entry_read, 577 .read = bm_entry_read,
578 .write = bm_entry_write, 578 .write = bm_entry_write,
579 .llseek = default_llseek,
579}; 580};
580 581
581/* /register */ 582/* /register */
@@ -643,6 +644,7 @@ out:
643 644
644static const struct file_operations bm_register_operations = { 645static const struct file_operations bm_register_operations = {
645 .write = bm_register_write, 646 .write = bm_register_write,
647 .llseek = noop_llseek,
646}; 648};
647 649
648/* /status */ 650/* /status */
@@ -680,6 +682,7 @@ static ssize_t bm_status_write(struct file * file, const char __user * buffer,
680static const struct file_operations bm_status_operations = { 682static const struct file_operations bm_status_operations = {
681 .read = bm_status_read, 683 .read = bm_status_read,
682 .write = bm_status_write, 684 .write = bm_status_write,
685 .llseek = default_llseek,
683}; 686};
684 687
685/* Superblock handling */ 688/* Superblock handling */
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 1776dbd8dc98..144f8a5730f5 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -815,6 +815,7 @@ static const struct file_operations btrfs_ctl_fops = {
815 .unlocked_ioctl = btrfs_control_ioctl, 815 .unlocked_ioctl = btrfs_control_ioctl,
816 .compat_ioctl = btrfs_control_ioctl, 816 .compat_ioctl = btrfs_control_ioctl,
817 .owner = THIS_MODULE, 817 .owner = THIS_MODULE,
818 .llseek = noop_llseek,
818}; 819};
819 820
820static struct miscdevice btrfs_misc = { 821static struct miscdevice btrfs_misc = {
diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
index 727caedcdd92..0a1467b15516 100644
--- a/fs/cachefiles/daemon.c
+++ b/fs/cachefiles/daemon.c
@@ -55,6 +55,7 @@ const struct file_operations cachefiles_daemon_fops = {
55 .read = cachefiles_daemon_read, 55 .read = cachefiles_daemon_read,
56 .write = cachefiles_daemon_write, 56 .write = cachefiles_daemon_write,
57 .poll = cachefiles_daemon_poll, 57 .poll = cachefiles_daemon_poll,
58 .llseek = noop_llseek,
58}; 59};
59 60
60struct cachefiles_daemon_cmd { 61struct cachefiles_daemon_cmd {
diff --git a/fs/char_dev.c b/fs/char_dev.c
index 143d393881cb..e5b9df993b93 100644
--- a/fs/char_dev.c
+++ b/fs/char_dev.c
@@ -456,6 +456,7 @@ static void cdev_purge(struct cdev *cdev)
456 */ 456 */
457const struct file_operations def_chr_fops = { 457const struct file_operations def_chr_fops = {
458 .open = chrdev_open, 458 .open = chrdev_open,
459 .llseek = noop_llseek,
459}; 460};
460 461
461static struct kobject *exact_match(dev_t dev, int *part, void *data) 462static struct kobject *exact_match(dev_t dev, int *part, void *data)
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index b7431afdd76d..50208c15309a 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -35,7 +35,6 @@
35#include <linux/delay.h> 35#include <linux/delay.h>
36#include <linux/kthread.h> 36#include <linux/kthread.h>
37#include <linux/freezer.h> 37#include <linux/freezer.h>
38#include <linux/smp_lock.h>
39#include "cifsfs.h" 38#include "cifsfs.h"
40#include "cifspdu.h" 39#include "cifspdu.h"
41#define DECLARE_GLOBALS_HERE 40#define DECLARE_GLOBALS_HERE
@@ -200,8 +199,6 @@ cifs_put_super(struct super_block *sb)
200 return; 199 return;
201 } 200 }
202 201
203 lock_kernel();
204
205 rc = cifs_umount(sb, cifs_sb); 202 rc = cifs_umount(sb, cifs_sb);
206 if (rc) 203 if (rc)
207 cERROR(1, "cifs_umount failed with return code %d", rc); 204 cERROR(1, "cifs_umount failed with return code %d", rc);
@@ -215,8 +212,6 @@ cifs_put_super(struct super_block *sb)
215 unload_nls(cifs_sb->local_nls); 212 unload_nls(cifs_sb->local_nls);
216 bdi_destroy(&cifs_sb->bdi); 213 bdi_destroy(&cifs_sb->bdi);
217 kfree(cifs_sb); 214 kfree(cifs_sb);
218
219 unlock_kernel();
220} 215}
221 216
222static int 217static int
@@ -514,7 +509,9 @@ cifs_get_sb(struct file_system_type *fs_type,
514 int flags, const char *dev_name, void *data, struct vfsmount *mnt) 509 int flags, const char *dev_name, void *data, struct vfsmount *mnt)
515{ 510{
516 int rc; 511 int rc;
517 struct super_block *sb = sget(fs_type, NULL, set_anon_super, NULL); 512 struct super_block *sb;
513
514 sb = sget(fs_type, NULL, set_anon_super, NULL);
518 515
519 cFYI(1, "Devname: %s flags: %d ", dev_name, flags); 516 cFYI(1, "Devname: %s flags: %d ", dev_name, flags);
520 517
@@ -565,8 +562,8 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int origin)
565 562
566static int cifs_setlease(struct file *file, long arg, struct file_lock **lease) 563static int cifs_setlease(struct file *file, long arg, struct file_lock **lease)
567{ 564{
568 /* note that this is called by vfs setlease with the BKL held 565 /* note that this is called by vfs setlease with lock_flocks held
569 although I doubt that BKL is needed here in cifs */ 566 to protect *lease from going away */
570 struct inode *inode = file->f_path.dentry->d_inode; 567 struct inode *inode = file->f_path.dentry->d_inode;
571 568
572 if (!(S_ISREG(inode->i_mode))) 569 if (!(S_ISREG(inode->i_mode)))
diff --git a/fs/coda/inode.c b/fs/coda/inode.c
index 6526e6f21ecf..bfe8179b1295 100644
--- a/fs/coda/inode.c
+++ b/fs/coda/inode.c
@@ -148,6 +148,8 @@ static int coda_fill_super(struct super_block *sb, void *data, int silent)
148 int error; 148 int error;
149 int idx; 149 int idx;
150 150
151 lock_kernel();
152
151 idx = get_device_index((struct coda_mount_data *) data); 153 idx = get_device_index((struct coda_mount_data *) data);
152 154
153 /* Ignore errors in data, for backward compatibility */ 155 /* Ignore errors in data, for backward compatibility */
@@ -159,11 +161,13 @@ static int coda_fill_super(struct super_block *sb, void *data, int silent)
159 vc = &coda_comms[idx]; 161 vc = &coda_comms[idx];
160 if (!vc->vc_inuse) { 162 if (!vc->vc_inuse) {
161 printk("coda_read_super: No pseudo device\n"); 163 printk("coda_read_super: No pseudo device\n");
164 unlock_kernel();
162 return -EINVAL; 165 return -EINVAL;
163 } 166 }
164 167
165 if ( vc->vc_sb ) { 168 if ( vc->vc_sb ) {
166 printk("coda_read_super: Device already mounted\n"); 169 printk("coda_read_super: Device already mounted\n");
170 unlock_kernel();
167 return -EBUSY; 171 return -EBUSY;
168 } 172 }
169 173
@@ -202,7 +206,8 @@ static int coda_fill_super(struct super_block *sb, void *data, int silent)
202 sb->s_root = d_alloc_root(root); 206 sb->s_root = d_alloc_root(root);
203 if (!sb->s_root) 207 if (!sb->s_root)
204 goto error; 208 goto error;
205 return 0; 209 unlock_kernel();
210 return 0;
206 211
207 error: 212 error:
208 bdi_destroy(&vc->bdi); 213 bdi_destroy(&vc->bdi);
@@ -212,6 +217,7 @@ static int coda_fill_super(struct super_block *sb, void *data, int silent)
212 if (vc) 217 if (vc)
213 vc->vc_sb = NULL; 218 vc->vc_sb = NULL;
214 219
220 unlock_kernel();
215 return -EINVAL; 221 return -EINVAL;
216} 222}
217 223
diff --git a/fs/coda/pioctl.c b/fs/coda/pioctl.c
index ca25d96d45c9..028a9a0f588b 100644
--- a/fs/coda/pioctl.c
+++ b/fs/coda/pioctl.c
@@ -39,6 +39,7 @@ const struct inode_operations coda_ioctl_inode_operations = {
39const struct file_operations coda_ioctl_operations = { 39const struct file_operations coda_ioctl_operations = {
40 .owner = THIS_MODULE, 40 .owner = THIS_MODULE,
41 .unlocked_ioctl = coda_pioctl, 41 .unlocked_ioctl = coda_pioctl,
42 .llseek = noop_llseek,
42}; 43};
43 44
44/* the coda pioctl inode ops */ 45/* the coda pioctl inode ops */
diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c
index 116af7546cf0..fdc2f3ef7ecd 100644
--- a/fs/coda/psdev.c
+++ b/fs/coda/psdev.c
@@ -346,6 +346,7 @@ static const struct file_operations coda_psdev_fops = {
346 .unlocked_ioctl = coda_psdev_ioctl, 346 .unlocked_ioctl = coda_psdev_ioctl,
347 .open = coda_psdev_open, 347 .open = coda_psdev_open,
348 .release = coda_psdev_release, 348 .release = coda_psdev_release,
349 .llseek = noop_llseek,
349}; 350};
350 351
351static int init_coda_psdev(void) 352static int init_coda_psdev(void)
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 03e59aa318eb..d0ad09d57789 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -599,69 +599,6 @@ static int do_smb_getmountuid(unsigned int fd, unsigned int cmd,
599#define HIDPGETCONNLIST _IOR('H', 210, int) 599#define HIDPGETCONNLIST _IOR('H', 210, int)
600#define HIDPGETCONNINFO _IOR('H', 211, int) 600#define HIDPGETCONNINFO _IOR('H', 211, int)
601 601
602#ifdef CONFIG_BLOCK
603struct raw32_config_request
604{
605 compat_int_t raw_minor;
606 __u64 block_major;
607 __u64 block_minor;
608} __attribute__((packed));
609
610static int get_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req)
611{
612 int ret;
613
614 if (!access_ok(VERIFY_READ, user_req, sizeof(struct raw32_config_request)))
615 return -EFAULT;
616
617 ret = __get_user(req->raw_minor, &user_req->raw_minor);
618 ret |= __get_user(req->block_major, &user_req->block_major);
619 ret |= __get_user(req->block_minor, &user_req->block_minor);
620
621 return ret ? -EFAULT : 0;
622}
623
624static int set_raw32_request(struct raw_config_request *req, struct raw32_config_request __user *user_req)
625{
626 int ret;
627
628 if (!access_ok(VERIFY_WRITE, user_req, sizeof(struct raw32_config_request)))
629 return -EFAULT;
630
631 ret = __put_user(req->raw_minor, &user_req->raw_minor);
632 ret |= __put_user(req->block_major, &user_req->block_major);
633 ret |= __put_user(req->block_minor, &user_req->block_minor);
634
635 return ret ? -EFAULT : 0;
636}
637
638static int raw_ioctl(unsigned fd, unsigned cmd,
639 struct raw32_config_request __user *user_req)
640{
641 int ret;
642
643 switch (cmd) {
644 case RAW_SETBIND:
645 default: { /* RAW_GETBIND */
646 struct raw_config_request req;
647 mm_segment_t oldfs = get_fs();
648
649 if ((ret = get_raw32_request(&req, user_req)))
650 return ret;
651
652 set_fs(KERNEL_DS);
653 ret = sys_ioctl(fd,cmd,(unsigned long)&req);
654 set_fs(oldfs);
655
656 if ((!ret) && (cmd == RAW_GETBIND)) {
657 ret = set_raw32_request(&req, user_req);
658 }
659 break;
660 }
661 }
662 return ret;
663}
664#endif /* CONFIG_BLOCK */
665 602
666struct serial_struct32 { 603struct serial_struct32 {
667 compat_int_t type; 604 compat_int_t type;
@@ -1262,9 +1199,6 @@ COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE5)
1262COMPATIBLE_IOCTL(SOUND_MIXER_GETLEVELS) 1199COMPATIBLE_IOCTL(SOUND_MIXER_GETLEVELS)
1263COMPATIBLE_IOCTL(SOUND_MIXER_SETLEVELS) 1200COMPATIBLE_IOCTL(SOUND_MIXER_SETLEVELS)
1264COMPATIBLE_IOCTL(OSS_GETVERSION) 1201COMPATIBLE_IOCTL(OSS_GETVERSION)
1265/* Raw devices */
1266COMPATIBLE_IOCTL(RAW_SETBIND)
1267COMPATIBLE_IOCTL(RAW_GETBIND)
1268/* SMB ioctls which do not need any translations */ 1202/* SMB ioctls which do not need any translations */
1269COMPATIBLE_IOCTL(SMB_IOC_NEWCONN) 1203COMPATIBLE_IOCTL(SMB_IOC_NEWCONN)
1270/* Watchdog */ 1204/* Watchdog */
@@ -1523,10 +1457,6 @@ static long do_ioctl_trans(int fd, unsigned int cmd,
1523 case MTIOCGET32: 1457 case MTIOCGET32:
1524 case MTIOCPOS32: 1458 case MTIOCPOS32:
1525 return mt_ioctl_trans(fd, cmd, argp); 1459 return mt_ioctl_trans(fd, cmd, argp);
1526 /* Raw devices */
1527 case RAW_SETBIND:
1528 case RAW_GETBIND:
1529 return raw_ioctl(fd, cmd, argp);
1530#endif 1460#endif
1531 /* One SMB ioctl needs translations. */ 1461 /* One SMB ioctl needs translations. */
1532#define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t) 1462#define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t)
diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index 0210898458b2..89d394d8fe24 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -43,6 +43,7 @@ const struct file_operations debugfs_file_operations = {
43 .read = default_read_file, 43 .read = default_read_file,
44 .write = default_write_file, 44 .write = default_write_file,
45 .open = default_open, 45 .open = default_open,
46 .llseek = noop_llseek,
46}; 47};
47 48
48static void *debugfs_follow_link(struct dentry *dentry, struct nameidata *nd) 49static void *debugfs_follow_link(struct dentry *dentry, struct nameidata *nd)
@@ -454,6 +455,7 @@ static const struct file_operations fops_bool = {
454 .read = read_file_bool, 455 .read = read_file_bool,
455 .write = write_file_bool, 456 .write = write_file_bool,
456 .open = default_open, 457 .open = default_open,
458 .llseek = default_llseek,
457}; 459};
458 460
459/** 461/**
@@ -498,6 +500,7 @@ static ssize_t read_file_blob(struct file *file, char __user *user_buf,
498static const struct file_operations fops_blob = { 500static const struct file_operations fops_blob = {
499 .read = read_file_blob, 501 .read = read_file_blob,
500 .open = default_open, 502 .open = default_open,
503 .llseek = default_llseek,
501}; 504};
502 505
503/** 506/**
diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c
index c6cf25158746..6b42ba807dfd 100644
--- a/fs/dlm/debug_fs.c
+++ b/fs/dlm/debug_fs.c
@@ -643,7 +643,8 @@ static ssize_t waiters_read(struct file *file, char __user *userbuf,
643static const struct file_operations waiters_fops = { 643static const struct file_operations waiters_fops = {
644 .owner = THIS_MODULE, 644 .owner = THIS_MODULE,
645 .open = waiters_open, 645 .open = waiters_open,
646 .read = waiters_read 646 .read = waiters_read,
647 .llseek = default_llseek,
647}; 648};
648 649
649void dlm_delete_debug_file(struct dlm_ls *ls) 650void dlm_delete_debug_file(struct dlm_ls *ls)
diff --git a/fs/dlm/plock.c b/fs/dlm/plock.c
index d45c02db6943..30d8b85febbf 100644
--- a/fs/dlm/plock.c
+++ b/fs/dlm/plock.c
@@ -412,7 +412,8 @@ static const struct file_operations dev_fops = {
412 .read = dev_read, 412 .read = dev_read,
413 .write = dev_write, 413 .write = dev_write,
414 .poll = dev_poll, 414 .poll = dev_poll,
415 .owner = THIS_MODULE 415 .owner = THIS_MODULE,
416 .llseek = noop_llseek,
416}; 417};
417 418
418static struct miscdevice plock_dev_misc = { 419static struct miscdevice plock_dev_misc = {
diff --git a/fs/dlm/user.c b/fs/dlm/user.c
index b6272853130c..66d6c16bf440 100644
--- a/fs/dlm/user.c
+++ b/fs/dlm/user.c
@@ -1009,6 +1009,7 @@ static const struct file_operations device_fops = {
1009 .write = device_write, 1009 .write = device_write,
1010 .poll = device_poll, 1010 .poll = device_poll,
1011 .owner = THIS_MODULE, 1011 .owner = THIS_MODULE,
1012 .llseek = noop_llseek,
1012}; 1013};
1013 1014
1014static const struct file_operations ctl_device_fops = { 1015static const struct file_operations ctl_device_fops = {
@@ -1017,6 +1018,7 @@ static const struct file_operations ctl_device_fops = {
1017 .read = device_read, 1018 .read = device_read,
1018 .write = device_write, 1019 .write = device_write,
1019 .owner = THIS_MODULE, 1020 .owner = THIS_MODULE,
1021 .llseek = noop_llseek,
1020}; 1022};
1021 1023
1022static struct miscdevice ctl_device = { 1024static struct miscdevice ctl_device = {
@@ -1029,6 +1031,7 @@ static const struct file_operations monitor_device_fops = {
1029 .open = monitor_device_open, 1031 .open = monitor_device_open,
1030 .release = monitor_device_close, 1032 .release = monitor_device_close,
1031 .owner = THIS_MODULE, 1033 .owner = THIS_MODULE,
1034 .llseek = noop_llseek,
1032}; 1035};
1033 1036
1034static struct miscdevice monitor_device = { 1037static struct miscdevice monitor_device = {
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
index 622c95140802..91da02987bff 100644
--- a/fs/ecryptfs/file.c
+++ b/fs/ecryptfs/file.c
@@ -31,7 +31,6 @@
31#include <linux/security.h> 31#include <linux/security.h>
32#include <linux/compat.h> 32#include <linux/compat.h>
33#include <linux/fs_stack.h> 33#include <linux/fs_stack.h>
34#include <linux/smp_lock.h>
35#include "ecryptfs_kernel.h" 34#include "ecryptfs_kernel.h"
36 35
37/** 36/**
@@ -284,11 +283,9 @@ static int ecryptfs_fasync(int fd, struct file *file, int flag)
284 int rc = 0; 283 int rc = 0;
285 struct file *lower_file = NULL; 284 struct file *lower_file = NULL;
286 285
287 lock_kernel();
288 lower_file = ecryptfs_file_to_lower(file); 286 lower_file = ecryptfs_file_to_lower(file);
289 if (lower_file->f_op && lower_file->f_op->fasync) 287 if (lower_file->f_op && lower_file->f_op->fasync)
290 rc = lower_file->f_op->fasync(fd, lower_file, flag); 288 rc = lower_file->f_op->fasync(fd, lower_file, flag);
291 unlock_kernel();
292 return rc; 289 return rc;
293} 290}
294 291
@@ -332,6 +329,7 @@ const struct file_operations ecryptfs_dir_fops = {
332 .fsync = ecryptfs_fsync, 329 .fsync = ecryptfs_fsync,
333 .fasync = ecryptfs_fasync, 330 .fasync = ecryptfs_fasync,
334 .splice_read = generic_file_splice_read, 331 .splice_read = generic_file_splice_read,
332 .llseek = default_llseek,
335}; 333};
336 334
337const struct file_operations ecryptfs_main_fops = { 335const struct file_operations ecryptfs_main_fops = {
diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
index 00208c3d7e92..940a82e63dc3 100644
--- a/fs/ecryptfs/miscdev.c
+++ b/fs/ecryptfs/miscdev.c
@@ -482,6 +482,7 @@ static const struct file_operations ecryptfs_miscdev_fops = {
482 .read = ecryptfs_miscdev_read, 482 .read = ecryptfs_miscdev_read,
483 .write = ecryptfs_miscdev_write, 483 .write = ecryptfs_miscdev_write,
484 .release = ecryptfs_miscdev_release, 484 .release = ecryptfs_miscdev_release,
485 .llseek = noop_llseek,
485}; 486};
486 487
487static struct miscdevice ecryptfs_miscdev = { 488static struct miscdevice ecryptfs_miscdev = {
diff --git a/fs/eventfd.c b/fs/eventfd.c
index 6bd3f76fdf88..e0194b3e14d6 100644
--- a/fs/eventfd.c
+++ b/fs/eventfd.c
@@ -293,6 +293,7 @@ static const struct file_operations eventfd_fops = {
293 .poll = eventfd_poll, 293 .poll = eventfd_poll,
294 .read = eventfd_read, 294 .read = eventfd_read,
295 .write = eventfd_write, 295 .write = eventfd_write,
296 .llseek = noop_llseek,
296}; 297};
297 298
298/** 299/**
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 3817149919cb..256bb7bb102a 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -674,7 +674,8 @@ static unsigned int ep_eventpoll_poll(struct file *file, poll_table *wait)
674/* File callbacks that implement the eventpoll file behaviour */ 674/* File callbacks that implement the eventpoll file behaviour */
675static const struct file_operations eventpoll_fops = { 675static const struct file_operations eventpoll_fops = {
676 .release = ep_eventpoll_release, 676 .release = ep_eventpoll_release,
677 .poll = ep_eventpoll_poll 677 .poll = ep_eventpoll_poll,
678 .llseek = noop_llseek,
678}; 679};
679 680
680/* Fast test to see if the file is an evenpoll file */ 681/* Fast test to see if the file is an evenpoll file */
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 1ec602673ea8..85df87d0f7b7 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -747,15 +747,16 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
747 __le32 features; 747 __le32 features;
748 int err; 748 int err;
749 749
750 err = -ENOMEM;
750 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); 751 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
751 if (!sbi) 752 if (!sbi)
752 return -ENOMEM; 753 goto failed_unlock;
753 754
754 sbi->s_blockgroup_lock = 755 sbi->s_blockgroup_lock =
755 kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL); 756 kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL);
756 if (!sbi->s_blockgroup_lock) { 757 if (!sbi->s_blockgroup_lock) {
757 kfree(sbi); 758 kfree(sbi);
758 return -ENOMEM; 759 goto failed_unlock;
759 } 760 }
760 sb->s_fs_info = sbi; 761 sb->s_fs_info = sbi;
761 sbi->s_sb_block = sb_block; 762 sbi->s_sb_block = sb_block;
@@ -1107,6 +1108,7 @@ failed_sbi:
1107 sb->s_fs_info = NULL; 1108 sb->s_fs_info = NULL;
1108 kfree(sbi->s_blockgroup_lock); 1109 kfree(sbi->s_blockgroup_lock);
1109 kfree(sbi); 1110 kfree(sbi);
1111failed_unlock:
1110 return ret; 1112 return ret;
1111} 1113}
1112 1114
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index a367dd044280..377768009106 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -411,9 +411,6 @@ static void ext3_put_super (struct super_block * sb)
411 int i, err; 411 int i, err;
412 412
413 dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); 413 dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED);
414
415 lock_kernel();
416
417 ext3_xattr_put_super(sb); 414 ext3_xattr_put_super(sb);
418 err = journal_destroy(sbi->s_journal); 415 err = journal_destroy(sbi->s_journal);
419 sbi->s_journal = NULL; 416 sbi->s_journal = NULL;
@@ -462,8 +459,6 @@ static void ext3_put_super (struct super_block * sb)
462 sb->s_fs_info = NULL; 459 sb->s_fs_info = NULL;
463 kfree(sbi->s_blockgroup_lock); 460 kfree(sbi->s_blockgroup_lock);
464 kfree(sbi); 461 kfree(sbi);
465
466 unlock_kernel();
467} 462}
468 463
469static struct kmem_cache *ext3_inode_cachep; 464static struct kmem_cache *ext3_inode_cachep;
@@ -1627,8 +1622,6 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1627 sbi->s_resgid = EXT3_DEF_RESGID; 1622 sbi->s_resgid = EXT3_DEF_RESGID;
1628 sbi->s_sb_block = sb_block; 1623 sbi->s_sb_block = sb_block;
1629 1624
1630 unlock_kernel();
1631
1632 blocksize = sb_min_blocksize(sb, EXT3_MIN_BLOCK_SIZE); 1625 blocksize = sb_min_blocksize(sb, EXT3_MIN_BLOCK_SIZE);
1633 if (!blocksize) { 1626 if (!blocksize) {
1634 ext3_msg(sb, KERN_ERR, "error: unable to set blocksize"); 1627 ext3_msg(sb, KERN_ERR, "error: unable to set blocksize");
@@ -2025,7 +2018,6 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
2025 test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA ? "ordered": 2018 test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA ? "ordered":
2026 "writeback"); 2019 "writeback");
2027 2020
2028 lock_kernel();
2029 return 0; 2021 return 0;
2030 2022
2031cantfind_ext3: 2023cantfind_ext3:
@@ -2055,7 +2047,6 @@ out_fail:
2055 sb->s_fs_info = NULL; 2047 sb->s_fs_info = NULL;
2056 kfree(sbi->s_blockgroup_lock); 2048 kfree(sbi->s_blockgroup_lock);
2057 kfree(sbi); 2049 kfree(sbi);
2058 lock_kernel();
2059 return ret; 2050 return ret;
2060} 2051}
2061 2052
@@ -2538,8 +2529,6 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
2538 int i; 2529 int i;
2539#endif 2530#endif
2540 2531
2541 lock_kernel();
2542
2543 /* Store the original options */ 2532 /* Store the original options */
2544 lock_super(sb); 2533 lock_super(sb);
2545 old_sb_flags = sb->s_flags; 2534 old_sb_flags = sb->s_flags;
@@ -2648,7 +2637,6 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
2648 kfree(old_opts.s_qf_names[i]); 2637 kfree(old_opts.s_qf_names[i]);
2649#endif 2638#endif
2650 unlock_super(sb); 2639 unlock_super(sb);
2651 unlock_kernel();
2652 2640
2653 if (enable_quota) 2641 if (enable_quota)
2654 dquot_resume(sb, -1); 2642 dquot_resume(sb, -1);
@@ -2669,7 +2657,6 @@ restore_opts:
2669 } 2657 }
2670#endif 2658#endif
2671 unlock_super(sb); 2659 unlock_super(sb);
2672 unlock_kernel();
2673 return err; 2660 return err;
2674} 2661}
2675 2662
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 7f47c366bf15..8ecc1e590303 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -26,7 +26,6 @@
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/blkdev.h> 27#include <linux/blkdev.h>
28#include <linux/parser.h> 28#include <linux/parser.h>
29#include <linux/smp_lock.h>
30#include <linux/buffer_head.h> 29#include <linux/buffer_head.h>
31#include <linux/exportfs.h> 30#include <linux/exportfs.h>
32#include <linux/vfs.h> 31#include <linux/vfs.h>
@@ -708,7 +707,6 @@ static void ext4_put_super(struct super_block *sb)
708 destroy_workqueue(sbi->dio_unwritten_wq); 707 destroy_workqueue(sbi->dio_unwritten_wq);
709 708
710 lock_super(sb); 709 lock_super(sb);
711 lock_kernel();
712 if (sb->s_dirt) 710 if (sb->s_dirt)
713 ext4_commit_super(sb, 1); 711 ext4_commit_super(sb, 1);
714 712
@@ -775,7 +773,6 @@ static void ext4_put_super(struct super_block *sb)
775 * Now that we are completely done shutting down the 773 * Now that we are completely done shutting down the
776 * superblock, we need to actually destroy the kobject. 774 * superblock, we need to actually destroy the kobject.
777 */ 775 */
778 unlock_kernel();
779 unlock_super(sb); 776 unlock_super(sb);
780 kobject_put(&sbi->s_kobj); 777 kobject_put(&sbi->s_kobj);
781 wait_for_completion(&sbi->s_kobj_unregister); 778 wait_for_completion(&sbi->s_kobj_unregister);
@@ -2588,8 +2585,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
2588 sbi->s_sectors_written_start = 2585 sbi->s_sectors_written_start =
2589 part_stat_read(sb->s_bdev->bd_part, sectors[1]); 2586 part_stat_read(sb->s_bdev->bd_part, sectors[1]);
2590 2587
2591 unlock_kernel();
2592
2593 /* Cleanup superblock name */ 2588 /* Cleanup superblock name */
2594 for (cp = sb->s_id; (cp = strchr(cp, '/'));) 2589 for (cp = sb->s_id; (cp = strchr(cp, '/'));)
2595 *cp = '!'; 2590 *cp = '!';
@@ -3164,7 +3159,6 @@ no_journal:
3164 if (es->s_error_count) 3159 if (es->s_error_count)
3165 mod_timer(&sbi->s_err_report, jiffies + 300*HZ); /* 5 minutes */ 3160 mod_timer(&sbi->s_err_report, jiffies + 300*HZ); /* 5 minutes */
3166 3161
3167 lock_kernel();
3168 kfree(orig_data); 3162 kfree(orig_data);
3169 return 0; 3163 return 0;
3170 3164
@@ -3211,7 +3205,6 @@ out_fail:
3211 sb->s_fs_info = NULL; 3205 sb->s_fs_info = NULL;
3212 kfree(sbi->s_blockgroup_lock); 3206 kfree(sbi->s_blockgroup_lock);
3213 kfree(sbi); 3207 kfree(sbi);
3214 lock_kernel();
3215out_free_orig: 3208out_free_orig:
3216 kfree(orig_data); 3209 kfree(orig_data);
3217 return ret; 3210 return ret;
@@ -3720,8 +3713,6 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
3720#endif 3713#endif
3721 char *orig_data = kstrdup(data, GFP_KERNEL); 3714 char *orig_data = kstrdup(data, GFP_KERNEL);
3722 3715
3723 lock_kernel();
3724
3725 /* Store the original options */ 3716 /* Store the original options */
3726 lock_super(sb); 3717 lock_super(sb);
3727 old_sb_flags = sb->s_flags; 3718 old_sb_flags = sb->s_flags;
@@ -3856,7 +3847,6 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
3856 kfree(old_opts.s_qf_names[i]); 3847 kfree(old_opts.s_qf_names[i]);
3857#endif 3848#endif
3858 unlock_super(sb); 3849 unlock_super(sb);
3859 unlock_kernel();
3860 if (enable_quota) 3850 if (enable_quota)
3861 dquot_resume(sb, -1); 3851 dquot_resume(sb, -1);
3862 3852
@@ -3882,7 +3872,6 @@ restore_opts:
3882 } 3872 }
3883#endif 3873#endif
3884 unlock_super(sb); 3874 unlock_super(sb);
3885 unlock_kernel();
3886 kfree(orig_data); 3875 kfree(orig_data);
3887 return err; 3876 return err;
3888} 3877}
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 830058057d33..ad6998a92c30 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -14,7 +14,6 @@
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/time.h> 15#include <linux/time.h>
16#include <linux/slab.h> 16#include <linux/slab.h>
17#include <linux/smp_lock.h>
18#include <linux/seq_file.h> 17#include <linux/seq_file.h>
19#include <linux/pagemap.h> 18#include <linux/pagemap.h>
20#include <linux/mpage.h> 19#include <linux/mpage.h>
@@ -489,8 +488,6 @@ static void fat_put_super(struct super_block *sb)
489{ 488{
490 struct msdos_sb_info *sbi = MSDOS_SB(sb); 489 struct msdos_sb_info *sbi = MSDOS_SB(sb);
491 490
492 lock_kernel();
493
494 if (sb->s_dirt) 491 if (sb->s_dirt)
495 fat_write_super(sb); 492 fat_write_super(sb);
496 493
@@ -504,8 +501,6 @@ static void fat_put_super(struct super_block *sb)
504 501
505 sb->s_fs_info = NULL; 502 sb->s_fs_info = NULL;
506 kfree(sbi); 503 kfree(sbi);
507
508 unlock_kernel();
509} 504}
510 505
511static struct kmem_cache *fat_inode_cachep; 506static struct kmem_cache *fat_inode_cachep;
diff --git a/fs/fat/namei_msdos.c b/fs/fat/namei_msdos.c
index bbc94ae4fd77..bbca5c186ae7 100644
--- a/fs/fat/namei_msdos.c
+++ b/fs/fat/namei_msdos.c
@@ -662,12 +662,16 @@ static int msdos_fill_super(struct super_block *sb, void *data, int silent)
662{ 662{
663 int res; 663 int res;
664 664
665 lock_super(sb);
665 res = fat_fill_super(sb, data, silent, &msdos_dir_inode_operations, 0); 666 res = fat_fill_super(sb, data, silent, &msdos_dir_inode_operations, 0);
666 if (res) 667 if (res) {
668 unlock_super(sb);
667 return res; 669 return res;
670 }
668 671
669 sb->s_flags |= MS_NOATIME; 672 sb->s_flags |= MS_NOATIME;
670 sb->s_root->d_op = &msdos_dentry_operations; 673 sb->s_root->d_op = &msdos_dentry_operations;
674 unlock_super(sb);
671 return 0; 675 return 0;
672} 676}
673 677
diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
index 6fcc7e71fbaa..6f0f6c9a0152 100644
--- a/fs/fat/namei_vfat.c
+++ b/fs/fat/namei_vfat.c
@@ -1055,15 +1055,19 @@ static int vfat_fill_super(struct super_block *sb, void *data, int silent)
1055{ 1055{
1056 int res; 1056 int res;
1057 1057
1058 lock_super(sb);
1058 res = fat_fill_super(sb, data, silent, &vfat_dir_inode_operations, 1); 1059 res = fat_fill_super(sb, data, silent, &vfat_dir_inode_operations, 1);
1059 if (res) 1060 if (res) {
1061 unlock_super(sb);
1060 return res; 1062 return res;
1063 }
1061 1064
1062 if (MSDOS_SB(sb)->options.name_check != 's') 1065 if (MSDOS_SB(sb)->options.name_check != 's')
1063 sb->s_root->d_op = &vfat_ci_dentry_ops; 1066 sb->s_root->d_op = &vfat_ci_dentry_ops;
1064 else 1067 else
1065 sb->s_root->d_op = &vfat_dentry_ops; 1068 sb->s_root->d_op = &vfat_dentry_ops;
1066 1069
1070 unlock_super(sb);
1067 return 0; 1071 return 0;
1068} 1072}
1069 1073
diff --git a/fs/fifo.c b/fs/fifo.c
index 5d6606ffc2d2..4e303c22d5ee 100644
--- a/fs/fifo.c
+++ b/fs/fifo.c
@@ -151,4 +151,5 @@ err_nocleanup:
151 */ 151 */
152const struct file_operations def_fifo_fops = { 152const struct file_operations def_fifo_fops = {
153 .open = fifo_open, /* will set read_ or write_pipefifo_fops */ 153 .open = fifo_open, /* will set read_ or write_pipefifo_fops */
154 .llseek = noop_llseek,
154}; 155};
diff --git a/fs/freevxfs/vxfs_lookup.c b/fs/freevxfs/vxfs_lookup.c
index 0ec7bb2c95c6..6c5131d592f0 100644
--- a/fs/freevxfs/vxfs_lookup.c
+++ b/fs/freevxfs/vxfs_lookup.c
@@ -36,7 +36,6 @@
36#include <linux/highmem.h> 36#include <linux/highmem.h>
37#include <linux/kernel.h> 37#include <linux/kernel.h>
38#include <linux/pagemap.h> 38#include <linux/pagemap.h>
39#include <linux/smp_lock.h>
40 39
41#include "vxfs.h" 40#include "vxfs.h"
42#include "vxfs_dir.h" 41#include "vxfs_dir.h"
@@ -212,16 +211,12 @@ vxfs_lookup(struct inode *dip, struct dentry *dp, struct nameidata *nd)
212 if (dp->d_name.len > VXFS_NAMELEN) 211 if (dp->d_name.len > VXFS_NAMELEN)
213 return ERR_PTR(-ENAMETOOLONG); 212 return ERR_PTR(-ENAMETOOLONG);
214 213
215 lock_kernel();
216 ino = vxfs_inode_by_name(dip, dp); 214 ino = vxfs_inode_by_name(dip, dp);
217 if (ino) { 215 if (ino) {
218 ip = vxfs_iget(dip->i_sb, ino); 216 ip = vxfs_iget(dip->i_sb, ino);
219 if (IS_ERR(ip)) { 217 if (IS_ERR(ip))
220 unlock_kernel();
221 return ERR_CAST(ip); 218 return ERR_CAST(ip);
222 }
223 } 219 }
224 unlock_kernel();
225 d_add(dp, ip); 220 d_add(dp, ip);
226 return NULL; 221 return NULL;
227} 222}
@@ -248,8 +243,6 @@ vxfs_readdir(struct file *fp, void *retp, filldir_t filler)
248 u_long page, npages, block, pblocks, nblocks, offset; 243 u_long page, npages, block, pblocks, nblocks, offset;
249 loff_t pos; 244 loff_t pos;
250 245
251 lock_kernel();
252
253 switch ((long)fp->f_pos) { 246 switch ((long)fp->f_pos) {
254 case 0: 247 case 0:
255 if (filler(retp, ".", 1, fp->f_pos, ip->i_ino, DT_DIR) < 0) 248 if (filler(retp, ".", 1, fp->f_pos, ip->i_ino, DT_DIR) < 0)
@@ -265,10 +258,8 @@ vxfs_readdir(struct file *fp, void *retp, filldir_t filler)
265 258
266 pos = fp->f_pos - 2; 259 pos = fp->f_pos - 2;
267 260
268 if (pos > VXFS_DIRROUND(ip->i_size)) { 261 if (pos > VXFS_DIRROUND(ip->i_size))
269 unlock_kernel();
270 return 0; 262 return 0;
271 }
272 263
273 npages = dir_pages(ip); 264 npages = dir_pages(ip);
274 nblocks = dir_blocks(ip); 265 nblocks = dir_blocks(ip);
@@ -327,6 +318,5 @@ vxfs_readdir(struct file *fp, void *retp, filldir_t filler)
327done: 318done:
328 fp->f_pos = ((page << PAGE_CACHE_SHIFT) | offset) + 2; 319 fp->f_pos = ((page << PAGE_CACHE_SHIFT) | offset) + 2;
329out: 320out:
330 unlock_kernel();
331 return 0; 321 return 0;
332} 322}
diff --git a/fs/freevxfs/vxfs_super.c b/fs/freevxfs/vxfs_super.c
index dc0c041e85cb..71b0148b8784 100644
--- a/fs/freevxfs/vxfs_super.c
+++ b/fs/freevxfs/vxfs_super.c
@@ -38,7 +38,6 @@
38#include <linux/buffer_head.h> 38#include <linux/buffer_head.h>
39#include <linux/kernel.h> 39#include <linux/kernel.h>
40#include <linux/slab.h> 40#include <linux/slab.h>
41#include <linux/smp_lock.h>
42#include <linux/stat.h> 41#include <linux/stat.h>
43#include <linux/vfs.h> 42#include <linux/vfs.h>
44#include <linux/mount.h> 43#include <linux/mount.h>
@@ -81,16 +80,12 @@ vxfs_put_super(struct super_block *sbp)
81{ 80{
82 struct vxfs_sb_info *infp = VXFS_SBI(sbp); 81 struct vxfs_sb_info *infp = VXFS_SBI(sbp);
83 82
84 lock_kernel();
85
86 vxfs_put_fake_inode(infp->vsi_fship); 83 vxfs_put_fake_inode(infp->vsi_fship);
87 vxfs_put_fake_inode(infp->vsi_ilist); 84 vxfs_put_fake_inode(infp->vsi_ilist);
88 vxfs_put_fake_inode(infp->vsi_stilist); 85 vxfs_put_fake_inode(infp->vsi_stilist);
89 86
90 brelse(infp->vsi_bp); 87 brelse(infp->vsi_bp);
91 kfree(infp); 88 kfree(infp);
92
93 unlock_kernel();
94} 89}
95 90
96/** 91/**
@@ -148,7 +143,7 @@ static int vxfs_remount(struct super_block *sb, int *flags, char *data)
148 * The superblock on success, else %NULL. 143 * The superblock on success, else %NULL.
149 * 144 *
150 * Locking: 145 * Locking:
151 * We are under the bkl and @sbp->s_lock. 146 * We are under @sbp->s_lock.
152 */ 147 */
153static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent) 148static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent)
154{ 149{
diff --git a/fs/fuse/control.c b/fs/fuse/control.c
index 3773fd63d2f9..7367e177186f 100644
--- a/fs/fuse/control.c
+++ b/fs/fuse/control.c
@@ -179,23 +179,27 @@ static ssize_t fuse_conn_congestion_threshold_write(struct file *file,
179static const struct file_operations fuse_ctl_abort_ops = { 179static const struct file_operations fuse_ctl_abort_ops = {
180 .open = nonseekable_open, 180 .open = nonseekable_open,
181 .write = fuse_conn_abort_write, 181 .write = fuse_conn_abort_write,
182 .llseek = no_llseek,
182}; 183};
183 184
184static const struct file_operations fuse_ctl_waiting_ops = { 185static const struct file_operations fuse_ctl_waiting_ops = {
185 .open = nonseekable_open, 186 .open = nonseekable_open,
186 .read = fuse_conn_waiting_read, 187 .read = fuse_conn_waiting_read,
188 .llseek = no_llseek,
187}; 189};
188 190
189static const struct file_operations fuse_conn_max_background_ops = { 191static const struct file_operations fuse_conn_max_background_ops = {
190 .open = nonseekable_open, 192 .open = nonseekable_open,
191 .read = fuse_conn_max_background_read, 193 .read = fuse_conn_max_background_read,
192 .write = fuse_conn_max_background_write, 194 .write = fuse_conn_max_background_write,
195 .llseek = no_llseek,
193}; 196};
194 197
195static const struct file_operations fuse_conn_congestion_threshold_ops = { 198static const struct file_operations fuse_conn_congestion_threshold_ops = {
196 .open = nonseekable_open, 199 .open = nonseekable_open,
197 .read = fuse_conn_congestion_threshold_read, 200 .read = fuse_conn_congestion_threshold_read,
198 .write = fuse_conn_congestion_threshold_write, 201 .write = fuse_conn_congestion_threshold_write,
202 .llseek = no_llseek,
199}; 203};
200 204
201static struct dentry *fuse_ctl_add_dentry(struct dentry *parent, 205static struct dentry *fuse_ctl_add_dentry(struct dentry *parent,
diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
index e1f8171278bd..3e87cce5837d 100644
--- a/fs/fuse/cuse.c
+++ b/fs/fuse/cuse.c
@@ -182,6 +182,7 @@ static const struct file_operations cuse_frontend_fops = {
182 .unlocked_ioctl = cuse_file_ioctl, 182 .unlocked_ioctl = cuse_file_ioctl,
183 .compat_ioctl = cuse_file_compat_ioctl, 183 .compat_ioctl = cuse_file_compat_ioctl,
184 .poll = fuse_file_poll, 184 .poll = fuse_file_poll,
185 .llseek = noop_llseek,
185}; 186};
186 187
187 188
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index 237ee6a940df..aa996471ec5c 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -622,6 +622,8 @@ static ssize_t gfs2_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
622 * cluster; until we do, disable leases (by just returning -EINVAL), 622 * cluster; until we do, disable leases (by just returning -EINVAL),
623 * unless the administrator has requested purely local locking. 623 * unless the administrator has requested purely local locking.
624 * 624 *
625 * Locking: called under lock_flocks
626 *
625 * Returns: errno 627 * Returns: errno
626 */ 628 */
627 629
@@ -773,6 +775,7 @@ const struct file_operations gfs2_dir_fops = {
773 .fsync = gfs2_fsync, 775 .fsync = gfs2_fsync,
774 .lock = gfs2_lock, 776 .lock = gfs2_lock,
775 .flock = gfs2_flock, 777 .flock = gfs2_flock,
778 .llseek = default_llseek,
776}; 779};
777 780
778#endif /* CONFIG_GFS2_FS_LOCKING_DLM */ 781#endif /* CONFIG_GFS2_FS_LOCKING_DLM */
@@ -799,5 +802,6 @@ const struct file_operations gfs2_dir_fops_nolock = {
799 .open = gfs2_open, 802 .open = gfs2_open,
800 .release = gfs2_close, 803 .release = gfs2_close,
801 .fsync = gfs2_fsync, 804 .fsync = gfs2_fsync,
805 .llseek = default_llseek,
802}; 806};
803 807
diff --git a/fs/hfs/super.c b/fs/hfs/super.c
index 34235d4bf08b..33254160f650 100644
--- a/fs/hfs/super.c
+++ b/fs/hfs/super.c
@@ -20,7 +20,6 @@
20#include <linux/parser.h> 20#include <linux/parser.h>
21#include <linux/seq_file.h> 21#include <linux/seq_file.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/smp_lock.h>
24#include <linux/vfs.h> 23#include <linux/vfs.h>
25 24
26#include "hfs_fs.h" 25#include "hfs_fs.h"
@@ -79,15 +78,11 @@ static int hfs_sync_fs(struct super_block *sb, int wait)
79 */ 78 */
80static void hfs_put_super(struct super_block *sb) 79static void hfs_put_super(struct super_block *sb)
81{ 80{
82 lock_kernel();
83
84 if (sb->s_dirt) 81 if (sb->s_dirt)
85 hfs_write_super(sb); 82 hfs_write_super(sb);
86 hfs_mdb_close(sb); 83 hfs_mdb_close(sb);
87 /* release the MDB's resources */ 84 /* release the MDB's resources */
88 hfs_mdb_put(sb); 85 hfs_mdb_put(sb);
89
90 unlock_kernel();
91} 86}
92 87
93/* 88/*
@@ -385,6 +380,7 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent)
385 sbi = kzalloc(sizeof(struct hfs_sb_info), GFP_KERNEL); 380 sbi = kzalloc(sizeof(struct hfs_sb_info), GFP_KERNEL);
386 if (!sbi) 381 if (!sbi)
387 return -ENOMEM; 382 return -ENOMEM;
383
388 sb->s_fs_info = sbi; 384 sb->s_fs_info = sbi;
389 INIT_HLIST_HEAD(&sbi->rsrc_inodes); 385 INIT_HLIST_HEAD(&sbi->rsrc_inodes);
390 386
diff --git a/fs/hpfs/Kconfig b/fs/hpfs/Kconfig
index 56bd15c5bf6c..63b6f5632318 100644
--- a/fs/hpfs/Kconfig
+++ b/fs/hpfs/Kconfig
@@ -1,6 +1,7 @@
1config HPFS_FS 1config HPFS_FS
2 tristate "OS/2 HPFS file system support" 2 tristate "OS/2 HPFS file system support"
3 depends on BLOCK 3 depends on BLOCK
4 depends on BKL # nontrivial to fix
4 help 5 help
5 OS/2 is IBM's operating system for PC's, the same as Warp, and HPFS 6 OS/2 is IBM's operating system for PC's, the same as Warp, and HPFS
6 is the file system used for organizing files on OS/2 hard disk 7 is the file system used for organizing files on OS/2 hard disk
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c
index 2607010be2fe..c969a1aa163a 100644
--- a/fs/hpfs/super.c
+++ b/fs/hpfs/super.c
@@ -477,11 +477,15 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
477 477
478 int o; 478 int o;
479 479
480 lock_kernel();
481
480 save_mount_options(s, options); 482 save_mount_options(s, options);
481 483
482 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); 484 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
483 if (!sbi) 485 if (!sbi) {
486 unlock_kernel();
484 return -ENOMEM; 487 return -ENOMEM;
488 }
485 s->s_fs_info = sbi; 489 s->s_fs_info = sbi;
486 490
487 sbi->sb_bmp_dir = NULL; 491 sbi->sb_bmp_dir = NULL;
@@ -666,6 +670,7 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
666 root->i_blocks = 5; 670 root->i_blocks = 5;
667 hpfs_brelse4(&qbh); 671 hpfs_brelse4(&qbh);
668 } 672 }
673 unlock_kernel();
669 return 0; 674 return 0;
670 675
671bail4: brelse(bh2); 676bail4: brelse(bh2);
@@ -677,6 +682,7 @@ bail0:
677 kfree(sbi->sb_cp_table); 682 kfree(sbi->sb_cp_table);
678 s->s_fs_info = NULL; 683 s->s_fs_info = NULL;
679 kfree(sbi); 684 kfree(sbi);
685 unlock_kernel();
680 return -EINVAL; 686 return -EINVAL;
681} 687}
682 688
diff --git a/fs/hppfs/hppfs.c b/fs/hppfs/hppfs.c
index 7b027720d820..4e2a45ea6140 100644
--- a/fs/hppfs/hppfs.c
+++ b/fs/hppfs/hppfs.c
@@ -598,6 +598,7 @@ static const struct file_operations hppfs_dir_fops = {
598 .readdir = hppfs_readdir, 598 .readdir = hppfs_readdir,
599 .open = hppfs_dir_open, 599 .open = hppfs_dir_open,
600 .fsync = hppfs_fsync, 600 .fsync = hppfs_fsync,
601 .llseek = default_llseek,
601}; 602};
602 603
603static int hppfs_statfs(struct dentry *dentry, struct kstatfs *sf) 604static int hppfs_statfs(struct dentry *dentry, struct kstatfs *sf)
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 6e5bd42f3860..113eba3d3c38 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -674,6 +674,7 @@ const struct file_operations hugetlbfs_file_operations = {
674 .mmap = hugetlbfs_file_mmap, 674 .mmap = hugetlbfs_file_mmap,
675 .fsync = noop_fsync, 675 .fsync = noop_fsync,
676 .get_unmapped_area = hugetlb_get_unmapped_area, 676 .get_unmapped_area = hugetlb_get_unmapped_area,
677 .llseek = default_llseek,
677}; 678};
678 679
679static const struct inode_operations hugetlbfs_dir_inode_operations = { 680static const struct inode_operations hugetlbfs_dir_inode_operations = {
diff --git a/fs/isofs/dir.c b/fs/isofs/dir.c
index e0aca9a0ac68..0542b6eedf80 100644
--- a/fs/isofs/dir.c
+++ b/fs/isofs/dir.c
@@ -10,7 +10,6 @@
10 * 10 *
11 * isofs directory handling functions 11 * isofs directory handling functions
12 */ 12 */
13#include <linux/smp_lock.h>
14#include <linux/gfp.h> 13#include <linux/gfp.h>
15#include "isofs.h" 14#include "isofs.h"
16 15
@@ -255,18 +254,19 @@ static int isofs_readdir(struct file *filp,
255 char *tmpname; 254 char *tmpname;
256 struct iso_directory_record *tmpde; 255 struct iso_directory_record *tmpde;
257 struct inode *inode = filp->f_path.dentry->d_inode; 256 struct inode *inode = filp->f_path.dentry->d_inode;
257 struct isofs_sb_info *sbi = ISOFS_SB(inode->i_sb);
258 258
259 tmpname = (char *)__get_free_page(GFP_KERNEL); 259 tmpname = (char *)__get_free_page(GFP_KERNEL);
260 if (tmpname == NULL) 260 if (tmpname == NULL)
261 return -ENOMEM; 261 return -ENOMEM;
262 262
263 lock_kernel(); 263 mutex_lock(&sbi->s_mutex);
264 tmpde = (struct iso_directory_record *) (tmpname+1024); 264 tmpde = (struct iso_directory_record *) (tmpname+1024);
265 265
266 result = do_isofs_readdir(inode, filp, dirent, filldir, tmpname, tmpde); 266 result = do_isofs_readdir(inode, filp, dirent, filldir, tmpname, tmpde);
267 267
268 free_page((unsigned long) tmpname); 268 free_page((unsigned long) tmpname);
269 unlock_kernel(); 269 mutex_unlock(&sbi->s_mutex);
270 return result; 270 return result;
271} 271}
272 272
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index 5a44811b5027..09ff41a752a0 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -17,7 +17,6 @@
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <linux/nls.h> 18#include <linux/nls.h>
19#include <linux/ctype.h> 19#include <linux/ctype.h>
20#include <linux/smp_lock.h>
21#include <linux/statfs.h> 20#include <linux/statfs.h>
22#include <linux/cdrom.h> 21#include <linux/cdrom.h>
23#include <linux/parser.h> 22#include <linux/parser.h>
@@ -44,11 +43,7 @@ static void isofs_put_super(struct super_block *sb)
44 struct isofs_sb_info *sbi = ISOFS_SB(sb); 43 struct isofs_sb_info *sbi = ISOFS_SB(sb);
45 44
46#ifdef CONFIG_JOLIET 45#ifdef CONFIG_JOLIET
47 lock_kernel();
48
49 unload_nls(sbi->s_nls_iocharset); 46 unload_nls(sbi->s_nls_iocharset);
50
51 unlock_kernel();
52#endif 47#endif
53 48
54 kfree(sbi); 49 kfree(sbi);
@@ -823,6 +818,7 @@ root_found:
823 sbi->s_utf8 = opt.utf8; 818 sbi->s_utf8 = opt.utf8;
824 sbi->s_nocompress = opt.nocompress; 819 sbi->s_nocompress = opt.nocompress;
825 sbi->s_overriderockperm = opt.overriderockperm; 820 sbi->s_overriderockperm = opt.overriderockperm;
821 mutex_init(&sbi->s_mutex);
826 /* 822 /*
827 * It would be incredibly stupid to allow people to mark every file 823 * It would be incredibly stupid to allow people to mark every file
828 * on the disk as suid, so we merely allow them to set the default 824 * on the disk as suid, so we merely allow them to set the default
@@ -977,8 +973,6 @@ int isofs_get_blocks(struct inode *inode, sector_t iblock_s,
977 int section, rv, error; 973 int section, rv, error;
978 struct iso_inode_info *ei = ISOFS_I(inode); 974 struct iso_inode_info *ei = ISOFS_I(inode);
979 975
980 lock_kernel();
981
982 error = -EIO; 976 error = -EIO;
983 rv = 0; 977 rv = 0;
984 if (iblock < 0 || iblock != iblock_s) { 978 if (iblock < 0 || iblock != iblock_s) {
@@ -1054,7 +1048,6 @@ int isofs_get_blocks(struct inode *inode, sector_t iblock_s,
1054 1048
1055 error = 0; 1049 error = 0;
1056abort: 1050abort:
1057 unlock_kernel();
1058 return rv != 0 ? rv : error; 1051 return rv != 0 ? rv : error;
1059} 1052}
1060 1053
diff --git a/fs/isofs/isofs.h b/fs/isofs/isofs.h
index 7d33de84f52a..2882dc089f87 100644
--- a/fs/isofs/isofs.h
+++ b/fs/isofs/isofs.h
@@ -55,6 +55,7 @@ struct isofs_sb_info {
55 gid_t s_gid; 55 gid_t s_gid;
56 uid_t s_uid; 56 uid_t s_uid;
57 struct nls_table *s_nls_iocharset; /* Native language support table */ 57 struct nls_table *s_nls_iocharset; /* Native language support table */
58 struct mutex s_mutex; /* replaces BKL, please remove if possible */
58}; 59};
59 60
60#define ISOFS_INVALID_MODE ((mode_t) -1) 61#define ISOFS_INVALID_MODE ((mode_t) -1)
diff --git a/fs/isofs/namei.c b/fs/isofs/namei.c
index ab438beb867c..0d23abfd4280 100644
--- a/fs/isofs/namei.c
+++ b/fs/isofs/namei.c
@@ -6,7 +6,6 @@
6 * (C) 1991 Linus Torvalds - minix filesystem 6 * (C) 1991 Linus Torvalds - minix filesystem
7 */ 7 */
8 8
9#include <linux/smp_lock.h>
10#include <linux/gfp.h> 9#include <linux/gfp.h>
11#include "isofs.h" 10#include "isofs.h"
12 11
@@ -168,6 +167,7 @@ struct dentry *isofs_lookup(struct inode *dir, struct dentry *dentry, struct nam
168 int found; 167 int found;
169 unsigned long uninitialized_var(block); 168 unsigned long uninitialized_var(block);
170 unsigned long uninitialized_var(offset); 169 unsigned long uninitialized_var(offset);
170 struct isofs_sb_info *sbi = ISOFS_SB(dir->i_sb);
171 struct inode *inode; 171 struct inode *inode;
172 struct page *page; 172 struct page *page;
173 173
@@ -177,7 +177,7 @@ struct dentry *isofs_lookup(struct inode *dir, struct dentry *dentry, struct nam
177 if (!page) 177 if (!page)
178 return ERR_PTR(-ENOMEM); 178 return ERR_PTR(-ENOMEM);
179 179
180 lock_kernel(); 180 mutex_lock(&sbi->s_mutex);
181 found = isofs_find_entry(dir, dentry, 181 found = isofs_find_entry(dir, dentry,
182 &block, &offset, 182 &block, &offset,
183 page_address(page), 183 page_address(page),
@@ -188,10 +188,10 @@ struct dentry *isofs_lookup(struct inode *dir, struct dentry *dentry, struct nam
188 if (found) { 188 if (found) {
189 inode = isofs_iget(dir->i_sb, block, offset); 189 inode = isofs_iget(dir->i_sb, block, offset);
190 if (IS_ERR(inode)) { 190 if (IS_ERR(inode)) {
191 unlock_kernel(); 191 mutex_unlock(&sbi->s_mutex);
192 return ERR_CAST(inode); 192 return ERR_CAST(inode);
193 } 193 }
194 } 194 }
195 unlock_kernel(); 195 mutex_unlock(&sbi->s_mutex);
196 return d_splice_alias(inode, dentry); 196 return d_splice_alias(inode, dentry);
197} 197}
diff --git a/fs/isofs/rock.c b/fs/isofs/rock.c
index 96a685c550fd..f9cd04db6eab 100644
--- a/fs/isofs/rock.c
+++ b/fs/isofs/rock.c
@@ -8,7 +8,6 @@
8 8
9#include <linux/slab.h> 9#include <linux/slab.h>
10#include <linux/pagemap.h> 10#include <linux/pagemap.h>
11#include <linux/smp_lock.h>
12 11
13#include "isofs.h" 12#include "isofs.h"
14#include "rock.h" 13#include "rock.h"
@@ -661,6 +660,7 @@ static int rock_ridge_symlink_readpage(struct file *file, struct page *page)
661{ 660{
662 struct inode *inode = page->mapping->host; 661 struct inode *inode = page->mapping->host;
663 struct iso_inode_info *ei = ISOFS_I(inode); 662 struct iso_inode_info *ei = ISOFS_I(inode);
663 struct isofs_sb_info *sbi = ISOFS_SB(inode->i_sb);
664 char *link = kmap(page); 664 char *link = kmap(page);
665 unsigned long bufsize = ISOFS_BUFFER_SIZE(inode); 665 unsigned long bufsize = ISOFS_BUFFER_SIZE(inode);
666 struct buffer_head *bh; 666 struct buffer_head *bh;
@@ -673,12 +673,12 @@ static int rock_ridge_symlink_readpage(struct file *file, struct page *page)
673 struct rock_state rs; 673 struct rock_state rs;
674 int ret; 674 int ret;
675 675
676 if (!ISOFS_SB(inode->i_sb)->s_rock) 676 if (!sbi->s_rock)
677 goto error; 677 goto error;
678 678
679 init_rock_state(&rs, inode); 679 init_rock_state(&rs, inode);
680 block = ei->i_iget5_block; 680 block = ei->i_iget5_block;
681 lock_kernel(); 681 mutex_lock(&sbi->s_mutex);
682 bh = sb_bread(inode->i_sb, block); 682 bh = sb_bread(inode->i_sb, block);
683 if (!bh) 683 if (!bh)
684 goto out_noread; 684 goto out_noread;
@@ -748,7 +748,7 @@ repeat:
748 goto fail; 748 goto fail;
749 brelse(bh); 749 brelse(bh);
750 *rpnt = '\0'; 750 *rpnt = '\0';
751 unlock_kernel(); 751 mutex_unlock(&sbi->s_mutex);
752 SetPageUptodate(page); 752 SetPageUptodate(page);
753 kunmap(page); 753 kunmap(page);
754 unlock_page(page); 754 unlock_page(page);
@@ -765,7 +765,7 @@ out_bad_span:
765 printk("symlink spans iso9660 blocks\n"); 765 printk("symlink spans iso9660 blocks\n");
766fail: 766fail:
767 brelse(bh); 767 brelse(bh);
768 unlock_kernel(); 768 mutex_unlock(&sbi->s_mutex);
769error: 769error:
770 SetPageError(page); 770 SetPageError(page);
771 kunmap(page); 771 kunmap(page);
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index 6b2964a19850..d9beb06e6fca 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -21,7 +21,6 @@
21#include <linux/vmalloc.h> 21#include <linux/vmalloc.h>
22#include <linux/vfs.h> 22#include <linux/vfs.h>
23#include <linux/crc32.h> 23#include <linux/crc32.h>
24#include <linux/smp_lock.h>
25#include "nodelist.h" 24#include "nodelist.h"
26 25
27static int jffs2_flash_setup(struct jffs2_sb_info *c); 26static int jffs2_flash_setup(struct jffs2_sb_info *c);
@@ -391,7 +390,6 @@ int jffs2_remount_fs (struct super_block *sb, int *flags, char *data)
391 This also catches the case where it was stopped and this 390 This also catches the case where it was stopped and this
392 is just a remount to restart it. 391 is just a remount to restart it.
393 Flush the writebuffer, if neccecary, else we loose it */ 392 Flush the writebuffer, if neccecary, else we loose it */
394 lock_kernel();
395 if (!(sb->s_flags & MS_RDONLY)) { 393 if (!(sb->s_flags & MS_RDONLY)) {
396 jffs2_stop_garbage_collect_thread(c); 394 jffs2_stop_garbage_collect_thread(c);
397 mutex_lock(&c->alloc_sem); 395 mutex_lock(&c->alloc_sem);
@@ -403,8 +401,6 @@ int jffs2_remount_fs (struct super_block *sb, int *flags, char *data)
403 jffs2_start_garbage_collect_thread(c); 401 jffs2_start_garbage_collect_thread(c);
404 402
405 *flags |= MS_NOATIME; 403 *flags |= MS_NOATIME;
406
407 unlock_kernel();
408 return 0; 404 return 0;
409} 405}
410 406
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
index 662bba099501..d1ae5dfc22b9 100644
--- a/fs/jffs2/super.c
+++ b/fs/jffs2/super.c
@@ -12,7 +12,6 @@
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/slab.h> 14#include <linux/slab.h>
15#include <linux/smp_lock.h>
16#include <linux/init.h> 15#include <linux/init.h>
17#include <linux/list.h> 16#include <linux/list.h>
18#include <linux/fs.h> 17#include <linux/fs.h>
@@ -146,6 +145,7 @@ static const struct super_operations jffs2_super_operations =
146static int jffs2_fill_super(struct super_block *sb, void *data, int silent) 145static int jffs2_fill_super(struct super_block *sb, void *data, int silent)
147{ 146{
148 struct jffs2_sb_info *c; 147 struct jffs2_sb_info *c;
148 int ret;
149 149
150 D1(printk(KERN_DEBUG "jffs2_get_sb_mtd():" 150 D1(printk(KERN_DEBUG "jffs2_get_sb_mtd():"
151 " New superblock for device %d (\"%s\")\n", 151 " New superblock for device %d (\"%s\")\n",
@@ -175,7 +175,8 @@ static int jffs2_fill_super(struct super_block *sb, void *data, int silent)
175#ifdef CONFIG_JFFS2_FS_POSIX_ACL 175#ifdef CONFIG_JFFS2_FS_POSIX_ACL
176 sb->s_flags |= MS_POSIXACL; 176 sb->s_flags |= MS_POSIXACL;
177#endif 177#endif
178 return jffs2_do_fill_super(sb, data, silent); 178 ret = jffs2_do_fill_super(sb, data, silent);
179 return ret;
179} 180}
180 181
181static int jffs2_get_sb(struct file_system_type *fs_type, 182static int jffs2_get_sb(struct file_system_type *fs_type,
@@ -192,8 +193,6 @@ static void jffs2_put_super (struct super_block *sb)
192 193
193 D2(printk(KERN_DEBUG "jffs2: jffs2_put_super()\n")); 194 D2(printk(KERN_DEBUG "jffs2: jffs2_put_super()\n"));
194 195
195 lock_kernel();
196
197 if (sb->s_dirt) 196 if (sb->s_dirt)
198 jffs2_write_super(sb); 197 jffs2_write_super(sb);
199 198
@@ -215,8 +214,6 @@ static void jffs2_put_super (struct super_block *sb)
215 if (c->mtd->sync) 214 if (c->mtd->sync)
216 c->mtd->sync(c->mtd); 215 c->mtd->sync(c->mtd);
217 216
218 unlock_kernel();
219
220 D1(printk(KERN_DEBUG "jffs2_put_super returning\n")); 217 D1(printk(KERN_DEBUG "jffs2_put_super returning\n"));
221} 218}
222 219
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index ec8c3e4baca3..68eee2bf629e 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -33,7 +33,6 @@
33#include <linux/slab.h> 33#include <linux/slab.h>
34#include <asm/uaccess.h> 34#include <asm/uaccess.h>
35#include <linux/seq_file.h> 35#include <linux/seq_file.h>
36#include <linux/smp_lock.h>
37 36
38#include "jfs_incore.h" 37#include "jfs_incore.h"
39#include "jfs_filsys.h" 38#include "jfs_filsys.h"
@@ -176,8 +175,6 @@ static void jfs_put_super(struct super_block *sb)
176 175
177 dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); 176 dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED);
178 177
179 lock_kernel();
180
181 rc = jfs_umount(sb); 178 rc = jfs_umount(sb);
182 if (rc) 179 if (rc)
183 jfs_err("jfs_umount failed with return code %d", rc); 180 jfs_err("jfs_umount failed with return code %d", rc);
@@ -188,8 +185,6 @@ static void jfs_put_super(struct super_block *sb)
188 iput(sbi->direct_inode); 185 iput(sbi->direct_inode);
189 186
190 kfree(sbi); 187 kfree(sbi);
191
192 unlock_kernel();
193} 188}
194 189
195enum { 190enum {
@@ -369,19 +364,16 @@ static int jfs_remount(struct super_block *sb, int *flags, char *data)
369 if (!parse_options(data, sb, &newLVSize, &flag)) { 364 if (!parse_options(data, sb, &newLVSize, &flag)) {
370 return -EINVAL; 365 return -EINVAL;
371 } 366 }
372 lock_kernel(); 367
373 if (newLVSize) { 368 if (newLVSize) {
374 if (sb->s_flags & MS_RDONLY) { 369 if (sb->s_flags & MS_RDONLY) {
375 printk(KERN_ERR 370 printk(KERN_ERR
376 "JFS: resize requires volume to be mounted read-write\n"); 371 "JFS: resize requires volume to be mounted read-write\n");
377 unlock_kernel();
378 return -EROFS; 372 return -EROFS;
379 } 373 }
380 rc = jfs_extendfs(sb, newLVSize, 0); 374 rc = jfs_extendfs(sb, newLVSize, 0);
381 if (rc) { 375 if (rc)
382 unlock_kernel();
383 return rc; 376 return rc;
384 }
385 } 377 }
386 378
387 if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) { 379 if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) {
@@ -397,36 +389,30 @@ static int jfs_remount(struct super_block *sb, int *flags, char *data)
397 /* mark the fs r/w for quota activity */ 389 /* mark the fs r/w for quota activity */
398 sb->s_flags &= ~MS_RDONLY; 390 sb->s_flags &= ~MS_RDONLY;
399 391
400 unlock_kernel();
401 dquot_resume(sb, -1); 392 dquot_resume(sb, -1);
402 return ret; 393 return ret;
403 } 394 }
404 if ((!(sb->s_flags & MS_RDONLY)) && (*flags & MS_RDONLY)) { 395 if ((!(sb->s_flags & MS_RDONLY)) && (*flags & MS_RDONLY)) {
405 rc = dquot_suspend(sb, -1); 396 rc = dquot_suspend(sb, -1);
406 if (rc < 0) { 397 if (rc < 0) {
407 unlock_kernel();
408 return rc; 398 return rc;
409 } 399 }
410 rc = jfs_umount_rw(sb); 400 rc = jfs_umount_rw(sb);
411 JFS_SBI(sb)->flag = flag; 401 JFS_SBI(sb)->flag = flag;
412 unlock_kernel();
413 return rc; 402 return rc;
414 } 403 }
415 if ((JFS_SBI(sb)->flag & JFS_NOINTEGRITY) != (flag & JFS_NOINTEGRITY)) 404 if ((JFS_SBI(sb)->flag & JFS_NOINTEGRITY) != (flag & JFS_NOINTEGRITY))
416 if (!(sb->s_flags & MS_RDONLY)) { 405 if (!(sb->s_flags & MS_RDONLY)) {
417 rc = jfs_umount_rw(sb); 406 rc = jfs_umount_rw(sb);
418 if (rc) { 407 if (rc)
419 unlock_kernel();
420 return rc; 408 return rc;
421 } 409
422 JFS_SBI(sb)->flag = flag; 410 JFS_SBI(sb)->flag = flag;
423 ret = jfs_mount_rw(sb, 1); 411 ret = jfs_mount_rw(sb, 1);
424 unlock_kernel();
425 return ret; 412 return ret;
426 } 413 }
427 JFS_SBI(sb)->flag = flag; 414 JFS_SBI(sb)->flag = flag;
428 415
429 unlock_kernel();
430 return 0; 416 return 0;
431} 417}
432 418
@@ -446,6 +432,7 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent)
446 sbi = kzalloc(sizeof (struct jfs_sb_info), GFP_KERNEL); 432 sbi = kzalloc(sizeof (struct jfs_sb_info), GFP_KERNEL);
447 if (!sbi) 433 if (!sbi)
448 return -ENOMEM; 434 return -ENOMEM;
435
449 sb->s_fs_info = sbi; 436 sb->s_fs_info = sbi;
450 sbi->sb = sb; 437 sbi->sb = sb;
451 sbi->uid = sbi->gid = sbi->umask = -1; 438 sbi->uid = sbi->gid = sbi->umask = -1;
diff --git a/fs/locks.c b/fs/locks.c
index ab24d49fc048..8b2b6ad56a09 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -143,6 +143,22 @@ int lease_break_time = 45;
143static LIST_HEAD(file_lock_list); 143static LIST_HEAD(file_lock_list);
144static LIST_HEAD(blocked_list); 144static LIST_HEAD(blocked_list);
145 145
146/*
147 * Protects the two list heads above, plus the inode->i_flock list
148 * FIXME: should use a spinlock, once lockd and ceph are ready.
149 */
150void lock_flocks(void)
151{
152 lock_kernel();
153}
154EXPORT_SYMBOL_GPL(lock_flocks);
155
156void unlock_flocks(void)
157{
158 unlock_kernel();
159}
160EXPORT_SYMBOL_GPL(unlock_flocks);
161
146static struct kmem_cache *filelock_cache __read_mostly; 162static struct kmem_cache *filelock_cache __read_mostly;
147 163
148/* Allocate an empty lock structure. */ 164/* Allocate an empty lock structure. */
@@ -511,9 +527,9 @@ static void __locks_delete_block(struct file_lock *waiter)
511 */ 527 */
512static void locks_delete_block(struct file_lock *waiter) 528static void locks_delete_block(struct file_lock *waiter)
513{ 529{
514 lock_kernel(); 530 lock_flocks();
515 __locks_delete_block(waiter); 531 __locks_delete_block(waiter);
516 unlock_kernel(); 532 unlock_flocks();
517} 533}
518 534
519/* Insert waiter into blocker's block list. 535/* Insert waiter into blocker's block list.
@@ -644,7 +660,7 @@ posix_test_lock(struct file *filp, struct file_lock *fl)
644{ 660{
645 struct file_lock *cfl; 661 struct file_lock *cfl;
646 662
647 lock_kernel(); 663 lock_flocks();
648 for (cfl = filp->f_path.dentry->d_inode->i_flock; cfl; cfl = cfl->fl_next) { 664 for (cfl = filp->f_path.dentry->d_inode->i_flock; cfl; cfl = cfl->fl_next) {
649 if (!IS_POSIX(cfl)) 665 if (!IS_POSIX(cfl))
650 continue; 666 continue;
@@ -657,7 +673,7 @@ posix_test_lock(struct file *filp, struct file_lock *fl)
657 fl->fl_pid = pid_vnr(cfl->fl_nspid); 673 fl->fl_pid = pid_vnr(cfl->fl_nspid);
658 } else 674 } else
659 fl->fl_type = F_UNLCK; 675 fl->fl_type = F_UNLCK;
660 unlock_kernel(); 676 unlock_flocks();
661 return; 677 return;
662} 678}
663EXPORT_SYMBOL(posix_test_lock); 679EXPORT_SYMBOL(posix_test_lock);
@@ -730,18 +746,16 @@ static int flock_lock_file(struct file *filp, struct file_lock *request)
730 int error = 0; 746 int error = 0;
731 int found = 0; 747 int found = 0;
732 748
733 lock_kernel(); 749 if (!(request->fl_flags & FL_ACCESS) && (request->fl_type != F_UNLCK)) {
734 if (request->fl_flags & FL_ACCESS)
735 goto find_conflict;
736
737 if (request->fl_type != F_UNLCK) {
738 error = -ENOMEM;
739 new_fl = locks_alloc_lock(); 750 new_fl = locks_alloc_lock();
740 if (new_fl == NULL) 751 if (!new_fl)
741 goto out; 752 return -ENOMEM;
742 error = 0;
743 } 753 }
744 754
755 lock_flocks();
756 if (request->fl_flags & FL_ACCESS)
757 goto find_conflict;
758
745 for_each_lock(inode, before) { 759 for_each_lock(inode, before) {
746 struct file_lock *fl = *before; 760 struct file_lock *fl = *before;
747 if (IS_POSIX(fl)) 761 if (IS_POSIX(fl))
@@ -767,8 +781,11 @@ static int flock_lock_file(struct file *filp, struct file_lock *request)
767 * If a higher-priority process was blocked on the old file lock, 781 * If a higher-priority process was blocked on the old file lock,
768 * give it the opportunity to lock the file. 782 * give it the opportunity to lock the file.
769 */ 783 */
770 if (found) 784 if (found) {
785 unlock_flocks();
771 cond_resched(); 786 cond_resched();
787 lock_flocks();
788 }
772 789
773find_conflict: 790find_conflict:
774 for_each_lock(inode, before) { 791 for_each_lock(inode, before) {
@@ -794,7 +811,7 @@ find_conflict:
794 error = 0; 811 error = 0;
795 812
796out: 813out:
797 unlock_kernel(); 814 unlock_flocks();
798 if (new_fl) 815 if (new_fl)
799 locks_free_lock(new_fl); 816 locks_free_lock(new_fl);
800 return error; 817 return error;
@@ -823,7 +840,7 @@ static int __posix_lock_file(struct inode *inode, struct file_lock *request, str
823 new_fl2 = locks_alloc_lock(); 840 new_fl2 = locks_alloc_lock();
824 } 841 }
825 842
826 lock_kernel(); 843 lock_flocks();
827 if (request->fl_type != F_UNLCK) { 844 if (request->fl_type != F_UNLCK) {
828 for_each_lock(inode, before) { 845 for_each_lock(inode, before) {
829 fl = *before; 846 fl = *before;
@@ -991,7 +1008,7 @@ static int __posix_lock_file(struct inode *inode, struct file_lock *request, str
991 locks_wake_up_blocks(left); 1008 locks_wake_up_blocks(left);
992 } 1009 }
993 out: 1010 out:
994 unlock_kernel(); 1011 unlock_flocks();
995 /* 1012 /*
996 * Free any unused locks. 1013 * Free any unused locks.
997 */ 1014 */
@@ -1066,14 +1083,14 @@ int locks_mandatory_locked(struct inode *inode)
1066 /* 1083 /*
1067 * Search the lock list for this inode for any POSIX locks. 1084 * Search the lock list for this inode for any POSIX locks.
1068 */ 1085 */
1069 lock_kernel(); 1086 lock_flocks();
1070 for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) { 1087 for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) {
1071 if (!IS_POSIX(fl)) 1088 if (!IS_POSIX(fl))
1072 continue; 1089 continue;
1073 if (fl->fl_owner != owner) 1090 if (fl->fl_owner != owner)
1074 break; 1091 break;
1075 } 1092 }
1076 unlock_kernel(); 1093 unlock_flocks();
1077 return fl ? -EAGAIN : 0; 1094 return fl ? -EAGAIN : 0;
1078} 1095}
1079 1096
@@ -1186,7 +1203,7 @@ int __break_lease(struct inode *inode, unsigned int mode)
1186 1203
1187 new_fl = lease_alloc(NULL, want_write ? F_WRLCK : F_RDLCK); 1204 new_fl = lease_alloc(NULL, want_write ? F_WRLCK : F_RDLCK);
1188 1205
1189 lock_kernel(); 1206 lock_flocks();
1190 1207
1191 time_out_leases(inode); 1208 time_out_leases(inode);
1192 1209
@@ -1247,8 +1264,10 @@ restart:
1247 break_time++; 1264 break_time++;
1248 } 1265 }
1249 locks_insert_block(flock, new_fl); 1266 locks_insert_block(flock, new_fl);
1267 unlock_flocks();
1250 error = wait_event_interruptible_timeout(new_fl->fl_wait, 1268 error = wait_event_interruptible_timeout(new_fl->fl_wait,
1251 !new_fl->fl_next, break_time); 1269 !new_fl->fl_next, break_time);
1270 lock_flocks();
1252 __locks_delete_block(new_fl); 1271 __locks_delete_block(new_fl);
1253 if (error >= 0) { 1272 if (error >= 0) {
1254 if (error == 0) 1273 if (error == 0)
@@ -1263,7 +1282,7 @@ restart:
1263 } 1282 }
1264 1283
1265out: 1284out:
1266 unlock_kernel(); 1285 unlock_flocks();
1267 if (!IS_ERR(new_fl)) 1286 if (!IS_ERR(new_fl))
1268 locks_free_lock(new_fl); 1287 locks_free_lock(new_fl);
1269 return error; 1288 return error;
@@ -1319,7 +1338,7 @@ int fcntl_getlease(struct file *filp)
1319 struct file_lock *fl; 1338 struct file_lock *fl;
1320 int type = F_UNLCK; 1339 int type = F_UNLCK;
1321 1340
1322 lock_kernel(); 1341 lock_flocks();
1323 time_out_leases(filp->f_path.dentry->d_inode); 1342 time_out_leases(filp->f_path.dentry->d_inode);
1324 for (fl = filp->f_path.dentry->d_inode->i_flock; fl && IS_LEASE(fl); 1343 for (fl = filp->f_path.dentry->d_inode->i_flock; fl && IS_LEASE(fl);
1325 fl = fl->fl_next) { 1344 fl = fl->fl_next) {
@@ -1328,7 +1347,7 @@ int fcntl_getlease(struct file *filp)
1328 break; 1347 break;
1329 } 1348 }
1330 } 1349 }
1331 unlock_kernel(); 1350 unlock_flocks();
1332 return type; 1351 return type;
1333} 1352}
1334 1353
@@ -1341,7 +1360,7 @@ int fcntl_getlease(struct file *filp)
1341 * The (input) flp->fl_lmops->fl_break function is required 1360 * The (input) flp->fl_lmops->fl_break function is required
1342 * by break_lease(). 1361 * by break_lease().
1343 * 1362 *
1344 * Called with kernel lock held. 1363 * Called with file_lock_lock held.
1345 */ 1364 */
1346int generic_setlease(struct file *filp, long arg, struct file_lock **flp) 1365int generic_setlease(struct file *filp, long arg, struct file_lock **flp)
1347{ 1366{
@@ -1436,7 +1455,15 @@ out:
1436} 1455}
1437EXPORT_SYMBOL(generic_setlease); 1456EXPORT_SYMBOL(generic_setlease);
1438 1457
1439 /** 1458static int __vfs_setlease(struct file *filp, long arg, struct file_lock **lease)
1459{
1460 if (filp->f_op && filp->f_op->setlease)
1461 return filp->f_op->setlease(filp, arg, lease);
1462 else
1463 return generic_setlease(filp, arg, lease);
1464}
1465
1466/**
1440 * vfs_setlease - sets a lease on an open file 1467 * vfs_setlease - sets a lease on an open file
1441 * @filp: file pointer 1468 * @filp: file pointer
1442 * @arg: type of lease to obtain 1469 * @arg: type of lease to obtain
@@ -1467,12 +1494,9 @@ int vfs_setlease(struct file *filp, long arg, struct file_lock **lease)
1467{ 1494{
1468 int error; 1495 int error;
1469 1496
1470 lock_kernel(); 1497 lock_flocks();
1471 if (filp->f_op && filp->f_op->setlease) 1498 error = __vfs_setlease(filp, arg, lease);
1472 error = filp->f_op->setlease(filp, arg, lease); 1499 unlock_flocks();
1473 else
1474 error = generic_setlease(filp, arg, lease);
1475 unlock_kernel();
1476 1500
1477 return error; 1501 return error;
1478} 1502}
@@ -1499,9 +1523,9 @@ int fcntl_setlease(unsigned int fd, struct file *filp, long arg)
1499 if (error) 1523 if (error)
1500 return error; 1524 return error;
1501 1525
1502 lock_kernel(); 1526 lock_flocks();
1503 1527
1504 error = vfs_setlease(filp, arg, &flp); 1528 error = __vfs_setlease(filp, arg, &flp);
1505 if (error || arg == F_UNLCK) 1529 if (error || arg == F_UNLCK)
1506 goto out_unlock; 1530 goto out_unlock;
1507 1531
@@ -1516,7 +1540,7 @@ int fcntl_setlease(unsigned int fd, struct file *filp, long arg)
1516 1540
1517 error = __f_setown(filp, task_pid(current), PIDTYPE_PID, 0); 1541 error = __f_setown(filp, task_pid(current), PIDTYPE_PID, 0);
1518out_unlock: 1542out_unlock:
1519 unlock_kernel(); 1543 unlock_flocks();
1520 return error; 1544 return error;
1521} 1545}
1522 1546
@@ -2020,7 +2044,7 @@ void locks_remove_flock(struct file *filp)
2020 fl.fl_ops->fl_release_private(&fl); 2044 fl.fl_ops->fl_release_private(&fl);
2021 } 2045 }
2022 2046
2023 lock_kernel(); 2047 lock_flocks();
2024 before = &inode->i_flock; 2048 before = &inode->i_flock;
2025 2049
2026 while ((fl = *before) != NULL) { 2050 while ((fl = *before) != NULL) {
@@ -2038,7 +2062,7 @@ void locks_remove_flock(struct file *filp)
2038 } 2062 }
2039 before = &fl->fl_next; 2063 before = &fl->fl_next;
2040 } 2064 }
2041 unlock_kernel(); 2065 unlock_flocks();
2042} 2066}
2043 2067
2044/** 2068/**
@@ -2053,12 +2077,12 @@ posix_unblock_lock(struct file *filp, struct file_lock *waiter)
2053{ 2077{
2054 int status = 0; 2078 int status = 0;
2055 2079
2056 lock_kernel(); 2080 lock_flocks();
2057 if (waiter->fl_next) 2081 if (waiter->fl_next)
2058 __locks_delete_block(waiter); 2082 __locks_delete_block(waiter);
2059 else 2083 else
2060 status = -ENOENT; 2084 status = -ENOENT;
2061 unlock_kernel(); 2085 unlock_flocks();
2062 return status; 2086 return status;
2063} 2087}
2064 2088
@@ -2172,7 +2196,7 @@ static int locks_show(struct seq_file *f, void *v)
2172 2196
2173static void *locks_start(struct seq_file *f, loff_t *pos) 2197static void *locks_start(struct seq_file *f, loff_t *pos)
2174{ 2198{
2175 lock_kernel(); 2199 lock_flocks();
2176 f->private = (void *)1; 2200 f->private = (void *)1;
2177 return seq_list_start(&file_lock_list, *pos); 2201 return seq_list_start(&file_lock_list, *pos);
2178} 2202}
@@ -2184,7 +2208,7 @@ static void *locks_next(struct seq_file *f, void *v, loff_t *pos)
2184 2208
2185static void locks_stop(struct seq_file *f, void *v) 2209static void locks_stop(struct seq_file *f, void *v)
2186{ 2210{
2187 unlock_kernel(); 2211 unlock_flocks();
2188} 2212}
2189 2213
2190static const struct seq_operations locks_seq_operations = { 2214static const struct seq_operations locks_seq_operations = {
@@ -2231,7 +2255,7 @@ int lock_may_read(struct inode *inode, loff_t start, unsigned long len)
2231{ 2255{
2232 struct file_lock *fl; 2256 struct file_lock *fl;
2233 int result = 1; 2257 int result = 1;
2234 lock_kernel(); 2258 lock_flocks();
2235 for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) { 2259 for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) {
2236 if (IS_POSIX(fl)) { 2260 if (IS_POSIX(fl)) {
2237 if (fl->fl_type == F_RDLCK) 2261 if (fl->fl_type == F_RDLCK)
@@ -2248,7 +2272,7 @@ int lock_may_read(struct inode *inode, loff_t start, unsigned long len)
2248 result = 0; 2272 result = 0;
2249 break; 2273 break;
2250 } 2274 }
2251 unlock_kernel(); 2275 unlock_flocks();
2252 return result; 2276 return result;
2253} 2277}
2254 2278
@@ -2271,7 +2295,7 @@ int lock_may_write(struct inode *inode, loff_t start, unsigned long len)
2271{ 2295{
2272 struct file_lock *fl; 2296 struct file_lock *fl;
2273 int result = 1; 2297 int result = 1;
2274 lock_kernel(); 2298 lock_flocks();
2275 for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) { 2299 for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) {
2276 if (IS_POSIX(fl)) { 2300 if (IS_POSIX(fl)) {
2277 if ((fl->fl_end < start) || (fl->fl_start > (start + len))) 2301 if ((fl->fl_end < start) || (fl->fl_start > (start + len)))
@@ -2286,7 +2310,7 @@ int lock_may_write(struct inode *inode, loff_t start, unsigned long len)
2286 result = 0; 2310 result = 0;
2287 break; 2311 break;
2288 } 2312 }
2289 unlock_kernel(); 2313 unlock_flocks();
2290 return result; 2314 return result;
2291} 2315}
2292 2316
diff --git a/fs/logfs/dir.c b/fs/logfs/dir.c
index 9777eb5b5522..1eb4e89e045b 100644
--- a/fs/logfs/dir.c
+++ b/fs/logfs/dir.c
@@ -827,4 +827,5 @@ const struct file_operations logfs_dir_fops = {
827 .unlocked_ioctl = logfs_ioctl, 827 .unlocked_ioctl = logfs_ioctl,
828 .readdir = logfs_readdir, 828 .readdir = logfs_readdir,
829 .read = generic_read_dir, 829 .read = generic_read_dir,
830 .llseek = default_llseek,
830}; 831};
diff --git a/fs/namespace.c b/fs/namespace.c
index a72eaabfe8f2..7ca5182c0bed 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1744,9 +1744,7 @@ static int do_new_mount(struct path *path, char *type, int flags,
1744 if (!capable(CAP_SYS_ADMIN)) 1744 if (!capable(CAP_SYS_ADMIN))
1745 return -EPERM; 1745 return -EPERM;
1746 1746
1747 lock_kernel();
1748 mnt = do_kern_mount(type, flags, name, data); 1747 mnt = do_kern_mount(type, flags, name, data);
1749 unlock_kernel();
1750 if (IS_ERR(mnt)) 1748 if (IS_ERR(mnt))
1751 return PTR_ERR(mnt); 1749 return PTR_ERR(mnt);
1752 1750
diff --git a/fs/ncpfs/dir.c b/fs/ncpfs/dir.c
index 9578cbe0cd58..aac8832e919e 100644
--- a/fs/ncpfs/dir.c
+++ b/fs/ncpfs/dir.c
@@ -95,6 +95,34 @@ const struct dentry_operations ncp_root_dentry_operations =
95}; 95};
96 96
97 97
98#define ncp_namespace(i) (NCP_SERVER(i)->name_space[NCP_FINFO(i)->volNumber])
99
100static inline int ncp_preserve_entry_case(struct inode *i, __u32 nscreator)
101{
102#ifdef CONFIG_NCPFS_SMALLDOS
103 int ns = ncp_namespace(i);
104
105 if ((ns == NW_NS_DOS)
106#ifdef CONFIG_NCPFS_OS2_NS
107 || ((ns == NW_NS_OS2) && (nscreator == NW_NS_DOS))
108#endif /* CONFIG_NCPFS_OS2_NS */
109 )
110 return 0;
111#endif /* CONFIG_NCPFS_SMALLDOS */
112 return 1;
113}
114
115#define ncp_preserve_case(i) (ncp_namespace(i) != NW_NS_DOS)
116
117static inline int ncp_case_sensitive(struct dentry *dentry)
118{
119#ifdef CONFIG_NCPFS_NFS_NS
120 return ncp_namespace(dentry->d_inode) == NW_NS_NFS;
121#else
122 return 0;
123#endif /* CONFIG_NCPFS_NFS_NS */
124}
125
98/* 126/*
99 * Note: leave the hash unchanged if the directory 127 * Note: leave the hash unchanged if the directory
100 * is case-sensitive. 128 * is case-sensitive.
@@ -102,13 +130,12 @@ const struct dentry_operations ncp_root_dentry_operations =
102static int 130static int
103ncp_hash_dentry(struct dentry *dentry, struct qstr *this) 131ncp_hash_dentry(struct dentry *dentry, struct qstr *this)
104{ 132{
105 struct nls_table *t; 133 if (!ncp_case_sensitive(dentry)) {
106 unsigned long hash; 134 struct nls_table *t;
107 int i; 135 unsigned long hash;
108 136 int i;
109 t = NCP_IO_TABLE(dentry);
110 137
111 if (!ncp_case_sensitive(dentry->d_inode)) { 138 t = NCP_IO_TABLE(dentry);
112 hash = init_name_hash(); 139 hash = init_name_hash();
113 for (i=0; i<this->len ; i++) 140 for (i=0; i<this->len ; i++)
114 hash = partial_name_hash(ncp_tolower(t, this->name[i]), 141 hash = partial_name_hash(ncp_tolower(t, this->name[i]),
@@ -124,7 +151,7 @@ ncp_compare_dentry(struct dentry *dentry, struct qstr *a, struct qstr *b)
124 if (a->len != b->len) 151 if (a->len != b->len)
125 return 1; 152 return 1;
126 153
127 if (ncp_case_sensitive(dentry->d_inode)) 154 if (ncp_case_sensitive(dentry))
128 return strncmp(a->name, b->name, a->len); 155 return strncmp(a->name, b->name, a->len);
129 156
130 return ncp_strnicmp(NCP_IO_TABLE(dentry), a->name, b->name, a->len); 157 return ncp_strnicmp(NCP_IO_TABLE(dentry), a->name, b->name, a->len);
@@ -266,7 +293,7 @@ leave_me:;
266 293
267 294
268static int 295static int
269__ncp_lookup_validate(struct dentry *dentry) 296ncp_lookup_validate(struct dentry *dentry, struct nameidata *nd)
270{ 297{
271 struct ncp_server *server; 298 struct ncp_server *server;
272 struct dentry *parent; 299 struct dentry *parent;
@@ -283,9 +310,6 @@ __ncp_lookup_validate(struct dentry *dentry)
283 310
284 server = NCP_SERVER(dir); 311 server = NCP_SERVER(dir);
285 312
286 if (!ncp_conn_valid(server))
287 goto finished;
288
289 /* 313 /*
290 * Inspired by smbfs: 314 * Inspired by smbfs:
291 * The default validation is based on dentry age: 315 * The default validation is based on dentry age:
@@ -304,8 +328,11 @@ __ncp_lookup_validate(struct dentry *dentry)
304 if (ncp_is_server_root(dir)) { 328 if (ncp_is_server_root(dir)) {
305 res = ncp_io2vol(server, __name, &len, dentry->d_name.name, 329 res = ncp_io2vol(server, __name, &len, dentry->d_name.name,
306 dentry->d_name.len, 1); 330 dentry->d_name.len, 1);
307 if (!res) 331 if (!res) {
308 res = ncp_lookup_volume(server, __name, &(finfo.i)); 332 res = ncp_lookup_volume(server, __name, &(finfo.i));
333 if (!res)
334 ncp_update_known_namespace(server, finfo.i.volNumber, NULL);
335 }
309 } else { 336 } else {
310 res = ncp_io2vol(server, __name, &len, dentry->d_name.name, 337 res = ncp_io2vol(server, __name, &len, dentry->d_name.name,
311 dentry->d_name.len, !ncp_preserve_case(dir)); 338 dentry->d_name.len, !ncp_preserve_case(dir));
@@ -320,13 +347,17 @@ __ncp_lookup_validate(struct dentry *dentry)
320 * what we remember, it's not valid any more. 347 * what we remember, it's not valid any more.
321 */ 348 */
322 if (!res) { 349 if (!res) {
323 if (finfo.i.dirEntNum == NCP_FINFO(dentry->d_inode)->dirEntNum) { 350 struct inode *inode = dentry->d_inode;
351
352 mutex_lock(&inode->i_mutex);
353 if (finfo.i.dirEntNum == NCP_FINFO(inode)->dirEntNum) {
324 ncp_new_dentry(dentry); 354 ncp_new_dentry(dentry);
325 val=1; 355 val=1;
326 } else 356 } else
327 DDPRINTK("ncp_lookup_validate: found, but dirEntNum changed\n"); 357 DDPRINTK("ncp_lookup_validate: found, but dirEntNum changed\n");
328 358
329 ncp_update_inode2(dentry->d_inode, &finfo); 359 ncp_update_inode2(inode, &finfo);
360 mutex_unlock(&inode->i_mutex);
330 } 361 }
331 362
332finished: 363finished:
@@ -335,16 +366,6 @@ finished:
335 return val; 366 return val;
336} 367}
337 368
338static int
339ncp_lookup_validate(struct dentry * dentry, struct nameidata *nd)
340{
341 int res;
342 lock_kernel();
343 res = __ncp_lookup_validate(dentry);
344 unlock_kernel();
345 return res;
346}
347
348static struct dentry * 369static struct dentry *
349ncp_dget_fpos(struct dentry *dentry, struct dentry *parent, unsigned long fpos) 370ncp_dget_fpos(struct dentry *dentry, struct dentry *parent, unsigned long fpos)
350{ 371{
@@ -411,8 +432,6 @@ static int ncp_readdir(struct file *filp, void *dirent, filldir_t filldir)
411 int result, mtime_valid = 0; 432 int result, mtime_valid = 0;
412 time_t mtime = 0; 433 time_t mtime = 0;
413 434
414 lock_kernel();
415
416 ctl.page = NULL; 435 ctl.page = NULL;
417 ctl.cache = NULL; 436 ctl.cache = NULL;
418 437
@@ -421,6 +440,7 @@ static int ncp_readdir(struct file *filp, void *dirent, filldir_t filldir)
421 (int) filp->f_pos); 440 (int) filp->f_pos);
422 441
423 result = -EIO; 442 result = -EIO;
443 /* Do not generate '.' and '..' when server is dead. */
424 if (!ncp_conn_valid(server)) 444 if (!ncp_conn_valid(server))
425 goto out; 445 goto out;
426 446
@@ -532,6 +552,12 @@ read_really:
532 ctl.head.end = ctl.fpos - 1; 552 ctl.head.end = ctl.fpos - 1;
533 ctl.head.eof = ctl.valid; 553 ctl.head.eof = ctl.valid;
534finished: 554finished:
555 if (ctl.page) {
556 kunmap(ctl.page);
557 SetPageUptodate(ctl.page);
558 unlock_page(ctl.page);
559 page_cache_release(ctl.page);
560 }
535 if (page) { 561 if (page) {
536 cache->head = ctl.head; 562 cache->head = ctl.head;
537 kunmap(page); 563 kunmap(page);
@@ -539,23 +565,17 @@ finished:
539 unlock_page(page); 565 unlock_page(page);
540 page_cache_release(page); 566 page_cache_release(page);
541 } 567 }
542 if (ctl.page) {
543 kunmap(ctl.page);
544 SetPageUptodate(ctl.page);
545 unlock_page(ctl.page);
546 page_cache_release(ctl.page);
547 }
548out: 568out:
549 unlock_kernel();
550 return result; 569 return result;
551} 570}
552 571
553static int 572static int
554ncp_fill_cache(struct file *filp, void *dirent, filldir_t filldir, 573ncp_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
555 struct ncp_cache_control *ctrl, struct ncp_entry_info *entry) 574 struct ncp_cache_control *ctrl, struct ncp_entry_info *entry,
575 int inval_childs)
556{ 576{
557 struct dentry *newdent, *dentry = filp->f_path.dentry; 577 struct dentry *newdent, *dentry = filp->f_path.dentry;
558 struct inode *newino, *inode = dentry->d_inode; 578 struct inode *dir = dentry->d_inode;
559 struct ncp_cache_control ctl = *ctrl; 579 struct ncp_cache_control ctl = *ctrl;
560 struct qstr qname; 580 struct qstr qname;
561 int valid = 0; 581 int valid = 0;
@@ -564,9 +584,9 @@ ncp_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
564 __u8 __name[NCP_MAXPATHLEN + 1]; 584 __u8 __name[NCP_MAXPATHLEN + 1];
565 585
566 qname.len = sizeof(__name); 586 qname.len = sizeof(__name);
567 if (ncp_vol2io(NCP_SERVER(inode), __name, &qname.len, 587 if (ncp_vol2io(NCP_SERVER(dir), __name, &qname.len,
568 entry->i.entryName, entry->i.nameLen, 588 entry->i.entryName, entry->i.nameLen,
569 !ncp_preserve_entry_case(inode, entry->i.NSCreator))) 589 !ncp_preserve_entry_case(dir, entry->i.NSCreator)))
570 return 1; /* I'm not sure */ 590 return 1; /* I'm not sure */
571 591
572 qname.name = __name; 592 qname.name = __name;
@@ -584,22 +604,64 @@ ncp_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
584 goto end_advance; 604 goto end_advance;
585 } else { 605 } else {
586 hashed = 1; 606 hashed = 1;
587 memcpy((char *) newdent->d_name.name, qname.name, 607
588 newdent->d_name.len); 608 /* If case sensitivity changed for this volume, all entries below this one
609 should be thrown away. This entry itself is not affected, as its case
610 sensitivity is controlled by its own parent. */
611 if (inval_childs)
612 shrink_dcache_parent(newdent);
613
614 /*
615 * It is not as dangerous as it looks. NetWare's OS2 namespace is
616 * case preserving yet case insensitive. So we update dentry's name
617 * as received from server. We found dentry via d_lookup with our
618 * hash, so we know that hash does not change, and so replacing name
619 * should be reasonably safe.
620 */
621 if (qname.len == newdent->d_name.len &&
622 memcmp(newdent->d_name.name, qname.name, newdent->d_name.len)) {
623 struct inode *inode = newdent->d_inode;
624
625 /*
626 * Inside ncpfs all uses of d_name are either for debugging,
627 * or on functions which acquire inode mutex (mknod, creat,
628 * lookup). So grab i_mutex here, to be sure. d_path
629 * uses dcache_lock when generating path, so we should too.
630 * And finally d_compare is protected by dentry's d_lock, so
631 * here we go.
632 */
633 if (inode)
634 mutex_lock(&inode->i_mutex);
635 spin_lock(&dcache_lock);
636 spin_lock(&newdent->d_lock);
637 memcpy((char *) newdent->d_name.name, qname.name,
638 newdent->d_name.len);
639 spin_unlock(&newdent->d_lock);
640 spin_unlock(&dcache_lock);
641 if (inode)
642 mutex_unlock(&inode->i_mutex);
643 }
589 } 644 }
590 645
591 if (!newdent->d_inode) { 646 if (!newdent->d_inode) {
647 struct inode *inode;
648
592 entry->opened = 0; 649 entry->opened = 0;
593 entry->ino = iunique(inode->i_sb, 2); 650 entry->ino = iunique(dir->i_sb, 2);
594 newino = ncp_iget(inode->i_sb, entry); 651 inode = ncp_iget(dir->i_sb, entry);
595 if (newino) { 652 if (inode) {
596 newdent->d_op = &ncp_dentry_operations; 653 newdent->d_op = &ncp_dentry_operations;
597 d_instantiate(newdent, newino); 654 d_instantiate(newdent, inode);
598 if (!hashed) 655 if (!hashed)
599 d_rehash(newdent); 656 d_rehash(newdent);
600 } 657 }
601 } else 658 } else {
602 ncp_update_inode2(newdent->d_inode, entry); 659 struct inode *inode = newdent->d_inode;
660
661 mutex_lock(&inode->i_mutex);
662 ncp_update_inode2(inode, entry);
663 mutex_unlock(&inode->i_mutex);
664 }
603 665
604 if (newdent->d_inode) { 666 if (newdent->d_inode) {
605 ino = newdent->d_inode->i_ino; 667 ino = newdent->d_inode->i_ino;
@@ -617,7 +679,7 @@ ncp_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
617 ctl.cache = NULL; 679 ctl.cache = NULL;
618 ctl.idx -= NCP_DIRCACHE_SIZE; 680 ctl.idx -= NCP_DIRCACHE_SIZE;
619 ctl.ofs += 1; 681 ctl.ofs += 1;
620 ctl.page = grab_cache_page(&inode->i_data, ctl.ofs); 682 ctl.page = grab_cache_page(&dir->i_data, ctl.ofs);
621 if (ctl.page) 683 if (ctl.page)
622 ctl.cache = kmap(ctl.page); 684 ctl.cache = kmap(ctl.page);
623 } 685 }
@@ -633,7 +695,7 @@ end_advance:
633 if (!ino) 695 if (!ino)
634 ino = find_inode_number(dentry, &qname); 696 ino = find_inode_number(dentry, &qname);
635 if (!ino) 697 if (!ino)
636 ino = iunique(inode->i_sb, 2); 698 ino = iunique(dir->i_sb, 2);
637 ctl.filled = filldir(dirent, qname.name, qname.len, 699 ctl.filled = filldir(dirent, qname.name, qname.len,
638 filp->f_pos, ino, DT_UNKNOWN); 700 filp->f_pos, ino, DT_UNKNOWN);
639 if (!ctl.filled) 701 if (!ctl.filled)
@@ -660,6 +722,7 @@ ncp_read_volume_list(struct file *filp, void *dirent, filldir_t filldir,
660 (unsigned long) filp->f_pos); 722 (unsigned long) filp->f_pos);
661 723
662 for (i = 0; i < NCP_NUMBER_OF_VOLUMES; i++) { 724 for (i = 0; i < NCP_NUMBER_OF_VOLUMES; i++) {
725 int inval_dentry;
663 726
664 if (ncp_get_volume_info_with_number(server, i, &info) != 0) 727 if (ncp_get_volume_info_with_number(server, i, &info) != 0)
665 return; 728 return;
@@ -675,8 +738,9 @@ ncp_read_volume_list(struct file *filp, void *dirent, filldir_t filldir,
675 info.volume_name); 738 info.volume_name);
676 continue; 739 continue;
677 } 740 }
741 inval_dentry = ncp_update_known_namespace(server, entry.i.volNumber, NULL);
678 entry.volume = entry.i.volNumber; 742 entry.volume = entry.i.volNumber;
679 if (!ncp_fill_cache(filp, dirent, filldir, ctl, &entry)) 743 if (!ncp_fill_cache(filp, dirent, filldir, ctl, &entry, inval_dentry))
680 return; 744 return;
681 } 745 }
682} 746}
@@ -739,7 +803,7 @@ ncp_do_readdir(struct file *filp, void *dirent, filldir_t filldir,
739 rpl += onerpl; 803 rpl += onerpl;
740 rpls -= onerpl; 804 rpls -= onerpl;
741 entry.volume = entry.i.volNumber; 805 entry.volume = entry.i.volNumber;
742 if (!ncp_fill_cache(filp, dirent, filldir, ctl, &entry)) 806 if (!ncp_fill_cache(filp, dirent, filldir, ctl, &entry, 0))
743 break; 807 break;
744 } 808 }
745 } while (more); 809 } while (more);
@@ -775,17 +839,19 @@ int ncp_conn_logged_in(struct super_block *sb)
775 if (dent) { 839 if (dent) {
776 struct inode* ino = dent->d_inode; 840 struct inode* ino = dent->d_inode;
777 if (ino) { 841 if (ino) {
842 ncp_update_known_namespace(server, volNumber, NULL);
778 NCP_FINFO(ino)->volNumber = volNumber; 843 NCP_FINFO(ino)->volNumber = volNumber;
779 NCP_FINFO(ino)->dirEntNum = dirEntNum; 844 NCP_FINFO(ino)->dirEntNum = dirEntNum;
780 NCP_FINFO(ino)->DosDirNum = DosDirNum; 845 NCP_FINFO(ino)->DosDirNum = DosDirNum;
846 result = 0;
781 } else { 847 } else {
782 DPRINTK("ncpfs: sb->s_root->d_inode == NULL!\n"); 848 DPRINTK("ncpfs: sb->s_root->d_inode == NULL!\n");
783 } 849 }
784 } else { 850 } else {
785 DPRINTK("ncpfs: sb->s_root == NULL!\n"); 851 DPRINTK("ncpfs: sb->s_root == NULL!\n");
786 } 852 }
787 } 853 } else
788 result = 0; 854 result = 0;
789 855
790out: 856out:
791 return result; 857 return result;
@@ -799,7 +865,6 @@ static struct dentry *ncp_lookup(struct inode *dir, struct dentry *dentry, struc
799 int error, res, len; 865 int error, res, len;
800 __u8 __name[NCP_MAXPATHLEN + 1]; 866 __u8 __name[NCP_MAXPATHLEN + 1];
801 867
802 lock_kernel();
803 error = -EIO; 868 error = -EIO;
804 if (!ncp_conn_valid(server)) 869 if (!ncp_conn_valid(server))
805 goto finished; 870 goto finished;
@@ -813,6 +878,8 @@ static struct dentry *ncp_lookup(struct inode *dir, struct dentry *dentry, struc
813 dentry->d_name.len, 1); 878 dentry->d_name.len, 1);
814 if (!res) 879 if (!res)
815 res = ncp_lookup_volume(server, __name, &(finfo.i)); 880 res = ncp_lookup_volume(server, __name, &(finfo.i));
881 if (!res)
882 ncp_update_known_namespace(server, finfo.i.volNumber, NULL);
816 } else { 883 } else {
817 res = ncp_io2vol(server, __name, &len, dentry->d_name.name, 884 res = ncp_io2vol(server, __name, &len, dentry->d_name.name,
818 dentry->d_name.len, !ncp_preserve_case(dir)); 885 dentry->d_name.len, !ncp_preserve_case(dir));
@@ -846,7 +913,6 @@ add_entry:
846 913
847finished: 914finished:
848 PPRINTK("ncp_lookup: result=%d\n", error); 915 PPRINTK("ncp_lookup: result=%d\n", error);
849 unlock_kernel();
850 return ERR_PTR(error); 916 return ERR_PTR(error);
851} 917}
852 918
@@ -887,11 +953,6 @@ int ncp_create_new(struct inode *dir, struct dentry *dentry, int mode,
887 PPRINTK("ncp_create_new: creating %s/%s, mode=%x\n", 953 PPRINTK("ncp_create_new: creating %s/%s, mode=%x\n",
888 dentry->d_parent->d_name.name, dentry->d_name.name, mode); 954 dentry->d_parent->d_name.name, dentry->d_name.name, mode);
889 955
890 error = -EIO;
891 lock_kernel();
892 if (!ncp_conn_valid(server))
893 goto out;
894
895 ncp_age_dentry(server, dentry); 956 ncp_age_dentry(server, dentry);
896 len = sizeof(__name); 957 len = sizeof(__name);
897 error = ncp_io2vol(server, __name, &len, dentry->d_name.name, 958 error = ncp_io2vol(server, __name, &len, dentry->d_name.name,
@@ -917,6 +978,8 @@ int ncp_create_new(struct inode *dir, struct dentry *dentry, int mode,
917 if (result) { 978 if (result) {
918 if (result == 0x87) 979 if (result == 0x87)
919 error = -ENAMETOOLONG; 980 error = -ENAMETOOLONG;
981 else if (result < 0)
982 error = result;
920 DPRINTK("ncp_create: %s/%s failed\n", 983 DPRINTK("ncp_create: %s/%s failed\n",
921 dentry->d_parent->d_name.name, dentry->d_name.name); 984 dentry->d_parent->d_name.name, dentry->d_name.name);
922 goto out; 985 goto out;
@@ -935,7 +998,6 @@ int ncp_create_new(struct inode *dir, struct dentry *dentry, int mode,
935 998
936 error = ncp_instantiate(dir, dentry, &finfo); 999 error = ncp_instantiate(dir, dentry, &finfo);
937out: 1000out:
938 unlock_kernel();
939 return error; 1001 return error;
940} 1002}
941 1003
@@ -955,11 +1017,6 @@ static int ncp_mkdir(struct inode *dir, struct dentry *dentry, int mode)
955 DPRINTK("ncp_mkdir: making %s/%s\n", 1017 DPRINTK("ncp_mkdir: making %s/%s\n",
956 dentry->d_parent->d_name.name, dentry->d_name.name); 1018 dentry->d_parent->d_name.name, dentry->d_name.name);
957 1019
958 error = -EIO;
959 lock_kernel();
960 if (!ncp_conn_valid(server))
961 goto out;
962
963 ncp_age_dentry(server, dentry); 1020 ncp_age_dentry(server, dentry);
964 len = sizeof(__name); 1021 len = sizeof(__name);
965 error = ncp_io2vol(server, __name, &len, dentry->d_name.name, 1022 error = ncp_io2vol(server, __name, &len, dentry->d_name.name,
@@ -967,12 +1024,11 @@ static int ncp_mkdir(struct inode *dir, struct dentry *dentry, int mode)
967 if (error) 1024 if (error)
968 goto out; 1025 goto out;
969 1026
970 error = -EACCES; 1027 error = ncp_open_create_file_or_subdir(server, dir, __name,
971 if (ncp_open_create_file_or_subdir(server, dir, __name,
972 OC_MODE_CREATE, aDIR, 1028 OC_MODE_CREATE, aDIR,
973 cpu_to_le16(0xffff), 1029 cpu_to_le16(0xffff),
974 &finfo) == 0) 1030 &finfo);
975 { 1031 if (error == 0) {
976 if (ncp_is_nfs_extras(server, finfo.volume)) { 1032 if (ncp_is_nfs_extras(server, finfo.volume)) {
977 mode |= S_IFDIR; 1033 mode |= S_IFDIR;
978 finfo.i.nfs.mode = mode; 1034 finfo.i.nfs.mode = mode;
@@ -983,9 +1039,10 @@ static int ncp_mkdir(struct inode *dir, struct dentry *dentry, int mode)
983 goto out; 1039 goto out;
984 } 1040 }
985 error = ncp_instantiate(dir, dentry, &finfo); 1041 error = ncp_instantiate(dir, dentry, &finfo);
1042 } else if (error > 0) {
1043 error = -EACCES;
986 } 1044 }
987out: 1045out:
988 unlock_kernel();
989 return error; 1046 return error;
990} 1047}
991 1048
@@ -998,11 +1055,6 @@ static int ncp_rmdir(struct inode *dir, struct dentry *dentry)
998 DPRINTK("ncp_rmdir: removing %s/%s\n", 1055 DPRINTK("ncp_rmdir: removing %s/%s\n",
999 dentry->d_parent->d_name.name, dentry->d_name.name); 1056 dentry->d_parent->d_name.name, dentry->d_name.name);
1000 1057
1001 error = -EIO;
1002 lock_kernel();
1003 if (!ncp_conn_valid(server))
1004 goto out;
1005
1006 error = -EBUSY; 1058 error = -EBUSY;
1007 if (!d_unhashed(dentry)) 1059 if (!d_unhashed(dentry))
1008 goto out; 1060 goto out;
@@ -1036,11 +1088,10 @@ static int ncp_rmdir(struct inode *dir, struct dentry *dentry)
1036 error = -ENOENT; 1088 error = -ENOENT;
1037 break; 1089 break;
1038 default: 1090 default:
1039 error = -EACCES; 1091 error = result < 0 ? result : -EACCES;
1040 break; 1092 break;
1041 } 1093 }
1042out: 1094out:
1043 unlock_kernel();
1044 return error; 1095 return error;
1045} 1096}
1046 1097
@@ -1050,15 +1101,10 @@ static int ncp_unlink(struct inode *dir, struct dentry *dentry)
1050 struct ncp_server *server; 1101 struct ncp_server *server;
1051 int error; 1102 int error;
1052 1103
1053 lock_kernel();
1054 server = NCP_SERVER(dir); 1104 server = NCP_SERVER(dir);
1055 DPRINTK("ncp_unlink: unlinking %s/%s\n", 1105 DPRINTK("ncp_unlink: unlinking %s/%s\n",
1056 dentry->d_parent->d_name.name, dentry->d_name.name); 1106 dentry->d_parent->d_name.name, dentry->d_name.name);
1057 1107
1058 error = -EIO;
1059 if (!ncp_conn_valid(server))
1060 goto out;
1061
1062 /* 1108 /*
1063 * Check whether to close the file ... 1109 * Check whether to close the file ...
1064 */ 1110 */
@@ -1097,12 +1143,9 @@ static int ncp_unlink(struct inode *dir, struct dentry *dentry)
1097 error = -ENOENT; 1143 error = -ENOENT;
1098 break; 1144 break;
1099 default: 1145 default:
1100 error = -EACCES; 1146 error = error < 0 ? error : -EACCES;
1101 break; 1147 break;
1102 } 1148 }
1103
1104out:
1105 unlock_kernel();
1106 return error; 1149 return error;
1107} 1150}
1108 1151
@@ -1118,11 +1161,6 @@ static int ncp_rename(struct inode *old_dir, struct dentry *old_dentry,
1118 old_dentry->d_parent->d_name.name, old_dentry->d_name.name, 1161 old_dentry->d_parent->d_name.name, old_dentry->d_name.name,
1119 new_dentry->d_parent->d_name.name, new_dentry->d_name.name); 1162 new_dentry->d_parent->d_name.name, new_dentry->d_name.name);
1120 1163
1121 error = -EIO;
1122 lock_kernel();
1123 if (!ncp_conn_valid(server))
1124 goto out;
1125
1126 ncp_age_dentry(server, old_dentry); 1164 ncp_age_dentry(server, old_dentry);
1127 ncp_age_dentry(server, new_dentry); 1165 ncp_age_dentry(server, new_dentry);
1128 1166
@@ -1161,11 +1199,10 @@ static int ncp_rename(struct inode *old_dir, struct dentry *old_dentry,
1161 error = -ENOENT; 1199 error = -ENOENT;
1162 break; 1200 break;
1163 default: 1201 default:
1164 error = -EACCES; 1202 error = error < 0 ? error : -EACCES;
1165 break; 1203 break;
1166 } 1204 }
1167out: 1205out:
1168 unlock_kernel();
1169 return error; 1206 return error;
1170} 1207}
1171 1208
diff --git a/fs/ncpfs/file.c b/fs/ncpfs/file.c
index 3639cc5cbdae..6c754f70c529 100644
--- a/fs/ncpfs/file.c
+++ b/fs/ncpfs/file.c
@@ -113,9 +113,6 @@ ncp_file_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
113 DPRINTK("ncp_file_read: enter %s/%s\n", 113 DPRINTK("ncp_file_read: enter %s/%s\n",
114 dentry->d_parent->d_name.name, dentry->d_name.name); 114 dentry->d_parent->d_name.name, dentry->d_name.name);
115 115
116 if (!ncp_conn_valid(NCP_SERVER(inode)))
117 return -EIO;
118
119 pos = *ppos; 116 pos = *ppos;
120 117
121 if ((ssize_t) count < 0) { 118 if ((ssize_t) count < 0) {
@@ -192,13 +189,11 @@ ncp_file_write(struct file *file, const char __user *buf, size_t count, loff_t *
192 189
193 DPRINTK("ncp_file_write: enter %s/%s\n", 190 DPRINTK("ncp_file_write: enter %s/%s\n",
194 dentry->d_parent->d_name.name, dentry->d_name.name); 191 dentry->d_parent->d_name.name, dentry->d_name.name);
195 if (!ncp_conn_valid(NCP_SERVER(inode)))
196 return -EIO;
197 if ((ssize_t) count < 0) 192 if ((ssize_t) count < 0)
198 return -EINVAL; 193 return -EINVAL;
199 pos = *ppos; 194 pos = *ppos;
200 if (file->f_flags & O_APPEND) { 195 if (file->f_flags & O_APPEND) {
201 pos = inode->i_size; 196 pos = i_size_read(inode);
202 } 197 }
203 198
204 if (pos + count > MAX_NON_LFS && !(file->f_flags&O_LARGEFILE)) { 199 if (pos + count > MAX_NON_LFS && !(file->f_flags&O_LARGEFILE)) {
@@ -264,8 +259,11 @@ ncp_file_write(struct file *file, const char __user *buf, size_t count, loff_t *
264 259
265 *ppos = pos; 260 *ppos = pos;
266 261
267 if (pos > inode->i_size) { 262 if (pos > i_size_read(inode)) {
268 inode->i_size = pos; 263 mutex_lock(&inode->i_mutex);
264 if (pos > i_size_read(inode))
265 i_size_write(inode, pos);
266 mutex_unlock(&inode->i_mutex);
269 } 267 }
270 DPRINTK("ncp_file_write: exit %s/%s\n", 268 DPRINTK("ncp_file_write: exit %s/%s\n",
271 dentry->d_parent->d_name.name, dentry->d_name.name); 269 dentry->d_parent->d_name.name, dentry->d_name.name);
@@ -281,18 +279,9 @@ static int ncp_release(struct inode *inode, struct file *file) {
281 return 0; 279 return 0;
282} 280}
283 281
284static loff_t ncp_remote_llseek(struct file *file, loff_t offset, int origin)
285{
286 loff_t ret;
287 lock_kernel();
288 ret = generic_file_llseek_unlocked(file, offset, origin);
289 unlock_kernel();
290 return ret;
291}
292
293const struct file_operations ncp_file_operations = 282const struct file_operations ncp_file_operations =
294{ 283{
295 .llseek = ncp_remote_llseek, 284 .llseek = generic_file_llseek,
296 .read = ncp_file_read, 285 .read = ncp_file_read,
297 .write = ncp_file_write, 286 .write = ncp_file_write,
298 .unlocked_ioctl = ncp_ioctl, 287 .unlocked_ioctl = ncp_ioctl,
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index b4de38cf49f5..985fabb26aca 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -139,7 +139,7 @@ static void ncp_update_dates(struct inode *inode, struct nw_info_struct *nwi)
139 inode->i_mode = nwi->nfs.mode; 139 inode->i_mode = nwi->nfs.mode;
140 } 140 }
141 141
142 inode->i_blocks = (inode->i_size + NCP_BLOCK_SIZE - 1) >> NCP_BLOCK_SHIFT; 142 inode->i_blocks = (i_size_read(inode) + NCP_BLOCK_SIZE - 1) >> NCP_BLOCK_SHIFT;
143 143
144 inode->i_mtime.tv_sec = ncp_date_dos2unix(nwi->modifyTime, nwi->modifyDate); 144 inode->i_mtime.tv_sec = ncp_date_dos2unix(nwi->modifyTime, nwi->modifyDate);
145 inode->i_ctime.tv_sec = ncp_date_dos2unix(nwi->creationTime, nwi->creationDate); 145 inode->i_ctime.tv_sec = ncp_date_dos2unix(nwi->creationTime, nwi->creationDate);
@@ -158,18 +158,21 @@ static void ncp_update_attrs(struct inode *inode, struct ncp_entry_info *nwinfo)
158 inode->i_mode = server->m.dir_mode; 158 inode->i_mode = server->m.dir_mode;
159 /* for directories dataStreamSize seems to be some 159 /* for directories dataStreamSize seems to be some
160 Object ID ??? */ 160 Object ID ??? */
161 inode->i_size = NCP_BLOCK_SIZE; 161 i_size_write(inode, NCP_BLOCK_SIZE);
162 } else { 162 } else {
163 u32 size;
164
163 inode->i_mode = server->m.file_mode; 165 inode->i_mode = server->m.file_mode;
164 inode->i_size = le32_to_cpu(nwi->dataStreamSize); 166 size = le32_to_cpu(nwi->dataStreamSize);
167 i_size_write(inode, size);
165#ifdef CONFIG_NCPFS_EXTRAS 168#ifdef CONFIG_NCPFS_EXTRAS
166 if ((server->m.flags & (NCP_MOUNT_EXTRAS|NCP_MOUNT_SYMLINKS)) 169 if ((server->m.flags & (NCP_MOUNT_EXTRAS|NCP_MOUNT_SYMLINKS))
167 && (nwi->attributes & aSHARED)) { 170 && (nwi->attributes & aSHARED)) {
168 switch (nwi->attributes & (aHIDDEN|aSYSTEM)) { 171 switch (nwi->attributes & (aHIDDEN|aSYSTEM)) {
169 case aHIDDEN: 172 case aHIDDEN:
170 if (server->m.flags & NCP_MOUNT_SYMLINKS) { 173 if (server->m.flags & NCP_MOUNT_SYMLINKS) {
171 if (/* (inode->i_size >= NCP_MIN_SYMLINK_SIZE) 174 if (/* (size >= NCP_MIN_SYMLINK_SIZE)
172 && */ (inode->i_size <= NCP_MAX_SYMLINK_SIZE)) { 175 && */ (size <= NCP_MAX_SYMLINK_SIZE)) {
173 inode->i_mode = (inode->i_mode & ~S_IFMT) | S_IFLNK; 176 inode->i_mode = (inode->i_mode & ~S_IFMT) | S_IFLNK;
174 NCP_FINFO(inode)->flags |= NCPI_KLUDGE_SYMLINK; 177 NCP_FINFO(inode)->flags |= NCPI_KLUDGE_SYMLINK;
175 break; 178 break;
@@ -208,7 +211,7 @@ void ncp_update_inode2(struct inode* inode, struct ncp_entry_info *nwinfo)
208} 211}
209 212
210/* 213/*
211 * Fill in the inode based on the ncp_entry_info structure. 214 * Fill in the inode based on the ncp_entry_info structure. Used only for brand new inodes.
212 */ 215 */
213static void ncp_set_attr(struct inode *inode, struct ncp_entry_info *nwinfo) 216static void ncp_set_attr(struct inode *inode, struct ncp_entry_info *nwinfo)
214{ 217{
@@ -254,6 +257,7 @@ ncp_iget(struct super_block *sb, struct ncp_entry_info *info)
254 if (inode) { 257 if (inode) {
255 atomic_set(&NCP_FINFO(inode)->opened, info->opened); 258 atomic_set(&NCP_FINFO(inode)->opened, info->opened);
256 259
260 inode->i_mapping->backing_dev_info = sb->s_bdi;
257 inode->i_ino = info->ino; 261 inode->i_ino = info->ino;
258 ncp_set_attr(inode, info); 262 ncp_set_attr(inode, info);
259 if (S_ISREG(inode->i_mode)) { 263 if (S_ISREG(inode->i_mode)) {
@@ -299,10 +303,12 @@ ncp_evict_inode(struct inode *inode)
299 303
300static void ncp_stop_tasks(struct ncp_server *server) { 304static void ncp_stop_tasks(struct ncp_server *server) {
301 struct sock* sk = server->ncp_sock->sk; 305 struct sock* sk = server->ncp_sock->sk;
302 306
307 lock_sock(sk);
303 sk->sk_error_report = server->error_report; 308 sk->sk_error_report = server->error_report;
304 sk->sk_data_ready = server->data_ready; 309 sk->sk_data_ready = server->data_ready;
305 sk->sk_write_space = server->write_space; 310 sk->sk_write_space = server->write_space;
311 release_sock(sk);
306 del_timer_sync(&server->timeout_tm); 312 del_timer_sync(&server->timeout_tm);
307 flush_scheduled_work(); 313 flush_scheduled_work();
308} 314}
@@ -565,10 +571,12 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
565/* server->conn_status = 0; */ 571/* server->conn_status = 0; */
566/* server->root_dentry = NULL; */ 572/* server->root_dentry = NULL; */
567/* server->root_setuped = 0; */ 573/* server->root_setuped = 0; */
574 mutex_init(&server->root_setup_lock);
568#ifdef CONFIG_NCPFS_PACKET_SIGNING 575#ifdef CONFIG_NCPFS_PACKET_SIGNING
569/* server->sign_wanted = 0; */ 576/* server->sign_wanted = 0; */
570/* server->sign_active = 0; */ 577/* server->sign_active = 0; */
571#endif 578#endif
579 init_rwsem(&server->auth_rwsem);
572 server->auth.auth_type = NCP_AUTH_NONE; 580 server->auth.auth_type = NCP_AUTH_NONE;
573/* server->auth.object_name_len = 0; */ 581/* server->auth.object_name_len = 0; */
574/* server->auth.object_name = NULL; */ 582/* server->auth.object_name = NULL; */
@@ -593,16 +601,12 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
593 server->nls_io = load_nls_default(); 601 server->nls_io = load_nls_default();
594#endif /* CONFIG_NCPFS_NLS */ 602#endif /* CONFIG_NCPFS_NLS */
595 603
596 server->dentry_ttl = 0; /* no caching */ 604 atomic_set(&server->dentry_ttl, 0); /* no caching */
597 605
598 INIT_LIST_HEAD(&server->tx.requests); 606 INIT_LIST_HEAD(&server->tx.requests);
599 mutex_init(&server->rcv.creq_mutex); 607 mutex_init(&server->rcv.creq_mutex);
600 server->tx.creq = NULL; 608 server->tx.creq = NULL;
601 server->rcv.creq = NULL; 609 server->rcv.creq = NULL;
602 server->data_ready = sock->sk->sk_data_ready;
603 server->write_space = sock->sk->sk_write_space;
604 server->error_report = sock->sk->sk_error_report;
605 sock->sk->sk_user_data = server;
606 610
607 init_timer(&server->timeout_tm); 611 init_timer(&server->timeout_tm);
608#undef NCP_PACKET_SIZE 612#undef NCP_PACKET_SIZE
@@ -619,6 +623,11 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
619 if (server->rxbuf == NULL) 623 if (server->rxbuf == NULL)
620 goto out_txbuf; 624 goto out_txbuf;
621 625
626 lock_sock(sock->sk);
627 server->data_ready = sock->sk->sk_data_ready;
628 server->write_space = sock->sk->sk_write_space;
629 server->error_report = sock->sk->sk_error_report;
630 sock->sk->sk_user_data = server;
622 sock->sk->sk_data_ready = ncp_tcp_data_ready; 631 sock->sk->sk_data_ready = ncp_tcp_data_ready;
623 sock->sk->sk_error_report = ncp_tcp_error_report; 632 sock->sk->sk_error_report = ncp_tcp_error_report;
624 if (sock->type == SOCK_STREAM) { 633 if (sock->type == SOCK_STREAM) {
@@ -634,6 +643,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
634 server->timeout_tm.data = (unsigned long)server; 643 server->timeout_tm.data = (unsigned long)server;
635 server->timeout_tm.function = ncpdgram_timeout_call; 644 server->timeout_tm.function = ncpdgram_timeout_call;
636 } 645 }
646 release_sock(sock->sk);
637 647
638 ncp_lock_server(server); 648 ncp_lock_server(server);
639 error = ncp_connect(server); 649 error = ncp_connect(server);
@@ -658,8 +668,10 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
658 goto out_disconnect; 668 goto out_disconnect;
659 } 669 }
660 } 670 }
671 ncp_lock_server(server);
661 if (options & 2) 672 if (options & 2)
662 server->sign_wanted = 1; 673 server->sign_wanted = 1;
674 ncp_unlock_server(server);
663 } 675 }
664 else 676 else
665#endif /* CONFIG_NCPFS_PACKET_SIGNING */ 677#endif /* CONFIG_NCPFS_PACKET_SIGNING */
@@ -720,6 +732,9 @@ out_nls:
720 unload_nls(server->nls_io); 732 unload_nls(server->nls_io);
721 unload_nls(server->nls_vol); 733 unload_nls(server->nls_vol);
722#endif 734#endif
735 mutex_destroy(&server->rcv.creq_mutex);
736 mutex_destroy(&server->root_setup_lock);
737 mutex_destroy(&server->mutex);
723out_fput2: 738out_fput2:
724 if (server->info_filp) 739 if (server->info_filp)
725 fput(server->info_filp); 740 fput(server->info_filp);
@@ -743,8 +758,6 @@ static void ncp_put_super(struct super_block *sb)
743{ 758{
744 struct ncp_server *server = NCP_SBP(sb); 759 struct ncp_server *server = NCP_SBP(sb);
745 760
746 lock_kernel();
747
748 ncp_lock_server(server); 761 ncp_lock_server(server);
749 ncp_disconnect(server); 762 ncp_disconnect(server);
750 ncp_unlock_server(server); 763 ncp_unlock_server(server);
@@ -756,6 +769,9 @@ static void ncp_put_super(struct super_block *sb)
756 unload_nls(server->nls_vol); 769 unload_nls(server->nls_vol);
757 unload_nls(server->nls_io); 770 unload_nls(server->nls_io);
758#endif /* CONFIG_NCPFS_NLS */ 771#endif /* CONFIG_NCPFS_NLS */
772 mutex_destroy(&server->rcv.creq_mutex);
773 mutex_destroy(&server->root_setup_lock);
774 mutex_destroy(&server->mutex);
759 775
760 if (server->info_filp) 776 if (server->info_filp)
761 fput(server->info_filp); 777 fput(server->info_filp);
@@ -771,8 +787,6 @@ static void ncp_put_super(struct super_block *sb)
771 vfree(server->packet); 787 vfree(server->packet);
772 sb->s_fs_info = NULL; 788 sb->s_fs_info = NULL;
773 kfree(server); 789 kfree(server);
774
775 unlock_kernel();
776} 790}
777 791
778static int ncp_statfs(struct dentry *dentry, struct kstatfs *buf) 792static int ncp_statfs(struct dentry *dentry, struct kstatfs *buf)
@@ -851,10 +865,8 @@ int ncp_notify_change(struct dentry *dentry, struct iattr *attr)
851 865
852 result = -EIO; 866 result = -EIO;
853 867
854 lock_kernel();
855
856 server = NCP_SERVER(inode); 868 server = NCP_SERVER(inode);
857 if ((!server) || !ncp_conn_valid(server)) 869 if (!server) /* How this could happen? */
858 goto out; 870 goto out;
859 871
860 /* ageing the dentry to force validation */ 872 /* ageing the dentry to force validation */
@@ -981,8 +993,6 @@ int ncp_notify_change(struct dentry *dentry, struct iattr *attr)
981 result = ncp_modify_file_or_subdir_dos_info(NCP_SERVER(inode), 993 result = ncp_modify_file_or_subdir_dos_info(NCP_SERVER(inode),
982 inode, info_mask, &info); 994 inode, info_mask, &info);
983 if (result != 0) { 995 if (result != 0) {
984 result = -EACCES;
985
986 if (info_mask == (DM_CREATE_TIME | DM_CREATE_DATE)) { 996 if (info_mask == (DM_CREATE_TIME | DM_CREATE_DATE)) {
987 /* NetWare seems not to allow this. I 997 /* NetWare seems not to allow this. I
988 do not know why. So, just tell the 998 do not know why. So, just tell the
@@ -1005,7 +1015,8 @@ int ncp_notify_change(struct dentry *dentry, struct iattr *attr)
1005 mark_inode_dirty(inode); 1015 mark_inode_dirty(inode);
1006 1016
1007out: 1017out:
1008 unlock_kernel(); 1018 if (result > 0)
1019 result = -EACCES;
1009 return result; 1020 return result;
1010} 1021}
1011 1022
diff --git a/fs/ncpfs/ioctl.c b/fs/ncpfs/ioctl.c
index 84a8cfc4e38e..c2a1f9a155c3 100644
--- a/fs/ncpfs/ioctl.c
+++ b/fs/ncpfs/ioctl.c
@@ -35,16 +35,11 @@
35#define NCP_PACKET_SIZE_INTERNAL 65536 35#define NCP_PACKET_SIZE_INTERNAL 65536
36 36
37static int 37static int
38ncp_get_fs_info(struct ncp_server * server, struct file *file, 38ncp_get_fs_info(struct ncp_server * server, struct inode *inode,
39 struct ncp_fs_info __user *arg) 39 struct ncp_fs_info __user *arg)
40{ 40{
41 struct inode *inode = file->f_path.dentry->d_inode;
42 struct ncp_fs_info info; 41 struct ncp_fs_info info;
43 42
44 if (file_permission(file, MAY_WRITE) != 0
45 && current_uid() != server->m.mounted_uid)
46 return -EACCES;
47
48 if (copy_from_user(&info, arg, sizeof(info))) 43 if (copy_from_user(&info, arg, sizeof(info)))
49 return -EFAULT; 44 return -EFAULT;
50 45
@@ -65,16 +60,11 @@ ncp_get_fs_info(struct ncp_server * server, struct file *file,
65} 60}
66 61
67static int 62static int
68ncp_get_fs_info_v2(struct ncp_server * server, struct file *file, 63ncp_get_fs_info_v2(struct ncp_server * server, struct inode *inode,
69 struct ncp_fs_info_v2 __user * arg) 64 struct ncp_fs_info_v2 __user * arg)
70{ 65{
71 struct inode *inode = file->f_path.dentry->d_inode;
72 struct ncp_fs_info_v2 info2; 66 struct ncp_fs_info_v2 info2;
73 67
74 if (file_permission(file, MAY_WRITE) != 0
75 && current_uid() != server->m.mounted_uid)
76 return -EACCES;
77
78 if (copy_from_user(&info2, arg, sizeof(info2))) 68 if (copy_from_user(&info2, arg, sizeof(info2)))
79 return -EFAULT; 69 return -EFAULT;
80 70
@@ -136,16 +126,11 @@ struct compat_ncp_privatedata_ioctl
136#define NCP_IOC_SETPRIVATEDATA_32 _IOR('n', 10, struct compat_ncp_privatedata_ioctl) 126#define NCP_IOC_SETPRIVATEDATA_32 _IOR('n', 10, struct compat_ncp_privatedata_ioctl)
137 127
138static int 128static int
139ncp_get_compat_fs_info_v2(struct ncp_server * server, struct file *file, 129ncp_get_compat_fs_info_v2(struct ncp_server * server, struct inode *inode,
140 struct compat_ncp_fs_info_v2 __user * arg) 130 struct compat_ncp_fs_info_v2 __user * arg)
141{ 131{
142 struct inode *inode = file->f_path.dentry->d_inode;
143 struct compat_ncp_fs_info_v2 info2; 132 struct compat_ncp_fs_info_v2 info2;
144 133
145 if (file_permission(file, MAY_WRITE) != 0
146 && current_uid() != server->m.mounted_uid)
147 return -EACCES;
148
149 if (copy_from_user(&info2, arg, sizeof(info2))) 134 if (copy_from_user(&info2, arg, sizeof(info2)))
150 return -EFAULT; 135 return -EFAULT;
151 136
@@ -182,11 +167,8 @@ ncp_set_charsets(struct ncp_server* server, struct ncp_nls_ioctl __user *arg)
182 struct nls_table *iocharset; 167 struct nls_table *iocharset;
183 struct nls_table *oldset_io; 168 struct nls_table *oldset_io;
184 struct nls_table *oldset_cp; 169 struct nls_table *oldset_cp;
185 170 int utf8;
186 if (!capable(CAP_SYS_ADMIN)) 171 int err;
187 return -EACCES;
188 if (server->root_setuped)
189 return -EBUSY;
190 172
191 if (copy_from_user(&user, arg, sizeof(user))) 173 if (copy_from_user(&user, arg, sizeof(user)))
192 return -EFAULT; 174 return -EFAULT;
@@ -206,28 +188,40 @@ ncp_set_charsets(struct ncp_server* server, struct ncp_nls_ioctl __user *arg)
206 user.iocharset[NCP_IOCSNAME_LEN] = 0; 188 user.iocharset[NCP_IOCSNAME_LEN] = 0;
207 if (!user.iocharset[0] || !strcmp(user.iocharset, "default")) { 189 if (!user.iocharset[0] || !strcmp(user.iocharset, "default")) {
208 iocharset = load_nls_default(); 190 iocharset = load_nls_default();
209 NCP_CLR_FLAG(server, NCP_FLAG_UTF8); 191 utf8 = 0;
210 } else if (!strcmp(user.iocharset, "utf8")) { 192 } else if (!strcmp(user.iocharset, "utf8")) {
211 iocharset = load_nls_default(); 193 iocharset = load_nls_default();
212 NCP_SET_FLAG(server, NCP_FLAG_UTF8); 194 utf8 = 1;
213 } else { 195 } else {
214 iocharset = load_nls(user.iocharset); 196 iocharset = load_nls(user.iocharset);
215 if (!iocharset) { 197 if (!iocharset) {
216 unload_nls(codepage); 198 unload_nls(codepage);
217 return -EBADRQC; 199 return -EBADRQC;
218 } 200 }
219 NCP_CLR_FLAG(server, NCP_FLAG_UTF8); 201 utf8 = 0;
220 } 202 }
221 203
222 oldset_cp = server->nls_vol; 204 mutex_lock(&server->root_setup_lock);
223 server->nls_vol = codepage; 205 if (server->root_setuped) {
224 oldset_io = server->nls_io; 206 oldset_cp = codepage;
225 server->nls_io = iocharset; 207 oldset_io = iocharset;
226 208 err = -EBUSY;
209 } else {
210 if (utf8)
211 NCP_SET_FLAG(server, NCP_FLAG_UTF8);
212 else
213 NCP_CLR_FLAG(server, NCP_FLAG_UTF8);
214 oldset_cp = server->nls_vol;
215 server->nls_vol = codepage;
216 oldset_io = server->nls_io;
217 server->nls_io = iocharset;
218 err = 0;
219 }
220 mutex_unlock(&server->root_setup_lock);
227 unload_nls(oldset_cp); 221 unload_nls(oldset_cp);
228 unload_nls(oldset_io); 222 unload_nls(oldset_io);
229 223
230 return 0; 224 return err;
231} 225}
232 226
233static int 227static int
@@ -237,6 +231,7 @@ ncp_get_charsets(struct ncp_server* server, struct ncp_nls_ioctl __user *arg)
237 int len; 231 int len;
238 232
239 memset(&user, 0, sizeof(user)); 233 memset(&user, 0, sizeof(user));
234 mutex_lock(&server->root_setup_lock);
240 if (server->nls_vol && server->nls_vol->charset) { 235 if (server->nls_vol && server->nls_vol->charset) {
241 len = strlen(server->nls_vol->charset); 236 len = strlen(server->nls_vol->charset);
242 if (len > NCP_IOCSNAME_LEN) 237 if (len > NCP_IOCSNAME_LEN)
@@ -254,6 +249,7 @@ ncp_get_charsets(struct ncp_server* server, struct ncp_nls_ioctl __user *arg)
254 strncpy(user.iocharset, server->nls_io->charset, len); 249 strncpy(user.iocharset, server->nls_io->charset, len);
255 user.iocharset[len] = 0; 250 user.iocharset[len] = 0;
256 } 251 }
252 mutex_unlock(&server->root_setup_lock);
257 253
258 if (copy_to_user(arg, &user, sizeof(user))) 254 if (copy_to_user(arg, &user, sizeof(user)))
259 return -EFAULT; 255 return -EFAULT;
@@ -261,25 +257,19 @@ ncp_get_charsets(struct ncp_server* server, struct ncp_nls_ioctl __user *arg)
261} 257}
262#endif /* CONFIG_NCPFS_NLS */ 258#endif /* CONFIG_NCPFS_NLS */
263 259
264static long __ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 260static long __ncp_ioctl(struct inode *inode, unsigned int cmd, unsigned long arg)
265{ 261{
266 struct inode *inode = filp->f_dentry->d_inode;
267 struct ncp_server *server = NCP_SERVER(inode); 262 struct ncp_server *server = NCP_SERVER(inode);
268 int result; 263 int result;
269 struct ncp_ioctl_request request; 264 struct ncp_ioctl_request request;
270 char* bouncebuffer; 265 char* bouncebuffer;
271 void __user *argp = (void __user *)arg; 266 void __user *argp = (void __user *)arg;
272 uid_t uid = current_uid();
273 267
274 switch (cmd) { 268 switch (cmd) {
275#ifdef CONFIG_COMPAT 269#ifdef CONFIG_COMPAT
276 case NCP_IOC_NCPREQUEST_32: 270 case NCP_IOC_NCPREQUEST_32:
277#endif 271#endif
278 case NCP_IOC_NCPREQUEST: 272 case NCP_IOC_NCPREQUEST:
279 if (file_permission(filp, MAY_WRITE) != 0
280 && uid != server->m.mounted_uid)
281 return -EACCES;
282
283#ifdef CONFIG_COMPAT 273#ifdef CONFIG_COMPAT
284 if (cmd == NCP_IOC_NCPREQUEST_32) { 274 if (cmd == NCP_IOC_NCPREQUEST_32) {
285 struct compat_ncp_ioctl_request request32; 275 struct compat_ncp_ioctl_request request32;
@@ -314,7 +304,7 @@ static long __ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
314 server->current_size = request.size; 304 server->current_size = request.size;
315 memcpy(server->packet, bouncebuffer, request.size); 305 memcpy(server->packet, bouncebuffer, request.size);
316 306
317 result = ncp_request2(server, request.function, 307 result = ncp_request2(server, request.function,
318 bouncebuffer, NCP_PACKET_SIZE_INTERNAL); 308 bouncebuffer, NCP_PACKET_SIZE_INTERNAL);
319 if (result < 0) 309 if (result < 0)
320 result = -EIO; 310 result = -EIO;
@@ -331,69 +321,69 @@ static long __ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
331 321
332 case NCP_IOC_CONN_LOGGED_IN: 322 case NCP_IOC_CONN_LOGGED_IN:
333 323
334 if (!capable(CAP_SYS_ADMIN))
335 return -EACCES;
336 if (!(server->m.int_flags & NCP_IMOUNT_LOGGEDIN_POSSIBLE)) 324 if (!(server->m.int_flags & NCP_IMOUNT_LOGGEDIN_POSSIBLE))
337 return -EINVAL; 325 return -EINVAL;
326 mutex_lock(&server->root_setup_lock);
338 if (server->root_setuped) 327 if (server->root_setuped)
339 return -EBUSY; 328 result = -EBUSY;
340 server->root_setuped = 1; 329 else {
341 return ncp_conn_logged_in(inode->i_sb); 330 result = ncp_conn_logged_in(inode->i_sb);
331 if (result == 0)
332 server->root_setuped = 1;
333 }
334 mutex_unlock(&server->root_setup_lock);
335 return result;
342 336
343 case NCP_IOC_GET_FS_INFO: 337 case NCP_IOC_GET_FS_INFO:
344 return ncp_get_fs_info(server, filp, argp); 338 return ncp_get_fs_info(server, inode, argp);
345 339
346 case NCP_IOC_GET_FS_INFO_V2: 340 case NCP_IOC_GET_FS_INFO_V2:
347 return ncp_get_fs_info_v2(server, filp, argp); 341 return ncp_get_fs_info_v2(server, inode, argp);
348 342
349#ifdef CONFIG_COMPAT 343#ifdef CONFIG_COMPAT
350 case NCP_IOC_GET_FS_INFO_V2_32: 344 case NCP_IOC_GET_FS_INFO_V2_32:
351 return ncp_get_compat_fs_info_v2(server, filp, argp); 345 return ncp_get_compat_fs_info_v2(server, inode, argp);
352#endif 346#endif
353 /* we have too many combinations of CONFIG_COMPAT, 347 /* we have too many combinations of CONFIG_COMPAT,
354 * CONFIG_64BIT and CONFIG_UID16, so just handle 348 * CONFIG_64BIT and CONFIG_UID16, so just handle
355 * any of the possible ioctls */ 349 * any of the possible ioctls */
356 case NCP_IOC_GETMOUNTUID16: 350 case NCP_IOC_GETMOUNTUID16:
357 case NCP_IOC_GETMOUNTUID32: 351 {
358 case NCP_IOC_GETMOUNTUID64:
359 if (file_permission(filp, MAY_READ) != 0
360 && uid != server->m.mounted_uid)
361 return -EACCES;
362
363 if (cmd == NCP_IOC_GETMOUNTUID16) {
364 u16 uid; 352 u16 uid;
353
365 SET_UID(uid, server->m.mounted_uid); 354 SET_UID(uid, server->m.mounted_uid);
366 if (put_user(uid, (u16 __user *)argp)) 355 if (put_user(uid, (u16 __user *)argp))
367 return -EFAULT; 356 return -EFAULT;
368 } else if (cmd == NCP_IOC_GETMOUNTUID32) { 357 return 0;
369 if (put_user(server->m.mounted_uid,
370 (u32 __user *)argp))
371 return -EFAULT;
372 } else {
373 if (put_user(server->m.mounted_uid,
374 (u64 __user *)argp))
375 return -EFAULT;
376 } 358 }
359 case NCP_IOC_GETMOUNTUID32:
360 if (put_user(server->m.mounted_uid,
361 (u32 __user *)argp))
362 return -EFAULT;
363 return 0;
364 case NCP_IOC_GETMOUNTUID64:
365 if (put_user(server->m.mounted_uid,
366 (u64 __user *)argp))
367 return -EFAULT;
377 return 0; 368 return 0;
378 369
379 case NCP_IOC_GETROOT: 370 case NCP_IOC_GETROOT:
380 { 371 {
381 struct ncp_setroot_ioctl sr; 372 struct ncp_setroot_ioctl sr;
382 373
383 if (file_permission(filp, MAY_READ) != 0 374 result = -EACCES;
384 && uid != server->m.mounted_uid) 375 mutex_lock(&server->root_setup_lock);
385 return -EACCES;
386
387 if (server->m.mounted_vol[0]) { 376 if (server->m.mounted_vol[0]) {
388 struct dentry* dentry = inode->i_sb->s_root; 377 struct dentry* dentry = inode->i_sb->s_root;
389 378
390 if (dentry) { 379 if (dentry) {
391 struct inode* s_inode = dentry->d_inode; 380 struct inode* s_inode = dentry->d_inode;
392 381
393 if (s_inode) { 382 if (s_inode) {
394 sr.volNumber = NCP_FINFO(s_inode)->volNumber; 383 sr.volNumber = NCP_FINFO(s_inode)->volNumber;
395 sr.dirEntNum = NCP_FINFO(s_inode)->dirEntNum; 384 sr.dirEntNum = NCP_FINFO(s_inode)->dirEntNum;
396 sr.namespace = server->name_space[sr.volNumber]; 385 sr.namespace = server->name_space[sr.volNumber];
386 result = 0;
397 } else 387 } else
398 DPRINTK("ncpfs: s_root->d_inode==NULL\n"); 388 DPRINTK("ncpfs: s_root->d_inode==NULL\n");
399 } else 389 } else
@@ -402,10 +392,12 @@ static long __ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
402 sr.volNumber = -1; 392 sr.volNumber = -1;
403 sr.namespace = 0; 393 sr.namespace = 0;
404 sr.dirEntNum = 0; 394 sr.dirEntNum = 0;
395 result = 0;
405 } 396 }
406 if (copy_to_user(argp, &sr, sizeof(sr))) 397 mutex_unlock(&server->root_setup_lock);
407 return -EFAULT; 398 if (!result && copy_to_user(argp, &sr, sizeof(sr)))
408 return 0; 399 result = -EFAULT;
400 return result;
409 } 401 }
410 402
411 case NCP_IOC_SETROOT: 403 case NCP_IOC_SETROOT:
@@ -416,103 +408,114 @@ static long __ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
416 __le32 dosde; 408 __le32 dosde;
417 struct dentry* dentry; 409 struct dentry* dentry;
418 410
419 if (!capable(CAP_SYS_ADMIN))
420 {
421 return -EACCES;
422 }
423 if (server->root_setuped) return -EBUSY;
424 if (copy_from_user(&sr, argp, sizeof(sr))) 411 if (copy_from_user(&sr, argp, sizeof(sr)))
425 return -EFAULT; 412 return -EFAULT;
426 if (sr.volNumber < 0) { 413 mutex_lock(&server->root_setup_lock);
427 server->m.mounted_vol[0] = 0; 414 if (server->root_setuped)
428 vnum = NCP_NUMBER_OF_VOLUMES; 415 result = -EBUSY;
429 de = 0; 416 else {
430 dosde = 0; 417 if (sr.volNumber < 0) {
431 } else if (sr.volNumber >= NCP_NUMBER_OF_VOLUMES) { 418 server->m.mounted_vol[0] = 0;
432 return -EINVAL; 419 vnum = NCP_NUMBER_OF_VOLUMES;
433 } else if (ncp_mount_subdir(server, sr.volNumber, 420 de = 0;
434 sr.namespace, sr.dirEntNum, 421 dosde = 0;
435 &vnum, &de, &dosde)) { 422 result = 0;
436 return -ENOENT; 423 } else if (sr.volNumber >= NCP_NUMBER_OF_VOLUMES) {
437 } 424 result = -EINVAL;
438 425 } else if (ncp_mount_subdir(server, sr.volNumber,
439 dentry = inode->i_sb->s_root; 426 sr.namespace, sr.dirEntNum,
440 server->root_setuped = 1; 427 &vnum, &de, &dosde)) {
441 if (dentry) { 428 result = -ENOENT;
442 struct inode* s_inode = dentry->d_inode;
443
444 if (s_inode) {
445 NCP_FINFO(s_inode)->volNumber = vnum;
446 NCP_FINFO(s_inode)->dirEntNum = de;
447 NCP_FINFO(s_inode)->DosDirNum = dosde;
448 } else 429 } else
449 DPRINTK("ncpfs: s_root->d_inode==NULL\n"); 430 result = 0;
450 } else 431
451 DPRINTK("ncpfs: s_root==NULL\n"); 432 if (result == 0) {
433 dentry = inode->i_sb->s_root;
434 if (dentry) {
435 struct inode* s_inode = dentry->d_inode;
436
437 if (s_inode) {
438 NCP_FINFO(s_inode)->volNumber = vnum;
439 NCP_FINFO(s_inode)->dirEntNum = de;
440 NCP_FINFO(s_inode)->DosDirNum = dosde;
441 server->root_setuped = 1;
442 } else {
443 DPRINTK("ncpfs: s_root->d_inode==NULL\n");
444 result = -EIO;
445 }
446 } else {
447 DPRINTK("ncpfs: s_root==NULL\n");
448 result = -EIO;
449 }
450 }
451 result = 0;
452 }
453 mutex_unlock(&server->root_setup_lock);
452 454
453 return 0; 455 return result;
454 } 456 }
455 457
456#ifdef CONFIG_NCPFS_PACKET_SIGNING 458#ifdef CONFIG_NCPFS_PACKET_SIGNING
457 case NCP_IOC_SIGN_INIT: 459 case NCP_IOC_SIGN_INIT:
458 if (file_permission(filp, MAY_WRITE) != 0 460 {
459 && uid != server->m.mounted_uid) 461 struct ncp_sign_init sign;
460 return -EACCES;
461
462 if (argp) {
463 if (server->sign_wanted)
464 {
465 struct ncp_sign_init sign;
466 462
463 if (argp)
467 if (copy_from_user(&sign, argp, sizeof(sign))) 464 if (copy_from_user(&sign, argp, sizeof(sign)))
468 return -EFAULT; 465 return -EFAULT;
469 memcpy(server->sign_root,sign.sign_root,8); 466 ncp_lock_server(server);
470 memcpy(server->sign_last,sign.sign_last,16); 467 mutex_lock(&server->rcv.creq_mutex);
471 server->sign_active = 1; 468 if (argp) {
469 if (server->sign_wanted) {
470 memcpy(server->sign_root,sign.sign_root,8);
471 memcpy(server->sign_last,sign.sign_last,16);
472 server->sign_active = 1;
473 }
474 /* ignore when signatures not wanted */
475 } else {
476 server->sign_active = 0;
472 } 477 }
473 /* ignore when signatures not wanted */ 478 mutex_unlock(&server->rcv.creq_mutex);
474 } else { 479 ncp_unlock_server(server);
475 server->sign_active = 0; 480 return 0;
476 } 481 }
477 return 0; 482
478
479 case NCP_IOC_SIGN_WANTED: 483 case NCP_IOC_SIGN_WANTED:
480 if (file_permission(filp, MAY_READ) != 0 484 {
481 && uid != server->m.mounted_uid) 485 int state;
482 return -EACCES; 486
483 487 ncp_lock_server(server);
484 if (put_user(server->sign_wanted, (int __user *)argp)) 488 state = server->sign_wanted;
485 return -EFAULT; 489 ncp_unlock_server(server);
486 return 0; 490 if (put_user(state, (int __user *)argp))
491 return -EFAULT;
492 return 0;
493 }
487 494
488 case NCP_IOC_SET_SIGN_WANTED: 495 case NCP_IOC_SET_SIGN_WANTED:
489 { 496 {
490 int newstate; 497 int newstate;
491 498
492 if (file_permission(filp, MAY_WRITE) != 0
493 && uid != server->m.mounted_uid)
494 return -EACCES;
495
496 /* get only low 8 bits... */ 499 /* get only low 8 bits... */
497 if (get_user(newstate, (unsigned char __user *)argp)) 500 if (get_user(newstate, (unsigned char __user *)argp))
498 return -EFAULT; 501 return -EFAULT;
502 result = 0;
503 ncp_lock_server(server);
499 if (server->sign_active) { 504 if (server->sign_active) {
500 /* cannot turn signatures OFF when active */ 505 /* cannot turn signatures OFF when active */
501 if (!newstate) return -EINVAL; 506 if (!newstate)
507 result = -EINVAL;
502 } else { 508 } else {
503 server->sign_wanted = newstate != 0; 509 server->sign_wanted = newstate != 0;
504 } 510 }
505 return 0; 511 ncp_unlock_server(server);
512 return result;
506 } 513 }
507 514
508#endif /* CONFIG_NCPFS_PACKET_SIGNING */ 515#endif /* CONFIG_NCPFS_PACKET_SIGNING */
509 516
510#ifdef CONFIG_NCPFS_IOCTL_LOCKING 517#ifdef CONFIG_NCPFS_IOCTL_LOCKING
511 case NCP_IOC_LOCKUNLOCK: 518 case NCP_IOC_LOCKUNLOCK:
512 if (file_permission(filp, MAY_WRITE) != 0
513 && uid != server->m.mounted_uid)
514 return -EACCES;
515
516 { 519 {
517 struct ncp_lock_ioctl rqdata; 520 struct ncp_lock_ioctl rqdata;
518 521
@@ -541,16 +544,13 @@ static long __ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
541 { 544 {
542 return result; 545 return result;
543 } 546 }
544 result = -EIO;
545 if (!ncp_conn_valid(server))
546 goto outrel;
547 result = -EISDIR; 547 result = -EISDIR;
548 if (!S_ISREG(inode->i_mode)) 548 if (!S_ISREG(inode->i_mode))
549 goto outrel; 549 goto outrel;
550 if (rqdata.cmd == NCP_LOCK_CLEAR) 550 if (rqdata.cmd == NCP_LOCK_CLEAR)
551 { 551 {
552 result = ncp_ClearPhysicalRecord(NCP_SERVER(inode), 552 result = ncp_ClearPhysicalRecord(NCP_SERVER(inode),
553 NCP_FINFO(inode)->file_handle, 553 NCP_FINFO(inode)->file_handle,
554 rqdata.offset, 554 rqdata.offset,
555 rqdata.length); 555 rqdata.length);
556 if (result > 0) result = 0; /* no such lock */ 556 if (result > 0) result = 0; /* no such lock */
@@ -573,7 +573,7 @@ static long __ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
573 rqdata.timeout); 573 rqdata.timeout);
574 if (result > 0) result = -EAGAIN; 574 if (result > 0) result = -EAGAIN;
575 } 575 }
576outrel: 576outrel:
577 ncp_inode_close(inode); 577 ncp_inode_close(inode);
578 return result; 578 return result;
579 } 579 }
@@ -581,60 +581,62 @@ outrel:
581 581
582#ifdef CONFIG_COMPAT 582#ifdef CONFIG_COMPAT
583 case NCP_IOC_GETOBJECTNAME_32: 583 case NCP_IOC_GETOBJECTNAME_32:
584 if (uid != server->m.mounted_uid)
585 return -EACCES;
586 { 584 {
587 struct compat_ncp_objectname_ioctl user; 585 struct compat_ncp_objectname_ioctl user;
588 size_t outl; 586 size_t outl;
589 587
590 if (copy_from_user(&user, argp, sizeof(user))) 588 if (copy_from_user(&user, argp, sizeof(user)))
591 return -EFAULT; 589 return -EFAULT;
590 down_read(&server->auth_rwsem);
592 user.auth_type = server->auth.auth_type; 591 user.auth_type = server->auth.auth_type;
593 outl = user.object_name_len; 592 outl = user.object_name_len;
594 user.object_name_len = server->auth.object_name_len; 593 user.object_name_len = server->auth.object_name_len;
595 if (outl > user.object_name_len) 594 if (outl > user.object_name_len)
596 outl = user.object_name_len; 595 outl = user.object_name_len;
596 result = 0;
597 if (outl) { 597 if (outl) {
598 if (copy_to_user(compat_ptr(user.object_name), 598 if (copy_to_user(compat_ptr(user.object_name),
599 server->auth.object_name, 599 server->auth.object_name,
600 outl)) return -EFAULT; 600 outl))
601 result = -EFAULT;
601 } 602 }
602 if (copy_to_user(argp, &user, sizeof(user))) 603 up_read(&server->auth_rwsem);
603 return -EFAULT; 604 if (!result && copy_to_user(argp, &user, sizeof(user)))
604 return 0; 605 result = -EFAULT;
606 return result;
605 } 607 }
606#endif 608#endif
607 609
608 case NCP_IOC_GETOBJECTNAME: 610 case NCP_IOC_GETOBJECTNAME:
609 if (uid != server->m.mounted_uid)
610 return -EACCES;
611 { 611 {
612 struct ncp_objectname_ioctl user; 612 struct ncp_objectname_ioctl user;
613 size_t outl; 613 size_t outl;
614 614
615 if (copy_from_user(&user, argp, sizeof(user))) 615 if (copy_from_user(&user, argp, sizeof(user)))
616 return -EFAULT; 616 return -EFAULT;
617 down_read(&server->auth_rwsem);
617 user.auth_type = server->auth.auth_type; 618 user.auth_type = server->auth.auth_type;
618 outl = user.object_name_len; 619 outl = user.object_name_len;
619 user.object_name_len = server->auth.object_name_len; 620 user.object_name_len = server->auth.object_name_len;
620 if (outl > user.object_name_len) 621 if (outl > user.object_name_len)
621 outl = user.object_name_len; 622 outl = user.object_name_len;
623 result = 0;
622 if (outl) { 624 if (outl) {
623 if (copy_to_user(user.object_name, 625 if (copy_to_user(user.object_name,
624 server->auth.object_name, 626 server->auth.object_name,
625 outl)) return -EFAULT; 627 outl))
628 result = -EFAULT;
626 } 629 }
627 if (copy_to_user(argp, &user, sizeof(user))) 630 up_read(&server->auth_rwsem);
628 return -EFAULT; 631 if (!result && copy_to_user(argp, &user, sizeof(user)))
629 return 0; 632 result = -EFAULT;
633 return result;
630 } 634 }
631 635
632#ifdef CONFIG_COMPAT 636#ifdef CONFIG_COMPAT
633 case NCP_IOC_SETOBJECTNAME_32: 637 case NCP_IOC_SETOBJECTNAME_32:
634#endif 638#endif
635 case NCP_IOC_SETOBJECTNAME: 639 case NCP_IOC_SETOBJECTNAME:
636 if (uid != server->m.mounted_uid)
637 return -EACCES;
638 { 640 {
639 struct ncp_objectname_ioctl user; 641 struct ncp_objectname_ioctl user;
640 void* newname; 642 void* newname;
@@ -666,9 +668,7 @@ outrel:
666 } else { 668 } else {
667 newname = NULL; 669 newname = NULL;
668 } 670 }
669 /* enter critical section */ 671 down_write(&server->auth_rwsem);
670 /* maybe that kfree can sleep so do that this way */
671 /* it is at least more SMP friendly (in future...) */
672 oldname = server->auth.object_name; 672 oldname = server->auth.object_name;
673 oldnamelen = server->auth.object_name_len; 673 oldnamelen = server->auth.object_name_len;
674 oldprivate = server->priv.data; 674 oldprivate = server->priv.data;
@@ -678,7 +678,7 @@ outrel:
678 server->auth.object_name = newname; 678 server->auth.object_name = newname;
679 server->priv.len = 0; 679 server->priv.len = 0;
680 server->priv.data = NULL; 680 server->priv.data = NULL;
681 /* leave critical section */ 681 up_write(&server->auth_rwsem);
682 kfree(oldprivate); 682 kfree(oldprivate);
683 kfree(oldname); 683 kfree(oldname);
684 return 0; 684 return 0;
@@ -688,8 +688,6 @@ outrel:
688 case NCP_IOC_GETPRIVATEDATA_32: 688 case NCP_IOC_GETPRIVATEDATA_32:
689#endif 689#endif
690 case NCP_IOC_GETPRIVATEDATA: 690 case NCP_IOC_GETPRIVATEDATA:
691 if (uid != server->m.mounted_uid)
692 return -EACCES;
693 { 691 {
694 struct ncp_privatedata_ioctl user; 692 struct ncp_privatedata_ioctl user;
695 size_t outl; 693 size_t outl;
@@ -706,14 +704,20 @@ outrel:
706 if (copy_from_user(&user, argp, sizeof(user))) 704 if (copy_from_user(&user, argp, sizeof(user)))
707 return -EFAULT; 705 return -EFAULT;
708 706
707 down_read(&server->auth_rwsem);
709 outl = user.len; 708 outl = user.len;
710 user.len = server->priv.len; 709 user.len = server->priv.len;
711 if (outl > user.len) outl = user.len; 710 if (outl > user.len) outl = user.len;
711 result = 0;
712 if (outl) { 712 if (outl) {
713 if (copy_to_user(user.data, 713 if (copy_to_user(user.data,
714 server->priv.data, 714 server->priv.data,
715 outl)) return -EFAULT; 715 outl))
716 result = -EFAULT;
716 } 717 }
718 up_read(&server->auth_rwsem);
719 if (result)
720 return result;
717#ifdef CONFIG_COMPAT 721#ifdef CONFIG_COMPAT
718 if (cmd == NCP_IOC_GETPRIVATEDATA_32) { 722 if (cmd == NCP_IOC_GETPRIVATEDATA_32) {
719 struct compat_ncp_privatedata_ioctl user32; 723 struct compat_ncp_privatedata_ioctl user32;
@@ -733,8 +737,6 @@ outrel:
733 case NCP_IOC_SETPRIVATEDATA_32: 737 case NCP_IOC_SETPRIVATEDATA_32:
734#endif 738#endif
735 case NCP_IOC_SETPRIVATEDATA: 739 case NCP_IOC_SETPRIVATEDATA:
736 if (uid != server->m.mounted_uid)
737 return -EACCES;
738 { 740 {
739 struct ncp_privatedata_ioctl user; 741 struct ncp_privatedata_ioctl user;
740 void* new; 742 void* new;
@@ -762,12 +764,12 @@ outrel:
762 } else { 764 } else {
763 new = NULL; 765 new = NULL;
764 } 766 }
765 /* enter critical section */ 767 down_write(&server->auth_rwsem);
766 old = server->priv.data; 768 old = server->priv.data;
767 oldlen = server->priv.len; 769 oldlen = server->priv.len;
768 server->priv.len = user.len; 770 server->priv.len = user.len;
769 server->priv.data = new; 771 server->priv.data = new;
770 /* leave critical section */ 772 up_write(&server->auth_rwsem);
771 kfree(old); 773 kfree(old);
772 return 0; 774 return 0;
773 } 775 }
@@ -775,17 +777,13 @@ outrel:
775#ifdef CONFIG_NCPFS_NLS 777#ifdef CONFIG_NCPFS_NLS
776 case NCP_IOC_SETCHARSETS: 778 case NCP_IOC_SETCHARSETS:
777 return ncp_set_charsets(server, argp); 779 return ncp_set_charsets(server, argp);
778 780
779 case NCP_IOC_GETCHARSETS: 781 case NCP_IOC_GETCHARSETS:
780 return ncp_get_charsets(server, argp); 782 return ncp_get_charsets(server, argp);
781 783
782#endif /* CONFIG_NCPFS_NLS */ 784#endif /* CONFIG_NCPFS_NLS */
783 785
784 case NCP_IOC_SETDENTRYTTL: 786 case NCP_IOC_SETDENTRYTTL:
785 if (file_permission(filp, MAY_WRITE) != 0 &&
786 uid != server->m.mounted_uid)
787 return -EACCES;
788
789 { 787 {
790 u_int32_t user; 788 u_int32_t user;
791 789
@@ -795,13 +793,13 @@ outrel:
795 if (user > 20000) 793 if (user > 20000)
796 return -EINVAL; 794 return -EINVAL;
797 user = (user * HZ) / 1000; 795 user = (user * HZ) / 1000;
798 server->dentry_ttl = user; 796 atomic_set(&server->dentry_ttl, user);
799 return 0; 797 return 0;
800 } 798 }
801 799
802 case NCP_IOC_GETDENTRYTTL: 800 case NCP_IOC_GETDENTRYTTL:
803 { 801 {
804 u_int32_t user = (server->dentry_ttl * 1000) / HZ; 802 u_int32_t user = (atomic_read(&server->dentry_ttl) * 1000) / HZ;
805 if (copy_to_user(argp, &user, sizeof(user))) 803 if (copy_to_user(argp, &user, sizeof(user)))
806 return -EFAULT; 804 return -EFAULT;
807 return 0; 805 return 0;
@@ -811,59 +809,103 @@ outrel:
811 return -EINVAL; 809 return -EINVAL;
812} 810}
813 811
814static int ncp_ioctl_need_write(unsigned int cmd) 812long ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
815{ 813{
814 struct inode *inode = filp->f_dentry->d_inode;
815 struct ncp_server *server = NCP_SERVER(inode);
816 uid_t uid = current_uid();
817 int need_drop_write = 0;
818 long ret;
819
816 switch (cmd) { 820 switch (cmd) {
817 case NCP_IOC_GET_FS_INFO:
818 case NCP_IOC_GET_FS_INFO_V2:
819 case NCP_IOC_NCPREQUEST:
820 case NCP_IOC_SETDENTRYTTL:
821 case NCP_IOC_SIGN_INIT:
822 case NCP_IOC_LOCKUNLOCK:
823 case NCP_IOC_SET_SIGN_WANTED:
824 return 1;
825 case NCP_IOC_GETOBJECTNAME:
826 case NCP_IOC_SETOBJECTNAME:
827 case NCP_IOC_GETPRIVATEDATA:
828 case NCP_IOC_SETPRIVATEDATA:
829 case NCP_IOC_SETCHARSETS: 821 case NCP_IOC_SETCHARSETS:
830 case NCP_IOC_GETCHARSETS:
831 case NCP_IOC_CONN_LOGGED_IN: 822 case NCP_IOC_CONN_LOGGED_IN:
832 case NCP_IOC_GETDENTRYTTL:
833 case NCP_IOC_GETMOUNTUID2:
834 case NCP_IOC_SIGN_WANTED:
835 case NCP_IOC_GETROOT:
836 case NCP_IOC_SETROOT: 823 case NCP_IOC_SETROOT:
837 return 0; 824 if (!capable(CAP_SYS_ADMIN)) {
838 default: 825 ret = -EACCES;
839 /* unknown IOCTL command, assume write */ 826 goto out;
840 return 1; 827 }
828 break;
841 } 829 }
842} 830 if (server->m.mounted_uid != uid) {
843 831 switch (cmd) {
844long ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
845{
846 long ret;
847
848 lock_kernel();
849 if (ncp_ioctl_need_write(cmd)) {
850 /* 832 /*
851 * inside the ioctl(), any failures which 833 * Only mount owner can issue these ioctls. Information
852 * are because of file_permission() are 834 * necessary to authenticate to other NDS servers are
853 * -EACCESS, so it seems consistent to keep 835 * stored here.
854 * that here.
855 */ 836 */
856 if (mnt_want_write(filp->f_path.mnt)) { 837 case NCP_IOC_GETOBJECTNAME:
838 case NCP_IOC_SETOBJECTNAME:
839 case NCP_IOC_GETPRIVATEDATA:
840 case NCP_IOC_SETPRIVATEDATA:
841#ifdef CONFIG_COMPAT
842 case NCP_IOC_GETOBJECTNAME_32:
843 case NCP_IOC_SETOBJECTNAME_32:
844 case NCP_IOC_GETPRIVATEDATA_32:
845 case NCP_IOC_SETPRIVATEDATA_32:
846#endif
857 ret = -EACCES; 847 ret = -EACCES;
858 goto out; 848 goto out;
849 /*
850 * These require write access on the inode if user id
851 * does not match. Note that they do not write to the
852 * file... But old code did mnt_want_write, so I keep
853 * it as is. Of course not for mountpoint owner, as
854 * that breaks read-only mounts altogether as ncpmount
855 * needs working NCP_IOC_NCPREQUEST and
856 * NCP_IOC_GET_FS_INFO. Some of these codes (setdentryttl,
857 * signinit, setsignwanted) should be probably restricted
858 * to owner only, or even more to CAP_SYS_ADMIN).
859 */
860 case NCP_IOC_GET_FS_INFO:
861 case NCP_IOC_GET_FS_INFO_V2:
862 case NCP_IOC_NCPREQUEST:
863 case NCP_IOC_SETDENTRYTTL:
864 case NCP_IOC_SIGN_INIT:
865 case NCP_IOC_LOCKUNLOCK:
866 case NCP_IOC_SET_SIGN_WANTED:
867#ifdef CONFIG_COMPAT
868 case NCP_IOC_GET_FS_INFO_V2_32:
869 case NCP_IOC_NCPREQUEST_32:
870#endif
871 ret = mnt_want_write_file(filp);
872 if (ret)
873 goto out;
874 need_drop_write = 1;
875 ret = inode_permission(inode, MAY_WRITE);
876 if (ret)
877 goto outDropWrite;
878 break;
879 /*
880 * Read access required.
881 */
882 case NCP_IOC_GETMOUNTUID16:
883 case NCP_IOC_GETMOUNTUID32:
884 case NCP_IOC_GETMOUNTUID64:
885 case NCP_IOC_GETROOT:
886 case NCP_IOC_SIGN_WANTED:
887 ret = inode_permission(inode, MAY_READ);
888 if (ret)
889 goto out;
890 break;
891 /*
892 * Anybody can read these.
893 */
894 case NCP_IOC_GETCHARSETS:
895 case NCP_IOC_GETDENTRYTTL:
896 default:
897 /* Three codes below are protected by CAP_SYS_ADMIN above. */
898 case NCP_IOC_SETCHARSETS:
899 case NCP_IOC_CONN_LOGGED_IN:
900 case NCP_IOC_SETROOT:
901 break;
859 } 902 }
860 } 903 }
861 ret = __ncp_ioctl(filp, cmd, arg); 904 ret = __ncp_ioctl(inode, cmd, arg);
862 if (ncp_ioctl_need_write(cmd)) 905outDropWrite:
906 if (need_drop_write)
863 mnt_drop_write(filp->f_path.mnt); 907 mnt_drop_write(filp->f_path.mnt);
864
865out: 908out:
866 unlock_kernel();
867 return ret; 909 return ret;
868} 910}
869 911
@@ -872,10 +914,8 @@ long ncp_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
872{ 914{
873 long ret; 915 long ret;
874 916
875 lock_kernel();
876 arg = (unsigned long) compat_ptr(arg); 917 arg = (unsigned long) compat_ptr(arg);
877 ret = ncp_ioctl(file, cmd, arg); 918 ret = ncp_ioctl(file, cmd, arg);
878 unlock_kernel();
879 return ret; 919 return ret;
880} 920}
881#endif 921#endif
diff --git a/fs/ncpfs/ncplib_kernel.c b/fs/ncpfs/ncplib_kernel.c
index 0ec6237a5970..a95615a0b6ac 100644
--- a/fs/ncpfs/ncplib_kernel.c
+++ b/fs/ncpfs/ncplib_kernel.c
@@ -107,17 +107,17 @@ ncp_reply_data(struct ncp_server *server, int offset)
107 return &(server->packet[sizeof(struct ncp_reply_header) + offset]); 107 return &(server->packet[sizeof(struct ncp_reply_header) + offset]);
108} 108}
109 109
110static inline u8 BVAL(void *data) 110static inline u8 BVAL(const void *data)
111{ 111{
112 return *(u8 *)data; 112 return *(const u8 *)data;
113} 113}
114 114
115static u8 ncp_reply_byte(struct ncp_server *server, int offset) 115static u8 ncp_reply_byte(struct ncp_server *server, int offset)
116{ 116{
117 return *(u8 *)ncp_reply_data(server, offset); 117 return *(const u8 *)ncp_reply_data(server, offset);
118} 118}
119 119
120static inline u16 WVAL_LH(void *data) 120static inline u16 WVAL_LH(const void *data)
121{ 121{
122 return get_unaligned_le16(data); 122 return get_unaligned_le16(data);
123} 123}
@@ -134,7 +134,7 @@ ncp_reply_be16(struct ncp_server *server, int offset)
134 return get_unaligned_be16(ncp_reply_data(server, offset)); 134 return get_unaligned_be16(ncp_reply_data(server, offset));
135} 135}
136 136
137static inline u32 DVAL_LH(void *data) 137static inline u32 DVAL_LH(const void *data)
138{ 138{
139 return get_unaligned_le32(data); 139 return get_unaligned_le32(data);
140} 140}
@@ -349,9 +349,9 @@ int ncp_dirhandle_free(struct ncp_server* server, __u8 dirhandle) {
349 return result; 349 return result;
350} 350}
351 351
352void ncp_extract_file_info(void *structure, struct nw_info_struct *target) 352void ncp_extract_file_info(const void *structure, struct nw_info_struct *target)
353{ 353{
354 __u8 *name_len; 354 const __u8 *name_len;
355 const int info_struct_size = offsetof(struct nw_info_struct, nameLen); 355 const int info_struct_size = offsetof(struct nw_info_struct, nameLen);
356 356
357 memcpy(target, structure, info_struct_size); 357 memcpy(target, structure, info_struct_size);
@@ -364,7 +364,7 @@ void ncp_extract_file_info(void *structure, struct nw_info_struct *target)
364} 364}
365 365
366#ifdef CONFIG_NCPFS_NFS_NS 366#ifdef CONFIG_NCPFS_NFS_NS
367static inline void ncp_extract_nfs_info(unsigned char *structure, 367static inline void ncp_extract_nfs_info(const unsigned char *structure,
368 struct nw_nfs_info *target) 368 struct nw_nfs_info *target)
369{ 369{
370 target->mode = DVAL_LH(structure); 370 target->mode = DVAL_LH(structure);
@@ -417,7 +417,7 @@ int ncp_obtain_nfs_info(struct ncp_server *server,
417 * Returns information for a (one-component) name relative to 417 * Returns information for a (one-component) name relative to
418 * the specified directory. 418 * the specified directory.
419 */ 419 */
420int ncp_obtain_info(struct ncp_server *server, struct inode *dir, char *path, 420int ncp_obtain_info(struct ncp_server *server, struct inode *dir, const char *path,
421 struct nw_info_struct *target) 421 struct nw_info_struct *target)
422{ 422{
423 __u8 volnum = NCP_FINFO(dir)->volNumber; 423 __u8 volnum = NCP_FINFO(dir)->volNumber;
@@ -452,16 +452,16 @@ out:
452#ifdef CONFIG_NCPFS_NFS_NS 452#ifdef CONFIG_NCPFS_NFS_NS
453static int 453static int
454ncp_obtain_DOS_dir_base(struct ncp_server *server, 454ncp_obtain_DOS_dir_base(struct ncp_server *server,
455 __u8 volnum, __le32 dirent, 455 __u8 ns, __u8 volnum, __le32 dirent,
456 char *path, /* At most 1 component */ 456 const char *path, /* At most 1 component */
457 __le32 *DOS_dir_base) 457 __le32 *DOS_dir_base)
458{ 458{
459 int result; 459 int result;
460 460
461 ncp_init_request(server); 461 ncp_init_request(server);
462 ncp_add_byte(server, 6); /* subfunction */ 462 ncp_add_byte(server, 6); /* subfunction */
463 ncp_add_byte(server, server->name_space[volnum]); 463 ncp_add_byte(server, ns);
464 ncp_add_byte(server, server->name_space[volnum]); 464 ncp_add_byte(server, ns);
465 ncp_add_word(server, cpu_to_le16(0x8006)); /* get all */ 465 ncp_add_word(server, cpu_to_le16(0x8006)); /* get all */
466 ncp_add_dword(server, RIM_DIRECTORY); 466 ncp_add_dword(server, RIM_DIRECTORY);
467 ncp_add_handle_path(server, volnum, dirent, 1, path); 467 ncp_add_handle_path(server, volnum, dirent, 1, path);
@@ -523,10 +523,27 @@ ncp_get_known_namespace(struct ncp_server *server, __u8 volume)
523#endif /* defined(CONFIG_NCPFS_OS2_NS) || defined(CONFIG_NCPFS_NFS_NS) */ 523#endif /* defined(CONFIG_NCPFS_OS2_NS) || defined(CONFIG_NCPFS_NFS_NS) */
524} 524}
525 525
526int
527ncp_update_known_namespace(struct ncp_server *server, __u8 volume, int *ret_ns)
528{
529 int ns = ncp_get_known_namespace(server, volume);
530
531 if (ret_ns)
532 *ret_ns = ns;
533
534 DPRINTK("lookup_vol: namespace[%d] = %d\n",
535 volume, server->name_space[volume]);
536
537 if (server->name_space[volume] == ns)
538 return 0;
539 server->name_space[volume] = ns;
540 return 1;
541}
542
526static int 543static int
527ncp_ObtainSpecificDirBase(struct ncp_server *server, 544ncp_ObtainSpecificDirBase(struct ncp_server *server,
528 __u8 nsSrc, __u8 nsDst, __u8 vol_num, __le32 dir_base, 545 __u8 nsSrc, __u8 nsDst, __u8 vol_num, __le32 dir_base,
529 char *path, /* At most 1 component */ 546 const char *path, /* At most 1 component */
530 __le32 *dirEntNum, __le32 *DosDirNum) 547 __le32 *dirEntNum, __le32 *DosDirNum)
531{ 548{
532 int result; 549 int result;
@@ -560,14 +577,13 @@ ncp_mount_subdir(struct ncp_server *server,
560{ 577{
561 int dstNS; 578 int dstNS;
562 int result; 579 int result;
563 580
564 dstNS = ncp_get_known_namespace(server, volNumber); 581 ncp_update_known_namespace(server, volNumber, &dstNS);
565 if ((result = ncp_ObtainSpecificDirBase(server, srcNS, dstNS, volNumber, 582 if ((result = ncp_ObtainSpecificDirBase(server, srcNS, dstNS, volNumber,
566 dirEntNum, NULL, newDirEnt, newDosEnt)) != 0) 583 dirEntNum, NULL, newDirEnt, newDosEnt)) != 0)
567 { 584 {
568 return result; 585 return result;
569 } 586 }
570 server->name_space[volNumber] = dstNS;
571 *volume = volNumber; 587 *volume = volNumber;
572 server->m.mounted_vol[1] = 0; 588 server->m.mounted_vol[1] = 0;
573 server->m.mounted_vol[0] = 'X'; 589 server->m.mounted_vol[0] = 'X';
@@ -575,11 +591,10 @@ ncp_mount_subdir(struct ncp_server *server,
575} 591}
576 592
577int 593int
578ncp_get_volume_root(struct ncp_server *server, const char *volname, 594ncp_get_volume_root(struct ncp_server *server,
579 __u32* volume, __le32* dirent, __le32* dosdirent) 595 const char *volname, __u32* volume, __le32* dirent, __le32* dosdirent)
580{ 596{
581 int result; 597 int result;
582 __u8 volnum;
583 598
584 DPRINTK("ncp_get_volume_root: looking up vol %s\n", volname); 599 DPRINTK("ncp_get_volume_root: looking up vol %s\n", volname);
585 600
@@ -601,21 +616,14 @@ ncp_get_volume_root(struct ncp_server *server, const char *volname,
601 return result; 616 return result;
602 } 617 }
603 *dirent = *dosdirent = ncp_reply_dword(server, 4); 618 *dirent = *dosdirent = ncp_reply_dword(server, 4);
604 volnum = ncp_reply_byte(server, 8); 619 *volume = ncp_reply_byte(server, 8);
605 ncp_unlock_server(server); 620 ncp_unlock_server(server);
606 *volume = volnum;
607
608 server->name_space[volnum] = ncp_get_known_namespace(server, volnum);
609
610 DPRINTK("lookup_vol: namespace[%d] = %d\n",
611 volnum, server->name_space[volnum]);
612
613 return 0; 621 return 0;
614} 622}
615 623
616int 624int
617ncp_lookup_volume(struct ncp_server *server, const char *volname, 625ncp_lookup_volume(struct ncp_server *server,
618 struct nw_info_struct *target) 626 const char *volname, struct nw_info_struct *target)
619{ 627{
620 int result; 628 int result;
621 629
@@ -625,6 +633,7 @@ ncp_lookup_volume(struct ncp_server *server, const char *volname,
625 if (result) { 633 if (result) {
626 return result; 634 return result;
627 } 635 }
636 ncp_update_known_namespace(server, target->volNumber, NULL);
628 target->nameLen = strlen(volname); 637 target->nameLen = strlen(volname);
629 memcpy(target->entryName, volname, target->nameLen+1); 638 memcpy(target->entryName, volname, target->nameLen+1);
630 target->attributes = aDIR; 639 target->attributes = aDIR;
@@ -676,8 +685,8 @@ int ncp_modify_nfs_info(struct ncp_server *server, __u8 volnum, __le32 dirent,
676{ 685{
677 int result = 0; 686 int result = 0;
678 687
688 ncp_init_request(server);
679 if (server->name_space[volnum] == NW_NS_NFS) { 689 if (server->name_space[volnum] == NW_NS_NFS) {
680 ncp_init_request(server);
681 ncp_add_byte(server, 25); /* subfunction */ 690 ncp_add_byte(server, 25); /* subfunction */
682 ncp_add_byte(server, server->name_space[volnum]); 691 ncp_add_byte(server, server->name_space[volnum]);
683 ncp_add_byte(server, NW_NS_NFS); 692 ncp_add_byte(server, NW_NS_NFS);
@@ -690,8 +699,8 @@ int ncp_modify_nfs_info(struct ncp_server *server, __u8 volnum, __le32 dirent,
690 ncp_add_dword_lh(server, 1); /* nlinks */ 699 ncp_add_dword_lh(server, 1); /* nlinks */
691 ncp_add_dword_lh(server, rdev); 700 ncp_add_dword_lh(server, rdev);
692 result = ncp_request(server, 87); 701 result = ncp_request(server, 87);
693 ncp_unlock_server(server);
694 } 702 }
703 ncp_unlock_server(server);
695 return result; 704 return result;
696} 705}
697#endif 706#endif
@@ -700,7 +709,7 @@ int ncp_modify_nfs_info(struct ncp_server *server, __u8 volnum, __le32 dirent,
700static int 709static int
701ncp_DeleteNSEntry(struct ncp_server *server, 710ncp_DeleteNSEntry(struct ncp_server *server,
702 __u8 have_dir_base, __u8 volnum, __le32 dirent, 711 __u8 have_dir_base, __u8 volnum, __le32 dirent,
703 char* name, __u8 ns, __le16 attr) 712 const char* name, __u8 ns, __le16 attr)
704{ 713{
705 int result; 714 int result;
706 715
@@ -734,23 +743,25 @@ ncp_del_file_or_subdir2(struct ncp_server *server,
734 743
735int 744int
736ncp_del_file_or_subdir(struct ncp_server *server, 745ncp_del_file_or_subdir(struct ncp_server *server,
737 struct inode *dir, char *name) 746 struct inode *dir, const char *name)
738{ 747{
739 __u8 volnum = NCP_FINFO(dir)->volNumber; 748 __u8 volnum = NCP_FINFO(dir)->volNumber;
740 __le32 dirent = NCP_FINFO(dir)->dirEntNum; 749 __le32 dirent = NCP_FINFO(dir)->dirEntNum;
750 int name_space;
741 751
752 name_space = server->name_space[volnum];
742#ifdef CONFIG_NCPFS_NFS_NS 753#ifdef CONFIG_NCPFS_NFS_NS
743 if (server->name_space[volnum]==NW_NS_NFS) 754 if (name_space == NW_NS_NFS)
744 { 755 {
745 int result; 756 int result;
746 757
747 result=ncp_obtain_DOS_dir_base(server, volnum, dirent, name, &dirent); 758 result=ncp_obtain_DOS_dir_base(server, name_space, volnum, dirent, name, &dirent);
748 if (result) return result; 759 if (result) return result;
749 return ncp_DeleteNSEntry(server, 1, volnum, dirent, NULL, NW_NS_DOS, cpu_to_le16(0x8006)); 760 name = NULL;
761 name_space = NW_NS_DOS;
750 } 762 }
751 else
752#endif /* CONFIG_NCPFS_NFS_NS */ 763#endif /* CONFIG_NCPFS_NFS_NS */
753 return ncp_DeleteNSEntry(server, 1, volnum, dirent, name, server->name_space[volnum], cpu_to_le16(0x8006)); 764 return ncp_DeleteNSEntry(server, 1, volnum, dirent, name, name_space, cpu_to_le16(0x8006));
754} 765}
755 766
756static inline void ConvertToNWfromDWORD(__u16 v0, __u16 v1, __u8 ret[6]) 767static inline void ConvertToNWfromDWORD(__u16 v0, __u16 v1, __u8 ret[6])
@@ -765,7 +776,7 @@ static inline void ConvertToNWfromDWORD(__u16 v0, __u16 v1, __u8 ret[6])
765/* If both dir and name are NULL, then in target there's already a 776/* If both dir and name are NULL, then in target there's already a
766 looked-up entry that wants to be opened. */ 777 looked-up entry that wants to be opened. */
767int ncp_open_create_file_or_subdir(struct ncp_server *server, 778int ncp_open_create_file_or_subdir(struct ncp_server *server,
768 struct inode *dir, char *name, 779 struct inode *dir, const char *name,
769 int open_create_mode, 780 int open_create_mode,
770 __le32 create_attributes, 781 __le32 create_attributes,
771 __le16 desired_acc_rights, 782 __le16 desired_acc_rights,
@@ -890,8 +901,8 @@ int ncp_search_for_fileset(struct ncp_server *server,
890 901
891static int 902static int
892ncp_RenameNSEntry(struct ncp_server *server, 903ncp_RenameNSEntry(struct ncp_server *server,
893 struct inode *old_dir, char *old_name, __le16 old_type, 904 struct inode *old_dir, const char *old_name, __le16 old_type,
894 struct inode *new_dir, char *new_name) 905 struct inode *new_dir, const char *new_name)
895{ 906{
896 int result = -EINVAL; 907 int result = -EINVAL;
897 908
@@ -929,8 +940,8 @@ out:
929} 940}
930 941
931int ncp_ren_or_mov_file_or_subdir(struct ncp_server *server, 942int ncp_ren_or_mov_file_or_subdir(struct ncp_server *server,
932 struct inode *old_dir, char *old_name, 943 struct inode *old_dir, const char *old_name,
933 struct inode *new_dir, char *new_name) 944 struct inode *new_dir, const char *new_name)
934{ 945{
935 int result; 946 int result;
936 __le16 old_type = cpu_to_le16(0x06); 947 __le16 old_type = cpu_to_le16(0x06);
@@ -958,7 +969,7 @@ int
958ncp_read_kernel(struct ncp_server *server, const char *file_id, 969ncp_read_kernel(struct ncp_server *server, const char *file_id,
959 __u32 offset, __u16 to_read, char *target, int *bytes_read) 970 __u32 offset, __u16 to_read, char *target, int *bytes_read)
960{ 971{
961 char *source; 972 const char *source;
962 int result; 973 int result;
963 974
964 ncp_init_request(server); 975 ncp_init_request(server);
diff --git a/fs/ncpfs/ncplib_kernel.h b/fs/ncpfs/ncplib_kernel.h
index 2441d1ab57dc..3c57eca634ce 100644
--- a/fs/ncpfs/ncplib_kernel.h
+++ b/fs/ncpfs/ncplib_kernel.h
@@ -65,10 +65,11 @@ static inline void ncp_inode_close(struct inode *inode) {
65 atomic_dec(&NCP_FINFO(inode)->opened); 65 atomic_dec(&NCP_FINFO(inode)->opened);
66} 66}
67 67
68void ncp_extract_file_info(void* src, struct nw_info_struct* target); 68void ncp_extract_file_info(const void* src, struct nw_info_struct* target);
69int ncp_obtain_info(struct ncp_server *server, struct inode *, char *, 69int ncp_obtain_info(struct ncp_server *server, struct inode *, const char *,
70 struct nw_info_struct *target); 70 struct nw_info_struct *target);
71int ncp_obtain_nfs_info(struct ncp_server *server, struct nw_info_struct *target); 71int ncp_obtain_nfs_info(struct ncp_server *server, struct nw_info_struct *target);
72int ncp_update_known_namespace(struct ncp_server *server, __u8 volume, int *ret_ns);
72int ncp_get_volume_root(struct ncp_server *server, const char *volname, 73int ncp_get_volume_root(struct ncp_server *server, const char *volname,
73 __u32 *volume, __le32 *dirent, __le32 *dosdirent); 74 __u32 *volume, __le32 *dirent, __le32 *dosdirent);
74int ncp_lookup_volume(struct ncp_server *, const char *, struct nw_info_struct *); 75int ncp_lookup_volume(struct ncp_server *, const char *, struct nw_info_struct *);
@@ -80,8 +81,8 @@ int ncp_modify_nfs_info(struct ncp_server *, __u8 volnum, __le32 dirent,
80 __u32 mode, __u32 rdev); 81 __u32 mode, __u32 rdev);
81 82
82int ncp_del_file_or_subdir2(struct ncp_server *, struct dentry*); 83int ncp_del_file_or_subdir2(struct ncp_server *, struct dentry*);
83int ncp_del_file_or_subdir(struct ncp_server *, struct inode *, char *); 84int ncp_del_file_or_subdir(struct ncp_server *, struct inode *, const char *);
84int ncp_open_create_file_or_subdir(struct ncp_server *, struct inode *, char *, 85int ncp_open_create_file_or_subdir(struct ncp_server *, struct inode *, const char *,
85 int, __le32, __le16, struct ncp_entry_info *); 86 int, __le32, __le16, struct ncp_entry_info *);
86 87
87int ncp_initialize_search(struct ncp_server *, struct inode *, 88int ncp_initialize_search(struct ncp_server *, struct inode *,
@@ -93,7 +94,7 @@ int ncp_search_for_fileset(struct ncp_server *server,
93 char** rbuf, size_t* rsize); 94 char** rbuf, size_t* rsize);
94 95
95int ncp_ren_or_mov_file_or_subdir(struct ncp_server *server, 96int ncp_ren_or_mov_file_or_subdir(struct ncp_server *server,
96 struct inode *, char *, struct inode *, char *); 97 struct inode *, const char *, struct inode *, const char *);
97 98
98 99
99int 100int
@@ -170,13 +171,13 @@ static inline int ncp_strnicmp(struct nls_table *t, const unsigned char *s1,
170#endif /* CONFIG_NCPFS_NLS */ 171#endif /* CONFIG_NCPFS_NLS */
171 172
172#define NCP_GET_AGE(dentry) (jiffies - (dentry)->d_time) 173#define NCP_GET_AGE(dentry) (jiffies - (dentry)->d_time)
173#define NCP_MAX_AGE(server) ((server)->dentry_ttl) 174#define NCP_MAX_AGE(server) atomic_read(&(server)->dentry_ttl)
174#define NCP_TEST_AGE(server,dentry) (NCP_GET_AGE(dentry) < NCP_MAX_AGE(server)) 175#define NCP_TEST_AGE(server,dentry) (NCP_GET_AGE(dentry) < NCP_MAX_AGE(server))
175 176
176static inline void 177static inline void
177ncp_age_dentry(struct ncp_server* server, struct dentry* dentry) 178ncp_age_dentry(struct ncp_server* server, struct dentry* dentry)
178{ 179{
179 dentry->d_time = jiffies - server->dentry_ttl; 180 dentry->d_time = jiffies - NCP_MAX_AGE(server);
180} 181}
181 182
182static inline void 183static inline void
diff --git a/fs/ncpfs/ncpsign_kernel.c b/fs/ncpfs/ncpsign_kernel.c
index 7c0b5c21e6cf..d8b2d7e6910b 100644
--- a/fs/ncpfs/ncpsign_kernel.c
+++ b/fs/ncpfs/ncpsign_kernel.c
@@ -15,21 +15,21 @@
15 15
16/* i386: 32-bit, little endian, handles mis-alignment */ 16/* i386: 32-bit, little endian, handles mis-alignment */
17#ifdef __i386__ 17#ifdef __i386__
18#define GET_LE32(p) (*(int *)(p)) 18#define GET_LE32(p) (*(const int *)(p))
19#define PUT_LE32(p,v) { *(int *)(p)=v; } 19#define PUT_LE32(p,v) { *(int *)(p)=v; }
20#else 20#else
21/* from include/ncplib.h */ 21/* from include/ncplib.h */
22#define BVAL(buf,pos) (((__u8 *)(buf))[pos]) 22#define BVAL(buf,pos) (((const __u8 *)(buf))[pos])
23#define PVAL(buf,pos) ((unsigned)BVAL(buf,pos)) 23#define PVAL(buf,pos) ((unsigned)BVAL(buf,pos))
24#define BSET(buf,pos,val) (BVAL(buf,pos) = (val)) 24#define BSET(buf,pos,val) (((__u8 *)(buf))[pos] = (val))
25 25
26static inline __u16 26static inline __u16
27WVAL_LH(__u8 * buf, int pos) 27WVAL_LH(const __u8 * buf, int pos)
28{ 28{
29 return PVAL(buf, pos) | PVAL(buf, pos + 1) << 8; 29 return PVAL(buf, pos) | PVAL(buf, pos + 1) << 8;
30} 30}
31static inline __u32 31static inline __u32
32DVAL_LH(__u8 * buf, int pos) 32DVAL_LH(const __u8 * buf, int pos)
33{ 33{
34 return WVAL_LH(buf, pos) | WVAL_LH(buf, pos + 2) << 16; 34 return WVAL_LH(buf, pos) | WVAL_LH(buf, pos + 2) << 16;
35} 35}
diff --git a/fs/ncpfs/sock.c b/fs/ncpfs/sock.c
index c7ff6c700a6e..668bd267346e 100644
--- a/fs/ncpfs/sock.c
+++ b/fs/ncpfs/sock.c
@@ -746,7 +746,6 @@ static int ncp_do_request(struct ncp_server *server, int size,
746 return -EIO; 746 return -EIO;
747 } 747 }
748 if (!ncp_conn_valid(server)) { 748 if (!ncp_conn_valid(server)) {
749 printk(KERN_ERR "ncpfs: Connection invalid!\n");
750 return -EIO; 749 return -EIO;
751 } 750 }
752 { 751 {
diff --git a/fs/nfs/Kconfig b/fs/nfs/Kconfig
index f7e13db613cb..b950415d7c43 100644
--- a/fs/nfs/Kconfig
+++ b/fs/nfs/Kconfig
@@ -1,6 +1,7 @@
1config NFS_FS 1config NFS_FS
2 tristate "NFS client support" 2 tristate "NFS client support"
3 depends on INET && FILE_LOCKING 3 depends on INET && FILE_LOCKING
4 depends on BKL # fix as soon as lockd is done
4 select LOCKD 5 select LOCKD
5 select SUNRPC 6 select SUNRPC
6 select NFS_ACL_SUPPORT if NFS_V3_ACL 7 select NFS_ACL_SUPPORT if NFS_V3_ACL
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index b9c3c43cea1d..232a7eead33a 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -71,20 +71,20 @@ static int nfs_delegation_claim_locks(struct nfs_open_context *ctx, struct nfs4_
71 if (inode->i_flock == NULL) 71 if (inode->i_flock == NULL)
72 goto out; 72 goto out;
73 73
74 /* Protect inode->i_flock using the BKL */ 74 /* Protect inode->i_flock using the file locks lock */
75 lock_kernel(); 75 lock_flocks();
76 for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) { 76 for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) {
77 if (!(fl->fl_flags & (FL_POSIX|FL_FLOCK))) 77 if (!(fl->fl_flags & (FL_POSIX|FL_FLOCK)))
78 continue; 78 continue;
79 if (nfs_file_open_context(fl->fl_file) != ctx) 79 if (nfs_file_open_context(fl->fl_file) != ctx)
80 continue; 80 continue;
81 unlock_kernel(); 81 unlock_flocks();
82 status = nfs4_lock_delegation_recall(state, fl); 82 status = nfs4_lock_delegation_recall(state, fl);
83 if (status < 0) 83 if (status < 0)
84 goto out; 84 goto out;
85 lock_kernel(); 85 lock_flocks();
86 } 86 }
87 unlock_kernel(); 87 unlock_flocks();
88out: 88out:
89 return status; 89 return status;
90} 90}
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 3e2f19b04c06..96524c5dca6b 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -40,7 +40,7 @@
40 40
41#include <linux/kernel.h> 41#include <linux/kernel.h>
42#include <linux/slab.h> 42#include <linux/slab.h>
43#include <linux/smp_lock.h> 43#include <linux/fs.h>
44#include <linux/nfs_fs.h> 44#include <linux/nfs_fs.h>
45#include <linux/nfs_idmap.h> 45#include <linux/nfs_idmap.h>
46#include <linux/kthread.h> 46#include <linux/kthread.h>
@@ -970,13 +970,13 @@ static int nfs4_reclaim_locks(struct nfs4_state *state, const struct nfs4_state_
970 /* Guard against delegation returns and new lock/unlock calls */ 970 /* Guard against delegation returns and new lock/unlock calls */
971 down_write(&nfsi->rwsem); 971 down_write(&nfsi->rwsem);
972 /* Protect inode->i_flock using the BKL */ 972 /* Protect inode->i_flock using the BKL */
973 lock_kernel(); 973 lock_flocks();
974 for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) { 974 for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) {
975 if (!(fl->fl_flags & (FL_POSIX|FL_FLOCK))) 975 if (!(fl->fl_flags & (FL_POSIX|FL_FLOCK)))
976 continue; 976 continue;
977 if (nfs_file_open_context(fl->fl_file)->state != state) 977 if (nfs_file_open_context(fl->fl_file)->state != state)
978 continue; 978 continue;
979 unlock_kernel(); 979 unlock_flocks();
980 status = ops->recover_lock(state, fl); 980 status = ops->recover_lock(state, fl);
981 switch (status) { 981 switch (status) {
982 case 0: 982 case 0:
@@ -1003,9 +1003,9 @@ static int nfs4_reclaim_locks(struct nfs4_state *state, const struct nfs4_state_
1003 /* kill_proc(fl->fl_pid, SIGLOST, 1); */ 1003 /* kill_proc(fl->fl_pid, SIGLOST, 1); */
1004 status = 0; 1004 status = 0;
1005 } 1005 }
1006 lock_kernel(); 1006 lock_flocks();
1007 } 1007 }
1008 unlock_kernel(); 1008 unlock_flocks();
1009out: 1009out:
1010 up_write(&nfsi->rwsem); 1010 up_write(&nfsi->rwsem);
1011 return status; 1011 return status;
diff --git a/fs/nfsd/Kconfig b/fs/nfsd/Kconfig
index 4264377552e2..7cf4ddafb4ab 100644
--- a/fs/nfsd/Kconfig
+++ b/fs/nfsd/Kconfig
@@ -2,6 +2,7 @@ config NFSD
2 tristate "NFS server support" 2 tristate "NFS server support"
3 depends on INET 3 depends on INET
4 depends on FILE_LOCKING 4 depends on FILE_LOCKING
5 depends on BKL # fix as soon as lockd is done
5 select LOCKD 6 select LOCKD
6 select SUNRPC 7 select SUNRPC
7 select EXPORTFS 8 select EXPORTFS
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index cf0d2ffb3c84..a7292fcf7718 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -33,7 +33,7 @@
33*/ 33*/
34 34
35#include <linux/file.h> 35#include <linux/file.h>
36#include <linux/smp_lock.h> 36#include <linux/fs.h>
37#include <linux/slab.h> 37#include <linux/slab.h>
38#include <linux/namei.h> 38#include <linux/namei.h>
39#include <linux/swap.h> 39#include <linux/swap.h>
@@ -3895,7 +3895,7 @@ check_for_locks(struct nfs4_file *filp, struct nfs4_stateowner *lowner)
3895 struct inode *inode = filp->fi_inode; 3895 struct inode *inode = filp->fi_inode;
3896 int status = 0; 3896 int status = 0;
3897 3897
3898 lock_kernel(); 3898 lock_flocks();
3899 for (flpp = &inode->i_flock; *flpp != NULL; flpp = &(*flpp)->fl_next) { 3899 for (flpp = &inode->i_flock; *flpp != NULL; flpp = &(*flpp)->fl_next) {
3900 if ((*flpp)->fl_owner == (fl_owner_t)lowner) { 3900 if ((*flpp)->fl_owner == (fl_owner_t)lowner) {
3901 status = 1; 3901 status = 1;
@@ -3903,7 +3903,7 @@ check_for_locks(struct nfs4_file *filp, struct nfs4_stateowner *lowner)
3903 } 3903 }
3904 } 3904 }
3905out: 3905out:
3906 unlock_kernel(); 3906 unlock_flocks();
3907 return status; 3907 return status;
3908} 3908}
3909 3909
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index b53b1d042f1f..06fa87e52e82 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -137,6 +137,7 @@ static const struct file_operations transaction_ops = {
137 .write = nfsctl_transaction_write, 137 .write = nfsctl_transaction_write,
138 .read = nfsctl_transaction_read, 138 .read = nfsctl_transaction_read,
139 .release = simple_transaction_release, 139 .release = simple_transaction_release,
140 .llseek = default_llseek,
140}; 141};
141 142
142static int exports_open(struct inode *inode, struct file *file) 143static int exports_open(struct inode *inode, struct file *file)
diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c
index f90a33d9a5b0..0442ee3b394f 100644
--- a/fs/nilfs2/ioctl.c
+++ b/fs/nilfs2/ioctl.c
@@ -22,7 +22,6 @@
22 22
23#include <linux/fs.h> 23#include <linux/fs.h>
24#include <linux/wait.h> 24#include <linux/wait.h>
25#include <linux/smp_lock.h> /* lock_kernel(), unlock_kernel() */
26#include <linux/slab.h> 25#include <linux/slab.h>
27#include <linux/capability.h> /* capable() */ 26#include <linux/capability.h> /* capable() */
28#include <linux/uaccess.h> /* copy_from_user(), copy_to_user() */ 27#include <linux/uaccess.h> /* copy_from_user(), copy_to_user() */
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index 922263393c76..9f4913f78408 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -45,7 +45,6 @@
45#include <linux/parser.h> 45#include <linux/parser.h>
46#include <linux/random.h> 46#include <linux/random.h>
47#include <linux/crc32.h> 47#include <linux/crc32.h>
48#include <linux/smp_lock.h>
49#include <linux/vfs.h> 48#include <linux/vfs.h>
50#include <linux/writeback.h> 49#include <linux/writeback.h>
51#include <linux/kobject.h> 50#include <linux/kobject.h>
@@ -342,8 +341,6 @@ static void nilfs_put_super(struct super_block *sb)
342 struct nilfs_sb_info *sbi = NILFS_SB(sb); 341 struct nilfs_sb_info *sbi = NILFS_SB(sb);
343 struct the_nilfs *nilfs = sbi->s_nilfs; 342 struct the_nilfs *nilfs = sbi->s_nilfs;
344 343
345 lock_kernel();
346
347 nilfs_detach_segment_constructor(sbi); 344 nilfs_detach_segment_constructor(sbi);
348 345
349 if (!(sb->s_flags & MS_RDONLY)) { 346 if (!(sb->s_flags & MS_RDONLY)) {
@@ -361,8 +358,6 @@ static void nilfs_put_super(struct super_block *sb)
361 sbi->s_super = NULL; 358 sbi->s_super = NULL;
362 sb->s_fs_info = NULL; 359 sb->s_fs_info = NULL;
363 nilfs_put_sbinfo(sbi); 360 nilfs_put_sbinfo(sbi);
364
365 unlock_kernel();
366} 361}
367 362
368static int nilfs_sync_fs(struct super_block *sb, int wait) 363static int nilfs_sync_fs(struct super_block *sb, int wait)
@@ -949,8 +944,6 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data)
949 struct nilfs_mount_options old_opts; 944 struct nilfs_mount_options old_opts;
950 int was_snapshot, err; 945 int was_snapshot, err;
951 946
952 lock_kernel();
953
954 down_write(&nilfs->ns_super_sem); 947 down_write(&nilfs->ns_super_sem);
955 old_sb_flags = sb->s_flags; 948 old_sb_flags = sb->s_flags;
956 old_opts.mount_opt = sbi->s_mount_opt; 949 old_opts.mount_opt = sbi->s_mount_opt;
@@ -1024,7 +1017,6 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data)
1024 } 1017 }
1025 out: 1018 out:
1026 up_write(&nilfs->ns_super_sem); 1019 up_write(&nilfs->ns_super_sem);
1027 unlock_kernel();
1028 return 0; 1020 return 0;
1029 1021
1030 restore_opts: 1022 restore_opts:
@@ -1032,7 +1024,6 @@ static int nilfs_remount(struct super_block *sb, int *flags, char *data)
1032 sbi->s_mount_opt = old_opts.mount_opt; 1024 sbi->s_mount_opt = old_opts.mount_opt;
1033 sbi->s_snapshot_cno = old_opts.snapshot_cno; 1025 sbi->s_snapshot_cno = old_opts.snapshot_cno;
1034 up_write(&nilfs->ns_super_sem); 1026 up_write(&nilfs->ns_super_sem);
1035 unlock_kernel();
1036 return err; 1027 return err;
1037} 1028}
1038 1029
@@ -1205,7 +1196,6 @@ nilfs_get_sb(struct file_system_type *fs_type, int flags,
1205 put_nilfs(nilfs); 1196 put_nilfs(nilfs);
1206 failed: 1197 failed:
1207 close_bdev_exclusive(sd.bdev, mode); 1198 close_bdev_exclusive(sd.bdev, mode);
1208
1209 return err; 1199 return err;
1210 1200
1211 cancel_new: 1201 cancel_new:
diff --git a/fs/no-block.c b/fs/no-block.c
index d269a93d3467..6e40e42a43de 100644
--- a/fs/no-block.c
+++ b/fs/no-block.c
@@ -19,4 +19,5 @@ static int no_blkdev_open(struct inode * inode, struct file * filp)
19 19
20const struct file_operations def_blk_fops = { 20const struct file_operations def_blk_fops = {
21 .open = no_blkdev_open, 21 .open = no_blkdev_open,
22 .llseek = noop_llseek,
22}; 23};
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index 5ed8e58d7bfc..bbcb98e7fcc6 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -433,6 +433,7 @@ static const struct file_operations fanotify_fops = {
433 .release = fanotify_release, 433 .release = fanotify_release,
434 .unlocked_ioctl = fanotify_ioctl, 434 .unlocked_ioctl = fanotify_ioctl,
435 .compat_ioctl = fanotify_ioctl, 435 .compat_ioctl = fanotify_ioctl,
436 .llseek = noop_llseek,
436}; 437};
437 438
438static void fanotify_free_mark(struct fsnotify_mark *fsn_mark) 439static void fanotify_free_mark(struct fsnotify_mark *fsn_mark)
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index bf7f6d776c31..24edc1185d53 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -344,6 +344,7 @@ static const struct file_operations inotify_fops = {
344 .release = inotify_release, 344 .release = inotify_release,
345 .unlocked_ioctl = inotify_ioctl, 345 .unlocked_ioctl = inotify_ioctl,
346 .compat_ioctl = inotify_ioctl, 346 .compat_ioctl = inotify_ioctl,
347 .llseek = noop_llseek,
347}; 348};
348 349
349 350
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index 512806171bfa..19c5180f8a28 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -30,7 +30,6 @@
30#include <linux/buffer_head.h> 30#include <linux/buffer_head.h>
31#include <linux/vfs.h> 31#include <linux/vfs.h>
32#include <linux/moduleparam.h> 32#include <linux/moduleparam.h>
33#include <linux/smp_lock.h>
34#include <linux/bitmap.h> 33#include <linux/bitmap.h>
35 34
36#include "sysctl.h" 35#include "sysctl.h"
@@ -445,7 +444,6 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt)
445 444
446 ntfs_debug("Entering with remount options string: %s", opt); 445 ntfs_debug("Entering with remount options string: %s", opt);
447 446
448 lock_kernel();
449#ifndef NTFS_RW 447#ifndef NTFS_RW
450 /* For read-only compiled driver, enforce read-only flag. */ 448 /* For read-only compiled driver, enforce read-only flag. */
451 *flags |= MS_RDONLY; 449 *flags |= MS_RDONLY;
@@ -469,18 +467,15 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt)
469 if (NVolErrors(vol)) { 467 if (NVolErrors(vol)) {
470 ntfs_error(sb, "Volume has errors and is read-only%s", 468 ntfs_error(sb, "Volume has errors and is read-only%s",
471 es); 469 es);
472 unlock_kernel();
473 return -EROFS; 470 return -EROFS;
474 } 471 }
475 if (vol->vol_flags & VOLUME_IS_DIRTY) { 472 if (vol->vol_flags & VOLUME_IS_DIRTY) {
476 ntfs_error(sb, "Volume is dirty and read-only%s", es); 473 ntfs_error(sb, "Volume is dirty and read-only%s", es);
477 unlock_kernel();
478 return -EROFS; 474 return -EROFS;
479 } 475 }
480 if (vol->vol_flags & VOLUME_MODIFIED_BY_CHKDSK) { 476 if (vol->vol_flags & VOLUME_MODIFIED_BY_CHKDSK) {
481 ntfs_error(sb, "Volume has been modified by chkdsk " 477 ntfs_error(sb, "Volume has been modified by chkdsk "
482 "and is read-only%s", es); 478 "and is read-only%s", es);
483 unlock_kernel();
484 return -EROFS; 479 return -EROFS;
485 } 480 }
486 if (vol->vol_flags & VOLUME_MUST_MOUNT_RO_MASK) { 481 if (vol->vol_flags & VOLUME_MUST_MOUNT_RO_MASK) {
@@ -488,13 +483,11 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt)
488 "(0x%x) and is read-only%s", 483 "(0x%x) and is read-only%s",
489 (unsigned)le16_to_cpu(vol->vol_flags), 484 (unsigned)le16_to_cpu(vol->vol_flags),
490 es); 485 es);
491 unlock_kernel();
492 return -EROFS; 486 return -EROFS;
493 } 487 }
494 if (ntfs_set_volume_flags(vol, VOLUME_IS_DIRTY)) { 488 if (ntfs_set_volume_flags(vol, VOLUME_IS_DIRTY)) {
495 ntfs_error(sb, "Failed to set dirty bit in volume " 489 ntfs_error(sb, "Failed to set dirty bit in volume "
496 "information flags%s", es); 490 "information flags%s", es);
497 unlock_kernel();
498 return -EROFS; 491 return -EROFS;
499 } 492 }
500#if 0 493#if 0
@@ -514,21 +507,18 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt)
514 ntfs_error(sb, "Failed to empty journal $LogFile%s", 507 ntfs_error(sb, "Failed to empty journal $LogFile%s",
515 es); 508 es);
516 NVolSetErrors(vol); 509 NVolSetErrors(vol);
517 unlock_kernel();
518 return -EROFS; 510 return -EROFS;
519 } 511 }
520 if (!ntfs_mark_quotas_out_of_date(vol)) { 512 if (!ntfs_mark_quotas_out_of_date(vol)) {
521 ntfs_error(sb, "Failed to mark quotas out of date%s", 513 ntfs_error(sb, "Failed to mark quotas out of date%s",
522 es); 514 es);
523 NVolSetErrors(vol); 515 NVolSetErrors(vol);
524 unlock_kernel();
525 return -EROFS; 516 return -EROFS;
526 } 517 }
527 if (!ntfs_stamp_usnjrnl(vol)) { 518 if (!ntfs_stamp_usnjrnl(vol)) {
528 ntfs_error(sb, "Failed to stamp transation log " 519 ntfs_error(sb, "Failed to stamp transation log "
529 "($UsnJrnl)%s", es); 520 "($UsnJrnl)%s", es);
530 NVolSetErrors(vol); 521 NVolSetErrors(vol);
531 unlock_kernel();
532 return -EROFS; 522 return -EROFS;
533 } 523 }
534 } else if (!(sb->s_flags & MS_RDONLY) && (*flags & MS_RDONLY)) { 524 } else if (!(sb->s_flags & MS_RDONLY) && (*flags & MS_RDONLY)) {
@@ -544,11 +534,9 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt)
544 534
545 // TODO: Deal with *flags. 535 // TODO: Deal with *flags.
546 536
547 if (!parse_options(vol, opt)) { 537 if (!parse_options(vol, opt))
548 unlock_kernel();
549 return -EINVAL; 538 return -EINVAL;
550 } 539
551 unlock_kernel();
552 ntfs_debug("Done."); 540 ntfs_debug("Done.");
553 return 0; 541 return 0;
554} 542}
@@ -2261,8 +2249,6 @@ static void ntfs_put_super(struct super_block *sb)
2261 2249
2262 ntfs_debug("Entering."); 2250 ntfs_debug("Entering.");
2263 2251
2264 lock_kernel();
2265
2266#ifdef NTFS_RW 2252#ifdef NTFS_RW
2267 /* 2253 /*
2268 * Commit all inodes while they are still open in case some of them 2254 * Commit all inodes while they are still open in case some of them
@@ -2433,8 +2419,6 @@ static void ntfs_put_super(struct super_block *sb)
2433 2419
2434 sb->s_fs_info = NULL; 2420 sb->s_fs_info = NULL;
2435 kfree(vol); 2421 kfree(vol);
2436
2437 unlock_kernel();
2438} 2422}
2439 2423
2440/** 2424/**
@@ -2772,8 +2756,6 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent)
2772 init_rwsem(&vol->mftbmp_lock); 2756 init_rwsem(&vol->mftbmp_lock);
2773 init_rwsem(&vol->lcnbmp_lock); 2757 init_rwsem(&vol->lcnbmp_lock);
2774 2758
2775 unlock_kernel();
2776
2777 /* By default, enable sparse support. */ 2759 /* By default, enable sparse support. */
2778 NVolSetSparseEnabled(vol); 2760 NVolSetSparseEnabled(vol);
2779 2761
@@ -2940,7 +2922,6 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent)
2940 } 2922 }
2941 mutex_unlock(&ntfs_lock); 2923 mutex_unlock(&ntfs_lock);
2942 sb->s_export_op = &ntfs_export_ops; 2924 sb->s_export_op = &ntfs_export_ops;
2943 lock_kernel();
2944 lockdep_on(); 2925 lockdep_on();
2945 return 0; 2926 return 0;
2946 } 2927 }
@@ -3057,7 +3038,6 @@ iput_tmp_ino_err_out_now:
3057 } 3038 }
3058 /* Errors at this stage are irrelevant. */ 3039 /* Errors at this stage are irrelevant. */
3059err_out_now: 3040err_out_now:
3060 lock_kernel();
3061 sb->s_fs_info = NULL; 3041 sb->s_fs_info = NULL;
3062 kfree(vol); 3042 kfree(vol);
3063 ntfs_debug("Failed, returning -EINVAL."); 3043 ntfs_debug("Failed, returning -EINVAL.");
diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c
index c2903b84bb7a..a7ebd9d42dc8 100644
--- a/fs/ocfs2/dlmfs/dlmfs.c
+++ b/fs/ocfs2/dlmfs/dlmfs.c
@@ -612,6 +612,7 @@ static const struct file_operations dlmfs_file_operations = {
612 .poll = dlmfs_file_poll, 612 .poll = dlmfs_file_poll,
613 .read = dlmfs_file_read, 613 .read = dlmfs_file_read,
614 .write = dlmfs_file_write, 614 .write = dlmfs_file_write,
615 .llseek = default_llseek,
615}; 616};
616 617
617static const struct inode_operations dlmfs_dir_inode_operations = { 618static const struct inode_operations dlmfs_dir_inode_operations = {
diff --git a/fs/ocfs2/stack_user.c b/fs/ocfs2/stack_user.c
index 2dc57bca0688..252e7c82f929 100644
--- a/fs/ocfs2/stack_user.c
+++ b/fs/ocfs2/stack_user.c
@@ -22,7 +22,6 @@
22#include <linux/miscdevice.h> 22#include <linux/miscdevice.h>
23#include <linux/mutex.h> 23#include <linux/mutex.h>
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/smp_lock.h>
26#include <linux/reboot.h> 25#include <linux/reboot.h>
27#include <asm/uaccess.h> 26#include <asm/uaccess.h>
28 27
@@ -612,12 +611,10 @@ static int ocfs2_control_open(struct inode *inode, struct file *file)
612 return -ENOMEM; 611 return -ENOMEM;
613 p->op_this_node = -1; 612 p->op_this_node = -1;
614 613
615 lock_kernel();
616 mutex_lock(&ocfs2_control_lock); 614 mutex_lock(&ocfs2_control_lock);
617 file->private_data = p; 615 file->private_data = p;
618 list_add(&p->op_list, &ocfs2_control_private_list); 616 list_add(&p->op_list, &ocfs2_control_private_list);
619 mutex_unlock(&ocfs2_control_lock); 617 mutex_unlock(&ocfs2_control_lock);
620 unlock_kernel();
621 618
622 return 0; 619 return 0;
623} 620}
@@ -628,6 +625,7 @@ static const struct file_operations ocfs2_control_fops = {
628 .read = ocfs2_control_read, 625 .read = ocfs2_control_read,
629 .write = ocfs2_control_write, 626 .write = ocfs2_control_write,
630 .owner = THIS_MODULE, 627 .owner = THIS_MODULE,
628 .llseek = default_llseek,
631}; 629};
632 630
633static struct miscdevice ocfs2_control_device = { 631static struct miscdevice ocfs2_control_device = {
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index a8a0ca44f88f..56f0cb395820 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -630,8 +630,6 @@ static int ocfs2_remount(struct super_block *sb, int *flags, char *data)
630 struct ocfs2_super *osb = OCFS2_SB(sb); 630 struct ocfs2_super *osb = OCFS2_SB(sb);
631 u32 tmp; 631 u32 tmp;
632 632
633 lock_kernel();
634
635 if (!ocfs2_parse_options(sb, data, &parsed_options, 1) || 633 if (!ocfs2_parse_options(sb, data, &parsed_options, 1) ||
636 !ocfs2_check_set_options(sb, &parsed_options)) { 634 !ocfs2_check_set_options(sb, &parsed_options)) {
637 ret = -EINVAL; 635 ret = -EINVAL;
@@ -739,7 +737,6 @@ unlock_osb:
739 MS_POSIXACL : 0); 737 MS_POSIXACL : 0);
740 } 738 }
741out: 739out:
742 unlock_kernel();
743 return ret; 740 return ret;
744} 741}
745 742
@@ -1696,13 +1693,9 @@ static void ocfs2_put_super(struct super_block *sb)
1696{ 1693{
1697 mlog_entry("(0x%p)\n", sb); 1694 mlog_entry("(0x%p)\n", sb);
1698 1695
1699 lock_kernel();
1700
1701 ocfs2_sync_blockdev(sb); 1696 ocfs2_sync_blockdev(sb);
1702 ocfs2_dismount_volume(sb, 0); 1697 ocfs2_dismount_volume(sb, 0);
1703 1698
1704 unlock_kernel();
1705
1706 mlog_exit_void(); 1699 mlog_exit_void();
1707} 1700}
1708 1701
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 8e4addaa5424..dc5d5f51f3fe 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1151,6 +1151,7 @@ static ssize_t oom_score_adj_write(struct file *file, const char __user *buf,
1151static const struct file_operations proc_oom_score_adj_operations = { 1151static const struct file_operations proc_oom_score_adj_operations = {
1152 .read = oom_score_adj_read, 1152 .read = oom_score_adj_read,
1153 .write = oom_score_adj_write, 1153 .write = oom_score_adj_write,
1154 .llseek = default_llseek,
1154}; 1155};
1155 1156
1156#ifdef CONFIG_AUDITSYSCALL 1157#ifdef CONFIG_AUDITSYSCALL
@@ -2039,11 +2040,13 @@ static ssize_t proc_fdinfo_read(struct file *file, char __user *buf,
2039static const struct file_operations proc_fdinfo_file_operations = { 2040static const struct file_operations proc_fdinfo_file_operations = {
2040 .open = nonseekable_open, 2041 .open = nonseekable_open,
2041 .read = proc_fdinfo_read, 2042 .read = proc_fdinfo_read,
2043 .llseek = no_llseek,
2042}; 2044};
2043 2045
2044static const struct file_operations proc_fd_operations = { 2046static const struct file_operations proc_fd_operations = {
2045 .read = generic_read_dir, 2047 .read = generic_read_dir,
2046 .readdir = proc_readfd, 2048 .readdir = proc_readfd,
2049 .llseek = default_llseek,
2047}; 2050};
2048 2051
2049/* 2052/*
@@ -2112,6 +2115,7 @@ static int proc_readfdinfo(struct file *filp, void *dirent, filldir_t filldir)
2112static const struct file_operations proc_fdinfo_operations = { 2115static const struct file_operations proc_fdinfo_operations = {
2113 .read = generic_read_dir, 2116 .read = generic_read_dir,
2114 .readdir = proc_readfdinfo, 2117 .readdir = proc_readfdinfo,
2118 .llseek = default_llseek,
2115}; 2119};
2116 2120
2117/* 2121/*
@@ -2343,6 +2347,7 @@ static int proc_attr_dir_readdir(struct file * filp,
2343static const struct file_operations proc_attr_dir_operations = { 2347static const struct file_operations proc_attr_dir_operations = {
2344 .read = generic_read_dir, 2348 .read = generic_read_dir,
2345 .readdir = proc_attr_dir_readdir, 2349 .readdir = proc_attr_dir_readdir,
2350 .llseek = default_llseek,
2346}; 2351};
2347 2352
2348static struct dentry *proc_attr_dir_lookup(struct inode *dir, 2353static struct dentry *proc_attr_dir_lookup(struct inode *dir,
@@ -2751,6 +2756,7 @@ static int proc_tgid_base_readdir(struct file * filp,
2751static const struct file_operations proc_tgid_base_operations = { 2756static const struct file_operations proc_tgid_base_operations = {
2752 .read = generic_read_dir, 2757 .read = generic_read_dir,
2753 .readdir = proc_tgid_base_readdir, 2758 .readdir = proc_tgid_base_readdir,
2759 .llseek = default_llseek,
2754}; 2760};
2755 2761
2756static struct dentry *proc_tgid_base_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd){ 2762static struct dentry *proc_tgid_base_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd){
@@ -3088,6 +3094,7 @@ static struct dentry *proc_tid_base_lookup(struct inode *dir, struct dentry *den
3088static const struct file_operations proc_tid_base_operations = { 3094static const struct file_operations proc_tid_base_operations = {
3089 .read = generic_read_dir, 3095 .read = generic_read_dir,
3090 .readdir = proc_tid_base_readdir, 3096 .readdir = proc_tid_base_readdir,
3097 .llseek = default_llseek,
3091}; 3098};
3092 3099
3093static const struct inode_operations proc_tid_base_inode_operations = { 3100static const struct inode_operations proc_tid_base_inode_operations = {
@@ -3324,4 +3331,5 @@ static const struct inode_operations proc_task_inode_operations = {
3324static const struct file_operations proc_task_operations = { 3331static const struct file_operations proc_task_operations = {
3325 .read = generic_read_dir, 3332 .read = generic_read_dir,
3326 .readdir = proc_task_readdir, 3333 .readdir = proc_task_readdir,
3334 .llseek = default_llseek,
3327}; 3335};
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 5be436ea088e..2fc52552271d 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -364,6 +364,7 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
364static const struct file_operations proc_sys_file_operations = { 364static const struct file_operations proc_sys_file_operations = {
365 .read = proc_sys_read, 365 .read = proc_sys_read,
366 .write = proc_sys_write, 366 .write = proc_sys_write,
367 .llseek = default_llseek,
367}; 368};
368 369
369static const struct file_operations proc_sys_dir_file_operations = { 370static const struct file_operations proc_sys_dir_file_operations = {
diff --git a/fs/proc/root.c b/fs/proc/root.c
index 4258384ed22d..93d99b316325 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -179,6 +179,7 @@ static int proc_root_readdir(struct file * filp,
179static const struct file_operations proc_root_operations = { 179static const struct file_operations proc_root_operations = {
180 .read = generic_read_dir, 180 .read = generic_read_dir,
181 .readdir = proc_root_readdir, 181 .readdir = proc_root_readdir,
182 .llseek = default_llseek,
182}; 183};
183 184
184/* 185/*
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 1dbca4e8cc16..871e25ed0069 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -539,6 +539,7 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
539 539
540const struct file_operations proc_clear_refs_operations = { 540const struct file_operations proc_clear_refs_operations = {
541 .write = clear_refs_write, 541 .write = clear_refs_write,
542 .llseek = noop_llseek,
542}; 543};
543 544
544struct pagemapread { 545struct pagemapread {
diff --git a/fs/qnx4/dir.c b/fs/qnx4/dir.c
index 6e8fc62b40a8..7b0329468a5d 100644
--- a/fs/qnx4/dir.c
+++ b/fs/qnx4/dir.c
@@ -11,7 +11,6 @@
11 * 20-06-1998 by Frank Denis : Linux 2.1.99+ & dcache support. 11 * 20-06-1998 by Frank Denis : Linux 2.1.99+ & dcache support.
12 */ 12 */
13 13
14#include <linux/smp_lock.h>
15#include <linux/buffer_head.h> 14#include <linux/buffer_head.h>
16#include "qnx4.h" 15#include "qnx4.h"
17 16
@@ -29,8 +28,6 @@ static int qnx4_readdir(struct file *filp, void *dirent, filldir_t filldir)
29 QNX4DEBUG((KERN_INFO "qnx4_readdir:i_size = %ld\n", (long) inode->i_size)); 28 QNX4DEBUG((KERN_INFO "qnx4_readdir:i_size = %ld\n", (long) inode->i_size));
30 QNX4DEBUG((KERN_INFO "filp->f_pos = %ld\n", (long) filp->f_pos)); 29 QNX4DEBUG((KERN_INFO "filp->f_pos = %ld\n", (long) filp->f_pos));
31 30
32 lock_kernel();
33
34 while (filp->f_pos < inode->i_size) { 31 while (filp->f_pos < inode->i_size) {
35 blknum = qnx4_block_map( inode, filp->f_pos >> QNX4_BLOCK_SIZE_BITS ); 32 blknum = qnx4_block_map( inode, filp->f_pos >> QNX4_BLOCK_SIZE_BITS );
36 bh = sb_bread(inode->i_sb, blknum); 33 bh = sb_bread(inode->i_sb, blknum);
@@ -71,7 +68,6 @@ static int qnx4_readdir(struct file *filp, void *dirent, filldir_t filldir)
71 brelse(bh); 68 brelse(bh);
72 } 69 }
73out: 70out:
74 unlock_kernel();
75 return 0; 71 return 0;
76} 72}
77 73
diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c
index 16829722be93..01bad30026fc 100644
--- a/fs/qnx4/inode.c
+++ b/fs/qnx4/inode.c
@@ -16,7 +16,6 @@
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <linux/highuid.h> 18#include <linux/highuid.h>
19#include <linux/smp_lock.h>
20#include <linux/pagemap.h> 19#include <linux/pagemap.h>
21#include <linux/buffer_head.h> 20#include <linux/buffer_head.h>
22#include <linux/writeback.h> 21#include <linux/writeback.h>
@@ -157,8 +156,6 @@ static int qnx4_statfs(struct dentry *dentry, struct kstatfs *buf)
157 struct super_block *sb = dentry->d_sb; 156 struct super_block *sb = dentry->d_sb;
158 u64 id = huge_encode_dev(sb->s_bdev->bd_dev); 157 u64 id = huge_encode_dev(sb->s_bdev->bd_dev);
159 158
160 lock_kernel();
161
162 buf->f_type = sb->s_magic; 159 buf->f_type = sb->s_magic;
163 buf->f_bsize = sb->s_blocksize; 160 buf->f_bsize = sb->s_blocksize;
164 buf->f_blocks = le32_to_cpu(qnx4_sb(sb)->BitMap->di_size) * 8; 161 buf->f_blocks = le32_to_cpu(qnx4_sb(sb)->BitMap->di_size) * 8;
@@ -168,8 +165,6 @@ static int qnx4_statfs(struct dentry *dentry, struct kstatfs *buf)
168 buf->f_fsid.val[0] = (u32)id; 165 buf->f_fsid.val[0] = (u32)id;
169 buf->f_fsid.val[1] = (u32)(id >> 32); 166 buf->f_fsid.val[1] = (u32)(id >> 32);
170 167
171 unlock_kernel();
172
173 return 0; 168 return 0;
174} 169}
175 170
@@ -283,7 +278,6 @@ static int qnx4_fill_super(struct super_block *s, void *data, int silent)
283 goto outi; 278 goto outi;
284 279
285 brelse(bh); 280 brelse(bh);
286
287 return 0; 281 return 0;
288 282
289 outi: 283 outi:
diff --git a/fs/qnx4/namei.c b/fs/qnx4/namei.c
index 58703ebba879..275327b5615e 100644
--- a/fs/qnx4/namei.c
+++ b/fs/qnx4/namei.c
@@ -12,7 +12,6 @@
12 * 04-07-1998 by Frank Denis : first step for rmdir/unlink. 12 * 04-07-1998 by Frank Denis : first step for rmdir/unlink.
13 */ 13 */
14 14
15#include <linux/smp_lock.h>
16#include <linux/buffer_head.h> 15#include <linux/buffer_head.h>
17#include "qnx4.h" 16#include "qnx4.h"
18 17
@@ -109,7 +108,6 @@ struct dentry * qnx4_lookup(struct inode *dir, struct dentry *dentry, struct nam
109 int len = dentry->d_name.len; 108 int len = dentry->d_name.len;
110 struct inode *foundinode = NULL; 109 struct inode *foundinode = NULL;
111 110
112 lock_kernel();
113 if (!(bh = qnx4_find_entry(len, dir, name, &de, &ino))) 111 if (!(bh = qnx4_find_entry(len, dir, name, &de, &ino)))
114 goto out; 112 goto out;
115 /* The entry is linked, let's get the real info */ 113 /* The entry is linked, let's get the real info */
@@ -123,13 +121,11 @@ struct dentry * qnx4_lookup(struct inode *dir, struct dentry *dentry, struct nam
123 121
124 foundinode = qnx4_iget(dir->i_sb, ino); 122 foundinode = qnx4_iget(dir->i_sb, ino);
125 if (IS_ERR(foundinode)) { 123 if (IS_ERR(foundinode)) {
126 unlock_kernel();
127 QNX4DEBUG((KERN_ERR "qnx4: lookup->iget -> error %ld\n", 124 QNX4DEBUG((KERN_ERR "qnx4: lookup->iget -> error %ld\n",
128 PTR_ERR(foundinode))); 125 PTR_ERR(foundinode)));
129 return ERR_CAST(foundinode); 126 return ERR_CAST(foundinode);
130 } 127 }
131out: 128out:
132 unlock_kernel();
133 d_add(dentry, foundinode); 129 d_add(dentry, foundinode);
134 130
135 return NULL; 131 return NULL;
diff --git a/fs/read_write.c b/fs/read_write.c
index 74e36586e4d3..e757ef26e4ce 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -124,7 +124,7 @@ loff_t default_llseek(struct file *file, loff_t offset, int origin)
124{ 124{
125 loff_t retval; 125 loff_t retval;
126 126
127 lock_kernel(); 127 mutex_lock(&file->f_dentry->d_inode->i_mutex);
128 switch (origin) { 128 switch (origin) {
129 case SEEK_END: 129 case SEEK_END:
130 offset += i_size_read(file->f_path.dentry->d_inode); 130 offset += i_size_read(file->f_path.dentry->d_inode);
@@ -145,7 +145,7 @@ loff_t default_llseek(struct file *file, loff_t offset, int origin)
145 retval = offset; 145 retval = offset;
146 } 146 }
147out: 147out:
148 unlock_kernel(); 148 mutex_unlock(&file->f_dentry->d_inode->i_mutex);
149 return retval; 149 return retval;
150} 150}
151EXPORT_SYMBOL(default_llseek); 151EXPORT_SYMBOL(default_llseek);
@@ -156,7 +156,6 @@ loff_t vfs_llseek(struct file *file, loff_t offset, int origin)
156 156
157 fn = no_llseek; 157 fn = no_llseek;
158 if (file->f_mode & FMODE_LSEEK) { 158 if (file->f_mode & FMODE_LSEEK) {
159 fn = default_llseek;
160 if (file->f_op && file->f_op->llseek) 159 if (file->f_op && file->f_op->llseek)
161 fn = file->f_op->llseek; 160 fn = file->f_op->llseek;
162 } 161 }
diff --git a/fs/romfs/super.c b/fs/romfs/super.c
index 42d213546894..268580535c92 100644
--- a/fs/romfs/super.c
+++ b/fs/romfs/super.c
@@ -282,6 +282,7 @@ error:
282static const struct file_operations romfs_dir_operations = { 282static const struct file_operations romfs_dir_operations = {
283 .read = generic_read_dir, 283 .read = generic_read_dir,
284 .readdir = romfs_readdir, 284 .readdir = romfs_readdir,
285 .llseek = default_llseek,
285}; 286};
286 287
287static const struct inode_operations romfs_dir_inode_operations = { 288static const struct inode_operations romfs_dir_inode_operations = {
diff --git a/fs/signalfd.c b/fs/signalfd.c
index 1c5a6add779d..74047304b01a 100644
--- a/fs/signalfd.c
+++ b/fs/signalfd.c
@@ -206,6 +206,7 @@ static const struct file_operations signalfd_fops = {
206 .release = signalfd_release, 206 .release = signalfd_release,
207 .poll = signalfd_poll, 207 .poll = signalfd_poll,
208 .read = signalfd_read, 208 .read = signalfd_read,
209 .llseek = noop_llseek,
209}; 210};
210 211
211SYSCALL_DEFINE4(signalfd4, int, ufd, sigset_t __user *, user_mask, 212SYSCALL_DEFINE4(signalfd4, int, ufd, sigset_t __user *, user_mask,
diff --git a/fs/smbfs/Kconfig b/fs/smbfs/Kconfig
index e668127c8b2e..2bc24a8c4039 100644
--- a/fs/smbfs/Kconfig
+++ b/fs/smbfs/Kconfig
@@ -1,5 +1,6 @@
1config SMB_FS 1config SMB_FS
2 tristate "SMB file system support (OBSOLETE, please use CIFS)" 2 tristate "SMB file system support (OBSOLETE, please use CIFS)"
3 depends on BKL # probably unfixable
3 depends on INET 4 depends on INET
4 select NLS 5 select NLS
5 help 6 help
diff --git a/fs/smbfs/inode.c b/fs/smbfs/inode.c
index 450c91941988..8fc5e50e142f 100644
--- a/fs/smbfs/inode.c
+++ b/fs/smbfs/inode.c
@@ -501,6 +501,8 @@ static int smb_fill_super(struct super_block *sb, void *raw_data, int silent)
501 void *mem; 501 void *mem;
502 static int warn_count; 502 static int warn_count;
503 503
504 lock_kernel();
505
504 if (warn_count < 5) { 506 if (warn_count < 5) {
505 warn_count++; 507 warn_count++;
506 printk(KERN_EMERG "smbfs is deprecated and will be removed" 508 printk(KERN_EMERG "smbfs is deprecated and will be removed"
@@ -621,6 +623,7 @@ static int smb_fill_super(struct super_block *sb, void *raw_data, int silent)
621 623
622 smb_new_dentry(sb->s_root); 624 smb_new_dentry(sb->s_root);
623 625
626 unlock_kernel();
624 return 0; 627 return 0;
625 628
626out_no_root: 629out_no_root:
@@ -643,9 +646,11 @@ out_wrong_data:
643out_no_data: 646out_no_data:
644 printk(KERN_ERR "smb_fill_super: missing data argument\n"); 647 printk(KERN_ERR "smb_fill_super: missing data argument\n");
645out_fail: 648out_fail:
649 unlock_kernel();
646 return -EINVAL; 650 return -EINVAL;
647out_no_server: 651out_no_server:
648 printk(KERN_ERR "smb_fill_super: cannot allocate struct smb_sb_info\n"); 652 printk(KERN_ERR "smb_fill_super: cannot allocate struct smb_sb_info\n");
653 unlock_kernel();
649 return -ENOMEM; 654 return -ENOMEM;
650} 655}
651 656
diff --git a/fs/squashfs/dir.c b/fs/squashfs/dir.c
index 12b933ac6585..0dc340aa2be9 100644
--- a/fs/squashfs/dir.c
+++ b/fs/squashfs/dir.c
@@ -230,5 +230,6 @@ failed_read:
230 230
231const struct file_operations squashfs_dir_ops = { 231const struct file_operations squashfs_dir_ops = {
232 .read = generic_read_dir, 232 .read = generic_read_dir,
233 .readdir = squashfs_readdir 233 .readdir = squashfs_readdir,
234 .llseek = default_llseek,
234}; 235};
diff --git a/fs/squashfs/super.c b/fs/squashfs/super.c
index 88b4f8606652..07a4f1156048 100644
--- a/fs/squashfs/super.c
+++ b/fs/squashfs/super.c
@@ -30,7 +30,6 @@
30#include <linux/fs.h> 30#include <linux/fs.h>
31#include <linux/vfs.h> 31#include <linux/vfs.h>
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/smp_lock.h>
34#include <linux/mutex.h> 33#include <linux/mutex.h>
35#include <linux/pagemap.h> 34#include <linux/pagemap.h>
36#include <linux/init.h> 35#include <linux/init.h>
@@ -354,8 +353,6 @@ static int squashfs_remount(struct super_block *sb, int *flags, char *data)
354 353
355static void squashfs_put_super(struct super_block *sb) 354static void squashfs_put_super(struct super_block *sb)
356{ 355{
357 lock_kernel();
358
359 if (sb->s_fs_info) { 356 if (sb->s_fs_info) {
360 struct squashfs_sb_info *sbi = sb->s_fs_info; 357 struct squashfs_sb_info *sbi = sb->s_fs_info;
361 squashfs_cache_delete(sbi->block_cache); 358 squashfs_cache_delete(sbi->block_cache);
@@ -370,8 +367,6 @@ static void squashfs_put_super(struct super_block *sb)
370 kfree(sb->s_fs_info); 367 kfree(sb->s_fs_info);
371 sb->s_fs_info = NULL; 368 sb->s_fs_info = NULL;
372 } 369 }
373
374 unlock_kernel();
375} 370}
376 371
377 372
diff --git a/fs/timerfd.c b/fs/timerfd.c
index b86ab8eff79a..8c4fc1425b3e 100644
--- a/fs/timerfd.c
+++ b/fs/timerfd.c
@@ -144,6 +144,7 @@ static const struct file_operations timerfd_fops = {
144 .release = timerfd_release, 144 .release = timerfd_release,
145 .poll = timerfd_poll, 145 .poll = timerfd_poll,
146 .read = timerfd_read, 146 .read = timerfd_read,
147 .llseek = noop_llseek,
147}; 148};
148 149
149static struct file *timerfd_fget(int fd) 150static struct file *timerfd_fget(int fd)
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
index c2a68baa782f..c6c553fd0b3d 100644
--- a/fs/ubifs/debug.c
+++ b/fs/ubifs/debug.c
@@ -2625,6 +2625,7 @@ static const struct file_operations dfs_fops = {
2625 .open = open_debugfs_file, 2625 .open = open_debugfs_file,
2626 .write = write_debugfs_file, 2626 .write = write_debugfs_file,
2627 .owner = THIS_MODULE, 2627 .owner = THIS_MODULE,
2628 .llseek = default_llseek,
2628}; 2629};
2629 2630
2630/** 2631/**
diff --git a/fs/udf/Kconfig b/fs/udf/Kconfig
index 0e0e99bd6bce..f8def3c8ea4c 100644
--- a/fs/udf/Kconfig
+++ b/fs/udf/Kconfig
@@ -1,5 +1,6 @@
1config UDF_FS 1config UDF_FS
2 tristate "UDF file system support" 2 tristate "UDF file system support"
3 depends on BKL # needs serious work to remove
3 select CRC_ITU_T 4 select CRC_ITU_T
4 help 5 help
5 This is the new file system used on some CD-ROMs and DVDs. Say Y if 6 This is the new file system used on some CD-ROMs and DVDs. Say Y if
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 65412d84a45d..76f3d6d97b40 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -1880,6 +1880,8 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
1880 struct kernel_lb_addr rootdir, fileset; 1880 struct kernel_lb_addr rootdir, fileset;
1881 struct udf_sb_info *sbi; 1881 struct udf_sb_info *sbi;
1882 1882
1883 lock_kernel();
1884
1883 uopt.flags = (1 << UDF_FLAG_USE_AD_IN_ICB) | (1 << UDF_FLAG_STRICT); 1885 uopt.flags = (1 << UDF_FLAG_USE_AD_IN_ICB) | (1 << UDF_FLAG_STRICT);
1884 uopt.uid = -1; 1886 uopt.uid = -1;
1885 uopt.gid = -1; 1887 uopt.gid = -1;
@@ -1888,8 +1890,10 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
1888 uopt.dmode = UDF_INVALID_MODE; 1890 uopt.dmode = UDF_INVALID_MODE;
1889 1891
1890 sbi = kzalloc(sizeof(struct udf_sb_info), GFP_KERNEL); 1892 sbi = kzalloc(sizeof(struct udf_sb_info), GFP_KERNEL);
1891 if (!sbi) 1893 if (!sbi) {
1894 unlock_kernel();
1892 return -ENOMEM; 1895 return -ENOMEM;
1896 }
1893 1897
1894 sb->s_fs_info = sbi; 1898 sb->s_fs_info = sbi;
1895 1899
@@ -2035,6 +2039,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
2035 goto error_out; 2039 goto error_out;
2036 } 2040 }
2037 sb->s_maxbytes = MAX_LFS_FILESIZE; 2041 sb->s_maxbytes = MAX_LFS_FILESIZE;
2042 unlock_kernel();
2038 return 0; 2043 return 0;
2039 2044
2040error_out: 2045error_out:
@@ -2055,6 +2060,7 @@ error_out:
2055 kfree(sbi); 2060 kfree(sbi);
2056 sb->s_fs_info = NULL; 2061 sb->s_fs_info = NULL;
2057 2062
2063 unlock_kernel();
2058 return -EINVAL; 2064 return -EINVAL;
2059} 2065}
2060 2066
diff --git a/fs/ufs/Kconfig b/fs/ufs/Kconfig
index e4f10a40768a..30c8f223253d 100644
--- a/fs/ufs/Kconfig
+++ b/fs/ufs/Kconfig
@@ -1,6 +1,7 @@
1config UFS_FS 1config UFS_FS
2 tristate "UFS file system support (read only)" 2 tristate "UFS file system support (read only)"
3 depends on BLOCK 3 depends on BLOCK
4 depends on BKL # probably fixable
4 help 5 help
5 BSD and derivate versions of Unix (such as SunOS, FreeBSD, NetBSD, 6 BSD and derivate versions of Unix (such as SunOS, FreeBSD, NetBSD,
6 OpenBSD and NeXTstep) use a file system called UFS. Some System V 7 OpenBSD and NeXTstep) use a file system called UFS. Some System V
diff --git a/fs/ufs/super.c b/fs/ufs/super.c
index d510c1b91817..6b9be90dae7d 100644
--- a/fs/ufs/super.c
+++ b/fs/ufs/super.c
@@ -696,6 +696,8 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent)
696 unsigned maxsymlen; 696 unsigned maxsymlen;
697 int ret = -EINVAL; 697 int ret = -EINVAL;
698 698
699 lock_kernel();
700
699 uspi = NULL; 701 uspi = NULL;
700 ubh = NULL; 702 ubh = NULL;
701 flags = 0; 703 flags = 0;
@@ -1163,6 +1165,7 @@ magic_found:
1163 goto failed; 1165 goto failed;
1164 1166
1165 UFSD("EXIT\n"); 1167 UFSD("EXIT\n");
1168 unlock_kernel();
1166 return 0; 1169 return 0;
1167 1170
1168dalloc_failed: 1171dalloc_failed:
@@ -1174,10 +1177,12 @@ failed:
1174 kfree(sbi); 1177 kfree(sbi);
1175 sb->s_fs_info = NULL; 1178 sb->s_fs_info = NULL;
1176 UFSD("EXIT (FAILED)\n"); 1179 UFSD("EXIT (FAILED)\n");
1180 unlock_kernel();
1177 return ret; 1181 return ret;
1178 1182
1179failed_nomem: 1183failed_nomem:
1180 UFSD("EXIT (NOMEM)\n"); 1184 UFSD("EXIT (NOMEM)\n");
1185 unlock_kernel();
1181 return -ENOMEM; 1186 return -ENOMEM;
1182} 1187}
1183 1188
diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
index fd57b8477fab..e994197f84b7 100644
--- a/include/asm-generic/atomic.h
+++ b/include/asm-generic/atomic.h
@@ -120,14 +120,23 @@ static inline void atomic_dec(atomic_t *v)
120#define atomic_dec_and_test(v) (atomic_sub_return(1, (v)) == 0) 120#define atomic_dec_and_test(v) (atomic_sub_return(1, (v)) == 0)
121#define atomic_inc_and_test(v) (atomic_add_return(1, (v)) == 0) 121#define atomic_inc_and_test(v) (atomic_add_return(1, (v)) == 0)
122 122
123#define atomic_add_unless(v, a, u) \ 123#define atomic_xchg(ptr, v) (xchg(&(ptr)->counter, (v)))
124({ \ 124#define atomic_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), (old), (new)))
125 int c, old; \ 125
126 c = atomic_read(v); \ 126#define cmpxchg_local(ptr, o, n) \
127 while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \ 127 ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\
128 c = old; \ 128 (unsigned long)(n), sizeof(*(ptr))))
129 c != (u); \ 129
130}) 130#define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
131
132static inline int atomic_add_unless(atomic_t *v, int a, int u)
133{
134 int c, old;
135 c = atomic_read(v);
136 while (c != u && (old = atomic_cmpxchg(v, c, c + a)) != c)
137 c = old;
138 return c != u;
139}
131 140
132#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) 141#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
133 142
@@ -141,15 +150,6 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
141 raw_local_irq_restore(flags); 150 raw_local_irq_restore(flags);
142} 151}
143 152
144#define atomic_xchg(ptr, v) (xchg(&(ptr)->counter, (v)))
145#define atomic_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), (old), (new)))
146
147#define cmpxchg_local(ptr, o, n) \
148 ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\
149 (unsigned long)(n), sizeof(*(ptr))))
150
151#define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
152
153/* Assume that atomic operations are already serializing */ 153/* Assume that atomic operations are already serializing */
154#define smp_mb__before_atomic_dec() barrier() 154#define smp_mb__before_atomic_dec() barrier()
155#define smp_mb__after_atomic_dec() barrier() 155#define smp_mb__after_atomic_dec() barrier()
diff --git a/include/asm-generic/bitops/find.h b/include/asm-generic/bitops/find.h
index 1914e9742512..110fa700f853 100644
--- a/include/asm-generic/bitops/find.h
+++ b/include/asm-generic/bitops/find.h
@@ -1,15 +1,50 @@
1#ifndef _ASM_GENERIC_BITOPS_FIND_H_ 1#ifndef _ASM_GENERIC_BITOPS_FIND_H_
2#define _ASM_GENERIC_BITOPS_FIND_H_ 2#define _ASM_GENERIC_BITOPS_FIND_H_
3 3
4#ifndef CONFIG_GENERIC_FIND_NEXT_BIT 4/**
5 * find_next_bit - find the next set bit in a memory region
6 * @addr: The address to base the search on
7 * @offset: The bitnumber to start searching at
8 * @size: The bitmap size in bits
9 */
5extern unsigned long find_next_bit(const unsigned long *addr, unsigned long 10extern unsigned long find_next_bit(const unsigned long *addr, unsigned long
6 size, unsigned long offset); 11 size, unsigned long offset);
7 12
13/**
14 * find_next_zero_bit - find the next cleared bit in a memory region
15 * @addr: The address to base the search on
16 * @offset: The bitnumber to start searching at
17 * @size: The bitmap size in bits
18 */
8extern unsigned long find_next_zero_bit(const unsigned long *addr, unsigned 19extern unsigned long find_next_zero_bit(const unsigned long *addr, unsigned
9 long size, unsigned long offset); 20 long size, unsigned long offset);
10#endif 21
22#ifdef CONFIG_GENERIC_FIND_FIRST_BIT
23
24/**
25 * find_first_bit - find the first set bit in a memory region
26 * @addr: The address to start the search at
27 * @size: The maximum size to search
28 *
29 * Returns the bit number of the first set bit.
30 */
31extern unsigned long find_first_bit(const unsigned long *addr,
32 unsigned long size);
33
34/**
35 * find_first_zero_bit - find the first cleared bit in a memory region
36 * @addr: The address to start the search at
37 * @size: The maximum size to search
38 *
39 * Returns the bit number of the first cleared bit.
40 */
41extern unsigned long find_first_zero_bit(const unsigned long *addr,
42 unsigned long size);
43#else /* CONFIG_GENERIC_FIND_FIRST_BIT */
11 44
12#define find_first_bit(addr, size) find_next_bit((addr), (size), 0) 45#define find_first_bit(addr, size) find_next_bit((addr), (size), 0)
13#define find_first_zero_bit(addr, size) find_next_zero_bit((addr), (size), 0) 46#define find_first_zero_bit(addr, size) find_next_zero_bit((addr), (size), 0)
14 47
48#endif /* CONFIG_GENERIC_FIND_FIRST_BIT */
49
15#endif /*_ASM_GENERIC_BITOPS_FIND_H_ */ 50#endif /*_ASM_GENERIC_BITOPS_FIND_H_ */
diff --git a/include/asm-generic/fcntl.h b/include/asm-generic/fcntl.h
index a70b2d2bfc14..0fc16e3f0bfc 100644
--- a/include/asm-generic/fcntl.h
+++ b/include/asm-generic/fcntl.h
@@ -122,7 +122,7 @@
122 122
123struct f_owner_ex { 123struct f_owner_ex {
124 int type; 124 int type;
125 pid_t pid; 125 __kernel_pid_t pid;
126}; 126};
127 127
128/* for F_[GET|SET]FL */ 128/* for F_[GET|SET]FL */
diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index 118601fce92d..3577ca11a0be 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -19,7 +19,9 @@
19#include <asm-generic/iomap.h> 19#include <asm-generic/iomap.h>
20#endif 20#endif
21 21
22#ifndef mmiowb
22#define mmiowb() do {} while (0) 23#define mmiowb() do {} while (0)
24#endif
23 25
24/*****************************************************************************/ 26/*****************************************************************************/
25/* 27/*
@@ -28,39 +30,51 @@
28 * differently. On the simple architectures, we just read/write the 30 * differently. On the simple architectures, we just read/write the
29 * memory location directly. 31 * memory location directly.
30 */ 32 */
33#ifndef __raw_readb
31static inline u8 __raw_readb(const volatile void __iomem *addr) 34static inline u8 __raw_readb(const volatile void __iomem *addr)
32{ 35{
33 return *(const volatile u8 __force *) addr; 36 return *(const volatile u8 __force *) addr;
34} 37}
38#endif
35 39
40#ifndef __raw_readw
36static inline u16 __raw_readw(const volatile void __iomem *addr) 41static inline u16 __raw_readw(const volatile void __iomem *addr)
37{ 42{
38 return *(const volatile u16 __force *) addr; 43 return *(const volatile u16 __force *) addr;
39} 44}
45#endif
40 46
47#ifndef __raw_readl
41static inline u32 __raw_readl(const volatile void __iomem *addr) 48static inline u32 __raw_readl(const volatile void __iomem *addr)
42{ 49{
43 return *(const volatile u32 __force *) addr; 50 return *(const volatile u32 __force *) addr;
44} 51}
52#endif
45 53
46#define readb __raw_readb 54#define readb __raw_readb
47#define readw(addr) __le16_to_cpu(__raw_readw(addr)) 55#define readw(addr) __le16_to_cpu(__raw_readw(addr))
48#define readl(addr) __le32_to_cpu(__raw_readl(addr)) 56#define readl(addr) __le32_to_cpu(__raw_readl(addr))
49 57
58#ifndef __raw_writeb
50static inline void __raw_writeb(u8 b, volatile void __iomem *addr) 59static inline void __raw_writeb(u8 b, volatile void __iomem *addr)
51{ 60{
52 *(volatile u8 __force *) addr = b; 61 *(volatile u8 __force *) addr = b;
53} 62}
63#endif
54 64
65#ifndef __raw_writew
55static inline void __raw_writew(u16 b, volatile void __iomem *addr) 66static inline void __raw_writew(u16 b, volatile void __iomem *addr)
56{ 67{
57 *(volatile u16 __force *) addr = b; 68 *(volatile u16 __force *) addr = b;
58} 69}
70#endif
59 71
72#ifndef __raw_writel
60static inline void __raw_writel(u32 b, volatile void __iomem *addr) 73static inline void __raw_writel(u32 b, volatile void __iomem *addr)
61{ 74{
62 *(volatile u32 __force *) addr = b; 75 *(volatile u32 __force *) addr = b;
63} 76}
77#endif
64 78
65#define writeb __raw_writeb 79#define writeb __raw_writeb
66#define writew(b,addr) __raw_writew(__cpu_to_le16(b),addr) 80#define writew(b,addr) __raw_writew(__cpu_to_le16(b),addr)
@@ -122,6 +136,7 @@ static inline void outl(u32 b, unsigned long addr)
122#define outw_p(x, addr) outw((x), (addr)) 136#define outw_p(x, addr) outw((x), (addr))
123#define outl_p(x, addr) outl((x), (addr)) 137#define outl_p(x, addr) outl((x), (addr))
124 138
139#ifndef insb
125static inline void insb(unsigned long addr, void *buffer, int count) 140static inline void insb(unsigned long addr, void *buffer, int count)
126{ 141{
127 if (count) { 142 if (count) {
@@ -132,7 +147,9 @@ static inline void insb(unsigned long addr, void *buffer, int count)
132 } while (--count); 147 } while (--count);
133 } 148 }
134} 149}
150#endif
135 151
152#ifndef insw
136static inline void insw(unsigned long addr, void *buffer, int count) 153static inline void insw(unsigned long addr, void *buffer, int count)
137{ 154{
138 if (count) { 155 if (count) {
@@ -143,7 +160,9 @@ static inline void insw(unsigned long addr, void *buffer, int count)
143 } while (--count); 160 } while (--count);
144 } 161 }
145} 162}
163#endif
146 164
165#ifndef insl
147static inline void insl(unsigned long addr, void *buffer, int count) 166static inline void insl(unsigned long addr, void *buffer, int count)
148{ 167{
149 if (count) { 168 if (count) {
@@ -154,7 +173,9 @@ static inline void insl(unsigned long addr, void *buffer, int count)
154 } while (--count); 173 } while (--count);
155 } 174 }
156} 175}
176#endif
157 177
178#ifndef outsb
158static inline void outsb(unsigned long addr, const void *buffer, int count) 179static inline void outsb(unsigned long addr, const void *buffer, int count)
159{ 180{
160 if (count) { 181 if (count) {
@@ -164,7 +185,9 @@ static inline void outsb(unsigned long addr, const void *buffer, int count)
164 } while (--count); 185 } while (--count);
165 } 186 }
166} 187}
188#endif
167 189
190#ifndef outsw
168static inline void outsw(unsigned long addr, const void *buffer, int count) 191static inline void outsw(unsigned long addr, const void *buffer, int count)
169{ 192{
170 if (count) { 193 if (count) {
@@ -174,7 +197,9 @@ static inline void outsw(unsigned long addr, const void *buffer, int count)
174 } while (--count); 197 } while (--count);
175 } 198 }
176} 199}
200#endif
177 201
202#ifndef outsl
178static inline void outsl(unsigned long addr, const void *buffer, int count) 203static inline void outsl(unsigned long addr, const void *buffer, int count)
179{ 204{
180 if (count) { 205 if (count) {
@@ -184,6 +209,7 @@ static inline void outsl(unsigned long addr, const void *buffer, int count)
184 } while (--count); 209 } while (--count);
185 } 210 }
186} 211}
212#endif
187 213
188#ifndef CONFIG_GENERIC_IOMAP 214#ifndef CONFIG_GENERIC_IOMAP
189#define ioread8(addr) readb(addr) 215#define ioread8(addr) readb(addr)
diff --git a/include/asm-generic/kdebug.h b/include/asm-generic/kdebug.h
index 11e57b6a85fc..d1814497bcdb 100644
--- a/include/asm-generic/kdebug.h
+++ b/include/asm-generic/kdebug.h
@@ -3,7 +3,7 @@
3 3
4enum die_val { 4enum die_val {
5 DIE_UNUSED, 5 DIE_UNUSED,
6 DIE_OOPS=1 6 DIE_OOPS = 1,
7}; 7};
8 8
9#endif /* _ASM_GENERIC_KDEBUG_H */ 9#endif /* _ASM_GENERIC_KDEBUG_H */
diff --git a/include/asm-generic/system.h b/include/asm-generic/system.h
index efa403b5e121..4b0b9cbbfae5 100644
--- a/include/asm-generic/system.h
+++ b/include/asm-generic/system.h
@@ -21,6 +21,7 @@
21#include <linux/irqflags.h> 21#include <linux/irqflags.h>
22 22
23#include <asm/cmpxchg-local.h> 23#include <asm/cmpxchg-local.h>
24#include <asm/cmpxchg.h>
24 25
25struct task_struct; 26struct task_struct;
26 27
@@ -136,25 +137,6 @@ unsigned long __xchg(unsigned long x, volatile void *ptr, int size)
136#define xchg(ptr, x) \ 137#define xchg(ptr, x) \
137 ((__typeof__(*(ptr))) __xchg((unsigned long)(x), (ptr), sizeof(*(ptr)))) 138 ((__typeof__(*(ptr))) __xchg((unsigned long)(x), (ptr), sizeof(*(ptr))))
138 139
139static inline unsigned long __cmpxchg(volatile unsigned long *m,
140 unsigned long old, unsigned long new)
141{
142 unsigned long retval;
143 unsigned long flags;
144
145 local_irq_save(flags);
146 retval = *m;
147 if (retval == old)
148 *m = new;
149 local_irq_restore(flags);
150 return retval;
151}
152
153#define cmpxchg(ptr, o, n) \
154 ((__typeof__(*(ptr))) __cmpxchg((unsigned long *)(ptr), \
155 (unsigned long)(o), \
156 (unsigned long)(n)))
157
158#endif /* !__ASSEMBLY__ */ 140#endif /* !__ASSEMBLY__ */
159 141
160#endif /* __KERNEL__ */ 142#endif /* __KERNEL__ */
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index fc68053378ce..827cc95711ef 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -136,28 +136,6 @@ static inline unsigned long __ffs64(u64 word)
136} 136}
137 137
138#ifdef __KERNEL__ 138#ifdef __KERNEL__
139#ifdef CONFIG_GENERIC_FIND_FIRST_BIT
140
141/**
142 * find_first_bit - find the first set bit in a memory region
143 * @addr: The address to start the search at
144 * @size: The maximum size to search
145 *
146 * Returns the bit number of the first set bit.
147 */
148extern unsigned long find_first_bit(const unsigned long *addr,
149 unsigned long size);
150
151/**
152 * find_first_zero_bit - find the first cleared bit in a memory region
153 * @addr: The address to start the search at
154 * @size: The maximum size to search
155 *
156 * Returns the bit number of the first cleared bit.
157 */
158extern unsigned long find_first_zero_bit(const unsigned long *addr,
159 unsigned long size);
160#endif /* CONFIG_GENERIC_FIND_FIRST_BIT */
161 139
162#ifdef CONFIG_GENERIC_FIND_LAST_BIT 140#ifdef CONFIG_GENERIC_FIND_LAST_BIT
163/** 141/**
@@ -171,28 +149,5 @@ extern unsigned long find_last_bit(const unsigned long *addr,
171 unsigned long size); 149 unsigned long size);
172#endif /* CONFIG_GENERIC_FIND_LAST_BIT */ 150#endif /* CONFIG_GENERIC_FIND_LAST_BIT */
173 151
174#ifdef CONFIG_GENERIC_FIND_NEXT_BIT
175
176/**
177 * find_next_bit - find the next set bit in a memory region
178 * @addr: The address to base the search on
179 * @offset: The bitnumber to start searching at
180 * @size: The bitmap size in bits
181 */
182extern unsigned long find_next_bit(const unsigned long *addr,
183 unsigned long size, unsigned long offset);
184
185/**
186 * find_next_zero_bit - find the next cleared bit in a memory region
187 * @addr: The address to base the search on
188 * @offset: The bitnumber to start searching at
189 * @size: The bitmap size in bits
190 */
191
192extern unsigned long find_next_zero_bit(const unsigned long *addr,
193 unsigned long size,
194 unsigned long offset);
195
196#endif /* CONFIG_GENERIC_FIND_NEXT_BIT */
197#endif /* __KERNEL__ */ 152#endif /* __KERNEL__ */
198#endif 153#endif
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 7d6f18fddfdb..0a81b87ea158 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1093,10 +1093,6 @@ struct file_lock {
1093 1093
1094#include <linux/fcntl.h> 1094#include <linux/fcntl.h>
1095 1095
1096/* temporary stubs for BKL removal */
1097#define lock_flocks() lock_kernel()
1098#define unlock_flocks() unlock_kernel()
1099
1100extern void send_sigio(struct fown_struct *fown, int fd, int band); 1096extern void send_sigio(struct fown_struct *fown, int fd, int band);
1101 1097
1102#ifdef CONFIG_FILE_LOCKING 1098#ifdef CONFIG_FILE_LOCKING
@@ -1135,6 +1131,8 @@ extern int vfs_setlease(struct file *, long, struct file_lock **);
1135extern int lease_modify(struct file_lock **, int); 1131extern int lease_modify(struct file_lock **, int);
1136extern int lock_may_read(struct inode *, loff_t start, unsigned long count); 1132extern int lock_may_read(struct inode *, loff_t start, unsigned long count);
1137extern int lock_may_write(struct inode *, loff_t start, unsigned long count); 1133extern int lock_may_write(struct inode *, loff_t start, unsigned long count);
1134extern void lock_flocks(void);
1135extern void unlock_flocks(void);
1138#else /* !CONFIG_FILE_LOCKING */ 1136#else /* !CONFIG_FILE_LOCKING */
1139static inline int fcntl_getlk(struct file *file, struct flock __user *user) 1137static inline int fcntl_getlk(struct file *file, struct flock __user *user)
1140{ 1138{
@@ -1277,6 +1275,14 @@ static inline int lock_may_write(struct inode *inode, loff_t start,
1277 return 1; 1275 return 1;
1278} 1276}
1279 1277
1278static inline void lock_flocks(void)
1279{
1280}
1281
1282static inline void unlock_flocks(void)
1283{
1284}
1285
1280#endif /* !CONFIG_FILE_LOCKING */ 1286#endif /* !CONFIG_FILE_LOCKING */
1281 1287
1282 1288
@@ -2456,6 +2462,7 @@ static const struct file_operations __fops = { \
2456 .release = simple_attr_release, \ 2462 .release = simple_attr_release, \
2457 .read = simple_attr_read, \ 2463 .read = simple_attr_read, \
2458 .write = simple_attr_write, \ 2464 .write = simple_attr_write, \
2465 .llseek = generic_file_llseek, \
2459}; 2466};
2460 2467
2461static inline void __attribute__((format(printf, 1, 2))) 2468static inline void __attribute__((format(printf, 1, 2)))
diff --git a/include/linux/ncp_fs.h b/include/linux/ncp_fs.h
index 4522aed00906..ef663061d5ac 100644
--- a/include/linux/ncp_fs.h
+++ b/include/linux/ncp_fs.h
@@ -241,34 +241,6 @@ int ncp_mmap(struct file *, struct vm_area_struct *);
241/* linux/fs/ncpfs/ncplib_kernel.c */ 241/* linux/fs/ncpfs/ncplib_kernel.c */
242int ncp_make_closed(struct inode *); 242int ncp_make_closed(struct inode *);
243 243
244#define ncp_namespace(i) (NCP_SERVER(i)->name_space[NCP_FINFO(i)->volNumber])
245
246static inline int ncp_preserve_entry_case(struct inode *i, __u32 nscreator)
247{
248#ifdef CONFIG_NCPFS_SMALLDOS
249 int ns = ncp_namespace(i);
250
251 if ((ns == NW_NS_DOS)
252#ifdef CONFIG_NCPFS_OS2_NS
253 || ((ns == NW_NS_OS2) && (nscreator == NW_NS_DOS))
254#endif /* CONFIG_NCPFS_OS2_NS */
255 )
256 return 0;
257#endif /* CONFIG_NCPFS_SMALLDOS */
258 return 1;
259}
260
261#define ncp_preserve_case(i) (ncp_namespace(i) != NW_NS_DOS)
262
263static inline int ncp_case_sensitive(struct inode *i)
264{
265#ifdef CONFIG_NCPFS_NFS_NS
266 return ncp_namespace(i) == NW_NS_NFS;
267#else
268 return 0;
269#endif /* CONFIG_NCPFS_NFS_NS */
270}
271
272#endif /* __KERNEL__ */ 244#endif /* __KERNEL__ */
273 245
274#endif /* _LINUX_NCP_FS_H */ 246#endif /* _LINUX_NCP_FS_H */
diff --git a/include/linux/ncp_fs_sb.h b/include/linux/ncp_fs_sb.h
index 8da05bc098ca..d64b0e894336 100644
--- a/include/linux/ncp_fs_sb.h
+++ b/include/linux/ncp_fs_sb.h
@@ -62,6 +62,7 @@ struct ncp_server {
62 int ncp_reply_size; 62 int ncp_reply_size;
63 63
64 int root_setuped; 64 int root_setuped;
65 struct mutex root_setup_lock;
65 66
66 /* info for packet signing */ 67 /* info for packet signing */
67 int sign_wanted; /* 1=Server needs signed packets */ 68 int sign_wanted; /* 1=Server needs signed packets */
@@ -81,13 +82,14 @@ struct ncp_server {
81 size_t len; 82 size_t len;
82 void* data; 83 void* data;
83 } priv; 84 } priv;
85 struct rw_semaphore auth_rwsem;
84 86
85 /* nls info: codepage for volume and charset for I/O */ 87 /* nls info: codepage for volume and charset for I/O */
86 struct nls_table *nls_vol; 88 struct nls_table *nls_vol;
87 struct nls_table *nls_io; 89 struct nls_table *nls_io;
88 90
89 /* maximum age in jiffies */ 91 /* maximum age in jiffies */
90 int dentry_ttl; 92 atomic_t dentry_ttl;
91 93
92 /* miscellaneous */ 94 /* miscellaneous */
93 unsigned int flags; 95 unsigned int flags;
diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h
index 27ef6b190ea6..018db9a62ffe 100644
--- a/include/linux/percpu-defs.h
+++ b/include/linux/percpu-defs.h
@@ -148,6 +148,18 @@
148 DEFINE_PER_CPU_SECTION(type, name, "..readmostly") 148 DEFINE_PER_CPU_SECTION(type, name, "..readmostly")
149 149
150/* 150/*
151 * Declaration/definition used for large per-CPU variables that must be
152 * aligned to something larger than the pagesize.
153 */
154#define DECLARE_PER_CPU_MULTIPAGE_ALIGNED(type, name, size) \
155 DECLARE_PER_CPU_SECTION(type, name, "..page_aligned") \
156 __aligned(size)
157
158#define DEFINE_PER_CPU_MULTIPAGE_ALIGNED(type, name, size) \
159 DEFINE_PER_CPU_SECTION(type, name, "..page_aligned") \
160 __aligned(size)
161
162/*
151 * Intermodule exports for per-CPU variables. sparse forgets about 163 * Intermodule exports for per-CPU variables. sparse forgets about
152 * address space across EXPORT_SYMBOL(), change EXPORT_SYMBOL() to 164 * address space across EXPORT_SYMBOL(), change EXPORT_SYMBOL() to
153 * noop if __CHECKER__. 165 * noop if __CHECKER__.
diff --git a/include/linux/smp_lock.h b/include/linux/smp_lock.h
index 2ea1dd1ba21c..291f721144c2 100644
--- a/include/linux/smp_lock.h
+++ b/include/linux/smp_lock.h
@@ -54,12 +54,15 @@ static inline void cycle_kernel_lock(void)
54 54
55#else 55#else
56 56
57#ifdef CONFIG_BKL /* provoke build bug if not set */
57#define lock_kernel() 58#define lock_kernel()
58#define unlock_kernel() 59#define unlock_kernel()
59#define release_kernel_lock(task) do { } while(0)
60#define cycle_kernel_lock() do { } while(0) 60#define cycle_kernel_lock() do { } while(0)
61#define reacquire_kernel_lock(task) 0
62#define kernel_locked() 1 61#define kernel_locked() 1
62#endif /* CONFIG_BKL */
63
64#define release_kernel_lock(task) do { } while(0)
65#define reacquire_kernel_lock(task) 0
63 66
64#endif /* CONFIG_LOCK_KERNEL */ 67#endif /* CONFIG_LOCK_KERNEL */
65#endif /* __LINUX_SMPLOCK_H */ 68#endif /* __LINUX_SMPLOCK_H */
diff --git a/init/Kconfig b/init/Kconfig
index 36890f0c8456..be85a0ab1b82 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -71,7 +71,7 @@ config BROKEN_ON_SMP
71 71
72config LOCK_KERNEL 72config LOCK_KERNEL
73 bool 73 bool
74 depends on SMP || PREEMPT 74 depends on (SMP || PREEMPT) && BKL
75 default y 75 default y
76 76
77config INIT_ENV_ARG_LIMIT 77config INIT_ENV_ARG_LIMIT
diff --git a/init/main.c b/init/main.c
index 9684c9670b48..e59af24a0b7c 100644
--- a/init/main.c
+++ b/init/main.c
@@ -424,7 +424,6 @@ static void __init setup_command_line(char *command_line)
424static __initdata DECLARE_COMPLETION(kthreadd_done); 424static __initdata DECLARE_COMPLETION(kthreadd_done);
425 425
426static noinline void __init_refok rest_init(void) 426static noinline void __init_refok rest_init(void)
427 __releases(kernel_lock)
428{ 427{
429 int pid; 428 int pid;
430 429
@@ -818,7 +817,6 @@ static void run_init_process(const char *init_filename)
818 * makes it inline to init() and it becomes part of init.text section 817 * makes it inline to init() and it becomes part of init.text section
819 */ 818 */
820static noinline int init_post(void) 819static noinline int init_post(void)
821 __releases(kernel_lock)
822{ 820{
823 /* need to finish all async __init code before freeing the memory */ 821 /* need to finish all async __init code before freeing the memory */
824 async_synchronize_full(); 822 async_synchronize_full();
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index c60e519e2917..e1e7b9635f5d 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -1219,6 +1219,7 @@ static const struct file_operations mqueue_file_operations = {
1219 .flush = mqueue_flush_file, 1219 .flush = mqueue_flush_file,
1220 .poll = mqueue_poll_file, 1220 .poll = mqueue_poll_file,
1221 .read = mqueue_read_file, 1221 .read = mqueue_read_file,
1222 .llseek = default_llseek,
1222}; 1223};
1223 1224
1224static const struct super_operations mqueue_super_ops = { 1225static const struct super_operations mqueue_super_ops = {
diff --git a/ipc/shm.c b/ipc/shm.c
index 52ed77eb9713..7bc46a9fe1f8 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -298,6 +298,7 @@ static const struct file_operations shm_file_operations = {
298#ifndef CONFIG_MMU 298#ifndef CONFIG_MMU
299 .get_unmapped_area = shm_get_unmapped_area, 299 .get_unmapped_area = shm_get_unmapped_area,
300#endif 300#endif
301 .llseek = noop_llseek,
301}; 302};
302 303
303static const struct file_operations shm_file_operations_huge = { 304static const struct file_operations shm_file_operations_huge = {
@@ -305,6 +306,7 @@ static const struct file_operations shm_file_operations_huge = {
305 .fsync = shm_fsync, 306 .fsync = shm_fsync,
306 .release = shm_release, 307 .release = shm_release,
307 .get_unmapped_area = shm_get_unmapped_area, 308 .get_unmapped_area = shm_get_unmapped_area,
309 .llseek = noop_llseek,
308}; 310};
309 311
310int is_file_shm_hugepages(struct file *file) 312int is_file_shm_hugepages(struct file *file)
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 291ba3d04bea..7b69b8d0313d 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -52,7 +52,6 @@
52#include <linux/cgroupstats.h> 52#include <linux/cgroupstats.h>
53#include <linux/hash.h> 53#include <linux/hash.h>
54#include <linux/namei.h> 54#include <linux/namei.h>
55#include <linux/smp_lock.h>
56#include <linux/pid_namespace.h> 55#include <linux/pid_namespace.h>
57#include <linux/idr.h> 56#include <linux/idr.h>
58#include <linux/vmalloc.h> /* TODO: replace with more sophisticated array */ 57#include <linux/vmalloc.h> /* TODO: replace with more sophisticated array */
@@ -1222,7 +1221,6 @@ static int cgroup_remount(struct super_block *sb, int *flags, char *data)
1222 struct cgroup *cgrp = &root->top_cgroup; 1221 struct cgroup *cgrp = &root->top_cgroup;
1223 struct cgroup_sb_opts opts; 1222 struct cgroup_sb_opts opts;
1224 1223
1225 lock_kernel();
1226 mutex_lock(&cgrp->dentry->d_inode->i_mutex); 1224 mutex_lock(&cgrp->dentry->d_inode->i_mutex);
1227 mutex_lock(&cgroup_mutex); 1225 mutex_lock(&cgroup_mutex);
1228 1226
@@ -1255,7 +1253,6 @@ static int cgroup_remount(struct super_block *sb, int *flags, char *data)
1255 kfree(opts.name); 1253 kfree(opts.name);
1256 mutex_unlock(&cgroup_mutex); 1254 mutex_unlock(&cgroup_mutex);
1257 mutex_unlock(&cgrp->dentry->d_inode->i_mutex); 1255 mutex_unlock(&cgrp->dentry->d_inode->i_mutex);
1258 unlock_kernel();
1259 return ret; 1256 return ret;
1260} 1257}
1261 1258
@@ -1568,7 +1565,6 @@ static int cgroup_get_sb(struct file_system_type *fs_type,
1568 out_err: 1565 out_err:
1569 kfree(opts.release_agent); 1566 kfree(opts.release_agent);
1570 kfree(opts.name); 1567 kfree(opts.name);
1571
1572 return ret; 1568 return ret;
1573} 1569}
1574 1570
diff --git a/kernel/configs.c b/kernel/configs.c
index abaee684ecbf..b4066b44a99d 100644
--- a/kernel/configs.c
+++ b/kernel/configs.c
@@ -66,6 +66,7 @@ ikconfig_read_current(struct file *file, char __user *buf,
66static const struct file_operations ikconfig_file_ops = { 66static const struct file_operations ikconfig_file_ops = {
67 .owner = THIS_MODULE, 67 .owner = THIS_MODULE,
68 .read = ikconfig_read_current, 68 .read = ikconfig_read_current,
69 .llseek = default_llseek,
69}; 70};
70 71
71static int __init ikconfig_init(void) 72static int __init ikconfig_init(void)
diff --git a/kernel/gcov/fs.c b/kernel/gcov/fs.c
index f83972b16564..9bd0934f6c33 100644
--- a/kernel/gcov/fs.c
+++ b/kernel/gcov/fs.c
@@ -561,6 +561,7 @@ static ssize_t reset_read(struct file *file, char __user *addr, size_t len,
561static const struct file_operations gcov_reset_fops = { 561static const struct file_operations gcov_reset_fops = {
562 .write = reset_write, 562 .write = reset_write,
563 .read = reset_read, 563 .read = reset_read,
564 .llseek = noop_llseek,
564}; 565};
565 566
566/* 567/*
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index ec4210c6501e..56a891914273 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -2000,6 +2000,7 @@ static ssize_t write_enabled_file_bool(struct file *file,
2000static const struct file_operations fops_kp = { 2000static const struct file_operations fops_kp = {
2001 .read = read_enabled_file_bool, 2001 .read = read_enabled_file_bool,
2002 .write = write_enabled_file_bool, 2002 .write = write_enabled_file_bool,
2003 .llseek = default_llseek,
2003}; 2004};
2004 2005
2005static int __kprobes debugfs_kprobe_init(void) 2006static int __kprobes debugfs_kprobe_init(void)
diff --git a/kernel/pm_qos_params.c b/kernel/pm_qos_params.c
index 645e541a45f6..a96b850ba08a 100644
--- a/kernel/pm_qos_params.c
+++ b/kernel/pm_qos_params.c
@@ -110,6 +110,7 @@ static const struct file_operations pm_qos_power_fops = {
110 .write = pm_qos_power_write, 110 .write = pm_qos_power_write,
111 .open = pm_qos_power_open, 111 .open = pm_qos_power_open,
112 .release = pm_qos_power_release, 112 .release = pm_qos_power_release,
113 .llseek = noop_llseek,
113}; 114};
114 115
115/* unlocked internal variant */ 116/* unlocked internal variant */
diff --git a/kernel/profile.c b/kernel/profile.c
index b22a899934cc..66f841b7fbd3 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -555,6 +555,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
555static const struct file_operations proc_profile_operations = { 555static const struct file_operations proc_profile_operations = {
556 .read = read_profile, 556 .read = read_profile,
557 .write = write_profile, 557 .write = write_profile,
558 .llseek = default_llseek,
558}; 559};
559 560
560#ifdef CONFIG_SMP 561#ifdef CONFIG_SMP
diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
index a56f629b057a..66cb89bc5ef1 100644
--- a/kernel/rtmutex-tester.c
+++ b/kernel/rtmutex-tester.c
@@ -76,7 +76,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
76 } 76 }
77 77
78 if (!lockwakeup && td->bkl == 4) { 78 if (!lockwakeup && td->bkl == 4) {
79#ifdef CONFIG_LOCK_KERNEL
79 unlock_kernel(); 80 unlock_kernel();
81#endif
80 td->bkl = 0; 82 td->bkl = 0;
81 } 83 }
82 return 0; 84 return 0;
@@ -133,14 +135,18 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
133 if (td->bkl) 135 if (td->bkl)
134 return 0; 136 return 0;
135 td->bkl = 1; 137 td->bkl = 1;
138#ifdef CONFIG_LOCK_KERNEL
136 lock_kernel(); 139 lock_kernel();
140#endif
137 td->bkl = 4; 141 td->bkl = 4;
138 return 0; 142 return 0;
139 143
140 case RTTEST_UNLOCKBKL: 144 case RTTEST_UNLOCKBKL:
141 if (td->bkl != 4) 145 if (td->bkl != 4)
142 break; 146 break;
147#ifdef CONFIG_LOCK_KERNEL
143 unlock_kernel(); 148 unlock_kernel();
149#endif
144 td->bkl = 0; 150 td->bkl = 0;
145 return 0; 151 return 0;
146 152
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index 959f8d6c8cc1..bc251ed66724 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -23,7 +23,6 @@
23#include <linux/mutex.h> 23#include <linux/mutex.h>
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/debugfs.h> 25#include <linux/debugfs.h>
26#include <linux/smp_lock.h>
27#include <linux/time.h> 26#include <linux/time.h>
28#include <linux/uaccess.h> 27#include <linux/uaccess.h>
29 28
@@ -326,6 +325,7 @@ static const struct file_operations blk_dropped_fops = {
326 .owner = THIS_MODULE, 325 .owner = THIS_MODULE,
327 .open = blk_dropped_open, 326 .open = blk_dropped_open,
328 .read = blk_dropped_read, 327 .read = blk_dropped_read,
328 .llseek = default_llseek,
329}; 329};
330 330
331static int blk_msg_open(struct inode *inode, struct file *filp) 331static int blk_msg_open(struct inode *inode, struct file *filp)
@@ -365,6 +365,7 @@ static const struct file_operations blk_msg_fops = {
365 .owner = THIS_MODULE, 365 .owner = THIS_MODULE,
366 .open = blk_msg_open, 366 .open = blk_msg_open,
367 .write = blk_msg_write, 367 .write = blk_msg_write,
368 .llseek = noop_llseek,
368}; 369};
369 370
370/* 371/*
@@ -639,7 +640,6 @@ int blk_trace_ioctl(struct block_device *bdev, unsigned cmd, char __user *arg)
639 if (!q) 640 if (!q)
640 return -ENXIO; 641 return -ENXIO;
641 642
642 lock_kernel();
643 mutex_lock(&bdev->bd_mutex); 643 mutex_lock(&bdev->bd_mutex);
644 644
645 switch (cmd) { 645 switch (cmd) {
@@ -667,7 +667,6 @@ int blk_trace_ioctl(struct block_device *bdev, unsigned cmd, char __user *arg)
667 } 667 }
668 668
669 mutex_unlock(&bdev->bd_mutex); 669 mutex_unlock(&bdev->bd_mutex);
670 unlock_kernel();
671 return ret; 670 return ret;
672} 671}
673 672
@@ -1652,10 +1651,9 @@ static ssize_t sysfs_blk_trace_attr_show(struct device *dev,
1652 struct block_device *bdev; 1651 struct block_device *bdev;
1653 ssize_t ret = -ENXIO; 1652 ssize_t ret = -ENXIO;
1654 1653
1655 lock_kernel();
1656 bdev = bdget(part_devt(p)); 1654 bdev = bdget(part_devt(p));
1657 if (bdev == NULL) 1655 if (bdev == NULL)
1658 goto out_unlock_kernel; 1656 goto out;
1659 1657
1660 q = blk_trace_get_queue(bdev); 1658 q = blk_trace_get_queue(bdev);
1661 if (q == NULL) 1659 if (q == NULL)
@@ -1683,8 +1681,7 @@ out_unlock_bdev:
1683 mutex_unlock(&bdev->bd_mutex); 1681 mutex_unlock(&bdev->bd_mutex);
1684out_bdput: 1682out_bdput:
1685 bdput(bdev); 1683 bdput(bdev);
1686out_unlock_kernel: 1684out:
1687 unlock_kernel();
1688 return ret; 1685 return ret;
1689} 1686}
1690 1687
@@ -1714,11 +1711,10 @@ static ssize_t sysfs_blk_trace_attr_store(struct device *dev,
1714 1711
1715 ret = -ENXIO; 1712 ret = -ENXIO;
1716 1713
1717 lock_kernel();
1718 p = dev_to_part(dev); 1714 p = dev_to_part(dev);
1719 bdev = bdget(part_devt(p)); 1715 bdev = bdget(part_devt(p));
1720 if (bdev == NULL) 1716 if (bdev == NULL)
1721 goto out_unlock_kernel; 1717 goto out;
1722 1718
1723 q = blk_trace_get_queue(bdev); 1719 q = blk_trace_get_queue(bdev);
1724 if (q == NULL) 1720 if (q == NULL)
@@ -1753,8 +1749,6 @@ out_unlock_bdev:
1753 mutex_unlock(&bdev->bd_mutex); 1749 mutex_unlock(&bdev->bd_mutex);
1754out_bdput: 1750out_bdput:
1755 bdput(bdev); 1751 bdput(bdev);
1756out_unlock_kernel:
1757 unlock_kernel();
1758out: 1752out:
1759 return ret ? ret : count; 1753 return ret ? ret : count;
1760} 1754}
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index ebd80d50c474..f3dadae83883 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -800,6 +800,7 @@ static const struct file_operations ftrace_profile_fops = {
800 .open = tracing_open_generic, 800 .open = tracing_open_generic,
801 .read = ftrace_profile_read, 801 .read = ftrace_profile_read,
802 .write = ftrace_profile_write, 802 .write = ftrace_profile_write,
803 .llseek = default_llseek,
803}; 804};
804 805
805/* used to initialize the real stat files */ 806/* used to initialize the real stat files */
@@ -2669,6 +2670,7 @@ static const struct file_operations ftrace_graph_fops = {
2669 .read = seq_read, 2670 .read = seq_read,
2670 .write = ftrace_graph_write, 2671 .write = ftrace_graph_write,
2671 .release = ftrace_graph_release, 2672 .release = ftrace_graph_release,
2673 .llseek = seq_lseek,
2672}; 2674};
2673#endif /* CONFIG_FUNCTION_GRAPH_TRACER */ 2675#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
2674 2676
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index c5a632a669e1..c3dab054d18e 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -3974,6 +3974,7 @@ static const struct file_operations rb_simple_fops = {
3974 .open = tracing_open_generic, 3974 .open = tracing_open_generic,
3975 .read = rb_simple_read, 3975 .read = rb_simple_read,
3976 .write = rb_simple_write, 3976 .write = rb_simple_write,
3977 .llseek = default_llseek,
3977}; 3978};
3978 3979
3979 3980
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 398c0e8b332c..0725eeab1937 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -932,6 +932,7 @@ static const struct file_operations ftrace_enable_fops = {
932 .open = tracing_open_generic, 932 .open = tracing_open_generic,
933 .read = event_enable_read, 933 .read = event_enable_read,
934 .write = event_enable_write, 934 .write = event_enable_write,
935 .llseek = default_llseek,
935}; 936};
936 937
937static const struct file_operations ftrace_event_format_fops = { 938static const struct file_operations ftrace_event_format_fops = {
@@ -944,29 +945,34 @@ static const struct file_operations ftrace_event_format_fops = {
944static const struct file_operations ftrace_event_id_fops = { 945static const struct file_operations ftrace_event_id_fops = {
945 .open = tracing_open_generic, 946 .open = tracing_open_generic,
946 .read = event_id_read, 947 .read = event_id_read,
948 .llseek = default_llseek,
947}; 949};
948 950
949static const struct file_operations ftrace_event_filter_fops = { 951static const struct file_operations ftrace_event_filter_fops = {
950 .open = tracing_open_generic, 952 .open = tracing_open_generic,
951 .read = event_filter_read, 953 .read = event_filter_read,
952 .write = event_filter_write, 954 .write = event_filter_write,
955 .llseek = default_llseek,
953}; 956};
954 957
955static const struct file_operations ftrace_subsystem_filter_fops = { 958static const struct file_operations ftrace_subsystem_filter_fops = {
956 .open = tracing_open_generic, 959 .open = tracing_open_generic,
957 .read = subsystem_filter_read, 960 .read = subsystem_filter_read,
958 .write = subsystem_filter_write, 961 .write = subsystem_filter_write,
962 .llseek = default_llseek,
959}; 963};
960 964
961static const struct file_operations ftrace_system_enable_fops = { 965static const struct file_operations ftrace_system_enable_fops = {
962 .open = tracing_open_generic, 966 .open = tracing_open_generic,
963 .read = system_enable_read, 967 .read = system_enable_read,
964 .write = system_enable_write, 968 .write = system_enable_write,
969 .llseek = default_llseek,
965}; 970};
966 971
967static const struct file_operations ftrace_show_header_fops = { 972static const struct file_operations ftrace_show_header_fops = {
968 .open = tracing_open_generic, 973 .open = tracing_open_generic,
969 .read = show_header, 974 .read = show_header,
975 .llseek = default_llseek,
970}; 976};
971 977
972static struct dentry *event_trace_events_dir(void) 978static struct dentry *event_trace_events_dir(void)
diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
index a6b7e0e0f3eb..4c5dead0c239 100644
--- a/kernel/trace/trace_stack.c
+++ b/kernel/trace/trace_stack.c
@@ -195,6 +195,7 @@ static const struct file_operations stack_max_size_fops = {
195 .open = tracing_open_generic, 195 .open = tracing_open_generic,
196 .read = stack_max_size_read, 196 .read = stack_max_size_read,
197 .write = stack_max_size_write, 197 .write = stack_max_size_write,
198 .llseek = default_llseek,
198}; 199};
199 200
200static void * 201static void *
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 21ac83070a80..7b2a8ca97ada 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -461,6 +461,15 @@ config DEBUG_MUTEXES
461 This feature allows mutex semantics violations to be detected and 461 This feature allows mutex semantics violations to be detected and
462 reported. 462 reported.
463 463
464config BKL
465 bool "Big Kernel Lock" if (SMP || PREEMPT)
466 default y
467 help
468 This is the traditional lock that is used in old code instead
469 of proper locking. All drivers that use the BKL should depend
470 on this symbol.
471 Say Y here unless you are working on removing the BKL.
472
464config DEBUG_LOCK_ALLOC 473config DEBUG_LOCK_ALLOC
465 bool "Lock debugging: detect incorrect freeing of live locks" 474 bool "Lock debugging: detect incorrect freeing of live locks"
466 depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT 475 depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index 01e64270e246..4bfb0471f106 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -590,6 +590,7 @@ out_unlock:
590static const struct file_operations filter_fops = { 590static const struct file_operations filter_fops = {
591 .read = filter_read, 591 .read = filter_read,
592 .write = filter_write, 592 .write = filter_write,
593 .llseek = default_llseek,
593}; 594};
594 595
595static int dma_debug_fs_init(void) 596static int dma_debug_fs_init(void)
diff --git a/net/atm/proc.c b/net/atm/proc.c
index 6262aeae398e..f85da0779e5e 100644
--- a/net/atm/proc.c
+++ b/net/atm/proc.c
@@ -38,6 +38,7 @@ static ssize_t proc_dev_atm_read(struct file *file, char __user *buf,
38static const struct file_operations proc_atm_dev_ops = { 38static const struct file_operations proc_atm_dev_ops = {
39 .owner = THIS_MODULE, 39 .owner = THIS_MODULE,
40 .read = proc_dev_atm_read, 40 .read = proc_dev_atm_read,
41 .llseek = noop_llseek,
41}; 42};
42 43
43static void add_stats(struct seq_file *seq, const char *aal, 44static void add_stats(struct seq_file *seq, const char *aal,
diff --git a/net/dccp/probe.c b/net/dccp/probe.c
index 078e48d442fd..33d0e6297c21 100644
--- a/net/dccp/probe.c
+++ b/net/dccp/probe.c
@@ -149,6 +149,7 @@ static const struct file_operations dccpprobe_fops = {
149 .owner = THIS_MODULE, 149 .owner = THIS_MODULE,
150 .open = dccpprobe_open, 150 .open = dccpprobe_open,
151 .read = dccpprobe_read, 151 .read = dccpprobe_read,
152 .llseek = noop_llseek,
152}; 153};
153 154
154static __init int dccpprobe_init(void) 155static __init int dccpprobe_init(void)
diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
index f8efada580e8..6211e2114173 100644
--- a/net/ipv4/tcp_probe.c
+++ b/net/ipv4/tcp_probe.c
@@ -214,6 +214,7 @@ static const struct file_operations tcpprobe_fops = {
214 .owner = THIS_MODULE, 214 .owner = THIS_MODULE,
215 .open = tcpprobe_open, 215 .open = tcpprobe_open,
216 .read = tcpprobe_read, 216 .read = tcpprobe_read,
217 .llseek = noop_llseek,
217}; 218};
218 219
219static __init int tcpprobe_init(void) 220static __init int tcpprobe_init(void)
diff --git a/net/ipx/Kconfig b/net/ipx/Kconfig
index e9ad0062fbb6..02549cb2c328 100644
--- a/net/ipx/Kconfig
+++ b/net/ipx/Kconfig
@@ -3,6 +3,7 @@
3# 3#
4config IPX 4config IPX
5 tristate "The IPX protocol" 5 tristate "The IPX protocol"
6 depends on BKL # should be fixable
6 select LLC 7 select LLC
7 ---help--- 8 ---help---
8 This is support for the Novell networking protocol, IPX, commonly 9 This is support for the Novell networking protocol, IPX, commonly
diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c
index a694c593ff6a..b8b0ae79a743 100644
--- a/net/mac80211/debugfs.c
+++ b/net/mac80211/debugfs.c
@@ -36,6 +36,7 @@ static ssize_t name## _read(struct file *file, char __user *userbuf, \
36static const struct file_operations name## _ops = { \ 36static const struct file_operations name## _ops = { \
37 .read = name## _read, \ 37 .read = name## _read, \
38 .open = mac80211_open_file_generic, \ 38 .open = mac80211_open_file_generic, \
39 .llseek = generic_file_llseek, \
39}; 40};
40 41
41#define DEBUGFS_ADD(name) \ 42#define DEBUGFS_ADD(name) \
@@ -101,7 +102,8 @@ static ssize_t tsf_write(struct file *file,
101static const struct file_operations tsf_ops = { 102static const struct file_operations tsf_ops = {
102 .read = tsf_read, 103 .read = tsf_read,
103 .write = tsf_write, 104 .write = tsf_write,
104 .open = mac80211_open_file_generic 105 .open = mac80211_open_file_generic,
106 .llseek = default_llseek,
105}; 107};
106 108
107static ssize_t reset_write(struct file *file, const char __user *user_buf, 109static ssize_t reset_write(struct file *file, const char __user *user_buf,
@@ -120,6 +122,7 @@ static ssize_t reset_write(struct file *file, const char __user *user_buf,
120static const struct file_operations reset_ops = { 122static const struct file_operations reset_ops = {
121 .write = reset_write, 123 .write = reset_write,
122 .open = mac80211_open_file_generic, 124 .open = mac80211_open_file_generic,
125 .llseek = noop_llseek,
123}; 126};
124 127
125static ssize_t noack_read(struct file *file, char __user *user_buf, 128static ssize_t noack_read(struct file *file, char __user *user_buf,
@@ -155,7 +158,8 @@ static ssize_t noack_write(struct file *file,
155static const struct file_operations noack_ops = { 158static const struct file_operations noack_ops = {
156 .read = noack_read, 159 .read = noack_read,
157 .write = noack_write, 160 .write = noack_write,
158 .open = mac80211_open_file_generic 161 .open = mac80211_open_file_generic,
162 .llseek = default_llseek,
159}; 163};
160 164
161static ssize_t uapsd_queues_read(struct file *file, char __user *user_buf, 165static ssize_t uapsd_queues_read(struct file *file, char __user *user_buf,
@@ -201,7 +205,8 @@ static ssize_t uapsd_queues_write(struct file *file,
201static const struct file_operations uapsd_queues_ops = { 205static const struct file_operations uapsd_queues_ops = {
202 .read = uapsd_queues_read, 206 .read = uapsd_queues_read,
203 .write = uapsd_queues_write, 207 .write = uapsd_queues_write,
204 .open = mac80211_open_file_generic 208 .open = mac80211_open_file_generic,
209 .llseek = default_llseek,
205}; 210};
206 211
207static ssize_t uapsd_max_sp_len_read(struct file *file, char __user *user_buf, 212static ssize_t uapsd_max_sp_len_read(struct file *file, char __user *user_buf,
@@ -247,7 +252,8 @@ static ssize_t uapsd_max_sp_len_write(struct file *file,
247static const struct file_operations uapsd_max_sp_len_ops = { 252static const struct file_operations uapsd_max_sp_len_ops = {
248 .read = uapsd_max_sp_len_read, 253 .read = uapsd_max_sp_len_read,
249 .write = uapsd_max_sp_len_write, 254 .write = uapsd_max_sp_len_write,
250 .open = mac80211_open_file_generic 255 .open = mac80211_open_file_generic,
256 .llseek = default_llseek,
251}; 257};
252 258
253static ssize_t channel_type_read(struct file *file, char __user *user_buf, 259static ssize_t channel_type_read(struct file *file, char __user *user_buf,
@@ -279,7 +285,8 @@ static ssize_t channel_type_read(struct file *file, char __user *user_buf,
279 285
280static const struct file_operations channel_type_ops = { 286static const struct file_operations channel_type_ops = {
281 .read = channel_type_read, 287 .read = channel_type_read,
282 .open = mac80211_open_file_generic 288 .open = mac80211_open_file_generic,
289 .llseek = default_llseek,
283}; 290};
284 291
285static ssize_t queues_read(struct file *file, char __user *user_buf, 292static ssize_t queues_read(struct file *file, char __user *user_buf,
@@ -302,7 +309,8 @@ static ssize_t queues_read(struct file *file, char __user *user_buf,
302 309
303static const struct file_operations queues_ops = { 310static const struct file_operations queues_ops = {
304 .read = queues_read, 311 .read = queues_read,
305 .open = mac80211_open_file_generic 312 .open = mac80211_open_file_generic,
313 .llseek = default_llseek,
306}; 314};
307 315
308/* statistics stuff */ 316/* statistics stuff */
@@ -346,6 +354,7 @@ static ssize_t stats_ ##name## _read(struct file *file, \
346static const struct file_operations stats_ ##name## _ops = { \ 354static const struct file_operations stats_ ##name## _ops = { \
347 .read = stats_ ##name## _read, \ 355 .read = stats_ ##name## _read, \
348 .open = mac80211_open_file_generic, \ 356 .open = mac80211_open_file_generic, \
357 .llseek = generic_file_llseek, \
349}; 358};
350 359
351#define DEBUGFS_STATS_ADD(name, field) \ 360#define DEBUGFS_STATS_ADD(name, field) \
diff --git a/net/mac80211/debugfs_key.c b/net/mac80211/debugfs_key.c
index fa5e76e658ef..7cd8dd9fc240 100644
--- a/net/mac80211/debugfs_key.c
+++ b/net/mac80211/debugfs_key.c
@@ -32,6 +32,7 @@ static ssize_t key_##name##_read(struct file *file, \
32static const struct file_operations key_ ##name## _ops = { \ 32static const struct file_operations key_ ##name## _ops = { \
33 .read = key_##name##_read, \ 33 .read = key_##name##_read, \
34 .open = mac80211_open_file_generic, \ 34 .open = mac80211_open_file_generic, \
35 .llseek = generic_file_llseek, \
35} 36}
36 37
37#define KEY_FILE(name, format) \ 38#define KEY_FILE(name, format) \
@@ -46,6 +47,7 @@ static const struct file_operations key_ ##name## _ops = { \
46static const struct file_operations key_ ##name## _ops = { \ 47static const struct file_operations key_ ##name## _ops = { \
47 .read = key_conf_##name##_read, \ 48 .read = key_conf_##name##_read, \
48 .open = mac80211_open_file_generic, \ 49 .open = mac80211_open_file_generic, \
50 .llseek = generic_file_llseek, \
49} 51}
50 52
51#define KEY_CONF_FILE(name, format) \ 53#define KEY_CONF_FILE(name, format) \
diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c
index 20b2998fa0ed..8ad33eef7dda 100644
--- a/net/mac80211/debugfs_netdev.c
+++ b/net/mac80211/debugfs_netdev.c
@@ -121,6 +121,7 @@ static const struct file_operations name##_ops = { \
121 .read = ieee80211_if_read_##name, \ 121 .read = ieee80211_if_read_##name, \
122 .write = (_write), \ 122 .write = (_write), \
123 .open = mac80211_open_file_generic, \ 123 .open = mac80211_open_file_generic, \
124 .llseek = generic_file_llseek, \
124} 125}
125 126
126#define __IEEE80211_IF_FILE_W(name) \ 127#define __IEEE80211_IF_FILE_W(name) \
diff --git a/net/mac80211/debugfs_sta.c b/net/mac80211/debugfs_sta.c
index 76839d4dfaac..6a8fdc372c43 100644
--- a/net/mac80211/debugfs_sta.c
+++ b/net/mac80211/debugfs_sta.c
@@ -36,6 +36,7 @@ static ssize_t sta_ ##name## _read(struct file *file, \
36static const struct file_operations sta_ ##name## _ops = { \ 36static const struct file_operations sta_ ##name## _ops = { \
37 .read = sta_##name##_read, \ 37 .read = sta_##name##_read, \
38 .open = mac80211_open_file_generic, \ 38 .open = mac80211_open_file_generic, \
39 .llseek = generic_file_llseek, \
39} 40}
40 41
41#define STA_OPS_RW(name) \ 42#define STA_OPS_RW(name) \
@@ -43,6 +44,7 @@ static const struct file_operations sta_ ##name## _ops = { \
43 .read = sta_##name##_read, \ 44 .read = sta_##name##_read, \
44 .write = sta_##name##_write, \ 45 .write = sta_##name##_write, \
45 .open = mac80211_open_file_generic, \ 46 .open = mac80211_open_file_generic, \
47 .llseek = generic_file_llseek, \
46} 48}
47 49
48#define STA_FILE(name, field, format) \ 50#define STA_FILE(name, field, format) \
diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
index be04d46110fe..334cbd3d2aae 100644
--- a/net/mac80211/rate.c
+++ b/net/mac80211/rate.c
@@ -145,6 +145,7 @@ static ssize_t rcname_read(struct file *file, char __user *userbuf,
145static const struct file_operations rcname_ops = { 145static const struct file_operations rcname_ops = {
146 .read = rcname_read, 146 .read = rcname_read,
147 .open = mac80211_open_file_generic, 147 .open = mac80211_open_file_generic,
148 .llseek = default_llseek,
148}; 149};
149#endif 150#endif
150 151
diff --git a/net/mac80211/rc80211_minstrel_debugfs.c b/net/mac80211/rc80211_minstrel_debugfs.c
index 241e76f3fdf2..a290ad231d77 100644
--- a/net/mac80211/rc80211_minstrel_debugfs.c
+++ b/net/mac80211/rc80211_minstrel_debugfs.c
@@ -122,6 +122,7 @@ static const struct file_operations minstrel_stat_fops = {
122 .open = minstrel_stats_open, 122 .open = minstrel_stats_open,
123 .read = minstrel_stats_read, 123 .read = minstrel_stats_read,
124 .release = minstrel_stats_release, 124 .release = minstrel_stats_release,
125 .llseek = default_llseek,
125}; 126};
126 127
127void 128void
diff --git a/net/mac80211/rc80211_minstrel_ht_debugfs.c b/net/mac80211/rc80211_minstrel_ht_debugfs.c
index 4a5a4b3e7799..cefcb5d2dae6 100644
--- a/net/mac80211/rc80211_minstrel_ht_debugfs.c
+++ b/net/mac80211/rc80211_minstrel_ht_debugfs.c
@@ -90,7 +90,7 @@ minstrel_ht_stats_open(struct inode *inode, struct file *file)
90 MINSTREL_TRUNC(mi->avg_ampdu_len * 10) % 10); 90 MINSTREL_TRUNC(mi->avg_ampdu_len * 10) % 10);
91 ms->len = p - ms->buf; 91 ms->len = p - ms->buf;
92 92
93 return 0; 93 return nonseekable_open(inode, file);
94} 94}
95 95
96static const struct file_operations minstrel_ht_stat_fops = { 96static const struct file_operations minstrel_ht_stat_fops = {
@@ -98,6 +98,7 @@ static const struct file_operations minstrel_ht_stat_fops = {
98 .open = minstrel_ht_stats_open, 98 .open = minstrel_ht_stats_open,
99 .read = minstrel_stats_read, 99 .read = minstrel_stats_read,
100 .release = minstrel_stats_release, 100 .release = minstrel_stats_release,
101 .llseek = no_llseek,
101}; 102};
102 103
103void 104void
diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
index 47438b4a9af5..7905f79cc2e4 100644
--- a/net/mac80211/rc80211_pid_debugfs.c
+++ b/net/mac80211/rc80211_pid_debugfs.c
@@ -206,6 +206,7 @@ static const struct file_operations rc_pid_fop_events = {
206 .poll = rate_control_pid_events_poll, 206 .poll = rate_control_pid_events_poll,
207 .open = rate_control_pid_events_open, 207 .open = rate_control_pid_events_open,
208 .release = rate_control_pid_events_release, 208 .release = rate_control_pid_events_release,
209 .llseek = noop_llseek,
209}; 210};
210 211
211void rate_control_pid_add_sta_debugfs(void *priv, void *priv_sta, 212void rate_control_pid_add_sta_debugfs(void *priv, void *priv_sta,
diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c
index 76aec6a44762..d2ff15a2412b 100644
--- a/net/netfilter/xt_recent.c
+++ b/net/netfilter/xt_recent.c
@@ -567,6 +567,7 @@ static const struct file_operations recent_mt_fops = {
567 .write = recent_mt_proc_write, 567 .write = recent_mt_proc_write,
568 .release = seq_release_private, 568 .release = seq_release_private,
569 .owner = THIS_MODULE, 569 .owner = THIS_MODULE,
570 .llseek = seq_lseek,
570}; 571};
571 572
572static int __net_init recent_proc_net_init(struct net *net) 573static int __net_init recent_proc_net_init(struct net *net)
diff --git a/net/nonet.c b/net/nonet.c
index 92e76640c7cd..b1a73fda9c12 100644
--- a/net/nonet.c
+++ b/net/nonet.c
@@ -22,4 +22,5 @@ static int sock_no_open(struct inode *irrelevant, struct file *dontcare)
22const struct file_operations bad_sock_fops = { 22const struct file_operations bad_sock_fops = {
23 .owner = THIS_MODULE, 23 .owner = THIS_MODULE,
24 .open = sock_no_open, 24 .open = sock_no_open,
25 .llseek = noop_llseek,
25}; 26};
diff --git a/net/rfkill/core.c b/net/rfkill/core.c
index 51875a0c5d48..04f599089e6d 100644
--- a/net/rfkill/core.c
+++ b/net/rfkill/core.c
@@ -1241,6 +1241,7 @@ static const struct file_operations rfkill_fops = {
1241 .unlocked_ioctl = rfkill_fop_ioctl, 1241 .unlocked_ioctl = rfkill_fop_ioctl,
1242 .compat_ioctl = rfkill_fop_ioctl, 1242 .compat_ioctl = rfkill_fop_ioctl,
1243#endif 1243#endif
1244 .llseek = no_llseek,
1244}; 1245};
1245 1246
1246static struct miscdevice rfkill_miscdev = { 1247static struct miscdevice rfkill_miscdev = {
diff --git a/net/sctp/probe.c b/net/sctp/probe.c
index db3a42b8b349..289b1ba62cac 100644
--- a/net/sctp/probe.c
+++ b/net/sctp/probe.c
@@ -117,6 +117,7 @@ static const struct file_operations sctpprobe_fops = {
117 .owner = THIS_MODULE, 117 .owner = THIS_MODULE,
118 .open = sctpprobe_open, 118 .open = sctpprobe_open,
119 .read = sctpprobe_read, 119 .read = sctpprobe_read,
120 .llseek = noop_llseek,
120}; 121};
121 122
122sctp_disposition_t jsctp_sf_eat_sack(const struct sctp_endpoint *ep, 123sctp_disposition_t jsctp_sf_eat_sack(const struct sctp_endpoint *ep,
diff --git a/net/socket.c b/net/socket.c
index 2270b941bcc7..9eac5c394134 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -502,6 +502,7 @@ static int sock_no_open(struct inode *irrelevant, struct file *dontcare)
502const struct file_operations bad_sock_fops = { 502const struct file_operations bad_sock_fops = {
503 .owner = THIS_MODULE, 503 .owner = THIS_MODULE,
504 .open = sock_no_open, 504 .open = sock_no_open,
505 .llseek = noop_llseek,
505}; 506};
506 507
507/** 508/**
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index 2b06410e584e..7dce81a926c5 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -28,7 +28,6 @@
28#include <linux/workqueue.h> 28#include <linux/workqueue.h>
29#include <linux/mutex.h> 29#include <linux/mutex.h>
30#include <linux/pagemap.h> 30#include <linux/pagemap.h>
31#include <linux/smp_lock.h>
32#include <asm/ioctls.h> 31#include <asm/ioctls.h>
33#include <linux/sunrpc/types.h> 32#include <linux/sunrpc/types.h>
34#include <linux/sunrpc/cache.h> 33#include <linux/sunrpc/cache.h>
@@ -1348,15 +1347,10 @@ static unsigned int cache_poll_procfs(struct file *filp, poll_table *wait)
1348static long cache_ioctl_procfs(struct file *filp, 1347static long cache_ioctl_procfs(struct file *filp,
1349 unsigned int cmd, unsigned long arg) 1348 unsigned int cmd, unsigned long arg)
1350{ 1349{
1351 long ret;
1352 struct inode *inode = filp->f_path.dentry->d_inode; 1350 struct inode *inode = filp->f_path.dentry->d_inode;
1353 struct cache_detail *cd = PDE(inode)->data; 1351 struct cache_detail *cd = PDE(inode)->data;
1354 1352
1355 lock_kernel(); 1353 return cache_ioctl(inode, filp, cmd, arg, cd);
1356 ret = cache_ioctl(inode, filp, cmd, arg, cd);
1357 unlock_kernel();
1358
1359 return ret;
1360} 1354}
1361 1355
1362static int cache_open_procfs(struct inode *inode, struct file *filp) 1356static int cache_open_procfs(struct inode *inode, struct file *filp)
@@ -1441,6 +1435,7 @@ static const struct file_operations cache_flush_operations_procfs = {
1441 .read = read_flush_procfs, 1435 .read = read_flush_procfs,
1442 .write = write_flush_procfs, 1436 .write = write_flush_procfs,
1443 .release = release_flush_procfs, 1437 .release = release_flush_procfs,
1438 .llseek = no_llseek,
1444}; 1439};
1445 1440
1446static void remove_cache_proc_entries(struct cache_detail *cd) 1441static void remove_cache_proc_entries(struct cache_detail *cd)
@@ -1555,13 +1550,8 @@ static long cache_ioctl_pipefs(struct file *filp,
1555{ 1550{
1556 struct inode *inode = filp->f_dentry->d_inode; 1551 struct inode *inode = filp->f_dentry->d_inode;
1557 struct cache_detail *cd = RPC_I(inode)->private; 1552 struct cache_detail *cd = RPC_I(inode)->private;
1558 long ret;
1559 1553
1560 lock_kernel(); 1554 return cache_ioctl(inode, filp, cmd, arg, cd);
1561 ret = cache_ioctl(inode, filp, cmd, arg, cd);
1562 unlock_kernel();
1563
1564 return ret;
1565} 1555}
1566 1556
1567static int cache_open_pipefs(struct inode *inode, struct file *filp) 1557static int cache_open_pipefs(struct inode *inode, struct file *filp)
@@ -1646,6 +1636,7 @@ const struct file_operations cache_flush_operations_pipefs = {
1646 .read = read_flush_pipefs, 1636 .read = read_flush_pipefs,
1647 .write = write_flush_pipefs, 1637 .write = write_flush_pipefs,
1648 .release = release_flush_pipefs, 1638 .release = release_flush_pipefs,
1639 .llseek = no_llseek,
1649}; 1640};
1650 1641
1651int sunrpc_cache_register_pipefs(struct dentry *parent, 1642int sunrpc_cache_register_pipefs(struct dentry *parent,
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 8c8eef2b8f26..28bcd52e3ce9 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -27,7 +27,6 @@
27#include <linux/workqueue.h> 27#include <linux/workqueue.h>
28#include <linux/sunrpc/rpc_pipe_fs.h> 28#include <linux/sunrpc/rpc_pipe_fs.h>
29#include <linux/sunrpc/cache.h> 29#include <linux/sunrpc/cache.h>
30#include <linux/smp_lock.h>
31 30
32static struct vfsmount *rpc_mount __read_mostly; 31static struct vfsmount *rpc_mount __read_mostly;
33static int rpc_mount_count; 32static int rpc_mount_count;
@@ -309,40 +308,33 @@ rpc_pipe_poll(struct file *filp, struct poll_table_struct *wait)
309 return mask; 308 return mask;
310} 309}
311 310
312static int 311static long
313rpc_pipe_ioctl_unlocked(struct file *filp, unsigned int cmd, unsigned long arg) 312rpc_pipe_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
314{ 313{
315 struct rpc_inode *rpci = RPC_I(filp->f_path.dentry->d_inode); 314 struct inode *inode = filp->f_path.dentry->d_inode;
315 struct rpc_inode *rpci = RPC_I(inode);
316 int len; 316 int len;
317 317
318 switch (cmd) { 318 switch (cmd) {
319 case FIONREAD: 319 case FIONREAD:
320 if (rpci->ops == NULL) 320 spin_lock(&inode->i_lock);
321 if (rpci->ops == NULL) {
322 spin_unlock(&inode->i_lock);
321 return -EPIPE; 323 return -EPIPE;
324 }
322 len = rpci->pipelen; 325 len = rpci->pipelen;
323 if (filp->private_data) { 326 if (filp->private_data) {
324 struct rpc_pipe_msg *msg; 327 struct rpc_pipe_msg *msg;
325 msg = (struct rpc_pipe_msg *)filp->private_data; 328 msg = (struct rpc_pipe_msg *)filp->private_data;
326 len += msg->len - msg->copied; 329 len += msg->len - msg->copied;
327 } 330 }
331 spin_unlock(&inode->i_lock);
328 return put_user(len, (int __user *)arg); 332 return put_user(len, (int __user *)arg);
329 default: 333 default:
330 return -EINVAL; 334 return -EINVAL;
331 } 335 }
332} 336}
333 337
334static long
335rpc_pipe_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
336{
337 long ret;
338
339 lock_kernel();
340 ret = rpc_pipe_ioctl_unlocked(filp, cmd, arg);
341 unlock_kernel();
342
343 return ret;
344}
345
346static const struct file_operations rpc_pipe_fops = { 338static const struct file_operations rpc_pipe_fops = {
347 .owner = THIS_MODULE, 339 .owner = THIS_MODULE,
348 .llseek = no_llseek, 340 .llseek = no_llseek,
diff --git a/net/wireless/debugfs.c b/net/wireless/debugfs.c
index a4991a3efec0..39765bcfb472 100644
--- a/net/wireless/debugfs.c
+++ b/net/wireless/debugfs.c
@@ -34,6 +34,7 @@ static ssize_t name## _read(struct file *file, char __user *userbuf, \
34static const struct file_operations name## _ops = { \ 34static const struct file_operations name## _ops = { \
35 .read = name## _read, \ 35 .read = name## _read, \
36 .open = cfg80211_open_file_generic, \ 36 .open = cfg80211_open_file_generic, \
37 .llseek = generic_file_llseek, \
37}; 38};
38 39
39DEBUGFS_READONLY_FILE(rts_threshold, 20, "%d", 40DEBUGFS_READONLY_FILE(rts_threshold, 20, "%d",
@@ -102,6 +103,7 @@ static ssize_t ht40allow_map_read(struct file *file,
102static const struct file_operations ht40allow_map_ops = { 103static const struct file_operations ht40allow_map_ops = {
103 .read = ht40allow_map_read, 104 .read = ht40allow_map_read,
104 .open = cfg80211_open_file_generic, 105 .open = cfg80211_open_file_generic,
106 .llseek = default_llseek,
105}; 107};
106 108
107#define DEBUGFS_ADD(name) \ 109#define DEBUGFS_ADD(name) \
diff --git a/net/x25/Kconfig b/net/x25/Kconfig
index e6759c9660bb..2196e55e4f61 100644
--- a/net/x25/Kconfig
+++ b/net/x25/Kconfig
@@ -5,6 +5,7 @@
5config X25 5config X25
6 tristate "CCITT X.25 Packet Layer (EXPERIMENTAL)" 6 tristate "CCITT X.25 Packet Layer (EXPERIMENTAL)"
7 depends on EXPERIMENTAL 7 depends on EXPERIMENTAL
8 depends on BKL # should be fixable
8 ---help--- 9 ---help---
9 X.25 is a set of standardized network protocols, similar in scope to 10 X.25 is a set of standardized network protocols, similar in scope to
10 frame relay; the one physical line from your box to the X.25 network 11 frame relay; the one physical line from your box to the X.25 network
diff --git a/samples/kfifo/bytestream-example.c b/samples/kfifo/bytestream-example.c
index 178061e87ffe..cfe40addda76 100644
--- a/samples/kfifo/bytestream-example.c
+++ b/samples/kfifo/bytestream-example.c
@@ -148,6 +148,7 @@ static const struct file_operations fifo_fops = {
148 .owner = THIS_MODULE, 148 .owner = THIS_MODULE,
149 .read = fifo_read, 149 .read = fifo_read,
150 .write = fifo_write, 150 .write = fifo_write,
151 .llseek = noop_llseek,
151}; 152};
152 153
153static int __init example_init(void) 154static int __init example_init(void)
diff --git a/samples/kfifo/inttype-example.c b/samples/kfifo/inttype-example.c
index 71b2aabca96a..6f8e79e76c9e 100644
--- a/samples/kfifo/inttype-example.c
+++ b/samples/kfifo/inttype-example.c
@@ -141,6 +141,7 @@ static const struct file_operations fifo_fops = {
141 .owner = THIS_MODULE, 141 .owner = THIS_MODULE,
142 .read = fifo_read, 142 .read = fifo_read,
143 .write = fifo_write, 143 .write = fifo_write,
144 .llseek = noop_llseek,
144}; 145};
145 146
146static int __init example_init(void) 147static int __init example_init(void)
diff --git a/samples/kfifo/record-example.c b/samples/kfifo/record-example.c
index e68bd16a5da4..2d7529eeb294 100644
--- a/samples/kfifo/record-example.c
+++ b/samples/kfifo/record-example.c
@@ -155,6 +155,7 @@ static const struct file_operations fifo_fops = {
155 .owner = THIS_MODULE, 155 .owner = THIS_MODULE,
156 .read = fifo_read, 156 .read = fifo_read,
157 .write = fifo_write, 157 .write = fifo_write,
158 .llseek = noop_llseek,
158}; 159};
159 160
160static int __init example_init(void) 161static int __init example_init(void)
diff --git a/samples/tracepoints/tracepoint-sample.c b/samples/tracepoints/tracepoint-sample.c
index 26fab33ffa8c..f4d89e008c32 100644
--- a/samples/tracepoints/tracepoint-sample.c
+++ b/samples/tracepoints/tracepoint-sample.c
@@ -30,6 +30,7 @@ static int my_open(struct inode *inode, struct file *file)
30 30
31static const struct file_operations mark_ops = { 31static const struct file_operations mark_ops = {
32 .open = my_open, 32 .open = my_open,
33 .llseek = noop_llseek,
33}; 34};
34 35
35static int __init sample_init(void) 36static int __init sample_init(void)
diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
index 544ff5837cb6..0848292982a2 100644
--- a/security/apparmor/apparmorfs.c
+++ b/security/apparmor/apparmorfs.c
@@ -88,7 +88,8 @@ static ssize_t profile_load(struct file *f, const char __user *buf, size_t size,
88} 88}
89 89
90static const struct file_operations aa_fs_profile_load = { 90static const struct file_operations aa_fs_profile_load = {
91 .write = profile_load 91 .write = profile_load,
92 .llseek = default_llseek,
92}; 93};
93 94
94/* .replace file hook fn to load and/or replace policy */ 95/* .replace file hook fn to load and/or replace policy */
@@ -109,7 +110,8 @@ static ssize_t profile_replace(struct file *f, const char __user *buf,
109} 110}
110 111
111static const struct file_operations aa_fs_profile_replace = { 112static const struct file_operations aa_fs_profile_replace = {
112 .write = profile_replace 113 .write = profile_replace,
114 .llseek = default_llseek,
113}; 115};
114 116
115/* .remove file hook fn to remove loaded policy */ 117/* .remove file hook fn to remove loaded policy */
@@ -136,7 +138,8 @@ static ssize_t profile_remove(struct file *f, const char __user *buf,
136} 138}
137 139
138static const struct file_operations aa_fs_profile_remove = { 140static const struct file_operations aa_fs_profile_remove = {
139 .write = profile_remove 141 .write = profile_remove,
142 .llseek = default_llseek,
140}; 143};
141 144
142/** Base file system setup **/ 145/** Base file system setup **/
diff --git a/security/inode.c b/security/inode.c
index 8c777f022ad1..88839866cbcd 100644
--- a/security/inode.c
+++ b/security/inode.c
@@ -53,6 +53,7 @@ static const struct file_operations default_file_ops = {
53 .read = default_read_file, 53 .read = default_read_file,
54 .write = default_write_file, 54 .write = default_write_file,
55 .open = default_open, 55 .open = default_open,
56 .llseek = noop_llseek,
56}; 57};
57 58
58static struct inode *get_inode(struct super_block *sb, int mode, dev_t dev) 59static struct inode *get_inode(struct super_block *sb, int mode, dev_t dev)
diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
index a2b72d77f926..7512502d0162 100644
--- a/security/smack/smackfs.c
+++ b/security/smack/smackfs.c
@@ -968,6 +968,7 @@ static ssize_t smk_write_doi(struct file *file, const char __user *buf,
968static const struct file_operations smk_doi_ops = { 968static const struct file_operations smk_doi_ops = {
969 .read = smk_read_doi, 969 .read = smk_read_doi,
970 .write = smk_write_doi, 970 .write = smk_write_doi,
971 .llseek = default_llseek,
971}; 972};
972 973
973/** 974/**
@@ -1031,6 +1032,7 @@ static ssize_t smk_write_direct(struct file *file, const char __user *buf,
1031static const struct file_operations smk_direct_ops = { 1032static const struct file_operations smk_direct_ops = {
1032 .read = smk_read_direct, 1033 .read = smk_read_direct,
1033 .write = smk_write_direct, 1034 .write = smk_write_direct,
1035 .llseek = default_llseek,
1034}; 1036};
1035 1037
1036/** 1038/**
@@ -1112,6 +1114,7 @@ static ssize_t smk_write_ambient(struct file *file, const char __user *buf,
1112static const struct file_operations smk_ambient_ops = { 1114static const struct file_operations smk_ambient_ops = {
1113 .read = smk_read_ambient, 1115 .read = smk_read_ambient,
1114 .write = smk_write_ambient, 1116 .write = smk_write_ambient,
1117 .llseek = default_llseek,
1115}; 1118};
1116 1119
1117/** 1120/**
@@ -1191,6 +1194,7 @@ static ssize_t smk_write_onlycap(struct file *file, const char __user *buf,
1191static const struct file_operations smk_onlycap_ops = { 1194static const struct file_operations smk_onlycap_ops = {
1192 .read = smk_read_onlycap, 1195 .read = smk_read_onlycap,
1193 .write = smk_write_onlycap, 1196 .write = smk_write_onlycap,
1197 .llseek = default_llseek,
1194}; 1198};
1195 1199
1196/** 1200/**
@@ -1255,6 +1259,7 @@ static ssize_t smk_write_logging(struct file *file, const char __user *buf,
1255static const struct file_operations smk_logging_ops = { 1259static const struct file_operations smk_logging_ops = {
1256 .read = smk_read_logging, 1260 .read = smk_read_logging,
1257 .write = smk_write_logging, 1261 .write = smk_write_logging,
1262 .llseek = default_llseek,
1258}; 1263};
1259/** 1264/**
1260 * smk_fill_super - fill the /smackfs superblock 1265 * smk_fill_super - fill the /smackfs superblock
diff --git a/sound/core/seq/oss/seq_oss.c b/sound/core/seq/oss/seq_oss.c
index f25e3cc7ddfa..a1f1a2f00ccb 100644
--- a/sound/core/seq/oss/seq_oss.c
+++ b/sound/core/seq/oss/seq_oss.c
@@ -220,6 +220,7 @@ static const struct file_operations seq_oss_f_ops =
220 .poll = odev_poll, 220 .poll = odev_poll,
221 .unlocked_ioctl = odev_ioctl, 221 .unlocked_ioctl = odev_ioctl,
222 .compat_ioctl = odev_ioctl_compat, 222 .compat_ioctl = odev_ioctl_compat,
223 .llseek = noop_llseek,
223}; 224};
224 225
225static int __init 226static int __init
diff --git a/sound/core/sound.c b/sound/core/sound.c
index ac42af42b787..62a093efb453 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -184,7 +184,8 @@ static int snd_open(struct inode *inode, struct file *file)
184static const struct file_operations snd_fops = 184static const struct file_operations snd_fops =
185{ 185{
186 .owner = THIS_MODULE, 186 .owner = THIS_MODULE,
187 .open = snd_open 187 .open = snd_open,
188 .llseek = noop_llseek,
188}; 189};
189 190
190#ifdef CONFIG_SND_DYNAMIC_MINORS 191#ifdef CONFIG_SND_DYNAMIC_MINORS
diff --git a/sound/oss/msnd_pinnacle.c b/sound/oss/msnd_pinnacle.c
index 2e48b17667d0..ca942f7cd231 100644
--- a/sound/oss/msnd_pinnacle.c
+++ b/sound/oss/msnd_pinnacle.c
@@ -1117,6 +1117,7 @@ static const struct file_operations dev_fileops = {
1117 .unlocked_ioctl = dev_ioctl, 1117 .unlocked_ioctl = dev_ioctl,
1118 .open = dev_open, 1118 .open = dev_open,
1119 .release = dev_release, 1119 .release = dev_release,
1120 .llseek = noop_llseek,
1120}; 1121};
1121 1122
1122static int reset_dsp(void) 1123static int reset_dsp(void)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index acc91daa1c55..4057d35343bb 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -223,6 +223,7 @@ static const struct file_operations codec_reg_fops = {
223 .open = codec_reg_open_file, 223 .open = codec_reg_open_file,
224 .read = codec_reg_read_file, 224 .read = codec_reg_read_file,
225 .write = codec_reg_write_file, 225 .write = codec_reg_write_file,
226 .llseek = default_llseek,
226}; 227};
227 228
228static void soc_init_codec_debugfs(struct snd_soc_codec *codec) 229static void soc_init_codec_debugfs(struct snd_soc_codec *codec)
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 03cb7c05ebec..72a53d0a41e9 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -1089,6 +1089,7 @@ static ssize_t dapm_widget_power_read_file(struct file *file,
1089static const struct file_operations dapm_widget_power_fops = { 1089static const struct file_operations dapm_widget_power_fops = {
1090 .open = dapm_widget_power_open_file, 1090 .open = dapm_widget_power_open_file,
1091 .read = dapm_widget_power_read_file, 1091 .read = dapm_widget_power_read_file,
1092 .llseek = default_llseek,
1092}; 1093};
1093 1094
1094void snd_soc_dapm_debugfs_init(struct snd_soc_codec *codec) 1095void snd_soc_dapm_debugfs_init(struct snd_soc_codec *codec)
diff --git a/sound/sound_core.c b/sound/sound_core.c
index cb61317df509..c03bbaefdbc3 100644
--- a/sound/sound_core.c
+++ b/sound/sound_core.c
@@ -165,6 +165,7 @@ static const struct file_operations soundcore_fops =
165 /* We must have an owner or the module locking fails */ 165 /* We must have an owner or the module locking fails */
166 .owner = THIS_MODULE, 166 .owner = THIS_MODULE,
167 .open = soundcore_open, 167 .open = soundcore_open,
168 .llseek = noop_llseek,
168}; 169};
169 170
170/* 171/*
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 5186e728c53e..60e5e4612b0b 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1305,6 +1305,7 @@ static struct file_operations kvm_vcpu_fops = {
1305 .unlocked_ioctl = kvm_vcpu_ioctl, 1305 .unlocked_ioctl = kvm_vcpu_ioctl,
1306 .compat_ioctl = kvm_vcpu_ioctl, 1306 .compat_ioctl = kvm_vcpu_ioctl,
1307 .mmap = kvm_vcpu_mmap, 1307 .mmap = kvm_vcpu_mmap,
1308 .llseek = noop_llseek,
1308}; 1309};
1309 1310
1310/* 1311/*
@@ -1774,6 +1775,7 @@ static struct file_operations kvm_vm_fops = {
1774 .compat_ioctl = kvm_vm_compat_ioctl, 1775 .compat_ioctl = kvm_vm_compat_ioctl,
1775#endif 1776#endif
1776 .mmap = kvm_vm_mmap, 1777 .mmap = kvm_vm_mmap,
1778 .llseek = noop_llseek,
1777}; 1779};
1778 1780
1779static int kvm_dev_ioctl_create_vm(void) 1781static int kvm_dev_ioctl_create_vm(void)
@@ -1867,6 +1869,7 @@ out:
1867static struct file_operations kvm_chardev_ops = { 1869static struct file_operations kvm_chardev_ops = {
1868 .unlocked_ioctl = kvm_dev_ioctl, 1870 .unlocked_ioctl = kvm_dev_ioctl,
1869 .compat_ioctl = kvm_dev_ioctl, 1871 .compat_ioctl = kvm_dev_ioctl,
1872 .llseek = noop_llseek,
1870}; 1873};
1871 1874
1872static struct miscdevice kvm_dev = { 1875static struct miscdevice kvm_dev = {