From ef6b9eeb180b52ba2e546c4bbcb04429bc396491 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Tue, 22 Apr 2008 17:33:25 +1000 Subject: [PATCH] --- yaml --- r: 94993 b: refs/heads/master c: 42173f6860af7e016a950a9a19a66679cfc46d98 h: refs/heads/master i: 94991: d8c2759555aee4b15aebbad40f3dfca7643dbddc v: v3 --- [refs] | 2 +- trunk/Documentation/DMA-API.txt | 69 +- trunk/Documentation/DMA-attributes.txt | 24 - trunk/Documentation/DMA-mapping.txt | 38 +- trunk/Documentation/cgroups.txt | 3 +- trunk/Documentation/controllers/devices.txt | 48 - .../controllers/resource_counter.txt | 181 -- trunk/Documentation/cpu-freq/user-guide.txt | 14 - trunk/Documentation/cpusets.txt | 26 +- trunk/Documentation/i2c/writing-clients | 3 +- trunk/Documentation/i386/boot.txt | 12 +- trunk/Documentation/kernel-parameters.txt | 10 +- trunk/Documentation/keys-request-key.txt | 11 +- trunk/Documentation/keys.txt | 59 +- trunk/Documentation/oops-tracing.txt | 4 - .../sound/alsa/ALSA-Configuration.txt | 1 - trunk/Documentation/sysrq.txt | 2 - .../video4linux/CARDLIST.saa7134 | 3 +- trunk/Documentation/video4linux/cx18.txt | 34 - trunk/MAINTAINERS | 11 +- trunk/arch/Kconfig | 3 - trunk/arch/alpha/kernel/asm-offsets.c | 6 +- trunk/arch/alpha/kernel/pci.c | 4 +- trunk/arch/arm/configs/am200epdkit_defconfig | 22 +- trunk/arch/arm/kernel/asm-offsets.c | 8 +- trunk/arch/arm/kernel/atags.c | 2 +- trunk/arch/arm/kernel/ecard.c | 56 +- trunk/arch/arm/kernel/kprobes-decode.c | 2 +- trunk/arch/arm/kernel/kprobes.c | 2 +- trunk/arch/arm/mach-at91/at91cap9_devices.c | 2 +- .../arch/arm/mach-at91/at91sam9263_devices.c | 2 +- trunk/arch/arm/mach-at91/board-csb337.c | 3 +- trunk/arch/arm/mach-at91/board-dk.c | 3 +- trunk/arch/arm/mach-at91/board-eb9200.c | 3 +- trunk/arch/arm/mach-at91/pm.c | 14 +- trunk/arch/arm/mach-davinci/clock.c | 6 +- trunk/arch/arm/mach-iop32x/em7210.c | 3 +- trunk/arch/arm/mach-iop32x/glantank.c | 4 +- trunk/arch/arm/mach-iop32x/n2100.c | 4 +- trunk/arch/arm/mach-ixp4xx/dsmg600-setup.c | 2 +- trunk/arch/arm/mach-ixp4xx/nas100d-setup.c | 2 +- trunk/arch/arm/mach-ixp4xx/nslu2-setup.c | 2 +- trunk/arch/arm/mach-omap1/board-h2.c | 2 + trunk/arch/arm/mach-omap1/board-h3.c | 3 +- trunk/arch/arm/mach-omap1/board-osk.c | 1 + trunk/arch/arm/mach-orion5x/addr-map.c | 4 +- trunk/arch/arm/mach-orion5x/common.c | 6 +- trunk/arch/arm/mach-orion5x/common.h | 3 +- trunk/arch/arm/mach-orion5x/db88f5281-setup.c | 15 +- trunk/arch/arm/mach-orion5x/dns323-setup.c | 24 +- .../arch/arm/mach-orion5x/kurobox_pro-setup.c | 20 +- trunk/arch/arm/mach-orion5x/pci.c | 20 +- trunk/arch/arm/mach-orion5x/rd88f5182-setup.c | 15 +- trunk/arch/arm/mach-orion5x/ts209-setup.c | 16 +- trunk/arch/arm/mach-pxa/Makefile | 6 +- trunk/arch/arm/mach-pxa/gumstix.c | 1 - trunk/arch/arm/mach-pxa/magician.c | 61 +- trunk/arch/arm/mach-pxa/pcm990-baseboard.c | 5 +- trunk/arch/arm/mach-pxa/pm.c | 4 +- trunk/arch/arm/mach-pxa/pxa3xx.c | 2 - trunk/arch/arm/mm/Kconfig | 7 +- trunk/arch/arm/mm/Makefile | 1 - trunk/arch/arm/mm/copypage-feroceon.S | 95 -- trunk/arch/arm/mm/iomap.c | 4 +- trunk/arch/arm/mm/proc-feroceon.S | 60 +- trunk/arch/arm/oprofile/op_model_mpcore.c | 44 +- trunk/arch/avr32/kernel/asm-offsets.c | 9 +- trunk/arch/avr32/mm/tlb.c | 6 +- trunk/arch/blackfin/kernel/asm-offsets.c | 3 +- trunk/arch/blackfin/kernel/signal.c | 2 +- trunk/arch/blackfin/mach-bf533/boards/stamp.c | 3 + trunk/arch/blackfin/mach-bf537/boards/stamp.c | 3 + trunk/arch/blackfin/mach-bf548/boards/ezkit.c | 2 + trunk/arch/cris/kernel/profile.c | 4 +- trunk/arch/frv/kernel/asm-offsets.c | 9 +- trunk/arch/frv/kernel/signal.c | 4 +- trunk/arch/frv/kernel/traps.c | 7 +- trunk/arch/frv/mb93090-mb00/pci-iomap.c | 4 +- trunk/arch/frv/mm/unaligned.c | 217 +++ trunk/arch/h8300/kernel/asm-offsets.c | 6 +- trunk/arch/ia64/Kconfig | 6 +- trunk/arch/ia64/hp/common/hwsw_iommu.c | 61 +- trunk/arch/ia64/hp/common/sba_iommu.c | 70 +- trunk/arch/ia64/kernel/asm-offsets.c | 7 +- trunk/arch/ia64/kernel/perfmon.c | 6 +- trunk/arch/ia64/kernel/salinfo.c | 10 +- trunk/arch/ia64/kernel/smpboot.c | 12 +- trunk/arch/ia64/kernel/topology.c | 9 - trunk/arch/ia64/kernel/uncached.c | 23 +- trunk/arch/ia64/mm/tlb.c | 5 +- trunk/arch/ia64/sn/kernel/sn2/sn2_smp.c | 5 +- trunk/arch/ia64/sn/kernel/sn2/sn_proc_fs.c | 29 +- trunk/arch/ia64/sn/pci/pci_dma.c | 81 +- trunk/arch/m68k/kernel/asm-offsets.c | 4 +- trunk/arch/m68k/mac/iop.c | 85 + trunk/arch/m68knommu/kernel/asm-offsets.c | 6 +- trunk/arch/mips/basler/excite/excite_procfs.c | 30 +- trunk/arch/mips/kernel/asm-offsets.c | 478 +++--- trunk/arch/mips/lib/iomap-pci.c | 4 +- trunk/arch/mips/pmc-sierra/yosemite/setup.c | 3 + trunk/arch/mn10300/kernel/asm-offsets.c | 9 +- trunk/arch/mn10300/unit-asb2305/pci-iomap.c | 4 +- trunk/arch/parisc/kernel/asm-offsets.c | 6 +- trunk/arch/parisc/kernel/pci-dma.c | 7 +- trunk/arch/parisc/lib/iomap.c | 4 +- trunk/arch/powerpc/Kconfig | 13 - trunk/arch/powerpc/Kconfig.debug | 1 + trunk/arch/powerpc/boot/dts/mpc8641_hpcn.dts | 12 - trunk/arch/powerpc/configs/g5_defconfig | 1 - trunk/arch/powerpc/kernel/Makefile | 1 + trunk/arch/powerpc/kernel/asm-offsets.c | 7 +- trunk/arch/powerpc/kernel/entry_32.S | 5 +- trunk/arch/powerpc/kernel/head_64.S | 11 - trunk/arch/powerpc/kernel/irq.c | 10 +- trunk/arch/powerpc/kernel/lparcfg.c | 6 +- trunk/arch/powerpc/kernel/misc_32.S | 25 - trunk/arch/powerpc/kernel/proc_ppc64.c | 5 +- trunk/arch/powerpc/kernel/process.c | 2 - trunk/arch/powerpc/kernel/rio.c | 52 + trunk/arch/powerpc/kernel/rtas-proc.c | 45 +- trunk/arch/powerpc/kernel/rtas_flash.c | 13 +- trunk/arch/powerpc/kernel/setup_32.c | 21 - trunk/arch/powerpc/mm/mem.c | 30 +- trunk/arch/powerpc/platforms/86xx/Kconfig | 1 - .../powerpc/platforms/86xx/mpc86xx_hpcn.c | 1 - .../arch/powerpc/platforms/cell/spufs/sched.c | 3 +- .../powerpc/platforms/cell/spufs/sputrace.c | 3 +- .../arch/powerpc/platforms/iseries/lpevents.c | 8 +- trunk/arch/powerpc/platforms/iseries/mf.c | 6 +- trunk/arch/powerpc/platforms/iseries/proc.c | 8 +- .../arch/powerpc/platforms/iseries/viopath.c | 7 +- .../arch/powerpc/platforms/powermac/Makefile | 5 +- trunk/arch/powerpc/platforms/powermac/setup.c | 3 +- trunk/arch/powerpc/platforms/pseries/Makefile | 1 - trunk/arch/powerpc/platforms/pseries/eeh.c | 10 +- .../platforms/pseries/hotplug-memory.c | 141 -- .../arch/powerpc/platforms/pseries/reconfig.c | 7 +- trunk/arch/powerpc/platforms/pseries/rtasd.c | 7 +- trunk/arch/powerpc/sysdev/fsl_rio.c | 711 +++----- trunk/arch/powerpc/sysdev/fsl_rio.h | 20 + trunk/arch/powerpc/sysdev/fsl_soc.c | 27 +- trunk/arch/ppc/kernel/asm-offsets.c | 7 +- trunk/arch/ppc/kernel/pci.c | 4 +- trunk/arch/ppc/platforms/sbc82xx.c | 2 + trunk/arch/s390/kernel/asm-offsets.c | 54 +- trunk/arch/s390/kernel/irq.c | 2 + trunk/arch/sh/boards/renesas/migor/setup.c | 3 +- trunk/arch/sh/boards/renesas/r7780rp/setup.c | 3 +- trunk/arch/sh/drivers/pci/pci.c | 4 +- trunk/arch/sh/kernel/asm-offsets.c | 7 +- trunk/arch/sh/kernel/irq.c | 2 + trunk/arch/sparc/kernel/asm-offsets.c | 6 +- trunk/arch/sparc/lib/iomap.c | 4 +- trunk/arch/sparc64/lib/iomap.c | 4 +- trunk/arch/um/kernel/exitcode.c | 2 +- trunk/arch/um/kernel/process.c | 2 +- trunk/arch/um/kernel/time.c | 3 +- trunk/arch/v850/kernel/asm-offsets.c | 7 +- trunk/arch/v850/kernel/rte_mb_a_pci.c | 4 +- trunk/arch/x86/Kconfig | 23 +- trunk/arch/x86/boot/edd.c | 10 +- trunk/arch/x86/kernel/Makefile | 4 - trunk/arch/x86/kernel/acpi/boot.c | 70 - trunk/arch/x86/kernel/asm-offsets_32.c | 9 +- trunk/arch/x86/kernel/asm-offsets_64.c | 9 +- .../x86/kernel/cpu/cpufreq/acpi-cpufreq.c | 1 - trunk/arch/x86/kernel/cpu/mtrr/generic.c | 2 +- trunk/arch/x86/kernel/cpu/mtrr/if.c | 2 +- trunk/arch/x86/kernel/e820_64.c | 2 +- trunk/arch/x86/kernel/irq_32.c | 2 + trunk/arch/x86/kernel/mmconf-fam10h_64.c | 243 --- trunk/arch/x86/kernel/olpc.c | 260 --- trunk/arch/x86/kernel/setup_64.c | 20 - trunk/arch/x86/kernel/smpboot.c | 10 +- trunk/arch/x86/kernel/time_32.c | 1 + trunk/arch/x86/kernel/vsmp_64.c | 2 +- trunk/arch/x86/mm/k8topology_64.c | 38 +- trunk/arch/x86/pci/Makefile_32 | 2 - trunk/arch/x86/pci/Makefile_64 | 2 +- trunk/arch/x86/pci/acpi.c | 27 +- trunk/arch/x86/pci/common.c | 22 +- trunk/arch/x86/pci/direct.c | 8 +- trunk/arch/x86/pci/fixup.c | 17 - trunk/arch/x86/pci/init.c | 15 +- trunk/arch/x86/pci/irq.c | 4 +- trunk/arch/x86/pci/k8-bus_64.c | 575 +------ trunk/arch/x86/pci/legacy.c | 4 +- trunk/arch/x86/pci/mmconfig-shared.c | 247 +-- trunk/arch/x86/pci/mmconfig_32.c | 4 - trunk/arch/x86/pci/mmconfig_64.c | 22 +- trunk/arch/x86/pci/mp_bus_to_node.c | 23 - trunk/arch/x86/pci/olpc.c | 313 ---- trunk/arch/x86/pci/pci.h | 4 +- trunk/arch/xtensa/kernel/asm-offsets.c | 3 +- trunk/block/blk-barrier.c | 11 +- trunk/block/blk-core.c | 75 +- trunk/block/blk-map.c | 21 +- trunk/block/blk-merge.c | 6 +- trunk/block/blk-settings.c | 3 +- trunk/block/blk-sysfs.c | 26 - trunk/block/blk-tag.c | 8 +- trunk/block/blk.h | 1 + trunk/block/elevator.c | 18 +- trunk/block/scsi_ioctl.c | 3 + trunk/drivers/acpi/ac.c | 12 +- trunk/drivers/acpi/battery.c | 12 +- trunk/drivers/acpi/bus.c | 2 - trunk/drivers/acpi/button.c | 24 +- trunk/drivers/acpi/ec.c | 11 +- trunk/drivers/acpi/event.c | 8 +- trunk/drivers/acpi/fan.c | 14 +- trunk/drivers/acpi/power.c | 11 +- trunk/drivers/acpi/processor_core.c | 48 +- trunk/drivers/acpi/processor_idle.c | 13 +- trunk/drivers/acpi/processor_perflib.c | 13 +- trunk/drivers/acpi/processor_thermal.c | 1 - trunk/drivers/acpi/processor_throttling.c | 1 - trunk/drivers/acpi/sbs.c | 35 +- trunk/drivers/acpi/sleep/proc.c | 26 +- trunk/drivers/acpi/system.c | 27 +- trunk/drivers/acpi/thermal.c | 67 +- trunk/drivers/acpi/video.c | 112 +- trunk/drivers/ata/Kconfig | 8 +- trunk/drivers/ata/Makefile | 2 +- trunk/drivers/ata/ahci.c | 2 +- trunk/drivers/ata/libata-core.c | 3 - trunk/drivers/ata/libata-scsi.c | 507 ++++-- trunk/drivers/ata/libata.h | 28 + trunk/drivers/ata/pata_atiixp.c | 4 +- trunk/drivers/ata/pata_bf54x.c | 124 +- .../ata/{pata_rb532_cf.c => pata_rb500_cf.c} | 78 +- trunk/drivers/ata/pata_via.c | 11 +- trunk/drivers/ata/sata_mv.c | 77 +- trunk/drivers/base/core.c | 14 +- trunk/drivers/base/firmware_class.c | 2 - trunk/drivers/block/aoe/aoe.h | 1 + trunk/drivers/block/aoe/aoecmd.c | 24 +- trunk/drivers/block/aoe/aoedev.c | 18 + trunk/drivers/block/aoe/aoenet.c | 4 +- trunk/drivers/block/cciss.c | 4 +- trunk/drivers/block/cpqarray.c | 4 +- trunk/drivers/block/floppy.c | 6 +- trunk/drivers/block/loop.c | 2 +- trunk/drivers/block/nbd.c | 172 +- trunk/drivers/block/paride/pd.c | 4 +- trunk/drivers/block/pktcdvd.c | 13 +- trunk/drivers/block/ps3disk.c | 4 +- trunk/drivers/block/ub.c | 2 +- trunk/drivers/block/xen-blkfront.c | 2 +- trunk/drivers/cdrom/cdrom.c | 1 + trunk/drivers/cdrom/viocd.c | 10 +- trunk/drivers/char/Kconfig | 9 - trunk/drivers/char/apm-emulation.c | 23 +- trunk/drivers/char/i8k.c | 6 +- trunk/drivers/char/ip2/ip2main.c | 55 +- trunk/drivers/char/ipmi/Makefile | 4 + trunk/drivers/char/ipmi/ipmi_bt_sm.c | 153 +- trunk/drivers/char/ipmi/ipmi_kcs_sm.c | 153 +- trunk/drivers/char/ipmi/ipmi_msghandler.c | 1508 ++++++++--------- trunk/drivers/char/ipmi/ipmi_poweroff.c | 206 ++- trunk/drivers/char/ipmi/ipmi_si_intf.c | 698 ++++---- trunk/drivers/char/ipmi/ipmi_si_sm.h | 89 +- trunk/drivers/char/ipmi/ipmi_smic_sm.c | 149 +- trunk/drivers/char/ipmi/ipmi_watchdog.c | 244 ++- trunk/drivers/char/mem.c | 10 - trunk/drivers/char/misc.c | 27 +- trunk/drivers/char/mspec.c | 12 +- .../drivers/char/pcmcia/ipwireless/hardware.c | 26 + .../drivers/char/pcmcia/ipwireless/hardware.h | 2 + .../drivers/char/pcmcia/ipwireless/network.c | 15 + .../drivers/char/pcmcia/ipwireless/network.h | 3 + trunk/drivers/char/random.c | 297 ++-- trunk/drivers/char/rocket_int.h | 2 +- trunk/drivers/char/rtc.c | 6 +- trunk/drivers/char/snsc_event.c | 10 +- trunk/drivers/char/sysrq.c | 46 - trunk/drivers/char/toshiba.c | 3 +- trunk/drivers/char/tpm/Kconfig | 5 +- trunk/drivers/char/tpm/tpm_nsc.c | 2 +- trunk/drivers/char/tty_audit.c | 63 +- trunk/drivers/char/tty_io.c | 5 +- trunk/drivers/char/viotape.c | 9 +- trunk/drivers/char/vt.c | 7 +- trunk/drivers/cpufreq/Kconfig | 9 - trunk/drivers/cpufreq/cpufreq.c | 29 +- trunk/drivers/cpufreq/cpufreq_powersave.c | 8 +- trunk/drivers/cpufreq/cpufreq_stats.c | 2 +- trunk/drivers/edac/Kconfig | 2 +- trunk/drivers/edac/amd76x_edac.c | 7 - trunk/drivers/edac/e752x_edac.c | 220 +-- trunk/drivers/edac/e7xxx_edac.c | 13 +- trunk/drivers/edac/edac_device.c | 33 +- trunk/drivers/edac/edac_mc.c | 23 +- trunk/drivers/edac/edac_module.h | 1 + trunk/drivers/edac/edac_pci.c | 8 +- trunk/drivers/edac/edac_pci_sysfs.c | 11 +- trunk/drivers/edac/i3000_edac.c | 13 +- trunk/drivers/edac/i5000_edac.c | 14 +- trunk/drivers/edac/i82443bxgx_edac.c | 7 - trunk/drivers/edac/i82860_edac.c | 7 - trunk/drivers/edac/i82875p_edac.c | 9 - trunk/drivers/edac/i82975x_edac.c | 8 +- trunk/drivers/edac/pasemi_edac.c | 7 - trunk/drivers/edac/r82600_edac.c | 7 - trunk/drivers/firmware/Kconfig | 9 - trunk/drivers/firmware/dcdbas.c | 16 +- trunk/drivers/firmware/dell_rbu.c | 12 +- trunk/drivers/gpio/pca953x.c | 24 +- trunk/drivers/gpio/pcf857x.c | 36 +- trunk/drivers/hid/hid-core.c | 6 +- trunk/drivers/hwmon/f75375s.c | 29 +- trunk/drivers/i2c/busses/i2c-amd756-s4882.c | 5 +- trunk/drivers/i2c/busses/i2c-piix4.c | 10 +- trunk/drivers/i2c/busses/i2c-sis5595.c | 14 +- trunk/drivers/i2c/busses/i2c-sis630.c | 2 +- trunk/drivers/i2c/busses/i2c-stub.c | 2 +- trunk/drivers/i2c/busses/i2c-taos-evm.c | 3 +- trunk/drivers/i2c/chips/ds1682.c | 10 +- trunk/drivers/i2c/chips/menelaus.c | 10 +- trunk/drivers/i2c/chips/tps65010.c | 34 +- trunk/drivers/i2c/chips/tsl2550.c | 10 +- trunk/drivers/i2c/i2c-core.c | 51 +- trunk/drivers/ide/ide-cd.c | 4 +- trunk/drivers/ide/ide-cd_verbose.c | 2 +- trunk/drivers/ide/ide-io.c | 3 +- trunk/drivers/ide/ide-proc.c | 7 +- trunk/drivers/ide/ide-tape.c | 2 +- trunk/drivers/ide/ide-taskfile.c | 3 +- trunk/drivers/ide/ide.c | 4 +- trunk/drivers/ide/pci/alim15x3.c | 10 +- trunk/drivers/ide/pci/siimage.c | 9 +- trunk/drivers/infiniband/core/umem.c | 17 +- .../infiniband/hw/amso1100/c2_provider.c | 2 +- trunk/drivers/infiniband/hw/cxgb3/cxio_hal.c | 18 +- trunk/drivers/infiniband/hw/cxgb3/cxio_hal.h | 1 - trunk/drivers/infiniband/hw/cxgb3/cxio_wr.h | 21 +- trunk/drivers/infiniband/hw/cxgb3/iwch.c | 1 - trunk/drivers/infiniband/hw/cxgb3/iwch.h | 1 - trunk/drivers/infiniband/hw/cxgb3/iwch_cm.c | 167 +- trunk/drivers/infiniband/hw/cxgb3/iwch_cm.h | 2 - .../infiniband/hw/cxgb3/iwch_provider.c | 4 +- .../infiniband/hw/cxgb3/iwch_provider.h | 3 - trunk/drivers/infiniband/hw/cxgb3/iwch_qp.c | 60 +- .../drivers/infiniband/hw/ehca/ehca_classes.h | 5 - trunk/drivers/infiniband/hw/ehca/ehca_cq.c | 11 - trunk/drivers/infiniband/hw/ehca/ehca_eq.c | 35 +- trunk/drivers/infiniband/hw/ehca/ehca_main.c | 36 +- trunk/drivers/infiniband/hw/ehca/ehca_mrmw.c | 2 +- trunk/drivers/infiniband/hw/ehca/ehca_qp.c | 26 +- trunk/drivers/infiniband/hw/ipath/ipath_mr.c | 3 +- trunk/drivers/infiniband/hw/mlx4/cq.c | 4 +- trunk/drivers/infiniband/hw/mlx4/doorbell.c | 2 +- trunk/drivers/infiniband/hw/mlx4/mr.c | 3 +- trunk/drivers/infiniband/hw/mlx4/qp.c | 2 +- trunk/drivers/infiniband/hw/mlx4/srq.c | 2 +- trunk/drivers/infiniband/hw/mthca/mthca_mr.c | 13 + .../infiniband/hw/mthca/mthca_provider.c | 20 +- .../infiniband/hw/mthca/mthca_provider.h | 1 - .../drivers/infiniband/hw/mthca/mthca_user.h | 10 - trunk/drivers/infiniband/hw/nes/Kconfig | 1 - trunk/drivers/infiniband/hw/nes/nes.c | 4 - trunk/drivers/infiniband/hw/nes/nes.h | 5 +- trunk/drivers/infiniband/hw/nes/nes_cm.c | 8 +- trunk/drivers/infiniband/hw/nes/nes_hw.c | 371 +--- trunk/drivers/infiniband/hw/nes/nes_hw.h | 19 +- trunk/drivers/infiniband/hw/nes/nes_nic.c | 180 +- trunk/drivers/infiniband/hw/nes/nes_utils.c | 10 +- trunk/drivers/infiniband/hw/nes/nes_verbs.c | 4 +- trunk/drivers/infiniband/ulp/ipoib/ipoib.h | 7 +- trunk/drivers/infiniband/ulp/ipoib/ipoib_cm.c | 8 +- .../infiniband/ulp/ipoib/ipoib_ethtool.c | 2 +- trunk/drivers/infiniband/ulp/ipoib/ipoib_ib.c | 45 +- .../drivers/infiniband/ulp/ipoib/ipoib_main.c | 3 +- .../infiniband/ulp/ipoib/ipoib_verbs.c | 39 +- .../drivers/infiniband/ulp/ipoib/ipoib_vlan.c | 3 - .../drivers/infiniband/ulp/iser/iscsi_iser.c | 4 +- .../drivers/infiniband/ulp/iser/iscsi_iser.h | 7 - .../drivers/infiniband/ulp/iser/iser_memory.c | 9 +- trunk/drivers/input/input.c | 18 +- trunk/drivers/input/tablet/aiptek.c | 16 +- trunk/drivers/input/tablet/gtco.c | 14 +- trunk/drivers/input/tablet/kbtab.c | 4 +- trunk/drivers/isdn/capi/kcapi_proc.c | 24 +- trunk/drivers/isdn/divert/divert_procfs.c | 5 +- trunk/drivers/isdn/hardware/eicon/divasproc.c | 8 +- trunk/drivers/isdn/hysdn/hysdn_procconf.c | 9 +- trunk/drivers/isdn/hysdn/hysdn_proclog.c | 8 +- trunk/drivers/leds/led-class.c | 2 +- trunk/drivers/macintosh/Kconfig | 8 - trunk/drivers/macintosh/Makefile | 5 - .../drivers/macintosh/windfarm_lm75_sensor.c | 6 - .../macintosh/windfarm_max6690_sensor.c | 20 +- trunk/drivers/macintosh/windfarm_pm121.c | 1040 ------------ .../drivers/macintosh/windfarm_smu_controls.c | 4 - trunk/drivers/mca/mca-legacy.c | 18 + trunk/drivers/mca/mca-proc.c | 2 +- trunk/drivers/md/dm-emc.c | 2 + trunk/drivers/md/dm-mpath-hp-sw.c | 1 + trunk/drivers/md/dm-mpath-rdac.c | 1 + trunk/drivers/md/dm-table.c | 5 +- trunk/drivers/md/md.c | 9 +- trunk/drivers/media/Kconfig | 172 +- trunk/drivers/media/Makefile | 10 +- trunk/drivers/media/common/tuners/Kconfig | 146 -- trunk/drivers/media/common/tuners/Makefile | 25 - trunk/drivers/media/dvb/Kconfig | 4 +- trunk/drivers/media/dvb/b2c2/Kconfig | 2 +- trunk/drivers/media/dvb/b2c2/Makefile | 2 +- trunk/drivers/media/dvb/bt8xx/Kconfig | 2 +- trunk/drivers/media/dvb/bt8xx/Makefile | 2 +- trunk/drivers/media/dvb/bt8xx/dst.c | 2 +- trunk/drivers/media/dvb/dvb-core/Kconfig | 34 + .../drivers/media/dvb/dvb-core/dvb_frontend.c | 2 +- trunk/drivers/media/dvb/dvb-core/dvbdev.h | 2 +- trunk/drivers/media/dvb/dvb-usb/Kconfig | 26 +- trunk/drivers/media/dvb/dvb-usb/Makefile | 2 +- trunk/drivers/media/dvb/frontends/Kconfig | 121 +- trunk/drivers/media/dvb/frontends/Makefile | 11 +- .../{common/tuners => dvb/frontends}/mt2060.c | 0 .../{common/tuners => dvb/frontends}/mt2060.h | 4 +- .../tuners => dvb/frontends}/mt2060_priv.h | 0 .../{common/tuners => dvb/frontends}/mt2131.c | 0 .../{common/tuners => dvb/frontends}/mt2131.h | 4 +- .../tuners => dvb/frontends}/mt2131_priv.h | 0 .../{common/tuners => dvb/frontends}/mt2266.c | 0 .../{common/tuners => dvb/frontends}/mt2266.h | 4 +- .../{common/tuners => dvb/frontends}/qt1010.c | 0 .../{common/tuners => dvb/frontends}/qt1010.h | 4 +- .../tuners => dvb/frontends}/qt1010_priv.h | 0 trunk/drivers/media/dvb/frontends/s5h1420.c | 2 +- .../frontends}/tda18271-common.c | 0 .../tuners => dvb/frontends}/tda18271-fe.c | 0 .../tuners => dvb/frontends}/tda18271-priv.h | 0 .../frontends/tda18271-tables.c} | 0 .../tuners => dvb/frontends}/tda18271.h | 2 +- .../tuners => dvb/frontends}/tda827x.c | 0 .../tuners => dvb/frontends}/tda827x.h | 4 +- .../{common/tuners => dvb/frontends}/xc5000.c | 0 .../{common/tuners => dvb/frontends}/xc5000.h | 6 +- .../tuners => dvb/frontends}/xc5000_priv.h | 0 trunk/drivers/media/video/Kconfig | 50 +- trunk/drivers/media/video/Makefile | 14 +- trunk/drivers/media/video/au0828/Kconfig | 2 +- trunk/drivers/media/video/au0828/Makefile | 2 +- trunk/drivers/media/video/bt8xx/Kconfig | 2 +- trunk/drivers/media/video/bt8xx/Makefile | 1 - trunk/drivers/media/video/cs5345.c | 3 +- trunk/drivers/media/video/cs53l32a.c | 3 +- trunk/drivers/media/video/cx18/Kconfig | 20 - trunk/drivers/media/video/cx18/Makefile | 11 - trunk/drivers/media/video/cx18/cx18-audio.c | 73 - trunk/drivers/media/video/cx18/cx18-audio.h | 26 - .../drivers/media/video/cx18/cx18-av-audio.c | 361 ---- trunk/drivers/media/video/cx18/cx18-av-core.c | 879 ---------- trunk/drivers/media/video/cx18/cx18-av-core.h | 318 ---- .../media/video/cx18/cx18-av-firmware.c | 120 -- trunk/drivers/media/video/cx18/cx18-av-vbi.c | 413 ----- trunk/drivers/media/video/cx18/cx18-cards.c | 277 --- trunk/drivers/media/video/cx18/cx18-cards.h | 170 -- .../drivers/media/video/cx18/cx18-controls.c | 306 ---- .../drivers/media/video/cx18/cx18-controls.h | 24 - trunk/drivers/media/video/cx18/cx18-driver.c | 971 ----------- trunk/drivers/media/video/cx18/cx18-driver.h | 500 ------ trunk/drivers/media/video/cx18/cx18-dvb.c | 288 ---- trunk/drivers/media/video/cx18/cx18-dvb.h | 25 - trunk/drivers/media/video/cx18/cx18-fileops.c | 711 -------- trunk/drivers/media/video/cx18/cx18-fileops.h | 45 - .../drivers/media/video/cx18/cx18-firmware.c | 373 ---- .../drivers/media/video/cx18/cx18-firmware.h | 25 - trunk/drivers/media/video/cx18/cx18-gpio.c | 74 - trunk/drivers/media/video/cx18/cx18-gpio.h | 24 - trunk/drivers/media/video/cx18/cx18-i2c.c | 431 ----- trunk/drivers/media/video/cx18/cx18-i2c.h | 33 - trunk/drivers/media/video/cx18/cx18-ioctl.c | 851 ---------- trunk/drivers/media/video/cx18/cx18-ioctl.h | 30 - trunk/drivers/media/video/cx18/cx18-irq.c | 179 -- trunk/drivers/media/video/cx18/cx18-irq.h | 37 - trunk/drivers/media/video/cx18/cx18-mailbox.c | 372 ---- trunk/drivers/media/video/cx18/cx18-mailbox.h | 73 - trunk/drivers/media/video/cx18/cx18-queue.c | 282 --- trunk/drivers/media/video/cx18/cx18-queue.h | 59 - trunk/drivers/media/video/cx18/cx18-scb.c | 121 -- trunk/drivers/media/video/cx18/cx18-scb.h | 285 ---- trunk/drivers/media/video/cx18/cx18-streams.c | 566 ------- trunk/drivers/media/video/cx18/cx18-streams.h | 33 - trunk/drivers/media/video/cx18/cx18-vbi.c | 208 --- trunk/drivers/media/video/cx18/cx18-vbi.h | 26 - trunk/drivers/media/video/cx18/cx18-version.h | 34 - trunk/drivers/media/video/cx18/cx18-video.c | 45 - trunk/drivers/media/video/cx18/cx18-video.h | 22 - trunk/drivers/media/video/cx18/cx23418.h | 458 ----- trunk/drivers/media/video/cx23885/Kconfig | 12 +- trunk/drivers/media/video/cx23885/Makefile | 1 - .../media/video/cx25840/cx25840-core.c | 3 +- trunk/drivers/media/video/cx88/Kconfig | 4 +- trunk/drivers/media/video/cx88/Makefile | 1 - trunk/drivers/media/video/cx88/cx88-cards.c | 50 +- trunk/drivers/media/video/cx88/cx88-i2c.c | 30 + trunk/drivers/media/video/em28xx/Kconfig | 2 +- trunk/drivers/media/video/em28xx/Makefile | 1 - trunk/drivers/media/video/ivtv/Kconfig | 2 +- trunk/drivers/media/video/ivtv/Makefile | 1 - trunk/drivers/media/video/ivtv/ivtv-cards.c | 98 +- trunk/drivers/media/video/ivtv/ivtv-cards.h | 5 +- trunk/drivers/media/video/ivtv/ivtv-driver.c | 43 +- trunk/drivers/media/video/ivtv/ivtv-gpio.c | 9 +- trunk/drivers/media/video/ivtv/ivtv-i2c.c | 3 +- trunk/drivers/media/video/ivtv/ivtv-ioctl.c | 44 +- trunk/drivers/media/video/ivtv/ivtv-irq.c | 4 +- trunk/drivers/media/video/ivtv/ivtv-version.h | 2 +- trunk/drivers/media/video/ivtv/ivtvfb.c | 2 +- trunk/drivers/media/video/m52790.c | 3 +- trunk/drivers/media/video/msp3400-driver.c | 2 +- .../media/{common/tuners => video}/mt20xx.c | 0 .../media/{common/tuners => video}/mt20xx.h | 2 +- trunk/drivers/media/video/mt9m001.c | 12 +- trunk/drivers/media/video/mt9v022.c | 12 +- trunk/drivers/media/video/pvrusb2/Kconfig | 55 +- trunk/drivers/media/video/pvrusb2/Makefile | 1 - .../media/video/pvrusb2/pvrusb2-debug.h | 1 - .../media/video/pvrusb2/pvrusb2-devattr.c | 8 + .../drivers/media/video/pvrusb2/pvrusb2-dvb.c | 42 +- trunk/drivers/media/video/saa7115.c | 3 +- trunk/drivers/media/video/saa7127.c | 3 +- trunk/drivers/media/video/saa7134/Kconfig | 6 +- trunk/drivers/media/video/saa7134/Makefile | 1 - .../media/video/saa7134/saa7134-cards.c | 260 ++- .../drivers/media/video/saa7134/saa7134-i2c.c | 42 + .../media/video/saa7134/saa7134-input.c | 1 - trunk/drivers/media/video/saa7134/saa7134.h | 1 - trunk/drivers/media/video/saa717x.c | 3 +- trunk/drivers/media/video/tcm825x.c | 3 +- .../media/{common/tuners => video}/tda8290.c | 8 +- .../media/{common/tuners => video}/tda8290.h | 2 +- .../media/{common/tuners => video}/tda9887.c | 0 .../media/{common/tuners => video}/tda9887.h | 2 +- .../media/{common/tuners => video}/tea5761.c | 0 .../media/{common/tuners => video}/tea5761.h | 2 +- .../media/{common/tuners => video}/tea5767.c | 0 .../media/{common/tuners => video}/tea5767.h | 2 +- trunk/drivers/media/video/tlv320aic23b.c | 3 +- trunk/drivers/media/video/tuner-core.c | 127 +- .../{common/tuners => video}/tuner-i2c.h | 0 .../{common/tuners => video}/tuner-simple.c | 0 .../{common/tuners => video}/tuner-simple.h | 2 +- .../{common/tuners => video}/tuner-types.c | 0 .../tuners => video}/tuner-xc2028-types.h | 0 .../{common/tuners => video}/tuner-xc2028.c | 0 .../{common/tuners => video}/tuner-xc2028.h | 2 +- trunk/drivers/media/video/tvaudio.c | 2 +- trunk/drivers/media/video/upd64031a.c | 3 +- trunk/drivers/media/video/upd64083.c | 3 +- trunk/drivers/media/video/usbvision/Kconfig | 2 +- trunk/drivers/media/video/usbvision/Makefile | 1 - trunk/drivers/media/video/v4l2-common.c | 5 +- trunk/drivers/media/video/vp27smpx.c | 3 +- trunk/drivers/media/video/wm8739.c | 3 +- trunk/drivers/media/video/wm8775.c | 3 +- trunk/drivers/media/video/zoran_procfs.c | 7 +- trunk/drivers/message/i2o/i2o_block.c | 2 +- trunk/drivers/message/i2o/i2o_proc.c | 6 +- trunk/drivers/mfd/htc-pasic3.c | 9 +- trunk/drivers/misc/hdpuftrs/hdpu_cpustate.c | 5 +- trunk/drivers/misc/hdpuftrs/hdpu_nexus.c | 17 +- trunk/drivers/misc/ibmasm/command.c | 6 +- trunk/drivers/misc/ibmasm/heartbeat.c | 6 +- trunk/drivers/misc/intel_menlow.c | 24 +- trunk/drivers/misc/ioc4.c | 20 +- trunk/drivers/misc/phantom.c | 34 +- trunk/drivers/misc/sgi-xp/xpc_partition.c | 4 +- trunk/drivers/misc/sony-laptop.c | 4 +- trunk/drivers/mmc/host/mmc_spi.c | 2 +- trunk/drivers/mmc/host/mmci.c | 4 +- trunk/drivers/net/arm/am79c961a.c | 10 +- trunk/drivers/net/bonding/bond_main.c | 9 +- trunk/drivers/net/cxgb3/version.h | 2 +- trunk/drivers/net/e100.c | 2 +- trunk/drivers/net/hamachi.c | 2 +- trunk/drivers/net/ibmveth.c | 9 +- trunk/drivers/net/irda/mcs7780.c | 2 +- trunk/drivers/net/irda/stir4200.c | 2 +- trunk/drivers/net/irda/vlsi_ir.c | 5 +- trunk/drivers/net/mlx4/cq.c | 4 +- trunk/drivers/net/mlx4/mr.c | 6 + trunk/drivers/net/myri10ge/myri10ge.c | 2 +- trunk/drivers/net/pppoe.c | 4 +- trunk/drivers/net/pppol2tp.c | 4 +- trunk/drivers/net/rionet.c | 16 +- trunk/drivers/net/tehuti.c | 2 +- trunk/drivers/net/tg3.c | 2 +- trunk/drivers/net/tulip/de4x5.c | 35 +- trunk/drivers/net/tulip/de4x5.h | 2 +- trunk/drivers/net/tulip/tulip.h | 7 +- trunk/drivers/net/tulip/tulip_core.c | 10 +- trunk/drivers/net/wireless/airo.c | 94 +- trunk/drivers/net/wireless/ath5k/base.c | 8 +- trunk/drivers/net/wireless/b43/main.c | 2 +- trunk/drivers/net/wireless/b43legacy/main.c | 2 +- trunk/drivers/net/wireless/iwlwifi/iwl-3945.c | 32 +- trunk/drivers/net/wireless/libertas/scan.c | 2 +- trunk/drivers/net/wireless/zd1211rw/zd_usb.c | 4 +- trunk/drivers/net/yellowfin.c | 2 +- trunk/drivers/nubus/proc.c | 44 +- trunk/drivers/parisc/ccio-dma.c | 14 +- trunk/drivers/parisc/sba_iommu.c | 14 +- trunk/drivers/parport/parport_pc.c | 4 - trunk/drivers/pci/hotplug/pciehp.h | 17 +- trunk/drivers/pci/hotplug/pciehp_core.c | 19 +- trunk/drivers/pci/hotplug/pciehp_ctrl.c | 46 +- trunk/drivers/pci/hotplug/pciehp_hpc.c | 565 ++++-- trunk/drivers/pci/hotplug/shpchp_core.c | 11 +- trunk/drivers/pci/msi.c | 56 +- trunk/drivers/pci/pci-driver.c | 2 - trunk/drivers/pci/pcie/Kconfig | 2 +- trunk/drivers/pci/probe.c | 21 +- trunk/drivers/pci/proc.c | 15 +- trunk/drivers/pcmcia/cistpl.c | 39 +- trunk/drivers/pcmcia/pcmcia_ioctl.c | 4 +- trunk/drivers/pnp/isapnp/proc.c | 9 +- trunk/drivers/pnp/pnpbios/proc.c | 4 +- trunk/drivers/power/ds2760_battery.c | 4 +- trunk/drivers/power/olpc_battery.c | 2 + trunk/drivers/power/power_supply_core.c | 6 +- trunk/drivers/power/power_supply_leds.c | 4 +- trunk/drivers/rapidio/Kconfig | 8 + trunk/drivers/rapidio/rio-access.c | 10 +- trunk/drivers/rapidio/rio-scan.c | 55 +- trunk/drivers/rapidio/rio-sysfs.c | 3 +- trunk/drivers/rapidio/rio.c | 2 +- trunk/drivers/rapidio/rio.h | 9 +- trunk/drivers/rtc/rtc-bfin.c | 2 +- trunk/drivers/rtc/rtc-ds1307.c | 66 +- trunk/drivers/rtc/rtc-ds1374.c | 10 +- trunk/drivers/rtc/rtc-isl1208.c | 9 +- trunk/drivers/rtc/rtc-m41t80.c | 81 +- trunk/drivers/rtc/rtc-pcf8563.c | 10 +- trunk/drivers/rtc/rtc-proc.c | 8 +- trunk/drivers/rtc/rtc-rs5c372.c | 27 +- trunk/drivers/rtc/rtc-s35390a.c | 10 +- trunk/drivers/rtc/rtc-x1205.c | 10 +- trunk/drivers/s390/block/dasd_proc.c | 16 +- trunk/drivers/s390/char/tape_proc.c | 9 +- trunk/drivers/s390/cio/blacklist.c | 7 +- trunk/drivers/s390/cio/qdio.c | 4 +- trunk/drivers/scsi/megaraid.c | 6 +- trunk/drivers/scsi/scsi_debug.c | 2 +- trunk/drivers/scsi/scsi_devinfo.c | 77 +- trunk/drivers/scsi/scsi_error.c | 1 - trunk/drivers/scsi/scsi_lib.c | 31 +- trunk/drivers/scsi/scsi_proc.c | 4 +- trunk/drivers/scsi/scsi_scan.c | 2 +- trunk/drivers/scsi/scsi_transport_sas.c | 3 +- trunk/drivers/scsi/sd.c | 1 + trunk/drivers/scsi/sg.c | 12 +- trunk/drivers/serial/s3c2410.c | 7 +- trunk/drivers/usb/atm/ueagle-atm.c | 48 +- trunk/drivers/usb/class/cdc-acm.c | 2 +- trunk/drivers/usb/core/inode.c | 4 +- trunk/drivers/usb/gadget/at91_udc.c | 11 +- trunk/drivers/usb/gadget/goku_udc.c | 2 +- trunk/drivers/usb/gadget/omap_udc.c | 7 +- trunk/drivers/usb/gadget/rndis.c | 40 +- trunk/drivers/usb/gadget/usbstring.c | 2 +- trunk/drivers/usb/host/ehci-hub.c | 2 +- trunk/drivers/usb/host/ohci-hub.c | 4 +- trunk/drivers/usb/host/sl811-hcd.c | 10 +- trunk/drivers/video/clps711xfb.c | 2 +- trunk/drivers/video/console/fbcon.c | 8 +- trunk/drivers/video/console/mdacon.c | 2 +- trunk/drivers/video/console/sticon.c | 4 +- trunk/drivers/video/console/vgacon.c | 4 +- trunk/drivers/video/matrox/matroxfb_misc.c | 28 +- trunk/drivers/video/metronomefb.c | 9 +- trunk/drivers/zorro/proc.c | 81 +- trunk/fs/Kconfig.binfmt | 2 +- trunk/fs/adfs/dir_f.c | 4 +- trunk/fs/affs/file.c | 21 +- trunk/fs/affs/super.c | 3 +- trunk/fs/afs/afs_cm.h | 3 +- trunk/fs/afs/cell.c | 2 +- trunk/fs/afs/cmservice.c | 133 +- trunk/fs/afs/proc.c | 33 +- trunk/fs/aio.c | 74 +- trunk/fs/autofs4/root.c | 2 +- trunk/fs/befs/linuxvfs.c | 6 +- trunk/fs/binfmt_aout.c | 12 +- trunk/fs/binfmt_elf.c | 30 +- trunk/fs/binfmt_elf_fdpic.c | 14 +- trunk/fs/binfmt_em86.c | 2 +- trunk/fs/binfmt_flat.c | 9 +- trunk/fs/binfmt_misc.c | 6 - trunk/fs/binfmt_script.c | 2 +- trunk/fs/bio.c | 90 - trunk/fs/buffer.c | 22 +- trunk/fs/char_dev.c | 1 + trunk/fs/cifs/cifs_debug.c | 4 +- trunk/fs/coda/coda_linux.c | 2 +- trunk/fs/coda/dir.c | 6 +- trunk/fs/drop_caches.c | 14 +- trunk/fs/ecryptfs/Makefile | 2 +- trunk/fs/ecryptfs/crypto.c | 33 +- trunk/fs/ecryptfs/ecryptfs_kernel.h | 102 +- trunk/fs/ecryptfs/file.c | 2 - trunk/fs/ecryptfs/inode.c | 6 +- trunk/fs/ecryptfs/keystore.c | 89 +- trunk/fs/ecryptfs/main.c | 2 +- trunk/fs/ecryptfs/messaging.c | 524 ++---- trunk/fs/ecryptfs/miscdev.c | 598 ------- trunk/fs/ecryptfs/mmap.c | 18 +- trunk/fs/ecryptfs/netlink.c | 33 +- trunk/fs/ecryptfs/read_write.c | 16 +- trunk/fs/eventpoll.c | 27 +- trunk/fs/exec.c | 6 +- trunk/fs/ext4/mballoc.c | 22 +- trunk/fs/fat/inode.c | 8 +- trunk/fs/freevxfs/vxfs_extern.h | 5 - trunk/fs/freevxfs/vxfs_immed.c | 1 - trunk/fs/freevxfs/vxfs_inode.c | 5 + trunk/fs/fs-writeback.c | 78 +- trunk/fs/hfs/super.c | 6 +- trunk/fs/hfsplus/hfsplus_fs.h | 4 - trunk/fs/hfsplus/inode.c | 3 + trunk/fs/hfsplus/options.c | 3 +- trunk/fs/hfsplus/super.c | 2 +- trunk/fs/hfsplus/wrapper.c | 2 +- trunk/fs/inode.c | 6 +- trunk/fs/inotify_user.c | 2 +- trunk/fs/ioctl.c | 4 +- trunk/fs/isofs/isofs.h | 12 +- trunk/fs/jbd2/journal.c | 17 +- trunk/fs/jfs/jfs_debug.c | 4 +- trunk/fs/namei.c | 9 - trunk/fs/namespace.c | 13 +- trunk/fs/ncpfs/ncplib_kernel.c | 39 +- trunk/fs/nfs/client.c | 20 +- trunk/fs/nfsd/nfsctl.c | 4 +- trunk/fs/ntfs/mft.c | 6 +- trunk/fs/proc/base.c | 113 +- trunk/fs/proc/generic.c | 132 +- trunk/fs/proc/inode.c | 69 +- trunk/fs/proc/internal.h | 4 +- trunk/fs/proc/nommu.c | 2 +- trunk/fs/proc/proc_misc.c | 66 +- trunk/fs/proc/proc_sysctl.c | 52 +- trunk/fs/proc/proc_tty.c | 81 +- trunk/fs/proc/root.c | 14 +- trunk/fs/proc/task_mmu.c | 34 + trunk/fs/proc/task_nommu.c | 34 + trunk/fs/ramfs/file-mmu.c | 3 - trunk/fs/ramfs/internal.h | 1 + trunk/fs/reiserfs/procfs.c | 9 +- trunk/fs/splice.c | 2 +- trunk/fs/super.c | 2 +- trunk/fs/sync.c | 2 +- trunk/fs/timerfd.c | 1 - trunk/fs/xattr.c | 41 +- trunk/fs/xfs/linux-2.6/xfs_vnode.h | 24 - trunk/fs/xfs/xfs_acl.c | 6 +- trunk/fs/xfs/xfs_vnodeops.c | 20 +- trunk/include/asm-alpha/unaligned.h | 13 +- trunk/include/asm-arm/arch-orion5x/io.h | 9 +- trunk/include/asm-arm/arch-pxa/irqs.h | 5 +- trunk/include/asm-arm/arch-pxa/magician.h | 49 + trunk/include/asm-arm/arch-pxa/system.h | 2 - trunk/include/asm-arm/page.h | 8 - trunk/include/asm-arm/unaligned.h | 174 +- trunk/include/asm-avr32/unaligned.h | 13 +- trunk/include/asm-blackfin/unaligned.h | 13 +- trunk/include/asm-cris/unaligned.h | 17 +- trunk/include/asm-frv/unaligned.h | 196 ++- trunk/include/asm-generic/ioctl.h | 33 +- trunk/include/asm-generic/unaligned.h | 124 ++ trunk/include/asm-h8300/unaligned.h | 20 +- trunk/include/asm-ia64/dma-mapping.h | 28 +- trunk/include/asm-ia64/machvec.h | 50 +- trunk/include/asm-ia64/machvec_hpzx1.h | 16 +- .../include/asm-ia64/machvec_hpzx1_swiotlb.h | 16 +- trunk/include/asm-ia64/machvec_sn2.h | 16 +- trunk/include/asm-ia64/topology.h | 2 - trunk/include/asm-ia64/unaligned.h | 7 +- trunk/include/asm-ia64/uncached.h | 6 +- trunk/include/asm-m32r/unaligned.h | 27 +- trunk/include/asm-m68k/unaligned.h | 17 +- trunk/include/asm-m68knommu/unaligned.h | 22 +- trunk/include/asm-mips/unaligned.h | 37 +- trunk/include/asm-mn10300/unaligned.h | 130 +- trunk/include/asm-parisc/unaligned.h | 12 +- trunk/include/asm-powerpc/irq.h | 2 + trunk/include/asm-powerpc/processor.h | 6 - trunk/include/asm-powerpc/system.h | 24 +- trunk/include/asm-powerpc/unaligned.h | 11 +- trunk/include/{asm-powerpc => asm-ppc}/rio.h | 0 trunk/include/asm-s390/unaligned.h | 25 +- trunk/include/asm-sh/unaligned.h | 20 +- trunk/include/asm-sparc/unaligned.h | 10 +- trunk/include/asm-sparc64/unaligned.h | 10 +- trunk/include/asm-um/unaligned.h | 6 +- trunk/include/asm-v850/unaligned.h | 124 +- trunk/include/asm-x86/olpc.h | 132 -- trunk/include/asm-x86/pci.h | 2 - trunk/include/asm-x86/time.h | 1 + trunk/include/asm-x86/topology.h | 20 - trunk/include/asm-x86/tsc.h | 2 +- trunk/include/asm-x86/unaligned.h | 31 +- trunk/include/asm-xtensa/unaligned.h | 35 +- trunk/include/linux/Kbuild | 11 +- trunk/include/linux/acpi.h | 5 - trunk/include/linux/aio.h | 19 + trunk/include/linux/audit.h | 28 +- trunk/include/linux/backing-dev.h | 2 + trunk/include/linux/binfmts.h | 4 +- trunk/include/linux/bio.h | 2 - trunk/include/linux/bitops.h | 117 +- trunk/include/linux/blkdev.h | 51 +- trunk/include/linux/buffer_head.h | 1 + trunk/include/linux/capability.h | 12 +- trunk/include/linux/cgroup.h | 80 +- trunk/include/linux/cgroup_subsys.h | 6 - trunk/include/linux/coda_linux.h | 3 + trunk/include/linux/console_struct.h | 1 - trunk/include/linux/cpu.h | 2 +- trunk/include/linux/cpufreq.h | 6 +- trunk/include/linux/device_cgroup.h | 12 - trunk/include/linux/dma-attrs.h | 74 - trunk/include/linux/dma-mapping.h | 17 - trunk/include/linux/edac.h | 14 +- trunk/include/linux/elf.h | 2 +- trunk/include/linux/fs.h | 2 + trunk/include/linux/gfp.h | 6 +- trunk/include/linux/i2c-id.h | 3 + trunk/include/linux/i2c.h | 17 +- trunk/include/linux/idr.h | 3 - trunk/include/linux/init.h | 2 - trunk/include/linux/interrupt.h | 1 - trunk/include/linux/ipc_namespace.h | 24 +- trunk/include/linux/ipmi.h | 85 +- trunk/include/linux/ipmi_smi.h | 10 +- trunk/include/linux/kbuild.h | 15 - trunk/include/linux/kernel.h | 5 - trunk/include/linux/key.h | 30 +- trunk/include/linux/keyctl.h | 1 - trunk/include/linux/libata.h | 12 +- trunk/include/linux/list.h | 5 +- trunk/include/linux/lmb.h | 4 +- trunk/include/linux/mca-legacy.h | 1 + trunk/include/linux/memcontrol.h | 16 +- trunk/include/linux/memory.h | 7 - trunk/include/linux/mlx4/device.h | 3 +- trunk/include/linux/mm.h | 15 +- trunk/include/linux/mm_types.h | 11 +- trunk/include/linux/mod_devicetable.h | 11 - trunk/include/linux/msg.h | 14 +- trunk/include/linux/msi.h | 1 - trunk/include/linux/nbd.h | 10 +- trunk/include/linux/netlink.h | 1 - trunk/include/linux/notifier.h | 4 - trunk/include/linux/pci.h | 21 +- trunk/include/linux/pci_ids.h | 2 - trunk/include/linux/percpu.h | 1 + trunk/include/linux/personality.h | 4 + trunk/include/linux/phantom.h | 11 +- trunk/include/linux/proc_fs.h | 61 +- trunk/include/linux/res_counter.h | 29 +- trunk/include/linux/resource.h | 1 - trunk/include/linux/rio.h | 38 +- trunk/include/linux/sched.h | 13 - trunk/include/linux/security.h | 69 +- trunk/include/linux/smb.h | 1 - trunk/include/linux/syscalls.h | 30 +- trunk/include/linux/sysctl.h | 14 +- trunk/include/linux/sysv_fs.h | 6 +- trunk/include/linux/tty.h | 9 +- trunk/include/linux/unaligned/access_ok.h | 67 - trunk/include/linux/unaligned/be_byteshift.h | 70 - trunk/include/linux/unaligned/be_memmove.h | 36 - trunk/include/linux/unaligned/be_struct.h | 36 - trunk/include/linux/unaligned/generic.h | 68 - trunk/include/linux/unaligned/le_byteshift.h | 70 - trunk/include/linux/unaligned/le_memmove.h | 36 - trunk/include/linux/unaligned/le_struct.h | 36 - trunk/include/linux/unaligned/memmove.h | 45 - trunk/include/linux/unaligned/packed_struct.h | 46 - trunk/include/linux/xattr.h | 6 +- trunk/include/media/v4l2-chip-ident.h | 1 - trunk/include/media/v4l2-common.h | 4 +- trunk/include/media/v4l2-i2c-drv-legacy.h | 2 +- trunk/include/media/v4l2-i2c-drv.h | 2 +- trunk/include/net/netlabel.h | 1 - trunk/include/net/xfrm.h | 23 +- trunk/include/rdma/ib_umem.h | 4 +- trunk/include/rdma/ib_verbs.h | 33 - trunk/include/scsi/libiscsi.h | 1 - trunk/include/sound/mpu401.h | 1 - trunk/init/Kconfig | 41 +- trunk/init/initramfs.c | 20 +- trunk/init/main.c | 23 +- trunk/ipc/Makefile | 2 +- trunk/ipc/ipc_sysctl.c | 68 +- trunk/ipc/ipcns_notifier.c | 82 - trunk/ipc/msg.c | 239 +-- trunk/ipc/namespace.c | 26 - trunk/ipc/sem.c | 159 +- trunk/ipc/shm.c | 186 +- trunk/ipc/util.c | 131 +- trunk/ipc/util.h | 6 +- trunk/kernel/Makefile | 2 +- trunk/kernel/audit.c | 249 +-- trunk/kernel/audit.h | 13 - trunk/kernel/auditfilter.c | 55 +- trunk/kernel/auditsc.c | 40 +- trunk/kernel/bounds.c | 6 +- trunk/kernel/cgroup.c | 331 ++-- trunk/kernel/cgroup_debug.c | 20 +- trunk/kernel/configs.c | 7 +- trunk/kernel/cpu.c | 40 +- trunk/kernel/cpuset.c | 355 ++-- trunk/kernel/dma.c | 7 +- trunk/kernel/exit.c | 83 - trunk/kernel/fork.c | 48 +- trunk/kernel/irq/devres.c | 1 - trunk/kernel/irq/manage.c | 1 - trunk/kernel/kallsyms.c | 6 +- trunk/kernel/kthread.c | 2 +- trunk/kernel/latencytop.c | 9 +- trunk/kernel/lockdep_proc.c | 16 +- trunk/kernel/marker.c | 1 - trunk/kernel/notifier.c | 38 - trunk/kernel/ns_cgroup.c | 2 - trunk/kernel/nsproxy.c | 12 - trunk/kernel/panic.c | 8 +- trunk/kernel/printk.c | 26 +- trunk/kernel/profile.c | 4 +- trunk/kernel/rcutorture.c | 1 - trunk/kernel/relay.c | 37 +- trunk/kernel/res_counter.c | 10 - trunk/kernel/resource.c | 10 +- trunk/kernel/sched.c | 62 +- trunk/kernel/sched_debug.c | 5 +- trunk/kernel/sys.c | 31 +- trunk/kernel/sysctl.c | 176 +- trunk/kernel/time.c | 1 - trunk/kernel/time/timer_list.c | 5 +- trunk/kernel/time/timer_stats.c | 5 +- trunk/kernel/user.c | 15 +- trunk/kernel/user_namespace.c | 2 - trunk/kernel/utsname.c | 1 - trunk/kernel/workqueue.c | 24 +- trunk/lib/Makefile | 2 +- trunk/lib/find_next_bit.c | 22 +- trunk/lib/idr.c | 10 +- trunk/lib/inflate.c | 3 - trunk/lib/iomap.c | 2 +- trunk/lib/lmb.c | 99 +- trunk/lib/ratelimit.c | 51 - trunk/lib/swiotlb.c | 149 +- trunk/mm/hugetlb.c | 6 +- trunk/mm/memcontrol.c | 179 +- trunk/mm/mmap.c | 24 +- trunk/mm/nommu.c | 23 +- trunk/mm/page_alloc.c | 37 +- trunk/mm/slub.c | 2 +- trunk/mm/swapfile.c | 6 +- trunk/mm/vmscan.c | 7 +- trunk/net/core/dev.c | 2 +- trunk/net/ipv4/af_inet.c | 2 +- trunk/net/irda/irnet/irnet_irda.c | 65 +- trunk/net/irda/irnet/irnet_irda.h | 8 + trunk/net/key/af_key.c | 17 +- trunk/net/netfilter/nf_queue.c | 2 +- trunk/net/netlabel/netlabel_unlabeled.c | 1 - trunk/net/netlabel/netlabel_user.c | 4 +- trunk/net/netlabel/netlabel_user.h | 1 - trunk/net/netlink/af_netlink.c | 1 - trunk/net/xfrm/xfrm_output.c | 2 +- trunk/net/xfrm/xfrm_policy.c | 12 +- trunk/net/xfrm/xfrm_state.c | 13 +- trunk/net/xfrm/xfrm_user.c | 41 +- trunk/samples/markers/marker-example.c | 6 +- trunk/scripts/Lindent | 18 +- trunk/scripts/checkpatch.pl | 150 +- trunk/scripts/mod/file2alias.c | 13 - trunk/security/Makefile | 1 - trunk/security/commoncap.c | 6 +- trunk/security/device_cgroup.c | 575 ------- trunk/security/dummy.c | 23 +- trunk/security/keys/Makefile | 1 - trunk/security/keys/compat.c | 3 - trunk/security/keys/internal.h | 30 +- trunk/security/keys/key.c | 86 +- trunk/security/keys/keyctl.c | 126 +- trunk/security/keys/keyring.c | 54 +- trunk/security/keys/proc.c | 17 +- trunk/security/keys/process_keys.c | 142 +- trunk/security/keys/request_key.c | 50 +- trunk/security/keys/request_key_auth.c | 13 +- trunk/security/keys/sysctl.c | 50 - trunk/security/security.c | 19 +- trunk/security/selinux/avc.c | 2 +- trunk/security/selinux/hooks.c | 39 +- trunk/security/selinux/include/security.h | 4 +- trunk/security/selinux/ss/services.c | 8 +- trunk/security/smack/smack_lsm.c | 169 +- trunk/security/smack/smackfs.c | 2 - trunk/sound/core/info.c | 4 +- trunk/sound/core/memalloc.c | 5 +- trunk/sound/drivers/Kconfig | 2 - trunk/sound/drivers/mpu401/mpu401_uart.c | 2 +- trunk/sound/pci/hda/patch_realtek.c | 86 - trunk/sound/pci/ice1712/ice1724.c | 3 +- trunk/sound/sh/aica.c | 2 +- trunk/sound/soc/Kconfig | 1 - trunk/sound/soc/Makefile | 2 +- trunk/sound/soc/codecs/wm9712.c | 62 +- trunk/sound/soc/omap/Kconfig | 19 - trunk/sound/soc/omap/Makefile | 11 - trunk/sound/soc/omap/n810.c | 336 ---- trunk/sound/soc/omap/omap-mcbsp.c | 414 ----- trunk/sound/soc/omap/omap-mcbsp.h | 49 - trunk/sound/soc/omap/omap-pcm.c | 357 ---- trunk/sound/soc/omap/omap-pcm.h | 35 - 1020 files changed, 11134 insertions(+), 29971 deletions(-) delete mode 100644 trunk/Documentation/DMA-attributes.txt delete mode 100644 trunk/Documentation/controllers/devices.txt delete mode 100644 trunk/Documentation/controllers/resource_counter.txt delete mode 100644 trunk/Documentation/video4linux/cx18.txt delete mode 100644 trunk/arch/arm/mm/copypage-feroceon.S create mode 100644 trunk/arch/frv/mm/unaligned.c create mode 100644 trunk/arch/powerpc/kernel/rio.c delete mode 100644 trunk/arch/powerpc/platforms/pseries/hotplug-memory.c create mode 100644 trunk/arch/powerpc/sysdev/fsl_rio.h delete mode 100644 trunk/arch/x86/kernel/mmconf-fam10h_64.c delete mode 100644 trunk/arch/x86/kernel/olpc.c delete mode 100644 trunk/arch/x86/pci/mp_bus_to_node.c delete mode 100644 trunk/arch/x86/pci/olpc.c rename trunk/drivers/ata/{pata_rb532_cf.c => pata_rb500_cf.c} (72%) delete mode 100644 trunk/drivers/macintosh/windfarm_pm121.c delete mode 100644 trunk/drivers/media/common/tuners/Kconfig delete mode 100644 trunk/drivers/media/common/tuners/Makefile create mode 100644 trunk/drivers/media/dvb/dvb-core/Kconfig rename trunk/drivers/media/{common/tuners => dvb/frontends}/mt2060.c (100%) rename trunk/drivers/media/{common/tuners => dvb/frontends}/mt2060.h (90%) rename trunk/drivers/media/{common/tuners => dvb/frontends}/mt2060_priv.h (100%) rename trunk/drivers/media/{common/tuners => dvb/frontends}/mt2131.c (100%) rename trunk/drivers/media/{common/tuners => dvb/frontends}/mt2131.h (91%) rename trunk/drivers/media/{common/tuners => dvb/frontends}/mt2131_priv.h (100%) rename trunk/drivers/media/{common/tuners => dvb/frontends}/mt2266.c (100%) rename trunk/drivers/media/{common/tuners => dvb/frontends}/mt2266.h (88%) rename trunk/drivers/media/{common/tuners => dvb/frontends}/qt1010.c (100%) rename trunk/drivers/media/{common/tuners => dvb/frontends}/qt1010.h (91%) rename trunk/drivers/media/{common/tuners => dvb/frontends}/qt1010_priv.h (100%) rename trunk/drivers/media/{common/tuners => dvb/frontends}/tda18271-common.c (100%) rename trunk/drivers/media/{common/tuners => dvb/frontends}/tda18271-fe.c (100%) rename trunk/drivers/media/{common/tuners => dvb/frontends}/tda18271-priv.h (100%) rename trunk/drivers/media/{common/tuners/tda18271-maps.c => dvb/frontends/tda18271-tables.c} (100%) rename trunk/drivers/media/{common/tuners => dvb/frontends}/tda18271.h (96%) rename trunk/drivers/media/{common/tuners => dvb/frontends}/tda827x.c (100%) rename trunk/drivers/media/{common/tuners => dvb/frontends}/tda827x.h (93%) rename trunk/drivers/media/{common/tuners => dvb/frontends}/xc5000.c (100%) rename trunk/drivers/media/{common/tuners => dvb/frontends}/xc5000.h (92%) rename trunk/drivers/media/{common/tuners => dvb/frontends}/xc5000_priv.h (100%) delete mode 100644 trunk/drivers/media/video/cx18/Kconfig delete mode 100644 trunk/drivers/media/video/cx18/Makefile delete mode 100644 trunk/drivers/media/video/cx18/cx18-audio.c delete mode 100644 trunk/drivers/media/video/cx18/cx18-audio.h delete mode 100644 trunk/drivers/media/video/cx18/cx18-av-audio.c delete mode 100644 trunk/drivers/media/video/cx18/cx18-av-core.c delete mode 100644 trunk/drivers/media/video/cx18/cx18-av-core.h delete mode 100644 trunk/drivers/media/video/cx18/cx18-av-firmware.c delete mode 100644 trunk/drivers/media/video/cx18/cx18-av-vbi.c delete mode 100644 trunk/drivers/media/video/cx18/cx18-cards.c delete mode 100644 trunk/drivers/media/video/cx18/cx18-cards.h delete mode 100644 trunk/drivers/media/video/cx18/cx18-controls.c delete mode 100644 trunk/drivers/media/video/cx18/cx18-controls.h delete mode 100644 trunk/drivers/media/video/cx18/cx18-driver.c delete mode 100644 trunk/drivers/media/video/cx18/cx18-driver.h delete mode 100644 trunk/drivers/media/video/cx18/cx18-dvb.c delete mode 100644 trunk/drivers/media/video/cx18/cx18-dvb.h delete mode 100644 trunk/drivers/media/video/cx18/cx18-fileops.c delete mode 100644 trunk/drivers/media/video/cx18/cx18-fileops.h delete mode 100644 trunk/drivers/media/video/cx18/cx18-firmware.c delete mode 100644 trunk/drivers/media/video/cx18/cx18-firmware.h delete mode 100644 trunk/drivers/media/video/cx18/cx18-gpio.c delete mode 100644 trunk/drivers/media/video/cx18/cx18-gpio.h delete mode 100644 trunk/drivers/media/video/cx18/cx18-i2c.c delete mode 100644 trunk/drivers/media/video/cx18/cx18-i2c.h delete mode 100644 trunk/drivers/media/video/cx18/cx18-ioctl.c delete mode 100644 trunk/drivers/media/video/cx18/cx18-ioctl.h delete mode 100644 trunk/drivers/media/video/cx18/cx18-irq.c delete mode 100644 trunk/drivers/media/video/cx18/cx18-irq.h delete mode 100644 trunk/drivers/media/video/cx18/cx18-mailbox.c delete mode 100644 trunk/drivers/media/video/cx18/cx18-mailbox.h delete mode 100644 trunk/drivers/media/video/cx18/cx18-queue.c delete mode 100644 trunk/drivers/media/video/cx18/cx18-queue.h delete mode 100644 trunk/drivers/media/video/cx18/cx18-scb.c delete mode 100644 trunk/drivers/media/video/cx18/cx18-scb.h delete mode 100644 trunk/drivers/media/video/cx18/cx18-streams.c delete mode 100644 trunk/drivers/media/video/cx18/cx18-streams.h delete mode 100644 trunk/drivers/media/video/cx18/cx18-vbi.c delete mode 100644 trunk/drivers/media/video/cx18/cx18-vbi.h delete mode 100644 trunk/drivers/media/video/cx18/cx18-version.h delete mode 100644 trunk/drivers/media/video/cx18/cx18-video.c delete mode 100644 trunk/drivers/media/video/cx18/cx18-video.h delete mode 100644 trunk/drivers/media/video/cx18/cx23418.h rename trunk/drivers/media/{common/tuners => video}/mt20xx.c (100%) rename trunk/drivers/media/{common/tuners => video}/mt20xx.h (91%) rename trunk/drivers/media/{common/tuners => video}/tda8290.c (99%) rename trunk/drivers/media/{common/tuners => video}/tda8290.h (94%) rename trunk/drivers/media/{common/tuners => video}/tda9887.c (100%) rename trunk/drivers/media/{common/tuners => video}/tda9887.h (92%) rename trunk/drivers/media/{common/tuners => video}/tea5761.c (100%) rename trunk/drivers/media/{common/tuners => video}/tea5761.h (93%) rename trunk/drivers/media/{common/tuners => video}/tea5767.c (100%) rename trunk/drivers/media/{common/tuners => video}/tea5767.h (94%) rename trunk/drivers/media/{common/tuners => video}/tuner-i2c.h (100%) rename trunk/drivers/media/{common/tuners => video}/tuner-simple.c (100%) rename trunk/drivers/media/{common/tuners => video}/tuner-simple.h (92%) rename trunk/drivers/media/{common/tuners => video}/tuner-types.c (100%) rename trunk/drivers/media/{common/tuners => video}/tuner-xc2028-types.h (100%) rename trunk/drivers/media/{common/tuners => video}/tuner-xc2028.c (100%) rename trunk/drivers/media/{common/tuners => video}/tuner-xc2028.h (93%) delete mode 100644 trunk/fs/ecryptfs/miscdev.c create mode 100644 trunk/include/asm-generic/unaligned.h rename trunk/include/{asm-powerpc => asm-ppc}/rio.h (100%) delete mode 100644 trunk/include/asm-x86/olpc.h delete mode 100644 trunk/include/linux/device_cgroup.h delete mode 100644 trunk/include/linux/dma-attrs.h delete mode 100644 trunk/include/linux/kbuild.h delete mode 100644 trunk/include/linux/unaligned/access_ok.h delete mode 100644 trunk/include/linux/unaligned/be_byteshift.h delete mode 100644 trunk/include/linux/unaligned/be_memmove.h delete mode 100644 trunk/include/linux/unaligned/be_struct.h delete mode 100644 trunk/include/linux/unaligned/generic.h delete mode 100644 trunk/include/linux/unaligned/le_byteshift.h delete mode 100644 trunk/include/linux/unaligned/le_memmove.h delete mode 100644 trunk/include/linux/unaligned/le_struct.h delete mode 100644 trunk/include/linux/unaligned/memmove.h delete mode 100644 trunk/include/linux/unaligned/packed_struct.h delete mode 100644 trunk/ipc/ipcns_notifier.c delete mode 100644 trunk/lib/ratelimit.c delete mode 100644 trunk/security/device_cgroup.c delete mode 100644 trunk/security/keys/sysctl.c delete mode 100644 trunk/sound/soc/omap/Kconfig delete mode 100644 trunk/sound/soc/omap/Makefile delete mode 100644 trunk/sound/soc/omap/n810.c delete mode 100644 trunk/sound/soc/omap/omap-mcbsp.c delete mode 100644 trunk/sound/soc/omap/omap-mcbsp.h delete mode 100644 trunk/sound/soc/omap/omap-pcm.c delete mode 100644 trunk/sound/soc/omap/omap-pcm.h diff --git a/[refs] b/[refs] index 89c3bed5ddce..0089b27fd31c 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: a94a630a4c69430bb4562ab8252104449bba9a67 +refs/heads/master: 42173f6860af7e016a950a9a19a66679cfc46d98 diff --git a/trunk/Documentation/DMA-API.txt b/trunk/Documentation/DMA-API.txt index 80d150458c80..b939ebb62871 100644 --- a/trunk/Documentation/DMA-API.txt +++ b/trunk/Documentation/DMA-API.txt @@ -145,7 +145,7 @@ Part Ic - DMA addressing limitations int dma_supported(struct device *dev, u64 mask) int -pci_dma_supported(struct pci_dev *hwdev, u64 mask) +pci_dma_supported(struct device *dev, u64 mask) Checks to see if the device can support DMA to the memory described by mask. @@ -189,7 +189,7 @@ dma_addr_t dma_map_single(struct device *dev, void *cpu_addr, size_t size, enum dma_data_direction direction) dma_addr_t -pci_map_single(struct pci_dev *hwdev, void *cpu_addr, size_t size, +pci_map_single(struct device *dev, void *cpu_addr, size_t size, int direction) Maps a piece of processor virtual memory so it can be accessed by the @@ -395,71 +395,6 @@ Notes: You must do this: See also dma_map_single(). -dma_addr_t -dma_map_single_attrs(struct device *dev, void *cpu_addr, size_t size, - enum dma_data_direction dir, - struct dma_attrs *attrs) - -void -dma_unmap_single_attrs(struct device *dev, dma_addr_t dma_addr, - size_t size, enum dma_data_direction dir, - struct dma_attrs *attrs) - -int -dma_map_sg_attrs(struct device *dev, struct scatterlist *sgl, - int nents, enum dma_data_direction dir, - struct dma_attrs *attrs) - -void -dma_unmap_sg_attrs(struct device *dev, struct scatterlist *sgl, - int nents, enum dma_data_direction dir, - struct dma_attrs *attrs) - -The four functions above are just like the counterpart functions -without the _attrs suffixes, except that they pass an optional -struct dma_attrs*. - -struct dma_attrs encapsulates a set of "dma attributes". For the -definition of struct dma_attrs see linux/dma-attrs.h. - -The interpretation of dma attributes is architecture-specific, and -each attribute should be documented in Documentation/DMA-attributes.txt. - -If struct dma_attrs* is NULL, the semantics of each of these -functions is identical to those of the corresponding function -without the _attrs suffix. As a result dma_map_single_attrs() -can generally replace dma_map_single(), etc. - -As an example of the use of the *_attrs functions, here's how -you could pass an attribute DMA_ATTR_FOO when mapping memory -for DMA: - -#include -/* DMA_ATTR_FOO should be defined in linux/dma-attrs.h and - * documented in Documentation/DMA-attributes.txt */ -... - - DEFINE_DMA_ATTRS(attrs); - dma_set_attr(DMA_ATTR_FOO, &attrs); - .... - n = dma_map_sg_attrs(dev, sg, nents, DMA_TO_DEVICE, &attr); - .... - -Architectures that care about DMA_ATTR_FOO would check for its -presence in their implementations of the mapping and unmapping -routines, e.g.: - -void whizco_dma_map_sg_attrs(struct device *dev, dma_addr_t dma_addr, - size_t size, enum dma_data_direction dir, - struct dma_attrs *attrs) -{ - .... - int foo = dma_get_attr(DMA_ATTR_FOO, attrs); - .... - if (foo) - /* twizzle the frobnozzle */ - .... - Part II - Advanced dma_ usage ----------------------------- diff --git a/trunk/Documentation/DMA-attributes.txt b/trunk/Documentation/DMA-attributes.txt deleted file mode 100644 index 6d772f84b477..000000000000 --- a/trunk/Documentation/DMA-attributes.txt +++ /dev/null @@ -1,24 +0,0 @@ - DMA attributes - ============== - -This document describes the semantics of the DMA attributes that are -defined in linux/dma-attrs.h. - -DMA_ATTR_WRITE_BARRIER ----------------------- - -DMA_ATTR_WRITE_BARRIER is a (write) barrier attribute for DMA. DMA -to a memory region with the DMA_ATTR_WRITE_BARRIER attribute forces -all pending DMA writes to complete, and thus provides a mechanism to -strictly order DMA from a device across all intervening busses and -bridges. This barrier is not specific to a particular type of -interconnect, it applies to the system as a whole, and so its -implementation must account for the idiosyncracies of the system all -the way from the DMA device to memory. - -As an example of a situation where DMA_ATTR_WRITE_BARRIER would be -useful, suppose that a device does a DMA write to indicate that data is -ready and available in memory. The DMA of the "completion indication" -could race with data DMA. Mapping the memory used for completion -indications with DMA_ATTR_WRITE_BARRIER would prevent the race. - diff --git a/trunk/Documentation/DMA-mapping.txt b/trunk/Documentation/DMA-mapping.txt index b463ecd0c7ce..d84f89dbf921 100644 --- a/trunk/Documentation/DMA-mapping.txt +++ b/trunk/Documentation/DMA-mapping.txt @@ -315,11 +315,11 @@ you should do: dma_addr_t dma_handle; - cpu_addr = pci_alloc_consistent(pdev, size, &dma_handle); + cpu_addr = pci_alloc_consistent(dev, size, &dma_handle); -where pdev is a struct pci_dev *. This may be called in interrupt context. -You should use dma_alloc_coherent (see DMA-API.txt) for buses -where devices don't have struct pci_dev (like ISA, EISA). +where dev is a struct pci_dev *. You should pass NULL for PCI like buses +where devices don't have struct pci_dev (like ISA, EISA). This may be +called in interrupt context. This argument is needed because the DMA translations may be bus specific (and often is private to the bus which the device is attached @@ -332,7 +332,7 @@ __get_free_pages (but takes size instead of a page order). If your driver needs regions sized smaller than a page, you may prefer using the pci_pool interface, described below. -The consistent DMA mapping interfaces, for non-NULL pdev, will by +The consistent DMA mapping interfaces, for non-NULL dev, will by default return a DMA address which is SAC (Single Address Cycle) addressable. Even if the device indicates (via PCI dma mask) that it may address the upper 32-bits and thus perform DAC cycles, consistent @@ -354,9 +354,9 @@ buffer you receive will not cross a 64K boundary. To unmap and free such a DMA region, you call: - pci_free_consistent(pdev, size, cpu_addr, dma_handle); + pci_free_consistent(dev, size, cpu_addr, dma_handle); -where pdev, size are the same as in the above call and cpu_addr and +where dev, size are the same as in the above call and cpu_addr and dma_handle are the values pci_alloc_consistent returned to you. This function may not be called in interrupt context. @@ -371,9 +371,9 @@ Create a pci_pool like this: struct pci_pool *pool; - pool = pci_pool_create(name, pdev, size, align, alloc); + pool = pci_pool_create(name, dev, size, align, alloc); -The "name" is for diagnostics (like a kmem_cache name); pdev and size +The "name" is for diagnostics (like a kmem_cache name); dev and size are as above. The device's hardware alignment requirement for this type of data is "align" (which is expressed in bytes, and must be a power of two). If your device has no boundary crossing restrictions, @@ -472,11 +472,11 @@ To map a single region, you do: void *addr = buffer->ptr; size_t size = buffer->len; - dma_handle = pci_map_single(pdev, addr, size, direction); + dma_handle = pci_map_single(dev, addr, size, direction); and to unmap it: - pci_unmap_single(pdev, dma_handle, size, direction); + pci_unmap_single(dev, dma_handle, size, direction); You should call pci_unmap_single when the DMA activity is finished, e.g. from the interrupt which told you that the DMA transfer is done. @@ -493,17 +493,17 @@ Specifically: unsigned long offset = buffer->offset; size_t size = buffer->len; - dma_handle = pci_map_page(pdev, page, offset, size, direction); + dma_handle = pci_map_page(dev, page, offset, size, direction); ... - pci_unmap_page(pdev, dma_handle, size, direction); + pci_unmap_page(dev, dma_handle, size, direction); Here, "offset" means byte offset within the given page. With scatterlists, you map a region gathered from several regions by: - int i, count = pci_map_sg(pdev, sglist, nents, direction); + int i, count = pci_map_sg(dev, sglist, nents, direction); struct scatterlist *sg; for_each_sg(sglist, sg, count, i) { @@ -527,7 +527,7 @@ accessed sg->address and sg->length as shown above. To unmap a scatterlist, just call: - pci_unmap_sg(pdev, sglist, nents, direction); + pci_unmap_sg(dev, sglist, nents, direction); Again, make sure DMA activity has already finished. @@ -550,11 +550,11 @@ correct copy of the DMA buffer. So, firstly, just map it with pci_map_{single,sg}, and after each DMA transfer call either: - pci_dma_sync_single_for_cpu(pdev, dma_handle, size, direction); + pci_dma_sync_single_for_cpu(dev, dma_handle, size, direction); or: - pci_dma_sync_sg_for_cpu(pdev, sglist, nents, direction); + pci_dma_sync_sg_for_cpu(dev, sglist, nents, direction); as appropriate. @@ -562,7 +562,7 @@ Then, if you wish to let the device get at the DMA area again, finish accessing the data with the cpu, and then before actually giving the buffer to the hardware call either: - pci_dma_sync_single_for_device(pdev, dma_handle, size, direction); + pci_dma_sync_single_for_device(dev, dma_handle, size, direction); or: @@ -739,7 +739,7 @@ failure can be determined by: dma_addr_t dma_handle; - dma_handle = pci_map_single(pdev, addr, size, direction); + dma_handle = pci_map_single(dev, addr, size, direction); if (pci_dma_mapping_error(dma_handle)) { /* * reduce current DMA mapping usage, diff --git a/trunk/Documentation/cgroups.txt b/trunk/Documentation/cgroups.txt index c298a6690e0d..31d12e21ff8a 100644 --- a/trunk/Documentation/cgroups.txt +++ b/trunk/Documentation/cgroups.txt @@ -500,7 +500,8 @@ post-attachment activity that requires memory allocations or blocking. void fork(struct cgroup_subsy *ss, struct task_struct *task) -Called when a task is forked into a cgroup. +Called when a task is forked into a cgroup. Also called during +registration for all existing tasks. void exit(struct cgroup_subsys *ss, struct task_struct *task) diff --git a/trunk/Documentation/controllers/devices.txt b/trunk/Documentation/controllers/devices.txt deleted file mode 100644 index 4dcea42432c2..000000000000 --- a/trunk/Documentation/controllers/devices.txt +++ /dev/null @@ -1,48 +0,0 @@ -Device Whitelist Controller - -1. Description: - -Implement a cgroup to track and enforce open and mknod restrictions -on device files. A device cgroup associates a device access -whitelist with each cgroup. A whitelist entry has 4 fields. -'type' is a (all), c (char), or b (block). 'all' means it applies -to all types and all major and minor numbers. Major and minor are -either an integer or * for all. Access is a composition of r -(read), w (write), and m (mknod). - -The root device cgroup starts with rwm to 'all'. A child device -cgroup gets a copy of the parent. Administrators can then remove -devices from the whitelist or add new entries. A child cgroup can -never receive a device access which is denied its parent. However -when a device access is removed from a parent it will not also be -removed from the child(ren). - -2. User Interface - -An entry is added using devices.allow, and removed using -devices.deny. For instance - - echo 'c 1:3 mr' > /cgroups/1/devices.allow - -allows cgroup 1 to read and mknod the device usually known as -/dev/null. Doing - - echo a > /cgroups/1/devices.deny - -will remove the default 'a *:* mrw' entry. - -3. Security - -Any task can move itself between cgroups. This clearly won't -suffice, but we can decide the best way to adequately restrict -movement as people get some experience with this. We may just want -to require CAP_SYS_ADMIN, which at least is a separate bit from -CAP_MKNOD. We may want to just refuse moving to a cgroup which -isn't a descendent of the current one. Or we may want to use -CAP_MAC_ADMIN, since we really are trying to lock down root. - -CAP_SYS_ADMIN is needed to modify the whitelist or move another -task to a new cgroup. (Again we'll probably want to change that). - -A cgroup may not be granted more permissions than the cgroup's -parent has. diff --git a/trunk/Documentation/controllers/resource_counter.txt b/trunk/Documentation/controllers/resource_counter.txt deleted file mode 100644 index f196ac1d7d25..000000000000 --- a/trunk/Documentation/controllers/resource_counter.txt +++ /dev/null @@ -1,181 +0,0 @@ - - The Resource Counter - -The resource counter, declared at include/linux/res_counter.h, -is supposed to facilitate the resource management by controllers -by providing common stuff for accounting. - -This "stuff" includes the res_counter structure and routines -to work with it. - - - -1. Crucial parts of the res_counter structure - - a. unsigned long long usage - - The usage value shows the amount of a resource that is consumed - by a group at a given time. The units of measurement should be - determined by the controller that uses this counter. E.g. it can - be bytes, items or any other unit the controller operates on. - - b. unsigned long long max_usage - - The maximal value of the usage over time. - - This value is useful when gathering statistical information about - the particular group, as it shows the actual resource requirements - for a particular group, not just some usage snapshot. - - c. unsigned long long limit - - The maximal allowed amount of resource to consume by the group. In - case the group requests for more resources, so that the usage value - would exceed the limit, the resource allocation is rejected (see - the next section). - - d. unsigned long long failcnt - - The failcnt stands for "failures counter". This is the number of - resource allocation attempts that failed. - - c. spinlock_t lock - - Protects changes of the above values. - - - -2. Basic accounting routines - - a. void res_counter_init(struct res_counter *rc) - - Initializes the resource counter. As usual, should be the first - routine called for a new counter. - - b. int res_counter_charge[_locked] - (struct res_counter *rc, unsigned long val) - - When a resource is about to be allocated it has to be accounted - with the appropriate resource counter (controller should determine - which one to use on its own). This operation is called "charging". - - This is not very important which operation - resource allocation - or charging - is performed first, but - * if the allocation is performed first, this may create a - temporary resource over-usage by the time resource counter is - charged; - * if the charging is performed first, then it should be uncharged - on error path (if the one is called). - - c. void res_counter_uncharge[_locked] - (struct res_counter *rc, unsigned long val) - - When a resource is released (freed) it should be de-accounted - from the resource counter it was accounted to. This is called - "uncharging". - - The _locked routines imply that the res_counter->lock is taken. - - - 2.1 Other accounting routines - - There are more routines that may help you with common needs, like - checking whether the limit is reached or resetting the max_usage - value. They are all declared in include/linux/res_counter.h. - - - -3. Analyzing the resource counter registrations - - a. If the failcnt value constantly grows, this means that the counter's - limit is too tight. Either the group is misbehaving and consumes too - many resources, or the configuration is not suitable for the group - and the limit should be increased. - - b. The max_usage value can be used to quickly tune the group. One may - set the limits to maximal values and either load the container with - a common pattern or leave one for a while. After this the max_usage - value shows the amount of memory the container would require during - its common activity. - - Setting the limit a bit above this value gives a pretty good - configuration that works in most of the cases. - - c. If the max_usage is much less than the limit, but the failcnt value - is growing, then the group tries to allocate a big chunk of resource - at once. - - d. If the max_usage is much less than the limit, but the failcnt value - is 0, then this group is given too high limit, that it does not - require. It is better to lower the limit a bit leaving more resource - for other groups. - - - -4. Communication with the control groups subsystem (cgroups) - -All the resource controllers that are using cgroups and resource counters -should provide files (in the cgroup filesystem) to work with the resource -counter fields. They are recommended to adhere to the following rules: - - a. File names - - Field name File name - --------------------------------------------------- - usage usage_in_ - max_usage max_usage_in_ - limit limit_in_ - failcnt failcnt - lock no file :) - - b. Reading from file should show the corresponding field value in the - appropriate format. - - c. Writing to file - - Field Expected behavior - ---------------------------------- - usage prohibited - max_usage reset to usage - limit set the limit - failcnt reset to zero - - - -5. Usage example - - a. Declare a task group (take a look at cgroups subsystem for this) and - fold a res_counter into it - - struct my_group { - struct res_counter res; - - - } - - b. Put hooks in resource allocation/release paths - - int alloc_something(...) - { - if (res_counter_charge(res_counter_ptr, amount) < 0) - return -ENOMEM; - - - } - - void release_something(...) - { - res_counter_uncharge(res_counter_ptr, amount); - - - } - - In order to keep the usage value self-consistent, both the - "res_counter_ptr" and the "amount" in release_something() should be - the same as they were in the alloc_something() when the releasing - resource was allocated. - - c. Provide the way to read res_counter values and set them (the cgroups - still can help with it). - - c. Compile and run :) diff --git a/trunk/Documentation/cpu-freq/user-guide.txt b/trunk/Documentation/cpu-freq/user-guide.txt index 6c442d8426b5..af3b925ece08 100644 --- a/trunk/Documentation/cpu-freq/user-guide.txt +++ b/trunk/Documentation/cpu-freq/user-guide.txt @@ -154,11 +154,6 @@ scaling_governor, and by "echoing" the name of another that some governors won't load - they only work on some specific architectures or processors. - -cpuinfo_cur_freq : Current speed of the CPU, in KHz. - -scaling_available_frequencies : List of available frequencies, in KHz. - scaling_min_freq and scaling_max_freq show the current "policy limits" (in kHz). By echoing new values into these @@ -167,15 +162,6 @@ scaling_max_freq show the current "policy limits" (in first set scaling_max_freq, then scaling_min_freq. -affected_cpus : List of CPUs that require software coordination - of frequency. - -related_cpus : List of CPUs that need some sort of frequency - coordination, whether software or hardware. - -scaling_driver : Hardware driver for cpufreq. - -scaling_cur_freq : Current frequency of the CPU, in KHz. If you have selected the "userspace" governor which allows you to set the CPU operating frequency to a specific value, you can read out diff --git a/trunk/Documentation/cpusets.txt b/trunk/Documentation/cpusets.txt index fb7b361e6eea..aa854b9b18cd 100644 --- a/trunk/Documentation/cpusets.txt +++ b/trunk/Documentation/cpusets.txt @@ -171,7 +171,6 @@ files describing that cpuset: - memory_migrate flag: if set, move pages to cpusets nodes - cpu_exclusive flag: is cpu placement exclusive? - mem_exclusive flag: is memory placement exclusive? - - mem_hardwall flag: is memory allocation hardwalled - memory_pressure: measure of how much paging pressure in cpuset In addition, the root cpuset only has the following file: @@ -223,18 +222,17 @@ If a cpuset is cpu or mem exclusive, no other cpuset, other than a direct ancestor or descendent, may share any of the same CPUs or Memory Nodes. -A cpuset that is mem_exclusive *or* mem_hardwall is "hardwalled", -i.e. it restricts kernel allocations for page, buffer and other data -commonly shared by the kernel across multiple users. All cpusets, -whether hardwalled or not, restrict allocations of memory for user -space. This enables configuring a system so that several independent -jobs can share common kernel data, such as file system pages, while -isolating each job's user allocation in its own cpuset. To do this, -construct a large mem_exclusive cpuset to hold all the jobs, and -construct child, non-mem_exclusive cpusets for each individual job. -Only a small amount of typical kernel memory, such as requests from -interrupt handlers, is allowed to be taken outside even a -mem_exclusive cpuset. +A cpuset that is mem_exclusive restricts kernel allocations for +page, buffer and other data commonly shared by the kernel across +multiple users. All cpusets, whether mem_exclusive or not, restrict +allocations of memory for user space. This enables configuring a +system so that several independent jobs can share common kernel data, +such as file system pages, while isolating each jobs user allocation in +its own cpuset. To do this, construct a large mem_exclusive cpuset to +hold all the jobs, and construct child, non-mem_exclusive cpusets for +each individual job. Only a small amount of typical kernel memory, +such as requests from interrupt handlers, is allowed to be taken +outside even a mem_exclusive cpuset. 1.5 What is memory_pressure ? @@ -709,7 +707,7 @@ Now you want to do something with this cpuset. In this directory you can find several files: # ls -cpus cpu_exclusive mems mem_exclusive mem_hardwall tasks +cpus cpu_exclusive mems mem_exclusive tasks Reading them will give you information about the state of this cpuset: the CPUs and Memory Nodes it can use, the processes that are using diff --git a/trunk/Documentation/i2c/writing-clients b/trunk/Documentation/i2c/writing-clients index ee75cbace28d..bfb0a5520817 100644 --- a/trunk/Documentation/i2c/writing-clients +++ b/trunk/Documentation/i2c/writing-clients @@ -164,8 +164,7 @@ I2C device drivers using this binding model work just like any other kind of driver in Linux: they provide a probe() method to bind to those devices, and a remove() method to unbind. - static int foo_probe(struct i2c_client *client, - const struct i2c_device_id *id); + static int foo_probe(struct i2c_client *client); static int foo_remove(struct i2c_client *client); Remember that the i2c_driver does not create those client handles. The diff --git a/trunk/Documentation/i386/boot.txt b/trunk/Documentation/i386/boot.txt index 95ad15c3b01f..0fac3465f2e3 100644 --- a/trunk/Documentation/i386/boot.txt +++ b/trunk/Documentation/i386/boot.txt @@ -40,17 +40,9 @@ Protocol 2.05: (Kernel 2.6.20) Make protected mode kernel relocatable. Introduce relocatable_kernel and kernel_alignment fields. Protocol 2.06: (Kernel 2.6.22) Added a field that contains the size of - the boot command line. + the boot command line -Protocol 2.07: (Kernel 2.6.24) Added paravirtualised boot protocol. - Introduced hardware_subarch and hardware_subarch_data - and KEEP_SEGMENTS flag in load_flags. - -Protocol 2.08: (Kernel 2.6.26) Added crc32 checksum and ELF format - payload. Introduced payload_offset and payload length - fields to aid in locating the payload. - -Protocol 2.09: (Kernel 2.6.26) Added a field of 64-bit physical +Protocol 2.09: (kernel 2.6.26) Added a field of 64-bit physical pointer to single linked list of struct setup_data. **** MEMORY LAYOUT diff --git a/trunk/Documentation/kernel-parameters.txt b/trunk/Documentation/kernel-parameters.txt index 3ce193f86565..e5f3d918316f 100644 --- a/trunk/Documentation/kernel-parameters.txt +++ b/trunk/Documentation/kernel-parameters.txt @@ -627,7 +627,8 @@ and is between 256 and 4096 characters. It is defined in the file eata= [HW,SCSI] edd= [EDD] - Format: {"off" | "on" | "skip[mbr]"} + Format: {"of[f]" | "sk[ipmbr]"} + See comment in arch/i386/boot/edd.S eisa_irq_edge= [PARISC,HW] See header of drivers/parisc/eisa.c. @@ -1388,13 +1389,6 @@ and is between 256 and 4096 characters. It is defined in the file nr_uarts= [SERIAL] maximum number of UARTs to be registered. - olpc_ec_timeout= [OLPC] ms delay when issuing EC commands - Rather than timing out after 20 ms if an EC - command is not properly ACKed, override the length - of the timeout. We have interrupts disabled while - waiting for the ACK, so if this is set too high - interrupts *may* be lost! - opl3= [HW,OSS] Format: diff --git a/trunk/Documentation/keys-request-key.txt b/trunk/Documentation/keys-request-key.txt index 09b55e461740..266955d23ee6 100644 --- a/trunk/Documentation/keys-request-key.txt +++ b/trunk/Documentation/keys-request-key.txt @@ -11,29 +11,26 @@ request_key*(): struct key *request_key(const struct key_type *type, const char *description, - const char *callout_info); + const char *callout_string); or: struct key *request_key_with_auxdata(const struct key_type *type, const char *description, - const char *callout_info, - size_t callout_len, + const char *callout_string, void *aux); or: struct key *request_key_async(const struct key_type *type, const char *description, - const char *callout_info, - size_t callout_len); + const char *callout_string); or: struct key *request_key_async_with_auxdata(const struct key_type *type, const char *description, - const char *callout_info, - size_t callout_len, + const char *callout_string, void *aux); Or by userspace invoking the request_key system call: diff --git a/trunk/Documentation/keys.txt b/trunk/Documentation/keys.txt index d5c7a57d1700..51652d39e61c 100644 --- a/trunk/Documentation/keys.txt +++ b/trunk/Documentation/keys.txt @@ -170,8 +170,7 @@ The key service provides a number of features besides keys: amount of description and payload space that can be consumed. The user can view information on this and other statistics through procfs - files. The root user may also alter the quota limits through sysctl files - (see the section "New procfs files"). + files. Process-specific and thread-specific keyrings are not counted towards a user's quota. @@ -330,27 +329,6 @@ about the status of the key service: / Key size quota -Four new sysctl files have been added also for the purpose of controlling the -quota limits on keys: - - (*) /proc/sys/kernel/keys/root_maxkeys - /proc/sys/kernel/keys/root_maxbytes - - These files hold the maximum number of keys that root may have and the - maximum total number of bytes of data that root may have stored in those - keys. - - (*) /proc/sys/kernel/keys/maxkeys - /proc/sys/kernel/keys/maxbytes - - These files hold the maximum number of keys that each non-root user may - have and the maximum total number of bytes of data that each of those - users may have stored in their keys. - -Root may alter these by writing each new limit as a decimal number string to -the appropriate file. - - =============================== USERSPACE SYSTEM CALL INTERFACE =============================== @@ -733,27 +711,6 @@ The keyctl syscall functions are: The assumed authoritative key is inherited across fork and exec. - (*) Get the LSM security context attached to a key. - - long keyctl(KEYCTL_GET_SECURITY, key_serial_t key, char *buffer, - size_t buflen) - - This function returns a string that represents the LSM security context - attached to a key in the buffer provided. - - Unless there's an error, it always returns the amount of data it could - produce, even if that's too big for the buffer, but it won't copy more - than requested to userspace. If the buffer pointer is NULL then no copy - will take place. - - A NUL character is included at the end of the string if the buffer is - sufficiently big. This is included in the returned count. If no LSM is - in force then an empty string will be returned. - - A process must have view permission on the key for this function to be - successful. - - =============== KERNEL SERVICES =============== @@ -814,7 +771,7 @@ payload contents" for more information. struct key *request_key(const struct key_type *type, const char *description, - const char *callout_info); + const char *callout_string); This is used to request a key or keyring with a description that matches the description specified according to the key type's match function. This @@ -836,28 +793,24 @@ payload contents" for more information. struct key *request_key_with_auxdata(const struct key_type *type, const char *description, - const void *callout_info, - size_t callout_len, + const char *callout_string, void *aux); This is identical to request_key(), except that the auxiliary data is - passed to the key_type->request_key() op if it exists, and the callout_info - is a blob of length callout_len, if given (the length may be 0). + passed to the key_type->request_key() op if it exists. (*) A key can be requested asynchronously by calling one of: struct key *request_key_async(const struct key_type *type, const char *description, - const void *callout_info, - size_t callout_len); + const char *callout_string); or: struct key *request_key_async_with_auxdata(const struct key_type *type, const char *description, - const char *callout_info, - size_t callout_len, + const char *callout_string, void *aux); which are asynchronous equivalents of request_key() and diff --git a/trunk/Documentation/oops-tracing.txt b/trunk/Documentation/oops-tracing.txt index b152e81da592..7f60dfe642ca 100644 --- a/trunk/Documentation/oops-tracing.txt +++ b/trunk/Documentation/oops-tracing.txt @@ -253,10 +253,6 @@ characters, each representing a particular tainted value. 8: 'D' if the kernel has died recently, i.e. there was an OOPS or BUG. - 9: 'A' if the ACPI table has been overridden. - - 10: 'W' if a warning has previously been issued by the kernel. - The primary reason for the 'Tainted: ' string is to tell kernel debuggers if this is a clean kernel or if anything unusual has occurred. Tainting is permanent: even if an offending module is diff --git a/trunk/Documentation/sound/alsa/ALSA-Configuration.txt b/trunk/Documentation/sound/alsa/ALSA-Configuration.txt index 0bbee38acd26..fd4c32a031c9 100644 --- a/trunk/Documentation/sound/alsa/ALSA-Configuration.txt +++ b/trunk/Documentation/sound/alsa/ALSA-Configuration.txt @@ -795,7 +795,6 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. lg-lw LG LW20/LW25 laptop tcl TCL S700 clevo Clevo laptops (m520G, m665n) - medion Medion Rim 2150 test for testing/debugging purpose, almost all controls can be adjusted. Appearing only when compiled with $CONFIG_SND_DEBUG=y diff --git a/trunk/Documentation/sysrq.txt b/trunk/Documentation/sysrq.txt index 5ce0952aa065..10c8f6922ef4 100644 --- a/trunk/Documentation/sysrq.txt +++ b/trunk/Documentation/sysrq.txt @@ -85,8 +85,6 @@ On all - write a character to /proc/sysrq-trigger. e.g.: 'k' - Secure Access Key (SAK) Kills all programs on the current virtual console. NOTE: See important comments below in SAK section. -'l' - Shows a stack backtrace for all active CPUs. - 'm' - Will dump current memory info to your console. 'n' - Used to make RT tasks nice-able diff --git a/trunk/Documentation/video4linux/CARDLIST.saa7134 b/trunk/Documentation/video4linux/CARDLIST.saa7134 index 67937df1e974..44d84dd15ad6 100644 --- a/trunk/Documentation/video4linux/CARDLIST.saa7134 +++ b/trunk/Documentation/video4linux/CARDLIST.saa7134 @@ -128,7 +128,7 @@ 127 -> Beholder BeholdTV 507 FM/RDS / BeholdTV 509 FM [0000:5071,0000:507B,5ace:5070,5ace:5090] 128 -> Beholder BeholdTV Columbus TVFM [0000:5201] 129 -> Beholder BeholdTV 607 / BeholdTV 609 [5ace:6070,5ace:6071,5ace:6072,5ace:6073,5ace:6090,5ace:6091,5ace:6092,5ace:6093] -130 -> Beholder BeholdTV M6 / BeholdTV M6 Extra [5ace:6190,5ace:6193,5ace:6191] +130 -> Beholder BeholdTV M6 / BeholdTV M6 Extra [5ace:6190,5ace:6193] 131 -> Twinhan Hybrid DTV-DVB 3056 PCI [1822:0022] 132 -> Genius TVGO AM11MCE 133 -> NXP Snake DVB-S reference design @@ -140,4 +140,3 @@ 139 -> Compro VideoMate T750 [185b:c900] 140 -> Avermedia DVB-S Pro A700 [1461:a7a1] 141 -> Avermedia DVB-S Hybrid+FM A700 [1461:a7a2] -142 -> Beholder BeholdTV H6 [5ace:6290] diff --git a/trunk/Documentation/video4linux/cx18.txt b/trunk/Documentation/video4linux/cx18.txt deleted file mode 100644 index 077d56ec3f3d..000000000000 --- a/trunk/Documentation/video4linux/cx18.txt +++ /dev/null @@ -1,34 +0,0 @@ -Some notes regarding the cx18 driver for the Conexant CX23418 MPEG -encoder chip: - -1) The only hardware currently supported is the Hauppauge HVR-1600. - -2) Some people have problems getting the i2c bus to work. Cause unknown. - The symptom is that the eeprom cannot be read and the card is - unusable. - -3) The audio from the analog tuner is mono only. Probably caused by - incorrect audio register information in the datasheet. We are - waiting for updated information from Conexant. - -4) VBI (raw or sliced) has not yet been implemented. - -5) MPEG indexing is not yet implemented. - -6) The driver is still a bit rough around the edges, this should - improve over time. - - -Firmware: - -The firmware needs to be extracted from the Windows Hauppauge HVR-1600 -driver, available here: - -http://hauppauge.lightpath.net/software/install_cd/hauppauge_cd_3.4d1.zip - -Unzip, then copy the following files to the firmware directory -and rename them as follows: - -Drivers/Driver18/hcw18apu.rom -> v4l-cx23418-apu.fw -Drivers/Driver18/hcw18enc.rom -> v4l-cx23418-cpu.fw -Drivers/Driver18/hcw18mlC.rom -> v4l-cx23418-dig.fw diff --git a/trunk/MAINTAINERS b/trunk/MAINTAINERS index bca09ed77029..c1dd1ae7b133 100644 --- a/trunk/MAINTAINERS +++ b/trunk/MAINTAINERS @@ -752,13 +752,11 @@ W: http://atmelwlandriver.sourceforge.net/ S: Maintained AUDIT SUBSYSTEM -P: Al Viro -M: viro@zeniv.linux.org.uk -P: Eric Paris -M: eparis@redhat.com +P: David Woodhouse +M: dwmw2@infradead.org L: linux-audit@redhat.com (subscribers-only) W: http://people.redhat.com/sgrubb/audit/ -T: git git.kernel.org/pub/scm/linux/kernel/git/viro/audit-current.git +T: git kernel.org:/pub/scm/linux/kernel/git/dwmw2/audit-2.6.git S: Maintained AUXILIARY DISPLAY DRIVERS @@ -2696,7 +2694,7 @@ P: David Howells M: dhowells@redhat.com P: Koichi Yasutake M: yasutake.koichi@jp.panasonic.com -L: linux-am33-list@redhat.com (moderated for non-subscribers) +L: linux-am33-list@redhat.com W: ftp://ftp.redhat.com/pub/redhat/gnupro/AM33/ S: Maintained @@ -3116,7 +3114,6 @@ P: Jesse Barnes M: jbarnes@virtuousgeek.org L: linux-kernel@vger.kernel.org L: linux-pci@atrey.karlin.mff.cuni.cz -T: git kernel.org:/pub/scm/linux/kernel/git/jbarnes/pci-2.6.git S: Supported PCI HOTPLUG CORE diff --git a/trunk/arch/Kconfig b/trunk/arch/Kconfig index 3ea332b009e5..694c9af520bb 100644 --- a/trunk/arch/Kconfig +++ b/trunk/arch/Kconfig @@ -36,6 +36,3 @@ config HAVE_KPROBES config HAVE_KRETPROBES def_bool n - -config HAVE_DMA_ATTRS - def_bool n diff --git a/trunk/arch/alpha/kernel/asm-offsets.c b/trunk/arch/alpha/kernel/asm-offsets.c index 4b18cd94d59d..6c56c754a0b5 100644 --- a/trunk/arch/alpha/kernel/asm-offsets.c +++ b/trunk/arch/alpha/kernel/asm-offsets.c @@ -8,9 +8,13 @@ #include #include #include -#include #include +#define DEFINE(sym, val) \ + asm volatile("\n->" #sym " %0 " #val : : "i" (val)) + +#define BLANK() asm volatile("\n->" : : ) + void foo(void) { DEFINE(TI_TASK, offsetof(struct thread_info, task)); diff --git a/trunk/arch/alpha/kernel/pci.c b/trunk/arch/alpha/kernel/pci.c index 36ab22a7ea12..baf57563b14c 100644 --- a/trunk/arch/alpha/kernel/pci.c +++ b/trunk/arch/alpha/kernel/pci.c @@ -514,8 +514,8 @@ sys_pciconfig_iobase(long which, unsigned long bus, unsigned long dfn) void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen) { - resource_size_t start = pci_resource_start(dev, bar); - resource_size_t len = pci_resource_len(dev, bar); + unsigned long start = pci_resource_start(dev, bar); + unsigned long len = pci_resource_len(dev, bar); unsigned long flags = pci_resource_flags(dev, bar); if (!len || !start) diff --git a/trunk/arch/arm/configs/am200epdkit_defconfig b/trunk/arch/arm/configs/am200epdkit_defconfig index 5e68420f4680..dc030cfe5009 100644 --- a/trunk/arch/arm/configs/am200epdkit_defconfig +++ b/trunk/arch/arm/configs/am200epdkit_defconfig @@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit -# Linux kernel version: 2.6.25 -# Sun Apr 20 00:29:49 2008 +# Linux kernel version: 2.6.25-rc3 +# Sun Mar 9 06:33:33 2008 # CONFIG_ARM=y CONFIG_SYS_SUPPORTS_APM_EMULATION=y @@ -51,8 +51,7 @@ CONFIG_FAIR_GROUP_SCHED=y # CONFIG_RT_GROUP_SCHED is not set CONFIG_USER_SCHED=y # CONFIG_CGROUP_SCHED is not set -CONFIG_SYSFS_DEPRECATED=y -CONFIG_SYSFS_DEPRECATED_V2=y +# CONFIG_SYSFS_DEPRECATED is not set # CONFIG_RELAY is not set # CONFIG_NAMESPACES is not set # CONFIG_BLK_DEV_INITRD is not set @@ -86,7 +85,6 @@ CONFIG_SLAB=y CONFIG_HAVE_OPROFILE=y # CONFIG_KPROBES is not set CONFIG_HAVE_KPROBES=y -CONFIG_HAVE_KRETPROBES=y CONFIG_PROC_PAGE_MONITOR=y CONFIG_SLABINFO=y CONFIG_RT_MUTEXES=y @@ -117,6 +115,7 @@ CONFIG_IOSCHED_NOOP=y CONFIG_DEFAULT_NOOP=y CONFIG_DEFAULT_IOSCHED="noop" CONFIG_CLASSIC_RCU=y +# CONFIG_PREEMPT_RCU is not set # # System Type @@ -321,6 +320,8 @@ CONFIG_TCP_CONG_CUBIC=y CONFIG_DEFAULT_TCP_CONG="cubic" # CONFIG_TCP_MD5SIG is not set # CONFIG_IPV6 is not set +# CONFIG_INET6_XFRM_TUNNEL is not set +# CONFIG_INET6_TUNNEL is not set # CONFIG_NETWORK_SECMARK is not set # CONFIG_NETFILTER is not set # CONFIG_IP_DCCP is not set @@ -382,6 +383,7 @@ CONFIG_IEEE80211=m CONFIG_IEEE80211_CRYPT_WEP=m # CONFIG_IEEE80211_CRYPT_CCMP is not set # CONFIG_IEEE80211_CRYPT_TKIP is not set +# CONFIG_IEEE80211_SOFTMAC is not set # CONFIG_RFKILL is not set # CONFIG_NET_9P is not set @@ -501,7 +503,7 @@ CONFIG_IDE_MAX_HWIFS=2 CONFIG_BLK_DEV_IDE=m # -# Please see Documentation/ide/ide.txt for help/info on IDE drives +# Please see Documentation/ide.txt for help/info on IDE drives # # CONFIG_BLK_DEV_IDE_SATA is not set CONFIG_BLK_DEV_IDEDISK=m @@ -516,9 +518,10 @@ CONFIG_IDE_PROC_FS=y # # IDE chipset support/bugfixes # +CONFIG_IDE_GENERIC=m # CONFIG_BLK_DEV_PLATFORM is not set # CONFIG_BLK_DEV_IDEDMA is not set -# CONFIG_BLK_DEV_HD_ONLY is not set +CONFIG_IDE_ARCH_OBSOLETE_INIT=y # CONFIG_BLK_DEV_HD is not set # @@ -559,7 +562,6 @@ CONFIG_NETDEV_10000=y # # CONFIG_WLAN_PRE80211 is not set # CONFIG_WLAN_80211 is not set -# CONFIG_IWLWIFI_LEDS is not set # CONFIG_NET_PCMCIA is not set # CONFIG_WAN is not set # CONFIG_PPP is not set @@ -705,8 +707,6 @@ CONFIG_SSB_POSSIBLE=y # # CONFIG_MFD_SM501 is not set # CONFIG_MFD_ASIC3 is not set -# CONFIG_HTC_EGPIO is not set -# CONFIG_HTC_PASIC3 is not set # # Multimedia devices @@ -745,7 +745,6 @@ CONFIG_FB_TILEBLITTING=y CONFIG_FB_PXA=y CONFIG_FB_PXA_PARAMETERS=y CONFIG_FB_MBX=m -# CONFIG_FB_METRONOME is not set CONFIG_FB_VIRTUAL=m # CONFIG_BACKLIGHT_LCD_SUPPORT is not set @@ -892,6 +891,7 @@ CONFIG_RTC_LIB=y # CONFIG_JFS_FS is not set # CONFIG_FS_POSIX_ACL is not set # CONFIG_XFS_FS is not set +# CONFIG_GFS2_FS is not set # CONFIG_OCFS2_FS is not set # CONFIG_DNOTIFY is not set CONFIG_INOTIFY=y diff --git a/trunk/arch/arm/kernel/asm-offsets.c b/trunk/arch/arm/kernel/asm-offsets.c index 4a881258bb17..0a0d2479274b 100644 --- a/trunk/arch/arm/kernel/asm-offsets.c +++ b/trunk/arch/arm/kernel/asm-offsets.c @@ -16,7 +16,6 @@ #include #include #include -#include /* * Make sure that the compiler and target are compatible. @@ -36,6 +35,13 @@ #error Known good compilers: 3.3 #endif +/* Use marker if you need to separate the values later */ + +#define DEFINE(sym, val) \ + asm volatile("\n->" #sym " %0 " #val : : "i" (val)) + +#define BLANK() asm volatile("\n->" : : ) + int main(void) { DEFINE(TSK_ACTIVE_MM, offsetof(struct task_struct, active_mm)); diff --git a/trunk/arch/arm/kernel/atags.c b/trunk/arch/arm/kernel/atags.c index 64c420805e6f..e2e934c38080 100644 --- a/trunk/arch/arm/kernel/atags.c +++ b/trunk/arch/arm/kernel/atags.c @@ -35,7 +35,7 @@ create_proc_entries(void) { struct proc_dir_entry* tags_entry; - tags_entry = create_proc_read_entry("atags", 0400, NULL, read_buffer, &tags_buffer); + tags_entry = create_proc_read_entry("atags", 0400, &proc_root, read_buffer, &tags_buffer); if (!tags_entry) return -ENOMEM; diff --git a/trunk/arch/arm/kernel/ecard.c b/trunk/arch/arm/kernel/ecard.c index a53c0aba5c14..f56d48c451ea 100644 --- a/trunk/arch/arm/kernel/ecard.c +++ b/trunk/arch/arm/kernel/ecard.c @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include @@ -724,14 +723,17 @@ unsigned int __ecard_address(ecard_t *ec, card_type_t type, card_speed_t speed) return address; } -static int ecard_prints(struct seq_file *m, ecard_t *ec) +static int ecard_prints(char *buffer, ecard_t *ec) { - seq_printf(m, " %d: %s ", ec->slot_no, ec->easi ? "EASI" : " "); + char *start = buffer; + + buffer += sprintf(buffer, " %d: %s ", ec->slot_no, + ec->easi ? "EASI" : " "); if (ec->cid.id == 0) { struct in_chunk_dir incd; - seq_printf(m, "[%04X:%04X] ", + buffer += sprintf(buffer, "[%04X:%04X] ", ec->cid.manufacturer, ec->cid.product); if (!ec->card_desc && ec->cid.cd && @@ -742,43 +744,43 @@ static int ecard_prints(struct seq_file *m, ecard_t *ec) strcpy((char *)ec->card_desc, incd.d.string); } - seq_printf(m, "%s\n", ec->card_desc ? ec->card_desc : "*unknown*"); + buffer += sprintf(buffer, "%s\n", ec->card_desc ? ec->card_desc : "*unknown*"); } else - seq_printf(m, "Simple card %d\n", ec->cid.id); + buffer += sprintf(buffer, "Simple card %d\n", ec->cid.id); - return 0; + return buffer - start; } -static int ecard_devices_proc_show(struct seq_file *m, void *v) +static int get_ecard_dev_info(char *buf, char **start, off_t pos, int count) { ecard_t *ec = cards; - - while (ec) { - ecard_prints(m, ec); + off_t at = 0; + int len, cnt; + + cnt = 0; + while (ec && count > cnt) { + len = ecard_prints(buf, ec); + at += len; + if (at >= pos) { + if (!*start) { + *start = buf + (pos - (at - len)); + cnt = at - pos; + } else + cnt += len; + buf += len; + } ec = ec->next; } - return 0; + return (count > cnt) ? cnt : count; } -static int ecard_devices_proc_open(struct inode *inode, struct file *file) -{ - return single_open(file, ecard_devices_proc_show, NULL); -} - -static const struct file_operations bus_ecard_proc_fops = { - .owner = THIS_MODULE, - .open = ecard_devices_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - static struct proc_dir_entry *proc_bus_ecard_dir = NULL; static void ecard_proc_init(void) { - proc_bus_ecard_dir = proc_mkdir("bus/ecard", NULL); - proc_create("devices", 0, proc_bus_ecard_dir, &bus_ecard_proc_fops); + proc_bus_ecard_dir = proc_mkdir("ecard", proc_bus); + create_proc_info_entry("devices", 0, proc_bus_ecard_dir, + get_ecard_dev_info); } #define ec_set_resource(ec,nr,st,sz) \ diff --git a/trunk/arch/arm/kernel/kprobes-decode.c b/trunk/arch/arm/kernel/kprobes-decode.c index b4565bb133c1..d51bc8b60557 100644 --- a/trunk/arch/arm/kernel/kprobes-decode.c +++ b/trunk/arch/arm/kernel/kprobes-decode.c @@ -1176,7 +1176,7 @@ space_cccc_001x(kprobe_opcode_t insn, struct arch_specific_insn *asi) * *S (bit 20) updates condition codes * ADC/SBC/RSC reads the C flag */ - insn &= 0xfff00fff; /* Rn = r0, Rd = r0 */ + insn &= 0xfff00ff0; /* Rn = r0, Rd = r0 */ asi->insn[0] = insn; asi->insn_handler = (insn & (1 << 20)) ? /* S-bit */ emulate_alu_imm_rwflags : emulate_alu_imm_rflags; diff --git a/trunk/arch/arm/kernel/kprobes.c b/trunk/arch/arm/kernel/kprobes.c index 5593dd207216..13e371aad879 100644 --- a/trunk/arch/arm/kernel/kprobes.c +++ b/trunk/arch/arm/kernel/kprobes.c @@ -66,7 +66,7 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p) return -ENOMEM; for (is = 0; is < MAX_INSN_SIZE; ++is) p->ainsn.insn[is] = tmp_insn[is]; - flush_insns(p->ainsn.insn, MAX_INSN_SIZE); + flush_insns(&p->ainsn.insn, MAX_INSN_SIZE); break; case INSN_GOOD_NO_SLOT: /* instruction doesn't need insn slot */ diff --git a/trunk/arch/arm/mach-at91/at91cap9_devices.c b/trunk/arch/arm/mach-at91/at91cap9_devices.c index be526746e01e..f1a80d74a4b6 100644 --- a/trunk/arch/arm/mach-at91/at91cap9_devices.c +++ b/trunk/arch/arm/mach-at91/at91cap9_devices.c @@ -246,7 +246,7 @@ void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) } mmc0_data = *data; - at91_clock_associate("mci0_clk", &at91cap9_mmc0_device.dev, "mci_clk"); + at91_clock_associate("mci0_clk", &at91cap9_mmc1_device.dev, "mci_clk"); platform_device_register(&at91cap9_mmc0_device); } else { /* MCI1 */ /* CLK */ diff --git a/trunk/arch/arm/mach-at91/at91sam9263_devices.c b/trunk/arch/arm/mach-at91/at91sam9263_devices.c index 719667e25c98..b6454c525962 100644 --- a/trunk/arch/arm/mach-at91/at91sam9263_devices.c +++ b/trunk/arch/arm/mach-at91/at91sam9263_devices.c @@ -308,7 +308,7 @@ void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) } mmc0_data = *data; - at91_clock_associate("mci0_clk", &at91sam9263_mmc0_device.dev, "mci_clk"); + at91_clock_associate("mci0_clk", &at91sam9263_mmc1_device.dev, "mci_clk"); platform_device_register(&at91sam9263_mmc0_device); } else { /* MCI1 */ /* CLK */ diff --git a/trunk/arch/arm/mach-at91/board-csb337.c b/trunk/arch/arm/mach-at91/board-csb337.c index 81f1ebb4e964..26fea4dcc3a0 100644 --- a/trunk/arch/arm/mach-at91/board-csb337.c +++ b/trunk/arch/arm/mach-at91/board-csb337.c @@ -79,7 +79,8 @@ static struct at91_udc_data __initdata csb337_udc_data = { static struct i2c_board_info __initdata csb337_i2c_devices[] = { { - I2C_BOARD_INFO("ds1307", 0x68), + I2C_BOARD_INFO("rtc-ds1307", 0x68), + .type = "ds1307", }, }; diff --git a/trunk/arch/arm/mach-at91/board-dk.c b/trunk/arch/arm/mach-at91/board-dk.c index c1a813c7169b..0a897efeba8e 100644 --- a/trunk/arch/arm/mach-at91/board-dk.c +++ b/trunk/arch/arm/mach-at91/board-dk.c @@ -132,7 +132,8 @@ static struct i2c_board_info __initdata dk_i2c_devices[] = { I2C_BOARD_INFO("x9429", 0x28), }, { - I2C_BOARD_INFO("24c1024", 0x50), + I2C_BOARD_INFO("at24c", 0x50), + .type = "24c1024", } }; diff --git a/trunk/arch/arm/mach-at91/board-eb9200.c b/trunk/arch/arm/mach-at91/board-eb9200.c index af1a1d8ecc30..b7b79bb9d6c4 100644 --- a/trunk/arch/arm/mach-at91/board-eb9200.c +++ b/trunk/arch/arm/mach-at91/board-eb9200.c @@ -93,7 +93,8 @@ static struct at91_mmc_data __initdata eb9200_mmc_data = { static struct i2c_board_info __initdata eb9200_i2c_devices[] = { { - I2C_BOARD_INFO("24c512", 0x50), + I2C_BOARD_INFO("at24c", 0x50), + .type = "24c512", }, }; diff --git a/trunk/arch/arm/mach-at91/pm.c b/trunk/arch/arm/mach-at91/pm.c index aa863c157708..39733b6992aa 100644 --- a/trunk/arch/arm/mach-at91/pm.c +++ b/trunk/arch/arm/mach-at91/pm.c @@ -61,15 +61,6 @@ static inline void sdram_selfrefresh_enable(void) #else #include -#ifdef CONFIG_ARCH_AT91SAM9263 -/* - * FIXME either or both the SDRAM controllers (EB0, EB1) might be in use; - * handle those cases both here and in the Suspend-To-RAM support. - */ -#define AT91_SDRAMC AT91_SDRAMC0 -#warning Assuming EB1 SDRAM controller is *NOT* used -#endif - static u32 saved_lpr; static inline void sdram_selfrefresh_enable(void) @@ -84,6 +75,11 @@ static inline void sdram_selfrefresh_enable(void) #define sdram_selfrefresh_disable() at91_sys_write(AT91_SDRAMC_LPR, saved_lpr) +/* + * FIXME: The AT91SAM9263 has a second EBI controller which may have + * additional SDRAM. pm_slowclock.S will require a similar fix. + */ + #endif diff --git a/trunk/arch/arm/mach-davinci/clock.c b/trunk/arch/arm/mach-davinci/clock.c index c6b94f60e0b2..4143828a9684 100644 --- a/trunk/arch/arm/mach-davinci/clock.c +++ b/trunk/arch/arm/mach-davinci/clock.c @@ -311,7 +311,11 @@ static const struct file_operations proc_davinci_ck_operations = { static int __init davinci_ck_proc_init(void) { - proc_create("davinci_clocks", 0, NULL, &proc_davinci_ck_operations); + struct proc_dir_entry *entry; + + entry = create_proc_entry("davinci_clocks", 0, NULL); + if (entry) + entry->proc_fops = &proc_davinci_ck_operations; return 0; } diff --git a/trunk/arch/arm/mach-iop32x/em7210.c b/trunk/arch/arm/mach-iop32x/em7210.c index 4877597c8758..c947152f9a3c 100644 --- a/trunk/arch/arm/mach-iop32x/em7210.c +++ b/trunk/arch/arm/mach-iop32x/em7210.c @@ -50,7 +50,8 @@ static struct sys_timer em7210_timer = { */ static struct i2c_board_info __initdata em7210_i2c_devices[] = { { - I2C_BOARD_INFO("rs5c372a", 0x32), + I2C_BOARD_INFO("rtc-rs5c372", 0x32), + .type = "rs5c372a", }, }; diff --git a/trunk/arch/arm/mach-iop32x/glantank.c b/trunk/arch/arm/mach-iop32x/glantank.c index d4fca75ce542..d2a7b04f1cb0 100644 --- a/trunk/arch/arm/mach-iop32x/glantank.c +++ b/trunk/arch/arm/mach-iop32x/glantank.c @@ -176,10 +176,12 @@ static struct f75375s_platform_data glantank_f75375s = { static struct i2c_board_info __initdata glantank_i2c_devices[] = { { - I2C_BOARD_INFO("rs5c372a", 0x32), + I2C_BOARD_INFO("rtc-rs5c372", 0x32), + .type = "rs5c372a", }, { I2C_BOARD_INFO("f75375", 0x2e), + .type = "f75375", .platform_data = &glantank_f75375s, }, }; diff --git a/trunk/arch/arm/mach-iop32x/n2100.c b/trunk/arch/arm/mach-iop32x/n2100.c index 2741063bf361..bc91d6e66bc4 100644 --- a/trunk/arch/arm/mach-iop32x/n2100.c +++ b/trunk/arch/arm/mach-iop32x/n2100.c @@ -208,10 +208,12 @@ static struct f75375s_platform_data n2100_f75375s = { static struct i2c_board_info __initdata n2100_i2c_devices[] = { { - I2C_BOARD_INFO("rs5c372b", 0x32), + I2C_BOARD_INFO("rtc-rs5c372", 0x32), + .type = "rs5c372b", }, { I2C_BOARD_INFO("f75375", 0x2e), + .type = "f75375", .platform_data = &n2100_f75375s, }, }; diff --git a/trunk/arch/arm/mach-ixp4xx/dsmg600-setup.c b/trunk/arch/arm/mach-ixp4xx/dsmg600-setup.c index a51bfa6978b6..8cb07437a807 100644 --- a/trunk/arch/arm/mach-ixp4xx/dsmg600-setup.c +++ b/trunk/arch/arm/mach-ixp4xx/dsmg600-setup.c @@ -65,7 +65,7 @@ static struct platform_device dsmg600_i2c_gpio = { static struct i2c_board_info __initdata dsmg600_i2c_board_info [] = { { - I2C_BOARD_INFO("pcf8563", 0x51), + I2C_BOARD_INFO("rtc-pcf8563", 0x51), }, }; diff --git a/trunk/arch/arm/mach-ixp4xx/nas100d-setup.c b/trunk/arch/arm/mach-ixp4xx/nas100d-setup.c index 84b5e62a9c0a..159e1c4f1eda 100644 --- a/trunk/arch/arm/mach-ixp4xx/nas100d-setup.c +++ b/trunk/arch/arm/mach-ixp4xx/nas100d-setup.c @@ -54,7 +54,7 @@ static struct platform_device nas100d_flash = { static struct i2c_board_info __initdata nas100d_i2c_board_info [] = { { - I2C_BOARD_INFO("pcf8563", 0x51), + I2C_BOARD_INFO("rtc-pcf8563", 0x51), }, }; diff --git a/trunk/arch/arm/mach-ixp4xx/nslu2-setup.c b/trunk/arch/arm/mach-ixp4xx/nslu2-setup.c index a48a6655b887..d9a182895a0f 100644 --- a/trunk/arch/arm/mach-ixp4xx/nslu2-setup.c +++ b/trunk/arch/arm/mach-ixp4xx/nslu2-setup.c @@ -57,7 +57,7 @@ static struct i2c_gpio_platform_data nslu2_i2c_gpio_data = { static struct i2c_board_info __initdata nslu2_i2c_board_info [] = { { - I2C_BOARD_INFO("x1205", 0x6f), + I2C_BOARD_INFO("rtc-x1205", 0x6f), }, }; diff --git a/trunk/arch/arm/mach-omap1/board-h2.c b/trunk/arch/arm/mach-omap1/board-h2.c index 4b444fdaafea..507987720015 100644 --- a/trunk/arch/arm/mach-omap1/board-h2.c +++ b/trunk/arch/arm/mach-omap1/board-h2.c @@ -351,9 +351,11 @@ static void __init h2_init_smc91x(void) static struct i2c_board_info __initdata h2_i2c_board_info[] = { { I2C_BOARD_INFO("tps65010", 0x48), + .type = "tps65010", .irq = OMAP_GPIO_IRQ(58), }, { I2C_BOARD_INFO("isp1301_omap", 0x2d), + .type = "isp1301_omap", .irq = OMAP_GPIO_IRQ(2), }, }; diff --git a/trunk/arch/arm/mach-omap1/board-h3.c b/trunk/arch/arm/mach-omap1/board-h3.c index 7fbaa8d648cd..c3ef1ee5f77b 100644 --- a/trunk/arch/arm/mach-omap1/board-h3.c +++ b/trunk/arch/arm/mach-omap1/board-h3.c @@ -473,7 +473,8 @@ static struct omap_board_config_kernel h3_config[] __initdata = { static struct i2c_board_info __initdata h3_i2c_board_info[] = { { - I2C_BOARD_INFO("tps65013", 0x48), + I2C_BOARD_INFO("tps65010", 0x48), + .type = "tps65013", /* .irq = OMAP_GPIO_IRQ(??), */ }, }; diff --git a/trunk/arch/arm/mach-omap1/board-osk.c b/trunk/arch/arm/mach-omap1/board-osk.c index a66505f58b15..4f9baba7d893 100644 --- a/trunk/arch/arm/mach-omap1/board-osk.c +++ b/trunk/arch/arm/mach-omap1/board-osk.c @@ -254,6 +254,7 @@ static struct tps65010_board tps_board = { static struct i2c_board_info __initdata osk_i2c_board_info[] = { { I2C_BOARD_INFO("tps65010", 0x48), + .type = "tps65010", .irq = OMAP_GPIO_IRQ(OMAP_MPUIO(1)), .platform_data = &tps_board, diff --git a/trunk/arch/arm/mach-orion5x/addr-map.c b/trunk/arch/arm/mach-orion5x/addr-map.c index 9608503d67f5..6b179371e0a2 100644 --- a/trunk/arch/arm/mach-orion5x/addr-map.c +++ b/trunk/arch/arm/mach-orion5x/addr-map.c @@ -19,14 +19,14 @@ /* * The Orion has fully programable address map. There's a separate address - * map for each of the device _master_ interfaces, e.g. CPU, PCI, PCIe, USB, + * map for each of the device _master_ interfaces, e.g. CPU, PCI, PCIE, USB, * Gigabit Ethernet, DMA/XOR engines, etc. Each interface has its own * address decode windows that allow it to access any of the Orion resources. * * CPU address decoding -- * Linux assumes that it is the boot loader that already setup the access to * DDR and internal registers. - * Setup access to PCI and PCIe IO/MEM space is issued by this file. + * Setup access to PCI and PCI-E IO/MEM space is issued by this file. * Setup access to various devices located on the device bus interface (e.g. * flashes, RTC, etc) should be issued by machine-setup.c according to * specific board population (by using orion5x_setup_*_win()). diff --git a/trunk/arch/arm/mach-orion5x/common.c b/trunk/arch/arm/mach-orion5x/common.c index 968deb58be01..439c7784af02 100644 --- a/trunk/arch/arm/mach-orion5x/common.c +++ b/trunk/arch/arm/mach-orion5x/common.c @@ -132,7 +132,7 @@ static struct platform_device orion5x_uart = { static struct resource orion5x_ehci0_resources[] = { { .start = ORION5X_USB0_PHYS_BASE, - .end = ORION5X_USB0_PHYS_BASE + SZ_4K - 1, + .end = ORION5X_USB0_PHYS_BASE + SZ_4K, .flags = IORESOURCE_MEM, }, { @@ -145,7 +145,7 @@ static struct resource orion5x_ehci0_resources[] = { static struct resource orion5x_ehci1_resources[] = { { .start = ORION5X_USB1_PHYS_BASE, - .end = ORION5X_USB1_PHYS_BASE + SZ_4K - 1, + .end = ORION5X_USB1_PHYS_BASE + SZ_4K, .flags = IORESOURCE_MEM, }, { @@ -317,7 +317,7 @@ struct sys_timer orion5x_timer = { ****************************************************************************/ /* - * Identify device ID and rev from PCIe configuration header space '0'. + * Identify device ID and rev from PCIE configuration header space '0'. */ static void __init orion5x_id(u32 *dev, u32 *rev, char **dev_name) { diff --git a/trunk/arch/arm/mach-orion5x/common.h b/trunk/arch/arm/mach-orion5x/common.h index 14adf8d1a54a..f4c4c9a72a7c 100644 --- a/trunk/arch/arm/mach-orion5x/common.h +++ b/trunk/arch/arm/mach-orion5x/common.h @@ -33,9 +33,10 @@ struct pci_sys_data; struct pci_bus; void orion5x_pcie_id(u32 *dev, u32 *rev); +int orion5x_pcie_local_bus_nr(void); +int orion5x_pci_local_bus_nr(void); int orion5x_pci_sys_setup(int nr, struct pci_sys_data *sys); struct pci_bus *orion5x_pci_sys_scan_bus(int nr, struct pci_sys_data *sys); -int orion5x_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin); /* * Valid GPIO pins according to MPP setup, used by machine-setup. diff --git a/trunk/arch/arm/mach-orion5x/db88f5281-setup.c b/trunk/arch/arm/mach-orion5x/db88f5281-setup.c index 44c64342dacb..872aed372327 100644 --- a/trunk/arch/arm/mach-orion5x/db88f5281-setup.c +++ b/trunk/arch/arm/mach-orion5x/db88f5281-setup.c @@ -241,17 +241,14 @@ void __init db88f5281_pci_preinit(void) static int __init db88f5281_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin) { - int irq; - /* - * Check for devices with hard-wired IRQs. + * PCIE IRQ is connected internally (not GPIO) */ - irq = orion5x_pci_map_irq(dev, slot, pin); - if (irq != -1) - return irq; + if (dev->bus->number == orion5x_pcie_local_bus_nr()) + return IRQ_ORION5X_PCIE0_INT; /* - * PCI IRQs are connected via GPIOs. + * PCI IRQs are connected via GPIOs */ switch (slot - DB88F5281_PCI_SLOT0_OFFS) { case 0: @@ -295,7 +292,9 @@ static struct mv643xx_eth_platform_data db88f5281_eth_data = { * RTC DS1339 on I2C bus ****************************************************************************/ static struct i2c_board_info __initdata db88f5281_i2c_rtc = { - I2C_BOARD_INFO("ds1339", 0x68), + .driver_name = "rtc-ds1307", + .type = "ds1339", + .addr = 0x68, }; /***************************************************************************** diff --git a/trunk/arch/arm/mach-orion5x/dns323-setup.c b/trunk/arch/arm/mach-orion5x/dns323-setup.c index f9430f5ca9a8..d67790ef236e 100644 --- a/trunk/arch/arm/mach-orion5x/dns323-setup.c +++ b/trunk/arch/arm/mach-orion5x/dns323-setup.c @@ -43,16 +43,11 @@ static int __init dns323_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin) { - int irq; + /* PCI-E */ + if (dev->bus->number == orion5x_pcie_local_bus_nr()) + return IRQ_ORION5X_PCIE0_INT; - /* - * Check for devices with hard-wired IRQs. - */ - irq = orion5x_pci_map_irq(dev, slot, pin); - if (irq != -1) - return irq; - - pr_err("%s: requested mapping for unknown device\n", __func__); + pr_err("%s: requested mapping for unknown bus\n", __func__); return -1; } @@ -225,16 +220,19 @@ static struct platform_device *dns323_plat_devices[] __initdata = { static struct i2c_board_info __initdata dns323_i2c_devices[] = { { I2C_BOARD_INFO("g760a", 0x3e), + .type = "g760a", }, #if 0 /* this entry requires the new-style driver model lm75 driver, * for the meantime "insmod lm75.ko force_lm75=0,0x48" is needed */ { - I2C_BOARD_INFO("g751", 0x48), + I2C_BOARD_INFO("lm75", 0x48), + .type = "g751", }, #endif { - I2C_BOARD_INFO("m41t80", 0x68), + I2C_BOARD_INFO("rtc-m41t80", 0x68), + .type = "m41t80", } }; @@ -255,9 +253,9 @@ static void __init dns323_init(void) */ orion5x_setup_dev_boot_win(DNS323_NOR_BOOT_BASE, DNS323_NOR_BOOT_SIZE); - /* DNS-323 has a Marvell 88X7042 SATA controller attached via PCIe + /* DNS-323 has a Marvell 88X7042 SATA controller attached via PCIE * - * Open a special address decode windows for the PCIe WA. + * Open a special address decode windows for the PCIE WA. */ orion5x_setup_pcie_wa_win(ORION5X_PCIE_WA_PHYS_BASE, ORION5X_PCIE_WA_SIZE); diff --git a/trunk/arch/arm/mach-orion5x/kurobox_pro-setup.c b/trunk/arch/arm/mach-orion5x/kurobox_pro-setup.c index 88410862feef..91413455beba 100644 --- a/trunk/arch/arm/mach-orion5x/kurobox_pro-setup.c +++ b/trunk/arch/arm/mach-orion5x/kurobox_pro-setup.c @@ -120,19 +120,13 @@ static struct platform_device kurobox_pro_nor_flash = { static int __init kurobox_pro_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin) { - int irq; - - /* - * Check for devices with hard-wired IRQs. - */ - irq = orion5x_pci_map_irq(dev, slot, pin); - if (irq != -1) - return irq; - /* * PCI isn't used on the Kuro */ - printk(KERN_ERR "kurobox_pro_pci_map_irq failed, unknown bus\n"); + if (dev->bus->number == orion5x_pcie_local_bus_nr()) + return IRQ_ORION5X_PCIE0_INT; + else + printk(KERN_ERR "kurobox_pro_pci_map_irq failed, unknown bus\n"); return -1; } @@ -168,7 +162,9 @@ static struct mv643xx_eth_platform_data kurobox_pro_eth_data = { * RTC 5C372a on I2C bus ****************************************************************************/ static struct i2c_board_info __initdata kurobox_pro_i2c_rtc = { - I2C_BOARD_INFO("rs5c372a", 0x32), + .driver_name = "rtc-rs5c372", + .type = "rs5c372a", + .addr = 0x32, }; /***************************************************************************** @@ -197,7 +193,7 @@ static void __init kurobox_pro_init(void) orion5x_setup_dev0_win(KUROBOX_PRO_NAND_BASE, KUROBOX_PRO_NAND_SIZE); /* - * Open a special address decode windows for the PCIe WA. + * Open a special address decode windows for the PCIE WA. */ orion5x_setup_pcie_wa_win(ORION5X_PCIE_WA_PHYS_BASE, ORION5X_PCIE_WA_SIZE); diff --git a/trunk/arch/arm/mach-orion5x/pci.c b/trunk/arch/arm/mach-orion5x/pci.c index 9d5d39fa19c3..fdf99fca85b3 100644 --- a/trunk/arch/arm/mach-orion5x/pci.c +++ b/trunk/arch/arm/mach-orion5x/pci.c @@ -41,6 +41,11 @@ void __init orion5x_pcie_id(u32 *dev, u32 *rev) *rev = orion_pcie_rev(PCIE_BASE); } +int __init orion5x_pcie_local_bus_nr(void) +{ + return orion_pcie_get_local_bus_nr(PCIE_BASE); +} + static int pcie_valid_config(int bus, int dev) { /* @@ -264,7 +269,7 @@ static int __init pcie_setup(struct pci_sys_data *sys) */ static DEFINE_SPINLOCK(orion5x_pci_lock); -static int orion5x_pci_local_bus_nr(void) +int orion5x_pci_local_bus_nr(void) { u32 conf = orion5x_read(PCI_P2P_CONF); return((conf & PCI_P2P_BUS_MASK) >> PCI_P2P_BUS_OFFS); @@ -552,16 +557,3 @@ struct pci_bus __init *orion5x_pci_sys_scan_bus(int nr, struct pci_sys_data *sys return bus; } - -int __init orion5x_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin) -{ - int bus = dev->bus->number; - - /* - * PCIe endpoint? - */ - if (bus < orion5x_pci_local_bus_nr()) - return IRQ_ORION5X_PCIE0_INT; - - return -1; -} diff --git a/trunk/arch/arm/mach-orion5x/rd88f5182-setup.c b/trunk/arch/arm/mach-orion5x/rd88f5182-setup.c index 81abc1003aae..37e8b2dc3ed5 100644 --- a/trunk/arch/arm/mach-orion5x/rd88f5182-setup.c +++ b/trunk/arch/arm/mach-orion5x/rd88f5182-setup.c @@ -172,14 +172,11 @@ void __init rd88f5182_pci_preinit(void) static int __init rd88f5182_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin) { - int irq; - /* - * Check for devices with hard-wired IRQs. + * PCI-E isn't used on the RD2 */ - irq = orion5x_pci_map_irq(dev, slot, pin); - if (irq != -1) - return irq; + if (dev->bus->number == orion5x_pcie_local_bus_nr()) + return IRQ_ORION5X_PCIE0_INT; /* * PCI IRQs are connected via GPIOs @@ -227,7 +224,9 @@ static struct mv643xx_eth_platform_data rd88f5182_eth_data = { * RTC DS1338 on I2C bus ****************************************************************************/ static struct i2c_board_info __initdata rd88f5182_i2c_rtc = { - I2C_BOARD_INFO("ds1338", 0x68), + .driver_name = "rtc-ds1307", + .type = "ds1338", + .addr = 0x68, }; /***************************************************************************** @@ -260,7 +259,7 @@ static void __init rd88f5182_init(void) orion5x_setup_dev1_win(RD88F5182_NOR_BASE, RD88F5182_NOR_SIZE); /* - * Open a special address decode windows for the PCIe WA. + * Open a special address decode windows for the PCIE WA. */ orion5x_setup_pcie_wa_win(ORION5X_PCIE_WA_PHYS_BASE, ORION5X_PCIE_WA_SIZE); diff --git a/trunk/arch/arm/mach-orion5x/ts209-setup.c b/trunk/arch/arm/mach-orion5x/ts209-setup.c index 9afb41ee6e07..fd43863a86f6 100644 --- a/trunk/arch/arm/mach-orion5x/ts209-setup.c +++ b/trunk/arch/arm/mach-orion5x/ts209-setup.c @@ -141,17 +141,14 @@ void __init qnap_ts209_pci_preinit(void) static int __init qnap_ts209_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin) { - int irq; - /* - * Check for devices with hard-wired IRQs. + * PCIE IRQ is connected internally (not GPIO) */ - irq = orion5x_pci_map_irq(dev, slot, pin); - if (irq != -1) - return irq; + if (dev->bus->number == orion5x_pcie_local_bus_nr()) + return IRQ_ORION5X_PCIE0_INT; /* - * PCI IRQs are connected via GPIOs. + * PCI IRQs are connected via GPIOs */ switch (slot - QNAP_TS209_PCI_SLOT0_OFFS) { case 0: @@ -279,7 +276,8 @@ static void __init ts209_find_mac_addr(void) #define TS209_RTC_GPIO 3 static struct i2c_board_info __initdata qnap_ts209_i2c_rtc = { - I2C_BOARD_INFO("s35390a", 0x30), + .driver_name = "rtc-s35390a", + .addr = 0x30, .irq = 0, }; @@ -375,7 +373,7 @@ static void __init qnap_ts209_init(void) QNAP_TS209_NOR_BOOT_SIZE); /* - * Open a special address decode windows for the PCIe WA. + * Open a special address decode windows for the PCIE WA. */ orion5x_setup_pcie_wa_win(ORION5X_PCIE_WA_PHYS_BASE, ORION5X_PCIE_WA_SIZE); diff --git a/trunk/arch/arm/mach-pxa/Makefile b/trunk/arch/arm/mach-pxa/Makefile index 6a830853aa6a..7cdcb459ea9d 100644 --- a/trunk/arch/arm/mach-pxa/Makefile +++ b/trunk/arch/arm/mach-pxa/Makefile @@ -5,9 +5,9 @@ # Common support (must be linked before board specific support) obj-y += clock.o devices.o generic.o irq.o dma.o \ time.o gpio.o -obj-$(CONFIG_PXA25x) += mfp-pxa2xx.o pxa25x.o -obj-$(CONFIG_PXA27x) += mfp-pxa2xx.o pxa27x.o -obj-$(CONFIG_PXA3xx) += mfp-pxa3xx.o pxa3xx.o smemc.o +obj-$(CONFIG_PXA25x) += pxa25x.o mfp-pxa2xx.o +obj-$(CONFIG_PXA27x) += pxa27x.o mfp-pxa2xx.o +obj-$(CONFIG_PXA3xx) += pxa3xx.o mfp-pxa3xx.o smemc.o obj-$(CONFIG_CPU_PXA300) += pxa300.o obj-$(CONFIG_CPU_PXA320) += pxa320.o diff --git a/trunk/arch/arm/mach-pxa/gumstix.c b/trunk/arch/arm/mach-pxa/gumstix.c index bdf239754037..f01d18544133 100644 --- a/trunk/arch/arm/mach-pxa/gumstix.c +++ b/trunk/arch/arm/mach-pxa/gumstix.c @@ -40,7 +40,6 @@ #include #include -#include #include "generic.h" diff --git a/trunk/arch/arm/mach-pxa/magician.c b/trunk/arch/arm/mach-pxa/magician.c index badba064dc04..d70be75bd199 100644 --- a/trunk/arch/arm/mach-pxa/magician.c +++ b/trunk/arch/arm/mach-pxa/magician.c @@ -114,14 +114,6 @@ static unsigned long magician_pin_config[] = { GPIO82_CIF_DD_5, GPIO84_CIF_FV, GPIO85_CIF_LV, - - /* Magician specific input GPIOs */ - GPIO9_GPIO, /* unknown */ - GPIO10_GPIO, /* GSM_IRQ */ - GPIO13_GPIO, /* CPLD_IRQ */ - GPIO107_GPIO, /* DS1WM_IRQ */ - GPIO108_GPIO, /* GSM_READY */ - GPIO115_GPIO, /* nPEN_IRQ */ }; /* @@ -446,7 +438,7 @@ static struct pasic3_led pasic3_leds[] = { static struct platform_device pasic3; -static struct pasic3_leds_machinfo pasic3_leds_info = { +static struct pasic3_leds_machinfo __devinit pasic3_leds_info = { .num_leds = ARRAY_SIZE(pasic3_leds), .power_gpio = EGPIO_MAGICIAN_LED_POWER, .leds = pasic3_leds, @@ -551,28 +543,9 @@ static struct platform_device power_supply = { static int magician_mci_init(struct device *dev, irq_handler_t detect_irq, void *data) { - int err; - - err = request_irq(IRQ_MAGICIAN_SD, detect_irq, + return request_irq(IRQ_MAGICIAN_SD, detect_irq, IRQF_DISABLED | IRQF_SAMPLE_RANDOM, "MMC card detect", data); - if (err) - goto err_request_irq; - err = gpio_request(EGPIO_MAGICIAN_SD_POWER, "SD_POWER"); - if (err) - goto err_request_power; - err = gpio_request(EGPIO_MAGICIAN_nSD_READONLY, "nSD_READONLY"); - if (err) - goto err_request_readonly; - - return 0; - -err_request_readonly: - gpio_free(EGPIO_MAGICIAN_SD_POWER); -err_request_power: - free_irq(IRQ_MAGICIAN_SD, data); -err_request_irq: - return err; } static void magician_mci_setpower(struct device *dev, unsigned int vdd) @@ -589,8 +562,6 @@ static int magician_mci_get_ro(struct device *dev) static void magician_mci_exit(struct device *dev, void *data) { - gpio_free(EGPIO_MAGICIAN_nSD_READONLY); - gpio_free(EGPIO_MAGICIAN_SD_POWER); free_irq(IRQ_MAGICIAN_SD, data); } @@ -672,42 +643,28 @@ static void __init magician_init(void) { void __iomem *cpld; int lcd_select; - int err; - - gpio_request(GPIO13_MAGICIAN_CPLD_IRQ, "CPLD_IRQ"); - gpio_request(GPIO107_MAGICIAN_DS1WM_IRQ, "DS1WM_IRQ"); pxa2xx_mfp_config(ARRAY_AND_SIZE(magician_pin_config)); platform_add_devices(devices, ARRAY_SIZE(devices)); - - err = gpio_request(GPIO83_MAGICIAN_nIR_EN, "nIR_EN"); - if (!err) { - gpio_direction_output(GPIO83_MAGICIAN_nIR_EN, 1); - pxa_set_ficp_info(&magician_ficp_info); - } pxa_set_i2c_info(NULL); pxa_set_mci_info(&magician_mci_info); pxa_set_ohci_info(&magician_ohci_info); + pxa_set_ficp_info(&magician_ficp_info); /* Check LCD type we have */ cpld = ioremap_nocache(PXA_CS3_PHYS, 0x1000); if (cpld) { u8 board_id = __raw_readb(cpld+0x14); - iounmap(cpld); system_rev = board_id & 0x7; lcd_select = board_id & 0x8; + iounmap(cpld); pr_info("LCD type: %s\n", lcd_select ? "Samsung" : "Toppoly"); - if (lcd_select && (system_rev < 3)) { - gpio_request(GPIO75_MAGICIAN_SAMSUNG_POWER, "SAMSUNG_POWER"); - gpio_direction_output(GPIO75_MAGICIAN_SAMSUNG_POWER, 0); - } - gpio_request(GPIO104_MAGICIAN_LCD_POWER_1, "LCD_POWER_1"); - gpio_request(GPIO105_MAGICIAN_LCD_POWER_2, "LCD_POWER_2"); - gpio_request(GPIO106_MAGICIAN_LCD_POWER_3, "LCD_POWER_3"); - gpio_direction_output(GPIO104_MAGICIAN_LCD_POWER_1, 0); - gpio_direction_output(GPIO105_MAGICIAN_LCD_POWER_2, 0); - gpio_direction_output(GPIO106_MAGICIAN_LCD_POWER_3, 0); + if (lcd_select && (system_rev < 3)) + pxa_gpio_mode(GPIO75_MAGICIAN_SAMSUNG_POWER_MD); + pxa_gpio_mode(GPIO104_MAGICIAN_LCD_POWER_1_MD); + pxa_gpio_mode(GPIO105_MAGICIAN_LCD_POWER_2_MD); + pxa_gpio_mode(GPIO106_MAGICIAN_LCD_POWER_3_MD); set_pxa_fb_info(lcd_select ? &samsung_info : &toppoly_info); } else pr_err("LCD detection: CPLD mapping failed\n"); diff --git a/trunk/arch/arm/mach-pxa/pcm990-baseboard.c b/trunk/arch/arm/mach-pxa/pcm990-baseboard.c index 49d951db0f3d..e6be9d0aeccf 100644 --- a/trunk/arch/arm/mach-pxa/pcm990-baseboard.c +++ b/trunk/arch/arm/mach-pxa/pcm990-baseboard.c @@ -320,13 +320,16 @@ static struct soc_camera_link iclink[] = { static struct i2c_board_info __initdata pcm990_i2c_devices[] = { { /* Must initialize before the camera(s) */ - I2C_BOARD_INFO("pca9536", 0x41), + I2C_BOARD_INFO("pca953x", 0x41), + .type = "pca9536", .platform_data = &pca9536_data, }, { I2C_BOARD_INFO("mt9v022", 0x48), + .type = "mt9v022", .platform_data = &iclink[0], /* With extender */ }, { I2C_BOARD_INFO("mt9m001", 0x5d), + .type = "mt9m001", .platform_data = &iclink[0], /* With extender */ }, }; diff --git a/trunk/arch/arm/mach-pxa/pm.c b/trunk/arch/arm/mach-pxa/pm.c index ec1bbf333a3a..039194cbe477 100644 --- a/trunk/arch/arm/mach-pxa/pm.c +++ b/trunk/arch/arm/mach-pxa/pm.c @@ -46,8 +46,8 @@ int pxa_pm_enter(suspend_state_t state) sleep_save_checksum += sleep_save[i]; } - /* Clear reset status */ - RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR; + /* Clear sleep reset status */ + RCSR = RCSR_SMR; /* *** go zzz *** */ pxa_cpu_pm_fns->enter(state); diff --git a/trunk/arch/arm/mach-pxa/pxa3xx.c b/trunk/arch/arm/mach-pxa/pxa3xx.c index b6a6f5fcc77a..dde355e88fa1 100644 --- a/trunk/arch/arm/mach-pxa/pxa3xx.c +++ b/trunk/arch/arm/mach-pxa/pxa3xx.c @@ -486,8 +486,6 @@ static int pxa3xx_set_wake(unsigned int irq, unsigned int on) case IRQ_MMC3: mask = ADXER_MFP_GEN12; break; - default: - return -EINVAL; } local_irq_save(flags); diff --git a/trunk/arch/arm/mm/Kconfig b/trunk/arch/arm/mm/Kconfig index 33ed048502a3..1b8229d9c9d5 100644 --- a/trunk/arch/arm/mm/Kconfig +++ b/trunk/arch/arm/mm/Kconfig @@ -372,7 +372,7 @@ config CPU_FEROCEON select CPU_PABRT_NOIFAR select CPU_CACHE_VIVT select CPU_CP15_MMU - select CPU_COPY_FEROCEON if MMU + select CPU_COPY_V4WB if MMU select CPU_TLB_V4WBI if MMU config CPU_FEROCEON_OLD_ID @@ -523,9 +523,6 @@ config CPU_COPY_V4WT config CPU_COPY_V4WB bool -config CPU_COPY_FEROCEON - bool - config CPU_COPY_V6 bool @@ -661,7 +658,7 @@ config CPU_DCACHE_SIZE config CPU_DCACHE_WRITETHROUGH bool "Force write through D-cache" - depends on (CPU_ARM740T || CPU_ARM920T || CPU_ARM922T || CPU_ARM925T || CPU_ARM926T || CPU_ARM940T || CPU_ARM946E || CPU_ARM1020) && !CPU_DCACHE_DISABLE + depends on (CPU_ARM740T || CPU_ARM920T || CPU_ARM922T || CPU_ARM925T || CPU_ARM926T || CPU_ARM940T || CPU_ARM946E || CPU_ARM1020 || CPU_FEROCEON) && !CPU_DCACHE_DISABLE default y if CPU_ARM925T help Say Y here to use the data cache in writethrough mode. Unless you diff --git a/trunk/arch/arm/mm/Makefile b/trunk/arch/arm/mm/Makefile index 32b2d2d213a6..44536a0b995a 100644 --- a/trunk/arch/arm/mm/Makefile +++ b/trunk/arch/arm/mm/Makefile @@ -36,7 +36,6 @@ obj-$(CONFIG_CPU_CACHE_V7) += cache-v7.o obj-$(CONFIG_CPU_COPY_V3) += copypage-v3.o obj-$(CONFIG_CPU_COPY_V4WT) += copypage-v4wt.o obj-$(CONFIG_CPU_COPY_V4WB) += copypage-v4wb.o -obj-$(CONFIG_CPU_COPY_FEROCEON) += copypage-feroceon.o obj-$(CONFIG_CPU_COPY_V6) += copypage-v6.o context.o obj-$(CONFIG_CPU_SA1100) += copypage-v4mc.o obj-$(CONFIG_CPU_XSCALE) += copypage-xscale.o diff --git a/trunk/arch/arm/mm/copypage-feroceon.S b/trunk/arch/arm/mm/copypage-feroceon.S deleted file mode 100644 index 7eb0d320d240..000000000000 --- a/trunk/arch/arm/mm/copypage-feroceon.S +++ /dev/null @@ -1,95 +0,0 @@ -/* - * linux/arch/arm/lib/copypage-feroceon.S - * - * Copyright (C) 2008 Marvell Semiconductors - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This handles copy_user_page and clear_user_page on Feroceon - * more optimally than the generic implementations. - */ -#include -#include -#include - - .text - .align 5 - -ENTRY(feroceon_copy_user_page) - stmfd sp!, {r4-r9, lr} - mov ip, #PAGE_SZ -1: mov lr, r1 - ldmia r1!, {r2 - r9} - pld [lr, #32] - pld [lr, #64] - pld [lr, #96] - pld [lr, #128] - pld [lr, #160] - pld [lr, #192] - pld [lr, #224] - stmia r0, {r2 - r9} - ldmia r1!, {r2 - r9} - mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D line - add r0, r0, #32 - stmia r0, {r2 - r9} - ldmia r1!, {r2 - r9} - mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D line - add r0, r0, #32 - stmia r0, {r2 - r9} - ldmia r1!, {r2 - r9} - mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D line - add r0, r0, #32 - stmia r0, {r2 - r9} - ldmia r1!, {r2 - r9} - mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D line - add r0, r0, #32 - stmia r0, {r2 - r9} - ldmia r1!, {r2 - r9} - mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D line - add r0, r0, #32 - stmia r0, {r2 - r9} - ldmia r1!, {r2 - r9} - mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D line - add r0, r0, #32 - stmia r0, {r2 - r9} - ldmia r1!, {r2 - r9} - mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D line - add r0, r0, #32 - stmia r0, {r2 - r9} - subs ip, ip, #(32 * 8) - mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D line - add r0, r0, #32 - bne 1b - mcr p15, 0, ip, c7, c10, 4 @ drain WB - ldmfd sp!, {r4-r9, pc} - - .align 5 - -ENTRY(feroceon_clear_user_page) - stmfd sp!, {r4-r7, lr} - mov r1, #PAGE_SZ/32 - mov r2, #0 - mov r3, #0 - mov r4, #0 - mov r5, #0 - mov r6, #0 - mov r7, #0 - mov ip, #0 - mov lr, #0 -1: stmia r0, {r2-r7, ip, lr} - subs r1, r1, #1 - mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D line - add r0, r0, #32 - bne 1b - mcr p15, 0, r1, c7, c10, 4 @ drain WB - ldmfd sp!, {r4-r7, pc} - - __INITDATA - - .type feroceon_user_fns, #object -ENTRY(feroceon_user_fns) - .long feroceon_clear_user_page - .long feroceon_copy_user_page - .size feroceon_user_fns, . - feroceon_user_fns diff --git a/trunk/arch/arm/mm/iomap.c b/trunk/arch/arm/mm/iomap.c index 7429f8c01015..62066f3020c8 100644 --- a/trunk/arch/arm/mm/iomap.c +++ b/trunk/arch/arm/mm/iomap.c @@ -26,8 +26,8 @@ EXPORT_SYMBOL(ioport_unmap); #ifdef CONFIG_PCI void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen) { - resource_size_t start = pci_resource_start(dev, bar); - resource_size_t len = pci_resource_len(dev, bar); + unsigned long start = pci_resource_start(dev, bar); + unsigned long len = pci_resource_len(dev, bar); unsigned long flags = pci_resource_flags(dev, bar); if (!len || !start) diff --git a/trunk/arch/arm/mm/proc-feroceon.S b/trunk/arch/arm/mm/proc-feroceon.S index a02c1712b52d..90e7594e29b1 100644 --- a/trunk/arch/arm/mm/proc-feroceon.S +++ b/trunk/arch/arm/mm/proc-feroceon.S @@ -93,7 +93,7 @@ ENTRY(cpu_feroceon_reset) * * Called with IRQs disabled */ - .align 5 + .align 10 ENTRY(cpu_feroceon_do_idle) mov r0, #0 mcr p15, 0, r0, c7, c10, 4 @ Drain write buffer @@ -106,7 +106,6 @@ ENTRY(cpu_feroceon_do_idle) * Clean and invalidate all cache entries in a particular * address space. */ - .align 5 ENTRY(feroceon_flush_user_cache_all) /* FALLTHROUGH */ @@ -119,8 +118,12 @@ ENTRY(feroceon_flush_kern_cache_all) mov r2, #VM_EXEC mov ip, #0 __flush_whole_cache: +#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH + mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache +#else 1: mrc p15, 0, r15, c7, c14, 3 @ test,clean,invalidate bne 1b +#endif tst r2, #VM_EXEC mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache mcrne p15, 0, ip, c7, c10, 4 @ drain WB @@ -136,19 +139,27 @@ __flush_whole_cache: * - end - end address (exclusive) * - flags - vm_flags describing address space */ - .align 5 ENTRY(feroceon_flush_user_cache_range) mov ip, #0 sub r3, r1, r0 @ calculate total size cmp r3, #CACHE_DLIMIT bgt __flush_whole_cache 1: tst r2, #VM_EXEC +#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH + mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry + mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry + add r0, r0, #CACHE_DLINESIZE + mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry + mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry + add r0, r0, #CACHE_DLINESIZE +#else mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry add r0, r0, #CACHE_DLINESIZE mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry add r0, r0, #CACHE_DLINESIZE +#endif cmp r0, r1 blo 1b tst r2, #VM_EXEC @@ -165,7 +176,6 @@ ENTRY(feroceon_flush_user_cache_range) * - start - virtual start address * - end - virtual end address */ - .align 5 ENTRY(feroceon_coherent_kern_range) /* FALLTHROUGH */ @@ -197,7 +207,6 @@ ENTRY(feroceon_coherent_user_range) * * - addr - page aligned address */ - .align 5 ENTRY(feroceon_flush_kern_dcache_page) add r1, r0, #PAGE_SZ 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry @@ -222,12 +231,13 @@ ENTRY(feroceon_flush_kern_dcache_page) * * (same as v4wb) */ - .align 5 ENTRY(feroceon_dma_inv_range) +#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH tst r0, #CACHE_DLINESIZE - 1 mcrne p15, 0, r0, c7, c10, 1 @ clean D entry tst r1, #CACHE_DLINESIZE - 1 mcrne p15, 0, r1, c7, c10, 1 @ clean D entry +#endif bic r0, r0, #CACHE_DLINESIZE - 1 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry add r0, r0, #CACHE_DLINESIZE @@ -246,13 +256,14 @@ ENTRY(feroceon_dma_inv_range) * * (same as v4wb) */ - .align 5 ENTRY(feroceon_dma_clean_range) +#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH bic r0, r0, #CACHE_DLINESIZE - 1 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry add r0, r0, #CACHE_DLINESIZE cmp r0, r1 blo 1b +#endif mcr p15, 0, r0, c7, c10, 4 @ drain WB mov pc, lr @@ -264,10 +275,14 @@ ENTRY(feroceon_dma_clean_range) * - start - virtual start address * - end - virtual end address */ - .align 5 ENTRY(feroceon_dma_flush_range) bic r0, r0, #CACHE_DLINESIZE - 1 -1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry +1: +#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH + mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry +#else + mcr p15, 0, r0, c7, c10, 1 @ clean D entry +#endif add r0, r0, #CACHE_DLINESIZE cmp r0, r1 blo 1b @@ -285,12 +300,13 @@ ENTRY(feroceon_cache_fns) .long feroceon_dma_clean_range .long feroceon_dma_flush_range - .align 5 ENTRY(cpu_feroceon_dcache_clean_area) +#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry add r0, r0, #CACHE_DLINESIZE subs r1, r1, #CACHE_DLINESIZE bhi 1b +#endif mcr p15, 0, r0, c7, c10, 4 @ drain WB mov pc, lr @@ -307,9 +323,13 @@ ENTRY(cpu_feroceon_dcache_clean_area) ENTRY(cpu_feroceon_switch_mm) #ifdef CONFIG_MMU mov ip, #0 +#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH + mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache +#else @ && 'Clean & Invalidate whole DCache' 1: mrc p15, 0, r15, c7, c14, 3 @ test,clean,invalidate bne 1b +#endif mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache mcr p15, 0, ip, c7, c10, 4 @ drain WB mcr p15, 0, r0, c2, c0, 0 @ load page table pointer @@ -342,9 +362,16 @@ ENTRY(cpu_feroceon_set_pte_ext) tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young? movne r2, #0 +#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH + eor r3, r2, #0x0a @ C & small page? + tst r3, #0x0b + biceq r2, r2, #4 +#endif str r2, [r0] @ hardware version mov r0, r0 +#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH mcr p15, 0, r0, c7, c10, 1 @ clean D entry +#endif mcr p15, 0, r0, c7, c10, 4 @ drain WB #endif mov pc, lr @@ -360,11 +387,20 @@ __feroceon_setup: mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4 #endif + +#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH + mov r0, #4 @ disable write-back on caches explicitly + mcr p15, 7, r0, c15, c0, 0 +#endif + adr r5, feroceon_crval ldmia r5, {r5, r6} mrc p15, 0, r0, c1, c0 @ get control register v4 bic r0, r0, r5 orr r0, r0, r6 +#ifdef CONFIG_CPU_CACHE_ROUND_ROBIN + orr r0, r0, #0x4000 @ .1.. .... .... .... +#endif mov pc, lr .size __feroceon_setup, . - __feroceon_setup @@ -440,7 +476,7 @@ __feroceon_old_id_proc_info: .long cpu_feroceon_name .long feroceon_processor_functions .long v4wbi_tlb_fns - .long feroceon_user_fns + .long v4wb_user_fns .long feroceon_cache_fns .size __feroceon_old_id_proc_info, . - __feroceon_old_id_proc_info #endif @@ -466,6 +502,6 @@ __feroceon_proc_info: .long cpu_feroceon_name .long feroceon_processor_functions .long v4wbi_tlb_fns - .long feroceon_user_fns + .long v4wb_user_fns .long feroceon_cache_fns .size __feroceon_proc_info, . - __feroceon_proc_info diff --git a/trunk/arch/arm/oprofile/op_model_mpcore.c b/trunk/arch/arm/oprofile/op_model_mpcore.c index 74fae6045650..75bae067922d 100644 --- a/trunk/arch/arm/oprofile/op_model_mpcore.c +++ b/trunk/arch/arm/oprofile/op_model_mpcore.c @@ -51,7 +51,7 @@ /* * MPCore SCU event monitor support */ -#define SCU_EVENTMONITORS_VA_BASE __io_address(REALVIEW_EB11MP_SCU_BASE + 0x10) +#define SCU_EVENTMONITORS_VA_BASE __io_address(REALVIEW_MPCORE_SCU_BASE + 0x10) /* * Bitmask of used SCU counters @@ -80,7 +80,7 @@ static irqreturn_t scu_em_interrupt(int irq, void *arg) struct eventmonitor __iomem *emc = SCU_EVENTMONITORS_VA_BASE; unsigned int cnt; - cnt = irq - IRQ_EB11MP_PMU_SCU0; + cnt = irq - IRQ_PMU_SCU0; oprofile_add_sample(get_irq_regs(), SCU_COUNTER(cnt)); scu_reset_counter(emc, cnt); @@ -119,10 +119,10 @@ static int scu_start(void) */ for (i = 0; i < NUM_SCU_COUNTERS; i++) { if (scu_em_used & (1 << i)) { - ret = request_irq(IRQ_EB11MP_PMU_SCU0 + i, scu_em_interrupt, IRQF_DISABLED, "SCU PMU", NULL); + ret = request_irq(IRQ_PMU_SCU0 + i, scu_em_interrupt, IRQF_DISABLED, "SCU PMU", NULL); if (ret) { printk(KERN_ERR "oprofile: unable to request IRQ%u for SCU Event Monitor\n", - IRQ_EB11MP_PMU_SCU0 + i); + IRQ_PMU_SCU0 + i); goto err_free_scu; } } @@ -153,7 +153,7 @@ static int scu_start(void) err_free_scu: while (i--) - free_irq(IRQ_EB11MP_PMU_SCU0 + i, NULL); + free_irq(IRQ_PMU_SCU0 + i, NULL); return ret; } @@ -175,7 +175,7 @@ static void scu_stop(void) for (i = 0; i < NUM_SCU_COUNTERS; i++) { if (scu_em_used & (1 << i)) { scu_reset_counter(emc, i); - free_irq(IRQ_EB11MP_PMU_SCU0 + i, NULL); + free_irq(IRQ_PMU_SCU0 + i, NULL); } } } @@ -225,10 +225,10 @@ static int em_setup_ctrs(void) } static int arm11_irqs[] = { - [0] = IRQ_EB11MP_PMU_CPU0, - [1] = IRQ_EB11MP_PMU_CPU1, - [2] = IRQ_EB11MP_PMU_CPU2, - [3] = IRQ_EB11MP_PMU_CPU3 + [0] = IRQ_PMU_CPU0, + [1] = IRQ_PMU_CPU1, + [2] = IRQ_PMU_CPU2, + [3] = IRQ_PMU_CPU3 }; static int em_start(void) @@ -273,22 +273,22 @@ static int em_setup(void) /* * Send SCU PMU interrupts to the "owner" CPU. */ - em_route_irq(IRQ_EB11MP_PMU_SCU0, 0); - em_route_irq(IRQ_EB11MP_PMU_SCU1, 0); - em_route_irq(IRQ_EB11MP_PMU_SCU2, 1); - em_route_irq(IRQ_EB11MP_PMU_SCU3, 1); - em_route_irq(IRQ_EB11MP_PMU_SCU4, 2); - em_route_irq(IRQ_EB11MP_PMU_SCU5, 2); - em_route_irq(IRQ_EB11MP_PMU_SCU6, 3); - em_route_irq(IRQ_EB11MP_PMU_SCU7, 3); + em_route_irq(IRQ_PMU_SCU0, 0); + em_route_irq(IRQ_PMU_SCU1, 0); + em_route_irq(IRQ_PMU_SCU2, 1); + em_route_irq(IRQ_PMU_SCU3, 1); + em_route_irq(IRQ_PMU_SCU4, 2); + em_route_irq(IRQ_PMU_SCU5, 2); + em_route_irq(IRQ_PMU_SCU6, 3); + em_route_irq(IRQ_PMU_SCU7, 3); /* * Send CP15 PMU interrupts to the owner CPU. */ - em_route_irq(IRQ_EB11MP_PMU_CPU0, 0); - em_route_irq(IRQ_EB11MP_PMU_CPU1, 1); - em_route_irq(IRQ_EB11MP_PMU_CPU2, 2); - em_route_irq(IRQ_EB11MP_PMU_CPU3, 3); + em_route_irq(IRQ_PMU_CPU0, 0); + em_route_irq(IRQ_PMU_CPU1, 1); + em_route_irq(IRQ_PMU_CPU2, 2); + em_route_irq(IRQ_PMU_CPU3, 3); return 0; } diff --git a/trunk/arch/avr32/kernel/asm-offsets.c b/trunk/arch/avr32/kernel/asm-offsets.c index e4796c67a831..078cd33f467b 100644 --- a/trunk/arch/avr32/kernel/asm-offsets.c +++ b/trunk/arch/avr32/kernel/asm-offsets.c @@ -5,7 +5,14 @@ */ #include -#include + +#define DEFINE(sym, val) \ + asm volatile("\n->" #sym " %0 " #val : : "i" (val)) + +#define BLANK() asm volatile("\n->" : : ) + +#define OFFSET(sym, str, mem) \ + DEFINE(sym, offsetof(struct str, mem)); void foo(void) { diff --git a/trunk/arch/avr32/mm/tlb.c b/trunk/arch/avr32/mm/tlb.c index cd12edbea9f2..b835257a8fa3 100644 --- a/trunk/arch/avr32/mm/tlb.c +++ b/trunk/arch/avr32/mm/tlb.c @@ -369,7 +369,11 @@ static const struct file_operations proc_tlb_operations = { static int __init proctlb_init(void) { - proc_create("tlb", 0, NULL, &proc_tlb_operations); + struct proc_dir_entry *entry; + + entry = create_proc_entry("tlb", 0, NULL); + if (entry) + entry->proc_fops = &proc_tlb_operations; return 0; } late_initcall(proctlb_init); diff --git a/trunk/arch/blackfin/kernel/asm-offsets.c b/trunk/arch/blackfin/kernel/asm-offsets.c index 721f15f3cebf..b56b2741cdea 100644 --- a/trunk/arch/blackfin/kernel/asm-offsets.c +++ b/trunk/arch/blackfin/kernel/asm-offsets.c @@ -34,7 +34,8 @@ #include #include #include -#include + +#define DEFINE(sym, val) asm volatile("\n->" #sym " %0 " #val : : "i" (val)) int main(void) { diff --git a/trunk/arch/blackfin/kernel/signal.c b/trunk/arch/blackfin/kernel/signal.c index cb9d883d493c..d1fa24401dc6 100644 --- a/trunk/arch/blackfin/kernel/signal.c +++ b/trunk/arch/blackfin/kernel/signal.c @@ -212,7 +212,7 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t * info, /* Set up registers for signal handler */ wrusp((unsigned long)frame); - if (current->personality & FDPIC_FUNCPTRS) { + if (get_personality & FDPIC_FUNCPTRS) { struct fdpic_func_descriptor __user *funcptr = (struct fdpic_func_descriptor *) ka->sa.sa_handler; __get_user(regs->pc, &funcptr->text); diff --git a/trunk/arch/blackfin/mach-bf533/boards/stamp.c b/trunk/arch/blackfin/mach-bf533/boards/stamp.c index 024f418ae543..fddce32901a2 100644 --- a/trunk/arch/blackfin/mach-bf533/boards/stamp.c +++ b/trunk/arch/blackfin/mach-bf533/boards/stamp.c @@ -499,17 +499,20 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = { #if defined(CONFIG_JOYSTICK_AD7142) || defined(CONFIG_JOYSTICK_AD7142_MODULE) { I2C_BOARD_INFO("ad7142_joystick", 0x2C), + .type = "ad7142_joystick", .irq = 39, }, #endif #if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE) { I2C_BOARD_INFO("pcf8574_lcd", 0x22), + .type = "pcf8574_lcd", }, #endif #if defined(CONFIG_TWI_KEYPAD) || defined(CONFIG_TWI_KEYPAD_MODULE) { I2C_BOARD_INFO("pcf8574_keypad", 0x27), + .type = "pcf8574_keypad", .irq = 39, }, #endif diff --git a/trunk/arch/blackfin/mach-bf537/boards/stamp.c b/trunk/arch/blackfin/mach-bf537/boards/stamp.c index d3727b7c2d7d..0cec14b1ef5c 100644 --- a/trunk/arch/blackfin/mach-bf537/boards/stamp.c +++ b/trunk/arch/blackfin/mach-bf537/boards/stamp.c @@ -751,17 +751,20 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = { #if defined(CONFIG_JOYSTICK_AD7142) || defined(CONFIG_JOYSTICK_AD7142_MODULE) { I2C_BOARD_INFO("ad7142_joystick", 0x2C), + .type = "ad7142_joystick", .irq = 55, }, #endif #if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE) { I2C_BOARD_INFO("pcf8574_lcd", 0x22), + .type = "pcf8574_lcd", }, #endif #if defined(CONFIG_TWI_KEYPAD) || defined(CONFIG_TWI_KEYPAD_MODULE) { I2C_BOARD_INFO("pcf8574_keypad", 0x27), + .type = "pcf8574_keypad", .irq = 72, }, #endif diff --git a/trunk/arch/blackfin/mach-bf548/boards/ezkit.c b/trunk/arch/blackfin/mach-bf548/boards/ezkit.c index b00f68ac6bc9..231dfbd3bc1f 100644 --- a/trunk/arch/blackfin/mach-bf548/boards/ezkit.c +++ b/trunk/arch/blackfin/mach-bf548/boards/ezkit.c @@ -641,11 +641,13 @@ static struct i2c_board_info __initdata bfin_i2c_board_info1[] = { #if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE) { I2C_BOARD_INFO("pcf8574_lcd", 0x22), + .type = "pcf8574_lcd", }, #endif #if defined(CONFIG_TWI_KEYPAD) || defined(CONFIG_TWI_KEYPAD_MODULE) { I2C_BOARD_INFO("pcf8574_keypad", 0x27), + .type = "pcf8574_keypad", .irq = 212, }, #endif diff --git a/trunk/arch/cris/kernel/profile.c b/trunk/arch/cris/kernel/profile.c index 44f7b4f79476..aad0a9e5991a 100644 --- a/trunk/arch/cris/kernel/profile.c +++ b/trunk/arch/cris/kernel/profile.c @@ -75,9 +75,9 @@ __init init_cris_profile(void) sample_buffer_pos = sample_buffer; - entry = proc_create("system_profile", S_IWUSR | S_IRUGO, NULL, - &cris_proc_profile_operations); + entry = create_proc_entry("system_profile", S_IWUSR | S_IRUGO, NULL); if (entry) { + entry->proc_fops = &cris_proc_profile_operations; entry->size = SAMPLE_BUFFER_SIZE; } prof_running = 1; diff --git a/trunk/arch/frv/kernel/asm-offsets.c b/trunk/arch/frv/kernel/asm-offsets.c index 9de96843a278..fbb19fc1af40 100644 --- a/trunk/arch/frv/kernel/asm-offsets.c +++ b/trunk/arch/frv/kernel/asm-offsets.c @@ -7,13 +7,15 @@ #include #include #include -#include #include #include #include #include #include +#define DEFINE(sym, val) \ + asm volatile("\n->" #sym " %0 " #val : : "i" (val)) + #define DEF_PTREG(sym, reg) \ asm volatile("\n->" #sym " %0 offsetof(struct pt_regs, " #reg ")" \ : : "i" (offsetof(struct pt_regs, reg))) @@ -30,6 +32,11 @@ asm volatile("\n->" #sym " %0 offsetof(struct frv_frame0, " #reg ")" \ : : "i" (offsetof(struct frv_frame0, reg))) +#define BLANK() asm volatile("\n->" : : ) + +#define OFFSET(sym, str, mem) \ + DEFINE(sym, offsetof(struct str, mem)); + void foo(void) { /* offsets into the thread_info structure */ diff --git a/trunk/arch/frv/kernel/signal.c b/trunk/arch/frv/kernel/signal.c index 3bdb368292a8..d64bcaff54cd 100644 --- a/trunk/arch/frv/kernel/signal.c +++ b/trunk/arch/frv/kernel/signal.c @@ -297,7 +297,7 @@ static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set) __frame->lr = (unsigned long) &frame->retcode; __frame->gr8 = sig; - if (current->personality & FDPIC_FUNCPTRS) { + if (get_personality & FDPIC_FUNCPTRS) { struct fdpic_func_descriptor __user *funcptr = (struct fdpic_func_descriptor __user *) ka->sa.sa_handler; __get_user(__frame->pc, &funcptr->text); @@ -396,7 +396,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, __frame->gr8 = sig; __frame->gr9 = (unsigned long) &frame->info; - if (current->personality & FDPIC_FUNCPTRS) { + if (get_personality & FDPIC_FUNCPTRS) { struct fdpic_func_descriptor __user *funcptr = (struct fdpic_func_descriptor __user *) ka->sa.sa_handler; __get_user(__frame->pc, &funcptr->text); diff --git a/trunk/arch/frv/kernel/traps.c b/trunk/arch/frv/kernel/traps.c index 1d2dfe67d442..a40df80b2ebd 100644 --- a/trunk/arch/frv/kernel/traps.c +++ b/trunk/arch/frv/kernel/traps.c @@ -362,8 +362,11 @@ asmlinkage void memory_access_exception(unsigned long esr0, #ifdef CONFIG_MMU unsigned long fixup; - fixup = search_exception_table(__frame->pc); - if (fixup) { + if ((esr0 & ESRx_EC) == ESRx_EC_DATA_ACCESS) + if (handle_misalignment(esr0, ear0, epcr0) == 0) + return; + + if ((fixup = search_exception_table(__frame->pc)) != 0) { __frame->pc = fixup; return; } diff --git a/trunk/arch/frv/mb93090-mb00/pci-iomap.c b/trunk/arch/frv/mb93090-mb00/pci-iomap.c index 35f6df28351e..068fa04bd527 100644 --- a/trunk/arch/frv/mb93090-mb00/pci-iomap.c +++ b/trunk/arch/frv/mb93090-mb00/pci-iomap.c @@ -13,8 +13,8 @@ void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen) { - resource_size_t start = pci_resource_start(dev, bar); - resource_size_t len = pci_resource_len(dev, bar); + unsigned long start = pci_resource_start(dev, bar); + unsigned long len = pci_resource_len(dev, bar); unsigned long flags = pci_resource_flags(dev, bar); if (!len || !start) diff --git a/trunk/arch/frv/mm/unaligned.c b/trunk/arch/frv/mm/unaligned.c new file mode 100644 index 000000000000..8f0375fc15a8 --- /dev/null +++ b/trunk/arch/frv/mm/unaligned.c @@ -0,0 +1,217 @@ +/* unaligned.c: unalignment fixup handler for CPUs on which it is supported (FR451 only) + * + * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved. + * Written by David Howells (dhowells@redhat.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#if 0 +#define kdebug(fmt, ...) printk("FDPIC "fmt"\n" ,##__VA_ARGS__ ) +#else +#define kdebug(fmt, ...) do {} while(0) +#endif + +#define _MA_SIGNED 0x01 +#define _MA_HALF 0x02 +#define _MA_WORD 0x04 +#define _MA_DWORD 0x08 +#define _MA_SZ_MASK 0x0e +#define _MA_LOAD 0x10 +#define _MA_STORE 0x20 +#define _MA_UPDATE 0x40 +#define _MA_IMM 0x80 + +#define _MA_LDxU _MA_LOAD | _MA_UPDATE +#define _MA_LDxI _MA_LOAD | _MA_IMM +#define _MA_STxU _MA_STORE | _MA_UPDATE +#define _MA_STxI _MA_STORE | _MA_IMM + +static const uint8_t tbl_LDGRk_reg[0x40] = { + [0x02] = _MA_LOAD | _MA_HALF | _MA_SIGNED, /* LDSH @(GRi,GRj),GRk */ + [0x03] = _MA_LOAD | _MA_HALF, /* LDUH @(GRi,GRj),GRk */ + [0x04] = _MA_LOAD | _MA_WORD, /* LD @(GRi,GRj),GRk */ + [0x05] = _MA_LOAD | _MA_DWORD, /* LDD @(GRi,GRj),GRk */ + [0x12] = _MA_LDxU | _MA_HALF | _MA_SIGNED, /* LDSHU @(GRi,GRj),GRk */ + [0x13] = _MA_LDxU | _MA_HALF, /* LDUHU @(GRi,GRj),GRk */ + [0x14] = _MA_LDxU | _MA_WORD, /* LDU @(GRi,GRj),GRk */ + [0x15] = _MA_LDxU | _MA_DWORD, /* LDDU @(GRi,GRj),GRk */ +}; + +static const uint8_t tbl_STGRk_reg[0x40] = { + [0x01] = _MA_STORE | _MA_HALF, /* STH @(GRi,GRj),GRk */ + [0x02] = _MA_STORE | _MA_WORD, /* ST @(GRi,GRj),GRk */ + [0x03] = _MA_STORE | _MA_DWORD, /* STD @(GRi,GRj),GRk */ + [0x11] = _MA_STxU | _MA_HALF, /* STHU @(GRi,GRj),GRk */ + [0x12] = _MA_STxU | _MA_WORD, /* STU @(GRi,GRj),GRk */ + [0x13] = _MA_STxU | _MA_DWORD, /* STDU @(GRi,GRj),GRk */ +}; + +static const uint8_t tbl_LDSTGRk_imm[0x80] = { + [0x31] = _MA_LDxI | _MA_HALF | _MA_SIGNED, /* LDSHI @(GRi,d12),GRk */ + [0x32] = _MA_LDxI | _MA_WORD, /* LDI @(GRi,d12),GRk */ + [0x33] = _MA_LDxI | _MA_DWORD, /* LDDI @(GRi,d12),GRk */ + [0x36] = _MA_LDxI | _MA_HALF, /* LDUHI @(GRi,d12),GRk */ + [0x51] = _MA_STxI | _MA_HALF, /* STHI @(GRi,d12),GRk */ + [0x52] = _MA_STxI | _MA_WORD, /* STI @(GRi,d12),GRk */ + [0x53] = _MA_STxI | _MA_DWORD, /* STDI @(GRi,d12),GRk */ +}; + + +/*****************************************************************************/ +/* + * see if we can handle the exception by fixing up a misaligned memory access + */ +int handle_misalignment(unsigned long esr0, unsigned long ear0, unsigned long epcr0) +{ + unsigned long insn, addr, *greg; + int GRi, GRj, GRk, D12, op; + + union { + uint64_t _64; + uint32_t _32[2]; + uint16_t _16; + uint8_t _8[8]; + } x; + + if (!(esr0 & ESR0_EAV) || !(epcr0 & EPCR0_V) || !(ear0 & 7)) + return -EAGAIN; + + epcr0 &= EPCR0_PC; + + if (__frame->pc != epcr0) { + kdebug("MISALIGN: Execution not halted on excepting instruction\n"); + BUG(); + } + + if (__get_user(insn, (unsigned long *) epcr0) < 0) + return -EFAULT; + + /* determine the instruction type first */ + switch ((insn >> 18) & 0x7f) { + case 0x2: + /* LDx @(GRi,GRj),GRk */ + op = tbl_LDGRk_reg[(insn >> 6) & 0x3f]; + break; + + case 0x3: + /* STx GRk,@(GRi,GRj) */ + op = tbl_STGRk_reg[(insn >> 6) & 0x3f]; + break; + + default: + op = tbl_LDSTGRk_imm[(insn >> 18) & 0x7f]; + break; + } + + if (!op) + return -EAGAIN; + + kdebug("MISALIGN: pc=%08lx insn=%08lx ad=%08lx op=%02x\n", epcr0, insn, ear0, op); + + memset(&x, 0xba, 8); + + /* validate the instruction parameters */ + greg = (unsigned long *) &__frame->tbr; + + GRi = (insn >> 12) & 0x3f; + GRk = (insn >> 25) & 0x3f; + + if (GRi > 31 || GRk > 31) + return -ENOENT; + + if (op & _MA_DWORD && GRk & 1) + return -EINVAL; + + if (op & _MA_IMM) { + D12 = insn & 0xfff; + asm ("slli %0,#20,%0 ! srai %0,#20,%0" : "=r"(D12) : "0"(D12)); /* sign extend */ + addr = (GRi ? greg[GRi] : 0) + D12; + } + else { + GRj = (insn >> 0) & 0x3f; + if (GRj > 31) + return -ENOENT; + addr = (GRi ? greg[GRi] : 0) + (GRj ? greg[GRj] : 0); + } + + if (addr != ear0) { + kdebug("MISALIGN: Calculated addr (%08lx) does not match EAR0 (%08lx)\n", + addr, ear0); + return -EFAULT; + } + + /* check the address is okay */ + if (user_mode(__frame) && ___range_ok(ear0, 8) < 0) + return -EFAULT; + + /* perform the memory op */ + if (op & _MA_STORE) { + /* perform a store */ + x._32[0] = 0; + if (GRk != 0) { + if (op & _MA_HALF) { + x._16 = greg[GRk]; + } + else { + x._32[0] = greg[GRk]; + } + } + if (op & _MA_DWORD) + x._32[1] = greg[GRk + 1]; + + kdebug("MISALIGN: Store GR%d { %08x:%08x } -> %08lx (%dB)\n", + GRk, x._32[1], x._32[0], addr, op & _MA_SZ_MASK); + + if (__memcpy_user((void *) addr, &x, op & _MA_SZ_MASK) != 0) + return -EFAULT; + } + else { + /* perform a load */ + if (__memcpy_user(&x, (void *) addr, op & _MA_SZ_MASK) != 0) + return -EFAULT; + + if (op & _MA_HALF) { + if (op & _MA_SIGNED) + asm ("slli %0,#16,%0 ! srai %0,#16,%0" + : "=r"(x._32[0]) : "0"(x._16)); + else + asm ("sethi #0,%0" + : "=r"(x._32[0]) : "0"(x._16)); + } + + kdebug("MISALIGN: Load %08lx (%dB) -> GR%d, { %08x:%08x }\n", + addr, op & _MA_SZ_MASK, GRk, x._32[1], x._32[0]); + + if (GRk != 0) + greg[GRk] = x._32[0]; + if (op & _MA_DWORD) + greg[GRk + 1] = x._32[1]; + } + + /* update the base pointer if required */ + if (op & _MA_UPDATE) + greg[GRi] = addr; + + /* well... we've done that insn */ + __frame->pc = __frame->pc + 4; + + return 0; +} /* end handle_misalignment() */ diff --git a/trunk/arch/h8300/kernel/asm-offsets.c b/trunk/arch/h8300/kernel/asm-offsets.c index 2042552e0871..fc30b4fd0914 100644 --- a/trunk/arch/h8300/kernel/asm-offsets.c +++ b/trunk/arch/h8300/kernel/asm-offsets.c @@ -13,11 +13,15 @@ #include #include #include -#include #include #include #include +#define DEFINE(sym, val) \ + asm volatile("\n->" #sym " %0 " #val : : "i" (val)) + +#define BLANK() asm volatile("\n->" : : ) + int main(void) { /* offsets into the task struct */ diff --git a/trunk/arch/ia64/Kconfig b/trunk/arch/ia64/Kconfig index 0df5f6f75edf..3aa6c821449a 100644 --- a/trunk/arch/ia64/Kconfig +++ b/trunk/arch/ia64/Kconfig @@ -19,7 +19,6 @@ config IA64 select HAVE_OPROFILE select HAVE_KPROBES select HAVE_KRETPROBES - select HAVE_DMA_ATTRS select HAVE_KVM default y help @@ -48,9 +47,6 @@ config MMU config SWIOTLB bool -config IOMMU_HELPER - bool - config GENERIC_LOCKBREAK bool default y @@ -619,7 +615,7 @@ config IRQ_PER_CPU default y config IOMMU_HELPER - def_bool (IA64_HP_ZX1 || IA64_HP_ZX1_SWIOTLB || IA64_GENERIC || SWIOTLB) + def_bool (IA64_HP_ZX1 || IA64_HP_ZX1_SWIOTLB || IA64_GENERIC) source "arch/ia64/hp/sim/Kconfig" diff --git a/trunk/arch/ia64/hp/common/hwsw_iommu.c b/trunk/arch/ia64/hp/common/hwsw_iommu.c index 1c44ec2a1d58..8f6bcfe1dada 100644 --- a/trunk/arch/ia64/hp/common/hwsw_iommu.c +++ b/trunk/arch/ia64/hp/common/hwsw_iommu.c @@ -20,10 +20,10 @@ extern int swiotlb_late_init_with_default_size (size_t size); extern ia64_mv_dma_alloc_coherent swiotlb_alloc_coherent; extern ia64_mv_dma_free_coherent swiotlb_free_coherent; -extern ia64_mv_dma_map_single_attrs swiotlb_map_single_attrs; -extern ia64_mv_dma_unmap_single_attrs swiotlb_unmap_single_attrs; -extern ia64_mv_dma_map_sg_attrs swiotlb_map_sg_attrs; -extern ia64_mv_dma_unmap_sg_attrs swiotlb_unmap_sg_attrs; +extern ia64_mv_dma_map_single swiotlb_map_single; +extern ia64_mv_dma_unmap_single swiotlb_unmap_single; +extern ia64_mv_dma_map_sg swiotlb_map_sg; +extern ia64_mv_dma_unmap_sg swiotlb_unmap_sg; extern ia64_mv_dma_supported swiotlb_dma_supported; extern ia64_mv_dma_mapping_error swiotlb_dma_mapping_error; @@ -31,19 +31,19 @@ extern ia64_mv_dma_mapping_error swiotlb_dma_mapping_error; extern ia64_mv_dma_alloc_coherent sba_alloc_coherent; extern ia64_mv_dma_free_coherent sba_free_coherent; -extern ia64_mv_dma_map_single_attrs sba_map_single_attrs; -extern ia64_mv_dma_unmap_single_attrs sba_unmap_single_attrs; -extern ia64_mv_dma_map_sg_attrs sba_map_sg_attrs; -extern ia64_mv_dma_unmap_sg_attrs sba_unmap_sg_attrs; +extern ia64_mv_dma_map_single sba_map_single; +extern ia64_mv_dma_unmap_single sba_unmap_single; +extern ia64_mv_dma_map_sg sba_map_sg; +extern ia64_mv_dma_unmap_sg sba_unmap_sg; extern ia64_mv_dma_supported sba_dma_supported; extern ia64_mv_dma_mapping_error sba_dma_mapping_error; #define hwiommu_alloc_coherent sba_alloc_coherent #define hwiommu_free_coherent sba_free_coherent -#define hwiommu_map_single_attrs sba_map_single_attrs -#define hwiommu_unmap_single_attrs sba_unmap_single_attrs -#define hwiommu_map_sg_attrs sba_map_sg_attrs -#define hwiommu_unmap_sg_attrs sba_unmap_sg_attrs +#define hwiommu_map_single sba_map_single +#define hwiommu_unmap_single sba_unmap_single +#define hwiommu_map_sg sba_map_sg +#define hwiommu_unmap_sg sba_unmap_sg #define hwiommu_dma_supported sba_dma_supported #define hwiommu_dma_mapping_error sba_dma_mapping_error #define hwiommu_sync_single_for_cpu machvec_dma_sync_single @@ -98,48 +98,41 @@ hwsw_free_coherent (struct device *dev, size_t size, void *vaddr, dma_addr_t dma } dma_addr_t -hwsw_map_single_attrs(struct device *dev, void *addr, size_t size, int dir, - struct dma_attrs *attrs) +hwsw_map_single (struct device *dev, void *addr, size_t size, int dir) { if (use_swiotlb(dev)) - return swiotlb_map_single_attrs(dev, addr, size, dir, attrs); + return swiotlb_map_single(dev, addr, size, dir); else - return hwiommu_map_single_attrs(dev, addr, size, dir, attrs); + return hwiommu_map_single(dev, addr, size, dir); } -EXPORT_SYMBOL(hwsw_map_single_attrs); void -hwsw_unmap_single_attrs(struct device *dev, dma_addr_t iova, size_t size, - int dir, struct dma_attrs *attrs) +hwsw_unmap_single (struct device *dev, dma_addr_t iova, size_t size, int dir) { if (use_swiotlb(dev)) - return swiotlb_unmap_single_attrs(dev, iova, size, dir, attrs); + return swiotlb_unmap_single(dev, iova, size, dir); else - return hwiommu_unmap_single_attrs(dev, iova, size, dir, attrs); + return hwiommu_unmap_single(dev, iova, size, dir); } -EXPORT_SYMBOL(hwsw_unmap_single_attrs); + int -hwsw_map_sg_attrs(struct device *dev, struct scatterlist *sglist, int nents, - int dir, struct dma_attrs *attrs) +hwsw_map_sg (struct device *dev, struct scatterlist *sglist, int nents, int dir) { if (use_swiotlb(dev)) - return swiotlb_map_sg_attrs(dev, sglist, nents, dir, attrs); + return swiotlb_map_sg(dev, sglist, nents, dir); else - return hwiommu_map_sg_attrs(dev, sglist, nents, dir, attrs); + return hwiommu_map_sg(dev, sglist, nents, dir); } -EXPORT_SYMBOL(hwsw_map_sg_attrs); void -hwsw_unmap_sg_attrs(struct device *dev, struct scatterlist *sglist, int nents, - int dir, struct dma_attrs *attrs) +hwsw_unmap_sg (struct device *dev, struct scatterlist *sglist, int nents, int dir) { if (use_swiotlb(dev)) - return swiotlb_unmap_sg_attrs(dev, sglist, nents, dir, attrs); + return swiotlb_unmap_sg(dev, sglist, nents, dir); else - return hwiommu_unmap_sg_attrs(dev, sglist, nents, dir, attrs); + return hwiommu_unmap_sg(dev, sglist, nents, dir); } -EXPORT_SYMBOL(hwsw_unmap_sg_attrs); void hwsw_sync_single_for_cpu (struct device *dev, dma_addr_t addr, size_t size, int dir) @@ -192,6 +185,10 @@ hwsw_dma_mapping_error (dma_addr_t dma_addr) } EXPORT_SYMBOL(hwsw_dma_mapping_error); +EXPORT_SYMBOL(hwsw_map_single); +EXPORT_SYMBOL(hwsw_unmap_single); +EXPORT_SYMBOL(hwsw_map_sg); +EXPORT_SYMBOL(hwsw_unmap_sg); EXPORT_SYMBOL(hwsw_dma_supported); EXPORT_SYMBOL(hwsw_alloc_coherent); EXPORT_SYMBOL(hwsw_free_coherent); diff --git a/trunk/arch/ia64/hp/common/sba_iommu.c b/trunk/arch/ia64/hp/common/sba_iommu.c index 34421aed1e2a..9409de5c9441 100644 --- a/trunk/arch/ia64/hp/common/sba_iommu.c +++ b/trunk/arch/ia64/hp/common/sba_iommu.c @@ -899,18 +899,16 @@ sba_mark_invalid(struct ioc *ioc, dma_addr_t iova, size_t byte_cnt) } /** - * sba_map_single_attrs - map one buffer and return IOVA for DMA + * sba_map_single - map one buffer and return IOVA for DMA * @dev: instance of PCI owned by the driver that's asking. * @addr: driver buffer to map. * @size: number of bytes to map in driver buffer. * @dir: R/W or both. - * @attrs: optional dma attributes * * See Documentation/DMA-mapping.txt */ dma_addr_t -sba_map_single_attrs(struct device *dev, void *addr, size_t size, int dir, - struct dma_attrs *attrs) +sba_map_single(struct device *dev, void *addr, size_t size, int dir) { struct ioc *ioc; dma_addr_t iovp; @@ -934,8 +932,7 @@ sba_map_single_attrs(struct device *dev, void *addr, size_t size, int dir, ** Device is bit capable of DMA'ing to the buffer... ** just return the PCI address of ptr */ - DBG_BYPASS("sba_map_single_attrs() bypass mask/addr: " - "0x%lx/0x%lx\n", + DBG_BYPASS("sba_map_single() bypass mask/addr: 0x%lx/0x%lx\n", to_pci_dev(dev)->dma_mask, pci_addr); return pci_addr; } @@ -956,7 +953,7 @@ sba_map_single_attrs(struct device *dev, void *addr, size_t size, int dir, #ifdef ASSERT_PDIR_SANITY spin_lock_irqsave(&ioc->res_lock, flags); - if (sba_check_pdir(ioc,"Check before sba_map_single_attrs()")) + if (sba_check_pdir(ioc,"Check before sba_map_single()")) panic("Sanity check failed"); spin_unlock_irqrestore(&ioc->res_lock, flags); #endif @@ -985,12 +982,11 @@ sba_map_single_attrs(struct device *dev, void *addr, size_t size, int dir, /* form complete address */ #ifdef ASSERT_PDIR_SANITY spin_lock_irqsave(&ioc->res_lock, flags); - sba_check_pdir(ioc,"Check after sba_map_single_attrs()"); + sba_check_pdir(ioc,"Check after sba_map_single()"); spin_unlock_irqrestore(&ioc->res_lock, flags); #endif return SBA_IOVA(ioc, iovp, offset); } -EXPORT_SYMBOL(sba_map_single_attrs); #ifdef ENABLE_MARK_CLEAN static SBA_INLINE void @@ -1017,17 +1013,15 @@ sba_mark_clean(struct ioc *ioc, dma_addr_t iova, size_t size) #endif /** - * sba_unmap_single_attrs - unmap one IOVA and free resources + * sba_unmap_single - unmap one IOVA and free resources * @dev: instance of PCI owned by the driver that's asking. * @iova: IOVA of driver buffer previously mapped. * @size: number of bytes mapped in driver buffer. * @dir: R/W or both. - * @attrs: optional dma attributes * * See Documentation/DMA-mapping.txt */ -void sba_unmap_single_attrs(struct device *dev, dma_addr_t iova, size_t size, - int dir, struct dma_attrs *attrs) +void sba_unmap_single(struct device *dev, dma_addr_t iova, size_t size, int dir) { struct ioc *ioc; #if DELAYED_RESOURCE_CNT > 0 @@ -1044,8 +1038,7 @@ void sba_unmap_single_attrs(struct device *dev, dma_addr_t iova, size_t size, /* ** Address does not fall w/in IOVA, must be bypassing */ - DBG_BYPASS("sba_unmap_single_atttrs() bypass addr: 0x%lx\n", - iova); + DBG_BYPASS("sba_unmap_single() bypass addr: 0x%lx\n", iova); #ifdef ENABLE_MARK_CLEAN if (dir == DMA_FROM_DEVICE) { @@ -1094,7 +1087,7 @@ void sba_unmap_single_attrs(struct device *dev, dma_addr_t iova, size_t size, spin_unlock_irqrestore(&ioc->res_lock, flags); #endif /* DELAYED_RESOURCE_CNT == 0 */ } -EXPORT_SYMBOL(sba_unmap_single_attrs); + /** * sba_alloc_coherent - allocate/map shared mem for DMA @@ -1151,8 +1144,7 @@ sba_alloc_coherent (struct device *dev, size_t size, dma_addr_t *dma_handle, gfp * If device can't bypass or bypass is disabled, pass the 32bit fake * device to map single to get an iova mapping. */ - *dma_handle = sba_map_single_attrs(&ioc->sac_only_dev->dev, addr, - size, 0, NULL); + *dma_handle = sba_map_single(&ioc->sac_only_dev->dev, addr, size, 0); return addr; } @@ -1169,7 +1161,7 @@ sba_alloc_coherent (struct device *dev, size_t size, dma_addr_t *dma_handle, gfp */ void sba_free_coherent (struct device *dev, size_t size, void *vaddr, dma_addr_t dma_handle) { - sba_unmap_single_attrs(dev, dma_handle, size, 0, NULL); + sba_unmap_single(dev, dma_handle, size, 0); free_pages((unsigned long) vaddr, get_order(size)); } @@ -1418,12 +1410,10 @@ sba_coalesce_chunks(struct ioc *ioc, struct device *dev, * @sglist: array of buffer/length pairs * @nents: number of entries in list * @dir: R/W or both. - * @attrs: optional dma attributes * * See Documentation/DMA-mapping.txt */ -int sba_map_sg_attrs(struct device *dev, struct scatterlist *sglist, int nents, - int dir, struct dma_attrs *attrs) +int sba_map_sg(struct device *dev, struct scatterlist *sglist, int nents, int dir) { struct ioc *ioc; int coalesced, filled = 0; @@ -1451,16 +1441,16 @@ int sba_map_sg_attrs(struct device *dev, struct scatterlist *sglist, int nents, /* Fast path single entry scatterlists. */ if (nents == 1) { sglist->dma_length = sglist->length; - sglist->dma_address = sba_map_single_attrs(dev, sba_sg_address(sglist), sglist->length, dir, attrs); + sglist->dma_address = sba_map_single(dev, sba_sg_address(sglist), sglist->length, dir); return 1; } #ifdef ASSERT_PDIR_SANITY spin_lock_irqsave(&ioc->res_lock, flags); - if (sba_check_pdir(ioc,"Check before sba_map_sg_attrs()")) + if (sba_check_pdir(ioc,"Check before sba_map_sg()")) { sba_dump_sg(ioc, sglist, nents); - panic("Check before sba_map_sg_attrs()"); + panic("Check before sba_map_sg()"); } spin_unlock_irqrestore(&ioc->res_lock, flags); #endif @@ -1489,10 +1479,10 @@ int sba_map_sg_attrs(struct device *dev, struct scatterlist *sglist, int nents, #ifdef ASSERT_PDIR_SANITY spin_lock_irqsave(&ioc->res_lock, flags); - if (sba_check_pdir(ioc,"Check after sba_map_sg_attrs()")) + if (sba_check_pdir(ioc,"Check after sba_map_sg()")) { sba_dump_sg(ioc, sglist, nents); - panic("Check after sba_map_sg_attrs()\n"); + panic("Check after sba_map_sg()\n"); } spin_unlock_irqrestore(&ioc->res_lock, flags); #endif @@ -1502,20 +1492,18 @@ int sba_map_sg_attrs(struct device *dev, struct scatterlist *sglist, int nents, return filled; } -EXPORT_SYMBOL(sba_map_sg_attrs); + /** - * sba_unmap_sg_attrs - unmap Scatter/Gather list + * sba_unmap_sg - unmap Scatter/Gather list * @dev: instance of PCI owned by the driver that's asking. * @sglist: array of buffer/length pairs * @nents: number of entries in list * @dir: R/W or both. - * @attrs: optional dma attributes * * See Documentation/DMA-mapping.txt */ -void sba_unmap_sg_attrs(struct device *dev, struct scatterlist *sglist, - int nents, int dir, struct dma_attrs *attrs) +void sba_unmap_sg (struct device *dev, struct scatterlist *sglist, int nents, int dir) { #ifdef ASSERT_PDIR_SANITY struct ioc *ioc; @@ -1530,14 +1518,13 @@ void sba_unmap_sg_attrs(struct device *dev, struct scatterlist *sglist, ASSERT(ioc); spin_lock_irqsave(&ioc->res_lock, flags); - sba_check_pdir(ioc,"Check before sba_unmap_sg_attrs()"); + sba_check_pdir(ioc,"Check before sba_unmap_sg()"); spin_unlock_irqrestore(&ioc->res_lock, flags); #endif while (nents && sglist->dma_length) { - sba_unmap_single_attrs(dev, sglist->dma_address, - sglist->dma_length, dir, attrs); + sba_unmap_single(dev, sglist->dma_address, sglist->dma_length, dir); sglist = sg_next(sglist); nents--; } @@ -1546,12 +1533,11 @@ void sba_unmap_sg_attrs(struct device *dev, struct scatterlist *sglist, #ifdef ASSERT_PDIR_SANITY spin_lock_irqsave(&ioc->res_lock, flags); - sba_check_pdir(ioc,"Check after sba_unmap_sg_attrs()"); + sba_check_pdir(ioc,"Check after sba_unmap_sg()"); spin_unlock_irqrestore(&ioc->res_lock, flags); #endif } -EXPORT_SYMBOL(sba_unmap_sg_attrs); /************************************************************** * @@ -1932,13 +1918,15 @@ static const struct file_operations ioc_fops = { static void __init ioc_proc_init(void) { - struct proc_dir_entry *dir; + struct proc_dir_entry *dir, *entry; dir = proc_mkdir("bus/mckinley", NULL); if (!dir) return; - proc_create(ioc_list->name, 0, dir, &ioc_fops); + entry = create_proc_entry(ioc_list->name, 0, dir); + if (entry) + entry->proc_fops = &ioc_fops; } #endif @@ -2178,6 +2166,10 @@ sba_page_override(char *str) __setup("sbapagesize=",sba_page_override); EXPORT_SYMBOL(sba_dma_mapping_error); +EXPORT_SYMBOL(sba_map_single); +EXPORT_SYMBOL(sba_unmap_single); +EXPORT_SYMBOL(sba_map_sg); +EXPORT_SYMBOL(sba_unmap_sg); EXPORT_SYMBOL(sba_dma_supported); EXPORT_SYMBOL(sba_alloc_coherent); EXPORT_SYMBOL(sba_free_coherent); diff --git a/trunk/arch/ia64/kernel/asm-offsets.c b/trunk/arch/ia64/kernel/asm-offsets.c index c64a55af9b95..230a6f92367f 100644 --- a/trunk/arch/ia64/kernel/asm-offsets.c +++ b/trunk/arch/ia64/kernel/asm-offsets.c @@ -9,7 +9,7 @@ #include #include #include -#include + #include #include #include @@ -19,6 +19,11 @@ #include "../kernel/sigframe.h" #include "../kernel/fsyscall_gtod_data.h" +#define DEFINE(sym, val) \ + asm volatile("\n->" #sym " %0 " #val : : "i" (val)) + +#define BLANK() asm volatile("\n->" : : ) + void foo(void) { DEFINE(IA64_TASK_SIZE, sizeof (struct task_struct)); diff --git a/trunk/arch/ia64/kernel/perfmon.c b/trunk/arch/ia64/kernel/perfmon.c index 7fbb51e10bbe..c8e403752a0c 100644 --- a/trunk/arch/ia64/kernel/perfmon.c +++ b/trunk/arch/ia64/kernel/perfmon.c @@ -6695,12 +6695,16 @@ pfm_init(void) /* * create /proc/perfmon (mostly for debugging purposes) */ - perfmon_dir = proc_create("perfmon", S_IRUGO, NULL, &pfm_proc_fops); + perfmon_dir = create_proc_entry("perfmon", S_IRUGO, NULL); if (perfmon_dir == NULL) { printk(KERN_ERR "perfmon: cannot create /proc entry, perfmon disabled\n"); pmu_conf = NULL; return -1; } + /* + * install customized file operations for /proc/perfmon entry + */ + perfmon_dir->proc_fops = &pfm_proc_fops; /* * create /proc/sys/kernel/perfmon (for debugging purposes) diff --git a/trunk/arch/ia64/kernel/salinfo.c b/trunk/arch/ia64/kernel/salinfo.c index ecb9eb78d687..b11bb50a197a 100644 --- a/trunk/arch/ia64/kernel/salinfo.c +++ b/trunk/arch/ia64/kernel/salinfo.c @@ -648,16 +648,18 @@ salinfo_init(void) if (!dir) continue; - entry = proc_create_data("event", S_IRUSR, dir, - &salinfo_event_fops, data); + entry = create_proc_entry("event", S_IRUSR, dir); if (!entry) continue; + entry->data = data; + entry->proc_fops = &salinfo_event_fops; *sdir++ = entry; - entry = proc_create_data("data", S_IRUSR | S_IWUSR, dir, - &salinfo_data_fops, data); + entry = create_proc_entry("data", S_IRUSR | S_IWUSR, dir); if (!entry) continue; + entry->data = data; + entry->proc_fops = &salinfo_data_fops; *sdir++ = entry; /* we missed any events before now */ diff --git a/trunk/arch/ia64/kernel/smpboot.c b/trunk/arch/ia64/kernel/smpboot.c index d7ad42b77d41..16483be18c0b 100644 --- a/trunk/arch/ia64/kernel/smpboot.c +++ b/trunk/arch/ia64/kernel/smpboot.c @@ -873,8 +873,7 @@ identify_siblings(struct cpuinfo_ia64 *c) u16 pltid; pal_logical_to_physical_t info; - status = ia64_pal_logical_to_phys(-1, &info); - if (status != PAL_STATUS_SUCCESS) { + if ((status = ia64_pal_logical_to_phys(-1, &info)) != PAL_STATUS_SUCCESS) { if (status != PAL_STATUS_UNIMPLEMENTED) { printk(KERN_ERR "ia64_pal_logical_to_phys failed with %ld\n", @@ -886,13 +885,8 @@ identify_siblings(struct cpuinfo_ia64 *c) info.overview_cpp = 1; info.overview_tpc = 1; } - - status = ia64_sal_physical_id_info(&pltid); - if (status != PAL_STATUS_SUCCESS) { - if (status != PAL_STATUS_UNIMPLEMENTED) - printk(KERN_ERR - "ia64_sal_pltid failed with %ld\n", - status); + if ((status = ia64_sal_physical_id_info(&pltid)) != PAL_STATUS_SUCCESS) { + printk(KERN_ERR "ia64_sal_pltid failed with %ld\n", status); return; } diff --git a/trunk/arch/ia64/kernel/topology.c b/trunk/arch/ia64/kernel/topology.c index abb17a613b17..a2484fc1a06c 100644 --- a/trunk/arch/ia64/kernel/topology.c +++ b/trunk/arch/ia64/kernel/topology.c @@ -27,15 +27,6 @@ static struct ia64_cpu *sysfs_cpus; -void arch_fix_phys_package_id(int num, u32 slot) -{ -#ifdef CONFIG_SMP - if (cpu_data(num)->socket_id == -1) - cpu_data(num)->socket_id = slot; -#endif -} -EXPORT_SYMBOL_GPL(arch_fix_phys_package_id); - int arch_register_cpu(int num) { #if defined (CONFIG_ACPI) && defined (CONFIG_HOTPLUG_CPU) diff --git a/trunk/arch/ia64/kernel/uncached.c b/trunk/arch/ia64/kernel/uncached.c index e77995a6e3ed..2a90c32024f4 100644 --- a/trunk/arch/ia64/kernel/uncached.c +++ b/trunk/arch/ia64/kernel/uncached.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2001-2008 Silicon Graphics, Inc. All rights reserved. + * Copyright (C) 2001-2006 Silicon Graphics, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License @@ -177,13 +177,12 @@ static int uncached_add_chunk(struct uncached_pool *uc_pool, int nid) * uncached_alloc_page * * @starting_nid: node id of node to start with, or -1 - * @n_pages: number of contiguous pages to allocate * - * Allocate the specified number of contiguous uncached pages on the - * the requested node. If not enough contiguous uncached pages are available - * on the requested node, roundrobin starting with the next higher node. + * Allocate 1 uncached page. Allocates on the requested node. If no + * uncached pages are available on the requested node, roundrobin starting + * with the next higher node. */ -unsigned long uncached_alloc_page(int starting_nid, int n_pages) +unsigned long uncached_alloc_page(int starting_nid) { unsigned long uc_addr; struct uncached_pool *uc_pool; @@ -203,8 +202,7 @@ unsigned long uncached_alloc_page(int starting_nid, int n_pages) if (uc_pool->pool == NULL) continue; do { - uc_addr = gen_pool_alloc(uc_pool->pool, - n_pages * PAGE_SIZE); + uc_addr = gen_pool_alloc(uc_pool->pool, PAGE_SIZE); if (uc_addr != 0) return uc_addr; } while (uncached_add_chunk(uc_pool, nid) == 0); @@ -219,12 +217,11 @@ EXPORT_SYMBOL(uncached_alloc_page); /* * uncached_free_page * - * @uc_addr: uncached address of first page to free - * @n_pages: number of contiguous pages to free + * @uc_addr: uncached address of page to free * - * Free the specified number of uncached pages. + * Free a single uncached page. */ -void uncached_free_page(unsigned long uc_addr, int n_pages) +void uncached_free_page(unsigned long uc_addr) { int nid = paddr_to_nid(uc_addr - __IA64_UNCACHED_OFFSET); struct gen_pool *pool = uncached_pools[nid].pool; @@ -235,7 +232,7 @@ void uncached_free_page(unsigned long uc_addr, int n_pages) if ((uc_addr & (0XFUL << 60)) != __IA64_UNCACHED_OFFSET) panic("uncached_free_page invalid address %lx\n", uc_addr); - gen_pool_free(pool, uc_addr, n_pages * PAGE_SIZE); + gen_pool_free(pool, uc_addr, PAGE_SIZE); } EXPORT_SYMBOL(uncached_free_page); diff --git a/trunk/arch/ia64/mm/tlb.c b/trunk/arch/ia64/mm/tlb.c index 8caf42471f0d..d52ec4e83409 100644 --- a/trunk/arch/ia64/mm/tlb.c +++ b/trunk/arch/ia64/mm/tlb.c @@ -168,10 +168,7 @@ setup_ptcg_sem(int max_purges, int nptcg_from) static int firstcpu = 1; if (toolatetochangeptcgsem) { - if (nptcg_from == NPTCG_FROM_PAL && max_purges == 0) - BUG_ON(1 < nptcg); - else - BUG_ON(max_purges < nptcg); + BUG_ON(max_purges < nptcg); return; } diff --git a/trunk/arch/ia64/sn/kernel/sn2/sn2_smp.c b/trunk/arch/ia64/sn/kernel/sn2/sn2_smp.c index 49d3120415eb..dfc6bf1c7b41 100644 --- a/trunk/arch/ia64/sn/kernel/sn2/sn2_smp.c +++ b/trunk/arch/ia64/sn/kernel/sn2/sn2_smp.c @@ -550,12 +550,11 @@ static int __init sn2_ptc_init(void) if (!ia64_platform_is("sn2")) return 0; - proc_sn2_ptc = proc_create(PTC_BASENAME, 0444, - NULL, &proc_sn2_ptc_operations); - if (!&proc_sn2_ptc_operations) { + if (!(proc_sn2_ptc = create_proc_entry(PTC_BASENAME, 0444, NULL))) { printk(KERN_ERR "unable to create %s proc entry", PTC_BASENAME); return -EINVAL; } + proc_sn2_ptc->proc_fops = &proc_sn2_ptc_operations; spin_lock_init(&sn2_global_ptc_lock); return 0; } diff --git a/trunk/arch/ia64/sn/kernel/sn2/sn_proc_fs.c b/trunk/arch/ia64/sn/kernel/sn2/sn_proc_fs.c index 2526e5c783a4..62b3e9a496ac 100644 --- a/trunk/arch/ia64/sn/kernel/sn2/sn_proc_fs.c +++ b/trunk/arch/ia64/sn/kernel/sn2/sn_proc_fs.c @@ -139,21 +139,30 @@ static const struct file_operations proc_sn_topo_fops = { void register_sn_procfs(void) { static struct proc_dir_entry *sgi_proc_dir = NULL; + struct proc_dir_entry *pde; BUG_ON(sgi_proc_dir != NULL); if (!(sgi_proc_dir = proc_mkdir("sgi_sn", NULL))) return; - proc_create("partition_id", 0444, sgi_proc_dir, - &proc_partition_id_fops); - proc_create("system_serial_number", 0444, sgi_proc_dir, - &proc_system_sn_fops); - proc_create("licenseID", 0444, sgi_proc_dir, &proc_license_id_fops); - proc_create("sn_force_interrupt", 0644, sgi_proc_dir, - &proc_sn_force_intr_fops); - proc_create("coherence_id", 0444, sgi_proc_dir, - &proc_coherence_id_fops); - proc_create("sn_topology", 0444, sgi_proc_dir, &proc_sn_topo_fops); + pde = create_proc_entry("partition_id", 0444, sgi_proc_dir); + if (pde) + pde->proc_fops = &proc_partition_id_fops; + pde = create_proc_entry("system_serial_number", 0444, sgi_proc_dir); + if (pde) + pde->proc_fops = &proc_system_sn_fops; + pde = create_proc_entry("licenseID", 0444, sgi_proc_dir); + if (pde) + pde->proc_fops = &proc_license_id_fops; + pde = create_proc_entry("sn_force_interrupt", 0644, sgi_proc_dir); + if (pde) + pde->proc_fops = &proc_sn_force_intr_fops; + pde = create_proc_entry("coherence_id", 0444, sgi_proc_dir); + if (pde) + pde->proc_fops = &proc_coherence_id_fops; + pde = create_proc_entry("sn_topology", 0444, sgi_proc_dir); + if (pde) + pde->proc_fops = &proc_sn_topo_fops; } #endif /* CONFIG_PROC_FS */ diff --git a/trunk/arch/ia64/sn/pci/pci_dma.c b/trunk/arch/ia64/sn/pci/pci_dma.c index 52175af299a0..18b94b792d54 100644 --- a/trunk/arch/ia64/sn/pci/pci_dma.c +++ b/trunk/arch/ia64/sn/pci/pci_dma.c @@ -10,7 +10,6 @@ */ #include -#include #include #include #include @@ -150,12 +149,11 @@ void sn_dma_free_coherent(struct device *dev, size_t size, void *cpu_addr, EXPORT_SYMBOL(sn_dma_free_coherent); /** - * sn_dma_map_single_attrs - map a single page for DMA + * sn_dma_map_single - map a single page for DMA * @dev: device to map for * @cpu_addr: kernel virtual address of the region to map * @size: size of the region * @direction: DMA direction - * @attrs: optional dma attributes * * Map the region pointed to by @cpu_addr for DMA and return the * DMA address. @@ -165,59 +163,42 @@ EXPORT_SYMBOL(sn_dma_free_coherent); * no way of saving the dmamap handle from the alloc to later free * (which is pretty much unacceptable). * - * mappings with the DMA_ATTR_WRITE_BARRIER get mapped with - * dma_map_consistent() so that writes force a flush of pending DMA. - * (See "SGI Altix Architecture Considerations for Linux Device Drivers", - * Document Number: 007-4763-001) - * * TODO: simplify our interface; * figure out how to save dmamap handle so can use two step. */ -dma_addr_t sn_dma_map_single_attrs(struct device *dev, void *cpu_addr, - size_t size, int direction, - struct dma_attrs *attrs) +dma_addr_t sn_dma_map_single(struct device *dev, void *cpu_addr, size_t size, + int direction) { dma_addr_t dma_addr; unsigned long phys_addr; struct pci_dev *pdev = to_pci_dev(dev); struct sn_pcibus_provider *provider = SN_PCIDEV_BUSPROVIDER(pdev); - int dmabarr; - - dmabarr = dma_get_attr(DMA_ATTR_WRITE_BARRIER, attrs); BUG_ON(dev->bus != &pci_bus_type); phys_addr = __pa(cpu_addr); - if (dmabarr) - dma_addr = provider->dma_map_consistent(pdev, phys_addr, - size, SN_DMA_ADDR_PHYS); - else - dma_addr = provider->dma_map(pdev, phys_addr, size, - SN_DMA_ADDR_PHYS); - + dma_addr = provider->dma_map(pdev, phys_addr, size, SN_DMA_ADDR_PHYS); if (!dma_addr) { printk(KERN_ERR "%s: out of ATEs\n", __func__); return 0; } return dma_addr; } -EXPORT_SYMBOL(sn_dma_map_single_attrs); +EXPORT_SYMBOL(sn_dma_map_single); /** - * sn_dma_unmap_single_attrs - unamp a DMA mapped page + * sn_dma_unmap_single - unamp a DMA mapped page * @dev: device to sync * @dma_addr: DMA address to sync * @size: size of region * @direction: DMA direction - * @attrs: optional dma attributes * * This routine is supposed to sync the DMA region specified * by @dma_handle into the coherence domain. On SN, we're always cache * coherent, so we just need to free any ATEs associated with this mapping. */ -void sn_dma_unmap_single_attrs(struct device *dev, dma_addr_t dma_addr, - size_t size, int direction, - struct dma_attrs *attrs) +void sn_dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, + int direction) { struct pci_dev *pdev = to_pci_dev(dev); struct sn_pcibus_provider *provider = SN_PCIDEV_BUSPROVIDER(pdev); @@ -226,21 +207,19 @@ void sn_dma_unmap_single_attrs(struct device *dev, dma_addr_t dma_addr, provider->dma_unmap(pdev, dma_addr, direction); } -EXPORT_SYMBOL(sn_dma_unmap_single_attrs); +EXPORT_SYMBOL(sn_dma_unmap_single); /** - * sn_dma_unmap_sg_attrs - unmap a DMA scatterlist + * sn_dma_unmap_sg - unmap a DMA scatterlist * @dev: device to unmap * @sg: scatterlist to unmap * @nhwentries: number of scatterlist entries * @direction: DMA direction - * @attrs: optional dma attributes * * Unmap a set of streaming mode DMA translations. */ -void sn_dma_unmap_sg_attrs(struct device *dev, struct scatterlist *sgl, - int nhwentries, int direction, - struct dma_attrs *attrs) +void sn_dma_unmap_sg(struct device *dev, struct scatterlist *sgl, + int nhwentries, int direction) { int i; struct pci_dev *pdev = to_pci_dev(dev); @@ -255,34 +234,25 @@ void sn_dma_unmap_sg_attrs(struct device *dev, struct scatterlist *sgl, sg->dma_length = 0; } } -EXPORT_SYMBOL(sn_dma_unmap_sg_attrs); +EXPORT_SYMBOL(sn_dma_unmap_sg); /** - * sn_dma_map_sg_attrs - map a scatterlist for DMA + * sn_dma_map_sg - map a scatterlist for DMA * @dev: device to map for * @sg: scatterlist to map * @nhwentries: number of entries * @direction: direction of the DMA transaction - * @attrs: optional dma attributes - * - * mappings with the DMA_ATTR_WRITE_BARRIER get mapped with - * dma_map_consistent() so that writes force a flush of pending DMA. - * (See "SGI Altix Architecture Considerations for Linux Device Drivers", - * Document Number: 007-4763-001) * * Maps each entry of @sg for DMA. */ -int sn_dma_map_sg_attrs(struct device *dev, struct scatterlist *sgl, - int nhwentries, int direction, struct dma_attrs *attrs) +int sn_dma_map_sg(struct device *dev, struct scatterlist *sgl, int nhwentries, + int direction) { unsigned long phys_addr; struct scatterlist *saved_sg = sgl, *sg; struct pci_dev *pdev = to_pci_dev(dev); struct sn_pcibus_provider *provider = SN_PCIDEV_BUSPROVIDER(pdev); int i; - int dmabarr; - - dmabarr = dma_get_attr(DMA_ATTR_WRITE_BARRIER, attrs); BUG_ON(dev->bus != &pci_bus_type); @@ -290,19 +260,11 @@ int sn_dma_map_sg_attrs(struct device *dev, struct scatterlist *sgl, * Setup a DMA address for each entry in the scatterlist. */ for_each_sg(sgl, sg, nhwentries, i) { - dma_addr_t dma_addr; phys_addr = SG_ENT_PHYS_ADDRESS(sg); - if (dmabarr) - dma_addr = provider->dma_map_consistent(pdev, - phys_addr, - sg->length, - SN_DMA_ADDR_PHYS); - else - dma_addr = provider->dma_map(pdev, phys_addr, - sg->length, - SN_DMA_ADDR_PHYS); + sg->dma_address = provider->dma_map(pdev, + phys_addr, sg->length, + SN_DMA_ADDR_PHYS); - sg->dma_address = dma_addr; if (!sg->dma_address) { printk(KERN_ERR "%s: out of ATEs\n", __func__); @@ -310,8 +272,7 @@ int sn_dma_map_sg_attrs(struct device *dev, struct scatterlist *sgl, * Free any successfully allocated entries. */ if (i > 0) - sn_dma_unmap_sg_attrs(dev, saved_sg, i, - direction, attrs); + sn_dma_unmap_sg(dev, saved_sg, i, direction); return 0; } @@ -320,7 +281,7 @@ int sn_dma_map_sg_attrs(struct device *dev, struct scatterlist *sgl, return nhwentries; } -EXPORT_SYMBOL(sn_dma_map_sg_attrs); +EXPORT_SYMBOL(sn_dma_map_sg); void sn_dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size, int direction) diff --git a/trunk/arch/m68k/kernel/asm-offsets.c b/trunk/arch/m68k/kernel/asm-offsets.c index b1f012f6c493..246a8820c223 100644 --- a/trunk/arch/m68k/kernel/asm-offsets.c +++ b/trunk/arch/m68k/kernel/asm-offsets.c @@ -11,12 +11,14 @@ #include #include #include -#include #include #include #include #include +#define DEFINE(sym, val) \ + asm volatile("\n->" #sym " %0 " #val : : "i" (val)) + int main(void) { /* offsets into the task struct */ diff --git a/trunk/arch/m68k/mac/iop.c b/trunk/arch/m68k/mac/iop.c index 326fb9978094..5b2799eb96a6 100644 --- a/trunk/arch/m68k/mac/iop.c +++ b/trunk/arch/m68k/mac/iop.c @@ -109,6 +109,7 @@ #include #include #include +#include #include #include @@ -123,6 +124,10 @@ int iop_scc_present,iop_ism_present; +#ifdef CONFIG_PROC_FS +static int iop_get_proc_info(char *, char **, off_t, int); +#endif /* CONFIG_PROC_FS */ + /* structure for tracking channel listeners */ struct listener { @@ -294,6 +299,12 @@ void __init iop_init(void) iop_listeners[IOP_NUM_ISM][i].devname = NULL; iop_listeners[IOP_NUM_ISM][i].handler = NULL; } + +#if 0 /* Crashing in 2.4 now, not yet sure why. --jmt */ +#ifdef CONFIG_PROC_FS + create_proc_info_entry("mac_iop", 0, &proc_root, iop_get_proc_info); +#endif +#endif } /* @@ -626,3 +637,77 @@ irqreturn_t iop_ism_irq(int irq, void *dev_id) } return IRQ_HANDLED; } + +#ifdef CONFIG_PROC_FS + +char *iop_chan_state(int state) +{ + switch(state) { + case IOP_MSG_IDLE : return "idle "; + case IOP_MSG_NEW : return "new "; + case IOP_MSG_RCVD : return "received "; + case IOP_MSG_COMPLETE : return "completed "; + default : return "unknown "; + } +} + +int iop_dump_one_iop(char *buf, int iop_num, char *iop_name) +{ + int i,len = 0; + volatile struct mac_iop *iop = iop_base[iop_num]; + + len += sprintf(buf+len, "%s IOP channel states:\n\n", iop_name); + len += sprintf(buf+len, "## send_state recv_state device\n"); + len += sprintf(buf+len, "------------------------------------------------\n"); + for (i = 0 ; i < NUM_IOP_CHAN ; i++) { + len += sprintf(buf+len, "%2d %10s %10s %s\n", i, + iop_chan_state(iop_readb(iop, IOP_ADDR_SEND_STATE+i)), + iop_chan_state(iop_readb(iop, IOP_ADDR_RECV_STATE+i)), + iop_listeners[iop_num][i].handler? + iop_listeners[iop_num][i].devname : ""); + + } + len += sprintf(buf+len, "\n"); + return len; +} + +static int iop_get_proc_info(char *buf, char **start, off_t pos, int count) +{ + int len, cnt; + + cnt = 0; + len = sprintf(buf, "IOPs detected:\n\n"); + + if (iop_scc_present) { + len += sprintf(buf+len, "SCC IOP (%p): status %02X\n", + iop_base[IOP_NUM_SCC], + (uint) iop_base[IOP_NUM_SCC]->status_ctrl); + } + if (iop_ism_present) { + len += sprintf(buf+len, "ISM IOP (%p): status %02X\n\n", + iop_base[IOP_NUM_ISM], + (uint) iop_base[IOP_NUM_ISM]->status_ctrl); + } + + if (iop_scc_present) { + len += iop_dump_one_iop(buf+len, IOP_NUM_SCC, "SCC"); + + } + + if (iop_ism_present) { + len += iop_dump_one_iop(buf+len, IOP_NUM_ISM, "ISM"); + + } + + if (len >= pos) { + if (!*start) { + *start = buf + pos; + cnt = len - pos; + } else { + cnt += len; + } + } + return (count > cnt) ? cnt : count; +} + +#endif /* CONFIG_PROC_FS */ diff --git a/trunk/arch/m68knommu/kernel/asm-offsets.c b/trunk/arch/m68knommu/kernel/asm-offsets.c index fd0c685a7f11..d97b89bae53c 100644 --- a/trunk/arch/m68knommu/kernel/asm-offsets.c +++ b/trunk/arch/m68knommu/kernel/asm-offsets.c @@ -13,11 +13,15 @@ #include #include #include -#include #include #include #include +#define DEFINE(sym, val) \ + asm volatile("\n->" #sym " %0 " #val : : "i" (val)) + +#define BLANK() asm volatile("\n->" : : ) + int main(void) { /* offsets into the task struct */ diff --git a/trunk/arch/mips/basler/excite/excite_procfs.c b/trunk/arch/mips/basler/excite/excite_procfs.c index 08923e6825b5..9ee67a95f6b9 100644 --- a/trunk/arch/mips/basler/excite/excite_procfs.c +++ b/trunk/arch/mips/basler/excite/excite_procfs.c @@ -18,9 +18,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include + #include -#include #include #include #include @@ -29,25 +28,14 @@ #include -static int excite_unit_id_proc_show(struct seq_file *m, void *v) +static int excite_get_unit_id(char *buf, char **addr, off_t offs, int size) { - seq_printf(m, "%06x", unit_id); - return 0; + const int len = snprintf(buf, PAGE_SIZE, "%06x", unit_id); + const int w = len - offs; + *addr = buf + offs; + return w < size ? w : size; } -static int excite_unit_id_proc_open(struct inode *inode, struct file *file) -{ - return single_open(file, excite_unit_id_proc_show, NULL); -} - -static const struct file_operations excite_unit_id_proc_fops = { - .owner = THIS_MODULE, - .open = excite_unit_id_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - static int excite_bootrom_read(char *page, char **start, off_t off, int count, int *eof, void *data) @@ -77,12 +65,12 @@ excite_bootrom_read(char *page, char **start, off_t off, int count, void excite_procfs_init(void) { /* Create & populate /proc/excite */ - struct proc_dir_entry * const pdir = proc_mkdir("excite", NULL); + struct proc_dir_entry * const pdir = proc_mkdir("excite", &proc_root); if (pdir) { struct proc_dir_entry * e; - e = proc_create("unit_id", S_IRUGO, pdir, - &excite_unit_id_proc_fops); + e = create_proc_info_entry("unit_id", S_IRUGO, pdir, + excite_get_unit_id); if (e) e->size = 6; e = create_proc_read_entry("bootrom", S_IRUGO, pdir, diff --git a/trunk/arch/mips/kernel/asm-offsets.c b/trunk/arch/mips/kernel/asm-offsets.c index 72942226fcdd..5bf03b3c4150 100644 --- a/trunk/arch/mips/kernel/asm-offsets.c +++ b/trunk/arch/mips/kernel/asm-offsets.c @@ -13,285 +13,327 @@ #include #include #include -#include + #include #include +#define text(t) __asm__("\n->#" t) +#define _offset(type, member) (&(((type *)NULL)->member)) +#define offset(string, ptr, member) \ + __asm__("\n->" string " %0" : : "i" (_offset(ptr, member))) +#define constant(string, member) \ + __asm__("\n->" string " %0" : : "ri" (member)) +#define size(string, size) \ + __asm__("\n->" string " %0" : : "i" (sizeof(size))) +#define linefeed text("") + void output_ptreg_defines(void) { - COMMENT("MIPS pt_regs offsets."); - OFFSET(PT_R0, pt_regs, regs[0]); - OFFSET(PT_R1, pt_regs, regs[1]); - OFFSET(PT_R2, pt_regs, regs[2]); - OFFSET(PT_R3, pt_regs, regs[3]); - OFFSET(PT_R4, pt_regs, regs[4]); - OFFSET(PT_R5, pt_regs, regs[5]); - OFFSET(PT_R6, pt_regs, regs[6]); - OFFSET(PT_R7, pt_regs, regs[7]); - OFFSET(PT_R8, pt_regs, regs[8]); - OFFSET(PT_R9, pt_regs, regs[9]); - OFFSET(PT_R10, pt_regs, regs[10]); - OFFSET(PT_R11, pt_regs, regs[11]); - OFFSET(PT_R12, pt_regs, regs[12]); - OFFSET(PT_R13, pt_regs, regs[13]); - OFFSET(PT_R14, pt_regs, regs[14]); - OFFSET(PT_R15, pt_regs, regs[15]); - OFFSET(PT_R16, pt_regs, regs[16]); - OFFSET(PT_R17, pt_regs, regs[17]); - OFFSET(PT_R18, pt_regs, regs[18]); - OFFSET(PT_R19, pt_regs, regs[19]); - OFFSET(PT_R20, pt_regs, regs[20]); - OFFSET(PT_R21, pt_regs, regs[21]); - OFFSET(PT_R22, pt_regs, regs[22]); - OFFSET(PT_R23, pt_regs, regs[23]); - OFFSET(PT_R24, pt_regs, regs[24]); - OFFSET(PT_R25, pt_regs, regs[25]); - OFFSET(PT_R26, pt_regs, regs[26]); - OFFSET(PT_R27, pt_regs, regs[27]); - OFFSET(PT_R28, pt_regs, regs[28]); - OFFSET(PT_R29, pt_regs, regs[29]); - OFFSET(PT_R30, pt_regs, regs[30]); - OFFSET(PT_R31, pt_regs, regs[31]); - OFFSET(PT_LO, pt_regs, lo); - OFFSET(PT_HI, pt_regs, hi); + text("MIPS pt_regs offsets."); + offset("PT_R0", struct pt_regs, regs[0]); + offset("PT_R1", struct pt_regs, regs[1]); + offset("PT_R2", struct pt_regs, regs[2]); + offset("PT_R3", struct pt_regs, regs[3]); + offset("PT_R4", struct pt_regs, regs[4]); + offset("PT_R5", struct pt_regs, regs[5]); + offset("PT_R6", struct pt_regs, regs[6]); + offset("PT_R7", struct pt_regs, regs[7]); + offset("PT_R8", struct pt_regs, regs[8]); + offset("PT_R9", struct pt_regs, regs[9]); + offset("PT_R10", struct pt_regs, regs[10]); + offset("PT_R11", struct pt_regs, regs[11]); + offset("PT_R12", struct pt_regs, regs[12]); + offset("PT_R13", struct pt_regs, regs[13]); + offset("PT_R14", struct pt_regs, regs[14]); + offset("PT_R15", struct pt_regs, regs[15]); + offset("PT_R16", struct pt_regs, regs[16]); + offset("PT_R17", struct pt_regs, regs[17]); + offset("PT_R18", struct pt_regs, regs[18]); + offset("PT_R19", struct pt_regs, regs[19]); + offset("PT_R20", struct pt_regs, regs[20]); + offset("PT_R21", struct pt_regs, regs[21]); + offset("PT_R22", struct pt_regs, regs[22]); + offset("PT_R23", struct pt_regs, regs[23]); + offset("PT_R24", struct pt_regs, regs[24]); + offset("PT_R25", struct pt_regs, regs[25]); + offset("PT_R26", struct pt_regs, regs[26]); + offset("PT_R27", struct pt_regs, regs[27]); + offset("PT_R28", struct pt_regs, regs[28]); + offset("PT_R29", struct pt_regs, regs[29]); + offset("PT_R30", struct pt_regs, regs[30]); + offset("PT_R31", struct pt_regs, regs[31]); + offset("PT_LO", struct pt_regs, lo); + offset("PT_HI", struct pt_regs, hi); #ifdef CONFIG_CPU_HAS_SMARTMIPS - OFFSET(PT_ACX, pt_regs, acx); + offset("PT_ACX", struct pt_regs, acx); #endif - OFFSET(PT_EPC, pt_regs, cp0_epc); - OFFSET(PT_BVADDR, pt_regs, cp0_badvaddr); - OFFSET(PT_STATUS, pt_regs, cp0_status); - OFFSET(PT_CAUSE, pt_regs, cp0_cause); + offset("PT_EPC", struct pt_regs, cp0_epc); + offset("PT_BVADDR", struct pt_regs, cp0_badvaddr); + offset("PT_STATUS", struct pt_regs, cp0_status); + offset("PT_CAUSE", struct pt_regs, cp0_cause); #ifdef CONFIG_MIPS_MT_SMTC - OFFSET(PT_TCSTATUS, pt_regs, cp0_tcstatus); + offset("PT_TCSTATUS", struct pt_regs, cp0_tcstatus); #endif /* CONFIG_MIPS_MT_SMTC */ - DEFINE(PT_SIZE, sizeof(struct pt_regs)); - BLANK(); + size("PT_SIZE", struct pt_regs); + linefeed; } void output_task_defines(void) { - COMMENT("MIPS task_struct offsets."); - OFFSET(TASK_STATE, task_struct, state); - OFFSET(TASK_THREAD_INFO, task_struct, stack); - OFFSET(TASK_FLAGS, task_struct, flags); - OFFSET(TASK_MM, task_struct, mm); - OFFSET(TASK_PID, task_struct, pid); - DEFINE(TASK_STRUCT_SIZE, sizeof(struct task_struct)); - BLANK(); + text("MIPS task_struct offsets."); + offset("TASK_STATE", struct task_struct, state); + offset("TASK_THREAD_INFO", struct task_struct, stack); + offset("TASK_FLAGS", struct task_struct, flags); + offset("TASK_MM", struct task_struct, mm); + offset("TASK_PID", struct task_struct, pid); + size( "TASK_STRUCT_SIZE", struct task_struct); + linefeed; } void output_thread_info_defines(void) { - COMMENT("MIPS thread_info offsets."); - OFFSET(TI_TASK, thread_info, task); - OFFSET(TI_EXEC_DOMAIN, thread_info, exec_domain); - OFFSET(TI_FLAGS, thread_info, flags); - OFFSET(TI_TP_VALUE, thread_info, tp_value); - OFFSET(TI_CPU, thread_info, cpu); - OFFSET(TI_PRE_COUNT, thread_info, preempt_count); - OFFSET(TI_ADDR_LIMIT, thread_info, addr_limit); - OFFSET(TI_RESTART_BLOCK, thread_info, restart_block); - OFFSET(TI_REGS, thread_info, regs); - DEFINE(_THREAD_SIZE, THREAD_SIZE); - DEFINE(_THREAD_MASK, THREAD_MASK); - BLANK(); + text("MIPS thread_info offsets."); + offset("TI_TASK", struct thread_info, task); + offset("TI_EXEC_DOMAIN", struct thread_info, exec_domain); + offset("TI_FLAGS", struct thread_info, flags); + offset("TI_TP_VALUE", struct thread_info, tp_value); + offset("TI_CPU", struct thread_info, cpu); + offset("TI_PRE_COUNT", struct thread_info, preempt_count); + offset("TI_ADDR_LIMIT", struct thread_info, addr_limit); + offset("TI_RESTART_BLOCK", struct thread_info, restart_block); + offset("TI_REGS", struct thread_info, regs); + constant("_THREAD_SIZE", THREAD_SIZE); + constant("_THREAD_MASK", THREAD_MASK); + linefeed; } void output_thread_defines(void) { - COMMENT("MIPS specific thread_struct offsets."); - OFFSET(THREAD_REG16, task_struct, thread.reg16); - OFFSET(THREAD_REG17, task_struct, thread.reg17); - OFFSET(THREAD_REG18, task_struct, thread.reg18); - OFFSET(THREAD_REG19, task_struct, thread.reg19); - OFFSET(THREAD_REG20, task_struct, thread.reg20); - OFFSET(THREAD_REG21, task_struct, thread.reg21); - OFFSET(THREAD_REG22, task_struct, thread.reg22); - OFFSET(THREAD_REG23, task_struct, thread.reg23); - OFFSET(THREAD_REG29, task_struct, thread.reg29); - OFFSET(THREAD_REG30, task_struct, thread.reg30); - OFFSET(THREAD_REG31, task_struct, thread.reg31); - OFFSET(THREAD_STATUS, task_struct, + text("MIPS specific thread_struct offsets."); + offset("THREAD_REG16", struct task_struct, thread.reg16); + offset("THREAD_REG17", struct task_struct, thread.reg17); + offset("THREAD_REG18", struct task_struct, thread.reg18); + offset("THREAD_REG19", struct task_struct, thread.reg19); + offset("THREAD_REG20", struct task_struct, thread.reg20); + offset("THREAD_REG21", struct task_struct, thread.reg21); + offset("THREAD_REG22", struct task_struct, thread.reg22); + offset("THREAD_REG23", struct task_struct, thread.reg23); + offset("THREAD_REG29", struct task_struct, thread.reg29); + offset("THREAD_REG30", struct task_struct, thread.reg30); + offset("THREAD_REG31", struct task_struct, thread.reg31); + offset("THREAD_STATUS", struct task_struct, thread.cp0_status); - OFFSET(THREAD_FPU, task_struct, thread.fpu); + offset("THREAD_FPU", struct task_struct, thread.fpu); - OFFSET(THREAD_BVADDR, task_struct, \ + offset("THREAD_BVADDR", struct task_struct, \ thread.cp0_badvaddr); - OFFSET(THREAD_BUADDR, task_struct, \ + offset("THREAD_BUADDR", struct task_struct, \ thread.cp0_baduaddr); - OFFSET(THREAD_ECODE, task_struct, \ + offset("THREAD_ECODE", struct task_struct, \ thread.error_code); - OFFSET(THREAD_TRAPNO, task_struct, thread.trap_no); - OFFSET(THREAD_TRAMP, task_struct, \ + offset("THREAD_TRAPNO", struct task_struct, thread.trap_no); + offset("THREAD_TRAMP", struct task_struct, \ thread.irix_trampoline); - OFFSET(THREAD_OLDCTX, task_struct, \ + offset("THREAD_OLDCTX", struct task_struct, \ thread.irix_oldctx); - BLANK(); + linefeed; } void output_thread_fpu_defines(void) { - OFFSET(THREAD_FPR0, task_struct, thread.fpu.fpr[0]); - OFFSET(THREAD_FPR1, task_struct, thread.fpu.fpr[1]); - OFFSET(THREAD_FPR2, task_struct, thread.fpu.fpr[2]); - OFFSET(THREAD_FPR3, task_struct, thread.fpu.fpr[3]); - OFFSET(THREAD_FPR4, task_struct, thread.fpu.fpr[4]); - OFFSET(THREAD_FPR5, task_struct, thread.fpu.fpr[5]); - OFFSET(THREAD_FPR6, task_struct, thread.fpu.fpr[6]); - OFFSET(THREAD_FPR7, task_struct, thread.fpu.fpr[7]); - OFFSET(THREAD_FPR8, task_struct, thread.fpu.fpr[8]); - OFFSET(THREAD_FPR9, task_struct, thread.fpu.fpr[9]); - OFFSET(THREAD_FPR10, task_struct, thread.fpu.fpr[10]); - OFFSET(THREAD_FPR11, task_struct, thread.fpu.fpr[11]); - OFFSET(THREAD_FPR12, task_struct, thread.fpu.fpr[12]); - OFFSET(THREAD_FPR13, task_struct, thread.fpu.fpr[13]); - OFFSET(THREAD_FPR14, task_struct, thread.fpu.fpr[14]); - OFFSET(THREAD_FPR15, task_struct, thread.fpu.fpr[15]); - OFFSET(THREAD_FPR16, task_struct, thread.fpu.fpr[16]); - OFFSET(THREAD_FPR17, task_struct, thread.fpu.fpr[17]); - OFFSET(THREAD_FPR18, task_struct, thread.fpu.fpr[18]); - OFFSET(THREAD_FPR19, task_struct, thread.fpu.fpr[19]); - OFFSET(THREAD_FPR20, task_struct, thread.fpu.fpr[20]); - OFFSET(THREAD_FPR21, task_struct, thread.fpu.fpr[21]); - OFFSET(THREAD_FPR22, task_struct, thread.fpu.fpr[22]); - OFFSET(THREAD_FPR23, task_struct, thread.fpu.fpr[23]); - OFFSET(THREAD_FPR24, task_struct, thread.fpu.fpr[24]); - OFFSET(THREAD_FPR25, task_struct, thread.fpu.fpr[25]); - OFFSET(THREAD_FPR26, task_struct, thread.fpu.fpr[26]); - OFFSET(THREAD_FPR27, task_struct, thread.fpu.fpr[27]); - OFFSET(THREAD_FPR28, task_struct, thread.fpu.fpr[28]); - OFFSET(THREAD_FPR29, task_struct, thread.fpu.fpr[29]); - OFFSET(THREAD_FPR30, task_struct, thread.fpu.fpr[30]); - OFFSET(THREAD_FPR31, task_struct, thread.fpu.fpr[31]); + offset("THREAD_FPR0", + struct task_struct, thread.fpu.fpr[0]); + offset("THREAD_FPR1", + struct task_struct, thread.fpu.fpr[1]); + offset("THREAD_FPR2", + struct task_struct, thread.fpu.fpr[2]); + offset("THREAD_FPR3", + struct task_struct, thread.fpu.fpr[3]); + offset("THREAD_FPR4", + struct task_struct, thread.fpu.fpr[4]); + offset("THREAD_FPR5", + struct task_struct, thread.fpu.fpr[5]); + offset("THREAD_FPR6", + struct task_struct, thread.fpu.fpr[6]); + offset("THREAD_FPR7", + struct task_struct, thread.fpu.fpr[7]); + offset("THREAD_FPR8", + struct task_struct, thread.fpu.fpr[8]); + offset("THREAD_FPR9", + struct task_struct, thread.fpu.fpr[9]); + offset("THREAD_FPR10", + struct task_struct, thread.fpu.fpr[10]); + offset("THREAD_FPR11", + struct task_struct, thread.fpu.fpr[11]); + offset("THREAD_FPR12", + struct task_struct, thread.fpu.fpr[12]); + offset("THREAD_FPR13", + struct task_struct, thread.fpu.fpr[13]); + offset("THREAD_FPR14", + struct task_struct, thread.fpu.fpr[14]); + offset("THREAD_FPR15", + struct task_struct, thread.fpu.fpr[15]); + offset("THREAD_FPR16", + struct task_struct, thread.fpu.fpr[16]); + offset("THREAD_FPR17", + struct task_struct, thread.fpu.fpr[17]); + offset("THREAD_FPR18", + struct task_struct, thread.fpu.fpr[18]); + offset("THREAD_FPR19", + struct task_struct, thread.fpu.fpr[19]); + offset("THREAD_FPR20", + struct task_struct, thread.fpu.fpr[20]); + offset("THREAD_FPR21", + struct task_struct, thread.fpu.fpr[21]); + offset("THREAD_FPR22", + struct task_struct, thread.fpu.fpr[22]); + offset("THREAD_FPR23", + struct task_struct, thread.fpu.fpr[23]); + offset("THREAD_FPR24", + struct task_struct, thread.fpu.fpr[24]); + offset("THREAD_FPR25", + struct task_struct, thread.fpu.fpr[25]); + offset("THREAD_FPR26", + struct task_struct, thread.fpu.fpr[26]); + offset("THREAD_FPR27", + struct task_struct, thread.fpu.fpr[27]); + offset("THREAD_FPR28", + struct task_struct, thread.fpu.fpr[28]); + offset("THREAD_FPR29", + struct task_struct, thread.fpu.fpr[29]); + offset("THREAD_FPR30", + struct task_struct, thread.fpu.fpr[30]); + offset("THREAD_FPR31", + struct task_struct, thread.fpu.fpr[31]); - OFFSET(THREAD_FCR31, task_struct, thread.fpu.fcr31); - BLANK(); + offset("THREAD_FCR31", + struct task_struct, thread.fpu.fcr31); + linefeed; } void output_mm_defines(void) { - COMMENT("Size of struct page"); - DEFINE(STRUCT_PAGE_SIZE, sizeof(struct page)); - BLANK(); - COMMENT("Linux mm_struct offsets."); - OFFSET(MM_USERS, mm_struct, mm_users); - OFFSET(MM_PGD, mm_struct, pgd); - OFFSET(MM_CONTEXT, mm_struct, context); - BLANK(); - DEFINE(_PAGE_SIZE, PAGE_SIZE); - DEFINE(_PAGE_SHIFT, PAGE_SHIFT); - BLANK(); - DEFINE(_PGD_T_SIZE, sizeof(pgd_t)); - DEFINE(_PMD_T_SIZE, sizeof(pmd_t)); - DEFINE(_PTE_T_SIZE, sizeof(pte_t)); - BLANK(); - DEFINE(_PGD_T_LOG2, PGD_T_LOG2); - DEFINE(_PMD_T_LOG2, PMD_T_LOG2); - DEFINE(_PTE_T_LOG2, PTE_T_LOG2); - BLANK(); - DEFINE(_PGD_ORDER, PGD_ORDER); - DEFINE(_PMD_ORDER, PMD_ORDER); - DEFINE(_PTE_ORDER, PTE_ORDER); - BLANK(); - DEFINE(_PMD_SHIFT, PMD_SHIFT); - DEFINE(_PGDIR_SHIFT, PGDIR_SHIFT); - BLANK(); - DEFINE(_PTRS_PER_PGD, PTRS_PER_PGD); - DEFINE(_PTRS_PER_PMD, PTRS_PER_PMD); - DEFINE(_PTRS_PER_PTE, PTRS_PER_PTE); - BLANK(); + text("Size of struct page"); + size("STRUCT_PAGE_SIZE", struct page); + linefeed; + text("Linux mm_struct offsets."); + offset("MM_USERS", struct mm_struct, mm_users); + offset("MM_PGD", struct mm_struct, pgd); + offset("MM_CONTEXT", struct mm_struct, context); + linefeed; + constant("_PAGE_SIZE", PAGE_SIZE); + constant("_PAGE_SHIFT", PAGE_SHIFT); + linefeed; + constant("_PGD_T_SIZE", sizeof(pgd_t)); + constant("_PMD_T_SIZE", sizeof(pmd_t)); + constant("_PTE_T_SIZE", sizeof(pte_t)); + linefeed; + constant("_PGD_T_LOG2", PGD_T_LOG2); + constant("_PMD_T_LOG2", PMD_T_LOG2); + constant("_PTE_T_LOG2", PTE_T_LOG2); + linefeed; + constant("_PGD_ORDER", PGD_ORDER); + constant("_PMD_ORDER", PMD_ORDER); + constant("_PTE_ORDER", PTE_ORDER); + linefeed; + constant("_PMD_SHIFT", PMD_SHIFT); + constant("_PGDIR_SHIFT", PGDIR_SHIFT); + linefeed; + constant("_PTRS_PER_PGD", PTRS_PER_PGD); + constant("_PTRS_PER_PMD", PTRS_PER_PMD); + constant("_PTRS_PER_PTE", PTRS_PER_PTE); + linefeed; } #ifdef CONFIG_32BIT void output_sc_defines(void) { - COMMENT("Linux sigcontext offsets."); - OFFSET(SC_REGS, sigcontext, sc_regs); - OFFSET(SC_FPREGS, sigcontext, sc_fpregs); - OFFSET(SC_ACX, sigcontext, sc_acx); - OFFSET(SC_MDHI, sigcontext, sc_mdhi); - OFFSET(SC_MDLO, sigcontext, sc_mdlo); - OFFSET(SC_PC, sigcontext, sc_pc); - OFFSET(SC_FPC_CSR, sigcontext, sc_fpc_csr); - OFFSET(SC_FPC_EIR, sigcontext, sc_fpc_eir); - OFFSET(SC_HI1, sigcontext, sc_hi1); - OFFSET(SC_LO1, sigcontext, sc_lo1); - OFFSET(SC_HI2, sigcontext, sc_hi2); - OFFSET(SC_LO2, sigcontext, sc_lo2); - OFFSET(SC_HI3, sigcontext, sc_hi3); - OFFSET(SC_LO3, sigcontext, sc_lo3); - BLANK(); + text("Linux sigcontext offsets."); + offset("SC_REGS", struct sigcontext, sc_regs); + offset("SC_FPREGS", struct sigcontext, sc_fpregs); + offset("SC_ACX", struct sigcontext, sc_acx); + offset("SC_MDHI", struct sigcontext, sc_mdhi); + offset("SC_MDLO", struct sigcontext, sc_mdlo); + offset("SC_PC", struct sigcontext, sc_pc); + offset("SC_FPC_CSR", struct sigcontext, sc_fpc_csr); + offset("SC_FPC_EIR", struct sigcontext, sc_fpc_eir); + offset("SC_HI1", struct sigcontext, sc_hi1); + offset("SC_LO1", struct sigcontext, sc_lo1); + offset("SC_HI2", struct sigcontext, sc_hi2); + offset("SC_LO2", struct sigcontext, sc_lo2); + offset("SC_HI3", struct sigcontext, sc_hi3); + offset("SC_LO3", struct sigcontext, sc_lo3); + linefeed; } #endif #ifdef CONFIG_64BIT void output_sc_defines(void) { - COMMENT("Linux sigcontext offsets."); - OFFSET(SC_REGS, sigcontext, sc_regs); - OFFSET(SC_FPREGS, sigcontext, sc_fpregs); - OFFSET(SC_MDHI, sigcontext, sc_mdhi); - OFFSET(SC_MDLO, sigcontext, sc_mdlo); - OFFSET(SC_PC, sigcontext, sc_pc); - OFFSET(SC_FPC_CSR, sigcontext, sc_fpc_csr); - BLANK(); + text("Linux sigcontext offsets."); + offset("SC_REGS", struct sigcontext, sc_regs); + offset("SC_FPREGS", struct sigcontext, sc_fpregs); + offset("SC_MDHI", struct sigcontext, sc_mdhi); + offset("SC_MDLO", struct sigcontext, sc_mdlo); + offset("SC_PC", struct sigcontext, sc_pc); + offset("SC_FPC_CSR", struct sigcontext, sc_fpc_csr); + linefeed; } #endif #ifdef CONFIG_MIPS32_COMPAT void output_sc32_defines(void) { - COMMENT("Linux 32-bit sigcontext offsets."); - OFFSET(SC32_FPREGS, sigcontext32, sc_fpregs); - OFFSET(SC32_FPC_CSR, sigcontext32, sc_fpc_csr); - OFFSET(SC32_FPC_EIR, sigcontext32, sc_fpc_eir); - BLANK(); + text("Linux 32-bit sigcontext offsets."); + offset("SC32_FPREGS", struct sigcontext32, sc_fpregs); + offset("SC32_FPC_CSR", struct sigcontext32, sc_fpc_csr); + offset("SC32_FPC_EIR", struct sigcontext32, sc_fpc_eir); + linefeed; } #endif void output_signal_defined(void) { - COMMENT("Linux signal numbers."); - DEFINE(_SIGHUP, SIGHUP); - DEFINE(_SIGINT, SIGINT); - DEFINE(_SIGQUIT, SIGQUIT); - DEFINE(_SIGILL, SIGILL); - DEFINE(_SIGTRAP, SIGTRAP); - DEFINE(_SIGIOT, SIGIOT); - DEFINE(_SIGABRT, SIGABRT); - DEFINE(_SIGEMT, SIGEMT); - DEFINE(_SIGFPE, SIGFPE); - DEFINE(_SIGKILL, SIGKILL); - DEFINE(_SIGBUS, SIGBUS); - DEFINE(_SIGSEGV, SIGSEGV); - DEFINE(_SIGSYS, SIGSYS); - DEFINE(_SIGPIPE, SIGPIPE); - DEFINE(_SIGALRM, SIGALRM); - DEFINE(_SIGTERM, SIGTERM); - DEFINE(_SIGUSR1, SIGUSR1); - DEFINE(_SIGUSR2, SIGUSR2); - DEFINE(_SIGCHLD, SIGCHLD); - DEFINE(_SIGPWR, SIGPWR); - DEFINE(_SIGWINCH, SIGWINCH); - DEFINE(_SIGURG, SIGURG); - DEFINE(_SIGIO, SIGIO); - DEFINE(_SIGSTOP, SIGSTOP); - DEFINE(_SIGTSTP, SIGTSTP); - DEFINE(_SIGCONT, SIGCONT); - DEFINE(_SIGTTIN, SIGTTIN); - DEFINE(_SIGTTOU, SIGTTOU); - DEFINE(_SIGVTALRM, SIGVTALRM); - DEFINE(_SIGPROF, SIGPROF); - DEFINE(_SIGXCPU, SIGXCPU); - DEFINE(_SIGXFSZ, SIGXFSZ); - BLANK(); + text("Linux signal numbers."); + constant("_SIGHUP", SIGHUP); + constant("_SIGINT", SIGINT); + constant("_SIGQUIT", SIGQUIT); + constant("_SIGILL", SIGILL); + constant("_SIGTRAP", SIGTRAP); + constant("_SIGIOT", SIGIOT); + constant("_SIGABRT", SIGABRT); + constant("_SIGEMT", SIGEMT); + constant("_SIGFPE", SIGFPE); + constant("_SIGKILL", SIGKILL); + constant("_SIGBUS", SIGBUS); + constant("_SIGSEGV", SIGSEGV); + constant("_SIGSYS", SIGSYS); + constant("_SIGPIPE", SIGPIPE); + constant("_SIGALRM", SIGALRM); + constant("_SIGTERM", SIGTERM); + constant("_SIGUSR1", SIGUSR1); + constant("_SIGUSR2", SIGUSR2); + constant("_SIGCHLD", SIGCHLD); + constant("_SIGPWR", SIGPWR); + constant("_SIGWINCH", SIGWINCH); + constant("_SIGURG", SIGURG); + constant("_SIGIO", SIGIO); + constant("_SIGSTOP", SIGSTOP); + constant("_SIGTSTP", SIGTSTP); + constant("_SIGCONT", SIGCONT); + constant("_SIGTTIN", SIGTTIN); + constant("_SIGTTOU", SIGTTOU); + constant("_SIGVTALRM", SIGVTALRM); + constant("_SIGPROF", SIGPROF); + constant("_SIGXCPU", SIGXCPU); + constant("_SIGXFSZ", SIGXFSZ); + linefeed; } void output_irq_cpustat_t_defines(void) { - COMMENT("Linux irq_cpustat_t offsets."); - DEFINE(IC_SOFTIRQ_PENDING, - offsetof(irq_cpustat_t, __softirq_pending)); - DEFINE(IC_IRQ_CPUSTAT_T, sizeof(irq_cpustat_t)); - BLANK(); + text("Linux irq_cpustat_t offsets."); + offset("IC_SOFTIRQ_PENDING", irq_cpustat_t, __softirq_pending); + size("IC_IRQ_CPUSTAT_T", irq_cpustat_t); + linefeed; } diff --git a/trunk/arch/mips/lib/iomap-pci.c b/trunk/arch/mips/lib/iomap-pci.c index 2ab899c4b4ce..c11b2494bb6e 100644 --- a/trunk/arch/mips/lib/iomap-pci.c +++ b/trunk/arch/mips/lib/iomap-pci.c @@ -45,8 +45,8 @@ static void __iomem *ioport_map_pci(struct pci_dev *dev, */ void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen) { - resource_size_t start = pci_resource_start(dev, bar); - resource_size_t len = pci_resource_len(dev, bar); + unsigned long start = pci_resource_start(dev, bar); + unsigned long len = pci_resource_len(dev, bar); unsigned long flags = pci_resource_flags(dev, bar); if (!len || !start) diff --git a/trunk/arch/mips/pmc-sierra/yosemite/setup.c b/trunk/arch/mips/pmc-sierra/yosemite/setup.c index 6537d90a25bb..855977ca51cd 100644 --- a/trunk/arch/mips/pmc-sierra/yosemite/setup.c +++ b/trunk/arch/mips/pmc-sierra/yosemite/setup.c @@ -143,6 +143,9 @@ void __init plat_time_init(void) mips_hpt_frequency = 33000000 * 3 * 5; } +/* No other usable initialization hook than this ... */ +extern void (*late_time_init)(void); + unsigned long ocd_base; EXPORT_SYMBOL(ocd_base); diff --git a/trunk/arch/mn10300/kernel/asm-offsets.c b/trunk/arch/mn10300/kernel/asm-offsets.c index 2646fcbd7d89..ee2d9f8af5ad 100644 --- a/trunk/arch/mn10300/kernel/asm-offsets.c +++ b/trunk/arch/mn10300/kernel/asm-offsets.c @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -15,6 +14,14 @@ #include "sigframe.h" #include "mn10300-serial.h" +#define DEFINE(sym, val) \ + asm volatile("\n->" #sym " %0 " #val : : "i" (val)) + +#define BLANK() asm volatile("\n->") + +#define OFFSET(sym, str, mem) \ + DEFINE(sym, offsetof(struct str, mem)); + void foo(void) { OFFSET(SIGCONTEXT_d0, sigcontext, d0); diff --git a/trunk/arch/mn10300/unit-asb2305/pci-iomap.c b/trunk/arch/mn10300/unit-asb2305/pci-iomap.c index c1a8d8f941fd..dbceae4307da 100644 --- a/trunk/arch/mn10300/unit-asb2305/pci-iomap.c +++ b/trunk/arch/mn10300/unit-asb2305/pci-iomap.c @@ -16,8 +16,8 @@ */ void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen) { - resource_size_t start = pci_resource_start(dev, bar); - resource_size_t len = pci_resource_len(dev, bar); + unsigned long start = pci_resource_start(dev, bar); + unsigned long len = pci_resource_len(dev, bar); unsigned long flags = pci_resource_flags(dev, bar); if (!len || !start) diff --git a/trunk/arch/parisc/kernel/asm-offsets.c b/trunk/arch/parisc/kernel/asm-offsets.c index 3efc0b73e4ff..eaa79bc14d94 100644 --- a/trunk/arch/parisc/kernel/asm-offsets.c +++ b/trunk/arch/parisc/kernel/asm-offsets.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include @@ -40,6 +39,11 @@ #include #include +#define DEFINE(sym, val) \ + asm volatile("\n->" #sym " %0 " #val : : "i" (val)) + +#define BLANK() asm volatile("\n->" : : ) + #ifdef CONFIG_64BIT #define FRAME_SIZE 128 #else diff --git a/trunk/arch/parisc/kernel/pci-dma.c b/trunk/arch/parisc/kernel/pci-dma.c index ccd61b9567a6..9448d4e91142 100644 --- a/trunk/arch/parisc/kernel/pci-dma.c +++ b/trunk/arch/parisc/kernel/pci-dma.c @@ -397,9 +397,10 @@ pcxl_dma_init(void) "pcxl_dma_init: Unable to create gsc /proc dir entry\n"); else { struct proc_dir_entry* ent; - ent = proc_create("pcxl_dma", 0, proc_gsc_root, - &proc_pcxl_dma_ops); - if (!ent) + ent = create_proc_entry("pcxl_dma", 0, proc_gsc_root); + if (ent) + ent->proc_fops = &proc_pcxl_dma_ops; + else printk(KERN_WARNING "pci-dma.c: Unable to create pcxl_dma /proc entry.\n"); } diff --git a/trunk/arch/parisc/lib/iomap.c b/trunk/arch/parisc/lib/iomap.c index 9abed07db7fc..f4a811690ab3 100644 --- a/trunk/arch/parisc/lib/iomap.c +++ b/trunk/arch/parisc/lib/iomap.c @@ -438,8 +438,8 @@ void ioport_unmap(void __iomem *addr) /* Create a virtual mapping cookie for a PCI BAR (memory or IO) */ void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen) { - resource_size_t start = pci_resource_start(dev, bar); - resource_size_t len = pci_resource_len(dev, bar); + unsigned long start = pci_resource_start(dev, bar); + unsigned long len = pci_resource_len(dev, bar); unsigned long flags = pci_resource_flags(dev, bar); if (!len || !start) diff --git a/trunk/arch/powerpc/Kconfig b/trunk/arch/powerpc/Kconfig index 3934e2659407..4e40c122bf26 100644 --- a/trunk/arch/powerpc/Kconfig +++ b/trunk/arch/powerpc/Kconfig @@ -608,19 +608,6 @@ source "drivers/pcmcia/Kconfig" source "drivers/pci/hotplug/Kconfig" -config HAS_RAPIDIO - bool - default n - -config RAPIDIO - bool "RapidIO support" - depends on HAS_RAPIDIO - help - If you say Y here, the kernel will include drivers and - infrastructure code to support RapidIO interconnect devices. - -source "drivers/rapidio/Kconfig" - endmenu menu "Advanced setup" diff --git a/trunk/arch/powerpc/Kconfig.debug b/trunk/arch/powerpc/Kconfig.debug index a7d24e692bab..807a2dce6263 100644 --- a/trunk/arch/powerpc/Kconfig.debug +++ b/trunk/arch/powerpc/Kconfig.debug @@ -118,6 +118,7 @@ config XMON_DISASSEMBLY config IRQSTACKS bool "Use separate kernel stacks when processing interrupts" + depends on PPC64 help If you say Y here the kernel will use separate kernel stacks for handling hard and soft interrupts. This can help avoid diff --git a/trunk/arch/powerpc/boot/dts/mpc8641_hpcn.dts b/trunk/arch/powerpc/boot/dts/mpc8641_hpcn.dts index 1e4bfe9cadb9..7f9b999843ce 100644 --- a/trunk/arch/powerpc/boot/dts/mpc8641_hpcn.dts +++ b/trunk/arch/powerpc/boot/dts/mpc8641_hpcn.dts @@ -26,7 +26,6 @@ serial1 = &serial1; pci0 = &pci0; pci1 = &pci1; - rapidio0 = &rapidio0; }; cpus { @@ -501,15 +500,4 @@ 0x0 0x00100000>; }; }; - rapidio0: rapidio@f80c0000 { - #address-cells = <2>; - #size-cells = <2>; - compatible = "fsl,rapidio-delta"; - reg = <0xf80c0000 0x20000>; - ranges = <0 0 0xc0000000 0 0x20000000>; - interrupt-parent = <&mpic>; - /* err_irq bell_outb_irq bell_inb_irq - msg1_tx_irq msg1_rx_irq msg2_tx_irq msg2_rx_irq */ - interrupts = <48 2 49 2 50 2 53 2 54 2 55 2 56 2>; - }; }; diff --git a/trunk/arch/powerpc/configs/g5_defconfig b/trunk/arch/powerpc/configs/g5_defconfig index 88338a9f5e95..a20501f89474 100644 --- a/trunk/arch/powerpc/configs/g5_defconfig +++ b/trunk/arch/powerpc/configs/g5_defconfig @@ -696,7 +696,6 @@ CONFIG_WINDFARM=y CONFIG_WINDFARM_PM81=y CONFIG_WINDFARM_PM91=y CONFIG_WINDFARM_PM112=y -CONFIG_WINDFARM_PM121=y # CONFIG_PMAC_RACKMETER is not set CONFIG_NETDEVICES=y # CONFIG_NETDEVICES_MULTIQUEUE is not set diff --git a/trunk/arch/powerpc/kernel/Makefile b/trunk/arch/powerpc/kernel/Makefile index d14cebf62bb0..9177b21b1a95 100644 --- a/trunk/arch/powerpc/kernel/Makefile +++ b/trunk/arch/powerpc/kernel/Makefile @@ -73,6 +73,7 @@ pci64-$(CONFIG_PPC64) += pci_dn.o isa-bridge.o obj-$(CONFIG_PCI) += pci_$(CONFIG_WORD_SIZE).o $(pci64-y) \ pci-common.o obj-$(CONFIG_PCI_MSI) += msi.o +obj-$(CONFIG_RAPIDIO) += rio.o obj-$(CONFIG_KEXEC) += machine_kexec.o crash.o \ machine_kexec_$(CONFIG_WORD_SIZE).o obj-$(CONFIG_AUDIT) += audit.o diff --git a/trunk/arch/powerpc/kernel/asm-offsets.c b/trunk/arch/powerpc/kernel/asm-offsets.c index ec9228d687b0..62134845af08 100644 --- a/trunk/arch/powerpc/kernel/asm-offsets.c +++ b/trunk/arch/powerpc/kernel/asm-offsets.c @@ -30,7 +30,6 @@ #include #include #endif -#include #include #include @@ -52,6 +51,11 @@ #include #endif +#define DEFINE(sym, val) \ + asm volatile("\n->" #sym " %0 " #val : : "i" (val)) + +#define BLANK() asm volatile("\n->" : : ) + int main(void) { DEFINE(THREAD, offsetof(struct task_struct, thread)); @@ -63,7 +67,6 @@ int main(void) #endif /* CONFIG_PPC64 */ DEFINE(KSP, offsetof(struct thread_struct, ksp)); - DEFINE(KSP_LIMIT, offsetof(struct thread_struct, ksp_limit)); DEFINE(PT_REGS, offsetof(struct thread_struct, regs)); DEFINE(THREAD_FPEXC_MODE, offsetof(struct thread_struct, fpexc_mode)); DEFINE(THREAD_FPR0, offsetof(struct thread_struct, fpr[0])); diff --git a/trunk/arch/powerpc/kernel/entry_32.S b/trunk/arch/powerpc/kernel/entry_32.S index 0c8614d9875c..84c868633068 100644 --- a/trunk/arch/powerpc/kernel/entry_32.S +++ b/trunk/arch/powerpc/kernel/entry_32.S @@ -137,12 +137,11 @@ transfer_to_handler: 2: /* if from kernel, check interrupted DOZE/NAP mode and * check for stack overflow */ - lwz r9,KSP_LIMIT(r12) - cmplw r1,r9 /* if r1 <= ksp_limit */ + lwz r9,THREAD_INFO-THREAD(r12) + cmplw r1,r9 /* if r1 <= current->thread_info */ ble- stack_ovf /* then the kernel stack overflowed */ 5: #ifdef CONFIG_6xx - rlwinm r9,r1,0,0,31-THREAD_SHIFT tophys(r9,r9) /* check local flags */ lwz r12,TI_LOCAL_FLAGS(r9) mtcrf 0x01,r12 diff --git a/trunk/arch/powerpc/kernel/head_64.S b/trunk/arch/powerpc/kernel/head_64.S index 024805e1747d..215973a2c8d5 100644 --- a/trunk/arch/powerpc/kernel/head_64.S +++ b/trunk/arch/powerpc/kernel/head_64.S @@ -239,10 +239,6 @@ instruction_access_slb_pSeries: .globl system_call_pSeries system_call_pSeries: HMT_MEDIUM -BEGIN_FTR_SECTION - cmpdi r0,0x1ebe - beq- 1f -END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE) mr r9,r13 mfmsr r10 mfspr r13,SPRN_SPRG3 @@ -257,13 +253,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE) rfid b . /* prevent speculative execution */ -/* Fast LE/BE switch system call */ -1: mfspr r12,SPRN_SRR1 - xori r12,r12,MSR_LE - mtspr SPRN_SRR1,r12 - rfid /* return to userspace */ - b . - STD_EXCEPTION_PSERIES(0xd00, single_step) STD_EXCEPTION_PSERIES(0xe00, trap_0e) diff --git a/trunk/arch/powerpc/kernel/irq.c b/trunk/arch/powerpc/kernel/irq.c index 2f73f705d564..425616f92d18 100644 --- a/trunk/arch/powerpc/kernel/irq.c +++ b/trunk/arch/powerpc/kernel/irq.c @@ -307,7 +307,6 @@ void do_IRQ(struct pt_regs *regs) if (curtp != irqtp) { struct irq_desc *desc = irq_desc + irq; void *handler = desc->handle_irq; - unsigned long saved_sp_limit = current->thread.ksp_limit; if (handler == NULL) handler = &__do_IRQ; irqtp->task = curtp->task; @@ -320,10 +319,7 @@ void do_IRQ(struct pt_regs *regs) (irqtp->preempt_count & ~SOFTIRQ_MASK) | (curtp->preempt_count & SOFTIRQ_MASK); - current->thread.ksp_limit = (unsigned long)irqtp + - _ALIGN_UP(sizeof(struct thread_info), 16); call_handle_irq(irq, desc, irqtp, handler); - current->thread.ksp_limit = saved_sp_limit; irqtp->task = NULL; @@ -356,7 +352,9 @@ void __init init_IRQ(void) { if (ppc_md.init_IRQ) ppc_md.init_IRQ(); +#ifdef CONFIG_PPC64 irq_ctx_init(); +#endif } @@ -385,15 +383,11 @@ void irq_ctx_init(void) static inline void do_softirq_onstack(void) { struct thread_info *curtp, *irqtp; - unsigned long saved_sp_limit = current->thread.ksp_limit; curtp = current_thread_info(); irqtp = softirq_ctx[smp_processor_id()]; irqtp->task = curtp->task; - current->thread.ksp_limit = (unsigned long)irqtp + - _ALIGN_UP(sizeof(struct thread_info), 16); call_do_softirq(irqtp); - current->thread.ksp_limit = saved_sp_limit; irqtp->task = NULL; } diff --git a/trunk/arch/powerpc/kernel/lparcfg.c b/trunk/arch/powerpc/kernel/lparcfg.c index 1e656b43ad7f..1ffacc698ffb 100644 --- a/trunk/arch/powerpc/kernel/lparcfg.c +++ b/trunk/arch/powerpc/kernel/lparcfg.c @@ -591,8 +591,10 @@ int __init lparcfg_init(void) !firmware_has_feature(FW_FEATURE_ISERIES)) mode |= S_IWUSR; - ent = proc_create("ppc64/lparcfg", mode, NULL, &lparcfg_fops); - if (!ent) { + ent = create_proc_entry("ppc64/lparcfg", mode, NULL); + if (ent) { + ent->proc_fops = &lparcfg_fops; + } else { printk(KERN_ERR "Failed to create ppc64/lparcfg\n"); return -EIO; } diff --git a/trunk/arch/powerpc/kernel/misc_32.S b/trunk/arch/powerpc/kernel/misc_32.S index 89aaaa6f3561..92ccc6fcc5b0 100644 --- a/trunk/arch/powerpc/kernel/misc_32.S +++ b/trunk/arch/powerpc/kernel/misc_32.S @@ -32,31 +32,6 @@ .text -#ifdef CONFIG_IRQSTACKS -_GLOBAL(call_do_softirq) - mflr r0 - stw r0,4(r1) - stwu r1,THREAD_SIZE-STACK_FRAME_OVERHEAD(r3) - mr r1,r3 - bl __do_softirq - lwz r1,0(r1) - lwz r0,4(r1) - mtlr r0 - blr - -_GLOBAL(call_handle_irq) - mflr r0 - stw r0,4(r1) - mtctr r6 - stwu r1,THREAD_SIZE-STACK_FRAME_OVERHEAD(r5) - mr r1,r5 - bctrl - lwz r1,0(r1) - lwz r0,4(r1) - mtlr r0 - blr -#endif /* CONFIG_IRQSTACKS */ - /* * This returns the high 64 bits of the product of two 64-bit numbers. */ diff --git a/trunk/arch/powerpc/kernel/proc_ppc64.c b/trunk/arch/powerpc/kernel/proc_ppc64.c index c647ddef40dc..f78dfce1b771 100644 --- a/trunk/arch/powerpc/kernel/proc_ppc64.c +++ b/trunk/arch/powerpc/kernel/proc_ppc64.c @@ -68,11 +68,12 @@ static int __init proc_ppc64_init(void) { struct proc_dir_entry *pde; - pde = proc_create_data("ppc64/systemcfg", S_IFREG|S_IRUGO, NULL, - &page_map_fops, vdso_data); + pde = create_proc_entry("ppc64/systemcfg", S_IFREG|S_IRUGO, NULL); if (!pde) return 1; + pde->data = vdso_data; pde->size = PAGE_SIZE; + pde->proc_fops = &page_map_fops; return 0; } diff --git a/trunk/arch/powerpc/kernel/process.c b/trunk/arch/powerpc/kernel/process.c index 7de41c3948ec..6caad17ea72e 100644 --- a/trunk/arch/powerpc/kernel/process.c +++ b/trunk/arch/powerpc/kernel/process.c @@ -589,8 +589,6 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp, kregs = (struct pt_regs *) sp; sp -= STACK_FRAME_OVERHEAD; p->thread.ksp = sp; - p->thread.ksp_limit = (unsigned long)task_stack_page(p) + - _ALIGN_UP(sizeof(struct thread_info), 16); #ifdef CONFIG_PPC64 if (cpu_has_feature(CPU_FTR_SLB)) { diff --git a/trunk/arch/powerpc/kernel/rio.c b/trunk/arch/powerpc/kernel/rio.c new file mode 100644 index 000000000000..29487fedfc76 --- /dev/null +++ b/trunk/arch/powerpc/kernel/rio.c @@ -0,0 +1,52 @@ +/* + * RapidIO PPC32 support + * + * Copyright 2005 MontaVista Software, Inc. + * Matt Porter + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include +#include +#include + +#include + +/** + * platform_rio_init - Do platform specific RIO init + * + * Any platform specific initialization of RapdIO + * hardware is done here as well as registration + * of any active master ports in the system. + */ +void __attribute__ ((weak)) + platform_rio_init(void) +{ + printk(KERN_WARNING "RIO: No platform_rio_init() present\n"); +} + +/** + * ppc_rio_init - Do PPC32 RIO init + * + * Calls platform-specific RIO init code and then calls + * rio_init_mports() to initialize any master ports that + * have been registered with the RIO subsystem. + */ +static int __init ppc_rio_init(void) +{ + printk(KERN_INFO "RIO: RapidIO init\n"); + + /* Platform specific initialization */ + platform_rio_init(); + + /* Enumerate all registered ports */ + rio_init_mports(); + + return 0; +} + +subsys_initcall(ppc_rio_init); diff --git a/trunk/arch/powerpc/kernel/rtas-proc.c b/trunk/arch/powerpc/kernel/rtas-proc.c index f9c6abc84a94..f2e3bc714d76 100644 --- a/trunk/arch/powerpc/kernel/rtas-proc.c +++ b/trunk/arch/powerpc/kernel/rtas-proc.c @@ -255,6 +255,8 @@ static void check_location(struct seq_file *m, const char *c); static int __init proc_rtas_init(void) { + struct proc_dir_entry *entry; + if (!machine_is(pseries)) return -ENODEV; @@ -262,20 +264,35 @@ static int __init proc_rtas_init(void) if (rtas_node == NULL) return -ENODEV; - proc_create("ppc64/rtas/progress", S_IRUGO|S_IWUSR, NULL, - &ppc_rtas_progress_operations); - proc_create("ppc64/rtas/clock", S_IRUGO|S_IWUSR, NULL, - &ppc_rtas_clock_operations); - proc_create("ppc64/rtas/poweron", S_IWUSR|S_IRUGO, NULL, - &ppc_rtas_poweron_operations); - proc_create("ppc64/rtas/sensors", S_IRUGO, NULL, - &ppc_rtas_sensors_operations); - proc_create("ppc64/rtas/frequency", S_IWUSR|S_IRUGO, NULL, - &ppc_rtas_tone_freq_operations); - proc_create("ppc64/rtas/volume", S_IWUSR|S_IRUGO, NULL, - &ppc_rtas_tone_volume_operations); - proc_create("ppc64/rtas/rmo_buffer", S_IRUSR, NULL, - &ppc_rtas_rmo_buf_ops); + entry = create_proc_entry("ppc64/rtas/progress", S_IRUGO|S_IWUSR, NULL); + if (entry) + entry->proc_fops = &ppc_rtas_progress_operations; + + entry = create_proc_entry("ppc64/rtas/clock", S_IRUGO|S_IWUSR, NULL); + if (entry) + entry->proc_fops = &ppc_rtas_clock_operations; + + entry = create_proc_entry("ppc64/rtas/poweron", S_IWUSR|S_IRUGO, NULL); + if (entry) + entry->proc_fops = &ppc_rtas_poweron_operations; + + entry = create_proc_entry("ppc64/rtas/sensors", S_IRUGO, NULL); + if (entry) + entry->proc_fops = &ppc_rtas_sensors_operations; + + entry = create_proc_entry("ppc64/rtas/frequency", S_IWUSR|S_IRUGO, + NULL); + if (entry) + entry->proc_fops = &ppc_rtas_tone_freq_operations; + + entry = create_proc_entry("ppc64/rtas/volume", S_IWUSR|S_IRUGO, NULL); + if (entry) + entry->proc_fops = &ppc_rtas_tone_volume_operations; + + entry = create_proc_entry("ppc64/rtas/rmo_buffer", S_IRUSR, NULL); + if (entry) + entry->proc_fops = &ppc_rtas_rmo_buf_ops; + return 0; } diff --git a/trunk/arch/powerpc/kernel/rtas_flash.c b/trunk/arch/powerpc/kernel/rtas_flash.c index 0a5e22b22729..627f126d1848 100644 --- a/trunk/arch/powerpc/kernel/rtas_flash.c +++ b/trunk/arch/powerpc/kernel/rtas_flash.c @@ -704,11 +704,18 @@ static int initialize_flash_pde_data(const char *rtas_call_name, static struct proc_dir_entry *create_flash_pde(const char *filename, const struct file_operations *fops) { - return proc_create(filename, S_IRUSR | S_IWUSR, NULL, fops); + struct proc_dir_entry *ent = NULL; + + ent = create_proc_entry(filename, S_IRUSR | S_IWUSR, NULL); + if (ent != NULL) { + ent->proc_fops = fops; + ent->owner = THIS_MODULE; + } + + return ent; } static const struct file_operations rtas_flash_operations = { - .owner = THIS_MODULE, .read = rtas_flash_read, .write = rtas_flash_write, .open = rtas_excl_open, @@ -716,7 +723,6 @@ static const struct file_operations rtas_flash_operations = { }; static const struct file_operations manage_flash_operations = { - .owner = THIS_MODULE, .read = manage_flash_read, .write = manage_flash_write, .open = rtas_excl_open, @@ -724,7 +730,6 @@ static const struct file_operations manage_flash_operations = { }; static const struct file_operations validate_flash_operations = { - .owner = THIS_MODULE, .read = validate_flash_read, .write = validate_flash_write, .open = rtas_excl_open, diff --git a/trunk/arch/powerpc/kernel/setup_32.c b/trunk/arch/powerpc/kernel/setup_32.c index 5112a4aa801d..36f6779c88d4 100644 --- a/trunk/arch/powerpc/kernel/setup_32.c +++ b/trunk/arch/powerpc/kernel/setup_32.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include @@ -230,24 +229,6 @@ int __init ppc_init(void) arch_initcall(ppc_init); -#ifdef CONFIG_IRQSTACKS -static void __init irqstack_early_init(void) -{ - unsigned int i; - - /* interrupt stacks must be in lowmem, we get that for free on ppc32 - * as the lmb is limited to lowmem by LMB_REAL_LIMIT */ - for_each_possible_cpu(i) { - softirq_ctx[i] = (struct thread_info *) - __va(lmb_alloc(THREAD_SIZE, THREAD_SIZE)); - hardirq_ctx[i] = (struct thread_info *) - __va(lmb_alloc(THREAD_SIZE, THREAD_SIZE)); - } -} -#else -#define irqstack_early_init() -#endif - /* Warning, IO base is not yet inited */ void __init setup_arch(char **cmdline_p) { @@ -305,8 +286,6 @@ void __init setup_arch(char **cmdline_p) init_mm.end_data = (unsigned long) _edata; init_mm.brk = klimit; - irqstack_early_init(); - /* set up the bootmem stuff with available memory */ do_init_bootmem(); if ( ppc_md.progress ) ppc_md.progress("setup_arch: bootmem", 0x3eab); diff --git a/trunk/arch/powerpc/mm/mem.c b/trunk/arch/powerpc/mm/mem.c index f67e118116fa..d9e37f365b54 100644 --- a/trunk/arch/powerpc/mm/mem.c +++ b/trunk/arch/powerpc/mm/mem.c @@ -154,35 +154,19 @@ int remove_memory(u64 start, u64 size) /* * walk_memory_resource() needs to make sure there is no holes in a given - * memory range. PPC64 does not maintain the memory layout in /proc/iomem. - * Instead it maintains it in lmb.memory structures. Walk through the - * memory regions, find holes and callback for contiguous regions. + * memory range. On PPC64, since this range comes from /sysfs, the range + * is guaranteed to be valid, non-overlapping and can not contain any + * holes. By the time we get here (memory add or remove), /proc/device-tree + * is updated and correct. Only reason we need to check against device-tree + * would be if we allow user-land to specify a memory range through a + * system call/ioctl etc. instead of doing offline/online through /sysfs. */ int walk_memory_resource(unsigned long start_pfn, unsigned long nr_pages, void *arg, int (*func)(unsigned long, unsigned long, void *)) { - struct lmb_property res; - unsigned long pfn, len; - u64 end; - int ret = -1; - - res.base = (u64) start_pfn << PAGE_SHIFT; - res.size = (u64) nr_pages << PAGE_SHIFT; - - end = res.base + res.size - 1; - while ((res.base < end) && (lmb_find(&res) >= 0)) { - pfn = (unsigned long)(res.base >> PAGE_SHIFT); - len = (unsigned long)(res.size >> PAGE_SHIFT); - ret = (*func)(pfn, len, arg); - if (ret) - break; - res.base += (res.size + 1); - res.size = (end - res.base + 1); - } - return ret; + return (*func)(start_pfn, nr_pages, arg); } -EXPORT_SYMBOL_GPL(walk_memory_resource); #endif /* CONFIG_MEMORY_HOTPLUG */ diff --git a/trunk/arch/powerpc/platforms/86xx/Kconfig b/trunk/arch/powerpc/platforms/86xx/Kconfig index 053f49a1dcae..7442c58d44f5 100644 --- a/trunk/arch/powerpc/platforms/86xx/Kconfig +++ b/trunk/arch/powerpc/platforms/86xx/Kconfig @@ -8,7 +8,6 @@ config MPC8641_HPCN select PPC_I8259 select DEFAULT_UIMAGE select FSL_ULI1575 - select HAS_RAPIDIO help This option enables support for the MPC8641 HPCN board. diff --git a/trunk/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c b/trunk/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c index f13704aabbea..f947f555fd46 100644 --- a/trunk/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c +++ b/trunk/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c @@ -221,7 +221,6 @@ mpc86xx_time_init(void) static __initdata struct of_device_id of_bus_ids[] = { { .compatible = "simple-bus", }, - { .compatible = "fsl,rapidio-delta", }, {}, }; diff --git a/trunk/arch/powerpc/platforms/cell/spufs/sched.c b/trunk/arch/powerpc/platforms/cell/spufs/sched.c index 45dcd2693502..00528ef84ad2 100644 --- a/trunk/arch/powerpc/platforms/cell/spufs/sched.c +++ b/trunk/arch/powerpc/platforms/cell/spufs/sched.c @@ -1063,9 +1063,10 @@ int __init spu_sched_init(void) mod_timer(&spuloadavg_timer, 0); - entry = proc_create("spu_loadavg", 0, NULL, &spu_loadavg_fops); + entry = create_proc_entry("spu_loadavg", 0, NULL); if (!entry) goto out_stop_kthread; + entry->proc_fops = &spu_loadavg_fops; pr_debug("spusched: tick: %d, min ticks: %d, default ticks: %d\n", SPUSCHED_TICK, MIN_SPU_TIMESLICE, DEF_SPU_TIMESLICE); diff --git a/trunk/arch/powerpc/platforms/cell/spufs/sputrace.c b/trunk/arch/powerpc/platforms/cell/spufs/sputrace.c index aea5286f1245..79aa773f3c99 100644 --- a/trunk/arch/powerpc/platforms/cell/spufs/sputrace.c +++ b/trunk/arch/powerpc/platforms/cell/spufs/sputrace.c @@ -201,9 +201,10 @@ static int __init sputrace_init(void) if (!sputrace_log) goto out; - entry = proc_create("sputrace", S_IRUSR, NULL, &sputrace_fops); + entry = create_proc_entry("sputrace", S_IRUSR, NULL); if (!entry) goto out_free_log; + entry->proc_fops = &sputrace_fops; for (i = 0; i < ARRAY_SIZE(spu_probes); i++) { struct spu_probe *p = &spu_probes[i]; diff --git a/trunk/arch/powerpc/platforms/iseries/lpevents.c b/trunk/arch/powerpc/platforms/iseries/lpevents.c index b0f8a857ec02..e5b40e3e0082 100644 --- a/trunk/arch/powerpc/platforms/iseries/lpevents.c +++ b/trunk/arch/powerpc/platforms/iseries/lpevents.c @@ -330,11 +330,15 @@ static const struct file_operations proc_lpevents_operations = { static int __init proc_lpevents_init(void) { + struct proc_dir_entry *e; + if (!firmware_has_feature(FW_FEATURE_ISERIES)) return 0; - proc_create("iSeries/lpevents", S_IFREG|S_IRUGO, NULL, - &proc_lpevents_operations); + e = create_proc_entry("iSeries/lpevents", S_IFREG|S_IRUGO, NULL); + if (e) + e->proc_fops = &proc_lpevents_operations; + return 0; } __initcall(proc_lpevents_init); diff --git a/trunk/arch/powerpc/platforms/iseries/mf.c b/trunk/arch/powerpc/platforms/iseries/mf.c index 1dc7295746da..c0f2433bc16e 100644 --- a/trunk/arch/powerpc/platforms/iseries/mf.c +++ b/trunk/arch/powerpc/platforms/iseries/mf.c @@ -1255,11 +1255,11 @@ static int __init mf_proc_init(void) if (i == 3) /* no vmlinux entry for 'D' */ continue; - ent = proc_create_data("vmlinux", S_IFREG|S_IWUSR, mf, - &proc_vmlinux_operations, - (void *)(long)i); + ent = create_proc_entry("vmlinux", S_IFREG|S_IWUSR, mf); if (!ent) return 1; + ent->data = (void *)(long)i; + ent->proc_fops = &proc_vmlinux_operations; } ent = create_proc_entry("side", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root); diff --git a/trunk/arch/powerpc/platforms/iseries/proc.c b/trunk/arch/powerpc/platforms/iseries/proc.c index 91f4c6cd4b99..f2cde4180204 100644 --- a/trunk/arch/powerpc/platforms/iseries/proc.c +++ b/trunk/arch/powerpc/platforms/iseries/proc.c @@ -110,11 +110,15 @@ static const struct file_operations proc_titantod_operations = { static int __init iseries_proc_init(void) { + struct proc_dir_entry *e; + if (!firmware_has_feature(FW_FEATURE_ISERIES)) return 0; - proc_create("iSeries/titanTod", S_IFREG|S_IRUGO, NULL, - &proc_titantod_operations); + e = create_proc_entry("iSeries/titanTod", S_IFREG|S_IRUGO, NULL); + if (e) + e->proc_fops = &proc_titantod_operations; + return 0; } __initcall(iseries_proc_init); diff --git a/trunk/arch/powerpc/platforms/iseries/viopath.c b/trunk/arch/powerpc/platforms/iseries/viopath.c index 49ff4dc422b7..df23331eb25c 100644 --- a/trunk/arch/powerpc/platforms/iseries/viopath.c +++ b/trunk/arch/powerpc/platforms/iseries/viopath.c @@ -180,10 +180,15 @@ static const struct file_operations proc_viopath_operations = { static int __init vio_proc_init(void) { + struct proc_dir_entry *e; + if (!firmware_has_feature(FW_FEATURE_ISERIES)) return 0; - proc_create("iSeries/config", 0, NULL, &proc_viopath_operations); + e = create_proc_entry("iSeries/config", 0, NULL); + if (e) + e->proc_fops = &proc_viopath_operations; + return 0; } __initcall(vio_proc_init); diff --git a/trunk/arch/powerpc/platforms/powermac/Makefile b/trunk/arch/powerpc/platforms/powermac/Makefile index 4d72c8f72159..78093d7f97af 100644 --- a/trunk/arch/powerpc/platforms/powermac/Makefile +++ b/trunk/arch/powerpc/platforms/powermac/Makefile @@ -6,10 +6,7 @@ obj-y += pic.o setup.o time.o feature.o pci.o \ obj-$(CONFIG_PMAC_BACKLIGHT) += backlight.o obj-$(CONFIG_CPU_FREQ_PMAC) += cpufreq_32.o obj-$(CONFIG_CPU_FREQ_PMAC64) += cpufreq_64.o -# CONFIG_NVRAM is an arch. independant tristate symbol, for pmac32 we really -# need this to be a bool. Cheat here and pretend CONFIG_NVRAM=m is really -# CONFIG_NVRAM=y -obj-$(CONFIG_NVRAM:m=y) += nvram.o +obj-$(CONFIG_NVRAM) += nvram.o # ppc64 pmac doesn't define CONFIG_NVRAM but needs nvram stuff obj-$(CONFIG_PPC64) += nvram.o obj-$(CONFIG_PPC32) += bootx_init.o diff --git a/trunk/arch/powerpc/platforms/powermac/setup.c b/trunk/arch/powerpc/platforms/powermac/setup.c index 00bd0166d07f..bf44c5441a36 100644 --- a/trunk/arch/powerpc/platforms/powermac/setup.c +++ b/trunk/arch/powerpc/platforms/powermac/setup.c @@ -337,8 +337,7 @@ static void __init pmac_setup_arch(void) find_via_pmu(); smu_init(); -#if defined(CONFIG_NVRAM) || defined(CONFIG_NVRAM_MODULE) || \ - defined(CONFIG_PPC64) +#if defined(CONFIG_NVRAM) || defined(CONFIG_PPC64) pmac_nvram_init(); #endif diff --git a/trunk/arch/powerpc/platforms/pseries/Makefile b/trunk/arch/powerpc/platforms/pseries/Makefile index 554c6e42ef2a..bd2593ed28dd 100644 --- a/trunk/arch/powerpc/platforms/pseries/Makefile +++ b/trunk/arch/powerpc/platforms/pseries/Makefile @@ -18,7 +18,6 @@ obj-$(CONFIG_PCI) += pci.o pci_dlpar.o obj-$(CONFIG_PCI_MSI) += msi.o obj-$(CONFIG_HOTPLUG_CPU) += hotplug-cpu.o -obj-$(CONFIG_MEMORY_HOTPLUG) += hotplug-memory.o obj-$(CONFIG_HVC_CONSOLE) += hvconsole.o obj-$(CONFIG_HVCS) += hvcserver.o diff --git a/trunk/arch/powerpc/platforms/pseries/eeh.c b/trunk/arch/powerpc/platforms/pseries/eeh.c index 6f544ba4b37f..a3fd56b186e6 100644 --- a/trunk/arch/powerpc/platforms/pseries/eeh.c +++ b/trunk/arch/powerpc/platforms/pseries/eeh.c @@ -1259,8 +1259,14 @@ static const struct file_operations proc_eeh_operations = { static int __init eeh_init_proc(void) { - if (machine_is(pseries)) - proc_create("ppc64/eeh", 0, NULL, &proc_eeh_operations); + struct proc_dir_entry *e; + + if (machine_is(pseries)) { + e = create_proc_entry("ppc64/eeh", 0, NULL); + if (e) + e->proc_fops = &proc_eeh_operations; + } + return 0; } __initcall(eeh_init_proc); diff --git a/trunk/arch/powerpc/platforms/pseries/hotplug-memory.c b/trunk/arch/powerpc/platforms/pseries/hotplug-memory.c deleted file mode 100644 index 3c5727dd5aa5..000000000000 --- a/trunk/arch/powerpc/platforms/pseries/hotplug-memory.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * pseries Memory Hotplug infrastructure. - * - * Copyright (C) 2008 Badari Pulavarty, IBM Corporation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - */ - -#include -#include -#include -#include -#include - -static int pseries_remove_memory(struct device_node *np) -{ - const char *type; - const unsigned int *my_index; - const unsigned int *regs; - u64 start_pfn, start; - struct zone *zone; - int ret = -EINVAL; - - /* - * Check to see if we are actually removing memory - */ - type = of_get_property(np, "device_type", NULL); - if (type == NULL || strcmp(type, "memory") != 0) - return 0; - - /* - * Find the memory index and size of the removing section - */ - my_index = of_get_property(np, "ibm,my-drc-index", NULL); - if (!my_index) - return ret; - - regs = of_get_property(np, "reg", NULL); - if (!regs) - return ret; - - start_pfn = section_nr_to_pfn(*my_index & 0xffff); - zone = page_zone(pfn_to_page(start_pfn)); - - /* - * Remove section mappings and sysfs entries for the - * section of the memory we are removing. - * - * NOTE: Ideally, this should be done in generic code like - * remove_memory(). But remove_memory() gets called by writing - * to sysfs "state" file and we can't remove sysfs entries - * while writing to it. So we have to defer it to here. - */ - ret = __remove_pages(zone, start_pfn, regs[3] >> PAGE_SHIFT); - if (ret) - return ret; - - /* - * Update memory regions for memory remove - */ - lmb_remove(start_pfn << PAGE_SHIFT, regs[3]); - - /* - * Remove htab bolted mappings for this section of memory - */ - start = (unsigned long)__va(start_pfn << PAGE_SHIFT); - ret = remove_section_mapping(start, start + regs[3]); - return ret; -} - -static int pseries_add_memory(struct device_node *np) -{ - const char *type; - const unsigned int *my_index; - const unsigned int *regs; - u64 start_pfn; - int ret = -EINVAL; - - /* - * Check to see if we are actually adding memory - */ - type = of_get_property(np, "device_type", NULL); - if (type == NULL || strcmp(type, "memory") != 0) - return 0; - - /* - * Find the memory index and size of the added section - */ - my_index = of_get_property(np, "ibm,my-drc-index", NULL); - if (!my_index) - return ret; - - regs = of_get_property(np, "reg", NULL); - if (!regs) - return ret; - - start_pfn = section_nr_to_pfn(*my_index & 0xffff); - - /* - * Update memory region to represent the memory add - */ - lmb_add(start_pfn << PAGE_SHIFT, regs[3]); - return 0; -} - -static int pseries_memory_notifier(struct notifier_block *nb, - unsigned long action, void *node) -{ - int err = NOTIFY_OK; - - switch (action) { - case PSERIES_RECONFIG_ADD: - if (pseries_add_memory(node)) - err = NOTIFY_BAD; - break; - case PSERIES_RECONFIG_REMOVE: - if (pseries_remove_memory(node)) - err = NOTIFY_BAD; - break; - default: - err = NOTIFY_DONE; - break; - } - return err; -} - -static struct notifier_block pseries_mem_nb = { - .notifier_call = pseries_memory_notifier, -}; - -static int __init pseries_memory_hotplug_init(void) -{ - if (firmware_has_feature(FW_FEATURE_LPAR)) - pSeries_reconfig_notifier_register(&pseries_mem_nb); - - return 0; -} -machine_device_initcall(pseries, pseries_memory_hotplug_init); diff --git a/trunk/arch/powerpc/platforms/pseries/reconfig.c b/trunk/arch/powerpc/platforms/pseries/reconfig.c index 75769aae41d5..ac75c10de278 100644 --- a/trunk/arch/powerpc/platforms/pseries/reconfig.c +++ b/trunk/arch/powerpc/platforms/pseries/reconfig.c @@ -512,9 +512,12 @@ static int proc_ppc64_create_ofdt(void) if (!machine_is(pseries)) return 0; - ent = proc_create("ppc64/ofdt", S_IWUSR, NULL, &ofdt_fops); - if (ent) + ent = create_proc_entry("ppc64/ofdt", S_IWUSR, NULL); + if (ent) { + ent->data = NULL; ent->size = 0; + ent->proc_fops = &ofdt_fops; + } return 0; } diff --git a/trunk/arch/powerpc/platforms/pseries/rtasd.c b/trunk/arch/powerpc/platforms/pseries/rtasd.c index 7d3e2b0bd4d2..befadd4f9524 100644 --- a/trunk/arch/powerpc/platforms/pseries/rtasd.c +++ b/trunk/arch/powerpc/platforms/pseries/rtasd.c @@ -468,9 +468,10 @@ static int __init rtas_init(void) return -ENOMEM; } - entry = proc_create("ppc64/rtas/error_log", S_IRUSR, NULL, - &proc_rtas_log_operations); - if (!entry) + entry = create_proc_entry("ppc64/rtas/error_log", S_IRUSR, NULL); + if (entry) + entry->proc_fops = &proc_rtas_log_operations; + else printk(KERN_ERR "Failed to create error_log proc entry\n"); if (kernel_thread(rtasd, NULL, CLONE_FS) < 0) diff --git a/trunk/arch/powerpc/sysdev/fsl_rio.c b/trunk/arch/powerpc/sysdev/fsl_rio.c index 3d920376f58e..af2425e4655f 100644 --- a/trunk/arch/powerpc/sysdev/fsl_rio.c +++ b/trunk/arch/powerpc/sysdev/fsl_rio.c @@ -1,8 +1,5 @@ /* - * Freescale MPC85xx/MPC86xx RapidIO support - * - * Copyright (C) 2007, 2008 Freescale Semiconductor, Inc. - * Zhang Wei + * MPC85xx RapidIO support * * Copyright 2005 MontaVista Software, Inc. * Matt Porter @@ -20,23 +17,12 @@ #include #include #include -#include -#include #include -/* RapidIO definition irq, which read from OF-tree */ -#define IRQ_RIO_BELL(m) (((struct rio_priv *)(m->priv))->bellirq) -#define IRQ_RIO_TX(m) (((struct rio_priv *)(m->priv))->txirq) -#define IRQ_RIO_RX(m) (((struct rio_priv *)(m->priv))->rxirq) - +#define RIO_REGS_BASE (CCSRBAR + 0xc0000) #define RIO_ATMU_REGS_OFFSET 0x10c00 -#define RIO_P_MSG_REGS_OFFSET 0x11000 -#define RIO_S_MSG_REGS_OFFSET 0x13000 -#define RIO_ESCSR 0x158 -#define RIO_CCSR 0x15c -#define RIO_ISR_AACR 0x10120 -#define RIO_ISR_AACR_AA 0x1 /* Accept All ID */ +#define RIO_MSG_REGS_OFFSET 0x11000 #define RIO_MAINT_WIN_SIZE 0x400000 #define RIO_DBELL_WIN_SIZE 0x1000 @@ -64,18 +50,18 @@ #define DOORBELL_DSR_TE 0x00000080 #define DOORBELL_DSR_QFI 0x00000010 #define DOORBELL_DSR_DIQI 0x00000001 -#define DOORBELL_TID_OFFSET 0x02 -#define DOORBELL_SID_OFFSET 0x04 +#define DOORBELL_TID_OFFSET 0x03 +#define DOORBELL_SID_OFFSET 0x05 #define DOORBELL_INFO_OFFSET 0x06 #define DOORBELL_MESSAGE_SIZE 0x08 -#define DBELL_SID(x) (*(u16 *)(x + DOORBELL_SID_OFFSET)) -#define DBELL_TID(x) (*(u16 *)(x + DOORBELL_TID_OFFSET)) +#define DBELL_SID(x) (*(u8 *)(x + DOORBELL_SID_OFFSET)) +#define DBELL_TID(x) (*(u8 *)(x + DOORBELL_TID_OFFSET)) #define DBELL_INF(x) (*(u16 *)(x + DOORBELL_INFO_OFFSET)) struct rio_atmu_regs { u32 rowtar; - u32 rowtear; + u32 pad1; u32 rowbar; u32 pad2; u32 rowar; @@ -101,15 +87,7 @@ struct rio_msg_regs { u32 ifqdpar; u32 pad6; u32 ifqepar; - u32 pad7[226]; - u32 odmr; - u32 odsr; - u32 res0[4]; - u32 oddpr; - u32 oddatr; - u32 res1[3]; - u32 odretcr; - u32 res2[12]; + u32 pad7[250]; u32 dmr; u32 dsr; u32 pad8; @@ -134,12 +112,20 @@ struct rio_tx_desc { u32 res4; }; -struct rio_dbell_ring { +static u32 regs_win; +static struct rio_atmu_regs *atmu_regs; +static struct rio_atmu_regs *maint_atmu_regs; +static struct rio_atmu_regs *dbell_atmu_regs; +static u32 dbell_win; +static u32 maint_win; +static struct rio_msg_regs *msg_regs; + +static struct rio_dbell_ring { void *virt; dma_addr_t phys; -}; +} dbell_ring; -struct rio_msg_tx_ring { +static struct rio_msg_tx_ring { void *virt; dma_addr_t phys; void *virt_buffer[RIO_MAX_TX_RING_SIZE]; @@ -147,35 +133,19 @@ struct rio_msg_tx_ring { int tx_slot; int size; void *dev_id; -}; +} msg_tx_ring; -struct rio_msg_rx_ring { +static struct rio_msg_rx_ring { void *virt; dma_addr_t phys; void *virt_buffer[RIO_MAX_RX_RING_SIZE]; int rx_slot; int size; void *dev_id; -}; - -struct rio_priv { - void __iomem *regs_win; - struct rio_atmu_regs __iomem *atmu_regs; - struct rio_atmu_regs __iomem *maint_atmu_regs; - struct rio_atmu_regs __iomem *dbell_atmu_regs; - void __iomem *dbell_win; - void __iomem *maint_win; - struct rio_msg_regs __iomem *msg_regs; - struct rio_dbell_ring dbell_ring; - struct rio_msg_tx_ring msg_tx_ring; - struct rio_msg_rx_ring msg_rx_ring; - int bellirq; - int txirq; - int rxirq; -}; +} msg_rx_ring; /** - * fsl_rio_doorbell_send - Send a MPC85xx doorbell message + * mpc85xx_rio_doorbell_send - Send a MPC85xx doorbell message * @index: ID of RapidIO interface * @destid: Destination ID of target device * @data: 16-bit info field of RapidIO doorbell message @@ -183,34 +153,18 @@ struct rio_priv { * Sends a MPC85xx doorbell message. Returns %0 on success or * %-EINVAL on failure. */ -static int fsl_rio_doorbell_send(struct rio_mport *mport, - int index, u16 destid, u16 data) +static int mpc85xx_rio_doorbell_send(int index, u16 destid, u16 data) { - struct rio_priv *priv = mport->priv; - pr_debug("fsl_doorbell_send: index %d destid %4.4x data %4.4x\n", + pr_debug("mpc85xx_doorbell_send: index %d destid %4.4x data %4.4x\n", index, destid, data); - switch (mport->phy_type) { - case RIO_PHY_PARALLEL: - out_be32(&priv->dbell_atmu_regs->rowtar, destid << 22); - out_be16(priv->dbell_win, data); - break; - case RIO_PHY_SERIAL: - /* In the serial version silicons, such as MPC8548, MPC8641, - * below operations is must be. - */ - out_be32(&priv->msg_regs->odmr, 0x00000000); - out_be32(&priv->msg_regs->odretcr, 0x00000004); - out_be32(&priv->msg_regs->oddpr, destid << 16); - out_be32(&priv->msg_regs->oddatr, data); - out_be32(&priv->msg_regs->odmr, 0x00000001); - break; - } + out_be32((void *)&dbell_atmu_regs->rowtar, destid << 22); + out_be16((void *)(dbell_win), data); return 0; } /** - * fsl_local_config_read - Generate a MPC85xx local config space read + * mpc85xx_local_config_read - Generate a MPC85xx local config space read * @index: ID of RapdiIO interface * @offset: Offset into configuration space * @len: Length (in bytes) of the maintenance transaction @@ -219,19 +173,17 @@ static int fsl_rio_doorbell_send(struct rio_mport *mport, * Generates a MPC85xx local configuration space read. Returns %0 on * success or %-EINVAL on failure. */ -static int fsl_local_config_read(struct rio_mport *mport, - int index, u32 offset, int len, u32 *data) +static int mpc85xx_local_config_read(int index, u32 offset, int len, u32 * data) { - struct rio_priv *priv = mport->priv; - pr_debug("fsl_local_config_read: index %d offset %8.8x\n", index, + pr_debug("mpc85xx_local_config_read: index %d offset %8.8x\n", index, offset); - *data = in_be32(priv->regs_win + offset); + *data = in_be32((void *)(regs_win + offset)); return 0; } /** - * fsl_local_config_write - Generate a MPC85xx local config space write + * mpc85xx_local_config_write - Generate a MPC85xx local config space write * @index: ID of RapdiIO interface * @offset: Offset into configuration space * @len: Length (in bytes) of the maintenance transaction @@ -240,20 +192,18 @@ static int fsl_local_config_read(struct rio_mport *mport, * Generates a MPC85xx local configuration space write. Returns %0 on * success or %-EINVAL on failure. */ -static int fsl_local_config_write(struct rio_mport *mport, - int index, u32 offset, int len, u32 data) +static int mpc85xx_local_config_write(int index, u32 offset, int len, u32 data) { - struct rio_priv *priv = mport->priv; pr_debug - ("fsl_local_config_write: index %d offset %8.8x data %8.8x\n", + ("mpc85xx_local_config_write: index %d offset %8.8x data %8.8x\n", index, offset, data); - out_be32(priv->regs_win + offset, data); + out_be32((void *)(regs_win + offset), data); return 0; } /** - * fsl_rio_config_read - Generate a MPC85xx read maintenance transaction + * mpc85xx_rio_config_read - Generate a MPC85xx read maintenance transaction * @index: ID of RapdiIO interface * @destid: Destination ID of transaction * @hopcount: Number of hops to target device @@ -265,19 +215,18 @@ static int fsl_local_config_write(struct rio_mport *mport, * success or %-EINVAL on failure. */ static int -fsl_rio_config_read(struct rio_mport *mport, int index, u16 destid, - u8 hopcount, u32 offset, int len, u32 *val) +mpc85xx_rio_config_read(int index, u16 destid, u8 hopcount, u32 offset, int len, + u32 * val) { - struct rio_priv *priv = mport->priv; u8 *data; pr_debug - ("fsl_rio_config_read: index %d destid %d hopcount %d offset %8.8x len %d\n", + ("mpc85xx_rio_config_read: index %d destid %d hopcount %d offset %8.8x len %d\n", index, destid, hopcount, offset, len); - out_be32(&priv->maint_atmu_regs->rowtar, + out_be32((void *)&maint_atmu_regs->rowtar, (destid << 22) | (hopcount << 12) | ((offset & ~0x3) >> 9)); - data = (u8 *) priv->maint_win + offset; + data = (u8 *) maint_win + offset; switch (len) { case 1: *val = in_8((u8 *) data); @@ -294,7 +243,7 @@ fsl_rio_config_read(struct rio_mport *mport, int index, u16 destid, } /** - * fsl_rio_config_write - Generate a MPC85xx write maintenance transaction + * mpc85xx_rio_config_write - Generate a MPC85xx write maintenance transaction * @index: ID of RapdiIO interface * @destid: Destination ID of transaction * @hopcount: Number of hops to target device @@ -306,18 +255,17 @@ fsl_rio_config_read(struct rio_mport *mport, int index, u16 destid, * success or %-EINVAL on failure. */ static int -fsl_rio_config_write(struct rio_mport *mport, int index, u16 destid, - u8 hopcount, u32 offset, int len, u32 val) +mpc85xx_rio_config_write(int index, u16 destid, u8 hopcount, u32 offset, + int len, u32 val) { - struct rio_priv *priv = mport->priv; u8 *data; pr_debug - ("fsl_rio_config_write: index %d destid %d hopcount %d offset %8.8x len %d val %8.8x\n", + ("mpc85xx_rio_config_write: index %d destid %d hopcount %d offset %8.8x len %d val %8.8x\n", index, destid, hopcount, offset, len, val); - out_be32(&priv->maint_atmu_regs->rowtar, + out_be32((void *)&maint_atmu_regs->rowtar, (destid << 22) | (hopcount << 12) | ((offset & ~0x3) >> 9)); - data = (u8 *) priv->maint_win + offset; + data = (u8 *) maint_win + offset; switch (len) { case 1: out_8((u8 *) data, val); @@ -348,10 +296,9 @@ int rio_hw_add_outb_message(struct rio_mport *mport, struct rio_dev *rdev, int mbox, void *buffer, size_t len) { - struct rio_priv *priv = mport->priv; u32 omr; - struct rio_tx_desc *desc = (struct rio_tx_desc *)priv->msg_tx_ring.virt - + priv->msg_tx_ring.tx_slot; + struct rio_tx_desc *desc = + (struct rio_tx_desc *)msg_tx_ring.virt + msg_tx_ring.tx_slot; int ret = 0; pr_debug @@ -364,43 +311,31 @@ rio_hw_add_outb_message(struct rio_mport *mport, struct rio_dev *rdev, int mbox, } /* Copy and clear rest of buffer */ - memcpy(priv->msg_tx_ring.virt_buffer[priv->msg_tx_ring.tx_slot], buffer, - len); + memcpy(msg_tx_ring.virt_buffer[msg_tx_ring.tx_slot], buffer, len); if (len < (RIO_MAX_MSG_SIZE - 4)) - memset(priv->msg_tx_ring.virt_buffer[priv->msg_tx_ring.tx_slot] - + len, 0, RIO_MAX_MSG_SIZE - len); + memset((void *)((u32) msg_tx_ring. + virt_buffer[msg_tx_ring.tx_slot] + len), 0, + RIO_MAX_MSG_SIZE - len); - switch (mport->phy_type) { - case RIO_PHY_PARALLEL: - /* Set mbox field for message */ - desc->dport = mbox & 0x3; + /* Set mbox field for message */ + desc->dport = mbox & 0x3; - /* Enable EOMI interrupt, set priority, and set destid */ - desc->dattr = 0x28000000 | (rdev->destid << 2); - break; - case RIO_PHY_SERIAL: - /* Set mbox field for message, and set destid */ - desc->dport = (rdev->destid << 16) | (mbox & 0x3); - - /* Enable EOMI interrupt and priority */ - desc->dattr = 0x28000000; - break; - } + /* Enable EOMI interrupt, set priority, and set destid */ + desc->dattr = 0x28000000 | (rdev->destid << 2); /* Set transfer size aligned to next power of 2 (in double words) */ desc->dwcnt = is_power_of_2(len) ? len : 1 << get_bitmask_order(len); /* Set snooping and source buffer address */ - desc->saddr = 0x00000004 - | priv->msg_tx_ring.phys_buffer[priv->msg_tx_ring.tx_slot]; + desc->saddr = 0x00000004 | msg_tx_ring.phys_buffer[msg_tx_ring.tx_slot]; /* Increment enqueue pointer */ - omr = in_be32(&priv->msg_regs->omr); - out_be32(&priv->msg_regs->omr, omr | RIO_MSG_OMR_MUI); + omr = in_be32((void *)&msg_regs->omr); + out_be32((void *)&msg_regs->omr, omr | RIO_MSG_OMR_MUI); /* Go to next descriptor */ - if (++priv->msg_tx_ring.tx_slot == priv->msg_tx_ring.size) - priv->msg_tx_ring.tx_slot = 0; + if (++msg_tx_ring.tx_slot == msg_tx_ring.size) + msg_tx_ring.tx_slot = 0; out: return ret; @@ -409,7 +344,7 @@ rio_hw_add_outb_message(struct rio_mport *mport, struct rio_dev *rdev, int mbox, EXPORT_SYMBOL_GPL(rio_hw_add_outb_message); /** - * fsl_rio_tx_handler - MPC85xx outbound message interrupt handler + * mpc85xx_rio_tx_handler - MPC85xx outbound message interrupt handler * @irq: Linux interrupt number * @dev_instance: Pointer to interrupt-specific data * @@ -417,34 +352,32 @@ EXPORT_SYMBOL_GPL(rio_hw_add_outb_message); * mailbox event handler and acks the interrupt occurrence. */ static irqreturn_t -fsl_rio_tx_handler(int irq, void *dev_instance) +mpc85xx_rio_tx_handler(int irq, void *dev_instance) { int osr; struct rio_mport *port = (struct rio_mport *)dev_instance; - struct rio_priv *priv = port->priv; - osr = in_be32(&priv->msg_regs->osr); + osr = in_be32((void *)&msg_regs->osr); if (osr & RIO_MSG_OSR_TE) { pr_info("RIO: outbound message transmission error\n"); - out_be32(&priv->msg_regs->osr, RIO_MSG_OSR_TE); + out_be32((void *)&msg_regs->osr, RIO_MSG_OSR_TE); goto out; } if (osr & RIO_MSG_OSR_QOI) { pr_info("RIO: outbound message queue overflow\n"); - out_be32(&priv->msg_regs->osr, RIO_MSG_OSR_QOI); + out_be32((void *)&msg_regs->osr, RIO_MSG_OSR_QOI); goto out; } if (osr & RIO_MSG_OSR_EOMI) { - u32 dqp = in_be32(&priv->msg_regs->odqdpar); - int slot = (dqp - priv->msg_tx_ring.phys) >> 5; - port->outb_msg[0].mcback(port, priv->msg_tx_ring.dev_id, -1, - slot); + u32 dqp = in_be32((void *)&msg_regs->odqdpar); + int slot = (dqp - msg_tx_ring.phys) >> 5; + port->outb_msg[0].mcback(port, msg_tx_ring.dev_id, -1, slot); /* Ack the end-of-message interrupt */ - out_be32(&priv->msg_regs->osr, RIO_MSG_OSR_EOMI); + out_be32((void *)&msg_regs->osr, RIO_MSG_OSR_EOMI); } out: @@ -465,7 +398,6 @@ fsl_rio_tx_handler(int irq, void *dev_instance) int rio_open_outb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entries) { int i, j, rc = 0; - struct rio_priv *priv = mport->priv; if ((entries < RIO_MIN_TX_RING_SIZE) || (entries > RIO_MAX_TX_RING_SIZE) || (!is_power_of_2(entries))) { @@ -474,53 +406,54 @@ int rio_open_outb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entr } /* Initialize shadow copy ring */ - priv->msg_tx_ring.dev_id = dev_id; - priv->msg_tx_ring.size = entries; - - for (i = 0; i < priv->msg_tx_ring.size; i++) { - priv->msg_tx_ring.virt_buffer[i] = - dma_alloc_coherent(NULL, RIO_MSG_BUFFER_SIZE, - &priv->msg_tx_ring.phys_buffer[i], GFP_KERNEL); - if (!priv->msg_tx_ring.virt_buffer[i]) { + msg_tx_ring.dev_id = dev_id; + msg_tx_ring.size = entries; + + for (i = 0; i < msg_tx_ring.size; i++) { + if (! + (msg_tx_ring.virt_buffer[i] = + dma_alloc_coherent(NULL, RIO_MSG_BUFFER_SIZE, + &msg_tx_ring.phys_buffer[i], + GFP_KERNEL))) { rc = -ENOMEM; - for (j = 0; j < priv->msg_tx_ring.size; j++) - if (priv->msg_tx_ring.virt_buffer[j]) + for (j = 0; j < msg_tx_ring.size; j++) + if (msg_tx_ring.virt_buffer[j]) dma_free_coherent(NULL, - RIO_MSG_BUFFER_SIZE, - priv->msg_tx_ring. - virt_buffer[j], - priv->msg_tx_ring. - phys_buffer[j]); + RIO_MSG_BUFFER_SIZE, + msg_tx_ring. + virt_buffer[j], + msg_tx_ring. + phys_buffer[j]); goto out; } } /* Initialize outbound message descriptor ring */ - priv->msg_tx_ring.virt = dma_alloc_coherent(NULL, - priv->msg_tx_ring.size * RIO_MSG_DESC_SIZE, - &priv->msg_tx_ring.phys, GFP_KERNEL); - if (!priv->msg_tx_ring.virt) { + if (!(msg_tx_ring.virt = dma_alloc_coherent(NULL, + msg_tx_ring.size * + RIO_MSG_DESC_SIZE, + &msg_tx_ring.phys, + GFP_KERNEL))) { rc = -ENOMEM; goto out_dma; } - memset(priv->msg_tx_ring.virt, 0, - priv->msg_tx_ring.size * RIO_MSG_DESC_SIZE); - priv->msg_tx_ring.tx_slot = 0; + memset(msg_tx_ring.virt, 0, msg_tx_ring.size * RIO_MSG_DESC_SIZE); + msg_tx_ring.tx_slot = 0; /* Point dequeue/enqueue pointers at first entry in ring */ - out_be32(&priv->msg_regs->odqdpar, priv->msg_tx_ring.phys); - out_be32(&priv->msg_regs->odqepar, priv->msg_tx_ring.phys); + out_be32((void *)&msg_regs->odqdpar, msg_tx_ring.phys); + out_be32((void *)&msg_regs->odqepar, msg_tx_ring.phys); /* Configure for snooping */ - out_be32(&priv->msg_regs->osar, 0x00000004); + out_be32((void *)&msg_regs->osar, 0x00000004); /* Clear interrupt status */ - out_be32(&priv->msg_regs->osr, 0x000000b3); + out_be32((void *)&msg_regs->osr, 0x000000b3); /* Hook up outbound message handler */ - rc = request_irq(IRQ_RIO_TX(mport), fsl_rio_tx_handler, 0, - "msg_tx", (void *)mport); - if (rc < 0) + if ((rc = + request_irq(MPC85xx_IRQ_RIO_TX, mpc85xx_rio_tx_handler, 0, + "msg_tx", (void *)mport)) < 0) goto out_irq; /* @@ -530,28 +463,28 @@ int rio_open_outb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entr * Chaining mode * Disable */ - out_be32(&priv->msg_regs->omr, 0x00100220); + out_be32((void *)&msg_regs->omr, 0x00100220); /* Set number of entries */ - out_be32(&priv->msg_regs->omr, - in_be32(&priv->msg_regs->omr) | + out_be32((void *)&msg_regs->omr, + in_be32((void *)&msg_regs->omr) | ((get_bitmask_order(entries) - 2) << 12)); /* Now enable the unit */ - out_be32(&priv->msg_regs->omr, in_be32(&priv->msg_regs->omr) | 0x1); + out_be32((void *)&msg_regs->omr, in_be32((void *)&msg_regs->omr) | 0x1); out: return rc; out_irq: - dma_free_coherent(NULL, priv->msg_tx_ring.size * RIO_MSG_DESC_SIZE, - priv->msg_tx_ring.virt, priv->msg_tx_ring.phys); + dma_free_coherent(NULL, msg_tx_ring.size * RIO_MSG_DESC_SIZE, + msg_tx_ring.virt, msg_tx_ring.phys); out_dma: - for (i = 0; i < priv->msg_tx_ring.size; i++) + for (i = 0; i < msg_tx_ring.size; i++) dma_free_coherent(NULL, RIO_MSG_BUFFER_SIZE, - priv->msg_tx_ring.virt_buffer[i], - priv->msg_tx_ring.phys_buffer[i]); + msg_tx_ring.virt_buffer[i], + msg_tx_ring.phys_buffer[i]); return rc; } @@ -566,20 +499,19 @@ int rio_open_outb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entr */ void rio_close_outb_mbox(struct rio_mport *mport, int mbox) { - struct rio_priv *priv = mport->priv; /* Disable inbound message unit */ - out_be32(&priv->msg_regs->omr, 0); + out_be32((void *)&msg_regs->omr, 0); /* Free ring */ - dma_free_coherent(NULL, priv->msg_tx_ring.size * RIO_MSG_DESC_SIZE, - priv->msg_tx_ring.virt, priv->msg_tx_ring.phys); + dma_free_coherent(NULL, msg_tx_ring.size * RIO_MSG_DESC_SIZE, + msg_tx_ring.virt, msg_tx_ring.phys); /* Free interrupt */ - free_irq(IRQ_RIO_TX(mport), (void *)mport); + free_irq(MPC85xx_IRQ_RIO_TX, (void *)mport); } /** - * fsl_rio_rx_handler - MPC85xx inbound message interrupt handler + * mpc85xx_rio_rx_handler - MPC85xx inbound message interrupt handler * @irq: Linux interrupt number * @dev_instance: Pointer to interrupt-specific data * @@ -587,17 +519,16 @@ void rio_close_outb_mbox(struct rio_mport *mport, int mbox) * mailbox event handler and acks the interrupt occurrence. */ static irqreturn_t -fsl_rio_rx_handler(int irq, void *dev_instance) +mpc85xx_rio_rx_handler(int irq, void *dev_instance) { int isr; struct rio_mport *port = (struct rio_mport *)dev_instance; - struct rio_priv *priv = port->priv; - isr = in_be32(&priv->msg_regs->isr); + isr = in_be32((void *)&msg_regs->isr); if (isr & RIO_MSG_ISR_TE) { pr_info("RIO: inbound message reception error\n"); - out_be32((void *)&priv->msg_regs->isr, RIO_MSG_ISR_TE); + out_be32((void *)&msg_regs->isr, RIO_MSG_ISR_TE); goto out; } @@ -609,10 +540,10 @@ fsl_rio_rx_handler(int irq, void *dev_instance) * make the callback with an unknown/invalid mailbox number * argument. */ - port->inb_msg[0].mcback(port, priv->msg_rx_ring.dev_id, -1, -1); + port->inb_msg[0].mcback(port, msg_rx_ring.dev_id, -1, -1); /* Ack the queueing interrupt */ - out_be32(&priv->msg_regs->isr, RIO_MSG_ISR_DIQI); + out_be32((void *)&msg_regs->isr, RIO_MSG_ISR_DIQI); } out: @@ -633,7 +564,6 @@ fsl_rio_rx_handler(int irq, void *dev_instance) int rio_open_inb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entries) { int i, rc = 0; - struct rio_priv *priv = mport->priv; if ((entries < RIO_MIN_RX_RING_SIZE) || (entries > RIO_MAX_RX_RING_SIZE) || (!is_power_of_2(entries))) { @@ -642,35 +572,36 @@ int rio_open_inb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entri } /* Initialize client buffer ring */ - priv->msg_rx_ring.dev_id = dev_id; - priv->msg_rx_ring.size = entries; - priv->msg_rx_ring.rx_slot = 0; - for (i = 0; i < priv->msg_rx_ring.size; i++) - priv->msg_rx_ring.virt_buffer[i] = NULL; + msg_rx_ring.dev_id = dev_id; + msg_rx_ring.size = entries; + msg_rx_ring.rx_slot = 0; + for (i = 0; i < msg_rx_ring.size; i++) + msg_rx_ring.virt_buffer[i] = NULL; /* Initialize inbound message ring */ - priv->msg_rx_ring.virt = dma_alloc_coherent(NULL, - priv->msg_rx_ring.size * RIO_MAX_MSG_SIZE, - &priv->msg_rx_ring.phys, GFP_KERNEL); - if (!priv->msg_rx_ring.virt) { + if (!(msg_rx_ring.virt = dma_alloc_coherent(NULL, + msg_rx_ring.size * + RIO_MAX_MSG_SIZE, + &msg_rx_ring.phys, + GFP_KERNEL))) { rc = -ENOMEM; goto out; } /* Point dequeue/enqueue pointers at first entry in ring */ - out_be32(&priv->msg_regs->ifqdpar, (u32) priv->msg_rx_ring.phys); - out_be32(&priv->msg_regs->ifqepar, (u32) priv->msg_rx_ring.phys); + out_be32((void *)&msg_regs->ifqdpar, (u32) msg_rx_ring.phys); + out_be32((void *)&msg_regs->ifqepar, (u32) msg_rx_ring.phys); /* Clear interrupt status */ - out_be32(&priv->msg_regs->isr, 0x00000091); + out_be32((void *)&msg_regs->isr, 0x00000091); /* Hook up inbound message handler */ - rc = request_irq(IRQ_RIO_RX(mport), fsl_rio_rx_handler, 0, - "msg_rx", (void *)mport); - if (rc < 0) { + if ((rc = + request_irq(MPC85xx_IRQ_RIO_RX, mpc85xx_rio_rx_handler, 0, + "msg_rx", (void *)mport)) < 0) { dma_free_coherent(NULL, RIO_MSG_BUFFER_SIZE, - priv->msg_tx_ring.virt_buffer[i], - priv->msg_tx_ring.phys_buffer[i]); + msg_tx_ring.virt_buffer[i], + msg_tx_ring.phys_buffer[i]); goto out; } @@ -681,13 +612,15 @@ int rio_open_inb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entri * Unmask all interrupt sources * Disable */ - out_be32(&priv->msg_regs->imr, 0x001b0060); + out_be32((void *)&msg_regs->imr, 0x001b0060); /* Set number of queue entries */ - setbits32(&priv->msg_regs->imr, (get_bitmask_order(entries) - 2) << 12); + out_be32((void *)&msg_regs->imr, + in_be32((void *)&msg_regs->imr) | + ((get_bitmask_order(entries) - 2) << 12)); /* Now enable the unit */ - setbits32(&priv->msg_regs->imr, 0x1); + out_be32((void *)&msg_regs->imr, in_be32((void *)&msg_regs->imr) | 0x1); out: return rc; @@ -703,16 +636,15 @@ int rio_open_inb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entri */ void rio_close_inb_mbox(struct rio_mport *mport, int mbox) { - struct rio_priv *priv = mport->priv; /* Disable inbound message unit */ - out_be32(&priv->msg_regs->imr, 0); + out_be32((void *)&msg_regs->imr, 0); /* Free ring */ - dma_free_coherent(NULL, priv->msg_rx_ring.size * RIO_MAX_MSG_SIZE, - priv->msg_rx_ring.virt, priv->msg_rx_ring.phys); + dma_free_coherent(NULL, msg_rx_ring.size * RIO_MAX_MSG_SIZE, + msg_rx_ring.virt, msg_rx_ring.phys); /* Free interrupt */ - free_irq(IRQ_RIO_RX(mport), (void *)mport); + free_irq(MPC85xx_IRQ_RIO_RX, (void *)mport); } /** @@ -727,22 +659,21 @@ void rio_close_inb_mbox(struct rio_mport *mport, int mbox) int rio_hw_add_inb_buffer(struct rio_mport *mport, int mbox, void *buf) { int rc = 0; - struct rio_priv *priv = mport->priv; pr_debug("RIO: rio_hw_add_inb_buffer(), msg_rx_ring.rx_slot %d\n", - priv->msg_rx_ring.rx_slot); + msg_rx_ring.rx_slot); - if (priv->msg_rx_ring.virt_buffer[priv->msg_rx_ring.rx_slot]) { + if (msg_rx_ring.virt_buffer[msg_rx_ring.rx_slot]) { printk(KERN_ERR "RIO: error adding inbound buffer %d, buffer exists\n", - priv->msg_rx_ring.rx_slot); + msg_rx_ring.rx_slot); rc = -EINVAL; goto out; } - priv->msg_rx_ring.virt_buffer[priv->msg_rx_ring.rx_slot] = buf; - if (++priv->msg_rx_ring.rx_slot == priv->msg_rx_ring.size) - priv->msg_rx_ring.rx_slot = 0; + msg_rx_ring.virt_buffer[msg_rx_ring.rx_slot] = buf; + if (++msg_rx_ring.rx_slot == msg_rx_ring.size) + msg_rx_ring.rx_slot = 0; out: return rc; @@ -760,21 +691,20 @@ EXPORT_SYMBOL_GPL(rio_hw_add_inb_buffer); */ void *rio_hw_get_inb_message(struct rio_mport *mport, int mbox) { - struct rio_priv *priv = mport->priv; + u32 imr; u32 phys_buf, virt_buf; void *buf = NULL; int buf_idx; - phys_buf = in_be32(&priv->msg_regs->ifqdpar); + phys_buf = in_be32((void *)&msg_regs->ifqdpar); /* If no more messages, then bail out */ - if (phys_buf == in_be32(&priv->msg_regs->ifqepar)) + if (phys_buf == in_be32((void *)&msg_regs->ifqepar)) goto out2; - virt_buf = (u32) priv->msg_rx_ring.virt + (phys_buf - - priv->msg_rx_ring.phys); - buf_idx = (phys_buf - priv->msg_rx_ring.phys) / RIO_MAX_MSG_SIZE; - buf = priv->msg_rx_ring.virt_buffer[buf_idx]; + virt_buf = (u32) msg_rx_ring.virt + (phys_buf - msg_rx_ring.phys); + buf_idx = (phys_buf - msg_rx_ring.phys) / RIO_MAX_MSG_SIZE; + buf = msg_rx_ring.virt_buffer[buf_idx]; if (!buf) { printk(KERN_ERR @@ -786,10 +716,11 @@ void *rio_hw_get_inb_message(struct rio_mport *mport, int mbox) memcpy(buf, (void *)virt_buf, RIO_MAX_MSG_SIZE); /* Clear the available buffer */ - priv->msg_rx_ring.virt_buffer[buf_idx] = NULL; + msg_rx_ring.virt_buffer[buf_idx] = NULL; out1: - setbits32(&priv->msg_regs->imr, RIO_MSG_IMR_MI); + imr = in_be32((void *)&msg_regs->imr); + out_be32((void *)&msg_regs->imr, imr | RIO_MSG_IMR_MI); out2: return buf; @@ -798,7 +729,7 @@ void *rio_hw_get_inb_message(struct rio_mport *mport, int mbox) EXPORT_SYMBOL_GPL(rio_hw_get_inb_message); /** - * fsl_rio_dbell_handler - MPC85xx doorbell interrupt handler + * mpc85xx_rio_dbell_handler - MPC85xx doorbell interrupt handler * @irq: Linux interrupt number * @dev_instance: Pointer to interrupt-specific data * @@ -806,31 +737,31 @@ EXPORT_SYMBOL_GPL(rio_hw_get_inb_message); * doorbell event handlers and executes a matching event handler. */ static irqreturn_t -fsl_rio_dbell_handler(int irq, void *dev_instance) +mpc85xx_rio_dbell_handler(int irq, void *dev_instance) { int dsr; struct rio_mport *port = (struct rio_mport *)dev_instance; - struct rio_priv *priv = port->priv; - dsr = in_be32(&priv->msg_regs->dsr); + dsr = in_be32((void *)&msg_regs->dsr); if (dsr & DOORBELL_DSR_TE) { pr_info("RIO: doorbell reception error\n"); - out_be32(&priv->msg_regs->dsr, DOORBELL_DSR_TE); + out_be32((void *)&msg_regs->dsr, DOORBELL_DSR_TE); goto out; } if (dsr & DOORBELL_DSR_QFI) { pr_info("RIO: doorbell queue full\n"); - out_be32(&priv->msg_regs->dsr, DOORBELL_DSR_QFI); + out_be32((void *)&msg_regs->dsr, DOORBELL_DSR_QFI); goto out; } /* XXX Need to check/dispatch until queue empty */ if (dsr & DOORBELL_DSR_DIQI) { u32 dmsg = - (u32) priv->dbell_ring.virt + - (in_be32(&priv->msg_regs->dqdpar) & 0xfff); + (u32) dbell_ring.virt + + (in_be32((void *)&msg_regs->dqdpar) & 0xfff); + u32 dmr; struct rio_dbell *dbell; int found = 0; @@ -853,8 +784,9 @@ fsl_rio_dbell_handler(int irq, void *dev_instance) ("RIO: spurious doorbell, sid %2.2x tid %2.2x info %4.4x\n", DBELL_SID(dmsg), DBELL_TID(dmsg), DBELL_INF(dmsg)); } - setbits32(&priv->msg_regs->dmr, DOORBELL_DMR_DI); - out_be32(&priv->msg_regs->dsr, DOORBELL_DSR_DIQI); + dmr = in_be32((void *)&msg_regs->dmr); + out_be32((void *)&msg_regs->dmr, dmr | DOORBELL_DMR_DI); + out_be32((void *)&msg_regs->dsr, DOORBELL_DSR_DIQI); } out: @@ -862,22 +794,21 @@ fsl_rio_dbell_handler(int irq, void *dev_instance) } /** - * fsl_rio_doorbell_init - MPC85xx doorbell interface init + * mpc85xx_rio_doorbell_init - MPC85xx doorbell interface init * @mport: Master port implementing the inbound doorbell unit * * Initializes doorbell unit hardware and inbound DMA buffer - * ring. Called from fsl_rio_setup(). Returns %0 on success + * ring. Called from mpc85xx_rio_setup(). Returns %0 on success * or %-ENOMEM on failure. */ -static int fsl_rio_doorbell_init(struct rio_mport *mport) +static int mpc85xx_rio_doorbell_init(struct rio_mport *mport) { - struct rio_priv *priv = mport->priv; int rc = 0; /* Map outbound doorbell window immediately after maintenance window */ - priv->dbell_win = ioremap(mport->iores.start + RIO_MAINT_WIN_SIZE, - RIO_DBELL_WIN_SIZE); - if (!priv->dbell_win) { + if (!(dbell_win = + (u32) ioremap(mport->iores.start + RIO_MAINT_WIN_SIZE, + RIO_DBELL_WIN_SIZE))) { printk(KERN_ERR "RIO: unable to map outbound doorbell window\n"); rc = -ENOMEM; @@ -885,36 +816,37 @@ static int fsl_rio_doorbell_init(struct rio_mport *mport) } /* Initialize inbound doorbells */ - priv->dbell_ring.virt = dma_alloc_coherent(NULL, 512 * - DOORBELL_MESSAGE_SIZE, &priv->dbell_ring.phys, GFP_KERNEL); - if (!priv->dbell_ring.virt) { + if (!(dbell_ring.virt = dma_alloc_coherent(NULL, + 512 * DOORBELL_MESSAGE_SIZE, + &dbell_ring.phys, + GFP_KERNEL))) { printk(KERN_ERR "RIO: unable allocate inbound doorbell ring\n"); rc = -ENOMEM; - iounmap(priv->dbell_win); + iounmap((void *)dbell_win); goto out; } /* Point dequeue/enqueue pointers at first entry in ring */ - out_be32(&priv->msg_regs->dqdpar, (u32) priv->dbell_ring.phys); - out_be32(&priv->msg_regs->dqepar, (u32) priv->dbell_ring.phys); + out_be32((void *)&msg_regs->dqdpar, (u32) dbell_ring.phys); + out_be32((void *)&msg_regs->dqepar, (u32) dbell_ring.phys); /* Clear interrupt status */ - out_be32(&priv->msg_regs->dsr, 0x00000091); + out_be32((void *)&msg_regs->dsr, 0x00000091); /* Hook up doorbell handler */ - rc = request_irq(IRQ_RIO_BELL(mport), fsl_rio_dbell_handler, 0, - "dbell_rx", (void *)mport); - if (rc < 0) { - iounmap(priv->dbell_win); + if ((rc = + request_irq(MPC85xx_IRQ_RIO_BELL, mpc85xx_rio_dbell_handler, 0, + "dbell_rx", (void *)mport) < 0)) { + iounmap((void *)dbell_win); dma_free_coherent(NULL, 512 * DOORBELL_MESSAGE_SIZE, - priv->dbell_ring.virt, priv->dbell_ring.phys); + dbell_ring.virt, dbell_ring.phys); printk(KERN_ERR "MPC85xx RIO: unable to request inbound doorbell irq"); goto out; } /* Configure doorbells for snooping, 512 entries, and enable */ - out_be32(&priv->msg_regs->dmr, 0x00108161); + out_be32((void *)&msg_regs->dmr, 0x00108161); out: return rc; @@ -922,7 +854,7 @@ static int fsl_rio_doorbell_init(struct rio_mport *mport) static char *cmdline = NULL; -static int fsl_rio_get_hdid(int index) +static int mpc85xx_rio_get_hdid(int index) { /* XXX Need to parse multiple entries in some format */ if (!cmdline) @@ -931,7 +863,7 @@ static int fsl_rio_get_hdid(int index) return simple_strtol(cmdline, NULL, 0); } -static int fsl_rio_get_cmdline(char *s) +static int mpc85xx_rio_get_cmdline(char *s) { if (!s) return 0; @@ -940,266 +872,61 @@ static int fsl_rio_get_cmdline(char *s) return 1; } -__setup("riohdid=", fsl_rio_get_cmdline); - -static inline void fsl_rio_info(struct device *dev, u32 ccsr) -{ - const char *str; - if (ccsr & 1) { - /* Serial phy */ - switch (ccsr >> 30) { - case 0: - str = "1"; - break; - case 1: - str = "4"; - break; - default: - str = "Unknown"; - break;; - } - dev_info(dev, "Hardware port width: %s\n", str); - - switch ((ccsr >> 27) & 7) { - case 0: - str = "Single-lane 0"; - break; - case 1: - str = "Single-lane 2"; - break; - case 2: - str = "Four-lane"; - break; - default: - str = "Unknown"; - break; - } - dev_info(dev, "Training connection status: %s\n", str); - } else { - /* Parallel phy */ - if (!(ccsr & 0x80000000)) - dev_info(dev, "Output port operating in 8-bit mode\n"); - if (!(ccsr & 0x08000000)) - dev_info(dev, "Input port operating in 8-bit mode\n"); - } -} +__setup("riohdid=", mpc85xx_rio_get_cmdline); /** - * fsl_rio_setup - Setup MPC85xx RapidIO interface - * @fsl_rio_setup - Setup Freescale PowerPC RapidIO interface + * mpc85xx_rio_setup - Setup MPC85xx RapidIO interface + * @law_start: Starting physical address of RapidIO LAW + * @law_size: Size of RapidIO LAW * * Initializes MPC85xx RapidIO hardware interface, configures * master port with system-specific info, and registers the * master port with the RapidIO subsystem. */ -int fsl_rio_setup(struct of_device *dev) +void mpc85xx_rio_setup(int law_start, int law_size) { struct rio_ops *ops; struct rio_mport *port; - struct rio_priv *priv; - int rc = 0; - const u32 *dt_range, *cell; - struct resource regs; - int rlen; - u32 ccsr; - u64 law_start, law_size; - int paw, aw, sw; - - if (!dev->node) { - dev_err(&dev->dev, "Device OF-Node is NULL"); - return -EFAULT; - } - - rc = of_address_to_resource(dev->node, 0, ®s); - if (rc) { - dev_err(&dev->dev, "Can't get %s property 'reg'\n", - dev->node->full_name); - return -EFAULT; - } - dev_info(&dev->dev, "Of-device full name %s\n", dev->node->full_name); - dev_info(&dev->dev, "Regs start 0x%08x size 0x%08x\n", regs.start, - regs.end - regs.start + 1); - - dt_range = of_get_property(dev->node, "ranges", &rlen); - if (!dt_range) { - dev_err(&dev->dev, "Can't get %s property 'ranges'\n", - dev->node->full_name); - return -EFAULT; - } - - /* Get node address wide */ - cell = of_get_property(dev->node, "#address-cells", NULL); - if (cell) - aw = *cell; - else - aw = of_n_addr_cells(dev->node); - /* Get node size wide */ - cell = of_get_property(dev->node, "#size-cells", NULL); - if (cell) - sw = *cell; - else - sw = of_n_size_cells(dev->node); - /* Get parent address wide wide */ - paw = of_n_addr_cells(dev->node); - - law_start = of_read_number(dt_range + aw, paw); - law_size = of_read_number(dt_range + aw + paw, sw); - - dev_info(&dev->dev, "LAW start 0x%016llx, size 0x%016llx.\n", - law_start, law_size); ops = kmalloc(sizeof(struct rio_ops), GFP_KERNEL); - ops->lcread = fsl_local_config_read; - ops->lcwrite = fsl_local_config_write; - ops->cread = fsl_rio_config_read; - ops->cwrite = fsl_rio_config_write; - ops->dsend = fsl_rio_doorbell_send; + ops->lcread = mpc85xx_local_config_read; + ops->lcwrite = mpc85xx_local_config_write; + ops->cread = mpc85xx_rio_config_read; + ops->cwrite = mpc85xx_rio_config_write; + ops->dsend = mpc85xx_rio_doorbell_send; - port = kzalloc(sizeof(struct rio_mport), GFP_KERNEL); + port = kmalloc(sizeof(struct rio_mport), GFP_KERNEL); port->id = 0; port->index = 0; - - priv = kzalloc(sizeof(struct rio_priv), GFP_KERNEL); - if (!priv) { - printk(KERN_ERR "Can't alloc memory for 'priv'\n"); - rc = -ENOMEM; - goto err; - } - INIT_LIST_HEAD(&port->dbells); port->iores.start = law_start; port->iores.end = law_start + law_size; port->iores.flags = IORESOURCE_MEM; - priv->bellirq = irq_of_parse_and_map(dev->node, 2); - priv->txirq = irq_of_parse_and_map(dev->node, 3); - priv->rxirq = irq_of_parse_and_map(dev->node, 4); - dev_info(&dev->dev, "bellirq: %d, txirq: %d, rxirq %d\n", priv->bellirq, - priv->txirq, priv->rxirq); - rio_init_dbell_res(&port->riores[RIO_DOORBELL_RESOURCE], 0, 0xffff); rio_init_mbox_res(&port->riores[RIO_INB_MBOX_RESOURCE], 0, 0); rio_init_mbox_res(&port->riores[RIO_OUTB_MBOX_RESOURCE], 0, 0); strcpy(port->name, "RIO0 mport"); port->ops = ops; - port->host_deviceid = fsl_rio_get_hdid(port->id); + port->host_deviceid = mpc85xx_rio_get_hdid(port->id); - port->priv = priv; rio_register_mport(port); - priv->regs_win = ioremap(regs.start, regs.end - regs.start + 1); - - /* Probe the master port phy type */ - ccsr = in_be32(priv->regs_win + RIO_CCSR); - port->phy_type = (ccsr & 1) ? RIO_PHY_SERIAL : RIO_PHY_PARALLEL; - dev_info(&dev->dev, "RapidIO PHY type: %s\n", - (port->phy_type == RIO_PHY_PARALLEL) ? "parallel" : - ((port->phy_type == RIO_PHY_SERIAL) ? "serial" : - "unknown")); - /* Checking the port training status */ - if (in_be32((priv->regs_win + RIO_ESCSR)) & 1) { - dev_err(&dev->dev, "Port is not ready. " - "Try to restart connection...\n"); - switch (port->phy_type) { - case RIO_PHY_SERIAL: - /* Disable ports */ - out_be32(priv->regs_win + RIO_CCSR, 0); - /* Set 1x lane */ - setbits32(priv->regs_win + RIO_CCSR, 0x02000000); - /* Enable ports */ - setbits32(priv->regs_win + RIO_CCSR, 0x00600000); - break; - case RIO_PHY_PARALLEL: - /* Disable ports */ - out_be32(priv->regs_win + RIO_CCSR, 0x22000000); - /* Enable ports */ - out_be32(priv->regs_win + RIO_CCSR, 0x44000000); - break; - } - msleep(100); - if (in_be32((priv->regs_win + RIO_ESCSR)) & 1) { - dev_err(&dev->dev, "Port restart failed.\n"); - rc = -ENOLINK; - goto err; - } - dev_info(&dev->dev, "Port restart success!\n"); - } - fsl_rio_info(&dev->dev, ccsr); - - port->sys_size = (in_be32((priv->regs_win + RIO_PEF_CAR)) - & RIO_PEF_CTLS) >> 4; - dev_info(&dev->dev, "RapidIO Common Transport System size: %d\n", - port->sys_size ? 65536 : 256); - - priv->atmu_regs = (struct rio_atmu_regs *)(priv->regs_win - + RIO_ATMU_REGS_OFFSET); - priv->maint_atmu_regs = priv->atmu_regs + 1; - priv->dbell_atmu_regs = priv->atmu_regs + 2; - priv->msg_regs = (struct rio_msg_regs *)(priv->regs_win + - ((port->phy_type == RIO_PHY_SERIAL) ? - RIO_S_MSG_REGS_OFFSET : RIO_P_MSG_REGS_OFFSET)); - - /* Set to receive any dist ID for serial RapidIO controller. */ - if (port->phy_type == RIO_PHY_SERIAL) - out_be32((priv->regs_win + RIO_ISR_AACR), RIO_ISR_AACR_AA); + regs_win = (u32) ioremap(RIO_REGS_BASE, 0x20000); + atmu_regs = (struct rio_atmu_regs *)(regs_win + RIO_ATMU_REGS_OFFSET); + maint_atmu_regs = atmu_regs + 1; + dbell_atmu_regs = atmu_regs + 2; + msg_regs = (struct rio_msg_regs *)(regs_win + RIO_MSG_REGS_OFFSET); /* Configure maintenance transaction window */ - out_be32(&priv->maint_atmu_regs->rowbar, 0x000c0000); - out_be32(&priv->maint_atmu_regs->rowar, 0x80077015); + out_be32((void *)&maint_atmu_regs->rowbar, 0x000c0000); + out_be32((void *)&maint_atmu_regs->rowar, 0x80077015); - priv->maint_win = ioremap(law_start, RIO_MAINT_WIN_SIZE); + maint_win = (u32) ioremap(law_start, RIO_MAINT_WIN_SIZE); /* Configure outbound doorbell window */ - out_be32(&priv->dbell_atmu_regs->rowbar, 0x000c0400); - out_be32(&priv->dbell_atmu_regs->rowar, 0x8004200b); - fsl_rio_doorbell_init(port); - - return 0; -err: - if (priv) - iounmap(priv->regs_win); - kfree(ops); - kfree(priv); - kfree(port); - return rc; -} - -/* The probe function for RapidIO peer-to-peer network. - */ -static int __devinit fsl_of_rio_rpn_probe(struct of_device *dev, - const struct of_device_id *match) -{ - int rc; - printk(KERN_INFO "Setting up RapidIO peer-to-peer network %s\n", - dev->node->full_name); - - rc = fsl_rio_setup(dev); - if (rc) - goto out; - - /* Enumerate all registered ports */ - rc = rio_init_mports(); -out: - return rc; -}; - -static const struct of_device_id fsl_of_rio_rpn_ids[] = { - { - .compatible = "fsl,rapidio-delta", - }, - {}, -}; - -static struct of_platform_driver fsl_of_rio_rpn_driver = { - .name = "fsl-of-rio", - .match_table = fsl_of_rio_rpn_ids, - .probe = fsl_of_rio_rpn_probe, -}; - -static __init int fsl_of_rio_rpn_init(void) -{ - return of_register_platform_driver(&fsl_of_rio_rpn_driver); + out_be32((void *)&dbell_atmu_regs->rowbar, 0x000c0400); + out_be32((void *)&dbell_atmu_regs->rowar, 0x8004200b); + mpc85xx_rio_doorbell_init(port); } - -subsys_initcall(fsl_of_rio_rpn_init); diff --git a/trunk/arch/powerpc/sysdev/fsl_rio.h b/trunk/arch/powerpc/sysdev/fsl_rio.h new file mode 100644 index 000000000000..6d3ff30b1579 --- /dev/null +++ b/trunk/arch/powerpc/sysdev/fsl_rio.h @@ -0,0 +1,20 @@ +/* + * MPC85xx RapidIO definitions + * + * Copyright 2005 MontaVista Software, Inc. + * Matt Porter + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#ifndef __PPC_SYSLIB_PPC85XX_RIO_H +#define __PPC_SYSLIB_PPC85XX_RIO_H + +#include + +extern void mpc85xx_rio_setup(int law_start, int law_size); + +#endif /* __PPC_SYSLIB_PPC85XX_RIO_H */ diff --git a/trunk/arch/powerpc/sysdev/fsl_soc.c b/trunk/arch/powerpc/sysdev/fsl_soc.c index 324c01b70ddd..7b45670c7af3 100644 --- a/trunk/arch/powerpc/sysdev/fsl_soc.c +++ b/trunk/arch/powerpc/sysdev/fsl_soc.c @@ -418,21 +418,22 @@ arch_initcall(gfar_of_init); #include struct i2c_driver_device { char *of_device; + char *i2c_driver; char *i2c_type; }; static struct i2c_driver_device i2c_devices[] __initdata = { - {"ricoh,rs5c372a", "rs5c372a"}, - {"ricoh,rs5c372b", "rs5c372b"}, - {"ricoh,rv5c386", "rv5c386"}, - {"ricoh,rv5c387a", "rv5c387a"}, - {"dallas,ds1307", "ds1307"}, - {"dallas,ds1337", "ds1337"}, - {"dallas,ds1338", "ds1338"}, - {"dallas,ds1339", "ds1339"}, - {"dallas,ds1340", "ds1340"}, - {"stm,m41t00", "m41t00"}, - {"dallas,ds1374", "rtc-ds1374"}, + {"ricoh,rs5c372a", "rtc-rs5c372", "rs5c372a",}, + {"ricoh,rs5c372b", "rtc-rs5c372", "rs5c372b",}, + {"ricoh,rv5c386", "rtc-rs5c372", "rv5c386",}, + {"ricoh,rv5c387a", "rtc-rs5c372", "rv5c387a",}, + {"dallas,ds1307", "rtc-ds1307", "ds1307",}, + {"dallas,ds1337", "rtc-ds1307", "ds1337",}, + {"dallas,ds1338", "rtc-ds1307", "ds1338",}, + {"dallas,ds1339", "rtc-ds1307", "ds1339",}, + {"dallas,ds1340", "rtc-ds1307", "ds1340",}, + {"stm,m41t00", "rtc-ds1307", "m41t00"}, + {"dallas,ds1374", "rtc-ds1374", "rtc-ds1374",}, }; static int __init of_find_i2c_driver(struct device_node *node, @@ -443,7 +444,9 @@ static int __init of_find_i2c_driver(struct device_node *node, for (i = 0; i < ARRAY_SIZE(i2c_devices); i++) { if (!of_device_is_compatible(node, i2c_devices[i].of_device)) continue; - if (strlcpy(info->type, i2c_devices[i].i2c_type, + if (strlcpy(info->driver_name, i2c_devices[i].i2c_driver, + KOBJ_NAME_LEN) >= KOBJ_NAME_LEN || + strlcpy(info->type, i2c_devices[i].i2c_type, I2C_NAME_SIZE) >= I2C_NAME_SIZE) return -ENOMEM; return 0; diff --git a/trunk/arch/ppc/kernel/asm-offsets.c b/trunk/arch/ppc/kernel/asm-offsets.c index 8dcbdd6c2d2c..a51a17714231 100644 --- a/trunk/arch/ppc/kernel/asm-offsets.c +++ b/trunk/arch/ppc/kernel/asm-offsets.c @@ -18,8 +18,6 @@ #include #include #include -#include - #include #include #include @@ -28,6 +26,11 @@ #include #include +#define DEFINE(sym, val) \ + asm volatile("\n->" #sym " %0 " #val : : "i" (val)) + +#define BLANK() asm volatile("\n->" : : ) + int main(void) { diff --git a/trunk/arch/ppc/kernel/pci.c b/trunk/arch/ppc/kernel/pci.c index df3ef6db072c..50ce83f20adb 100644 --- a/trunk/arch/ppc/kernel/pci.c +++ b/trunk/arch/ppc/kernel/pci.c @@ -1121,8 +1121,8 @@ void __init pci_init_resource(struct resource *res, resource_size_t start, void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max) { - resource_size_t start = pci_resource_start(dev, bar); - resource_size_t len = pci_resource_len(dev, bar); + unsigned long start = pci_resource_start(dev, bar); + unsigned long len = pci_resource_len(dev, bar); unsigned long flags = pci_resource_flags(dev, bar); if (!len) diff --git a/trunk/arch/ppc/platforms/sbc82xx.c b/trunk/arch/ppc/platforms/sbc82xx.c index 24f6e0694ac1..0df6aacb8237 100644 --- a/trunk/arch/ppc/platforms/sbc82xx.c +++ b/trunk/arch/ppc/platforms/sbc82xx.c @@ -30,6 +30,8 @@ static void (*callback_init_IRQ)(void); extern unsigned char __res[sizeof(bd_t)]; +extern void (*late_time_init)(void); + #ifdef CONFIG_GEN_RTC TODC_ALLOC(); diff --git a/trunk/arch/s390/kernel/asm-offsets.c b/trunk/arch/s390/kernel/asm-offsets.c index fa28ecae636b..1375f8a4469e 100644 --- a/trunk/arch/s390/kernel/asm-offsets.c +++ b/trunk/arch/s390/kernel/asm-offsets.c @@ -5,38 +5,44 @@ */ #include -#include + +/* Use marker if you need to separate the values later */ + +#define DEFINE(sym, val, marker) \ + asm volatile("\n->" #sym " %0 " #val " " #marker : : "i" (val)) + +#define BLANK() asm volatile("\n->" : : ) int main(void) { - DEFINE(__THREAD_info, offsetof(struct task_struct, stack)); - DEFINE(__THREAD_ksp, offsetof(struct task_struct, thread.ksp)); - DEFINE(__THREAD_per, offsetof(struct task_struct, thread.per_info)); + DEFINE(__THREAD_info, offsetof(struct task_struct, stack),); + DEFINE(__THREAD_ksp, offsetof(struct task_struct, thread.ksp),); + DEFINE(__THREAD_per, offsetof(struct task_struct, thread.per_info),); DEFINE(__THREAD_mm_segment, - offsetof(struct task_struct, thread.mm_segment)); + offsetof(struct task_struct, thread.mm_segment),); BLANK(); - DEFINE(__TASK_pid, offsetof(struct task_struct, pid)); + DEFINE(__TASK_pid, offsetof(struct task_struct, pid),); BLANK(); - DEFINE(__PER_atmid, offsetof(per_struct, lowcore.words.perc_atmid)); - DEFINE(__PER_address, offsetof(per_struct, lowcore.words.address)); - DEFINE(__PER_access_id, offsetof(per_struct, lowcore.words.access_id)); + DEFINE(__PER_atmid, offsetof(per_struct, lowcore.words.perc_atmid),); + DEFINE(__PER_address, offsetof(per_struct, lowcore.words.address),); + DEFINE(__PER_access_id, offsetof(per_struct, lowcore.words.access_id),); BLANK(); - DEFINE(__TI_task, offsetof(struct thread_info, task)); - DEFINE(__TI_domain, offsetof(struct thread_info, exec_domain)); - DEFINE(__TI_flags, offsetof(struct thread_info, flags)); - DEFINE(__TI_cpu, offsetof(struct thread_info, cpu)); - DEFINE(__TI_precount, offsetof(struct thread_info, preempt_count)); + DEFINE(__TI_task, offsetof(struct thread_info, task),); + DEFINE(__TI_domain, offsetof(struct thread_info, exec_domain),); + DEFINE(__TI_flags, offsetof(struct thread_info, flags),); + DEFINE(__TI_cpu, offsetof(struct thread_info, cpu),); + DEFINE(__TI_precount, offsetof(struct thread_info, preempt_count),); BLANK(); - DEFINE(__PT_ARGS, offsetof(struct pt_regs, args)); - DEFINE(__PT_PSW, offsetof(struct pt_regs, psw)); - DEFINE(__PT_GPRS, offsetof(struct pt_regs, gprs)); - DEFINE(__PT_ORIG_GPR2, offsetof(struct pt_regs, orig_gpr2)); - DEFINE(__PT_ILC, offsetof(struct pt_regs, ilc)); - DEFINE(__PT_TRAP, offsetof(struct pt_regs, trap)); - DEFINE(__PT_SIZE, sizeof(struct pt_regs)); + DEFINE(__PT_ARGS, offsetof(struct pt_regs, args),); + DEFINE(__PT_PSW, offsetof(struct pt_regs, psw),); + DEFINE(__PT_GPRS, offsetof(struct pt_regs, gprs),); + DEFINE(__PT_ORIG_GPR2, offsetof(struct pt_regs, orig_gpr2),); + DEFINE(__PT_ILC, offsetof(struct pt_regs, ilc),); + DEFINE(__PT_TRAP, offsetof(struct pt_regs, trap),); + DEFINE(__PT_SIZE, sizeof(struct pt_regs),); BLANK(); - DEFINE(__SF_BACKCHAIN, offsetof(struct stack_frame, back_chain)); - DEFINE(__SF_GPRS, offsetof(struct stack_frame, gprs)); - DEFINE(__SF_EMPTY, offsetof(struct stack_frame, empty1)); + DEFINE(__SF_BACKCHAIN, offsetof(struct stack_frame, back_chain),); + DEFINE(__SF_GPRS, offsetof(struct stack_frame, gprs),); + DEFINE(__SF_EMPTY, offsetof(struct stack_frame, empty1),); return 0; } diff --git a/trunk/arch/s390/kernel/irq.c b/trunk/arch/s390/kernel/irq.c index c59a86dca584..c36d8123ca14 100644 --- a/trunk/arch/s390/kernel/irq.c +++ b/trunk/arch/s390/kernel/irq.c @@ -60,6 +60,8 @@ init_IRQ(void) /* * Switch to the asynchronous interrupt stack for softirq execution. */ +extern void __do_softirq(void); + asmlinkage void do_softirq(void) { unsigned long flags, old, new; diff --git a/trunk/arch/sh/boards/renesas/migor/setup.c b/trunk/arch/sh/boards/renesas/migor/setup.c index e7c150d49702..00d52a20d8a5 100644 --- a/trunk/arch/sh/boards/renesas/migor/setup.c +++ b/trunk/arch/sh/boards/renesas/migor/setup.c @@ -199,7 +199,8 @@ static struct platform_device *migor_devices[] __initdata = { static struct i2c_board_info __initdata migor_i2c_devices[] = { { - I2C_BOARD_INFO("rs5c372b", 0x32), + I2C_BOARD_INFO("rtc-rs5c372", 0x32), + .type = "rs5c372b", }, { I2C_BOARD_INFO("migor_ts", 0x51), diff --git a/trunk/arch/sh/boards/renesas/r7780rp/setup.c b/trunk/arch/sh/boards/renesas/r7780rp/setup.c index ac0a96522e45..a5c5e9236501 100644 --- a/trunk/arch/sh/boards/renesas/r7780rp/setup.c +++ b/trunk/arch/sh/boards/renesas/r7780rp/setup.c @@ -199,7 +199,8 @@ static struct platform_device smbus_device = { static struct i2c_board_info __initdata highlander_i2c_devices[] = { { - I2C_BOARD_INFO("r2025sd", 0x32), + I2C_BOARD_INFO("rtc-rs5c372", 0x32), + .type = "r2025sd", }, }; diff --git a/trunk/arch/sh/drivers/pci/pci.c b/trunk/arch/sh/drivers/pci/pci.c index 08d2e7325252..49b435c3a57a 100644 --- a/trunk/arch/sh/drivers/pci/pci.c +++ b/trunk/arch/sh/drivers/pci/pci.c @@ -191,8 +191,8 @@ void __init pcibios_update_irq(struct pci_dev *dev, int irq) void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen) { - resource_size_t start = pci_resource_start(dev, bar); - resource_size_t len = pci_resource_len(dev, bar); + unsigned long start = pci_resource_start(dev, bar); + unsigned long len = pci_resource_len(dev, bar); unsigned long flags = pci_resource_flags(dev, bar); if (unlikely(!len || !start)) diff --git a/trunk/arch/sh/kernel/asm-offsets.c b/trunk/arch/sh/kernel/asm-offsets.c index 57cf0e0680f3..dc6725c51a89 100644 --- a/trunk/arch/sh/kernel/asm-offsets.c +++ b/trunk/arch/sh/kernel/asm-offsets.c @@ -11,10 +11,13 @@ #include #include #include -#include - #include +#define DEFINE(sym, val) \ + asm volatile("\n->" #sym " %0 " #val : : "i" (val)) + +#define BLANK() asm volatile("\n->" : : ) + int main(void) { /* offsets into the thread_info struct */ diff --git a/trunk/arch/sh/kernel/irq.c b/trunk/arch/sh/kernel/irq.c index a2a99e487e33..9bf19b00696a 100644 --- a/trunk/arch/sh/kernel/irq.c +++ b/trunk/arch/sh/kernel/irq.c @@ -200,6 +200,8 @@ void irq_ctx_exit(int cpu) hardirq_ctx[cpu] = NULL; } +extern asmlinkage void __do_softirq(void); + asmlinkage void do_softirq(void) { unsigned long flags; diff --git a/trunk/arch/sparc/kernel/asm-offsets.c b/trunk/arch/sparc/kernel/asm-offsets.c index cd3f7694e9b9..6773ed76e414 100644 --- a/trunk/arch/sparc/kernel/asm-offsets.c +++ b/trunk/arch/sparc/kernel/asm-offsets.c @@ -12,7 +12,11 @@ #include // #include -#include + +#define DEFINE(sym, val) \ + asm volatile("\n->" #sym " %0 " #val : : "i" (val)) + +#define BLANK() asm volatile("\n->" : : ) int foo(void) { diff --git a/trunk/arch/sparc/lib/iomap.c b/trunk/arch/sparc/lib/iomap.c index 9ef37e13a920..54501c1ca785 100644 --- a/trunk/arch/sparc/lib/iomap.c +++ b/trunk/arch/sparc/lib/iomap.c @@ -21,8 +21,8 @@ EXPORT_SYMBOL(ioport_unmap); /* Create a virtual mapping cookie for a PCI BAR (memory or IO) */ void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen) { - resource_size_t start = pci_resource_start(dev, bar); - resource_size_t len = pci_resource_len(dev, bar); + unsigned long start = pci_resource_start(dev, bar); + unsigned long len = pci_resource_len(dev, bar); unsigned long flags = pci_resource_flags(dev, bar); if (!len || !start) diff --git a/trunk/arch/sparc64/lib/iomap.c b/trunk/arch/sparc64/lib/iomap.c index 7120ebbd4d03..ac556db06973 100644 --- a/trunk/arch/sparc64/lib/iomap.c +++ b/trunk/arch/sparc64/lib/iomap.c @@ -21,8 +21,8 @@ EXPORT_SYMBOL(ioport_unmap); /* Create a virtual mapping cookie for a PCI BAR (memory or IO) */ void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen) { - resource_size_t start = pci_resource_start(dev, bar); - resource_size_t len = pci_resource_len(dev, bar); + unsigned long start = pci_resource_start(dev, bar); + unsigned long len = pci_resource_len(dev, bar); unsigned long flags = pci_resource_flags(dev, bar); if (!len || !start) diff --git a/trunk/arch/um/kernel/exitcode.c b/trunk/arch/um/kernel/exitcode.c index 6540d2c9fbb7..984f80e668ca 100644 --- a/trunk/arch/um/kernel/exitcode.c +++ b/trunk/arch/um/kernel/exitcode.c @@ -59,7 +59,7 @@ static int make_proc_exitcode(void) { struct proc_dir_entry *ent; - ent = create_proc_entry("exitcode", 0600, NULL); + ent = create_proc_entry("exitcode", 0600, &proc_root); if (ent == NULL) { printk(KERN_WARNING "make_proc_exitcode : Failed to register " "/proc/exitcode\n"); diff --git a/trunk/arch/um/kernel/process.c b/trunk/arch/um/kernel/process.c index 83603cfbde81..e8cb9ff183e9 100644 --- a/trunk/arch/um/kernel/process.c +++ b/trunk/arch/um/kernel/process.c @@ -364,7 +364,7 @@ int __init make_proc_sysemu(void) if (!sysemu_supported) return 0; - ent = create_proc_entry("sysemu", 0600, NULL); + ent = create_proc_entry("sysemu", 0600, &proc_root); if (ent == NULL) { diff --git a/trunk/arch/um/kernel/time.c b/trunk/arch/um/kernel/time.c index 0d0cea2ac98d..e066e84493b1 100644 --- a/trunk/arch/um/kernel/time.c +++ b/trunk/arch/um/kernel/time.c @@ -4,7 +4,6 @@ */ #include -#include #include #include #include @@ -110,6 +109,8 @@ static void __init setup_itimer(void) clockevents_register_device(&itimer_clockevent); } +extern void (*late_time_init)(void); + void __init time_init(void) { long long nsecs; diff --git a/trunk/arch/v850/kernel/asm-offsets.c b/trunk/arch/v850/kernel/asm-offsets.c index 581e6986a776..cee5c3142d41 100644 --- a/trunk/arch/v850/kernel/asm-offsets.c +++ b/trunk/arch/v850/kernel/asm-offsets.c @@ -13,11 +13,14 @@ #include #include #include -#include - #include #include +#define DEFINE(sym, val) \ + asm volatile("\n->" #sym " %0 " #val : : "i" (val)) + +#define BLANK() asm volatile("\n->" : : ) + int main (void) { /* offsets into the task struct */ diff --git a/trunk/arch/v850/kernel/rte_mb_a_pci.c b/trunk/arch/v850/kernel/rte_mb_a_pci.c index 687e367d8b64..7165478824e7 100644 --- a/trunk/arch/v850/kernel/rte_mb_a_pci.c +++ b/trunk/arch/v850/kernel/rte_mb_a_pci.c @@ -790,8 +790,8 @@ pci_free_consistent (struct pci_dev *pdev, size_t size, void *cpu_addr, void __iomem *pci_iomap (struct pci_dev *dev, int bar, unsigned long max) { - resource_size_t start = pci_resource_start (dev, bar); - resource_size_t len = pci_resource_len (dev, bar); + unsigned long start = pci_resource_start (dev, bar); + unsigned long len = pci_resource_len (dev, bar); if (!start || len == 0) return 0; diff --git a/trunk/arch/x86/Kconfig b/trunk/arch/x86/Kconfig index f70e3e3a9fa7..a12dbb2b93f3 100644 --- a/trunk/arch/x86/Kconfig +++ b/trunk/arch/x86/Kconfig @@ -537,6 +537,9 @@ config CALGARY_IOMMU_ENABLED_BY_DEFAULT Calgary anyway, pass 'iommu=calgary' on the kernel command line. If unsure, say Y. +config IOMMU_HELPER + def_bool (CALGARY_IOMMU || GART_IOMMU) + # need this always selected by IOMMU for the VIA workaround config SWIOTLB bool @@ -547,8 +550,6 @@ config SWIOTLB access 32-bits of memory can be used on systems with more than 3 GB of memory. If unsure, say Y. -config IOMMU_HELPER - def_bool (CALGARY_IOMMU || GART_IOMMU || SWIOTLB) config NR_CPUS int "Maximum number of CPUs (2-255)" @@ -1504,10 +1505,6 @@ config PCI_GODIRECT config PCI_GOANY bool "Any" -config PCI_GOOLPC - bool "OLPC" - depends on OLPC - endchoice config PCI_BIOS @@ -1517,17 +1514,12 @@ config PCI_BIOS # x86-64 doesn't support PCI BIOS access from long mode so always go direct. config PCI_DIRECT def_bool y - depends on PCI && (X86_64 || (PCI_GODIRECT || PCI_GOANY || PCI_GOOLPC) || X86_VISWS) + depends on PCI && (X86_64 || (PCI_GODIRECT || PCI_GOANY) || X86_VISWS) config PCI_MMCONFIG def_bool y depends on X86_32 && PCI && ACPI && (PCI_GOMMCONFIG || PCI_GOANY) -config PCI_OLPC - bool - depends on PCI && PCI_GOOLPC - default y - config PCI_DOMAINS def_bool y depends on PCI @@ -1647,13 +1639,6 @@ config GEODE_MFGPT_TIMER MFGPTs have a better resolution and max interval than the generic PIT, and are suitable for use as high-res timers. -config OLPC - bool "One Laptop Per Child support" - default n - help - Add support for detecting the unique features of the OLPC - XO hardware. - endif # X86_32 config K8_NB diff --git a/trunk/arch/x86/boot/edd.c b/trunk/arch/x86/boot/edd.c index 03399d64013b..d84a48ece785 100644 --- a/trunk/arch/x86/boot/edd.c +++ b/trunk/arch/x86/boot/edd.c @@ -126,25 +126,17 @@ void query_edd(void) { char eddarg[8]; int do_mbr = 1; -#ifdef CONFIG_EDD_OFF - int do_edd = 0; -#else int do_edd = 1; -#endif int be_quiet; int devno; struct edd_info ei, *edp; u32 *mbrptr; if (cmdline_find_option("edd", eddarg, sizeof eddarg) > 0) { - if (!strcmp(eddarg, "skipmbr") || !strcmp(eddarg, "skip")) { - do_edd = 1; + if (!strcmp(eddarg, "skipmbr") || !strcmp(eddarg, "skip")) do_mbr = 0; - } else if (!strcmp(eddarg, "off")) do_edd = 0; - else if (!strcmp(eddarg, "on")) - do_edd = 1; } be_quiet = cmdline_find_option_bool("quiet"); diff --git a/trunk/arch/x86/kernel/Makefile b/trunk/arch/x86/kernel/Makefile index 30d54ed27e55..fa19c3819540 100644 --- a/trunk/arch/x86/kernel/Makefile +++ b/trunk/arch/x86/kernel/Makefile @@ -91,8 +91,6 @@ endif obj-$(CONFIG_SCx200) += scx200.o scx200-y += scx200_32.o -obj-$(CONFIG_OLPC) += olpc.o - ### # 64 bit specific files ifeq ($(CONFIG_X86_64),y) @@ -103,6 +101,4 @@ ifeq ($(CONFIG_X86_64),y) obj-$(CONFIG_GART_IOMMU) += pci-gart_64.o aperture_64.o obj-$(CONFIG_CALGARY_IOMMU) += pci-calgary_64.o tce_64.o obj-$(CONFIG_SWIOTLB) += pci-swiotlb_64.o - - obj-$(CONFIG_PCI_MMCONFIG) += mmconf-fam10h_64.o endif diff --git a/trunk/arch/x86/kernel/acpi/boot.c b/trunk/arch/x86/kernel/acpi/boot.c index c49ebcc6c41e..977ed5cdeaa3 100644 --- a/trunk/arch/x86/kernel/acpi/boot.c +++ b/trunk/arch/x86/kernel/acpi/boot.c @@ -771,32 +771,6 @@ static void __init acpi_register_lapic_address(unsigned long address) boot_cpu_physical_apicid = GET_APIC_ID(read_apic_id()); } -static int __init early_acpi_parse_madt_lapic_addr_ovr(void) -{ - int count; - - if (!cpu_has_apic) - return -ENODEV; - - /* - * Note that the LAPIC address is obtained from the MADT (32-bit value) - * and (optionally) overriden by a LAPIC_ADDR_OVR entry (64-bit value). - */ - - count = - acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE, - acpi_parse_lapic_addr_ovr, 0); - if (count < 0) { - printk(KERN_ERR PREFIX - "Error parsing LAPIC address override entry\n"); - return count; - } - - acpi_register_lapic_address(acpi_lapic_addr); - - return count; -} - static int __init acpi_parse_madt_lapic_entries(void) { int count; @@ -927,33 +901,6 @@ static inline int acpi_parse_madt_ioapic_entries(void) } #endif /* !CONFIG_X86_IO_APIC */ -static void __init early_acpi_process_madt(void) -{ -#ifdef CONFIG_X86_LOCAL_APIC - int error; - - if (!acpi_table_parse(ACPI_SIG_MADT, acpi_parse_madt)) { - - /* - * Parse MADT LAPIC entries - */ - error = early_acpi_parse_madt_lapic_addr_ovr(); - if (!error) { - acpi_lapic = 1; - smp_found_config = 1; - } - if (error == -EINVAL) { - /* - * Dell Precision Workstation 410, 610 come here. - */ - printk(KERN_ERR PREFIX - "Invalid BIOS MADT, disabling ACPI\n"); - disable_acpi(); - } - } -#endif -} - static void __init acpi_process_madt(void) { #ifdef CONFIG_X86_LOCAL_APIC @@ -1286,23 +1233,6 @@ int __init acpi_boot_table_init(void) return 0; } -int __init early_acpi_boot_init(void) -{ - /* - * If acpi_disabled, bail out - * One exception: acpi=ht continues far enough to enumerate LAPICs - */ - if (acpi_disabled && !acpi_ht) - return 1; - - /* - * Process the Multiple APIC Description Table (MADT), if present - */ - early_acpi_process_madt(); - - return 0; -} - int __init acpi_boot_init(void) { /* diff --git a/trunk/arch/x86/kernel/asm-offsets_32.c b/trunk/arch/x86/kernel/asm-offsets_32.c index 92588083950f..670c3c311289 100644 --- a/trunk/arch/x86/kernel/asm-offsets_32.c +++ b/trunk/arch/x86/kernel/asm-offsets_32.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include "sigframe.h" #include @@ -24,6 +23,14 @@ #include #include "../../../drivers/lguest/lg.h" +#define DEFINE(sym, val) \ + asm volatile("\n->" #sym " %0 " #val : : "i" (val)) + +#define BLANK() asm volatile("\n->" : : ) + +#define OFFSET(sym, str, mem) \ + DEFINE(sym, offsetof(struct str, mem)); + /* workaround for a warning with -Wmissing-prototypes */ void foo(void); diff --git a/trunk/arch/x86/kernel/asm-offsets_64.c b/trunk/arch/x86/kernel/asm-offsets_64.c index f126c05d6170..494e1e096ee6 100644 --- a/trunk/arch/x86/kernel/asm-offsets_64.c +++ b/trunk/arch/x86/kernel/asm-offsets_64.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -18,6 +17,14 @@ #include #include +#define DEFINE(sym, val) \ + asm volatile("\n->" #sym " %0 " #val : : "i" (val)) + +#define BLANK() asm volatile("\n->" : : ) + +#define OFFSET(sym, str, mem) \ + DEFINE(sym, offsetof(struct str, mem)) + #define __NO_STUBS 1 #undef __SYSCALL #undef _ASM_X86_64_UNISTD_H_ diff --git a/trunk/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c b/trunk/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c index b0c8208df9fa..8db8f73503b3 100644 --- a/trunk/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c +++ b/trunk/arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c @@ -601,7 +601,6 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) { policy->cpus = perf->shared_cpu_map; } - policy->related_cpus = perf->shared_cpu_map; #ifdef CONFIG_SMP dmi_check_system(sw_any_bug_dmi_table); diff --git a/trunk/arch/x86/kernel/cpu/mtrr/generic.c b/trunk/arch/x86/kernel/cpu/mtrr/generic.c index 5d241ce94a44..353efe4f5017 100644 --- a/trunk/arch/x86/kernel/cpu/mtrr/generic.c +++ b/trunk/arch/x86/kernel/cpu/mtrr/generic.c @@ -90,7 +90,7 @@ u8 mtrr_type_lookup(u64 start, u64 end) * Look of multiple ranges matching this address and pick type * as per MTRR precedence */ - if (!(mtrr_state.enabled & 2)) { + if (!mtrr_state.enabled & 2) { return mtrr_state.def_type; } diff --git a/trunk/arch/x86/kernel/cpu/mtrr/if.c b/trunk/arch/x86/kernel/cpu/mtrr/if.c index 84c480bb3715..1960f1985e5e 100644 --- a/trunk/arch/x86/kernel/cpu/mtrr/if.c +++ b/trunk/arch/x86/kernel/cpu/mtrr/if.c @@ -424,7 +424,7 @@ static int __init mtrr_if_init(void) return -ENODEV; proc_root_mtrr = - proc_create("mtrr", S_IWUSR | S_IRUGO, NULL, &mtrr_fops); + proc_create("mtrr", S_IWUSR | S_IRUGO, &proc_root, &mtrr_fops); if (proc_root_mtrr) proc_root_mtrr->owner = THIS_MODULE; diff --git a/trunk/arch/x86/kernel/e820_64.c b/trunk/arch/x86/kernel/e820_64.c index 124480c0008d..645ee5e32a27 100644 --- a/trunk/arch/x86/kernel/e820_64.c +++ b/trunk/arch/x86/kernel/e820_64.c @@ -100,7 +100,7 @@ void __init free_early(unsigned long start, unsigned long end) for (j = i + 1; j < MAX_EARLY_RES && early_res[j].end; j++) ; - memmove(&early_res[i], &early_res[i + 1], + memcpy(&early_res[i], &early_res[i + 1], (j - 1 - i) * sizeof(struct early_res)); early_res[j - 1].end = 0; diff --git a/trunk/arch/x86/kernel/irq_32.c b/trunk/arch/x86/kernel/irq_32.c index 147352df28b9..00bda7bcda63 100644 --- a/trunk/arch/x86/kernel/irq_32.c +++ b/trunk/arch/x86/kernel/irq_32.c @@ -190,6 +190,8 @@ void irq_ctx_exit(int cpu) hardirq_ctx[cpu] = NULL; } +extern asmlinkage void __do_softirq(void); + asmlinkage void do_softirq(void) { unsigned long flags; diff --git a/trunk/arch/x86/kernel/mmconf-fam10h_64.c b/trunk/arch/x86/kernel/mmconf-fam10h_64.c deleted file mode 100644 index edc5fbfe85c0..000000000000 --- a/trunk/arch/x86/kernel/mmconf-fam10h_64.c +++ /dev/null @@ -1,243 +0,0 @@ -/* - * AMD Family 10h mmconfig enablement - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../pci/pci.h" - -struct pci_hostbridge_probe { - u32 bus; - u32 slot; - u32 vendor; - u32 device; -}; - -static u64 __cpuinitdata fam10h_pci_mmconf_base; -static int __cpuinitdata fam10h_pci_mmconf_base_status; - -static struct pci_hostbridge_probe pci_probes[] __cpuinitdata = { - { 0, 0x18, PCI_VENDOR_ID_AMD, 0x1200 }, - { 0xff, 0, PCI_VENDOR_ID_AMD, 0x1200 }, -}; - -struct range { - u64 start; - u64 end; -}; - -static int __cpuinit cmp_range(const void *x1, const void *x2) -{ - const struct range *r1 = x1; - const struct range *r2 = x2; - int start1, start2; - - start1 = r1->start >> 32; - start2 = r2->start >> 32; - - return start1 - start2; -} - -/*[47:0] */ -/* need to avoid (0xfd<<32) and (0xfe<<32), ht used space */ -#define FAM10H_PCI_MMCONF_BASE (0xfcULL<<32) -#define BASE_VALID(b) ((b != (0xfdULL << 32)) && (b != (0xfeULL << 32))) -static void __cpuinit get_fam10h_pci_mmconf_base(void) -{ - int i; - unsigned bus; - unsigned slot; - int found; - - u64 val; - u32 address; - u64 tom2; - u64 base = FAM10H_PCI_MMCONF_BASE; - - int hi_mmio_num; - struct range range[8]; - - /* only try to get setting from BSP */ - /* -1 or 1 */ - if (fam10h_pci_mmconf_base_status) - return; - - if (!early_pci_allowed()) - goto fail; - - found = 0; - for (i = 0; i < ARRAY_SIZE(pci_probes); i++) { - u32 id; - u16 device; - u16 vendor; - - bus = pci_probes[i].bus; - slot = pci_probes[i].slot; - id = read_pci_config(bus, slot, 0, PCI_VENDOR_ID); - - vendor = id & 0xffff; - device = (id>>16) & 0xffff; - if (pci_probes[i].vendor == vendor && - pci_probes[i].device == device) { - found = 1; - break; - } - } - - if (!found) - goto fail; - - /* SYS_CFG */ - address = MSR_K8_SYSCFG; - rdmsrl(address, val); - - /* TOP_MEM2 is not enabled? */ - if (!(val & (1<<21))) { - tom2 = 0; - } else { - /* TOP_MEM2 */ - address = MSR_K8_TOP_MEM2; - rdmsrl(address, val); - tom2 = val & (0xffffULL<<32); - } - - if (base <= tom2) - base = tom2 + (1ULL<<32); - - /* - * need to check if the range is in the high mmio range that is - * above 4G - */ - hi_mmio_num = 0; - for (i = 0; i < 8; i++) { - u32 reg; - u64 start; - u64 end; - reg = read_pci_config(bus, slot, 1, 0x80 + (i << 3)); - if (!(reg & 3)) - continue; - - start = (((u64)reg) << 8) & (0xffULL << 32); /* 39:16 on 31:8*/ - reg = read_pci_config(bus, slot, 1, 0x84 + (i << 3)); - end = (((u64)reg) << 8) & (0xffULL << 32); /* 39:16 on 31:8*/ - - if (!end) - continue; - - range[hi_mmio_num].start = start; - range[hi_mmio_num].end = end; - hi_mmio_num++; - } - - if (!hi_mmio_num) - goto out; - - /* sort the range */ - sort(range, hi_mmio_num, sizeof(struct range), cmp_range, NULL); - - if (range[hi_mmio_num - 1].end < base) - goto out; - if (range[0].start > base) - goto out; - - /* need to find one window */ - base = range[0].start - (1ULL << 32); - if ((base > tom2) && BASE_VALID(base)) - goto out; - base = range[hi_mmio_num - 1].end + (1ULL << 32); - if ((base > tom2) && BASE_VALID(base)) - goto out; - /* need to find window between ranges */ - if (hi_mmio_num > 1) - for (i = 0; i < hi_mmio_num - 1; i++) { - if (range[i + 1].start > (range[i].end + (1ULL << 32))) { - base = range[i].end + (1ULL << 32); - if ((base > tom2) && BASE_VALID(base)) - goto out; - } - } - -fail: - fam10h_pci_mmconf_base_status = -1; - return; -out: - fam10h_pci_mmconf_base = base; - fam10h_pci_mmconf_base_status = 1; -} - -void __cpuinit fam10h_check_enable_mmcfg(void) -{ - u64 val; - u32 address; - - if (!(pci_probe & PCI_CHECK_ENABLE_AMD_MMCONF)) - return; - - address = MSR_FAM10H_MMIO_CONF_BASE; - rdmsrl(address, val); - - /* try to make sure that AP's setting is identical to BSP setting */ - if (val & FAM10H_MMIO_CONF_ENABLE) { - unsigned busnbits; - busnbits = (val >> FAM10H_MMIO_CONF_BUSRANGE_SHIFT) & - FAM10H_MMIO_CONF_BUSRANGE_MASK; - - /* only trust the one handle 256 buses, if acpi=off */ - if (!acpi_pci_disabled || busnbits >= 8) { - u64 base; - base = val & (0xffffULL << 32); - if (fam10h_pci_mmconf_base_status <= 0) { - fam10h_pci_mmconf_base = base; - fam10h_pci_mmconf_base_status = 1; - return; - } else if (fam10h_pci_mmconf_base == base) - return; - } - } - - /* - * if it is not enabled, try to enable it and assume only one segment - * with 256 buses - */ - get_fam10h_pci_mmconf_base(); - if (fam10h_pci_mmconf_base_status <= 0) - return; - - printk(KERN_INFO "Enable MMCONFIG on AMD Family 10h\n"); - val &= ~((FAM10H_MMIO_CONF_BASE_MASK< - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef CONFIG_OPEN_FIRMWARE -#include -#endif - -struct olpc_platform_t olpc_platform_info; -EXPORT_SYMBOL_GPL(olpc_platform_info); - -static DEFINE_SPINLOCK(ec_lock); - -/* what the timeout *should* be (in ms) */ -#define EC_BASE_TIMEOUT 20 - -/* the timeout that bugs in the EC might force us to actually use */ -static int ec_timeout = EC_BASE_TIMEOUT; - -static int __init olpc_ec_timeout_set(char *str) -{ - if (get_option(&str, &ec_timeout) != 1) { - ec_timeout = EC_BASE_TIMEOUT; - printk(KERN_ERR "olpc-ec: invalid argument to " - "'olpc_ec_timeout=', ignoring!\n"); - } - printk(KERN_DEBUG "olpc-ec: using %d ms delay for EC commands.\n", - ec_timeout); - return 1; -} -__setup("olpc_ec_timeout=", olpc_ec_timeout_set); - -/* - * These {i,o}bf_status functions return whether the buffers are full or not. - */ - -static inline unsigned int ibf_status(unsigned int port) -{ - return !!(inb(port) & 0x02); -} - -static inline unsigned int obf_status(unsigned int port) -{ - return inb(port) & 0x01; -} - -#define wait_on_ibf(p, d) __wait_on_ibf(__LINE__, (p), (d)) -static int __wait_on_ibf(unsigned int line, unsigned int port, int desired) -{ - unsigned int timeo; - int state = ibf_status(port); - - for (timeo = ec_timeout; state != desired && timeo; timeo--) { - mdelay(1); - state = ibf_status(port); - } - - if ((state == desired) && (ec_timeout > EC_BASE_TIMEOUT) && - timeo < (ec_timeout - EC_BASE_TIMEOUT)) { - printk(KERN_WARNING "olpc-ec: %d: waited %u ms for IBF!\n", - line, ec_timeout - timeo); - } - - return !(state == desired); -} - -#define wait_on_obf(p, d) __wait_on_obf(__LINE__, (p), (d)) -static int __wait_on_obf(unsigned int line, unsigned int port, int desired) -{ - unsigned int timeo; - int state = obf_status(port); - - for (timeo = ec_timeout; state != desired && timeo; timeo--) { - mdelay(1); - state = obf_status(port); - } - - if ((state == desired) && (ec_timeout > EC_BASE_TIMEOUT) && - timeo < (ec_timeout - EC_BASE_TIMEOUT)) { - printk(KERN_WARNING "olpc-ec: %d: waited %u ms for OBF!\n", - line, ec_timeout - timeo); - } - - return !(state == desired); -} - -/* - * This allows the kernel to run Embedded Controller commands. The EC is - * documented at , and the - * available EC commands are here: - * . Unfortunately, while - * OpenFirmware's source is available, the EC's is not. - */ -int olpc_ec_cmd(unsigned char cmd, unsigned char *inbuf, size_t inlen, - unsigned char *outbuf, size_t outlen) -{ - unsigned long flags; - int ret = -EIO; - int i; - - spin_lock_irqsave(&ec_lock, flags); - - /* Clear OBF */ - for (i = 0; i < 10 && (obf_status(0x6c) == 1); i++) - inb(0x68); - if (i == 10) { - printk(KERN_ERR "olpc-ec: timeout while attempting to " - "clear OBF flag!\n"); - goto err; - } - - if (wait_on_ibf(0x6c, 0)) { - printk(KERN_ERR "olpc-ec: timeout waiting for EC to " - "quiesce!\n"); - goto err; - } - -restart: - /* - * Note that if we time out during any IBF checks, that's a failure; - * we have to return. There's no way for the kernel to clear that. - * - * If we time out during an OBF check, we can restart the command; - * reissuing it will clear the OBF flag, and we should be alright. - * The OBF flag will sometimes misbehave due to what we believe - * is a hardware quirk.. - */ - printk(KERN_DEBUG "olpc-ec: running cmd 0x%x\n", cmd); - outb(cmd, 0x6c); - - if (wait_on_ibf(0x6c, 0)) { - printk(KERN_ERR "olpc-ec: timeout waiting for EC to read " - "command!\n"); - goto err; - } - - if (inbuf && inlen) { - /* write data to EC */ - for (i = 0; i < inlen; i++) { - if (wait_on_ibf(0x6c, 0)) { - printk(KERN_ERR "olpc-ec: timeout waiting for" - " EC accept data!\n"); - goto err; - } - printk(KERN_DEBUG "olpc-ec: sending cmd arg 0x%x\n", - inbuf[i]); - outb(inbuf[i], 0x68); - } - } - if (outbuf && outlen) { - /* read data from EC */ - for (i = 0; i < outlen; i++) { - if (wait_on_obf(0x6c, 1)) { - printk(KERN_ERR "olpc-ec: timeout waiting for" - " EC to provide data!\n"); - goto restart; - } - outbuf[i] = inb(0x68); - printk(KERN_DEBUG "olpc-ec: received 0x%x\n", - outbuf[i]); - } - } - - ret = 0; -err: - spin_unlock_irqrestore(&ec_lock, flags); - return ret; -} -EXPORT_SYMBOL_GPL(olpc_ec_cmd); - -#ifdef CONFIG_OPEN_FIRMWARE -static void __init platform_detect(void) -{ - size_t propsize; - u32 rev; - - if (ofw("getprop", 4, 1, NULL, "board-revision-int", &rev, 4, - &propsize) || propsize != 4) { - printk(KERN_ERR "ofw: getprop call failed!\n"); - rev = 0; - } - olpc_platform_info.boardrev = be32_to_cpu(rev); -} -#else -static void __init platform_detect(void) -{ - /* stopgap until OFW support is added to the kernel */ - olpc_platform_info.boardrev = be32_to_cpu(0xc2); -} -#endif - -static int __init olpc_init(void) -{ - unsigned char *romsig; - - /* The ioremap check is dangerous; limit what we run it on */ - if (!is_geode() || geode_has_vsa2()) - return 0; - - spin_lock_init(&ec_lock); - - romsig = ioremap(0xffffffc0, 16); - if (!romsig) - return 0; - - if (strncmp(romsig, "CL1 Q", 7)) - goto unmap; - if (strncmp(romsig+6, romsig+13, 3)) { - printk(KERN_INFO "OLPC BIOS signature looks invalid. " - "Assuming not OLPC\n"); - goto unmap; - } - - printk(KERN_INFO "OLPC board with OpenFirmware %.16s\n", romsig); - olpc_platform_info.flags |= OLPC_F_PRESENT; - - /* get the platform revision */ - platform_detect(); - - /* assume B1 and above models always have a DCON */ - if (olpc_board_at_least(olpc_board(0xb1))) - olpc_platform_info.flags |= OLPC_F_DCON; - - /* get the EC revision */ - olpc_ec_cmd(EC_FIRMWARE_REV, NULL, 0, - (unsigned char *) &olpc_platform_info.ecver, 1); - - /* check to see if the VSA exists */ - if (geode_has_vsa2()) - olpc_platform_info.flags |= OLPC_F_VSA; - - printk(KERN_INFO "OLPC board revision %s%X (EC=%x)\n", - ((olpc_platform_info.boardrev & 0xf) < 8) ? "pre" : "", - olpc_platform_info.boardrev >> 4, - olpc_platform_info.ecver); - -unmap: - iounmap(romsig); - return 0; -} - -postcore_initcall(olpc_init); diff --git a/trunk/arch/x86/kernel/setup_64.c b/trunk/arch/x86/kernel/setup_64.c index 22c14e21c97c..a94fb959a87a 100644 --- a/trunk/arch/x86/kernel/setup_64.c +++ b/trunk/arch/x86/kernel/setup_64.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -41,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -290,18 +288,6 @@ static void __init parse_setup_data(void) } } -#ifdef CONFIG_PCI_MMCONFIG -extern void __cpuinit fam10h_check_enable_mmcfg(void); -extern void __init check_enable_amd_mmconf_dmi(void); -#else -void __cpuinit fam10h_check_enable_mmcfg(void) -{ -} -void __init check_enable_amd_mmconf_dmi(void) -{ -} -#endif - /* * setup_arch - architecture-specific boot-time initializations * @@ -529,9 +515,6 @@ void __init setup_arch(char **cmdline_p) conswitchp = &dummy_con; #endif #endif - - /* do this before identify_cpu for boot cpu */ - check_enable_amd_mmconf_dmi(); } static int __cpuinit get_model_name(struct cpuinfo_x86 *c) @@ -784,9 +767,6 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c) /* MFENCE stops RDTSC speculation */ set_cpu_cap(c, X86_FEATURE_MFENCE_RDTSC); - if (c->x86 == 0x10) - fam10h_check_enable_mmcfg(); - if (amd_apic_timer_broken()) disable_apic_timer = 1; diff --git a/trunk/arch/x86/kernel/smpboot.c b/trunk/arch/x86/kernel/smpboot.c index 84241a256dc8..04c662ba18f1 100644 --- a/trunk/arch/x86/kernel/smpboot.c +++ b/trunk/arch/x86/kernel/smpboot.c @@ -1149,10 +1149,14 @@ static int __init smp_sanity_check(unsigned max_cpus) "forcing use of dummy APIC emulation.\n"); smpboot_clear_io_apic(); #ifdef CONFIG_X86_32 - connect_bsp_APIC(); + if (nmi_watchdog == NMI_LOCAL_APIC) { + printk(KERN_INFO "activating minimal APIC for" + "NMI watchdog use.\n"); + connect_bsp_APIC(); + setup_local_APIC(); + end_local_APIC_setup(); + } #endif - setup_local_APIC(); - end_local_APIC_setup(); return -1; } diff --git a/trunk/arch/x86/kernel/time_32.c b/trunk/arch/x86/kernel/time_32.c index 2ff21f398934..1a89e93f3f1c 100644 --- a/trunk/arch/x86/kernel/time_32.c +++ b/trunk/arch/x86/kernel/time_32.c @@ -115,6 +115,7 @@ irqreturn_t timer_interrupt(int irq, void *dev_id) return IRQ_HANDLED; } +extern void (*late_time_init)(void); /* Duplicate of time_init() below, with hpet_enable part added */ void __init hpet_time_init(void) { diff --git a/trunk/arch/x86/kernel/vsmp_64.c b/trunk/arch/x86/kernel/vsmp_64.c index ba8c0b75ab0a..caf2a26f5cfd 100644 --- a/trunk/arch/x86/kernel/vsmp_64.c +++ b/trunk/arch/x86/kernel/vsmp_64.c @@ -133,7 +133,7 @@ int is_vsmp_box(void) } } #else -static void __init detect_vsmp_box(void) +static int __init detect_vsmp_box(void) { } int is_vsmp_box(void) diff --git a/trunk/arch/x86/mm/k8topology_64.c b/trunk/arch/x86/mm/k8topology_64.c index 1f476e477844..86808e666f9c 100644 --- a/trunk/arch/x86/mm/k8topology_64.c +++ b/trunk/arch/x86/mm/k8topology_64.c @@ -13,15 +13,12 @@ #include #include #include -#include #include #include #include #include #include #include -#include -#include static __init int find_northbridge(void) { @@ -47,30 +44,6 @@ static __init int find_northbridge(void) return -1; } -static __init void early_get_boot_cpu_id(void) -{ - /* - * need to get boot_cpu_id so can use that to create apicid_to_node - * in k8_scan_nodes() - */ - /* - * Find possible boot-time SMP configuration: - */ - early_find_smp_config(); -#ifdef CONFIG_ACPI - /* - * Read APIC information from ACPI tables. - */ - early_acpi_boot_init(); -#endif - /* - * get boot-time SMP configuration: - */ - if (smp_found_config) - early_get_smp_config(); - early_init_lapic_mapping(); -} - int __init k8_scan_nodes(unsigned long start, unsigned long end) { unsigned long prevbase; @@ -83,7 +56,6 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end) unsigned cores; unsigned bits; int j; - unsigned apicid_base; if (!early_pci_allowed()) return -1; @@ -202,19 +174,11 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end) /* use the coreid bits from early_identify_cpu */ bits = boot_cpu_data.x86_coreid_bits; cores = (1< 0) { - printk(KERN_INFO "BSP APIC ID: %02x\n", - boot_cpu_physical_apicid); - apicid_base = boot_cpu_physical_apicid; - } for (i = 0; i < 8; i++) { if (nodes[i].start != nodes[i].end) { nodeid = nodeids[i]; - for (j = apicid_base; j < cores + apicid_base; j++) + for (j = 0; j < cores; j++) apicid_to_node[(nodeid << bits) + j] = i; setup_node_bootmem(i, nodes[i].start, nodes[i].end); } diff --git a/trunk/arch/x86/pci/Makefile_32 b/trunk/arch/x86/pci/Makefile_32 index 2a1516efb542..cdd6828b5abb 100644 --- a/trunk/arch/x86/pci/Makefile_32 +++ b/trunk/arch/x86/pci/Makefile_32 @@ -3,7 +3,6 @@ obj-y := i386.o init.o obj-$(CONFIG_PCI_BIOS) += pcbios.o obj-$(CONFIG_PCI_MMCONFIG) += mmconfig_32.o direct.o mmconfig-shared.o obj-$(CONFIG_PCI_DIRECT) += direct.o -obj-$(CONFIG_PCI_OLPC) += olpc.o pci-y := fixup.o pci-$(CONFIG_ACPI) += acpi.o @@ -11,6 +10,5 @@ pci-y += legacy.o irq.o pci-$(CONFIG_X86_VISWS) := visws.o fixup.o pci-$(CONFIG_X86_NUMAQ) := numa.o irq.o -pci-$(CONFIG_NUMA) += mp_bus_to_node.o obj-y += $(pci-y) common.o early.o diff --git a/trunk/arch/x86/pci/Makefile_64 b/trunk/arch/x86/pci/Makefile_64 index 8fbd19832cf6..7d8c467bf143 100644 --- a/trunk/arch/x86/pci/Makefile_64 +++ b/trunk/arch/x86/pci/Makefile_64 @@ -13,5 +13,5 @@ obj-y += legacy.o irq.o common.o early.o # mmconfig has a 64bit special obj-$(CONFIG_PCI_MMCONFIG) += mmconfig_64.o direct.o mmconfig-shared.o -obj-y += k8-bus_64.o +obj-$(CONFIG_NUMA) += k8-bus_64.o diff --git a/trunk/arch/x86/pci/acpi.c b/trunk/arch/x86/pci/acpi.c index 1a9c0c6a1a18..2664cb3fc96c 100644 --- a/trunk/arch/x86/pci/acpi.c +++ b/trunk/arch/x86/pci/acpi.c @@ -191,10 +191,7 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_device *device, int do { struct pci_bus *bus; struct pci_sysdata *sd; - int node; -#ifdef CONFIG_ACPI_NUMA int pxm; -#endif dmi_check_system(acpi_pciprobe_dmi_table); @@ -204,17 +201,6 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_device *device, int do return NULL; } - node = -1; -#ifdef CONFIG_ACPI_NUMA - pxm = acpi_get_pxm(device->handle); - if (pxm >= 0) - node = pxm_to_node(pxm); - if (node != -1) - set_mp_bus_to_node(busnum, node); - else - node = get_mp_bus_to_node(busnum); -#endif - /* Allocate per-root-bus (not per bus) arch-specific data. * TODO: leak; this memory is never freed. * It's arguable whether it's worth the trouble to care. @@ -226,7 +212,13 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_device *device, int do } sd->domain = domain; - sd->node = node; + sd->node = -1; + + pxm = acpi_get_pxm(device->handle); +#ifdef CONFIG_ACPI_NUMA + if (pxm >= 0) + sd->node = pxm_to_node(pxm); +#endif /* * Maybe the desired pci bus has been already scanned. In such case * it is unnecessary to scan the pci bus with the given domain,busnum. @@ -246,9 +238,9 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_device *device, int do kfree(sd); #ifdef CONFIG_ACPI_NUMA - if (bus) { + if (bus != NULL) { if (pxm >= 0) { - printk(KERN_DEBUG "bus %02x -> pxm %d -> node %d\n", + printk("bus %d -> pxm %d -> node %d\n", busnum, pxm, pxm_to_node(pxm)); } } @@ -256,6 +248,7 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_device *device, int do if (bus && (pci_probe & PCI_USE__CRS)) get_current_resources(device, busnum, domain, bus); + return bus; } diff --git a/trunk/arch/x86/pci/common.c b/trunk/arch/x86/pci/common.c index 2a4d751818b7..75fcc29ecf52 100644 --- a/trunk/arch/x86/pci/common.c +++ b/trunk/arch/x86/pci/common.c @@ -342,14 +342,9 @@ struct pci_bus * __devinit pcibios_scan_root(int busnum) return NULL; } - sd->node = get_mp_bus_to_node(busnum); - printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum); - bus = pci_scan_bus_parented(NULL, busnum, &pci_root_ops, sd); - if (!bus) - kfree(sd); - return bus; + return pci_scan_bus_parented(NULL, busnum, &pci_root_ops, sd); } extern u8 pci_cache_line_size; @@ -425,10 +420,6 @@ char * __devinit pcibios_setup(char *str) pci_probe &= ~PCI_PROBE_MMCONF; return NULL; } - else if (!strcmp(str, "check_enable_amd_mmconf")) { - pci_probe |= PCI_CHECK_ENABLE_AMD_MMCONF; - return NULL; - } #endif else if (!strcmp(str, "noacpi")) { acpi_noirq_set(); @@ -489,7 +480,7 @@ void pcibios_disable_device (struct pci_dev *dev) pcibios_disable_irq(dev); } -struct pci_bus *pci_scan_bus_on_node(int busno, struct pci_ops *ops, int node) +struct pci_bus *__devinit pci_scan_bus_with_sysdata(int busno) { struct pci_bus *bus = NULL; struct pci_sysdata *sd; @@ -504,15 +495,10 @@ struct pci_bus *pci_scan_bus_on_node(int busno, struct pci_ops *ops, int node) printk(KERN_ERR "PCI: OOM, skipping PCI bus %02x\n", busno); return NULL; } - sd->node = node; - bus = pci_scan_bus(busno, ops, sd); + sd->node = -1; + bus = pci_scan_bus(busno, &pci_root_ops, sd); if (!bus) kfree(sd); return bus; } - -struct pci_bus *pci_scan_bus_with_sysdata(int busno) -{ - return pci_scan_bus_on_node(busno, &pci_root_ops, -1); -} diff --git a/trunk/arch/x86/pci/direct.c b/trunk/arch/x86/pci/direct.c index 21d1e0e0d535..42f3e4cad179 100644 --- a/trunk/arch/x86/pci/direct.c +++ b/trunk/arch/x86/pci/direct.c @@ -258,8 +258,7 @@ void __init pci_direct_init(int type) { if (type == 0) return; - printk(KERN_INFO "PCI: Using configuration type %d for base access\n", - type); + printk(KERN_INFO "PCI: Using configuration type %d\n", type); if (type == 1) raw_pci_ops = &pci_direct_conf1; else @@ -276,10 +275,8 @@ int __init pci_direct_probe(void) if (!region) goto type2; - if (pci_check_type1()) { - raw_pci_ops = &pci_direct_conf1; + if (pci_check_type1()) return 1; - } release_resource(region); type2: @@ -293,6 +290,7 @@ int __init pci_direct_probe(void) goto fail2; if (pci_check_type2()) { + printk(KERN_INFO "PCI: Using configuration type 2\n"); raw_pci_ops = &pci_direct_conf2; return 2; } diff --git a/trunk/arch/x86/pci/fixup.c b/trunk/arch/x86/pci/fixup.c index b60b2abd480c..a5ef5f551373 100644 --- a/trunk/arch/x86/pci/fixup.c +++ b/trunk/arch/x86/pci/fixup.c @@ -493,20 +493,3 @@ static void __devinit pci_siemens_interrupt_controller(struct pci_dev *dev) } DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SIEMENS, 0x0015, pci_siemens_interrupt_controller); - -/* - * Regular PCI devices have 256 bytes, but AMD Family 10h Opteron ext config - * have 4096 bytes. Even if the device is capable, that doesn't mean we can - * access it. Maybe we don't have a way to generate extended config space - * accesses. So check it - */ -static void fam10h_pci_cfg_space_size(struct pci_dev *dev) -{ - dev->cfg_size = pci_cfg_space_size_ext(dev, 0); -} - -DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, 0x1200, fam10h_pci_cfg_space_size); -DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, 0x1201, fam10h_pci_cfg_space_size); -DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, 0x1202, fam10h_pci_cfg_space_size); -DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, 0x1203, fam10h_pci_cfg_space_size); -DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, 0x1204, fam10h_pci_cfg_space_size); diff --git a/trunk/arch/x86/pci/init.c b/trunk/arch/x86/pci/init.c index dd30c6076b5d..3de9f9ba2da6 100644 --- a/trunk/arch/x86/pci/init.c +++ b/trunk/arch/x86/pci/init.c @@ -6,17 +6,16 @@ in the right sequence from here. */ static __init int pci_access_init(void) { -#ifdef CONFIG_PCI_DIRECT - int type = 0; + int type __maybe_unused = 0; +#ifdef CONFIG_PCI_DIRECT type = pci_direct_probe(); #endif - - pci_mmcfg_early_init(); - -#ifdef CONFIG_PCI_OLPC - pci_olpc_init(); +#ifdef CONFIG_PCI_MMCONFIG + pci_mmcfg_init(type); #endif + if (raw_pci_ops) + return 0; #ifdef CONFIG_PCI_BIOS pci_pcbios_init(); #endif @@ -29,7 +28,7 @@ static __init int pci_access_init(void) #ifdef CONFIG_PCI_DIRECT pci_direct_init(type); #endif - if (!raw_pci_ops && !raw_pci_ext_ops) + if (!raw_pci_ops) printk(KERN_ERR "PCI: Fatal: No config space access function found\n"); diff --git a/trunk/arch/x86/pci/irq.c b/trunk/arch/x86/pci/irq.c index 0908fca901bf..579745ca6b66 100644 --- a/trunk/arch/x86/pci/irq.c +++ b/trunk/arch/x86/pci/irq.c @@ -136,11 +136,9 @@ static void __init pirq_peer_trick(void) busmap[e->bus] = 1; } for(i = 1; i < 256; i++) { - int node; if (!busmap[i] || pci_find_bus(0, i)) continue; - node = get_mp_bus_to_node(i); - if (pci_scan_bus_on_node(i, &pci_root_ops, node)) + if (pci_scan_bus_with_sysdata(i)) printk(KERN_INFO "PCI: Discovered primary peer " "bus %02x [IRQ]\n", i); } diff --git a/trunk/arch/x86/pci/k8-bus_64.c b/trunk/arch/x86/pci/k8-bus_64.c index ab6d4b18a88f..9cc813e29706 100644 --- a/trunk/arch/x86/pci/k8-bus_64.c +++ b/trunk/arch/x86/pci/k8-bus_64.c @@ -1,536 +1,83 @@ #include #include -#include #include #include -#include /* * This discovers the pcibus <-> node mapping on AMD K8. - * also get peer root bus resource for io,mmio + * + * RED-PEN need to call this again on PCI hotplug + * RED-PEN empty cpus get reported wrong */ - -/* - * sub bus (transparent) will use entres from 3 to store extra from root, - * so need to make sure have enought slot there, increase PCI_BUS_NUM_RESOURCES? - */ -#define RES_NUM 16 -struct pci_root_info { - char name[12]; - unsigned int res_num; - struct resource res[RES_NUM]; - int bus_min; - int bus_max; - int node; - int link; -}; - -/* 4 at this time, it may become to 32 */ -#define PCI_ROOT_NR 4 -static int pci_root_num; -static struct pci_root_info pci_root_info[PCI_ROOT_NR]; - -#ifdef CONFIG_NUMA - -#define BUS_NR 256 - -static int mp_bus_to_node[BUS_NR]; - -void set_mp_bus_to_node(int busnum, int node) -{ - if (busnum >= 0 && busnum < BUS_NR) - mp_bus_to_node[busnum] = node; -} - -int get_mp_bus_to_node(int busnum) -{ - int node = -1; - - if (busnum < 0 || busnum > (BUS_NR - 1)) - return node; - - node = mp_bus_to_node[busnum]; - - /* - * let numa_node_id to decide it later in dma_alloc_pages - * if there is no ram on that node - */ - if (node != -1 && !node_online(node)) - node = -1; - - return node; -} -#endif - -void set_pci_bus_resources_arch_default(struct pci_bus *b) -{ - int i; - int j; - struct pci_root_info *info; - - /* if only one root bus, don't need to anything */ - if (pci_root_num < 2) - return; - - for (i = 0; i < pci_root_num; i++) { - if (pci_root_info[i].bus_min == b->number) - break; - } - - if (i == pci_root_num) - return; - - info = &pci_root_info[i]; - for (j = 0; j < info->res_num; j++) { - struct resource *res; - struct resource *root; - - res = &info->res[j]; - b->resource[j] = res; - if (res->flags & IORESOURCE_IO) - root = &ioport_resource; - else - root = &iomem_resource; - insert_resource(root, res); - } -} - -#define RANGE_NUM 16 - -struct res_range { - size_t start; - size_t end; -}; - -static void __init update_range(struct res_range *range, size_t start, - size_t end) -{ - int i; - int j; - - for (j = 0; j < RANGE_NUM; j++) { - if (!range[j].end) - continue; - - if (start <= range[j].start && end >= range[j].end) { - range[j].start = 0; - range[j].end = 0; - continue; - } - - if (start <= range[j].start && end < range[j].end && range[j].start < end + 1) { - range[j].start = end + 1; - continue; - } - - - if (start > range[j].start && end >= range[j].end && range[j].end > start - 1) { - range[j].end = start - 1; - continue; - } - - if (start > range[j].start && end < range[j].end) { - /* find the new spare */ - for (i = 0; i < RANGE_NUM; i++) { - if (range[i].end == 0) - break; - } - if (i < RANGE_NUM) { - range[i].end = range[j].end; - range[i].start = end + 1; - } else { - printk(KERN_ERR "run of slot in ranges\n"); - } - range[j].end = start - 1; - continue; - } - } -} - -static void __init update_res(struct pci_root_info *info, size_t start, - size_t end, unsigned long flags, int merge) -{ - int i; - struct resource *res; - - if (!merge) - goto addit; - - /* try to merge it with old one */ - for (i = 0; i < info->res_num; i++) { - size_t final_start, final_end; - size_t common_start, common_end; - - res = &info->res[i]; - if (res->flags != flags) - continue; - - common_start = max((size_t)res->start, start); - common_end = min((size_t)res->end, end); - if (common_start > common_end + 1) - continue; - - final_start = min((size_t)res->start, start); - final_end = max((size_t)res->end, end); - - res->start = final_start; - res->end = final_end; - return; - } - -addit: - - /* need to add that */ - if (info->res_num >= RES_NUM) - return; - - res = &info->res[info->res_num]; - res->name = info->name; - res->flags = flags; - res->start = start; - res->end = end; - res->child = NULL; - info->res_num++; -} - -struct pci_hostbridge_probe { - u32 bus; - u32 slot; - u32 vendor; - u32 device; -}; - -static struct pci_hostbridge_probe pci_probes[] __initdata = { - { 0, 0x18, PCI_VENDOR_ID_AMD, 0x1100 }, - { 0, 0x18, PCI_VENDOR_ID_AMD, 0x1200 }, - { 0xff, 0, PCI_VENDOR_ID_AMD, 0x1200 }, - { 0, 0x18, PCI_VENDOR_ID_AMD, 0x1300 }, -}; - -static u64 __initdata fam10h_mmconf_start; -static u64 __initdata fam10h_mmconf_end; -static void __init get_pci_mmcfg_amd_fam10h_range(void) -{ - u32 address; - u64 base, msr; - unsigned segn_busn_bits; - - /* assume all cpus from fam10h have mmconf */ - if (boot_cpu_data.x86 < 0x10) - return; - - address = MSR_FAM10H_MMIO_CONF_BASE; - rdmsrl(address, msr); - - /* mmconfig is not enable */ - if (!(msr & FAM10H_MMIO_CONF_ENABLE)) - return; - - base = msr & (FAM10H_MMIO_CONF_BASE_MASK<> FAM10H_MMIO_CONF_BUSRANGE_SHIFT) & - FAM10H_MMIO_CONF_BUSRANGE_MASK; - - fam10h_mmconf_start = base; - fam10h_mmconf_end = base + (1ULL<<(segn_busn_bits + 20)) - 1; -} +#define NODE_ID_REGISTER 0x60 +#define NODE_ID(dword) (dword & 0x07) +#define LDT_BUS_NUMBER_REGISTER_0 0x94 +#define LDT_BUS_NUMBER_REGISTER_1 0xB4 +#define LDT_BUS_NUMBER_REGISTER_2 0xD4 +#define NR_LDT_BUS_NUMBER_REGISTERS 3 +#define SECONDARY_LDT_BUS_NUMBER(dword) ((dword >> 8) & 0xFF) +#define SUBORDINATE_LDT_BUS_NUMBER(dword) ((dword >> 16) & 0xFF) +#define PCI_DEVICE_ID_K8HTCONFIG 0x1100 /** - * early_fill_mp_bus_to_node() - * called before pcibios_scan_root and pci_scan_bus + * fill_mp_bus_to_cpumask() * fills the mp_bus_to_cpumask array based according to the LDT Bus Number * Registers found in the K8 northbridge */ -static int __init early_fill_mp_bus_info(void) +__init static int +fill_mp_bus_to_cpumask(void) { - int i; - int j; - unsigned bus; - unsigned slot; - int found; - int node; - int link; - int def_node; - int def_link; - struct pci_root_info *info; - u32 reg; - struct resource *res; - size_t start; - size_t end; - struct res_range range[RANGE_NUM]; - u64 val; - u32 address; - -#ifdef CONFIG_NUMA - for (i = 0; i < BUS_NR; i++) - mp_bus_to_node[i] = -1; -#endif - - if (!early_pci_allowed()) - return -1; - - found = 0; - for (i = 0; i < ARRAY_SIZE(pci_probes); i++) { - u32 id; - u16 device; - u16 vendor; - - bus = pci_probes[i].bus; - slot = pci_probes[i].slot; - id = read_pci_config(bus, slot, 0, PCI_VENDOR_ID); - - vendor = id & 0xffff; - device = (id>>16) & 0xffff; - if (pci_probes[i].vendor == vendor && - pci_probes[i].device == device) { - found = 1; - break; - } - } - - if (!found) - return 0; - - pci_root_num = 0; - for (i = 0; i < 4; i++) { - int min_bus; - int max_bus; - reg = read_pci_config(bus, slot, 1, 0xe0 + (i << 2)); - - /* Check if that register is enabled for bus range */ - if ((reg & 7) != 3) - continue; - - min_bus = (reg >> 16) & 0xff; - max_bus = (reg >> 24) & 0xff; - node = (reg >> 4) & 0x07; -#ifdef CONFIG_NUMA - for (j = min_bus; j <= max_bus; j++) - mp_bus_to_node[j] = (unsigned char) node; -#endif - link = (reg >> 8) & 0x03; - - info = &pci_root_info[pci_root_num]; - info->bus_min = min_bus; - info->bus_max = max_bus; - info->node = node; - info->link = link; - sprintf(info->name, "PCI Bus #%02x", min_bus); - pci_root_num++; - } - - /* get the default node and link for left over res */ - reg = read_pci_config(bus, slot, 0, 0x60); - def_node = (reg >> 8) & 0x07; - reg = read_pci_config(bus, slot, 0, 0x64); - def_link = (reg >> 8) & 0x03; - - memset(range, 0, sizeof(range)); - range[0].end = 0xffff; - /* io port resource */ - for (i = 0; i < 4; i++) { - reg = read_pci_config(bus, slot, 1, 0xc0 + (i << 3)); - if (!(reg & 3)) - continue; - - start = reg & 0xfff000; - reg = read_pci_config(bus, slot, 1, 0xc4 + (i << 3)); - node = reg & 0x07; - link = (reg >> 4) & 0x03; - end = (reg & 0xfff000) | 0xfff; - - /* find the position */ - for (j = 0; j < pci_root_num; j++) { - info = &pci_root_info[j]; - if (info->node == node && info->link == link) - break; - } - if (j == pci_root_num) - continue; /* not found */ - - info = &pci_root_info[j]; - printk(KERN_DEBUG "node %d link %d: io port [%llx, %llx]\n", - node, link, (u64)start, (u64)end); - - /* kernel only handle 16 bit only */ - if (end > 0xffff) - end = 0xffff; - update_res(info, start, end, IORESOURCE_IO, 1); - update_range(range, start, end); - } - /* add left over io port range to def node/link, [0, 0xffff] */ - /* find the position */ - for (j = 0; j < pci_root_num; j++) { - info = &pci_root_info[j]; - if (info->node == def_node && info->link == def_link) - break; - } - if (j < pci_root_num) { - info = &pci_root_info[j]; - for (i = 0; i < RANGE_NUM; i++) { - if (!range[i].end) - continue; - - update_res(info, range[i].start, range[i].end, - IORESOURCE_IO, 1); - } - } - - memset(range, 0, sizeof(range)); - /* 0xfd00000000-0xffffffffff for HT */ - range[0].end = (0xfdULL<<32) - 1; - - /* need to take out [0, TOM) for RAM*/ - address = MSR_K8_TOP_MEM1; - rdmsrl(address, val); - end = (val & 0xffffff8000000ULL); - printk(KERN_INFO "TOM: %016lx aka %ldM\n", end, end>>20); - if (end < (1ULL<<32)) - update_range(range, 0, end - 1); - - /* get mmconfig */ - get_pci_mmcfg_amd_fam10h_range(); - /* need to take out mmconf range */ - if (fam10h_mmconf_end) { - printk(KERN_DEBUG "Fam 10h mmconf [%llx, %llx]\n", fam10h_mmconf_start, fam10h_mmconf_end); - update_range(range, fam10h_mmconf_start, fam10h_mmconf_end); - } - - /* mmio resource */ - for (i = 0; i < 8; i++) { - reg = read_pci_config(bus, slot, 1, 0x80 + (i << 3)); - if (!(reg & 3)) - continue; - - start = reg & 0xffffff00; /* 39:16 on 31:8*/ - start <<= 8; - reg = read_pci_config(bus, slot, 1, 0x84 + (i << 3)); - node = reg & 0x07; - link = (reg >> 4) & 0x03; - end = (reg & 0xffffff00); - end <<= 8; - end |= 0xffff; - - /* find the position */ - for (j = 0; j < pci_root_num; j++) { - info = &pci_root_info[j]; - if (info->node == node && info->link == link) - break; - } - if (j == pci_root_num) - continue; /* not found */ - - info = &pci_root_info[j]; - - printk(KERN_DEBUG "node %d link %d: mmio [%llx, %llx]", - node, link, (u64)start, (u64)end); - /* - * some sick allocation would have range overlap with fam10h - * mmconf range, so need to update start and end. - */ - if (fam10h_mmconf_end) { - int changed = 0; - u64 endx = 0; - if (start >= fam10h_mmconf_start && - start <= fam10h_mmconf_end) { - start = fam10h_mmconf_end + 1; - changed = 1; - } - - if (end >= fam10h_mmconf_start && - end <= fam10h_mmconf_end) { - end = fam10h_mmconf_start - 1; - changed = 1; - } - - if (start < fam10h_mmconf_start && - end > fam10h_mmconf_end) { - /* we got a hole */ - endx = fam10h_mmconf_start - 1; - update_res(info, start, endx, IORESOURCE_MEM, 0); - update_range(range, start, endx); - printk(KERN_CONT " ==> [%llx, %llx]", (u64)start, endx); - start = fam10h_mmconf_end + 1; - changed = 1; - } - if (changed) { - if (start <= end) { - printk(KERN_CONT " %s [%llx, %llx]", endx?"and":"==>", (u64)start, (u64)end); - } else { - printk(KERN_CONT "%s\n", endx?"":" ==> none"); - continue; - } + struct pci_dev *nb_dev = NULL; + int i, j; + u32 ldtbus, nid; + static int lbnr[3] = { + LDT_BUS_NUMBER_REGISTER_0, + LDT_BUS_NUMBER_REGISTER_1, + LDT_BUS_NUMBER_REGISTER_2 + }; + + while ((nb_dev = pci_get_device(PCI_VENDOR_ID_AMD, + PCI_DEVICE_ID_K8HTCONFIG, nb_dev))) { + pci_read_config_dword(nb_dev, NODE_ID_REGISTER, &nid); + + for (i = 0; i < NR_LDT_BUS_NUMBER_REGISTERS; i++) { + pci_read_config_dword(nb_dev, lbnr[i], &ldtbus); + /* + * if there are no busses hanging off of the current + * ldt link then both the secondary and subordinate + * bus number fields are set to 0. + * + * RED-PEN + * This is slightly broken because it assumes + * HT node IDs == Linux node ids, which is not always + * true. However it is probably mostly true. + */ + if (!(SECONDARY_LDT_BUS_NUMBER(ldtbus) == 0 + && SUBORDINATE_LDT_BUS_NUMBER(ldtbus) == 0)) { + for (j = SECONDARY_LDT_BUS_NUMBER(ldtbus); + j <= SUBORDINATE_LDT_BUS_NUMBER(ldtbus); + j++) { + struct pci_bus *bus; + struct pci_sysdata *sd; + + long node = NODE_ID(nid); + /* Algorithm a bit dumb, but + it shouldn't matter here */ + bus = pci_find_bus(0, j); + if (!bus) + continue; + if (!node_online(node)) + node = 0; + + sd = bus->sysdata; + sd->node = node; + } } } - - update_res(info, start, end, IORESOURCE_MEM, 1); - update_range(range, start, end); - printk(KERN_CONT "\n"); - } - - /* need to take out [4G, TOM2) for RAM*/ - /* SYS_CFG */ - address = MSR_K8_SYSCFG; - rdmsrl(address, val); - /* TOP_MEM2 is enabled? */ - if (val & (1<<21)) { - /* TOP_MEM2 */ - address = MSR_K8_TOP_MEM2; - rdmsrl(address, val); - end = (val & 0xffffff8000000ULL); - printk(KERN_INFO "TOM2: %016lx aka %ldM\n", end, end>>20); - update_range(range, 1ULL<<32, end - 1); - } - - /* - * add left over mmio range to def node/link ? - * that is tricky, just record range in from start_min to 4G - */ - for (j = 0; j < pci_root_num; j++) { - info = &pci_root_info[j]; - if (info->node == def_node && info->link == def_link) - break; - } - if (j < pci_root_num) { - info = &pci_root_info[j]; - - for (i = 0; i < RANGE_NUM; i++) { - if (!range[i].end) - continue; - - update_res(info, range[i].start, range[i].end, - IORESOURCE_MEM, 1); - } - } - -#ifdef CONFIG_NUMA - for (i = 0; i < BUS_NR; i++) { - node = mp_bus_to_node[i]; - if (node >= 0) - printk(KERN_DEBUG "bus: %02x to node: %02x\n", i, node); - } -#endif - - for (i = 0; i < pci_root_num; i++) { - int res_num; - int busnum; - - info = &pci_root_info[i]; - res_num = info->res_num; - busnum = info->bus_min; - printk(KERN_DEBUG "bus: [%02x,%02x] on node %x link %x\n", - info->bus_min, info->bus_max, info->node, info->link); - for (j = 0; j < res_num; j++) { - res = &info->res[j]; - printk(KERN_DEBUG "bus: %02x index %x %s: [%llx, %llx]\n", - busnum, j, - (res->flags & IORESOURCE_IO)?"io port":"mmio", - res->start, res->end); - } } return 0; } -postcore_initcall(early_fill_mp_bus_info); +fs_initcall(fill_mp_bus_to_cpumask); diff --git a/trunk/arch/x86/pci/legacy.c b/trunk/arch/x86/pci/legacy.c index a67921ce60af..e041ced0ce13 100644 --- a/trunk/arch/x86/pci/legacy.c +++ b/trunk/arch/x86/pci/legacy.c @@ -12,7 +12,6 @@ static void __devinit pcibios_fixup_peer_bridges(void) { int n, devfn; - long node; if (pcibios_last_bus <= 0 || pcibios_last_bus >= 0xff) return; @@ -22,13 +21,12 @@ static void __devinit pcibios_fixup_peer_bridges(void) u32 l; if (pci_find_bus(0, n)) continue; - node = get_mp_bus_to_node(n); for (devfn = 0; devfn < 256; devfn += 8) { if (!raw_pci_read(0, n, devfn, PCI_VENDOR_ID, 2, &l) && l != 0x0000 && l != 0xffff) { DBG("Found device at %02x:%02x [%04x]\n", n, devfn, l); printk(KERN_INFO "PCI: Discovered peer bus %02x\n", n); - pci_scan_bus_on_node(n, &pci_root_ops, node); + pci_scan_bus_with_sysdata(n); break; } } diff --git a/trunk/arch/x86/pci/mmconfig-shared.c b/trunk/arch/x86/pci/mmconfig-shared.c index 0cfebecf2a8f..8d54df4dfaad 100644 --- a/trunk/arch/x86/pci/mmconfig-shared.c +++ b/trunk/arch/x86/pci/mmconfig-shared.c @@ -28,7 +28,7 @@ static int __initdata pci_mmcfg_resources_inserted; static const char __init *pci_mmcfg_e7520(void) { u32 win; - raw_pci_ops->read(0, 0, PCI_DEVFN(0, 0), 0xce, 2, &win); + pci_direct_conf1.read(0, 0, PCI_DEVFN(0,0), 0xce, 2, &win); win = win & 0xf000; if(win == 0x0000 || win == 0xf000) @@ -53,7 +53,7 @@ static const char __init *pci_mmcfg_intel_945(void) pci_mmcfg_config_num = 1; - raw_pci_ops->read(0, 0, PCI_DEVFN(0, 0), 0x48, 4, &pciexbar); + pci_direct_conf1.read(0, 0, PCI_DEVFN(0,0), 0x48, 4, &pciexbar); /* Enable bit */ if (!(pciexbar & 1)) @@ -100,102 +100,33 @@ static const char __init *pci_mmcfg_intel_945(void) return "Intel Corporation 945G/GZ/P/PL Express Memory Controller Hub"; } -static const char __init *pci_mmcfg_amd_fam10h(void) -{ - u32 low, high, address; - u64 base, msr; - int i; - unsigned segnbits = 0, busnbits; - - if (!(pci_probe & PCI_CHECK_ENABLE_AMD_MMCONF)) - return NULL; - - address = MSR_FAM10H_MMIO_CONF_BASE; - if (rdmsr_safe(address, &low, &high)) - return NULL; - - msr = high; - msr <<= 32; - msr |= low; - - /* mmconfig is not enable */ - if (!(msr & FAM10H_MMIO_CONF_ENABLE)) - return NULL; - - base = msr & (FAM10H_MMIO_CONF_BASE_MASK<> FAM10H_MMIO_CONF_BUSRANGE_SHIFT) & - FAM10H_MMIO_CONF_BUSRANGE_MASK; - - /* - * only handle bus 0 ? - * need to skip it - */ - if (!busnbits) - return NULL; - - if (busnbits > 8) { - segnbits = busnbits - 8; - busnbits = 8; - } - - pci_mmcfg_config_num = (1 << segnbits); - pci_mmcfg_config = kzalloc(sizeof(pci_mmcfg_config[0]) * - pci_mmcfg_config_num, GFP_KERNEL); - if (!pci_mmcfg_config) - return NULL; - - for (i = 0; i < (1 << segnbits); i++) { - pci_mmcfg_config[i].address = base + (1<<28) * i; - pci_mmcfg_config[i].pci_segment = i; - pci_mmcfg_config[i].start_bus_number = 0; - pci_mmcfg_config[i].end_bus_number = (1 << busnbits) - 1; - } - - return "AMD Family 10h NB"; -} - struct pci_mmcfg_hostbridge_probe { - u32 bus; - u32 devfn; u32 vendor; u32 device; const char *(*probe)(void); }; static struct pci_mmcfg_hostbridge_probe pci_mmcfg_probes[] __initdata = { - { 0, PCI_DEVFN(0, 0), PCI_VENDOR_ID_INTEL, - PCI_DEVICE_ID_INTEL_E7520_MCH, pci_mmcfg_e7520 }, - { 0, PCI_DEVFN(0, 0), PCI_VENDOR_ID_INTEL, - PCI_DEVICE_ID_INTEL_82945G_HB, pci_mmcfg_intel_945 }, - { 0, PCI_DEVFN(0x18, 0), PCI_VENDOR_ID_AMD, - 0x1200, pci_mmcfg_amd_fam10h }, - { 0xff, PCI_DEVFN(0, 0), PCI_VENDOR_ID_AMD, - 0x1200, pci_mmcfg_amd_fam10h }, + { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7520_MCH, pci_mmcfg_e7520 }, + { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82945G_HB, pci_mmcfg_intel_945 }, }; static int __init pci_mmcfg_check_hostbridge(void) { u32 l; - u32 bus, devfn; u16 vendor, device; int i; const char *name; - if (!raw_pci_ops) - return 0; + pci_direct_conf1.read(0, 0, PCI_DEVFN(0,0), 0, 4, &l); + vendor = l & 0xffff; + device = (l >> 16) & 0xffff; pci_mmcfg_config_num = 0; pci_mmcfg_config = NULL; name = NULL; for (i = 0; !name && i < ARRAY_SIZE(pci_mmcfg_probes); i++) { - bus = pci_mmcfg_probes[i].bus; - devfn = pci_mmcfg_probes[i].devfn; - raw_pci_ops->read(0, bus, devfn, 0, 4, &l); - vendor = l & 0xffff; - device = (l >> 16) & 0xffff; - if (pci_mmcfg_probes[i].vendor == vendor && pci_mmcfg_probes[i].device == device) name = pci_mmcfg_probes[i].probe(); @@ -242,78 +173,9 @@ static void __init pci_mmcfg_insert_resources(unsigned long resource_flags) pci_mmcfg_resources_inserted = 1; } -static acpi_status __init check_mcfg_resource(struct acpi_resource *res, - void *data) -{ - struct resource *mcfg_res = data; - struct acpi_resource_address64 address; - acpi_status status; - - if (res->type == ACPI_RESOURCE_TYPE_FIXED_MEMORY32) { - struct acpi_resource_fixed_memory32 *fixmem32 = - &res->data.fixed_memory32; - if (!fixmem32) - return AE_OK; - if ((mcfg_res->start >= fixmem32->address) && - (mcfg_res->end < (fixmem32->address + - fixmem32->address_length))) { - mcfg_res->flags = 1; - return AE_CTRL_TERMINATE; - } - } - if ((res->type != ACPI_RESOURCE_TYPE_ADDRESS32) && - (res->type != ACPI_RESOURCE_TYPE_ADDRESS64)) - return AE_OK; - - status = acpi_resource_to_address64(res, &address); - if (ACPI_FAILURE(status) || - (address.address_length <= 0) || - (address.resource_type != ACPI_MEMORY_RANGE)) - return AE_OK; - - if ((mcfg_res->start >= address.minimum) && - (mcfg_res->end < (address.minimum + address.address_length))) { - mcfg_res->flags = 1; - return AE_CTRL_TERMINATE; - } - return AE_OK; -} - -static acpi_status __init find_mboard_resource(acpi_handle handle, u32 lvl, - void *context, void **rv) -{ - struct resource *mcfg_res = context; - - acpi_walk_resources(handle, METHOD_NAME__CRS, - check_mcfg_resource, context); - - if (mcfg_res->flags) - return AE_CTRL_TERMINATE; - - return AE_OK; -} - -static int __init is_acpi_reserved(unsigned long start, unsigned long end) -{ - struct resource mcfg_res; - - mcfg_res.start = start; - mcfg_res.end = end; - mcfg_res.flags = 0; - - acpi_get_devices("PNP0C01", find_mboard_resource, &mcfg_res, NULL); - - if (!mcfg_res.flags) - acpi_get_devices("PNP0C02", find_mboard_resource, &mcfg_res, - NULL); - - return mcfg_res.flags; -} - -static void __init pci_mmcfg_reject_broken(int early) +static void __init pci_mmcfg_reject_broken(int type) { typeof(pci_mmcfg_config[0]) *cfg; - int i; if ((pci_mmcfg_config_num == 0) || (pci_mmcfg_config == NULL) || @@ -322,80 +184,51 @@ static void __init pci_mmcfg_reject_broken(int early) cfg = &pci_mmcfg_config[0]; - for (i = 0; i < pci_mmcfg_config_num; i++) { - int valid = 0; - u32 size = (cfg->end_bus_number + 1) << 20; - cfg = &pci_mmcfg_config[i]; - printk(KERN_NOTICE "PCI: MCFG configuration %d: base %lx " - "segment %hu buses %u - %u\n", - i, (unsigned long)cfg->address, cfg->pci_segment, - (unsigned int)cfg->start_bus_number, - (unsigned int)cfg->end_bus_number); - - if (!early && - is_acpi_reserved(cfg->address, cfg->address + size - 1)) { - printk(KERN_NOTICE "PCI: MCFG area at %Lx reserved " - "in ACPI motherboard resources\n", - cfg->address); - valid = 1; - } - - if (valid) - continue; - - if (!early) - printk(KERN_ERR "PCI: BIOS Bug: MCFG area at %Lx is not" - " reserved in ACPI motherboard resources\n", - cfg->address); - /* Don't try to do this check unless configuration - type 1 is available. how about type 2 ?*/ - if (raw_pci_ops && e820_all_mapped(cfg->address, - cfg->address + size - 1, - E820_RESERVED)) { - printk(KERN_NOTICE - "PCI: MCFG area at %Lx reserved in E820\n", - cfg->address); - valid = 1; - } - - if (!valid) - goto reject; + /* + * Handle more broken MCFG tables on Asus etc. + * They only contain a single entry for bus 0-0. + */ + if (pci_mmcfg_config_num == 1 && + cfg->pci_segment == 0 && + (cfg->start_bus_number | cfg->end_bus_number) == 0) { + printk(KERN_ERR "PCI: start and end of bus number is 0. " + "Rejected as broken MCFG.\n"); + goto reject; } + /* + * Only do this check when type 1 works. If it doesn't work + * assume we run on a Mac and always use MCFG + */ + if (type == 1 && !e820_all_mapped(cfg->address, + cfg->address + MMCONFIG_APER_MIN, + E820_RESERVED)) { + printk(KERN_ERR "PCI: BIOS Bug: MCFG area at %Lx is not" + " E820-reserved\n", cfg->address); + goto reject; + } return; reject: printk(KERN_ERR "PCI: Not using MMCONFIG.\n"); - pci_mmcfg_arch_free(); kfree(pci_mmcfg_config); pci_mmcfg_config = NULL; pci_mmcfg_config_num = 0; } -static int __initdata known_bridge; - -void __init __pci_mmcfg_init(int early) +void __init pci_mmcfg_init(int type) { - /* MMCONFIG disabled */ - if ((pci_probe & PCI_PROBE_MMCONF) == 0) - return; + int known_bridge = 0; - /* MMCONFIG already enabled */ - if (!early && !(pci_probe & PCI_PROBE_MASK & ~PCI_PROBE_MMCONF)) - return; - - /* for late to exit */ - if (known_bridge) + if ((pci_probe & PCI_PROBE_MMCONF) == 0) return; - if (early) { - if (pci_mmcfg_check_hostbridge()) - known_bridge = 1; - } + if (type == 1 && pci_mmcfg_check_hostbridge()) + known_bridge = 1; if (!known_bridge) { acpi_table_parse(ACPI_SIG_MCFG, acpi_parse_mcfg); - pci_mmcfg_reject_broken(early); + pci_mmcfg_reject_broken(type); } if ((pci_mmcfg_config_num == 0) || @@ -416,16 +249,6 @@ void __init __pci_mmcfg_init(int early) } } -void __init pci_mmcfg_early_init(void) -{ - __pci_mmcfg_init(1); -} - -void __init pci_mmcfg_late_init(void) -{ - __pci_mmcfg_init(0); -} - static int __init pci_mmcfg_late_insert_resources(void) { /* diff --git a/trunk/arch/x86/pci/mmconfig_32.c b/trunk/arch/x86/pci/mmconfig_32.c index f3c761dce695..081816ada057 100644 --- a/trunk/arch/x86/pci/mmconfig_32.c +++ b/trunk/arch/x86/pci/mmconfig_32.c @@ -136,7 +136,3 @@ int __init pci_mmcfg_arch_init(void) raw_pci_ext_ops = &pci_mmcfg; return 1; } - -void __init pci_mmcfg_arch_free(void) -{ -} diff --git a/trunk/arch/x86/pci/mmconfig_64.c b/trunk/arch/x86/pci/mmconfig_64.c index a1994163c99d..9207fd49233c 100644 --- a/trunk/arch/x86/pci/mmconfig_64.c +++ b/trunk/arch/x86/pci/mmconfig_64.c @@ -127,7 +127,7 @@ static void __iomem * __init mcfg_ioremap(struct acpi_mcfg_allocation *cfg) int __init pci_mmcfg_arch_init(void) { int i; - pci_mmcfg_virt = kzalloc(sizeof(*pci_mmcfg_virt) * + pci_mmcfg_virt = kmalloc(sizeof(*pci_mmcfg_virt) * pci_mmcfg_config_num, GFP_KERNEL); if (pci_mmcfg_virt == NULL) { printk(KERN_ERR "PCI: Can not allocate memory for mmconfig structures\n"); @@ -141,29 +141,9 @@ int __init pci_mmcfg_arch_init(void) printk(KERN_ERR "PCI: Cannot map mmconfig aperture for " "segment %d\n", pci_mmcfg_config[i].pci_segment); - pci_mmcfg_arch_free(); return 0; } } raw_pci_ext_ops = &pci_mmcfg; return 1; } - -void __init pci_mmcfg_arch_free(void) -{ - int i; - - if (pci_mmcfg_virt == NULL) - return; - - for (i = 0; i < pci_mmcfg_config_num; ++i) { - if (pci_mmcfg_virt[i].virt) { - iounmap(pci_mmcfg_virt[i].virt); - pci_mmcfg_virt[i].virt = NULL; - pci_mmcfg_virt[i].cfg = NULL; - } - } - - kfree(pci_mmcfg_virt); - pci_mmcfg_virt = NULL; -} diff --git a/trunk/arch/x86/pci/mp_bus_to_node.c b/trunk/arch/x86/pci/mp_bus_to_node.c deleted file mode 100644 index 022943999b84..000000000000 --- a/trunk/arch/x86/pci/mp_bus_to_node.c +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include -#include - -#define BUS_NR 256 - -static unsigned char mp_bus_to_node[BUS_NR]; - -void set_mp_bus_to_node(int busnum, int node) -{ - if (busnum >= 0 && busnum < BUS_NR) - mp_bus_to_node[busnum] = (unsigned char) node; -} - -int get_mp_bus_to_node(int busnum) -{ - int node; - - if (busnum < 0 || busnum > (BUS_NR - 1)) - return 0; - node = mp_bus_to_node[busnum]; - return node; -} diff --git a/trunk/arch/x86/pci/olpc.c b/trunk/arch/x86/pci/olpc.c deleted file mode 100644 index 5e7636558c02..000000000000 --- a/trunk/arch/x86/pci/olpc.c +++ /dev/null @@ -1,313 +0,0 @@ -/* - * Low-level PCI config space access for OLPC systems who lack the VSA - * PCI virtualization software. - * - * Copyright © 2006 Advanced Micro Devices, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * The AMD Geode chipset (ie: GX2 processor, cs5536 I/O companion device) - * has some I/O functions (display, southbridge, sound, USB HCIs, etc) - * that more or less behave like PCI devices, but the hardware doesn't - * directly implement the PCI configuration space headers. AMD provides - * "VSA" (Virtual System Architecture) software that emulates PCI config - * space for these devices, by trapping I/O accesses to PCI config register - * (CF8/CFC) and running some code in System Management Mode interrupt state. - * On the OLPC platform, we don't want to use that VSA code because - * (a) it slows down suspend/resume, and (b) recompiling it requires special - * compilers that are hard to get. So instead of letting the complex VSA - * code simulate the PCI config registers for the on-chip devices, we - * just simulate them the easy way, by inserting the code into the - * pci_write_config and pci_read_config path. Most of the config registers - * are read-only anyway, so the bulk of the simulation is just table lookup. - */ - -#include -#include -#include -#include -#include "pci.h" - -/* - * In the tables below, the first two line (8 longwords) are the - * size masks that are used when the higher level PCI code determines - * the size of the region by writing ~0 to a base address register - * and reading back the result. - * - * The following lines are the values that are read during normal - * PCI config access cycles, i.e. not after just having written - * ~0 to a base address register. - */ - -static const uint32_t lxnb_hdr[] = { /* dev 1 function 0 - devfn = 8 */ - 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, - - 0x281022, 0x2200005, 0x6000021, 0x80f808, /* AMD Vendor ID */ - 0x0, 0x0, 0x0, 0x0, /* No virtual registers, hence no BAR */ - 0x0, 0x0, 0x0, 0x28100b, - 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, -}; - -static const uint32_t gxnb_hdr[] = { /* dev 1 function 0 - devfn = 8 */ - 0xfffffffd, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, - - 0x28100b, 0x2200005, 0x6000021, 0x80f808, /* NSC Vendor ID */ - 0xac1d, 0x0, 0x0, 0x0, /* I/O BAR - base of virtual registers */ - 0x0, 0x0, 0x0, 0x28100b, - 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, -}; - -static const uint32_t lxfb_hdr[] = { /* dev 1 function 1 - devfn = 9 */ - 0xff000008, 0xffffc000, 0xffffc000, 0xffffc000, - 0xffffc000, 0x0, 0x0, 0x0, - - 0x20811022, 0x2200003, 0x3000000, 0x0, /* AMD Vendor ID */ - 0xfd000000, 0xfe000000, 0xfe004000, 0xfe008000, /* FB, GP, VG, DF */ - 0xfe00c000, 0x0, 0x0, 0x30100b, /* VIP */ - 0x0, 0x0, 0x0, 0x10e, /* INTA, IRQ14 for graphics accel */ - 0x0, 0x0, 0x0, 0x0, - 0x3d0, 0x3c0, 0xa0000, 0x0, /* VG IO, VG IO, EGA FB, MONO FB */ - 0x0, 0x0, 0x0, 0x0, -}; - -static const uint32_t gxfb_hdr[] = { /* dev 1 function 1 - devfn = 9 */ - 0xff800008, 0xffffc000, 0xffffc000, 0xffffc000, - 0x0, 0x0, 0x0, 0x0, - - 0x30100b, 0x2200003, 0x3000000, 0x0, /* NSC Vendor ID */ - 0xfd000000, 0xfe000000, 0xfe004000, 0xfe008000, /* FB, GP, VG, DF */ - 0x0, 0x0, 0x0, 0x30100b, - 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, - 0x3d0, 0x3c0, 0xa0000, 0x0, /* VG IO, VG IO, EGA FB, MONO FB */ - 0x0, 0x0, 0x0, 0x0, -}; - -static const uint32_t aes_hdr[] = { /* dev 1 function 2 - devfn = 0xa */ - 0xffffc000, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, - - 0x20821022, 0x2a00006, 0x10100000, 0x8, /* NSC Vendor ID */ - 0xfe010000, 0x0, 0x0, 0x0, /* AES registers */ - 0x0, 0x0, 0x0, 0x20821022, - 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, -}; - - -static const uint32_t isa_hdr[] = { /* dev f function 0 - devfn = 78 */ - 0xfffffff9, 0xffffff01, 0xffffffc1, 0xffffffe1, - 0xffffff81, 0xffffffc1, 0x0, 0x0, - - 0x20901022, 0x2a00049, 0x6010003, 0x802000, - 0x18b1, 0x1001, 0x1801, 0x1881, /* SMB-8 GPIO-256 MFGPT-64 IRQ-32 */ - 0x1401, 0x1841, 0x0, 0x20901022, /* PMS-128 ACPI-64 */ - 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xaa5b, /* IRQ steering */ - 0x0, 0x0, 0x0, 0x0, -}; - -static const uint32_t ac97_hdr[] = { /* dev f function 3 - devfn = 7b */ - 0xffffff81, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, - - 0x20931022, 0x2a00041, 0x4010001, 0x0, - 0x1481, 0x0, 0x0, 0x0, /* I/O BAR-128 */ - 0x0, 0x0, 0x0, 0x20931022, - 0x0, 0x0, 0x0, 0x205, /* IntB, IRQ5 */ - 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, -}; - -static const uint32_t ohci_hdr[] = { /* dev f function 4 - devfn = 7c */ - 0xfffff000, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, - - 0x20941022, 0x2300006, 0xc031002, 0x0, - 0xfe01a000, 0x0, 0x0, 0x0, /* MEMBAR-1000 */ - 0x0, 0x0, 0x0, 0x20941022, - 0x0, 0x40, 0x0, 0x40a, /* CapPtr INT-D, IRQA */ - 0xc8020001, 0x0, 0x0, 0x0, /* Capabilities - 40 is R/O, - 44 is mask 8103 (power control) */ - 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, -}; - -static const uint32_t ehci_hdr[] = { /* dev f function 4 - devfn = 7d */ - 0xfffff000, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, - - 0x20951022, 0x2300006, 0xc032002, 0x0, - 0xfe01b000, 0x0, 0x0, 0x0, /* MEMBAR-1000 */ - 0x0, 0x0, 0x0, 0x20951022, - 0x0, 0x40, 0x0, 0x40a, /* CapPtr INT-D, IRQA */ - 0xc8020001, 0x0, 0x0, 0x0, /* Capabilities - 40 is R/O, 44 is - mask 8103 (power control) */ -#if 0 - 0x1, 0x40080000, 0x0, 0x0, /* EECP - see EHCI spec section 2.1.7 */ -#endif - 0x01000001, 0x0, 0x0, 0x0, /* EECP - see EHCI spec section 2.1.7 */ - 0x2020, 0x0, 0x0, 0x0, /* (EHCI page 8) 60 SBRN (R/O), - 61 FLADJ (R/W), PORTWAKECAP */ -}; - -static uint32_t ff_loc = ~0; -static uint32_t zero_loc; -static int bar_probing; /* Set after a write of ~0 to a BAR */ -static int is_lx; - -#define NB_SLOT 0x1 /* Northbridge - GX chip - Device 1 */ -#define SB_SLOT 0xf /* Southbridge - CS5536 chip - Device F */ - -static int is_simulated(unsigned int bus, unsigned int devfn) -{ - return (!bus && ((PCI_SLOT(devfn) == NB_SLOT) || - (PCI_SLOT(devfn) == SB_SLOT))); -} - -static uint32_t *hdr_addr(const uint32_t *hdr, int reg) -{ - uint32_t addr; - - /* - * This is a little bit tricky. The header maps consist of - * 0x20 bytes of size masks, followed by 0x70 bytes of header data. - * In the normal case, when not probing a BAR's size, we want - * to access the header data, so we add 0x20 to the reg offset, - * thus skipping the size mask area. - * In the BAR probing case, we want to access the size mask for - * the BAR, so we subtract 0x10 (the config header offset for - * BAR0), and don't skip the size mask area. - */ - - addr = (uint32_t)hdr + reg + (bar_probing ? -0x10 : 0x20); - - bar_probing = 0; - return (uint32_t *)addr; -} - -static int pci_olpc_read(unsigned int seg, unsigned int bus, - unsigned int devfn, int reg, int len, uint32_t *value) -{ - uint32_t *addr; - - /* Use the hardware mechanism for non-simulated devices */ - if (!is_simulated(bus, devfn)) - return pci_direct_conf1.read(seg, bus, devfn, reg, len, value); - - /* - * No device has config registers past 0x70, so we save table space - * by not storing entries for the nonexistent registers - */ - if (reg >= 0x70) - addr = &zero_loc; - else { - switch (devfn) { - case 0x8: - addr = hdr_addr(is_lx ? lxnb_hdr : gxnb_hdr, reg); - break; - case 0x9: - addr = hdr_addr(is_lx ? lxfb_hdr : gxfb_hdr, reg); - break; - case 0xa: - addr = is_lx ? hdr_addr(aes_hdr, reg) : &ff_loc; - break; - case 0x78: - addr = hdr_addr(isa_hdr, reg); - break; - case 0x7b: - addr = hdr_addr(ac97_hdr, reg); - break; - case 0x7c: - addr = hdr_addr(ohci_hdr, reg); - break; - case 0x7d: - addr = hdr_addr(ehci_hdr, reg); - break; - default: - addr = &ff_loc; - break; - } - } - switch (len) { - case 1: - *value = *(uint8_t *)addr; - break; - case 2: - *value = *(uint16_t *)addr; - break; - case 4: - *value = *addr; - break; - default: - BUG(); - } - - return 0; -} - -static int pci_olpc_write(unsigned int seg, unsigned int bus, - unsigned int devfn, int reg, int len, uint32_t value) -{ - /* Use the hardware mechanism for non-simulated devices */ - if (!is_simulated(bus, devfn)) - return pci_direct_conf1.write(seg, bus, devfn, reg, len, value); - - /* XXX we may want to extend this to simulate EHCI power management */ - - /* - * Mostly we just discard writes, but if the write is a size probe - * (i.e. writing ~0 to a BAR), we remember it and arrange to return - * the appropriate size mask on the next read. This is cheating - * to some extent, because it depends on the fact that the next - * access after such a write will always be a read to the same BAR. - */ - - if ((reg >= 0x10) && (reg < 0x2c)) { - /* write is to a BAR */ - if (value == ~0) - bar_probing = 1; - } else { - /* - * No warning on writes to ROM BAR, CMD, LATENCY_TIMER, - * CACHE_LINE_SIZE, or PM registers. - */ - if ((reg != PCI_ROM_ADDRESS) && (reg != PCI_COMMAND_MASTER) && - (reg != PCI_LATENCY_TIMER) && - (reg != PCI_CACHE_LINE_SIZE) && (reg != 0x44)) - printk(KERN_WARNING "OLPC PCI: Config write to devfn" - " %x reg %x value %x\n", devfn, reg, value); - } - - return 0; -} - -static struct pci_raw_ops pci_olpc_conf = { - .read = pci_olpc_read, - .write = pci_olpc_write, -}; - -void __init pci_olpc_init(void) -{ - if (!machine_is_olpc() || olpc_has_vsa()) - return; - - printk(KERN_INFO "PCI: Using configuration type OLPC\n"); - raw_pci_ops = &pci_olpc_conf; - is_lx = is_geode_lx(); -} diff --git a/trunk/arch/x86/pci/pci.h b/trunk/arch/x86/pci/pci.h index c58805a92db5..c4bddaeff619 100644 --- a/trunk/arch/x86/pci/pci.h +++ b/trunk/arch/x86/pci/pci.h @@ -26,7 +26,6 @@ #define PCI_ASSIGN_ALL_BUSSES 0x4000 #define PCI_CAN_SKIP_ISA_ALIGN 0x8000 #define PCI_USE__CRS 0x10000 -#define PCI_CHECK_ENABLE_AMD_MMCONF 0x20000 extern unsigned int pci_probe; extern unsigned long pirq_table_addr; @@ -98,12 +97,11 @@ extern struct pci_raw_ops pci_direct_conf1; extern int pci_direct_probe(void); extern void pci_direct_init(int type); extern void pci_pcbios_init(void); -extern void pci_olpc_init(void); +extern void pci_mmcfg_init(int type); /* pci-mmconfig.c */ extern int __init pci_mmcfg_arch_init(void); -extern void __init pci_mmcfg_arch_free(void); /* * AMD Fam10h CPUs are buggy, and cannot access MMIO config space diff --git a/trunk/arch/xtensa/kernel/asm-offsets.c b/trunk/arch/xtensa/kernel/asm-offsets.c index 070ff8af3a21..ef63adadf7f4 100644 --- a/trunk/arch/xtensa/kernel/asm-offsets.c +++ b/trunk/arch/xtensa/kernel/asm-offsets.c @@ -19,11 +19,12 @@ #include #include #include -#include #include #include +#define DEFINE(sym, val) asm volatile("\n->" #sym " %0 " #val : : "i" (val)) + int main(void) { /* struct pt_regs */ diff --git a/trunk/block/blk-barrier.c b/trunk/block/blk-barrier.c index 66e55288178c..55c5f1fc4f1f 100644 --- a/trunk/block/blk-barrier.c +++ b/trunk/block/blk-barrier.c @@ -53,7 +53,7 @@ EXPORT_SYMBOL(blk_queue_ordered); /* * Cache flushing for ordered writes handling */ -unsigned blk_ordered_cur_seq(struct request_queue *q) +inline unsigned blk_ordered_cur_seq(struct request_queue *q) { if (!q->ordseq) return 0; @@ -143,8 +143,10 @@ static void queue_flush(struct request_queue *q, unsigned which) end_io = post_flush_end_io; } - blk_rq_init(q, rq); rq->cmd_flags = REQ_HARDBARRIER; + rq_init(q, rq); + rq->elevator_private = NULL; + rq->elevator_private2 = NULL; rq->rq_disk = q->bar_rq.rq_disk; rq->end_io = end_io; q->prepare_flush_fn(q, rq); @@ -165,11 +167,14 @@ static inline struct request *start_ordered(struct request_queue *q, blkdev_dequeue_request(rq); q->orig_bar_rq = rq; rq = &q->bar_rq; - blk_rq_init(q, rq); + rq->cmd_flags = 0; + rq_init(q, rq); if (bio_data_dir(q->orig_bar_rq->bio) == WRITE) rq->cmd_flags |= REQ_RW; if (q->ordered & QUEUE_ORDERED_FUA) rq->cmd_flags |= REQ_FUA; + rq->elevator_private = NULL; + rq->elevator_private2 = NULL; init_request_from_bio(rq, q->orig_bar_rq->bio); rq->end_io = bar_end_io; diff --git a/trunk/block/blk-core.c b/trunk/block/blk-core.c index 5d09f8c56024..2a438a93f723 100644 --- a/trunk/block/blk-core.c +++ b/trunk/block/blk-core.c @@ -107,21 +107,41 @@ struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev) } EXPORT_SYMBOL(blk_get_backing_dev_info); -void blk_rq_init(struct request_queue *q, struct request *rq) +/* + * We can't just memset() the structure, since the allocation path + * already stored some information in the request. + */ +void rq_init(struct request_queue *q, struct request *rq) { - memset(rq, 0, sizeof(*rq)); - INIT_LIST_HEAD(&rq->queuelist); INIT_LIST_HEAD(&rq->donelist); rq->q = q; rq->sector = rq->hard_sector = (sector_t) -1; + rq->nr_sectors = rq->hard_nr_sectors = 0; + rq->current_nr_sectors = rq->hard_cur_sectors = 0; + rq->bio = rq->biotail = NULL; INIT_HLIST_NODE(&rq->hash); RB_CLEAR_NODE(&rq->rb_node); - rq->cmd = rq->__cmd; + rq->rq_disk = NULL; + rq->nr_phys_segments = 0; + rq->nr_hw_segments = 0; + rq->ioprio = 0; + rq->special = NULL; + rq->buffer = NULL; rq->tag = -1; + rq->errors = 0; rq->ref_count = 1; + rq->cmd_len = 0; + memset(rq->cmd, 0, sizeof(rq->cmd)); + rq->data_len = 0; + rq->extra_len = 0; + rq->sense_len = 0; + rq->data = NULL; + rq->sense = NULL; + rq->end_io = NULL; + rq->end_io_data = NULL; + rq->next_rq = NULL; } -EXPORT_SYMBOL(blk_rq_init); static void req_bio_endio(struct request *rq, struct bio *bio, unsigned int nbytes, int error) @@ -174,7 +194,7 @@ void blk_dump_rq_flags(struct request *rq, char *msg) if (blk_pc_request(rq)) { printk(KERN_INFO " cdb: "); - for (bit = 0; bit < BLK_MAX_CDB; bit++) + for (bit = 0; bit < sizeof(rq->cmd); bit++) printk("%02x ", rq->cmd[bit]); printk("\n"); } @@ -200,8 +220,7 @@ void blk_plug_device(struct request_queue *q) if (blk_queue_stopped(q)) return; - if (!test_bit(QUEUE_FLAG_PLUGGED, &q->queue_flags)) { - __set_bit(QUEUE_FLAG_PLUGGED, &q->queue_flags); + if (!test_and_set_bit(QUEUE_FLAG_PLUGGED, &q->queue_flags)) { mod_timer(&q->unplug_timer, jiffies + q->unplug_delay); blk_add_trace_generic(q, NULL, 0, BLK_TA_PLUG); } @@ -216,10 +235,9 @@ int blk_remove_plug(struct request_queue *q) { WARN_ON(!irqs_disabled()); - if (!test_bit(QUEUE_FLAG_PLUGGED, &q->queue_flags)) + if (!test_and_clear_bit(QUEUE_FLAG_PLUGGED, &q->queue_flags)) return 0; - queue_flag_clear(QUEUE_FLAG_PLUGGED, q); del_timer(&q->unplug_timer); return 1; } @@ -315,16 +333,15 @@ void blk_start_queue(struct request_queue *q) { WARN_ON(!irqs_disabled()); - queue_flag_clear(QUEUE_FLAG_STOPPED, q); + clear_bit(QUEUE_FLAG_STOPPED, &q->queue_flags); /* * one level of recursion is ok and is much faster than kicking * the unplug handling */ - if (!test_bit(QUEUE_FLAG_REENTER, &q->queue_flags)) { - queue_flag_set(QUEUE_FLAG_REENTER, q); + if (!test_and_set_bit(QUEUE_FLAG_REENTER, &q->queue_flags)) { q->request_fn(q); - queue_flag_clear(QUEUE_FLAG_REENTER, q); + clear_bit(QUEUE_FLAG_REENTER, &q->queue_flags); } else { blk_plug_device(q); kblockd_schedule_work(&q->unplug_work); @@ -349,7 +366,7 @@ EXPORT_SYMBOL(blk_start_queue); void blk_stop_queue(struct request_queue *q) { blk_remove_plug(q); - queue_flag_set(QUEUE_FLAG_STOPPED, q); + set_bit(QUEUE_FLAG_STOPPED, &q->queue_flags); } EXPORT_SYMBOL(blk_stop_queue); @@ -378,8 +395,11 @@ EXPORT_SYMBOL(blk_sync_queue); * blk_run_queue - run a single device queue * @q: The queue to run */ -void __blk_run_queue(struct request_queue *q) +void blk_run_queue(struct request_queue *q) { + unsigned long flags; + + spin_lock_irqsave(q->queue_lock, flags); blk_remove_plug(q); /* @@ -387,28 +407,15 @@ void __blk_run_queue(struct request_queue *q) * handling reinvoke the handler shortly if we already got there. */ if (!elv_queue_empty(q)) { - if (!test_bit(QUEUE_FLAG_REENTER, &q->queue_flags)) { - queue_flag_set(QUEUE_FLAG_REENTER, q); + if (!test_and_set_bit(QUEUE_FLAG_REENTER, &q->queue_flags)) { q->request_fn(q); - queue_flag_clear(QUEUE_FLAG_REENTER, q); + clear_bit(QUEUE_FLAG_REENTER, &q->queue_flags); } else { blk_plug_device(q); kblockd_schedule_work(&q->unplug_work); } } -} -EXPORT_SYMBOL(__blk_run_queue); - -/** - * blk_run_queue - run a single device queue - * @q: The queue to run - */ -void blk_run_queue(struct request_queue *q) -{ - unsigned long flags; - spin_lock_irqsave(q->queue_lock, flags); - __blk_run_queue(q); spin_unlock_irqrestore(q->queue_lock, flags); } EXPORT_SYMBOL(blk_run_queue); @@ -421,7 +428,7 @@ void blk_put_queue(struct request_queue *q) void blk_cleanup_queue(struct request_queue *q) { mutex_lock(&q->sysfs_lock); - queue_flag_set_unlocked(QUEUE_FLAG_DEAD, q); + set_bit(QUEUE_FLAG_DEAD, &q->queue_flags); mutex_unlock(&q->sysfs_lock); if (q->elevator) @@ -600,8 +607,6 @@ blk_alloc_request(struct request_queue *q, int rw, int priv, gfp_t gfp_mask) if (!rq) return NULL; - blk_rq_init(q, rq); - /* * first three bits are identical in rq->cmd_flags and bio->bi_rw, * see bio.h and blkdev.h @@ -784,6 +789,8 @@ static struct request *get_request(struct request_queue *q, int rw_flags, if (ioc_batching(q, ioc)) ioc->nr_batch_requests--; + rq_init(q, rq); + blk_add_trace_generic(q, bio, rw, BLK_TA_GETRQ); out: return rq; diff --git a/trunk/block/blk-map.c b/trunk/block/blk-map.c index 0b1af5a3537c..3c942bd6422a 100644 --- a/trunk/block/blk-map.c +++ b/trunk/block/blk-map.c @@ -255,18 +255,10 @@ EXPORT_SYMBOL(blk_rq_unmap_user); * @kbuf: the kernel buffer * @len: length of user data * @gfp_mask: memory allocation flags - * - * Description: - * Data will be mapped directly if possible. Otherwise a bounce - * buffer is used. */ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf, unsigned int len, gfp_t gfp_mask) { - unsigned long kaddr; - unsigned int alignment; - int reading = rq_data_dir(rq) == READ; - int do_copy = 0; struct bio *bio; if (len > (q->max_hw_sectors << 9)) @@ -274,24 +266,13 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf, if (!len || !kbuf) return -EINVAL; - kaddr = (unsigned long)kbuf; - alignment = queue_dma_alignment(q) | q->dma_pad_mask; - do_copy = ((kaddr & alignment) || (len & alignment)); - - if (do_copy) - bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading); - else - bio = bio_map_kern(q, kbuf, len, gfp_mask); - + bio = bio_map_kern(q, kbuf, len, gfp_mask); if (IS_ERR(bio)) return PTR_ERR(bio); if (rq_data_dir(rq) == WRITE) bio->bi_rw |= (1 << BIO_RW); - if (do_copy) - rq->cmd_flags |= REQ_COPY_USER; - blk_rq_bio_prep(q, rq, bio); blk_queue_bounce(q, &rq->bio); rq->buffer = rq->data = NULL; diff --git a/trunk/block/blk-merge.c b/trunk/block/blk-merge.c index 73b23562af20..b5c5c4a9e3f0 100644 --- a/trunk/block/blk-merge.c +++ b/trunk/block/blk-merge.c @@ -55,7 +55,7 @@ void blk_recalc_rq_segments(struct request *rq) if (!rq->bio) return; - cluster = test_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags); + cluster = q->queue_flags & (1 << QUEUE_FLAG_CLUSTER); hw_seg_size = seg_size = 0; phys_size = hw_size = nr_phys_segs = nr_hw_segs = 0; rq_for_each_segment(bv, rq, iter) { @@ -128,7 +128,7 @@ EXPORT_SYMBOL(blk_recount_segments); static int blk_phys_contig_segment(struct request_queue *q, struct bio *bio, struct bio *nxt) { - if (!test_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags)) + if (!(q->queue_flags & (1 << QUEUE_FLAG_CLUSTER))) return 0; if (!BIOVEC_PHYS_MERGEABLE(__BVEC_END(bio), __BVEC_START(nxt))) @@ -175,7 +175,7 @@ int blk_rq_map_sg(struct request_queue *q, struct request *rq, int nsegs, cluster; nsegs = 0; - cluster = test_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags); + cluster = q->queue_flags & (1 << QUEUE_FLAG_CLUSTER); /* * for each bio in rq diff --git a/trunk/block/blk-settings.c b/trunk/block/blk-settings.c index 6089384ab064..5713f7e5cbd2 100644 --- a/trunk/block/blk-settings.c +++ b/trunk/block/blk-settings.c @@ -14,6 +14,7 @@ unsigned long blk_max_low_pfn; EXPORT_SYMBOL(blk_max_low_pfn); unsigned long blk_max_pfn; +EXPORT_SYMBOL(blk_max_pfn); /** * blk_queue_prep_rq - set a prepare_request function for queue @@ -287,7 +288,7 @@ void blk_queue_stack_limits(struct request_queue *t, struct request_queue *b) t->max_segment_size = min(t->max_segment_size, b->max_segment_size); t->hardsect_size = max(t->hardsect_size, b->hardsect_size); if (!test_bit(QUEUE_FLAG_CLUSTER, &b->queue_flags)) - queue_flag_clear(QUEUE_FLAG_CLUSTER, t); + clear_bit(QUEUE_FLAG_CLUSTER, &t->queue_flags); } EXPORT_SYMBOL(blk_queue_stack_limits); diff --git a/trunk/block/blk-sysfs.c b/trunk/block/blk-sysfs.c index e85c4013e8a2..fc41d83be22b 100644 --- a/trunk/block/blk-sysfs.c +++ b/trunk/block/blk-sysfs.c @@ -135,25 +135,6 @@ static ssize_t queue_max_hw_sectors_show(struct request_queue *q, char *page) return queue_var_show(max_hw_sectors_kb, (page)); } -static ssize_t queue_nomerges_show(struct request_queue *q, char *page) -{ - return queue_var_show(blk_queue_nomerges(q), page); -} - -static ssize_t queue_nomerges_store(struct request_queue *q, const char *page, - size_t count) -{ - unsigned long nm; - ssize_t ret = queue_var_store(&nm, page, count); - - if (nm) - set_bit(QUEUE_FLAG_NOMERGES, &q->queue_flags); - else - clear_bit(QUEUE_FLAG_NOMERGES, &q->queue_flags); - - return ret; -} - static struct queue_sysfs_entry queue_requests_entry = { .attr = {.name = "nr_requests", .mode = S_IRUGO | S_IWUSR }, @@ -189,12 +170,6 @@ static struct queue_sysfs_entry queue_hw_sector_size_entry = { .show = queue_hw_sector_size_show, }; -static struct queue_sysfs_entry queue_nomerges_entry = { - .attr = {.name = "nomerges", .mode = S_IRUGO | S_IWUSR }, - .show = queue_nomerges_show, - .store = queue_nomerges_store, -}; - static struct attribute *default_attrs[] = { &queue_requests_entry.attr, &queue_ra_entry.attr, @@ -202,7 +177,6 @@ static struct attribute *default_attrs[] = { &queue_max_sectors_entry.attr, &queue_iosched_entry.attr, &queue_hw_sector_size_entry.attr, - &queue_nomerges_entry.attr, NULL, }; diff --git a/trunk/block/blk-tag.c b/trunk/block/blk-tag.c index e176ddbe599e..4780a46ce234 100644 --- a/trunk/block/blk-tag.c +++ b/trunk/block/blk-tag.c @@ -70,7 +70,7 @@ void __blk_queue_free_tags(struct request_queue *q) __blk_free_tags(bqt); q->queue_tags = NULL; - queue_flag_clear(QUEUE_FLAG_QUEUED, q); + q->queue_flags &= ~(1 << QUEUE_FLAG_QUEUED); } /** @@ -98,7 +98,7 @@ EXPORT_SYMBOL(blk_free_tags); **/ void blk_queue_free_tags(struct request_queue *q) { - queue_flag_clear(QUEUE_FLAG_QUEUED, q); + clear_bit(QUEUE_FLAG_QUEUED, &q->queue_flags); } EXPORT_SYMBOL(blk_queue_free_tags); @@ -188,7 +188,7 @@ int blk_queue_init_tags(struct request_queue *q, int depth, rc = blk_queue_resize_tags(q, depth); if (rc) return rc; - queue_flag_set(QUEUE_FLAG_QUEUED, q); + set_bit(QUEUE_FLAG_QUEUED, &q->queue_flags); return 0; } else atomic_inc(&tags->refcnt); @@ -197,7 +197,7 @@ int blk_queue_init_tags(struct request_queue *q, int depth, * assign it, all done */ q->queue_tags = tags; - queue_flag_set(QUEUE_FLAG_QUEUED, q); + q->queue_flags |= (1 << QUEUE_FLAG_QUEUED); INIT_LIST_HEAD(&q->tag_busy_list); return 0; fail: diff --git a/trunk/block/blk.h b/trunk/block/blk.h index 59776ab4742a..ec9120fb789a 100644 --- a/trunk/block/blk.h +++ b/trunk/block/blk.h @@ -10,6 +10,7 @@ extern struct kmem_cache *blk_requestq_cachep; extern struct kobj_type blk_queue_ktype; +void rq_init(struct request_queue *q, struct request *rq); void init_request_from_bio(struct request *req, struct bio *bio); void blk_rq_bio_prep(struct request_queue *q, struct request *rq, struct bio *bio); diff --git a/trunk/block/elevator.c b/trunk/block/elevator.c index ac5310ef8270..88318c383608 100644 --- a/trunk/block/elevator.c +++ b/trunk/block/elevator.c @@ -69,7 +69,7 @@ static int elv_iosched_allow_merge(struct request *rq, struct bio *bio) /* * can we safely merge with this request? */ -int elv_rq_merge_ok(struct request *rq, struct bio *bio) +inline int elv_rq_merge_ok(struct request *rq, struct bio *bio) { if (!rq_mergeable(rq)) return 0; @@ -488,9 +488,6 @@ int elv_merge(struct request_queue *q, struct request **req, struct bio *bio) } } - if (blk_queue_nomerges(q)) - return ELEVATOR_NO_MERGE; - /* * See if our hash lookup can find a potential backmerge. */ @@ -1073,7 +1070,7 @@ static int elevator_switch(struct request_queue *q, struct elevator_type *new_e) */ spin_lock_irq(q->queue_lock); - queue_flag_set(QUEUE_FLAG_ELVSWITCH, q); + set_bit(QUEUE_FLAG_ELVSWITCH, &q->queue_flags); elv_drain_elevator(q); @@ -1107,10 +1104,7 @@ static int elevator_switch(struct request_queue *q, struct elevator_type *new_e) * finally exit old elevator and turn off BYPASS. */ elevator_exit(old_elevator); - spin_lock_irq(q->queue_lock); - queue_flag_clear(QUEUE_FLAG_ELVSWITCH, q); - spin_unlock_irq(q->queue_lock); - + clear_bit(QUEUE_FLAG_ELVSWITCH, &q->queue_flags); return 1; fail_register: @@ -1121,11 +1115,7 @@ static int elevator_switch(struct request_queue *q, struct elevator_type *new_e) elevator_exit(e); q->elevator = old_elevator; elv_register_queue(q); - - spin_lock_irq(q->queue_lock); - queue_flag_clear(QUEUE_FLAG_ELVSWITCH, q); - spin_unlock_irq(q->queue_lock); - + clear_bit(QUEUE_FLAG_ELVSWITCH, &q->queue_flags); return 0; } diff --git a/trunk/block/scsi_ioctl.c b/trunk/block/scsi_ioctl.c index ffa3720e6ca0..a2c3a936ebf9 100644 --- a/trunk/block/scsi_ioctl.c +++ b/trunk/block/scsi_ioctl.c @@ -217,6 +217,8 @@ EXPORT_SYMBOL_GPL(blk_verify_command); static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq, struct sg_io_hdr *hdr, int has_write_perm) { + memset(rq->cmd, 0, BLK_MAX_CDB); /* ATAPI hates garbage after CDB */ + if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len)) return -EFAULT; if (blk_verify_command(rq->cmd, has_write_perm)) @@ -529,6 +531,7 @@ static int __blk_send_generic(struct request_queue *q, struct gendisk *bd_disk, rq->data_len = 0; rq->extra_len = 0; rq->timeout = BLK_DEFAULT_SG_TIMEOUT; + memset(rq->cmd, 0, sizeof(rq->cmd)); rq->cmd[0] = cmd; rq->cmd[4] = data; rq->cmd_len = 6; diff --git a/trunk/drivers/acpi/ac.c b/trunk/drivers/acpi/ac.c index 5b73f6a2cd86..43a95e5640de 100644 --- a/trunk/drivers/acpi/ac.c +++ b/trunk/drivers/acpi/ac.c @@ -92,7 +92,6 @@ struct acpi_ac { #ifdef CONFIG_ACPI_PROCFS_POWER static const struct file_operations acpi_ac_fops = { - .owner = THIS_MODULE, .open = acpi_ac_open_fs, .read = seq_read, .llseek = seq_lseek, @@ -196,11 +195,16 @@ static int acpi_ac_add_fs(struct acpi_device *device) } /* 'state' [R] */ - entry = proc_create_data(ACPI_AC_FILE_STATE, - S_IRUGO, acpi_device_dir(device), - &acpi_ac_fops, acpi_driver_data(device)); + entry = create_proc_entry(ACPI_AC_FILE_STATE, + S_IRUGO, acpi_device_dir(device)); if (!entry) return -ENODEV; + else { + entry->proc_fops = &acpi_ac_fops; + entry->data = acpi_driver_data(device); + entry->owner = THIS_MODULE; + } + return 0; } diff --git a/trunk/drivers/acpi/battery.c b/trunk/drivers/acpi/battery.c index b1c723f9f58d..d5729d5dc190 100644 --- a/trunk/drivers/acpi/battery.c +++ b/trunk/drivers/acpi/battery.c @@ -741,13 +741,15 @@ static int acpi_battery_add_fs(struct acpi_device *device) } for (i = 0; i < ACPI_BATTERY_NUMFILES; ++i) { - entry = proc_create_data(acpi_battery_file[i].name, - acpi_battery_file[i].mode, - acpi_device_dir(device), - &acpi_battery_file[i].ops, - acpi_driver_data(device)); + entry = create_proc_entry(acpi_battery_file[i].name, + acpi_battery_file[i].mode, acpi_device_dir(device)); if (!entry) return -ENODEV; + else { + entry->proc_fops = &acpi_battery_file[i].ops; + entry->data = acpi_driver_data(device); + entry->owner = THIS_MODULE; + } } return 0; } diff --git a/trunk/drivers/acpi/bus.c b/trunk/drivers/acpi/bus.c index a6dbcf4d9ef5..2d1955c11833 100644 --- a/trunk/drivers/acpi/bus.c +++ b/trunk/drivers/acpi/bus.c @@ -35,7 +35,6 @@ #ifdef CONFIG_X86 #include #endif -#include #include #include @@ -785,7 +784,6 @@ static int __init acpi_init(void) result = acpi_bus_init(); if (!result) { - pci_mmcfg_late_init(); if (!(pm_flags & PM_APM)) pm_flags |= PM_ACPI; else { diff --git a/trunk/drivers/acpi/button.c b/trunk/drivers/acpi/button.c index 1dfec413588c..6c5da83cdb68 100644 --- a/trunk/drivers/acpi/button.c +++ b/trunk/drivers/acpi/button.c @@ -102,7 +102,6 @@ struct acpi_button { }; static const struct file_operations acpi_button_info_fops = { - .owner = THIS_MODULE, .open = acpi_button_info_open_fs, .read = seq_read, .llseek = seq_lseek, @@ -110,7 +109,6 @@ static const struct file_operations acpi_button_info_fops = { }; static const struct file_operations acpi_button_state_fops = { - .owner = THIS_MODULE, .open = acpi_button_state_open_fs, .read = seq_read, .llseek = seq_lseek, @@ -209,21 +207,27 @@ static int acpi_button_add_fs(struct acpi_device *device) acpi_device_dir(device)->owner = THIS_MODULE; /* 'info' [R] */ - entry = proc_create_data(ACPI_BUTTON_FILE_INFO, - S_IRUGO, acpi_device_dir(device), - &acpi_button_info_fops, - acpi_driver_data(device)); + entry = create_proc_entry(ACPI_BUTTON_FILE_INFO, + S_IRUGO, acpi_device_dir(device)); if (!entry) return -ENODEV; + else { + entry->proc_fops = &acpi_button_info_fops; + entry->data = acpi_driver_data(device); + entry->owner = THIS_MODULE; + } /* show lid state [R] */ if (button->type == ACPI_BUTTON_TYPE_LID) { - entry = proc_create_data(ACPI_BUTTON_FILE_STATE, - S_IRUGO, acpi_device_dir(device), - &acpi_button_state_fops, - acpi_driver_data(device)); + entry = create_proc_entry(ACPI_BUTTON_FILE_STATE, + S_IRUGO, acpi_device_dir(device)); if (!entry) return -ENODEV; + else { + entry->proc_fops = &acpi_button_state_fops; + entry->data = acpi_driver_data(device); + entry->owner = THIS_MODULE; + } } return 0; diff --git a/trunk/drivers/acpi/ec.c b/trunk/drivers/acpi/ec.c index e3f04b272f3f..7222a18a0319 100644 --- a/trunk/drivers/acpi/ec.c +++ b/trunk/drivers/acpi/ec.c @@ -669,11 +669,16 @@ static int acpi_ec_add_fs(struct acpi_device *device) return -ENODEV; } - entry = proc_create_data(ACPI_EC_FILE_INFO, S_IRUGO, - acpi_device_dir(device), - &acpi_ec_info_ops, acpi_driver_data(device)); + entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO, + acpi_device_dir(device)); if (!entry) return -ENODEV; + else { + entry->proc_fops = &acpi_ec_info_ops; + entry->data = acpi_driver_data(device); + entry->owner = THIS_MODULE; + } + return 0; } diff --git a/trunk/drivers/acpi/event.c b/trunk/drivers/acpi/event.c index 0c24bd4d6562..abec1ca94cf4 100644 --- a/trunk/drivers/acpi/event.c +++ b/trunk/drivers/acpi/event.c @@ -102,7 +102,6 @@ static unsigned int acpi_system_poll_event(struct file *file, poll_table * wait) } static const struct file_operations acpi_system_event_ops = { - .owner = THIS_MODULE, .open = acpi_system_open_event, .read = acpi_system_read_event, .release = acpi_system_close_event, @@ -295,9 +294,10 @@ static int __init acpi_event_init(void) #ifdef CONFIG_ACPI_PROC_EVENT /* 'event' [R] */ - entry = proc_create("event", S_IRUSR, acpi_root_dir, - &acpi_system_event_ops); - if (!entry) + entry = create_proc_entry("event", S_IRUSR, acpi_root_dir); + if (entry) + entry->proc_fops = &acpi_system_event_ops; + else return -ENODEV; #endif diff --git a/trunk/drivers/acpi/fan.c b/trunk/drivers/acpi/fan.c index 194077ab9b85..c8e3cba423ef 100644 --- a/trunk/drivers/acpi/fan.c +++ b/trunk/drivers/acpi/fan.c @@ -192,13 +192,17 @@ static int acpi_fan_add_fs(struct acpi_device *device) } /* 'status' [R/W] */ - entry = proc_create_data(ACPI_FAN_FILE_STATE, - S_IFREG | S_IRUGO | S_IWUSR, - acpi_device_dir(device), - &acpi_fan_state_ops, - device); + entry = create_proc_entry(ACPI_FAN_FILE_STATE, + S_IFREG | S_IRUGO | S_IWUSR, + acpi_device_dir(device)); if (!entry) return -ENODEV; + else { + entry->proc_fops = &acpi_fan_state_ops; + entry->data = device; + entry->owner = THIS_MODULE; + } + return 0; } diff --git a/trunk/drivers/acpi/power.c b/trunk/drivers/acpi/power.c index 21fc8bf0d31f..76bf6d90c700 100644 --- a/trunk/drivers/acpi/power.c +++ b/trunk/drivers/acpi/power.c @@ -93,7 +93,6 @@ struct acpi_power_resource { static struct list_head acpi_power_resource_list; static const struct file_operations acpi_power_fops = { - .owner = THIS_MODULE, .open = acpi_power_open_fs, .read = seq_read, .llseek = seq_lseek, @@ -544,11 +543,15 @@ static int acpi_power_add_fs(struct acpi_device *device) } /* 'status' [R] */ - entry = proc_create_data(ACPI_POWER_FILE_STATUS, - S_IRUGO, acpi_device_dir(device), - &acpi_power_fops, acpi_driver_data(device)); + entry = create_proc_entry(ACPI_POWER_FILE_STATUS, + S_IRUGO, acpi_device_dir(device)); if (!entry) return -EIO; + else { + entry->proc_fops = &acpi_power_fops; + entry->data = acpi_driver_data(device); + } + return 0; } diff --git a/trunk/drivers/acpi/processor_core.c b/trunk/drivers/acpi/processor_core.c index 5241e3ff5080..a825b431b64f 100644 --- a/trunk/drivers/acpi/processor_core.c +++ b/trunk/drivers/acpi/processor_core.c @@ -112,7 +112,6 @@ static struct acpi_driver acpi_processor_driver = { #define UNINSTALL_NOTIFY_HANDLER 2 static const struct file_operations acpi_processor_info_fops = { - .owner = THIS_MODULE, .open = acpi_processor_info_open_fs, .read = seq_read, .llseek = seq_lseek, @@ -327,30 +326,40 @@ static int acpi_processor_add_fs(struct acpi_device *device) acpi_device_dir(device)->owner = THIS_MODULE; /* 'info' [R] */ - entry = proc_create_data(ACPI_PROCESSOR_FILE_INFO, - S_IRUGO, acpi_device_dir(device), - &acpi_processor_info_fops, - acpi_driver_data(device)); + entry = create_proc_entry(ACPI_PROCESSOR_FILE_INFO, + S_IRUGO, acpi_device_dir(device)); if (!entry) return -EIO; + else { + entry->proc_fops = &acpi_processor_info_fops; + entry->data = acpi_driver_data(device); + entry->owner = THIS_MODULE; + } /* 'throttling' [R/W] */ - entry = proc_create_data(ACPI_PROCESSOR_FILE_THROTTLING, - S_IFREG | S_IRUGO | S_IWUSR, - acpi_device_dir(device), - &acpi_processor_throttling_fops, - acpi_driver_data(device)); + entry = create_proc_entry(ACPI_PROCESSOR_FILE_THROTTLING, + S_IFREG | S_IRUGO | S_IWUSR, + acpi_device_dir(device)); if (!entry) return -EIO; + else { + entry->proc_fops = &acpi_processor_throttling_fops; + entry->data = acpi_driver_data(device); + entry->owner = THIS_MODULE; + } /* 'limit' [R/W] */ - entry = proc_create_data(ACPI_PROCESSOR_FILE_LIMIT, - S_IFREG | S_IRUGO | S_IWUSR, - acpi_device_dir(device), - &acpi_processor_limit_fops, - acpi_driver_data(device)); + entry = create_proc_entry(ACPI_PROCESSOR_FILE_LIMIT, + S_IFREG | S_IRUGO | S_IWUSR, + acpi_device_dir(device)); if (!entry) return -EIO; + else { + entry->proc_fops = &acpi_processor_limit_fops; + entry->data = acpi_driver_data(device); + entry->owner = THIS_MODULE; + } + return 0; } @@ -603,15 +612,6 @@ static int acpi_processor_get_info(struct acpi_processor *pr, unsigned has_uid) request_region(pr->throttling.address, 6, "ACPI CPU throttle"); } - /* - * If ACPI describes a slot number for this CPU, we can use it - * ensure we get the right value in the "physical id" field - * of /proc/cpuinfo - */ - status = acpi_evaluate_object(pr->handle, "_SUN", NULL, &buffer); - if (ACPI_SUCCESS(status)) - arch_fix_phys_package_id(pr->id, object.integer.value); - return 0; } diff --git a/trunk/drivers/acpi/processor_idle.c b/trunk/drivers/acpi/processor_idle.c index 789d4947ed31..0d90ff5fd117 100644 --- a/trunk/drivers/acpi/processor_idle.c +++ b/trunk/drivers/acpi/processor_idle.c @@ -1282,7 +1282,6 @@ static int acpi_processor_power_open_fs(struct inode *inode, struct file *file) } static const struct file_operations acpi_processor_power_fops = { - .owner = THIS_MODULE, .open = acpi_processor_power_open_fs, .read = seq_read, .llseek = seq_lseek, @@ -1823,12 +1822,16 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr, } /* 'power' [R] */ - entry = proc_create_data(ACPI_PROCESSOR_FILE_POWER, - S_IRUGO, acpi_device_dir(device), - &acpi_processor_power_fops, - acpi_driver_data(device)); + entry = create_proc_entry(ACPI_PROCESSOR_FILE_POWER, + S_IRUGO, acpi_device_dir(device)); if (!entry) return -EIO; + else { + entry->proc_fops = &acpi_processor_power_fops; + entry->data = acpi_driver_data(device); + entry->owner = THIS_MODULE; + } + return 0; } diff --git a/trunk/drivers/acpi/processor_perflib.c b/trunk/drivers/acpi/processor_perflib.c index d80b2d1441af..b477a4be8a69 100644 --- a/trunk/drivers/acpi/processor_perflib.c +++ b/trunk/drivers/acpi/processor_perflib.c @@ -411,7 +411,6 @@ EXPORT_SYMBOL(acpi_processor_notify_smm); static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file); static struct file_operations acpi_processor_perf_fops = { - .owner = THIS_MODULE, .open = acpi_processor_perf_open_fs, .read = seq_read, .llseek = seq_lseek, @@ -457,6 +456,7 @@ static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file) static void acpi_cpufreq_add_file(struct acpi_processor *pr) { + struct proc_dir_entry *entry = NULL; struct acpi_device *device = NULL; @@ -464,9 +464,14 @@ static void acpi_cpufreq_add_file(struct acpi_processor *pr) return; /* add file 'performance' [R/W] */ - proc_create_data(ACPI_PROCESSOR_FILE_PERFORMANCE, S_IFREG | S_IRUGO, - acpi_device_dir(device), - &acpi_processor_perf_fops, acpi_driver_data(device)); + entry = create_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE, + S_IFREG | S_IRUGO, + acpi_device_dir(device)); + if (entry){ + entry->proc_fops = &acpi_processor_perf_fops; + entry->data = acpi_driver_data(device); + entry->owner = THIS_MODULE; + } return; } diff --git a/trunk/drivers/acpi/processor_thermal.c b/trunk/drivers/acpi/processor_thermal.c index ef34b18f95ca..649ae99b9216 100644 --- a/trunk/drivers/acpi/processor_thermal.c +++ b/trunk/drivers/acpi/processor_thermal.c @@ -509,7 +509,6 @@ static ssize_t acpi_processor_write_limit(struct file * file, } struct file_operations acpi_processor_limit_fops = { - .owner = THIS_MODULE, .open = acpi_processor_limit_open_fs, .read = seq_read, .write = acpi_processor_write_limit, diff --git a/trunk/drivers/acpi/processor_throttling.c b/trunk/drivers/acpi/processor_throttling.c index bb06738860c4..0bba3a914e86 100644 --- a/trunk/drivers/acpi/processor_throttling.c +++ b/trunk/drivers/acpi/processor_throttling.c @@ -1252,7 +1252,6 @@ static ssize_t acpi_processor_write_throttling(struct file *file, } struct file_operations acpi_processor_throttling_fops = { - .owner = THIS_MODULE, .open = acpi_processor_throttling_open_fs, .read = seq_read, .write = acpi_processor_write_throttling, diff --git a/trunk/drivers/acpi/sbs.c b/trunk/drivers/acpi/sbs.c index 10a36512647c..585ae3c9c8ea 100644 --- a/trunk/drivers/acpi/sbs.c +++ b/trunk/drivers/acpi/sbs.c @@ -483,6 +483,8 @@ acpi_sbs_add_fs(struct proc_dir_entry **dir, struct file_operations *state_fops, struct file_operations *alarm_fops, void *data) { + struct proc_dir_entry *entry = NULL; + if (!*dir) { *dir = proc_mkdir(dir_name, parent_dir); if (!*dir) { @@ -492,19 +494,34 @@ acpi_sbs_add_fs(struct proc_dir_entry **dir, } /* 'info' [R] */ - if (info_fops) - proc_create_data(ACPI_SBS_FILE_INFO, S_IRUGO, *dir, - info_fops, data); + if (info_fops) { + entry = create_proc_entry(ACPI_SBS_FILE_INFO, S_IRUGO, *dir); + if (entry) { + entry->proc_fops = info_fops; + entry->data = data; + entry->owner = THIS_MODULE; + } + } /* 'state' [R] */ - if (state_fops) - proc_create_data(ACPI_SBS_FILE_STATE, S_IRUGO, *dir, - state_fops, data); + if (state_fops) { + entry = create_proc_entry(ACPI_SBS_FILE_STATE, S_IRUGO, *dir); + if (entry) { + entry->proc_fops = state_fops; + entry->data = data; + entry->owner = THIS_MODULE; + } + } /* 'alarm' [R/W] */ - if (alarm_fops) - proc_create_data(ACPI_SBS_FILE_ALARM, S_IRUGO, *dir, - alarm_fops, data); + if (alarm_fops) { + entry = create_proc_entry(ACPI_SBS_FILE_ALARM, S_IRUGO, *dir); + if (entry) { + entry->proc_fops = alarm_fops; + entry->data = data; + entry->owner = THIS_MODULE; + } + } return 0; } diff --git a/trunk/drivers/acpi/sleep/proc.c b/trunk/drivers/acpi/sleep/proc.c index 8a5fe8710513..f8df5217d477 100644 --- a/trunk/drivers/acpi/sleep/proc.c +++ b/trunk/drivers/acpi/sleep/proc.c @@ -440,7 +440,6 @@ acpi_system_wakeup_device_open_fs(struct inode *inode, struct file *file) } static const struct file_operations acpi_system_wakeup_device_fops = { - .owner = THIS_MODULE, .open = acpi_system_wakeup_device_open_fs, .read = seq_read, .write = acpi_system_write_wakeup_device, @@ -450,7 +449,6 @@ static const struct file_operations acpi_system_wakeup_device_fops = { #ifdef CONFIG_ACPI_PROCFS static const struct file_operations acpi_system_sleep_fops = { - .owner = THIS_MODULE, .open = acpi_system_sleep_open_fs, .read = seq_read, .write = acpi_system_write_sleep, @@ -461,7 +459,6 @@ static const struct file_operations acpi_system_sleep_fops = { #ifdef HAVE_ACPI_LEGACY_ALARM static const struct file_operations acpi_system_alarm_fops = { - .owner = THIS_MODULE, .open = acpi_system_alarm_open_fs, .read = seq_read, .write = acpi_system_write_alarm, @@ -480,26 +477,37 @@ static u32 rtc_handler(void *context) static int __init acpi_sleep_proc_init(void) { + struct proc_dir_entry *entry = NULL; + if (acpi_disabled) return 0; #ifdef CONFIG_ACPI_PROCFS /* 'sleep' [R/W] */ - proc_create("sleep", S_IFREG | S_IRUGO | S_IWUSR, - acpi_root_dir, &acpi_system_sleep_fops); + entry = + create_proc_entry("sleep", S_IFREG | S_IRUGO | S_IWUSR, + acpi_root_dir); + if (entry) + entry->proc_fops = &acpi_system_sleep_fops; #endif /* CONFIG_ACPI_PROCFS */ #ifdef HAVE_ACPI_LEGACY_ALARM /* 'alarm' [R/W] */ - proc_create("alarm", S_IFREG | S_IRUGO | S_IWUSR, - acpi_root_dir, &acpi_system_alarm_fops); + entry = + create_proc_entry("alarm", S_IFREG | S_IRUGO | S_IWUSR, + acpi_root_dir); + if (entry) + entry->proc_fops = &acpi_system_alarm_fops; acpi_install_fixed_event_handler(ACPI_EVENT_RTC, rtc_handler, NULL); #endif /* HAVE_ACPI_LEGACY_ALARM */ /* 'wakeup device' [R/W] */ - proc_create("wakeup", S_IFREG | S_IRUGO | S_IWUSR, - acpi_root_dir, &acpi_system_wakeup_device_fops); + entry = + create_proc_entry("wakeup", S_IFREG | S_IRUGO | S_IWUSR, + acpi_root_dir); + if (entry) + entry->proc_fops = &acpi_system_wakeup_device_fops; return 0; } diff --git a/trunk/drivers/acpi/system.c b/trunk/drivers/acpi/system.c index 769f24855eb6..4749f379a915 100644 --- a/trunk/drivers/acpi/system.c +++ b/trunk/drivers/acpi/system.c @@ -396,7 +396,6 @@ static int acpi_system_info_open_fs(struct inode *inode, struct file *file) } static const struct file_operations acpi_system_info_ops = { - .owner = THIS_MODULE, .open = acpi_system_info_open_fs, .read = seq_read, .llseek = seq_lseek, @@ -407,7 +406,6 @@ static ssize_t acpi_system_read_dsdt(struct file *, char __user *, size_t, loff_t *); static const struct file_operations acpi_system_dsdt_ops = { - .owner = THIS_MODULE, .read = acpi_system_read_dsdt, }; @@ -432,7 +430,6 @@ static ssize_t acpi_system_read_fadt(struct file *, char __user *, size_t, loff_t *); static const struct file_operations acpi_system_fadt_ops = { - .owner = THIS_MODULE, .read = acpi_system_read_fadt, }; @@ -457,23 +454,31 @@ static int acpi_system_procfs_init(void) { struct proc_dir_entry *entry; int error = 0; + char *name; /* 'info' [R] */ - entry = proc_create(ACPI_SYSTEM_FILE_INFO, S_IRUGO, acpi_root_dir, - &acpi_system_info_ops); + name = ACPI_SYSTEM_FILE_INFO; + entry = create_proc_entry(name, S_IRUGO, acpi_root_dir); if (!entry) goto Error; + else { + entry->proc_fops = &acpi_system_info_ops; + } /* 'dsdt' [R] */ - entry = proc_create(ACPI_SYSTEM_FILE_DSDT, S_IRUSR, acpi_root_dir, - &acpi_system_dsdt_ops); - if (!entry) + name = ACPI_SYSTEM_FILE_DSDT; + entry = create_proc_entry(name, S_IRUSR, acpi_root_dir); + if (entry) + entry->proc_fops = &acpi_system_dsdt_ops; + else goto Error; /* 'fadt' [R] */ - entry = proc_create(ACPI_SYSTEM_FILE_FADT, S_IRUSR, acpi_root_dir, - &acpi_system_fadt_ops); - if (!entry) + name = ACPI_SYSTEM_FILE_FADT; + entry = create_proc_entry(name, S_IRUSR, acpi_root_dir); + if (entry) + entry->proc_fops = &acpi_system_fadt_ops; + else goto Error; Done: diff --git a/trunk/drivers/acpi/thermal.c b/trunk/drivers/acpi/thermal.c index 0815ac3ae3d6..766bd25d3376 100644 --- a/trunk/drivers/acpi/thermal.c +++ b/trunk/drivers/acpi/thermal.c @@ -198,7 +198,6 @@ struct acpi_thermal { }; static const struct file_operations acpi_thermal_state_fops = { - .owner = THIS_MODULE, .open = acpi_thermal_state_open_fs, .read = seq_read, .llseek = seq_lseek, @@ -206,7 +205,6 @@ static const struct file_operations acpi_thermal_state_fops = { }; static const struct file_operations acpi_thermal_temp_fops = { - .owner = THIS_MODULE, .open = acpi_thermal_temp_open_fs, .read = seq_read, .llseek = seq_lseek, @@ -214,7 +212,6 @@ static const struct file_operations acpi_thermal_temp_fops = { }; static const struct file_operations acpi_thermal_trip_fops = { - .owner = THIS_MODULE, .open = acpi_thermal_trip_open_fs, .read = seq_read, .llseek = seq_lseek, @@ -222,7 +219,6 @@ static const struct file_operations acpi_thermal_trip_fops = { }; static const struct file_operations acpi_thermal_cooling_fops = { - .owner = THIS_MODULE, .open = acpi_thermal_cooling_open_fs, .read = seq_read, .write = acpi_thermal_write_cooling_mode, @@ -231,7 +227,6 @@ static const struct file_operations acpi_thermal_cooling_fops = { }; static const struct file_operations acpi_thermal_polling_fops = { - .owner = THIS_MODULE, .open = acpi_thermal_polling_open_fs, .read = seq_read, .write = acpi_thermal_write_polling, @@ -1424,47 +1419,63 @@ static int acpi_thermal_add_fs(struct acpi_device *device) } /* 'state' [R] */ - entry = proc_create_data(ACPI_THERMAL_FILE_STATE, - S_IRUGO, acpi_device_dir(device), - &acpi_thermal_state_fops, - acpi_driver_data(device)); + entry = create_proc_entry(ACPI_THERMAL_FILE_STATE, + S_IRUGO, acpi_device_dir(device)); if (!entry) return -ENODEV; + else { + entry->proc_fops = &acpi_thermal_state_fops; + entry->data = acpi_driver_data(device); + entry->owner = THIS_MODULE; + } /* 'temperature' [R] */ - entry = proc_create_data(ACPI_THERMAL_FILE_TEMPERATURE, - S_IRUGO, acpi_device_dir(device), - &acpi_thermal_temp_fops, - acpi_driver_data(device)); + entry = create_proc_entry(ACPI_THERMAL_FILE_TEMPERATURE, + S_IRUGO, acpi_device_dir(device)); if (!entry) return -ENODEV; + else { + entry->proc_fops = &acpi_thermal_temp_fops; + entry->data = acpi_driver_data(device); + entry->owner = THIS_MODULE; + } /* 'trip_points' [R] */ - entry = proc_create_data(ACPI_THERMAL_FILE_TRIP_POINTS, - S_IRUGO, - acpi_device_dir(device), - &acpi_thermal_trip_fops, - acpi_driver_data(device)); + entry = create_proc_entry(ACPI_THERMAL_FILE_TRIP_POINTS, + S_IRUGO, + acpi_device_dir(device)); if (!entry) return -ENODEV; + else { + entry->proc_fops = &acpi_thermal_trip_fops; + entry->data = acpi_driver_data(device); + entry->owner = THIS_MODULE; + } /* 'cooling_mode' [R/W] */ - entry = proc_create_data(ACPI_THERMAL_FILE_COOLING_MODE, - S_IFREG | S_IRUGO | S_IWUSR, - acpi_device_dir(device), - &acpi_thermal_cooling_fops, - acpi_driver_data(device)); + entry = create_proc_entry(ACPI_THERMAL_FILE_COOLING_MODE, + S_IFREG | S_IRUGO | S_IWUSR, + acpi_device_dir(device)); if (!entry) return -ENODEV; + else { + entry->proc_fops = &acpi_thermal_cooling_fops; + entry->data = acpi_driver_data(device); + entry->owner = THIS_MODULE; + } /* 'polling_frequency' [R/W] */ - entry = proc_create_data(ACPI_THERMAL_FILE_POLLING_FREQ, - S_IFREG | S_IRUGO | S_IWUSR, - acpi_device_dir(device), - &acpi_thermal_polling_fops, - acpi_driver_data(device)); + entry = create_proc_entry(ACPI_THERMAL_FILE_POLLING_FREQ, + S_IFREG | S_IRUGO | S_IWUSR, + acpi_device_dir(device)); if (!entry) return -ENODEV; + else { + entry->proc_fops = &acpi_thermal_polling_fops; + entry->data = acpi_driver_data(device); + entry->owner = THIS_MODULE; + } + return 0; } diff --git a/trunk/drivers/acpi/video.c b/trunk/drivers/acpi/video.c index 43b228314a86..980a74188781 100644 --- a/trunk/drivers/acpi/video.c +++ b/trunk/drivers/acpi/video.c @@ -192,7 +192,6 @@ struct acpi_video_device { /* bus */ static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file); static struct file_operations acpi_video_bus_info_fops = { - .owner = THIS_MODULE, .open = acpi_video_bus_info_open_fs, .read = seq_read, .llseek = seq_lseek, @@ -201,7 +200,6 @@ static struct file_operations acpi_video_bus_info_fops = { static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file); static struct file_operations acpi_video_bus_ROM_fops = { - .owner = THIS_MODULE, .open = acpi_video_bus_ROM_open_fs, .read = seq_read, .llseek = seq_lseek, @@ -211,7 +209,6 @@ static struct file_operations acpi_video_bus_ROM_fops = { static int acpi_video_bus_POST_info_open_fs(struct inode *inode, struct file *file); static struct file_operations acpi_video_bus_POST_info_fops = { - .owner = THIS_MODULE, .open = acpi_video_bus_POST_info_open_fs, .read = seq_read, .llseek = seq_lseek, @@ -220,7 +217,6 @@ static struct file_operations acpi_video_bus_POST_info_fops = { static int acpi_video_bus_POST_open_fs(struct inode *inode, struct file *file); static struct file_operations acpi_video_bus_POST_fops = { - .owner = THIS_MODULE, .open = acpi_video_bus_POST_open_fs, .read = seq_read, .llseek = seq_lseek, @@ -229,7 +225,6 @@ static struct file_operations acpi_video_bus_POST_fops = { static int acpi_video_bus_DOS_open_fs(struct inode *inode, struct file *file); static struct file_operations acpi_video_bus_DOS_fops = { - .owner = THIS_MODULE, .open = acpi_video_bus_DOS_open_fs, .read = seq_read, .llseek = seq_lseek, @@ -240,7 +235,6 @@ static struct file_operations acpi_video_bus_DOS_fops = { static int acpi_video_device_info_open_fs(struct inode *inode, struct file *file); static struct file_operations acpi_video_device_info_fops = { - .owner = THIS_MODULE, .open = acpi_video_device_info_open_fs, .read = seq_read, .llseek = seq_lseek, @@ -250,7 +244,6 @@ static struct file_operations acpi_video_device_info_fops = { static int acpi_video_device_state_open_fs(struct inode *inode, struct file *file); static struct file_operations acpi_video_device_state_fops = { - .owner = THIS_MODULE, .open = acpi_video_device_state_open_fs, .read = seq_read, .llseek = seq_lseek, @@ -260,7 +253,6 @@ static struct file_operations acpi_video_device_state_fops = { static int acpi_video_device_brightness_open_fs(struct inode *inode, struct file *file); static struct file_operations acpi_video_device_brightness_fops = { - .owner = THIS_MODULE, .open = acpi_video_device_brightness_open_fs, .read = seq_read, .llseek = seq_lseek, @@ -270,7 +262,6 @@ static struct file_operations acpi_video_device_brightness_fops = { static int acpi_video_device_EDID_open_fs(struct inode *inode, struct file *file); static struct file_operations acpi_video_device_EDID_fops = { - .owner = THIS_MODULE, .open = acpi_video_device_EDID_open_fs, .read = seq_read, .llseek = seq_lseek, @@ -1079,36 +1070,51 @@ static int acpi_video_device_add_fs(struct acpi_device *device) } /* 'info' [R] */ - entry = proc_create_data("info", S_IRUGO, acpi_device_dir(device), - &acpi_video_device_info_fops, acpi_driver_data(device)); + entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device)); if (!entry) return -ENODEV; + else { + entry->proc_fops = &acpi_video_device_info_fops; + entry->data = acpi_driver_data(device); + entry->owner = THIS_MODULE; + } /* 'state' [R/W] */ - acpi_video_device_state_fops.write = acpi_video_device_write_state; - entry = proc_create_data("state", S_IFREG | S_IRUGO | S_IWUSR, - acpi_device_dir(device), - &acpi_video_device_state_fops, - acpi_driver_data(device)); + entry = + create_proc_entry("state", S_IFREG | S_IRUGO | S_IWUSR, + acpi_device_dir(device)); if (!entry) return -ENODEV; + else { + acpi_video_device_state_fops.write = acpi_video_device_write_state; + entry->proc_fops = &acpi_video_device_state_fops; + entry->data = acpi_driver_data(device); + entry->owner = THIS_MODULE; + } /* 'brightness' [R/W] */ - acpi_video_device_brightness_fops.write = - acpi_video_device_write_brightness; - entry = proc_create_data("brightness", S_IFREG | S_IRUGO | S_IWUSR, - acpi_device_dir(device), - &acpi_video_device_brightness_fops, - acpi_driver_data(device)); + entry = + create_proc_entry("brightness", S_IFREG | S_IRUGO | S_IWUSR, + acpi_device_dir(device)); if (!entry) return -ENODEV; + else { + acpi_video_device_brightness_fops.write = acpi_video_device_write_brightness; + entry->proc_fops = &acpi_video_device_brightness_fops; + entry->data = acpi_driver_data(device); + entry->owner = THIS_MODULE; + } /* 'EDID' [R] */ - entry = proc_create_data("EDID", S_IRUGO, acpi_device_dir(device), - &acpi_video_device_EDID_fops, - acpi_driver_data(device)); + entry = create_proc_entry("EDID", S_IRUGO, acpi_device_dir(device)); if (!entry) return -ENODEV; + else { + entry->proc_fops = &acpi_video_device_EDID_fops; + entry->data = acpi_driver_data(device); + entry->owner = THIS_MODULE; + } + return 0; } @@ -1347,43 +1353,61 @@ static int acpi_video_bus_add_fs(struct acpi_device *device) } /* 'info' [R] */ - entry = proc_create_data("info", S_IRUGO, acpi_device_dir(device), - &acpi_video_bus_info_fops, - acpi_driver_data(device)); + entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device)); if (!entry) return -ENODEV; + else { + entry->proc_fops = &acpi_video_bus_info_fops; + entry->data = acpi_driver_data(device); + entry->owner = THIS_MODULE; + } /* 'ROM' [R] */ - entry = proc_create_data("ROM", S_IRUGO, acpi_device_dir(device), - &acpi_video_bus_ROM_fops, - acpi_driver_data(device)); + entry = create_proc_entry("ROM", S_IRUGO, acpi_device_dir(device)); if (!entry) return -ENODEV; + else { + entry->proc_fops = &acpi_video_bus_ROM_fops; + entry->data = acpi_driver_data(device); + entry->owner = THIS_MODULE; + } /* 'POST_info' [R] */ - entry = proc_create_data("POST_info", S_IRUGO, acpi_device_dir(device), - &acpi_video_bus_POST_info_fops, - acpi_driver_data(device)); + entry = + create_proc_entry("POST_info", S_IRUGO, acpi_device_dir(device)); if (!entry) return -ENODEV; + else { + entry->proc_fops = &acpi_video_bus_POST_info_fops; + entry->data = acpi_driver_data(device); + entry->owner = THIS_MODULE; + } /* 'POST' [R/W] */ - acpi_video_bus_POST_fops.write = acpi_video_bus_write_POST; - entry = proc_create_data("POST", S_IFREG | S_IRUGO | S_IRUSR, - acpi_device_dir(device), - &acpi_video_bus_POST_fops, - acpi_driver_data(device)); + entry = + create_proc_entry("POST", S_IFREG | S_IRUGO | S_IRUSR, + acpi_device_dir(device)); if (!entry) return -ENODEV; + else { + acpi_video_bus_POST_fops.write = acpi_video_bus_write_POST; + entry->proc_fops = &acpi_video_bus_POST_fops; + entry->data = acpi_driver_data(device); + entry->owner = THIS_MODULE; + } /* 'DOS' [R/W] */ - acpi_video_bus_DOS_fops.write = acpi_video_bus_write_DOS; - entry = proc_create_data("DOS", S_IFREG | S_IRUGO | S_IRUSR, - acpi_device_dir(device), - &acpi_video_bus_DOS_fops, - acpi_driver_data(device)); + entry = + create_proc_entry("DOS", S_IFREG | S_IRUGO | S_IRUSR, + acpi_device_dir(device)); if (!entry) return -ENODEV; + else { + acpi_video_bus_DOS_fops.write = acpi_video_bus_write_DOS; + entry->proc_fops = &acpi_video_bus_DOS_fops; + entry->data = acpi_driver_data(device); + entry->owner = THIS_MODULE; + } return 0; } diff --git a/trunk/drivers/ata/Kconfig b/trunk/drivers/ata/Kconfig index 1c11df9a5f32..292aa9a0f02f 100644 --- a/trunk/drivers/ata/Kconfig +++ b/trunk/drivers/ata/Kconfig @@ -566,11 +566,11 @@ config PATA_RADISYS If unsure, say N. -config PATA_RB532 - tristate "RouterBoard 532 PATA CompactFlash support" - depends on MIKROTIK_RB532 +config PATA_RB500 + tristate "RouterBoard 500 PATA CompactFlash support" + depends on MIKROTIK_RB500 help - This option enables support for the RouterBoard 532 + This option enables support for the RouterBoard 500 PATA CompactFlash controller. If unsure, say N. diff --git a/trunk/drivers/ata/Makefile b/trunk/drivers/ata/Makefile index b693d829383a..1fbc2aa648b7 100644 --- a/trunk/drivers/ata/Makefile +++ b/trunk/drivers/ata/Makefile @@ -55,7 +55,7 @@ obj-$(CONFIG_PATA_PDC2027X) += pata_pdc2027x.o obj-$(CONFIG_PATA_PDC_OLD) += pata_pdc202xx_old.o obj-$(CONFIG_PATA_QDI) += pata_qdi.o obj-$(CONFIG_PATA_RADISYS) += pata_radisys.o -obj-$(CONFIG_PATA_RB532) += pata_rb532_cf.o +obj-$(CONFIG_PATA_RB500) += pata_rb500_cf.o obj-$(CONFIG_PATA_RZ1000) += pata_rz1000.o obj-$(CONFIG_PATA_SC1200) += pata_sc1200.o obj-$(CONFIG_PATA_SERVERWORKS) += pata_serverworks.o diff --git a/trunk/drivers/ata/ahci.c b/trunk/drivers/ata/ahci.c index 8cace9aa9c03..7c4f886f1f16 100644 --- a/trunk/drivers/ata/ahci.c +++ b/trunk/drivers/ata/ahci.c @@ -358,7 +358,7 @@ static const struct ata_port_info ahci_port_info[] = { /* board_ahci_sb600 */ { AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL | - AHCI_HFLAG_32BIT_ONLY | AHCI_HFLAG_NO_MSI | + AHCI_HFLAG_32BIT_ONLY | AHCI_HFLAG_SECT255 | AHCI_HFLAG_NO_PMP), .flags = AHCI_FLAG_COMMON, .pio_mask = 0x1f, /* pio0-4 */ diff --git a/trunk/drivers/ata/libata-core.c b/trunk/drivers/ata/libata-core.c index 3bc488538204..51b7d2fad36a 100644 --- a/trunk/drivers/ata/libata-core.c +++ b/trunk/drivers/ata/libata-core.c @@ -3933,9 +3933,6 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { /* Devices which get the IVB wrong */ { "QUANTUM FIREBALLlct10 05", "A03.0900", ATA_HORKAGE_IVB, }, - /* Maybe we should just blacklist TSSTcorp... */ - { "TSSTcorp CDDVDW SH-S202H", "SB00", ATA_HORKAGE_IVB, }, - { "TSSTcorp CDDVDW SH-S202H", "SB01", ATA_HORKAGE_IVB, }, { "TSSTcorp CDDVDW SH-S202J", "SB00", ATA_HORKAGE_IVB, }, { "TSSTcorp CDDVDW SH-S202J", "SB01", ATA_HORKAGE_IVB, }, { "TSSTcorp CDDVDW SH-S202N", "SB00", ATA_HORKAGE_IVB, }, diff --git a/trunk/drivers/ata/libata-scsi.c b/trunk/drivers/ata/libata-scsi.c index 3ce43920e459..a34f32442edf 100644 --- a/trunk/drivers/ata/libata-scsi.c +++ b/trunk/drivers/ata/libata-scsi.c @@ -49,11 +49,7 @@ #include "libata.h" -#define SECTOR_SIZE 512 -#define ATA_SCSI_RBUF_SIZE 4096 - -static DEFINE_SPINLOCK(ata_scsi_rbuf_lock); -static u8 ata_scsi_rbuf[ATA_SCSI_RBUF_SIZE]; +#define SECTOR_SIZE 512 typedef unsigned int (*ata_xlat_func_t)(struct ata_queued_cmd *qc); @@ -183,13 +179,6 @@ DEVICE_ATTR(link_power_management_policy, S_IRUGO | S_IWUSR, ata_scsi_lpm_show, ata_scsi_lpm_put); EXPORT_SYMBOL_GPL(dev_attr_link_power_management_policy); -static void ata_scsi_set_sense(struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq) -{ - cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; - - scsi_build_sense_buffer(0, cmd->sense_buffer, sk, asc, ascq); -} - static void ata_scsi_invalid_field(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) { @@ -1643,48 +1632,53 @@ static int ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd, /** * ata_scsi_rbuf_get - Map response buffer. - * @flags: unsigned long variable to store irq enable status - * @copy_in: copy in from user buffer + * @cmd: SCSI command containing buffer to be mapped. + * @buf_out: Pointer to mapped area. * - * Prepare buffer for simulated SCSI commands. + * Maps buffer contained within SCSI command @cmd. * * LOCKING: - * spin_lock_irqsave(ata_scsi_rbuf_lock) on success + * spin_lock_irqsave(host lock) * * RETURNS: - * Pointer to response buffer. + * Length of response buffer. */ -static void *ata_scsi_rbuf_get(struct scsi_cmnd *cmd, bool copy_in, - unsigned long *flags) + +static unsigned int ata_scsi_rbuf_get(struct scsi_cmnd *cmd, u8 **buf_out) { - spin_lock_irqsave(&ata_scsi_rbuf_lock, *flags); + u8 *buf; + unsigned int buflen; + + struct scatterlist *sg = scsi_sglist(cmd); - memset(ata_scsi_rbuf, 0, ATA_SCSI_RBUF_SIZE); - if (copy_in) - sg_copy_to_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), - ata_scsi_rbuf, ATA_SCSI_RBUF_SIZE); - return ata_scsi_rbuf; + if (sg) { + buf = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset; + buflen = sg->length; + } else { + buf = NULL; + buflen = 0; + } + + *buf_out = buf; + return buflen; } /** * ata_scsi_rbuf_put - Unmap response buffer. * @cmd: SCSI command containing buffer to be unmapped. - * @copy_out: copy out result - * @flags: @flags passed to ata_scsi_rbuf_get() + * @buf: buffer to unmap * - * Returns rbuf buffer. The result is copied to @cmd's buffer if - * @copy_back is true. + * Unmaps response buffer contained within @cmd. * * LOCKING: - * Unlocks ata_scsi_rbuf_lock. + * spin_lock_irqsave(host lock) */ -static inline void ata_scsi_rbuf_put(struct scsi_cmnd *cmd, bool copy_out, - unsigned long *flags) + +static inline void ata_scsi_rbuf_put(struct scsi_cmnd *cmd, u8 *buf) { - if (copy_out) - sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), - ata_scsi_rbuf, ATA_SCSI_RBUF_SIZE); - spin_unlock_irqrestore(&ata_scsi_rbuf_lock, *flags); + struct scatterlist *sg = scsi_sglist(cmd); + if (sg) + kunmap_atomic(buf - sg->offset, KM_IRQ0); } /** @@ -1702,27 +1696,51 @@ static inline void ata_scsi_rbuf_put(struct scsi_cmnd *cmd, bool copy_out, * LOCKING: * spin_lock_irqsave(host lock) */ -static void ata_scsi_rbuf_fill(struct ata_scsi_args *args, - unsigned int (*actor)(struct ata_scsi_args *args, u8 *rbuf)) + +void ata_scsi_rbuf_fill(struct ata_scsi_args *args, + unsigned int (*actor) (struct ata_scsi_args *args, + u8 *rbuf, unsigned int buflen)) { u8 *rbuf; - unsigned int rc; + unsigned int buflen, rc; struct scsi_cmnd *cmd = args->cmd; unsigned long flags; - rbuf = ata_scsi_rbuf_get(cmd, false, &flags); - rc = actor(args, rbuf); - ata_scsi_rbuf_put(cmd, rc == 0, &flags); + local_irq_save(flags); + + buflen = ata_scsi_rbuf_get(cmd, &rbuf); + memset(rbuf, 0, buflen); + rc = actor(args, rbuf, buflen); + ata_scsi_rbuf_put(cmd, rbuf); + + local_irq_restore(flags); if (rc == 0) cmd->result = SAM_STAT_GOOD; args->done(cmd); } +/** + * ATA_SCSI_RBUF_SET - helper to set values in SCSI response buffer + * @idx: byte index into SCSI response buffer + * @val: value to set + * + * To be used by SCSI command simulator functions. This macros + * expects two local variables, u8 *rbuf and unsigned int buflen, + * are in scope. + * + * LOCKING: + * None. + */ +#define ATA_SCSI_RBUF_SET(idx, val) do { \ + if ((idx) < buflen) rbuf[(idx)] = (u8)(val); \ + } while (0) + /** * ata_scsiop_inq_std - Simulate INQUIRY command * @args: device IDENTIFY data / SCSI command of interest. * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. + * @buflen: Response buffer length. * * Returns standard device identification data associated * with non-VPD INQUIRY command output. @@ -1730,17 +1748,10 @@ static void ata_scsi_rbuf_fill(struct ata_scsi_args *args, * LOCKING: * spin_lock_irqsave(host lock) */ -static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf) -{ - const u8 versions[] = { - 0x60, /* SAM-3 (no version claimed) */ - - 0x03, - 0x20, /* SBC-2 (no version claimed) */ - 0x02, - 0x60 /* SPC-3 (no version claimed) */ - }; +unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf, + unsigned int buflen) +{ u8 hdr[] = { TYPE_DISK, 0, @@ -1749,21 +1760,35 @@ static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf) 95 - 4 }; - VPRINTK("ENTER\n"); - /* set scsi removeable (RMB) bit per ata bit */ if (ata_id_removeable(args->id)) hdr[1] |= (1 << 7); + VPRINTK("ENTER\n"); + memcpy(rbuf, hdr, sizeof(hdr)); - memcpy(&rbuf[8], "ATA ", 8); - ata_id_string(args->id, &rbuf[16], ATA_ID_PROD, 16); - ata_id_string(args->id, &rbuf[32], ATA_ID_FW_REV, 4); - if (rbuf[32] == 0 || rbuf[32] == ' ') - memcpy(&rbuf[32], "n/a ", 4); + if (buflen > 35) { + memcpy(&rbuf[8], "ATA ", 8); + ata_id_string(args->id, &rbuf[16], ATA_ID_PROD, 16); + ata_id_string(args->id, &rbuf[32], ATA_ID_FW_REV, 4); + if (rbuf[32] == 0 || rbuf[32] == ' ') + memcpy(&rbuf[32], "n/a ", 4); + } + + if (buflen > 63) { + const u8 versions[] = { + 0x60, /* SAM-3 (no version claimed) */ + + 0x03, + 0x20, /* SBC-2 (no version claimed) */ - memcpy(rbuf + 59, versions, sizeof(versions)); + 0x02, + 0x60 /* SPC-3 (no version claimed) */ + }; + + memcpy(rbuf + 59, versions, sizeof(versions)); + } return 0; } @@ -1772,22 +1797,27 @@ static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf) * ata_scsiop_inq_00 - Simulate INQUIRY VPD page 0, list of pages * @args: device IDENTIFY data / SCSI command of interest. * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. + * @buflen: Response buffer length. * * Returns list of inquiry VPD pages available. * * LOCKING: * spin_lock_irqsave(host lock) */ -static unsigned int ata_scsiop_inq_00(struct ata_scsi_args *args, u8 *rbuf) + +unsigned int ata_scsiop_inq_00(struct ata_scsi_args *args, u8 *rbuf, + unsigned int buflen) { const u8 pages[] = { 0x00, /* page 0x00, this page */ 0x80, /* page 0x80, unit serial no page */ 0x83 /* page 0x83, device ident page */ }; - rbuf[3] = sizeof(pages); /* number of supported VPD pages */ - memcpy(rbuf + 4, pages, sizeof(pages)); + + if (buflen > 6) + memcpy(rbuf + 4, pages, sizeof(pages)); + return 0; } @@ -1795,13 +1825,16 @@ static unsigned int ata_scsiop_inq_00(struct ata_scsi_args *args, u8 *rbuf) * ata_scsiop_inq_80 - Simulate INQUIRY VPD page 80, device serial number * @args: device IDENTIFY data / SCSI command of interest. * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. + * @buflen: Response buffer length. * * Returns ATA device serial number. * * LOCKING: * spin_lock_irqsave(host lock) */ -static unsigned int ata_scsiop_inq_80(struct ata_scsi_args *args, u8 *rbuf) + +unsigned int ata_scsiop_inq_80(struct ata_scsi_args *args, u8 *rbuf, + unsigned int buflen) { const u8 hdr[] = { 0, @@ -1809,10 +1842,12 @@ static unsigned int ata_scsiop_inq_80(struct ata_scsi_args *args, u8 *rbuf) 0, ATA_ID_SERNO_LEN, /* page len */ }; - memcpy(rbuf, hdr, sizeof(hdr)); - ata_id_string(args->id, (unsigned char *) &rbuf[4], - ATA_ID_SERNO, ATA_ID_SERNO_LEN); + + if (buflen > (ATA_ID_SERNO_LEN + 4 - 1)) + ata_id_string(args->id, (unsigned char *) &rbuf[4], + ATA_ID_SERNO, ATA_ID_SERNO_LEN); + return 0; } @@ -1820,6 +1855,7 @@ static unsigned int ata_scsiop_inq_80(struct ata_scsi_args *args, u8 *rbuf) * ata_scsiop_inq_83 - Simulate INQUIRY VPD page 83, device identity * @args: device IDENTIFY data / SCSI command of interest. * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. + * @buflen: Response buffer length. * * Yields two logical unit device identification designators: * - vendor specific ASCII containing the ATA serial number @@ -1829,37 +1865,41 @@ static unsigned int ata_scsiop_inq_80(struct ata_scsi_args *args, u8 *rbuf) * LOCKING: * spin_lock_irqsave(host lock) */ -static unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf) + +unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf, + unsigned int buflen) { - const int sat_model_serial_desc_len = 68; int num; + const int sat_model_serial_desc_len = 68; rbuf[1] = 0x83; /* this page code */ num = 4; - /* piv=0, assoc=lu, code_set=ACSII, designator=vendor */ - rbuf[num + 0] = 2; - rbuf[num + 3] = ATA_ID_SERNO_LEN; - num += 4; - ata_id_string(args->id, (unsigned char *) rbuf + num, - ATA_ID_SERNO, ATA_ID_SERNO_LEN); - num += ATA_ID_SERNO_LEN; - - /* SAT defined lu model and serial numbers descriptor */ - /* piv=0, assoc=lu, code_set=ACSII, designator=t10 vendor id */ - rbuf[num + 0] = 2; - rbuf[num + 1] = 1; - rbuf[num + 3] = sat_model_serial_desc_len; - num += 4; - memcpy(rbuf + num, "ATA ", 8); - num += 8; - ata_id_string(args->id, (unsigned char *) rbuf + num, ATA_ID_PROD, - ATA_ID_PROD_LEN); - num += ATA_ID_PROD_LEN; - ata_id_string(args->id, (unsigned char *) rbuf + num, ATA_ID_SERNO, - ATA_ID_SERNO_LEN); - num += ATA_ID_SERNO_LEN; - + if (buflen > (ATA_ID_SERNO_LEN + num + 3)) { + /* piv=0, assoc=lu, code_set=ACSII, designator=vendor */ + rbuf[num + 0] = 2; + rbuf[num + 3] = ATA_ID_SERNO_LEN; + num += 4; + ata_id_string(args->id, (unsigned char *) rbuf + num, + ATA_ID_SERNO, ATA_ID_SERNO_LEN); + num += ATA_ID_SERNO_LEN; + } + if (buflen > (sat_model_serial_desc_len + num + 3)) { + /* SAT defined lu model and serial numbers descriptor */ + /* piv=0, assoc=lu, code_set=ACSII, designator=t10 vendor id */ + rbuf[num + 0] = 2; + rbuf[num + 1] = 1; + rbuf[num + 3] = sat_model_serial_desc_len; + num += 4; + memcpy(rbuf + num, "ATA ", 8); + num += 8; + ata_id_string(args->id, (unsigned char *) rbuf + num, + ATA_ID_PROD, ATA_ID_PROD_LEN); + num += ATA_ID_PROD_LEN; + ata_id_string(args->id, (unsigned char *) rbuf + num, + ATA_ID_SERNO, ATA_ID_SERNO_LEN); + num += ATA_ID_SERNO_LEN; + } rbuf[3] = num - 4; /* page len (assume less than 256 bytes) */ return 0; } @@ -1868,26 +1908,35 @@ static unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf) * ata_scsiop_inq_89 - Simulate INQUIRY VPD page 89, ATA info * @args: device IDENTIFY data / SCSI command of interest. * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. + * @buflen: Response buffer length. * * Yields SAT-specified ATA VPD page. * * LOCKING: * spin_lock_irqsave(host lock) */ -static unsigned int ata_scsiop_inq_89(struct ata_scsi_args *args, u8 *rbuf) + +static unsigned int ata_scsiop_inq_89(struct ata_scsi_args *args, u8 *rbuf, + unsigned int buflen) { + u8 pbuf[60]; struct ata_taskfile tf; + unsigned int i; + if (!buflen) + return 0; + + memset(&pbuf, 0, sizeof(pbuf)); memset(&tf, 0, sizeof(tf)); - rbuf[1] = 0x89; /* our page code */ - rbuf[2] = (0x238 >> 8); /* page size fixed at 238h */ - rbuf[3] = (0x238 & 0xff); + pbuf[1] = 0x89; /* our page code */ + pbuf[2] = (0x238 >> 8); /* page size fixed at 238h */ + pbuf[3] = (0x238 & 0xff); - memcpy(&rbuf[8], "linux ", 8); - memcpy(&rbuf[16], "libata ", 16); - memcpy(&rbuf[32], DRV_VERSION, 4); - ata_id_string(args->id, &rbuf[32], ATA_ID_FW_REV, 4); + memcpy(&pbuf[8], "linux ", 8); + memcpy(&pbuf[16], "libata ", 16); + memcpy(&pbuf[32], DRV_VERSION, 4); + ata_id_string(args->id, &pbuf[32], ATA_ID_FW_REV, 4); /* we don't store the ATA device signature, so we fake it */ @@ -1895,12 +1944,19 @@ static unsigned int ata_scsiop_inq_89(struct ata_scsi_args *args, u8 *rbuf) tf.lbal = 0x1; tf.nsect = 0x1; - ata_tf_to_fis(&tf, 0, 1, &rbuf[36]); /* TODO: PMP? */ - rbuf[36] = 0x34; /* force D2H Reg FIS (34h) */ + ata_tf_to_fis(&tf, 0, 1, &pbuf[36]); /* TODO: PMP? */ + pbuf[36] = 0x34; /* force D2H Reg FIS (34h) */ - rbuf[56] = ATA_CMD_ID_ATA; + pbuf[56] = ATA_CMD_ID_ATA; - memcpy(&rbuf[60], &args->id[0], 512); + i = min(buflen, 60U); + memcpy(rbuf, &pbuf[0], i); + buflen -= i; + + if (!buflen) + return 0; + + memcpy(&rbuf[60], &args->id[0], min(buflen, 512U)); return 0; } @@ -1908,6 +1964,7 @@ static unsigned int ata_scsiop_inq_89(struct ata_scsi_args *args, u8 *rbuf) * ata_scsiop_noop - Command handler that simply returns success. * @args: device IDENTIFY data / SCSI command of interest. * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. + * @buflen: Response buffer length. * * No operation. Simply returns success to caller, to indicate * that the caller should successfully complete this SCSI command. @@ -1915,16 +1972,47 @@ static unsigned int ata_scsiop_inq_89(struct ata_scsi_args *args, u8 *rbuf) * LOCKING: * spin_lock_irqsave(host lock) */ -static unsigned int ata_scsiop_noop(struct ata_scsi_args *args, u8 *rbuf) + +unsigned int ata_scsiop_noop(struct ata_scsi_args *args, u8 *rbuf, + unsigned int buflen) { VPRINTK("ENTER\n"); return 0; } +/** + * ata_msense_push - Push data onto MODE SENSE data output buffer + * @ptr_io: (input/output) Location to store more output data + * @last: End of output data buffer + * @buf: Pointer to BLOB being added to output buffer + * @buflen: Length of BLOB + * + * Store MODE SENSE data on an output buffer. + * + * LOCKING: + * None. + */ + +static void ata_msense_push(u8 **ptr_io, const u8 *last, + const u8 *buf, unsigned int buflen) +{ + u8 *ptr = *ptr_io; + + if ((ptr + buflen - 1) > last) + return; + + memcpy(ptr, buf, buflen); + + ptr += buflen; + + *ptr_io = ptr; +} + /** * ata_msense_caching - Simulate MODE SENSE caching info page * @id: device IDENTIFY data - * @buf: output buffer + * @ptr_io: (input/output) Location to store more output data + * @last: End of output data buffer * * Generate a caching info page, which conditionally indicates * write caching to the SCSI layer, depending on device @@ -1933,43 +2021,58 @@ static unsigned int ata_scsiop_noop(struct ata_scsi_args *args, u8 *rbuf) * LOCKING: * None. */ -static unsigned int ata_msense_caching(u16 *id, u8 *buf) + +static unsigned int ata_msense_caching(u16 *id, u8 **ptr_io, + const u8 *last) { - memcpy(buf, def_cache_mpage, sizeof(def_cache_mpage)); + u8 page[CACHE_MPAGE_LEN]; + + memcpy(page, def_cache_mpage, sizeof(page)); if (ata_id_wcache_enabled(id)) - buf[2] |= (1 << 2); /* write cache enable */ + page[2] |= (1 << 2); /* write cache enable */ if (!ata_id_rahead_enabled(id)) - buf[12] |= (1 << 5); /* disable read ahead */ - return sizeof(def_cache_mpage); + page[12] |= (1 << 5); /* disable read ahead */ + + ata_msense_push(ptr_io, last, page, sizeof(page)); + return sizeof(page); } /** * ata_msense_ctl_mode - Simulate MODE SENSE control mode page - * @buf: output buffer + * @dev: Device associated with this MODE SENSE command + * @ptr_io: (input/output) Location to store more output data + * @last: End of output data buffer * * Generate a generic MODE SENSE control mode page. * * LOCKING: * None. */ -static unsigned int ata_msense_ctl_mode(u8 *buf) + +static unsigned int ata_msense_ctl_mode(u8 **ptr_io, const u8 *last) { - memcpy(buf, def_control_mpage, sizeof(def_control_mpage)); + ata_msense_push(ptr_io, last, def_control_mpage, + sizeof(def_control_mpage)); return sizeof(def_control_mpage); } /** * ata_msense_rw_recovery - Simulate MODE SENSE r/w error recovery page - * @bufp: output buffer + * @dev: Device associated with this MODE SENSE command + * @ptr_io: (input/output) Location to store more output data + * @last: End of output data buffer * * Generate a generic MODE SENSE r/w error recovery page. * * LOCKING: * None. */ -static unsigned int ata_msense_rw_recovery(u8 *buf) + +static unsigned int ata_msense_rw_recovery(u8 **ptr_io, const u8 *last) { - memcpy(buf, def_rw_recovery_mpage, sizeof(def_rw_recovery_mpage)); + + ata_msense_push(ptr_io, last, def_rw_recovery_mpage, + sizeof(def_rw_recovery_mpage)); return sizeof(def_rw_recovery_mpage); } @@ -2001,6 +2104,7 @@ static int ata_dev_supports_fua(u16 *id) * ata_scsiop_mode_sense - Simulate MODE SENSE 6, 10 commands * @args: device IDENTIFY data / SCSI command of interest. * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. + * @buflen: Response buffer length. * * Simulate MODE SENSE commands. Assume this is invoked for direct * access devices (e.g. disks) only. There should be no block @@ -2009,17 +2113,19 @@ static int ata_dev_supports_fua(u16 *id) * LOCKING: * spin_lock_irqsave(host lock) */ -static unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf) + +unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf, + unsigned int buflen) { struct ata_device *dev = args->dev; - u8 *scsicmd = args->cmd->cmnd, *p = rbuf; + u8 *scsicmd = args->cmd->cmnd, *p, *last; const u8 sat_blk_desc[] = { 0, 0, 0, 0, /* number of blocks: sat unspecified */ 0, 0, 0x2, 0x0 /* block length: 512 bytes */ }; u8 pg, spg; - unsigned int ebd, page_control, six_byte; + unsigned int ebd, page_control, six_byte, output_len, alloc_len, minlen; u8 dpofua; VPRINTK("ENTER\n"); @@ -2042,10 +2148,17 @@ static unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf) goto invalid_fld; } - if (six_byte) - p += 4 + (ebd ? 8 : 0); - else - p += 8 + (ebd ? 8 : 0); + if (six_byte) { + output_len = 4 + (ebd ? 8 : 0); + alloc_len = scsicmd[4]; + } else { + output_len = 8 + (ebd ? 8 : 0); + alloc_len = (scsicmd[7] << 8) + scsicmd[8]; + } + minlen = (alloc_len < buflen) ? alloc_len : buflen; + + p = rbuf + output_len; + last = rbuf + minlen - 1; pg = scsicmd[2] & 0x3f; spg = scsicmd[3]; @@ -2058,48 +2171,61 @@ static unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf) switch(pg) { case RW_RECOVERY_MPAGE: - p += ata_msense_rw_recovery(p); + output_len += ata_msense_rw_recovery(&p, last); break; case CACHE_MPAGE: - p += ata_msense_caching(args->id, p); + output_len += ata_msense_caching(args->id, &p, last); break; - case CONTROL_MPAGE: - p += ata_msense_ctl_mode(p); + case CONTROL_MPAGE: { + output_len += ata_msense_ctl_mode(&p, last); break; + } case ALL_MPAGES: - p += ata_msense_rw_recovery(p); - p += ata_msense_caching(args->id, p); - p += ata_msense_ctl_mode(p); + output_len += ata_msense_rw_recovery(&p, last); + output_len += ata_msense_caching(args->id, &p, last); + output_len += ata_msense_ctl_mode(&p, last); break; default: /* invalid page code */ goto invalid_fld; } + if (minlen < 1) + return 0; + dpofua = 0; if (ata_dev_supports_fua(args->id) && (dev->flags & ATA_DFLAG_LBA48) && (!(dev->flags & ATA_DFLAG_PIO) || dev->multi_count)) dpofua = 1 << 4; if (six_byte) { - rbuf[0] = p - rbuf - 1; - rbuf[2] |= dpofua; + output_len--; + rbuf[0] = output_len; + if (minlen > 2) + rbuf[2] |= dpofua; if (ebd) { - rbuf[3] = sizeof(sat_blk_desc); - memcpy(rbuf + 4, sat_blk_desc, sizeof(sat_blk_desc)); + if (minlen > 3) + rbuf[3] = sizeof(sat_blk_desc); + if (minlen > 11) + memcpy(rbuf + 4, sat_blk_desc, + sizeof(sat_blk_desc)); } } else { - unsigned int output_len = p - rbuf - 2; - + output_len -= 2; rbuf[0] = output_len >> 8; - rbuf[1] = output_len; - rbuf[3] |= dpofua; + if (minlen > 1) + rbuf[1] = output_len; + if (minlen > 3) + rbuf[3] |= dpofua; if (ebd) { - rbuf[7] = sizeof(sat_blk_desc); - memcpy(rbuf + 8, sat_blk_desc, sizeof(sat_blk_desc)); + if (minlen > 7) + rbuf[7] = sizeof(sat_blk_desc); + if (minlen > 15) + memcpy(rbuf + 8, sat_blk_desc, + sizeof(sat_blk_desc)); } } return 0; @@ -2119,13 +2245,15 @@ static unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf) * ata_scsiop_read_cap - Simulate READ CAPACITY[ 16] commands * @args: device IDENTIFY data / SCSI command of interest. * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. + * @buflen: Response buffer length. * * Simulate READ CAPACITY commands. * * LOCKING: * None. */ -static unsigned int ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf) +unsigned int ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf, + unsigned int buflen) { u64 last_lba = args->dev->n_sectors - 1; /* LBA of the last block */ @@ -2136,28 +2264,28 @@ static unsigned int ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf) last_lba = 0xffffffff; /* sector count, 32-bit */ - rbuf[0] = last_lba >> (8 * 3); - rbuf[1] = last_lba >> (8 * 2); - rbuf[2] = last_lba >> (8 * 1); - rbuf[3] = last_lba; + ATA_SCSI_RBUF_SET(0, last_lba >> (8 * 3)); + ATA_SCSI_RBUF_SET(1, last_lba >> (8 * 2)); + ATA_SCSI_RBUF_SET(2, last_lba >> (8 * 1)); + ATA_SCSI_RBUF_SET(3, last_lba); /* sector size */ - rbuf[6] = ATA_SECT_SIZE >> 8; - rbuf[7] = ATA_SECT_SIZE & 0xff; + ATA_SCSI_RBUF_SET(6, ATA_SECT_SIZE >> 8); + ATA_SCSI_RBUF_SET(7, ATA_SECT_SIZE & 0xff); } else { /* sector count, 64-bit */ - rbuf[0] = last_lba >> (8 * 7); - rbuf[1] = last_lba >> (8 * 6); - rbuf[2] = last_lba >> (8 * 5); - rbuf[3] = last_lba >> (8 * 4); - rbuf[4] = last_lba >> (8 * 3); - rbuf[5] = last_lba >> (8 * 2); - rbuf[6] = last_lba >> (8 * 1); - rbuf[7] = last_lba; + ATA_SCSI_RBUF_SET(0, last_lba >> (8 * 7)); + ATA_SCSI_RBUF_SET(1, last_lba >> (8 * 6)); + ATA_SCSI_RBUF_SET(2, last_lba >> (8 * 5)); + ATA_SCSI_RBUF_SET(3, last_lba >> (8 * 4)); + ATA_SCSI_RBUF_SET(4, last_lba >> (8 * 3)); + ATA_SCSI_RBUF_SET(5, last_lba >> (8 * 2)); + ATA_SCSI_RBUF_SET(6, last_lba >> (8 * 1)); + ATA_SCSI_RBUF_SET(7, last_lba); /* sector size */ - rbuf[10] = ATA_SECT_SIZE >> 8; - rbuf[11] = ATA_SECT_SIZE & 0xff; + ATA_SCSI_RBUF_SET(10, ATA_SECT_SIZE >> 8); + ATA_SCSI_RBUF_SET(11, ATA_SECT_SIZE & 0xff); } return 0; @@ -2167,13 +2295,16 @@ static unsigned int ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf) * ata_scsiop_report_luns - Simulate REPORT LUNS command * @args: device IDENTIFY data / SCSI command of interest. * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. + * @buflen: Response buffer length. * * Simulate REPORT LUNS command. * * LOCKING: * spin_lock_irqsave(host lock) */ -static unsigned int ata_scsiop_report_luns(struct ata_scsi_args *args, u8 *rbuf) + +unsigned int ata_scsiop_report_luns(struct ata_scsi_args *args, u8 *rbuf, + unsigned int buflen) { VPRINTK("ENTER\n"); rbuf[3] = 8; /* just one lun, LUN 0, size 8 bytes */ @@ -2181,6 +2312,53 @@ static unsigned int ata_scsiop_report_luns(struct ata_scsi_args *args, u8 *rbuf) return 0; } +/** + * ata_scsi_set_sense - Set SCSI sense data and status + * @cmd: SCSI request to be handled + * @sk: SCSI-defined sense key + * @asc: SCSI-defined additional sense code + * @ascq: SCSI-defined additional sense code qualifier + * + * Helper function that builds a valid fixed format, current + * response code and the given sense key (sk), additional sense + * code (asc) and additional sense code qualifier (ascq) with + * a SCSI command status of %SAM_STAT_CHECK_CONDITION and + * DRIVER_SENSE set in the upper bits of scsi_cmnd::result . + * + * LOCKING: + * Not required + */ + +void ata_scsi_set_sense(struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq) +{ + cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; + + scsi_build_sense_buffer(0, cmd->sense_buffer, sk, asc, ascq); +} + +/** + * ata_scsi_badcmd - End a SCSI request with an error + * @cmd: SCSI request to be handled + * @done: SCSI command completion function + * @asc: SCSI-defined additional sense code + * @ascq: SCSI-defined additional sense code qualifier + * + * Helper function that completes a SCSI command with + * %SAM_STAT_CHECK_CONDITION, with a sense key %ILLEGAL_REQUEST + * and the specified additional sense codes. + * + * LOCKING: + * spin_lock_irqsave(host lock) + */ + +void ata_scsi_badcmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), u8 asc, u8 ascq) +{ + DPRINTK("ENTER\n"); + ata_scsi_set_sense(cmd, ILLEGAL_REQUEST, asc, ascq); + + done(cmd); +} + static void atapi_sense_complete(struct ata_queued_cmd *qc) { if (qc->err_mask && ((qc->err_mask & AC_ERR_DEV) == 0)) { @@ -2307,10 +2485,13 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc) u8 *scsicmd = cmd->cmnd; if ((scsicmd[0] == INQUIRY) && ((scsicmd[1] & 0x03) == 0)) { + u8 *buf = NULL; + unsigned int buflen; unsigned long flags; - u8 *buf; - buf = ata_scsi_rbuf_get(cmd, true, &flags); + local_irq_save(flags); + + buflen = ata_scsi_rbuf_get(cmd, &buf); /* ATAPI devices typically report zero for their SCSI version, * and sometimes deviate from the spec WRT response data @@ -2325,7 +2506,9 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc) buf[3] = 0x32; } - ata_scsi_rbuf_put(cmd, true, &flags); + ata_scsi_rbuf_put(cmd, buf); + + local_irq_restore(flags); } cmd->result = SAM_STAT_GOOD; diff --git a/trunk/drivers/ata/libata.h b/trunk/drivers/ata/libata.h index 4514283937ea..ae2cfd95d43e 100644 --- a/trunk/drivers/ata/libata.h +++ b/trunk/drivers/ata/libata.h @@ -146,6 +146,34 @@ extern void ata_scsi_scan_host(struct ata_port *ap, int sync); extern int ata_scsi_offline_dev(struct ata_device *dev); extern void ata_scsi_media_change_notify(struct ata_device *dev); extern void ata_scsi_hotplug(struct work_struct *work); +extern unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf, + unsigned int buflen); + +extern unsigned int ata_scsiop_inq_00(struct ata_scsi_args *args, u8 *rbuf, + unsigned int buflen); + +extern unsigned int ata_scsiop_inq_80(struct ata_scsi_args *args, u8 *rbuf, + unsigned int buflen); +extern unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf, + unsigned int buflen); +extern unsigned int ata_scsiop_noop(struct ata_scsi_args *args, u8 *rbuf, + unsigned int buflen); +extern unsigned int ata_scsiop_sync_cache(struct ata_scsi_args *args, u8 *rbuf, + unsigned int buflen); +extern unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf, + unsigned int buflen); +extern unsigned int ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf, + unsigned int buflen); +extern unsigned int ata_scsiop_report_luns(struct ata_scsi_args *args, u8 *rbuf, + unsigned int buflen); +extern void ata_scsi_badcmd(struct scsi_cmnd *cmd, + void (*done)(struct scsi_cmnd *), + u8 asc, u8 ascq); +extern void ata_scsi_set_sense(struct scsi_cmnd *cmd, + u8 sk, u8 asc, u8 ascq); +extern void ata_scsi_rbuf_fill(struct ata_scsi_args *args, + unsigned int (*actor) (struct ata_scsi_args *args, + u8 *rbuf, unsigned int buflen)); extern void ata_schedule_scsi_eh(struct Scsi_Host *shost); extern void ata_scsi_dev_rescan(struct work_struct *work); extern int ata_bus_probe(struct ata_port *ap); diff --git a/trunk/drivers/ata/pata_atiixp.c b/trunk/drivers/ata/pata_atiixp.c index d7de7baf58a8..78738fb4223b 100644 --- a/trunk/drivers/ata/pata_atiixp.c +++ b/trunk/drivers/ata/pata_atiixp.c @@ -88,8 +88,8 @@ static void atiixp_set_pio_timing(struct ata_port *ap, struct ata_device *adev, pci_write_config_word(pdev, ATIIXP_IDE_PIO_MODE, pio_mode_data); pci_read_config_word(pdev, ATIIXP_IDE_PIO_TIMING, &pio_timing_data); - pio_timing_data &= ~(0xFF << timing_shift); - pio_timing_data |= (pio_timings[pio] << timing_shift); + pio_mode_data &= ~(0xFF << timing_shift); + pio_mode_data |= (pio_timings[pio] << timing_shift); pci_write_config_word(pdev, ATIIXP_IDE_PIO_TIMING, pio_timing_data); } diff --git a/trunk/drivers/ata/pata_bf54x.c b/trunk/drivers/ata/pata_bf54x.c index 9ab89732cf94..a75de0684c15 100644 --- a/trunk/drivers/ata/pata_bf54x.c +++ b/trunk/drivers/ata/pata_bf54x.c @@ -1272,8 +1272,8 @@ static void bfin_freeze(struct ata_port *ap) void bfin_thaw(struct ata_port *ap) { - dev_dbg(ap->dev, "in atapi dma thaw\n"); bfin_check_status(ap); + bfin_irq_clear(ap); bfin_irq_on(ap); } @@ -1339,130 +1339,13 @@ static int bfin_port_start(struct ata_port *ap) return 0; } -static unsigned int bfin_ata_host_intr(struct ata_port *ap, - struct ata_queued_cmd *qc) -{ - struct ata_eh_info *ehi = &ap->link.eh_info; - u8 status, host_stat = 0; - - VPRINTK("ata%u: protocol %d task_state %d\n", - ap->print_id, qc->tf.protocol, ap->hsm_task_state); - - /* Check whether we are expecting interrupt in this state */ - switch (ap->hsm_task_state) { - case HSM_ST_FIRST: - /* Some pre-ATAPI-4 devices assert INTRQ - * at this state when ready to receive CDB. - */ - - /* Check the ATA_DFLAG_CDB_INTR flag is enough here. - * The flag was turned on only for atapi devices. - * No need to check is_atapi_taskfile(&qc->tf) again. - */ - if (!(qc->dev->flags & ATA_DFLAG_CDB_INTR)) - goto idle_irq; - break; - case HSM_ST_LAST: - if (qc->tf.protocol == ATA_PROT_DMA || - qc->tf.protocol == ATAPI_PROT_DMA) { - /* check status of DMA engine */ - host_stat = ap->ops->bmdma_status(ap); - VPRINTK("ata%u: host_stat 0x%X\n", - ap->print_id, host_stat); - - /* if it's not our irq... */ - if (!(host_stat & ATA_DMA_INTR)) - goto idle_irq; - - /* before we do anything else, clear DMA-Start bit */ - ap->ops->bmdma_stop(qc); - - if (unlikely(host_stat & ATA_DMA_ERR)) { - /* error when transfering data to/from memory */ - qc->err_mask |= AC_ERR_HOST_BUS; - ap->hsm_task_state = HSM_ST_ERR; - } - } - break; - case HSM_ST: - break; - default: - goto idle_irq; - } - - /* check altstatus */ - status = ap->ops->sff_check_altstatus(ap); - if (status & ATA_BUSY) - goto busy_ata; - - /* check main status, clearing INTRQ */ - status = ap->ops->sff_check_status(ap); - if (unlikely(status & ATA_BUSY)) - goto busy_ata; - - /* ack bmdma irq events */ - ap->ops->sff_irq_clear(ap); - - ata_sff_hsm_move(ap, qc, status, 0); - - if (unlikely(qc->err_mask) && (qc->tf.protocol == ATA_PROT_DMA || - qc->tf.protocol == ATAPI_PROT_DMA)) - ata_ehi_push_desc(ehi, "BMDMA stat 0x%x", host_stat); - -busy_ata: - return 1; /* irq handled */ - -idle_irq: - ap->stats.idle_irq++; - -#ifdef ATA_IRQ_TRAP - if ((ap->stats.idle_irq % 1000) == 0) { - ap->ops->irq_ack(ap, 0); /* debug trap */ - ata_port_printk(ap, KERN_WARNING, "irq trap\n"); - return 1; - } -#endif - return 0; /* irq not handled */ -} - -static irqreturn_t bfin_ata_interrupt(int irq, void *dev_instance) -{ - struct ata_host *host = dev_instance; - unsigned int i; - unsigned int handled = 0; - unsigned long flags; - - /* TODO: make _irqsave conditional on x86 PCI IDE legacy mode */ - spin_lock_irqsave(&host->lock, flags); - - for (i = 0; i < host->n_ports; i++) { - struct ata_port *ap; - - ap = host->ports[i]; - if (ap && - !(ap->flags & ATA_FLAG_DISABLED)) { - struct ata_queued_cmd *qc; - - qc = ata_qc_from_tag(ap, ap->link.active_tag); - if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)) && - (qc->flags & ATA_QCFLAG_ACTIVE)) - handled |= bfin_ata_host_intr(ap, qc); - } - } - - spin_unlock_irqrestore(&host->lock, flags); - - return IRQ_RETVAL(handled); -} - - static struct scsi_host_template bfin_sht = { ATA_BASE_SHT(DRV_NAME), .sg_tablesize = SG_NONE, .dma_boundary = ATA_DMA_BOUNDARY, }; -static struct ata_port_operations bfin_pata_ops = { +static const struct ata_port_operations bfin_pata_ops = { .inherits = &ata_sff_port_ops, .set_piomode = bfin_set_piomode, @@ -1487,6 +1370,7 @@ static struct ata_port_operations bfin_pata_ops = { .thaw = bfin_thaw, .softreset = bfin_softreset, .postreset = bfin_postreset, + .post_internal_cmd = bfin_bmdma_stop, .sff_irq_clear = bfin_irq_clear, .sff_irq_on = bfin_irq_on, @@ -1623,7 +1507,7 @@ static int __devinit bfin_atapi_probe(struct platform_device *pdev) } if (ata_host_activate(host, platform_get_irq(pdev, 0), - bfin_ata_interrupt, IRQF_SHARED, &bfin_sht) != 0) { + ata_sff_interrupt, IRQF_SHARED, &bfin_sht) != 0) { peripheral_free_list(atapi_io_port); dev_err(&pdev->dev, "Fail to attach ATAPI device\n"); return -ENODEV; diff --git a/trunk/drivers/ata/pata_rb532_cf.c b/trunk/drivers/ata/pata_rb500_cf.c similarity index 72% rename from trunk/drivers/ata/pata_rb532_cf.c rename to trunk/drivers/ata/pata_rb500_cf.c index a108d259f19d..4345174aaeec 100644 --- a/trunk/drivers/ata/pata_rb532_cf.c +++ b/trunk/drivers/ata/pata_rb500_cf.c @@ -32,7 +32,7 @@ #include -#define DRV_NAME "pata-rb532-cf" +#define DRV_NAME "pata-rb500-cf" #define DRV_VERSION "0.1.0" #define DRV_DESC "PATA driver for RouterBOARD 532 Compact Flash" @@ -43,7 +43,7 @@ #define RB500_CF_REG_CTRL 0x080E #define RB500_CF_REG_DATA 0x0C00 -struct rb532_cf_info { +struct rb500_cf_info { void __iomem *iobase; unsigned int gpio_line; int frozen; @@ -52,10 +52,10 @@ struct rb532_cf_info { /* ------------------------------------------------------------------------ */ -static inline void rb532_pata_finish_io(struct ata_port *ap) +static inline void rb500_pata_finish_io(struct ata_port *ap) { struct ata_host *ah = ap->host; - struct rb532_cf_info *info = ah->private_data; + struct rb500_cf_info *info = ah->private_data; ata_sff_altstatus(ap); ndelay(RB500_CF_IO_DELAY); @@ -63,14 +63,14 @@ static inline void rb532_pata_finish_io(struct ata_port *ap) set_irq_type(info->irq, IRQ_TYPE_LEVEL_HIGH); } -static void rb532_pata_exec_command(struct ata_port *ap, +static void rb500_pata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf) { writeb(tf->command, ap->ioaddr.command_addr); - rb532_pata_finish_io(ap); + rb500_pata_finish_io(ap); } -static void rb532_pata_data_xfer(struct ata_device *adev, unsigned char *buf, +static void rb500_pata_data_xfer(struct ata_device *adev, unsigned char *buf, unsigned int buflen, int write_data) { struct ata_port *ap = adev->link->ap; @@ -84,27 +84,27 @@ static void rb532_pata_data_xfer(struct ata_device *adev, unsigned char *buf, *buf = readb(ioaddr); } - rb532_pata_finish_io(adev->link->ap); + rb500_pata_finish_io(adev->link->ap); } -static void rb532_pata_freeze(struct ata_port *ap) +static void rb500_pata_freeze(struct ata_port *ap) { - struct rb532_cf_info *info = ap->host->private_data; + struct rb500_cf_info *info = ap->host->private_data; info->frozen = 1; } -static void rb532_pata_thaw(struct ata_port *ap) +static void rb500_pata_thaw(struct ata_port *ap) { - struct rb532_cf_info *info = ap->host->private_data; + struct rb500_cf_info *info = ap->host->private_data; info->frozen = 0; } -static irqreturn_t rb532_pata_irq_handler(int irq, void *dev_instance) +static irqreturn_t rb500_pata_irq_handler(int irq, void *dev_instance) { struct ata_host *ah = dev_instance; - struct rb532_cf_info *info = ah->private_data; + struct rb500_cf_info *info = ah->private_data; if (gpio_get_value(info->gpio_line)) { set_irq_type(info->irq, IRQ_TYPE_LEVEL_LOW); @@ -117,30 +117,30 @@ static irqreturn_t rb532_pata_irq_handler(int irq, void *dev_instance) return IRQ_HANDLED; } -static struct ata_port_operations rb532_pata_port_ops = { +static struct ata_port_operations rb500_pata_port_ops = { .inherits = &ata_sff_port_ops, - .sff_exec_command = rb532_pata_exec_command, - .sff_data_xfer = rb532_pata_data_xfer, - .freeze = rb532_pata_freeze, - .thaw = rb532_pata_thaw, + .sff_exec_command = rb500_pata_exec_command, + .sff_data_xfer = rb500_pata_data_xfer, + .freeze = rb500_pata_freeze, + .thaw = rb500_pata_thaw, }; /* ------------------------------------------------------------------------ */ -static struct scsi_host_template rb532_pata_sht = { +static struct scsi_host_template rb500_pata_sht = { ATA_PIO_SHT(DRV_NAME), }; /* ------------------------------------------------------------------------ */ -static void rb532_pata_setup_ports(struct ata_host *ah) +static void rb500_pata_setup_ports(struct ata_host *ah) { - struct rb532_cf_info *info = ah->private_data; + struct rb500_cf_info *info = ah->private_data; struct ata_port *ap; ap = ah->ports[0]; - ap->ops = &rb532_pata_port_ops; + ap->ops = &rb500_pata_port_ops; ap->pio_mask = 0x1f; /* PIO4 */ ap->flags = ATA_FLAG_NO_LEGACY | ATA_FLAG_MMIO; @@ -153,13 +153,13 @@ static void rb532_pata_setup_ports(struct ata_host *ah) ap->ioaddr.data_addr = info->iobase + RB500_CF_REG_DATA; } -static __devinit int rb532_pata_driver_probe(struct platform_device *pdev) +static __devinit int rb500_pata_driver_probe(struct platform_device *pdev) { unsigned int irq; int gpio; struct resource *res; struct ata_host *ah; - struct rb532_cf_info *info; + struct rb500_cf_info *info; int ret; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -213,10 +213,10 @@ static __devinit int rb532_pata_driver_probe(struct platform_device *pdev) goto err_free_gpio; } - rb532_pata_setup_ports(ah); + rb500_pata_setup_ports(ah); - ret = ata_host_activate(ah, irq, rb532_pata_irq_handler, - IRQF_TRIGGER_LOW, &rb532_pata_sht); + ret = ata_host_activate(ah, irq, rb500_pata_irq_handler, + IRQF_TRIGGER_LOW, &rb500_pata_sht); if (ret) goto err_free_gpio; @@ -228,10 +228,10 @@ static __devinit int rb532_pata_driver_probe(struct platform_device *pdev) return ret; } -static __devexit int rb532_pata_driver_remove(struct platform_device *pdev) +static __devexit int rb500_pata_driver_remove(struct platform_device *pdev) { struct ata_host *ah = platform_get_drvdata(pdev); - struct rb532_cf_info *info = ah->private_data; + struct rb500_cf_info *info = ah->private_data; ata_host_detach(ah); gpio_free(info->gpio_line); @@ -242,9 +242,9 @@ static __devexit int rb532_pata_driver_remove(struct platform_device *pdev) /* work with hotplug and coldplug */ MODULE_ALIAS("platform:" DRV_NAME); -static struct platform_driver rb532_pata_platform_driver = { - .probe = rb532_pata_driver_probe, - .remove = __devexit_p(rb532_pata_driver_remove), +static struct platform_driver rb500_pata_platform_driver = { + .probe = rb500_pata_driver_probe, + .remove = __devexit_p(rb500_pata_driver_remove), .driver = { .name = DRV_NAME, .owner = THIS_MODULE, @@ -255,16 +255,16 @@ static struct platform_driver rb532_pata_platform_driver = { #define DRV_INFO DRV_DESC " version " DRV_VERSION -static int __init rb532_pata_module_init(void) +static int __init rb500_pata_module_init(void) { printk(KERN_INFO DRV_INFO "\n"); - return platform_driver_register(&rb532_pata_platform_driver); + return platform_driver_register(&rb500_pata_platform_driver); } -static void __exit rb532_pata_module_exit(void) +static void __exit rb500_pata_module_exit(void) { - platform_driver_unregister(&rb532_pata_platform_driver); + platform_driver_unregister(&rb500_pata_platform_driver); } MODULE_AUTHOR("Gabor Juhos "); @@ -273,5 +273,5 @@ MODULE_DESCRIPTION(DRV_DESC); MODULE_VERSION(DRV_VERSION); MODULE_LICENSE("GPL"); -module_init(rb532_pata_module_init); -module_exit(rb532_pata_module_exit); +module_init(rb500_pata_module_init); +module_exit(rb500_pata_module_exit); diff --git a/trunk/drivers/ata/pata_via.c b/trunk/drivers/ata/pata_via.c index 2fea6cbe7755..d4840748fb5c 100644 --- a/trunk/drivers/ata/pata_via.c +++ b/trunk/drivers/ata/pata_via.c @@ -464,12 +464,11 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) } pci_dev_put(isa); - if (!(config->flags & VIA_NO_ENABLES)) { - /* 0x40 low bits indicate enabled channels */ - pci_read_config_byte(pdev, 0x40 , &enable); - enable &= 3; - if (enable == 0) - return -ENODEV; + /* 0x40 low bits indicate enabled channels */ + pci_read_config_byte(pdev, 0x40 , &enable); + enable &= 3; + if (enable == 0) { + return -ENODEV; } /* Initialise the FIFO for the enabled channels. */ diff --git a/trunk/drivers/ata/sata_mv.c b/trunk/drivers/ata/sata_mv.c index 842b1a15b78c..26a6337195b3 100644 --- a/trunk/drivers/ata/sata_mv.c +++ b/trunk/drivers/ata/sata_mv.c @@ -172,11 +172,10 @@ enum { PCIE_IRQ_MASK_OFS = 0x1910, PCIE_UNMASK_ALL_IRQS = 0x40a, /* assorted bits */ - /* Host Controller Main Interrupt Cause/Mask registers (1 per-chip) */ - PCI_HC_MAIN_IRQ_CAUSE_OFS = 0x1d60, - PCI_HC_MAIN_IRQ_MASK_OFS = 0x1d64, - SOC_HC_MAIN_IRQ_CAUSE_OFS = 0x20020, - SOC_HC_MAIN_IRQ_MASK_OFS = 0x20024, + HC_MAIN_IRQ_CAUSE_OFS = 0x1d60, + HC_MAIN_IRQ_MASK_OFS = 0x1d64, + HC_SOC_MAIN_IRQ_CAUSE_OFS = 0x20020, + HC_SOC_MAIN_IRQ_MASK_OFS = 0x20024, ERR_IRQ = (1 << 0), /* shift by port # */ DONE_IRQ = (1 << 1), /* shift by port # */ HC0_IRQ_PEND = 0x1ff, /* bits 0-8 = HC0's ports */ @@ -446,8 +445,8 @@ struct mv_host_priv { const struct mv_hw_ops *ops; int n_ports; void __iomem *base; - void __iomem *main_irq_cause_addr; - void __iomem *main_irq_mask_addr; + void __iomem *main_cause_reg_addr; + void __iomem *main_mask_reg_addr; u32 irq_cause_ofs; u32 irq_mask_ofs; u32 unmask_all_irqs; @@ -728,8 +727,8 @@ static inline unsigned int mv_hardport_from_port(unsigned int port) * Simple code, with two return values, so macro rather than inline. * * port is the sole input, in range 0..7. - * shift is one output, for use with main_irq_cause / main_irq_mask registers. - * hardport is the other output, in range 0..3. + * shift is one output, for use with the main_cause and main_mask registers. + * hardport is the other output, in range 0..3 * * Note that port and hardport may be the same variable in some cases. */ @@ -1680,12 +1679,12 @@ static void mv_process_crpb_entries(struct ata_port *ap, struct mv_port_priv *pp /** * mv_host_intr - Handle all interrupts on the given host controller * @host: host specific structure - * @main_irq_cause: Main interrupt cause register for the chip. + * @main_cause: Main interrupt cause register for the chip. * * LOCKING: * Inherited from caller. */ -static int mv_host_intr(struct ata_host *host, u32 main_irq_cause) +static int mv_host_intr(struct ata_host *host, u32 main_cause) { struct mv_host_priv *hpriv = host->private_data; void __iomem *mmio = hpriv->base, *hc_mmio = NULL; @@ -1706,7 +1705,7 @@ static int mv_host_intr(struct ata_host *host, u32 main_irq_cause) * Do nothing if port is not interrupting or is disabled: */ MV_PORT_TO_SHIFT_AND_HARDPORT(port, shift, hardport); - port_cause = (main_irq_cause >> shift) & (DONE_IRQ | ERR_IRQ); + port_cause = (main_cause >> shift) & (DONE_IRQ | ERR_IRQ); if (!port_cause || !ap || (ap->flags & ATA_FLAG_DISABLED)) continue; /* @@ -1812,20 +1811,20 @@ static irqreturn_t mv_interrupt(int irq, void *dev_instance) struct ata_host *host = dev_instance; struct mv_host_priv *hpriv = host->private_data; unsigned int handled = 0; - u32 main_irq_cause, main_irq_mask; + u32 main_cause, main_mask; spin_lock(&host->lock); - main_irq_cause = readl(hpriv->main_irq_cause_addr); - main_irq_mask = readl(hpriv->main_irq_mask_addr); + main_cause = readl(hpriv->main_cause_reg_addr); + main_mask = readl(hpriv->main_mask_reg_addr); /* * Deal with cases where we either have nothing pending, or have read * a bogus register value which can indicate HW removal or PCI fault. */ - if ((main_irq_cause & main_irq_mask) && (main_irq_cause != 0xffffffffU)) { - if (unlikely((main_irq_cause & PCI_ERR) && HAS_PCI(host))) + if ((main_cause & main_mask) && (main_cause != 0xffffffffU)) { + if (unlikely((main_cause & PCI_ERR) && HAS_PCI(host))) handled = mv_pci_error(host, hpriv->base); else - handled = mv_host_intr(host, main_irq_cause); + handled = mv_host_intr(host, main_cause); } spin_unlock(&host->lock); return IRQ_RETVAL(handled); @@ -2028,7 +2027,7 @@ static void mv_reset_pci_bus(struct ata_host *host, void __iomem *mmio) ZERO(MV_PCI_DISC_TIMER); ZERO(MV_PCI_MSI_TRIGGER); writel(0x000100ff, mmio + MV_PCI_XBAR_TMOUT); - ZERO(PCI_HC_MAIN_IRQ_MASK_OFS); + ZERO(HC_MAIN_IRQ_MASK_OFS); ZERO(MV_PCI_SERR_MASK); ZERO(hpriv->irq_cause_ofs); ZERO(hpriv->irq_mask_ofs); @@ -2405,7 +2404,7 @@ static void mv_eh_freeze(struct ata_port *ap) { struct mv_host_priv *hpriv = ap->host->private_data; unsigned int shift, hardport, port = ap->port_no; - u32 main_irq_mask; + u32 main_mask; /* FIXME: handle coalescing completion events properly */ @@ -2413,9 +2412,9 @@ static void mv_eh_freeze(struct ata_port *ap) MV_PORT_TO_SHIFT_AND_HARDPORT(port, shift, hardport); /* disable assertion of portN err, done events */ - main_irq_mask = readl(hpriv->main_irq_mask_addr); - main_irq_mask &= ~((DONE_IRQ | ERR_IRQ) << shift); - writelfl(main_irq_mask, hpriv->main_irq_mask_addr); + main_mask = readl(hpriv->main_mask_reg_addr); + main_mask &= ~((DONE_IRQ | ERR_IRQ) << shift); + writelfl(main_mask, hpriv->main_mask_reg_addr); } static void mv_eh_thaw(struct ata_port *ap) @@ -2424,7 +2423,7 @@ static void mv_eh_thaw(struct ata_port *ap) unsigned int shift, hardport, port = ap->port_no; void __iomem *hc_mmio = mv_hc_base_from_port(hpriv->base, port); void __iomem *port_mmio = mv_ap_base(ap); - u32 main_irq_mask, hc_irq_cause; + u32 main_mask, hc_irq_cause; /* FIXME: handle coalescing completion events properly */ @@ -2439,9 +2438,9 @@ static void mv_eh_thaw(struct ata_port *ap) writelfl(hc_irq_cause, hc_mmio + HC_IRQ_CAUSE_OFS); /* enable assertion of portN err, done events */ - main_irq_mask = readl(hpriv->main_irq_mask_addr); - main_irq_mask |= ((DONE_IRQ | ERR_IRQ) << shift); - writelfl(main_irq_mask, hpriv->main_irq_mask_addr); + main_mask = readl(hpriv->main_mask_reg_addr); + main_mask |= ((DONE_IRQ | ERR_IRQ) << shift); + writelfl(main_mask, hpriv->main_mask_reg_addr); } /** @@ -2655,15 +2654,15 @@ static int mv_init_host(struct ata_host *host, unsigned int board_idx) goto done; if (HAS_PCI(host)) { - hpriv->main_irq_cause_addr = mmio + PCI_HC_MAIN_IRQ_CAUSE_OFS; - hpriv->main_irq_mask_addr = mmio + PCI_HC_MAIN_IRQ_MASK_OFS; + hpriv->main_cause_reg_addr = mmio + HC_MAIN_IRQ_CAUSE_OFS; + hpriv->main_mask_reg_addr = mmio + HC_MAIN_IRQ_MASK_OFS; } else { - hpriv->main_irq_cause_addr = mmio + SOC_HC_MAIN_IRQ_CAUSE_OFS; - hpriv->main_irq_mask_addr = mmio + SOC_HC_MAIN_IRQ_MASK_OFS; + hpriv->main_cause_reg_addr = mmio + HC_SOC_MAIN_IRQ_CAUSE_OFS; + hpriv->main_mask_reg_addr = mmio + HC_SOC_MAIN_IRQ_MASK_OFS; } /* global interrupt mask: 0 == mask everything */ - writel(0, hpriv->main_irq_mask_addr); + writel(0, hpriv->main_mask_reg_addr); n_hc = mv_get_hc_count(host->ports[0]->flags); @@ -2713,23 +2712,23 @@ static int mv_init_host(struct ata_host *host, unsigned int board_idx) writelfl(hpriv->unmask_all_irqs, mmio + hpriv->irq_mask_ofs); if (IS_GEN_I(hpriv)) writelfl(~HC_MAIN_MASKED_IRQS_5, - hpriv->main_irq_mask_addr); + hpriv->main_mask_reg_addr); else writelfl(~HC_MAIN_MASKED_IRQS, - hpriv->main_irq_mask_addr); + hpriv->main_mask_reg_addr); VPRINTK("HC MAIN IRQ cause/mask=0x%08x/0x%08x " "PCI int cause/mask=0x%08x/0x%08x\n", - readl(hpriv->main_irq_cause_addr), - readl(hpriv->main_irq_mask_addr), + readl(hpriv->main_cause_reg_addr), + readl(hpriv->main_mask_reg_addr), readl(mmio + hpriv->irq_cause_ofs), readl(mmio + hpriv->irq_mask_ofs)); } else { writelfl(~HC_MAIN_MASKED_IRQS_SOC, - hpriv->main_irq_mask_addr); + hpriv->main_mask_reg_addr); VPRINTK("HC MAIN IRQ cause/mask=0x%08x/0x%08x\n", - readl(hpriv->main_irq_cause_addr), - readl(hpriv->main_irq_mask_addr)); + readl(hpriv->main_cause_reg_addr), + readl(hpriv->main_mask_reg_addr)); } done: return rc; diff --git a/trunk/drivers/base/core.c b/trunk/drivers/base/core.c index be288b5e4180..9248e0927d08 100644 --- a/trunk/drivers/base/core.c +++ b/trunk/drivers/base/core.c @@ -787,10 +787,6 @@ int device_add(struct device *dev) parent = get_device(dev->parent); setup_parent(dev, parent); - /* use parent numa_node */ - if (parent) - set_dev_node(dev, dev_to_node(parent)); - /* first, register with generic layer. */ error = kobject_add(&dev->kobj, dev->kobj.parent, "%s", dev->bus_id); if (error) @@ -1310,11 +1306,8 @@ int device_move(struct device *dev, struct device *new_parent) dev->parent = new_parent; if (old_parent) klist_remove(&dev->knode_parent); - if (new_parent) { + if (new_parent) klist_add_tail(&dev->knode_parent, &new_parent->klist_children); - set_dev_node(dev, dev_to_node(new_parent)); - } - if (!dev->class) goto out_put; error = device_move_class_links(dev, old_parent, new_parent); @@ -1324,12 +1317,9 @@ int device_move(struct device *dev, struct device *new_parent) if (!kobject_move(&dev->kobj, &old_parent->kobj)) { if (new_parent) klist_remove(&dev->knode_parent); - dev->parent = old_parent; - if (old_parent) { + if (old_parent) klist_add_tail(&dev->knode_parent, &old_parent->klist_children); - set_dev_node(dev, dev_to_node(old_parent)); - } } cleanup_glue_dir(dev, new_parent_kobj); put_device(new_parent); diff --git a/trunk/drivers/base/firmware_class.c b/trunk/drivers/base/firmware_class.c index 9fd4a8534146..1fef7df8c9d6 100644 --- a/trunk/drivers/base/firmware_class.c +++ b/trunk/drivers/base/firmware_class.c @@ -396,8 +396,6 @@ _request_firmware(const struct firmware **firmware_p, const char *name, if (!firmware_p) return -EINVAL; - printk(KERN_INFO "firmware: requesting %s\n", name); - *firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL); if (!firmware) { printk(KERN_ERR "%s: kmalloc(struct firmware) failed\n", diff --git a/trunk/drivers/block/aoe/aoe.h b/trunk/drivers/block/aoe/aoe.h index 5b4c6e649c11..280e71ee744c 100644 --- a/trunk/drivers/block/aoe/aoe.h +++ b/trunk/drivers/block/aoe/aoe.h @@ -195,6 +195,7 @@ void aoedev_exit(void); struct aoedev *aoedev_by_aoeaddr(int maj, int min); struct aoedev *aoedev_by_sysminor_m(ulong sysminor); void aoedev_downdev(struct aoedev *d); +int aoedev_isbusy(struct aoedev *d); int aoedev_flush(const char __user *str, size_t size); int aoenet_init(void); diff --git a/trunk/drivers/block/aoe/aoecmd.c b/trunk/drivers/block/aoe/aoecmd.c index 8fc429cf82b6..d00293ba3b45 100644 --- a/trunk/drivers/block/aoe/aoecmd.c +++ b/trunk/drivers/block/aoe/aoecmd.c @@ -668,16 +668,16 @@ ataid_complete(struct aoedev *d, struct aoetgt *t, unsigned char *id) u16 n; /* word 83: command set supported */ - n = get_unaligned_le16(&id[83 << 1]); + n = le16_to_cpu(get_unaligned((__le16 *) &id[83<<1])); /* word 86: command set/feature enabled */ - n |= get_unaligned_le16(&id[86 << 1]); + n |= le16_to_cpu(get_unaligned((__le16 *) &id[86<<1])); if (n & (1<<10)) { /* bit 10: LBA 48 */ d->flags |= DEVFL_EXT; /* word 100: number lba48 sectors */ - ssize = get_unaligned_le64(&id[100 << 1]); + ssize = le64_to_cpu(get_unaligned((__le64 *) &id[100<<1])); /* set as in ide-disk.c:init_idedisk_capacity */ d->geo.cylinders = ssize; @@ -688,12 +688,12 @@ ataid_complete(struct aoedev *d, struct aoetgt *t, unsigned char *id) d->flags &= ~DEVFL_EXT; /* number lba28 sectors */ - ssize = get_unaligned_le32(&id[60 << 1]); + ssize = le32_to_cpu(get_unaligned((__le32 *) &id[60<<1])); /* NOTE: obsolete in ATA 6 */ - d->geo.cylinders = get_unaligned_le16(&id[54 << 1]); - d->geo.heads = get_unaligned_le16(&id[55 << 1]); - d->geo.sectors = get_unaligned_le16(&id[56 << 1]); + d->geo.cylinders = le16_to_cpu(get_unaligned((__le16 *) &id[54<<1])); + d->geo.heads = le16_to_cpu(get_unaligned((__le16 *) &id[55<<1])); + d->geo.sectors = le16_to_cpu(get_unaligned((__le16 *) &id[56<<1])); } if (d->ssize != ssize) @@ -779,7 +779,7 @@ aoecmd_ata_rsp(struct sk_buff *skb) u16 aoemajor; hin = (struct aoe_hdr *) skb_mac_header(skb); - aoemajor = get_unaligned_be16(&hin->major); + aoemajor = be16_to_cpu(get_unaligned(&hin->major)); d = aoedev_by_aoeaddr(aoemajor, hin->minor); if (d == NULL) { snprintf(ebuf, sizeof ebuf, "aoecmd_ata_rsp: ata response " @@ -791,7 +791,7 @@ aoecmd_ata_rsp(struct sk_buff *skb) spin_lock_irqsave(&d->lock, flags); - n = get_unaligned_be32(&hin->tag); + n = be32_to_cpu(get_unaligned(&hin->tag)); t = gettgt(d, hin->src); if (t == NULL) { printk(KERN_INFO "aoe: can't find target e%ld.%d:%012llx\n", @@ -806,9 +806,9 @@ aoecmd_ata_rsp(struct sk_buff *skb) snprintf(ebuf, sizeof ebuf, "%15s e%d.%d tag=%08x@%08lx\n", "unexpected rsp", - get_unaligned_be16(&hin->major), + be16_to_cpu(get_unaligned(&hin->major)), hin->minor, - get_unaligned_be32(&hin->tag), + be32_to_cpu(get_unaligned(&hin->tag)), jiffies); aoechr_error(ebuf); return; @@ -873,7 +873,7 @@ aoecmd_ata_rsp(struct sk_buff *skb) printk(KERN_INFO "aoe: unrecognized ata command %2.2Xh for %d.%d\n", ahout->cmdstat, - get_unaligned_be16(&hin->major), + be16_to_cpu(get_unaligned(&hin->major)), hin->minor); } } diff --git a/trunk/drivers/block/aoe/aoedev.c b/trunk/drivers/block/aoe/aoedev.c index a1d813ab0d6b..f9a1cd9edb77 100644 --- a/trunk/drivers/block/aoe/aoedev.c +++ b/trunk/drivers/block/aoe/aoedev.c @@ -18,6 +18,24 @@ static void skbpoolfree(struct aoedev *d); static struct aoedev *devlist; static DEFINE_SPINLOCK(devlist_lock); +int +aoedev_isbusy(struct aoedev *d) +{ + struct aoetgt **t, **te; + struct frame *f, *e; + + t = d->targets; + te = t + NTARGETS; + for (; t < te && *t; t++) { + f = (*t)->frames; + e = f + (*t)->nframes; + for (; f < e; f++) + if (f->tag != FREETAG) + return 1; + } + return 0; +} + struct aoedev * aoedev_by_aoeaddr(int maj, int min) { diff --git a/trunk/drivers/block/aoe/aoenet.c b/trunk/drivers/block/aoe/aoenet.c index d625169c8e48..18d243c73eee 100644 --- a/trunk/drivers/block/aoe/aoenet.c +++ b/trunk/drivers/block/aoe/aoenet.c @@ -128,7 +128,7 @@ aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt, skb_push(skb, ETH_HLEN); /* (1) */ h = (struct aoe_hdr *) skb_mac_header(skb); - n = get_unaligned_be32(&h->tag); + n = be32_to_cpu(get_unaligned(&h->tag)); if ((h->verfl & AOEFL_RSP) == 0 || (n & 1<<31)) goto exit; @@ -140,7 +140,7 @@ aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt, printk(KERN_ERR "%s%d.%d@%s; ecode=%d '%s'\n", "aoe: error packet from ", - get_unaligned_be16(&h->major), + be16_to_cpu(get_unaligned(&h->major)), h->minor, skb->dev->name, h->err, aoe_errlist[n]); goto exit; diff --git a/trunk/drivers/block/cciss.c b/trunk/drivers/block/cciss.c index e539be5750dc..cf6083a1f928 100644 --- a/trunk/drivers/block/cciss.c +++ b/trunk/drivers/block/cciss.c @@ -425,7 +425,7 @@ static void __devinit cciss_procinit(int i) struct proc_dir_entry *pde; if (proc_cciss == NULL) - proc_cciss = proc_mkdir("driver/cciss", NULL); + proc_cciss = proc_mkdir("cciss", proc_root_driver); if (!proc_cciss) return; pde = proc_create(hba[i]->devname, S_IWUSR | S_IRUSR | S_IRGRP | @@ -3700,7 +3700,7 @@ static void __exit cciss_cleanup(void) cciss_remove_one(hba[i]->pdev); } } - remove_proc_entry("driver/cciss", NULL); + remove_proc_entry("cciss", proc_root_driver); } static void fail_all_cmds(unsigned long ctlr) diff --git a/trunk/drivers/block/cpqarray.c b/trunk/drivers/block/cpqarray.c index 09c14341e6e3..69199185ff4b 100644 --- a/trunk/drivers/block/cpqarray.c +++ b/trunk/drivers/block/cpqarray.c @@ -214,7 +214,7 @@ static struct proc_dir_entry *proc_array; static void __init ida_procinit(int i) { if (proc_array == NULL) { - proc_array = proc_mkdir("driver/cpqarray", NULL); + proc_array = proc_mkdir("cpqarray", proc_root_driver); if (!proc_array) return; } @@ -1796,7 +1796,7 @@ static void __exit cpqarray_exit(void) } } - remove_proc_entry("driver/cpqarray", NULL); + remove_proc_entry("cpqarray", proc_root_driver); } module_init(cpqarray_init) diff --git a/trunk/drivers/block/floppy.c b/trunk/drivers/block/floppy.c index 395f8ea7981c..7652e87d60c5 100644 --- a/trunk/drivers/block/floppy.c +++ b/trunk/drivers/block/floppy.c @@ -4526,15 +4526,14 @@ static void __init parse_floppy_cfg_string(char *cfg) } } -static int __init floppy_module_init(void) +int __init init_module(void) { if (floppy) parse_floppy_cfg_string(floppy); return floppy_init(); } -module_init(floppy_module_init); -static void __exit floppy_module_exit(void) +void cleanup_module(void) { int drive; @@ -4563,7 +4562,6 @@ static void __exit floppy_module_exit(void) /* eject disk, if any */ fd_eject(0); } -module_exit(floppy_module_exit); module_param(floppy, charp, 0); module_param(FLOPPY_IRQ, int, 0); diff --git a/trunk/drivers/block/loop.c b/trunk/drivers/block/loop.c index d3a25b027ff9..f7f163557aa0 100644 --- a/trunk/drivers/block/loop.c +++ b/trunk/drivers/block/loop.c @@ -546,7 +546,7 @@ static void loop_unplug(struct request_queue *q) { struct loop_device *lo = q->queuedata; - queue_flag_clear_unlocked(QUEUE_FLAG_PLUGGED, q); + clear_bit(QUEUE_FLAG_PLUGGED, &q->queue_flags); blk_run_address_space(lo->lo_backing_file->f_mapping); } diff --git a/trunk/drivers/block/nbd.c b/trunk/drivers/block/nbd.c index ad98dda6037d..60cc54368b66 100644 --- a/trunk/drivers/block/nbd.c +++ b/trunk/drivers/block/nbd.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include @@ -56,7 +55,6 @@ static unsigned int debugflags; static unsigned int nbds_max = 16; static struct nbd_device *nbd_dev; -static int max_part; /* * Use just one lock (or at most 1 per NIC). Two arguments for this: @@ -339,7 +337,7 @@ static struct request *nbd_read_stat(struct nbd_device *lo) } req = nbd_find_request(lo, *(struct request **)reply.handle); - if (IS_ERR(req)) { + if (unlikely(IS_ERR(req))) { result = PTR_ERR(req); if (result != -ENOENT) goto harderror; @@ -443,85 +441,6 @@ static void nbd_clear_que(struct nbd_device *lo) } -static void nbd_handle_req(struct nbd_device *lo, struct request *req) -{ - if (!blk_fs_request(req)) - goto error_out; - - nbd_cmd(req) = NBD_CMD_READ; - if (rq_data_dir(req) == WRITE) { - nbd_cmd(req) = NBD_CMD_WRITE; - if (lo->flags & NBD_READ_ONLY) { - printk(KERN_ERR "%s: Write on read-only\n", - lo->disk->disk_name); - goto error_out; - } - } - - req->errors = 0; - - mutex_lock(&lo->tx_lock); - if (unlikely(!lo->sock)) { - mutex_unlock(&lo->tx_lock); - printk(KERN_ERR "%s: Attempted send on closed socket\n", - lo->disk->disk_name); - req->errors++; - nbd_end_request(req); - return; - } - - lo->active_req = req; - - if (nbd_send_req(lo, req) != 0) { - printk(KERN_ERR "%s: Request send failed\n", - lo->disk->disk_name); - req->errors++; - nbd_end_request(req); - } else { - spin_lock(&lo->queue_lock); - list_add(&req->queuelist, &lo->queue_head); - spin_unlock(&lo->queue_lock); - } - - lo->active_req = NULL; - mutex_unlock(&lo->tx_lock); - wake_up_all(&lo->active_wq); - - return; - -error_out: - req->errors++; - nbd_end_request(req); -} - -static int nbd_thread(void *data) -{ - struct nbd_device *lo = data; - struct request *req; - - set_user_nice(current, -20); - while (!kthread_should_stop() || !list_empty(&lo->waiting_queue)) { - /* wait for something to do */ - wait_event_interruptible(lo->waiting_wq, - kthread_should_stop() || - !list_empty(&lo->waiting_queue)); - - /* extract request */ - if (list_empty(&lo->waiting_queue)) - continue; - - spin_lock_irq(&lo->queue_lock); - req = list_entry(lo->waiting_queue.next, struct request, - queuelist); - list_del_init(&req->queuelist); - spin_unlock_irq(&lo->queue_lock); - - /* handle request */ - nbd_handle_req(lo, req); - } - return 0; -} - /* * We always wait for result of write, for now. It would be nice to make it optional * in future @@ -537,23 +456,65 @@ static void do_nbd_request(struct request_queue * q) struct nbd_device *lo; blkdev_dequeue_request(req); - - spin_unlock_irq(q->queue_lock); - dprintk(DBG_BLKDEV, "%s: request %p: dequeued (flags=%x)\n", req->rq_disk->disk_name, req, req->cmd_type); + if (!blk_fs_request(req)) + goto error_out; + lo = req->rq_disk->private_data; BUG_ON(lo->magic != LO_MAGIC); - spin_lock_irq(&lo->queue_lock); - list_add_tail(&req->queuelist, &lo->waiting_queue); - spin_unlock_irq(&lo->queue_lock); + nbd_cmd(req) = NBD_CMD_READ; + if (rq_data_dir(req) == WRITE) { + nbd_cmd(req) = NBD_CMD_WRITE; + if (lo->flags & NBD_READ_ONLY) { + printk(KERN_ERR "%s: Write on read-only\n", + lo->disk->disk_name); + goto error_out; + } + } + + req->errors = 0; + spin_unlock_irq(q->queue_lock); + + mutex_lock(&lo->tx_lock); + if (unlikely(!lo->sock)) { + mutex_unlock(&lo->tx_lock); + printk(KERN_ERR "%s: Attempted send on closed socket\n", + lo->disk->disk_name); + req->errors++; + nbd_end_request(req); + spin_lock_irq(q->queue_lock); + continue; + } + + lo->active_req = req; - wake_up(&lo->waiting_wq); + if (nbd_send_req(lo, req) != 0) { + printk(KERN_ERR "%s: Request send failed\n", + lo->disk->disk_name); + req->errors++; + nbd_end_request(req); + } else { + spin_lock(&lo->queue_lock); + list_add(&req->queuelist, &lo->queue_head); + spin_unlock(&lo->queue_lock); + } + + lo->active_req = NULL; + mutex_unlock(&lo->tx_lock); + wake_up_all(&lo->active_wq); spin_lock_irq(q->queue_lock); + continue; + +error_out: + req->errors++; + spin_unlock(q->queue_lock); + nbd_end_request(req); + spin_lock(q->queue_lock); } } @@ -563,7 +524,6 @@ static int nbd_ioctl(struct inode *inode, struct file *file, struct nbd_device *lo = inode->i_bdev->bd_disk->private_data; int error; struct request sreq ; - struct task_struct *thread; if (!capable(CAP_SYS_ADMIN)) return -EPERM; @@ -577,7 +537,6 @@ static int nbd_ioctl(struct inode *inode, struct file *file, switch (cmd) { case NBD_DISCONNECT: printk(KERN_INFO "%s: NBD_DISCONNECT\n", lo->disk->disk_name); - blk_rq_init(NULL, &sreq); sreq.cmd_type = REQ_TYPE_SPECIAL; nbd_cmd(&sreq) = NBD_CMD_DISC; /* @@ -612,13 +571,10 @@ static int nbd_ioctl(struct inode *inode, struct file *file, error = -EINVAL; file = fget(arg); if (file) { - struct block_device *bdev = inode->i_bdev; inode = file->f_path.dentry->d_inode; if (S_ISSOCK(inode->i_mode)) { lo->file = file; lo->sock = SOCKET_I(inode); - if (max_part > 0) - bdev->bd_invalidated = 1; error = 0; } else { fput(file); @@ -650,12 +606,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file, case NBD_DO_IT: if (!lo->file) return -EINVAL; - thread = kthread_create(nbd_thread, lo, lo->disk->disk_name); - if (IS_ERR(thread)) - return PTR_ERR(thread); - wake_up_process(thread); error = nbd_do_it(lo); - kthread_stop(thread); if (error) return error; sock_shutdown(lo, 1); @@ -668,8 +619,6 @@ static int nbd_ioctl(struct inode *inode, struct file *file, lo->bytesize = 0; inode->i_bdev->bd_inode->i_size = 0; set_capacity(lo->disk, 0); - if (max_part > 0) - ioctl_by_bdev(inode->i_bdev, BLKRRPART, 0); return lo->harderror; case NBD_CLEAR_QUE: /* @@ -703,7 +652,6 @@ static int __init nbd_init(void) { int err = -ENOMEM; int i; - int part_shift; BUILD_BUG_ON(sizeof(struct nbd_request) != 28); @@ -711,17 +659,8 @@ static int __init nbd_init(void) if (!nbd_dev) return -ENOMEM; - if (max_part < 0) { - printk(KERN_CRIT "nbd: max_part must be >= 0\n"); - return -EINVAL; - } - - part_shift = 0; - if (max_part > 0) - part_shift = fls(max_part); - for (i = 0; i < nbds_max; i++) { - struct gendisk *disk = alloc_disk(1 << part_shift); + struct gendisk *disk = alloc_disk(1); elevator_t *old_e; if (!disk) goto out; @@ -756,18 +695,17 @@ static int __init nbd_init(void) nbd_dev[i].file = NULL; nbd_dev[i].magic = LO_MAGIC; nbd_dev[i].flags = 0; - INIT_LIST_HEAD(&nbd_dev[i].waiting_queue); spin_lock_init(&nbd_dev[i].queue_lock); INIT_LIST_HEAD(&nbd_dev[i].queue_head); mutex_init(&nbd_dev[i].tx_lock); init_waitqueue_head(&nbd_dev[i].active_wq); - init_waitqueue_head(&nbd_dev[i].waiting_wq); nbd_dev[i].blksize = 1024; nbd_dev[i].bytesize = 0; disk->major = NBD_MAJOR; - disk->first_minor = i << part_shift; + disk->first_minor = i; disk->fops = &nbd_fops; disk->private_data = &nbd_dev[i]; + disk->flags |= GENHD_FL_SUPPRESS_PARTITION_INFO; sprintf(disk->disk_name, "nbd%d", i); set_capacity(disk, 0); add_disk(disk); @@ -805,9 +743,7 @@ MODULE_DESCRIPTION("Network Block Device"); MODULE_LICENSE("GPL"); module_param(nbds_max, int, 0444); -MODULE_PARM_DESC(nbds_max, "number of network block devices to initialize (default: 16)"); -module_param(max_part, int, 0444); -MODULE_PARM_DESC(max_part, "number of partitions per device (default: 0)"); +MODULE_PARM_DESC(nbds_max, "How many network block devices to initialize."); #ifndef NDEBUG module_param(debugflags, int, 0644); MODULE_PARM_DESC(debugflags, "flags for controlling debug output"); diff --git a/trunk/drivers/block/paride/pd.c b/trunk/drivers/block/paride/pd.c index 570f3b70dce7..df819f8a95a6 100644 --- a/trunk/drivers/block/paride/pd.c +++ b/trunk/drivers/block/paride/pd.c @@ -716,8 +716,10 @@ static int pd_special_command(struct pd_unit *disk, struct request rq; int err = 0; - blk_rq_init(NULL, &rq); + memset(&rq, 0, sizeof(rq)); + rq.errors = 0; rq.rq_disk = disk->gd; + rq.ref_count = 1; rq.end_io_data = &wait; rq.end_io = blk_end_sync_rq; blk_insert_request(disk->gd->queue, &rq, 0, func); diff --git a/trunk/drivers/block/pktcdvd.c b/trunk/drivers/block/pktcdvd.c index 3ba1df93e9e3..18feb1c7c33b 100644 --- a/trunk/drivers/block/pktcdvd.c +++ b/trunk/drivers/block/pktcdvd.c @@ -776,6 +776,8 @@ static int pkt_generic_packet(struct pktcdvd_device *pd, struct packet_command * rq->cmd_len = COMMAND_SIZE(cgc->cmd[0]); memcpy(rq->cmd, cgc->cmd, CDROM_PACKET_SIZE); + if (sizeof(rq->cmd) > CDROM_PACKET_SIZE) + memset(rq->cmd + CDROM_PACKET_SIZE, 0, sizeof(rq->cmd) - CDROM_PACKET_SIZE); rq->timeout = 60*HZ; rq->cmd_type = REQ_TYPE_BLOCK_PC; @@ -2742,6 +2744,7 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev) int i; int ret = 0; char b[BDEVNAME_SIZE]; + struct proc_dir_entry *proc; struct block_device *bdev; if (pd->pkt_dev == dev) { @@ -2785,7 +2788,11 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev) goto out_mem; } - proc_create_data(pd->name, 0, pkt_proc, &pkt_proc_fops, pd); + proc = create_proc_entry(pd->name, 0, pkt_proc); + if (proc) { + proc->data = pd; + proc->proc_fops = &pkt_proc_fops; + } DPRINTK(DRIVER_NAME": writer %s mapped to %s\n", pd->name, bdevname(bdev, b)); return 0; @@ -3094,7 +3101,7 @@ static int __init pkt_init(void) goto out_misc; } - pkt_proc = proc_mkdir("driver/"DRIVER_NAME, NULL); + pkt_proc = proc_mkdir(DRIVER_NAME, proc_root_driver); return 0; @@ -3110,7 +3117,7 @@ static int __init pkt_init(void) static void __exit pkt_exit(void) { - remove_proc_entry("driver/"DRIVER_NAME, NULL); + remove_proc_entry(DRIVER_NAME, proc_root_driver); misc_deregister(&pkt_misc); pkt_debugfs_cleanup(); diff --git a/trunk/drivers/block/ps3disk.c b/trunk/drivers/block/ps3disk.c index d797e209951d..7483f947f0e9 100644 --- a/trunk/drivers/block/ps3disk.c +++ b/trunk/drivers/block/ps3disk.c @@ -102,7 +102,8 @@ static void ps3disk_scatter_gather(struct ps3_storage_device *dev, dev_dbg(&dev->sbd.core, "%s:%u: bio %u: %u segs %u sectors from %lu\n", __func__, __LINE__, i, bio_segments(iter.bio), - bio_sectors(iter.bio), iter.bio->bi_sector); + bio_sectors(iter.bio), + (unsigned long)iter.bio->bi_sector); size = bvec->bv_len; buf = bvec_kmap_irq(bvec, &flags); @@ -405,6 +406,7 @@ static void ps3disk_prepare_flush(struct request_queue *q, struct request *req) dev_dbg(&dev->sbd.core, "%s:%u\n", __func__, __LINE__); + memset(req->cmd, 0, sizeof(req->cmd)); req->cmd_type = REQ_TYPE_FLUSH; } diff --git a/trunk/drivers/block/ub.c b/trunk/drivers/block/ub.c index e322cce8c12d..27bfe72aab59 100644 --- a/trunk/drivers/block/ub.c +++ b/trunk/drivers/block/ub.c @@ -2399,7 +2399,7 @@ static void ub_disconnect(struct usb_interface *intf) del_gendisk(lun->disk); /* * I wish I could do: - * queue_flag_set(QUEUE_FLAG_DEAD, q); + * set_bit(QUEUE_FLAG_DEAD, &q->queue_flags); * As it is, we rely on our internal poisoning and let * the upper levels to spin furiously failing all the I/O. */ diff --git a/trunk/drivers/block/xen-blkfront.c b/trunk/drivers/block/xen-blkfront.c index f2fff5799ddf..d771da816d95 100644 --- a/trunk/drivers/block/xen-blkfront.c +++ b/trunk/drivers/block/xen-blkfront.c @@ -137,7 +137,7 @@ static void blkif_restart_queue_callback(void *arg) schedule_work(&info->work); } -static int blkif_getgeo(struct block_device *bd, struct hd_geometry *hg) +int blkif_getgeo(struct block_device *bd, struct hd_geometry *hg) { /* We don't have real geometry info, but let's at least return values consistent with the size of the device */ diff --git a/trunk/drivers/cdrom/cdrom.c b/trunk/drivers/cdrom/cdrom.c index 69f26eb6415b..ac3829030ac5 100644 --- a/trunk/drivers/cdrom/cdrom.c +++ b/trunk/drivers/cdrom/cdrom.c @@ -2194,6 +2194,7 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf, if (ret) break; + memset(rq->cmd, 0, sizeof(rq->cmd)); rq->cmd[0] = GPCMD_READ_CD; rq->cmd[1] = 1 << 2; rq->cmd[2] = (lba >> 24) & 0xff; diff --git a/trunk/drivers/cdrom/viocd.c b/trunk/drivers/cdrom/viocd.c index 5245a4a0ba74..b74b6c2768a8 100644 --- a/trunk/drivers/cdrom/viocd.c +++ b/trunk/drivers/cdrom/viocd.c @@ -144,7 +144,6 @@ static int proc_viocd_open(struct inode *inode, struct file *file) } static const struct file_operations proc_viocd_operations = { - .owner = THIS_MODULE, .open = proc_viocd_open, .read = seq_read, .llseek = seq_lseek, @@ -680,6 +679,7 @@ static struct vio_driver viocd_driver = { static int __init viocd_init(void) { + struct proc_dir_entry *e; int ret = 0; if (!firmware_has_feature(FW_FEATURE_ISERIES)) @@ -719,8 +719,12 @@ static int __init viocd_init(void) if (ret) goto out_free_info; - proc_create("iSeries/viocd", S_IFREG|S_IRUGO, NULL, - &proc_viocd_operations); + e = create_proc_entry("iSeries/viocd", S_IFREG|S_IRUGO, NULL); + if (e) { + e->owner = THIS_MODULE; + e->proc_fops = &proc_viocd_operations; + } + return 0; out_free_info: diff --git a/trunk/drivers/char/Kconfig b/trunk/drivers/char/Kconfig index 5dce3877eee5..929d4fa73fd9 100644 --- a/trunk/drivers/char/Kconfig +++ b/trunk/drivers/char/Kconfig @@ -80,15 +80,6 @@ config VT_HW_CONSOLE_BINDING information. For framebuffer console users, please refer to . -config DEVKMEM - bool "/dev/kmem virtual device support" - default y - help - Say Y here if you want to support the /dev/kmem device. The - /dev/kmem device is rarely used, but can be used for certain - kind of kernel debugging operations. - When in doubt, say "N". - config SERIAL_NONSTANDARD bool "Non-standard serial port support" depends on HAS_IOMEM diff --git a/trunk/drivers/char/apm-emulation.c b/trunk/drivers/char/apm-emulation.c index cdd876dbb2b0..17d54315e146 100644 --- a/trunk/drivers/char/apm-emulation.c +++ b/trunk/drivers/char/apm-emulation.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -494,10 +493,11 @@ static struct miscdevice apm_device = { * -1: Unknown * 8) min = minutes; sec = seconds */ -static int proc_apm_show(struct seq_file *m, void *v) +static int apm_get_info(char *buf, char **start, off_t fpos, int length) { struct apm_power_info info; char *units; + int ret; info.ac_line_status = 0xff; info.battery_status = 0xff; @@ -515,27 +515,14 @@ static int proc_apm_show(struct seq_file *m, void *v) case 1: units = "sec"; break; } - seq_printf(m, "%s 1.2 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n", + ret = sprintf(buf, "%s 1.2 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n", driver_version, APM_32_BIT_SUPPORT, info.ac_line_status, info.battery_status, info.battery_flag, info.battery_life, info.time, units); - return 0; -} - -static int proc_apm_open(struct inode *inode, struct file *file) -{ - return single_open(file, proc_apm_show, NULL); + return ret; } - -static const struct file_operations apm_proc_fops = { - .owner = THIS_MODULE, - .open = proc_apm_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; #endif static int kapmd(void *arg) @@ -606,7 +593,7 @@ static int __init apm_init(void) wake_up_process(kapmd_tsk); #ifdef CONFIG_PROC_FS - proc_create("apm", 0, NULL, &apm_proc_fops); + create_proc_info_entry("apm", 0, NULL, apm_get_info); #endif ret = misc_register(&apm_device); diff --git a/trunk/drivers/char/i8k.c b/trunk/drivers/char/i8k.c index f49037b744f9..8609b8236c67 100644 --- a/trunk/drivers/char/i8k.c +++ b/trunk/drivers/char/i8k.c @@ -82,7 +82,6 @@ static int i8k_ioctl(struct inode *, struct file *, unsigned int, unsigned long); static const struct file_operations i8k_fops = { - .owner = THIS_MODULE, .open = i8k_open_fs, .read = seq_read, .llseek = seq_lseek, @@ -555,10 +554,13 @@ static int __init i8k_init(void) return -ENODEV; /* Register the proc entry */ - proc_i8k = proc_create("i8k", 0, NULL, &i8k_fops); + proc_i8k = create_proc_entry("i8k", 0, NULL); if (!proc_i8k) return -ENOENT; + proc_i8k->proc_fops = &i8k_fops; + proc_i8k->owner = THIS_MODULE; + printk(KERN_INFO "Dell laptop SMM driver v%s Massimo Dal Zotto (dz@debian.org)\n", I8K_VERSION); diff --git a/trunk/drivers/char/ip2/ip2main.c b/trunk/drivers/char/ip2/ip2main.c index 0a61856c631f..b1d6cad84282 100644 --- a/trunk/drivers/char/ip2/ip2main.c +++ b/trunk/drivers/char/ip2/ip2main.c @@ -133,9 +133,8 @@ *****************/ #include -#include -static const struct file_operations ip2mem_proc_fops; +static int ip2_read_procmem(char *, char **, off_t, int); static int ip2_read_proc(char *, char **, off_t, int, int *, void * ); /********************/ @@ -424,7 +423,7 @@ cleanup_module(void) } put_tty_driver(ip2_tty_driver); unregister_chrdev(IP2_IPL_MAJOR, pcIpl); - remove_proc_entry("ip2mem", NULL); + remove_proc_entry("ip2mem", &proc_root); // free memory for (i = 0; i < IP2_MAX_BOARDS; i++) { @@ -696,7 +695,7 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize) } } /* Register the read_procmem thing */ - if (!proc_create("ip2mem",0,NULL,&ip2mem_proc_fops)) { + if (!create_proc_info_entry("ip2mem",0,&proc_root,ip2_read_procmem)) { printk(KERN_ERR "IP2: failed to register read_procmem\n"); } else { @@ -2968,61 +2967,65 @@ ip2_ipl_open( struct inode *pInode, struct file *pFile ) } return 0; } +/******************************************************************************/ +/* Function: ip2_read_procmem */ +/* Parameters: */ +/* */ +/* Returns: Length of output */ +/* */ +/* Description: */ +/* Supplies some driver operating parameters */ +/* Not real useful unless your debugging the fifo */ +/* */ +/******************************************************************************/ + +#define LIMIT (PAGE_SIZE - 120) static int -proc_ip2mem_show(struct seq_file *m, void *v) +ip2_read_procmem(char *buf, char **start, off_t offset, int len) { i2eBordStrPtr pB; i2ChanStrPtr pCh; PTTY tty; int i; + len = 0; + #define FMTLINE "%3d: 0x%08x 0x%08x 0%011o 0%011o\n" #define FMTLIN2 " 0x%04x 0x%04x tx flow 0x%x\n" #define FMTLIN3 " 0x%04x 0x%04x rc flow\n" - seq_printf(m,"\n"); + len += sprintf(buf+len,"\n"); for( i = 0; i < IP2_MAX_BOARDS; ++i ) { pB = i2BoardPtrTable[i]; if ( pB ) { - seq_printf(m,"board %d:\n",i); - seq_printf(m,"\tFifo rem: %d mty: %x outM %x\n", + len += sprintf(buf+len,"board %d:\n",i); + len += sprintf(buf+len,"\tFifo rem: %d mty: %x outM %x\n", pB->i2eFifoRemains,pB->i2eWaitingForEmptyFifo,pB->i2eOutMailWaiting); } } - seq_printf(m,"#: tty flags, port flags, cflags, iflags\n"); + len += sprintf(buf+len,"#: tty flags, port flags, cflags, iflags\n"); for (i=0; i < IP2_MAX_PORTS; i++) { + if (len > LIMIT) + break; pCh = DevTable[i]; if (pCh) { tty = pCh->pTTY; if (tty && tty->count) { - seq_printf(m,FMTLINE,i,(int)tty->flags,pCh->flags, + len += sprintf(buf+len,FMTLINE,i,(int)tty->flags,pCh->flags, tty->termios->c_cflag,tty->termios->c_iflag); - seq_printf(m,FMTLIN2, + len += sprintf(buf+len,FMTLIN2, pCh->outfl.asof,pCh->outfl.room,pCh->channelNeeds); - seq_printf(m,FMTLIN3,pCh->infl.asof,pCh->infl.room); + len += sprintf(buf+len,FMTLIN3,pCh->infl.asof,pCh->infl.room); } } } - return 0; -} - -static int proc_ip2mem_open(struct inode *inode, struct file *file) -{ - return single_open(file, proc_ip2mem_show, NULL); + return len; } -static const struct file_operations ip2mem_proc_fops = { - .owner = THIS_MODULE, - .open = proc_ip2mem_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - /* * This is the handler for /proc/tty/driver/ip2 * diff --git a/trunk/drivers/char/ipmi/Makefile b/trunk/drivers/char/ipmi/Makefile index eb8a1a8c188e..553f0a408eda 100644 --- a/trunk/drivers/char/ipmi/Makefile +++ b/trunk/drivers/char/ipmi/Makefile @@ -9,3 +9,7 @@ obj-$(CONFIG_IPMI_DEVICE_INTERFACE) += ipmi_devintf.o obj-$(CONFIG_IPMI_SI) += ipmi_si.o obj-$(CONFIG_IPMI_WATCHDOG) += ipmi_watchdog.o obj-$(CONFIG_IPMI_POWEROFF) += ipmi_poweroff.o + +ipmi_si.o: $(ipmi_si-objs) + $(LD) -r -o $@ $(ipmi_si-objs) + diff --git a/trunk/drivers/char/ipmi/ipmi_bt_sm.c b/trunk/drivers/char/ipmi/ipmi_bt_sm.c index 7b98c067190a..e736119b6497 100644 --- a/trunk/drivers/char/ipmi/ipmi_bt_sm.c +++ b/trunk/drivers/char/ipmi/ipmi_bt_sm.c @@ -37,32 +37,26 @@ #define BT_DEBUG_ENABLE 1 /* Generic messages */ #define BT_DEBUG_MSG 2 /* Prints all request/response buffers */ #define BT_DEBUG_STATES 4 /* Verbose look at state changes */ -/* - * BT_DEBUG_OFF must be zero to correspond to the default uninitialized - * value - */ +/* BT_DEBUG_OFF must be zero to correspond to the default uninitialized + value */ static int bt_debug; /* 0 == BT_DEBUG_OFF */ module_param(bt_debug, int, 0644); MODULE_PARM_DESC(bt_debug, "debug bitmask, 1=enable, 2=messages, 4=states"); -/* - * Typical "Get BT Capabilities" values are 2-3 retries, 5-10 seconds, - * and 64 byte buffers. However, one HP implementation wants 255 bytes of - * buffer (with a documented message of 160 bytes) so go for the max. - * Since the Open IPMI architecture is single-message oriented at this - * stage, the queue depth of BT is of no concern. - */ +/* Typical "Get BT Capabilities" values are 2-3 retries, 5-10 seconds, + and 64 byte buffers. However, one HP implementation wants 255 bytes of + buffer (with a documented message of 160 bytes) so go for the max. + Since the Open IPMI architecture is single-message oriented at this + stage, the queue depth of BT is of no concern. */ #define BT_NORMAL_TIMEOUT 5 /* seconds */ #define BT_NORMAL_RETRY_LIMIT 2 #define BT_RESET_DELAY 6 /* seconds after warm reset */ -/* - * States are written in chronological order and usually cover - * multiple rows of the state table discussion in the IPMI spec. - */ +/* States are written in chronological order and usually cover + multiple rows of the state table discussion in the IPMI spec. */ enum bt_states { BT_STATE_IDLE = 0, /* Order is critical in this list */ @@ -82,12 +76,10 @@ enum bt_states { BT_STATE_LONG_BUSY /* BT doesn't get hosed :-) */ }; -/* - * Macros seen at the end of state "case" blocks. They help with legibility - * and debugging. - */ +/* Macros seen at the end of state "case" blocks. They help with legibility + and debugging. */ -#define BT_STATE_CHANGE(X, Y) { bt->state = X; return Y; } +#define BT_STATE_CHANGE(X,Y) { bt->state = X; return Y; } #define BT_SI_SM_RETURN(Y) { last_printed = BT_STATE_PRINTME; return Y; } @@ -118,13 +110,11 @@ struct si_sm_data { #define BT_H_BUSY 0x40 #define BT_B_BUSY 0x80 -/* - * Some bits are toggled on each write: write once to set it, once - * more to clear it; writing a zero does nothing. To absolutely - * clear it, check its state and write if set. This avoids the "get - * current then use as mask" scheme to modify one bit. Note that the - * variable "bt" is hardcoded into these macros. - */ +/* Some bits are toggled on each write: write once to set it, once + more to clear it; writing a zero does nothing. To absolutely + clear it, check its state and write if set. This avoids the "get + current then use as mask" scheme to modify one bit. Note that the + variable "bt" is hardcoded into these macros. */ #define BT_STATUS bt->io->inputb(bt->io, 0) #define BT_CONTROL(x) bt->io->outputb(bt->io, 0, x) @@ -135,10 +125,8 @@ struct si_sm_data { #define BT_INTMASK_R bt->io->inputb(bt->io, 2) #define BT_INTMASK_W(x) bt->io->outputb(bt->io, 2, x) -/* - * Convenience routines for debugging. These are not multi-open safe! - * Note the macros have hardcoded variables in them. - */ +/* Convenience routines for debugging. These are not multi-open safe! + Note the macros have hardcoded variables in them. */ static char *state2txt(unsigned char state) { @@ -194,8 +182,7 @@ static char *status2txt(unsigned char status) static unsigned int bt_init_data(struct si_sm_data *bt, struct si_sm_io *io) { memset(bt, 0, sizeof(struct si_sm_data)); - if (bt->io != io) { - /* external: one-time only things */ + if (bt->io != io) { /* external: one-time only things */ bt->io = io; bt->seq = 0; } @@ -242,7 +229,7 @@ static int bt_start_transaction(struct si_sm_data *bt, printk(KERN_WARNING "BT: +++++++++++++++++ New command\n"); printk(KERN_WARNING "BT: NetFn/LUN CMD [%d data]:", size - 2); for (i = 0; i < size; i ++) - printk(" %02x", data[i]); + printk (" %02x", data[i]); printk("\n"); } bt->write_data[0] = size + 1; /* all data plus seq byte */ @@ -259,10 +246,8 @@ static int bt_start_transaction(struct si_sm_data *bt, return 0; } -/* - * After the upper state machine has been told SI_SM_TRANSACTION_COMPLETE - * it calls this. Strip out the length and seq bytes. - */ +/* After the upper state machine has been told SI_SM_TRANSACTION_COMPLETE + it calls this. Strip out the length and seq bytes. */ static int bt_get_result(struct si_sm_data *bt, unsigned char *data, @@ -284,10 +269,10 @@ static int bt_get_result(struct si_sm_data *bt, memcpy(data + 2, bt->read_data + 4, msg_len - 2); if (bt_debug & BT_DEBUG_MSG) { - printk(KERN_WARNING "BT: result %d bytes:", msg_len); + printk (KERN_WARNING "BT: result %d bytes:", msg_len); for (i = 0; i < msg_len; i++) printk(" %02x", data[i]); - printk("\n"); + printk ("\n"); } return msg_len; } @@ -307,10 +292,8 @@ static void reset_flags(struct si_sm_data *bt) BT_INTMASK_W(BT_BMC_HWRST); } -/* - * Get rid of an unwanted/stale response. This should only be needed for - * BMCs that support multiple outstanding requests. - */ +/* Get rid of an unwanted/stale response. This should only be needed for + BMCs that support multiple outstanding requests. */ static void drain_BMC2HOST(struct si_sm_data *bt) { @@ -343,8 +326,8 @@ static inline void write_all_bytes(struct si_sm_data *bt) printk(KERN_WARNING "BT: write %d bytes seq=0x%02X", bt->write_count, bt->seq); for (i = 0; i < bt->write_count; i++) - printk(" %02x", bt->write_data[i]); - printk("\n"); + printk (" %02x", bt->write_data[i]); + printk ("\n"); } for (i = 0; i < bt->write_count; i++) HOST2BMC(bt->write_data[i]); @@ -354,10 +337,8 @@ static inline int read_all_bytes(struct si_sm_data *bt) { unsigned char i; - /* - * length is "framing info", minimum = 4: NetFn, Seq, Cmd, cCode. - * Keep layout of first four bytes aligned with write_data[] - */ + /* length is "framing info", minimum = 4: NetFn, Seq, Cmd, cCode. + Keep layout of first four bytes aligned with write_data[] */ bt->read_data[0] = BMC2HOST; bt->read_count = bt->read_data[0]; @@ -381,8 +362,8 @@ static inline int read_all_bytes(struct si_sm_data *bt) if (max > 16) max = 16; for (i = 0; i < max; i++) - printk(KERN_CONT " %02x", bt->read_data[i]); - printk(KERN_CONT "%s\n", bt->read_count == max ? "" : " ..."); + printk (" %02x", bt->read_data[i]); + printk ("%s\n", bt->read_count == max ? "" : " ..."); } /* per the spec, the (NetFn[1], Seq[2], Cmd[3]) tuples must match */ @@ -421,10 +402,8 @@ static enum si_sm_result error_recovery(struct si_sm_data *bt, printk(KERN_WARNING "IPMI BT: %s in %s %s ", /* open-ended line */ reason, STATE2TXT, STATUS2TXT); - /* - * Per the IPMI spec, retries are based on the sequence number - * known only to this module, so manage a restart here. - */ + /* Per the IPMI spec, retries are based on the sequence number + known only to this module, so manage a restart here. */ (bt->error_retries)++; if (bt->error_retries < bt->BT_CAP_retries) { printk("%d retries left\n", @@ -433,8 +412,8 @@ static enum si_sm_result error_recovery(struct si_sm_data *bt, return SI_SM_CALL_WITHOUT_DELAY; } - printk(KERN_WARNING "failed %d retries, sending error response\n", - bt->BT_CAP_retries); + printk("failed %d retries, sending error response\n", + bt->BT_CAP_retries); if (!bt->nonzero_status) printk(KERN_ERR "IPMI BT: stuck, try power cycle\n"); @@ -445,10 +424,8 @@ static enum si_sm_result error_recovery(struct si_sm_data *bt, return SI_SM_CALL_WITHOUT_DELAY; } - /* - * Concoct a useful error message, set up the next state, and - * be done with this sequence. - */ + /* Concoct a useful error message, set up the next state, and + be done with this sequence. */ bt->state = BT_STATE_IDLE; switch (cCode) { @@ -484,12 +461,10 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time) last_printed = bt->state; } - /* - * Commands that time out may still (eventually) provide a response. - * This stale response will get in the way of a new response so remove - * it if possible (hopefully during IDLE). Even if it comes up later - * it will be rejected by its (now-forgotten) seq number. - */ + /* Commands that time out may still (eventually) provide a response. + This stale response will get in the way of a new response so remove + it if possible (hopefully during IDLE). Even if it comes up later + it will be rejected by its (now-forgotten) seq number. */ if ((bt->state < BT_STATE_WRITE_BYTES) && (status & BT_B2H_ATN)) { drain_BMC2HOST(bt); @@ -497,8 +472,7 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time) } if ((bt->state != BT_STATE_IDLE) && - (bt->state < BT_STATE_PRINTME)) { - /* check timeout */ + (bt->state < BT_STATE_PRINTME)) { /* check timeout */ bt->timeout -= time; if ((bt->timeout < 0) && (bt->state < BT_STATE_RESET1)) return error_recovery(bt, @@ -508,10 +482,8 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time) switch (bt->state) { - /* - * Idle state first checks for asynchronous messages from another - * channel, then does some opportunistic housekeeping. - */ + /* Idle state first checks for asynchronous messages from another + channel, then does some opportunistic housekeeping. */ case BT_STATE_IDLE: if (status & BT_SMS_ATN) { @@ -559,19 +531,16 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time) BT_SI_SM_RETURN(SI_SM_CALL_WITH_DELAY); BT_CONTROL(BT_H_BUSY); /* set */ - /* - * Uncached, ordered writes should just proceeed serially but - * some BMCs don't clear B2H_ATN with one hit. Fast-path a - * workaround without too much penalty to the general case. - */ + /* Uncached, ordered writes should just proceeed serially but + some BMCs don't clear B2H_ATN with one hit. Fast-path a + workaround without too much penalty to the general case. */ BT_CONTROL(BT_B2H_ATN); /* clear it to ACK the BMC */ BT_STATE_CHANGE(BT_STATE_CLEAR_B2H, SI_SM_CALL_WITHOUT_DELAY); case BT_STATE_CLEAR_B2H: - if (status & BT_B2H_ATN) { - /* keep hitting it */ + if (status & BT_B2H_ATN) { /* keep hitting it */ BT_CONTROL(BT_B2H_ATN); BT_SI_SM_RETURN(SI_SM_CALL_WITH_DELAY); } @@ -579,8 +548,7 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time) SI_SM_CALL_WITHOUT_DELAY); case BT_STATE_READ_BYTES: - if (!(status & BT_H_BUSY)) - /* check in case of retry */ + if (!(status & BT_H_BUSY)) /* check in case of retry */ BT_CONTROL(BT_H_BUSY); BT_CONTROL(BT_CLR_RD_PTR); /* start of BMC2HOST buffer */ i = read_all_bytes(bt); /* true == packet seq match */ @@ -631,10 +599,8 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time) BT_STATE_CHANGE(BT_STATE_XACTION_START, SI_SM_CALL_WITH_DELAY); - /* - * Get BT Capabilities, using timing of upper level state machine. - * Set outreqs to prevent infinite loop on timeout. - */ + /* Get BT Capabilities, using timing of upper level state machine. + Set outreqs to prevent infinite loop on timeout. */ case BT_STATE_CAPABILITIES_BEGIN: bt->BT_CAP_outreqs = 1; { @@ -672,12 +638,10 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time) static int bt_detect(struct si_sm_data *bt) { - /* - * It's impossible for the BT status and interrupt registers to be - * all 1's, (assuming a properly functioning, self-initialized BMC) - * but that's what you get from reading a bogus address, so we - * test that first. The calling routine uses negative logic. - */ + /* It's impossible for the BT status and interrupt registers to be + all 1's, (assuming a properly functioning, self-initialized BMC) + but that's what you get from reading a bogus address, so we + test that first. The calling routine uses negative logic. */ if ((BT_STATUS == 0xFF) && (BT_INTMASK_R == 0xFF)) return 1; @@ -694,7 +658,8 @@ static int bt_size(void) return sizeof(struct si_sm_data); } -struct si_sm_handlers bt_smi_handlers = { +struct si_sm_handlers bt_smi_handlers = +{ .init_data = bt_init_data, .start_transaction = bt_start_transaction, .get_result = bt_get_result, diff --git a/trunk/drivers/char/ipmi/ipmi_kcs_sm.c b/trunk/drivers/char/ipmi/ipmi_kcs_sm.c index 80704875794c..c1b8228cb7b6 100644 --- a/trunk/drivers/char/ipmi/ipmi_kcs_sm.c +++ b/trunk/drivers/char/ipmi/ipmi_kcs_sm.c @@ -60,58 +60,37 @@ MODULE_PARM_DESC(kcs_debug, "debug bitmask, 1=enable, 2=messages, 4=states"); /* The states the KCS driver may be in. */ enum kcs_states { - /* The KCS interface is currently doing nothing. */ - KCS_IDLE, - - /* - * We are starting an operation. The data is in the output - * buffer, but nothing has been done to the interface yet. This - * was added to the state machine in the spec to wait for the - * initial IBF. - */ - KCS_START_OP, - - /* We have written a write cmd to the interface. */ - KCS_WAIT_WRITE_START, - - /* We are writing bytes to the interface. */ - KCS_WAIT_WRITE, - - /* - * We have written the write end cmd to the interface, and - * still need to write the last byte. - */ - KCS_WAIT_WRITE_END, - - /* We are waiting to read data from the interface. */ - KCS_WAIT_READ, - - /* - * State to transition to the error handler, this was added to - * the state machine in the spec to be sure IBF was there. - */ - KCS_ERROR0, - - /* - * First stage error handler, wait for the interface to - * respond. - */ - KCS_ERROR1, - - /* - * The abort cmd has been written, wait for the interface to - * respond. - */ - KCS_ERROR2, - - /* - * We wrote some data to the interface, wait for it to switch - * to read mode. - */ - KCS_ERROR3, - - /* The hardware failed to follow the state machine. */ - KCS_HOSED + KCS_IDLE, /* The KCS interface is currently + doing nothing. */ + KCS_START_OP, /* We are starting an operation. The + data is in the output buffer, but + nothing has been done to the + interface yet. This was added to + the state machine in the spec to + wait for the initial IBF. */ + KCS_WAIT_WRITE_START, /* We have written a write cmd to the + interface. */ + KCS_WAIT_WRITE, /* We are writing bytes to the + interface. */ + KCS_WAIT_WRITE_END, /* We have written the write end cmd + to the interface, and still need to + write the last byte. */ + KCS_WAIT_READ, /* We are waiting to read data from + the interface. */ + KCS_ERROR0, /* State to transition to the error + handler, this was added to the + state machine in the spec to be + sure IBF was there. */ + KCS_ERROR1, /* First stage error handler, wait for + the interface to respond. */ + KCS_ERROR2, /* The abort cmd has been written, + wait for the interface to + respond. */ + KCS_ERROR3, /* We wrote some data to the + interface, wait for it to switch to + read mode. */ + KCS_HOSED /* The hardware failed to follow the + state machine. */ }; #define MAX_KCS_READ_SIZE IPMI_MAX_MSG_LENGTH @@ -123,7 +102,8 @@ enum kcs_states { #define MAX_ERROR_RETRIES 10 #define ERROR0_OBF_WAIT_JIFFIES (2*HZ) -struct si_sm_data { +struct si_sm_data +{ enum kcs_states state; struct si_sm_io *io; unsigned char write_data[MAX_KCS_WRITE_SIZE]; @@ -207,8 +187,7 @@ static inline void start_error_recovery(struct si_sm_data *kcs, char *reason) (kcs->error_retries)++; if (kcs->error_retries > MAX_ERROR_RETRIES) { if (kcs_debug & KCS_DEBUG_ENABLE) - printk(KERN_DEBUG "ipmi_kcs_sm: kcs hosed: %s\n", - reason); + printk(KERN_DEBUG "ipmi_kcs_sm: kcs hosed: %s\n", reason); kcs->state = KCS_HOSED; } else { kcs->error0_timeout = jiffies + ERROR0_OBF_WAIT_JIFFIES; @@ -292,9 +271,10 @@ static int start_kcs_transaction(struct si_sm_data *kcs, unsigned char *data, if (kcs_debug & KCS_DEBUG_MSG) { printk(KERN_DEBUG "start_kcs_transaction -"); - for (i = 0; i < size; i++) + for (i = 0; i < size; i ++) { printk(" %02x", (unsigned char) (data [i])); - printk("\n"); + } + printk ("\n"); } kcs->error_retries = 0; memcpy(kcs->write_data, data, size); @@ -325,11 +305,9 @@ static int get_kcs_result(struct si_sm_data *kcs, unsigned char *data, kcs->read_pos = 3; } if (kcs->truncated) { - /* - * Report a truncated error. We might overwrite - * another error, but that's too bad, the user needs - * to know it was truncated. - */ + /* Report a truncated error. We might overwrite + another error, but that's too bad, the user needs + to know it was truncated. */ data[2] = IPMI_ERR_MSG_TRUNCATED; kcs->truncated = 0; } @@ -337,11 +315,9 @@ static int get_kcs_result(struct si_sm_data *kcs, unsigned char *data, return kcs->read_pos; } -/* - * This implements the state machine defined in the IPMI manual, see - * that for details on how this works. Divide that flowchart into - * sections delimited by "Wait for IBF" and this will become clear. - */ +/* This implements the state machine defined in the IPMI manual, see + that for details on how this works. Divide that flowchart into + sections delimited by "Wait for IBF" and this will become clear. */ static enum si_sm_result kcs_event(struct si_sm_data *kcs, long time) { unsigned char status; @@ -412,12 +388,11 @@ static enum si_sm_result kcs_event(struct si_sm_data *kcs, long time) write_next_byte(kcs); } break; - + case KCS_WAIT_WRITE_END: if (state != KCS_WRITE_STATE) { start_error_recovery(kcs, - "Not in write state" - " for write end"); + "Not in write state for write end"); break; } clear_obf(kcs, status); @@ -438,15 +413,13 @@ static enum si_sm_result kcs_event(struct si_sm_data *kcs, long time) return SI_SM_CALL_WITH_DELAY; read_next_byte(kcs); } else { - /* - * We don't implement this exactly like the state - * machine in the spec. Some broken hardware - * does not write the final dummy byte to the - * read register. Thus obf will never go high - * here. We just go straight to idle, and we - * handle clearing out obf in idle state if it - * happens to come in. - */ + /* We don't implement this exactly like the state + machine in the spec. Some broken hardware + does not write the final dummy byte to the + read register. Thus obf will never go high + here. We just go straight to idle, and we + handle clearing out obf in idle state if it + happens to come in. */ clear_obf(kcs, status); kcs->orig_write_count = 0; kcs->state = KCS_IDLE; @@ -457,8 +430,7 @@ static enum si_sm_result kcs_event(struct si_sm_data *kcs, long time) case KCS_ERROR0: clear_obf(kcs, status); status = read_status(kcs); - if (GET_STATUS_OBF(status)) - /* controller isn't responding */ + if (GET_STATUS_OBF(status)) /* controller isn't responding */ if (time_before(jiffies, kcs->error0_timeout)) return SI_SM_CALL_WITH_TICK_DELAY; write_cmd(kcs, KCS_GET_STATUS_ABORT); @@ -470,7 +442,7 @@ static enum si_sm_result kcs_event(struct si_sm_data *kcs, long time) write_data(kcs, 0); kcs->state = KCS_ERROR2; break; - + case KCS_ERROR2: if (state != KCS_READ_STATE) { start_error_recovery(kcs, @@ -484,7 +456,7 @@ static enum si_sm_result kcs_event(struct si_sm_data *kcs, long time) write_data(kcs, KCS_READ_BYTE); kcs->state = KCS_ERROR3; break; - + case KCS_ERROR3: if (state != KCS_IDLE_STATE) { start_error_recovery(kcs, @@ -503,7 +475,7 @@ static enum si_sm_result kcs_event(struct si_sm_data *kcs, long time) return SI_SM_TRANSACTION_COMPLETE; } break; - + case KCS_HOSED: break; } @@ -523,12 +495,10 @@ static int kcs_size(void) static int kcs_detect(struct si_sm_data *kcs) { - /* - * It's impossible for the KCS status register to be all 1's, - * (assuming a properly functioning, self-initialized BMC) - * but that's what you get from reading a bogus address, so we - * test that first. - */ + /* It's impossible for the KCS status register to be all 1's, + (assuming a properly functioning, self-initialized BMC) + but that's what you get from reading a bogus address, so we + test that first. */ if (read_status(kcs) == 0xff) return 1; @@ -539,7 +509,8 @@ static void kcs_cleanup(struct si_sm_data *kcs) { } -struct si_sm_handlers kcs_smi_handlers = { +struct si_sm_handlers kcs_smi_handlers = +{ .init_data = init_kcs_data, .start_transaction = start_kcs_transaction, .get_result = get_kcs_result, diff --git a/trunk/drivers/char/ipmi/ipmi_msghandler.c b/trunk/drivers/char/ipmi/ipmi_msghandler.c index 8a59aaa21be5..32b2b22996dc 100644 --- a/trunk/drivers/char/ipmi/ipmi_msghandler.c +++ b/trunk/drivers/char/ipmi/ipmi_msghandler.c @@ -47,7 +47,7 @@ #define PFX "IPMI message handler: " -#define IPMI_DRIVER_VERSION "39.2" +#define IPMI_DRIVER_VERSION "39.1" static struct ipmi_recv_msg *ipmi_alloc_recv_msg(void); static int ipmi_init_msghandler(void); @@ -63,16 +63,16 @@ static struct proc_dir_entry *proc_ipmi_root; #define MAX_EVENTS_IN_QUEUE 25 -/* - * Don't let a message sit in a queue forever, always time it with at lest - * the max message timer. This is in milliseconds. - */ +/* Don't let a message sit in a queue forever, always time it with at lest + the max message timer. This is in milliseconds. */ #define MAX_MSG_TIMEOUT 60000 + /* * The main "user" data structure. */ -struct ipmi_user { +struct ipmi_user +{ struct list_head link; /* Set to "0" when the user is destroyed. */ @@ -91,7 +91,8 @@ struct ipmi_user { int gets_events; }; -struct cmd_rcvr { +struct cmd_rcvr +{ struct list_head link; ipmi_user_t user; @@ -105,12 +106,12 @@ struct cmd_rcvr { * or change any data until the RCU period completes. So we * use this next variable during mass deletion so we can have * a list and don't have to wait and restart the search on - * every individual deletion of a command. - */ + * every individual deletion of a command. */ struct cmd_rcvr *next; }; -struct seq_table { +struct seq_table +{ unsigned int inuse : 1; unsigned int broadcast : 1; @@ -118,60 +119,53 @@ struct seq_table { unsigned long orig_timeout; unsigned int retries_left; - /* - * To verify on an incoming send message response that this is - * the message that the response is for, we keep a sequence id - * and increment it every time we send a message. - */ + /* To verify on an incoming send message response that this is + the message that the response is for, we keep a sequence id + and increment it every time we send a message. */ long seqid; - /* - * This is held so we can properly respond to the message on a - * timeout, and it is used to hold the temporary data for - * retransmission, too. - */ + /* This is held so we can properly respond to the message on a + timeout, and it is used to hold the temporary data for + retransmission, too. */ struct ipmi_recv_msg *recv_msg; }; -/* - * Store the information in a msgid (long) to allow us to find a - * sequence table entry from the msgid. - */ +/* Store the information in a msgid (long) to allow us to find a + sequence table entry from the msgid. */ #define STORE_SEQ_IN_MSGID(seq, seqid) (((seq&0xff)<<26) | (seqid&0x3ffffff)) #define GET_SEQ_FROM_MSGID(msgid, seq, seqid) \ do { \ seq = ((msgid >> 26) & 0x3f); \ seqid = (msgid & 0x3fffff); \ - } while (0) + } while (0) #define NEXT_SEQID(seqid) (((seqid) + 1) & 0x3fffff) -struct ipmi_channel { +struct ipmi_channel +{ unsigned char medium; unsigned char protocol; - /* - * My slave address. This is initialized to IPMI_BMC_SLAVE_ADDR, - * but may be changed by the user. - */ + /* My slave address. This is initialized to IPMI_BMC_SLAVE_ADDR, + but may be changed by the user. */ unsigned char address; - /* - * My LUN. This should generally stay the SMS LUN, but just in - * case... - */ + /* My LUN. This should generally stay the SMS LUN, but just in + case... */ unsigned char lun; }; #ifdef CONFIG_PROC_FS -struct ipmi_proc_entry { +struct ipmi_proc_entry +{ char *name; struct ipmi_proc_entry *next; }; #endif -struct bmc_device { +struct bmc_device +{ struct platform_device *dev; struct ipmi_device_id id; unsigned char guid[16]; @@ -192,108 +186,10 @@ struct bmc_device { struct device_attribute aux_firmware_rev_attr; }; -/* - * Various statistics for IPMI, these index stats[] in the ipmi_smi - * structure. - */ -enum ipmi_stat_indexes { - /* Commands we got from the user that were invalid. */ - IPMI_STAT_sent_invalid_commands = 0, - - /* Commands we sent to the MC. */ - IPMI_STAT_sent_local_commands, - - /* Responses from the MC that were delivered to a user. */ - IPMI_STAT_handled_local_responses, - - /* Responses from the MC that were not delivered to a user. */ - IPMI_STAT_unhandled_local_responses, - - /* Commands we sent out to the IPMB bus. */ - IPMI_STAT_sent_ipmb_commands, - - /* Commands sent on the IPMB that had errors on the SEND CMD */ - IPMI_STAT_sent_ipmb_command_errs, - - /* Each retransmit increments this count. */ - IPMI_STAT_retransmitted_ipmb_commands, - - /* - * When a message times out (runs out of retransmits) this is - * incremented. - */ - IPMI_STAT_timed_out_ipmb_commands, - - /* - * This is like above, but for broadcasts. Broadcasts are - * *not* included in the above count (they are expected to - * time out). - */ - IPMI_STAT_timed_out_ipmb_broadcasts, - - /* Responses I have sent to the IPMB bus. */ - IPMI_STAT_sent_ipmb_responses, - - /* The response was delivered to the user. */ - IPMI_STAT_handled_ipmb_responses, - - /* The response had invalid data in it. */ - IPMI_STAT_invalid_ipmb_responses, - - /* The response didn't have anyone waiting for it. */ - IPMI_STAT_unhandled_ipmb_responses, - - /* Commands we sent out to the IPMB bus. */ - IPMI_STAT_sent_lan_commands, - - /* Commands sent on the IPMB that had errors on the SEND CMD */ - IPMI_STAT_sent_lan_command_errs, - - /* Each retransmit increments this count. */ - IPMI_STAT_retransmitted_lan_commands, - - /* - * When a message times out (runs out of retransmits) this is - * incremented. - */ - IPMI_STAT_timed_out_lan_commands, - - /* Responses I have sent to the IPMB bus. */ - IPMI_STAT_sent_lan_responses, - - /* The response was delivered to the user. */ - IPMI_STAT_handled_lan_responses, - - /* The response had invalid data in it. */ - IPMI_STAT_invalid_lan_responses, - - /* The response didn't have anyone waiting for it. */ - IPMI_STAT_unhandled_lan_responses, - - /* The command was delivered to the user. */ - IPMI_STAT_handled_commands, - - /* The command had invalid data in it. */ - IPMI_STAT_invalid_commands, - - /* The command didn't have anyone waiting for it. */ - IPMI_STAT_unhandled_commands, - - /* Invalid data in an event. */ - IPMI_STAT_invalid_events, - - /* Events that were received with the proper format. */ - IPMI_STAT_events, - - - /* This *must* remain last, add new values above this. */ - IPMI_NUM_STATS -}; - - #define IPMI_IPMB_NUM_SEQ 64 #define IPMI_MAX_CHANNELS 16 -struct ipmi_smi { +struct ipmi_smi +{ /* What interface number are we? */ int intf_num; @@ -302,10 +198,8 @@ struct ipmi_smi { /* Used for a list of interfaces. */ struct list_head link; - /* - * The list of upper layers that are using me. seq_lock - * protects this. - */ + /* The list of upper layers that are using me. seq_lock + * protects this. */ struct list_head users; /* Information to supply to users. */ @@ -319,12 +213,10 @@ struct ipmi_smi { char *my_dev_name; char *sysfs_name; - /* - * This is the lower-layer's sender routine. Note that you + /* This is the lower-layer's sender routine. Note that you * must either be holding the ipmi_interfaces_mutex or be in * an umpreemptible region to use this. You must fetch the - * value into a local variable and make sure it is not NULL. - */ + * value into a local variable and make sure it is not NULL. */ struct ipmi_smi_handlers *handlers; void *send_info; @@ -337,45 +229,34 @@ struct ipmi_smi { /* Driver-model device for the system interface. */ struct device *si_dev; - /* - * A table of sequence numbers for this interface. We use the - * sequence numbers for IPMB messages that go out of the - * interface to match them up with their responses. A routine - * is called periodically to time the items in this list. - */ + /* A table of sequence numbers for this interface. We use the + sequence numbers for IPMB messages that go out of the + interface to match them up with their responses. A routine + is called periodically to time the items in this list. */ spinlock_t seq_lock; struct seq_table seq_table[IPMI_IPMB_NUM_SEQ]; int curr_seq; - /* - * Messages that were delayed for some reason (out of memory, - * for instance), will go in here to be processed later in a - * periodic timer interrupt. - */ + /* Messages that were delayed for some reason (out of memory, + for instance), will go in here to be processed later in a + periodic timer interrupt. */ spinlock_t waiting_msgs_lock; struct list_head waiting_msgs; - /* - * The list of command receivers that are registered for commands - * on this interface. - */ + /* The list of command receivers that are registered for commands + on this interface. */ struct mutex cmd_rcvrs_mutex; struct list_head cmd_rcvrs; - /* - * Events that were queues because no one was there to receive - * them. - */ + /* Events that were queues because no one was there to receive + them. */ spinlock_t events_lock; /* For dealing with event stuff. */ struct list_head waiting_events; unsigned int waiting_events_count; /* How many events in queue? */ - char delivering_events; - char event_msg_printed; + int delivering_events; - /* - * The event receiver for my BMC, only really used at panic - * shutdown as a place to store this. - */ + /* The event receiver for my BMC, only really used at panic + shutdown as a place to store this. */ unsigned char event_receiver; unsigned char event_receiver_lun; unsigned char local_sel_device; @@ -387,18 +268,14 @@ struct ipmi_smi { int auto_maintenance_timeout; spinlock_t maintenance_mode_lock; /* Used in a timer... */ - /* - * A cheap hack, if this is non-null and a message to an - * interface comes in with a NULL user, call this routine with - * it. Note that the message will still be freed by the - * caller. This only works on the system interface. - */ + /* A cheap hack, if this is non-null and a message to an + interface comes in with a NULL user, call this routine with + it. Note that the message will still be freed by the + caller. This only works on the system interface. */ void (*null_user_handler)(ipmi_smi_t intf, struct ipmi_recv_msg *msg); - /* - * When we are scanning the channels for an SMI, this will - * tell which channel we are scanning. - */ + /* When we are scanning the channels for an SMI, this will + tell which channel we are scanning. */ int curr_channel; /* Channel information */ @@ -408,14 +285,74 @@ struct ipmi_smi { struct proc_dir_entry *proc_dir; char proc_dir_name[10]; - atomic_t stats[IPMI_NUM_STATS]; + spinlock_t counter_lock; /* For making counters atomic. */ - /* - * run_to_completion duplicate of smb_info, smi_info - * and ipmi_serial_info structures. Used to decrease numbers of - * parameters passed by "low" level IPMI code. - */ - int run_to_completion; + /* Commands we got that were invalid. */ + unsigned int sent_invalid_commands; + + /* Commands we sent to the MC. */ + unsigned int sent_local_commands; + /* Responses from the MC that were delivered to a user. */ + unsigned int handled_local_responses; + /* Responses from the MC that were not delivered to a user. */ + unsigned int unhandled_local_responses; + + /* Commands we sent out to the IPMB bus. */ + unsigned int sent_ipmb_commands; + /* Commands sent on the IPMB that had errors on the SEND CMD */ + unsigned int sent_ipmb_command_errs; + /* Each retransmit increments this count. */ + unsigned int retransmitted_ipmb_commands; + /* When a message times out (runs out of retransmits) this is + incremented. */ + unsigned int timed_out_ipmb_commands; + + /* This is like above, but for broadcasts. Broadcasts are + *not* included in the above count (they are expected to + time out). */ + unsigned int timed_out_ipmb_broadcasts; + + /* Responses I have sent to the IPMB bus. */ + unsigned int sent_ipmb_responses; + + /* The response was delivered to the user. */ + unsigned int handled_ipmb_responses; + /* The response had invalid data in it. */ + unsigned int invalid_ipmb_responses; + /* The response didn't have anyone waiting for it. */ + unsigned int unhandled_ipmb_responses; + + /* Commands we sent out to the IPMB bus. */ + unsigned int sent_lan_commands; + /* Commands sent on the IPMB that had errors on the SEND CMD */ + unsigned int sent_lan_command_errs; + /* Each retransmit increments this count. */ + unsigned int retransmitted_lan_commands; + /* When a message times out (runs out of retransmits) this is + incremented. */ + unsigned int timed_out_lan_commands; + + /* Responses I have sent to the IPMB bus. */ + unsigned int sent_lan_responses; + + /* The response was delivered to the user. */ + unsigned int handled_lan_responses; + /* The response had invalid data in it. */ + unsigned int invalid_lan_responses; + /* The response didn't have anyone waiting for it. */ + unsigned int unhandled_lan_responses; + + /* The command was delivered to the user. */ + unsigned int handled_commands; + /* The command had invalid data in it. */ + unsigned int invalid_commands; + /* The command didn't have anyone waiting for it. */ + unsigned int unhandled_commands; + + /* Invalid data in an event. */ + unsigned int invalid_events; + /* Events that were received with the proper format. */ + unsigned int events; }; #define to_si_intf_from_dev(device) container_of(device, struct ipmi_smi, dev) @@ -431,19 +368,12 @@ static DEFINE_MUTEX(ipmidriver_mutex); static LIST_HEAD(ipmi_interfaces); static DEFINE_MUTEX(ipmi_interfaces_mutex); -/* - * List of watchers that want to know when smi's are added and deleted. - */ +/* List of watchers that want to know when smi's are added and + deleted. */ static LIST_HEAD(smi_watchers); static DEFINE_MUTEX(smi_watchers_mutex); -#define ipmi_inc_stat(intf, stat) \ - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat]) -#define ipmi_get_stat(intf, stat) \ - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat])) - - static void free_recv_msg_list(struct list_head *q) { struct ipmi_recv_msg *msg, *msg2; @@ -487,8 +417,10 @@ static void clean_up_interface_data(ipmi_smi_t intf) for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++) { if ((intf->seq_table[i].inuse) - && (intf->seq_table[i].recv_msg)) + && (intf->seq_table[i].recv_msg)) + { ipmi_free_recv_msg(intf->seq_table[i].recv_msg); + } } } @@ -555,7 +487,6 @@ int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher) } return -ENOMEM; } -EXPORT_SYMBOL(ipmi_smi_watcher_register); int ipmi_smi_watcher_unregister(struct ipmi_smi_watcher *watcher) { @@ -564,7 +495,6 @@ int ipmi_smi_watcher_unregister(struct ipmi_smi_watcher *watcher) mutex_unlock(&smi_watchers_mutex); return 0; } -EXPORT_SYMBOL(ipmi_smi_watcher_unregister); /* * Must be called with smi_watchers_mutex held. @@ -600,7 +530,8 @@ ipmi_addr_equal(struct ipmi_addr *addr1, struct ipmi_addr *addr2) } if ((addr1->addr_type == IPMI_IPMB_ADDR_TYPE) - || (addr1->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) { + || (addr1->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) + { struct ipmi_ipmb_addr *ipmb_addr1 = (struct ipmi_ipmb_addr *) addr1; struct ipmi_ipmb_addr *ipmb_addr2 @@ -628,8 +559,9 @@ ipmi_addr_equal(struct ipmi_addr *addr1, struct ipmi_addr *addr2) int ipmi_validate_addr(struct ipmi_addr *addr, int len) { - if (len < sizeof(struct ipmi_system_interface_addr)) + if (len < sizeof(struct ipmi_system_interface_addr)) { return -EINVAL; + } if (addr->addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE) { if (addr->channel != IPMI_BMC_CHANNEL) @@ -643,21 +575,23 @@ int ipmi_validate_addr(struct ipmi_addr *addr, int len) return -EINVAL; if ((addr->addr_type == IPMI_IPMB_ADDR_TYPE) - || (addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) { - if (len < sizeof(struct ipmi_ipmb_addr)) + || (addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) + { + if (len < sizeof(struct ipmi_ipmb_addr)) { return -EINVAL; + } return 0; } if (addr->addr_type == IPMI_LAN_ADDR_TYPE) { - if (len < sizeof(struct ipmi_lan_addr)) + if (len < sizeof(struct ipmi_lan_addr)) { return -EINVAL; + } return 0; } return -EINVAL; } -EXPORT_SYMBOL(ipmi_validate_addr); unsigned int ipmi_addr_length(int addr_type) { @@ -665,28 +599,34 @@ unsigned int ipmi_addr_length(int addr_type) return sizeof(struct ipmi_system_interface_addr); if ((addr_type == IPMI_IPMB_ADDR_TYPE) - || (addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) + || (addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) + { return sizeof(struct ipmi_ipmb_addr); + } if (addr_type == IPMI_LAN_ADDR_TYPE) return sizeof(struct ipmi_lan_addr); return 0; } -EXPORT_SYMBOL(ipmi_addr_length); static void deliver_response(struct ipmi_recv_msg *msg) { if (!msg->user) { ipmi_smi_t intf = msg->user_msg_data; + unsigned long flags; /* Special handling for NULL users. */ if (intf->null_user_handler) { intf->null_user_handler(intf, msg); - ipmi_inc_stat(intf, handled_local_responses); + spin_lock_irqsave(&intf->counter_lock, flags); + intf->handled_local_responses++; + spin_unlock_irqrestore(&intf->counter_lock, flags); } else { /* No handler, so give up. */ - ipmi_inc_stat(intf, unhandled_local_responses); + spin_lock_irqsave(&intf->counter_lock, flags); + intf->unhandled_local_responses++; + spin_unlock_irqrestore(&intf->counter_lock, flags); } ipmi_free_recv_msg(msg); } else { @@ -706,11 +646,9 @@ deliver_err_response(struct ipmi_recv_msg *msg, int err) deliver_response(msg); } -/* - * Find the next sequence number not being used and add the given - * message with the given timeout to the sequence table. This must be - * called with the interface's seq_lock held. - */ +/* Find the next sequence number not being used and add the given + message with the given timeout to the sequence table. This must be + called with the interface's seq_lock held. */ static int intf_next_seq(ipmi_smi_t intf, struct ipmi_recv_msg *recv_msg, unsigned long timeout, @@ -722,8 +660,10 @@ static int intf_next_seq(ipmi_smi_t intf, int rv = 0; unsigned int i; - for (i = intf->curr_seq; (i+1)%IPMI_IPMB_NUM_SEQ != intf->curr_seq; - i = (i+1)%IPMI_IPMB_NUM_SEQ) { + for (i = intf->curr_seq; + (i+1)%IPMI_IPMB_NUM_SEQ != intf->curr_seq; + i = (i+1)%IPMI_IPMB_NUM_SEQ) + { if (!intf->seq_table[i].inuse) break; } @@ -731,10 +671,8 @@ static int intf_next_seq(ipmi_smi_t intf, if (!intf->seq_table[i].inuse) { intf->seq_table[i].recv_msg = recv_msg; - /* - * Start with the maximum timeout, when the send response - * comes in we will start the real timer. - */ + /* Start with the maximum timeout, when the send response + comes in we will start the real timer. */ intf->seq_table[i].timeout = MAX_MSG_TIMEOUT; intf->seq_table[i].orig_timeout = timeout; intf->seq_table[i].retries_left = retries; @@ -747,17 +685,15 @@ static int intf_next_seq(ipmi_smi_t intf, } else { rv = -EAGAIN; } - + return rv; } -/* - * Return the receive message for the given sequence number and - * release the sequence number so it can be reused. Some other data - * is passed in to be sure the message matches up correctly (to help - * guard against message coming in after their timeout and the - * sequence number being reused). - */ +/* Return the receive message for the given sequence number and + release the sequence number so it can be reused. Some other data + is passed in to be sure the message matches up correctly (to help + guard against message coming in after their timeout and the + sequence number being reused). */ static int intf_find_seq(ipmi_smi_t intf, unsigned char seq, short channel, @@ -776,9 +712,11 @@ static int intf_find_seq(ipmi_smi_t intf, if (intf->seq_table[seq].inuse) { struct ipmi_recv_msg *msg = intf->seq_table[seq].recv_msg; - if ((msg->addr.channel == channel) && (msg->msg.cmd == cmd) - && (msg->msg.netfn == netfn) - && (ipmi_addr_equal(addr, &(msg->addr)))) { + if ((msg->addr.channel == channel) + && (msg->msg.cmd == cmd) + && (msg->msg.netfn == netfn) + && (ipmi_addr_equal(addr, &(msg->addr)))) + { *recv_msg = msg; intf->seq_table[seq].inuse = 0; rv = 0; @@ -803,12 +741,11 @@ static int intf_start_seq_timer(ipmi_smi_t intf, GET_SEQ_FROM_MSGID(msgid, seq, seqid); spin_lock_irqsave(&(intf->seq_lock), flags); - /* - * We do this verification because the user can be deleted - * while a message is outstanding. - */ + /* We do this verification because the user can be deleted + while a message is outstanding. */ if ((intf->seq_table[seq].inuse) - && (intf->seq_table[seq].seqid == seqid)) { + && (intf->seq_table[seq].seqid == seqid)) + { struct seq_table *ent = &(intf->seq_table[seq]); ent->timeout = ent->orig_timeout; rv = 0; @@ -833,12 +770,11 @@ static int intf_err_seq(ipmi_smi_t intf, GET_SEQ_FROM_MSGID(msgid, seq, seqid); spin_lock_irqsave(&(intf->seq_lock), flags); - /* - * We do this verification because the user can be deleted - * while a message is outstanding. - */ + /* We do this verification because the user can be deleted + while a message is outstanding. */ if ((intf->seq_table[seq].inuse) - && (intf->seq_table[seq].seqid == seqid)) { + && (intf->seq_table[seq].seqid == seqid)) + { struct seq_table *ent = &(intf->seq_table[seq]); ent->inuse = 0; @@ -864,30 +800,24 @@ int ipmi_create_user(unsigned int if_num, int rv = 0; ipmi_smi_t intf; - /* - * There is no module usecount here, because it's not - * required. Since this can only be used by and called from - * other modules, they will implicitly use this module, and - * thus this can't be removed unless the other modules are - * removed. - */ + /* There is no module usecount here, because it's not + required. Since this can only be used by and called from + other modules, they will implicitly use this module, and + thus this can't be removed unless the other modules are + removed. */ if (handler == NULL) return -EINVAL; - /* - * Make sure the driver is actually initialized, this handles - * problems with initialization order. - */ + /* Make sure the driver is actually initialized, this handles + problems with initialization order. */ if (!initialized) { rv = ipmi_init_msghandler(); if (rv) return rv; - /* - * The init code doesn't return an error if it was turned - * off, but it won't initialize. Check that. - */ + /* The init code doesn't return an error if it was turned + off, but it won't initialize. Check that. */ if (!initialized) return -ENODEV; } @@ -928,10 +858,8 @@ int ipmi_create_user(unsigned int if_num, } } - /* - * Hold the lock so intf->handlers is guaranteed to be good - * until now - */ + /* Hold the lock so intf->handlers is guaranteed to be good + * until now */ mutex_unlock(&ipmi_interfaces_mutex); new_user->valid = 1; @@ -948,7 +876,6 @@ int ipmi_create_user(unsigned int if_num, kfree(new_user); return rv; } -EXPORT_SYMBOL(ipmi_create_user); static void free_user(struct kref *ref) { @@ -972,7 +899,8 @@ int ipmi_destroy_user(ipmi_user_t user) for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++) { if (intf->seq_table[i].inuse - && (intf->seq_table[i].recv_msg->user == user)) { + && (intf->seq_table[i].recv_msg->user == user)) + { intf->seq_table[i].inuse = 0; ipmi_free_recv_msg(intf->seq_table[i].recv_msg); } @@ -1015,7 +943,6 @@ int ipmi_destroy_user(ipmi_user_t user) return 0; } -EXPORT_SYMBOL(ipmi_destroy_user); void ipmi_get_version(ipmi_user_t user, unsigned char *major, @@ -1024,7 +951,6 @@ void ipmi_get_version(ipmi_user_t user, *major = user->intf->ipmi_version_major; *minor = user->intf->ipmi_version_minor; } -EXPORT_SYMBOL(ipmi_get_version); int ipmi_set_my_address(ipmi_user_t user, unsigned int channel, @@ -1035,7 +961,6 @@ int ipmi_set_my_address(ipmi_user_t user, user->intf->channels[channel].address = address; return 0; } -EXPORT_SYMBOL(ipmi_set_my_address); int ipmi_get_my_address(ipmi_user_t user, unsigned int channel, @@ -1046,7 +971,6 @@ int ipmi_get_my_address(ipmi_user_t user, *address = user->intf->channels[channel].address; return 0; } -EXPORT_SYMBOL(ipmi_get_my_address); int ipmi_set_my_LUN(ipmi_user_t user, unsigned int channel, @@ -1057,7 +981,6 @@ int ipmi_set_my_LUN(ipmi_user_t user, user->intf->channels[channel].lun = LUN & 0x3; return 0; } -EXPORT_SYMBOL(ipmi_set_my_LUN); int ipmi_get_my_LUN(ipmi_user_t user, unsigned int channel, @@ -1068,7 +991,6 @@ int ipmi_get_my_LUN(ipmi_user_t user, *address = user->intf->channels[channel].lun; return 0; } -EXPORT_SYMBOL(ipmi_get_my_LUN); int ipmi_get_maintenance_mode(ipmi_user_t user) { @@ -1153,11 +1075,6 @@ int ipmi_set_gets_events(ipmi_user_t user, int val) list_for_each_entry_safe(msg, msg2, &intf->waiting_events, link) list_move_tail(&msg->link, &msgs); intf->waiting_events_count = 0; - if (intf->event_msg_printed) { - printk(KERN_WARNING PFX "Event queue no longer" - " full\n"); - intf->event_msg_printed = 0; - } intf->delivering_events = 1; spin_unlock_irqrestore(&intf->events_lock, flags); @@ -1177,7 +1094,6 @@ int ipmi_set_gets_events(ipmi_user_t user, int val) return 0; } -EXPORT_SYMBOL(ipmi_set_gets_events); static struct cmd_rcvr *find_cmd_rcvr(ipmi_smi_t intf, unsigned char netfn, @@ -1243,7 +1159,6 @@ int ipmi_register_for_cmd(ipmi_user_t user, return rv; } -EXPORT_SYMBOL(ipmi_register_for_cmd); int ipmi_unregister_for_cmd(ipmi_user_t user, unsigned char netfn, @@ -1281,13 +1196,19 @@ int ipmi_unregister_for_cmd(ipmi_user_t user, } return rv; } -EXPORT_SYMBOL(ipmi_unregister_for_cmd); + +void ipmi_user_set_run_to_completion(ipmi_user_t user, int val) +{ + ipmi_smi_t intf = user->intf; + if (intf->handlers) + intf->handlers->set_run_to_completion(intf->send_info, val); +} static unsigned char ipmb_checksum(unsigned char *data, int size) { unsigned char csum = 0; - + for (; size > 0; size--, data++) csum += *data; @@ -1329,10 +1250,8 @@ static inline void format_ipmb_msg(struct ipmi_smi_msg *smi_msg, = ipmb_checksum(&(smi_msg->data[i+6]), smi_msg->data_size-6); - /* - * Add on the checksum size and the offset from the - * broadcast. - */ + /* Add on the checksum size and the offset from the + broadcast. */ smi_msg->data_size += 1 + i; smi_msg->msgid = msgid; @@ -1368,21 +1287,17 @@ static inline void format_lan_msg(struct ipmi_smi_msg *smi_msg, = ipmb_checksum(&(smi_msg->data[7]), smi_msg->data_size-7); - /* - * Add on the checksum size and the offset from the - * broadcast. - */ + /* Add on the checksum size and the offset from the + broadcast. */ smi_msg->data_size += 1; smi_msg->msgid = msgid; } -/* - * Separate from ipmi_request so that the user does not have to be - * supplied in certain circumstances (mainly at panic time). If - * messages are supplied, they will be freed, even if an error - * occurs. - */ +/* Separate from ipmi_request so that the user does not have to be + supplied in certain circumstances (mainly at panic time). If + messages are supplied, they will be freed, even if an error + occurs. */ static int i_ipmi_request(ipmi_user_t user, ipmi_smi_t intf, struct ipmi_addr *addr, @@ -1404,18 +1319,19 @@ static int i_ipmi_request(ipmi_user_t user, struct ipmi_smi_handlers *handlers; - if (supplied_recv) + if (supplied_recv) { recv_msg = supplied_recv; - else { + } else { recv_msg = ipmi_alloc_recv_msg(); - if (recv_msg == NULL) + if (recv_msg == NULL) { return -ENOMEM; + } } recv_msg->user_msg_data = user_msg_data; - if (supplied_smi) + if (supplied_smi) { smi_msg = (struct ipmi_smi_msg *) supplied_smi; - else { + } else { smi_msg = ipmi_alloc_smi_msg(); if (smi_msg == NULL) { ipmi_free_recv_msg(recv_msg); @@ -1434,10 +1350,8 @@ static int i_ipmi_request(ipmi_user_t user, if (user) kref_get(&user->refcount); recv_msg->msgid = msgid; - /* - * Store the message to send in the receive message so timeout - * responses can get the proper response data. - */ + /* Store the message to send in the receive message so timeout + responses can get the proper response data. */ recv_msg->msg = *msg; if (addr->addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE) { @@ -1451,7 +1365,9 @@ static int i_ipmi_request(ipmi_user_t user, smi_addr = (struct ipmi_system_interface_addr *) addr; if (smi_addr->lun > 3) { - ipmi_inc_stat(intf, sent_invalid_commands); + spin_lock_irqsave(&intf->counter_lock, flags); + intf->sent_invalid_commands++; + spin_unlock_irqrestore(&intf->counter_lock, flags); rv = -EINVAL; goto out_err; } @@ -1461,12 +1377,13 @@ static int i_ipmi_request(ipmi_user_t user, if ((msg->netfn == IPMI_NETFN_APP_REQUEST) && ((msg->cmd == IPMI_SEND_MSG_CMD) || (msg->cmd == IPMI_GET_MSG_CMD) - || (msg->cmd == IPMI_READ_EVENT_MSG_BUFFER_CMD))) { - /* - * We don't let the user do these, since we manage - * the sequence numbers. - */ - ipmi_inc_stat(intf, sent_invalid_commands); + || (msg->cmd == IPMI_READ_EVENT_MSG_BUFFER_CMD))) + { + /* We don't let the user do these, since we manage + the sequence numbers. */ + spin_lock_irqsave(&intf->counter_lock, flags); + intf->sent_invalid_commands++; + spin_unlock_irqrestore(&intf->counter_lock, flags); rv = -EINVAL; goto out_err; } @@ -1474,12 +1391,14 @@ static int i_ipmi_request(ipmi_user_t user, if (((msg->netfn == IPMI_NETFN_APP_REQUEST) && ((msg->cmd == IPMI_COLD_RESET_CMD) || (msg->cmd == IPMI_WARM_RESET_CMD))) - || (msg->netfn == IPMI_NETFN_FIRMWARE_REQUEST)) { + || (msg->netfn == IPMI_NETFN_FIRMWARE_REQUEST)) + { spin_lock_irqsave(&intf->maintenance_mode_lock, flags); intf->auto_maintenance_timeout = IPMI_MAINTENANCE_MODE_TIMEOUT; if (!intf->maintenance_mode - && !intf->maintenance_mode_enable) { + && !intf->maintenance_mode_enable) + { intf->maintenance_mode_enable = 1; maintenance_mode_update(intf); } @@ -1488,7 +1407,9 @@ static int i_ipmi_request(ipmi_user_t user, } if ((msg->data_len + 2) > IPMI_MAX_MSG_LENGTH) { - ipmi_inc_stat(intf, sent_invalid_commands); + spin_lock_irqsave(&intf->counter_lock, flags); + intf->sent_invalid_commands++; + spin_unlock_irqrestore(&intf->counter_lock, flags); rv = -EMSGSIZE; goto out_err; } @@ -1500,23 +1421,31 @@ static int i_ipmi_request(ipmi_user_t user, if (msg->data_len > 0) memcpy(&(smi_msg->data[2]), msg->data, msg->data_len); smi_msg->data_size = msg->data_len + 2; - ipmi_inc_stat(intf, sent_local_commands); + spin_lock_irqsave(&intf->counter_lock, flags); + intf->sent_local_commands++; + spin_unlock_irqrestore(&intf->counter_lock, flags); } else if ((addr->addr_type == IPMI_IPMB_ADDR_TYPE) - || (addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) { + || (addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) + { struct ipmi_ipmb_addr *ipmb_addr; unsigned char ipmb_seq; long seqid; int broadcast = 0; if (addr->channel >= IPMI_MAX_CHANNELS) { - ipmi_inc_stat(intf, sent_invalid_commands); + spin_lock_irqsave(&intf->counter_lock, flags); + intf->sent_invalid_commands++; + spin_unlock_irqrestore(&intf->counter_lock, flags); rv = -EINVAL; goto out_err; } if (intf->channels[addr->channel].medium - != IPMI_CHANNEL_MEDIUM_IPMB) { - ipmi_inc_stat(intf, sent_invalid_commands); + != IPMI_CHANNEL_MEDIUM_IPMB) + { + spin_lock_irqsave(&intf->counter_lock, flags); + intf->sent_invalid_commands++; + spin_unlock_irqrestore(&intf->counter_lock, flags); rv = -EINVAL; goto out_err; } @@ -1528,11 +1457,9 @@ static int i_ipmi_request(ipmi_user_t user, retries = 4; } if (addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE) { - /* - * Broadcasts add a zero at the beginning of the - * message, but otherwise is the same as an IPMB - * address. - */ + /* Broadcasts add a zero at the beginning of the + message, but otherwise is the same as an IPMB + address. */ addr->addr_type = IPMI_IPMB_ADDR_TYPE; broadcast = 1; } @@ -1542,19 +1469,21 @@ static int i_ipmi_request(ipmi_user_t user, if (retry_time_ms == 0) retry_time_ms = 1000; - /* - * 9 for the header and 1 for the checksum, plus - * possibly one for the broadcast. - */ + /* 9 for the header and 1 for the checksum, plus + possibly one for the broadcast. */ if ((msg->data_len + 10 + broadcast) > IPMI_MAX_MSG_LENGTH) { - ipmi_inc_stat(intf, sent_invalid_commands); + spin_lock_irqsave(&intf->counter_lock, flags); + intf->sent_invalid_commands++; + spin_unlock_irqrestore(&intf->counter_lock, flags); rv = -EMSGSIZE; goto out_err; } ipmb_addr = (struct ipmi_ipmb_addr *) addr; if (ipmb_addr->lun > 3) { - ipmi_inc_stat(intf, sent_invalid_commands); + spin_lock_irqsave(&intf->counter_lock, flags); + intf->sent_invalid_commands++; + spin_unlock_irqrestore(&intf->counter_lock, flags); rv = -EINVAL; goto out_err; } @@ -1562,31 +1491,29 @@ static int i_ipmi_request(ipmi_user_t user, memcpy(&recv_msg->addr, ipmb_addr, sizeof(*ipmb_addr)); if (recv_msg->msg.netfn & 0x1) { - /* - * It's a response, so use the user's sequence - * from msgid. - */ - ipmi_inc_stat(intf, sent_ipmb_responses); + /* It's a response, so use the user's sequence + from msgid. */ + spin_lock_irqsave(&intf->counter_lock, flags); + intf->sent_ipmb_responses++; + spin_unlock_irqrestore(&intf->counter_lock, flags); format_ipmb_msg(smi_msg, msg, ipmb_addr, msgid, msgid, broadcast, source_address, source_lun); - /* - * Save the receive message so we can use it - * to deliver the response. - */ + /* Save the receive message so we can use it + to deliver the response. */ smi_msg->user_data = recv_msg; } else { /* It's a command, so get a sequence for it. */ spin_lock_irqsave(&(intf->seq_lock), flags); - ipmi_inc_stat(intf, sent_ipmb_commands); + spin_lock(&intf->counter_lock); + intf->sent_ipmb_commands++; + spin_unlock(&intf->counter_lock); - /* - * Create a sequence number with a 1 second - * timeout and 4 retries. - */ + /* Create a sequence number with a 1 second + timeout and 4 retries. */ rv = intf_next_seq(intf, recv_msg, retry_time_ms, @@ -1595,42 +1522,34 @@ static int i_ipmi_request(ipmi_user_t user, &ipmb_seq, &seqid); if (rv) { - /* - * We have used up all the sequence numbers, - * probably, so abort. - */ + /* We have used up all the sequence numbers, + probably, so abort. */ spin_unlock_irqrestore(&(intf->seq_lock), flags); goto out_err; } - /* - * Store the sequence number in the message, - * so that when the send message response - * comes back we can start the timer. - */ + /* Store the sequence number in the message, + so that when the send message response + comes back we can start the timer. */ format_ipmb_msg(smi_msg, msg, ipmb_addr, STORE_SEQ_IN_MSGID(ipmb_seq, seqid), ipmb_seq, broadcast, source_address, source_lun); - /* - * Copy the message into the recv message data, so we - * can retransmit it later if necessary. - */ + /* Copy the message into the recv message data, so we + can retransmit it later if necessary. */ memcpy(recv_msg->msg_data, smi_msg->data, smi_msg->data_size); recv_msg->msg.data = recv_msg->msg_data; recv_msg->msg.data_len = smi_msg->data_size; - /* - * We don't unlock until here, because we need - * to copy the completed message into the - * recv_msg before we release the lock. - * Otherwise, race conditions may bite us. I - * know that's pretty paranoid, but I prefer - * to be correct. - */ + /* We don't unlock until here, because we need + to copy the completed message into the + recv_msg before we release the lock. + Otherwise, race conditions may bite us. I + know that's pretty paranoid, but I prefer + to be correct. */ spin_unlock_irqrestore(&(intf->seq_lock), flags); } } else if (addr->addr_type == IPMI_LAN_ADDR_TYPE) { @@ -1639,16 +1558,21 @@ static int i_ipmi_request(ipmi_user_t user, long seqid; if (addr->channel >= IPMI_MAX_CHANNELS) { - ipmi_inc_stat(intf, sent_invalid_commands); + spin_lock_irqsave(&intf->counter_lock, flags); + intf->sent_invalid_commands++; + spin_unlock_irqrestore(&intf->counter_lock, flags); rv = -EINVAL; goto out_err; } if ((intf->channels[addr->channel].medium - != IPMI_CHANNEL_MEDIUM_8023LAN) + != IPMI_CHANNEL_MEDIUM_8023LAN) && (intf->channels[addr->channel].medium - != IPMI_CHANNEL_MEDIUM_ASYNC)) { - ipmi_inc_stat(intf, sent_invalid_commands); + != IPMI_CHANNEL_MEDIUM_ASYNC)) + { + spin_lock_irqsave(&intf->counter_lock, flags); + intf->sent_invalid_commands++; + spin_unlock_irqrestore(&intf->counter_lock, flags); rv = -EINVAL; goto out_err; } @@ -1661,14 +1585,18 @@ static int i_ipmi_request(ipmi_user_t user, /* 11 for the header and 1 for the checksum. */ if ((msg->data_len + 12) > IPMI_MAX_MSG_LENGTH) { - ipmi_inc_stat(intf, sent_invalid_commands); + spin_lock_irqsave(&intf->counter_lock, flags); + intf->sent_invalid_commands++; + spin_unlock_irqrestore(&intf->counter_lock, flags); rv = -EMSGSIZE; goto out_err; } lan_addr = (struct ipmi_lan_addr *) addr; if (lan_addr->lun > 3) { - ipmi_inc_stat(intf, sent_invalid_commands); + spin_lock_irqsave(&intf->counter_lock, flags); + intf->sent_invalid_commands++; + spin_unlock_irqrestore(&intf->counter_lock, flags); rv = -EINVAL; goto out_err; } @@ -1676,30 +1604,28 @@ static int i_ipmi_request(ipmi_user_t user, memcpy(&recv_msg->addr, lan_addr, sizeof(*lan_addr)); if (recv_msg->msg.netfn & 0x1) { - /* - * It's a response, so use the user's sequence - * from msgid. - */ - ipmi_inc_stat(intf, sent_lan_responses); + /* It's a response, so use the user's sequence + from msgid. */ + spin_lock_irqsave(&intf->counter_lock, flags); + intf->sent_lan_responses++; + spin_unlock_irqrestore(&intf->counter_lock, flags); format_lan_msg(smi_msg, msg, lan_addr, msgid, msgid, source_lun); - /* - * Save the receive message so we can use it - * to deliver the response. - */ + /* Save the receive message so we can use it + to deliver the response. */ smi_msg->user_data = recv_msg; } else { /* It's a command, so get a sequence for it. */ spin_lock_irqsave(&(intf->seq_lock), flags); - ipmi_inc_stat(intf, sent_lan_commands); + spin_lock(&intf->counter_lock); + intf->sent_lan_commands++; + spin_unlock(&intf->counter_lock); - /* - * Create a sequence number with a 1 second - * timeout and 4 retries. - */ + /* Create a sequence number with a 1 second + timeout and 4 retries. */ rv = intf_next_seq(intf, recv_msg, retry_time_ms, @@ -1708,46 +1634,40 @@ static int i_ipmi_request(ipmi_user_t user, &ipmb_seq, &seqid); if (rv) { - /* - * We have used up all the sequence numbers, - * probably, so abort. - */ + /* We have used up all the sequence numbers, + probably, so abort. */ spin_unlock_irqrestore(&(intf->seq_lock), flags); goto out_err; } - /* - * Store the sequence number in the message, - * so that when the send message response - * comes back we can start the timer. - */ + /* Store the sequence number in the message, + so that when the send message response + comes back we can start the timer. */ format_lan_msg(smi_msg, msg, lan_addr, STORE_SEQ_IN_MSGID(ipmb_seq, seqid), ipmb_seq, source_lun); - /* - * Copy the message into the recv message data, so we - * can retransmit it later if necessary. - */ + /* Copy the message into the recv message data, so we + can retransmit it later if necessary. */ memcpy(recv_msg->msg_data, smi_msg->data, smi_msg->data_size); recv_msg->msg.data = recv_msg->msg_data; recv_msg->msg.data_len = smi_msg->data_size; - /* - * We don't unlock until here, because we need - * to copy the completed message into the - * recv_msg before we release the lock. - * Otherwise, race conditions may bite us. I - * know that's pretty paranoid, but I prefer - * to be correct. - */ + /* We don't unlock until here, because we need + to copy the completed message into the + recv_msg before we release the lock. + Otherwise, race conditions may bite us. I + know that's pretty paranoid, but I prefer + to be correct. */ spin_unlock_irqrestore(&(intf->seq_lock), flags); } } else { /* Unknown address type. */ - ipmi_inc_stat(intf, sent_invalid_commands); + spin_lock_irqsave(&intf->counter_lock, flags); + intf->sent_invalid_commands++; + spin_unlock_irqrestore(&intf->counter_lock, flags); rv = -EINVAL; goto out_err; } @@ -1815,7 +1735,6 @@ int ipmi_request_settime(ipmi_user_t user, retries, retry_time_ms); } -EXPORT_SYMBOL(ipmi_request_settime); int ipmi_request_supply_msgs(ipmi_user_t user, struct ipmi_addr *addr, @@ -1847,7 +1766,6 @@ int ipmi_request_supply_msgs(ipmi_user_t user, lun, -1, 0); } -EXPORT_SYMBOL(ipmi_request_supply_msgs); #ifdef CONFIG_PROC_FS static int ipmb_file_read_proc(char *page, char **start, off_t off, @@ -1872,7 +1790,7 @@ static int version_file_read_proc(char *page, char **start, off_t off, char *out = (char *) page; ipmi_smi_t intf = data; - return sprintf(out, "%u.%u\n", + return sprintf(out, "%d.%d\n", ipmi_version_major(&intf->bmc->id), ipmi_version_minor(&intf->bmc->id)); } @@ -1883,65 +1801,65 @@ static int stat_file_read_proc(char *page, char **start, off_t off, char *out = (char *) page; ipmi_smi_t intf = data; - out += sprintf(out, "sent_invalid_commands: %u\n", - ipmi_get_stat(intf, sent_invalid_commands)); - out += sprintf(out, "sent_local_commands: %u\n", - ipmi_get_stat(intf, sent_local_commands)); - out += sprintf(out, "handled_local_responses: %u\n", - ipmi_get_stat(intf, handled_local_responses)); - out += sprintf(out, "unhandled_local_responses: %u\n", - ipmi_get_stat(intf, unhandled_local_responses)); - out += sprintf(out, "sent_ipmb_commands: %u\n", - ipmi_get_stat(intf, sent_ipmb_commands)); - out += sprintf(out, "sent_ipmb_command_errs: %u\n", - ipmi_get_stat(intf, sent_ipmb_command_errs)); - out += sprintf(out, "retransmitted_ipmb_commands: %u\n", - ipmi_get_stat(intf, retransmitted_ipmb_commands)); - out += sprintf(out, "timed_out_ipmb_commands: %u\n", - ipmi_get_stat(intf, timed_out_ipmb_commands)); - out += sprintf(out, "timed_out_ipmb_broadcasts: %u\n", - ipmi_get_stat(intf, timed_out_ipmb_broadcasts)); - out += sprintf(out, "sent_ipmb_responses: %u\n", - ipmi_get_stat(intf, sent_ipmb_responses)); - out += sprintf(out, "handled_ipmb_responses: %u\n", - ipmi_get_stat(intf, handled_ipmb_responses)); - out += sprintf(out, "invalid_ipmb_responses: %u\n", - ipmi_get_stat(intf, invalid_ipmb_responses)); - out += sprintf(out, "unhandled_ipmb_responses: %u\n", - ipmi_get_stat(intf, unhandled_ipmb_responses)); - out += sprintf(out, "sent_lan_commands: %u\n", - ipmi_get_stat(intf, sent_lan_commands)); - out += sprintf(out, "sent_lan_command_errs: %u\n", - ipmi_get_stat(intf, sent_lan_command_errs)); - out += sprintf(out, "retransmitted_lan_commands: %u\n", - ipmi_get_stat(intf, retransmitted_lan_commands)); - out += sprintf(out, "timed_out_lan_commands: %u\n", - ipmi_get_stat(intf, timed_out_lan_commands)); - out += sprintf(out, "sent_lan_responses: %u\n", - ipmi_get_stat(intf, sent_lan_responses)); - out += sprintf(out, "handled_lan_responses: %u\n", - ipmi_get_stat(intf, handled_lan_responses)); - out += sprintf(out, "invalid_lan_responses: %u\n", - ipmi_get_stat(intf, invalid_lan_responses)); - out += sprintf(out, "unhandled_lan_responses: %u\n", - ipmi_get_stat(intf, unhandled_lan_responses)); - out += sprintf(out, "handled_commands: %u\n", - ipmi_get_stat(intf, handled_commands)); - out += sprintf(out, "invalid_commands: %u\n", - ipmi_get_stat(intf, invalid_commands)); - out += sprintf(out, "unhandled_commands: %u\n", - ipmi_get_stat(intf, unhandled_commands)); - out += sprintf(out, "invalid_events: %u\n", - ipmi_get_stat(intf, invalid_events)); - out += sprintf(out, "events: %u\n", - ipmi_get_stat(intf, events)); + out += sprintf(out, "sent_invalid_commands: %d\n", + intf->sent_invalid_commands); + out += sprintf(out, "sent_local_commands: %d\n", + intf->sent_local_commands); + out += sprintf(out, "handled_local_responses: %d\n", + intf->handled_local_responses); + out += sprintf(out, "unhandled_local_responses: %d\n", + intf->unhandled_local_responses); + out += sprintf(out, "sent_ipmb_commands: %d\n", + intf->sent_ipmb_commands); + out += sprintf(out, "sent_ipmb_command_errs: %d\n", + intf->sent_ipmb_command_errs); + out += sprintf(out, "retransmitted_ipmb_commands: %d\n", + intf->retransmitted_ipmb_commands); + out += sprintf(out, "timed_out_ipmb_commands: %d\n", + intf->timed_out_ipmb_commands); + out += sprintf(out, "timed_out_ipmb_broadcasts: %d\n", + intf->timed_out_ipmb_broadcasts); + out += sprintf(out, "sent_ipmb_responses: %d\n", + intf->sent_ipmb_responses); + out += sprintf(out, "handled_ipmb_responses: %d\n", + intf->handled_ipmb_responses); + out += sprintf(out, "invalid_ipmb_responses: %d\n", + intf->invalid_ipmb_responses); + out += sprintf(out, "unhandled_ipmb_responses: %d\n", + intf->unhandled_ipmb_responses); + out += sprintf(out, "sent_lan_commands: %d\n", + intf->sent_lan_commands); + out += sprintf(out, "sent_lan_command_errs: %d\n", + intf->sent_lan_command_errs); + out += sprintf(out, "retransmitted_lan_commands: %d\n", + intf->retransmitted_lan_commands); + out += sprintf(out, "timed_out_lan_commands: %d\n", + intf->timed_out_lan_commands); + out += sprintf(out, "sent_lan_responses: %d\n", + intf->sent_lan_responses); + out += sprintf(out, "handled_lan_responses: %d\n", + intf->handled_lan_responses); + out += sprintf(out, "invalid_lan_responses: %d\n", + intf->invalid_lan_responses); + out += sprintf(out, "unhandled_lan_responses: %d\n", + intf->unhandled_lan_responses); + out += sprintf(out, "handled_commands: %d\n", + intf->handled_commands); + out += sprintf(out, "invalid_commands: %d\n", + intf->invalid_commands); + out += sprintf(out, "unhandled_commands: %d\n", + intf->unhandled_commands); + out += sprintf(out, "invalid_events: %d\n", + intf->invalid_events); + out += sprintf(out, "events: %d\n", + intf->events); return (out - ((char *) page)); } #endif /* CONFIG_PROC_FS */ int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name, - read_proc_t *read_proc, + read_proc_t *read_proc, write_proc_t *write_proc, void *data, struct module *owner) { int rv = 0; @@ -1968,6 +1886,7 @@ int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name, } else { file->data = data; file->read_proc = read_proc; + file->write_proc = write_proc; file->owner = owner; mutex_lock(&smi->proc_entry_lock); @@ -1980,7 +1899,6 @@ int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name, return rv; } -EXPORT_SYMBOL(ipmi_smi_add_proc_entry); static int add_proc_entries(ipmi_smi_t smi, int num) { @@ -1991,22 +1909,23 @@ static int add_proc_entries(ipmi_smi_t smi, int num) smi->proc_dir = proc_mkdir(smi->proc_dir_name, proc_ipmi_root); if (!smi->proc_dir) rv = -ENOMEM; - else + else { smi->proc_dir->owner = THIS_MODULE; + } if (rv == 0) rv = ipmi_smi_add_proc_entry(smi, "stats", - stat_file_read_proc, + stat_file_read_proc, NULL, smi, THIS_MODULE); if (rv == 0) rv = ipmi_smi_add_proc_entry(smi, "ipmb", - ipmb_file_read_proc, + ipmb_file_read_proc, NULL, smi, THIS_MODULE); if (rv == 0) rv = ipmi_smi_add_proc_entry(smi, "version", - version_file_read_proc, + version_file_read_proc, NULL, smi, THIS_MODULE); #endif /* CONFIG_PROC_FS */ @@ -2291,47 +2210,37 @@ static int create_files(struct bmc_device *bmc) err = device_create_file(&bmc->dev->dev, &bmc->device_id_attr); - if (err) - goto out; + if (err) goto out; err = device_create_file(&bmc->dev->dev, &bmc->provides_dev_sdrs_attr); - if (err) - goto out_devid; + if (err) goto out_devid; err = device_create_file(&bmc->dev->dev, &bmc->revision_attr); - if (err) - goto out_sdrs; + if (err) goto out_sdrs; err = device_create_file(&bmc->dev->dev, &bmc->firmware_rev_attr); - if (err) - goto out_rev; + if (err) goto out_rev; err = device_create_file(&bmc->dev->dev, &bmc->version_attr); - if (err) - goto out_firm; + if (err) goto out_firm; err = device_create_file(&bmc->dev->dev, &bmc->add_dev_support_attr); - if (err) - goto out_version; + if (err) goto out_version; err = device_create_file(&bmc->dev->dev, &bmc->manufacturer_id_attr); - if (err) - goto out_add_dev; + if (err) goto out_add_dev; err = device_create_file(&bmc->dev->dev, &bmc->product_id_attr); - if (err) - goto out_manu; + if (err) goto out_manu; if (bmc->id.aux_firmware_revision_set) { err = device_create_file(&bmc->dev->dev, &bmc->aux_firmware_rev_attr); - if (err) - goto out_prod_id; + if (err) goto out_prod_id; } if (bmc->guid_set) { err = device_create_file(&bmc->dev->dev, &bmc->guid_attr); - if (err) - goto out_aux_firm; + if (err) goto out_aux_firm; } return 0; @@ -2459,10 +2368,8 @@ static int ipmi_bmc_register(ipmi_smi_t intf, int ifnum, "ipmi_msghandler:" " Unable to register bmc device: %d\n", rv); - /* - * Don't go to out_err, you can only do that if - * the device is registered already. - */ + /* Don't go to out_err, you can only do that if + the device is registered already. */ return rv; } @@ -2653,18 +2560,17 @@ channel_handler(ipmi_smi_t intf, struct ipmi_recv_msg *msg) if ((msg->addr.addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE) && (msg->msg.netfn == IPMI_NETFN_APP_RESPONSE) - && (msg->msg.cmd == IPMI_GET_CHANNEL_INFO_CMD)) { + && (msg->msg.cmd == IPMI_GET_CHANNEL_INFO_CMD)) + { /* It's the one we want */ if (msg->msg.data[0] != 0) { /* Got an error from the channel, just go on. */ if (msg->msg.data[0] == IPMI_INVALID_COMMAND_ERR) { - /* - * If the MC does not support this - * command, that is legal. We just - * assume it has one IPMB at channel - * zero. - */ + /* If the MC does not support this + command, that is legal. We just + assume it has one IPMB at channel + zero. */ intf->channels[0].medium = IPMI_CHANNEL_MEDIUM_IPMB; intf->channels[0].protocol @@ -2685,7 +2591,7 @@ channel_handler(ipmi_smi_t intf, struct ipmi_recv_msg *msg) intf->channels[chan].medium = msg->msg.data[2] & 0x7f; intf->channels[chan].protocol = msg->msg.data[3] & 0x1f; - next_channel: + next_channel: intf->curr_channel++; if (intf->curr_channel >= IPMI_MAX_CHANNELS) wake_up(&intf->waitq); @@ -2713,7 +2619,6 @@ void ipmi_poll_interface(ipmi_user_t user) if (intf->handlers->poll) intf->handlers->poll(intf->send_info); } -EXPORT_SYMBOL(ipmi_poll_interface); int ipmi_register_smi(struct ipmi_smi_handlers *handlers, void *send_info, @@ -2728,18 +2633,14 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers, ipmi_smi_t tintf; struct list_head *link; - /* - * Make sure the driver is actually initialized, this handles - * problems with initialization order. - */ + /* Make sure the driver is actually initialized, this handles + problems with initialization order. */ if (!initialized) { rv = ipmi_init_msghandler(); if (rv) return rv; - /* - * The init code doesn't return an error if it was turned - * off, but it won't initialize. Check that. - */ + /* The init code doesn't return an error if it was turned + off, but it won't initialize. Check that. */ if (!initialized) return -ENODEV; } @@ -2787,9 +2688,8 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers, spin_lock_init(&intf->maintenance_mode_lock); INIT_LIST_HEAD(&intf->cmd_rcvrs); init_waitqueue_head(&intf->waitq); - for (i = 0; i < IPMI_NUM_STATS; i++) - atomic_set(&intf->stats[i], 0); + spin_lock_init(&intf->counter_lock); intf->proc_dir = NULL; mutex_lock(&smi_watchers_mutex); @@ -2817,12 +2717,11 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers, get_guid(intf); if ((intf->ipmi_version_major > 1) - || ((intf->ipmi_version_major == 1) - && (intf->ipmi_version_minor >= 5))) { - /* - * Start scanning the channels to see what is - * available. - */ + || ((intf->ipmi_version_major == 1) + && (intf->ipmi_version_minor >= 5))) + { + /* Start scanning the channels to see what is + available. */ intf->null_user_handler = channel_handler; intf->curr_channel = 0; rv = send_channel_info_cmd(intf, 0); @@ -2870,7 +2769,6 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers, return rv; } -EXPORT_SYMBOL(ipmi_register_smi); static void cleanup_smi_msgs(ipmi_smi_t intf) { @@ -2905,10 +2803,8 @@ int ipmi_unregister_smi(ipmi_smi_t intf) remove_proc_entries(intf); - /* - * Call all the watcher interfaces to tell them that - * an interface is gone. - */ + /* Call all the watcher interfaces to tell them that + an interface is gone. */ list_for_each_entry(w, &smi_watchers, link) w->smi_gone(intf_num); mutex_unlock(&smi_watchers_mutex); @@ -2916,21 +2812,22 @@ int ipmi_unregister_smi(ipmi_smi_t intf) kref_put(&intf->refcount, intf_free); return 0; } -EXPORT_SYMBOL(ipmi_unregister_smi); static int handle_ipmb_get_msg_rsp(ipmi_smi_t intf, struct ipmi_smi_msg *msg) { struct ipmi_ipmb_addr ipmb_addr; struct ipmi_recv_msg *recv_msg; + unsigned long flags; - /* - * This is 11, not 10, because the response must contain a - * completion code. - */ + + /* This is 11, not 10, because the response must contain a + * completion code. */ if (msg->rsp_size < 11) { /* Message not big enough, just ignore it. */ - ipmi_inc_stat(intf, invalid_ipmb_responses); + spin_lock_irqsave(&intf->counter_lock, flags); + intf->invalid_ipmb_responses++; + spin_unlock_irqrestore(&intf->counter_lock, flags); return 0; } @@ -2944,38 +2841,37 @@ static int handle_ipmb_get_msg_rsp(ipmi_smi_t intf, ipmb_addr.channel = msg->rsp[3] & 0x0f; ipmb_addr.lun = msg->rsp[7] & 3; - /* - * It's a response from a remote entity. Look up the sequence - * number and handle the response. - */ + /* It's a response from a remote entity. Look up the sequence + number and handle the response. */ if (intf_find_seq(intf, msg->rsp[7] >> 2, msg->rsp[3] & 0x0f, msg->rsp[8], (msg->rsp[4] >> 2) & (~1), (struct ipmi_addr *) &(ipmb_addr), - &recv_msg)) { - /* - * We were unable to find the sequence number, - * so just nuke the message. - */ - ipmi_inc_stat(intf, unhandled_ipmb_responses); + &recv_msg)) + { + /* We were unable to find the sequence number, + so just nuke the message. */ + spin_lock_irqsave(&intf->counter_lock, flags); + intf->unhandled_ipmb_responses++; + spin_unlock_irqrestore(&intf->counter_lock, flags); return 0; } memcpy(recv_msg->msg_data, &(msg->rsp[9]), msg->rsp_size - 9); - /* - * The other fields matched, so no need to set them, except - * for netfn, which needs to be the response that was - * returned, not the request value. - */ + /* THe other fields matched, so no need to set them, except + for netfn, which needs to be the response that was + returned, not the request value. */ recv_msg->msg.netfn = msg->rsp[4] >> 2; recv_msg->msg.data = recv_msg->msg_data; recv_msg->msg.data_len = msg->rsp_size - 10; recv_msg->recv_type = IPMI_RESPONSE_RECV_TYPE; - ipmi_inc_stat(intf, handled_ipmb_responses); + spin_lock_irqsave(&intf->counter_lock, flags); + intf->handled_ipmb_responses++; + spin_unlock_irqrestore(&intf->counter_lock, flags); deliver_response(recv_msg); return 0; @@ -2992,11 +2888,14 @@ static int handle_ipmb_get_msg_cmd(ipmi_smi_t intf, ipmi_user_t user = NULL; struct ipmi_ipmb_addr *ipmb_addr; struct ipmi_recv_msg *recv_msg; + unsigned long flags; struct ipmi_smi_handlers *handlers; if (msg->rsp_size < 10) { /* Message not big enough, just ignore it. */ - ipmi_inc_stat(intf, invalid_commands); + spin_lock_irqsave(&intf->counter_lock, flags); + intf->invalid_commands++; + spin_unlock_irqrestore(&intf->counter_lock, flags); return 0; } @@ -3020,17 +2919,19 @@ static int handle_ipmb_get_msg_cmd(ipmi_smi_t intf, if (user == NULL) { /* We didn't find a user, deliver an error response. */ - ipmi_inc_stat(intf, unhandled_commands); + spin_lock_irqsave(&intf->counter_lock, flags); + intf->unhandled_commands++; + spin_unlock_irqrestore(&intf->counter_lock, flags); msg->data[0] = (IPMI_NETFN_APP_REQUEST << 2); msg->data[1] = IPMI_SEND_MSG_CMD; msg->data[2] = msg->rsp[3]; msg->data[3] = msg->rsp[6]; - msg->data[4] = ((netfn + 1) << 2) | (msg->rsp[7] & 0x3); + msg->data[4] = ((netfn + 1) << 2) | (msg->rsp[7] & 0x3); msg->data[5] = ipmb_checksum(&(msg->data[3]), 2); msg->data[6] = intf->channels[msg->rsp[3] & 0xf].address; - /* rqseq/lun */ - msg->data[7] = (msg->rsp[7] & 0xfc) | (msg->rsp[4] & 0x3); + /* rqseq/lun */ + msg->data[7] = (msg->rsp[7] & 0xfc) | (msg->rsp[4] & 0x3); msg->data[8] = msg->rsp[8]; /* cmd */ msg->data[9] = IPMI_INVALID_CMD_COMPLETION_CODE; msg->data[10] = ipmb_checksum(&(msg->data[6]), 4); @@ -3049,25 +2950,23 @@ static int handle_ipmb_get_msg_cmd(ipmi_smi_t intf, handlers = intf->handlers; if (handlers) { handlers->sender(intf->send_info, msg, 0); - /* - * We used the message, so return the value - * that causes it to not be freed or - * queued. - */ + /* We used the message, so return the value + that causes it to not be freed or + queued. */ rv = -1; } rcu_read_unlock(); } else { /* Deliver the message to the user. */ - ipmi_inc_stat(intf, handled_commands); + spin_lock_irqsave(&intf->counter_lock, flags); + intf->handled_commands++; + spin_unlock_irqrestore(&intf->counter_lock, flags); recv_msg = ipmi_alloc_recv_msg(); if (!recv_msg) { - /* - * We couldn't allocate memory for the - * message, so requeue it for handling - * later. - */ + /* We couldn't allocate memory for the + message, so requeue it for handling + later. */ rv = 1; kref_put(&user->refcount, free_user); } else { @@ -3078,10 +2977,8 @@ static int handle_ipmb_get_msg_cmd(ipmi_smi_t intf, ipmb_addr->lun = msg->rsp[7] & 3; ipmb_addr->channel = msg->rsp[3] & 0xf; - /* - * Extract the rest of the message information - * from the IPMB header. - */ + /* Extract the rest of the message information + from the IPMB header.*/ recv_msg->user = user; recv_msg->recv_type = IPMI_CMD_RECV_TYPE; recv_msg->msgid = msg->rsp[7] >> 2; @@ -3089,10 +2986,8 @@ static int handle_ipmb_get_msg_cmd(ipmi_smi_t intf, recv_msg->msg.cmd = msg->rsp[8]; recv_msg->msg.data = recv_msg->msg_data; - /* - * We chop off 10, not 9 bytes because the checksum - * at the end also needs to be removed. - */ + /* We chop off 10, not 9 bytes because the checksum + at the end also needs to be removed. */ recv_msg->msg.data_len = msg->rsp_size - 10; memcpy(recv_msg->msg_data, &(msg->rsp[9]), @@ -3109,15 +3004,16 @@ static int handle_lan_get_msg_rsp(ipmi_smi_t intf, { struct ipmi_lan_addr lan_addr; struct ipmi_recv_msg *recv_msg; + unsigned long flags; - /* - * This is 13, not 12, because the response must contain a - * completion code. - */ + /* This is 13, not 12, because the response must contain a + * completion code. */ if (msg->rsp_size < 13) { /* Message not big enough, just ignore it. */ - ipmi_inc_stat(intf, invalid_lan_responses); + spin_lock_irqsave(&intf->counter_lock, flags); + intf->invalid_lan_responses++; + spin_unlock_irqrestore(&intf->counter_lock, flags); return 0; } @@ -3134,38 +3030,37 @@ static int handle_lan_get_msg_rsp(ipmi_smi_t intf, lan_addr.privilege = msg->rsp[3] >> 4; lan_addr.lun = msg->rsp[9] & 3; - /* - * It's a response from a remote entity. Look up the sequence - * number and handle the response. - */ + /* It's a response from a remote entity. Look up the sequence + number and handle the response. */ if (intf_find_seq(intf, msg->rsp[9] >> 2, msg->rsp[3] & 0x0f, msg->rsp[10], (msg->rsp[6] >> 2) & (~1), (struct ipmi_addr *) &(lan_addr), - &recv_msg)) { - /* - * We were unable to find the sequence number, - * so just nuke the message. - */ - ipmi_inc_stat(intf, unhandled_lan_responses); + &recv_msg)) + { + /* We were unable to find the sequence number, + so just nuke the message. */ + spin_lock_irqsave(&intf->counter_lock, flags); + intf->unhandled_lan_responses++; + spin_unlock_irqrestore(&intf->counter_lock, flags); return 0; } memcpy(recv_msg->msg_data, &(msg->rsp[11]), msg->rsp_size - 11); - /* - * The other fields matched, so no need to set them, except - * for netfn, which needs to be the response that was - * returned, not the request value. - */ + /* The other fields matched, so no need to set them, except + for netfn, which needs to be the response that was + returned, not the request value. */ recv_msg->msg.netfn = msg->rsp[6] >> 2; recv_msg->msg.data = recv_msg->msg_data; recv_msg->msg.data_len = msg->rsp_size - 12; recv_msg->recv_type = IPMI_RESPONSE_RECV_TYPE; - ipmi_inc_stat(intf, handled_lan_responses); + spin_lock_irqsave(&intf->counter_lock, flags); + intf->handled_lan_responses++; + spin_unlock_irqrestore(&intf->counter_lock, flags); deliver_response(recv_msg); return 0; @@ -3182,10 +3077,13 @@ static int handle_lan_get_msg_cmd(ipmi_smi_t intf, ipmi_user_t user = NULL; struct ipmi_lan_addr *lan_addr; struct ipmi_recv_msg *recv_msg; + unsigned long flags; if (msg->rsp_size < 12) { /* Message not big enough, just ignore it. */ - ipmi_inc_stat(intf, invalid_commands); + spin_lock_irqsave(&intf->counter_lock, flags); + intf->invalid_commands++; + spin_unlock_irqrestore(&intf->counter_lock, flags); return 0; } @@ -3209,23 +3107,23 @@ static int handle_lan_get_msg_cmd(ipmi_smi_t intf, if (user == NULL) { /* We didn't find a user, just give up. */ - ipmi_inc_stat(intf, unhandled_commands); + spin_lock_irqsave(&intf->counter_lock, flags); + intf->unhandled_commands++; + spin_unlock_irqrestore(&intf->counter_lock, flags); - /* - * Don't do anything with these messages, just allow - * them to be freed. - */ - rv = 0; + rv = 0; /* Don't do anything with these messages, just + allow them to be freed. */ } else { /* Deliver the message to the user. */ - ipmi_inc_stat(intf, handled_commands); + spin_lock_irqsave(&intf->counter_lock, flags); + intf->handled_commands++; + spin_unlock_irqrestore(&intf->counter_lock, flags); recv_msg = ipmi_alloc_recv_msg(); if (!recv_msg) { - /* - * We couldn't allocate memory for the - * message, so requeue it for handling later. - */ + /* We couldn't allocate memory for the + message, so requeue it for handling + later. */ rv = 1; kref_put(&user->refcount, free_user); } else { @@ -3239,10 +3137,8 @@ static int handle_lan_get_msg_cmd(ipmi_smi_t intf, lan_addr->channel = msg->rsp[3] & 0xf; lan_addr->privilege = msg->rsp[3] >> 4; - /* - * Extract the rest of the message information - * from the IPMB header. - */ + /* Extract the rest of the message information + from the IPMB header.*/ recv_msg->user = user; recv_msg->recv_type = IPMI_CMD_RECV_TYPE; recv_msg->msgid = msg->rsp[9] >> 2; @@ -3250,10 +3146,8 @@ static int handle_lan_get_msg_cmd(ipmi_smi_t intf, recv_msg->msg.cmd = msg->rsp[10]; recv_msg->msg.data = recv_msg->msg_data; - /* - * We chop off 12, not 11 bytes because the checksum - * at the end also needs to be removed. - */ + /* We chop off 12, not 11 bytes because the checksum + at the end also needs to be removed. */ recv_msg->msg.data_len = msg->rsp_size - 12; memcpy(recv_msg->msg_data, &(msg->rsp[11]), @@ -3269,7 +3163,7 @@ static void copy_event_into_recv_msg(struct ipmi_recv_msg *recv_msg, struct ipmi_smi_msg *msg) { struct ipmi_system_interface_addr *smi_addr; - + recv_msg->msgid = 0; smi_addr = (struct ipmi_system_interface_addr *) &(recv_msg->addr); smi_addr->addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; @@ -3295,7 +3189,9 @@ static int handle_read_event_rsp(ipmi_smi_t intf, if (msg->rsp_size < 19) { /* Message is too small to be an IPMB event. */ - ipmi_inc_stat(intf, invalid_events); + spin_lock_irqsave(&intf->counter_lock, flags); + intf->invalid_events++; + spin_unlock_irqrestore(&intf->counter_lock, flags); return 0; } @@ -3308,12 +3204,12 @@ static int handle_read_event_rsp(ipmi_smi_t intf, spin_lock_irqsave(&intf->events_lock, flags); - ipmi_inc_stat(intf, events); + spin_lock(&intf->counter_lock); + intf->events++; + spin_unlock(&intf->counter_lock); - /* - * Allocate and fill in one message for every user that is - * getting events. - */ + /* Allocate and fill in one message for every user that is getting + events. */ rcu_read_lock(); list_for_each_entry_rcu(user, &intf->users, link) { if (!user->gets_events) @@ -3327,11 +3223,9 @@ static int handle_read_event_rsp(ipmi_smi_t intf, list_del(&recv_msg->link); ipmi_free_recv_msg(recv_msg); } - /* - * We couldn't allocate memory for the - * message, so requeue it for handling - * later. - */ + /* We couldn't allocate memory for the + message, so requeue it for handling + later. */ rv = 1; goto out; } @@ -3352,17 +3246,13 @@ static int handle_read_event_rsp(ipmi_smi_t intf, deliver_response(recv_msg); } } else if (intf->waiting_events_count < MAX_EVENTS_IN_QUEUE) { - /* - * No one to receive the message, put it in queue if there's - * not already too many things in the queue. - */ + /* No one to receive the message, put it in queue if there's + not already too many things in the queue. */ recv_msg = ipmi_alloc_recv_msg(); if (!recv_msg) { - /* - * We couldn't allocate memory for the - * message, so requeue it for handling - * later. - */ + /* We couldn't allocate memory for the + message, so requeue it for handling + later. */ rv = 1; goto out; } @@ -3370,14 +3260,11 @@ static int handle_read_event_rsp(ipmi_smi_t intf, copy_event_into_recv_msg(recv_msg, msg); list_add_tail(&(recv_msg->link), &(intf->waiting_events)); intf->waiting_events_count++; - } else if (!intf->event_msg_printed) { - /* - * There's too many things in the queue, discard this - * message. - */ - printk(KERN_WARNING PFX "Event queue full, discarding" - " incoming events\n"); - intf->event_msg_printed = 1; + } else { + /* There's too many things in the queue, discard this + message. */ + printk(KERN_WARNING PFX "Event queue full, discarding an" + " incoming event\n"); } out: @@ -3390,15 +3277,16 @@ static int handle_bmc_rsp(ipmi_smi_t intf, struct ipmi_smi_msg *msg) { struct ipmi_recv_msg *recv_msg; + unsigned long flags; struct ipmi_user *user; recv_msg = (struct ipmi_recv_msg *) msg->user_data; - if (recv_msg == NULL) { - printk(KERN_WARNING - "IPMI message received with no owner. This\n" - "could be because of a malformed message, or\n" - "because of a hardware error. Contact your\n" - "hardware vender for assistance\n"); + if (recv_msg == NULL) + { + printk(KERN_WARNING"IPMI message received with no owner. This\n" + "could be because of a malformed message, or\n" + "because of a hardware error. Contact your\n" + "hardware vender for assistance\n"); return 0; } @@ -3406,12 +3294,16 @@ static int handle_bmc_rsp(ipmi_smi_t intf, /* Make sure the user still exists. */ if (user && !user->valid) { /* The user for the message went away, so give up. */ - ipmi_inc_stat(intf, unhandled_local_responses); + spin_lock_irqsave(&intf->counter_lock, flags); + intf->unhandled_local_responses++; + spin_unlock_irqrestore(&intf->counter_lock, flags); ipmi_free_recv_msg(recv_msg); } else { struct ipmi_system_interface_addr *smi_addr; - ipmi_inc_stat(intf, handled_local_responses); + spin_lock_irqsave(&intf->counter_lock, flags); + intf->handled_local_responses++; + spin_unlock_irqrestore(&intf->counter_lock, flags); recv_msg->recv_type = IPMI_RESPONSE_RECV_TYPE; recv_msg->msgid = msg->msgid; smi_addr = ((struct ipmi_system_interface_addr *) @@ -3432,11 +3324,9 @@ static int handle_bmc_rsp(ipmi_smi_t intf, return 0; } -/* - * Handle a new message. Return 1 if the message should be requeued, - * 0 if the message should be freed, or -1 if the message should not - * be freed or requeued. - */ +/* Handle a new message. Return 1 if the message should be requeued, + 0 if the message should be freed, or -1 if the message should not + be freed or requeued. */ static int handle_new_recv_msg(ipmi_smi_t intf, struct ipmi_smi_msg *msg) { @@ -3461,12 +3351,10 @@ static int handle_new_recv_msg(ipmi_smi_t intf, msg->rsp[1] = msg->data[1]; msg->rsp[2] = IPMI_ERR_UNSPECIFIED; msg->rsp_size = 3; - } else if (((msg->rsp[0] >> 2) != ((msg->data[0] >> 2) | 1)) - || (msg->rsp[1] != msg->data[1])) { - /* - * The NetFN and Command in the response is not even - * marginally correct. - */ + } else if (((msg->rsp[0] >> 2) != ((msg->data[0] >> 2) | 1))/* Netfn */ + || (msg->rsp[1] != msg->data[1])) /* Command */ + { + /* The response is not even marginally correct. */ printk(KERN_WARNING PFX "BMC returned incorrect response," " expected netfn %x cmd %x, got netfn %x cmd %x\n", (msg->data[0] >> 2) | 1, msg->data[1], @@ -3481,11 +3369,10 @@ static int handle_new_recv_msg(ipmi_smi_t intf, if ((msg->rsp[0] == ((IPMI_NETFN_APP_REQUEST|1) << 2)) && (msg->rsp[1] == IPMI_SEND_MSG_CMD) - && (msg->user_data != NULL)) { - /* - * It's a response to a response we sent. For this we - * deliver a send message response to the user. - */ + && (msg->user_data != NULL)) + { + /* It's a response to a response we sent. For this we + deliver a send message response to the user. */ struct ipmi_recv_msg *recv_msg = msg->user_data; requeue = 0; @@ -3511,7 +3398,8 @@ static int handle_new_recv_msg(ipmi_smi_t intf, recv_msg->msg_data[0] = msg->rsp[2]; deliver_response(recv_msg); } else if ((msg->rsp[0] == ((IPMI_NETFN_APP_REQUEST|1) << 2)) - && (msg->rsp[1] == IPMI_GET_MSG_CMD)) { + && (msg->rsp[1] == IPMI_GET_MSG_CMD)) + { /* It's from the receive queue. */ chan = msg->rsp[3] & 0xf; if (chan >= IPMI_MAX_CHANNELS) { @@ -3523,16 +3411,12 @@ static int handle_new_recv_msg(ipmi_smi_t intf, switch (intf->channels[chan].medium) { case IPMI_CHANNEL_MEDIUM_IPMB: if (msg->rsp[4] & 0x04) { - /* - * It's a response, so find the - * requesting message and send it up. - */ + /* It's a response, so find the + requesting message and send it up. */ requeue = handle_ipmb_get_msg_rsp(intf, msg); } else { - /* - * It's a command to the SMS from some other - * entity. Handle that. - */ + /* It's a command to the SMS from some other + entity. Handle that. */ requeue = handle_ipmb_get_msg_cmd(intf, msg); } break; @@ -3540,30 +3424,25 @@ static int handle_new_recv_msg(ipmi_smi_t intf, case IPMI_CHANNEL_MEDIUM_8023LAN: case IPMI_CHANNEL_MEDIUM_ASYNC: if (msg->rsp[6] & 0x04) { - /* - * It's a response, so find the - * requesting message and send it up. - */ + /* It's a response, so find the + requesting message and send it up. */ requeue = handle_lan_get_msg_rsp(intf, msg); } else { - /* - * It's a command to the SMS from some other - * entity. Handle that. - */ + /* It's a command to the SMS from some other + entity. Handle that. */ requeue = handle_lan_get_msg_cmd(intf, msg); } break; default: - /* - * We don't handle the channel type, so just - * free the message. - */ + /* We don't handle the channel type, so just + * free the message. */ requeue = 0; } } else if ((msg->rsp[0] == ((IPMI_NETFN_APP_REQUEST|1) << 2)) - && (msg->rsp[1] == IPMI_READ_EVENT_MSG_BUFFER_CMD)) { + && (msg->rsp[1] == IPMI_READ_EVENT_MSG_BUFFER_CMD)) + { /* It's an asyncronous event. */ requeue = handle_read_event_rsp(intf, msg); } else { @@ -3579,82 +3458,71 @@ static int handle_new_recv_msg(ipmi_smi_t intf, void ipmi_smi_msg_received(ipmi_smi_t intf, struct ipmi_smi_msg *msg) { - unsigned long flags = 0; /* keep us warning-free. */ + unsigned long flags; int rv; - int run_to_completion; if ((msg->data_size >= 2) && (msg->data[0] == (IPMI_NETFN_APP_REQUEST << 2)) && (msg->data[1] == IPMI_SEND_MSG_CMD) - && (msg->user_data == NULL)) { - /* - * This is the local response to a command send, start - * the timer for these. The user_data will not be - * NULL if this is a response send, and we will let - * response sends just go through. - */ - - /* - * Check for errors, if we get certain errors (ones - * that mean basically we can try again later), we - * ignore them and start the timer. Otherwise we - * report the error immediately. - */ + && (msg->user_data == NULL)) + { + /* This is the local response to a command send, start + the timer for these. The user_data will not be + NULL if this is a response send, and we will let + response sends just go through. */ + + /* Check for errors, if we get certain errors (ones + that mean basically we can try again later), we + ignore them and start the timer. Otherwise we + report the error immediately. */ if ((msg->rsp_size >= 3) && (msg->rsp[2] != 0) && (msg->rsp[2] != IPMI_NODE_BUSY_ERR) && (msg->rsp[2] != IPMI_LOST_ARBITRATION_ERR) && (msg->rsp[2] != IPMI_BUS_ERR) - && (msg->rsp[2] != IPMI_NAK_ON_WRITE_ERR)) { + && (msg->rsp[2] != IPMI_NAK_ON_WRITE_ERR)) + { int chan = msg->rsp[3] & 0xf; /* Got an error sending the message, handle it. */ + spin_lock_irqsave(&intf->counter_lock, flags); if (chan >= IPMI_MAX_CHANNELS) ; /* This shouldn't happen */ else if ((intf->channels[chan].medium == IPMI_CHANNEL_MEDIUM_8023LAN) || (intf->channels[chan].medium == IPMI_CHANNEL_MEDIUM_ASYNC)) - ipmi_inc_stat(intf, sent_lan_command_errs); + intf->sent_lan_command_errs++; else - ipmi_inc_stat(intf, sent_ipmb_command_errs); + intf->sent_ipmb_command_errs++; + spin_unlock_irqrestore(&intf->counter_lock, flags); intf_err_seq(intf, msg->msgid, msg->rsp[2]); - } else + } else { /* The message was sent, start the timer. */ intf_start_seq_timer(intf, msg->msgid); + } ipmi_free_smi_msg(msg); goto out; } - /* - * To preserve message order, if the list is not empty, we - * tack this message onto the end of the list. - */ - run_to_completion = intf->run_to_completion; - if (!run_to_completion) - spin_lock_irqsave(&intf->waiting_msgs_lock, flags); + /* To preserve message order, if the list is not empty, we + tack this message onto the end of the list. */ + spin_lock_irqsave(&intf->waiting_msgs_lock, flags); if (!list_empty(&intf->waiting_msgs)) { list_add_tail(&msg->link, &intf->waiting_msgs); - if (!run_to_completion) - spin_unlock_irqrestore(&intf->waiting_msgs_lock, flags); + spin_unlock_irqrestore(&intf->waiting_msgs_lock, flags); goto out; } - if (!run_to_completion) - spin_unlock_irqrestore(&intf->waiting_msgs_lock, flags); - + spin_unlock_irqrestore(&intf->waiting_msgs_lock, flags); + rv = handle_new_recv_msg(intf, msg); if (rv > 0) { - /* - * Could not handle the message now, just add it to a - * list to handle later. - */ - run_to_completion = intf->run_to_completion; - if (!run_to_completion) - spin_lock_irqsave(&intf->waiting_msgs_lock, flags); + /* Could not handle the message now, just add it to a + list to handle later. */ + spin_lock_irqsave(&intf->waiting_msgs_lock, flags); list_add_tail(&msg->link, &intf->waiting_msgs); - if (!run_to_completion) - spin_unlock_irqrestore(&intf->waiting_msgs_lock, flags); + spin_unlock_irqrestore(&intf->waiting_msgs_lock, flags); } else if (rv == 0) { ipmi_free_smi_msg(msg); } @@ -3662,7 +3530,6 @@ void ipmi_smi_msg_received(ipmi_smi_t intf, out: return; } -EXPORT_SYMBOL(ipmi_smi_msg_received); void ipmi_smi_watchdog_pretimeout(ipmi_smi_t intf) { @@ -3677,7 +3544,7 @@ void ipmi_smi_watchdog_pretimeout(ipmi_smi_t intf) } rcu_read_unlock(); } -EXPORT_SYMBOL(ipmi_smi_watchdog_pretimeout); + static struct ipmi_smi_msg * smi_from_recv_msg(ipmi_smi_t intf, struct ipmi_recv_msg *recv_msg, @@ -3685,16 +3552,14 @@ smi_from_recv_msg(ipmi_smi_t intf, struct ipmi_recv_msg *recv_msg, { struct ipmi_smi_msg *smi_msg = ipmi_alloc_smi_msg(); if (!smi_msg) - /* - * If we can't allocate the message, then just return, we - * get 4 retries, so this should be ok. - */ + /* If we can't allocate the message, then just return, we + get 4 retries, so this should be ok. */ return NULL; memcpy(smi_msg->data, recv_msg->msg.data, recv_msg->msg.data_len); smi_msg->data_size = recv_msg->msg.data_len; smi_msg->msgid = STORE_SEQ_IN_MSGID(seq, seqid); - + #ifdef DEBUG_MSGING { int m; @@ -3729,26 +3594,28 @@ static void check_msg_timeout(ipmi_smi_t intf, struct seq_table *ent, ent->inuse = 0; msg = ent->recv_msg; list_add_tail(&msg->link, timeouts); + spin_lock(&intf->counter_lock); if (ent->broadcast) - ipmi_inc_stat(intf, timed_out_ipmb_broadcasts); + intf->timed_out_ipmb_broadcasts++; else if (ent->recv_msg->addr.addr_type == IPMI_LAN_ADDR_TYPE) - ipmi_inc_stat(intf, timed_out_lan_commands); + intf->timed_out_lan_commands++; else - ipmi_inc_stat(intf, timed_out_ipmb_commands); + intf->timed_out_ipmb_commands++; + spin_unlock(&intf->counter_lock); } else { struct ipmi_smi_msg *smi_msg; /* More retries, send again. */ - /* - * Start with the max timer, set to normal timer after - * the message is sent. - */ + /* Start with the max timer, set to normal + timer after the message is sent. */ ent->timeout = MAX_MSG_TIMEOUT; ent->retries_left--; + spin_lock(&intf->counter_lock); if (ent->recv_msg->addr.addr_type == IPMI_LAN_ADDR_TYPE) - ipmi_inc_stat(intf, retransmitted_lan_commands); + intf->retransmitted_lan_commands++; else - ipmi_inc_stat(intf, retransmitted_ipmb_commands); + intf->retransmitted_ipmb_commands++; + spin_unlock(&intf->counter_lock); smi_msg = smi_from_recv_msg(intf, ent->recv_msg, slot, ent->seqid); @@ -3757,13 +3624,11 @@ static void check_msg_timeout(ipmi_smi_t intf, struct seq_table *ent, spin_unlock_irqrestore(&intf->seq_lock, *flags); - /* - * Send the new message. We send with a zero - * priority. It timed out, I doubt time is that - * critical now, and high priority messages are really - * only for messages to the local MC, which don't get - * resent. - */ + /* Send the new message. We send with a zero + * priority. It timed out, I doubt time is + * that critical now, and high priority + * messages are really only for messages to the + * local MC, which don't get resent. */ handlers = intf->handlers; if (handlers) intf->handlers->sender(intf->send_info, @@ -3794,20 +3659,16 @@ static void ipmi_timeout_handler(long timeout_period) list_del(&smi_msg->link); ipmi_free_smi_msg(smi_msg); } else { - /* - * To preserve message order, quit if we - * can't handle a message. - */ + /* To preserve message order, quit if we + can't handle a message. */ break; } } spin_unlock_irqrestore(&intf->waiting_msgs_lock, flags); - /* - * Go through the seq table and find any messages that - * have timed out, putting them in the timeouts - * list. - */ + /* Go through the seq table and find any messages that + have timed out, putting them in the timeouts + list. */ INIT_LIST_HEAD(&timeouts); spin_lock_irqsave(&intf->seq_lock, flags); for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++) @@ -3833,7 +3694,8 @@ static void ipmi_timeout_handler(long timeout_period) intf->auto_maintenance_timeout -= timeout_period; if (!intf->maintenance_mode - && (intf->auto_maintenance_timeout <= 0)) { + && (intf->auto_maintenance_timeout <= 0)) + { intf->maintenance_mode_enable = 0; maintenance_mode_update(intf); } @@ -3851,10 +3713,8 @@ static void ipmi_request_event(void) struct ipmi_smi_handlers *handlers; rcu_read_lock(); - /* - * Called from the timer, no need to check if handlers is - * valid. - */ + /* Called from the timer, no need to check if handlers is + * valid. */ list_for_each_entry_rcu(intf, &ipmi_interfaces, link) { /* No event requests when in maintenance mode. */ if (intf->maintenance_mode_enable) @@ -3875,12 +3735,10 @@ static struct timer_list ipmi_timer; /* How many jiffies does it take to get to the timeout time. */ #define IPMI_TIMEOUT_JIFFIES ((IPMI_TIMEOUT_TIME * HZ) / 1000) -/* - * Request events from the queue every second (this is the number of - * IPMI_TIMEOUT_TIMES between event requests). Hopefully, in the - * future, IPMI will add a way to know immediately if an event is in - * the queue and this silliness can go away. - */ +/* Request events from the queue every second (this is the number of + IPMI_TIMEOUT_TIMES between event requests). Hopefully, in the + future, IPMI will add a way to know immediately if an event is in + the queue and this silliness can go away. */ #define IPMI_REQUEST_EV_TIME (1000 / (IPMI_TIMEOUT_TIME)) static atomic_t stop_operation; @@ -3924,7 +3782,6 @@ struct ipmi_smi_msg *ipmi_alloc_smi_msg(void) } return rv; } -EXPORT_SYMBOL(ipmi_alloc_smi_msg); static void free_recv_msg(struct ipmi_recv_msg *msg) { @@ -3932,7 +3789,7 @@ static void free_recv_msg(struct ipmi_recv_msg *msg) kfree(msg); } -static struct ipmi_recv_msg *ipmi_alloc_recv_msg(void) +struct ipmi_recv_msg *ipmi_alloc_recv_msg(void) { struct ipmi_recv_msg *rv; @@ -3951,7 +3808,6 @@ void ipmi_free_recv_msg(struct ipmi_recv_msg *msg) kref_put(&msg->user->refcount, free_user); msg->done(msg); } -EXPORT_SYMBOL(ipmi_free_recv_msg); #ifdef CONFIG_IPMI_PANIC_EVENT @@ -3969,7 +3825,8 @@ static void event_receiver_fetcher(ipmi_smi_t intf, struct ipmi_recv_msg *msg) if ((msg->addr.addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE) && (msg->msg.netfn == IPMI_NETFN_SENSOR_EVENT_RESPONSE) && (msg->msg.cmd == IPMI_GET_EVENT_RECEIVER_CMD) - && (msg->msg.data[0] == IPMI_CC_NO_ERROR)) { + && (msg->msg.data[0] == IPMI_CC_NO_ERROR)) + { /* A get event receiver command, save it. */ intf->event_receiver = msg->msg.data[1]; intf->event_receiver_lun = msg->msg.data[2] & 0x3; @@ -3981,11 +3838,10 @@ static void device_id_fetcher(ipmi_smi_t intf, struct ipmi_recv_msg *msg) if ((msg->addr.addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE) && (msg->msg.netfn == IPMI_NETFN_APP_RESPONSE) && (msg->msg.cmd == IPMI_GET_DEVICE_ID_CMD) - && (msg->msg.data[0] == IPMI_CC_NO_ERROR)) { - /* - * A get device id command, save if we are an event - * receiver or generator. - */ + && (msg->msg.data[0] == IPMI_CC_NO_ERROR)) + { + /* A get device id command, save if we are an event + receiver or generator. */ intf->local_sel_device = (msg->msg.data[6] >> 2) & 1; intf->local_event_generator = (msg->msg.data[6] >> 5) & 1; } @@ -4018,10 +3874,8 @@ static void send_panic_events(char *str) data[4] = 0x6f; /* Sensor specific, IPMI table 36-1 */ data[5] = 0xa1; /* Runtime stop OEM bytes 2 & 3. */ - /* - * Put a few breadcrumbs in. Hopefully later we can add more things - * to make the panic events more useful. - */ + /* Put a few breadcrumbs in. Hopefully later we can add more things + to make the panic events more useful. */ if (str) { data[3] = str[0]; data[6] = str[1]; @@ -4037,7 +3891,6 @@ static void send_panic_events(char *str) /* Interface is not ready. */ continue; - intf->run_to_completion = 1; /* Send the event announcing the panic. */ intf->handlers->set_run_to_completion(intf->send_info, 1); i_ipmi_request(NULL, @@ -4055,11 +3908,9 @@ static void send_panic_events(char *str) } #ifdef CONFIG_IPMI_PANIC_STRING - /* - * On every interface, dump a bunch of OEM event holding the - * string. - */ - if (!str) + /* On every interface, dump a bunch of OEM event holding the + string. */ + if (!str) return; /* For every registered interface, send the event. */ @@ -4080,13 +3931,11 @@ static void send_panic_events(char *str) */ smp_rmb(); - /* - * First job here is to figure out where to send the - * OEM events. There's no way in IPMI to send OEM - * events using an event send command, so we have to - * find the SEL to put them in and stick them in - * there. - */ + /* First job here is to figure out where to send the + OEM events. There's no way in IPMI to send OEM + events using an event send command, so we have to + find the SEL to put them in and stick them in + there. */ /* Get capabilities from the get device id. */ intf->local_sel_device = 0; @@ -4134,29 +3983,24 @@ static void send_panic_events(char *str) } intf->null_user_handler = NULL; - /* - * Validate the event receiver. The low bit must not - * be 1 (it must be a valid IPMB address), it cannot - * be zero, and it must not be my address. - */ - if (((intf->event_receiver & 1) == 0) + /* Validate the event receiver. The low bit must not + be 1 (it must be a valid IPMB address), it cannot + be zero, and it must not be my address. */ + if (((intf->event_receiver & 1) == 0) && (intf->event_receiver != 0) - && (intf->event_receiver != intf->channels[0].address)) { - /* - * The event receiver is valid, send an IPMB - * message. - */ + && (intf->event_receiver != intf->channels[0].address)) + { + /* The event receiver is valid, send an IPMB + message. */ ipmb = (struct ipmi_ipmb_addr *) &addr; ipmb->addr_type = IPMI_IPMB_ADDR_TYPE; ipmb->channel = 0; /* FIXME - is this right? */ ipmb->lun = intf->event_receiver_lun; ipmb->slave_addr = intf->event_receiver; } else if (intf->local_sel_device) { - /* - * The event receiver was not valid (or was - * me), but I am an SEL device, just dump it - * in my SEL. - */ + /* The event receiver was not valid (or was + me), but I am an SEL device, just dump it + in my SEL. */ si = (struct ipmi_system_interface_addr *) &addr; si->addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; si->channel = IPMI_BMC_CHANNEL; @@ -4164,6 +4008,7 @@ static void send_panic_events(char *str) } else continue; /* No where to send the event. */ + msg.netfn = IPMI_NETFN_STORAGE_REQUEST; /* Storage. */ msg.cmd = IPMI_ADD_SEL_ENTRY_CMD; msg.data = data; @@ -4180,10 +4025,8 @@ static void send_panic_events(char *str) data[2] = 0xf0; /* OEM event without timestamp. */ data[3] = intf->channels[0].address; data[4] = j++; /* sequence # */ - /* - * Always give 11 bytes, so strncpy will fill - * it with zeroes for me. - */ + /* Always give 11 bytes, so strncpy will fill + it with zeroes for me. */ strncpy(data+5, p, 11); p += size; @@ -4200,7 +4043,7 @@ static void send_panic_events(char *str) intf->channels[0].lun, 0, 1); /* no retry, and no wait. */ } - } + } #endif /* CONFIG_IPMI_PANIC_STRING */ } #endif /* CONFIG_IPMI_PANIC_EVENT */ @@ -4209,7 +4052,7 @@ static int has_panicked; static int panic_event(struct notifier_block *this, unsigned long event, - void *ptr) + void *ptr) { ipmi_smi_t intf; @@ -4223,7 +4066,6 @@ static int panic_event(struct notifier_block *this, /* Interface is not ready. */ continue; - intf->run_to_completion = 1; intf->handlers->set_run_to_completion(intf->send_info, 1); } @@ -4291,16 +4133,11 @@ static __exit void cleanup_ipmi(void) atomic_notifier_chain_unregister(&panic_notifier_list, &panic_block); - /* - * This can't be called if any interfaces exist, so no worry - * about shutting down the interfaces. - */ + /* This can't be called if any interfaces exist, so no worry about + shutting down the interfaces. */ - /* - * Tell the timer to stop, then wait for it to stop. This - * avoids problems with race conditions removing the timer - * here. - */ + /* Tell the timer to stop, then wait for it to stop. This avoids + problems with race conditions removing the timer here. */ atomic_inc(&stop_operation); del_timer_sync(&ipmi_timer); @@ -4327,6 +4164,31 @@ module_exit(cleanup_ipmi); module_init(ipmi_init_msghandler_mod); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Corey Minyard "); -MODULE_DESCRIPTION("Incoming and outgoing message routing for an IPMI" - " interface."); +MODULE_DESCRIPTION("Incoming and outgoing message routing for an IPMI interface."); MODULE_VERSION(IPMI_DRIVER_VERSION); + +EXPORT_SYMBOL(ipmi_create_user); +EXPORT_SYMBOL(ipmi_destroy_user); +EXPORT_SYMBOL(ipmi_get_version); +EXPORT_SYMBOL(ipmi_request_settime); +EXPORT_SYMBOL(ipmi_request_supply_msgs); +EXPORT_SYMBOL(ipmi_poll_interface); +EXPORT_SYMBOL(ipmi_register_smi); +EXPORT_SYMBOL(ipmi_unregister_smi); +EXPORT_SYMBOL(ipmi_register_for_cmd); +EXPORT_SYMBOL(ipmi_unregister_for_cmd); +EXPORT_SYMBOL(ipmi_smi_msg_received); +EXPORT_SYMBOL(ipmi_smi_watchdog_pretimeout); +EXPORT_SYMBOL(ipmi_alloc_smi_msg); +EXPORT_SYMBOL(ipmi_addr_length); +EXPORT_SYMBOL(ipmi_validate_addr); +EXPORT_SYMBOL(ipmi_set_gets_events); +EXPORT_SYMBOL(ipmi_smi_watcher_register); +EXPORT_SYMBOL(ipmi_smi_watcher_unregister); +EXPORT_SYMBOL(ipmi_set_my_address); +EXPORT_SYMBOL(ipmi_get_my_address); +EXPORT_SYMBOL(ipmi_set_my_LUN); +EXPORT_SYMBOL(ipmi_get_my_LUN); +EXPORT_SYMBOL(ipmi_smi_add_proc_entry); +EXPORT_SYMBOL(ipmi_user_set_run_to_completion); +EXPORT_SYMBOL(ipmi_free_recv_msg); diff --git a/trunk/drivers/char/ipmi/ipmi_poweroff.c b/trunk/drivers/char/ipmi/ipmi_poweroff.c index a261bd735dfb..b86186de7f07 100644 --- a/trunk/drivers/char/ipmi/ipmi_poweroff.c +++ b/trunk/drivers/char/ipmi/ipmi_poweroff.c @@ -87,10 +87,7 @@ MODULE_PARM_DESC(ifnum_to_use, "The interface number to use for the watchdog " /* parameter definition to allow user to flag power cycle */ module_param(poweroff_powercycle, int, 0644); -MODULE_PARM_DESC(poweroff_powercycle, - " Set to non-zero to enable power cycle instead of power" - " down. Power cycle is contingent on hardware support," - " otherwise it defaults back to power down."); +MODULE_PARM_DESC(poweroff_powercycle, " Set to non-zero to enable power cycle instead of power down. Power cycle is contingent on hardware support, otherwise it defaults back to power down."); /* Stuff from the get device id command. */ static unsigned int mfg_id; @@ -98,25 +95,22 @@ static unsigned int prod_id; static unsigned char capabilities; static unsigned char ipmi_version; -/* - * We use our own messages for this operation, we don't let the system - * allocate them, since we may be in a panic situation. The whole - * thing is single-threaded, anyway, so multiple messages are not - * required. - */ -static atomic_t dummy_count = ATOMIC_INIT(0); +/* We use our own messages for this operation, we don't let the system + allocate them, since we may be in a panic situation. The whole + thing is single-threaded, anyway, so multiple messages are not + required. */ static void dummy_smi_free(struct ipmi_smi_msg *msg) { - atomic_dec(&dummy_count); } static void dummy_recv_free(struct ipmi_recv_msg *msg) { - atomic_dec(&dummy_count); } -static struct ipmi_smi_msg halt_smi_msg = { +static struct ipmi_smi_msg halt_smi_msg = +{ .done = dummy_smi_free }; -static struct ipmi_recv_msg halt_recv_msg = { +static struct ipmi_recv_msg halt_recv_msg = +{ .done = dummy_recv_free }; @@ -133,7 +127,8 @@ static void receive_handler(struct ipmi_recv_msg *recv_msg, void *handler_data) complete(comp); } -static struct ipmi_user_hndl ipmi_poweroff_handler = { +static struct ipmi_user_hndl ipmi_poweroff_handler = +{ .ipmi_recv_hndl = receive_handler }; @@ -157,28 +152,17 @@ static int ipmi_request_wait_for_response(ipmi_user_t user, return halt_recv_msg.msg.data[0]; } -/* Wait for message to complete, spinning. */ +/* We are in run-to-completion mode, no completion is desired. */ static int ipmi_request_in_rc_mode(ipmi_user_t user, struct ipmi_addr *addr, struct kernel_ipmi_msg *send_msg) { int rv; - atomic_set(&dummy_count, 2); rv = ipmi_request_supply_msgs(user, addr, 0, send_msg, NULL, &halt_smi_msg, &halt_recv_msg, 0); - if (rv) { - atomic_set(&dummy_count, 0); + if (rv) return rv; - } - - /* - * Spin until our message is done. - */ - while (atomic_read(&dummy_count) > 0) { - ipmi_poll_interface(user); - cpu_relax(); - } return halt_recv_msg.msg.data[0]; } @@ -200,47 +184,47 @@ static int ipmi_request_in_rc_mode(ipmi_user_t user, static void (*atca_oem_poweroff_hook)(ipmi_user_t user); -static void pps_poweroff_atca(ipmi_user_t user) +static void pps_poweroff_atca (ipmi_user_t user) { - struct ipmi_system_interface_addr smi_addr; - struct kernel_ipmi_msg send_msg; - int rv; - /* - * Configure IPMI address for local access - */ - smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; - smi_addr.channel = IPMI_BMC_CHANNEL; - smi_addr.lun = 0; - - printk(KERN_INFO PFX "PPS powerdown hook used"); - - send_msg.netfn = IPMI_NETFN_OEM; - send_msg.cmd = IPMI_ATCA_PPS_GRACEFUL_RESTART; - send_msg.data = IPMI_ATCA_PPS_IANA; - send_msg.data_len = 3; - rv = ipmi_request_in_rc_mode(user, - (struct ipmi_addr *) &smi_addr, - &send_msg); - if (rv && rv != IPMI_UNKNOWN_ERR_COMPLETION_CODE) { - printk(KERN_ERR PFX "Unable to send ATCA ," - " IPMI error 0x%x\n", rv); - } + struct ipmi_system_interface_addr smi_addr; + struct kernel_ipmi_msg send_msg; + int rv; + /* + * Configure IPMI address for local access + */ + smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; + smi_addr.channel = IPMI_BMC_CHANNEL; + smi_addr.lun = 0; + + printk(KERN_INFO PFX "PPS powerdown hook used"); + + send_msg.netfn = IPMI_NETFN_OEM; + send_msg.cmd = IPMI_ATCA_PPS_GRACEFUL_RESTART; + send_msg.data = IPMI_ATCA_PPS_IANA; + send_msg.data_len = 3; + rv = ipmi_request_in_rc_mode(user, + (struct ipmi_addr *) &smi_addr, + &send_msg); + if (rv && rv != IPMI_UNKNOWN_ERR_COMPLETION_CODE) { + printk(KERN_ERR PFX "Unable to send ATCA ," + " IPMI error 0x%x\n", rv); + } return; } -static int ipmi_atca_detect(ipmi_user_t user) +static int ipmi_atca_detect (ipmi_user_t user) { struct ipmi_system_interface_addr smi_addr; struct kernel_ipmi_msg send_msg; int rv; unsigned char data[1]; - /* - * Configure IPMI address for local access - */ - smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; - smi_addr.channel = IPMI_BMC_CHANNEL; - smi_addr.lun = 0; + /* + * Configure IPMI address for local access + */ + smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; + smi_addr.channel = IPMI_BMC_CHANNEL; + smi_addr.lun = 0; /* * Use get address info to check and see if we are ATCA @@ -254,30 +238,28 @@ static int ipmi_atca_detect(ipmi_user_t user) (struct ipmi_addr *) &smi_addr, &send_msg); - printk(KERN_INFO PFX "ATCA Detect mfg 0x%X prod 0x%X\n", - mfg_id, prod_id); - if ((mfg_id == IPMI_MOTOROLA_MANUFACTURER_ID) - && (prod_id == IPMI_MOTOROLA_PPS_IPMC_PRODUCT_ID)) { - printk(KERN_INFO PFX - "Installing Pigeon Point Systems Poweroff Hook\n"); + printk(KERN_INFO PFX "ATCA Detect mfg 0x%X prod 0x%X\n", mfg_id, prod_id); + if((mfg_id == IPMI_MOTOROLA_MANUFACTURER_ID) + && (prod_id == IPMI_MOTOROLA_PPS_IPMC_PRODUCT_ID)) { + printk(KERN_INFO PFX "Installing Pigeon Point Systems Poweroff Hook\n"); atca_oem_poweroff_hook = pps_poweroff_atca; } return !rv; } -static void ipmi_poweroff_atca(ipmi_user_t user) +static void ipmi_poweroff_atca (ipmi_user_t user) { struct ipmi_system_interface_addr smi_addr; struct kernel_ipmi_msg send_msg; int rv; unsigned char data[4]; - /* - * Configure IPMI address for local access - */ - smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; - smi_addr.channel = IPMI_BMC_CHANNEL; - smi_addr.lun = 0; + /* + * Configure IPMI address for local access + */ + smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; + smi_addr.channel = IPMI_BMC_CHANNEL; + smi_addr.lun = 0; printk(KERN_INFO PFX "Powering down via ATCA power command\n"); @@ -291,24 +273,23 @@ static void ipmi_poweroff_atca(ipmi_user_t user) data[2] = 0; /* Power Level */ data[3] = 0; /* Don't change saved presets */ send_msg.data = data; - send_msg.data_len = sizeof(data); + send_msg.data_len = sizeof (data); rv = ipmi_request_in_rc_mode(user, (struct ipmi_addr *) &smi_addr, &send_msg); - /* - * At this point, the system may be shutting down, and most - * serial drivers (if used) will have interrupts turned off - * it may be better to ignore IPMI_UNKNOWN_ERR_COMPLETION_CODE - * return code - */ - if (rv && rv != IPMI_UNKNOWN_ERR_COMPLETION_CODE) { + /** At this point, the system may be shutting down, and most + ** serial drivers (if used) will have interrupts turned off + ** it may be better to ignore IPMI_UNKNOWN_ERR_COMPLETION_CODE + ** return code + **/ + if (rv && rv != IPMI_UNKNOWN_ERR_COMPLETION_CODE) { printk(KERN_ERR PFX "Unable to send ATCA powerdown message," " IPMI error 0x%x\n", rv); goto out; } - if (atca_oem_poweroff_hook) - atca_oem_poweroff_hook(user); + if(atca_oem_poweroff_hook) + return atca_oem_poweroff_hook(user); out: return; } @@ -329,13 +310,13 @@ static void ipmi_poweroff_atca(ipmi_user_t user) #define IPMI_CPI1_PRODUCT_ID 0x000157 #define IPMI_CPI1_MANUFACTURER_ID 0x0108 -static int ipmi_cpi1_detect(ipmi_user_t user) +static int ipmi_cpi1_detect (ipmi_user_t user) { return ((mfg_id == IPMI_CPI1_MANUFACTURER_ID) && (prod_id == IPMI_CPI1_PRODUCT_ID)); } -static void ipmi_poweroff_cpi1(ipmi_user_t user) +static void ipmi_poweroff_cpi1 (ipmi_user_t user) { struct ipmi_system_interface_addr smi_addr; struct ipmi_ipmb_addr ipmb_addr; @@ -347,12 +328,12 @@ static void ipmi_poweroff_cpi1(ipmi_user_t user) unsigned char aer_addr; unsigned char aer_lun; - /* - * Configure IPMI address for local access - */ - smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; - smi_addr.channel = IPMI_BMC_CHANNEL; - smi_addr.lun = 0; + /* + * Configure IPMI address for local access + */ + smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; + smi_addr.channel = IPMI_BMC_CHANNEL; + smi_addr.lun = 0; printk(KERN_INFO PFX "Powering down via CPI1 power command\n"); @@ -444,7 +425,7 @@ static void ipmi_poweroff_cpi1(ipmi_user_t user) */ #define DELL_IANA_MFR_ID {0xA2, 0x02, 0x00} -static int ipmi_dell_chassis_detect(ipmi_user_t user) +static int ipmi_dell_chassis_detect (ipmi_user_t user) { const char ipmi_version_major = ipmi_version & 0xF; const char ipmi_version_minor = (ipmi_version >> 4) & 0xF; @@ -463,25 +444,25 @@ static int ipmi_dell_chassis_detect(ipmi_user_t user) #define IPMI_NETFN_CHASSIS_REQUEST 0 #define IPMI_CHASSIS_CONTROL_CMD 0x02 -static int ipmi_chassis_detect(ipmi_user_t user) +static int ipmi_chassis_detect (ipmi_user_t user) { /* Chassis support, use it. */ return (capabilities & 0x80); } -static void ipmi_poweroff_chassis(ipmi_user_t user) +static void ipmi_poweroff_chassis (ipmi_user_t user) { struct ipmi_system_interface_addr smi_addr; struct kernel_ipmi_msg send_msg; int rv; unsigned char data[1]; - /* - * Configure IPMI address for local access - */ - smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; - smi_addr.channel = IPMI_BMC_CHANNEL; - smi_addr.lun = 0; + /* + * Configure IPMI address for local access + */ + smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; + smi_addr.channel = IPMI_BMC_CHANNEL; + smi_addr.lun = 0; powercyclefailed: printk(KERN_INFO PFX "Powering %s via IPMI chassis control command\n", @@ -544,13 +525,15 @@ static struct poweroff_function poweroff_functions[] = { /* Called on a powerdown request. */ -static void ipmi_poweroff_function(void) +static void ipmi_poweroff_function (void) { if (!ready) return; /* Use run-to-completion mode, since interrupts may be off. */ + ipmi_user_set_run_to_completion(ipmi_user, 1); specific_poweroff_func(ipmi_user); + ipmi_user_set_run_to_completion(ipmi_user, 0); } /* Wait for an IPMI interface to be installed, the first one installed @@ -578,13 +561,13 @@ static void ipmi_po_new_smi(int if_num, struct device *device) ipmi_ifnum = if_num; - /* - * Do a get device ide and store some results, since this is + /* + * Do a get device ide and store some results, since this is * used by several functions. - */ - smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; - smi_addr.channel = IPMI_BMC_CHANNEL; - smi_addr.lun = 0; + */ + smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; + smi_addr.channel = IPMI_BMC_CHANNEL; + smi_addr.lun = 0; send_msg.netfn = IPMI_NETFN_APP_REQUEST; send_msg.cmd = IPMI_GET_DEVICE_ID_CMD; @@ -649,7 +632,8 @@ static void ipmi_po_smi_gone(int if_num) pm_power_off = old_poweroff_func; } -static struct ipmi_smi_watcher smi_watcher = { +static struct ipmi_smi_watcher smi_watcher = +{ .owner = THIS_MODULE, .new_smi = ipmi_po_new_smi, .smi_gone = ipmi_po_smi_gone @@ -691,12 +675,12 @@ static struct ctl_table_header *ipmi_table_header; /* * Startup and shutdown functions. */ -static int ipmi_poweroff_init(void) +static int ipmi_poweroff_init (void) { int rv; - printk(KERN_INFO "Copyright (C) 2004 MontaVista Software -" - " IPMI Powerdown via sys_reboot.\n"); + printk (KERN_INFO "Copyright (C) 2004 MontaVista Software -" + " IPMI Powerdown via sys_reboot.\n"); if (poweroff_powercycle) printk(KERN_INFO PFX "Power cycle is enabled.\n"); diff --git a/trunk/drivers/char/ipmi/ipmi_si_intf.c b/trunk/drivers/char/ipmi/ipmi_si_intf.c index 5a5455585c1d..4f560d0bb808 100644 --- a/trunk/drivers/char/ipmi/ipmi_si_intf.c +++ b/trunk/drivers/char/ipmi/ipmi_si_intf.c @@ -80,7 +80,7 @@ #define SI_USEC_PER_JIFFY (1000000/HZ) #define SI_TIMEOUT_JIFFIES (SI_TIMEOUT_TIME_USEC/SI_USEC_PER_JIFFY) #define SI_SHORT_TIMEOUT_USEC 250 /* .25ms when the SM request a - short timeout */ + short timeout */ /* Bit for BMC global enables. */ #define IPMI_BMC_RCV_MSG_INTR 0x01 @@ -114,61 +114,14 @@ static char *si_to_str[] = { "kcs", "smic", "bt" }; #define DEVICE_NAME "ipmi_si" -static struct device_driver ipmi_driver = { +static struct device_driver ipmi_driver = +{ .name = DEVICE_NAME, .bus = &platform_bus_type }; - -/* - * Indexes into stats[] in smi_info below. - */ -enum si_stat_indexes { - /* - * Number of times the driver requested a timer while an operation - * was in progress. - */ - SI_STAT_short_timeouts = 0, - - /* - * Number of times the driver requested a timer while nothing was in - * progress. - */ - SI_STAT_long_timeouts, - - /* Number of times the interface was idle while being polled. */ - SI_STAT_idles, - - /* Number of interrupts the driver handled. */ - SI_STAT_interrupts, - - /* Number of time the driver got an ATTN from the hardware. */ - SI_STAT_attentions, - - /* Number of times the driver requested flags from the hardware. */ - SI_STAT_flag_fetches, - - /* Number of times the hardware didn't follow the state machine. */ - SI_STAT_hosed_count, - - /* Number of completed messages. */ - SI_STAT_complete_transactions, - - /* Number of IPMI events received from the hardware. */ - SI_STAT_events, - - /* Number of watchdog pretimeouts. */ - SI_STAT_watchdog_pretimeouts, - - /* Number of asyncronous messages received. */ - SI_STAT_incoming_messages, - - - /* This *must* remain last, add new values above this. */ - SI_NUM_STATS -}; - -struct smi_info { +struct smi_info +{ int intf_num; ipmi_smi_t intf; struct si_sm_data *si_sm; @@ -181,10 +134,8 @@ struct smi_info { struct ipmi_smi_msg *curr_msg; enum si_intf_state si_state; - /* - * Used to handle the various types of I/O that can occur with - * IPMI - */ + /* Used to handle the various types of I/O that can occur with + IPMI */ struct si_sm_io io; int (*io_setup)(struct smi_info *info); void (*io_cleanup)(struct smi_info *info); @@ -195,18 +146,15 @@ struct smi_info { void (*addr_source_cleanup)(struct smi_info *info); void *addr_source_data; - /* - * Per-OEM handler, called from handle_flags(). Returns 1 - * when handle_flags() needs to be re-run or 0 indicating it - * set si_state itself. - */ + /* Per-OEM handler, called from handle_flags(). + Returns 1 when handle_flags() needs to be re-run + or 0 indicating it set si_state itself. + */ int (*oem_data_avail_handler)(struct smi_info *smi_info); - /* - * Flags from the last GET_MSG_FLAGS command, used when an ATTN - * is set to hold the flags until we are done handling everything - * from the flags. - */ + /* Flags from the last GET_MSG_FLAGS command, used when an ATTN + is set to hold the flags until we are done handling everything + from the flags. */ #define RECEIVE_MSG_AVAIL 0x01 #define EVENT_MSG_BUFFER_FULL 0x02 #define WDT_PRE_TIMEOUT_INT 0x08 @@ -214,31 +162,25 @@ struct smi_info { #define OEM1_DATA_AVAIL 0x40 #define OEM2_DATA_AVAIL 0x80 #define OEM_DATA_AVAIL (OEM0_DATA_AVAIL | \ - OEM1_DATA_AVAIL | \ - OEM2_DATA_AVAIL) + OEM1_DATA_AVAIL | \ + OEM2_DATA_AVAIL) unsigned char msg_flags; - /* - * If set to true, this will request events the next time the - * state machine is idle. - */ + /* If set to true, this will request events the next time the + state machine is idle. */ atomic_t req_events; - /* - * If true, run the state machine to completion on every send - * call. Generally used after a panic to make sure stuff goes - * out. - */ + /* If true, run the state machine to completion on every send + call. Generally used after a panic to make sure stuff goes + out. */ int run_to_completion; /* The I/O port of an SI interface. */ int port; - /* - * The space between start addresses of the two ports. For - * instance, if the first port is 0xca2 and the spacing is 4, then - * the second port is 0xca6. - */ + /* The space between start addresses of the two ports. For + instance, if the first port is 0xca2 and the spacing is 4, then + the second port is 0xca6. */ unsigned int spacing; /* zero if no irq; */ @@ -253,12 +195,10 @@ struct smi_info { /* Used to gracefully stop the timer without race conditions. */ atomic_t stop_operation; - /* - * The driver will disable interrupts when it gets into a - * situation where it cannot handle messages due to lack of - * memory. Once that situation clears up, it will re-enable - * interrupts. - */ + /* The driver will disable interrupts when it gets into a + situation where it cannot handle messages due to lack of + memory. Once that situation clears up, it will re-enable + interrupts. */ int interrupt_disabled; /* From the get device id response... */ @@ -268,28 +208,33 @@ struct smi_info { struct device *dev; struct platform_device *pdev; - /* - * True if we allocated the device, false if it came from - * someplace else (like PCI). - */ + /* True if we allocated the device, false if it came from + * someplace else (like PCI). */ int dev_registered; /* Slave address, could be reported from DMI. */ unsigned char slave_addr; /* Counters and things for the proc filesystem. */ - atomic_t stats[SI_NUM_STATS]; - - struct task_struct *thread; + spinlock_t count_lock; + unsigned long short_timeouts; + unsigned long long_timeouts; + unsigned long timeout_restarts; + unsigned long idles; + unsigned long interrupts; + unsigned long attentions; + unsigned long flag_fetches; + unsigned long hosed_count; + unsigned long complete_transactions; + unsigned long events; + unsigned long watchdog_pretimeouts; + unsigned long incoming_messages; + + struct task_struct *thread; struct list_head link; }; -#define smi_inc_stat(smi, stat) \ - atomic_inc(&(smi)->stats[SI_STAT_ ## stat]) -#define smi_get_stat(smi, stat) \ - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat])) - #define SI_MAX_PARMS 4 static int force_kipmid[SI_MAX_PARMS]; @@ -301,7 +246,7 @@ static int try_smi_init(struct smi_info *smi); static void cleanup_one_si(struct smi_info *to_clean); static ATOMIC_NOTIFIER_HEAD(xaction_notifier_list); -static int register_xaction_notifier(struct notifier_block *nb) +static int register_xaction_notifier(struct notifier_block * nb) { return atomic_notifier_chain_register(&xaction_notifier_list, nb); } @@ -310,7 +255,7 @@ static void deliver_recv_msg(struct smi_info *smi_info, struct ipmi_smi_msg *msg) { /* Deliver the message to the upper layer with the lock - released. */ + released. */ spin_unlock(&(smi_info->si_lock)); ipmi_smi_msg_received(smi_info->intf, msg); spin_lock(&(smi_info->si_lock)); @@ -342,12 +287,9 @@ static enum si_sm_result start_next_msg(struct smi_info *smi_info) struct timeval t; #endif - /* - * No need to save flags, we aleady have interrupts off and we - * already hold the SMI lock. - */ - if (!smi_info->run_to_completion) - spin_lock(&(smi_info->msg_lock)); + /* No need to save flags, we aleady have interrupts off and we + already hold the SMI lock. */ + spin_lock(&(smi_info->msg_lock)); /* Pick the high priority queue first. */ if (!list_empty(&(smi_info->hp_xmit_msgs))) { @@ -368,7 +310,7 @@ static enum si_sm_result start_next_msg(struct smi_info *smi_info) link); #ifdef DEBUG_TIMING do_gettimeofday(&t); - printk(KERN_DEBUG "**Start2: %d.%9.9d\n", t.tv_sec, t.tv_usec); + printk("**Start2: %d.%9.9d\n", t.tv_sec, t.tv_usec); #endif err = atomic_notifier_call_chain(&xaction_notifier_list, 0, smi_info); @@ -380,14 +322,14 @@ static enum si_sm_result start_next_msg(struct smi_info *smi_info) smi_info->si_sm, smi_info->curr_msg->data, smi_info->curr_msg->data_size); - if (err) + if (err) { return_hosed_msg(smi_info, err); + } rv = SI_SM_CALL_WITHOUT_DELAY; } - out: - if (!smi_info->run_to_completion) - spin_unlock(&(smi_info->msg_lock)); + out: + spin_unlock(&(smi_info->msg_lock)); return rv; } @@ -396,10 +338,8 @@ static void start_enable_irq(struct smi_info *smi_info) { unsigned char msg[2]; - /* - * If we are enabling interrupts, we have to tell the - * BMC to use them. - */ + /* If we are enabling interrupts, we have to tell the + BMC to use them. */ msg[0] = (IPMI_NETFN_APP_REQUEST << 2); msg[1] = IPMI_GET_BMC_GLOBAL_ENABLES_CMD; @@ -431,12 +371,10 @@ static void start_clear_flags(struct smi_info *smi_info) smi_info->si_state = SI_CLEARING_FLAGS; } -/* - * When we have a situtaion where we run out of memory and cannot - * allocate messages, we just leave them in the BMC and run the system - * polled until we can allocate some memory. Once we have some - * memory, we will re-enable the interrupt. - */ +/* When we have a situtaion where we run out of memory and cannot + allocate messages, we just leave them in the BMC and run the system + polled until we can allocate some memory. Once we have some + memory, we will re-enable the interrupt. */ static inline void disable_si_irq(struct smi_info *smi_info) { if ((smi_info->irq) && (!smi_info->interrupt_disabled)) { @@ -458,7 +396,9 @@ static void handle_flags(struct smi_info *smi_info) retry: if (smi_info->msg_flags & WDT_PRE_TIMEOUT_INT) { /* Watchdog pre-timeout */ - smi_inc_stat(smi_info, watchdog_pretimeouts); + spin_lock(&smi_info->count_lock); + smi_info->watchdog_pretimeouts++; + spin_unlock(&smi_info->count_lock); start_clear_flags(smi_info); smi_info->msg_flags &= ~WDT_PRE_TIMEOUT_INT; @@ -504,11 +444,12 @@ static void handle_flags(struct smi_info *smi_info) smi_info->curr_msg->data_size); smi_info->si_state = SI_GETTING_EVENTS; } else if (smi_info->msg_flags & OEM_DATA_AVAIL && - smi_info->oem_data_avail_handler) { + smi_info->oem_data_avail_handler) { if (smi_info->oem_data_avail_handler(smi_info)) goto retry; - } else + } else { smi_info->si_state = SI_NORMAL; + } } static void handle_transaction_done(struct smi_info *smi_info) @@ -518,7 +459,7 @@ static void handle_transaction_done(struct smi_info *smi_info) struct timeval t; do_gettimeofday(&t); - printk(KERN_DEBUG "**Done: %d.%9.9d\n", t.tv_sec, t.tv_usec); + printk("**Done: %d.%9.9d\n", t.tv_sec, t.tv_usec); #endif switch (smi_info->si_state) { case SI_NORMAL: @@ -531,11 +472,9 @@ static void handle_transaction_done(struct smi_info *smi_info) smi_info->curr_msg->rsp, IPMI_MAX_MSG_LENGTH); - /* - * Do this here becase deliver_recv_msg() releases the - * lock, and a new message can be put in during the - * time the lock is released. - */ + /* Do this here becase deliver_recv_msg() releases the + lock, and a new message can be put in during the + time the lock is released. */ msg = smi_info->curr_msg; smi_info->curr_msg = NULL; deliver_recv_msg(smi_info, msg); @@ -549,13 +488,12 @@ static void handle_transaction_done(struct smi_info *smi_info) /* We got the flags from the SMI, now handle them. */ len = smi_info->handlers->get_result(smi_info->si_sm, msg, 4); if (msg[2] != 0) { - /* Error fetching flags, just give up for now. */ + /* Error fetching flags, just give up for + now. */ smi_info->si_state = SI_NORMAL; } else if (len < 4) { - /* - * Hmm, no flags. That's technically illegal, but - * don't use uninitialized data. - */ + /* Hmm, no flags. That's technically illegal, but + don't use uninitialized data. */ smi_info->si_state = SI_NORMAL; } else { smi_info->msg_flags = msg[3]; @@ -592,11 +530,9 @@ static void handle_transaction_done(struct smi_info *smi_info) smi_info->curr_msg->rsp, IPMI_MAX_MSG_LENGTH); - /* - * Do this here becase deliver_recv_msg() releases the - * lock, and a new message can be put in during the - * time the lock is released. - */ + /* Do this here becase deliver_recv_msg() releases the + lock, and a new message can be put in during the + time the lock is released. */ msg = smi_info->curr_msg; smi_info->curr_msg = NULL; if (msg->rsp[2] != 0) { @@ -607,14 +543,14 @@ static void handle_transaction_done(struct smi_info *smi_info) smi_info->msg_flags &= ~EVENT_MSG_BUFFER_FULL; handle_flags(smi_info); } else { - smi_inc_stat(smi_info, events); - - /* - * Do this before we deliver the message - * because delivering the message releases the - * lock and something else can mess with the - * state. - */ + spin_lock(&smi_info->count_lock); + smi_info->events++; + spin_unlock(&smi_info->count_lock); + + /* Do this before we deliver the message + because delivering the message releases the + lock and something else can mess with the + state. */ handle_flags(smi_info); deliver_recv_msg(smi_info, msg); @@ -630,11 +566,9 @@ static void handle_transaction_done(struct smi_info *smi_info) smi_info->curr_msg->rsp, IPMI_MAX_MSG_LENGTH); - /* - * Do this here becase deliver_recv_msg() releases the - * lock, and a new message can be put in during the - * time the lock is released. - */ + /* Do this here becase deliver_recv_msg() releases the + lock, and a new message can be put in during the + time the lock is released. */ msg = smi_info->curr_msg; smi_info->curr_msg = NULL; if (msg->rsp[2] != 0) { @@ -645,14 +579,14 @@ static void handle_transaction_done(struct smi_info *smi_info) smi_info->msg_flags &= ~RECEIVE_MSG_AVAIL; handle_flags(smi_info); } else { - smi_inc_stat(smi_info, incoming_messages); - - /* - * Do this before we deliver the message - * because delivering the message releases the - * lock and something else can mess with the - * state. - */ + spin_lock(&smi_info->count_lock); + smi_info->incoming_messages++; + spin_unlock(&smi_info->count_lock); + + /* Do this before we deliver the message + because delivering the message releases the + lock and something else can mess with the + state. */ handle_flags(smi_info); deliver_recv_msg(smi_info, msg); @@ -740,70 +674,69 @@ static void handle_transaction_done(struct smi_info *smi_info) } } -/* - * Called on timeouts and events. Timeouts should pass the elapsed - * time, interrupts should pass in zero. Must be called with - * si_lock held and interrupts disabled. - */ +/* Called on timeouts and events. Timeouts should pass the elapsed + time, interrupts should pass in zero. Must be called with + si_lock held and interrupts disabled. */ static enum si_sm_result smi_event_handler(struct smi_info *smi_info, int time) { enum si_sm_result si_sm_result; restart: - /* - * There used to be a loop here that waited a little while - * (around 25us) before giving up. That turned out to be - * pointless, the minimum delays I was seeing were in the 300us - * range, which is far too long to wait in an interrupt. So - * we just run until the state machine tells us something - * happened or it needs a delay. - */ + /* There used to be a loop here that waited a little while + (around 25us) before giving up. That turned out to be + pointless, the minimum delays I was seeing were in the 300us + range, which is far too long to wait in an interrupt. So + we just run until the state machine tells us something + happened or it needs a delay. */ si_sm_result = smi_info->handlers->event(smi_info->si_sm, time); time = 0; while (si_sm_result == SI_SM_CALL_WITHOUT_DELAY) + { si_sm_result = smi_info->handlers->event(smi_info->si_sm, 0); + } - if (si_sm_result == SI_SM_TRANSACTION_COMPLETE) { - smi_inc_stat(smi_info, complete_transactions); + if (si_sm_result == SI_SM_TRANSACTION_COMPLETE) + { + spin_lock(&smi_info->count_lock); + smi_info->complete_transactions++; + spin_unlock(&smi_info->count_lock); handle_transaction_done(smi_info); si_sm_result = smi_info->handlers->event(smi_info->si_sm, 0); - } else if (si_sm_result == SI_SM_HOSED) { - smi_inc_stat(smi_info, hosed_count); + } + else if (si_sm_result == SI_SM_HOSED) + { + spin_lock(&smi_info->count_lock); + smi_info->hosed_count++; + spin_unlock(&smi_info->count_lock); - /* - * Do the before return_hosed_msg, because that - * releases the lock. - */ + /* Do the before return_hosed_msg, because that + releases the lock. */ smi_info->si_state = SI_NORMAL; if (smi_info->curr_msg != NULL) { - /* - * If we were handling a user message, format - * a response to send to the upper layer to - * tell it about the error. - */ + /* If we were handling a user message, format + a response to send to the upper layer to + tell it about the error. */ return_hosed_msg(smi_info, IPMI_ERR_UNSPECIFIED); } si_sm_result = smi_info->handlers->event(smi_info->si_sm, 0); } - /* - * We prefer handling attn over new messages. But don't do - * this if there is not yet an upper layer to handle anything. - */ - if (likely(smi_info->intf) && si_sm_result == SI_SM_ATTN) { + /* We prefer handling attn over new messages. */ + if (si_sm_result == SI_SM_ATTN) + { unsigned char msg[2]; - smi_inc_stat(smi_info, attentions); + spin_lock(&smi_info->count_lock); + smi_info->attentions++; + spin_unlock(&smi_info->count_lock); - /* - * Got a attn, send down a get message flags to see - * what's causing it. It would be better to handle - * this in the upper layer, but due to the way - * interrupts work with the SMI, that's not really - * possible. - */ + /* Got a attn, send down a get message flags to see + what's causing it. It would be better to handle + this in the upper layer, but due to the way + interrupts work with the SMI, that's not really + possible. */ msg[0] = (IPMI_NETFN_APP_REQUEST << 2); msg[1] = IPMI_GET_MSG_FLAGS_CMD; @@ -815,19 +748,20 @@ static enum si_sm_result smi_event_handler(struct smi_info *smi_info, /* If we are currently idle, try to start the next message. */ if (si_sm_result == SI_SM_IDLE) { - smi_inc_stat(smi_info, idles); + spin_lock(&smi_info->count_lock); + smi_info->idles++; + spin_unlock(&smi_info->count_lock); si_sm_result = start_next_msg(smi_info); if (si_sm_result != SI_SM_IDLE) goto restart; - } + } if ((si_sm_result == SI_SM_IDLE) - && (atomic_read(&smi_info->req_events))) { - /* - * We are idle and the upper layer requested that I fetch - * events, so do so. - */ + && (atomic_read(&smi_info->req_events))) + { + /* We are idle and the upper layer requested that I fetch + events, so do so. */ atomic_set(&smi_info->req_events, 0); smi_info->curr_msg = ipmi_alloc_smi_msg(); @@ -869,50 +803,56 @@ static void sender(void *send_info, return; } + spin_lock_irqsave(&(smi_info->msg_lock), flags); #ifdef DEBUG_TIMING do_gettimeofday(&t); printk("**Enqueue: %d.%9.9d\n", t.tv_sec, t.tv_usec); #endif if (smi_info->run_to_completion) { - /* - * If we are running to completion, then throw it in - * the list and run transactions until everything is - * clear. Priority doesn't matter here. - */ - - /* - * Run to completion means we are single-threaded, no - * need for locks. - */ + /* If we are running to completion, then throw it in + the list and run transactions until everything is + clear. Priority doesn't matter here. */ list_add_tail(&(msg->link), &(smi_info->xmit_msgs)); + /* We have to release the msg lock and claim the smi + lock in this case, because of race conditions. */ + spin_unlock_irqrestore(&(smi_info->msg_lock), flags); + + spin_lock_irqsave(&(smi_info->si_lock), flags); result = smi_event_handler(smi_info, 0); while (result != SI_SM_IDLE) { udelay(SI_SHORT_TIMEOUT_USEC); result = smi_event_handler(smi_info, SI_SHORT_TIMEOUT_USEC); } + spin_unlock_irqrestore(&(smi_info->si_lock), flags); return; + } else { + if (priority > 0) { + list_add_tail(&(msg->link), &(smi_info->hp_xmit_msgs)); + } else { + list_add_tail(&(msg->link), &(smi_info->xmit_msgs)); + } } + spin_unlock_irqrestore(&(smi_info->msg_lock), flags); - spin_lock_irqsave(&smi_info->msg_lock, flags); - if (priority > 0) - list_add_tail(&msg->link, &smi_info->hp_xmit_msgs); - else - list_add_tail(&msg->link, &smi_info->xmit_msgs); - spin_unlock_irqrestore(&smi_info->msg_lock, flags); - - spin_lock_irqsave(&smi_info->si_lock, flags); - if (smi_info->si_state == SI_NORMAL && smi_info->curr_msg == NULL) + spin_lock_irqsave(&(smi_info->si_lock), flags); + if ((smi_info->si_state == SI_NORMAL) + && (smi_info->curr_msg == NULL)) + { start_next_msg(smi_info); - spin_unlock_irqrestore(&smi_info->si_lock, flags); + } + spin_unlock_irqrestore(&(smi_info->si_lock), flags); } static void set_run_to_completion(void *send_info, int i_run_to_completion) { struct smi_info *smi_info = send_info; enum si_sm_result result; + unsigned long flags; + + spin_lock_irqsave(&(smi_info->si_lock), flags); smi_info->run_to_completion = i_run_to_completion; if (i_run_to_completion) { @@ -923,6 +863,8 @@ static void set_run_to_completion(void *send_info, int i_run_to_completion) SI_SHORT_TIMEOUT_USEC); } } + + spin_unlock_irqrestore(&(smi_info->si_lock), flags); } static int ipmi_thread(void *data) @@ -936,8 +878,9 @@ static int ipmi_thread(void *data) spin_lock_irqsave(&(smi_info->si_lock), flags); smi_result = smi_event_handler(smi_info, 0); spin_unlock_irqrestore(&(smi_info->si_lock), flags); - if (smi_result == SI_SM_CALL_WITHOUT_DELAY) - ; /* do nothing */ + if (smi_result == SI_SM_CALL_WITHOUT_DELAY) { + /* do nothing */ + } else if (smi_result == SI_SM_CALL_WITH_DELAY) schedule(); else @@ -988,7 +931,7 @@ static void smi_timeout(unsigned long data) spin_lock_irqsave(&(smi_info->si_lock), flags); #ifdef DEBUG_TIMING do_gettimeofday(&t); - printk(KERN_DEBUG "**Timer: %d.%9.9d\n", t.tv_sec, t.tv_usec); + printk("**Timer: %d.%9.9d\n", t.tv_sec, t.tv_usec); #endif jiffies_now = jiffies; time_diff = (((long)jiffies_now - (long)smi_info->last_timeout_jiffies) @@ -1002,19 +945,23 @@ static void smi_timeout(unsigned long data) if ((smi_info->irq) && (!smi_info->interrupt_disabled)) { /* Running with interrupts, only do long timeouts. */ smi_info->si_timer.expires = jiffies + SI_TIMEOUT_JIFFIES; - smi_inc_stat(smi_info, long_timeouts); + spin_lock_irqsave(&smi_info->count_lock, flags); + smi_info->long_timeouts++; + spin_unlock_irqrestore(&smi_info->count_lock, flags); goto do_add_timer; } - /* - * If the state machine asks for a short delay, then shorten - * the timer timeout. - */ + /* If the state machine asks for a short delay, then shorten + the timer timeout. */ if (smi_result == SI_SM_CALL_WITH_DELAY) { - smi_inc_stat(smi_info, short_timeouts); + spin_lock_irqsave(&smi_info->count_lock, flags); + smi_info->short_timeouts++; + spin_unlock_irqrestore(&smi_info->count_lock, flags); smi_info->si_timer.expires = jiffies + 1; } else { - smi_inc_stat(smi_info, long_timeouts); + spin_lock_irqsave(&smi_info->count_lock, flags); + smi_info->long_timeouts++; + spin_unlock_irqrestore(&smi_info->count_lock, flags); smi_info->si_timer.expires = jiffies + SI_TIMEOUT_JIFFIES; } @@ -1032,11 +979,13 @@ static irqreturn_t si_irq_handler(int irq, void *data) spin_lock_irqsave(&(smi_info->si_lock), flags); - smi_inc_stat(smi_info, interrupts); + spin_lock(&smi_info->count_lock); + smi_info->interrupts++; + spin_unlock(&smi_info->count_lock); #ifdef DEBUG_TIMING do_gettimeofday(&t); - printk(KERN_DEBUG "**Interrupt: %d.%9.9d\n", t.tv_sec, t.tv_usec); + printk("**Interrupt: %d.%9.9d\n", t.tv_sec, t.tv_usec); #endif smi_event_handler(smi_info, 0); spin_unlock_irqrestore(&(smi_info->si_lock), flags); @@ -1079,7 +1028,7 @@ static int smi_start_processing(void *send_info, * The BT interface is efficient enough to not need a thread, * and there is no need for a thread if we have interrupts. */ - else if ((new_smi->si_type != SI_BT) && (!new_smi->irq)) + else if ((new_smi->si_type != SI_BT) && (!new_smi->irq)) enable = 1; if (enable) { @@ -1105,7 +1054,8 @@ static void set_maintenance_mode(void *send_info, int enable) atomic_set(&smi_info->req_events, 0); } -static struct ipmi_smi_handlers handlers = { +static struct ipmi_smi_handlers handlers = +{ .owner = THIS_MODULE, .start_processing = smi_start_processing, .sender = sender, @@ -1115,10 +1065,8 @@ static struct ipmi_smi_handlers handlers = { .poll = poll, }; -/* - * There can be 4 IO ports passed in (with or without IRQs), 4 addresses, - * a default IO port, and 1 ACPI/SPMI address. That sets SI_MAX_DRIVERS. - */ +/* There can be 4 IO ports passed in (with or without IRQs), 4 addresses, + a default IO port, and 1 ACPI/SPMI address. That sets SI_MAX_DRIVERS */ static LIST_HEAD(smi_infos); static DEFINE_MUTEX(smi_infos_lock); @@ -1309,9 +1257,10 @@ static void port_cleanup(struct smi_info *info) int idx; if (addr) { - for (idx = 0; idx < info->io_size; idx++) + for (idx = 0; idx < info->io_size; idx++) { release_region(addr + idx * info->io.regspacing, info->io.regsize); + } } } @@ -1325,10 +1274,8 @@ static int port_setup(struct smi_info *info) info->io_cleanup = port_cleanup; - /* - * Figure out the actual inb/inw/inl/etc routine to use based - * upon the register size. - */ + /* Figure out the actual inb/inw/inl/etc routine to use based + upon the register size. */ switch (info->io.regsize) { case 1: info->io.inputb = port_inb; @@ -1343,18 +1290,17 @@ static int port_setup(struct smi_info *info) info->io.outputb = port_outl; break; default: - printk(KERN_WARNING "ipmi_si: Invalid register size: %d\n", + printk("ipmi_si: Invalid register size: %d\n", info->io.regsize); return -EINVAL; } - /* - * Some BIOSes reserve disjoint I/O regions in their ACPI + /* Some BIOSes reserve disjoint I/O regions in their ACPI * tables. This causes problems when trying to register the * entire I/O region. Therefore we must register each I/O * port separately. */ - for (idx = 0; idx < info->io_size; idx++) { + for (idx = 0; idx < info->io_size; idx++) { if (request_region(addr + idx * info->io.regspacing, info->io.regsize, DEVICE_NAME) == NULL) { /* Undo allocations */ @@ -1442,10 +1388,8 @@ static int mem_setup(struct smi_info *info) info->io_cleanup = mem_cleanup; - /* - * Figure out the actual readb/readw/readl/etc routine to use based - * upon the register size. - */ + /* Figure out the actual readb/readw/readl/etc routine to use based + upon the register size. */ switch (info->io.regsize) { case 1: info->io.inputb = intf_mem_inb; @@ -1466,18 +1410,16 @@ static int mem_setup(struct smi_info *info) break; #endif default: - printk(KERN_WARNING "ipmi_si: Invalid register size: %d\n", + printk("ipmi_si: Invalid register size: %d\n", info->io.regsize); return -EINVAL; } - /* - * Calculate the total amount of memory to claim. This is an + /* Calculate the total amount of memory to claim. This is an * unusual looking calculation, but it avoids claiming any * more memory than it has to. It will claim everything * between the first address to the end of the last full - * register. - */ + * register. */ mapsize = ((info->io_size * info->io.regspacing) - (info->io.regspacing - info->io.regsize)); @@ -1807,11 +1749,9 @@ static __devinit void hardcode_find_bmc(void) #include -/* - * Once we get an ACPI failure, we don't try any more, because we go - * through the tables sequentially. Once we don't find a table, there - * are no more. - */ +/* Once we get an ACPI failure, we don't try any more, because we go + through the tables sequentially. Once we don't find a table, there + are no more. */ static int acpi_failure; /* For GPE-type interrupts. */ @@ -1825,7 +1765,9 @@ static u32 ipmi_acpi_gpe(void *context) spin_lock_irqsave(&(smi_info->si_lock), flags); - smi_inc_stat(smi_info, interrupts); + spin_lock(&smi_info->count_lock); + smi_info->interrupts++; + spin_unlock(&smi_info->count_lock); #ifdef DEBUG_TIMING do_gettimeofday(&t); @@ -1874,8 +1816,7 @@ static int acpi_gpe_irq_setup(struct smi_info *info) /* * Defined at - * http://h21007.www2.hp.com/dspp/files/unprotected/devresource/ - * Docs/TechPapers/IA64/hpspmi.pdf + * http://h21007.www2.hp.com/dspp/files/unprotected/devresource/Docs/TechPapers/IA64/hpspmi.pdf */ struct SPMITable { s8 Signature[4]; @@ -1897,18 +1838,14 @@ struct SPMITable { */ u8 InterruptType; - /* - * If bit 0 of InterruptType is set, then this is the SCI - * interrupt in the GPEx_STS register. - */ + /* If bit 0 of InterruptType is set, then this is the SCI + interrupt in the GPEx_STS register. */ u8 GPE; s16 Reserved; - /* - * If bit 1 of InterruptType is set, then this is the I/O - * APIC/SAPIC interrupt. - */ + /* If bit 1 of InterruptType is set, then this is the I/O + APIC/SAPIC interrupt. */ u32 GlobalSystemInterrupt; /* The actual register address. */ @@ -1926,7 +1863,7 @@ static __devinit int try_init_acpi(struct SPMITable *spmi) if (spmi->IPMIlegacy != 1) { printk(KERN_INFO "IPMI: Bad SPMI legacy %d\n", spmi->IPMIlegacy); - return -ENODEV; + return -ENODEV; } if (spmi->addr.space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) @@ -1943,7 +1880,8 @@ static __devinit int try_init_acpi(struct SPMITable *spmi) info->addr_source = "ACPI"; /* Figure out the interface type. */ - switch (spmi->InterfaceType) { + switch (spmi->InterfaceType) + { case 1: /* KCS */ info->si_type = SI_KCS; break; @@ -1991,8 +1929,7 @@ static __devinit int try_init_acpi(struct SPMITable *spmi) info->io.addr_type = IPMI_IO_ADDR_SPACE; } else { kfree(info); - printk(KERN_WARNING - "ipmi_si: Unknown ACPI I/O Address type\n"); + printk("ipmi_si: Unknown ACPI I/O Address type\n"); return -EIO; } info->io.addr_data = spmi->addr.address; @@ -2026,7 +1963,8 @@ static __devinit void acpi_find_bmc(void) #endif #ifdef CONFIG_DMI -struct dmi_ipmi_data { +struct dmi_ipmi_data +{ u8 type; u8 addr_space; unsigned long base_addr; @@ -2051,10 +1989,11 @@ static int __devinit decode_dmi(const struct dmi_header *dm, /* I/O */ base_addr &= 0xFFFE; dmi->addr_space = IPMI_IO_ADDR_SPACE; - } else + } + else { /* Memory */ dmi->addr_space = IPMI_MEM_ADDR_SPACE; - + } /* If bit 4 of byte 0x10 is set, then the lsb for the address is odd. */ dmi->base_addr = base_addr | ((data[0x10] & 0x10) >> 4); @@ -2063,7 +2002,7 @@ static int __devinit decode_dmi(const struct dmi_header *dm, /* The top two bits of byte 0x10 hold the register spacing. */ reg_spacing = (data[0x10] & 0xC0) >> 6; - switch (reg_spacing) { + switch(reg_spacing){ case 0x00: /* Byte boundaries */ dmi->offset = 1; break; @@ -2079,14 +2018,12 @@ static int __devinit decode_dmi(const struct dmi_header *dm, } } else { /* Old DMI spec. */ - /* - * Note that technically, the lower bit of the base + /* Note that technically, the lower bit of the base * address should be 1 if the address is I/O and 0 if * the address is in memory. So many systems get that * wrong (and all that I have seen are I/O) so we just * ignore that bit and assume I/O. Systems that use - * memory should use the newer spec, anyway. - */ + * memory should use the newer spec, anyway. */ dmi->base_addr = base_addr & 0xfffe; dmi->addr_space = IPMI_IO_ADDR_SPACE; dmi->offset = 1; @@ -2293,13 +2230,13 @@ static struct pci_device_id ipmi_pci_devices[] = { MODULE_DEVICE_TABLE(pci, ipmi_pci_devices); static struct pci_driver ipmi_pci_driver = { - .name = DEVICE_NAME, - .id_table = ipmi_pci_devices, - .probe = ipmi_pci_probe, - .remove = __devexit_p(ipmi_pci_remove), + .name = DEVICE_NAME, + .id_table = ipmi_pci_devices, + .probe = ipmi_pci_probe, + .remove = __devexit_p(ipmi_pci_remove), #ifdef CONFIG_PM - .suspend = ipmi_pci_suspend, - .resume = ipmi_pci_resume, + .suspend = ipmi_pci_suspend, + .resume = ipmi_pci_resume, #endif }; #endif /* CONFIG_PCI */ @@ -2369,7 +2306,7 @@ static int __devinit ipmi_of_probe(struct of_device *dev, info->io.addr_data, info->io.regsize, info->io.regspacing, info->irq); - dev->dev.driver_data = (void *) info; + dev->dev.driver_data = (void*) info; return try_smi_init(info); } @@ -2382,16 +2319,14 @@ static int __devexit ipmi_of_remove(struct of_device *dev) static struct of_device_id ipmi_match[] = { - { .type = "ipmi", .compatible = "ipmi-kcs", - .data = (void *)(unsigned long) SI_KCS }, - { .type = "ipmi", .compatible = "ipmi-smic", - .data = (void *)(unsigned long) SI_SMIC }, - { .type = "ipmi", .compatible = "ipmi-bt", - .data = (void *)(unsigned long) SI_BT }, + { .type = "ipmi", .compatible = "ipmi-kcs", .data = (void *)(unsigned long) SI_KCS }, + { .type = "ipmi", .compatible = "ipmi-smic", .data = (void *)(unsigned long) SI_SMIC }, + { .type = "ipmi", .compatible = "ipmi-bt", .data = (void *)(unsigned long) SI_BT }, {}, }; -static struct of_platform_driver ipmi_of_platform_driver = { +static struct of_platform_driver ipmi_of_platform_driver = +{ .name = "ipmi", .match_table = ipmi_match, .probe = ipmi_of_probe, @@ -2412,32 +2347,32 @@ static int try_get_dev_id(struct smi_info *smi_info) if (!resp) return -ENOMEM; - /* - * Do a Get Device ID command, since it comes back with some - * useful info. - */ + /* Do a Get Device ID command, since it comes back with some + useful info. */ msg[0] = IPMI_NETFN_APP_REQUEST << 2; msg[1] = IPMI_GET_DEVICE_ID_CMD; smi_info->handlers->start_transaction(smi_info->si_sm, msg, 2); smi_result = smi_info->handlers->event(smi_info->si_sm, 0); - for (;;) { + for (;;) + { if (smi_result == SI_SM_CALL_WITH_DELAY || smi_result == SI_SM_CALL_WITH_TICK_DELAY) { schedule_timeout_uninterruptible(1); smi_result = smi_info->handlers->event( smi_info->si_sm, 100); - } else if (smi_result == SI_SM_CALL_WITHOUT_DELAY) { + } + else if (smi_result == SI_SM_CALL_WITHOUT_DELAY) + { smi_result = smi_info->handlers->event( smi_info->si_sm, 0); - } else + } + else break; } if (smi_result == SI_SM_HOSED) { - /* - * We couldn't get the state machine to run, so whatever's at - * the port is probably not an IPMI SMI interface. - */ + /* We couldn't get the state machine to run, so whatever's at + the port is probably not an IPMI SMI interface. */ rv = -ENODEV; goto out; } @@ -2470,28 +2405,30 @@ static int stat_file_read_proc(char *page, char **start, off_t off, out += sprintf(out, "interrupts_enabled: %d\n", smi->irq && !smi->interrupt_disabled); - out += sprintf(out, "short_timeouts: %u\n", - smi_get_stat(smi, short_timeouts)); - out += sprintf(out, "long_timeouts: %u\n", - smi_get_stat(smi, long_timeouts)); - out += sprintf(out, "idles: %u\n", - smi_get_stat(smi, idles)); - out += sprintf(out, "interrupts: %u\n", - smi_get_stat(smi, interrupts)); - out += sprintf(out, "attentions: %u\n", - smi_get_stat(smi, attentions)); - out += sprintf(out, "flag_fetches: %u\n", - smi_get_stat(smi, flag_fetches)); - out += sprintf(out, "hosed_count: %u\n", - smi_get_stat(smi, hosed_count)); - out += sprintf(out, "complete_transactions: %u\n", - smi_get_stat(smi, complete_transactions)); - out += sprintf(out, "events: %u\n", - smi_get_stat(smi, events)); - out += sprintf(out, "watchdog_pretimeouts: %u\n", - smi_get_stat(smi, watchdog_pretimeouts)); - out += sprintf(out, "incoming_messages: %u\n", - smi_get_stat(smi, incoming_messages)); + out += sprintf(out, "short_timeouts: %ld\n", + smi->short_timeouts); + out += sprintf(out, "long_timeouts: %ld\n", + smi->long_timeouts); + out += sprintf(out, "timeout_restarts: %ld\n", + smi->timeout_restarts); + out += sprintf(out, "idles: %ld\n", + smi->idles); + out += sprintf(out, "interrupts: %ld\n", + smi->interrupts); + out += sprintf(out, "attentions: %ld\n", + smi->attentions); + out += sprintf(out, "flag_fetches: %ld\n", + smi->flag_fetches); + out += sprintf(out, "hosed_count: %ld\n", + smi->hosed_count); + out += sprintf(out, "complete_transactions: %ld\n", + smi->complete_transactions); + out += sprintf(out, "events: %ld\n", + smi->events); + out += sprintf(out, "watchdog_pretimeouts: %ld\n", + smi->watchdog_pretimeouts); + out += sprintf(out, "incoming_messages: %ld\n", + smi->incoming_messages); return out - page; } @@ -2523,7 +2460,7 @@ static int param_read_proc(char *page, char **start, off_t off, static int oem_data_avail_to_receive_msg_avail(struct smi_info *smi_info) { smi_info->msg_flags = ((smi_info->msg_flags & ~OEM_DATA_AVAIL) | - RECEIVE_MSG_AVAIL); + RECEIVE_MSG_AVAIL); return 1; } @@ -2565,9 +2502,10 @@ static void setup_dell_poweredge_oem_data_handler(struct smi_info *smi_info) id->ipmi_version == DELL_POWEREDGE_8G_BMC_IPMI_VERSION) { smi_info->oem_data_avail_handler = oem_data_avail_to_receive_msg_avail; - } else if (ipmi_version_major(id) < 1 || - (ipmi_version_major(id) == 1 && - ipmi_version_minor(id) < 5)) { + } + else if (ipmi_version_major(id) < 1 || + (ipmi_version_major(id) == 1 && + ipmi_version_minor(id) < 5)) { smi_info->oem_data_avail_handler = oem_data_avail_to_receive_msg_avail; } @@ -2659,10 +2597,8 @@ static void setup_xaction_handlers(struct smi_info *smi_info) static inline void wait_for_timer_and_thread(struct smi_info *smi_info) { if (smi_info->intf) { - /* - * The timer and thread are only running if the - * interface has been started up and registered. - */ + /* The timer and thread are only running if the + interface has been started up and registered. */ if (smi_info->thread != NULL) kthread_stop(smi_info->thread); del_timer_sync(&smi_info->si_timer); @@ -2740,7 +2676,6 @@ static int is_new_interface(struct smi_info *info) static int try_smi_init(struct smi_info *new_smi) { int rv; - int i; if (new_smi->addr_source) { printk(KERN_INFO "ipmi_si: Trying %s-specified %s state" @@ -2787,7 +2722,7 @@ static int try_smi_init(struct smi_info *new_smi) /* Allocate the state machine's data and initialize it. */ new_smi->si_sm = kmalloc(new_smi->handlers->size(), GFP_KERNEL); if (!new_smi->si_sm) { - printk(KERN_ERR "Could not allocate state machine memory\n"); + printk(" Could not allocate state machine memory\n"); rv = -ENOMEM; goto out_err; } @@ -2797,12 +2732,13 @@ static int try_smi_init(struct smi_info *new_smi) /* Now that we know the I/O size, we can set up the I/O. */ rv = new_smi->io_setup(new_smi); if (rv) { - printk(KERN_ERR "Could not set up I/O space\n"); + printk(" Could not set up I/O space\n"); goto out_err; } spin_lock_init(&(new_smi->si_lock)); spin_lock_init(&(new_smi->msg_lock)); + spin_lock_init(&(new_smi->count_lock)); /* Do low-level detection first. */ if (new_smi->handlers->detect(new_smi->si_sm)) { @@ -2813,10 +2749,8 @@ static int try_smi_init(struct smi_info *new_smi) goto out_err; } - /* - * Attempt a get device id command. If it fails, we probably - * don't have a BMC here. - */ + /* Attempt a get device id command. If it fails, we probably + don't have a BMC here. */ rv = try_get_dev_id(new_smi); if (rv) { if (new_smi->addr_source) @@ -2833,28 +2767,22 @@ static int try_smi_init(struct smi_info *new_smi) new_smi->curr_msg = NULL; atomic_set(&new_smi->req_events, 0); new_smi->run_to_completion = 0; - for (i = 0; i < SI_NUM_STATS; i++) - atomic_set(&new_smi->stats[i], 0); new_smi->interrupt_disabled = 0; atomic_set(&new_smi->stop_operation, 0); new_smi->intf_num = smi_num; smi_num++; - /* - * Start clearing the flags before we enable interrupts or the - * timer to avoid racing with the timer. - */ + /* Start clearing the flags before we enable interrupts or the + timer to avoid racing with the timer. */ start_clear_flags(new_smi); /* IRQ is defined to be set when non-zero. */ if (new_smi->irq) new_smi->si_state = SI_CLEARING_FLAGS_THEN_SET_IRQ; if (!new_smi->dev) { - /* - * If we don't already have a device from something - * else (like PCI), then register a new one. - */ + /* If we don't already have a device from something + * else (like PCI), then register a new one. */ new_smi->pdev = platform_device_alloc("ipmi_si", new_smi->intf_num); if (rv) { @@ -2892,7 +2820,7 @@ static int try_smi_init(struct smi_info *new_smi) } rv = ipmi_smi_add_proc_entry(new_smi->intf, "type", - type_file_read_proc, + type_file_read_proc, NULL, new_smi, THIS_MODULE); if (rv) { printk(KERN_ERR @@ -2902,7 +2830,7 @@ static int try_smi_init(struct smi_info *new_smi) } rv = ipmi_smi_add_proc_entry(new_smi->intf, "si_stats", - stat_file_read_proc, + stat_file_read_proc, NULL, new_smi, THIS_MODULE); if (rv) { printk(KERN_ERR @@ -2912,7 +2840,7 @@ static int try_smi_init(struct smi_info *new_smi) } rv = ipmi_smi_add_proc_entry(new_smi->intf, "params", - param_read_proc, + param_read_proc, NULL, new_smi, THIS_MODULE); if (rv) { printk(KERN_ERR @@ -2925,8 +2853,7 @@ static int try_smi_init(struct smi_info *new_smi) mutex_unlock(&smi_infos_lock); - printk(KERN_INFO "IPMI %s interface initialized\n", - si_to_str[new_smi->si_type]); + printk(KERN_INFO "IPMI %s interface initialized\n",si_to_str[new_smi->si_type]); return 0; @@ -2941,11 +2868,9 @@ static int try_smi_init(struct smi_info *new_smi) if (new_smi->irq_cleanup) new_smi->irq_cleanup(new_smi); - /* - * Wait until we know that we are out of any interrupt - * handlers might have been running before we freed the - * interrupt. - */ + /* Wait until we know that we are out of any interrupt + handlers might have been running before we freed the + interrupt. */ synchronize_sched(); if (new_smi->si_sm) { @@ -3017,10 +2942,11 @@ static __devinit int init_ipmi_si(void) #ifdef CONFIG_PCI rv = pci_register_driver(&ipmi_pci_driver); - if (rv) + if (rv){ printk(KERN_ERR "init_ipmi_si: Unable to register PCI driver: %d\n", rv); + } #endif #ifdef CONFIG_PPC_OF @@ -3049,8 +2975,7 @@ static __devinit int init_ipmi_si(void) of_unregister_platform_driver(&ipmi_of_platform_driver); #endif driver_unregister(&ipmi_driver); - printk(KERN_WARNING - "ipmi_si: Unable to find any System Interface(s)\n"); + printk("ipmi_si: Unable to find any System Interface(s)\n"); return -ENODEV; } else { mutex_unlock(&smi_infos_lock); @@ -3072,17 +2997,13 @@ static void cleanup_one_si(struct smi_info *to_clean) /* Tell the driver that we are shutting down. */ atomic_inc(&to_clean->stop_operation); - /* - * Make sure the timer and thread are stopped and will not run - * again. - */ + /* Make sure the timer and thread are stopped and will not run + again. */ wait_for_timer_and_thread(to_clean); - /* - * Timeouts are stopped, now make sure the interrupts are off - * for the device. A little tricky with locks to make sure - * there are no races. - */ + /* Timeouts are stopped, now make sure the interrupts are off + for the device. A little tricky with locks to make sure + there are no races. */ spin_lock_irqsave(&to_clean->si_lock, flags); while (to_clean->curr_msg || (to_clean->si_state != SI_NORMAL)) { spin_unlock_irqrestore(&to_clean->si_lock, flags); @@ -3153,5 +3074,4 @@ module_exit(cleanup_ipmi_si); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Corey Minyard "); -MODULE_DESCRIPTION("Interface to the IPMI driver for the KCS, SMIC, and BT" - " system interfaces."); +MODULE_DESCRIPTION("Interface to the IPMI driver for the KCS, SMIC, and BT system interfaces."); diff --git a/trunk/drivers/char/ipmi/ipmi_si_sm.h b/trunk/drivers/char/ipmi/ipmi_si_sm.h index df89f73475fb..4b731b24dc16 100644 --- a/trunk/drivers/char/ipmi/ipmi_si_sm.h +++ b/trunk/drivers/char/ipmi/ipmi_si_sm.h @@ -34,27 +34,22 @@ * 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* - * This is defined by the state machines themselves, it is an opaque - * data type for them to use. - */ +/* This is defined by the state machines themselves, it is an opaque + data type for them to use. */ struct si_sm_data; -/* - * The structure for doing I/O in the state machine. The state - * machine doesn't have the actual I/O routines, they are done through - * this interface. - */ -struct si_sm_io { +/* The structure for doing I/O in the state machine. The state + machine doesn't have the actual I/O routines, they are done through + this interface. */ +struct si_sm_io +{ unsigned char (*inputb)(struct si_sm_io *io, unsigned int offset); void (*outputb)(struct si_sm_io *io, unsigned int offset, unsigned char b); - /* - * Generic info used by the actual handling routines, the - * state machine shouldn't touch these. - */ + /* Generic info used by the actual handling routines, the + state machine shouldn't touch these. */ void __iomem *addr; int regspacing; int regsize; @@ -64,67 +59,53 @@ struct si_sm_io { }; /* Results of SMI events. */ -enum si_sm_result { +enum si_sm_result +{ SI_SM_CALL_WITHOUT_DELAY, /* Call the driver again immediately */ SI_SM_CALL_WITH_DELAY, /* Delay some before calling again. */ - SI_SM_CALL_WITH_TICK_DELAY,/* Delay >=1 tick before calling again. */ + SI_SM_CALL_WITH_TICK_DELAY, /* Delay at least 1 tick before calling again. */ SI_SM_TRANSACTION_COMPLETE, /* A transaction is finished. */ SI_SM_IDLE, /* The SM is in idle state. */ SI_SM_HOSED, /* The hardware violated the state machine. */ - - /* - * The hardware is asserting attn and the state machine is - * idle. - */ - SI_SM_ATTN + SI_SM_ATTN /* The hardware is asserting attn and the + state machine is idle. */ }; /* Handlers for the SMI state machine. */ -struct si_sm_handlers { - /* - * Put the version number of the state machine here so the - * upper layer can print it. - */ +struct si_sm_handlers +{ + /* Put the version number of the state machine here so the + upper layer can print it. */ char *version; - /* - * Initialize the data and return the amount of I/O space to - * reserve for the space. - */ + /* Initialize the data and return the amount of I/O space to + reserve for the space. */ unsigned int (*init_data)(struct si_sm_data *smi, struct si_sm_io *io); - /* - * Start a new transaction in the state machine. This will - * return -2 if the state machine is not idle, -1 if the size - * is invalid (to large or too small), or 0 if the transaction - * is successfully completed. - */ + /* Start a new transaction in the state machine. This will + return -2 if the state machine is not idle, -1 if the size + is invalid (to large or too small), or 0 if the transaction + is successfully completed. */ int (*start_transaction)(struct si_sm_data *smi, unsigned char *data, unsigned int size); - /* - * Return the results after the transaction. This will return - * -1 if the buffer is too small, zero if no transaction is - * present, or the actual length of the result data. - */ + /* Return the results after the transaction. This will return + -1 if the buffer is too small, zero if no transaction is + present, or the actual length of the result data. */ int (*get_result)(struct si_sm_data *smi, unsigned char *data, unsigned int length); - /* - * Call this periodically (for a polled interface) or upon - * receiving an interrupt (for a interrupt-driven interface). - * If interrupt driven, you should probably poll this - * periodically when not in idle state. This should be called - * with the time that passed since the last call, if it is - * significant. Time is in microseconds. - */ + /* Call this periodically (for a polled interface) or upon + receiving an interrupt (for a interrupt-driven interface). + If interrupt driven, you should probably poll this + periodically when not in idle state. This should be called + with the time that passed since the last call, if it is + significant. Time is in microseconds. */ enum si_sm_result (*event)(struct si_sm_data *smi, long time); - /* - * Attempt to detect an SMI. Returns 0 on success or nonzero - * on failure. - */ + /* Attempt to detect an SMI. Returns 0 on success or nonzero + on failure. */ int (*detect)(struct si_sm_data *smi); /* The interface is shutting down, so clean it up. */ diff --git a/trunk/drivers/char/ipmi/ipmi_smic_sm.c b/trunk/drivers/char/ipmi/ipmi_smic_sm.c index faed92971907..e64ea7d25d24 100644 --- a/trunk/drivers/char/ipmi/ipmi_smic_sm.c +++ b/trunk/drivers/char/ipmi/ipmi_smic_sm.c @@ -85,7 +85,6 @@ enum smic_states { /* SMIC Flags Register Bits */ #define SMIC_RX_DATA_READY 0x80 #define SMIC_TX_DATA_READY 0x40 - /* * SMIC_SMI and SMIC_EVM_DATA_AVAIL are only used by * a few systems, and then only by Systems Management @@ -105,22 +104,23 @@ enum smic_states { #define EC_ILLEGAL_COMMAND 0x04 #define EC_BUFFER_FULL 0x05 -struct si_sm_data { +struct si_sm_data +{ enum smic_states state; struct si_sm_io *io; - unsigned char write_data[MAX_SMIC_WRITE_SIZE]; - int write_pos; - int write_count; - int orig_write_count; - unsigned char read_data[MAX_SMIC_READ_SIZE]; - int read_pos; - int truncated; - unsigned int error_retries; - long smic_timeout; + unsigned char write_data[MAX_SMIC_WRITE_SIZE]; + int write_pos; + int write_count; + int orig_write_count; + unsigned char read_data[MAX_SMIC_READ_SIZE]; + int read_pos; + int truncated; + unsigned int error_retries; + long smic_timeout; }; -static unsigned int init_smic_data(struct si_sm_data *smic, - struct si_sm_io *io) +static unsigned int init_smic_data (struct si_sm_data *smic, + struct si_sm_io *io) { smic->state = SMIC_IDLE; smic->io = io; @@ -150,10 +150,11 @@ static int start_smic_transaction(struct si_sm_data *smic, return IPMI_NOT_IN_MY_STATE_ERR; if (smic_debug & SMIC_DEBUG_MSG) { - printk(KERN_DEBUG "start_smic_transaction -"); - for (i = 0; i < size; i++) - printk(" %02x", (unsigned char) data[i]); - printk("\n"); + printk(KERN_INFO "start_smic_transaction -"); + for (i = 0; i < size; i ++) { + printk (" %02x", (unsigned char) (data [i])); + } + printk ("\n"); } smic->error_retries = 0; memcpy(smic->write_data, data, size); @@ -172,10 +173,11 @@ static int smic_get_result(struct si_sm_data *smic, int i; if (smic_debug & SMIC_DEBUG_MSG) { - printk(KERN_DEBUG "smic_get result -"); - for (i = 0; i < smic->read_pos; i++) - printk(" %02x", smic->read_data[i]); - printk("\n"); + printk (KERN_INFO "smic_get result -"); + for (i = 0; i < smic->read_pos; i ++) { + printk (" %02x", (smic->read_data [i])); + } + printk ("\n"); } if (length < smic->read_pos) { smic->read_pos = length; @@ -221,8 +223,8 @@ static inline void write_smic_control(struct si_sm_data *smic, smic->io->outputb(smic->io, 1, control); } -static inline void write_si_sm_data(struct si_sm_data *smic, - unsigned char data) +static inline void write_si_sm_data (struct si_sm_data *smic, + unsigned char data) { smic->io->outputb(smic->io, 0, data); } @@ -231,9 +233,10 @@ static inline void start_error_recovery(struct si_sm_data *smic, char *reason) { (smic->error_retries)++; if (smic->error_retries > SMIC_MAX_ERROR_RETRIES) { - if (smic_debug & SMIC_DEBUG_ENABLE) + if (smic_debug & SMIC_DEBUG_ENABLE) { printk(KERN_WARNING "ipmi_smic_drv: smic hosed: %s\n", reason); + } smic->state = SMIC_HOSED; } else { smic->write_count = smic->orig_write_count; @@ -251,14 +254,14 @@ static inline void write_next_byte(struct si_sm_data *smic) (smic->write_count)--; } -static inline void read_next_byte(struct si_sm_data *smic) +static inline void read_next_byte (struct si_sm_data *smic) { if (smic->read_pos >= MAX_SMIC_READ_SIZE) { - read_smic_data(smic); + read_smic_data (smic); smic->truncated = 1; } else { smic->read_data[smic->read_pos] = read_smic_data(smic); - smic->read_pos++; + (smic->read_pos)++; } } @@ -333,7 +336,7 @@ static inline void read_next_byte(struct si_sm_data *smic) SMIC_SC_SMS_RD_END 0xC6 */ -static enum si_sm_result smic_event(struct si_sm_data *smic, long time) +static enum si_sm_result smic_event (struct si_sm_data *smic, long time) { unsigned char status; unsigned char flags; @@ -344,15 +347,13 @@ static enum si_sm_result smic_event(struct si_sm_data *smic, long time) return SI_SM_HOSED; } if (smic->state != SMIC_IDLE) { - if (smic_debug & SMIC_DEBUG_STATES) - printk(KERN_DEBUG + if (smic_debug & SMIC_DEBUG_STATES) { + printk(KERN_INFO "smic_event - smic->smic_timeout = %ld," " time = %ld\n", smic->smic_timeout, time); - /* - * FIXME: smic_event is sometimes called with time > - * SMIC_RETRY_TIMEOUT - */ + } +/* FIXME: smic_event is sometimes called with time > SMIC_RETRY_TIMEOUT */ if (time < SMIC_RETRY_TIMEOUT) { smic->smic_timeout -= time; if (smic->smic_timeout < 0) { @@ -365,9 +366,9 @@ static enum si_sm_result smic_event(struct si_sm_data *smic, long time) if (flags & SMIC_FLAG_BSY) return SI_SM_CALL_WITH_DELAY; - status = read_smic_status(smic); + status = read_smic_status (smic); if (smic_debug & SMIC_DEBUG_STATES) - printk(KERN_DEBUG + printk(KERN_INFO "smic_event - state = %d, flags = 0x%02x," " status = 0x%02x\n", smic->state, flags, status); @@ -376,7 +377,9 @@ static enum si_sm_result smic_event(struct si_sm_data *smic, long time) case SMIC_IDLE: /* in IDLE we check for available messages */ if (flags & SMIC_SMS_DATA_AVAIL) + { return SI_SM_ATTN; + } return SI_SM_IDLE; case SMIC_START_OP: @@ -388,7 +391,7 @@ static enum si_sm_result smic_event(struct si_sm_data *smic, long time) case SMIC_OP_OK: if (status != SMIC_SC_SMS_READY) { - /* this should not happen */ + /* this should not happen */ start_error_recovery(smic, "state = SMIC_OP_OK," " status != SMIC_SC_SMS_READY"); @@ -408,10 +411,8 @@ static enum si_sm_result smic_event(struct si_sm_data *smic, long time) "status != SMIC_SC_SMS_WR_START"); return SI_SM_CALL_WITH_DELAY; } - /* - * we must not issue WR_(NEXT|END) unless - * TX_DATA_READY is set - * */ + /* we must not issue WR_(NEXT|END) unless + TX_DATA_READY is set */ if (flags & SMIC_TX_DATA_READY) { if (smic->write_count == 1) { /* last byte */ @@ -423,8 +424,10 @@ static enum si_sm_result smic_event(struct si_sm_data *smic, long time) } write_next_byte(smic); write_smic_flags(smic, flags | SMIC_FLAG_BSY); - } else + } + else { return SI_SM_CALL_WITH_DELAY; + } break; case SMIC_WRITE_NEXT: @@ -439,48 +442,52 @@ static enum si_sm_result smic_event(struct si_sm_data *smic, long time) if (smic->write_count == 1) { write_smic_control(smic, SMIC_CC_SMS_WR_END); smic->state = SMIC_WRITE_END; - } else { + } + else { write_smic_control(smic, SMIC_CC_SMS_WR_NEXT); smic->state = SMIC_WRITE_NEXT; } write_next_byte(smic); write_smic_flags(smic, flags | SMIC_FLAG_BSY); - } else + } + else { return SI_SM_CALL_WITH_DELAY; + } break; case SMIC_WRITE_END: if (status != SMIC_SC_SMS_WR_END) { - start_error_recovery(smic, - "state = SMIC_WRITE_END, " - "status != SMIC_SC_SMS_WR_END"); + start_error_recovery (smic, + "state = SMIC_WRITE_END, " + "status != SMIC_SC_SMS_WR_END"); return SI_SM_CALL_WITH_DELAY; } /* data register holds an error code */ data = read_smic_data(smic); if (data != 0) { - if (smic_debug & SMIC_DEBUG_ENABLE) - printk(KERN_DEBUG + if (smic_debug & SMIC_DEBUG_ENABLE) { + printk(KERN_INFO "SMIC_WRITE_END: data = %02x\n", data); + } start_error_recovery(smic, "state = SMIC_WRITE_END, " "data != SUCCESS"); return SI_SM_CALL_WITH_DELAY; - } else + } else { smic->state = SMIC_WRITE2READ; + } break; case SMIC_WRITE2READ: - /* - * we must wait for RX_DATA_READY to be set before we - * can continue - */ + /* we must wait for RX_DATA_READY to be set before we + can continue */ if (flags & SMIC_RX_DATA_READY) { write_smic_control(smic, SMIC_CC_SMS_RD_START); write_smic_flags(smic, flags | SMIC_FLAG_BSY); smic->state = SMIC_READ_START; - } else + } else { return SI_SM_CALL_WITH_DELAY; + } break; case SMIC_READ_START: @@ -495,16 +502,15 @@ static enum si_sm_result smic_event(struct si_sm_data *smic, long time) write_smic_control(smic, SMIC_CC_SMS_RD_NEXT); write_smic_flags(smic, flags | SMIC_FLAG_BSY); smic->state = SMIC_READ_NEXT; - } else + } else { return SI_SM_CALL_WITH_DELAY; + } break; case SMIC_READ_NEXT: switch (status) { - /* - * smic tells us that this is the last byte to be read - * --> clean up - */ + /* smic tells us that this is the last byte to be read + --> clean up */ case SMIC_SC_SMS_RD_END: read_next_byte(smic); write_smic_control(smic, SMIC_CC_SMS_RD_END); @@ -517,8 +523,9 @@ static enum si_sm_result smic_event(struct si_sm_data *smic, long time) write_smic_control(smic, SMIC_CC_SMS_RD_NEXT); write_smic_flags(smic, flags | SMIC_FLAG_BSY); smic->state = SMIC_READ_NEXT; - } else + } else { return SI_SM_CALL_WITH_DELAY; + } break; default: start_error_recovery( @@ -539,9 +546,10 @@ static enum si_sm_result smic_event(struct si_sm_data *smic, long time) data = read_smic_data(smic); /* data register holds an error code */ if (data != 0) { - if (smic_debug & SMIC_DEBUG_ENABLE) - printk(KERN_DEBUG + if (smic_debug & SMIC_DEBUG_ENABLE) { + printk(KERN_INFO "SMIC_READ_END: data = %02x\n", data); + } start_error_recovery(smic, "state = SMIC_READ_END, " "data != SUCCESS"); @@ -557,7 +565,7 @@ static enum si_sm_result smic_event(struct si_sm_data *smic, long time) default: if (smic_debug & SMIC_DEBUG_ENABLE) { - printk(KERN_DEBUG "smic->state = %d\n", smic->state); + printk(KERN_WARNING "smic->state = %d\n", smic->state); start_error_recovery(smic, "state = UNKNOWN"); return SI_SM_CALL_WITH_DELAY; } @@ -568,12 +576,10 @@ static enum si_sm_result smic_event(struct si_sm_data *smic, long time) static int smic_detect(struct si_sm_data *smic) { - /* - * It's impossible for the SMIC fnags register to be all 1's, - * (assuming a properly functioning, self-initialized BMC) - * but that's what you get from reading a bogus address, so we - * test that first. - */ + /* It's impossible for the SMIC fnags register to be all 1's, + (assuming a properly functioning, self-initialized BMC) + but that's what you get from reading a bogus address, so we + test that first. */ if (read_smic_flags(smic) == 0xff) return 1; @@ -589,7 +595,8 @@ static int smic_size(void) return sizeof(struct si_sm_data); } -struct si_sm_handlers smic_smi_handlers = { +struct si_sm_handlers smic_smi_handlers = +{ .init_data = init_smic_data, .start_transaction = start_smic_transaction, .get_result = smic_get_result, diff --git a/trunk/drivers/char/ipmi/ipmi_watchdog.c b/trunk/drivers/char/ipmi/ipmi_watchdog.c index 1b9a87047817..8f45ca9235ad 100644 --- a/trunk/drivers/char/ipmi/ipmi_watchdog.c +++ b/trunk/drivers/char/ipmi/ipmi_watchdog.c @@ -54,15 +54,13 @@ #include #ifdef CONFIG_X86 -/* - * This is ugly, but I've determined that x86 is the only architecture - * that can reasonably support the IPMI NMI watchdog timeout at this - * time. If another architecture adds this capability somehow, it - * will have to be a somewhat different mechanism and I have no idea - * how it will work. So in the unlikely event that another - * architecture supports this, we can figure out a good generic - * mechanism for it at that time. - */ +/* This is ugly, but I've determined that x86 is the only architecture + that can reasonably support the IPMI NMI watchdog timeout at this + time. If another architecture adds this capability somehow, it + will have to be a somewhat different mechanism and I have no idea + how it will work. So in the unlikely event that another + architecture supports this, we can figure out a good generic + mechanism for it at that time. */ #include #define HAVE_DIE_NMI #endif @@ -97,8 +95,9 @@ /* Operations that can be performed on a pretimout. */ #define WDOG_PREOP_NONE 0 #define WDOG_PREOP_PANIC 1 -/* Cause data to be available to read. Doesn't work in NMI mode. */ -#define WDOG_PREOP_GIVE_DATA 2 +#define WDOG_PREOP_GIVE_DATA 2 /* Cause data to be available to + read. Doesn't work in NMI + mode. */ /* Actions to perform on a full timeout. */ #define WDOG_SET_TIMEOUT_ACT(byte, use) \ @@ -109,10 +108,8 @@ #define WDOG_TIMEOUT_POWER_DOWN 2 #define WDOG_TIMEOUT_POWER_CYCLE 3 -/* - * Byte 3 of the get command, byte 4 of the get response is the - * pre-timeout in seconds. - */ +/* Byte 3 of the get command, byte 4 of the get response is the + pre-timeout in seconds. */ /* Bits for setting byte 4 of the set command, byte 5 of the get response. */ #define WDOG_EXPIRE_CLEAR_BIOS_FRB2 (1 << 1) @@ -121,13 +118,11 @@ #define WDOG_EXPIRE_CLEAR_SMS_OS (1 << 4) #define WDOG_EXPIRE_CLEAR_OEM (1 << 5) -/* - * Setting/getting the watchdog timer value. This is for bytes 5 and - * 6 (the timeout time) of the set command, and bytes 6 and 7 (the - * timeout time) and 8 and 9 (the current countdown value) of the - * response. The timeout value is given in seconds (in the command it - * is 100ms intervals). - */ +/* Setting/getting the watchdog timer value. This is for bytes 5 and + 6 (the timeout time) of the set command, and bytes 6 and 7 (the + timeout time) and 8 and 9 (the current countdown value) of the + response. The timeout value is given in seconds (in the command it + is 100ms intervals). */ #define WDOG_SET_TIMEOUT(byte1, byte2, val) \ (byte1) = (((val) * 10) & 0xff), (byte2) = (((val) * 10) >> 8) #define WDOG_GET_TIMEOUT(byte1, byte2) \ @@ -189,10 +184,8 @@ static int ipmi_set_timeout(int do_heartbeat); static void ipmi_register_watchdog(int ipmi_intf); static void ipmi_unregister_watchdog(int ipmi_intf); -/* - * If true, the driver will start running as soon as it is configured - * and ready. - */ +/* If true, the driver will start running as soon as it is configured + and ready. */ static int start_now; static int set_param_int(const char *val, struct kernel_param *kp) @@ -316,12 +309,10 @@ static int ipmi_ignore_heartbeat; /* Is someone using the watchdog? Only one user is allowed. */ static unsigned long ipmi_wdog_open; -/* - * If set to 1, the heartbeat command will set the state to reset and - * start the timer. The timer doesn't normally run when the driver is - * first opened until the heartbeat is set the first time, this - * variable is used to accomplish this. - */ +/* If set to 1, the heartbeat command will set the state to reset and + start the timer. The timer doesn't normally run when the driver is + first opened until the heartbeat is set the first time, this + variable is used to accomplish this. */ static int ipmi_start_timer_on_heartbeat; /* IPMI version of the BMC. */ @@ -338,12 +329,10 @@ static int nmi_handler_registered; static int ipmi_heartbeat(void); -/* - * We use a mutex to make sure that only one thing can send a set - * timeout at one time, because we only have one copy of the data. - * The mutex is claimed when the set_timeout is sent and freed - * when both messages are free. - */ +/* We use a mutex to make sure that only one thing can send a set + timeout at one time, because we only have one copy of the data. + The mutex is claimed when the set_timeout is sent and freed + when both messages are free. */ static atomic_t set_timeout_tofree = ATOMIC_INIT(0); static DEFINE_MUTEX(set_timeout_lock); static DECLARE_COMPLETION(set_timeout_wait); @@ -357,13 +346,15 @@ static void set_timeout_free_recv(struct ipmi_recv_msg *msg) if (atomic_dec_and_test(&set_timeout_tofree)) complete(&set_timeout_wait); } -static struct ipmi_smi_msg set_timeout_smi_msg = { +static struct ipmi_smi_msg set_timeout_smi_msg = +{ .done = set_timeout_free_smi }; -static struct ipmi_recv_msg set_timeout_recv_msg = { +static struct ipmi_recv_msg set_timeout_recv_msg = +{ .done = set_timeout_free_recv }; - + static int i_ipmi_set_timeout(struct ipmi_smi_msg *smi_msg, struct ipmi_recv_msg *recv_msg, int *send_heartbeat_now) @@ -382,14 +373,13 @@ static int i_ipmi_set_timeout(struct ipmi_smi_msg *smi_msg, WDOG_SET_TIMER_USE(data[0], WDOG_TIMER_USE_SMS_OS); if ((ipmi_version_major > 1) - || ((ipmi_version_major == 1) && (ipmi_version_minor >= 5))) { + || ((ipmi_version_major == 1) && (ipmi_version_minor >= 5))) + { /* This is an IPMI 1.5-only feature. */ data[0] |= WDOG_DONT_STOP_ON_SET; } else if (ipmi_watchdog_state != WDOG_TIMEOUT_NONE) { - /* - * In ipmi 1.0, setting the timer stops the watchdog, we - * need to start it back up again. - */ + /* In ipmi 1.0, setting the timer stops the watchdog, we + need to start it back up again. */ hbnow = 1; } @@ -475,10 +465,12 @@ static void panic_recv_free(struct ipmi_recv_msg *msg) atomic_dec(&panic_done_count); } -static struct ipmi_smi_msg panic_halt_heartbeat_smi_msg = { +static struct ipmi_smi_msg panic_halt_heartbeat_smi_msg = +{ .done = panic_smi_free }; -static struct ipmi_recv_msg panic_halt_heartbeat_recv_msg = { +static struct ipmi_recv_msg panic_halt_heartbeat_recv_msg = +{ .done = panic_recv_free }; @@ -488,10 +480,8 @@ static void panic_halt_ipmi_heartbeat(void) struct ipmi_system_interface_addr addr; int rv; - /* - * Don't reset the timer if we have the timer turned off, that - * re-enables the watchdog. - */ + /* Don't reset the timer if we have the timer turned off, that + re-enables the watchdog. */ if (ipmi_watchdog_state == WDOG_TIMEOUT_NONE) return; @@ -515,19 +505,19 @@ static void panic_halt_ipmi_heartbeat(void) atomic_add(2, &panic_done_count); } -static struct ipmi_smi_msg panic_halt_smi_msg = { +static struct ipmi_smi_msg panic_halt_smi_msg = +{ .done = panic_smi_free }; -static struct ipmi_recv_msg panic_halt_recv_msg = { +static struct ipmi_recv_msg panic_halt_recv_msg = +{ .done = panic_recv_free }; -/* - * Special call, doesn't claim any locks. This is only to be called - * at panic or halt time, in run-to-completion mode, when the caller - * is the only CPU and the only thing that will be going is these IPMI - * calls. - */ +/* Special call, doesn't claim any locks. This is only to be called + at panic or halt time, in run-to-completion mode, when the caller + is the only CPU and the only thing that will be going is these IPMI + calls. */ static void panic_halt_ipmi_set_timeout(void) { int send_heartbeat_now; @@ -550,12 +540,10 @@ static void panic_halt_ipmi_set_timeout(void) ipmi_poll_interface(watchdog_user); } -/* - * We use a mutex to make sure that only one thing can send a - * heartbeat at one time, because we only have one copy of the data. - * The semaphore is claimed when the set_timeout is sent and freed - * when both messages are free. - */ +/* We use a semaphore to make sure that only one thing can send a + heartbeat at one time, because we only have one copy of the data. + The semaphore is claimed when the set_timeout is sent and freed + when both messages are free. */ static atomic_t heartbeat_tofree = ATOMIC_INIT(0); static DEFINE_MUTEX(heartbeat_lock); static DECLARE_COMPLETION(heartbeat_wait); @@ -569,13 +557,15 @@ static void heartbeat_free_recv(struct ipmi_recv_msg *msg) if (atomic_dec_and_test(&heartbeat_tofree)) complete(&heartbeat_wait); } -static struct ipmi_smi_msg heartbeat_smi_msg = { +static struct ipmi_smi_msg heartbeat_smi_msg = +{ .done = heartbeat_free_smi }; -static struct ipmi_recv_msg heartbeat_recv_msg = { +static struct ipmi_recv_msg heartbeat_recv_msg = +{ .done = heartbeat_free_recv }; - + static int ipmi_heartbeat(void) { struct kernel_ipmi_msg msg; @@ -590,12 +580,10 @@ static int ipmi_heartbeat(void) ipmi_watchdog_state = action_val; return ipmi_set_timeout(IPMI_SET_TIMEOUT_FORCE_HB); } else if (pretimeout_since_last_heartbeat) { - /* - * A pretimeout occurred, make sure we set the timeout. - * We don't want to set the action, though, we want to - * leave that alone (thus it can't be combined with the - * above operation. - */ + /* A pretimeout occurred, make sure we set the timeout. + We don't want to set the action, though, we want to + leave that alone (thus it can't be combined with the + above operation. */ return ipmi_set_timeout(IPMI_SET_TIMEOUT_HB_IF_NECESSARY); } @@ -603,10 +591,8 @@ static int ipmi_heartbeat(void) atomic_set(&heartbeat_tofree, 2); - /* - * Don't reset the timer if we have the timer turned off, that - * re-enables the watchdog. - */ + /* Don't reset the timer if we have the timer turned off, that + re-enables the watchdog. */ if (ipmi_watchdog_state == WDOG_TIMEOUT_NONE) { mutex_unlock(&heartbeat_lock); return 0; @@ -639,12 +625,10 @@ static int ipmi_heartbeat(void) wait_for_completion(&heartbeat_wait); if (heartbeat_recv_msg.msg.data[0] != 0) { - /* - * Got an error in the heartbeat response. It was already - * reported in ipmi_wdog_msg_handler, but we should return - * an error here. - */ - rv = -EINVAL; + /* Got an error in the heartbeat response. It was already + reported in ipmi_wdog_msg_handler, but we should return + an error here. */ + rv = -EINVAL; } mutex_unlock(&heartbeat_lock); @@ -652,7 +636,8 @@ static int ipmi_heartbeat(void) return rv; } -static struct watchdog_info ident = { +static struct watchdog_info ident = +{ .options = 0, /* WDIOF_SETTIMEOUT, */ .firmware_version = 1, .identity = "IPMI" @@ -665,7 +650,7 @@ static int ipmi_ioctl(struct inode *inode, struct file *file, int i; int val; - switch (cmd) { + switch(cmd) { case WDIOC_GETSUPPORT: i = copy_to_user(argp, &ident, sizeof(ident)); return i ? -EFAULT : 0; @@ -705,13 +690,15 @@ static int ipmi_ioctl(struct inode *inode, struct file *file, i = copy_from_user(&val, argp, sizeof(int)); if (i) return -EFAULT; - if (val & WDIOS_DISABLECARD) { + if (val & WDIOS_DISABLECARD) + { ipmi_watchdog_state = WDOG_TIMEOUT_NONE; ipmi_set_timeout(IPMI_SET_TIMEOUT_NO_HB); ipmi_start_timer_on_heartbeat = 0; } - if (val & WDIOS_ENABLECARD) { + if (val & WDIOS_ENABLECARD) + { ipmi_watchdog_state = action_val; ipmi_set_timeout(IPMI_SET_TIMEOUT_FORCE_HB); } @@ -737,13 +724,13 @@ static ssize_t ipmi_write(struct file *file, int rv; if (len) { - if (!nowayout) { - size_t i; + if (!nowayout) { + size_t i; /* In case it was set long ago */ expect_close = 0; - for (i = 0; i != len; i++) { + for (i = 0; i != len; i++) { char c; if (get_user(c, buf + i)) @@ -771,17 +758,15 @@ static ssize_t ipmi_read(struct file *file, if (count <= 0) return 0; - /* - * Reading returns if the pretimeout has gone off, and it only does - * it once per pretimeout. - */ + /* Reading returns if the pretimeout has gone off, and it only does + it once per pretimeout. */ spin_lock(&ipmi_read_lock); if (!data_to_read) { if (file->f_flags & O_NONBLOCK) { rv = -EAGAIN; goto out; } - + init_waitqueue_entry(&wait, current); add_wait_queue(&read_q, &wait); while (!data_to_read) { @@ -791,7 +776,7 @@ static ssize_t ipmi_read(struct file *file, spin_lock(&ipmi_read_lock); } remove_wait_queue(&read_q, &wait); - + if (signal_pending(current)) { rv = -ERESTARTSYS; goto out; @@ -814,27 +799,25 @@ static ssize_t ipmi_read(struct file *file, static int ipmi_open(struct inode *ino, struct file *filep) { - switch (iminor(ino)) { - case WATCHDOG_MINOR: + switch (iminor(ino)) { + case WATCHDOG_MINOR: if (test_and_set_bit(0, &ipmi_wdog_open)) - return -EBUSY; + return -EBUSY; - /* - * Don't start the timer now, let it start on the - * first heartbeat. - */ + /* Don't start the timer now, let it start on the + first heartbeat. */ ipmi_start_timer_on_heartbeat = 1; return nonseekable_open(ino, filep); default: return (-ENODEV); - } + } } static unsigned int ipmi_poll(struct file *file, poll_table *wait) { unsigned int mask = 0; - + poll_wait(file, &read_q, wait); spin_lock(&ipmi_read_lock); @@ -868,7 +851,7 @@ static int ipmi_close(struct inode *ino, struct file *filep) clear_bit(0, &ipmi_wdog_open); } - ipmi_fasync(-1, filep, 0); + ipmi_fasync (-1, filep, 0); expect_close = 0; return 0; @@ -899,7 +882,7 @@ static void ipmi_wdog_msg_handler(struct ipmi_recv_msg *msg, msg->msg.data[0], msg->msg.cmd); } - + ipmi_free_recv_msg(msg); } @@ -919,14 +902,14 @@ static void ipmi_wdog_pretimeout_handler(void *handler_data) } } - /* - * On some machines, the heartbeat will give an error and not - * work unless we re-enable the timer. So do so. - */ + /* On some machines, the heartbeat will give + an error and not work unless we re-enable + the timer. So do so. */ pretimeout_since_last_heartbeat = 1; } -static struct ipmi_user_hndl ipmi_hndlrs = { +static struct ipmi_user_hndl ipmi_hndlrs = +{ .ipmi_recv_hndl = ipmi_wdog_msg_handler, .ipmi_watchdog_pretimeout = ipmi_wdog_pretimeout_handler }; @@ -966,10 +949,8 @@ static void ipmi_register_watchdog(int ipmi_intf) int old_timeout = timeout; int old_preop_val = preop_val; - /* - * Set the pretimeout to go off in a second and give - * ourselves plenty of time to stop the timer. - */ + /* Set the pretimeout to go off in a second and give + ourselves plenty of time to stop the timer. */ ipmi_watchdog_state = WDOG_TIMEOUT_RESET; preop_val = WDOG_PREOP_NONE; /* Make sure nothing happens */ pretimeout = 99; @@ -993,7 +974,7 @@ static void ipmi_register_watchdog(int ipmi_intf) " occur. The NMI pretimeout will" " likely not work\n"); } - out_restore: + out_restore: testing_nmi = 0; preop_val = old_preop_val; pretimeout = old_pretimeout; @@ -1028,11 +1009,9 @@ static void ipmi_unregister_watchdog(int ipmi_intf) /* Make sure no one can call us any more. */ misc_deregister(&ipmi_wdog_miscdev); - /* - * Wait to make sure the message makes it out. The lower layer has - * pointers to our buffers, we want to make sure they are done before - * we release our memory. - */ + /* Wait to make sure the message makes it out. The lower layer has + pointers to our buffers, we want to make sure they are done before + we release our memory. */ while (atomic_read(&set_timeout_tofree)) schedule_timeout_uninterruptible(1); @@ -1073,17 +1052,15 @@ ipmi_nmi(struct notifier_block *self, unsigned long val, void *data) return NOTIFY_STOP; } - /* If we are not expecting a timeout, ignore it. */ + /* If we are not expecting a timeout, ignore it. */ if (ipmi_watchdog_state == WDOG_TIMEOUT_NONE) return NOTIFY_OK; if (preaction_val != WDOG_PRETIMEOUT_NMI) return NOTIFY_OK; - /* - * If no one else handled the NMI, we assume it was the IPMI - * watchdog. - */ + /* If no one else handled the NMI, we assume it was the IPMI + watchdog. */ if (preop_val == WDOG_PREOP_PANIC) { /* On some machines, the heartbeat will give an error and not work unless we re-enable @@ -1105,7 +1082,7 @@ static int wdog_reboot_handler(struct notifier_block *this, unsigned long code, void *unused) { - static int reboot_event_handled; + static int reboot_event_handled = 0; if ((watchdog_user) && (!reboot_event_handled)) { /* Make sure we only do this once. */ @@ -1138,7 +1115,7 @@ static int wdog_panic_handler(struct notifier_block *this, unsigned long event, void *unused) { - static int panic_event_handled; + static int panic_event_handled = 0; /* On a panic, if we have a panic timeout, make sure to extend the watchdog timer to a reasonable value to complete the @@ -1148,7 +1125,7 @@ static int wdog_panic_handler(struct notifier_block *this, ipmi_watchdog_state != WDOG_TIMEOUT_NONE) { /* Make sure we do this only once. */ panic_event_handled = 1; - + timeout = 255; pretimeout = 0; panic_halt_ipmi_set_timeout(); @@ -1174,7 +1151,8 @@ static void ipmi_smi_gone(int if_num) ipmi_unregister_watchdog(if_num); } -static struct ipmi_smi_watcher smi_watcher = { +static struct ipmi_smi_watcher smi_watcher = +{ .owner = THIS_MODULE, .new_smi = ipmi_new_smi, .smi_gone = ipmi_smi_gone diff --git a/trunk/drivers/char/mem.c b/trunk/drivers/char/mem.c index 934ffafedaea..e83623ead441 100644 --- a/trunk/drivers/char/mem.c +++ b/trunk/drivers/char/mem.c @@ -364,7 +364,6 @@ static int mmap_mem(struct file * file, struct vm_area_struct * vma) return 0; } -#ifdef CONFIG_DEVKMEM static int mmap_kmem(struct file * file, struct vm_area_struct * vma) { unsigned long pfn; @@ -385,7 +384,6 @@ static int mmap_kmem(struct file * file, struct vm_area_struct * vma) vma->vm_pgoff = pfn; return mmap_mem(file, vma); } -#endif #ifdef CONFIG_CRASH_DUMP /* @@ -424,7 +422,6 @@ static ssize_t read_oldmem(struct file *file, char __user *buf, extern long vread(char *buf, char *addr, unsigned long count); extern long vwrite(char *buf, char *addr, unsigned long count); -#ifdef CONFIG_DEVKMEM /* * This function reads the *virtual* memory as seen by the kernel. */ @@ -629,7 +626,6 @@ static ssize_t write_kmem(struct file * file, const char __user * buf, *ppos = p; return virtr + wrote; } -#endif #ifdef CONFIG_DEVPORT static ssize_t read_port(struct file * file, char __user * buf, @@ -807,7 +803,6 @@ static const struct file_operations mem_fops = { .get_unmapped_area = get_unmapped_area_mem, }; -#ifdef CONFIG_DEVKMEM static const struct file_operations kmem_fops = { .llseek = memory_lseek, .read = read_kmem, @@ -816,7 +811,6 @@ static const struct file_operations kmem_fops = { .open = open_kmem, .get_unmapped_area = get_unmapped_area_mem, }; -#endif static const struct file_operations null_fops = { .llseek = null_lseek, @@ -895,13 +889,11 @@ static int memory_open(struct inode * inode, struct file * filp) filp->f_mapping->backing_dev_info = &directly_mappable_cdev_bdi; break; -#ifdef CONFIG_DEVKMEM case 2: filp->f_op = &kmem_fops; filp->f_mapping->backing_dev_info = &directly_mappable_cdev_bdi; break; -#endif case 3: filp->f_op = &null_fops; break; @@ -950,9 +942,7 @@ static const struct { const struct file_operations *fops; } devlist[] = { /* list of minor devices */ {1, "mem", S_IRUSR | S_IWUSR | S_IRGRP, &mem_fops}, -#ifdef CONFIG_DEVKMEM {2, "kmem", S_IRUSR | S_IWUSR | S_IRGRP, &kmem_fops}, -#endif {3, "null", S_IRUGO | S_IWUGO, &null_fops}, #ifdef CONFIG_DEVPORT {4, "port", S_IRUSR | S_IWUSR | S_IRGRP, &port_fops}, diff --git a/trunk/drivers/char/misc.c b/trunk/drivers/char/misc.c index eaace0db0ff4..4d058dadbfcc 100644 --- a/trunk/drivers/char/misc.c +++ b/trunk/drivers/char/misc.c @@ -263,26 +263,23 @@ EXPORT_SYMBOL(misc_deregister); static int __init misc_init(void) { - int err; - #ifdef CONFIG_PROC_FS - proc_create("misc", 0, NULL, &misc_proc_fops); + struct proc_dir_entry *ent; + + ent = create_proc_entry("misc", 0, NULL); + if (ent) + ent->proc_fops = &misc_proc_fops; #endif misc_class = class_create(THIS_MODULE, "misc"); - err = PTR_ERR(misc_class); if (IS_ERR(misc_class)) - goto fail_remove; + return PTR_ERR(misc_class); - err = -EIO; - if (register_chrdev(MISC_MAJOR,"misc",&misc_fops)) - goto fail_printk; + if (register_chrdev(MISC_MAJOR,"misc",&misc_fops)) { + printk("unable to get major %d for misc devices\n", + MISC_MAJOR); + class_destroy(misc_class); + return -EIO; + } return 0; - -fail_printk: - printk("unable to get major %d for misc devices\n", MISC_MAJOR); - class_destroy(misc_class); -fail_remove: - remove_proc_entry("misc", NULL); - return err; } subsys_initcall(misc_init); diff --git a/trunk/drivers/char/mspec.c b/trunk/drivers/char/mspec.c index fe2a95b5d3c0..ff146c2b08fd 100644 --- a/trunk/drivers/char/mspec.c +++ b/trunk/drivers/char/mspec.c @@ -180,7 +180,7 @@ mspec_close(struct vm_area_struct *vma) my_page = vdata->maddr[index]; vdata->maddr[index] = 0; if (!mspec_zero_block(my_page, PAGE_SIZE)) - uncached_free_page(my_page, 1); + uncached_free_page(my_page); else printk(KERN_WARNING "mspec_close(): " "failed to zero page %ld\n", my_page); @@ -209,7 +209,7 @@ mspec_nopfn(struct vm_area_struct *vma, unsigned long address) index = (address - vdata->vm_start) >> PAGE_SHIFT; maddr = (volatile unsigned long) vdata->maddr[index]; if (maddr == 0) { - maddr = uncached_alloc_page(numa_node_id(), 1); + maddr = uncached_alloc_page(numa_node_id()); if (maddr == 0) return NOPFN_OOM; @@ -218,7 +218,7 @@ mspec_nopfn(struct vm_area_struct *vma, unsigned long address) vdata->count++; vdata->maddr[index] = maddr; } else { - uncached_free_page(maddr, 1); + uncached_free_page(maddr); maddr = vdata->maddr[index]; } spin_unlock(&vdata->lock); @@ -367,7 +367,7 @@ mspec_init(void) int nasid; unsigned long phys; - scratch_page[nid] = uncached_alloc_page(nid, 1); + scratch_page[nid] = uncached_alloc_page(nid); if (scratch_page[nid] == 0) goto free_scratch_pages; phys = __pa(scratch_page[nid]); @@ -414,7 +414,7 @@ mspec_init(void) free_scratch_pages: for_each_node(nid) { if (scratch_page[nid] != 0) - uncached_free_page(scratch_page[nid], 1); + uncached_free_page(scratch_page[nid]); } return ret; } @@ -431,7 +431,7 @@ mspec_exit(void) for_each_node(nid) { if (scratch_page[nid] != 0) - uncached_free_page(scratch_page[nid], 1); + uncached_free_page(scratch_page[nid]); } } } diff --git a/trunk/drivers/char/pcmcia/ipwireless/hardware.c b/trunk/drivers/char/pcmcia/ipwireless/hardware.c index fa9d3c945f31..1f978ff87fa8 100644 --- a/trunk/drivers/char/pcmcia/ipwireless/hardware.c +++ b/trunk/drivers/char/pcmcia/ipwireless/hardware.c @@ -354,6 +354,32 @@ struct ipw_rx_packet { unsigned int channel_idx; }; +#ifdef IPWIRELESS_STATE_DEBUG +int ipwireless_dump_hardware_state(char *p, size_t limit, + struct ipw_hardware *hw) +{ + return snprintf(p, limit, + "debug: initializing=%d\n" + "debug: tx_ready=%d\n" + "debug: tx_queued=%d\n" + "debug: rx_ready=%d\n" + "debug: rx_bytes_queued=%d\n" + "debug: blocking_rx=%d\n" + "debug: removed=%d\n" + "debug: hardware.shutting_down=%d\n" + "debug: to_setup=%d\n", + hw->initializing, + hw->tx_ready, + hw->tx_queued, + hw->rx_ready, + hw->rx_bytes_queued, + hw->blocking_rx, + hw->removed, + hw->shutting_down, + hw->to_setup); +} +#endif + static char *data_type(const unsigned char *buf, unsigned length) { struct nl_packet_header *hdr = (struct nl_packet_header *) buf; diff --git a/trunk/drivers/char/pcmcia/ipwireless/hardware.h b/trunk/drivers/char/pcmcia/ipwireless/hardware.h index 19ce5eb266b1..c83190ffb0e7 100644 --- a/trunk/drivers/char/pcmcia/ipwireless/hardware.h +++ b/trunk/drivers/char/pcmcia/ipwireless/hardware.h @@ -58,5 +58,7 @@ void ipwireless_init_hardware_v1(struct ipw_hardware *hw, void *reboot_cb_data); void ipwireless_init_hardware_v2_v3(struct ipw_hardware *hw); void ipwireless_sleep(unsigned int tenths); +int ipwireless_dump_hardware_state(char *p, size_t limit, + struct ipw_hardware *hw); #endif diff --git a/trunk/drivers/char/pcmcia/ipwireless/network.c b/trunk/drivers/char/pcmcia/ipwireless/network.c index fe914d34f7f6..d793e68b3e0d 100644 --- a/trunk/drivers/char/pcmcia/ipwireless/network.c +++ b/trunk/drivers/char/pcmcia/ipwireless/network.c @@ -63,6 +63,21 @@ struct ipw_network { struct work_struct work_go_offline; }; + +#ifdef IPWIRELESS_STATE_DEBUG +int ipwireless_dump_network_state(char *p, size_t limit, + struct ipw_network *network) +{ + return snprintf(p, limit, + "debug: ppp_blocked=%d\n" + "debug: outgoing_packets_queued=%d\n" + "debug: network.shutting_down=%d\n", + network->ppp_blocked, + network->outgoing_packets_queued, + network->shutting_down); +} +#endif + static void notify_packet_sent(void *callback_data, unsigned int packet_length) { struct ipw_network *network = callback_data; diff --git a/trunk/drivers/char/pcmcia/ipwireless/network.h b/trunk/drivers/char/pcmcia/ipwireless/network.h index ccacd26fc7ef..b0e1e952fd14 100644 --- a/trunk/drivers/char/pcmcia/ipwireless/network.h +++ b/trunk/drivers/char/pcmcia/ipwireless/network.h @@ -49,4 +49,7 @@ void ipwireless_ppp_close(struct ipw_network *net); int ipwireless_ppp_channel_index(struct ipw_network *net); int ipwireless_ppp_unit_number(struct ipw_network *net); +int ipwireless_dump_network_state(char *p, size_t limit, + struct ipw_network *net); + #endif diff --git a/trunk/drivers/char/random.c b/trunk/drivers/char/random.c index 0cf98bd4f2d2..f43c89f7c449 100644 --- a/trunk/drivers/char/random.c +++ b/trunk/drivers/char/random.c @@ -272,7 +272,7 @@ static int random_write_wakeup_thresh = 128; static int trickle_thresh __read_mostly = INPUT_POOL_WORDS * 28; -static DEFINE_PER_CPU(int, trickle_count); +static DEFINE_PER_CPU(int, trickle_count) = 0; /* * A pool of size .poolwords is stirred with a primitive polynomial @@ -370,19 +370,17 @@ static struct poolinfo { */ static DECLARE_WAIT_QUEUE_HEAD(random_read_wait); static DECLARE_WAIT_QUEUE_HEAD(random_write_wait); -static struct fasync_struct *fasync; #if 0 -static int debug; +static int debug = 0; module_param(debug, bool, 0644); -#define DEBUG_ENT(fmt, arg...) do { \ - if (debug) \ - printk(KERN_DEBUG "random %04d %04d %04d: " \ - fmt,\ - input_pool.entropy_count,\ - blocking_pool.entropy_count,\ - nonblocking_pool.entropy_count,\ - ## arg); } while (0) +#define DEBUG_ENT(fmt, arg...) do { if (debug) \ + printk(KERN_DEBUG "random %04d %04d %04d: " \ + fmt,\ + input_pool.entropy_count,\ + blocking_pool.entropy_count,\ + nonblocking_pool.entropy_count,\ + ## arg); } while (0) #else #define DEBUG_ENT(fmt, arg...) do {} while (0) #endif @@ -396,7 +394,7 @@ module_param(debug, bool, 0644); struct entropy_store; struct entropy_store { - /* read-only data: */ + /* mostly-read data: */ struct poolinfo *poolinfo; __u32 *pool; const char *name; @@ -404,7 +402,7 @@ struct entropy_store { struct entropy_store *pull; /* read-write data: */ - spinlock_t lock; + spinlock_t lock ____cacheline_aligned_in_smp; unsigned add_ptr; int entropy_count; int input_rotate; @@ -440,26 +438,25 @@ static struct entropy_store nonblocking_pool = { }; /* - * This function adds bytes into the entropy "pool". It does not + * This function adds a byte into the entropy "pool". It does not * update the entropy estimate. The caller should call - * credit_entropy_bits if this is appropriate. + * credit_entropy_store if this is appropriate. * * The pool is stirred with a primitive polynomial of the appropriate * degree, and then twisted. We twist by three bits at a time because * it's cheap to do so and helps slightly in the expected case where * the entropy is concentrated in the low-order bits. */ -static void mix_pool_bytes_extract(struct entropy_store *r, const void *in, - int nbytes, __u8 out[64]) +static void __add_entropy_words(struct entropy_store *r, const __u32 *in, + int nwords, __u32 out[16]) { static __u32 const twist_table[8] = { 0x00000000, 0x3b6e20c8, 0x76dc4190, 0x4db26158, 0xedb88320, 0xd6d6a3e8, 0x9b64c2b0, 0xa00ae278 }; - unsigned long i, j, tap1, tap2, tap3, tap4, tap5; - int input_rotate; + unsigned long i, add_ptr, tap1, tap2, tap3, tap4, tap5; + int new_rotate, input_rotate; int wordmask = r->poolinfo->poolwords - 1; - const char *bytes = in; - __u32 w; + __u32 w, next_w; unsigned long flags; /* Taps are constant, so we can load them without holding r->lock. */ @@ -468,76 +465,78 @@ static void mix_pool_bytes_extract(struct entropy_store *r, const void *in, tap3 = r->poolinfo->tap3; tap4 = r->poolinfo->tap4; tap5 = r->poolinfo->tap5; + next_w = *in++; spin_lock_irqsave(&r->lock, flags); + prefetch_range(r->pool, wordmask); input_rotate = r->input_rotate; - i = r->add_ptr; + add_ptr = r->add_ptr; - /* mix one byte at a time to simplify size handling and churn faster */ - while (nbytes--) { - w = rol32(*bytes++, input_rotate & 31); - i = (i - 1) & wordmask; + while (nwords--) { + w = rol32(next_w, input_rotate); + if (nwords > 0) + next_w = *in++; + i = add_ptr = (add_ptr - 1) & wordmask; + /* + * Normally, we add 7 bits of rotation to the pool. + * At the beginning of the pool, add an extra 7 bits + * rotation, so that successive passes spread the + * input bits across the pool evenly. + */ + new_rotate = input_rotate + 14; + if (i) + new_rotate = input_rotate + 7; + input_rotate = new_rotate & 31; /* XOR in the various taps */ - w ^= r->pool[i]; w ^= r->pool[(i + tap1) & wordmask]; w ^= r->pool[(i + tap2) & wordmask]; w ^= r->pool[(i + tap3) & wordmask]; w ^= r->pool[(i + tap4) & wordmask]; w ^= r->pool[(i + tap5) & wordmask]; - - /* Mix the result back in with a twist */ + w ^= r->pool[i]; r->pool[i] = (w >> 3) ^ twist_table[w & 7]; - - /* - * Normally, we add 7 bits of rotation to the pool. - * At the beginning of the pool, add an extra 7 bits - * rotation, so that successive passes spread the - * input bits across the pool evenly. - */ - input_rotate += i ? 7 : 14; } r->input_rotate = input_rotate; - r->add_ptr = i; + r->add_ptr = add_ptr; - if (out) - for (j = 0; j < 16; j++) - ((__u32 *)out)[j] = r->pool[(i - j) & wordmask]; + if (out) { + for (i = 0; i < 16; i++) { + out[i] = r->pool[add_ptr]; + add_ptr = (add_ptr - 1) & wordmask; + } + } spin_unlock_irqrestore(&r->lock, flags); } -static void mix_pool_bytes(struct entropy_store *r, const void *in, int bytes) +static inline void add_entropy_words(struct entropy_store *r, const __u32 *in, + int nwords) { - mix_pool_bytes_extract(r, in, bytes, NULL); + __add_entropy_words(r, in, nwords, NULL); } /* * Credit (or debit) the entropy store with n bits of entropy */ -static void credit_entropy_bits(struct entropy_store *r, int nbits) +static void credit_entropy_store(struct entropy_store *r, int nbits) { unsigned long flags; - if (!nbits) - return; - spin_lock_irqsave(&r->lock, flags); - DEBUG_ENT("added %d entropy credits to %s\n", nbits, r->name); - r->entropy_count += nbits; - if (r->entropy_count < 0) { - DEBUG_ENT("negative entropy/overflow\n"); + if (r->entropy_count + nbits < 0) { + DEBUG_ENT("negative entropy/overflow (%d+%d)\n", + r->entropy_count, nbits); r->entropy_count = 0; - } else if (r->entropy_count > r->poolinfo->POOLBITS) + } else if (r->entropy_count + nbits > r->poolinfo->POOLBITS) { r->entropy_count = r->poolinfo->POOLBITS; - - /* should we wake readers? */ - if (r == &input_pool && - r->entropy_count >= random_read_wakeup_thresh) { - wake_up_interruptible(&random_read_wait); - kill_fasync(&fasync, SIGIO, POLL_IN); + } else { + r->entropy_count += nbits; + if (nbits) + DEBUG_ENT("added %d entropy credits to %s\n", + nbits, r->name); } spin_unlock_irqrestore(&r->lock, flags); @@ -552,7 +551,7 @@ static void credit_entropy_bits(struct entropy_store *r, int nbits) /* There is one of these per entropy source */ struct timer_rand_state { cycles_t last_time; - long last_delta, last_delta2; + long last_delta,last_delta2; unsigned dont_count_entropy:1; }; @@ -587,7 +586,7 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num) sample.jiffies = jiffies; sample.cycles = get_cycles(); sample.num = num; - mix_pool_bytes(&input_pool, &sample, sizeof(sample)); + add_entropy_words(&input_pool, (u32 *)&sample, sizeof(sample)/4); /* * Calculate number of bits of randomness we probably added. @@ -621,9 +620,13 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num) * Round down by 1 bit on general principles, * and limit entropy entimate to 12 bits. */ - credit_entropy_bits(&input_pool, - min_t(int, fls(delta>>1), 11)); + credit_entropy_store(&input_pool, + min_t(int, fls(delta>>1), 11)); } + + if(input_pool.entropy_count >= random_read_wakeup_thresh) + wake_up_interruptible(&random_read_wait); + out: preempt_enable(); } @@ -674,7 +677,7 @@ void add_disk_randomness(struct gendisk *disk) * *********************************************************************/ -static ssize_t extract_entropy(struct entropy_store *r, void *buf, +static ssize_t extract_entropy(struct entropy_store *r, void * buf, size_t nbytes, int min, int rsvd); /* @@ -701,10 +704,10 @@ static void xfer_secondary_pool(struct entropy_store *r, size_t nbytes) "(%d of %d requested)\n", r->name, bytes * 8, nbytes * 8, r->entropy_count); - bytes = extract_entropy(r->pull, tmp, bytes, - random_read_wakeup_thresh / 8, rsvd); - mix_pool_bytes(r, tmp, bytes); - credit_entropy_bits(r, bytes*8); + bytes=extract_entropy(r->pull, tmp, bytes, + random_read_wakeup_thresh / 8, rsvd); + add_entropy_words(r, tmp, (bytes + 3) / 4); + credit_entropy_store(r, bytes*8); } } @@ -741,15 +744,13 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min, if (r->limit && nbytes + reserved >= r->entropy_count / 8) nbytes = r->entropy_count/8 - reserved; - if (r->entropy_count / 8 >= nbytes + reserved) + if(r->entropy_count / 8 >= nbytes + reserved) r->entropy_count -= nbytes*8; else r->entropy_count = reserved; - if (r->entropy_count < random_write_wakeup_thresh) { + if (r->entropy_count < random_write_wakeup_thresh) wake_up_interruptible(&random_write_wait); - kill_fasync(&fasync, SIGIO, POLL_OUT); - } } DEBUG_ENT("debiting %d entropy credits from %s%s\n", @@ -763,46 +764,45 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min, static void extract_buf(struct entropy_store *r, __u8 *out) { int i; - __u32 hash[5], workspace[SHA_WORKSPACE_WORDS]; - __u8 extract[64]; - - /* Generate a hash across the pool, 16 words (512 bits) at a time */ - sha_init(hash); - for (i = 0; i < r->poolinfo->poolwords; i += 16) - sha_transform(hash, (__u8 *)(r->pool + i), workspace); + __u32 data[16], buf[5 + SHA_WORKSPACE_WORDS]; + sha_init(buf); /* - * We mix the hash back into the pool to prevent backtracking - * attacks (where the attacker knows the state of the pool - * plus the current outputs, and attempts to find previous - * ouputs), unless the hash function can be inverted. By - * mixing at least a SHA1 worth of hash data back, we make - * brute-forcing the feedback as hard as brute-forcing the - * hash. + * As we hash the pool, we mix intermediate values of + * the hash back into the pool. This eliminates + * backtracking attacks (where the attacker knows + * the state of the pool plus the current outputs, and + * attempts to find previous ouputs), unless the hash + * function can be inverted. */ - mix_pool_bytes_extract(r, hash, sizeof(hash), extract); + for (i = 0; i < r->poolinfo->poolwords; i += 16) { + /* hash blocks of 16 words = 512 bits */ + sha_transform(buf, (__u8 *)(r->pool + i), buf + 5); + /* feed back portion of the resulting hash */ + add_entropy_words(r, &buf[i % 5], 1); + } /* - * To avoid duplicates, we atomically extract a portion of the - * pool while mixing, and hash one final time. + * To avoid duplicates, we atomically extract a + * portion of the pool while mixing, and hash one + * final time. */ - sha_transform(hash, extract, workspace); - memset(extract, 0, sizeof(extract)); - memset(workspace, 0, sizeof(workspace)); + __add_entropy_words(r, &buf[i % 5], 1, data); + sha_transform(buf, (__u8 *)data, buf + 5); /* - * In case the hash function has some recognizable output - * pattern, we fold it in half. Thus, we always feed back - * twice as much data as we output. + * In case the hash function has some recognizable + * output pattern, we fold it in half. */ - hash[0] ^= hash[3]; - hash[1] ^= hash[4]; - hash[2] ^= rol32(hash[2], 16); - memcpy(out, hash, EXTRACT_SIZE); - memset(hash, 0, sizeof(hash)); + + buf[0] ^= buf[3]; + buf[1] ^= buf[4]; + buf[2] ^= rol32(buf[2], 16); + memcpy(out, buf, EXTRACT_SIZE); + memset(buf, 0, sizeof(buf)); } -static ssize_t extract_entropy(struct entropy_store *r, void *buf, +static ssize_t extract_entropy(struct entropy_store *r, void * buf, size_t nbytes, int min, int reserved) { ssize_t ret = 0, i; @@ -872,6 +872,7 @@ void get_random_bytes(void *buf, int nbytes) { extract_entropy(&nonblocking_pool, buf, nbytes, 0, 0); } + EXPORT_SYMBOL(get_random_bytes); /* @@ -893,11 +894,12 @@ static void init_std_data(struct entropy_store *r) spin_unlock_irqrestore(&r->lock, flags); now = ktime_get_real(); - mix_pool_bytes(r, &now, sizeof(now)); - mix_pool_bytes(r, utsname(), sizeof(*(utsname()))); + add_entropy_words(r, (__u32 *)&now, sizeof(now)/4); + add_entropy_words(r, (__u32 *)utsname(), + sizeof(*(utsname()))/4); } -static int rand_initialize(void) +static int __init rand_initialize(void) { init_std_data(&input_pool); init_std_data(&blocking_pool); @@ -938,7 +940,7 @@ void rand_initialize_disk(struct gendisk *disk) #endif static ssize_t -random_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) +random_read(struct file * file, char __user * buf, size_t nbytes, loff_t *ppos) { ssize_t n, retval = 0, count = 0; @@ -1000,7 +1002,8 @@ random_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) } static ssize_t -urandom_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) +urandom_read(struct file * file, char __user * buf, + size_t nbytes, loff_t *ppos) { return extract_entropy_user(&nonblocking_pool, buf, nbytes); } @@ -1035,15 +1038,16 @@ write_pool(struct entropy_store *r, const char __user *buffer, size_t count) count -= bytes; p += bytes; - mix_pool_bytes(r, buf, bytes); + add_entropy_words(r, buf, (bytes + 3) / 4); cond_resched(); } return 0; } -static ssize_t random_write(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos) +static ssize_t +random_write(struct file * file, const char __user * buffer, + size_t count, loff_t *ppos) { size_t ret; struct inode *inode = file->f_path.dentry->d_inode; @@ -1060,7 +1064,9 @@ static ssize_t random_write(struct file *file, const char __user *buffer, return (ssize_t)count; } -static long random_ioctl(struct file *f, unsigned int cmd, unsigned long arg) +static int +random_ioctl(struct inode * inode, struct file * file, + unsigned int cmd, unsigned long arg) { int size, ent_count; int __user *p = (int __user *)arg; @@ -1068,8 +1074,8 @@ static long random_ioctl(struct file *f, unsigned int cmd, unsigned long arg) switch (cmd) { case RNDGETENTCNT: - /* inherently racy, no point locking */ - if (put_user(input_pool.entropy_count, p)) + ent_count = input_pool.entropy_count; + if (put_user(ent_count, p)) return -EFAULT; return 0; case RNDADDTOENTCNT: @@ -1077,7 +1083,13 @@ static long random_ioctl(struct file *f, unsigned int cmd, unsigned long arg) return -EPERM; if (get_user(ent_count, p)) return -EFAULT; - credit_entropy_bits(&input_pool, ent_count); + credit_entropy_store(&input_pool, ent_count); + /* + * Wake up waiting processes if we have enough + * entropy. + */ + if (input_pool.entropy_count >= random_read_wakeup_thresh) + wake_up_interruptible(&random_read_wait); return 0; case RNDADDENTROPY: if (!capable(CAP_SYS_ADMIN)) @@ -1092,45 +1104,39 @@ static long random_ioctl(struct file *f, unsigned int cmd, unsigned long arg) size); if (retval < 0) return retval; - credit_entropy_bits(&input_pool, ent_count); + credit_entropy_store(&input_pool, ent_count); + /* + * Wake up waiting processes if we have enough + * entropy. + */ + if (input_pool.entropy_count >= random_read_wakeup_thresh) + wake_up_interruptible(&random_read_wait); return 0; case RNDZAPENTCNT: case RNDCLEARPOOL: /* Clear the entropy pool counters. */ if (!capable(CAP_SYS_ADMIN)) return -EPERM; - rand_initialize(); + init_std_data(&input_pool); + init_std_data(&blocking_pool); + init_std_data(&nonblocking_pool); return 0; default: return -EINVAL; } } -static int random_fasync(int fd, struct file *filp, int on) -{ - return fasync_helper(fd, filp, on, &fasync); -} - -static int random_release(struct inode *inode, struct file *filp) -{ - return fasync_helper(-1, filp, 0, &fasync); -} - const struct file_operations random_fops = { .read = random_read, .write = random_write, .poll = random_poll, - .unlocked_ioctl = random_ioctl, - .fasync = random_fasync, - .release = random_release, + .ioctl = random_ioctl, }; const struct file_operations urandom_fops = { .read = urandom_read, .write = random_write, - .unlocked_ioctl = random_ioctl, - .fasync = random_fasync, - .release = random_release, + .ioctl = random_ioctl, }; /*************************************************************** @@ -1151,6 +1157,7 @@ void generate_random_uuid(unsigned char uuid_out[16]) /* Set the UUID variant to DCE */ uuid_out[8] = (uuid_out[8] & 0x3F) | 0x80; } + EXPORT_SYMBOL(generate_random_uuid); /******************************************************************** @@ -1332,7 +1339,7 @@ ctl_table random_table[] = { #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) -static __u32 twothirdsMD4Transform(__u32 const buf[4], __u32 const in[12]) +static __u32 twothirdsMD4Transform (__u32 const buf[4], __u32 const in[12]) { __u32 a = buf[0], b = buf[1], c = buf[2], d = buf[3]; @@ -1480,8 +1487,8 @@ __u32 secure_tcpv6_sequence_number(__be32 *saddr, __be32 *daddr, */ memcpy(hash, saddr, 16); - hash[4] = ((__force u16)sport << 16) + (__force u16)dport; - memcpy(&hash[5], keyptr->secret, sizeof(__u32) * 7); + hash[4]=((__force u16)sport << 16) + (__force u16)dport; + memcpy(&hash[5],keyptr->secret,sizeof(__u32) * 7); seq = twothirdsMD4Transform((const __u32 *)daddr, hash) & HASH_MASK; seq += keyptr->count; @@ -1531,10 +1538,10 @@ __u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr, * Note that the words are placed into the starting vector, which is * then mixed with a partial MD4 over random data. */ - hash[0] = (__force u32)saddr; - hash[1] = (__force u32)daddr; - hash[2] = ((__force u16)sport << 16) + (__force u16)dport; - hash[3] = keyptr->secret[11]; + hash[0]=(__force u32)saddr; + hash[1]=(__force u32)daddr; + hash[2]=((__force u16)sport << 16) + (__force u16)dport; + hash[3]=keyptr->secret[11]; seq = half_md4_transform(hash, keyptr->secret) & HASH_MASK; seq += keyptr->count; @@ -1549,7 +1556,10 @@ __u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr, * Choosing a clock of 64 ns period is OK. (period of 274 s) */ seq += ktime_to_ns(ktime_get_real()) >> 6; - +#if 0 + printk("init_seq(%lx, %lx, %d, %d) = %d\n", + saddr, daddr, sport, dport, seq); +#endif return seq; } @@ -1572,15 +1582,14 @@ u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport) } #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) -u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr, - __be16 dport) +u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr, __be16 dport) { struct keydata *keyptr = get_keyptr(); u32 hash[12]; memcpy(hash, saddr, 16); hash[4] = (__force u32)dport; - memcpy(&hash[5], keyptr->secret, sizeof(__u32) * 7); + memcpy(&hash[5],keyptr->secret,sizeof(__u32) * 7); return twothirdsMD4Transform((const __u32 *)daddr, hash); } @@ -1608,9 +1617,13 @@ u64 secure_dccp_sequence_number(__be32 saddr, __be32 daddr, seq += ktime_to_ns(ktime_get_real()); seq &= (1ull << 48) - 1; - +#if 0 + printk("dccp init_seq(%lx, %lx, %d, %d) = %d\n", + saddr, daddr, sport, dport, seq); +#endif return seq; } + EXPORT_SYMBOL(secure_dccp_sequence_number); #endif diff --git a/trunk/drivers/char/rocket_int.h b/trunk/drivers/char/rocket_int.h index 143cc432fdb2..b01d38125a8f 100644 --- a/trunk/drivers/char/rocket_int.h +++ b/trunk/drivers/char/rocket_int.h @@ -55,7 +55,7 @@ static inline void sOutW(unsigned short port, unsigned short value) static inline void out32(unsigned short port, Byte_t *p) { - u32 value = get_unaligned_le32(p); + u32 value = le32_to_cpu(get_unaligned((__le32 *)p)); #ifdef ROCKET_DEBUG_IO printk(KERN_DEBUG "out32(%x, %lx)...\n", port, value); #endif diff --git a/trunk/drivers/char/rtc.c b/trunk/drivers/char/rtc.c index 5f80a9dff573..e2ec2ee4cf79 100644 --- a/trunk/drivers/char/rtc.c +++ b/trunk/drivers/char/rtc.c @@ -1069,8 +1069,10 @@ static int __init rtc_init(void) } #ifdef CONFIG_PROC_FS - ent = proc_create("driver/rtc", 0, NULL, &rtc_proc_fops); - if (!ent) + ent = create_proc_entry("driver/rtc", 0, NULL); + if (ent) + ent->proc_fops = &rtc_proc_fops; + else printk(KERN_WARNING "rtc: Failed to register with procfs.\n"); #endif diff --git a/trunk/drivers/char/snsc_event.c b/trunk/drivers/char/snsc_event.c index 31a7765eaf73..1b75b0b7d542 100644 --- a/trunk/drivers/char/snsc_event.c +++ b/trunk/drivers/char/snsc_event.c @@ -63,13 +63,16 @@ static int scdrv_parse_event(char *event, int *src, int *code, int *esp_code, char *desc) { char *desc_end; + __be32 from_buf; /* record event source address */ - *src = get_unaligned_be32(event); + from_buf = get_unaligned((__be32 *)event); + *src = be32_to_cpup(&from_buf); event += 4; /* move on to event code */ /* record the system controller's event code */ - *code = get_unaligned_be32(event); + from_buf = get_unaligned((__be32 *)event); + *code = be32_to_cpup(&from_buf); event += 4; /* move on to event arguments */ /* how many arguments are in the packet? */ @@ -83,7 +86,8 @@ scdrv_parse_event(char *event, int *src, int *code, int *esp_code, char *desc) /* not an integer argument, so give up */ return -1; } - *esp_code = get_unaligned_be32(event); + from_buf = get_unaligned((__be32 *)event); + *esp_code = be32_to_cpup(&from_buf); event += 4; /* parse out the event description */ diff --git a/trunk/drivers/char/sysrq.c b/trunk/drivers/char/sysrq.c index 9e9bad8bdcf4..1ade193c9128 100644 --- a/trunk/drivers/char/sysrq.c +++ b/trunk/drivers/char/sysrq.c @@ -196,48 +196,6 @@ static struct sysrq_key_op sysrq_showlocks_op = { #define sysrq_showlocks_op (*(struct sysrq_key_op *)0) #endif -#ifdef CONFIG_SMP -static DEFINE_SPINLOCK(show_lock); - -static void showacpu(void *dummy) -{ - unsigned long flags; - - /* Idle CPUs have no interesting backtrace. */ - if (idle_cpu(smp_processor_id())) - return; - - spin_lock_irqsave(&show_lock, flags); - printk(KERN_INFO "CPU%d:\n", smp_processor_id()); - show_stack(NULL, NULL); - spin_unlock_irqrestore(&show_lock, flags); -} - -static void sysrq_showregs_othercpus(struct work_struct *dummy) -{ - smp_call_function(showacpu, NULL, 0, 0); -} - -static DECLARE_WORK(sysrq_showallcpus, sysrq_showregs_othercpus); - -static void sysrq_handle_showallcpus(int key, struct tty_struct *tty) -{ - struct pt_regs *regs = get_irq_regs(); - if (regs) { - printk(KERN_INFO "CPU%d:\n", smp_processor_id()); - show_regs(regs); - } - schedule_work(&sysrq_showallcpus); -} - -static struct sysrq_key_op sysrq_showallcpus_op = { - .handler = sysrq_handle_showallcpus, - .help_msg = "aLlcpus", - .action_msg = "Show backtrace of all active CPUs", - .enable_mask = SYSRQ_ENABLE_DUMP, -}; -#endif - static void sysrq_handle_showregs(int key, struct tty_struct *tty) { struct pt_regs *regs = get_irq_regs(); @@ -382,11 +340,7 @@ static struct sysrq_key_op *sysrq_key_table[36] = { &sysrq_kill_op, /* i */ NULL, /* j */ &sysrq_SAK_op, /* k */ -#ifdef CONFIG_SMP - &sysrq_showallcpus_op, /* l */ -#else NULL, /* l */ -#endif &sysrq_showmem_op, /* m */ &sysrq_unrt_op, /* n */ /* o: This will often be registered as 'Off' at init time */ diff --git a/trunk/drivers/char/toshiba.c b/trunk/drivers/char/toshiba.c index 64f1ceed0b2c..ce5ebe3b168f 100644 --- a/trunk/drivers/char/toshiba.c +++ b/trunk/drivers/char/toshiba.c @@ -520,11 +520,12 @@ static int __init toshiba_init(void) { struct proc_dir_entry *pde; - pde = proc_create("toshiba", 0, NULL, &proc_toshiba_fops); + pde = create_proc_entry("toshiba", 0, NULL); if (!pde) { misc_deregister(&tosh_device); return -ENOMEM; } + pde->proc_fops = &proc_toshiba_fops; } #endif diff --git a/trunk/drivers/char/tpm/Kconfig b/trunk/drivers/char/tpm/Kconfig index 3738cfa209ff..8f3f7620f95a 100644 --- a/trunk/drivers/char/tpm/Kconfig +++ b/trunk/drivers/char/tpm/Kconfig @@ -23,7 +23,7 @@ if TCG_TPM config TCG_TIS tristate "TPM Interface Specification 1.2 Interface" - depends on PNP + depends on PNPACPI ---help--- If you have a TPM security chip that is compliant with the TCG TIS 1.2 TPM specification say Yes and it will be accessible @@ -32,6 +32,7 @@ config TCG_TIS config TCG_NSC tristate "National Semiconductor TPM Interface" + depends on PNPACPI ---help--- If you have a TPM security chip from National Semiconductor say Yes and it will be accessible from within Linux. To @@ -47,7 +48,7 @@ config TCG_ATMEL config TCG_INFINEON tristate "Infineon Technologies TPM Interface" - depends on PNP + depends on PNPACPI ---help--- If you have a TPM security chip from Infineon Technologies (either SLD 9630 TT 1.1 or SLB 9635 TT 1.2) say Yes and it diff --git a/trunk/drivers/char/tpm/tpm_nsc.c b/trunk/drivers/char/tpm/tpm_nsc.c index ab18c1e7b115..6313326bc41f 100644 --- a/trunk/drivers/char/tpm/tpm_nsc.c +++ b/trunk/drivers/char/tpm/tpm_nsc.c @@ -264,7 +264,7 @@ static const struct tpm_vendor_specific tpm_nsc = { static struct platform_device *pdev = NULL; -static void tpm_nsc_remove(struct device *dev) +static void __devexit tpm_nsc_remove(struct device *dev) { struct tpm_chip *chip = dev_get_drvdata(dev); if ( chip ) { diff --git a/trunk/drivers/char/tty_audit.c b/trunk/drivers/char/tty_audit.c index 6342b0534f4d..7722466e052f 100644 --- a/trunk/drivers/char/tty_audit.c +++ b/trunk/drivers/char/tty_audit.c @@ -92,7 +92,7 @@ static void tty_audit_buf_push(struct task_struct *tsk, uid_t loginuid, get_task_comm(name, tsk); audit_log_untrustedstring(ab, name); audit_log_format(ab, " data="); - audit_log_n_untrustedstring(ab, buf->data, buf->valid); + audit_log_n_untrustedstring(ab, buf->valid, buf->data); audit_log_end(ab); } buf->valid = 0; @@ -151,9 +151,14 @@ void tty_audit_fork(struct signal_struct *sig) /** * tty_audit_push_task - Flush task's pending audit data */ -void tty_audit_push_task(struct task_struct *tsk, uid_t loginuid, u32 sessionid) +void tty_audit_push_task(struct task_struct *tsk, uid_t loginuid) { struct tty_audit_buf *buf; + /* FIXME I think this is correct. Check against netlink once that is + * I really need to read this code more closely. But that's for + * another patch. + */ + unsigned int sessionid = audit_get_sessionid(tsk); spin_lock_irq(&tsk->sighand->siglock); buf = tsk->signal->tty_audit_buf; @@ -233,10 +238,6 @@ void tty_audit_add_data(struct tty_struct *tty, unsigned char *data, if (unlikely(size == 0)) return; - if (tty->driver->type == TTY_DRIVER_TYPE_PTY - && tty->driver->subtype == PTY_TYPE_MASTER) - return; - buf = tty_audit_buf_get(tty); if (!buf) return; @@ -299,3 +300,53 @@ void tty_audit_push(struct tty_struct *tty) tty_audit_buf_put(buf); } } + +/** + * tty_audit_opening - A TTY is being opened. + * + * As a special hack, tasks that close all their TTYs and open new ones + * are assumed to be system daemons (e.g. getty) and auditing is + * automatically disabled for them. + */ +void tty_audit_opening(void) +{ + int disable; + + disable = 1; + spin_lock_irq(¤t->sighand->siglock); + if (current->signal->audit_tty == 0) + disable = 0; + spin_unlock_irq(¤t->sighand->siglock); + if (!disable) + return; + + task_lock(current); + if (current->files) { + struct fdtable *fdt; + unsigned i; + + /* + * We don't take a ref to the file, so we must hold ->file_lock + * instead. + */ + spin_lock(¤t->files->file_lock); + fdt = files_fdtable(current->files); + for (i = 0; i < fdt->max_fds; i++) { + struct file *filp; + + filp = fcheck_files(current->files, i); + if (filp && is_tty(filp)) { + disable = 0; + break; + } + } + spin_unlock(¤t->files->file_lock); + } + task_unlock(current); + if (!disable) + return; + + spin_lock_irq(¤t->sighand->siglock); + current->signal->audit_tty = 0; + spin_unlock_irq(¤t->sighand->siglock); +} diff --git a/trunk/drivers/char/tty_io.c b/trunk/drivers/char/tty_io.c index 2fa6856706ab..98b65a230994 100644 --- a/trunk/drivers/char/tty_io.c +++ b/trunk/drivers/char/tty_io.c @@ -2755,6 +2755,7 @@ static int tty_open(struct inode *inode, struct file *filp) __proc_set_tty(current, tty); spin_unlock_irq(¤t->sighand->siglock); mutex_unlock(&tty_mutex); + tty_audit_opening(); return 0; } @@ -2817,8 +2818,10 @@ static int ptmx_open(struct inode *inode, struct file *filp) check_tty_count(tty, "tty_open"); retval = ptm_driver->open(tty, filp); - if (!retval) + if (!retval) { + tty_audit_opening(); return 0; + } out1: release_dev(filp); return retval; diff --git a/trunk/drivers/char/viotape.c b/trunk/drivers/char/viotape.c index 58aad63831f4..db7a731e2362 100644 --- a/trunk/drivers/char/viotape.c +++ b/trunk/drivers/char/viotape.c @@ -249,7 +249,6 @@ static int proc_viotape_open(struct inode *inode, struct file *file) } static const struct file_operations proc_viotape_operations = { - .owner = THIS_MODULE, .open = proc_viotape_open, .read = seq_read, .llseek = seq_lseek, @@ -916,6 +915,7 @@ static struct vio_driver viotape_driver = { int __init viotap_init(void) { int ret; + struct proc_dir_entry *e; if (!firmware_has_feature(FW_FEATURE_ISERIES)) return -ENODEV; @@ -968,8 +968,11 @@ int __init viotap_init(void) if (ret) goto unreg_class; - proc_create("iSeries/viotape", S_IFREG|S_IRUGO, NULL, - &proc_viotape_operations); + e = create_proc_entry("iSeries/viotape", S_IFREG|S_IRUGO, NULL); + if (e) { + e->owner = THIS_MODULE; + e->proc_fops = &proc_viotape_operations; + } return 0; diff --git a/trunk/drivers/char/vt.c b/trunk/drivers/char/vt.c index 1c2660477135..df4c3ead9e2b 100644 --- a/trunk/drivers/char/vt.c +++ b/trunk/drivers/char/vt.c @@ -301,7 +301,7 @@ static void scrup(struct vc_data *vc, unsigned int t, unsigned int b, int nr) d = (unsigned short *)(vc->vc_origin + vc->vc_size_row * t); s = (unsigned short *)(vc->vc_origin + vc->vc_size_row * (t + nr)); scr_memmovew(d, s, (b - t - nr) * vc->vc_size_row); - scr_memsetw(d + (b - t - nr) * vc->vc_cols, vc->vc_scrl_erase_char, + scr_memsetw(d + (b - t - nr) * vc->vc_cols, vc->vc_video_erase_char, vc->vc_size_row * nr); } @@ -319,7 +319,7 @@ static void scrdown(struct vc_data *vc, unsigned int t, unsigned int b, int nr) s = (unsigned short *)(vc->vc_origin + vc->vc_size_row * t); step = vc->vc_cols * nr; scr_memmovew(s + step, s, (b - t - nr) * vc->vc_size_row); - scr_memsetw(s, vc->vc_scrl_erase_char, 2 * step); + scr_memsetw(s, vc->vc_video_erase_char, 2 * step); } static void do_update_region(struct vc_data *vc, unsigned long start, int count) @@ -400,7 +400,7 @@ static u8 build_attr(struct vc_data *vc, u8 _color, u8 _intensity, u8 _blink, * Bit 7 : blink */ { - u8 a = _color; + u8 a = vc->vc_color; if (!vc->vc_can_do_color) return _intensity | (_italic ? 2 : 0) | @@ -434,7 +434,6 @@ static void update_attr(struct vc_data *vc) vc->vc_blink, vc->vc_underline, vc->vc_reverse ^ vc->vc_decscnm, vc->vc_italic); vc->vc_video_erase_char = (build_attr(vc, vc->vc_color, 1, vc->vc_blink, 0, vc->vc_decscnm, 0) << 8) | ' '; - vc->vc_scrl_erase_char = (build_attr(vc, vc->vc_def_color, 1, false, false, false, false) << 8) | ' '; } /* Note: inverting the screen twice should revert to the original state */ diff --git a/trunk/drivers/cpufreq/Kconfig b/trunk/drivers/cpufreq/Kconfig index 5f076aef74fa..c159ae64eeb2 100644 --- a/trunk/drivers/cpufreq/Kconfig +++ b/trunk/drivers/cpufreq/Kconfig @@ -69,15 +69,6 @@ config CPU_FREQ_DEFAULT_GOV_PERFORMANCE the frequency statically to the highest frequency supported by the CPU. -config CPU_FREQ_DEFAULT_GOV_POWERSAVE - bool "powersave" - depends on EMBEDDED - select CPU_FREQ_GOV_POWERSAVE - help - Use the CPUFreq governor 'powersave' as default. This sets - the frequency statically to the lowest frequency supported by - the CPU. - config CPU_FREQ_DEFAULT_GOV_USERSPACE bool "userspace" select CPU_FREQ_GOV_USERSPACE diff --git a/trunk/drivers/cpufreq/cpufreq.c b/trunk/drivers/cpufreq/cpufreq.c index 7fce038fa57e..d3575f5ec6d2 100644 --- a/trunk/drivers/cpufreq/cpufreq.c +++ b/trunk/drivers/cpufreq/cpufreq.c @@ -583,13 +583,15 @@ static ssize_t show_scaling_available_governors(struct cpufreq_policy *policy, i += sprintf(&buf[i], "\n"); return i; } - -static ssize_t show_cpus(cpumask_t mask, char *buf) +/** + * show_affected_cpus - show the CPUs affected by each transition + */ +static ssize_t show_affected_cpus(struct cpufreq_policy *policy, char *buf) { ssize_t i = 0; unsigned int cpu; - for_each_cpu_mask(cpu, mask) { + for_each_cpu_mask(cpu, policy->cpus) { if (i) i += scnprintf(&buf[i], (PAGE_SIZE - i - 2), " "); i += scnprintf(&buf[i], (PAGE_SIZE - i - 2), "%u", cpu); @@ -600,25 +602,6 @@ static ssize_t show_cpus(cpumask_t mask, char *buf) return i; } -/** - * show_related_cpus - show the CPUs affected by each transition even if - * hw coordination is in use - */ -static ssize_t show_related_cpus(struct cpufreq_policy *policy, char *buf) -{ - if (cpus_empty(policy->related_cpus)) - return show_cpus(policy->cpus, buf); - return show_cpus(policy->related_cpus, buf); -} - -/** - * show_affected_cpus - show the CPUs affected by each transition - */ -static ssize_t show_affected_cpus(struct cpufreq_policy *policy, char *buf) -{ - return show_cpus(policy->cpus, buf); -} - static ssize_t store_scaling_setspeed(struct cpufreq_policy *policy, const char *buf, size_t count) { @@ -663,7 +646,6 @@ define_one_ro(cpuinfo_max_freq); define_one_ro(scaling_available_governors); define_one_ro(scaling_driver); define_one_ro(scaling_cur_freq); -define_one_ro(related_cpus); define_one_ro(affected_cpus); define_one_rw(scaling_min_freq); define_one_rw(scaling_max_freq); @@ -676,7 +658,6 @@ static struct attribute *default_attrs[] = { &scaling_min_freq.attr, &scaling_max_freq.attr, &affected_cpus.attr, - &related_cpus.attr, &scaling_governor.attr, &scaling_driver.attr, &scaling_available_governors.attr, diff --git a/trunk/drivers/cpufreq/cpufreq_powersave.c b/trunk/drivers/cpufreq/cpufreq_powersave.c index 88d2f44fba48..13fe06b94b0a 100644 --- a/trunk/drivers/cpufreq/cpufreq_powersave.c +++ b/trunk/drivers/cpufreq/cpufreq_powersave.c @@ -35,12 +35,12 @@ static int cpufreq_governor_powersave(struct cpufreq_policy *policy, return 0; } -struct cpufreq_governor cpufreq_gov_powersave = { +static struct cpufreq_governor cpufreq_gov_powersave = { .name = "powersave", .governor = cpufreq_governor_powersave, .owner = THIS_MODULE, }; -EXPORT_SYMBOL(cpufreq_gov_powersave); + static int __init cpufreq_gov_powersave_init(void) { @@ -58,9 +58,5 @@ MODULE_AUTHOR("Dominik Brodowski "); MODULE_DESCRIPTION("CPUfreq policy governor 'powersave'"); MODULE_LICENSE("GPL"); -#ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE -fs_initcall(cpufreq_gov_powersave_init); -#else module_init(cpufreq_gov_powersave_init); -#endif module_exit(cpufreq_gov_powersave_exit); diff --git a/trunk/drivers/cpufreq/cpufreq_stats.c b/trunk/drivers/cpufreq/cpufreq_stats.c index ae70d63a8b26..ef09e069433b 100644 --- a/trunk/drivers/cpufreq/cpufreq_stats.c +++ b/trunk/drivers/cpufreq/cpufreq_stats.c @@ -288,7 +288,7 @@ cpufreq_stat_notifier_trans (struct notifier_block *nb, unsigned long val, if (!stat) return 0; - old_index = stat->last_index; + old_index = freq_table_get_index(stat, freq->old); new_index = freq_table_get_index(stat, freq->new); cpufreq_stats_update(freq->cpu); diff --git a/trunk/drivers/edac/Kconfig b/trunk/drivers/edac/Kconfig index 6e6c3c4aea6b..2b382990fe58 100644 --- a/trunk/drivers/edac/Kconfig +++ b/trunk/drivers/edac/Kconfig @@ -67,7 +67,7 @@ config EDAC_E7XXX E7205, E7500, E7501 and E7505 server chipsets. config EDAC_E752X - tristate "Intel e752x (e7520, e7525, e7320) and 3100" + tristate "Intel e752x (e7520, e7525, e7320)" depends on EDAC_MM_EDAC && PCI && X86 && HOTPLUG help Support for error detection and correction on the Intel diff --git a/trunk/drivers/edac/amd76x_edac.c b/trunk/drivers/edac/amd76x_edac.c index 2b95f1a3edfc..f22075410591 100644 --- a/trunk/drivers/edac/amd76x_edac.c +++ b/trunk/drivers/edac/amd76x_edac.c @@ -17,7 +17,6 @@ #include #include #include -#include #include "edac_core.h" #define AMD76X_REVISION " Ver: 2.0.2 " __DATE__ @@ -345,9 +344,6 @@ static struct pci_driver amd76x_driver = { static int __init amd76x_init(void) { - /* Ensure that the OPSTATE is set correctly for POLL or NMI */ - opstate_init(); - return pci_register_driver(&amd76x_driver); } @@ -362,6 +358,3 @@ module_exit(amd76x_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Linux Networx (http://lnxi.com) Thayne Harbaugh"); MODULE_DESCRIPTION("MC support for AMD 76x memory controllers"); - -module_param(edac_op_state, int, 0444); -MODULE_PARM_DESC(edac_op_state, "EDAC Error Reporting state: 0=Poll,1=NMI"); diff --git a/trunk/drivers/edac/e752x_edac.c b/trunk/drivers/edac/e752x_edac.c index c94a0eb492cb..6eb434749cd5 100644 --- a/trunk/drivers/edac/e752x_edac.c +++ b/trunk/drivers/edac/e752x_edac.c @@ -29,7 +29,6 @@ #define EDAC_MOD_STR "e752x_edac" static int force_function_unhide; -static int sysbus_parity = -1; static struct edac_pci_ctl_info *e752x_pci; @@ -63,14 +62,6 @@ static struct edac_pci_ctl_info *e752x_pci; #define PCI_DEVICE_ID_INTEL_7320_1_ERR 0x3593 #endif /* PCI_DEVICE_ID_INTEL_7320_1_ERR */ -#ifndef PCI_DEVICE_ID_INTEL_3100_0 -#define PCI_DEVICE_ID_INTEL_3100_0 0x35B0 -#endif /* PCI_DEVICE_ID_INTEL_3100_0 */ - -#ifndef PCI_DEVICE_ID_INTEL_3100_1_ERR -#define PCI_DEVICE_ID_INTEL_3100_1_ERR 0x35B1 -#endif /* PCI_DEVICE_ID_INTEL_3100_1_ERR */ - #define E752X_NR_CSROWS 8 /* number of csrows */ /* E752X register addresses - device 0 function 0 */ @@ -161,12 +152,6 @@ static struct edac_pci_ctl_info *e752x_pci; /* error syndrome register (16b) */ #define E752X_DEVPRES1 0xF4 /* Device Present 1 register (8b) */ -/* 3100 IMCH specific register addresses - device 0 function 1 */ -#define I3100_NSI_FERR 0x48 /* NSI first error reg (32b) */ -#define I3100_NSI_NERR 0x4C /* NSI next error reg (32b) */ -#define I3100_NSI_SMICMD 0x54 /* NSI SMI command register (32b) */ -#define I3100_NSI_EMASK 0x90 /* NSI error mask register (32b) */ - /* ICH5R register addresses - device 30 function 0 */ #define ICH5R_PCI_STAT 0x06 /* PCI status register (16b) */ #define ICH5R_PCI_2ND_STAT 0x1E /* PCI status secondary reg (16b) */ @@ -175,8 +160,7 @@ static struct edac_pci_ctl_info *e752x_pci; enum e752x_chips { E7520 = 0, E7525 = 1, - E7320 = 2, - I3100 = 3 + E7320 = 2 }; struct e752x_pvt { @@ -201,10 +185,8 @@ struct e752x_dev_info { struct e752x_error_info { u32 ferr_global; u32 nerr_global; - u32 nsi_ferr; /* 3100 only */ - u32 nsi_nerr; /* 3100 only */ - u8 hi_ferr; /* all but 3100 */ - u8 hi_nerr; /* all but 3100 */ + u8 hi_ferr; + u8 hi_nerr; u16 sysbus_ferr; u16 sysbus_nerr; u8 buf_ferr; @@ -233,10 +215,6 @@ static const struct e752x_dev_info e752x_devs[] = { .err_dev = PCI_DEVICE_ID_INTEL_7320_1_ERR, .ctl_dev = PCI_DEVICE_ID_INTEL_7320_0, .ctl_name = "E7320"}, - [I3100] = { - .err_dev = PCI_DEVICE_ID_INTEL_3100_1_ERR, - .ctl_dev = PCI_DEVICE_ID_INTEL_3100_0, - .ctl_name = "3100"}, }; static unsigned long ctl_page_to_phys(struct mem_ctl_info *mci, @@ -424,7 +402,7 @@ static inline void process_threshold_ce(struct mem_ctl_info *mci, u16 error, static char *global_message[11] = { "PCI Express C1", "PCI Express C", "PCI Express B1", "PCI Express B", "PCI Express A1", "PCI Express A", - "DMA Controler", "HUB or NS Interface", "System Bus", + "DMA Controler", "HUB Interface", "System Bus", "DRAM Controler", "Internal Buffer" }; @@ -477,63 +455,6 @@ static inline void hub_error(int fatal, u8 errors, int *error_found, do_hub_error(fatal, errors); } -#define NSI_FATAL_MASK 0x0c080081 -#define NSI_NON_FATAL_MASK 0x23a0ba64 -#define NSI_ERR_MASK (NSI_FATAL_MASK | NSI_NON_FATAL_MASK) - -static char *nsi_message[30] = { - "NSI Link Down", /* NSI_FERR/NSI_NERR bit 0, fatal error */ - "", /* reserved */ - "NSI Parity Error", /* bit 2, non-fatal */ - "", /* reserved */ - "", /* reserved */ - "Correctable Error Message", /* bit 5, non-fatal */ - "Non-Fatal Error Message", /* bit 6, non-fatal */ - "Fatal Error Message", /* bit 7, fatal */ - "", /* reserved */ - "Receiver Error", /* bit 9, non-fatal */ - "", /* reserved */ - "Bad TLP", /* bit 11, non-fatal */ - "Bad DLLP", /* bit 12, non-fatal */ - "REPLAY_NUM Rollover", /* bit 13, non-fatal */ - "", /* reserved */ - "Replay Timer Timeout", /* bit 15, non-fatal */ - "", /* reserved */ - "", /* reserved */ - "", /* reserved */ - "Data Link Protocol Error", /* bit 19, fatal */ - "", /* reserved */ - "Poisoned TLP", /* bit 21, non-fatal */ - "", /* reserved */ - "Completion Timeout", /* bit 23, non-fatal */ - "Completer Abort", /* bit 24, non-fatal */ - "Unexpected Completion", /* bit 25, non-fatal */ - "Receiver Overflow", /* bit 26, fatal */ - "Malformed TLP", /* bit 27, fatal */ - "", /* reserved */ - "Unsupported Request" /* bit 29, non-fatal */ -}; - -static void do_nsi_error(int fatal, u32 errors) -{ - int i; - - for (i = 0; i < 30; i++) { - if (errors & (1 << i)) - printk(KERN_WARNING "%sError %s\n", - fatal_message[fatal], nsi_message[i]); - } -} - -static inline void nsi_error(int fatal, u32 errors, int *error_found, - int handle_error) -{ - *error_found = 1; - - if (handle_error) - do_nsi_error(fatal, errors); -} - static char *membuf_message[4] = { "Internal PMWB to DRAM parity", "Internal PMWB to System Bus Parity", @@ -625,31 +546,6 @@ static void e752x_check_hub_interface(struct e752x_error_info *info, } } -static void e752x_check_ns_interface(struct e752x_error_info *info, - int *error_found, int handle_error) -{ - u32 stat32; - - stat32 = info->nsi_ferr; - if (stat32 & NSI_ERR_MASK) { /* Error, so process */ - if (stat32 & NSI_FATAL_MASK) /* check for fatal errors */ - nsi_error(1, stat32 & NSI_FATAL_MASK, error_found, - handle_error); - if (stat32 & NSI_NON_FATAL_MASK) /* check for non-fatal ones */ - nsi_error(0, stat32 & NSI_NON_FATAL_MASK, error_found, - handle_error); - } - stat32 = info->nsi_nerr; - if (stat32 & NSI_ERR_MASK) { - if (stat32 & NSI_FATAL_MASK) - nsi_error(1, stat32 & NSI_FATAL_MASK, error_found, - handle_error); - if (stat32 & NSI_NON_FATAL_MASK) - nsi_error(0, stat32 & NSI_NON_FATAL_MASK, error_found, - handle_error); - } -} - static void e752x_check_sysbus(struct e752x_error_info *info, int *error_found, int handle_error) { @@ -757,15 +653,7 @@ static void e752x_get_error_info(struct mem_ctl_info *mci, pci_read_config_dword(dev, E752X_FERR_GLOBAL, &info->ferr_global); if (info->ferr_global) { - if (pvt->dev_info->err_dev == PCI_DEVICE_ID_INTEL_3100_1_ERR) { - pci_read_config_dword(dev, I3100_NSI_FERR, - &info->nsi_ferr); - info->hi_ferr = 0; - } else { - pci_read_config_byte(dev, E752X_HI_FERR, - &info->hi_ferr); - info->nsi_ferr = 0; - } + pci_read_config_byte(dev, E752X_HI_FERR, &info->hi_ferr); pci_read_config_word(dev, E752X_SYSBUS_FERR, &info->sysbus_ferr); pci_read_config_byte(dev, E752X_BUF_FERR, &info->buf_ferr); @@ -781,15 +669,10 @@ static void e752x_get_error_info(struct mem_ctl_info *mci, pci_read_config_dword(dev, E752X_DRAM_RETR_ADD, &info->dram_retr_add); - /* ignore the reserved bits just in case */ if (info->hi_ferr & 0x7f) pci_write_config_byte(dev, E752X_HI_FERR, info->hi_ferr); - if (info->nsi_ferr & NSI_ERR_MASK) - pci_write_config_dword(dev, I3100_NSI_FERR, - info->nsi_ferr); - if (info->sysbus_ferr) pci_write_config_word(dev, E752X_SYSBUS_FERR, info->sysbus_ferr); @@ -809,15 +692,7 @@ static void e752x_get_error_info(struct mem_ctl_info *mci, pci_read_config_dword(dev, E752X_NERR_GLOBAL, &info->nerr_global); if (info->nerr_global) { - if (pvt->dev_info->err_dev == PCI_DEVICE_ID_INTEL_3100_1_ERR) { - pci_read_config_dword(dev, I3100_NSI_NERR, - &info->nsi_nerr); - info->hi_nerr = 0; - } else { - pci_read_config_byte(dev, E752X_HI_NERR, - &info->hi_nerr); - info->nsi_nerr = 0; - } + pci_read_config_byte(dev, E752X_HI_NERR, &info->hi_nerr); pci_read_config_word(dev, E752X_SYSBUS_NERR, &info->sysbus_nerr); pci_read_config_byte(dev, E752X_BUF_NERR, &info->buf_nerr); @@ -831,10 +706,6 @@ static void e752x_get_error_info(struct mem_ctl_info *mci, pci_write_config_byte(dev, E752X_HI_NERR, info->hi_nerr); - if (info->nsi_nerr & NSI_ERR_MASK) - pci_write_config_dword(dev, I3100_NSI_NERR, - info->nsi_nerr); - if (info->sysbus_nerr) pci_write_config_word(dev, E752X_SYSBUS_NERR, info->sysbus_nerr); @@ -879,7 +750,6 @@ static int e752x_process_error_info(struct mem_ctl_info *mci, global_error(0, stat32, &error_found, handle_errors); e752x_check_hub_interface(info, &error_found, handle_errors); - e752x_check_ns_interface(info, &error_found, handle_errors); e752x_check_sysbus(info, &error_found, handle_errors); e752x_check_membuf(info, &error_found, handle_errors); e752x_check_dram(mci, info, &error_found, handle_errors); @@ -1050,53 +920,15 @@ static int e752x_get_devs(struct pci_dev *pdev, int dev_idx, return 1; } -/* Setup system bus parity mask register. - * Sysbus parity supported on: - * e7320/e7520/e7525 + Xeon - * i3100 + Xeon/Celeron - * Sysbus parity not supported on: - * i3100 + Pentium M/Celeron M/Core Duo/Core2 Duo - */ -static void e752x_init_sysbus_parity_mask(struct e752x_pvt *pvt) -{ - char *cpu_id = cpu_data(0).x86_model_id; - struct pci_dev *dev = pvt->dev_d0f1; - int enable = 1; - - /* Allow module paramter override, else see if CPU supports parity */ - if (sysbus_parity != -1) { - enable = sysbus_parity; - } else if (cpu_id[0] && - ((strstr(cpu_id, "Pentium") && strstr(cpu_id, " M ")) || - (strstr(cpu_id, "Celeron") && strstr(cpu_id, " M ")) || - (strstr(cpu_id, "Core") && strstr(cpu_id, "Duo")))) { - e752x_printk(KERN_INFO, "System Bus Parity not " - "supported by CPU, disabling\n"); - enable = 0; - } - - if (enable) - pci_write_config_word(dev, E752X_SYSBUS_ERRMASK, 0x0000); - else - pci_write_config_word(dev, E752X_SYSBUS_ERRMASK, 0x0309); -} - static void e752x_init_error_reporting_regs(struct e752x_pvt *pvt) { struct pci_dev *dev; dev = pvt->dev_d0f1; /* Turn off error disable & SMI in case the BIOS turned it on */ - if (pvt->dev_info->err_dev == PCI_DEVICE_ID_INTEL_3100_1_ERR) { - pci_write_config_dword(dev, I3100_NSI_EMASK, 0); - pci_write_config_dword(dev, I3100_NSI_SMICMD, 0); - } else { - pci_write_config_byte(dev, E752X_HI_ERRMASK, 0x00); - pci_write_config_byte(dev, E752X_HI_SMICMD, 0x00); - } - - e752x_init_sysbus_parity_mask(pvt); - + pci_write_config_byte(dev, E752X_HI_ERRMASK, 0x00); + pci_write_config_byte(dev, E752X_HI_SMICMD, 0x00); + pci_write_config_word(dev, E752X_SYSBUS_ERRMASK, 0x00); pci_write_config_word(dev, E752X_SYSBUS_SMICMD, 0x00); pci_write_config_byte(dev, E752X_BUF_ERRMASK, 0x00); pci_write_config_byte(dev, E752X_BUF_SMICMD, 0x00); @@ -1117,6 +949,16 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx) debugf0("%s(): mci\n", __func__); debugf0("Starting Probe1\n"); + /* make sure error reporting method is sane */ + switch (edac_op_state) { + case EDAC_OPSTATE_POLL: + case EDAC_OPSTATE_NMI: + break; + default: + edac_op_state = EDAC_OPSTATE_POLL; + break; + } + /* check to see if device 0 function 1 is enabled; if it isn't, we * assume the BIOS has reserved it for a reason and is expecting * exclusive access, we take care not to violate that assumption and @@ -1143,9 +985,8 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx) debugf3("%s(): init mci\n", __func__); mci->mtype_cap = MEM_FLAG_RDDR; - /* 3100 IMCH supports SECDEC only */ - mci->edac_ctl_cap = (dev_idx == I3100) ? EDAC_FLAG_SECDED : - (EDAC_FLAG_NONE | EDAC_FLAG_SECDED | EDAC_FLAG_S4ECD4ED); + mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED | + EDAC_FLAG_S4ECD4ED; /* FIXME - what if different memory types are in different csrows? */ mci->mod_name = EDAC_MOD_STR; mci->mod_ver = E752X_REVISION; @@ -1177,10 +1018,7 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx) e752x_init_csrows(mci, pdev, ddrcsr); e752x_init_mem_map_table(pdev, pvt); - if (dev_idx == I3100) - mci->edac_cap = EDAC_FLAG_SECDED; /* the only mode supported */ - else - mci->edac_cap |= EDAC_FLAG_NONE; + mci->edac_cap |= EDAC_FLAG_NONE; debugf3("%s(): tolm, remapbase, remaplimit\n", __func__); /* load the top of low memory, remap base, and remap limit vars */ @@ -1271,9 +1109,6 @@ static const struct pci_device_id e752x_pci_tbl[] __devinitdata = { { PCI_VEND_DEV(INTEL, 7320_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0, E7320}, - { - PCI_VEND_DEV(INTEL, 3100_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0, - I3100}, { 0, } /* 0 terminated list. */ @@ -1293,10 +1128,6 @@ static int __init e752x_init(void) int pci_rc; debugf3("%s()\n", __func__); - - /* Ensure that the OPSTATE is set correctly for POLL or NMI */ - opstate_init(); - pci_rc = pci_register_driver(&e752x_driver); return (pci_rc < 0) ? pci_rc : 0; } @@ -1312,15 +1143,10 @@ module_exit(e752x_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Linux Networx (http://lnxi.com) Tom Zimmerman\n"); -MODULE_DESCRIPTION("MC support for Intel e752x/3100 memory controllers"); +MODULE_DESCRIPTION("MC support for Intel e752x memory controllers"); module_param(force_function_unhide, int, 0444); MODULE_PARM_DESC(force_function_unhide, "if BIOS sets Dev0:Fun1 up as hidden:" " 1=force unhide and hope BIOS doesn't fight driver for Dev0:Fun1 access"); - module_param(edac_op_state, int, 0444); MODULE_PARM_DESC(edac_op_state, "EDAC Error Reporting state: 0=Poll,1=NMI"); - -module_param(sysbus_parity, int, 0444); -MODULE_PARM_DESC(sysbus_parity, "0=disable system bus parity checking," - " 1=enable system bus parity checking, default=auto-detect"); diff --git a/trunk/drivers/edac/e7xxx_edac.c b/trunk/drivers/edac/e7xxx_edac.c index c7d11cc4e21a..96ecc4926641 100644 --- a/trunk/drivers/edac/e7xxx_edac.c +++ b/trunk/drivers/edac/e7xxx_edac.c @@ -414,6 +414,16 @@ static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx) debugf0("%s(): mci\n", __func__); + /* make sure error reporting method is sane */ + switch (edac_op_state) { + case EDAC_OPSTATE_POLL: + case EDAC_OPSTATE_NMI: + break; + default: + edac_op_state = EDAC_OPSTATE_POLL; + break; + } + pci_read_config_dword(pdev, E7XXX_DRC, &drc); drc_chan = dual_channel_active(drc, dev_idx); @@ -555,9 +565,6 @@ static struct pci_driver e7xxx_driver = { static int __init e7xxx_init(void) { - /* Ensure that the OPSTATE is set correctly for POLL or NMI */ - opstate_init(); - return pci_register_driver(&e7xxx_driver); } diff --git a/trunk/drivers/edac/edac_device.c b/trunk/drivers/edac/edac_device.c index 63372fa7ecfe..b9552bc03dea 100644 --- a/trunk/drivers/edac/edac_device.c +++ b/trunk/drivers/edac/edac_device.c @@ -36,7 +36,7 @@ * is protected by the 'device_ctls_mutex' lock */ static DEFINE_MUTEX(device_ctls_mutex); -static LIST_HEAD(edac_device_list); +static struct list_head edac_device_list = LIST_HEAD_INIT(edac_device_list); #ifdef CONFIG_EDAC_DEBUG static void edac_device_dump_device(struct edac_device_ctl_info *edac_dev) @@ -375,6 +375,37 @@ static void del_edac_device_from_global_list(struct edac_device_ctl_info wait_for_completion(&edac_device->removal_complete); } +/** + * edac_device_find + * Search for a edac_device_ctl_info structure whose index is 'idx'. + * + * If found, return a pointer to the structure. + * Else return NULL. + * + * Caller must hold device_ctls_mutex. + */ +struct edac_device_ctl_info *edac_device_find(int idx) +{ + struct list_head *item; + struct edac_device_ctl_info *edac_dev; + + /* Iterate over list, looking for exact match of ID */ + list_for_each(item, &edac_device_list) { + edac_dev = list_entry(item, struct edac_device_ctl_info, link); + + if (edac_dev->dev_idx >= idx) { + if (edac_dev->dev_idx == idx) + return edac_dev; + + /* not on list, so terminate early */ + break; + } + } + + return NULL; +} +EXPORT_SYMBOL_GPL(edac_device_find); + /* * edac_device_workq_function * performs the operation scheduled by a workq request diff --git a/trunk/drivers/edac/edac_mc.c b/trunk/drivers/edac/edac_mc.c index a4cf1645f588..063a1bffe38b 100644 --- a/trunk/drivers/edac/edac_mc.c +++ b/trunk/drivers/edac/edac_mc.c @@ -36,7 +36,7 @@ /* lock to memory controller's control array */ static DEFINE_MUTEX(mem_ctls_mutex); -static LIST_HEAD(mc_devices); +static struct list_head mc_devices = LIST_HEAD_INIT(mc_devices); #ifdef CONFIG_EDAC_DEBUG @@ -886,3 +886,24 @@ void edac_mc_handle_fbd_ce(struct mem_ctl_info *mci, mci->csrows[csrow].channels[channel].ce_count++; } EXPORT_SYMBOL(edac_mc_handle_fbd_ce); + +/* + * Iterate over all MC instances and check for ECC, et al, errors + */ +void edac_check_mc_devices(void) +{ + struct list_head *item; + struct mem_ctl_info *mci; + + debugf3("%s()\n", __func__); + mutex_lock(&mem_ctls_mutex); + + list_for_each(item, &mc_devices) { + mci = list_entry(item, struct mem_ctl_info, link); + + if (mci->edac_check != NULL) + mci->edac_check(mci); + } + + mutex_unlock(&mem_ctls_mutex); +} diff --git a/trunk/drivers/edac/edac_module.h b/trunk/drivers/edac/edac_module.h index 233d4798c3aa..cbc419c8ebc1 100644 --- a/trunk/drivers/edac/edac_module.h +++ b/trunk/drivers/edac/edac_module.h @@ -27,6 +27,7 @@ extern int edac_mc_register_sysfs_main_kobj(struct mem_ctl_info *mci); extern void edac_mc_unregister_sysfs_main_kobj(struct mem_ctl_info *mci); extern int edac_create_sysfs_mci_device(struct mem_ctl_info *mci); extern void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci); +extern void edac_check_mc_devices(void); extern int edac_get_log_ue(void); extern int edac_get_log_ce(void); extern int edac_get_panic_on_ue(void); diff --git a/trunk/drivers/edac/edac_pci.c b/trunk/drivers/edac/edac_pci.c index 9b24340b52e1..32be43576a8e 100644 --- a/trunk/drivers/edac/edac_pci.c +++ b/trunk/drivers/edac/edac_pci.c @@ -29,7 +29,7 @@ #include "edac_module.h" static DEFINE_MUTEX(edac_pci_ctls_mutex); -static LIST_HEAD(edac_pci_list); +static struct list_head edac_pci_list = LIST_HEAD_INIT(edac_pci_list); /* * edac_pci_alloc_ctl_info @@ -189,9 +189,6 @@ static void del_edac_pci_from_global_list(struct edac_pci_ctl_info *pci) wait_for_completion(&pci->complete); } -#if 0 -/* Older code, but might use in the future */ - /* * edac_pci_find() * Search for an edac_pci_ctl_info structure whose index is 'idx' @@ -222,7 +219,6 @@ struct edac_pci_ctl_info *edac_pci_find(int idx) return NULL; } EXPORT_SYMBOL_GPL(edac_pci_find); -#endif /* * edac_pci_workq_function() @@ -426,7 +422,7 @@ EXPORT_SYMBOL_GPL(edac_pci_del_device); * * a Generic parity check API */ -static void edac_pci_generic_check(struct edac_pci_ctl_info *pci) +void edac_pci_generic_check(struct edac_pci_ctl_info *pci) { debugf4("%s()\n", __func__); edac_pci_do_parity_check(); diff --git a/trunk/drivers/edac/edac_pci_sysfs.c b/trunk/drivers/edac/edac_pci_sysfs.c index 2c1fa1bb6df2..71c3195d3704 100644 --- a/trunk/drivers/edac/edac_pci_sysfs.c +++ b/trunk/drivers/edac/edac_pci_sysfs.c @@ -37,17 +37,17 @@ int edac_pci_get_check_errors(void) return check_pci_errors; } -static int edac_pci_get_log_pe(void) +int edac_pci_get_log_pe(void) { return edac_pci_log_pe; } -static int edac_pci_get_log_npe(void) +int edac_pci_get_log_npe(void) { return edac_pci_log_npe; } -static int edac_pci_get_panic_on_pe(void) +int edac_pci_get_panic_on_pe(void) { return edac_pci_panic_on_pe; } @@ -197,8 +197,7 @@ static int edac_pci_create_instance_kobj(struct edac_pci_ctl_info *pci, int idx) * * unregister the kobj for the EDAC PCI instance */ -static void edac_pci_unregister_sysfs_instance_kobj( - struct edac_pci_ctl_info *pci) +void edac_pci_unregister_sysfs_instance_kobj(struct edac_pci_ctl_info *pci) { debugf0("%s()\n", __func__); @@ -338,7 +337,7 @@ static struct kobj_type ktype_edac_pci_main_kobj = { * setup the sysfs for EDAC PCI attributes * assumes edac_class has already been initialized */ -static int edac_pci_main_kobj_setup(void) +int edac_pci_main_kobj_setup(void) { int err; struct sysdev_class *edac_class; diff --git a/trunk/drivers/edac/i3000_edac.c b/trunk/drivers/edac/i3000_edac.c index 6c9a0f2a593c..5d4292811c14 100644 --- a/trunk/drivers/edac/i3000_edac.c +++ b/trunk/drivers/edac/i3000_edac.c @@ -326,6 +326,15 @@ static int i3000_probe1(struct pci_dev *pdev, int dev_idx) return -ENODEV; } + switch (edac_op_state) { + case EDAC_OPSTATE_POLL: + case EDAC_OPSTATE_NMI: + break; + default: + edac_op_state = EDAC_OPSTATE_POLL; + break; + } + c0dra[0] = readb(window + I3000_C0DRA + 0); /* ranks 0,1 */ c0dra[1] = readb(window + I3000_C0DRA + 1); /* ranks 2,3 */ c1dra[0] = readb(window + I3000_C1DRA + 0); /* ranks 0,1 */ @@ -494,10 +503,6 @@ static int __init i3000_init(void) int pci_rc; debugf3("MC: %s()\n", __func__); - - /* Ensure that the OPSTATE is set correctly for POLL or NMI */ - opstate_init(); - pci_rc = pci_register_driver(&i3000_driver); if (pci_rc < 0) goto fail0; diff --git a/trunk/drivers/edac/i5000_edac.c b/trunk/drivers/edac/i5000_edac.c index 4a16b5b61cfb..5a852017c17a 100644 --- a/trunk/drivers/edac/i5000_edac.c +++ b/trunk/drivers/edac/i5000_edac.c @@ -1286,6 +1286,16 @@ static int i5000_probe1(struct pci_dev *pdev, int dev_idx) if (PCI_FUNC(pdev->devfn) != 0) return -ENODEV; + /* make sure error reporting method is sane */ + switch (edac_op_state) { + case EDAC_OPSTATE_POLL: + case EDAC_OPSTATE_NMI: + break; + default: + edac_op_state = EDAC_OPSTATE_POLL; + break; + } + /* Ask the devices for the number of CSROWS and CHANNELS so * that we can calculate the memory resources, etc * @@ -1468,9 +1478,6 @@ static int __init i5000_init(void) debugf2("MC: " __FILE__ ": %s()\n", __func__); - /* Ensure that the OPSTATE is set correctly for POLL or NMI */ - opstate_init(); - pci_rc = pci_register_driver(&i5000_driver); return (pci_rc < 0) ? pci_rc : 0; @@ -1494,6 +1501,5 @@ MODULE_AUTHOR ("Linux Networx (http://lnxi.com) Doug Thompson "); MODULE_DESCRIPTION("MC Driver for Intel I5000 memory controllers - " I5000_REVISION); - module_param(edac_op_state, int, 0444); MODULE_PARM_DESC(edac_op_state, "EDAC Error Reporting state: 0=Poll,1=NMI"); diff --git a/trunk/drivers/edac/i82443bxgx_edac.c b/trunk/drivers/edac/i82443bxgx_edac.c index c5305e3ee434..83bfe37c4bbb 100644 --- a/trunk/drivers/edac/i82443bxgx_edac.c +++ b/trunk/drivers/edac/i82443bxgx_edac.c @@ -29,7 +29,6 @@ #include -#include #include "edac_core.h" #define I82443_REVISION "0.1" @@ -387,9 +386,6 @@ static struct pci_driver i82443bxgx_edacmc_driver = { static int __init i82443bxgx_edacmc_init(void) { - /* Ensure that the OPSTATE is set correctly for POLL or NMI */ - opstate_init(); - return pci_register_driver(&i82443bxgx_edacmc_driver); } @@ -404,6 +400,3 @@ module_exit(i82443bxgx_edacmc_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Tim Small - WPAD"); MODULE_DESCRIPTION("EDAC MC support for Intel 82443BX/GX memory controllers"); - -module_param(edac_op_state, int, 0444); -MODULE_PARM_DESC(edac_op_state, "EDAC Error Reporting state: 0=Poll,1=NMI"); diff --git a/trunk/drivers/edac/i82860_edac.c b/trunk/drivers/edac/i82860_edac.c index c0088ba9672b..f5ecd2c4d813 100644 --- a/trunk/drivers/edac/i82860_edac.c +++ b/trunk/drivers/edac/i82860_edac.c @@ -14,7 +14,6 @@ #include #include #include -#include #include "edac_core.h" #define I82860_REVISION " Ver: 2.0.2 " __DATE__ @@ -295,9 +294,6 @@ static int __init i82860_init(void) debugf3("%s()\n", __func__); - /* Ensure that the OPSTATE is set correctly for POLL or NMI */ - opstate_init(); - if ((pci_rc = pci_register_driver(&i82860_driver)) < 0) goto fail0; @@ -349,6 +345,3 @@ MODULE_LICENSE("GPL"); MODULE_AUTHOR("Red Hat Inc. (http://www.redhat.com) " "Ben Woodard "); MODULE_DESCRIPTION("ECC support for Intel 82860 memory hub controllers"); - -module_param(edac_op_state, int, 0444); -MODULE_PARM_DESC(edac_op_state, "EDAC Error Reporting state: 0=Poll,1=NMI"); diff --git a/trunk/drivers/edac/i82875p_edac.c b/trunk/drivers/edac/i82875p_edac.c index e43bdc43a1bf..031abadc439a 100644 --- a/trunk/drivers/edac/i82875p_edac.c +++ b/trunk/drivers/edac/i82875p_edac.c @@ -18,7 +18,6 @@ #include #include #include -#include #include "edac_core.h" #define I82875P_REVISION " Ver: 2.0.2 " __DATE__ @@ -394,7 +393,6 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx) struct i82875p_error_info discard; debugf0("%s()\n", __func__); - ovrfl_pdev = pci_get_device(PCI_VEND_DEV(INTEL, 82875_6), NULL); if (i82875p_setup_overfl_dev(pdev, &ovrfl_pdev, &ovrfl_window)) @@ -534,10 +532,6 @@ static int __init i82875p_init(void) int pci_rc; debugf3("%s()\n", __func__); - - /* Ensure that the OPSTATE is set correctly for POLL or NMI */ - opstate_init(); - pci_rc = pci_register_driver(&i82875p_driver); if (pci_rc < 0) @@ -592,6 +586,3 @@ module_exit(i82875p_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Linux Networx (http://lnxi.com) Thayne Harbaugh"); MODULE_DESCRIPTION("MC support for Intel 82875 memory hub controllers"); - -module_param(edac_op_state, int, 0444); -MODULE_PARM_DESC(edac_op_state, "EDAC Error Reporting state: 0=Poll,1=NMI"); diff --git a/trunk/drivers/edac/i82975x_edac.c b/trunk/drivers/edac/i82975x_edac.c index 2eed3ea2cf62..0ee888456932 100644 --- a/trunk/drivers/edac/i82975x_edac.c +++ b/trunk/drivers/edac/i82975x_edac.c @@ -14,7 +14,7 @@ #include #include #include -#include + #include "edac_core.h" #define I82975X_REVISION " Ver: 1.0.0 " __DATE__ @@ -611,9 +611,6 @@ static int __init i82975x_init(void) debugf3("%s()\n", __func__); - /* Ensure that the OPSTATE is set correctly for POLL or NMI */ - opstate_init(); - pci_rc = pci_register_driver(&i82975x_driver); if (pci_rc < 0) goto fail0; @@ -667,6 +664,3 @@ module_exit(i82975x_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Arvind R. "); MODULE_DESCRIPTION("MC support for Intel 82975 memory hub controllers"); - -module_param(edac_op_state, int, 0444); -MODULE_PARM_DESC(edac_op_state, "EDAC Error Reporting state: 0=Poll,1=NMI"); diff --git a/trunk/drivers/edac/pasemi_edac.c b/trunk/drivers/edac/pasemi_edac.c index 8e6b91bd2e99..90320917be28 100644 --- a/trunk/drivers/edac/pasemi_edac.c +++ b/trunk/drivers/edac/pasemi_edac.c @@ -26,7 +26,6 @@ #include #include #include -#include #include "edac_core.h" #define MODULE_NAME "pasemi_edac" @@ -285,9 +284,6 @@ static struct pci_driver pasemi_edac_driver = { static int __init pasemi_edac_init(void) { - /* Ensure that the OPSTATE is set correctly for POLL or NMI */ - opstate_init(); - return pci_register_driver(&pasemi_edac_driver); } @@ -302,6 +298,3 @@ module_exit(pasemi_edac_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Egor Martovetsky "); MODULE_DESCRIPTION("MC support for PA Semi PWRficient memory controller"); -module_param(edac_op_state, int, 0444); -MODULE_PARM_DESC(edac_op_state, "EDAC Error Reporting state: 0=Poll,1=NMI"); - diff --git a/trunk/drivers/edac/r82600_edac.c b/trunk/drivers/edac/r82600_edac.c index 9900675e9598..e25f712f2dc3 100644 --- a/trunk/drivers/edac/r82600_edac.c +++ b/trunk/drivers/edac/r82600_edac.c @@ -20,7 +20,6 @@ #include #include #include -#include #include "edac_core.h" #define R82600_REVISION " Ver: 2.0.2 " __DATE__ @@ -394,9 +393,6 @@ static struct pci_driver r82600_driver = { static int __init r82600_init(void) { - /* Ensure that the OPSTATE is set correctly for POLL or NMI */ - opstate_init(); - return pci_register_driver(&r82600_driver); } @@ -416,6 +412,3 @@ MODULE_DESCRIPTION("MC support for Radisys 82600 memory controllers"); module_param(disable_hardware_scrub, bool, 0644); MODULE_PARM_DESC(disable_hardware_scrub, "If set, disable the chipset's automatic scrub for CEs"); - -module_param(edac_op_state, int, 0444); -MODULE_PARM_DESC(edac_op_state, "EDAC Error Reporting state: 0=Poll,1=NMI"); diff --git a/trunk/drivers/firmware/Kconfig b/trunk/drivers/firmware/Kconfig index dc2cec6127d1..40ffd767647d 100644 --- a/trunk/drivers/firmware/Kconfig +++ b/trunk/drivers/firmware/Kconfig @@ -17,15 +17,6 @@ config EDD obscure configurations. Most disk controller BIOS vendors do not yet implement this feature. -config EDD_OFF - bool "Sets default behavior for EDD detection to off" - depends on EDD - default n - help - Say Y if you want EDD disabled by default, even though it is compiled into the - kernel. Say N if you want EDD enabled by default. EDD can be dynamically set - using the kernel parameter 'edd={on|skipmbr|off}'. - config EFI_VARS tristate "EFI Variable Support via sysfs" depends on EFI diff --git a/trunk/drivers/firmware/dcdbas.c b/trunk/drivers/firmware/dcdbas.c index 25918f7dfd0f..f235940719e7 100644 --- a/trunk/drivers/firmware/dcdbas.c +++ b/trunk/drivers/firmware/dcdbas.c @@ -63,7 +63,7 @@ static void smi_data_buf_free(void) return; dev_dbg(&dcdbas_pdev->dev, "%s: phys: %x size: %lu\n", - __func__, smi_data_buf_phys_addr, smi_data_buf_size); + __FUNCTION__, smi_data_buf_phys_addr, smi_data_buf_size); dma_free_coherent(&dcdbas_pdev->dev, smi_data_buf_size, smi_data_buf, smi_data_buf_handle); @@ -92,7 +92,7 @@ static int smi_data_buf_realloc(unsigned long size) if (!buf) { dev_dbg(&dcdbas_pdev->dev, "%s: failed to allocate memory size %lu\n", - __func__, size); + __FUNCTION__, size); return -ENOMEM; } /* memory zeroed by dma_alloc_coherent */ @@ -110,7 +110,7 @@ static int smi_data_buf_realloc(unsigned long size) smi_data_buf_size = size; dev_dbg(&dcdbas_pdev->dev, "%s: phys: %x size: %lu\n", - __func__, smi_data_buf_phys_addr, smi_data_buf_size); + __FUNCTION__, smi_data_buf_phys_addr, smi_data_buf_size); return 0; } @@ -258,7 +258,7 @@ static int smi_request(struct smi_cmd *smi_cmd) if (smi_cmd->magic != SMI_CMD_MAGIC) { dev_info(&dcdbas_pdev->dev, "%s: invalid magic value\n", - __func__); + __FUNCTION__); return -EBADR; } @@ -267,7 +267,7 @@ static int smi_request(struct smi_cmd *smi_cmd) set_cpus_allowed_ptr(current, &cpumask_of_cpu(0)); if (smp_processor_id() != 0) { dev_dbg(&dcdbas_pdev->dev, "%s: failed to get CPU 0\n", - __func__); + __FUNCTION__); ret = -EBUSY; goto out; } @@ -428,7 +428,7 @@ static int host_control_smi(void) default: dev_dbg(&dcdbas_pdev->dev, "%s: invalid SMI type %u\n", - __func__, host_control_smi_type); + __FUNCTION__, host_control_smi_type); return -ENOSYS; } @@ -456,13 +456,13 @@ static void dcdbas_host_control(void) host_control_action = HC_ACTION_NONE; if (!smi_data_buf) { - dev_dbg(&dcdbas_pdev->dev, "%s: no SMI buffer\n", __func__); + dev_dbg(&dcdbas_pdev->dev, "%s: no SMI buffer\n", __FUNCTION__); return; } if (smi_data_buf_size < sizeof(struct apm_cmd)) { dev_dbg(&dcdbas_pdev->dev, "%s: SMI buffer too small\n", - __func__); + __FUNCTION__); return; } diff --git a/trunk/drivers/firmware/dell_rbu.c b/trunk/drivers/firmware/dell_rbu.c index 6a8b1e037e07..477a3d0e3caf 100644 --- a/trunk/drivers/firmware/dell_rbu.c +++ b/trunk/drivers/firmware/dell_rbu.c @@ -123,7 +123,7 @@ static int create_packet(void *data, size_t length) if (!newpacket) { printk(KERN_WARNING "dell_rbu:%s: failed to allocate new " - "packet\n", __func__); + "packet\n", __FUNCTION__); retval = -ENOMEM; spin_lock(&rbu_data.lock); goto out_noalloc; @@ -152,7 +152,7 @@ static int create_packet(void *data, size_t length) printk(KERN_WARNING "dell_rbu:%s: failed to allocate " "invalid_addr_packet_array \n", - __func__); + __FUNCTION__); retval = -ENOMEM; spin_lock(&rbu_data.lock); goto out_alloc_packet; @@ -164,7 +164,7 @@ static int create_packet(void *data, size_t length) if (!packet_data_temp_buf) { printk(KERN_WARNING "dell_rbu:%s: failed to allocate new " - "packet\n", __func__); + "packet\n", __FUNCTION__); retval = -ENOMEM; spin_lock(&rbu_data.lock); goto out_alloc_packet_array; @@ -416,7 +416,7 @@ static int img_update_realloc(unsigned long size) */ if ((size != 0) && (rbu_data.image_update_buffer == NULL)) { printk(KERN_ERR "dell_rbu:%s: corruption " - "check failed\n", __func__); + "check failed\n", __FUNCTION__); return -EINVAL; } /* @@ -642,7 +642,7 @@ static ssize_t write_rbu_image_type(struct kobject *kobj, if (req_firm_rc) { printk(KERN_ERR "dell_rbu:%s request_firmware_nowait" - " failed %d\n", __func__, rc); + " failed %d\n", __FUNCTION__, rc); rc = -EIO; } else rbu_data.entry_created = 1; @@ -718,7 +718,7 @@ static int __init dcdrbu_init(void) if (IS_ERR(rbu_device)) { printk(KERN_ERR "dell_rbu:%s:platform_device_register_simple " - "failed\n", __func__); + "failed\n", __FUNCTION__); return PTR_ERR(rbu_device); } diff --git a/trunk/drivers/gpio/pca953x.c b/trunk/drivers/gpio/pca953x.c index 5a99e81d2784..e0e0af536108 100644 --- a/trunk/drivers/gpio/pca953x.c +++ b/trunk/drivers/gpio/pca953x.c @@ -23,7 +23,13 @@ #define PCA953X_INVERT 2 #define PCA953X_DIRECTION 3 -static const struct i2c_device_id pca953x_id[] = { +/* This is temporary - in 2.6.26 i2c_driver_data should replace it. */ +struct pca953x_desc { + char name[I2C_NAME_SIZE]; + unsigned long driver_data; +}; + +static const struct pca953x_desc pca953x_descs[] = { { "pca9534", 8, }, { "pca9535", 16, }, { "pca9536", 4, }, @@ -31,9 +37,7 @@ static const struct i2c_device_id pca953x_id[] = { { "pca9538", 8, }, { "pca9539", 16, }, /* REVISIT several pca955x parts should work here too */ - { } }; -MODULE_DEVICE_TABLE(i2c, pca953x_id); struct pca953x_chip { unsigned gpio_start; @@ -188,17 +192,26 @@ static void pca953x_setup_gpio(struct pca953x_chip *chip, int gpios) gc->owner = THIS_MODULE; } -static int __devinit pca953x_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int __devinit pca953x_probe(struct i2c_client *client) { struct pca953x_platform_data *pdata; struct pca953x_chip *chip; int ret, i; + const struct pca953x_desc *id = NULL; pdata = client->dev.platform_data; if (pdata == NULL) return -ENODEV; + /* this loop vanishes when we get i2c_device_id */ + for (i = 0; i < ARRAY_SIZE(pca953x_descs); i++) + if (!strcmp(pca953x_descs[i].name, client->name)) { + id = pca953x_descs + i; + break; + } + if (!id) + return -ENODEV; + chip = kzalloc(sizeof(struct pca953x_chip), GFP_KERNEL); if (chip == NULL) return -ENOMEM; @@ -278,7 +291,6 @@ static struct i2c_driver pca953x_driver = { }, .probe = pca953x_probe, .remove = pca953x_remove, - .id_table = pca953x_id, }; static int __init pca953x_init(void) diff --git a/trunk/drivers/gpio/pcf857x.c b/trunk/drivers/gpio/pcf857x.c index aa6cc8b2a2bc..1106aa15ac79 100644 --- a/trunk/drivers/gpio/pcf857x.c +++ b/trunk/drivers/gpio/pcf857x.c @@ -26,21 +26,6 @@ #include -static const struct i2c_device_id pcf857x_id[] = { - { "pcf8574", 8 }, - { "pca8574", 8 }, - { "pca9670", 8 }, - { "pca9672", 8 }, - { "pca9674", 8 }, - { "pcf8575", 16 }, - { "pca8575", 16 }, - { "pca9671", 16 }, - { "pca9673", 16 }, - { "pca9675", 16 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, pcf857x_id); - /* * The pcf857x, pca857x, and pca967x chips only expose one read and one * write register. Writing a "one" bit (to match the reset state) lets @@ -157,8 +142,7 @@ static void pcf857x_set16(struct gpio_chip *chip, unsigned offset, int value) /*-------------------------------------------------------------------------*/ -static int pcf857x_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int pcf857x_probe(struct i2c_client *client) { struct pcf857x_platform_data *pdata; struct pcf857x *gpio; @@ -188,8 +172,13 @@ static int pcf857x_probe(struct i2c_client *client, * * NOTE: we don't distinguish here between *4 and *4a parts. */ - gpio->chip.ngpio = id->driver_data; - if (gpio->chip.ngpio == 8) { + if (strcmp(client->name, "pcf8574") == 0 + || strcmp(client->name, "pca8574") == 0 + || strcmp(client->name, "pca9670") == 0 + || strcmp(client->name, "pca9672") == 0 + || strcmp(client->name, "pca9674") == 0 + ) { + gpio->chip.ngpio = 8; gpio->chip.direction_input = pcf857x_input8; gpio->chip.get = pcf857x_get8; gpio->chip.direction_output = pcf857x_output8; @@ -209,7 +198,13 @@ static int pcf857x_probe(struct i2c_client *client, * * NOTE: we don't distinguish here between '75 and '75c parts. */ - } else if (gpio->chip.ngpio == 16) { + } else if (strcmp(client->name, "pcf8575") == 0 + || strcmp(client->name, "pca8575") == 0 + || strcmp(client->name, "pca9671") == 0 + || strcmp(client->name, "pca9673") == 0 + || strcmp(client->name, "pca9675") == 0 + ) { + gpio->chip.ngpio = 16; gpio->chip.direction_input = pcf857x_input16; gpio->chip.get = pcf857x_get16; gpio->chip.direction_output = pcf857x_output16; @@ -318,7 +313,6 @@ static struct i2c_driver pcf857x_driver = { }, .probe = pcf857x_probe, .remove = pcf857x_remove, - .id_table = pcf857x_id, }; static int __init pcf857x_init(void) diff --git a/trunk/drivers/hid/hid-core.c b/trunk/drivers/hid/hid-core.c index f43d6d3cf2fa..e03c67dd3e63 100644 --- a/trunk/drivers/hid/hid-core.c +++ b/trunk/drivers/hid/hid-core.c @@ -606,7 +606,7 @@ static u8 *fetch_item(__u8 *start, __u8 *end, struct hid_item *item) case 2: if ((end - start) < 2) return NULL; - item->data.u16 = get_unaligned_le16(start); + item->data.u16 = le16_to_cpu(get_unaligned((__le16*)start)); start = (__u8 *)((__le16 *)start + 1); return start; @@ -614,7 +614,7 @@ static u8 *fetch_item(__u8 *start, __u8 *end, struct hid_item *item) item->size++; if ((end - start) < 4) return NULL; - item->data.u32 = get_unaligned_le32(start); + item->data.u32 = le32_to_cpu(get_unaligned((__le32*)start)); start = (__u8 *)((__le32 *)start + 1); return start; } @@ -765,7 +765,7 @@ static __inline__ __u32 extract(__u8 *report, unsigned offset, unsigned n) report += offset >> 3; /* adjust byte index */ offset &= 7; /* now only need bit offset into one byte */ - x = get_unaligned_le64(report); + x = le64_to_cpu(get_unaligned((__le64 *) report)); x = (x >> offset) & ((1ULL << n) - 1); /* extract bit field */ return (u32) x; } diff --git a/trunk/drivers/hwmon/f75375s.c b/trunk/drivers/hwmon/f75375s.c index dc1f30e432ea..1464338e4e11 100644 --- a/trunk/drivers/hwmon/f75375s.c +++ b/trunk/drivers/hwmon/f75375s.c @@ -117,8 +117,7 @@ struct f75375_data { static int f75375_attach_adapter(struct i2c_adapter *adapter); static int f75375_detect(struct i2c_adapter *adapter, int address, int kind); static int f75375_detach_client(struct i2c_client *client); -static int f75375_probe(struct i2c_client *client, - const struct i2c_device_id *id); +static int f75375_probe(struct i2c_client *client); static int f75375_remove(struct i2c_client *client); static struct i2c_driver f75375_legacy_driver = { @@ -129,20 +128,12 @@ static struct i2c_driver f75375_legacy_driver = { .detach_client = f75375_detach_client, }; -static const struct i2c_device_id f75375_id[] = { - { "f75373", f75373 }, - { "f75375", f75375 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, f75375_id); - static struct i2c_driver f75375_driver = { .driver = { .name = "f75375", }, .probe = f75375_probe, .remove = f75375_remove, - .id_table = f75375_id, }; static inline int f75375_read8(struct i2c_client *client, u8 reg) @@ -637,8 +628,7 @@ static void f75375_init(struct i2c_client *client, struct f75375_data *data, } -static int f75375_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int f75375_probe(struct i2c_client *client) { struct f75375_data *data = i2c_get_clientdata(client); struct f75375s_platform_data *f75375s_pdata = client->dev.platform_data; @@ -653,7 +643,15 @@ static int f75375_probe(struct i2c_client *client, i2c_set_clientdata(client, data); data->client = client; mutex_init(&data->update_lock); - data->kind = id->driver_data; + + if (strcmp(client->name, "f75375") == 0) + data->kind = f75375; + else if (strcmp(client->name, "f75373") == 0) + data->kind = f75373; + else { + dev_err(&client->dev, "Unsupported device: %s\n", client->name); + return -ENODEV; + } if ((err = sysfs_create_group(&client->dev.kobj, &f75375_group))) goto exit_free; @@ -714,7 +712,6 @@ static int f75375_detect(struct i2c_adapter *adapter, int address, int kind) u8 version = 0; int err = 0; const char *name = ""; - struct i2c_device_id id; if (!(client = kzalloc(sizeof(*client), GFP_KERNEL))) { err = -ENOMEM; @@ -751,9 +748,7 @@ static int f75375_detect(struct i2c_adapter *adapter, int address, int kind) if ((err = i2c_attach_client(client))) goto exit_free; - strlcpy(id.name, name, I2C_NAME_SIZE); - id.driver_data = kind; - if ((err = f75375_probe(client, &id)) < 0) + if ((err = f75375_probe(client)) < 0) goto exit_detach; return 0; diff --git a/trunk/drivers/i2c/busses/i2c-amd756-s4882.c b/trunk/drivers/i2c/busses/i2c-amd756-s4882.c index c38a0a112208..e5e96c817566 100644 --- a/trunk/drivers/i2c/busses/i2c-amd756-s4882.c +++ b/trunk/drivers/i2c/busses/i2c-amd756-s4882.c @@ -1,7 +1,7 @@ /* * i2c-amd756-s4882.c - i2c-amd756 extras for the Tyan S4882 motherboard * - * Copyright (C) 2004, 2008 Jean Delvare + * Copyright (C) 2004 Jean Delvare * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -231,8 +231,7 @@ static int __init amd756_s4882_init(void) kfree(s4882_adapter); s4882_adapter = NULL; ERROR1: - /* Restore physical bus */ - i2c_add_adapter(&amd756_smbus); + i2c_del_adapter(&amd756_smbus); ERROR0: return error; } diff --git a/trunk/drivers/i2c/busses/i2c-piix4.c b/trunk/drivers/i2c/busses/i2c-piix4.c index fdc9ad805e35..9bbe96cef719 100644 --- a/trunk/drivers/i2c/busses/i2c-piix4.c +++ b/trunk/drivers/i2c/busses/i2c-piix4.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -222,7 +223,7 @@ static int piix4_transaction(void) dev_err(&piix4_adapter.dev, "Failed! (%02x)\n", temp); return -1; } else { - dev_dbg(&piix4_adapter.dev, "Successful!\n"); + dev_dbg(&piix4_adapter.dev, "Successfull!\n"); } } @@ -342,7 +343,12 @@ static s32 piix4_access(struct i2c_adapter * adap, u16 addr, switch (size) { - case PIIX4_BYTE: + case PIIX4_BYTE: /* Where is the result put? I assume here it is in + SMBHSTDAT0 but it might just as well be in the + SMBHSTCMD. No clue in the docs */ + + data->byte = inb_p(SMBHSTDAT0); + break; case PIIX4_BYTE_DATA: data->byte = inb_p(SMBHSTDAT0); break; diff --git a/trunk/drivers/i2c/busses/i2c-sis5595.c b/trunk/drivers/i2c/busses/i2c-sis5595.c index 9ca8f9155f95..283769cecee2 100644 --- a/trunk/drivers/i2c/busses/i2c-sis5595.c +++ b/trunk/drivers/i2c/busses/i2c-sis5595.c @@ -238,7 +238,7 @@ static int sis5595_transaction(struct i2c_adapter *adap) dev_dbg(&adap->dev, "Failed! (%02x)\n", temp); return -1; } else { - dev_dbg(&adap->dev, "Successful!\n"); + dev_dbg(&adap->dev, "Successfull!\n"); } } @@ -316,8 +316,14 @@ static s32 sis5595_access(struct i2c_adapter *adap, u16 addr, } size = (size == I2C_SMBUS_PROC_CALL) ? SIS5595_PROC_CALL : SIS5595_WORD_DATA; break; +/* + case I2C_SMBUS_BLOCK_DATA: + printk(KERN_WARNING "sis5595.o: Block data not yet implemented!\n"); + return -1; + break; +*/ default: - dev_warn(&adap->dev, "Unsupported transaction %d\n", size); + printk(KERN_WARNING "sis5595.o: Unsupported transaction %d\n", size); return -1; } @@ -332,7 +338,9 @@ static s32 sis5595_access(struct i2c_adapter *adap, u16 addr, switch (size) { - case SIS5595_BYTE: + case SIS5595_BYTE: /* Where is the result put? I assume here it is in + SMB_DATA but it might just as well be in the + SMB_CMD. No clue in the docs */ case SIS5595_BYTE_DATA: data->byte = sis5595_read(SMB_BYTE); break; diff --git a/trunk/drivers/i2c/busses/i2c-sis630.c b/trunk/drivers/i2c/busses/i2c-sis630.c index 3765dd7f450f..5fd734f99ee9 100644 --- a/trunk/drivers/i2c/busses/i2c-sis630.c +++ b/trunk/drivers/i2c/busses/i2c-sis630.c @@ -136,7 +136,7 @@ static int sis630_transaction_start(struct i2c_adapter *adap, int size, u8 *oldc dev_dbg(&adap->dev, "Failed! (%02x)\n", temp); return -1; } else { - dev_dbg(&adap->dev, "Successful!\n"); + dev_dbg(&adap->dev, "Successfull!\n"); } } diff --git a/trunk/drivers/i2c/busses/i2c-stub.c b/trunk/drivers/i2c/busses/i2c-stub.c index d08eeec53913..c2a9f8c94f5e 100644 --- a/trunk/drivers/i2c/busses/i2c-stub.c +++ b/trunk/drivers/i2c/busses/i2c-stub.c @@ -33,7 +33,7 @@ static unsigned short chip_addr[MAX_CHIPS]; module_param_array(chip_addr, ushort, NULL, S_IRUGO); MODULE_PARM_DESC(chip_addr, - "Chip addresses (up to 10, between 0x03 and 0x77)"); + "Chip addresses (up to 10, between 0x03 and 0x77)\n"); struct stub_chip { u8 pointer; diff --git a/trunk/drivers/i2c/busses/i2c-taos-evm.c b/trunk/drivers/i2c/busses/i2c-taos-evm.c index de9db49e54d9..1b0cfd5472fd 100644 --- a/trunk/drivers/i2c/busses/i2c-taos-evm.c +++ b/trunk/drivers/i2c/busses/i2c-taos-evm.c @@ -51,6 +51,7 @@ struct taos_data { /* TAOS TSL2550 EVM */ static struct i2c_board_info tsl2550_info = { I2C_BOARD_INFO("tsl2550", 0x39), + .type = "tsl2550", }; /* Instantiate i2c devices based on the adapter name */ @@ -58,7 +59,7 @@ static struct i2c_client *taos_instantiate_device(struct i2c_adapter *adapter) { if (!strncmp(adapter->name, "TAOS TSL2550 EVM", 16)) { dev_info(&adapter->dev, "Instantiating device %s at 0x%02x\n", - tsl2550_info.type, tsl2550_info.addr); + tsl2550_info.driver_name, tsl2550_info.addr); return i2c_new_device(adapter, &tsl2550_info); } diff --git a/trunk/drivers/i2c/chips/ds1682.c b/trunk/drivers/i2c/chips/ds1682.c index 23be4d42cb02..9e94542c18a2 100644 --- a/trunk/drivers/i2c/chips/ds1682.c +++ b/trunk/drivers/i2c/chips/ds1682.c @@ -200,8 +200,7 @@ static struct bin_attribute ds1682_eeprom_attr = { /* * Called when a ds1682 device is matched with this driver */ -static int ds1682_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int ds1682_probe(struct i2c_client *client) { int rc; @@ -235,19 +234,12 @@ static int ds1682_remove(struct i2c_client *client) return 0; } -static const struct i2c_device_id ds1682_id[] = { - { "ds1682", 0 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, ds1682_id); - static struct i2c_driver ds1682_driver = { .driver = { .name = "ds1682", }, .probe = ds1682_probe, .remove = ds1682_remove, - .id_table = ds1682_id, }; static int __init ds1682_init(void) diff --git a/trunk/drivers/i2c/chips/menelaus.c b/trunk/drivers/i2c/chips/menelaus.c index b36db1797c11..2dea0123a958 100644 --- a/trunk/drivers/i2c/chips/menelaus.c +++ b/trunk/drivers/i2c/chips/menelaus.c @@ -1149,8 +1149,7 @@ static inline void menelaus_rtc_init(struct menelaus_chip *m) static struct i2c_driver menelaus_i2c_driver; -static int menelaus_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int menelaus_probe(struct i2c_client *client) { struct menelaus_chip *menelaus; int rev = 0, val; @@ -1243,19 +1242,12 @@ static int __exit menelaus_remove(struct i2c_client *client) return 0; } -static const struct i2c_device_id menelaus_id[] = { - { "menelaus", 0 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, menelaus_id); - static struct i2c_driver menelaus_i2c_driver = { .driver = { .name = DRIVER_NAME, }, .probe = menelaus_probe, .remove = __exit_p(menelaus_remove), - .id_table = menelaus_id, }; static int __init menelaus_init(void) diff --git a/trunk/drivers/i2c/chips/tps65010.c b/trunk/drivers/i2c/chips/tps65010.c index 85949685191b..b67f69c2e7f3 100644 --- a/trunk/drivers/i2c/chips/tps65010.c +++ b/trunk/drivers/i2c/chips/tps65010.c @@ -64,6 +64,7 @@ static struct i2c_driver tps65010_driver; * as part of board setup by a bootloader. */ enum tps_model { + TPS_UNKNOWN = 0, TPS65010, TPS65011, TPS65012, @@ -526,13 +527,11 @@ static int __exit tps65010_remove(struct i2c_client *client) flush_scheduled_work(); debugfs_remove(tps->file); kfree(tps); - i2c_set_clientdata(client, NULL); the_tps = NULL; return 0; } -static int tps65010_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int tps65010_probe(struct i2c_client *client) { struct tps65010 *tps; int status; @@ -553,7 +552,20 @@ static int tps65010_probe(struct i2c_client *client, mutex_init(&tps->lock); INIT_DELAYED_WORK(&tps->work, tps65010_work); tps->client = client; - tps->model = id->driver_data; + + if (strcmp(client->name, "tps65010") == 0) + tps->model = TPS65010; + else if (strcmp(client->name, "tps65011") == 0) + tps->model = TPS65011; + else if (strcmp(client->name, "tps65012") == 0) + tps->model = TPS65012; + else if (strcmp(client->name, "tps65013") == 0) + tps->model = TPS65013; + else { + dev_warn(&client->dev, "unknown chip '%s'\n", client->name); + status = -ENODEV; + goto fail1; + } /* the IRQ is active low, but many gpio lines can't support that * so this driver uses falling-edge triggers instead. @@ -582,6 +594,9 @@ static int tps65010_probe(struct i2c_client *client, case TPS65012: tps->por = 1; break; + case TPS_UNKNOWN: + printk(KERN_WARNING "%s: unknown TPS chip\n", DRIVER_NAME); + break; /* else CHGCONFIG.POR is replaced by AUA, enabling a WAIT mode */ } tps->chgconf = i2c_smbus_read_byte_data(client, TPS_CHGCONFIG); @@ -600,7 +615,6 @@ static int tps65010_probe(struct i2c_client *client, i2c_smbus_read_byte_data(client, TPS_DEFGPIO), i2c_smbus_read_byte_data(client, TPS_MASK3)); - i2c_set_clientdata(client, tps); the_tps = tps; #if defined(CONFIG_USB_GADGET) && !defined(CONFIG_USB_OTG) @@ -668,22 +682,12 @@ static int tps65010_probe(struct i2c_client *client, return status; } -static const struct i2c_device_id tps65010_id[] = { - { "tps65010", TPS65010 }, - { "tps65011", TPS65011 }, - { "tps65012", TPS65012 }, - { "tps65013", TPS65013 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, tps65010_id); - static struct i2c_driver tps65010_driver = { .driver = { .name = "tps65010", }, .probe = tps65010_probe, .remove = __exit_p(tps65010_remove), - .id_table = tps65010_id, }; /*-------------------------------------------------------------------------*/ diff --git a/trunk/drivers/i2c/chips/tsl2550.c b/trunk/drivers/i2c/chips/tsl2550.c index 1a9cc135219f..a10fd2791a69 100644 --- a/trunk/drivers/i2c/chips/tsl2550.c +++ b/trunk/drivers/i2c/chips/tsl2550.c @@ -364,8 +364,7 @@ static int tsl2550_init_client(struct i2c_client *client) */ static struct i2c_driver tsl2550_driver; -static int __devinit tsl2550_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int __devinit tsl2550_probe(struct i2c_client *client) { struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); struct tsl2550_data *data; @@ -452,12 +451,6 @@ static int tsl2550_resume(struct i2c_client *client) #endif /* CONFIG_PM */ -static const struct i2c_device_id tsl2550_id[] = { - { "tsl2550", 0 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, tsl2550_id); - static struct i2c_driver tsl2550_driver = { .driver = { .name = TSL2550_DRV_NAME, @@ -467,7 +460,6 @@ static struct i2c_driver tsl2550_driver = { .resume = tsl2550_resume, .probe = tsl2550_probe, .remove = __devexit_p(tsl2550_remove), - .id_table = tsl2550_id, }; static int __init tsl2550_init(void) diff --git a/trunk/drivers/i2c/i2c-core.c b/trunk/drivers/i2c/i2c-core.c index 26384daccb96..6c7fa8d53c0e 100644 --- a/trunk/drivers/i2c/i2c-core.c +++ b/trunk/drivers/i2c/i2c-core.c @@ -48,17 +48,6 @@ static DEFINE_IDR(i2c_adapter_idr); /* ------------------------------------------------------------------------- */ -static const struct i2c_device_id *i2c_match_id(const struct i2c_device_id *id, - const struct i2c_client *client) -{ - while (id->name[0]) { - if (strcmp(client->name, id->name) == 0) - return id; - id++; - } - return NULL; -} - static int i2c_device_match(struct device *dev, struct device_driver *drv) { struct i2c_client *client = to_i2c_client(dev); @@ -70,10 +59,6 @@ static int i2c_device_match(struct device *dev, struct device_driver *drv) if (!is_newstyle_driver(driver)) return 0; - /* match on an id table if there is one */ - if (driver->id_table) - return i2c_match_id(driver->id_table, client) != NULL; - /* new style drivers use the same kind of driver matching policy * as platform devices or SPI: compare device and driver IDs. */ @@ -88,17 +73,11 @@ static int i2c_device_uevent(struct device *dev, struct kobj_uevent_env *env) struct i2c_client *client = to_i2c_client(dev); /* by definition, legacy drivers can't hotplug */ - if (dev->driver) + if (dev->driver || !client->driver_name) return 0; - if (client->driver_name[0]) { - if (add_uevent_var(env, "MODALIAS=%s", client->driver_name)) - return -ENOMEM; - } else { - if (add_uevent_var(env, "MODALIAS=%s%s", - I2C_MODULE_PREFIX, client->name)) - return -ENOMEM; - } + if (add_uevent_var(env, "MODALIAS=%s", client->driver_name)) + return -ENOMEM; dev_dbg(dev, "uevent\n"); return 0; } @@ -111,19 +90,13 @@ static int i2c_device_probe(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); struct i2c_driver *driver = to_i2c_driver(dev->driver); - const struct i2c_device_id *id; int status; if (!driver->probe) return -ENODEV; client->driver = driver; dev_dbg(dev, "probe\n"); - - if (driver->id_table) - id = i2c_match_id(driver->id_table, client); - else - id = NULL; - status = driver->probe(client, id); + status = driver->probe(client); if (status) client->driver = NULL; return status; @@ -206,9 +179,9 @@ static ssize_t show_client_name(struct device *dev, struct device_attribute *att static ssize_t show_modalias(struct device *dev, struct device_attribute *attr, char *buf) { struct i2c_client *client = to_i2c_client(dev); - return client->driver_name[0] + return client->driver_name ? sprintf(buf, "%s\n", client->driver_name) - : sprintf(buf, "%s%s\n", I2C_MODULE_PREFIX, client->name); + : 0; } static struct device_attribute i2c_dev_attrs[] = { @@ -327,21 +300,15 @@ void i2c_unregister_device(struct i2c_client *client) EXPORT_SYMBOL_GPL(i2c_unregister_device); -static int dummy_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - return 0; -} - -static int dummy_remove(struct i2c_client *client) +static int dummy_nop(struct i2c_client *client) { return 0; } static struct i2c_driver dummy_driver = { .driver.name = "dummy", - .probe = dummy_probe, - .remove = dummy_remove, + .probe = dummy_nop, + .remove = dummy_nop, }; /** diff --git a/trunk/drivers/ide/ide-cd.c b/trunk/drivers/ide/ide-cd.c index 68e7f19dc036..fe9df38f62cc 100644 --- a/trunk/drivers/ide/ide-cd.c +++ b/trunk/drivers/ide/ide-cd.c @@ -782,7 +782,7 @@ static ide_startstop_t cdrom_start_seek_continuation(ide_drive_t *drive) sector_div(frame, queue_hardsect_size(drive->queue) >> SECTOR_BITS); - memset(rq->cmd, 0, BLK_MAX_CDB); + memset(rq->cmd, 0, sizeof(rq->cmd)); rq->cmd[0] = GPCMD_SEEK; put_unaligned(cpu_to_be32(frame), (unsigned int *) &rq->cmd[2]); @@ -1694,7 +1694,7 @@ static int ide_cdrom_prep_fs(struct request_queue *q, struct request *rq) long block = (long)rq->hard_sector / (hard_sect >> 9); unsigned long blocks = rq->hard_nr_sectors / (hard_sect >> 9); - memset(rq->cmd, 0, BLK_MAX_CDB); + memset(rq->cmd, 0, sizeof(rq->cmd)); if (rq_data_dir(rq) == READ) rq->cmd[0] = GPCMD_READ_10; diff --git a/trunk/drivers/ide/ide-cd_verbose.c b/trunk/drivers/ide/ide-cd_verbose.c index 6490a2dea96b..6ed7ca071331 100644 --- a/trunk/drivers/ide/ide-cd_verbose.c +++ b/trunk/drivers/ide/ide-cd_verbose.c @@ -326,7 +326,7 @@ void ide_cd_log_error(const char *name, struct request *failed_command, printk(KERN_ERR " The failed \"%s\" packet command " "was: \n \"", s); - for (i = 0; i < BLK_MAX_CDB; i++) + for (i = 0; i < sizeof(failed_command->cmd); i++) printk(KERN_CONT "%02x ", failed_command->cmd[i]); printk(KERN_CONT "\"\n"); } diff --git a/trunk/drivers/ide/ide-io.c b/trunk/drivers/ide/ide-io.c index 696525342e9a..788783da9025 100644 --- a/trunk/drivers/ide/ide-io.c +++ b/trunk/drivers/ide/ide-io.c @@ -1550,7 +1550,8 @@ irqreturn_t ide_intr (int irq, void *dev_id) void ide_init_drive_cmd (struct request *rq) { - blk_rq_init(NULL, rq); + memset(rq, 0, sizeof(*rq)); + rq->ref_count = 1; } EXPORT_SYMBOL(ide_init_drive_cmd); diff --git a/trunk/drivers/ide/ide-proc.c b/trunk/drivers/ide/ide-proc.c index 8d6ad812a014..7b2f3815a838 100644 --- a/trunk/drivers/ide/ide-proc.c +++ b/trunk/drivers/ide/ide-proc.c @@ -822,7 +822,6 @@ static int ide_drivers_open(struct inode *inode, struct file *file) } static const struct file_operations ide_drivers_operations = { - .owner = THIS_MODULE, .open = ide_drivers_open, .read = seq_read, .llseek = seq_lseek, @@ -831,12 +830,16 @@ static const struct file_operations ide_drivers_operations = { void proc_ide_create(void) { + struct proc_dir_entry *entry; + proc_ide_root = proc_mkdir("ide", NULL); if (!proc_ide_root) return; - proc_create("drivers", 0, proc_ide_root, &ide_drivers_operations); + entry = create_proc_entry("drivers", 0, proc_ide_root); + if (entry) + entry->proc_fops = &ide_drivers_operations; } void proc_ide_destroy(void) diff --git a/trunk/drivers/ide/ide-tape.c b/trunk/drivers/ide/ide-tape.c index 1e1f26331a24..54a43b044608 100644 --- a/trunk/drivers/ide/ide-tape.c +++ b/trunk/drivers/ide/ide-tape.c @@ -662,7 +662,7 @@ static void idetape_create_request_sense_cmd(struct ide_atapi_pc *pc) static void idetape_init_rq(struct request *rq, u8 cmd) { - blk_rq_init(NULL, rq); + memset(rq, 0, sizeof(*rq)); rq->cmd_type = REQ_TYPE_SPECIAL; rq->cmd[0] = cmd; } diff --git a/trunk/drivers/ide/ide-taskfile.c b/trunk/drivers/ide/ide-taskfile.c index 0c908ca3ff79..9a846a0cd5a4 100644 --- a/trunk/drivers/ide/ide-taskfile.c +++ b/trunk/drivers/ide/ide-taskfile.c @@ -494,7 +494,8 @@ int ide_raw_taskfile(ide_drive_t *drive, ide_task_t *task, u8 *buf, u16 nsect) { struct request rq; - blk_rq_init(NULL, &rq); + memset(&rq, 0, sizeof(rq)); + rq.ref_count = 1; rq.cmd_type = REQ_TYPE_ATA_TASKFILE; rq.buffer = buf; diff --git a/trunk/drivers/ide/ide.c b/trunk/drivers/ide/ide.c index c758dcb13b14..999584c03d97 100644 --- a/trunk/drivers/ide/ide.c +++ b/trunk/drivers/ide/ide.c @@ -564,7 +564,7 @@ static int generic_ide_suspend(struct device *dev, pm_message_t mesg) if (!(drive->dn % 2)) ide_acpi_get_timing(hwif); - blk_rq_init(NULL, &rq); + memset(&rq, 0, sizeof(rq)); memset(&rqpm, 0, sizeof(rqpm)); memset(&args, 0, sizeof(args)); rq.cmd_type = REQ_TYPE_PM_SUSPEND; @@ -602,7 +602,7 @@ static int generic_ide_resume(struct device *dev) ide_acpi_exec_tfs(drive); - blk_rq_init(NULL, &rq); + memset(&rq, 0, sizeof(rq)); memset(&rqpm, 0, sizeof(rqpm)); memset(&args, 0, sizeof(args)); rq.cmd_type = REQ_TYPE_PM_RESUME; diff --git a/trunk/drivers/ide/pci/alim15x3.c b/trunk/drivers/ide/pci/alim15x3.c index c1922f9cfe80..b36a22b8c213 100644 --- a/trunk/drivers/ide/pci/alim15x3.c +++ b/trunk/drivers/ide/pci/alim15x3.c @@ -412,14 +412,14 @@ static u8 __devinit ali_cable_detect(ide_hwif_t *hwif) return cbl; } -#if !defined(CONFIG_SPARC64) && !defined(CONFIG_PPC) +#ifndef CONFIG_SPARC64 /** * init_hwif_ali15x3 - Initialize the ALI IDE x86 stuff * @hwif: interface to configure * * Obtain the IRQ tables for an ALi based IDE solution on the PC * class platforms. This part of the code isn't applicable to the - * Sparc and PowerPC systems. + * Sparc systems */ static void __devinit init_hwif_ali15x3 (ide_hwif_t *hwif) @@ -463,9 +463,7 @@ static void __devinit init_hwif_ali15x3 (ide_hwif_t *hwif) hwif->irq = irq; } } -#else -#define init_hwif_ali15x3 NULL -#endif /* !defined(CONFIG_SPARC64) && !defined(CONFIG_PPC) */ +#endif /** * init_dma_ali15x3 - set up DMA on ALi15x3 @@ -519,7 +517,9 @@ static const struct ide_dma_ops ali_dma_ops = { static const struct ide_port_info ali15x3_chipset __devinitdata = { .name = "ALI15X3", .init_chipset = init_chipset_ali15x3, +#ifndef CONFIG_SPARC64 .init_hwif = init_hwif_ali15x3, +#endif .init_dma = init_dma_ali15x3, .port_ops = &ali_port_ops, .pio_mask = ATA_PIO5, diff --git a/trunk/drivers/ide/pci/siimage.c b/trunk/drivers/ide/pci/siimage.c index 0006b9e58567..4cf8fc54aa2a 100644 --- a/trunk/drivers/ide/pci/siimage.c +++ b/trunk/drivers/ide/pci/siimage.c @@ -737,15 +737,8 @@ static const struct ide_port_ops sil_sata_port_ops = { .cable_detect = sil_cable_detect, }; -static const struct ide_dma_ops sil_dma_ops = { - .dma_host_set = ide_dma_host_set, - .dma_setup = ide_dma_setup, - .dma_exec_cmd = ide_dma_exec_cmd, - .dma_start = ide_dma_start, - .dma_end = __ide_dma_end, +static struct ide_dma_ops sil_dma_ops = { .dma_test_irq = siimage_dma_test_irq, - .dma_timeout = ide_dma_timeout, - .dma_lost_irq = ide_dma_lost_irq, }; #define DECLARE_SII_DEV(name_str, p_ops) \ diff --git a/trunk/drivers/infiniband/core/umem.c b/trunk/drivers/infiniband/core/umem.c index fe78f7d25099..4e3128ff73c1 100644 --- a/trunk/drivers/infiniband/core/umem.c +++ b/trunk/drivers/infiniband/core/umem.c @@ -38,7 +38,6 @@ #include #include #include -#include #include "uverbs.h" @@ -73,10 +72,9 @@ static void __ib_umem_release(struct ib_device *dev, struct ib_umem *umem, int d * @addr: userspace virtual address to start at * @size: length of region to pin * @access: IB_ACCESS_xxx flags for memory being pinned - * @dmasync: flush in-flight DMA when the memory region is written */ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr, - size_t size, int access, int dmasync) + size_t size, int access) { struct ib_umem *umem; struct page **page_list; @@ -89,10 +87,6 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr, int ret; int off; int i; - DEFINE_DMA_ATTRS(attrs); - - if (dmasync) - dma_set_attr(DMA_ATTR_WRITE_BARRIER, &attrs); if (!can_do_mlock()) return ERR_PTR(-EPERM); @@ -180,11 +174,10 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr, sg_set_page(&chunk->page_list[i], page_list[i + off], PAGE_SIZE, 0); } - chunk->nmap = ib_dma_map_sg_attrs(context->device, - &chunk->page_list[0], - chunk->nents, - DMA_BIDIRECTIONAL, - &attrs); + chunk->nmap = ib_dma_map_sg(context->device, + &chunk->page_list[0], + chunk->nents, + DMA_BIDIRECTIONAL); if (chunk->nmap <= 0) { for (i = 0; i < chunk->nents; ++i) put_page(sg_page(&chunk->page_list[i])); diff --git a/trunk/drivers/infiniband/hw/amso1100/c2_provider.c b/trunk/drivers/infiniband/hw/amso1100/c2_provider.c index 2acf9b62cf99..6af2c0f79a67 100644 --- a/trunk/drivers/infiniband/hw/amso1100/c2_provider.c +++ b/trunk/drivers/infiniband/hw/amso1100/c2_provider.c @@ -452,7 +452,7 @@ static struct ib_mr *c2_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, return ERR_PTR(-ENOMEM); c2mr->pd = c2pd; - c2mr->umem = ib_umem_get(pd->uobject->context, start, length, acc, 0); + c2mr->umem = ib_umem_get(pd->uobject->context, start, length, acc); if (IS_ERR(c2mr->umem)) { err = PTR_ERR(c2mr->umem); kfree(c2mr); diff --git a/trunk/drivers/infiniband/hw/cxgb3/cxio_hal.c b/trunk/drivers/infiniband/hw/cxgb3/cxio_hal.c index ed2ee4ba4b7c..66eb7030aea8 100644 --- a/trunk/drivers/infiniband/hw/cxgb3/cxio_hal.c +++ b/trunk/drivers/infiniband/hw/cxgb3/cxio_hal.c @@ -456,8 +456,7 @@ void cxio_count_scqes(struct t3_cq *cq, struct t3_wq *wq, int *count) ptr = cq->sw_rptr; while (!Q_EMPTY(ptr, cq->sw_wptr)) { cqe = cq->sw_queue + (Q_PTR2IDX(ptr, cq->size_log2)); - if ((SQ_TYPE(*cqe) || - ((CQE_OPCODE(*cqe) == T3_READ_RESP) && wq->oldest_read)) && + if ((SQ_TYPE(*cqe) || (CQE_OPCODE(*cqe) == T3_READ_RESP)) && (CQE_QPID(*cqe) == wq->qpid)) (*count)++; ptr++; @@ -830,8 +829,7 @@ int cxio_rdma_init(struct cxio_rdev *rdev_p, struct t3_rdma_init_attr *attr) wqe->mpaattrs = attr->mpaattrs; wqe->qpcaps = attr->qpcaps; wqe->ulpdu_size = cpu_to_be16(attr->tcp_emss); - wqe->rqe_count = cpu_to_be16(attr->rqe_count); - wqe->flags_rtr_type = cpu_to_be16(attr->flags|V_RTR_TYPE(attr->rtr_type)); + wqe->flags = cpu_to_be32(attr->flags); wqe->ord = cpu_to_be32(attr->ord); wqe->ird = cpu_to_be32(attr->ird); wqe->qp_dma_addr = cpu_to_be64(attr->qp_dma_addr); @@ -1136,18 +1134,6 @@ int cxio_poll_cq(struct t3_wq *wq, struct t3_cq *cq, struct t3_cqe *cqe, */ if (RQ_TYPE(*hw_cqe) && (CQE_OPCODE(*hw_cqe) == T3_READ_RESP)) { - /* - * If this is an unsolicited read response, then the read - * was generated by the kernel driver as part of peer-2-peer - * connection setup. So ignore the completion. - */ - if (!wq->oldest_read) { - if (CQE_STATUS(*hw_cqe)) - wq->error = 1; - ret = -1; - goto skip_cqe; - } - /* * Don't write to the HWCQ, so create a new read req CQE * in local memory. diff --git a/trunk/drivers/infiniband/hw/cxgb3/cxio_hal.h b/trunk/drivers/infiniband/hw/cxgb3/cxio_hal.h index 2bcff7f5046e..99543d634704 100644 --- a/trunk/drivers/infiniband/hw/cxgb3/cxio_hal.h +++ b/trunk/drivers/infiniband/hw/cxgb3/cxio_hal.h @@ -53,7 +53,6 @@ #define T3_MAX_PBL_SIZE 256 #define T3_MAX_RQ_SIZE 1024 #define T3_MAX_NUM_STAG (1<<15) -#define T3_MAX_MR_SIZE 0x100000000ULL #define T3_STAG_UNSET 0xffffffff diff --git a/trunk/drivers/infiniband/hw/cxgb3/cxio_wr.h b/trunk/drivers/infiniband/hw/cxgb3/cxio_wr.h index f1a25a821a45..969d4d928455 100644 --- a/trunk/drivers/infiniband/hw/cxgb3/cxio_wr.h +++ b/trunk/drivers/infiniband/hw/cxgb3/cxio_wr.h @@ -278,17 +278,6 @@ enum t3_qp_caps { uP_RI_QP_STAG0_ENABLE = 0x10 } __attribute__ ((packed)); -enum rdma_init_rtr_types { - RTR_READ = 1, - RTR_WRITE = 2, - RTR_SEND = 3, -}; - -#define S_RTR_TYPE 2 -#define M_RTR_TYPE 0x3 -#define V_RTR_TYPE(x) ((x) << S_RTR_TYPE) -#define G_RTR_TYPE(x) ((((x) >> S_RTR_TYPE)) & M_RTR_TYPE) - struct t3_rdma_init_attr { u32 tid; u32 qpid; @@ -304,9 +293,7 @@ struct t3_rdma_init_attr { u32 ird; u64 qp_dma_addr; u32 qp_dma_size; - enum rdma_init_rtr_types rtr_type; - u16 flags; - u16 rqe_count; + u32 flags; u32 irs; }; @@ -322,8 +309,8 @@ struct t3_rdma_init_wr { u8 mpaattrs; /* 5 */ u8 qpcaps; __be16 ulpdu_size; - __be16 flags_rtr_type; - __be16 rqe_count; + __be32 flags; /* bits 31-1 - reservered */ + /* bit 0 - set if RECV posted */ __be32 ord; /* 6 */ __be32 ird; __be64 qp_dma_addr; /* 7 */ @@ -337,7 +324,7 @@ struct t3_genbit { }; enum rdma_init_wr_flags { - MPA_INITIATOR = (1<<0), + RECVS_POSTED = (1<<0), PRIV_QP = (1<<1), }; diff --git a/trunk/drivers/infiniband/hw/cxgb3/iwch.c b/trunk/drivers/infiniband/hw/cxgb3/iwch.c index 71554eacb13c..6ba4138c8ec3 100644 --- a/trunk/drivers/infiniband/hw/cxgb3/iwch.c +++ b/trunk/drivers/infiniband/hw/cxgb3/iwch.c @@ -83,7 +83,6 @@ static void rnic_init(struct iwch_dev *rnicp) rnicp->attr.max_phys_buf_entries = T3_MAX_PBL_SIZE; rnicp->attr.max_pds = T3_MAX_NUM_PD - 1; rnicp->attr.mem_pgsizes_bitmask = 0x7FFF; /* 4KB-128MB */ - rnicp->attr.max_mr_size = T3_MAX_MR_SIZE; rnicp->attr.can_resize_wq = 0; rnicp->attr.max_rdma_reads_per_qp = 8; rnicp->attr.max_rdma_read_resources = diff --git a/trunk/drivers/infiniband/hw/cxgb3/iwch.h b/trunk/drivers/infiniband/hw/cxgb3/iwch.h index d2409a505e8d..9ad9b1e7c8c1 100644 --- a/trunk/drivers/infiniband/hw/cxgb3/iwch.h +++ b/trunk/drivers/infiniband/hw/cxgb3/iwch.h @@ -66,7 +66,6 @@ struct iwch_rnic_attributes { * size (4k)^i. Phys block list mode unsupported. */ u32 mem_pgsizes_bitmask; - u64 max_mr_size; u8 can_resize_wq; /* diff --git a/trunk/drivers/infiniband/hw/cxgb3/iwch_cm.c b/trunk/drivers/infiniband/hw/cxgb3/iwch_cm.c index d44a6df9ad8c..72ca360c3dbc 100644 --- a/trunk/drivers/infiniband/hw/cxgb3/iwch_cm.c +++ b/trunk/drivers/infiniband/hw/cxgb3/iwch_cm.c @@ -63,10 +63,6 @@ static char *states[] = { NULL, }; -int peer2peer = 0; -module_param(peer2peer, int, 0644); -MODULE_PARM_DESC(peer2peer, "Support peer2peer ULPs (default=0)"); - static int ep_timeout_secs = 10; module_param(ep_timeout_secs, int, 0644); MODULE_PARM_DESC(ep_timeout_secs, "CM Endpoint operation timeout " @@ -129,12 +125,6 @@ static void start_ep_timer(struct iwch_ep *ep) static void stop_ep_timer(struct iwch_ep *ep) { PDBG("%s ep %p\n", __func__, ep); - if (!timer_pending(&ep->timer)) { - printk(KERN_ERR "%s timer stopped when its not running! ep %p state %u\n", - __func__, ep, ep->com.state); - WARN_ON(1); - return; - } del_timer_sync(&ep->timer); put_ep(&ep->com); } @@ -518,7 +508,7 @@ static void send_mpa_req(struct iwch_ep *ep, struct sk_buff *skb) skb_reset_transport_header(skb); len = skb->len; req = (struct tx_data_wr *) skb_push(skb, sizeof(*req)); - req->wr_hi = htonl(V_WR_OP(FW_WROPCODE_OFLD_TX_DATA)|F_WR_COMPL); + req->wr_hi = htonl(V_WR_OP(FW_WROPCODE_OFLD_TX_DATA)); req->wr_lo = htonl(V_WR_TID(ep->hwtid)); req->len = htonl(len); req->param = htonl(V_TX_PORT(ep->l2t->smt_idx) | @@ -569,7 +559,7 @@ static int send_mpa_reject(struct iwch_ep *ep, const void *pdata, u8 plen) set_arp_failure_handler(skb, arp_failure_discard); skb_reset_transport_header(skb); req = (struct tx_data_wr *) skb_push(skb, sizeof(*req)); - req->wr_hi = htonl(V_WR_OP(FW_WROPCODE_OFLD_TX_DATA)|F_WR_COMPL); + req->wr_hi = htonl(V_WR_OP(FW_WROPCODE_OFLD_TX_DATA)); req->wr_lo = htonl(V_WR_TID(ep->hwtid)); req->len = htonl(mpalen); req->param = htonl(V_TX_PORT(ep->l2t->smt_idx) | @@ -621,7 +611,7 @@ static int send_mpa_reply(struct iwch_ep *ep, const void *pdata, u8 plen) skb_reset_transport_header(skb); len = skb->len; req = (struct tx_data_wr *) skb_push(skb, sizeof(*req)); - req->wr_hi = htonl(V_WR_OP(FW_WROPCODE_OFLD_TX_DATA)|F_WR_COMPL); + req->wr_hi = htonl(V_WR_OP(FW_WROPCODE_OFLD_TX_DATA)); req->wr_lo = htonl(V_WR_TID(ep->hwtid)); req->len = htonl(len); req->param = htonl(V_TX_PORT(ep->l2t->smt_idx) | @@ -889,7 +879,6 @@ static void process_mpa_reply(struct iwch_ep *ep, struct sk_buff *skb) * the MPA header is valid. */ state_set(&ep->com, FPDU_MODE); - ep->mpa_attr.initiator = 1; ep->mpa_attr.crc_enabled = (mpa->flags & MPA_CRC) | crc_enabled ? 1 : 0; ep->mpa_attr.recv_marker_enabled = markers_enabled; ep->mpa_attr.xmit_marker_enabled = mpa->flags & MPA_MARKERS ? 1 : 0; @@ -912,14 +901,8 @@ static void process_mpa_reply(struct iwch_ep *ep, struct sk_buff *skb) /* bind QP and TID with INIT_WR */ err = iwch_modify_qp(ep->com.qp->rhp, ep->com.qp, mask, &attrs, 1); - if (err) - goto err; - - if (peer2peer && iwch_rqes_posted(ep->com.qp) == 0) { - iwch_post_zb_read(ep->com.qp); - } - - goto out; + if (!err) + goto out; err: abort_connection(ep, skb, GFP_KERNEL); out: @@ -1012,7 +995,6 @@ static void process_mpa_request(struct iwch_ep *ep, struct sk_buff *skb) * If we get here we have accumulated the entire mpa * start reply message including private data. */ - ep->mpa_attr.initiator = 0; ep->mpa_attr.crc_enabled = (mpa->flags & MPA_CRC) | crc_enabled ? 1 : 0; ep->mpa_attr.recv_marker_enabled = markers_enabled; ep->mpa_attr.xmit_marker_enabled = mpa->flags & MPA_MARKERS ? 1 : 0; @@ -1083,33 +1065,17 @@ static int tx_ack(struct t3cdev *tdev, struct sk_buff *skb, void *ctx) PDBG("%s ep %p credits %u\n", __func__, ep, credits); - if (credits == 0) { - PDBG(KERN_ERR "%s 0 credit ack ep %p state %u\n", - __func__, ep, state_read(&ep->com)); + if (credits == 0) return CPL_RET_BUF_DONE; - } - BUG_ON(credits != 1); + BUG_ON(ep->mpa_skb == NULL); + kfree_skb(ep->mpa_skb); + ep->mpa_skb = NULL; dst_confirm(ep->dst); - if (!ep->mpa_skb) { - PDBG("%s rdma_init wr_ack ep %p state %u\n", - __func__, ep, state_read(&ep->com)); - if (ep->mpa_attr.initiator) { - PDBG("%s initiator ep %p state %u\n", - __func__, ep, state_read(&ep->com)); - if (peer2peer) - iwch_post_zb_read(ep->com.qp); - } else { - PDBG("%s responder ep %p state %u\n", - __func__, ep, state_read(&ep->com)); - ep->com.rpl_done = 1; - wake_up(&ep->com.waitq); - } - } else { - PDBG("%s lsm ack ep %p state %u freeing skb\n", - __func__, ep, state_read(&ep->com)); - kfree_skb(ep->mpa_skb); - ep->mpa_skb = NULL; + if (state_read(&ep->com) == MPA_REP_SENT) { + ep->com.rpl_done = 1; + PDBG("waking up ep %p\n", ep); + wake_up(&ep->com.waitq); } return CPL_RET_BUF_DONE; } @@ -1117,11 +1083,8 @@ static int tx_ack(struct t3cdev *tdev, struct sk_buff *skb, void *ctx) static int abort_rpl(struct t3cdev *tdev, struct sk_buff *skb, void *ctx) { struct iwch_ep *ep = ctx; - unsigned long flags; - int release = 0; PDBG("%s ep %p\n", __func__, ep); - BUG_ON(!ep); /* * We get 2 abort replies from the HW. The first one must @@ -1132,22 +1095,9 @@ static int abort_rpl(struct t3cdev *tdev, struct sk_buff *skb, void *ctx) return CPL_RET_BUF_DONE; } - spin_lock_irqsave(&ep->com.lock, flags); - switch (ep->com.state) { - case ABORTING: - close_complete_upcall(ep); - __state_set(&ep->com, DEAD); - release = 1; - break; - default: - printk(KERN_ERR "%s ep %p state %d\n", - __func__, ep, ep->com.state); - break; - } - spin_unlock_irqrestore(&ep->com.lock, flags); - - if (release) - release_ep_resources(ep); + close_complete_upcall(ep); + state_set(&ep->com, DEAD); + release_ep_resources(ep); return CPL_RET_BUF_DONE; } @@ -1520,8 +1470,7 @@ static int peer_abort(struct t3cdev *tdev, struct sk_buff *skb, void *ctx) struct sk_buff *rpl_skb; struct iwch_qp_attributes attrs; int ret; - int release = 0; - unsigned long flags; + int state; if (is_neg_adv_abort(req->status)) { PDBG("%s neg_adv_abort ep %p tid %d\n", __func__, ep, @@ -1539,9 +1488,9 @@ static int peer_abort(struct t3cdev *tdev, struct sk_buff *skb, void *ctx) return CPL_RET_BUF_DONE; } - spin_lock_irqsave(&ep->com.lock, flags); - PDBG("%s ep %p state %u\n", __func__, ep, ep->com.state); - switch (ep->com.state) { + state = state_read(&ep->com); + PDBG("%s ep %p state %u\n", __func__, ep, state); + switch (state) { case CONNECTING: break; case MPA_REQ_WAIT: @@ -1587,25 +1536,21 @@ static int peer_abort(struct t3cdev *tdev, struct sk_buff *skb, void *ctx) break; case DEAD: PDBG("%s PEER_ABORT IN DEAD STATE!!!!\n", __func__); - spin_unlock_irqrestore(&ep->com.lock, flags); return CPL_RET_BUF_DONE; default: BUG_ON(1); break; } dst_confirm(ep->dst); - if (ep->com.state != ABORTING) { - __state_set(&ep->com, DEAD); - release = 1; - } - spin_unlock_irqrestore(&ep->com.lock, flags); rpl_skb = get_skb(skb, sizeof(*rpl), GFP_KERNEL); if (!rpl_skb) { printk(KERN_ERR MOD "%s - cannot allocate skb!\n", __func__); - release = 1; - goto out; + dst_release(ep->dst); + l2t_release(L2DATA(ep->com.tdev), ep->l2t); + put_ep(&ep->com); + return CPL_RET_BUF_DONE; } rpl_skb->priority = CPL_PRIORITY_DATA; rpl = (struct cpl_abort_rpl *) skb_put(rpl_skb, sizeof(*rpl)); @@ -1614,9 +1559,10 @@ static int peer_abort(struct t3cdev *tdev, struct sk_buff *skb, void *ctx) OPCODE_TID(rpl) = htonl(MK_OPCODE_TID(CPL_ABORT_RPL, ep->hwtid)); rpl->cmd = CPL_ABORT_NO_RST; cxgb3_ofld_send(ep->com.tdev, rpl_skb); -out: - if (release) + if (state != ABORTING) { + state_set(&ep->com, DEAD); release_ep_resources(ep); + } return CPL_RET_BUF_DONE; } @@ -1715,18 +1661,15 @@ static void ep_timeout(unsigned long arg) struct iwch_ep *ep = (struct iwch_ep *)arg; struct iwch_qp_attributes attrs; unsigned long flags; - int abort = 1; spin_lock_irqsave(&ep->com.lock, flags); PDBG("%s ep %p tid %u state %d\n", __func__, ep, ep->hwtid, ep->com.state); switch (ep->com.state) { case MPA_REQ_SENT: - __state_set(&ep->com, ABORTING); connect_reply_upcall(ep, -ETIMEDOUT); break; case MPA_REQ_WAIT: - __state_set(&ep->com, ABORTING); break; case CLOSING: case MORIBUND: @@ -1736,17 +1679,13 @@ static void ep_timeout(unsigned long arg) ep->com.qp, IWCH_QP_ATTR_NEXT_STATE, &attrs, 1); } - __state_set(&ep->com, ABORTING); break; default: - printk(KERN_ERR "%s unexpected state ep %p state %u\n", - __func__, ep, ep->com.state); - WARN_ON(1); - abort = 0; + BUG(); } + __state_set(&ep->com, CLOSING); spin_unlock_irqrestore(&ep->com.lock, flags); - if (abort) - abort_connection(ep, NULL, GFP_ATOMIC); + abort_connection(ep, NULL, GFP_ATOMIC); put_ep(&ep->com); } @@ -1823,19 +1762,16 @@ int iwch_accept_cr(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) if (err) goto err; - /* if needed, wait for wr_ack */ - if (iwch_rqes_posted(qp)) { - wait_event(ep->com.waitq, ep->com.rpl_done); - err = ep->com.rpl_err; - if (err) - goto err; - } - err = send_mpa_reply(ep, conn_param->private_data, conn_param->private_data_len); if (err) goto err; + /* wait for wr_ack */ + wait_event(ep->com.waitq, ep->com.rpl_done); + err = ep->com.rpl_err; + if (err) + goto err; state_set(&ep->com, FPDU_MODE); established_upcall(ep); @@ -2032,39 +1968,40 @@ int iwch_ep_disconnect(struct iwch_ep *ep, int abrupt, gfp_t gfp) PDBG("%s ep %p state %s, abrupt %d\n", __func__, ep, states[ep->com.state], abrupt); + if (ep->com.state == DEAD) { + PDBG("%s already dead ep %p\n", __func__, ep); + goto out; + } + + if (abrupt) { + if (ep->com.state != ABORTING) { + ep->com.state = ABORTING; + close = 1; + } + goto out; + } + switch (ep->com.state) { case MPA_REQ_WAIT: case MPA_REQ_SENT: case MPA_REQ_RCVD: case MPA_REP_SENT: case FPDU_MODE: + start_ep_timer(ep); + ep->com.state = CLOSING; close = 1; - if (abrupt) - ep->com.state = ABORTING; - else { - ep->com.state = CLOSING; - start_ep_timer(ep); - } break; case CLOSING: + ep->com.state = MORIBUND; close = 1; - if (abrupt) { - stop_ep_timer(ep); - ep->com.state = ABORTING; - } else - ep->com.state = MORIBUND; break; case MORIBUND: - case ABORTING: - case DEAD: - PDBG("%s ignoring disconnect ep %p state %u\n", - __func__, ep, ep->com.state); break; default: BUG(); break; } - +out: spin_unlock_irqrestore(&ep->com.lock, flags); if (close) { if (abrupt) diff --git a/trunk/drivers/infiniband/hw/cxgb3/iwch_cm.h b/trunk/drivers/infiniband/hw/cxgb3/iwch_cm.h index d7c7e09f0996..2bb7fbdb3ff4 100644 --- a/trunk/drivers/infiniband/hw/cxgb3/iwch_cm.h +++ b/trunk/drivers/infiniband/hw/cxgb3/iwch_cm.h @@ -56,7 +56,6 @@ #define put_ep(ep) { \ PDBG("put_ep (via %s:%u) ep %p refcnt %d\n", __func__, __LINE__, \ ep, atomic_read(&((ep)->kref.refcount))); \ - WARN_ON(atomic_read(&((ep)->kref.refcount)) < 1); \ kref_put(&((ep)->kref), __free_ep); \ } @@ -226,6 +225,5 @@ int iwch_ep_redirect(void *ctx, struct dst_entry *old, struct dst_entry *new, st int __init iwch_cm_init(void); void __exit iwch_cm_term(void); -extern int peer2peer; #endif /* _IWCH_CM_H_ */ diff --git a/trunk/drivers/infiniband/hw/cxgb3/iwch_provider.c b/trunk/drivers/infiniband/hw/cxgb3/iwch_provider.c index d07d3a377b5f..ab4695c1dd56 100644 --- a/trunk/drivers/infiniband/hw/cxgb3/iwch_provider.c +++ b/trunk/drivers/infiniband/hw/cxgb3/iwch_provider.c @@ -602,7 +602,7 @@ static struct ib_mr *iwch_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, if (!mhp) return ERR_PTR(-ENOMEM); - mhp->umem = ib_umem_get(pd->uobject->context, start, length, acc, 0); + mhp->umem = ib_umem_get(pd->uobject->context, start, length, acc); if (IS_ERR(mhp->umem)) { err = PTR_ERR(mhp->umem); kfree(mhp); @@ -998,7 +998,7 @@ static int iwch_query_device(struct ib_device *ibdev, props->device_cap_flags = dev->device_cap_flags; props->vendor_id = (u32)dev->rdev.rnic_info.pdev->vendor; props->vendor_part_id = (u32)dev->rdev.rnic_info.pdev->device; - props->max_mr_size = dev->attr.max_mr_size; + props->max_mr_size = ~0ull; props->max_qp = dev->attr.max_qps; props->max_qp_wr = dev->attr.max_wrs; props->max_sge = dev->attr.max_sge_per_wr; diff --git a/trunk/drivers/infiniband/hw/cxgb3/iwch_provider.h b/trunk/drivers/infiniband/hw/cxgb3/iwch_provider.h index db5100d27ca2..61356f91109d 100644 --- a/trunk/drivers/infiniband/hw/cxgb3/iwch_provider.h +++ b/trunk/drivers/infiniband/hw/cxgb3/iwch_provider.h @@ -118,7 +118,6 @@ enum IWCH_QP_FLAGS { }; struct iwch_mpa_attributes { - u8 initiator; u8 recv_marker_enabled; u8 xmit_marker_enabled; /* iWARP: enable inbound Read Resp. */ u8 crc_enabled; @@ -323,7 +322,6 @@ enum iwch_qp_query_flags { IWCH_QP_QUERY_TEST_USERWRITE = 0x32 /* Test special */ }; -u16 iwch_rqes_posted(struct iwch_qp *qhp); int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, struct ib_send_wr **bad_wr); int iwch_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr, @@ -333,7 +331,6 @@ int iwch_bind_mw(struct ib_qp *qp, struct ib_mw_bind *mw_bind); int iwch_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc); int iwch_post_terminate(struct iwch_qp *qhp, struct respQ_msg_t *rsp_msg); -int iwch_post_zb_read(struct iwch_qp *qhp); int iwch_register_device(struct iwch_dev *dev); void iwch_unregister_device(struct iwch_dev *dev); int iwch_quiesce_qps(struct iwch_cq *chp); diff --git a/trunk/drivers/infiniband/hw/cxgb3/iwch_qp.c b/trunk/drivers/infiniband/hw/cxgb3/iwch_qp.c index 9b4be889c58e..8891c3b0a3d5 100644 --- a/trunk/drivers/infiniband/hw/cxgb3/iwch_qp.c +++ b/trunk/drivers/infiniband/hw/cxgb3/iwch_qp.c @@ -586,36 +586,6 @@ static inline void build_term_codes(struct respQ_msg_t *rsp_msg, } } -int iwch_post_zb_read(struct iwch_qp *qhp) -{ - union t3_wr *wqe; - struct sk_buff *skb; - u8 flit_cnt = sizeof(struct t3_rdma_read_wr) >> 3; - - PDBG("%s enter\n", __func__); - skb = alloc_skb(40, GFP_KERNEL); - if (!skb) { - printk(KERN_ERR "%s cannot send zb_read!!\n", __func__); - return -ENOMEM; - } - wqe = (union t3_wr *)skb_put(skb, sizeof(struct t3_rdma_read_wr)); - memset(wqe, 0, sizeof(struct t3_rdma_read_wr)); - wqe->read.rdmaop = T3_READ_REQ; - wqe->read.reserved[0] = 0; - wqe->read.reserved[1] = 0; - wqe->read.reserved[2] = 0; - wqe->read.rem_stag = cpu_to_be32(1); - wqe->read.rem_to = cpu_to_be64(1); - wqe->read.local_stag = cpu_to_be32(1); - wqe->read.local_len = cpu_to_be32(0); - wqe->read.local_to = cpu_to_be64(1); - wqe->send.wrh.op_seop_flags = cpu_to_be32(V_FW_RIWR_OP(T3_WR_READ)); - wqe->send.wrh.gen_tid_len = cpu_to_be32(V_FW_RIWR_TID(qhp->ep->hwtid)| - V_FW_RIWR_LEN(flit_cnt)); - skb->priority = CPL_PRIORITY_DATA; - return cxgb3_ofld_send(qhp->rhp->rdev.t3cdev_p, skb); -} - /* * This posts a TERMINATE with layer=RDMA, type=catastrophic. */ @@ -701,18 +671,11 @@ static void flush_qp(struct iwch_qp *qhp, unsigned long *flag) /* - * Return count of RECV WRs posted + * Return non zero if at least one RECV was pre-posted. */ -u16 iwch_rqes_posted(struct iwch_qp *qhp) +static int rqes_posted(struct iwch_qp *qhp) { - union t3_wr *wqe = qhp->wq.queue; - u16 count = 0; - while ((count+1) != 0 && fw_riwrh_opcode((struct fw_riwrh *)wqe) == T3_WR_RCV) { - count++; - wqe++; - } - PDBG("%s qhp %p count %u\n", __func__, qhp, count); - return count; + return fw_riwrh_opcode((struct fw_riwrh *)qhp->wq.queue) == T3_WR_RCV; } static int rdma_init(struct iwch_dev *rhp, struct iwch_qp *qhp, @@ -753,17 +716,8 @@ static int rdma_init(struct iwch_dev *rhp, struct iwch_qp *qhp, init_attr.ird = qhp->attr.max_ird; init_attr.qp_dma_addr = qhp->wq.dma_addr; init_attr.qp_dma_size = (1UL << qhp->wq.size_log2); - init_attr.rqe_count = iwch_rqes_posted(qhp); - init_attr.flags = qhp->attr.mpa_attr.initiator ? MPA_INITIATOR : 0; + init_attr.flags = rqes_posted(qhp) ? RECVS_POSTED : 0; init_attr.flags |= capable(CAP_NET_BIND_SERVICE) ? PRIV_QP : 0; - if (peer2peer) { - init_attr.rtr_type = RTR_READ; - if (init_attr.ord == 0 && qhp->attr.mpa_attr.initiator) - init_attr.ord = 1; - if (init_attr.ird == 0 && !qhp->attr.mpa_attr.initiator) - init_attr.ird = 1; - } else - init_attr.rtr_type = 0; init_attr.irs = qhp->ep->rcv_seq; PDBG("%s init_attr.rq_addr 0x%x init_attr.rq_size = %d " "flags 0x%x qpcaps 0x%x\n", __func__, @@ -878,7 +832,6 @@ int iwch_modify_qp(struct iwch_dev *rhp, struct iwch_qp *qhp, abort=0; disconnect = 1; ep = qhp->ep; - get_ep(&ep->com); } flush_qp(qhp, &flag); break; @@ -895,7 +848,6 @@ int iwch_modify_qp(struct iwch_dev *rhp, struct iwch_qp *qhp, abort=1; disconnect = 1; ep = qhp->ep; - get_ep(&ep->com); } goto err; break; @@ -977,10 +929,8 @@ int iwch_modify_qp(struct iwch_dev *rhp, struct iwch_qp *qhp, * on the EP. This can be a normal close (RTS->CLOSING) or * an abnormal close (RTS/CLOSING->ERROR). */ - if (disconnect) { + if (disconnect) iwch_ep_disconnect(ep, abort, GFP_KERNEL); - put_ep(&ep->com); - } /* * If free is 1, then we've disassociated the EP from the QP diff --git a/trunk/drivers/infiniband/hw/ehca/ehca_classes.h b/trunk/drivers/infiniband/hw/ehca/ehca_classes.h index 00bab60f6de4..3d6d9461c31d 100644 --- a/trunk/drivers/infiniband/hw/ehca/ehca_classes.h +++ b/trunk/drivers/infiniband/hw/ehca/ehca_classes.h @@ -66,7 +66,6 @@ struct ehca_av; #include "ehca_irq.h" #define EHCA_EQE_CACHE_SIZE 20 -#define EHCA_MAX_NUM_QUEUES 0xffff struct ehca_eqe_cache_entry { struct ehca_eqe *eqe; @@ -128,8 +127,6 @@ struct ehca_shca { /* MR pgsize: bit 0-3 means 4K, 64K, 1M, 16M respectively */ u32 hca_cap_mr_pgsize; int max_mtu; - atomic_t num_cqs; - atomic_t num_qps; }; struct ehca_pd { @@ -347,8 +344,6 @@ extern int ehca_use_hp_mr; extern int ehca_scaling_code; extern int ehca_lock_hcalls; extern int ehca_nr_ports; -extern int ehca_max_cq; -extern int ehca_max_qp; struct ipzu_queue_resp { u32 qe_size; /* queue entry size */ diff --git a/trunk/drivers/infiniband/hw/ehca/ehca_cq.c b/trunk/drivers/infiniband/hw/ehca/ehca_cq.c index 5540b276a33c..ec0cfcf3073f 100644 --- a/trunk/drivers/infiniband/hw/ehca/ehca_cq.c +++ b/trunk/drivers/infiniband/hw/ehca/ehca_cq.c @@ -132,19 +132,10 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe, int comp_vector, if (cqe >= 0xFFFFFFFF - 64 - additional_cqe) return ERR_PTR(-EINVAL); - if (!atomic_add_unless(&shca->num_cqs, 1, ehca_max_cq)) { - ehca_err(device, "Unable to create CQ, max number of %i " - "CQs reached.", ehca_max_cq); - ehca_err(device, "To increase the maximum number of CQs " - "use the number_of_cqs module parameter.\n"); - return ERR_PTR(-ENOSPC); - } - my_cq = kmem_cache_zalloc(cq_cache, GFP_KERNEL); if (!my_cq) { ehca_err(device, "Out of memory for ehca_cq struct device=%p", device); - atomic_dec(&shca->num_cqs); return ERR_PTR(-ENOMEM); } @@ -314,7 +305,6 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe, int comp_vector, create_cq_exit1: kmem_cache_free(cq_cache, my_cq); - atomic_dec(&shca->num_cqs); return cq; } @@ -369,7 +359,6 @@ int ehca_destroy_cq(struct ib_cq *cq) ipz_queue_dtor(NULL, &my_cq->ipz_queue); kmem_cache_free(cq_cache, my_cq); - atomic_dec(&shca->num_cqs); return 0; } diff --git a/trunk/drivers/infiniband/hw/ehca/ehca_eq.c b/trunk/drivers/infiniband/hw/ehca/ehca_eq.c index 49660dfa1867..b4ac617a70e6 100644 --- a/trunk/drivers/infiniband/hw/ehca/ehca_eq.c +++ b/trunk/drivers/infiniband/hw/ehca/ehca_eq.c @@ -54,8 +54,7 @@ int ehca_create_eq(struct ehca_shca *shca, struct ehca_eq *eq, const enum ehca_eq_type type, const u32 length) { - int ret; - u64 h_ret; + u64 ret; u32 nr_pages; u32 i; void *vpage; @@ -74,15 +73,15 @@ int ehca_create_eq(struct ehca_shca *shca, return -EINVAL; } - h_ret = hipz_h_alloc_resource_eq(shca->ipz_hca_handle, - &eq->pf, - type, - length, - &eq->ipz_eq_handle, - &eq->length, - &nr_pages, &eq->ist); + ret = hipz_h_alloc_resource_eq(shca->ipz_hca_handle, + &eq->pf, + type, + length, + &eq->ipz_eq_handle, + &eq->length, + &nr_pages, &eq->ist); - if (h_ret != H_SUCCESS) { + if (ret != H_SUCCESS) { ehca_err(ib_dev, "Can't allocate EQ/NEQ. eq=%p", eq); return -EINVAL; } @@ -98,22 +97,24 @@ int ehca_create_eq(struct ehca_shca *shca, u64 rpage; vpage = ipz_qpageit_get_inc(&eq->ipz_queue); - if (!vpage) + if (!vpage) { + ret = H_RESOURCE; goto create_eq_exit2; + } rpage = virt_to_abs(vpage); - h_ret = hipz_h_register_rpage_eq(shca->ipz_hca_handle, - eq->ipz_eq_handle, - &eq->pf, - 0, 0, rpage, 1); + ret = hipz_h_register_rpage_eq(shca->ipz_hca_handle, + eq->ipz_eq_handle, + &eq->pf, + 0, 0, rpage, 1); if (i == (nr_pages - 1)) { /* last page */ vpage = ipz_qpageit_get_inc(&eq->ipz_queue); - if (h_ret != H_SUCCESS || vpage) + if (ret != H_SUCCESS || vpage) goto create_eq_exit2; } else { - if (h_ret != H_PAGE_REGISTERED || !vpage) + if (ret != H_PAGE_REGISTERED || !vpage) goto create_eq_exit2; } } diff --git a/trunk/drivers/infiniband/hw/ehca/ehca_main.c b/trunk/drivers/infiniband/hw/ehca/ehca_main.c index 482103eb6eac..65048976198c 100644 --- a/trunk/drivers/infiniband/hw/ehca/ehca_main.c +++ b/trunk/drivers/infiniband/hw/ehca/ehca_main.c @@ -68,8 +68,6 @@ int ehca_port_act_time = 30; int ehca_static_rate = -1; int ehca_scaling_code = 0; int ehca_lock_hcalls = -1; -int ehca_max_cq = -1; -int ehca_max_qp = -1; module_param_named(open_aqp1, ehca_open_aqp1, bool, S_IRUGO); module_param_named(debug_level, ehca_debug_level, int, S_IRUGO); @@ -81,8 +79,6 @@ module_param_named(poll_all_eqs, ehca_poll_all_eqs, bool, S_IRUGO); module_param_named(static_rate, ehca_static_rate, int, S_IRUGO); module_param_named(scaling_code, ehca_scaling_code, bool, S_IRUGO); module_param_named(lock_hcalls, ehca_lock_hcalls, bool, S_IRUGO); -module_param_named(number_of_cqs, ehca_max_cq, int, S_IRUGO); -module_param_named(number_of_qps, ehca_max_qp, int, S_IRUGO); MODULE_PARM_DESC(open_aqp1, "Open AQP1 on startup (default: no)"); @@ -108,12 +104,6 @@ MODULE_PARM_DESC(scaling_code, MODULE_PARM_DESC(lock_hcalls, "Serialize all hCalls made by the driver " "(default: autodetect)"); -MODULE_PARM_DESC(number_of_cqs, - "Max number of CQs which can be allocated " - "(default: autodetect)"); -MODULE_PARM_DESC(number_of_qps, - "Max number of QPs which can be allocated " - "(default: autodetect)"); DEFINE_RWLOCK(ehca_qp_idr_lock); DEFINE_RWLOCK(ehca_cq_idr_lock); @@ -365,25 +355,6 @@ static int ehca_sense_attributes(struct ehca_shca *shca) if (rblock->memory_page_size_supported & pgsize_map[i]) shca->hca_cap_mr_pgsize |= pgsize_map[i + 1]; - /* Set maximum number of CQs and QPs to calculate EQ size */ - if (ehca_max_qp == -1) - ehca_max_qp = min_t(int, rblock->max_qp, EHCA_MAX_NUM_QUEUES); - else if (ehca_max_qp < 1 || ehca_max_qp > rblock->max_qp) { - ehca_gen_err("Requested number of QPs is out of range (1 - %i) " - "specified by HW", rblock->max_qp); - ret = -EINVAL; - goto sense_attributes1; - } - - if (ehca_max_cq == -1) - ehca_max_cq = min_t(int, rblock->max_cq, EHCA_MAX_NUM_QUEUES); - else if (ehca_max_cq < 1 || ehca_max_cq > rblock->max_cq) { - ehca_gen_err("Requested number of CQs is out of range (1 - %i) " - "specified by HW", rblock->max_cq); - ret = -EINVAL; - goto sense_attributes1; - } - /* query max MTU from first port -- it's the same for all ports */ port = (struct hipz_query_port *)rblock; h_ret = hipz_h_query_port(shca->ipz_hca_handle, 1, port); @@ -713,7 +684,7 @@ static int __devinit ehca_probe(struct of_device *dev, struct ehca_shca *shca; const u64 *handle; struct ib_pd *ibpd; - int ret, i, eq_size; + int ret, i; handle = of_get_property(dev->node, "ibm,hca-handle", NULL); if (!handle) { @@ -734,8 +705,6 @@ static int __devinit ehca_probe(struct of_device *dev, return -ENOMEM; } mutex_init(&shca->modify_mutex); - atomic_set(&shca->num_cqs, 0); - atomic_set(&shca->num_qps, 0); for (i = 0; i < ARRAY_SIZE(shca->sport); i++) spin_lock_init(&shca->sport[i].mod_sqp_lock); @@ -755,9 +724,8 @@ static int __devinit ehca_probe(struct of_device *dev, goto probe1; } - eq_size = 2 * ehca_max_cq + 4 * ehca_max_qp; /* create event queues */ - ret = ehca_create_eq(shca, &shca->eq, EHCA_EQ, eq_size); + ret = ehca_create_eq(shca, &shca->eq, EHCA_EQ, 2048); if (ret) { ehca_err(&shca->ib_device, "Cannot create EQ."); goto probe1; diff --git a/trunk/drivers/infiniband/hw/ehca/ehca_mrmw.c b/trunk/drivers/infiniband/hw/ehca/ehca_mrmw.c index f974367cad40..46ae4eb2c4e1 100644 --- a/trunk/drivers/infiniband/hw/ehca/ehca_mrmw.c +++ b/trunk/drivers/infiniband/hw/ehca/ehca_mrmw.c @@ -323,7 +323,7 @@ struct ib_mr *ehca_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, } e_mr->umem = ib_umem_get(pd->uobject->context, start, length, - mr_access_flags, 0); + mr_access_flags); if (IS_ERR(e_mr->umem)) { ib_mr = (void *)e_mr->umem; goto reg_user_mr_exit1; diff --git a/trunk/drivers/infiniband/hw/ehca/ehca_qp.c b/trunk/drivers/infiniband/hw/ehca/ehca_qp.c index 18fba92fa7ae..57bef1152cc2 100644 --- a/trunk/drivers/infiniband/hw/ehca/ehca_qp.c +++ b/trunk/drivers/infiniband/hw/ehca/ehca_qp.c @@ -421,18 +421,8 @@ static struct ehca_qp *internal_create_qp( u32 swqe_size = 0, rwqe_size = 0, ib_qp_num; unsigned long flags; - if (!atomic_add_unless(&shca->num_qps, 1, ehca_max_qp)) { - ehca_err(pd->device, "Unable to create QP, max number of %i " - "QPs reached.", ehca_max_qp); - ehca_err(pd->device, "To increase the maximum number of QPs " - "use the number_of_qps module parameter.\n"); - return ERR_PTR(-ENOSPC); - } - - if (init_attr->create_flags) { - atomic_dec(&shca->num_qps); + if (init_attr->create_flags) return ERR_PTR(-EINVAL); - } memset(&parms, 0, sizeof(parms)); qp_type = init_attr->qp_type; @@ -441,7 +431,6 @@ static struct ehca_qp *internal_create_qp( init_attr->sq_sig_type != IB_SIGNAL_ALL_WR) { ehca_err(pd->device, "init_attr->sg_sig_type=%x not allowed", init_attr->sq_sig_type); - atomic_dec(&shca->num_qps); return ERR_PTR(-EINVAL); } @@ -466,7 +455,6 @@ static struct ehca_qp *internal_create_qp( if (is_llqp && has_srq) { ehca_err(pd->device, "LLQPs can't have an SRQ"); - atomic_dec(&shca->num_qps); return ERR_PTR(-EINVAL); } @@ -478,7 +466,6 @@ static struct ehca_qp *internal_create_qp( ehca_err(pd->device, "no more than three SGEs " "supported for SRQ pd=%p max_sge=%x", pd, init_attr->cap.max_recv_sge); - atomic_dec(&shca->num_qps); return ERR_PTR(-EINVAL); } } @@ -490,7 +477,6 @@ static struct ehca_qp *internal_create_qp( qp_type != IB_QPT_SMI && qp_type != IB_QPT_GSI) { ehca_err(pd->device, "wrong QP Type=%x", qp_type); - atomic_dec(&shca->num_qps); return ERR_PTR(-EINVAL); } @@ -504,7 +490,6 @@ static struct ehca_qp *internal_create_qp( "or max_rq_wr=%x for RC LLQP", init_attr->cap.max_send_wr, init_attr->cap.max_recv_wr); - atomic_dec(&shca->num_qps); return ERR_PTR(-EINVAL); } break; @@ -512,7 +497,6 @@ static struct ehca_qp *internal_create_qp( if (!EHCA_BMASK_GET(HCA_CAP_UD_LL_QP, shca->hca_cap)) { ehca_err(pd->device, "UD LLQP not supported " "by this adapter"); - atomic_dec(&shca->num_qps); return ERR_PTR(-ENOSYS); } if (!(init_attr->cap.max_send_sge <= 5 @@ -524,22 +508,20 @@ static struct ehca_qp *internal_create_qp( "or max_recv_sge=%x for UD LLQP", init_attr->cap.max_send_sge, init_attr->cap.max_recv_sge); - atomic_dec(&shca->num_qps); return ERR_PTR(-EINVAL); } else if (init_attr->cap.max_send_wr > 255) { ehca_err(pd->device, "Invalid Number of " "max_send_wr=%x for UD QP_TYPE=%x", init_attr->cap.max_send_wr, qp_type); - atomic_dec(&shca->num_qps); return ERR_PTR(-EINVAL); } break; default: ehca_err(pd->device, "unsupported LL QP Type=%x", qp_type); - atomic_dec(&shca->num_qps); return ERR_PTR(-EINVAL); + break; } } else { int max_sge = (qp_type == IB_QPT_UD || qp_type == IB_QPT_SMI @@ -551,7 +533,6 @@ static struct ehca_qp *internal_create_qp( "send_sge=%x recv_sge=%x max_sge=%x", init_attr->cap.max_send_sge, init_attr->cap.max_recv_sge, max_sge); - atomic_dec(&shca->num_qps); return ERR_PTR(-EINVAL); } } @@ -562,7 +543,6 @@ static struct ehca_qp *internal_create_qp( my_qp = kmem_cache_zalloc(qp_cache, GFP_KERNEL); if (!my_qp) { ehca_err(pd->device, "pd=%p not enough memory to alloc qp", pd); - atomic_dec(&shca->num_qps); return ERR_PTR(-ENOMEM); } @@ -843,7 +823,6 @@ static struct ehca_qp *internal_create_qp( create_qp_exit0: kmem_cache_free(qp_cache, my_qp); - atomic_dec(&shca->num_qps); return ERR_PTR(ret); } @@ -1969,7 +1948,6 @@ static int internal_destroy_qp(struct ib_device *dev, struct ehca_qp *my_qp, if (HAS_SQ(my_qp)) ipz_queue_dtor(my_pd, &my_qp->ipz_squeue); kmem_cache_free(qp_cache, my_qp); - atomic_dec(&shca->num_qps); return 0; } diff --git a/trunk/drivers/infiniband/hw/ipath/ipath_mr.c b/trunk/drivers/infiniband/hw/ipath/ipath_mr.c index 9d343b7c2f3b..db4ba92f79fc 100644 --- a/trunk/drivers/infiniband/hw/ipath/ipath_mr.c +++ b/trunk/drivers/infiniband/hw/ipath/ipath_mr.c @@ -195,8 +195,7 @@ struct ib_mr *ipath_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, goto bail; } - umem = ib_umem_get(pd->uobject->context, start, length, - mr_access_flags, 0); + umem = ib_umem_get(pd->uobject->context, start, length, mr_access_flags); if (IS_ERR(umem)) return (void *) umem; diff --git a/trunk/drivers/infiniband/hw/mlx4/cq.c b/trunk/drivers/infiniband/hw/mlx4/cq.c index 2f199c5c4a72..5e570bb0bb6f 100644 --- a/trunk/drivers/infiniband/hw/mlx4/cq.c +++ b/trunk/drivers/infiniband/hw/mlx4/cq.c @@ -137,7 +137,7 @@ static int mlx4_ib_get_cq_umem(struct mlx4_ib_dev *dev, struct ib_ucontext *cont int err; *umem = ib_umem_get(context, buf_addr, cqe * sizeof (struct mlx4_cqe), - IB_ACCESS_LOCAL_WRITE, 1); + IB_ACCESS_LOCAL_WRITE); if (IS_ERR(*umem)) return PTR_ERR(*umem); @@ -221,7 +221,7 @@ struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev, int entries, int vector } err = mlx4_cq_alloc(dev->dev, entries, &cq->buf.mtt, uar, - cq->db.dma, &cq->mcq, 0); + cq->db.dma, &cq->mcq); if (err) goto err_dbmap; diff --git a/trunk/drivers/infiniband/hw/mlx4/doorbell.c b/trunk/drivers/infiniband/hw/mlx4/doorbell.c index 8aee4233b388..8e342cc9baec 100644 --- a/trunk/drivers/infiniband/hw/mlx4/doorbell.c +++ b/trunk/drivers/infiniband/hw/mlx4/doorbell.c @@ -63,7 +63,7 @@ int mlx4_ib_db_map_user(struct mlx4_ib_ucontext *context, unsigned long virt, page->user_virt = (virt & PAGE_MASK); page->refcnt = 0; page->umem = ib_umem_get(&context->ibucontext, virt & PAGE_MASK, - PAGE_SIZE, 0, 0); + PAGE_SIZE, 0); if (IS_ERR(page->umem)) { err = PTR_ERR(page->umem); kfree(page); diff --git a/trunk/drivers/infiniband/hw/mlx4/mr.c b/trunk/drivers/infiniband/hw/mlx4/mr.c index 68e92485fc76..fe2c2e94a5f8 100644 --- a/trunk/drivers/infiniband/hw/mlx4/mr.c +++ b/trunk/drivers/infiniband/hw/mlx4/mr.c @@ -132,8 +132,7 @@ struct ib_mr *mlx4_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, if (!mr) return ERR_PTR(-ENOMEM); - mr->umem = ib_umem_get(pd->uobject->context, start, length, - access_flags, 0); + mr->umem = ib_umem_get(pd->uobject->context, start, length, access_flags); if (IS_ERR(mr->umem)) { err = PTR_ERR(mr->umem); goto err_free; diff --git a/trunk/drivers/infiniband/hw/mlx4/qp.c b/trunk/drivers/infiniband/hw/mlx4/qp.c index 8e02ecfec188..80ea8b9e7761 100644 --- a/trunk/drivers/infiniband/hw/mlx4/qp.c +++ b/trunk/drivers/infiniband/hw/mlx4/qp.c @@ -482,7 +482,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, goto err; qp->umem = ib_umem_get(pd->uobject->context, ucmd.buf_addr, - qp->buf_size, 0, 0); + qp->buf_size, 0); if (IS_ERR(qp->umem)) { err = PTR_ERR(qp->umem); goto err; diff --git a/trunk/drivers/infiniband/hw/mlx4/srq.c b/trunk/drivers/infiniband/hw/mlx4/srq.c index 12d6bc6f8007..204619702f9d 100644 --- a/trunk/drivers/infiniband/hw/mlx4/srq.c +++ b/trunk/drivers/infiniband/hw/mlx4/srq.c @@ -109,7 +109,7 @@ struct ib_srq *mlx4_ib_create_srq(struct ib_pd *pd, } srq->umem = ib_umem_get(pd->uobject->context, ucmd.buf_addr, - buf_size, 0, 0); + buf_size, 0); if (IS_ERR(srq->umem)) { err = PTR_ERR(srq->umem); goto err_srq; diff --git a/trunk/drivers/infiniband/hw/mthca/mthca_mr.c b/trunk/drivers/infiniband/hw/mthca/mthca_mr.c index 820205dec560..3538da16e3fe 100644 --- a/trunk/drivers/infiniband/hw/mthca/mthca_mr.c +++ b/trunk/drivers/infiniband/hw/mthca/mthca_mr.c @@ -818,9 +818,15 @@ int mthca_arbel_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list, void mthca_tavor_fmr_unmap(struct mthca_dev *dev, struct mthca_fmr *fmr) { + u32 key; + if (!fmr->maps) return; + key = tavor_key_to_hw_index(fmr->ibmr.lkey); + key &= dev->limits.num_mpts - 1; + fmr->ibmr.lkey = fmr->ibmr.rkey = tavor_hw_index_to_key(key); + fmr->maps = 0; writeb(MTHCA_MPT_STATUS_SW, fmr->mem.tavor.mpt); @@ -828,9 +834,16 @@ void mthca_tavor_fmr_unmap(struct mthca_dev *dev, struct mthca_fmr *fmr) void mthca_arbel_fmr_unmap(struct mthca_dev *dev, struct mthca_fmr *fmr) { + u32 key; + if (!fmr->maps) return; + key = arbel_key_to_hw_index(fmr->ibmr.lkey); + key &= dev->limits.num_mpts - 1; + key = adjust_key(dev, key); + fmr->ibmr.lkey = fmr->ibmr.rkey = arbel_hw_index_to_key(key); + fmr->maps = 0; *(u8 *) fmr->mem.arbel.mpt = MTHCA_MPT_STATUS_SW; diff --git a/trunk/drivers/infiniband/hw/mthca/mthca_provider.c b/trunk/drivers/infiniband/hw/mthca/mthca_provider.c index be34f99ca625..696e1f302332 100644 --- a/trunk/drivers/infiniband/hw/mthca/mthca_provider.c +++ b/trunk/drivers/infiniband/hw/mthca/mthca_provider.c @@ -39,8 +39,6 @@ #include #include #include - -#include #include #include "mthca_dev.h" @@ -369,8 +367,6 @@ static struct ib_ucontext *mthca_alloc_ucontext(struct ib_device *ibdev, return ERR_PTR(-EFAULT); } - context->reg_mr_warned = 0; - return &context->ibucontext; } @@ -1010,31 +1006,17 @@ static struct ib_mr *mthca_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, struct mthca_dev *dev = to_mdev(pd->device); struct ib_umem_chunk *chunk; struct mthca_mr *mr; - struct mthca_reg_mr ucmd; u64 *pages; int shift, n, len; int i, j, k; int err = 0; int write_mtt_size; - if (udata->inlen - sizeof (struct ib_uverbs_cmd_hdr) < sizeof ucmd) { - if (!to_mucontext(pd->uobject->context)->reg_mr_warned) { - mthca_warn(dev, "Process '%s' did not pass in MR attrs.\n", - current->comm); - mthca_warn(dev, " Update libmthca to fix this.\n"); - } - ++to_mucontext(pd->uobject->context)->reg_mr_warned; - ucmd.mr_attrs = 0; - } else if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) - return ERR_PTR(-EFAULT); - mr = kmalloc(sizeof *mr, GFP_KERNEL); if (!mr) return ERR_PTR(-ENOMEM); - mr->umem = ib_umem_get(pd->uobject->context, start, length, acc, - ucmd.mr_attrs & MTHCA_MR_DMASYNC); - + mr->umem = ib_umem_get(pd->uobject->context, start, length, acc); if (IS_ERR(mr->umem)) { err = PTR_ERR(mr->umem); goto err; diff --git a/trunk/drivers/infiniband/hw/mthca/mthca_provider.h b/trunk/drivers/infiniband/hw/mthca/mthca_provider.h index 934bf9544037..262616c8ebb6 100644 --- a/trunk/drivers/infiniband/hw/mthca/mthca_provider.h +++ b/trunk/drivers/infiniband/hw/mthca/mthca_provider.h @@ -67,7 +67,6 @@ struct mthca_ucontext { struct ib_ucontext ibucontext; struct mthca_uar uar; struct mthca_user_db_table *db_tab; - int reg_mr_warned; }; struct mthca_mtt; diff --git a/trunk/drivers/infiniband/hw/mthca/mthca_user.h b/trunk/drivers/infiniband/hw/mthca/mthca_user.h index e1262c942db8..02cc0a766f3a 100644 --- a/trunk/drivers/infiniband/hw/mthca/mthca_user.h +++ b/trunk/drivers/infiniband/hw/mthca/mthca_user.h @@ -61,16 +61,6 @@ struct mthca_alloc_pd_resp { __u32 reserved; }; -struct mthca_reg_mr { -/* - * Mark the memory region with a DMA attribute that causes - * in-flight DMA to be flushed when the region is written to: - */ -#define MTHCA_MR_DMASYNC 0x1 - __u32 mr_attrs; - __u32 reserved; -}; - struct mthca_create_cq { __u32 lkey; __u32 pdn; diff --git a/trunk/drivers/infiniband/hw/nes/Kconfig b/trunk/drivers/infiniband/hw/nes/Kconfig index d449eb6ec78e..2aeb7ac972a9 100644 --- a/trunk/drivers/infiniband/hw/nes/Kconfig +++ b/trunk/drivers/infiniband/hw/nes/Kconfig @@ -2,7 +2,6 @@ config INFINIBAND_NES tristate "NetEffect RNIC Driver" depends on PCI && INET && INFINIBAND select LIBCRC32C - select INET_LRO ---help--- This is a low-level driver for NetEffect RDMA enabled Network Interface Cards (RNIC). diff --git a/trunk/drivers/infiniband/hw/nes/nes.c b/trunk/drivers/infiniband/hw/nes/nes.c index 9f7364a9096d..a4e9269a29bd 100644 --- a/trunk/drivers/infiniband/hw/nes/nes.c +++ b/trunk/drivers/infiniband/hw/nes/nes.c @@ -91,10 +91,6 @@ unsigned int nes_debug_level = 0; module_param_named(debug_level, nes_debug_level, uint, 0644); MODULE_PARM_DESC(debug_level, "Enable debug output level"); -unsigned int nes_lro_max_aggr = NES_LRO_MAX_AGGR; -module_param(nes_lro_max_aggr, int, NES_LRO_MAX_AGGR); -MODULE_PARM_DESC(nes_mro_max_aggr, " nic LRO MAX packet aggregation"); - LIST_HEAD(nes_adapter_list); static LIST_HEAD(nes_dev_list); diff --git a/trunk/drivers/infiniband/hw/nes/nes.h b/trunk/drivers/infiniband/hw/nes/nes.h index 1f9f7bf73862..cdf2e9ad62f7 100644 --- a/trunk/drivers/infiniband/hw/nes/nes.h +++ b/trunk/drivers/infiniband/hw/nes/nes.h @@ -173,7 +173,6 @@ extern int disable_mpa_crc; extern unsigned int send_first; extern unsigned int nes_drv_opt; extern unsigned int nes_debug_level; -extern unsigned int nes_lro_max_aggr; extern struct list_head nes_adapter_list; @@ -536,8 +535,8 @@ int nes_register_ofa_device(struct nes_ib_device *); int nes_read_eeprom_values(struct nes_device *, struct nes_adapter *); void nes_write_1G_phy_reg(struct nes_device *, u8, u8, u16); void nes_read_1G_phy_reg(struct nes_device *, u8, u8, u16 *); -void nes_write_10G_phy_reg(struct nes_device *, u16, u8, u16, u16); -void nes_read_10G_phy_reg(struct nes_device *, u8, u8, u16); +void nes_write_10G_phy_reg(struct nes_device *, u16, u8, u16); +void nes_read_10G_phy_reg(struct nes_device *, u16, u8); struct nes_cqp_request *nes_get_cqp_request(struct nes_device *); void nes_post_cqp_request(struct nes_device *, struct nes_cqp_request *, int); int nes_arp_table(struct nes_device *, u32, u8 *, u32); diff --git a/trunk/drivers/infiniband/hw/nes/nes_cm.c b/trunk/drivers/infiniband/hw/nes/nes_cm.c index 9a4b40fae40d..d940fc27129a 100644 --- a/trunk/drivers/infiniband/hw/nes/nes_cm.c +++ b/trunk/drivers/infiniband/hw/nes/nes_cm.c @@ -594,7 +594,7 @@ static void nes_cm_timer_tick(unsigned long pass) continue; } /* this seems like the correct place, but leave send entry unprotected */ - /* spin_unlock_irqrestore(&cm_node->retrans_list_lock, flags); */ + // spin_unlock_irqrestore(&cm_node->retrans_list_lock, flags); atomic_inc(&send_entry->skb->users); cm_packets_retrans++; nes_debug(NES_DBG_CM, "Retransmitting send_entry %p for node %p," @@ -1335,7 +1335,7 @@ static int process_packet(struct nes_cm_node *cm_node, struct sk_buff *skb, cm_node->loc_addr, cm_node->loc_port, cm_node->rem_addr, cm_node->rem_port, cm_node->state, atomic_read(&cm_node->ref_count)); - /* create event */ + // create event cm_node->state = NES_CM_STATE_CLOSED; create_event(cm_node, NES_CM_EVENT_ABORTED); @@ -1669,7 +1669,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core, if (!cm_node) return NULL; - /* set our node side to client (active) side */ + // set our node side to client (active) side cm_node->tcp_cntxt.client = 1; cm_node->tcp_cntxt.rcv_wscale = NES_CM_DEFAULT_RCV_WND_SCALE; @@ -1694,7 +1694,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core, loopbackremotenode->mpa_frame_size = mpa_frame_size - sizeof(struct ietf_mpa_frame); - /* we are done handling this state, set node to a TSA state */ + // we are done handling this state, set node to a TSA state cm_node->state = NES_CM_STATE_TSA; cm_node->tcp_cntxt.rcv_nxt = loopbackremotenode->tcp_cntxt.loc_seq_num; loopbackremotenode->tcp_cntxt.rcv_nxt = cm_node->tcp_cntxt.loc_seq_num; diff --git a/trunk/drivers/infiniband/hw/nes/nes_hw.c b/trunk/drivers/infiniband/hw/nes/nes_hw.c index 8dc70f9bad2f..08964cc7e98a 100644 --- a/trunk/drivers/infiniband/hw/nes/nes_hw.c +++ b/trunk/drivers/infiniband/hw/nes/nes_hw.c @@ -38,7 +38,6 @@ #include #include #include -#include #include "nes.h" @@ -833,7 +832,7 @@ static void nes_init_csr_ne020(struct nes_device *nesdev, u8 hw_rev, u8 port_cou nes_write_indexed(nesdev, 0x00000900, 0x20000001); nes_write_indexed(nesdev, 0x000060C0, 0x0000028e); nes_write_indexed(nesdev, 0x000060C8, 0x00000020); - + // nes_write_indexed(nesdev, 0x000001EC, 0x7b2625a0); /* nes_write_indexed(nesdev, 0x000001EC, 0x5f2625a0); */ @@ -1208,16 +1207,11 @@ int nes_init_phy(struct nes_device *nesdev) { struct nes_adapter *nesadapter = nesdev->nesadapter; u32 counter = 0; - u32 sds_common_control0; u32 mac_index = nesdev->mac_index; - u32 tx_config = 0; + u32 tx_config; u16 phy_data; - u32 temp_phy_data = 0; - u32 temp_phy_data2 = 0; - u32 i = 0; - if ((nesadapter->OneG_Mode) && - (nesadapter->phy_type[mac_index] != NES_PHY_TYPE_PUMA_1G)) { + if (nesadapter->OneG_Mode) { nes_debug(NES_DBG_PHY, "1G PHY, mac_index = %d.\n", mac_index); if (nesadapter->phy_type[mac_index] == NES_PHY_TYPE_1G) { printk(PFX "%s: Programming mdc config for 1G\n", __func__); @@ -1229,7 +1223,7 @@ int nes_init_phy(struct nes_device *nesdev) nes_read_1G_phy_reg(nesdev, 1, nesadapter->phy_index[mac_index], &phy_data); nes_debug(NES_DBG_PHY, "Phy data from register 1 phy address %u = 0x%X.\n", nesadapter->phy_index[mac_index], phy_data); - nes_write_1G_phy_reg(nesdev, 23, nesadapter->phy_index[mac_index], 0xb000); + nes_write_1G_phy_reg(nesdev, 23, nesadapter->phy_index[mac_index], 0xb000); /* Reset the PHY */ nes_write_1G_phy_reg(nesdev, 0, nesadapter->phy_index[mac_index], 0x8000); @@ -1283,126 +1277,12 @@ int nes_init_phy(struct nes_device *nesdev) nes_read_1G_phy_reg(nesdev, 0, nesadapter->phy_index[mac_index], &phy_data); nes_write_1G_phy_reg(nesdev, 0, nesadapter->phy_index[mac_index], phy_data | 0x0300); } else { - if ((nesadapter->phy_type[mac_index] == NES_PHY_TYPE_IRIS) || - (nesadapter->phy_type[mac_index] == NES_PHY_TYPE_ARGUS)) { + if (nesadapter->phy_type[mac_index] == NES_PHY_TYPE_IRIS) { /* setup 10G MDIO operation */ tx_config = nes_read_indexed(nesdev, NES_IDX_MAC_TX_CONFIG); tx_config |= 0x14; nes_write_indexed(nesdev, NES_IDX_MAC_TX_CONFIG, tx_config); } - if ((nesadapter->phy_type[mac_index] == NES_PHY_TYPE_ARGUS)) { - nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x3, 0xd7ee); - - temp_phy_data = (u16)nes_read_indexed(nesdev, NES_IDX_MAC_MDIO_CONTROL); - mdelay(10); - nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x3, 0xd7ee); - temp_phy_data2 = (u16)nes_read_indexed(nesdev, NES_IDX_MAC_MDIO_CONTROL); - - /* - * if firmware is already running (like from a - * driver un-load/load, don't do anything. - */ - if (temp_phy_data == temp_phy_data2) { - /* configure QT2505 AMCC PHY */ - nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x1, 0x0000, 0x8000); - nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x1, 0xc300, 0x0000); - nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x1, 0xc302, 0x0044); - nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x1, 0xc318, 0x0052); - nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x1, 0xc319, 0x0008); - nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x1, 0xc31a, 0x0098); - nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x3, 0x0026, 0x0E00); - nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x3, 0x0027, 0x0000); - nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x3, 0x0028, 0xA528); - - /* - * remove micro from reset; chip boots from ROM, - * uploads EEPROM f/w image, uC executes f/w - */ - nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x1, 0xc300, 0x0002); - - /* - * wait for heart beat to start to - * know loading is done - */ - counter = 0; - do { - nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x3, 0xd7ee); - temp_phy_data = (u16)nes_read_indexed(nesdev, NES_IDX_MAC_MDIO_CONTROL); - if (counter++ > 1000) { - nes_debug(NES_DBG_PHY, "AMCC PHY- breaking from heartbeat check \n"); - break; - } - mdelay(100); - nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x3, 0xd7ee); - temp_phy_data2 = (u16)nes_read_indexed(nesdev, NES_IDX_MAC_MDIO_CONTROL); - } while ((temp_phy_data2 == temp_phy_data)); - - /* - * wait for tracking to start to know - * f/w is good to go - */ - counter = 0; - do { - nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x3, 0xd7fd); - temp_phy_data = (u16)nes_read_indexed(nesdev, NES_IDX_MAC_MDIO_CONTROL); - if (counter++ > 1000) { - nes_debug(NES_DBG_PHY, "AMCC PHY- breaking from status check \n"); - break; - } - mdelay(1000); - /* - * nes_debug(NES_DBG_PHY, "AMCC PHY- phy_status not ready yet = 0x%02X\n", - * temp_phy_data); - */ - } while (((temp_phy_data & 0xff) != 0x50) && ((temp_phy_data & 0xff) != 0x70)); - - /* set LOS Control invert RXLOSB_I_PADINV */ - nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x1, 0xd003, 0x0000); - /* set LOS Control to mask of RXLOSB_I */ - nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x1, 0xc314, 0x0042); - /* set LED1 to input mode (LED1 and LED2 share same LED) */ - nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x1, 0xd006, 0x0007); - /* set LED2 to RX link_status and activity */ - nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x1, 0xd007, 0x000A); - /* set LED3 to RX link_status */ - nes_write_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 0x1, 0xd008, 0x0009); - - /* - * reset the res-calibration on t2 - * serdes; ensures it is stable after - * the amcc phy is stable - */ - - sds_common_control0 = nes_read_indexed(nesdev, NES_IDX_ETH_SERDES_COMMON_CONTROL0); - sds_common_control0 |= 0x1; - nes_write_indexed(nesdev, NES_IDX_ETH_SERDES_COMMON_CONTROL0, sds_common_control0); - - /* release the res-calibration reset */ - sds_common_control0 &= 0xfffffffe; - nes_write_indexed(nesdev, NES_IDX_ETH_SERDES_COMMON_CONTROL0, sds_common_control0); - - i = 0; - while (((nes_read32(nesdev->regs + NES_SOFTWARE_RESET) & 0x00000040) != 0x00000040) - && (i++ < 5000)) { - /* mdelay(1); */ - } - - /* - * wait for link train done before moving on, - * or will get an interupt storm - */ - counter = 0; - do { - temp_phy_data = nes_read_indexed(nesdev, NES_IDX_PHY_PCS_CONTROL_STATUS0 + - (0x200 * (nesdev->mac_index & 1))); - if (counter++ > 1000) { - nes_debug(NES_DBG_PHY, "AMCC PHY- breaking from link train wait \n"); - break; - } - mdelay(1); - } while (((temp_phy_data & 0x0f1f0000) != 0x0f0f0000)); - } - } } return 0; } @@ -1495,25 +1375,6 @@ static void nes_rq_wqes_timeout(unsigned long parm) } -static int nes_lro_get_skb_hdr(struct sk_buff *skb, void **iphdr, - void **tcph, u64 *hdr_flags, void *priv) -{ - unsigned int ip_len; - struct iphdr *iph; - skb_reset_network_header(skb); - iph = ip_hdr(skb); - if (iph->protocol != IPPROTO_TCP) - return -1; - ip_len = ip_hdrlen(skb); - skb_set_transport_header(skb, ip_len); - *tcph = tcp_hdr(skb); - - *hdr_flags = LRO_IPV4 | LRO_TCP; - *iphdr = iph; - return 0; -} - - /** * nes_init_nic_qp */ @@ -1659,10 +1520,10 @@ int nes_init_nic_qp(struct nes_device *nesdev, struct net_device *netdev) } u64temp = (u64)nesvnic->nic.sq_pbase; - nic_context->context_words[NES_NIC_CTX_SQ_LOW_IDX] = cpu_to_le32((u32)u64temp); + nic_context->context_words[NES_NIC_CTX_SQ_LOW_IDX] = cpu_to_le32((u32)u64temp); nic_context->context_words[NES_NIC_CTX_SQ_HIGH_IDX] = cpu_to_le32((u32)(u64temp >> 32)); u64temp = (u64)nesvnic->nic.rq_pbase; - nic_context->context_words[NES_NIC_CTX_RQ_LOW_IDX] = cpu_to_le32((u32)u64temp); + nic_context->context_words[NES_NIC_CTX_RQ_LOW_IDX] = cpu_to_le32((u32)u64temp); nic_context->context_words[NES_NIC_CTX_RQ_HIGH_IDX] = cpu_to_le32((u32)(u64temp >> 32)); cqp_wqe->wqe_words[NES_CQP_WQE_OPCODE_IDX] = cpu_to_le32(NES_CQP_CREATE_QP | @@ -1714,7 +1575,7 @@ int nes_init_nic_qp(struct nes_device *nesdev, struct net_device *netdev) nic_rqe = &nesvnic->nic.rq_vbase[counter]; nic_rqe->wqe_words[NES_NIC_RQ_WQE_LENGTH_1_0_IDX] = cpu_to_le32(nesvnic->max_frame_size); nic_rqe->wqe_words[NES_NIC_RQ_WQE_LENGTH_3_2_IDX] = 0; - nic_rqe->wqe_words[NES_NIC_RQ_WQE_FRAG0_LOW_IDX] = cpu_to_le32((u32)pmem); + nic_rqe->wqe_words[NES_NIC_RQ_WQE_FRAG0_LOW_IDX] = cpu_to_le32((u32)pmem); nic_rqe->wqe_words[NES_NIC_RQ_WQE_FRAG0_HIGH_IDX] = cpu_to_le32((u32)((u64)pmem >> 32)); nesvnic->nic.rx_skb[counter] = skb; } @@ -1731,21 +1592,15 @@ int nes_init_nic_qp(struct nes_device *nesdev, struct net_device *netdev) nesvnic->rq_wqes_timer.function = nes_rq_wqes_timeout; nesvnic->rq_wqes_timer.data = (unsigned long)nesvnic; nes_debug(NES_DBG_INIT, "NAPI support Enabled\n"); + if (nesdev->nesadapter->et_use_adaptive_rx_coalesce) { nes_nic_init_timer(nesdev); if (netdev->mtu > 1500) jumbomode = 1; - nes_nic_init_timer_defaults(nesdev, jumbomode); - } - nesvnic->lro_mgr.max_aggr = NES_LRO_MAX_AGGR; - nesvnic->lro_mgr.max_desc = NES_MAX_LRO_DESCRIPTORS; - nesvnic->lro_mgr.lro_arr = nesvnic->lro_desc; - nesvnic->lro_mgr.get_skb_header = nes_lro_get_skb_hdr; - nesvnic->lro_mgr.features = LRO_F_NAPI | LRO_F_EXTRACT_VLAN_ID; - nesvnic->lro_mgr.dev = netdev; - nesvnic->lro_mgr.ip_summed = CHECKSUM_UNNECESSARY; - nesvnic->lro_mgr.ip_summed_aggr = CHECKSUM_UNNECESSARY; + nes_nic_init_timer_defaults(nesdev, jumbomode); + } + return 0; } @@ -1765,8 +1620,8 @@ void nes_destroy_nic_qp(struct nes_vnic *nesvnic) /* Free remaining NIC receive buffers */ while (nesvnic->nic.rq_head != nesvnic->nic.rq_tail) { - nic_rqe = &nesvnic->nic.rq_vbase[nesvnic->nic.rq_tail]; - wqe_frag = (u64)le32_to_cpu(nic_rqe->wqe_words[NES_NIC_RQ_WQE_FRAG0_LOW_IDX]); + nic_rqe = &nesvnic->nic.rq_vbase[nesvnic->nic.rq_tail]; + wqe_frag = (u64)le32_to_cpu(nic_rqe->wqe_words[NES_NIC_RQ_WQE_FRAG0_LOW_IDX]); wqe_frag |= ((u64)le32_to_cpu(nic_rqe->wqe_words[NES_NIC_RQ_WQE_FRAG0_HIGH_IDX])) << 32; pci_unmap_single(nesdev->pcidev, (dma_addr_t)wqe_frag, nesvnic->max_frame_size, PCI_DMA_FROMDEVICE); @@ -1849,17 +1704,17 @@ int nes_napi_isr(struct nes_device *nesdev) /* iff NIC, process here, else wait for DPC */ if ((int_stat) && ((int_stat & 0x0000ff00) == int_stat)) { nesdev->napi_isr_ran = 0; - nes_write32(nesdev->regs + NES_INT_STAT, - (int_stat & - ~(NES_INT_INTF | NES_INT_TIMER | NES_INT_MAC0 | NES_INT_MAC1 | NES_INT_MAC2 | NES_INT_MAC3))); + nes_write32(nesdev->regs+NES_INT_STAT, + (int_stat & + ~(NES_INT_INTF|NES_INT_TIMER|NES_INT_MAC0|NES_INT_MAC1|NES_INT_MAC2|NES_INT_MAC3))); /* Process the CEQs */ nes_process_ceq(nesdev, &nesdev->nesadapter->ceq[nesdev->nic_ceq_index]); if (unlikely((((nesadapter->et_rx_coalesce_usecs_irq) && - (!nesadapter->et_use_adaptive_rx_coalesce)) || - ((nesadapter->et_use_adaptive_rx_coalesce) && - (nesdev->deepcq_count > nesadapter->et_pkt_rate_low))))) { + (!nesadapter->et_use_adaptive_rx_coalesce)) || + ((nesadapter->et_use_adaptive_rx_coalesce) && + (nesdev->deepcq_count > nesadapter->et_pkt_rate_low)))) ) { if ((nesdev->int_req & NES_INT_TIMER) == 0) { /* Enable Periodic timer interrupts */ nesdev->int_req |= NES_INT_TIMER; @@ -1937,12 +1792,12 @@ void nes_dpc(unsigned long param) } if (int_stat) { - if (int_stat & ~(NES_INT_INTF | NES_INT_TIMER | NES_INT_MAC0| - NES_INT_MAC1|NES_INT_MAC2 | NES_INT_MAC3)) { + if (int_stat & ~(NES_INT_INTF|NES_INT_TIMER|NES_INT_MAC0| + NES_INT_MAC1|NES_INT_MAC2|NES_INT_MAC3)) { /* Ack the interrupts */ nes_write32(nesdev->regs+NES_INT_STAT, - (int_stat & ~(NES_INT_INTF | NES_INT_TIMER | NES_INT_MAC0| - NES_INT_MAC1 | NES_INT_MAC2 | NES_INT_MAC3))); + (int_stat & ~(NES_INT_INTF|NES_INT_TIMER|NES_INT_MAC0| + NES_INT_MAC1|NES_INT_MAC2|NES_INT_MAC3))); } temp_int_stat = int_stat; @@ -2007,8 +1862,8 @@ void nes_dpc(unsigned long param) } } /* Don't use the interface interrupt bit stay in loop */ - int_stat &= ~NES_INT_INTF | NES_INT_TIMER | NES_INT_MAC0 | - NES_INT_MAC1 | NES_INT_MAC2 | NES_INT_MAC3; + int_stat &= ~NES_INT_INTF|NES_INT_TIMER|NES_INT_MAC0| + NES_INT_MAC1|NES_INT_MAC2|NES_INT_MAC3; } while ((int_stat != 0) && (loop_counter++ < MAX_DPC_ITERATIONS)); if (timer_ints == 1) { @@ -2019,9 +1874,9 @@ void nes_dpc(unsigned long param) nesdev->timer_only_int_count = 0; nesdev->int_req &= ~NES_INT_TIMER; nes_write32(nesdev->regs + NES_INTF_INT_MASK, ~(nesdev->intf_int_req)); - nes_write32(nesdev->regs + NES_INT_MASK, ~nesdev->int_req); + nes_write32(nesdev->regs+NES_INT_MASK, ~nesdev->int_req); } else { - nes_write32(nesdev->regs+NES_INT_MASK, 0x0000ffff | (~nesdev->int_req)); + nes_write32(nesdev->regs+NES_INT_MASK, 0x0000ffff|(~nesdev->int_req)); } } else { if (unlikely(nesadapter->et_use_adaptive_rx_coalesce)) @@ -2029,7 +1884,7 @@ void nes_dpc(unsigned long param) nes_nic_init_timer(nesdev); } nesdev->timer_only_int_count = 0; - nes_write32(nesdev->regs+NES_INT_MASK, 0x0000ffff | (~nesdev->int_req)); + nes_write32(nesdev->regs+NES_INT_MASK, 0x0000ffff|(~nesdev->int_req)); } } else { nesdev->timer_only_int_count = 0; @@ -2078,7 +1933,7 @@ static void nes_process_ceq(struct nes_device *nesdev, struct nes_hw_ceq *ceq) do { if (le32_to_cpu(ceq->ceq_vbase[head].ceqe_words[NES_CEQE_CQ_CTX_HIGH_IDX]) & NES_CEQE_VALID) { - u64temp = (((u64)(le32_to_cpu(ceq->ceq_vbase[head].ceqe_words[NES_CEQE_CQ_CTX_HIGH_IDX]))) << 32) | + u64temp = (((u64)(le32_to_cpu(ceq->ceq_vbase[head].ceqe_words[NES_CEQE_CQ_CTX_HIGH_IDX])))<<32) | ((u64)(le32_to_cpu(ceq->ceq_vbase[head].ceqe_words[NES_CEQE_CQ_CTX_LOW_IDX]))); u64temp <<= 1; cq = *((struct nes_hw_cq **)&u64temp); @@ -2106,7 +1961,7 @@ static void nes_process_ceq(struct nes_device *nesdev, struct nes_hw_ceq *ceq) */ static void nes_process_aeq(struct nes_device *nesdev, struct nes_hw_aeq *aeq) { - /* u64 u64temp; */ +// u64 u64temp; u32 head; u32 aeq_size; u32 aeqe_misc; @@ -2125,10 +1980,8 @@ static void nes_process_aeq(struct nes_device *nesdev, struct nes_hw_aeq *aeq) if (aeqe_misc & (NES_AEQE_QP|NES_AEQE_CQ)) { if (aeqe_cq_id >= NES_FIRST_QPN) { /* dealing with an accelerated QP related AE */ - /* - * u64temp = (((u64)(le32_to_cpu(aeqe->aeqe_words[NES_AEQE_COMP_CTXT_HIGH_IDX]))) << 32) | - * ((u64)(le32_to_cpu(aeqe->aeqe_words[NES_AEQE_COMP_CTXT_LOW_IDX]))); - */ +// u64temp = (((u64)(le32_to_cpu(aeqe->aeqe_words[NES_AEQE_COMP_CTXT_HIGH_IDX])))<<32) | +// ((u64)(le32_to_cpu(aeqe->aeqe_words[NES_AEQE_COMP_CTXT_LOW_IDX]))); nes_process_iwarp_aeqe(nesdev, (struct nes_hw_aeqe *)aeqe); } else { /* TODO: dealing with a CQP related AE */ @@ -2228,8 +2081,6 @@ static void nes_process_mac_intr(struct nes_device *nesdev, u32 mac_number) u32 u32temp; u16 phy_data; u16 temp_phy_data; - u32 pcs_val = 0x0f0f0000; - u32 pcs_mask = 0x0f1f0000; spin_lock_irqsave(&nesadapter->phy_lock, flags); if (nesadapter->mac_sw_state[mac_number] != NES_MAC_SW_IDLE) { @@ -2293,30 +2144,13 @@ static void nes_process_mac_intr(struct nes_device *nesdev, u32 mac_number) nes_debug(NES_DBG_PHY, "Eth SERDES Common Status: 0=0x%08X, 1=0x%08X\n", nes_read_indexed(nesdev, NES_IDX_ETH_SERDES_COMMON_STATUS0), nes_read_indexed(nesdev, NES_IDX_ETH_SERDES_COMMON_STATUS0+0x200)); - - if (nesadapter->phy_type[mac_index] == NES_PHY_TYPE_PUMA_1G) { - switch (mac_index) { - case 1: - case 3: - pcs_control_status = nes_read_indexed(nesdev, - NES_IDX_PHY_PCS_CONTROL_STATUS0 + 0x200); - break; - default: - pcs_control_status = nes_read_indexed(nesdev, - NES_IDX_PHY_PCS_CONTROL_STATUS0); - break; - } - } else { - pcs_control_status = nes_read_indexed(nesdev, - NES_IDX_PHY_PCS_CONTROL_STATUS0 + ((mac_index & 1) * 0x200)); - pcs_control_status = nes_read_indexed(nesdev, - NES_IDX_PHY_PCS_CONTROL_STATUS0 + ((mac_index & 1) * 0x200)); - } - + pcs_control_status = nes_read_indexed(nesdev, + NES_IDX_PHY_PCS_CONTROL_STATUS0 + ((mac_index&1)*0x200)); + pcs_control_status = nes_read_indexed(nesdev, + NES_IDX_PHY_PCS_CONTROL_STATUS0 + ((mac_index&1)*0x200)); nes_debug(NES_DBG_PHY, "PCS PHY Control/Status%u: 0x%08X\n", mac_index, pcs_control_status); - if ((nesadapter->OneG_Mode) && - (nesadapter->phy_type[mac_index] != NES_PHY_TYPE_PUMA_1G)) { + if (nesadapter->OneG_Mode) { u32temp = 0x01010000; if (nesadapter->port_count > 2) { u32temp |= 0x02020000; @@ -2325,59 +2159,24 @@ static void nes_process_mac_intr(struct nes_device *nesdev, u32 mac_number) phy_data = 0; nes_debug(NES_DBG_PHY, "PCS says the link is down\n"); } - } else { - switch (nesadapter->phy_type[mac_index]) { - case NES_PHY_TYPE_IRIS: - nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 1, 1); - temp_phy_data = (u16)nes_read_indexed(nesdev, NES_IDX_MAC_MDIO_CONTROL); - u32temp = 20; - do { - nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 1, 1); - phy_data = (u16)nes_read_indexed(nesdev, NES_IDX_MAC_MDIO_CONTROL); - if ((phy_data == temp_phy_data) || (!(--u32temp))) - break; - temp_phy_data = phy_data; - } while (1); - nes_debug(NES_DBG_PHY, "%s: Phy data = 0x%04X, link was %s.\n", - __func__, phy_data, nesadapter->mac_link_down[mac_index] ? "DOWN" : "UP"); - break; - - case NES_PHY_TYPE_ARGUS: - /* clear the alarms */ - nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 4, 0x0008); - nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 4, 0xc001); - nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 4, 0xc002); - nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 4, 0xc005); - nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 4, 0xc006); - nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 1, 0x9003); - nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 1, 0x9004); - nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 1, 0x9005); - /* check link status */ - nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 1, 1); - temp_phy_data = (u16)nes_read_indexed(nesdev, NES_IDX_MAC_MDIO_CONTROL); - u32temp = 100; - do { - nes_read_10G_phy_reg(nesdev, nesadapter->phy_index[mac_index], 1, 1); - - phy_data = (u16)nes_read_indexed(nesdev, NES_IDX_MAC_MDIO_CONTROL); - if ((phy_data == temp_phy_data) || (!(--u32temp))) - break; - temp_phy_data = phy_data; - } while (1); - nes_debug(NES_DBG_PHY, "%s: Phy data = 0x%04X, link was %s.\n", - __func__, phy_data, nesadapter->mac_link_down ? "DOWN" : "UP"); - break; + } else if (nesadapter->phy_type[mac_index] == NES_PHY_TYPE_IRIS) { + nes_read_10G_phy_reg(nesdev, 1, nesadapter->phy_index[mac_index]); + temp_phy_data = (u16)nes_read_indexed(nesdev, + NES_IDX_MAC_MDIO_CONTROL); + u32temp = 20; + do { + nes_read_10G_phy_reg(nesdev, 1, nesadapter->phy_index[mac_index]); + phy_data = (u16)nes_read_indexed(nesdev, + NES_IDX_MAC_MDIO_CONTROL); + if ((phy_data == temp_phy_data) || (!(--u32temp))) + break; + temp_phy_data = phy_data; + } while (1); + nes_debug(NES_DBG_PHY, "%s: Phy data = 0x%04X, link was %s.\n", + __func__, phy_data, nesadapter->mac_link_down ? "DOWN" : "UP"); - case NES_PHY_TYPE_PUMA_1G: - if (mac_index < 2) - pcs_val = pcs_mask = 0x01010000; - else - pcs_val = pcs_mask = 0x02020000; - /* fall through */ - default: - phy_data = (pcs_val == (pcs_control_status & pcs_mask)) ? 0x4 : 0x0; - break; - } + } else { + phy_data = (0x0f0f0000 == (pcs_control_status & 0x0f1f0000)) ? 4 : 0; } if (phy_data & 0x0004) { @@ -2386,8 +2185,8 @@ static void nes_process_mac_intr(struct nes_device *nesdev, u32 mac_number) nes_debug(NES_DBG_PHY, "The Link is UP!!. linkup was %d\n", nesvnic->linkup); if (nesvnic->linkup == 0) { - printk(PFX "The Link is now up for port %s, netdev %p.\n", - nesvnic->netdev->name, nesvnic->netdev); + printk(PFX "The Link is now up for port %u, netdev %p.\n", + mac_index, nesvnic->netdev); if (netif_queue_stopped(nesvnic->netdev)) netif_start_queue(nesvnic->netdev); nesvnic->linkup = 1; @@ -2400,8 +2199,8 @@ static void nes_process_mac_intr(struct nes_device *nesdev, u32 mac_number) nes_debug(NES_DBG_PHY, "The Link is Down!!. linkup was %d\n", nesvnic->linkup); if (nesvnic->linkup == 1) { - printk(PFX "The Link is now down for port %s, netdev %p.\n", - nesvnic->netdev->name, nesvnic->netdev); + printk(PFX "The Link is now down for port %u, netdev %p.\n", + mac_index, nesvnic->netdev); if (!(netif_queue_stopped(nesvnic->netdev))) netif_stop_queue(nesvnic->netdev); nesvnic->linkup = 0; @@ -2455,13 +2254,10 @@ void nes_nic_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *cq) u16 pkt_type; u16 rqes_processed = 0; u8 sq_cqes = 0; - u8 nes_use_lro = 0; head = cq->cq_head; cq_size = cq->cq_size; cq->cqes_pending = 1; - if (nesvnic->netdev->features & NETIF_F_LRO) - nes_use_lro = 1; do { if (le32_to_cpu(cq->cq_vbase[head].cqe_words[NES_NIC_CQE_MISC_IDX]) & NES_NIC_CQE_VALID) { @@ -2476,10 +2272,8 @@ void nes_nic_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *cq) /* bump past the vlan tag */ wqe_fragment_length++; if (le16_to_cpu(wqe_fragment_length[wqe_fragment_index]) != 0) { - u64temp = (u64) le32_to_cpu(nic_sqe->wqe_words[NES_NIC_SQ_WQE_FRAG0_LOW_IDX + - wqe_fragment_index * 2]); - u64temp += ((u64)le32_to_cpu(nic_sqe->wqe_words[NES_NIC_SQ_WQE_FRAG0_HIGH_IDX + - wqe_fragment_index * 2])) << 32; + u64temp = (u64) le32_to_cpu(nic_sqe->wqe_words[NES_NIC_SQ_WQE_FRAG0_LOW_IDX+wqe_fragment_index*2]); + u64temp += ((u64)le32_to_cpu(nic_sqe->wqe_words[NES_NIC_SQ_WQE_FRAG0_HIGH_IDX+wqe_fragment_index*2]))<<32; bus_address = (dma_addr_t)u64temp; if (test_and_clear_bit(nesnic->sq_tail, nesnic->first_frag_overflow)) { pci_unmap_single(nesdev->pcidev, @@ -2489,10 +2283,8 @@ void nes_nic_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *cq) } for (; wqe_fragment_index < 5; wqe_fragment_index++) { if (wqe_fragment_length[wqe_fragment_index]) { - u64temp = le32_to_cpu(nic_sqe->wqe_words[NES_NIC_SQ_WQE_FRAG0_LOW_IDX + - wqe_fragment_index * 2]); - u64temp += ((u64)le32_to_cpu(nic_sqe->wqe_words[NES_NIC_SQ_WQE_FRAG0_HIGH_IDX - + wqe_fragment_index * 2])) <<32; + u64temp = le32_to_cpu(nic_sqe->wqe_words[NES_NIC_SQ_WQE_FRAG0_LOW_IDX+wqe_fragment_index*2]); + u64temp += ((u64)le32_to_cpu(nic_sqe->wqe_words[NES_NIC_SQ_WQE_FRAG0_HIGH_IDX+wqe_fragment_index*2]))<<32; bus_address = (dma_addr_t)u64temp; pci_unmap_page(nesdev->pcidev, bus_address, @@ -2539,7 +2331,7 @@ void nes_nic_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *cq) if (atomic_read(&nesvnic->rx_skbs_needed) > (nesvnic->nic.rq_size>>1)) { nes_write32(nesdev->regs+NES_CQE_ALLOC, cq->cq_number | (cqe_count << 16)); - /* nesadapter->tune_timer.cq_count += cqe_count; */ +// nesadapter->tune_timer.cq_count += cqe_count; nesdev->currcq_count += cqe_count; cqe_count = 0; nes_replenish_nic_rq(nesvnic); @@ -2587,16 +2379,9 @@ void nes_nic_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *cq) >> 16); nes_debug(NES_DBG_CQ, "%s: Reporting stripped VLAN packet. Tag = 0x%04X\n", nesvnic->netdev->name, vlan_tag); - if (nes_use_lro) - lro_vlan_hwaccel_receive_skb(&nesvnic->lro_mgr, rx_skb, - nesvnic->vlan_grp, vlan_tag, NULL); - else - nes_vlan_rx(rx_skb, nesvnic->vlan_grp, vlan_tag); + nes_vlan_rx(rx_skb, nesvnic->vlan_grp, vlan_tag); } else { - if (nes_use_lro) - lro_receive_skb(&nesvnic->lro_mgr, rx_skb, NULL); - else - nes_netif_rx(rx_skb); + nes_netif_rx(rx_skb); } } @@ -2614,7 +2399,7 @@ void nes_nic_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *cq) /* Replenish Nic CQ */ nes_write32(nesdev->regs+NES_CQE_ALLOC, cq->cq_number | (cqe_count << 16)); - /* nesdev->nesadapter->tune_timer.cq_count += cqe_count; */ +// nesdev->nesadapter->tune_timer.cq_count += cqe_count; nesdev->currcq_count += cqe_count; cqe_count = 0; } @@ -2628,27 +2413,26 @@ void nes_nic_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *cq) } while (1); - if (nes_use_lro) - lro_flush_all(&nesvnic->lro_mgr); if (sq_cqes) { barrier(); /* restart the queue if it had been stopped */ if (netif_queue_stopped(nesvnic->netdev)) netif_wake_queue(nesvnic->netdev); } + cq->cq_head = head; /* nes_debug(NES_DBG_CQ, "CQ%u Processed = %u cqes, new head = %u.\n", cq->cq_number, cqe_count, cq->cq_head); */ cq->cqe_allocs_pending = cqe_count; if (unlikely(nesadapter->et_use_adaptive_rx_coalesce)) { - /* nesdev->nesadapter->tune_timer.cq_count += cqe_count; */ +// nesdev->nesadapter->tune_timer.cq_count += cqe_count; nesdev->currcq_count += cqe_count; nes_nic_tune_timer(nesdev); } if (atomic_read(&nesvnic->rx_skbs_needed)) nes_replenish_nic_rq(nesvnic); -} + } /** @@ -2677,7 +2461,7 @@ static void nes_cqp_ce_handler(struct nes_device *nesdev, struct nes_hw_cq *cq) if (le32_to_cpu(cq->cq_vbase[head].cqe_words[NES_CQE_OPCODE_IDX]) & NES_CQE_VALID) { u64temp = (((u64)(le32_to_cpu(cq->cq_vbase[head]. - cqe_words[NES_CQE_COMP_COMP_CTX_HIGH_IDX]))) << 32) | + cqe_words[NES_CQE_COMP_COMP_CTX_HIGH_IDX])))<<32) | ((u64)(le32_to_cpu(cq->cq_vbase[head]. cqe_words[NES_CQE_COMP_COMP_CTX_LOW_IDX]))); cqp = *((struct nes_hw_cqp **)&u64temp); @@ -2694,7 +2478,7 @@ static void nes_cqp_ce_handler(struct nes_device *nesdev, struct nes_hw_cq *cq) } u64temp = (((u64)(le32_to_cpu(nesdev->cqp.sq_vbase[cqp->sq_tail]. - wqe_words[NES_CQP_WQE_COMP_SCRATCH_HIGH_IDX]))) << 32) | + wqe_words[NES_CQP_WQE_COMP_SCRATCH_HIGH_IDX])))<<32) | ((u64)(le32_to_cpu(nesdev->cqp.sq_vbase[cqp->sq_tail]. wqe_words[NES_CQP_WQE_COMP_SCRATCH_LOW_IDX]))); cqp_request = *((struct nes_cqp_request **)&u64temp); @@ -2731,7 +2515,7 @@ static void nes_cqp_ce_handler(struct nes_device *nesdev, struct nes_hw_cq *cq) } else { nes_debug(NES_DBG_CQP, "CQP request %p (opcode 0x%02X) freed.\n", cqp_request, - le32_to_cpu(cqp_request->cqp_wqe.wqe_words[NES_CQP_WQE_OPCODE_IDX]) & 0x3f); + le32_to_cpu(cqp_request->cqp_wqe.wqe_words[NES_CQP_WQE_OPCODE_IDX])&0x3f); if (cqp_request->dynamic) { kfree(cqp_request); } else { @@ -2745,7 +2529,7 @@ static void nes_cqp_ce_handler(struct nes_device *nesdev, struct nes_hw_cq *cq) } cq->cq_vbase[head].cqe_words[NES_CQE_OPCODE_IDX] = 0; - nes_write32(nesdev->regs + NES_CQE_ALLOC, cq->cq_number | (1 << 16)); + nes_write32(nesdev->regs+NES_CQE_ALLOC, cq->cq_number | (1 << 16)); if (++cqp->sq_tail >= cqp->sq_size) cqp->sq_tail = 0; @@ -2814,13 +2598,13 @@ static void nes_process_iwarp_aeqe(struct nes_device *nesdev, nes_debug(NES_DBG_AEQ, "\n"); aeq_info = le32_to_cpu(aeqe->aeqe_words[NES_AEQE_MISC_IDX]); if ((NES_AEQE_INBOUND_RDMA&aeq_info) || (!(NES_AEQE_QP&aeq_info))) { - context = le32_to_cpu(aeqe->aeqe_words[NES_AEQE_COMP_CTXT_LOW_IDX]); + context = le32_to_cpu(aeqe->aeqe_words[NES_AEQE_COMP_CTXT_LOW_IDX]); context += ((u64)le32_to_cpu(aeqe->aeqe_words[NES_AEQE_COMP_CTXT_HIGH_IDX])) << 32; } else { aeqe_context = le32_to_cpu(aeqe->aeqe_words[NES_AEQE_COMP_CTXT_LOW_IDX]); aeqe_context += ((u64)le32_to_cpu(aeqe->aeqe_words[NES_AEQE_COMP_CTXT_HIGH_IDX])) << 32; context = (unsigned long)nesadapter->qp_table[le32_to_cpu( - aeqe->aeqe_words[NES_AEQE_COMP_QP_CQ_ID_IDX]) - NES_FIRST_QPN]; + aeqe->aeqe_words[NES_AEQE_COMP_QP_CQ_ID_IDX])-NES_FIRST_QPN]; BUG_ON(!context); } @@ -2833,6 +2617,7 @@ static void nes_process_iwarp_aeqe(struct nes_device *nesdev, le32_to_cpu(aeqe->aeqe_words[NES_AEQE_COMP_QP_CQ_ID_IDX]), aeqe, nes_tcp_state_str[tcp_state], nes_iwarp_state_str[iwarp_state]); + switch (async_event_id) { case NES_AEQE_AEID_LLP_FIN_RECEIVED: nesqp = *((struct nes_qp **)&context); @@ -3236,7 +3021,7 @@ void nes_manage_arp_cache(struct net_device *netdev, unsigned char *mac_addr, cqp_wqe->wqe_words[NES_CQP_WQE_OPCODE_IDX] |= cpu_to_le32(NES_CQP_ARP_VALID); cqp_wqe->wqe_words[NES_CQP_ARP_WQE_MAC_ADDR_LOW_IDX] = cpu_to_le32( (((u32)mac_addr[2]) << 24) | (((u32)mac_addr[3]) << 16) | - (((u32)mac_addr[4]) << 8) | (u32)mac_addr[5]); + (((u32)mac_addr[4]) << 8) | (u32)mac_addr[5]); cqp_wqe->wqe_words[NES_CQP_ARP_WQE_MAC_HIGH_IDX] = cpu_to_le32( (((u32)mac_addr[0]) << 16) | (u32)mac_addr[1]); } else { diff --git a/trunk/drivers/infiniband/hw/nes/nes_hw.h b/trunk/drivers/infiniband/hw/nes/nes_hw.h index 745bf94f3f07..8f36e231bdf5 100644 --- a/trunk/drivers/infiniband/hw/nes/nes_hw.h +++ b/trunk/drivers/infiniband/hw/nes/nes_hw.h @@ -33,12 +33,8 @@ #ifndef __NES_HW_H #define __NES_HW_H -#include - -#define NES_PHY_TYPE_1G 2 -#define NES_PHY_TYPE_IRIS 3 -#define NES_PHY_TYPE_ARGUS 4 -#define NES_PHY_TYPE_PUMA_1G 5 +#define NES_PHY_TYPE_1G 2 +#define NES_PHY_TYPE_IRIS 3 #define NES_PHY_TYPE_PUMA_10G 6 #define NES_MULTICAST_PF_MAX 8 @@ -969,7 +965,7 @@ struct nes_arp_entry { #define NES_NIC_CQ_DOWNWARD_TREND 16 struct nes_hw_tune_timer { - /* u16 cq_count; */ + //u16 cq_count; u16 threshold_low; u16 threshold_target; u16 threshold_high; @@ -986,10 +982,8 @@ struct nes_hw_tune_timer { #define NES_TIMER_INT_LIMIT 2 #define NES_TIMER_INT_LIMIT_DYNAMIC 10 #define NES_TIMER_ENABLE_LIMIT 4 -#define NES_MAX_LINK_INTERRUPTS 128 -#define NES_MAX_LINK_CHECK 200 -#define NES_MAX_LRO_DESCRIPTORS 32 -#define NES_LRO_MAX_AGGR 64 +#define NES_MAX_LINK_INTERRUPTS 128 +#define NES_MAX_LINK_CHECK 200 struct nes_adapter { u64 fw_ver; @@ -1189,9 +1183,6 @@ struct nes_vnic { u8 of_device_registered; u8 rdma_enabled; u8 rx_checksum_disabled; - u32 lro_max_aggr; - struct net_lro_mgr lro_mgr; - struct net_lro_desc lro_desc[NES_MAX_LRO_DESCRIPTORS]; }; struct nes_ib_device { diff --git a/trunk/drivers/infiniband/hw/nes/nes_nic.c b/trunk/drivers/infiniband/hw/nes/nes_nic.c index 1b0938c87774..e5366b013c1a 100644 --- a/trunk/drivers/infiniband/hw/nes/nes_nic.c +++ b/trunk/drivers/infiniband/hw/nes/nes_nic.c @@ -185,13 +185,12 @@ static int nes_netdev_open(struct net_device *netdev) nic_active |= nic_active_bit; nes_write_indexed(nesdev, NES_IDX_NIC_BROADCAST_ON, nic_active); - macaddr_high = ((u16)netdev->dev_addr[0]) << 8; + macaddr_high = ((u16)netdev->dev_addr[0]) << 8; macaddr_high += (u16)netdev->dev_addr[1]; - - macaddr_low = ((u32)netdev->dev_addr[2]) << 24; - macaddr_low += ((u32)netdev->dev_addr[3]) << 16; - macaddr_low += ((u32)netdev->dev_addr[4]) << 8; - macaddr_low += (u32)netdev->dev_addr[5]; + macaddr_low = ((u32)netdev->dev_addr[2]) << 24; + macaddr_low += ((u32)netdev->dev_addr[3]) << 16; + macaddr_low += ((u32)netdev->dev_addr[4]) << 8; + macaddr_low += (u32)netdev->dev_addr[5]; /* Program the various MAC regs */ for (i = 0; i < NES_MAX_PORT_COUNT; i++) { @@ -452,7 +451,7 @@ static int nes_netdev_start_xmit(struct sk_buff *skb, struct net_device *netdev) __le16 *wqe_fragment_length; u32 nr_frags; u32 original_first_length; - /* u64 *wqe_fragment_address; */ +// u64 *wqe_fragment_address; /* first fragment (0) is used by copy buffer */ u16 wqe_fragment_index=1; u16 hoffset; @@ -462,12 +461,11 @@ static int nes_netdev_start_xmit(struct sk_buff *skb, struct net_device *netdev) u32 old_head; u32 wqe_misc; - /* - * nes_debug(NES_DBG_NIC_TX, "%s Request to tx NIC packet length %u, headlen %u," - * " (%u frags), tso_size=%u\n", - * netdev->name, skb->len, skb_headlen(skb), - * skb_shinfo(skb)->nr_frags, skb_is_gso(skb)); - */ + /* nes_debug(NES_DBG_NIC_TX, "%s Request to tx NIC packet length %u, headlen %u," + " (%u frags), tso_size=%u\n", + netdev->name, skb->len, skb_headlen(skb), + skb_shinfo(skb)->nr_frags, skb_is_gso(skb)); + */ if (!netif_carrier_ok(netdev)) return NETDEV_TX_OK; @@ -797,12 +795,12 @@ static int nes_netdev_set_mac_address(struct net_device *netdev, void *p) memcpy(netdev->dev_addr, mac_addr->sa_data, netdev->addr_len); printk(PFX "%s: Address length = %d, Address = %s\n", __func__, netdev->addr_len, print_mac(mac, mac_addr->sa_data)); - macaddr_high = ((u16)netdev->dev_addr[0]) << 8; + macaddr_high = ((u16)netdev->dev_addr[0]) << 8; macaddr_high += (u16)netdev->dev_addr[1]; - macaddr_low = ((u32)netdev->dev_addr[2]) << 24; - macaddr_low += ((u32)netdev->dev_addr[3]) << 16; - macaddr_low += ((u32)netdev->dev_addr[4]) << 8; - macaddr_low += (u32)netdev->dev_addr[5]; + macaddr_low = ((u32)netdev->dev_addr[2]) << 24; + macaddr_low += ((u32)netdev->dev_addr[3]) << 16; + macaddr_low += ((u32)netdev->dev_addr[4]) << 8; + macaddr_low += (u32)netdev->dev_addr[5]; for (i = 0; i < NES_MAX_PORT_COUNT; i++) { if (nesvnic->qp_nic_index[i] == 0xf) { @@ -883,12 +881,12 @@ static void nes_netdev_set_multicast_list(struct net_device *netdev) print_mac(mac, multicast_addr->dmi_addr), perfect_filter_register_address+(mc_index * 8), mc_nic_index); - macaddr_high = ((u16)multicast_addr->dmi_addr[0]) << 8; + macaddr_high = ((u16)multicast_addr->dmi_addr[0]) << 8; macaddr_high += (u16)multicast_addr->dmi_addr[1]; - macaddr_low = ((u32)multicast_addr->dmi_addr[2]) << 24; - macaddr_low += ((u32)multicast_addr->dmi_addr[3]) << 16; - macaddr_low += ((u32)multicast_addr->dmi_addr[4]) << 8; - macaddr_low += (u32)multicast_addr->dmi_addr[5]; + macaddr_low = ((u32)multicast_addr->dmi_addr[2]) << 24; + macaddr_low += ((u32)multicast_addr->dmi_addr[3]) << 16; + macaddr_low += ((u32)multicast_addr->dmi_addr[4]) << 8; + macaddr_low += (u32)multicast_addr->dmi_addr[5]; nes_write_indexed(nesdev, perfect_filter_register_address+(mc_index * 8), macaddr_low); @@ -912,23 +910,23 @@ static void nes_netdev_set_multicast_list(struct net_device *netdev) /** * nes_netdev_change_mtu */ -static int nes_netdev_change_mtu(struct net_device *netdev, int new_mtu) +static int nes_netdev_change_mtu(struct net_device *netdev, int new_mtu) { struct nes_vnic *nesvnic = netdev_priv(netdev); - struct nes_device *nesdev = nesvnic->nesdev; - int ret = 0; - u8 jumbomode = 0; + struct nes_device *nesdev = nesvnic->nesdev; + int ret = 0; + u8 jumbomode=0; - if ((new_mtu < ETH_ZLEN) || (new_mtu > max_mtu)) + if ((new_mtu < ETH_ZLEN) || (new_mtu > max_mtu)) return -EINVAL; - netdev->mtu = new_mtu; + netdev->mtu = new_mtu; nesvnic->max_frame_size = new_mtu + VLAN_ETH_HLEN; if (netdev->mtu > 1500) { jumbomode=1; } - nes_nic_init_timer_defaults(nesdev, jumbomode); + nes_nic_init_timer_defaults(nesdev, jumbomode); if (netif_running(netdev)) { nes_netdev_stop(netdev); @@ -938,7 +936,8 @@ static int nes_netdev_change_mtu(struct net_device *netdev, int new_mtu) return ret; } -static const char nes_ethtool_stringset[][ETH_GSTRING_LEN] = { +#define NES_ETHTOOL_STAT_COUNT 55 +static const char nes_ethtool_stringset[NES_ETHTOOL_STAT_COUNT][ETH_GSTRING_LEN] = { "Link Change Interrupts", "Linearized SKBs", "T/GSO Requests", @@ -994,12 +993,8 @@ static const char nes_ethtool_stringset[][ETH_GSTRING_LEN] = { "CQ Depth 32", "CQ Depth 128", "CQ Depth 256", - "LRO aggregated", - "LRO flushed", - "LRO no_desc", }; -#define NES_ETHTOOL_STAT_COUNT ARRAY_SIZE(nes_ethtool_stringset) /** * nes_netdev_get_rx_csum @@ -1194,9 +1189,6 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev, target_stat_values[52] = int_mod_cq_depth_32; target_stat_values[53] = int_mod_cq_depth_128; target_stat_values[54] = int_mod_cq_depth_256; - target_stat_values[55] = nesvnic->lro_mgr.stats.aggregated; - target_stat_values[56] = nesvnic->lro_mgr.stats.flushed; - target_stat_values[57] = nesvnic->lro_mgr.stats.no_desc; } @@ -1227,14 +1219,14 @@ static int nes_netdev_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *et_coalesce) { struct nes_vnic *nesvnic = netdev_priv(netdev); - struct nes_device *nesdev = nesvnic->nesdev; + struct nes_device *nesdev = nesvnic->nesdev; struct nes_adapter *nesadapter = nesdev->nesadapter; struct nes_hw_tune_timer *shared_timer = &nesadapter->tune_timer; unsigned long flags; - spin_lock_irqsave(&nesadapter->periodic_timer_lock, flags); + spin_lock_irqsave(&nesadapter->periodic_timer_lock, flags); if (et_coalesce->rx_max_coalesced_frames_low) { - shared_timer->threshold_low = et_coalesce->rx_max_coalesced_frames_low; + shared_timer->threshold_low = et_coalesce->rx_max_coalesced_frames_low; } if (et_coalesce->rx_max_coalesced_frames_irq) { shared_timer->threshold_target = et_coalesce->rx_max_coalesced_frames_irq; @@ -1254,14 +1246,14 @@ static int nes_netdev_set_coalesce(struct net_device *netdev, nesadapter->et_rx_coalesce_usecs_irq = et_coalesce->rx_coalesce_usecs_irq; if (et_coalesce->use_adaptive_rx_coalesce) { nesadapter->et_use_adaptive_rx_coalesce = 1; - nesadapter->timer_int_limit = NES_TIMER_INT_LIMIT_DYNAMIC; + nesadapter->timer_int_limit = NES_TIMER_INT_LIMIT_DYNAMIC; nesadapter->et_rx_coalesce_usecs_irq = 0; if (et_coalesce->pkt_rate_low) { - nesadapter->et_pkt_rate_low = et_coalesce->pkt_rate_low; + nesadapter->et_pkt_rate_low = et_coalesce->pkt_rate_low; } } else { nesadapter->et_use_adaptive_rx_coalesce = 0; - nesadapter->timer_int_limit = NES_TIMER_INT_LIMIT; + nesadapter->timer_int_limit = NES_TIMER_INT_LIMIT; if (nesadapter->et_rx_coalesce_usecs_irq) { nes_write32(nesdev->regs+NES_PERIODIC_CONTROL, 0x80000000 | ((u32)(nesadapter->et_rx_coalesce_usecs_irq*8))); @@ -1278,28 +1270,28 @@ static int nes_netdev_get_coalesce(struct net_device *netdev, struct ethtool_coalesce *et_coalesce) { struct nes_vnic *nesvnic = netdev_priv(netdev); - struct nes_device *nesdev = nesvnic->nesdev; + struct nes_device *nesdev = nesvnic->nesdev; struct nes_adapter *nesadapter = nesdev->nesadapter; struct ethtool_coalesce temp_et_coalesce; struct nes_hw_tune_timer *shared_timer = &nesadapter->tune_timer; unsigned long flags; memset(&temp_et_coalesce, 0, sizeof(temp_et_coalesce)); - temp_et_coalesce.rx_coalesce_usecs_irq = nesadapter->et_rx_coalesce_usecs_irq; - temp_et_coalesce.use_adaptive_rx_coalesce = nesadapter->et_use_adaptive_rx_coalesce; - temp_et_coalesce.rate_sample_interval = nesadapter->et_rate_sample_interval; + temp_et_coalesce.rx_coalesce_usecs_irq = nesadapter->et_rx_coalesce_usecs_irq; + temp_et_coalesce.use_adaptive_rx_coalesce = nesadapter->et_use_adaptive_rx_coalesce; + temp_et_coalesce.rate_sample_interval = nesadapter->et_rate_sample_interval; temp_et_coalesce.pkt_rate_low = nesadapter->et_pkt_rate_low; spin_lock_irqsave(&nesadapter->periodic_timer_lock, flags); - temp_et_coalesce.rx_max_coalesced_frames_low = shared_timer->threshold_low; - temp_et_coalesce.rx_max_coalesced_frames_irq = shared_timer->threshold_target; + temp_et_coalesce.rx_max_coalesced_frames_low = shared_timer->threshold_low; + temp_et_coalesce.rx_max_coalesced_frames_irq = shared_timer->threshold_target; temp_et_coalesce.rx_max_coalesced_frames_high = shared_timer->threshold_high; - temp_et_coalesce.rx_coalesce_usecs_low = shared_timer->timer_in_use_min; + temp_et_coalesce.rx_coalesce_usecs_low = shared_timer->timer_in_use_min; temp_et_coalesce.rx_coalesce_usecs_high = shared_timer->timer_in_use_max; if (nesadapter->et_use_adaptive_rx_coalesce) { temp_et_coalesce.rx_coalesce_usecs_irq = shared_timer->timer_in_use; } spin_unlock_irqrestore(&nesadapter->periodic_timer_lock, flags); - memcpy(et_coalesce, &temp_et_coalesce, sizeof(*et_coalesce)); + memcpy(et_coalesce, &temp_et_coalesce, sizeof(*et_coalesce)); return 0; } @@ -1378,38 +1370,30 @@ static int nes_netdev_get_settings(struct net_device *netdev, struct ethtool_cmd u16 phy_data; et_cmd->duplex = DUPLEX_FULL; - et_cmd->port = PORT_MII; - + et_cmd->port = PORT_MII; if (nesadapter->OneG_Mode) { + et_cmd->supported = SUPPORTED_1000baseT_Full|SUPPORTED_Autoneg; + et_cmd->advertising = ADVERTISED_1000baseT_Full|ADVERTISED_Autoneg; et_cmd->speed = SPEED_1000; - if (nesadapter->phy_type[nesdev->mac_index] == NES_PHY_TYPE_PUMA_1G) { - et_cmd->supported = SUPPORTED_1000baseT_Full; - et_cmd->advertising = ADVERTISED_1000baseT_Full; - et_cmd->autoneg = AUTONEG_DISABLE; - et_cmd->transceiver = XCVR_INTERNAL; - et_cmd->phy_address = nesdev->mac_index; + nes_read_1G_phy_reg(nesdev, 0, nesadapter->phy_index[nesdev->mac_index], + &phy_data); + if (phy_data&0x1000) { + et_cmd->autoneg = AUTONEG_ENABLE; } else { - et_cmd->supported = SUPPORTED_1000baseT_Full | SUPPORTED_Autoneg; - et_cmd->advertising = ADVERTISED_1000baseT_Full | ADVERTISED_Autoneg; - nes_read_1G_phy_reg(nesdev, 0, nesadapter->phy_index[nesdev->mac_index], &phy_data); - if (phy_data & 0x1000) - et_cmd->autoneg = AUTONEG_ENABLE; - else - et_cmd->autoneg = AUTONEG_DISABLE; - et_cmd->transceiver = XCVR_EXTERNAL; - et_cmd->phy_address = nesadapter->phy_index[nesdev->mac_index]; + et_cmd->autoneg = AUTONEG_DISABLE; } + et_cmd->transceiver = XCVR_EXTERNAL; + et_cmd->phy_address = nesadapter->phy_index[nesdev->mac_index]; } else { - if ((nesadapter->phy_type[nesdev->mac_index] == NES_PHY_TYPE_IRIS) || - (nesadapter->phy_type[nesdev->mac_index] == NES_PHY_TYPE_ARGUS)) { + if (nesadapter->phy_type[nesvnic->logical_port] == NES_PHY_TYPE_IRIS) { et_cmd->transceiver = XCVR_EXTERNAL; - et_cmd->port = PORT_FIBRE; - et_cmd->supported = SUPPORTED_FIBRE; + et_cmd->port = PORT_FIBRE; + et_cmd->supported = SUPPORTED_FIBRE; et_cmd->advertising = ADVERTISED_FIBRE; et_cmd->phy_address = nesadapter->phy_index[nesdev->mac_index]; } else { et_cmd->transceiver = XCVR_INTERNAL; - et_cmd->supported = SUPPORTED_10000baseT_Full; + et_cmd->supported = SUPPORTED_10000baseT_Full; et_cmd->advertising = ADVERTISED_10000baseT_Full; et_cmd->phy_address = nesdev->mac_index; } @@ -1432,15 +1416,14 @@ static int nes_netdev_set_settings(struct net_device *netdev, struct ethtool_cmd struct nes_adapter *nesadapter = nesdev->nesadapter; u16 phy_data; - if ((nesadapter->OneG_Mode) && - (nesadapter->phy_type[nesdev->mac_index] != NES_PHY_TYPE_PUMA_1G)) { + if (nesadapter->OneG_Mode) { nes_read_1G_phy_reg(nesdev, 0, nesadapter->phy_index[nesdev->mac_index], &phy_data); if (et_cmd->autoneg) { /* Turn on Full duplex, Autoneg, and restart autonegotiation */ phy_data |= 0x1300; } else { - /* Turn off autoneg */ + // Turn off autoneg phy_data &= ~0x1000; } nes_write_1G_phy_reg(nesdev, 0, nesadapter->phy_index[nesdev->mac_index], @@ -1471,8 +1454,6 @@ static struct ethtool_ops nes_ethtool_ops = { .set_sg = ethtool_op_set_sg, .get_tso = ethtool_op_get_tso, .set_tso = ethtool_op_set_tso, - .get_flags = ethtool_op_get_flags, - .set_flags = ethtool_op_set_flags, }; @@ -1626,34 +1607,27 @@ struct net_device *nes_netdev_init(struct nes_device *nesdev, list_add_tail(&nesvnic->list, &nesdev->nesadapter->nesvnic_list[nesdev->mac_index]); if ((nesdev->netdev_count == 0) && - ((PCI_FUNC(nesdev->pcidev->devfn) == nesdev->mac_index) || - ((nesdev->nesadapter->phy_type[nesdev->mac_index] == NES_PHY_TYPE_PUMA_1G) && - (((PCI_FUNC(nesdev->pcidev->devfn) == 1) && (nesdev->mac_index == 2)) || - ((PCI_FUNC(nesdev->pcidev->devfn) == 2) && (nesdev->mac_index == 1)))))) { - /* - * nes_debug(NES_DBG_INIT, "Setting up PHY interrupt mask. Using register index 0x%04X\n", - * NES_IDX_PHY_PCS_CONTROL_STATUS0 + (0x200 * (nesvnic->logical_port & 1))); - */ + (PCI_FUNC(nesdev->pcidev->devfn) == nesdev->mac_index)) { + nes_debug(NES_DBG_INIT, "Setting up PHY interrupt mask. Using register index 0x%04X\n", + NES_IDX_PHY_PCS_CONTROL_STATUS0+(0x200*(nesvnic->logical_port&1))); u32temp = nes_read_indexed(nesdev, NES_IDX_PHY_PCS_CONTROL_STATUS0 + - (0x200 * (nesdev->mac_index & 1))); - if (nesdev->nesadapter->phy_type[nesdev->mac_index] != NES_PHY_TYPE_PUMA_1G) { - u32temp |= 0x00200000; - nes_write_indexed(nesdev, NES_IDX_PHY_PCS_CONTROL_STATUS0 + - (0x200 * (nesdev->mac_index & 1)), u32temp); - } - + (0x200*(nesvnic->logical_port&1))); + u32temp |= 0x00200000; + nes_write_indexed(nesdev, NES_IDX_PHY_PCS_CONTROL_STATUS0 + + (0x200*(nesvnic->logical_port&1)), u32temp); u32temp = nes_read_indexed(nesdev, NES_IDX_PHY_PCS_CONTROL_STATUS0 + - (0x200 * (nesdev->mac_index & 1))); - + (0x200*(nesvnic->logical_port&1)) ); if ((u32temp&0x0f1f0000) == 0x0f0f0000) { - if (nesdev->nesadapter->phy_type[nesdev->mac_index] == NES_PHY_TYPE_IRIS) { + if (nesdev->nesadapter->phy_type[nesvnic->logical_port] == NES_PHY_TYPE_IRIS) { nes_init_phy(nesdev); - nes_read_10G_phy_reg(nesdev, nesdev->nesadapter->phy_index[nesdev->mac_index], 1, 1); + nes_read_10G_phy_reg(nesdev, 1, + nesdev->nesadapter->phy_index[nesvnic->logical_port]); temp_phy_data = (u16)nes_read_indexed(nesdev, NES_IDX_MAC_MDIO_CONTROL); u32temp = 20; do { - nes_read_10G_phy_reg(nesdev, nesdev->nesadapter->phy_index[nesdev->mac_index], 1, 1); + nes_read_10G_phy_reg(nesdev, 1, + nesdev->nesadapter->phy_index[nesvnic->logical_port]); phy_data = (u16)nes_read_indexed(nesdev, NES_IDX_MAC_MDIO_CONTROL); if ((phy_data == temp_phy_data) || (!(--u32temp))) @@ -1670,14 +1644,6 @@ struct net_device *nes_netdev_init(struct nes_device *nesdev, nes_debug(NES_DBG_INIT, "The Link is UP!!.\n"); nesvnic->linkup = 1; } - } else if (nesdev->nesadapter->phy_type[nesdev->mac_index] == NES_PHY_TYPE_PUMA_1G) { - nes_debug(NES_DBG_INIT, "mac_index=%d, logical_port=%d, u32temp=0x%04X, PCI_FUNC=%d\n", - nesdev->mac_index, nesvnic->logical_port, u32temp, PCI_FUNC(nesdev->pcidev->devfn)); - if (((nesdev->mac_index < 2) && ((u32temp&0x01010000) == 0x01010000)) || - ((nesdev->mac_index > 1) && ((u32temp&0x02020000) == 0x02020000))) { - nes_debug(NES_DBG_INIT, "The Link is UP!!.\n"); - nesvnic->linkup = 1; - } } /* clear the MAC interrupt status, assumes direct logical to physical mapping */ u32temp = nes_read_indexed(nesdev, NES_IDX_MAC_INT_STATUS + (0x200 * nesdev->mac_index)); diff --git a/trunk/drivers/infiniband/hw/nes/nes_utils.c b/trunk/drivers/infiniband/hw/nes/nes_utils.c index fe83d1b2b177..c6d5631a6995 100644 --- a/trunk/drivers/infiniband/hw/nes/nes_utils.c +++ b/trunk/drivers/infiniband/hw/nes/nes_utils.c @@ -444,13 +444,15 @@ void nes_read_1G_phy_reg(struct nes_device *nesdev, u8 phy_reg, u8 phy_addr, u16 /** * nes_write_10G_phy_reg */ -void nes_write_10G_phy_reg(struct nes_device *nesdev, u16 phy_addr, u8 dev_addr, u16 phy_reg, - u16 data) +void nes_write_10G_phy_reg(struct nes_device *nesdev, u16 phy_reg, + u8 phy_addr, u16 data) { + u32 dev_addr; u32 port_addr; u32 u32temp; u32 counter; + dev_addr = 1; port_addr = phy_addr; /* set address */ @@ -490,12 +492,14 @@ void nes_write_10G_phy_reg(struct nes_device *nesdev, u16 phy_addr, u8 dev_addr, * This routine only issues the read, the data must be read * separately. */ -void nes_read_10G_phy_reg(struct nes_device *nesdev, u8 phy_addr, u8 dev_addr, u16 phy_reg) +void nes_read_10G_phy_reg(struct nes_device *nesdev, u16 phy_reg, u8 phy_addr) { + u32 dev_addr; u32 port_addr; u32 u32temp; u32 counter; + dev_addr = 1; port_addr = phy_addr; /* set address */ diff --git a/trunk/drivers/infiniband/hw/nes/nes_verbs.c b/trunk/drivers/infiniband/hw/nes/nes_verbs.c index 99b3c4ae86eb..ee74f7c7a6da 100644 --- a/trunk/drivers/infiniband/hw/nes/nes_verbs.c +++ b/trunk/drivers/infiniband/hw/nes/nes_verbs.c @@ -1266,7 +1266,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd, sq_size = init_attr->cap.max_send_wr; rq_size = init_attr->cap.max_recv_wr; - /* check if the encoded sizes are OK or not... */ + // check if the encoded sizes are OK or not... sq_encoded_size = nes_get_encoded_size(&sq_size); rq_encoded_size = nes_get_encoded_size(&rq_size); @@ -2377,7 +2377,7 @@ static struct ib_mr *nes_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, u8 single_page = 1; u8 stag_key; - region = ib_umem_get(pd->uobject->context, start, length, acc, 0); + region = ib_umem_get(pd->uobject->context, start, length, acc); if (IS_ERR(region)) { return (struct ib_mr *)region; } diff --git a/trunk/drivers/infiniband/ulp/ipoib/ipoib.h b/trunk/drivers/infiniband/ulp/ipoib/ipoib.h index 9044f8803532..f1f142dc64b1 100644 --- a/trunk/drivers/infiniband/ulp/ipoib/ipoib.h +++ b/trunk/drivers/infiniband/ulp/ipoib/ipoib.h @@ -95,8 +95,6 @@ enum { IPOIB_MCAST_FLAG_SENDONLY = 1, IPOIB_MCAST_FLAG_BUSY = 2, /* joining or already joined */ IPOIB_MCAST_FLAG_ATTACHED = 3, - - MAX_SEND_CQE = 16, }; #define IPOIB_OP_RECV (1ul << 31) @@ -287,8 +285,7 @@ struct ipoib_dev_priv { u16 pkey_index; struct ib_pd *pd; struct ib_mr *mr; - struct ib_cq *recv_cq; - struct ib_cq *send_cq; + struct ib_cq *cq; struct ib_qp *qp; u32 qkey; @@ -308,7 +305,6 @@ struct ipoib_dev_priv { struct ib_sge tx_sge[MAX_SKB_FRAGS + 1]; struct ib_send_wr tx_wr; unsigned tx_outstanding; - struct ib_wc send_wc[MAX_SEND_CQE]; struct ib_recv_wr rx_wr; struct ib_sge rx_sge[IPOIB_UD_RX_SG]; @@ -666,6 +662,7 @@ static inline int ipoib_register_debugfs(void) { return 0; } static inline void ipoib_unregister_debugfs(void) { } #endif + #define ipoib_printk(level, priv, format, arg...) \ printk(level "%s: " format, ((struct ipoib_dev_priv *) priv)->dev->name , ## arg) #define ipoib_warn(priv, format, arg...) \ diff --git a/trunk/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/trunk/drivers/infiniband/ulp/ipoib/ipoib_cm.c index 97e67d36378f..9db7b0bd9134 100644 --- a/trunk/drivers/infiniband/ulp/ipoib/ipoib_cm.c +++ b/trunk/drivers/infiniband/ulp/ipoib/ipoib_cm.c @@ -249,8 +249,8 @@ static struct ib_qp *ipoib_cm_create_rx_qp(struct net_device *dev, struct ipoib_dev_priv *priv = netdev_priv(dev); struct ib_qp_init_attr attr = { .event_handler = ipoib_cm_rx_event_handler, - .send_cq = priv->recv_cq, /* For drain WR */ - .recv_cq = priv->recv_cq, + .send_cq = priv->cq, /* For drain WR */ + .recv_cq = priv->cq, .srq = priv->cm.srq, .cap.max_send_wr = 1, /* For drain WR */ .cap.max_send_sge = 1, /* FIXME: 0 Seems not to work */ @@ -951,8 +951,8 @@ static struct ib_qp *ipoib_cm_create_tx_qp(struct net_device *dev, struct ipoib_ { struct ipoib_dev_priv *priv = netdev_priv(dev); struct ib_qp_init_attr attr = { - .send_cq = priv->recv_cq, - .recv_cq = priv->recv_cq, + .send_cq = priv->cq, + .recv_cq = priv->cq, .srq = priv->cm.srq, .cap.max_send_wr = ipoib_sendq_size, .cap.max_send_sge = 1, diff --git a/trunk/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c b/trunk/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c index 10279b79c44d..9a47428366c9 100644 --- a/trunk/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c +++ b/trunk/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c @@ -71,7 +71,7 @@ static int ipoib_set_coalesce(struct net_device *dev, coal->rx_max_coalesced_frames > 0xffff) return -EINVAL; - ret = ib_modify_cq(priv->recv_cq, coal->rx_max_coalesced_frames, + ret = ib_modify_cq(priv->cq, coal->rx_max_coalesced_frames, coal->rx_coalesce_usecs); if (ret && ret != -ENOSYS) { ipoib_warn(priv, "failed modifying CQ (%d)\n", ret); diff --git a/trunk/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/trunk/drivers/infiniband/ulp/ipoib/ipoib_ib.c index 97b815c1a3fc..7cf1fa7074ab 100644 --- a/trunk/drivers/infiniband/ulp/ipoib/ipoib_ib.c +++ b/trunk/drivers/infiniband/ulp/ipoib/ipoib_ib.c @@ -364,6 +364,7 @@ static void ipoib_ib_handle_tx_wc(struct net_device *dev, struct ib_wc *wc) struct ipoib_dev_priv *priv = netdev_priv(dev); unsigned int wr_id = wc->wr_id; struct ipoib_tx_buf *tx_req; + unsigned long flags; ipoib_dbg_data(priv, "send completion: id %d, status: %d\n", wr_id, wc->status); @@ -383,11 +384,13 @@ static void ipoib_ib_handle_tx_wc(struct net_device *dev, struct ib_wc *wc) dev_kfree_skb_any(tx_req->skb); + spin_lock_irqsave(&priv->tx_lock, flags); ++priv->tx_tail; if (unlikely(--priv->tx_outstanding == ipoib_sendq_size >> 1) && netif_queue_stopped(dev) && test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags)) netif_wake_queue(dev); + spin_unlock_irqrestore(&priv->tx_lock, flags); if (wc->status != IB_WC_SUCCESS && wc->status != IB_WC_WR_FLUSH_ERR) @@ -396,17 +399,6 @@ static void ipoib_ib_handle_tx_wc(struct net_device *dev, struct ib_wc *wc) wc->status, wr_id, wc->vendor_err); } -static int poll_tx(struct ipoib_dev_priv *priv) -{ - int n, i; - - n = ib_poll_cq(priv->send_cq, MAX_SEND_CQE, priv->send_wc); - for (i = 0; i < n; ++i) - ipoib_ib_handle_tx_wc(priv->dev, priv->send_wc + i); - - return n == MAX_SEND_CQE; -} - int ipoib_poll(struct napi_struct *napi, int budget) { struct ipoib_dev_priv *priv = container_of(napi, struct ipoib_dev_priv, napi); @@ -422,7 +414,7 @@ int ipoib_poll(struct napi_struct *napi, int budget) int max = (budget - done); t = min(IPOIB_NUM_WC, max); - n = ib_poll_cq(priv->recv_cq, t, priv->ibwc); + n = ib_poll_cq(priv->cq, t, priv->ibwc); for (i = 0; i < n; i++) { struct ib_wc *wc = priv->ibwc + i; @@ -433,8 +425,12 @@ int ipoib_poll(struct napi_struct *napi, int budget) ipoib_cm_handle_rx_wc(dev, wc); else ipoib_ib_handle_rx_wc(dev, wc); - } else - ipoib_cm_handle_tx_wc(priv->dev, wc); + } else { + if (wc->wr_id & IPOIB_OP_CM) + ipoib_cm_handle_tx_wc(dev, wc); + else + ipoib_ib_handle_tx_wc(dev, wc); + } } if (n != t) @@ -443,7 +439,7 @@ int ipoib_poll(struct napi_struct *napi, int budget) if (done < budget) { netif_rx_complete(dev, napi); - if (unlikely(ib_req_notify_cq(priv->recv_cq, + if (unlikely(ib_req_notify_cq(priv->cq, IB_CQ_NEXT_COMP | IB_CQ_REPORT_MISSED_EVENTS)) && netif_rx_reschedule(dev, napi)) @@ -566,16 +562,12 @@ void ipoib_send(struct net_device *dev, struct sk_buff *skb, address->last_send = priv->tx_head; ++priv->tx_head; - skb_orphan(skb); if (++priv->tx_outstanding == ipoib_sendq_size) { ipoib_dbg(priv, "TX ring full, stopping kernel net queue\n"); netif_stop_queue(dev); } } - - if (unlikely(priv->tx_outstanding > MAX_SEND_CQE)) - poll_tx(priv); } static void __ipoib_reap_ah(struct net_device *dev) @@ -722,7 +714,7 @@ void ipoib_drain_cq(struct net_device *dev) struct ipoib_dev_priv *priv = netdev_priv(dev); int i, n; do { - n = ib_poll_cq(priv->recv_cq, IPOIB_NUM_WC, priv->ibwc); + n = ib_poll_cq(priv->cq, IPOIB_NUM_WC, priv->ibwc); for (i = 0; i < n; ++i) { /* * Convert any successful completions to flush @@ -737,13 +729,14 @@ void ipoib_drain_cq(struct net_device *dev) ipoib_cm_handle_rx_wc(dev, priv->ibwc + i); else ipoib_ib_handle_rx_wc(dev, priv->ibwc + i); - } else - ipoib_cm_handle_tx_wc(dev, priv->ibwc + i); + } else { + if (priv->ibwc[i].wr_id & IPOIB_OP_CM) + ipoib_cm_handle_tx_wc(dev, priv->ibwc + i); + else + ipoib_ib_handle_tx_wc(dev, priv->ibwc + i); + } } } while (n == IPOIB_NUM_WC); - - while (poll_tx(priv)) - ; /* nothing */ } int ipoib_ib_dev_stop(struct net_device *dev, int flush) @@ -833,7 +826,7 @@ int ipoib_ib_dev_stop(struct net_device *dev, int flush) msleep(1); } - ib_req_notify_cq(priv->recv_cq, IB_CQ_NEXT_COMP); + ib_req_notify_cq(priv->cq, IB_CQ_NEXT_COMP); return 0; } diff --git a/trunk/drivers/infiniband/ulp/ipoib/ipoib_main.c b/trunk/drivers/infiniband/ulp/ipoib/ipoib_main.c index 2442090ac8d1..7a4ed9d3d844 100644 --- a/trunk/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/trunk/drivers/infiniband/ulp/ipoib/ipoib_main.c @@ -1298,8 +1298,7 @@ static int __init ipoib_init_module(void) ipoib_sendq_size = roundup_pow_of_two(ipoib_sendq_size); ipoib_sendq_size = min(ipoib_sendq_size, IPOIB_MAX_QUEUE_SIZE); - ipoib_sendq_size = max(ipoib_sendq_size, max(2 * MAX_SEND_CQE, - IPOIB_MIN_QUEUE_SIZE)); + ipoib_sendq_size = max(ipoib_sendq_size, IPOIB_MIN_QUEUE_SIZE); #ifdef CONFIG_INFINIBAND_IPOIB_CM ipoib_max_conn_qp = min(ipoib_max_conn_qp, IPOIB_CM_MAX_CONN_QP); #endif diff --git a/trunk/drivers/infiniband/ulp/ipoib/ipoib_verbs.c b/trunk/drivers/infiniband/ulp/ipoib/ipoib_verbs.c index c1e7ece1fd44..07c03f178a49 100644 --- a/trunk/drivers/infiniband/ulp/ipoib/ipoib_verbs.c +++ b/trunk/drivers/infiniband/ulp/ipoib/ipoib_verbs.c @@ -171,33 +171,26 @@ int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca) goto out_free_pd; } - size = ipoib_recvq_size + 1; + size = ipoib_sendq_size + ipoib_recvq_size + 1; ret = ipoib_cm_dev_init(dev); if (!ret) { - size += ipoib_sendq_size; if (ipoib_cm_has_srq(dev)) size += ipoib_recvq_size + 1; /* 1 extra for rx_drain_qp */ else size += ipoib_recvq_size * ipoib_max_conn_qp; } - priv->recv_cq = ib_create_cq(priv->ca, ipoib_ib_completion, NULL, dev, size, 0); - if (IS_ERR(priv->recv_cq)) { - printk(KERN_WARNING "%s: failed to create receive CQ\n", ca->name); + priv->cq = ib_create_cq(priv->ca, ipoib_ib_completion, NULL, dev, size, 0); + if (IS_ERR(priv->cq)) { + printk(KERN_WARNING "%s: failed to create CQ\n", ca->name); goto out_free_mr; } - priv->send_cq = ib_create_cq(priv->ca, NULL, NULL, dev, ipoib_sendq_size, 0); - if (IS_ERR(priv->send_cq)) { - printk(KERN_WARNING "%s: failed to create send CQ\n", ca->name); - goto out_free_recv_cq; - } - - if (ib_req_notify_cq(priv->recv_cq, IB_CQ_NEXT_COMP)) - goto out_free_send_cq; + if (ib_req_notify_cq(priv->cq, IB_CQ_NEXT_COMP)) + goto out_free_cq; - init_attr.send_cq = priv->send_cq; - init_attr.recv_cq = priv->recv_cq; + init_attr.send_cq = priv->cq; + init_attr.recv_cq = priv->cq; if (priv->hca_caps & IB_DEVICE_UD_TSO) init_attr.create_flags = IB_QP_CREATE_IPOIB_UD_LSO; @@ -208,7 +201,7 @@ int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca) priv->qp = ib_create_qp(priv->pd, &init_attr); if (IS_ERR(priv->qp)) { printk(KERN_WARNING "%s: failed to create QP\n", ca->name); - goto out_free_send_cq; + goto out_free_cq; } priv->dev->dev_addr[1] = (priv->qp->qp_num >> 16) & 0xff; @@ -237,11 +230,8 @@ int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca) return 0; -out_free_send_cq: - ib_destroy_cq(priv->send_cq); - -out_free_recv_cq: - ib_destroy_cq(priv->recv_cq); +out_free_cq: + ib_destroy_cq(priv->cq); out_free_mr: ib_dereg_mr(priv->mr); @@ -264,11 +254,8 @@ void ipoib_transport_dev_cleanup(struct net_device *dev) clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); } - if (ib_destroy_cq(priv->send_cq)) - ipoib_warn(priv, "ib_cq_destroy (send) failed\n"); - - if (ib_destroy_cq(priv->recv_cq)) - ipoib_warn(priv, "ib_cq_destroy (recv) failed\n"); + if (ib_destroy_cq(priv->cq)) + ipoib_warn(priv, "ib_cq_destroy failed\n"); ipoib_cm_dev_cleanup(dev); diff --git a/trunk/drivers/infiniband/ulp/ipoib/ipoib_vlan.c b/trunk/drivers/infiniband/ulp/ipoib/ipoib_vlan.c index 1cdb5cfb0ff1..431fdeaa2dc4 100644 --- a/trunk/drivers/infiniband/ulp/ipoib/ipoib_vlan.c +++ b/trunk/drivers/infiniband/ulp/ipoib/ipoib_vlan.c @@ -90,9 +90,6 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey) } priv->max_ib_mtu = ppriv->max_ib_mtu; - /* MTU will be reset when mcast join happens */ - priv->dev->mtu = IPOIB_UD_MTU(priv->max_ib_mtu); - priv->mcast_mtu = priv->admin_mtu = priv->dev->mtu; set_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags); priv->pkey = pkey; diff --git a/trunk/drivers/infiniband/ulp/iser/iscsi_iser.c b/trunk/drivers/infiniband/ulp/iser/iscsi_iser.c index aeb58cae9a3f..be1b9fbd416d 100644 --- a/trunk/drivers/infiniband/ulp/iser/iscsi_iser.c +++ b/trunk/drivers/infiniband/ulp/iser/iscsi_iser.c @@ -473,15 +473,13 @@ iscsi_iser_conn_get_stats(struct iscsi_cls_conn *cls_conn, struct iscsi_stats *s stats->r2t_pdus = conn->r2t_pdus_cnt; /* always 0 */ stats->tmfcmd_pdus = conn->tmfcmd_pdus_cnt; stats->tmfrsp_pdus = conn->tmfrsp_pdus_cnt; - stats->custom_length = 4; + stats->custom_length = 3; strcpy(stats->custom[0].desc, "qp_tx_queue_full"); stats->custom[0].value = 0; /* TB iser_conn->qp_tx_queue_full; */ strcpy(stats->custom[1].desc, "fmr_map_not_avail"); stats->custom[1].value = 0; /* TB iser_conn->fmr_map_not_avail */; strcpy(stats->custom[2].desc, "eh_abort_cnt"); stats->custom[2].value = conn->eh_abort_cnt; - strcpy(stats->custom[3].desc, "fmr_unalign_cnt"); - stats->custom[3].value = conn->fmr_unalign_cnt; } static int diff --git a/trunk/drivers/infiniband/ulp/iser/iscsi_iser.h b/trunk/drivers/infiniband/ulp/iser/iscsi_iser.h index a8c1b300e34d..1ee867b1b341 100644 --- a/trunk/drivers/infiniband/ulp/iser/iscsi_iser.h +++ b/trunk/drivers/infiniband/ulp/iser/iscsi_iser.h @@ -70,13 +70,6 @@ #define DRV_DATE "May 7th, 2006" #define iser_dbg(fmt, arg...) \ - do { \ - if (iser_debug_level > 1) \ - printk(KERN_DEBUG PFX "%s:" fmt,\ - __func__ , ## arg); \ - } while (0) - -#define iser_warn(fmt, arg...) \ do { \ if (iser_debug_level > 0) \ printk(KERN_DEBUG PFX "%s:" fmt,\ diff --git a/trunk/drivers/infiniband/ulp/iser/iser_memory.c b/trunk/drivers/infiniband/ulp/iser/iser_memory.c index cac50c4dc159..4a17743a639f 100644 --- a/trunk/drivers/infiniband/ulp/iser/iser_memory.c +++ b/trunk/drivers/infiniband/ulp/iser/iser_memory.c @@ -334,11 +334,8 @@ static void iser_data_buf_dump(struct iser_data_buf *data, struct scatterlist *sg; int i; - if (iser_debug_level == 0) - return; - for_each_sg(sgl, sg, data->dma_nents, i) - iser_warn("sg[%d] dma_addr:0x%lX page:0x%p " + iser_err("sg[%d] dma_addr:0x%lX page:0x%p " "off:0x%x sz:0x%x dma_len:0x%x\n", i, (unsigned long)ib_sg_dma_address(ibdev, sg), sg_page(sg), sg->offset, @@ -423,7 +420,6 @@ void iser_dma_unmap_task_data(struct iscsi_iser_cmd_task *iser_ctask) int iser_reg_rdma_mem(struct iscsi_iser_cmd_task *iser_ctask, enum iser_data_dir cmd_dir) { - struct iscsi_conn *iscsi_conn = iser_ctask->iser_conn->iscsi_conn; struct iser_conn *ib_conn = iser_ctask->iser_conn->ib_conn; struct iser_device *device = ib_conn->device; struct ib_device *ibdev = device->ib_device; @@ -438,8 +434,7 @@ int iser_reg_rdma_mem(struct iscsi_iser_cmd_task *iser_ctask, aligned_len = iser_data_buf_aligned_len(mem, ibdev); if (aligned_len != mem->dma_nents) { - iscsi_conn->fmr_unalign_cnt++; - iser_warn("rdma alignment violation %d/%d aligned\n", + iser_err("rdma alignment violation %d/%d aligned\n", aligned_len, mem->size); iser_data_buf_dump(mem, ibdev); diff --git a/trunk/drivers/input/input.c b/trunk/drivers/input/input.c index 27006fc18305..f02c242c3114 100644 --- a/trunk/drivers/input/input.c +++ b/trunk/drivers/input/input.c @@ -898,26 +898,30 @@ static int __init input_proc_init(void) { struct proc_dir_entry *entry; - proc_bus_input_dir = proc_mkdir("bus/input", NULL); + proc_bus_input_dir = proc_mkdir("input", proc_bus); if (!proc_bus_input_dir) return -ENOMEM; proc_bus_input_dir->owner = THIS_MODULE; - entry = proc_create("devices", 0, proc_bus_input_dir, - &input_devices_fileops); + entry = create_proc_entry("devices", 0, proc_bus_input_dir); if (!entry) goto fail1; - entry = proc_create("handlers", 0, proc_bus_input_dir, - &input_handlers_fileops); + entry->owner = THIS_MODULE; + entry->proc_fops = &input_devices_fileops; + + entry = create_proc_entry("handlers", 0, proc_bus_input_dir); if (!entry) goto fail2; + entry->owner = THIS_MODULE; + entry->proc_fops = &input_handlers_fileops; + return 0; fail2: remove_proc_entry("devices", proc_bus_input_dir); - fail1: remove_proc_entry("bus/input", NULL); + fail1: remove_proc_entry("input", proc_bus); return -ENOMEM; } @@ -925,7 +929,7 @@ static void input_proc_exit(void) { remove_proc_entry("devices", proc_bus_input_dir); remove_proc_entry("handlers", proc_bus_input_dir); - remove_proc_entry("bus/input", NULL); + remove_proc_entry("input", proc_bus); } #else /* !CONFIG_PROC_FS */ diff --git a/trunk/drivers/input/tablet/aiptek.c b/trunk/drivers/input/tablet/aiptek.c index 55c1134d6137..1d759f6f8076 100644 --- a/trunk/drivers/input/tablet/aiptek.c +++ b/trunk/drivers/input/tablet/aiptek.c @@ -528,9 +528,9 @@ static void aiptek_irq(struct urb *urb) (aiptek->curSetting.pointerMode)) { aiptek->diagnostic = AIPTEK_DIAGNOSTIC_TOOL_DISALLOWED; } else { - x = get_unaligned_le16(data + 1); - y = get_unaligned_le16(data + 3); - z = get_unaligned_le16(data + 6); + x = le16_to_cpu(get_unaligned((__le16 *) (data + 1))); + y = le16_to_cpu(get_unaligned((__le16 *) (data + 3))); + z = le16_to_cpu(get_unaligned((__le16 *) (data + 6))); dv = (data[5] & 0x01) != 0 ? 1 : 0; p = (data[5] & 0x02) != 0 ? 1 : 0; @@ -613,8 +613,8 @@ static void aiptek_irq(struct urb *urb) (aiptek->curSetting.pointerMode)) { aiptek->diagnostic = AIPTEK_DIAGNOSTIC_TOOL_DISALLOWED; } else { - x = get_unaligned_le16(data + 1); - y = get_unaligned_le16(data + 3); + x = le16_to_cpu(get_unaligned((__le16 *) (data + 1))); + y = le16_to_cpu(get_unaligned((__le16 *) (data + 3))); jitterable = data[5] & 0x1c; @@ -679,7 +679,7 @@ static void aiptek_irq(struct urb *urb) pck = (data[1] & aiptek->curSetting.stylusButtonUpper) != 0 ? 1 : 0; macro = dv && p && tip && !(data[3] & 1) ? (data[3] >> 1) : -1; - z = get_unaligned_le16(data + 4); + z = le16_to_cpu(get_unaligned((__le16 *) (data + 4))); if (dv) { /* If the selected tool changed, reset the old @@ -757,7 +757,7 @@ static void aiptek_irq(struct urb *urb) * hat switches (which just so happen to be the macroKeys.) */ else if (data[0] == 6) { - macro = get_unaligned_le16(data + 1); + macro = le16_to_cpu(get_unaligned((__le16 *) (data + 1))); if (macro > 0) { input_report_key(inputdev, macroKeyEvents[macro - 1], 0); @@ -952,7 +952,7 @@ aiptek_query(struct aiptek *aiptek, unsigned char command, unsigned char data) buf[0], buf[1], buf[2]); ret = -EIO; } else { - ret = get_unaligned_le16(buf + 1); + ret = le16_to_cpu(get_unaligned((__le16 *) (buf + 1))); } kfree(buf); return ret; diff --git a/trunk/drivers/input/tablet/gtco.c b/trunk/drivers/input/tablet/gtco.c index c5a8661a1baa..f66ca215cdec 100644 --- a/trunk/drivers/input/tablet/gtco.c +++ b/trunk/drivers/input/tablet/gtco.c @@ -245,11 +245,11 @@ static void parse_hid_report_descriptor(struct gtco *device, char * report, data = report[i]; break; case 2: - data16 = get_unaligned_le16(&report[i]); + data16 = le16_to_cpu(get_unaligned((__le16 *)&report[i])); break; case 3: size = 4; - data32 = get_unaligned_le32(&report[i]); + data32 = le32_to_cpu(get_unaligned((__le32 *)&report[i])); break; } @@ -695,10 +695,10 @@ static void gtco_urb_callback(struct urb *urbinfo) /* Fall thru */ case 1: /* All reports have X and Y coords in the same place */ - val = get_unaligned_le16(&device->buffer[1]); + val = le16_to_cpu(get_unaligned((__le16 *)&device->buffer[1])); input_report_abs(inputdev, ABS_X, val); - val = get_unaligned_le16(&device->buffer[3]); + val = le16_to_cpu(get_unaligned((__le16 *)&device->buffer[3])); input_report_abs(inputdev, ABS_Y, val); /* Ditto for proximity bit */ @@ -762,7 +762,7 @@ static void gtco_urb_callback(struct urb *urbinfo) le_buffer[1] = (u8)(device->buffer[4] >> 1); le_buffer[1] |= (u8)((device->buffer[5] & 0x1) << 7); - val = get_unaligned_le16(le_buffer); + val = le16_to_cpu(get_unaligned((__le16 *)le_buffer)); input_report_abs(inputdev, ABS_Y, val); /* @@ -772,10 +772,10 @@ static void gtco_urb_callback(struct urb *urbinfo) buttonbyte = device->buffer[5] >> 1; } else { - val = get_unaligned_le16(&device->buffer[1]); + val = le16_to_cpu(get_unaligned((__le16 *)&device->buffer[1])); input_report_abs(inputdev, ABS_X, val); - val = get_unaligned_le16(&device->buffer[3]); + val = le16_to_cpu(get_unaligned((__le16 *)&device->buffer[3])); input_report_abs(inputdev, ABS_Y, val); buttonbyte = device->buffer[5]; diff --git a/trunk/drivers/input/tablet/kbtab.c b/trunk/drivers/input/tablet/kbtab.c index f23f5a97fb38..1182fc133167 100644 --- a/trunk/drivers/input/tablet/kbtab.c +++ b/trunk/drivers/input/tablet/kbtab.c @@ -63,8 +63,8 @@ static void kbtab_irq(struct urb *urb) goto exit; } - kbtab->x = get_unaligned_le16(&data[1]); - kbtab->y = get_unaligned_le16(&data[3]); + kbtab->x = le16_to_cpu(get_unaligned((__le16 *) &data[1])); + kbtab->y = le16_to_cpu(get_unaligned((__le16 *) &data[3])); kbtab->pressure = (data[5]); diff --git a/trunk/drivers/isdn/capi/kcapi_proc.c b/trunk/drivers/isdn/capi/kcapi_proc.c index c29208bd7521..845a797b0030 100644 --- a/trunk/drivers/isdn/capi/kcapi_proc.c +++ b/trunk/drivers/isdn/capi/kcapi_proc.c @@ -114,7 +114,6 @@ static int seq_contrstats_open(struct inode *inode, struct file *file) } static const struct file_operations proc_controller_ops = { - .owner = THIS_MODULE, .open = seq_controller_open, .read = seq_read, .llseek = seq_lseek, @@ -122,7 +121,6 @@ static const struct file_operations proc_controller_ops = { }; static const struct file_operations proc_contrstats_ops = { - .owner = THIS_MODULE, .open = seq_contrstats_open, .read = seq_read, .llseek = seq_lseek, @@ -221,7 +219,6 @@ seq_applstats_open(struct inode *inode, struct file *file) } static const struct file_operations proc_applications_ops = { - .owner = THIS_MODULE, .open = seq_applications_open, .read = seq_read, .llseek = seq_lseek, @@ -229,13 +226,21 @@ static const struct file_operations proc_applications_ops = { }; static const struct file_operations proc_applstats_ops = { - .owner = THIS_MODULE, .open = seq_applstats_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release, }; +static void +create_seq_entry(char *name, mode_t mode, const struct file_operations *f) +{ + struct proc_dir_entry *entry; + entry = create_proc_entry(name, mode, NULL); + if (entry) + entry->proc_fops = f; +} + // --------------------------------------------------------------------------- static void *capi_driver_start(struct seq_file *seq, loff_t *pos) @@ -278,7 +283,6 @@ seq_capi_driver_open(struct inode *inode, struct file *file) } static const struct file_operations proc_driver_ops = { - .owner = THIS_MODULE, .open = seq_capi_driver_open, .read = seq_read, .llseek = seq_lseek, @@ -292,11 +296,11 @@ kcapi_proc_init(void) { proc_mkdir("capi", NULL); proc_mkdir("capi/controllers", NULL); - proc_create("capi/controller", 0, NULL, &proc_controller_ops); - proc_create("capi/contrstats", 0, NULL, &proc_contrstats_ops); - proc_create("capi/applications", 0, NULL, &proc_applications_ops); - proc_create("capi/applstats", 0, NULL, &proc_applstats_ops); - proc_create("capi/driver", 0, NULL, &proc_driver_ops); + create_seq_entry("capi/controller", 0, &proc_controller_ops); + create_seq_entry("capi/contrstats", 0, &proc_contrstats_ops); + create_seq_entry("capi/applications", 0, &proc_applications_ops); + create_seq_entry("capi/applstats", 0, &proc_applstats_ops); + create_seq_entry("capi/driver", 0, &proc_driver_ops); } void __exit diff --git a/trunk/drivers/isdn/divert/divert_procfs.c b/trunk/drivers/isdn/divert/divert_procfs.c index 8b256a617c8a..4fd4c46892e3 100644 --- a/trunk/drivers/isdn/divert/divert_procfs.c +++ b/trunk/drivers/isdn/divert/divert_procfs.c @@ -288,12 +288,13 @@ divert_dev_init(void) isdn_proc_entry = proc_mkdir("isdn", init_net.proc_net); if (!isdn_proc_entry) return (-1); - isdn_divert_entry = proc_create("divert", S_IFREG | S_IRUGO, - isdn_proc_entry, &isdn_fops); + isdn_divert_entry = create_proc_entry("divert", S_IFREG | S_IRUGO, isdn_proc_entry); if (!isdn_divert_entry) { remove_proc_entry("isdn", init_net.proc_net); return (-1); } + isdn_divert_entry->proc_fops = &isdn_fops; + isdn_divert_entry->owner = THIS_MODULE; #endif /* CONFIG_PROC_FS */ return (0); diff --git a/trunk/drivers/isdn/hardware/eicon/divasproc.c b/trunk/drivers/isdn/hardware/eicon/divasproc.c index fae895828a17..0632a2606998 100644 --- a/trunk/drivers/isdn/hardware/eicon/divasproc.c +++ b/trunk/drivers/isdn/hardware/eicon/divasproc.c @@ -125,11 +125,15 @@ static const struct file_operations divas_fops = { int create_divas_proc(void) { - proc_create(divas_proc_name, S_IFREG | S_IRUGO, proc_net_eicon, - &divas_fops); + divas_proc_entry = create_proc_entry(divas_proc_name, + S_IFREG | S_IRUGO, + proc_net_eicon); if (!divas_proc_entry) return (0); + divas_proc_entry->proc_fops = &divas_fops; + divas_proc_entry->owner = THIS_MODULE; + return (1); } diff --git a/trunk/drivers/isdn/hysdn/hysdn_procconf.c b/trunk/drivers/isdn/hysdn/hysdn_procconf.c index 877be9922c3d..27d890b48f88 100644 --- a/trunk/drivers/isdn/hysdn/hysdn_procconf.c +++ b/trunk/drivers/isdn/hysdn/hysdn_procconf.c @@ -370,7 +370,6 @@ hysdn_conf_close(struct inode *ino, struct file *filep) /******************************************************/ static const struct file_operations conf_fops = { - .owner = THIS_MODULE, .llseek = no_llseek, .read = hysdn_conf_read, .write = hysdn_conf_write, @@ -403,9 +402,11 @@ hysdn_procconf_init(void) while (card) { sprintf(conf_name, "%s%d", PROC_CONF_BASENAME, card->myid); - if ((card->procconf = (void *) proc_create(conf_name, - S_IFREG | S_IRUGO | S_IWUSR, - hysdn_proc_entry)) != NULL) { + if ((card->procconf = (void *) create_proc_entry(conf_name, + S_IFREG | S_IRUGO | S_IWUSR, + hysdn_proc_entry)) != NULL) { + ((struct proc_dir_entry *) card->procconf)->proc_fops = &conf_fops; + ((struct proc_dir_entry *) card->procconf)->owner = THIS_MODULE; hysdn_proclog_init(card); /* init the log file entry */ } card = card->next; /* next entry */ diff --git a/trunk/drivers/isdn/hysdn/hysdn_proclog.c b/trunk/drivers/isdn/hysdn/hysdn_proclog.c index 8991d2c8ee4a..27b3991fb0ec 100644 --- a/trunk/drivers/isdn/hysdn/hysdn_proclog.c +++ b/trunk/drivers/isdn/hysdn/hysdn_proclog.c @@ -380,7 +380,6 @@ hysdn_log_poll(struct file *file, poll_table * wait) /**************************************************/ static const struct file_operations log_fops = { - .owner = THIS_MODULE, .llseek = no_llseek, .read = hysdn_log_read, .write = hysdn_log_write, @@ -403,9 +402,10 @@ hysdn_proclog_init(hysdn_card * card) if ((pd = kzalloc(sizeof(struct procdata), GFP_KERNEL)) != NULL) { sprintf(pd->log_name, "%s%d", PROC_LOG_BASENAME, card->myid); - pd->log = proc_create(pd->log_name, - S_IFREG | S_IRUGO | S_IWUSR, hysdn_proc_entry, - &log_fops); + if ((pd->log = create_proc_entry(pd->log_name, S_IFREG | S_IRUGO | S_IWUSR, hysdn_proc_entry)) != NULL) { + pd->log->proc_fops = &log_fops; + pd->log->owner = THIS_MODULE; + } init_waitqueue_head(&(pd->rd_queue)); diff --git a/trunk/drivers/leds/led-class.c b/trunk/drivers/leds/led-class.c index b3c54be74556..ac05a928f764 100644 --- a/trunk/drivers/leds/led-class.c +++ b/trunk/drivers/leds/led-class.c @@ -105,7 +105,7 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev) led_cdev->dev = device_create(leds_class, parent, 0, "%s", led_cdev->name); - if (IS_ERR(led_cdev->dev)) + if (unlikely(IS_ERR(led_cdev->dev))) return PTR_ERR(led_cdev->dev); dev_set_drvdata(led_cdev->dev, led_cdev); diff --git a/trunk/drivers/macintosh/Kconfig b/trunk/drivers/macintosh/Kconfig index b52659620d50..77f50b63a970 100644 --- a/trunk/drivers/macintosh/Kconfig +++ b/trunk/drivers/macintosh/Kconfig @@ -234,14 +234,6 @@ config WINDFARM_PM112 which are the recent dual and quad G5 machines using the 970MP dual-core processor. -config WINDFARM_PM121 - tristate "Support for thermal management on PowerMac12,1" - depends on WINDFARM && I2C && PMAC_SMU - select I2C_POWERMAC - help - This driver provides thermal control for the PowerMac12,1 - which is the iMac G5 (iSight). - config ANSLCD tristate "Support for ANS LCD display" depends on ADB_CUDA && PPC_PMAC diff --git a/trunk/drivers/macintosh/Makefile b/trunk/drivers/macintosh/Makefile index e3132efa17c0..2dfc3f4eaf42 100644 --- a/trunk/drivers/macintosh/Makefile +++ b/trunk/drivers/macintosh/Makefile @@ -42,9 +42,4 @@ obj-$(CONFIG_WINDFARM_PM112) += windfarm_pm112.o windfarm_smu_sat.o \ windfarm_smu_sensors.o \ windfarm_max6690_sensor.o \ windfarm_lm75_sensor.o windfarm_pid.o -obj-$(CONFIG_WINDFARM_PM121) += windfarm_pm121.o windfarm_smu_sat.o \ - windfarm_smu_controls.o \ - windfarm_smu_sensors.o \ - windfarm_max6690_sensor.o \ - windfarm_lm75_sensor.o windfarm_pid.o obj-$(CONFIG_PMAC_RACKMETER) += rack-meter.o diff --git a/trunk/drivers/macintosh/windfarm_lm75_sensor.c b/trunk/drivers/macintosh/windfarm_lm75_sensor.c index b92b959fe16e..7e10c3ab4d50 100644 --- a/trunk/drivers/macintosh/windfarm_lm75_sensor.c +++ b/trunk/drivers/macintosh/windfarm_lm75_sensor.c @@ -127,12 +127,6 @@ static struct wf_lm75_sensor *wf_lm75_create(struct i2c_adapter *adapter, */ if (!strcmp(loc, "Hard drive") || !strcmp(loc, "DRIVE BAY")) lm->sens.name = "hd-temp"; - else if (!strcmp(loc, "Incoming Air Temp")) - lm->sens.name = "incoming-air-temp"; - else if (!strcmp(loc, "ODD Temp")) - lm->sens.name = "optical-drive-temp"; - else if (!strcmp(loc, "HD Temp")) - lm->sens.name = "hard-drive-temp"; else goto fail; diff --git a/trunk/drivers/macintosh/windfarm_max6690_sensor.c b/trunk/drivers/macintosh/windfarm_max6690_sensor.c index e207a90d6b27..5f03aab9fb5d 100644 --- a/trunk/drivers/macintosh/windfarm_max6690_sensor.c +++ b/trunk/drivers/macintosh/windfarm_max6690_sensor.c @@ -77,28 +77,18 @@ static struct wf_sensor_ops wf_max6690_ops = { .owner = THIS_MODULE, }; -static void wf_max6690_create(struct i2c_adapter *adapter, u8 addr, - const char *loc) +static void wf_max6690_create(struct i2c_adapter *adapter, u8 addr) { struct wf_6690_sensor *max; - char *name; + char *name = "backside-temp"; max = kzalloc(sizeof(struct wf_6690_sensor), GFP_KERNEL); if (max == NULL) { printk(KERN_ERR "windfarm: Couldn't create MAX6690 sensor %s: " - "no memory\n", loc); + "no memory\n", name); return; } - if (!strcmp(loc, "BACKSIDE")) - name = "backside-temp"; - else if (!strcmp(loc, "NB Ambient")) - name = "north-bridge-temp"; - else if (!strcmp(loc, "GPU Ambient")) - name = "gpu-temp"; - else - goto fail; - max->sens.ops = &wf_max6690_ops; max->sens.name = name; max->i2c.addr = addr >> 1; @@ -148,7 +138,9 @@ static int wf_max6690_attach(struct i2c_adapter *adapter) if (loc == NULL || addr == 0) continue; printk("found max6690, loc=%s addr=0x%02x\n", loc, addr); - wf_max6690_create(adapter, addr, loc); + if (strcmp(loc, "BACKSIDE")) + continue; + wf_max6690_create(adapter, addr); } return 0; diff --git a/trunk/drivers/macintosh/windfarm_pm121.c b/trunk/drivers/macintosh/windfarm_pm121.c deleted file mode 100644 index 66ec4fb115bb..000000000000 --- a/trunk/drivers/macintosh/windfarm_pm121.c +++ /dev/null @@ -1,1040 +0,0 @@ -/* - * Windfarm PowerMac thermal control. iMac G5 iSight - * - * (c) Copyright 2007 Étienne Bersac - * - * Bits & pieces from windfarm_pm81.c by (c) Copyright 2005 Benjamin - * Herrenschmidt, IBM Corp. - * - * Released under the term of the GNU GPL v2. - * - * - * - * PowerMac12,1 - * ============ - * - * - * The algorithm used is the PID control algorithm, used the same way - * the published Darwin code does, using the same values that are - * present in the Darwin 8.10 snapshot property lists (note however - * that none of the code has been re-used, it's a complete - * re-implementation - * - * There is two models using PowerMac12,1. Model 2 is iMac G5 iSight - * 17" while Model 3 is iMac G5 20". They do have both the same - * controls with a tiny difference. The control-ids of hard-drive-fan - * and cpu-fan is swapped. - * - * - * Target Correction : - * - * controls have a target correction calculated as : - * - * new_min = ((((average_power * slope) >> 16) + offset) >> 16) + min_value - * new_value = max(new_value, max(new_min, 0)) - * - * OD Fan control correction. - * - * # model_id: 2 - * offset : -19563152 - * slope : 1956315 - * - * # model_id: 3 - * offset : -15650652 - * slope : 1565065 - * - * HD Fan control correction. - * - * # model_id: 2 - * offset : -15650652 - * slope : 1565065 - * - * # model_id: 3 - * offset : -19563152 - * slope : 1956315 - * - * CPU Fan control correction. - * - * # model_id: 2 - * offset : -25431900 - * slope : 2543190 - * - * # model_id: 3 - * offset : -15650652 - * slope : 1565065 - * - * - * Target rubber-banding : - * - * Some controls have a target correction which depends on another - * control value. The correction is computed in the following way : - * - * new_min = ref_value * slope + offset - * - * ref_value is the value of the reference control. If new_min is - * greater than 0, then we correct the target value using : - * - * new_target = max (new_target, new_min >> 16) - * - * - * # model_id : 2 - * control : cpu-fan - * ref : optical-drive-fan - * offset : -15650652 - * slope : 1565065 - * - * # model_id : 3 - * control : optical-drive-fan - * ref : hard-drive-fan - * offset : -32768000 - * slope : 65536 - * - * - * In order to have the moste efficient correction with those - * dependencies, we must trigger HD loop before OD loop before CPU - * loop. - * - * - * The various control loops found in Darwin config file are: - * - * HD Fan control loop. - * - * # model_id: 2 - * control : hard-drive-fan - * sensor : hard-drive-temp - * PID params : G_d = 0x00000000 - * G_p = 0x002D70A3 - * G_r = 0x00019999 - * History = 2 entries - * Input target = 0x370000 - * Interval = 5s - * - * # model_id: 3 - * control : hard-drive-fan - * sensor : hard-drive-temp - * PID params : G_d = 0x00000000 - * G_p = 0x002170A3 - * G_r = 0x00019999 - * History = 2 entries - * Input target = 0x370000 - * Interval = 5s - * - * OD Fan control loop. - * - * # model_id: 2 - * control : optical-drive-fan - * sensor : optical-drive-temp - * PID params : G_d = 0x00000000 - * G_p = 0x001FAE14 - * G_r = 0x00019999 - * History = 2 entries - * Input target = 0x320000 - * Interval = 5s - * - * # model_id: 3 - * control : optical-drive-fan - * sensor : optical-drive-temp - * PID params : G_d = 0x00000000 - * G_p = 0x001FAE14 - * G_r = 0x00019999 - * History = 2 entries - * Input target = 0x320000 - * Interval = 5s - * - * GPU Fan control loop. - * - * # model_id: 2 - * control : hard-drive-fan - * sensor : gpu-temp - * PID params : G_d = 0x00000000 - * G_p = 0x002A6666 - * G_r = 0x00019999 - * History = 2 entries - * Input target = 0x5A0000 - * Interval = 5s - * - * # model_id: 3 - * control : cpu-fan - * sensor : gpu-temp - * PID params : G_d = 0x00000000 - * G_p = 0x0010CCCC - * G_r = 0x00019999 - * History = 2 entries - * Input target = 0x500000 - * Interval = 5s - * - * KODIAK (aka northbridge) Fan control loop. - * - * # model_id: 2 - * control : optical-drive-fan - * sensor : north-bridge-temp - * PID params : G_d = 0x00000000 - * G_p = 0x003BD70A - * G_r = 0x00019999 - * History = 2 entries - * Input target = 0x550000 - * Interval = 5s - * - * # model_id: 3 - * control : hard-drive-fan - * sensor : north-bridge-temp - * PID params : G_d = 0x00000000 - * G_p = 0x0030F5C2 - * G_r = 0x00019999 - * History = 2 entries - * Input target = 0x550000 - * Interval = 5s - * - * CPU Fan control loop. - * - * control : cpu-fan - * sensors : cpu-temp, cpu-power - * PID params : from SDB partition - * - * - * CPU Slew control loop. - * - * control : cpufreq-clamp - * sensor : cpu-temp - * - */ - -#undef DEBUG - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "windfarm.h" -#include "windfarm_pid.h" - -#define VERSION "0.3" - -static int pm121_mach_model; /* machine model id */ - -/* Controls & sensors */ -static struct wf_sensor *sensor_cpu_power; -static struct wf_sensor *sensor_cpu_temp; -static struct wf_sensor *sensor_cpu_voltage; -static struct wf_sensor *sensor_cpu_current; -static struct wf_sensor *sensor_gpu_temp; -static struct wf_sensor *sensor_north_bridge_temp; -static struct wf_sensor *sensor_hard_drive_temp; -static struct wf_sensor *sensor_optical_drive_temp; -static struct wf_sensor *sensor_incoming_air_temp; /* unused ! */ - -enum { - FAN_CPU, - FAN_HD, - FAN_OD, - CPUFREQ, - N_CONTROLS -}; -static struct wf_control *controls[N_CONTROLS] = {}; - -/* Set to kick the control loop into life */ -static int pm121_all_controls_ok, pm121_all_sensors_ok, pm121_started; - -enum { - FAILURE_FAN = 1 << 0, - FAILURE_SENSOR = 1 << 1, - FAILURE_OVERTEMP = 1 << 2 -}; - -/* All sys loops. Note the HD before the OD loop in order to have it - run before. */ -enum { - LOOP_GPU, /* control = hd or cpu, but luckily, - it doesn't matter */ - LOOP_HD, /* control = hd */ - LOOP_KODIAK, /* control = hd or od */ - LOOP_OD, /* control = od */ - N_LOOPS -}; - -static const char *loop_names[N_LOOPS] = { - "GPU", - "HD", - "KODIAK", - "OD", -}; - -#define PM121_NUM_CONFIGS 2 - -static unsigned int pm121_failure_state; -static int pm121_readjust, pm121_skipping; -static s32 average_power; - -struct pm121_correction { - int offset; - int slope; -}; - -static struct pm121_correction corrections[N_CONTROLS][PM121_NUM_CONFIGS] = { - /* FAN_OD */ - { - /* MODEL 2 */ - { .offset = -19563152, - .slope = 1956315 - }, - /* MODEL 3 */ - { .offset = -15650652, - .slope = 1565065 - }, - }, - /* FAN_HD */ - { - /* MODEL 2 */ - { .offset = -15650652, - .slope = 1565065 - }, - /* MODEL 3 */ - { .offset = -19563152, - .slope = 1956315 - }, - }, - /* FAN_CPU */ - { - /* MODEL 2 */ - { .offset = -25431900, - .slope = 2543190 - }, - /* MODEL 3 */ - { .offset = -15650652, - .slope = 1565065 - }, - }, - /* CPUFREQ has no correction (and is not implemented at all) */ -}; - -struct pm121_connection { - unsigned int control_id; - unsigned int ref_id; - struct pm121_correction correction; -}; - -static struct pm121_connection pm121_connections[] = { - /* MODEL 2 */ - { .control_id = FAN_CPU, - .ref_id = FAN_OD, - { .offset = -32768000, - .slope = 65536 - } - }, - /* MODEL 3 */ - { .control_id = FAN_OD, - .ref_id = FAN_HD, - { .offset = -32768000, - .slope = 65536 - } - }, -}; - -/* pointer to the current model connection */ -static struct pm121_connection *pm121_connection; - -/* - * ****** System Fans Control Loop ****** - * - */ - -/* Since each loop handles only one control and we want to avoid - * writing virtual control, we store the control correction with the - * loop params. Some data are not set, there are common to all loop - * and thus, hardcoded. - */ -struct pm121_sys_param { - /* purely informative since we use mach_model-2 as index */ - int model_id; - struct wf_sensor **sensor; /* use sensor_id instead ? */ - s32 gp, itarget; - unsigned int control_id; -}; - -static struct pm121_sys_param -pm121_sys_all_params[N_LOOPS][PM121_NUM_CONFIGS] = { - /* GPU Fan control loop */ - { - { .model_id = 2, - .sensor = &sensor_gpu_temp, - .gp = 0x002A6666, - .itarget = 0x5A0000, - .control_id = FAN_HD, - }, - { .model_id = 3, - .sensor = &sensor_gpu_temp, - .gp = 0x0010CCCC, - .itarget = 0x500000, - .control_id = FAN_CPU, - }, - }, - /* HD Fan control loop */ - { - { .model_id = 2, - .sensor = &sensor_hard_drive_temp, - .gp = 0x002D70A3, - .itarget = 0x370000, - .control_id = FAN_HD, - }, - { .model_id = 3, - .sensor = &sensor_hard_drive_temp, - .gp = 0x002170A3, - .itarget = 0x370000, - .control_id = FAN_HD, - }, - }, - /* KODIAK Fan control loop */ - { - { .model_id = 2, - .sensor = &sensor_north_bridge_temp, - .gp = 0x003BD70A, - .itarget = 0x550000, - .control_id = FAN_OD, - }, - { .model_id = 3, - .sensor = &sensor_north_bridge_temp, - .gp = 0x0030F5C2, - .itarget = 0x550000, - .control_id = FAN_HD, - }, - }, - /* OD Fan control loop */ - { - { .model_id = 2, - .sensor = &sensor_optical_drive_temp, - .gp = 0x001FAE14, - .itarget = 0x320000, - .control_id = FAN_OD, - }, - { .model_id = 3, - .sensor = &sensor_optical_drive_temp, - .gp = 0x001FAE14, - .itarget = 0x320000, - .control_id = FAN_OD, - }, - }, -}; - -/* the hardcoded values */ -#define PM121_SYS_GD 0x00000000 -#define PM121_SYS_GR 0x00019999 -#define PM121_SYS_HISTORY_SIZE 2 -#define PM121_SYS_INTERVAL 5 - -/* State data used by the system fans control loop - */ -struct pm121_sys_state { - int ticks; - s32 setpoint; - struct wf_pid_state pid; -}; - -struct pm121_sys_state *pm121_sys_state[N_LOOPS] = {}; - -/* - * ****** CPU Fans Control Loop ****** - * - */ - -#define PM121_CPU_INTERVAL 1 - -/* State data used by the cpu fans control loop - */ -struct pm121_cpu_state { - int ticks; - s32 setpoint; - struct wf_cpu_pid_state pid; -}; - -static struct pm121_cpu_state *pm121_cpu_state; - - - -/* - * ***** Implementation ***** - * - */ - -/* correction the value using the output-low-bound correction algo */ -static s32 pm121_correct(s32 new_setpoint, - unsigned int control_id, - s32 min) -{ - s32 new_min; - struct pm121_correction *correction; - correction = &corrections[control_id][pm121_mach_model - 2]; - - new_min = (average_power * correction->slope) >> 16; - new_min += correction->offset; - new_min = (new_min >> 16) + min; - - return max(new_setpoint, max(new_min, 0)); -} - -static s32 pm121_connect(unsigned int control_id, s32 setpoint) -{ - s32 new_min, value, new_setpoint; - - if (pm121_connection->control_id == control_id) { - controls[control_id]->ops->get_value(controls[control_id], - &value); - new_min = value * pm121_connection->correction.slope; - new_min += pm121_connection->correction.offset; - if (new_min > 0) { - new_setpoint = max(setpoint, (new_min >> 16)); - if (new_setpoint != setpoint) { - pr_debug("pm121: %s depending on %s, " - "corrected from %d to %d RPM\n", - controls[control_id]->name, - controls[pm121_connection->ref_id]->name, - (int) setpoint, (int) new_setpoint); - } - } else - new_setpoint = setpoint; - } - /* no connection */ - else - new_setpoint = setpoint; - - return new_setpoint; -} - -/* FAN LOOPS */ -static void pm121_create_sys_fans(int loop_id) -{ - struct pm121_sys_param *param = NULL; - struct wf_pid_param pid_param; - struct wf_control *control = NULL; - int i; - - /* First, locate the params for this model */ - for (i = 0; i < PM121_NUM_CONFIGS; i++) { - if (pm121_sys_all_params[loop_id][i].model_id == pm121_mach_model) { - param = &(pm121_sys_all_params[loop_id][i]); - break; - } - } - - /* No params found, put fans to max */ - if (param == NULL) { - printk(KERN_WARNING "pm121: %s fan config not found " - " for this machine model\n", - loop_names[loop_id]); - goto fail; - } - - control = controls[param->control_id]; - - /* Alloc & initialize state */ - pm121_sys_state[loop_id] = kmalloc(sizeof(struct pm121_sys_state), - GFP_KERNEL); - if (pm121_sys_state[loop_id] == NULL) { - printk(KERN_WARNING "pm121: Memory allocation error\n"); - goto fail; - } - pm121_sys_state[loop_id]->ticks = 1; - - /* Fill PID params */ - pid_param.gd = PM121_SYS_GD; - pid_param.gp = param->gp; - pid_param.gr = PM121_SYS_GR; - pid_param.interval = PM121_SYS_INTERVAL; - pid_param.history_len = PM121_SYS_HISTORY_SIZE; - pid_param.itarget = param->itarget; - pid_param.min = control->ops->get_min(control); - pid_param.max = control->ops->get_max(control); - - wf_pid_init(&pm121_sys_state[loop_id]->pid, &pid_param); - - pr_debug("pm121: %s Fan control loop initialized.\n" - " itarged=%d.%03d, min=%d RPM, max=%d RPM\n", - loop_names[loop_id], FIX32TOPRINT(pid_param.itarget), - pid_param.min, pid_param.max); - return; - - fail: - /* note that this is not optimal since another loop may still - control the same control */ - printk(KERN_WARNING "pm121: failed to set up %s loop " - "setting \"%s\" to max speed.\n", - loop_names[loop_id], control->name); - - if (control) - wf_control_set_max(control); -} - -static void pm121_sys_fans_tick(int loop_id) -{ - struct pm121_sys_param *param; - struct pm121_sys_state *st; - struct wf_sensor *sensor; - struct wf_control *control; - s32 temp, new_setpoint; - int rc; - - param = &(pm121_sys_all_params[loop_id][pm121_mach_model-2]); - st = pm121_sys_state[loop_id]; - sensor = *(param->sensor); - control = controls[param->control_id]; - - if (--st->ticks != 0) { - if (pm121_readjust) - goto readjust; - return; - } - st->ticks = PM121_SYS_INTERVAL; - - rc = sensor->ops->get_value(sensor, &temp); - if (rc) { - printk(KERN_WARNING "windfarm: %s sensor error %d\n", - sensor->name, rc); - pm121_failure_state |= FAILURE_SENSOR; - return; - } - - pr_debug("pm121: %s Fan tick ! %s: %d.%03d\n", - loop_names[loop_id], sensor->name, - FIX32TOPRINT(temp)); - - new_setpoint = wf_pid_run(&st->pid, temp); - - /* correction */ - new_setpoint = pm121_correct(new_setpoint, - param->control_id, - st->pid.param.min); - /* linked corretion */ - new_setpoint = pm121_connect(param->control_id, new_setpoint); - - if (new_setpoint == st->setpoint) - return; - st->setpoint = new_setpoint; - pr_debug("pm121: %s corrected setpoint: %d RPM\n", - control->name, (int)new_setpoint); - readjust: - if (control && pm121_failure_state == 0) { - rc = control->ops->set_value(control, st->setpoint); - if (rc) { - printk(KERN_WARNING "windfarm: %s fan error %d\n", - control->name, rc); - pm121_failure_state |= FAILURE_FAN; - } - } -} - - -/* CPU LOOP */ -static void pm121_create_cpu_fans(void) -{ - struct wf_cpu_pid_param pid_param; - const struct smu_sdbp_header *hdr; - struct smu_sdbp_cpupiddata *piddata; - struct smu_sdbp_fvt *fvt; - struct wf_control *fan_cpu; - s32 tmax, tdelta, maxpow, powadj; - - fan_cpu = controls[FAN_CPU]; - - /* First, locate the PID params in SMU SBD */ - hdr = smu_get_sdb_partition(SMU_SDB_CPUPIDDATA_ID, NULL); - if (hdr == 0) { - printk(KERN_WARNING "pm121: CPU PID fan config not found.\n"); - goto fail; - } - piddata = (struct smu_sdbp_cpupiddata *)&hdr[1]; - - /* Get the FVT params for operating point 0 (the only supported one - * for now) in order to get tmax - */ - hdr = smu_get_sdb_partition(SMU_SDB_FVT_ID, NULL); - if (hdr) { - fvt = (struct smu_sdbp_fvt *)&hdr[1]; - tmax = ((s32)fvt->maxtemp) << 16; - } else - tmax = 0x5e0000; /* 94 degree default */ - - /* Alloc & initialize state */ - pm121_cpu_state = kmalloc(sizeof(struct pm121_cpu_state), - GFP_KERNEL); - if (pm121_cpu_state == NULL) - goto fail; - pm121_cpu_state->ticks = 1; - - /* Fill PID params */ - pid_param.interval = PM121_CPU_INTERVAL; - pid_param.history_len = piddata->history_len; - if (pid_param.history_len > WF_CPU_PID_MAX_HISTORY) { - printk(KERN_WARNING "pm121: History size overflow on " - "CPU control loop (%d)\n", piddata->history_len); - pid_param.history_len = WF_CPU_PID_MAX_HISTORY; - } - pid_param.gd = piddata->gd; - pid_param.gp = piddata->gp; - pid_param.gr = piddata->gr / pid_param.history_len; - - tdelta = ((s32)piddata->target_temp_delta) << 16; - maxpow = ((s32)piddata->max_power) << 16; - powadj = ((s32)piddata->power_adj) << 16; - - pid_param.tmax = tmax; - pid_param.ttarget = tmax - tdelta; - pid_param.pmaxadj = maxpow - powadj; - - pid_param.min = fan_cpu->ops->get_min(fan_cpu); - pid_param.max = fan_cpu->ops->get_max(fan_cpu); - - wf_cpu_pid_init(&pm121_cpu_state->pid, &pid_param); - - pr_debug("pm121: CPU Fan control initialized.\n"); - pr_debug(" ttarged=%d.%03d, tmax=%d.%03d, min=%d RPM, max=%d RPM,\n", - FIX32TOPRINT(pid_param.ttarget), FIX32TOPRINT(pid_param.tmax), - pid_param.min, pid_param.max); - - return; - - fail: - printk(KERN_WARNING "pm121: CPU fan config not found, max fan speed\n"); - - if (controls[CPUFREQ]) - wf_control_set_max(controls[CPUFREQ]); - if (fan_cpu) - wf_control_set_max(fan_cpu); -} - - -static void pm121_cpu_fans_tick(struct pm121_cpu_state *st) -{ - s32 new_setpoint, temp, power; - struct wf_control *fan_cpu = NULL; - int rc; - - if (--st->ticks != 0) { - if (pm121_readjust) - goto readjust; - return; - } - st->ticks = PM121_CPU_INTERVAL; - - fan_cpu = controls[FAN_CPU]; - - rc = sensor_cpu_temp->ops->get_value(sensor_cpu_temp, &temp); - if (rc) { - printk(KERN_WARNING "pm121: CPU temp sensor error %d\n", - rc); - pm121_failure_state |= FAILURE_SENSOR; - return; - } - - rc = sensor_cpu_power->ops->get_value(sensor_cpu_power, &power); - if (rc) { - printk(KERN_WARNING "pm121: CPU power sensor error %d\n", - rc); - pm121_failure_state |= FAILURE_SENSOR; - return; - } - - pr_debug("pm121: CPU Fans tick ! CPU temp: %d.%03d°C, power: %d.%03d\n", - FIX32TOPRINT(temp), FIX32TOPRINT(power)); - - if (temp > st->pid.param.tmax) - pm121_failure_state |= FAILURE_OVERTEMP; - - new_setpoint = wf_cpu_pid_run(&st->pid, power, temp); - - /* correction */ - new_setpoint = pm121_correct(new_setpoint, - FAN_CPU, - st->pid.param.min); - - /* connected correction */ - new_setpoint = pm121_connect(FAN_CPU, new_setpoint); - - if (st->setpoint == new_setpoint) - return; - st->setpoint = new_setpoint; - pr_debug("pm121: CPU corrected setpoint: %d RPM\n", (int)new_setpoint); - - readjust: - if (fan_cpu && pm121_failure_state == 0) { - rc = fan_cpu->ops->set_value(fan_cpu, st->setpoint); - if (rc) { - printk(KERN_WARNING "pm121: %s fan error %d\n", - fan_cpu->name, rc); - pm121_failure_state |= FAILURE_FAN; - } - } -} - -/* - * ****** Common ****** - * - */ - -static void pm121_tick(void) -{ - unsigned int last_failure = pm121_failure_state; - unsigned int new_failure; - s32 total_power; - int i; - - if (!pm121_started) { - pr_debug("pm121: creating control loops !\n"); - for (i = 0; i < N_LOOPS; i++) - pm121_create_sys_fans(i); - - pm121_create_cpu_fans(); - pm121_started = 1; - } - - /* skipping ticks */ - if (pm121_skipping && --pm121_skipping) - return; - - /* compute average power */ - total_power = 0; - for (i = 0; i < pm121_cpu_state->pid.param.history_len; i++) - total_power += pm121_cpu_state->pid.powers[i]; - - average_power = total_power / pm121_cpu_state->pid.param.history_len; - - - pm121_failure_state = 0; - for (i = 0 ; i < N_LOOPS; i++) { - if (pm121_sys_state[i]) - pm121_sys_fans_tick(i); - } - - if (pm121_cpu_state) - pm121_cpu_fans_tick(pm121_cpu_state); - - pm121_readjust = 0; - new_failure = pm121_failure_state & ~last_failure; - - /* If entering failure mode, clamp cpufreq and ramp all - * fans to full speed. - */ - if (pm121_failure_state && !last_failure) { - for (i = 0; i < N_CONTROLS; i++) { - if (controls[i]) - wf_control_set_max(controls[i]); - } - } - - /* If leaving failure mode, unclamp cpufreq and readjust - * all fans on next iteration - */ - if (!pm121_failure_state && last_failure) { - if (controls[CPUFREQ]) - wf_control_set_min(controls[CPUFREQ]); - pm121_readjust = 1; - } - - /* Overtemp condition detected, notify and start skipping a couple - * ticks to let the temperature go down - */ - if (new_failure & FAILURE_OVERTEMP) { - wf_set_overtemp(); - pm121_skipping = 2; - } - - /* We only clear the overtemp condition if overtemp is cleared - * _and_ no other failure is present. Since a sensor error will - * clear the overtemp condition (can't measure temperature) at - * the control loop levels, but we don't want to keep it clear - * here in this case - */ - if (new_failure == 0 && last_failure & FAILURE_OVERTEMP) - wf_clear_overtemp(); -} - - -static struct wf_control* pm121_register_control(struct wf_control *ct, - const char *match, - unsigned int id) -{ - if (controls[id] == NULL && !strcmp(ct->name, match)) { - if (wf_get_control(ct) == 0) - controls[id] = ct; - } - return controls[id]; -} - -static void pm121_new_control(struct wf_control *ct) -{ - int all = 1; - - if (pm121_all_controls_ok) - return; - - all = pm121_register_control(ct, "optical-drive-fan", FAN_OD) && all; - all = pm121_register_control(ct, "hard-drive-fan", FAN_HD) && all; - all = pm121_register_control(ct, "cpu-fan", FAN_CPU) && all; - all = pm121_register_control(ct, "cpufreq-clamp", CPUFREQ) && all; - - if (all) - pm121_all_controls_ok = 1; -} - - - - -static struct wf_sensor* pm121_register_sensor(struct wf_sensor *sensor, - const char *match, - struct wf_sensor **var) -{ - if (*var == NULL && !strcmp(sensor->name, match)) { - if (wf_get_sensor(sensor) == 0) - *var = sensor; - } - return *var; -} - -static void pm121_new_sensor(struct wf_sensor *sr) -{ - int all = 1; - - if (pm121_all_sensors_ok) - return; - - all = pm121_register_sensor(sr, "cpu-temp", - &sensor_cpu_temp) && all; - all = pm121_register_sensor(sr, "cpu-current", - &sensor_cpu_current) && all; - all = pm121_register_sensor(sr, "cpu-voltage", - &sensor_cpu_voltage) && all; - all = pm121_register_sensor(sr, "cpu-power", - &sensor_cpu_power) && all; - all = pm121_register_sensor(sr, "hard-drive-temp", - &sensor_hard_drive_temp) && all; - all = pm121_register_sensor(sr, "optical-drive-temp", - &sensor_optical_drive_temp) && all; - all = pm121_register_sensor(sr, "incoming-air-temp", - &sensor_incoming_air_temp) && all; - all = pm121_register_sensor(sr, "north-bridge-temp", - &sensor_north_bridge_temp) && all; - all = pm121_register_sensor(sr, "gpu-temp", - &sensor_gpu_temp) && all; - - if (all) - pm121_all_sensors_ok = 1; -} - - - -static int pm121_notify(struct notifier_block *self, - unsigned long event, void *data) -{ - switch (event) { - case WF_EVENT_NEW_CONTROL: - pr_debug("pm121: new control %s detected\n", - ((struct wf_control *)data)->name); - pm121_new_control(data); - break; - case WF_EVENT_NEW_SENSOR: - pr_debug("pm121: new sensor %s detected\n", - ((struct wf_sensor *)data)->name); - pm121_new_sensor(data); - break; - case WF_EVENT_TICK: - if (pm121_all_controls_ok && pm121_all_sensors_ok) - pm121_tick(); - break; - } - - return 0; -} - -static struct notifier_block pm121_events = { - .notifier_call = pm121_notify, -}; - -static int pm121_init_pm(void) -{ - const struct smu_sdbp_header *hdr; - - hdr = smu_get_sdb_partition(SMU_SDB_SENSORTREE_ID, NULL); - if (hdr != 0) { - struct smu_sdbp_sensortree *st = - (struct smu_sdbp_sensortree *)&hdr[1]; - pm121_mach_model = st->model_id; - } - - pm121_connection = &pm121_connections[pm121_mach_model - 2]; - - printk(KERN_INFO "pm121: Initializing for iMac G5 iSight model ID %d\n", - pm121_mach_model); - - return 0; -} - - -static int pm121_probe(struct platform_device *ddev) -{ - wf_register_client(&pm121_events); - - return 0; -} - -static int __devexit pm121_remove(struct platform_device *ddev) -{ - wf_unregister_client(&pm121_events); - return 0; -} - -static struct platform_driver pm121_driver = { - .probe = pm121_probe, - .remove = __devexit_p(pm121_remove), - .driver = { - .name = "windfarm", - .bus = &platform_bus_type, - }, -}; - - -static int __init pm121_init(void) -{ - int rc = -ENODEV; - - if (machine_is_compatible("PowerMac12,1")) - rc = pm121_init_pm(); - - if (rc == 0) { - request_module("windfarm_smu_controls"); - request_module("windfarm_smu_sensors"); - request_module("windfarm_smu_sat"); - request_module("windfarm_lm75_sensor"); - request_module("windfarm_max6690_sensor"); - request_module("windfarm_cpufreq_clamp"); - platform_driver_register(&pm121_driver); - } - - return rc; -} - -static void __exit pm121_exit(void) -{ - - platform_driver_unregister(&pm121_driver); -} - - -module_init(pm121_init); -module_exit(pm121_exit); - -MODULE_AUTHOR("Étienne Bersac "); -MODULE_DESCRIPTION("Thermal control logic for iMac G5 (iSight)"); -MODULE_LICENSE("GPL"); - diff --git a/trunk/drivers/macintosh/windfarm_smu_controls.c b/trunk/drivers/macintosh/windfarm_smu_controls.c index 961fa0e7c2cf..58c2590f05ec 100644 --- a/trunk/drivers/macintosh/windfarm_smu_controls.c +++ b/trunk/drivers/macintosh/windfarm_smu_controls.c @@ -218,10 +218,6 @@ static struct smu_fan_control *smu_fan_create(struct device_node *node, fct->ctrl.name = "cpu-fan"; else if (!strcmp(l, "Hard Drive") || !strcmp(l, "Hard drive")) fct->ctrl.name = "drive-bay-fan"; - else if (!strcmp(l, "HDD Fan")) /* seen on iMac G5 iSight */ - fct->ctrl.name = "hard-drive-fan"; - else if (!strcmp(l, "ODD Fan")) /* same */ - fct->ctrl.name = "optical-drive-fan"; /* Unrecognized fan, bail out */ if (fct->ctrl.name == NULL) diff --git a/trunk/drivers/mca/mca-legacy.c b/trunk/drivers/mca/mca-legacy.c index 494f0c2001f5..0c7bfa74c8ef 100644 --- a/trunk/drivers/mca/mca-legacy.c +++ b/trunk/drivers/mca/mca-legacy.c @@ -281,6 +281,24 @@ void mca_set_adapter_name(int slot, char* name) } EXPORT_SYMBOL(mca_set_adapter_name); +/** + * mca_is_adapter_used - check if claimed by driver + * @slot: slot to check + * + * Returns 1 if the slot has been claimed by a driver + */ + +int mca_is_adapter_used(int slot) +{ + struct mca_device *mca_dev = mca_find_device_by_slot(slot); + + if(!mca_dev) + return 0; + + return mca_device_claimed(mca_dev); +} +EXPORT_SYMBOL(mca_is_adapter_used); + /** * mca_mark_as_used - claim an MCA device * @slot: slot to claim diff --git a/trunk/drivers/mca/mca-proc.c b/trunk/drivers/mca/mca-proc.c index 81ea0d377bf4..33d5e0820cc5 100644 --- a/trunk/drivers/mca/mca-proc.c +++ b/trunk/drivers/mca/mca-proc.c @@ -183,7 +183,7 @@ void __init mca_do_proc_init(void) struct proc_dir_entry* node = NULL; struct mca_device *mca_dev; - proc_mca = proc_mkdir("mca", NULL); + proc_mca = proc_mkdir("mca", &proc_root); create_proc_read_entry("pos",0,proc_mca,get_mca_info,NULL); create_proc_read_entry("machine",0,proc_mca,get_mca_machine_info,NULL); diff --git a/trunk/drivers/md/dm-emc.c b/trunk/drivers/md/dm-emc.c index 3ea5ad4b7805..6b91b9ab1d41 100644 --- a/trunk/drivers/md/dm-emc.c +++ b/trunk/drivers/md/dm-emc.c @@ -110,6 +110,8 @@ static struct request *get_failover_req(struct emc_handler *h, memset(rq->sense, 0, SCSI_SENSE_BUFFERSIZE); rq->sense_len = 0; + memset(&rq->cmd, 0, BLK_MAX_CDB); + rq->timeout = EMC_FAILOVER_TIMEOUT; rq->cmd_type = REQ_TYPE_BLOCK_PC; rq->cmd_flags |= REQ_FAILFAST | REQ_NOMERGE; diff --git a/trunk/drivers/md/dm-mpath-hp-sw.c b/trunk/drivers/md/dm-mpath-hp-sw.c index b63a0ab37c53..204bf42c9449 100644 --- a/trunk/drivers/md/dm-mpath-hp-sw.c +++ b/trunk/drivers/md/dm-mpath-hp-sw.c @@ -137,6 +137,7 @@ static struct request *hp_sw_get_request(struct dm_path *path) req->sense = h->sense; memset(req->sense, 0, SCSI_SENSE_BUFFERSIZE); + memset(&req->cmd, 0, BLK_MAX_CDB); req->cmd[0] = START_STOP; req->cmd[4] = 1; req->cmd_len = COMMAND_SIZE(req->cmd[0]); diff --git a/trunk/drivers/md/dm-mpath-rdac.c b/trunk/drivers/md/dm-mpath-rdac.c index 95e77734880a..e04eb5c697fb 100644 --- a/trunk/drivers/md/dm-mpath-rdac.c +++ b/trunk/drivers/md/dm-mpath-rdac.c @@ -284,6 +284,7 @@ static struct request *get_rdac_req(struct rdac_handler *h, return NULL; } + memset(&rq->cmd, 0, BLK_MAX_CDB); rq->sense = h->sense; memset(rq->sense, 0, SCSI_SENSE_BUFFERSIZE); rq->sense_len = 0; diff --git a/trunk/drivers/md/dm-table.c b/trunk/drivers/md/dm-table.c index 94116eaf4709..51be53344214 100644 --- a/trunk/drivers/md/dm-table.c +++ b/trunk/drivers/md/dm-table.c @@ -873,11 +873,10 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q) q->max_hw_sectors = t->limits.max_hw_sectors; q->seg_boundary_mask = t->limits.seg_boundary_mask; q->bounce_pfn = t->limits.bounce_pfn; - if (t->limits.no_cluster) - queue_flag_clear_unlocked(QUEUE_FLAG_CLUSTER, q); + q->queue_flags &= ~(1 << QUEUE_FLAG_CLUSTER); else - queue_flag_set_unlocked(QUEUE_FLAG_CLUSTER, q); + q->queue_flags |= (1 << QUEUE_FLAG_CLUSTER); } diff --git a/trunk/drivers/md/md.c b/trunk/drivers/md/md.c index bb3e4b1cb773..87620b705bee 100644 --- a/trunk/drivers/md/md.c +++ b/trunk/drivers/md/md.c @@ -282,8 +282,7 @@ static mddev_t * mddev_find(dev_t unit) kfree(new); return NULL; } - /* Can be unlocked because the queue is new: no concurrency */ - queue_flag_set_unlocked(QUEUE_FLAG_CLUSTER, new->queue); + set_bit(QUEUE_FLAG_CLUSTER, &new->queue->queue_flags); blk_queue_make_request(new->queue, md_fail_request); @@ -5948,9 +5947,13 @@ static struct notifier_block md_notifier = { static void md_geninit(void) { + struct proc_dir_entry *p; + dprintk("md: sizeof(mdp_super_t) = %d\n", (int)sizeof(mdp_super_t)); - proc_create("mdstat", S_IRUGO, NULL, &md_seq_fops); + p = create_proc_entry("mdstat", S_IRUGO, NULL); + if (p) + p->proc_fops = &md_seq_fops; } static int __init md_init(void) diff --git a/trunk/drivers/media/Kconfig b/trunk/drivers/media/Kconfig index ddf57e135c6c..128bb9cd5755 100644 --- a/trunk/drivers/media/Kconfig +++ b/trunk/drivers/media/Kconfig @@ -5,20 +5,16 @@ menu "Multimedia devices" depends on HAS_IOMEM -comment "Multimedia core support" - -# -# V4L core and enabled API's -# - config VIDEO_DEV tristate "Video For Linux" ---help--- - V4L core support for video capture and overlay devices, webcams and - AM/FM radio cards. + Support for audio/video capture and overlay devices and FM radio + cards. The exact capabilities of each device vary. This kernel includes support for the new Video for Linux Two API, - (V4L2). + (V4L2) as well as the original system. Drivers and applications + need to be rewritten to use V4L2, but drivers for popular cards + and applications for most video capture functions already exist. Additional info and docs are available on the web at @@ -40,11 +36,8 @@ config VIDEO_ALLOW_V4L1 default VIDEO_DEV && VIDEO_V4L2_COMMON select VIDEO_V4L1_COMPAT ---help--- - Enables drivers based on the legacy V4L1 API. - - This api were developed to be used at Kernel 2.2 and 2.4, but - lacks support for several video standards. There are several - drivers at kernel that still depends on it. + Enables a compatibility API used by most V4L2 devices to allow + its usage with legacy applications that supports only V4L1 api. If you are unsure as to whether this is required, answer Y. @@ -53,8 +46,9 @@ config VIDEO_V4L1_COMPAT depends on VIDEO_DEV default VIDEO_DEV ---help--- - Enables a compatibility API used by most V4L2 devices to allow - its usage with legacy applications that supports only V4L1 api. + This api were developed to be used at Kernel 2.2 and 2.4, but + lacks support for several video standards. There are several + drivers at kernel that still depends on it. Documentation for the original API is included in the file . @@ -64,57 +58,135 @@ config VIDEO_V4L1_COMPAT If you are unsure as to whether this is required, answer Y. -# -# DVB Core -# +config VIDEO_V4L2 + tristate + depends on VIDEO_DEV && VIDEO_V4L2_COMMON + default VIDEO_DEV && VIDEO_V4L2_COMMON -config DVB_CORE - tristate "DVB for Linux" - depends on NET && INET - select CRC32 - help - DVB core utility functions for device handling, software fallbacks etc. +config VIDEO_V4L1 + tristate + depends on VIDEO_DEV && VIDEO_V4L2_COMMON && VIDEO_ALLOW_V4L1 + default VIDEO_DEV && VIDEO_V4L2_COMMON && VIDEO_ALLOW_V4L1 - Enable this if you own a DVB/ATSC adapter and want to use it or if - you compile Linux for a digital SetTopBox. +source "drivers/media/video/Kconfig" - Say Y when you have a DVB or an ATSC card and want to use it. +source "drivers/media/radio/Kconfig" - API specs and user tools are available from . +source "drivers/media/dvb/Kconfig" - Please report problems regarding this support to the LinuxDVB - mailing list. +source "drivers/media/common/Kconfig" + +config VIDEO_TUNER + tristate + depends on I2C + select TUNER_XC2028 if !VIDEO_TUNER_CUSTOMIZE + select TUNER_MT20XX if !VIDEO_TUNER_CUSTOMIZE + select TUNER_TDA8290 if !VIDEO_TUNER_CUSTOMIZE + select TUNER_TEA5761 if !VIDEO_TUNER_CUSTOMIZE + select TUNER_TEA5767 if !VIDEO_TUNER_CUSTOMIZE + select TUNER_SIMPLE if !VIDEO_TUNER_CUSTOMIZE + select TUNER_TDA9887 if !VIDEO_TUNER_CUSTOMIZE + +menuconfig VIDEO_TUNER_CUSTOMIZE + bool "Customize analog tuner modules to build" + depends on VIDEO_TUNER + help + This allows the user to deselect tuner drivers unnecessary + for their hardware from the build. Use this option with care + as deselecting tuner drivers which are in fact necessary will + result in V4L devices which cannot be tuned due to lack of + driver support If unsure say N. -config VIDEO_MEDIA - tristate - default DVB_CORE || VIDEO_DEV - depends on DVB_CORE || VIDEO_DEV +if VIDEO_TUNER_CUSTOMIZE -comment "Multimedia drivers" +config TUNER_XC2028 + tristate "XCeive xc2028/xc3028 tuners" + depends on I2C && FW_LOADER + default m if VIDEO_TUNER_CUSTOMIZE + help + Say Y here to include support for the xc2028/xc3028 tuners. -source "drivers/media/common/Kconfig" +config TUNER_MT20XX + tristate "Microtune 2032 / 2050 tuners" + depends on I2C + default m if VIDEO_TUNER_CUSTOMIZE + help + Say Y here to include support for the MT2032 / MT2050 tuner. + +config TUNER_TDA8290 + tristate "TDA 8290/8295 + 8275(a)/18271 tuner combo" + depends on I2C + select DVB_TDA827X + select DVB_TDA18271 + default m if VIDEO_TUNER_CUSTOMIZE + help + Say Y here to include support for Philips TDA8290+8275(a) tuner. -# -# Tuner drivers for DVB and V4L -# +config TUNER_TEA5761 + tristate "TEA 5761 radio tuner (EXPERIMENTAL)" + depends on I2C && EXPERIMENTAL + default m if VIDEO_TUNER_CUSTOMIZE + help + Say Y here to include support for the Philips TEA5761 radio tuner. -source "drivers/media/common/tuners/Kconfig" +config TUNER_TEA5767 + tristate "TEA 5767 radio tuner" + depends on I2C + default m if VIDEO_TUNER_CUSTOMIZE + help + Say Y here to include support for the Philips TEA5767 radio tuner. -# -# Video/Radio/Hybrid adapters -# +config TUNER_SIMPLE + tristate "Simple tuner support" + depends on I2C + select TUNER_TDA9887 + default m if VIDEO_TUNER_CUSTOMIZE + help + Say Y here to include support for various simple tuners. -source "drivers/media/video/Kconfig" +config TUNER_TDA9887 + tristate "TDA 9885/6/7 analog IF demodulator" + depends on I2C + default m if VIDEO_TUNER_CUSTOMIZE + help + Say Y here to include support for Philips TDA9885/6/7 + analog IF demodulator. -source "drivers/media/radio/Kconfig" +endif # VIDEO_TUNER_CUSTOMIZE -# -# DVB adapters -# +config VIDEOBUF_GEN + tristate -source "drivers/media/dvb/Kconfig" +config VIDEOBUF_DMA_SG + depends on HAS_DMA + select VIDEOBUF_GEN + tristate + +config VIDEOBUF_VMALLOC + select VIDEOBUF_GEN + tristate + +config VIDEOBUF_DVB + tristate + select VIDEOBUF_GEN + select VIDEOBUF_DMA_SG + +config VIDEO_BTCX + tristate + +config VIDEO_IR_I2C + tristate + +config VIDEO_IR + tristate + depends on INPUT + select VIDEO_IR_I2C if I2C + +config VIDEO_TVEEPROM + tristate + depends on I2C config DAB boolean "DAB adapters" diff --git a/trunk/drivers/media/Makefile b/trunk/drivers/media/Makefile index 73f742c7e818..7b8bb6949f5e 100644 --- a/trunk/drivers/media/Makefile +++ b/trunk/drivers/media/Makefile @@ -2,10 +2,10 @@ # Makefile for the kernel multimedia device drivers. # -obj-$(CONFIG_VIDEO_MEDIA) += common/ - -# Since hybrid devices are here, should be compiled if DVB and/or V4L -obj-$(CONFIG_VIDEO_MEDIA) += video/ - +obj-y := common/ +obj-y += video/ obj-$(CONFIG_VIDEO_DEV) += radio/ obj-$(CONFIG_DVB_CORE) += dvb/ +ifeq ($(CONFIG_DVB_CORE),) + obj-$(CONFIG_VIDEO_TUNER) += dvb/frontends/ +endif diff --git a/trunk/drivers/media/common/tuners/Kconfig b/trunk/drivers/media/common/tuners/Kconfig deleted file mode 100644 index 7b379e1ce01b..000000000000 --- a/trunk/drivers/media/common/tuners/Kconfig +++ /dev/null @@ -1,146 +0,0 @@ -config MEDIA_ATTACH - bool "Load and attach frontend driver modules as needed" - depends on DVB_CORE - depends on MODULES - help - Remove the static dependency of DVB card drivers on all - frontend modules for all possible card variants. Instead, - allow the card drivers to only load the frontend modules - they require. This saves several KBytes of memory. - - Note: You will need module-init-tools v3.2 or later for this feature. - - If unsure say Y. - -config MEDIA_TUNER - tristate - default DVB_CORE || VIDEO_DEV - depends on DVB_CORE || VIDEO_DEV - select MEDIA_TUNER_XC2028 if !MEDIA_TUNER_CUSTOMIZE - select MEDIA_TUNER_XC5000 if !MEDIA_TUNER_CUSTOMIZE - select MEDIA_TUNER_MT20XX if !MEDIA_TUNER_CUSTOMIZE - select MEDIA_TUNER_TDA8290 if !MEDIA_TUNER_CUSTOMIZE - select MEDIA_TUNER_TEA5761 if !MEDIA_TUNER_CUSTOMIZE - select MEDIA_TUNER_TEA5767 if !MEDIA_TUNER_CUSTOMIZE - select MEDIA_TUNER_SIMPLE if !MEDIA_TUNER_CUSTOMIZE - select MEDIA_TUNER_TDA9887 if !MEDIA_TUNER_CUSTOMIZE - -menuconfig MEDIA_TUNER_CUSTOMIZE - bool "Customize analog and hybrid tuner modules to build" - depends on MEDIA_TUNER - help - This allows the user to deselect tuner drivers unnecessary - for their hardware from the build. Use this option with care - as deselecting tuner drivers which are in fact necessary will - result in V4L/DVB devices which cannot be tuned due to lack of - driver support - - If unsure say N. - -if MEDIA_TUNER_CUSTOMIZE - -config MEDIA_TUNER_SIMPLE - tristate "Simple tuner support" - depends on I2C - select MEDIA_TUNER_TDA9887 - default m if MEDIA_TUNER_CUSTOMIZE - help - Say Y here to include support for various simple tuners. - -config MEDIA_TUNER_TDA8290 - tristate "TDA 8290/8295 + 8275(a)/18271 tuner combo" - depends on I2C - select MEDIA_TUNER_TDA827X - select MEDIA_TUNER_TDA18271 - default m if MEDIA_TUNER_CUSTOMIZE - help - Say Y here to include support for Philips TDA8290+8275(a) tuner. - -config MEDIA_TUNER_TDA827X - tristate "Philips TDA827X silicon tuner" - depends on DVB_CORE && I2C - default m if DVB_FE_CUSTOMISE - help - A DVB-T silicon tuner module. Say Y when you want to support this tuner. - -config MEDIA_TUNER_TDA18271 - tristate "NXP TDA18271 silicon tuner" - depends on I2C - default m if DVB_FE_CUSTOMISE - help - A silicon tuner module. Say Y when you want to support this tuner. - -config MEDIA_TUNER_TDA9887 - tristate "TDA 9885/6/7 analog IF demodulator" - depends on I2C - default m if MEDIA_TUNER_CUSTOMIZE - help - Say Y here to include support for Philips TDA9885/6/7 - analog IF demodulator. - -config MEDIA_TUNER_TEA5761 - tristate "TEA 5761 radio tuner (EXPERIMENTAL)" - depends on I2C && EXPERIMENTAL - default m if MEDIA_TUNER_CUSTOMIZE - help - Say Y here to include support for the Philips TEA5761 radio tuner. - -config MEDIA_TUNER_TEA5767 - tristate "TEA 5767 radio tuner" - depends on I2C - default m if MEDIA_TUNER_CUSTOMIZE - help - Say Y here to include support for the Philips TEA5767 radio tuner. - -config MEDIA_TUNER_MT20XX - tristate "Microtune 2032 / 2050 tuners" - depends on I2C - default m if MEDIA_TUNER_CUSTOMIZE - help - Say Y here to include support for the MT2032 / MT2050 tuner. - -config MEDIA_TUNER_MT2060 - tristate "Microtune MT2060 silicon IF tuner" - depends on I2C - default m if DVB_FE_CUSTOMISE - help - A driver for the silicon IF tuner MT2060 from Microtune. - -config MEDIA_TUNER_MT2266 - tristate "Microtune MT2266 silicon tuner" - depends on I2C - default m if DVB_FE_CUSTOMISE - help - A driver for the silicon baseband tuner MT2266 from Microtune. - -config MEDIA_TUNER_MT2131 - tristate "Microtune MT2131 silicon tuner" - depends on I2C - default m if DVB_FE_CUSTOMISE - help - A driver for the silicon baseband tuner MT2131 from Microtune. - -config MEDIA_TUNER_QT1010 - tristate "Quantek QT1010 silicon tuner" - depends on DVB_CORE && I2C - default m if DVB_FE_CUSTOMISE - help - A driver for the silicon tuner QT1010 from Quantek. - -config MEDIA_TUNER_XC2028 - tristate "XCeive xc2028/xc3028 tuners" - depends on I2C && FW_LOADER - default m if MEDIA_TUNER_CUSTOMIZE - help - Say Y here to include support for the xc2028/xc3028 tuners. - -config MEDIA_TUNER_XC5000 - tristate "Xceive XC5000 silicon tuner" - depends on I2C - default m if DVB_FE_CUSTOMISE - help - A driver for the silicon tuner XC5000 from Xceive. - This device is only used inside a SiP called togther with a - demodulator for now. - -endif # MEDIA_TUNER_CUSTOMIZE diff --git a/trunk/drivers/media/common/tuners/Makefile b/trunk/drivers/media/common/tuners/Makefile deleted file mode 100644 index 236d9932fd92..000000000000 --- a/trunk/drivers/media/common/tuners/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -# -# Makefile for common V4L/DVB tuners -# - -tda18271-objs := tda18271-maps.o tda18271-common.o tda18271-fe.o - -obj-$(CONFIG_MEDIA_TUNER_XC2028) += tuner-xc2028.o -obj-$(CONFIG_MEDIA_TUNER_SIMPLE) += tuner-simple.o -# tuner-types will be merged into tuner-simple, in the future -obj-$(CONFIG_MEDIA_TUNER_SIMPLE) += tuner-types.o -obj-$(CONFIG_MEDIA_TUNER_MT20XX) += mt20xx.o -obj-$(CONFIG_MEDIA_TUNER_TDA8290) += tda8290.o -obj-$(CONFIG_MEDIA_TUNER_TEA5767) += tea5767.o -obj-$(CONFIG_MEDIA_TUNER_TEA5761) += tea5761.o -obj-$(CONFIG_MEDIA_TUNER_TDA9887) += tda9887.o -obj-$(CONFIG_MEDIA_TUNER_TDA827X) += tda827x.o -obj-$(CONFIG_MEDIA_TUNER_TDA18271) += tda18271.o -obj-$(CONFIG_MEDIA_TUNER_XC5000) += xc5000.o -obj-$(CONFIG_MEDIA_TUNER_MT2060) += mt2060.o -obj-$(CONFIG_MEDIA_TUNER_MT2266) += mt2266.o -obj-$(CONFIG_MEDIA_TUNER_QT1010) += qt1010.o -obj-$(CONFIG_MEDIA_TUNER_MT2131) += mt2131.o - -EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core -EXTRA_CFLAGS += -Idrivers/media/dvb/frontends diff --git a/trunk/drivers/media/dvb/Kconfig b/trunk/drivers/media/dvb/Kconfig index 7b21b49f1945..03ef88acd9b8 100644 --- a/trunk/drivers/media/dvb/Kconfig +++ b/trunk/drivers/media/dvb/Kconfig @@ -1,7 +1,9 @@ # -# DVB device configuration +# Multimedia device configuration # +source "drivers/media/dvb/dvb-core/Kconfig" + menuconfig DVB_CAPTURE_DRIVERS bool "DVB/ATSC adapters" depends on DVB_CORE diff --git a/trunk/drivers/media/dvb/b2c2/Kconfig b/trunk/drivers/media/dvb/b2c2/Kconfig index 73dc2ee9b014..6ec5afba1ca7 100644 --- a/trunk/drivers/media/dvb/b2c2/Kconfig +++ b/trunk/drivers/media/dvb/b2c2/Kconfig @@ -9,7 +9,7 @@ config DVB_B2C2_FLEXCOP select DVB_STV0297 if !DVB_FE_CUSTOMISE select DVB_BCM3510 if !DVB_FE_CUSTOMISE select DVB_LGDT330X if !DVB_FE_CUSTOMISE - select MEDIA_TUNER_SIMPLE if !DVB_FE_CUSTOMISE + select TUNER_SIMPLE if !DVB_FE_CUSTOMISE select DVB_S5H1420 if !DVB_FE_CUSTOMISE select DVB_TUNER_ITD1000 if !DVB_FE_CUSTOMISE select DVB_ISL6421 if !DVB_FE_CUSTOMISE diff --git a/trunk/drivers/media/dvb/b2c2/Makefile b/trunk/drivers/media/dvb/b2c2/Makefile index d9db066f9854..870e2848c296 100644 --- a/trunk/drivers/media/dvb/b2c2/Makefile +++ b/trunk/drivers/media/dvb/b2c2/Makefile @@ -14,4 +14,4 @@ b2c2-flexcop-usb-objs = flexcop-usb.o obj-$(CONFIG_DVB_B2C2_FLEXCOP_USB) += b2c2-flexcop-usb.o EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ -EXTRA_CFLAGS += -Idrivers/media/common/tuners/ +EXTRA_CFLAGS += -Idrivers/media/video/ diff --git a/trunk/drivers/media/dvb/bt8xx/Kconfig b/trunk/drivers/media/dvb/bt8xx/Kconfig index d1239b8342f8..902c762e0b7f 100644 --- a/trunk/drivers/media/dvb/bt8xx/Kconfig +++ b/trunk/drivers/media/dvb/bt8xx/Kconfig @@ -8,7 +8,7 @@ config DVB_BT8XX select DVB_OR51211 if !DVB_FE_CUSTOMISE select DVB_LGDT330X if !DVB_FE_CUSTOMISE select DVB_ZL10353 if !DVB_FE_CUSTOMISE - select MEDIA_TUNER_SIMPLE if !DVB_FE_CUSTOMISE + select TUNER_SIMPLE if !DVB_FE_CUSTOMISE select FW_LOADER help Support for PCI cards based on the Bt8xx PCI bridge. Examples are diff --git a/trunk/drivers/media/dvb/bt8xx/Makefile b/trunk/drivers/media/dvb/bt8xx/Makefile index d98f1d49ffa8..9d3e68b5d6eb 100644 --- a/trunk/drivers/media/dvb/bt8xx/Makefile +++ b/trunk/drivers/media/dvb/bt8xx/Makefile @@ -3,4 +3,4 @@ obj-$(CONFIG_DVB_BT8XX) += bt878.o dvb-bt8xx.o dst.o dst_ca.o EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core EXTRA_CFLAGS += -Idrivers/media/dvb/frontends EXTRA_CFLAGS += -Idrivers/media/video/bt8xx -EXTRA_CFLAGS += -Idrivers/media/common/tuners +EXTRA_CFLAGS += -Idrivers/media/video diff --git a/trunk/drivers/media/dvb/bt8xx/dst.c b/trunk/drivers/media/dvb/bt8xx/dst.c index a7637562e742..75711bde23ad 100644 --- a/trunk/drivers/media/dvb/bt8xx/dst.c +++ b/trunk/drivers/media/dvb/bt8xx/dst.c @@ -1714,7 +1714,7 @@ static void dst_release(struct dvb_frontend *fe) struct dst_state *state = fe->demodulator_priv; if (state->dst_ca) { dvb_unregister_device(state->dst_ca); -#ifdef CONFIG_MEDIA_ATTACH +#ifdef CONFIG_DVB_CORE_ATTACH symbol_put(dst_ca_attach); #endif } diff --git a/trunk/drivers/media/dvb/dvb-core/Kconfig b/trunk/drivers/media/dvb/dvb-core/Kconfig new file mode 100644 index 000000000000..e3e6839f8073 --- /dev/null +++ b/trunk/drivers/media/dvb/dvb-core/Kconfig @@ -0,0 +1,34 @@ +config DVB_CORE + tristate "DVB for Linux" + depends on NET && INET + select CRC32 + help + Support Digital Video Broadcasting hardware. Enable this if you + own a DVB adapter and want to use it or if you compile Linux for + a digital SetTopBox. + + DVB core utility functions for device handling, software fallbacks etc. + Say Y when you have a DVB card and want to use it. Say Y if your want + to build your drivers outside the kernel, but need the DVB core. All + in-kernel drivers will select this automatically if needed. + + API specs and user tools are available from . + + Please report problems regarding this driver to the LinuxDVB + mailing list. + + If unsure say N. + +config DVB_CORE_ATTACH + bool "Load and attach frontend modules as needed" + depends on DVB_CORE + depends on MODULES + help + Remove the static dependency of DVB card drivers on all + frontend modules for all possible card variants. Instead, + allow the card drivers to only load the frontend modules + they require. This saves several KBytes of memory. + + Note: You will need module-init-tools v3.2 or later for this feature. + + If unsure say Y. diff --git a/trunk/drivers/media/dvb/dvb-core/dvb_frontend.c b/trunk/drivers/media/dvb/dvb-core/dvb_frontend.c index 8cbdb218952f..2dddd08c5445 100644 --- a/trunk/drivers/media/dvb/dvb-core/dvb_frontend.c +++ b/trunk/drivers/media/dvb/dvb-core/dvb_frontend.c @@ -1189,7 +1189,7 @@ int dvb_unregister_frontend(struct dvb_frontend* fe) } EXPORT_SYMBOL(dvb_unregister_frontend); -#ifdef CONFIG_MEDIA_ATTACH +#ifdef CONFIG_DVB_CORE_ATTACH void dvb_frontend_detach(struct dvb_frontend* fe) { void *ptr; diff --git a/trunk/drivers/media/dvb/dvb-core/dvbdev.h b/trunk/drivers/media/dvb/dvb-core/dvbdev.h index 89d12dc477a7..5f9a737c6de1 100644 --- a/trunk/drivers/media/dvb/dvb-core/dvbdev.h +++ b/trunk/drivers/media/dvb/dvb-core/dvbdev.h @@ -115,7 +115,7 @@ extern int dvb_usercopy(struct inode *inode, struct file *file, unsigned int cmd, void *arg)); /** generic DVB attach function. */ -#ifdef CONFIG_MEDIA_ATTACH +#ifdef CONFIG_DVB_CORE_ATTACH #define dvb_attach(FUNCTION, ARGS...) ({ \ void *__r = NULL; \ typeof(&FUNCTION) __a = symbol_request(FUNCTION); \ diff --git a/trunk/drivers/media/dvb/dvb-usb/Kconfig b/trunk/drivers/media/dvb/dvb-usb/Kconfig index 4c1cff9feb2e..3c8493d2026d 100644 --- a/trunk/drivers/media/dvb/dvb-usb/Kconfig +++ b/trunk/drivers/media/dvb/dvb-usb/Kconfig @@ -25,7 +25,7 @@ config DVB_USB_A800 tristate "AVerMedia AverTV DVB-T USB 2.0 (A800)" depends on DVB_USB select DVB_DIB3000MC - select MEDIA_TUNER_MT2060 if !DVB_FE_CUSTOMISE + select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE select DVB_PLL if !DVB_FE_CUSTOMISE help Say Y here to support the AVerMedia AverTV DVB-T USB 2.0 (A800) receiver. @@ -35,7 +35,7 @@ config DVB_USB_DIBUSB_MB depends on DVB_USB select DVB_PLL if !DVB_FE_CUSTOMISE select DVB_DIB3000MB - select MEDIA_TUNER_MT2060 if !DVB_FE_CUSTOMISE + select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE help Support for USB 1.1 and 2.0 DVB-T receivers based on reference designs made by DiBcom () equipped with a DiB3000M-B demodulator. @@ -56,7 +56,7 @@ config DVB_USB_DIBUSB_MC tristate "DiBcom USB DVB-T devices (based on the DiB3000M-C/P) (see help for device list)" depends on DVB_USB select DVB_DIB3000MC - select MEDIA_TUNER_MT2060 if !DVB_FE_CUSTOMISE + select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE help Support for USB2.0 DVB-T receivers based on reference designs made by DiBcom () equipped with a DiB3000M-C/P demodulator. @@ -73,8 +73,8 @@ config DVB_USB_DIB0700 select DVB_DIB7000P select DVB_DIB7000M select DVB_DIB3000MC - select MEDIA_TUNER_MT2060 if !DVB_FE_CUSTOMISE - select MEDIA_TUNER_MT2266 if !DVB_FE_CUSTOMISE + select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE + select DVB_TUNER_MT2266 if !DVB_FE_CUSTOMISE select DVB_TUNER_DIB0070 help Support for USB2.0/1.1 DVB receivers based on the DiB0700 USB bridge. The @@ -93,7 +93,7 @@ config DVB_USB_UMT_010 depends on DVB_USB select DVB_PLL if !DVB_FE_CUSTOMISE select DVB_DIB3000MC - select MEDIA_TUNER_MT2060 if !DVB_FE_CUSTOMISE + select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE help Say Y here to support the HanfTek UMT-010 USB2.0 stick-sized DVB-T receiver. @@ -105,7 +105,7 @@ config DVB_USB_CXUSB select DVB_LGDT330X if !DVB_FE_CUSTOMISE select DVB_MT352 if !DVB_FE_CUSTOMISE select DVB_ZL10353 if !DVB_FE_CUSTOMISE - select MEDIA_TUNER_SIMPLE if !DVB_FE_CUSTOMISE + select TUNER_SIMPLE if !DVB_FE_CUSTOMISE help Say Y here to support the Conexant USB2.0 hybrid reference design. Currently, only DVB and ATSC modes are supported, analog mode @@ -118,7 +118,7 @@ config DVB_USB_M920X tristate "Uli m920x DVB-T USB2.0 support" depends on DVB_USB select DVB_MT352 if !DVB_FE_CUSTOMISE - select MEDIA_TUNER_QT1010 if !DVB_FE_CUSTOMISE + select DVB_TUNER_QT1010 if !DVB_FE_CUSTOMISE help Say Y here to support the MSI Mega Sky 580 USB2.0 DVB-T receiver. Currently, only devices with a product id of @@ -129,7 +129,7 @@ config DVB_USB_GL861 tristate "Genesys Logic GL861 USB2.0 support" depends on DVB_USB select DVB_ZL10353 if !DVB_FE_CUSTOMISE - select MEDIA_TUNER_QT1010 if !DVB_FE_CUSTOMISE + select DVB_TUNER_QT1010 if !DVB_FE_CUSTOMISE help Say Y here to support the MSI Megasky 580 (55801) DVB-T USB2.0 receiver with USB ID 0db0:5581. @@ -138,7 +138,7 @@ config DVB_USB_AU6610 tristate "Alcor Micro AU6610 USB2.0 support" depends on DVB_USB select DVB_ZL10353 if !DVB_FE_CUSTOMISE - select MEDIA_TUNER_QT1010 if !DVB_FE_CUSTOMISE + select DVB_TUNER_QT1010 if !DVB_FE_CUSTOMISE help Say Y here to support the Sigmatek DVB-110 DVB-T USB2.0 receiver. @@ -190,7 +190,7 @@ config DVB_USB_NOVA_T_USB2 tristate "Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 support" depends on DVB_USB select DVB_DIB3000MC - select MEDIA_TUNER_MT2060 if !DVB_FE_CUSTOMISE + select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE select DVB_PLL if !DVB_FE_CUSTOMISE help Say Y here to support the Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 receiver. @@ -227,8 +227,8 @@ config DVB_USB_OPERA1 config DVB_USB_AF9005 tristate "Afatech AF9005 DVB-T USB1.1 support" depends on DVB_USB && EXPERIMENTAL - select MEDIA_TUNER_MT2060 if !DVB_FE_CUSTOMISE - select MEDIA_TUNER_QT1010 if !DVB_FE_CUSTOMISE + select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE + select DVB_TUNER_QT1010 if !DVB_FE_CUSTOMISE help Say Y here to support the Afatech AF9005 based DVB-T USB1.1 receiver and the TerraTec Cinergy T USB XE (Rev.1) diff --git a/trunk/drivers/media/dvb/dvb-usb/Makefile b/trunk/drivers/media/dvb/dvb-usb/Makefile index c6511a6c0ab8..60a910052c16 100644 --- a/trunk/drivers/media/dvb/dvb-usb/Makefile +++ b/trunk/drivers/media/dvb/dvb-usb/Makefile @@ -63,5 +63,5 @@ obj-$(CONFIG_DVB_USB_AF9005_REMOTE) += dvb-usb-af9005-remote.o EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ # due to tuner-xc3028 -EXTRA_CFLAGS += -Idrivers/media/common/tuners +EXTRA_CFLAGS += -Idrivers/media/video diff --git a/trunk/drivers/media/dvb/frontends/Kconfig b/trunk/drivers/media/dvb/frontends/Kconfig index 6d2384605927..f5fceb3cdb3c 100644 --- a/trunk/drivers/media/dvb/frontends/Kconfig +++ b/trunk/drivers/media/dvb/frontends/Kconfig @@ -15,36 +15,22 @@ config DVB_FE_CUSTOMISE comment "DVB-S (satellite) frontends" depends on DVB_CORE -config DVB_CX24110 - tristate "Conexant CX24110 based" - depends on DVB_CORE && I2C - default m if DVB_FE_CUSTOMISE - help - A DVB-S tuner module. Say Y when you want to support this frontend. - -config DVB_CX24123 - tristate "Conexant CX24123 based" - depends on DVB_CORE && I2C - default m if DVB_FE_CUSTOMISE - help - A DVB-S tuner module. Say Y when you want to support this frontend. - -config DVB_MT312 - tristate "Zarlink VP310/MT312 based" +config DVB_STV0299 + tristate "ST STV0299 based" depends on DVB_CORE && I2C default m if DVB_FE_CUSTOMISE help A DVB-S tuner module. Say Y when you want to support this frontend. -config DVB_S5H1420 - tristate "Samsung S5H1420 based" +config DVB_CX24110 + tristate "Conexant CX24110 based" depends on DVB_CORE && I2C default m if DVB_FE_CUSTOMISE help A DVB-S tuner module. Say Y when you want to support this frontend. -config DVB_STV0299 - tristate "ST STV0299 based" +config DVB_CX24123 + tristate "Conexant CX24123 based" depends on DVB_CORE && I2C default m if DVB_FE_CUSTOMISE help @@ -57,8 +43,8 @@ config DVB_TDA8083 help A DVB-S tuner module. Say Y when you want to support this frontend. -config DVB_TDA10086 - tristate "Philips TDA10086 based" +config DVB_MT312 + tristate "Zarlink VP310/MT312 based" depends on DVB_CORE && I2C default m if DVB_FE_CUSTOMISE help @@ -71,26 +57,19 @@ config DVB_VES1X93 help A DVB-S tuner module. Say Y when you want to support this frontend. -config DVB_TUNER_ITD1000 - tristate "Integrant ITD1000 Zero IF tuner for DVB-S/DSS" +config DVB_S5H1420 + tristate "Samsung S5H1420 based" depends on DVB_CORE && I2C default m if DVB_FE_CUSTOMISE help A DVB-S tuner module. Say Y when you want to support this frontend. -config DVB_TDA826X - tristate "Philips TDA826X silicon tuner" - depends on DVB_CORE && I2C - default m if DVB_FE_CUSTOMISE - help - A DVB-S silicon tuner module. Say Y when you want to support this tuner. - -config DVB_TUA6100 - tristate "Infineon TUA6100 PLL" +config DVB_TDA10086 + tristate "Philips TDA10086 based" depends on DVB_CORE && I2C default m if DVB_FE_CUSTOMISE help - A DVB-S PLL chip. + A DVB-S tuner module. Say Y when you want to support this frontend. comment "DVB-T (terrestrial) frontends" depends on DVB_CORE @@ -336,7 +315,7 @@ config DVB_S5H1411 An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want to support this frontend. -comment "Digital terrestrial only tuners/PLL" +comment "Tuners/PLL support" depends on DVB_CORE config DVB_PLL @@ -347,6 +326,55 @@ config DVB_PLL This module drives a number of tuners based on PLL chips with a common I2C interface. Say Y when you want to support these tuners. +config DVB_TDA826X + tristate "Philips TDA826X silicon tuner" + depends on DVB_CORE && I2C + default m if DVB_FE_CUSTOMISE + help + A DVB-S silicon tuner module. Say Y when you want to support this tuner. + +config DVB_TDA827X + tristate "Philips TDA827X silicon tuner" + depends on DVB_CORE && I2C + default m if DVB_FE_CUSTOMISE + help + A DVB-T silicon tuner module. Say Y when you want to support this tuner. + +config DVB_TDA18271 + tristate "NXP TDA18271 silicon tuner" + depends on I2C + default m if DVB_FE_CUSTOMISE + help + A silicon tuner module. Say Y when you want to support this tuner. + +config DVB_TUNER_QT1010 + tristate "Quantek QT1010 silicon tuner" + depends on DVB_CORE && I2C + default m if DVB_FE_CUSTOMISE + help + A driver for the silicon tuner QT1010 from Quantek. + +config DVB_TUNER_MT2060 + tristate "Microtune MT2060 silicon IF tuner" + depends on I2C + default m if DVB_FE_CUSTOMISE + help + A driver for the silicon IF tuner MT2060 from Microtune. + +config DVB_TUNER_MT2266 + tristate "Microtune MT2266 silicon tuner" + depends on I2C + default m if DVB_FE_CUSTOMISE + help + A driver for the silicon baseband tuner MT2266 from Microtune. + +config DVB_TUNER_MT2131 + tristate "Microtune MT2131 silicon tuner" + depends on I2C + default m if DVB_FE_CUSTOMISE + help + A driver for the silicon baseband tuner MT2131 from Microtune. + config DVB_TUNER_DIB0070 tristate "DiBcom DiB0070 silicon base-band tuner" depends on I2C @@ -356,7 +384,21 @@ config DVB_TUNER_DIB0070 This device is only used inside a SiP called togther with a demodulator for now. -comment "SEC control devices for DVB-S" +config DVB_TUNER_XC5000 + tristate "Xceive XC5000 silicon tuner" + depends on I2C + default m if DVB_FE_CUSTOMISE + help + A driver for the silicon tuner XC5000 from Xceive. + This device is only used inside a SiP called togther with a + demodulator for now. + +config DVB_TUNER_ITD1000 + tristate "Integrant ITD1000 Zero IF tuner for DVB-S/DSS" + depends on DVB_CORE && I2C + default m if DVB_FE_CUSTOMISE + +comment "Miscellaneous devices" depends on DVB_CORE config DVB_LNBP21 @@ -380,4 +422,11 @@ config DVB_ISL6421 help An SEC control chip. +config DVB_TUA6100 + tristate "TUA6100 PLL" + depends on DVB_CORE && I2C + default m if DVB_FE_CUSTOMISE + help + A DVBS PLL chip. + endmenu diff --git a/trunk/drivers/media/dvb/frontends/Makefile b/trunk/drivers/media/dvb/frontends/Makefile index a89dc0fc4c6f..9747c73dc826 100644 --- a/trunk/drivers/media/dvb/frontends/Makefile +++ b/trunk/drivers/media/dvb/frontends/Makefile @@ -3,7 +3,9 @@ # EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -EXTRA_CFLAGS += -Idrivers/media/common/tuners/ +EXTRA_CFLAGS += -Idrivers/media/video/ + +tda18271-objs := tda18271-tables.o tda18271-common.o tda18271-fe.o obj-$(CONFIG_DVB_PLL) += dvb-pll.o obj-$(CONFIG_DVB_STV0299) += stv0299.o @@ -40,9 +42,16 @@ obj-$(CONFIG_DVB_ISL6405) += isl6405.o obj-$(CONFIG_DVB_ISL6421) += isl6421.o obj-$(CONFIG_DVB_TDA10086) += tda10086.o obj-$(CONFIG_DVB_TDA826X) += tda826x.o +obj-$(CONFIG_DVB_TDA827X) += tda827x.o +obj-$(CONFIG_DVB_TDA18271) += tda18271.o +obj-$(CONFIG_DVB_TUNER_MT2060) += mt2060.o +obj-$(CONFIG_DVB_TUNER_MT2266) += mt2266.o obj-$(CONFIG_DVB_TUNER_DIB0070) += dib0070.o +obj-$(CONFIG_DVB_TUNER_QT1010) += qt1010.o obj-$(CONFIG_DVB_TUA6100) += tua6100.o +obj-$(CONFIG_DVB_TUNER_MT2131) += mt2131.o obj-$(CONFIG_DVB_S5H1409) += s5h1409.o +obj-$(CONFIG_DVB_TUNER_XC5000) += xc5000.o obj-$(CONFIG_DVB_TUNER_ITD1000) += itd1000.o obj-$(CONFIG_DVB_AU8522) += au8522.o obj-$(CONFIG_DVB_TDA10048) += tda10048.o diff --git a/trunk/drivers/media/common/tuners/mt2060.c b/trunk/drivers/media/dvb/frontends/mt2060.c similarity index 100% rename from trunk/drivers/media/common/tuners/mt2060.c rename to trunk/drivers/media/dvb/frontends/mt2060.c diff --git a/trunk/drivers/media/common/tuners/mt2060.h b/trunk/drivers/media/dvb/frontends/mt2060.h similarity index 90% rename from trunk/drivers/media/common/tuners/mt2060.h rename to trunk/drivers/media/dvb/frontends/mt2060.h index cb60caffb6b6..acba0058f519 100644 --- a/trunk/drivers/media/common/tuners/mt2060.h +++ b/trunk/drivers/media/dvb/frontends/mt2060.h @@ -30,7 +30,7 @@ struct mt2060_config { u8 clock_out; /* 0 = off, 1 = CLK/4, 2 = CLK/2, 3 = CLK/1 */ }; -#if defined(CONFIG_MEDIA_TUNER_MT2060) || (defined(CONFIG_MEDIA_TUNER_MT2060_MODULE) && defined(MODULE)) +#if defined(CONFIG_DVB_TUNER_MT2060) || (defined(CONFIG_DVB_TUNER_MT2060_MODULE) && defined(MODULE)) extern struct dvb_frontend * mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2060_config *cfg, u16 if1); #else static inline struct dvb_frontend * mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2060_config *cfg, u16 if1) @@ -38,6 +38,6 @@ static inline struct dvb_frontend * mt2060_attach(struct dvb_frontend *fe, struc printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); return NULL; } -#endif // CONFIG_MEDIA_TUNER_MT2060 +#endif // CONFIG_DVB_TUNER_MT2060 #endif diff --git a/trunk/drivers/media/common/tuners/mt2060_priv.h b/trunk/drivers/media/dvb/frontends/mt2060_priv.h similarity index 100% rename from trunk/drivers/media/common/tuners/mt2060_priv.h rename to trunk/drivers/media/dvb/frontends/mt2060_priv.h diff --git a/trunk/drivers/media/common/tuners/mt2131.c b/trunk/drivers/media/dvb/frontends/mt2131.c similarity index 100% rename from trunk/drivers/media/common/tuners/mt2131.c rename to trunk/drivers/media/dvb/frontends/mt2131.c diff --git a/trunk/drivers/media/common/tuners/mt2131.h b/trunk/drivers/media/dvb/frontends/mt2131.h similarity index 91% rename from trunk/drivers/media/common/tuners/mt2131.h rename to trunk/drivers/media/dvb/frontends/mt2131.h index cd8376f6f7b4..606d8576bc98 100644 --- a/trunk/drivers/media/common/tuners/mt2131.h +++ b/trunk/drivers/media/dvb/frontends/mt2131.h @@ -30,7 +30,7 @@ struct mt2131_config { u8 clock_out; /* 0 = off, 1 = CLK/4, 2 = CLK/2, 3 = CLK/1 */ }; -#if defined(CONFIG_MEDIA_TUNER_MT2131) || (defined(CONFIG_MEDIA_TUNER_MT2131_MODULE) && defined(MODULE)) +#if defined(CONFIG_DVB_TUNER_MT2131) || (defined(CONFIG_DVB_TUNER_MT2131_MODULE) && defined(MODULE)) extern struct dvb_frontend* mt2131_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2131_config *cfg, @@ -44,7 +44,7 @@ static inline struct dvb_frontend* mt2131_attach(struct dvb_frontend *fe, printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); return NULL; } -#endif /* CONFIG_MEDIA_TUNER_MT2131 */ +#endif /* CONFIG_DVB_TUNER_MT2131 */ #endif /* __MT2131_H__ */ diff --git a/trunk/drivers/media/common/tuners/mt2131_priv.h b/trunk/drivers/media/dvb/frontends/mt2131_priv.h similarity index 100% rename from trunk/drivers/media/common/tuners/mt2131_priv.h rename to trunk/drivers/media/dvb/frontends/mt2131_priv.h diff --git a/trunk/drivers/media/common/tuners/mt2266.c b/trunk/drivers/media/dvb/frontends/mt2266.c similarity index 100% rename from trunk/drivers/media/common/tuners/mt2266.c rename to trunk/drivers/media/dvb/frontends/mt2266.c diff --git a/trunk/drivers/media/common/tuners/mt2266.h b/trunk/drivers/media/dvb/frontends/mt2266.h similarity index 88% rename from trunk/drivers/media/common/tuners/mt2266.h rename to trunk/drivers/media/dvb/frontends/mt2266.h index 4d083882d044..c5113efe333c 100644 --- a/trunk/drivers/media/common/tuners/mt2266.h +++ b/trunk/drivers/media/dvb/frontends/mt2266.h @@ -24,7 +24,7 @@ struct mt2266_config { u8 i2c_address; }; -#if defined(CONFIG_MEDIA_TUNER_MT2266) || (defined(CONFIG_MEDIA_TUNER_MT2266_MODULE) && defined(MODULE)) +#if defined(CONFIG_DVB_TUNER_MT2266) || (defined(CONFIG_DVB_TUNER_MT2266_MODULE) && defined(MODULE)) extern struct dvb_frontend * mt2266_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2266_config *cfg); #else static inline struct dvb_frontend * mt2266_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2266_config *cfg) @@ -32,6 +32,6 @@ static inline struct dvb_frontend * mt2266_attach(struct dvb_frontend *fe, struc printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); return NULL; } -#endif // CONFIG_MEDIA_TUNER_MT2266 +#endif // CONFIG_DVB_TUNER_MT2266 #endif diff --git a/trunk/drivers/media/common/tuners/qt1010.c b/trunk/drivers/media/dvb/frontends/qt1010.c similarity index 100% rename from trunk/drivers/media/common/tuners/qt1010.c rename to trunk/drivers/media/dvb/frontends/qt1010.c diff --git a/trunk/drivers/media/common/tuners/qt1010.h b/trunk/drivers/media/dvb/frontends/qt1010.h similarity index 91% rename from trunk/drivers/media/common/tuners/qt1010.h rename to trunk/drivers/media/dvb/frontends/qt1010.h index 807fb7b6146b..cff6a7ca5380 100644 --- a/trunk/drivers/media/common/tuners/qt1010.h +++ b/trunk/drivers/media/dvb/frontends/qt1010.h @@ -36,7 +36,7 @@ struct qt1010_config { * @param cfg tuner hw based configuration * @return fe pointer on success, NULL on failure */ -#if defined(CONFIG_MEDIA_TUNER_QT1010) || (defined(CONFIG_MEDIA_TUNER_QT1010_MODULE) && defined(MODULE)) +#if defined(CONFIG_DVB_TUNER_QT1010) || (defined(CONFIG_DVB_TUNER_QT1010_MODULE) && defined(MODULE)) extern struct dvb_frontend *qt1010_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct qt1010_config *cfg); @@ -48,6 +48,6 @@ static inline struct dvb_frontend *qt1010_attach(struct dvb_frontend *fe, printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); return NULL; } -#endif // CONFIG_MEDIA_TUNER_QT1010 +#endif // CONFIG_DVB_TUNER_QT1010 #endif diff --git a/trunk/drivers/media/common/tuners/qt1010_priv.h b/trunk/drivers/media/dvb/frontends/qt1010_priv.h similarity index 100% rename from trunk/drivers/media/common/tuners/qt1010_priv.h rename to trunk/drivers/media/dvb/frontends/qt1010_priv.h diff --git a/trunk/drivers/media/dvb/frontends/s5h1420.c b/trunk/drivers/media/dvb/frontends/s5h1420.c index 720ed9ff7c5f..281e1cb2edc6 100644 --- a/trunk/drivers/media/dvb/frontends/s5h1420.c +++ b/trunk/drivers/media/dvb/frontends/s5h1420.c @@ -481,7 +481,7 @@ static void s5h1420_setsymbolrate(struct s5h1420_state* state, val *= 2; do_div(val, (state->fclk / 1000)); - dprintk("symbol rate register: %06llx\n", (unsigned long long)val); + dprintk("symbol rate register: %06llx\n", val); v = s5h1420_readreg(state, Loop01); s5h1420_writereg(state, Loop01, v & 0x7f); diff --git a/trunk/drivers/media/common/tuners/tda18271-common.c b/trunk/drivers/media/dvb/frontends/tda18271-common.c similarity index 100% rename from trunk/drivers/media/common/tuners/tda18271-common.c rename to trunk/drivers/media/dvb/frontends/tda18271-common.c diff --git a/trunk/drivers/media/common/tuners/tda18271-fe.c b/trunk/drivers/media/dvb/frontends/tda18271-fe.c similarity index 100% rename from trunk/drivers/media/common/tuners/tda18271-fe.c rename to trunk/drivers/media/dvb/frontends/tda18271-fe.c diff --git a/trunk/drivers/media/common/tuners/tda18271-priv.h b/trunk/drivers/media/dvb/frontends/tda18271-priv.h similarity index 100% rename from trunk/drivers/media/common/tuners/tda18271-priv.h rename to trunk/drivers/media/dvb/frontends/tda18271-priv.h diff --git a/trunk/drivers/media/common/tuners/tda18271-maps.c b/trunk/drivers/media/dvb/frontends/tda18271-tables.c similarity index 100% rename from trunk/drivers/media/common/tuners/tda18271-maps.c rename to trunk/drivers/media/dvb/frontends/tda18271-tables.c diff --git a/trunk/drivers/media/common/tuners/tda18271.h b/trunk/drivers/media/dvb/frontends/tda18271.h similarity index 96% rename from trunk/drivers/media/common/tuners/tda18271.h rename to trunk/drivers/media/dvb/frontends/tda18271.h index 7db9831c0cb0..0e7af8d05a38 100644 --- a/trunk/drivers/media/common/tuners/tda18271.h +++ b/trunk/drivers/media/dvb/frontends/tda18271.h @@ -81,7 +81,7 @@ struct tda18271_config { unsigned int small_i2c:1; }; -#if defined(CONFIG_MEDIA_TUNER_TDA18271) || (defined(CONFIG_MEDIA_TUNER_TDA18271_MODULE) && defined(MODULE)) +#if defined(CONFIG_DVB_TDA18271) || (defined(CONFIG_DVB_TDA18271_MODULE) && defined(MODULE)) extern struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr, struct i2c_adapter *i2c, struct tda18271_config *cfg); diff --git a/trunk/drivers/media/common/tuners/tda827x.c b/trunk/drivers/media/dvb/frontends/tda827x.c similarity index 100% rename from trunk/drivers/media/common/tuners/tda827x.c rename to trunk/drivers/media/dvb/frontends/tda827x.c diff --git a/trunk/drivers/media/common/tuners/tda827x.h b/trunk/drivers/media/dvb/frontends/tda827x.h similarity index 93% rename from trunk/drivers/media/common/tuners/tda827x.h rename to trunk/drivers/media/dvb/frontends/tda827x.h index 7850a9a1dc8f..b73c23570dab 100644 --- a/trunk/drivers/media/common/tuners/tda827x.h +++ b/trunk/drivers/media/dvb/frontends/tda827x.h @@ -51,7 +51,7 @@ struct tda827x_config * @param cfg optional callback function pointers. * @return FE pointer on success, NULL on failure. */ -#if defined(CONFIG_MEDIA_TUNER_TDA827X) || (defined(CONFIG_MEDIA_TUNER_TDA827X_MODULE) && defined(MODULE)) +#if defined(CONFIG_DVB_TDA827X) || (defined(CONFIG_DVB_TDA827X_MODULE) && defined(MODULE)) extern struct dvb_frontend* tda827x_attach(struct dvb_frontend *fe, int addr, struct i2c_adapter *i2c, struct tda827x_config *cfg); @@ -64,6 +64,6 @@ static inline struct dvb_frontend* tda827x_attach(struct dvb_frontend *fe, printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); return NULL; } -#endif // CONFIG_MEDIA_TUNER_TDA827X +#endif // CONFIG_DVB_TDA827X #endif // __DVB_TDA827X_H__ diff --git a/trunk/drivers/media/common/tuners/xc5000.c b/trunk/drivers/media/dvb/frontends/xc5000.c similarity index 100% rename from trunk/drivers/media/common/tuners/xc5000.c rename to trunk/drivers/media/dvb/frontends/xc5000.c diff --git a/trunk/drivers/media/common/tuners/xc5000.h b/trunk/drivers/media/dvb/frontends/xc5000.h similarity index 92% rename from trunk/drivers/media/common/tuners/xc5000.h rename to trunk/drivers/media/dvb/frontends/xc5000.h index 0ee80f9d19b8..b890883a0cdc 100644 --- a/trunk/drivers/media/common/tuners/xc5000.h +++ b/trunk/drivers/media/dvb/frontends/xc5000.h @@ -45,8 +45,8 @@ struct xc5000_config { /* xc5000 callback command */ #define XC5000_TUNER_RESET 0 -#if defined(CONFIG_MEDIA_TUNER_XC5000) || \ - (defined(CONFIG_MEDIA_TUNER_XC5000_MODULE) && defined(MODULE)) +#if defined(CONFIG_DVB_TUNER_XC5000) || \ + (defined(CONFIG_DVB_TUNER_XC5000_MODULE) && defined(MODULE)) extern struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct xc5000_config *cfg); @@ -58,6 +58,6 @@ static inline struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe, printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); return NULL; } -#endif // CONFIG_MEDIA_TUNER_XC5000 +#endif // CONFIG_DVB_TUNER_XC5000 #endif // __XC5000_H__ diff --git a/trunk/drivers/media/common/tuners/xc5000_priv.h b/trunk/drivers/media/dvb/frontends/xc5000_priv.h similarity index 100% rename from trunk/drivers/media/common/tuners/xc5000_priv.h rename to trunk/drivers/media/dvb/frontends/xc5000_priv.h diff --git a/trunk/drivers/media/video/Kconfig b/trunk/drivers/media/video/Kconfig index fe743aa7f645..fe9a4cc14141 100644 --- a/trunk/drivers/media/video/Kconfig +++ b/trunk/drivers/media/video/Kconfig @@ -1,49 +1,3 @@ -# -# Generic video config states -# - -config VIDEO_V4L2 - tristate - depends on VIDEO_DEV && VIDEO_V4L2_COMMON - default VIDEO_DEV && VIDEO_V4L2_COMMON - -config VIDEO_V4L1 - tristate - depends on VIDEO_DEV && VIDEO_V4L2_COMMON && VIDEO_ALLOW_V4L1 - default VIDEO_DEV && VIDEO_V4L2_COMMON && VIDEO_ALLOW_V4L1 - -config VIDEOBUF_GEN - tristate - -config VIDEOBUF_DMA_SG - depends on HAS_DMA - select VIDEOBUF_GEN - tristate - -config VIDEOBUF_VMALLOC - select VIDEOBUF_GEN - tristate - -config VIDEOBUF_DVB - tristate - select VIDEOBUF_GEN - select VIDEOBUF_DMA_SG - -config VIDEO_BTCX - tristate - -config VIDEO_IR_I2C - tristate - -config VIDEO_IR - tristate - depends on INPUT - select VIDEO_IR_I2C if I2C - -config VIDEO_TVEEPROM - tristate - depends on I2C - # # Multimedia Video device configuration # @@ -690,7 +644,7 @@ config VIDEO_MXB tristate "Siemens-Nixdorf 'Multimedia eXtension Board'" depends on PCI && VIDEO_V4L1 && I2C select VIDEO_SAA7146_VV - select MEDIA_TUNER + select VIDEO_TUNER select VIDEO_SAA7111 if VIDEO_HELPER_CHIPS_AUTO select VIDEO_TDA9840 if VIDEO_HELPER_CHIPS_AUTO select VIDEO_TEA6415C if VIDEO_HELPER_CHIPS_AUTO @@ -748,8 +702,6 @@ source "drivers/media/video/au0828/Kconfig" source "drivers/media/video/ivtv/Kconfig" -source "drivers/media/video/cx18/Kconfig" - config VIDEO_M32R_AR tristate "AR devices" depends on M32R && VIDEO_V4L1 diff --git a/trunk/drivers/media/video/Makefile b/trunk/drivers/media/video/Makefile index a352c6e31f0c..be14227f3726 100644 --- a/trunk/drivers/media/video/Makefile +++ b/trunk/drivers/media/video/Makefile @@ -84,7 +84,17 @@ obj-$(CONFIG_VIDEO_HEXIUM_GEMINI) += hexium_gemini.o obj-$(CONFIG_VIDEO_DPC) += dpc7146.o obj-$(CONFIG_TUNER_3036) += tuner-3036.o -obj-$(CONFIG_MEDIA_TUNER) += tuner.o +obj-$(CONFIG_VIDEO_TUNER) += tuner.o + +obj-$(CONFIG_TUNER_XC2028) += tuner-xc2028.o +obj-$(CONFIG_TUNER_SIMPLE) += tuner-simple.o +# tuner-types will be merged into tuner-simple, in the future +obj-$(CONFIG_TUNER_SIMPLE) += tuner-types.o +obj-$(CONFIG_TUNER_MT20XX) += mt20xx.o +obj-$(CONFIG_TUNER_TDA8290) += tda8290.o +obj-$(CONFIG_TUNER_TEA5767) += tea5767.o +obj-$(CONFIG_TUNER_TEA5761) += tea5761.o +obj-$(CONFIG_TUNER_TDA9887) += tda9887.o obj-$(CONFIG_VIDEOBUF_GEN) += videobuf-core.o obj-$(CONFIG_VIDEOBUF_DMA_SG) += videobuf-dma-sg.o @@ -124,7 +134,6 @@ obj-$(CONFIG_USB_VICAM) += usbvideo/ obj-$(CONFIG_USB_QUICKCAM_MESSENGER) += usbvideo/ obj-$(CONFIG_VIDEO_IVTV) += ivtv/ -obj-$(CONFIG_VIDEO_CX18) += cx18/ obj-$(CONFIG_VIDEO_VIVI) += vivi.o obj-$(CONFIG_VIDEO_CX23885) += cx23885/ @@ -138,4 +147,3 @@ obj-$(CONFIG_VIDEO_AU0828) += au0828/ EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core EXTRA_CFLAGS += -Idrivers/media/dvb/frontends -EXTRA_CFLAGS += -Idrivers/media/common/tuners diff --git a/trunk/drivers/media/video/au0828/Kconfig b/trunk/drivers/media/video/au0828/Kconfig index cab277fafa63..41708267e7a4 100644 --- a/trunk/drivers/media/video/au0828/Kconfig +++ b/trunk/drivers/media/video/au0828/Kconfig @@ -4,7 +4,7 @@ config VIDEO_AU0828 depends on VIDEO_DEV && I2C && INPUT && DVB_CORE select I2C_ALGOBIT select DVB_AU8522 if !DVB_FE_CUSTOMIZE - select MEDIA_TUNER_XC5000 if !DVB_FE_CUSTOMIZE + select DVB_TUNER_XC5000 if !DVB_FE_CUSTOMIZE ---help--- This is a video4linux driver for Auvitek's USB device. diff --git a/trunk/drivers/media/video/au0828/Makefile b/trunk/drivers/media/video/au0828/Makefile index cd2c58281b4e..9f4f572c89c5 100644 --- a/trunk/drivers/media/video/au0828/Makefile +++ b/trunk/drivers/media/video/au0828/Makefile @@ -2,7 +2,7 @@ au0828-objs := au0828-core.o au0828-i2c.o au0828-cards.o au0828-dvb.o obj-$(CONFIG_VIDEO_AU0828) += au0828.o -EXTRA_CFLAGS += -Idrivers/media/common/tuners +EXTRA_CFLAGS += -Idrivers/media/video EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core EXTRA_CFLAGS += -Idrivers/media/dvb/frontends diff --git a/trunk/drivers/media/video/bt8xx/Kconfig b/trunk/drivers/media/video/bt8xx/Kconfig index 7431ef6de9f1..cfc822bb502a 100644 --- a/trunk/drivers/media/video/bt8xx/Kconfig +++ b/trunk/drivers/media/video/bt8xx/Kconfig @@ -6,7 +6,7 @@ config VIDEO_BT848 select VIDEO_BTCX select VIDEOBUF_DMA_SG select VIDEO_IR - select MEDIA_TUNER + select VIDEO_TUNER select VIDEO_TVEEPROM select VIDEO_MSP3400 if VIDEO_HELPER_CHIPS_AUTO select VIDEO_TVAUDIO if VIDEO_HELPER_CHIPS_AUTO diff --git a/trunk/drivers/media/video/bt8xx/Makefile b/trunk/drivers/media/video/bt8xx/Makefile index e415f6fc447c..924d216d9570 100644 --- a/trunk/drivers/media/video/bt8xx/Makefile +++ b/trunk/drivers/media/video/bt8xx/Makefile @@ -9,5 +9,4 @@ bttv-objs := bttv-driver.o bttv-cards.o bttv-if.o \ obj-$(CONFIG_VIDEO_BT848) += bttv.o EXTRA_CFLAGS += -Idrivers/media/video -EXTRA_CFLAGS += -Idrivers/media/common/tuners EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core diff --git a/trunk/drivers/media/video/cs5345.c b/trunk/drivers/media/video/cs5345.c index 2a429f9e32cd..fae469ce16f5 100644 --- a/trunk/drivers/media/video/cs5345.c +++ b/trunk/drivers/media/video/cs5345.c @@ -142,8 +142,7 @@ static int cs5345_command(struct i2c_client *client, unsigned cmd, void *arg) /* ----------------------------------------------------------------------- */ -static int cs5345_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int cs5345_probe(struct i2c_client *client) { /* Check if the adapter supports the needed features */ if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) diff --git a/trunk/drivers/media/video/cs53l32a.c b/trunk/drivers/media/video/cs53l32a.c index 2dfd0afc62db..f41bfde045fe 100644 --- a/trunk/drivers/media/video/cs53l32a.c +++ b/trunk/drivers/media/video/cs53l32a.c @@ -135,8 +135,7 @@ static int cs53l32a_command(struct i2c_client *client, unsigned cmd, void *arg) * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' */ -static int cs53l32a_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int cs53l32a_probe(struct i2c_client *client) { int i; diff --git a/trunk/drivers/media/video/cx18/Kconfig b/trunk/drivers/media/video/cx18/Kconfig deleted file mode 100644 index be654a27bd3c..000000000000 --- a/trunk/drivers/media/video/cx18/Kconfig +++ /dev/null @@ -1,20 +0,0 @@ -config VIDEO_CX18 - tristate "Conexant cx23418 MPEG encoder support" - depends on VIDEO_V4L2 && DVB_CORE && PCI && I2C && EXPERIMENTAL - select I2C_ALGOBIT - select FW_LOADER - select VIDEO_IR - select VIDEO_TUNER - select VIDEO_TVEEPROM - select VIDEO_CX2341X - select VIDEO_CS5345 - select DVB_S5H1409 - ---help--- - This is a video4linux driver for Conexant cx23418 based - PCI combo video recorder devices. - - This is used in devices such as the Hauppauge HVR-1600 - cards. - - To compile this driver as a module, choose M here: the - module will be called cx18. diff --git a/trunk/drivers/media/video/cx18/Makefile b/trunk/drivers/media/video/cx18/Makefile deleted file mode 100644 index b23d2e26120f..000000000000 --- a/trunk/drivers/media/video/cx18/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -cx18-objs := cx18-driver.o cx18-cards.o cx18-i2c.o cx18-firmware.o cx18-gpio.o \ - cx18-queue.o cx18-streams.o cx18-fileops.o cx18-ioctl.o cx18-controls.o \ - cx18-mailbox.o cx18-vbi.o cx18-audio.o cx18-video.o cx18-irq.o \ - cx18-av-core.o cx18-av-audio.o cx18-av-firmware.o cx18-av-vbi.o cx18-scb.o \ - cx18-dvb.o - -obj-$(CONFIG_VIDEO_CX18) += cx18.o - -EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core -EXTRA_CFLAGS += -Idrivers/media/dvb/frontends -EXTRA_CFLAGS += -Idrivers/media/common/tuners diff --git a/trunk/drivers/media/video/cx18/cx18-audio.c b/trunk/drivers/media/video/cx18/cx18-audio.c deleted file mode 100644 index 1adc404d955e..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-audio.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * cx18 audio-related functions - * - * Derived from ivtv-audio.c - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -#include "cx18-driver.h" -#include "cx18-i2c.h" -#include "cx18-cards.h" -#include "cx18-audio.h" - -/* Selects the audio input and output according to the current - settings. */ -int cx18_audio_set_io(struct cx18 *cx) -{ - struct v4l2_routing route; - u32 audio_input; - int mux_input; - - /* Determine which input to use */ - if (test_bit(CX18_F_I_RADIO_USER, &cx->i_flags)) { - audio_input = cx->card->radio_input.audio_input; - mux_input = cx->card->radio_input.muxer_input; - } else { - audio_input = - cx->card->audio_inputs[cx->audio_input].audio_input; - mux_input = - cx->card->audio_inputs[cx->audio_input].muxer_input; - } - - /* handle muxer chips */ - route.input = mux_input; - route.output = 0; - cx18_i2c_hw(cx, cx->card->hw_muxer, VIDIOC_INT_S_AUDIO_ROUTING, &route); - - route.input = audio_input; - return cx18_i2c_hw(cx, cx->card->hw_audio_ctrl, - VIDIOC_INT_S_AUDIO_ROUTING, &route); -} - -void cx18_audio_set_route(struct cx18 *cx, struct v4l2_routing *route) -{ - cx18_i2c_hw(cx, cx->card->hw_audio_ctrl, - VIDIOC_INT_S_AUDIO_ROUTING, route); -} - -void cx18_audio_set_audio_clock_freq(struct cx18 *cx, u8 freq) -{ - static u32 freqs[3] = { 44100, 48000, 32000 }; - - /* The audio clock of the digitizer must match the codec sample - rate otherwise you get some very strange effects. */ - if (freq > 2) - return; - cx18_call_i2c_clients(cx, VIDIOC_INT_AUDIO_CLOCK_FREQ, &freqs[freq]); -} diff --git a/trunk/drivers/media/video/cx18/cx18-audio.h b/trunk/drivers/media/video/cx18/cx18-audio.h deleted file mode 100644 index cb569a69379c..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-audio.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * cx18 audio-related functions - * - * Derived from ivtv-audio.c - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -int cx18_audio_set_io(struct cx18 *cx); -void cx18_audio_set_route(struct cx18 *cx, struct v4l2_routing *route); -void cx18_audio_set_audio_clock_freq(struct cx18 *cx, u8 freq); diff --git a/trunk/drivers/media/video/cx18/cx18-av-audio.c b/trunk/drivers/media/video/cx18/cx18-av-audio.c deleted file mode 100644 index 2dc3a5dd170e..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-av-audio.c +++ /dev/null @@ -1,361 +0,0 @@ -/* - * cx18 ADEC audio functions - * - * Derived from cx25840-audio.c - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#include "cx18-driver.h" - -static int set_audclk_freq(struct cx18 *cx, u32 freq) -{ - struct cx18_av_state *state = &cx->av_state; - - if (freq != 32000 && freq != 44100 && freq != 48000) - return -EINVAL; - - /* common for all inputs and rates */ - /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x10 */ - cx18_av_write(cx, 0x127, 0x50); - - if (state->aud_input != CX18_AV_AUDIO_SERIAL) { - switch (freq) { - case 32000: - /* VID_PLL and AUX_PLL */ - cx18_av_write4(cx, 0x108, 0x1006040f); - - /* AUX_PLL_FRAC */ - cx18_av_write4(cx, 0x110, 0x01bb39ee); - - /* src3/4/6_ctl = 0x0801f77f */ - cx18_av_write4(cx, 0x900, 0x0801f77f); - cx18_av_write4(cx, 0x904, 0x0801f77f); - cx18_av_write4(cx, 0x90c, 0x0801f77f); - break; - - case 44100: - /* VID_PLL and AUX_PLL */ - cx18_av_write4(cx, 0x108, 0x1009040f); - - /* AUX_PLL_FRAC */ - cx18_av_write4(cx, 0x110, 0x00ec6bd6); - - /* src3/4/6_ctl = 0x08016d59 */ - cx18_av_write4(cx, 0x900, 0x08016d59); - cx18_av_write4(cx, 0x904, 0x08016d59); - cx18_av_write4(cx, 0x90c, 0x08016d59); - break; - - case 48000: - /* VID_PLL and AUX_PLL */ - cx18_av_write4(cx, 0x108, 0x100a040f); - - /* AUX_PLL_FRAC */ - cx18_av_write4(cx, 0x110, 0x0098d6e5); - - /* src3/4/6_ctl = 0x08014faa */ - cx18_av_write4(cx, 0x900, 0x08014faa); - cx18_av_write4(cx, 0x904, 0x08014faa); - cx18_av_write4(cx, 0x90c, 0x08014faa); - break; - } - } else { - switch (freq) { - case 32000: - /* VID_PLL and AUX_PLL */ - cx18_av_write4(cx, 0x108, 0x1e08040f); - - /* AUX_PLL_FRAC */ - cx18_av_write4(cx, 0x110, 0x012a0869); - - /* src1_ctl = 0x08010000 */ - cx18_av_write4(cx, 0x8f8, 0x08010000); - - /* src3/4/6_ctl = 0x08020000 */ - cx18_av_write4(cx, 0x900, 0x08020000); - cx18_av_write4(cx, 0x904, 0x08020000); - cx18_av_write4(cx, 0x90c, 0x08020000); - - /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x14 */ - cx18_av_write(cx, 0x127, 0x54); - break; - - case 44100: - /* VID_PLL and AUX_PLL */ - cx18_av_write4(cx, 0x108, 0x1809040f); - - /* AUX_PLL_FRAC */ - cx18_av_write4(cx, 0x110, 0x00ec6bd6); - - /* src1_ctl = 0x08010000 */ - cx18_av_write4(cx, 0x8f8, 0x080160cd); - - /* src3/4/6_ctl = 0x08020000 */ - cx18_av_write4(cx, 0x900, 0x08017385); - cx18_av_write4(cx, 0x904, 0x08017385); - cx18_av_write4(cx, 0x90c, 0x08017385); - break; - - case 48000: - /* VID_PLL and AUX_PLL */ - cx18_av_write4(cx, 0x108, 0x180a040f); - - /* AUX_PLL_FRAC */ - cx18_av_write4(cx, 0x110, 0x0098d6e5); - - /* src1_ctl = 0x08010000 */ - cx18_av_write4(cx, 0x8f8, 0x08018000); - - /* src3/4/6_ctl = 0x08020000 */ - cx18_av_write4(cx, 0x900, 0x08015555); - cx18_av_write4(cx, 0x904, 0x08015555); - cx18_av_write4(cx, 0x90c, 0x08015555); - break; - } - } - - state->audclk_freq = freq; - - return 0; -} - -void cx18_av_audio_set_path(struct cx18 *cx) -{ - struct cx18_av_state *state = &cx->av_state; - - /* stop microcontroller */ - cx18_av_and_or(cx, 0x803, ~0x10, 0); - - /* assert soft reset */ - cx18_av_and_or(cx, 0x810, ~0x1, 0x01); - - /* Mute everything to prevent the PFFT! */ - cx18_av_write(cx, 0x8d3, 0x1f); - - if (state->aud_input == CX18_AV_AUDIO_SERIAL) { - /* Set Path1 to Serial Audio Input */ - cx18_av_write4(cx, 0x8d0, 0x01011012); - - /* The microcontroller should not be started for the - * non-tuner inputs: autodetection is specific for - * TV audio. */ - } else { - /* Set Path1 to Analog Demod Main Channel */ - cx18_av_write4(cx, 0x8d0, 0x1f063870); - } - - set_audclk_freq(cx, state->audclk_freq); - - /* deassert soft reset */ - cx18_av_and_or(cx, 0x810, ~0x1, 0x00); - - if (state->aud_input != CX18_AV_AUDIO_SERIAL) { - /* When the microcontroller detects the - * audio format, it will unmute the lines */ - cx18_av_and_or(cx, 0x803, ~0x10, 0x10); - } -} - -static int get_volume(struct cx18 *cx) -{ - /* Volume runs +18dB to -96dB in 1/2dB steps - * change to fit the msp3400 -114dB to +12dB range */ - - /* check PATH1_VOLUME */ - int vol = 228 - cx18_av_read(cx, 0x8d4); - vol = (vol / 2) + 23; - return vol << 9; -} - -static void set_volume(struct cx18 *cx, int volume) -{ - /* First convert the volume to msp3400 values (0-127) */ - int vol = volume >> 9; - /* now scale it up to cx18_av values - * -114dB to -96dB maps to 0 - * this should be 19, but in my testing that was 4dB too loud */ - if (vol <= 23) - vol = 0; - else - vol -= 23; - - /* PATH1_VOLUME */ - cx18_av_write(cx, 0x8d4, 228 - (vol * 2)); -} - -static int get_bass(struct cx18 *cx) -{ - /* bass is 49 steps +12dB to -12dB */ - - /* check PATH1_EQ_BASS_VOL */ - int bass = cx18_av_read(cx, 0x8d9) & 0x3f; - bass = (((48 - bass) * 0xffff) + 47) / 48; - return bass; -} - -static void set_bass(struct cx18 *cx, int bass) -{ - /* PATH1_EQ_BASS_VOL */ - cx18_av_and_or(cx, 0x8d9, ~0x3f, 48 - (bass * 48 / 0xffff)); -} - -static int get_treble(struct cx18 *cx) -{ - /* treble is 49 steps +12dB to -12dB */ - - /* check PATH1_EQ_TREBLE_VOL */ - int treble = cx18_av_read(cx, 0x8db) & 0x3f; - treble = (((48 - treble) * 0xffff) + 47) / 48; - return treble; -} - -static void set_treble(struct cx18 *cx, int treble) -{ - /* PATH1_EQ_TREBLE_VOL */ - cx18_av_and_or(cx, 0x8db, ~0x3f, 48 - (treble * 48 / 0xffff)); -} - -static int get_balance(struct cx18 *cx) -{ - /* balance is 7 bit, 0 to -96dB */ - - /* check PATH1_BAL_LEVEL */ - int balance = cx18_av_read(cx, 0x8d5) & 0x7f; - /* check PATH1_BAL_LEFT */ - if ((cx18_av_read(cx, 0x8d5) & 0x80) == 0) - balance = 0x80 - balance; - else - balance = 0x80 + balance; - return balance << 8; -} - -static void set_balance(struct cx18 *cx, int balance) -{ - int bal = balance >> 8; - if (bal > 0x80) { - /* PATH1_BAL_LEFT */ - cx18_av_and_or(cx, 0x8d5, 0x7f, 0x80); - /* PATH1_BAL_LEVEL */ - cx18_av_and_or(cx, 0x8d5, ~0x7f, bal & 0x7f); - } else { - /* PATH1_BAL_LEFT */ - cx18_av_and_or(cx, 0x8d5, 0x7f, 0x00); - /* PATH1_BAL_LEVEL */ - cx18_av_and_or(cx, 0x8d5, ~0x7f, 0x80 - bal); - } -} - -static int get_mute(struct cx18 *cx) -{ - /* check SRC1_MUTE_EN */ - return cx18_av_read(cx, 0x8d3) & 0x2 ? 1 : 0; -} - -static void set_mute(struct cx18 *cx, int mute) -{ - struct cx18_av_state *state = &cx->av_state; - - if (state->aud_input != CX18_AV_AUDIO_SERIAL) { - /* Must turn off microcontroller in order to mute sound. - * Not sure if this is the best method, but it does work. - * If the microcontroller is running, then it will undo any - * changes to the mute register. */ - if (mute) { - /* disable microcontroller */ - cx18_av_and_or(cx, 0x803, ~0x10, 0x00); - cx18_av_write(cx, 0x8d3, 0x1f); - } else { - /* enable microcontroller */ - cx18_av_and_or(cx, 0x803, ~0x10, 0x10); - } - } else { - /* SRC1_MUTE_EN */ - cx18_av_and_or(cx, 0x8d3, ~0x2, mute ? 0x02 : 0x00); - } -} - -int cx18_av_audio(struct cx18 *cx, unsigned int cmd, void *arg) -{ - struct cx18_av_state *state = &cx->av_state; - struct v4l2_control *ctrl = arg; - int retval; - - switch (cmd) { - case VIDIOC_INT_AUDIO_CLOCK_FREQ: - if (state->aud_input != CX18_AV_AUDIO_SERIAL) { - cx18_av_and_or(cx, 0x803, ~0x10, 0); - cx18_av_write(cx, 0x8d3, 0x1f); - } - cx18_av_and_or(cx, 0x810, ~0x1, 1); - retval = set_audclk_freq(cx, *(u32 *)arg); - cx18_av_and_or(cx, 0x810, ~0x1, 0); - if (state->aud_input != CX18_AV_AUDIO_SERIAL) - cx18_av_and_or(cx, 0x803, ~0x10, 0x10); - return retval; - - case VIDIOC_G_CTRL: - switch (ctrl->id) { - case V4L2_CID_AUDIO_VOLUME: - ctrl->value = get_volume(cx); - break; - case V4L2_CID_AUDIO_BASS: - ctrl->value = get_bass(cx); - break; - case V4L2_CID_AUDIO_TREBLE: - ctrl->value = get_treble(cx); - break; - case V4L2_CID_AUDIO_BALANCE: - ctrl->value = get_balance(cx); - break; - case V4L2_CID_AUDIO_MUTE: - ctrl->value = get_mute(cx); - break; - default: - return -EINVAL; - } - break; - - case VIDIOC_S_CTRL: - switch (ctrl->id) { - case V4L2_CID_AUDIO_VOLUME: - set_volume(cx, ctrl->value); - break; - case V4L2_CID_AUDIO_BASS: - set_bass(cx, ctrl->value); - break; - case V4L2_CID_AUDIO_TREBLE: - set_treble(cx, ctrl->value); - break; - case V4L2_CID_AUDIO_BALANCE: - set_balance(cx, ctrl->value); - break; - case V4L2_CID_AUDIO_MUTE: - set_mute(cx, ctrl->value); - break; - default: - return -EINVAL; - } - break; - - default: - return -EINVAL; - } - - return 0; -} diff --git a/trunk/drivers/media/video/cx18/cx18-av-core.c b/trunk/drivers/media/video/cx18/cx18-av-core.c deleted file mode 100644 index 66864904c99b..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-av-core.c +++ /dev/null @@ -1,879 +0,0 @@ -/* - * cx18 ADEC audio functions - * - * Derived from cx25840-core.c - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#include "cx18-driver.h" - -int cx18_av_write(struct cx18 *cx, u16 addr, u8 value) -{ - u32 x = readl(cx->reg_mem + 0xc40000 + (addr & ~3)); - u32 mask = 0xff; - int shift = (addr & 3) * 8; - - x = (x & ~(mask << shift)) | ((u32)value << shift); - writel(x, cx->reg_mem + 0xc40000 + (addr & ~3)); - return 0; -} - -int cx18_av_write4(struct cx18 *cx, u16 addr, u32 value) -{ - writel(value, cx->reg_mem + 0xc40000 + addr); - return 0; -} - -u8 cx18_av_read(struct cx18 *cx, u16 addr) -{ - u32 x = readl(cx->reg_mem + 0xc40000 + (addr & ~3)); - int shift = (addr & 3) * 8; - - return (x >> shift) & 0xff; -} - -u32 cx18_av_read4(struct cx18 *cx, u16 addr) -{ - return readl(cx->reg_mem + 0xc40000 + addr); -} - -int cx18_av_and_or(struct cx18 *cx, u16 addr, unsigned and_mask, - u8 or_value) -{ - return cx18_av_write(cx, addr, - (cx18_av_read(cx, addr) & and_mask) | - or_value); -} - -int cx18_av_and_or4(struct cx18 *cx, u16 addr, u32 and_mask, - u32 or_value) -{ - return cx18_av_write4(cx, addr, - (cx18_av_read4(cx, addr) & and_mask) | - or_value); -} - -/* ----------------------------------------------------------------------- */ - -static int set_input(struct cx18 *cx, enum cx18_av_video_input vid_input, - enum cx18_av_audio_input aud_input); -static void log_audio_status(struct cx18 *cx); -static void log_video_status(struct cx18 *cx); - -/* ----------------------------------------------------------------------- */ - -static void cx18_av_initialize(struct cx18 *cx) -{ - u32 v; - - cx18_av_loadfw(cx); - /* Stop 8051 code execution */ - cx18_av_write4(cx, CXADEC_DL_CTL, 0x03000000); - - /* initallize the PLL by toggling sleep bit */ - v = cx18_av_read4(cx, CXADEC_HOST_REG1); - /* enable sleep mode */ - cx18_av_write4(cx, CXADEC_HOST_REG1, v | 1); - /* disable sleep mode */ - cx18_av_write4(cx, CXADEC_HOST_REG1, v & 0xfffe); - - /* initialize DLLs */ - v = cx18_av_read4(cx, CXADEC_DLL1_DIAG_CTRL) & 0xE1FFFEFF; - /* disable FLD */ - cx18_av_write4(cx, CXADEC_DLL1_DIAG_CTRL, v); - /* enable FLD */ - cx18_av_write4(cx, CXADEC_DLL1_DIAG_CTRL, v | 0x10000100); - - v = cx18_av_read4(cx, CXADEC_DLL2_DIAG_CTRL) & 0xE1FFFEFF; - /* disable FLD */ - cx18_av_write4(cx, CXADEC_DLL2_DIAG_CTRL, v); - /* enable FLD */ - cx18_av_write4(cx, CXADEC_DLL2_DIAG_CTRL, v | 0x06000100); - - /* set analog bias currents. Set Vreg to 1.20V. */ - cx18_av_write4(cx, CXADEC_AFE_DIAG_CTRL1, 0x000A1802); - - v = cx18_av_read4(cx, CXADEC_AFE_DIAG_CTRL3) | 1; - /* enable TUNE_FIL_RST */ - cx18_av_write4(cx, CXADEC_AFE_DIAG_CTRL3, v); - /* disable TUNE_FIL_RST */ - cx18_av_write4(cx, CXADEC_AFE_DIAG_CTRL3, v & 0xFFFFFFFE); - - /* enable 656 output */ - cx18_av_and_or4(cx, CXADEC_PIN_CTRL1, ~0, 0x040C00); - - /* video output drive strength */ - cx18_av_and_or4(cx, CXADEC_PIN_CTRL2, ~0, 0x2); - - /* reset video */ - cx18_av_write4(cx, CXADEC_SOFT_RST_CTRL, 0x8000); - cx18_av_write4(cx, CXADEC_SOFT_RST_CTRL, 0); - - /* set video to auto-detect */ - /* Clear bits 11-12 to enable slow locking mode. Set autodetect mode */ - /* set the comb notch = 1 */ - cx18_av_and_or4(cx, CXADEC_MODE_CTRL, 0xFFF7E7F0, 0x02040800); - - /* Enable wtw_en in CRUSH_CTRL (Set bit 22) */ - /* Enable maj_sel in CRUSH_CTRL (Set bit 20) */ - cx18_av_and_or4(cx, CXADEC_CRUSH_CTRL, ~0, 0x00500000); - - /* Set VGA_TRACK_RANGE to 0x20 */ - cx18_av_and_or4(cx, CXADEC_DFE_CTRL2, 0xFFFF00FF, 0x00002000); - - /* Enable VBI capture */ - cx18_av_write4(cx, CXADEC_OUT_CTRL1, 0x4010253F); - /* cx18_av_write4(cx, CXADEC_OUT_CTRL1, 0x4010253E); */ - - /* Set the video input. - The setting in MODE_CTRL gets lost when we do the above setup */ - /* EncSetSignalStd(dwDevNum, pEnc->dwSigStd); */ - /* EncSetVideoInput(dwDevNum, pEnc->VidIndSelection); */ - - v = cx18_av_read4(cx, CXADEC_AFE_CTRL); - v &= 0xFFFBFFFF; /* turn OFF bit 18 for droop_comp_ch1 */ - v &= 0xFFFF7FFF; /* turn OFF bit 9 for clamp_sel_ch1 */ - v &= 0xFFFFFFFE; /* turn OFF bit 0 for 12db_ch1 */ - /* v |= 0x00000001;*/ /* turn ON bit 0 for 12db_ch1 */ - cx18_av_write4(cx, CXADEC_AFE_CTRL, v); - -/* if(dwEnable && dw3DCombAvailable) { */ -/* CxDevWrReg(CXADEC_SRC_COMB_CFG, 0x7728021F); */ -/* } else { */ -/* CxDevWrReg(CXADEC_SRC_COMB_CFG, 0x6628021F); */ -/* } */ - cx18_av_write4(cx, CXADEC_SRC_COMB_CFG, 0x6628021F); -} - -/* ----------------------------------------------------------------------- */ - -static void input_change(struct cx18 *cx) -{ - struct cx18_av_state *state = &cx->av_state; - v4l2_std_id std = state->std; - - /* Follow step 8c and 8d of section 3.16 in the cx18_av datasheet */ - if (std & V4L2_STD_SECAM) - cx18_av_write(cx, 0x402, 0); - else { - cx18_av_write(cx, 0x402, 0x04); - cx18_av_write(cx, 0x49f, (std & V4L2_STD_NTSC) ? 0x14 : 0x11); - } - cx18_av_and_or(cx, 0x401, ~0x60, 0); - cx18_av_and_or(cx, 0x401, ~0x60, 0x60); - - if (std & V4L2_STD_525_60) { - if (std == V4L2_STD_NTSC_M_JP) { - /* Japan uses EIAJ audio standard */ - cx18_av_write(cx, 0x808, 0xf7); - } else if (std == V4L2_STD_NTSC_M_KR) { - /* South Korea uses A2 audio standard */ - cx18_av_write(cx, 0x808, 0xf8); - } else { - /* Others use the BTSC audio standard */ - cx18_av_write(cx, 0x808, 0xf6); - } - cx18_av_write(cx, 0x80b, 0x00); - } else if (std & V4L2_STD_PAL) { - /* Follow tuner change procedure for PAL */ - cx18_av_write(cx, 0x808, 0xff); - cx18_av_write(cx, 0x80b, 0x03); - } else if (std & V4L2_STD_SECAM) { - /* Select autodetect for SECAM */ - cx18_av_write(cx, 0x808, 0xff); - cx18_av_write(cx, 0x80b, 0x03); - } - - if (cx18_av_read(cx, 0x803) & 0x10) { - /* restart audio decoder microcontroller */ - cx18_av_and_or(cx, 0x803, ~0x10, 0x00); - cx18_av_and_or(cx, 0x803, ~0x10, 0x10); - } -} - -static int set_input(struct cx18 *cx, enum cx18_av_video_input vid_input, - enum cx18_av_audio_input aud_input) -{ - struct cx18_av_state *state = &cx->av_state; - u8 is_composite = (vid_input >= CX18_AV_COMPOSITE1 && - vid_input <= CX18_AV_COMPOSITE8); - u8 reg; - - CX18_DEBUG_INFO("decoder set video input %d, audio input %d\n", - vid_input, aud_input); - - if (is_composite) { - reg = 0xf0 + (vid_input - CX18_AV_COMPOSITE1); - } else { - int luma = vid_input & 0xf0; - int chroma = vid_input & 0xf00; - - if ((vid_input & ~0xff0) || - luma < CX18_AV_SVIDEO_LUMA1 || - luma > CX18_AV_SVIDEO_LUMA4 || - chroma < CX18_AV_SVIDEO_CHROMA4 || - chroma > CX18_AV_SVIDEO_CHROMA8) { - CX18_ERR("0x%04x is not a valid video input!\n", - vid_input); - return -EINVAL; - } - reg = 0xf0 + ((luma - CX18_AV_SVIDEO_LUMA1) >> 4); - if (chroma >= CX18_AV_SVIDEO_CHROMA7) { - reg &= 0x3f; - reg |= (chroma - CX18_AV_SVIDEO_CHROMA7) >> 2; - } else { - reg &= 0xcf; - reg |= (chroma - CX18_AV_SVIDEO_CHROMA4) >> 4; - } - } - - switch (aud_input) { - case CX18_AV_AUDIO_SERIAL: - /* do nothing, use serial audio input */ - break; - case CX18_AV_AUDIO4: reg &= ~0x30; break; - case CX18_AV_AUDIO5: reg &= ~0x30; reg |= 0x10; break; - case CX18_AV_AUDIO6: reg &= ~0x30; reg |= 0x20; break; - case CX18_AV_AUDIO7: reg &= ~0xc0; break; - case CX18_AV_AUDIO8: reg &= ~0xc0; reg |= 0x40; break; - - default: - CX18_ERR("0x%04x is not a valid audio input!\n", aud_input); - return -EINVAL; - } - - cx18_av_write(cx, 0x103, reg); - /* Set INPUT_MODE to Composite (0) or S-Video (1) */ - cx18_av_and_or(cx, 0x401, ~0x6, is_composite ? 0 : 0x02); - /* Set CH_SEL_ADC2 to 1 if input comes from CH3 */ - cx18_av_and_or(cx, 0x102, ~0x2, (reg & 0x80) == 0 ? 2 : 0); - /* Set DUAL_MODE_ADC2 to 1 if input comes from both CH2 and CH3 */ - if ((reg & 0xc0) != 0xc0 && (reg & 0x30) != 0x30) - cx18_av_and_or(cx, 0x102, ~0x4, 4); - else - cx18_av_and_or(cx, 0x102, ~0x4, 0); - /*cx18_av_and_or4(cx, 0x104, ~0x001b4180, 0x00004180);*/ - - state->vid_input = vid_input; - state->aud_input = aud_input; - cx18_av_audio_set_path(cx); - input_change(cx); - return 0; -} - -/* ----------------------------------------------------------------------- */ - -static int set_v4lstd(struct cx18 *cx) -{ - struct cx18_av_state *state = &cx->av_state; - u8 fmt = 0; /* zero is autodetect */ - u8 pal_m = 0; - - /* First tests should be against specific std */ - if (state->std == V4L2_STD_NTSC_M_JP) { - fmt = 0x2; - } else if (state->std == V4L2_STD_NTSC_443) { - fmt = 0x3; - } else if (state->std == V4L2_STD_PAL_M) { - pal_m = 1; - fmt = 0x5; - } else if (state->std == V4L2_STD_PAL_N) { - fmt = 0x6; - } else if (state->std == V4L2_STD_PAL_Nc) { - fmt = 0x7; - } else if (state->std == V4L2_STD_PAL_60) { - fmt = 0x8; - } else { - /* Then, test against generic ones */ - if (state->std & V4L2_STD_NTSC) - fmt = 0x1; - else if (state->std & V4L2_STD_PAL) - fmt = 0x4; - else if (state->std & V4L2_STD_SECAM) - fmt = 0xc; - } - - CX18_DEBUG_INFO("changing video std to fmt %i\n", fmt); - - /* Follow step 9 of section 3.16 in the cx18_av datasheet. - Without this PAL may display a vertical ghosting effect. - This happens for example with the Yuan MPC622. */ - if (fmt >= 4 && fmt < 8) { - /* Set format to NTSC-M */ - cx18_av_and_or(cx, 0x400, ~0xf, 1); - /* Turn off LCOMB */ - cx18_av_and_or(cx, 0x47b, ~6, 0); - } - cx18_av_and_or(cx, 0x400, ~0xf, fmt); - cx18_av_and_or(cx, 0x403, ~0x3, pal_m); - cx18_av_vbi_setup(cx); - input_change(cx); - return 0; -} - -/* ----------------------------------------------------------------------- */ - -static int set_v4lctrl(struct cx18 *cx, struct v4l2_control *ctrl) -{ - switch (ctrl->id) { - case V4L2_CID_BRIGHTNESS: - if (ctrl->value < 0 || ctrl->value > 255) { - CX18_ERR("invalid brightness setting %d\n", - ctrl->value); - return -ERANGE; - } - - cx18_av_write(cx, 0x414, ctrl->value - 128); - break; - - case V4L2_CID_CONTRAST: - if (ctrl->value < 0 || ctrl->value > 127) { - CX18_ERR("invalid contrast setting %d\n", - ctrl->value); - return -ERANGE; - } - - cx18_av_write(cx, 0x415, ctrl->value << 1); - break; - - case V4L2_CID_SATURATION: - if (ctrl->value < 0 || ctrl->value > 127) { - CX18_ERR("invalid saturation setting %d\n", - ctrl->value); - return -ERANGE; - } - - cx18_av_write(cx, 0x420, ctrl->value << 1); - cx18_av_write(cx, 0x421, ctrl->value << 1); - break; - - case V4L2_CID_HUE: - if (ctrl->value < -127 || ctrl->value > 127) { - CX18_ERR("invalid hue setting %d\n", ctrl->value); - return -ERANGE; - } - - cx18_av_write(cx, 0x422, ctrl->value); - break; - - case V4L2_CID_AUDIO_VOLUME: - case V4L2_CID_AUDIO_BASS: - case V4L2_CID_AUDIO_TREBLE: - case V4L2_CID_AUDIO_BALANCE: - case V4L2_CID_AUDIO_MUTE: - return cx18_av_audio(cx, VIDIOC_S_CTRL, ctrl); - - default: - return -EINVAL; - } - - return 0; -} - -static int get_v4lctrl(struct cx18 *cx, struct v4l2_control *ctrl) -{ - switch (ctrl->id) { - case V4L2_CID_BRIGHTNESS: - ctrl->value = (s8)cx18_av_read(cx, 0x414) + 128; - break; - case V4L2_CID_CONTRAST: - ctrl->value = cx18_av_read(cx, 0x415) >> 1; - break; - case V4L2_CID_SATURATION: - ctrl->value = cx18_av_read(cx, 0x420) >> 1; - break; - case V4L2_CID_HUE: - ctrl->value = (s8)cx18_av_read(cx, 0x422); - break; - case V4L2_CID_AUDIO_VOLUME: - case V4L2_CID_AUDIO_BASS: - case V4L2_CID_AUDIO_TREBLE: - case V4L2_CID_AUDIO_BALANCE: - case V4L2_CID_AUDIO_MUTE: - return cx18_av_audio(cx, VIDIOC_G_CTRL, ctrl); - default: - return -EINVAL; - } - - return 0; -} - -/* ----------------------------------------------------------------------- */ - -static int get_v4lfmt(struct cx18 *cx, struct v4l2_format *fmt) -{ - switch (fmt->type) { - case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: - return cx18_av_vbi(cx, VIDIOC_G_FMT, fmt); - default: - return -EINVAL; - } - - return 0; -} - -static int set_v4lfmt(struct cx18 *cx, struct v4l2_format *fmt) -{ - struct cx18_av_state *state = &cx->av_state; - struct v4l2_pix_format *pix; - int HSC, VSC, Vsrc, Hsrc, filter, Vlines; - int is_50Hz = !(state->std & V4L2_STD_525_60); - - switch (fmt->type) { - case V4L2_BUF_TYPE_VIDEO_CAPTURE: - pix = &(fmt->fmt.pix); - - Vsrc = (cx18_av_read(cx, 0x476) & 0x3f) << 4; - Vsrc |= (cx18_av_read(cx, 0x475) & 0xf0) >> 4; - - Hsrc = (cx18_av_read(cx, 0x472) & 0x3f) << 4; - Hsrc |= (cx18_av_read(cx, 0x471) & 0xf0) >> 4; - - Vlines = pix->height + (is_50Hz ? 4 : 7); - - if ((pix->width * 16 < Hsrc) || (Hsrc < pix->width) || - (Vlines * 8 < Vsrc) || (Vsrc < Vlines)) { - CX18_ERR("%dx%d is not a valid size!\n", - pix->width, pix->height); - return -ERANGE; - } - - HSC = (Hsrc * (1 << 20)) / pix->width - (1 << 20); - VSC = (1 << 16) - (Vsrc * (1 << 9) / Vlines - (1 << 9)); - VSC &= 0x1fff; - - if (pix->width >= 385) - filter = 0; - else if (pix->width > 192) - filter = 1; - else if (pix->width > 96) - filter = 2; - else - filter = 3; - - CX18_DEBUG_INFO("decoder set size %dx%d -> scale %ux%u\n", - pix->width, pix->height, HSC, VSC); - - /* HSCALE=HSC */ - cx18_av_write(cx, 0x418, HSC & 0xff); - cx18_av_write(cx, 0x419, (HSC >> 8) & 0xff); - cx18_av_write(cx, 0x41a, HSC >> 16); - /* VSCALE=VSC */ - cx18_av_write(cx, 0x41c, VSC & 0xff); - cx18_av_write(cx, 0x41d, VSC >> 8); - /* VS_INTRLACE=1 VFILT=filter */ - cx18_av_write(cx, 0x41e, 0x8 | filter); - break; - - case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: - return cx18_av_vbi(cx, VIDIOC_S_FMT, fmt); - - case V4L2_BUF_TYPE_VBI_CAPTURE: - return cx18_av_vbi(cx, VIDIOC_S_FMT, fmt); - - default: - return -EINVAL; - } - - return 0; -} - -/* ----------------------------------------------------------------------- */ - -int cx18_av_cmd(struct cx18 *cx, unsigned int cmd, void *arg) -{ - struct cx18_av_state *state = &cx->av_state; - struct v4l2_tuner *vt = arg; - struct v4l2_routing *route = arg; - - /* ignore these commands */ - switch (cmd) { - case TUNER_SET_TYPE_ADDR: - return 0; - } - - if (!state->is_initialized) { - CX18_DEBUG_INFO("cmd %08x triggered fw load\n", cmd); - /* initialize on first use */ - state->is_initialized = 1; - cx18_av_initialize(cx); - } - - switch (cmd) { - case VIDIOC_INT_DECODE_VBI_LINE: - return cx18_av_vbi(cx, cmd, arg); - - case VIDIOC_INT_AUDIO_CLOCK_FREQ: - return cx18_av_audio(cx, cmd, arg); - - case VIDIOC_STREAMON: - CX18_DEBUG_INFO("enable output\n"); - cx18_av_write(cx, 0x115, 0x8c); - cx18_av_write(cx, 0x116, 0x07); - break; - - case VIDIOC_STREAMOFF: - CX18_DEBUG_INFO("disable output\n"); - cx18_av_write(cx, 0x115, 0x00); - cx18_av_write(cx, 0x116, 0x00); - break; - - case VIDIOC_LOG_STATUS: - log_video_status(cx); - log_audio_status(cx); - break; - - case VIDIOC_G_CTRL: - return get_v4lctrl(cx, (struct v4l2_control *)arg); - - case VIDIOC_S_CTRL: - return set_v4lctrl(cx, (struct v4l2_control *)arg); - - case VIDIOC_QUERYCTRL: - { - struct v4l2_queryctrl *qc = arg; - - switch (qc->id) { - case V4L2_CID_BRIGHTNESS: - case V4L2_CID_CONTRAST: - case V4L2_CID_SATURATION: - case V4L2_CID_HUE: - return v4l2_ctrl_query_fill_std(qc); - default: - break; - } - - switch (qc->id) { - case V4L2_CID_AUDIO_VOLUME: - case V4L2_CID_AUDIO_MUTE: - case V4L2_CID_AUDIO_BALANCE: - case V4L2_CID_AUDIO_BASS: - case V4L2_CID_AUDIO_TREBLE: - return v4l2_ctrl_query_fill_std(qc); - default: - return -EINVAL; - } - return -EINVAL; - } - - case VIDIOC_G_STD: - *(v4l2_std_id *)arg = state->std; - break; - - case VIDIOC_S_STD: - if (state->radio == 0 && state->std == *(v4l2_std_id *)arg) - return 0; - state->radio = 0; - state->std = *(v4l2_std_id *)arg; - return set_v4lstd(cx); - - case AUDC_SET_RADIO: - state->radio = 1; - break; - - case VIDIOC_INT_G_VIDEO_ROUTING: - route->input = state->vid_input; - route->output = 0; - break; - - case VIDIOC_INT_S_VIDEO_ROUTING: - return set_input(cx, route->input, state->aud_input); - - case VIDIOC_INT_G_AUDIO_ROUTING: - route->input = state->aud_input; - route->output = 0; - break; - - case VIDIOC_INT_S_AUDIO_ROUTING: - return set_input(cx, state->vid_input, route->input); - - case VIDIOC_S_FREQUENCY: - input_change(cx); - break; - - case VIDIOC_G_TUNER: - { - u8 vpres = cx18_av_read(cx, 0x40e) & 0x20; - u8 mode; - int val = 0; - - if (state->radio) - break; - - vt->signal = vpres ? 0xffff : 0x0; - - vt->capability |= - V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LANG1 | - V4L2_TUNER_CAP_LANG2 | V4L2_TUNER_CAP_SAP; - - mode = cx18_av_read(cx, 0x804); - - /* get rxsubchans and audmode */ - if ((mode & 0xf) == 1) - val |= V4L2_TUNER_SUB_STEREO; - else - val |= V4L2_TUNER_SUB_MONO; - - if (mode == 2 || mode == 4) - val = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2; - - if (mode & 0x10) - val |= V4L2_TUNER_SUB_SAP; - - vt->rxsubchans = val; - vt->audmode = state->audmode; - break; - } - - case VIDIOC_S_TUNER: - if (state->radio) - break; - - switch (vt->audmode) { - case V4L2_TUNER_MODE_MONO: - /* mono -> mono - stereo -> mono - bilingual -> lang1 */ - cx18_av_and_or(cx, 0x809, ~0xf, 0x00); - break; - case V4L2_TUNER_MODE_STEREO: - case V4L2_TUNER_MODE_LANG1: - /* mono -> mono - stereo -> stereo - bilingual -> lang1 */ - cx18_av_and_or(cx, 0x809, ~0xf, 0x04); - break; - case V4L2_TUNER_MODE_LANG1_LANG2: - /* mono -> mono - stereo -> stereo - bilingual -> lang1/lang2 */ - cx18_av_and_or(cx, 0x809, ~0xf, 0x07); - break; - case V4L2_TUNER_MODE_LANG2: - /* mono -> mono - stereo -> stereo - bilingual -> lang2 */ - cx18_av_and_or(cx, 0x809, ~0xf, 0x01); - break; - default: - return -EINVAL; - } - state->audmode = vt->audmode; - break; - - case VIDIOC_G_FMT: - return get_v4lfmt(cx, (struct v4l2_format *)arg); - - case VIDIOC_S_FMT: - return set_v4lfmt(cx, (struct v4l2_format *)arg); - - case VIDIOC_INT_RESET: - cx18_av_initialize(cx); - break; - - default: - return -EINVAL; - } - - return 0; -} - -/* ----------------------------------------------------------------------- */ - -/* ----------------------------------------------------------------------- */ - -static void log_video_status(struct cx18 *cx) -{ - static const char *const fmt_strs[] = { - "0x0", - "NTSC-M", "NTSC-J", "NTSC-4.43", - "PAL-BDGHI", "PAL-M", "PAL-N", "PAL-Nc", "PAL-60", - "0x9", "0xA", "0xB", - "SECAM", - "0xD", "0xE", "0xF" - }; - - struct cx18_av_state *state = &cx->av_state; - u8 vidfmt_sel = cx18_av_read(cx, 0x400) & 0xf; - u8 gen_stat1 = cx18_av_read(cx, 0x40d); - u8 gen_stat2 = cx18_av_read(cx, 0x40e); - int vid_input = state->vid_input; - - CX18_INFO("Video signal: %spresent\n", - (gen_stat2 & 0x20) ? "" : "not "); - CX18_INFO("Detected format: %s\n", - fmt_strs[gen_stat1 & 0xf]); - - CX18_INFO("Specified standard: %s\n", - vidfmt_sel ? fmt_strs[vidfmt_sel] : "automatic detection"); - - if (vid_input >= CX18_AV_COMPOSITE1 && - vid_input <= CX18_AV_COMPOSITE8) { - CX18_INFO("Specified video input: Composite %d\n", - vid_input - CX18_AV_COMPOSITE1 + 1); - } else { - CX18_INFO("Specified video input: S-Video (Luma In%d, Chroma In%d)\n", - (vid_input & 0xf0) >> 4, (vid_input & 0xf00) >> 8); - } - - CX18_INFO("Specified audioclock freq: %d Hz\n", state->audclk_freq); -} - -/* ----------------------------------------------------------------------- */ - -static void log_audio_status(struct cx18 *cx) -{ - struct cx18_av_state *state = &cx->av_state; - u8 download_ctl = cx18_av_read(cx, 0x803); - u8 mod_det_stat0 = cx18_av_read(cx, 0x805); - u8 mod_det_stat1 = cx18_av_read(cx, 0x804); - u8 audio_config = cx18_av_read(cx, 0x808); - u8 pref_mode = cx18_av_read(cx, 0x809); - u8 afc0 = cx18_av_read(cx, 0x80b); - u8 mute_ctl = cx18_av_read(cx, 0x8d3); - int aud_input = state->aud_input; - char *p; - - switch (mod_det_stat0) { - case 0x00: p = "mono"; break; - case 0x01: p = "stereo"; break; - case 0x02: p = "dual"; break; - case 0x04: p = "tri"; break; - case 0x10: p = "mono with SAP"; break; - case 0x11: p = "stereo with SAP"; break; - case 0x12: p = "dual with SAP"; break; - case 0x14: p = "tri with SAP"; break; - case 0xfe: p = "forced mode"; break; - default: p = "not defined"; - } - CX18_INFO("Detected audio mode: %s\n", p); - - switch (mod_det_stat1) { - case 0x00: p = "BTSC"; break; - case 0x01: p = "EIAJ"; break; - case 0x02: p = "A2-M"; break; - case 0x03: p = "A2-BG"; break; - case 0x04: p = "A2-DK1"; break; - case 0x05: p = "A2-DK2"; break; - case 0x06: p = "A2-DK3"; break; - case 0x07: p = "A1 (6.0 MHz FM Mono)"; break; - case 0x08: p = "AM-L"; break; - case 0x09: p = "NICAM-BG"; break; - case 0x0a: p = "NICAM-DK"; break; - case 0x0b: p = "NICAM-I"; break; - case 0x0c: p = "NICAM-L"; break; - case 0x0d: p = "BTSC/EIAJ/A2-M Mono (4.5 MHz FMMono)"; break; - case 0xff: p = "no detected audio standard"; break; - default: p = "not defined"; - } - CX18_INFO("Detected audio standard: %s\n", p); - CX18_INFO("Audio muted: %s\n", - (mute_ctl & 0x2) ? "yes" : "no"); - CX18_INFO("Audio microcontroller: %s\n", - (download_ctl & 0x10) ? "running" : "stopped"); - - switch (audio_config >> 4) { - case 0x00: p = "BTSC"; break; - case 0x01: p = "EIAJ"; break; - case 0x02: p = "A2-M"; break; - case 0x03: p = "A2-BG"; break; - case 0x04: p = "A2-DK1"; break; - case 0x05: p = "A2-DK2"; break; - case 0x06: p = "A2-DK3"; break; - case 0x07: p = "A1 (6.0 MHz FM Mono)"; break; - case 0x08: p = "AM-L"; break; - case 0x09: p = "NICAM-BG"; break; - case 0x0a: p = "NICAM-DK"; break; - case 0x0b: p = "NICAM-I"; break; - case 0x0c: p = "NICAM-L"; break; - case 0x0d: p = "FM radio"; break; - case 0x0f: p = "automatic detection"; break; - default: p = "undefined"; - } - CX18_INFO("Configured audio standard: %s\n", p); - - if ((audio_config >> 4) < 0xF) { - switch (audio_config & 0xF) { - case 0x00: p = "MONO1 (LANGUAGE A/Mono L+R channel for BTSC, EIAJ, A2)"; break; - case 0x01: p = "MONO2 (LANGUAGE B)"; break; - case 0x02: p = "MONO3 (STEREO forced MONO)"; break; - case 0x03: p = "MONO4 (NICAM ANALOG-Language C/Analog Fallback)"; break; - case 0x04: p = "STEREO"; break; - case 0x05: p = "DUAL1 (AB)"; break; - case 0x06: p = "DUAL2 (AC) (FM)"; break; - case 0x07: p = "DUAL3 (BC) (FM)"; break; - case 0x08: p = "DUAL4 (AC) (AM)"; break; - case 0x09: p = "DUAL5 (BC) (AM)"; break; - case 0x0a: p = "SAP"; break; - default: p = "undefined"; - } - CX18_INFO("Configured audio mode: %s\n", p); - } else { - switch (audio_config & 0xF) { - case 0x00: p = "BG"; break; - case 0x01: p = "DK1"; break; - case 0x02: p = "DK2"; break; - case 0x03: p = "DK3"; break; - case 0x04: p = "I"; break; - case 0x05: p = "L"; break; - case 0x06: p = "BTSC"; break; - case 0x07: p = "EIAJ"; break; - case 0x08: p = "A2-M"; break; - case 0x09: p = "FM Radio"; break; - case 0x0f: p = "automatic standard and mode detection"; break; - default: p = "undefined"; - } - CX18_INFO("Configured audio system: %s\n", p); - } - - if (aud_input) - CX18_INFO("Specified audio input: Tuner (In%d)\n", - aud_input); - else - CX18_INFO("Specified audio input: External\n"); - - switch (pref_mode & 0xf) { - case 0: p = "mono/language A"; break; - case 1: p = "language B"; break; - case 2: p = "language C"; break; - case 3: p = "analog fallback"; break; - case 4: p = "stereo"; break; - case 5: p = "language AC"; break; - case 6: p = "language BC"; break; - case 7: p = "language AB"; break; - default: p = "undefined"; - } - CX18_INFO("Preferred audio mode: %s\n", p); - - if ((audio_config & 0xf) == 0xf) { - switch ((afc0 >> 2) & 0x1) { - case 0: p = "system DK"; break; - case 1: p = "system L"; break; - } - CX18_INFO("Selected 65 MHz format: %s\n", p); - - switch (afc0 & 0x3) { - case 0: p = "BTSC"; break; - case 1: p = "EIAJ"; break; - case 2: p = "A2-M"; break; - default: p = "undefined"; - } - CX18_INFO("Selected 45 MHz format: %s\n", p); - } -} diff --git a/trunk/drivers/media/video/cx18/cx18-av-core.h b/trunk/drivers/media/video/cx18/cx18-av-core.h deleted file mode 100644 index 786901d72e9a..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-av-core.h +++ /dev/null @@ -1,318 +0,0 @@ -/* - * cx18 ADEC header - * - * Derived from cx25840-core.h - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef _CX18_AV_CORE_H_ -#define _CX18_AV_CORE_H_ - -struct cx18; - -enum cx18_av_video_input { - /* Composite video inputs In1-In8 */ - CX18_AV_COMPOSITE1 = 1, - CX18_AV_COMPOSITE2, - CX18_AV_COMPOSITE3, - CX18_AV_COMPOSITE4, - CX18_AV_COMPOSITE5, - CX18_AV_COMPOSITE6, - CX18_AV_COMPOSITE7, - CX18_AV_COMPOSITE8, - - /* S-Video inputs consist of one luma input (In1-In4) ORed with one - chroma input (In5-In8) */ - CX18_AV_SVIDEO_LUMA1 = 0x10, - CX18_AV_SVIDEO_LUMA2 = 0x20, - CX18_AV_SVIDEO_LUMA3 = 0x30, - CX18_AV_SVIDEO_LUMA4 = 0x40, - CX18_AV_SVIDEO_CHROMA4 = 0x400, - CX18_AV_SVIDEO_CHROMA5 = 0x500, - CX18_AV_SVIDEO_CHROMA6 = 0x600, - CX18_AV_SVIDEO_CHROMA7 = 0x700, - CX18_AV_SVIDEO_CHROMA8 = 0x800, - - /* S-Video aliases for common luma/chroma combinations */ - CX18_AV_SVIDEO1 = 0x510, - CX18_AV_SVIDEO2 = 0x620, - CX18_AV_SVIDEO3 = 0x730, - CX18_AV_SVIDEO4 = 0x840, -}; - -enum cx18_av_audio_input { - /* Audio inputs: serial or In4-In8 */ - CX18_AV_AUDIO_SERIAL, - CX18_AV_AUDIO4 = 4, - CX18_AV_AUDIO5, - CX18_AV_AUDIO6, - CX18_AV_AUDIO7, - CX18_AV_AUDIO8, -}; - -struct cx18_av_state { - int radio; - v4l2_std_id std; - enum cx18_av_video_input vid_input; - enum cx18_av_audio_input aud_input; - u32 audclk_freq; - int audmode; - int vbi_line_offset; - u32 id; - u32 rev; - int is_initialized; -}; - - -/* Registers */ -#define CXADEC_CHIP_TYPE_TIGER 0x837 -#define CXADEC_CHIP_TYPE_MAKO 0x843 - -#define CXADEC_HOST_REG1 0x000 -#define CXADEC_HOST_REG2 0x001 - -#define CXADEC_CHIP_CTRL 0x100 -#define CXADEC_AFE_CTRL 0x104 -#define CXADEC_PLL_CTRL1 0x108 -#define CXADEC_VID_PLL_FRAC 0x10C -#define CXADEC_AUX_PLL_FRAC 0x110 -#define CXADEC_PIN_CTRL1 0x114 -#define CXADEC_PIN_CTRL2 0x118 -#define CXADEC_PIN_CFG1 0x11C -#define CXADEC_PIN_CFG2 0x120 - -#define CXADEC_PIN_CFG3 0x124 -#define CXADEC_I2S_MCLK 0x127 - -#define CXADEC_AUD_LOCK1 0x128 -#define CXADEC_AUD_LOCK2 0x12C -#define CXADEC_POWER_CTRL 0x130 -#define CXADEC_AFE_DIAG_CTRL1 0x134 -#define CXADEC_AFE_DIAG_CTRL2 0x138 -#define CXADEC_AFE_DIAG_CTRL3 0x13C -#define CXADEC_PLL_DIAG_CTRL 0x140 -#define CXADEC_TEST_CTRL1 0x144 -#define CXADEC_TEST_CTRL2 0x148 -#define CXADEC_BIST_STAT 0x14C -#define CXADEC_DLL1_DIAG_CTRL 0x158 -#define CXADEC_DLL2_DIAG_CTRL 0x15C - -/* IR registers */ -#define CXADEC_IR_CTRL_REG 0x200 -#define CXADEC_IR_TXCLK_REG 0x204 -#define CXADEC_IR_RXCLK_REG 0x208 -#define CXADEC_IR_CDUTY_REG 0x20C -#define CXADEC_IR_STAT_REG 0x210 -#define CXADEC_IR_IRQEN_REG 0x214 -#define CXADEC_IR_FILTER_REG 0x218 -#define CXADEC_IR_FIFO_REG 0x21C - -/* Video Registers */ -#define CXADEC_MODE_CTRL 0x400 -#define CXADEC_OUT_CTRL1 0x404 -#define CXADEC_OUT_CTRL2 0x408 -#define CXADEC_GEN_STAT 0x40C -#define CXADEC_INT_STAT_MASK 0x410 -#define CXADEC_LUMA_CTRL 0x414 - -#define CXADEC_BRIGHTNESS_CTRL_BYTE 0x414 -#define CXADEC_CONTRAST_CTRL_BYTE 0x415 -#define CXADEC_LUMA_CTRL_BYTE_3 0x416 - -#define CXADEC_HSCALE_CTRL 0x418 -#define CXADEC_VSCALE_CTRL 0x41C - -#define CXADEC_CHROMA_CTRL 0x420 - -#define CXADEC_USAT_CTRL_BYTE 0x420 -#define CXADEC_VSAT_CTRL_BYTE 0x421 -#define CXADEC_HUE_CTRL_BYTE 0x422 - -#define CXADEC_VBI_LINE_CTRL1 0x424 -#define CXADEC_VBI_LINE_CTRL2 0x428 -#define CXADEC_VBI_LINE_CTRL3 0x42C -#define CXADEC_VBI_LINE_CTRL4 0x430 -#define CXADEC_VBI_LINE_CTRL5 0x434 -#define CXADEC_VBI_FC_CFG 0x438 -#define CXADEC_VBI_MISC_CFG1 0x43C -#define CXADEC_VBI_MISC_CFG2 0x440 -#define CXADEC_VBI_PAY1 0x444 -#define CXADEC_VBI_PAY2 0x448 -#define CXADEC_VBI_CUST1_CFG1 0x44C -#define CXADEC_VBI_CUST1_CFG2 0x450 -#define CXADEC_VBI_CUST1_CFG3 0x454 -#define CXADEC_VBI_CUST2_CFG1 0x458 -#define CXADEC_VBI_CUST2_CFG2 0x45C -#define CXADEC_VBI_CUST2_CFG3 0x460 -#define CXADEC_VBI_CUST3_CFG1 0x464 -#define CXADEC_VBI_CUST3_CFG2 0x468 -#define CXADEC_VBI_CUST3_CFG3 0x46C -#define CXADEC_HORIZ_TIM_CTRL 0x470 -#define CXADEC_VERT_TIM_CTRL 0x474 -#define CXADEC_SRC_COMB_CFG 0x478 -#define CXADEC_CHROMA_VBIOFF_CFG 0x47C -#define CXADEC_FIELD_COUNT 0x480 -#define CXADEC_MISC_TIM_CTRL 0x484 -#define CXADEC_DFE_CTRL1 0x488 -#define CXADEC_DFE_CTRL2 0x48C -#define CXADEC_DFE_CTRL3 0x490 -#define CXADEC_PLL_CTRL2 0x494 -#define CXADEC_HTL_CTRL 0x498 -#define CXADEC_COMB_CTRL 0x49C -#define CXADEC_CRUSH_CTRL 0x4A0 -#define CXADEC_SOFT_RST_CTRL 0x4A4 -#define CXADEC_MV_DT_CTRL2 0x4A8 -#define CXADEC_MV_DT_CTRL3 0x4AC -#define CXADEC_MISC_DIAG_CTRL 0x4B8 - -#define CXADEC_DL_CTL 0x800 -#define CXADEC_DL_CTL_ADDRESS_LOW 0x800 /* Byte 1 in DL_CTL */ -#define CXADEC_DL_CTL_ADDRESS_HIGH 0x801 /* Byte 2 in DL_CTL */ -#define CXADEC_DL_CTL_DATA 0x802 /* Byte 3 in DL_CTL */ -#define CXADEC_DL_CTL_CONTROL 0x803 /* Byte 4 in DL_CTL */ - -#define CXADEC_STD_DET_STATUS 0x804 - -#define CXADEC_STD_DET_CTL 0x808 -#define CXADEC_STD_DET_CTL_AUD_CTL 0x808 /* Byte 1 in STD_DET_CTL */ -#define CXADEC_STD_DET_CTL_PREF_MODE 0x809 /* Byte 2 in STD_DET_CTL */ - -#define CXADEC_DW8051_INT 0x80C -#define CXADEC_GENERAL_CTL 0x810 -#define CXADEC_AAGC_CTL 0x814 -#define CXADEC_IF_SRC_CTL 0x818 -#define CXADEC_ANLOG_DEMOD_CTL 0x81C -#define CXADEC_ROT_FREQ_CTL 0x820 -#define CXADEC_FM1_CTL 0x824 -#define CXADEC_PDF_CTL 0x828 -#define CXADEC_DFT1_CTL1 0x82C -#define CXADEC_DFT1_CTL2 0x830 -#define CXADEC_DFT_STATUS 0x834 -#define CXADEC_DFT2_CTL1 0x838 -#define CXADEC_DFT2_CTL2 0x83C -#define CXADEC_DFT2_STATUS 0x840 -#define CXADEC_DFT3_CTL1 0x844 -#define CXADEC_DFT3_CTL2 0x848 -#define CXADEC_DFT3_STATUS 0x84C -#define CXADEC_DFT4_CTL1 0x850 -#define CXADEC_DFT4_CTL2 0x854 -#define CXADEC_DFT4_STATUS 0x858 -#define CXADEC_AM_MTS_DET 0x85C -#define CXADEC_ANALOG_MUX_CTL 0x860 -#define CXADEC_DIG_PLL_CTL1 0x864 -#define CXADEC_DIG_PLL_CTL2 0x868 -#define CXADEC_DIG_PLL_CTL3 0x86C -#define CXADEC_DIG_PLL_CTL4 0x870 -#define CXADEC_DIG_PLL_CTL5 0x874 -#define CXADEC_DEEMPH_GAIN_CTL 0x878 -#define CXADEC_DEEMPH_COEF1 0x87C -#define CXADEC_DEEMPH_COEF2 0x880 -#define CXADEC_DBX1_CTL1 0x884 -#define CXADEC_DBX1_CTL2 0x888 -#define CXADEC_DBX1_STATUS 0x88C -#define CXADEC_DBX2_CTL1 0x890 -#define CXADEC_DBX2_CTL2 0x894 -#define CXADEC_DBX2_STATUS 0x898 -#define CXADEC_AM_FM_DIFF 0x89C - -/* NICAM registers go here */ -#define CXADEC_NICAM_STATUS 0x8C8 -#define CXADEC_DEMATRIX_CTL 0x8CC - -#define CXADEC_PATH1_CTL1 0x8D0 -#define CXADEC_PATH1_VOL_CTL 0x8D4 -#define CXADEC_PATH1_EQ_CTL 0x8D8 -#define CXADEC_PATH1_SC_CTL 0x8DC - -#define CXADEC_PATH2_CTL1 0x8E0 -#define CXADEC_PATH2_VOL_CTL 0x8E4 -#define CXADEC_PATH2_EQ_CTL 0x8E8 -#define CXADEC_PATH2_SC_CTL 0x8EC - -#define CXADEC_SRC_CTL 0x8F0 -#define CXADEC_SRC_LF_COEF 0x8F4 -#define CXADEC_SRC1_CTL 0x8F8 -#define CXADEC_SRC2_CTL 0x8FC -#define CXADEC_SRC3_CTL 0x900 -#define CXADEC_SRC4_CTL 0x904 -#define CXADEC_SRC5_CTL 0x908 -#define CXADEC_SRC6_CTL 0x90C - -#define CXADEC_BASEBAND_OUT_SEL 0x910 -#define CXADEC_I2S_IN_CTL 0x914 -#define CXADEC_I2S_OUT_CTL 0x918 -#define CXADEC_AC97_CTL 0x91C -#define CXADEC_QAM_PDF 0x920 -#define CXADEC_QAM_CONST_DEC 0x924 -#define CXADEC_QAM_ROTATOR_FREQ 0x948 - -/* Bit defintions / settings used in Mako Audio */ -#define CXADEC_PREF_MODE_MONO_LANGA 0 -#define CXADEC_PREF_MODE_MONO_LANGB 1 -#define CXADEC_PREF_MODE_MONO_LANGC 2 -#define CXADEC_PREF_MODE_FALLBACK 3 -#define CXADEC_PREF_MODE_STEREO 4 -#define CXADEC_PREF_MODE_DUAL_LANG_AC 5 -#define CXADEC_PREF_MODE_DUAL_LANG_BC 6 -#define CXADEC_PREF_MODE_DUAL_LANG_AB 7 - - -#define CXADEC_DETECT_STEREO 1 -#define CXADEC_DETECT_DUAL 2 -#define CXADEC_DETECT_TRI 4 -#define CXADEC_DETECT_SAP 0x10 -#define CXADEC_DETECT_NO_SIGNAL 0xFF - -#define CXADEC_SELECT_AUDIO_STANDARD_BG 0xF0 /* NICAM BG and A2 BG */ -#define CXADEC_SELECT_AUDIO_STANDARD_DK1 0xF1 /* NICAM DK and A2 DK */ -#define CXADEC_SELECT_AUDIO_STANDARD_DK2 0xF2 -#define CXADEC_SELECT_AUDIO_STANDARD_DK3 0xF3 -#define CXADEC_SELECT_AUDIO_STANDARD_I 0xF4 /* NICAM I and A1 */ -#define CXADEC_SELECT_AUDIO_STANDARD_L 0xF5 /* NICAM L and System L AM */ -#define CXADEC_SELECT_AUDIO_STANDARD_BTSC 0xF6 -#define CXADEC_SELECT_AUDIO_STANDARD_EIAJ 0xF7 -#define CXADEC_SELECT_AUDIO_STANDARD_A2_M 0xF8 /* A2 M */ -#define CXADEC_SELECT_AUDIO_STANDARD_FM 0xF9 /* FM radio */ -#define CXADEC_SELECT_AUDIO_STANDARD_AUTO 0xFF /* Auto detect */ - -/* ----------------------------------------------------------------------- */ -/* cx18_av-core.c */ -int cx18_av_write(struct cx18 *cx, u16 addr, u8 value); -int cx18_av_write4(struct cx18 *cx, u16 addr, u32 value); -u8 cx18_av_read(struct cx18 *cx, u16 addr); -u32 cx18_av_read4(struct cx18 *cx, u16 addr); -int cx18_av_and_or(struct cx18 *cx, u16 addr, unsigned mask, u8 value); -int cx18_av_and_or4(struct cx18 *cx, u16 addr, u32 mask, u32 value); -int cx18_av_cmd(struct cx18 *cx, unsigned int cmd, void *arg); - -/* ----------------------------------------------------------------------- */ -/* cx18_av-firmware.c */ -int cx18_av_loadfw(struct cx18 *cx); - -/* ----------------------------------------------------------------------- */ -/* cx18_av-audio.c */ -int cx18_av_audio(struct cx18 *cx, unsigned int cmd, void *arg); -void cx18_av_audio_set_path(struct cx18 *cx); - -/* ----------------------------------------------------------------------- */ -/* cx18_av-vbi.c */ -void cx18_av_vbi_setup(struct cx18 *cx); -int cx18_av_vbi(struct cx18 *cx, unsigned int cmd, void *arg); - -#endif diff --git a/trunk/drivers/media/video/cx18/cx18-av-firmware.c b/trunk/drivers/media/video/cx18/cx18-av-firmware.c deleted file mode 100644 index 526e142156cd..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-av-firmware.c +++ /dev/null @@ -1,120 +0,0 @@ -/* - * cx18 ADEC firmware functions - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#include "cx18-driver.h" -#include - -#define FWFILE "v4l-cx23418-dig.fw" - -int cx18_av_loadfw(struct cx18 *cx) -{ - const struct firmware *fw = NULL; - u32 size; - u32 v; - u8 *ptr; - int i; - - if (request_firmware(&fw, FWFILE, &cx->dev->dev) != 0) { - CX18_ERR("unable to open firmware %s\n", FWFILE); - return -EINVAL; - } - - cx18_av_write4(cx, CXADEC_CHIP_CTRL, 0x00010000); - cx18_av_write(cx, CXADEC_STD_DET_CTL, 0xf6); /* Byte 0 */ - - /* Reset the Mako core (Register is undocumented.) */ - cx18_av_write4(cx, 0x8100, 0x00010000); - - /* Put the 8051 in reset and enable firmware upload */ - cx18_av_write4(cx, CXADEC_DL_CTL, 0x0F000000); - - ptr = fw->data; - size = fw->size; - - for (i = 0; i < size; i++) { - u32 dl_control = 0x0F000000 | ((u32)ptr[i] << 16); - u32 value = 0; - int retries; - - for (retries = 0; retries < 5; retries++) { - cx18_av_write4(cx, CXADEC_DL_CTL, dl_control); - value = cx18_av_read4(cx, CXADEC_DL_CTL); - if ((value & 0x3F00) == (dl_control & 0x3F00)) - break; - } - if (retries >= 5) { - CX18_ERR("unable to load firmware %s\n", FWFILE); - release_firmware(fw); - return -EIO; - } - } - - cx18_av_write4(cx, CXADEC_DL_CTL, 0x13000000 | fw->size); - - /* Output to the 416 */ - cx18_av_and_or4(cx, CXADEC_PIN_CTRL1, ~0, 0x78000); - - /* Audio input control 1 set to Sony mode */ - /* Audio output input 2 is 0 for slave operation input */ - /* 0xC4000914[5]: 0 = left sample on WS=0, 1 = left sample on WS=1 */ - /* 0xC4000914[7]: 0 = Philips mode, 1 = Sony mode (1st SCK rising edge - after WS transition for first bit of audio word. */ - cx18_av_write4(cx, CXADEC_I2S_IN_CTL, 0x000000A0); - - /* Audio output control 1 is set to Sony mode */ - /* Audio output control 2 is set to 1 for master mode */ - /* 0xC4000918[5]: 0 = left sample on WS=0, 1 = left sample on WS=1 */ - /* 0xC4000918[7]: 0 = Philips mode, 1 = Sony mode (1st SCK rising edge - after WS transition for first bit of audio word. */ - /* 0xC4000918[8]: 0 = slave operation, 1 = master (SCK_OUT and WS_OUT - are generated) */ - cx18_av_write4(cx, CXADEC_I2S_OUT_CTL, 0x000001A0); - - /* set alt I2s master clock to /16 and enable alt divider i2s - passthrough */ - cx18_av_write4(cx, CXADEC_PIN_CFG3, 0x5000B687); - - cx18_av_write4(cx, CXADEC_STD_DET_CTL, 0x000000F6); - /* CxDevWrReg(CXADEC_STD_DET_CTL, 0x000000FF); */ - - /* Set bit 0 in register 0x9CC to signify that this is MiniMe. */ - /* Register 0x09CC is defined by the Merlin firmware, and doesn't - have a name in the spec. */ - cx18_av_write4(cx, 0x09CC, 1); - -#define CX18_AUDIO_ENABLE 0xc72014 - v = read_reg(CX18_AUDIO_ENABLE); - /* If bit 11 is 1 */ - if (v & 0x800) - write_reg(v & 0xFFFFFBFF, CX18_AUDIO_ENABLE); /* Clear bit 10 */ - - /* Enable WW auto audio standard detection */ - v = cx18_av_read4(cx, CXADEC_STD_DET_CTL); - v |= 0xFF; /* Auto by default */ - v |= 0x400; /* Stereo by default */ - v |= 0x14000000; - cx18_av_write4(cx, CXADEC_STD_DET_CTL, v); - - release_firmware(fw); - - CX18_INFO("loaded %s firmware (%d bytes)\n", FWFILE, size); - return 0; -} diff --git a/trunk/drivers/media/video/cx18/cx18-av-vbi.c b/trunk/drivers/media/video/cx18/cx18-av-vbi.c deleted file mode 100644 index d09f1daf4ebf..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-av-vbi.c +++ /dev/null @@ -1,413 +0,0 @@ -/* - * cx18 ADEC VBI functions - * - * Derived from cx25840-vbi.c - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - - -#include "cx18-driver.h" - -static int odd_parity(u8 c) -{ - c ^= (c >> 4); - c ^= (c >> 2); - c ^= (c >> 1); - - return c & 1; -} - -static int decode_vps(u8 *dst, u8 *p) -{ - static const u8 biphase_tbl[] = { - 0xf0, 0x78, 0x70, 0xf0, 0xb4, 0x3c, 0x34, 0xb4, - 0xb0, 0x38, 0x30, 0xb0, 0xf0, 0x78, 0x70, 0xf0, - 0xd2, 0x5a, 0x52, 0xd2, 0x96, 0x1e, 0x16, 0x96, - 0x92, 0x1a, 0x12, 0x92, 0xd2, 0x5a, 0x52, 0xd2, - 0xd0, 0x58, 0x50, 0xd0, 0x94, 0x1c, 0x14, 0x94, - 0x90, 0x18, 0x10, 0x90, 0xd0, 0x58, 0x50, 0xd0, - 0xf0, 0x78, 0x70, 0xf0, 0xb4, 0x3c, 0x34, 0xb4, - 0xb0, 0x38, 0x30, 0xb0, 0xf0, 0x78, 0x70, 0xf0, - 0xe1, 0x69, 0x61, 0xe1, 0xa5, 0x2d, 0x25, 0xa5, - 0xa1, 0x29, 0x21, 0xa1, 0xe1, 0x69, 0x61, 0xe1, - 0xc3, 0x4b, 0x43, 0xc3, 0x87, 0x0f, 0x07, 0x87, - 0x83, 0x0b, 0x03, 0x83, 0xc3, 0x4b, 0x43, 0xc3, - 0xc1, 0x49, 0x41, 0xc1, 0x85, 0x0d, 0x05, 0x85, - 0x81, 0x09, 0x01, 0x81, 0xc1, 0x49, 0x41, 0xc1, - 0xe1, 0x69, 0x61, 0xe1, 0xa5, 0x2d, 0x25, 0xa5, - 0xa1, 0x29, 0x21, 0xa1, 0xe1, 0x69, 0x61, 0xe1, - 0xe0, 0x68, 0x60, 0xe0, 0xa4, 0x2c, 0x24, 0xa4, - 0xa0, 0x28, 0x20, 0xa0, 0xe0, 0x68, 0x60, 0xe0, - 0xc2, 0x4a, 0x42, 0xc2, 0x86, 0x0e, 0x06, 0x86, - 0x82, 0x0a, 0x02, 0x82, 0xc2, 0x4a, 0x42, 0xc2, - 0xc0, 0x48, 0x40, 0xc0, 0x84, 0x0c, 0x04, 0x84, - 0x80, 0x08, 0x00, 0x80, 0xc0, 0x48, 0x40, 0xc0, - 0xe0, 0x68, 0x60, 0xe0, 0xa4, 0x2c, 0x24, 0xa4, - 0xa0, 0x28, 0x20, 0xa0, 0xe0, 0x68, 0x60, 0xe0, - 0xf0, 0x78, 0x70, 0xf0, 0xb4, 0x3c, 0x34, 0xb4, - 0xb0, 0x38, 0x30, 0xb0, 0xf0, 0x78, 0x70, 0xf0, - 0xd2, 0x5a, 0x52, 0xd2, 0x96, 0x1e, 0x16, 0x96, - 0x92, 0x1a, 0x12, 0x92, 0xd2, 0x5a, 0x52, 0xd2, - 0xd0, 0x58, 0x50, 0xd0, 0x94, 0x1c, 0x14, 0x94, - 0x90, 0x18, 0x10, 0x90, 0xd0, 0x58, 0x50, 0xd0, - 0xf0, 0x78, 0x70, 0xf0, 0xb4, 0x3c, 0x34, 0xb4, - 0xb0, 0x38, 0x30, 0xb0, 0xf0, 0x78, 0x70, 0xf0, - }; - - u8 c, err = 0; - int i; - - for (i = 0; i < 2 * 13; i += 2) { - err |= biphase_tbl[p[i]] | biphase_tbl[p[i + 1]]; - c = (biphase_tbl[p[i + 1]] & 0xf) | - ((biphase_tbl[p[i]] & 0xf) << 4); - dst[i / 2] = c; - } - - return err & 0xf0; -} - -void cx18_av_vbi_setup(struct cx18 *cx) -{ - struct cx18_av_state *state = &cx->av_state; - v4l2_std_id std = state->std; - int hblank, hactive, burst, vblank, vactive, sc; - int vblank656, src_decimation; - int luma_lpf, uv_lpf, comb; - u32 pll_int, pll_frac, pll_post; - - /* datasheet startup, step 8d */ - if (std & ~V4L2_STD_NTSC) - cx18_av_write(cx, 0x49f, 0x11); - else - cx18_av_write(cx, 0x49f, 0x14); - - if (std & V4L2_STD_625_50) { - hblank = 0x084; - hactive = 0x2d0; - burst = 0x5d; - vblank = 0x024; - vactive = 0x244; - vblank656 = 0x28; - src_decimation = 0x21f; - - luma_lpf = 2; - if (std & V4L2_STD_SECAM) { - uv_lpf = 0; - comb = 0; - sc = 0x0a425f; - } else if (std == V4L2_STD_PAL_Nc) { - uv_lpf = 1; - comb = 0x20; - sc = 556453; - } else { - uv_lpf = 1; - comb = 0x20; - sc = 0x0a8263; - } - } else { - hactive = 720; - hblank = 122; - vactive = 487; - luma_lpf = 1; - uv_lpf = 1; - - src_decimation = 0x21f; - if (std == V4L2_STD_PAL_60) { - vblank = 26; - vblank656 = 26; - burst = 0x5b; - luma_lpf = 2; - comb = 0x20; - sc = 0x0a8263; - } else if (std == V4L2_STD_PAL_M) { - vblank = 20; - vblank656 = 24; - burst = 0x61; - comb = 0x20; - - sc = 555452; - } else { - vblank = 26; - vblank656 = 26; - burst = 0x5b; - comb = 0x66; - sc = 556063; - } - } - - /* DEBUG: Displays configured PLL frequency */ - pll_int = cx18_av_read(cx, 0x108); - pll_frac = cx18_av_read4(cx, 0x10c) & 0x1ffffff; - pll_post = cx18_av_read(cx, 0x109); - CX18_DEBUG_INFO("PLL regs = int: %u, frac: %u, post: %u\n", - pll_int, pll_frac, pll_post); - - if (pll_post) { - int fin, fsc; - int pll = 28636363L * ((((u64)pll_int) << 25) + pll_frac); - - pll >>= 25; - pll /= pll_post; - CX18_DEBUG_INFO("PLL = %d.%06d MHz\n", - pll / 1000000, pll % 1000000); - CX18_DEBUG_INFO("PLL/8 = %d.%06d MHz\n", - pll / 8000000, (pll / 8) % 1000000); - - fin = ((u64)src_decimation * pll) >> 12; - CX18_DEBUG_INFO("ADC Sampling freq = %d.%06d MHz\n", - fin / 1000000, fin % 1000000); - - fsc = (((u64)sc) * pll) >> 24L; - CX18_DEBUG_INFO("Chroma sub-carrier freq = %d.%06d MHz\n", - fsc / 1000000, fsc % 1000000); - - CX18_DEBUG_INFO("hblank %i, hactive %i, " - "vblank %i , vactive %i, vblank656 %i, src_dec %i," - "burst 0x%02x, luma_lpf %i, uv_lpf %i, comb 0x%02x," - " sc 0x%06x\n", - hblank, hactive, vblank, vactive, vblank656, - src_decimation, burst, luma_lpf, uv_lpf, comb, sc); - } - - /* Sets horizontal blanking delay and active lines */ - cx18_av_write(cx, 0x470, hblank); - cx18_av_write(cx, 0x471, 0xff & (((hblank >> 8) & 0x3) | - (hactive << 4))); - cx18_av_write(cx, 0x472, hactive >> 4); - - /* Sets burst gate delay */ - cx18_av_write(cx, 0x473, burst); - - /* Sets vertical blanking delay and active duration */ - cx18_av_write(cx, 0x474, vblank); - cx18_av_write(cx, 0x475, 0xff & (((vblank >> 8) & 0x3) | - (vactive << 4))); - cx18_av_write(cx, 0x476, vactive >> 4); - cx18_av_write(cx, 0x477, vblank656); - - /* Sets src decimation rate */ - cx18_av_write(cx, 0x478, 0xff & src_decimation); - cx18_av_write(cx, 0x479, 0xff & (src_decimation >> 8)); - - /* Sets Luma and UV Low pass filters */ - cx18_av_write(cx, 0x47a, luma_lpf << 6 | ((uv_lpf << 4) & 0x30)); - - /* Enables comb filters */ - cx18_av_write(cx, 0x47b, comb); - - /* Sets SC Step*/ - cx18_av_write(cx, 0x47c, sc); - cx18_av_write(cx, 0x47d, 0xff & sc >> 8); - cx18_av_write(cx, 0x47e, 0xff & sc >> 16); - - /* Sets VBI parameters */ - if (std & V4L2_STD_625_50) { - cx18_av_write(cx, 0x47f, 0x01); - state->vbi_line_offset = 5; - } else { - cx18_av_write(cx, 0x47f, 0x00); - state->vbi_line_offset = 8; - } -} - -int cx18_av_vbi(struct cx18 *cx, unsigned int cmd, void *arg) -{ - struct cx18_av_state *state = &cx->av_state; - struct v4l2_format *fmt; - struct v4l2_sliced_vbi_format *svbi; - - switch (cmd) { - case VIDIOC_G_FMT: - { - static u16 lcr2vbi[] = { - 0, V4L2_SLICED_TELETEXT_B, 0, /* 1 */ - 0, V4L2_SLICED_WSS_625, 0, /* 4 */ - V4L2_SLICED_CAPTION_525, /* 6 */ - 0, 0, V4L2_SLICED_VPS, 0, 0, /* 9 */ - 0, 0, 0, 0 - }; - int is_pal = !(state->std & V4L2_STD_525_60); - int i; - - fmt = arg; - if (fmt->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE) - return -EINVAL; - svbi = &fmt->fmt.sliced; - memset(svbi, 0, sizeof(*svbi)); - /* we're done if raw VBI is active */ - if ((cx18_av_read(cx, 0x404) & 0x10) == 0) - break; - - if (is_pal) { - for (i = 7; i <= 23; i++) { - u8 v = cx18_av_read(cx, 0x424 + i - 7); - - svbi->service_lines[0][i] = lcr2vbi[v >> 4]; - svbi->service_lines[1][i] = lcr2vbi[v & 0xf]; - svbi->service_set |= svbi->service_lines[0][i] | - svbi->service_lines[1][i]; - } - } else { - for (i = 10; i <= 21; i++) { - u8 v = cx18_av_read(cx, 0x424 + i - 10); - - svbi->service_lines[0][i] = lcr2vbi[v >> 4]; - svbi->service_lines[1][i] = lcr2vbi[v & 0xf]; - svbi->service_set |= svbi->service_lines[0][i] | - svbi->service_lines[1][i]; - } - } - break; - } - - case VIDIOC_S_FMT: - { - int is_pal = !(state->std & V4L2_STD_525_60); - int vbi_offset = is_pal ? 1 : 0; - int i, x; - u8 lcr[24]; - - fmt = arg; - if (fmt->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE) - return -EINVAL; - svbi = &fmt->fmt.sliced; - if (svbi->service_set == 0) { - /* raw VBI */ - memset(svbi, 0, sizeof(*svbi)); - - /* Setup VBI */ - cx18_av_vbi_setup(cx); - - /* VBI Offset */ - cx18_av_write(cx, 0x47f, vbi_offset); - cx18_av_write(cx, 0x404, 0x2e); - break; - } - - for (x = 0; x <= 23; x++) - lcr[x] = 0x00; - - /* Setup VBI */ - cx18_av_vbi_setup(cx); - - /* Sliced VBI */ - cx18_av_write(cx, 0x404, 0x32); /* Ancillary data */ - cx18_av_write(cx, 0x406, 0x13); - cx18_av_write(cx, 0x47f, vbi_offset); - - if (is_pal) { - for (i = 0; i <= 6; i++) - svbi->service_lines[0][i] = - svbi->service_lines[1][i] = 0; - } else { - for (i = 0; i <= 9; i++) - svbi->service_lines[0][i] = - svbi->service_lines[1][i] = 0; - - for (i = 22; i <= 23; i++) - svbi->service_lines[0][i] = - svbi->service_lines[1][i] = 0; - } - - for (i = 7; i <= 23; i++) { - for (x = 0; x <= 1; x++) { - switch (svbi->service_lines[1-x][i]) { - case V4L2_SLICED_TELETEXT_B: - lcr[i] |= 1 << (4 * x); - break; - case V4L2_SLICED_WSS_625: - lcr[i] |= 4 << (4 * x); - break; - case V4L2_SLICED_CAPTION_525: - lcr[i] |= 6 << (4 * x); - break; - case V4L2_SLICED_VPS: - lcr[i] |= 9 << (4 * x); - break; - } - } - } - - if (is_pal) { - for (x = 1, i = 0x424; i <= 0x434; i++, x++) - cx18_av_write(cx, i, lcr[6 + x]); - } else { - for (x = 1, i = 0x424; i <= 0x430; i++, x++) - cx18_av_write(cx, i, lcr[9 + x]); - for (i = 0x431; i <= 0x434; i++) - cx18_av_write(cx, i, 0); - } - - cx18_av_write(cx, 0x43c, 0x16); - cx18_av_write(cx, 0x474, is_pal ? 0x2a : 0x22); - break; - } - - case VIDIOC_INT_DECODE_VBI_LINE: - { - struct v4l2_decode_vbi_line *vbi = arg; - u8 *p = vbi->p; - int id1, id2, l, err = 0; - - if (p[0] || p[1] != 0xff || p[2] != 0xff || - (p[3] != 0x55 && p[3] != 0x91)) { - vbi->line = vbi->type = 0; - break; - } - - p += 4; - id1 = p[-1]; - id2 = p[0] & 0xf; - l = p[2] & 0x3f; - l += state->vbi_line_offset; - p += 4; - - switch (id2) { - case 1: - id2 = V4L2_SLICED_TELETEXT_B; - break; - case 4: - id2 = V4L2_SLICED_WSS_625; - break; - case 6: - id2 = V4L2_SLICED_CAPTION_525; - err = !odd_parity(p[0]) || !odd_parity(p[1]); - break; - case 9: - id2 = V4L2_SLICED_VPS; - if (decode_vps(p, p) != 0) - err = 1; - break; - default: - id2 = 0; - err = 1; - break; - } - - vbi->type = err ? 0 : id2; - vbi->line = err ? 0 : l; - vbi->is_second_field = err ? 0 : (id1 == 0x55); - vbi->p = p; - break; - } - } - - return 0; -} diff --git a/trunk/drivers/media/video/cx18/cx18-cards.c b/trunk/drivers/media/video/cx18/cx18-cards.c deleted file mode 100644 index f5e3ba1f5354..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-cards.c +++ /dev/null @@ -1,277 +0,0 @@ -/* - * cx18 functions to query card hardware - * - * Derived from ivtv-cards.c - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -#include "cx18-driver.h" -#include "cx18-cards.h" -#include "cx18-i2c.h" -#include - -/********************** card configuration *******************************/ - -/* usual i2c tuner addresses to probe */ -static struct cx18_card_tuner_i2c cx18_i2c_std = { - .radio = { I2C_CLIENT_END }, - .demod = { 0x43, I2C_CLIENT_END }, - .tv = { 0x61, 0x60, I2C_CLIENT_END }, -}; - -/* Please add new PCI IDs to: http://pci-ids.ucw.cz/iii - This keeps the PCI ID database up to date. Note that the entries - must be added under vendor 0x4444 (Conexant) as subsystem IDs. - New vendor IDs should still be added to the vendor ID list. */ - -/* Hauppauge HVR-1600 cards */ - -/* Note: for Hauppauge cards the tveeprom information is used instead - of PCI IDs */ -static const struct cx18_card cx18_card_hvr1600_esmt = { - .type = CX18_CARD_HVR_1600_ESMT, - .name = "Hauppauge HVR-1600", - .comment = "DVB & VBI are not yet supported\n", - .v4l2_capabilities = CX18_CAP_ENCODER, - .hw_audio_ctrl = CX18_HW_CX23418, - .hw_muxer = CX18_HW_CS5345, - .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER | CX18_HW_CS5345, - .video_inputs = { - { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 }, - { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 }, - { CX18_CARD_INPUT_COMPOSITE1, 1, CX23418_COMPOSITE3 }, - { CX18_CARD_INPUT_SVIDEO2, 2, CX23418_SVIDEO2 }, - { CX18_CARD_INPUT_COMPOSITE2, 2, CX23418_COMPOSITE4 }, - }, - .audio_inputs = { - { CX18_CARD_INPUT_AUD_TUNER, - CX23418_AUDIO8, CS5345_IN_1 | CS5345_MCLK_1_5 }, - { CX18_CARD_INPUT_LINE_IN1, - CX23418_AUDIO_SERIAL, CS5345_IN_2 }, - { CX18_CARD_INPUT_LINE_IN2, - CX23418_AUDIO_SERIAL, CS5345_IN_2 }, - }, - .radio_input = { CX18_CARD_INPUT_AUD_TUNER, - CX23418_AUDIO_SERIAL, 0 }, - .ddr = { - /* ESMT M13S128324A-5B memory */ - .chip_config = 0x003, - .refresh = 0x30c, - .timing1 = 0x44220e82, - .timing2 = 0x08, - .tune_lane = 0, - .initial_emrs = 0, - }, - .gpio_init.initial_value = 0x3001, - .gpio_init.direction = 0x3001, - .i2c = &cx18_i2c_std, -}; - -static const struct cx18_card cx18_card_hvr1600_samsung = { - .type = CX18_CARD_HVR_1600_SAMSUNG, - .name = "Hauppauge HVR-1600 (Preproduction)", - .comment = "DVB & VBI are not yet supported\n", - .v4l2_capabilities = CX18_CAP_ENCODER, - .hw_audio_ctrl = CX18_HW_CX23418, - .hw_muxer = CX18_HW_CS5345, - .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER | CX18_HW_CS5345, - .video_inputs = { - { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 }, - { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 }, - { CX18_CARD_INPUT_COMPOSITE1, 1, CX23418_COMPOSITE3 }, - { CX18_CARD_INPUT_SVIDEO2, 2, CX23418_SVIDEO2 }, - { CX18_CARD_INPUT_COMPOSITE2, 2, CX23418_COMPOSITE4 }, - }, - .audio_inputs = { - { CX18_CARD_INPUT_AUD_TUNER, - CX23418_AUDIO8, CS5345_IN_1 | CS5345_MCLK_1_5 }, - { CX18_CARD_INPUT_LINE_IN1, - CX23418_AUDIO_SERIAL, CS5345_IN_2 }, - { CX18_CARD_INPUT_LINE_IN2, - CX23418_AUDIO_SERIAL, CS5345_IN_2 }, - }, - .radio_input = { CX18_CARD_INPUT_AUD_TUNER, - CX23418_AUDIO_SERIAL, 0 }, - .ddr = { - /* Samsung K4D263238G-VC33 memory */ - .chip_config = 0x003, - .refresh = 0x30c, - .timing1 = 0x23230b73, - .timing2 = 0x08, - .tune_lane = 0, - .initial_emrs = 2, - }, - .gpio_init.initial_value = 0x3001, - .gpio_init.direction = 0x3001, - .i2c = &cx18_i2c_std, -}; - -/* ------------------------------------------------------------------------- */ - -/* Compro VideoMate H900: not working at the moment! */ - -static const struct cx18_card_pci_info cx18_pci_h900[] = { - { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_COMPRO, 0xe100 }, - { 0, 0, 0 } -}; - -static const struct cx18_card cx18_card_h900 = { - .type = CX18_CARD_COMPRO_H900, - .name = "Compro VideoMate H900", - .comment = "Not yet supported!\n", - .v4l2_capabilities = 0, - .hw_audio_ctrl = CX18_HW_CX23418, - .hw_all = CX18_HW_TUNER, - .video_inputs = { - { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 }, - { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 }, - { CX18_CARD_INPUT_COMPOSITE1, 1, CX23418_COMPOSITE3 }, - }, - .audio_inputs = { - { CX18_CARD_INPUT_AUD_TUNER, - CX23418_AUDIO8, 0 }, - { CX18_CARD_INPUT_LINE_IN1, - CX23418_AUDIO_SERIAL, 0 }, - }, - .radio_input = { CX18_CARD_INPUT_AUD_TUNER, - CX23418_AUDIO_SERIAL, 0 }, - .tuners = { - { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 }, - }, - .ddr = { - /* EtronTech EM6A9160TS-5G memory */ - .chip_config = 0x50003, - .refresh = 0x753, - .timing1 = 0x24330e84, - .timing2 = 0x1f, - .tune_lane = 0, - .initial_emrs = 0, - }, - .pci_list = cx18_pci_h900, - .i2c = &cx18_i2c_std, -}; - -/* ------------------------------------------------------------------------- */ - -/* Yuan MPC718: not working at the moment! */ - -static const struct cx18_card_pci_info cx18_pci_mpc718[] = { - { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_YUAN, 0x0718 }, - { 0, 0, 0 } -}; - -static const struct cx18_card cx18_card_mpc718 = { - .type = CX18_CARD_YUAN_MPC718, - .name = "Yuan MPC718", - .comment = "Not yet supported!\n", - .v4l2_capabilities = 0, - .hw_audio_ctrl = CX18_HW_CX23418, - .hw_all = CX18_HW_TUNER, - .video_inputs = { - { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 }, - { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 }, - { CX18_CARD_INPUT_COMPOSITE1, 1, CX23418_COMPOSITE3 }, - }, - .audio_inputs = { - { CX18_CARD_INPUT_AUD_TUNER, - CX23418_AUDIO8, 0 }, - { CX18_CARD_INPUT_LINE_IN1, - CX23418_AUDIO_SERIAL, 0 }, - }, - .radio_input = { CX18_CARD_INPUT_AUD_TUNER, - CX23418_AUDIO_SERIAL, 0 }, - .tuners = { - /* XC3028 tuner */ - { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 }, - }, - /* tuner reset */ - .gpio_init = { .direction = 0x1000, .initial_value = 0x1000 }, - .ddr = { - /* Probably Samsung K4D263238G-VC33 memory */ - .chip_config = 0x003, - .refresh = 0x30c, - .timing1 = 0x23230b73, - .timing2 = 0x08, - .tune_lane = 0, - .initial_emrs = 2, - }, - .pci_list = cx18_pci_mpc718, - .i2c = &cx18_i2c_std, -}; - -static const struct cx18_card *cx18_card_list[] = { - &cx18_card_hvr1600_esmt, - &cx18_card_hvr1600_samsung, - &cx18_card_h900, - &cx18_card_mpc718, -}; - -const struct cx18_card *cx18_get_card(u16 index) -{ - if (index >= ARRAY_SIZE(cx18_card_list)) - return NULL; - return cx18_card_list[index]; -} - -int cx18_get_input(struct cx18 *cx, u16 index, struct v4l2_input *input) -{ - const struct cx18_card_video_input *card_input = - cx->card->video_inputs + index; - static const char * const input_strs[] = { - "Tuner 1", - "S-Video 1", - "S-Video 2", - "Composite 1", - "Composite 2", - "Composite 3" - }; - - memset(input, 0, sizeof(*input)); - if (index >= cx->nof_inputs) - return -EINVAL; - input->index = index; - strlcpy(input->name, input_strs[card_input->video_type - 1], - sizeof(input->name)); - input->type = (card_input->video_type == CX18_CARD_INPUT_VID_TUNER ? - V4L2_INPUT_TYPE_TUNER : V4L2_INPUT_TYPE_CAMERA); - input->audioset = (1 << cx->nof_audio_inputs) - 1; - input->std = (input->type == V4L2_INPUT_TYPE_TUNER) ? - cx->tuner_std : V4L2_STD_ALL; - return 0; -} - -int cx18_get_audio_input(struct cx18 *cx, u16 index, struct v4l2_audio *audio) -{ - const struct cx18_card_audio_input *aud_input = - cx->card->audio_inputs + index; - static const char * const input_strs[] = { - "Tuner 1", - "Line In 1", - "Line In 2" - }; - - memset(audio, 0, sizeof(*audio)); - if (index >= cx->nof_audio_inputs) - return -EINVAL; - strlcpy(audio->name, input_strs[aud_input->audio_type - 1], - sizeof(audio->name)); - audio->index = index; - audio->capability = V4L2_AUDCAP_STEREO; - return 0; -} diff --git a/trunk/drivers/media/video/cx18/cx18-cards.h b/trunk/drivers/media/video/cx18/cx18-cards.h deleted file mode 100644 index bca249bdd337..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-cards.h +++ /dev/null @@ -1,170 +0,0 @@ -/* - * cx18 functions to query card hardware - * - * Derived from ivtv-cards.c - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* hardware flags */ -#define CX18_HW_TUNER (1 << 0) -#define CX18_HW_TVEEPROM (1 << 1) -#define CX18_HW_CS5345 (1 << 2) -#define CX18_HW_GPIO (1 << 3) -#define CX18_HW_CX23418 (1 << 4) -#define CX18_HW_DVB (1 << 5) - -/* video inputs */ -#define CX18_CARD_INPUT_VID_TUNER 1 -#define CX18_CARD_INPUT_SVIDEO1 2 -#define CX18_CARD_INPUT_SVIDEO2 3 -#define CX18_CARD_INPUT_COMPOSITE1 4 -#define CX18_CARD_INPUT_COMPOSITE2 5 -#define CX18_CARD_INPUT_COMPOSITE3 6 - -enum cx34180_video_input { - /* Composite video inputs In1-In8 */ - CX23418_COMPOSITE1 = 1, - CX23418_COMPOSITE2, - CX23418_COMPOSITE3, - CX23418_COMPOSITE4, - CX23418_COMPOSITE5, - CX23418_COMPOSITE6, - CX23418_COMPOSITE7, - CX23418_COMPOSITE8, - - /* S-Video inputs consist of one luma input (In1-In4) ORed with one - chroma input (In5-In8) */ - CX23418_SVIDEO_LUMA1 = 0x10, - CX23418_SVIDEO_LUMA2 = 0x20, - CX23418_SVIDEO_LUMA3 = 0x30, - CX23418_SVIDEO_LUMA4 = 0x40, - CX23418_SVIDEO_CHROMA4 = 0x400, - CX23418_SVIDEO_CHROMA5 = 0x500, - CX23418_SVIDEO_CHROMA6 = 0x600, - CX23418_SVIDEO_CHROMA7 = 0x700, - CX23418_SVIDEO_CHROMA8 = 0x800, - - /* S-Video aliases for common luma/chroma combinations */ - CX23418_SVIDEO1 = 0x510, - CX23418_SVIDEO2 = 0x620, - CX23418_SVIDEO3 = 0x730, - CX23418_SVIDEO4 = 0x840, -}; - -/* audio inputs */ -#define CX18_CARD_INPUT_AUD_TUNER 1 -#define CX18_CARD_INPUT_LINE_IN1 2 -#define CX18_CARD_INPUT_LINE_IN2 3 - -#define CX18_CARD_MAX_VIDEO_INPUTS 6 -#define CX18_CARD_MAX_AUDIO_INPUTS 3 -#define CX18_CARD_MAX_TUNERS 2 - -enum cx23418_audio_input { - /* Audio inputs: serial or In4-In8 */ - CX23418_AUDIO_SERIAL, - CX23418_AUDIO4 = 4, - CX23418_AUDIO5, - CX23418_AUDIO6, - CX23418_AUDIO7, - CX23418_AUDIO8, -}; - -/* V4L2 capability aliases */ -#define CX18_CAP_ENCODER (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_TUNER | \ - V4L2_CAP_AUDIO | V4L2_CAP_READWRITE) -/* | V4L2_CAP_VBI_CAPTURE | V4L2_CAP_SLICED_VBI_CAPTURE) not yet */ - -struct cx18_card_video_input { - u8 video_type; /* video input type */ - u8 audio_index; /* index in cx18_card_audio_input array */ - u16 video_input; /* hardware video input */ -}; - -struct cx18_card_audio_input { - u8 audio_type; /* audio input type */ - u32 audio_input; /* hardware audio input */ - u16 muxer_input; /* hardware muxer input for boards with a - multiplexer chip */ -}; - -struct cx18_card_pci_info { - u16 device; - u16 subsystem_vendor; - u16 subsystem_device; -}; - -/* GPIO definitions */ - -/* The mask is the set of bits used by the operation */ - -struct cx18_gpio_init { /* set initial GPIO DIR and OUT values */ - u16 direction; /* DIR setting. Leave to 0 if no init is needed */ - u16 initial_value; -}; - -struct cx18_card_tuner { - v4l2_std_id std; /* standard for which the tuner is suitable */ - int tuner; /* tuner ID (from tuner.h) */ -}; - -struct cx18_card_tuner_i2c { - unsigned short radio[2];/* radio tuner i2c address to probe */ - unsigned short demod[2];/* demodulator i2c address to probe */ - unsigned short tv[4]; /* tv tuner i2c addresses to probe */ -}; - -struct cx18_ddr { /* DDR config data */ - u32 chip_config; - u32 refresh; - u32 timing1; - u32 timing2; - u32 tune_lane; - u32 initial_emrs; -}; - -/* for card information/parameters */ -struct cx18_card { - int type; - char *name; - char *comment; - u32 v4l2_capabilities; - u32 hw_audio_ctrl; /* hardware used for the V4L2 controls (only - 1 dev allowed) */ - u32 hw_muxer; /* hardware used to multiplex audio input */ - u32 hw_all; /* all hardware used by the board */ - struct cx18_card_video_input video_inputs[CX18_CARD_MAX_VIDEO_INPUTS]; - struct cx18_card_audio_input audio_inputs[CX18_CARD_MAX_AUDIO_INPUTS]; - struct cx18_card_audio_input radio_input; - - /* GPIO card-specific settings */ - struct cx18_gpio_init gpio_init; - - struct cx18_card_tuner tuners[CX18_CARD_MAX_TUNERS]; - struct cx18_card_tuner_i2c *i2c; - - struct cx18_ddr ddr; - - /* list of device and subsystem vendor/devices that - correspond to this card type. */ - const struct cx18_card_pci_info *pci_list; -}; - -int cx18_get_input(struct cx18 *cx, u16 index, struct v4l2_input *input); -int cx18_get_audio_input(struct cx18 *cx, u16 index, struct v4l2_audio *input); -const struct cx18_card *cx18_get_card(u16 index); diff --git a/trunk/drivers/media/video/cx18/cx18-controls.c b/trunk/drivers/media/video/cx18/cx18-controls.c deleted file mode 100644 index 2bdac5ebbb0d..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-controls.c +++ /dev/null @@ -1,306 +0,0 @@ -/* - * cx18 ioctl control functions - * - * Derived from ivtv-controls.c - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -#include "cx18-driver.h" -#include "cx18-av-core.h" -#include "cx18-cards.h" -#include "cx18-ioctl.h" -#include "cx18-audio.h" -#include "cx18-i2c.h" -#include "cx18-mailbox.h" -#include "cx18-controls.h" - -static const u32 user_ctrls[] = { - V4L2_CID_USER_CLASS, - V4L2_CID_BRIGHTNESS, - V4L2_CID_CONTRAST, - V4L2_CID_SATURATION, - V4L2_CID_HUE, - V4L2_CID_AUDIO_VOLUME, - V4L2_CID_AUDIO_BALANCE, - V4L2_CID_AUDIO_BASS, - V4L2_CID_AUDIO_TREBLE, - V4L2_CID_AUDIO_MUTE, - V4L2_CID_AUDIO_LOUDNESS, - 0 -}; - -static const u32 *ctrl_classes[] = { - user_ctrls, - cx2341x_mpeg_ctrls, - NULL -}; - -static int cx18_queryctrl(struct cx18 *cx, struct v4l2_queryctrl *qctrl) -{ - const char *name; - - CX18_DEBUG_IOCTL("VIDIOC_QUERYCTRL(%08x)\n", qctrl->id); - - qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id); - if (qctrl->id == 0) - return -EINVAL; - - switch (qctrl->id) { - /* Standard V4L2 controls */ - case V4L2_CID_BRIGHTNESS: - case V4L2_CID_HUE: - case V4L2_CID_SATURATION: - case V4L2_CID_CONTRAST: - if (cx18_av_cmd(cx, VIDIOC_QUERYCTRL, qctrl)) - qctrl->flags |= V4L2_CTRL_FLAG_DISABLED; - return 0; - - case V4L2_CID_AUDIO_VOLUME: - case V4L2_CID_AUDIO_MUTE: - case V4L2_CID_AUDIO_BALANCE: - case V4L2_CID_AUDIO_BASS: - case V4L2_CID_AUDIO_TREBLE: - case V4L2_CID_AUDIO_LOUDNESS: - if (cx18_i2c_hw(cx, cx->card->hw_audio_ctrl, VIDIOC_QUERYCTRL, qctrl)) - qctrl->flags |= V4L2_CTRL_FLAG_DISABLED; - return 0; - - default: - if (cx2341x_ctrl_query(&cx->params, qctrl)) - qctrl->flags |= V4L2_CTRL_FLAG_DISABLED; - return 0; - } - strncpy(qctrl->name, name, sizeof(qctrl->name) - 1); - qctrl->name[sizeof(qctrl->name) - 1] = 0; - return 0; -} - -static int cx18_querymenu(struct cx18 *cx, struct v4l2_querymenu *qmenu) -{ - struct v4l2_queryctrl qctrl; - - qctrl.id = qmenu->id; - cx18_queryctrl(cx, &qctrl); - return v4l2_ctrl_query_menu(qmenu, &qctrl, cx2341x_ctrl_get_menu(qmenu->id)); -} - -static int cx18_s_ctrl(struct cx18 *cx, struct v4l2_control *vctrl) -{ - s32 v = vctrl->value; - - CX18_DEBUG_IOCTL("VIDIOC_S_CTRL(%08x, %x)\n", vctrl->id, v); - - switch (vctrl->id) { - /* Standard V4L2 controls */ - case V4L2_CID_BRIGHTNESS: - case V4L2_CID_HUE: - case V4L2_CID_SATURATION: - case V4L2_CID_CONTRAST: - return cx18_av_cmd(cx, VIDIOC_S_CTRL, vctrl); - - case V4L2_CID_AUDIO_VOLUME: - case V4L2_CID_AUDIO_MUTE: - case V4L2_CID_AUDIO_BALANCE: - case V4L2_CID_AUDIO_BASS: - case V4L2_CID_AUDIO_TREBLE: - case V4L2_CID_AUDIO_LOUDNESS: - return cx18_i2c_hw(cx, cx->card->hw_audio_ctrl, VIDIOC_S_CTRL, vctrl); - - default: - CX18_DEBUG_IOCTL("invalid control %x\n", vctrl->id); - return -EINVAL; - } - return 0; -} - -static int cx18_g_ctrl(struct cx18 *cx, struct v4l2_control *vctrl) -{ - CX18_DEBUG_IOCTL("VIDIOC_G_CTRL(%08x)\n", vctrl->id); - - switch (vctrl->id) { - /* Standard V4L2 controls */ - case V4L2_CID_BRIGHTNESS: - case V4L2_CID_HUE: - case V4L2_CID_SATURATION: - case V4L2_CID_CONTRAST: - return cx18_av_cmd(cx, VIDIOC_G_CTRL, vctrl); - - case V4L2_CID_AUDIO_VOLUME: - case V4L2_CID_AUDIO_MUTE: - case V4L2_CID_AUDIO_BALANCE: - case V4L2_CID_AUDIO_BASS: - case V4L2_CID_AUDIO_TREBLE: - case V4L2_CID_AUDIO_LOUDNESS: - return cx18_i2c_hw(cx, cx->card->hw_audio_ctrl, VIDIOC_G_CTRL, vctrl); - default: - CX18_DEBUG_IOCTL("invalid control %x\n", vctrl->id); - return -EINVAL; - } - return 0; -} - -static int cx18_setup_vbi_fmt(struct cx18 *cx, enum v4l2_mpeg_stream_vbi_fmt fmt) -{ - if (!(cx->v4l2_cap & V4L2_CAP_SLICED_VBI_CAPTURE)) - return -EINVAL; - if (atomic_read(&cx->capturing) > 0) - return -EBUSY; - - /* First try to allocate sliced VBI buffers if needed. */ - if (fmt && cx->vbi.sliced_mpeg_data[0] == NULL) { - int i; - - for (i = 0; i < CX18_VBI_FRAMES; i++) { - /* Yuck, hardcoded. Needs to be a define */ - cx->vbi.sliced_mpeg_data[i] = kmalloc(2049, GFP_KERNEL); - if (cx->vbi.sliced_mpeg_data[i] == NULL) { - while (--i >= 0) { - kfree(cx->vbi.sliced_mpeg_data[i]); - cx->vbi.sliced_mpeg_data[i] = NULL; - } - return -ENOMEM; - } - } - } - - cx->vbi.insert_mpeg = fmt; - - if (cx->vbi.insert_mpeg == 0) - return 0; - /* Need sliced data for mpeg insertion */ - if (cx18_get_service_set(cx->vbi.sliced_in) == 0) { - if (cx->is_60hz) - cx->vbi.sliced_in->service_set = V4L2_SLICED_CAPTION_525; - else - cx->vbi.sliced_in->service_set = V4L2_SLICED_WSS_625; - cx18_expand_service_set(cx->vbi.sliced_in, cx->is_50hz); - } - return 0; -} - -int cx18_control_ioctls(struct cx18 *cx, unsigned int cmd, void *arg) -{ - struct v4l2_control ctrl; - - switch (cmd) { - case VIDIOC_QUERYMENU: - CX18_DEBUG_IOCTL("VIDIOC_QUERYMENU\n"); - return cx18_querymenu(cx, arg); - - case VIDIOC_QUERYCTRL: - return cx18_queryctrl(cx, arg); - - case VIDIOC_S_CTRL: - return cx18_s_ctrl(cx, arg); - - case VIDIOC_G_CTRL: - return cx18_g_ctrl(cx, arg); - - case VIDIOC_S_EXT_CTRLS: - { - struct v4l2_ext_controls *c = arg; - - if (c->ctrl_class == V4L2_CTRL_CLASS_USER) { - int i; - int err = 0; - - for (i = 0; i < c->count; i++) { - ctrl.id = c->controls[i].id; - ctrl.value = c->controls[i].value; - err = cx18_s_ctrl(cx, &ctrl); - c->controls[i].value = ctrl.value; - if (err) { - c->error_idx = i; - break; - } - } - return err; - } - CX18_DEBUG_IOCTL("VIDIOC_S_EXT_CTRLS\n"); - if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) { - struct cx2341x_mpeg_params p = cx->params; - int err = cx2341x_ext_ctrls(&p, atomic_read(&cx->capturing), arg, cmd); - - if (err) - return err; - - if (p.video_encoding != cx->params.video_encoding) { - int is_mpeg1 = p.video_encoding == - V4L2_MPEG_VIDEO_ENCODING_MPEG_1; - struct v4l2_format fmt; - - /* fix videodecoder resolution */ - fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - fmt.fmt.pix.width = cx->params.width / (is_mpeg1 ? 2 : 1); - fmt.fmt.pix.height = cx->params.height; - cx18_av_cmd(cx, VIDIOC_S_FMT, &fmt); - } - err = cx2341x_update(cx, cx18_api_func, &cx->params, &p); - if (!err && cx->params.stream_vbi_fmt != p.stream_vbi_fmt) - err = cx18_setup_vbi_fmt(cx, p.stream_vbi_fmt); - cx->params = p; - cx->dualwatch_stereo_mode = p.audio_properties & 0x0300; - cx18_audio_set_audio_clock_freq(cx, p.audio_properties & 0x03); - return err; - } - return -EINVAL; - } - - case VIDIOC_G_EXT_CTRLS: - { - struct v4l2_ext_controls *c = arg; - - if (c->ctrl_class == V4L2_CTRL_CLASS_USER) { - int i; - int err = 0; - - for (i = 0; i < c->count; i++) { - ctrl.id = c->controls[i].id; - ctrl.value = c->controls[i].value; - err = cx18_g_ctrl(cx, &ctrl); - c->controls[i].value = ctrl.value; - if (err) { - c->error_idx = i; - break; - } - } - return err; - } - CX18_DEBUG_IOCTL("VIDIOC_G_EXT_CTRLS\n"); - if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) - return cx2341x_ext_ctrls(&cx->params, 0, arg, cmd); - return -EINVAL; - } - - case VIDIOC_TRY_EXT_CTRLS: - { - struct v4l2_ext_controls *c = arg; - - CX18_DEBUG_IOCTL("VIDIOC_TRY_EXT_CTRLS\n"); - if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) - return cx2341x_ext_ctrls(&cx->params, - atomic_read(&cx->capturing), arg, cmd); - return -EINVAL; - } - - default: - return -EINVAL; - } - return 0; -} diff --git a/trunk/drivers/media/video/cx18/cx18-controls.h b/trunk/drivers/media/video/cx18/cx18-controls.h deleted file mode 100644 index 6e985cf422a0..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-controls.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * cx18 ioctl control functions - * - * Derived from ivtv-controls.h - * - * Copyright (C) 2007 Hans Verkuil - - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -int cx18_control_ioctls(struct cx18 *cx, unsigned int cmd, void *arg); diff --git a/trunk/drivers/media/video/cx18/cx18-driver.c b/trunk/drivers/media/video/cx18/cx18-driver.c deleted file mode 100644 index 9f31befc3139..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-driver.c +++ /dev/null @@ -1,971 +0,0 @@ -/* - * cx18 driver initialization and card probing - * - * Derived from ivtv-driver.c - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -#include "cx18-driver.h" -#include "cx18-version.h" -#include "cx18-cards.h" -#include "cx18-i2c.h" -#include "cx18-irq.h" -#include "cx18-gpio.h" -#include "cx18-firmware.h" -#include "cx18-streams.h" -#include "cx18-av-core.h" -#include "cx18-scb.h" -#include "cx18-mailbox.h" -#include "cx18-ioctl.h" -#include "tuner-xc2028.h" - -#include - - -/* var to keep track of the number of array elements in use */ -int cx18_cards_active; - -/* If you have already X v4l cards, then set this to X. This way - the device numbers stay matched. Example: you have a WinTV card - without radio and a Compro H900 with. Normally this would give a - video1 device together with a radio0 device for the Compro. By - setting this to 1 you ensure that radio0 is now also radio1. */ -int cx18_first_minor; - -/* Master variable for all cx18 info */ -struct cx18 *cx18_cards[CX18_MAX_CARDS]; - -/* Protects cx18_cards_active */ -DEFINE_SPINLOCK(cx18_cards_lock); - -/* add your revision and whatnot here */ -static struct pci_device_id cx18_pci_tbl[] __devinitdata = { - {PCI_VENDOR_ID_CX, PCI_DEVICE_ID_CX23418, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {0,} -}; - -MODULE_DEVICE_TABLE(pci, cx18_pci_tbl); - -/* Parameter declarations */ -static int cardtype[CX18_MAX_CARDS]; -static int tuner[CX18_MAX_CARDS] = { -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1 }; -static int radio[CX18_MAX_CARDS] = { -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1 }; - -static int cardtype_c = 1; -static int tuner_c = 1; -static int radio_c = 1; -static char pal[] = "--"; -static char secam[] = "--"; -static char ntsc[] = "-"; - -/* Buffers */ -static int enc_mpg_buffers = CX18_DEFAULT_ENC_MPG_BUFFERS; -static int enc_ts_buffers = CX18_DEFAULT_ENC_TS_BUFFERS; -static int enc_yuv_buffers = CX18_DEFAULT_ENC_YUV_BUFFERS; -static int enc_vbi_buffers = CX18_DEFAULT_ENC_VBI_BUFFERS; -static int enc_pcm_buffers = CX18_DEFAULT_ENC_PCM_BUFFERS; - -static int cx18_pci_latency = 1; - -int cx18_debug; - -module_param_array(tuner, int, &tuner_c, 0644); -module_param_array(radio, bool, &radio_c, 0644); -module_param_array(cardtype, int, &cardtype_c, 0644); -module_param_string(pal, pal, sizeof(pal), 0644); -module_param_string(secam, secam, sizeof(secam), 0644); -module_param_string(ntsc, ntsc, sizeof(ntsc), 0644); -module_param_named(debug, cx18_debug, int, 0644); -module_param(cx18_pci_latency, int, 0644); -module_param(cx18_first_minor, int, 0644); - -module_param(enc_mpg_buffers, int, 0644); -module_param(enc_ts_buffers, int, 0644); -module_param(enc_yuv_buffers, int, 0644); -module_param(enc_vbi_buffers, int, 0644); -module_param(enc_pcm_buffers, int, 0644); - -MODULE_PARM_DESC(tuner, "Tuner type selection,\n" - "\t\t\tsee tuner.h for values"); -MODULE_PARM_DESC(radio, - "Enable or disable the radio. Use only if autodetection\n" - "\t\t\tfails. 0 = disable, 1 = enable"); -MODULE_PARM_DESC(cardtype, - "Only use this option if your card is not detected properly.\n" - "\t\tSpecify card type:\n" - "\t\t\t 1 = Hauppauge HVR 1600 (ESMT memory)\n" - "\t\t\t 2 = Hauppauge HVR 1600 (Samsung memory)\n" - "\t\t\t 3 = Compro VideoMate H900\n" - "\t\t\t 4 = Yuan MPC718\n" - "\t\t\t 0 = Autodetect (default)\n" - "\t\t\t-1 = Ignore this card\n\t\t"); -MODULE_PARM_DESC(pal, "Set PAL standard: B, G, H, D, K, I, M, N, Nc, 60"); -MODULE_PARM_DESC(secam, "Set SECAM standard: B, G, H, D, K, L, LC"); -MODULE_PARM_DESC(ntsc, "Set NTSC standard: M, J, K"); -MODULE_PARM_DESC(debug, - "Debug level (bitmask). Default: 0\n" - "\t\t\t 1/0x0001: warning\n" - "\t\t\t 2/0x0002: info\n" - "\t\t\t 4/0x0004: mailbox\n" - "\t\t\t 8/0x0008: dma\n" - "\t\t\t 16/0x0010: ioctl\n" - "\t\t\t 32/0x0020: file\n" - "\t\t\t 64/0x0040: i2c\n" - "\t\t\t128/0x0080: irq\n" - "\t\t\t256/0x0100: high volume\n"); -MODULE_PARM_DESC(cx18_pci_latency, - "Change the PCI latency to 64 if lower: 0 = No, 1 = Yes,\n" - "\t\t\tDefault: Yes"); -MODULE_PARM_DESC(enc_mpg_buffers, - "Encoder MPG Buffers (in MB)\n" - "\t\t\tDefault: " __stringify(CX18_DEFAULT_ENC_MPG_BUFFERS)); -MODULE_PARM_DESC(enc_ts_buffers, - "Encoder TS Buffers (in MB)\n" - "\t\t\tDefault: " __stringify(CX18_DEFAULT_ENC_TS_BUFFERS)); -MODULE_PARM_DESC(enc_yuv_buffers, - "Encoder YUV Buffers (in MB)\n" - "\t\t\tDefault: " __stringify(CX18_DEFAULT_ENC_YUV_BUFFERS)); -MODULE_PARM_DESC(enc_vbi_buffers, - "Encoder VBI Buffers (in MB)\n" - "\t\t\tDefault: " __stringify(CX18_DEFAULT_ENC_VBI_BUFFERS)); -MODULE_PARM_DESC(enc_pcm_buffers, - "Encoder PCM buffers (in MB)\n" - "\t\t\tDefault: " __stringify(CX18_DEFAULT_ENC_PCM_BUFFERS)); - -MODULE_PARM_DESC(cx18_first_minor, "Set minor assigned to first card"); - -MODULE_AUTHOR("Hans Verkuil"); -MODULE_DESCRIPTION("CX23418 driver"); -MODULE_SUPPORTED_DEVICE("CX23418 MPEG2 encoder"); -MODULE_LICENSE("GPL"); - -MODULE_VERSION(CX18_VERSION); - -int cx18_waitq(wait_queue_head_t *waitq) -{ - DEFINE_WAIT(wait); - - prepare_to_wait(waitq, &wait, TASK_INTERRUPTIBLE); - schedule(); - finish_wait(waitq, &wait); - return signal_pending(current) ? -EINTR : 0; -} - -/* Generic utility functions */ -int cx18_msleep_timeout(unsigned int msecs, int intr) -{ - int timeout = msecs_to_jiffies(msecs); - int sig; - - do { - set_current_state(intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE); - timeout = schedule_timeout(timeout); - sig = intr ? signal_pending(current) : 0; - } while (!sig && timeout); - return sig; -} - -/* Release ioremapped memory */ -static void cx18_iounmap(struct cx18 *cx) -{ - if (cx == NULL) - return; - - /* Release io memory */ - if (cx->enc_mem != NULL) { - CX18_DEBUG_INFO("releasing enc_mem\n"); - iounmap(cx->enc_mem); - cx->enc_mem = NULL; - } -} - -/* Hauppauge card? get values from tveeprom */ -void cx18_read_eeprom(struct cx18 *cx, struct tveeprom *tv) -{ - u8 eedata[256]; - - cx->i2c_client[0].addr = 0xA0 >> 1; - tveeprom_read(&cx->i2c_client[0], eedata, sizeof(eedata)); - tveeprom_hauppauge_analog(&cx->i2c_client[0], tv, eedata); -} - -static void cx18_process_eeprom(struct cx18 *cx) -{ - struct tveeprom tv; - - cx18_read_eeprom(cx, &tv); - - /* Many thanks to Steven Toth from Hauppauge for providing the - model numbers */ - switch (tv.model) { - case 74000 ... 74099: - cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT); - break; - case 74700 ... 74799: - cx->card = cx18_get_card(CX18_CARD_HVR_1600_SAMSUNG); - break; - case 0: - CX18_ERR("Invalid EEPROM\n"); - return; - default: - CX18_ERR("Unknown model %d, defaulting to HVR-1600\n", tv.model); - cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT); - break; - } - - cx->v4l2_cap = cx->card->v4l2_capabilities; - cx->card_name = cx->card->name; - cx->card_i2c = cx->card->i2c; - - CX18_INFO("Autodetected %s\n", cx->card_name); - - if (tv.tuner_type == TUNER_ABSENT) - CX18_ERR("tveeprom cannot autodetect tuner!"); - - if (cx->options.tuner == -1) - cx->options.tuner = tv.tuner_type; - if (cx->options.radio == -1) - cx->options.radio = (tv.has_radio != 0); - - if (cx->std != 0) - /* user specified tuner standard */ - return; - - /* autodetect tuner standard */ - if (tv.tuner_formats & V4L2_STD_PAL) { - CX18_DEBUG_INFO("PAL tuner detected\n"); - cx->std |= V4L2_STD_PAL_BG | V4L2_STD_PAL_H; - } else if (tv.tuner_formats & V4L2_STD_NTSC) { - CX18_DEBUG_INFO("NTSC tuner detected\n"); - cx->std |= V4L2_STD_NTSC_M; - } else if (tv.tuner_formats & V4L2_STD_SECAM) { - CX18_DEBUG_INFO("SECAM tuner detected\n"); - cx->std |= V4L2_STD_SECAM_L; - } else { - CX18_INFO("No tuner detected, default to NTSC-M\n"); - cx->std |= V4L2_STD_NTSC_M; - } -} - -static v4l2_std_id cx18_parse_std(struct cx18 *cx) -{ - switch (pal[0]) { - case '6': - return V4L2_STD_PAL_60; - case 'b': - case 'B': - case 'g': - case 'G': - return V4L2_STD_PAL_BG; - case 'h': - case 'H': - return V4L2_STD_PAL_H; - case 'n': - case 'N': - if (pal[1] == 'c' || pal[1] == 'C') - return V4L2_STD_PAL_Nc; - return V4L2_STD_PAL_N; - case 'i': - case 'I': - return V4L2_STD_PAL_I; - case 'd': - case 'D': - case 'k': - case 'K': - return V4L2_STD_PAL_DK; - case 'M': - case 'm': - return V4L2_STD_PAL_M; - case '-': - break; - default: - CX18_WARN("pal= argument not recognised\n"); - return 0; - } - - switch (secam[0]) { - case 'b': - case 'B': - case 'g': - case 'G': - case 'h': - case 'H': - return V4L2_STD_SECAM_B | V4L2_STD_SECAM_G | V4L2_STD_SECAM_H; - case 'd': - case 'D': - case 'k': - case 'K': - return V4L2_STD_SECAM_DK; - case 'l': - case 'L': - if (secam[1] == 'C' || secam[1] == 'c') - return V4L2_STD_SECAM_LC; - return V4L2_STD_SECAM_L; - case '-': - break; - default: - CX18_WARN("secam= argument not recognised\n"); - return 0; - } - - switch (ntsc[0]) { - case 'm': - case 'M': - return V4L2_STD_NTSC_M; - case 'j': - case 'J': - return V4L2_STD_NTSC_M_JP; - case 'k': - case 'K': - return V4L2_STD_NTSC_M_KR; - case '-': - break; - default: - CX18_WARN("ntsc= argument not recognised\n"); - return 0; - } - - /* no match found */ - return 0; -} - -static void cx18_process_options(struct cx18 *cx) -{ - int i, j; - - cx->options.megabytes[CX18_ENC_STREAM_TYPE_MPG] = enc_mpg_buffers; - cx->options.megabytes[CX18_ENC_STREAM_TYPE_TS] = enc_ts_buffers; - cx->options.megabytes[CX18_ENC_STREAM_TYPE_YUV] = enc_yuv_buffers; - cx->options.megabytes[CX18_ENC_STREAM_TYPE_VBI] = enc_vbi_buffers; - cx->options.megabytes[CX18_ENC_STREAM_TYPE_PCM] = enc_pcm_buffers; - cx->options.cardtype = cardtype[cx->num]; - cx->options.tuner = tuner[cx->num]; - cx->options.radio = radio[cx->num]; - - cx->std = cx18_parse_std(cx); - if (cx->options.cardtype == -1) { - CX18_INFO("Ignore card\n"); - return; - } - cx->card = cx18_get_card(cx->options.cardtype - 1); - if (cx->card) - CX18_INFO("User specified %s card\n", cx->card->name); - else if (cx->options.cardtype != 0) - CX18_ERR("Unknown user specified type, trying to autodetect card\n"); - if (cx->card == NULL) { - if (cx->dev->subsystem_vendor == CX18_PCI_ID_HAUPPAUGE) { - cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT); - CX18_INFO("Autodetected Hauppauge card\n"); - } - } - if (cx->card == NULL) { - for (i = 0; (cx->card = cx18_get_card(i)); i++) { - if (cx->card->pci_list == NULL) - continue; - for (j = 0; cx->card->pci_list[j].device; j++) { - if (cx->dev->device != - cx->card->pci_list[j].device) - continue; - if (cx->dev->subsystem_vendor != - cx->card->pci_list[j].subsystem_vendor) - continue; - if (cx->dev->subsystem_device != - cx->card->pci_list[j].subsystem_device) - continue; - CX18_INFO("Autodetected %s card\n", cx->card->name); - goto done; - } - } - } -done: - - if (cx->card == NULL) { - cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT); - CX18_ERR("Unknown card: vendor/device: %04x/%04x\n", - cx->dev->vendor, cx->dev->device); - CX18_ERR(" subsystem vendor/device: %04x/%04x\n", - cx->dev->subsystem_vendor, cx->dev->subsystem_device); - CX18_ERR("Defaulting to %s card\n", cx->card->name); - CX18_ERR("Please mail the vendor/device and subsystem vendor/device IDs and what kind of\n"); - CX18_ERR("card you have to the ivtv-devel mailinglist (www.ivtvdriver.org)\n"); - CX18_ERR("Prefix your subject line with [UNKNOWN CX18 CARD].\n"); - } - cx->v4l2_cap = cx->card->v4l2_capabilities; - cx->card_name = cx->card->name; - cx->card_i2c = cx->card->i2c; -} - -/* Precondition: the cx18 structure has been memset to 0. Only - the dev and num fields have been filled in. - No assumptions on the card type may be made here (see cx18_init_struct2 - for that). - */ -static int __devinit cx18_init_struct1(struct cx18 *cx) -{ - cx->base_addr = pci_resource_start(cx->dev, 0); - - mutex_init(&cx->serialize_lock); - mutex_init(&cx->i2c_bus_lock[0]); - mutex_init(&cx->i2c_bus_lock[1]); - - spin_lock_init(&cx->lock); - spin_lock_init(&cx->dma_reg_lock); - - /* start counting open_id at 1 */ - cx->open_id = 1; - - /* Initial settings */ - cx2341x_fill_defaults(&cx->params); - cx->temporal_strength = cx->params.video_temporal_filter; - cx->spatial_strength = cx->params.video_spatial_filter; - cx->filter_mode = cx->params.video_spatial_filter_mode | - (cx->params.video_temporal_filter_mode << 1) | - (cx->params.video_median_filter_type << 2); - cx->params.port = CX2341X_PORT_MEMORY; - cx->params.capabilities = CX2341X_CAP_HAS_SLICED_VBI; - init_waitqueue_head(&cx->cap_w); - init_waitqueue_head(&cx->mb_apu_waitq); - init_waitqueue_head(&cx->mb_cpu_waitq); - init_waitqueue_head(&cx->mb_epu_waitq); - init_waitqueue_head(&cx->mb_hpu_waitq); - init_waitqueue_head(&cx->dma_waitq); - - /* VBI */ - cx->vbi.in.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE; - cx->vbi.sliced_in = &cx->vbi.in.fmt.sliced; - cx->vbi.raw_size = 1456; - cx->vbi.raw_decoder_line_size = 1456; - cx->vbi.raw_decoder_sav_odd_field = 0x20; - cx->vbi.raw_decoder_sav_even_field = 0x60; - cx->vbi.sliced_decoder_line_size = 272; - cx->vbi.sliced_decoder_sav_odd_field = 0xB0; - cx->vbi.sliced_decoder_sav_even_field = 0xF0; - return 0; -} - -/* Second initialization part. Here the card type has been - autodetected. */ -static void __devinit cx18_init_struct2(struct cx18 *cx) -{ - int i; - - for (i = 0; i < CX18_CARD_MAX_VIDEO_INPUTS; i++) - if (cx->card->video_inputs[i].video_type == 0) - break; - cx->nof_inputs = i; - for (i = 0; i < CX18_CARD_MAX_AUDIO_INPUTS; i++) - if (cx->card->audio_inputs[i].audio_type == 0) - break; - cx->nof_audio_inputs = i; - - /* Find tuner input */ - for (i = 0; i < cx->nof_inputs; i++) { - if (cx->card->video_inputs[i].video_type == - CX18_CARD_INPUT_VID_TUNER) - break; - } - if (i == cx->nof_inputs) - i = 0; - cx->active_input = i; - cx->audio_input = cx->card->video_inputs[i].audio_index; - cx->av_state.vid_input = CX18_AV_COMPOSITE7; - cx->av_state.aud_input = CX18_AV_AUDIO8; - cx->av_state.audclk_freq = 48000; - cx->av_state.audmode = V4L2_TUNER_MODE_LANG1; - cx->av_state.vbi_line_offset = 8; -} - -static int cx18_setup_pci(struct cx18 *cx, struct pci_dev *dev, - const struct pci_device_id *pci_id) -{ - u16 cmd; - unsigned char pci_latency; - - CX18_DEBUG_INFO("Enabling pci device\n"); - - if (pci_enable_device(dev)) { - CX18_ERR("Can't enable device %d!\n", cx->num); - return -EIO; - } - if (pci_set_dma_mask(dev, 0xffffffff)) { - CX18_ERR("No suitable DMA available on card %d.\n", cx->num); - return -EIO; - } - if (!request_mem_region(cx->base_addr, CX18_MEM_SIZE, "cx18 encoder")) { - CX18_ERR("Cannot request encoder memory region on card %d.\n", cx->num); - return -EIO; - } - - /* Check for bus mastering */ - pci_read_config_word(dev, PCI_COMMAND, &cmd); - cmd |= PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER; - pci_write_config_word(dev, PCI_COMMAND, cmd); - - pci_read_config_byte(dev, PCI_CLASS_REVISION, &cx->card_rev); - pci_read_config_byte(dev, PCI_LATENCY_TIMER, &pci_latency); - - if (pci_latency < 64 && cx18_pci_latency) { - CX18_INFO("Unreasonably low latency timer, " - "setting to 64 (was %d)\n", pci_latency); - pci_write_config_byte(dev, PCI_LATENCY_TIMER, 64); - pci_read_config_byte(dev, PCI_LATENCY_TIMER, &pci_latency); - } - /* This config space value relates to DMA latencies. The - default value 0x8080 is too low however and will lead - to DMA errors. 0xffff is the max value which solves - these problems. */ - pci_write_config_dword(dev, 0x40, 0xffff); - - CX18_DEBUG_INFO("cx%d (rev %d) at %02x:%02x.%x, " - "irq: %d, latency: %d, memory: 0x%lx\n", - cx->dev->device, cx->card_rev, dev->bus->number, - PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), - cx->dev->irq, pci_latency, (unsigned long)cx->base_addr); - - return 0; -} - -static u32 cx18_request_module(struct cx18 *cx, u32 hw, - const char *name, u32 id) -{ - if ((hw & id) == 0) - return hw; - if (request_module(name) != 0) { - CX18_ERR("Failed to load module %s\n", name); - return hw & ~id; - } - CX18_DEBUG_INFO("Loaded module %s\n", name); - return hw; -} - -static void cx18_load_and_init_modules(struct cx18 *cx) -{ - u32 hw = cx->card->hw_all; - int i; - - /* load modules */ -#ifndef CONFIG_VIDEO_TUNER - hw = cx18_request_module(cx, hw, "tuner", CX18_HW_TUNER); -#endif -#ifndef CONFIG_VIDEO_CS5345 - hw = cx18_request_module(cx, hw, "cs5345", CX18_HW_CS5345); -#endif - - /* check which i2c devices are actually found */ - for (i = 0; i < 32; i++) { - u32 device = 1 << i; - - if (!(device & hw)) - continue; - if (device == CX18_HW_GPIO || device == CX18_HW_TVEEPROM || - device == CX18_HW_CX23418 || device == CX18_HW_DVB) { - /* These 'devices' do not use i2c probing */ - cx->hw_flags |= device; - continue; - } - cx18_i2c_register(cx, i); - if (cx18_i2c_hw_addr(cx, device) > 0) - cx->hw_flags |= device; - } - - hw = cx->hw_flags; -} - -static int __devinit cx18_probe(struct pci_dev *dev, - const struct pci_device_id *pci_id) -{ - int retval = 0; - int vbi_buf_size; - u32 devtype; - struct cx18 *cx; - - spin_lock(&cx18_cards_lock); - - /* Make sure we've got a place for this card */ - if (cx18_cards_active == CX18_MAX_CARDS) { - printk(KERN_ERR "cx18: Maximum number of cards detected (%d).\n", - cx18_cards_active); - spin_unlock(&cx18_cards_lock); - return -ENOMEM; - } - - cx = kzalloc(sizeof(struct cx18), GFP_ATOMIC); - if (cx == 0) { - spin_unlock(&cx18_cards_lock); - return -ENOMEM; - } - cx18_cards[cx18_cards_active] = cx; - cx->dev = dev; - cx->num = cx18_cards_active++; - snprintf(cx->name, sizeof(cx->name) - 1, "cx18-%d", cx->num); - CX18_INFO("Initializing card #%d\n", cx->num); - - spin_unlock(&cx18_cards_lock); - - cx18_process_options(cx); - if (cx->options.cardtype == -1) { - retval = -ENODEV; - goto err; - } - if (cx18_init_struct1(cx)) { - retval = -ENOMEM; - goto err; - } - - CX18_DEBUG_INFO("base addr: 0x%08x\n", cx->base_addr); - - /* PCI Device Setup */ - retval = cx18_setup_pci(cx, dev, pci_id); - if (retval != 0) { - if (retval == -EIO) - goto free_workqueue; - else if (retval == -ENXIO) - goto free_mem; - } - /* save cx in the pci struct for later use */ - pci_set_drvdata(dev, cx); - - /* map io memory */ - CX18_DEBUG_INFO("attempting ioremap at 0x%08x len 0x%08x\n", - cx->base_addr + CX18_MEM_OFFSET, CX18_MEM_SIZE); - cx->enc_mem = ioremap_nocache(cx->base_addr + CX18_MEM_OFFSET, - CX18_MEM_SIZE); - if (!cx->enc_mem) { - CX18_ERR("ioremap failed, perhaps increasing __VMALLOC_RESERVE in page.h\n"); - CX18_ERR("or disabling CONFIG_HIGHMEM4G into the kernel would help\n"); - retval = -ENOMEM; - goto free_mem; - } - cx->reg_mem = cx->enc_mem + CX18_REG_OFFSET; - devtype = read_reg(0xC72028); - switch (devtype & 0xff000000) { - case 0xff000000: - CX18_INFO("cx23418 revision %08x (A)\n", devtype); - break; - case 0x01000000: - CX18_INFO("cx23418 revision %08x (B)\n", devtype); - break; - default: - CX18_INFO("cx23418 revision %08x (Unknown)\n", devtype); - break; - } - - cx18_init_power(cx, 1); - cx18_init_memory(cx); - - cx->scb = (struct cx18_scb *)(cx->enc_mem + SCB_OFFSET); - cx18_init_scb(cx); - - cx18_gpio_init(cx); - - /* active i2c */ - CX18_DEBUG_INFO("activating i2c...\n"); - if (init_cx18_i2c(cx)) { - CX18_ERR("Could not initialize i2c\n"); - goto free_map; - } - - CX18_DEBUG_INFO("Active card count: %d.\n", cx18_cards_active); - - if (cx->card->hw_all & CX18_HW_TVEEPROM) { - /* Based on the model number the cardtype may be changed. - The PCI IDs are not always reliable. */ - cx18_process_eeprom(cx); - } - if (cx->card->comment) - CX18_INFO("%s", cx->card->comment); - if (cx->card->v4l2_capabilities == 0) { - retval = -ENODEV; - goto free_i2c; - } - cx18_init_memory(cx); - - /* Register IRQ */ - retval = request_irq(cx->dev->irq, cx18_irq_handler, - IRQF_SHARED | IRQF_DISABLED, cx->name, (void *)cx); - if (retval) { - CX18_ERR("Failed to register irq %d\n", retval); - goto free_i2c; - } - - if (cx->std == 0) - cx->std = V4L2_STD_NTSC_M; - - if (cx->options.tuner == -1) { - int i; - - for (i = 0; i < CX18_CARD_MAX_TUNERS; i++) { - if ((cx->std & cx->card->tuners[i].std) == 0) - continue; - cx->options.tuner = cx->card->tuners[i].tuner; - break; - } - } - /* if no tuner was found, then pick the first tuner in the card list */ - if (cx->options.tuner == -1 && cx->card->tuners[0].std) { - cx->std = cx->card->tuners[0].std; - cx->options.tuner = cx->card->tuners[0].tuner; - } - if (cx->options.radio == -1) - cx->options.radio = (cx->card->radio_input.audio_type != 0); - - /* The card is now fully identified, continue with card-specific - initialization. */ - cx18_init_struct2(cx); - - cx18_load_and_init_modules(cx); - - if (cx->std & V4L2_STD_525_60) { - cx->is_60hz = 1; - cx->is_out_60hz = 1; - } else { - cx->is_50hz = 1; - cx->is_out_50hz = 1; - } - cx->params.video_gop_size = cx->is_60hz ? 15 : 12; - - cx->stream_buf_size[CX18_ENC_STREAM_TYPE_MPG] = 0x08000; - cx->stream_buf_size[CX18_ENC_STREAM_TYPE_TS] = 0x08000; - cx->stream_buf_size[CX18_ENC_STREAM_TYPE_PCM] = 0x01200; - cx->stream_buf_size[CX18_ENC_STREAM_TYPE_YUV] = 0x20000; - vbi_buf_size = cx->vbi.raw_size * (cx->is_60hz ? 24 : 36) / 2; - cx->stream_buf_size[CX18_ENC_STREAM_TYPE_VBI] = vbi_buf_size; - - if (cx->options.radio > 0) - cx->v4l2_cap |= V4L2_CAP_RADIO; - - retval = cx18_streams_setup(cx); - if (retval) { - CX18_ERR("Error %d setting up streams\n", retval); - goto free_irq; - } - retval = cx18_streams_register(cx); - if (retval) { - CX18_ERR("Error %d registering devices\n", retval); - goto free_streams; - } - - if (cx->options.tuner > -1) { - struct tuner_setup setup; - - setup.addr = ADDR_UNSET; - setup.type = cx->options.tuner; - setup.mode_mask = T_ANALOG_TV; /* matches TV tuners */ - setup.tuner_callback = (setup.type == TUNER_XC2028) ? - cx18_reset_tuner_gpio : NULL; - cx18_call_i2c_clients(cx, TUNER_SET_TYPE_ADDR, &setup); - if (setup.type == TUNER_XC2028) { - static struct xc2028_ctrl ctrl = { - .fname = XC2028_DEFAULT_FIRMWARE, - .max_len = 64, - }; - struct v4l2_priv_tun_config cfg = { - .tuner = cx->options.tuner, - .priv = &ctrl, - }; - cx18_call_i2c_clients(cx, TUNER_SET_CONFIG, &cfg); - } - } - - /* The tuner is fixed to the standard. The other inputs (e.g. S-Video) - are not. */ - cx->tuner_std = cx->std; - - cx18_init_on_first_open(cx); - - CX18_INFO("Initialized card #%d: %s\n", cx->num, cx->card_name); - - return 0; - -free_streams: - cx18_streams_cleanup(cx); -free_irq: - free_irq(cx->dev->irq, (void *)cx); -free_i2c: - exit_cx18_i2c(cx); -free_map: - cx18_iounmap(cx); -free_mem: - release_mem_region(cx->base_addr, CX18_MEM_SIZE); -free_workqueue: -err: - if (retval == 0) - retval = -ENODEV; - CX18_ERR("Error %d on initialization\n", retval); - - kfree(cx18_cards[cx18_cards_active]); - cx18_cards[cx18_cards_active] = NULL; - return retval; -} - -int cx18_init_on_first_open(struct cx18 *cx) -{ - int video_input; - int fw_retry_count = 3; - struct v4l2_frequency vf; - - if (test_bit(CX18_F_I_FAILED, &cx->i_flags)) - return -ENXIO; - - if (test_and_set_bit(CX18_F_I_INITED, &cx->i_flags)) - return 0; - - while (--fw_retry_count > 0) { - /* load firmware */ - if (cx18_firmware_init(cx) == 0) - break; - if (fw_retry_count > 1) - CX18_WARN("Retry loading firmware\n"); - } - - if (fw_retry_count == 0) { - set_bit(CX18_F_I_FAILED, &cx->i_flags); - return -ENXIO; - } - set_bit(CX18_F_I_LOADED_FW, &cx->i_flags); - - /* Init the firmware twice to work around a silicon bug - * transport related. */ - - fw_retry_count = 3; - while (--fw_retry_count > 0) { - /* load firmware */ - if (cx18_firmware_init(cx) == 0) - break; - if (fw_retry_count > 1) - CX18_WARN("Retry loading firmware\n"); - } - - if (fw_retry_count == 0) { - set_bit(CX18_F_I_FAILED, &cx->i_flags); - return -ENXIO; - } - - vf.tuner = 0; - vf.type = V4L2_TUNER_ANALOG_TV; - vf.frequency = 6400; /* the tuner 'baseline' frequency */ - - /* Set initial frequency. For PAL/SECAM broadcasts no - 'default' channel exists AFAIK. */ - if (cx->std == V4L2_STD_NTSC_M_JP) - vf.frequency = 1460; /* ch. 1 91250*16/1000 */ - else if (cx->std & V4L2_STD_NTSC_M) - vf.frequency = 1076; /* ch. 4 67250*16/1000 */ - - video_input = cx->active_input; - cx->active_input++; /* Force update of input */ - cx18_v4l2_ioctls(cx, NULL, VIDIOC_S_INPUT, &video_input); - - /* Let the VIDIOC_S_STD ioctl do all the work, keeps the code - in one place. */ - cx->std++; /* Force full standard initialization */ - cx18_v4l2_ioctls(cx, NULL, VIDIOC_S_STD, &cx->tuner_std); - cx18_v4l2_ioctls(cx, NULL, VIDIOC_S_FREQUENCY, &vf); - return 0; -} - -static void cx18_remove(struct pci_dev *pci_dev) -{ - struct cx18 *cx = pci_get_drvdata(pci_dev); - - CX18_DEBUG_INFO("Removing Card #%d\n", cx->num); - - /* Stop all captures */ - CX18_DEBUG_INFO("Stopping all streams\n"); - if (atomic_read(&cx->capturing) > 0) - cx18_stop_all_captures(cx); - - /* Interrupts */ - sw1_irq_disable(IRQ_CPU_TO_EPU | IRQ_APU_TO_EPU); - sw2_irq_disable(IRQ_CPU_TO_EPU_ACK | IRQ_APU_TO_EPU_ACK); - - cx18_halt_firmware(cx); - - cx18_streams_cleanup(cx); - - exit_cx18_i2c(cx); - - free_irq(cx->dev->irq, (void *)cx); - - if (cx->dev) - cx18_iounmap(cx); - - release_mem_region(cx->base_addr, CX18_MEM_SIZE); - - pci_disable_device(cx->dev); - - CX18_INFO("Removed %s, card #%d\n", cx->card_name, cx->num); -} - -/* define a pci_driver for card detection */ -static struct pci_driver cx18_pci_driver = { - .name = "cx18", - .id_table = cx18_pci_tbl, - .probe = cx18_probe, - .remove = cx18_remove, -}; - -static int module_start(void) -{ - printk(KERN_INFO "cx18: Start initialization, version %s\n", CX18_VERSION); - - memset(cx18_cards, 0, sizeof(cx18_cards)); - - /* Validate parameters */ - if (cx18_first_minor < 0 || cx18_first_minor >= CX18_MAX_CARDS) { - printk(KERN_ERR "cx18: Exiting, ivtv_first_minor must be between 0 and %d\n", - CX18_MAX_CARDS - 1); - return -1; - } - - if (cx18_debug < 0 || cx18_debug > 511) { - cx18_debug = 0; - printk(KERN_INFO "cx18: Debug value must be >= 0 and <= 511!\n"); - } - - if (pci_register_driver(&cx18_pci_driver)) { - printk(KERN_ERR "cx18: Error detecting PCI card\n"); - return -ENODEV; - } - printk(KERN_INFO "cx18: End initialization\n"); - return 0; -} - -static void module_cleanup(void) -{ - int i; - - pci_unregister_driver(&cx18_pci_driver); - - for (i = 0; i < cx18_cards_active; i++) { - if (cx18_cards[i] == NULL) - continue; - kfree(cx18_cards[i]); - } -} - -module_init(module_start); -module_exit(module_cleanup); diff --git a/trunk/drivers/media/video/cx18/cx18-driver.h b/trunk/drivers/media/video/cx18/cx18-driver.h deleted file mode 100644 index 2ee939193bb7..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-driver.h +++ /dev/null @@ -1,500 +0,0 @@ -/* - * cx18 driver internal defines and structures - * - * Derived from ivtv-driver.h - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -#ifndef CX18_DRIVER_H -#define CX18_DRIVER_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include "cx18-mailbox.h" -#include "cx18-av-core.h" -#include "cx23418.h" - -/* DVB */ -#include "demux.h" -#include "dmxdev.h" -#include "dvb_demux.h" -#include "dvb_frontend.h" -#include "dvb_net.h" -#include "dvbdev.h" - -#ifndef CONFIG_PCI -# error "This driver requires kernel PCI support." -#endif - -#define CX18_MEM_OFFSET 0x00000000 -#define CX18_MEM_SIZE 0x04000000 -#define CX18_REG_OFFSET 0x02000000 - -/* Maximum cx18 driver instances. */ -#define CX18_MAX_CARDS 32 - -/* Supported cards */ -#define CX18_CARD_HVR_1600_ESMT 0 /* Hauppauge HVR 1600 (ESMT memory) */ -#define CX18_CARD_HVR_1600_SAMSUNG 1 /* Hauppauge HVR 1600 (Samsung memory) */ -#define CX18_CARD_COMPRO_H900 2 /* Compro VideoMate H900 */ -#define CX18_CARD_YUAN_MPC718 3 /* Yuan MPC718 */ -#define CX18_CARD_LAST 3 - -#define CX18_ENC_STREAM_TYPE_MPG 0 -#define CX18_ENC_STREAM_TYPE_TS 1 -#define CX18_ENC_STREAM_TYPE_YUV 2 -#define CX18_ENC_STREAM_TYPE_VBI 3 -#define CX18_ENC_STREAM_TYPE_PCM 4 -#define CX18_ENC_STREAM_TYPE_IDX 5 -#define CX18_ENC_STREAM_TYPE_RAD 6 -#define CX18_MAX_STREAMS 7 - -/* system vendor and device IDs */ -#define PCI_VENDOR_ID_CX 0x14f1 -#define PCI_DEVICE_ID_CX23418 0x5b7a - -/* subsystem vendor ID */ -#define CX18_PCI_ID_HAUPPAUGE 0x0070 -#define CX18_PCI_ID_COMPRO 0x185b -#define CX18_PCI_ID_YUAN 0x12ab - -/* ======================================================================== */ -/* ========================== START USER SETTABLE DMA VARIABLES =========== */ -/* ======================================================================== */ - -/* DMA Buffers, Default size in MB allocated */ -#define CX18_DEFAULT_ENC_TS_BUFFERS 1 -#define CX18_DEFAULT_ENC_MPG_BUFFERS 2 -#define CX18_DEFAULT_ENC_IDX_BUFFERS 1 -#define CX18_DEFAULT_ENC_YUV_BUFFERS 2 -#define CX18_DEFAULT_ENC_VBI_BUFFERS 1 -#define CX18_DEFAULT_ENC_PCM_BUFFERS 1 - -/* i2c stuff */ -#define I2C_CLIENTS_MAX 16 - -/* debugging */ - -/* Flag to turn on high volume debugging */ -#define CX18_DBGFLG_WARN (1 << 0) -#define CX18_DBGFLG_INFO (1 << 1) -#define CX18_DBGFLG_API (1 << 2) -#define CX18_DBGFLG_DMA (1 << 3) -#define CX18_DBGFLG_IOCTL (1 << 4) -#define CX18_DBGFLG_FILE (1 << 5) -#define CX18_DBGFLG_I2C (1 << 6) -#define CX18_DBGFLG_IRQ (1 << 7) -/* Flag to turn on high volume debugging */ -#define CX18_DBGFLG_HIGHVOL (1 << 8) - -/* NOTE: extra space before comma in 'cx->num , ## args' is required for - gcc-2.95, otherwise it won't compile. */ -#define CX18_DEBUG(x, type, fmt, args...) \ - do { \ - if ((x) & cx18_debug) \ - printk(KERN_INFO "cx18-%d " type ": " fmt, cx->num , ## args); \ - } while (0) -#define CX18_DEBUG_WARN(fmt, args...) CX18_DEBUG(CX18_DBGFLG_WARN, "warning", fmt , ## args) -#define CX18_DEBUG_INFO(fmt, args...) CX18_DEBUG(CX18_DBGFLG_INFO, "info", fmt , ## args) -#define CX18_DEBUG_API(fmt, args...) CX18_DEBUG(CX18_DBGFLG_API, "api", fmt , ## args) -#define CX18_DEBUG_DMA(fmt, args...) CX18_DEBUG(CX18_DBGFLG_DMA, "dma", fmt , ## args) -#define CX18_DEBUG_IOCTL(fmt, args...) CX18_DEBUG(CX18_DBGFLG_IOCTL, "ioctl", fmt , ## args) -#define CX18_DEBUG_FILE(fmt, args...) CX18_DEBUG(CX18_DBGFLG_FILE, "file", fmt , ## args) -#define CX18_DEBUG_I2C(fmt, args...) CX18_DEBUG(CX18_DBGFLG_I2C, "i2c", fmt , ## args) -#define CX18_DEBUG_IRQ(fmt, args...) CX18_DEBUG(CX18_DBGFLG_IRQ, "irq", fmt , ## args) - -#define CX18_DEBUG_HIGH_VOL(x, type, fmt, args...) \ - do { \ - if (((x) & cx18_debug) && (cx18_debug & CX18_DBGFLG_HIGHVOL)) \ - printk(KERN_INFO "cx18%d " type ": " fmt, cx->num , ## args); \ - } while (0) -#define CX18_DEBUG_HI_WARN(fmt, args...) CX18_DEBUG_HIGH_VOL(CX18_DBGFLG_WARN, "warning", fmt , ## args) -#define CX18_DEBUG_HI_INFO(fmt, args...) CX18_DEBUG_HIGH_VOL(CX18_DBGFLG_INFO, "info", fmt , ## args) -#define CX18_DEBUG_HI_API(fmt, args...) CX18_DEBUG_HIGH_VOL(CX18_DBGFLG_API, "api", fmt , ## args) -#define CX18_DEBUG_HI_DMA(fmt, args...) CX18_DEBUG_HIGH_VOL(CX18_DBGFLG_DMA, "dma", fmt , ## args) -#define CX18_DEBUG_HI_IOCTL(fmt, args...) CX18_DEBUG_HIGH_VOL(CX18_DBGFLG_IOCTL, "ioctl", fmt , ## args) -#define CX18_DEBUG_HI_FILE(fmt, args...) CX18_DEBUG_HIGH_VOL(CX18_DBGFLG_FILE, "file", fmt , ## args) -#define CX18_DEBUG_HI_I2C(fmt, args...) CX18_DEBUG_HIGH_VOL(CX18_DBGFLG_I2C, "i2c", fmt , ## args) -#define CX18_DEBUG_HI_IRQ(fmt, args...) CX18_DEBUG_HIGH_VOL(CX18_DBGFLG_IRQ, "irq", fmt , ## args) - -/* Standard kernel messages */ -#define CX18_ERR(fmt, args...) printk(KERN_ERR "cx18-%d: " fmt, cx->num , ## args) -#define CX18_WARN(fmt, args...) printk(KERN_WARNING "cx18-%d: " fmt, cx->num , ## args) -#define CX18_INFO(fmt, args...) printk(KERN_INFO "cx18-%d: " fmt, cx->num , ## args) - -/* Values for CX18_API_DEC_PLAYBACK_SPEED mpeg_frame_type_mask parameter: */ -#define MPEG_FRAME_TYPE_IFRAME 1 -#define MPEG_FRAME_TYPE_IFRAME_PFRAME 3 -#define MPEG_FRAME_TYPE_ALL 7 - -#define CX18_MAX_PGM_INDEX (400) - -extern int cx18_debug; - - -struct cx18_options { - int megabytes[CX18_MAX_STREAMS]; /* Size in megabytes of each stream */ - int cardtype; /* force card type on load */ - int tuner; /* set tuner on load */ - int radio; /* enable/disable radio */ -}; - -/* per-buffer bit flags */ -#define CX18_F_B_NEED_BUF_SWAP 0 /* this buffer should be byte swapped */ - -/* per-stream, s_flags */ -#define CX18_F_S_CLAIMED 3 /* this stream is claimed */ -#define CX18_F_S_STREAMING 4 /* the fw is decoding/encoding this stream */ -#define CX18_F_S_INTERNAL_USE 5 /* this stream is used internally (sliced VBI processing) */ -#define CX18_F_S_STREAMOFF 7 /* signal end of stream EOS */ -#define CX18_F_S_APPL_IO 8 /* this stream is used read/written by an application */ - -/* per-cx18, i_flags */ -#define CX18_F_I_LOADED_FW 0 /* Loaded the firmware the first time */ -#define CX18_F_I_EOS 4 /* End of encoder stream reached */ -#define CX18_F_I_RADIO_USER 5 /* The radio tuner is selected */ -#define CX18_F_I_ENC_PAUSED 13 /* the encoder is paused */ -#define CX18_F_I_INITED 21 /* set after first open */ -#define CX18_F_I_FAILED 22 /* set if first open failed */ - -/* These are the VBI types as they appear in the embedded VBI private packets. */ -#define CX18_SLICED_TYPE_TELETEXT_B (1) -#define CX18_SLICED_TYPE_CAPTION_525 (4) -#define CX18_SLICED_TYPE_WSS_625 (5) -#define CX18_SLICED_TYPE_VPS (7) - -struct cx18_buffer { - struct list_head list; - dma_addr_t dma_handle; - u32 id; - unsigned long b_flags; - char *buf; - - u32 bytesused; - u32 readpos; -}; - -struct cx18_queue { - struct list_head list; - u32 buffers; - u32 length; - u32 bytesused; -}; - -struct cx18_dvb { - struct dmx_frontend hw_frontend; - struct dmx_frontend mem_frontend; - struct dmxdev dmxdev; - struct dvb_adapter dvb_adapter; - struct dvb_demux demux; - struct dvb_frontend *fe; - struct dvb_net dvbnet; - int enabled; - int feeding; - - struct mutex feedlock; - -}; - -struct cx18; /* forward reference */ -struct cx18_scb; /* forward reference */ - -struct cx18_stream { - /* These first four fields are always set, even if the stream - is not actually created. */ - struct video_device *v4l2dev; /* NULL when stream not created */ - struct cx18 *cx; /* for ease of use */ - const char *name; /* name of the stream */ - int type; /* stream type */ - u32 handle; /* task handle */ - unsigned mdl_offset; - - u32 id; - spinlock_t qlock; /* locks access to the queues */ - unsigned long s_flags; /* status flags, see above */ - int dma; /* can be PCI_DMA_TODEVICE, - PCI_DMA_FROMDEVICE or - PCI_DMA_NONE */ - u64 dma_pts; - wait_queue_head_t waitq; - - /* Buffer Stats */ - u32 buffers; - u32 buf_size; - u32 buffers_stolen; - - /* Buffer Queues */ - struct cx18_queue q_free; /* free buffers */ - struct cx18_queue q_full; /* full buffers */ - struct cx18_queue q_io; /* waiting for I/O */ - - /* DVB / Digital Transport */ - struct cx18_dvb dvb; -}; - -struct cx18_open_id { - u32 open_id; - int type; - enum v4l2_priority prio; - struct cx18 *cx; -}; - -/* forward declaration of struct defined in cx18-cards.h */ -struct cx18_card; - - -#define CX18_VBI_FRAMES 32 - -/* VBI data */ -struct vbi_info { - u32 enc_size; - u32 frame; - u8 cc_data_odd[256]; - u8 cc_data_even[256]; - int cc_pos; - u8 cc_no_update; - u8 vps[5]; - u8 vps_found; - int wss; - u8 wss_found; - u8 wss_no_update; - u32 raw_decoder_line_size; - u8 raw_decoder_sav_odd_field; - u8 raw_decoder_sav_even_field; - u32 sliced_decoder_line_size; - u8 sliced_decoder_sav_odd_field; - u8 sliced_decoder_sav_even_field; - struct v4l2_format in; - /* convenience pointer to sliced struct in vbi_in union */ - struct v4l2_sliced_vbi_format *sliced_in; - u32 service_set_in; - int insert_mpeg; - - /* Buffer for the maximum of 2 * 18 * packet_size sliced VBI lines. - One for /dev/vbi0 and one for /dev/vbi8 */ - struct v4l2_sliced_vbi_data sliced_data[36]; - - /* Buffer for VBI data inserted into MPEG stream. - The first byte is a dummy byte that's never used. - The next 16 bytes contain the MPEG header for the VBI data, - the remainder is the actual VBI data. - The max size accepted by the MPEG VBI reinsertion turns out - to be 1552 bytes, which happens to be 4 + (1 + 42) * (2 * 18) bytes, - where 4 is a four byte header, 42 is the max sliced VBI payload, 1 is - a single line header byte and 2 * 18 is the number of VBI lines per frame. - - However, it seems that the data must be 1K aligned, so we have to - pad the data until the 1 or 2 K boundary. - - This pointer array will allocate 2049 bytes to store each VBI frame. */ - u8 *sliced_mpeg_data[CX18_VBI_FRAMES]; - u32 sliced_mpeg_size[CX18_VBI_FRAMES]; - struct cx18_buffer sliced_mpeg_buf; - u32 inserted_frame; - - u32 start[2], count; - u32 raw_size; - u32 sliced_size; -}; - -/* Per cx23418, per I2C bus private algo callback data */ -struct cx18_i2c_algo_callback_data { - struct cx18 *cx; - int bus_index; /* 0 or 1 for the cx23418's 1st or 2nd I2C bus */ -}; - -/* Struct to hold info about cx18 cards */ -struct cx18 { - int num; /* board number, -1 during init! */ - char name[8]; /* board name for printk and interrupts (e.g. 'cx180') */ - struct pci_dev *dev; /* PCI device */ - const struct cx18_card *card; /* card information */ - const char *card_name; /* full name of the card */ - const struct cx18_card_tuner_i2c *card_i2c; /* i2c addresses to probe for tuner */ - u8 is_50hz; - u8 is_60hz; - u8 is_out_50hz; - u8 is_out_60hz; - u8 nof_inputs; /* number of video inputs */ - u8 nof_audio_inputs; /* number of audio inputs */ - u16 buffer_id; /* buffer ID counter */ - u32 v4l2_cap; /* V4L2 capabilities of card */ - u32 hw_flags; /* Hardware description of the board */ - unsigned mdl_offset; - struct cx18_scb *scb; /* pointer to SCB */ - - struct cx18_av_state av_state; - - /* codec settings */ - struct cx2341x_mpeg_params params; - u32 filter_mode; - u32 temporal_strength; - u32 spatial_strength; - - /* dualwatch */ - unsigned long dualwatch_jiffies; - u16 dualwatch_stereo_mode; - - /* Digitizer type */ - int digitizer; /* 0x00EF = saa7114 0x00FO = saa7115 0x0106 = mic */ - - struct mutex serialize_lock; /* mutex used to serialize open/close/start/stop/ioctl operations */ - struct cx18_options options; /* User options */ - int stream_buf_size[CX18_MAX_STREAMS]; /* Stream buffer size */ - struct cx18_stream streams[CX18_MAX_STREAMS]; /* Stream data */ - unsigned long i_flags; /* global cx18 flags */ - atomic_t capturing; /* count number of active capture streams */ - spinlock_t lock; /* lock access to this struct */ - int search_pack_header; - - spinlock_t dma_reg_lock; /* lock access to DMA engine registers */ - - int open_id; /* incremented each time an open occurs, used as - unique ID. Starts at 1, so 0 can be used as - uninitialized value in the stream->id. */ - - u32 base_addr; - struct v4l2_prio_state prio; - - u8 card_rev; - void __iomem *enc_mem, *reg_mem; - - struct vbi_info vbi; - - u32 pgm_info_offset; - u32 pgm_info_num; - u32 pgm_info_write_idx; - u32 pgm_info_read_idx; - struct v4l2_enc_idx_entry pgm_info[CX18_MAX_PGM_INDEX]; - - u64 mpg_data_received; - u64 vbi_data_inserted; - - wait_queue_head_t mb_apu_waitq; - wait_queue_head_t mb_cpu_waitq; - wait_queue_head_t mb_epu_waitq; - wait_queue_head_t mb_hpu_waitq; - wait_queue_head_t cap_w; - /* when the current DMA is finished this queue is woken up */ - wait_queue_head_t dma_waitq; - - /* i2c */ - struct i2c_adapter i2c_adap[2]; - struct i2c_algo_bit_data i2c_algo[2]; - struct cx18_i2c_algo_callback_data i2c_algo_cb_data[2]; - struct i2c_client i2c_client[2]; - struct mutex i2c_bus_lock[2]; - struct i2c_client *i2c_clients[I2C_CLIENTS_MAX]; - - /* v4l2 and User settings */ - - /* codec settings */ - u32 audio_input; - u32 active_input; - u32 active_output; - v4l2_std_id std; - v4l2_std_id tuner_std; /* The norm of the tuner (fixed) */ -}; - -/* Globals */ -extern struct cx18 *cx18_cards[]; -extern int cx18_cards_active; -extern int cx18_first_minor; -extern spinlock_t cx18_cards_lock; - -/*==============Prototypes==================*/ - -/* Return non-zero if a signal is pending */ -int cx18_msleep_timeout(unsigned int msecs, int intr); - -/* Wait on queue, returns -EINTR if interrupted */ -int cx18_waitq(wait_queue_head_t *waitq); - -/* Read Hauppauge eeprom */ -struct tveeprom; /* forward reference */ -void cx18_read_eeprom(struct cx18 *cx, struct tveeprom *tv); - -/* First-open initialization: load firmware, etc. */ -int cx18_init_on_first_open(struct cx18 *cx); - -/* This is a PCI post thing, where if the pci register is not read, then - the write doesn't always take effect right away. By reading back the - register any pending PCI writes will be performed (in order), and so - you can be sure that the writes are guaranteed to be done. - - Rarely needed, only in some timing sensitive cases. - Apparently if this is not done some motherboards seem - to kill the firmware and get into the broken state until computer is - rebooted. */ -#define write_sync(val, reg) \ - do { writel(val, reg); readl(reg); } while (0) - -#define read_reg(reg) readl(cx->reg_mem + (reg)) -#define write_reg(val, reg) writel(val, cx->reg_mem + (reg)) -#define write_reg_sync(val, reg) \ - do { write_reg(val, reg); read_reg(reg); } while (0) - -#define read_enc(addr) readl(cx->enc_mem + (u32)(addr)) -#define write_enc(val, addr) writel(val, cx->enc_mem + (u32)(addr)) -#define write_enc_sync(val, addr) \ - do { write_enc(val, addr); read_enc(addr); } while (0) - -#define sw1_irq_enable(val) do { \ - write_reg(val, SW1_INT_STATUS); \ - write_reg(read_reg(SW1_INT_ENABLE_PCI) | (val), SW1_INT_ENABLE_PCI); \ -} while (0) - -#define sw1_irq_disable(val) \ - write_reg(read_reg(SW1_INT_ENABLE_PCI) & ~(val), SW1_INT_ENABLE_PCI); - -#define sw2_irq_enable(val) do { \ - write_reg(val, SW2_INT_STATUS); \ - write_reg(read_reg(SW2_INT_ENABLE_PCI) | (val), SW2_INT_ENABLE_PCI); \ -} while (0) - -#define sw2_irq_disable(val) \ - write_reg(read_reg(SW2_INT_ENABLE_PCI) & ~(val), SW2_INT_ENABLE_PCI); - -#define setup_page(addr) do { \ - u32 val = read_reg(0xD000F8) & ~0x1f00; \ - write_reg(val | (((addr) >> 17) & 0x1f00), 0xD000F8); \ -} while (0) - -#endif /* CX18_DRIVER_H */ diff --git a/trunk/drivers/media/video/cx18/cx18-dvb.c b/trunk/drivers/media/video/cx18/cx18-dvb.c deleted file mode 100644 index 65efe69d939a..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-dvb.c +++ /dev/null @@ -1,288 +0,0 @@ -/* - * cx18 functions for DVB support - * - * Copyright (c) 2008 Steven Toth - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "cx18-version.h" -#include "cx18-dvb.h" -#include "cx18-streams.h" -#include "cx18-cards.h" -#include "s5h1409.h" - -/* Wait until the MXL500X driver is merged */ -#ifdef HAVE_MXL500X -#include "mxl500x.h" -#endif - -DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); - -#define CX18_REG_DMUX_NUM_PORT_0_CONTROL 0xd5a000 - -#ifdef HAVE_MXL500X -static struct mxl500x_config hauppauge_hvr1600_tuner = { - .delsys = MXL500x_MODE_ATSC, - .octf = MXL500x_OCTF_CH, - .xtal_freq = 16000000, - .iflo_freq = 5380000, - .ref_freq = 322800000, - .rssi_ena = MXL_RSSI_ENABLE, - .addr = 0xC6 >> 1, -}; - -static struct s5h1409_config hauppauge_hvr1600_config = { - .demod_address = 0x32 >> 1, - .output_mode = S5H1409_SERIAL_OUTPUT, - .gpio = S5H1409_GPIO_ON, - .qam_if = 44000, - .inversion = S5H1409_INVERSION_OFF, - .status_mode = S5H1409_DEMODLOCKING, - .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK - -}; -#endif - -static int dvb_register(struct cx18_stream *stream); - -/* Kernel DVB framework calls this when the feed needs to start. - * The CX18 framework should enable the transport DMA handling - * and queue processing. - */ -static int cx18_dvb_start_feed(struct dvb_demux_feed *feed) -{ - struct dvb_demux *demux = feed->demux; - struct cx18_stream *stream = (struct cx18_stream *) demux->priv; - struct cx18 *cx = stream->cx; - int ret = -EINVAL; - u32 v; - - CX18_DEBUG_INFO("Start feed: pid = 0x%x index = %d\n", - feed->pid, feed->index); - switch (cx->card->type) { - case CX18_CARD_HVR_1600_ESMT: - case CX18_CARD_HVR_1600_SAMSUNG: - v = read_reg(CX18_REG_DMUX_NUM_PORT_0_CONTROL); - v |= 0x00400000; /* Serial Mode */ - v |= 0x00002000; /* Data Length - Byte */ - v |= 0x00010000; /* Error - Polarity */ - v |= 0x00020000; /* Error - Passthru */ - v |= 0x000c0000; /* Error - Ignore */ - write_reg(v, CX18_REG_DMUX_NUM_PORT_0_CONTROL); - break; - - default: - /* Assumption - Parallel transport - Signalling - * undefined or default. - */ - break; - } - - if (!demux->dmx.frontend) - return -EINVAL; - - if (stream) { - mutex_lock(&stream->dvb.feedlock); - if (stream->dvb.feeding++ == 0) { - CX18_DEBUG_INFO("Starting Transport DMA\n"); - ret = cx18_start_v4l2_encode_stream(stream); - } else - ret = 0; - mutex_unlock(&stream->dvb.feedlock); - } - - return ret; -} - -/* Kernel DVB framework calls this when the feed needs to stop. */ -static int cx18_dvb_stop_feed(struct dvb_demux_feed *feed) -{ - struct dvb_demux *demux = feed->demux; - struct cx18_stream *stream = (struct cx18_stream *)demux->priv; - struct cx18 *cx = stream->cx; - int ret = -EINVAL; - - CX18_DEBUG_INFO("Stop feed: pid = 0x%x index = %d\n", - feed->pid, feed->index); - - if (stream) { - mutex_lock(&stream->dvb.feedlock); - if (--stream->dvb.feeding == 0) { - CX18_DEBUG_INFO("Stopping Transport DMA\n"); - ret = cx18_stop_v4l2_encode_stream(stream, 0); - } else - ret = 0; - mutex_unlock(&stream->dvb.feedlock); - } - - return ret; -} - -int cx18_dvb_register(struct cx18_stream *stream) -{ - struct cx18 *cx = stream->cx; - struct cx18_dvb *dvb = &stream->dvb; - struct dvb_adapter *dvb_adapter; - struct dvb_demux *dvbdemux; - struct dmx_demux *dmx; - int ret; - - if (!dvb) - return -EINVAL; - - ret = dvb_register_adapter(&dvb->dvb_adapter, - CX18_DRIVER_NAME, - THIS_MODULE, &cx->dev->dev, adapter_nr); - if (ret < 0) - goto err_out; - - dvb_adapter = &dvb->dvb_adapter; - - dvbdemux = &dvb->demux; - - dvbdemux->priv = (void *)stream; - - dvbdemux->filternum = 256; - dvbdemux->feednum = 256; - dvbdemux->start_feed = cx18_dvb_start_feed; - dvbdemux->stop_feed = cx18_dvb_stop_feed; - dvbdemux->dmx.capabilities = (DMX_TS_FILTERING | - DMX_SECTION_FILTERING | DMX_MEMORY_BASED_FILTERING); - ret = dvb_dmx_init(dvbdemux); - if (ret < 0) - goto err_dvb_unregister_adapter; - - dmx = &dvbdemux->dmx; - - dvb->hw_frontend.source = DMX_FRONTEND_0; - dvb->mem_frontend.source = DMX_MEMORY_FE; - dvb->dmxdev.filternum = 256; - dvb->dmxdev.demux = dmx; - - ret = dvb_dmxdev_init(&dvb->dmxdev, dvb_adapter); - if (ret < 0) - goto err_dvb_dmx_release; - - ret = dmx->add_frontend(dmx, &dvb->hw_frontend); - if (ret < 0) - goto err_dvb_dmxdev_release; - - ret = dmx->add_frontend(dmx, &dvb->mem_frontend); - if (ret < 0) - goto err_remove_hw_frontend; - - ret = dmx->connect_frontend(dmx, &dvb->hw_frontend); - if (ret < 0) - goto err_remove_mem_frontend; - - ret = dvb_register(stream); - if (ret < 0) - goto err_disconnect_frontend; - - dvb_net_init(dvb_adapter, &dvb->dvbnet, dmx); - - CX18_INFO("DVB Frontend registered\n"); - mutex_init(&dvb->feedlock); - dvb->enabled = 1; - return ret; - -err_disconnect_frontend: - dmx->disconnect_frontend(dmx); -err_remove_mem_frontend: - dmx->remove_frontend(dmx, &dvb->mem_frontend); -err_remove_hw_frontend: - dmx->remove_frontend(dmx, &dvb->hw_frontend); -err_dvb_dmxdev_release: - dvb_dmxdev_release(&dvb->dmxdev); -err_dvb_dmx_release: - dvb_dmx_release(dvbdemux); -err_dvb_unregister_adapter: - dvb_unregister_adapter(dvb_adapter); -err_out: - return ret; -} - -void cx18_dvb_unregister(struct cx18_stream *stream) -{ - struct cx18 *cx = stream->cx; - struct cx18_dvb *dvb = &stream->dvb; - struct dvb_adapter *dvb_adapter; - struct dvb_demux *dvbdemux; - struct dmx_demux *dmx; - - CX18_INFO("unregister DVB\n"); - - dvb_adapter = &dvb->dvb_adapter; - dvbdemux = &dvb->demux; - dmx = &dvbdemux->dmx; - - dmx->close(dmx); - dvb_net_release(&dvb->dvbnet); - dmx->remove_frontend(dmx, &dvb->mem_frontend); - dmx->remove_frontend(dmx, &dvb->hw_frontend); - dvb_dmxdev_release(&dvb->dmxdev); - dvb_dmx_release(dvbdemux); - dvb_unregister_frontend(dvb->fe); - dvb_frontend_detach(dvb->fe); - dvb_unregister_adapter(dvb_adapter); -} - -/* All the DVB attach calls go here, this function get's modified - * for each new card. No other function in this file needs - * to change. - */ -static int dvb_register(struct cx18_stream *stream) -{ - struct cx18_dvb *dvb = &stream->dvb; - struct cx18 *cx = stream->cx; - int ret = 0; - - switch (cx->card->type) { -/* Wait until the MXL500X driver is merged */ -#ifdef HAVE_MXL500X - case CX18_CARD_HVR_1600_ESMT: - case CX18_CARD_HVR_1600_SAMSUNG: - dvb->fe = dvb_attach(s5h1409_attach, - &hauppauge_hvr1600_config, - &cx->i2c_adap[0]); - if (dvb->fe != NULL) { - dvb_attach(mxl500x_attach, dvb->fe, - &hauppauge_hvr1600_tuner, - &cx->i2c_adap[0]); - ret = 0; - } - break; -#endif - default: - /* No Digital Tv Support */ - break; - } - - if (dvb->fe == NULL) { - CX18_ERR("frontend initialization failed\n"); - return -1; - } - - ret = dvb_register_frontend(&dvb->dvb_adapter, dvb->fe); - if (ret < 0) { - if (dvb->fe->ops.release) - dvb->fe->ops.release(dvb->fe); - return ret; - } - - return ret; -} diff --git a/trunk/drivers/media/video/cx18/cx18-dvb.h b/trunk/drivers/media/video/cx18/cx18-dvb.h deleted file mode 100644 index d6a6ccda79a9..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-dvb.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * cx18 functions for DVB support - * - * Copyright (c) 2008 Steven Toth - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "cx18-driver.h" - -int cx18_dvb_register(struct cx18_stream *stream); -void cx18_dvb_unregister(struct cx18_stream *stream); diff --git a/trunk/drivers/media/video/cx18/cx18-fileops.c b/trunk/drivers/media/video/cx18/cx18-fileops.c deleted file mode 100644 index 69303065a294..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-fileops.c +++ /dev/null @@ -1,711 +0,0 @@ -/* - * cx18 file operation functions - * - * Derived from ivtv-fileops.c - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -#include "cx18-driver.h" -#include "cx18-fileops.h" -#include "cx18-i2c.h" -#include "cx18-queue.h" -#include "cx18-vbi.h" -#include "cx18-audio.h" -#include "cx18-mailbox.h" -#include "cx18-scb.h" -#include "cx18-streams.h" -#include "cx18-controls.h" -#include "cx18-ioctl.h" -#include "cx18-cards.h" - -/* This function tries to claim the stream for a specific file descriptor. - If no one else is using this stream then the stream is claimed and - associated VBI streams are also automatically claimed. - Possible error returns: -EBUSY if someone else has claimed - the stream or 0 on success. */ -int cx18_claim_stream(struct cx18_open_id *id, int type) -{ - struct cx18 *cx = id->cx; - struct cx18_stream *s = &cx->streams[type]; - struct cx18_stream *s_vbi; - int vbi_type; - - if (test_and_set_bit(CX18_F_S_CLAIMED, &s->s_flags)) { - /* someone already claimed this stream */ - if (s->id == id->open_id) { - /* yes, this file descriptor did. So that's OK. */ - return 0; - } - if (s->id == -1 && type == CX18_ENC_STREAM_TYPE_VBI) { - /* VBI is handled already internally, now also assign - the file descriptor to this stream for external - reading of the stream. */ - s->id = id->open_id; - CX18_DEBUG_INFO("Start Read VBI\n"); - return 0; - } - /* someone else is using this stream already */ - CX18_DEBUG_INFO("Stream %d is busy\n", type); - return -EBUSY; - } - s->id = id->open_id; - - /* CX18_DEC_STREAM_TYPE_MPG needs to claim CX18_DEC_STREAM_TYPE_VBI, - CX18_ENC_STREAM_TYPE_MPG needs to claim CX18_ENC_STREAM_TYPE_VBI - (provided VBI insertion is on and sliced VBI is selected), for all - other streams we're done */ - if (type == CX18_ENC_STREAM_TYPE_MPG && - cx->vbi.insert_mpeg && cx->vbi.sliced_in->service_set) { - vbi_type = CX18_ENC_STREAM_TYPE_VBI; - } else { - return 0; - } - s_vbi = &cx->streams[vbi_type]; - - set_bit(CX18_F_S_CLAIMED, &s_vbi->s_flags); - - /* mark that it is used internally */ - set_bit(CX18_F_S_INTERNAL_USE, &s_vbi->s_flags); - return 0; -} - -/* This function releases a previously claimed stream. It will take into - account associated VBI streams. */ -void cx18_release_stream(struct cx18_stream *s) -{ - struct cx18 *cx = s->cx; - struct cx18_stream *s_vbi; - - s->id = -1; - if (s->type == CX18_ENC_STREAM_TYPE_VBI && - test_bit(CX18_F_S_INTERNAL_USE, &s->s_flags)) { - /* this stream is still in use internally */ - return; - } - if (!test_and_clear_bit(CX18_F_S_CLAIMED, &s->s_flags)) { - CX18_DEBUG_WARN("Release stream %s not in use!\n", s->name); - return; - } - - cx18_flush_queues(s); - - /* CX18_ENC_STREAM_TYPE_MPG needs to release CX18_ENC_STREAM_TYPE_VBI, - for all other streams we're done */ - if (s->type == CX18_ENC_STREAM_TYPE_MPG) - s_vbi = &cx->streams[CX18_ENC_STREAM_TYPE_VBI]; - else - return; - - /* clear internal use flag */ - if (!test_and_clear_bit(CX18_F_S_INTERNAL_USE, &s_vbi->s_flags)) { - /* was already cleared */ - return; - } - if (s_vbi->id != -1) { - /* VBI stream still claimed by a file descriptor */ - return; - } - clear_bit(CX18_F_S_CLAIMED, &s_vbi->s_flags); - cx18_flush_queues(s_vbi); -} - -static void cx18_dualwatch(struct cx18 *cx) -{ - struct v4l2_tuner vt; - u16 new_bitmap; - u16 new_stereo_mode; - const u16 stereo_mask = 0x0300; - const u16 dual = 0x0200; - - new_stereo_mode = cx->params.audio_properties & stereo_mask; - memset(&vt, 0, sizeof(vt)); - cx18_call_i2c_clients(cx, VIDIOC_G_TUNER, &vt); - if (vt.audmode == V4L2_TUNER_MODE_LANG1_LANG2 && - (vt.rxsubchans & V4L2_TUNER_SUB_LANG2)) - new_stereo_mode = dual; - - if (new_stereo_mode == cx->dualwatch_stereo_mode) - return; - - new_bitmap = new_stereo_mode | (cx->params.audio_properties & ~stereo_mask); - - CX18_DEBUG_INFO("dualwatch: change stereo flag from 0x%x to 0x%x. new audio_bitmask=0x%ux\n", - cx->dualwatch_stereo_mode, new_stereo_mode, new_bitmap); - - if (cx18_vapi(cx, CX18_CPU_SET_AUDIO_PARAMETERS, 2, - cx18_find_handle(cx), new_bitmap) == 0) { - cx->dualwatch_stereo_mode = new_stereo_mode; - return; - } - CX18_DEBUG_INFO("dualwatch: changing stereo flag failed\n"); -} - - -static struct cx18_buffer *cx18_get_buffer(struct cx18_stream *s, int non_block, int *err) -{ - struct cx18 *cx = s->cx; - struct cx18_stream *s_vbi = &cx->streams[CX18_ENC_STREAM_TYPE_VBI]; - struct cx18_buffer *buf; - DEFINE_WAIT(wait); - - *err = 0; - while (1) { - if (s->type == CX18_ENC_STREAM_TYPE_MPG) { - - if (time_after(jiffies, cx->dualwatch_jiffies + msecs_to_jiffies(1000))) { - cx->dualwatch_jiffies = jiffies; - cx18_dualwatch(cx); - } - if (test_bit(CX18_F_S_INTERNAL_USE, &s_vbi->s_flags) && - !test_bit(CX18_F_S_APPL_IO, &s_vbi->s_flags)) { - while ((buf = cx18_dequeue(s_vbi, &s_vbi->q_full))) { - /* byteswap and process VBI data */ -/* cx18_process_vbi_data(cx, buf, s_vbi->dma_pts, s_vbi->type); */ - cx18_enqueue(s_vbi, buf, &s_vbi->q_free); - } - } - buf = &cx->vbi.sliced_mpeg_buf; - if (buf->readpos != buf->bytesused) - return buf; - } - - /* do we have leftover data? */ - buf = cx18_dequeue(s, &s->q_io); - if (buf) - return buf; - - /* do we have new data? */ - buf = cx18_dequeue(s, &s->q_full); - if (buf) { - if (!test_and_clear_bit(CX18_F_B_NEED_BUF_SWAP, - &buf->b_flags)) - return buf; - if (s->type == CX18_ENC_STREAM_TYPE_MPG) - /* byteswap MPG data */ - cx18_buf_swap(buf); - else { - /* byteswap and process VBI data */ - cx18_process_vbi_data(cx, buf, - s->dma_pts, s->type); - } - return buf; - } - - /* return if end of stream */ - if (!test_bit(CX18_F_S_STREAMING, &s->s_flags)) { - CX18_DEBUG_INFO("EOS %s\n", s->name); - return NULL; - } - - /* return if file was opened with O_NONBLOCK */ - if (non_block) { - *err = -EAGAIN; - return NULL; - } - - /* wait for more data to arrive */ - prepare_to_wait(&s->waitq, &wait, TASK_INTERRUPTIBLE); - /* New buffers might have become available before we were added - to the waitqueue */ - if (!s->q_full.buffers) - schedule(); - finish_wait(&s->waitq, &wait); - if (signal_pending(current)) { - /* return if a signal was received */ - CX18_DEBUG_INFO("User stopped %s\n", s->name); - *err = -EINTR; - return NULL; - } - } -} - -static void cx18_setup_sliced_vbi_buf(struct cx18 *cx) -{ - int idx = cx->vbi.inserted_frame % CX18_VBI_FRAMES; - - cx->vbi.sliced_mpeg_buf.buf = cx->vbi.sliced_mpeg_data[idx]; - cx->vbi.sliced_mpeg_buf.bytesused = cx->vbi.sliced_mpeg_size[idx]; - cx->vbi.sliced_mpeg_buf.readpos = 0; -} - -static size_t cx18_copy_buf_to_user(struct cx18_stream *s, - struct cx18_buffer *buf, char __user *ubuf, size_t ucount) -{ - struct cx18 *cx = s->cx; - size_t len = buf->bytesused - buf->readpos; - - if (len > ucount) - len = ucount; - if (cx->vbi.insert_mpeg && s->type == CX18_ENC_STREAM_TYPE_MPG && - cx->vbi.sliced_in->service_set && buf != &cx->vbi.sliced_mpeg_buf) { - const char *start = buf->buf + buf->readpos; - const char *p = start + 1; - const u8 *q; - u8 ch = cx->search_pack_header ? 0xba : 0xe0; - int stuffing, i; - - while (start + len > p) { - q = memchr(p, 0, start + len - p); - if (q == NULL) - break; - p = q + 1; - if ((char *)q + 15 >= buf->buf + buf->bytesused || - q[1] != 0 || q[2] != 1 || q[3] != ch) - continue; - if (!cx->search_pack_header) { - if ((q[6] & 0xc0) != 0x80) - continue; - if (((q[7] & 0xc0) == 0x80 && - (q[9] & 0xf0) == 0x20) || - ((q[7] & 0xc0) == 0xc0 && - (q[9] & 0xf0) == 0x30)) { - ch = 0xba; - cx->search_pack_header = 1; - p = q + 9; - } - continue; - } - stuffing = q[13] & 7; - /* all stuffing bytes must be 0xff */ - for (i = 0; i < stuffing; i++) - if (q[14 + i] != 0xff) - break; - if (i == stuffing && - (q[4] & 0xc4) == 0x44 && - (q[12] & 3) == 3 && - q[14 + stuffing] == 0 && - q[15 + stuffing] == 0 && - q[16 + stuffing] == 1) { - cx->search_pack_header = 0; - len = (char *)q - start; - cx18_setup_sliced_vbi_buf(cx); - break; - } - } - } - if (copy_to_user(ubuf, (u8 *)buf->buf + buf->readpos, len)) { - CX18_DEBUG_WARN("copy %zd bytes to user failed for %s\n", - len, s->name); - return -EFAULT; - } - buf->readpos += len; - if (s->type == CX18_ENC_STREAM_TYPE_MPG && - buf != &cx->vbi.sliced_mpeg_buf) - cx->mpg_data_received += len; - return len; -} - -static ssize_t cx18_read(struct cx18_stream *s, char __user *ubuf, - size_t tot_count, int non_block) -{ - struct cx18 *cx = s->cx; - size_t tot_written = 0; - int single_frame = 0; - - if (atomic_read(&cx->capturing) == 0 && s->id == -1) { - /* shouldn't happen */ - CX18_DEBUG_WARN("Stream %s not initialized before read\n", - s->name); - return -EIO; - } - - /* Each VBI buffer is one frame, the v4l2 API says that for VBI the - frames should arrive one-by-one, so make sure we never output more - than one VBI frame at a time */ - if (s->type == CX18_ENC_STREAM_TYPE_VBI && - cx->vbi.sliced_in->service_set) - single_frame = 1; - - for (;;) { - struct cx18_buffer *buf; - int rc; - - buf = cx18_get_buffer(s, non_block, &rc); - /* if there is no data available... */ - if (buf == NULL) { - /* if we got data, then return that regardless */ - if (tot_written) - break; - /* EOS condition */ - if (rc == 0) { - clear_bit(CX18_F_S_STREAMOFF, &s->s_flags); - clear_bit(CX18_F_S_APPL_IO, &s->s_flags); - cx18_release_stream(s); - } - /* set errno */ - return rc; - } - - rc = cx18_copy_buf_to_user(s, buf, ubuf + tot_written, - tot_count - tot_written); - - if (buf != &cx->vbi.sliced_mpeg_buf) { - if (buf->readpos == buf->bytesused) { - cx18_buf_sync_for_device(s, buf); - cx18_enqueue(s, buf, &s->q_free); - cx18_vapi(cx, CX18_CPU_DE_SET_MDL, 5, - s->handle, - (void *)&cx->scb->cpu_mdl[buf->id] - cx->enc_mem, - 1, buf->id, s->buf_size); - } else - cx18_enqueue(s, buf, &s->q_io); - } else if (buf->readpos == buf->bytesused) { - int idx = cx->vbi.inserted_frame % CX18_VBI_FRAMES; - - cx->vbi.sliced_mpeg_size[idx] = 0; - cx->vbi.inserted_frame++; - cx->vbi_data_inserted += buf->bytesused; - } - if (rc < 0) - return rc; - tot_written += rc; - - if (tot_written == tot_count || single_frame) - break; - } - return tot_written; -} - -static ssize_t cx18_read_pos(struct cx18_stream *s, char __user *ubuf, - size_t count, loff_t *pos, int non_block) -{ - ssize_t rc = count ? cx18_read(s, ubuf, count, non_block) : 0; - struct cx18 *cx = s->cx; - - CX18_DEBUG_HI_FILE("read %zd from %s, got %zd\n", count, s->name, rc); - if (rc > 0) - pos += rc; - return rc; -} - -int cx18_start_capture(struct cx18_open_id *id) -{ - struct cx18 *cx = id->cx; - struct cx18_stream *s = &cx->streams[id->type]; - struct cx18_stream *s_vbi; - - if (s->type == CX18_ENC_STREAM_TYPE_RAD) { - /* you cannot read from these stream types. */ - return -EPERM; - } - - /* Try to claim this stream. */ - if (cx18_claim_stream(id, s->type)) - return -EBUSY; - - /* If capture is already in progress, then we also have to - do nothing extra. */ - if (test_bit(CX18_F_S_STREAMOFF, &s->s_flags) || - test_and_set_bit(CX18_F_S_STREAMING, &s->s_flags)) { - set_bit(CX18_F_S_APPL_IO, &s->s_flags); - return 0; - } - - /* Start VBI capture if required */ - s_vbi = &cx->streams[CX18_ENC_STREAM_TYPE_VBI]; - if (s->type == CX18_ENC_STREAM_TYPE_MPG && - test_bit(CX18_F_S_INTERNAL_USE, &s_vbi->s_flags) && - !test_and_set_bit(CX18_F_S_STREAMING, &s_vbi->s_flags)) { - /* Note: the CX18_ENC_STREAM_TYPE_VBI is claimed - automatically when the MPG stream is claimed. - We only need to start the VBI capturing. */ - if (cx18_start_v4l2_encode_stream(s_vbi)) { - CX18_DEBUG_WARN("VBI capture start failed\n"); - - /* Failure, clean up and return an error */ - clear_bit(CX18_F_S_STREAMING, &s_vbi->s_flags); - clear_bit(CX18_F_S_STREAMING, &s->s_flags); - /* also releases the associated VBI stream */ - cx18_release_stream(s); - return -EIO; - } - CX18_DEBUG_INFO("VBI insertion started\n"); - } - - /* Tell the card to start capturing */ - if (!cx18_start_v4l2_encode_stream(s)) { - /* We're done */ - set_bit(CX18_F_S_APPL_IO, &s->s_flags); - /* Resume a possibly paused encoder */ - if (test_and_clear_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags)) - cx18_vapi(cx, CX18_CPU_CAPTURE_PAUSE, 1, s->handle); - return 0; - } - - /* failure, clean up */ - CX18_DEBUG_WARN("Failed to start capturing for stream %s\n", s->name); - - /* Note: the CX18_ENC_STREAM_TYPE_VBI is released - automatically when the MPG stream is released. - We only need to stop the VBI capturing. */ - if (s->type == CX18_ENC_STREAM_TYPE_MPG && - test_bit(CX18_F_S_STREAMING, &s_vbi->s_flags)) { - cx18_stop_v4l2_encode_stream(s_vbi, 0); - clear_bit(CX18_F_S_STREAMING, &s_vbi->s_flags); - } - clear_bit(CX18_F_S_STREAMING, &s->s_flags); - cx18_release_stream(s); - return -EIO; -} - -ssize_t cx18_v4l2_read(struct file *filp, char __user *buf, size_t count, - loff_t *pos) -{ - struct cx18_open_id *id = filp->private_data; - struct cx18 *cx = id->cx; - struct cx18_stream *s = &cx->streams[id->type]; - int rc; - - CX18_DEBUG_HI_FILE("read %zd bytes from %s\n", count, s->name); - - mutex_lock(&cx->serialize_lock); - rc = cx18_start_capture(id); - mutex_unlock(&cx->serialize_lock); - if (rc) - return rc; - return cx18_read_pos(s, buf, count, pos, filp->f_flags & O_NONBLOCK); -} - -unsigned int cx18_v4l2_enc_poll(struct file *filp, poll_table *wait) -{ - struct cx18_open_id *id = filp->private_data; - struct cx18 *cx = id->cx; - struct cx18_stream *s = &cx->streams[id->type]; - int eof = test_bit(CX18_F_S_STREAMOFF, &s->s_flags); - - /* Start a capture if there is none */ - if (!eof && !test_bit(CX18_F_S_STREAMING, &s->s_flags)) { - int rc; - - mutex_lock(&cx->serialize_lock); - rc = cx18_start_capture(id); - mutex_unlock(&cx->serialize_lock); - if (rc) { - CX18_DEBUG_INFO("Could not start capture for %s (%d)\n", - s->name, rc); - return POLLERR; - } - CX18_DEBUG_FILE("Encoder poll started capture\n"); - } - - /* add stream's waitq to the poll list */ - CX18_DEBUG_HI_FILE("Encoder poll\n"); - poll_wait(filp, &s->waitq, wait); - - if (s->q_full.length || s->q_io.length) - return POLLIN | POLLRDNORM; - if (eof) - return POLLHUP; - return 0; -} - -void cx18_stop_capture(struct cx18_open_id *id, int gop_end) -{ - struct cx18 *cx = id->cx; - struct cx18_stream *s = &cx->streams[id->type]; - - CX18_DEBUG_IOCTL("close() of %s\n", s->name); - - /* 'Unclaim' this stream */ - - /* Stop capturing */ - if (test_bit(CX18_F_S_STREAMING, &s->s_flags)) { - struct cx18_stream *s_vbi = - &cx->streams[CX18_ENC_STREAM_TYPE_VBI]; - - CX18_DEBUG_INFO("close stopping capture\n"); - /* Special case: a running VBI capture for VBI insertion - in the mpeg stream. Need to stop that too. */ - if (id->type == CX18_ENC_STREAM_TYPE_MPG && - test_bit(CX18_F_S_STREAMING, &s_vbi->s_flags) && - !test_bit(CX18_F_S_APPL_IO, &s_vbi->s_flags)) { - CX18_DEBUG_INFO("close stopping embedded VBI capture\n"); - cx18_stop_v4l2_encode_stream(s_vbi, 0); - } - if (id->type == CX18_ENC_STREAM_TYPE_VBI && - test_bit(CX18_F_S_INTERNAL_USE, &s->s_flags)) - /* Also used internally, don't stop capturing */ - s->id = -1; - else - cx18_stop_v4l2_encode_stream(s, gop_end); - } - if (!gop_end) { - clear_bit(CX18_F_S_APPL_IO, &s->s_flags); - clear_bit(CX18_F_S_STREAMOFF, &s->s_flags); - cx18_release_stream(s); - } -} - -int cx18_v4l2_close(struct inode *inode, struct file *filp) -{ - struct cx18_open_id *id = filp->private_data; - struct cx18 *cx = id->cx; - struct cx18_stream *s = &cx->streams[id->type]; - - CX18_DEBUG_IOCTL("close() of %s\n", s->name); - - v4l2_prio_close(&cx->prio, &id->prio); - - /* Easy case first: this stream was never claimed by us */ - if (s->id != id->open_id) { - kfree(id); - return 0; - } - - /* 'Unclaim' this stream */ - - /* Stop radio */ - mutex_lock(&cx->serialize_lock); - if (id->type == CX18_ENC_STREAM_TYPE_RAD) { - /* Closing radio device, return to TV mode */ - cx18_mute(cx); - /* Mark that the radio is no longer in use */ - clear_bit(CX18_F_I_RADIO_USER, &cx->i_flags); - /* Switch tuner to TV */ - cx18_call_i2c_clients(cx, VIDIOC_S_STD, &cx->std); - /* Select correct audio input (i.e. TV tuner or Line in) */ - cx18_audio_set_io(cx); - if (atomic_read(&cx->capturing) > 0) { - /* Undo video mute */ - cx18_vapi(cx, CX18_CPU_SET_VIDEO_MUTE, 2, s->handle, - cx->params.video_mute | - (cx->params.video_mute_yuv << 8)); - } - /* Done! Unmute and continue. */ - cx18_unmute(cx); - cx18_release_stream(s); - } else { - cx18_stop_capture(id, 0); - } - kfree(id); - mutex_unlock(&cx->serialize_lock); - return 0; -} - -static int cx18_serialized_open(struct cx18_stream *s, struct file *filp) -{ - struct cx18 *cx = s->cx; - struct cx18_open_id *item; - - CX18_DEBUG_FILE("open %s\n", s->name); - - /* Allocate memory */ - item = kmalloc(sizeof(struct cx18_open_id), GFP_KERNEL); - if (NULL == item) { - CX18_DEBUG_WARN("nomem on v4l2 open\n"); - return -ENOMEM; - } - item->cx = cx; - item->type = s->type; - v4l2_prio_open(&cx->prio, &item->prio); - - item->open_id = cx->open_id++; - filp->private_data = item; - - if (item->type == CX18_ENC_STREAM_TYPE_RAD) { - /* Try to claim this stream */ - if (cx18_claim_stream(item, item->type)) { - /* No, it's already in use */ - kfree(item); - return -EBUSY; - } - - if (!test_bit(CX18_F_I_RADIO_USER, &cx->i_flags)) { - if (atomic_read(&cx->capturing) > 0) { - /* switching to radio while capture is - in progress is not polite */ - cx18_release_stream(s); - kfree(item); - return -EBUSY; - } - } - - /* Mark that the radio is being used. */ - set_bit(CX18_F_I_RADIO_USER, &cx->i_flags); - /* We have the radio */ - cx18_mute(cx); - /* Switch tuner to radio */ - cx18_call_i2c_clients(cx, AUDC_SET_RADIO, NULL); - /* Select the correct audio input (i.e. radio tuner) */ - cx18_audio_set_io(cx); - /* Done! Unmute and continue. */ - cx18_unmute(cx); - } - return 0; -} - -int cx18_v4l2_open(struct inode *inode, struct file *filp) -{ - int res, x, y = 0; - struct cx18 *cx = NULL; - struct cx18_stream *s = NULL; - int minor = iminor(inode); - - /* Find which card this open was on */ - spin_lock(&cx18_cards_lock); - for (x = 0; cx == NULL && x < cx18_cards_active; x++) { - /* find out which stream this open was on */ - for (y = 0; y < CX18_MAX_STREAMS; y++) { - s = &cx18_cards[x]->streams[y]; - if (s->v4l2dev && s->v4l2dev->minor == minor) { - cx = cx18_cards[x]; - break; - } - } - } - spin_unlock(&cx18_cards_lock); - - if (cx == NULL) { - /* Couldn't find a device registered - on that minor, shouldn't happen! */ - printk(KERN_WARNING "No cx18 device found on minor %d\n", - minor); - return -ENXIO; - } - - mutex_lock(&cx->serialize_lock); - if (cx18_init_on_first_open(cx)) { - CX18_ERR("Failed to initialize on minor %d\n", minor); - mutex_unlock(&cx->serialize_lock); - return -ENXIO; - } - res = cx18_serialized_open(s, filp); - mutex_unlock(&cx->serialize_lock); - return res; -} - -void cx18_mute(struct cx18 *cx) -{ - if (atomic_read(&cx->capturing)) - cx18_vapi(cx, CX18_CPU_SET_AUDIO_MUTE, 2, - cx18_find_handle(cx), 1); - CX18_DEBUG_INFO("Mute\n"); -} - -void cx18_unmute(struct cx18 *cx) -{ - if (atomic_read(&cx->capturing)) { - cx18_msleep_timeout(100, 0); - cx18_vapi(cx, CX18_CPU_SET_MISC_PARAMETERS, 2, - cx18_find_handle(cx), 12); - cx18_vapi(cx, CX18_CPU_SET_AUDIO_MUTE, 2, - cx18_find_handle(cx), 0); - } - CX18_DEBUG_INFO("Unmute\n"); -} diff --git a/trunk/drivers/media/video/cx18/cx18-fileops.h b/trunk/drivers/media/video/cx18/cx18-fileops.h deleted file mode 100644 index 16cdafbd24c5..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-fileops.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * cx18 file operation functions - * - * Derived from ivtv-fileops.h - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -/* Testing/Debugging */ -int cx18_v4l2_open(struct inode *inode, struct file *filp); -ssize_t cx18_v4l2_read(struct file *filp, char __user *buf, size_t count, - loff_t *pos); -ssize_t cx18_v4l2_write(struct file *filp, const char __user *buf, size_t count, - loff_t *pos); -int cx18_v4l2_close(struct inode *inode, struct file *filp); -unsigned int cx18_v4l2_enc_poll(struct file *filp, poll_table *wait); -int cx18_start_capture(struct cx18_open_id *id); -void cx18_stop_capture(struct cx18_open_id *id, int gop_end); -void cx18_mute(struct cx18 *cx); -void cx18_unmute(struct cx18 *cx); - -/* Utilities */ - -/* Try to claim a stream for the filehandle. Return 0 on success, - -EBUSY if stream already claimed. Once a stream is claimed, it - remains claimed until the associated filehandle is closed. */ -int cx18_claim_stream(struct cx18_open_id *id, int type); - -/* Release a previously claimed stream. */ -void cx18_release_stream(struct cx18_stream *s); diff --git a/trunk/drivers/media/video/cx18/cx18-firmware.c b/trunk/drivers/media/video/cx18/cx18-firmware.c deleted file mode 100644 index 2694ce350631..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-firmware.c +++ /dev/null @@ -1,373 +0,0 @@ -/* - * cx18 firmware functions - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -#include "cx18-driver.h" -#include "cx18-scb.h" -#include "cx18-irq.h" -#include "cx18-firmware.h" -#include "cx18-cards.h" -#include - -#define CX18_PROC_SOFT_RESET 0xc70010 -#define CX18_DDR_SOFT_RESET 0xc70014 -#define CX18_CLOCK_SELECT1 0xc71000 -#define CX18_CLOCK_SELECT2 0xc71004 -#define CX18_HALF_CLOCK_SELECT1 0xc71008 -#define CX18_HALF_CLOCK_SELECT2 0xc7100C -#define CX18_CLOCK_POLARITY1 0xc71010 -#define CX18_CLOCK_POLARITY2 0xc71014 -#define CX18_ADD_DELAY_ENABLE1 0xc71018 -#define CX18_ADD_DELAY_ENABLE2 0xc7101C -#define CX18_CLOCK_ENABLE1 0xc71020 -#define CX18_CLOCK_ENABLE2 0xc71024 - -#define CX18_REG_BUS_TIMEOUT_EN 0xc72024 - -#define CX18_AUDIO_ENABLE 0xc72014 -#define CX18_REG_BUS_TIMEOUT_EN 0xc72024 - -#define CX18_FAST_CLOCK_PLL_INT 0xc78000 -#define CX18_FAST_CLOCK_PLL_FRAC 0xc78004 -#define CX18_FAST_CLOCK_PLL_POST 0xc78008 -#define CX18_FAST_CLOCK_PLL_PRESCALE 0xc7800C -#define CX18_FAST_CLOCK_PLL_ADJUST_BANDWIDTH 0xc78010 - -#define CX18_SLOW_CLOCK_PLL_INT 0xc78014 -#define CX18_SLOW_CLOCK_PLL_FRAC 0xc78018 -#define CX18_SLOW_CLOCK_PLL_POST 0xc7801C -#define CX18_MPEG_CLOCK_PLL_INT 0xc78040 -#define CX18_MPEG_CLOCK_PLL_FRAC 0xc78044 -#define CX18_MPEG_CLOCK_PLL_POST 0xc78048 -#define CX18_PLL_POWER_DOWN 0xc78088 -#define CX18_SW1_INT_STATUS 0xc73104 -#define CX18_SW1_INT_ENABLE_PCI 0xc7311C -#define CX18_SW2_INT_SET 0xc73140 -#define CX18_SW2_INT_STATUS 0xc73144 -#define CX18_ADEC_CONTROL 0xc78120 - -#define CX18_DDR_REQUEST_ENABLE 0xc80000 -#define CX18_DDR_CHIP_CONFIG 0xc80004 -#define CX18_DDR_REFRESH 0xc80008 -#define CX18_DDR_TIMING1 0xc8000C -#define CX18_DDR_TIMING2 0xc80010 -#define CX18_DDR_POWER_REG 0xc8001C - -#define CX18_DDR_TUNE_LANE 0xc80048 -#define CX18_DDR_INITIAL_EMRS 0xc80054 -#define CX18_DDR_MB_PER_ROW_7 0xc8009C -#define CX18_DDR_BASE_63_ADDR 0xc804FC - -#define CX18_WMB_CLIENT02 0xc90108 -#define CX18_WMB_CLIENT05 0xc90114 -#define CX18_WMB_CLIENT06 0xc90118 -#define CX18_WMB_CLIENT07 0xc9011C -#define CX18_WMB_CLIENT08 0xc90120 -#define CX18_WMB_CLIENT09 0xc90124 -#define CX18_WMB_CLIENT10 0xc90128 -#define CX18_WMB_CLIENT11 0xc9012C -#define CX18_WMB_CLIENT12 0xc90130 -#define CX18_WMB_CLIENT13 0xc90134 -#define CX18_WMB_CLIENT14 0xc90138 - -#define CX18_DSP0_INTERRUPT_MASK 0xd0004C - -/* Encoder/decoder firmware sizes */ -#define CX18_FW_CPU_SIZE (174716) -#define CX18_FW_APU_SIZE (141200) - -#define APU_ROM_SYNC1 0x6D676553 /* "mgeS" */ -#define APU_ROM_SYNC2 0x72646548 /* "rdeH" */ - -struct cx18_apu_rom_seghdr { - u32 sync1; - u32 sync2; - u32 addr; - u32 size; -}; - -static int load_cpu_fw_direct(const char *fn, u8 __iomem *mem, struct cx18 *cx, long size) -{ - const struct firmware *fw = NULL; - int retries = 3; - int i, j; - u32 __iomem *dst = (u32 __iomem *)mem; - const u32 *src; - -retry: - if (!retries || request_firmware(&fw, fn, &cx->dev->dev)) { - CX18_ERR("Unable to open firmware %s (must be %ld bytes)\n", - fn, size); - CX18_ERR("Did you put the firmware in the hotplug firmware directory?\n"); - return -ENOMEM; - } - - src = (const u32 *)fw->data; - - if (fw->size != size) { - /* Due to race conditions in firmware loading (esp. with - udev <0.95) the wrong file was sometimes loaded. So we check - filesizes to see if at least the right-sized file was - loaded. If not, then we retry. */ - CX18_INFO("retry: file loaded was not %s (expected size %ld, got %zd)\n", - fn, size, fw->size); - release_firmware(fw); - retries--; - goto retry; - } - for (i = 0; i < fw->size; i += 4096) { - setup_page(i); - for (j = i; j < fw->size && j < i + 4096; j += 4) { - /* no need for endianness conversion on the ppc */ - __raw_writel(*src, dst); - if (__raw_readl(dst) != *src) { - CX18_ERR("Mismatch at offset %x\n", i); - release_firmware(fw); - return -EIO; - } - dst++; - src++; - } - } - if (!test_bit(CX18_F_I_LOADED_FW, &cx->i_flags)) - CX18_INFO("loaded %s firmware (%zd bytes)\n", fn, fw->size); - release_firmware(fw); - return size; -} - -static int load_apu_fw_direct(const char *fn, u8 __iomem *dst, struct cx18 *cx, long size) -{ - const struct firmware *fw = NULL; - int retries = 3; - int i, j; - const u32 *src; - struct cx18_apu_rom_seghdr seghdr; - const u8 *vers; - u32 offset = 0; - u32 apu_version = 0; - int sz; - -retry: - if (!retries || request_firmware(&fw, fn, &cx->dev->dev)) { - CX18_ERR("unable to open firmware %s (must be %ld bytes)\n", - fn, size); - CX18_ERR("did you put the firmware in the hotplug firmware directory?\n"); - return -ENOMEM; - } - - src = (const u32 *)fw->data; - vers = fw->data + sizeof(seghdr); - sz = fw->size; - - if (fw->size != size) { - /* Due to race conditions in firmware loading (esp. with - udev <0.95) the wrong file was sometimes loaded. So we check - filesizes to see if at least the right-sized file was - loaded. If not, then we retry. */ - CX18_INFO("retry: file loaded was not %s (expected size %ld, got %zd)\n", - fn, size, fw->size); - release_firmware(fw); - retries--; - goto retry; - } - apu_version = (vers[0] << 24) | (vers[4] << 16) | vers[32]; - while (offset + sizeof(seghdr) < size) { - /* TODO: byteswapping */ - memcpy(&seghdr, src + offset / 4, sizeof(seghdr)); - offset += sizeof(seghdr); - if (seghdr.sync1 != APU_ROM_SYNC1 || - seghdr.sync2 != APU_ROM_SYNC2) { - offset += seghdr.size; - continue; - } - CX18_DEBUG_INFO("load segment %x-%x\n", seghdr.addr, - seghdr.addr + seghdr.size - 1); - if (offset + seghdr.size > sz) - break; - for (i = 0; i < seghdr.size; i += 4096) { - setup_page(offset + i); - for (j = i; j < seghdr.size && j < i + 4096; j += 4) { - /* no need for endianness conversion on the ppc */ - __raw_writel(src[(offset + j) / 4], dst + seghdr.addr + j); - if (__raw_readl(dst + seghdr.addr + j) != src[(offset + j) / 4]) { - CX18_ERR("Mismatch at offset %x\n", offset + j); - release_firmware(fw); - return -EIO; - } - } - } - offset += seghdr.size; - } - if (!test_bit(CX18_F_I_LOADED_FW, &cx->i_flags)) - CX18_INFO("loaded %s firmware V%08x (%zd bytes)\n", - fn, apu_version, fw->size); - release_firmware(fw); - /* Clear bit0 for APU to start from 0 */ - write_reg(read_reg(0xc72030) & ~1, 0xc72030); - return size; -} - -void cx18_halt_firmware(struct cx18 *cx) -{ - CX18_DEBUG_INFO("Preparing for firmware halt.\n"); - write_reg(0x000F000F, CX18_PROC_SOFT_RESET); /* stop the fw */ - write_reg(0x00020002, CX18_ADEC_CONTROL); -} - -void cx18_init_power(struct cx18 *cx, int lowpwr) -{ - /* power-down Spare and AOM PLLs */ - /* power-up fast, slow and mpeg PLLs */ - write_reg(0x00000008, CX18_PLL_POWER_DOWN); - - /* ADEC out of sleep */ - write_reg(0x00020000, CX18_ADEC_CONTROL); - - /* The fast clock is at 200/245 MHz */ - write_reg(lowpwr ? 0xD : 0x11, CX18_FAST_CLOCK_PLL_INT); - write_reg(lowpwr ? 0x1EFBF37 : 0x038E3D7, CX18_FAST_CLOCK_PLL_FRAC); - - write_reg(2, CX18_FAST_CLOCK_PLL_POST); - write_reg(1, CX18_FAST_CLOCK_PLL_PRESCALE); - write_reg(4, CX18_FAST_CLOCK_PLL_ADJUST_BANDWIDTH); - - /* set slow clock to 125/120 MHz */ - write_reg(lowpwr ? 0x11 : 0x10, CX18_SLOW_CLOCK_PLL_INT); - write_reg(lowpwr ? 0xEBAF05 : 0x18618A8, CX18_SLOW_CLOCK_PLL_FRAC); - write_reg(4, CX18_SLOW_CLOCK_PLL_POST); - - /* mpeg clock pll 54MHz */ - write_reg(0xF, CX18_MPEG_CLOCK_PLL_INT); - write_reg(0x2BCFEF, CX18_MPEG_CLOCK_PLL_FRAC); - write_reg(8, CX18_MPEG_CLOCK_PLL_POST); - - /* Defaults */ - /* APU = SC or SC/2 = 125/62.5 */ - /* EPU = SC = 125 */ - /* DDR = FC = 180 */ - /* ENC = SC = 125 */ - /* AI1 = SC = 125 */ - /* VIM2 = disabled */ - /* PCI = FC/2 = 90 */ - /* AI2 = disabled */ - /* DEMUX = disabled */ - /* AO = SC/2 = 62.5 */ - /* SER = 54MHz */ - /* VFC = disabled */ - /* USB = disabled */ - - write_reg(lowpwr ? 0xFFFF0020 : 0x00060004, CX18_CLOCK_SELECT1); - write_reg(lowpwr ? 0xFFFF0004 : 0x00060006, CX18_CLOCK_SELECT2); - - write_reg(0xFFFF0002, CX18_HALF_CLOCK_SELECT1); - write_reg(0xFFFF0104, CX18_HALF_CLOCK_SELECT2); - - write_reg(0xFFFF9026, CX18_CLOCK_ENABLE1); - write_reg(0xFFFF3105, CX18_CLOCK_ENABLE2); -} - -void cx18_init_memory(struct cx18 *cx) -{ - cx18_msleep_timeout(10, 0); - write_reg(0x10000, CX18_DDR_SOFT_RESET); - cx18_msleep_timeout(10, 0); - - write_reg(cx->card->ddr.chip_config, CX18_DDR_CHIP_CONFIG); - - cx18_msleep_timeout(10, 0); - - write_reg(cx->card->ddr.refresh, CX18_DDR_REFRESH); - write_reg(cx->card->ddr.timing1, CX18_DDR_TIMING1); - write_reg(cx->card->ddr.timing2, CX18_DDR_TIMING2); - - cx18_msleep_timeout(10, 0); - - /* Initialize DQS pad time */ - write_reg(cx->card->ddr.tune_lane, CX18_DDR_TUNE_LANE); - write_reg(cx->card->ddr.initial_emrs, CX18_DDR_INITIAL_EMRS); - - cx18_msleep_timeout(10, 0); - - write_reg(0x20000, CX18_DDR_SOFT_RESET); - cx18_msleep_timeout(10, 0); - - /* use power-down mode when idle */ - write_reg(0x00000010, CX18_DDR_POWER_REG); - - write_reg(0x10001, CX18_REG_BUS_TIMEOUT_EN); - - write_reg(0x48, CX18_DDR_MB_PER_ROW_7); - write_reg(0xE0000, CX18_DDR_BASE_63_ADDR); - - write_reg(0x00000101, CX18_WMB_CLIENT02); /* AO */ - write_reg(0x00000101, CX18_WMB_CLIENT09); /* AI2 */ - write_reg(0x00000101, CX18_WMB_CLIENT05); /* VIM1 */ - write_reg(0x00000101, CX18_WMB_CLIENT06); /* AI1 */ - write_reg(0x00000101, CX18_WMB_CLIENT07); /* 3D comb */ - write_reg(0x00000101, CX18_WMB_CLIENT10); /* ME */ - write_reg(0x00000101, CX18_WMB_CLIENT12); /* ENC */ - write_reg(0x00000101, CX18_WMB_CLIENT13); /* PK */ - write_reg(0x00000101, CX18_WMB_CLIENT11); /* RC */ - write_reg(0x00000101, CX18_WMB_CLIENT14); /* AVO */ -} - -int cx18_firmware_init(struct cx18 *cx) -{ - /* Allow chip to control CLKRUN */ - write_reg(0x5, CX18_DSP0_INTERRUPT_MASK); - - write_reg(0x000F000F, CX18_PROC_SOFT_RESET); /* stop the fw */ - - cx18_msleep_timeout(1, 0); - - sw1_irq_enable(IRQ_CPU_TO_EPU | IRQ_APU_TO_EPU); - sw2_irq_enable(IRQ_CPU_TO_EPU_ACK | IRQ_APU_TO_EPU_ACK); - - /* Only if the processor is not running */ - if (read_reg(CX18_PROC_SOFT_RESET) & 8) { - int sz = load_apu_fw_direct("v4l-cx23418-apu.fw", - cx->enc_mem, cx, CX18_FW_APU_SIZE); - - sz = sz <= 0 ? sz : load_cpu_fw_direct("v4l-cx23418-cpu.fw", - cx->enc_mem, cx, CX18_FW_CPU_SIZE); - - if (sz > 0) { - int retries = 0; - - /* start the CPU */ - write_reg(0x00080000, CX18_PROC_SOFT_RESET); - while (retries++ < 50) { /* Loop for max 500mS */ - if ((read_reg(CX18_PROC_SOFT_RESET) & 1) == 0) - break; - cx18_msleep_timeout(10, 0); - } - cx18_msleep_timeout(200, 0); - if (retries == 51) { - CX18_ERR("Could not start the CPU\n"); - return -EIO; - } - } - if (sz <= 0) - return -EIO; - } - /* initialize GPIO */ - write_reg(0x14001400, 0xC78110); - return 0; -} diff --git a/trunk/drivers/media/video/cx18/cx18-firmware.h b/trunk/drivers/media/video/cx18/cx18-firmware.h deleted file mode 100644 index 38d4c05e8499..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-firmware.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * cx18 firmware functions - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -int cx18_firmware_init(struct cx18 *cx); -void cx18_halt_firmware(struct cx18 *cx); -void cx18_init_memory(struct cx18 *cx); -void cx18_init_power(struct cx18 *cx, int lowpwr); diff --git a/trunk/drivers/media/video/cx18/cx18-gpio.c b/trunk/drivers/media/video/cx18/cx18-gpio.c deleted file mode 100644 index 19253e6b8673..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-gpio.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * cx18 gpio functions - * - * Derived from ivtv-gpio.c - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -#include "cx18-driver.h" -#include "cx18-cards.h" -#include "cx18-gpio.h" -#include "tuner-xc2028.h" - -/********************* GPIO stuffs *********************/ - -/* GPIO registers */ -#define CX18_REG_GPIO_IN 0xc72010 -#define CX18_REG_GPIO_OUT1 0xc78100 -#define CX18_REG_GPIO_DIR1 0xc78108 -#define CX18_REG_GPIO_OUT2 0xc78104 -#define CX18_REG_GPIO_DIR2 0xc7810c - -/* - * HVR-1600 GPIO pins, courtesy of Hauppauge: - * - * gpio0: zilog ir process reset pin - * gpio1: zilog programming pin (you should never use this) - * gpio12: cx24227 reset pin - * gpio13: cs5345 reset pin -*/ - -void cx18_gpio_init(struct cx18 *cx) -{ - if (cx->card->gpio_init.direction == 0) - return; - - CX18_DEBUG_INFO("GPIO initial dir: %08x out: %08x\n", - read_reg(CX18_REG_GPIO_DIR1), read_reg(CX18_REG_GPIO_OUT1)); - - /* init output data then direction */ - write_reg(cx->card->gpio_init.direction << 16, CX18_REG_GPIO_DIR1); - write_reg(0, CX18_REG_GPIO_DIR2); - write_reg((cx->card->gpio_init.direction << 16) | - cx->card->gpio_init.initial_value, CX18_REG_GPIO_OUT1); - write_reg(0, CX18_REG_GPIO_OUT2); -} - -/* Xceive tuner reset function */ -int cx18_reset_tuner_gpio(void *dev, int cmd, int value) -{ - struct i2c_algo_bit_data *algo = dev; - struct cx18 *cx = algo->data; -/* int curdir, curout;*/ - - if (cmd != XC2028_TUNER_RESET) - return 0; - CX18_DEBUG_INFO("Resetting tuner\n"); - return 0; -} diff --git a/trunk/drivers/media/video/cx18/cx18-gpio.h b/trunk/drivers/media/video/cx18/cx18-gpio.h deleted file mode 100644 index 41bac8856b50..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-gpio.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * cx18 gpio functions - * - * Derived from ivtv-gpio.h - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -void cx18_gpio_init(struct cx18 *cx); -int cx18_reset_tuner_gpio(void *dev, int cmd, int value); diff --git a/trunk/drivers/media/video/cx18/cx18-i2c.c b/trunk/drivers/media/video/cx18/cx18-i2c.c deleted file mode 100644 index 18c88d1e4833..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-i2c.c +++ /dev/null @@ -1,431 +0,0 @@ -/* - * cx18 I2C functions - * - * Derived from ivtv-i2c.c - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -#include "cx18-driver.h" -#include "cx18-cards.h" -#include "cx18-gpio.h" -#include "cx18-av-core.h" - -#include - -#define CX18_REG_I2C_1_WR 0xf15000 -#define CX18_REG_I2C_1_RD 0xf15008 -#define CX18_REG_I2C_2_WR 0xf25100 -#define CX18_REG_I2C_2_RD 0xf25108 - -#define SETSCL_BIT 0x0001 -#define SETSDL_BIT 0x0002 -#define GETSCL_BIT 0x0004 -#define GETSDL_BIT 0x0008 - -#ifndef I2C_ADAP_CLASS_TV_ANALOG -#define I2C_ADAP_CLASS_TV_ANALOG I2C_CLASS_TV_ANALOG -#endif - -#define CX18_CS5345_I2C_ADDR 0x4c - -/* This array should match the CX18_HW_ defines */ -static const u8 hw_driverids[] = { - I2C_DRIVERID_TUNER, - I2C_DRIVERID_TVEEPROM, - I2C_DRIVERID_CS5345, - 0, /* CX18_HW_GPIO dummy driver ID */ - 0 /* CX18_HW_CX23418 dummy driver ID */ -}; - -/* This array should match the CX18_HW_ defines */ -static const u8 hw_addrs[] = { - 0, - 0, - CX18_CS5345_I2C_ADDR, - 0, /* CX18_HW_GPIO dummy driver ID */ - 0, /* CX18_HW_CX23418 dummy driver ID */ -}; - -/* This array should match the CX18_HW_ defines */ -/* This might well become a card-specific array */ -static const u8 hw_bus[] = { - 0, - 0, - 0, - 0, /* CX18_HW_GPIO dummy driver ID */ - 0, /* CX18_HW_CX23418 dummy driver ID */ -}; - -/* This array should match the CX18_HW_ defines */ -static const char * const hw_drivernames[] = { - "tuner", - "tveeprom", - "cs5345", - "gpio", - "cx23418", -}; - -int cx18_i2c_register(struct cx18 *cx, unsigned idx) -{ - struct i2c_board_info info; - struct i2c_client *c; - u8 id, bus; - int i; - - CX18_DEBUG_I2C("i2c client register\n"); - if (idx >= ARRAY_SIZE(hw_driverids) || hw_driverids[idx] == 0) - return -1; - id = hw_driverids[idx]; - bus = hw_bus[idx]; - memset(&info, 0, sizeof(info)); - strlcpy(info.driver_name, hw_drivernames[idx], - sizeof(info.driver_name)); - info.addr = hw_addrs[idx]; - for (i = 0; i < I2C_CLIENTS_MAX; i++) - if (cx->i2c_clients[i] == NULL) - break; - - if (i == I2C_CLIENTS_MAX) { - CX18_ERR("insufficient room for new I2C client!\n"); - return -ENOMEM; - } - - if (id != I2C_DRIVERID_TUNER) { - c = i2c_new_device(&cx->i2c_adap[bus], &info); - if (c->driver == NULL) - i2c_unregister_device(c); - else - cx->i2c_clients[i] = c; - return cx->i2c_clients[i] ? 0 : -ENODEV; - } - - /* special tuner handling */ - c = i2c_new_probed_device(&cx->i2c_adap[1], &info, cx->card_i2c->radio); - if (c && c->driver == NULL) - i2c_unregister_device(c); - else if (c) - cx->i2c_clients[i++] = c; - c = i2c_new_probed_device(&cx->i2c_adap[1], &info, cx->card_i2c->demod); - if (c && c->driver == NULL) - i2c_unregister_device(c); - else if (c) - cx->i2c_clients[i++] = c; - c = i2c_new_probed_device(&cx->i2c_adap[1], &info, cx->card_i2c->tv); - if (c && c->driver == NULL) - i2c_unregister_device(c); - else if (c) - cx->i2c_clients[i++] = c; - return 0; -} - -static int attach_inform(struct i2c_client *client) -{ - return 0; -} - -static int detach_inform(struct i2c_client *client) -{ - int i; - struct cx18 *cx = (struct cx18 *)i2c_get_adapdata(client->adapter); - - CX18_DEBUG_I2C("i2c client detach\n"); - for (i = 0; i < I2C_CLIENTS_MAX; i++) { - if (cx->i2c_clients[i] == client) { - cx->i2c_clients[i] = NULL; - break; - } - } - CX18_DEBUG_I2C("i2c detach [client=%s,%s]\n", - client->name, (i < I2C_CLIENTS_MAX) ? "ok" : "failed"); - - return 0; -} - -static void cx18_setscl(void *data, int state) -{ - struct cx18 *cx = ((struct cx18_i2c_algo_callback_data *)data)->cx; - int bus_index = ((struct cx18_i2c_algo_callback_data *)data)->bus_index; - u32 addr = bus_index ? CX18_REG_I2C_2_WR : CX18_REG_I2C_1_WR; - u32 r = read_reg(addr); - - if (state) - write_reg_sync(r | SETSCL_BIT, addr); - else - write_reg_sync(r & ~SETSCL_BIT, addr); -} - -static void cx18_setsda(void *data, int state) -{ - struct cx18 *cx = ((struct cx18_i2c_algo_callback_data *)data)->cx; - int bus_index = ((struct cx18_i2c_algo_callback_data *)data)->bus_index; - u32 addr = bus_index ? CX18_REG_I2C_2_WR : CX18_REG_I2C_1_WR; - u32 r = read_reg(addr); - - if (state) - write_reg_sync(r | SETSDL_BIT, addr); - else - write_reg_sync(r & ~SETSDL_BIT, addr); -} - -static int cx18_getscl(void *data) -{ - struct cx18 *cx = ((struct cx18_i2c_algo_callback_data *)data)->cx; - int bus_index = ((struct cx18_i2c_algo_callback_data *)data)->bus_index; - u32 addr = bus_index ? CX18_REG_I2C_2_RD : CX18_REG_I2C_1_RD; - - return read_reg(addr) & GETSCL_BIT; -} - -static int cx18_getsda(void *data) -{ - struct cx18 *cx = ((struct cx18_i2c_algo_callback_data *)data)->cx; - int bus_index = ((struct cx18_i2c_algo_callback_data *)data)->bus_index; - u32 addr = bus_index ? CX18_REG_I2C_2_RD : CX18_REG_I2C_1_RD; - - return read_reg(addr) & GETSDL_BIT; -} - -/* template for i2c-bit-algo */ -static struct i2c_adapter cx18_i2c_adap_template = { - .name = "cx18 i2c driver", - .id = I2C_HW_B_CX2341X, - .algo = NULL, /* set by i2c-algo-bit */ - .algo_data = NULL, /* filled from template */ - .client_register = attach_inform, - .client_unregister = detach_inform, - .owner = THIS_MODULE, -}; - -#define CX18_SCL_PERIOD (10) /* usecs. 10 usec is period for a 100 KHz clock */ -#define CX18_ALGO_BIT_TIMEOUT (2) /* seconds */ - -static struct i2c_algo_bit_data cx18_i2c_algo_template = { - .setsda = cx18_setsda, - .setscl = cx18_setscl, - .getsda = cx18_getsda, - .getscl = cx18_getscl, - .udelay = CX18_SCL_PERIOD/2, /* 1/2 clock period in usec*/ - .timeout = CX18_ALGO_BIT_TIMEOUT*HZ /* jiffies */ -}; - -static struct i2c_client cx18_i2c_client_template = { - .name = "cx18 internal", -}; - -int cx18_call_i2c_client(struct cx18 *cx, int addr, unsigned cmd, void *arg) -{ - struct i2c_client *client; - int retval; - int i; - - CX18_DEBUG_I2C("call_i2c_client addr=%02x\n", addr); - for (i = 0; i < I2C_CLIENTS_MAX; i++) { - client = cx->i2c_clients[i]; - if (client == NULL || client->driver == NULL || - client->driver->command == NULL) - continue; - if (addr == client->addr) { - retval = client->driver->command(client, cmd, arg); - return retval; - } - } - if (cmd != VIDIOC_G_CHIP_IDENT) - CX18_ERR("i2c addr 0x%02x not found for cmd 0x%x!\n", - addr, cmd); - return -ENODEV; -} - -/* Find the i2c device based on the driver ID and return - its i2c address or -ENODEV if no matching device was found. */ -static int cx18_i2c_id_addr(struct cx18 *cx, u32 id) -{ - struct i2c_client *client; - int retval = -ENODEV; - int i; - - for (i = 0; i < I2C_CLIENTS_MAX; i++) { - client = cx->i2c_clients[i]; - if (client == NULL || client->driver == NULL) - continue; - if (id == client->driver->id) { - retval = client->addr; - break; - } - } - return retval; -} - -/* Find the i2c device name matching the DRIVERID */ -static const char *cx18_i2c_id_name(u32 id) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(hw_driverids); i++) - if (hw_driverids[i] == id) - return hw_drivernames[i]; - return "unknown device"; -} - -/* Find the i2c device name matching the CX18_HW_ flag */ -static const char *cx18_i2c_hw_name(u32 hw) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(hw_driverids); i++) - if (1 << i == hw) - return hw_drivernames[i]; - return "unknown device"; -} - -/* Find the i2c device matching the CX18_HW_ flag and return - its i2c address or -ENODEV if no matching device was found. */ -int cx18_i2c_hw_addr(struct cx18 *cx, u32 hw) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(hw_driverids); i++) - if (1 << i == hw) - return cx18_i2c_id_addr(cx, hw_driverids[i]); - return -ENODEV; -} - -/* Calls i2c device based on CX18_HW_ flag. If hw == 0, then do nothing. - If hw == CX18_HW_GPIO then call the gpio handler. */ -int cx18_i2c_hw(struct cx18 *cx, u32 hw, unsigned int cmd, void *arg) -{ - int addr; - - if (hw == CX18_HW_GPIO || hw == 0) - return 0; - if (hw == CX18_HW_CX23418) - return cx18_av_cmd(cx, cmd, arg); - - addr = cx18_i2c_hw_addr(cx, hw); - if (addr < 0) { - CX18_ERR("i2c hardware 0x%08x (%s) not found for cmd 0x%x!\n", - hw, cx18_i2c_hw_name(hw), cmd); - return addr; - } - return cx18_call_i2c_client(cx, addr, cmd, arg); -} - -/* Calls i2c device based on I2C driver ID. */ -int cx18_i2c_id(struct cx18 *cx, u32 id, unsigned int cmd, void *arg) -{ - int addr; - - addr = cx18_i2c_id_addr(cx, id); - if (addr < 0) { - if (cmd != VIDIOC_G_CHIP_IDENT) - CX18_ERR("i2c ID 0x%08x (%s) not found for cmd 0x%x!\n", - id, cx18_i2c_id_name(id), cmd); - return addr; - } - return cx18_call_i2c_client(cx, addr, cmd, arg); -} - -/* broadcast cmd for all I2C clients and for the gpio subsystem */ -void cx18_call_i2c_clients(struct cx18 *cx, unsigned int cmd, void *arg) -{ - if (cx->i2c_adap[0].algo == NULL || cx->i2c_adap[1].algo == NULL) { - CX18_ERR("adapter is not set\n"); - return; - } - cx18_av_cmd(cx, cmd, arg); - i2c_clients_command(&cx->i2c_adap[0], cmd, arg); - i2c_clients_command(&cx->i2c_adap[1], cmd, arg); -} - -/* init + register i2c algo-bit adapter */ -int init_cx18_i2c(struct cx18 *cx) -{ - int i; - CX18_DEBUG_I2C("i2c init\n"); - - for (i = 0; i < 2; i++) { - memcpy(&cx->i2c_adap[i], &cx18_i2c_adap_template, - sizeof(struct i2c_adapter)); - memcpy(&cx->i2c_algo[i], &cx18_i2c_algo_template, - sizeof(struct i2c_algo_bit_data)); - cx->i2c_algo_cb_data[i].cx = cx; - cx->i2c_algo_cb_data[i].bus_index = i; - cx->i2c_algo[i].data = &cx->i2c_algo_cb_data[i]; - cx->i2c_adap[i].algo_data = &cx->i2c_algo[i]; - - sprintf(cx->i2c_adap[i].name + strlen(cx->i2c_adap[i].name), - " #%d-%d", cx->num, i); - i2c_set_adapdata(&cx->i2c_adap[i], cx); - - memcpy(&cx->i2c_client[i], &cx18_i2c_client_template, - sizeof(struct i2c_client)); - sprintf(cx->i2c_client[i].name + - strlen(cx->i2c_client[i].name), "%d", i); - cx->i2c_client[i].adapter = &cx->i2c_adap[i]; - cx->i2c_adap[i].dev.parent = &cx->dev->dev; - } - - if (read_reg(CX18_REG_I2C_2_WR) != 0x0003c02f) { - /* Reset/Unreset I2C hardware block */ - write_reg(0x10000000, 0xc71004); /* Clock select 220MHz */ - write_reg_sync(0x10001000, 0xc71024); /* Clock Enable */ - } - /* courtesy of Steven Toth */ - write_reg_sync(0x00c00000, 0xc7001c); - mdelay(10); - write_reg_sync(0x00c000c0, 0xc7001c); - mdelay(10); - write_reg_sync(0x00c00000, 0xc7001c); - - write_reg_sync(0x00c00000, 0xc730c8); /* Set to edge-triggered intrs. */ - write_reg_sync(0x00c00000, 0xc730c4); /* Clear any stale intrs */ - - /* Hw I2C1 Clock Freq ~100kHz */ - write_reg_sync(0x00021c0f & ~4, CX18_REG_I2C_1_WR); - cx18_setscl(&cx->i2c_algo_cb_data[0], 1); - cx18_setsda(&cx->i2c_algo_cb_data[0], 1); - - /* Hw I2C2 Clock Freq ~100kHz */ - write_reg_sync(0x00021c0f & ~4, CX18_REG_I2C_2_WR); - cx18_setscl(&cx->i2c_algo_cb_data[1], 1); - cx18_setsda(&cx->i2c_algo_cb_data[1], 1); - - return i2c_bit_add_bus(&cx->i2c_adap[0]) || - i2c_bit_add_bus(&cx->i2c_adap[1]); -} - -void exit_cx18_i2c(struct cx18 *cx) -{ - int i; - CX18_DEBUG_I2C("i2c exit\n"); - write_reg(read_reg(CX18_REG_I2C_1_WR) | 4, CX18_REG_I2C_1_WR); - write_reg(read_reg(CX18_REG_I2C_2_WR) | 4, CX18_REG_I2C_2_WR); - - for (i = 0; i < 2; i++) { - i2c_del_adapter(&cx->i2c_adap[i]); - } -} - -/* - Hauppauge HVR1600 should have: - 32 cx24227 - 98 unknown - a0 eeprom - c2 tuner - e? zilog ir - */ diff --git a/trunk/drivers/media/video/cx18/cx18-i2c.h b/trunk/drivers/media/video/cx18/cx18-i2c.h deleted file mode 100644 index 113c3f9a2cc0..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-i2c.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * cx18 I2C functions - * - * Derived from ivtv-i2c.h - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -int cx18_i2c_hw_addr(struct cx18 *cx, u32 hw); -int cx18_i2c_hw(struct cx18 *cx, u32 hw, unsigned int cmd, void *arg); -int cx18_i2c_id(struct cx18 *cx, u32 id, unsigned int cmd, void *arg); -int cx18_call_i2c_client(struct cx18 *cx, int addr, unsigned cmd, void *arg); -void cx18_call_i2c_clients(struct cx18 *cx, unsigned int cmd, void *arg); -int cx18_i2c_register(struct cx18 *cx, unsigned idx); - -/* init + register i2c algo-bit adapter */ -int init_cx18_i2c(struct cx18 *cx); -void exit_cx18_i2c(struct cx18 *cx); diff --git a/trunk/drivers/media/video/cx18/cx18-ioctl.c b/trunk/drivers/media/video/cx18/cx18-ioctl.c deleted file mode 100644 index dbdcb86ec5aa..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-ioctl.c +++ /dev/null @@ -1,851 +0,0 @@ -/* - * cx18 ioctl system call - * - * Derived from ivtv-ioctl.c - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -#include "cx18-driver.h" -#include "cx18-version.h" -#include "cx18-mailbox.h" -#include "cx18-i2c.h" -#include "cx18-queue.h" -#include "cx18-fileops.h" -#include "cx18-vbi.h" -#include "cx18-audio.h" -#include "cx18-video.h" -#include "cx18-streams.h" -#include "cx18-ioctl.h" -#include "cx18-gpio.h" -#include "cx18-controls.h" -#include "cx18-cards.h" -#include "cx18-av-core.h" -#include -#include -#include - -u16 cx18_service2vbi(int type) -{ - switch (type) { - case V4L2_SLICED_TELETEXT_B: - return CX18_SLICED_TYPE_TELETEXT_B; - case V4L2_SLICED_CAPTION_525: - return CX18_SLICED_TYPE_CAPTION_525; - case V4L2_SLICED_WSS_625: - return CX18_SLICED_TYPE_WSS_625; - case V4L2_SLICED_VPS: - return CX18_SLICED_TYPE_VPS; - default: - return 0; - } -} - -static int valid_service_line(int field, int line, int is_pal) -{ - return (is_pal && line >= 6 && (line != 23 || field == 0)) || - (!is_pal && line >= 10 && line < 22); -} - -static u16 select_service_from_set(int field, int line, u16 set, int is_pal) -{ - u16 valid_set = (is_pal ? V4L2_SLICED_VBI_625 : V4L2_SLICED_VBI_525); - int i; - - set = set & valid_set; - if (set == 0 || !valid_service_line(field, line, is_pal)) - return 0; - if (!is_pal) { - if (line == 21 && (set & V4L2_SLICED_CAPTION_525)) - return V4L2_SLICED_CAPTION_525; - } else { - if (line == 16 && field == 0 && (set & V4L2_SLICED_VPS)) - return V4L2_SLICED_VPS; - if (line == 23 && field == 0 && (set & V4L2_SLICED_WSS_625)) - return V4L2_SLICED_WSS_625; - if (line == 23) - return 0; - } - for (i = 0; i < 32; i++) { - if ((1 << i) & set) - return 1 << i; - } - return 0; -} - -void cx18_expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal) -{ - u16 set = fmt->service_set; - int f, l; - - fmt->service_set = 0; - for (f = 0; f < 2; f++) { - for (l = 0; l < 24; l++) - fmt->service_lines[f][l] = select_service_from_set(f, l, set, is_pal); - } -} - -static int check_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal) -{ - int f, l; - u16 set = 0; - - for (f = 0; f < 2; f++) { - for (l = 0; l < 24; l++) { - fmt->service_lines[f][l] = select_service_from_set(f, l, fmt->service_lines[f][l], is_pal); - set |= fmt->service_lines[f][l]; - } - } - return set != 0; -} - -u16 cx18_get_service_set(struct v4l2_sliced_vbi_format *fmt) -{ - int f, l; - u16 set = 0; - - for (f = 0; f < 2; f++) { - for (l = 0; l < 24; l++) - set |= fmt->service_lines[f][l]; - } - return set; -} - -static const struct { - v4l2_std_id std; - char *name; -} enum_stds[] = { - { V4L2_STD_PAL_BG | V4L2_STD_PAL_H, "PAL-BGH" }, - { V4L2_STD_PAL_DK, "PAL-DK" }, - { V4L2_STD_PAL_I, "PAL-I" }, - { V4L2_STD_PAL_M, "PAL-M" }, - { V4L2_STD_PAL_N, "PAL-N" }, - { V4L2_STD_PAL_Nc, "PAL-Nc" }, - { V4L2_STD_SECAM_B | V4L2_STD_SECAM_G | V4L2_STD_SECAM_H, "SECAM-BGH" }, - { V4L2_STD_SECAM_DK, "SECAM-DK" }, - { V4L2_STD_SECAM_L, "SECAM-L" }, - { V4L2_STD_SECAM_LC, "SECAM-L'" }, - { V4L2_STD_NTSC_M, "NTSC-M" }, - { V4L2_STD_NTSC_M_JP, "NTSC-J" }, - { V4L2_STD_NTSC_M_KR, "NTSC-K" }, -}; - -static const struct v4l2_standard cx18_std_60hz = { - .frameperiod = {.numerator = 1001, .denominator = 30000}, - .framelines = 525, -}; - -static const struct v4l2_standard cx18_std_50hz = { - .frameperiod = { .numerator = 1, .denominator = 25 }, - .framelines = 625, -}; - -static int cx18_cxc(struct cx18 *cx, unsigned int cmd, void *arg) -{ - struct v4l2_register *regs = arg; - unsigned long flags; - - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - if (regs->reg >= CX18_MEM_OFFSET + CX18_MEM_SIZE) - return -EINVAL; - - spin_lock_irqsave(&cx18_cards_lock, flags); - if (cmd == VIDIOC_DBG_G_REGISTER) - regs->val = read_enc(regs->reg); - else - write_enc(regs->val, regs->reg); - spin_unlock_irqrestore(&cx18_cards_lock, flags); - return 0; -} - -static int cx18_get_fmt(struct cx18 *cx, int streamtype, struct v4l2_format *fmt) -{ - switch (fmt->type) { - case V4L2_BUF_TYPE_VIDEO_CAPTURE: - fmt->fmt.pix.width = cx->params.width; - fmt->fmt.pix.height = cx->params.height; - fmt->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; - fmt->fmt.pix.field = V4L2_FIELD_INTERLACED; - if (streamtype == CX18_ENC_STREAM_TYPE_YUV) { - fmt->fmt.pix.pixelformat = V4L2_PIX_FMT_HM12; - /* YUV size is (Y=(h*w) + UV=(h*(w/2))) */ - fmt->fmt.pix.sizeimage = - fmt->fmt.pix.height * fmt->fmt.pix.width + - fmt->fmt.pix.height * (fmt->fmt.pix.width / 2); - } else { - fmt->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; - fmt->fmt.pix.sizeimage = 128 * 1024; - } - break; - - case V4L2_BUF_TYPE_VBI_CAPTURE: - fmt->fmt.vbi.sampling_rate = 27000000; - fmt->fmt.vbi.offset = 248; - fmt->fmt.vbi.samples_per_line = cx->vbi.raw_decoder_line_size - 4; - fmt->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY; - fmt->fmt.vbi.start[0] = cx->vbi.start[0]; - fmt->fmt.vbi.start[1] = cx->vbi.start[1]; - fmt->fmt.vbi.count[0] = fmt->fmt.vbi.count[1] = cx->vbi.count; - break; - - case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: - { - struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced; - - vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36; - memset(vbifmt->reserved, 0, sizeof(vbifmt->reserved)); - memset(vbifmt->service_lines, 0, sizeof(vbifmt->service_lines)); - - cx18_av_cmd(cx, VIDIOC_G_FMT, fmt); - vbifmt->service_set = cx18_get_service_set(vbifmt); - break; - } - default: - return -EINVAL; - } - return 0; -} - -static int cx18_try_or_set_fmt(struct cx18 *cx, int streamtype, - struct v4l2_format *fmt, int set_fmt) -{ - struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced; - u16 set; - - /* set window size */ - if (fmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { - int w = fmt->fmt.pix.width; - int h = fmt->fmt.pix.height; - - if (w > 720) - w = 720; - else if (w < 1) - w = 1; - if (h > (cx->is_50hz ? 576 : 480)) - h = (cx->is_50hz ? 576 : 480); - else if (h < 2) - h = 2; - cx18_get_fmt(cx, streamtype, fmt); - fmt->fmt.pix.width = w; - fmt->fmt.pix.height = h; - - if (!set_fmt || (cx->params.width == w && cx->params.height == h)) - return 0; - if (atomic_read(&cx->capturing) > 0) - return -EBUSY; - - cx->params.width = w; - cx->params.height = h; - if (w != 720 || h != (cx->is_50hz ? 576 : 480)) - cx->params.video_temporal_filter = 0; - else - cx->params.video_temporal_filter = 8; - cx18_av_cmd(cx, VIDIOC_S_FMT, fmt); - return cx18_get_fmt(cx, streamtype, fmt); - } - - /* set raw VBI format */ - if (fmt->type == V4L2_BUF_TYPE_VBI_CAPTURE) { - if (set_fmt && streamtype == CX18_ENC_STREAM_TYPE_VBI && - cx->vbi.sliced_in->service_set && - atomic_read(&cx->capturing) > 0) - return -EBUSY; - if (set_fmt) { - cx->vbi.sliced_in->service_set = 0; - cx18_av_cmd(cx, VIDIOC_S_FMT, &cx->vbi.in); - } - return cx18_get_fmt(cx, streamtype, fmt); - } - - /* any else but sliced VBI capture is an error */ - if (fmt->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE) - return -EINVAL; - - /* TODO: implement sliced VBI, for now silently return 0 */ - return 0; - - /* set sliced VBI capture format */ - vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36; - memset(vbifmt->reserved, 0, sizeof(vbifmt->reserved)); - - if (vbifmt->service_set) - cx18_expand_service_set(vbifmt, cx->is_50hz); - set = check_service_set(vbifmt, cx->is_50hz); - vbifmt->service_set = cx18_get_service_set(vbifmt); - - if (!set_fmt) - return 0; - if (set == 0) - return -EINVAL; - if (atomic_read(&cx->capturing) > 0 && cx->vbi.sliced_in->service_set == 0) - return -EBUSY; - cx18_av_cmd(cx, VIDIOC_S_FMT, fmt); - memcpy(cx->vbi.sliced_in, vbifmt, sizeof(*cx->vbi.sliced_in)); - return 0; -} - -static int cx18_debug_ioctls(struct file *filp, unsigned int cmd, void *arg) -{ - struct cx18_open_id *id = (struct cx18_open_id *)filp->private_data; - struct cx18 *cx = id->cx; - struct v4l2_register *reg = arg; - - switch (cmd) { - /* ioctls to allow direct access to the encoder registers for testing */ - case VIDIOC_DBG_G_REGISTER: - if (v4l2_chip_match_host(reg->match_type, reg->match_chip)) - return cx18_cxc(cx, cmd, arg); - if (reg->match_type == V4L2_CHIP_MATCH_I2C_DRIVER) - return cx18_i2c_id(cx, reg->match_chip, cmd, arg); - return cx18_call_i2c_client(cx, reg->match_chip, cmd, arg); - - case VIDIOC_DBG_S_REGISTER: - if (v4l2_chip_match_host(reg->match_type, reg->match_chip)) - return cx18_cxc(cx, cmd, arg); - if (reg->match_type == V4L2_CHIP_MATCH_I2C_DRIVER) - return cx18_i2c_id(cx, reg->match_chip, cmd, arg); - return cx18_call_i2c_client(cx, reg->match_chip, cmd, arg); - - case VIDIOC_G_CHIP_IDENT: { - struct v4l2_chip_ident *chip = arg; - - chip->ident = V4L2_IDENT_NONE; - chip->revision = 0; - if (reg->match_type == V4L2_CHIP_MATCH_HOST) { - if (v4l2_chip_match_host(reg->match_type, reg->match_chip)) { - struct v4l2_chip_ident *chip = arg; - - chip->ident = V4L2_IDENT_CX23418; - } - return 0; - } - if (reg->match_type == V4L2_CHIP_MATCH_I2C_DRIVER) - return cx18_i2c_id(cx, reg->match_chip, cmd, arg); - if (reg->match_type == V4L2_CHIP_MATCH_I2C_ADDR) - return cx18_call_i2c_client(cx, reg->match_chip, cmd, arg); - return -EINVAL; - } - - case VIDIOC_INT_S_AUDIO_ROUTING: { - struct v4l2_routing *route = arg; - - cx18_audio_set_route(cx, route); - break; - } - - default: - return -EINVAL; - } - return 0; -} - -int cx18_v4l2_ioctls(struct cx18 *cx, struct file *filp, unsigned cmd, void *arg) -{ - struct cx18_open_id *id = NULL; - - if (filp) - id = (struct cx18_open_id *)filp->private_data; - - switch (cmd) { - case VIDIOC_G_PRIORITY: - { - enum v4l2_priority *p = arg; - - *p = v4l2_prio_max(&cx->prio); - break; - } - - case VIDIOC_S_PRIORITY: - { - enum v4l2_priority *prio = arg; - - return v4l2_prio_change(&cx->prio, &id->prio, *prio); - } - - case VIDIOC_QUERYCAP:{ - struct v4l2_capability *vcap = arg; - - memset(vcap, 0, sizeof(*vcap)); - strlcpy(vcap->driver, CX18_DRIVER_NAME, sizeof(vcap->driver)); - strlcpy(vcap->card, cx->card_name, sizeof(vcap->card)); - strlcpy(vcap->bus_info, pci_name(cx->dev), sizeof(vcap->bus_info)); - vcap->version = CX18_DRIVER_VERSION; /* version */ - vcap->capabilities = cx->v4l2_cap; /* capabilities */ - - /* reserved.. must set to 0! */ - vcap->reserved[0] = vcap->reserved[1] = - vcap->reserved[2] = vcap->reserved[3] = 0; - break; - } - - case VIDIOC_ENUMAUDIO:{ - struct v4l2_audio *vin = arg; - - return cx18_get_audio_input(cx, vin->index, vin); - } - - case VIDIOC_G_AUDIO:{ - struct v4l2_audio *vin = arg; - - vin->index = cx->audio_input; - return cx18_get_audio_input(cx, vin->index, vin); - } - - case VIDIOC_S_AUDIO:{ - struct v4l2_audio *vout = arg; - - if (vout->index >= cx->nof_audio_inputs) - return -EINVAL; - cx->audio_input = vout->index; - cx18_audio_set_io(cx); - break; - } - - case VIDIOC_ENUMINPUT:{ - struct v4l2_input *vin = arg; - - /* set it to defaults from our table */ - return cx18_get_input(cx, vin->index, vin); - } - - case VIDIOC_TRY_FMT: - case VIDIOC_S_FMT: { - struct v4l2_format *fmt = arg; - - return cx18_try_or_set_fmt(cx, id->type, fmt, cmd == VIDIOC_S_FMT); - } - - case VIDIOC_G_FMT: { - struct v4l2_format *fmt = arg; - int type = fmt->type; - - memset(fmt, 0, sizeof(*fmt)); - fmt->type = type; - return cx18_get_fmt(cx, id->type, fmt); - } - - case VIDIOC_CROPCAP: { - struct v4l2_cropcap *cropcap = arg; - - if (cropcap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; - cropcap->bounds.top = cropcap->bounds.left = 0; - cropcap->bounds.width = 720; - cropcap->bounds.height = cx->is_50hz ? 576 : 480; - cropcap->pixelaspect.numerator = cx->is_50hz ? 59 : 10; - cropcap->pixelaspect.denominator = cx->is_50hz ? 54 : 11; - cropcap->defrect = cropcap->bounds; - return 0; - } - - case VIDIOC_S_CROP: { - struct v4l2_crop *crop = arg; - - if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; - return cx18_av_cmd(cx, VIDIOC_S_CROP, arg); - } - - case VIDIOC_G_CROP: { - struct v4l2_crop *crop = arg; - - if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - return -EINVAL; - return cx18_av_cmd(cx, VIDIOC_G_CROP, arg); - } - - case VIDIOC_ENUM_FMT: { - static struct v4l2_fmtdesc formats[] = { - { 0, 0, 0, - "HM12 (YUV 4:1:1)", V4L2_PIX_FMT_HM12, - { 0, 0, 0, 0 } - }, - { 1, 0, V4L2_FMT_FLAG_COMPRESSED, - "MPEG", V4L2_PIX_FMT_MPEG, - { 0, 0, 0, 0 } - } - }; - struct v4l2_fmtdesc *fmt = arg; - enum v4l2_buf_type type = fmt->type; - - switch (type) { - case V4L2_BUF_TYPE_VIDEO_CAPTURE: - break; - default: - return -EINVAL; - } - if (fmt->index > 1) - return -EINVAL; - *fmt = formats[fmt->index]; - fmt->type = type; - return 0; - } - - case VIDIOC_G_INPUT:{ - *(int *)arg = cx->active_input; - break; - } - - case VIDIOC_S_INPUT:{ - int inp = *(int *)arg; - - if (inp < 0 || inp >= cx->nof_inputs) - return -EINVAL; - - if (inp == cx->active_input) { - CX18_DEBUG_INFO("Input unchanged\n"); - break; - } - CX18_DEBUG_INFO("Changing input from %d to %d\n", - cx->active_input, inp); - - cx->active_input = inp; - /* Set the audio input to whatever is appropriate for the - input type. */ - cx->audio_input = cx->card->video_inputs[inp].audio_index; - - /* prevent others from messing with the streams until - we're finished changing inputs. */ - cx18_mute(cx); - cx18_video_set_io(cx); - cx18_audio_set_io(cx); - cx18_unmute(cx); - break; - } - - case VIDIOC_G_FREQUENCY:{ - struct v4l2_frequency *vf = arg; - - if (vf->tuner != 0) - return -EINVAL; - cx18_call_i2c_clients(cx, cmd, arg); - break; - } - - case VIDIOC_S_FREQUENCY:{ - struct v4l2_frequency vf = *(struct v4l2_frequency *)arg; - - if (vf.tuner != 0) - return -EINVAL; - - cx18_mute(cx); - CX18_DEBUG_INFO("v4l2 ioctl: set frequency %d\n", vf.frequency); - cx18_call_i2c_clients(cx, cmd, &vf); - cx18_unmute(cx); - break; - } - - case VIDIOC_ENUMSTD:{ - struct v4l2_standard *vs = arg; - int idx = vs->index; - - if (idx < 0 || idx >= ARRAY_SIZE(enum_stds)) - return -EINVAL; - - *vs = (enum_stds[idx].std & V4L2_STD_525_60) ? - cx18_std_60hz : cx18_std_50hz; - vs->index = idx; - vs->id = enum_stds[idx].std; - strlcpy(vs->name, enum_stds[idx].name, sizeof(vs->name)); - break; - } - - case VIDIOC_G_STD:{ - *(v4l2_std_id *) arg = cx->std; - break; - } - - case VIDIOC_S_STD: { - v4l2_std_id std = *(v4l2_std_id *) arg; - - if ((std & V4L2_STD_ALL) == 0) - return -EINVAL; - - if (std == cx->std) - break; - - if (test_bit(CX18_F_I_RADIO_USER, &cx->i_flags) || - atomic_read(&cx->capturing) > 0) { - /* Switching standard would turn off the radio or mess - with already running streams, prevent that by - returning EBUSY. */ - return -EBUSY; - } - - cx->std = std; - cx->is_60hz = (std & V4L2_STD_525_60) ? 1 : 0; - cx->params.is_50hz = cx->is_50hz = !cx->is_60hz; - cx->params.width = 720; - cx->params.height = cx->is_50hz ? 576 : 480; - cx->vbi.count = cx->is_50hz ? 18 : 12; - cx->vbi.start[0] = cx->is_50hz ? 6 : 10; - cx->vbi.start[1] = cx->is_50hz ? 318 : 273; - cx->vbi.sliced_decoder_line_size = cx->is_60hz ? 272 : 284; - CX18_DEBUG_INFO("Switching standard to %llx.\n", (unsigned long long)cx->std); - - /* Tuner */ - cx18_call_i2c_clients(cx, VIDIOC_S_STD, &cx->std); - break; - } - - case VIDIOC_S_TUNER: { /* Setting tuner can only set audio mode */ - struct v4l2_tuner *vt = arg; - - if (vt->index != 0) - return -EINVAL; - - cx18_call_i2c_clients(cx, VIDIOC_S_TUNER, vt); - break; - } - - case VIDIOC_G_TUNER: { - struct v4l2_tuner *vt = arg; - - if (vt->index != 0) - return -EINVAL; - - memset(vt, 0, sizeof(*vt)); - cx18_call_i2c_clients(cx, VIDIOC_G_TUNER, vt); - - if (test_bit(CX18_F_I_RADIO_USER, &cx->i_flags)) { - strlcpy(vt->name, "cx18 Radio Tuner", sizeof(vt->name)); - vt->type = V4L2_TUNER_RADIO; - } else { - strlcpy(vt->name, "cx18 TV Tuner", sizeof(vt->name)); - vt->type = V4L2_TUNER_ANALOG_TV; - } - break; - } - - case VIDIOC_G_SLICED_VBI_CAP: { - struct v4l2_sliced_vbi_cap *cap = arg; - int set = cx->is_50hz ? V4L2_SLICED_VBI_625 : V4L2_SLICED_VBI_525; - int f, l; - enum v4l2_buf_type type = cap->type; - - memset(cap, 0, sizeof(*cap)); - cap->type = type; - if (type == V4L2_BUF_TYPE_SLICED_VBI_CAPTURE) { - for (f = 0; f < 2; f++) { - for (l = 0; l < 24; l++) { - if (valid_service_line(f, l, cx->is_50hz)) - cap->service_lines[f][l] = set; - } - } - return 0; - } - return -EINVAL; - } - - case VIDIOC_ENCODER_CMD: - case VIDIOC_TRY_ENCODER_CMD: { - struct v4l2_encoder_cmd *enc = arg; - int try = cmd == VIDIOC_TRY_ENCODER_CMD; - - memset(&enc->raw, 0, sizeof(enc->raw)); - switch (enc->cmd) { - case V4L2_ENC_CMD_START: - enc->flags = 0; - if (try) - return 0; - return cx18_start_capture(id); - - case V4L2_ENC_CMD_STOP: - enc->flags &= V4L2_ENC_CMD_STOP_AT_GOP_END; - if (try) - return 0; - cx18_stop_capture(id, enc->flags & V4L2_ENC_CMD_STOP_AT_GOP_END); - return 0; - - case V4L2_ENC_CMD_PAUSE: - enc->flags = 0; - if (try) - return 0; - if (!atomic_read(&cx->capturing)) - return -EPERM; - if (test_and_set_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags)) - return 0; - cx18_mute(cx); - cx18_vapi(cx, CX18_CPU_CAPTURE_PAUSE, 1, cx18_find_handle(cx)); - break; - - case V4L2_ENC_CMD_RESUME: - enc->flags = 0; - if (try) - return 0; - if (!atomic_read(&cx->capturing)) - return -EPERM; - if (!test_and_clear_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags)) - return 0; - cx18_vapi(cx, CX18_CPU_CAPTURE_RESUME, 1, cx18_find_handle(cx)); - cx18_unmute(cx); - break; - default: - return -EINVAL; - } - break; - } - - case VIDIOC_LOG_STATUS: - { - struct v4l2_input vidin; - struct v4l2_audio audin; - int i; - - CX18_INFO("================= START STATUS CARD #%d =================\n", cx->num); - if (cx->hw_flags & CX18_HW_TVEEPROM) { - struct tveeprom tv; - - cx18_read_eeprom(cx, &tv); - } - cx18_call_i2c_clients(cx, VIDIOC_LOG_STATUS, NULL); - cx18_get_input(cx, cx->active_input, &vidin); - cx18_get_audio_input(cx, cx->audio_input, &audin); - CX18_INFO("Video Input: %s\n", vidin.name); - CX18_INFO("Audio Input: %s\n", audin.name); - CX18_INFO("Tuner: %s\n", - test_bit(CX18_F_I_RADIO_USER, &cx->i_flags) ? - "Radio" : "TV"); - cx2341x_log_status(&cx->params, cx->name); - CX18_INFO("Status flags: 0x%08lx\n", cx->i_flags); - for (i = 0; i < CX18_MAX_STREAMS; i++) { - struct cx18_stream *s = &cx->streams[i]; - - if (s->v4l2dev == NULL || s->buffers == 0) - continue; - CX18_INFO("Stream %s: status 0x%04lx, %d%% of %d KiB (%d buffers) in use\n", - s->name, s->s_flags, - (s->buffers - s->q_free.buffers) * 100 / s->buffers, - (s->buffers * s->buf_size) / 1024, s->buffers); - } - CX18_INFO("Read MPEG/VBI: %lld/%lld bytes\n", - (long long)cx->mpg_data_received, - (long long)cx->vbi_data_inserted); - CX18_INFO("================== END STATUS CARD #%d ==================\n", cx->num); - break; - } - - default: - return -EINVAL; - } - return 0; -} - -static int cx18_v4l2_do_ioctl(struct inode *inode, struct file *filp, - unsigned int cmd, void *arg) -{ - struct cx18_open_id *id = (struct cx18_open_id *)filp->private_data; - struct cx18 *cx = id->cx; - int ret; - - /* check priority */ - switch (cmd) { - case VIDIOC_S_CTRL: - case VIDIOC_S_STD: - case VIDIOC_S_INPUT: - case VIDIOC_S_TUNER: - case VIDIOC_S_FREQUENCY: - case VIDIOC_S_FMT: - case VIDIOC_S_CROP: - case VIDIOC_S_EXT_CTRLS: - ret = v4l2_prio_check(&cx->prio, &id->prio); - if (ret) - return ret; - } - - switch (cmd) { - case VIDIOC_DBG_G_REGISTER: - case VIDIOC_DBG_S_REGISTER: - case VIDIOC_G_CHIP_IDENT: - case VIDIOC_INT_S_AUDIO_ROUTING: - case VIDIOC_INT_RESET: - if (cx18_debug & CX18_DBGFLG_IOCTL) { - printk(KERN_INFO "cx18%d ioctl: ", cx->num); - v4l_printk_ioctl(cmd); - } - return cx18_debug_ioctls(filp, cmd, arg); - - case VIDIOC_G_PRIORITY: - case VIDIOC_S_PRIORITY: - case VIDIOC_QUERYCAP: - case VIDIOC_ENUMINPUT: - case VIDIOC_G_INPUT: - case VIDIOC_S_INPUT: - case VIDIOC_G_FMT: - case VIDIOC_S_FMT: - case VIDIOC_TRY_FMT: - case VIDIOC_ENUM_FMT: - case VIDIOC_CROPCAP: - case VIDIOC_G_CROP: - case VIDIOC_S_CROP: - case VIDIOC_G_FREQUENCY: - case VIDIOC_S_FREQUENCY: - case VIDIOC_ENUMSTD: - case VIDIOC_G_STD: - case VIDIOC_S_STD: - case VIDIOC_S_TUNER: - case VIDIOC_G_TUNER: - case VIDIOC_ENUMAUDIO: - case VIDIOC_S_AUDIO: - case VIDIOC_G_AUDIO: - case VIDIOC_G_SLICED_VBI_CAP: - case VIDIOC_LOG_STATUS: - case VIDIOC_G_ENC_INDEX: - case VIDIOC_ENCODER_CMD: - case VIDIOC_TRY_ENCODER_CMD: - if (cx18_debug & CX18_DBGFLG_IOCTL) { - printk(KERN_INFO "cx18%d ioctl: ", cx->num); - v4l_printk_ioctl(cmd); - } - return cx18_v4l2_ioctls(cx, filp, cmd, arg); - - case VIDIOC_QUERYMENU: - case VIDIOC_QUERYCTRL: - case VIDIOC_S_CTRL: - case VIDIOC_G_CTRL: - case VIDIOC_S_EXT_CTRLS: - case VIDIOC_G_EXT_CTRLS: - case VIDIOC_TRY_EXT_CTRLS: - if (cx18_debug & CX18_DBGFLG_IOCTL) { - printk(KERN_INFO "cx18%d ioctl: ", cx->num); - v4l_printk_ioctl(cmd); - } - return cx18_control_ioctls(cx, cmd, arg); - - case 0x00005401: /* Handle isatty() calls */ - return -EINVAL; - default: - return v4l_compat_translate_ioctl(inode, filp, cmd, arg, - cx18_v4l2_do_ioctl); - } - return 0; -} - -int cx18_v4l2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, - unsigned long arg) -{ - struct cx18_open_id *id = (struct cx18_open_id *)filp->private_data; - struct cx18 *cx = id->cx; - int res; - - mutex_lock(&cx->serialize_lock); - res = video_usercopy(inode, filp, cmd, arg, cx18_v4l2_do_ioctl); - mutex_unlock(&cx->serialize_lock); - return res; -} diff --git a/trunk/drivers/media/video/cx18/cx18-ioctl.h b/trunk/drivers/media/video/cx18/cx18-ioctl.h deleted file mode 100644 index 9f4c7eb2897f..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-ioctl.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * cx18 ioctl system call - * - * Derived from ivtv-ioctl.h - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -u16 cx18_service2vbi(int type); -void cx18_expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal); -u16 cx18_get_service_set(struct v4l2_sliced_vbi_format *fmt); -int cx18_v4l2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, - unsigned long arg); -int cx18_v4l2_ioctls(struct cx18 *cx, struct file *filp, unsigned cmd, - void *arg); diff --git a/trunk/drivers/media/video/cx18/cx18-irq.c b/trunk/drivers/media/video/cx18/cx18-irq.c deleted file mode 100644 index 6e14f8bda559..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-irq.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * cx18 interrupt handling - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -#include "cx18-driver.h" -#include "cx18-firmware.h" -#include "cx18-fileops.h" -#include "cx18-queue.h" -#include "cx18-irq.h" -#include "cx18-ioctl.h" -#include "cx18-mailbox.h" -#include "cx18-vbi.h" -#include "cx18-scb.h" - -#define DMA_MAGIC_COOKIE 0x000001fe - -static void epu_dma_done(struct cx18 *cx, struct cx18_mailbox *mb) -{ - u32 handle = mb->args[0]; - struct cx18_stream *s = NULL; - struct cx18_buffer *buf; - u32 off; - int i; - int id; - - for (i = 0; i < CX18_MAX_STREAMS; i++) { - s = &cx->streams[i]; - if ((handle == s->handle) && (s->dvb.enabled)) - break; - if (s->v4l2dev && handle == s->handle) - break; - } - if (i == CX18_MAX_STREAMS) { - CX18_WARN("DMA done for unknown handle %d for stream %s\n", - handle, s->name); - mb->error = CXERR_NOT_OPEN; - mb->cmd = 0; - cx18_mb_ack(cx, mb); - return; - } - - off = mb->args[1]; - if (mb->args[2] != 1) - CX18_WARN("Ack struct = %d for %s\n", - mb->args[2], s->name); - id = read_enc(off); - buf = cx18_queue_find_buf(s, id, read_enc(off + 4)); - CX18_DEBUG_HI_DMA("DMA DONE for %s (buffer %d)\n", s->name, id); - if (buf) { - cx18_buf_sync_for_cpu(s, buf); - if (s->type == CX18_ENC_STREAM_TYPE_TS && s->dvb.enabled) { - /* process the buffer here */ - CX18_DEBUG_HI_DMA("TS recv and sent bytesused=%d\n", - buf->bytesused); - - dvb_dmx_swfilter(&s->dvb.demux, buf->buf, - buf->bytesused); - - cx18_buf_sync_for_device(s, buf); - cx18_vapi(cx, CX18_CPU_DE_SET_MDL, 5, s->handle, - (void *)&cx->scb->cpu_mdl[buf->id] - cx->enc_mem, - 1, buf->id, s->buf_size); - } else - set_bit(CX18_F_B_NEED_BUF_SWAP, &buf->b_flags); - } else { - CX18_WARN("Could not find buf %d for stream %s\n", - read_enc(off), s->name); - } - mb->error = 0; - mb->cmd = 0; - cx18_mb_ack(cx, mb); - wake_up(&cx->dma_waitq); - if (s->id != -1) - wake_up(&s->waitq); -} - -static void epu_debug(struct cx18 *cx, struct cx18_mailbox *mb) -{ - char str[256] = { 0 }; - char *p; - - if (mb->args[1]) { - setup_page(mb->args[1]); - memcpy_fromio(str, cx->enc_mem + mb->args[1], 252); - str[252] = 0; - } - cx18_mb_ack(cx, mb); - CX18_DEBUG_INFO("%x %s\n", mb->args[0], str); - p = strchr(str, '.'); - if (!test_bit(CX18_F_I_LOADED_FW, &cx->i_flags) && p && p > str) - CX18_INFO("FW version: %s\n", p - 1); -} - -static void hpu_cmd(struct cx18 *cx, u32 sw1) -{ - struct cx18_mailbox mb; - - if (sw1 & IRQ_CPU_TO_EPU) { - memcpy_fromio(&mb, &cx->scb->cpu2epu_mb, sizeof(mb)); - mb.error = 0; - - switch (mb.cmd) { - case CX18_EPU_DMA_DONE: - epu_dma_done(cx, &mb); - break; - case CX18_EPU_DEBUG: - epu_debug(cx, &mb); - break; - default: - CX18_WARN("Unexpected mailbox command %08x\n", mb.cmd); - break; - } - } - if (sw1 & (IRQ_APU_TO_EPU | IRQ_HPU_TO_EPU)) - CX18_WARN("Unexpected interrupt %08x\n", sw1); -} - -irqreturn_t cx18_irq_handler(int irq, void *dev_id) -{ - struct cx18 *cx = (struct cx18 *)dev_id; - u32 sw1, sw1_mask; - u32 sw2, sw2_mask; - u32 hw2, hw2_mask; - - spin_lock(&cx->dma_reg_lock); - - hw2_mask = read_reg(HW2_INT_MASK5_PCI); - hw2 = read_reg(HW2_INT_CLR_STATUS) & hw2_mask; - sw2_mask = read_reg(SW2_INT_ENABLE_PCI) | IRQ_EPU_TO_HPU_ACK; - sw2 = read_reg(SW2_INT_STATUS) & sw2_mask; - sw1_mask = read_reg(SW1_INT_ENABLE_PCI) | IRQ_EPU_TO_HPU; - sw1 = read_reg(SW1_INT_STATUS) & sw1_mask; - - write_reg(sw2&sw2_mask, SW2_INT_STATUS); - write_reg(sw1&sw1_mask, SW1_INT_STATUS); - write_reg(hw2&hw2_mask, HW2_INT_CLR_STATUS); - - if (sw1 || sw2 || hw2) - CX18_DEBUG_HI_IRQ("SW1: %x SW2: %x HW2: %x\n", sw1, sw2, hw2); - - /* To do: interrupt-based I2C handling - if (hw2 & 0x00c00000) { - } - */ - - if (sw2) { - if (sw2 & (cx->scb->cpu2hpu_irq_ack | cx->scb->cpu2epu_irq_ack)) - wake_up(&cx->mb_cpu_waitq); - if (sw2 & (cx->scb->apu2hpu_irq_ack | cx->scb->apu2epu_irq_ack)) - wake_up(&cx->mb_apu_waitq); - if (sw2 & cx->scb->epu2hpu_irq_ack) - wake_up(&cx->mb_epu_waitq); - if (sw2 & cx->scb->hpu2epu_irq_ack) - wake_up(&cx->mb_hpu_waitq); - } - - if (sw1) - hpu_cmd(cx, sw1); - spin_unlock(&cx->dma_reg_lock); - - return (hw2 | sw1 | sw2) ? IRQ_HANDLED : IRQ_NONE; -} diff --git a/trunk/drivers/media/video/cx18/cx18-irq.h b/trunk/drivers/media/video/cx18/cx18-irq.h deleted file mode 100644 index 379f704f5cba..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-irq.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * cx18 interrupt handling - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -#define HW2_I2C1_INT (1 << 22) -#define HW2_I2C2_INT (1 << 23) -#define HW2_INT_CLR_STATUS 0xc730c4 -#define HW2_INT_MASK5_PCI 0xc730e4 -#define SW1_INT_SET 0xc73100 -#define SW1_INT_STATUS 0xc73104 -#define SW1_INT_ENABLE_PCI 0xc7311c -#define SW2_INT_SET 0xc73140 -#define SW2_INT_STATUS 0xc73144 -#define SW2_INT_ENABLE_PCI 0xc7315c - -irqreturn_t cx18_irq_handler(int irq, void *dev_id); - -void cx18_irq_work_handler(struct work_struct *work); -void cx18_dma_stream_dec_prepare(struct cx18_stream *s, u32 offset, int lock); -void cx18_unfinished_dma(unsigned long arg); diff --git a/trunk/drivers/media/video/cx18/cx18-mailbox.c b/trunk/drivers/media/video/cx18/cx18-mailbox.c deleted file mode 100644 index 0c5f328bca54..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-mailbox.c +++ /dev/null @@ -1,372 +0,0 @@ -/* - * cx18 mailbox functions - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -#include - -#include "cx18-driver.h" -#include "cx18-scb.h" -#include "cx18-irq.h" -#include "cx18-mailbox.h" - -#define API_FAST (1 << 2) /* Short timeout */ -#define API_SLOW (1 << 3) /* Additional 300ms timeout */ - -#define APU 0 -#define CPU 1 -#define EPU 2 -#define HPU 3 - -struct cx18_api_info { - u32 cmd; - u8 flags; /* Flags, see above */ - u8 rpu; /* Processing unit */ - const char *name; /* The name of the command */ -}; - -#define API_ENTRY(rpu, x, f) { (x), (f), (rpu), #x } - -static const struct cx18_api_info api_info[] = { - /* MPEG encoder API */ - API_ENTRY(CPU, CX18_CPU_SET_CHANNEL_TYPE, 0), - API_ENTRY(CPU, CX18_EPU_DEBUG, 0), - API_ENTRY(CPU, CX18_CREATE_TASK, 0), - API_ENTRY(CPU, CX18_DESTROY_TASK, 0), - API_ENTRY(CPU, CX18_CPU_CAPTURE_START, API_SLOW), - API_ENTRY(CPU, CX18_CPU_CAPTURE_STOP, API_SLOW), - API_ENTRY(CPU, CX18_CPU_CAPTURE_PAUSE, 0), - API_ENTRY(CPU, CX18_CPU_CAPTURE_RESUME, 0), - API_ENTRY(CPU, CX18_CPU_SET_CHANNEL_TYPE, 0), - API_ENTRY(CPU, CX18_CPU_SET_STREAM_OUTPUT_TYPE, 0), - API_ENTRY(CPU, CX18_CPU_SET_VIDEO_IN, 0), - API_ENTRY(CPU, CX18_CPU_SET_VIDEO_RATE, 0), - API_ENTRY(CPU, CX18_CPU_SET_VIDEO_RESOLUTION, 0), - API_ENTRY(CPU, CX18_CPU_SET_FILTER_PARAM, 0), - API_ENTRY(CPU, CX18_CPU_SET_SPATIAL_FILTER_TYPE, 0), - API_ENTRY(CPU, CX18_CPU_SET_MEDIAN_CORING, 0), - API_ENTRY(CPU, CX18_CPU_SET_INDEXTABLE, 0), - API_ENTRY(CPU, CX18_CPU_SET_AUDIO_PARAMETERS, 0), - API_ENTRY(CPU, CX18_CPU_SET_VIDEO_MUTE, 0), - API_ENTRY(CPU, CX18_CPU_SET_AUDIO_MUTE, 0), - API_ENTRY(CPU, CX18_CPU_SET_MISC_PARAMETERS, 0), - API_ENTRY(CPU, CX18_CPU_SET_RAW_VBI_PARAM, API_SLOW), - API_ENTRY(CPU, CX18_CPU_SET_CAPTURE_LINE_NO, 0), - API_ENTRY(CPU, CX18_CPU_SET_COPYRIGHT, 0), - API_ENTRY(CPU, CX18_CPU_SET_AUDIO_PID, 0), - API_ENTRY(CPU, CX18_CPU_SET_VIDEO_PID, 0), - API_ENTRY(CPU, CX18_CPU_SET_VER_CROP_LINE, 0), - API_ENTRY(CPU, CX18_CPU_SET_GOP_STRUCTURE, 0), - API_ENTRY(CPU, CX18_CPU_SET_SCENE_CHANGE_DETECTION, 0), - API_ENTRY(CPU, CX18_CPU_SET_ASPECT_RATIO, 0), - API_ENTRY(CPU, CX18_CPU_SET_SKIP_INPUT_FRAME, 0), - API_ENTRY(CPU, CX18_CPU_SET_SLICED_VBI_PARAM, 0), - API_ENTRY(CPU, CX18_CPU_SET_USERDATA_PLACE_HOLDER, 0), - API_ENTRY(CPU, CX18_CPU_GET_ENC_PTS, 0), - API_ENTRY(CPU, CX18_CPU_DE_SET_MDL_ACK, 0), - API_ENTRY(CPU, CX18_CPU_DE_SET_MDL, API_FAST), - API_ENTRY(0, 0, 0), -}; - -static const struct cx18_api_info *find_api_info(u32 cmd) -{ - int i; - - for (i = 0; api_info[i].cmd; i++) - if (api_info[i].cmd == cmd) - return &api_info[i]; - return NULL; -} - -static struct cx18_mailbox *cx18_mb_is_complete(struct cx18 *cx, int rpu, - u32 *state, u32 *irq, u32 *req) -{ - struct cx18_mailbox *mb = NULL; - int wait_count = 0; - u32 ack; - - switch (rpu) { - case APU: - mb = &cx->scb->epu2apu_mb; - *state = readl(&cx->scb->apu_state); - *irq = readl(&cx->scb->epu2apu_irq); - break; - - case CPU: - mb = &cx->scb->epu2cpu_mb; - *state = readl(&cx->scb->cpu_state); - *irq = readl(&cx->scb->epu2cpu_irq); - break; - - case HPU: - mb = &cx->scb->epu2hpu_mb; - *state = readl(&cx->scb->hpu_state); - *irq = readl(&cx->scb->epu2hpu_irq); - break; - } - - if (mb == NULL) - return mb; - - do { - *req = readl(&mb->request); - ack = readl(&mb->ack); - wait_count++; - } while (*req != ack && wait_count < 600); - - if (*req == ack) { - (*req)++; - if (*req == 0 || *req == 0xffffffff) - *req = 1; - return mb; - } - return NULL; -} - -long cx18_mb_ack(struct cx18 *cx, const struct cx18_mailbox *mb) -{ - const struct cx18_api_info *info = find_api_info(mb->cmd); - struct cx18_mailbox *ack_mb; - u32 ack_irq; - u8 rpu = CPU; - - if (info == NULL && mb->cmd) { - CX18_WARN("Cannot ack unknown command %x\n", mb->cmd); - return -EINVAL; - } - if (info) - rpu = info->rpu; - - switch (rpu) { - case HPU: - ack_irq = IRQ_EPU_TO_HPU_ACK; - ack_mb = &cx->scb->hpu2epu_mb; - break; - case APU: - ack_irq = IRQ_EPU_TO_APU_ACK; - ack_mb = &cx->scb->apu2epu_mb; - break; - case CPU: - ack_irq = IRQ_EPU_TO_CPU_ACK; - ack_mb = &cx->scb->cpu2epu_mb; - break; - default: - CX18_WARN("Unknown RPU for command %x\n", mb->cmd); - return -EINVAL; - } - - setup_page(SCB_OFFSET); - write_sync(mb->request, &ack_mb->ack); - write_reg(ack_irq, SW2_INT_SET); - return 0; -} - - -static int cx18_api_call(struct cx18 *cx, u32 cmd, int args, u32 data[]) -{ - const struct cx18_api_info *info = find_api_info(cmd); - u32 state = 0, irq = 0, req, oldreq, err; - struct cx18_mailbox *mb; - wait_queue_head_t *waitq; - int timeout = 100; - int cnt = 0; - int sig = 0; - int i; - - if (info == NULL) { - CX18_WARN("unknown cmd %x\n", cmd); - return -EINVAL; - } - - if (cmd == CX18_CPU_DE_SET_MDL) - CX18_DEBUG_HI_API("%s\n", info->name); - else - CX18_DEBUG_API("%s\n", info->name); - setup_page(SCB_OFFSET); - mb = cx18_mb_is_complete(cx, info->rpu, &state, &irq, &req); - - if (mb == NULL) { - CX18_ERR("mb %s busy\n", info->name); - return -EBUSY; - } - - oldreq = req - 1; - writel(cmd, &mb->cmd); - for (i = 0; i < args; i++) - writel(data[i], &mb->args[i]); - writel(0, &mb->error); - writel(req, &mb->request); - - switch (info->rpu) { - case APU: waitq = &cx->mb_apu_waitq; break; - case CPU: waitq = &cx->mb_cpu_waitq; break; - case EPU: waitq = &cx->mb_epu_waitq; break; - case HPU: waitq = &cx->mb_hpu_waitq; break; - default: return -EINVAL; - } - if (info->flags & API_FAST) - timeout /= 2; - write_reg(irq, SW1_INT_SET); - - while (!sig && readl(&mb->ack) != readl(&mb->request) && cnt < 660) { - if (cnt > 200 && !in_atomic()) - sig = cx18_msleep_timeout(10, 1); - cnt++; - } - if (sig) - return -EINTR; - if (cnt == 660) { - writel(oldreq, &mb->request); - CX18_ERR("mb %s failed\n", info->name); - return -EINVAL; - } - for (i = 0; i < MAX_MB_ARGUMENTS; i++) - data[i] = readl(&mb->args[i]); - err = readl(&mb->error); - if (!in_atomic() && (info->flags & API_SLOW)) - cx18_msleep_timeout(300, 0); - if (err) - CX18_DEBUG_API("mailbox error %08x for command %s\n", err, - info->name); - return err ? -EIO : 0; -} - -int cx18_api(struct cx18 *cx, u32 cmd, int args, u32 data[]) -{ - int res = cx18_api_call(cx, cmd, args, data); - - /* Allow a single retry, probably already too late though. - If there is no free mailbox then that is usually an indication - of a more serious problem. */ - return (res == -EBUSY) ? cx18_api_call(cx, cmd, args, data) : res; -} - -static int cx18_set_filter_param(struct cx18_stream *s) -{ - struct cx18 *cx = s->cx; - u32 mode; - int ret; - - mode = (cx->filter_mode & 1) ? 2 : (cx->spatial_strength ? 1 : 0); - ret = cx18_vapi(cx, CX18_CPU_SET_FILTER_PARAM, 4, - s->handle, 1, mode, cx->spatial_strength); - mode = (cx->filter_mode & 2) ? 2 : (cx->temporal_strength ? 1 : 0); - ret = ret ? ret : cx18_vapi(cx, CX18_CPU_SET_FILTER_PARAM, 4, - s->handle, 0, mode, cx->temporal_strength); - ret = ret ? ret : cx18_vapi(cx, CX18_CPU_SET_FILTER_PARAM, 4, - s->handle, 2, cx->filter_mode >> 2, 0); - return ret; -} - -int cx18_api_func(void *priv, u32 cmd, int in, int out, - u32 data[CX2341X_MBOX_MAX_DATA]) -{ - struct cx18 *cx = priv; - struct cx18_stream *s = &cx->streams[CX18_ENC_STREAM_TYPE_MPG]; - - switch (cmd) { - case CX2341X_ENC_SET_OUTPUT_PORT: - return 0; - case CX2341X_ENC_SET_FRAME_RATE: - return cx18_vapi(cx, CX18_CPU_SET_VIDEO_IN, 6, - s->handle, 0, 0, 0, 0, data[0]); - case CX2341X_ENC_SET_FRAME_SIZE: - return cx18_vapi(cx, CX18_CPU_SET_VIDEO_RESOLUTION, 3, - s->handle, data[1], data[0]); - case CX2341X_ENC_SET_STREAM_TYPE: - return cx18_vapi(cx, CX18_CPU_SET_STREAM_OUTPUT_TYPE, 2, - s->handle, data[0]); - case CX2341X_ENC_SET_ASPECT_RATIO: - return cx18_vapi(cx, CX18_CPU_SET_ASPECT_RATIO, 2, - s->handle, data[0]); - - case CX2341X_ENC_SET_GOP_PROPERTIES: - return cx18_vapi(cx, CX18_CPU_SET_GOP_STRUCTURE, 3, - s->handle, data[0], data[1]); - case CX2341X_ENC_SET_GOP_CLOSURE: - return 0; - case CX2341X_ENC_SET_AUDIO_PROPERTIES: - return cx18_vapi(cx, CX18_CPU_SET_AUDIO_PARAMETERS, 2, - s->handle, data[0]); - case CX2341X_ENC_MUTE_AUDIO: - return cx18_vapi(cx, CX18_CPU_SET_AUDIO_MUTE, 2, - s->handle, data[0]); - case CX2341X_ENC_SET_BIT_RATE: - return cx18_vapi(cx, CX18_CPU_SET_VIDEO_RATE, 5, - s->handle, data[0], data[1], data[2], data[3]); - case CX2341X_ENC_MUTE_VIDEO: - return cx18_vapi(cx, CX18_CPU_SET_VIDEO_MUTE, 2, - s->handle, data[0]); - case CX2341X_ENC_SET_FRAME_DROP_RATE: - return cx18_vapi(cx, CX18_CPU_SET_SKIP_INPUT_FRAME, 2, - s->handle, data[0]); - case CX2341X_ENC_MISC: - return cx18_vapi(cx, CX18_CPU_SET_MISC_PARAMETERS, 4, - s->handle, data[0], data[1], data[2]); - case CX2341X_ENC_SET_DNR_FILTER_MODE: - cx->filter_mode = (data[0] & 3) | (data[1] << 2); - return cx18_set_filter_param(s); - case CX2341X_ENC_SET_DNR_FILTER_PROPS: - cx->spatial_strength = data[0]; - cx->temporal_strength = data[1]; - return cx18_set_filter_param(s); - case CX2341X_ENC_SET_SPATIAL_FILTER_TYPE: - return cx18_vapi(cx, CX18_CPU_SET_SPATIAL_FILTER_TYPE, 3, - s->handle, data[0], data[1]); - case CX2341X_ENC_SET_CORING_LEVELS: - return cx18_vapi(cx, CX18_CPU_SET_MEDIAN_CORING, 5, - s->handle, data[0], data[1], data[2], data[3]); - } - CX18_WARN("Unknown cmd %x\n", cmd); - return 0; -} - -int cx18_vapi_result(struct cx18 *cx, u32 data[MAX_MB_ARGUMENTS], - u32 cmd, int args, ...) -{ - va_list ap; - int i; - - va_start(ap, args); - for (i = 0; i < args; i++) - data[i] = va_arg(ap, u32); - va_end(ap); - return cx18_api(cx, cmd, args, data); -} - -int cx18_vapi(struct cx18 *cx, u32 cmd, int args, ...) -{ - u32 data[MAX_MB_ARGUMENTS]; - va_list ap; - int i; - - if (cx == NULL) { - CX18_ERR("cx == NULL (cmd=%x)\n", cmd); - return 0; - } - if (args > MAX_MB_ARGUMENTS) { - CX18_ERR("args too big (cmd=%x)\n", cmd); - args = MAX_MB_ARGUMENTS; - } - va_start(ap, args); - for (i = 0; i < args; i++) - data[i] = va_arg(ap, u32); - va_end(ap); - return cx18_api(cx, cmd, args, data); -} diff --git a/trunk/drivers/media/video/cx18/cx18-mailbox.h b/trunk/drivers/media/video/cx18/cx18-mailbox.h deleted file mode 100644 index d995641536b3..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-mailbox.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * cx18 mailbox functions - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -#ifndef _CX18_MAILBOX_H_ -#define _CX18_MAILBOX_H_ - -/* mailbox max args */ -#define MAX_MB_ARGUMENTS 6 -/* compatibility, should be same as the define in cx2341x.h */ -#define CX2341X_MBOX_MAX_DATA 16 - -#define MB_RESERVED_HANDLE_0 0 -#define MB_RESERVED_HANDLE_1 0xFFFFFFFF - -struct cx18; - -/* The cx18_mailbox struct is the mailbox structure which is used for passing - messages between processors */ -struct cx18_mailbox { - /* The sender sets a handle in 'request' after he fills the command. The - 'request' should be different than 'ack'. The sender, also, generates - an interrupt on XPU2YPU_irq where XPU is the sender and YPU is the - receiver. */ - u32 request; - /* The receiver detects a new command when 'req' is different than 'ack'. - He sets 'ack' to the same value as 'req' to clear the command. He, also, - generates an interrupt on YPU2XPU_irq where XPU is the sender and YPU - is the receiver. */ - u32 ack; - u32 reserved[6]; - /* 'cmd' identifies the command. The list of these commands are in - cx23418.h */ - u32 cmd; - /* Each command can have up to 6 arguments */ - u32 args[MAX_MB_ARGUMENTS]; - /* The return code can be one of the codes in the file cx23418.h. If the - command is completed successfuly, the error will be ERR_SYS_SUCCESS. - If it is pending, the code is ERR_SYS_PENDING. If it failed, the error - code would indicate the task from which the error originated and will - be one of the errors in cx23418.h. In that case, the following - applies ((error & 0xff) != 0). - If the command is pending, the return will be passed in a MB from the - receiver to the sender. 'req' will be returned in args[0] */ - u32 error; -}; - -int cx18_api(struct cx18 *cx, u32 cmd, int args, u32 data[]); -int cx18_vapi_result(struct cx18 *cx, u32 data[MAX_MB_ARGUMENTS], u32 cmd, - int args, ...); -int cx18_vapi(struct cx18 *cx, u32 cmd, int args, ...); -int cx18_api_func(void *priv, u32 cmd, int in, int out, - u32 data[CX2341X_MBOX_MAX_DATA]); -long cx18_mb_ack(struct cx18 *cx, const struct cx18_mailbox *mb); - -#endif diff --git a/trunk/drivers/media/video/cx18/cx18-queue.c b/trunk/drivers/media/video/cx18/cx18-queue.c deleted file mode 100644 index 65af1bb507ca..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-queue.c +++ /dev/null @@ -1,282 +0,0 @@ -/* - * cx18 buffer queues - * - * Derived from ivtv-queue.c - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -#include "cx18-driver.h" -#include "cx18-streams.h" -#include "cx18-queue.h" -#include "cx18-scb.h" - -int cx18_buf_copy_from_user(struct cx18_stream *s, struct cx18_buffer *buf, - const char __user *src, int copybytes) -{ - if (s->buf_size - buf->bytesused < copybytes) - copybytes = s->buf_size - buf->bytesused; - if (copy_from_user(buf->buf + buf->bytesused, src, copybytes)) - return -EFAULT; - buf->bytesused += copybytes; - return copybytes; -} - -void cx18_buf_swap(struct cx18_buffer *buf) -{ - int i; - - for (i = 0; i < buf->bytesused; i += 4) - swab32s((u32 *)(buf->buf + i)); -} - -void cx18_queue_init(struct cx18_queue *q) -{ - INIT_LIST_HEAD(&q->list); - q->buffers = 0; - q->length = 0; - q->bytesused = 0; -} - -void cx18_enqueue(struct cx18_stream *s, struct cx18_buffer *buf, - struct cx18_queue *q) -{ - unsigned long flags = 0; - - /* clear the buffer if it is going to be enqueued to the free queue */ - if (q == &s->q_free) { - buf->bytesused = 0; - buf->readpos = 0; - buf->b_flags = 0; - } - spin_lock_irqsave(&s->qlock, flags); - list_add_tail(&buf->list, &q->list); - q->buffers++; - q->length += s->buf_size; - q->bytesused += buf->bytesused - buf->readpos; - spin_unlock_irqrestore(&s->qlock, flags); -} - -struct cx18_buffer *cx18_dequeue(struct cx18_stream *s, struct cx18_queue *q) -{ - struct cx18_buffer *buf = NULL; - unsigned long flags = 0; - - spin_lock_irqsave(&s->qlock, flags); - if (!list_empty(&q->list)) { - buf = list_entry(q->list.next, struct cx18_buffer, list); - list_del_init(q->list.next); - q->buffers--; - q->length -= s->buf_size; - q->bytesused -= buf->bytesused - buf->readpos; - } - spin_unlock_irqrestore(&s->qlock, flags); - return buf; -} - -struct cx18_buffer *cx18_queue_find_buf(struct cx18_stream *s, u32 id, - u32 bytesused) -{ - struct cx18 *cx = s->cx; - struct list_head *p; - - list_for_each(p, &s->q_free.list) { - struct cx18_buffer *buf = - list_entry(p, struct cx18_buffer, list); - - if (buf->id != id) - continue; - buf->bytesused = bytesused; - /* the transport buffers are handled differently, - so there is no need to move them to the full queue */ - if (s->type == CX18_ENC_STREAM_TYPE_TS) - return buf; - s->q_free.buffers--; - s->q_free.length -= s->buf_size; - s->q_full.buffers++; - s->q_full.length += s->buf_size; - s->q_full.bytesused += buf->bytesused; - list_move_tail(&buf->list, &s->q_full.list); - return buf; - } - CX18_ERR("Cannot find buffer %d for stream %s\n", id, s->name); - return NULL; -} - -static void cx18_queue_move_buf(struct cx18_stream *s, struct cx18_queue *from, - struct cx18_queue *to, int clear, int full) -{ - struct cx18_buffer *buf = - list_entry(from->list.next, struct cx18_buffer, list); - - list_move_tail(from->list.next, &to->list); - from->buffers--; - from->length -= s->buf_size; - from->bytesused -= buf->bytesused - buf->readpos; - /* special handling for q_free */ - if (clear) - buf->bytesused = buf->readpos = buf->b_flags = 0; - else if (full) { - /* special handling for stolen buffers, assume - all bytes are used. */ - buf->bytesused = s->buf_size; - buf->readpos = buf->b_flags = 0; - } - to->buffers++; - to->length += s->buf_size; - to->bytesused += buf->bytesused - buf->readpos; -} - -/* Move 'needed_bytes' worth of buffers from queue 'from' into queue 'to'. - If 'needed_bytes' == 0, then move all buffers from 'from' into 'to'. - If 'steal' != NULL, then buffers may also taken from that queue if - needed. - - The buffer is automatically cleared if it goes to the free queue. It is - also cleared if buffers need to be taken from the 'steal' queue and - the 'from' queue is the free queue. - - When 'from' is q_free, then needed_bytes is compared to the total - available buffer length, otherwise needed_bytes is compared to the - bytesused value. For the 'steal' queue the total available buffer - length is always used. - - -ENOMEM is returned if the buffers could not be obtained, 0 if all - buffers where obtained from the 'from' list and if non-zero then - the number of stolen buffers is returned. */ -int cx18_queue_move(struct cx18_stream *s, struct cx18_queue *from, - struct cx18_queue *steal, struct cx18_queue *to, int needed_bytes) -{ - unsigned long flags; - int rc = 0; - int from_free = from == &s->q_free; - int to_free = to == &s->q_free; - int bytes_available; - - spin_lock_irqsave(&s->qlock, flags); - if (needed_bytes == 0) { - from_free = 1; - needed_bytes = from->length; - } - - bytes_available = from_free ? from->length : from->bytesused; - bytes_available += steal ? steal->length : 0; - - if (bytes_available < needed_bytes) { - spin_unlock_irqrestore(&s->qlock, flags); - return -ENOMEM; - } - if (from_free) { - u32 old_length = to->length; - - while (to->length - old_length < needed_bytes) { - if (list_empty(&from->list)) - from = steal; - if (from == steal) - rc++; /* keep track of 'stolen' buffers */ - cx18_queue_move_buf(s, from, to, 1, 0); - } - } else { - u32 old_bytesused = to->bytesused; - - while (to->bytesused - old_bytesused < needed_bytes) { - if (list_empty(&from->list)) - from = steal; - if (from == steal) - rc++; /* keep track of 'stolen' buffers */ - cx18_queue_move_buf(s, from, to, to_free, rc); - } - } - spin_unlock_irqrestore(&s->qlock, flags); - return rc; -} - -void cx18_flush_queues(struct cx18_stream *s) -{ - cx18_queue_move(s, &s->q_io, NULL, &s->q_free, 0); - cx18_queue_move(s, &s->q_full, NULL, &s->q_free, 0); -} - -int cx18_stream_alloc(struct cx18_stream *s) -{ - struct cx18 *cx = s->cx; - int i; - - if (s->buffers == 0) - return 0; - - CX18_DEBUG_INFO("Allocate %s stream: %d x %d buffers (%dkB total)\n", - s->name, s->buffers, s->buf_size, - s->buffers * s->buf_size / 1024); - - if (((char *)&cx->scb->cpu_mdl[cx->mdl_offset + s->buffers] - - (char *)cx->scb) > SCB_RESERVED_SIZE) { - unsigned bufsz = (((char *)cx->scb) + SCB_RESERVED_SIZE - - ((char *)cx->scb->cpu_mdl)); - - CX18_ERR("Too many buffers, cannot fit in SCB area\n"); - CX18_ERR("Max buffers = %zd\n", - bufsz / sizeof(struct cx18_mdl)); - return -ENOMEM; - } - - s->mdl_offset = cx->mdl_offset; - - /* allocate stream buffers. Initially all buffers are in q_free. */ - for (i = 0; i < s->buffers; i++) { - struct cx18_buffer *buf = - kzalloc(sizeof(struct cx18_buffer), GFP_KERNEL); - - if (buf == NULL) - break; - buf->buf = kmalloc(s->buf_size, GFP_KERNEL); - if (buf->buf == NULL) { - kfree(buf); - break; - } - buf->id = cx->buffer_id++; - INIT_LIST_HEAD(&buf->list); - buf->dma_handle = pci_map_single(s->cx->dev, - buf->buf, s->buf_size, s->dma); - cx18_buf_sync_for_cpu(s, buf); - cx18_enqueue(s, buf, &s->q_free); - } - if (i == s->buffers) { - cx->mdl_offset += s->buffers; - return 0; - } - CX18_ERR("Couldn't allocate buffers for %s stream\n", s->name); - cx18_stream_free(s); - return -ENOMEM; -} - -void cx18_stream_free(struct cx18_stream *s) -{ - struct cx18_buffer *buf; - - /* move all buffers to q_free */ - cx18_flush_queues(s); - - /* empty q_free */ - while ((buf = cx18_dequeue(s, &s->q_free))) { - pci_unmap_single(s->cx->dev, buf->dma_handle, - s->buf_size, s->dma); - kfree(buf->buf); - kfree(buf); - } -} diff --git a/trunk/drivers/media/video/cx18/cx18-queue.h b/trunk/drivers/media/video/cx18/cx18-queue.h deleted file mode 100644 index f86c8a6fa6e7..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-queue.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * cx18 buffer queues - * - * Derived from ivtv-queue.h - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -#define CX18_DMA_UNMAPPED ((u32) -1) - -/* cx18_buffer utility functions */ - -static inline void cx18_buf_sync_for_cpu(struct cx18_stream *s, - struct cx18_buffer *buf) -{ - pci_dma_sync_single_for_cpu(s->cx->dev, buf->dma_handle, - s->buf_size, s->dma); -} - -static inline void cx18_buf_sync_for_device(struct cx18_stream *s, - struct cx18_buffer *buf) -{ - pci_dma_sync_single_for_device(s->cx->dev, buf->dma_handle, - s->buf_size, s->dma); -} - -int cx18_buf_copy_from_user(struct cx18_stream *s, struct cx18_buffer *buf, - const char __user *src, int copybytes); -void cx18_buf_swap(struct cx18_buffer *buf); - -/* cx18_queue utility functions */ -void cx18_queue_init(struct cx18_queue *q); -void cx18_enqueue(struct cx18_stream *s, struct cx18_buffer *buf, - struct cx18_queue *q); -struct cx18_buffer *cx18_dequeue(struct cx18_stream *s, struct cx18_queue *q); -int cx18_queue_move(struct cx18_stream *s, struct cx18_queue *from, - struct cx18_queue *steal, struct cx18_queue *to, int needed_bytes); -struct cx18_buffer *cx18_queue_find_buf(struct cx18_stream *s, u32 id, - u32 bytesused); -void cx18_flush_queues(struct cx18_stream *s); - -/* cx18_stream utility functions */ -int cx18_stream_alloc(struct cx18_stream *s); -void cx18_stream_free(struct cx18_stream *s); diff --git a/trunk/drivers/media/video/cx18/cx18-scb.c b/trunk/drivers/media/video/cx18/cx18-scb.c deleted file mode 100644 index 30bc803e30da..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-scb.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * cx18 System Control Block initialization - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -#include "cx18-driver.h" -#include "cx18-scb.h" - -void cx18_init_scb(struct cx18 *cx) -{ - setup_page(SCB_OFFSET); - memset_io(cx->scb, 0, 0x10000); - - writel(IRQ_APU_TO_CPU, &cx->scb->apu2cpu_irq); - writel(IRQ_CPU_TO_APU_ACK, &cx->scb->cpu2apu_irq_ack); - writel(IRQ_HPU_TO_CPU, &cx->scb->hpu2cpu_irq); - writel(IRQ_CPU_TO_HPU_ACK, &cx->scb->cpu2hpu_irq_ack); - writel(IRQ_PPU_TO_CPU, &cx->scb->ppu2cpu_irq); - writel(IRQ_CPU_TO_PPU_ACK, &cx->scb->cpu2ppu_irq_ack); - writel(IRQ_EPU_TO_CPU, &cx->scb->epu2cpu_irq); - writel(IRQ_CPU_TO_EPU_ACK, &cx->scb->cpu2epu_irq_ack); - - writel(IRQ_CPU_TO_APU, &cx->scb->cpu2apu_irq); - writel(IRQ_APU_TO_CPU_ACK, &cx->scb->apu2cpu_irq_ack); - writel(IRQ_HPU_TO_APU, &cx->scb->hpu2apu_irq); - writel(IRQ_APU_TO_HPU_ACK, &cx->scb->apu2hpu_irq_ack); - writel(IRQ_PPU_TO_APU, &cx->scb->ppu2apu_irq); - writel(IRQ_APU_TO_PPU_ACK, &cx->scb->apu2ppu_irq_ack); - writel(IRQ_EPU_TO_APU, &cx->scb->epu2apu_irq); - writel(IRQ_APU_TO_EPU_ACK, &cx->scb->apu2epu_irq_ack); - - writel(IRQ_CPU_TO_HPU, &cx->scb->cpu2hpu_irq); - writel(IRQ_HPU_TO_CPU_ACK, &cx->scb->hpu2cpu_irq_ack); - writel(IRQ_APU_TO_HPU, &cx->scb->apu2hpu_irq); - writel(IRQ_HPU_TO_APU_ACK, &cx->scb->hpu2apu_irq_ack); - writel(IRQ_PPU_TO_HPU, &cx->scb->ppu2hpu_irq); - writel(IRQ_HPU_TO_PPU_ACK, &cx->scb->hpu2ppu_irq_ack); - writel(IRQ_EPU_TO_HPU, &cx->scb->epu2hpu_irq); - writel(IRQ_HPU_TO_EPU_ACK, &cx->scb->hpu2epu_irq_ack); - - writel(IRQ_CPU_TO_PPU, &cx->scb->cpu2ppu_irq); - writel(IRQ_PPU_TO_CPU_ACK, &cx->scb->ppu2cpu_irq_ack); - writel(IRQ_APU_TO_PPU, &cx->scb->apu2ppu_irq); - writel(IRQ_PPU_TO_APU_ACK, &cx->scb->ppu2apu_irq_ack); - writel(IRQ_HPU_TO_PPU, &cx->scb->hpu2ppu_irq); - writel(IRQ_PPU_TO_HPU_ACK, &cx->scb->ppu2hpu_irq_ack); - writel(IRQ_EPU_TO_PPU, &cx->scb->epu2ppu_irq); - writel(IRQ_PPU_TO_EPU_ACK, &cx->scb->ppu2epu_irq_ack); - - writel(IRQ_CPU_TO_EPU, &cx->scb->cpu2epu_irq); - writel(IRQ_EPU_TO_CPU_ACK, &cx->scb->epu2cpu_irq_ack); - writel(IRQ_APU_TO_EPU, &cx->scb->apu2epu_irq); - writel(IRQ_EPU_TO_APU_ACK, &cx->scb->epu2apu_irq_ack); - writel(IRQ_HPU_TO_EPU, &cx->scb->hpu2epu_irq); - writel(IRQ_EPU_TO_HPU_ACK, &cx->scb->epu2hpu_irq_ack); - writel(IRQ_PPU_TO_EPU, &cx->scb->ppu2epu_irq); - writel(IRQ_EPU_TO_PPU_ACK, &cx->scb->epu2ppu_irq_ack); - - writel(SCB_OFFSET + offsetof(struct cx18_scb, apu2cpu_mb), - &cx->scb->apu2cpu_mb_offset); - writel(SCB_OFFSET + offsetof(struct cx18_scb, hpu2cpu_mb), - &cx->scb->hpu2cpu_mb_offset); - writel(SCB_OFFSET + offsetof(struct cx18_scb, ppu2cpu_mb), - &cx->scb->ppu2cpu_mb_offset); - writel(SCB_OFFSET + offsetof(struct cx18_scb, epu2cpu_mb), - &cx->scb->epu2cpu_mb_offset); - writel(SCB_OFFSET + offsetof(struct cx18_scb, cpu2apu_mb), - &cx->scb->cpu2apu_mb_offset); - writel(SCB_OFFSET + offsetof(struct cx18_scb, hpu2apu_mb), - &cx->scb->hpu2apu_mb_offset); - writel(SCB_OFFSET + offsetof(struct cx18_scb, ppu2apu_mb), - &cx->scb->ppu2apu_mb_offset); - writel(SCB_OFFSET + offsetof(struct cx18_scb, epu2apu_mb), - &cx->scb->epu2apu_mb_offset); - writel(SCB_OFFSET + offsetof(struct cx18_scb, cpu2hpu_mb), - &cx->scb->cpu2hpu_mb_offset); - writel(SCB_OFFSET + offsetof(struct cx18_scb, apu2hpu_mb), - &cx->scb->apu2hpu_mb_offset); - writel(SCB_OFFSET + offsetof(struct cx18_scb, ppu2hpu_mb), - &cx->scb->ppu2hpu_mb_offset); - writel(SCB_OFFSET + offsetof(struct cx18_scb, epu2hpu_mb), - &cx->scb->epu2hpu_mb_offset); - writel(SCB_OFFSET + offsetof(struct cx18_scb, cpu2ppu_mb), - &cx->scb->cpu2ppu_mb_offset); - writel(SCB_OFFSET + offsetof(struct cx18_scb, apu2ppu_mb), - &cx->scb->apu2ppu_mb_offset); - writel(SCB_OFFSET + offsetof(struct cx18_scb, hpu2ppu_mb), - &cx->scb->hpu2ppu_mb_offset); - writel(SCB_OFFSET + offsetof(struct cx18_scb, epu2ppu_mb), - &cx->scb->epu2ppu_mb_offset); - writel(SCB_OFFSET + offsetof(struct cx18_scb, cpu2epu_mb), - &cx->scb->cpu2epu_mb_offset); - writel(SCB_OFFSET + offsetof(struct cx18_scb, apu2epu_mb), - &cx->scb->apu2epu_mb_offset); - writel(SCB_OFFSET + offsetof(struct cx18_scb, hpu2epu_mb), - &cx->scb->hpu2epu_mb_offset); - writel(SCB_OFFSET + offsetof(struct cx18_scb, ppu2epu_mb), - &cx->scb->ppu2epu_mb_offset); - - writel(SCB_OFFSET + offsetof(struct cx18_scb, cpu_state), - &cx->scb->ipc_offset); - - writel(1, &cx->scb->hpu_state); - writel(1, &cx->scb->epu_state); -} diff --git a/trunk/drivers/media/video/cx18/cx18-scb.h b/trunk/drivers/media/video/cx18/cx18-scb.h deleted file mode 100644 index 86b4cb15d163..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-scb.h +++ /dev/null @@ -1,285 +0,0 @@ -/* - * cx18 System Control Block initialization - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -#ifndef CX18_SCB_H -#define CX18_SCB_H - -#include "cx18-mailbox.h" - -/* NOTE: All ACK interrupts are in the SW2 register. All non-ACK interrupts - are in the SW1 register. */ - -#define IRQ_APU_TO_CPU 0x00000001 -#define IRQ_CPU_TO_APU_ACK 0x00000001 -#define IRQ_HPU_TO_CPU 0x00000002 -#define IRQ_CPU_TO_HPU_ACK 0x00000002 -#define IRQ_PPU_TO_CPU 0x00000004 -#define IRQ_CPU_TO_PPU_ACK 0x00000004 -#define IRQ_EPU_TO_CPU 0x00000008 -#define IRQ_CPU_TO_EPU_ACK 0x00000008 - -#define IRQ_CPU_TO_APU 0x00000010 -#define IRQ_APU_TO_CPU_ACK 0x00000010 -#define IRQ_HPU_TO_APU 0x00000020 -#define IRQ_APU_TO_HPU_ACK 0x00000020 -#define IRQ_PPU_TO_APU 0x00000040 -#define IRQ_APU_TO_PPU_ACK 0x00000040 -#define IRQ_EPU_TO_APU 0x00000080 -#define IRQ_APU_TO_EPU_ACK 0x00000080 - -#define IRQ_CPU_TO_HPU 0x00000100 -#define IRQ_HPU_TO_CPU_ACK 0x00000100 -#define IRQ_APU_TO_HPU 0x00000200 -#define IRQ_HPU_TO_APU_ACK 0x00000200 -#define IRQ_PPU_TO_HPU 0x00000400 -#define IRQ_HPU_TO_PPU_ACK 0x00000400 -#define IRQ_EPU_TO_HPU 0x00000800 -#define IRQ_HPU_TO_EPU_ACK 0x00000800 - -#define IRQ_CPU_TO_PPU 0x00001000 -#define IRQ_PPU_TO_CPU_ACK 0x00001000 -#define IRQ_APU_TO_PPU 0x00002000 -#define IRQ_PPU_TO_APU_ACK 0x00002000 -#define IRQ_HPU_TO_PPU 0x00004000 -#define IRQ_PPU_TO_HPU_ACK 0x00004000 -#define IRQ_EPU_TO_PPU 0x00008000 -#define IRQ_PPU_TO_EPU_ACK 0x00008000 - -#define IRQ_CPU_TO_EPU 0x00010000 -#define IRQ_EPU_TO_CPU_ACK 0x00010000 -#define IRQ_APU_TO_EPU 0x00020000 -#define IRQ_EPU_TO_APU_ACK 0x00020000 -#define IRQ_HPU_TO_EPU 0x00040000 -#define IRQ_EPU_TO_HPU_ACK 0x00040000 -#define IRQ_PPU_TO_EPU 0x00080000 -#define IRQ_EPU_TO_PPU_ACK 0x00080000 - -#define SCB_OFFSET 0xDC0000 - -/* If Firmware uses fixed memory map, it shall not allocate the area - between SCB_OFFSET and SCB_OFFSET+SCB_RESERVED_SIZE-1 inclusive */ -#define SCB_RESERVED_SIZE 0x10000 - - -/* This structure is used by EPU to provide memory descriptors in its memory */ -struct cx18_mdl { - u32 paddr; /* Physical address of a buffer segment */ - u32 length; /* Length of the buffer segment */ -}; - -/* This structure is used by CPU to provide completed buffers information */ -struct cx18_mdl_ack { - u32 id; /* ID of a completed MDL */ - u32 data_used; /* Total data filled in the MDL for buffer 'id' */ -}; - -struct cx18_scb { - /* These fields form the System Control Block which is used at boot time - for localizing the IPC data as well as the code positions for all - processors. The offsets are from the start of this struct. */ - - /* Offset where to find the Inter-Processor Communication data */ - u32 ipc_offset; - u32 reserved01[7]; - /* Offset where to find the start of the CPU code */ - u32 cpu_code_offset; - u32 reserved02[3]; - /* Offset where to find the start of the APU code */ - u32 apu_code_offset; - u32 reserved03[3]; - /* Offset where to find the start of the HPU code */ - u32 hpu_code_offset; - u32 reserved04[3]; - /* Offset where to find the start of the PPU code */ - u32 ppu_code_offset; - u32 reserved05[3]; - - /* These fields form Inter-Processor Communication data which is used - by all processors to locate the information needed for communicating - with other processors */ - - /* Fields for CPU: */ - - /* bit 0: 1/0 processor ready/not ready. Set other bits to 0. */ - u32 cpu_state; - u32 reserved1[7]; - /* Offset to the mailbox used for sending commands from APU to CPU */ - u32 apu2cpu_mb_offset; - /* Value to write to register SW1 register set (0xC7003100) after the - command is ready */ - u32 apu2cpu_irq; - /* Value to write to register SW2 register set (0xC7003140) after the - command is cleared */ - u32 apu2cpu_irq_ack; - u32 reserved2[13]; - - u32 hpu2cpu_mb_offset; - u32 hpu2cpu_irq; - u32 hpu2cpu_irq_ack; - u32 reserved3[13]; - - u32 ppu2cpu_mb_offset; - u32 ppu2cpu_irq; - u32 ppu2cpu_irq_ack; - u32 reserved4[13]; - - u32 epu2cpu_mb_offset; - u32 epu2cpu_irq; - u32 epu2cpu_irq_ack; - u32 reserved5[13]; - u32 reserved6[8]; - - /* Fields for APU: */ - - u32 apu_state; - u32 reserved11[7]; - u32 cpu2apu_mb_offset; - u32 cpu2apu_irq; - u32 cpu2apu_irq_ack; - u32 reserved12[13]; - - u32 hpu2apu_mb_offset; - u32 hpu2apu_irq; - u32 hpu2apu_irq_ack; - u32 reserved13[13]; - - u32 ppu2apu_mb_offset; - u32 ppu2apu_irq; - u32 ppu2apu_irq_ack; - u32 reserved14[13]; - - u32 epu2apu_mb_offset; - u32 epu2apu_irq; - u32 epu2apu_irq_ack; - u32 reserved15[13]; - u32 reserved16[8]; - - /* Fields for HPU: */ - - u32 hpu_state; - u32 reserved21[7]; - u32 cpu2hpu_mb_offset; - u32 cpu2hpu_irq; - u32 cpu2hpu_irq_ack; - u32 reserved22[13]; - - u32 apu2hpu_mb_offset; - u32 apu2hpu_irq; - u32 apu2hpu_irq_ack; - u32 reserved23[13]; - - u32 ppu2hpu_mb_offset; - u32 ppu2hpu_irq; - u32 ppu2hpu_irq_ack; - u32 reserved24[13]; - - u32 epu2hpu_mb_offset; - u32 epu2hpu_irq; - u32 epu2hpu_irq_ack; - u32 reserved25[13]; - u32 reserved26[8]; - - /* Fields for PPU: */ - - u32 ppu_state; - u32 reserved31[7]; - u32 cpu2ppu_mb_offset; - u32 cpu2ppu_irq; - u32 cpu2ppu_irq_ack; - u32 reserved32[13]; - - u32 apu2ppu_mb_offset; - u32 apu2ppu_irq; - u32 apu2ppu_irq_ack; - u32 reserved33[13]; - - u32 hpu2ppu_mb_offset; - u32 hpu2ppu_irq; - u32 hpu2ppu_irq_ack; - u32 reserved34[13]; - - u32 epu2ppu_mb_offset; - u32 epu2ppu_irq; - u32 epu2ppu_irq_ack; - u32 reserved35[13]; - u32 reserved36[8]; - - /* Fields for EPU: */ - - u32 epu_state; - u32 reserved41[7]; - u32 cpu2epu_mb_offset; - u32 cpu2epu_irq; - u32 cpu2epu_irq_ack; - u32 reserved42[13]; - - u32 apu2epu_mb_offset; - u32 apu2epu_irq; - u32 apu2epu_irq_ack; - u32 reserved43[13]; - - u32 hpu2epu_mb_offset; - u32 hpu2epu_irq; - u32 hpu2epu_irq_ack; - u32 reserved44[13]; - - u32 ppu2epu_mb_offset; - u32 ppu2epu_irq; - u32 ppu2epu_irq_ack; - u32 reserved45[13]; - u32 reserved46[8]; - - u32 semaphores[8]; /* Semaphores */ - - u32 reserved50[32]; /* Reserved for future use */ - - struct cx18_mailbox apu2cpu_mb; - struct cx18_mailbox hpu2cpu_mb; - struct cx18_mailbox ppu2cpu_mb; - struct cx18_mailbox epu2cpu_mb; - - struct cx18_mailbox cpu2apu_mb; - struct cx18_mailbox hpu2apu_mb; - struct cx18_mailbox ppu2apu_mb; - struct cx18_mailbox epu2apu_mb; - - struct cx18_mailbox cpu2hpu_mb; - struct cx18_mailbox apu2hpu_mb; - struct cx18_mailbox ppu2hpu_mb; - struct cx18_mailbox epu2hpu_mb; - - struct cx18_mailbox cpu2ppu_mb; - struct cx18_mailbox apu2ppu_mb; - struct cx18_mailbox hpu2ppu_mb; - struct cx18_mailbox epu2ppu_mb; - - struct cx18_mailbox cpu2epu_mb; - struct cx18_mailbox apu2epu_mb; - struct cx18_mailbox hpu2epu_mb; - struct cx18_mailbox ppu2epu_mb; - - struct cx18_mdl_ack cpu_mdl_ack[CX18_MAX_STREAMS][2]; - struct cx18_mdl cpu_mdl[1]; -}; - -void cx18_init_scb(struct cx18 *cx); - -#endif diff --git a/trunk/drivers/media/video/cx18/cx18-streams.c b/trunk/drivers/media/video/cx18/cx18-streams.c deleted file mode 100644 index afb141b2027a..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-streams.c +++ /dev/null @@ -1,566 +0,0 @@ -/* - * cx18 init/start/stop/exit stream functions - * - * Derived from ivtv-streams.c - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -#include "cx18-driver.h" -#include "cx18-fileops.h" -#include "cx18-mailbox.h" -#include "cx18-i2c.h" -#include "cx18-queue.h" -#include "cx18-ioctl.h" -#include "cx18-streams.h" -#include "cx18-cards.h" -#include "cx18-scb.h" -#include "cx18-av-core.h" -#include "cx18-dvb.h" - -#define CX18_DSP0_INTERRUPT_MASK 0xd0004C - -static struct file_operations cx18_v4l2_enc_fops = { - .owner = THIS_MODULE, - .read = cx18_v4l2_read, - .open = cx18_v4l2_open, - .ioctl = cx18_v4l2_ioctl, - .release = cx18_v4l2_close, - .poll = cx18_v4l2_enc_poll, -}; - -/* offset from 0 to register ts v4l2 minors on */ -#define CX18_V4L2_ENC_TS_OFFSET 16 -/* offset from 0 to register pcm v4l2 minors on */ -#define CX18_V4L2_ENC_PCM_OFFSET 24 -/* offset from 0 to register yuv v4l2 minors on */ -#define CX18_V4L2_ENC_YUV_OFFSET 32 - -static struct { - const char *name; - int vfl_type; - int minor_offset; - int dma; - enum v4l2_buf_type buf_type; - struct file_operations *fops; -} cx18_stream_info[] = { - { /* CX18_ENC_STREAM_TYPE_MPG */ - "encoder MPEG", - VFL_TYPE_GRABBER, 0, - PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VIDEO_CAPTURE, - &cx18_v4l2_enc_fops - }, - { /* CX18_ENC_STREAM_TYPE_TS */ - "TS", - VFL_TYPE_GRABBER, -1, - PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VIDEO_CAPTURE, - &cx18_v4l2_enc_fops - }, - { /* CX18_ENC_STREAM_TYPE_YUV */ - "encoder YUV", - VFL_TYPE_GRABBER, CX18_V4L2_ENC_YUV_OFFSET, - PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VIDEO_CAPTURE, - &cx18_v4l2_enc_fops - }, - { /* CX18_ENC_STREAM_TYPE_VBI */ - "encoder VBI", - VFL_TYPE_VBI, 0, - PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VBI_CAPTURE, - &cx18_v4l2_enc_fops - }, - { /* CX18_ENC_STREAM_TYPE_PCM */ - "encoder PCM audio", - VFL_TYPE_GRABBER, CX18_V4L2_ENC_PCM_OFFSET, - PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_PRIVATE, - &cx18_v4l2_enc_fops - }, - { /* CX18_ENC_STREAM_TYPE_IDX */ - "encoder IDX", - VFL_TYPE_GRABBER, -1, - PCI_DMA_FROMDEVICE, V4L2_BUF_TYPE_VIDEO_CAPTURE, - &cx18_v4l2_enc_fops - }, - { /* CX18_ENC_STREAM_TYPE_RAD */ - "encoder radio", - VFL_TYPE_RADIO, 0, - PCI_DMA_NONE, V4L2_BUF_TYPE_PRIVATE, - &cx18_v4l2_enc_fops - }, -}; - -static void cx18_stream_init(struct cx18 *cx, int type) -{ - struct cx18_stream *s = &cx->streams[type]; - struct video_device *dev = s->v4l2dev; - u32 max_size = cx->options.megabytes[type] * 1024 * 1024; - - /* we need to keep v4l2dev, so restore it afterwards */ - memset(s, 0, sizeof(*s)); - s->v4l2dev = dev; - - /* initialize cx18_stream fields */ - s->cx = cx; - s->type = type; - s->name = cx18_stream_info[type].name; - s->handle = 0xffffffff; - - s->dma = cx18_stream_info[type].dma; - s->buf_size = cx->stream_buf_size[type]; - if (s->buf_size) - s->buffers = max_size / s->buf_size; - if (s->buffers > 63) { - /* Each stream has a maximum of 63 buffers, - ensure we do not exceed that. */ - s->buffers = 63; - s->buf_size = (max_size / s->buffers) & ~0xfff; - } - spin_lock_init(&s->qlock); - init_waitqueue_head(&s->waitq); - s->id = -1; - cx18_queue_init(&s->q_free); - cx18_queue_init(&s->q_full); - cx18_queue_init(&s->q_io); -} - -static int cx18_prep_dev(struct cx18 *cx, int type) -{ - struct cx18_stream *s = &cx->streams[type]; - u32 cap = cx->v4l2_cap; - int minor_offset = cx18_stream_info[type].minor_offset; - int minor; - - /* These four fields are always initialized. If v4l2dev == NULL, then - this stream is not in use. In that case no other fields but these - four can be used. */ - s->v4l2dev = NULL; - s->cx = cx; - s->type = type; - s->name = cx18_stream_info[type].name; - - /* Check whether the radio is supported */ - if (type == CX18_ENC_STREAM_TYPE_RAD && !(cap & V4L2_CAP_RADIO)) - return 0; - - /* Check whether VBI is supported */ - if (type == CX18_ENC_STREAM_TYPE_VBI && - !(cap & (V4L2_CAP_VBI_CAPTURE | V4L2_CAP_SLICED_VBI_CAPTURE))) - return 0; - - /* card number + user defined offset + device offset */ - minor = cx->num + cx18_first_minor + minor_offset; - - /* User explicitly selected 0 buffers for these streams, so don't - create them. */ - if (cx18_stream_info[type].dma != PCI_DMA_NONE && - cx->options.megabytes[type] == 0) { - CX18_INFO("Disabled %s device\n", cx18_stream_info[type].name); - return 0; - } - - cx18_stream_init(cx, type); - - if (minor_offset == -1) - return 0; - - /* allocate and initialize the v4l2 video device structure */ - s->v4l2dev = video_device_alloc(); - if (s->v4l2dev == NULL) { - CX18_ERR("Couldn't allocate v4l2 video_device for %s\n", - s->name); - return -ENOMEM; - } - - s->v4l2dev->type = - VID_TYPE_CAPTURE | VID_TYPE_TUNER | VID_TYPE_TELETEXT | - VID_TYPE_CLIPPING | VID_TYPE_SCALES | VID_TYPE_MPEG_ENCODER; - snprintf(s->v4l2dev->name, sizeof(s->v4l2dev->name), "cx18%d %s", - cx->num, s->name); - - s->v4l2dev->minor = minor; - s->v4l2dev->dev = &cx->dev->dev; - s->v4l2dev->fops = cx18_stream_info[type].fops; - s->v4l2dev->release = video_device_release; - - return 0; -} - -/* Initialize v4l2 variables and register v4l2 devices */ -int cx18_streams_setup(struct cx18 *cx) -{ - int type; - - /* Setup V4L2 Devices */ - for (type = 0; type < CX18_MAX_STREAMS; type++) { - /* Prepare device */ - if (cx18_prep_dev(cx, type)) - break; - - /* Allocate Stream */ - if (cx18_stream_alloc(&cx->streams[type])) - break; - } - if (type == CX18_MAX_STREAMS) - return 0; - - /* One or more streams could not be initialized. Clean 'em all up. */ - cx18_streams_cleanup(cx); - return -ENOMEM; -} - -static int cx18_reg_dev(struct cx18 *cx, int type) -{ - struct cx18_stream *s = &cx->streams[type]; - int vfl_type = cx18_stream_info[type].vfl_type; - int minor; - - /* TODO: Shouldn't this be a VFL_TYPE_TRANSPORT or something? - * We need a VFL_TYPE_TS defined. - */ - if (strcmp("TS", s->name) == 0) { - /* just return if no DVB is supported */ - if ((cx->card->hw_all & CX18_HW_DVB) == 0) - return 0; - if (cx18_dvb_register(s) < 0) { - CX18_ERR("DVB failed to register\n"); - return -EINVAL; - } - } - - if (s->v4l2dev == NULL) - return 0; - - minor = s->v4l2dev->minor; - - /* Register device. First try the desired minor, then any free one. */ - if (video_register_device(s->v4l2dev, vfl_type, minor) && - video_register_device(s->v4l2dev, vfl_type, -1)) { - CX18_ERR("Couldn't register v4l2 device for %s minor %d\n", - s->name, minor); - video_device_release(s->v4l2dev); - s->v4l2dev = NULL; - return -ENOMEM; - } - minor = s->v4l2dev->minor; - - switch (vfl_type) { - case VFL_TYPE_GRABBER: - CX18_INFO("Registered device video%d for %s (%d MB)\n", - minor, s->name, cx->options.megabytes[type]); - break; - - case VFL_TYPE_RADIO: - CX18_INFO("Registered device radio%d for %s\n", - minor - MINOR_VFL_TYPE_RADIO_MIN, s->name); - break; - - case VFL_TYPE_VBI: - if (cx->options.megabytes[type]) - CX18_INFO("Registered device vbi%d for %s (%d MB)\n", - minor - MINOR_VFL_TYPE_VBI_MIN, - s->name, cx->options.megabytes[type]); - else - CX18_INFO("Registered device vbi%d for %s\n", - minor - MINOR_VFL_TYPE_VBI_MIN, s->name); - break; - } - - return 0; -} - -/* Register v4l2 devices */ -int cx18_streams_register(struct cx18 *cx) -{ - int type; - int err = 0; - - /* Register V4L2 devices */ - for (type = 0; type < CX18_MAX_STREAMS; type++) - err |= cx18_reg_dev(cx, type); - - if (err == 0) - return 0; - - /* One or more streams could not be initialized. Clean 'em all up. */ - cx18_streams_cleanup(cx); - return -ENOMEM; -} - -/* Unregister v4l2 devices */ -void cx18_streams_cleanup(struct cx18 *cx) -{ - struct video_device *vdev; - int type; - - /* Teardown all streams */ - for (type = 0; type < CX18_MAX_STREAMS; type++) { - if (cx->streams[type].dvb.enabled) - cx18_dvb_unregister(&cx->streams[type]); - - vdev = cx->streams[type].v4l2dev; - - cx->streams[type].v4l2dev = NULL; - if (vdev == NULL) - continue; - - cx18_stream_free(&cx->streams[type]); - - /* Unregister device */ - video_unregister_device(vdev); - } -} - -static void cx18_vbi_setup(struct cx18_stream *s) -{ - struct cx18 *cx = s->cx; - int raw = cx->vbi.sliced_in->service_set == 0; - u32 data[CX2341X_MBOX_MAX_DATA]; - int lines; - - if (cx->is_60hz) { - cx->vbi.count = 12; - cx->vbi.start[0] = 10; - cx->vbi.start[1] = 273; - } else { /* PAL/SECAM */ - cx->vbi.count = 18; - cx->vbi.start[0] = 6; - cx->vbi.start[1] = 318; - } - - /* setup VBI registers */ - cx18_av_cmd(cx, VIDIOC_S_FMT, &cx->vbi.in); - - /* determine number of lines and total number of VBI bytes. - A raw line takes 1443 bytes: 2 * 720 + 4 byte frame header - 1 - The '- 1' byte is probably an unused U or V byte. Or something... - A sliced line takes 51 bytes: 4 byte frame header, 4 byte internal - header, 42 data bytes + checksum (to be confirmed) */ - if (raw) { - lines = cx->vbi.count * 2; - } else { - lines = cx->is_60hz ? 24 : 38; - if (cx->is_60hz) - lines += 2; - } - - cx->vbi.enc_size = lines * - (raw ? cx->vbi.raw_size : cx->vbi.sliced_size); - - data[0] = s->handle; - /* Lines per field */ - data[1] = (lines / 2) | ((lines / 2) << 16); - /* bytes per line */ - data[2] = (raw ? cx->vbi.raw_size : cx->vbi.sliced_size); - /* Every X number of frames a VBI interrupt arrives - (frames as in 25 or 30 fps) */ - data[3] = 1; - /* Setup VBI for the cx25840 digitizer */ - if (raw) { - data[4] = 0x20602060; - data[5] = 0x30703070; - } else { - data[4] = 0xB0F0B0F0; - data[5] = 0xA0E0A0E0; - } - - CX18_DEBUG_INFO("Setup VBI h: %d lines %x bpl %d fr %d %x %x\n", - data[0], data[1], data[2], data[3], data[4], data[5]); - - if (s->type == CX18_ENC_STREAM_TYPE_VBI) - cx18_api(cx, CX18_CPU_SET_RAW_VBI_PARAM, 6, data); -} - -int cx18_start_v4l2_encode_stream(struct cx18_stream *s) -{ - u32 data[MAX_MB_ARGUMENTS]; - struct cx18 *cx = s->cx; - struct list_head *p; - int ts = 0; - int captype = 0; - - if (s->v4l2dev == NULL && s->dvb.enabled == 0) - return -EINVAL; - - CX18_DEBUG_INFO("Start encoder stream %s\n", s->name); - - switch (s->type) { - case CX18_ENC_STREAM_TYPE_MPG: - captype = CAPTURE_CHANNEL_TYPE_MPEG; - cx->mpg_data_received = cx->vbi_data_inserted = 0; - cx->dualwatch_jiffies = jiffies; - cx->dualwatch_stereo_mode = cx->params.audio_properties & 0x300; - cx->search_pack_header = 0; - break; - - case CX18_ENC_STREAM_TYPE_TS: - captype = CAPTURE_CHANNEL_TYPE_TS; - ts = 1; - break; - case CX18_ENC_STREAM_TYPE_YUV: - captype = CAPTURE_CHANNEL_TYPE_YUV; - break; - case CX18_ENC_STREAM_TYPE_PCM: - captype = CAPTURE_CHANNEL_TYPE_PCM; - break; - case CX18_ENC_STREAM_TYPE_VBI: - captype = cx->vbi.sliced_in->service_set ? - CAPTURE_CHANNEL_TYPE_SLICED_VBI : CAPTURE_CHANNEL_TYPE_VBI; - cx->vbi.frame = 0; - cx->vbi.inserted_frame = 0; - memset(cx->vbi.sliced_mpeg_size, - 0, sizeof(cx->vbi.sliced_mpeg_size)); - break; - default: - return -EINVAL; - } - s->buffers_stolen = 0; - - /* mute/unmute video */ - cx18_vapi(cx, CX18_CPU_SET_VIDEO_MUTE, 2, - s->handle, !!test_bit(CX18_F_I_RADIO_USER, &cx->i_flags)); - - /* Clear Streamoff flags in case left from last capture */ - clear_bit(CX18_F_S_STREAMOFF, &s->s_flags); - - cx18_vapi_result(cx, data, CX18_CREATE_TASK, 1, CPU_CMD_MASK_CAPTURE); - s->handle = data[0]; - cx18_vapi(cx, CX18_CPU_SET_CHANNEL_TYPE, 2, s->handle, captype); - - if (atomic_read(&cx->capturing) == 0 && !ts) { - /* Stuff from Windows, we don't know what it is */ - cx18_vapi(cx, CX18_CPU_SET_VER_CROP_LINE, 2, s->handle, 0); - cx18_vapi(cx, CX18_CPU_SET_MISC_PARAMETERS, 3, s->handle, 3, 1); - cx18_vapi(cx, CX18_CPU_SET_MISC_PARAMETERS, 3, s->handle, 8, 0); - cx18_vapi(cx, CX18_CPU_SET_MISC_PARAMETERS, 3, s->handle, 4, 1); - cx18_vapi(cx, CX18_CPU_SET_MISC_PARAMETERS, 2, s->handle, 12); - - cx18_vapi(cx, CX18_CPU_SET_CAPTURE_LINE_NO, 3, - s->handle, cx->digitizer, cx->digitizer); - - /* Setup VBI */ - if (cx->v4l2_cap & V4L2_CAP_VBI_CAPTURE) - cx18_vbi_setup(s); - - /* assign program index info. - Mask 7: select I/P/B, Num_req: 400 max */ - cx18_vapi_result(cx, data, CX18_CPU_SET_INDEXTABLE, 1, 0); - - /* Setup API for Stream */ - cx2341x_update(cx, cx18_api_func, NULL, &cx->params); - } - - if (atomic_read(&cx->capturing) == 0) { - clear_bit(CX18_F_I_EOS, &cx->i_flags); - write_reg(7, CX18_DSP0_INTERRUPT_MASK); - } - - cx18_vapi(cx, CX18_CPU_DE_SET_MDL_ACK, 3, s->handle, - (void *)&cx->scb->cpu_mdl_ack[s->type][0] - cx->enc_mem, - (void *)&cx->scb->cpu_mdl_ack[s->type][1] - cx->enc_mem); - - list_for_each(p, &s->q_free.list) { - struct cx18_buffer *buf = list_entry(p, struct cx18_buffer, list); - - writel(buf->dma_handle, &cx->scb->cpu_mdl[buf->id].paddr); - writel(s->buf_size, &cx->scb->cpu_mdl[buf->id].length); - cx18_vapi(cx, CX18_CPU_DE_SET_MDL, 5, s->handle, - (void *)&cx->scb->cpu_mdl[buf->id] - cx->enc_mem, 1, - buf->id, s->buf_size); - } - /* begin_capture */ - if (cx18_vapi(cx, CX18_CPU_CAPTURE_START, 1, s->handle)) { - CX18_DEBUG_WARN("Error starting capture!\n"); - cx18_vapi(cx, CX18_DESTROY_TASK, 1, s->handle); - return -EINVAL; - } - - /* you're live! sit back and await interrupts :) */ - atomic_inc(&cx->capturing); - return 0; -} - -void cx18_stop_all_captures(struct cx18 *cx) -{ - int i; - - for (i = CX18_MAX_STREAMS - 1; i >= 0; i--) { - struct cx18_stream *s = &cx->streams[i]; - - if (s->v4l2dev == NULL && s->dvb.enabled == 0) - continue; - if (test_bit(CX18_F_S_STREAMING, &s->s_flags)) - cx18_stop_v4l2_encode_stream(s, 0); - } -} - -int cx18_stop_v4l2_encode_stream(struct cx18_stream *s, int gop_end) -{ - struct cx18 *cx = s->cx; - unsigned long then; - - if (s->v4l2dev == NULL && s->dvb.enabled == 0) - return -EINVAL; - - /* This function assumes that you are allowed to stop the capture - and that we are actually capturing */ - - CX18_DEBUG_INFO("Stop Capture\n"); - - if (atomic_read(&cx->capturing) == 0) - return 0; - - if (s->type == CX18_ENC_STREAM_TYPE_MPG) - cx18_vapi(cx, CX18_CPU_CAPTURE_STOP, 2, s->handle, !gop_end); - else - cx18_vapi(cx, CX18_CPU_CAPTURE_STOP, 1, s->handle); - - then = jiffies; - - if (s->type == CX18_ENC_STREAM_TYPE_MPG && gop_end) { - CX18_INFO("ignoring gop_end: not (yet?) supported by the firmware\n"); - } - - atomic_dec(&cx->capturing); - - /* Clear capture and no-read bits */ - clear_bit(CX18_F_S_STREAMING, &s->s_flags); - - cx18_vapi(cx, CX18_DESTROY_TASK, 1, s->handle); - s->handle = 0xffffffff; - - if (atomic_read(&cx->capturing) > 0) - return 0; - - write_reg(5, CX18_DSP0_INTERRUPT_MASK); - wake_up(&s->waitq); - - return 0; -} - -u32 cx18_find_handle(struct cx18 *cx) -{ - int i; - - /* find first available handle to be used for global settings */ - for (i = 0; i < CX18_MAX_STREAMS; i++) { - struct cx18_stream *s = &cx->streams[i]; - - if (s->v4l2dev && s->handle) - return s->handle; - } - return 0; -} diff --git a/trunk/drivers/media/video/cx18/cx18-streams.h b/trunk/drivers/media/video/cx18/cx18-streams.h deleted file mode 100644 index 8c7ba7d2fa79..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-streams.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * cx18 init/start/stop/exit stream functions - * - * Derived from ivtv-streams.h - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -u32 cx18_find_handle(struct cx18 *cx); -int cx18_streams_setup(struct cx18 *cx); -int cx18_streams_register(struct cx18 *cx); -void cx18_streams_cleanup(struct cx18 *cx); - -/* Capture related */ -int cx18_start_v4l2_encode_stream(struct cx18_stream *s); -int cx18_stop_v4l2_encode_stream(struct cx18_stream *s, int gop_end); - -void cx18_stop_all_captures(struct cx18 *cx); diff --git a/trunk/drivers/media/video/cx18/cx18-vbi.c b/trunk/drivers/media/video/cx18/cx18-vbi.c deleted file mode 100644 index 22e76ee3f447..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-vbi.c +++ /dev/null @@ -1,208 +0,0 @@ -/* - * cx18 Vertical Blank Interval support functions - * - * Derived from ivtv-vbi.c - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -#include "cx18-driver.h" -#include "cx18-vbi.h" -#include "cx18-ioctl.h" -#include "cx18-queue.h" -#include "cx18-av-core.h" - -static void copy_vbi_data(struct cx18 *cx, int lines, u32 pts_stamp) -{ - int line = 0; - int i; - u32 linemask[2] = { 0, 0 }; - unsigned short size; - static const u8 mpeg_hdr_data[] = { - 0x00, 0x00, 0x01, 0xba, 0x44, 0x00, 0x0c, 0x66, - 0x24, 0x01, 0x01, 0xd1, 0xd3, 0xfa, 0xff, 0xff, - 0x00, 0x00, 0x01, 0xbd, 0x00, 0x1a, 0x84, 0x80, - 0x07, 0x21, 0x00, 0x5d, 0x63, 0xa7, 0xff, 0xff - }; - const int sd = sizeof(mpeg_hdr_data); /* start of vbi data */ - int idx = cx->vbi.frame % CX18_VBI_FRAMES; - u8 *dst = &cx->vbi.sliced_mpeg_data[idx][0]; - - for (i = 0; i < lines; i++) { - struct v4l2_sliced_vbi_data *sdata = cx->vbi.sliced_data + i; - int f, l; - - if (sdata->id == 0) - continue; - - l = sdata->line - 6; - f = sdata->field; - if (f) - l += 18; - if (l < 32) - linemask[0] |= (1 << l); - else - linemask[1] |= (1 << (l - 32)); - dst[sd + 12 + line * 43] = cx18_service2vbi(sdata->id); - memcpy(dst + sd + 12 + line * 43 + 1, sdata->data, 42); - line++; - } - memcpy(dst, mpeg_hdr_data, sizeof(mpeg_hdr_data)); - if (line == 36) { - /* All lines are used, so there is no space for the linemask - (the max size of the VBI data is 36 * 43 + 4 bytes). - So in this case we use the magic number 'ITV0'. */ - memcpy(dst + sd, "ITV0", 4); - memcpy(dst + sd + 4, dst + sd + 12, line * 43); - size = 4 + ((43 * line + 3) & ~3); - } else { - memcpy(dst + sd, "cx0", 4); - memcpy(dst + sd + 4, &linemask[0], 8); - size = 12 + ((43 * line + 3) & ~3); - } - dst[4+16] = (size + 10) >> 8; - dst[5+16] = (size + 10) & 0xff; - dst[9+16] = 0x21 | ((pts_stamp >> 29) & 0x6); - dst[10+16] = (pts_stamp >> 22) & 0xff; - dst[11+16] = 1 | ((pts_stamp >> 14) & 0xff); - dst[12+16] = (pts_stamp >> 7) & 0xff; - dst[13+16] = 1 | ((pts_stamp & 0x7f) << 1); - cx->vbi.sliced_mpeg_size[idx] = sd + size; -} - -/* Compress raw VBI format, removes leading SAV codes and surplus space - after the field. - Returns new compressed size. */ -static u32 compress_raw_buf(struct cx18 *cx, u8 *buf, u32 size) -{ - u32 line_size = cx->vbi.raw_decoder_line_size; - u32 lines = cx->vbi.count; - u8 sav1 = cx->vbi.raw_decoder_sav_odd_field; - u8 sav2 = cx->vbi.raw_decoder_sav_even_field; - u8 *q = buf; - u8 *p; - int i; - - for (i = 0; i < lines; i++) { - p = buf + i * line_size; - - /* Look for SAV code */ - if (p[0] != 0xff || p[1] || p[2] || - (p[3] != sav1 && p[3] != sav2)) - break; - memcpy(q, p + 4, line_size - 4); - q += line_size - 4; - } - return lines * (line_size - 4); -} - - -/* Compressed VBI format, all found sliced blocks put next to one another - Returns new compressed size */ -static u32 compress_sliced_buf(struct cx18 *cx, u32 line, u8 *buf, - u32 size, u8 sav) -{ - u32 line_size = cx->vbi.sliced_decoder_line_size; - struct v4l2_decode_vbi_line vbi; - int i; - - /* find the first valid line */ - for (i = 0; i < size; i++, buf++) { - if (buf[0] == 0xff && !buf[1] && !buf[2] && buf[3] == sav) - break; - } - - size -= i; - if (size < line_size) - return line; - for (i = 0; i < size / line_size; i++) { - u8 *p = buf + i * line_size; - - /* Look for SAV code */ - if (p[0] != 0xff || p[1] || p[2] || p[3] != sav) - continue; - vbi.p = p + 4; - cx18_av_cmd(cx, VIDIOC_INT_DECODE_VBI_LINE, &vbi); - if (vbi.type) { - cx->vbi.sliced_data[line].id = vbi.type; - cx->vbi.sliced_data[line].field = vbi.is_second_field; - cx->vbi.sliced_data[line].line = vbi.line; - memcpy(cx->vbi.sliced_data[line].data, vbi.p, 42); - line++; - } - } - return line; -} - -void cx18_process_vbi_data(struct cx18 *cx, struct cx18_buffer *buf, - u64 pts_stamp, int streamtype) -{ - u8 *p = (u8 *) buf->buf; - u32 size = buf->bytesused; - int lines; - - if (streamtype != CX18_ENC_STREAM_TYPE_VBI) - return; - - /* Raw VBI data */ - if (cx->vbi.sliced_in->service_set == 0) { - u8 type; - - cx18_buf_swap(buf); - - type = p[3]; - - size = buf->bytesused = compress_raw_buf(cx, p, size); - - /* second field of the frame? */ - if (type == cx->vbi.raw_decoder_sav_even_field) { - /* Dirty hack needed for backwards - compatibility of old VBI software. */ - p += size - 4; - memcpy(p, &cx->vbi.frame, 4); - cx->vbi.frame++; - } - return; - } - - /* Sliced VBI data with data insertion */ - cx18_buf_swap(buf); - - /* first field */ - lines = compress_sliced_buf(cx, 0, p, size / 2, - cx->vbi.sliced_decoder_sav_odd_field); - /* second field */ - /* experimentation shows that the second half does not always - begin at the exact address. So start a bit earlier - (hence 32). */ - lines = compress_sliced_buf(cx, lines, p + size / 2 - 32, - size / 2 + 32, cx->vbi.sliced_decoder_sav_even_field); - /* always return at least one empty line */ - if (lines == 0) { - cx->vbi.sliced_data[0].id = 0; - cx->vbi.sliced_data[0].line = 0; - cx->vbi.sliced_data[0].field = 0; - lines = 1; - } - buf->bytesused = size = lines * sizeof(cx->vbi.sliced_data[0]); - memcpy(p, &cx->vbi.sliced_data[0], size); - - if (cx->vbi.insert_mpeg) - copy_vbi_data(cx, lines, pts_stamp); - cx->vbi.frame++; -} diff --git a/trunk/drivers/media/video/cx18/cx18-vbi.h b/trunk/drivers/media/video/cx18/cx18-vbi.h deleted file mode 100644 index c56ff7d28f20..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-vbi.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * cx18 Vertical Blank Interval support functions - * - * Derived from ivtv-vbi.h - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -void cx18_process_vbi_data(struct cx18 *cx, struct cx18_buffer *buf, - u64 pts_stamp, int streamtype); -int cx18_used_line(struct cx18 *cx, int line, int field); diff --git a/trunk/drivers/media/video/cx18/cx18-version.h b/trunk/drivers/media/video/cx18/cx18-version.h deleted file mode 100644 index d5c7a6f968dd..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-version.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * cx18 driver version information - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -#ifndef CX18_VERSION_H -#define CX18_VERSION_H - -#define CX18_DRIVER_NAME "cx18" -#define CX18_DRIVER_VERSION_MAJOR 1 -#define CX18_DRIVER_VERSION_MINOR 0 -#define CX18_DRIVER_VERSION_PATCHLEVEL 0 - -#define CX18_VERSION __stringify(CX18_DRIVER_VERSION_MAJOR) "." __stringify(CX18_DRIVER_VERSION_MINOR) "." __stringify(CX18_DRIVER_VERSION_PATCHLEVEL) -#define CX18_DRIVER_VERSION KERNEL_VERSION(CX18_DRIVER_VERSION_MAJOR, \ - CX18_DRIVER_VERSION_MINOR, CX18_DRIVER_VERSION_PATCHLEVEL) - -#endif diff --git a/trunk/drivers/media/video/cx18/cx18-video.c b/trunk/drivers/media/video/cx18/cx18-video.c deleted file mode 100644 index 2e5c41939330..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-video.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * cx18 video interface functions - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -#include "cx18-driver.h" -#include "cx18-video.h" -#include "cx18-av-core.h" -#include "cx18-cards.h" - -void cx18_video_set_io(struct cx18 *cx) -{ - struct v4l2_routing route; - int inp = cx->active_input; - u32 type; - - route.input = cx->card->video_inputs[inp].video_input; - route.output = 0; - cx18_av_cmd(cx, VIDIOC_INT_S_VIDEO_ROUTING, &route); - - type = cx->card->video_inputs[inp].video_type; - - if (type == CX18_CARD_INPUT_VID_TUNER) - route.input = 0; /* Tuner */ - else if (type < CX18_CARD_INPUT_COMPOSITE1) - route.input = 2; /* S-Video */ - else - route.input = 1; /* Composite */ -} diff --git a/trunk/drivers/media/video/cx18/cx18-video.h b/trunk/drivers/media/video/cx18/cx18-video.h deleted file mode 100644 index 529006a06e5c..000000000000 --- a/trunk/drivers/media/video/cx18/cx18-video.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * cx18 video interface functions - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -void cx18_video_set_io(struct cx18 *cx); diff --git a/trunk/drivers/media/video/cx18/cx23418.h b/trunk/drivers/media/video/cx18/cx23418.h deleted file mode 100644 index 33f78da9dba8..000000000000 --- a/trunk/drivers/media/video/cx18/cx23418.h +++ /dev/null @@ -1,458 +0,0 @@ -/* - * cx18 header containing common defines. - * - * Copyright (C) 2007 Hans Verkuil - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - */ - -#ifndef CX23418_H -#define CX23418_H - -#include - -#define MGR_CMD_MASK 0x40000000 -/* The MSB of the command code indicates that this is the completion of a - command */ -#define MGR_CMD_MASK_ACK (MGR_CMD_MASK | 0x80000000) - -/* Description: This command creates a new instance of a certain task - IN[0] - Task ID. This is one of the XPU_CMD_MASK_YYY where XPU is - the processor on which the task YYY will be created - OUT[0] - Task handle. This handle is passed along with commands to - dispatch to the right instance of the task - ReturnCode - One of the ERR_SYS_... */ -#define CX18_CREATE_TASK (MGR_CMD_MASK | 0x0001) - -/* Description: This command destroys an instance of a task - IN[0] - Task handle. Hanlde of the task to destroy - ReturnCode - One of the ERR_SYS_... */ -#define CX18_DESTROY_TASK (MGR_CMD_MASK | 0x0002) - -/* All commands for CPU have the following mask set */ -#define CPU_CMD_MASK 0x20000000 -#define CPU_CMD_MASK_ACK (CPU_CMD_MASK | 0x80000000) -#define CPU_CMD_MASK_CAPTURE (CPU_CMD_MASK | 0x00020000) -#define CPU_CMD_MASK_TS (CPU_CMD_MASK | 0x00040000) - -#define EPU_CMD_MASK 0x02000000 -#define EPU_CMD_MASK_DEBUG (EPU_CMD_MASK | 0x000000) -#define EPU_CMD_MASK_DE (EPU_CMD_MASK | 0x040000) - -/* Description: This command indicates that a Memory Descriptor List has been - filled with the requested channel type - IN[0] - Task handle. Handle of the task - IN[1] - Offset of the MDL_ACK from the beginning of the local DDR. - IN[2] - Number of CNXT_MDL_ACK structures in the array pointed to by IN[1] - ReturnCode - One of the ERR_DE_... */ -#define CX18_EPU_DMA_DONE (EPU_CMD_MASK_DE | 0x0001) - -/* Something interesting happened - IN[0] - A value to log - IN[1] - An offset of a string in the MiniMe memory; - 0/zero/NULL means "I have nothing to say" */ -#define CX18_EPU_DEBUG (EPU_CMD_MASK_DEBUG | 0x0003) - -/* Description: This command starts streaming with the set channel type - IN[0] - Task handle. Handle of the task to start - ReturnCode - One of the ERR_CAPTURE_... */ -#define CX18_CPU_CAPTURE_START (CPU_CMD_MASK_CAPTURE | 0x0002) - -/* Description: This command stops streaming with the set channel type - IN[0] - Task handle. Handle of the task to stop - IN[1] - 0 = stop at end of GOP, 1 = stop at end of frame (MPEG only) - ReturnCode - One of the ERR_CAPTURE_... */ -#define CX18_CPU_CAPTURE_STOP (CPU_CMD_MASK_CAPTURE | 0x0003) - -/* Description: This command pauses streaming with the set channel type - IN[0] - Task handle. Handle of the task to pause - ReturnCode - One of the ERR_CAPTURE_... */ -#define CX18_CPU_CAPTURE_PAUSE (CPU_CMD_MASK_CAPTURE | 0x0007) - -/* Description: This command resumes streaming with the set channel type - IN[0] - Task handle. Handle of the task to resume - ReturnCode - One of the ERR_CAPTURE_... */ -#define CX18_CPU_CAPTURE_RESUME (CPU_CMD_MASK_CAPTURE | 0x0008) - -#define CAPTURE_CHANNEL_TYPE_NONE 0 -#define CAPTURE_CHANNEL_TYPE_MPEG 1 -#define CAPTURE_CHANNEL_TYPE_INDEX 2 -#define CAPTURE_CHANNEL_TYPE_YUV 3 -#define CAPTURE_CHANNEL_TYPE_PCM 4 -#define CAPTURE_CHANNEL_TYPE_VBI 5 -#define CAPTURE_CHANNEL_TYPE_SLICED_VBI 6 -#define CAPTURE_CHANNEL_TYPE_TS 7 -#define CAPTURE_CHANNEL_TYPE_MAX 15 - -/* Description: This command sets the channel type. This can only be done - when stopped. - IN[0] - Task handle. Handle of the task to start - IN[1] - Channel Type. See Below. - ReturnCode - One of the ERR_CAPTURE_... */ -#define CX18_CPU_SET_CHANNEL_TYPE (CPU_CMD_MASK_CAPTURE + 1) - -/* Description: Set stream output type - IN[0] - task handle. Handle of the task to start - IN[1] - type - ReturnCode - One of the ERR_CAPTURE_... */ -#define CX18_CPU_SET_STREAM_OUTPUT_TYPE (CPU_CMD_MASK_CAPTURE | 0x0012) - -/* Description: Set video input resolution and frame rate - IN[0] - task handle - IN[1] - reserved - IN[2] - reserved - IN[3] - reserved - IN[4] - reserved - IN[5] - frame rate, 0 - 29.97f/s, 1 - 25f/s - ReturnCode - One of the ERR_CAPTURE_... */ -#define CX18_CPU_SET_VIDEO_IN (CPU_CMD_MASK_CAPTURE | 0x0004) - -/* Description: Set video frame rate - IN[0] - task handle. Handle of the task to start - IN[1] - video bit rate mode - IN[2] - video average rate - IN[3] - video peak rate - IN[4] - system mux rate - ReturnCode - One of the ERR_CAPTURE_... */ -#define CX18_CPU_SET_VIDEO_RATE (CPU_CMD_MASK_CAPTURE | 0x0005) - -/* Description: Set video output resolution - IN[0] - task handle - IN[1] - horizontal size - IN[2] - vertical size - ReturnCode - One of the ERR_CAPTURE_... */ -#define CX18_CPU_SET_VIDEO_RESOLUTION (CPU_CMD_MASK_CAPTURE | 0x0006) - -/* Description: This command set filter parameters - IN[0] - Task handle. Handle of the task - IN[1] - type, 0 - temporal, 1 - spatial, 2 - median - IN[2] - mode, temporal/spatial: 0 - disable, 1 - static, 2 - dynamic - median: 0 = disable, 1 = horizontal, 2 = vertical, - 3 = horizontal/vertical, 4 = diagonal - IN[3] - strength, temporal 0 - 31, spatial 0 - 15 - ReturnCode - One of the ERR_CAPTURE_... */ -#define CX18_CPU_SET_FILTER_PARAM (CPU_CMD_MASK_CAPTURE | 0x0009) - -/* Description: This command set spatial filter type - IN[0] - Task handle. - IN[1] - luma type: 0 = disable, 1 = 1D horizontal only, 2 = 1D vertical only, - 3 = 2D H/V separable, 4 = 2D symmetric non-separable - IN[2] - chroma type: 0 - diable, 1 = 1D horizontal - ReturnCode - One of the ERR_CAPTURE_... */ -#define CX18_CPU_SET_SPATIAL_FILTER_TYPE (CPU_CMD_MASK_CAPTURE | 0x000C) - -/* Description: This command set coring levels for median filter - IN[0] - Task handle. - IN[1] - luma_high - IN[2] - luma_low - IN[3] - chroma_high - IN[4] - chroma_low - ReturnCode - One of the ERR_CAPTURE_... */ -#define CX18_CPU_SET_MEDIAN_CORING (CPU_CMD_MASK_CAPTURE | 0x000E) - -/* Description: This command set the picture type mask for index file - IN[0] - 0 = disable index file output - 1 = output I picture - 2 = P picture - 4 = B picture - other = illegal */ -#define CX18_CPU_SET_INDEXTABLE (CPU_CMD_MASK_CAPTURE | 0x0010) - -/* Description: Set audio parameters - IN[0] - task handle. Handle of the task to start - IN[1] - audio parameter - ReturnCode - One of the ERR_CAPTURE_... */ -#define CX18_CPU_SET_AUDIO_PARAMETERS (CPU_CMD_MASK_CAPTURE | 0x0011) - -/* Description: Set video mute - IN[0] - task handle. Handle of the task to start - IN[1] - bit31-24: muteYvalue - bit23-16: muteUvalue - bit15-8: muteVvalue - bit0: 1:mute, 0: unmute - ReturnCode - One of the ERR_CAPTURE_... */ -#define CX18_CPU_SET_VIDEO_MUTE (CPU_CMD_MASK_CAPTURE | 0x0013) - -/* Description: Set audio mute - IN[0] - task handle. Handle of the task to start - IN[1] - mute/unmute - ReturnCode - One of the ERR_CAPTURE_... */ -#define CX18_CPU_SET_AUDIO_MUTE (CPU_CMD_MASK_CAPTURE | 0x0014) - -/* Description: Set stream output type - IN[0] - task handle. Handle of the task to start - IN[1] - subType - SET_INITIAL_SCR 1 - SET_QUALITY_MODE 2 - SET_VIM_PROTECT_MODE 3 - SET_PTS_CORRECTION 4 - SET_USB_FLUSH_MODE 5 - SET_MERAQPAR_ENABLE 6 - SET_NAV_PACK_INSERTION 7 - SET_SCENE_CHANGE_ENABLE 8 - IN[2] - parameter 1 - IN[3] - parameter 2 - ReturnCode - One of the ERR_CAPTURE_... */ -#define CX18_CPU_SET_MISC_PARAMETERS (CPU_CMD_MASK_CAPTURE | 0x0015) - -/* Description: Set raw VBI parameters - IN[0] - Task handle - IN[1] - No. of input lines per field: - bit[15:0]: field 1, - bit[31:16]: field 2 - IN[2] - No. of input bytes per line - IN[3] - No. of output frames per transfer - IN[4] - start code - IN[5] - stop code - ReturnCode */ -#define CX18_CPU_SET_RAW_VBI_PARAM (CPU_CMD_MASK_CAPTURE | 0x0016) - -/* Description: Set capture line No. - IN[0] - task handle. Handle of the task to start - IN[1] - height1 - IN[2] - height2 - ReturnCode - One of the ERR_CAPTURE_... */ -#define CX18_CPU_SET_CAPTURE_LINE_NO (CPU_CMD_MASK_CAPTURE | 0x0017) - -/* Description: Set copyright - IN[0] - task handle. Handle of the task to start - IN[1] - copyright - ReturnCode - One of the ERR_CAPTURE_... */ -#define CX18_CPU_SET_COPYRIGHT (CPU_CMD_MASK_CAPTURE | 0x0018) - -/* Description: Set audio PID - IN[0] - task handle. Handle of the task to start - IN[1] - PID - ReturnCode - One of the ERR_CAPTURE_... */ -#define CX18_CPU_SET_AUDIO_PID (CPU_CMD_MASK_CAPTURE | 0x0019) - -/* Description: Set video PID - IN[0] - task handle. Handle of the task to start - IN[1] - PID - ReturnCode - One of the ERR_CAPTURE_... */ -#define CX18_CPU_SET_VIDEO_PID (CPU_CMD_MASK_CAPTURE | 0x001A) - -/* Description: Set Vertical Crop Line - IN[0] - task handle. Handle of the task to start - IN[1] - Line - ReturnCode - One of the ERR_CAPTURE_... */ -#define CX18_CPU_SET_VER_CROP_LINE (CPU_CMD_MASK_CAPTURE | 0x001B) - -/* Description: Set COP structure - IN[0] - task handle. Handle of the task to start - IN[1] - M - IN[2] - N - ReturnCode - One of the ERR_CAPTURE_... */ -#define CX18_CPU_SET_GOP_STRUCTURE (CPU_CMD_MASK_CAPTURE | 0x001C) - -/* Description: Set Scene Change Detection - IN[0] - task handle. Handle of the task to start - IN[1] - scene change - ReturnCode - One of the ERR_CAPTURE_... */ -#define CX18_CPU_SET_SCENE_CHANGE_DETECTION (CPU_CMD_MASK_CAPTURE | 0x001D) - -/* Description: Set Aspect Ratio - IN[0] - task handle. Handle of the task to start - IN[1] - AspectRatio - ReturnCode - One of the ERR_CAPTURE_... */ -#define CX18_CPU_SET_ASPECT_RATIO (CPU_CMD_MASK_CAPTURE | 0x001E) - -/* Description: Set Skip Input Frame - IN[0] - task handle. Handle of the task to start - IN[1] - skip input frames - ReturnCode - One of the ERR_CAPTURE_... */ -#define CX18_CPU_SET_SKIP_INPUT_FRAME (CPU_CMD_MASK_CAPTURE | 0x001F) - -/* Description: Set sliced VBI parameters - - Note This API will only apply to MPEG and Sliced VBI Channels - IN[0] - Task handle - IN[1] - output type, 0 - CC, 1 - Moji, 2 - Teletext - IN[2] - start / stop line - bit[15:0] start line number - bit[31:16] stop line number - IN[3] - number of output frames per interrupt - IN[4] - VBI insertion mode - bit 0: output user data, 1 - enable - bit 1: output private stream, 1 - enable - bit 2: mux option, 0 - in GOP, 1 - in picture - bit[7:0] private stream ID - IN[5] - insertion period while mux option is in picture - ReturnCode - VBI data offset */ -#define CX18_CPU_SET_SLICED_VBI_PARAM (CPU_CMD_MASK_CAPTURE | 0x0020) - -/* Description: Set the user data place holder - IN[0] - type of data (0 for user) - IN[1] - Stuffing period - IN[2] - ID data size in word (less than 10) - IN[3] - Pointer to ID buffer */ -#define CX18_CPU_SET_USERDATA_PLACE_HOLDER (CPU_CMD_MASK_CAPTURE | 0x0021) - - -/* Description: - In[0] Task Handle - return parameter: - Out[0] Reserved - Out[1] Video PTS bit[32:2] of last output video frame. - Out[2] Video PTS bit[ 1:0] of last output video frame. - Out[3] Hardware Video PTS counter bit[31:0], - these bits get incremented on every 90kHz clock tick. - Out[4] Hardware Video PTS counter bit32, - these bits get incremented on every 90kHz clock tick. - ReturnCode */ -#define CX18_CPU_GET_ENC_PTS (CPU_CMD_MASK_CAPTURE | 0x0022) - -/* Below is the list of commands related to the data exchange */ -#define CPU_CMD_MASK_DE (CPU_CMD_MASK | 0x040000) - -/* Description: This command provides the physical base address of the local - DDR as viewed by EPU - IN[0] - Physical offset where EPU has the local DDR mapped - ReturnCode - One of the ERR_DE_... */ -#define CPU_CMD_DE_SetBase (CPU_CMD_MASK_DE | 0x0001) - -/* Description: This command provides the offsets in the device memory where - the 2 cx18_mdl_ack blocks reside - IN[0] - Task handle. Handle of the task to start - IN[1] - Offset of the first cx18_mdl_ack from the beginning of the - local DDR. - IN[2] - Offset of the second cx18_mdl_ack from the beginning of the - local DDR. - ReturnCode - One of the ERR_DE_... */ -#define CX18_CPU_DE_SET_MDL_ACK (CPU_CMD_MASK_DE | 0x0002) - -/* Description: This command provides the offset to a Memory Descriptor List - IN[0] - Task handle. Handle of the task to start - IN[1] - Offset of the MDL from the beginning of the local DDR. - IN[2] - Number of cx18_mdl structures in the array pointed to by IN[1] - IN[3] - Buffer ID - IN[4] - Total buffer length - ReturnCode - One of the ERR_DE_... */ -#define CX18_CPU_DE_SET_MDL (CPU_CMD_MASK_DE | 0x0005) - -/* Description: This command requests return of all current Memory - Descriptor Lists to the driver - IN[0] - Task handle. Handle of the task to start - ReturnCode - One of the ERR_DE_... */ -/* #define CX18_CPU_DE_ReleaseMDL (CPU_CMD_MASK_DE | 0x0006) */ - -/* Description: This command signals the cpu that the dat buffer has been - consumed and ready for re-use. - IN[0] - Task handle. Handle of the task - IN[1] - Offset of the data block from the beginning of the local DDR. - IN[2] - Number of bytes in the data block - ReturnCode - One of the ERR_DE_... */ -/* #define CX18_CPU_DE_RELEASE_BUFFER (CPU_CMD_MASK_DE | 0x0007) */ - -/* No Error / Success */ -#define CNXT_OK 0x000000 - -/* Received unknown command */ -#define CXERR_UNK_CMD 0x000001 - -/* First parameter in the command is invalid */ -#define CXERR_INVALID_PARAM1 0x000002 - -/* Second parameter in the command is invalid */ -#define CXERR_INVALID_PARAM2 0x000003 - -/* Device interface is not open/found */ -#define CXERR_DEV_NOT_FOUND 0x000004 - -/* Requested function is not implemented/available */ -#define CXERR_NOTSUPPORTED 0x000005 - -/* Invalid pointer is provided */ -#define CXERR_BADPTR 0x000006 - -/* Unable to allocate memory */ -#define CXERR_NOMEM 0x000007 - -/* Object/Link not found */ -#define CXERR_LINK 0x000008 - -/* Device busy, command cannot be executed */ -#define CXERR_BUSY 0x000009 - -/* File/device/handle is not open. */ -#define CXERR_NOT_OPEN 0x00000A - -/* Value is out of range */ -#define CXERR_OUTOFRANGE 0x00000B - -/* Buffer overflow */ -#define CXERR_OVERFLOW 0x00000C - -/* Version mismatch */ -#define CXERR_BADVER 0x00000D - -/* Operation timed out */ -#define CXERR_TIMEOUT 0x00000E - -/* Operation aborted */ -#define CXERR_ABORT 0x00000F - -/* Specified I2C device not found for read/write */ -#define CXERR_I2CDEV_NOTFOUND 0x000010 - -/* Error in I2C data xfer (but I2C device is present) */ -#define CXERR_I2CDEV_XFERERR 0x000011 - -/* Chanel changing component not ready */ -#define CXERR_CHANNELNOTREADY 0x000012 - -/* PPU (Presensation/Decoder) mail box is corrupted */ -#define CXERR_PPU_MB_CORRUPT 0x000013 - -/* CPU (Capture/Encoder) mail box is corrupted */ -#define CXERR_CPU_MB_CORRUPT 0x000014 - -/* APU (Audio) mail box is corrupted */ -#define CXERR_APU_MB_CORRUPT 0x000015 - -/* Unable to open file for reading */ -#define CXERR_FILE_OPEN_READ 0x000016 - -/* Unable to open file for writing */ -#define CXERR_FILE_OPEN_WRITE 0x000017 - -/* Unable to find the I2C section specified */ -#define CXERR_I2C_BADSECTION 0x000018 - -/* Error in I2C data xfer (but I2C device is present) */ -#define CXERR_I2CDEV_DATALOW 0x000019 - -/* Error in I2C data xfer (but I2C device is present) */ -#define CXERR_I2CDEV_CLOCKLOW 0x00001A - -/* No Interrupt received from HW (for I2C access) */ -#define CXERR_NO_HW_I2C_INTR 0x00001B - -/* RPU is not ready to accept commands! */ -#define CXERR_RPU_NOT_READY 0x00001C - -/* RPU is not ready to accept commands! */ -#define CXERR_RPU_NO_ACK 0x00001D - -/* The are no buffers ready. Try again soon! */ -#define CXERR_NODATA_AGAIN 0x00001E - -/* The stream is stopping. Function not alllowed now! */ -#define CXERR_STOPPING_STATUS 0x00001F - -/* Trying to access hardware when the power is turned OFF */ -#define CXERR_DEVPOWER_OFF 0x000020 - -#endif /* CX23418_H */ diff --git a/trunk/drivers/media/video/cx23885/Kconfig b/trunk/drivers/media/video/cx23885/Kconfig index cadf936c3673..ca5fbce3a909 100644 --- a/trunk/drivers/media/video/cx23885/Kconfig +++ b/trunk/drivers/media/video/cx23885/Kconfig @@ -4,19 +4,19 @@ config VIDEO_CX23885 select I2C_ALGOBIT select FW_LOADER select VIDEO_BTCX - select MEDIA_TUNER + select VIDEO_TUNER select VIDEO_TVEEPROM select VIDEO_IR select VIDEOBUF_DVB select VIDEO_CX25840 - select MEDIA_TUNER_MT2131 if !DVB_FE_CUSTOMISE + select DVB_TUNER_MT2131 if !DVB_FE_CUSTOMISE select DVB_S5H1409 if !DVB_FE_CUSTOMISE select DVB_LGDT330X if !DVB_FE_CUSTOMISE select DVB_PLL if !DVB_FE_CUSTOMISE - select MEDIA_TUNER_XC2028 if !DVB_FE_CUSTOMIZE - select MEDIA_TUNER_TDA8290 if !DVB_FE_CUSTOMIZE - select MEDIA_TUNER_TDA18271 if !DVB_FE_CUSTOMIZE - select MEDIA_TUNER_XC5000 if !DVB_FE_CUSTOMIZE + select TUNER_XC2028 if !DVB_FE_CUSTOMIZE + select TUNER_TDA8290 if !DVB_FE_CUSTOMIZE + select DVB_TDA18271 if !DVB_FE_CUSTOMIZE + select DVB_TUNER_XC5000 if !DVB_FE_CUSTOMIZE select DVB_TDA10048 if !DVB_FE_CUSTOMIZE ---help--- This is a video4linux driver for Conexant 23885 based diff --git a/trunk/drivers/media/video/cx23885/Makefile b/trunk/drivers/media/video/cx23885/Makefile index 29c23b44c13c..d7b0721af062 100644 --- a/trunk/drivers/media/video/cx23885/Makefile +++ b/trunk/drivers/media/video/cx23885/Makefile @@ -3,7 +3,6 @@ cx23885-objs := cx23885-cards.o cx23885-video.o cx23885-vbi.o cx23885-core.o cx2 obj-$(CONFIG_VIDEO_CX23885) += cx23885.o EXTRA_CFLAGS += -Idrivers/media/video -EXTRA_CFLAGS += -Idrivers/media/common/tuners EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core EXTRA_CFLAGS += -Idrivers/media/dvb/frontends diff --git a/trunk/drivers/media/video/cx25840/cx25840-core.c b/trunk/drivers/media/video/cx25840/cx25840-core.c index 88823810497c..7fde678b2c4a 100644 --- a/trunk/drivers/media/video/cx25840/cx25840-core.c +++ b/trunk/drivers/media/video/cx25840/cx25840-core.c @@ -1209,8 +1209,7 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd, /* ----------------------------------------------------------------------- */ -static int cx25840_probe(struct i2c_client *client, - const struct i2c_device_id *did) +static int cx25840_probe(struct i2c_client *client) { struct cx25840_state *state; u32 id; diff --git a/trunk/drivers/media/video/cx88/Kconfig b/trunk/drivers/media/video/cx88/Kconfig index b0d7d6a7a4cc..27635cdcbaf2 100644 --- a/trunk/drivers/media/video/cx88/Kconfig +++ b/trunk/drivers/media/video/cx88/Kconfig @@ -5,7 +5,7 @@ config VIDEO_CX88 select FW_LOADER select VIDEO_BTCX select VIDEOBUF_DMA_SG - select MEDIA_TUNER + select VIDEO_TUNER select VIDEO_TVEEPROM select VIDEO_IR select VIDEO_WM8775 if VIDEO_HELPER_CHIPS_AUTO @@ -57,7 +57,7 @@ config VIDEO_CX88_DVB select DVB_NXT200X if !DVB_FE_CUSTOMISE select DVB_CX24123 if !DVB_FE_CUSTOMISE select DVB_ISL6421 if !DVB_FE_CUSTOMISE - select MEDIA_TUNER_SIMPLE if !DVB_FE_CUSTOMISE + select TUNER_SIMPLE if !DVB_FE_CUSTOMISE select DVB_S5H1411 if !DVB_FE_CUSTOMISE ---help--- This adds support for DVB/ATSC cards based on the diff --git a/trunk/drivers/media/video/cx88/Makefile b/trunk/drivers/media/video/cx88/Makefile index 6ec30f242578..532cee35eb3c 100644 --- a/trunk/drivers/media/video/cx88/Makefile +++ b/trunk/drivers/media/video/cx88/Makefile @@ -10,6 +10,5 @@ obj-$(CONFIG_VIDEO_CX88_DVB) += cx88-dvb.o obj-$(CONFIG_VIDEO_CX88_VP3054) += cx88-vp3054-i2c.o EXTRA_CFLAGS += -Idrivers/media/video -EXTRA_CFLAGS += -Idrivers/media/common/tuners EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core EXTRA_CFLAGS += -Idrivers/media/dvb/frontends diff --git a/trunk/drivers/media/video/cx88/cx88-cards.c b/trunk/drivers/media/video/cx88/cx88-cards.c index aeba26dc0a37..2b6b283cda15 100644 --- a/trunk/drivers/media/video/cx88/cx88-cards.c +++ b/trunk/drivers/media/video/cx88/cx88-cards.c @@ -57,9 +57,6 @@ MODULE_PARM_DESC(latency,"pci latency timer"); /* ------------------------------------------------------------------ */ /* board config info */ -/* If radio_type !=UNSET, radio_addr should be specified - */ - static const struct cx88_board cx88_boards[] = { [CX88_BOARD_UNKNOWN] = { .name = "UNKNOWN/GENERIC", @@ -2449,31 +2446,25 @@ EXPORT_SYMBOL_GPL(cx88_setup_xc3028); static void cx88_card_setup(struct cx88_core *core) { static u8 eeprom[256]; - struct tuner_setup tun_setup; - unsigned int mode_mask = T_RADIO | - T_ANALOG_TV | - T_DIGITAL_TV; - - memset(&tun_setup, 0, sizeof(tun_setup)); if (0 == core->i2c_rc) { core->i2c_client.addr = 0xa0 >> 1; - tveeprom_read(&core->i2c_client, eeprom, sizeof(eeprom)); + tveeprom_read(&core->i2c_client,eeprom,sizeof(eeprom)); } switch (core->boardnr) { case CX88_BOARD_HAUPPAUGE: case CX88_BOARD_HAUPPAUGE_ROSLYN: if (0 == core->i2c_rc) - hauppauge_eeprom(core, eeprom+8); + hauppauge_eeprom(core,eeprom+8); break; case CX88_BOARD_GDI: if (0 == core->i2c_rc) - gdi_eeprom(core, eeprom); + gdi_eeprom(core,eeprom); break; case CX88_BOARD_WINFAST2000XP_EXPERT: if (0 == core->i2c_rc) - leadtek_eeprom(core, eeprom); + leadtek_eeprom(core,eeprom); break; case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: case CX88_BOARD_HAUPPAUGE_NOVASE2_S1: @@ -2483,7 +2474,7 @@ static void cx88_card_setup(struct cx88_core *core) case CX88_BOARD_HAUPPAUGE_HVR3000: case CX88_BOARD_HAUPPAUGE_HVR1300: if (0 == core->i2c_rc) - hauppauge_eeprom(core, eeprom); + hauppauge_eeprom(core,eeprom); break; case CX88_BOARD_KWORLD_DVBS_100: cx_write(MO_GP0_IO, 0x000007f8); @@ -2564,35 +2555,6 @@ static void cx88_card_setup(struct cx88_core *core) cx88_call_i2c_clients(core, TUNER_SET_CONFIG, &tea5767_cfg); } - } /*end switch() */ - - - /* Setup tuners */ - if ((core->board.radio_type != UNSET)) { - tun_setup.mode_mask = T_RADIO; - tun_setup.type = core->board.radio_type; - tun_setup.addr = core->board.radio_addr; - tun_setup.tuner_callback = cx88_tuner_callback; - cx88_call_i2c_clients(core, TUNER_SET_TYPE_ADDR, &tun_setup); - mode_mask &= ~T_RADIO; - } - - if (core->board.tuner_type != TUNER_ABSENT) { - tun_setup.mode_mask = mode_mask; - tun_setup.type = core->board.tuner_type; - tun_setup.addr = core->board.tuner_addr; - tun_setup.tuner_callback = cx88_tuner_callback; - - cx88_call_i2c_clients(core, TUNER_SET_TYPE_ADDR, &tun_setup); - } - - if (core->board.tda9887_conf) { - struct v4l2_priv_tun_config tda9887_cfg; - - tda9887_cfg.tuner = TUNER_TDA9887; - tda9887_cfg.priv = &core->board.tda9887_conf; - - cx88_call_i2c_clients(core, TUNER_SET_CONFIG, &tda9887_cfg); } if (core->board.tuner_type == TUNER_XC2028) { @@ -2610,7 +2572,6 @@ static void cx88_card_setup(struct cx88_core *core) ctl.fname); cx88_call_i2c_clients(core, TUNER_SET_CONFIG, &xc2028_cfg); } - cx88_call_i2c_clients (core, TUNER_SET_STANDBY, NULL); } /* ------------------------------------------------------------------ */ @@ -2749,6 +2710,7 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr) if (TUNER_ABSENT != core->board.tuner_type) request_module("tuner"); + cx88_call_i2c_clients (core, TUNER_SET_STANDBY, NULL); cx88_card_setup(core); cx88_ir_init(core, pci); diff --git a/trunk/drivers/media/video/cx88/cx88-i2c.c b/trunk/drivers/media/video/cx88/cx88-i2c.c index 00aa7a3f1105..c6b44732a082 100644 --- a/trunk/drivers/media/video/cx88/cx88-i2c.c +++ b/trunk/drivers/media/video/cx88/cx88-i2c.c @@ -104,7 +104,37 @@ static int attach_inform(struct i2c_client *client) dprintk(1, "%s i2c attach [addr=0x%x,client=%s]\n", client->driver->driver.name, client->addr, client->name); + if (!client->driver->command) + return 0; + + if (core->board.radio_type != UNSET) { + if ((core->board.radio_addr==ADDR_UNSET)||(core->board.radio_addr==client->addr)) { + tun_setup.mode_mask = T_RADIO; + tun_setup.type = core->board.radio_type; + tun_setup.addr = core->board.radio_addr; + tun_setup.tuner_callback = cx88_tuner_callback; + client->driver->command (client, TUNER_SET_TYPE_ADDR, &tun_setup); + } + } + if (core->board.tuner_type != UNSET) { + if ((core->board.tuner_addr==ADDR_UNSET)||(core->board.tuner_addr==client->addr)) { + + tun_setup.mode_mask = T_ANALOG_TV; + tun_setup.type = core->board.tuner_type; + tun_setup.addr = core->board.tuner_addr; + tun_setup.tuner_callback = cx88_tuner_callback; + client->driver->command (client,TUNER_SET_TYPE_ADDR, &tun_setup); + } + } + + if (core->board.tda9887_conf) { + struct v4l2_priv_tun_config tda9887_cfg; + tda9887_cfg.tuner = TUNER_TDA9887; + tda9887_cfg.priv = &core->board.tda9887_conf; + + client->driver->command(client, TUNER_SET_CONFIG, &tda9887_cfg); + } return 0; } diff --git a/trunk/drivers/media/video/em28xx/Kconfig b/trunk/drivers/media/video/em28xx/Kconfig index c7c2896bbd8b..9caffed2b6b8 100644 --- a/trunk/drivers/media/video/em28xx/Kconfig +++ b/trunk/drivers/media/video/em28xx/Kconfig @@ -1,7 +1,7 @@ config VIDEO_EM28XX tristate "Empia EM28xx USB video capture support" depends on VIDEO_DEV && I2C && INPUT - select MEDIA_TUNER + select VIDEO_TUNER select VIDEO_TVEEPROM select VIDEO_IR select VIDEOBUF_VMALLOC diff --git a/trunk/drivers/media/video/em28xx/Makefile b/trunk/drivers/media/video/em28xx/Makefile index 8137a8c94bfc..3d1c3cc337fe 100644 --- a/trunk/drivers/media/video/em28xx/Makefile +++ b/trunk/drivers/media/video/em28xx/Makefile @@ -8,7 +8,6 @@ obj-$(CONFIG_VIDEO_EM28XX_ALSA) += em28xx-alsa.o obj-$(CONFIG_VIDEO_EM28XX_DVB) += em28xx-dvb.o EXTRA_CFLAGS += -Idrivers/media/video -EXTRA_CFLAGS += -Idrivers/media/common/tuners EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core EXTRA_CFLAGS += -Idrivers/media/dvb/frontends diff --git a/trunk/drivers/media/video/ivtv/Kconfig b/trunk/drivers/media/video/ivtv/Kconfig index eec115bf9517..b6171702c4d0 100644 --- a/trunk/drivers/media/video/ivtv/Kconfig +++ b/trunk/drivers/media/video/ivtv/Kconfig @@ -4,7 +4,7 @@ config VIDEO_IVTV select I2C_ALGOBIT select FW_LOADER select VIDEO_IR - select MEDIA_TUNER + select VIDEO_TUNER select VIDEO_TVEEPROM select VIDEO_CX2341X select VIDEO_CX25840 diff --git a/trunk/drivers/media/video/ivtv/Makefile b/trunk/drivers/media/video/ivtv/Makefile index 26ce0d6eaee1..a0389014fa88 100644 --- a/trunk/drivers/media/video/ivtv/Makefile +++ b/trunk/drivers/media/video/ivtv/Makefile @@ -8,7 +8,6 @@ obj-$(CONFIG_VIDEO_IVTV) += ivtv.o obj-$(CONFIG_VIDEO_FB_IVTV) += ivtvfb.o EXTRA_CFLAGS += -Idrivers/media/video -EXTRA_CFLAGS += -Idrivers/media/common/tuners EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core EXTRA_CFLAGS += -Idrivers/media/dvb/frontends diff --git a/trunk/drivers/media/video/ivtv/ivtv-cards.c b/trunk/drivers/media/video/ivtv/ivtv-cards.c index 4fb8faefe2ce..e908649ea37c 100644 --- a/trunk/drivers/media/video/ivtv/ivtv-cards.c +++ b/trunk/drivers/media/video/ivtv/ivtv-cards.c @@ -40,8 +40,6 @@ #define MSP_MONO MSP_INPUT(MSP_IN_MONO, MSP_IN_TUNER1, \ MSP_DSP_IN_SCART, MSP_DSP_IN_SCART) -#define V4L2_STD_NOT_MN (V4L2_STD_PAL|V4L2_STD_SECAM) - /* usual i2c tuner addresses to probe */ static struct ivtv_card_tuner_i2c ivtv_i2c_std = { .radio = { I2C_CLIENT_END }, @@ -300,7 +298,7 @@ static const struct ivtv_card ivtv_card_mpg600 = { .gpio_audio_detect = { .mask = 0x0900, .stereo = 0x0100 }, .tuners = { /* The PAL tuner is confirmed */ - { .std = V4L2_STD_NOT_MN, .tuner = TUNER_PHILIPS_FQ1216ME }, + { .std = V4L2_STD_625_50, .tuner = TUNER_PHILIPS_FQ1216ME }, { .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_FQ1286 }, }, .pci_list = ivtv_pci_mpg600, @@ -341,7 +339,7 @@ static const struct ivtv_card ivtv_card_mpg160 = { .lang1 = 0x0004, .lang2 = 0x0000, .both = 0x0008 }, .gpio_audio_detect = { .mask = 0x0900, .stereo = 0x0100 }, .tuners = { - { .std = V4L2_STD_NOT_MN, .tuner = TUNER_PHILIPS_FQ1216ME }, + { .std = V4L2_STD_625_50, .tuner = TUNER_PHILIPS_FQ1216ME }, { .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_FQ1286 }, }, .pci_list = ivtv_pci_mpg160, @@ -377,7 +375,7 @@ static const struct ivtv_card ivtv_card_pg600 = { { IVTV_CARD_INPUT_LINE_IN1, CX25840_AUDIO_SERIAL }, }, .tuners = { - { .std = V4L2_STD_NOT_MN, .tuner = TUNER_PHILIPS_FQ1216ME }, + { .std = V4L2_STD_625_50, .tuner = TUNER_PHILIPS_FQ1216ME }, { .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_FQ1286 }, }, .pci_list = ivtv_pci_pg600, @@ -418,7 +416,7 @@ static const struct ivtv_card ivtv_card_avc2410 = { on the country/region setting of the user to decide which tuner is available. */ .tuners = { - { .std = V4L2_STD_NOT_MN, .tuner = TUNER_PHILIPS_FM1216ME_MK3 }, + { .std = V4L2_STD_625_50, .tuner = TUNER_PHILIPS_FM1216ME_MK3 }, { .std = V4L2_STD_ALL - V4L2_STD_NTSC_M_JP, .tuner = TUNER_PHILIPS_FM1236_MK3 }, { .std = V4L2_STD_NTSC_M_JP, .tuner = TUNER_PHILIPS_FQ1286 }, @@ -492,7 +490,7 @@ static const struct ivtv_card ivtv_card_tg5000tv = { .gpio_video_input = { .mask = 0x0030, .tuner = 0x0000, .composite = 0x0010, .svideo = 0x0020 }, .tuners = { - { .std = V4L2_STD_525_60|V4L2_STD_MN, .tuner = TUNER_PHILIPS_FQ1286 }, + { .std = V4L2_STD_525_60, .tuner = TUNER_PHILIPS_FQ1286 }, }, .pci_list = ivtv_pci_tg5000tv, .i2c = &ivtv_i2c_std, @@ -523,7 +521,7 @@ static const struct ivtv_card ivtv_card_va2000 = { { IVTV_CARD_INPUT_AUD_TUNER, MSP_TUNER }, }, .tuners = { - { .std = V4L2_STD_525_60|V4L2_STD_MN, .tuner = TUNER_PHILIPS_FQ1286 }, + { .std = V4L2_STD_525_60, .tuner = TUNER_PHILIPS_FQ1286 }, }, .pci_list = ivtv_pci_va2000, .i2c = &ivtv_i2c_std, @@ -567,7 +565,7 @@ static const struct ivtv_card ivtv_card_cx23416gyc = { .gpio_audio_freq = { .mask = 0xc000, .f32000 = 0x0000, .f44100 = 0x4000, .f48000 = 0x8000 }, .tuners = { - { .std = V4L2_STD_NOT_MN, .tuner = TUNER_PHILIPS_FM1216ME_MK3 }, + { .std = V4L2_STD_625_50, .tuner = TUNER_PHILIPS_FM1216ME_MK3 }, { .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_FM1236_MK3 }, }, .pci_list = ivtv_pci_cx23416gyc, @@ -599,7 +597,7 @@ static const struct ivtv_card ivtv_card_cx23416gyc_nogr = { .gpio_audio_freq = { .mask = 0xc000, .f32000 = 0x0000, .f44100 = 0x4000, .f48000 = 0x8000 }, .tuners = { - { .std = V4L2_STD_NOT_MN, .tuner = TUNER_PHILIPS_FM1216ME_MK3 }, + { .std = V4L2_STD_625_50, .tuner = TUNER_PHILIPS_FM1216ME_MK3 }, { .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_FM1236_MK3 }, }, .i2c = &ivtv_i2c_std, @@ -629,7 +627,7 @@ static const struct ivtv_card ivtv_card_cx23416gyc_nogrycs = { .gpio_audio_freq = { .mask = 0xc000, .f32000 = 0x0000, .f44100 = 0x4000, .f48000 = 0x8000 }, .tuners = { - { .std = V4L2_STD_NOT_MN, .tuner = TUNER_PHILIPS_FM1216ME_MK3 }, + { .std = V4L2_STD_625_50, .tuner = TUNER_PHILIPS_FM1216ME_MK3 }, { .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_FM1236_MK3 }, }, .i2c = &ivtv_i2c_std, @@ -669,7 +667,7 @@ static const struct ivtv_card ivtv_card_gv_mvprx = { .gpio_audio_input = { .mask = 0xffff, .tuner = 0x0200, .linein = 0x0300 }, .tuners = { /* This card has the Panasonic VP27 tuner */ - { .std = V4L2_STD_525_60|V4L2_STD_MN, .tuner = TUNER_PANASONIC_VP27 }, + { .std = V4L2_STD_525_60, .tuner = TUNER_PANASONIC_VP27 }, }, .pci_list = ivtv_pci_gv_mvprx, .i2c = &ivtv_i2c_std, @@ -706,7 +704,7 @@ static const struct ivtv_card ivtv_card_gv_mvprx2e = { .gpio_audio_input = { .mask = 0xffff, .tuner = 0x0200, .linein = 0x0300 }, .tuners = { /* This card has the Panasonic VP27 tuner */ - { .std = V4L2_STD_525_60|V4L2_STD_MN, .tuner = TUNER_PANASONIC_VP27 }, + { .std = V4L2_STD_525_60, .tuner = TUNER_PANASONIC_VP27 }, }, .pci_list = ivtv_pci_gv_mvprx2e, .i2c = &ivtv_i2c_std, @@ -741,7 +739,7 @@ static const struct ivtv_card ivtv_card_gotview_pci_dvd = { .gpio_init = { .direction = 0xf000, .initial_value = 0xA000 }, .tuners = { /* This card has a Philips FQ1216ME MK3 tuner */ - { .std = V4L2_STD_NOT_MN, .tuner = TUNER_PHILIPS_FM1216ME_MK3 }, + { .std = V4L2_STD_625_50, .tuner = TUNER_PHILIPS_FM1216ME_MK3 }, }, .pci_list = ivtv_pci_gotview_pci_dvd, .i2c = &ivtv_i2c_std, @@ -780,7 +778,7 @@ static const struct ivtv_card ivtv_card_gotview_pci_dvd2 = { .gpio_audio_input = { .mask = 0x0800, .tuner = 0, .linein = 0, .radio = 0x0800 }, .tuners = { /* This card has a Philips FQ1216ME MK5 tuner */ - { .std = V4L2_STD_NOT_MN, .tuner = TUNER_PHILIPS_FM1216ME_MK3 }, + { .std = V4L2_STD_625_50, .tuner = TUNER_PHILIPS_FM1216ME_MK3 }, }, .pci_list = ivtv_pci_gotview_pci_dvd2, .i2c = &ivtv_i2c_std, @@ -858,7 +856,7 @@ static const struct ivtv_card ivtv_card_dctmvtvp1 = { .gpio_video_input = { .mask = 0x0030, .tuner = 0x0000, .composite = 0x0010, .svideo = 0x0020}, .tuners = { - { .std = V4L2_STD_525_60|V4L2_STD_MN, .tuner = TUNER_PHILIPS_FQ1286 }, + { .std = V4L2_STD_525_60, .tuner = TUNER_PHILIPS_FQ1286 }, }, .pci_list = ivtv_pci_dctmvtvp1, .i2c = &ivtv_i2c_std, @@ -877,7 +875,6 @@ static const struct ivtv_card_pci_info ivtv_pci_pg600v2[] = { static const struct ivtv_card ivtv_card_pg600v2 = { .type = IVTV_CARD_PG600V2, .name = "Yuan PG600-2, GotView PCI DVD Lite", - .comment = "only Composite and S-Video inputs are supported, not the tuner\n", .v4l2_capabilities = IVTV_CAP_ENCODER, .hw_video = IVTV_HW_CX25840, .hw_audio = IVTV_HW_CX25840, @@ -924,7 +921,6 @@ static const struct ivtv_card ivtv_card_club3d = { }, .radio_input = { IVTV_CARD_INPUT_AUD_TUNER, CX25840_AUDIO5 }, .gpio_init = { .direction = 0x1000, .initial_value = 0x1000 }, /* tuner reset */ - .xceive_pin = 12, .tuners = { { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 }, }, @@ -948,22 +944,15 @@ static const struct ivtv_card ivtv_card_avertv_mce116 = { .hw_video = IVTV_HW_CX25840, .hw_audio = IVTV_HW_CX25840, .hw_audio_ctrl = IVTV_HW_CX25840, - .hw_all = IVTV_HW_CX25840 | IVTV_HW_TUNER | IVTV_HW_WM8739, + .hw_all = IVTV_HW_CX25840 | IVTV_HW_WM8739, .video_inputs = { - { IVTV_CARD_INPUT_VID_TUNER, 0, CX25840_COMPOSITE2 }, - { IVTV_CARD_INPUT_SVIDEO1, 1, CX25840_SVIDEO3 }, - { IVTV_CARD_INPUT_COMPOSITE1, 1, CX25840_COMPOSITE1 }, + { IVTV_CARD_INPUT_SVIDEO1, 0, CX25840_SVIDEO3 }, + { IVTV_CARD_INPUT_COMPOSITE1, 0, CX25840_COMPOSITE1 }, }, .audio_inputs = { - { IVTV_CARD_INPUT_AUD_TUNER, CX25840_AUDIO5 }, { IVTV_CARD_INPUT_LINE_IN1, CX25840_AUDIO_SERIAL, 1 }, }, - /* enable line-in */ - .gpio_init = { .direction = 0xe400, .initial_value = 0x4400 }, - .xceive_pin = 10, - .tuners = { - { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 }, - }, + .gpio_init = { .direction = 0xe000, .initial_value = 0x4000 }, /* enable line-in */ .pci_list = ivtv_pci_avertv_mce116, .i2c = &ivtv_i2c_std, }; @@ -1001,7 +990,7 @@ static const struct ivtv_card ivtv_card_aver_pvr150 = { .gpio_audio_input = { .mask = 0x0800, .tuner = 0, .linein = 0, .radio = 0x0800 }, .tuners = { /* This card has a Partsnic PTI-5NF05 tuner */ - { .std = V4L2_STD_525_60|V4L2_STD_MN, .tuner = TUNER_TCL_2002N }, + { .std = V4L2_STD_525_60, .tuner = TUNER_TCL_2002N }, }, .pci_list = ivtv_pci_aver_pvr150, .i2c = &ivtv_i2c_radio, @@ -1069,48 +1058,12 @@ static const struct ivtv_card ivtv_card_asus_falcon2 = { }, .radio_input = { IVTV_CARD_INPUT_AUD_TUNER, CX25840_AUDIO_SERIAL, M52790_IN_TUNER }, .tuners = { - { .std = V4L2_STD_525_60|V4L2_STD_MN, .tuner = TUNER_PHILIPS_FM1236_MK3 }, + { .std = V4L2_STD_525_60, .tuner = TUNER_PHILIPS_FM1236_MK3 }, }, .pci_list = ivtv_pci_asus_falcon2, .i2c = &ivtv_i2c_std, }; -/* ------------------------------------------------------------------------- */ - -/* AVerMedia M104 miniPCI card */ - -static const struct ivtv_card_pci_info ivtv_pci_aver_m104[] = { - { PCI_DEVICE_ID_IVTV16, IVTV_PCI_ID_AVERMEDIA, 0xc136 }, - { 0, 0, 0 } -}; - -static const struct ivtv_card ivtv_card_aver_m104 = { - .type = IVTV_CARD_AVER_M104, - .name = "AVerMedia M104", - .comment = "Not yet supported!\n", - .v4l2_capabilities = 0, /*IVTV_CAP_ENCODER,*/ - .hw_video = IVTV_HW_CX25840, - .hw_audio = IVTV_HW_CX25840, - .hw_audio_ctrl = IVTV_HW_CX25840, - .hw_all = IVTV_HW_CX25840 | IVTV_HW_TUNER | IVTV_HW_WM8739, - .video_inputs = { - { IVTV_CARD_INPUT_SVIDEO1, 0, CX25840_SVIDEO3 }, - { IVTV_CARD_INPUT_COMPOSITE1, 0, CX25840_COMPOSITE1 }, - }, - .audio_inputs = { - { IVTV_CARD_INPUT_LINE_IN1, CX25840_AUDIO_SERIAL, 1 }, - }, - .radio_input = { IVTV_CARD_INPUT_AUD_TUNER, CX25840_AUDIO_SERIAL, 2 }, - /* enable line-in + reset tuner */ - .gpio_init = { .direction = 0xe400, .initial_value = 0x4000 }, - .xceive_pin = 10, - .tuners = { - { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 }, - }, - .pci_list = ivtv_pci_aver_m104, - .i2c = &ivtv_i2c_std, -}; - static const struct ivtv_card *ivtv_card_list[] = { &ivtv_card_pvr250, &ivtv_card_pvr350, @@ -1136,7 +1089,6 @@ static const struct ivtv_card *ivtv_card_list[] = { &ivtv_card_asus_falcon2, &ivtv_card_aver_pvr150, &ivtv_card_aver_ezmaker, - &ivtv_card_aver_m104, /* Variations of standard cards but with the same PCI IDs. These cards must come last in this list. */ @@ -1168,8 +1120,7 @@ int ivtv_get_input(struct ivtv *itv, u16 index, struct v4l2_input *input) if (index >= itv->nof_inputs) return -EINVAL; input->index = index; - strlcpy(input->name, input_strs[card_input->video_type - 1], - sizeof(input->name)); + strcpy(input->name, input_strs[card_input->video_type - 1]); input->type = (card_input->video_type == IVTV_CARD_INPUT_VID_TUNER ? V4L2_INPUT_TYPE_TUNER : V4L2_INPUT_TYPE_CAMERA); input->audioset = (1 << itv->nof_audio_inputs) - 1; @@ -1186,7 +1137,7 @@ int ivtv_get_output(struct ivtv *itv, u16 index, struct v4l2_output *output) if (index >= itv->card->nof_outputs) return -EINVAL; output->index = index; - strlcpy(output->name, card_output->name, sizeof(output->name)); + strcpy(output->name, card_output->name); output->type = V4L2_OUTPUT_TYPE_ANALOG; output->audioset = 1; output->std = V4L2_STD_ALL; @@ -1205,8 +1156,7 @@ int ivtv_get_audio_input(struct ivtv *itv, u16 index, struct v4l2_audio *audio) memset(audio, 0, sizeof(*audio)); if (index >= itv->nof_audio_inputs) return -EINVAL; - strlcpy(audio->name, input_strs[aud_input->audio_type - 1], - sizeof(audio->name)); + strcpy(audio->name, input_strs[aud_input->audio_type - 1]); audio->index = index; audio->capability = V4L2_AUDCAP_STEREO; return 0; @@ -1217,6 +1167,6 @@ int ivtv_get_audio_output(struct ivtv *itv, u16 index, struct v4l2_audioout *aud memset(aud_output, 0, sizeof(*aud_output)); if (itv->card->video_outputs == NULL || index != 0) return -EINVAL; - strlcpy(aud_output->name, "A/V Audio Out", sizeof(aud_output->name)); + strcpy(aud_output->name, "A/V Audio Out"); return 0; } diff --git a/trunk/drivers/media/video/ivtv/ivtv-cards.h b/trunk/drivers/media/video/ivtv/ivtv-cards.h index 748485dcebbd..9186fa2ee5fc 100644 --- a/trunk/drivers/media/video/ivtv/ivtv-cards.h +++ b/trunk/drivers/media/video/ivtv/ivtv-cards.h @@ -48,8 +48,7 @@ #define IVTV_CARD_ASUS_FALCON2 21 /* ASUS Falcon2 */ #define IVTV_CARD_AVER_PVR150PLUS 22 /* AVerMedia PVR-150 Plus */ #define IVTV_CARD_AVER_EZMAKER 23 /* AVerMedia EZMaker PCI Deluxe */ -#define IVTV_CARD_AVER_M104 24 /* AverMedia M104 miniPCI card */ -#define IVTV_CARD_LAST 24 +#define IVTV_CARD_LAST 23 /* Variants of existing cards but with the same PCI IDs. The driver detects these based on other device information. @@ -245,7 +244,6 @@ struct ivtv_card_tuner_i2c { struct ivtv_card { int type; char *name; - char *comment; u32 v4l2_capabilities; u32 hw_video; /* hardware used to process video */ u32 hw_audio; /* hardware used to process audio */ @@ -258,7 +256,6 @@ struct ivtv_card { int nof_outputs; const struct ivtv_card_output *video_outputs; u8 gr_config; /* config byte for the ghost reduction device */ - u8 xceive_pin; /* XCeive tuner GPIO reset pin */ /* GPIO card-specific settings */ struct ivtv_gpio_init gpio_init; diff --git a/trunk/drivers/media/video/ivtv/ivtv-driver.c b/trunk/drivers/media/video/ivtv/ivtv-driver.c index 47b5649729df..065df53f80fd 100644 --- a/trunk/drivers/media/video/ivtv/ivtv-driver.c +++ b/trunk/drivers/media/video/ivtv/ivtv-driver.c @@ -190,7 +190,6 @@ MODULE_PARM_DESC(cardtype, "\t\t\t22 = ASUS Falcon2\n" "\t\t\t23 = AverMedia PVR-150 Plus\n" "\t\t\t24 = AverMedia EZMaker PCI Deluxe\n" - "\t\t\t25 = AverMedia M104 (not yet working)\n" "\t\t\t 0 = Autodetect (default)\n" "\t\t\t-1 = Ignore this card\n\t\t"); MODULE_PARM_DESC(pal, "Set PAL standard: BGH, DK, I, M, N, Nc, 60"); @@ -872,7 +871,7 @@ static void ivtv_load_and_init_modules(struct ivtv *itv) unsigned i; /* load modules */ -#ifndef CONFIG_MEDIA_TUNER +#ifndef CONFIG_VIDEO_TUNER hw = ivtv_request_module(itv, hw, "tuner", IVTV_HW_TUNER); #endif #ifndef CONFIG_VIDEO_CX25840 @@ -1098,13 +1097,6 @@ static int __devinit ivtv_probe(struct pci_dev *dev, The PCI IDs are not always reliable. */ ivtv_process_eeprom(itv); } - if (itv->card->comment) - IVTV_INFO("%s", itv->card->comment); - if (itv->card->v4l2_capabilities == 0) { - /* card was detected but is not supported */ - retval = -ENODEV; - goto free_i2c; - } if (itv->std == 0) { itv->std = V4L2_STD_NTSC_M; @@ -1203,6 +1195,13 @@ static int __devinit ivtv_probe(struct pci_dev *dev, ivtv_call_i2c_clients(itv, VIDIOC_INT_S_STD_OUTPUT, &itv->std); } + retval = ivtv_streams_setup(itv); + if (retval) { + IVTV_ERR("Error %d setting up streams\n", retval); + goto free_i2c; + } + + IVTV_DEBUG_IRQ("Masking interrupts\n"); /* clear interrupt mask, effectively disabling interrupts */ ivtv_set_irq_mask(itv, 0xffffffff); @@ -1211,38 +1210,32 @@ static int __devinit ivtv_probe(struct pci_dev *dev, IRQF_SHARED | IRQF_DISABLED, itv->name, (void *)itv); if (retval) { IVTV_ERR("Failed to register irq %d\n", retval); - goto free_i2c; - } - - retval = ivtv_streams_setup(itv); - if (retval) { - IVTV_ERR("Error %d setting up streams\n", retval); - goto free_irq; + goto free_streams; } retval = ivtv_streams_register(itv); if (retval) { IVTV_ERR("Error %d registering devices\n", retval); - goto free_streams; + goto free_irq; } IVTV_INFO("Initialized card #%d: %s\n", itv->num, itv->card_name); return 0; -free_streams: - ivtv_streams_cleanup(itv); -free_irq: + free_irq: free_irq(itv->dev->irq, (void *)itv); -free_i2c: + free_streams: + ivtv_streams_cleanup(itv); + free_i2c: exit_ivtv_i2c(itv); -free_io: + free_io: ivtv_iounmap(itv); -free_mem: + free_mem: release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE); release_mem_region(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE); if (itv->has_cx23415) release_mem_region(itv->base_addr + IVTV_DECODER_OFFSET, IVTV_DECODER_SIZE); -free_workqueue: + free_workqueue: destroy_workqueue(itv->irq_work_queues); -err: + err: if (retval == 0) retval = -ENODEV; IVTV_ERR("Error %d on initialization\n", retval); diff --git a/trunk/drivers/media/video/ivtv/ivtv-gpio.c b/trunk/drivers/media/video/ivtv/ivtv-gpio.c index d8ac09f3cce6..688cd3856685 100644 --- a/trunk/drivers/media/video/ivtv/ivtv-gpio.c +++ b/trunk/drivers/media/video/ivtv/ivtv-gpio.c @@ -128,17 +128,20 @@ int ivtv_reset_tuner_gpio(void *dev, int cmd, int value) { struct i2c_algo_bit_data *algo = dev; struct ivtv *itv = algo->data; - u32 curout; + int curdir, curout; if (cmd != XC2028_TUNER_RESET) return 0; IVTV_DEBUG_INFO("Resetting tuner\n"); curout = read_reg(IVTV_REG_GPIO_OUT); - curout &= ~(1 << itv->card->xceive_pin); + curdir = read_reg(IVTV_REG_GPIO_DIR); + curdir |= (1 << 12); /* GPIO bit 12 */ + + curout &= ~(1 << 12); write_reg(curout, IVTV_REG_GPIO_OUT); schedule_timeout_interruptible(msecs_to_jiffies(1)); - curout |= 1 << itv->card->xceive_pin; + curout |= (1 << 12); write_reg(curout, IVTV_REG_GPIO_OUT); schedule_timeout_interruptible(msecs_to_jiffies(1)); return 0; diff --git a/trunk/drivers/media/video/ivtv/ivtv-i2c.c b/trunk/drivers/media/video/ivtv/ivtv-i2c.c index 771adf47e944..9824eafee021 100644 --- a/trunk/drivers/media/video/ivtv/ivtv-i2c.c +++ b/trunk/drivers/media/video/ivtv/ivtv-i2c.c @@ -167,8 +167,7 @@ int ivtv_i2c_register(struct ivtv *itv, unsigned idx) return -1; id = hw_driverids[idx]; memset(&info, 0, sizeof(info)); - strlcpy(info.driver_name, hw_drivernames[idx], - sizeof(info.driver_name)); + strcpy(info.driver_name, hw_drivernames[idx]); info.addr = hw_addrs[idx]; for (i = 0; itv->i2c_clients[i] && i < I2C_CLIENTS_MAX; i++) {} diff --git a/trunk/drivers/media/video/ivtv/ivtv-ioctl.c b/trunk/drivers/media/video/ivtv/ivtv-ioctl.c index d508b5d0538c..15cac1812122 100644 --- a/trunk/drivers/media/video/ivtv/ivtv-ioctl.c +++ b/trunk/drivers/media/video/ivtv/ivtv-ioctl.c @@ -243,31 +243,20 @@ static int ivtv_validate_speed(int cur_speed, int new_speed) int fact = new_speed < 0 ? -1 : 1; int s; - if (cur_speed == 0) - cur_speed = 1000; - if (new_speed < 0) - new_speed = -new_speed; - if (cur_speed < 0) - cur_speed = -cur_speed; + if (new_speed < 0) new_speed = -new_speed; + if (cur_speed < 0) cur_speed = -cur_speed; if (cur_speed <= new_speed) { - if (new_speed > 1500) - return fact * 2000; - if (new_speed > 1000) - return fact * 1500; + if (new_speed > 1500) return fact * 2000; + if (new_speed > 1000) return fact * 1500; } else { - if (new_speed >= 2000) - return fact * 2000; - if (new_speed >= 1500) - return fact * 1500; - if (new_speed >= 1000) - return fact * 1000; - } - if (new_speed == 0) - return 1000; - if (new_speed == 1 || new_speed == 1000) - return fact * new_speed; + if (new_speed >= 2000) return fact * 2000; + if (new_speed >= 1500) return fact * 1500; + if (new_speed >= 1000) return fact * 1000; + } + if (new_speed == 0) return 1000; + if (new_speed == 1 || new_speed == 1000) return fact * new_speed; s = new_speed; new_speed = 1000 / new_speed; @@ -752,9 +741,10 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void struct v4l2_capability *vcap = arg; memset(vcap, 0, sizeof(*vcap)); - strlcpy(vcap->driver, IVTV_DRIVER_NAME, sizeof(vcap->driver)); - strlcpy(vcap->card, itv->card_name, sizeof(vcap->card)); - strlcpy(vcap->bus_info, pci_name(itv->dev), sizeof(vcap->bus_info)); + strcpy(vcap->driver, IVTV_DRIVER_NAME); /* driver name */ + strncpy(vcap->card, itv->card_name, + sizeof(vcap->card)-1); /* card type */ + strcpy(vcap->bus_info, pci_name(itv->dev)); /* bus info... */ vcap->version = IVTV_DRIVER_VERSION; /* version */ vcap->capabilities = itv->v4l2_cap; /* capabilities */ @@ -1028,7 +1018,7 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void ivtv_std_60hz : ivtv_std_50hz; vs->index = idx; vs->id = enum_stds[idx].std; - strlcpy(vs->name, enum_stds[idx].name, sizeof(vs->name)); + strcpy(vs->name, enum_stds[idx].name); break; } @@ -1112,10 +1102,10 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void ivtv_call_i2c_clients(itv, VIDIOC_G_TUNER, vt); if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags)) { - strlcpy(vt->name, "ivtv Radio Tuner", sizeof(vt->name)); + strcpy(vt->name, "ivtv Radio Tuner"); vt->type = V4L2_TUNER_RADIO; } else { - strlcpy(vt->name, "ivtv TV Tuner", sizeof(vt->name)); + strcpy(vt->name, "ivtv TV Tuner"); vt->type = V4L2_TUNER_ANALOG_TV; } break; diff --git a/trunk/drivers/media/video/ivtv/ivtv-irq.c b/trunk/drivers/media/video/ivtv/ivtv-irq.c index d8ba3a4a8761..a329c4689dbf 100644 --- a/trunk/drivers/media/video/ivtv/ivtv-irq.c +++ b/trunk/drivers/media/video/ivtv/ivtv-irq.c @@ -384,7 +384,7 @@ static void ivtv_dma_enc_start_xfer(struct ivtv_stream *s) ivtv_stream_sync_for_device(s); write_reg(s->sg_handle, IVTV_REG_ENCDMAADDR); write_reg_sync(read_reg(IVTV_REG_DMAXFER) | 0x02, IVTV_REG_DMAXFER); - itv->dma_timer.expires = jiffies + msecs_to_jiffies(300); + itv->dma_timer.expires = jiffies + msecs_to_jiffies(100); add_timer(&itv->dma_timer); } @@ -400,7 +400,7 @@ static void ivtv_dma_dec_start_xfer(struct ivtv_stream *s) ivtv_stream_sync_for_device(s); write_reg(s->sg_handle, IVTV_REG_DECDMAADDR); write_reg_sync(read_reg(IVTV_REG_DMAXFER) | 0x01, IVTV_REG_DMAXFER); - itv->dma_timer.expires = jiffies + msecs_to_jiffies(300); + itv->dma_timer.expires = jiffies + msecs_to_jiffies(100); add_timer(&itv->dma_timer); } diff --git a/trunk/drivers/media/video/ivtv/ivtv-version.h b/trunk/drivers/media/video/ivtv/ivtv-version.h index 02c5ab071d1b..0f1d4cc4b4d9 100644 --- a/trunk/drivers/media/video/ivtv/ivtv-version.h +++ b/trunk/drivers/media/video/ivtv/ivtv-version.h @@ -23,7 +23,7 @@ #define IVTV_DRIVER_NAME "ivtv" #define IVTV_DRIVER_VERSION_MAJOR 1 #define IVTV_DRIVER_VERSION_MINOR 2 -#define IVTV_DRIVER_VERSION_PATCHLEVEL 1 +#define IVTV_DRIVER_VERSION_PATCHLEVEL 0 #define IVTV_VERSION __stringify(IVTV_DRIVER_VERSION_MAJOR) "." __stringify(IVTV_DRIVER_VERSION_MINOR) "." __stringify(IVTV_DRIVER_VERSION_PATCHLEVEL) #define IVTV_DRIVER_VERSION KERNEL_VERSION(IVTV_DRIVER_VERSION_MAJOR,IVTV_DRIVER_VERSION_MINOR,IVTV_DRIVER_VERSION_PATCHLEVEL) diff --git a/trunk/drivers/media/video/ivtv/ivtvfb.c b/trunk/drivers/media/video/ivtv/ivtvfb.c index df789f683e63..3b23fc05f7c4 100644 --- a/trunk/drivers/media/video/ivtv/ivtvfb.c +++ b/trunk/drivers/media/video/ivtv/ivtvfb.c @@ -532,7 +532,7 @@ static int ivtvfb_get_fix(struct ivtv *itv, struct fb_fix_screeninfo *fix) IVTVFB_DEBUG_INFO("ivtvfb_get_fix\n"); memset(fix, 0, sizeof(struct fb_fix_screeninfo)); - strlcpy(fix->id, "cx23415 TV out", sizeof(fix->id)); + strcpy(fix->id, "cx23415 TV out"); fix->smem_start = oi->video_pbase; fix->smem_len = oi->video_buffer_size; fix->type = FB_TYPE_PACKED_PIXELS; diff --git a/trunk/drivers/media/video/m52790.c b/trunk/drivers/media/video/m52790.c index 5b9dfa2c51b4..d4bf14c284ef 100644 --- a/trunk/drivers/media/video/m52790.c +++ b/trunk/drivers/media/video/m52790.c @@ -126,8 +126,7 @@ static int m52790_command(struct i2c_client *client, unsigned int cmd, /* i2c implementation */ -static int m52790_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int m52790_probe(struct i2c_client *client) { struct m52790_state *state; diff --git a/trunk/drivers/media/video/msp3400-driver.c b/trunk/drivers/media/video/msp3400-driver.c index e6273162e123..b73c740f7fb2 100644 --- a/trunk/drivers/media/video/msp3400-driver.c +++ b/trunk/drivers/media/video/msp3400-driver.c @@ -805,7 +805,7 @@ static int msp_resume(struct i2c_client *client) /* ----------------------------------------------------------------------- */ -static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id) +static int msp_probe(struct i2c_client *client) { struct msp_state *state; int (*thread_func)(void *data) = NULL; diff --git a/trunk/drivers/media/common/tuners/mt20xx.c b/trunk/drivers/media/video/mt20xx.c similarity index 100% rename from trunk/drivers/media/common/tuners/mt20xx.c rename to trunk/drivers/media/video/mt20xx.c diff --git a/trunk/drivers/media/common/tuners/mt20xx.h b/trunk/drivers/media/video/mt20xx.h similarity index 91% rename from trunk/drivers/media/common/tuners/mt20xx.h rename to trunk/drivers/media/video/mt20xx.h index 259553a24903..aa848e14ce5e 100644 --- a/trunk/drivers/media/common/tuners/mt20xx.h +++ b/trunk/drivers/media/video/mt20xx.h @@ -20,7 +20,7 @@ #include #include "dvb_frontend.h" -#if defined(CONFIG_MEDIA_TUNER_MT20XX) || (defined(CONFIG_MEDIA_TUNER_MT20XX_MODULE) && defined(MODULE)) +#if defined(CONFIG_TUNER_MT20XX) || (defined(CONFIG_TUNER_MT20XX_MODULE) && defined(MODULE)) extern struct dvb_frontend *microtune_attach(struct dvb_frontend *fe, struct i2c_adapter* i2c_adap, u8 i2c_addr); diff --git a/trunk/drivers/media/video/mt9m001.c b/trunk/drivers/media/video/mt9m001.c index 179e47049a45..3fb5f63df1e6 100644 --- a/trunk/drivers/media/video/mt9m001.c +++ b/trunk/drivers/media/video/mt9m001.c @@ -372,7 +372,7 @@ static int mt9m001_set_register(struct soc_camera_device *icd, } #endif -static const struct v4l2_queryctrl mt9m001_controls[] = { +const struct v4l2_queryctrl mt9m001_controls[] = { { .id = V4L2_CID_VFLIP, .type = V4L2_CTRL_TYPE_BOOLEAN, @@ -620,8 +620,7 @@ static void mt9m001_video_remove(struct soc_camera_device *icd) soc_camera_video_stop(&mt9m001->icd); } -static int mt9m001_probe(struct i2c_client *client, - const struct i2c_device_id *did) +static int mt9m001_probe(struct i2c_client *client) { struct mt9m001 *mt9m001; struct soc_camera_device *icd; @@ -697,19 +696,12 @@ static int mt9m001_remove(struct i2c_client *client) return 0; } -static const struct i2c_device_id mt9m001_id[] = { - { "mt9m001", 0 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, mt9m001_id); - static struct i2c_driver mt9m001_i2c_driver = { .driver = { .name = "mt9m001", }, .probe = mt9m001_probe, .remove = mt9m001_remove, - .id_table = mt9m001_id, }; static int __init mt9m001_mod_init(void) diff --git a/trunk/drivers/media/video/mt9v022.c b/trunk/drivers/media/video/mt9v022.c index d1391ac55096..d4b9e2744343 100644 --- a/trunk/drivers/media/video/mt9v022.c +++ b/trunk/drivers/media/video/mt9v022.c @@ -452,7 +452,7 @@ static int mt9v022_set_register(struct soc_camera_device *icd, } #endif -static const struct v4l2_queryctrl mt9v022_controls[] = { +const struct v4l2_queryctrl mt9v022_controls[] = { { .id = V4L2_CID_VFLIP, .type = V4L2_CTRL_TYPE_BOOLEAN, @@ -745,8 +745,7 @@ static void mt9v022_video_remove(struct soc_camera_device *icd) soc_camera_video_stop(&mt9v022->icd); } -static int mt9v022_probe(struct i2c_client *client, - const struct i2c_device_id *did) +static int mt9v022_probe(struct i2c_client *client) { struct mt9v022 *mt9v022; struct soc_camera_device *icd; @@ -819,19 +818,12 @@ static int mt9v022_remove(struct i2c_client *client) return 0; } -static const struct i2c_device_id mt9v022_id[] = { - { "mt9v022", 0 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, mt9v022_id); - static struct i2c_driver mt9v022_i2c_driver = { .driver = { .name = "mt9v022", }, .probe = mt9v022_probe, .remove = mt9v022_remove, - .id_table = mt9v022_id, }; static int __init mt9v022_mod_init(void) diff --git a/trunk/drivers/media/video/pvrusb2/Kconfig b/trunk/drivers/media/video/pvrusb2/Kconfig index 9620c67fae77..158b3d0c6532 100644 --- a/trunk/drivers/media/video/pvrusb2/Kconfig +++ b/trunk/drivers/media/video/pvrusb2/Kconfig @@ -1,15 +1,14 @@ config VIDEO_PVRUSB2 tristate "Hauppauge WinTV-PVR USB2 support" - depends on VIDEO_V4L2 && I2C + depends on VIDEO_V4L2 && I2C && EXPERIMENTAL select FW_LOADER - select MEDIA_TUNER + select VIDEO_TUNER select VIDEO_TVEEPROM select VIDEO_CX2341X select VIDEO_SAA711X select VIDEO_CX25840 select VIDEO_MSP3400 select VIDEO_WM8775 - select VIDEO_CS53L32A ---help--- This is a video4linux driver for Conexant 23416 based usb2 personal video recorder devices. @@ -17,6 +16,32 @@ config VIDEO_PVRUSB2 To compile this driver as a module, choose M here: the module will be called pvrusb2 +config VIDEO_PVRUSB2_ONAIR_CREATOR + bool "pvrusb2 driver support for OnAir Creator model" + depends on VIDEO_PVRUSB2 && EXPERIMENTAL + select VIDEO_SAA711X + select VIDEO_CS53L32A + ---help--- + + This option enables support for the OnAir Creator USB tuner + device. This is a hybrid device, however currently only + analog mode is supported. + + If you are in doubt, say Y. + +config VIDEO_PVRUSB2_ONAIR_USB2 + bool "pvrusb2 driver support for OnAir USB2 model" + depends on VIDEO_PVRUSB2 && EXPERIMENTAL + select VIDEO_SAA711X + select VIDEO_CS53L32A + ---help--- + + This option enables support for the OnAir USB2 tuner device + (also known as the Sasem tuner). This is a hybrid device, + however currently only analog mode is supported. + + If you are in doubt, say Y. + config VIDEO_PVRUSB2_SYSFS bool "pvrusb2 sysfs support (EXPERIMENTAL)" default y @@ -34,23 +59,29 @@ config VIDEO_PVRUSB2_SYSFS Note: This feature is experimental and subject to change. config VIDEO_PVRUSB2_DVB - bool "pvrusb2 ATSC/DVB support (EXPERIMENTAL)" - default y + bool "pvrusb2 DVB support (EXPERIMENTAL)" + default n depends on VIDEO_PVRUSB2 && DVB_CORE && EXPERIMENTAL select DVB_LGDT330X if !DVB_FE_CUSTOMISE select DVB_S5H1409 if !DVB_FE_CUSTOMISE select DVB_S5H1411 if !DVB_FE_CUSTOMISE select DVB_TDA10048 if !DVB_FE_CUSTOMIZE - select MEDIA_TUNER_TDA18271 if !DVB_FE_CUSTOMIZE - select MEDIA_TUNER_SIMPLE if !DVB_FE_CUSTOMISE - select MEDIA_TUNER_TDA8290 if !DVB_FE_CUSTOMIZE + select DVB_TDA18271 if !DVB_FE_CUSTOMIZE + select TUNER_SIMPLE if !DVB_FE_CUSTOMISE + select TUNER_TDA8290 if !DVB_FE_CUSTOMIZE ---help--- - This option enables a DVB interface for the pvrusb2 driver. - If your device does not support digital television, this - feature will have no affect on the driver's operation. + This option enables compilation of a DVB interface for the + pvrusb2 driver. Currently this is very very experimental. + It is also limiting - the DVB interface can only access the + digital side of hybrid devices, and there are going to be + issues if you attempt to mess with the V4L side at the same + time. Don't turn this on unless you know what you are + doing. - If you are in doubt, say Y. + If you are in doubt, say N. + + Note: This feature is very experimental and might break config VIDEO_PVRUSB2_DEBUGIFC bool "pvrusb2 debug interface" diff --git a/trunk/drivers/media/video/pvrusb2/Makefile b/trunk/drivers/media/video/pvrusb2/Makefile index 4fda2de69ab7..5b3083c89aa9 100644 --- a/trunk/drivers/media/video/pvrusb2/Makefile +++ b/trunk/drivers/media/video/pvrusb2/Makefile @@ -16,6 +16,5 @@ pvrusb2-objs := pvrusb2-i2c-core.o pvrusb2-i2c-cmd-v4l2.o \ obj-$(CONFIG_VIDEO_PVRUSB2) += pvrusb2.o EXTRA_CFLAGS += -Idrivers/media/video -EXTRA_CFLAGS += -Idrivers/media/common/tuners EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core EXTRA_CFLAGS += -Idrivers/media/dvb/frontends diff --git a/trunk/drivers/media/video/pvrusb2/pvrusb2-debug.h b/trunk/drivers/media/video/pvrusb2/pvrusb2-debug.h index 707d2d9635d7..11537ddf8aa3 100644 --- a/trunk/drivers/media/video/pvrusb2/pvrusb2-debug.h +++ b/trunk/drivers/media/video/pvrusb2/pvrusb2-debug.h @@ -54,7 +54,6 @@ extern int pvrusb2_debug; #define PVR2_TRACE_DATA_FLOW (1 << 25) /* Track data flow */ #define PVR2_TRACE_DEBUGIFC (1 << 26) /* Debug interface actions */ #define PVR2_TRACE_GPIO (1 << 27) /* GPIO state bit changes */ -#define PVR2_TRACE_DVB_FEED (1 << 28) /* DVB transport feed debug */ #endif /* __PVRUSB2_HDW_INTERNAL_H */ diff --git a/trunk/drivers/media/video/pvrusb2/pvrusb2-devattr.c b/trunk/drivers/media/video/pvrusb2/pvrusb2-devattr.c index 5bf6d8fda1f9..3a141d93e1a9 100644 --- a/trunk/drivers/media/video/pvrusb2/pvrusb2-devattr.c +++ b/trunk/drivers/media/video/pvrusb2/pvrusb2-devattr.c @@ -153,6 +153,7 @@ static const struct pvr2_device_desc pvr2_device_gotview_2d = { +#ifdef CONFIG_VIDEO_PVRUSB2_ONAIR_CREATOR /*------------------------------------------------------------------------*/ /* OnAir Creator */ @@ -211,9 +212,11 @@ static const struct pvr2_device_desc pvr2_device_onair_creator = { .dvb_props = &pvr2_onair_creator_fe_props, #endif }; +#endif +#ifdef CONFIG_VIDEO_PVRUSB2_ONAIR_USB2 /*------------------------------------------------------------------------*/ /* OnAir USB 2.0 */ @@ -271,6 +274,7 @@ static const struct pvr2_device_desc pvr2_device_onair_usb2 = { .dvb_props = &pvr2_onair_usb2_fe_props, #endif }; +#endif @@ -493,10 +497,14 @@ struct usb_device_id pvr2_device_table[] = { .driver_info = (kernel_ulong_t)&pvr2_device_gotview_2}, { USB_DEVICE(0x1164, 0x0602), .driver_info = (kernel_ulong_t)&pvr2_device_gotview_2d}, +#ifdef CONFIG_VIDEO_PVRUSB2_ONAIR_CREATOR { USB_DEVICE(0x11ba, 0x1003), .driver_info = (kernel_ulong_t)&pvr2_device_onair_creator}, +#endif +#ifdef CONFIG_VIDEO_PVRUSB2_ONAIR_USB2 { USB_DEVICE(0x11ba, 0x1001), .driver_info = (kernel_ulong_t)&pvr2_device_onair_usb2}, +#endif { USB_DEVICE(0x2040, 0x7300), .driver_info = (kernel_ulong_t)&pvr2_device_73xxx}, { USB_DEVICE(0x2040, 0x7500), diff --git a/trunk/drivers/media/video/pvrusb2/pvrusb2-dvb.c b/trunk/drivers/media/video/pvrusb2/pvrusb2-dvb.c index 6ec4bf81fc7f..6504c97e0bbc 100644 --- a/trunk/drivers/media/video/pvrusb2/pvrusb2-dvb.c +++ b/trunk/drivers/media/video/pvrusb2/pvrusb2-dvb.c @@ -21,7 +21,6 @@ #include #include #include "dvbdev.h" -#include "pvrusb2-debug.h" #include "pvrusb2-hdw-internal.h" #include "pvrusb2-hdw.h" #include "pvrusb2-io.h" @@ -36,7 +35,7 @@ static int pvr2_dvb_feed_func(struct pvr2_dvb_adapter *adap) struct pvr2_buffer *bp; struct pvr2_stream *stream; - pvr2_trace(PVR2_TRACE_DVB_FEED, "dvb feed thread started"); + printk(KERN_DEBUG "dvb thread started\n"); set_freezable(); stream = adap->channel.stream->stream; @@ -83,7 +82,7 @@ static int pvr2_dvb_feed_func(struct pvr2_dvb_adapter *adap) /* If we get here and ret is < 0, then an error has occurred. Probably would be a good idea to communicate that to DVB core... */ - pvr2_trace(PVR2_TRACE_DVB_FEED, "dvb feed thread stopped"); + printk(KERN_DEBUG "dvb thread stopped\n"); return 0; } @@ -211,8 +210,7 @@ static int pvr2_dvb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff) do { if (onoff) { if (!adap->feedcount) { - pvr2_trace(PVR2_TRACE_DVB_FEED, - "start feeding demux"); + printk(KERN_DEBUG "start feeding\n"); ret = pvr2_dvb_stream_start(adap); if (ret < 0) break; } @@ -220,8 +218,7 @@ static int pvr2_dvb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff) } else if (adap->feedcount > 0) { (adap->feedcount)--; if (!adap->feedcount) { - pvr2_trace(PVR2_TRACE_DVB_FEED, - "stop feeding demux"); + printk(KERN_DEBUG "stop feeding\n"); pvr2_dvb_stream_end(adap); } } @@ -233,13 +230,15 @@ static int pvr2_dvb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff) static int pvr2_dvb_start_feed(struct dvb_demux_feed *dvbdmxfeed) { - pvr2_trace(PVR2_TRACE_DVB_FEED, "start pid: 0x%04x", dvbdmxfeed->pid); + printk(KERN_DEBUG "start pid: 0x%04x, feedtype: %d\n", + dvbdmxfeed->pid, dvbdmxfeed->type); return pvr2_dvb_ctrl_feed(dvbdmxfeed, 1); } static int pvr2_dvb_stop_feed(struct dvb_demux_feed *dvbdmxfeed) { - pvr2_trace(PVR2_TRACE_DVB_FEED, "stop pid: 0x%04x", dvbdmxfeed->pid); + printk(KERN_DEBUG "stop pid: 0x%04x, feedtype: %d\n", + dvbdmxfeed->pid, dvbdmxfeed->type); return pvr2_dvb_ctrl_feed(dvbdmxfeed, 0); } @@ -260,8 +259,7 @@ static int pvr2_dvb_adapter_init(struct pvr2_dvb_adapter *adap) &adap->channel.hdw->usb_dev->dev, adapter_nr); if (ret < 0) { - pvr2_trace(PVR2_TRACE_ERROR_LEGS, - "dvb_register_adapter failed: error %d", ret); + err("dvb_register_adapter failed: error %d", ret); goto err; } adap->dvb_adap.priv = adap; @@ -278,8 +276,7 @@ static int pvr2_dvb_adapter_init(struct pvr2_dvb_adapter *adap) ret = dvb_dmx_init(&adap->demux); if (ret < 0) { - pvr2_trace(PVR2_TRACE_ERROR_LEGS, - "dvb_dmx_init failed: error %d", ret); + err("dvb_dmx_init failed: error %d", ret); goto err_dmx; } @@ -289,8 +286,7 @@ static int pvr2_dvb_adapter_init(struct pvr2_dvb_adapter *adap) ret = dvb_dmxdev_init(&adap->dmxdev, &adap->dvb_adap); if (ret < 0) { - pvr2_trace(PVR2_TRACE_ERROR_LEGS, - "dvb_dmxdev_init failed: error %d", ret); + err("dvb_dmxdev_init failed: error %d", ret); goto err_dmx_dev; } @@ -308,7 +304,7 @@ static int pvr2_dvb_adapter_init(struct pvr2_dvb_adapter *adap) static int pvr2_dvb_adapter_exit(struct pvr2_dvb_adapter *adap) { - pvr2_trace(PVR2_TRACE_INFO, "unregistering DVB devices"); + printk(KERN_DEBUG "unregistering DVB devices\n"); dvb_net_release(&adap->dvb_net); adap->demux.dmx.close(&adap->demux.dmx); dvb_dmxdev_release(&adap->dmxdev); @@ -324,7 +320,7 @@ static int pvr2_dvb_frontend_init(struct pvr2_dvb_adapter *adap) int ret = 0; if (dvb_props == NULL) { - pvr2_trace(PVR2_TRACE_ERROR_LEGS, "fe_props not defined!"); + err("fe_props not defined!"); return -EINVAL; } @@ -332,15 +328,13 @@ static int pvr2_dvb_frontend_init(struct pvr2_dvb_adapter *adap) &adap->channel, (1 << PVR2_CVAL_INPUT_DTV)); if (ret) { - pvr2_trace(PVR2_TRACE_ERROR_LEGS, - "failed to grab control of dtv input (code=%d)", + err("failed to grab control of dtv input (code=%d)", ret); return ret; } if (dvb_props->frontend_attach == NULL) { - pvr2_trace(PVR2_TRACE_ERROR_LEGS, - "frontend_attach not defined!"); + err("frontend_attach not defined!"); ret = -EINVAL; goto done; } @@ -348,8 +342,7 @@ static int pvr2_dvb_frontend_init(struct pvr2_dvb_adapter *adap) if ((dvb_props->frontend_attach(adap) == 0) && (adap->fe)) { if (dvb_register_frontend(&adap->dvb_adap, adap->fe)) { - pvr2_trace(PVR2_TRACE_ERROR_LEGS, - "frontend registration failed!"); + err("frontend registration failed!"); dvb_frontend_detach(adap->fe); adap->fe = NULL; ret = -ENODEV; @@ -366,8 +359,7 @@ static int pvr2_dvb_frontend_init(struct pvr2_dvb_adapter *adap) adap->fe->ops.ts_bus_ctrl = pvr2_dvb_bus_ctrl; } else { - pvr2_trace(PVR2_TRACE_ERROR_LEGS, - "no frontend was attached!"); + err("no frontend was attached!"); ret = -ENODEV; return ret; } diff --git a/trunk/drivers/media/video/saa7115.c b/trunk/drivers/media/video/saa7115.c index e684108637ad..416d05d4a969 100644 --- a/trunk/drivers/media/video/saa7115.c +++ b/trunk/drivers/media/video/saa7115.c @@ -1450,8 +1450,7 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar /* ----------------------------------------------------------------------- */ -static int saa7115_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int saa7115_probe(struct i2c_client *client) { struct saa711x_state *state; int i; diff --git a/trunk/drivers/media/video/saa7127.c b/trunk/drivers/media/video/saa7127.c index e750cd65c1c3..06c88db656b4 100644 --- a/trunk/drivers/media/video/saa7127.c +++ b/trunk/drivers/media/video/saa7127.c @@ -661,8 +661,7 @@ static int saa7127_command(struct i2c_client *client, /* ----------------------------------------------------------------------- */ -static int saa7127_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int saa7127_probe(struct i2c_client *client) { struct saa7127_state *state; struct v4l2_sliced_vbi_data vbi = { 0, 0, 0, 0 }; /* set to disabled */ diff --git a/trunk/drivers/media/video/saa7134/Kconfig b/trunk/drivers/media/video/saa7134/Kconfig index 40e4c3bd2cb9..e086f14d5663 100644 --- a/trunk/drivers/media/video/saa7134/Kconfig +++ b/trunk/drivers/media/video/saa7134/Kconfig @@ -3,7 +3,7 @@ config VIDEO_SAA7134 depends on VIDEO_DEV && PCI && I2C && INPUT select VIDEOBUF_DMA_SG select VIDEO_IR - select MEDIA_TUNER + select VIDEO_TUNER select VIDEO_TVEEPROM select CRC32 ---help--- @@ -35,9 +35,9 @@ config VIDEO_SAA7134_DVB select DVB_NXT200X if !DVB_FE_CUSTOMISE select DVB_TDA10086 if !DVB_FE_CUSTOMISE select DVB_TDA826X if !DVB_FE_CUSTOMISE - select MEDIA_TUNER_TDA827X if !DVB_FE_CUSTOMISE + select DVB_TDA827X if !DVB_FE_CUSTOMISE select DVB_ISL6421 if !DVB_FE_CUSTOMISE - select MEDIA_TUNER_SIMPLE if !DVB_FE_CUSTOMISE + select TUNER_SIMPLE if !DVB_FE_CUSTOMISE ---help--- This adds support for DVB cards based on the Philips saa7134 chip. diff --git a/trunk/drivers/media/video/saa7134/Makefile b/trunk/drivers/media/video/saa7134/Makefile index 3dbaa19a6d00..9aff937ba7a5 100644 --- a/trunk/drivers/media/video/saa7134/Makefile +++ b/trunk/drivers/media/video/saa7134/Makefile @@ -11,6 +11,5 @@ obj-$(CONFIG_VIDEO_SAA7134_ALSA) += saa7134-alsa.o obj-$(CONFIG_VIDEO_SAA7134_DVB) += saa7134-dvb.o EXTRA_CFLAGS += -Idrivers/media/video -EXTRA_CFLAGS += -Idrivers/media/common/tuners EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core EXTRA_CFLAGS += -Idrivers/media/dvb/frontends diff --git a/trunk/drivers/media/video/saa7134/saa7134-cards.c b/trunk/drivers/media/video/saa7134/saa7134-cards.c index b111903aa322..98375955a84b 100644 --- a/trunk/drivers/media/video/saa7134/saa7134-cards.c +++ b/trunk/drivers/media/video/saa7134/saa7134-cards.c @@ -47,9 +47,6 @@ static char name_svideo[] = "S-Video"; /* ------------------------------------------------------------------ */ /* board config info */ -/* If radio_type !=UNSET, radio_addr should be specified - */ - struct saa7134_board saa7134_boards[] = { [SAA7134_BOARD_UNKNOWN] = { .name = "UNKNOWN/GENERIC", @@ -3090,7 +3087,7 @@ struct saa7134_board saa7134_boards[] = { .tuner_type = TUNER_PHILIPS_TD1316, /* untested */ .radio_type = TUNER_TEA5767, /* untested */ .tuner_addr = ADDR_UNSET, - .radio_addr = 0x60, + .radio_addr = ADDR_UNSET, .tda9887_conf = TDA9887_PRESENT, .mpeg = SAA7134_MPEG_DVB, .inputs = {{ @@ -4250,36 +4247,6 @@ struct saa7134_board saa7134_boards[] = { .amux = LINE1, } }, }, - [SAA7134_BOARD_BEHOLD_H6] = { - /* Igor Kuznetsov */ - .name = "Beholder BeholdTV H6", - .audio_clock = 0x00187de7, - .tuner_type = TUNER_PHILIPS_FMD1216ME_MK3, - .radio_type = UNSET, - .tuner_addr = ADDR_UNSET, - .radio_addr = ADDR_UNSET, - .tda9887_conf = TDA9887_PRESENT, - .inputs = {{ - .name = name_tv, - .vmux = 3, - .amux = TV, - .tv = 1, - }, { - .name = name_comp1, - .vmux = 1, - .amux = LINE1, - }, { - .name = name_svideo, - .vmux = 8, - .amux = LINE1, - } }, - .radio = { - .name = name_radio, - .amux = LINE2, - }, - /* no DVB support for now */ - /* .mpeg = SAA7134_MPEG_DVB, */ - }, }; const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards); @@ -5230,12 +5197,6 @@ struct pci_device_id saa7134_pci_tbl[] = { .subvendor = 0x5ace, .subdevice = 0x6193, .driver_data = SAA7134_BOARD_BEHOLD_M6, - }, { - .vendor = PCI_VENDOR_ID_PHILIPS, - .device = PCI_DEVICE_ID_PHILIPS_SAA7133, - .subvendor = 0x5ace, - .subdevice = 0x6191, - .driver_data = SAA7134_BOARD_BEHOLD_M6, },{ .vendor = PCI_VENDOR_ID_PHILIPS, .device = PCI_DEVICE_ID_PHILIPS_SAA7133, @@ -5284,12 +5245,6 @@ struct pci_device_id saa7134_pci_tbl[] = { .subvendor = 0x185b, .subdevice = 0xc900, .driver_data = SAA7134_BOARD_VIDEOMATE_T750, - }, { - .vendor = PCI_VENDOR_ID_PHILIPS, - .device = PCI_DEVICE_ID_PHILIPS_SAA7133, - .subvendor = 0x5ace, - .subdevice = 0x6290, - .driver_data = SAA7134_BOARD_BEHOLD_H6, }, { /* --- boards without eeprom + subsystem ID --- */ .vendor = PCI_VENDOR_ID_PHILIPS, @@ -5622,87 +5577,20 @@ int saa7134_board_init1(struct saa7134_dev *dev) return 0; } -static void saa7134_tuner_setup(struct saa7134_dev *dev) -{ - struct tuner_setup tun_setup; - unsigned int mode_mask = T_RADIO | - T_ANALOG_TV | - T_DIGITAL_TV; - - memset(&tun_setup, 0, sizeof(tun_setup)); - tun_setup.tuner_callback = saa7134_tuner_callback; - - if (saa7134_boards[dev->board].radio_type != UNSET) { - tun_setup.type = saa7134_boards[dev->board].radio_type; - tun_setup.addr = saa7134_boards[dev->board].radio_addr; - - tun_setup.mode_mask = T_RADIO; - - saa7134_i2c_call_clients(dev, TUNER_SET_TYPE_ADDR, &tun_setup); - mode_mask &= ~T_RADIO; - } - - if ((dev->tuner_type != TUNER_ABSENT) && (dev->tuner_type != UNSET)) { - tun_setup.type = dev->tuner_type; - tun_setup.addr = dev->tuner_addr; - tun_setup.config = saa7134_boards[dev->board].tuner_config; - tun_setup.tuner_callback = saa7134_tuner_callback; - - tun_setup.mode_mask = mode_mask; - - saa7134_i2c_call_clients(dev, TUNER_SET_TYPE_ADDR, &tun_setup); - } - - if (dev->tda9887_conf) { - struct v4l2_priv_tun_config tda9887_cfg; - - tda9887_cfg.tuner = TUNER_TDA9887; - tda9887_cfg.priv = &dev->tda9887_conf; - - saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, - &tda9887_cfg); - } - - if (dev->tuner_type == TUNER_XC2028) { - struct v4l2_priv_tun_config xc2028_cfg; - struct xc2028_ctrl ctl; - - memset(&xc2028_cfg, 0, sizeof(ctl)); - memset(&ctl, 0, sizeof(ctl)); - - ctl.fname = XC2028_DEFAULT_FIRMWARE; - ctl.max_len = 64; - - switch (dev->board) { - case SAA7134_BOARD_AVERMEDIA_A16D: - ctl.demod = XC3028_FE_ZARLINK456; - break; - default: - ctl.demod = XC3028_FE_OREN538; - ctl.mts = 1; - } - - xc2028_cfg.tuner = TUNER_XC2028; - xc2028_cfg.priv = &ctl; - - saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, &xc2028_cfg); - } -} - /* stuff which needs working i2c */ int saa7134_board_init2(struct saa7134_dev *dev) { unsigned char buf; int board; - - dev->tuner_type = saa7134_boards[dev->board].tuner_type; - dev->tuner_addr = saa7134_boards[dev->board].tuner_addr; + struct tuner_setup tun_setup; + tun_setup.config = 0; + tun_setup.tuner_callback = saa7134_tuner_callback; switch (dev->board) { case SAA7134_BOARD_BMK_MPEX_NOTUNER: case SAA7134_BOARD_BMK_MPEX_TUNER: dev->i2c_client.addr = 0x60; - board = (i2c_master_recv(&dev->i2c_client, &buf, 0) < 0) + board = (i2c_master_recv(&dev->i2c_client,&buf,0) < 0) ? SAA7134_BOARD_BMK_MPEX_NOTUNER : SAA7134_BOARD_BMK_MPEX_TUNER; if (board == dev->board) @@ -5712,9 +5600,21 @@ int saa7134_board_init2(struct saa7134_dev *dev) saa7134_boards[dev->board].name); dev->tuner_type = saa7134_boards[dev->board].tuner_type; + if (TUNER_ABSENT != dev->tuner_type) { + tun_setup.mode_mask = T_RADIO | + T_ANALOG_TV | + T_DIGITAL_TV; + tun_setup.type = dev->tuner_type; + tun_setup.addr = ADDR_UNSET; + tun_setup.tuner_callback = saa7134_tuner_callback; + + saa7134_i2c_call_clients(dev, + TUNER_SET_TYPE_ADDR, + &tun_setup); + } break; case SAA7134_BOARD_MD7134: - { + { u8 subaddr; u8 data[3]; int ret, tuner_t; @@ -5767,8 +5667,30 @@ int saa7134_board_init2(struct saa7134_dev *dev) } printk(KERN_INFO "%s Tuner type is %d\n", dev->name, dev->tuner_type); + if (dev->tuner_type == TUNER_PHILIPS_FMD1216ME_MK3) { + struct v4l2_priv_tun_config tda9887_cfg; + + tda9887_cfg.tuner = TUNER_TDA9887; + tda9887_cfg.priv = &dev->tda9887_conf; + + dev->tda9887_conf = TDA9887_PRESENT | + TDA9887_PORT1_ACTIVE | + TDA9887_PORT2_ACTIVE; + + saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, + &tda9887_cfg); + } + + tun_setup.mode_mask = T_RADIO | + T_ANALOG_TV | + T_DIGITAL_TV; + tun_setup.type = dev->tuner_type; + tun_setup.addr = ADDR_UNSET; + + saa7134_i2c_call_clients(dev, + TUNER_SET_TYPE_ADDR, &tun_setup); + } break; - } case SAA7134_BOARD_PHILIPS_EUROPA: if (dev->autodetected && (dev->eedata[0x41] == 0x1c)) { /* Reconfigure board as Snake reference design */ @@ -5780,43 +5702,43 @@ int saa7134_board_init2(struct saa7134_dev *dev) } case SAA7134_BOARD_VIDEOMATE_DVBT_300: case SAA7134_BOARD_ASUS_EUROPA2_HYBRID: - { - /* The Philips EUROPA based hybrid boards have the tuner connected through * the channel decoder. We have to make it transparent to find it */ + { u8 data[] = { 0x07, 0x02}; struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)}; i2c_transfer(&dev->i2c_adap, &msg, 1); + tun_setup.mode_mask = T_ANALOG_TV | T_DIGITAL_TV; + tun_setup.type = dev->tuner_type; + tun_setup.addr = dev->tuner_addr; + + saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR,&tun_setup); + } break; - } case SAA7134_BOARD_PHILIPS_TIGER: case SAA7134_BOARD_PHILIPS_TIGER_S: - { + { u8 data[] = { 0x3c, 0x33, 0x60}; struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)}; - if (dev->autodetected && (dev->eedata[0x49] == 0x50)) { + if(dev->autodetected && (dev->eedata[0x49] == 0x50)) { dev->board = SAA7134_BOARD_PHILIPS_TIGER_S; printk(KERN_INFO "%s: Reconfigured board as %s\n", dev->name, saa7134_boards[dev->board].name); } - if (dev->board == SAA7134_BOARD_PHILIPS_TIGER_S) { - dev->tuner_type = TUNER_PHILIPS_TDA8290; - - saa7134_tuner_setup(dev); + if(dev->board == SAA7134_BOARD_PHILIPS_TIGER_S) { + tun_setup.mode_mask = T_ANALOG_TV | T_DIGITAL_TV; + tun_setup.type = TUNER_PHILIPS_TDA8290; + tun_setup.addr = 0x4b; + tun_setup.config = 2; + saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR,&tun_setup); data[2] = 0x68; - i2c_transfer(&dev->i2c_adap, &msg, 1); - - /* Tuner setup is handled before I2C transfer. - Due to that, there's no need to do it later - */ - return 0; } i2c_transfer(&dev->i2c_adap, &msg, 1); + } break; - } case SAA7134_BOARD_HAUPPAUGE_HVR1110: hauppauge_eeprom(dev, dev->eedata+0x80); /* break intentionally omitted */ @@ -5829,55 +5751,52 @@ int saa7134_board_init2(struct saa7134_dev *dev) case SAA7134_BOARD_AVERMEDIA_SUPER_007: case SAA7134_BOARD_TWINHAN_DTV_DVB_3056: case SAA7134_BOARD_CREATIX_CTX953: - { /* this is a hybrid board, initialize to analog mode * and configure firmware eeprom address */ + { u8 data[] = { 0x3c, 0x33, 0x60}; struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)}; i2c_transfer(&dev->i2c_adap, &msg, 1); + } break; - } case SAA7134_BOARD_FLYDVB_TRIO: - { + { u8 data[] = { 0x3c, 0x33, 0x62}; struct i2c_msg msg = {.addr=0x09, .flags=0, .buf=data, .len = sizeof(data)}; i2c_transfer(&dev->i2c_adap, &msg, 1); + } break; - } case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331: case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS: - { /* initialize analog mode */ + { u8 data[] = { 0x3c, 0x33, 0x6a}; struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)}; i2c_transfer(&dev->i2c_adap, &msg, 1); + } break; - } case SAA7134_BOARD_CINERGY_HT_PCMCIA: case SAA7134_BOARD_CINERGY_HT_PCI: - { /* initialize analog mode */ + { u8 data[] = { 0x3c, 0x33, 0x68}; struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)}; i2c_transfer(&dev->i2c_adap, &msg, 1); + } break; - } case SAA7134_BOARD_KWORLD_ATSC110: - { - /* enable tuner */ - int i; - static const u8 buffer [] = { 0x10, 0x12, 0x13, 0x04, 0x16, - 0x00, 0x14, 0x04, 0x17, 0x00 }; - dev->i2c_client.addr = 0x0a; - for (i = 0; i < 5; i++) - if (2 != i2c_master_send(&dev->i2c_client, - &buffer[i*2], 2)) - printk(KERN_WARNING - "%s: Unable to enable tuner(%i).\n", - dev->name, i); + { + /* enable tuner */ + int i; + static const u8 buffer [] = { 0x10,0x12,0x13,0x04,0x16,0x00,0x14,0x04,0x017,0x00 }; + dev->i2c_client.addr = 0x0a; + for (i = 0; i < 5; i++) + if (2 != i2c_master_send(&dev->i2c_client,&buffer[i*2],2)) + printk(KERN_WARNING "%s: Unable to enable tuner(%i).\n", + dev->name, i); + } break; - } case SAA7134_BOARD_VIDEOMATE_DVBT_200: case SAA7134_BOARD_VIDEOMATE_DVBT_200A: /* The T200 and the T200A share the same pci id. Consequently, @@ -5902,7 +5821,7 @@ int saa7134_board_init2(struct saa7134_dev *dev) } break; case SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM: - { + { struct v4l2_priv_tun_config tea5767_cfg; struct tea5767_ctrl ctl; @@ -5913,11 +5832,34 @@ int saa7134_board_init2(struct saa7134_dev *dev) tea5767_cfg.tuner = TUNER_TEA5767; tea5767_cfg.priv = &ctl; saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, &tea5767_cfg); + } break; } - } /* switch() */ - saa7134_tuner_setup(dev); + if (dev->tuner_type == TUNER_XC2028) { + struct v4l2_priv_tun_config xc2028_cfg; + struct xc2028_ctrl ctl; + + memset(&xc2028_cfg, 0, sizeof(ctl)); + memset(&ctl, 0, sizeof(ctl)); + + ctl.fname = XC2028_DEFAULT_FIRMWARE; + ctl.max_len = 64; + + switch (dev->board) { + case SAA7134_BOARD_AVERMEDIA_A16D: + ctl.demod = XC3028_FE_ZARLINK456; + break; + default: + ctl.demod = XC3028_FE_OREN538; + ctl.mts = 1; + } + + xc2028_cfg.tuner = TUNER_XC2028; + xc2028_cfg.priv = &ctl; + + saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, &xc2028_cfg); + } return 0; } diff --git a/trunk/drivers/media/video/saa7134/saa7134-i2c.c b/trunk/drivers/media/video/saa7134/saa7134-i2c.c index d8af3863f2d3..2ccfaba0c490 100644 --- a/trunk/drivers/media/video/saa7134/saa7134-i2c.c +++ b/trunk/drivers/media/video/saa7134/saa7134-i2c.c @@ -324,6 +324,8 @@ static u32 functionality(struct i2c_adapter *adap) static int attach_inform(struct i2c_client *client) { struct saa7134_dev *dev = client->adapter->algo_data; + int tuner = dev->tuner_type; + struct tuner_setup tun_setup; d1printk( "%s i2c attach [addr=0x%x,client=%s]\n", client->driver->driver.name, client->addr, client->name); @@ -344,6 +346,46 @@ static int attach_inform(struct i2c_client *client) } } + if (!client->driver->command) + return 0; + + if (saa7134_boards[dev->board].radio_type != UNSET) { + + tun_setup.type = saa7134_boards[dev->board].radio_type; + tun_setup.addr = saa7134_boards[dev->board].radio_addr; + + if ((tun_setup.addr == ADDR_UNSET) || (tun_setup.addr == client->addr)) { + tun_setup.mode_mask = T_RADIO; + + client->driver->command(client, TUNER_SET_TYPE_ADDR, &tun_setup); + } + } + + if (tuner != UNSET) { + tun_setup.type = tuner; + tun_setup.addr = saa7134_boards[dev->board].tuner_addr; + tun_setup.config = saa7134_boards[dev->board].tuner_config; + tun_setup.tuner_callback = saa7134_tuner_callback; + + if ((tun_setup.addr == ADDR_UNSET)||(tun_setup.addr == client->addr)) { + + tun_setup.mode_mask = T_ANALOG_TV; + + client->driver->command(client,TUNER_SET_TYPE_ADDR, &tun_setup); + } + + if (tuner == TUNER_TDA9887) { + struct v4l2_priv_tun_config tda9887_cfg; + + tda9887_cfg.tuner = TUNER_TDA9887; + tda9887_cfg.priv = &dev->tda9887_conf; + + client->driver->command(client, TUNER_SET_CONFIG, + &tda9887_cfg); + } + } + + return 0; } diff --git a/trunk/drivers/media/video/saa7134/saa7134-input.c b/trunk/drivers/media/video/saa7134/saa7134-input.c index 919632b10aae..767ff30832f2 100644 --- a/trunk/drivers/media/video/saa7134/saa7134-input.c +++ b/trunk/drivers/media/video/saa7134/saa7134-input.c @@ -531,7 +531,6 @@ void saa7134_set_i2c_ir(struct saa7134_dev *dev, struct IR_i2c *ir) break; case SAA7134_BOARD_BEHOLD_607_9FM: case SAA7134_BOARD_BEHOLD_M6: - case SAA7134_BOARD_BEHOLD_H6: snprintf(ir->c.name, sizeof(ir->c.name), "BeholdTV"); ir->get_key = get_key_beholdm6xx; ir->ir_codes = ir_codes_behold; diff --git a/trunk/drivers/media/video/saa7134/saa7134.h b/trunk/drivers/media/video/saa7134/saa7134.h index 34ff0d4998f3..924ffd13637e 100644 --- a/trunk/drivers/media/video/saa7134/saa7134.h +++ b/trunk/drivers/media/video/saa7134/saa7134.h @@ -263,7 +263,6 @@ struct saa7134_format { #define SAA7134_BOARD_VIDEOMATE_T750 139 #define SAA7134_BOARD_AVERMEDIA_A700_PRO 140 #define SAA7134_BOARD_AVERMEDIA_A700_HYBRID 141 -#define SAA7134_BOARD_BEHOLD_H6 142 #define SAA7134_MAXBOARDS 8 diff --git a/trunk/drivers/media/video/saa717x.c b/trunk/drivers/media/video/saa717x.c index 72c4081feff5..53c5edbcf7ea 100644 --- a/trunk/drivers/media/video/saa717x.c +++ b/trunk/drivers/media/video/saa717x.c @@ -1418,8 +1418,7 @@ static int saa717x_command(struct i2c_client *client, unsigned cmd, void *arg) /* i2c implementation */ /* ----------------------------------------------------------------------- */ -static int saa717x_probe(struct i2c_client *client, - const struct i2c_device_id *did) +static int saa717x_probe(struct i2c_client *client) { struct saa717x_state *decoder; u8 id = 0; diff --git a/trunk/drivers/media/video/tcm825x.c b/trunk/drivers/media/video/tcm825x.c index e57a64605778..6943b447a1bd 100644 --- a/trunk/drivers/media/video/tcm825x.c +++ b/trunk/drivers/media/video/tcm825x.c @@ -840,8 +840,7 @@ static struct v4l2_int_device tcm825x_int_device = { }, }; -static int tcm825x_probe(struct i2c_client *client, - const struct i2c_device_id *did) +static int tcm825x_probe(struct i2c_client *client) { struct tcm825x_sensor *sensor = &tcm825x; int rval; diff --git a/trunk/drivers/media/common/tuners/tda8290.c b/trunk/drivers/media/video/tda8290.c similarity index 99% rename from trunk/drivers/media/common/tuners/tda8290.c rename to trunk/drivers/media/video/tda8290.c index 91204d3f282d..0ebb5b525e57 100644 --- a/trunk/drivers/media/common/tuners/tda8290.c +++ b/trunk/drivers/media/video/tda8290.c @@ -578,16 +578,16 @@ static int tda829x_find_tuner(struct dvb_frontend *fe) if ((data == 0x83) || (data == 0x84)) { priv->ver |= TDA18271; - dvb_attach(tda18271_attach, fe, priv->tda827x_addr, - priv->i2c_props.adap, &tda829x_tda18271_config); + tda18271_attach(fe, priv->tda827x_addr, + priv->i2c_props.adap, + &tda829x_tda18271_config); } else { if ((data & 0x3c) == 0) priv->ver |= TDA8275; else priv->ver |= TDA8275A; - dvb_attach(tda827x_attach, fe, priv->tda827x_addr, - priv->i2c_props.adap, &priv->cfg); + tda827x_attach(fe, priv->tda827x_addr, priv->i2c_props.adap, &priv->cfg); priv->cfg.switch_addr = priv->i2c_props.addr; } if (fe->ops.tuner_ops.init) diff --git a/trunk/drivers/media/common/tuners/tda8290.h b/trunk/drivers/media/video/tda8290.h similarity index 94% rename from trunk/drivers/media/common/tuners/tda8290.h rename to trunk/drivers/media/video/tda8290.h index aa074f3f0c07..d3bbf276a469 100644 --- a/trunk/drivers/media/common/tuners/tda8290.h +++ b/trunk/drivers/media/video/tda8290.h @@ -29,7 +29,7 @@ struct tda829x_config { #define TDA829X_DONT_PROBE 1 }; -#if defined(CONFIG_MEDIA_TUNER_TDA8290) || (defined(CONFIG_MEDIA_TUNER_TDA8290_MODULE) && defined(MODULE)) +#if defined(CONFIG_TUNER_TDA8290) || (defined(CONFIG_TUNER_TDA8290_MODULE) && defined(MODULE)) extern int tda829x_probe(struct i2c_adapter *i2c_adap, u8 i2c_addr); extern struct dvb_frontend *tda829x_attach(struct dvb_frontend *fe, diff --git a/trunk/drivers/media/common/tuners/tda9887.c b/trunk/drivers/media/video/tda9887.c similarity index 100% rename from trunk/drivers/media/common/tuners/tda9887.c rename to trunk/drivers/media/video/tda9887.c diff --git a/trunk/drivers/media/common/tuners/tda9887.h b/trunk/drivers/media/video/tda9887.h similarity index 92% rename from trunk/drivers/media/common/tuners/tda9887.h rename to trunk/drivers/media/video/tda9887.h index acc419e8c4fc..be49dcbfc70e 100644 --- a/trunk/drivers/media/common/tuners/tda9887.h +++ b/trunk/drivers/media/video/tda9887.h @@ -21,7 +21,7 @@ #include "dvb_frontend.h" /* ------------------------------------------------------------------------ */ -#if defined(CONFIG_MEDIA_TUNER_TDA9887) || (defined(CONFIG_MEDIA_TUNER_TDA9887_MODULE) && defined(MODULE)) +#if defined(CONFIG_TUNER_TDA9887) || (defined(CONFIG_TUNER_TDA9887_MODULE) && defined(MODULE)) extern struct dvb_frontend *tda9887_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c_adap, u8 i2c_addr); diff --git a/trunk/drivers/media/common/tuners/tea5761.c b/trunk/drivers/media/video/tea5761.c similarity index 100% rename from trunk/drivers/media/common/tuners/tea5761.c rename to trunk/drivers/media/video/tea5761.c diff --git a/trunk/drivers/media/common/tuners/tea5761.h b/trunk/drivers/media/video/tea5761.h similarity index 93% rename from trunk/drivers/media/common/tuners/tea5761.h rename to trunk/drivers/media/video/tea5761.h index 2e2ff82c95a4..8eb62722b988 100644 --- a/trunk/drivers/media/common/tuners/tea5761.h +++ b/trunk/drivers/media/video/tea5761.h @@ -20,7 +20,7 @@ #include #include "dvb_frontend.h" -#if defined(CONFIG_MEDIA_TUNER_TEA5761) || (defined(CONFIG_MEDIA_TUNER_TEA5761_MODULE) && defined(MODULE)) +#if defined(CONFIG_TUNER_TEA5761) || (defined(CONFIG_TUNER_TEA5761_MODULE) && defined(MODULE)) extern int tea5761_autodetection(struct i2c_adapter* i2c_adap, u8 i2c_addr); extern struct dvb_frontend *tea5761_attach(struct dvb_frontend *fe, diff --git a/trunk/drivers/media/common/tuners/tea5767.c b/trunk/drivers/media/video/tea5767.c similarity index 100% rename from trunk/drivers/media/common/tuners/tea5767.c rename to trunk/drivers/media/video/tea5767.c diff --git a/trunk/drivers/media/common/tuners/tea5767.h b/trunk/drivers/media/video/tea5767.h similarity index 94% rename from trunk/drivers/media/common/tuners/tea5767.h rename to trunk/drivers/media/video/tea5767.h index d30ab1b483de..7b547c092e25 100644 --- a/trunk/drivers/media/common/tuners/tea5767.h +++ b/trunk/drivers/media/video/tea5767.h @@ -39,7 +39,7 @@ struct tea5767_ctrl { enum tea5767_xtal xtal_freq; }; -#if defined(CONFIG_MEDIA_TUNER_TEA5767) || (defined(CONFIG_MEDIA_TUNER_TEA5767_MODULE) && defined(MODULE)) +#if defined(CONFIG_TUNER_TEA5767) || (defined(CONFIG_TUNER_TEA5767_MODULE) && defined(MODULE)) extern int tea5767_autodetection(struct i2c_adapter* i2c_adap, u8 i2c_addr); extern struct dvb_frontend *tea5767_attach(struct dvb_frontend *fe, diff --git a/trunk/drivers/media/video/tlv320aic23b.c b/trunk/drivers/media/video/tlv320aic23b.c index f1db54202dea..dc7b9c220b90 100644 --- a/trunk/drivers/media/video/tlv320aic23b.c +++ b/trunk/drivers/media/video/tlv320aic23b.c @@ -125,8 +125,7 @@ static int tlv320aic23b_command(struct i2c_client *client, * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' */ -static int tlv320aic23b_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int tlv320aic23b_probe(struct i2c_client *client) { struct tlv320aic23b_state *state; diff --git a/trunk/drivers/media/video/tuner-core.c b/trunk/drivers/media/video/tuner-core.c index cc19c4abb467..2b72e10e6b9f 100644 --- a/trunk/drivers/media/video/tuner-core.c +++ b/trunk/drivers/media/video/tuner-core.c @@ -33,46 +33,6 @@ #define PREFIX t->i2c->driver->driver.name -/** This macro allows us to probe dynamically, avoiding static links */ -#ifdef CONFIG_DVB_CORE_ATTACH -#define tuner_symbol_probe(FUNCTION, ARGS...) ({ \ - int __r = -EINVAL; \ - typeof(&FUNCTION) __a = symbol_request(FUNCTION); \ - if (__a) { \ - __r = (int) __a(ARGS); \ - } else { \ - printk(KERN_ERR "TUNER: Unable to find " \ - "symbol "#FUNCTION"()\n"); \ - } \ - symbol_put(FUNCTION); \ - __r; \ -}) - -static void tuner_detach(struct dvb_frontend *fe) -{ - if (fe->ops.tuner_ops.release) { - fe->ops.tuner_ops.release(fe); - symbol_put_addr(fe->ops.tuner_ops.release); - } - if (fe->ops.analog_ops.release) { - fe->ops.analog_ops.release(fe); - symbol_put_addr(fe->ops.analog_ops.release); - } -} -#else -#define tuner_symbol_probe(FUNCTION, ARGS...) ({ \ - FUNCTION(ARGS); \ -}) - -static void tuner_detach(struct dvb_frontend *fe) -{ - if (fe->ops.tuner_ops.release) - fe->ops.tuner_ops.release(fe); - if (fe->ops.analog_ops.release) - fe->ops.analog_ops.release(fe); -} -#endif - struct tuner { /* device */ struct dvb_frontend fe; @@ -96,7 +56,7 @@ struct tuner { /* standard i2c insmod options */ static unsigned short normal_i2c[] = { -#if defined(CONFIG_MEDIA_TUNER_TEA5761) || (defined(CONFIG_MEDIA_TUNER_TEA5761_MODULE) && defined(MODULE)) +#if defined(CONFIG_TUNER_TEA5761) || (defined(CONFIG_TUNER_TEA5761_MODULE) && defined(MODULE)) 0x10, #endif 0x42, 0x43, 0x4a, 0x4b, /* tda8290 */ @@ -179,6 +139,22 @@ static void fe_set_params(struct dvb_frontend *fe, fe_tuner_ops->set_analog_params(fe, params); } +static void fe_release(struct dvb_frontend *fe) +{ + if (fe->ops.tuner_ops.release) + fe->ops.tuner_ops.release(fe); + + /* DO NOT kfree(fe->analog_demod_priv) + * + * If we are in this function, analog_demod_priv contains a pointer + * to struct tuner *t. This will be kfree'd in tuner_detach(). + * + * Otherwise, fe->ops.analog_demod_ops->release will + * handle the cleanup for analog demodulator modules. + */ + fe->analog_demod_priv = NULL; +} + static void fe_standby(struct dvb_frontend *fe) { struct dvb_tuner_ops *fe_tuner_ops = &fe->ops.tuner_ops; @@ -215,6 +191,7 @@ static void tuner_status(struct dvb_frontend *fe); static struct analog_demod_ops tuner_core_ops = { .set_params = fe_set_params, .standby = fe_standby, + .release = fe_release, .has_signal = fe_has_signal, .set_config = fe_set_config, .tuner_status = tuner_status @@ -346,8 +323,7 @@ static void attach_tda829x(struct tuner *t) .lna_cfg = t->config, .tuner_callback = t->tuner_callback, }; - dvb_attach(tda829x_attach, - &t->fe, t->i2c->adapter, t->i2c->addr, &cfg); + tda829x_attach(&t->fe, t->i2c->adapter, t->i2c->addr, &cfg); } static struct xc5000_config xc5000_cfg; @@ -380,13 +356,12 @@ static void set_type(struct i2c_client *c, unsigned int type, } /* discard private data, in case set_type() was previously called */ - tuner_detach(&t->fe); - t->fe.analog_demod_priv = NULL; + if (analog_ops->release) + analog_ops->release(&t->fe); switch (t->type) { case TUNER_MT2032: - dvb_attach(microtune_attach, - &t->fe, t->i2c->adapter, t->i2c->addr); + microtune_attach(&t->fe, t->i2c->adapter, t->i2c->addr); break; case TUNER_PHILIPS_TDA8290: { @@ -394,14 +369,12 @@ static void set_type(struct i2c_client *c, unsigned int type, break; } case TUNER_TEA5767: - if (!dvb_attach(tea5767_attach, &t->fe, - t->i2c->adapter, t->i2c->addr)) + if (!tea5767_attach(&t->fe, t->i2c->adapter, t->i2c->addr)) goto attach_failed; t->mode_mask = T_RADIO; break; case TUNER_TEA5761: - if (!dvb_attach(tea5761_attach, &t->fe, - t->i2c->adapter, t->i2c->addr)) + if (!tea5761_attach(&t->fe, t->i2c->adapter, t->i2c->addr)) goto attach_failed; t->mode_mask = T_RADIO; break; @@ -415,8 +388,8 @@ static void set_type(struct i2c_client *c, unsigned int type, buffer[2] = 0x86; buffer[3] = 0x54; i2c_master_send(c, buffer, 4); - if (!dvb_attach(simple_tuner_attach, &t->fe, - t->i2c->adapter, t->i2c->addr, t->type)) + if (!simple_tuner_attach(&t->fe, t->i2c->adapter, t->i2c->addr, + t->type)) goto attach_failed; break; case TUNER_PHILIPS_TD1316: @@ -424,9 +397,9 @@ static void set_type(struct i2c_client *c, unsigned int type, buffer[1] = 0xdc; buffer[2] = 0x86; buffer[3] = 0xa4; - i2c_master_send(c, buffer, 4); - if (!dvb_attach(simple_tuner_attach, &t->fe, - t->i2c->adapter, t->i2c->addr, t->type)) + i2c_master_send(c,buffer,4); + if (!simple_tuner_attach(&t->fe, t->i2c->adapter, + t->i2c->addr, t->type)) goto attach_failed; break; case TUNER_XC2028: @@ -436,13 +409,12 @@ static void set_type(struct i2c_client *c, unsigned int type, .i2c_addr = t->i2c->addr, .callback = t->tuner_callback, }; - if (!dvb_attach(xc2028_attach, &t->fe, &cfg)) + if (!xc2028_attach(&t->fe, &cfg)) goto attach_failed; break; } case TUNER_TDA9887: - dvb_attach(tda9887_attach, - &t->fe, t->i2c->adapter, t->i2c->addr); + tda9887_attach(&t->fe, t->i2c->adapter, t->i2c->addr); break; case TUNER_XC5000: { @@ -452,8 +424,7 @@ static void set_type(struct i2c_client *c, unsigned int type, xc5000_cfg.if_khz = 5380; xc5000_cfg.priv = c->adapter->algo_data; xc5000_cfg.tuner_callback = t->tuner_callback; - if (!dvb_attach(xc5000_attach, - &t->fe, t->i2c->adapter, &xc5000_cfg)) + if (!xc5000_attach(&t->fe, t->i2c->adapter, &xc5000_cfg)) goto attach_failed; xc_tuner_ops = &t->fe.ops.tuner_ops; @@ -462,8 +433,8 @@ static void set_type(struct i2c_client *c, unsigned int type, break; } default: - if (!dvb_attach(simple_tuner_attach, &t->fe, - t->i2c->adapter, t->i2c->addr, t->type)) + if (!simple_tuner_attach(&t->fe, t->i2c->adapter, + t->i2c->addr, t->type)) goto attach_failed; break; @@ -471,14 +442,12 @@ static void set_type(struct i2c_client *c, unsigned int type, if ((NULL == analog_ops->set_params) && (fe_tuner_ops->set_analog_params)) { - strlcpy(t->i2c->name, fe_tuner_ops->info.name, sizeof(t->i2c->name)); t->fe.analog_demod_priv = t; memcpy(analog_ops, &tuner_core_ops, sizeof(struct analog_demod_ops)); - } else { strlcpy(t->i2c->name, analog_ops->info.name, sizeof(t->i2c->name)); @@ -676,8 +645,8 @@ static void tuner_status(struct dvb_frontend *fe) { struct tuner *t = fe->analog_demod_priv; unsigned long freq, freq_fraction; - struct dvb_tuner_ops *fe_tuner_ops = &fe->ops.tuner_ops; - struct analog_demod_ops *analog_ops = &fe->ops.analog_ops; + struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops; + struct analog_demod_ops *analog_ops = &t->fe.ops.analog_ops; const char *p; switch (t->mode) { @@ -761,10 +730,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) struct dvb_tuner_ops *fe_tuner_ops = &t->fe.ops.tuner_ops; struct analog_demod_ops *analog_ops = &t->fe.ops.analog_ops; - if (tuner_debug > 1) { + if (tuner_debug>1) v4l_i2c_print_ioctl(client,cmd); - printk("\n"); - } switch (cmd) { /* --- configuration --- */ @@ -1106,8 +1073,7 @@ static void tuner_lookup(struct i2c_adapter *adap, /* During client attach, set_type is called by adapter's attach_inform callback. set_type must then be completed by tuner_probe. */ -static int tuner_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int tuner_probe(struct i2c_client *client) { struct tuner *t; struct tuner *radio; @@ -1145,9 +1111,8 @@ static int tuner_probe(struct i2c_client *client, if (!no_autodetect) { switch (client->addr) { case 0x10: - if (tuner_symbol_probe(tea5761_autodetection, - t->i2c->adapter, - t->i2c->addr) >= 0) { + if (tea5761_autodetection(t->i2c->adapter, + t->i2c->addr) >= 0) { t->type = TUNER_TEA5761; t->mode_mask = T_RADIO; t->mode = T_STANDBY; @@ -1166,8 +1131,8 @@ static int tuner_probe(struct i2c_client *client, case 0x4b: /* If chip is not tda8290, don't register. since it can be tda9887*/ - if (tuner_symbol_probe(tda829x_probe, t->i2c->adapter, - t->i2c->addr) == 0) { + if (tda829x_probe(t->i2c->adapter, + t->i2c->addr) == 0) { tuner_dbg("tda829x detected\n"); } else { /* Default is being tda9887 */ @@ -1179,8 +1144,7 @@ static int tuner_probe(struct i2c_client *client, } break; case 0x60: - if (tuner_symbol_probe(tea5767_autodetection, - t->i2c->adapter, t->i2c->addr) + if (tea5767_autodetection(t->i2c->adapter, t->i2c->addr) != EINVAL) { t->type = TUNER_TEA5767; t->mode_mask = T_RADIO; @@ -1269,9 +1233,10 @@ static int tuner_legacy_probe(struct i2c_adapter *adap) static int tuner_remove(struct i2c_client *client) { struct tuner *t = i2c_get_clientdata(client); + struct analog_demod_ops *analog_ops = &t->fe.ops.analog_ops; - tuner_detach(&t->fe); - t->fe.analog_demod_priv = NULL; + if (analog_ops->release) + analog_ops->release(&t->fe); list_del(&t->list); kfree(t); diff --git a/trunk/drivers/media/common/tuners/tuner-i2c.h b/trunk/drivers/media/video/tuner-i2c.h similarity index 100% rename from trunk/drivers/media/common/tuners/tuner-i2c.h rename to trunk/drivers/media/video/tuner-i2c.h diff --git a/trunk/drivers/media/common/tuners/tuner-simple.c b/trunk/drivers/media/video/tuner-simple.c similarity index 100% rename from trunk/drivers/media/common/tuners/tuner-simple.c rename to trunk/drivers/media/video/tuner-simple.c diff --git a/trunk/drivers/media/common/tuners/tuner-simple.h b/trunk/drivers/media/video/tuner-simple.h similarity index 92% rename from trunk/drivers/media/common/tuners/tuner-simple.h rename to trunk/drivers/media/video/tuner-simple.h index 381fa5d35a9b..e46cf0121e03 100644 --- a/trunk/drivers/media/common/tuners/tuner-simple.h +++ b/trunk/drivers/media/video/tuner-simple.h @@ -20,7 +20,7 @@ #include #include "dvb_frontend.h" -#if defined(CONFIG_MEDIA_TUNER_SIMPLE) || (defined(CONFIG_MEDIA_TUNER_SIMPLE_MODULE) && defined(MODULE)) +#if defined(CONFIG_TUNER_SIMPLE) || (defined(CONFIG_TUNER_SIMPLE_MODULE) && defined(MODULE)) extern struct dvb_frontend *simple_tuner_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c_adap, u8 i2c_addr, diff --git a/trunk/drivers/media/common/tuners/tuner-types.c b/trunk/drivers/media/video/tuner-types.c similarity index 100% rename from trunk/drivers/media/common/tuners/tuner-types.c rename to trunk/drivers/media/video/tuner-types.c diff --git a/trunk/drivers/media/common/tuners/tuner-xc2028-types.h b/trunk/drivers/media/video/tuner-xc2028-types.h similarity index 100% rename from trunk/drivers/media/common/tuners/tuner-xc2028-types.h rename to trunk/drivers/media/video/tuner-xc2028-types.h diff --git a/trunk/drivers/media/common/tuners/tuner-xc2028.c b/trunk/drivers/media/video/tuner-xc2028.c similarity index 100% rename from trunk/drivers/media/common/tuners/tuner-xc2028.c rename to trunk/drivers/media/video/tuner-xc2028.c diff --git a/trunk/drivers/media/common/tuners/tuner-xc2028.h b/trunk/drivers/media/video/tuner-xc2028.h similarity index 93% rename from trunk/drivers/media/common/tuners/tuner-xc2028.h rename to trunk/drivers/media/video/tuner-xc2028.h index 216025cf5d4b..fc2f132a5541 100644 --- a/trunk/drivers/media/common/tuners/tuner-xc2028.h +++ b/trunk/drivers/media/video/tuner-xc2028.h @@ -47,7 +47,7 @@ struct xc2028_config { #define XC2028_TUNER_RESET 0 #define XC2028_RESET_CLK 1 -#if defined(CONFIG_MEDIA_TUNER_XC2028) || (defined(CONFIG_MEDIA_TUNER_XC2028_MODULE) && defined(MODULE)) +#if defined(CONFIG_TUNER_XC2028) || (defined(CONFIG_TUNER_XC2028_MODULE) && defined(MODULE)) extern struct dvb_frontend *xc2028_attach(struct dvb_frontend *fe, struct xc2028_config *cfg); #else diff --git a/trunk/drivers/media/video/tvaudio.c b/trunk/drivers/media/video/tvaudio.c index 6f9945b04e1f..f29a2cd0f2f2 100644 --- a/trunk/drivers/media/video/tvaudio.c +++ b/trunk/drivers/media/video/tvaudio.c @@ -1461,7 +1461,7 @@ static struct CHIPDESC chiplist[] = { /* ---------------------------------------------------------------------- */ /* i2c registration */ -static int chip_probe(struct i2c_client *client, const struct i2c_device_id *id) +static int chip_probe(struct i2c_client *client) { struct CHIPSTATE *chip; struct CHIPDESC *desc; diff --git a/trunk/drivers/media/video/upd64031a.c b/trunk/drivers/media/video/upd64031a.c index 93bfd19dec7d..bd201397a2ac 100644 --- a/trunk/drivers/media/video/upd64031a.c +++ b/trunk/drivers/media/video/upd64031a.c @@ -195,8 +195,7 @@ static int upd64031a_command(struct i2c_client *client, unsigned cmd, void *arg) /* i2c implementation */ -static int upd64031a_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int upd64031a_probe(struct i2c_client *client) { struct upd64031a_state *state; int i; diff --git a/trunk/drivers/media/video/upd64083.c b/trunk/drivers/media/video/upd64083.c index 9ab712a56ce0..2d9a88f70c85 100644 --- a/trunk/drivers/media/video/upd64083.c +++ b/trunk/drivers/media/video/upd64083.c @@ -172,8 +172,7 @@ static int upd64083_command(struct i2c_client *client, unsigned cmd, void *arg) /* i2c implementation */ -static int upd64083_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int upd64083_probe(struct i2c_client *client) { struct upd64083_state *state; int i; diff --git a/trunk/drivers/media/video/usbvision/Kconfig b/trunk/drivers/media/video/usbvision/Kconfig index 74e1d3075a20..fc24ef05b3f3 100644 --- a/trunk/drivers/media/video/usbvision/Kconfig +++ b/trunk/drivers/media/video/usbvision/Kconfig @@ -1,7 +1,7 @@ config VIDEO_USBVISION tristate "USB video devices based on Nogatech NT1003/1004/1005" depends on I2C && VIDEO_V4L2 - select MEDIA_TUNER + select VIDEO_TUNER select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO ---help--- There are more than 50 different USB video devices based on diff --git a/trunk/drivers/media/video/usbvision/Makefile b/trunk/drivers/media/video/usbvision/Makefile index 338718750945..9ac92a80c645 100644 --- a/trunk/drivers/media/video/usbvision/Makefile +++ b/trunk/drivers/media/video/usbvision/Makefile @@ -3,4 +3,3 @@ usbvision-objs := usbvision-core.o usbvision-video.o usbvision-i2c.o usbvision- obj-$(CONFIG_VIDEO_USBVISION) += usbvision.o EXTRA_CFLAGS += -Idrivers/media/video -EXTRA_CFLAGS += -Idrivers/media/common/tuners diff --git a/trunk/drivers/media/video/v4l2-common.c b/trunk/drivers/media/video/v4l2-common.c index e9dd996fd5df..7cc42c1da457 100644 --- a/trunk/drivers/media/video/v4l2-common.c +++ b/trunk/drivers/media/video/v4l2-common.c @@ -710,8 +710,7 @@ EXPORT_SYMBOL(v4l2_chip_ident_i2c_client); /* Helper function for I2C legacy drivers */ int v4l2_i2c_attach(struct i2c_adapter *adapter, int address, struct i2c_driver *driver, - const char *name, - int (*probe)(struct i2c_client *, const struct i2c_device_id *)) + const char *name, int (*probe)(struct i2c_client *)) { struct i2c_client *client; int err; @@ -725,7 +724,7 @@ int v4l2_i2c_attach(struct i2c_adapter *adapter, int address, struct i2c_driver client->driver = driver; strlcpy(client->name, name, sizeof(client->name)); - err = probe(client, NULL); + err = probe(client); if (err == 0) { i2c_attach_client(client); } else { diff --git a/trunk/drivers/media/video/vp27smpx.c b/trunk/drivers/media/video/vp27smpx.c index fac0deba24af..282c81403c97 100644 --- a/trunk/drivers/media/video/vp27smpx.c +++ b/trunk/drivers/media/video/vp27smpx.c @@ -121,8 +121,7 @@ static int vp27smpx_command(struct i2c_client *client, unsigned cmd, void *arg) * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' */ -static int vp27smpx_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int vp27smpx_probe(struct i2c_client *client) { struct vp27smpx_state *state; diff --git a/trunk/drivers/media/video/wm8739.c b/trunk/drivers/media/video/wm8739.c index 0f8ed8461fba..31795b4f8b63 100644 --- a/trunk/drivers/media/video/wm8739.c +++ b/trunk/drivers/media/video/wm8739.c @@ -261,8 +261,7 @@ static int wm8739_command(struct i2c_client *client, unsigned cmd, void *arg) /* i2c implementation */ -static int wm8739_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int wm8739_probe(struct i2c_client *client) { struct wm8739_state *state; diff --git a/trunk/drivers/media/video/wm8775.c b/trunk/drivers/media/video/wm8775.c index 67a409e60c46..869f9e7946b6 100644 --- a/trunk/drivers/media/video/wm8775.c +++ b/trunk/drivers/media/video/wm8775.c @@ -159,8 +159,7 @@ static int wm8775_command(struct i2c_client *client, unsigned cmd, void *arg) * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' */ -static int wm8775_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int wm8775_probe(struct i2c_client *client) { struct wm8775_state *state; diff --git a/trunk/drivers/media/video/zoran_procfs.c b/trunk/drivers/media/video/zoran_procfs.c index 870bc5a70e3f..328ed6e7ac6a 100644 --- a/trunk/drivers/media/video/zoran_procfs.c +++ b/trunk/drivers/media/video/zoran_procfs.c @@ -180,7 +180,6 @@ static ssize_t zoran_write(struct file *file, const char __user *buffer, } static const struct file_operations zoran_operations = { - .owner = THIS_MODULE, .open = zoran_open, .read = seq_read, .write = zoran_write, @@ -196,8 +195,10 @@ zoran_proc_init (struct zoran *zr) char name[8]; snprintf(name, 7, "zoran%d", zr->id); - zr->zoran_proc = proc_create_data(name, 0, NULL, &zoran_operations, zr); - if (zr->zoran_proc != NULL) { + if ((zr->zoran_proc = create_proc_entry(name, 0, NULL))) { + zr->zoran_proc->data = zr; + zr->zoran_proc->owner = THIS_MODULE; + zr->zoran_proc->proc_fops = &zoran_operations; dprintk(2, KERN_INFO "%s: procfs entry /proc/%s allocated. data=%p\n", diff --git a/trunk/drivers/message/i2o/i2o_block.c b/trunk/drivers/message/i2o/i2o_block.c index 81483de8c0fd..a95314897402 100644 --- a/trunk/drivers/message/i2o/i2o_block.c +++ b/trunk/drivers/message/i2o/i2o_block.c @@ -371,7 +371,7 @@ static int i2o_block_prep_req_fn(struct request_queue *q, struct request *req) /* connect the i2o_block_request to the request */ if (!req->special) { ireq = i2o_block_request_alloc(); - if (IS_ERR(ireq)) { + if (unlikely(IS_ERR(ireq))) { osm_debug("unable to allocate i2o_block_request!\n"); return BLKPREP_DEFER; } diff --git a/trunk/drivers/message/i2o/i2o_proc.c b/trunk/drivers/message/i2o/i2o_proc.c index 54a3016ff45d..6fdd072201f9 100644 --- a/trunk/drivers/message/i2o/i2o_proc.c +++ b/trunk/drivers/message/i2o/i2o_proc.c @@ -1893,11 +1893,13 @@ static int i2o_proc_create_entries(struct proc_dir_entry *dir, struct proc_dir_entry *tmp; while (i2o_pe->name) { - tmp = proc_create_data(i2o_pe->name, i2o_pe->mode, dir, - i2o_pe->fops, data); + tmp = create_proc_entry(i2o_pe->name, i2o_pe->mode, dir); if (!tmp) return -1; + tmp->data = data; + tmp->proc_fops = i2o_pe->fops; + i2o_pe++; } diff --git a/trunk/drivers/mfd/htc-pasic3.c b/trunk/drivers/mfd/htc-pasic3.c index 633cbba072f0..4edc120a6359 100644 --- a/trunk/drivers/mfd/htc-pasic3.c +++ b/trunk/drivers/mfd/htc-pasic3.c @@ -132,9 +132,8 @@ static struct ds1wm_platform_data ds1wm_pdata = { .disable = ds1wm_disable, }; -static int ds1wm_device_add(struct platform_device *pasic3_pdev, int bus_shift) +static int ds1wm_device_add(struct device *pasic3_dev, int bus_shift) { - struct device *pasic3_dev = &pasic3_pdev->dev; struct pasic3_data *asic = pasic3_dev->driver_data; struct platform_device *pdev; int ret; @@ -145,8 +144,8 @@ static int ds1wm_device_add(struct platform_device *pasic3_pdev, int bus_shift) return -ENOMEM; } - ret = platform_device_add_resources(pdev, pasic3_pdev->resource, - pasic3_pdev->num_resources); + ret = platform_device_add_resources(pdev, pdev->resource, + pdev->num_resources); if (ret < 0) { dev_dbg(pasic3_dev, "failed to add DS1WM resources\n"); goto exit_pdev_put; @@ -208,7 +207,7 @@ static int __init pasic3_probe(struct platform_device *pdev) return -ENOMEM; } - ret = ds1wm_device_add(pdev, asic->bus_shift); + ret = ds1wm_device_add(dev, asic->bus_shift); if (ret < 0) dev_warn(dev, "failed to register DS1WM\n"); diff --git a/trunk/drivers/misc/hdpuftrs/hdpu_cpustate.c b/trunk/drivers/misc/hdpuftrs/hdpu_cpustate.c index ff51ab67231c..302e92418bbe 100644 --- a/trunk/drivers/misc/hdpuftrs/hdpu_cpustate.c +++ b/trunk/drivers/misc/hdpuftrs/hdpu_cpustate.c @@ -210,10 +210,13 @@ static int hdpu_cpustate_probe(struct platform_device *pdev) return ret; } - proc_de = proc_create("sky_cpustate", 0666, NULL, &proc_cpustate); + proc_de = create_proc_entry("sky_cpustate", 0666, &proc_root); if (!proc_de) { printk(KERN_WARNING "sky_cpustate: " "Unable to create proc entry\n"); + } else { + proc_de->proc_fops = &proc_cpustate; + proc_de->owner = THIS_MODULE; } printk(KERN_INFO "Sky CPU State Driver v" SKY_CPUSTATE_VERSION "\n"); diff --git a/trunk/drivers/misc/hdpuftrs/hdpu_nexus.c b/trunk/drivers/misc/hdpuftrs/hdpu_nexus.c index 08e26beefe64..2fa36f7a6eb3 100644 --- a/trunk/drivers/misc/hdpuftrs/hdpu_nexus.c +++ b/trunk/drivers/misc/hdpuftrs/hdpu_nexus.c @@ -102,17 +102,22 @@ static int hdpu_nexus_probe(struct platform_device *pdev) printk(KERN_ERR "sky_nexus: Could not map slot id\n"); } - hdpu_slot_id = proc_create("sky_slot_id", 0666, NULL, &proc_slot_id); + hdpu_slot_id = create_proc_entry("sky_slot_id", 0666, &proc_root); if (!hdpu_slot_id) { printk(KERN_WARNING "sky_nexus: " "Unable to create proc dir entry: sky_slot_id\n"); + } else { + hdpu_slot_id->proc_fops = &proc_slot_id; + hdpu_slot_id->owner = THIS_MODULE; } - hdpu_chassis_id = proc_create("sky_chassis_id", 0666, NULL, - &proc_chassis_id); - if (!hdpu_chassis_id) + hdpu_chassis_id = create_proc_entry("sky_chassis_id", 0666, &proc_root); + if (!hdpu_chassis_id) { printk(KERN_WARNING "sky_nexus: " "Unable to create proc dir entry: sky_chassis_id\n"); + } else { + hdpu_chassis_id->proc_fops = &proc_chassis_id; + hdpu_chassis_id->owner = THIS_MODULE; } return 0; @@ -123,8 +128,8 @@ static int hdpu_nexus_remove(struct platform_device *pdev) slot_id = -1; chassis_id = -1; - remove_proc_entry("sky_slot_id", NULL); - remove_proc_entry("sky_chassis_id", NULL); + remove_proc_entry("sky_slot_id", &proc_root); + remove_proc_entry("sky_chassis_id", &proc_root); hdpu_slot_id = 0; hdpu_chassis_id = 0; diff --git a/trunk/drivers/misc/ibmasm/command.c b/trunk/drivers/misc/ibmasm/command.c index 276d3fb68094..1a0e7978226a 100644 --- a/trunk/drivers/misc/ibmasm/command.c +++ b/trunk/drivers/misc/ibmasm/command.c @@ -96,7 +96,7 @@ static inline void do_exec_command(struct service_processor *sp) { char tsbuf[32]; - dbg("%s:%d at %s\n", __func__, __LINE__, get_timestamp(tsbuf)); + dbg("%s:%d at %s\n", __FUNCTION__, __LINE__, get_timestamp(tsbuf)); if (ibmasm_send_i2o_message(sp)) { sp->current_command->status = IBMASM_CMD_FAILED; @@ -119,7 +119,7 @@ void ibmasm_exec_command(struct service_processor *sp, struct command *cmd) unsigned long flags; char tsbuf[32]; - dbg("%s:%d at %s\n", __func__, __LINE__, get_timestamp(tsbuf)); + dbg("%s:%d at %s\n", __FUNCTION__, __LINE__, get_timestamp(tsbuf)); spin_lock_irqsave(&sp->lock, flags); @@ -139,7 +139,7 @@ static void exec_next_command(struct service_processor *sp) unsigned long flags; char tsbuf[32]; - dbg("%s:%d at %s\n", __func__, __LINE__, get_timestamp(tsbuf)); + dbg("%s:%d at %s\n", __FUNCTION__, __LINE__, get_timestamp(tsbuf)); spin_lock_irqsave(&sp->lock, flags); sp->current_command = dequeue_command(sp); diff --git a/trunk/drivers/misc/ibmasm/heartbeat.c b/trunk/drivers/misc/ibmasm/heartbeat.c index 1bc4306572a4..3036e785b3e4 100644 --- a/trunk/drivers/misc/ibmasm/heartbeat.c +++ b/trunk/drivers/misc/ibmasm/heartbeat.c @@ -75,9 +75,9 @@ void ibmasm_heartbeat_exit(struct service_processor *sp) { char tsbuf[32]; - dbg("%s:%d at %s\n", __func__, __LINE__, get_timestamp(tsbuf)); + dbg("%s:%d at %s\n", __FUNCTION__, __LINE__, get_timestamp(tsbuf)); ibmasm_wait_for_response(sp->heartbeat, IBMASM_CMD_TIMEOUT_NORMAL); - dbg("%s:%d at %s\n", __func__, __LINE__, get_timestamp(tsbuf)); + dbg("%s:%d at %s\n", __FUNCTION__, __LINE__, get_timestamp(tsbuf)); suspend_heartbeats = 1; command_put(sp->heartbeat); } @@ -88,7 +88,7 @@ void ibmasm_receive_heartbeat(struct service_processor *sp, void *message, size struct dot_command_header *header = (struct dot_command_header *)cmd->buffer; char tsbuf[32]; - dbg("%s:%d at %s\n", __func__, __LINE__, get_timestamp(tsbuf)); + dbg("%s:%d at %s\n", __FUNCTION__, __LINE__, get_timestamp(tsbuf)); if (suspend_heartbeats) return; diff --git a/trunk/drivers/misc/intel_menlow.c b/trunk/drivers/misc/intel_menlow.c index 80a136352408..0c0bb3093e07 100644 --- a/trunk/drivers/misc/intel_menlow.c +++ b/trunk/drivers/misc/intel_menlow.c @@ -175,17 +175,19 @@ static int intel_menlow_memory_add(struct acpi_device *device) goto end; } - acpi_driver_data(device) = cdev; - result = sysfs_create_link(&device->dev.kobj, - &cdev->device.kobj, "thermal_cooling"); - if (result) - goto unregister; - - result = sysfs_create_link(&cdev->device.kobj, - &device->dev.kobj, "device"); - if (result) { - sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); - goto unregister; + if (cdev) { + acpi_driver_data(device) = cdev; + result = sysfs_create_link(&device->dev.kobj, + &cdev->device.kobj, "thermal_cooling"); + if (result) + goto unregister; + + result = sysfs_create_link(&cdev->device.kobj, + &device->dev.kobj, "device"); + if (result) { + sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); + goto unregister; + } } end: diff --git a/trunk/drivers/misc/ioc4.c b/trunk/drivers/misc/ioc4.c index 6f76573e7c8a..05172d2613d6 100644 --- a/trunk/drivers/misc/ioc4.c +++ b/trunk/drivers/misc/ioc4.c @@ -75,7 +75,7 @@ ioc4_register_submodule(struct ioc4_submodule *is) printk(KERN_WARNING "%s: IOC4 submodule %s probe failed " "for pci_dev %s", - __func__, module_name(is->is_owner), + __FUNCTION__, module_name(is->is_owner), pci_name(idd->idd_pdev)); } } @@ -102,7 +102,7 @@ ioc4_unregister_submodule(struct ioc4_submodule *is) printk(KERN_WARNING "%s: IOC4 submodule %s remove failed " "for pci_dev %s.\n", - __func__, module_name(is->is_owner), + __FUNCTION__, module_name(is->is_owner), pci_name(idd->idd_pdev)); } } @@ -282,7 +282,7 @@ ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id) if ((ret = pci_enable_device(pdev))) { printk(KERN_WARNING "%s: Failed to enable IOC4 device for pci_dev %s.\n", - __func__, pci_name(pdev)); + __FUNCTION__, pci_name(pdev)); goto out; } pci_set_master(pdev); @@ -292,7 +292,7 @@ ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id) if (!idd) { printk(KERN_WARNING "%s: Failed to allocate IOC4 data for pci_dev %s.\n", - __func__, pci_name(pdev)); + __FUNCTION__, pci_name(pdev)); ret = -ENODEV; goto out_idd; } @@ -307,7 +307,7 @@ ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id) printk(KERN_WARNING "%s: Unable to find IOC4 misc resource " "for pci_dev %s.\n", - __func__, pci_name(idd->idd_pdev)); + __FUNCTION__, pci_name(idd->idd_pdev)); ret = -ENODEV; goto out_pci; } @@ -316,7 +316,7 @@ ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id) printk(KERN_WARNING "%s: Unable to request IOC4 misc region " "for pci_dev %s.\n", - __func__, pci_name(idd->idd_pdev)); + __FUNCTION__, pci_name(idd->idd_pdev)); ret = -ENODEV; goto out_pci; } @@ -326,7 +326,7 @@ ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id) printk(KERN_WARNING "%s: Unable to remap IOC4 misc region " "for pci_dev %s.\n", - __func__, pci_name(idd->idd_pdev)); + __FUNCTION__, pci_name(idd->idd_pdev)); ret = -ENODEV; goto out_misc_region; } @@ -372,7 +372,7 @@ ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id) printk(KERN_WARNING "%s: IOC4 submodule 0x%s probe failed " "for pci_dev %s.\n", - __func__, module_name(is->is_owner), + __FUNCTION__, module_name(is->is_owner), pci_name(idd->idd_pdev)); } } @@ -406,7 +406,7 @@ ioc4_remove(struct pci_dev *pdev) printk(KERN_WARNING "%s: IOC4 submodule 0x%s remove failed " "for pci_dev %s.\n", - __func__, module_name(is->is_owner), + __FUNCTION__, module_name(is->is_owner), pci_name(idd->idd_pdev)); } } @@ -418,7 +418,7 @@ ioc4_remove(struct pci_dev *pdev) printk(KERN_WARNING "%s: Unable to get IOC4 misc mapping for pci_dev %s. " "Device removal may be incomplete.\n", - __func__, pci_name(idd->idd_pdev)); + __FUNCTION__, pci_name(idd->idd_pdev)); } release_mem_region(idd->idd_bar0, sizeof(struct ioc4_misc_regs)); diff --git a/trunk/drivers/misc/phantom.c b/trunk/drivers/misc/phantom.c index 71d1c84e2fa8..7fa61e907e1c 100644 --- a/trunk/drivers/misc/phantom.c +++ b/trunk/drivers/misc/phantom.c @@ -12,7 +12,6 @@ * or alternatively, you might use OpenHaptics provided by Sensable. */ -#include #include #include #include @@ -92,8 +91,11 @@ static long phantom_ioctl(struct file *file, unsigned int cmd, unsigned long flags; unsigned int i; + if (_IOC_TYPE(cmd) != PH_IOC_MAGIC || + _IOC_NR(cmd) > PH_IOC_MAXNR) + return -ENOTTY; + switch (cmd) { - case PHN_SETREG: case PHN_SET_REG: if (copy_from_user(&r, argp, sizeof(r))) return -EFAULT; @@ -124,7 +126,6 @@ static long phantom_ioctl(struct file *file, unsigned int cmd, phantom_status(dev, dev->status & ~PHB_RUNNING); spin_unlock_irqrestore(&dev->regs_lock, flags); break; - case PHN_SETREGS: case PHN_SET_REGS: if (copy_from_user(&rs, argp, sizeof(rs))) return -EFAULT; @@ -142,7 +143,6 @@ static long phantom_ioctl(struct file *file, unsigned int cmd, } spin_unlock_irqrestore(&dev->regs_lock, flags); break; - case PHN_GETREG: case PHN_GET_REG: if (copy_from_user(&r, argp, sizeof(r))) return -EFAULT; @@ -155,7 +155,6 @@ static long phantom_ioctl(struct file *file, unsigned int cmd, if (copy_to_user(argp, &r, sizeof(r))) return -EFAULT; break; - case PHN_GETREGS: case PHN_GET_REGS: { u32 m; @@ -169,7 +168,6 @@ static long phantom_ioctl(struct file *file, unsigned int cmd, for (i = 0; i < m; i++) if (rs.mask & BIT(i)) rs.values[i] = ioread32(dev->iaddr + i); - atomic_set(&dev->counter, 0); spin_unlock_irqrestore(&dev->regs_lock, flags); if (copy_to_user(argp, &rs, sizeof(rs))) @@ -193,20 +191,6 @@ static long phantom_ioctl(struct file *file, unsigned int cmd, return 0; } -#ifdef CONFIG_COMPAT -static long phantom_compat_ioctl(struct file *filp, unsigned int cmd, - unsigned long arg) -{ - if (_IOC_NR(cmd) <= 3 && _IOC_SIZE(cmd) == sizeof(compat_uptr_t)) { - cmd &= ~(_IOC_SIZEMASK << _IOC_SIZESHIFT); - cmd |= sizeof(void *) << _IOC_SIZESHIFT; - } - return phantom_ioctl(filp, cmd, (unsigned long)compat_ptr(arg)); -} -#else -#define phantom_compat_ioctl NULL -#endif - static int phantom_open(struct inode *inode, struct file *file) { struct phantom_device *dev = container_of(inode->i_cdev, @@ -255,12 +239,11 @@ static unsigned int phantom_poll(struct file *file, poll_table *wait) pr_debug("phantom_poll: %d\n", atomic_read(&dev->counter)); poll_wait(file, &dev->wait, wait); - - if (!(dev->status & PHB_RUNNING)) - mask = POLLERR; - else if (atomic_read(&dev->counter)) + if (atomic_read(&dev->counter)) { mask = POLLIN | POLLRDNORM; - + atomic_dec(&dev->counter); + } else if ((dev->status & PHB_RUNNING) == 0) + mask = POLLIN | POLLRDNORM | POLLERR; pr_debug("phantom_poll end: %x/%d\n", mask, atomic_read(&dev->counter)); return mask; @@ -270,7 +253,6 @@ static struct file_operations phantom_file_ops = { .open = phantom_open, .release = phantom_release, .unlocked_ioctl = phantom_ioctl, - .compat_ioctl = phantom_compat_ioctl, .poll = phantom_poll, }; diff --git a/trunk/drivers/misc/sgi-xp/xpc_partition.c b/trunk/drivers/misc/sgi-xp/xpc_partition.c index acd3fd4285d7..27e200ec5826 100644 --- a/trunk/drivers/misc/sgi-xp/xpc_partition.c +++ b/trunk/drivers/misc/sgi-xp/xpc_partition.c @@ -211,7 +211,7 @@ xpc_rsvd_page_init(void) */ amos_page = xpc_vars->amos_page; if (amos_page == NULL) { - amos_page = (AMO_t *)TO_AMO(uncached_alloc_page(0, 1)); + amos_page = (AMO_t *)TO_AMO(uncached_alloc_page(0)); if (amos_page == NULL) { dev_err(xpc_part, "can't allocate page of AMOs\n"); return NULL; @@ -230,7 +230,7 @@ xpc_rsvd_page_init(void) dev_err(xpc_part, "can't change memory " "protections\n"); uncached_free_page(__IA64_UNCACHED_OFFSET | - TO_PHYS((u64)amos_page), 1); + TO_PHYS((u64)amos_page)); return NULL; } } diff --git a/trunk/drivers/misc/sony-laptop.c b/trunk/drivers/misc/sony-laptop.c index 00e48e2a9c11..02ff3d19b1cc 100644 --- a/trunk/drivers/misc/sony-laptop.c +++ b/trunk/drivers/misc/sony-laptop.c @@ -961,7 +961,7 @@ static int sony_nc_resume(struct acpi_device *device) ret = acpi_callsetfunc(sony_nc_acpi_handle, *item->acpiset, item->value, NULL); if (ret < 0) { - printk("%s: %d\n", __func__, ret); + printk("%s: %d\n", __FUNCTION__, ret); break; } } @@ -1453,7 +1453,7 @@ static struct sonypi_eventtypes type4_events[] = { udelay(1); \ if (!n) \ dprintk("command failed at %s : %s (line %d)\n", \ - __FILE__, __func__, __LINE__); \ + __FILE__, __FUNCTION__, __LINE__); \ } static u8 sony_pic_call1(u8 dev) diff --git a/trunk/drivers/mmc/host/mmc_spi.c b/trunk/drivers/mmc/host/mmc_spi.c index 35508584ac2a..365024b83d3d 100644 --- a/trunk/drivers/mmc/host/mmc_spi.c +++ b/trunk/drivers/mmc/host/mmc_spi.c @@ -340,7 +340,7 @@ static int mmc_spi_response_get(struct mmc_spi_host *host, /* SPI R3, R4, or R7 == R1 + 4 bytes */ case MMC_RSP_SPI_R3: - cmd->resp[1] = get_unaligned_be32(cp); + cmd->resp[1] = be32_to_cpu(get_unaligned((u32 *)cp)); break; /* SPI R1 == just one status byte */ diff --git a/trunk/drivers/mmc/host/mmci.c b/trunk/drivers/mmc/host/mmci.c index 626ac083f4e0..95244a7e7353 100644 --- a/trunk/drivers/mmc/host/mmci.c +++ b/trunk/drivers/mmc/host/mmci.c @@ -213,10 +213,9 @@ static int mmci_pio_read(struct mmci_host *host, char *buffer, unsigned int rema void __iomem *base = host->base; char *ptr = buffer; u32 status; - int host_remain = host->size; do { - int count = host_remain - (readl(base + MMCIFIFOCNT) << 2); + int count = host->size - (readl(base + MMCIFIFOCNT) << 2); if (count > remain) count = remain; @@ -228,7 +227,6 @@ static int mmci_pio_read(struct mmci_host *host, char *buffer, unsigned int rema ptr += count; remain -= count; - host_remain -= count; if (remain == 0) break; diff --git a/trunk/drivers/net/arm/am79c961a.c b/trunk/drivers/net/arm/am79c961a.c index a637910b02dd..ba6bd03a015f 100644 --- a/trunk/drivers/net/arm/am79c961a.c +++ b/trunk/drivers/net/arm/am79c961a.c @@ -693,15 +693,11 @@ static int __init am79c961_probe(struct platform_device *pdev) * done by the ether bootp loader. */ dev->base_addr = res->start; - ret = platform_get_irq(pdev, 0); - - if (ret < 0) { - ret = -ENODEV; - goto nodev; - } - dev->irq = ret; + dev->irq = platform_get_irq(pdev, 0); ret = -ENODEV; + if (dev->irq < 0) + goto nodev; if (!request_region(dev->base_addr, 0x18, dev->name)) goto nodev; diff --git a/trunk/drivers/net/bonding/bond_main.c b/trunk/drivers/net/bonding/bond_main.c index 6425603bc379..6e91b4b7aabb 100644 --- a/trunk/drivers/net/bonding/bond_main.c +++ b/trunk/drivers/net/bonding/bond_main.c @@ -3282,14 +3282,17 @@ static int bond_create_proc_entry(struct bonding *bond) struct net_device *bond_dev = bond->dev; if (bond_proc_dir) { - bond->proc_entry = proc_create_data(bond_dev->name, - S_IRUGO, bond_proc_dir, - &bond_info_fops, bond); + bond->proc_entry = create_proc_entry(bond_dev->name, + S_IRUGO, + bond_proc_dir); if (bond->proc_entry == NULL) { printk(KERN_WARNING DRV_NAME ": Warning: Cannot create /proc/net/%s/%s\n", DRV_NAME, bond_dev->name); } else { + bond->proc_entry->data = bond; + bond->proc_entry->proc_fops = &bond_info_fops; + bond->proc_entry->owner = THIS_MODULE; memcpy(bond->proc_file_name, bond_dev->name, IFNAMSIZ); } } diff --git a/trunk/drivers/net/cxgb3/version.h b/trunk/drivers/net/cxgb3/version.h index a0177fc55e28..229303ff6a39 100644 --- a/trunk/drivers/net/cxgb3/version.h +++ b/trunk/drivers/net/cxgb3/version.h @@ -38,7 +38,7 @@ #define DRV_VERSION "1.0-ko" /* Firmware version */ -#define FW_VERSION_MAJOR 6 +#define FW_VERSION_MAJOR 5 #define FW_VERSION_MINOR 0 #define FW_VERSION_MICRO 0 #endif /* __CHELSIO_VERSION_H */ diff --git a/trunk/drivers/net/e100.c b/trunk/drivers/net/e100.c index f3cba5e24ec5..2d139ec79777 100644 --- a/trunk/drivers/net/e100.c +++ b/trunk/drivers/net/e100.c @@ -1802,7 +1802,7 @@ static int e100_rx_alloc_skb(struct nic *nic, struct rx *rx) * it is protected by the before last buffer's el bit being set */ if (rx->prev->skb) { struct rfd *prev_rfd = (struct rfd *)rx->prev->skb->data; - put_unaligned_le32(rx->dma_addr, &prev_rfd->link); + put_unaligned(cpu_to_le32(rx->dma_addr), &prev_rfd->link); } return 0; diff --git a/trunk/drivers/net/hamachi.c b/trunk/drivers/net/hamachi.c index e5c2380f50ca..b53f6b6491b3 100644 --- a/trunk/drivers/net/hamachi.c +++ b/trunk/drivers/net/hamachi.c @@ -1508,7 +1508,7 @@ static int hamachi_rx(struct net_device *dev) hmp->rx_buf_sz, PCI_DMA_FROMDEVICE); buf_addr = (u8 *) hmp->rx_skbuff[entry]->data; - frame_status = get_unaligned_le32(&(buf_addr[data_size - 12])); + frame_status = le32_to_cpu(get_unaligned((__le32*)&(buf_addr[data_size - 12]))); if (hamachi_debug > 4) printk(KERN_DEBUG " hamachi_rx() status was %8.8x.\n", frame_status); diff --git a/trunk/drivers/net/ibmveth.c b/trunk/drivers/net/ibmveth.c index 00527805e4f1..ce4fc2ec2fe4 100644 --- a/trunk/drivers/net/ibmveth.c +++ b/trunk/drivers/net/ibmveth.c @@ -1302,10 +1302,13 @@ static void ibmveth_proc_register_adapter(struct ibmveth_adapter *adapter) if (ibmveth_proc_dir) { char u_addr[10]; sprintf(u_addr, "%x", adapter->vdev->unit_address); - entry = proc_create_data(u_addr, S_IFREG, ibmveth_proc_dir, - &ibmveth_proc_fops, adapter); - if (!entry) + entry = create_proc_entry(u_addr, S_IFREG, ibmveth_proc_dir); + if (!entry) { ibmveth_error_printk("Cannot create adapter proc entry"); + } else { + entry->data = (void *) adapter; + entry->proc_fops = &ibmveth_proc_fops; + } } return; } diff --git a/trunk/drivers/net/irda/mcs7780.c b/trunk/drivers/net/irda/mcs7780.c index ad92d3ff1c40..93916cf33f29 100644 --- a/trunk/drivers/net/irda/mcs7780.c +++ b/trunk/drivers/net/irda/mcs7780.c @@ -464,7 +464,7 @@ static void mcs_unwrap_fir(struct mcs_cb *mcs, __u8 *buf, int len) } fcs = ~(crc32_le(~0, buf, new_len)); - if(fcs != get_unaligned_le32(buf + new_len)) { + if(fcs != le32_to_cpu(get_unaligned((__le32 *)(buf+new_len)))) { IRDA_ERROR("crc error calc 0x%x len %d\n", fcs, new_len); mcs->stats.rx_errors++; mcs->stats.rx_crc_errors++; diff --git a/trunk/drivers/net/irda/stir4200.c b/trunk/drivers/net/irda/stir4200.c index 051963782749..e59c485bc497 100644 --- a/trunk/drivers/net/irda/stir4200.c +++ b/trunk/drivers/net/irda/stir4200.c @@ -329,7 +329,7 @@ static void fir_eof(struct stir_cb *stir) } fcs = ~(crc32_le(~0, rx_buff->data, len)); - if (fcs != get_unaligned_le32(rx_buff->data + len)) { + if (fcs != le32_to_cpu(get_unaligned((__le32 *)(rx_buff->data+len)))) { pr_debug("crc error calc 0x%x len %d\n", fcs, len); stir->stats.rx_errors++; stir->stats.rx_crc_errors++; diff --git a/trunk/drivers/net/irda/vlsi_ir.c b/trunk/drivers/net/irda/vlsi_ir.c index d15e00b8591e..acd082a96a4f 100644 --- a/trunk/drivers/net/irda/vlsi_ir.c +++ b/trunk/drivers/net/irda/vlsi_ir.c @@ -1674,12 +1674,13 @@ vlsi_irda_probe(struct pci_dev *pdev, const struct pci_device_id *id) if (vlsi_proc_root != NULL) { struct proc_dir_entry *ent; - ent = proc_create_data(ndev->name, S_IFREG|S_IRUGO, - vlsi_proc_root, VLSI_PROC_FOPS, ndev); + ent = create_proc_entry(ndev->name, S_IFREG|S_IRUGO, vlsi_proc_root); if (!ent) { IRDA_WARNING("%s: failed to create proc entry\n", __FUNCTION__); } else { + ent->data = ndev; + ent->proc_fops = VLSI_PROC_FOPS; ent->size = 0; } idev->proc_entry = ent; diff --git a/trunk/drivers/net/mlx4/cq.c b/trunk/drivers/net/mlx4/cq.c index 95e87a2f8896..6fda0af9d0a6 100644 --- a/trunk/drivers/net/mlx4/cq.c +++ b/trunk/drivers/net/mlx4/cq.c @@ -188,8 +188,7 @@ int mlx4_cq_resize(struct mlx4_dev *dev, struct mlx4_cq *cq, EXPORT_SYMBOL_GPL(mlx4_cq_resize); int mlx4_cq_alloc(struct mlx4_dev *dev, int nent, struct mlx4_mtt *mtt, - struct mlx4_uar *uar, u64 db_rec, struct mlx4_cq *cq, - int collapsed) + struct mlx4_uar *uar, u64 db_rec, struct mlx4_cq *cq) { struct mlx4_priv *priv = mlx4_priv(dev); struct mlx4_cq_table *cq_table = &priv->cq_table; @@ -225,7 +224,6 @@ int mlx4_cq_alloc(struct mlx4_dev *dev, int nent, struct mlx4_mtt *mtt, cq_context = mailbox->buf; memset(cq_context, 0, sizeof *cq_context); - cq_context->flags = cpu_to_be32(!!collapsed << 18); cq_context->logsize_usrpage = cpu_to_be32((ilog2(nent) << 24) | uar->index); cq_context->comp_eqn = priv->eq_table.eq[MLX4_EQ_COMP].eqn; cq_context->log_page_size = mtt->page_shift - MLX4_ICM_PAGE_SHIFT; diff --git a/trunk/drivers/net/mlx4/mr.c b/trunk/drivers/net/mlx4/mr.c index cb46446b2691..79b317b88c86 100644 --- a/trunk/drivers/net/mlx4/mr.c +++ b/trunk/drivers/net/mlx4/mr.c @@ -607,9 +607,15 @@ EXPORT_SYMBOL_GPL(mlx4_fmr_enable); void mlx4_fmr_unmap(struct mlx4_dev *dev, struct mlx4_fmr *fmr, u32 *lkey, u32 *rkey) { + u32 key; + if (!fmr->maps) return; + key = key_to_hw_index(fmr->mr.key); + key &= dev->caps.num_mpts - 1; + *lkey = *rkey = fmr->mr.key = hw_index_to_key(key); + fmr->maps = 0; *(u8 *) fmr->mpt = MLX4_MPT_STATUS_SW; diff --git a/trunk/drivers/net/myri10ge/myri10ge.c b/trunk/drivers/net/myri10ge/myri10ge.c index ef63c8d2bd7e..cead81e80f0c 100644 --- a/trunk/drivers/net/myri10ge/myri10ge.c +++ b/trunk/drivers/net/myri10ge/myri10ge.c @@ -2437,7 +2437,7 @@ static int myri10ge_sw_tso(struct sk_buff *skb, struct net_device *dev) int status; segs = skb_gso_segment(skb, dev->features & ~NETIF_F_TSO6); - if (IS_ERR(segs)) + if (unlikely(IS_ERR(segs))) goto drop; while (segs) { diff --git a/trunk/drivers/net/pppoe.c b/trunk/drivers/net/pppoe.c index 58a26a47af29..4fad4ddb3504 100644 --- a/trunk/drivers/net/pppoe.c +++ b/trunk/drivers/net/pppoe.c @@ -1052,9 +1052,11 @@ static int __init pppoe_proc_init(void) { struct proc_dir_entry *p; - p = proc_net_fops_create(&init_net, "pppoe", S_IRUGO, &pppoe_seq_fops); + p = create_proc_entry("pppoe", S_IRUGO, init_net.proc_net); if (!p) return -ENOMEM; + + p->proc_fops = &pppoe_seq_fops; return 0; } #else /* CONFIG_PROC_FS */ diff --git a/trunk/drivers/net/pppol2tp.c b/trunk/drivers/net/pppol2tp.c index 244d7830c92a..3d10ca050b79 100644 --- a/trunk/drivers/net/pppol2tp.c +++ b/trunk/drivers/net/pppol2tp.c @@ -2469,12 +2469,12 @@ static int __init pppol2tp_init(void) goto out_unregister_pppol2tp_proto; #ifdef CONFIG_PROC_FS - pppol2tp_proc = proc_net_fops_create(&init_net, "pppol2tp", 0, - &pppol2tp_proc_fops); + pppol2tp_proc = create_proc_entry("pppol2tp", 0, init_net.proc_net); if (!pppol2tp_proc) { err = -ENOMEM; goto out_unregister_pppox_proto; } + pppol2tp_proc->proc_fops = &pppol2tp_proc_fops; #endif /* CONFIG_PROC_FS */ printk(KERN_INFO "PPPoL2TP kernel driver, %s\n", PPPOL2TP_DRV_VERSION); diff --git a/trunk/drivers/net/rionet.c b/trunk/drivers/net/rionet.c index 2b8fd68bc516..e7fd08adbbac 100644 --- a/trunk/drivers/net/rionet.c +++ b/trunk/drivers/net/rionet.c @@ -77,7 +77,7 @@ static int rionet_capable = 1; * could be made into a hash table to save memory depending * on system trade-offs. */ -static struct rio_dev **rionet_active; +static struct rio_dev *rionet_active[RIO_MAX_ROUTE_ENTRIES]; #define is_rionet_capable(pef, src_ops, dst_ops) \ ((pef & RIO_PEF_INB_MBOX) && \ @@ -195,8 +195,7 @@ static int rionet_start_xmit(struct sk_buff *skb, struct net_device *ndev) } if (eth->h_dest[0] & 0x01) { - for (i = 0; i < RIO_MAX_ROUTE_ENTRIES(rnet->mport->sys_size); - i++) + for (i = 0; i < RIO_MAX_ROUTE_ENTRIES; i++) if (rionet_active[i]) rionet_queue_tx_msg(skb, ndev, rionet_active[i]); @@ -386,8 +385,6 @@ static void rionet_remove(struct rio_dev *rdev) struct net_device *ndev = NULL; struct rionet_peer *peer, *tmp; - free_pages((unsigned long)rionet_active, rdev->net->hport->sys_size ? - __ilog2(sizeof(void *)) + 4 : 0); unregister_netdev(ndev); kfree(ndev); @@ -446,15 +443,6 @@ static int rionet_setup_netdev(struct rio_mport *mport) goto out; } - rionet_active = (struct rio_dev **)__get_free_pages(GFP_KERNEL, - mport->sys_size ? __ilog2(sizeof(void *)) + 4 : 0); - if (!rionet_active) { - rc = -ENOMEM; - goto out; - } - memset((void *)rionet_active, 0, sizeof(void *) * - RIO_MAX_ROUTE_ENTRIES(mport->sys_size)); - /* Set up private area */ rnet = (struct rionet_private *)ndev->priv; rnet->mport = mport; diff --git a/trunk/drivers/net/tehuti.c b/trunk/drivers/net/tehuti.c index 432e837a1760..e83b166aa6b9 100644 --- a/trunk/drivers/net/tehuti.c +++ b/trunk/drivers/net/tehuti.c @@ -649,7 +649,7 @@ static int bdx_ioctl_priv(struct net_device *ndev, struct ifreq *ifr, int cmd) DBG("%d 0x%x 0x%x\n", data[0], data[1], data[2]); } - if (!capable(CAP_SYS_RAWIO)) + if (!capable(CAP_NET_ADMIN)) return -EPERM; switch (data[0]) { diff --git a/trunk/drivers/net/tg3.c b/trunk/drivers/net/tg3.c index b66c75e3b8a1..e3f74c9f78bd 100644 --- a/trunk/drivers/net/tg3.c +++ b/trunk/drivers/net/tg3.c @@ -4361,7 +4361,7 @@ static int tg3_tso_bug(struct tg3 *tp, struct sk_buff *skb) } segs = skb_gso_segment(skb, tp->dev->features & ~NETIF_F_TSO); - if (IS_ERR(segs)) + if (unlikely(IS_ERR(segs))) goto tg3_tso_bug_end; do { diff --git a/trunk/drivers/net/tulip/de4x5.c b/trunk/drivers/net/tulip/de4x5.c index bc30c6e8fea2..6c6fc325c8f9 100644 --- a/trunk/drivers/net/tulip/de4x5.c +++ b/trunk/drivers/net/tulip/de4x5.c @@ -482,6 +482,7 @@ static char version[] __devinitdata = "de4x5.c:V0.546 2001/02/22 davies@maniac.ultranet.com\n"; #define c_char const char +#define TWIDDLE(a) (u_short)le16_to_cpu(get_unaligned((__le16 *)(a))) /* ** MII Information @@ -4404,7 +4405,7 @@ srom_infoleaf_info(struct net_device *dev) } } - lp->infoleaf_offset = get_unaligned_le16(p + 1); + lp->infoleaf_offset = TWIDDLE(p+1); return 0; } @@ -4475,7 +4476,7 @@ srom_exec(struct net_device *dev, u_char *p) while (count--) { gep_wr(((lp->chipset==DC21140) && (lp->ibn!=5) ? - *p++ : get_unaligned_le16(w++)), dev); + *p++ : TWIDDLE(w++)), dev); mdelay(2); /* 2ms per action */ } @@ -4710,10 +4711,10 @@ type1_infoblock(struct net_device *dev, u_char count, u_char *p) lp->active = *p++; lp->phy[lp->active].gep = (*p ? p : NULL); p += (*p + 1); lp->phy[lp->active].rst = (*p ? p : NULL); p += (*p + 1); - lp->phy[lp->active].mc = get_unaligned_le16(p); p += 2; - lp->phy[lp->active].ana = get_unaligned_le16(p); p += 2; - lp->phy[lp->active].fdx = get_unaligned_le16(p); p += 2; - lp->phy[lp->active].ttm = get_unaligned_le16(p); + lp->phy[lp->active].mc = TWIDDLE(p); p += 2; + lp->phy[lp->active].ana = TWIDDLE(p); p += 2; + lp->phy[lp->active].fdx = TWIDDLE(p); p += 2; + lp->phy[lp->active].ttm = TWIDDLE(p); return 0; } else if ((lp->media == INIT) && (lp->timeout < 0)) { lp->ibn = 1; @@ -4750,16 +4751,16 @@ type2_infoblock(struct net_device *dev, u_char count, u_char *p) lp->infoblock_media = (*p) & MEDIA_CODE; if ((*p++) & EXT_FIELD) { - lp->cache.csr13 = get_unaligned_le16(p); p += 2; - lp->cache.csr14 = get_unaligned_le16(p); p += 2; - lp->cache.csr15 = get_unaligned_le16(p); p += 2; + lp->cache.csr13 = TWIDDLE(p); p += 2; + lp->cache.csr14 = TWIDDLE(p); p += 2; + lp->cache.csr15 = TWIDDLE(p); p += 2; } else { lp->cache.csr13 = CSR13; lp->cache.csr14 = CSR14; lp->cache.csr15 = CSR15; } - lp->cache.gepc = ((s32)(get_unaligned_le16(p)) << 16); p += 2; - lp->cache.gep = ((s32)(get_unaligned_le16(p)) << 16); + lp->cache.gepc = ((s32)(TWIDDLE(p)) << 16); p += 2; + lp->cache.gep = ((s32)(TWIDDLE(p)) << 16); lp->infoblock_csr6 = OMR_SIA; lp->useMII = false; @@ -4791,10 +4792,10 @@ type3_infoblock(struct net_device *dev, u_char count, u_char *p) if (MOTO_SROM_BUG) lp->active = 0; lp->phy[lp->active].gep = (*p ? p : NULL); p += (2 * (*p) + 1); lp->phy[lp->active].rst = (*p ? p : NULL); p += (2 * (*p) + 1); - lp->phy[lp->active].mc = get_unaligned_le16(p); p += 2; - lp->phy[lp->active].ana = get_unaligned_le16(p); p += 2; - lp->phy[lp->active].fdx = get_unaligned_le16(p); p += 2; - lp->phy[lp->active].ttm = get_unaligned_le16(p); p += 2; + lp->phy[lp->active].mc = TWIDDLE(p); p += 2; + lp->phy[lp->active].ana = TWIDDLE(p); p += 2; + lp->phy[lp->active].fdx = TWIDDLE(p); p += 2; + lp->phy[lp->active].ttm = TWIDDLE(p); p += 2; lp->phy[lp->active].mci = *p; return 0; } else if ((lp->media == INIT) && (lp->timeout < 0)) { @@ -4834,8 +4835,8 @@ type4_infoblock(struct net_device *dev, u_char count, u_char *p) lp->cache.csr13 = CSR13; /* Hard coded defaults */ lp->cache.csr14 = CSR14; lp->cache.csr15 = CSR15; - lp->cache.gepc = ((s32)(get_unaligned_le16(p)) << 16); p += 2; - lp->cache.gep = ((s32)(get_unaligned_le16(p)) << 16); p += 2; + lp->cache.gepc = ((s32)(TWIDDLE(p)) << 16); p += 2; + lp->cache.gep = ((s32)(TWIDDLE(p)) << 16); p += 2; csr6 = *p++; flags = *p++; diff --git a/trunk/drivers/net/tulip/de4x5.h b/trunk/drivers/net/tulip/de4x5.h index f5f33b3eb067..9fb8d7f07994 100644 --- a/trunk/drivers/net/tulip/de4x5.h +++ b/trunk/drivers/net/tulip/de4x5.h @@ -1017,4 +1017,4 @@ struct de4x5_ioctl { #define DE4X5_SET_OMR 0x0d /* Set the OMR Register contents */ #define DE4X5_GET_REG 0x0e /* Get the DE4X5 Registers */ -#define MOTO_SROM_BUG (lp->active == 8 && (get_unaligned_le32(dev->dev_addr) & 0x00ffffff) == 0x3e0008) +#define MOTO_SROM_BUG ((lp->active == 8) && (((le32_to_cpu(get_unaligned(((__le32 *)dev->dev_addr))))&0x00ffffff)==0x3e0008)) diff --git a/trunk/drivers/net/tulip/tulip.h b/trunk/drivers/net/tulip/tulip.h index 92c68a22f16b..908422f2f320 100644 --- a/trunk/drivers/net/tulip/tulip.h +++ b/trunk/drivers/net/tulip/tulip.h @@ -25,7 +25,6 @@ #include #include #include -#include @@ -305,7 +304,11 @@ enum t21143_csr6_bits { #define RUN_AT(x) (jiffies + (x)) -#define get_u16(ptr) get_unaligned_le16((ptr)) +#if defined(__i386__) /* AKA get_unaligned() */ +#define get_u16(ptr) (*(u16 *)(ptr)) +#else +#define get_u16(ptr) (((u8*)(ptr))[0] + (((u8*)(ptr))[1]<<8)) +#endif struct medialeaf { u8 type; diff --git a/trunk/drivers/net/tulip/tulip_core.c b/trunk/drivers/net/tulip/tulip_core.c index f9d13fa05d64..fa1c1c329a2d 100644 --- a/trunk/drivers/net/tulip/tulip_core.c +++ b/trunk/drivers/net/tulip/tulip_core.c @@ -327,8 +327,8 @@ static void tulip_up(struct net_device *dev) tp->dirty_rx = tp->dirty_tx = 0; if (tp->flags & MC_HASH_ONLY) { - u32 addr_low = get_unaligned_le32(dev->dev_addr); - u32 addr_high = get_unaligned_le16(dev->dev_addr + 4); + u32 addr_low = le32_to_cpu(get_unaligned((__le32 *)dev->dev_addr)); + u32 addr_high = le16_to_cpu(get_unaligned((__le16 *)(dev->dev_addr+4))); if (tp->chip_id == AX88140) { iowrite32(0, ioaddr + CSR13); iowrite32(addr_low, ioaddr + CSR14); @@ -1437,13 +1437,13 @@ static int __devinit tulip_init_one (struct pci_dev *pdev, do value = ioread32(ioaddr + CSR9); while (value < 0 && --boguscnt > 0); - put_unaligned_le16(value, ((__le16 *)dev->dev_addr) + i); + put_unaligned(cpu_to_le16(value), ((__le16*)dev->dev_addr) + i); sum += value & 0xffff; } } else if (chip_idx == COMET) { /* No need to read the EEPROM. */ - put_unaligned_le32(ioread32(ioaddr + 0xA4), dev->dev_addr); - put_unaligned_le16(ioread32(ioaddr + 0xA8), dev->dev_addr + 4); + put_unaligned(cpu_to_le32(ioread32(ioaddr + 0xA4)), (__le32 *)dev->dev_addr); + put_unaligned(cpu_to_le16(ioread32(ioaddr + 0xA8)), (__le16 *)(dev->dev_addr + 4)); for (i = 0; i < 6; i ++) sum += dev->dev_addr[i]; } else { diff --git a/trunk/drivers/net/wireless/airo.c b/trunk/drivers/net/wireless/airo.c index 45f47c1c0a35..932d6b1c9d0b 100644 --- a/trunk/drivers/net/wireless/airo.c +++ b/trunk/drivers/net/wireless/airo.c @@ -3657,7 +3657,7 @@ void mpi_receive_802_11 (struct airo_info *ai) ptr += hdrlen; if (hdrlen == 24) ptr += 6; - gap = get_unaligned_le16(ptr); + gap = le16_to_cpu(get_unaligned((__le16 *)ptr)); ptr += sizeof(__le16); if (gap) { if (gap <= 8) @@ -4347,28 +4347,24 @@ static int proc_config_open( struct inode *inode, struct file *file ); static int proc_wepkey_open( struct inode *inode, struct file *file ); static const struct file_operations proc_statsdelta_ops = { - .owner = THIS_MODULE, .read = proc_read, .open = proc_statsdelta_open, .release = proc_close }; static const struct file_operations proc_stats_ops = { - .owner = THIS_MODULE, .read = proc_read, .open = proc_stats_open, .release = proc_close }; static const struct file_operations proc_status_ops = { - .owner = THIS_MODULE, .read = proc_read, .open = proc_status_open, .release = proc_close }; static const struct file_operations proc_SSID_ops = { - .owner = THIS_MODULE, .read = proc_read, .write = proc_write, .open = proc_SSID_open, @@ -4376,7 +4372,6 @@ static const struct file_operations proc_SSID_ops = { }; static const struct file_operations proc_BSSList_ops = { - .owner = THIS_MODULE, .read = proc_read, .write = proc_write, .open = proc_BSSList_open, @@ -4384,7 +4379,6 @@ static const struct file_operations proc_BSSList_ops = { }; static const struct file_operations proc_APList_ops = { - .owner = THIS_MODULE, .read = proc_read, .write = proc_write, .open = proc_APList_open, @@ -4392,7 +4386,6 @@ static const struct file_operations proc_APList_ops = { }; static const struct file_operations proc_config_ops = { - .owner = THIS_MODULE, .read = proc_read, .write = proc_write, .open = proc_config_open, @@ -4400,7 +4393,6 @@ static const struct file_operations proc_config_ops = { }; static const struct file_operations proc_wepkey_ops = { - .owner = THIS_MODULE, .read = proc_read, .write = proc_write, .open = proc_wepkey_open, @@ -4419,6 +4411,10 @@ struct proc_data { void (*on_close) (struct inode *, struct file *); }; +#ifndef SETPROC_OPS +#define SETPROC_OPS(entry, ops) (entry)->proc_fops = &(ops) +#endif + static int setup_proc_entry( struct net_device *dev, struct airo_info *apriv ) { struct proc_dir_entry *entry; @@ -4434,76 +4430,100 @@ static int setup_proc_entry( struct net_device *dev, apriv->proc_entry->owner = THIS_MODULE; /* Setup the StatsDelta */ - entry = proc_create_data("StatsDelta", - S_IFREG | (S_IRUGO&proc_perm), - apriv->proc_entry, &proc_statsdelta_ops, dev); + entry = create_proc_entry("StatsDelta", + S_IFREG | (S_IRUGO&proc_perm), + apriv->proc_entry); if (!entry) goto fail_stats_delta; entry->uid = proc_uid; entry->gid = proc_gid; + entry->data = dev; + entry->owner = THIS_MODULE; + SETPROC_OPS(entry, proc_statsdelta_ops); /* Setup the Stats */ - entry = proc_create_data("Stats", - S_IFREG | (S_IRUGO&proc_perm), - apriv->proc_entry, &proc_stats_ops, dev); + entry = create_proc_entry("Stats", + S_IFREG | (S_IRUGO&proc_perm), + apriv->proc_entry); if (!entry) goto fail_stats; entry->uid = proc_uid; entry->gid = proc_gid; + entry->data = dev; + entry->owner = THIS_MODULE; + SETPROC_OPS(entry, proc_stats_ops); /* Setup the Status */ - entry = proc_create_data("Status", - S_IFREG | (S_IRUGO&proc_perm), - apriv->proc_entry, &proc_status_ops, dev); + entry = create_proc_entry("Status", + S_IFREG | (S_IRUGO&proc_perm), + apriv->proc_entry); if (!entry) goto fail_status; entry->uid = proc_uid; entry->gid = proc_gid; + entry->data = dev; + entry->owner = THIS_MODULE; + SETPROC_OPS(entry, proc_status_ops); /* Setup the Config */ - entry = proc_create_data("Config", - S_IFREG | proc_perm, - apriv->proc_entry, &proc_config_ops, dev); + entry = create_proc_entry("Config", + S_IFREG | proc_perm, + apriv->proc_entry); if (!entry) goto fail_config; entry->uid = proc_uid; entry->gid = proc_gid; + entry->data = dev; + entry->owner = THIS_MODULE; + SETPROC_OPS(entry, proc_config_ops); /* Setup the SSID */ - entry = proc_create_data("SSID", - S_IFREG | proc_perm, - apriv->proc_entry, &proc_SSID_ops, dev); + entry = create_proc_entry("SSID", + S_IFREG | proc_perm, + apriv->proc_entry); if (!entry) goto fail_ssid; entry->uid = proc_uid; entry->gid = proc_gid; + entry->data = dev; + entry->owner = THIS_MODULE; + SETPROC_OPS(entry, proc_SSID_ops); /* Setup the APList */ - entry = proc_create_data("APList", - S_IFREG | proc_perm, - apriv->proc_entry, &proc_APList_ops, dev); + entry = create_proc_entry("APList", + S_IFREG | proc_perm, + apriv->proc_entry); if (!entry) goto fail_aplist; entry->uid = proc_uid; entry->gid = proc_gid; + entry->data = dev; + entry->owner = THIS_MODULE; + SETPROC_OPS(entry, proc_APList_ops); /* Setup the BSSList */ - entry = proc_create_data("BSSList", - S_IFREG | proc_perm, - apriv->proc_entry, &proc_BSSList_ops, dev); + entry = create_proc_entry("BSSList", + S_IFREG | proc_perm, + apriv->proc_entry); if (!entry) goto fail_bsslist; entry->uid = proc_uid; entry->gid = proc_gid; + entry->data = dev; + entry->owner = THIS_MODULE; + SETPROC_OPS(entry, proc_BSSList_ops); /* Setup the WepKey */ - entry = proc_create_data("WepKey", - S_IFREG | proc_perm, - apriv->proc_entry, &proc_wepkey_ops, dev); + entry = create_proc_entry("WepKey", + S_IFREG | proc_perm, + apriv->proc_entry); if (!entry) goto fail_wepkey; entry->uid = proc_uid; entry->gid = proc_gid; + entry->data = dev; + entry->owner = THIS_MODULE; + SETPROC_OPS(entry, proc_wepkey_ops); return 0; @@ -5605,9 +5625,9 @@ static int __init airo_init_module( void ) int have_isa_dev = 0; #endif - airo_entry = create_proc_entry("driver/aironet", + airo_entry = create_proc_entry("aironet", S_IFDIR | airo_perm, - NULL); + proc_root_driver); if (airo_entry) { airo_entry->uid = proc_uid; @@ -5631,7 +5651,7 @@ static int __init airo_init_module( void ) airo_print_info("", "Finished probing for PCI adapters"); if (i) { - remove_proc_entry("driver/aironet", NULL); + remove_proc_entry("aironet", proc_root_driver); return i; } #endif @@ -5653,7 +5673,7 @@ static void __exit airo_cleanup_module( void ) #ifdef CONFIG_PCI pci_unregister_driver(&airo_driver); #endif - remove_proc_entry("driver/aironet", NULL); + remove_proc_entry("aironet", proc_root_driver); } /* diff --git a/trunk/drivers/net/wireless/ath5k/base.c b/trunk/drivers/net/wireless/ath5k/base.c index 4e5c8fc35200..e18305b781c9 100644 --- a/trunk/drivers/net/wireless/ath5k/base.c +++ b/trunk/drivers/net/wireless/ath5k/base.c @@ -58,6 +58,10 @@ #include "reg.h" #include "debug.h" +/* unaligned little endian access */ +#define LE_READ_2(_p) (le16_to_cpu(get_unaligned((__le16 *)(_p)))) +#define LE_READ_4(_p) (le32_to_cpu(get_unaligned((__le32 *)(_p)))) + enum { ATH_LED_TX, ATH_LED_RX, @@ -2905,9 +2909,9 @@ static void ath5k_configure_filter(struct ieee80211_hw *hw, if (!mclist) break; /* calculate XOR of eight 6-bit values */ - val = get_unaligned_le32(mclist->dmi_addr + 0); + val = LE_READ_4(mclist->dmi_addr + 0); pos = (val >> 18) ^ (val >> 12) ^ (val >> 6) ^ val; - val = get_unaligned_le32(mclist->dmi_addr + 3); + val = LE_READ_4(mclist->dmi_addr + 3); pos ^= (val >> 18) ^ (val >> 12) ^ (val >> 6) ^ val; pos &= 0x3f; mfilt[pos / 32] |= (1 << (pos % 32)); diff --git a/trunk/drivers/net/wireless/b43/main.c b/trunk/drivers/net/wireless/b43/main.c index 8c24cd72aaca..4bf8a99099fe 100644 --- a/trunk/drivers/net/wireless/b43/main.c +++ b/trunk/drivers/net/wireless/b43/main.c @@ -2171,7 +2171,7 @@ static int b43_write_initvals(struct b43_wldev *dev, goto err_format; array_size -= sizeof(iv->data.d32); - value = get_unaligned_be32(&iv->data.d32); + value = be32_to_cpu(get_unaligned(&iv->data.d32)); b43_write32(dev, offset, value); iv = (const struct b43_iv *)((const uint8_t *)iv + diff --git a/trunk/drivers/net/wireless/b43legacy/main.c b/trunk/drivers/net/wireless/b43legacy/main.c index 14a5eea2573e..ef829ee8ffd4 100644 --- a/trunk/drivers/net/wireless/b43legacy/main.c +++ b/trunk/drivers/net/wireless/b43legacy/main.c @@ -1720,7 +1720,7 @@ static int b43legacy_write_initvals(struct b43legacy_wldev *dev, goto err_format; array_size -= sizeof(iv->data.d32); - value = get_unaligned_be32(&iv->data.d32); + value = be32_to_cpu(get_unaligned(&iv->data.d32)); b43legacy_write32(dev, offset, value); iv = (const struct b43legacy_iv *)((const uint8_t *)iv + diff --git a/trunk/drivers/net/wireless/iwlwifi/iwl-3945.c b/trunk/drivers/net/wireless/iwlwifi/iwl-3945.c index d3406830c8e3..598e4eef4f40 100644 --- a/trunk/drivers/net/wireless/iwlwifi/iwl-3945.c +++ b/trunk/drivers/net/wireless/iwlwifi/iwl-3945.c @@ -554,36 +554,40 @@ static void iwl3945_add_radiotap(struct iwl3945_priv *priv, iwl3945_rt->rt_hdr.it_pad = 0; /* total header + data */ - put_unaligned_le16(sizeof(*iwl3945_rt), &iwl3945_rt->rt_hdr.it_len); + put_unaligned(cpu_to_le16(sizeof(*iwl3945_rt)), + &iwl3945_rt->rt_hdr.it_len); /* Indicate all the fields we add to the radiotap header */ - put_unaligned_le32((1 << IEEE80211_RADIOTAP_TSFT) | - (1 << IEEE80211_RADIOTAP_FLAGS) | - (1 << IEEE80211_RADIOTAP_RATE) | - (1 << IEEE80211_RADIOTAP_CHANNEL) | - (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | - (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) | - (1 << IEEE80211_RADIOTAP_ANTENNA), - &iwl3945_rt->rt_hdr.it_present); + put_unaligned(cpu_to_le32((1 << IEEE80211_RADIOTAP_TSFT) | + (1 << IEEE80211_RADIOTAP_FLAGS) | + (1 << IEEE80211_RADIOTAP_RATE) | + (1 << IEEE80211_RADIOTAP_CHANNEL) | + (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | + (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) | + (1 << IEEE80211_RADIOTAP_ANTENNA)), + &iwl3945_rt->rt_hdr.it_present); /* Zero the flags, we'll add to them as we go */ iwl3945_rt->rt_flags = 0; - put_unaligned_le64(tsf, &iwl3945_rt->rt_tsf); + put_unaligned(cpu_to_le64(tsf), &iwl3945_rt->rt_tsf); iwl3945_rt->rt_dbmsignal = signal; iwl3945_rt->rt_dbmnoise = noise; /* Convert the channel frequency and set the flags */ - put_unaligned_le16(stats->freq, &iwl3945_rt->rt_channelMHz); + put_unaligned(cpu_to_le16(stats->freq), &iwl3945_rt->rt_channelMHz); if (!(phy_flags_hw & RX_RES_PHY_FLAGS_BAND_24_MSK)) - put_unaligned_le16(IEEE80211_CHAN_OFDM | IEEE80211_CHAN_5GHZ, + put_unaligned(cpu_to_le16(IEEE80211_CHAN_OFDM | + IEEE80211_CHAN_5GHZ), &iwl3945_rt->rt_chbitmask); else if (phy_flags_hw & RX_RES_PHY_FLAGS_MOD_CCK_MSK) - put_unaligned_le16(IEEE80211_CHAN_CCK | IEEE80211_CHAN_2GHZ, + put_unaligned(cpu_to_le16(IEEE80211_CHAN_CCK | + IEEE80211_CHAN_2GHZ), &iwl3945_rt->rt_chbitmask); else /* 802.11g */ - put_unaligned_le16(IEEE80211_CHAN_OFDM | IEEE80211_CHAN_2GHZ, + put_unaligned(cpu_to_le16(IEEE80211_CHAN_OFDM | + IEEE80211_CHAN_2GHZ), &iwl3945_rt->rt_chbitmask); if (rate == -1) diff --git a/trunk/drivers/net/wireless/libertas/scan.c b/trunk/drivers/net/wireless/libertas/scan.c index 1a409fcc80d3..e72c97a0d6c1 100644 --- a/trunk/drivers/net/wireless/libertas/scan.c +++ b/trunk/drivers/net/wireless/libertas/scan.c @@ -522,7 +522,7 @@ static int lbs_process_bss(struct bss_descriptor *bss, if (*bytesleft >= sizeof(beaconsize)) { /* Extract & convert beacon size from the command buffer */ - beaconsize = get_unaligned_le16(*pbeaconinfo); + beaconsize = le16_to_cpu(get_unaligned((__le16 *)*pbeaconinfo)); *bytesleft -= sizeof(beaconsize); *pbeaconinfo += sizeof(beaconsize); } diff --git a/trunk/drivers/net/wireless/zd1211rw/zd_usb.c b/trunk/drivers/net/wireless/zd1211rw/zd_usb.c index 5316074f39f0..e34675c2f8fc 100644 --- a/trunk/drivers/net/wireless/zd1211rw/zd_usb.c +++ b/trunk/drivers/net/wireless/zd1211rw/zd_usb.c @@ -545,11 +545,11 @@ static void handle_rx_packet(struct zd_usb *usb, const u8 *buffer, * be padded. Unaligned access might also happen if the length_info * structure is not present. */ - if (get_unaligned_le16(&length_info->tag) == RX_LENGTH_INFO_TAG) + if (get_unaligned(&length_info->tag) == cpu_to_le16(RX_LENGTH_INFO_TAG)) { unsigned int l, k, n; for (i = 0, l = 0;; i++) { - k = get_unaligned_le16(&length_info->length[i]); + k = le16_to_cpu(get_unaligned(&length_info->length[i])); if (k == 0) return; n = l+k; diff --git a/trunk/drivers/net/yellowfin.c b/trunk/drivers/net/yellowfin.c index 57e1f495b9fc..24640726f8bb 100644 --- a/trunk/drivers/net/yellowfin.c +++ b/trunk/drivers/net/yellowfin.c @@ -1062,7 +1062,7 @@ static int yellowfin_rx(struct net_device *dev) buf_addr = rx_skb->data; data_size = (le32_to_cpu(desc->dbdma_cmd) - le32_to_cpu(desc->result_status)) & 0xffff; - frame_status = get_unaligned_le16(&(buf_addr[data_size - 2])); + frame_status = le16_to_cpu(get_unaligned((__le16*)&(buf_addr[data_size - 2]))); if (yellowfin_debug > 4) printk(KERN_DEBUG " yellowfin_rx() status was %4.4x.\n", frame_status); diff --git a/trunk/drivers/nubus/proc.c b/trunk/drivers/nubus/proc.c index 208dd12825bc..e07492be1f4a 100644 --- a/trunk/drivers/nubus/proc.c +++ b/trunk/drivers/nubus/proc.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include @@ -29,36 +28,38 @@ #include static int -nubus_devices_proc_show(struct seq_file *m, void *v) +get_nubus_dev_info(char *buf, char **start, off_t pos, int count) { struct nubus_dev *dev = nubus_devices; + off_t at = 0; + int len, cnt; - while (dev) { - seq_printf(m, "%x\t%04x %04x %04x %04x", + cnt = 0; + while (dev && count > cnt) { + len = sprintf(buf, "%x\t%04x %04x %04x %04x", dev->board->slot, dev->category, dev->type, dev->dr_sw, dev->dr_hw); - seq_printf(m, "\t%08lx\n", dev->board->slot_addr); + len += sprintf(buf+len, + "\t%08lx", + dev->board->slot_addr); + buf[len++] = '\n'; + at += len; + if (at >= pos) { + if (!*start) { + *start = buf + (pos - (at - len)); + cnt = at - pos; + } else + cnt += len; + buf += len; + } dev = dev->next; } - return 0; -} - -static int nubus_devices_proc_open(struct inode *inode, struct file *file) -{ - return single_open(file, nubus_devices_proc_show, NULL); + return (count > cnt) ? cnt : count; } -static const struct file_operations nubus_devices_proc_fops = { - .owner = THIS_MODULE, - .open = nubus_devices_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - static struct proc_dir_entry *proc_bus_nubus_dir; static void nubus_proc_subdir(struct nubus_dev* dev, @@ -170,7 +171,8 @@ void __init nubus_proc_init(void) { if (!MACH_IS_MAC) return; - proc_bus_nubus_dir = proc_mkdir("bus/nubus", NULL); - proc_create("devices", 0, proc_bus_nubus_dir, &nubus_devices_proc_fops); + proc_bus_nubus_dir = proc_mkdir("nubus", proc_bus); + create_proc_info_entry("devices", 0, proc_bus_nubus_dir, + get_nubus_dev_info); proc_bus_nubus_add_devices(); } diff --git a/trunk/drivers/parisc/ccio-dma.c b/trunk/drivers/parisc/ccio-dma.c index 07d2a8d4498f..62db3c3fe4dc 100644 --- a/trunk/drivers/parisc/ccio-dma.c +++ b/trunk/drivers/parisc/ccio-dma.c @@ -1551,7 +1551,8 @@ static int __init ccio_probe(struct parisc_device *dev) { int i; struct ioc *ioc, **ioc_p = &ioc_list; - + struct proc_dir_entry *info_entry, *bitmap_entry; + ioc = kzalloc(sizeof(struct ioc), GFP_KERNEL); if (ioc == NULL) { printk(KERN_ERR MODULE_NAME ": memory allocation failure\n"); @@ -1579,10 +1580,13 @@ static int __init ccio_probe(struct parisc_device *dev) HBA_DATA(dev->dev.platform_data)->iommu = ioc; if (ioc_count == 0) { - proc_create(MODULE_NAME, 0, proc_runway_root, - &ccio_proc_info_fops); - proc_create(MODULE_NAME"-bitmap", 0, proc_runway_root, - &ccio_proc_bitmap_fops); + info_entry = create_proc_entry(MODULE_NAME, 0, proc_runway_root); + if (info_entry) + info_entry->proc_fops = &ccio_proc_info_fops; + + bitmap_entry = create_proc_entry(MODULE_NAME"-bitmap", 0, proc_runway_root); + if (bitmap_entry) + bitmap_entry->proc_fops = &ccio_proc_bitmap_fops; } ioc_count++; diff --git a/trunk/drivers/parisc/sba_iommu.c b/trunk/drivers/parisc/sba_iommu.c index afc849bd3f58..8c4d2c13d5f2 100644 --- a/trunk/drivers/parisc/sba_iommu.c +++ b/trunk/drivers/parisc/sba_iommu.c @@ -1895,9 +1895,7 @@ sba_driver_callback(struct parisc_device *dev) int i; char *version; void __iomem *sba_addr = ioremap_nocache(dev->hpa.start, SBA_FUNC_SIZE); -#ifdef CONFIG_PROC_FS - struct proc_dir_entry *root; -#endif + struct proc_dir_entry *info_entry, *bitmap_entry, *root; sba_dump_ranges(sba_addr); @@ -1975,8 +1973,14 @@ sba_driver_callback(struct parisc_device *dev) break; } - proc_create("sba_iommu", 0, root, &sba_proc_fops); - proc_create("sba_iommu-bitmap", 0, root, &sba_proc_bitmap_fops); + info_entry = create_proc_entry("sba_iommu", 0, root); + bitmap_entry = create_proc_entry("sba_iommu-bitmap", 0, root); + + if (info_entry) + info_entry->proc_fops = &sba_proc_fops; + + if (bitmap_entry) + bitmap_entry->proc_fops = &sba_proc_bitmap_fops; #endif parisc_vmerge_boundary = IOVP_SIZE; diff --git a/trunk/drivers/parport/parport_pc.c b/trunk/drivers/parport/parport_pc.c index e71092e80288..a85808938205 100644 --- a/trunk/drivers/parport/parport_pc.c +++ b/trunk/drivers/parport/parport_pc.c @@ -3082,7 +3082,6 @@ static struct pci_driver parport_pc_pci_driver; static int __init parport_pc_init_superio(int autoirq, int autodma) {return 0;} #endif /* CONFIG_PCI */ -#ifdef CONFIG_PNP static const struct pnp_device_id parport_pc_pnp_tbl[] = { /* Standard LPT Printer Port */ @@ -3149,9 +3148,6 @@ static struct pnp_driver parport_pc_pnp_driver = { .remove = parport_pc_pnp_remove, }; -#else -static struct pnp_driver parport_pc_pnp_driver; -#endif /* CONFIG_PNP */ static int __devinit parport_pc_platform_probe(struct platform_device *pdev) { diff --git a/trunk/drivers/pci/hotplug/pciehp.h b/trunk/drivers/pci/hotplug/pciehp.h index 8264a7680435..f14267e197dd 100644 --- a/trunk/drivers/pci/hotplug/pciehp.h +++ b/trunk/drivers/pci/hotplug/pciehp.h @@ -93,10 +93,11 @@ struct controller { u8 slot_device_offset; u32 first_slot; /* First physical slot number */ /* PCIE only has 1 slot */ u8 slot_bus; /* Bus where the slots handled by this controller sit */ - u32 slot_cap; + u8 ctrlcap; u8 cap_base; struct timer_list poll_timer; volatile int cmd_busy; + spinlock_t lock; }; #define INT_BUTTON_IGNORE 0 @@ -136,13 +137,13 @@ struct controller { #define HP_SUPR_RM_SUP 0x00000020 #define EMI_PRSN 0x00020000 -#define ATTN_BUTTN(ctrl) ((ctrl)->slot_cap & ATTN_BUTTN_PRSN) -#define POWER_CTRL(ctrl) ((ctrl)->slot_cap & PWR_CTRL_PRSN) -#define MRL_SENS(ctrl) ((ctrl)->slot_cap & MRL_SENS_PRSN) -#define ATTN_LED(ctrl) ((ctrl)->slot_cap & ATTN_LED_PRSN) -#define PWR_LED(ctrl) ((ctrl)->slot_cap & PWR_LED_PRSN) -#define HP_SUPR_RM(ctrl) ((ctrl)->slot_cap & HP_SUPR_RM_SUP) -#define EMI(ctrl) ((ctrl)->slot_cap & EMI_PRSN) +#define ATTN_BUTTN(cap) (cap & ATTN_BUTTN_PRSN) +#define POWER_CTRL(cap) (cap & PWR_CTRL_PRSN) +#define MRL_SENS(cap) (cap & MRL_SENS_PRSN) +#define ATTN_LED(cap) (cap & ATTN_LED_PRSN) +#define PWR_LED(cap) (cap & PWR_LED_PRSN) +#define HP_SUPR_RM(cap) (cap & HP_SUPR_RM_SUP) +#define EMI(cap) (cap & EMI_PRSN) extern int pciehp_sysfs_enable_slot(struct slot *slot); extern int pciehp_sysfs_disable_slot(struct slot *slot); diff --git a/trunk/drivers/pci/hotplug/pciehp_core.c b/trunk/drivers/pci/hotplug/pciehp_core.c index 43d8ddb2d679..aee19f013d84 100644 --- a/trunk/drivers/pci/hotplug/pciehp_core.c +++ b/trunk/drivers/pci/hotplug/pciehp_core.c @@ -41,7 +41,6 @@ int pciehp_debug; int pciehp_poll_mode; int pciehp_poll_time; int pciehp_force; -int pciehp_slot_with_bus; struct workqueue_struct *pciehp_wq; #define DRIVER_VERSION "0.4" @@ -56,12 +55,10 @@ module_param(pciehp_debug, bool, 0644); module_param(pciehp_poll_mode, bool, 0644); module_param(pciehp_poll_time, int, 0644); module_param(pciehp_force, bool, 0644); -module_param(pciehp_slot_with_bus, bool, 0644); MODULE_PARM_DESC(pciehp_debug, "Debugging mode enabled or not"); MODULE_PARM_DESC(pciehp_poll_mode, "Using polling mechanism for hot-plug events or not"); MODULE_PARM_DESC(pciehp_poll_time, "Polling mechanism frequency, in seconds"); MODULE_PARM_DESC(pciehp_force, "Force pciehp, even if _OSC and OSHP are missing"); -MODULE_PARM_DESC(pciehp_slot_with_bus, "Use bus number in the slot name"); #define PCIE_MODULE_NAME "pciehp" @@ -196,12 +193,8 @@ static void release_slot(struct hotplug_slot *hotplug_slot) static void make_slot_name(struct slot *slot) { - if (pciehp_slot_with_bus) - snprintf(slot->hotplug_slot->name, SLOT_NAME_SIZE, "%04d_%04d", - slot->bus, slot->number); - else - snprintf(slot->hotplug_slot->name, SLOT_NAME_SIZE, "%d", - slot->number); + snprintf(slot->hotplug_slot->name, SLOT_NAME_SIZE, "%04d_%04d", + slot->bus, slot->number); } static int init_slots(struct controller *ctrl) @@ -258,7 +251,7 @@ static int init_slots(struct controller *ctrl) goto error_info; } /* create additional sysfs entries */ - if (EMI(ctrl)) { + if (EMI(ctrl->ctrlcap)) { retval = sysfs_create_file(&hotplug_slot->kobj, &hotplug_slot_attr_lock.attr); if (retval) { @@ -291,7 +284,7 @@ static void cleanup_slots(struct controller *ctrl) list_for_each_safe(tmp, next, &ctrl->slot_list) { slot = list_entry(tmp, struct slot, slot_list); list_del(&slot->slot_list); - if (EMI(ctrl)) + if (EMI(ctrl->ctrlcap)) sysfs_remove_file(&slot->hotplug_slot->kobj, &hotplug_slot_attr_lock.attr); cancel_delayed_work(&slot->work); @@ -312,7 +305,7 @@ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status) hotplug_slot->info->attention_status = status; - if (ATTN_LED(slot->ctrl)) + if (ATTN_LED(slot->ctrl->ctrlcap)) slot->hpc_ops->set_attention_status(slot, status); return 0; @@ -479,7 +472,7 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_ if (rc) /* -ENODEV: shouldn't happen, but deal with it */ value = 0; } - if ((POWER_CTRL(ctrl)) && !value) { + if ((POWER_CTRL(ctrl->ctrlcap)) && !value) { rc = t_slot->hpc_ops->power_off_slot(t_slot); /* Power off slot if not occupied*/ if (rc) goto err_out_free_ctrl_slot; diff --git a/trunk/drivers/pci/hotplug/pciehp_ctrl.c b/trunk/drivers/pci/hotplug/pciehp_ctrl.c index 0a7aa628e955..0c481f7d2ab3 100644 --- a/trunk/drivers/pci/hotplug/pciehp_ctrl.c +++ b/trunk/drivers/pci/hotplug/pciehp_ctrl.c @@ -178,7 +178,7 @@ u8 pciehp_handle_power_fault(u8 hp_slot, struct controller *ctrl) static void set_slot_off(struct controller *ctrl, struct slot * pslot) { /* turn off slot, turn on Amber LED, turn off Green LED if supported*/ - if (POWER_CTRL(ctrl)) { + if (POWER_CTRL(ctrl->ctrlcap)) { if (pslot->hpc_ops->power_off_slot(pslot)) { err("%s: Issue of Slot Power Off command failed\n", __func__); @@ -186,10 +186,10 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot) } } - if (PWR_LED(ctrl)) + if (PWR_LED(ctrl->ctrlcap)) pslot->hpc_ops->green_led_off(pslot); - if (ATTN_LED(ctrl)) { + if (ATTN_LED(ctrl->ctrlcap)) { if (pslot->hpc_ops->set_attention_status(pslot, 1)) { err("%s: Issue of Set Attention Led command failed\n", __func__); @@ -214,14 +214,14 @@ static int board_added(struct slot *p_slot) __func__, p_slot->device, ctrl->slot_device_offset, p_slot->hp_slot); - if (POWER_CTRL(ctrl)) { + if (POWER_CTRL(ctrl->ctrlcap)) { /* Power on slot */ retval = p_slot->hpc_ops->power_on_slot(p_slot); if (retval) return retval; } - if (PWR_LED(ctrl)) + if (PWR_LED(ctrl->ctrlcap)) p_slot->hpc_ops->green_led_blink(p_slot); /* Wait for ~1 second */ @@ -254,7 +254,7 @@ static int board_added(struct slot *p_slot) */ if (pcie_mch_quirk) pci_fixup_device(pci_fixup_final, ctrl->pci_dev); - if (PWR_LED(ctrl)) + if (PWR_LED(ctrl->ctrlcap)) p_slot->hpc_ops->green_led_on(p_slot); return 0; @@ -279,7 +279,7 @@ static int remove_board(struct slot *p_slot) dbg("In %s, hp_slot = %d\n", __func__, p_slot->hp_slot); - if (POWER_CTRL(ctrl)) { + if (POWER_CTRL(ctrl->ctrlcap)) { /* power off slot */ retval = p_slot->hpc_ops->power_off_slot(p_slot); if (retval) { @@ -289,7 +289,7 @@ static int remove_board(struct slot *p_slot) } } - if (PWR_LED(ctrl)) + if (PWR_LED(ctrl->ctrlcap)) /* turn off Green LED */ p_slot->hpc_ops->green_led_off(p_slot); @@ -327,7 +327,7 @@ static void pciehp_power_thread(struct work_struct *work) case POWERON_STATE: mutex_unlock(&p_slot->lock); if (pciehp_enable_slot(p_slot) && - PWR_LED(p_slot->ctrl)) + PWR_LED(p_slot->ctrl->ctrlcap)) p_slot->hpc_ops->green_led_off(p_slot); mutex_lock(&p_slot->lock); p_slot->state = STATIC_STATE; @@ -409,9 +409,9 @@ static void handle_button_press_event(struct slot *p_slot) "press.\n", p_slot->name); } /* blink green LED and turn off amber */ - if (PWR_LED(ctrl)) + if (PWR_LED(ctrl->ctrlcap)) p_slot->hpc_ops->green_led_blink(p_slot); - if (ATTN_LED(ctrl)) + if (ATTN_LED(ctrl->ctrlcap)) p_slot->hpc_ops->set_attention_status(p_slot, 0); schedule_delayed_work(&p_slot->work, 5*HZ); @@ -427,13 +427,13 @@ static void handle_button_press_event(struct slot *p_slot) dbg("%s: button cancel\n", __func__); cancel_delayed_work(&p_slot->work); if (p_slot->state == BLINKINGOFF_STATE) { - if (PWR_LED(ctrl)) + if (PWR_LED(ctrl->ctrlcap)) p_slot->hpc_ops->green_led_on(p_slot); } else { - if (PWR_LED(ctrl)) + if (PWR_LED(ctrl->ctrlcap)) p_slot->hpc_ops->green_led_off(p_slot); } - if (ATTN_LED(ctrl)) + if (ATTN_LED(ctrl->ctrlcap)) p_slot->hpc_ops->set_attention_status(p_slot, 0); info("PCI slot #%s - action canceled due to button press\n", p_slot->name); @@ -492,16 +492,16 @@ static void interrupt_event_handler(struct work_struct *work) handle_button_press_event(p_slot); break; case INT_POWER_FAULT: - if (!POWER_CTRL(ctrl)) + if (!POWER_CTRL(ctrl->ctrlcap)) break; - if (ATTN_LED(ctrl)) + if (ATTN_LED(ctrl->ctrlcap)) p_slot->hpc_ops->set_attention_status(p_slot, 1); - if (PWR_LED(ctrl)) + if (PWR_LED(ctrl->ctrlcap)) p_slot->hpc_ops->green_led_off(p_slot); break; case INT_PRESENCE_ON: case INT_PRESENCE_OFF: - if (!HP_SUPR_RM(ctrl)) + if (!HP_SUPR_RM(ctrl->ctrlcap)) break; dbg("Surprise Removal\n"); update_slot_info(p_slot); @@ -531,7 +531,7 @@ int pciehp_enable_slot(struct slot *p_slot) mutex_unlock(&p_slot->ctrl->crit_sect); return -ENODEV; } - if (MRL_SENS(p_slot->ctrl)) { + if (MRL_SENS(p_slot->ctrl->ctrlcap)) { rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); if (rc || getstatus) { info("%s: latch open on slot(%s)\n", __func__, @@ -541,7 +541,7 @@ int pciehp_enable_slot(struct slot *p_slot) } } - if (POWER_CTRL(p_slot->ctrl)) { + if (POWER_CTRL(p_slot->ctrl->ctrlcap)) { rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); if (rc || getstatus) { info("%s: already enabled on slot(%s)\n", __func__, @@ -576,7 +576,7 @@ int pciehp_disable_slot(struct slot *p_slot) /* Check to see if (latch closed, card present, power on) */ mutex_lock(&p_slot->ctrl->crit_sect); - if (!HP_SUPR_RM(p_slot->ctrl)) { + if (!HP_SUPR_RM(p_slot->ctrl->ctrlcap)) { ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); if (ret || !getstatus) { info("%s: no adapter on slot(%s)\n", __func__, @@ -586,7 +586,7 @@ int pciehp_disable_slot(struct slot *p_slot) } } - if (MRL_SENS(p_slot->ctrl)) { + if (MRL_SENS(p_slot->ctrl->ctrlcap)) { ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); if (ret || getstatus) { info("%s: latch open on slot(%s)\n", __func__, @@ -596,7 +596,7 @@ int pciehp_disable_slot(struct slot *p_slot) } } - if (POWER_CTRL(p_slot->ctrl)) { + if (POWER_CTRL(p_slot->ctrl->ctrlcap)) { ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); if (ret || !getstatus) { info("%s: already disabled slot(%s)\n", __func__, diff --git a/trunk/drivers/pci/hotplug/pciehp_hpc.c b/trunk/drivers/pci/hotplug/pciehp_hpc.c index 891f81a0400c..b4bbd07d1e39 100644 --- a/trunk/drivers/pci/hotplug/pciehp_hpc.c +++ b/trunk/drivers/pci/hotplug/pciehp_hpc.c @@ -221,32 +221,6 @@ static void start_int_poll_timer(struct controller *ctrl, int sec) add_timer(&ctrl->poll_timer); } -static inline int pciehp_request_irq(struct controller *ctrl) -{ - int retval, irq = ctrl->pci_dev->irq; - - /* Install interrupt polling timer. Start with 10 sec delay */ - if (pciehp_poll_mode) { - init_timer(&ctrl->poll_timer); - start_int_poll_timer(ctrl, 10); - return 0; - } - - /* Installs the interrupt handler */ - retval = request_irq(irq, pcie_isr, IRQF_SHARED, MY_NAME, ctrl); - if (retval) - err("Cannot get irq %d for the hotplug controller\n", irq); - return retval; -} - -static inline void pciehp_free_irq(struct controller *ctrl) -{ - if (pciehp_poll_mode) - del_timer_sync(&ctrl->poll_timer); - else - free_irq(ctrl->pci_dev->irq, ctrl); -} - static inline int pcie_wait_cmd(struct controller *ctrl) { int retval = 0; @@ -268,15 +242,17 @@ static inline int pcie_wait_cmd(struct controller *ctrl) /** * pcie_write_cmd - Issue controller command - * @ctrl: controller to which the command is issued + * @slot: slot to which the command is issued * @cmd: command value written to slot control register * @mask: bitmask of slot control register to be modified */ -static int pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask) +static int pcie_write_cmd(struct slot *slot, u16 cmd, u16 mask) { + struct controller *ctrl = slot->ctrl; int retval = 0; u16 slot_status; u16 slot_ctrl; + unsigned long flags; mutex_lock(&ctrl->ctrl_lock); @@ -294,24 +270,24 @@ static int pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask) __func__); } + spin_lock_irqsave(&ctrl->lock, flags); retval = pciehp_readw(ctrl, SLOTCTRL, &slot_ctrl); if (retval) { err("%s: Cannot read SLOTCTRL register\n", __func__); - goto out; + goto out_spin_unlock; } slot_ctrl &= ~mask; - slot_ctrl |= (cmd & mask); - /* Don't enable command completed if caller is changing it. */ - if (!(mask & CMD_CMPL_INTR_ENABLE)) - slot_ctrl |= CMD_CMPL_INTR_ENABLE; + slot_ctrl |= ((cmd & mask) | CMD_CMPL_INTR_ENABLE); ctrl->cmd_busy = 1; - smp_mb(); retval = pciehp_writew(ctrl, SLOTCTRL, slot_ctrl); if (retval) err("%s: Cannot write to SLOTCTRL register\n", __func__); + out_spin_unlock: + spin_unlock_irqrestore(&ctrl->lock, flags); + /* * Wait for command completion. */ @@ -491,7 +467,12 @@ static int hpc_toggle_emi(struct slot *slot) slot_cmd = EMI_CTRL; cmd_mask = EMI_CTRL; - rc = pcie_write_cmd(slot->ctrl, slot_cmd, cmd_mask); + if (!pciehp_poll_mode) { + slot_cmd = slot_cmd | HP_INTR_ENABLE; + cmd_mask = cmd_mask | HP_INTR_ENABLE; + } + + rc = pcie_write_cmd(slot, slot_cmd, cmd_mask); slot->last_emi_toggle = get_seconds(); return rc; @@ -518,7 +499,12 @@ static int hpc_set_attention_status(struct slot *slot, u8 value) default: return -1; } - rc = pcie_write_cmd(ctrl, slot_cmd, cmd_mask); + if (!pciehp_poll_mode) { + slot_cmd = slot_cmd | HP_INTR_ENABLE; + cmd_mask = cmd_mask | HP_INTR_ENABLE; + } + + rc = pcie_write_cmd(slot, slot_cmd, cmd_mask); dbg("%s: SLOTCTRL %x write cmd %x\n", __func__, ctrl->cap_base + SLOTCTRL, slot_cmd); @@ -533,7 +519,13 @@ static void hpc_set_green_led_on(struct slot *slot) slot_cmd = 0x0100; cmd_mask = PWR_LED_CTRL; - pcie_write_cmd(ctrl, slot_cmd, cmd_mask); + if (!pciehp_poll_mode) { + slot_cmd = slot_cmd | HP_INTR_ENABLE; + cmd_mask = cmd_mask | HP_INTR_ENABLE; + } + + pcie_write_cmd(slot, slot_cmd, cmd_mask); + dbg("%s: SLOTCTRL %x write cmd %x\n", __func__, ctrl->cap_base + SLOTCTRL, slot_cmd); } @@ -546,7 +538,12 @@ static void hpc_set_green_led_off(struct slot *slot) slot_cmd = 0x0300; cmd_mask = PWR_LED_CTRL; - pcie_write_cmd(ctrl, slot_cmd, cmd_mask); + if (!pciehp_poll_mode) { + slot_cmd = slot_cmd | HP_INTR_ENABLE; + cmd_mask = cmd_mask | HP_INTR_ENABLE; + } + + pcie_write_cmd(slot, slot_cmd, cmd_mask); dbg("%s: SLOTCTRL %x write cmd %x\n", __func__, ctrl->cap_base + SLOTCTRL, slot_cmd); } @@ -559,19 +556,23 @@ static void hpc_set_green_led_blink(struct slot *slot) slot_cmd = 0x0200; cmd_mask = PWR_LED_CTRL; - pcie_write_cmd(ctrl, slot_cmd, cmd_mask); + if (!pciehp_poll_mode) { + slot_cmd = slot_cmd | HP_INTR_ENABLE; + cmd_mask = cmd_mask | HP_INTR_ENABLE; + } + + pcie_write_cmd(slot, slot_cmd, cmd_mask); + dbg("%s: SLOTCTRL %x write cmd %x\n", __func__, ctrl->cap_base + SLOTCTRL, slot_cmd); } static void hpc_release_ctlr(struct controller *ctrl) { - /* Mask Hot-plug Interrupt Enable */ - if (pcie_write_cmd(ctrl, 0, HP_INTR_ENABLE | CMD_CMPL_INTR_ENABLE)) - err("%s: Cannot mask hotplut interrupt enable\n", __func__); - - /* Free interrupt handler or interrupt polling timer */ - pciehp_free_irq(ctrl); + if (pciehp_poll_mode) + del_timer(&ctrl->poll_timer); + else + free_irq(ctrl->pci_dev->irq, ctrl); /* * If this is the last controller to be released, destroy the @@ -611,13 +612,19 @@ static int hpc_power_on_slot(struct slot * slot) cmd_mask = PWR_CTRL; /* Enable detection that we turned off at slot power-off time */ if (!pciehp_poll_mode) { - slot_cmd |= (PWR_FAULT_DETECT_ENABLE | MRL_DETECT_ENABLE | - PRSN_DETECT_ENABLE); - cmd_mask |= (PWR_FAULT_DETECT_ENABLE | MRL_DETECT_ENABLE | - PRSN_DETECT_ENABLE); + slot_cmd = slot_cmd | + PWR_FAULT_DETECT_ENABLE | + MRL_DETECT_ENABLE | + PRSN_DETECT_ENABLE | + HP_INTR_ENABLE; + cmd_mask = cmd_mask | + PWR_FAULT_DETECT_ENABLE | + MRL_DETECT_ENABLE | + PRSN_DETECT_ENABLE | + HP_INTR_ENABLE; } - retval = pcie_write_cmd(ctrl, slot_cmd, cmd_mask); + retval = pcie_write_cmd(slot, slot_cmd, cmd_mask); if (retval) { err("%s: Write %x command failed!\n", __func__, slot_cmd); @@ -690,13 +697,18 @@ static int hpc_power_off_slot(struct slot * slot) * till the slot is powered on again. */ if (!pciehp_poll_mode) { - slot_cmd &= ~(PWR_FAULT_DETECT_ENABLE | MRL_DETECT_ENABLE | - PRSN_DETECT_ENABLE); - cmd_mask |= (PWR_FAULT_DETECT_ENABLE | MRL_DETECT_ENABLE | - PRSN_DETECT_ENABLE); + slot_cmd = (slot_cmd & + ~PWR_FAULT_DETECT_ENABLE & + ~MRL_DETECT_ENABLE & + ~PRSN_DETECT_ENABLE) | HP_INTR_ENABLE; + cmd_mask = cmd_mask | + PWR_FAULT_DETECT_ENABLE | + MRL_DETECT_ENABLE | + PRSN_DETECT_ENABLE | + HP_INTR_ENABLE; } - retval = pcie_write_cmd(ctrl, slot_cmd, cmd_mask); + retval = pcie_write_cmd(slot, slot_cmd, cmd_mask); if (retval) { err("%s: Write command failed!\n", __func__); retval = -1; @@ -721,56 +733,139 @@ static int hpc_power_off_slot(struct slot * slot) static irqreturn_t pcie_isr(int irq, void *dev_id) { struct controller *ctrl = (struct controller *)dev_id; - u16 detected, intr_loc; + u16 slot_status, intr_detect, intr_loc; + u16 temp_word; + int hp_slot = 0; /* only 1 slot per PCI Express port */ + int rc = 0; + unsigned long flags; + + rc = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); + if (rc) { + err("%s: Cannot read SLOTSTATUS register\n", __func__); + return IRQ_NONE; + } - /* - * In order to guarantee that all interrupt events are - * serviced, we need to re-inspect Slot Status register after - * clearing what is presumed to be the last pending interrupt. - */ - intr_loc = 0; - do { - if (pciehp_readw(ctrl, SLOTSTATUS, &detected)) { - err("%s: Cannot read SLOTSTATUS\n", __func__); + intr_detect = (ATTN_BUTTN_PRESSED | PWR_FAULT_DETECTED | + MRL_SENS_CHANGED | PRSN_DETECT_CHANGED | CMD_COMPLETED); + + intr_loc = slot_status & intr_detect; + + /* Check to see if it was our interrupt */ + if ( !intr_loc ) + return IRQ_NONE; + + dbg("%s: intr_loc %x\n", __func__, intr_loc); + /* Mask Hot-plug Interrupt Enable */ + if (!pciehp_poll_mode) { + spin_lock_irqsave(&ctrl->lock, flags); + rc = pciehp_readw(ctrl, SLOTCTRL, &temp_word); + if (rc) { + err("%s: Cannot read SLOT_CTRL register\n", + __func__); + spin_unlock_irqrestore(&ctrl->lock, flags); return IRQ_NONE; } - detected &= (ATTN_BUTTN_PRESSED | PWR_FAULT_DETECTED | - MRL_SENS_CHANGED | PRSN_DETECT_CHANGED | - CMD_COMPLETED); - intr_loc |= detected; - if (!intr_loc) + dbg("%s: pciehp_readw(SLOTCTRL) with value %x\n", + __func__, temp_word); + temp_word = (temp_word & ~HP_INTR_ENABLE & + ~CMD_CMPL_INTR_ENABLE) | 0x00; + rc = pciehp_writew(ctrl, SLOTCTRL, temp_word); + if (rc) { + err("%s: Cannot write to SLOTCTRL register\n", + __func__); + spin_unlock_irqrestore(&ctrl->lock, flags); return IRQ_NONE; - if (pciehp_writew(ctrl, SLOTSTATUS, detected)) { - err("%s: Cannot write to SLOTSTATUS\n", __func__); + } + spin_unlock_irqrestore(&ctrl->lock, flags); + + rc = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); + if (rc) { + err("%s: Cannot read SLOT_STATUS register\n", + __func__); return IRQ_NONE; } - } while (detected); + dbg("%s: pciehp_readw(SLOTSTATUS) with value %x\n", + __func__, slot_status); - dbg("%s: intr_loc %x\n", __FUNCTION__, intr_loc); + /* Clear command complete interrupt caused by this write */ + temp_word = 0x1f; + rc = pciehp_writew(ctrl, SLOTSTATUS, temp_word); + if (rc) { + err("%s: Cannot write to SLOTSTATUS register\n", + __func__); + return IRQ_NONE; + } + } - /* Check Command Complete Interrupt Pending */ if (intr_loc & CMD_COMPLETED) { + /* + * Command Complete Interrupt Pending + */ ctrl->cmd_busy = 0; - smp_mb(); wake_up_interruptible(&ctrl->queue); } - /* Check MRL Sensor Changed */ if (intr_loc & MRL_SENS_CHANGED) - pciehp_handle_switch_change(0, ctrl); + pciehp_handle_switch_change(hp_slot, ctrl); - /* Check Attention Button Pressed */ if (intr_loc & ATTN_BUTTN_PRESSED) - pciehp_handle_attention_button(0, ctrl); + pciehp_handle_attention_button(hp_slot, ctrl); - /* Check Presence Detect Changed */ if (intr_loc & PRSN_DETECT_CHANGED) - pciehp_handle_presence_change(0, ctrl); + pciehp_handle_presence_change(hp_slot, ctrl); - /* Check Power Fault Detected */ if (intr_loc & PWR_FAULT_DETECTED) - pciehp_handle_power_fault(0, ctrl); + pciehp_handle_power_fault(hp_slot, ctrl); + + /* Clear all events after serving them */ + temp_word = 0x1F; + rc = pciehp_writew(ctrl, SLOTSTATUS, temp_word); + if (rc) { + err("%s: Cannot write to SLOTSTATUS register\n", __func__); + return IRQ_NONE; + } + /* Unmask Hot-plug Interrupt Enable */ + if (!pciehp_poll_mode) { + spin_lock_irqsave(&ctrl->lock, flags); + rc = pciehp_readw(ctrl, SLOTCTRL, &temp_word); + if (rc) { + err("%s: Cannot read SLOTCTRL register\n", + __func__); + spin_unlock_irqrestore(&ctrl->lock, flags); + return IRQ_NONE; + } + + dbg("%s: Unmask Hot-plug Interrupt Enable\n", __func__); + temp_word = (temp_word & ~HP_INTR_ENABLE) | HP_INTR_ENABLE; + + rc = pciehp_writew(ctrl, SLOTCTRL, temp_word); + if (rc) { + err("%s: Cannot write to SLOTCTRL register\n", + __func__); + spin_unlock_irqrestore(&ctrl->lock, flags); + return IRQ_NONE; + } + spin_unlock_irqrestore(&ctrl->lock, flags); + + rc = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); + if (rc) { + err("%s: Cannot read SLOT_STATUS register\n", + __func__); + return IRQ_NONE; + } + + /* Clear command complete interrupt caused by this write */ + temp_word = 0x1F; + rc = pciehp_writew(ctrl, SLOTSTATUS, temp_word); + if (rc) { + err("%s: Cannot write to SLOTSTATUS failed\n", + __func__); + return IRQ_NONE; + } + dbg("%s: pciehp_writew(SLOTSTATUS) with value %x\n", + __func__, temp_word); + } return IRQ_HANDLED; } @@ -957,7 +1052,7 @@ static struct hpc_ops pciehp_hpc_ops = { }; #ifdef CONFIG_ACPI -static int pciehp_acpi_get_hp_hw_control_from_firmware(struct pci_dev *dev) +int pciehp_acpi_get_hp_hw_control_from_firmware(struct pci_dev *dev) { acpi_status status; acpi_handle chandle, handle = DEVICE_ACPI_HANDLE(&(dev->dev)); @@ -1017,7 +1112,7 @@ static int pciehp_acpi_get_hp_hw_control_from_firmware(struct pci_dev *dev) break; } - dbg("Cannot get control of hotplug hardware for pci %s\n", + err("Cannot get control of hotplug hardware for pci %s\n", pci_name(dev)); kfree(string.pointer); @@ -1028,9 +1123,45 @@ static int pciehp_acpi_get_hp_hw_control_from_firmware(struct pci_dev *dev) static int pcie_init_hardware_part1(struct controller *ctrl, struct pcie_device *dev) { + int rc; + u16 temp_word; + u32 slot_cap; + u16 slot_status; + + rc = pciehp_readl(ctrl, SLOTCAP, &slot_cap); + if (rc) { + err("%s: Cannot read SLOTCAP register\n", __func__); + return -1; + } + /* Mask Hot-plug Interrupt Enable */ - if (pcie_write_cmd(ctrl, 0, HP_INTR_ENABLE | CMD_CMPL_INTR_ENABLE)) { - err("%s: Cannot mask hotplug interrupt enable\n", __func__); + rc = pciehp_readw(ctrl, SLOTCTRL, &temp_word); + if (rc) { + err("%s: Cannot read SLOTCTRL register\n", __func__); + return -1; + } + + dbg("%s: SLOTCTRL %x value read %x\n", + __func__, ctrl->cap_base + SLOTCTRL, temp_word); + temp_word = (temp_word & ~HP_INTR_ENABLE & ~CMD_CMPL_INTR_ENABLE) | + 0x00; + + rc = pciehp_writew(ctrl, SLOTCTRL, temp_word); + if (rc) { + err("%s: Cannot write to SLOTCTRL register\n", __func__); + return -1; + } + + rc = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); + if (rc) { + err("%s: Cannot read SLOTSTATUS register\n", __func__); + return -1; + } + + temp_word = 0x1F; /* Clear all events */ + rc = pciehp_writew(ctrl, SLOTSTATUS, temp_word); + if (rc) { + err("%s: Cannot write to SLOTSTATUS register\n", __func__); return -1; } return 0; @@ -1038,126 +1169,206 @@ static int pcie_init_hardware_part1(struct controller *ctrl, int pcie_init_hardware_part2(struct controller *ctrl, struct pcie_device *dev) { - u16 cmd, mask; + int rc; + u16 temp_word; + u16 intr_enable = 0; + u32 slot_cap; + u16 slot_status; - /* - * We need to clear all events before enabling hotplug interrupt - * notification mechanism in order for hotplug controler to - * generate interrupts. - */ - if (pciehp_writew(ctrl, SLOTSTATUS, 0x1f)) { - err("%s: Cannot write to SLOTSTATUS register\n", __FUNCTION__); - return -1; + rc = pciehp_readw(ctrl, SLOTCTRL, &temp_word); + if (rc) { + err("%s: Cannot read SLOTCTRL register\n", __func__); + goto abort; + } + + intr_enable = intr_enable | PRSN_DETECT_ENABLE; + + rc = pciehp_readl(ctrl, SLOTCAP, &slot_cap); + if (rc) { + err("%s: Cannot read SLOTCAP register\n", __func__); + goto abort; } - cmd = PRSN_DETECT_ENABLE; - if (ATTN_BUTTN(ctrl)) - cmd |= ATTN_BUTTN_ENABLE; - if (POWER_CTRL(ctrl)) - cmd |= PWR_FAULT_DETECT_ENABLE; - if (MRL_SENS(ctrl)) - cmd |= MRL_DETECT_ENABLE; - if (!pciehp_poll_mode) - cmd |= HP_INTR_ENABLE; + if (ATTN_BUTTN(slot_cap)) + intr_enable = intr_enable | ATTN_BUTTN_ENABLE; + + if (POWER_CTRL(slot_cap)) + intr_enable = intr_enable | PWR_FAULT_DETECT_ENABLE; + + if (MRL_SENS(slot_cap)) + intr_enable = intr_enable | MRL_DETECT_ENABLE; - mask = PRSN_DETECT_ENABLE | ATTN_BUTTN_ENABLE | - PWR_FAULT_DETECT_ENABLE | MRL_DETECT_ENABLE | HP_INTR_ENABLE; + temp_word = (temp_word & ~intr_enable) | intr_enable; - if (pcie_write_cmd(ctrl, cmd, mask)) { - err("%s: Cannot enable software notification\n", __func__); + if (pciehp_poll_mode) { + temp_word = (temp_word & ~HP_INTR_ENABLE) | 0x0; + } else { + temp_word = (temp_word & ~HP_INTR_ENABLE) | HP_INTR_ENABLE; + } + + /* + * Unmask Hot-plug Interrupt Enable for the interrupt + * notification mechanism case. + */ + rc = pciehp_writew(ctrl, SLOTCTRL, temp_word); + if (rc) { + err("%s: Cannot write to SLOTCTRL register\n", __func__); goto abort; } + rc = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); + if (rc) { + err("%s: Cannot read SLOTSTATUS register\n", __func__); + goto abort_disable_intr; + } + + temp_word = 0x1F; /* Clear all events */ + rc = pciehp_writew(ctrl, SLOTSTATUS, temp_word); + if (rc) { + err("%s: Cannot write to SLOTSTATUS register\n", __func__); + goto abort_disable_intr; + } - if (pciehp_force) + if (pciehp_force) { dbg("Bypassing BIOS check for pciehp use on %s\n", pci_name(ctrl->pci_dev)); - else if (pciehp_get_hp_hw_control_from_firmware(ctrl->pci_dev)) - goto abort_disable_intr; + } else { + rc = pciehp_get_hp_hw_control_from_firmware(ctrl->pci_dev); + if (rc) + goto abort_disable_intr; + } return 0; /* We end up here for the many possible ways to fail this API. */ abort_disable_intr: - if (pcie_write_cmd(ctrl, 0, HP_INTR_ENABLE)) + rc = pciehp_readw(ctrl, SLOTCTRL, &temp_word); + if (!rc) { + temp_word &= ~(intr_enable | HP_INTR_ENABLE); + rc = pciehp_writew(ctrl, SLOTCTRL, temp_word); + } + if (rc) err("%s : disabling interrupts failed\n", __func__); abort: return -1; } -static inline void dbg_ctrl(struct controller *ctrl) +int pcie_init(struct controller *ctrl, struct pcie_device *dev) { - int i; - u16 reg16; - struct pci_dev *pdev = ctrl->pci_dev; + int rc; + u16 cap_reg; + u32 slot_cap; + int cap_base; + u16 slot_status, slot_ctrl; + struct pci_dev *pdev; - if (!pciehp_debug) - return; + pdev = dev->port; + ctrl->pci_dev = pdev; /* save pci_dev in context */ - dbg("Hotplug Controller:\n"); - dbg(" Seg/Bus/Dev/Func/IRQ : %s IRQ %d\n", pci_name(pdev), pdev->irq); - dbg(" Vendor ID : 0x%04x\n", pdev->vendor); - dbg(" Device ID : 0x%04x\n", pdev->device); - dbg(" Subsystem ID : 0x%04x\n", pdev->subsystem_device); - dbg(" Subsystem Vendor ID : 0x%04x\n", pdev->subsystem_vendor); - dbg(" PCIe Cap offset : 0x%02x\n", ctrl->cap_base); - for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { - if (!pci_resource_len(pdev, i)) - continue; - dbg(" PCI resource [%d] : 0x%llx@0x%llx\n", i, - (unsigned long long)pci_resource_len(pdev, i), - (unsigned long long)pci_resource_start(pdev, i)); - } - dbg("Slot Capabilities : 0x%08x\n", ctrl->slot_cap); - dbg(" Physical Slot Number : %d\n", ctrl->first_slot); - dbg(" Attention Button : %3s\n", ATTN_BUTTN(ctrl) ? "yes" : "no"); - dbg(" Power Controller : %3s\n", POWER_CTRL(ctrl) ? "yes" : "no"); - dbg(" MRL Sensor : %3s\n", MRL_SENS(ctrl) ? "yes" : "no"); - dbg(" Attention Indicator : %3s\n", ATTN_LED(ctrl) ? "yes" : "no"); - dbg(" Power Indicator : %3s\n", PWR_LED(ctrl) ? "yes" : "no"); - dbg(" Hot-Plug Surprise : %3s\n", HP_SUPR_RM(ctrl) ? "yes" : "no"); - dbg(" EMI Present : %3s\n", EMI(ctrl) ? "yes" : "no"); - pciehp_readw(ctrl, SLOTSTATUS, ®16); - dbg("Slot Status : 0x%04x\n", reg16); - pciehp_readw(ctrl, SLOTSTATUS, ®16); - dbg("Slot Control : 0x%04x\n", reg16); -} + dbg("%s: hotplug controller vendor id 0x%x device id 0x%x\n", + __func__, pdev->vendor, pdev->device); -int pcie_init(struct controller *ctrl, struct pcie_device *dev) -{ - u32 slot_cap; - struct pci_dev *pdev = dev->port; + cap_base = pci_find_capability(pdev, PCI_CAP_ID_EXP); + if (cap_base == 0) { + dbg("%s: Can't find PCI_CAP_ID_EXP (0x10)\n", __func__); + goto abort; + } + + ctrl->cap_base = cap_base; - ctrl->pci_dev = pdev; - ctrl->cap_base = pci_find_capability(pdev, PCI_CAP_ID_EXP); - if (!ctrl->cap_base) { - err("%s: Cannot find PCI Express capability\n", __func__); + dbg("%s: pcie_cap_base %x\n", __func__, cap_base); + + rc = pciehp_readw(ctrl, CAPREG, &cap_reg); + if (rc) { + err("%s: Cannot read CAPREG register\n", __func__); + goto abort; + } + dbg("%s: CAPREG offset %x cap_reg %x\n", + __func__, ctrl->cap_base + CAPREG, cap_reg); + + if (((cap_reg & SLOT_IMPL) == 0) || + (((cap_reg & DEV_PORT_TYPE) != 0x0040) + && ((cap_reg & DEV_PORT_TYPE) != 0x0060))) { + dbg("%s : This is not a root port or the port is not " + "connected to a slot\n", __func__); goto abort; } - if (pciehp_readl(ctrl, SLOTCAP, &slot_cap)) { + + rc = pciehp_readl(ctrl, SLOTCAP, &slot_cap); + if (rc) { err("%s: Cannot read SLOTCAP register\n", __func__); goto abort; } + dbg("%s: SLOTCAP offset %x slot_cap %x\n", + __func__, ctrl->cap_base + SLOTCAP, slot_cap); - ctrl->slot_cap = slot_cap; - ctrl->first_slot = slot_cap >> 19; - ctrl->slot_device_offset = 0; - ctrl->num_slots = 1; - ctrl->hpc_ops = &pciehp_hpc_ops; - mutex_init(&ctrl->crit_sect); - mutex_init(&ctrl->ctrl_lock); - init_waitqueue_head(&ctrl->queue); - dbg_ctrl(ctrl); + if (!(slot_cap & HP_CAP)) { + dbg("%s : This slot is not hot-plug capable\n", __func__); + goto abort; + } + /* For debugging purpose */ + rc = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); + if (rc) { + err("%s: Cannot read SLOTSTATUS register\n", __func__); + goto abort; + } + dbg("%s: SLOTSTATUS offset %x slot_status %x\n", + __func__, ctrl->cap_base + SLOTSTATUS, slot_status); + + rc = pciehp_readw(ctrl, SLOTCTRL, &slot_ctrl); + if (rc) { + err("%s: Cannot read SLOTCTRL register\n", __func__); + goto abort; + } + dbg("%s: SLOTCTRL offset %x slot_ctrl %x\n", + __func__, ctrl->cap_base + SLOTCTRL, slot_ctrl); + + for (rc = 0; rc < DEVICE_COUNT_RESOURCE; rc++) + if (pci_resource_len(pdev, rc) > 0) + dbg("pci resource[%d] start=0x%llx(len=0x%llx)\n", rc, + (unsigned long long)pci_resource_start(pdev, rc), + (unsigned long long)pci_resource_len(pdev, rc)); info("HPC vendor_id %x device_id %x ss_vid %x ss_did %x\n", pdev->vendor, pdev->device, pdev->subsystem_vendor, pdev->subsystem_device); - if (pcie_init_hardware_part1(ctrl, dev)) - goto abort; + mutex_init(&ctrl->crit_sect); + mutex_init(&ctrl->ctrl_lock); + spin_lock_init(&ctrl->lock); + + /* setup wait queue */ + init_waitqueue_head(&ctrl->queue); + + /* return PCI Controller Info */ + ctrl->slot_device_offset = 0; + ctrl->num_slots = 1; + ctrl->first_slot = slot_cap >> 19; + ctrl->ctrlcap = slot_cap & 0x0000007f; - if (pciehp_request_irq(ctrl)) + rc = pcie_init_hardware_part1(ctrl, dev); + if (rc) goto abort; + if (pciehp_poll_mode) { + /* Install interrupt polling timer. Start with 10 sec delay */ + init_timer(&ctrl->poll_timer); + start_int_poll_timer(ctrl, 10); + } else { + /* Installs the interrupt handler */ + rc = request_irq(ctrl->pci_dev->irq, pcie_isr, IRQF_SHARED, + MY_NAME, (void *)ctrl); + dbg("%s: request_irq %d for hpc%d (returns %d)\n", + __func__, ctrl->pci_dev->irq, + atomic_read(&pciehp_num_controllers), rc); + if (rc) { + err("Can't get irq %d for the hotplug controller\n", + ctrl->pci_dev->irq); + goto abort; + } + } + dbg("pciehp ctrl b:d:f:irq=0x%x:%x:%x:%x\n", pdev->bus->number, + PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn), dev->irq); + /* * If this is the first controller to be initialized, * initialize the pciehp work queue @@ -1165,17 +1376,21 @@ int pcie_init(struct controller *ctrl, struct pcie_device *dev) if (atomic_add_return(1, &pciehp_num_controllers) == 1) { pciehp_wq = create_singlethread_workqueue("pciehpd"); if (!pciehp_wq) { + rc = -ENOMEM; goto abort_free_irq; } } - if (pcie_init_hardware_part2(ctrl, dev)) - goto abort_free_irq; - - return 0; - + rc = pcie_init_hardware_part2(ctrl, dev); + if (rc == 0) { + ctrl->hpc_ops = &pciehp_hpc_ops; + return 0; + } abort_free_irq: - pciehp_free_irq(ctrl); + if (pciehp_poll_mode) + del_timer_sync(&ctrl->poll_timer); + else + free_irq(ctrl->pci_dev->irq, ctrl); abort: return -1; } diff --git a/trunk/drivers/pci/hotplug/shpchp_core.c b/trunk/drivers/pci/hotplug/shpchp_core.c index 1648076600fc..43816d4b3c43 100644 --- a/trunk/drivers/pci/hotplug/shpchp_core.c +++ b/trunk/drivers/pci/hotplug/shpchp_core.c @@ -39,7 +39,6 @@ int shpchp_debug; int shpchp_poll_mode; int shpchp_poll_time; -int shpchp_slot_with_bus; struct workqueue_struct *shpchp_wq; #define DRIVER_VERSION "0.4" @@ -53,11 +52,9 @@ MODULE_LICENSE("GPL"); module_param(shpchp_debug, bool, 0644); module_param(shpchp_poll_mode, bool, 0644); module_param(shpchp_poll_time, int, 0644); -module_param(shpchp_slot_with_bus, bool, 0644); MODULE_PARM_DESC(shpchp_debug, "Debugging mode enabled or not"); MODULE_PARM_DESC(shpchp_poll_mode, "Using polling mechanism for hot-plug events or not"); MODULE_PARM_DESC(shpchp_poll_time, "Polling mechanism frequency, in seconds"); -MODULE_PARM_DESC(shpchp_slot_with_bus, "Use bus number in the slot name"); #define SHPC_MODULE_NAME "shpchp" @@ -103,12 +100,8 @@ static void release_slot(struct hotplug_slot *hotplug_slot) static void make_slot_name(struct slot *slot) { - if (shpchp_slot_with_bus) - snprintf(slot->hotplug_slot->name, SLOT_NAME_SIZE, "%04d_%04d", - slot->bus, slot->number); - else - snprintf(slot->hotplug_slot->name, SLOT_NAME_SIZE, "%d", - slot->number); + snprintf(slot->hotplug_slot->name, SLOT_NAME_SIZE, "%04d_%04d", + slot->bus, slot->number); } static int init_slots(struct controller *ctrl) diff --git a/trunk/drivers/pci/msi.c b/trunk/drivers/pci/msi.c index 8c61304cbb37..26938da8f438 100644 --- a/trunk/drivers/pci/msi.c +++ b/trunk/drivers/pci/msi.c @@ -123,7 +123,7 @@ static void msix_flush_writes(unsigned int irq) } } -static void msi_set_mask_bits(unsigned int irq, u32 mask, u32 flag) +static void msi_set_mask_bit(unsigned int irq, int flag) { struct msi_desc *entry; @@ -137,8 +137,8 @@ static void msi_set_mask_bits(unsigned int irq, u32 mask, u32 flag) pos = (long)entry->mask_base; pci_read_config_dword(entry->dev, pos, &mask_bits); - mask_bits &= ~(mask); - mask_bits |= flag & mask; + mask_bits &= ~(1); + mask_bits |= flag; pci_write_config_dword(entry->dev, pos, mask_bits); } else { msi_set_enable(entry->dev, !flag); @@ -241,13 +241,13 @@ void write_msi_msg(unsigned int irq, struct msi_msg *msg) void mask_msi_irq(unsigned int irq) { - msi_set_mask_bits(irq, 1, 1); + msi_set_mask_bit(irq, 1); msix_flush_writes(irq); } void unmask_msi_irq(unsigned int irq) { - msi_set_mask_bits(irq, 1, 0); + msi_set_mask_bit(irq, 0); msix_flush_writes(irq); } @@ -291,8 +291,7 @@ static void __pci_restore_msi_state(struct pci_dev *dev) msi_set_enable(dev, 0); write_msi_msg(dev->irq, &entry->msg); if (entry->msi_attrib.maskbit) - msi_set_mask_bits(dev->irq, entry->msi_attrib.maskbits_mask, - entry->msi_attrib.masked); + msi_set_mask_bit(dev->irq, entry->msi_attrib.masked); pci_read_config_word(dev, pos + PCI_MSI_FLAGS, &control); control &= ~(PCI_MSI_FLAGS_QSIZE | PCI_MSI_FLAGS_ENABLE); @@ -316,7 +315,7 @@ static void __pci_restore_msix_state(struct pci_dev *dev) list_for_each_entry(entry, &dev->msi_list, list) { write_msi_msg(entry->irq, &entry->msg); - msi_set_mask_bits(entry->irq, 1, entry->msi_attrib.masked); + msi_set_mask_bit(entry->irq, entry->msi_attrib.masked); } BUG_ON(list_empty(&dev->msi_list)); @@ -383,7 +382,6 @@ static int msi_capability_init(struct pci_dev *dev) pci_write_config_dword(dev, msi_mask_bits_reg(pos, is_64bit_address(control)), maskbits); - entry->msi_attrib.maskbits_mask = temp; } list_add_tail(&entry->list, &dev->msi_list); @@ -571,9 +569,10 @@ int pci_enable_msi(struct pci_dev* dev) } EXPORT_SYMBOL(pci_enable_msi); -void pci_msi_shutdown(struct pci_dev* dev) +void pci_disable_msi(struct pci_dev* dev) { struct msi_desc *entry; + int default_irq; if (!pci_msi_enable || !dev || !dev->msi_enabled) return; @@ -584,31 +583,15 @@ void pci_msi_shutdown(struct pci_dev* dev) BUG_ON(list_empty(&dev->msi_list)); entry = list_entry(dev->msi_list.next, struct msi_desc, list); - /* Return the the pci reset with msi irqs unmasked */ - if (entry->msi_attrib.maskbit) { - u32 mask = entry->msi_attrib.maskbits_mask; - msi_set_mask_bits(dev->irq, mask, ~mask); - } - if (!entry->dev || entry->msi_attrib.type != PCI_CAP_ID_MSI) - return; - - /* Restore dev->irq to its default pin-assertion irq */ - dev->irq = entry->msi_attrib.default_irq; -} -void pci_disable_msi(struct pci_dev* dev) -{ - struct msi_desc *entry; - - if (!pci_msi_enable || !dev || !dev->msi_enabled) - return; - - pci_msi_shutdown(dev); - - entry = list_entry(dev->msi_list.next, struct msi_desc, list); - if (!entry->dev || entry->msi_attrib.type != PCI_CAP_ID_MSI) + if (!entry->dev || entry->msi_attrib.type != PCI_CAP_ID_MSI) { return; + } + default_irq = entry->msi_attrib.default_irq; msi_free_irqs(dev); + + /* Restore dev->irq to its default pin-assertion irq */ + dev->irq = default_irq; } EXPORT_SYMBOL(pci_disable_msi); @@ -701,7 +684,7 @@ static void msix_free_all_irqs(struct pci_dev *dev) msi_free_irqs(dev); } -void pci_msix_shutdown(struct pci_dev* dev) +void pci_disable_msix(struct pci_dev* dev) { if (!pci_msi_enable || !dev || !dev->msix_enabled) return; @@ -709,13 +692,6 @@ void pci_msix_shutdown(struct pci_dev* dev) msix_set_enable(dev, 0); pci_intx_for_msi(dev, 1); dev->msix_enabled = 0; -} -void pci_disable_msix(struct pci_dev* dev) -{ - if (!pci_msi_enable || !dev || !dev->msix_enabled) - return; - - pci_msix_shutdown(dev); msix_free_all_irqs(dev); } diff --git a/trunk/drivers/pci/pci-driver.c b/trunk/drivers/pci/pci-driver.c index 72cf61ed8f96..e8d94fafc280 100644 --- a/trunk/drivers/pci/pci-driver.c +++ b/trunk/drivers/pci/pci-driver.c @@ -360,8 +360,6 @@ static void pci_device_shutdown(struct device *dev) if (drv && drv->shutdown) drv->shutdown(pci_dev); - pci_msi_shutdown(pci_dev); - pci_msix_shutdown(pci_dev); } /** diff --git a/trunk/drivers/pci/pcie/Kconfig b/trunk/drivers/pci/pcie/Kconfig index 5a0c6ad53f8e..25b04fb2517d 100644 --- a/trunk/drivers/pci/pcie/Kconfig +++ b/trunk/drivers/pci/pcie/Kconfig @@ -33,7 +33,7 @@ source "drivers/pci/pcie/aer/Kconfig" config PCIEASPM bool "PCI Express ASPM support(Experimental)" depends on PCI && EXPERIMENTAL && PCIEPORTBUS - default n + default y help This enables PCI Express ASPM (Active State Power Management) and Clock Power Management. ASPM supports state L0/L0s/L1. diff --git a/trunk/drivers/pci/probe.c b/trunk/drivers/pci/probe.c index 4a55bf380957..f991359f0c36 100644 --- a/trunk/drivers/pci/probe.c +++ b/trunk/drivers/pci/probe.c @@ -842,14 +842,11 @@ static void set_pcie_port_type(struct pci_dev *pdev) * reading the dword at 0x100 which must either be 0 or a valid extended * capability header. */ -int pci_cfg_space_size_ext(struct pci_dev *dev, unsigned check_exp_pcix) +int pci_cfg_space_size(struct pci_dev *dev) { int pos; u32 status; - if (!check_exp_pcix) - goto skip; - pos = pci_find_capability(dev, PCI_CAP_ID_EXP); if (!pos) { pos = pci_find_capability(dev, PCI_CAP_ID_PCIX); @@ -861,7 +858,6 @@ int pci_cfg_space_size_ext(struct pci_dev *dev, unsigned check_exp_pcix) goto fail; } - skip: if (pci_read_config_dword(dev, 256, &status) != PCIBIOS_SUCCESSFUL) goto fail; if (status == 0xffffffff) @@ -873,11 +869,6 @@ int pci_cfg_space_size_ext(struct pci_dev *dev, unsigned check_exp_pcix) return PCI_CFG_SPACE_SIZE; } -int pci_cfg_space_size(struct pci_dev *dev) -{ - return pci_cfg_space_size_ext(dev, 1); -} - static void pci_release_bus_bridge_dev(struct device *dev) { kfree(dev); @@ -973,6 +964,7 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) dev->dev.release = pci_release_dev; pci_dev_get(dev); + set_dev_node(&dev->dev, pcibus_to_node(bus)); dev->dev.dma_mask = &dev->dma_mask; dev->dev.dma_parms = &dev->dma_parms; dev->dev.coherent_dma_mask = 0xffffffffull; @@ -1088,10 +1080,6 @@ unsigned int __devinit pci_scan_child_bus(struct pci_bus *bus) return max; } -void __attribute__((weak)) set_pci_bus_resources_arch_default(struct pci_bus *b) -{ -} - struct pci_bus * pci_create_bus(struct device *parent, int bus, struct pci_ops *ops, void *sysdata) { @@ -1131,9 +1119,6 @@ struct pci_bus * pci_create_bus(struct device *parent, goto dev_reg_err; b->bridge = get_device(dev); - if (!parent) - set_dev_node(b->bridge, pcibus_to_node(b)); - b->dev.class = &pcibus_class; b->dev.parent = b->bridge; sprintf(b->dev.bus_id, "%04x:%02x", pci_domain_nr(b), bus); @@ -1151,8 +1136,6 @@ struct pci_bus * pci_create_bus(struct device *parent, b->resource[0] = &ioport_resource; b->resource[1] = &iomem_resource; - set_pci_bus_resources_arch_default(b); - return b; dev_create_file_err: diff --git a/trunk/drivers/pci/proc.c b/trunk/drivers/pci/proc.c index 963a97642ae9..ef18fcd641e2 100644 --- a/trunk/drivers/pci/proc.c +++ b/trunk/drivers/pci/proc.c @@ -293,7 +293,6 @@ static int proc_bus_pci_release(struct inode *inode, struct file *file) #endif /* HAVE_PCI_MMAP */ static const struct file_operations proc_bus_pci_operations = { - .owner = THIS_MODULE, .llseek = proc_bus_pci_lseek, .read = proc_bus_pci_read, .write = proc_bus_pci_write, @@ -407,10 +406,11 @@ int pci_proc_attach_device(struct pci_dev *dev) } sprintf(name, "%02x.%x", PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)); - e = proc_create_data(name, S_IFREG | S_IRUGO | S_IWUSR, bus->procdir, - &proc_bus_pci_operations, dev); + e = create_proc_entry(name, S_IFREG | S_IRUGO | S_IWUSR, bus->procdir); if (!e) return -ENOMEM; + e->proc_fops = &proc_bus_pci_operations; + e->data = dev; e->size = dev->cfg_size; dev->procent = e; @@ -462,7 +462,6 @@ static int proc_bus_pci_dev_open(struct inode *inode, struct file *file) return seq_open(file, &proc_bus_pci_devices_op); } static const struct file_operations proc_bus_pci_dev_operations = { - .owner = THIS_MODULE, .open = proc_bus_pci_dev_open, .read = seq_read, .llseek = seq_lseek, @@ -471,10 +470,12 @@ static const struct file_operations proc_bus_pci_dev_operations = { static int __init pci_proc_init(void) { + struct proc_dir_entry *entry; struct pci_dev *dev = NULL; - proc_bus_pci_dir = proc_mkdir("bus/pci", NULL); - proc_create("devices", 0, proc_bus_pci_dir, - &proc_bus_pci_dev_operations); + proc_bus_pci_dir = proc_mkdir("pci", proc_bus); + entry = create_proc_entry("devices", 0, proc_bus_pci_dir); + if (entry) + entry->proc_fops = &proc_bus_pci_dev_operations; proc_initialized = 1; while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { pci_proc_attach_device(dev); diff --git a/trunk/drivers/pcmcia/cistpl.c b/trunk/drivers/pcmcia/cistpl.c index 36379535f9da..06a85d7d5aa2 100644 --- a/trunk/drivers/pcmcia/cistpl.c +++ b/trunk/drivers/pcmcia/cistpl.c @@ -402,6 +402,15 @@ EXPORT_SYMBOL(pcmcia_replace_cis); ======================================================================*/ +static inline u16 cis_get_u16(void *ptr) +{ + return le16_to_cpu(get_unaligned((__le16 *) ptr)); +} +static inline u32 cis_get_u32(void *ptr) +{ + return le32_to_cpu(get_unaligned((__le32 *) ptr)); +} + typedef struct tuple_flags { u_int link_space:4; u_int has_link:1; @@ -462,7 +471,7 @@ static int follow_link(struct pcmcia_socket *s, tuple_t *tuple) /* Get indirect link from the MFC tuple */ read_cis_cache(s, LINK_SPACE(tuple->Flags), tuple->LinkOffset, 5, link); - ofs = get_unaligned_le32(link + 1); + ofs = cis_get_u32(link + 1); SPACE(tuple->Flags) = (link[0] == CISTPL_MFC_ATTR); /* Move to the next indirect link */ tuple->LinkOffset += 5; @@ -670,8 +679,8 @@ static int parse_checksum(tuple_t *tuple, cistpl_checksum_t *csum) if (tuple->TupleDataLen < 5) return CS_BAD_TUPLE; p = (u_char *) tuple->TupleData; - csum->addr = tuple->CISOffset + get_unaligned_le16(p) - 2; - csum->len = get_unaligned_le16(p + 2); + csum->addr = tuple->CISOffset + cis_get_u16(p) - 2; + csum->len = cis_get_u16(p + 2); csum->sum = *(p + 4); return CS_SUCCESS; } @@ -682,7 +691,7 @@ static int parse_longlink(tuple_t *tuple, cistpl_longlink_t *link) { if (tuple->TupleDataLen < 4) return CS_BAD_TUPLE; - link->addr = get_unaligned_le32(tuple->TupleData); + link->addr = cis_get_u32(tuple->TupleData); return CS_SUCCESS; } @@ -701,7 +710,7 @@ static int parse_longlink_mfc(tuple_t *tuple, return CS_BAD_TUPLE; for (i = 0; i < link->nfn; i++) { link->fn[i].space = *p; p++; - link->fn[i].addr = get_unaligned_le32(p); + link->fn[i].addr = cis_get_u32(p); p += 4; } return CS_SUCCESS; @@ -791,8 +800,8 @@ static int parse_manfid(tuple_t *tuple, cistpl_manfid_t *m) { if (tuple->TupleDataLen < 4) return CS_BAD_TUPLE; - m->manf = get_unaligned_le16(tuple->TupleData); - m->card = get_unaligned_le16(tuple->TupleData + 2); + m->manf = cis_get_u16(tuple->TupleData); + m->card = cis_get_u16(tuple->TupleData + 2); return CS_SUCCESS; } @@ -1091,7 +1100,7 @@ static int parse_cftable_entry(tuple_t *tuple, break; case 0x20: entry->mem.nwin = 1; - entry->mem.win[0].len = get_unaligned_le16(p) << 8; + entry->mem.win[0].len = cis_get_u16(p) << 8; entry->mem.win[0].card_addr = 0; entry->mem.win[0].host_addr = 0; p += 2; @@ -1099,8 +1108,8 @@ static int parse_cftable_entry(tuple_t *tuple, break; case 0x40: entry->mem.nwin = 1; - entry->mem.win[0].len = get_unaligned_le16(p) << 8; - entry->mem.win[0].card_addr = get_unaligned_le16(p + 2) << 8; + entry->mem.win[0].len = cis_get_u16(p) << 8; + entry->mem.win[0].card_addr = cis_get_u16(p + 2) << 8; entry->mem.win[0].host_addr = 0; p += 4; if (p > q) return CS_BAD_TUPLE; @@ -1137,7 +1146,7 @@ static int parse_bar(tuple_t *tuple, cistpl_bar_t *bar) p = (u_char *)tuple->TupleData; bar->attr = *p; p += 2; - bar->size = get_unaligned_le32(p); + bar->size = cis_get_u32(p); return CS_SUCCESS; } @@ -1150,7 +1159,7 @@ static int parse_config_cb(tuple_t *tuple, cistpl_config_t *config) return CS_BAD_TUPLE; config->last_idx = *(++p); p++; - config->base = get_unaligned_le32(p); + config->base = cis_get_u32(p); config->subtuples = tuple->TupleDataLen - 6; return CS_SUCCESS; } @@ -1266,7 +1275,7 @@ static int parse_vers_2(tuple_t *tuple, cistpl_vers_2_t *v2) v2->vers = p[0]; v2->comply = p[1]; - v2->dindex = get_unaligned_le16(p +2 ); + v2->dindex = cis_get_u16(p +2 ); v2->vspec8 = p[6]; v2->vspec9 = p[7]; v2->nhdr = p[8]; @@ -1307,8 +1316,8 @@ static int parse_format(tuple_t *tuple, cistpl_format_t *fmt) fmt->type = p[0]; fmt->edc = p[1]; - fmt->offset = get_unaligned_le32(p + 2); - fmt->length = get_unaligned_le32(p + 6); + fmt->offset = cis_get_u32(p + 2); + fmt->length = cis_get_u32(p + 6); return CS_SUCCESS; } diff --git a/trunk/drivers/pcmcia/pcmcia_ioctl.c b/trunk/drivers/pcmcia/pcmcia_ioctl.c index 5f186abca108..27523c5f4dad 100644 --- a/trunk/drivers/pcmcia/pcmcia_ioctl.c +++ b/trunk/drivers/pcmcia/pcmcia_ioctl.c @@ -787,7 +787,7 @@ void __init pcmcia_setup_ioctl(void) { major_dev = i; #ifdef CONFIG_PROC_FS - proc_pccard = proc_mkdir("bus/pccard", NULL); + proc_pccard = proc_mkdir("pccard", proc_bus); if (proc_pccard) create_proc_read_entry("drivers",0,proc_pccard,proc_read_drivers,NULL); #endif @@ -798,7 +798,7 @@ void __exit pcmcia_cleanup_ioctl(void) { #ifdef CONFIG_PROC_FS if (proc_pccard) { remove_proc_entry("drivers", proc_pccard); - remove_proc_entry("bus/pccard", NULL); + remove_proc_entry("pccard", proc_bus); } #endif if (major_dev != -1) diff --git a/trunk/drivers/pnp/isapnp/proc.c b/trunk/drivers/pnp/isapnp/proc.c index 3f94edab25fa..2b8266c3d40f 100644 --- a/trunk/drivers/pnp/isapnp/proc.c +++ b/trunk/drivers/pnp/isapnp/proc.c @@ -85,7 +85,6 @@ static ssize_t isapnp_proc_bus_read(struct file *file, char __user * buf, } static const struct file_operations isapnp_proc_bus_file_operations = { - .owner = THIS_MODULE, .llseek = isapnp_proc_bus_lseek, .read = isapnp_proc_bus_read, }; @@ -103,10 +102,12 @@ static int isapnp_proc_attach_device(struct pnp_dev *dev) return -ENOMEM; } sprintf(name, "%02x", dev->number); - e = dev->procent = proc_create_data(name, S_IFREG | S_IRUGO, de, - &isapnp_proc_bus_file_operations, dev); + e = dev->procent = create_proc_entry(name, S_IFREG | S_IRUGO, de); if (!e) return -ENOMEM; + e->proc_fops = &isapnp_proc_bus_file_operations; + e->owner = THIS_MODULE; + e->data = dev; e->size = 256; return 0; } @@ -115,7 +116,7 @@ int __init isapnp_proc_init(void) { struct pnp_dev *dev; - isapnp_proc_bus_dir = proc_mkdir("bus/isapnp", NULL); + isapnp_proc_bus_dir = proc_mkdir("isapnp", proc_bus); protocol_for_each_dev(&isapnp_protocol, dev) { isapnp_proc_attach_device(dev); } diff --git a/trunk/drivers/pnp/pnpbios/proc.c b/trunk/drivers/pnp/pnpbios/proc.c index 46d506f66259..bb19bc957bad 100644 --- a/trunk/drivers/pnp/pnpbios/proc.c +++ b/trunk/drivers/pnp/pnpbios/proc.c @@ -256,7 +256,7 @@ int pnpbios_interface_attach_device(struct pnp_bios_node *node) */ int __init pnpbios_proc_init(void) { - proc_pnp = proc_mkdir("bus/pnp", NULL); + proc_pnp = proc_mkdir("pnp", proc_bus); if (!proc_pnp) return -EIO; proc_pnp_boot = proc_mkdir("boot", proc_pnp); @@ -294,5 +294,5 @@ void __exit pnpbios_proc_exit(void) remove_proc_entry("configuration_info", proc_pnp); remove_proc_entry("devices", proc_pnp); remove_proc_entry("boot", proc_pnp); - remove_proc_entry("bus/pnp", NULL); + remove_proc_entry("pnp", proc_bus); } diff --git a/trunk/drivers/power/ds2760_battery.c b/trunk/drivers/power/ds2760_battery.c index 71be36f18709..bdb9b7285b3d 100644 --- a/trunk/drivers/power/ds2760_battery.c +++ b/trunk/drivers/power/ds2760_battery.c @@ -262,7 +262,7 @@ static void ds2760_battery_work(struct work_struct *work) struct ds2760_device_info, monitor_work.work); const int interval = HZ * 60; - dev_dbg(di->dev, "%s\n", __func__); + dev_dbg(di->dev, "%s\n", __FUNCTION__); ds2760_battery_update_status(di); queue_delayed_work(di->monitor_wqueue, &di->monitor_work, interval); @@ -275,7 +275,7 @@ static void ds2760_battery_external_power_changed(struct power_supply *psy) { struct ds2760_device_info *di = to_ds2760_device_info(psy); - dev_dbg(di->dev, "%s\n", __func__); + dev_dbg(di->dev, "%s\n", __FUNCTION__); cancel_delayed_work(&di->monitor_work); queue_delayed_work(di->monitor_wqueue, &di->monitor_work, HZ/10); diff --git a/trunk/drivers/power/olpc_battery.c b/trunk/drivers/power/olpc_battery.c index ab1e8289f07f..af7a231092a4 100644 --- a/trunk/drivers/power/olpc_battery.c +++ b/trunk/drivers/power/olpc_battery.c @@ -315,6 +315,7 @@ static int __init olpc_bat_init(void) if (ret) goto battery_failed; + olpc_register_battery_callback(&olpc_battery_trigger_uevent); goto success; battery_failed: @@ -327,6 +328,7 @@ static int __init olpc_bat_init(void) static void __exit olpc_bat_exit(void) { + olpc_deregister_battery_callback(); power_supply_unregister(&olpc_bat); power_supply_unregister(&olpc_ac); platform_device_unregister(bat_pdev); diff --git a/trunk/drivers/power/power_supply_core.c b/trunk/drivers/power/power_supply_core.c index 138dd76ee347..03d6a38464ef 100644 --- a/trunk/drivers/power/power_supply_core.c +++ b/trunk/drivers/power/power_supply_core.c @@ -39,7 +39,7 @@ static void power_supply_changed_work(struct work_struct *work) struct power_supply *psy = container_of(work, struct power_supply, changed_work); - dev_dbg(psy->dev, "%s\n", __func__); + dev_dbg(psy->dev, "%s\n", __FUNCTION__); class_for_each_device(power_supply_class, psy, __power_supply_changed_work); @@ -51,7 +51,7 @@ static void power_supply_changed_work(struct work_struct *work) void power_supply_changed(struct power_supply *psy) { - dev_dbg(psy->dev, "%s\n", __func__); + dev_dbg(psy->dev, "%s\n", __FUNCTION__); schedule_work(&psy->changed_work); } @@ -82,7 +82,7 @@ int power_supply_am_i_supplied(struct power_supply *psy) error = class_for_each_device(power_supply_class, psy, __power_supply_am_i_supplied); - dev_dbg(psy->dev, "%s %d\n", __func__, error); + dev_dbg(psy->dev, "%s %d\n", __FUNCTION__, error); return error; } diff --git a/trunk/drivers/power/power_supply_leds.c b/trunk/drivers/power/power_supply_leds.c index 2dece40c544f..fa3034f85c38 100644 --- a/trunk/drivers/power/power_supply_leds.c +++ b/trunk/drivers/power/power_supply_leds.c @@ -24,7 +24,7 @@ static void power_supply_update_bat_leds(struct power_supply *psy) if (psy->get_property(psy, POWER_SUPPLY_PROP_STATUS, &status)) return; - dev_dbg(psy->dev, "%s %d\n", __func__, status.intval); + dev_dbg(psy->dev, "%s %d\n", __FUNCTION__, status.intval); switch (status.intval) { case POWER_SUPPLY_STATUS_FULL: @@ -101,7 +101,7 @@ static void power_supply_update_gen_leds(struct power_supply *psy) if (psy->get_property(psy, POWER_SUPPLY_PROP_ONLINE, &online)) return; - dev_dbg(psy->dev, "%s %d\n", __func__, online.intval); + dev_dbg(psy->dev, "%s %d\n", __FUNCTION__, online.intval); if (online.intval) led_trigger_event(psy->online_trig, LED_FULL); diff --git a/trunk/drivers/rapidio/Kconfig b/trunk/drivers/rapidio/Kconfig index c32822ad84a4..4142115d298e 100644 --- a/trunk/drivers/rapidio/Kconfig +++ b/trunk/drivers/rapidio/Kconfig @@ -1,6 +1,14 @@ # # RapidIO configuration # +config RAPIDIO_8_BIT_TRANSPORT + bool "8-bit transport addressing" + depends on RAPIDIO + ---help--- + By default, the kernel assumes a 16-bit addressed RapidIO + network. By selecting this option, the kernel will support + an 8-bit addressed network. + config RAPIDIO_DISC_TIMEOUT int "Discovery timeout duration (seconds)" depends on RAPIDIO diff --git a/trunk/drivers/rapidio/rio-access.c b/trunk/drivers/rapidio/rio-access.c index a3824baca2e5..8b56bbdd011e 100644 --- a/trunk/drivers/rapidio/rio-access.c +++ b/trunk/drivers/rapidio/rio-access.c @@ -48,7 +48,7 @@ int __rio_local_read_config_##size \ u32 data = 0; \ if (RIO_##size##_BAD) return RIO_BAD_SIZE; \ spin_lock_irqsave(&rio_config_lock, flags); \ - res = mport->ops->lcread(mport, mport->id, offset, len, &data); \ + res = mport->ops->lcread(mport->id, offset, len, &data); \ *value = (type)data; \ spin_unlock_irqrestore(&rio_config_lock, flags); \ return res; \ @@ -71,7 +71,7 @@ int __rio_local_write_config_##size \ unsigned long flags; \ if (RIO_##size##_BAD) return RIO_BAD_SIZE; \ spin_lock_irqsave(&rio_config_lock, flags); \ - res = mport->ops->lcwrite(mport, mport->id, offset, len, value);\ + res = mport->ops->lcwrite(mport->id, offset, len, value); \ spin_unlock_irqrestore(&rio_config_lock, flags); \ return res; \ } @@ -108,7 +108,7 @@ int rio_mport_read_config_##size \ u32 data = 0; \ if (RIO_##size##_BAD) return RIO_BAD_SIZE; \ spin_lock_irqsave(&rio_config_lock, flags); \ - res = mport->ops->cread(mport, mport->id, destid, hopcount, offset, len, &data); \ + res = mport->ops->cread(mport->id, destid, hopcount, offset, len, &data); \ *value = (type)data; \ spin_unlock_irqrestore(&rio_config_lock, flags); \ return res; \ @@ -131,7 +131,7 @@ int rio_mport_write_config_##size \ unsigned long flags; \ if (RIO_##size##_BAD) return RIO_BAD_SIZE; \ spin_lock_irqsave(&rio_config_lock, flags); \ - res = mport->ops->cwrite(mport, mport->id, destid, hopcount, offset, len, value); \ + res = mport->ops->cwrite(mport->id, destid, hopcount, offset, len, value); \ spin_unlock_irqrestore(&rio_config_lock, flags); \ return res; \ } @@ -166,7 +166,7 @@ int rio_mport_send_doorbell(struct rio_mport *mport, u16 destid, u16 data) unsigned long flags; spin_lock_irqsave(&rio_doorbell_lock, flags); - res = mport->ops->dsend(mport, mport->id, destid, data); + res = mport->ops->dsend(mport->id, destid, data); spin_unlock_irqrestore(&rio_doorbell_lock, flags); return res; diff --git a/trunk/drivers/rapidio/rio-scan.c b/trunk/drivers/rapidio/rio-scan.c index a926c896475e..44420723a359 100644 --- a/trunk/drivers/rapidio/rio-scan.c +++ b/trunk/drivers/rapidio/rio-scan.c @@ -73,7 +73,7 @@ static u16 rio_get_device_id(struct rio_mport *port, u16 destid, u8 hopcount) rio_mport_read_config_32(port, destid, hopcount, RIO_DID_CSR, &result); - return RIO_GET_DID(port->sys_size, result); + return RIO_GET_DID(result); } /** @@ -88,7 +88,7 @@ static u16 rio_get_device_id(struct rio_mport *port, u16 destid, u8 hopcount) static void rio_set_device_id(struct rio_mport *port, u16 destid, u8 hopcount, u16 did) { rio_mport_write_config_32(port, destid, hopcount, RIO_DID_CSR, - RIO_SET_DID(port->sys_size, did)); + RIO_SET_DID(did)); } /** @@ -100,8 +100,7 @@ static void rio_set_device_id(struct rio_mport *port, u16 destid, u8 hopcount, u */ static void rio_local_set_device_id(struct rio_mport *port, u16 did) { - rio_local_write_config_32(port, RIO_DID_CSR, RIO_SET_DID(port->sys_size, - did)); + rio_local_write_config_32(port, RIO_DID_CSR, RIO_SET_DID(did)); } /** @@ -351,18 +350,8 @@ static struct rio_dev *rio_setup_device(struct rio_net *net, rswitch->switchid = next_switchid; rswitch->hopcount = hopcount; rswitch->destid = destid; - rswitch->route_table = kzalloc(sizeof(u8)* - RIO_MAX_ROUTE_ENTRIES(port->sys_size), - GFP_KERNEL); - if (!rswitch->route_table) { - kfree(rdev); - rdev = NULL; - kfree(rswitch); - goto out; - } /* Initialize switch route table */ - for (rdid = 0; rdid < RIO_MAX_ROUTE_ENTRIES(port->sys_size); - rdid++) + for (rdid = 0; rdid < RIO_MAX_ROUTE_ENTRIES; rdid++) rswitch->route_table[rdid] = RIO_INVALID_ROUTE; rdev->rswitch = rswitch; sprintf(rio_name(rdev), "%02x:s:%04x", rdev->net->id, @@ -491,7 +480,7 @@ static u16 rio_get_host_deviceid_lock(struct rio_mport *port, u8 hopcount) { u32 result; - rio_mport_read_config_32(port, RIO_ANY_DESTID(port->sys_size), hopcount, + rio_mport_read_config_32(port, RIO_ANY_DESTID, hopcount, RIO_HOST_DID_LOCK_CSR, &result); return (u16) (result & 0xffff); @@ -582,16 +571,14 @@ static int rio_enum_peer(struct rio_net *net, struct rio_mport *port, } /* Attempt to acquire device lock */ - rio_mport_write_config_32(port, RIO_ANY_DESTID(port->sys_size), - hopcount, + rio_mport_write_config_32(port, RIO_ANY_DESTID, hopcount, RIO_HOST_DID_LOCK_CSR, port->host_deviceid); while ((tmp = rio_get_host_deviceid_lock(port, hopcount)) < port->host_deviceid) { /* Delay a bit */ mdelay(1); /* Attempt to acquire device lock again */ - rio_mport_write_config_32(port, RIO_ANY_DESTID(port->sys_size), - hopcount, + rio_mport_write_config_32(port, RIO_ANY_DESTID, hopcount, RIO_HOST_DID_LOCK_CSR, port->host_deviceid); } @@ -603,9 +590,7 @@ static int rio_enum_peer(struct rio_net *net, struct rio_mport *port, } /* Setup new RIO device */ - rdev = rio_setup_device(net, port, RIO_ANY_DESTID(port->sys_size), - hopcount, 1); - if (rdev) { + if ((rdev = rio_setup_device(net, port, RIO_ANY_DESTID, hopcount, 1))) { /* Add device to the global and bus/net specific list. */ list_add_tail(&rdev->net_list, &net->devices); } else @@ -613,8 +598,7 @@ static int rio_enum_peer(struct rio_net *net, struct rio_mport *port, if (rio_is_switch(rdev)) { next_switchid++; - sw_inport = rio_get_swpinfo_inport(port, - RIO_ANY_DESTID(port->sys_size), hopcount); + sw_inport = rio_get_swpinfo_inport(port, RIO_ANY_DESTID, hopcount); rio_route_add_entry(port, rdev->rswitch, RIO_GLOBAL_TABLE, port->host_deviceid, sw_inport); rdev->rswitch->route_table[port->host_deviceid] = sw_inport; @@ -628,8 +612,7 @@ static int rio_enum_peer(struct rio_net *net, struct rio_mport *port, } num_ports = - rio_get_swpinfo_tports(port, RIO_ANY_DESTID(port->sys_size), - hopcount); + rio_get_swpinfo_tports(port, RIO_ANY_DESTID, hopcount); pr_debug( "RIO: found %s (vid %4.4x did %4.4x) with %d ports\n", rio_name(rdev), rdev->vid, rdev->did, num_ports); @@ -641,15 +624,13 @@ static int rio_enum_peer(struct rio_net *net, struct rio_mport *port, cur_destid = next_destid; if (rio_sport_is_active - (port, RIO_ANY_DESTID(port->sys_size), hopcount, - port_num)) { + (port, RIO_ANY_DESTID, hopcount, port_num)) { pr_debug( "RIO: scanning device on port %d\n", port_num); rio_route_add_entry(port, rdev->rswitch, - RIO_GLOBAL_TABLE, - RIO_ANY_DESTID(port->sys_size), - port_num); + RIO_GLOBAL_TABLE, + RIO_ANY_DESTID, port_num); if (rio_enum_peer(net, port, hopcount + 1) < 0) return -1; @@ -754,8 +735,7 @@ rio_disc_peer(struct rio_net *net, struct rio_mport *port, u16 destid, pr_debug( "RIO: scanning device on port %d\n", port_num); - for (ndestid = 0; - ndestid < RIO_ANY_DESTID(port->sys_size); + for (ndestid = 0; ndestid < RIO_ANY_DESTID; ndestid++) { rio_route_get_entry(port, rdev->rswitch, RIO_GLOBAL_TABLE, @@ -937,9 +917,7 @@ static void rio_build_route_tables(void) list_for_each_entry(rdev, &rio_devices, global_list) if (rio_is_switch(rdev)) - for (i = 0; - i < RIO_MAX_ROUTE_ENTRIES(rdev->net->hport->sys_size); - i++) { + for (i = 0; i < RIO_MAX_ROUTE_ENTRIES; i++) { if (rio_route_get_entry (rdev->net->hport, rdev->rswitch, RIO_GLOBAL_TABLE, i, &sport) < 0) @@ -1003,8 +981,7 @@ int rio_disc_mport(struct rio_mport *mport) del_timer_sync(&rio_enum_timer); pr_debug("done\n"); - if (rio_disc_peer(net, mport, RIO_ANY_DESTID(mport->sys_size), - 0) < 0) { + if (rio_disc_peer(net, mport, RIO_ANY_DESTID, 0) < 0) { printk(KERN_INFO "RIO: master port %d device has failed discovery\n", mport->id); diff --git a/trunk/drivers/rapidio/rio-sysfs.c b/trunk/drivers/rapidio/rio-sysfs.c index 97a147f050d6..659e31164cf0 100644 --- a/trunk/drivers/rapidio/rio-sysfs.c +++ b/trunk/drivers/rapidio/rio-sysfs.c @@ -43,8 +43,7 @@ static ssize_t routes_show(struct device *dev, struct device_attribute *attr, ch if (!rdev->rswitch) goto out; - for (i = 0; i < RIO_MAX_ROUTE_ENTRIES(rdev->net->hport->sys_size); - i++) { + for (i = 0; i < RIO_MAX_ROUTE_ENTRIES; i++) { if (rdev->rswitch->route_table[i] == RIO_INVALID_ROUTE) continue; str += diff --git a/trunk/drivers/rapidio/rio.c b/trunk/drivers/rapidio/rio.c index 680661abbc4b..80c5f1ba2e49 100644 --- a/trunk/drivers/rapidio/rio.c +++ b/trunk/drivers/rapidio/rio.c @@ -43,7 +43,7 @@ u16 rio_local_get_device_id(struct rio_mport *port) rio_local_read_config_32(port, RIO_DID_CSR, &result); - return (RIO_GET_DID(port->sys_size, result)); + return (RIO_GET_DID(result)); } /** diff --git a/trunk/drivers/rapidio/rio.h b/trunk/drivers/rapidio/rio.h index 7786d02581f2..80e3f03b5041 100644 --- a/trunk/drivers/rapidio/rio.h +++ b/trunk/drivers/rapidio/rio.h @@ -51,5 +51,10 @@ extern struct rio_route_ops __end_rio_route_ops[]; DECLARE_RIO_ROUTE_SECTION(.rio_route_ops, \ vid, did, add_hook, get_hook) -#define RIO_GET_DID(size, x) (size ? (x & 0xffff) : ((x & 0x00ff0000) >> 16)) -#define RIO_SET_DID(size, x) (size ? (x & 0xffff) : ((x & 0x000000ff) << 16)) +#ifdef CONFIG_RAPIDIO_8_BIT_TRANSPORT +#define RIO_GET_DID(x) ((x & 0x00ff0000) >> 16) +#define RIO_SET_DID(x) ((x & 0x000000ff) << 16) +#else +#define RIO_GET_DID(x) (x & 0xffff) +#define RIO_SET_DID(x) (x & 0xffff) +#endif diff --git a/trunk/drivers/rtc/rtc-bfin.c b/trunk/drivers/rtc/rtc-bfin.c index 8624f55d0560..4f28045d9ef2 100644 --- a/trunk/drivers/rtc/rtc-bfin.c +++ b/trunk/drivers/rtc/rtc-bfin.c @@ -419,7 +419,7 @@ static int __devinit bfin_rtc_probe(struct platform_device *pdev) return -ENOMEM; rtc->rtc_dev = rtc_device_register(pdev->name, &pdev->dev, &bfin_rtc_ops, THIS_MODULE); - if (IS_ERR(rtc)) { + if (unlikely(IS_ERR(rtc))) { ret = PTR_ERR(rtc->rtc_dev); goto err; } diff --git a/trunk/drivers/rtc/rtc-ds1307.c b/trunk/drivers/rtc/rtc-ds1307.c index bbf97e65202a..f389a28720d2 100644 --- a/trunk/drivers/rtc/rtc-ds1307.c +++ b/trunk/drivers/rtc/rtc-ds1307.c @@ -99,38 +99,45 @@ struct ds1307 { }; struct chip_desc { + char name[9]; unsigned nvram56:1; unsigned alarm:1; + enum ds_type type; }; -static const struct chip_desc chips[] = { -[ds_1307] = { +static const struct chip_desc chips[] = { { + .name = "ds1307", + .type = ds_1307, .nvram56 = 1, -}, -[ds_1337] = { +}, { + .name = "ds1337", + .type = ds_1337, .alarm = 1, -}, -[ds_1338] = { +}, { + .name = "ds1338", + .type = ds_1338, .nvram56 = 1, -}, -[ds_1339] = { +}, { + .name = "ds1339", + .type = ds_1339, .alarm = 1, -}, -[ds_1340] = { -}, -[m41t00] = { +}, { + .name = "ds1340", + .type = ds_1340, +}, { + .name = "m41t00", + .type = m41t00, }, }; -static const struct i2c_device_id ds1307_id[] = { - { "ds1307", ds_1307 }, - { "ds1337", ds_1337 }, - { "ds1338", ds_1338 }, - { "ds1339", ds_1339 }, - { "ds1340", ds_1340 }, - { "m41t00", m41t00 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, ds1307_id); +static inline const struct chip_desc *find_chip(const char *s) +{ + unsigned i; + + for (i = 0; i < ARRAY_SIZE(chips); i++) + if (strnicmp(s, chips[i].name, sizeof chips[i].name) == 0) + return &chips[i]; + return NULL; +} static int ds1307_get_time(struct device *dev, struct rtc_time *t) { @@ -319,15 +326,21 @@ static struct bin_attribute nvram = { static struct i2c_driver ds1307_driver; -static int __devinit ds1307_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int __devinit ds1307_probe(struct i2c_client *client) { struct ds1307 *ds1307; int err = -ENODEV; int tmp; - const struct chip_desc *chip = &chips[id->driver_data]; + const struct chip_desc *chip; struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); + chip = find_chip(client->name); + if (!chip) { + dev_err(&client->dev, "unknown chip type '%s'\n", + client->name); + return -ENODEV; + } + if (!i2c_check_functionality(adapter, I2C_FUNC_I2C | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) return -EIO; @@ -348,7 +361,7 @@ static int __devinit ds1307_probe(struct i2c_client *client, ds1307->msg[1].len = sizeof(ds1307->regs); ds1307->msg[1].buf = ds1307->regs; - ds1307->type = id->driver_data; + ds1307->type = chip->type; switch (ds1307->type) { case ds_1337: @@ -537,7 +550,6 @@ static struct i2c_driver ds1307_driver = { }, .probe = ds1307_probe, .remove = __devexit_p(ds1307_remove), - .id_table = ds1307_id, }; static int __init ds1307_init(void) diff --git a/trunk/drivers/rtc/rtc-ds1374.c b/trunk/drivers/rtc/rtc-ds1374.c index fa2d2f8b3f4d..45bda186befc 100644 --- a/trunk/drivers/rtc/rtc-ds1374.c +++ b/trunk/drivers/rtc/rtc-ds1374.c @@ -41,12 +41,6 @@ #define DS1374_REG_SR_AF 0x01 /* Alarm Flag */ #define DS1374_REG_TCR 0x09 /* Trickle Charge */ -static const struct i2c_device_id ds1374_id[] = { - { "rtc-ds1374", 0 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, ds1374_id); - struct ds1374 { struct i2c_client *client; struct rtc_device *rtc; @@ -361,8 +355,7 @@ static const struct rtc_class_ops ds1374_rtc_ops = { .ioctl = ds1374_ioctl, }; -static int ds1374_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int ds1374_probe(struct i2c_client *client) { struct ds1374 *ds1374; int ret; @@ -436,7 +429,6 @@ static struct i2c_driver ds1374_driver = { }, .probe = ds1374_probe, .remove = __devexit_p(ds1374_remove), - .id_table = ds1374_id, }; static int __init ds1374_init(void) diff --git a/trunk/drivers/rtc/rtc-isl1208.c b/trunk/drivers/rtc/rtc-isl1208.c index fbb90b1e4098..fb15e3fb4ce2 100644 --- a/trunk/drivers/rtc/rtc-isl1208.c +++ b/trunk/drivers/rtc/rtc-isl1208.c @@ -490,7 +490,7 @@ isl1208_sysfs_unregister(struct device *dev) } static int -isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id) +isl1208_probe(struct i2c_client *client) { int rc = 0; struct rtc_device *rtc; @@ -545,19 +545,12 @@ isl1208_remove(struct i2c_client *client) return 0; } -static const struct i2c_device_id isl1208_id[] = { - { "isl1208", 0 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, isl1208_id); - static struct i2c_driver isl1208_driver = { .driver = { .name = "rtc-isl1208", }, .probe = isl1208_probe, .remove = isl1208_remove, - .id_table = isl1208_id, }; static int __init diff --git a/trunk/drivers/rtc/rtc-m41t80.c b/trunk/drivers/rtc/rtc-m41t80.c index 316bfaa80872..1cb33cac1237 100644 --- a/trunk/drivers/rtc/rtc-m41t80.c +++ b/trunk/drivers/rtc/rtc-m41t80.c @@ -60,21 +60,48 @@ #define DRV_VERSION "0.05" -static const struct i2c_device_id m41t80_id[] = { - { "m41t80", 0 }, - { "m41t81", M41T80_FEATURE_HT }, - { "m41t81s", M41T80_FEATURE_HT | M41T80_FEATURE_BL }, - { "m41t82", M41T80_FEATURE_HT | M41T80_FEATURE_BL }, - { "m41t83", M41T80_FEATURE_HT | M41T80_FEATURE_BL }, - { "m41st84", M41T80_FEATURE_HT | M41T80_FEATURE_BL }, - { "m41st85", M41T80_FEATURE_HT | M41T80_FEATURE_BL }, - { "m41st87", M41T80_FEATURE_HT | M41T80_FEATURE_BL }, - { } +struct m41t80_chip_info { + const char *name; + u8 features; +}; + +static const struct m41t80_chip_info m41t80_chip_info_tbl[] = { + { + .name = "m41t80", + .features = 0, + }, + { + .name = "m41t81", + .features = M41T80_FEATURE_HT, + }, + { + .name = "m41t81s", + .features = M41T80_FEATURE_HT | M41T80_FEATURE_BL, + }, + { + .name = "m41t82", + .features = M41T80_FEATURE_HT | M41T80_FEATURE_BL, + }, + { + .name = "m41t83", + .features = M41T80_FEATURE_HT | M41T80_FEATURE_BL, + }, + { + .name = "m41st84", + .features = M41T80_FEATURE_HT | M41T80_FEATURE_BL, + }, + { + .name = "m41st85", + .features = M41T80_FEATURE_HT | M41T80_FEATURE_BL, + }, + { + .name = "m41st87", + .features = M41T80_FEATURE_HT | M41T80_FEATURE_BL, + }, }; -MODULE_DEVICE_TABLE(i2c, m41t80_id); struct m41t80_data { - u8 features; + const struct m41t80_chip_info *chip; struct rtc_device *rtc; }; @@ -181,7 +208,7 @@ static int m41t80_rtc_proc(struct device *dev, struct seq_file *seq) struct m41t80_data *clientdata = i2c_get_clientdata(client); u8 reg; - if (clientdata->features & M41T80_FEATURE_BL) { + if (clientdata->chip->features & M41T80_FEATURE_BL) { reg = i2c_smbus_read_byte_data(client, M41T80_REG_FLAGS); seq_printf(seq, "battery\t\t: %s\n", (reg & M41T80_FLAGS_BATT_LOW) ? "exhausted" : "ok"); @@ -729,12 +756,12 @@ static struct notifier_block wdt_notifier = { * ***************************************************************************** */ -static int m41t80_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int m41t80_probe(struct i2c_client *client) { - int rc = 0; + int i, rc = 0; struct rtc_device *rtc = NULL; struct rtc_time tm; + const struct m41t80_chip_info *chip; struct m41t80_data *clientdata = NULL; if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C @@ -746,6 +773,19 @@ static int m41t80_probe(struct i2c_client *client, dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n"); + chip = NULL; + for (i = 0; i < ARRAY_SIZE(m41t80_chip_info_tbl); i++) { + if (!strcmp(m41t80_chip_info_tbl[i].name, client->name)) { + chip = &m41t80_chip_info_tbl[i]; + break; + } + } + if (!chip) { + dev_err(&client->dev, "%s is not supported\n", client->name); + rc = -ENODEV; + goto exit; + } + clientdata = kzalloc(sizeof(*clientdata), GFP_KERNEL); if (!clientdata) { rc = -ENOMEM; @@ -761,7 +801,7 @@ static int m41t80_probe(struct i2c_client *client, } clientdata->rtc = rtc; - clientdata->features = id->driver_data; + clientdata->chip = chip; i2c_set_clientdata(client, clientdata); /* Make sure HT (Halt Update) bit is cleared */ @@ -770,7 +810,7 @@ static int m41t80_probe(struct i2c_client *client, goto ht_err; if (rc & M41T80_ALHOUR_HT) { - if (clientdata->features & M41T80_FEATURE_HT) { + if (chip->features & M41T80_FEATURE_HT) { m41t80_get_datetime(client, &tm); dev_info(&client->dev, "HT bit was set!\n"); dev_info(&client->dev, @@ -802,7 +842,7 @@ static int m41t80_probe(struct i2c_client *client, goto exit; #ifdef CONFIG_RTC_DRV_M41T80_WDT - if (clientdata->features & M41T80_FEATURE_HT) { + if (chip->features & M41T80_FEATURE_HT) { rc = misc_register(&wdt_dev); if (rc) goto exit; @@ -838,7 +878,7 @@ static int m41t80_remove(struct i2c_client *client) struct rtc_device *rtc = clientdata->rtc; #ifdef CONFIG_RTC_DRV_M41T80_WDT - if (clientdata->features & M41T80_FEATURE_HT) { + if (clientdata->chip->features & M41T80_FEATURE_HT) { misc_deregister(&wdt_dev); unregister_reboot_notifier(&wdt_notifier); } @@ -856,7 +896,6 @@ static struct i2c_driver m41t80_driver = { }, .probe = m41t80_probe, .remove = m41t80_remove, - .id_table = m41t80_id, }; static int __init m41t80_rtc_init(void) diff --git a/trunk/drivers/rtc/rtc-pcf8563.c b/trunk/drivers/rtc/rtc-pcf8563.c index 0fc4c3630780..a41681d26eba 100644 --- a/trunk/drivers/rtc/rtc-pcf8563.c +++ b/trunk/drivers/rtc/rtc-pcf8563.c @@ -246,8 +246,7 @@ static const struct rtc_class_ops pcf8563_rtc_ops = { .set_time = pcf8563_rtc_set_time, }; -static int pcf8563_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int pcf8563_probe(struct i2c_client *client) { struct pcf8563 *pcf8563; @@ -300,19 +299,12 @@ static int pcf8563_remove(struct i2c_client *client) return 0; } -static const struct i2c_device_id pcf8563_id[] = { - { "pcf8563", 0 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, pcf8563_id); - static struct i2c_driver pcf8563_driver = { .driver = { .name = "rtc-pcf8563", }, .probe = pcf8563_probe, .remove = pcf8563_remove, - .id_table = pcf8563_id, }; static int __init pcf8563_init(void) diff --git a/trunk/drivers/rtc/rtc-proc.c b/trunk/drivers/rtc/rtc-proc.c index 0c6257a034ff..8d300e6d0d9e 100644 --- a/trunk/drivers/rtc/rtc-proc.c +++ b/trunk/drivers/rtc/rtc-proc.c @@ -108,10 +108,12 @@ void rtc_proc_add_device(struct rtc_device *rtc) if (rtc->id == 0) { struct proc_dir_entry *ent; - ent = proc_create_data("driver/rtc", 0, NULL, - &rtc_proc_fops, rtc); - if (ent) + ent = create_proc_entry("driver/rtc", 0, NULL); + if (ent) { + ent->proc_fops = &rtc_proc_fops; ent->owner = rtc->owner; + ent->data = rtc; + } } } diff --git a/trunk/drivers/rtc/rtc-rs5c372.c b/trunk/drivers/rtc/rtc-rs5c372.c index 56caf6b2c3e5..7e63074708eb 100644 --- a/trunk/drivers/rtc/rtc-rs5c372.c +++ b/trunk/drivers/rtc/rtc-rs5c372.c @@ -69,15 +69,6 @@ enum rtc_type { rtc_rv5c387a, }; -static const struct i2c_device_id rs5c372_id[] = { - { "rs5c372a", rtc_rs5c372a }, - { "rs5c372b", rtc_rs5c372b }, - { "rv5c386", rtc_rv5c386 }, - { "rv5c387a", rtc_rv5c387a }, - { } -}; -MODULE_DEVICE_TABLE(i2c, rs5c372_id); - /* REVISIT: this assumes that: * - we're in the 21st century, so it's safe to ignore the century * bit for rv5c38[67] (REG_MONTH bit 7); @@ -503,8 +494,7 @@ static void rs5c_sysfs_unregister(struct device *dev) static struct i2c_driver rs5c372_driver; -static int rs5c372_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int rs5c372_probe(struct i2c_client *client) { int err = 0; struct rs5c372 *rs5c372; @@ -524,7 +514,6 @@ static int rs5c372_probe(struct i2c_client *client, rs5c372->client = client; i2c_set_clientdata(client, rs5c372); - rs5c372->type = id->driver_data; /* we read registers 0x0f then 0x00-0x0f; skip the first one */ rs5c372->regs = &rs5c372->buf[1]; @@ -533,6 +522,19 @@ static int rs5c372_probe(struct i2c_client *client, if (err < 0) goto exit_kfree; + if (strcmp(client->name, "rs5c372a") == 0) + rs5c372->type = rtc_rs5c372a; + else if (strcmp(client->name, "rs5c372b") == 0) + rs5c372->type = rtc_rs5c372b; + else if (strcmp(client->name, "rv5c386") == 0) + rs5c372->type = rtc_rv5c386; + else if (strcmp(client->name, "rv5c387a") == 0) + rs5c372->type = rtc_rv5c387a; + else { + rs5c372->type = rtc_rs5c372b; + dev_warn(&client->dev, "assuming rs5c372b\n"); + } + /* clock may be set for am/pm or 24 hr time */ switch (rs5c372->type) { case rtc_rs5c372a: @@ -649,7 +651,6 @@ static struct i2c_driver rs5c372_driver = { }, .probe = rs5c372_probe, .remove = rs5c372_remove, - .id_table = rs5c372_id, }; static __init int rs5c372_init(void) diff --git a/trunk/drivers/rtc/rtc-s35390a.c b/trunk/drivers/rtc/rtc-s35390a.c index 29f47bacfc77..e8abc90c32c5 100644 --- a/trunk/drivers/rtc/rtc-s35390a.c +++ b/trunk/drivers/rtc/rtc-s35390a.c @@ -34,12 +34,6 @@ #define S35390A_FLAG_RESET 0x80 #define S35390A_FLAG_TEST 0x01 -static const struct i2c_device_id s35390a_id[] = { - { "s35390a", 0 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, s35390a_id); - struct s35390a { struct i2c_client *client[8]; struct rtc_device *rtc; @@ -201,8 +195,7 @@ static const struct rtc_class_ops s35390a_rtc_ops = { static struct i2c_driver s35390a_driver; -static int s35390a_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int s35390a_probe(struct i2c_client *client) { int err; unsigned int i; @@ -303,7 +296,6 @@ static struct i2c_driver s35390a_driver = { }, .probe = s35390a_probe, .remove = s35390a_remove, - .id_table = s35390a_id, }; static int __init s35390a_rtc_init(void) diff --git a/trunk/drivers/rtc/rtc-x1205.c b/trunk/drivers/rtc/rtc-x1205.c index eaf55945f21b..095282f63523 100644 --- a/trunk/drivers/rtc/rtc-x1205.c +++ b/trunk/drivers/rtc/rtc-x1205.c @@ -494,8 +494,7 @@ static void x1205_sysfs_unregister(struct device *dev) } -static int x1205_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int x1205_probe(struct i2c_client *client) { int err = 0; unsigned char sr; @@ -553,19 +552,12 @@ static int x1205_remove(struct i2c_client *client) return 0; } -static const struct i2c_device_id x1205_id[] = { - { "x1205", 0 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, x1205_id); - static struct i2c_driver x1205_driver = { .driver = { .name = "rtc-x1205", }, .probe = x1205_probe, .remove = x1205_remove, - .id_table = x1205_id, }; static int __init x1205_init(void) diff --git a/trunk/drivers/s390/block/dasd_proc.c b/trunk/drivers/s390/block/dasd_proc.c index 03c0e40a92ff..556063e8f7a9 100644 --- a/trunk/drivers/s390/block/dasd_proc.c +++ b/trunk/drivers/s390/block/dasd_proc.c @@ -157,7 +157,6 @@ static int dasd_devices_open(struct inode *inode, struct file *file) } static const struct file_operations dasd_devices_file_ops = { - .owner = THIS_MODULE, .open = dasd_devices_open, .read = seq_read, .llseek = seq_lseek, @@ -312,16 +311,17 @@ dasd_statistics_write(struct file *file, const char __user *user_buf, int dasd_proc_init(void) { - dasd_proc_root_entry = proc_mkdir("dasd", NULL); + dasd_proc_root_entry = proc_mkdir("dasd", &proc_root); if (!dasd_proc_root_entry) goto out_nodasd; dasd_proc_root_entry->owner = THIS_MODULE; - dasd_devices_entry = proc_create("devices", - S_IFREG | S_IRUGO | S_IWUSR, - dasd_proc_root_entry, - &dasd_devices_file_ops); + dasd_devices_entry = create_proc_entry("devices", + S_IFREG | S_IRUGO | S_IWUSR, + dasd_proc_root_entry); if (!dasd_devices_entry) goto out_nodevices; + dasd_devices_entry->proc_fops = &dasd_devices_file_ops; + dasd_devices_entry->owner = THIS_MODULE; dasd_statistics_entry = create_proc_entry("statistics", S_IFREG | S_IRUGO | S_IWUSR, dasd_proc_root_entry); @@ -335,7 +335,7 @@ dasd_proc_init(void) out_nostatistics: remove_proc_entry("devices", dasd_proc_root_entry); out_nodevices: - remove_proc_entry("dasd", NULL); + remove_proc_entry("dasd", &proc_root); out_nodasd: return -ENOENT; } @@ -345,5 +345,5 @@ dasd_proc_exit(void) { remove_proc_entry("devices", dasd_proc_root_entry); remove_proc_entry("statistics", dasd_proc_root_entry); - remove_proc_entry("dasd", NULL); + remove_proc_entry("dasd", &proc_root); } diff --git a/trunk/drivers/s390/char/tape_proc.c b/trunk/drivers/s390/char/tape_proc.c index e7c888c14e71..c9b96d51b28f 100644 --- a/trunk/drivers/s390/char/tape_proc.c +++ b/trunk/drivers/s390/char/tape_proc.c @@ -111,7 +111,6 @@ static int tape_proc_open(struct inode *inode, struct file *file) static const struct file_operations tape_proc_ops = { - .owner = THIS_MODULE, .open = tape_proc_open, .read = seq_read, .llseek = seq_lseek, @@ -125,12 +124,14 @@ void tape_proc_init(void) { tape_proc_devices = - proc_create("tapedevices", S_IFREG | S_IRUGO | S_IWUSR, NULL, - &tape_proc_ops); + create_proc_entry ("tapedevices", S_IFREG | S_IRUGO | S_IWUSR, + &proc_root); if (tape_proc_devices == NULL) { PRINT_WARN("tape: Cannot register procfs entry tapedevices\n"); return; } + tape_proc_devices->proc_fops = &tape_proc_ops; + tape_proc_devices->owner = THIS_MODULE; } /* @@ -140,5 +141,5 @@ void tape_proc_cleanup(void) { if (tape_proc_devices != NULL) - remove_proc_entry ("tapedevices", NULL); + remove_proc_entry ("tapedevices", &proc_root); } diff --git a/trunk/drivers/s390/cio/blacklist.c b/trunk/drivers/s390/cio/blacklist.c index 40ef948fcb3a..e8597ec92247 100644 --- a/trunk/drivers/s390/cio/blacklist.c +++ b/trunk/drivers/s390/cio/blacklist.c @@ -374,10 +374,13 @@ cio_ignore_proc_init (void) { struct proc_dir_entry *entry; - entry = proc_create("cio_ignore", S_IFREG | S_IRUGO | S_IWUSR, NULL, - &cio_ignore_proc_fops); + entry = create_proc_entry ("cio_ignore", S_IFREG | S_IRUGO | S_IWUSR, + &proc_root); if (!entry) return -ENOENT; + + entry->proc_fops = &cio_ignore_proc_fops; + return 0; } diff --git a/trunk/drivers/s390/cio/qdio.c b/trunk/drivers/s390/cio/qdio.c index 43876e287370..10aa1e780801 100644 --- a/trunk/drivers/s390/cio/qdio.c +++ b/trunk/drivers/s390/cio/qdio.c @@ -3632,7 +3632,7 @@ qdio_add_procfs_entry(void) { proc_perf_file_registration=0; qdio_perf_proc_file=create_proc_entry(QDIO_PERF, - S_IFREG|0444,NULL); + S_IFREG|0444,&proc_root); if (qdio_perf_proc_file) { qdio_perf_proc_file->read_proc=&qdio_perf_procfile_read; } else proc_perf_file_registration=-1; @@ -3647,7 +3647,7 @@ static void qdio_remove_procfs_entry(void) { if (!proc_perf_file_registration) /* means if it went ok earlier */ - remove_proc_entry(QDIO_PERF,NULL); + remove_proc_entry(QDIO_PERF,&proc_root); } /** diff --git a/trunk/drivers/scsi/megaraid.c b/trunk/drivers/scsi/megaraid.c index 18551aaf5e09..b135a1ed4b2c 100644 --- a/trunk/drivers/scsi/megaraid.c +++ b/trunk/drivers/scsi/megaraid.c @@ -4996,7 +4996,7 @@ static int __init megaraid_init(void) max_mbox_busy_wait = MBOX_BUSY_WAIT; #ifdef CONFIG_PROC_FS - mega_proc_dir_entry = proc_mkdir("megaraid", NULL); + mega_proc_dir_entry = proc_mkdir("megaraid", &proc_root); if (!mega_proc_dir_entry) { printk(KERN_WARNING "megaraid: failed to create megaraid root\n"); @@ -5005,7 +5005,7 @@ static int __init megaraid_init(void) error = pci_register_driver(&megaraid_pci_driver); if (error) { #ifdef CONFIG_PROC_FS - remove_proc_entry("megaraid", NULL); + remove_proc_entry("megaraid", &proc_root); #endif return error; } @@ -5035,7 +5035,7 @@ static void __exit megaraid_exit(void) pci_unregister_driver(&megaraid_pci_driver); #ifdef CONFIG_PROC_FS - remove_proc_entry("megaraid", NULL); + remove_proc_entry("megaraid", &proc_root); #endif } diff --git a/trunk/drivers/scsi/scsi_debug.c b/trunk/drivers/scsi/scsi_debug.c index f6600bfb5bde..07103c399fe0 100644 --- a/trunk/drivers/scsi/scsi_debug.c +++ b/trunk/drivers/scsi/scsi_debug.c @@ -1773,7 +1773,7 @@ static int scsi_debug_slave_alloc(struct scsi_device *sdp) if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts) printk(KERN_INFO "scsi_debug: slave_alloc <%u %u %u %u>\n", sdp->host->host_no, sdp->channel, sdp->id, sdp->lun); - queue_flag_set_unlocked(QUEUE_FLAG_BIDI, sdp->request_queue); + set_bit(QUEUE_FLAG_BIDI, &sdp->request_queue->queue_flags); return 0; } diff --git a/trunk/drivers/scsi/scsi_devinfo.c b/trunk/drivers/scsi/scsi_devinfo.c index a235802f2981..b8de041bc0ae 100644 --- a/trunk/drivers/scsi/scsi_devinfo.c +++ b/trunk/drivers/scsi/scsi_devinfo.c @@ -449,40 +449,37 @@ int scsi_get_device_flags(struct scsi_device *sdev, } #ifdef CONFIG_SCSI_PROC_FS -static int devinfo_seq_show(struct seq_file *m, void *v) +/* + * proc_scsi_dev_info_read: dump the scsi_dev_info_list via + * /proc/scsi/device_info + */ +static int proc_scsi_devinfo_read(char *buffer, char **start, + off_t offset, int length) { - struct scsi_dev_info_list *devinfo = - list_entry(v, struct scsi_dev_info_list, dev_info_list); + struct scsi_dev_info_list *devinfo; + int size, len = 0; + off_t begin = 0; + off_t pos = 0; - seq_printf(m, "'%.8s' '%.16s' 0x%x\n", + list_for_each_entry(devinfo, &scsi_dev_info_list, dev_info_list) { + size = sprintf(buffer + len, "'%.8s' '%.16s' 0x%x\n", devinfo->vendor, devinfo->model, devinfo->flags); - return 0; -} - -static void * devinfo_seq_start(struct seq_file *m, loff_t *pos) -{ - return seq_list_start(&scsi_dev_info_list, *pos); -} - -static void * devinfo_seq_next(struct seq_file *m, void *v, loff_t *pos) -{ - return seq_list_next(v, &scsi_dev_info_list, pos); -} - -static void devinfo_seq_stop(struct seq_file *m, void *v) -{ -} - -static const struct seq_operations scsi_devinfo_seq_ops = { - .start = devinfo_seq_start, - .next = devinfo_seq_next, - .stop = devinfo_seq_stop, - .show = devinfo_seq_show, -}; + len += size; + pos = begin + len; + if (pos < offset) { + len = 0; + begin = pos; + } + if (pos > offset + length) + goto stop_output; + } -static int proc_scsi_devinfo_open(struct inode *inode, struct file *file) -{ - return seq_open(file, &scsi_devinfo_seq_ops); +stop_output: + *start = buffer + (offset - begin); /* Start of wanted data */ + len -= (offset - begin); /* Start slop */ + if (len > length) + len = length; /* Ending slop */ + return (len); } /* @@ -492,12 +489,11 @@ static int proc_scsi_devinfo_open(struct inode *inode, struct file *file) * integer value of flag to the scsi device info list. * To use, echo "vendor:model:flag" > /proc/scsi/device_info */ -static ssize_t proc_scsi_devinfo_write(struct file *file, - const char __user *buf, - size_t length, loff_t *ppos) +static int proc_scsi_devinfo_write(struct file *file, const char __user *buf, + unsigned long length, void *data) { char *buffer; - ssize_t err = length; + int err = length; if (!buf || length>PAGE_SIZE) return -EINVAL; @@ -521,15 +517,6 @@ static ssize_t proc_scsi_devinfo_write(struct file *file, free_page((unsigned long)buffer); return err; } - -static const struct file_operations scsi_devinfo_proc_fops = { - .owner = THIS_MODULE, - .open = proc_scsi_devinfo_open, - .read = seq_read, - .write = proc_scsi_devinfo_write, - .llseek = seq_lseek, - .release = seq_release, -}; #endif /* CONFIG_SCSI_PROC_FS */ module_param_string(dev_flags, scsi_dev_flags, sizeof(scsi_dev_flags), 0); @@ -590,13 +577,15 @@ int __init scsi_init_devinfo(void) } #ifdef CONFIG_SCSI_PROC_FS - p = proc_create("scsi/device_info", 0, NULL, &scsi_devinfo_proc_fops); + p = create_proc_entry("scsi/device_info", 0, NULL); if (!p) { error = -ENOMEM; goto out; } p->owner = THIS_MODULE; + p->get_info = proc_scsi_devinfo_read; + p->write_proc = proc_scsi_devinfo_write; #endif /* CONFIG_SCSI_PROC_FS */ out: diff --git a/trunk/drivers/scsi/scsi_error.c b/trunk/drivers/scsi/scsi_error.c index 1eaba6cd80f4..221f31e36d26 100644 --- a/trunk/drivers/scsi/scsi_error.c +++ b/trunk/drivers/scsi/scsi_error.c @@ -1771,7 +1771,6 @@ scsi_reset_provider(struct scsi_device *dev, int flag) unsigned long flags; int rtn; - blk_rq_init(NULL, &req); scmd->request = &req; memset(&scmd->eh_timeout, 0, sizeof(scmd->eh_timeout)); diff --git a/trunk/drivers/scsi/scsi_lib.c b/trunk/drivers/scsi/scsi_lib.c index d545ad1cf47a..67f412bb4974 100644 --- a/trunk/drivers/scsi/scsi_lib.c +++ b/trunk/drivers/scsi/scsi_lib.c @@ -536,9 +536,6 @@ static void scsi_run_queue(struct request_queue *q) !shost->host_blocked && !shost->host_self_blocked && !((shost->can_queue > 0) && (shost->host_busy >= shost->can_queue))) { - - int flagset; - /* * As long as shost is accepting commands and we have * starved queues, call blk_run_queue. scsi_request_fn @@ -552,20 +549,19 @@ static void scsi_run_queue(struct request_queue *q) sdev = list_entry(shost->starved_list.next, struct scsi_device, starved_entry); list_del_init(&sdev->starved_entry); - spin_unlock(shost->host_lock); - - spin_lock(sdev->request_queue->queue_lock); - flagset = test_bit(QUEUE_FLAG_REENTER, &q->queue_flags) && - !test_bit(QUEUE_FLAG_REENTER, - &sdev->request_queue->queue_flags); - if (flagset) - queue_flag_set(QUEUE_FLAG_REENTER, sdev->request_queue); - __blk_run_queue(sdev->request_queue); - if (flagset) - queue_flag_clear(QUEUE_FLAG_REENTER, sdev->request_queue); - spin_unlock(sdev->request_queue->queue_lock); + spin_unlock_irqrestore(shost->host_lock, flags); - spin_lock(shost->host_lock); + + if (test_bit(QUEUE_FLAG_REENTER, &q->queue_flags) && + !test_and_set_bit(QUEUE_FLAG_REENTER, + &sdev->request_queue->queue_flags)) { + blk_run_queue(sdev->request_queue); + clear_bit(QUEUE_FLAG_REENTER, + &sdev->request_queue->queue_flags); + } else + blk_run_queue(sdev->request_queue); + + spin_lock_irqsave(shost->host_lock, flags); if (unlikely(!list_empty(&sdev->starved_entry))) /* * sdev lost a race, and was put back on the @@ -1589,9 +1585,8 @@ struct request_queue *__scsi_alloc_queue(struct Scsi_Host *shost, blk_queue_max_segment_size(q, dma_get_max_seg_size(dev)); - /* New queue, no concurrency on queue_flags */ if (!shost->use_clustering) - queue_flag_clear_unlocked(QUEUE_FLAG_CLUSTER, q); + clear_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags); /* * set a reasonable default alignment on word boundaries: the diff --git a/trunk/drivers/scsi/scsi_proc.c b/trunk/drivers/scsi/scsi_proc.c index e4a0d2f9b357..3a1c99d5c775 100644 --- a/trunk/drivers/scsi/scsi_proc.c +++ b/trunk/drivers/scsi/scsi_proc.c @@ -413,7 +413,6 @@ static int proc_scsi_open(struct inode *inode, struct file *file) } static const struct file_operations proc_scsi_operations = { - .owner = THIS_MODULE, .open = proc_scsi_open, .read = seq_read, .write = proc_scsi_write, @@ -432,9 +431,10 @@ int __init scsi_init_procfs(void) if (!proc_scsi) goto err1; - pde = proc_create("scsi/scsi", 0, NULL, &proc_scsi_operations); + pde = create_proc_entry("scsi/scsi", 0, NULL); if (!pde) goto err2; + pde->proc_fops = &proc_scsi_operations; return 0; diff --git a/trunk/drivers/scsi/scsi_scan.c b/trunk/drivers/scsi/scsi_scan.c index a00eee6f7be9..fcd7455ffc39 100644 --- a/trunk/drivers/scsi/scsi_scan.c +++ b/trunk/drivers/scsi/scsi_scan.c @@ -1828,7 +1828,7 @@ void scsi_scan_host(struct Scsi_Host *shost) } p = kthread_run(do_scan_async, data, "scsi_scan_%d", shost->host_no); - if (IS_ERR(p)) + if (unlikely(IS_ERR(p))) do_scan_async(data); } EXPORT_SYMBOL(scsi_scan_host); diff --git a/trunk/drivers/scsi/scsi_transport_sas.c b/trunk/drivers/scsi/scsi_transport_sas.c index f4461d35ffb9..7899e3dda9bf 100644 --- a/trunk/drivers/scsi/scsi_transport_sas.c +++ b/trunk/drivers/scsi/scsi_transport_sas.c @@ -248,7 +248,8 @@ static int sas_bsg_initialize(struct Scsi_Host *shost, struct sas_rphy *rphy) else q->queuedata = shost; - queue_flag_set_unlocked(QUEUE_FLAG_BIDI, q); + set_bit(QUEUE_FLAG_BIDI, &q->queue_flags); + return 0; } diff --git a/trunk/drivers/scsi/sd.c b/trunk/drivers/scsi/sd.c index 01cefbb2d539..3cea17dd5dba 100644 --- a/trunk/drivers/scsi/sd.c +++ b/trunk/drivers/scsi/sd.c @@ -860,6 +860,7 @@ static int sd_sync_cache(struct scsi_disk *sdkp) static void sd_prepare_flush(struct request_queue *q, struct request *rq) { + memset(rq->cmd, 0, sizeof(rq->cmd)); rq->cmd_type = REQ_TYPE_BLOCK_PC; rq->timeout = SD_TIMEOUT; rq->cmd[0] = SYNCHRONIZE_CACHE; diff --git a/trunk/drivers/scsi/sg.c b/trunk/drivers/scsi/sg.c index c9d7f721b9e2..2029422bc04d 100644 --- a/trunk/drivers/scsi/sg.c +++ b/trunk/drivers/scsi/sg.c @@ -2667,6 +2667,7 @@ sg_proc_init(void) { int k, mask; int num_leaves = ARRAY_SIZE(sg_proc_leaf_arr); + struct proc_dir_entry *pdep; struct sg_proc_leaf * leaf; sg_proc_sgp = proc_mkdir(sg_proc_sg_dirname, NULL); @@ -2675,10 +2676,13 @@ sg_proc_init(void) for (k = 0; k < num_leaves; ++k) { leaf = &sg_proc_leaf_arr[k]; mask = leaf->fops->write ? S_IRUGO | S_IWUSR : S_IRUGO; - leaf->fops->owner = THIS_MODULE; - leaf->fops->read = seq_read; - leaf->fops->llseek = seq_lseek; - proc_create(leaf->name, mask, sg_proc_sgp, leaf->fops); + pdep = create_proc_entry(leaf->name, mask, sg_proc_sgp); + if (pdep) { + leaf->fops->owner = THIS_MODULE, + leaf->fops->read = seq_read, + leaf->fops->llseek = seq_lseek, + pdep->proc_fops = leaf->fops; + } } return 0; } diff --git a/trunk/drivers/serial/s3c2410.c b/trunk/drivers/serial/s3c2410.c index da5a02cb4f63..4ffa2585429a 100644 --- a/trunk/drivers/serial/s3c2410.c +++ b/trunk/drivers/serial/s3c2410.c @@ -1022,7 +1022,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport, struct uart_port *port = &ourport->port; struct s3c2410_uartcfg *cfg; struct resource *res; - int ret; dbg("s3c24xx_serial_init_port: port=%p, platdev=%p\n", port, platdev); @@ -1065,11 +1064,9 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport, port->mapbase = res->start; port->membase = S3C24XX_VA_UART + (res->start - S3C24XX_PA_UART); - ret = platform_get_irq(platdev, 0); - if (ret < 0) + port->irq = platform_get_irq(platdev, 0); + if (port->irq < 0) port->irq = 0; - else - port->irq = ret; ourport->clk = clk_get(&platdev->dev, "uart"); diff --git a/trunk/drivers/usb/atm/ueagle-atm.c b/trunk/drivers/usb/atm/ueagle-atm.c index 5f71ff3aee35..4220f22b6660 100644 --- a/trunk/drivers/usb/atm/ueagle-atm.c +++ b/trunk/drivers/usb/atm/ueagle-atm.c @@ -305,6 +305,8 @@ enum { */ #define FW_GET_BYTE(p) *((__u8 *) (p)) +#define FW_GET_WORD(p) le16_to_cpu(get_unaligned((__le16 *) (p))) +#define FW_GET_LONG(p) le32_to_cpu(get_unaligned((__le32 *) (p))) #define FW_DIR "ueagle-atm/" #define NB_MODEM 4 @@ -619,7 +621,7 @@ static void uea_upload_pre_firmware(const struct firmware *fw_entry, void *conte if (size < 4) goto err_fw_corrupted; - crc = get_unaligned_le32(pfw); + crc = FW_GET_LONG(pfw); pfw += 4; size -= 4; if (crc32_be(0, pfw, size) != crc) @@ -638,7 +640,7 @@ static void uea_upload_pre_firmware(const struct firmware *fw_entry, void *conte while (size > 3) { u8 len = FW_GET_BYTE(pfw); - u16 add = get_unaligned_le16(pfw + 1); + u16 add = FW_GET_WORD(pfw + 1); size -= len + 3; if (size < 0) @@ -736,7 +738,7 @@ static int check_dsp_e1(u8 *dsp, unsigned int len) for (i = 0; i < pagecount; i++) { - pageoffset = get_unaligned_le32(dsp + p); + pageoffset = FW_GET_LONG(dsp + p); p += 4; if (pageoffset == 0) @@ -757,7 +759,7 @@ static int check_dsp_e1(u8 *dsp, unsigned int len) return 1; pp += 2; /* skip blockaddr */ - blocksize = get_unaligned_le16(dsp + pp); + blocksize = FW_GET_WORD(dsp + pp); pp += 2; /* enough space for block data? */ @@ -926,7 +928,7 @@ static void uea_load_page_e1(struct work_struct *work) goto bad1; p += 4 * pageno; - pageoffset = get_unaligned_le32(p); + pageoffset = FW_GET_LONG(p); if (pageoffset == 0) goto bad1; @@ -943,10 +945,10 @@ static void uea_load_page_e1(struct work_struct *work) bi.wOvlOffset = cpu_to_le16(ovl | 0x8000); for (i = 0; i < blockcount; i++) { - blockaddr = get_unaligned_le16(p); + blockaddr = FW_GET_WORD(p); p += 2; - blocksize = get_unaligned_le16(p); + blocksize = FW_GET_WORD(p); p += 2; bi.wSize = cpu_to_le16(blocksize); @@ -1150,9 +1152,9 @@ static int uea_cmv_e1(struct uea_softc *sc, cmv.bDirection = E1_HOSTTOMODEM; cmv.bFunction = function; cmv.wIndex = cpu_to_le16(sc->cmv_dsc.e1.idx); - put_unaligned_le32(address, &cmv.dwSymbolicAddress); + put_unaligned(cpu_to_le32(address), &cmv.dwSymbolicAddress); cmv.wOffsetAddress = cpu_to_le16(offset); - put_unaligned_le32(data >> 16 | data << 16, &cmv.dwData); + put_unaligned(cpu_to_le32(data >> 16 | data << 16), &cmv.dwData); ret = uea_request(sc, UEA_E1_SET_BLOCK, UEA_MPTX_START, sizeof(cmv), &cmv); if (ret < 0) @@ -1644,7 +1646,7 @@ static int request_cmvs(struct uea_softc *sc, if (size < 5) goto err_fw_corrupted; - crc = get_unaligned_le32(data); + crc = FW_GET_LONG(data); data += 4; size -= 4; if (crc32_be(0, data, size) != crc) @@ -1694,9 +1696,9 @@ static int uea_send_cmvs_e1(struct uea_softc *sc) "please update your firmware\n"); for (i = 0; i < len; i++) { - ret = uea_write_cmv_e1(sc, get_unaligned_le32(&cmvs_v1[i].address), - get_unaligned_le16(&cmvs_v1[i].offset), - get_unaligned_le32(&cmvs_v1[i].data)); + ret = uea_write_cmv_e1(sc, FW_GET_LONG(&cmvs_v1[i].address), + FW_GET_WORD(&cmvs_v1[i].offset), + FW_GET_LONG(&cmvs_v1[i].data)); if (ret < 0) goto out; } @@ -1704,9 +1706,9 @@ static int uea_send_cmvs_e1(struct uea_softc *sc) struct uea_cmvs_v2 *cmvs_v2 = cmvs_ptr; for (i = 0; i < len; i++) { - ret = uea_write_cmv_e1(sc, get_unaligned_le32(&cmvs_v2[i].address), - (u16) get_unaligned_le32(&cmvs_v2[i].offset), - get_unaligned_le32(&cmvs_v2[i].data)); + ret = uea_write_cmv_e1(sc, FW_GET_LONG(&cmvs_v2[i].address), + (u16) FW_GET_LONG(&cmvs_v2[i].offset), + FW_GET_LONG(&cmvs_v2[i].data)); if (ret < 0) goto out; } @@ -1757,10 +1759,10 @@ static int uea_send_cmvs_e4(struct uea_softc *sc) for (i = 0; i < len; i++) { ret = uea_write_cmv_e4(sc, 1, - get_unaligned_le32(&cmvs_v2[i].group), - get_unaligned_le32(&cmvs_v2[i].address), - get_unaligned_le32(&cmvs_v2[i].offset), - get_unaligned_le32(&cmvs_v2[i].data)); + FW_GET_LONG(&cmvs_v2[i].group), + FW_GET_LONG(&cmvs_v2[i].address), + FW_GET_LONG(&cmvs_v2[i].offset), + FW_GET_LONG(&cmvs_v2[i].data)); if (ret < 0) goto out; } @@ -1962,7 +1964,7 @@ static void uea_dispatch_cmv_e1(struct uea_softc *sc, struct intr_pkt *intr) if (UEA_CHIP_VERSION(sc) == ADI930 && cmv->bFunction == E1_MAKEFUNCTION(2, 2)) { cmv->wIndex = cpu_to_le16(dsc->idx); - put_unaligned_le32(dsc->address, &cmv->dwSymbolicAddress); + put_unaligned(cpu_to_le32(dsc->address), &cmv->dwSymbolicAddress); cmv->wOffsetAddress = cpu_to_le16(dsc->offset); } else goto bad2; @@ -1976,11 +1978,11 @@ static void uea_dispatch_cmv_e1(struct uea_softc *sc, struct intr_pkt *intr) /* in case of MEMACCESS */ if (le16_to_cpu(cmv->wIndex) != dsc->idx || - get_unaligned_le32(&cmv->dwSymbolicAddress) != dsc->address || + le32_to_cpu(get_unaligned(&cmv->dwSymbolicAddress)) != dsc->address || le16_to_cpu(cmv->wOffsetAddress) != dsc->offset) goto bad2; - sc->data = get_unaligned_le32(&cmv->dwData); + sc->data = le32_to_cpu(get_unaligned(&cmv->dwData)); sc->data = sc->data << 16 | sc->data >> 16; wake_up_cmv_ack(sc); diff --git a/trunk/drivers/usb/class/cdc-acm.c b/trunk/drivers/usb/class/cdc-acm.c index cefe7f2c6f75..7b572e75e73c 100644 --- a/trunk/drivers/usb/class/cdc-acm.c +++ b/trunk/drivers/usb/class/cdc-acm.c @@ -280,7 +280,7 @@ static void acm_ctrl_irq(struct urb *urb) case USB_CDC_NOTIFY_SERIAL_STATE: - newctrl = get_unaligned_le16(data); + newctrl = le16_to_cpu(get_unaligned((__le16 *) data)); if (acm->tty && !acm->clocal && (acm->ctrlin & ~newctrl & ACM_CTRL_DCD)) { dbg("calling hangup"); diff --git a/trunk/drivers/usb/core/inode.c b/trunk/drivers/usb/core/inode.c index 1d253dd4ea81..8607846e3c3f 100644 --- a/trunk/drivers/usb/core/inode.c +++ b/trunk/drivers/usb/core/inode.c @@ -773,7 +773,7 @@ int __init usbfs_init(void) usb_register_notify(&usbfs_nb); /* create mount point for usbfs */ - usbdir = proc_mkdir("bus/usb", NULL); + usbdir = proc_mkdir("usb", proc_bus); return 0; } @@ -783,6 +783,6 @@ void usbfs_cleanup(void) usb_unregister_notify(&usbfs_nb); unregister_filesystem(&usb_fs_type); if (usbdir) - remove_proc_entry("bus/usb", NULL); + remove_proc_entry("usb", proc_bus); } diff --git a/trunk/drivers/usb/gadget/at91_udc.c b/trunk/drivers/usb/gadget/at91_udc.c index 274c60a970cd..9b913afb2e6d 100644 --- a/trunk/drivers/usb/gadget/at91_udc.c +++ b/trunk/drivers/usb/gadget/at91_udc.c @@ -231,7 +231,6 @@ static int proc_udc_open(struct inode *inode, struct file *file) } static const struct file_operations proc_ops = { - .owner = THIS_MODULE, .open = proc_udc_open, .read = seq_read, .llseek = seq_lseek, @@ -240,7 +239,15 @@ static const struct file_operations proc_ops = { static void create_debug_file(struct at91_udc *udc) { - udc->pde = proc_create_data(debug_filename, 0, NULL, &proc_ops, udc); + struct proc_dir_entry *pde; + + pde = create_proc_entry (debug_filename, 0, NULL); + udc->pde = pde; + if (pde == NULL) + return; + + pde->proc_fops = &proc_ops; + pde->data = udc; } static void remove_debug_file(struct at91_udc *udc) diff --git a/trunk/drivers/usb/gadget/goku_udc.c b/trunk/drivers/usb/gadget/goku_udc.c index be6613afedbf..64a592cbbe7b 100644 --- a/trunk/drivers/usb/gadget/goku_udc.c +++ b/trunk/drivers/usb/gadget/goku_udc.c @@ -127,7 +127,7 @@ goku_ep_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) /* enabling the no-toggle interrupt mode would need an api hook */ mode = 0; - max = get_unaligned_le16(&desc->wMaxPacketSize); + max = le16_to_cpu(get_unaligned(&desc->wMaxPacketSize)); switch (max) { case 64: mode++; case 32: mode++; diff --git a/trunk/drivers/usb/gadget/omap_udc.c b/trunk/drivers/usb/gadget/omap_udc.c index 881d74c3d964..95f7662376f1 100644 --- a/trunk/drivers/usb/gadget/omap_udc.c +++ b/trunk/drivers/usb/gadget/omap_udc.c @@ -2504,7 +2504,6 @@ static int proc_udc_open(struct inode *inode, struct file *file) } static const struct file_operations proc_ops = { - .owner = THIS_MODULE, .open = proc_udc_open, .read = seq_read, .llseek = seq_lseek, @@ -2513,7 +2512,11 @@ static const struct file_operations proc_ops = { static void create_proc_file(void) { - proc_create(proc_filename, 0, NULL, &proc_ops); + struct proc_dir_entry *pde; + + pde = create_proc_entry (proc_filename, 0, NULL); + if (pde) + pde->proc_fops = &proc_ops; } static void remove_proc_file(void) diff --git a/trunk/drivers/usb/gadget/rndis.c b/trunk/drivers/usb/gadget/rndis.c index d0677f5d3cd5..bd58dd504f6f 100644 --- a/trunk/drivers/usb/gadget/rndis.c +++ b/trunk/drivers/usb/gadget/rndis.c @@ -183,10 +183,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, DBG("query OID %08x value, len %d:\n", OID, buf_len); for (i = 0; i < buf_len; i += 16) { DBG("%03d: %08x %08x %08x %08x\n", i, - get_unaligned_le32(&buf[i]), - get_unaligned_le32(&buf[i + 4]), - get_unaligned_le32(&buf[i + 8]), - get_unaligned_le32(&buf[i + 12])); + le32_to_cpu(get_unaligned((__le32 *) + &buf[i])), + le32_to_cpu(get_unaligned((__le32 *) + &buf[i + 4])), + le32_to_cpu(get_unaligned((__le32 *) + &buf[i + 8])), + le32_to_cpu(get_unaligned((__le32 *) + &buf[i + 12]))); } } @@ -662,7 +666,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, break; case OID_PNP_QUERY_POWER: DBG("%s: OID_PNP_QUERY_POWER D%d\n", __func__, - get_unaligned_le32(buf) - 1); + le32_to_cpu(get_unaligned((__le32 *)buf)) - 1); /* only suspend is a real power state, and * it can't be entered by OID_PNP_SET_POWER... */ @@ -701,10 +705,14 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len, DBG("set OID %08x value, len %d:\n", OID, buf_len); for (i = 0; i < buf_len; i += 16) { DBG("%03d: %08x %08x %08x %08x\n", i, - get_unaligned_le32(&buf[i]), - get_unaligned_le32(&buf[i + 4]), - get_unaligned_le32(&buf[i + 8]), - get_unaligned_le32(&buf[i + 12])); + le32_to_cpu(get_unaligned((__le32 *) + &buf[i])), + le32_to_cpu(get_unaligned((__le32 *) + &buf[i + 4])), + le32_to_cpu(get_unaligned((__le32 *) + &buf[i + 8])), + le32_to_cpu(get_unaligned((__le32 *) + &buf[i + 12]))); } } @@ -718,7 +726,8 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len, * PROMISCUOUS, DIRECTED, * MULTICAST, ALL_MULTICAST, BROADCAST */ - *params->filter = (u16)get_unaligned_le32(buf); + *params->filter = (u16) le32_to_cpu(get_unaligned( + (__le32 *)buf)); DBG("%s: OID_GEN_CURRENT_PACKET_FILTER %08x\n", __func__, *params->filter); @@ -768,7 +777,7 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len, * resuming, Windows forces a reset, and then SET_POWER D0. * FIXME ... then things go batty; Windows wedges itself. */ - i = get_unaligned_le32(buf); + i = le32_to_cpu(get_unaligned((__le32 *)buf)); DBG("%s: OID_PNP_SET_POWER D%d\n", __func__, i - 1); switch (i) { case NdisDeviceStateD0: @@ -1055,8 +1064,8 @@ int rndis_msg_parser (u8 configNr, u8 *buf) return -ENOMEM; tmp = (__le32 *) buf; - MsgType = get_unaligned_le32(tmp++); - MsgLength = get_unaligned_le32(tmp++); + MsgType = le32_to_cpu(get_unaligned(tmp++)); + MsgLength = le32_to_cpu(get_unaligned(tmp++)); if (configNr >= RNDIS_MAX_CONFIGS) return -ENOTSUPP; @@ -1287,9 +1296,10 @@ int rndis_rm_hdr(struct sk_buff *skb) tmp++; /* DataOffset, DataLength */ - if (!skb_pull(skb, get_unaligned_le32(tmp++) + 8)) + if (!skb_pull(skb, le32_to_cpu(get_unaligned(tmp++)) + + 8 /* offset of DataOffset */)) return -EOVERFLOW; - skb_trim(skb, get_unaligned_le32(tmp++)); + skb_trim(skb, le32_to_cpu(get_unaligned(tmp++))); return 0; } diff --git a/trunk/drivers/usb/gadget/usbstring.c b/trunk/drivers/usb/gadget/usbstring.c index 4154be375c7a..878e428a0ec1 100644 --- a/trunk/drivers/usb/gadget/usbstring.c +++ b/trunk/drivers/usb/gadget/usbstring.c @@ -74,7 +74,7 @@ static int utf8_to_utf16le(const char *s, __le16 *cp, unsigned len) goto fail; } else uchar = c; - put_unaligned_le16(uchar, cp++); + put_unaligned (cpu_to_le16 (uchar), cp++); count++; len--; } diff --git a/trunk/drivers/usb/host/ehci-hub.c b/trunk/drivers/usb/host/ehci-hub.c index 382587c4457c..f13d1029aeb2 100644 --- a/trunk/drivers/usb/host/ehci-hub.c +++ b/trunk/drivers/usb/host/ehci-hub.c @@ -770,7 +770,7 @@ static int ehci_hub_control ( if (status & ~0xffff) /* only if wPortChange is interesting */ #endif dbg_port (ehci, "GetStatus", wIndex + 1, temp); - put_unaligned_le32(status, buf); + put_unaligned(cpu_to_le32 (status), (__le32 *) buf); break; case SetHubFeature: switch (wValue) { diff --git a/trunk/drivers/usb/host/ohci-hub.c b/trunk/drivers/usb/host/ohci-hub.c index 17dc2eccda83..5be3bb3e6a9d 100644 --- a/trunk/drivers/usb/host/ohci-hub.c +++ b/trunk/drivers/usb/host/ohci-hub.c @@ -736,14 +736,14 @@ static int ohci_hub_control ( break; case GetHubStatus: temp = roothub_status (ohci) & ~(RH_HS_CRWE | RH_HS_DRWE); - put_unaligned_le32(temp, buf); + put_unaligned(cpu_to_le32 (temp), (__le32 *) buf); break; case GetPortStatus: if (!wIndex || wIndex > ports) goto error; wIndex--; temp = roothub_portstatus (ohci, wIndex); - put_unaligned_le32(temp, buf); + put_unaligned(cpu_to_le32 (temp), (__le32 *) buf); #ifndef OHCI_VERBOSE_DEBUG if (*(u16*)(buf+2)) /* only if wPortChange is interesting */ diff --git a/trunk/drivers/usb/host/sl811-hcd.c b/trunk/drivers/usb/host/sl811-hcd.c index 426575247b23..3fd7a0c12078 100644 --- a/trunk/drivers/usb/host/sl811-hcd.c +++ b/trunk/drivers/usb/host/sl811-hcd.c @@ -1506,7 +1506,15 @@ static const char proc_filename[] = "driver/sl811h"; static void create_debug_file(struct sl811 *sl811) { - sl811->pde = proc_create_data(proc_filename, 0, NULL, &proc_ops, sl811); + struct proc_dir_entry *pde; + + pde = create_proc_entry(proc_filename, 0, NULL); + if (pde == NULL) + return; + + pde->proc_fops = &proc_ops; + pde->data = sl811; + sl811->pde = pde; } static void remove_debug_file(struct sl811 *sl811) diff --git a/trunk/drivers/video/clps711xfb.c b/trunk/drivers/video/clps711xfb.c index 9f8a389dc7ae..17b5267f44d7 100644 --- a/trunk/drivers/video/clps711xfb.c +++ b/trunk/drivers/video/clps711xfb.c @@ -381,7 +381,7 @@ int __init clps711xfb_init(void) /* Register the /proc entries. */ clps7111fb_backlight_proc_entry = create_proc_entry("backlight", 0444, - NULL); + &proc_root); if (clps7111fb_backlight_proc_entry == NULL) { printk("Couldn't create the /proc entry for the backlight.\n"); return -EINVAL; diff --git a/trunk/drivers/video/console/fbcon.c b/trunk/drivers/video/console/fbcon.c index ad31983b43eb..8eda7b60df8f 100644 --- a/trunk/drivers/video/console/fbcon.c +++ b/trunk/drivers/video/console/fbcon.c @@ -1881,7 +1881,7 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir, scr_memsetw((unsigned short *) (vc->vc_origin + vc->vc_size_row * (b - count)), - vc->vc_scrl_erase_char, + vc->vc_video_erase_char, vc->vc_size_row * count); return 1; break; @@ -1953,7 +1953,7 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir, scr_memsetw((unsigned short *) (vc->vc_origin + vc->vc_size_row * (b - count)), - vc->vc_scrl_erase_char, + vc->vc_video_erase_char, vc->vc_size_row * count); return 1; } @@ -1972,7 +1972,7 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir, scr_memsetw((unsigned short *) (vc->vc_origin + vc->vc_size_row * t), - vc->vc_scrl_erase_char, + vc->vc_video_erase_char, vc->vc_size_row * count); return 1; break; @@ -2042,7 +2042,7 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir, scr_memsetw((unsigned short *) (vc->vc_origin + vc->vc_size_row * t), - vc->vc_scrl_erase_char, + vc->vc_video_erase_char, vc->vc_size_row * count); return 1; } diff --git a/trunk/drivers/video/console/mdacon.c b/trunk/drivers/video/console/mdacon.c index 38a296bbdfc9..bd8d995fe25d 100644 --- a/trunk/drivers/video/console/mdacon.c +++ b/trunk/drivers/video/console/mdacon.c @@ -531,7 +531,7 @@ static void mdacon_cursor(struct vc_data *c, int mode) static int mdacon_scroll(struct vc_data *c, int t, int b, int dir, int lines) { - u16 eattr = mda_convert_attr(c->vc_scrl_erase_char); + u16 eattr = mda_convert_attr(c->vc_video_erase_char); if (!lines) return 0; diff --git a/trunk/drivers/video/console/sticon.c b/trunk/drivers/video/console/sticon.c index a11cc2fdd4cd..67a682d6cc7b 100644 --- a/trunk/drivers/video/console/sticon.c +++ b/trunk/drivers/video/console/sticon.c @@ -170,12 +170,12 @@ static int sticon_scroll(struct vc_data *conp, int t, int b, int dir, int count) switch (dir) { case SM_UP: sti_bmove(sti, t + count, 0, t, 0, b - t - count, conp->vc_cols); - sti_clear(sti, b - count, 0, count, conp->vc_cols, conp->vc_scrl_erase_char); + sti_clear(sti, b - count, 0, count, conp->vc_cols, conp->vc_video_erase_char); break; case SM_DOWN: sti_bmove(sti, t, 0, t + count, 0, b - t - count, conp->vc_cols); - sti_clear(sti, t, 0, count, conp->vc_cols, conp->vc_scrl_erase_char); + sti_clear(sti, t, 0, count, conp->vc_cols, conp->vc_video_erase_char); break; } diff --git a/trunk/drivers/video/console/vgacon.c b/trunk/drivers/video/console/vgacon.c index bd1f57b259d9..6df29a62d720 100644 --- a/trunk/drivers/video/console/vgacon.c +++ b/trunk/drivers/video/console/vgacon.c @@ -1350,7 +1350,7 @@ static int vgacon_scroll(struct vc_data *c, int t, int b, int dir, } else c->vc_origin += delta; scr_memsetw((u16 *) (c->vc_origin + c->vc_screenbuf_size - - delta), c->vc_scrl_erase_char, + delta), c->vc_video_erase_char, delta); } else { if (oldo - delta < vga_vram_base) { @@ -1363,7 +1363,7 @@ static int vgacon_scroll(struct vc_data *c, int t, int b, int dir, } else c->vc_origin -= delta; c->vc_scr_end = c->vc_origin + c->vc_screenbuf_size; - scr_memsetw((u16 *) (c->vc_origin), c->vc_scrl_erase_char, + scr_memsetw((u16 *) (c->vc_origin), c->vc_video_erase_char, delta); } c->vc_scr_end = c->vc_origin + c->vc_screenbuf_size; diff --git a/trunk/drivers/video/matrox/matroxfb_misc.c b/trunk/drivers/video/matrox/matroxfb_misc.c index 5b5f072fc1a8..aaa3e538e5da 100644 --- a/trunk/drivers/video/matrox/matroxfb_misc.c +++ b/trunk/drivers/video/matrox/matroxfb_misc.c @@ -522,6 +522,8 @@ static void parse_bios(unsigned char __iomem* vbios, struct matrox_bios* bd) { #endif } +#define get_u16(x) (le16_to_cpu(get_unaligned((__u16*)(x)))) +#define get_u32(x) (le32_to_cpu(get_unaligned((__u32*)(x)))) static int parse_pins1(WPMINFO const struct matrox_bios* bd) { unsigned int maxdac; @@ -530,12 +532,11 @@ static int parse_pins1(WPMINFO const struct matrox_bios* bd) { case 1: maxdac = 220000; break; default: maxdac = 240000; break; } - if (get_unaligned_le16(bd->pins + 24)) { - maxdac = get_unaligned_le16(bd->pins + 24) * 10; + if (get_u16(bd->pins + 24)) { + maxdac = get_u16(bd->pins + 24) * 10; } MINFO->limits.pixel.vcomax = maxdac; - MINFO->values.pll.system = get_unaligned_le16(bd->pins + 28) ? - get_unaligned_le16(bd->pins + 28) * 10 : 50000; + MINFO->values.pll.system = get_u16(bd->pins + 28) ? get_u16(bd->pins + 28) * 10 : 50000; /* ignore 4MB, 8MB, module clocks */ MINFO->features.pll.ref_freq = 14318; MINFO->values.reg.mctlwtst = 0x00030101; @@ -574,8 +575,7 @@ static void default_pins2(WPMINFO2) { static int parse_pins3(WPMINFO const struct matrox_bios* bd) { MINFO->limits.pixel.vcomax = MINFO->limits.system.vcomax = (bd->pins[36] == 0xFF) ? 230000 : ((bd->pins[36] + 100) * 1000); - MINFO->values.reg.mctlwtst = get_unaligned_le32(bd->pins + 48) == 0xFFFFFFFF ? - 0x01250A21 : get_unaligned_le32(bd->pins + 48); + MINFO->values.reg.mctlwtst = get_u32(bd->pins + 48) == 0xFFFFFFFF ? 0x01250A21 : get_u32(bd->pins + 48); /* memory config */ MINFO->values.reg.memrdbk = ((bd->pins[57] << 21) & 0x1E000000) | ((bd->pins[57] << 22) & 0x00C00000) | @@ -601,7 +601,7 @@ static void default_pins3(WPMINFO2) { static int parse_pins4(WPMINFO const struct matrox_bios* bd) { MINFO->limits.pixel.vcomax = (bd->pins[ 39] == 0xFF) ? 230000 : bd->pins[ 39] * 4000; MINFO->limits.system.vcomax = (bd->pins[ 38] == 0xFF) ? MINFO->limits.pixel.vcomax : bd->pins[ 38] * 4000; - MINFO->values.reg.mctlwtst = get_unaligned_le32(bd->pins + 71); + MINFO->values.reg.mctlwtst = get_u32(bd->pins + 71); MINFO->values.reg.memrdbk = ((bd->pins[87] << 21) & 0x1E000000) | ((bd->pins[87] << 22) & 0x00C00000) | ((bd->pins[86] << 1) & 0x000001E0) | @@ -609,7 +609,7 @@ static int parse_pins4(WPMINFO const struct matrox_bios* bd) { MINFO->values.reg.opt = ((bd->pins[53] << 15) & 0x00400000) | ((bd->pins[53] << 22) & 0x10000000) | ((bd->pins[53] << 7) & 0x00001C00); - MINFO->values.reg.opt3 = get_unaligned_le32(bd->pins + 67); + MINFO->values.reg.opt3 = get_u32(bd->pins + 67); MINFO->values.pll.system = (bd->pins[ 65] == 0xFF) ? 200000 : bd->pins[ 65] * 4000; MINFO->features.pll.ref_freq = (bd->pins[ 92] & 0x01) ? 14318 : 27000; return 0; @@ -640,12 +640,12 @@ static int parse_pins5(WPMINFO const struct matrox_bios* bd) { MINFO->limits.video.vcomin = (bd->pins[122] == 0xFF) ? MINFO->limits.system.vcomin : bd->pins[122] * mult; MINFO->values.pll.system = MINFO->values.pll.video = (bd->pins[ 92] == 0xFF) ? 284000 : bd->pins[ 92] * 4000; - MINFO->values.reg.opt = get_unaligned_le32(bd->pins + 48); - MINFO->values.reg.opt2 = get_unaligned_le32(bd->pins + 52); - MINFO->values.reg.opt3 = get_unaligned_le32(bd->pins + 94); - MINFO->values.reg.mctlwtst = get_unaligned_le32(bd->pins + 98); - MINFO->values.reg.memmisc = get_unaligned_le32(bd->pins + 102); - MINFO->values.reg.memrdbk = get_unaligned_le32(bd->pins + 106); + MINFO->values.reg.opt = get_u32(bd->pins+ 48); + MINFO->values.reg.opt2 = get_u32(bd->pins+ 52); + MINFO->values.reg.opt3 = get_u32(bd->pins+ 94); + MINFO->values.reg.mctlwtst = get_u32(bd->pins+ 98); + MINFO->values.reg.memmisc = get_u32(bd->pins+102); + MINFO->values.reg.memrdbk = get_u32(bd->pins+106); MINFO->features.pll.ref_freq = (bd->pins[110] & 0x01) ? 14318 : 27000; MINFO->values.memory.ddr = (bd->pins[114] & 0x60) == 0x20; MINFO->values.memory.dll = (bd->pins[115] & 0x02) != 0; diff --git a/trunk/drivers/video/metronomefb.c b/trunk/drivers/video/metronomefb.c index cc4c038a1b3f..249791286367 100644 --- a/trunk/drivers/video/metronomefb.c +++ b/trunk/drivers/video/metronomefb.c @@ -206,7 +206,8 @@ static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t, } /* check waveform mode table address checksum */ - wmta = get_unaligned_le32(wfm_hdr->wmta) & 0x00FFFFFF; + wmta = le32_to_cpu(get_unaligned((__le32 *) wfm_hdr->wmta)); + wmta &= 0x00FFFFFF; cksum_idx = wmta + m*4 + 3; if (cksum_idx > size) return -EINVAL; @@ -218,7 +219,8 @@ static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t, } /* check waveform temperature table address checksum */ - tta = get_unaligned_le32(mem + wmta + m * 4) & 0x00FFFFFF; + tta = le32_to_cpu(get_unaligned((int *) (mem + wmta + m*4))); + tta &= 0x00FFFFFF; cksum_idx = tta + trn*4 + 3; if (cksum_idx > size) return -EINVAL; @@ -231,7 +233,8 @@ static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t, /* here we do the real work of putting the waveform into the metromem buffer. this does runlength decoding of the waveform */ - wfm_idx = get_unaligned_le32(mem + tta + trn * 4) & 0x00FFFFFF; + wfm_idx = le32_to_cpu(get_unaligned((__le32 *) (mem + tta + trn*4))); + wfm_idx &= 0x00FFFFFF; owfm_idx = wfm_idx; if (wfm_idx > size) return -EINVAL; diff --git a/trunk/drivers/zorro/proc.c b/trunk/drivers/zorro/proc.c index 099b6fb5b5cb..2ce4cebc31d9 100644 --- a/trunk/drivers/zorro/proc.c +++ b/trunk/drivers/zorro/proc.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -77,58 +76,36 @@ proc_bus_zorro_read(struct file *file, char __user *buf, size_t nbytes, loff_t * } static const struct file_operations proc_bus_zorro_operations = { - .owner = THIS_MODULE, .llseek = proc_bus_zorro_lseek, .read = proc_bus_zorro_read, }; -static void * zorro_seq_start(struct seq_file *m, loff_t *pos) +static int +get_zorro_dev_info(char *buf, char **start, off_t pos, int count) { - return (*pos < zorro_num_autocon) ? pos : NULL; -} - -static void * zorro_seq_next(struct seq_file *m, void *v, loff_t *pos) -{ - (*pos)++; - return (*pos < zorro_num_autocon) ? pos : NULL; -} - -static void zorro_seq_stop(struct seq_file *m, void *v) -{ -} - -static int zorro_seq_show(struct seq_file *m, void *v) -{ - u_int slot = *(loff_t *)v; - struct zorro_dev *z = &zorro_autocon[slot]; - - seq_printf(m, "%02x\t%08x\t%08lx\t%08lx\t%02x\n", slot, z->id, - (unsigned long)zorro_resource_start(z), - (unsigned long)zorro_resource_len(z), - z->rom.er_Type); - return 0; -} - -static const struct seq_operations zorro_devices_seq_ops = { - .start = zorro_seq_start, - .next = zorro_seq_next, - .stop = zorro_seq_stop, - .show = zorro_seq_show, -}; - -static int zorro_devices_proc_open(struct inode *inode, struct file *file) -{ - return seq_open(file, &zorro_devices_seq_ops); + u_int slot; + off_t at = 0; + int len, cnt; + + for (slot = cnt = 0; slot < zorro_num_autocon && count > cnt; slot++) { + struct zorro_dev *z = &zorro_autocon[slot]; + len = sprintf(buf, "%02x\t%08x\t%08lx\t%08lx\t%02x\n", slot, + z->id, (unsigned long)zorro_resource_start(z), + (unsigned long)zorro_resource_len(z), + z->rom.er_Type); + at += len; + if (at >= pos) { + if (!*start) { + *start = buf + (pos - (at - len)); + cnt = at - pos; + } else + cnt += len; + buf += len; + } + } + return (count > cnt) ? cnt : count; } -static const struct file_operations zorro_devices_proc_fops = { - .owner = THIS_MODULE, - .open = zorro_devices_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release, -}; - static struct proc_dir_entry *proc_bus_zorro_dir; static int __init zorro_proc_attach_device(u_int slot) @@ -137,11 +114,11 @@ static int __init zorro_proc_attach_device(u_int slot) char name[4]; sprintf(name, "%02x", slot); - entry = proc_create_data(name, 0, proc_bus_zorro_dir, - &proc_bus_zorro_operations, - &zorro_autocon[slot]); + entry = create_proc_entry(name, 0, proc_bus_zorro_dir); if (!entry) return -ENOMEM; + entry->proc_fops = &proc_bus_zorro_operations; + entry->data = &zorro_autocon[slot]; entry->size = sizeof(struct zorro_dev); return 0; } @@ -151,9 +128,9 @@ static int __init zorro_proc_init(void) u_int slot; if (MACH_IS_AMIGA && AMIGAHW_PRESENT(ZORRO)) { - proc_bus_zorro_dir = proc_mkdir("bus/zorro", NULL); - proc_create("devices", 0, proc_bus_zorro_dir, - &zorro_devices_proc_fops); + proc_bus_zorro_dir = proc_mkdir("zorro", proc_bus); + create_proc_info_entry("devices", 0, proc_bus_zorro_dir, + get_zorro_dev_info); for (slot = 0; slot < zorro_num_autocon; slot++) zorro_proc_attach_device(slot); } diff --git a/trunk/fs/Kconfig.binfmt b/trunk/fs/Kconfig.binfmt index 55e8ee1900a5..853845abcca6 100644 --- a/trunk/fs/Kconfig.binfmt +++ b/trunk/fs/Kconfig.binfmt @@ -41,7 +41,7 @@ config BINFMT_ELF_FDPIC It is also possible to run FDPIC ELF binaries on MMU linux also. config BINFMT_FLAT - bool "Kernel support for flat binaries" + tristate "Kernel support for flat binaries" depends on !MMU help Support uClinux FLAT format binaries. diff --git a/trunk/fs/adfs/dir_f.c b/trunk/fs/adfs/dir_f.c index ea7df2146921..b9b2b27b68c3 100644 --- a/trunk/fs/adfs/dir_f.c +++ b/trunk/fs/adfs/dir_f.c @@ -122,9 +122,9 @@ adfs_dir_checkbyte(const struct adfs_dir *dir) ptr.ptr8 = bufoff(bh, i); end.ptr8 = ptr.ptr8 + last - i; - do { + do dircheck = *ptr.ptr8++ ^ ror13(dircheck); - } while (ptr.ptr8 < end.ptr8); + while (ptr.ptr8 < end.ptr8); } /* diff --git a/trunk/fs/affs/file.c b/trunk/fs/affs/file.c index e87ede608f77..6e0c9399200e 100644 --- a/trunk/fs/affs/file.c +++ b/trunk/fs/affs/file.c @@ -325,7 +325,8 @@ affs_get_block(struct inode *inode, sector_t block, struct buffer_head *bh_resul pr_debug("AFFS: get_block(%u, %lu)\n", (u32)inode->i_ino, (unsigned long)block); - BUG_ON(block > (sector_t)0x7fffffffUL); + if (block > (sector_t)0x7fffffffUL) + BUG(); if (block >= AFFS_I(inode)->i_blkcnt) { if (block > AFFS_I(inode)->i_blkcnt || !create) @@ -492,7 +493,8 @@ affs_do_readpage_ofs(struct file *file, struct page *page, unsigned from, unsign u32 tmp; pr_debug("AFFS: read_page(%u, %ld, %d, %d)\n", (u32)inode->i_ino, page->index, from, to); - BUG_ON(from > to || to > PAGE_CACHE_SIZE); + if (from > to || to > PAGE_CACHE_SIZE) + BUG(); kmap(page); data = page_address(page); bsize = AFFS_SB(sb)->s_data_blksize; @@ -505,7 +507,8 @@ affs_do_readpage_ofs(struct file *file, struct page *page, unsigned from, unsign if (IS_ERR(bh)) return PTR_ERR(bh); tmp = min(bsize - boff, to - from); - BUG_ON(from + tmp > to || tmp > bsize); + if (from + tmp > to || tmp > bsize) + BUG(); memcpy(data + from, AFFS_DATA(bh) + boff, tmp); affs_brelse(bh); bidx++; @@ -537,7 +540,8 @@ affs_extent_file_ofs(struct inode *inode, u32 newsize) if (IS_ERR(bh)) return PTR_ERR(bh); tmp = min(bsize - boff, newsize - size); - BUG_ON(boff + tmp > bsize || tmp > bsize); + if (boff + tmp > bsize || tmp > bsize) + BUG(); memset(AFFS_DATA(bh) + boff, 0, tmp); AFFS_DATA_HEAD(bh)->size = cpu_to_be32(be32_to_cpu(AFFS_DATA_HEAD(bh)->size) + tmp); affs_fix_checksum(sb, bh); @@ -556,7 +560,8 @@ affs_extent_file_ofs(struct inode *inode, u32 newsize) if (IS_ERR(bh)) goto out; tmp = min(bsize, newsize - size); - BUG_ON(tmp > bsize); + if (tmp > bsize) + BUG(); AFFS_DATA_HEAD(bh)->ptype = cpu_to_be32(T_DATA); AFFS_DATA_HEAD(bh)->key = cpu_to_be32(inode->i_ino); AFFS_DATA_HEAD(bh)->sequence = cpu_to_be32(bidx); @@ -678,7 +683,8 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping, if (IS_ERR(bh)) return PTR_ERR(bh); tmp = min(bsize - boff, to - from); - BUG_ON(boff + tmp > bsize || tmp > bsize); + if (boff + tmp > bsize || tmp > bsize) + BUG(); memcpy(AFFS_DATA(bh) + boff, data + from, tmp); AFFS_DATA_HEAD(bh)->size = cpu_to_be32(be32_to_cpu(AFFS_DATA_HEAD(bh)->size) + tmp); affs_fix_checksum(sb, bh); @@ -726,7 +732,8 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping, if (IS_ERR(bh)) goto out; tmp = min(bsize, to - from); - BUG_ON(tmp > bsize); + if (tmp > bsize) + BUG(); memcpy(AFFS_DATA(bh), data + from, tmp); if (buffer_new(bh)) { AFFS_DATA_HEAD(bh)->ptype = cpu_to_be32(T_DATA); diff --git a/trunk/fs/affs/super.c b/trunk/fs/affs/super.c index 01d25d532541..d2dc047cb479 100644 --- a/trunk/fs/affs/super.c +++ b/trunk/fs/affs/super.c @@ -199,6 +199,7 @@ parse_options(char *options, uid_t *uid, gid_t *gid, int *mode, int *reserved, s case Opt_prefix: /* Free any previous prefix */ kfree(*prefix); + *prefix = NULL; *prefix = match_strdup(&args[0]); if (!*prefix) return 0; @@ -232,8 +233,6 @@ parse_options(char *options, uid_t *uid, gid_t *gid, int *mode, int *reserved, s break; case Opt_volume: { char *vol = match_strdup(&args[0]); - if (!vol) - return 0; strlcpy(volume, vol, 32); kfree(vol); break; diff --git a/trunk/fs/afs/afs_cm.h b/trunk/fs/afs/afs_cm.h index 255f5dd6040c..7b4d4fab4c80 100644 --- a/trunk/fs/afs/afs_cm.h +++ b/trunk/fs/afs/afs_cm.h @@ -24,8 +24,7 @@ enum AFS_CM_Operations { CBGetXStatsVersion = 209, /* get version of extended statistics */ CBGetXStats = 210, /* get contents of extended statistics data */ CBInitCallBackState3 = 213, /* initialise callback state, version 3 */ - CBProbeUuid = 214, /* check the client hasn't rebooted */ - CBTellMeAboutYourself = 65538, /* get client capabilities */ + CBGetCapabilities = 65538, /* get client capabilities */ }; #define AFS_CAP_ERROR_TRANSLATION 0x1 diff --git a/trunk/fs/afs/cell.c b/trunk/fs/afs/cell.c index 5e1df14e16b1..584bb0f9c36a 100644 --- a/trunk/fs/afs/cell.c +++ b/trunk/fs/afs/cell.c @@ -20,7 +20,7 @@ DECLARE_RWSEM(afs_proc_cells_sem); LIST_HEAD(afs_proc_cells); -static LIST_HEAD(afs_cells); +static struct list_head afs_cells = LIST_HEAD_INIT(afs_cells); static DEFINE_RWLOCK(afs_cells_lock); static DECLARE_RWSEM(afs_cells_sem); /* add/remove serialisation */ static DECLARE_WAIT_QUEUE_HEAD(afs_cells_freeable_wq); diff --git a/trunk/fs/afs/cmservice.c b/trunk/fs/afs/cmservice.c index eb765489164f..47b71c8947f9 100644 --- a/trunk/fs/afs/cmservice.c +++ b/trunk/fs/afs/cmservice.c @@ -26,9 +26,8 @@ static int afs_deliver_cb_init_call_back_state3(struct afs_call *, struct sk_buff *, bool); static int afs_deliver_cb_probe(struct afs_call *, struct sk_buff *, bool); static int afs_deliver_cb_callback(struct afs_call *, struct sk_buff *, bool); -static int afs_deliver_cb_probe_uuid(struct afs_call *, struct sk_buff *, bool); -static int afs_deliver_cb_tell_me_about_yourself(struct afs_call *, - struct sk_buff *, bool); +static int afs_deliver_cb_get_capabilities(struct afs_call *, struct sk_buff *, + bool); static void afs_cm_destructor(struct afs_call *); /* @@ -72,21 +71,11 @@ static const struct afs_call_type afs_SRXCBProbe = { }; /* - * CB.ProbeUuid operation type + * CB.GetCapabilities operation type */ -static const struct afs_call_type afs_SRXCBProbeUuid = { - .name = "CB.ProbeUuid", - .deliver = afs_deliver_cb_probe_uuid, - .abort_to_error = afs_abort_to_error, - .destructor = afs_cm_destructor, -}; - -/* - * CB.TellMeAboutYourself operation type - */ -static const struct afs_call_type afs_SRXCBTellMeAboutYourself = { - .name = "CB.TellMeAboutYourself", - .deliver = afs_deliver_cb_tell_me_about_yourself, +static const struct afs_call_type afs_SRXCBGetCapabilites = { + .name = "CB.GetCapabilities", + .deliver = afs_deliver_cb_get_capabilities, .abort_to_error = afs_abort_to_error, .destructor = afs_cm_destructor, }; @@ -114,8 +103,8 @@ bool afs_cm_incoming_call(struct afs_call *call) case CBProbe: call->type = &afs_SRXCBProbe; return true; - case CBTellMeAboutYourself: - call->type = &afs_SRXCBTellMeAboutYourself; + case CBGetCapabilities: + call->type = &afs_SRXCBGetCapabilites; return true; default: return false; @@ -403,106 +392,10 @@ static int afs_deliver_cb_probe(struct afs_call *call, struct sk_buff *skb, return 0; } -/* - * allow the fileserver to quickly find out if the fileserver has been rebooted - */ -static void SRXAFSCB_ProbeUuid(struct work_struct *work) -{ - struct afs_call *call = container_of(work, struct afs_call, work); - struct afs_uuid *r = call->request; - - struct { - __be32 match; - } reply; - - _enter(""); - - - if (memcmp(r, &afs_uuid, sizeof(afs_uuid)) == 0) - reply.match = htonl(0); - else - reply.match = htonl(1); - - afs_send_simple_reply(call, &reply, sizeof(reply)); - _leave(""); -} - -/* - * deliver request data to a CB.ProbeUuid call - */ -static int afs_deliver_cb_probe_uuid(struct afs_call *call, struct sk_buff *skb, - bool last) -{ - struct afs_uuid *r; - unsigned loop; - __be32 *b; - int ret; - - _enter("{%u},{%u},%d", call->unmarshall, skb->len, last); - - if (skb->len > 0) - return -EBADMSG; - if (!last) - return 0; - - switch (call->unmarshall) { - case 0: - call->offset = 0; - call->buffer = kmalloc(11 * sizeof(__be32), GFP_KERNEL); - if (!call->buffer) - return -ENOMEM; - call->unmarshall++; - - case 1: - _debug("extract UUID"); - ret = afs_extract_data(call, skb, last, call->buffer, - 11 * sizeof(__be32)); - switch (ret) { - case 0: break; - case -EAGAIN: return 0; - default: return ret; - } - - _debug("unmarshall UUID"); - call->request = kmalloc(sizeof(struct afs_uuid), GFP_KERNEL); - if (!call->request) - return -ENOMEM; - - b = call->buffer; - r = call->request; - r->time_low = ntohl(b[0]); - r->time_mid = ntohl(b[1]); - r->time_hi_and_version = ntohl(b[2]); - r->clock_seq_hi_and_reserved = ntohl(b[3]); - r->clock_seq_low = ntohl(b[4]); - - for (loop = 0; loop < 6; loop++) - r->node[loop] = ntohl(b[loop + 5]); - - call->offset = 0; - call->unmarshall++; - - case 2: - _debug("trailer"); - if (skb->len != 0) - return -EBADMSG; - break; - } - - if (!last) - return 0; - - call->state = AFS_CALL_REPLYING; - - INIT_WORK(&call->work, SRXAFSCB_ProbeUuid); - schedule_work(&call->work); - return 0; -} - /* * allow the fileserver to ask about the cache manager's capabilities */ -static void SRXAFSCB_TellMeAboutYourself(struct work_struct *work) +static void SRXAFSCB_GetCapabilities(struct work_struct *work) { struct afs_interface *ifs; struct afs_call *call = container_of(work, struct afs_call, work); @@ -563,10 +456,10 @@ static void SRXAFSCB_TellMeAboutYourself(struct work_struct *work) } /* - * deliver request data to a CB.TellMeAboutYourself call + * deliver request data to a CB.GetCapabilities call */ -static int afs_deliver_cb_tell_me_about_yourself(struct afs_call *call, - struct sk_buff *skb, bool last) +static int afs_deliver_cb_get_capabilities(struct afs_call *call, + struct sk_buff *skb, bool last) { _enter(",{%u},%d", skb->len, last); @@ -578,7 +471,7 @@ static int afs_deliver_cb_tell_me_about_yourself(struct afs_call *call, /* no unmarshalling required */ call->state = AFS_CALL_REPLYING; - INIT_WORK(&call->work, SRXAFSCB_TellMeAboutYourself); + INIT_WORK(&call->work, SRXAFSCB_GetCapabilities); schedule_work(&call->work); return 0; } diff --git a/trunk/fs/afs/proc.c b/trunk/fs/afs/proc.c index 9f7d1ae70269..846c7615ac9e 100644 --- a/trunk/fs/afs/proc.c +++ b/trunk/fs/afs/proc.c @@ -41,7 +41,6 @@ static const struct file_operations afs_proc_cells_fops = { .write = afs_proc_cells_write, .llseek = seq_lseek, .release = seq_release, - .owner = THIS_MODULE, }; static int afs_proc_rootcell_open(struct inode *inode, struct file *file); @@ -57,8 +56,7 @@ static const struct file_operations afs_proc_rootcell_fops = { .read = afs_proc_rootcell_read, .write = afs_proc_rootcell_write, .llseek = no_llseek, - .release = afs_proc_rootcell_release, - .owner = THIS_MODULE, + .release = afs_proc_rootcell_release }; static int afs_proc_cell_volumes_open(struct inode *inode, struct file *file); @@ -82,7 +80,6 @@ static const struct file_operations afs_proc_cell_volumes_fops = { .read = seq_read, .llseek = seq_lseek, .release = afs_proc_cell_volumes_release, - .owner = THIS_MODULE, }; static int afs_proc_cell_vlservers_open(struct inode *inode, @@ -107,7 +104,6 @@ static const struct file_operations afs_proc_cell_vlservers_fops = { .read = seq_read, .llseek = seq_lseek, .release = afs_proc_cell_vlservers_release, - .owner = THIS_MODULE, }; static int afs_proc_cell_servers_open(struct inode *inode, struct file *file); @@ -131,7 +127,6 @@ static const struct file_operations afs_proc_cell_servers_fops = { .read = seq_read, .llseek = seq_lseek, .release = afs_proc_cell_servers_release, - .owner = THIS_MODULE, }; /* @@ -148,13 +143,17 @@ int afs_proc_init(void) goto error_dir; proc_afs->owner = THIS_MODULE; - p = proc_create("cells", 0, proc_afs, &afs_proc_cells_fops); + p = create_proc_entry("cells", 0, proc_afs); if (!p) goto error_cells; + p->proc_fops = &afs_proc_cells_fops; + p->owner = THIS_MODULE; - p = proc_create("rootcell", 0, proc_afs, &afs_proc_rootcell_fops); + p = create_proc_entry("rootcell", 0, proc_afs); if (!p) goto error_rootcell; + p->proc_fops = &afs_proc_rootcell_fops; + p->owner = THIS_MODULE; _leave(" = 0"); return 0; @@ -396,20 +395,26 @@ int afs_proc_cell_setup(struct afs_cell *cell) if (!cell->proc_dir) goto error_dir; - p = proc_create_data("servers", 0, cell->proc_dir, - &afs_proc_cell_servers_fops, cell); + p = create_proc_entry("servers", 0, cell->proc_dir); if (!p) goto error_servers; + p->proc_fops = &afs_proc_cell_servers_fops; + p->owner = THIS_MODULE; + p->data = cell; - p = proc_create_data("vlservers", 0, cell->proc_dir, - &afs_proc_cell_vlservers_fops, cell); + p = create_proc_entry("vlservers", 0, cell->proc_dir); if (!p) goto error_vlservers; + p->proc_fops = &afs_proc_cell_vlservers_fops; + p->owner = THIS_MODULE; + p->data = cell; - p = proc_create_data("volumes", 0, cell->proc_dir, - &afs_proc_cell_volumes_fops, cell); + p = create_proc_entry("volumes", 0, cell->proc_dir); if (!p) goto error_volumes; + p->proc_fops = &afs_proc_cell_volumes_fops; + p->owner = THIS_MODULE; + p->data = cell; _leave(" = 0"); return 0; diff --git a/trunk/fs/aio.c b/trunk/fs/aio.c index 99c2352906a0..ae94e1dea266 100644 --- a/trunk/fs/aio.c +++ b/trunk/fs/aio.c @@ -191,43 +191,6 @@ static int aio_setup_ring(struct kioctx *ctx) kunmap_atomic((void *)((unsigned long)__event & PAGE_MASK), km); \ } while(0) - -/* __put_ioctx - * Called when the last user of an aio context has gone away, - * and the struct needs to be freed. - */ -static void __put_ioctx(struct kioctx *ctx) -{ - unsigned nr_events = ctx->max_reqs; - - BUG_ON(ctx->reqs_active); - - cancel_delayed_work(&ctx->wq); - cancel_work_sync(&ctx->wq.work); - aio_free_ring(ctx); - mmdrop(ctx->mm); - ctx->mm = NULL; - pr_debug("__put_ioctx: freeing %p\n", ctx); - kmem_cache_free(kioctx_cachep, ctx); - - if (nr_events) { - spin_lock(&aio_nr_lock); - BUG_ON(aio_nr - nr_events > aio_nr); - aio_nr -= nr_events; - spin_unlock(&aio_nr_lock); - } -} - -#define get_ioctx(kioctx) do { \ - BUG_ON(atomic_read(&(kioctx)->users) <= 0); \ - atomic_inc(&(kioctx)->users); \ -} while (0) -#define put_ioctx(kioctx) do { \ - BUG_ON(atomic_read(&(kioctx)->users) <= 0); \ - if (unlikely(atomic_dec_and_test(&(kioctx)->users))) \ - __put_ioctx(kioctx); \ -} while (0) - /* ioctx_alloc * Allocates and initializes an ioctx. Returns an ERR_PTR if it failed. */ @@ -277,7 +240,7 @@ static struct kioctx *ioctx_alloc(unsigned nr_events) if (ctx->max_reqs == 0) goto out_cleanup; - /* now link into global list. */ + /* now link into global list. kludge. FIXME */ write_lock(&mm->ioctx_list_lock); ctx->next = mm->ioctx_list; mm->ioctx_list = ctx; @@ -398,6 +361,32 @@ void exit_aio(struct mm_struct *mm) } } +/* __put_ioctx + * Called when the last user of an aio context has gone away, + * and the struct needs to be freed. + */ +void __put_ioctx(struct kioctx *ctx) +{ + unsigned nr_events = ctx->max_reqs; + + BUG_ON(ctx->reqs_active); + + cancel_delayed_work(&ctx->wq); + cancel_work_sync(&ctx->wq.work); + aio_free_ring(ctx); + mmdrop(ctx->mm); + ctx->mm = NULL; + pr_debug("__put_ioctx: freeing %p\n", ctx); + kmem_cache_free(kioctx_cachep, ctx); + + if (nr_events) { + spin_lock(&aio_nr_lock); + BUG_ON(aio_nr - nr_events > aio_nr); + aio_nr -= nr_events; + spin_unlock(&aio_nr_lock); + } +} + /* aio_get_req * Allocate a slot for an aio request. Increments the users count * of the kioctx so that the kioctx stays around until all requests are @@ -553,7 +542,10 @@ int aio_put_req(struct kiocb *req) return ret; } -static struct kioctx *lookup_ioctx(unsigned long ctx_id) +/* Lookup an ioctx id. ioctx_list is lockless for reads. + * FIXME: this is O(n) and is only suitable for development. + */ +struct kioctx *lookup_ioctx(unsigned long ctx_id) { struct kioctx *ioctx; struct mm_struct *mm; @@ -1560,7 +1552,7 @@ static int aio_wake_function(wait_queue_t *wait, unsigned mode, return 1; } -static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb, +int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb, struct iocb *iocb) { struct kiocb *req; @@ -1601,7 +1593,7 @@ static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb, * event using the eventfd_signal() function. */ req->ki_eventfd = eventfd_fget((int) iocb->aio_resfd); - if (IS_ERR(req->ki_eventfd)) { + if (unlikely(IS_ERR(req->ki_eventfd))) { ret = PTR_ERR(req->ki_eventfd); goto out_put_req; } diff --git a/trunk/fs/autofs4/root.c b/trunk/fs/autofs4/root.c index aa4c5ff8a40d..a54a946a50ae 100644 --- a/trunk/fs/autofs4/root.c +++ b/trunk/fs/autofs4/root.c @@ -533,9 +533,9 @@ static struct dentry *autofs4_lookup_unhashed(struct autofs_sb_info *sbi, struct goto next; if (d_unhashed(dentry)) { + struct autofs_info *ino = autofs4_dentry_ino(dentry); struct inode *inode = dentry->d_inode; - ino = autofs4_dentry_ino(dentry); list_del_init(&ino->rehash); dget(dentry); /* diff --git a/trunk/fs/befs/linuxvfs.c b/trunk/fs/befs/linuxvfs.c index e8717de3bab3..82123ff3e1dd 100644 --- a/trunk/fs/befs/linuxvfs.c +++ b/trunk/fs/befs/linuxvfs.c @@ -489,9 +489,9 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p) { befs_inode_info *befs_ino = BEFS_I(dentry->d_inode); if (befs_ino->i_flags & BEFS_LONG_SYMLINK) { - char *link = nd_get_link(nd); - if (!IS_ERR(link)) - kfree(link); + char *p = nd_get_link(nd); + if (!IS_ERR(p)) + kfree(p); } } diff --git a/trunk/fs/binfmt_aout.c b/trunk/fs/binfmt_aout.c index ba4cddb92f1d..a1bb2244cac7 100644 --- a/trunk/fs/binfmt_aout.c +++ b/trunk/fs/binfmt_aout.c @@ -372,17 +372,21 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs) flush_icache_range(text_addr, text_addr+ex.a_text+ex.a_data); } else { + static unsigned long error_time, error_time2; if ((ex.a_text & 0xfff || ex.a_data & 0xfff) && - (N_MAGIC(ex) != NMAGIC) && printk_ratelimit()) + (N_MAGIC(ex) != NMAGIC) && (jiffies-error_time2) > 5*HZ) { printk(KERN_NOTICE "executable not page aligned\n"); + error_time2 = jiffies; } - if ((fd_offset & ~PAGE_MASK) != 0 && printk_ratelimit()) + if ((fd_offset & ~PAGE_MASK) != 0 && + (jiffies-error_time) > 5*HZ) { printk(KERN_WARNING "fd_offset is not page aligned. Please convert program: %s\n", bprm->file->f_path.dentry->d_name.name); + error_time = jiffies; } if (!bprm->file->f_op->mmap||((fd_offset & ~PAGE_MASK) != 0)) { @@ -491,13 +495,15 @@ static int load_aout_library(struct file *file) start_addr = ex.a_entry & 0xfffff000; if ((N_TXTOFF(ex) & ~PAGE_MASK) != 0) { + static unsigned long error_time; loff_t pos = N_TXTOFF(ex); - if (printk_ratelimit()) + if ((jiffies-error_time) > 5*HZ) { printk(KERN_WARNING "N_TXTOFF is not page aligned. Please convert library: %s\n", file->f_path.dentry->d_name.name); + error_time = jiffies; } down_write(¤t->mm->mmap_sem); do_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss); diff --git a/trunk/fs/binfmt_elf.c b/trunk/fs/binfmt_elf.c index b25707fee2cc..9924581df6f6 100644 --- a/trunk/fs/binfmt_elf.c +++ b/trunk/fs/binfmt_elf.c @@ -1255,23 +1255,26 @@ static int writenote(struct memelfnote *men, struct file *file, static void fill_elf_header(struct elfhdr *elf, int segs, u16 machine, u32 flags, u8 osabi) { - memset(elf, 0, sizeof(*elf)); - memcpy(elf->e_ident, ELFMAG, SELFMAG); elf->e_ident[EI_CLASS] = ELF_CLASS; elf->e_ident[EI_DATA] = ELF_DATA; elf->e_ident[EI_VERSION] = EV_CURRENT; elf->e_ident[EI_OSABI] = ELF_OSABI; + memset(elf->e_ident+EI_PAD, 0, EI_NIDENT-EI_PAD); elf->e_type = ET_CORE; elf->e_machine = machine; elf->e_version = EV_CURRENT; + elf->e_entry = 0; elf->e_phoff = sizeof(struct elfhdr); + elf->e_shoff = 0; elf->e_flags = flags; elf->e_ehsize = sizeof(struct elfhdr); elf->e_phentsize = sizeof(struct elf_phdr); elf->e_phnum = segs; - + elf->e_shentsize = 0; + elf->e_shnum = 0; + elf->e_shstrndx = 0; return; } @@ -1722,25 +1725,26 @@ static int fill_note_info(struct elfhdr *elf, int phdrs, info->thread_status_size = 0; if (signr) { - struct elf_thread_status *ets; + struct elf_thread_status *tmp; rcu_read_lock(); do_each_thread(g, p) if (current->mm == p->mm && current != p) { - ets = kzalloc(sizeof(*ets), GFP_ATOMIC); - if (!ets) { + tmp = kzalloc(sizeof(*tmp), GFP_ATOMIC); + if (!tmp) { rcu_read_unlock(); return 0; } - ets->thread = p; - list_add(&ets->list, &info->thread_list); + tmp->thread = p; + list_add(&tmp->list, &info->thread_list); } while_each_thread(g, p); rcu_read_unlock(); list_for_each(t, &info->thread_list) { + struct elf_thread_status *tmp; int sz; - ets = list_entry(t, struct elf_thread_status, list); - sz = elf_dump_thread_status(signr, ets); + tmp = list_entry(t, struct elf_thread_status, list); + sz = elf_dump_thread_status(signr, tmp); info->thread_status_size += sz; } } @@ -1996,10 +2000,10 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, un for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) { struct page *page; - struct vm_area_struct *tmp_vma; + struct vm_area_struct *vma; if (get_user_pages(current, current->mm, addr, 1, 0, 1, - &page, &tmp_vma) <= 0) { + &page, &vma) <= 0) { DUMP_SEEK(PAGE_SIZE); } else { if (page == ZERO_PAGE(0)) { @@ -2009,7 +2013,7 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, un } } else { void *kaddr; - flush_cache_page(tmp_vma, addr, + flush_cache_page(vma, addr, page_to_pfn(page)); kaddr = kmap(page); if ((size += PAGE_SIZE) > limit || diff --git a/trunk/fs/binfmt_elf_fdpic.c b/trunk/fs/binfmt_elf_fdpic.c index ddd35d873391..32649f2a1654 100644 --- a/trunk/fs/binfmt_elf_fdpic.c +++ b/trunk/fs/binfmt_elf_fdpic.c @@ -136,8 +136,8 @@ static int elf_fdpic_fetch_phdrs(struct elf_fdpic_params *params, retval = kernel_read(file, params->hdr.e_phoff, (char *) params->phdrs, size); - if (unlikely(retval != size)) - return retval < 0 ? retval : -ENOEXEC; + if (retval < 0) + return retval; /* determine stack size for this binary */ phdr = params->phdrs; @@ -218,11 +218,8 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm, phdr->p_offset, interpreter_name, phdr->p_filesz); - if (unlikely(retval != phdr->p_filesz)) { - if (retval >= 0) - retval = -ENOEXEC; + if (retval < 0) goto error; - } retval = -ENOENT; if (interpreter_name[phdr->p_filesz - 1] != '\0') @@ -248,11 +245,8 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm, retval = kernel_read(interpreter, 0, bprm->buf, BINPRM_BUF_SIZE); - if (unlikely(retval != BINPRM_BUF_SIZE)) { - if (retval >= 0) - retval = -ENOEXEC; + if (retval < 0) goto error; - } interp_params.hdr = *((struct elfhdr *) bprm->buf); break; diff --git a/trunk/fs/binfmt_em86.c b/trunk/fs/binfmt_em86.c index f9c88d0c8ced..f95ae9789c91 100644 --- a/trunk/fs/binfmt_em86.c +++ b/trunk/fs/binfmt_em86.c @@ -43,7 +43,7 @@ static int load_em86(struct linux_binprm *bprm,struct pt_regs *regs) return -ENOEXEC; } - bprm->sh_bang = 1; /* Well, the bang-shell is implicit... */ + bprm->sh_bang++; /* Well, the bang-shell is implicit... */ allow_write_access(bprm->file); fput(bprm->file); bprm->file = NULL; diff --git a/trunk/fs/binfmt_flat.c b/trunk/fs/binfmt_flat.c index 3b40d45a3a16..0498b181dd52 100644 --- a/trunk/fs/binfmt_flat.c +++ b/trunk/fs/binfmt_flat.c @@ -531,8 +531,7 @@ static int load_flat_file(struct linux_binprm * bprm, DBG_FLT("BINFMT_FLAT: ROM mapping of file (we hope)\n"); down_write(¤t->mm->mmap_sem); - textpos = do_mmap(bprm->file, 0, text_len, PROT_READ|PROT_EXEC, - MAP_PRIVATE|MAP_EXECUTABLE, 0); + textpos = do_mmap(bprm->file, 0, text_len, PROT_READ|PROT_EXEC, MAP_PRIVATE, 0); up_write(¤t->mm->mmap_sem); if (!textpos || textpos >= (unsigned long) -4096) { if (!textpos) @@ -933,8 +932,14 @@ static int __init init_flat_binfmt(void) return register_binfmt(&flat_format); } +static void __exit exit_flat_binfmt(void) +{ + unregister_binfmt(&flat_format); +} + /****************************************************************************/ core_initcall(init_flat_binfmt); +module_exit(exit_flat_binfmt); /****************************************************************************/ diff --git a/trunk/fs/binfmt_misc.c b/trunk/fs/binfmt_misc.c index 7191306367c5..dbf0ac0523de 100644 --- a/trunk/fs/binfmt_misc.c +++ b/trunk/fs/binfmt_misc.c @@ -115,12 +115,6 @@ static int load_misc_binary(struct linux_binprm *bprm, struct pt_regs *regs) if (!enabled) goto _ret; - retval = -ENOEXEC; - if (bprm->misc_bang) - goto _ret; - - bprm->misc_bang = 1; - /* to keep locking time low, we copy the interpreter string */ read_lock(&entries_lock); fmt = check_file(bprm); diff --git a/trunk/fs/binfmt_script.c b/trunk/fs/binfmt_script.c index 9e3963f7ebf1..ab33939b12a7 100644 --- a/trunk/fs/binfmt_script.c +++ b/trunk/fs/binfmt_script.c @@ -29,7 +29,7 @@ static int load_script(struct linux_binprm *bprm,struct pt_regs *regs) * Sorta complicated, but hopefully it will work. -TYT */ - bprm->sh_bang = 1; + bprm->sh_bang++; allow_write_access(bprm->file); fput(bprm->file); bprm->file = NULL; diff --git a/trunk/fs/bio.c b/trunk/fs/bio.c index 799f86deff24..6e0b6f66df03 100644 --- a/trunk/fs/bio.c +++ b/trunk/fs/bio.c @@ -937,95 +937,6 @@ struct bio *bio_map_kern(struct request_queue *q, void *data, unsigned int len, return ERR_PTR(-EINVAL); } -static void bio_copy_kern_endio(struct bio *bio, int err) -{ - struct bio_vec *bvec; - const int read = bio_data_dir(bio) == READ; - char *p = bio->bi_private; - int i; - - __bio_for_each_segment(bvec, bio, i, 0) { - char *addr = page_address(bvec->bv_page); - - if (read && !err) - memcpy(p, addr, bvec->bv_len); - - __free_page(bvec->bv_page); - p += bvec->bv_len; - } - - bio_put(bio); -} - -/** - * bio_copy_kern - copy kernel address into bio - * @q: the struct request_queue for the bio - * @data: pointer to buffer to copy - * @len: length in bytes - * @gfp_mask: allocation flags for bio and page allocation - * - * copy the kernel address into a bio suitable for io to a block - * device. Returns an error pointer in case of error. - */ -struct bio *bio_copy_kern(struct request_queue *q, void *data, unsigned int len, - gfp_t gfp_mask, int reading) -{ - unsigned long kaddr = (unsigned long)data; - unsigned long end = (kaddr + len + PAGE_SIZE - 1) >> PAGE_SHIFT; - unsigned long start = kaddr >> PAGE_SHIFT; - const int nr_pages = end - start; - struct bio *bio; - struct bio_vec *bvec; - int i, ret; - - bio = bio_alloc(gfp_mask, nr_pages); - if (!bio) - return ERR_PTR(-ENOMEM); - - while (len) { - struct page *page; - unsigned int bytes = PAGE_SIZE; - - if (bytes > len) - bytes = len; - - page = alloc_page(q->bounce_gfp | gfp_mask); - if (!page) { - ret = -ENOMEM; - goto cleanup; - } - - if (bio_add_pc_page(q, bio, page, bytes, 0) < bytes) { - ret = -EINVAL; - goto cleanup; - } - - len -= bytes; - } - - if (!reading) { - void *p = data; - - bio_for_each_segment(bvec, bio, i) { - char *addr = page_address(bvec->bv_page); - - memcpy(addr, p, bvec->bv_len); - p += bvec->bv_len; - } - } - - bio->bi_private = data; - bio->bi_end_io = bio_copy_kern_endio; - return bio; -cleanup: - bio_for_each_segment(bvec, bio, i) - __free_page(bvec->bv_page); - - bio_put(bio); - - return ERR_PTR(ret); -} - /* * bio_set_pages_dirty() and bio_check_pages_dirty() are support functions * for performing direct-IO in BIOs. @@ -1362,7 +1273,6 @@ EXPORT_SYMBOL(bio_get_nr_vecs); EXPORT_SYMBOL(bio_map_user); EXPORT_SYMBOL(bio_unmap_user); EXPORT_SYMBOL(bio_map_kern); -EXPORT_SYMBOL(bio_copy_kern); EXPORT_SYMBOL(bio_pair_release); EXPORT_SYMBOL(bio_split); EXPORT_SYMBOL(bio_split_pool); diff --git a/trunk/fs/buffer.c b/trunk/fs/buffer.c index 189efa4efc6e..3db4a26adc44 100644 --- a/trunk/fs/buffer.c +++ b/trunk/fs/buffer.c @@ -2211,8 +2211,8 @@ int generic_cont_expand_simple(struct inode *inode, loff_t size) return err; } -static int cont_expand_zero(struct file *file, struct address_space *mapping, - loff_t pos, loff_t *bytes) +int cont_expand_zero(struct file *file, struct address_space *mapping, + loff_t pos, loff_t *bytes) { struct inode *inode = mapping->host; unsigned blocksize = 1 << inode->i_blkbits; @@ -2328,6 +2328,23 @@ int block_commit_write(struct page *page, unsigned from, unsigned to) return 0; } +int generic_commit_write(struct file *file, struct page *page, + unsigned from, unsigned to) +{ + struct inode *inode = page->mapping->host; + loff_t pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to; + __block_commit_write(inode,page,from,to); + /* + * No need to use i_size_read() here, the i_size + * cannot change under us because we hold i_mutex. + */ + if (pos > inode->i_size) { + i_size_write(inode, pos); + mark_inode_dirty(inode); + } + return 0; +} + /* * block_page_mkwrite() is not allowed to change the file size as it gets * called from a page fault handler when a page is first dirtied. Hence we must @@ -3298,6 +3315,7 @@ EXPORT_SYMBOL(end_buffer_write_sync); EXPORT_SYMBOL(file_fsync); EXPORT_SYMBOL(fsync_bdev); EXPORT_SYMBOL(generic_block_bmap); +EXPORT_SYMBOL(generic_commit_write); EXPORT_SYMBOL(generic_cont_expand_simple); EXPORT_SYMBOL(init_buffer); EXPORT_SYMBOL(invalidate_bdev); diff --git a/trunk/fs/char_dev.c b/trunk/fs/char_dev.c index 68e510b88457..038674aa88a7 100644 --- a/trunk/fs/char_dev.c +++ b/trunk/fs/char_dev.c @@ -55,6 +55,7 @@ static struct char_device_struct { unsigned int baseminor; int minorct; char name[64]; + struct file_operations *fops; struct cdev *cdev; /* will die */ } *chrdevs[CHRDEV_MAJOR_HASH_SIZE]; diff --git a/trunk/fs/cifs/cifs_debug.c b/trunk/fs/cifs/cifs_debug.c index cc950f69e51e..0228ed06069e 100644 --- a/trunk/fs/cifs/cifs_debug.c +++ b/trunk/fs/cifs/cifs_debug.c @@ -468,7 +468,7 @@ cifs_proc_init(void) { struct proc_dir_entry *pde; - proc_fs_cifs = proc_mkdir("fs/cifs", NULL); + proc_fs_cifs = proc_mkdir("cifs", proc_root_fs); if (proc_fs_cifs == NULL) return; @@ -559,7 +559,7 @@ cifs_proc_clean(void) remove_proc_entry("LinuxExtensionsEnabled", proc_fs_cifs); remove_proc_entry("Experimental", proc_fs_cifs); remove_proc_entry("LookupCacheEnabled", proc_fs_cifs); - remove_proc_entry("fs/cifs", NULL); + remove_proc_entry("cifs", proc_root_fs); } static int diff --git a/trunk/fs/coda/coda_linux.c b/trunk/fs/coda/coda_linux.c index e1c854890f94..95a54253c047 100644 --- a/trunk/fs/coda/coda_linux.c +++ b/trunk/fs/coda/coda_linux.c @@ -134,7 +134,7 @@ void coda_iattr_to_vattr(struct iattr *iattr, struct coda_vattr *vattr) unsigned int valid; /* clean out */ - vattr->va_mode = -1; + vattr->va_mode = (umode_t) -1; vattr->va_uid = (vuid_t) -1; vattr->va_gid = (vgid_t) -1; vattr->va_size = (off_t) -1; diff --git a/trunk/fs/coda/dir.c b/trunk/fs/coda/dir.c index 3d2580e00a3e..f89ff083079b 100644 --- a/trunk/fs/coda/dir.c +++ b/trunk/fs/coda/dir.c @@ -345,7 +345,7 @@ static int coda_symlink(struct inode *dir_inode, struct dentry *de, } /* destruction routines: unlink, rmdir */ -static int coda_unlink(struct inode *dir, struct dentry *de) +int coda_unlink(struct inode *dir, struct dentry *de) { int error; const char *name = de->d_name.name; @@ -365,7 +365,7 @@ static int coda_unlink(struct inode *dir, struct dentry *de) return 0; } -static int coda_rmdir(struct inode *dir, struct dentry *de) +int coda_rmdir(struct inode *dir, struct dentry *de) { const char *name = de->d_name.name; int len = de->d_name.len; @@ -424,7 +424,7 @@ static int coda_rename(struct inode *old_dir, struct dentry *old_dentry, /* file operations for directories */ -static int coda_readdir(struct file *coda_file, void *buf, filldir_t filldir) +int coda_readdir(struct file *coda_file, void *buf, filldir_t filldir) { struct coda_file_info *cfi; struct file *host_file; diff --git a/trunk/fs/drop_caches.c b/trunk/fs/drop_caches.c index 3e5637fc3779..59375efcf39d 100644 --- a/trunk/fs/drop_caches.c +++ b/trunk/fs/drop_caches.c @@ -14,26 +14,18 @@ int sysctl_drop_caches; static void drop_pagecache_sb(struct super_block *sb) { - struct inode *inode, *toput_inode = NULL; + struct inode *inode; spin_lock(&inode_lock); list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { if (inode->i_state & (I_FREEING|I_WILL_FREE)) continue; - if (inode->i_mapping->nrpages == 0) - continue; - __iget(inode); - spin_unlock(&inode_lock); __invalidate_mapping_pages(inode->i_mapping, 0, -1, true); - iput(toput_inode); - toput_inode = inode; - spin_lock(&inode_lock); } spin_unlock(&inode_lock); - iput(toput_inode); } -static void drop_pagecache(void) +void drop_pagecache(void) { struct super_block *sb; @@ -53,7 +45,7 @@ static void drop_pagecache(void) spin_unlock(&sb_lock); } -static void drop_slab(void) +void drop_slab(void) { int nr_objects; diff --git a/trunk/fs/ecryptfs/Makefile b/trunk/fs/ecryptfs/Makefile index 1e34a7fd4884..768857015516 100644 --- a/trunk/fs/ecryptfs/Makefile +++ b/trunk/fs/ecryptfs/Makefile @@ -4,4 +4,4 @@ obj-$(CONFIG_ECRYPT_FS) += ecryptfs.o -ecryptfs-objs := dentry.o file.o inode.o main.o super.o mmap.o read_write.o crypto.o keystore.o messaging.o netlink.o miscdev.o debug.o +ecryptfs-objs := dentry.o file.o inode.o main.o super.o mmap.o read_write.o crypto.o keystore.o messaging.o netlink.o debug.o diff --git a/trunk/fs/ecryptfs/crypto.c b/trunk/fs/ecryptfs/crypto.c index cd62d75b2cc0..a066e109ad9c 100644 --- a/trunk/fs/ecryptfs/crypto.c +++ b/trunk/fs/ecryptfs/crypto.c @@ -119,21 +119,21 @@ static int ecryptfs_calculate_md5(char *dst, if (rc) { printk(KERN_ERR "%s: Error initializing crypto hash; rc = [%d]\n", - __func__, rc); + __FUNCTION__, rc); goto out; } rc = crypto_hash_update(&desc, &sg, len); if (rc) { printk(KERN_ERR "%s: Error updating crypto hash; rc = [%d]\n", - __func__, rc); + __FUNCTION__, rc); goto out; } rc = crypto_hash_final(&desc, dst); if (rc) { printk(KERN_ERR "%s: Error finalizing crypto hash; rc = [%d]\n", - __func__, rc); + __FUNCTION__, rc); goto out; } out: @@ -437,7 +437,7 @@ static int ecryptfs_encrypt_extent(struct page *enc_extent_page, if (rc < 0) { printk(KERN_ERR "%s: Error attempting to encrypt page with " "page->index = [%ld], extent_offset = [%ld]; " - "rc = [%d]\n", __func__, page->index, extent_offset, + "rc = [%d]\n", __FUNCTION__, page->index, extent_offset, rc); goto out; } @@ -487,7 +487,7 @@ int ecryptfs_encrypt_page(struct page *page) 0, PAGE_CACHE_SIZE); if (rc) printk(KERN_ERR "%s: Error attempting to copy " - "page at index [%ld]\n", __func__, + "page at index [%ld]\n", __FUNCTION__, page->index); goto out; } @@ -508,7 +508,7 @@ int ecryptfs_encrypt_page(struct page *page) extent_offset); if (rc) { printk(KERN_ERR "%s: Error encrypting extent; " - "rc = [%d]\n", __func__, rc); + "rc = [%d]\n", __FUNCTION__, rc); goto out; } ecryptfs_lower_offset_for_extent( @@ -569,7 +569,7 @@ static int ecryptfs_decrypt_extent(struct page *page, if (rc < 0) { printk(KERN_ERR "%s: Error attempting to decrypt to page with " "page->index = [%ld], extent_offset = [%ld]; " - "rc = [%d]\n", __func__, page->index, extent_offset, + "rc = [%d]\n", __FUNCTION__, page->index, extent_offset, rc); goto out; } @@ -622,7 +622,7 @@ int ecryptfs_decrypt_page(struct page *page) ecryptfs_inode); if (rc) printk(KERN_ERR "%s: Error attempting to copy " - "page at index [%ld]\n", __func__, + "page at index [%ld]\n", __FUNCTION__, page->index); goto out; } @@ -656,7 +656,7 @@ int ecryptfs_decrypt_page(struct page *page) extent_offset); if (rc) { printk(KERN_ERR "%s: Error encrypting extent; " - "rc = [%d]\n", __func__, rc); + "rc = [%d]\n", __FUNCTION__, rc); goto out; } } @@ -1215,7 +1215,7 @@ int ecryptfs_read_and_validate_header_region(char *data, ecryptfs_inode); if (rc) { printk(KERN_ERR "%s: Error reading header region; rc = [%d]\n", - __func__, rc); + __FUNCTION__, rc); goto out; } if (!contains_ecryptfs_marker(data + ECRYPTFS_FILE_SIZE_BYTES)) { @@ -1246,6 +1246,7 @@ ecryptfs_write_header_metadata(char *virt, (*written) = 6; } +struct kmem_cache *ecryptfs_header_cache_0; struct kmem_cache *ecryptfs_header_cache_1; struct kmem_cache *ecryptfs_header_cache_2; @@ -1319,7 +1320,7 @@ ecryptfs_write_metadata_to_contents(struct ecryptfs_crypt_stat *crypt_stat, 0, crypt_stat->num_header_bytes_at_front); if (rc) printk(KERN_ERR "%s: Error attempting to write header " - "information to lower file; rc = [%d]\n", __func__, + "information to lower file; rc = [%d]\n", __FUNCTION__, rc); return rc; } @@ -1364,14 +1365,14 @@ int ecryptfs_write_metadata(struct dentry *ecryptfs_dentry) } } else { printk(KERN_WARNING "%s: Encrypted flag not set\n", - __func__); + __FUNCTION__); rc = -EINVAL; goto out; } /* Released in this function */ virt = kzalloc(crypt_stat->num_header_bytes_at_front, GFP_KERNEL); if (!virt) { - printk(KERN_ERR "%s: Out of memory\n", __func__); + printk(KERN_ERR "%s: Out of memory\n", __FUNCTION__); rc = -ENOMEM; goto out; } @@ -1379,7 +1380,7 @@ int ecryptfs_write_metadata(struct dentry *ecryptfs_dentry) ecryptfs_dentry); if (unlikely(rc)) { printk(KERN_ERR "%s: Error whilst writing headers; rc = [%d]\n", - __func__, rc); + __FUNCTION__, rc); goto out_free; } if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) @@ -1390,7 +1391,7 @@ int ecryptfs_write_metadata(struct dentry *ecryptfs_dentry) ecryptfs_dentry, virt); if (rc) { printk(KERN_ERR "%s: Error writing metadata out to lower file; " - "rc = [%d]\n", __func__, rc); + "rc = [%d]\n", __FUNCTION__, rc); goto out_free; } out_free: @@ -1584,7 +1585,7 @@ int ecryptfs_read_metadata(struct dentry *ecryptfs_dentry) if (!page_virt) { rc = -ENOMEM; printk(KERN_ERR "%s: Unable to allocate page_virt\n", - __func__); + __FUNCTION__); goto out; } rc = ecryptfs_read_lower(page_virt, 0, crypt_stat->extent_size, diff --git a/trunk/fs/ecryptfs/ecryptfs_kernel.h b/trunk/fs/ecryptfs/ecryptfs_kernel.h index 951ee33a022d..5007f788da01 100644 --- a/trunk/fs/ecryptfs/ecryptfs_kernel.h +++ b/trunk/fs/ecryptfs/ecryptfs_kernel.h @@ -4,7 +4,7 @@ * * Copyright (C) 1997-2003 Erez Zadok * Copyright (C) 2001-2003 Stony Brook University - * Copyright (C) 2004-2008 International Business Machines Corp. + * Copyright (C) 2004-2007 International Business Machines Corp. * Author(s): Michael A. Halcrow * Trevor S. Highland * Tyler Hicks @@ -34,7 +34,6 @@ #include #include #include -#include /* Version verification for shared data structures w/ userspace */ #define ECRYPTFS_VERSION_MAJOR 0x00 @@ -50,13 +49,11 @@ #define ECRYPTFS_VERSIONING_POLICY 0x00000008 #define ECRYPTFS_VERSIONING_XATTR 0x00000010 #define ECRYPTFS_VERSIONING_MULTKEY 0x00000020 -#define ECRYPTFS_VERSIONING_DEVMISC 0x00000040 #define ECRYPTFS_VERSIONING_MASK (ECRYPTFS_VERSIONING_PASSPHRASE \ | ECRYPTFS_VERSIONING_PLAINTEXT_PASSTHROUGH \ | ECRYPTFS_VERSIONING_PUBKEY \ | ECRYPTFS_VERSIONING_XATTR \ - | ECRYPTFS_VERSIONING_MULTKEY \ - | ECRYPTFS_VERSIONING_DEVMISC) + | ECRYPTFS_VERSIONING_MULTKEY) #define ECRYPTFS_MAX_PASSWORD_LENGTH 64 #define ECRYPTFS_MAX_PASSPHRASE_BYTES ECRYPTFS_MAX_PASSWORD_LENGTH #define ECRYPTFS_SALT_SIZE 8 @@ -76,14 +73,17 @@ #define ECRYPTFS_DEFAULT_MSG_CTX_ELEMS 32 #define ECRYPTFS_DEFAULT_SEND_TIMEOUT HZ #define ECRYPTFS_MAX_MSG_CTX_TTL (HZ*3) +#define ECRYPTFS_NLMSG_HELO 100 +#define ECRYPTFS_NLMSG_QUIT 101 +#define ECRYPTFS_NLMSG_REQUEST 102 +#define ECRYPTFS_NLMSG_RESPONSE 103 #define ECRYPTFS_MAX_PKI_NAME_BYTES 16 #define ECRYPTFS_DEFAULT_NUM_USERS 4 #define ECRYPTFS_MAX_NUM_USERS 32768 #define ECRYPTFS_TRANSPORT_NETLINK 0 #define ECRYPTFS_TRANSPORT_CONNECTOR 1 #define ECRYPTFS_TRANSPORT_RELAYFS 2 -#define ECRYPTFS_TRANSPORT_MISCDEV 3 -#define ECRYPTFS_DEFAULT_TRANSPORT ECRYPTFS_TRANSPORT_MISCDEV +#define ECRYPTFS_DEFAULT_TRANSPORT ECRYPTFS_TRANSPORT_NETLINK #define ECRYPTFS_XATTR_NAME "user.ecryptfs" #define RFC2440_CIPHER_DES3_EDE 0x02 @@ -366,63 +366,32 @@ struct ecryptfs_auth_tok_list_item { }; struct ecryptfs_message { - /* Can never be greater than ecryptfs_message_buf_len */ - /* Used to find the parent msg_ctx */ - /* Inherits from msg_ctx->index */ u32 index; u32 data_len; u8 data[]; }; struct ecryptfs_msg_ctx { -#define ECRYPTFS_MSG_CTX_STATE_FREE 0x01 -#define ECRYPTFS_MSG_CTX_STATE_PENDING 0x02 -#define ECRYPTFS_MSG_CTX_STATE_DONE 0x03 -#define ECRYPTFS_MSG_CTX_STATE_NO_REPLY 0x04 - u8 state; -#define ECRYPTFS_MSG_HELO 100 -#define ECRYPTFS_MSG_QUIT 101 -#define ECRYPTFS_MSG_REQUEST 102 -#define ECRYPTFS_MSG_RESPONSE 103 - u8 type; - u32 index; - /* Counter converts to a sequence number. Each message sent - * out for which we expect a response has an associated - * sequence number. The response must have the same sequence - * number as the counter for the msg_stc for the message to be - * valid. */ - u32 counter; - size_t msg_size; +#define ECRYPTFS_MSG_CTX_STATE_FREE 0x0001 +#define ECRYPTFS_MSG_CTX_STATE_PENDING 0x0002 +#define ECRYPTFS_MSG_CTX_STATE_DONE 0x0003 + u32 state; + unsigned int index; + unsigned int counter; struct ecryptfs_message *msg; struct task_struct *task; struct list_head node; - struct list_head daemon_out_list; struct mutex mux; }; extern unsigned int ecryptfs_transport; -struct ecryptfs_daemon; - -struct ecryptfs_daemon { -#define ECRYPTFS_DAEMON_IN_READ 0x00000001 -#define ECRYPTFS_DAEMON_IN_POLL 0x00000002 -#define ECRYPTFS_DAEMON_ZOMBIE 0x00000004 -#define ECRYPTFS_DAEMON_MISCDEV_OPEN 0x00000008 - u32 flags; - u32 num_queued_msg_ctx; - struct pid *pid; - uid_t euid; - struct user_namespace *user_ns; - struct task_struct *task; - struct mutex mux; - struct list_head msg_ctx_out_queue; - wait_queue_head_t wait; - struct hlist_node euid_chain; +struct ecryptfs_daemon_id { + pid_t pid; + uid_t uid; + struct hlist_node id_chain; }; -extern struct mutex ecryptfs_daemon_hash_mux; - static inline struct ecryptfs_file_info * ecryptfs_file_to_private(struct file *file) { @@ -531,7 +500,7 @@ ecryptfs_set_dentry_lower_mnt(struct dentry *dentry, struct vfsmount *lower_mnt) } #define ecryptfs_printk(type, fmt, arg...) \ - __ecryptfs_printk(type "%s: " fmt, __func__, ## arg); + __ecryptfs_printk(type "%s: " fmt, __FUNCTION__, ## arg); void __ecryptfs_printk(const char *fmt, ...); extern const struct file_operations ecryptfs_main_fops; @@ -612,13 +581,10 @@ int ecryptfs_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags); int ecryptfs_read_xattr_region(char *page_virt, struct inode *ecryptfs_inode); -int ecryptfs_process_helo(unsigned int transport, uid_t euid, - struct user_namespace *user_ns, struct pid *pid); -int ecryptfs_process_quit(uid_t euid, struct user_namespace *user_ns, - struct pid *pid); -int ecryptfs_process_response(struct ecryptfs_message *msg, uid_t euid, - struct user_namespace *user_ns, struct pid *pid, - u32 seq); +int ecryptfs_process_helo(unsigned int transport, uid_t uid, pid_t pid); +int ecryptfs_process_quit(uid_t uid, pid_t pid); +int ecryptfs_process_response(struct ecryptfs_message *msg, uid_t uid, + pid_t pid, u32 seq); int ecryptfs_send_message(unsigned int transport, char *data, int data_len, struct ecryptfs_msg_ctx **msg_ctx); int ecryptfs_wait_for_response(struct ecryptfs_msg_ctx *msg_ctx, @@ -627,14 +593,14 @@ int ecryptfs_init_messaging(unsigned int transport); void ecryptfs_release_messaging(unsigned int transport); int ecryptfs_send_netlink(char *data, int data_len, - struct ecryptfs_msg_ctx *msg_ctx, u8 msg_type, - u16 msg_flags, struct pid *daemon_pid); + struct ecryptfs_msg_ctx *msg_ctx, u16 msg_type, + u16 msg_flags, pid_t daemon_pid); int ecryptfs_init_netlink(void); void ecryptfs_release_netlink(void); int ecryptfs_send_connector(char *data, int data_len, - struct ecryptfs_msg_ctx *msg_ctx, u8 msg_type, - u16 msg_flags, struct pid *daemon_pid); + struct ecryptfs_msg_ctx *msg_ctx, u16 msg_type, + u16 msg_flags, pid_t daemon_pid); int ecryptfs_init_connector(void); void ecryptfs_release_connector(void); void @@ -676,21 +642,5 @@ int ecryptfs_read_lower_page_segment(struct page *page_for_ecryptfs, size_t offset_in_page, size_t size, struct inode *ecryptfs_inode); struct page *ecryptfs_get_locked_page(struct file *file, loff_t index); -int ecryptfs_exorcise_daemon(struct ecryptfs_daemon *daemon); -int ecryptfs_find_daemon_by_euid(struct ecryptfs_daemon **daemon, uid_t euid, - struct user_namespace *user_ns); -int ecryptfs_parse_packet_length(unsigned char *data, size_t *size, - size_t *length_size); -int ecryptfs_write_packet_length(char *dest, size_t size, - size_t *packet_size_length); -int ecryptfs_init_ecryptfs_miscdev(void); -void ecryptfs_destroy_ecryptfs_miscdev(void); -int ecryptfs_send_miscdev(char *data, size_t data_size, - struct ecryptfs_msg_ctx *msg_ctx, u8 msg_type, - u16 msg_flags, struct ecryptfs_daemon *daemon); -void ecryptfs_msg_ctx_alloc_to_free(struct ecryptfs_msg_ctx *msg_ctx); -int -ecryptfs_spawn_daemon(struct ecryptfs_daemon **daemon, uid_t euid, - struct user_namespace *user_ns, struct pid *pid); #endif /* #ifndef ECRYPTFS_KERNEL_H */ diff --git a/trunk/fs/ecryptfs/file.c b/trunk/fs/ecryptfs/file.c index 2258b8f654a6..2b8f5ed4adea 100644 --- a/trunk/fs/ecryptfs/file.c +++ b/trunk/fs/ecryptfs/file.c @@ -195,9 +195,7 @@ static int ecryptfs_open(struct inode *inode, struct file *file) file, ecryptfs_inode_to_private(inode)->lower_file); if (S_ISDIR(ecryptfs_dentry->d_inode->i_mode)) { ecryptfs_printk(KERN_DEBUG, "This is a directory\n"); - mutex_lock(&crypt_stat->cs_mutex); crypt_stat->flags &= ~(ECRYPTFS_ENCRYPTED); - mutex_unlock(&crypt_stat->cs_mutex); rc = 0; goto out; } diff --git a/trunk/fs/ecryptfs/inode.c b/trunk/fs/ecryptfs/inode.c index 0a1397335a8e..e23861152101 100644 --- a/trunk/fs/ecryptfs/inode.c +++ b/trunk/fs/ecryptfs/inode.c @@ -111,7 +111,7 @@ ecryptfs_do_create(struct inode *directory_inode, lower_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry); lower_dir_dentry = lock_parent(lower_dentry); - if (IS_ERR(lower_dir_dentry)) { + if (unlikely(IS_ERR(lower_dir_dentry))) { ecryptfs_printk(KERN_ERR, "Error locking directory of " "dentry\n"); rc = PTR_ERR(lower_dir_dentry); @@ -121,7 +121,7 @@ ecryptfs_do_create(struct inode *directory_inode, ecryptfs_dentry, mode, nd); if (rc) { printk(KERN_ERR "%s: Failure to create dentry in lower fs; " - "rc = [%d]\n", __func__, rc); + "rc = [%d]\n", __FUNCTION__, rc); goto out_lock; } rc = ecryptfs_interpose(lower_dentry, ecryptfs_dentry, @@ -908,9 +908,7 @@ static int ecryptfs_setattr(struct dentry *dentry, struct iattr *ia) if (ia->ia_valid & (ATTR_KILL_SUID | ATTR_KILL_SGID)) ia->ia_valid &= ~ATTR_MODE; - mutex_lock(&lower_dentry->d_inode->i_mutex); rc = notify_change(lower_dentry, ia); - mutex_unlock(&lower_dentry->d_inode->i_mutex); out: fsstack_copy_attr_all(inode, lower_inode, NULL); return rc; diff --git a/trunk/fs/ecryptfs/keystore.c b/trunk/fs/ecryptfs/keystore.c index e82b457180be..682b1b2482c2 100644 --- a/trunk/fs/ecryptfs/keystore.c +++ b/trunk/fs/ecryptfs/keystore.c @@ -65,7 +65,7 @@ static int process_request_key_err(long err_code) } /** - * ecryptfs_parse_packet_length + * parse_packet_length * @data: Pointer to memory containing length at offset * @size: This function writes the decoded size to this memory * address; zero on error @@ -73,8 +73,8 @@ static int process_request_key_err(long err_code) * * Returns zero on success; non-zero on error */ -int ecryptfs_parse_packet_length(unsigned char *data, size_t *size, - size_t *length_size) +static int parse_packet_length(unsigned char *data, size_t *size, + size_t *length_size) { int rc = 0; @@ -105,7 +105,7 @@ int ecryptfs_parse_packet_length(unsigned char *data, size_t *size, } /** - * ecryptfs_write_packet_length + * write_packet_length * @dest: The byte array target into which to write the length. Must * have at least 5 bytes allocated. * @size: The length to write. @@ -114,8 +114,8 @@ int ecryptfs_parse_packet_length(unsigned char *data, size_t *size, * * Returns zero on success; non-zero on error. */ -int ecryptfs_write_packet_length(char *dest, size_t size, - size_t *packet_size_length) +static int write_packet_length(char *dest, size_t size, + size_t *packet_size_length) { int rc = 0; @@ -162,8 +162,8 @@ write_tag_64_packet(char *signature, struct ecryptfs_session_key *session_key, goto out; } message[i++] = ECRYPTFS_TAG_64_PACKET_TYPE; - rc = ecryptfs_write_packet_length(&message[i], ECRYPTFS_SIG_SIZE_HEX, - &packet_size_len); + rc = write_packet_length(&message[i], ECRYPTFS_SIG_SIZE_HEX, + &packet_size_len); if (rc) { ecryptfs_printk(KERN_ERR, "Error generating tag 64 packet " "header; cannot generate packet length\n"); @@ -172,9 +172,8 @@ write_tag_64_packet(char *signature, struct ecryptfs_session_key *session_key, i += packet_size_len; memcpy(&message[i], signature, ECRYPTFS_SIG_SIZE_HEX); i += ECRYPTFS_SIG_SIZE_HEX; - rc = ecryptfs_write_packet_length(&message[i], - session_key->encrypted_key_size, - &packet_size_len); + rc = write_packet_length(&message[i], session_key->encrypted_key_size, + &packet_size_len); if (rc) { ecryptfs_printk(KERN_ERR, "Error generating tag 64 packet " "header; cannot generate packet length\n"); @@ -226,7 +225,7 @@ parse_tag_65_packet(struct ecryptfs_session_key *session_key, u8 *cipher_code, rc = -EIO; goto out; } - rc = ecryptfs_parse_packet_length(&data[i], &m_size, &data_len); + rc = parse_packet_length(&data[i], &m_size, &data_len); if (rc) { ecryptfs_printk(KERN_WARNING, "Error parsing packet length; " "rc = [%d]\n", rc); @@ -305,8 +304,8 @@ write_tag_66_packet(char *signature, u8 cipher_code, goto out; } message[i++] = ECRYPTFS_TAG_66_PACKET_TYPE; - rc = ecryptfs_write_packet_length(&message[i], ECRYPTFS_SIG_SIZE_HEX, - &packet_size_len); + rc = write_packet_length(&message[i], ECRYPTFS_SIG_SIZE_HEX, + &packet_size_len); if (rc) { ecryptfs_printk(KERN_ERR, "Error generating tag 66 packet " "header; cannot generate packet length\n"); @@ -316,8 +315,8 @@ write_tag_66_packet(char *signature, u8 cipher_code, memcpy(&message[i], signature, ECRYPTFS_SIG_SIZE_HEX); i += ECRYPTFS_SIG_SIZE_HEX; /* The encrypted key includes 1 byte cipher code and 2 byte checksum */ - rc = ecryptfs_write_packet_length(&message[i], crypt_stat->key_size + 3, - &packet_size_len); + rc = write_packet_length(&message[i], crypt_stat->key_size + 3, + &packet_size_len); if (rc) { ecryptfs_printk(KERN_ERR, "Error generating tag 66 packet " "header; cannot generate packet length\n"); @@ -358,25 +357,20 @@ parse_tag_67_packet(struct ecryptfs_key_record *key_rec, /* verify that everything through the encrypted FEK size is present */ if (message_len < 4) { rc = -EIO; - printk(KERN_ERR "%s: message_len is [%Zd]; minimum acceptable " - "message length is [%d]\n", __func__, message_len, 4); goto out; } if (data[i++] != ECRYPTFS_TAG_67_PACKET_TYPE) { + ecryptfs_printk(KERN_ERR, "Type should be ECRYPTFS_TAG_67\n"); rc = -EIO; - printk(KERN_ERR "%s: Type should be ECRYPTFS_TAG_67\n", - __func__); goto out; } if (data[i++]) { + ecryptfs_printk(KERN_ERR, "Status indicator has non zero value" + " [%d]\n", data[i-1]); rc = -EIO; - printk(KERN_ERR "%s: Status indicator has non zero " - "value [%d]\n", __func__, data[i-1]); - goto out; } - rc = ecryptfs_parse_packet_length(&data[i], &key_rec->enc_key_size, - &data_len); + rc = parse_packet_length(&data[i], &key_rec->enc_key_size, &data_len); if (rc) { ecryptfs_printk(KERN_WARNING, "Error parsing packet length; " "rc = [%d]\n", rc); @@ -384,17 +378,17 @@ parse_tag_67_packet(struct ecryptfs_key_record *key_rec, } i += data_len; if (message_len < (i + key_rec->enc_key_size)) { + ecryptfs_printk(KERN_ERR, "message_len [%d]; max len is [%d]\n", + message_len, (i + key_rec->enc_key_size)); rc = -EIO; - printk(KERN_ERR "%s: message_len [%Zd]; max len is [%Zd]\n", - __func__, message_len, (i + key_rec->enc_key_size)); goto out; } if (key_rec->enc_key_size > ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES) { + ecryptfs_printk(KERN_ERR, "Encrypted key_size [%d] larger than " + "the maximum key size [%d]\n", + key_rec->enc_key_size, + ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES); rc = -EIO; - printk(KERN_ERR "%s: Encrypted key_size [%Zd] larger than " - "the maximum key size [%d]\n", __func__, - key_rec->enc_key_size, - ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES); goto out; } memcpy(key_rec->enc_key, &data[i], key_rec->enc_key_size); @@ -451,7 +445,7 @@ decrypt_pki_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok, rc = write_tag_64_packet(auth_tok_sig, &(auth_tok->session_key), &netlink_message, &netlink_message_length); if (rc) { - ecryptfs_printk(KERN_ERR, "Failed to write tag 64 packet\n"); + ecryptfs_printk(KERN_ERR, "Failed to write tag 64 packet"); goto out; } rc = ecryptfs_send_message(ecryptfs_transport, netlink_message, @@ -576,8 +570,8 @@ parse_tag_1_packet(struct ecryptfs_crypt_stat *crypt_stat, goto out; } (*new_auth_tok) = &auth_tok_list_item->auth_tok; - rc = ecryptfs_parse_packet_length(&data[(*packet_size)], &body_size, - &length_size); + rc = parse_packet_length(&data[(*packet_size)], &body_size, + &length_size); if (rc) { printk(KERN_WARNING "Error parsing packet length; " "rc = [%d]\n", rc); @@ -710,8 +704,8 @@ parse_tag_3_packet(struct ecryptfs_crypt_stat *crypt_stat, goto out; } (*new_auth_tok) = &auth_tok_list_item->auth_tok; - rc = ecryptfs_parse_packet_length(&data[(*packet_size)], &body_size, - &length_size); + rc = parse_packet_length(&data[(*packet_size)], &body_size, + &length_size); if (rc) { printk(KERN_WARNING "Error parsing packet length; rc = [%d]\n", rc); @@ -858,8 +852,8 @@ parse_tag_11_packet(unsigned char *data, unsigned char *contents, rc = -EINVAL; goto out; } - rc = ecryptfs_parse_packet_length(&data[(*packet_size)], &body_size, - &length_size); + rc = parse_packet_length(&data[(*packet_size)], &body_size, + &length_size); if (rc) { printk(KERN_WARNING "Invalid tag 11 packet format\n"); goto out; @@ -1411,8 +1405,8 @@ write_tag_1_packet(char *dest, size_t *remaining_bytes, auth_tok->token.private_key.key_size; rc = pki_encrypt_session_key(auth_tok, crypt_stat, key_rec); if (rc) { - printk(KERN_ERR "Failed to encrypt session key via a key " - "module; rc = [%d]\n", rc); + ecryptfs_printk(KERN_ERR, "Failed to encrypt session key " + "via a pki"); goto out; } if (ecryptfs_verbosity > 0) { @@ -1436,9 +1430,8 @@ write_tag_1_packet(char *dest, size_t *remaining_bytes, goto out; } dest[(*packet_size)++] = ECRYPTFS_TAG_1_PACKET_TYPE; - rc = ecryptfs_write_packet_length(&dest[(*packet_size)], - (max_packet_size - 4), - &packet_size_length); + rc = write_packet_length(&dest[(*packet_size)], (max_packet_size - 4), + &packet_size_length); if (rc) { ecryptfs_printk(KERN_ERR, "Error generating tag 1 packet " "header; cannot generate packet length\n"); @@ -1496,9 +1489,8 @@ write_tag_11_packet(char *dest, size_t *remaining_bytes, char *contents, goto out; } dest[(*packet_length)++] = ECRYPTFS_TAG_11_PACKET_TYPE; - rc = ecryptfs_write_packet_length(&dest[(*packet_length)], - (max_packet_size - 4), - &packet_size_length); + rc = write_packet_length(&dest[(*packet_length)], + (max_packet_size - 4), &packet_size_length); if (rc) { printk(KERN_ERR "Error generating tag 11 packet header; cannot " "generate packet length. rc = [%d]\n", rc); @@ -1690,9 +1682,8 @@ write_tag_3_packet(char *dest, size_t *remaining_bytes, dest[(*packet_size)++] = ECRYPTFS_TAG_3_PACKET_TYPE; /* Chop off the Tag 3 identifier(1) and Tag 3 packet size(3) * to get the number of octets in the actual Tag 3 packet */ - rc = ecryptfs_write_packet_length(&dest[(*packet_size)], - (max_packet_size - 4), - &packet_size_length); + rc = write_packet_length(&dest[(*packet_size)], (max_packet_size - 4), + &packet_size_length); if (rc) { printk(KERN_ERR "Error generating tag 3 packet header; cannot " "generate packet length. rc = [%d]\n", rc); diff --git a/trunk/fs/ecryptfs/main.c b/trunk/fs/ecryptfs/main.c index d603631601eb..d25ac9500a92 100644 --- a/trunk/fs/ecryptfs/main.c +++ b/trunk/fs/ecryptfs/main.c @@ -219,7 +219,7 @@ int ecryptfs_interpose(struct dentry *lower_dentry, struct dentry *dentry, if (rc) { printk(KERN_ERR "%s: Error attempting to initialize the " "persistent file for the dentry with name [%s]; " - "rc = [%d]\n", __func__, dentry->d_name.name, rc); + "rc = [%d]\n", __FUNCTION__, dentry->d_name.name, rc); goto out; } out: diff --git a/trunk/fs/ecryptfs/messaging.c b/trunk/fs/ecryptfs/messaging.c index 1b5c20058acb..9cc2aec27b0d 100644 --- a/trunk/fs/ecryptfs/messaging.c +++ b/trunk/fs/ecryptfs/messaging.c @@ -1,7 +1,7 @@ /** * eCryptfs: Linux filesystem encryption layer * - * Copyright (C) 2004-2008 International Business Machines Corp. + * Copyright (C) 2004-2006 International Business Machines Corp. * Author(s): Michael A. Halcrow * Tyler Hicks * @@ -20,21 +20,19 @@ * 02111-1307, USA. */ #include -#include -#include #include "ecryptfs_kernel.h" static LIST_HEAD(ecryptfs_msg_ctx_free_list); static LIST_HEAD(ecryptfs_msg_ctx_alloc_list); static struct mutex ecryptfs_msg_ctx_lists_mux; -static struct hlist_head *ecryptfs_daemon_hash; -struct mutex ecryptfs_daemon_hash_mux; +static struct hlist_head *ecryptfs_daemon_id_hash; +static struct mutex ecryptfs_daemon_id_hash_mux; static int ecryptfs_hash_buckets; #define ecryptfs_uid_hash(uid) \ hash_long((unsigned long)uid, ecryptfs_hash_buckets) -static u32 ecryptfs_msg_counter; +static unsigned int ecryptfs_msg_counter; static struct ecryptfs_msg_ctx *ecryptfs_msg_ctx_arr; /** @@ -42,10 +40,9 @@ static struct ecryptfs_msg_ctx *ecryptfs_msg_ctx_arr; * @msg_ctx: The context that was acquired from the free list * * Acquires a context element from the free list and locks the mutex - * on the context. Sets the msg_ctx task to current. Returns zero on - * success; non-zero on error or upon failure to acquire a free - * context element. Must be called with ecryptfs_msg_ctx_lists_mux - * held. + * on the context. Returns zero on success; non-zero on error or upon + * failure to acquire a free context element. Be sure to lock the + * list mutex before calling. */ static int ecryptfs_acquire_free_msg_ctx(struct ecryptfs_msg_ctx **msg_ctx) { @@ -53,11 +50,11 @@ static int ecryptfs_acquire_free_msg_ctx(struct ecryptfs_msg_ctx **msg_ctx) int rc; if (list_empty(&ecryptfs_msg_ctx_free_list)) { - printk(KERN_WARNING "%s: The eCryptfs free " - "context list is empty. It may be helpful to " - "specify the ecryptfs_message_buf_len " - "parameter to be greater than the current " - "value of [%d]\n", __func__, ecryptfs_message_buf_len); + ecryptfs_printk(KERN_WARNING, "The eCryptfs free " + "context list is empty. It may be helpful to " + "specify the ecryptfs_message_buf_len " + "parameter to be greater than the current " + "value of [%d]\n", ecryptfs_message_buf_len); rc = -ENOMEM; goto out; } @@ -78,7 +75,8 @@ static int ecryptfs_acquire_free_msg_ctx(struct ecryptfs_msg_ctx **msg_ctx) * ecryptfs_msg_ctx_free_to_alloc * @msg_ctx: The context to move from the free list to the alloc list * - * Must be called with ecryptfs_msg_ctx_lists_mux held. + * Be sure to lock the list mutex and the context mutex before + * calling. */ static void ecryptfs_msg_ctx_free_to_alloc(struct ecryptfs_msg_ctx *msg_ctx) { @@ -91,39 +89,36 @@ static void ecryptfs_msg_ctx_free_to_alloc(struct ecryptfs_msg_ctx *msg_ctx) * ecryptfs_msg_ctx_alloc_to_free * @msg_ctx: The context to move from the alloc list to the free list * - * Must be called with ecryptfs_msg_ctx_lists_mux held. + * Be sure to lock the list mutex and the context mutex before + * calling. */ -void ecryptfs_msg_ctx_alloc_to_free(struct ecryptfs_msg_ctx *msg_ctx) +static void ecryptfs_msg_ctx_alloc_to_free(struct ecryptfs_msg_ctx *msg_ctx) { list_move(&(msg_ctx->node), &ecryptfs_msg_ctx_free_list); if (msg_ctx->msg) kfree(msg_ctx->msg); - msg_ctx->msg = NULL; msg_ctx->state = ECRYPTFS_MSG_CTX_STATE_FREE; } /** - * ecryptfs_find_daemon_by_euid - * @euid: The effective user id which maps to the desired daemon id - * @user_ns: The namespace in which @euid applies - * @daemon: If return value is zero, points to the desired daemon pointer + * ecryptfs_find_daemon_id + * @uid: The user id which maps to the desired daemon id + * @id: If return value is zero, points to the desired daemon id + * pointer * - * Must be called with ecryptfs_daemon_hash_mux held. - * - * Search the hash list for the given user id. - * - * Returns zero if the user id exists in the list; non-zero otherwise. + * Search the hash list for the given user id. Returns zero if the + * user id exists in the list; non-zero otherwise. The daemon id hash + * mutex should be held before calling this function. */ -int ecryptfs_find_daemon_by_euid(struct ecryptfs_daemon **daemon, uid_t euid, - struct user_namespace *user_ns) +static int ecryptfs_find_daemon_id(uid_t uid, struct ecryptfs_daemon_id **id) { struct hlist_node *elem; int rc; - hlist_for_each_entry(*daemon, elem, - &ecryptfs_daemon_hash[ecryptfs_uid_hash(euid)], - euid_chain) { - if ((*daemon)->euid == euid && (*daemon)->user_ns == user_ns) { + hlist_for_each_entry(*id, elem, + &ecryptfs_daemon_id_hash[ecryptfs_uid_hash(uid)], + id_chain) { + if ((*id)->uid == uid) { rc = 0; goto out; } @@ -133,325 +128,181 @@ int ecryptfs_find_daemon_by_euid(struct ecryptfs_daemon **daemon, uid_t euid, return rc; } -static int -ecryptfs_send_message_locked(unsigned int transport, char *data, int data_len, - u8 msg_type, struct ecryptfs_msg_ctx **msg_ctx); - -/** - * ecryptfs_send_raw_message - * @transport: Transport type - * @msg_type: Message type - * @daemon: Daemon struct for recipient of message - * - * A raw message is one that does not include an ecryptfs_message - * struct. It simply has a type. - * - * Must be called with ecryptfs_daemon_hash_mux held. - * - * Returns zero on success; non-zero otherwise - */ -static int ecryptfs_send_raw_message(unsigned int transport, u8 msg_type, - struct ecryptfs_daemon *daemon) +static int ecryptfs_send_raw_message(unsigned int transport, u16 msg_type, + pid_t pid) { - struct ecryptfs_msg_ctx *msg_ctx; int rc; switch(transport) { case ECRYPTFS_TRANSPORT_NETLINK: - rc = ecryptfs_send_netlink(NULL, 0, NULL, msg_type, 0, - daemon->pid); - break; - case ECRYPTFS_TRANSPORT_MISCDEV: - rc = ecryptfs_send_message_locked(transport, NULL, 0, msg_type, - &msg_ctx); - if (rc) { - printk(KERN_ERR "%s: Error whilst attempting to send " - "message via procfs; rc = [%d]\n", __func__, rc); - goto out; - } - /* Raw messages are logically context-free (e.g., no - * reply is expected), so we set the state of the - * ecryptfs_msg_ctx object to indicate that it should - * be freed as soon as the transport sends out the message. */ - mutex_lock(&msg_ctx->mux); - msg_ctx->state = ECRYPTFS_MSG_CTX_STATE_NO_REPLY; - mutex_unlock(&msg_ctx->mux); + rc = ecryptfs_send_netlink(NULL, 0, NULL, msg_type, 0, pid); break; case ECRYPTFS_TRANSPORT_CONNECTOR: case ECRYPTFS_TRANSPORT_RELAYFS: default: rc = -ENOSYS; } -out: - return rc; -} - -/** - * ecryptfs_spawn_daemon - Create and initialize a new daemon struct - * @daemon: Pointer to set to newly allocated daemon struct - * @euid: Effective user id for the daemon - * @user_ns: The namespace in which @euid applies - * @pid: Process id for the daemon - * - * Must be called ceremoniously while in possession of - * ecryptfs_sacred_daemon_hash_mux - * - * Returns zero on success; non-zero otherwise - */ -int -ecryptfs_spawn_daemon(struct ecryptfs_daemon **daemon, uid_t euid, - struct user_namespace *user_ns, struct pid *pid) -{ - int rc = 0; - - (*daemon) = kzalloc(sizeof(**daemon), GFP_KERNEL); - if (!(*daemon)) { - rc = -ENOMEM; - printk(KERN_ERR "%s: Failed to allocate [%Zd] bytes of " - "GFP_KERNEL memory\n", __func__, sizeof(**daemon)); - goto out; - } - (*daemon)->euid = euid; - (*daemon)->user_ns = get_user_ns(user_ns); - (*daemon)->pid = get_pid(pid); - (*daemon)->task = current; - mutex_init(&(*daemon)->mux); - INIT_LIST_HEAD(&(*daemon)->msg_ctx_out_queue); - init_waitqueue_head(&(*daemon)->wait); - (*daemon)->num_queued_msg_ctx = 0; - hlist_add_head(&(*daemon)->euid_chain, - &ecryptfs_daemon_hash[ecryptfs_uid_hash(euid)]); -out: return rc; } /** * ecryptfs_process_helo * @transport: The underlying transport (netlink, etc.) - * @euid: The user ID owner of the message - * @user_ns: The namespace in which @euid applies + * @uid: The user ID owner of the message * @pid: The process ID for the userspace program that sent the * message * - * Adds the euid and pid values to the daemon euid hash. If an euid + * Adds the uid and pid values to the daemon id hash. If a uid * already has a daemon pid registered, the daemon will be - * unregistered before the new daemon is put into the hash list. - * Returns zero after adding a new daemon to the hash list; + * unregistered before the new daemon id is put into the hash list. + * Returns zero after adding a new daemon id to the hash list; * non-zero otherwise. */ -int ecryptfs_process_helo(unsigned int transport, uid_t euid, - struct user_namespace *user_ns, struct pid *pid) +int ecryptfs_process_helo(unsigned int transport, uid_t uid, pid_t pid) { - struct ecryptfs_daemon *new_daemon; - struct ecryptfs_daemon *old_daemon; + struct ecryptfs_daemon_id *new_id; + struct ecryptfs_daemon_id *old_id; int rc; - mutex_lock(&ecryptfs_daemon_hash_mux); - rc = ecryptfs_find_daemon_by_euid(&old_daemon, euid, user_ns); - if (rc != 0) { + mutex_lock(&ecryptfs_daemon_id_hash_mux); + new_id = kmalloc(sizeof(*new_id), GFP_KERNEL); + if (!new_id) { + rc = -ENOMEM; + ecryptfs_printk(KERN_ERR, "Failed to allocate memory; unable " + "to register daemon [%d] for user [%d]\n", + pid, uid); + goto unlock; + } + if (!ecryptfs_find_daemon_id(uid, &old_id)) { printk(KERN_WARNING "Received request from user [%d] " - "to register daemon [0x%p]; unregistering daemon " - "[0x%p]\n", euid, pid, old_daemon->pid); - rc = ecryptfs_send_raw_message(transport, ECRYPTFS_MSG_QUIT, - old_daemon); + "to register daemon [%d]; unregistering daemon " + "[%d]\n", uid, pid, old_id->pid); + hlist_del(&old_id->id_chain); + rc = ecryptfs_send_raw_message(transport, ECRYPTFS_NLMSG_QUIT, + old_id->pid); if (rc) printk(KERN_WARNING "Failed to send QUIT " - "message to daemon [0x%p]; rc = [%d]\n", - old_daemon->pid, rc); - hlist_del(&old_daemon->euid_chain); - kfree(old_daemon); + "message to daemon [%d]; rc = [%d]\n", + old_id->pid, rc); + kfree(old_id); } - rc = ecryptfs_spawn_daemon(&new_daemon, euid, user_ns, pid); - if (rc) - printk(KERN_ERR "%s: The gods are displeased with this attempt " - "to create a new daemon object for euid [%d]; pid " - "[0x%p]; rc = [%d]\n", __func__, euid, pid, rc); - mutex_unlock(&ecryptfs_daemon_hash_mux); - return rc; -} - -/** - * ecryptfs_exorcise_daemon - Destroy the daemon struct - * - * Must be called ceremoniously while in possession of - * ecryptfs_daemon_hash_mux and the daemon's own mux. - */ -int ecryptfs_exorcise_daemon(struct ecryptfs_daemon *daemon) -{ - struct ecryptfs_msg_ctx *msg_ctx, *msg_ctx_tmp; - int rc = 0; - - mutex_lock(&daemon->mux); - if ((daemon->flags & ECRYPTFS_DAEMON_IN_READ) - || (daemon->flags & ECRYPTFS_DAEMON_IN_POLL)) { - rc = -EBUSY; - printk(KERN_WARNING "%s: Attempt to destroy daemon with pid " - "[0x%p], but it is in the midst of a read or a poll\n", - __func__, daemon->pid); - mutex_unlock(&daemon->mux); - goto out; - } - list_for_each_entry_safe(msg_ctx, msg_ctx_tmp, - &daemon->msg_ctx_out_queue, daemon_out_list) { - list_del(&msg_ctx->daemon_out_list); - daemon->num_queued_msg_ctx--; - printk(KERN_WARNING "%s: Warning: dropping message that is in " - "the out queue of a dying daemon\n", __func__); - ecryptfs_msg_ctx_alloc_to_free(msg_ctx); - } - hlist_del(&daemon->euid_chain); - if (daemon->task) - wake_up_process(daemon->task); - if (daemon->pid) - put_pid(daemon->pid); - if (daemon->user_ns) - put_user_ns(daemon->user_ns); - mutex_unlock(&daemon->mux); - memset(daemon, 0, sizeof(*daemon)); - kfree(daemon); -out: + new_id->uid = uid; + new_id->pid = pid; + hlist_add_head(&new_id->id_chain, + &ecryptfs_daemon_id_hash[ecryptfs_uid_hash(uid)]); + rc = 0; +unlock: + mutex_unlock(&ecryptfs_daemon_id_hash_mux); return rc; } /** * ecryptfs_process_quit - * @euid: The user ID owner of the message - * @user_ns: The namespace in which @euid applies + * @uid: The user ID owner of the message * @pid: The process ID for the userspace program that sent the * message * - * Deletes the corresponding daemon for the given euid and pid, if + * Deletes the corresponding daemon id for the given uid and pid, if * it is the registered that is requesting the deletion. Returns zero - * after deleting the desired daemon; non-zero otherwise. + * after deleting the desired daemon id; non-zero otherwise. */ -int ecryptfs_process_quit(uid_t euid, struct user_namespace *user_ns, - struct pid *pid) +int ecryptfs_process_quit(uid_t uid, pid_t pid) { - struct ecryptfs_daemon *daemon; + struct ecryptfs_daemon_id *id; int rc; - mutex_lock(&ecryptfs_daemon_hash_mux); - rc = ecryptfs_find_daemon_by_euid(&daemon, euid, user_ns); - if (rc || !daemon) { + mutex_lock(&ecryptfs_daemon_id_hash_mux); + if (ecryptfs_find_daemon_id(uid, &id)) { rc = -EINVAL; - printk(KERN_ERR "Received request from user [%d] to " - "unregister unrecognized daemon [0x%p]\n", euid, pid); - goto out_unlock; + ecryptfs_printk(KERN_ERR, "Received request from user [%d] to " + "unregister unrecognized daemon [%d]\n", uid, + pid); + goto unlock; } - rc = ecryptfs_exorcise_daemon(daemon); -out_unlock: - mutex_unlock(&ecryptfs_daemon_hash_mux); + if (id->pid != pid) { + rc = -EINVAL; + ecryptfs_printk(KERN_WARNING, "Received request from user [%d] " + "with pid [%d] to unregister daemon [%d]\n", + uid, pid, id->pid); + goto unlock; + } + hlist_del(&id->id_chain); + kfree(id); + rc = 0; +unlock: + mutex_unlock(&ecryptfs_daemon_id_hash_mux); return rc; } /** * ecryptfs_process_reponse * @msg: The ecryptfs message received; the caller should sanity check - * msg->data_len and free the memory + * msg->data_len * @pid: The process ID of the userspace application that sent the * message - * @seq: The sequence number of the message; must match the sequence - * number for the existing message context waiting for this - * response - * - * Processes a response message after sending an operation request to - * userspace. Some other process is awaiting this response. Before - * sending out its first communications, the other process allocated a - * msg_ctx from the ecryptfs_msg_ctx_arr at a particular index. The - * response message contains this index so that we can copy over the - * response message into the msg_ctx that the process holds a - * reference to. The other process is going to wake up, check to see - * that msg_ctx->state == ECRYPTFS_MSG_CTX_STATE_DONE, and then - * proceed to read off and process the response message. Returns zero - * upon delivery to desired context element; non-zero upon delivery - * failure or error. + * @seq: The sequence number of the message * - * Returns zero on success; non-zero otherwise + * Processes a response message after sending a operation request to + * userspace. Returns zero upon delivery to desired context element; + * non-zero upon delivery failure or error. */ -int ecryptfs_process_response(struct ecryptfs_message *msg, uid_t euid, - struct user_namespace *user_ns, struct pid *pid, - u32 seq) +int ecryptfs_process_response(struct ecryptfs_message *msg, uid_t uid, + pid_t pid, u32 seq) { - struct ecryptfs_daemon *daemon; + struct ecryptfs_daemon_id *id; struct ecryptfs_msg_ctx *msg_ctx; - size_t msg_size; - struct nsproxy *nsproxy; - struct user_namespace *current_user_ns; + int msg_size; int rc; if (msg->index >= ecryptfs_message_buf_len) { rc = -EINVAL; - printk(KERN_ERR "%s: Attempt to reference " - "context buffer at index [%d]; maximum " - "allowable is [%d]\n", __func__, msg->index, - (ecryptfs_message_buf_len - 1)); + ecryptfs_printk(KERN_ERR, "Attempt to reference " + "context buffer at index [%d]; maximum " + "allowable is [%d]\n", msg->index, + (ecryptfs_message_buf_len - 1)); goto out; } msg_ctx = &ecryptfs_msg_ctx_arr[msg->index]; mutex_lock(&msg_ctx->mux); - mutex_lock(&ecryptfs_daemon_hash_mux); - rcu_read_lock(); - nsproxy = task_nsproxy(msg_ctx->task); - if (nsproxy == NULL) { + if (ecryptfs_find_daemon_id(msg_ctx->task->euid, &id)) { rc = -EBADMSG; - printk(KERN_ERR "%s: Receiving process is a zombie. Dropping " - "message.\n", __func__); - rcu_read_unlock(); - mutex_unlock(&ecryptfs_daemon_hash_mux); + ecryptfs_printk(KERN_WARNING, "User [%d] received a " + "message response from process [%d] but does " + "not have a registered daemon\n", + msg_ctx->task->euid, pid); goto wake_up; } - current_user_ns = nsproxy->user_ns; - rc = ecryptfs_find_daemon_by_euid(&daemon, msg_ctx->task->euid, - current_user_ns); - rcu_read_unlock(); - mutex_unlock(&ecryptfs_daemon_hash_mux); - if (rc) { - rc = -EBADMSG; - printk(KERN_WARNING "%s: User [%d] received a " - "message response from process [0x%p] but does " - "not have a registered daemon\n", __func__, - msg_ctx->task->euid, pid); - goto wake_up; - } - if (msg_ctx->task->euid != euid) { + if (msg_ctx->task->euid != uid) { rc = -EBADMSG; - printk(KERN_WARNING "%s: Received message from user " - "[%d]; expected message from user [%d]\n", __func__, - euid, msg_ctx->task->euid); + ecryptfs_printk(KERN_WARNING, "Received message from user " + "[%d]; expected message from user [%d]\n", + uid, msg_ctx->task->euid); goto unlock; } - if (current_user_ns != user_ns) { + if (id->pid != pid) { rc = -EBADMSG; - printk(KERN_WARNING "%s: Received message from user_ns " - "[0x%p]; expected message from user_ns [0x%p]\n", - __func__, user_ns, nsproxy->user_ns); - goto unlock; - } - if (daemon->pid != pid) { - rc = -EBADMSG; - printk(KERN_ERR "%s: User [%d] sent a message response " - "from an unrecognized process [0x%p]\n", - __func__, msg_ctx->task->euid, pid); + ecryptfs_printk(KERN_ERR, "User [%d] received a " + "message response from an unrecognized " + "process [%d]\n", msg_ctx->task->euid, pid); goto unlock; } if (msg_ctx->state != ECRYPTFS_MSG_CTX_STATE_PENDING) { rc = -EINVAL; - printk(KERN_WARNING "%s: Desired context element is not " - "pending a response\n", __func__); + ecryptfs_printk(KERN_WARNING, "Desired context element is not " + "pending a response\n"); goto unlock; } else if (msg_ctx->counter != seq) { rc = -EINVAL; - printk(KERN_WARNING "%s: Invalid message sequence; " - "expected [%d]; received [%d]\n", __func__, - msg_ctx->counter, seq); + ecryptfs_printk(KERN_WARNING, "Invalid message sequence; " + "expected [%d]; received [%d]\n", + msg_ctx->counter, seq); goto unlock; } - msg_size = (sizeof(*msg) + msg->data_len); + msg_size = sizeof(*msg) + msg->data_len; msg_ctx->msg = kmalloc(msg_size, GFP_KERNEL); if (!msg_ctx->msg) { rc = -ENOMEM; - printk(KERN_ERR "%s: Failed to allocate [%Zd] bytes of " - "GFP_KERNEL memory\n", __func__, msg_size); + ecryptfs_printk(KERN_ERR, "Failed to allocate memory\n"); goto unlock; } memcpy(msg_ctx->msg, msg, msg_size); @@ -466,38 +317,34 @@ int ecryptfs_process_response(struct ecryptfs_message *msg, uid_t euid, } /** - * ecryptfs_send_message_locked + * ecryptfs_send_message * @transport: The transport over which to send the message (i.e., * netlink) * @data: The data to send * @data_len: The length of data * @msg_ctx: The message context allocated for the send - * - * Must be called with ecryptfs_daemon_hash_mux held. - * - * Returns zero on success; non-zero otherwise */ -static int -ecryptfs_send_message_locked(unsigned int transport, char *data, int data_len, - u8 msg_type, struct ecryptfs_msg_ctx **msg_ctx) +int ecryptfs_send_message(unsigned int transport, char *data, int data_len, + struct ecryptfs_msg_ctx **msg_ctx) { - struct ecryptfs_daemon *daemon; + struct ecryptfs_daemon_id *id; int rc; - rc = ecryptfs_find_daemon_by_euid(&daemon, current->euid, - current->nsproxy->user_ns); - if (rc || !daemon) { + mutex_lock(&ecryptfs_daemon_id_hash_mux); + if (ecryptfs_find_daemon_id(current->euid, &id)) { + mutex_unlock(&ecryptfs_daemon_id_hash_mux); rc = -ENOTCONN; - printk(KERN_ERR "%s: User [%d] does not have a daemon " - "registered\n", __func__, current->euid); + ecryptfs_printk(KERN_ERR, "User [%d] does not have a daemon " + "registered\n", current->euid); goto out; } + mutex_unlock(&ecryptfs_daemon_id_hash_mux); mutex_lock(&ecryptfs_msg_ctx_lists_mux); rc = ecryptfs_acquire_free_msg_ctx(msg_ctx); if (rc) { mutex_unlock(&ecryptfs_msg_ctx_lists_mux); - printk(KERN_WARNING "%s: Could not claim a free " - "context element\n", __func__); + ecryptfs_printk(KERN_WARNING, "Could not claim a free " + "context element\n"); goto out; } ecryptfs_msg_ctx_free_to_alloc(*msg_ctx); @@ -505,49 +352,22 @@ ecryptfs_send_message_locked(unsigned int transport, char *data, int data_len, mutex_unlock(&ecryptfs_msg_ctx_lists_mux); switch (transport) { case ECRYPTFS_TRANSPORT_NETLINK: - rc = ecryptfs_send_netlink(data, data_len, *msg_ctx, msg_type, - 0, daemon->pid); - break; - case ECRYPTFS_TRANSPORT_MISCDEV: - rc = ecryptfs_send_miscdev(data, data_len, *msg_ctx, msg_type, - 0, daemon); + rc = ecryptfs_send_netlink(data, data_len, *msg_ctx, + ECRYPTFS_NLMSG_REQUEST, 0, id->pid); break; case ECRYPTFS_TRANSPORT_CONNECTOR: case ECRYPTFS_TRANSPORT_RELAYFS: default: rc = -ENOSYS; } - if (rc) - printk(KERN_ERR "%s: Error attempting to send message to " - "userspace daemon; rc = [%d]\n", __func__, rc); + if (rc) { + printk(KERN_ERR "Error attempting to send message to userspace " + "daemon; rc = [%d]\n", rc); + } out: return rc; } -/** - * ecryptfs_send_message - * @transport: The transport over which to send the message (i.e., - * netlink) - * @data: The data to send - * @data_len: The length of data - * @msg_ctx: The message context allocated for the send - * - * Grabs ecryptfs_daemon_hash_mux. - * - * Returns zero on success; non-zero otherwise - */ -int ecryptfs_send_message(unsigned int transport, char *data, int data_len, - struct ecryptfs_msg_ctx **msg_ctx) -{ - int rc; - - mutex_lock(&ecryptfs_daemon_hash_mux); - rc = ecryptfs_send_message_locked(transport, data, data_len, - ECRYPTFS_MSG_REQUEST, msg_ctx); - mutex_unlock(&ecryptfs_daemon_hash_mux); - return rc; -} - /** * ecryptfs_wait_for_response * @msg_ctx: The context that was assigned when sending a message @@ -557,7 +377,7 @@ int ecryptfs_send_message(unsigned int transport, char *data, int data_len, * of time exceeds ecryptfs_message_wait_timeout. If zero is * returned, msg will point to a valid message from userspace; a * non-zero value is returned upon failure to receive a message or an - * error occurs. Callee must free @msg on success. + * error occurs. */ int ecryptfs_wait_for_response(struct ecryptfs_msg_ctx *msg_ctx, struct ecryptfs_message **msg) @@ -593,32 +413,32 @@ int ecryptfs_init_messaging(unsigned int transport) if (ecryptfs_number_of_users > ECRYPTFS_MAX_NUM_USERS) { ecryptfs_number_of_users = ECRYPTFS_MAX_NUM_USERS; - printk(KERN_WARNING "%s: Specified number of users is " - "too large, defaulting to [%d] users\n", __func__, - ecryptfs_number_of_users); + ecryptfs_printk(KERN_WARNING, "Specified number of users is " + "too large, defaulting to [%d] users\n", + ecryptfs_number_of_users); } - mutex_init(&ecryptfs_daemon_hash_mux); - mutex_lock(&ecryptfs_daemon_hash_mux); + mutex_init(&ecryptfs_daemon_id_hash_mux); + mutex_lock(&ecryptfs_daemon_id_hash_mux); ecryptfs_hash_buckets = 1; while (ecryptfs_number_of_users >> ecryptfs_hash_buckets) ecryptfs_hash_buckets++; - ecryptfs_daemon_hash = kmalloc((sizeof(struct hlist_head) - * ecryptfs_hash_buckets), GFP_KERNEL); - if (!ecryptfs_daemon_hash) { + ecryptfs_daemon_id_hash = kmalloc(sizeof(struct hlist_head) + * ecryptfs_hash_buckets, GFP_KERNEL); + if (!ecryptfs_daemon_id_hash) { rc = -ENOMEM; - printk(KERN_ERR "%s: Failed to allocate memory\n", __func__); - mutex_unlock(&ecryptfs_daemon_hash_mux); + ecryptfs_printk(KERN_ERR, "Failed to allocate memory\n"); + mutex_unlock(&ecryptfs_daemon_id_hash_mux); goto out; } for (i = 0; i < ecryptfs_hash_buckets; i++) - INIT_HLIST_HEAD(&ecryptfs_daemon_hash[i]); - mutex_unlock(&ecryptfs_daemon_hash_mux); + INIT_HLIST_HEAD(&ecryptfs_daemon_id_hash[i]); + mutex_unlock(&ecryptfs_daemon_id_hash_mux); + ecryptfs_msg_ctx_arr = kmalloc((sizeof(struct ecryptfs_msg_ctx) - * ecryptfs_message_buf_len), - GFP_KERNEL); + * ecryptfs_message_buf_len), GFP_KERNEL); if (!ecryptfs_msg_ctx_arr) { rc = -ENOMEM; - printk(KERN_ERR "%s: Failed to allocate memory\n", __func__); + ecryptfs_printk(KERN_ERR, "Failed to allocate memory\n"); goto out; } mutex_init(&ecryptfs_msg_ctx_lists_mux); @@ -626,7 +446,6 @@ int ecryptfs_init_messaging(unsigned int transport) ecryptfs_msg_counter = 0; for (i = 0; i < ecryptfs_message_buf_len; i++) { INIT_LIST_HEAD(&ecryptfs_msg_ctx_arr[i].node); - INIT_LIST_HEAD(&ecryptfs_msg_ctx_arr[i].daemon_out_list); mutex_init(&ecryptfs_msg_ctx_arr[i].mux); mutex_lock(&ecryptfs_msg_ctx_arr[i].mux); ecryptfs_msg_ctx_arr[i].index = i; @@ -645,11 +464,6 @@ int ecryptfs_init_messaging(unsigned int transport) if (rc) ecryptfs_release_messaging(transport); break; - case ECRYPTFS_TRANSPORT_MISCDEV: - rc = ecryptfs_init_ecryptfs_miscdev(); - if (rc) - ecryptfs_release_messaging(transport); - break; case ECRYPTFS_TRANSPORT_CONNECTOR: case ECRYPTFS_TRANSPORT_RELAYFS: default: @@ -674,37 +488,27 @@ void ecryptfs_release_messaging(unsigned int transport) kfree(ecryptfs_msg_ctx_arr); mutex_unlock(&ecryptfs_msg_ctx_lists_mux); } - if (ecryptfs_daemon_hash) { + if (ecryptfs_daemon_id_hash) { struct hlist_node *elem; - struct ecryptfs_daemon *daemon; + struct ecryptfs_daemon_id *id; int i; - mutex_lock(&ecryptfs_daemon_hash_mux); + mutex_lock(&ecryptfs_daemon_id_hash_mux); for (i = 0; i < ecryptfs_hash_buckets; i++) { - int rc; - - hlist_for_each_entry(daemon, elem, - &ecryptfs_daemon_hash[i], - euid_chain) { - rc = ecryptfs_exorcise_daemon(daemon); - if (rc) - printk(KERN_ERR "%s: Error whilst " - "attempting to destroy daemon; " - "rc = [%d]. Dazed and confused, " - "but trying to continue.\n", - __func__, rc); + hlist_for_each_entry(id, elem, + &ecryptfs_daemon_id_hash[i], + id_chain) { + hlist_del(elem); + kfree(id); } } - kfree(ecryptfs_daemon_hash); - mutex_unlock(&ecryptfs_daemon_hash_mux); + kfree(ecryptfs_daemon_id_hash); + mutex_unlock(&ecryptfs_daemon_id_hash_mux); } switch(transport) { case ECRYPTFS_TRANSPORT_NETLINK: ecryptfs_release_netlink(); break; - case ECRYPTFS_TRANSPORT_MISCDEV: - ecryptfs_destroy_ecryptfs_miscdev(); - break; case ECRYPTFS_TRANSPORT_CONNECTOR: case ECRYPTFS_TRANSPORT_RELAYFS: default: diff --git a/trunk/fs/ecryptfs/miscdev.c b/trunk/fs/ecryptfs/miscdev.c deleted file mode 100644 index 788995efd1d3..000000000000 --- a/trunk/fs/ecryptfs/miscdev.c +++ /dev/null @@ -1,598 +0,0 @@ -/** - * eCryptfs: Linux filesystem encryption layer - * - * Copyright (C) 2008 International Business Machines Corp. - * Author(s): Michael A. Halcrow - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License version - * 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include "ecryptfs_kernel.h" - -static atomic_t ecryptfs_num_miscdev_opens; - -/** - * ecryptfs_miscdev_poll - * @file: dev file (ignored) - * @pt: dev poll table (ignored) - * - * Returns the poll mask - */ -static unsigned int -ecryptfs_miscdev_poll(struct file *file, poll_table *pt) -{ - struct ecryptfs_daemon *daemon; - unsigned int mask = 0; - int rc; - - mutex_lock(&ecryptfs_daemon_hash_mux); - /* TODO: Just use file->private_data? */ - rc = ecryptfs_find_daemon_by_euid(&daemon, current->euid, - current->nsproxy->user_ns); - BUG_ON(rc || !daemon); - mutex_lock(&daemon->mux); - mutex_unlock(&ecryptfs_daemon_hash_mux); - if (daemon->flags & ECRYPTFS_DAEMON_ZOMBIE) { - printk(KERN_WARNING "%s: Attempt to poll on zombified " - "daemon\n", __func__); - goto out_unlock_daemon; - } - if (daemon->flags & ECRYPTFS_DAEMON_IN_READ) - goto out_unlock_daemon; - if (daemon->flags & ECRYPTFS_DAEMON_IN_POLL) - goto out_unlock_daemon; - daemon->flags |= ECRYPTFS_DAEMON_IN_POLL; - mutex_unlock(&daemon->mux); - poll_wait(file, &daemon->wait, pt); - mutex_lock(&daemon->mux); - if (!list_empty(&daemon->msg_ctx_out_queue)) - mask |= POLLIN | POLLRDNORM; -out_unlock_daemon: - daemon->flags &= ~ECRYPTFS_DAEMON_IN_POLL; - mutex_unlock(&daemon->mux); - return mask; -} - -/** - * ecryptfs_miscdev_open - * @inode: inode of miscdev handle (ignored) - * @file: file for miscdev handle (ignored) - * - * Returns zero on success; non-zero otherwise - */ -static int -ecryptfs_miscdev_open(struct inode *inode, struct file *file) -{ - struct ecryptfs_daemon *daemon = NULL; - int rc; - - mutex_lock(&ecryptfs_daemon_hash_mux); - rc = try_module_get(THIS_MODULE); - if (rc == 0) { - rc = -EIO; - printk(KERN_ERR "%s: Error attempting to increment module use " - "count; rc = [%d]\n", __func__, rc); - goto out_unlock_daemon_list; - } - rc = ecryptfs_find_daemon_by_euid(&daemon, current->euid, - current->nsproxy->user_ns); - if (rc || !daemon) { - rc = ecryptfs_spawn_daemon(&daemon, current->euid, - current->nsproxy->user_ns, - task_pid(current)); - if (rc) { - printk(KERN_ERR "%s: Error attempting to spawn daemon; " - "rc = [%d]\n", __func__, rc); - goto out_module_put_unlock_daemon_list; - } - } - mutex_lock(&daemon->mux); - if (daemon->pid != task_pid(current)) { - rc = -EINVAL; - printk(KERN_ERR "%s: pid [0x%p] has registered with euid [%d], " - "but pid [0x%p] has attempted to open the handle " - "instead\n", __func__, daemon->pid, daemon->euid, - task_pid(current)); - goto out_unlock_daemon; - } - if (daemon->flags & ECRYPTFS_DAEMON_MISCDEV_OPEN) { - rc = -EBUSY; - printk(KERN_ERR "%s: Miscellaneous device handle may only be " - "opened once per daemon; pid [0x%p] already has this " - "handle open\n", __func__, daemon->pid); - goto out_unlock_daemon; - } - daemon->flags |= ECRYPTFS_DAEMON_MISCDEV_OPEN; - atomic_inc(&ecryptfs_num_miscdev_opens); -out_unlock_daemon: - mutex_unlock(&daemon->mux); -out_module_put_unlock_daemon_list: - if (rc) - module_put(THIS_MODULE); -out_unlock_daemon_list: - mutex_unlock(&ecryptfs_daemon_hash_mux); - return rc; -} - -/** - * ecryptfs_miscdev_release - * @inode: inode of fs/ecryptfs/euid handle (ignored) - * @file: file for fs/ecryptfs/euid handle (ignored) - * - * This keeps the daemon registered until the daemon sends another - * ioctl to fs/ecryptfs/ctl or until the kernel module unregisters. - * - * Returns zero on success; non-zero otherwise - */ -static int -ecryptfs_miscdev_release(struct inode *inode, struct file *file) -{ - struct ecryptfs_daemon *daemon = NULL; - int rc; - - mutex_lock(&ecryptfs_daemon_hash_mux); - rc = ecryptfs_find_daemon_by_euid(&daemon, current->euid, - current->nsproxy->user_ns); - BUG_ON(rc || !daemon); - mutex_lock(&daemon->mux); - BUG_ON(daemon->pid != task_pid(current)); - BUG_ON(!(daemon->flags & ECRYPTFS_DAEMON_MISCDEV_OPEN)); - daemon->flags &= ~ECRYPTFS_DAEMON_MISCDEV_OPEN; - atomic_dec(&ecryptfs_num_miscdev_opens); - mutex_unlock(&daemon->mux); - rc = ecryptfs_exorcise_daemon(daemon); - if (rc) { - printk(KERN_CRIT "%s: Fatal error whilst attempting to " - "shut down daemon; rc = [%d]. Please report this " - "bug.\n", __func__, rc); - BUG(); - } - module_put(THIS_MODULE); - mutex_unlock(&ecryptfs_daemon_hash_mux); - return rc; -} - -/** - * ecryptfs_send_miscdev - * @data: Data to send to daemon; may be NULL - * @data_size: Amount of data to send to daemon - * @msg_ctx: Message context, which is used to handle the reply. If - * this is NULL, then we do not expect a reply. - * @msg_type: Type of message - * @msg_flags: Flags for message - * @daemon: eCryptfs daemon object - * - * Add msg_ctx to queue and then, if it exists, notify the blocked - * miscdevess about the data being available. Must be called with - * ecryptfs_daemon_hash_mux held. - * - * Returns zero on success; non-zero otherwise - */ -int ecryptfs_send_miscdev(char *data, size_t data_size, - struct ecryptfs_msg_ctx *msg_ctx, u8 msg_type, - u16 msg_flags, struct ecryptfs_daemon *daemon) -{ - int rc = 0; - - mutex_lock(&msg_ctx->mux); - if (data) { - msg_ctx->msg = kmalloc((sizeof(*msg_ctx->msg) + data_size), - GFP_KERNEL); - if (!msg_ctx->msg) { - rc = -ENOMEM; - printk(KERN_ERR "%s: Out of memory whilst attempting " - "to kmalloc(%Zd, GFP_KERNEL)\n", __func__, - (sizeof(*msg_ctx->msg) + data_size)); - goto out_unlock; - } - } else - msg_ctx->msg = NULL; - msg_ctx->msg->index = msg_ctx->index; - msg_ctx->msg->data_len = data_size; - msg_ctx->type = msg_type; - if (data) { - memcpy(msg_ctx->msg->data, data, data_size); - msg_ctx->msg_size = (sizeof(*msg_ctx->msg) + data_size); - } else - msg_ctx->msg_size = 0; - mutex_lock(&daemon->mux); - list_add_tail(&msg_ctx->daemon_out_list, &daemon->msg_ctx_out_queue); - daemon->num_queued_msg_ctx++; - wake_up_interruptible(&daemon->wait); - mutex_unlock(&daemon->mux); -out_unlock: - mutex_unlock(&msg_ctx->mux); - return rc; -} - -/** - * ecryptfs_miscdev_read - format and send message from queue - * @file: fs/ecryptfs/euid miscdevfs handle (ignored) - * @buf: User buffer into which to copy the next message on the daemon queue - * @count: Amount of space available in @buf - * @ppos: Offset in file (ignored) - * - * Pulls the most recent message from the daemon queue, formats it for - * being sent via a miscdevfs handle, and copies it into @buf - * - * Returns the number of bytes copied into the user buffer - */ -static ssize_t -ecryptfs_miscdev_read(struct file *file, char __user *buf, size_t count, - loff_t *ppos) -{ - struct ecryptfs_daemon *daemon; - struct ecryptfs_msg_ctx *msg_ctx; - size_t packet_length_size; - u32 counter_nbo; - char packet_length[3]; - size_t i; - size_t total_length; - int rc; - - mutex_lock(&ecryptfs_daemon_hash_mux); - /* TODO: Just use file->private_data? */ - rc = ecryptfs_find_daemon_by_euid(&daemon, current->euid, - current->nsproxy->user_ns); - BUG_ON(rc || !daemon); - mutex_lock(&daemon->mux); - if (daemon->flags & ECRYPTFS_DAEMON_ZOMBIE) { - rc = 0; - printk(KERN_WARNING "%s: Attempt to read from zombified " - "daemon\n", __func__); - goto out_unlock_daemon; - } - if (daemon->flags & ECRYPTFS_DAEMON_IN_READ) { - rc = 0; - goto out_unlock_daemon; - } - /* This daemon will not go away so long as this flag is set */ - daemon->flags |= ECRYPTFS_DAEMON_IN_READ; - mutex_unlock(&ecryptfs_daemon_hash_mux); -check_list: - if (list_empty(&daemon->msg_ctx_out_queue)) { - mutex_unlock(&daemon->mux); - rc = wait_event_interruptible( - daemon->wait, !list_empty(&daemon->msg_ctx_out_queue)); - mutex_lock(&daemon->mux); - if (rc < 0) { - rc = 0; - goto out_unlock_daemon; - } - } - if (daemon->flags & ECRYPTFS_DAEMON_ZOMBIE) { - rc = 0; - goto out_unlock_daemon; - } - if (list_empty(&daemon->msg_ctx_out_queue)) { - /* Something else jumped in since the - * wait_event_interruptable() and removed the - * message from the queue; try again */ - goto check_list; - } - BUG_ON(current->euid != daemon->euid); - BUG_ON(current->nsproxy->user_ns != daemon->user_ns); - BUG_ON(task_pid(current) != daemon->pid); - msg_ctx = list_first_entry(&daemon->msg_ctx_out_queue, - struct ecryptfs_msg_ctx, daemon_out_list); - BUG_ON(!msg_ctx); - mutex_lock(&msg_ctx->mux); - if (msg_ctx->msg) { - rc = ecryptfs_write_packet_length(packet_length, - msg_ctx->msg_size, - &packet_length_size); - if (rc) { - rc = 0; - printk(KERN_WARNING "%s: Error writing packet length; " - "rc = [%d]\n", __func__, rc); - goto out_unlock_msg_ctx; - } - } else { - packet_length_size = 0; - msg_ctx->msg_size = 0; - } - /* miscdevfs packet format: - * Octet 0: Type - * Octets 1-4: network byte order msg_ctx->counter - * Octets 5-N0: Size of struct ecryptfs_message to follow - * Octets N0-N1: struct ecryptfs_message (including data) - * - * Octets 5-N1 not written if the packet type does not - * include a message */ - total_length = (1 + 4 + packet_length_size + msg_ctx->msg_size); - if (count < total_length) { - rc = 0; - printk(KERN_WARNING "%s: Only given user buffer of " - "size [%Zd], but we need [%Zd] to read the " - "pending message\n", __func__, count, total_length); - goto out_unlock_msg_ctx; - } - i = 0; - buf[i++] = msg_ctx->type; - counter_nbo = cpu_to_be32(msg_ctx->counter); - memcpy(&buf[i], (char *)&counter_nbo, 4); - i += 4; - if (msg_ctx->msg) { - memcpy(&buf[i], packet_length, packet_length_size); - i += packet_length_size; - rc = copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size); - if (rc) { - printk(KERN_ERR "%s: copy_to_user returned error " - "[%d]\n", __func__, rc); - goto out_unlock_msg_ctx; - } - i += msg_ctx->msg_size; - } - rc = i; - list_del(&msg_ctx->daemon_out_list); - kfree(msg_ctx->msg); - msg_ctx->msg = NULL; - /* We do not expect a reply from the userspace daemon for any - * message type other than ECRYPTFS_MSG_REQUEST */ - if (msg_ctx->type != ECRYPTFS_MSG_REQUEST) - ecryptfs_msg_ctx_alloc_to_free(msg_ctx); -out_unlock_msg_ctx: - mutex_unlock(&msg_ctx->mux); -out_unlock_daemon: - daemon->flags &= ~ECRYPTFS_DAEMON_IN_READ; - mutex_unlock(&daemon->mux); - return rc; -} - -/** - * ecryptfs_miscdev_helo - * @euid: effective user id of miscdevess sending helo packet - * @user_ns: The namespace in which @euid applies - * @pid: miscdevess id of miscdevess sending helo packet - * - * Returns zero on success; non-zero otherwise - */ -static int ecryptfs_miscdev_helo(uid_t euid, struct user_namespace *user_ns, - struct pid *pid) -{ - int rc; - - rc = ecryptfs_process_helo(ECRYPTFS_TRANSPORT_MISCDEV, euid, user_ns, - pid); - if (rc) - printk(KERN_WARNING "Error processing HELO; rc = [%d]\n", rc); - return rc; -} - -/** - * ecryptfs_miscdev_quit - * @euid: effective user id of miscdevess sending quit packet - * @user_ns: The namespace in which @euid applies - * @pid: miscdevess id of miscdevess sending quit packet - * - * Returns zero on success; non-zero otherwise - */ -static int ecryptfs_miscdev_quit(uid_t euid, struct user_namespace *user_ns, - struct pid *pid) -{ - int rc; - - rc = ecryptfs_process_quit(euid, user_ns, pid); - if (rc) - printk(KERN_WARNING - "Error processing QUIT message; rc = [%d]\n", rc); - return rc; -} - -/** - * ecryptfs_miscdev_response - miscdevess response to message previously sent to daemon - * @data: Bytes comprising struct ecryptfs_message - * @data_size: sizeof(struct ecryptfs_message) + data len - * @euid: Effective user id of miscdevess sending the miscdev response - * @user_ns: The namespace in which @euid applies - * @pid: Miscdevess id of miscdevess sending the miscdev response - * @seq: Sequence number for miscdev response packet - * - * Returns zero on success; non-zero otherwise - */ -static int ecryptfs_miscdev_response(char *data, size_t data_size, - uid_t euid, struct user_namespace *user_ns, - struct pid *pid, u32 seq) -{ - struct ecryptfs_message *msg = (struct ecryptfs_message *)data; - int rc; - - if ((sizeof(*msg) + msg->data_len) != data_size) { - printk(KERN_WARNING "%s: (sizeof(*msg) + msg->data_len) = " - "[%Zd]; data_size = [%Zd]. Invalid packet.\n", __func__, - (sizeof(*msg) + msg->data_len), data_size); - rc = -EINVAL; - goto out; - } - rc = ecryptfs_process_response(msg, euid, user_ns, pid, seq); - if (rc) - printk(KERN_ERR - "Error processing response message; rc = [%d]\n", rc); -out: - return rc; -} - -/** - * ecryptfs_miscdev_write - handle write to daemon miscdev handle - * @file: File for misc dev handle (ignored) - * @buf: Buffer containing user data - * @count: Amount of data in @buf - * @ppos: Pointer to offset in file (ignored) - * - * miscdevfs packet format: - * Octet 0: Type - * Octets 1-4: network byte order msg_ctx->counter (0's for non-response) - * Octets 5-N0: Size of struct ecryptfs_message to follow - * Octets N0-N1: struct ecryptfs_message (including data) - * - * Returns the number of bytes read from @buf - */ -static ssize_t -ecryptfs_miscdev_write(struct file *file, const char __user *buf, - size_t count, loff_t *ppos) -{ - u32 counter_nbo, seq; - size_t packet_size, packet_size_length, i; - ssize_t sz = 0; - char *data; - int rc; - - if (count == 0) - goto out; - data = kmalloc(count, GFP_KERNEL); - if (!data) { - printk(KERN_ERR "%s: Out of memory whilst attempting to " - "kmalloc([%Zd], GFP_KERNEL)\n", __func__, count); - goto out; - } - rc = copy_from_user(data, buf, count); - if (rc) { - printk(KERN_ERR "%s: copy_from_user returned error [%d]\n", - __func__, rc); - goto out_free; - } - sz = count; - i = 0; - switch (data[i++]) { - case ECRYPTFS_MSG_RESPONSE: - if (count < (1 + 4 + 1 + sizeof(struct ecryptfs_message))) { - printk(KERN_WARNING "%s: Minimum acceptable packet " - "size is [%Zd], but amount of data written is " - "only [%Zd]. Discarding response packet.\n", - __func__, - (1 + 4 + 1 + sizeof(struct ecryptfs_message)), - count); - goto out_free; - } - memcpy((char *)&counter_nbo, &data[i], 4); - seq = be32_to_cpu(counter_nbo); - i += 4; - rc = ecryptfs_parse_packet_length(&data[i], &packet_size, - &packet_size_length); - if (rc) { - printk(KERN_WARNING "%s: Error parsing packet length; " - "rc = [%d]\n", __func__, rc); - goto out_free; - } - i += packet_size_length; - if ((1 + 4 + packet_size_length + packet_size) != count) { - printk(KERN_WARNING "%s: (1 + packet_size_length([%Zd])" - " + packet_size([%Zd]))([%Zd]) != " - "count([%Zd]). Invalid packet format.\n", - __func__, packet_size_length, packet_size, - (1 + packet_size_length + packet_size), count); - goto out_free; - } - rc = ecryptfs_miscdev_response(&data[i], packet_size, - current->euid, - current->nsproxy->user_ns, - task_pid(current), seq); - if (rc) - printk(KERN_WARNING "%s: Failed to deliver miscdev " - "response to requesting operation; rc = [%d]\n", - __func__, rc); - break; - case ECRYPTFS_MSG_HELO: - rc = ecryptfs_miscdev_helo(current->euid, - current->nsproxy->user_ns, - task_pid(current)); - if (rc) { - printk(KERN_ERR "%s: Error attempting to process " - "helo from pid [0x%p]; rc = [%d]\n", __func__, - task_pid(current), rc); - goto out_free; - } - break; - case ECRYPTFS_MSG_QUIT: - rc = ecryptfs_miscdev_quit(current->euid, - current->nsproxy->user_ns, - task_pid(current)); - if (rc) { - printk(KERN_ERR "%s: Error attempting to process " - "quit from pid [0x%p]; rc = [%d]\n", __func__, - task_pid(current), rc); - goto out_free; - } - break; - default: - ecryptfs_printk(KERN_WARNING, "Dropping miscdev " - "message of unrecognized type [%d]\n", - data[0]); - break; - } -out_free: - kfree(data); -out: - return sz; -} - - -static const struct file_operations ecryptfs_miscdev_fops = { - .open = ecryptfs_miscdev_open, - .poll = ecryptfs_miscdev_poll, - .read = ecryptfs_miscdev_read, - .write = ecryptfs_miscdev_write, - .release = ecryptfs_miscdev_release, -}; - -static struct miscdevice ecryptfs_miscdev = { - .minor = MISC_DYNAMIC_MINOR, - .name = "ecryptfs", - .fops = &ecryptfs_miscdev_fops -}; - -/** - * ecryptfs_init_ecryptfs_miscdev - * - * Messages sent to the userspace daemon from the kernel are placed on - * a queue associated with the daemon. The next read against the - * miscdev handle by that daemon will return the oldest message placed - * on the message queue for the daemon. - * - * Returns zero on success; non-zero otherwise - */ -int ecryptfs_init_ecryptfs_miscdev(void) -{ - int rc; - - atomic_set(&ecryptfs_num_miscdev_opens, 0); - mutex_lock(&ecryptfs_daemon_hash_mux); - rc = misc_register(&ecryptfs_miscdev); - if (rc) - printk(KERN_ERR "%s: Failed to register miscellaneous device " - "for communications with userspace daemons; rc = [%d]\n", - __func__, rc); - mutex_unlock(&ecryptfs_daemon_hash_mux); - return rc; -} - -/** - * ecryptfs_destroy_ecryptfs_miscdev - * - * All of the daemons must be exorcised prior to calling this - * function. - */ -void ecryptfs_destroy_ecryptfs_miscdev(void) -{ - BUG_ON(atomic_read(&ecryptfs_num_miscdev_opens) != 0); - misc_deregister(&ecryptfs_miscdev); -} diff --git a/trunk/fs/ecryptfs/mmap.c b/trunk/fs/ecryptfs/mmap.c index 2b6fe1e6e8ba..6df1debdccce 100644 --- a/trunk/fs/ecryptfs/mmap.c +++ b/trunk/fs/ecryptfs/mmap.c @@ -153,7 +153,7 @@ ecryptfs_copy_up_encrypted_with_header(struct page *page, flush_dcache_page(page); if (rc) { printk(KERN_ERR "%s: Error reading xattr " - "region; rc = [%d]\n", __func__, rc); + "region; rc = [%d]\n", __FUNCTION__, rc); goto out; } } else { @@ -169,7 +169,7 @@ ecryptfs_copy_up_encrypted_with_header(struct page *page, if (rc) { printk(KERN_ERR "%s: Error attempting to read " "extent at offset [%lld] in the lower " - "file; rc = [%d]\n", __func__, + "file; rc = [%d]\n", __FUNCTION__, lower_offset, rc); goto out; } @@ -212,7 +212,7 @@ static int ecryptfs_readpage(struct file *file, struct page *page) "the encrypted content from the lower " "file whilst inserting the metadata " "from the xattr into the header; rc = " - "[%d]\n", __func__, rc); + "[%d]\n", __FUNCTION__, rc); goto out; } @@ -293,7 +293,7 @@ static int ecryptfs_prepare_write(struct file *file, struct page *page, if (rc) { printk(KERN_ERR "%s: Error attemping to read " "lower page segment; rc = [%d]\n", - __func__, rc); + __FUNCTION__, rc); ClearPageUptodate(page); goto out; } else @@ -308,7 +308,7 @@ static int ecryptfs_prepare_write(struct file *file, struct page *page, "from the lower file whilst " "inserting the metadata from " "the xattr into the header; rc " - "= [%d]\n", __func__, rc); + "= [%d]\n", __FUNCTION__, rc); ClearPageUptodate(page); goto out; } @@ -320,7 +320,7 @@ static int ecryptfs_prepare_write(struct file *file, struct page *page, if (rc) { printk(KERN_ERR "%s: Error reading " "page; rc = [%d]\n", - __func__, rc); + __FUNCTION__, rc); ClearPageUptodate(page); goto out; } @@ -331,7 +331,7 @@ static int ecryptfs_prepare_write(struct file *file, struct page *page, if (rc) { printk(KERN_ERR "%s: Error decrypting page " "at index [%ld]; rc = [%d]\n", - __func__, page->index, rc); + __FUNCTION__, page->index, rc); ClearPageUptodate(page); goto out; } @@ -348,7 +348,7 @@ static int ecryptfs_prepare_write(struct file *file, struct page *page, if (rc) { printk(KERN_ERR "%s: Error on attempt to " "truncate to (higher) offset [%lld];" - " rc = [%d]\n", __func__, + " rc = [%d]\n", __FUNCTION__, prev_page_end_size, rc); goto out; } @@ -389,7 +389,7 @@ static int ecryptfs_write_inode_size_to_header(struct inode *ecryptfs_inode) kfree(file_size_virt); if (rc) printk(KERN_ERR "%s: Error writing file size to header; " - "rc = [%d]\n", __func__, rc); + "rc = [%d]\n", __FUNCTION__, rc); out: return rc; } diff --git a/trunk/fs/ecryptfs/netlink.c b/trunk/fs/ecryptfs/netlink.c index e0abad62b395..f638a698dc52 100644 --- a/trunk/fs/ecryptfs/netlink.c +++ b/trunk/fs/ecryptfs/netlink.c @@ -44,8 +44,8 @@ static struct sock *ecryptfs_nl_sock; * upon sending the message; non-zero upon error. */ int ecryptfs_send_netlink(char *data, int data_len, - struct ecryptfs_msg_ctx *msg_ctx, u8 msg_type, - u16 msg_flags, struct pid *daemon_pid) + struct ecryptfs_msg_ctx *msg_ctx, u16 msg_type, + u16 msg_flags, pid_t daemon_pid) { struct sk_buff *skb; struct nlmsghdr *nlh; @@ -60,7 +60,7 @@ int ecryptfs_send_netlink(char *data, int data_len, ecryptfs_printk(KERN_ERR, "Failed to allocate socket buffer\n"); goto out; } - nlh = NLMSG_PUT(skb, pid_nr(daemon_pid), msg_ctx ? msg_ctx->counter : 0, + nlh = NLMSG_PUT(skb, daemon_pid, msg_ctx ? msg_ctx->counter : 0, msg_type, payload_len); nlh->nlmsg_flags = msg_flags; if (msg_ctx && payload_len) { @@ -69,7 +69,7 @@ int ecryptfs_send_netlink(char *data, int data_len, msg->data_len = data_len; memcpy(msg->data, data, data_len); } - rc = netlink_unicast(ecryptfs_nl_sock, skb, pid_nr(daemon_pid), 0); + rc = netlink_unicast(ecryptfs_nl_sock, skb, daemon_pid, 0); if (rc < 0) { ecryptfs_printk(KERN_ERR, "Failed to send eCryptfs netlink " "message; rc = [%d]\n", rc); @@ -99,7 +99,6 @@ static int ecryptfs_process_nl_response(struct sk_buff *skb) { struct nlmsghdr *nlh = nlmsg_hdr(skb); struct ecryptfs_message *msg = NLMSG_DATA(nlh); - struct pid *pid; int rc; if (skb->len - NLMSG_HDRLEN - sizeof(*msg) != msg->data_len) { @@ -108,10 +107,8 @@ static int ecryptfs_process_nl_response(struct sk_buff *skb) "incorrectly specified data length\n"); goto out; } - pid = find_get_pid(NETLINK_CREDS(skb)->pid); - rc = ecryptfs_process_response(msg, NETLINK_CREDS(skb)->uid, NULL, - pid, nlh->nlmsg_seq); - put_pid(pid); + rc = ecryptfs_process_response(msg, NETLINK_CREDS(skb)->uid, + NETLINK_CREDS(skb)->pid, nlh->nlmsg_seq); if (rc) printk(KERN_ERR "Error processing response message; rc = [%d]\n", rc); @@ -129,13 +126,11 @@ static int ecryptfs_process_nl_response(struct sk_buff *skb) */ static int ecryptfs_process_nl_helo(struct sk_buff *skb) { - struct pid *pid; int rc; - pid = find_get_pid(NETLINK_CREDS(skb)->pid); rc = ecryptfs_process_helo(ECRYPTFS_TRANSPORT_NETLINK, - NETLINK_CREDS(skb)->uid, NULL, pid); - put_pid(pid); + NETLINK_CREDS(skb)->uid, + NETLINK_CREDS(skb)->pid); if (rc) printk(KERN_WARNING "Error processing HELO; rc = [%d]\n", rc); return rc; @@ -152,12 +147,10 @@ static int ecryptfs_process_nl_helo(struct sk_buff *skb) */ static int ecryptfs_process_nl_quit(struct sk_buff *skb) { - struct pid *pid; int rc; - pid = find_get_pid(NETLINK_CREDS(skb)->pid); - rc = ecryptfs_process_quit(NETLINK_CREDS(skb)->uid, NULL, pid); - put_pid(pid); + rc = ecryptfs_process_quit(NETLINK_CREDS(skb)->uid, + NETLINK_CREDS(skb)->pid); if (rc) printk(KERN_WARNING "Error processing QUIT message; rc = [%d]\n", rc); @@ -183,20 +176,20 @@ static void ecryptfs_receive_nl_message(struct sk_buff *skb) goto free; } switch (nlh->nlmsg_type) { - case ECRYPTFS_MSG_RESPONSE: + case ECRYPTFS_NLMSG_RESPONSE: if (ecryptfs_process_nl_response(skb)) { ecryptfs_printk(KERN_WARNING, "Failed to " "deliver netlink response to " "requesting operation\n"); } break; - case ECRYPTFS_MSG_HELO: + case ECRYPTFS_NLMSG_HELO: if (ecryptfs_process_nl_helo(skb)) { ecryptfs_printk(KERN_WARNING, "Failed to " "fulfill HELO request\n"); } break; - case ECRYPTFS_MSG_QUIT: + case ECRYPTFS_NLMSG_QUIT: if (ecryptfs_process_nl_quit(skb)) { ecryptfs_printk(KERN_WARNING, "Failed to " "fulfill QUIT request\n"); diff --git a/trunk/fs/ecryptfs/read_write.c b/trunk/fs/ecryptfs/read_write.c index ebf55150be56..0c4928623bbc 100644 --- a/trunk/fs/ecryptfs/read_write.c +++ b/trunk/fs/ecryptfs/read_write.c @@ -55,7 +55,7 @@ int ecryptfs_write_lower(struct inode *ecryptfs_inode, char *data, set_fs(fs_save); if (octets_written < 0) { printk(KERN_ERR "%s: octets_written = [%td]; " - "expected [%td]\n", __func__, octets_written, size); + "expected [%td]\n", __FUNCTION__, octets_written, size); rc = -EINVAL; } mutex_unlock(&inode_info->lower_file_mutex); @@ -153,7 +153,7 @@ int ecryptfs_write(struct file *ecryptfs_file, char *data, loff_t offset, rc = PTR_ERR(ecryptfs_page); printk(KERN_ERR "%s: Error getting page at " "index [%ld] from eCryptfs inode " - "mapping; rc = [%d]\n", __func__, + "mapping; rc = [%d]\n", __FUNCTION__, ecryptfs_page_idx, rc); goto out; } @@ -165,7 +165,7 @@ int ecryptfs_write(struct file *ecryptfs_file, char *data, loff_t offset, if (rc) { printk(KERN_ERR "%s: Error decrypting " "page; rc = [%d]\n", - __func__, rc); + __FUNCTION__, rc); ClearPageUptodate(ecryptfs_page); page_cache_release(ecryptfs_page); goto out; @@ -202,7 +202,7 @@ int ecryptfs_write(struct file *ecryptfs_file, char *data, loff_t offset, page_cache_release(ecryptfs_page); if (rc) { printk(KERN_ERR "%s: Error encrypting " - "page; rc = [%d]\n", __func__, rc); + "page; rc = [%d]\n", __FUNCTION__, rc); goto out; } pos += num_bytes; @@ -254,7 +254,7 @@ int ecryptfs_read_lower(char *data, loff_t offset, size_t size, set_fs(fs_save); if (octets_read < 0) { printk(KERN_ERR "%s: octets_read = [%td]; " - "expected [%td]\n", __func__, octets_read, size); + "expected [%td]\n", __FUNCTION__, octets_read, size); rc = -EINVAL; } mutex_unlock(&inode_info->lower_file_mutex); @@ -327,7 +327,7 @@ int ecryptfs_read(char *data, loff_t offset, size_t size, printk(KERN_ERR "%s: Attempt to read data past the end of the " "file; offset = [%lld]; size = [%td]; " "ecryptfs_file_size = [%lld]\n", - __func__, offset, size, ecryptfs_file_size); + __FUNCTION__, offset, size, ecryptfs_file_size); goto out; } pos = offset; @@ -345,14 +345,14 @@ int ecryptfs_read(char *data, loff_t offset, size_t size, rc = PTR_ERR(ecryptfs_page); printk(KERN_ERR "%s: Error getting page at " "index [%ld] from eCryptfs inode " - "mapping; rc = [%d]\n", __func__, + "mapping; rc = [%d]\n", __FUNCTION__, ecryptfs_page_idx, rc); goto out; } rc = ecryptfs_decrypt_page(ecryptfs_page); if (rc) { printk(KERN_ERR "%s: Error decrypting " - "page; rc = [%d]\n", __func__, rc); + "page; rc = [%d]\n", __FUNCTION__, rc); ClearPageUptodate(ecryptfs_page); page_cache_release(ecryptfs_page); goto out; diff --git a/trunk/fs/eventpoll.c b/trunk/fs/eventpoll.c index 0d237182d721..a415f42d32cf 100644 --- a/trunk/fs/eventpoll.c +++ b/trunk/fs/eventpoll.c @@ -257,6 +257,25 @@ static inline int ep_cmp_ffd(struct epoll_filefd *p1, (p1->file < p2->file ? -1 : p1->fd - p2->fd)); } +/* Special initialization for the RB tree node to detect linkage */ +static inline void ep_rb_initnode(struct rb_node *n) +{ + rb_set_parent(n, n); +} + +/* Removes a node from the RB tree and marks it for a fast is-linked check */ +static inline void ep_rb_erase(struct rb_node *n, struct rb_root *r) +{ + rb_erase(n, r); + rb_set_parent(n, n); +} + +/* Fast check to verify that the item is linked to the main RB tree */ +static inline int ep_rb_linked(struct rb_node *n) +{ + return rb_parent(n) != n; +} + /* Tells us if the item is currently linked */ static inline int ep_is_linked(struct list_head *p) { @@ -264,13 +283,13 @@ static inline int ep_is_linked(struct list_head *p) } /* Get the "struct epitem" from a wait queue pointer */ -static inline struct epitem *ep_item_from_wait(wait_queue_t *p) +static inline struct epitem * ep_item_from_wait(wait_queue_t *p) { return container_of(p, struct eppoll_entry, wait)->base; } /* Get the "struct epitem" from an epoll queue wrapper */ -static inline struct epitem *ep_item_from_epqueue(poll_table *p) +static inline struct epitem * ep_item_from_epqueue(poll_table *p) { return container_of(p, struct ep_pqueue, pt)->epi; } @@ -392,7 +411,8 @@ static int ep_remove(struct eventpoll *ep, struct epitem *epi) list_del_init(&epi->fllink); spin_unlock(&file->f_ep_lock); - rb_erase(&epi->rbn, &ep->rbr); + if (ep_rb_linked(&epi->rbn)) + ep_rb_erase(&epi->rbn, &ep->rbr); spin_lock_irqsave(&ep->lock, flags); if (ep_is_linked(&epi->rdllink)) @@ -708,6 +728,7 @@ static int ep_insert(struct eventpoll *ep, struct epoll_event *event, goto error_return; /* Item initialization follow here ... */ + ep_rb_initnode(&epi->rbn); INIT_LIST_HEAD(&epi->rdllink); INIT_LIST_HEAD(&epi->fllink); INIT_LIST_HEAD(&epi->pwqlist); diff --git a/trunk/fs/exec.c b/trunk/fs/exec.c index a13883903ee9..b152029f18f6 100644 --- a/trunk/fs/exec.c +++ b/trunk/fs/exec.c @@ -735,7 +735,6 @@ static int exec_mmap(struct mm_struct *mm) tsk->active_mm = mm; activate_mm(active_mm, mm); task_unlock(tsk); - mm_update_next_owner(mm); arch_pick_mmap_layout(mm); if (old_mm) { up_read(&old_mm->mmap_sem); @@ -964,8 +963,6 @@ int flush_old_exec(struct linux_binprm * bprm) if (retval) goto out; - set_mm_exe_file(bprm->mm, bprm->file); - /* * Release all of the old mmap stuff */ @@ -1271,6 +1268,7 @@ int do_execve(char * filename, { struct linux_binprm *bprm; struct file *file; + unsigned long env_p; struct files_struct *displaced; int retval; @@ -1323,9 +1321,11 @@ int do_execve(char * filename, if (retval < 0) goto out; + env_p = bprm->p; retval = copy_strings(bprm->argc, argv, bprm); if (retval < 0) goto out; + bprm->argv_len = env_p - bprm->p; retval = search_binary_handler(bprm,regs); if (retval >= 0) { diff --git a/trunk/fs/ext4/mballoc.c b/trunk/fs/ext4/mballoc.c index 9d57695de746..ef97f19c2f9d 100644 --- a/trunk/fs/ext4/mballoc.c +++ b/trunk/fs/ext4/mballoc.c @@ -2449,10 +2449,17 @@ static void ext4_mb_history_init(struct super_block *sb) int i; if (sbi->s_mb_proc != NULL) { - proc_create_data("mb_history", S_IRUGO, sbi->s_mb_proc, - &ext4_mb_seq_history_fops, sb); - proc_create_data("mb_groups", S_IRUGO, sbi->s_mb_proc, - &ext4_mb_seq_groups_fops, sb); + struct proc_dir_entry *p; + p = create_proc_entry("mb_history", S_IRUGO, sbi->s_mb_proc); + if (p) { + p->proc_fops = &ext4_mb_seq_history_fops; + p->data = sb; + } + p = create_proc_entry("mb_groups", S_IRUGO, sbi->s_mb_proc); + if (p) { + p->proc_fops = &ext4_mb_seq_groups_fops; + p->data = sb; + } } sbi->s_mb_history_max = 1000; @@ -2860,6 +2867,7 @@ static void ext4_mb_free_committed_blocks(struct super_block *sb) mb_debug("freed %u blocks in %u structures\n", count, count2); } +#define EXT4_ROOT "ext4" #define EXT4_MB_STATS_NAME "stats" #define EXT4_MB_MAX_TO_SCAN_NAME "max_to_scan" #define EXT4_MB_MIN_TO_SCAN_NAME "min_to_scan" @@ -2999,9 +3007,9 @@ int __init init_ext4_mballoc(void) return -ENOMEM; } #ifdef CONFIG_PROC_FS - proc_root_ext4 = proc_mkdir("fs/ext4", NULL); + proc_root_ext4 = proc_mkdir(EXT4_ROOT, proc_root_fs); if (proc_root_ext4 == NULL) - printk(KERN_ERR "EXT4-fs: Unable to create fs/ext4\n"); + printk(KERN_ERR "EXT4-fs: Unable to create %s\n", EXT4_ROOT); #endif return 0; } @@ -3012,7 +3020,7 @@ void exit_ext4_mballoc(void) kmem_cache_destroy(ext4_pspace_cachep); kmem_cache_destroy(ext4_ac_cachep); #ifdef CONFIG_PROC_FS - remove_proc_entry("fs/ext4", NULL); + remove_proc_entry(EXT4_ROOT, proc_root_fs); #endif } diff --git a/trunk/fs/fat/inode.c b/trunk/fs/fat/inode.c index 4e0a3dd9d677..5f522a55b596 100644 --- a/trunk/fs/fat/inode.c +++ b/trunk/fs/fat/inode.c @@ -1222,7 +1222,8 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, brelse(bh); goto out_invalid; } - logical_sector_size = get_unaligned_le16(&b->sector_size); + logical_sector_size = + le16_to_cpu(get_unaligned((__le16 *)&b->sector_size)); if (!is_power_of_2(logical_sector_size) || (logical_sector_size < 512) || (logical_sector_size > 4096)) { @@ -1321,7 +1322,8 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, sbi->dir_per_block_bits = ffs(sbi->dir_per_block) - 1; sbi->dir_start = sbi->fat_start + sbi->fats * sbi->fat_length; - sbi->dir_entries = get_unaligned_le16(&b->dir_entries); + sbi->dir_entries = + le16_to_cpu(get_unaligned((__le16 *)&b->dir_entries)); if (sbi->dir_entries & (sbi->dir_per_block - 1)) { if (!silent) printk(KERN_ERR "FAT: bogus directroy-entries per block" @@ -1333,7 +1335,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, rootdir_sectors = sbi->dir_entries * sizeof(struct msdos_dir_entry) / sb->s_blocksize; sbi->data_start = sbi->dir_start + rootdir_sectors; - total_sectors = get_unaligned_le16(&b->sectors); + total_sectors = le16_to_cpu(get_unaligned((__le16 *)&b->sectors)); if (total_sectors == 0) total_sectors = le32_to_cpu(b->total_sect); diff --git a/trunk/fs/freevxfs/vxfs_extern.h b/trunk/fs/freevxfs/vxfs_extern.h index 50ab5eecb99b..2b46064f66b2 100644 --- a/trunk/fs/freevxfs/vxfs_extern.h +++ b/trunk/fs/freevxfs/vxfs_extern.h @@ -50,11 +50,7 @@ extern daddr_t vxfs_bmap1(struct inode *, long); /* vxfs_fshead.c */ extern int vxfs_read_fshead(struct super_block *); -/* vxfs_immed.c */ -extern const struct inode_operations vxfs_immed_symlink_iops; - /* vxfs_inode.c */ -extern const struct address_space_operations vxfs_immed_aops; extern struct kmem_cache *vxfs_inode_cachep; extern void vxfs_dumpi(struct vxfs_inode_info *, ino_t); extern struct inode * vxfs_get_fake_inode(struct super_block *, @@ -73,7 +69,6 @@ extern const struct file_operations vxfs_dir_operations; extern int vxfs_read_olt(struct super_block *, u_long); /* vxfs_subr.c */ -extern const struct address_space_operations vxfs_aops; extern struct page * vxfs_get_page(struct address_space *, u_long); extern void vxfs_put_page(struct page *); extern struct buffer_head * vxfs_bread(struct inode *, int); diff --git a/trunk/fs/freevxfs/vxfs_immed.c b/trunk/fs/freevxfs/vxfs_immed.c index c36aeaf92e41..8a5959a61ba9 100644 --- a/trunk/fs/freevxfs/vxfs_immed.c +++ b/trunk/fs/freevxfs/vxfs_immed.c @@ -35,7 +35,6 @@ #include #include "vxfs.h" -#include "vxfs_extern.h" #include "vxfs_inode.h" diff --git a/trunk/fs/freevxfs/vxfs_inode.c b/trunk/fs/freevxfs/vxfs_inode.c index 9f3f2ceb73f0..ad88d2364bc2 100644 --- a/trunk/fs/freevxfs/vxfs_inode.c +++ b/trunk/fs/freevxfs/vxfs_inode.c @@ -41,6 +41,11 @@ #include "vxfs_extern.h" +extern const struct address_space_operations vxfs_aops; +extern const struct address_space_operations vxfs_immed_aops; + +extern const struct inode_operations vxfs_immed_symlink_iops; + struct kmem_cache *vxfs_inode_cachep; diff --git a/trunk/fs/fs-writeback.c b/trunk/fs/fs-writeback.c index ae45f77765c0..06557679ca41 100644 --- a/trunk/fs/fs-writeback.c +++ b/trunk/fs/fs-writeback.c @@ -25,45 +25,6 @@ #include #include "internal.h" - -/** - * writeback_acquire - attempt to get exclusive writeback access to a device - * @bdi: the device's backing_dev_info structure - * - * It is a waste of resources to have more than one pdflush thread blocked on - * a single request queue. Exclusion at the request_queue level is obtained - * via a flag in the request_queue's backing_dev_info.state. - * - * Non-request_queue-backed address_spaces will share default_backing_dev_info, - * unless they implement their own. Which is somewhat inefficient, as this - * may prevent concurrent writeback against multiple devices. - */ -static int writeback_acquire(struct backing_dev_info *bdi) -{ - return !test_and_set_bit(BDI_pdflush, &bdi->state); -} - -/** - * writeback_in_progress - determine whether there is writeback in progress - * @bdi: the device's backing_dev_info structure. - * - * Determine whether there is writeback in progress against a backing device. - */ -int writeback_in_progress(struct backing_dev_info *bdi) -{ - return test_bit(BDI_pdflush, &bdi->state); -} - -/** - * writeback_release - relinquish exclusive writeback access against a device. - * @bdi: the device's backing_dev_info structure - */ -static void writeback_release(struct backing_dev_info *bdi) -{ - BUG_ON(!writeback_in_progress(bdi)); - clear_bit(BDI_pdflush, &bdi->state); -} - /** * __mark_inode_dirty - internal function * @inode: inode to mark @@ -786,4 +747,43 @@ int generic_osync_inode(struct inode *inode, struct address_space *mapping, int return err; } + EXPORT_SYMBOL(generic_osync_inode); + +/** + * writeback_acquire - attempt to get exclusive writeback access to a device + * @bdi: the device's backing_dev_info structure + * + * It is a waste of resources to have more than one pdflush thread blocked on + * a single request queue. Exclusion at the request_queue level is obtained + * via a flag in the request_queue's backing_dev_info.state. + * + * Non-request_queue-backed address_spaces will share default_backing_dev_info, + * unless they implement their own. Which is somewhat inefficient, as this + * may prevent concurrent writeback against multiple devices. + */ +int writeback_acquire(struct backing_dev_info *bdi) +{ + return !test_and_set_bit(BDI_pdflush, &bdi->state); +} + +/** + * writeback_in_progress - determine whether there is writeback in progress + * @bdi: the device's backing_dev_info structure. + * + * Determine whether there is writeback in progress against a backing device. + */ +int writeback_in_progress(struct backing_dev_info *bdi) +{ + return test_bit(BDI_pdflush, &bdi->state); +} + +/** + * writeback_release - relinquish exclusive writeback access against a device. + * @bdi: the device's backing_dev_info structure + */ +void writeback_release(struct backing_dev_info *bdi) +{ + BUG_ON(!writeback_in_progress(bdi)); + clear_bit(BDI_pdflush, &bdi->state); +} diff --git a/trunk/fs/hfs/super.c b/trunk/fs/hfs/super.c index 8cf67974adf6..32de44ed0021 100644 --- a/trunk/fs/hfs/super.c +++ b/trunk/fs/hfs/super.c @@ -297,8 +297,7 @@ static int parse_options(char *options, struct hfs_sb_info *hsb) return 0; } p = match_strdup(&args[0]); - if (p) - hsb->nls_disk = load_nls(p); + hsb->nls_disk = load_nls(p); if (!hsb->nls_disk) { printk(KERN_ERR "hfs: unable to load codepage \"%s\"\n", p); kfree(p); @@ -312,8 +311,7 @@ static int parse_options(char *options, struct hfs_sb_info *hsb) return 0; } p = match_strdup(&args[0]); - if (p) - hsb->nls_io = load_nls(p); + hsb->nls_io = load_nls(p); if (!hsb->nls_io) { printk(KERN_ERR "hfs: unable to load iocharset \"%s\"\n", p); kfree(p); diff --git a/trunk/fs/hfsplus/hfsplus_fs.h b/trunk/fs/hfsplus/hfsplus_fs.h index 9e59537b43d5..d72d0a8b25aa 100644 --- a/trunk/fs/hfsplus/hfsplus_fs.h +++ b/trunk/fs/hfsplus/hfsplus_fs.h @@ -311,10 +311,6 @@ int hfsplus_delete_cat(u32, struct inode *, struct qstr *); int hfsplus_rename_cat(u32, struct inode *, struct qstr *, struct inode *, struct qstr *); -/* dir.c */ -extern const struct inode_operations hfsplus_dir_inode_operations; -extern const struct file_operations hfsplus_dir_operations; - /* extents.c */ int hfsplus_ext_cmp_key(const hfsplus_btree_key *, const hfsplus_btree_key *); void hfsplus_ext_write_extent(struct inode *); diff --git a/trunk/fs/hfsplus/inode.c b/trunk/fs/hfsplus/inode.c index d53b2af91c25..37744cf3706a 100644 --- a/trunk/fs/hfsplus/inode.c +++ b/trunk/fs/hfsplus/inode.c @@ -278,6 +278,9 @@ static int hfsplus_file_release(struct inode *inode, struct file *file) return 0; } +extern const struct inode_operations hfsplus_dir_inode_operations; +extern struct file_operations hfsplus_dir_operations; + static const struct inode_operations hfsplus_file_inode_operations = { .lookup = hfsplus_file_lookup, .truncate = hfsplus_file_truncate, diff --git a/trunk/fs/hfsplus/options.c b/trunk/fs/hfsplus/options.c index 9997cbf8beb5..dc64fac00831 100644 --- a/trunk/fs/hfsplus/options.c +++ b/trunk/fs/hfsplus/options.c @@ -132,8 +132,7 @@ int hfsplus_parse_options(char *input, struct hfsplus_sb_info *sbi) return 0; } p = match_strdup(&args[0]); - if (p) - sbi->nls = load_nls(p); + sbi->nls = load_nls(p); if (!sbi->nls) { printk(KERN_ERR "hfs: unable to load nls mapping \"%s\"\n", p); kfree(p); diff --git a/trunk/fs/hfsplus/super.c b/trunk/fs/hfsplus/super.c index 946466cd9f25..b0f9ad362d1d 100644 --- a/trunk/fs/hfsplus/super.c +++ b/trunk/fs/hfsplus/super.c @@ -357,7 +357,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent) printk(KERN_WARNING "hfs: Filesystem is marked locked, mounting read-only.\n"); sb->s_flags |= MS_RDONLY; } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_JOURNALED)) { - printk(KERN_WARNING "hfs: write access to a journaled filesystem is not supported, " + printk(KERN_WARNING "hfs: write access to a jounaled filesystem is not supported, " "use the force option at your own risk, mounting read-only.\n"); sb->s_flags |= MS_RDONLY; } diff --git a/trunk/fs/hfsplus/wrapper.c b/trunk/fs/hfsplus/wrapper.c index 175d08eacc86..72cab78f0509 100644 --- a/trunk/fs/hfsplus/wrapper.c +++ b/trunk/fs/hfsplus/wrapper.c @@ -47,7 +47,7 @@ static int hfsplus_read_mdb(void *bufptr, struct hfsplus_wd *wd) return 0; wd->ablk_start = be16_to_cpu(*(__be16 *)(bufptr + HFSP_WRAPOFF_ABLKSTART)); - extent = get_unaligned_be32(bufptr + HFSP_WRAPOFF_EMBEDEXT); + extent = be32_to_cpu(get_unaligned((__be32 *)(bufptr + HFSP_WRAPOFF_EMBEDEXT))); wd->embed_start = (extent >> 16) & 0xFFFF; wd->embed_count = extent & 0xFFFF; diff --git a/trunk/fs/inode.c b/trunk/fs/inode.c index bf6478130424..27ee1af50d02 100644 --- a/trunk/fs/inode.c +++ b/trunk/fs/inode.c @@ -495,7 +495,8 @@ static struct inode * find_inode(struct super_block * sb, struct hlist_head *hea struct inode * inode = NULL; repeat: - hlist_for_each_entry(inode, node, head, i_hash) { + hlist_for_each (node, head) { + inode = hlist_entry(node, struct inode, i_hash); if (inode->i_sb != sb) continue; if (!test(inode, data)) @@ -519,7 +520,8 @@ static struct inode * find_inode_fast(struct super_block * sb, struct hlist_head struct inode * inode = NULL; repeat: - hlist_for_each_entry(inode, node, head, i_hash) { + hlist_for_each (node, head) { + inode = hlist_entry(node, struct inode, i_hash); if (inode->i_ino != ino) continue; if (inode->i_sb != sb) diff --git a/trunk/fs/inotify_user.c b/trunk/fs/inotify_user.c index 6676c06bb7c1..7b94a1e3c015 100644 --- a/trunk/fs/inotify_user.c +++ b/trunk/fs/inotify_user.c @@ -598,7 +598,7 @@ asmlinkage long sys_inotify_init(void) } ih = inotify_init(&inotify_user_ops); - if (IS_ERR(ih)) { + if (unlikely(IS_ERR(ih))) { ret = PTR_ERR(ih); goto out_free_dev; } diff --git a/trunk/fs/ioctl.c b/trunk/fs/ioctl.c index 7db32b3382d3..f32fbde2175e 100644 --- a/trunk/fs/ioctl.c +++ b/trunk/fs/ioctl.c @@ -28,8 +28,8 @@ * * Returns 0 on success, -errno on error. */ -static long vfs_ioctl(struct file *filp, unsigned int cmd, - unsigned long arg) +long vfs_ioctl(struct file *filp, unsigned int cmd, + unsigned long arg) { int error = -ENOTTY; diff --git a/trunk/fs/isofs/isofs.h b/trunk/fs/isofs/isofs.h index ccbf72faf27a..d1bdf8adb351 100644 --- a/trunk/fs/isofs/isofs.h +++ b/trunk/fs/isofs/isofs.h @@ -78,29 +78,29 @@ static inline int isonum_712(char *p) } static inline unsigned int isonum_721(char *p) { - return get_unaligned_le16(p); + return le16_to_cpu(get_unaligned((__le16 *)p)); } static inline unsigned int isonum_722(char *p) { - return get_unaligned_be16(p); + return be16_to_cpu(get_unaligned((__le16 *)p)); } static inline unsigned int isonum_723(char *p) { /* Ignore bigendian datum due to broken mastering programs */ - return get_unaligned_le16(p); + return le16_to_cpu(get_unaligned((__le16 *)p)); } static inline unsigned int isonum_731(char *p) { - return get_unaligned_le32(p); + return le32_to_cpu(get_unaligned((__le32 *)p)); } static inline unsigned int isonum_732(char *p) { - return get_unaligned_be32(p); + return be32_to_cpu(get_unaligned((__le32 *)p)); } static inline unsigned int isonum_733(char *p) { /* Ignore bigendian datum due to broken mastering programs */ - return get_unaligned_le32(p); + return le32_to_cpu(get_unaligned((__le32 *)p)); } extern int iso_date(char *, int); diff --git a/trunk/fs/jbd2/journal.c b/trunk/fs/jbd2/journal.c index eb7eb6c27bcb..954cff001df6 100644 --- a/trunk/fs/jbd2/journal.c +++ b/trunk/fs/jbd2/journal.c @@ -904,10 +904,19 @@ static void jbd2_stats_proc_init(journal_t *journal) snprintf(name, sizeof(name) - 1, "%s", bdevname(journal->j_dev, name)); journal->j_proc_entry = proc_mkdir(name, proc_jbd2_stats); if (journal->j_proc_entry) { - proc_create_data("history", S_IRUGO, journal->j_proc_entry, - &jbd2_seq_history_fops, journal); - proc_create_data("info", S_IRUGO, journal->j_proc_entry, - &jbd2_seq_info_fops, journal); + struct proc_dir_entry *p; + p = create_proc_entry("history", S_IRUGO, + journal->j_proc_entry); + if (p) { + p->proc_fops = &jbd2_seq_history_fops; + p->data = journal; + p = create_proc_entry("info", S_IRUGO, + journal->j_proc_entry); + if (p) { + p->proc_fops = &jbd2_seq_info_fops; + p->data = journal; + } + } } } diff --git a/trunk/fs/jfs/jfs_debug.c b/trunk/fs/jfs/jfs_debug.c index bf6ab19b86ee..887f5759e536 100644 --- a/trunk/fs/jfs/jfs_debug.c +++ b/trunk/fs/jfs/jfs_debug.c @@ -89,7 +89,7 @@ void jfs_proc_init(void) { int i; - if (!(base = proc_mkdir("fs/jfs", NULL))) + if (!(base = proc_mkdir("jfs", proc_root_fs))) return; base->owner = THIS_MODULE; @@ -109,7 +109,7 @@ void jfs_proc_clean(void) if (base) { for (i = 0; i < NPROCENT; i++) remove_proc_entry(Entries[i].name, base); - remove_proc_entry("fs/jfs", NULL); + remove_proc_entry("jfs", proc_root_fs); } } diff --git a/trunk/fs/namei.c b/trunk/fs/namei.c index 32fd9655485b..e179f71bfcb0 100644 --- a/trunk/fs/namei.c +++ b/trunk/fs/namei.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include @@ -282,10 +281,6 @@ int permission(struct inode *inode, int mask, struct nameidata *nd) if (retval) return retval; - retval = devcgroup_inode_permission(inode, mask); - if (retval) - return retval; - return security_inode_permission(inode, mask, nd); } @@ -2033,10 +2028,6 @@ int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) if (!dir->i_op || !dir->i_op->mknod) return -EPERM; - error = devcgroup_inode_mknod(mode, dev); - if (error) - return error; - error = security_inode_mknod(dir, dentry, mode, dev); if (error) return error; diff --git a/trunk/fs/namespace.c b/trunk/fs/namespace.c index 061e5edb4d27..fe376805cf5f 100644 --- a/trunk/fs/namespace.c +++ b/trunk/fs/namespace.c @@ -1176,6 +1176,17 @@ static int mount_is_safe(struct nameidata *nd) #endif } +static int lives_below_in_same_fs(struct dentry *d, struct dentry *dentry) +{ + while (1) { + if (d == dentry) + return 1; + if (d == NULL || d == d->d_parent) + return 0; + d = d->d_parent; + } +} + struct vfsmount *copy_tree(struct vfsmount *mnt, struct dentry *dentry, int flag) { @@ -1192,7 +1203,7 @@ struct vfsmount *copy_tree(struct vfsmount *mnt, struct dentry *dentry, p = mnt; list_for_each_entry(r, &mnt->mnt_mounts, mnt_child) { - if (!is_subdir(r->mnt_mountpoint, dentry)) + if (!lives_below_in_same_fs(r->mnt_mountpoint, dentry)) continue; for (s = r; s; s = next_mnt(s, r)) { diff --git a/trunk/fs/ncpfs/ncplib_kernel.c b/trunk/fs/ncpfs/ncplib_kernel.c index 97645f112114..df6d60bdfcd3 100644 --- a/trunk/fs/ncpfs/ncplib_kernel.c +++ b/trunk/fs/ncpfs/ncplib_kernel.c @@ -102,47 +102,48 @@ static inline void ncp_init_request_s(struct ncp_server *server, int subfunction } static inline char * -ncp_reply_data(struct ncp_server *server, int offset) + ncp_reply_data(struct ncp_server *server, int offset) { return &(server->packet[sizeof(struct ncp_reply_header) + offset]); } -static inline u8 BVAL(void *data) +static inline __u8 BVAL(void* data) { - return *(u8 *)data; + return get_unaligned((__u8*)data); } -static u8 ncp_reply_byte(struct ncp_server *server, int offset) +static __u8 + ncp_reply_byte(struct ncp_server *server, int offset) { - return *(u8 *)ncp_reply_data(server, offset); + return get_unaligned((__u8 *) ncp_reply_data(server, offset)); } -static inline u16 WVAL_LH(void *data) +static inline __u16 WVAL_LH(void* data) { - return get_unaligned_le16(data); + return le16_to_cpu(get_unaligned((__le16*)data)); } -static u16 -ncp_reply_le16(struct ncp_server *server, int offset) +static __u16 + ncp_reply_le16(struct ncp_server *server, int offset) { - return get_unaligned_le16(ncp_reply_data(server, offset)); + return le16_to_cpu(get_unaligned((__le16 *) ncp_reply_data(server, offset))); } -static u16 -ncp_reply_be16(struct ncp_server *server, int offset) +static __u16 + ncp_reply_be16(struct ncp_server *server, int offset) { - return get_unaligned_be16(ncp_reply_data(server, offset)); + return be16_to_cpu(get_unaligned((__be16 *) ncp_reply_data(server, offset))); } -static inline u32 DVAL_LH(void *data) +static inline __u32 DVAL_LH(void* data) { - return get_unaligned_le32(data); + return le32_to_cpu(get_unaligned((__le32*)data)); } static __le32 -ncp_reply_dword(struct ncp_server *server, int offset) + ncp_reply_dword(struct ncp_server *server, int offset) { - return get_unaligned((__le32 *)ncp_reply_data(server, offset)); + return get_unaligned((__le32 *) ncp_reply_data(server, offset)); } static inline __u32 ncp_reply_dword_lh(struct ncp_server* server, int offset) { @@ -1005,8 +1006,8 @@ ncp_read_bounce(struct ncp_server *server, const char *file_id, result = ncp_request2(server, 72, bounce, bufsize); ncp_unlock_server(server); if (!result) { - int len = get_unaligned_be16((char *)bounce + - sizeof(struct ncp_reply_header)); + int len = be16_to_cpu(get_unaligned((__be16*)((char*)bounce + + sizeof(struct ncp_reply_header)))); result = -EIO; if (len <= to_read) { char* source; diff --git a/trunk/fs/nfs/client.c b/trunk/fs/nfs/client.c index 89ac5bb0401c..f2f3b284e6dd 100644 --- a/trunk/fs/nfs/client.c +++ b/trunk/fs/nfs/client.c @@ -1321,7 +1321,6 @@ static const struct file_operations nfs_server_list_fops = { .read = seq_read, .llseek = seq_lseek, .release = seq_release, - .owner = THIS_MODULE, }; static int nfs_volume_list_open(struct inode *inode, struct file *file); @@ -1342,7 +1341,6 @@ static const struct file_operations nfs_volume_list_fops = { .read = seq_read, .llseek = seq_lseek, .release = seq_release, - .owner = THIS_MODULE, }; /* @@ -1502,29 +1500,33 @@ int __init nfs_fs_proc_init(void) { struct proc_dir_entry *p; - proc_fs_nfs = proc_mkdir("fs/nfsfs", NULL); + proc_fs_nfs = proc_mkdir("nfsfs", proc_root_fs); if (!proc_fs_nfs) goto error_0; proc_fs_nfs->owner = THIS_MODULE; /* a file of servers with which we're dealing */ - p = proc_create("servers", S_IFREG|S_IRUGO, - proc_fs_nfs, &nfs_server_list_fops); + p = create_proc_entry("servers", S_IFREG|S_IRUGO, proc_fs_nfs); if (!p) goto error_1; + p->proc_fops = &nfs_server_list_fops; + p->owner = THIS_MODULE; + /* a file of volumes that we have mounted */ - p = proc_create("volumes", S_IFREG|S_IRUGO, - proc_fs_nfs, &nfs_volume_list_fops); + p = create_proc_entry("volumes", S_IFREG|S_IRUGO, proc_fs_nfs); if (!p) goto error_2; + + p->proc_fops = &nfs_volume_list_fops; + p->owner = THIS_MODULE; return 0; error_2: remove_proc_entry("servers", proc_fs_nfs); error_1: - remove_proc_entry("fs/nfsfs", NULL); + remove_proc_entry("nfsfs", proc_root_fs); error_0: return -ENOMEM; } @@ -1536,7 +1538,7 @@ void nfs_fs_proc_exit(void) { remove_proc_entry("volumes", proc_fs_nfs); remove_proc_entry("servers", proc_fs_nfs); - remove_proc_entry("fs/nfsfs", NULL); + remove_proc_entry("nfsfs", proc_root_fs); } #endif /* CONFIG_PROC_FS */ diff --git a/trunk/fs/nfsd/nfsctl.c b/trunk/fs/nfsd/nfsctl.c index 5ac00c4fee91..42f3820ee8f5 100644 --- a/trunk/fs/nfsd/nfsctl.c +++ b/trunk/fs/nfsd/nfsctl.c @@ -169,7 +169,6 @@ static const struct file_operations exports_operations = { .read = seq_read, .llseek = seq_lseek, .release = seq_release, - .owner = THIS_MODULE, }; /*----------------------------------------------------------------------------*/ @@ -802,9 +801,10 @@ static int create_proc_exports_entry(void) entry = proc_mkdir("fs/nfs", NULL); if (!entry) return -ENOMEM; - entry = proc_create("exports", 0, entry, &exports_operations); + entry = create_proc_entry("fs/nfs/exports", 0, NULL); if (!entry) return -ENOMEM; + entry->proc_fops = &exports_operations; return 0; } #else /* CONFIG_PROC_FS */ diff --git a/trunk/fs/ntfs/mft.c b/trunk/fs/ntfs/mft.c index 790defb847e7..2ad5c8b104b9 100644 --- a/trunk/fs/ntfs/mft.c +++ b/trunk/fs/ntfs/mft.c @@ -1191,7 +1191,7 @@ static int ntfs_mft_bitmap_find_and_alloc_free_rec_nolock(ntfs_volume *vol, if (size) { page = ntfs_map_page(mftbmp_mapping, ofs >> PAGE_CACHE_SHIFT); - if (IS_ERR(page)) { + if (unlikely(IS_ERR(page))) { ntfs_error(vol->sb, "Failed to read mft " "bitmap, aborting."); return PTR_ERR(page); @@ -2118,7 +2118,7 @@ static int ntfs_mft_record_format(const ntfs_volume *vol, const s64 mft_no) } /* Read, map, and pin the page containing the mft record. */ page = ntfs_map_page(mft_vi->i_mapping, index); - if (IS_ERR(page)) { + if (unlikely(IS_ERR(page))) { ntfs_error(vol->sb, "Failed to map page containing mft record " "to format 0x%llx.", (long long)mft_no); return PTR_ERR(page); @@ -2519,7 +2519,7 @@ ntfs_inode *ntfs_mft_record_alloc(ntfs_volume *vol, const int mode, ofs = (bit << vol->mft_record_size_bits) & ~PAGE_CACHE_MASK; /* Read, map, and pin the page containing the mft record. */ page = ntfs_map_page(vol->mft_ino->i_mapping, index); - if (IS_ERR(page)) { + if (unlikely(IS_ERR(page))) { ntfs_error(vol->sb, "Failed to map page containing allocated " "mft record 0x%llx.", (long long)bit); err = PTR_ERR(page); diff --git a/trunk/fs/proc/base.c b/trunk/fs/proc/base.c index fcf02f2deeba..c5e412a00b17 100644 --- a/trunk/fs/proc/base.c +++ b/trunk/fs/proc/base.c @@ -195,32 +195,12 @@ static int proc_root_link(struct inode *inode, struct path *path) return result; } -/* - * Return zero if current may access user memory in @task, -error if not. - */ -static int check_mem_permission(struct task_struct *task) -{ - /* - * A task can always look at itself, in case it chooses - * to use system calls instead of load instructions. - */ - if (task == current) - return 0; - - /* - * If current is actively ptrace'ing, and would also be - * permitted to freshly attach with ptrace now, permit it. - */ - if (task->parent == current && (task->ptrace & PT_PTRACED) && - task_is_stopped_or_traced(task) && - ptrace_may_attach(task)) - return 0; - - /* - * Noone else is allowed. - */ - return -EPERM; -} +#define MAY_PTRACE(task) \ + (task == current || \ + (task->parent == current && \ + (task->ptrace & PT_PTRACED) && \ + (task_is_stopped_or_traced(task)) && \ + security_ptrace(current,task) == 0)) struct mm_struct *mm_for_maps(struct task_struct *task) { @@ -742,7 +722,7 @@ static ssize_t mem_read(struct file * file, char __user * buf, if (!task) goto out_no_task; - if (check_mem_permission(task)) + if (!MAY_PTRACE(task) || !ptrace_may_attach(task)) goto out; ret = -ENOMEM; @@ -768,7 +748,7 @@ static ssize_t mem_read(struct file * file, char __user * buf, this_len = (count > PAGE_SIZE) ? PAGE_SIZE : count; retval = access_process_vm(task, src, page, this_len, 0); - if (!retval || check_mem_permission(task)) { + if (!retval || !MAY_PTRACE(task) || !ptrace_may_attach(task)) { if (!ret) ret = -EIO; break; @@ -812,7 +792,7 @@ static ssize_t mem_write(struct file * file, const char __user *buf, if (!task) goto out_no_task; - if (check_mem_permission(task)) + if (!MAY_PTRACE(task) || !ptrace_may_attach(task)) goto out; copied = -ENOMEM; @@ -1201,81 +1181,6 @@ static const struct file_operations proc_pid_sched_operations = { #endif -/* - * We added or removed a vma mapping the executable. The vmas are only mapped - * during exec and are not mapped with the mmap system call. - * Callers must hold down_write() on the mm's mmap_sem for these - */ -void added_exe_file_vma(struct mm_struct *mm) -{ - mm->num_exe_file_vmas++; -} - -void removed_exe_file_vma(struct mm_struct *mm) -{ - mm->num_exe_file_vmas--; - if ((mm->num_exe_file_vmas == 0) && mm->exe_file){ - fput(mm->exe_file); - mm->exe_file = NULL; - } - -} - -void set_mm_exe_file(struct mm_struct *mm, struct file *new_exe_file) -{ - if (new_exe_file) - get_file(new_exe_file); - if (mm->exe_file) - fput(mm->exe_file); - mm->exe_file = new_exe_file; - mm->num_exe_file_vmas = 0; -} - -struct file *get_mm_exe_file(struct mm_struct *mm) -{ - struct file *exe_file; - - /* We need mmap_sem to protect against races with removal of - * VM_EXECUTABLE vmas */ - down_read(&mm->mmap_sem); - exe_file = mm->exe_file; - if (exe_file) - get_file(exe_file); - up_read(&mm->mmap_sem); - return exe_file; -} - -void dup_mm_exe_file(struct mm_struct *oldmm, struct mm_struct *newmm) -{ - /* It's safe to write the exe_file pointer without exe_file_lock because - * this is called during fork when the task is not yet in /proc */ - newmm->exe_file = get_mm_exe_file(oldmm); -} - -static int proc_exe_link(struct inode *inode, struct path *exe_path) -{ - struct task_struct *task; - struct mm_struct *mm; - struct file *exe_file; - - task = get_proc_task(inode); - if (!task) - return -ENOENT; - mm = get_task_mm(task); - put_task_struct(task); - if (!mm) - return -ENOENT; - exe_file = get_mm_exe_file(mm); - mmput(mm); - if (exe_file) { - *exe_path = exe_file->f_path; - path_get(&exe_file->f_path); - fput(exe_file); - return 0; - } else - return -ENOENT; -} - static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd) { struct inode *inode = dentry->d_inode; diff --git a/trunk/fs/proc/generic.c b/trunk/fs/proc/generic.c index 9d53b39a9cf8..a36ad3c75cf4 100644 --- a/trunk/fs/proc/generic.c +++ b/trunk/fs/proc/generic.c @@ -69,7 +69,12 @@ proc_file_read(struct file *file, char __user *buf, size_t nbytes, count = min_t(size_t, PROC_BLOCK_SIZE, nbytes); start = NULL; - if (dp->read_proc) { + if (dp->get_info) { + /* Handle old net routines */ + n = dp->get_info(page, &start, *ppos, count); + if (n < count) + eof = 1; + } else if (dp->read_proc) { /* * How to be a proc read function * ------------------------------ @@ -272,11 +277,8 @@ static int xlate_proc_name(const char *name, int len; int rtn = 0; - de = *ret; - if (!de) - de = &proc_root; - spin_lock(&proc_subdir_lock); + de = &proc_root; while (1) { next = strchr(cp, '/'); if (!next) @@ -383,18 +385,20 @@ struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir, lock_kernel(); spin_lock(&proc_subdir_lock); - for (de = de->subdir; de ; de = de->next) { - if (de->namelen != dentry->d_name.len) - continue; - if (!memcmp(dentry->d_name.name, de->name, de->namelen)) { - unsigned int ino; + if (de) { + for (de = de->subdir; de ; de = de->next) { + if (de->namelen != dentry->d_name.len) + continue; + if (!memcmp(dentry->d_name.name, de->name, de->namelen)) { + unsigned int ino; - ino = de->low_ino; - de_get(de); - spin_unlock(&proc_subdir_lock); - error = -EINVAL; - inode = proc_get_inode(dir->i_sb, ino, de); - goto out_unlock; + ino = de->low_ino; + de_get(de); + spin_unlock(&proc_subdir_lock); + error = -EINVAL; + inode = proc_get_inode(dir->i_sb, ino, de); + goto out_unlock; + } } } spin_unlock(&proc_subdir_lock); @@ -406,8 +410,7 @@ struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir, d_add(dentry, inode); return NULL; } - if (de) - de_put(de); + de_put(de); return ERR_PTR(error); } @@ -437,6 +440,10 @@ int proc_readdir_de(struct proc_dir_entry *de, struct file *filp, void *dirent, lock_kernel(); ino = inode->i_ino; + if (!de) { + ret = -EINVAL; + goto out; + } i = filp->f_pos; switch (i) { case 0: @@ -575,7 +582,7 @@ static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent, /* make sure name is valid */ if (!name || !strlen(name)) goto out; - if (xlate_proc_name(name, parent, &fn) != 0) + if (!(*parent) && xlate_proc_name(name, parent, &fn) != 0) goto out; /* At this point there must not be any '/' characters beyond *fn */ @@ -675,10 +682,9 @@ struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode, return ent; } -struct proc_dir_entry *proc_create_data(const char *name, mode_t mode, - struct proc_dir_entry *parent, - const struct file_operations *proc_fops, - void *data) +struct proc_dir_entry *proc_create(const char *name, mode_t mode, + struct proc_dir_entry *parent, + const struct file_operations *proc_fops) { struct proc_dir_entry *pde; nlink_t nlink; @@ -699,7 +705,6 @@ struct proc_dir_entry *proc_create_data(const char *name, mode_t mode, if (!pde) goto out; pde->proc_fops = proc_fops; - pde->data = data; if (proc_register(parent, pde) < 0) goto out_free; return pde; @@ -729,58 +734,55 @@ void free_proc_entry(struct proc_dir_entry *de) void remove_proc_entry(const char *name, struct proc_dir_entry *parent) { struct proc_dir_entry **p; - struct proc_dir_entry *de = NULL; + struct proc_dir_entry *de; const char *fn = name; int len; - if (xlate_proc_name(name, &parent, &fn) != 0) - return; + if (!parent && xlate_proc_name(name, &parent, &fn) != 0) + goto out; len = strlen(fn); spin_lock(&proc_subdir_lock); for (p = &parent->subdir; *p; p=&(*p)->next ) { - if (proc_match(len, fn, *p)) { - de = *p; - *p = de->next; - de->next = NULL; - break; - } - } - spin_unlock(&proc_subdir_lock); - if (!de) - return; - - spin_lock(&de->pde_unload_lock); - /* - * Stop accepting new callers into module. If you're - * dynamically allocating ->proc_fops, save a pointer somewhere. - */ - de->proc_fops = NULL; - /* Wait until all existing callers into module are done. */ - if (de->pde_users > 0) { - DECLARE_COMPLETION_ONSTACK(c); + if (!proc_match(len, fn, *p)) + continue; + de = *p; + *p = de->next; + de->next = NULL; + + spin_lock(&de->pde_unload_lock); + /* + * Stop accepting new callers into module. If you're + * dynamically allocating ->proc_fops, save a pointer somewhere. + */ + de->proc_fops = NULL; + /* Wait until all existing callers into module are done. */ + if (de->pde_users > 0) { + DECLARE_COMPLETION_ONSTACK(c); + + if (!de->pde_unload_completion) + de->pde_unload_completion = &c; + + spin_unlock(&de->pde_unload_lock); + spin_unlock(&proc_subdir_lock); - if (!de->pde_unload_completion) - de->pde_unload_completion = &c; + wait_for_completion(de->pde_unload_completion); + spin_lock(&proc_subdir_lock); + goto continue_removing; + } spin_unlock(&de->pde_unload_lock); - wait_for_completion(de->pde_unload_completion); - - goto continue_removing; - } - spin_unlock(&de->pde_unload_lock); - continue_removing: - if (S_ISDIR(de->mode)) - parent->nlink--; - de->nlink = 0; - if (de->subdir) { - printk(KERN_WARNING "%s: removing non-empty directory " - "'%s/%s', leaking at least '%s'\n", __func__, - de->parent->name, de->name, de->subdir->name); - WARN_ON(1); + if (S_ISDIR(de->mode)) + parent->nlink--; + de->nlink = 0; + WARN_ON(de->subdir); + if (atomic_dec_and_test(&de->count)) + free_proc_entry(de); + break; } - if (atomic_dec_and_test(&de->count)) - free_proc_entry(de); + spin_unlock(&proc_subdir_lock); +out: + return; } diff --git a/trunk/fs/proc/inode.c b/trunk/fs/proc/inode.c index 6f4e8dc97da1..82b3a1b5a70b 100644 --- a/trunk/fs/proc/inode.c +++ b/trunk/fs/proc/inode.c @@ -25,7 +25,8 @@ struct proc_dir_entry *de_get(struct proc_dir_entry *de) { - atomic_inc(&de->count); + if (de) + atomic_inc(&de->count); return de; } @@ -34,16 +35,18 @@ struct proc_dir_entry *de_get(struct proc_dir_entry *de) */ void de_put(struct proc_dir_entry *de) { - lock_kernel(); - if (!atomic_read(&de->count)) { - printk("de_put: entry %s already free!\n", de->name); + if (de) { + lock_kernel(); + if (!atomic_read(&de->count)) { + printk("de_put: entry %s already free!\n", de->name); + unlock_kernel(); + return; + } + + if (atomic_dec_and_test(&de->count)) + free_proc_entry(de); unlock_kernel(); - return; } - - if (atomic_dec_and_test(&de->count)) - free_proc_entry(de); - unlock_kernel(); } /* @@ -389,7 +392,7 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino, { struct inode * inode; - if (!try_module_get(de->owner)) + if (de != NULL && !try_module_get(de->owner)) goto out_mod; inode = iget_locked(sb, ino); @@ -399,29 +402,30 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino, inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; PROC_I(inode)->fd = 0; PROC_I(inode)->pde = de; - - if (de->mode) { - inode->i_mode = de->mode; - inode->i_uid = de->uid; - inode->i_gid = de->gid; - } - if (de->size) - inode->i_size = de->size; - if (de->nlink) - inode->i_nlink = de->nlink; - if (de->proc_iops) - inode->i_op = de->proc_iops; - if (de->proc_fops) { - if (S_ISREG(inode->i_mode)) { + if (de) { + if (de->mode) { + inode->i_mode = de->mode; + inode->i_uid = de->uid; + inode->i_gid = de->gid; + } + if (de->size) + inode->i_size = de->size; + if (de->nlink) + inode->i_nlink = de->nlink; + if (de->proc_iops) + inode->i_op = de->proc_iops; + if (de->proc_fops) { + if (S_ISREG(inode->i_mode)) { #ifdef CONFIG_COMPAT - if (!de->proc_fops->compat_ioctl) - inode->i_fop = - &proc_reg_file_ops_no_compat; - else + if (!de->proc_fops->compat_ioctl) + inode->i_fop = + &proc_reg_file_ops_no_compat; + else #endif - inode->i_fop = &proc_reg_file_ops; - } else { - inode->i_fop = de->proc_fops; + inode->i_fop = &proc_reg_file_ops; + } else { + inode->i_fop = de->proc_fops; + } } } unlock_new_inode(inode); @@ -429,7 +433,8 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino, return inode; out_ino: - module_put(de->owner); + if (de != NULL) + module_put(de->owner); out_mod: return NULL; } diff --git a/trunk/fs/proc/internal.h b/trunk/fs/proc/internal.h index 28cbca805905..bc72f5c8c47d 100644 --- a/trunk/fs/proc/internal.h +++ b/trunk/fs/proc/internal.h @@ -11,7 +11,6 @@ #include -extern struct proc_dir_entry proc_root; #ifdef CONFIG_PROC_SYSCTL extern int proc_sys_init(void); #else @@ -47,6 +46,9 @@ extern int nommu_vma_show(struct seq_file *, struct vm_area_struct *); extern int maps_protect; +extern void create_seq_entry(char *name, mode_t mode, + const struct file_operations *f); +extern int proc_exe_link(struct inode *, struct path *); extern int proc_tid_stat(struct seq_file *m, struct pid_namespace *ns, struct pid *pid, struct task_struct *task); extern int proc_tgid_stat(struct seq_file *m, struct pid_namespace *ns, diff --git a/trunk/fs/proc/nommu.c b/trunk/fs/proc/nommu.c index 79ecd281d2cb..941e95114b5a 100644 --- a/trunk/fs/proc/nommu.c +++ b/trunk/fs/proc/nommu.c @@ -137,7 +137,7 @@ static const struct file_operations proc_nommu_vma_list_operations = { static int __init proc_nommu_init(void) { - proc_create("maps", S_IRUGO, NULL, &proc_nommu_vma_list_operations); + create_seq_entry("maps", S_IRUGO, &proc_nommu_vma_list_operations); return 0; } diff --git a/trunk/fs/proc/proc_misc.c b/trunk/fs/proc/proc_misc.c index 48bcf20cec2f..441a32f0e5f2 100644 --- a/trunk/fs/proc/proc_misc.c +++ b/trunk/fs/proc/proc_misc.c @@ -826,6 +826,14 @@ static struct file_operations proc_kpageflags_operations = { struct proc_dir_entry *proc_root_kcore; +void create_seq_entry(char *name, mode_t mode, const struct file_operations *f) +{ + struct proc_dir_entry *entry; + entry = create_proc_entry(name, mode, NULL); + if (entry) + entry->proc_fops = f; +} + void __init proc_misc_init(void) { static struct { @@ -854,52 +862,66 @@ void __init proc_misc_init(void) /* And now for trickier ones */ #ifdef CONFIG_PRINTK - proc_create("kmsg", S_IRUSR, NULL, &proc_kmsg_operations); + { + struct proc_dir_entry *entry; + entry = create_proc_entry("kmsg", S_IRUSR, &proc_root); + if (entry) + entry->proc_fops = &proc_kmsg_operations; + } #endif - proc_create("locks", 0, NULL, &proc_locks_operations); - proc_create("devices", 0, NULL, &proc_devinfo_operations); - proc_create("cpuinfo", 0, NULL, &proc_cpuinfo_operations); + create_seq_entry("locks", 0, &proc_locks_operations); + create_seq_entry("devices", 0, &proc_devinfo_operations); + create_seq_entry("cpuinfo", 0, &proc_cpuinfo_operations); #ifdef CONFIG_BLOCK - proc_create("partitions", 0, NULL, &proc_partitions_operations); + create_seq_entry("partitions", 0, &proc_partitions_operations); #endif - proc_create("stat", 0, NULL, &proc_stat_operations); - proc_create("interrupts", 0, NULL, &proc_interrupts_operations); + create_seq_entry("stat", 0, &proc_stat_operations); + create_seq_entry("interrupts", 0, &proc_interrupts_operations); #ifdef CONFIG_SLABINFO - proc_create("slabinfo",S_IWUSR|S_IRUGO,NULL,&proc_slabinfo_operations); + create_seq_entry("slabinfo",S_IWUSR|S_IRUGO,&proc_slabinfo_operations); #ifdef CONFIG_DEBUG_SLAB_LEAK - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations); + create_seq_entry("slab_allocators", 0 ,&proc_slabstats_operations); #endif #endif #ifdef CONFIG_MMU proc_create("vmallocinfo", S_IRUSR, NULL, &proc_vmalloc_operations); #endif - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations); - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops); - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations); - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations); + create_seq_entry("buddyinfo",S_IRUGO, &fragmentation_file_operations); + create_seq_entry("pagetypeinfo", S_IRUGO, &pagetypeinfo_file_ops); + create_seq_entry("vmstat",S_IRUGO, &proc_vmstat_file_operations); + create_seq_entry("zoneinfo",S_IRUGO, &proc_zoneinfo_file_operations); #ifdef CONFIG_BLOCK - proc_create("diskstats", 0, NULL, &proc_diskstats_operations); + create_seq_entry("diskstats", 0, &proc_diskstats_operations); #endif #ifdef CONFIG_MODULES - proc_create("modules", 0, NULL, &proc_modules_operations); + create_seq_entry("modules", 0, &proc_modules_operations); #endif #ifdef CONFIG_SCHEDSTATS - proc_create("schedstat", 0, NULL, &proc_schedstat_operations); + create_seq_entry("schedstat", 0, &proc_schedstat_operations); #endif #ifdef CONFIG_PROC_KCORE - proc_root_kcore = proc_create("kcore", S_IRUSR, NULL, &proc_kcore_operations); - if (proc_root_kcore) + proc_root_kcore = create_proc_entry("kcore", S_IRUSR, NULL); + if (proc_root_kcore) { + proc_root_kcore->proc_fops = &proc_kcore_operations; proc_root_kcore->size = (size_t)high_memory - PAGE_OFFSET + PAGE_SIZE; + } #endif #ifdef CONFIG_PROC_PAGE_MONITOR - proc_create("kpagecount", S_IRUSR, NULL, &proc_kpagecount_operations); - proc_create("kpageflags", S_IRUSR, NULL, &proc_kpageflags_operations); + create_seq_entry("kpagecount", S_IRUSR, &proc_kpagecount_operations); + create_seq_entry("kpageflags", S_IRUSR, &proc_kpageflags_operations); #endif #ifdef CONFIG_PROC_VMCORE - proc_vmcore = proc_create("vmcore", S_IRUSR, NULL, &proc_vmcore_operations); + proc_vmcore = create_proc_entry("vmcore", S_IRUSR, NULL); + if (proc_vmcore) + proc_vmcore->proc_fops = &proc_vmcore_operations; #endif #ifdef CONFIG_MAGIC_SYSRQ - proc_create("sysrq-trigger", S_IWUSR, NULL, &proc_sysrq_trigger_operations); + { + struct proc_dir_entry *entry; + entry = create_proc_entry("sysrq-trigger", S_IWUSR, NULL); + if (entry) + entry->proc_fops = &proc_sysrq_trigger_operations; + } #endif } diff --git a/trunk/fs/proc/proc_sysctl.c b/trunk/fs/proc/proc_sysctl.c index 5acc001d49f6..614c34b6d1c2 100644 --- a/trunk/fs/proc/proc_sysctl.c +++ b/trunk/fs/proc/proc_sysctl.c @@ -165,8 +165,8 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry, return err; } -static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf, - size_t count, loff_t *ppos, int write) +static ssize_t proc_sys_read(struct file *filp, char __user *buf, + size_t count, loff_t *ppos) { struct dentry *dentry = filp->f_dentry; struct ctl_table_header *head; @@ -190,12 +190,12 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf, * and won't be until we finish. */ error = -EPERM; - if (sysctl_perm(head->root, table, write ? MAY_WRITE : MAY_READ)) + if (sysctl_perm(table, MAY_READ)) goto out; /* careful: calling conventions are nasty here */ res = count; - error = table->proc_handler(table, write, filp, buf, &res, ppos); + error = table->proc_handler(table, 0, filp, buf, &res, ppos); if (!error) error = res; out: @@ -204,16 +204,44 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf, return error; } -static ssize_t proc_sys_read(struct file *filp, char __user *buf, - size_t count, loff_t *ppos) -{ - return proc_sys_call_handler(filp, (void __user *)buf, count, ppos, 0); -} - static ssize_t proc_sys_write(struct file *filp, const char __user *buf, size_t count, loff_t *ppos) { - return proc_sys_call_handler(filp, (void __user *)buf, count, ppos, 1); + struct dentry *dentry = filp->f_dentry; + struct ctl_table_header *head; + struct ctl_table *table; + ssize_t error; + size_t res; + + table = do_proc_sys_lookup(dentry->d_parent, &dentry->d_name, &head); + /* Has the sysctl entry disappeared on us? */ + error = -ENOENT; + if (!table) + goto out; + + /* Has the sysctl entry been replaced by a directory? */ + error = -EISDIR; + if (!table->proc_handler) + goto out; + + /* + * At this point we know that the sysctl was not unregistered + * and won't be until we finish. + */ + error = -EPERM; + if (sysctl_perm(table, MAY_WRITE)) + goto out; + + /* careful: calling conventions are nasty here */ + res = count; + error = table->proc_handler(table, 1, filp, (char __user *)buf, + &res, ppos); + if (!error) + error = res; +out: + sysctl_head_finish(head); + + return error; } @@ -388,7 +416,7 @@ static int proc_sys_permission(struct inode *inode, int mask, struct nameidata * goto out; /* Use the permissions on the sysctl table entry */ - error = sysctl_perm(head->root, table, mask); + error = sysctl_perm(table, mask); out: sysctl_head_finish(head); return error; diff --git a/trunk/fs/proc/proc_tty.c b/trunk/fs/proc/proc_tty.c index ac26ccc25f42..49816e00b51a 100644 --- a/trunk/fs/proc/proc_tty.c +++ b/trunk/fs/proc/proc_tty.c @@ -5,7 +5,7 @@ */ #include -#include + #include #include #include @@ -136,54 +136,39 @@ static const struct file_operations proc_tty_drivers_operations = { .release = seq_release, }; -static void * tty_ldiscs_seq_start(struct seq_file *m, loff_t *pos) -{ - return (*pos < NR_LDISCS) ? pos : NULL; -} - -static void * tty_ldiscs_seq_next(struct seq_file *m, void *v, loff_t *pos) -{ - (*pos)++; - return (*pos < NR_LDISCS) ? pos : NULL; -} - -static void tty_ldiscs_seq_stop(struct seq_file *m, void *v) -{ -} - -static int tty_ldiscs_seq_show(struct seq_file *m, void *v) +/* + * This is the handler for /proc/tty/ldiscs + */ +static int tty_ldiscs_read_proc(char *page, char **start, off_t off, + int count, int *eof, void *data) { - int i = *(loff_t *)v; + int i; + int len = 0; + off_t begin = 0; struct tty_ldisc *ld; - ld = tty_ldisc_get(i); - if (ld == NULL) + for (i=0; i < NR_LDISCS; i++) { + ld = tty_ldisc_get(i); + if (ld == NULL) + continue; + len += sprintf(page+len, "%-10s %2d\n", + ld->name ? ld->name : "???", i); + tty_ldisc_put(i); + if (len+begin > off+count) + break; + if (len+begin < off) { + begin += len; + len = 0; + } + } + if (i >= NR_LDISCS) + *eof = 1; + if (off >= len+begin) return 0; - seq_printf(m, "%-10s %2d\n", ld->name ? ld->name : "???", i); - tty_ldisc_put(i); - return 0; -} - -static const struct seq_operations tty_ldiscs_seq_ops = { - .start = tty_ldiscs_seq_start, - .next = tty_ldiscs_seq_next, - .stop = tty_ldiscs_seq_stop, - .show = tty_ldiscs_seq_show, -}; - -static int proc_tty_ldiscs_open(struct inode *inode, struct file *file) -{ - return seq_open(file, &tty_ldiscs_seq_ops); + *start = page + (off-begin); + return ((count < begin+len-off) ? count : begin+len-off); } -static const struct file_operations tty_ldiscs_proc_fops = { - .owner = THIS_MODULE, - .open = proc_tty_ldiscs_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release, -}; - /* * This function is called by tty_register_driver() to handle * registering the driver's /proc handler into /proc/tty/driver/ @@ -229,6 +214,7 @@ void proc_tty_unregister_driver(struct tty_driver *driver) */ void __init proc_tty_init(void) { + struct proc_dir_entry *entry; if (!proc_mkdir("tty", NULL)) return; proc_tty_ldisc = proc_mkdir("tty/ldisc", NULL); @@ -238,7 +224,10 @@ void __init proc_tty_init(void) * password lengths and inter-keystroke timings during password * entry. */ - proc_tty_driver = proc_mkdir_mode("tty/driver", S_IRUSR|S_IXUSR, NULL); - proc_create("tty/ldiscs", 0, NULL, &tty_ldiscs_proc_fops); - proc_create("tty/drivers", 0, NULL, &proc_tty_drivers_operations); + proc_tty_driver = proc_mkdir_mode("tty/driver", S_IRUSR | S_IXUSR, NULL); + + create_proc_read_entry("tty/ldiscs", 0, NULL, tty_ldiscs_read_proc, NULL); + entry = create_proc_entry("tty/drivers", 0, NULL); + if (entry) + entry->proc_fops = &proc_tty_drivers_operations; } diff --git a/trunk/fs/proc/root.c b/trunk/fs/proc/root.c index 95117538a4f6..ef0fb57fc9ef 100644 --- a/trunk/fs/proc/root.c +++ b/trunk/fs/proc/root.c @@ -22,6 +22,8 @@ #include "internal.h" +struct proc_dir_entry *proc_bus, *proc_root_fs, *proc_root_driver; + static int proc_test_super(struct super_block *sb, void *data) { return sb->s_fs_info == data; @@ -124,8 +126,8 @@ void __init proc_root_init(void) #ifdef CONFIG_SYSVIPC proc_mkdir("sysvipc", NULL); #endif - proc_mkdir("fs", NULL); - proc_mkdir("driver", NULL); + proc_root_fs = proc_mkdir("fs", NULL); + proc_root_driver = proc_mkdir("driver", NULL); proc_mkdir("fs/nfsd", NULL); /* somewhere for the nfsd filesystem to be mounted */ #if defined(CONFIG_SUN_OPENPROMFS) || defined(CONFIG_SUN_OPENPROMFS_MODULE) /* just give it a mountpoint */ @@ -135,7 +137,7 @@ void __init proc_root_init(void) #ifdef CONFIG_PROC_DEVICETREE proc_device_tree_init(); #endif - proc_mkdir("bus", NULL); + proc_bus = proc_mkdir("bus", NULL); proc_sys_init(); } @@ -230,5 +232,9 @@ void pid_ns_release_proc(struct pid_namespace *ns) EXPORT_SYMBOL(proc_symlink); EXPORT_SYMBOL(proc_mkdir); EXPORT_SYMBOL(create_proc_entry); -EXPORT_SYMBOL(proc_create_data); +EXPORT_SYMBOL(proc_create); EXPORT_SYMBOL(remove_proc_entry); +EXPORT_SYMBOL(proc_root); +EXPORT_SYMBOL(proc_root_fs); +EXPORT_SYMBOL(proc_bus); +EXPORT_SYMBOL(proc_root_driver); diff --git a/trunk/fs/proc/task_mmu.c b/trunk/fs/proc/task_mmu.c index e2b8e769f510..7415eeb7cc3a 100644 --- a/trunk/fs/proc/task_mmu.c +++ b/trunk/fs/proc/task_mmu.c @@ -75,6 +75,40 @@ int task_statm(struct mm_struct *mm, int *shared, int *text, return mm->total_vm; } +int proc_exe_link(struct inode *inode, struct path *path) +{ + struct vm_area_struct * vma; + int result = -ENOENT; + struct task_struct *task = get_proc_task(inode); + struct mm_struct * mm = NULL; + + if (task) { + mm = get_task_mm(task); + put_task_struct(task); + } + if (!mm) + goto out; + down_read(&mm->mmap_sem); + + vma = mm->mmap; + while (vma) { + if ((vma->vm_flags & VM_EXECUTABLE) && vma->vm_file) + break; + vma = vma->vm_next; + } + + if (vma) { + *path = vma->vm_file->f_path; + path_get(&vma->vm_file->f_path); + result = 0; + } + + up_read(&mm->mmap_sem); + mmput(mm); +out: + return result; +} + static void pad_len_spaces(struct seq_file *m, int len) { len = 25 + sizeof(void*) * 6 - len; diff --git a/trunk/fs/proc/task_nommu.c b/trunk/fs/proc/task_nommu.c index 4b733f108455..8011528518bd 100644 --- a/trunk/fs/proc/task_nommu.c +++ b/trunk/fs/proc/task_nommu.c @@ -103,6 +103,40 @@ int task_statm(struct mm_struct *mm, int *shared, int *text, return size; } +int proc_exe_link(struct inode *inode, struct path *path) +{ + struct vm_list_struct *vml; + struct vm_area_struct *vma; + struct task_struct *task = get_proc_task(inode); + struct mm_struct *mm = get_task_mm(task); + int result = -ENOENT; + + if (!mm) + goto out; + down_read(&mm->mmap_sem); + + vml = mm->context.vmlist; + vma = NULL; + while (vml) { + if ((vml->vma->vm_flags & VM_EXECUTABLE) && vml->vma->vm_file) { + vma = vml->vma; + break; + } + vml = vml->next; + } + + if (vma) { + *path = vma->vm_file->f_path; + path_get(&vma->vm_file->f_path); + result = 0; + } + + up_read(&mm->mmap_sem); + mmput(mm); +out: + return result; +} + /* * display mapping lines for a particular process's /proc/pid/maps */ diff --git a/trunk/fs/ramfs/file-mmu.c b/trunk/fs/ramfs/file-mmu.c index 9590b9024300..b41a514b0976 100644 --- a/trunk/fs/ramfs/file-mmu.c +++ b/trunk/fs/ramfs/file-mmu.c @@ -26,9 +26,6 @@ #include #include -#include - -#include "internal.h" const struct address_space_operations ramfs_aops = { .readpage = simple_readpage, diff --git a/trunk/fs/ramfs/internal.h b/trunk/fs/ramfs/internal.h index 6b330639b51d..af7cc074a476 100644 --- a/trunk/fs/ramfs/internal.h +++ b/trunk/fs/ramfs/internal.h @@ -11,4 +11,5 @@ extern const struct address_space_operations ramfs_aops; +extern const struct file_operations ramfs_file_operations; extern const struct inode_operations ramfs_file_inode_operations; diff --git a/trunk/fs/reiserfs/procfs.c b/trunk/fs/reiserfs/procfs.c index b9dbeeca7049..8f86c52b30d8 100644 --- a/trunk/fs/reiserfs/procfs.c +++ b/trunk/fs/reiserfs/procfs.c @@ -467,7 +467,6 @@ static const struct file_operations r_file_operations = { .read = seq_read, .llseek = seq_lseek, .release = seq_release, - .owner = THIS_MODULE, }; static struct proc_dir_entry *proc_info_root = NULL; @@ -476,8 +475,12 @@ static const char proc_info_root_name[] = "fs/reiserfs"; static void add_file(struct super_block *sb, char *name, int (*func) (struct seq_file *, struct super_block *)) { - proc_create_data(name, 0, REISERFS_SB(sb)->procdir, - &r_file_operations, func); + struct proc_dir_entry *de; + de = create_proc_entry(name, 0, REISERFS_SB(sb)->procdir); + if (de) { + de->data = func; + de->proc_fops = &r_file_operations; + } } int reiserfs_proc_info_init(struct super_block *sb) diff --git a/trunk/fs/splice.c b/trunk/fs/splice.c index 633f58ebfb72..eeb1a86a7014 100644 --- a/trunk/fs/splice.c +++ b/trunk/fs/splice.c @@ -1075,7 +1075,7 @@ long do_splice_direct(struct file *in, loff_t *ppos, struct file *out, ret = splice_direct_to_actor(in, &sd, direct_splice_actor); if (ret > 0) - *ppos = sd.pos; + *ppos += ret; return ret; } diff --git a/trunk/fs/super.c b/trunk/fs/super.c index 453877c5697b..a5a4aca7e22f 100644 --- a/trunk/fs/super.c +++ b/trunk/fs/super.c @@ -117,7 +117,7 @@ static inline void destroy_super(struct super_block *s) * Drop a superblock's refcount. Returns non-zero if the superblock was * destroyed. The caller must hold sb_lock. */ -static int __put_super(struct super_block *sb) +int __put_super(struct super_block *sb) { int ret = 0; diff --git a/trunk/fs/sync.c b/trunk/fs/sync.c index 228e17b5e9ee..7cd005ea7639 100644 --- a/trunk/fs/sync.c +++ b/trunk/fs/sync.c @@ -64,7 +64,7 @@ int file_fsync(struct file *filp, struct dentry *dentry, int datasync) /* sync the superblock to buffers */ sb = inode->i_sb; lock_super(sb); - if (sb->s_dirt && sb->s_op->write_super) + if (sb->s_op->write_super) sb->s_op->write_super(sb); unlock_super(sb); diff --git a/trunk/fs/timerfd.c b/trunk/fs/timerfd.c index 5400524e9cb1..10c80b59ec4b 100644 --- a/trunk/fs/timerfd.c +++ b/trunk/fs/timerfd.c @@ -20,7 +20,6 @@ #include #include #include -#include struct timerfd_ctx { struct hrtimer tmr; diff --git a/trunk/fs/xattr.c b/trunk/fs/xattr.c index 4706a8b1f495..89a942f07e1b 100644 --- a/trunk/fs/xattr.c +++ b/trunk/fs/xattr.c @@ -67,7 +67,7 @@ xattr_permission(struct inode *inode, const char *name, int mask) } int -vfs_setxattr(struct dentry *dentry, const char *name, const void *value, +vfs_setxattr(struct dentry *dentry, char *name, void *value, size_t size, int flags) { struct inode *inode = dentry->d_inode; @@ -131,7 +131,7 @@ xattr_getsecurity(struct inode *inode, const char *name, void *value, EXPORT_SYMBOL_GPL(xattr_getsecurity); ssize_t -vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size) +vfs_getxattr(struct dentry *dentry, char *name, void *value, size_t size) { struct inode *inode = dentry->d_inode; int error; @@ -187,7 +187,7 @@ vfs_listxattr(struct dentry *d, char *list, size_t size) EXPORT_SYMBOL_GPL(vfs_listxattr); int -vfs_removexattr(struct dentry *dentry, const char *name) +vfs_removexattr(struct dentry *dentry, char *name) { struct inode *inode = dentry->d_inode; int error; @@ -218,7 +218,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr); * Extended attribute SET operations */ static long -setxattr(struct dentry *d, const char __user *name, const void __user *value, +setxattr(struct dentry *d, char __user *name, void __user *value, size_t size, int flags) { int error; @@ -252,8 +252,8 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value, } asmlinkage long -sys_setxattr(const char __user *path, const char __user *name, - const void __user *value, size_t size, int flags) +sys_setxattr(char __user *path, char __user *name, void __user *value, + size_t size, int flags) { struct nameidata nd; int error; @@ -271,8 +271,8 @@ sys_setxattr(const char __user *path, const char __user *name, } asmlinkage long -sys_lsetxattr(const char __user *path, const char __user *name, - const void __user *value, size_t size, int flags) +sys_lsetxattr(char __user *path, char __user *name, void __user *value, + size_t size, int flags) { struct nameidata nd; int error; @@ -290,7 +290,7 @@ sys_lsetxattr(const char __user *path, const char __user *name, } asmlinkage long -sys_fsetxattr(int fd, const char __user *name, const void __user *value, +sys_fsetxattr(int fd, char __user *name, void __user *value, size_t size, int flags) { struct file *f; @@ -315,8 +315,7 @@ sys_fsetxattr(int fd, const char __user *name, const void __user *value, * Extended attribute GET operations */ static ssize_t -getxattr(struct dentry *d, const char __user *name, void __user *value, - size_t size) +getxattr(struct dentry *d, char __user *name, void __user *value, size_t size) { ssize_t error; void *kvalue = NULL; @@ -350,8 +349,8 @@ getxattr(struct dentry *d, const char __user *name, void __user *value, } asmlinkage ssize_t -sys_getxattr(const char __user *path, const char __user *name, - void __user *value, size_t size) +sys_getxattr(char __user *path, char __user *name, void __user *value, + size_t size) { struct nameidata nd; ssize_t error; @@ -365,7 +364,7 @@ sys_getxattr(const char __user *path, const char __user *name, } asmlinkage ssize_t -sys_lgetxattr(const char __user *path, const char __user *name, void __user *value, +sys_lgetxattr(char __user *path, char __user *name, void __user *value, size_t size) { struct nameidata nd; @@ -380,7 +379,7 @@ sys_lgetxattr(const char __user *path, const char __user *name, void __user *val } asmlinkage ssize_t -sys_fgetxattr(int fd, const char __user *name, void __user *value, size_t size) +sys_fgetxattr(int fd, char __user *name, void __user *value, size_t size) { struct file *f; ssize_t error = -EBADF; @@ -425,7 +424,7 @@ listxattr(struct dentry *d, char __user *list, size_t size) } asmlinkage ssize_t -sys_listxattr(const char __user *path, char __user *list, size_t size) +sys_listxattr(char __user *path, char __user *list, size_t size) { struct nameidata nd; ssize_t error; @@ -439,7 +438,7 @@ sys_listxattr(const char __user *path, char __user *list, size_t size) } asmlinkage ssize_t -sys_llistxattr(const char __user *path, char __user *list, size_t size) +sys_llistxattr(char __user *path, char __user *list, size_t size) { struct nameidata nd; ssize_t error; @@ -471,7 +470,7 @@ sys_flistxattr(int fd, char __user *list, size_t size) * Extended attribute REMOVE operations */ static long -removexattr(struct dentry *d, const char __user *name) +removexattr(struct dentry *d, char __user *name) { int error; char kname[XATTR_NAME_MAX + 1]; @@ -486,7 +485,7 @@ removexattr(struct dentry *d, const char __user *name) } asmlinkage long -sys_removexattr(const char __user *path, const char __user *name) +sys_removexattr(char __user *path, char __user *name) { struct nameidata nd; int error; @@ -504,7 +503,7 @@ sys_removexattr(const char __user *path, const char __user *name) } asmlinkage long -sys_lremovexattr(const char __user *path, const char __user *name) +sys_lremovexattr(char __user *path, char __user *name) { struct nameidata nd; int error; @@ -522,7 +521,7 @@ sys_lremovexattr(const char __user *path, const char __user *name) } asmlinkage long -sys_fremovexattr(int fd, const char __user *name) +sys_fremovexattr(int fd, char __user *name) { struct file *f; struct dentry *dentry; diff --git a/trunk/fs/xfs/linux-2.6/xfs_vnode.h b/trunk/fs/xfs/linux-2.6/xfs_vnode.h index 8b4d63ce8694..9d73cb5c0fc7 100644 --- a/trunk/fs/xfs/linux-2.6/xfs_vnode.h +++ b/trunk/fs/xfs/linux-2.6/xfs_vnode.h @@ -25,12 +25,6 @@ struct attrlist_cursor_kern; typedef struct inode bhv_vnode_t; -#define VN_ISLNK(vp) S_ISLNK((vp)->i_mode) -#define VN_ISREG(vp) S_ISREG((vp)->i_mode) -#define VN_ISDIR(vp) S_ISDIR((vp)->i_mode) -#define VN_ISCHR(vp) S_ISCHR((vp)->i_mode) -#define VN_ISBLK(vp) S_ISBLK((vp)->i_mode) - /* * Vnode to Linux inode mapping. */ @@ -151,24 +145,6 @@ typedef struct bhv_vattr { XFS_AT_TYPE|XFS_AT_BLKSIZE|XFS_AT_NBLOCKS|XFS_AT_VCODE|\ XFS_AT_NEXTENTS|XFS_AT_ANEXTENTS|XFS_AT_GENCOUNT) -/* - * Modes. - */ -#define VSUID S_ISUID /* set user id on execution */ -#define VSGID S_ISGID /* set group id on execution */ -#define VSVTX S_ISVTX /* save swapped text even after use */ -#define VREAD S_IRUSR /* read, write, execute permissions */ -#define VWRITE S_IWUSR -#define VEXEC S_IXUSR - -#define MODEMASK S_IALLUGO /* mode bits plus permission bits */ - -/* - * Check whether mandatory file locking is enabled. - */ -#define MANDLOCK(vp, mode) \ - (VN_ISREG(vp) && ((mode) & (VSGID|(VEXEC>>3))) == VSGID) - extern void vn_init(void); extern int vn_revalidate(bhv_vnode_t *); diff --git a/trunk/fs/xfs/xfs_acl.c b/trunk/fs/xfs/xfs_acl.c index 8e130b9720ae..b1275cc45617 100644 --- a/trunk/fs/xfs/xfs_acl.c +++ b/trunk/fs/xfs/xfs_acl.c @@ -72,7 +72,7 @@ xfs_acl_vhasacl_default( { int error; - if (!VN_ISDIR(vp)) + if (!S_ISDIR(vp->i_mode)) return 0; xfs_acl_get_attr(vp, NULL, _ACL_TYPE_DEFAULT, ATTR_KERNOVAL, &error); return (error == 0); @@ -379,7 +379,7 @@ xfs_acl_allow_set( if (vp->i_flags & (S_IMMUTABLE|S_APPEND)) return EPERM; - if (kind == _ACL_TYPE_DEFAULT && !VN_ISDIR(vp)) + if (kind == _ACL_TYPE_DEFAULT && !S_ISDIR(vp->i_mode)) return ENOTDIR; if (vp->i_sb->s_flags & MS_RDONLY) return EROFS; @@ -719,7 +719,7 @@ xfs_acl_inherit( * If the new file is a directory, its default ACL is a copy of * the containing directory's default ACL. */ - if (VN_ISDIR(vp)) + if (S_ISDIR(vp->i_mode)) xfs_acl_set_attr(vp, pdaclp, _ACL_TYPE_DEFAULT, &error); if (!error && !basicperms) xfs_acl_set_attr(vp, cacl, _ACL_TYPE_ACCESS, &error); diff --git a/trunk/fs/xfs/xfs_vnodeops.c b/trunk/fs/xfs/xfs_vnodeops.c index 6650601c64f7..3fef54b11582 100644 --- a/trunk/fs/xfs/xfs_vnodeops.c +++ b/trunk/fs/xfs/xfs_vnodeops.c @@ -211,7 +211,6 @@ xfs_setattr( int flags, cred_t *credp) { - bhv_vnode_t *vp = XFS_ITOV(ip); xfs_mount_t *mp = ip->i_mount; xfs_trans_t *tp; int mask; @@ -222,7 +221,6 @@ xfs_setattr( gid_t gid=0, igid=0; int timeflags = 0; xfs_prid_t projid=0, iprojid=0; - int mandlock_before, mandlock_after; struct xfs_dquot *udqp, *gdqp, *olddquot1, *olddquot2; int file_owner; int need_iolock = 1; @@ -383,7 +381,7 @@ xfs_setattr( m |= S_ISGID; #if 0 /* Linux allows this, Irix doesn't. */ - if ((vap->va_mode & S_ISVTX) && !VN_ISDIR(vp)) + if ((vap->va_mode & S_ISVTX) && !S_ISDIR(ip->i_d.di_mode)) m |= S_ISVTX; #endif if (m && !capable(CAP_FSETID)) @@ -461,10 +459,10 @@ xfs_setattr( goto error_return; } - if (VN_ISDIR(vp)) { + if (S_ISDIR(ip->i_d.di_mode)) { code = XFS_ERROR(EISDIR); goto error_return; - } else if (!VN_ISREG(vp)) { + } else if (!S_ISREG(ip->i_d.di_mode)) { code = XFS_ERROR(EINVAL); goto error_return; } @@ -626,9 +624,6 @@ xfs_setattr( xfs_trans_ihold(tp, ip); } - /* determine whether mandatory locking mode changes */ - mandlock_before = MANDLOCK(vp, ip->i_d.di_mode); - /* * Truncate file. Must have write permission and not be a directory. */ @@ -858,13 +853,6 @@ xfs_setattr( code = xfs_trans_commit(tp, commit_flags); } - /* - * If the (regular) file's mandatory locking mode changed, then - * notify the vnode. We do this under the inode lock to prevent - * racing calls to vop_vnode_change. - */ - mandlock_after = MANDLOCK(vp, ip->i_d.di_mode); - xfs_iunlock(ip, lock_flags); /* @@ -1491,7 +1479,7 @@ xfs_release( xfs_mount_t *mp = ip->i_mount; int error; - if (!VN_ISREG(vp) || (ip->i_d.di_mode == 0)) + if (!S_ISREG(ip->i_d.di_mode) || (ip->i_d.di_mode == 0)) return 0; /* If this is a read-only mount, don't do this (would generate I/O) */ diff --git a/trunk/include/asm-alpha/unaligned.h b/trunk/include/asm-alpha/unaligned.h index 3787c60aed3f..a1d72846f61c 100644 --- a/trunk/include/asm-alpha/unaligned.h +++ b/trunk/include/asm-alpha/unaligned.h @@ -1,11 +1,6 @@ -#ifndef _ASM_ALPHA_UNALIGNED_H -#define _ASM_ALPHA_UNALIGNED_H +#ifndef __ALPHA_UNALIGNED_H +#define __ALPHA_UNALIGNED_H -#include -#include -#include +#include -#define get_unaligned __get_unaligned_le -#define put_unaligned __put_unaligned_le - -#endif /* _ASM_ALPHA_UNALIGNED_H */ +#endif diff --git a/trunk/include/asm-arm/arch-orion5x/io.h b/trunk/include/asm-arm/arch-orion5x/io.h index 50f8c8802206..5148ab7ad1f8 100644 --- a/trunk/include/asm-arm/arch-orion5x/io.h +++ b/trunk/include/asm-arm/arch-orion5x/io.h @@ -20,10 +20,11 @@ static inline void __iomem * __arch_ioremap(unsigned long paddr, size_t size, unsigned int mtype) { void __iomem *retval; - unsigned long offs = paddr - ORION5X_REGS_PHYS_BASE; - if (mtype == MT_DEVICE && size && offs < ORION5X_REGS_SIZE && - size <= ORION5X_REGS_SIZE && offs + size <= ORION5X_REGS_SIZE) { - retval = (void __iomem *)ORION5X_REGS_VIRT_BASE + offs; + + if (mtype == MT_DEVICE && size && paddr >= ORION5X_REGS_PHYS_BASE && + paddr + size <= ORION5X_REGS_PHYS_BASE + ORION5X_REGS_SIZE) { + retval = (void __iomem *)ORION5X_REGS_VIRT_BASE + + (paddr - ORION5X_REGS_PHYS_BASE); } else { retval = __arm_ioremap(paddr, size, mtype); } diff --git a/trunk/include/asm-arm/arch-pxa/irqs.h b/trunk/include/asm-arm/arch-pxa/irqs.h index b6c8fe377683..50c77eacbd5e 100644 --- a/trunk/include/asm-arm/arch-pxa/irqs.h +++ b/trunk/include/asm-arm/arch-pxa/irqs.h @@ -239,7 +239,7 @@ /* ITE8152 irqs */ /* add IT8152 IRQs beyond BOARD_END */ #ifdef CONFIG_PCI_HOST_ITE8152 -#define IT8152_IRQ(x) (IRQ_BOARD_END + (x)) +#define IT8152_IRQ(x) (IRQ_GPIO(IRQ_BOARD_END) + 1 + (x)) /* IRQ-sources in 3 groups - local devices, LPC (serial), and external PCI */ #define IT8152_LD_IRQ_COUNT 9 @@ -253,9 +253,6 @@ #define IT8152_LAST_IRQ IT8152_LD_IRQ(IT8152_LD_IRQ_COUNT - 1) -#if NR_IRQS < (IT8152_LAST_IRQ+1) #undef NR_IRQS #define NR_IRQS (IT8152_LAST_IRQ+1) #endif - -#endif /* CONFIG_PCI_HOST_ITE8152 */ diff --git a/trunk/include/asm-arm/arch-pxa/magician.h b/trunk/include/asm-arm/arch-pxa/magician.h index 169b374f9921..b34fd5683e2d 100644 --- a/trunk/include/asm-arm/arch-pxa/magician.h +++ b/trunk/include/asm-arm/arch-pxa/magician.h @@ -13,6 +13,7 @@ #define _MAGICIAN_H_ #include +#include /* * PXA GPIOs @@ -62,6 +63,54 @@ #define GPIO119_MAGICIAN_UNKNOWN 119 #define GPIO120_MAGICIAN_UNKNOWN 120 +/* + * PXA GPIO alternate function mode & direction + */ + +#define GPIO0_MAGICIAN_KEY_POWER_MD (0 | GPIO_IN) +#define GPIO9_MAGICIAN_UNKNOWN_MD (9 | GPIO_IN) +#define GPIO10_MAGICIAN_GSM_IRQ_MD (10 | GPIO_IN) +#define GPIO11_MAGICIAN_GSM_OUT1_MD (11 | GPIO_OUT) +#define GPIO13_MAGICIAN_CPLD_IRQ_MD (13 | GPIO_IN) +#define GPIO18_MAGICIAN_UNKNOWN_MD (18 | GPIO_OUT) +#define GPIO22_MAGICIAN_VIBRA_EN_MD (22 | GPIO_OUT) +#define GPIO26_MAGICIAN_GSM_POWER_MD (26 | GPIO_OUT) +#define GPIO27_MAGICIAN_USBC_PUEN_MD (27 | GPIO_OUT) +#define GPIO30_MAGICIAN_nCHARGE_EN_MD (30 | GPIO_OUT) +#define GPIO37_MAGICIAN_KEY_HANGUP_MD (37 | GPIO_OUT) +#define GPIO38_MAGICIAN_KEY_CONTACTS_MD (38 | GPIO_OUT) +#define GPIO40_MAGICIAN_GSM_OUT2_MD (40 | GPIO_OUT) +#define GPIO48_MAGICIAN_UNKNOWN_MD (48 | GPIO_OUT) +#define GPIO56_MAGICIAN_UNKNOWN_MD (56 | GPIO_OUT) +#define GPIO57_MAGICIAN_CAM_RESET_MD (57 | GPIO_OUT) +#define GPIO75_MAGICIAN_SAMSUNG_POWER_MD (75 | GPIO_OUT) +#define GPIO83_MAGICIAN_nIR_EN_MD (83 | GPIO_OUT) +#define GPIO86_MAGICIAN_GSM_RESET_MD (86 | GPIO_OUT) +#define GPIO87_MAGICIAN_GSM_SELECT_MD (87 | GPIO_OUT) +#define GPIO90_MAGICIAN_KEY_CALENDAR_MD (90 | GPIO_OUT) +#define GPIO91_MAGICIAN_KEY_CAMERA_MD (91 | GPIO_OUT) +#define GPIO93_MAGICIAN_KEY_UP_MD (93 | GPIO_IN) +#define GPIO94_MAGICIAN_KEY_DOWN_MD (94 | GPIO_IN) +#define GPIO95_MAGICIAN_KEY_LEFT_MD (95 | GPIO_IN) +#define GPIO96_MAGICIAN_KEY_RIGHT_MD (96 | GPIO_IN) +#define GPIO97_MAGICIAN_KEY_ENTER_MD (97 | GPIO_IN) +#define GPIO98_MAGICIAN_KEY_RECORD_MD (98 | GPIO_IN) +#define GPIO99_MAGICIAN_HEADPHONE_IN_MD (99 | GPIO_IN) +#define GPIO100_MAGICIAN_KEY_VOL_UP_MD (100 | GPIO_IN) +#define GPIO101_MAGICIAN_KEY_VOL_DOWN_MD (101 | GPIO_IN) +#define GPIO102_MAGICIAN_KEY_PHONE_MD (102 | GPIO_IN) +#define GPIO103_MAGICIAN_LED_KP_MD (103 | GPIO_OUT) +#define GPIO104_MAGICIAN_LCD_POWER_1_MD (104 | GPIO_OUT) +#define GPIO105_MAGICIAN_LCD_POWER_2_MD (105 | GPIO_OUT) +#define GPIO106_MAGICIAN_LCD_POWER_3_MD (106 | GPIO_OUT) +#define GPIO107_MAGICIAN_DS1WM_IRQ_MD (107 | GPIO_IN) +#define GPIO108_MAGICIAN_GSM_READY_MD (108 | GPIO_IN) +#define GPIO114_MAGICIAN_UNKNOWN_MD (114 | GPIO_OUT) +#define GPIO115_MAGICIAN_nPEN_IRQ_MD (115 | GPIO_IN) +#define GPIO116_MAGICIAN_nCAM_EN_MD (116 | GPIO_OUT) +#define GPIO119_MAGICIAN_UNKNOWN_MD (119 | GPIO_OUT) +#define GPIO120_MAGICIAN_UNKNOWN_MD (120 | GPIO_OUT) + /* * CPLD IRQs */ diff --git a/trunk/include/asm-arm/arch-pxa/system.h b/trunk/include/asm-arm/arch-pxa/system.h index a758a719180f..1d56a3ef89fd 100644 --- a/trunk/include/asm-arm/arch-pxa/system.h +++ b/trunk/include/asm-arm/arch-pxa/system.h @@ -22,8 +22,6 @@ static inline void arch_idle(void) static inline void arch_reset(char mode) { - RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR; - if (mode == 's') { /* Jump into ROM at address 0 */ cpu_reset(0); diff --git a/trunk/include/asm-arm/page.h b/trunk/include/asm-arm/page.h index 5c22b0112106..c86f68ee6511 100644 --- a/trunk/include/asm-arm/page.h +++ b/trunk/include/asm-arm/page.h @@ -71,14 +71,6 @@ # endif #endif -#ifdef CONFIG_CPU_COPY_FEROCEON -# ifdef _USER -# define MULTI_USER 1 -# else -# define _USER feroceon -# endif -#endif - #ifdef CONFIG_CPU_SA1100 # ifdef _USER # define MULTI_USER 1 diff --git a/trunk/include/asm-arm/unaligned.h b/trunk/include/asm-arm/unaligned.h index 44593a894903..5db03cf3b905 100644 --- a/trunk/include/asm-arm/unaligned.h +++ b/trunk/include/asm-arm/unaligned.h @@ -1,9 +1,171 @@ -#ifndef _ASM_ARM_UNALIGNED_H -#define _ASM_ARM_UNALIGNED_H +#ifndef __ASM_ARM_UNALIGNED_H +#define __ASM_ARM_UNALIGNED_H -#include -#include -#include +#include + +extern int __bug_unaligned_x(const void *ptr); + +/* + * What is the most efficient way of loading/storing an unaligned value? + * + * That is the subject of this file. Efficiency here is defined as + * minimum code size with minimum register usage for the common cases. + * It is currently not believed that long longs are common, so we + * trade efficiency for the chars, shorts and longs against the long + * longs. + * + * Current stats with gcc 2.7.2.2 for these functions: + * + * ptrsize get: code regs put: code regs + * 1 1 1 1 2 + * 2 3 2 3 2 + * 4 7 3 7 3 + * 8 20 6 16 6 + * + * gcc 2.95.1 seems to code differently: + * + * ptrsize get: code regs put: code regs + * 1 1 1 1 2 + * 2 3 2 3 2 + * 4 7 4 7 4 + * 8 19 8 15 6 + * + * which may or may not be more efficient (depending upon whether + * you can afford the extra registers). Hopefully the gcc 2.95 + * is inteligent enough to decide if it is better to use the + * extra register, but evidence so far seems to suggest otherwise. + * + * Unfortunately, gcc is not able to optimise the high word + * out of long long >> 32, or the low word from long long << 32 + */ + +#define __get_unaligned_2_le(__p) \ + (unsigned int)(__p[0] | __p[1] << 8) + +#define __get_unaligned_2_be(__p) \ + (unsigned int)(__p[0] << 8 | __p[1]) + +#define __get_unaligned_4_le(__p) \ + (unsigned int)(__p[0] | __p[1] << 8 | __p[2] << 16 | __p[3] << 24) + +#define __get_unaligned_4_be(__p) \ + (unsigned int)(__p[0] << 24 | __p[1] << 16 | __p[2] << 8 | __p[3]) + +#define __get_unaligned_8_le(__p) \ + ((unsigned long long)__get_unaligned_4_le((__p+4)) << 32 | \ + __get_unaligned_4_le(__p)) + +#define __get_unaligned_8_be(__p) \ + ((unsigned long long)__get_unaligned_4_be(__p) << 32 | \ + __get_unaligned_4_be((__p+4))) + +#define __get_unaligned_le(ptr) \ + ((__force typeof(*(ptr)))({ \ + const __u8 *__p = (const __u8 *)(ptr); \ + __builtin_choose_expr(sizeof(*(ptr)) == 1, *__p, \ + __builtin_choose_expr(sizeof(*(ptr)) == 2, __get_unaligned_2_le(__p), \ + __builtin_choose_expr(sizeof(*(ptr)) == 4, __get_unaligned_4_le(__p), \ + __builtin_choose_expr(sizeof(*(ptr)) == 8, __get_unaligned_8_le(__p), \ + (void)__bug_unaligned_x(__p))))); \ + })) + +#define __get_unaligned_be(ptr) \ + ((__force typeof(*(ptr)))({ \ + const __u8 *__p = (const __u8 *)(ptr); \ + __builtin_choose_expr(sizeof(*(ptr)) == 1, *__p, \ + __builtin_choose_expr(sizeof(*(ptr)) == 2, __get_unaligned_2_be(__p), \ + __builtin_choose_expr(sizeof(*(ptr)) == 4, __get_unaligned_4_be(__p), \ + __builtin_choose_expr(sizeof(*(ptr)) == 8, __get_unaligned_8_be(__p), \ + (void)__bug_unaligned_x(__p))))); \ + })) + + +static inline void __put_unaligned_2_le(__u32 __v, register __u8 *__p) +{ + *__p++ = __v; + *__p++ = __v >> 8; +} + +static inline void __put_unaligned_2_be(__u32 __v, register __u8 *__p) +{ + *__p++ = __v >> 8; + *__p++ = __v; +} + +static inline void __put_unaligned_4_le(__u32 __v, register __u8 *__p) +{ + __put_unaligned_2_le(__v >> 16, __p + 2); + __put_unaligned_2_le(__v, __p); +} + +static inline void __put_unaligned_4_be(__u32 __v, register __u8 *__p) +{ + __put_unaligned_2_be(__v >> 16, __p); + __put_unaligned_2_be(__v, __p + 2); +} + +static inline void __put_unaligned_8_le(const unsigned long long __v, register __u8 *__p) +{ + /* + * tradeoff: 8 bytes of stack for all unaligned puts (2 + * instructions), or an extra register in the long long + * case - go for the extra register. + */ + __put_unaligned_4_le(__v >> 32, __p+4); + __put_unaligned_4_le(__v, __p); +} + +static inline void __put_unaligned_8_be(const unsigned long long __v, register __u8 *__p) +{ + /* + * tradeoff: 8 bytes of stack for all unaligned puts (2 + * instructions), or an extra register in the long long + * case - go for the extra register. + */ + __put_unaligned_4_be(__v >> 32, __p); + __put_unaligned_4_be(__v, __p+4); +} + +/* + * Try to store an unaligned value as efficiently as possible. + */ +#define __put_unaligned_le(val,ptr) \ + ({ \ + (void)sizeof(*(ptr) = (val)); \ + switch (sizeof(*(ptr))) { \ + case 1: \ + *(ptr) = (val); \ + break; \ + case 2: __put_unaligned_2_le((__force u16)(val),(__u8 *)(ptr)); \ + break; \ + case 4: __put_unaligned_4_le((__force u32)(val),(__u8 *)(ptr)); \ + break; \ + case 8: __put_unaligned_8_le((__force u64)(val),(__u8 *)(ptr)); \ + break; \ + default: __bug_unaligned_x(ptr); \ + break; \ + } \ + (void) 0; \ + }) + +#define __put_unaligned_be(val,ptr) \ + ({ \ + (void)sizeof(*(ptr) = (val)); \ + switch (sizeof(*(ptr))) { \ + case 1: \ + *(ptr) = (val); \ + break; \ + case 2: __put_unaligned_2_be((__force u16)(val),(__u8 *)(ptr)); \ + break; \ + case 4: __put_unaligned_4_be((__force u32)(val),(__u8 *)(ptr)); \ + break; \ + case 8: __put_unaligned_8_be((__force u64)(val),(__u8 *)(ptr)); \ + break; \ + default: __bug_unaligned_x(ptr); \ + break; \ + } \ + (void) 0; \ + }) /* * Select endianness @@ -16,4 +178,4 @@ #define put_unaligned __put_unaligned_be #endif -#endif /* _ASM_ARM_UNALIGNED_H */ +#endif diff --git a/trunk/include/asm-avr32/unaligned.h b/trunk/include/asm-avr32/unaligned.h index 041877290470..36f5fd430543 100644 --- a/trunk/include/asm-avr32/unaligned.h +++ b/trunk/include/asm-avr32/unaligned.h @@ -1,5 +1,5 @@ -#ifndef _ASM_AVR32_UNALIGNED_H -#define _ASM_AVR32_UNALIGNED_H +#ifndef __ASM_AVR32_UNALIGNED_H +#define __ASM_AVR32_UNALIGNED_H /* * AVR32 can handle some unaligned accesses, depending on the @@ -11,11 +11,6 @@ * optimize word loads in general. */ -#include -#include -#include +#include -#define get_unaligned __get_unaligned_be -#define put_unaligned __put_unaligned_be - -#endif /* _ASM_AVR32_UNALIGNED_H */ +#endif /* __ASM_AVR32_UNALIGNED_H */ diff --git a/trunk/include/asm-blackfin/unaligned.h b/trunk/include/asm-blackfin/unaligned.h index fd8a1d634945..10081dc241ef 100644 --- a/trunk/include/asm-blackfin/unaligned.h +++ b/trunk/include/asm-blackfin/unaligned.h @@ -1,11 +1,6 @@ -#ifndef _ASM_BLACKFIN_UNALIGNED_H -#define _ASM_BLACKFIN_UNALIGNED_H +#ifndef __BFIN_UNALIGNED_H +#define __BFIN_UNALIGNED_H -#include -#include -#include +#include -#define get_unaligned __get_unaligned_le -#define put_unaligned __put_unaligned_le - -#endif /* _ASM_BLACKFIN_UNALIGNED_H */ +#endif /* __BFIN_UNALIGNED_H */ diff --git a/trunk/include/asm-cris/unaligned.h b/trunk/include/asm-cris/unaligned.h index 7b3f3fec567c..7fbbb399f6f1 100644 --- a/trunk/include/asm-cris/unaligned.h +++ b/trunk/include/asm-cris/unaligned.h @@ -1,13 +1,16 @@ -#ifndef _ASM_CRIS_UNALIGNED_H -#define _ASM_CRIS_UNALIGNED_H +#ifndef __CRIS_UNALIGNED_H +#define __CRIS_UNALIGNED_H /* * CRIS can do unaligned accesses itself. + * + * The strange macros are there to make sure these can't + * be misused in a way that makes them not work on other + * architectures where unaligned accesses aren't as simple. */ -#include -#include -#define get_unaligned __get_unaligned_le -#define put_unaligned __put_unaligned_le +#define get_unaligned(ptr) (*(ptr)) -#endif /* _ASM_CRIS_UNALIGNED_H */ +#define put_unaligned(val, ptr) ((void)( *(ptr) = (val) )) + +#endif diff --git a/trunk/include/asm-frv/unaligned.h b/trunk/include/asm-frv/unaligned.h index 64ccc736f2d8..dc8e9c9bf6bd 100644 --- a/trunk/include/asm-frv/unaligned.h +++ b/trunk/include/asm-frv/unaligned.h @@ -9,14 +9,194 @@ * 2 of the License, or (at your option) any later version. */ -#ifndef _ASM_FRV_UNALIGNED_H -#define _ASM_FRV_UNALIGNED_H +#ifndef _ASM_UNALIGNED_H +#define _ASM_UNALIGNED_H -#include -#include -#include -#define get_unaligned __get_unaligned_be -#define put_unaligned __put_unaligned_be +/* + * Unaligned accesses on uClinux can't be performed in a fault handler - the + * CPU detects them as imprecise exceptions making this impossible. + * + * With the FR451, however, they are precise, and so we used to fix them up in + * the memory access fault handler. However, instruction bundling make this + * impractical. So, now we fall back to using memcpy. + */ +#ifdef CONFIG_MMU + +/* + * The asm statement in the macros below is a way to get GCC to copy a + * value from one variable to another without having any clue it's + * actually doing so, so that it won't have any idea that the values + * in the two variables are related. + */ + +#define get_unaligned(ptr) ({ \ + typeof((*(ptr))) __x; \ + void *__ptrcopy; \ + asm("" : "=r" (__ptrcopy) : "0" (ptr)); \ + memcpy(&__x, __ptrcopy, sizeof(*(ptr))); \ + __x; \ +}) + +#define put_unaligned(val, ptr) ({ \ + typeof((*(ptr))) __x = (val); \ + void *__ptrcopy; \ + asm("" : "=r" (__ptrcopy) : "0" (ptr)); \ + memcpy(__ptrcopy, &__x, sizeof(*(ptr))); \ +}) + +extern int handle_misalignment(unsigned long esr0, unsigned long ear0, unsigned long epcr0); + +#else + +#define get_unaligned(ptr) \ +({ \ + typeof(*(ptr)) x; \ + const char *__p = (const char *) (ptr); \ + \ + switch (sizeof(x)) { \ + case 1: \ + x = *(ptr); \ + break; \ + case 2: \ + { \ + uint8_t a; \ + asm(" ldub%I2 %M2,%0 \n" \ + " ldub%I3.p %M3,%1 \n" \ + " slli %0,#8,%0 \n" \ + " or %0,%1,%0 \n" \ + : "=&r"(x), "=&r"(a) \ + : "m"(__p[0]), "m"(__p[1]) \ + ); \ + break; \ + } \ + \ + case 4: \ + { \ + uint8_t a; \ + asm(" ldub%I2 %M2,%0 \n" \ + " ldub%I3.p %M3,%1 \n" \ + " slli %0,#8,%0 \n" \ + " or %0,%1,%0 \n" \ + " ldub%I4.p %M4,%1 \n" \ + " slli %0,#8,%0 \n" \ + " or %0,%1,%0 \n" \ + " ldub%I5.p %M5,%1 \n" \ + " slli %0,#8,%0 \n" \ + " or %0,%1,%0 \n" \ + : "=&r"(x), "=&r"(a) \ + : "m"(__p[0]), "m"(__p[1]), "m"(__p[2]), "m"(__p[3]) \ + ); \ + break; \ + } \ + \ + case 8: \ + { \ + union { uint64_t x; u32 y[2]; } z; \ + uint8_t a; \ + asm(" ldub%I3 %M3,%0 \n" \ + " ldub%I4.p %M4,%2 \n" \ + " slli %0,#8,%0 \n" \ + " or %0,%2,%0 \n" \ + " ldub%I5.p %M5,%2 \n" \ + " slli %0,#8,%0 \n" \ + " or %0,%2,%0 \n" \ + " ldub%I6.p %M6,%2 \n" \ + " slli %0,#8,%0 \n" \ + " or %0,%2,%0 \n" \ + " ldub%I7 %M7,%1 \n" \ + " ldub%I8.p %M8,%2 \n" \ + " slli %1,#8,%1 \n" \ + " or %1,%2,%1 \n" \ + " ldub%I9.p %M9,%2 \n" \ + " slli %1,#8,%1 \n" \ + " or %1,%2,%1 \n" \ + " ldub%I10.p %M10,%2 \n" \ + " slli %1,#8,%1 \n" \ + " or %1,%2,%1 \n" \ + : "=&r"(z.y[0]), "=&r"(z.y[1]), "=&r"(a) \ + : "m"(__p[0]), "m"(__p[1]), "m"(__p[2]), "m"(__p[3]), \ + "m"(__p[4]), "m"(__p[5]), "m"(__p[6]), "m"(__p[7]) \ + ); \ + x = z.x; \ + break; \ + } \ + \ + default: \ + x = 0; \ + BUG(); \ + break; \ + } \ + \ + x; \ +}) + +#define put_unaligned(val, ptr) \ +do { \ + char *__p = (char *) (ptr); \ + int x; \ + \ + switch (sizeof(*ptr)) { \ + case 2: \ + { \ + asm(" stb%I1.p %0,%M1 \n" \ + " srli %0,#8,%0 \n" \ + " stb%I2 %0,%M2 \n" \ + : "=r"(x), "=m"(__p[1]), "=m"(__p[0]) \ + : "0"(val) \ + ); \ + break; \ + } \ + \ + case 4: \ + { \ + asm(" stb%I1.p %0,%M1 \n" \ + " srli %0,#8,%0 \n" \ + " stb%I2.p %0,%M2 \n" \ + " srli %0,#8,%0 \n" \ + " stb%I3.p %0,%M3 \n" \ + " srli %0,#8,%0 \n" \ + " stb%I4 %0,%M4 \n" \ + : "=r"(x), "=m"(__p[3]), "=m"(__p[2]), "=m"(__p[1]), "=m"(__p[0]) \ + : "0"(val) \ + ); \ + break; \ + } \ + \ + case 8: \ + { \ + uint32_t __high, __low; \ + __high = (uint64_t)val >> 32; \ + __low = val & 0xffffffff; \ + asm(" stb%I2.p %0,%M2 \n" \ + " srli %0,#8,%0 \n" \ + " stb%I3.p %0,%M3 \n" \ + " srli %0,#8,%0 \n" \ + " stb%I4.p %0,%M4 \n" \ + " srli %0,#8,%0 \n" \ + " stb%I5.p %0,%M5 \n" \ + " srli %0,#8,%0 \n" \ + " stb%I6.p %1,%M6 \n" \ + " srli %1,#8,%1 \n" \ + " stb%I7.p %1,%M7 \n" \ + " srli %1,#8,%1 \n" \ + " stb%I8.p %1,%M8 \n" \ + " srli %1,#8,%1 \n" \ + " stb%I9 %1,%M9 \n" \ + : "=&r"(__low), "=&r"(__high), "=m"(__p[7]), "=m"(__p[6]), \ + "=m"(__p[5]), "=m"(__p[4]), "=m"(__p[3]), "=m"(__p[2]), \ + "=m"(__p[1]), "=m"(__p[0]) \ + : "0"(__low), "1"(__high) \ + ); \ + break; \ + } \ + \ + default: \ + *(ptr) = (val); \ + break; \ + } \ +} while(0) + +#endif -#endif /* _ASM_FRV_UNALIGNED_H */ +#endif diff --git a/trunk/include/asm-generic/ioctl.h b/trunk/include/asm-generic/ioctl.h index 864181385579..cd027298beb1 100644 --- a/trunk/include/asm-generic/ioctl.h +++ b/trunk/include/asm-generic/ioctl.h @@ -21,19 +21,8 @@ */ #define _IOC_NRBITS 8 #define _IOC_TYPEBITS 8 - -/* - * Let any architecture override either of the following before - * including this file. - */ - -#ifndef _IOC_SIZEBITS -# define _IOC_SIZEBITS 14 -#endif - -#ifndef _IOC_DIRBITS -# define _IOC_DIRBITS 2 -#endif +#define _IOC_SIZEBITS 14 +#define _IOC_DIRBITS 2 #define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) #define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) @@ -46,21 +35,11 @@ #define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) /* - * Direction bits, which any architecture can choose to override - * before including this file. + * Direction bits. */ - -#ifndef _IOC_NONE -# define _IOC_NONE 0U -#endif - -#ifndef _IOC_WRITE -# define _IOC_WRITE 1U -#endif - -#ifndef _IOC_READ -# define _IOC_READ 2U -#endif +#define _IOC_NONE 0U +#define _IOC_WRITE 1U +#define _IOC_READ 2U #define _IOC(dir,type,nr,size) \ (((dir) << _IOC_DIRSHIFT) | \ diff --git a/trunk/include/asm-generic/unaligned.h b/trunk/include/asm-generic/unaligned.h new file mode 100644 index 000000000000..2fe1b2e67f01 --- /dev/null +++ b/trunk/include/asm-generic/unaligned.h @@ -0,0 +1,124 @@ +#ifndef _ASM_GENERIC_UNALIGNED_H_ +#define _ASM_GENERIC_UNALIGNED_H_ + +/* + * For the benefit of those who are trying to port Linux to another + * architecture, here are some C-language equivalents. + * + * This is based almost entirely upon Richard Henderson's + * asm-alpha/unaligned.h implementation. Some comments were + * taken from David Mosberger's asm-ia64/unaligned.h header. + */ + +#include + +/* + * The main single-value unaligned transfer routines. + */ +#define get_unaligned(ptr) \ + __get_unaligned((ptr), sizeof(*(ptr))) +#define put_unaligned(x,ptr) \ + ((void)sizeof(*(ptr)=(x)),\ + __put_unaligned((__force __u64)(x), (ptr), sizeof(*(ptr)))) + +/* + * This function doesn't actually exist. The idea is that when + * someone uses the macros below with an unsupported size (datatype), + * the linker will alert us to the problem via an unresolved reference + * error. + */ +extern void bad_unaligned_access_length(void) __attribute__((noreturn)); + +struct __una_u64 { __u64 x __attribute__((packed)); }; +struct __una_u32 { __u32 x __attribute__((packed)); }; +struct __una_u16 { __u16 x __attribute__((packed)); }; + +/* + * Elemental unaligned loads + */ + +static inline __u64 __uldq(const __u64 *addr) +{ + const struct __una_u64 *ptr = (const struct __una_u64 *) addr; + return ptr->x; +} + +static inline __u32 __uldl(const __u32 *addr) +{ + const struct __una_u32 *ptr = (const struct __una_u32 *) addr; + return ptr->x; +} + +static inline __u16 __uldw(const __u16 *addr) +{ + const struct __una_u16 *ptr = (const struct __una_u16 *) addr; + return ptr->x; +} + +/* + * Elemental unaligned stores + */ + +static inline void __ustq(__u64 val, __u64 *addr) +{ + struct __una_u64 *ptr = (struct __una_u64 *) addr; + ptr->x = val; +} + +static inline void __ustl(__u32 val, __u32 *addr) +{ + struct __una_u32 *ptr = (struct __una_u32 *) addr; + ptr->x = val; +} + +static inline void __ustw(__u16 val, __u16 *addr) +{ + struct __una_u16 *ptr = (struct __una_u16 *) addr; + ptr->x = val; +} + +#define __get_unaligned(ptr, size) ({ \ + const void *__gu_p = ptr; \ + __u64 __val; \ + switch (size) { \ + case 1: \ + __val = *(const __u8 *)__gu_p; \ + break; \ + case 2: \ + __val = __uldw(__gu_p); \ + break; \ + case 4: \ + __val = __uldl(__gu_p); \ + break; \ + case 8: \ + __val = __uldq(__gu_p); \ + break; \ + default: \ + bad_unaligned_access_length(); \ + }; \ + (__force __typeof__(*(ptr)))__val; \ +}) + +#define __put_unaligned(val, ptr, size) \ +({ \ + void *__gu_p = ptr; \ + switch (size) { \ + case 1: \ + *(__u8 *)__gu_p = (__force __u8)val; \ + break; \ + case 2: \ + __ustw((__force __u16)val, __gu_p); \ + break; \ + case 4: \ + __ustl((__force __u32)val, __gu_p); \ + break; \ + case 8: \ + __ustq(val, __gu_p); \ + break; \ + default: \ + bad_unaligned_access_length(); \ + }; \ + (void)0; \ +}) + +#endif /* _ASM_GENERIC_UNALIGNED_H */ diff --git a/trunk/include/asm-h8300/unaligned.h b/trunk/include/asm-h8300/unaligned.h index b8d06c70c2da..ffb67f472070 100644 --- a/trunk/include/asm-h8300/unaligned.h +++ b/trunk/include/asm-h8300/unaligned.h @@ -1,11 +1,15 @@ -#ifndef _ASM_H8300_UNALIGNED_H -#define _ASM_H8300_UNALIGNED_H +#ifndef __H8300_UNALIGNED_H +#define __H8300_UNALIGNED_H -#include -#include -#include -#define get_unaligned __get_unaligned_be -#define put_unaligned __put_unaligned_be +/* Use memmove here, so gcc does not insert a __builtin_memcpy. */ -#endif /* _ASM_H8300_UNALIGNED_H */ +#define get_unaligned(ptr) \ + ({ __typeof__(*(ptr)) __tmp; memmove(&__tmp, (ptr), sizeof(*(ptr))); __tmp; }) + +#define put_unaligned(val, ptr) \ + ({ __typeof__(*(ptr)) __tmp = (val); \ + memmove((ptr), &__tmp, sizeof(*(ptr))); \ + (void)0; }) + +#endif diff --git a/trunk/include/asm-ia64/dma-mapping.h b/trunk/include/asm-ia64/dma-mapping.h index 9f0df9bd46b7..f1735a22d0ea 100644 --- a/trunk/include/asm-ia64/dma-mapping.h +++ b/trunk/include/asm-ia64/dma-mapping.h @@ -23,30 +23,10 @@ dma_free_noncoherent(struct device *dev, size_t size, void *cpu_addr, { dma_free_coherent(dev, size, cpu_addr, dma_handle); } -#define dma_map_single_attrs platform_dma_map_single_attrs -static inline dma_addr_t dma_map_single(struct device *dev, void *cpu_addr, - size_t size, int dir) -{ - return dma_map_single_attrs(dev, cpu_addr, size, dir, NULL); -} -#define dma_map_sg_attrs platform_dma_map_sg_attrs -static inline int dma_map_sg(struct device *dev, struct scatterlist *sgl, - int nents, int dir) -{ - return dma_map_sg_attrs(dev, sgl, nents, dir, NULL); -} -#define dma_unmap_single_attrs platform_dma_unmap_single_attrs -static inline void dma_unmap_single(struct device *dev, dma_addr_t cpu_addr, - size_t size, int dir) -{ - return dma_unmap_single_attrs(dev, cpu_addr, size, dir, NULL); -} -#define dma_unmap_sg_attrs platform_dma_unmap_sg_attrs -static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sgl, - int nents, int dir) -{ - return dma_unmap_sg_attrs(dev, sgl, nents, dir, NULL); -} +#define dma_map_single platform_dma_map_single +#define dma_map_sg platform_dma_map_sg +#define dma_unmap_single platform_dma_unmap_single +#define dma_unmap_sg platform_dma_unmap_sg #define dma_sync_single_for_cpu platform_dma_sync_single_for_cpu #define dma_sync_sg_for_cpu platform_dma_sync_sg_for_cpu #define dma_sync_single_for_device platform_dma_sync_single_for_device diff --git a/trunk/include/asm-ia64/machvec.h b/trunk/include/asm-ia64/machvec.h index 9f020eb825c5..c201a2020aa4 100644 --- a/trunk/include/asm-ia64/machvec.h +++ b/trunk/include/asm-ia64/machvec.h @@ -22,7 +22,6 @@ struct pci_bus; struct task_struct; struct pci_dev; struct msi_desc; -struct dma_attrs; typedef void ia64_mv_setup_t (char **); typedef void ia64_mv_cpu_init_t (void); @@ -57,11 +56,6 @@ typedef void ia64_mv_dma_sync_sg_for_device (struct device *, struct scatterlist typedef int ia64_mv_dma_mapping_error (dma_addr_t dma_addr); typedef int ia64_mv_dma_supported (struct device *, u64); -typedef dma_addr_t ia64_mv_dma_map_single_attrs (struct device *, void *, size_t, int, struct dma_attrs *); -typedef void ia64_mv_dma_unmap_single_attrs (struct device *, dma_addr_t, size_t, int, struct dma_attrs *); -typedef int ia64_mv_dma_map_sg_attrs (struct device *, struct scatterlist *, int, int, struct dma_attrs *); -typedef void ia64_mv_dma_unmap_sg_attrs (struct device *, struct scatterlist *, int, int, struct dma_attrs *); - /* * WARNING: The legacy I/O space is _architected_. Platforms are * expected to follow this architected model (see Section 10.7 in the @@ -142,10 +136,10 @@ extern void machvec_tlb_migrate_finish (struct mm_struct *); # define platform_dma_init ia64_mv.dma_init # define platform_dma_alloc_coherent ia64_mv.dma_alloc_coherent # define platform_dma_free_coherent ia64_mv.dma_free_coherent -# define platform_dma_map_single_attrs ia64_mv.dma_map_single_attrs -# define platform_dma_unmap_single_attrs ia64_mv.dma_unmap_single_attrs -# define platform_dma_map_sg_attrs ia64_mv.dma_map_sg_attrs -# define platform_dma_unmap_sg_attrs ia64_mv.dma_unmap_sg_attrs +# define platform_dma_map_single ia64_mv.dma_map_single +# define platform_dma_unmap_single ia64_mv.dma_unmap_single +# define platform_dma_map_sg ia64_mv.dma_map_sg +# define platform_dma_unmap_sg ia64_mv.dma_unmap_sg # define platform_dma_sync_single_for_cpu ia64_mv.dma_sync_single_for_cpu # define platform_dma_sync_sg_for_cpu ia64_mv.dma_sync_sg_for_cpu # define platform_dma_sync_single_for_device ia64_mv.dma_sync_single_for_device @@ -196,10 +190,10 @@ struct ia64_machine_vector { ia64_mv_dma_init *dma_init; ia64_mv_dma_alloc_coherent *dma_alloc_coherent; ia64_mv_dma_free_coherent *dma_free_coherent; - ia64_mv_dma_map_single_attrs *dma_map_single_attrs; - ia64_mv_dma_unmap_single_attrs *dma_unmap_single_attrs; - ia64_mv_dma_map_sg_attrs *dma_map_sg_attrs; - ia64_mv_dma_unmap_sg_attrs *dma_unmap_sg_attrs; + ia64_mv_dma_map_single *dma_map_single; + ia64_mv_dma_unmap_single *dma_unmap_single; + ia64_mv_dma_map_sg *dma_map_sg; + ia64_mv_dma_unmap_sg *dma_unmap_sg; ia64_mv_dma_sync_single_for_cpu *dma_sync_single_for_cpu; ia64_mv_dma_sync_sg_for_cpu *dma_sync_sg_for_cpu; ia64_mv_dma_sync_single_for_device *dma_sync_single_for_device; @@ -246,10 +240,10 @@ struct ia64_machine_vector { platform_dma_init, \ platform_dma_alloc_coherent, \ platform_dma_free_coherent, \ - platform_dma_map_single_attrs, \ - platform_dma_unmap_single_attrs, \ - platform_dma_map_sg_attrs, \ - platform_dma_unmap_sg_attrs, \ + platform_dma_map_single, \ + platform_dma_unmap_single, \ + platform_dma_map_sg, \ + platform_dma_unmap_sg, \ platform_dma_sync_single_for_cpu, \ platform_dma_sync_sg_for_cpu, \ platform_dma_sync_single_for_device, \ @@ -298,13 +292,9 @@ extern ia64_mv_dma_init swiotlb_init; extern ia64_mv_dma_alloc_coherent swiotlb_alloc_coherent; extern ia64_mv_dma_free_coherent swiotlb_free_coherent; extern ia64_mv_dma_map_single swiotlb_map_single; -extern ia64_mv_dma_map_single_attrs swiotlb_map_single_attrs; extern ia64_mv_dma_unmap_single swiotlb_unmap_single; -extern ia64_mv_dma_unmap_single_attrs swiotlb_unmap_single_attrs; extern ia64_mv_dma_map_sg swiotlb_map_sg; -extern ia64_mv_dma_map_sg_attrs swiotlb_map_sg_attrs; extern ia64_mv_dma_unmap_sg swiotlb_unmap_sg; -extern ia64_mv_dma_unmap_sg_attrs swiotlb_unmap_sg_attrs; extern ia64_mv_dma_sync_single_for_cpu swiotlb_sync_single_for_cpu; extern ia64_mv_dma_sync_sg_for_cpu swiotlb_sync_sg_for_cpu; extern ia64_mv_dma_sync_single_for_device swiotlb_sync_single_for_device; @@ -350,17 +340,17 @@ extern ia64_mv_dma_supported swiotlb_dma_supported; #ifndef platform_dma_free_coherent # define platform_dma_free_coherent swiotlb_free_coherent #endif -#ifndef platform_dma_map_single_attrs -# define platform_dma_map_single_attrs swiotlb_map_single_attrs +#ifndef platform_dma_map_single +# define platform_dma_map_single swiotlb_map_single #endif -#ifndef platform_dma_unmap_single_attrs -# define platform_dma_unmap_single_attrs swiotlb_unmap_single_attrs +#ifndef platform_dma_unmap_single +# define platform_dma_unmap_single swiotlb_unmap_single #endif -#ifndef platform_dma_map_sg_attrs -# define platform_dma_map_sg_attrs swiotlb_map_sg_attrs +#ifndef platform_dma_map_sg +# define platform_dma_map_sg swiotlb_map_sg #endif -#ifndef platform_dma_unmap_sg_attrs -# define platform_dma_unmap_sg_attrs swiotlb_unmap_sg_attrs +#ifndef platform_dma_unmap_sg +# define platform_dma_unmap_sg swiotlb_unmap_sg #endif #ifndef platform_dma_sync_single_for_cpu # define platform_dma_sync_single_for_cpu swiotlb_sync_single_for_cpu diff --git a/trunk/include/asm-ia64/machvec_hpzx1.h b/trunk/include/asm-ia64/machvec_hpzx1.h index 2f57f5144b9f..e90daf9ce340 100644 --- a/trunk/include/asm-ia64/machvec_hpzx1.h +++ b/trunk/include/asm-ia64/machvec_hpzx1.h @@ -4,10 +4,10 @@ extern ia64_mv_setup_t dig_setup; extern ia64_mv_dma_alloc_coherent sba_alloc_coherent; extern ia64_mv_dma_free_coherent sba_free_coherent; -extern ia64_mv_dma_map_single_attrs sba_map_single_attrs; -extern ia64_mv_dma_unmap_single_attrs sba_unmap_single_attrs; -extern ia64_mv_dma_map_sg_attrs sba_map_sg_attrs; -extern ia64_mv_dma_unmap_sg_attrs sba_unmap_sg_attrs; +extern ia64_mv_dma_map_single sba_map_single; +extern ia64_mv_dma_unmap_single sba_unmap_single; +extern ia64_mv_dma_map_sg sba_map_sg; +extern ia64_mv_dma_unmap_sg sba_unmap_sg; extern ia64_mv_dma_supported sba_dma_supported; extern ia64_mv_dma_mapping_error sba_dma_mapping_error; @@ -23,10 +23,10 @@ extern ia64_mv_dma_mapping_error sba_dma_mapping_error; #define platform_dma_init machvec_noop #define platform_dma_alloc_coherent sba_alloc_coherent #define platform_dma_free_coherent sba_free_coherent -#define platform_dma_map_single_attrs sba_map_single_attrs -#define platform_dma_unmap_single_attrs sba_unmap_single_attrs -#define platform_dma_map_sg_attrs sba_map_sg_attrs -#define platform_dma_unmap_sg_attrs sba_unmap_sg_attrs +#define platform_dma_map_single sba_map_single +#define platform_dma_unmap_single sba_unmap_single +#define platform_dma_map_sg sba_map_sg +#define platform_dma_unmap_sg sba_unmap_sg #define platform_dma_sync_single_for_cpu machvec_dma_sync_single #define platform_dma_sync_sg_for_cpu machvec_dma_sync_sg #define platform_dma_sync_single_for_device machvec_dma_sync_single diff --git a/trunk/include/asm-ia64/machvec_hpzx1_swiotlb.h b/trunk/include/asm-ia64/machvec_hpzx1_swiotlb.h index a842cdda827b..f00a34a148ff 100644 --- a/trunk/include/asm-ia64/machvec_hpzx1_swiotlb.h +++ b/trunk/include/asm-ia64/machvec_hpzx1_swiotlb.h @@ -4,10 +4,10 @@ extern ia64_mv_setup_t dig_setup; extern ia64_mv_dma_alloc_coherent hwsw_alloc_coherent; extern ia64_mv_dma_free_coherent hwsw_free_coherent; -extern ia64_mv_dma_map_single_attrs hwsw_map_single_attrs; -extern ia64_mv_dma_unmap_single_attrs hwsw_unmap_single_attrs; -extern ia64_mv_dma_map_sg_attrs hwsw_map_sg_attrs; -extern ia64_mv_dma_unmap_sg_attrs hwsw_unmap_sg_attrs; +extern ia64_mv_dma_map_single hwsw_map_single; +extern ia64_mv_dma_unmap_single hwsw_unmap_single; +extern ia64_mv_dma_map_sg hwsw_map_sg; +extern ia64_mv_dma_unmap_sg hwsw_unmap_sg; extern ia64_mv_dma_supported hwsw_dma_supported; extern ia64_mv_dma_mapping_error hwsw_dma_mapping_error; extern ia64_mv_dma_sync_single_for_cpu hwsw_sync_single_for_cpu; @@ -28,10 +28,10 @@ extern ia64_mv_dma_sync_sg_for_device hwsw_sync_sg_for_device; #define platform_dma_init machvec_noop #define platform_dma_alloc_coherent hwsw_alloc_coherent #define platform_dma_free_coherent hwsw_free_coherent -#define platform_dma_map_single_attrs hwsw_map_single_attrs -#define platform_dma_unmap_single_attrs hwsw_unmap_single_attrs -#define platform_dma_map_sg_attrs hwsw_map_sg_attrs -#define platform_dma_unmap_sg_attrs hwsw_unmap_sg_attrs +#define platform_dma_map_single hwsw_map_single +#define platform_dma_unmap_single hwsw_unmap_single +#define platform_dma_map_sg hwsw_map_sg +#define platform_dma_unmap_sg hwsw_unmap_sg #define platform_dma_supported hwsw_dma_supported #define platform_dma_mapping_error hwsw_dma_mapping_error #define platform_dma_sync_single_for_cpu hwsw_sync_single_for_cpu diff --git a/trunk/include/asm-ia64/machvec_sn2.h b/trunk/include/asm-ia64/machvec_sn2.h index 781308ea7b88..61439a7f5b08 100644 --- a/trunk/include/asm-ia64/machvec_sn2.h +++ b/trunk/include/asm-ia64/machvec_sn2.h @@ -57,10 +57,10 @@ extern ia64_mv_readl_t __sn_readl_relaxed; extern ia64_mv_readq_t __sn_readq_relaxed; extern ia64_mv_dma_alloc_coherent sn_dma_alloc_coherent; extern ia64_mv_dma_free_coherent sn_dma_free_coherent; -extern ia64_mv_dma_map_single_attrs sn_dma_map_single_attrs; -extern ia64_mv_dma_unmap_single_attrs sn_dma_unmap_single_attrs; -extern ia64_mv_dma_map_sg_attrs sn_dma_map_sg_attrs; -extern ia64_mv_dma_unmap_sg_attrs sn_dma_unmap_sg_attrs; +extern ia64_mv_dma_map_single sn_dma_map_single; +extern ia64_mv_dma_unmap_single sn_dma_unmap_single; +extern ia64_mv_dma_map_sg sn_dma_map_sg; +extern ia64_mv_dma_unmap_sg sn_dma_unmap_sg; extern ia64_mv_dma_sync_single_for_cpu sn_dma_sync_single_for_cpu; extern ia64_mv_dma_sync_sg_for_cpu sn_dma_sync_sg_for_cpu; extern ia64_mv_dma_sync_single_for_device sn_dma_sync_single_for_device; @@ -113,10 +113,10 @@ extern ia64_mv_pci_fixup_bus_t sn_pci_fixup_bus; #define platform_dma_init machvec_noop #define platform_dma_alloc_coherent sn_dma_alloc_coherent #define platform_dma_free_coherent sn_dma_free_coherent -#define platform_dma_map_single_attrs sn_dma_map_single_attrs -#define platform_dma_unmap_single_attrs sn_dma_unmap_single_attrs -#define platform_dma_map_sg_attrs sn_dma_map_sg_attrs -#define platform_dma_unmap_sg_attrs sn_dma_unmap_sg_attrs +#define platform_dma_map_single sn_dma_map_single +#define platform_dma_unmap_single sn_dma_unmap_single +#define platform_dma_map_sg sn_dma_map_sg +#define platform_dma_unmap_sg sn_dma_unmap_sg #define platform_dma_sync_single_for_cpu sn_dma_sync_single_for_cpu #define platform_dma_sync_sg_for_cpu sn_dma_sync_sg_for_cpu #define platform_dma_sync_single_for_device sn_dma_sync_single_for_device diff --git a/trunk/include/asm-ia64/topology.h b/trunk/include/asm-ia64/topology.h index 32863b3bb1d3..f2f72ef2a897 100644 --- a/trunk/include/asm-ia64/topology.h +++ b/trunk/include/asm-ia64/topology.h @@ -116,8 +116,6 @@ void build_cpu_to_node_map(void); #define smt_capable() (smp_num_siblings > 1) #endif -extern void arch_fix_phys_package_id(int num, u32 slot); - #define pcibus_to_cpumask(bus) (pcibus_to_node(bus) == -1 ? \ CPU_MASK_ALL : \ node_to_cpumask(pcibus_to_node(bus)) \ diff --git a/trunk/include/asm-ia64/unaligned.h b/trunk/include/asm-ia64/unaligned.h index 7bddc7f58584..bb8559888103 100644 --- a/trunk/include/asm-ia64/unaligned.h +++ b/trunk/include/asm-ia64/unaligned.h @@ -1,11 +1,6 @@ #ifndef _ASM_IA64_UNALIGNED_H #define _ASM_IA64_UNALIGNED_H -#include -#include -#include - -#define get_unaligned __get_unaligned_le -#define put_unaligned __put_unaligned_le +#include #endif /* _ASM_IA64_UNALIGNED_H */ diff --git a/trunk/include/asm-ia64/uncached.h b/trunk/include/asm-ia64/uncached.h index 13d7e65ca3cc..b82d923b73c1 100644 --- a/trunk/include/asm-ia64/uncached.h +++ b/trunk/include/asm-ia64/uncached.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2001-2008 Silicon Graphics, Inc. All rights reserved. + * Copyright (C) 2001-2005 Silicon Graphics, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License @@ -8,5 +8,5 @@ * Prototypes for the uncached page allocator */ -extern unsigned long uncached_alloc_page(int starting_nid, int n_pages); -extern void uncached_free_page(unsigned long uc_addr, int n_pages); +extern unsigned long uncached_alloc_page(int nid); +extern void uncached_free_page(unsigned long); diff --git a/trunk/include/asm-m32r/unaligned.h b/trunk/include/asm-m32r/unaligned.h index 377eb20d1ec6..fccc180c3913 100644 --- a/trunk/include/asm-m32r/unaligned.h +++ b/trunk/include/asm-m32r/unaligned.h @@ -1,18 +1,19 @@ #ifndef _ASM_M32R_UNALIGNED_H #define _ASM_M32R_UNALIGNED_H -#if defined(__LITTLE_ENDIAN__) -# include -# include -# include -# define get_unaligned __get_unaligned_le -# define put_unaligned __put_unaligned_le -#else -# include -# include -# include -# define get_unaligned __get_unaligned_be -# define put_unaligned __put_unaligned_be -#endif +/* + * For the benefit of those who are trying to port Linux to another + * architecture, here are some C-language equivalents. + */ + +#include + +#define get_unaligned(ptr) \ + ({ __typeof__(*(ptr)) __tmp; memmove(&__tmp, (ptr), sizeof(*(ptr))); __tmp; }) + +#define put_unaligned(val, ptr) \ + ({ __typeof__(*(ptr)) __tmp = (val); \ + memmove((ptr), &__tmp, sizeof(*(ptr))); \ + (void)0; }) #endif /* _ASM_M32R_UNALIGNED_H */ diff --git a/trunk/include/asm-m68k/unaligned.h b/trunk/include/asm-m68k/unaligned.h index 77698f2dc33c..804cb3f888fe 100644 --- a/trunk/include/asm-m68k/unaligned.h +++ b/trunk/include/asm-m68k/unaligned.h @@ -1,13 +1,16 @@ -#ifndef _ASM_M68K_UNALIGNED_H -#define _ASM_M68K_UNALIGNED_H +#ifndef __M68K_UNALIGNED_H +#define __M68K_UNALIGNED_H /* * The m68k can do unaligned accesses itself. + * + * The strange macros are there to make sure these can't + * be misused in a way that makes them not work on other + * architectures where unaligned accesses aren't as simple. */ -#include -#include -#define get_unaligned __get_unaligned_be -#define put_unaligned __put_unaligned_be +#define get_unaligned(ptr) (*(ptr)) -#endif /* _ASM_M68K_UNALIGNED_H */ +#define put_unaligned(val, ptr) ((void)( *(ptr) = (val) )) + +#endif diff --git a/trunk/include/asm-m68knommu/unaligned.h b/trunk/include/asm-m68knommu/unaligned.h index eb1ea4cb9a59..869e9dd24f54 100644 --- a/trunk/include/asm-m68knommu/unaligned.h +++ b/trunk/include/asm-m68knommu/unaligned.h @@ -1,25 +1,23 @@ -#ifndef _ASM_M68KNOMMU_UNALIGNED_H -#define _ASM_M68KNOMMU_UNALIGNED_H +#ifndef __M68K_UNALIGNED_H +#define __M68K_UNALIGNED_H #ifdef CONFIG_COLDFIRE -#include -#include -#include -#define get_unaligned __get_unaligned_be -#define put_unaligned __put_unaligned_be +#include #else /* * The m68k can do unaligned accesses itself. + * + * The strange macros are there to make sure these can't + * be misused in a way that makes them not work on other + * architectures where unaligned accesses aren't as simple. */ -#include -#include -#define get_unaligned __get_unaligned_be -#define put_unaligned __put_unaligned_be +#define get_unaligned(ptr) (*(ptr)) +#define put_unaligned(val, ptr) ((void)( *(ptr) = (val) )) #endif -#endif /* _ASM_M68KNOMMU_UNALIGNED_H */ +#endif diff --git a/trunk/include/asm-mips/unaligned.h b/trunk/include/asm-mips/unaligned.h index 792404948571..3249049e93aa 100644 --- a/trunk/include/asm-mips/unaligned.h +++ b/trunk/include/asm-mips/unaligned.h @@ -5,24 +5,25 @@ * * Copyright (C) 2007 Ralf Baechle (ralf@linux-mips.org) */ -#ifndef _ASM_MIPS_UNALIGNED_H -#define _ASM_MIPS_UNALIGNED_H +#ifndef __ASM_GENERIC_UNALIGNED_H +#define __ASM_GENERIC_UNALIGNED_H #include -#if defined(__MIPSEB__) -# include -# include -# include -# define get_unaligned __get_unaligned_be -# define put_unaligned __put_unaligned_be -#elif defined(__MIPSEL__) -# include -# include -# include -# define get_unaligned __get_unaligned_le -# define put_unaligned __put_unaligned_le -#else -# error "MIPS, but neither __MIPSEB__, nor __MIPSEL__???" -#endif -#endif /* _ASM_MIPS_UNALIGNED_H */ +#define get_unaligned(ptr) \ +({ \ + struct __packed { \ + typeof(*(ptr)) __v; \ + } *__p = (void *) (ptr); \ + __p->__v; \ +}) + +#define put_unaligned(val, ptr) \ +do { \ + struct __packed { \ + typeof(*(ptr)) __v; \ + } *__p = (void *) (ptr); \ + __p->__v = (val); \ +} while(0) + +#endif /* __ASM_GENERIC_UNALIGNED_H */ diff --git a/trunk/include/asm-mn10300/unaligned.h b/trunk/include/asm-mn10300/unaligned.h index 0df671318ae4..cad3afbd035f 100644 --- a/trunk/include/asm-mn10300/unaligned.h +++ b/trunk/include/asm-mn10300/unaligned.h @@ -8,13 +8,129 @@ * as published by the Free Software Foundation; either version * 2 of the Licence, or (at your option) any later version. */ -#ifndef _ASM_MN10300_UNALIGNED_H -#define _ASM_MN10300_UNALIGNED_H +#ifndef _ASM_UNALIGNED_H +#define _ASM_UNALIGNED_H -#include -#include +#include -#define get_unaligned __get_unaligned_le -#define put_unaligned __put_unaligned_le +#if 0 +extern int __bug_unaligned_x(void *ptr); -#endif /* _ASM_MN10300_UNALIGNED_H */ +/* + * What is the most efficient way of loading/storing an unaligned value? + * + * That is the subject of this file. Efficiency here is defined as + * minimum code size with minimum register usage for the common cases. + * It is currently not believed that long longs are common, so we + * trade efficiency for the chars, shorts and longs against the long + * longs. + * + * Current stats with gcc 2.7.2.2 for these functions: + * + * ptrsize get: code regs put: code regs + * 1 1 1 1 2 + * 2 3 2 3 2 + * 4 7 3 7 3 + * 8 20 6 16 6 + * + * gcc 2.95.1 seems to code differently: + * + * ptrsize get: code regs put: code regs + * 1 1 1 1 2 + * 2 3 2 3 2 + * 4 7 4 7 4 + * 8 19 8 15 6 + * + * which may or may not be more efficient (depending upon whether + * you can afford the extra registers). Hopefully the gcc 2.95 + * is inteligent enough to decide if it is better to use the + * extra register, but evidence so far seems to suggest otherwise. + * + * Unfortunately, gcc is not able to optimise the high word + * out of long long >> 32, or the low word from long long << 32 + */ + +#define __get_unaligned_2(__p) \ + (__p[0] | __p[1] << 8) + +#define __get_unaligned_4(__p) \ + (__p[0] | __p[1] << 8 | __p[2] << 16 | __p[3] << 24) + +#define get_unaligned(ptr) \ +({ \ + unsigned int __v1, __v2; \ + __typeof__(*(ptr)) __v; \ + __u8 *__p = (__u8 *)(ptr); \ + \ + switch (sizeof(*(ptr))) { \ + case 1: __v = *(ptr); break; \ + case 2: __v = __get_unaligned_2(__p); break; \ + case 4: __v = __get_unaligned_4(__p); break; \ + case 8: \ + __v2 = __get_unaligned_4((__p+4)); \ + __v1 = __get_unaligned_4(__p); \ + __v = ((unsigned long long)__v2 << 32 | __v1); \ + break; \ + default: __v = __bug_unaligned_x(__p); break; \ + } \ + __v; \ +}) + + +static inline void __put_unaligned_2(__u32 __v, register __u8 *__p) +{ + *__p++ = __v; + *__p++ = __v >> 8; +} + +static inline void __put_unaligned_4(__u32 __v, register __u8 *__p) +{ + __put_unaligned_2(__v >> 16, __p + 2); + __put_unaligned_2(__v, __p); +} + +static inline void __put_unaligned_8(const unsigned long long __v, __u8 *__p) +{ + /* + * tradeoff: 8 bytes of stack for all unaligned puts (2 + * instructions), or an extra register in the long long + * case - go for the extra register. + */ + __put_unaligned_4(__v >> 32, __p + 4); + __put_unaligned_4(__v, __p); +} + +/* + * Try to store an unaligned value as efficiently as possible. + */ +#define put_unaligned(val, ptr) \ + ({ \ + switch (sizeof(*(ptr))) { \ + case 1: \ + *(ptr) = (val); \ + break; \ + case 2: \ + __put_unaligned_2((val), (__u8 *)(ptr)); \ + break; \ + case 4: \ + __put_unaligned_4((val), (__u8 *)(ptr)); \ + break; \ + case 8: \ + __put_unaligned_8((val), (__u8 *)(ptr)); \ + break; \ + default: \ + __bug_unaligned_x(ptr); \ + break; \ + } \ + (void) 0; \ + }) + + +#else + +#define get_unaligned(ptr) (*(ptr)) +#define put_unaligned(val, ptr) ({ *(ptr) = (val); (void) 0; }) + +#endif + +#endif diff --git a/trunk/include/asm-parisc/unaligned.h b/trunk/include/asm-parisc/unaligned.h index dfc5d3321a54..53c905838d93 100644 --- a/trunk/include/asm-parisc/unaligned.h +++ b/trunk/include/asm-parisc/unaligned.h @@ -1,11 +1,7 @@ -#ifndef _ASM_PARISC_UNALIGNED_H -#define _ASM_PARISC_UNALIGNED_H +#ifndef _ASM_PARISC_UNALIGNED_H_ +#define _ASM_PARISC_UNALIGNED_H_ -#include -#include -#include -#define get_unaligned __get_unaligned_be -#define put_unaligned __put_unaligned_be +#include #ifdef __KERNEL__ struct pt_regs; @@ -13,4 +9,4 @@ void handle_unaligned(struct pt_regs *regs); int check_unaligned(struct pt_regs *regs); #endif -#endif /* _ASM_PARISC_UNALIGNED_H */ +#endif /* _ASM_PARISC_UNALIGNED_H_ */ diff --git a/trunk/include/asm-powerpc/irq.h b/trunk/include/asm-powerpc/irq.h index 5089deb8fec3..b5c03127a9b9 100644 --- a/trunk/include/asm-powerpc/irq.h +++ b/trunk/include/asm-powerpc/irq.h @@ -619,6 +619,8 @@ struct pt_regs; #define __ARCH_HAS_DO_SOFTIRQ +extern void __do_softirq(void); + #ifdef CONFIG_IRQSTACKS /* * Per-cpu stacks for handling hard and soft interrupts. diff --git a/trunk/include/asm-powerpc/processor.h b/trunk/include/asm-powerpc/processor.h index cf83f2d7e2a5..fd98ca998b4f 100644 --- a/trunk/include/asm-powerpc/processor.h +++ b/trunk/include/asm-powerpc/processor.h @@ -138,8 +138,6 @@ typedef struct { struct thread_struct { unsigned long ksp; /* Kernel stack pointer */ - unsigned long ksp_limit; /* if ksp <= ksp_limit stack overflow */ - #ifdef CONFIG_PPC64 unsigned long ksp_vsid; #endif @@ -184,14 +182,11 @@ struct thread_struct { #define ARCH_MIN_TASKALIGN 16 #define INIT_SP (sizeof(init_stack) + (unsigned long) &init_stack) -#define INIT_SP_LIMIT \ - (_ALIGN_UP(sizeof(init_thread_info), 16) + (unsigned long) &init_stack) #ifdef CONFIG_PPC32 #define INIT_THREAD { \ .ksp = INIT_SP, \ - .ksp_limit = INIT_SP_LIMIT, \ .fs = KERNEL_DS, \ .pgdir = swapper_pg_dir, \ .fpexc_mode = MSR_FE0 | MSR_FE1, \ @@ -199,7 +194,6 @@ struct thread_struct { #else #define INIT_THREAD { \ .ksp = INIT_SP, \ - .ksp_limit = INIT_SP_LIMIT, \ .regs = (struct pt_regs *)INIT_SP - 1, /* XXX bogus, I think */ \ .fs = KERNEL_DS, \ .fpr = {0}, \ diff --git a/trunk/include/asm-powerpc/system.h b/trunk/include/asm-powerpc/system.h index 2b6559a6d113..fab1674b31b6 100644 --- a/trunk/include/asm-powerpc/system.h +++ b/trunk/include/asm-powerpc/system.h @@ -204,7 +204,7 @@ extern int powersave_nap; /* set if nap mode can be used in idle loop */ * Changes the memory location '*ptr' to be val and returns * the previous value stored there. */ -static __always_inline unsigned long +static __inline__ unsigned long __xchg_u32(volatile void *p, unsigned long val) { unsigned long prev; @@ -229,7 +229,7 @@ __xchg_u32(volatile void *p, unsigned long val) * Changes the memory location '*ptr' to be val and returns * the previous value stored there. */ -static __always_inline unsigned long +static __inline__ unsigned long __xchg_u32_local(volatile void *p, unsigned long val) { unsigned long prev; @@ -247,7 +247,7 @@ __xchg_u32_local(volatile void *p, unsigned long val) } #ifdef CONFIG_PPC64 -static __always_inline unsigned long +static __inline__ unsigned long __xchg_u64(volatile void *p, unsigned long val) { unsigned long prev; @@ -266,7 +266,7 @@ __xchg_u64(volatile void *p, unsigned long val) return prev; } -static __always_inline unsigned long +static __inline__ unsigned long __xchg_u64_local(volatile void *p, unsigned long val) { unsigned long prev; @@ -290,7 +290,7 @@ __xchg_u64_local(volatile void *p, unsigned long val) */ extern void __xchg_called_with_bad_pointer(void); -static __always_inline unsigned long +static __inline__ unsigned long __xchg(volatile void *ptr, unsigned long x, unsigned int size) { switch (size) { @@ -305,7 +305,7 @@ __xchg(volatile void *ptr, unsigned long x, unsigned int size) return x; } -static __always_inline unsigned long +static __inline__ unsigned long __xchg_local(volatile void *ptr, unsigned long x, unsigned int size) { switch (size) { @@ -338,7 +338,7 @@ __xchg_local(volatile void *ptr, unsigned long x, unsigned int size) */ #define __HAVE_ARCH_CMPXCHG 1 -static __always_inline unsigned long +static __inline__ unsigned long __cmpxchg_u32(volatile unsigned int *p, unsigned long old, unsigned long new) { unsigned int prev; @@ -361,7 +361,7 @@ __cmpxchg_u32(volatile unsigned int *p, unsigned long old, unsigned long new) return prev; } -static __always_inline unsigned long +static __inline__ unsigned long __cmpxchg_u32_local(volatile unsigned int *p, unsigned long old, unsigned long new) { @@ -384,7 +384,7 @@ __cmpxchg_u32_local(volatile unsigned int *p, unsigned long old, } #ifdef CONFIG_PPC64 -static __always_inline unsigned long +static __inline__ unsigned long __cmpxchg_u64(volatile unsigned long *p, unsigned long old, unsigned long new) { unsigned long prev; @@ -406,7 +406,7 @@ __cmpxchg_u64(volatile unsigned long *p, unsigned long old, unsigned long new) return prev; } -static __always_inline unsigned long +static __inline__ unsigned long __cmpxchg_u64_local(volatile unsigned long *p, unsigned long old, unsigned long new) { @@ -432,7 +432,7 @@ __cmpxchg_u64_local(volatile unsigned long *p, unsigned long old, if something tries to do an invalid cmpxchg(). */ extern void __cmpxchg_called_with_bad_pointer(void); -static __always_inline unsigned long +static __inline__ unsigned long __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, unsigned int size) { @@ -448,7 +448,7 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, return old; } -static __always_inline unsigned long +static __inline__ unsigned long __cmpxchg_local(volatile void *ptr, unsigned long old, unsigned long new, unsigned int size) { diff --git a/trunk/include/asm-powerpc/unaligned.h b/trunk/include/asm-powerpc/unaligned.h index 5f1b1e3c2137..6c95dfa2652f 100644 --- a/trunk/include/asm-powerpc/unaligned.h +++ b/trunk/include/asm-powerpc/unaligned.h @@ -5,12 +5,15 @@ /* * The PowerPC can do unaligned accesses itself in big endian mode. + * + * The strange macros are there to make sure these can't + * be misused in a way that makes them not work on other + * architectures where unaligned accesses aren't as simple. */ -#include -#include -#define get_unaligned __get_unaligned_be -#define put_unaligned __put_unaligned_be +#define get_unaligned(ptr) (*(ptr)) + +#define put_unaligned(val, ptr) ((void)( *(ptr) = (val) )) #endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_UNALIGNED_H */ diff --git a/trunk/include/asm-powerpc/rio.h b/trunk/include/asm-ppc/rio.h similarity index 100% rename from trunk/include/asm-powerpc/rio.h rename to trunk/include/asm-ppc/rio.h diff --git a/trunk/include/asm-s390/unaligned.h b/trunk/include/asm-s390/unaligned.h index da9627afe5d8..8ee86dbedd1f 100644 --- a/trunk/include/asm-s390/unaligned.h +++ b/trunk/include/asm-s390/unaligned.h @@ -1,13 +1,24 @@ -#ifndef _ASM_S390_UNALIGNED_H -#define _ASM_S390_UNALIGNED_H +/* + * include/asm-s390/unaligned.h + * + * S390 version + * + * Derived from "include/asm-i386/unaligned.h" + */ + +#ifndef __S390_UNALIGNED_H +#define __S390_UNALIGNED_H /* * The S390 can do unaligned accesses itself. + * + * The strange macros are there to make sure these can't + * be misused in a way that makes them not work on other + * architectures where unaligned accesses aren't as simple. */ -#include -#include -#define get_unaligned __get_unaligned_be -#define put_unaligned __put_unaligned_be +#define get_unaligned(ptr) (*(ptr)) + +#define put_unaligned(val, ptr) ((void)( *(ptr) = (val) )) -#endif /* _ASM_S390_UNALIGNED_H */ +#endif diff --git a/trunk/include/asm-sh/unaligned.h b/trunk/include/asm-sh/unaligned.h index c1641a01d50f..5250e3063b42 100644 --- a/trunk/include/asm-sh/unaligned.h +++ b/trunk/include/asm-sh/unaligned.h @@ -1,19 +1,7 @@ -#ifndef _ASM_SH_UNALIGNED_H -#define _ASM_SH_UNALIGNED_H +#ifndef __ASM_SH_UNALIGNED_H +#define __ASM_SH_UNALIGNED_H /* SH can't handle unaligned accesses. */ -#ifdef __LITTLE_ENDIAN__ -# include -# include -# include -# define get_unaligned __get_unaligned_le -# define put_unaligned __put_unaligned_le -#else -# include -# include -# include -# define get_unaligned __get_unaligned_be -# define put_unaligned __put_unaligned_be -#endif +#include -#endif /* _ASM_SH_UNALIGNED_H */ +#endif /* __ASM_SH_UNALIGNED_H */ diff --git a/trunk/include/asm-sparc/unaligned.h b/trunk/include/asm-sparc/unaligned.h index 11d2d5fb5902..b6f8eddd30af 100644 --- a/trunk/include/asm-sparc/unaligned.h +++ b/trunk/include/asm-sparc/unaligned.h @@ -1,10 +1,6 @@ -#ifndef _ASM_SPARC_UNALIGNED_H -#define _ASM_SPARC_UNALIGNED_H +#ifndef _ASM_SPARC_UNALIGNED_H_ +#define _ASM_SPARC_UNALIGNED_H_ -#include -#include -#include -#define get_unaligned __get_unaligned_be -#define put_unaligned __put_unaligned_be +#include #endif /* _ASM_SPARC_UNALIGNED_H */ diff --git a/trunk/include/asm-sparc64/unaligned.h b/trunk/include/asm-sparc64/unaligned.h index edcebb09441e..1ed3ba537772 100644 --- a/trunk/include/asm-sparc64/unaligned.h +++ b/trunk/include/asm-sparc64/unaligned.h @@ -1,10 +1,6 @@ -#ifndef _ASM_SPARC64_UNALIGNED_H -#define _ASM_SPARC64_UNALIGNED_H +#ifndef _ASM_SPARC64_UNALIGNED_H_ +#define _ASM_SPARC64_UNALIGNED_H_ -#include -#include -#include -#define get_unaligned __get_unaligned_be -#define put_unaligned __put_unaligned_be +#include #endif /* _ASM_SPARC64_UNALIGNED_H */ diff --git a/trunk/include/asm-um/unaligned.h b/trunk/include/asm-um/unaligned.h index a47196974e39..1d2497c57274 100644 --- a/trunk/include/asm-um/unaligned.h +++ b/trunk/include/asm-um/unaligned.h @@ -1,6 +1,6 @@ -#ifndef _ASM_UM_UNALIGNED_H -#define _ASM_UM_UNALIGNED_H +#ifndef __UM_UNALIGNED_H +#define __UM_UNALIGNED_H #include "asm/arch/unaligned.h" -#endif /* _ASM_UM_UNALIGNED_H */ +#endif diff --git a/trunk/include/asm-v850/unaligned.h b/trunk/include/asm-v850/unaligned.h index 53122b28491e..e30b18653a94 100644 --- a/trunk/include/asm-v850/unaligned.h +++ b/trunk/include/asm-v850/unaligned.h @@ -1,4 +1,6 @@ /* + * include/asm-v850/unaligned.h -- Unaligned memory access + * * Copyright (C) 2001 NEC Corporation * Copyright (C) 2001 Miles Bader * @@ -6,17 +8,123 @@ * Public License. See the file COPYING in the main directory of this * archive for more details. * + * This file is a copy of the arm version, include/asm-arm/unaligned.h + * * Note that some v850 chips support unaligned access, but it seems too * annoying to use. */ -#ifndef _ASM_V850_UNALIGNED_H -#define _ASM_V850_UNALIGNED_H -#include -#include -#include +#ifndef __V850_UNALIGNED_H__ +#define __V850_UNALIGNED_H__ + +#include + +extern int __bug_unaligned_x(void *ptr); + +/* + * What is the most efficient way of loading/storing an unaligned value? + * + * That is the subject of this file. Efficiency here is defined as + * minimum code size with minimum register usage for the common cases. + * It is currently not believed that long longs are common, so we + * trade efficiency for the chars, shorts and longs against the long + * longs. + * + * Current stats with gcc 2.7.2.2 for these functions: + * + * ptrsize get: code regs put: code regs + * 1 1 1 1 2 + * 2 3 2 3 2 + * 4 7 3 7 3 + * 8 20 6 16 6 + * + * gcc 2.95.1 seems to code differently: + * + * ptrsize get: code regs put: code regs + * 1 1 1 1 2 + * 2 3 2 3 2 + * 4 7 4 7 4 + * 8 19 8 15 6 + * + * which may or may not be more efficient (depending upon whether + * you can afford the extra registers). Hopefully the gcc 2.95 + * is inteligent enough to decide if it is better to use the + * extra register, but evidence so far seems to suggest otherwise. + * + * Unfortunately, gcc is not able to optimise the high word + * out of long long >> 32, or the low word from long long << 32 + */ + +#define __get_unaligned_2(__p) \ + (__p[0] | __p[1] << 8) + +#define __get_unaligned_4(__p) \ + (__p[0] | __p[1] << 8 | __p[2] << 16 | __p[3] << 24) + +#define get_unaligned(ptr) \ + ({ \ + __typeof__(*(ptr)) __v; \ + __u8 *__p = (__u8 *)(ptr); \ + switch (sizeof(*(ptr))) { \ + case 1: __v = *(ptr); break; \ + case 2: __v = __get_unaligned_2(__p); break; \ + case 4: __v = __get_unaligned_4(__p); break; \ + case 8: { \ + unsigned int __v1, __v2; \ + __v2 = __get_unaligned_4((__p+4)); \ + __v1 = __get_unaligned_4(__p); \ + __v = ((unsigned long long)__v2 << 32 | __v1); \ + } \ + break; \ + default: __v = __bug_unaligned_x(__p); break; \ + } \ + __v; \ + }) + + +static inline void __put_unaligned_2(__u32 __v, register __u8 *__p) +{ + *__p++ = __v; + *__p++ = __v >> 8; +} + +static inline void __put_unaligned_4(__u32 __v, register __u8 *__p) +{ + __put_unaligned_2(__v >> 16, __p + 2); + __put_unaligned_2(__v, __p); +} + +static inline void __put_unaligned_8(const unsigned long long __v, register __u8 *__p) +{ + /* + * tradeoff: 8 bytes of stack for all unaligned puts (2 + * instructions), or an extra register in the long long + * case - go for the extra register. + */ + __put_unaligned_4(__v >> 32, __p+4); + __put_unaligned_4(__v, __p); +} + +/* + * Try to store an unaligned value as efficiently as possible. + */ +#define put_unaligned(val,ptr) \ + ({ \ + switch (sizeof(*(ptr))) { \ + case 1: \ + *(ptr) = (val); \ + break; \ + case 2: __put_unaligned_2((val),(__u8 *)(ptr)); \ + break; \ + case 4: __put_unaligned_4((val),(__u8 *)(ptr)); \ + break; \ + case 8: __put_unaligned_8((val),(__u8 *)(ptr)); \ + break; \ + default: __bug_unaligned_x(ptr); \ + break; \ + } \ + (void) 0; \ + }) -#define get_unaligned __get_unaligned_le -#define put_unaligned __put_unaligned_le -#endif /* _ASM_V850_UNALIGNED_H */ +#endif /* __V850_UNALIGNED_H__ */ diff --git a/trunk/include/asm-x86/olpc.h b/trunk/include/asm-x86/olpc.h deleted file mode 100644 index 97d47133486f..000000000000 --- a/trunk/include/asm-x86/olpc.h +++ /dev/null @@ -1,132 +0,0 @@ -/* OLPC machine specific definitions */ - -#ifndef ASM_OLPC_H_ -#define ASM_OLPC_H_ - -#include - -struct olpc_platform_t { - int flags; - uint32_t boardrev; - int ecver; -}; - -#define OLPC_F_PRESENT 0x01 -#define OLPC_F_DCON 0x02 -#define OLPC_F_VSA 0x04 - -#ifdef CONFIG_OLPC - -extern struct olpc_platform_t olpc_platform_info; - -/* - * OLPC board IDs contain the major build number within the mask 0x0ff0, - * and the minor build number withing 0x000f. Pre-builds have a minor - * number less than 8, and normal builds start at 8. For example, 0x0B10 - * is a PreB1, and 0x0C18 is a C1. - */ - -static inline uint32_t olpc_board(uint8_t id) -{ - return (id << 4) | 0x8; -} - -static inline uint32_t olpc_board_pre(uint8_t id) -{ - return id << 4; -} - -static inline int machine_is_olpc(void) -{ - return (olpc_platform_info.flags & OLPC_F_PRESENT) ? 1 : 0; -} - -/* - * The DCON is OLPC's Display Controller. It has a number of unique - * features that we might want to take advantage of.. - */ -static inline int olpc_has_dcon(void) -{ - return (olpc_platform_info.flags & OLPC_F_DCON) ? 1 : 0; -} - -/* - * The VSA is software from AMD that typical Geode bioses will include. - * It is used to emulate the PCI bus, VGA, etc. OLPC's Open Firmware does - * not include the VSA; instead, PCI is emulated by the kernel. - * - * The VSA is described further in arch/x86/pci/olpc.c. - */ -static inline int olpc_has_vsa(void) -{ - return (olpc_platform_info.flags & OLPC_F_VSA) ? 1 : 0; -} - -/* - * The "Mass Production" version of OLPC's XO is identified as being model - * C2. During the prototype phase, the following models (in chronological - * order) were created: A1, B1, B2, B3, B4, C1. The A1 through B2 models - * were based on Geode GX CPUs, and models after that were based upon - * Geode LX CPUs. There were also some hand-assembled models floating - * around, referred to as PreB1, PreB2, etc. - */ -static inline int olpc_board_at_least(uint32_t rev) -{ - return olpc_platform_info.boardrev >= rev; -} - -#else - -static inline int machine_is_olpc(void) -{ - return 0; -} - -static inline int olpc_has_dcon(void) -{ - return 0; -} - -static inline int olpc_has_vsa(void) -{ - return 0; -} - -#endif - -/* EC related functions */ - -extern int olpc_ec_cmd(unsigned char cmd, unsigned char *inbuf, size_t inlen, - unsigned char *outbuf, size_t outlen); - -extern int olpc_ec_mask_set(uint8_t bits); -extern int olpc_ec_mask_unset(uint8_t bits); - -/* EC commands */ - -#define EC_FIRMWARE_REV 0x08 - -/* SCI source values */ - -#define EC_SCI_SRC_EMPTY 0x00 -#define EC_SCI_SRC_GAME 0x01 -#define EC_SCI_SRC_BATTERY 0x02 -#define EC_SCI_SRC_BATSOC 0x04 -#define EC_SCI_SRC_BATERR 0x08 -#define EC_SCI_SRC_EBOOK 0x10 -#define EC_SCI_SRC_WLAN 0x20 -#define EC_SCI_SRC_ACPWR 0x40 -#define EC_SCI_SRC_ALL 0x7F - -/* GPIO assignments */ - -#define OLPC_GPIO_MIC_AC geode_gpio(1) -#define OLPC_GPIO_DCON_IRQ geode_gpio(7) -#define OLPC_GPIO_THRM_ALRM geode_gpio(10) -#define OLPC_GPIO_SMB_CLK geode_gpio(14) -#define OLPC_GPIO_SMB_DATA geode_gpio(15) -#define OLPC_GPIO_WORKAUX geode_gpio(24) -#define OLPC_GPIO_LID geode_gpio(26) -#define OLPC_GPIO_ECSCI geode_gpio(27) - -#endif diff --git a/trunk/include/asm-x86/pci.h b/trunk/include/asm-x86/pci.h index 30bbde0cb34b..ddd8e248fc0a 100644 --- a/trunk/include/asm-x86/pci.h +++ b/trunk/include/asm-x86/pci.h @@ -19,8 +19,6 @@ struct pci_sysdata { }; /* scan a bus after allocating a pci_sysdata for it */ -extern struct pci_bus *pci_scan_bus_on_node(int busno, struct pci_ops *ops, - int node); extern struct pci_bus *pci_scan_bus_with_sysdata(int busno); static inline int pci_domain_nr(struct pci_bus *bus) diff --git a/trunk/include/asm-x86/time.h b/trunk/include/asm-x86/time.h index bce72d7a958c..68779b048a3e 100644 --- a/trunk/include/asm-x86/time.h +++ b/trunk/include/asm-x86/time.h @@ -1,6 +1,7 @@ #ifndef _ASMX86_TIME_H #define _ASMX86_TIME_H +extern void (*late_time_init)(void); extern void hpet_time_init(void); #include diff --git a/trunk/include/asm-x86/topology.h b/trunk/include/asm-x86/topology.h index 4f35a0fb4f22..22073268b481 100644 --- a/trunk/include/asm-x86/topology.h +++ b/trunk/include/asm-x86/topology.h @@ -193,29 +193,9 @@ extern cpumask_t cpu_coregroup_map(int cpu); #define topology_thread_siblings(cpu) (per_cpu(cpu_sibling_map, cpu)) #endif -static inline void arch_fix_phys_package_id(int num, u32 slot) -{ -} - -struct pci_bus; -void set_pci_bus_resources_arch_default(struct pci_bus *b); - #ifdef CONFIG_SMP #define mc_capable() (boot_cpu_data.x86_max_cores > 1) #define smt_capable() (smp_num_siblings > 1) #endif -#ifdef CONFIG_NUMA -extern int get_mp_bus_to_node(int busnum); -extern void set_mp_bus_to_node(int busnum, int node); -#else -static inline int get_mp_bus_to_node(int busnum) -{ - return 0; -} -static inline void set_mp_bus_to_node(int busnum, int node) -{ -} -#endif - #endif diff --git a/trunk/include/asm-x86/tsc.h b/trunk/include/asm-x86/tsc.h index 548873ab5fc1..d2d8eb5b55f5 100644 --- a/trunk/include/asm-x86/tsc.h +++ b/trunk/include/asm-x86/tsc.h @@ -32,7 +32,7 @@ static inline cycles_t get_cycles(void) return ret; } -static __always_inline cycles_t vget_cycles(void) +static inline cycles_t vget_cycles(void) { /* * We only do VDSOs on TSC capable CPUs, so this shouldnt diff --git a/trunk/include/asm-x86/unaligned.h b/trunk/include/asm-x86/unaligned.h index a7bd416b4763..d270ffe72759 100644 --- a/trunk/include/asm-x86/unaligned.h +++ b/trunk/include/asm-x86/unaligned.h @@ -3,12 +3,35 @@ /* * The x86 can do unaligned accesses itself. + * + * The strange macros are there to make sure these can't + * be misused in a way that makes them not work on other + * architectures where unaligned accesses aren't as simple. */ -#include -#include +/** + * get_unaligned - get value from possibly mis-aligned location + * @ptr: pointer to value + * + * This macro should be used for accessing values larger in size than + * single bytes at locations that are expected to be improperly aligned, + * e.g. retrieving a u16 value from a location not u16-aligned. + * + * Note that unaligned accesses can be very expensive on some architectures. + */ +#define get_unaligned(ptr) (*(ptr)) -#define get_unaligned __get_unaligned_le -#define put_unaligned __put_unaligned_le +/** + * put_unaligned - put value to a possibly mis-aligned location + * @val: value to place + * @ptr: pointer to location + * + * This macro should be used for placing values larger in size than + * single bytes at locations that are expected to be improperly aligned, + * e.g. writing a u16 value to a location not u16-aligned. + * + * Note that unaligned accesses can be very expensive on some architectures. + */ +#define put_unaligned(val, ptr) ((void)(*(ptr) = (val))) #endif /* _ASM_X86_UNALIGNED_H */ diff --git a/trunk/include/asm-xtensa/unaligned.h b/trunk/include/asm-xtensa/unaligned.h index 8f3424fc5d18..28220890d0a6 100644 --- a/trunk/include/asm-xtensa/unaligned.h +++ b/trunk/include/asm-xtensa/unaligned.h @@ -1,4 +1,6 @@ /* + * include/asm-xtensa/unaligned.h + * * Xtensa doesn't handle unaligned accesses efficiently. * * This file is subject to the terms and conditions of the GNU General Public @@ -7,23 +9,20 @@ * * Copyright (C) 2001 - 2005 Tensilica Inc. */ -#ifndef _ASM_XTENSA_UNALIGNED_H -#define _ASM_XTENSA_UNALIGNED_H -#ifdef __XTENSA_EL__ -# include -# include -# include -# define get_unaligned __get_unaligned_le -# define put_unaligned __put_unaligned_le -#elif defined(__XTENSA_EB__) -# include -# include -# include -# define get_unaligned __get_unaligned_be -# define put_unaligned __put_unaligned_be -#else -# error processor byte order undefined! -#endif +#ifndef _XTENSA_UNALIGNED_H +#define _XTENSA_UNALIGNED_H + +#include + +/* Use memmove here, so gcc does not insert a __builtin_memcpy. */ + +#define get_unaligned(ptr) \ + ({ __typeof__(*(ptr)) __tmp; memmove(&__tmp, (ptr), sizeof(*(ptr))); __tmp; }) + +#define put_unaligned(val, ptr) \ + ({ __typeof__(*(ptr)) __tmp = (val); \ + memmove((ptr), &__tmp, sizeof(*(ptr))); \ + (void)0; }) -#endif /* _ASM_XTENSA_UNALIGNED_H */ +#endif /* _XTENSA_UNALIGNED_H */ diff --git a/trunk/include/linux/Kbuild b/trunk/include/linux/Kbuild index 78fade0a1e35..bda6f04791d4 100644 --- a/trunk/include/linux/Kbuild +++ b/trunk/include/linux/Kbuild @@ -20,7 +20,6 @@ header-y += affs_hardblocks.h header-y += aio_abi.h header-y += arcfb.h header-y += atmapi.h -header-y += atmarp.h header-y += atmbr2684.h header-y += atmclip.h header-y += atm_eni.h @@ -49,7 +48,6 @@ header-y += coff.h header-y += comstats.h header-y += const.h header-y += cgroupstats.h -header-y += cramfs_fs.h header-y += cycx_cfm.h header-y += dlmconstants.h header-y += dlm_device.h @@ -72,12 +70,10 @@ header-y += firewire-constants.h header-y += fuse.h header-y += genetlink.h header-y += gen_stats.h -header-y += gfs2_ondisk.h header-y += gigaset_dev.h header-y += hysdn_if.h header-y += i2o-dev.h header-y += i8k.h -header-y += if_addrlabel.h header-y += if_arcnet.h header-y += if_bonding.h header-y += if_cablemodem.h @@ -95,7 +91,6 @@ header-y += if_tunnel.h header-y += in6.h header-y += in_route.h header-y += ioctl.h -header-y += ip6_tunnel.h header-y += ipmi_msgdefs.h header-y += ipsec.h header-y += ipx.h @@ -122,6 +117,7 @@ header-y += nfs2.h header-y += nfs4_mount.h header-y += nfs_mount.h header-y += nl80211.h +header-y += oom.h header-y += param.h header-y += pci_regs.h header-y += pfkeyv2.h @@ -170,6 +166,7 @@ unifdef-y += adfs_fs.h unifdef-y += agpgart.h unifdef-y += apm_bios.h unifdef-y += atalk.h +unifdef-y += atmarp.h unifdef-y += atmdev.h unifdef-y += atm.h unifdef-y += atm_tcp.h @@ -185,6 +182,7 @@ unifdef-y += cm4000_cs.h unifdef-y += cn_proc.h unifdef-y += coda.h unifdef-y += connector.h +unifdef-y += cramfs_fs.h unifdef-y += cuda.h unifdef-y += cyclades.h unifdef-y += dccp.h @@ -207,6 +205,7 @@ unifdef-y += futex.h unifdef-y += fs.h unifdef-y += gameport.h unifdef-y += generic_serial.h +unifdef-y += gfs2_ondisk.h unifdef-y += hayesesp.h unifdef-y += hdlcdrv.h unifdef-y += hdlc.h @@ -220,6 +219,7 @@ unifdef-y += i2c-dev.h unifdef-y += icmp.h unifdef-y += icmpv6.h unifdef-y += if_addr.h +unifdef-y += if_addrlabel.h unifdef-y += if_arp.h unifdef-y += if_bridge.h unifdef-y += if_ec.h @@ -243,6 +243,7 @@ unifdef-y += ipc.h unifdef-y += ipmi.h unifdef-y += ipv6.h unifdef-y += ipv6_route.h +unifdef-y += ip6_tunnel.h unifdef-y += isdn.h unifdef-y += isdnif.h unifdef-y += isdn_divertif.h diff --git a/trunk/include/linux/acpi.h b/trunk/include/linux/acpi.h index 41f7ce7edd7a..2c7e003356ac 100644 --- a/trunk/include/linux/acpi.h +++ b/trunk/include/linux/acpi.h @@ -79,7 +79,6 @@ typedef int (*acpi_table_handler) (struct acpi_table_header *table); typedef int (*acpi_table_entry_handler) (struct acpi_subtable_header *header, const unsigned long end); char * __acpi_map_table (unsigned long phys_addr, unsigned long size); -int early_acpi_boot_init(void); int acpi_boot_init (void); int acpi_boot_table_init (void); int acpi_numa_init (void); @@ -236,10 +235,6 @@ int acpi_check_mem_region(resource_size_t start, resource_size_t n, #else /* CONFIG_ACPI */ -static inline int early_acpi_boot_init(void) -{ - return 0; -} static inline int acpi_boot_init(void) { return 0; diff --git a/trunk/include/linux/aio.h b/trunk/include/linux/aio.h index b51ddd28444e..0d0b7f629bd3 100644 --- a/trunk/include/linux/aio.h +++ b/trunk/include/linux/aio.h @@ -209,8 +209,27 @@ extern ssize_t wait_on_sync_kiocb(struct kiocb *iocb); extern int aio_put_req(struct kiocb *iocb); extern void kick_iocb(struct kiocb *iocb); extern int aio_complete(struct kiocb *iocb, long res, long res2); +extern void __put_ioctx(struct kioctx *ctx); struct mm_struct; extern void exit_aio(struct mm_struct *mm); +extern struct kioctx *lookup_ioctx(unsigned long ctx_id); +extern int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb, + struct iocb *iocb); + +/* semi private, but used by the 32bit emulations: */ +struct kioctx *lookup_ioctx(unsigned long ctx_id); +int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb, + struct iocb *iocb); + +#define get_ioctx(kioctx) do { \ + BUG_ON(atomic_read(&(kioctx)->users) <= 0); \ + atomic_inc(&(kioctx)->users); \ +} while (0) +#define put_ioctx(kioctx) do { \ + BUG_ON(atomic_read(&(kioctx)->users) <= 0); \ + if (unlikely(atomic_dec_and_test(&(kioctx)->users))) \ + __put_ioctx(kioctx); \ +} while (0) #define io_wait_to_kiocb(wait) container_of(wait, struct kiocb, ki_wait) diff --git a/trunk/include/linux/audit.h b/trunk/include/linux/audit.h index 63c3bb98558f..4ccb048cae1d 100644 --- a/trunk/include/linux/audit.h +++ b/trunk/include/linux/audit.h @@ -146,7 +146,7 @@ /* Rule structure sizes -- if these change, different AUDIT_ADD and * AUDIT_LIST commands must be implemented. */ #define AUDIT_MAX_FIELDS 64 -#define AUDIT_MAX_KEY_LEN 256 +#define AUDIT_MAX_KEY_LEN 32 #define AUDIT_BITMASK_SIZE 64 #define AUDIT_WORD(nr) ((__u32)((nr)/32)) #define AUDIT_BIT(nr) (1 << ((nr) - AUDIT_WORD(nr)*32)) @@ -209,7 +209,6 @@ #define AUDIT_WATCH 105 #define AUDIT_PERM 106 #define AUDIT_DIR 107 -#define AUDIT_FILETYPE 108 #define AUDIT_ARG0 200 #define AUDIT_ARG1 (AUDIT_ARG0+1) @@ -550,20 +549,16 @@ extern void audit_log_format(struct audit_buffer *ab, const char *fmt, ...) __attribute__((format(printf,2,3))); extern void audit_log_end(struct audit_buffer *ab); -extern int audit_string_contains_control(const char *string, - size_t len); -extern void audit_log_n_hex(struct audit_buffer *ab, +extern void audit_log_hex(struct audit_buffer *ab, const unsigned char *buf, size_t len); -extern void audit_log_n_string(struct audit_buffer *ab, - const char *buf, - size_t n); -#define audit_log_string(a,b) audit_log_n_string(a, b, strlen(b)); -extern void audit_log_n_untrustedstring(struct audit_buffer *ab, - const char *string, - size_t n); +extern int audit_string_contains_control(const char *string, + size_t len); extern void audit_log_untrustedstring(struct audit_buffer *ab, const char *string); +extern void audit_log_n_untrustedstring(struct audit_buffer *ab, + size_t n, + const char *string); extern void audit_log_d_path(struct audit_buffer *ab, const char *prefix, struct path *path); @@ -574,8 +569,7 @@ extern int audit_update_lsm_rules(void); extern int audit_filter_user(struct netlink_skb_parms *cb, int type); extern int audit_filter_type(int type); extern int audit_receive_filter(int type, int pid, int uid, int seq, - void *data, size_t datasz, uid_t loginuid, - u32 sessionid, u32 sid); + void *data, size_t datasz, uid_t loginuid, u32 sid); extern int audit_enabled; #else #define audit_log(c,g,t,f,...) do { ; } while (0) @@ -583,11 +577,9 @@ extern int audit_enabled; #define audit_log_vformat(b,f,a) do { ; } while (0) #define audit_log_format(b,f,...) do { ; } while (0) #define audit_log_end(b) do { ; } while (0) -#define audit_log_n_hex(a,b,l) do { ; } while (0) -#define audit_log_n_string(a,c,l) do { ; } while (0) -#define audit_log_string(a,c) do { ; } while (0) -#define audit_log_n_untrustedstring(a,n,s) do { ; } while (0) +#define audit_log_hex(a,b,l) do { ; } while (0) #define audit_log_untrustedstring(a,s) do { ; } while (0) +#define audit_log_n_untrustedstring(a,n,s) do { ; } while (0) #define audit_log_d_path(b, p, d) do { ; } while (0) #define audit_enabled 0 #endif diff --git a/trunk/include/linux/backing-dev.h b/trunk/include/linux/backing-dev.h index b66fa2bdfd9c..48a62baace58 100644 --- a/trunk/include/linux/backing-dev.h +++ b/trunk/include/linux/backing-dev.h @@ -156,7 +156,9 @@ static inline unsigned long bdi_stat_error(struct backing_dev_info *bdi) extern struct backing_dev_info default_backing_dev_info; void default_unplug_io_fn(struct backing_dev_info *bdi, struct page *page); +int writeback_acquire(struct backing_dev_info *bdi); int writeback_in_progress(struct backing_dev_info *bdi); +void writeback_release(struct backing_dev_info *bdi); static inline int bdi_congested(struct backing_dev_info *bdi, int bdi_bits) { diff --git a/trunk/include/linux/binfmts.h b/trunk/include/linux/binfmts.h index b512e48f6d8e..b7fc55ec8d48 100644 --- a/trunk/include/linux/binfmts.h +++ b/trunk/include/linux/binfmts.h @@ -34,8 +34,7 @@ struct linux_binprm{ #endif struct mm_struct *mm; unsigned long p; /* current top of mem */ - unsigned int sh_bang:1, - misc_bang:1; + int sh_bang; struct file * file; int e_uid, e_gid; kernel_cap_t cap_inheritable, cap_permitted; @@ -49,6 +48,7 @@ struct linux_binprm{ unsigned interp_flags; unsigned interp_data; unsigned long loader, exec; + unsigned long argv_len; }; #define BINPRM_FLAGS_ENFORCE_NONDUMP_BIT 0 diff --git a/trunk/include/linux/bio.h b/trunk/include/linux/bio.h index 61c15eaf3fb3..d259690863fb 100644 --- a/trunk/include/linux/bio.h +++ b/trunk/include/linux/bio.h @@ -324,8 +324,6 @@ extern struct bio *bio_map_user_iov(struct request_queue *, extern void bio_unmap_user(struct bio *); extern struct bio *bio_map_kern(struct request_queue *, void *, unsigned int, gfp_t); -extern struct bio *bio_copy_kern(struct request_queue *, void *, unsigned int, - gfp_t, int); extern void bio_set_pages_dirty(struct bio *bio); extern void bio_check_pages_dirty(struct bio *bio); extern struct bio *bio_copy_user(struct request_queue *, unsigned long, unsigned int, int); diff --git a/trunk/include/linux/bitops.h b/trunk/include/linux/bitops.h index 024f2b027244..48bde600a2db 100644 --- a/trunk/include/linux/bitops.h +++ b/trunk/include/linux/bitops.h @@ -6,8 +6,8 @@ #define BIT(nr) (1UL << (nr)) #define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) #define BIT_WORD(nr) ((nr) / BITS_PER_LONG) +#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_LONG) #define BITS_PER_BYTE 8 -#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) #endif /* @@ -114,6 +114,8 @@ static inline unsigned fls_long(unsigned long l) #ifdef __KERNEL__ #ifdef CONFIG_GENERIC_FIND_FIRST_BIT +extern unsigned long __find_first_bit(const unsigned long *addr, + unsigned long size); /** * find_first_bit - find the first set bit in a memory region @@ -122,8 +124,28 @@ static inline unsigned fls_long(unsigned long l) * * Returns the bit number of the first set bit. */ -extern unsigned long find_first_bit(const unsigned long *addr, - unsigned long size); +static __always_inline unsigned long +find_first_bit(const unsigned long *addr, unsigned long size) +{ + /* Avoid a function call if the bitmap size is a constant */ + /* and not bigger than BITS_PER_LONG. */ + + /* insert a sentinel so that __ffs returns size if there */ + /* are no set bits in the bitmap */ + if (__builtin_constant_p(size) && (size < BITS_PER_LONG)) + return __ffs((*addr) | (1ul << size)); + + /* the result of __ffs(0) is undefined, so it needs to be */ + /* handled separately */ + if (__builtin_constant_p(size) && (size == BITS_PER_LONG)) + return ((*addr) == 0) ? BITS_PER_LONG : __ffs(*addr); + + /* size is not constant or too big */ + return __find_first_bit(addr, size); +} + +extern unsigned long __find_first_zero_bit(const unsigned long *addr, + unsigned long size); /** * find_first_zero_bit - find the first cleared bit in a memory region @@ -132,12 +154,31 @@ extern unsigned long find_first_bit(const unsigned long *addr, * * Returns the bit number of the first cleared bit. */ -extern unsigned long find_first_zero_bit(const unsigned long *addr, - unsigned long size); - +static __always_inline unsigned long +find_first_zero_bit(const unsigned long *addr, unsigned long size) +{ + /* Avoid a function call if the bitmap size is a constant */ + /* and not bigger than BITS_PER_LONG. */ + + /* insert a sentinel so that __ffs returns size if there */ + /* are no set bits in the bitmap */ + if (__builtin_constant_p(size) && (size < BITS_PER_LONG)) { + return __ffs(~(*addr) | (1ul << size)); + } + + /* the result of __ffs(0) is undefined, so it needs to be */ + /* handled separately */ + if (__builtin_constant_p(size) && (size == BITS_PER_LONG)) + return (~(*addr) == 0) ? BITS_PER_LONG : __ffs(~(*addr)); + + /* size is not constant or too big */ + return __find_first_zero_bit(addr, size); +} #endif /* CONFIG_GENERIC_FIND_FIRST_BIT */ #ifdef CONFIG_GENERIC_FIND_NEXT_BIT +extern unsigned long __find_next_bit(const unsigned long *addr, + unsigned long size, unsigned long offset); /** * find_next_bit - find the next set bit in a memory region @@ -145,8 +186,36 @@ extern unsigned long find_first_zero_bit(const unsigned long *addr, * @offset: The bitnumber to start searching at * @size: The bitmap size in bits */ -extern unsigned long find_next_bit(const unsigned long *addr, - unsigned long size, unsigned long offset); +static __always_inline unsigned long +find_next_bit(const unsigned long *addr, unsigned long size, + unsigned long offset) +{ + unsigned long value; + + /* Avoid a function call if the bitmap size is a constant */ + /* and not bigger than BITS_PER_LONG. */ + + /* insert a sentinel so that __ffs returns size if there */ + /* are no set bits in the bitmap */ + if (__builtin_constant_p(size) && (size < BITS_PER_LONG)) { + value = (*addr) & ((~0ul) << offset); + value |= (1ul << size); + return __ffs(value); + } + + /* the result of __ffs(0) is undefined, so it needs to be */ + /* handled separately */ + if (__builtin_constant_p(size) && (size == BITS_PER_LONG)) { + value = (*addr) & ((~0ul) << offset); + return (value == 0) ? BITS_PER_LONG : __ffs(value); + } + + /* size is not constant or too big */ + return __find_next_bit(addr, size, offset); +} + +extern unsigned long __find_next_zero_bit(const unsigned long *addr, + unsigned long size, unsigned long offset); /** * find_next_zero_bit - find the next cleared bit in a memory region @@ -154,11 +223,33 @@ extern unsigned long find_next_bit(const unsigned long *addr, * @offset: The bitnumber to start searching at * @size: The bitmap size in bits */ - -extern unsigned long find_next_zero_bit(const unsigned long *addr, - unsigned long size, - unsigned long offset); - +static __always_inline unsigned long +find_next_zero_bit(const unsigned long *addr, unsigned long size, + unsigned long offset) +{ + unsigned long value; + + /* Avoid a function call if the bitmap size is a constant */ + /* and not bigger than BITS_PER_LONG. */ + + /* insert a sentinel so that __ffs returns size if there */ + /* are no set bits in the bitmap */ + if (__builtin_constant_p(size) && (size < BITS_PER_LONG)) { + value = (~(*addr)) & ((~0ul) << offset); + value |= (1ul << size); + return __ffs(value); + } + + /* the result of __ffs(0) is undefined, so it needs to be */ + /* handled separately */ + if (__builtin_constant_p(size) && (size == BITS_PER_LONG)) { + value = (~(*addr)) & ((~0ul) << offset); + return (value == 0) ? BITS_PER_LONG : __ffs(value); + } + + /* size is not constant or too big */ + return __find_next_zero_bit(addr, size, offset); +} #endif /* CONFIG_GENERIC_FIND_NEXT_BIT */ #endif /* __KERNEL__ */ #endif diff --git a/trunk/include/linux/blkdev.h b/trunk/include/linux/blkdev.h index d2a1b71e93c3..c5065e3d2ca9 100644 --- a/trunk/include/linux/blkdev.h +++ b/trunk/include/linux/blkdev.h @@ -215,9 +215,8 @@ struct request { /* * when request is used as a packet command carrier */ - unsigned short cmd_len; - unsigned char __cmd[BLK_MAX_CDB]; - unsigned char *cmd; + unsigned int cmd_len; + unsigned char cmd[BLK_MAX_CDB]; unsigned int data_len; unsigned int extra_len; /* length of alignment and padding */ @@ -408,41 +407,6 @@ struct request_queue #define QUEUE_FLAG_PLUGGED 7 /* queue is plugged */ #define QUEUE_FLAG_ELVSWITCH 8 /* don't use elevator, just do FIFO */ #define QUEUE_FLAG_BIDI 9 /* queue supports bidi requests */ -#define QUEUE_FLAG_NOMERGES 10 /* disable merge attempts */ - -static inline int queue_is_locked(struct request_queue *q) -{ -#ifdef CONFIG_SMP - spinlock_t *lock = q->queue_lock; - return lock && spin_is_locked(lock); -#else - return 1; -#endif -} - -static inline void queue_flag_set_unlocked(unsigned int flag, - struct request_queue *q) -{ - __set_bit(flag, &q->queue_flags); -} - -static inline void queue_flag_set(unsigned int flag, struct request_queue *q) -{ - WARN_ON_ONCE(!queue_is_locked(q)); - __set_bit(flag, &q->queue_flags); -} - -static inline void queue_flag_clear_unlocked(unsigned int flag, - struct request_queue *q) -{ - __clear_bit(flag, &q->queue_flags); -} - -static inline void queue_flag_clear(unsigned int flag, struct request_queue *q) -{ - WARN_ON_ONCE(!queue_is_locked(q)); - __clear_bit(flag, &q->queue_flags); -} enum { /* @@ -487,7 +451,6 @@ enum { #define blk_queue_plugged(q) test_bit(QUEUE_FLAG_PLUGGED, &(q)->queue_flags) #define blk_queue_tagged(q) test_bit(QUEUE_FLAG_QUEUED, &(q)->queue_flags) #define blk_queue_stopped(q) test_bit(QUEUE_FLAG_STOPPED, &(q)->queue_flags) -#define blk_queue_nomerges(q) test_bit(QUEUE_FLAG_NOMERGES, &(q)->queue_flags) #define blk_queue_flushing(q) ((q)->ordseq) #define blk_fs_request(rq) ((rq)->cmd_type == REQ_TYPE_FS) @@ -533,17 +496,17 @@ static inline int blk_queue_full(struct request_queue *q, int rw) static inline void blk_set_queue_full(struct request_queue *q, int rw) { if (rw == READ) - queue_flag_set(QUEUE_FLAG_READFULL, q); + set_bit(QUEUE_FLAG_READFULL, &q->queue_flags); else - queue_flag_set(QUEUE_FLAG_WRITEFULL, q); + set_bit(QUEUE_FLAG_WRITEFULL, &q->queue_flags); } static inline void blk_clear_queue_full(struct request_queue *q, int rw) { if (rw == READ) - queue_flag_clear(QUEUE_FLAG_READFULL, q); + clear_bit(QUEUE_FLAG_READFULL, &q->queue_flags); else - queue_flag_clear(QUEUE_FLAG_WRITEFULL, q); + clear_bit(QUEUE_FLAG_WRITEFULL, &q->queue_flags); } @@ -620,7 +583,6 @@ extern int blk_register_queue(struct gendisk *disk); extern void blk_unregister_queue(struct gendisk *disk); extern void register_disk(struct gendisk *dev); extern void generic_make_request(struct bio *bio); -extern void blk_rq_init(struct request_queue *q, struct request *rq); extern void blk_put_request(struct request *); extern void __blk_put_request(struct request_queue *, struct request *); extern void blk_end_sync_rq(struct request *rq, int error); @@ -664,7 +626,6 @@ extern void blk_start_queue(struct request_queue *q); extern void blk_stop_queue(struct request_queue *q); extern void blk_sync_queue(struct request_queue *q); extern void __blk_stop_queue(struct request_queue *q); -extern void __blk_run_queue(struct request_queue *); extern void blk_run_queue(struct request_queue *); extern void blk_start_queueing(struct request_queue *); extern int blk_rq_map_user(struct request_queue *, struct request *, void __user *, unsigned long); diff --git a/trunk/include/linux/buffer_head.h b/trunk/include/linux/buffer_head.h index 82aa36c53ea7..932eb02a2753 100644 --- a/trunk/include/linux/buffer_head.h +++ b/trunk/include/linux/buffer_head.h @@ -225,6 +225,7 @@ int block_page_mkwrite(struct vm_area_struct *vma, struct page *page, get_block_t get_block); void block_sync_page(struct page *); sector_t generic_block_bmap(struct address_space *, sector_t, get_block_t *); +int generic_commit_write(struct file *, struct page *, unsigned, unsigned); int block_truncate_page(struct address_space *, loff_t, get_block_t *); int file_fsync(struct file *, struct dentry *, int); int nobh_write_begin(struct file *, struct address_space *, diff --git a/trunk/include/linux/capability.h b/trunk/include/linux/capability.h index f4ea0dd9a618..eaab759b1460 100644 --- a/trunk/include/linux/capability.h +++ b/trunk/include/linux/capability.h @@ -365,12 +365,12 @@ typedef struct kernel_cap_struct { # error Fix up hand-coded capability macro initializers #else /* HAND-CODED capability initializers */ -# define CAP_EMPTY_SET ((kernel_cap_t){{ 0, 0 }}) -# define CAP_FULL_SET ((kernel_cap_t){{ ~0, ~0 }}) -# define CAP_INIT_EFF_SET ((kernel_cap_t){{ ~CAP_TO_MASK(CAP_SETPCAP), ~0 }}) -# define CAP_FS_SET ((kernel_cap_t){{ CAP_FS_MASK_B0, CAP_FS_MASK_B1 } }) -# define CAP_NFSD_SET ((kernel_cap_t){{ CAP_FS_MASK_B0|CAP_TO_MASK(CAP_SYS_RESOURCE), \ - CAP_FS_MASK_B1 } }) +# define CAP_EMPTY_SET {{ 0, 0 }} +# define CAP_FULL_SET {{ ~0, ~0 }} +# define CAP_INIT_EFF_SET {{ ~CAP_TO_MASK(CAP_SETPCAP), ~0 }} +# define CAP_FS_SET {{ CAP_FS_MASK_B0, CAP_FS_MASK_B1 } } +# define CAP_NFSD_SET {{ CAP_FS_MASK_B0|CAP_TO_MASK(CAP_SYS_RESOURCE), \ + CAP_FS_MASK_B1 } } #endif /* _LINUX_CAPABILITY_U32S != 2 */ diff --git a/trunk/include/linux/cgroup.h b/trunk/include/linux/cgroup.h index e155aa78d859..a6a6035a4e1e 100644 --- a/trunk/include/linux/cgroup.h +++ b/trunk/include/linux/cgroup.h @@ -88,17 +88,6 @@ static inline void css_put(struct cgroup_subsys_state *css) __css_put(css); } -/* bits in struct cgroup flags field */ -enum { - /* Control Group is dead */ - CGRP_REMOVED, - /* Control Group has previously had a child cgroup or a task, - * but no longer (only if CGRP_NOTIFY_ON_RELEASE is set) */ - CGRP_RELEASABLE, - /* Control Group requires release notifications to userspace */ - CGRP_NOTIFY_ON_RELEASE, -}; - struct cgroup { unsigned long flags; /* "unsigned long" so bitops work */ @@ -150,10 +139,10 @@ struct css_set { struct kref ref; /* - * List running through all cgroup groups in the same hash - * slot. Protected by css_set_lock + * List running through all cgroup groups. Protected by + * css_set_lock */ - struct hlist_node hlist; + struct list_head list; /* * List running through all tasks using this cgroup @@ -174,16 +163,7 @@ struct css_set { * during subsystem registration (at boot time). */ struct cgroup_subsys_state *subsys[CGROUP_SUBSYS_COUNT]; -}; - -/* - * cgroup_map_cb is an abstract callback API for reporting map-valued - * control files - */ -struct cgroup_map_cb { - int (*fill)(struct cgroup_map_cb *cb, const char *key, u64 value); - void *state; }; /* struct cftype: @@ -210,51 +190,20 @@ struct cftype { struct file *file, char __user *buf, size_t nbytes, loff_t *ppos); /* - * read_u64() is a shortcut for the common case of returning a + * read_uint() is a shortcut for the common case of returning a * single integer. Use it in place of read() */ - u64 (*read_u64) (struct cgroup *cgrp, struct cftype *cft); - /* - * read_s64() is a signed version of read_u64() - */ - s64 (*read_s64) (struct cgroup *cgrp, struct cftype *cft); - /* - * read_map() is used for defining a map of key/value - * pairs. It should call cb->fill(cb, key, value) for each - * entry. The key/value pairs (and their ordering) should not - * change between reboots. - */ - int (*read_map) (struct cgroup *cont, struct cftype *cft, - struct cgroup_map_cb *cb); - /* - * read_seq_string() is used for outputting a simple sequence - * using seqfile. - */ - int (*read_seq_string) (struct cgroup *cont, struct cftype *cft, - struct seq_file *m); - + u64 (*read_uint) (struct cgroup *cgrp, struct cftype *cft); ssize_t (*write) (struct cgroup *cgrp, struct cftype *cft, struct file *file, const char __user *buf, size_t nbytes, loff_t *ppos); /* - * write_u64() is a shortcut for the common case of accepting + * write_uint() is a shortcut for the common case of accepting * a single integer (as parsed by simple_strtoull) from * userspace. Use in place of write(); return 0 or error. */ - int (*write_u64) (struct cgroup *cgrp, struct cftype *cft, u64 val); - /* - * write_s64() is a signed version of write_u64() - */ - int (*write_s64) (struct cgroup *cgrp, struct cftype *cft, s64 val); - - /* - * trigger() callback can be used to get some kick from the - * userspace, when the actual string written is not important - * at all. The private field can be used to determine the - * kick type for multiplexing. - */ - int (*trigger)(struct cgroup *cgrp, unsigned int event); + int (*write_uint) (struct cgroup *cgrp, struct cftype *cft, u64 val); int (*release) (struct inode *inode, struct file *file); }; @@ -305,12 +254,6 @@ struct cgroup_subsys { struct cgroup *cgrp); void (*post_clone)(struct cgroup_subsys *ss, struct cgroup *cgrp); void (*bind)(struct cgroup_subsys *ss, struct cgroup *root); - /* - * This routine is called with the task_lock of mm->owner held - */ - void (*mm_owner_changed)(struct cgroup_subsys *ss, - struct cgroup *old, - struct cgroup *new); int subsys_id; int active; int disabled; @@ -396,13 +339,4 @@ static inline int cgroupstats_build(struct cgroupstats *stats, #endif /* !CONFIG_CGROUPS */ -#ifdef CONFIG_MM_OWNER -extern void -cgroup_mm_owner_callbacks(struct task_struct *old, struct task_struct *new); -#else /* !CONFIG_MM_OWNER */ -static inline void -cgroup_mm_owner_callbacks(struct task_struct *old, struct task_struct *new) -{ -} -#endif /* CONFIG_MM_OWNER */ #endif /* _LINUX_CGROUP_H */ diff --git a/trunk/include/linux/cgroup_subsys.h b/trunk/include/linux/cgroup_subsys.h index e2877454ec82..1ddebfc52565 100644 --- a/trunk/include/linux/cgroup_subsys.h +++ b/trunk/include/linux/cgroup_subsys.h @@ -42,9 +42,3 @@ SUBSYS(mem_cgroup) #endif /* */ - -#ifdef CONFIG_CGROUP_DEVICE -SUBSYS(devices) -#endif - -/* */ diff --git a/trunk/include/linux/coda_linux.h b/trunk/include/linux/coda_linux.h index 31b75311e2ca..1c47a34aa794 100644 --- a/trunk/include/linux/coda_linux.h +++ b/trunk/include/linux/coda_linux.h @@ -43,6 +43,9 @@ int coda_getattr(struct vfsmount *, struct dentry *, struct kstat *); int coda_setattr(struct dentry *, struct iattr *); /* this file: heloers */ +static __inline__ struct CodaFid *coda_i2f(struct inode *); +static __inline__ char *coda_i2s(struct inode *); +static __inline__ void coda_flag_inode(struct inode *, int flag); char *coda_f2s(struct CodaFid *f); int coda_isroot(struct inode *i); int coda_iscontrol(const char *name, size_t length); diff --git a/trunk/include/linux/console_struct.h b/trunk/include/linux/console_struct.h index b03f80a078be..d71f7c0f931b 100644 --- a/trunk/include/linux/console_struct.h +++ b/trunk/include/linux/console_struct.h @@ -53,7 +53,6 @@ struct vc_data { unsigned short vc_hi_font_mask; /* [#] Attribute set for upper 256 chars of font or 0 if not supported */ struct console_font vc_font; /* Current VC font set */ unsigned short vc_video_erase_char; /* Background erase character */ - unsigned short vc_scrl_erase_char; /* Erase character for scroll */ /* VT terminal data */ unsigned int vc_state; /* Escape sequence parser state */ unsigned int vc_npar,vc_par[NPAR]; /* Parameters of current escape sequence */ diff --git a/trunk/include/linux/cpu.h b/trunk/include/linux/cpu.h index 7464ba3b4333..f212fa98283e 100644 --- a/trunk/include/linux/cpu.h +++ b/trunk/include/linux/cpu.h @@ -108,7 +108,7 @@ static inline void cpuhotplug_mutex_unlock(struct mutex *cpu_hp_mutex) extern void get_online_cpus(void); extern void put_online_cpus(void); #define hotcpu_notifier(fn, pri) { \ - static struct notifier_block fn##_nb __cpuinitdata = \ + static struct notifier_block fn##_nb = \ { .notifier_call = fn, .priority = pri }; \ register_cpu_notifier(&fn##_nb); \ } diff --git a/trunk/include/linux/cpufreq.h b/trunk/include/linux/cpufreq.h index e7e91dbfde0f..ddd8652fc3f3 100644 --- a/trunk/include/linux/cpufreq.h +++ b/trunk/include/linux/cpufreq.h @@ -83,8 +83,7 @@ struct cpufreq_real_policy { }; struct cpufreq_policy { - cpumask_t cpus; /* CPUs requiring sw coordination */ - cpumask_t related_cpus; /* CPUs with any coordination */ + cpumask_t cpus; /* affected CPUs */ unsigned int shared_type; /* ANY or ALL affected CPUs should set cpufreq */ unsigned int cpu; /* cpu nr of registered CPU */ @@ -308,9 +307,6 @@ extern struct cpufreq_governor cpufreq_gov_performance; #endif #ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE #define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_performance) -#elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE) -extern struct cpufreq_governor cpufreq_gov_powersave; -#define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_powersave) #elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE) extern struct cpufreq_governor cpufreq_gov_userspace; #define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_userspace) diff --git a/trunk/include/linux/device_cgroup.h b/trunk/include/linux/device_cgroup.h deleted file mode 100644 index 0b0d9c39ed67..000000000000 --- a/trunk/include/linux/device_cgroup.h +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include - -#ifdef CONFIG_CGROUP_DEVICE -extern int devcgroup_inode_permission(struct inode *inode, int mask); -extern int devcgroup_inode_mknod(int mode, dev_t dev); -#else -static inline int devcgroup_inode_permission(struct inode *inode, int mask) -{ return 0; } -static inline int devcgroup_inode_mknod(int mode, dev_t dev) -{ return 0; } -#endif diff --git a/trunk/include/linux/dma-attrs.h b/trunk/include/linux/dma-attrs.h deleted file mode 100644 index 1677e2bfa00c..000000000000 --- a/trunk/include/linux/dma-attrs.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef _DMA_ATTR_H -#define _DMA_ATTR_H - -#include -#include -#include - -/** - * an enum dma_attr represents an attribute associated with a DMA - * mapping. The semantics of each attribute should be defined in - * Documentation/DMA-attributes.txt. - */ -enum dma_attr { - DMA_ATTR_WRITE_BARRIER, - DMA_ATTR_MAX, -}; - -#define __DMA_ATTRS_LONGS BITS_TO_LONGS(DMA_ATTR_MAX) - -/** - * struct dma_attrs - an opaque container for DMA attributes - * @flags - bitmask representing a collection of enum dma_attr - */ -struct dma_attrs { - unsigned long flags[__DMA_ATTRS_LONGS]; -}; - -#define DEFINE_DMA_ATTRS(x) \ - struct dma_attrs x = { \ - .flags = { [0 ... __DMA_ATTRS_LONGS-1] = 0 }, \ - } - -static inline void init_dma_attrs(struct dma_attrs *attrs) -{ - bitmap_zero(attrs->flags, __DMA_ATTRS_LONGS); -} - -#ifdef CONFIG_HAVE_DMA_ATTRS -/** - * dma_set_attr - set a specific attribute - * @attr: attribute to set - * @attrs: struct dma_attrs (may be NULL) - */ -static inline void dma_set_attr(enum dma_attr attr, struct dma_attrs *attrs) -{ - if (attrs == NULL) - return; - BUG_ON(attr >= DMA_ATTR_MAX); - __set_bit(attr, attrs->flags); -} - -/** - * dma_get_attr - check for a specific attribute - * @attr: attribute to set - * @attrs: struct dma_attrs (may be NULL) - */ -static inline int dma_get_attr(enum dma_attr attr, struct dma_attrs *attrs) -{ - if (attrs == NULL) - return 0; - BUG_ON(attr >= DMA_ATTR_MAX); - return test_bit(attr, attrs->flags); -} -#else /* !CONFIG_HAVE_DMA_ATTRS */ -static inline void dma_set_attr(enum dma_attr attr, struct dma_attrs *attrs) -{ -} - -static inline int dma_get_attr(enum dma_attr attr, struct dma_attrs *attrs) -{ - return 0; -} -#endif /* CONFIG_HAVE_DMA_ATTRS */ -#endif /* _DMA_ATTR_H */ diff --git a/trunk/include/linux/dma-mapping.h b/trunk/include/linux/dma-mapping.h index 952e0f857ac9..332030709623 100644 --- a/trunk/include/linux/dma-mapping.h +++ b/trunk/include/linux/dma-mapping.h @@ -146,21 +146,4 @@ static inline void dmam_release_declared_memory(struct device *dev) } #endif /* ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY */ -#ifndef CONFIG_HAVE_DMA_ATTRS -struct dma_attrs; - -#define dma_map_single_attrs(dev, cpu_addr, size, dir, attrs) \ - dma_map_single(dev, cpu_addr, size, dir) - -#define dma_unmap_single_attrs(dev, dma_addr, size, dir, attrs) \ - dma_unmap_single(dev, dma_addr, size, dir) - -#define dma_map_sg_attrs(dev, sgl, nents, dir, attrs) \ - dma_map_sg(dev, sgl, nents, dir) - -#define dma_unmap_sg_attrs(dev, sgl, nents, dir, attrs) \ - dma_unmap_sg(dev, sgl, nents, dir) - -#endif /* CONFIG_HAVE_DMA_ATTRS */ - #endif diff --git a/trunk/include/linux/edac.h b/trunk/include/linux/edac.h index 7cf92e8a4196..eab451e69a91 100644 --- a/trunk/include/linux/edac.h +++ b/trunk/include/linux/edac.h @@ -3,7 +3,7 @@ * * Author: Dave Jiang * - * 2006-2008 (c) MontaVista Software, Inc. This file is licensed under + * 2006-2007 (c) MontaVista Software, Inc. This file is licensed under * the terms of the GNU General Public License version 2. This program * is licensed "as is" without any warranty of any kind, whether express * or implied. @@ -26,16 +26,4 @@ extern atomic_t edac_handlers; extern int edac_handler_set(void); extern void edac_atomic_assert_error(void); -static inline void opstate_init(void) -{ - switch (edac_op_state) { - case EDAC_OPSTATE_POLL: - case EDAC_OPSTATE_NMI: - break; - default: - edac_op_state = EDAC_OPSTATE_POLL; - } - return; -} - #endif diff --git a/trunk/include/linux/elf.h b/trunk/include/linux/elf.h index ff9fbed90123..bad1b16ec49a 100644 --- a/trunk/include/linux/elf.h +++ b/trunk/include/linux/elf.h @@ -208,7 +208,7 @@ typedef struct elf32_hdr{ } Elf32_Ehdr; typedef struct elf64_hdr { - unsigned char e_ident[EI_NIDENT]; /* ELF "magic number" */ + unsigned char e_ident[16]; /* ELF "magic number" */ Elf64_Half e_type; Elf64_Half e_machine; Elf64_Word e_version; diff --git a/trunk/include/linux/fs.h b/trunk/include/linux/fs.h index a1ba005d08e7..2c925747bc49 100644 --- a/trunk/include/linux/fs.h +++ b/trunk/include/linux/fs.h @@ -1521,6 +1521,7 @@ extern int get_sb_pseudo(struct file_system_type *, char *, const struct super_operations *ops, unsigned long, struct vfsmount *mnt); extern int simple_set_mnt(struct vfsmount *mnt, struct super_block *sb); +int __put_super(struct super_block *sb); int __put_super_and_need_restart(struct super_block *sb); void unnamed_dev_init(void); @@ -1964,6 +1965,7 @@ extern int vfs_stat_fd(int dfd, char __user *, struct kstat *); extern int vfs_lstat_fd(int dfd, char __user *, struct kstat *); extern int vfs_fstat(unsigned int, struct kstat *); +extern long vfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); extern int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd, unsigned long arg); diff --git a/trunk/include/linux/gfp.h b/trunk/include/linux/gfp.h index b414be387180..c37653b6843f 100644 --- a/trunk/include/linux/gfp.h +++ b/trunk/include/linux/gfp.h @@ -40,9 +40,9 @@ struct vm_area_struct; #define __GFP_FS ((__force gfp_t)0x80u) /* Can call down to low-level FS? */ #define __GFP_COLD ((__force gfp_t)0x100u) /* Cache-cold page required */ #define __GFP_NOWARN ((__force gfp_t)0x200u) /* Suppress page allocation failure warning */ -#define __GFP_REPEAT ((__force gfp_t)0x400u) /* See above */ -#define __GFP_NOFAIL ((__force gfp_t)0x800u) /* See above */ -#define __GFP_NORETRY ((__force gfp_t)0x1000u)/* See above */ +#define __GFP_REPEAT ((__force gfp_t)0x400u) /* Retry the allocation. Might fail */ +#define __GFP_NOFAIL ((__force gfp_t)0x800u) /* Retry for ever. Cannot fail */ +#define __GFP_NORETRY ((__force gfp_t)0x1000u)/* Do not retry. Might fail */ #define __GFP_COMP ((__force gfp_t)0x4000u)/* Add compound page metadata */ #define __GFP_ZERO ((__force gfp_t)0x8000u)/* Return zeroed page on success */ #define __GFP_NOMEMALLOC ((__force gfp_t)0x10000u) /* Don't use emergency reserves */ diff --git a/trunk/include/linux/i2c-id.h b/trunk/include/linux/i2c-id.h index 580acc93903e..32eb8bbe4831 100644 --- a/trunk/include/linux/i2c-id.h +++ b/trunk/include/linux/i2c-id.h @@ -79,9 +79,12 @@ #define I2C_DRIVERID_UPD64031A 79 /* upd64031a video processor */ #define I2C_DRIVERID_SAA717X 80 /* saa717x video encoder */ #define I2C_DRIVERID_DS1672 81 /* Dallas/Maxim DS1672 RTC */ +#define I2C_DRIVERID_X1205 82 /* Xicor/Intersil X1205 RTC */ +#define I2C_DRIVERID_PCF8563 83 /* Philips PCF8563 RTC */ #define I2C_DRIVERID_BT866 85 /* Conexant bt866 video encoder */ #define I2C_DRIVERID_KS0127 86 /* Samsung ks0127 video decoder */ #define I2C_DRIVERID_TLV320AIC23B 87 /* TI TLV320AIC23B audio codec */ +#define I2C_DRIVERID_ISL1208 88 /* Intersil ISL1208 RTC */ #define I2C_DRIVERID_WM8731 89 /* Wolfson WM8731 audio codec */ #define I2C_DRIVERID_WM8750 90 /* Wolfson WM8750 audio codec */ #define I2C_DRIVERID_WM8753 91 /* Wolfson WM8753 audio codec */ diff --git a/trunk/include/linux/i2c.h b/trunk/include/linux/i2c.h index cb63da5c2139..365e0df3646b 100644 --- a/trunk/include/linux/i2c.h +++ b/trunk/include/linux/i2c.h @@ -126,7 +126,7 @@ struct i2c_driver { * With the driver model, device enumeration is NEVER done by drivers; * it's done by infrastructure. (NEW STYLE DRIVERS ONLY) */ - int (*probe)(struct i2c_client *, const struct i2c_device_id *); + int (*probe)(struct i2c_client *); int (*remove)(struct i2c_client *); /* driver model interfaces that don't relate to enumeration */ @@ -140,10 +140,11 @@ struct i2c_driver { int (*command)(struct i2c_client *client,unsigned int cmd, void *arg); struct device_driver driver; - const struct i2c_device_id *id_table; }; #define to_i2c_driver(d) container_of(d, struct i2c_driver, driver) +#define I2C_NAME_SIZE 20 + /** * struct i2c_client - represent an I2C slave device * @flags: I2C_CLIENT_TEN indicates the device uses a ten bit chip address; @@ -229,17 +230,17 @@ struct i2c_board_info { }; /** - * I2C_BOARD_INFO - macro used to list an i2c device and its address - * @dev_type: identifies the device type + * I2C_BOARD_INFO - macro used to list an i2c device and its driver + * @driver: identifies the driver to use with the device * @dev_addr: the device's address on the bus. * * This macro initializes essential fields of a struct i2c_board_info, * declaring what has been provided on a particular board. Optional - * fields (such as associated irq, or device-specific platform_data) - * are provided using conventional syntax. + * fields (such as the chip type, its associated irq, or device-specific + * platform_data) are provided using conventional syntax. */ -#define I2C_BOARD_INFO(dev_type,dev_addr) \ - .type = (dev_type), .addr = (dev_addr) +#define I2C_BOARD_INFO(driver,dev_addr) \ + .driver_name = (driver), .addr = (dev_addr) /* Add-on boards should register/unregister their devices; e.g. a board diff --git a/trunk/include/linux/idr.h b/trunk/include/linux/idr.h index 9a2d762124de..0edda411959c 100644 --- a/trunk/include/linux/idr.h +++ b/trunk/include/linux/idr.h @@ -14,7 +14,6 @@ #include #include -#include #if BITS_PER_LONG == 32 # define IDR_BITS 5 @@ -116,6 +115,4 @@ void ida_remove(struct ida *ida, int id); void ida_destroy(struct ida *ida); void ida_init(struct ida *ida); -void __init idr_init_cache(void); - #endif /* __IDR_H__ */ diff --git a/trunk/include/linux/init.h b/trunk/include/linux/init.h index 21d658cdfa27..fb58c0493cf2 100644 --- a/trunk/include/linux/init.h +++ b/trunk/include/linux/init.h @@ -147,8 +147,6 @@ extern unsigned int reset_devices; void setup_arch(char **); void prepare_namespace(void); -extern void (*late_time_init)(void); - #endif #ifndef MODULE diff --git a/trunk/include/linux/interrupt.h b/trunk/include/linux/interrupt.h index f1fc7470d26c..b5fef13148bd 100644 --- a/trunk/include/linux/interrupt.h +++ b/trunk/include/linux/interrupt.h @@ -289,7 +289,6 @@ struct softirq_action }; asmlinkage void do_softirq(void); -asmlinkage void __do_softirq(void); extern void open_softirq(int nr, void (*action)(struct softirq_action*), void *data); extern void softirq_init(void); #define __raise_softirq_irqoff(nr) do { or_softirq_pending(1UL << (nr)); } while (0) diff --git a/trunk/include/linux/ipc_namespace.h b/trunk/include/linux/ipc_namespace.h index ea6c18a8b0d4..e4451d1da753 100644 --- a/trunk/include/linux/ipc_namespace.h +++ b/trunk/include/linux/ipc_namespace.h @@ -4,17 +4,6 @@ #include #include #include -#include - -/* - * ipc namespace events - */ -#define IPCNS_MEMCHANGED 0x00000001 /* Notify lowmem size changed */ -#define IPCNS_CREATED 0x00000002 /* Notify new ipc namespace created */ -#define IPCNS_REMOVED 0x00000003 /* Notify ipc namespace removed */ - -#define IPCNS_CALLBACK_PRI 0 - struct ipc_ids { int in_use; @@ -41,24 +30,15 @@ struct ipc_namespace { size_t shm_ctlall; int shm_ctlmni; int shm_tot; - - struct notifier_block ipcns_nb; }; extern struct ipc_namespace init_ipc_ns; -extern atomic_t nr_ipc_ns; #ifdef CONFIG_SYSVIPC #define INIT_IPC_NS(ns) .ns = &init_ipc_ns, - -extern int register_ipcns_notifier(struct ipc_namespace *); -extern int cond_register_ipcns_notifier(struct ipc_namespace *); -extern int unregister_ipcns_notifier(struct ipc_namespace *); -extern int ipcns_notify(unsigned long); - -#else /* CONFIG_SYSVIPC */ +#else #define INIT_IPC_NS(ns) -#endif /* CONFIG_SYSVIPC */ +#endif #if defined(CONFIG_SYSVIPC) && defined(CONFIG_IPC_NS) extern void free_ipc_ns(struct kref *kref); diff --git a/trunk/include/linux/ipmi.h b/trunk/include/linux/ipmi.h index 7ebdb4fb4e54..c5bd28b69aec 100644 --- a/trunk/include/linux/ipmi.h +++ b/trunk/include/linux/ipmi.h @@ -64,7 +64,7 @@ * applications and another for userland applications. The * capabilities are basically the same for both interface, although * the interfaces are somewhat different. The stuff in the - * #ifdef __KERNEL__ below is the in-kernel interface. The userland + * #ifdef KERNEL below is the in-kernel interface. The userland * interface is defined later in the file. */ @@ -75,7 +75,8 @@ * work for sockets. */ #define IPMI_MAX_ADDR_SIZE 32 -struct ipmi_addr { +struct ipmi_addr +{ /* Try to take these from the "Channel Medium Type" table in section 6.5 of the IPMI 1.5 manual. */ int addr_type; @@ -89,7 +90,8 @@ struct ipmi_addr { * 0), or IPMC_BMC_CHANNEL if communicating directly with the BMC. */ #define IPMI_SYSTEM_INTERFACE_ADDR_TYPE 0x0c -struct ipmi_system_interface_addr { +struct ipmi_system_interface_addr +{ int addr_type; short channel; unsigned char lun; @@ -98,9 +100,10 @@ struct ipmi_system_interface_addr { /* An IPMB Address. */ #define IPMI_IPMB_ADDR_TYPE 0x01 /* Used for broadcast get device id as described in section 17.9 of the - IPMI 1.5 manual. */ + IPMI 1.5 manual. */ #define IPMI_IPMB_BROADCAST_ADDR_TYPE 0x41 -struct ipmi_ipmb_addr { +struct ipmi_ipmb_addr +{ int addr_type; short channel; unsigned char slave_addr; @@ -125,7 +128,8 @@ struct ipmi_ipmb_addr { * message is a little weird, but this is required. */ #define IPMI_LAN_ADDR_TYPE 0x04 -struct ipmi_lan_addr { +struct ipmi_lan_addr +{ int addr_type; short channel; unsigned char privilege; @@ -158,14 +162,16 @@ struct ipmi_lan_addr { * byte of data in the response (as the spec shows the messages laid * out). */ -struct ipmi_msg { +struct ipmi_msg +{ unsigned char netfn; unsigned char cmd; unsigned short data_len; unsigned char __user *data; }; -struct kernel_ipmi_msg { +struct kernel_ipmi_msg +{ unsigned char netfn; unsigned char cmd; unsigned short data_len; @@ -233,11 +239,12 @@ typedef struct ipmi_user *ipmi_user_t; * used after the message is delivered, so the upper layer may use the * link to build a linked list, if it likes. */ -struct ipmi_recv_msg { +struct ipmi_recv_msg +{ struct list_head link; /* The type of message as defined in the "Receive Types" - defines above. */ + defines above. */ int recv_type; ipmi_user_t user; @@ -264,8 +271,9 @@ struct ipmi_recv_msg { /* Allocate and free the receive message. */ void ipmi_free_recv_msg(struct ipmi_recv_msg *msg); -struct ipmi_user_hndl { - /* Routine type to call when a message needs to be routed to +struct ipmi_user_hndl +{ + /* Routine type to call when a message needs to be routed to the upper layer. This will be called with some locks held, the only IPMI routines that can be called are ipmi_request and the alloc/free operations. The handler_data is the @@ -360,8 +368,9 @@ int ipmi_request_supply_msgs(ipmi_user_t user, * Poll the IPMI interface for the user. This causes the IPMI code to * do an immediate check for information from the driver and handle * anything that is immediately pending. This will not block in any - * way. This is useful if you need to spin waiting for something to - * happen in the IPMI driver. + * way. This is useful if you need to implement polling from the user + * for things like modifying the watchdog timeout when a panic occurs + * or disabling the watchdog timer on a reboot. */ void ipmi_poll_interface(ipmi_user_t user); @@ -412,6 +421,12 @@ int ipmi_unregister_for_cmd(ipmi_user_t user, int ipmi_get_maintenance_mode(ipmi_user_t user); int ipmi_set_maintenance_mode(ipmi_user_t user, int mode); +/* + * Allow run-to-completion mode to be set for the interface of + * a specific user. + */ +void ipmi_user_set_run_to_completion(ipmi_user_t user, int val); + /* * When the user is created, it will not receive IPMI events by * default. The user must set this to TRUE to get incoming events. @@ -425,7 +440,8 @@ int ipmi_set_gets_events(ipmi_user_t user, int val); * every existing interface when a new watcher is registered with * ipmi_smi_watcher_register(). */ -struct ipmi_smi_watcher { +struct ipmi_smi_watcher +{ struct list_head link; /* You must set the owner to the current module, if you are in @@ -496,7 +512,8 @@ int ipmi_validate_addr(struct ipmi_addr *addr, int len); /* Messages sent to the interface are this format. */ -struct ipmi_req { +struct ipmi_req +{ unsigned char __user *addr; /* Address to send the message to. */ unsigned int addr_len; @@ -521,11 +538,12 @@ struct ipmi_req { /* Messages sent to the interface with timing parameters are this format. */ -struct ipmi_req_settime { +struct ipmi_req_settime +{ struct ipmi_req req; /* See ipmi_request_settime() above for details on these - values. */ + values. */ int retries; unsigned int retry_time_ms; }; @@ -542,7 +560,8 @@ struct ipmi_req_settime { struct ipmi_req_settime) /* Messages received from the interface are this format. */ -struct ipmi_recv { +struct ipmi_recv +{ int recv_type; /* Is this a command, response or an asyncronous event. */ @@ -588,12 +607,13 @@ struct ipmi_recv { struct ipmi_recv) /* Register to get commands from other entities on this interface. */ -struct ipmi_cmdspec { +struct ipmi_cmdspec +{ unsigned char netfn; unsigned char cmd; }; -/* +/* * Register to receive a specific command. error values: * - EFAULT - an address supplied was invalid. * - EBUSY - The netfn/cmd supplied was already in use. @@ -616,7 +636,8 @@ struct ipmi_cmdspec { * else. The chans field is a bitmask, (1 << channel) for each channel. * It may be IPMI_CHAN_ALL for all channels. */ -struct ipmi_cmdspec_chans { +struct ipmi_cmdspec_chans +{ unsigned int netfn; unsigned int cmd; unsigned int chans; @@ -638,7 +659,7 @@ struct ipmi_cmdspec_chans { #define IPMICTL_UNREGISTER_FOR_CMD_CHANS _IOR(IPMI_IOC_MAGIC, 29, \ struct ipmi_cmdspec_chans) -/* +/* * Set whether this interface receives events. Note that the first * user registered for events will get all pending events for the * interface. error values: @@ -654,18 +675,15 @@ struct ipmi_cmdspec_chans { * things it takes to determine your address (if not the BMC) and set * it for everyone else. You should probably leave the LUN alone. */ -struct ipmi_channel_lun_address_set { +struct ipmi_channel_lun_address_set +{ unsigned short channel; unsigned char value; }; -#define IPMICTL_SET_MY_CHANNEL_ADDRESS_CMD \ - _IOR(IPMI_IOC_MAGIC, 24, struct ipmi_channel_lun_address_set) -#define IPMICTL_GET_MY_CHANNEL_ADDRESS_CMD \ - _IOR(IPMI_IOC_MAGIC, 25, struct ipmi_channel_lun_address_set) -#define IPMICTL_SET_MY_CHANNEL_LUN_CMD \ - _IOR(IPMI_IOC_MAGIC, 26, struct ipmi_channel_lun_address_set) -#define IPMICTL_GET_MY_CHANNEL_LUN_CMD \ - _IOR(IPMI_IOC_MAGIC, 27, struct ipmi_channel_lun_address_set) +#define IPMICTL_SET_MY_CHANNEL_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 24, struct ipmi_channel_lun_address_set) +#define IPMICTL_GET_MY_CHANNEL_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 25, struct ipmi_channel_lun_address_set) +#define IPMICTL_SET_MY_CHANNEL_LUN_CMD _IOR(IPMI_IOC_MAGIC, 26, struct ipmi_channel_lun_address_set) +#define IPMICTL_GET_MY_CHANNEL_LUN_CMD _IOR(IPMI_IOC_MAGIC, 27, struct ipmi_channel_lun_address_set) /* Legacy interfaces, these only set IPMB 0. */ #define IPMICTL_SET_MY_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 17, unsigned int) #define IPMICTL_GET_MY_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 18, unsigned int) @@ -676,7 +694,8 @@ struct ipmi_channel_lun_address_set { * Get/set the default timing values for an interface. You shouldn't * generally mess with these. */ -struct ipmi_timing_parms { +struct ipmi_timing_parms +{ int retries; unsigned int retry_time_ms; }; diff --git a/trunk/include/linux/ipmi_smi.h b/trunk/include/linux/ipmi_smi.h index 62b73668b602..6e8cec503380 100644 --- a/trunk/include/linux/ipmi_smi.h +++ b/trunk/include/linux/ipmi_smi.h @@ -60,7 +60,8 @@ typedef struct ipmi_smi *ipmi_smi_t; * asynchronous data and messages and request them from the * interface. */ -struct ipmi_smi_msg { +struct ipmi_smi_msg +{ struct list_head link; long msgid; @@ -73,11 +74,12 @@ struct ipmi_smi_msg { unsigned char rsp[IPMI_MAX_MSG_LENGTH]; /* Will be called when the system is done with the message - (presumably to free it). */ + (presumably to free it). */ void (*done)(struct ipmi_smi_msg *msg); }; -struct ipmi_smi_handlers { +struct ipmi_smi_handlers +{ struct module *owner; /* The low-level interface cannot start sending messages to @@ -229,7 +231,7 @@ static inline void ipmi_free_smi_msg(struct ipmi_smi_msg *msg) directory for this interface. Note that the entry will automatically be dstroyed when the interface is destroyed. */ int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name, - read_proc_t *read_proc, + read_proc_t *read_proc, write_proc_t *write_proc, void *data, struct module *owner); #endif /* __LINUX_IPMI_SMI_H */ diff --git a/trunk/include/linux/kbuild.h b/trunk/include/linux/kbuild.h deleted file mode 100644 index 22a72198c14b..000000000000 --- a/trunk/include/linux/kbuild.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef __LINUX_KBUILD_H -#define __LINUX_KBUILD_H - -#define DEFINE(sym, val) \ - asm volatile("\n->" #sym " %0 " #val : : "i" (val)) - -#define BLANK() asm volatile("\n->" : : ) - -#define OFFSET(sym, str, mem) \ - DEFINE(sym, offsetof(struct str, mem)) - -#define COMMENT(x) \ - asm volatile("\n->#" x) - -#endif diff --git a/trunk/include/linux/kernel.h b/trunk/include/linux/kernel.h index 53839ba265ec..cd6d02cf854d 100644 --- a/trunk/include/linux/kernel.h +++ b/trunk/include/linux/kernel.h @@ -20,9 +20,6 @@ extern const char linux_banner[]; extern const char linux_proc_banner[]; -#define USHORT_MAX ((u16)(~0U)) -#define SHORT_MAX ((s16)(USHORT_MAX>>1)) -#define SHORT_MIN (-SHORT_MAX - 1) #define INT_MAX ((int)(~0U>>1)) #define INT_MIN (-INT_MAX - 1) #define UINT_MAX (~0U) @@ -191,7 +188,6 @@ extern int log_buf_copy(char *dest, int idx, int len); extern int printk_ratelimit_jiffies; extern int printk_ratelimit_burst; extern int printk_ratelimit(void); -extern int __ratelimit(int ratelimit_jiffies, int ratelimit_burst); extern int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst); extern bool printk_timed_ratelimit(unsigned long *caller_jiffies, unsigned int interval_msec); @@ -259,7 +255,6 @@ extern enum system_states { #define TAINT_USER (1<<6) #define TAINT_DIE (1<<7) #define TAINT_OVERRIDDEN_ACPI_TABLE (1<<8) -#define TAINT_WARN (1<<9) extern void dump_stack(void) __cold; diff --git a/trunk/include/linux/key.h b/trunk/include/linux/key.h index c45c962d1cc5..a70b8a8f2005 100644 --- a/trunk/include/linux/key.h +++ b/trunk/include/linux/key.h @@ -19,7 +19,6 @@ #include #include #include -#include #include #ifdef __KERNEL__ @@ -68,8 +67,6 @@ struct key; #define KEY_OTH_SETATTR 0x00000020 #define KEY_OTH_ALL 0x0000003f -#define KEY_PERM_UNDEF 0xffffffff - struct seq_file; struct user_struct; struct signal_struct; @@ -211,19 +208,16 @@ extern struct key *request_key(struct key_type *type, extern struct key *request_key_with_auxdata(struct key_type *type, const char *description, - const void *callout_info, - size_t callout_len, + const char *callout_info, void *aux); extern struct key *request_key_async(struct key_type *type, const char *description, - const void *callout_info, - size_t callout_len); + const char *callout_info); extern struct key *request_key_async_with_auxdata(struct key_type *type, const char *description, - const void *callout_info, - size_t callout_len, + const char *callout_info, void *aux); extern int wait_for_key_construction(struct key *key, bool intr); @@ -235,7 +229,6 @@ extern key_ref_t key_create_or_update(key_ref_t keyring, const char *description, const void *payload, size_t plen, - key_perm_t perm, unsigned long flags); extern int key_update(key_ref_t key, @@ -264,18 +257,14 @@ extern int keyring_add_key(struct key *keyring, extern struct key *key_lookup(key_serial_t id); -static inline key_serial_t key_serial(struct key *key) -{ - return key ? key->serial : 0; -} - -#ifdef CONFIG_SYSCTL -extern ctl_table key_sysctls[]; -#endif +#define key_serial(key) ((key) ? (key)->serial : 0) /* * the userspace interface */ +extern struct key root_user_keyring, root_session_keyring; +extern int alloc_uid_keyring(struct user_struct *user, + struct task_struct *ctx); extern void switch_uid_keyring(struct user_struct *new_user); extern int copy_keys(unsigned long clone_flags, struct task_struct *tsk); extern int copy_thread_group_keys(struct task_struct *tsk); @@ -304,6 +293,7 @@ extern void key_init(void); #define make_key_ref(k, p) ({ NULL; }) #define key_ref_to_ptr(k) ({ NULL; }) #define is_key_possessed(k) 0 +#define alloc_uid_keyring(u,c) 0 #define switch_uid_keyring(u) do { } while(0) #define __install_session_keyring(t, k) ({ NULL; }) #define copy_keys(f,t) 0 @@ -316,6 +306,10 @@ extern void key_init(void); #define key_fsgid_changed(t) do { } while(0) #define key_init() do { } while(0) +/* Initial keyrings */ +extern struct key root_user_keyring; +extern struct key root_session_keyring; + #endif /* CONFIG_KEYS */ #endif /* __KERNEL__ */ #endif /* _LINUX_KEY_H */ diff --git a/trunk/include/linux/keyctl.h b/trunk/include/linux/keyctl.h index 656ee6b77a4a..3365945640c9 100644 --- a/trunk/include/linux/keyctl.h +++ b/trunk/include/linux/keyctl.h @@ -49,6 +49,5 @@ #define KEYCTL_SET_REQKEY_KEYRING 14 /* set default request-key keyring */ #define KEYCTL_SET_TIMEOUT 15 /* set key timeout */ #define KEYCTL_ASSUME_AUTHORITY 16 /* assume request_key() authorisation */ -#define KEYCTL_GET_SECURITY 17 /* get key security label */ #endif /* _LINUX_KEYCTL_H */ diff --git a/trunk/include/linux/libata.h b/trunk/include/linux/libata.h index d1dfe872ee30..395a523d8c30 100644 --- a/trunk/include/linux/libata.h +++ b/trunk/include/linux/libata.h @@ -548,6 +548,11 @@ struct ata_device { u64 n_sectors; /* size of device, if ATA */ unsigned int class; /* ATA_DEV_xxx */ + union { + u16 id[ATA_ID_WORDS]; /* IDENTIFY xxx DEVICE data */ + u32 gscr[SATA_PMP_GSCR_DWORDS]; /* PMP GSCR block */ + }; + u8 pio_mode; u8 dma_mode; u8 xfer_mode; @@ -569,13 +574,8 @@ struct ata_device { u16 sectors; /* Number of sectors per track */ /* error history */ - int spdn_cnt; struct ata_ering ering; - - union { - u16 id[ATA_ID_WORDS]; /* IDENTIFY xxx DEVICE data */ - u32 gscr[SATA_PMP_GSCR_DWORDS]; /* PMP GSCR block */ - }; + int spdn_cnt; }; /* Offset into struct ata_device. Fields above it are maintained diff --git a/trunk/include/linux/list.h b/trunk/include/linux/list.h index 7627508f1b74..b4a939b6b625 100644 --- a/trunk/include/linux/list.h +++ b/trunk/include/linux/list.h @@ -328,7 +328,7 @@ static inline int list_is_singular(const struct list_head *head) return !list_empty(head) && (head->next == head->prev); } -static inline void __list_splice(const struct list_head *list, +static inline void __list_splice(struct list_head *list, struct list_head *head) { struct list_head *first = list->next; @@ -347,8 +347,7 @@ static inline void __list_splice(const struct list_head *list, * @list: the new list to add. * @head: the place to add it in the first list. */ -static inline void list_splice(const struct list_head *list, - struct list_head *head) +static inline void list_splice(struct list_head *list, struct list_head *head) { if (!list_empty(list)) __list_splice(list, head); diff --git a/trunk/include/linux/lmb.h b/trunk/include/linux/lmb.h index c46c89505dac..271153d27fba 100644 --- a/trunk/include/linux/lmb.h +++ b/trunk/include/linux/lmb.h @@ -40,8 +40,7 @@ extern struct lmb lmb; extern void __init lmb_init(void); extern void __init lmb_analyze(void); -extern long lmb_add(u64 base, u64 size); -extern long lmb_remove(u64 base, u64 size); +extern long __init lmb_add(u64 base, u64 size); extern long __init lmb_reserve(u64 base, u64 size); extern u64 __init lmb_alloc_nid(u64 size, u64 align, int nid, u64 (*nid_range)(u64, u64, int *)); @@ -54,7 +53,6 @@ extern u64 __init lmb_phys_mem_size(void); extern u64 __init lmb_end_of_DRAM(void); extern void __init lmb_enforce_memory_limit(u64 memory_limit); extern int __init lmb_is_reserved(u64 addr); -extern int lmb_find(struct lmb_property *res); extern void lmb_dump_all(void); diff --git a/trunk/include/linux/mca-legacy.h b/trunk/include/linux/mca-legacy.h index 7a3aea845902..f2bb770e530a 100644 --- a/trunk/include/linux/mca-legacy.h +++ b/trunk/include/linux/mca-legacy.h @@ -34,6 +34,7 @@ extern int mca_find_adapter(int id, int start); extern int mca_find_unused_adapter(int id, int start); +extern int mca_is_adapter_used(int slot); extern int mca_mark_as_used(int slot); extern void mca_mark_as_unused(int slot); diff --git a/trunk/include/linux/memcontrol.h b/trunk/include/linux/memcontrol.h index e6608776bc96..8b1c4295848b 100644 --- a/trunk/include/linux/memcontrol.h +++ b/trunk/include/linux/memcontrol.h @@ -27,6 +27,9 @@ struct mm_struct; #ifdef CONFIG_CGROUP_MEM_RES_CTLR +extern void mm_init_cgroup(struct mm_struct *mm, struct task_struct *p); +extern void mm_free_cgroup(struct mm_struct *mm); + #define page_reset_bad_cgroup(page) ((page)->page_cgroup = 0) extern struct page_cgroup *page_get_page_cgroup(struct page *page); @@ -45,10 +48,8 @@ extern unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, extern void mem_cgroup_out_of_memory(struct mem_cgroup *mem, gfp_t gfp_mask); int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem); -extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p); - #define mm_match_cgroup(mm, cgroup) \ - ((cgroup) == mem_cgroup_from_task((mm)->owner)) + ((cgroup) == rcu_dereference((mm)->mem_cgroup)) extern int mem_cgroup_prepare_migration(struct page *page); extern void mem_cgroup_end_migration(struct page *page); @@ -72,6 +73,15 @@ extern long mem_cgroup_calc_reclaim_inactive(struct mem_cgroup *mem, struct zone *zone, int priority); #else /* CONFIG_CGROUP_MEM_RES_CTLR */ +static inline void mm_init_cgroup(struct mm_struct *mm, + struct task_struct *p) +{ +} + +static inline void mm_free_cgroup(struct mm_struct *mm) +{ +} + static inline void page_reset_bad_cgroup(struct page *page) { } diff --git a/trunk/include/linux/memory.h b/trunk/include/linux/memory.h index 2f5f8a5ef2a0..f80e0e331cb7 100644 --- a/trunk/include/linux/memory.h +++ b/trunk/include/linux/memory.h @@ -53,13 +53,6 @@ struct memory_notify { struct notifier_block; struct mem_section; -/* - * Priorities for the hotplug memory callback routines (stored in decreasing - * order in the callback chain) - */ -#define SLAB_CALLBACK_PRI 1 -#define IPC_CALLBACK_PRI 10 - #ifndef CONFIG_MEMORY_HOTPLUG_SPARSE static inline int memory_dev_init(void) { diff --git a/trunk/include/linux/mlx4/device.h b/trunk/include/linux/mlx4/device.h index a744383d16e9..9fa1a8002ce2 100644 --- a/trunk/include/linux/mlx4/device.h +++ b/trunk/include/linux/mlx4/device.h @@ -382,8 +382,7 @@ void mlx4_free_hwq_res(struct mlx4_dev *mdev, struct mlx4_hwq_resources *wqres, int size); int mlx4_cq_alloc(struct mlx4_dev *dev, int nent, struct mlx4_mtt *mtt, - struct mlx4_uar *uar, u64 db_rec, struct mlx4_cq *cq, - int collapsed); + struct mlx4_uar *uar, u64 db_rec, struct mlx4_cq *cq); void mlx4_cq_free(struct mlx4_dev *dev, struct mlx4_cq *cq); int mlx4_qp_alloc(struct mlx4_dev *dev, int sqpn, struct mlx4_qp *qp); diff --git a/trunk/include/linux/mm.h b/trunk/include/linux/mm.h index c31a9cd2a30e..8b7f4a5d4f6a 100644 --- a/trunk/include/linux/mm.h +++ b/trunk/include/linux/mm.h @@ -1066,19 +1066,6 @@ extern void unlink_file_vma(struct vm_area_struct *); extern struct vm_area_struct *copy_vma(struct vm_area_struct **, unsigned long addr, unsigned long len, pgoff_t pgoff); extern void exit_mmap(struct mm_struct *); - -#ifdef CONFIG_PROC_FS -/* From fs/proc/base.c. callers must _not_ hold the mm's exe_file_lock */ -extern void added_exe_file_vma(struct mm_struct *mm); -extern void removed_exe_file_vma(struct mm_struct *mm); -#else -static inline void added_exe_file_vma(struct mm_struct *mm) -{} - -static inline void removed_exe_file_vma(struct mm_struct *mm) -{} -#endif /* CONFIG_PROC_FS */ - extern int may_expand_vm(struct mm_struct *mm, unsigned long npages); extern int install_special_mapping(struct mm_struct *mm, unsigned long addr, unsigned long len, @@ -1243,6 +1230,8 @@ int drop_caches_sysctl_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *); unsigned long shrink_slab(unsigned long scanned, gfp_t gfp_mask, unsigned long lru_pages); +void drop_pagecache(void); +void drop_slab(void); #ifndef CONFIG_MMU #define randomize_va_space 0 diff --git a/trunk/include/linux/mm_types.h b/trunk/include/linux/mm_types.h index eb7c16cc9559..e2bae8dde35a 100644 --- a/trunk/include/linux/mm_types.h +++ b/trunk/include/linux/mm_types.h @@ -225,15 +225,8 @@ struct mm_struct { /* aio bits */ rwlock_t ioctx_list_lock; /* aio lock */ struct kioctx *ioctx_list; -#ifdef CONFIG_MM_OWNER - struct task_struct *owner; /* The thread group leader that */ - /* owns the mm_struct. */ -#endif - -#ifdef CONFIG_PROC_FS - /* store ref to file /proc//exe symlink points to */ - struct file *exe_file; - unsigned long num_exe_file_vmas; +#ifdef CONFIG_CGROUP_MEM_RES_CTLR + struct mem_cgroup *mem_cgroup; #endif }; diff --git a/trunk/include/linux/mod_devicetable.h b/trunk/include/linux/mod_devicetable.h index d73eceaa7afb..139d49d2f078 100644 --- a/trunk/include/linux/mod_devicetable.h +++ b/trunk/include/linux/mod_devicetable.h @@ -368,15 +368,4 @@ struct virtio_device_id { }; #define VIRTIO_DEV_ANY_ID 0xffffffff -/* i2c */ - -#define I2C_NAME_SIZE 20 -#define I2C_MODULE_PREFIX "i2c:" - -struct i2c_device_id { - char name[I2C_NAME_SIZE]; - kernel_ulong_t driver_data; /* Data private to the driver */ -}; - - #endif /* LINUX_MOD_DEVICETABLE_H */ diff --git a/trunk/include/linux/msg.h b/trunk/include/linux/msg.h index 6f3b8e79a991..10a3d5a1abff 100644 --- a/trunk/include/linux/msg.h +++ b/trunk/include/linux/msg.h @@ -49,26 +49,16 @@ struct msginfo { unsigned short msgseg; }; -/* - * Scaling factor to compute msgmni: - * the memory dedicated to msg queues (msgmni * msgmnb) should occupy - * at most 1/MSG_MEM_SCALE of the lowmem (see the formula in ipc/msg.c): - * up to 8MB : msgmni = 16 (MSGMNI) - * 4 GB : msgmni = 8K - * more than 16 GB : msgmni = 32K (IPCMNI) - */ -#define MSG_MEM_SCALE 32 - #define MSGMNI 16 /* <= IPCMNI */ /* max # of msg queue identifiers */ #define MSGMAX 8192 /* <= INT_MAX */ /* max size of message (bytes) */ #define MSGMNB 16384 /* <= INT_MAX */ /* default max size of a message queue */ /* unused */ -#define MSGPOOL (MSGMNI * MSGMNB) /* size in bytes of message pool */ +#define MSGPOOL (MSGMNI*MSGMNB/1024) /* size in kilobytes of message pool */ #define MSGTQL MSGMNB /* number of system message headers */ #define MSGMAP MSGMNB /* number of entries in message map */ #define MSGSSZ 16 /* message segment size */ -#define __MSGSEG (MSGPOOL / MSGSSZ) /* max no. of segments */ +#define __MSGSEG ((MSGPOOL*1024)/ MSGSSZ) /* max no. of segments */ #define MSGSEG (__MSGSEG <= 0xffff ? __MSGSEG : 0xffff) #ifdef __KERNEL__ diff --git a/trunk/include/linux/msi.h b/trunk/include/linux/msi.h index 8f2939227207..94bb46d82efd 100644 --- a/trunk/include/linux/msi.h +++ b/trunk/include/linux/msi.h @@ -22,7 +22,6 @@ struct msi_desc { __u8 masked : 1; __u8 is_64 : 1; /* Address size: 0=32bit 1=64bit */ __u8 pos; /* Location of the msi capability */ - __u32 maskbits_mask; /* mask bits mask */ __u16 entry_nr; /* specific enabled entry */ unsigned default_irq; /* default pre-assigned irq */ }msi_attrib; diff --git a/trunk/include/linux/nbd.h b/trunk/include/linux/nbd.h index 155719dab813..986572081e19 100644 --- a/trunk/include/linux/nbd.h +++ b/trunk/include/linux/nbd.h @@ -56,11 +56,9 @@ struct nbd_device { int magic; spinlock_t queue_lock; - struct list_head queue_head; /* Requests waiting result */ + struct list_head queue_head;/* Requests are added here... */ struct request *active_req; wait_queue_head_t active_wq; - struct list_head waiting_queue; /* Requests to be sent */ - wait_queue_head_t waiting_wq; struct mutex tx_lock; struct gendisk *disk; @@ -88,7 +86,11 @@ struct nbd_request { char handle[8]; __be64 from; __be32 len; -} __attribute__ ((packed)); +} +#ifdef __GNUC__ + __attribute__ ((packed)) +#endif +; /* * This is the reply packet that nbd-server sends back to the client after diff --git a/trunk/include/linux/netlink.h b/trunk/include/linux/netlink.h index bec1062a25a1..fb0713b6ffaf 100644 --- a/trunk/include/linux/netlink.h +++ b/trunk/include/linux/netlink.h @@ -166,7 +166,6 @@ struct netlink_skb_parms __u32 dst_group; kernel_cap_t eff_cap; __u32 loginuid; /* Login (audit) uid */ - __u32 sessionid; /* Session id (audit) */ __u32 sid; /* SELinux security id */ }; diff --git a/trunk/include/linux/notifier.h b/trunk/include/linux/notifier.h index 0ff6224d172a..20dfed590183 100644 --- a/trunk/include/linux/notifier.h +++ b/trunk/include/linux/notifier.h @@ -121,10 +121,6 @@ extern int raw_notifier_chain_register(struct raw_notifier_head *nh, extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh, struct notifier_block *nb); -extern int blocking_notifier_chain_cond_register( - struct blocking_notifier_head *nh, - struct notifier_block *nb); - extern int atomic_notifier_chain_unregister(struct atomic_notifier_head *nh, struct notifier_block *nb); extern int blocking_notifier_chain_unregister(struct blocking_notifier_head *nh, diff --git a/trunk/include/linux/pci.h b/trunk/include/linux/pci.h index 96acd0dae241..292491324b01 100644 --- a/trunk/include/linux/pci.h +++ b/trunk/include/linux/pci.h @@ -20,6 +20,8 @@ /* Include the pci register defines */ #include +struct pci_vpd; + /* * The PCI interface treats multi-function devices as independent * devices. The slot/function address of each device is encoded @@ -129,8 +131,6 @@ struct pci_cap_saved_state { }; struct pcie_link_state; -struct pci_vpd; - /* * The pci_dev structure is used to describe PCI devices. */ @@ -254,7 +254,7 @@ static inline void pci_add_saved_cap(struct pci_dev *pci_dev, #define PCI_NUM_RESOURCES 11 #ifndef PCI_BUS_NUM_RESOURCES -#define PCI_BUS_NUM_RESOURCES 16 +#define PCI_BUS_NUM_RESOURCES 8 #endif #define PCI_REGION_FLAG_MASK 0x0fU /* These bits of resource flags tell us the PCI region flags */ @@ -666,7 +666,6 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, void pci_walk_bus(struct pci_bus *top, void (*cb)(struct pci_dev *, void *), void *userdata); -int pci_cfg_space_size_ext(struct pci_dev *dev, unsigned check_exp_pcix); int pci_cfg_space_size(struct pci_dev *dev); unsigned char pci_bus_max_busnr(struct pci_bus *bus); @@ -702,8 +701,6 @@ static inline int pci_enable_msi(struct pci_dev *dev) return -1; } -static inline void pci_msi_shutdown(struct pci_dev *dev) -{ } static inline void pci_disable_msi(struct pci_dev *dev) { } @@ -713,8 +710,6 @@ static inline int pci_enable_msix(struct pci_dev *dev, return -1; } -static inline void pci_msix_shutdown(struct pci_dev *dev) -{ } static inline void pci_disable_msix(struct pci_dev *dev) { } @@ -725,11 +720,9 @@ static inline void pci_restore_msi_state(struct pci_dev *dev) { } #else extern int pci_enable_msi(struct pci_dev *dev); -extern void pci_msi_shutdown(struct pci_dev *dev); extern void pci_disable_msi(struct pci_dev *dev); extern int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec); -extern void pci_msix_shutdown(struct pci_dev *dev); extern void pci_disable_msix(struct pci_dev *dev); extern void msi_remove_pci_irq_vectors(struct pci_dev *dev); extern void pci_restore_msi_state(struct pci_dev *dev); @@ -1060,13 +1053,5 @@ extern unsigned long pci_cardbus_mem_size; extern int pcibios_add_platform_entries(struct pci_dev *dev); -#ifdef CONFIG_PCI_MMCONFIG -extern void __init pci_mmcfg_early_init(void); -extern void __init pci_mmcfg_late_init(void); -#else -static inline void pci_mmcfg_early_init(void) { } -static inline void pci_mmcfg_late_init(void) { } -#endif - #endif /* __KERNEL__ */ #endif /* LINUX_PCI_H */ diff --git a/trunk/include/linux/pci_ids.h b/trunk/include/linux/pci_ids.h index e5a53daf17f1..70eb3c803d47 100644 --- a/trunk/include/linux/pci_ids.h +++ b/trunk/include/linux/pci_ids.h @@ -2413,8 +2413,6 @@ #define PCI_DEVICE_ID_INTEL_82443GX_0 0x71a0 #define PCI_DEVICE_ID_INTEL_82443GX_2 0x71a2 #define PCI_DEVICE_ID_INTEL_82372FB_1 0x7601 -#define PCI_DEVICE_ID_INTEL_SCH_LPC 0x8119 -#define PCI_DEVICE_ID_INTEL_SCH_IDE 0x811a #define PCI_DEVICE_ID_INTEL_82454GX 0x84c4 #define PCI_DEVICE_ID_INTEL_82450GX 0x84c5 #define PCI_DEVICE_ID_INTEL_82451NX 0x84ca diff --git a/trunk/include/linux/percpu.h b/trunk/include/linux/percpu.h index d746a2abb322..1ac969724bb2 100644 --- a/trunk/include/linux/percpu.h +++ b/trunk/include/linux/percpu.h @@ -4,6 +4,7 @@ #include #include /* For kmalloc() */ #include +#include /* For memset() */ #include #include diff --git a/trunk/include/linux/personality.h b/trunk/include/linux/personality.h index a84e9ff9b27e..012cd558189b 100644 --- a/trunk/include/linux/personality.h +++ b/trunk/include/linux/personality.h @@ -105,6 +105,10 @@ struct exec_domain { */ #define personality(pers) (pers & PER_MASK) +/* + * Personality of the currently running process. + */ +#define get_personality (current->personality) /* * Change personality of the currently running process. diff --git a/trunk/include/linux/phantom.h b/trunk/include/linux/phantom.h index 02268c54c250..96f4048a6cc3 100644 --- a/trunk/include/linux/phantom.h +++ b/trunk/include/linux/phantom.h @@ -27,17 +27,14 @@ struct phm_regs { #define PH_IOC_MAGIC 'p' #define PHN_GET_REG _IOWR(PH_IOC_MAGIC, 0, struct phm_reg *) -#define PHN_SET_REG _IOW(PH_IOC_MAGIC, 1, struct phm_reg *) +#define PHN_SET_REG _IOW (PH_IOC_MAGIC, 1, struct phm_reg *) #define PHN_GET_REGS _IOWR(PH_IOC_MAGIC, 2, struct phm_regs *) -#define PHN_SET_REGS _IOW(PH_IOC_MAGIC, 3, struct phm_regs *) +#define PHN_SET_REGS _IOW (PH_IOC_MAGIC, 3, struct phm_regs *) /* this ioctl tells the driver, that the caller is not OpenHaptics and might * use improved registers update (no more phantom switchoffs when using * libphantom) */ -#define PHN_NOT_OH _IO(PH_IOC_MAGIC, 4) -#define PHN_GETREG _IOWR(PH_IOC_MAGIC, 5, struct phm_reg) -#define PHN_SETREG _IOW(PH_IOC_MAGIC, 6, struct phm_reg) -#define PHN_GETREGS _IOWR(PH_IOC_MAGIC, 7, struct phm_regs) -#define PHN_SETREGS _IOW(PH_IOC_MAGIC, 8, struct phm_regs) +#define PHN_NOT_OH _IO (PH_IOC_MAGIC, 4) +#define PH_IOC_MAXNR 4 #define PHN_CONTROL 0x6 /* control byte in iaddr space */ #define PHN_CTL_AMP 0x1 /* switch after torques change */ diff --git a/trunk/include/linux/proc_fs.h b/trunk/include/linux/proc_fs.h index 9883bc942262..9b6c935f69cf 100644 --- a/trunk/include/linux/proc_fs.h +++ b/trunk/include/linux/proc_fs.h @@ -9,6 +9,7 @@ struct net; struct completion; + /* * The proc filesystem constants/structures */ @@ -40,7 +41,7 @@ enum { * /proc file has a parent, but "subdir" is NULL for all * non-directory entries). * - * "owner" is used to protect module + * "get_info" is called at "read", while "owner" is used to protect module * from unloading while proc_dir_entry is in use */ @@ -48,6 +49,7 @@ typedef int (read_proc_t)(char *page, char **start, off_t off, int count, int *eof, void *data); typedef int (write_proc_t)(struct file *file, const char __user *buffer, unsigned long count, void *data); +typedef int (get_info_t)(char *, char **, off_t, int); struct proc_dir_entry { unsigned int low_ino; @@ -68,6 +70,7 @@ struct proc_dir_entry { * somewhere. */ const struct file_operations *proc_fops; + get_info_t *get_info; struct module *owner; struct proc_dir_entry *next, *parent, *subdir; void *data; @@ -94,6 +97,10 @@ struct vmcore { #ifdef CONFIG_PROC_FS +extern struct proc_dir_entry proc_root; +extern struct proc_dir_entry *proc_root_fs; +extern struct proc_dir_entry *proc_bus; +extern struct proc_dir_entry *proc_root_driver; extern struct proc_dir_entry *proc_root_kcore; extern spinlock_t proc_subdir_lock; @@ -116,10 +123,9 @@ void de_put(struct proc_dir_entry *de); extern struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode, struct proc_dir_entry *parent); -struct proc_dir_entry *proc_create_data(const char *name, mode_t mode, +struct proc_dir_entry *proc_create(const char *name, mode_t mode, struct proc_dir_entry *parent, - const struct file_operations *proc_fops, - void *data); + const struct file_operations *proc_fops); extern void remove_proc_entry(const char *name, struct proc_dir_entry *parent); extern struct vfsmount *proc_mnt; @@ -174,12 +180,6 @@ extern struct proc_dir_entry *proc_mkdir(const char *,struct proc_dir_entry *); extern struct proc_dir_entry *proc_mkdir_mode(const char *name, mode_t mode, struct proc_dir_entry *parent); -static inline struct proc_dir_entry *proc_create(const char *name, mode_t mode, - struct proc_dir_entry *parent, const struct file_operations *proc_fops) -{ - return proc_create_data(name, mode, parent, proc_fops, NULL); -} - static inline struct proc_dir_entry *create_proc_read_entry(const char *name, mode_t mode, struct proc_dir_entry *base, read_proc_t *read_proc, void * data) @@ -192,20 +192,25 @@ static inline struct proc_dir_entry *create_proc_read_entry(const char *name, return res; } +static inline struct proc_dir_entry *create_proc_info_entry(const char *name, + mode_t mode, struct proc_dir_entry *base, get_info_t *get_info) +{ + struct proc_dir_entry *res=create_proc_entry(name,mode,base); + if (res) res->get_info=get_info; + return res; +} + extern struct proc_dir_entry *proc_net_fops_create(struct net *net, const char *name, mode_t mode, const struct file_operations *fops); extern void proc_net_remove(struct net *net, const char *name); extern struct proc_dir_entry *proc_net_mkdir(struct net *net, const char *name, struct proc_dir_entry *parent); -/* While the {get|set|dup}_mm_exe_file functions are for mm_structs, they are - * only needed to implement /proc/|self/exe so we define them here. */ -extern void set_mm_exe_file(struct mm_struct *mm, struct file *new_exe_file); -extern struct file *get_mm_exe_file(struct mm_struct *mm); -extern void dup_mm_exe_file(struct mm_struct *oldmm, struct mm_struct *newmm); - #else +#define proc_root_driver NULL +#define proc_bus NULL + #define proc_net_fops_create(net, name, mode, fops) ({ (void)(mode), NULL; }) static inline void proc_net_remove(struct net *net, const char *name) {} @@ -221,12 +226,6 @@ static inline struct proc_dir_entry *proc_create(const char *name, { return NULL; } -static inline struct proc_dir_entry *proc_create_data(const char *name, - mode_t mode, struct proc_dir_entry *parent, - const struct file_operations *proc_fops, void *data) -{ - return NULL; -} #define remove_proc_entry(name, parent) do {} while (0) static inline struct proc_dir_entry *proc_symlink(const char *name, @@ -237,11 +236,16 @@ static inline struct proc_dir_entry *proc_mkdir(const char *name, static inline struct proc_dir_entry *create_proc_read_entry(const char *name, mode_t mode, struct proc_dir_entry *base, read_proc_t *read_proc, void * data) { return NULL; } +static inline struct proc_dir_entry *create_proc_info_entry(const char *name, + mode_t mode, struct proc_dir_entry *base, get_info_t *get_info) + { return NULL; } struct tty_driver; static inline void proc_tty_register_driver(struct tty_driver *driver) {}; static inline void proc_tty_unregister_driver(struct tty_driver *driver) {}; +extern struct proc_dir_entry proc_root; + static inline int pid_ns_prepare_proc(struct pid_namespace *ns) { return 0; @@ -251,19 +255,6 @@ static inline void pid_ns_release_proc(struct pid_namespace *ns) { } -static inline void set_mm_exe_file(struct mm_struct *mm, - struct file *new_exe_file) -{} - -static inline struct file *get_mm_exe_file(struct mm_struct *mm) -{ - return NULL; -} - -static inline void dup_mm_exe_file(struct mm_struct *oldmm, - struct mm_struct *newmm) -{} - #endif /* CONFIG_PROC_FS */ #if !defined(CONFIG_PROC_KCORE) diff --git a/trunk/include/linux/res_counter.h b/trunk/include/linux/res_counter.h index 6d9e1fca098c..61363ce896d5 100644 --- a/trunk/include/linux/res_counter.h +++ b/trunk/include/linux/res_counter.h @@ -9,8 +9,6 @@ * * Author: Pavel Emelianov * - * See Documentation/controllers/resource_counter.txt for more - * info about what this counter is. */ #include @@ -26,10 +24,6 @@ struct res_counter { * the current resource consumption level */ unsigned long long usage; - /* - * the maximal value of the usage from the counter creation - */ - unsigned long long max_usage; /* * the limit that usage cannot exceed */ @@ -45,9 +39,8 @@ struct res_counter { spinlock_t lock; }; -/** +/* * Helpers to interact with userspace - * res_counter_read_u64() - returns the value of the specified member. * res_counter_read/_write - put/get the specified fields from the * res_counter struct to/from the user * @@ -58,8 +51,6 @@ struct res_counter { * @pos: and the offset. */ -u64 res_counter_read_u64(struct res_counter *counter, int member); - ssize_t res_counter_read(struct res_counter *counter, int member, const char __user *buf, size_t nbytes, loff_t *pos, int (*read_strategy)(unsigned long long val, char *s)); @@ -73,7 +64,6 @@ ssize_t res_counter_write(struct res_counter *counter, int member, enum { RES_USAGE, - RES_MAX_USAGE, RES_LIMIT, RES_FAILCNT, }; @@ -134,21 +124,4 @@ static inline bool res_counter_check_under_limit(struct res_counter *cnt) return ret; } -static inline void res_counter_reset_max(struct res_counter *cnt) -{ - unsigned long flags; - - spin_lock_irqsave(&cnt->lock, flags); - cnt->max_usage = cnt->usage; - spin_unlock_irqrestore(&cnt->lock, flags); -} - -static inline void res_counter_reset_failcnt(struct res_counter *cnt) -{ - unsigned long flags; - - spin_lock_irqsave(&cnt->lock, flags); - cnt->failcnt = 0; - spin_unlock_irqrestore(&cnt->lock, flags); -} #endif diff --git a/trunk/include/linux/resource.h b/trunk/include/linux/resource.h index aaa423a6f3d9..ae13db714742 100644 --- a/trunk/include/linux/resource.h +++ b/trunk/include/linux/resource.h @@ -19,7 +19,6 @@ struct task_struct; #define RUSAGE_SELF 0 #define RUSAGE_CHILDREN (-1) #define RUSAGE_BOTH (-2) /* sys_wait4() uses this */ -#define RUSAGE_THREAD 1 /* only the calling thread */ struct rusage { struct timeval ru_utime; /* user time used */ diff --git a/trunk/include/linux/rio.h b/trunk/include/linux/rio.h index cfb66bbc0f27..68e3f6853fa6 100644 --- a/trunk/include/linux/rio.h +++ b/trunk/include/linux/rio.h @@ -23,6 +23,7 @@ #include #include +#define RIO_ANY_DESTID 0xff #define RIO_NO_HOPCOUNT -1 #define RIO_INVALID_DESTID 0xffff @@ -38,8 +39,11 @@ entry is invalid (no route exists for the device ID) */ -#define RIO_MAX_ROUTE_ENTRIES(size) (size ? (1 << 16) : (1 << 8)) -#define RIO_ANY_DESTID(size) (size ? 0xffff : 0xff) +#ifdef CONFIG_RAPIDIO_8_BIT_TRANSPORT +#define RIO_MAX_ROUTE_ENTRIES (1 << 8) +#else +#define RIO_MAX_ROUTE_ENTRIES (1 << 16) +#endif #define RIO_MAX_MBOX 4 #define RIO_MAX_MSG_SIZE 0x1000 @@ -145,11 +149,6 @@ struct rio_dbell { void *dev_id; }; -enum rio_phy_type { - RIO_PHY_PARALLEL, - RIO_PHY_SERIAL, -}; - /** * struct rio_mport - RIO master port info * @dbells: List of doorbell events @@ -164,7 +163,6 @@ enum rio_phy_type { * @id: Port ID, unique among all ports * @index: Port index, unique among all port interfaces of the same type * @name: Port name string - * @priv: Master port private data */ struct rio_mport { struct list_head dbells; /* list of doorbell events */ @@ -179,13 +177,7 @@ struct rio_mport { unsigned char id; /* port ID, unique among all ports */ unsigned char index; /* port index, unique among all port interfaces of the same type */ - unsigned int sys_size; /* RapidIO common transport system size. - * 0 - Small size. 256 devices. - * 1 - Large size, 65536 devices. - */ - enum rio_phy_type phy_type; /* RapidIO phy type */ unsigned char name[40]; - void *priv; /* Master port private data */ }; /** @@ -219,7 +211,7 @@ struct rio_switch { u16 switchid; u16 hopcount; u16 destid; - u8 *route_table; + u8 route_table[RIO_MAX_ROUTE_ENTRIES]; int (*add_entry) (struct rio_mport * mport, u16 destid, u8 hopcount, u16 table, u16 route_destid, u8 route_port); int (*get_entry) (struct rio_mport * mport, u16 destid, u8 hopcount, @@ -237,15 +229,13 @@ struct rio_switch { * @dsend: Callback to send a doorbell message. */ struct rio_ops { - int (*lcread) (struct rio_mport *mport, int index, u32 offset, int len, - u32 *data); - int (*lcwrite) (struct rio_mport *mport, int index, u32 offset, int len, - u32 data); - int (*cread) (struct rio_mport *mport, int index, u16 destid, - u8 hopcount, u32 offset, int len, u32 *data); - int (*cwrite) (struct rio_mport *mport, int index, u16 destid, - u8 hopcount, u32 offset, int len, u32 data); - int (*dsend) (struct rio_mport *mport, int index, u16 destid, u16 data); + int (*lcread) (int index, u32 offset, int len, u32 * data); + int (*lcwrite) (int index, u32 offset, int len, u32 data); + int (*cread) (int index, u16 destid, u8 hopcount, u32 offset, int len, + u32 * data); + int (*cwrite) (int index, u16 destid, u8 hopcount, u32 offset, int len, + u32 data); + int (*dsend) (int index, u16 destid, u16 data); }; #define RIO_RESOURCE_MEM 0x00000100 diff --git a/trunk/include/linux/sched.h b/trunk/include/linux/sched.h index 1d02babdb2c7..024d72b47a0c 100644 --- a/trunk/include/linux/sched.h +++ b/trunk/include/linux/sched.h @@ -2148,19 +2148,6 @@ static inline void migration_init(void) #define TASK_SIZE_OF(tsk) TASK_SIZE #endif -#ifdef CONFIG_MM_OWNER -extern void mm_update_next_owner(struct mm_struct *mm); -extern void mm_init_owner(struct mm_struct *mm, struct task_struct *p); -#else -static inline void mm_update_next_owner(struct mm_struct *mm) -{ -} - -static inline void mm_init_owner(struct mm_struct *mm, struct task_struct *p) -{ -} -#endif /* CONFIG_MM_OWNER */ - #endif /* __KERNEL__ */ #endif diff --git a/trunk/include/linux/security.h b/trunk/include/linux/security.h index 50737c70e78e..d0a28fd1747a 100644 --- a/trunk/include/linux/security.h +++ b/trunk/include/linux/security.h @@ -53,9 +53,8 @@ extern void cap_capset_set(struct task_struct *target, kernel_cap_t *effective, extern int cap_bprm_set_security(struct linux_binprm *bprm); extern void cap_bprm_apply_creds(struct linux_binprm *bprm, int unsafe); extern int cap_bprm_secureexec(struct linux_binprm *bprm); -extern int cap_inode_setxattr(struct dentry *dentry, const char *name, - const void *value, size_t size, int flags); -extern int cap_inode_removexattr(struct dentry *dentry, const char *name); +extern int cap_inode_setxattr(struct dentry *dentry, char *name, void *value, size_t size, int flags); +extern int cap_inode_removexattr(struct dentry *dentry, char *name); extern int cap_inode_need_killpriv(struct dentry *dentry); extern int cap_inode_killpriv(struct dentry *dentry); extern int cap_task_post_setuid(uid_t old_ruid, uid_t old_euid, uid_t old_suid, int flags); @@ -1009,17 +1008,6 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts) * @perm describes the combination of permissions required of this key. * Return 1 if permission granted, 0 if permission denied and -ve it the * normal permissions model should be effected. - * @key_getsecurity: - * Get a textual representation of the security context attached to a key - * for the purposes of honouring KEYCTL_GETSECURITY. This function - * allocates the storage for the NUL-terminated string and the caller - * should free it. - * @key points to the key to be queried. - * @_buffer points to a pointer that should be set to point to the - * resulting string (if no label or an error occurs). - * Return the length of the string (including terminating NUL) or -ve if - * an error. - * May also return 0 (and a NULL buffer pointer) if there is no label. * * Security hooks affecting all System V IPC operations. * @@ -1374,13 +1362,13 @@ struct security_operations { int (*inode_setattr) (struct dentry *dentry, struct iattr *attr); int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry); void (*inode_delete) (struct inode *inode); - int (*inode_setxattr) (struct dentry *dentry, const char *name, - const void *value, size_t size, int flags); - void (*inode_post_setxattr) (struct dentry *dentry, const char *name, - const void *value, size_t size, int flags); - int (*inode_getxattr) (struct dentry *dentry, const char *name); + int (*inode_setxattr) (struct dentry *dentry, char *name, void *value, + size_t size, int flags); + void (*inode_post_setxattr) (struct dentry *dentry, char *name, void *value, + size_t size, int flags); + int (*inode_getxattr) (struct dentry *dentry, char *name); int (*inode_listxattr) (struct dentry *dentry); - int (*inode_removexattr) (struct dentry *dentry, const char *name); + int (*inode_removexattr) (struct dentry *dentry, char *name); int (*inode_need_killpriv) (struct dentry *dentry); int (*inode_killpriv) (struct dentry *dentry); int (*inode_getsecurity) (const struct inode *inode, const char *name, void **buffer, bool alloc); @@ -1481,7 +1469,7 @@ struct security_operations { int (*getprocattr) (struct task_struct *p, char *name, char **value); int (*setprocattr) (struct task_struct *p, char *name, void *value, size_t size); int (*secid_to_secctx) (u32 secid, char **secdata, u32 *seclen); - int (*secctx_to_secid) (const char *secdata, u32 seclen, u32 *secid); + int (*secctx_to_secid) (char *secdata, u32 seclen, u32 *secid); void (*release_secctx) (char *secdata, u32 seclen); #ifdef CONFIG_SECURITY_NETWORK @@ -1549,7 +1537,7 @@ struct security_operations { int (*key_permission) (key_ref_t key_ref, struct task_struct *context, key_perm_t perm); - int (*key_getsecurity)(struct key *key, char **_buffer); + #endif /* CONFIG_KEYS */ #ifdef CONFIG_AUDIT @@ -1645,13 +1633,13 @@ int security_inode_permission(struct inode *inode, int mask, struct nameidata *n int security_inode_setattr(struct dentry *dentry, struct iattr *attr); int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry); void security_inode_delete(struct inode *inode); -int security_inode_setxattr(struct dentry *dentry, const char *name, - const void *value, size_t size, int flags); -void security_inode_post_setxattr(struct dentry *dentry, const char *name, - const void *value, size_t size, int flags); -int security_inode_getxattr(struct dentry *dentry, const char *name); +int security_inode_setxattr(struct dentry *dentry, char *name, + void *value, size_t size, int flags); +void security_inode_post_setxattr(struct dentry *dentry, char *name, + void *value, size_t size, int flags); +int security_inode_getxattr(struct dentry *dentry, char *name); int security_inode_listxattr(struct dentry *dentry); -int security_inode_removexattr(struct dentry *dentry, const char *name); +int security_inode_removexattr(struct dentry *dentry, char *name); int security_inode_need_killpriv(struct dentry *dentry); int security_inode_killpriv(struct dentry *dentry); int security_inode_getsecurity(const struct inode *inode, const char *name, void **buffer, bool alloc); @@ -1730,7 +1718,7 @@ int security_setprocattr(struct task_struct *p, char *name, void *value, size_t int security_netlink_send(struct sock *sk, struct sk_buff *skb); int security_netlink_recv(struct sk_buff *skb, int cap); int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen); -int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid); +int security_secctx_to_secid(char *secdata, u32 seclen, u32 *secid); void security_release_secctx(char *secdata, u32 seclen); #else /* CONFIG_SECURITY */ @@ -2053,18 +2041,17 @@ static inline int security_inode_getattr(struct vfsmount *mnt, static inline void security_inode_delete(struct inode *inode) { } -static inline int security_inode_setxattr(struct dentry *dentry, - const char *name, const void *value, size_t size, int flags) +static inline int security_inode_setxattr(struct dentry *dentry, char *name, + void *value, size_t size, int flags) { return cap_inode_setxattr(dentry, name, value, size, flags); } -static inline void security_inode_post_setxattr(struct dentry *dentry, - const char *name, const void *value, size_t size, int flags) +static inline void security_inode_post_setxattr(struct dentry *dentry, char *name, + void *value, size_t size, int flags) { } -static inline int security_inode_getxattr(struct dentry *dentry, - const char *name) +static inline int security_inode_getxattr(struct dentry *dentry, char *name) { return 0; } @@ -2074,8 +2061,7 @@ static inline int security_inode_listxattr(struct dentry *dentry) return 0; } -static inline int security_inode_removexattr(struct dentry *dentry, - const char *name) +static inline int security_inode_removexattr(struct dentry *dentry, char *name) { return cap_inode_removexattr(dentry, name); } @@ -2449,7 +2435,7 @@ static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *secle return -EOPNOTSUPP; } -static inline int security_secctx_to_secid(const char *secdata, +static inline int security_secctx_to_secid(char *secdata, u32 seclen, u32 *secid) { @@ -2743,7 +2729,6 @@ int security_key_alloc(struct key *key, struct task_struct *tsk, unsigned long f void security_key_free(struct key *key); int security_key_permission(key_ref_t key_ref, struct task_struct *context, key_perm_t perm); -int security_key_getsecurity(struct key *key, char **_buffer); #else @@ -2765,12 +2750,6 @@ static inline int security_key_permission(key_ref_t key_ref, return 0; } -static inline int security_key_getsecurity(struct key *key, char **_buffer) -{ - *_buffer = NULL; - return 0; -} - #endif #endif /* CONFIG_KEYS */ diff --git a/trunk/include/linux/smb.h b/trunk/include/linux/smb.h index caa43b2370cb..f098dff93f6b 100644 --- a/trunk/include/linux/smb.h +++ b/trunk/include/linux/smb.h @@ -11,7 +11,6 @@ #include #include -#include enum smb_protocol { SMB_PROTOCOL_NONE, diff --git a/trunk/include/linux/syscalls.h b/trunk/include/linux/syscalls.h index 0522f368f9d7..8df6d1382ac8 100644 --- a/trunk/include/linux/syscalls.h +++ b/trunk/include/linux/syscalls.h @@ -240,28 +240,26 @@ asmlinkage long sys_truncate64(const char __user *path, loff_t length); asmlinkage long sys_ftruncate64(unsigned int fd, loff_t length); #endif -asmlinkage long sys_setxattr(const char __user *path, const char __user *name, - const void __user *value, size_t size, int flags); -asmlinkage long sys_lsetxattr(const char __user *path, const char __user *name, - const void __user *value, size_t size, int flags); -asmlinkage long sys_fsetxattr(int fd, const char __user *name, - const void __user *value, size_t size, int flags); -asmlinkage ssize_t sys_getxattr(const char __user *path, const char __user *name, +asmlinkage long sys_setxattr(char __user *path, char __user *name, + void __user *value, size_t size, int flags); +asmlinkage long sys_lsetxattr(char __user *path, char __user *name, + void __user *value, size_t size, int flags); +asmlinkage long sys_fsetxattr(int fd, char __user *name, void __user *value, + size_t size, int flags); +asmlinkage ssize_t sys_getxattr(char __user *path, char __user *name, void __user *value, size_t size); -asmlinkage ssize_t sys_lgetxattr(const char __user *path, const char __user *name, +asmlinkage ssize_t sys_lgetxattr(char __user *path, char __user *name, void __user *value, size_t size); -asmlinkage ssize_t sys_fgetxattr(int fd, const char __user *name, +asmlinkage ssize_t sys_fgetxattr(int fd, char __user *name, void __user *value, size_t size); -asmlinkage ssize_t sys_listxattr(const char __user *path, char __user *list, +asmlinkage ssize_t sys_listxattr(char __user *path, char __user *list, size_t size); -asmlinkage ssize_t sys_llistxattr(const char __user *path, char __user *list, +asmlinkage ssize_t sys_llistxattr(char __user *path, char __user *list, size_t size); asmlinkage ssize_t sys_flistxattr(int fd, char __user *list, size_t size); -asmlinkage long sys_removexattr(const char __user *path, - const char __user *name); -asmlinkage long sys_lremovexattr(const char __user *path, - const char __user *name); -asmlinkage long sys_fremovexattr(int fd, const char __user *name); +asmlinkage long sys_removexattr(char __user *path, char __user *name); +asmlinkage long sys_lremovexattr(char __user *path, char __user *name); +asmlinkage long sys_fremovexattr(int fd, char __user *name); asmlinkage unsigned long sys_brk(unsigned long brk); asmlinkage long sys_mprotect(unsigned long start, size_t len, diff --git a/trunk/include/linux/sysctl.h b/trunk/include/linux/sysctl.h index 24141b4d1a11..571f01d20a86 100644 --- a/trunk/include/linux/sysctl.h +++ b/trunk/include/linux/sysctl.h @@ -945,14 +945,11 @@ enum /* For the /proc/sys support */ struct ctl_table; struct nsproxy; -struct ctl_table_root; - extern struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev); extern struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces, struct ctl_table_header *prev); extern void sysctl_head_finish(struct ctl_table_header *prev); -extern int sysctl_perm(struct ctl_table_root *root, - struct ctl_table *table, int op); +extern int sysctl_perm(struct ctl_table *table, int op); typedef struct ctl_table ctl_table; @@ -984,6 +981,11 @@ extern int do_sysctl (int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp, void __user *newval, size_t newlen); +extern int do_sysctl_strategy (struct ctl_table *table, + int __user *name, int nlen, + void __user *oldval, size_t __user *oldlenp, + void __user *newval, size_t newlen); + extern ctl_handler sysctl_data; extern ctl_handler sysctl_string; extern ctl_handler sysctl_intvec; @@ -1052,8 +1054,6 @@ struct ctl_table_root { struct list_head header_list; struct list_head *(*lookup)(struct ctl_table_root *root, struct nsproxy *namespaces); - int (*permissions)(struct ctl_table_root *root, - struct nsproxy *namespaces, struct ctl_table *table); }; /* struct ctl_table_header is used to maintain dynamic lists of @@ -1085,6 +1085,8 @@ struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, void unregister_sysctl_table(struct ctl_table_header * table); int sysctl_check_table(struct nsproxy *namespaces, struct ctl_table *table); +#else /* __KERNEL__ */ + #endif /* __KERNEL__ */ #endif /* _LINUX_SYSCTL_H */ diff --git a/trunk/include/linux/sysv_fs.h b/trunk/include/linux/sysv_fs.h index 96411306eec6..e0248631e461 100644 --- a/trunk/include/linux/sysv_fs.h +++ b/trunk/include/linux/sysv_fs.h @@ -1,7 +1,11 @@ #ifndef _LINUX_SYSV_FS_H #define _LINUX_SYSV_FS_H -#define __packed2__ __attribute__((packed, aligned(2))) +#if defined(__GNUC__) +# define __packed2__ __attribute__((packed, aligned(2))) +#else +>> I want to scream! << +#endif #ifndef __KERNEL__ diff --git a/trunk/include/linux/tty.h b/trunk/include/linux/tty.h index 265831ccaa88..dd8e08fe8855 100644 --- a/trunk/include/linux/tty.h +++ b/trunk/include/linux/tty.h @@ -300,6 +300,7 @@ extern void tty_hangup(struct tty_struct * tty); extern void tty_vhangup(struct tty_struct * tty); extern void tty_unhangup(struct file *filp); extern int tty_hung_up_p(struct file * filp); +extern int is_tty(struct file *filp); extern void do_SAK(struct tty_struct *tty); extern void __do_SAK(struct tty_struct *tty); extern void disassociate_ctty(int priv); @@ -350,7 +351,8 @@ extern void tty_audit_add_data(struct tty_struct *tty, unsigned char *data, extern void tty_audit_exit(void); extern void tty_audit_fork(struct signal_struct *sig); extern void tty_audit_push(struct tty_struct *tty); -extern void tty_audit_push_task(struct task_struct *tsk, uid_t loginuid, u32 sessionid); +extern void tty_audit_push_task(struct task_struct *tsk, uid_t loginuid); +extern void tty_audit_opening(void); #else static inline void tty_audit_add_data(struct tty_struct *tty, unsigned char *data, size_t size) @@ -365,7 +367,10 @@ static inline void tty_audit_fork(struct signal_struct *sig) static inline void tty_audit_push(struct tty_struct *tty) { } -static inline void tty_audit_push_task(struct task_struct *tsk, uid_t loginuid, u32 sessionid) +static inline void tty_audit_push_task(struct task_struct *tsk, uid_t loginuid) +{ +} +static inline void tty_audit_opening(void) { } #endif diff --git a/trunk/include/linux/unaligned/access_ok.h b/trunk/include/linux/unaligned/access_ok.h deleted file mode 100644 index 99c1b4d20b0f..000000000000 --- a/trunk/include/linux/unaligned/access_ok.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef _LINUX_UNALIGNED_ACCESS_OK_H -#define _LINUX_UNALIGNED_ACCESS_OK_H - -#include -#include - -static inline u16 get_unaligned_le16(const void *p) -{ - return le16_to_cpup((__le16 *)p); -} - -static inline u32 get_unaligned_le32(const void *p) -{ - return le32_to_cpup((__le32 *)p); -} - -static inline u64 get_unaligned_le64(const void *p) -{ - return le64_to_cpup((__le64 *)p); -} - -static inline u16 get_unaligned_be16(const void *p) -{ - return be16_to_cpup((__be16 *)p); -} - -static inline u32 get_unaligned_be32(const void *p) -{ - return be32_to_cpup((__be32 *)p); -} - -static inline u64 get_unaligned_be64(const void *p) -{ - return be64_to_cpup((__be64 *)p); -} - -static inline void put_unaligned_le16(u16 val, void *p) -{ - *((__le16 *)p) = cpu_to_le16(val); -} - -static inline void put_unaligned_le32(u32 val, void *p) -{ - *((__le32 *)p) = cpu_to_le32(val); -} - -static inline void put_unaligned_le64(u64 val, void *p) -{ - *((__le64 *)p) = cpu_to_le64(val); -} - -static inline void put_unaligned_be16(u16 val, void *p) -{ - *((__be16 *)p) = cpu_to_be16(val); -} - -static inline void put_unaligned_be32(u32 val, void *p) -{ - *((__be32 *)p) = cpu_to_be32(val); -} - -static inline void put_unaligned_be64(u64 val, void *p) -{ - *((__be64 *)p) = cpu_to_be64(val); -} - -#endif /* _LINUX_UNALIGNED_ACCESS_OK_H */ diff --git a/trunk/include/linux/unaligned/be_byteshift.h b/trunk/include/linux/unaligned/be_byteshift.h deleted file mode 100644 index 46dd12c5709e..000000000000 --- a/trunk/include/linux/unaligned/be_byteshift.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef _LINUX_UNALIGNED_BE_BYTESHIFT_H -#define _LINUX_UNALIGNED_BE_BYTESHIFT_H - -#include - -static inline u16 __get_unaligned_be16(const u8 *p) -{ - return p[0] << 8 | p[1]; -} - -static inline u32 __get_unaligned_be32(const u8 *p) -{ - return p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3]; -} - -static inline u64 __get_unaligned_be64(const u8 *p) -{ - return (u64)__get_unaligned_be32(p) << 32 | - __get_unaligned_be32(p + 4); -} - -static inline void __put_unaligned_be16(u16 val, u8 *p) -{ - *p++ = val >> 8; - *p++ = val; -} - -static inline void __put_unaligned_be32(u32 val, u8 *p) -{ - __put_unaligned_be16(val >> 16, p); - __put_unaligned_be16(val, p + 2); -} - -static inline void __put_unaligned_be64(u64 val, u8 *p) -{ - __put_unaligned_be32(val >> 32, p); - __put_unaligned_be32(val, p + 4); -} - -static inline u16 get_unaligned_be16(const void *p) -{ - return __get_unaligned_be16((const u8 *)p); -} - -static inline u32 get_unaligned_be32(const void *p) -{ - return __get_unaligned_be32((const u8 *)p); -} - -static inline u64 get_unaligned_be64(const void *p) -{ - return __get_unaligned_be64((const u8 *)p); -} - -static inline void put_unaligned_be16(u16 val, void *p) -{ - __put_unaligned_be16(val, p); -} - -static inline void put_unaligned_be32(u32 val, void *p) -{ - __put_unaligned_be32(val, p); -} - -static inline void put_unaligned_be64(u64 val, void *p) -{ - __put_unaligned_be64(val, p); -} - -#endif /* _LINUX_UNALIGNED_BE_BYTESHIFT_H */ diff --git a/trunk/include/linux/unaligned/be_memmove.h b/trunk/include/linux/unaligned/be_memmove.h deleted file mode 100644 index c2a76c5c9ed0..000000000000 --- a/trunk/include/linux/unaligned/be_memmove.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef _LINUX_UNALIGNED_BE_MEMMOVE_H -#define _LINUX_UNALIGNED_BE_MEMMOVE_H - -#include - -static inline u16 get_unaligned_be16(const void *p) -{ - return __get_unaligned_memmove16((const u8 *)p); -} - -static inline u32 get_unaligned_be32(const void *p) -{ - return __get_unaligned_memmove32((const u8 *)p); -} - -static inline u64 get_unaligned_be64(const void *p) -{ - return __get_unaligned_memmove64((const u8 *)p); -} - -static inline void put_unaligned_be16(u16 val, void *p) -{ - __put_unaligned_memmove16(val, p); -} - -static inline void put_unaligned_be32(u32 val, void *p) -{ - __put_unaligned_memmove32(val, p); -} - -static inline void put_unaligned_be64(u64 val, void *p) -{ - __put_unaligned_memmove64(val, p); -} - -#endif /* _LINUX_UNALIGNED_LE_MEMMOVE_H */ diff --git a/trunk/include/linux/unaligned/be_struct.h b/trunk/include/linux/unaligned/be_struct.h deleted file mode 100644 index 132415836c50..000000000000 --- a/trunk/include/linux/unaligned/be_struct.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef _LINUX_UNALIGNED_BE_STRUCT_H -#define _LINUX_UNALIGNED_BE_STRUCT_H - -#include - -static inline u16 get_unaligned_be16(const void *p) -{ - return __get_unaligned_cpu16((const u8 *)p); -} - -static inline u32 get_unaligned_be32(const void *p) -{ - return __get_unaligned_cpu32((const u8 *)p); -} - -static inline u64 get_unaligned_be64(const void *p) -{ - return __get_unaligned_cpu64((const u8 *)p); -} - -static inline void put_unaligned_be16(u16 val, void *p) -{ - __put_unaligned_cpu16(val, p); -} - -static inline void put_unaligned_be32(u32 val, void *p) -{ - __put_unaligned_cpu32(val, p); -} - -static inline void put_unaligned_be64(u64 val, void *p) -{ - __put_unaligned_cpu64(val, p); -} - -#endif /* _LINUX_UNALIGNED_BE_STRUCT_H */ diff --git a/trunk/include/linux/unaligned/generic.h b/trunk/include/linux/unaligned/generic.h deleted file mode 100644 index 02d97ff3df70..000000000000 --- a/trunk/include/linux/unaligned/generic.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef _LINUX_UNALIGNED_GENERIC_H -#define _LINUX_UNALIGNED_GENERIC_H - -/* - * Cause a link-time error if we try an unaligned access other than - * 1,2,4 or 8 bytes long - */ -extern void __bad_unaligned_access_size(void); - -#define __get_unaligned_le(ptr) ((__force typeof(*(ptr)))({ \ - __builtin_choose_expr(sizeof(*(ptr)) == 1, *(ptr), \ - __builtin_choose_expr(sizeof(*(ptr)) == 2, get_unaligned_le16((ptr)), \ - __builtin_choose_expr(sizeof(*(ptr)) == 4, get_unaligned_le32((ptr)), \ - __builtin_choose_expr(sizeof(*(ptr)) == 8, get_unaligned_le64((ptr)), \ - __bad_unaligned_access_size())))); \ - })) - -#define __get_unaligned_be(ptr) ((__force typeof(*(ptr)))({ \ - __builtin_choose_expr(sizeof(*(ptr)) == 1, *(ptr), \ - __builtin_choose_expr(sizeof(*(ptr)) == 2, get_unaligned_be16((ptr)), \ - __builtin_choose_expr(sizeof(*(ptr)) == 4, get_unaligned_be32((ptr)), \ - __builtin_choose_expr(sizeof(*(ptr)) == 8, get_unaligned_be64((ptr)), \ - __bad_unaligned_access_size())))); \ - })) - -#define __put_unaligned_le(val, ptr) ({ \ - void *__gu_p = (ptr); \ - switch (sizeof(*(ptr))) { \ - case 1: \ - *(u8 *)__gu_p = (__force u8)(val); \ - break; \ - case 2: \ - put_unaligned_le16((__force u16)(val), __gu_p); \ - break; \ - case 4: \ - put_unaligned_le32((__force u32)(val), __gu_p); \ - break; \ - case 8: \ - put_unaligned_le64((__force u64)(val), __gu_p); \ - break; \ - default: \ - __bad_unaligned_access_size(); \ - break; \ - } \ - (void)0; }) - -#define __put_unaligned_be(val, ptr) ({ \ - void *__gu_p = (ptr); \ - switch (sizeof(*(ptr))) { \ - case 1: \ - *(u8 *)__gu_p = (__force u8)(val); \ - break; \ - case 2: \ - put_unaligned_be16((__force u16)(val), __gu_p); \ - break; \ - case 4: \ - put_unaligned_be32((__force u32)(val), __gu_p); \ - break; \ - case 8: \ - put_unaligned_be64((__force u64)(val), __gu_p); \ - break; \ - default: \ - __bad_unaligned_access_size(); \ - break; \ - } \ - (void)0; }) - -#endif /* _LINUX_UNALIGNED_GENERIC_H */ diff --git a/trunk/include/linux/unaligned/le_byteshift.h b/trunk/include/linux/unaligned/le_byteshift.h deleted file mode 100644 index 59777e951baf..000000000000 --- a/trunk/include/linux/unaligned/le_byteshift.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef _LINUX_UNALIGNED_LE_BYTESHIFT_H -#define _LINUX_UNALIGNED_LE_BYTESHIFT_H - -#include - -static inline u16 __get_unaligned_le16(const u8 *p) -{ - return p[0] | p[1] << 8; -} - -static inline u32 __get_unaligned_le32(const u8 *p) -{ - return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24; -} - -static inline u64 __get_unaligned_le64(const u8 *p) -{ - return (u64)__get_unaligned_le32(p + 4) << 32 | - __get_unaligned_le32(p); -} - -static inline void __put_unaligned_le16(u16 val, u8 *p) -{ - *p++ = val; - *p++ = val >> 8; -} - -static inline void __put_unaligned_le32(u32 val, u8 *p) -{ - __put_unaligned_le16(val >> 16, p + 2); - __put_unaligned_le16(val, p); -} - -static inline void __put_unaligned_le64(u64 val, u8 *p) -{ - __put_unaligned_le32(val >> 32, p + 4); - __put_unaligned_le32(val, p); -} - -static inline u16 get_unaligned_le16(const void *p) -{ - return __get_unaligned_le16((const u8 *)p); -} - -static inline u32 get_unaligned_le32(const void *p) -{ - return __get_unaligned_le32((const u8 *)p); -} - -static inline u64 get_unaligned_le64(const void *p) -{ - return __get_unaligned_le64((const u8 *)p); -} - -static inline void put_unaligned_le16(u16 val, void *p) -{ - __put_unaligned_le16(val, p); -} - -static inline void put_unaligned_le32(u32 val, void *p) -{ - __put_unaligned_le32(val, p); -} - -static inline void put_unaligned_le64(u64 val, void *p) -{ - __put_unaligned_le64(val, p); -} - -#endif /* _LINUX_UNALIGNED_LE_BYTESHIFT_H */ diff --git a/trunk/include/linux/unaligned/le_memmove.h b/trunk/include/linux/unaligned/le_memmove.h deleted file mode 100644 index 269849bee4ec..000000000000 --- a/trunk/include/linux/unaligned/le_memmove.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef _LINUX_UNALIGNED_LE_MEMMOVE_H -#define _LINUX_UNALIGNED_LE_MEMMOVE_H - -#include - -static inline u16 get_unaligned_le16(const void *p) -{ - return __get_unaligned_memmove16((const u8 *)p); -} - -static inline u32 get_unaligned_le32(const void *p) -{ - return __get_unaligned_memmove32((const u8 *)p); -} - -static inline u64 get_unaligned_le64(const void *p) -{ - return __get_unaligned_memmove64((const u8 *)p); -} - -static inline void put_unaligned_le16(u16 val, void *p) -{ - __put_unaligned_memmove16(val, p); -} - -static inline void put_unaligned_le32(u32 val, void *p) -{ - __put_unaligned_memmove32(val, p); -} - -static inline void put_unaligned_le64(u64 val, void *p) -{ - __put_unaligned_memmove64(val, p); -} - -#endif /* _LINUX_UNALIGNED_LE_MEMMOVE_H */ diff --git a/trunk/include/linux/unaligned/le_struct.h b/trunk/include/linux/unaligned/le_struct.h deleted file mode 100644 index 088c4572faa8..000000000000 --- a/trunk/include/linux/unaligned/le_struct.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef _LINUX_UNALIGNED_LE_STRUCT_H -#define _LINUX_UNALIGNED_LE_STRUCT_H - -#include - -static inline u16 get_unaligned_le16(const void *p) -{ - return __get_unaligned_cpu16((const u8 *)p); -} - -static inline u32 get_unaligned_le32(const void *p) -{ - return __get_unaligned_cpu32((const u8 *)p); -} - -static inline u64 get_unaligned_le64(const void *p) -{ - return __get_unaligned_cpu64((const u8 *)p); -} - -static inline void put_unaligned_le16(u16 val, void *p) -{ - __put_unaligned_cpu16(val, p); -} - -static inline void put_unaligned_le32(u32 val, void *p) -{ - __put_unaligned_cpu32(val, p); -} - -static inline void put_unaligned_le64(u64 val, void *p) -{ - __put_unaligned_cpu64(val, p); -} - -#endif /* _LINUX_UNALIGNED_LE_STRUCT_H */ diff --git a/trunk/include/linux/unaligned/memmove.h b/trunk/include/linux/unaligned/memmove.h deleted file mode 100644 index eeb5a779a4fd..000000000000 --- a/trunk/include/linux/unaligned/memmove.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef _LINUX_UNALIGNED_MEMMOVE_H -#define _LINUX_UNALIGNED_MEMMOVE_H - -#include -#include - -/* Use memmove here, so gcc does not insert a __builtin_memcpy. */ - -static inline u16 __get_unaligned_memmove16(const void *p) -{ - u16 tmp; - memmove(&tmp, p, 2); - return tmp; -} - -static inline u32 __get_unaligned_memmove32(const void *p) -{ - u32 tmp; - memmove(&tmp, p, 4); - return tmp; -} - -static inline u64 __get_unaligned_memmove64(const void *p) -{ - u64 tmp; - memmove(&tmp, p, 8); - return tmp; -} - -static inline void __put_unaligned_memmove16(u16 val, void *p) -{ - memmove(p, &val, 2); -} - -static inline void __put_unaligned_memmove32(u32 val, void *p) -{ - memmove(p, &val, 4); -} - -static inline void __put_unaligned_memmove64(u64 val, void *p) -{ - memmove(p, &val, 8); -} - -#endif /* _LINUX_UNALIGNED_MEMMOVE_H */ diff --git a/trunk/include/linux/unaligned/packed_struct.h b/trunk/include/linux/unaligned/packed_struct.h deleted file mode 100644 index 2498bb9fe002..000000000000 --- a/trunk/include/linux/unaligned/packed_struct.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef _LINUX_UNALIGNED_PACKED_STRUCT_H -#define _LINUX_UNALIGNED_PACKED_STRUCT_H - -#include - -struct __una_u16 { u16 x __attribute__((packed)); }; -struct __una_u32 { u32 x __attribute__((packed)); }; -struct __una_u64 { u64 x __attribute__((packed)); }; - -static inline u16 __get_unaligned_cpu16(const void *p) -{ - const struct __una_u16 *ptr = (const struct __una_u16 *)p; - return ptr->x; -} - -static inline u32 __get_unaligned_cpu32(const void *p) -{ - const struct __una_u32 *ptr = (const struct __una_u32 *)p; - return ptr->x; -} - -static inline u64 __get_unaligned_cpu64(const void *p) -{ - const struct __una_u64 *ptr = (const struct __una_u64 *)p; - return ptr->x; -} - -static inline void __put_unaligned_cpu16(u16 val, void *p) -{ - struct __una_u16 *ptr = (struct __una_u16 *)p; - ptr->x = val; -} - -static inline void __put_unaligned_cpu32(u32 val, void *p) -{ - struct __una_u32 *ptr = (struct __una_u32 *)p; - ptr->x = val; -} - -static inline void __put_unaligned_cpu64(u64 val, void *p) -{ - struct __una_u64 *ptr = (struct __una_u64 *)p; - ptr->x = val; -} - -#endif /* _LINUX_UNALIGNED_PACKED_STRUCT_H */ diff --git a/trunk/include/linux/xattr.h b/trunk/include/linux/xattr.h index d131e352cfe1..df6b95d2218e 100644 --- a/trunk/include/linux/xattr.h +++ b/trunk/include/linux/xattr.h @@ -47,10 +47,10 @@ struct xattr_handler { }; ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t); -ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t); +ssize_t vfs_getxattr(struct dentry *, char *, void *, size_t); ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size); -int vfs_setxattr(struct dentry *, const char *, const void *, size_t, int); -int vfs_removexattr(struct dentry *, const char *); +int vfs_setxattr(struct dentry *, char *, void *, size_t, int); +int vfs_removexattr(struct dentry *, char *); ssize_t generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size); ssize_t generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size); diff --git a/trunk/include/media/v4l2-chip-ident.h b/trunk/include/media/v4l2-chip-ident.h index 2a527742701a..0ea0bd85c036 100644 --- a/trunk/include/media/v4l2-chip-ident.h +++ b/trunk/include/media/v4l2-chip-ident.h @@ -64,7 +64,6 @@ enum { /* Conexant MPEG encoder/decoders: reserved range 410-420 */ V4L2_IDENT_CX23415 = 415, V4L2_IDENT_CX23416 = 416, - V4L2_IDENT_CX23418 = 418, /* module vp27smpx: just ident 2700 */ V4L2_IDENT_VP27SMPX = 2700, diff --git a/trunk/include/media/v4l2-common.h b/trunk/include/media/v4l2-common.h index 020d05758bd8..316a58453134 100644 --- a/trunk/include/media/v4l2-common.h +++ b/trunk/include/media/v4l2-common.h @@ -107,11 +107,9 @@ int v4l2_chip_match_host(u32 id_type, u32 chip_id); struct i2c_driver; struct i2c_adapter; struct i2c_client; -struct i2c_device_id; int v4l2_i2c_attach(struct i2c_adapter *adapter, int address, struct i2c_driver *driver, - const char *name, - int (*probe)(struct i2c_client *, const struct i2c_device_id *)); + const char *name, int (*probe)(struct i2c_client *)); /* ------------------------------------------------------------------------- */ diff --git a/trunk/include/media/v4l2-i2c-drv-legacy.h b/trunk/include/media/v4l2-i2c-drv-legacy.h index 347b6f8beb23..e7645578fc22 100644 --- a/trunk/include/media/v4l2-i2c-drv-legacy.h +++ b/trunk/include/media/v4l2-i2c-drv-legacy.h @@ -25,7 +25,7 @@ struct v4l2_i2c_driver_data { const char * const name; int driverid; int (*command)(struct i2c_client *client, unsigned int cmd, void *arg); - int (*probe)(struct i2c_client *client, const struct i2c_device_id *id); + int (*probe)(struct i2c_client *client); int (*remove)(struct i2c_client *client); int (*suspend)(struct i2c_client *client, pm_message_t state); int (*resume)(struct i2c_client *client); diff --git a/trunk/include/media/v4l2-i2c-drv.h b/trunk/include/media/v4l2-i2c-drv.h index 7b6f06be7950..9e4bab276915 100644 --- a/trunk/include/media/v4l2-i2c-drv.h +++ b/trunk/include/media/v4l2-i2c-drv.h @@ -30,7 +30,7 @@ struct v4l2_i2c_driver_data { const char * const name; int driverid; int (*command)(struct i2c_client *client, unsigned int cmd, void *arg); - int (*probe)(struct i2c_client *client, const struct i2c_device_id *id); + int (*probe)(struct i2c_client *client); int (*remove)(struct i2c_client *client); int (*suspend)(struct i2c_client *client, pm_message_t state); int (*resume)(struct i2c_client *client); diff --git a/trunk/include/net/netlabel.h b/trunk/include/net/netlabel.h index e4d2d6baa983..5e53a85b5ca1 100644 --- a/trunk/include/net/netlabel.h +++ b/trunk/include/net/netlabel.h @@ -103,7 +103,6 @@ struct cipso_v4_doi; struct netlbl_audit { u32 secid; uid_t loginuid; - u32 sessionid; }; /* diff --git a/trunk/include/net/xfrm.h b/trunk/include/net/xfrm.h index d1350bcccb03..baa9f372cfd1 100644 --- a/trunk/include/net/xfrm.h +++ b/trunk/include/net/xfrm.h @@ -597,9 +597,8 @@ struct xfrm_spi_skb_cb { /* Audit Information */ struct xfrm_audit { + u32 loginuid; u32 secid; - uid_t loginuid; - u32 sessionid; }; #ifdef CONFIG_AUDITSYSCALL @@ -617,13 +616,13 @@ static inline struct audit_buffer *xfrm_audit_start(const char *op) return audit_buf; } -static inline void xfrm_audit_helper_usrinfo(uid_t auid, u32 ses, u32 secid, +static inline void xfrm_audit_helper_usrinfo(u32 auid, u32 secid, struct audit_buffer *audit_buf) { char *secctx; u32 secctx_len; - audit_log_format(audit_buf, " auid=%u ses=%u", auid, ses); + audit_log_format(audit_buf, " auid=%u", auid); if (secid != 0 && security_secid_to_secctx(secid, &secctx, &secctx_len) == 0) { audit_log_format(audit_buf, " subj=%s", secctx); @@ -633,13 +632,13 @@ static inline void xfrm_audit_helper_usrinfo(uid_t auid, u32 ses, u32 secid, } extern void xfrm_audit_policy_add(struct xfrm_policy *xp, int result, - u32 auid, u32 ses, u32 secid); + u32 auid, u32 secid); extern void xfrm_audit_policy_delete(struct xfrm_policy *xp, int result, - u32 auid, u32 ses, u32 secid); + u32 auid, u32 secid); extern void xfrm_audit_state_add(struct xfrm_state *x, int result, - u32 auid, u32 ses, u32 secid); + u32 auid, u32 secid); extern void xfrm_audit_state_delete(struct xfrm_state *x, int result, - u32 auid, u32 ses, u32 secid); + u32 auid, u32 secid); extern void xfrm_audit_state_replay_overflow(struct xfrm_state *x, struct sk_buff *skb); extern void xfrm_audit_state_notfound_simple(struct sk_buff *skb, u16 family); @@ -648,10 +647,10 @@ extern void xfrm_audit_state_notfound(struct sk_buff *skb, u16 family, extern void xfrm_audit_state_icvfail(struct xfrm_state *x, struct sk_buff *skb, u8 proto); #else -#define xfrm_audit_policy_add(x, r, a, se, s) do { ; } while (0) -#define xfrm_audit_policy_delete(x, r, a, se, s) do { ; } while (0) -#define xfrm_audit_state_add(x, r, a, se, s) do { ; } while (0) -#define xfrm_audit_state_delete(x, r, a, se, s) do { ; } while (0) +#define xfrm_audit_policy_add(x, r, a, s) do { ; } while (0) +#define xfrm_audit_policy_delete(x, r, a, s) do { ; } while (0) +#define xfrm_audit_state_add(x, r, a, s) do { ; } while (0) +#define xfrm_audit_state_delete(x, r, a, s) do { ; } while (0) #define xfrm_audit_state_replay_overflow(x, s) do { ; } while (0) #define xfrm_audit_state_notfound_simple(s, f) do { ; } while (0) #define xfrm_audit_state_notfound(s, f, sp, sq) do { ; } while (0) diff --git a/trunk/include/rdma/ib_umem.h b/trunk/include/rdma/ib_umem.h index 9ee0d2e51b16..22298423cf0b 100644 --- a/trunk/include/rdma/ib_umem.h +++ b/trunk/include/rdma/ib_umem.h @@ -62,7 +62,7 @@ struct ib_umem_chunk { #ifdef CONFIG_INFINIBAND_USER_MEM struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr, - size_t size, int access, int dmasync); + size_t size, int access); void ib_umem_release(struct ib_umem *umem); int ib_umem_page_count(struct ib_umem *umem); @@ -72,7 +72,7 @@ int ib_umem_page_count(struct ib_umem *umem); static inline struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr, size_t size, - int access, int dmasync) { + int access) { return ERR_PTR(-EINVAL); } static inline void ib_umem_release(struct ib_umem *umem) { } diff --git a/trunk/include/rdma/ib_verbs.h b/trunk/include/rdma/ib_verbs.h index 911a661b7278..2dcbecce3f61 100644 --- a/trunk/include/rdma/ib_verbs.h +++ b/trunk/include/rdma/ib_verbs.h @@ -1542,24 +1542,6 @@ static inline void ib_dma_unmap_single(struct ib_device *dev, dma_unmap_single(dev->dma_device, addr, size, direction); } -static inline u64 ib_dma_map_single_attrs(struct ib_device *dev, - void *cpu_addr, size_t size, - enum dma_data_direction direction, - struct dma_attrs *attrs) -{ - return dma_map_single_attrs(dev->dma_device, cpu_addr, size, - direction, attrs); -} - -static inline void ib_dma_unmap_single_attrs(struct ib_device *dev, - u64 addr, size_t size, - enum dma_data_direction direction, - struct dma_attrs *attrs) -{ - return dma_unmap_single_attrs(dev->dma_device, addr, size, - direction, attrs); -} - /** * ib_dma_map_page - Map a physical page to DMA address * @dev: The device for which the dma_addr is to be created @@ -1629,21 +1611,6 @@ static inline void ib_dma_unmap_sg(struct ib_device *dev, dma_unmap_sg(dev->dma_device, sg, nents, direction); } -static inline int ib_dma_map_sg_attrs(struct ib_device *dev, - struct scatterlist *sg, int nents, - enum dma_data_direction direction, - struct dma_attrs *attrs) -{ - return dma_map_sg_attrs(dev->dma_device, sg, nents, direction, attrs); -} - -static inline void ib_dma_unmap_sg_attrs(struct ib_device *dev, - struct scatterlist *sg, int nents, - enum dma_data_direction direction, - struct dma_attrs *attrs) -{ - dma_unmap_sg_attrs(dev->dma_device, sg, nents, direction, attrs); -} /** * ib_sg_dma_address - Return the DMA address from a scatter/gather entry * @dev: The device for which the DMA addresses were created diff --git a/trunk/include/scsi/libiscsi.h b/trunk/include/scsi/libiscsi.h index cd3ca63d4fb1..7b90b63fb5c7 100644 --- a/trunk/include/scsi/libiscsi.h +++ b/trunk/include/scsi/libiscsi.h @@ -225,7 +225,6 @@ struct iscsi_conn { /* custom statistics */ uint32_t eh_abort_cnt; - uint32_t fmr_unalign_cnt; }; struct iscsi_pool { diff --git a/trunk/include/sound/mpu401.h b/trunk/include/sound/mpu401.h index 1f1d53f8830b..68b634b75068 100644 --- a/trunk/include/sound/mpu401.h +++ b/trunk/include/sound/mpu401.h @@ -50,7 +50,6 @@ #define MPU401_INFO_INTEGRATED (1 << 2) /* integrated h/w port */ #define MPU401_INFO_MMIO (1 << 3) /* MMIO access */ #define MPU401_INFO_TX_IRQ (1 << 4) /* independent TX irq */ -#define MPU401_INFO_NO_ACK (1 << 6) /* No ACK cmd needed */ #define MPU401_MODE_BIT_INPUT 0 #define MPU401_MODE_BIT_OUTPUT 1 diff --git a/trunk/init/Kconfig b/trunk/init/Kconfig index 3e7b257fc05f..da071c4bbfb7 100644 --- a/trunk/init/Kconfig +++ b/trunk/init/Kconfig @@ -259,14 +259,17 @@ config IKCONFIG_PROC config LOG_BUF_SHIFT int "Kernel log buffer size (16 => 64KB, 17 => 128KB)" range 12 21 - default 17 + default 17 if S390 || LOCKDEP + default 16 if X86_NUMAQ || IA64 + default 15 if SMP + default 14 help Select kernel log buffer size as a power of 2. - Examples: - 17 => 128 KB - 16 => 64 KB - 15 => 32 KB - 14 => 16 KB + Defaults and Examples: + 17 => 128 KB for S/390 + 16 => 64 KB for x86 NUMAQ or IA-64 + 15 => 32 KB for SMP + 14 => 16 KB for uniprocessor 13 => 8 KB 12 => 4 KB @@ -281,7 +284,6 @@ config CGROUPS config CGROUP_DEBUG bool "Example debug cgroup subsystem" depends on CGROUPS - default n help This option enables a simple cgroup subsystem that exports useful debugging information about the cgroups @@ -298,13 +300,6 @@ config CGROUP_NS for instance virtual servers and checkpoint/restart jobs. -config CGROUP_DEVICE - bool "Device controller for cgroups" - depends on CGROUPS && EXPERIMENTAL - help - Provides a cgroup implementing whitelists for devices which - a process in the cgroup can mknod or open. - config CPUSETS bool "Cpuset support" depends on SMP && CGROUPS @@ -378,13 +373,9 @@ config RESOURCE_COUNTERS infrastructure that works with cgroups depends on CGROUPS -config MM_OWNER - bool - config CGROUP_MEM_RES_CTLR bool "Memory Resource Controller for Control Groups" depends on CGROUPS && RESOURCE_COUNTERS - select MM_OWNER help Provides a memory resource controller that manages both page cache and RSS memory. @@ -397,9 +388,6 @@ config CGROUP_MEM_RES_CTLR Only enable when you're ok with these trade offs and really sure you need the memory resource controller. - This config option also selects MM_OWNER config option, which - could in turn add some fork/exit overhead. - config SYSFS_DEPRECATED bool @@ -550,17 +538,6 @@ config SYSCTL_SYSCALL If unsure say Y here. -config SYSCTL_SYSCALL_CHECK - bool "Sysctl checks" if EMBEDDED - depends on SYSCTL_SYSCALL - default y - ---help--- - sys_sysctl uses binary paths that have been found challenging - to properly maintain and use. This enables checks that help - you to keep things correct. - - If unsure say Y here. - config KALLSYMS bool "Load all symbols for debugging/ksymoops" if EMBEDDED default y diff --git a/trunk/init/initramfs.c b/trunk/init/initramfs.c index 8eeeccb328c9..d53fee8d8604 100644 --- a/trunk/init/initramfs.c +++ b/trunk/init/initramfs.c @@ -57,7 +57,7 @@ static char __init *find_link(int major, int minor, int ino, continue; return (*p)->name; } - q = kmalloc(sizeof(struct hash), GFP_KERNEL); + q = (struct hash *)malloc(sizeof(struct hash)); if (!q) panic("can't allocate link hash entry"); q->major = major; @@ -77,7 +77,7 @@ static void __init free_hash(void) while (*p) { q = *p; *p = q->next; - kfree(q); + free(q); } } } @@ -445,10 +445,10 @@ static char * __init unpack_to_rootfs(char *buf, unsigned len, int check_only) { int written; dry_run = check_only; - header_buf = kmalloc(110, GFP_KERNEL); - symlink_buf = kmalloc(PATH_MAX + N_ALIGN(PATH_MAX) + 1, GFP_KERNEL); - name_buf = kmalloc(N_ALIGN(PATH_MAX), GFP_KERNEL); - window = kmalloc(WSIZE, GFP_KERNEL); + header_buf = malloc(110); + symlink_buf = malloc(PATH_MAX + N_ALIGN(PATH_MAX) + 1); + name_buf = malloc(N_ALIGN(PATH_MAX)); + window = malloc(WSIZE); if (!window || !header_buf || !symlink_buf || !name_buf) panic("can't allocate buffers"); state = Start; @@ -484,10 +484,10 @@ static char * __init unpack_to_rootfs(char *buf, unsigned len, int check_only) buf += inptr; len -= inptr; } - kfree(window); - kfree(name_buf); - kfree(symlink_buf); - kfree(header_buf); + free(window); + free(name_buf); + free(symlink_buf); + free(header_buf); return message; } diff --git a/trunk/init/main.c b/trunk/init/main.c index 624266b524d4..1687b0167c4a 100644 --- a/trunk/init/main.c +++ b/trunk/init/main.c @@ -58,7 +58,6 @@ #include #include #include -#include #include #include @@ -560,7 +559,6 @@ asmlinkage void __init start_kernel(void) printk(KERN_NOTICE); printk(linux_banner); setup_arch(&command_line); - mm_init_owner(&init_mm, &init_task); setup_command_line(command_line); unwind_setup(); setup_per_cpu_areas(); @@ -638,7 +636,6 @@ asmlinkage void __init start_kernel(void) enable_debug_pagealloc(); cpu_hotplug_init(); kmem_cache_init(); - idr_init_cache(); setup_per_cpu_pageset(); numa_policy_init(); if (late_time_init) @@ -703,8 +700,10 @@ static void __init do_initcalls(void) int result; if (initcall_debug) { - print_fn_descriptor_symbol("calling %s()\n", + printk("Calling initcall 0x%p", *call); + print_fn_descriptor_symbol(": %s()", (unsigned long) *call); + printk("\n"); t0 = ktime_get(); } @@ -714,10 +713,15 @@ static void __init do_initcalls(void) t1 = ktime_get(); delta = ktime_sub(t1, t0); - print_fn_descriptor_symbol("initcall %s()", + printk("initcall 0x%p", *call); + print_fn_descriptor_symbol(": %s()", (unsigned long) *call); - printk(" returned %d after %Ld msecs\n", result, - (unsigned long long) delta.tv64 >> 20); + printk(" returned %d.\n", result); + + printk("initcall 0x%p ran for %Ld msecs: ", + *call, (unsigned long long)delta.tv64 >> 20); + print_fn_descriptor_symbol("%s()\n", + (unsigned long) *call); } if (result && result != -ENODEV && initcall_debug) { @@ -733,9 +737,10 @@ static void __init do_initcalls(void) local_irq_enable(); } if (msg) { - print_fn_descriptor_symbol(KERN_WARNING "initcall %s()", + printk(KERN_WARNING "initcall at 0x%p", *call); + print_fn_descriptor_symbol(": %s()", (unsigned long) *call); - printk(" returned with %s\n", msg); + printk(": returned with %s\n", msg); } } diff --git a/trunk/ipc/Makefile b/trunk/ipc/Makefile index 65c384395801..5fc5e33ea047 100644 --- a/trunk/ipc/Makefile +++ b/trunk/ipc/Makefile @@ -3,7 +3,7 @@ # obj-$(CONFIG_SYSVIPC_COMPAT) += compat.o -obj-$(CONFIG_SYSVIPC) += util.o msgutil.o msg.o sem.o shm.o ipcns_notifier.o +obj-$(CONFIG_SYSVIPC) += util.o msgutil.o msg.o sem.o shm.o obj-$(CONFIG_SYSVIPC_SYSCTL) += ipc_sysctl.o obj_mq-$(CONFIG_COMPAT) += compat_mq.o obj-$(CONFIG_POSIX_MQUEUE) += mqueue.o msgutil.o $(obj_mq-y) diff --git a/trunk/ipc/ipc_sysctl.c b/trunk/ipc/ipc_sysctl.c index d3497465cc0a..7f4235bed51b 100644 --- a/trunk/ipc/ipc_sysctl.c +++ b/trunk/ipc/ipc_sysctl.c @@ -15,8 +15,6 @@ #include #include #include -#include -#include "util.h" static void *get_ipc(ctl_table *table) { @@ -26,27 +24,6 @@ static void *get_ipc(ctl_table *table) return which; } -/* - * Routine that is called when a tunable has successfully been changed by - * hand and it has a callback routine registered on the ipc namespace notifier - * chain: we don't want such tunables to be recomputed anymore upon memory - * add/remove or ipc namespace creation/removal. - * They can come back to a recomputable state by being set to a <0 value. - */ -static void tunable_set_callback(int val) -{ - if (val >= 0) - unregister_ipcns_notifier(current->nsproxy->ipc_ns); - else { - /* - * Re-enable automatic recomputing only if not already - * enabled. - */ - recompute_msgmni(current->nsproxy->ipc_ns); - cond_register_ipcns_notifier(current->nsproxy->ipc_ns); - } -} - #ifdef CONFIG_PROC_FS static int proc_ipc_dointvec(ctl_table *table, int write, struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos) @@ -58,24 +35,6 @@ static int proc_ipc_dointvec(ctl_table *table, int write, struct file *filp, return proc_dointvec(&ipc_table, write, filp, buffer, lenp, ppos); } -static int proc_ipc_callback_dointvec(ctl_table *table, int write, - struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos) -{ - struct ctl_table ipc_table; - size_t lenp_bef = *lenp; - int rc; - - memcpy(&ipc_table, table, sizeof(ipc_table)); - ipc_table.data = get_ipc(table); - - rc = proc_dointvec(&ipc_table, write, filp, buffer, lenp, ppos); - - if (write && !rc && lenp_bef == *lenp) - tunable_set_callback(*((int *)(ipc_table.data))); - - return rc; -} - static int proc_ipc_doulongvec_minmax(ctl_table *table, int write, struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos) { @@ -90,7 +49,6 @@ static int proc_ipc_doulongvec_minmax(ctl_table *table, int write, #else #define proc_ipc_doulongvec_minmax NULL #define proc_ipc_dointvec NULL -#define proc_ipc_callback_dointvec NULL #endif #ifdef CONFIG_SYSCTL_SYSCALL @@ -132,30 +90,8 @@ static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen, } return 1; } - -static int sysctl_ipc_registered_data(ctl_table *table, int __user *name, - int nlen, void __user *oldval, size_t __user *oldlenp, - void __user *newval, size_t newlen) -{ - int rc; - - rc = sysctl_ipc_data(table, name, nlen, oldval, oldlenp, newval, - newlen); - - if (newval && newlen && rc > 0) { - /* - * Tunable has successfully been changed from userland - */ - int *data = get_ipc(table); - - tunable_set_callback(*data); - } - - return rc; -} #else #define sysctl_ipc_data NULL -#define sysctl_ipc_registered_data NULL #endif static struct ctl_table ipc_kern_table[] = { @@ -201,8 +137,8 @@ static struct ctl_table ipc_kern_table[] = { .data = &init_ipc_ns.msg_ctlmni, .maxlen = sizeof (init_ipc_ns.msg_ctlmni), .mode = 0644, - .proc_handler = proc_ipc_callback_dointvec, - .strategy = sysctl_ipc_registered_data, + .proc_handler = proc_ipc_dointvec, + .strategy = sysctl_ipc_data, }, { .ctl_name = KERN_MSGMNB, diff --git a/trunk/ipc/ipcns_notifier.c b/trunk/ipc/ipcns_notifier.c deleted file mode 100644 index 70ff09183f7b..000000000000 --- a/trunk/ipc/ipcns_notifier.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * linux/ipc/ipcns_notifier.c - * Copyright (C) 2007 BULL SA. Nadia Derbey - * - * Notification mechanism for ipc namespaces: - * The callback routine registered in the memory chain invokes the ipcns - * notifier chain with the IPCNS_MEMCHANGED event. - * Each callback routine registered in the ipcns namespace recomputes msgmni - * for the owning namespace. - */ - -#include -#include -#include -#include -#include - -#include "util.h" - - - -static BLOCKING_NOTIFIER_HEAD(ipcns_chain); - - -static int ipcns_callback(struct notifier_block *self, - unsigned long action, void *arg) -{ - struct ipc_namespace *ns; - - switch (action) { - case IPCNS_MEMCHANGED: /* amount of lowmem has changed */ - case IPCNS_CREATED: - case IPCNS_REMOVED: - /* - * It's time to recompute msgmni - */ - ns = container_of(self, struct ipc_namespace, ipcns_nb); - /* - * No need to get a reference on the ns: the 1st job of - * free_ipc_ns() is to unregister the callback routine. - * blocking_notifier_chain_unregister takes the wr lock to do - * it. - * When this callback routine is called the rd lock is held by - * blocking_notifier_call_chain. - * So the ipc ns cannot be freed while we are here. - */ - recompute_msgmni(ns); - break; - default: - break; - } - - return NOTIFY_OK; -} - -int register_ipcns_notifier(struct ipc_namespace *ns) -{ - memset(&ns->ipcns_nb, 0, sizeof(ns->ipcns_nb)); - ns->ipcns_nb.notifier_call = ipcns_callback; - ns->ipcns_nb.priority = IPCNS_CALLBACK_PRI; - return blocking_notifier_chain_register(&ipcns_chain, &ns->ipcns_nb); -} - -int cond_register_ipcns_notifier(struct ipc_namespace *ns) -{ - memset(&ns->ipcns_nb, 0, sizeof(ns->ipcns_nb)); - ns->ipcns_nb.notifier_call = ipcns_callback; - ns->ipcns_nb.priority = IPCNS_CALLBACK_PRI; - return blocking_notifier_chain_cond_register(&ipcns_chain, - &ns->ipcns_nb); -} - -int unregister_ipcns_notifier(struct ipc_namespace *ns) -{ - return blocking_notifier_chain_unregister(&ipcns_chain, - &ns->ipcns_nb); -} - -int ipcns_notify(unsigned long val) -{ - return blocking_notifier_call_chain(&ipcns_chain, val, NULL); -} diff --git a/trunk/ipc/msg.c b/trunk/ipc/msg.c index 32494e8cc7a5..46585a05473e 100644 --- a/trunk/ipc/msg.c +++ b/trunk/ipc/msg.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -71,6 +70,7 @@ struct msg_sender { #define msg_ids(ns) ((ns)->ids[IPC_MSG_IDS]) #define msg_unlock(msq) ipc_unlock(&(msq)->q_perm) +#define msg_buildid(id, seq) ipc_buildid(id, seq) static void freeque(struct ipc_namespace *, struct kern_ipc_perm *); static int newque(struct ipc_namespace *, struct ipc_params *); @@ -78,49 +78,11 @@ static int newque(struct ipc_namespace *, struct ipc_params *); static int sysvipc_msg_proc_show(struct seq_file *s, void *it); #endif -/* - * Scale msgmni with the available lowmem size: the memory dedicated to msg - * queues should occupy at most 1/MSG_MEM_SCALE of lowmem. - * Also take into account the number of nsproxies created so far. - * This should be done staying within the (MSGMNI , IPCMNI/nr_ipc_ns) range. - */ -void recompute_msgmni(struct ipc_namespace *ns) -{ - struct sysinfo i; - unsigned long allowed; - int nb_ns; - - si_meminfo(&i); - allowed = (((i.totalram - i.totalhigh) / MSG_MEM_SCALE) * i.mem_unit) - / MSGMNB; - nb_ns = atomic_read(&nr_ipc_ns); - allowed /= nb_ns; - - if (allowed < MSGMNI) { - ns->msg_ctlmni = MSGMNI; - goto out_callback; - } - - if (allowed > IPCMNI / nb_ns) { - ns->msg_ctlmni = IPCMNI / nb_ns; - goto out_callback; - } - - ns->msg_ctlmni = allowed; - -out_callback: - - printk(KERN_INFO "msgmni has been set to %d for ipc namespace %p\n", - ns->msg_ctlmni, ns); -} - void msg_init_ns(struct ipc_namespace *ns) { ns->msg_ctlmax = MSGMAX; ns->msg_ctlmnb = MSGMNB; - - recompute_msgmni(ns); - + ns->msg_ctlmni = MSGMNI; atomic_set(&ns->msg_bytes, 0); atomic_set(&ns->msg_hdrs, 0); ipc_init_ids(&ns->ids[IPC_MSG_IDS]); @@ -141,6 +103,21 @@ void __init msg_init(void) IPC_MSG_IDS, sysvipc_msg_proc_show); } +/* + * This routine is called in the paths where the rw_mutex is held to protect + * access to the idr tree. + */ +static inline struct msg_queue *msg_lock_check_down(struct ipc_namespace *ns, + int id) +{ + struct kern_ipc_perm *ipcp = ipc_lock_check_down(&msg_ids(ns), id); + + if (IS_ERR(ipcp)) + return (struct msg_queue *)ipcp; + + return container_of(ipcp, struct msg_queue, q_perm); +} + /* * msg_lock_(check_) routines are called in the paths where the rw_mutex * is not held. @@ -209,6 +186,7 @@ static int newque(struct ipc_namespace *ns, struct ipc_params *params) return id; } + msq->q_perm.id = msg_buildid(id, msq->q_perm.seq); msq->q_stime = msq->q_rtime = 0; msq->q_ctime = get_seconds(); msq->q_cbytes = msq->q_qnum = 0; @@ -346,19 +324,19 @@ copy_msqid_to_user(void __user *buf, struct msqid64_ds *in, int version) out.msg_rtime = in->msg_rtime; out.msg_ctime = in->msg_ctime; - if (in->msg_cbytes > USHORT_MAX) - out.msg_cbytes = USHORT_MAX; + if (in->msg_cbytes > USHRT_MAX) + out.msg_cbytes = USHRT_MAX; else out.msg_cbytes = in->msg_cbytes; out.msg_lcbytes = in->msg_cbytes; - if (in->msg_qnum > USHORT_MAX) - out.msg_qnum = USHORT_MAX; + if (in->msg_qnum > USHRT_MAX) + out.msg_qnum = USHRT_MAX; else out.msg_qnum = in->msg_qnum; - if (in->msg_qbytes > USHORT_MAX) - out.msg_qbytes = USHORT_MAX; + if (in->msg_qbytes > USHRT_MAX) + out.msg_qbytes = USHRT_MAX; else out.msg_qbytes = in->msg_qbytes; out.msg_lqbytes = in->msg_qbytes; @@ -373,14 +351,31 @@ copy_msqid_to_user(void __user *buf, struct msqid64_ds *in, int version) } } +struct msq_setbuf { + unsigned long qbytes; + uid_t uid; + gid_t gid; + mode_t mode; +}; + static inline unsigned long -copy_msqid_from_user(struct msqid64_ds *out, void __user *buf, int version) +copy_msqid_from_user(struct msq_setbuf *out, void __user *buf, int version) { switch(version) { case IPC_64: - if (copy_from_user(out, buf, sizeof(*out))) + { + struct msqid64_ds tbuf; + + if (copy_from_user(&tbuf, buf, sizeof(tbuf))) return -EFAULT; + + out->qbytes = tbuf.msg_qbytes; + out->uid = tbuf.msg_perm.uid; + out->gid = tbuf.msg_perm.gid; + out->mode = tbuf.msg_perm.mode; + return 0; + } case IPC_OLD: { struct msqid_ds tbuf_old; @@ -388,14 +383,14 @@ copy_msqid_from_user(struct msqid64_ds *out, void __user *buf, int version) if (copy_from_user(&tbuf_old, buf, sizeof(tbuf_old))) return -EFAULT; - out->msg_perm.uid = tbuf_old.msg_perm.uid; - out->msg_perm.gid = tbuf_old.msg_perm.gid; - out->msg_perm.mode = tbuf_old.msg_perm.mode; + out->uid = tbuf_old.msg_perm.uid; + out->gid = tbuf_old.msg_perm.gid; + out->mode = tbuf_old.msg_perm.mode; if (tbuf_old.msg_qbytes == 0) - out->msg_qbytes = tbuf_old.msg_lqbytes; + out->qbytes = tbuf_old.msg_lqbytes; else - out->msg_qbytes = tbuf_old.msg_qbytes; + out->qbytes = tbuf_old.msg_qbytes; return 0; } @@ -404,71 +399,10 @@ copy_msqid_from_user(struct msqid64_ds *out, void __user *buf, int version) } } -/* - * This function handles some msgctl commands which require the rw_mutex - * to be held in write mode. - * NOTE: no locks must be held, the rw_mutex is taken inside this function. - */ -static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd, - struct msqid_ds __user *buf, int version) -{ - struct kern_ipc_perm *ipcp; - struct msqid64_ds msqid64; - struct msg_queue *msq; - int err; - - if (cmd == IPC_SET) { - if (copy_msqid_from_user(&msqid64, buf, version)) - return -EFAULT; - } - - ipcp = ipcctl_pre_down(&msg_ids(ns), msqid, cmd, - &msqid64.msg_perm, msqid64.msg_qbytes); - if (IS_ERR(ipcp)) - return PTR_ERR(ipcp); - - msq = container_of(ipcp, struct msg_queue, q_perm); - - err = security_msg_queue_msgctl(msq, cmd); - if (err) - goto out_unlock; - - switch (cmd) { - case IPC_RMID: - freeque(ns, ipcp); - goto out_up; - case IPC_SET: - if (msqid64.msg_qbytes > ns->msg_ctlmnb && - !capable(CAP_SYS_RESOURCE)) { - err = -EPERM; - goto out_unlock; - } - - msq->q_qbytes = msqid64.msg_qbytes; - - ipc_update_perm(&msqid64.msg_perm, ipcp); - msq->q_ctime = get_seconds(); - /* sleeping receivers might be excluded by - * stricter permissions. - */ - expunge_all(msq, -EAGAIN); - /* sleeping senders might be able to send - * due to a larger queue size. - */ - ss_wakeup(&msq->q_senders, 0); - break; - default: - err = -EINVAL; - } -out_unlock: - msg_unlock(msq); -out_up: - up_write(&msg_ids(ns).rw_mutex); - return err; -} - asmlinkage long sys_msgctl(int msqid, int cmd, struct msqid_ds __user *buf) { + struct kern_ipc_perm *ipcp; + struct msq_setbuf uninitialized_var(setbuf); struct msg_queue *msq; int err, version; struct ipc_namespace *ns; @@ -564,13 +498,82 @@ asmlinkage long sys_msgctl(int msqid, int cmd, struct msqid_ds __user *buf) return success_return; } case IPC_SET: + if (!buf) + return -EFAULT; + if (copy_msqid_from_user(&setbuf, buf, version)) + return -EFAULT; + break; case IPC_RMID: - err = msgctl_down(ns, msqid, cmd, buf, version); - return err; + break; default: return -EINVAL; } + down_write(&msg_ids(ns).rw_mutex); + msq = msg_lock_check_down(ns, msqid); + if (IS_ERR(msq)) { + err = PTR_ERR(msq); + goto out_up; + } + + ipcp = &msq->q_perm; + + err = audit_ipc_obj(ipcp); + if (err) + goto out_unlock_up; + if (cmd == IPC_SET) { + err = audit_ipc_set_perm(setbuf.qbytes, setbuf.uid, setbuf.gid, + setbuf.mode); + if (err) + goto out_unlock_up; + } + + err = -EPERM; + if (current->euid != ipcp->cuid && + current->euid != ipcp->uid && !capable(CAP_SYS_ADMIN)) + /* We _could_ check for CAP_CHOWN above, but we don't */ + goto out_unlock_up; + + err = security_msg_queue_msgctl(msq, cmd); + if (err) + goto out_unlock_up; + + switch (cmd) { + case IPC_SET: + { + err = -EPERM; + if (setbuf.qbytes > ns->msg_ctlmnb && !capable(CAP_SYS_RESOURCE)) + goto out_unlock_up; + + msq->q_qbytes = setbuf.qbytes; + + ipcp->uid = setbuf.uid; + ipcp->gid = setbuf.gid; + ipcp->mode = (ipcp->mode & ~S_IRWXUGO) | + (S_IRWXUGO & setbuf.mode); + msq->q_ctime = get_seconds(); + /* sleeping receivers might be excluded by + * stricter permissions. + */ + expunge_all(msq, -EAGAIN); + /* sleeping senders might be able to send + * due to a larger queue size. + */ + ss_wakeup(&msq->q_senders, 0); + msg_unlock(msq); + break; + } + case IPC_RMID: + freeque(ns, &msq->q_perm); + break; + } + err = 0; +out_up: + up_write(&msg_ids(ns).rw_mutex); + return err; +out_unlock_up: + msg_unlock(msq); + goto out_up; out_unlock: msg_unlock(msq); return err; diff --git a/trunk/ipc/namespace.c b/trunk/ipc/namespace.c index 9171d948751e..1b967655eb35 100644 --- a/trunk/ipc/namespace.c +++ b/trunk/ipc/namespace.c @@ -20,20 +20,10 @@ static struct ipc_namespace *clone_ipc_ns(struct ipc_namespace *old_ns) if (ns == NULL) return ERR_PTR(-ENOMEM); - atomic_inc(&nr_ipc_ns); - sem_init_ns(ns); msg_init_ns(ns); shm_init_ns(ns); - /* - * msgmni has already been computed for the new ipc ns. - * Thus, do the ipcns creation notification before registering that - * new ipcns in the chain. - */ - ipcns_notify(IPCNS_CREATED); - register_ipcns_notifier(ns); - kref_init(&ns->kref); return ns; } @@ -89,24 +79,8 @@ void free_ipc_ns(struct kref *kref) struct ipc_namespace *ns; ns = container_of(kref, struct ipc_namespace, kref); - /* - * Unregistering the hotplug notifier at the beginning guarantees - * that the ipc namespace won't be freed while we are inside the - * callback routine. Since the blocking_notifier_chain_XXX routines - * hold a rw lock on the notifier list, unregister_ipcns_notifier() - * won't take the rw lock before blocking_notifier_call_chain() has - * released the rd lock. - */ - unregister_ipcns_notifier(ns); sem_exit_ns(ns); msg_exit_ns(ns); shm_exit_ns(ns); kfree(ns); - atomic_dec(&nr_ipc_ns); - - /* - * Do the ipcns removal notification after decrementing nr_ipc_ns in - * order to have a correct value when recomputing msgmni. - */ - ipcns_notify(IPCNS_REMOVED); } diff --git a/trunk/ipc/sem.c b/trunk/ipc/sem.c index e9418df5ff3e..0b45a4d383c6 100644 --- a/trunk/ipc/sem.c +++ b/trunk/ipc/sem.c @@ -91,6 +91,7 @@ #define sem_unlock(sma) ipc_unlock(&(sma)->sem_perm) #define sem_checkid(sma, semid) ipc_checkid(&sma->sem_perm, semid) +#define sem_buildid(id, seq) ipc_buildid(id, seq) static int newary(struct ipc_namespace *, struct ipc_params *); static void freeary(struct ipc_namespace *, struct kern_ipc_perm *); @@ -140,6 +141,21 @@ void __init sem_init (void) IPC_SEM_IDS, sysvipc_sem_proc_show); } +/* + * This routine is called in the paths where the rw_mutex is held to protect + * access to the idr tree. + */ +static inline struct sem_array *sem_lock_check_down(struct ipc_namespace *ns, + int id) +{ + struct kern_ipc_perm *ipcp = ipc_lock_check_down(&sem_ids(ns), id); + + if (IS_ERR(ipcp)) + return (struct sem_array *)ipcp; + + return container_of(ipcp, struct sem_array, sem_perm); +} + /* * sem_lock_(check_) routines are called in the paths where the rw_mutex * is not held. @@ -165,25 +181,6 @@ static inline struct sem_array *sem_lock_check(struct ipc_namespace *ns, return container_of(ipcp, struct sem_array, sem_perm); } -static inline void sem_lock_and_putref(struct sem_array *sma) -{ - ipc_lock_by_ptr(&sma->sem_perm); - ipc_rcu_putref(sma); -} - -static inline void sem_getref_and_unlock(struct sem_array *sma) -{ - ipc_rcu_getref(sma); - ipc_unlock(&(sma)->sem_perm); -} - -static inline void sem_putref(struct sem_array *sma) -{ - ipc_lock_by_ptr(&sma->sem_perm); - ipc_rcu_putref(sma); - ipc_unlock(&(sma)->sem_perm); -} - static inline void sem_rmid(struct ipc_namespace *ns, struct sem_array *s) { ipc_rmid(&sem_ids(ns), &s->sem_perm); @@ -271,6 +268,7 @@ static int newary(struct ipc_namespace *ns, struct ipc_params *params) } ns->used_sems += nsems; + sma->sem_perm.id = sem_buildid(id, sma->sem_perm.seq); sma->sem_base = (struct sem *) &sma[1]; /* sma->sem_pending = NULL; */ sma->sem_pending_last = &sma->sem_pending; @@ -702,15 +700,19 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum, int i; if(nsems > SEMMSL_FAST) { - sem_getref_and_unlock(sma); + ipc_rcu_getref(sma); + sem_unlock(sma); sem_io = ipc_alloc(sizeof(ushort)*nsems); if(sem_io == NULL) { - sem_putref(sma); + ipc_lock_by_ptr(&sma->sem_perm); + ipc_rcu_putref(sma); + sem_unlock(sma); return -ENOMEM; } - sem_lock_and_putref(sma); + ipc_lock_by_ptr(&sma->sem_perm); + ipc_rcu_putref(sma); if (sma->sem_perm.deleted) { sem_unlock(sma); err = -EIDRM; @@ -731,30 +733,38 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum, int i; struct sem_undo *un; - sem_getref_and_unlock(sma); + ipc_rcu_getref(sma); + sem_unlock(sma); if(nsems > SEMMSL_FAST) { sem_io = ipc_alloc(sizeof(ushort)*nsems); if(sem_io == NULL) { - sem_putref(sma); + ipc_lock_by_ptr(&sma->sem_perm); + ipc_rcu_putref(sma); + sem_unlock(sma); return -ENOMEM; } } if (copy_from_user (sem_io, arg.array, nsems*sizeof(ushort))) { - sem_putref(sma); + ipc_lock_by_ptr(&sma->sem_perm); + ipc_rcu_putref(sma); + sem_unlock(sma); err = -EFAULT; goto out_free; } for (i = 0; i < nsems; i++) { if (sem_io[i] > SEMVMX) { - sem_putref(sma); + ipc_lock_by_ptr(&sma->sem_perm); + ipc_rcu_putref(sma); + sem_unlock(sma); err = -ERANGE; goto out_free; } } - sem_lock_and_putref(sma); + ipc_lock_by_ptr(&sma->sem_perm); + ipc_rcu_putref(sma); if (sma->sem_perm.deleted) { sem_unlock(sma); err = -EIDRM; @@ -820,14 +830,28 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum, return err; } -static inline unsigned long -copy_semid_from_user(struct semid64_ds *out, void __user *buf, int version) +struct sem_setbuf { + uid_t uid; + gid_t gid; + mode_t mode; +}; + +static inline unsigned long copy_semid_from_user(struct sem_setbuf *out, void __user *buf, int version) { switch(version) { case IPC_64: - if (copy_from_user(out, buf, sizeof(*out))) + { + struct semid64_ds tbuf; + + if(copy_from_user(&tbuf, buf, sizeof(tbuf))) return -EFAULT; + + out->uid = tbuf.sem_perm.uid; + out->gid = tbuf.sem_perm.gid; + out->mode = tbuf.sem_perm.mode; + return 0; + } case IPC_OLD: { struct semid_ds tbuf_old; @@ -835,9 +859,9 @@ copy_semid_from_user(struct semid64_ds *out, void __user *buf, int version) if(copy_from_user(&tbuf_old, buf, sizeof(tbuf_old))) return -EFAULT; - out->sem_perm.uid = tbuf_old.sem_perm.uid; - out->sem_perm.gid = tbuf_old.sem_perm.gid; - out->sem_perm.mode = tbuf_old.sem_perm.mode; + out->uid = tbuf_old.sem_perm.uid; + out->gid = tbuf_old.sem_perm.gid; + out->mode = tbuf_old.sem_perm.mode; return 0; } @@ -846,29 +870,38 @@ copy_semid_from_user(struct semid64_ds *out, void __user *buf, int version) } } -/* - * This function handles some semctl commands which require the rw_mutex - * to be held in write mode. - * NOTE: no locks must be held, the rw_mutex is taken inside this function. - */ -static int semctl_down(struct ipc_namespace *ns, int semid, - int cmd, int version, union semun arg) +static int semctl_down(struct ipc_namespace *ns, int semid, int semnum, + int cmd, int version, union semun arg) { struct sem_array *sma; int err; - struct semid64_ds semid64; + struct sem_setbuf uninitialized_var(setbuf); struct kern_ipc_perm *ipcp; if(cmd == IPC_SET) { - if (copy_semid_from_user(&semid64, arg.buf, version)) + if(copy_semid_from_user (&setbuf, arg.buf, version)) return -EFAULT; } + sma = sem_lock_check_down(ns, semid); + if (IS_ERR(sma)) + return PTR_ERR(sma); - ipcp = ipcctl_pre_down(&sem_ids(ns), semid, cmd, &semid64.sem_perm, 0); - if (IS_ERR(ipcp)) - return PTR_ERR(ipcp); + ipcp = &sma->sem_perm; - sma = container_of(ipcp, struct sem_array, sem_perm); + err = audit_ipc_obj(ipcp); + if (err) + goto out_unlock; + + if (cmd == IPC_SET) { + err = audit_ipc_set_perm(0, setbuf.uid, setbuf.gid, setbuf.mode); + if (err) + goto out_unlock; + } + if (current->euid != ipcp->cuid && + current->euid != ipcp->uid && !capable(CAP_SYS_ADMIN)) { + err=-EPERM; + goto out_unlock; + } err = security_sem_semctl(sma, cmd); if (err) @@ -877,19 +910,26 @@ static int semctl_down(struct ipc_namespace *ns, int semid, switch(cmd){ case IPC_RMID: freeary(ns, ipcp); - goto out_up; + err = 0; + break; case IPC_SET: - ipc_update_perm(&semid64.sem_perm, ipcp); + ipcp->uid = setbuf.uid; + ipcp->gid = setbuf.gid; + ipcp->mode = (ipcp->mode & ~S_IRWXUGO) + | (setbuf.mode & S_IRWXUGO); sma->sem_ctime = get_seconds(); + sem_unlock(sma); + err = 0; break; default: + sem_unlock(sma); err = -EINVAL; + break; } + return err; out_unlock: sem_unlock(sma); -out_up: - up_write(&sem_ids(ns).rw_mutex); return err; } @@ -923,7 +963,9 @@ asmlinkage long sys_semctl (int semid, int semnum, int cmd, union semun arg) return err; case IPC_RMID: case IPC_SET: - err = semctl_down(ns, semid, cmd, version, arg); + down_write(&sem_ids(ns).rw_mutex); + err = semctl_down(ns,semid,semnum,cmd,version,arg); + up_write(&sem_ids(ns).rw_mutex); return err; default: return -EINVAL; @@ -1002,11 +1044,14 @@ static struct sem_undo *find_undo(struct ipc_namespace *ns, int semid) return ERR_PTR(PTR_ERR(sma)); nsems = sma->sem_nsems; - sem_getref_and_unlock(sma); + ipc_rcu_getref(sma); + sem_unlock(sma); new = kzalloc(sizeof(struct sem_undo) + sizeof(short)*nsems, GFP_KERNEL); if (!new) { - sem_putref(sma); + ipc_lock_by_ptr(&sma->sem_perm); + ipc_rcu_putref(sma); + sem_unlock(sma); return ERR_PTR(-ENOMEM); } new->semadj = (short *) &new[1]; @@ -1017,10 +1062,13 @@ static struct sem_undo *find_undo(struct ipc_namespace *ns, int semid) if (un) { spin_unlock(&ulp->lock); kfree(new); - sem_putref(sma); + ipc_lock_by_ptr(&sma->sem_perm); + ipc_rcu_putref(sma); + sem_unlock(sma); goto out; } - sem_lock_and_putref(sma); + ipc_lock_by_ptr(&sma->sem_perm); + ipc_rcu_putref(sma); if (sma->sem_perm.deleted) { sem_unlock(sma); spin_unlock(&ulp->lock); @@ -1250,7 +1298,6 @@ void exit_sem(struct task_struct *tsk) undo_list = tsk->sysvsem.undo_list; if (!undo_list) return; - tsk->sysvsem.undo_list = NULL; if (!atomic_dec_and_test(&undo_list->refcnt)) return; diff --git a/trunk/ipc/shm.c b/trunk/ipc/shm.c index 554429ade079..e636910454a9 100644 --- a/trunk/ipc/shm.c +++ b/trunk/ipc/shm.c @@ -60,6 +60,7 @@ static struct vm_operations_struct shm_vm_ops; #define shm_unlock(shp) \ ipc_unlock(&(shp)->shm_perm) +#define shm_buildid(id, seq) ipc_buildid(id, seq) static int newseg(struct ipc_namespace *, struct ipc_params *); static void shm_open(struct vm_area_struct *vma); @@ -126,6 +127,18 @@ static inline struct shmid_kernel *shm_lock_down(struct ipc_namespace *ns, return container_of(ipcp, struct shmid_kernel, shm_perm); } +static inline struct shmid_kernel *shm_lock_check_down( + struct ipc_namespace *ns, + int id) +{ + struct kern_ipc_perm *ipcp = ipc_lock_check_down(&shm_ids(ns), id); + + if (IS_ERR(ipcp)) + return (struct shmid_kernel *)ipcp; + + return container_of(ipcp, struct shmid_kernel, shm_perm); +} + /* * shm_lock_(check_) routines are called in the paths where the rw_mutex * is not held. @@ -156,6 +169,12 @@ static inline void shm_rmid(struct ipc_namespace *ns, struct shmid_kernel *s) ipc_rmid(&shm_ids(ns), &s->shm_perm); } +static inline int shm_addid(struct ipc_namespace *ns, struct shmid_kernel *shp) +{ + return ipc_addid(&shm_ids(ns), &shp->shm_perm, ns->shm_ctlmni); +} + + /* This is called by fork, once for every shm attach. */ static void shm_open(struct vm_area_struct *vma) @@ -397,7 +416,7 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params) if (IS_ERR(file)) goto no_file; - id = ipc_addid(&shm_ids(ns), &shp->shm_perm, ns->shm_ctlmni); + id = shm_addid(ns, shp); if (id < 0) { error = id; goto no_id; @@ -409,6 +428,7 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params) shp->shm_ctim = get_seconds(); shp->shm_segsz = size; shp->shm_nattch = 0; + shp->shm_perm.id = shm_buildid(id, shp->shm_perm.seq); shp->shm_file = file; /* * shmid gets reported as "inode#" in /proc/pid/maps. @@ -499,14 +519,28 @@ static inline unsigned long copy_shmid_to_user(void __user *buf, struct shmid64_ } } -static inline unsigned long -copy_shmid_from_user(struct shmid64_ds *out, void __user *buf, int version) +struct shm_setbuf { + uid_t uid; + gid_t gid; + mode_t mode; +}; + +static inline unsigned long copy_shmid_from_user(struct shm_setbuf *out, void __user *buf, int version) { switch(version) { case IPC_64: - if (copy_from_user(out, buf, sizeof(*out))) + { + struct shmid64_ds tbuf; + + if (copy_from_user(&tbuf, buf, sizeof(tbuf))) return -EFAULT; + + out->uid = tbuf.shm_perm.uid; + out->gid = tbuf.shm_perm.gid; + out->mode = tbuf.shm_perm.mode; + return 0; + } case IPC_OLD: { struct shmid_ds tbuf_old; @@ -514,9 +548,9 @@ copy_shmid_from_user(struct shmid64_ds *out, void __user *buf, int version) if (copy_from_user(&tbuf_old, buf, sizeof(tbuf_old))) return -EFAULT; - out->shm_perm.uid = tbuf_old.shm_perm.uid; - out->shm_perm.gid = tbuf_old.shm_perm.gid; - out->shm_perm.mode = tbuf_old.shm_perm.mode; + out->uid = tbuf_old.shm_perm.uid; + out->gid = tbuf_old.shm_perm.gid; + out->mode = tbuf_old.shm_perm.mode; return 0; } @@ -590,53 +624,9 @@ static void shm_get_stat(struct ipc_namespace *ns, unsigned long *rss, } } -/* - * This function handles some shmctl commands which require the rw_mutex - * to be held in write mode. - * NOTE: no locks must be held, the rw_mutex is taken inside this function. - */ -static int shmctl_down(struct ipc_namespace *ns, int shmid, int cmd, - struct shmid_ds __user *buf, int version) -{ - struct kern_ipc_perm *ipcp; - struct shmid64_ds shmid64; - struct shmid_kernel *shp; - int err; - - if (cmd == IPC_SET) { - if (copy_shmid_from_user(&shmid64, buf, version)) - return -EFAULT; - } - - ipcp = ipcctl_pre_down(&shm_ids(ns), shmid, cmd, &shmid64.shm_perm, 0); - if (IS_ERR(ipcp)) - return PTR_ERR(ipcp); - - shp = container_of(ipcp, struct shmid_kernel, shm_perm); - - err = security_shm_shmctl(shp, cmd); - if (err) - goto out_unlock; - switch (cmd) { - case IPC_RMID: - do_shm_rmid(ns, ipcp); - goto out_up; - case IPC_SET: - ipc_update_perm(&shmid64.shm_perm, ipcp); - shp->shm_ctim = get_seconds(); - break; - default: - err = -EINVAL; - } -out_unlock: - shm_unlock(shp); -out_up: - up_write(&shm_ids(ns).rw_mutex); - return err; -} - -asmlinkage long sys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf) +asmlinkage long sys_shmctl (int shmid, int cmd, struct shmid_ds __user *buf) { + struct shm_setbuf setbuf; struct shmid_kernel *shp; int err, version; struct ipc_namespace *ns; @@ -793,13 +783,97 @@ asmlinkage long sys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf) goto out; } case IPC_RMID: + { + /* + * We cannot simply remove the file. The SVID states + * that the block remains until the last person + * detaches from it, then is deleted. A shmat() on + * an RMID segment is legal in older Linux and if + * we change it apps break... + * + * Instead we set a destroyed flag, and then blow + * the name away when the usage hits zero. + */ + down_write(&shm_ids(ns).rw_mutex); + shp = shm_lock_check_down(ns, shmid); + if (IS_ERR(shp)) { + err = PTR_ERR(shp); + goto out_up; + } + + err = audit_ipc_obj(&(shp->shm_perm)); + if (err) + goto out_unlock_up; + + if (current->euid != shp->shm_perm.uid && + current->euid != shp->shm_perm.cuid && + !capable(CAP_SYS_ADMIN)) { + err=-EPERM; + goto out_unlock_up; + } + + err = security_shm_shmctl(shp, cmd); + if (err) + goto out_unlock_up; + + do_shm_rmid(ns, &shp->shm_perm); + up_write(&shm_ids(ns).rw_mutex); + goto out; + } + case IPC_SET: - err = shmctl_down(ns, shmid, cmd, buf, version); - return err; + { + if (!buf) { + err = -EFAULT; + goto out; + } + + if (copy_shmid_from_user (&setbuf, buf, version)) { + err = -EFAULT; + goto out; + } + down_write(&shm_ids(ns).rw_mutex); + shp = shm_lock_check_down(ns, shmid); + if (IS_ERR(shp)) { + err = PTR_ERR(shp); + goto out_up; + } + err = audit_ipc_obj(&(shp->shm_perm)); + if (err) + goto out_unlock_up; + err = audit_ipc_set_perm(0, setbuf.uid, setbuf.gid, setbuf.mode); + if (err) + goto out_unlock_up; + err=-EPERM; + if (current->euid != shp->shm_perm.uid && + current->euid != shp->shm_perm.cuid && + !capable(CAP_SYS_ADMIN)) { + goto out_unlock_up; + } + + err = security_shm_shmctl(shp, cmd); + if (err) + goto out_unlock_up; + + shp->shm_perm.uid = setbuf.uid; + shp->shm_perm.gid = setbuf.gid; + shp->shm_perm.mode = (shp->shm_perm.mode & ~S_IRWXUGO) + | (setbuf.mode & S_IRWXUGO); + shp->shm_ctim = get_seconds(); + break; + } + default: - return -EINVAL; + err = -EINVAL; + goto out; } + err = 0; +out_unlock_up: + shm_unlock(shp); +out_up: + up_write(&shm_ids(ns).rw_mutex); + goto out; out_unlock: shm_unlock(shp); out: diff --git a/trunk/ipc/util.c b/trunk/ipc/util.c index 3339177b336c..fd1b50da9db8 100644 --- a/trunk/ipc/util.c +++ b/trunk/ipc/util.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include @@ -53,57 +52,11 @@ struct ipc_namespace init_ipc_ns = { }, }; -atomic_t nr_ipc_ns = ATOMIC_INIT(1); - - -#ifdef CONFIG_MEMORY_HOTPLUG - -static void ipc_memory_notifier(struct work_struct *work) -{ - ipcns_notify(IPCNS_MEMCHANGED); -} - -static DECLARE_WORK(ipc_memory_wq, ipc_memory_notifier); - - -static int ipc_memory_callback(struct notifier_block *self, - unsigned long action, void *arg) -{ - switch (action) { - case MEM_ONLINE: /* memory successfully brought online */ - case MEM_OFFLINE: /* or offline: it's time to recompute msgmni */ - /* - * This is done by invoking the ipcns notifier chain with the - * IPC_MEMCHANGED event. - * In order not to keep the lock on the hotplug memory chain - * for too long, queue a work item that will, when waken up, - * activate the ipcns notification chain. - * No need to keep several ipc work items on the queue. - */ - if (!work_pending(&ipc_memory_wq)) - schedule_work(&ipc_memory_wq); - break; - case MEM_GOING_ONLINE: - case MEM_GOING_OFFLINE: - case MEM_CANCEL_ONLINE: - case MEM_CANCEL_OFFLINE: - default: - break; - } - - return NOTIFY_OK; -} - -#endif /* CONFIG_MEMORY_HOTPLUG */ - /** * ipc_init - initialise IPC subsystem * * The various system5 IPC resources (semaphores, messages and shared * memory) are initialised - * A callback routine is registered into the memory hotplug notifier - * chain: since msgmni scales to lowmem this callback routine will be - * called upon successful memory add / remove to recompute msmgni. */ static int __init ipc_init(void) @@ -111,8 +64,6 @@ static int __init ipc_init(void) sem_init(); msg_init(); shm_init(); - hotplug_memory_notifier(ipc_memory_callback, IPC_CALLBACK_PRI); - register_ipcns_notifier(&init_ipc_ns); return 0; } __initcall(ipc_init); @@ -133,8 +84,8 @@ void ipc_init_ids(struct ipc_ids *ids) ids->seq = 0; { int seq_limit = INT_MAX/SEQ_MULTIPLIER; - if (seq_limit > USHORT_MAX) - ids->seq_max = USHORT_MAX; + if(seq_limit > USHRT_MAX) + ids->seq_max = USHRT_MAX; else ids->seq_max = seq_limit; } @@ -165,12 +116,13 @@ void __init ipc_init_proc_interface(const char *path, const char *header, iface->ids = ids; iface->show = show; - pde = proc_create_data(path, - S_IRUGO, /* world readable */ - NULL, /* parent dir */ - &sysvipc_proc_fops, - iface); - if (!pde) { + pde = create_proc_entry(path, + S_IRUGO, /* world readable */ + NULL /* parent dir */); + if (pde) { + pde->data = iface; + pde->proc_fops = &sysvipc_proc_fops; + } else { kfree(iface); } } @@ -279,7 +231,6 @@ int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size) if(ids->seq > ids->seq_max) ids->seq = 0; - new->id = ipc_buildid(id, new->seq); spin_lock_init(&new->lock); new->deleted = 0; rcu_read_lock(); @@ -810,70 +761,6 @@ int ipcget(struct ipc_namespace *ns, struct ipc_ids *ids, return ipcget_public(ns, ids, ops, params); } -/** - * ipc_update_perm - update the permissions of an IPC. - * @in: the permission given as input. - * @out: the permission of the ipc to set. - */ -void ipc_update_perm(struct ipc64_perm *in, struct kern_ipc_perm *out) -{ - out->uid = in->uid; - out->gid = in->gid; - out->mode = (out->mode & ~S_IRWXUGO) - | (in->mode & S_IRWXUGO); -} - -/** - * ipcctl_pre_down - retrieve an ipc and check permissions for some IPC_XXX cmd - * @ids: the table of ids where to look for the ipc - * @id: the id of the ipc to retrieve - * @cmd: the cmd to check - * @perm: the permission to set - * @extra_perm: one extra permission parameter used by msq - * - * This function does some common audit and permissions check for some IPC_XXX - * cmd and is called from semctl_down, shmctl_down and msgctl_down. - * It must be called without any lock held and - * - retrieves the ipc with the given id in the given table. - * - performs some audit and permission check, depending on the given cmd - * - returns the ipc with both ipc and rw_mutex locks held in case of success - * or an err-code without any lock held otherwise. - */ -struct kern_ipc_perm *ipcctl_pre_down(struct ipc_ids *ids, int id, int cmd, - struct ipc64_perm *perm, int extra_perm) -{ - struct kern_ipc_perm *ipcp; - int err; - - down_write(&ids->rw_mutex); - ipcp = ipc_lock_check_down(ids, id); - if (IS_ERR(ipcp)) { - err = PTR_ERR(ipcp); - goto out_up; - } - - err = audit_ipc_obj(ipcp); - if (err) - goto out_unlock; - - if (cmd == IPC_SET) { - err = audit_ipc_set_perm(extra_perm, perm->uid, - perm->gid, perm->mode); - if (err) - goto out_unlock; - } - if (current->euid == ipcp->cuid || - current->euid == ipcp->uid || capable(CAP_SYS_ADMIN)) - return ipcp; - - err = -EPERM; -out_unlock: - ipc_unlock(ipcp); -out_up: - up_write(&ids->rw_mutex); - return ERR_PTR(err); -} - #ifdef __ARCH_WANT_IPC_PARSE_VERSION diff --git a/trunk/ipc/util.h b/trunk/ipc/util.h index cdb966aebe07..f37d160c98fe 100644 --- a/trunk/ipc/util.h +++ b/trunk/ipc/util.h @@ -12,6 +12,7 @@ #include +#define USHRT_MAX 0xffff #define SEQ_MULTIPLIER (IPCMNI) void sem_init (void); @@ -111,9 +112,6 @@ struct kern_ipc_perm *ipc_lock(struct ipc_ids *, int); void kernel_to_ipc64_perm(struct kern_ipc_perm *in, struct ipc64_perm *out); void ipc64_perm_to_ipc_perm(struct ipc64_perm *in, struct ipc_perm *out); -void ipc_update_perm(struct ipc64_perm *in, struct kern_ipc_perm *out); -struct kern_ipc_perm *ipcctl_pre_down(struct ipc_ids *ids, int id, int cmd, - struct ipc64_perm *perm, int extra_perm); #if defined(__ia64__) || defined(__x86_64__) || defined(__hppa__) || defined(__XTENSA__) /* On IA-64, we always use the "64-bit version" of the IPC structures. */ @@ -126,8 +124,6 @@ extern void free_msg(struct msg_msg *msg); extern struct msg_msg *load_msg(const void __user *src, int len); extern int store_msg(void __user *dest, struct msg_msg *msg, int len); -extern void recompute_msgmni(struct ipc_namespace *); - static inline int ipc_buildid(int id, int seq) { return SEQ_MULTIPLIER * seq + id; diff --git a/trunk/kernel/Makefile b/trunk/kernel/Makefile index 188c43223f52..6c5f081132a4 100644 --- a/trunk/kernel/Makefile +++ b/trunk/kernel/Makefile @@ -11,7 +11,7 @@ obj-y = sched.o fork.o exec_domain.o panic.o printk.o profile.o \ hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \ notifier.o ksysfs.o pm_qos_params.o -obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o +obj-$(CONFIG_SYSCTL) += sysctl_check.o obj-$(CONFIG_STACKTRACE) += stacktrace.o obj-y += time/ obj-$(CONFIG_DEBUG_MUTEXES) += mutex-debug.o diff --git a/trunk/kernel/audit.c b/trunk/kernel/audit.c index b7d3709cc452..a7b16086d36f 100644 --- a/trunk/kernel/audit.c +++ b/trunk/kernel/audit.c @@ -126,8 +126,6 @@ static int audit_freelist_count; static LIST_HEAD(audit_freelist); static struct sk_buff_head audit_skb_queue; -/* queue of skbs to send to auditd when/if it comes back */ -static struct sk_buff_head audit_skb_hold_queue; static struct task_struct *kauditd_task; static DECLARE_WAIT_QUEUE_HEAD(kauditd_wait); static DECLARE_WAIT_QUEUE_HEAD(audit_backlog_wait); @@ -156,11 +154,6 @@ struct audit_buffer { gfp_t gfp_mask; }; -struct audit_reply { - int pid; - struct sk_buff *skb; -}; - static void audit_set_pid(struct audit_buffer *ab, pid_t pid) { if (ab) { @@ -259,15 +252,14 @@ void audit_log_lost(const char *message) } static int audit_log_config_change(char *function_name, int new, int old, - uid_t loginuid, u32 sessionid, u32 sid, - int allow_changes) + uid_t loginuid, u32 sid, int allow_changes) { struct audit_buffer *ab; int rc = 0; ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE); - audit_log_format(ab, "%s=%d old=%d auid=%u ses=%u", function_name, new, - old, loginuid, sessionid); + audit_log_format(ab, "%s=%d old=%d by auid=%u", function_name, new, + old, loginuid); if (sid) { char *ctx = NULL; u32 len; @@ -287,8 +279,7 @@ static int audit_log_config_change(char *function_name, int new, int old, } static int audit_do_config_change(char *function_name, int *to_change, - int new, uid_t loginuid, u32 sessionid, - u32 sid) + int new, uid_t loginuid, u32 sid) { int allow_changes, rc = 0, old = *to_change; @@ -299,8 +290,8 @@ static int audit_do_config_change(char *function_name, int *to_change, allow_changes = 1; if (audit_enabled != AUDIT_OFF) { - rc = audit_log_config_change(function_name, new, old, loginuid, - sessionid, sid, allow_changes); + rc = audit_log_config_change(function_name, new, old, + loginuid, sid, allow_changes); if (rc) allow_changes = 0; } @@ -314,28 +305,26 @@ static int audit_do_config_change(char *function_name, int *to_change, return rc; } -static int audit_set_rate_limit(int limit, uid_t loginuid, u32 sessionid, - u32 sid) +static int audit_set_rate_limit(int limit, uid_t loginuid, u32 sid) { return audit_do_config_change("audit_rate_limit", &audit_rate_limit, - limit, loginuid, sessionid, sid); + limit, loginuid, sid); } -static int audit_set_backlog_limit(int limit, uid_t loginuid, u32 sessionid, - u32 sid) +static int audit_set_backlog_limit(int limit, uid_t loginuid, u32 sid) { return audit_do_config_change("audit_backlog_limit", &audit_backlog_limit, - limit, loginuid, sessionid, sid); + limit, loginuid, sid); } -static int audit_set_enabled(int state, uid_t loginuid, u32 sessionid, u32 sid) +static int audit_set_enabled(int state, uid_t loginuid, u32 sid) { int rc; if (state < AUDIT_OFF || state > AUDIT_LOCKED) return -EINVAL; rc = audit_do_config_change("audit_enabled", &audit_enabled, state, - loginuid, sessionid, sid); + loginuid, sid); if (!rc) audit_ever_enabled |= !!state; @@ -343,7 +332,7 @@ static int audit_set_enabled(int state, uid_t loginuid, u32 sessionid, u32 sid) return rc; } -static int audit_set_failure(int state, uid_t loginuid, u32 sessionid, u32 sid) +static int audit_set_failure(int state, uid_t loginuid, u32 sid) { if (state != AUDIT_FAIL_SILENT && state != AUDIT_FAIL_PRINTK @@ -351,43 +340,7 @@ static int audit_set_failure(int state, uid_t loginuid, u32 sessionid, u32 sid) return -EINVAL; return audit_do_config_change("audit_failure", &audit_failure, state, - loginuid, sessionid, sid); -} - -/* - * Queue skbs to be sent to auditd when/if it comes back. These skbs should - * already have been sent via prink/syslog and so if these messages are dropped - * it is not a huge concern since we already passed the audit_log_lost() - * notification and stuff. This is just nice to get audit messages during - * boot before auditd is running or messages generated while auditd is stopped. - * This only holds messages is audit_default is set, aka booting with audit=1 - * or building your kernel that way. - */ -static void audit_hold_skb(struct sk_buff *skb) -{ - if (audit_default && - skb_queue_len(&audit_skb_hold_queue) < audit_backlog_limit) - skb_queue_tail(&audit_skb_hold_queue, skb); - else - kfree_skb(skb); -} - -static void kauditd_send_skb(struct sk_buff *skb) -{ - int err; - /* take a reference in case we can't send it and we want to hold it */ - skb_get(skb); - err = netlink_unicast(audit_sock, skb, audit_nlk_pid, 0); - if (err < 0) { - BUG_ON(err != -ECONNREFUSED); /* Shoudn't happen */ - printk(KERN_ERR "audit: *NO* daemon at audit_pid=%d\n", audit_pid); - audit_log_lost("auditd dissapeared\n"); - audit_pid = 0; - /* we might get lucky and get this in the next auditd */ - audit_hold_skb(skb); - } else - /* drop the extra reference if sent ok */ - kfree_skb(skb); + loginuid, sid); } static int kauditd_thread(void *dummy) @@ -396,41 +349,24 @@ static int kauditd_thread(void *dummy) set_freezable(); while (!kthread_should_stop()) { - /* - * if auditd just started drain the queue of messages already - * sent to syslog/printk. remember loss here is ok. we already - * called audit_log_lost() if it didn't go out normally. so the - * race between the skb_dequeue and the next check for audit_pid - * doesn't matter. - * - * if you ever find kauditd to be too slow we can get a perf win - * by doing our own locking and keeping better track if there - * are messages in this queue. I don't see the need now, but - * in 5 years when I want to play with this again I'll see this - * note and still have no friggin idea what i'm thinking today. - */ - if (audit_default && audit_pid) { - skb = skb_dequeue(&audit_skb_hold_queue); - if (unlikely(skb)) { - while (skb && audit_pid) { - kauditd_send_skb(skb); - skb = skb_dequeue(&audit_skb_hold_queue); - } - } - } - skb = skb_dequeue(&audit_skb_queue); wake_up(&audit_backlog_wait); if (skb) { - if (audit_pid) - kauditd_send_skb(skb); - else { + if (audit_pid) { + int err = netlink_unicast(audit_sock, skb, audit_nlk_pid, 0); + if (err < 0) { + BUG_ON(err != -ECONNREFUSED); /* Shoudn't happen */ + printk(KERN_ERR "audit: *NO* daemon at audit_pid=%d\n", audit_pid); + audit_log_lost("auditd dissapeared\n"); + audit_pid = 0; + } + } else { if (printk_ratelimit()) - printk(KERN_NOTICE "%s\n", skb->data + NLMSG_SPACE(0)); + printk(KERN_NOTICE "%s\n", skb->data + + NLMSG_SPACE(0)); else audit_log_lost("printk limit exceeded\n"); - - audit_hold_skb(skb); + kfree_skb(skb); } } else { DECLARE_WAITQUEUE(wait, current); @@ -449,13 +385,13 @@ static int kauditd_thread(void *dummy) return 0; } -static int audit_prepare_user_tty(pid_t pid, uid_t loginuid, u32 sessionid) +static int audit_prepare_user_tty(pid_t pid, uid_t loginuid) { struct task_struct *tsk; int err; read_lock(&tasklist_lock); - tsk = find_task_by_vpid(pid); + tsk = find_task_by_pid(pid); err = -ESRCH; if (!tsk) goto out; @@ -468,7 +404,7 @@ static int audit_prepare_user_tty(pid_t pid, uid_t loginuid, u32 sessionid) if (err) goto out; - tty_audit_push_task(tsk, loginuid, sessionid); + tty_audit_push_task(tsk, loginuid); out: read_unlock(&tasklist_lock); return err; @@ -533,19 +469,6 @@ struct sk_buff *audit_make_reply(int pid, int seq, int type, int done, return NULL; } -static int audit_send_reply_thread(void *arg) -{ - struct audit_reply *reply = (struct audit_reply *)arg; - - mutex_lock(&audit_cmd_mutex); - mutex_unlock(&audit_cmd_mutex); - - /* Ignore failure. It'll only happen if the sender goes away, - because our timeout is set to infinite. */ - netlink_unicast(audit_sock, reply->skb, reply->pid, 0); - kfree(reply); - return 0; -} /** * audit_send_reply - send an audit reply message via netlink * @pid: process id to send reply to @@ -562,26 +485,14 @@ static int audit_send_reply_thread(void *arg) void audit_send_reply(int pid, int seq, int type, int done, int multi, void *payload, int size) { - struct sk_buff *skb; - struct task_struct *tsk; - struct audit_reply *reply = kmalloc(sizeof(struct audit_reply), - GFP_KERNEL); - - if (!reply) - return; - + struct sk_buff *skb; skb = audit_make_reply(pid, seq, type, done, multi, payload, size); if (!skb) return; - - reply->pid = pid; - reply->skb = skb; - - tsk = kthread_run(audit_send_reply_thread, reply, "audit_send_reply"); - if (IS_ERR(tsk)) { - kfree(reply); - kfree_skb(skb); - } + /* Ignore failure. It'll only happen if the sender goes away, + because our timeout is set to infinite. */ + netlink_unicast(audit_sock, skb, pid, 0); + return; } /* @@ -623,8 +534,7 @@ static int audit_netlink_ok(struct sk_buff *skb, u16 msg_type) } static int audit_log_common_recv_msg(struct audit_buffer **ab, u16 msg_type, - u32 pid, u32 uid, uid_t auid, u32 ses, - u32 sid) + u32 pid, u32 uid, uid_t auid, u32 sid) { int rc = 0; char *ctx = NULL; @@ -636,8 +546,8 @@ static int audit_log_common_recv_msg(struct audit_buffer **ab, u16 msg_type, } *ab = audit_log_start(NULL, GFP_KERNEL, msg_type); - audit_log_format(*ab, "user pid=%d uid=%u auid=%u ses=%u", - pid, uid, auid, ses); + audit_log_format(*ab, "user pid=%d uid=%u auid=%u", + pid, uid, auid); if (sid) { rc = security_secid_to_secctx(sid, &ctx, &len); if (rc) @@ -660,7 +570,6 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) struct audit_buffer *ab; u16 msg_type = nlh->nlmsg_type; uid_t loginuid; /* loginuid of sender */ - u32 sessionid; struct audit_sig_info *sig_data; char *ctx = NULL; u32 len; @@ -682,7 +591,6 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) pid = NETLINK_CREDS(skb)->pid; uid = NETLINK_CREDS(skb)->uid; loginuid = NETLINK_CB(skb).loginuid; - sessionid = NETLINK_CB(skb).sessionid; sid = NETLINK_CB(skb).sid; seq = nlh->nlmsg_seq; data = NLMSG_DATA(nlh); @@ -705,12 +613,12 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) status_get = (struct audit_status *)data; if (status_get->mask & AUDIT_STATUS_ENABLED) { err = audit_set_enabled(status_get->enabled, - loginuid, sessionid, sid); + loginuid, sid); if (err < 0) return err; } if (status_get->mask & AUDIT_STATUS_FAILURE) { err = audit_set_failure(status_get->failure, - loginuid, sessionid, sid); + loginuid, sid); if (err < 0) return err; } if (status_get->mask & AUDIT_STATUS_PID) { @@ -719,17 +627,17 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) if (audit_enabled != AUDIT_OFF) audit_log_config_change("audit_pid", new_pid, audit_pid, loginuid, - sessionid, sid, 1); + sid, 1); audit_pid = new_pid; audit_nlk_pid = NETLINK_CB(skb).pid; } if (status_get->mask & AUDIT_STATUS_RATE_LIMIT) err = audit_set_rate_limit(status_get->rate_limit, - loginuid, sessionid, sid); + loginuid, sid); if (status_get->mask & AUDIT_STATUS_BACKLOG_LIMIT) err = audit_set_backlog_limit(status_get->backlog_limit, - loginuid, sessionid, sid); + loginuid, sid); break; case AUDIT_USER: case AUDIT_FIRST_USER_MSG ... AUDIT_LAST_USER_MSG: @@ -741,13 +649,12 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) if (err == 1) { err = 0; if (msg_type == AUDIT_USER_TTY) { - err = audit_prepare_user_tty(pid, loginuid, - sessionid); + err = audit_prepare_user_tty(pid, loginuid); if (err) break; } audit_log_common_recv_msg(&ab, msg_type, pid, uid, - loginuid, sessionid, sid); + loginuid, sid); if (msg_type != AUDIT_USER_TTY) audit_log_format(ab, " msg='%.1024s'", @@ -757,7 +664,8 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) audit_log_format(ab, " msg="); size = nlmsg_len(nlh); - audit_log_n_untrustedstring(ab, data, size); + audit_log_n_untrustedstring(ab, size, + data); } audit_set_pid(ab, pid); audit_log_end(ab); @@ -769,7 +677,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) return -EINVAL; if (audit_enabled == AUDIT_LOCKED) { audit_log_common_recv_msg(&ab, AUDIT_CONFIG_CHANGE, pid, - uid, loginuid, sessionid, sid); + uid, loginuid, sid); audit_log_format(ab, " audit_enabled=%d res=0", audit_enabled); @@ -780,7 +688,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) case AUDIT_LIST: err = audit_receive_filter(nlh->nlmsg_type, NETLINK_CB(skb).pid, uid, seq, data, nlmsg_len(nlh), - loginuid, sessionid, sid); + loginuid, sid); break; case AUDIT_ADD_RULE: case AUDIT_DEL_RULE: @@ -788,7 +696,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) return -EINVAL; if (audit_enabled == AUDIT_LOCKED) { audit_log_common_recv_msg(&ab, AUDIT_CONFIG_CHANGE, pid, - uid, loginuid, sessionid, sid); + uid, loginuid, sid); audit_log_format(ab, " audit_enabled=%d res=0", audit_enabled); @@ -799,13 +707,13 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) case AUDIT_LIST_RULES: err = audit_receive_filter(nlh->nlmsg_type, NETLINK_CB(skb).pid, uid, seq, data, nlmsg_len(nlh), - loginuid, sessionid, sid); + loginuid, sid); break; case AUDIT_TRIM: audit_trim_trees(); audit_log_common_recv_msg(&ab, AUDIT_CONFIG_CHANGE, pid, - uid, loginuid, sessionid, sid); + uid, loginuid, sid); audit_log_format(ab, " op=trim res=1"); audit_log_end(ab); @@ -813,21 +721,21 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) case AUDIT_MAKE_EQUIV: { void *bufp = data; u32 sizes[2]; - size_t msglen = nlmsg_len(nlh); + size_t len = nlmsg_len(nlh); char *old, *new; err = -EINVAL; - if (msglen < 2 * sizeof(u32)) + if (len < 2 * sizeof(u32)) break; memcpy(sizes, bufp, 2 * sizeof(u32)); bufp += 2 * sizeof(u32); - msglen -= 2 * sizeof(u32); - old = audit_unpack_string(&bufp, &msglen, sizes[0]); + len -= 2 * sizeof(u32); + old = audit_unpack_string(&bufp, &len, sizes[0]); if (IS_ERR(old)) { err = PTR_ERR(old); break; } - new = audit_unpack_string(&bufp, &msglen, sizes[1]); + new = audit_unpack_string(&bufp, &len, sizes[1]); if (IS_ERR(new)) { err = PTR_ERR(new); kfree(old); @@ -837,7 +745,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) err = audit_tag_tree(old, new); audit_log_common_recv_msg(&ab, AUDIT_CONFIG_CHANGE, pid, - uid, loginuid, sessionid, sid); + uid, loginuid, sid); audit_log_format(ab, " op=make_equiv old="); audit_log_untrustedstring(ab, old); @@ -871,7 +779,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) struct task_struct *tsk; read_lock(&tasklist_lock); - tsk = find_task_by_vpid(pid); + tsk = find_task_by_pid(pid); if (!tsk) err = -ESRCH; else { @@ -894,7 +802,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) if (s->enabled != 0 && s->enabled != 1) return -EINVAL; read_lock(&tasklist_lock); - tsk = find_task_by_vpid(pid); + tsk = find_task_by_pid(pid); if (!tsk) err = -ESRCH; else { @@ -969,7 +877,6 @@ static int __init audit_init(void) audit_sock->sk_sndtimeo = MAX_SCHEDULE_TIMEOUT; skb_queue_head_init(&audit_skb_queue); - skb_queue_head_init(&audit_skb_hold_queue); audit_initialized = 1; audit_enabled = audit_default; audit_ever_enabled |= !!audit_default; @@ -1292,7 +1199,7 @@ void audit_log_format(struct audit_buffer *ab, const char *fmt, ...) * This function will take the passed buf and convert it into a string of * ascii hex digits. The new string is placed onto the skb. */ -void audit_log_n_hex(struct audit_buffer *ab, const unsigned char *buf, +void audit_log_hex(struct audit_buffer *ab, const unsigned char *buf, size_t len) { int i, avail, new_len; @@ -1328,8 +1235,8 @@ void audit_log_n_hex(struct audit_buffer *ab, const unsigned char *buf, * Format a string of no more than slen characters into the audit buffer, * enclosed in quote marks. */ -void audit_log_n_string(struct audit_buffer *ab, const char *string, - size_t slen) +static void audit_log_n_string(struct audit_buffer *ab, size_t slen, + const char *string) { int avail, new_len; unsigned char *ptr; @@ -1385,13 +1292,13 @@ int audit_string_contains_control(const char *string, size_t len) * The caller specifies the number of characters in the string to log, which may * or may not be the entire string. */ -void audit_log_n_untrustedstring(struct audit_buffer *ab, const char *string, - size_t len) +void audit_log_n_untrustedstring(struct audit_buffer *ab, size_t len, + const char *string) { if (audit_string_contains_control(string, len)) - audit_log_n_hex(ab, string, len); + audit_log_hex(ab, string, len); else - audit_log_n_string(ab, string, len); + audit_log_n_string(ab, len, string); } /** @@ -1404,7 +1311,7 @@ void audit_log_n_untrustedstring(struct audit_buffer *ab, const char *string, */ void audit_log_untrustedstring(struct audit_buffer *ab, const char *string) { - audit_log_n_untrustedstring(ab, string, strlen(string)); + audit_log_n_untrustedstring(ab, strlen(string), string); } /* This is a helper-function to print the escaped d_path */ @@ -1448,23 +1355,19 @@ void audit_log_end(struct audit_buffer *ab) audit_log_lost("rate limit exceeded"); } else { struct nlmsghdr *nlh = nlmsg_hdr(ab->skb); - nlh->nlmsg_len = ab->skb->len - NLMSG_SPACE(0); - if (audit_pid) { + nlh->nlmsg_len = ab->skb->len - NLMSG_SPACE(0); skb_queue_tail(&audit_skb_queue, ab->skb); + ab->skb = NULL; wake_up_interruptible(&kauditd_wait); - } else { - if (nlh->nlmsg_type != AUDIT_EOE) { - if (printk_ratelimit()) { - printk(KERN_NOTICE "type=%d %s\n", - nlh->nlmsg_type, - ab->skb->data + NLMSG_SPACE(0)); - } else - audit_log_lost("printk limit exceeded\n"); - } - audit_hold_skb(ab->skb); + } else if (nlh->nlmsg_type != AUDIT_EOE) { + if (printk_ratelimit()) { + printk(KERN_NOTICE "type=%d %s\n", + nlh->nlmsg_type, + ab->skb->data + NLMSG_SPACE(0)); + } else + audit_log_lost("printk limit exceeded\n"); } - ab->skb = NULL; } audit_buffer_free(ab); } diff --git a/trunk/kernel/audit.h b/trunk/kernel/audit.h index 9d6717412fec..3cfc54ee3e1f 100644 --- a/trunk/kernel/audit.h +++ b/trunk/kernel/audit.h @@ -74,11 +74,6 @@ struct audit_entry { struct audit_krule rule; }; -#ifdef CONFIG_AUDIT -extern int audit_enabled; -extern int audit_ever_enabled; -#endif - extern int audit_pid; #define AUDIT_INODE_BUCKETS 32 @@ -109,9 +104,6 @@ struct audit_netlink_list { int audit_send_list(void *); struct inotify_watch; -/* Inotify handle */ -extern struct inotify_handle *audit_ih; - extern void audit_free_parent(struct inotify_watch *); extern void audit_handle_ievent(struct inotify_watch *, u32, u32, u32, const char *, struct inode *); @@ -119,7 +111,6 @@ extern int selinux_audit_rule_update(void); extern struct mutex audit_filter_mutex; extern void audit_free_rule_rcu(struct rcu_head *); -extern struct list_head audit_filter_list[]; #ifdef CONFIG_AUDIT_TREE extern struct audit_chunk *audit_tree_lookup(const struct inode *); @@ -146,10 +137,6 @@ extern void audit_put_tree(struct audit_tree *); extern char *audit_unpack_string(void **, size_t *, size_t); -extern pid_t audit_sig_pid; -extern uid_t audit_sig_uid; -extern u32 audit_sig_sid; - #ifdef CONFIG_AUDITSYSCALL extern int __audit_signal_info(int sig, struct task_struct *t); static inline int audit_signal_info(int sig, struct task_struct *t) diff --git a/trunk/kernel/auditfilter.c b/trunk/kernel/auditfilter.c index 0e0bd27e6512..28fef6bf8534 100644 --- a/trunk/kernel/auditfilter.c +++ b/trunk/kernel/auditfilter.c @@ -89,9 +89,14 @@ struct list_head audit_filter_list[AUDIT_NR_FILTERS] = { DEFINE_MUTEX(audit_filter_mutex); +/* Inotify handle */ +extern struct inotify_handle *audit_ih; + /* Inotify events we care about. */ #define AUDIT_IN_WATCH IN_MOVE|IN_CREATE|IN_DELETE|IN_DELETE_SELF|IN_MOVE_SELF +extern int audit_enabled; + void audit_free_parent(struct inotify_watch *i_watch) { struct audit_parent *parent; @@ -267,7 +272,7 @@ static int audit_to_watch(struct audit_krule *krule, char *path, int len, return -EINVAL; watch = audit_init_watch(path); - if (IS_ERR(watch)) + if (unlikely(IS_ERR(watch))) return PTR_ERR(watch); audit_get_watch(watch); @@ -417,7 +422,7 @@ static inline struct audit_entry *audit_to_entry_common(struct audit_rule *rule) static struct audit_entry *audit_rule_to_entry(struct audit_rule *rule) { struct audit_entry *entry; - struct audit_field *ino_f; + struct audit_field *f; int err = 0; int i; @@ -478,10 +483,6 @@ static struct audit_entry *audit_rule_to_entry(struct audit_rule *rule) if (f->val & ~15) goto exit_free; break; - case AUDIT_FILETYPE: - if ((f->val & ~S_IFMT) > S_IFMT) - goto exit_free; - break; case AUDIT_INODE: err = audit_to_inode(&entry->rule, f); if (err) @@ -503,9 +504,9 @@ static struct audit_entry *audit_rule_to_entry(struct audit_rule *rule) } } - ino_f = entry->rule.inode_f; - if (ino_f) { - switch(ino_f->op) { + f = entry->rule.inode_f; + if (f) { + switch(f->op) { case AUDIT_NOT_EQUAL: entry->rule.inode_f = NULL; case AUDIT_EQUAL: @@ -530,7 +531,7 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data, { int err = 0; struct audit_entry *entry; - struct audit_field *ino_f; + struct audit_field *f; void *bufp; size_t remain = datasz - sizeof(struct audit_rule_data); int i; @@ -653,18 +654,14 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data, if (f->val & ~15) goto exit_free; break; - case AUDIT_FILETYPE: - if ((f->val & ~S_IFMT) > S_IFMT) - goto exit_free; - break; default: goto exit_free; } } - ino_f = entry->rule.inode_f; - if (ino_f) { - switch(ino_f->op) { + f = entry->rule.inode_f; + if (f) { + switch(f->op) { case AUDIT_NOT_EQUAL: entry->rule.inode_f = NULL; case AUDIT_EQUAL: @@ -851,7 +848,7 @@ static struct audit_watch *audit_dupe_watch(struct audit_watch *old) return ERR_PTR(-ENOMEM); new = audit_init_watch(path); - if (IS_ERR(new)) { + if (unlikely(IS_ERR(new))) { kfree(path); goto out; } @@ -992,7 +989,7 @@ static void audit_update_watch(struct audit_parent *parent, audit_set_auditable(current->audit_context); nwatch = audit_dupe_watch(owatch); - if (IS_ERR(nwatch)) { + if (unlikely(IS_ERR(nwatch))) { mutex_unlock(&audit_filter_mutex); audit_panic("error updating watch, skipping"); return; @@ -1007,7 +1004,7 @@ static void audit_update_watch(struct audit_parent *parent, list_del_rcu(&oentry->list); nentry = audit_dupe_rule(&oentry->rule, nwatch); - if (IS_ERR(nentry)) + if (unlikely(IS_ERR(nentry))) audit_panic("error updating watch, removing"); else { int h = audit_hash_ino((u32)ino); @@ -1503,9 +1500,8 @@ static void audit_list_rules(int pid, int seq, struct sk_buff_head *q) } /* Log rule additions and removals */ -static void audit_log_rule_change(uid_t loginuid, u32 sessionid, u32 sid, - char *action, struct audit_krule *rule, - int res) +static void audit_log_rule_change(uid_t loginuid, u32 sid, char *action, + struct audit_krule *rule, int res) { struct audit_buffer *ab; @@ -1515,7 +1511,7 @@ static void audit_log_rule_change(uid_t loginuid, u32 sessionid, u32 sid, ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE); if (!ab) return; - audit_log_format(ab, "auid=%u ses=%u", loginuid, sessionid); + audit_log_format(ab, "auid=%u", loginuid); if (sid) { char *ctx = NULL; u32 len; @@ -1547,7 +1543,7 @@ static void audit_log_rule_change(uid_t loginuid, u32 sessionid, u32 sid, * @sid: SE Linux Security ID of sender */ int audit_receive_filter(int type, int pid, int uid, int seq, void *data, - size_t datasz, uid_t loginuid, u32 sessionid, u32 sid) + size_t datasz, uid_t loginuid, u32 sid) { struct task_struct *tsk; struct audit_netlink_list *dest; @@ -1594,8 +1590,7 @@ int audit_receive_filter(int type, int pid, int uid, int seq, void *data, err = audit_add_rule(entry, &audit_filter_list[entry->rule.listnr]); - audit_log_rule_change(loginuid, sessionid, sid, "add", - &entry->rule, !err); + audit_log_rule_change(loginuid, sid, "add", &entry->rule, !err); if (err) audit_free_rule(entry); @@ -1611,8 +1606,8 @@ int audit_receive_filter(int type, int pid, int uid, int seq, void *data, err = audit_del_rule(entry, &audit_filter_list[entry->rule.listnr]); - audit_log_rule_change(loginuid, sessionid, sid, "remove", - &entry->rule, !err); + audit_log_rule_change(loginuid, sid, "remove", &entry->rule, + !err); audit_free_rule(entry); break; @@ -1790,7 +1785,7 @@ int audit_update_lsm_rules(void) watch = entry->rule.watch; tree = entry->rule.tree; nentry = audit_dupe_rule(&entry->rule, watch); - if (IS_ERR(nentry)) { + if (unlikely(IS_ERR(nentry))) { /* save the first error encountered for the * return value */ if (!err) diff --git a/trunk/kernel/auditsc.c b/trunk/kernel/auditsc.c index c10e7aae04d7..56e56ed594a8 100644 --- a/trunk/kernel/auditsc.c +++ b/trunk/kernel/auditsc.c @@ -68,6 +68,9 @@ #include "audit.h" +extern struct list_head audit_filter_list[]; +extern int audit_ever_enabled; + /* AUDIT_NAMES is the number of slots we reserve in the audit_context * for saving names from getname(). */ #define AUDIT_NAMES 20 @@ -280,19 +283,6 @@ static int audit_match_perm(struct audit_context *ctx, int mask) } } -static int audit_match_filetype(struct audit_context *ctx, int which) -{ - unsigned index = which & ~S_IFMT; - mode_t mode = which & S_IFMT; - if (index >= ctx->name_count) - return 0; - if (ctx->names[index].ino == -1) - return 0; - if ((ctx->names[index].mode ^ mode) & S_IFMT) - return 0; - return 1; -} - /* * We keep a linked list of fixed-sized (31 pointer) arrays of audit_chunk *; * ->first_trees points to its beginning, ->trees - to the current end of data. @@ -602,9 +592,6 @@ static int audit_filter_rules(struct task_struct *tsk, case AUDIT_PERM: result = audit_match_perm(ctx, f->val); break; - case AUDIT_FILETYPE: - result = audit_match_filetype(ctx, f->val); - break; } if (!result) @@ -1108,7 +1095,7 @@ static int audit_log_single_execve_arg(struct audit_context *context, audit_log_format(*ab, "[%d]", i); audit_log_format(*ab, "="); if (has_cntl) - audit_log_n_hex(*ab, buf, to_send); + audit_log_hex(*ab, buf, to_send); else audit_log_format(*ab, "\"%s\"", buf); audit_log_format(*ab, "\n"); @@ -1309,6 +1296,7 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts break; } case AUDIT_SOCKETCALL: { + int i; struct audit_aux_data_socketcall *axs = (void *)aux; audit_log_format(ab, "nargs=%d", axs->nargs); for (i=0; inargs; i++) @@ -1319,7 +1307,7 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts struct audit_aux_data_sockaddr *axs = (void *)aux; audit_log_format(ab, "saddr="); - audit_log_n_hex(ab, axs->a, axs->len); + audit_log_hex(ab, axs->a, axs->len); break; } case AUDIT_FD_PAIR: { @@ -1333,6 +1321,7 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts for (aux = context->aux_pids; aux; aux = aux->next) { struct audit_aux_data_pids *axs = (void *)aux; + int i; for (i = 0; i < axs->pid_count; i++) if (audit_log_pid_context(context, axs->target_pid[i], @@ -1382,8 +1371,8 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts default: /* log the name's directory component */ audit_log_format(ab, " name="); - audit_log_n_untrustedstring(ab, n->name, - n->name_len); + audit_log_n_untrustedstring(ab, n->name_len, + n->name); } } else audit_log_format(ab, " name=(null)"); @@ -1607,7 +1596,7 @@ static inline void handle_one(const struct inode *inode) if (likely(put_tree_ref(context, chunk))) return; if (unlikely(!grow_tree_refs(context))) { - printk(KERN_WARNING "out of memory, audit has lost a tree reference\n"); + printk(KERN_WARNING "out of memory, audit has lost a tree reference"); audit_set_auditable(context); audit_put_chunk(chunk); unroll_tree_refs(context, p, count); @@ -1667,7 +1656,7 @@ static void handle_path(const struct dentry *dentry) } /* too bad */ printk(KERN_WARNING - "out of memory, audit has lost a tree reference\n"); + "out of memory, audit has lost a tree reference"); unroll_tree_refs(context, p, count); audit_set_auditable(context); return; @@ -1763,13 +1752,13 @@ static int audit_inc_name_count(struct audit_context *context, if (context->name_count >= AUDIT_NAMES) { if (inode) printk(KERN_DEBUG "name_count maxed, losing inode data: " - "dev=%02x:%02x, inode=%lu\n", + "dev=%02x:%02x, inode=%lu", MAJOR(inode->i_sb->s_dev), MINOR(inode->i_sb->s_dev), inode->i_ino); else - printk(KERN_DEBUG "name_count maxed, losing inode data\n"); + printk(KERN_DEBUG "name_count maxed, losing inode data"); return 1; } context->name_count++; @@ -2372,6 +2361,9 @@ int __audit_signal_info(int sig, struct task_struct *t) struct audit_aux_data_pids *axp; struct task_struct *tsk = current; struct audit_context *ctx = tsk->audit_context; + extern pid_t audit_sig_pid; + extern uid_t audit_sig_uid; + extern u32 audit_sig_sid; if (audit_pid && t->tgid == audit_pid) { if (sig == SIGTERM || sig == SIGHUP || sig == SIGUSR1) { diff --git a/trunk/kernel/bounds.c b/trunk/kernel/bounds.c index 3c5301381837..c3c55544db2f 100644 --- a/trunk/kernel/bounds.c +++ b/trunk/kernel/bounds.c @@ -8,7 +8,11 @@ /* Include headers that define the enum constants of interest */ #include #include -#include + +#define DEFINE(sym, val) \ + asm volatile("\n->" #sym " %0 " #val : : "i" (val)) + +#define BLANK() asm volatile("\n->" : : ) void foo(void) { diff --git a/trunk/kernel/cgroup.c b/trunk/kernel/cgroup.c index b9d467d83fc1..6d8de051382b 100644 --- a/trunk/kernel/cgroup.c +++ b/trunk/kernel/cgroup.c @@ -44,7 +44,6 @@ #include #include #include -#include #include @@ -119,7 +118,17 @@ static int root_count; * be called. */ static int need_forkexit_callback; -static int need_mm_owner_callback __read_mostly; + +/* bits in struct cgroup flags field */ +enum { + /* Control Group is dead */ + CGRP_REMOVED, + /* Control Group has previously had a child cgroup or a task, + * but no longer (only if CGRP_NOTIFY_ON_RELEASE is set) */ + CGRP_RELEASABLE, + /* Control Group requires release notifications to userspace */ + CGRP_NOTIFY_ON_RELEASE, +}; /* convenient tests for these bits */ inline int cgroup_is_removed(const struct cgroup *cgrp) @@ -195,27 +204,6 @@ static struct cg_cgroup_link init_css_set_link; static DEFINE_RWLOCK(css_set_lock); static int css_set_count; -/* hash table for cgroup groups. This improves the performance to - * find an existing css_set */ -#define CSS_SET_HASH_BITS 7 -#define CSS_SET_TABLE_SIZE (1 << CSS_SET_HASH_BITS) -static struct hlist_head css_set_table[CSS_SET_TABLE_SIZE]; - -static struct hlist_head *css_set_hash(struct cgroup_subsys_state *css[]) -{ - int i; - int index; - unsigned long tmp = 0UL; - - for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) - tmp += (unsigned long)css[i]; - tmp = (tmp >> 16) ^ tmp; - - index = hash_long(tmp, CSS_SET_HASH_BITS); - - return &css_set_table[index]; -} - /* We don't maintain the lists running through each css_set to its * task until after the first call to cgroup_iter_start(). This * reduces the fork()/exit() overhead for people who have cgroups @@ -242,7 +230,7 @@ static int use_task_css_set_links; static void unlink_css_set(struct css_set *cg) { write_lock(&css_set_lock); - hlist_del(&cg->hlist); + list_del(&cg->list); css_set_count--; while (!list_empty(&cg->cg_links)) { struct cg_cgroup_link *link; @@ -307,7 +295,9 @@ static inline void put_css_set_taskexit(struct css_set *cg) /* * find_existing_css_set() is a helper for * find_css_set(), and checks to see whether an existing - * css_set is suitable. + * css_set is suitable. This currently walks a linked-list for + * simplicity; a later patch will use a hash table for better + * performance * * oldcg: the cgroup group that we're using before the cgroup * transition @@ -324,9 +314,7 @@ static struct css_set *find_existing_css_set( { int i; struct cgroupfs_root *root = cgrp->root; - struct hlist_head *hhead; - struct hlist_node *node; - struct css_set *cg; + struct list_head *l = &init_css_set.list; /* Built the set of subsystem state objects that we want to * see in the new css_set */ @@ -343,13 +331,18 @@ static struct css_set *find_existing_css_set( } } - hhead = css_set_hash(template); - hlist_for_each_entry(cg, node, hhead, hlist) { + /* Look through existing cgroup groups to find one to reuse */ + do { + struct css_set *cg = + list_entry(l, struct css_set, list); + if (!memcmp(template, cg->subsys, sizeof(cg->subsys))) { /* All subsystems matched */ return cg; } - } + /* Try the next cgroup group */ + l = l->next; + } while (l != &init_css_set.list); /* No existing cgroup group matched */ return NULL; @@ -411,8 +404,6 @@ static struct css_set *find_css_set( struct list_head tmp_cg_links; struct cg_cgroup_link *link; - struct hlist_head *hhead; - /* First see if we already have a cgroup group that matches * the desired set */ write_lock(&css_set_lock); @@ -437,7 +428,6 @@ static struct css_set *find_css_set( kref_init(&res->ref); INIT_LIST_HEAD(&res->cg_links); INIT_LIST_HEAD(&res->tasks); - INIT_HLIST_NODE(&res->hlist); /* Copy the set of subsystem state objects generated in * find_existing_css_set() */ @@ -477,12 +467,9 @@ static struct css_set *find_css_set( BUG_ON(!list_empty(&tmp_cg_links)); + /* Link this cgroup group into the list */ + list_add(&res->list, &init_css_set.list); css_set_count++; - - /* Add this cgroup group to the hash table */ - hhead = css_set_hash(res->subsys); - hlist_add_head(&res->hlist, hhead); - write_unlock(&css_set_lock); return res; @@ -961,7 +948,7 @@ static int cgroup_get_sb(struct file_system_type *fs_type, int ret = 0; struct super_block *sb; struct cgroupfs_root *root; - struct list_head tmp_cg_links; + struct list_head tmp_cg_links, *l; INIT_LIST_HEAD(&tmp_cg_links); /* First find the desired set of subsystems */ @@ -1003,7 +990,6 @@ static int cgroup_get_sb(struct file_system_type *fs_type, /* New superblock */ struct cgroup *cgrp = &root->top_cgroup; struct inode *inode; - int i; BUG_ON(sb->s_root != NULL); @@ -1048,25 +1034,22 @@ static int cgroup_get_sb(struct file_system_type *fs_type, /* Link the top cgroup in this hierarchy into all * the css_set objects */ write_lock(&css_set_lock); - for (i = 0; i < CSS_SET_TABLE_SIZE; i++) { - struct hlist_head *hhead = &css_set_table[i]; - struct hlist_node *node; + l = &init_css_set.list; + do { struct css_set *cg; - - hlist_for_each_entry(cg, node, hhead, hlist) { - struct cg_cgroup_link *link; - - BUG_ON(list_empty(&tmp_cg_links)); - link = list_entry(tmp_cg_links.next, - struct cg_cgroup_link, - cgrp_link_list); - list_del(&link->cgrp_link_list); - link->cg = cg; - list_add(&link->cgrp_link_list, - &root->top_cgroup.css_sets); - list_add(&link->cg_link_list, &cg->cg_links); - } - } + struct cg_cgroup_link *link; + cg = list_entry(l, struct css_set, list); + BUG_ON(list_empty(&tmp_cg_links)); + link = list_entry(tmp_cg_links.next, + struct cg_cgroup_link, + cgrp_link_list); + list_del(&link->cgrp_link_list); + link->cg = cg; + list_add(&link->cgrp_link_list, + &root->top_cgroup.css_sets); + list_add(&link->cg_link_list, &cg->cg_links); + l = l->next; + } while (l != &init_css_set.list); write_unlock(&css_set_lock); free_cg_links(&tmp_cg_links); @@ -1324,16 +1307,18 @@ enum cgroup_filetype { FILE_DIR, FILE_TASKLIST, FILE_NOTIFY_ON_RELEASE, + FILE_RELEASABLE, FILE_RELEASE_AGENT, }; -static ssize_t cgroup_write_X64(struct cgroup *cgrp, struct cftype *cft, - struct file *file, - const char __user *userbuf, - size_t nbytes, loff_t *unused_ppos) +static ssize_t cgroup_write_uint(struct cgroup *cgrp, struct cftype *cft, + struct file *file, + const char __user *userbuf, + size_t nbytes, loff_t *unused_ppos) { char buffer[64]; int retval = 0; + u64 val; char *end; if (!nbytes) @@ -1344,18 +1329,16 @@ static ssize_t cgroup_write_X64(struct cgroup *cgrp, struct cftype *cft, return -EFAULT; buffer[nbytes] = 0; /* nul-terminate */ - strstrip(buffer); - if (cft->write_u64) { - u64 val = simple_strtoull(buffer, &end, 0); - if (*end) - return -EINVAL; - retval = cft->write_u64(cgrp, cft, val); - } else { - s64 val = simple_strtoll(buffer, &end, 0); - if (*end) - return -EINVAL; - retval = cft->write_s64(cgrp, cft, val); - } + + /* strip newline if necessary */ + if (nbytes && (buffer[nbytes-1] == '\n')) + buffer[nbytes-1] = 0; + val = simple_strtoull(buffer, &end, 0); + if (*end) + return -EINVAL; + + /* Pass to subsystem */ + retval = cft->write_uint(cgrp, cft, val); if (!retval) retval = nbytes; return retval; @@ -1436,39 +1419,23 @@ static ssize_t cgroup_file_write(struct file *file, const char __user *buf, return -ENODEV; if (cft->write) return cft->write(cgrp, cft, file, buf, nbytes, ppos); - if (cft->write_u64 || cft->write_s64) - return cgroup_write_X64(cgrp, cft, file, buf, nbytes, ppos); - if (cft->trigger) { - int ret = cft->trigger(cgrp, (unsigned int)cft->private); - return ret ? ret : nbytes; - } + if (cft->write_uint) + return cgroup_write_uint(cgrp, cft, file, buf, nbytes, ppos); return -EINVAL; } -static ssize_t cgroup_read_u64(struct cgroup *cgrp, struct cftype *cft, - struct file *file, - char __user *buf, size_t nbytes, - loff_t *ppos) +static ssize_t cgroup_read_uint(struct cgroup *cgrp, struct cftype *cft, + struct file *file, + char __user *buf, size_t nbytes, + loff_t *ppos) { char tmp[64]; - u64 val = cft->read_u64(cgrp, cft); + u64 val = cft->read_uint(cgrp, cft); int len = sprintf(tmp, "%llu\n", (unsigned long long) val); return simple_read_from_buffer(buf, nbytes, ppos, tmp, len); } -static ssize_t cgroup_read_s64(struct cgroup *cgrp, struct cftype *cft, - struct file *file, - char __user *buf, size_t nbytes, - loff_t *ppos) -{ - char tmp[64]; - s64 val = cft->read_s64(cgrp, cft); - int len = sprintf(tmp, "%lld\n", (long long) val); - - return simple_read_from_buffer(buf, nbytes, ppos, tmp, len); -} - static ssize_t cgroup_common_file_read(struct cgroup *cgrp, struct cftype *cft, struct file *file, @@ -1523,56 +1490,11 @@ static ssize_t cgroup_file_read(struct file *file, char __user *buf, if (cft->read) return cft->read(cgrp, cft, file, buf, nbytes, ppos); - if (cft->read_u64) - return cgroup_read_u64(cgrp, cft, file, buf, nbytes, ppos); - if (cft->read_s64) - return cgroup_read_s64(cgrp, cft, file, buf, nbytes, ppos); + if (cft->read_uint) + return cgroup_read_uint(cgrp, cft, file, buf, nbytes, ppos); return -EINVAL; } -/* - * seqfile ops/methods for returning structured data. Currently just - * supports string->u64 maps, but can be extended in future. - */ - -struct cgroup_seqfile_state { - struct cftype *cft; - struct cgroup *cgroup; -}; - -static int cgroup_map_add(struct cgroup_map_cb *cb, const char *key, u64 value) -{ - struct seq_file *sf = cb->state; - return seq_printf(sf, "%s %llu\n", key, (unsigned long long)value); -} - -static int cgroup_seqfile_show(struct seq_file *m, void *arg) -{ - struct cgroup_seqfile_state *state = m->private; - struct cftype *cft = state->cft; - if (cft->read_map) { - struct cgroup_map_cb cb = { - .fill = cgroup_map_add, - .state = m, - }; - return cft->read_map(state->cgroup, cft, &cb); - } - return cft->read_seq_string(state->cgroup, cft, m); -} - -int cgroup_seqfile_release(struct inode *inode, struct file *file) -{ - struct seq_file *seq = file->private_data; - kfree(seq->private); - return single_release(inode, file); -} - -static struct file_operations cgroup_seqfile_operations = { - .read = seq_read, - .llseek = seq_lseek, - .release = cgroup_seqfile_release, -}; - static int cgroup_file_open(struct inode *inode, struct file *file) { int err; @@ -1585,18 +1507,7 @@ static int cgroup_file_open(struct inode *inode, struct file *file) cft = __d_cft(file->f_dentry); if (!cft) return -ENODEV; - if (cft->read_map || cft->read_seq_string) { - struct cgroup_seqfile_state *state = - kzalloc(sizeof(*state), GFP_USER); - if (!state) - return -ENOMEM; - state->cft = cft; - state->cgroup = __d_cgrp(file->f_dentry->d_parent); - file->f_op = &cgroup_seqfile_operations; - err = single_open(file, cgroup_seqfile_show, state); - if (err < 0) - kfree(state); - } else if (cft->open) + if (cft->open) err = cft->open(inode, file); else err = 0; @@ -1804,7 +1715,7 @@ static void cgroup_advance_iter(struct cgroup *cgrp, * The tasklist_lock is not held here, as do_each_thread() and * while_each_thread() are protected by RCU. */ -static void cgroup_enable_task_cg_lists(void) +void cgroup_enable_task_cg_lists(void) { struct task_struct *p, *g; write_lock(&css_set_lock); @@ -2002,14 +1913,14 @@ int cgroup_scan_tasks(struct cgroup_scanner *scan) if (heap->size) { for (i = 0; i < heap->size; i++) { - struct task_struct *q = heap->ptrs[i]; + struct task_struct *p = heap->ptrs[i]; if (i == 0) { - latest_time = q->start_time; - latest_task = q; + latest_time = p->start_time; + latest_task = p; } /* Process the task per the caller's callback */ - scan->process_task(q, scan); - put_task_struct(q); + scan->process_task(p, scan); + put_task_struct(p); } /* * If we had to process any tasks at all, scan again @@ -2227,6 +2138,11 @@ static u64 cgroup_read_notify_on_release(struct cgroup *cgrp, return notify_on_release(cgrp); } +static u64 cgroup_read_releasable(struct cgroup *cgrp, struct cftype *cft) +{ + return test_bit(CGRP_RELEASABLE, &cgrp->flags); +} + /* * for the common functions, 'private' gives the type of file */ @@ -2242,10 +2158,16 @@ static struct cftype files[] = { { .name = "notify_on_release", - .read_u64 = cgroup_read_notify_on_release, + .read_uint = cgroup_read_notify_on_release, .write = cgroup_common_file_write, .private = FILE_NOTIFY_ON_RELEASE, }, + + { + .name = "releasable", + .read_uint = cgroup_read_releasable, + .private = FILE_RELEASABLE, + } }; static struct cftype cft_release_agent = { @@ -2479,9 +2401,10 @@ static int cgroup_rmdir(struct inode *unused_dir, struct dentry *dentry) return 0; } -static void __init cgroup_init_subsys(struct cgroup_subsys *ss) +static void cgroup_init_subsys(struct cgroup_subsys *ss) { struct cgroup_subsys_state *css; + struct list_head *l; printk(KERN_INFO "Initializing cgroup subsys %s\n", ss->name); @@ -2492,19 +2415,34 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss) BUG_ON(IS_ERR(css)); init_cgroup_css(css, ss, dummytop); - /* Update the init_css_set to contain a subsys + /* Update all cgroup groups to contain a subsys * pointer to this state - since the subsystem is - * newly registered, all tasks and hence the - * init_css_set is in the subsystem's top cgroup. */ - init_css_set.subsys[ss->subsys_id] = dummytop->subsys[ss->subsys_id]; + * newly registered, all tasks and hence all cgroup + * groups are in the subsystem's top cgroup. */ + write_lock(&css_set_lock); + l = &init_css_set.list; + do { + struct css_set *cg = + list_entry(l, struct css_set, list); + cg->subsys[ss->subsys_id] = dummytop->subsys[ss->subsys_id]; + l = l->next; + } while (l != &init_css_set.list); + write_unlock(&css_set_lock); - need_forkexit_callback |= ss->fork || ss->exit; - need_mm_owner_callback |= !!ss->mm_owner_changed; + /* If this subsystem requested that it be notified with fork + * events, we should send it one now for every process in the + * system */ + if (ss->fork) { + struct task_struct *g, *p; + + read_lock(&tasklist_lock); + do_each_thread(g, p) { + ss->fork(ss, p); + } while_each_thread(g, p); + read_unlock(&tasklist_lock); + } - /* At system boot, before all subsystems have been - * registered, no tasks have been forked, so we don't - * need to invoke fork callbacks here. */ - BUG_ON(!list_empty(&init_task.tasks)); + need_forkexit_callback |= ss->fork || ss->exit; ss->active = 1; } @@ -2520,9 +2458,9 @@ int __init cgroup_init_early(void) int i; kref_init(&init_css_set.ref); kref_get(&init_css_set.ref); + INIT_LIST_HEAD(&init_css_set.list); INIT_LIST_HEAD(&init_css_set.cg_links); INIT_LIST_HEAD(&init_css_set.tasks); - INIT_HLIST_NODE(&init_css_set.hlist); css_set_count = 1; init_cgroup_root(&rootnode); list_add(&rootnode.root_list, &roots); @@ -2535,9 +2473,6 @@ int __init cgroup_init_early(void) list_add(&init_css_set_link.cg_link_list, &init_css_set.cg_links); - for (i = 0; i < CSS_SET_TABLE_SIZE; i++) - INIT_HLIST_HEAD(&css_set_table[i]); - for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) { struct cgroup_subsys *ss = subsys[i]; @@ -2567,7 +2502,7 @@ int __init cgroup_init(void) { int err; int i; - struct hlist_head *hhead; + struct proc_dir_entry *entry; err = bdi_init(&cgroup_backing_dev_info); if (err) @@ -2579,15 +2514,13 @@ int __init cgroup_init(void) cgroup_init_subsys(ss); } - /* Add init_css_set to the hash table */ - hhead = css_set_hash(init_css_set.subsys); - hlist_add_head(&init_css_set.hlist, hhead); - err = register_filesystem(&cgroup_fs_type); if (err < 0) goto out; - proc_create("cgroups", 0, NULL, &proc_cgroupstats_operations); + entry = create_proc_entry("cgroups", 0, NULL); + if (entry) + entry->proc_fops = &proc_cgroupstats_operations; out: if (err) @@ -2750,34 +2683,6 @@ void cgroup_fork_callbacks(struct task_struct *child) } } -#ifdef CONFIG_MM_OWNER -/** - * cgroup_mm_owner_callbacks - run callbacks when the mm->owner changes - * @p: the new owner - * - * Called on every change to mm->owner. mm_init_owner() does not - * invoke this routine, since it assigns the mm->owner the first time - * and does not change it. - */ -void cgroup_mm_owner_callbacks(struct task_struct *old, struct task_struct *new) -{ - struct cgroup *oldcgrp, *newcgrp; - - if (need_mm_owner_callback) { - int i; - for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) { - struct cgroup_subsys *ss = subsys[i]; - oldcgrp = task_cgroup(old, ss->subsys_id); - newcgrp = task_cgroup(new, ss->subsys_id); - if (oldcgrp == newcgrp) - continue; - if (ss->mm_owner_changed) - ss->mm_owner_changed(ss, oldcgrp, newcgrp); - } - } -} -#endif /* CONFIG_MM_OWNER */ - /** * cgroup_post_fork - called on a new task after adding it to the task list * @child: the task in question diff --git a/trunk/kernel/cgroup_debug.c b/trunk/kernel/cgroup_debug.c index c3dc3aba4c02..37301e877cb0 100644 --- a/trunk/kernel/cgroup_debug.c +++ b/trunk/kernel/cgroup_debug.c @@ -1,5 +1,5 @@ /* - * kernel/cgroup_debug.c - Example cgroup subsystem that + * kernel/ccontainer_debug.c - Example cgroup subsystem that * exposes debug info * * Copyright (C) Google Inc, 2007 @@ -62,35 +62,25 @@ static u64 current_css_set_refcount_read(struct cgroup *cont, return count; } -static u64 releasable_read(struct cgroup *cgrp, struct cftype *cft) -{ - return test_bit(CGRP_RELEASABLE, &cgrp->flags); -} - static struct cftype files[] = { { .name = "cgroup_refcount", - .read_u64 = cgroup_refcount_read, + .read_uint = cgroup_refcount_read, }, { .name = "taskcount", - .read_u64 = taskcount_read, + .read_uint = taskcount_read, }, { .name = "current_css_set", - .read_u64 = current_css_set_read, + .read_uint = current_css_set_read, }, { .name = "current_css_set_refcount", - .read_u64 = current_css_set_refcount_read, + .read_uint = current_css_set_refcount_read, }, - - { - .name = "releasable", - .read_u64 = releasable_read, - } }; static int debug_populate(struct cgroup_subsys *ss, struct cgroup *cont) diff --git a/trunk/kernel/configs.c b/trunk/kernel/configs.c index 4c345210ed8c..e84d3f9c6c7b 100644 --- a/trunk/kernel/configs.c +++ b/trunk/kernel/configs.c @@ -79,11 +79,12 @@ static int __init ikconfig_init(void) struct proc_dir_entry *entry; /* create the current config file */ - entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL, - &ikconfig_file_ops); + entry = create_proc_entry("config.gz", S_IFREG | S_IRUGO, + &proc_root); if (!entry) return -ENOMEM; + entry->proc_fops = &ikconfig_file_ops; entry->size = kernel_config_data_size; return 0; @@ -94,7 +95,7 @@ static int __init ikconfig_init(void) static void __exit ikconfig_cleanup(void) { - remove_proc_entry("config.gz", NULL); + remove_proc_entry("config.gz", &proc_root); } module_init(ikconfig_init); diff --git a/trunk/kernel/cpu.c b/trunk/kernel/cpu.c index a98f6ab16ecd..2011ad8d2697 100644 --- a/trunk/kernel/cpu.c +++ b/trunk/kernel/cpu.c @@ -33,13 +33,17 @@ static struct { * an ongoing cpu hotplug operation. */ int refcount; + wait_queue_head_t writer_queue; } cpu_hotplug; +#define writer_exists() (cpu_hotplug.active_writer != NULL) + void __init cpu_hotplug_init(void) { cpu_hotplug.active_writer = NULL; mutex_init(&cpu_hotplug.lock); cpu_hotplug.refcount = 0; + init_waitqueue_head(&cpu_hotplug.writer_queue); } #ifdef CONFIG_HOTPLUG_CPU @@ -61,8 +65,11 @@ void put_online_cpus(void) if (cpu_hotplug.active_writer == current) return; mutex_lock(&cpu_hotplug.lock); - if (!--cpu_hotplug.refcount && unlikely(cpu_hotplug.active_writer)) - wake_up_process(cpu_hotplug.active_writer); + cpu_hotplug.refcount--; + + if (unlikely(writer_exists()) && !cpu_hotplug.refcount) + wake_up(&cpu_hotplug.writer_queue); + mutex_unlock(&cpu_hotplug.lock); } @@ -91,8 +98,8 @@ void cpu_maps_update_done(void) * Note that during a cpu-hotplug operation, the new readers, if any, * will be blocked by the cpu_hotplug.lock * - * Since cpu_hotplug_begin() is always called after invoking - * cpu_maps_update_begin(), we can be sure that only one writer is active. + * Since cpu_maps_update_begin is always called after invoking + * cpu_maps_update_begin, we can be sure that only one writer is active. * * Note that theoretically, there is a possibility of a livelock: * - Refcount goes to zero, last reader wakes up the sleeping @@ -108,16 +115,19 @@ void cpu_maps_update_done(void) */ static void cpu_hotplug_begin(void) { - cpu_hotplug.active_writer = current; + DECLARE_WAITQUEUE(wait, current); - for (;;) { - mutex_lock(&cpu_hotplug.lock); - if (likely(!cpu_hotplug.refcount)) - break; - __set_current_state(TASK_UNINTERRUPTIBLE); + mutex_lock(&cpu_hotplug.lock); + + cpu_hotplug.active_writer = current; + add_wait_queue_exclusive(&cpu_hotplug.writer_queue, &wait); + while (cpu_hotplug.refcount) { + set_current_state(TASK_UNINTERRUPTIBLE); mutex_unlock(&cpu_hotplug.lock); schedule(); + mutex_lock(&cpu_hotplug.lock); } + remove_wait_queue_locked(&cpu_hotplug.writer_queue, &wait); } static void cpu_hotplug_done(void) @@ -126,7 +136,7 @@ static void cpu_hotplug_done(void) mutex_unlock(&cpu_hotplug.lock); } /* Need to know about CPUs going up/down? */ -int __ref register_cpu_notifier(struct notifier_block *nb) +int __cpuinit register_cpu_notifier(struct notifier_block *nb) { int ret; cpu_maps_update_begin(); @@ -139,7 +149,7 @@ int __ref register_cpu_notifier(struct notifier_block *nb) EXPORT_SYMBOL(register_cpu_notifier); -void __ref unregister_cpu_notifier(struct notifier_block *nb) +void unregister_cpu_notifier(struct notifier_block *nb) { cpu_maps_update_begin(); raw_notifier_chain_unregister(&cpu_chain, nb); @@ -170,7 +180,7 @@ struct take_cpu_down_param { }; /* Take this CPU down. */ -static int __ref take_cpu_down(void *_param) +static int take_cpu_down(void *_param) { struct take_cpu_down_param *param = _param; int err; @@ -189,7 +199,7 @@ static int __ref take_cpu_down(void *_param) } /* Requires cpu_add_remove_lock to be held */ -static int __ref _cpu_down(unsigned int cpu, int tasks_frozen) +static int _cpu_down(unsigned int cpu, int tasks_frozen) { int err, nr_calls = 0; struct task_struct *p; @@ -264,7 +274,7 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen) return err; } -int __ref cpu_down(unsigned int cpu) +int cpu_down(unsigned int cpu) { int err = 0; diff --git a/trunk/kernel/cpuset.c b/trunk/kernel/cpuset.c index 8da627d33804..48a976c52cf5 100644 --- a/trunk/kernel/cpuset.c +++ b/trunk/kernel/cpuset.c @@ -127,7 +127,6 @@ struct cpuset_hotplug_scanner { typedef enum { CS_CPU_EXCLUSIVE, CS_MEM_EXCLUSIVE, - CS_MEM_HARDWALL, CS_MEMORY_MIGRATE, CS_SCHED_LOAD_BALANCE, CS_SPREAD_PAGE, @@ -145,11 +144,6 @@ static inline int is_mem_exclusive(const struct cpuset *cs) return test_bit(CS_MEM_EXCLUSIVE, &cs->flags); } -static inline int is_mem_hardwall(const struct cpuset *cs) -{ - return test_bit(CS_MEM_HARDWALL, &cs->flags); -} - static inline int is_sched_load_balance(const struct cpuset *cs) { return test_bit(CS_SCHED_LOAD_BALANCE, &cs->flags); @@ -741,8 +735,7 @@ static inline int started_after(void *p1, void *p2) * Return nonzero if this tasks's cpus_allowed mask should be changed (in other * words, if its mask is not equal to its cpuset's mask). */ -static int cpuset_test_cpumask(struct task_struct *tsk, - struct cgroup_scanner *scan) +int cpuset_test_cpumask(struct task_struct *tsk, struct cgroup_scanner *scan) { return !cpus_equal(tsk->cpus_allowed, (cgroup_cs(scan->cg))->cpus_allowed); @@ -759,8 +752,7 @@ static int cpuset_test_cpumask(struct task_struct *tsk, * We don't need to re-check for the cgroup/cpuset membership, since we're * holding cgroup_lock() at this point. */ -static void cpuset_change_cpumask(struct task_struct *tsk, - struct cgroup_scanner *scan) +void cpuset_change_cpumask(struct task_struct *tsk, struct cgroup_scanner *scan) { set_cpus_allowed_ptr(tsk, &((cgroup_cs(scan->cg))->cpus_allowed)); } @@ -1031,6 +1023,19 @@ int current_cpuset_is_being_rebound(void) return task_cs(current) == cpuset_being_rebound; } +/* + * Call with cgroup_mutex held. + */ + +static int update_memory_pressure_enabled(struct cpuset *cs, char *buf) +{ + if (simple_strtoul(buf, NULL, 10) != 0) + cpuset_memory_pressure_enabled = 1; + else + cpuset_memory_pressure_enabled = 0; + return 0; +} + static int update_relax_domain_level(struct cpuset *cs, char *buf) { int val = simple_strtol(buf, NULL, 10); @@ -1048,20 +1053,25 @@ static int update_relax_domain_level(struct cpuset *cs, char *buf) /* * update_flag - read a 0 or a 1 in a file and update associated flag - * bit: the bit to update (see cpuset_flagbits_t) - * cs: the cpuset to update - * turning_on: whether the flag is being set or cleared + * bit: the bit to update (CS_CPU_EXCLUSIVE, CS_MEM_EXCLUSIVE, + * CS_SCHED_LOAD_BALANCE, + * CS_NOTIFY_ON_RELEASE, CS_MEMORY_MIGRATE, + * CS_SPREAD_PAGE, CS_SPREAD_SLAB) + * cs: the cpuset to update + * buf: the buffer where we read the 0 or 1 * * Call with cgroup_mutex held. */ -static int update_flag(cpuset_flagbits_t bit, struct cpuset *cs, - int turning_on) +static int update_flag(cpuset_flagbits_t bit, struct cpuset *cs, char *buf) { + int turning_on; struct cpuset trialcs; int err; int cpus_nonempty, balance_flag_changed; + turning_on = (simple_strtoul(buf, NULL, 10) != 0); + trialcs = *cs; if (turning_on) set_bit(bit, &trialcs.flags); @@ -1231,7 +1241,6 @@ typedef enum { FILE_MEMLIST, FILE_CPU_EXCLUSIVE, FILE_MEM_EXCLUSIVE, - FILE_MEM_HARDWALL, FILE_SCHED_LOAD_BALANCE, FILE_SCHED_RELAX_DOMAIN_LEVEL, FILE_MEMORY_PRESSURE_ENABLED, @@ -1280,71 +1289,46 @@ static ssize_t cpuset_common_file_write(struct cgroup *cont, case FILE_MEMLIST: retval = update_nodemask(cs, buffer); break; - case FILE_SCHED_RELAX_DOMAIN_LEVEL: - retval = update_relax_domain_level(cs, buffer); - break; - default: - retval = -EINVAL; - goto out2; - } - - if (retval == 0) - retval = nbytes; -out2: - cgroup_unlock(); -out1: - kfree(buffer); - return retval; -} - -static int cpuset_write_u64(struct cgroup *cgrp, struct cftype *cft, u64 val) -{ - int retval = 0; - struct cpuset *cs = cgroup_cs(cgrp); - cpuset_filetype_t type = cft->private; - - cgroup_lock(); - - if (cgroup_is_removed(cgrp)) { - cgroup_unlock(); - return -ENODEV; - } - - switch (type) { case FILE_CPU_EXCLUSIVE: - retval = update_flag(CS_CPU_EXCLUSIVE, cs, val); + retval = update_flag(CS_CPU_EXCLUSIVE, cs, buffer); break; case FILE_MEM_EXCLUSIVE: - retval = update_flag(CS_MEM_EXCLUSIVE, cs, val); - break; - case FILE_MEM_HARDWALL: - retval = update_flag(CS_MEM_HARDWALL, cs, val); + retval = update_flag(CS_MEM_EXCLUSIVE, cs, buffer); break; case FILE_SCHED_LOAD_BALANCE: - retval = update_flag(CS_SCHED_LOAD_BALANCE, cs, val); + retval = update_flag(CS_SCHED_LOAD_BALANCE, cs, buffer); + break; + case FILE_SCHED_RELAX_DOMAIN_LEVEL: + retval = update_relax_domain_level(cs, buffer); break; case FILE_MEMORY_MIGRATE: - retval = update_flag(CS_MEMORY_MIGRATE, cs, val); + retval = update_flag(CS_MEMORY_MIGRATE, cs, buffer); break; case FILE_MEMORY_PRESSURE_ENABLED: - cpuset_memory_pressure_enabled = !!val; + retval = update_memory_pressure_enabled(cs, buffer); break; case FILE_MEMORY_PRESSURE: retval = -EACCES; break; case FILE_SPREAD_PAGE: - retval = update_flag(CS_SPREAD_PAGE, cs, val); + retval = update_flag(CS_SPREAD_PAGE, cs, buffer); cs->mems_generation = cpuset_mems_generation++; break; case FILE_SPREAD_SLAB: - retval = update_flag(CS_SPREAD_SLAB, cs, val); + retval = update_flag(CS_SPREAD_SLAB, cs, buffer); cs->mems_generation = cpuset_mems_generation++; break; default: retval = -EINVAL; - break; + goto out2; } + + if (retval == 0) + retval = nbytes; +out2: cgroup_unlock(); +out1: + kfree(buffer); return retval; } @@ -1406,9 +1390,33 @@ static ssize_t cpuset_common_file_read(struct cgroup *cont, case FILE_MEMLIST: s += cpuset_sprintf_memlist(s, cs); break; + case FILE_CPU_EXCLUSIVE: + *s++ = is_cpu_exclusive(cs) ? '1' : '0'; + break; + case FILE_MEM_EXCLUSIVE: + *s++ = is_mem_exclusive(cs) ? '1' : '0'; + break; + case FILE_SCHED_LOAD_BALANCE: + *s++ = is_sched_load_balance(cs) ? '1' : '0'; + break; case FILE_SCHED_RELAX_DOMAIN_LEVEL: s += sprintf(s, "%d", cs->relax_domain_level); break; + case FILE_MEMORY_MIGRATE: + *s++ = is_memory_migrate(cs) ? '1' : '0'; + break; + case FILE_MEMORY_PRESSURE_ENABLED: + *s++ = cpuset_memory_pressure_enabled ? '1' : '0'; + break; + case FILE_MEMORY_PRESSURE: + s += sprintf(s, "%d", fmeter_getrate(&cs->fmeter)); + break; + case FILE_SPREAD_PAGE: + *s++ = is_spread_page(cs) ? '1' : '0'; + break; + case FILE_SPREAD_SLAB: + *s++ = is_spread_slab(cs) ? '1' : '0'; + break; default: retval = -EINVAL; goto out; @@ -1421,137 +1429,121 @@ static ssize_t cpuset_common_file_read(struct cgroup *cont, return retval; } -static u64 cpuset_read_u64(struct cgroup *cont, struct cftype *cft) -{ - struct cpuset *cs = cgroup_cs(cont); - cpuset_filetype_t type = cft->private; - switch (type) { - case FILE_CPU_EXCLUSIVE: - return is_cpu_exclusive(cs); - case FILE_MEM_EXCLUSIVE: - return is_mem_exclusive(cs); - case FILE_MEM_HARDWALL: - return is_mem_hardwall(cs); - case FILE_SCHED_LOAD_BALANCE: - return is_sched_load_balance(cs); - case FILE_MEMORY_MIGRATE: - return is_memory_migrate(cs); - case FILE_MEMORY_PRESSURE_ENABLED: - return cpuset_memory_pressure_enabled; - case FILE_MEMORY_PRESSURE: - return fmeter_getrate(&cs->fmeter); - case FILE_SPREAD_PAGE: - return is_spread_page(cs); - case FILE_SPREAD_SLAB: - return is_spread_slab(cs); - default: - BUG(); - } -} + + /* * for the common functions, 'private' gives the type of file */ -static struct cftype files[] = { - { - .name = "cpus", - .read = cpuset_common_file_read, - .write = cpuset_common_file_write, - .private = FILE_CPULIST, - }, - - { - .name = "mems", - .read = cpuset_common_file_read, - .write = cpuset_common_file_write, - .private = FILE_MEMLIST, - }, - - { - .name = "cpu_exclusive", - .read_u64 = cpuset_read_u64, - .write_u64 = cpuset_write_u64, - .private = FILE_CPU_EXCLUSIVE, - }, - - { - .name = "mem_exclusive", - .read_u64 = cpuset_read_u64, - .write_u64 = cpuset_write_u64, - .private = FILE_MEM_EXCLUSIVE, - }, - - { - .name = "mem_hardwall", - .read_u64 = cpuset_read_u64, - .write_u64 = cpuset_write_u64, - .private = FILE_MEM_HARDWALL, - }, - - { - .name = "sched_load_balance", - .read_u64 = cpuset_read_u64, - .write_u64 = cpuset_write_u64, - .private = FILE_SCHED_LOAD_BALANCE, - }, - - { - .name = "sched_relax_domain_level", - .read_u64 = cpuset_read_u64, - .write_u64 = cpuset_write_u64, - .private = FILE_SCHED_RELAX_DOMAIN_LEVEL, - }, - - { - .name = "memory_migrate", - .read_u64 = cpuset_read_u64, - .write_u64 = cpuset_write_u64, - .private = FILE_MEMORY_MIGRATE, - }, - - { - .name = "memory_pressure", - .read_u64 = cpuset_read_u64, - .write_u64 = cpuset_write_u64, - .private = FILE_MEMORY_PRESSURE, - }, - - { - .name = "memory_spread_page", - .read_u64 = cpuset_read_u64, - .write_u64 = cpuset_write_u64, - .private = FILE_SPREAD_PAGE, - }, - - { - .name = "memory_spread_slab", - .read_u64 = cpuset_read_u64, - .write_u64 = cpuset_write_u64, - .private = FILE_SPREAD_SLAB, - }, +static struct cftype cft_cpus = { + .name = "cpus", + .read = cpuset_common_file_read, + .write = cpuset_common_file_write, + .private = FILE_CPULIST, +}; + +static struct cftype cft_mems = { + .name = "mems", + .read = cpuset_common_file_read, + .write = cpuset_common_file_write, + .private = FILE_MEMLIST, +}; + +static struct cftype cft_cpu_exclusive = { + .name = "cpu_exclusive", + .read = cpuset_common_file_read, + .write = cpuset_common_file_write, + .private = FILE_CPU_EXCLUSIVE, +}; + +static struct cftype cft_mem_exclusive = { + .name = "mem_exclusive", + .read = cpuset_common_file_read, + .write = cpuset_common_file_write, + .private = FILE_MEM_EXCLUSIVE, +}; + +static struct cftype cft_sched_load_balance = { + .name = "sched_load_balance", + .read = cpuset_common_file_read, + .write = cpuset_common_file_write, + .private = FILE_SCHED_LOAD_BALANCE, +}; + +static struct cftype cft_sched_relax_domain_level = { + .name = "sched_relax_domain_level", + .read = cpuset_common_file_read, + .write = cpuset_common_file_write, + .private = FILE_SCHED_RELAX_DOMAIN_LEVEL, +}; + +static struct cftype cft_memory_migrate = { + .name = "memory_migrate", + .read = cpuset_common_file_read, + .write = cpuset_common_file_write, + .private = FILE_MEMORY_MIGRATE, }; static struct cftype cft_memory_pressure_enabled = { .name = "memory_pressure_enabled", - .read_u64 = cpuset_read_u64, - .write_u64 = cpuset_write_u64, + .read = cpuset_common_file_read, + .write = cpuset_common_file_write, .private = FILE_MEMORY_PRESSURE_ENABLED, }; +static struct cftype cft_memory_pressure = { + .name = "memory_pressure", + .read = cpuset_common_file_read, + .write = cpuset_common_file_write, + .private = FILE_MEMORY_PRESSURE, +}; + +static struct cftype cft_spread_page = { + .name = "memory_spread_page", + .read = cpuset_common_file_read, + .write = cpuset_common_file_write, + .private = FILE_SPREAD_PAGE, +}; + +static struct cftype cft_spread_slab = { + .name = "memory_spread_slab", + .read = cpuset_common_file_read, + .write = cpuset_common_file_write, + .private = FILE_SPREAD_SLAB, +}; + static int cpuset_populate(struct cgroup_subsys *ss, struct cgroup *cont) { int err; - err = cgroup_add_files(cont, ss, files, ARRAY_SIZE(files)); - if (err) + if ((err = cgroup_add_file(cont, ss, &cft_cpus)) < 0) + return err; + if ((err = cgroup_add_file(cont, ss, &cft_mems)) < 0) + return err; + if ((err = cgroup_add_file(cont, ss, &cft_cpu_exclusive)) < 0) + return err; + if ((err = cgroup_add_file(cont, ss, &cft_mem_exclusive)) < 0) + return err; + if ((err = cgroup_add_file(cont, ss, &cft_memory_migrate)) < 0) + return err; + if ((err = cgroup_add_file(cont, ss, &cft_sched_load_balance)) < 0) + return err; + if ((err = cgroup_add_file(cont, ss, + &cft_sched_relax_domain_level)) < 0) + return err; + if ((err = cgroup_add_file(cont, ss, &cft_memory_pressure)) < 0) + return err; + if ((err = cgroup_add_file(cont, ss, &cft_spread_page)) < 0) + return err; + if ((err = cgroup_add_file(cont, ss, &cft_spread_slab)) < 0) return err; /* memory_pressure_enabled is in root cpuset only */ - if (!cont->parent) + if (err == 0 && !cont->parent) err = cgroup_add_file(cont, ss, - &cft_memory_pressure_enabled); - return err; + &cft_memory_pressure_enabled); + return 0; } /* @@ -1651,7 +1643,7 @@ static void cpuset_destroy(struct cgroup_subsys *ss, struct cgroup *cont) cpuset_update_task_memory_state(); if (is_sched_load_balance(cs)) - update_flag(CS_SCHED_LOAD_BALANCE, cs, 0); + update_flag(CS_SCHED_LOAD_BALANCE, cs, "0"); number_of_cpusets--; kfree(cs); @@ -1716,8 +1708,7 @@ int __init cpuset_init(void) * Called by cgroup_scan_tasks() for each task in a cgroup. * Return nonzero to stop the walk through the tasks. */ -static void cpuset_do_move_task(struct task_struct *tsk, - struct cgroup_scanner *scan) +void cpuset_do_move_task(struct task_struct *tsk, struct cgroup_scanner *scan) { struct cpuset_hotplug_scanner *chsp; @@ -1979,14 +1970,14 @@ int cpuset_nodemask_valid_mems_allowed(nodemask_t *nodemask) } /* - * nearest_hardwall_ancestor() - Returns the nearest mem_exclusive or - * mem_hardwall ancestor to the specified cpuset. Call holding - * callback_mutex. If no ancestor is mem_exclusive or mem_hardwall - * (an unusual configuration), then returns the root cpuset. + * nearest_exclusive_ancestor() - Returns the nearest mem_exclusive + * ancestor to the specified cpuset. Call holding callback_mutex. + * If no ancestor is mem_exclusive (an unusual configuration), then + * returns the root cpuset. */ -static const struct cpuset *nearest_hardwall_ancestor(const struct cpuset *cs) +static const struct cpuset *nearest_exclusive_ancestor(const struct cpuset *cs) { - while (!(is_mem_exclusive(cs) || is_mem_hardwall(cs)) && cs->parent) + while (!is_mem_exclusive(cs) && cs->parent) cs = cs->parent; return cs; } @@ -2000,7 +1991,7 @@ static const struct cpuset *nearest_hardwall_ancestor(const struct cpuset *cs) * __GFP_THISNODE is set, yes, we can always allocate. If zone * z's node is in our tasks mems_allowed, yes. If it's not a * __GFP_HARDWALL request and this zone's nodes is in the nearest - * hardwalled cpuset ancestor to this tasks cpuset, yes. + * mem_exclusive cpuset ancestor to this tasks cpuset, yes. * If the task has been OOM killed and has access to memory reserves * as specified by the TIF_MEMDIE flag, yes. * Otherwise, no. @@ -2023,7 +2014,7 @@ static const struct cpuset *nearest_hardwall_ancestor(const struct cpuset *cs) * and do not allow allocations outside the current tasks cpuset * unless the task has been OOM killed as is marked TIF_MEMDIE. * GFP_KERNEL allocations are not so marked, so can escape to the - * nearest enclosing hardwalled ancestor cpuset. + * nearest enclosing mem_exclusive ancestor cpuset. * * Scanning up parent cpusets requires callback_mutex. The * __alloc_pages() routine only calls here with __GFP_HARDWALL bit @@ -2046,7 +2037,7 @@ static const struct cpuset *nearest_hardwall_ancestor(const struct cpuset *cs) * in_interrupt - any node ok (current task context irrelevant) * GFP_ATOMIC - any node ok * TIF_MEMDIE - any node ok - * GFP_KERNEL - any node in enclosing hardwalled cpuset ok + * GFP_KERNEL - any node in enclosing mem_exclusive cpuset ok * GFP_USER - only nodes in current tasks mems allowed ok. * * Rule: @@ -2083,7 +2074,7 @@ int __cpuset_zone_allowed_softwall(struct zone *z, gfp_t gfp_mask) mutex_lock(&callback_mutex); task_lock(current); - cs = nearest_hardwall_ancestor(task_cs(current)); + cs = nearest_exclusive_ancestor(task_cs(current)); task_unlock(current); allowed = node_isset(node, cs->mems_allowed); diff --git a/trunk/kernel/dma.c b/trunk/kernel/dma.c index d2c60a822790..6a82bb716dac 100644 --- a/trunk/kernel/dma.c +++ b/trunk/kernel/dma.c @@ -149,7 +149,12 @@ static const struct file_operations proc_dma_operations = { static int __init proc_dma_init(void) { - proc_create("dma", 0, NULL, &proc_dma_operations); + struct proc_dir_entry *e; + + e = create_proc_entry("dma", 0, NULL); + if (e) + e->proc_fops = &proc_dma_operations; + return 0; } diff --git a/trunk/kernel/exit.c b/trunk/kernel/exit.c index ae0f2c4e452b..2a9d98c641ac 100644 --- a/trunk/kernel/exit.c +++ b/trunk/kernel/exit.c @@ -557,88 +557,6 @@ void exit_fs(struct task_struct *tsk) EXPORT_SYMBOL_GPL(exit_fs); -#ifdef CONFIG_MM_OWNER -/* - * Task p is exiting and it owned mm, lets find a new owner for it - */ -static inline int -mm_need_new_owner(struct mm_struct *mm, struct task_struct *p) -{ - /* - * If there are other users of the mm and the owner (us) is exiting - * we need to find a new owner to take on the responsibility. - */ - if (!mm) - return 0; - if (atomic_read(&mm->mm_users) <= 1) - return 0; - if (mm->owner != p) - return 0; - return 1; -} - -void mm_update_next_owner(struct mm_struct *mm) -{ - struct task_struct *c, *g, *p = current; - -retry: - if (!mm_need_new_owner(mm, p)) - return; - - read_lock(&tasklist_lock); - /* - * Search in the children - */ - list_for_each_entry(c, &p->children, sibling) { - if (c->mm == mm) - goto assign_new_owner; - } - - /* - * Search in the siblings - */ - list_for_each_entry(c, &p->parent->children, sibling) { - if (c->mm == mm) - goto assign_new_owner; - } - - /* - * Search through everything else. We should not get - * here often - */ - do_each_thread(g, c) { - if (c->mm == mm) - goto assign_new_owner; - } while_each_thread(g, c); - - read_unlock(&tasklist_lock); - return; - -assign_new_owner: - BUG_ON(c == p); - get_task_struct(c); - /* - * The task_lock protects c->mm from changing. - * We always want mm->owner->mm == mm - */ - task_lock(c); - /* - * Delay read_unlock() till we have the task_lock() - * to ensure that c does not slip away underneath us - */ - read_unlock(&tasklist_lock); - if (c->mm != mm) { - task_unlock(c); - put_task_struct(c); - goto retry; - } - cgroup_mm_owner_callbacks(mm->owner, c); - mm->owner = c; - task_unlock(c); - put_task_struct(c); -} -#endif /* CONFIG_MM_OWNER */ - /* * Turn us into a lazy TLB process if we * aren't already.. @@ -678,7 +596,6 @@ static void exit_mm(struct task_struct * tsk) /* We don't want this task to be frozen prematurely */ clear_freeze_flag(tsk); task_unlock(tsk); - mm_update_next_owner(mm); mmput(mm); } diff --git a/trunk/kernel/fork.c b/trunk/kernel/fork.c index 068ffe007529..6067e429f281 100644 --- a/trunk/kernel/fork.c +++ b/trunk/kernel/fork.c @@ -381,13 +381,14 @@ static struct mm_struct * mm_init(struct mm_struct * mm, struct task_struct *p) mm->ioctx_list = NULL; mm->free_area_cache = TASK_UNMAPPED_BASE; mm->cached_hole_size = ~0UL; - mm_init_owner(mm, p); + mm_init_cgroup(mm, p); if (likely(!mm_alloc_pgd(mm))) { mm->def_flags = 0; return mm; } + mm_free_cgroup(mm); free_mm(mm); return NULL; } @@ -431,13 +432,13 @@ void mmput(struct mm_struct *mm) if (atomic_dec_and_test(&mm->mm_users)) { exit_aio(mm); exit_mmap(mm); - set_mm_exe_file(mm, NULL); if (!list_empty(&mm->mmlist)) { spin_lock(&mmlist_lock); list_del(&mm->mmlist); spin_unlock(&mmlist_lock); } put_swap_token(mm); + mm_free_cgroup(mm); mmdrop(mm); } } @@ -544,8 +545,6 @@ struct mm_struct *dup_mm(struct task_struct *tsk) if (init_new_context(tsk, mm)) goto fail_nocontext; - dup_mm_exe_file(oldmm, mm); - err = dup_mmap(mm, oldmm); if (err) goto free_pt; @@ -983,13 +982,6 @@ static void rt_mutex_init_task(struct task_struct *p) #endif } -#ifdef CONFIG_MM_OWNER -void mm_init_owner(struct mm_struct *mm, struct task_struct *p) -{ - mm->owner = p; -} -#endif /* CONFIG_MM_OWNER */ - /* * This creates a new process as a copy of the old one, * but does not actually start it yet. @@ -1671,6 +1663,18 @@ static int unshare_fd(unsigned long unshare_flags, struct files_struct **new_fdp return 0; } +/* + * Unsharing of semundo for tasks created with CLONE_SYSVSEM is not + * supported yet + */ +static int unshare_semundo(unsigned long unshare_flags, struct sem_undo_list **new_ulistp) +{ + if (unshare_flags & CLONE_SYSVSEM) + return -EINVAL; + + return 0; +} + /* * unshare allows a process to 'unshare' part of the process * context which was originally shared using clone. copy_* @@ -1686,8 +1690,8 @@ asmlinkage long sys_unshare(unsigned long unshare_flags) struct sighand_struct *new_sigh = NULL; struct mm_struct *mm, *new_mm = NULL, *active_mm = NULL; struct files_struct *fd, *new_fd = NULL; + struct sem_undo_list *new_ulist = NULL; struct nsproxy *new_nsproxy = NULL; - int do_sysvsem = 0; check_unshare_flags(&unshare_flags); @@ -1699,13 +1703,6 @@ asmlinkage long sys_unshare(unsigned long unshare_flags) CLONE_NEWNET)) goto bad_unshare_out; - /* - * CLONE_NEWIPC must also detach from the undolist: after switching - * to a new ipc namespace, the semaphore arrays from the old - * namespace are unreachable. - */ - if (unshare_flags & (CLONE_NEWIPC|CLONE_SYSVSEM)) - do_sysvsem = 1; if ((err = unshare_thread(unshare_flags))) goto bad_unshare_out; if ((err = unshare_fs(unshare_flags, &new_fs))) @@ -1716,17 +1713,13 @@ asmlinkage long sys_unshare(unsigned long unshare_flags) goto bad_unshare_cleanup_sigh; if ((err = unshare_fd(unshare_flags, &new_fd))) goto bad_unshare_cleanup_vm; + if ((err = unshare_semundo(unshare_flags, &new_ulist))) + goto bad_unshare_cleanup_fd; if ((err = unshare_nsproxy_namespaces(unshare_flags, &new_nsproxy, new_fs))) - goto bad_unshare_cleanup_fd; + goto bad_unshare_cleanup_semundo; - if (new_fs || new_mm || new_fd || do_sysvsem || new_nsproxy) { - if (do_sysvsem) { - /* - * CLONE_SYSVSEM is equivalent to sys_exit(). - */ - exit_sem(current); - } + if (new_fs || new_mm || new_fd || new_ulist || new_nsproxy) { if (new_nsproxy) { switch_task_namespaces(current, new_nsproxy); @@ -1762,6 +1755,7 @@ asmlinkage long sys_unshare(unsigned long unshare_flags) if (new_nsproxy) put_nsproxy(new_nsproxy); +bad_unshare_cleanup_semundo: bad_unshare_cleanup_fd: if (new_fd) put_files_struct(new_fd); diff --git a/trunk/kernel/irq/devres.c b/trunk/kernel/irq/devres.c index 38a25b8d8bff..6d9204f3a370 100644 --- a/trunk/kernel/irq/devres.c +++ b/trunk/kernel/irq/devres.c @@ -1,7 +1,6 @@ #include #include #include -#include /* * Device resource management aware IRQ request/free implementation. diff --git a/trunk/kernel/irq/manage.c b/trunk/kernel/irq/manage.c index 46e4ad1723f0..438a01464287 100644 --- a/trunk/kernel/irq/manage.c +++ b/trunk/kernel/irq/manage.c @@ -11,7 +11,6 @@ #include #include #include -#include #include "internals.h" diff --git a/trunk/kernel/kallsyms.c b/trunk/kernel/kallsyms.c index 6fc0040f3e3a..f091d13def00 100644 --- a/trunk/kernel/kallsyms.c +++ b/trunk/kernel/kallsyms.c @@ -472,7 +472,11 @@ static const struct file_operations kallsyms_operations = { static int __init kallsyms_init(void) { - proc_create("kallsyms", 0444, NULL, &kallsyms_operations); + struct proc_dir_entry *entry; + + entry = create_proc_entry("kallsyms", 0444, NULL); + if (entry) + entry->proc_fops = &kallsyms_operations; return 0; } __initcall(kallsyms_init); diff --git a/trunk/kernel/kthread.c b/trunk/kernel/kthread.c index ac72eea48339..92cf6930ab51 100644 --- a/trunk/kernel/kthread.c +++ b/trunk/kernel/kthread.c @@ -144,9 +144,9 @@ struct task_struct *kthread_create(int (*threadfn)(void *data), spin_lock(&kthread_create_lock); list_add_tail(&create.list, &kthread_create_list); + wake_up_process(kthreadd_task); spin_unlock(&kthread_create_lock); - wake_up_process(kthreadd_task); wait_for_completion(&create.done); if (!IS_ERR(create.result)) { diff --git a/trunk/kernel/latencytop.c b/trunk/kernel/latencytop.c index 5e7b45c56923..7c74dab0d21b 100644 --- a/trunk/kernel/latencytop.c +++ b/trunk/kernel/latencytop.c @@ -233,7 +233,14 @@ static struct file_operations lstats_fops = { static int __init init_lstats_procfs(void) { - proc_create("latency_stats", 0644, NULL, &lstats_fops); + struct proc_dir_entry *pe; + + pe = create_proc_entry("latency_stats", 0644, NULL); + if (!pe) + return -ENOMEM; + + pe->proc_fops = &lstats_fops; + return 0; } __initcall(init_lstats_procfs); diff --git a/trunk/kernel/lockdep_proc.c b/trunk/kernel/lockdep_proc.c index dc5d29648d85..8a135bd163c2 100644 --- a/trunk/kernel/lockdep_proc.c +++ b/trunk/kernel/lockdep_proc.c @@ -660,12 +660,20 @@ static const struct file_operations proc_lock_stat_operations = { static int __init lockdep_proc_init(void) { - proc_create("lockdep", S_IRUSR, NULL, &proc_lockdep_operations); - proc_create("lockdep_stats", S_IRUSR, NULL, - &proc_lockdep_stats_operations); + struct proc_dir_entry *entry; + + entry = create_proc_entry("lockdep", S_IRUSR, NULL); + if (entry) + entry->proc_fops = &proc_lockdep_operations; + + entry = create_proc_entry("lockdep_stats", S_IRUSR, NULL); + if (entry) + entry->proc_fops = &proc_lockdep_stats_operations; #ifdef CONFIG_LOCK_STAT - proc_create("lock_stat", S_IRUSR, NULL, &proc_lock_stat_operations); + entry = create_proc_entry("lock_stat", S_IRUSR, NULL); + if (entry) + entry->proc_fops = &proc_lock_stat_operations; #endif return 0; diff --git a/trunk/kernel/marker.c b/trunk/kernel/marker.c index 139260e5460c..005b95954593 100644 --- a/trunk/kernel/marker.c +++ b/trunk/kernel/marker.c @@ -23,7 +23,6 @@ #include #include #include -#include extern struct marker __start___markers[]; extern struct marker __stop___markers[]; diff --git a/trunk/kernel/notifier.c b/trunk/kernel/notifier.c index 823be11584ef..643360d1bb14 100644 --- a/trunk/kernel/notifier.c +++ b/trunk/kernel/notifier.c @@ -31,21 +31,6 @@ static int notifier_chain_register(struct notifier_block **nl, return 0; } -static int notifier_chain_cond_register(struct notifier_block **nl, - struct notifier_block *n) -{ - while ((*nl) != NULL) { - if ((*nl) == n) - return 0; - if (n->priority > (*nl)->priority) - break; - nl = &((*nl)->next); - } - n->next = *nl; - rcu_assign_pointer(*nl, n); - return 0; -} - static int notifier_chain_unregister(struct notifier_block **nl, struct notifier_block *n) { @@ -219,29 +204,6 @@ int blocking_notifier_chain_register(struct blocking_notifier_head *nh, } EXPORT_SYMBOL_GPL(blocking_notifier_chain_register); -/** - * blocking_notifier_chain_cond_register - Cond add notifier to a blocking notifier chain - * @nh: Pointer to head of the blocking notifier chain - * @n: New entry in notifier chain - * - * Adds a notifier to a blocking notifier chain, only if not already - * present in the chain. - * Must be called in process context. - * - * Currently always returns zero. - */ -int blocking_notifier_chain_cond_register(struct blocking_notifier_head *nh, - struct notifier_block *n) -{ - int ret; - - down_write(&nh->rwsem); - ret = notifier_chain_cond_register(&nh->head, n); - up_write(&nh->rwsem); - return ret; -} -EXPORT_SYMBOL_GPL(blocking_notifier_chain_cond_register); - /** * blocking_notifier_chain_unregister - Remove notifier from a blocking notifier chain * @nh: Pointer to head of the blocking notifier chain diff --git a/trunk/kernel/ns_cgroup.c b/trunk/kernel/ns_cgroup.c index 48d7ed6fc3a4..aead4d69f62b 100644 --- a/trunk/kernel/ns_cgroup.c +++ b/trunk/kernel/ns_cgroup.c @@ -7,8 +7,6 @@ #include #include #include -#include -#include struct ns_cgroup { struct cgroup_subsys_state css; diff --git a/trunk/kernel/nsproxy.c b/trunk/kernel/nsproxy.c index adc785146a1c..f5d332cf8c63 100644 --- a/trunk/kernel/nsproxy.c +++ b/trunk/kernel/nsproxy.c @@ -139,18 +139,6 @@ int copy_namespaces(unsigned long flags, struct task_struct *tsk) goto out; } - /* - * CLONE_NEWIPC must detach from the undolist: after switching - * to a new ipc namespace, the semaphore arrays from the old - * namespace are unreachable. In clone parlance, CLONE_SYSVSEM - * means share undolist with parent, so we must forbid using - * it along with CLONE_NEWIPC. - */ - if ((flags & CLONE_NEWIPC) && (flags & CLONE_SYSVSEM)) { - err = -EINVAL; - goto out; - } - new_ns = create_new_namespaces(flags, tsk, tsk->fs); if (IS_ERR(new_ns)) { err = PTR_ERR(new_ns); diff --git a/trunk/kernel/panic.c b/trunk/kernel/panic.c index 425567f45b9f..24af9f8bac99 100644 --- a/trunk/kernel/panic.c +++ b/trunk/kernel/panic.c @@ -153,8 +153,6 @@ EXPORT_SYMBOL(panic); * 'M' - System experienced a machine check exception. * 'B' - System has hit bad_page. * 'U' - Userspace-defined naughtiness. - * 'A' - ACPI table overridden. - * 'W' - Taint on warning. * * The string is overwritten by the next call to print_taint(). */ @@ -163,7 +161,7 @@ const char *print_tainted(void) { static char buf[20]; if (tainted) { - snprintf(buf, sizeof(buf), "Tainted: %c%c%c%c%c%c%c%c%c%c", + snprintf(buf, sizeof(buf), "Tainted: %c%c%c%c%c%c%c%c%c", tainted & TAINT_PROPRIETARY_MODULE ? 'P' : 'G', tainted & TAINT_FORCED_MODULE ? 'F' : ' ', tainted & TAINT_UNSAFE_SMP ? 'S' : ' ', @@ -172,8 +170,7 @@ const char *print_tainted(void) tainted & TAINT_BAD_PAGE ? 'B' : ' ', tainted & TAINT_USER ? 'U' : ' ', tainted & TAINT_DIE ? 'D' : ' ', - tainted & TAINT_OVERRIDDEN_ACPI_TABLE ? 'A' : ' ', - tainted & TAINT_WARN ? 'W' : ' '); + tainted & TAINT_OVERRIDDEN_ACPI_TABLE ? 'A' : ' '); } else snprintf(buf, sizeof(buf), "Not tainted"); @@ -315,7 +312,6 @@ void warn_on_slowpath(const char *file, int line) print_modules(); dump_stack(); print_oops_end_marker(); - add_taint(TAINT_WARN); } EXPORT_SYMBOL(warn_on_slowpath); #endif diff --git a/trunk/kernel/printk.c b/trunk/kernel/printk.c index d3f9c0f788bf..bdd4ea8c3f2b 100644 --- a/trunk/kernel/printk.c +++ b/trunk/kernel/printk.c @@ -1287,7 +1287,31 @@ void tty_write_message(struct tty_struct *tty, char *msg) */ int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst) { - return __ratelimit(ratelimit_jiffies, ratelimit_burst); + static DEFINE_SPINLOCK(ratelimit_lock); + static unsigned toks = 10 * 5 * HZ; + static unsigned long last_msg; + static int missed; + unsigned long flags; + unsigned long now = jiffies; + + spin_lock_irqsave(&ratelimit_lock, flags); + toks += now - last_msg; + last_msg = now; + if (toks > (ratelimit_burst * ratelimit_jiffies)) + toks = ratelimit_burst * ratelimit_jiffies; + if (toks >= ratelimit_jiffies) { + int lost = missed; + + missed = 0; + toks -= ratelimit_jiffies; + spin_unlock_irqrestore(&ratelimit_lock, flags); + if (lost) + printk(KERN_WARNING "printk: %d messages suppressed.\n", lost); + return 1; + } + missed++; + spin_unlock_irqrestore(&ratelimit_lock, flags); + return 0; } EXPORT_SYMBOL(__printk_ratelimit); diff --git a/trunk/kernel/profile.c b/trunk/kernel/profile.c index ae7ead82cbc9..606d7387265c 100644 --- a/trunk/kernel/profile.c +++ b/trunk/kernel/profile.c @@ -587,10 +587,10 @@ static int __init create_proc_profile(void) return 0; if (create_hash_tables()) return -1; - entry = proc_create("profile", S_IWUSR | S_IRUGO, - NULL, &proc_profile_operations); + entry = create_proc_entry("profile", S_IWUSR | S_IRUGO, NULL); if (!entry) return 0; + entry->proc_fops = &proc_profile_operations; entry->size = (1+prof_len) * sizeof(atomic_t); hotcpu_notifier(profile_cpu_callback, 0); return 0; diff --git a/trunk/kernel/rcutorture.c b/trunk/kernel/rcutorture.c index 33acc424667e..47894f919d4e 100644 --- a/trunk/kernel/rcutorture.c +++ b/trunk/kernel/rcutorture.c @@ -45,7 +45,6 @@ #include #include #include -#include MODULE_LICENSE("GPL"); MODULE_AUTHOR("Paul E. McKenney and " diff --git a/trunk/kernel/relay.c b/trunk/kernel/relay.c index 7de644cdec43..d6204a485818 100644 --- a/trunk/kernel/relay.c +++ b/trunk/kernel/relay.c @@ -65,35 +65,6 @@ static struct vm_operations_struct relay_file_mmap_ops = { .close = relay_file_mmap_close, }; -/* - * allocate an array of pointers of struct page - */ -static struct page **relay_alloc_page_array(unsigned int n_pages) -{ - struct page **array; - size_t pa_size = n_pages * sizeof(struct page *); - - if (pa_size > PAGE_SIZE) { - array = vmalloc(pa_size); - if (array) - memset(array, 0, pa_size); - } else { - array = kzalloc(pa_size, GFP_KERNEL); - } - return array; -} - -/* - * free an array of pointers of struct page - */ -static void relay_free_page_array(struct page **array) -{ - if (is_vmalloc_addr(array)) - vfree(array); - else - kfree(array); -} - /** * relay_mmap_buf: - mmap channel buffer to process address space * @buf: relay channel buffer @@ -138,7 +109,7 @@ static void *relay_alloc_buf(struct rchan_buf *buf, size_t *size) *size = PAGE_ALIGN(*size); n_pages = *size >> PAGE_SHIFT; - buf->page_array = relay_alloc_page_array(n_pages); + buf->page_array = kcalloc(n_pages, sizeof(struct page *), GFP_KERNEL); if (!buf->page_array) return NULL; @@ -159,7 +130,7 @@ static void *relay_alloc_buf(struct rchan_buf *buf, size_t *size) depopulate: for (j = 0; j < i; j++) __free_page(buf->page_array[j]); - relay_free_page_array(buf->page_array); + kfree(buf->page_array); return NULL; } @@ -218,7 +189,7 @@ static void relay_destroy_buf(struct rchan_buf *buf) vunmap(buf->start); for (i = 0; i < buf->page_count; i++) __free_page(buf->page_array[i]); - relay_free_page_array(buf->page_array); + kfree(buf->page_array); } chan->buf[buf->cpu] = NULL; kfree(buf->padding); @@ -1191,7 +1162,7 @@ static ssize_t relay_file_splice_read(struct file *in, ret = 0; spliced = 0; - while (len && !spliced) { + while (len) { ret = subbuf_splice_actor(in, ppos, pipe, len, flags, &nonpad_ret); if (ret < 0) break; diff --git a/trunk/kernel/res_counter.c b/trunk/kernel/res_counter.c index d3c61b4ebef2..efbfc0fc232f 100644 --- a/trunk/kernel/res_counter.c +++ b/trunk/kernel/res_counter.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include @@ -28,8 +27,6 @@ int res_counter_charge_locked(struct res_counter *counter, unsigned long val) } counter->usage += val; - if (counter->usage > counter->max_usage) - counter->max_usage = counter->usage; return 0; } @@ -68,8 +65,6 @@ res_counter_member(struct res_counter *counter, int member) switch (member) { case RES_USAGE: return &counter->usage; - case RES_MAX_USAGE: - return &counter->max_usage; case RES_LIMIT: return &counter->limit; case RES_FAILCNT: @@ -97,11 +92,6 @@ ssize_t res_counter_read(struct res_counter *counter, int member, pos, buf, s - buf); } -u64 res_counter_read_u64(struct res_counter *counter, int member) -{ - return *res_counter_member(counter, member); -} - ssize_t res_counter_write(struct res_counter *counter, int member, const char __user *userbuf, size_t nbytes, loff_t *pos, int (*write_strategy)(char *st_buf, unsigned long long *val)) diff --git a/trunk/kernel/resource.c b/trunk/kernel/resource.c index 74af2d7cb5a1..cee12cc47cab 100644 --- a/trunk/kernel/resource.c +++ b/trunk/kernel/resource.c @@ -131,8 +131,14 @@ static const struct file_operations proc_iomem_operations = { static int __init ioresources_init(void) { - proc_create("ioports", 0, NULL, &proc_ioports_operations); - proc_create("iomem", 0, NULL, &proc_iomem_operations); + struct proc_dir_entry *entry; + + entry = create_proc_entry("ioports", 0, NULL); + if (entry) + entry->proc_fops = &proc_ioports_operations; + entry = create_proc_entry("iomem", 0, NULL); + if (entry) + entry->proc_fops = &proc_iomem_operations; return 0; } __initcall(ioresources_init); diff --git a/trunk/kernel/sched.c b/trunk/kernel/sched.c index e2f7f5acc807..740fb409e5bb 100644 --- a/trunk/kernel/sched.c +++ b/trunk/kernel/sched.c @@ -9057,13 +9057,13 @@ cpu_cgroup_attach(struct cgroup_subsys *ss, struct cgroup *cgrp, } #ifdef CONFIG_FAIR_GROUP_SCHED -static int cpu_shares_write_u64(struct cgroup *cgrp, struct cftype *cftype, +static int cpu_shares_write_uint(struct cgroup *cgrp, struct cftype *cftype, u64 shareval) { return sched_group_set_shares(cgroup_tg(cgrp), shareval); } -static u64 cpu_shares_read_u64(struct cgroup *cgrp, struct cftype *cft) +static u64 cpu_shares_read_uint(struct cgroup *cgrp, struct cftype *cft) { struct task_group *tg = cgroup_tg(cgrp); @@ -9073,14 +9073,48 @@ static u64 cpu_shares_read_u64(struct cgroup *cgrp, struct cftype *cft) #ifdef CONFIG_RT_GROUP_SCHED static ssize_t cpu_rt_runtime_write(struct cgroup *cgrp, struct cftype *cft, - s64 val) + struct file *file, + const char __user *userbuf, + size_t nbytes, loff_t *unused_ppos) { - return sched_group_set_rt_runtime(cgroup_tg(cgrp), val); + char buffer[64]; + int retval = 0; + s64 val; + char *end; + + if (!nbytes) + return -EINVAL; + if (nbytes >= sizeof(buffer)) + return -E2BIG; + if (copy_from_user(buffer, userbuf, nbytes)) + return -EFAULT; + + buffer[nbytes] = 0; /* nul-terminate */ + + /* strip newline if necessary */ + if (nbytes && (buffer[nbytes-1] == '\n')) + buffer[nbytes-1] = 0; + val = simple_strtoll(buffer, &end, 0); + if (*end) + return -EINVAL; + + /* Pass to subsystem */ + retval = sched_group_set_rt_runtime(cgroup_tg(cgrp), val); + if (!retval) + retval = nbytes; + return retval; } -static s64 cpu_rt_runtime_read(struct cgroup *cgrp, struct cftype *cft) +static ssize_t cpu_rt_runtime_read(struct cgroup *cgrp, struct cftype *cft, + struct file *file, + char __user *buf, size_t nbytes, + loff_t *ppos) { - return sched_group_rt_runtime(cgroup_tg(cgrp)); + char tmp[64]; + long val = sched_group_rt_runtime(cgroup_tg(cgrp)); + int len = sprintf(tmp, "%ld\n", val); + + return simple_read_from_buffer(buf, nbytes, ppos, tmp, len); } static int cpu_rt_period_write_uint(struct cgroup *cgrp, struct cftype *cftype, @@ -9099,20 +9133,20 @@ static struct cftype cpu_files[] = { #ifdef CONFIG_FAIR_GROUP_SCHED { .name = "shares", - .read_u64 = cpu_shares_read_u64, - .write_u64 = cpu_shares_write_u64, + .read_uint = cpu_shares_read_uint, + .write_uint = cpu_shares_write_uint, }, #endif #ifdef CONFIG_RT_GROUP_SCHED { .name = "rt_runtime_us", - .read_s64 = cpu_rt_runtime_read, - .write_s64 = cpu_rt_runtime_write, + .read = cpu_rt_runtime_read, + .write = cpu_rt_runtime_write, }, { .name = "rt_period_us", - .read_u64 = cpu_rt_period_read_uint, - .write_u64 = cpu_rt_period_write_uint, + .read_uint = cpu_rt_period_read_uint, + .write_uint = cpu_rt_period_write_uint, }, #endif }; @@ -9243,8 +9277,8 @@ static int cpuusage_write(struct cgroup *cgrp, struct cftype *cftype, static struct cftype files[] = { { .name = "usage", - .read_u64 = cpuusage_read, - .write_u64 = cpuusage_write, + .read_uint = cpuusage_read, + .write_uint = cpuusage_write, }, }; diff --git a/trunk/kernel/sched_debug.c b/trunk/kernel/sched_debug.c index 8a9498e7c831..f3f4af4b8b0f 100644 --- a/trunk/kernel/sched_debug.c +++ b/trunk/kernel/sched_debug.c @@ -277,9 +277,12 @@ static int __init init_sched_debug_procfs(void) { struct proc_dir_entry *pe; - pe = proc_create("sched_debug", 0644, NULL, &sched_debug_fops); + pe = create_proc_entry("sched_debug", 0644, NULL); if (!pe) return -ENOMEM; + + pe->proc_fops = &sched_debug_fops; + return 0; } diff --git a/trunk/kernel/sys.c b/trunk/kernel/sys.c index e423d0d9e6ff..f2a451366953 100644 --- a/trunk/kernel/sys.c +++ b/trunk/kernel/sys.c @@ -1545,19 +1545,6 @@ asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim) * */ -static void accumulate_thread_rusage(struct task_struct *t, struct rusage *r, - cputime_t *utimep, cputime_t *stimep) -{ - *utimep = cputime_add(*utimep, t->utime); - *stimep = cputime_add(*stimep, t->stime); - r->ru_nvcsw += t->nvcsw; - r->ru_nivcsw += t->nivcsw; - r->ru_minflt += t->min_flt; - r->ru_majflt += t->maj_flt; - r->ru_inblock += task_io_get_inblock(t); - r->ru_oublock += task_io_get_oublock(t); -} - static void k_getrusage(struct task_struct *p, int who, struct rusage *r) { struct task_struct *t; @@ -1567,11 +1554,6 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r) memset((char *) r, 0, sizeof *r); utime = stime = cputime_zero; - if (who == RUSAGE_THREAD) { - accumulate_thread_rusage(p, r, &utime, &stime); - goto out; - } - rcu_read_lock(); if (!lock_task_sighand(p, &flags)) { rcu_read_unlock(); @@ -1604,7 +1586,14 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r) r->ru_oublock += p->signal->oublock; t = p; do { - accumulate_thread_rusage(t, r, &utime, &stime); + utime = cputime_add(utime, t->utime); + stime = cputime_add(stime, t->stime); + r->ru_nvcsw += t->nvcsw; + r->ru_nivcsw += t->nivcsw; + r->ru_minflt += t->min_flt; + r->ru_majflt += t->maj_flt; + r->ru_inblock += task_io_get_inblock(t); + r->ru_oublock += task_io_get_oublock(t); t = next_thread(t); } while (t != p); break; @@ -1616,7 +1605,6 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r) unlock_task_sighand(p, &flags); rcu_read_unlock(); -out: cputime_to_timeval(utime, &r->ru_utime); cputime_to_timeval(stime, &r->ru_stime); } @@ -1630,8 +1618,7 @@ int getrusage(struct task_struct *p, int who, struct rusage __user *ru) asmlinkage long sys_getrusage(int who, struct rusage __user *ru) { - if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN && - who != RUSAGE_THREAD) + if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN) return -EINVAL; return getrusage(current, who, ru); } diff --git a/trunk/kernel/sysctl.c b/trunk/kernel/sysctl.c index d7ffdc59816a..fd3364827ccf 100644 --- a/trunk/kernel/sysctl.c +++ b/trunk/kernel/sysctl.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -145,6 +144,12 @@ extern int no_unaligned_warning; extern int max_lock_depth; #endif +#ifdef CONFIG_SYSCTL_SYSCALL +static int parse_table(int __user *, int, void __user *, size_t __user *, + void __user *, size_t, struct ctl_table *); +#endif + + #ifdef CONFIG_PROC_SYSCTL static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos); @@ -804,14 +809,6 @@ static struct ctl_table kern_table[] = { .proc_handler = &proc_dostring, .strategy = &sysctl_string, }, -#ifdef CONFIG_KEYS - { - .ctl_name = CTL_UNNUMBERED, - .procname = "keys", - .mode = 0555, - .child = key_sysctls, - }, -#endif /* * NOTE: do not add new entries to this table unless you have read * Documentation/sysctl/ctl_unnumbered.txt @@ -1433,76 +1430,6 @@ void register_sysctl_root(struct ctl_table_root *root) } #ifdef CONFIG_SYSCTL_SYSCALL -/* Perform the actual read/write of a sysctl table entry. */ -static int do_sysctl_strategy(struct ctl_table_root *root, - struct ctl_table *table, - int __user *name, int nlen, - void __user *oldval, size_t __user *oldlenp, - void __user *newval, size_t newlen) -{ - int op = 0, rc; - - if (oldval) - op |= 004; - if (newval) - op |= 002; - if (sysctl_perm(root, table, op)) - return -EPERM; - - if (table->strategy) { - rc = table->strategy(table, name, nlen, oldval, oldlenp, - newval, newlen); - if (rc < 0) - return rc; - if (rc > 0) - return 0; - } - - /* If there is no strategy routine, or if the strategy returns - * zero, proceed with automatic r/w */ - if (table->data && table->maxlen) { - rc = sysctl_data(table, name, nlen, oldval, oldlenp, - newval, newlen); - if (rc < 0) - return rc; - } - return 0; -} - -static int parse_table(int __user *name, int nlen, - void __user *oldval, size_t __user *oldlenp, - void __user *newval, size_t newlen, - struct ctl_table_root *root, - struct ctl_table *table) -{ - int n; -repeat: - if (!nlen) - return -ENOTDIR; - if (get_user(n, name)) - return -EFAULT; - for ( ; table->ctl_name || table->procname; table++) { - if (!table->ctl_name) - continue; - if (n == table->ctl_name) { - int error; - if (table->child) { - if (sysctl_perm(root, table, 001)) - return -EPERM; - name++; - nlen--; - table = table->child; - goto repeat; - } - error = do_sysctl_strategy(root, table, name, nlen, - oldval, oldlenp, - newval, newlen); - return error; - } - } - return -ENOTDIR; -} - int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp, void __user *newval, size_t newlen) { @@ -1520,8 +1447,7 @@ int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *ol for (head = sysctl_head_next(NULL); head; head = sysctl_head_next(head)) { error = parse_table(name, nlen, oldval, oldlenp, - newval, newlen, - head->root, head->ctl_table); + newval, newlen, head->ctl_table); if (error != -ENOTDIR) { sysctl_head_finish(head); break; @@ -1567,22 +1493,84 @@ static int test_perm(int mode, int op) return -EACCES; } -int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op) +int sysctl_perm(struct ctl_table *table, int op) { int error; - int mode; - error = security_sysctl(table, op); if (error) return error; + return test_perm(table->mode, op); +} + +#ifdef CONFIG_SYSCTL_SYSCALL +static int parse_table(int __user *name, int nlen, + void __user *oldval, size_t __user *oldlenp, + void __user *newval, size_t newlen, + struct ctl_table *table) +{ + int n; +repeat: + if (!nlen) + return -ENOTDIR; + if (get_user(n, name)) + return -EFAULT; + for ( ; table->ctl_name || table->procname; table++) { + if (!table->ctl_name) + continue; + if (n == table->ctl_name) { + int error; + if (table->child) { + if (sysctl_perm(table, 001)) + return -EPERM; + name++; + nlen--; + table = table->child; + goto repeat; + } + error = do_sysctl_strategy(table, name, nlen, + oldval, oldlenp, + newval, newlen); + return error; + } + } + return -ENOTDIR; +} - if (root->permissions) - mode = root->permissions(root, current->nsproxy, table); - else - mode = table->mode; +/* Perform the actual read/write of a sysctl table entry. */ +int do_sysctl_strategy (struct ctl_table *table, + int __user *name, int nlen, + void __user *oldval, size_t __user *oldlenp, + void __user *newval, size_t newlen) +{ + int op = 0, rc; + + if (oldval) + op |= 004; + if (newval) + op |= 002; + if (sysctl_perm(table, op)) + return -EPERM; - return test_perm(mode, op); + if (table->strategy) { + rc = table->strategy(table, name, nlen, oldval, oldlenp, + newval, newlen); + if (rc < 0) + return rc; + if (rc > 0) + return 0; + } + + /* If there is no strategy routine, or if the strategy returns + * zero, proceed with automatic r/w */ + if (table->data && table->maxlen) { + rc = sysctl_data(table, name, nlen, oldval, oldlenp, + newval, newlen); + if (rc < 0) + return rc; + } + return 0; } +#endif /* CONFIG_SYSCTL_SYSCALL */ static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table) { @@ -1595,13 +1583,9 @@ static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table) static __init int sysctl_init(void) { + int err; sysctl_set_parent(NULL, root_table); -#ifdef CONFIG_SYSCTL_SYSCALL_CHECK - { - int err; - err = sysctl_check_table(current->nsproxy, root_table); - } -#endif + err = sysctl_check_table(current->nsproxy, root_table); return 0; } @@ -1728,12 +1712,10 @@ struct ctl_table_header *__register_sysctl_paths( header->unregistering = NULL; header->root = root; sysctl_set_parent(NULL, header->ctl_table); -#ifdef CONFIG_SYSCTL_SYSCALL_CHECK if (sysctl_check_table(namespaces, header->ctl_table)) { kfree(header); return NULL; } -#endif spin_lock(&sysctl_lock); header_list = lookup_header_list(root, namespaces); list_add_tail(&header->ctl_entry, header_list); diff --git a/trunk/kernel/time.c b/trunk/kernel/time.c index 86729042e4cd..35d373a98782 100644 --- a/trunk/kernel/time.c +++ b/trunk/kernel/time.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include diff --git a/trunk/kernel/time/timer_list.c b/trunk/kernel/time/timer_list.c index a40e20fd0001..67fe8fc21fb1 100644 --- a/trunk/kernel/time/timer_list.c +++ b/trunk/kernel/time/timer_list.c @@ -278,9 +278,12 @@ static int __init init_timer_list_procfs(void) { struct proc_dir_entry *pe; - pe = proc_create("timer_list", 0644, NULL, &timer_list_fops); + pe = create_proc_entry("timer_list", 0644, NULL); if (!pe) return -ENOMEM; + + pe->proc_fops = &timer_list_fops; + return 0; } __initcall(init_timer_list_procfs); diff --git a/trunk/kernel/time/timer_stats.c b/trunk/kernel/time/timer_stats.c index c994530d166d..417da8c5bc72 100644 --- a/trunk/kernel/time/timer_stats.c +++ b/trunk/kernel/time/timer_stats.c @@ -415,9 +415,12 @@ static int __init init_tstats_procfs(void) { struct proc_dir_entry *pe; - pe = proc_create("timer_stats", 0644, NULL, &tstats_fops); + pe = create_proc_entry("timer_stats", 0644, NULL); if (!pe) return -ENOMEM; + + pe->proc_fops = &tstats_fops; + return 0; } __initcall(init_tstats_procfs); diff --git a/trunk/kernel/user.c b/trunk/kernel/user.c index aefbbfa3159f..debce602bfdd 100644 --- a/trunk/kernel/user.c +++ b/trunk/kernel/user.c @@ -53,6 +53,10 @@ struct user_struct root_user = { .files = ATOMIC_INIT(0), .sigpending = ATOMIC_INIT(0), .locked_shm = 0, +#ifdef CONFIG_KEYS + .uid_keyring = &root_user_keyring, + .session_keyring = &root_session_keyring, +#endif #ifdef CONFIG_USER_SCHED .tg = &init_task_group, #endif @@ -416,13 +420,13 @@ struct user_struct * alloc_uid(struct user_namespace *ns, uid_t uid) new->mq_bytes = 0; #endif new->locked_shm = 0; -#ifdef CONFIG_KEYS - new->uid_keyring = new->session_keyring = NULL; -#endif - if (sched_create_user(new) < 0) + if (alloc_uid_keyring(new, current) < 0) goto out_free_user; + if (sched_create_user(new) < 0) + goto out_put_keys; + if (uids_user_create(new)) goto out_destoy_sched; @@ -455,6 +459,9 @@ struct user_struct * alloc_uid(struct user_namespace *ns, uid_t uid) out_destoy_sched: sched_destroy_user(new); +out_put_keys: + key_put(new->uid_keyring); + key_put(new->session_keyring); out_free_user: kmem_cache_free(uid_cachep, new); out_unlock: diff --git a/trunk/kernel/user_namespace.c b/trunk/kernel/user_namespace.c index a9ab0596de44..4c9006275df7 100644 --- a/trunk/kernel/user_namespace.c +++ b/trunk/kernel/user_namespace.c @@ -8,7 +8,6 @@ #include #include #include -#include #include /* @@ -74,4 +73,3 @@ void free_user_ns(struct kref *kref) release_uids(ns); kfree(ns); } -EXPORT_SYMBOL(free_user_ns); diff --git a/trunk/kernel/utsname.c b/trunk/kernel/utsname.c index 64d398f12444..816d7b24fa03 100644 --- a/trunk/kernel/utsname.c +++ b/trunk/kernel/utsname.c @@ -14,7 +14,6 @@ #include #include #include -#include /* * Clone a new ns copying an original utsname, setting refcount to 1 diff --git a/trunk/kernel/workqueue.c b/trunk/kernel/workqueue.c index 7db251a959c5..00ff4d08e370 100644 --- a/trunk/kernel/workqueue.c +++ b/trunk/kernel/workqueue.c @@ -158,8 +158,8 @@ static void __queue_work(struct cpu_workqueue_struct *cwq, * * Returns 0 if @work was already on a queue, non-zero otherwise. * - * We queue the work to the CPU on which it was submitted, but if the CPU dies - * it can be processed by another CPU. + * We queue the work to the CPU it was submitted, but there is no + * guarantee that it will be processed by that CPU. */ int queue_work(struct workqueue_struct *wq, struct work_struct *work) { @@ -772,7 +772,7 @@ struct workqueue_struct *__create_workqueue_key(const char *name, } EXPORT_SYMBOL_GPL(__create_workqueue_key); -static void cleanup_workqueue_thread(struct cpu_workqueue_struct *cwq) +static void cleanup_workqueue_thread(struct cpu_workqueue_struct *cwq, int cpu) { /* * Our caller is either destroy_workqueue() or CPU_DEAD, @@ -808,17 +808,20 @@ static void cleanup_workqueue_thread(struct cpu_workqueue_struct *cwq) void destroy_workqueue(struct workqueue_struct *wq) { const cpumask_t *cpu_map = wq_cpu_map(wq); + struct cpu_workqueue_struct *cwq; int cpu; get_online_cpus(); spin_lock(&workqueue_lock); list_del(&wq->list); spin_unlock(&workqueue_lock); - - for_each_cpu_mask(cpu, *cpu_map) - cleanup_workqueue_thread(per_cpu_ptr(wq->cpu_wq, cpu)); put_online_cpus(); + for_each_cpu_mask(cpu, *cpu_map) { + cwq = per_cpu_ptr(wq->cpu_wq, cpu); + cleanup_workqueue_thread(cwq, cpu); + } + free_percpu(wq->cpu_wq); kfree(wq); } @@ -835,6 +838,7 @@ static int __devinit workqueue_cpu_callback(struct notifier_block *nfb, action &= ~CPU_TASKS_FROZEN; switch (action) { + case CPU_UP_PREPARE: cpu_set(cpu, cpu_populated_map); } @@ -857,17 +861,11 @@ static int __devinit workqueue_cpu_callback(struct notifier_block *nfb, case CPU_UP_CANCELED: start_workqueue_thread(cwq, -1); case CPU_DEAD: - cleanup_workqueue_thread(cwq); + cleanup_workqueue_thread(cwq, cpu); break; } } - switch (action) { - case CPU_UP_CANCELED: - case CPU_DEAD: - cpu_clear(cpu, cpu_populated_map); - } - return NOTIFY_OK; } diff --git a/trunk/lib/Makefile b/trunk/lib/Makefile index 0ae4eb047aac..2d7001b7f5a4 100644 --- a/trunk/lib/Makefile +++ b/trunk/lib/Makefile @@ -6,7 +6,7 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \ rbtree.o radix-tree.o dump_stack.o \ idr.o int_sqrt.o extable.o prio_tree.o \ sha1.o irq_regs.o reciprocal_div.o argv_split.o \ - proportions.o prio_heap.o ratelimit.o + proportions.o prio_heap.o lib-$(CONFIG_MMU) += ioremap.o lib-$(CONFIG_SMP) += cpumask.o diff --git a/trunk/lib/find_next_bit.c b/trunk/lib/find_next_bit.c index 24c59ded47a0..d3f5784807b4 100644 --- a/trunk/lib/find_next_bit.c +++ b/trunk/lib/find_next_bit.c @@ -20,8 +20,8 @@ /* * Find the next set bit in a memory region. */ -unsigned long find_next_bit(const unsigned long *addr, unsigned long size, - unsigned long offset) +unsigned long __find_next_bit(const unsigned long *addr, + unsigned long size, unsigned long offset) { const unsigned long *p = addr + BITOP_WORD(offset); unsigned long result = offset & ~(BITS_PER_LONG-1); @@ -58,14 +58,14 @@ unsigned long find_next_bit(const unsigned long *addr, unsigned long size, found_middle: return result + __ffs(tmp); } -EXPORT_SYMBOL(find_next_bit); +EXPORT_SYMBOL(__find_next_bit); /* * This implementation of find_{first,next}_zero_bit was stolen from * Linus' asm-alpha/bitops.h. */ -unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size, - unsigned long offset) +unsigned long __find_next_zero_bit(const unsigned long *addr, + unsigned long size, unsigned long offset) { const unsigned long *p = addr + BITOP_WORD(offset); unsigned long result = offset & ~(BITS_PER_LONG-1); @@ -102,14 +102,15 @@ unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size, found_middle: return result + ffz(tmp); } -EXPORT_SYMBOL(find_next_zero_bit); +EXPORT_SYMBOL(__find_next_zero_bit); #endif /* CONFIG_GENERIC_FIND_NEXT_BIT */ #ifdef CONFIG_GENERIC_FIND_FIRST_BIT /* * Find the first set bit in a memory region. */ -unsigned long find_first_bit(const unsigned long *addr, unsigned long size) +unsigned long __find_first_bit(const unsigned long *addr, + unsigned long size) { const unsigned long *p = addr; unsigned long result = 0; @@ -130,12 +131,13 @@ unsigned long find_first_bit(const unsigned long *addr, unsigned long size) found: return result + __ffs(tmp); } -EXPORT_SYMBOL(find_first_bit); +EXPORT_SYMBOL(__find_first_bit); /* * Find the first cleared bit in a memory region. */ -unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size) +unsigned long __find_first_zero_bit(const unsigned long *addr, + unsigned long size) { const unsigned long *p = addr; unsigned long result = 0; @@ -156,7 +158,7 @@ unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size) found: return result + ffz(tmp); } -EXPORT_SYMBOL(find_first_zero_bit); +EXPORT_SYMBOL(__find_first_zero_bit); #endif /* CONFIG_GENERIC_FIND_FIRST_BIT */ #ifdef __BIG_ENDIAN diff --git a/trunk/lib/idr.c b/trunk/lib/idr.c index 8368c81fcb7d..afbb0b1023d4 100644 --- a/trunk/lib/idr.c +++ b/trunk/lib/idr.c @@ -585,11 +585,12 @@ static void idr_cache_ctor(struct kmem_cache *idr_layer_cache, void *idr_layer) memset(idr_layer, 0, sizeof(struct idr_layer)); } -void __init idr_init_cache(void) +static int init_id_cache(void) { - idr_layer_cache = kmem_cache_create("idr_layer_cache", - sizeof(struct idr_layer), 0, SLAB_PANIC, - idr_cache_ctor); + if (!idr_layer_cache) + idr_layer_cache = kmem_cache_create("idr_layer_cache", + sizeof(struct idr_layer), 0, 0, idr_cache_ctor); + return 0; } /** @@ -601,6 +602,7 @@ void __init idr_init_cache(void) */ void idr_init(struct idr *idp) { + init_id_cache(); memset(idp, 0, sizeof(struct idr)); spin_lock_init(&idp->lock); } diff --git a/trunk/lib/inflate.c b/trunk/lib/inflate.c index 9762294be062..845f91d3ac12 100644 --- a/trunk/lib/inflate.c +++ b/trunk/lib/inflate.c @@ -811,9 +811,6 @@ DEBG("region[r1].base; @@ -73,7 +74,7 @@ static long lmb_regions_adjacent(struct lmb_region *rgn, return lmb_addrs_adjacent(base1, size1, base2, size2); } -static void lmb_remove_region(struct lmb_region *rgn, unsigned long r) +static void __init lmb_remove_region(struct lmb_region *rgn, unsigned long r) { unsigned long i; @@ -85,7 +86,7 @@ static void lmb_remove_region(struct lmb_region *rgn, unsigned long r) } /* Assumption: base addr of region 1 < base addr of region 2 */ -static void lmb_coalesce_regions(struct lmb_region *rgn, +static void __init lmb_coalesce_regions(struct lmb_region *rgn, unsigned long r1, unsigned long r2) { rgn->region[r1].size += rgn->region[r2].size; @@ -117,7 +118,7 @@ void __init lmb_analyze(void) lmb.memory.size += lmb.memory.region[i].size; } -static long lmb_add_region(struct lmb_region *rgn, u64 base, u64 size) +static long __init lmb_add_region(struct lmb_region *rgn, u64 base, u64 size) { unsigned long coalesced = 0; long adjacent, i; @@ -181,7 +182,7 @@ static long lmb_add_region(struct lmb_region *rgn, u64 base, u64 size) return 0; } -long lmb_add(u64 base, u64 size) +long __init lmb_add(u64 base, u64 size) { struct lmb_region *_rgn = &lmb.memory; @@ -193,55 +194,6 @@ long lmb_add(u64 base, u64 size) } -long lmb_remove(u64 base, u64 size) -{ - struct lmb_region *rgn = &(lmb.memory); - u64 rgnbegin, rgnend; - u64 end = base + size; - int i; - - rgnbegin = rgnend = 0; /* supress gcc warnings */ - - /* Find the region where (base, size) belongs to */ - for (i=0; i < rgn->cnt; i++) { - rgnbegin = rgn->region[i].base; - rgnend = rgnbegin + rgn->region[i].size; - - if ((rgnbegin <= base) && (end <= rgnend)) - break; - } - - /* Didn't find the region */ - if (i == rgn->cnt) - return -1; - - /* Check to see if we are removing entire region */ - if ((rgnbegin == base) && (rgnend == end)) { - lmb_remove_region(rgn, i); - return 0; - } - - /* Check to see if region is matching at the front */ - if (rgnbegin == base) { - rgn->region[i].base = end; - rgn->region[i].size -= size; - return 0; - } - - /* Check to see if the region is matching at the end */ - if (rgnend == end) { - rgn->region[i].size -= size; - return 0; - } - - /* - * We need to split the entry - adjust the current one to the - * beginging of the hole and add the region after hole. - */ - rgn->region[i].size = base - rgn->region[i].base; - return lmb_add_region(rgn, end, rgnend - end); -} - long __init lmb_reserve(u64 base, u64 size) { struct lmb_region *_rgn = &lmb.reserved; @@ -474,36 +426,3 @@ int __init lmb_is_reserved(u64 addr) } return 0; } - -/* - * Given a , find which memory regions belong to this range. - * Adjust the request and return a contiguous chunk. - */ -int lmb_find(struct lmb_property *res) -{ - int i; - u64 rstart, rend; - - rstart = res->base; - rend = rstart + res->size - 1; - - for (i = 0; i < lmb.memory.cnt; i++) { - u64 start = lmb.memory.region[i].base; - u64 end = start + lmb.memory.region[i].size - 1; - - if (start > rend) - return -1; - - if ((end >= rstart) && (start < rend)) { - /* adjust the request */ - if (rstart < start) - rstart = start; - if (rend > end) - rend = end; - res->base = rstart; - res->size = rend - rstart + 1; - return 0; - } - } - return -1; -} diff --git a/trunk/lib/ratelimit.c b/trunk/lib/ratelimit.c deleted file mode 100644 index 485e3040dcd4..000000000000 --- a/trunk/lib/ratelimit.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * ratelimit.c - Do something with rate limit. - * - * Isolated from kernel/printk.c by Dave Young - * - * This file is released under the GPLv2. - * - */ - -#include -#include -#include - -/* - * __ratelimit - rate limiting - * @ratelimit_jiffies: minimum time in jiffies between two callbacks - * @ratelimit_burst: number of callbacks we do before ratelimiting - * - * This enforces a rate limit: not more than @ratelimit_burst callbacks - * in every ratelimit_jiffies - */ -int __ratelimit(int ratelimit_jiffies, int ratelimit_burst) -{ - static DEFINE_SPINLOCK(ratelimit_lock); - static unsigned toks = 10 * 5 * HZ; - static unsigned long last_msg; - static int missed; - unsigned long flags; - unsigned long now = jiffies; - - spin_lock_irqsave(&ratelimit_lock, flags); - toks += now - last_msg; - last_msg = now; - if (toks > (ratelimit_burst * ratelimit_jiffies)) - toks = ratelimit_burst * ratelimit_jiffies; - if (toks >= ratelimit_jiffies) { - int lost = missed; - - missed = 0; - toks -= ratelimit_jiffies; - spin_unlock_irqrestore(&ratelimit_lock, flags); - if (lost) - printk(KERN_WARNING "%s: %d messages suppressed\n", - __func__, lost); - return 1; - } - missed++; - spin_unlock_irqrestore(&ratelimit_lock, flags); - return 0; -} -EXPORT_SYMBOL(__ratelimit); diff --git a/trunk/lib/swiotlb.c b/trunk/lib/swiotlb.c index d568894df8cc..025922807e6e 100644 --- a/trunk/lib/swiotlb.c +++ b/trunk/lib/swiotlb.c @@ -31,7 +31,6 @@ #include #include -#include #define OFFSET(val,align) ((unsigned long) \ ( (val) & ( (align) - 1))) @@ -283,6 +282,15 @@ address_needs_mapping(struct device *hwdev, dma_addr_t addr) return (addr & ~mask) != 0; } +static inline unsigned int is_span_boundary(unsigned int index, + unsigned int nslots, + unsigned long offset_slots, + unsigned long max_slots) +{ + unsigned long offset = (offset_slots + index) & (max_slots - 1); + return offset + nslots > max_slots; +} + /* * Allocates bounce buffer and returns its kernel virtual address. */ @@ -323,53 +331,56 @@ map_single(struct device *hwdev, char *buffer, size_t size, int dir) * request and allocate a buffer from that IO TLB pool. */ spin_lock_irqsave(&io_tlb_lock, flags); - index = ALIGN(io_tlb_index, stride); - if (index >= io_tlb_nslabs) - index = 0; - wrap = index; - - do { - while (iommu_is_span_boundary(index, nslots, offset_slots, - max_slots)) { - index += stride; - if (index >= io_tlb_nslabs) - index = 0; - if (index == wrap) - goto not_found; - } - - /* - * If we find a slot that indicates we have 'nslots' number of - * contiguous buffers, we allocate the buffers from that slot - * and mark the entries as '0' indicating unavailable. - */ - if (io_tlb_list[index] >= nslots) { - int count = 0; - - for (i = index; i < (int) (index + nslots); i++) - io_tlb_list[i] = 0; - for (i = index - 1; (OFFSET(i, IO_TLB_SEGSIZE) != IO_TLB_SEGSIZE - 1) && io_tlb_list[i]; i--) - io_tlb_list[i] = ++count; - dma_addr = io_tlb_start + (index << IO_TLB_SHIFT); + { + index = ALIGN(io_tlb_index, stride); + if (index >= io_tlb_nslabs) + index = 0; + wrap = index; + + do { + while (is_span_boundary(index, nslots, offset_slots, + max_slots)) { + index += stride; + if (index >= io_tlb_nslabs) + index = 0; + if (index == wrap) + goto not_found; + } /* - * Update the indices to avoid searching in the next - * round. + * If we find a slot that indicates we have 'nslots' + * number of contiguous buffers, we allocate the + * buffers from that slot and mark the entries as '0' + * indicating unavailable. */ - io_tlb_index = ((index + nslots) < io_tlb_nslabs - ? (index + nslots) : 0); - - goto found; - } - index += stride; - if (index >= io_tlb_nslabs) - index = 0; - } while (index != wrap); + if (io_tlb_list[index] >= nslots) { + int count = 0; + + for (i = index; i < (int) (index + nslots); i++) + io_tlb_list[i] = 0; + for (i = index - 1; (OFFSET(i, IO_TLB_SEGSIZE) != IO_TLB_SEGSIZE -1) && io_tlb_list[i]; i--) + io_tlb_list[i] = ++count; + dma_addr = io_tlb_start + (index << IO_TLB_SHIFT); + + /* + * Update the indices to avoid searching in + * the next round. + */ + io_tlb_index = ((index + nslots) < io_tlb_nslabs + ? (index + nslots) : 0); + + goto found; + } + index += stride; + if (index >= io_tlb_nslabs) + index = 0; + } while (index != wrap); -not_found: - spin_unlock_irqrestore(&io_tlb_lock, flags); - return NULL; -found: + not_found: + spin_unlock_irqrestore(&io_tlb_lock, flags); + return NULL; + } + found: spin_unlock_irqrestore(&io_tlb_lock, flags); /* @@ -555,8 +566,7 @@ swiotlb_full(struct device *dev, size_t size, int dir, int do_panic) * either swiotlb_unmap_single or swiotlb_dma_sync_single is performed. */ dma_addr_t -swiotlb_map_single_attrs(struct device *hwdev, void *ptr, size_t size, - int dir, struct dma_attrs *attrs) +swiotlb_map_single(struct device *hwdev, void *ptr, size_t size, int dir) { dma_addr_t dev_addr = virt_to_bus(ptr); void *map; @@ -589,13 +599,6 @@ swiotlb_map_single_attrs(struct device *hwdev, void *ptr, size_t size, return dev_addr; } -EXPORT_SYMBOL(swiotlb_map_single_attrs); - -dma_addr_t -swiotlb_map_single(struct device *hwdev, void *ptr, size_t size, int dir) -{ - return swiotlb_map_single_attrs(hwdev, ptr, size, dir, NULL); -} /* * Unmap a single streaming mode DMA translation. The dma_addr and size must @@ -606,8 +609,8 @@ swiotlb_map_single(struct device *hwdev, void *ptr, size_t size, int dir) * whatever the device wrote there. */ void -swiotlb_unmap_single_attrs(struct device *hwdev, dma_addr_t dev_addr, - size_t size, int dir, struct dma_attrs *attrs) +swiotlb_unmap_single(struct device *hwdev, dma_addr_t dev_addr, size_t size, + int dir) { char *dma_addr = bus_to_virt(dev_addr); @@ -617,14 +620,7 @@ swiotlb_unmap_single_attrs(struct device *hwdev, dma_addr_t dev_addr, else if (dir == DMA_FROM_DEVICE) dma_mark_clean(dma_addr, size); } -EXPORT_SYMBOL(swiotlb_unmap_single_attrs); -void -swiotlb_unmap_single(struct device *hwdev, dma_addr_t dev_addr, size_t size, - int dir) -{ - return swiotlb_unmap_single_attrs(hwdev, dev_addr, size, dir, NULL); -} /* * Make physical memory consistent for a single streaming mode DMA translation * after a transfer. @@ -695,8 +691,6 @@ swiotlb_sync_single_range_for_device(struct device *hwdev, dma_addr_t dev_addr, SYNC_FOR_DEVICE); } -void swiotlb_unmap_sg_attrs(struct device *, struct scatterlist *, int, int, - struct dma_attrs *); /* * Map a set of buffers described by scatterlist in streaming mode for DMA. * This is the scatter-gather version of the above swiotlb_map_single @@ -714,8 +708,8 @@ void swiotlb_unmap_sg_attrs(struct device *, struct scatterlist *, int, int, * same here. */ int -swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl, int nelems, - int dir, struct dma_attrs *attrs) +swiotlb_map_sg(struct device *hwdev, struct scatterlist *sgl, int nelems, + int dir) { struct scatterlist *sg; void *addr; @@ -733,8 +727,7 @@ swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl, int nelems, /* Don't panic here, we expect map_sg users to do proper error handling. */ swiotlb_full(hwdev, sg->length, dir, 0); - swiotlb_unmap_sg_attrs(hwdev, sgl, i, dir, - attrs); + swiotlb_unmap_sg(hwdev, sgl, i, dir); sgl[0].dma_length = 0; return 0; } @@ -745,22 +738,14 @@ swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl, int nelems, } return nelems; } -EXPORT_SYMBOL(swiotlb_map_sg_attrs); - -int -swiotlb_map_sg(struct device *hwdev, struct scatterlist *sgl, int nelems, - int dir) -{ - return swiotlb_map_sg_attrs(hwdev, sgl, nelems, dir, NULL); -} /* * Unmap a set of streaming mode DMA translations. Again, cpu read rules * concerning calls here are the same as for swiotlb_unmap_single() above. */ void -swiotlb_unmap_sg_attrs(struct device *hwdev, struct scatterlist *sgl, - int nelems, int dir, struct dma_attrs *attrs) +swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sgl, int nelems, + int dir) { struct scatterlist *sg; int i; @@ -775,14 +760,6 @@ swiotlb_unmap_sg_attrs(struct device *hwdev, struct scatterlist *sgl, dma_mark_clean(SG_ENT_VIRT_ADDRESS(sg), sg->dma_length); } } -EXPORT_SYMBOL(swiotlb_unmap_sg_attrs); - -void -swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sgl, int nelems, - int dir) -{ - return swiotlb_unmap_sg_attrs(hwdev, sgl, nelems, dir, NULL); -} /* * Make physical memory consistent for a set of streaming mode DMA translations diff --git a/trunk/mm/hugetlb.c b/trunk/mm/hugetlb.c index bbf953eeb58b..2c37c67ed8c9 100644 --- a/trunk/mm/hugetlb.c +++ b/trunk/mm/hugetlb.c @@ -199,8 +199,7 @@ static struct page *alloc_fresh_huge_page_node(int nid) struct page *page; page = alloc_pages_node(nid, - htlb_alloc_mask|__GFP_COMP|__GFP_THISNODE| - __GFP_REPEAT|__GFP_NOWARN, + htlb_alloc_mask|__GFP_COMP|__GFP_THISNODE|__GFP_NOWARN, HUGETLB_PAGE_ORDER); if (page) { if (arch_prepare_hugepage(page)) { @@ -295,8 +294,7 @@ static struct page *alloc_buddy_huge_page(struct vm_area_struct *vma, } spin_unlock(&hugetlb_lock); - page = alloc_pages(htlb_alloc_mask|__GFP_COMP| - __GFP_REPEAT|__GFP_NOWARN, + page = alloc_pages(htlb_alloc_mask|__GFP_COMP|__GFP_NOWARN, HUGETLB_PAGE_ORDER); spin_lock(&hugetlb_lock); diff --git a/trunk/mm/memcontrol.c b/trunk/mm/memcontrol.c index 33add96cd5fb..2e0bfc93484b 100644 --- a/trunk/mm/memcontrol.c +++ b/trunk/mm/memcontrol.c @@ -26,18 +26,15 @@ #include #include #include -#include #include #include #include #include -#include #include struct cgroup_subsys mem_cgroup_subsys; static const int MEM_CGROUP_RECLAIM_RETRIES = 5; -static struct kmem_cache *page_cgroup_cache; /* * Statistics for memory cgroup. @@ -239,12 +236,26 @@ static struct mem_cgroup *mem_cgroup_from_cont(struct cgroup *cont) css); } -struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p) +static struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p) { return container_of(task_subsys_state(p, mem_cgroup_subsys_id), struct mem_cgroup, css); } +void mm_init_cgroup(struct mm_struct *mm, struct task_struct *p) +{ + struct mem_cgroup *mem; + + mem = mem_cgroup_from_task(p); + css_get(&mem->css); + mm->mem_cgroup = mem; +} + +void mm_free_cgroup(struct mm_struct *mm) +{ + css_put(&mm->mem_cgroup->css); +} + static inline int page_cgroup_locked(struct page *page) { return bit_spin_is_locked(PAGE_CGROUP_LOCK_BIT, &page->page_cgroup); @@ -276,10 +287,10 @@ static void unlock_page_cgroup(struct page *page) bit_spin_unlock(PAGE_CGROUP_LOCK_BIT, &page->page_cgroup); } -static void __mem_cgroup_remove_list(struct mem_cgroup_per_zone *mz, - struct page_cgroup *pc) +static void __mem_cgroup_remove_list(struct page_cgroup *pc) { int from = pc->flags & PAGE_CGROUP_FLAG_ACTIVE; + struct mem_cgroup_per_zone *mz = page_cgroup_zoneinfo(pc); if (from) MEM_CGROUP_ZSTAT(mz, MEM_CGROUP_ZSTAT_ACTIVE) -= 1; @@ -290,10 +301,10 @@ static void __mem_cgroup_remove_list(struct mem_cgroup_per_zone *mz, list_del_init(&pc->lru); } -static void __mem_cgroup_add_list(struct mem_cgroup_per_zone *mz, - struct page_cgroup *pc) +static void __mem_cgroup_add_list(struct page_cgroup *pc) { int to = pc->flags & PAGE_CGROUP_FLAG_ACTIVE; + struct mem_cgroup_per_zone *mz = page_cgroup_zoneinfo(pc); if (!to) { MEM_CGROUP_ZSTAT(mz, MEM_CGROUP_ZSTAT_INACTIVE) += 1; @@ -465,7 +476,6 @@ unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, int zid = zone_idx(z); struct mem_cgroup_per_zone *mz; - BUG_ON(!mem_cont); mz = mem_cgroup_zoneinfo(mem_cont, nid, zid); if (active) src = &mz->active_list; @@ -550,7 +560,7 @@ static int mem_cgroup_charge_common(struct page *page, struct mm_struct *mm, } unlock_page_cgroup(page); - pc = kmem_cache_zalloc(page_cgroup_cache, gfp_mask); + pc = kzalloc(sizeof(struct page_cgroup), gfp_mask); if (pc == NULL) goto err; @@ -564,7 +574,7 @@ static int mem_cgroup_charge_common(struct page *page, struct mm_struct *mm, mm = &init_mm; rcu_read_lock(); - mem = mem_cgroup_from_task(rcu_dereference(mm->owner)); + mem = rcu_dereference(mm->mem_cgroup); /* * For every charge from the cgroup, increment reference count */ @@ -592,6 +602,7 @@ static int mem_cgroup_charge_common(struct page *page, struct mm_struct *mm, mem_cgroup_out_of_memory(mem, gfp_mask); goto out; } + congestion_wait(WRITE, HZ/10); } pc->ref_cnt = 1; @@ -599,7 +610,7 @@ static int mem_cgroup_charge_common(struct page *page, struct mm_struct *mm, pc->page = page; pc->flags = PAGE_CGROUP_FLAG_ACTIVE; if (ctype == MEM_CGROUP_CHARGE_TYPE_CACHE) - pc->flags = PAGE_CGROUP_FLAG_CACHE; + pc->flags |= PAGE_CGROUP_FLAG_CACHE; lock_page_cgroup(page); if (page_get_page_cgroup(page)) { @@ -611,14 +622,14 @@ static int mem_cgroup_charge_common(struct page *page, struct mm_struct *mm, */ res_counter_uncharge(&mem->res, PAGE_SIZE); css_put(&mem->css); - kmem_cache_free(page_cgroup_cache, pc); + kfree(pc); goto retry; } page_assign_page_cgroup(page, pc); mz = page_cgroup_zoneinfo(pc); spin_lock_irqsave(&mz->lru_lock, flags); - __mem_cgroup_add_list(mz, pc); + __mem_cgroup_add_list(pc); spin_unlock_irqrestore(&mz->lru_lock, flags); unlock_page_cgroup(page); @@ -626,7 +637,7 @@ static int mem_cgroup_charge_common(struct page *page, struct mm_struct *mm, return 0; out: css_put(&mem->css); - kmem_cache_free(page_cgroup_cache, pc); + kfree(pc); err: return -ENOMEM; } @@ -674,7 +685,7 @@ void mem_cgroup_uncharge_page(struct page *page) if (--(pc->ref_cnt) == 0) { mz = page_cgroup_zoneinfo(pc); spin_lock_irqsave(&mz->lru_lock, flags); - __mem_cgroup_remove_list(mz, pc); + __mem_cgroup_remove_list(pc); spin_unlock_irqrestore(&mz->lru_lock, flags); page_assign_page_cgroup(page, NULL); @@ -684,7 +695,7 @@ void mem_cgroup_uncharge_page(struct page *page) res_counter_uncharge(&mem->res, PAGE_SIZE); css_put(&mem->css); - kmem_cache_free(page_cgroup_cache, pc); + kfree(pc); return; } @@ -736,7 +747,7 @@ void mem_cgroup_page_migration(struct page *page, struct page *newpage) mz = page_cgroup_zoneinfo(pc); spin_lock_irqsave(&mz->lru_lock, flags); - __mem_cgroup_remove_list(mz, pc); + __mem_cgroup_remove_list(pc); spin_unlock_irqrestore(&mz->lru_lock, flags); page_assign_page_cgroup(page, NULL); @@ -748,7 +759,7 @@ void mem_cgroup_page_migration(struct page *page, struct page *newpage) mz = page_cgroup_zoneinfo(pc); spin_lock_irqsave(&mz->lru_lock, flags); - __mem_cgroup_add_list(mz, pc); + __mem_cgroup_add_list(pc); spin_unlock_irqrestore(&mz->lru_lock, flags); unlock_page_cgroup(newpage); @@ -842,10 +853,13 @@ static int mem_cgroup_write_strategy(char *buf, unsigned long long *tmp) return 0; } -static u64 mem_cgroup_read(struct cgroup *cont, struct cftype *cft) +static ssize_t mem_cgroup_read(struct cgroup *cont, + struct cftype *cft, struct file *file, + char __user *userbuf, size_t nbytes, loff_t *ppos) { - return res_counter_read_u64(&mem_cgroup_from_cont(cont)->res, - cft->private); + return res_counter_read(&mem_cgroup_from_cont(cont)->res, + cft->private, userbuf, nbytes, ppos, + NULL); } static ssize_t mem_cgroup_write(struct cgroup *cont, struct cftype *cft, @@ -857,25 +871,27 @@ static ssize_t mem_cgroup_write(struct cgroup *cont, struct cftype *cft, mem_cgroup_write_strategy); } -static int mem_cgroup_reset(struct cgroup *cont, unsigned int event) +static ssize_t mem_force_empty_write(struct cgroup *cont, + struct cftype *cft, struct file *file, + const char __user *userbuf, + size_t nbytes, loff_t *ppos) { - struct mem_cgroup *mem; - - mem = mem_cgroup_from_cont(cont); - switch (event) { - case RES_MAX_USAGE: - res_counter_reset_max(&mem->res); - break; - case RES_FAILCNT: - res_counter_reset_failcnt(&mem->res); - break; - } - return 0; + struct mem_cgroup *mem = mem_cgroup_from_cont(cont); + int ret = mem_cgroup_force_empty(mem); + if (!ret) + ret = nbytes; + return ret; } -static int mem_force_empty_write(struct cgroup *cont, unsigned int event) +/* + * Note: This should be removed if cgroup supports write-only file. + */ +static ssize_t mem_force_empty_read(struct cgroup *cont, + struct cftype *cft, + struct file *file, char __user *userbuf, + size_t nbytes, loff_t *ppos) { - return mem_cgroup_force_empty(mem_cgroup_from_cont(cont)); + return -EINVAL; } static const struct mem_cgroup_stat_desc { @@ -886,9 +902,9 @@ static const struct mem_cgroup_stat_desc { [MEM_CGROUP_STAT_RSS] = { "rss", PAGE_SIZE, }, }; -static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft, - struct cgroup_map_cb *cb) +static int mem_control_stat_show(struct seq_file *m, void *arg) { + struct cgroup *cont = m->private; struct mem_cgroup *mem_cont = mem_cgroup_from_cont(cont); struct mem_cgroup_stat *stat = &mem_cont->stat; int i; @@ -898,7 +914,8 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft, val = mem_cgroup_read_stat(stat, i); val *= mem_cgroup_stat_desc[i].unit; - cb->fill(cb, mem_cgroup_stat_desc[i].msg, val); + seq_printf(m, "%s %lld\n", mem_cgroup_stat_desc[i].msg, + (long long)val); } /* showing # of active pages */ { @@ -908,43 +925,52 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft, MEM_CGROUP_ZSTAT_INACTIVE); active = mem_cgroup_get_all_zonestat(mem_cont, MEM_CGROUP_ZSTAT_ACTIVE); - cb->fill(cb, "active", (active) * PAGE_SIZE); - cb->fill(cb, "inactive", (inactive) * PAGE_SIZE); + seq_printf(m, "active %ld\n", (active) * PAGE_SIZE); + seq_printf(m, "inactive %ld\n", (inactive) * PAGE_SIZE); } return 0; } +static const struct file_operations mem_control_stat_file_operations = { + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static int mem_control_stat_open(struct inode *unused, struct file *file) +{ + /* XXX __d_cont */ + struct cgroup *cont = file->f_dentry->d_parent->d_fsdata; + + file->f_op = &mem_control_stat_file_operations; + return single_open(file, mem_control_stat_show, cont); +} + static struct cftype mem_cgroup_files[] = { { .name = "usage_in_bytes", .private = RES_USAGE, - .read_u64 = mem_cgroup_read, - }, - { - .name = "max_usage_in_bytes", - .private = RES_MAX_USAGE, - .trigger = mem_cgroup_reset, - .read_u64 = mem_cgroup_read, + .read = mem_cgroup_read, }, { .name = "limit_in_bytes", .private = RES_LIMIT, .write = mem_cgroup_write, - .read_u64 = mem_cgroup_read, + .read = mem_cgroup_read, }, { .name = "failcnt", .private = RES_FAILCNT, - .trigger = mem_cgroup_reset, - .read_u64 = mem_cgroup_read, + .read = mem_cgroup_read, }, { .name = "force_empty", - .trigger = mem_force_empty_write, + .write = mem_force_empty_write, + .read = mem_force_empty_read, }, { .name = "stat", - .read_map = mem_control_stat_show, + .open = mem_control_stat_open, }, }; @@ -984,29 +1010,6 @@ static void free_mem_cgroup_per_zone_info(struct mem_cgroup *mem, int node) kfree(mem->info.nodeinfo[node]); } -static struct mem_cgroup *mem_cgroup_alloc(void) -{ - struct mem_cgroup *mem; - - if (sizeof(*mem) < PAGE_SIZE) - mem = kmalloc(sizeof(*mem), GFP_KERNEL); - else - mem = vmalloc(sizeof(*mem)); - - if (mem) - memset(mem, 0, sizeof(*mem)); - return mem; -} - -static void mem_cgroup_free(struct mem_cgroup *mem) -{ - if (sizeof(*mem) < PAGE_SIZE) - kfree(mem); - else - vfree(mem); -} - - static struct cgroup_subsys_state * mem_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cont) { @@ -1015,15 +1018,17 @@ mem_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cont) if (unlikely((cont->parent) == NULL)) { mem = &init_mem_cgroup; - page_cgroup_cache = KMEM_CACHE(page_cgroup, SLAB_PANIC); - } else { - mem = mem_cgroup_alloc(); - if (!mem) - return ERR_PTR(-ENOMEM); - } + init_mm.mem_cgroup = mem; + } else + mem = kzalloc(sizeof(struct mem_cgroup), GFP_KERNEL); + + if (mem == NULL) + return ERR_PTR(-ENOMEM); res_counter_init(&mem->res); + memset(&mem->info, 0, sizeof(mem->info)); + for_each_node_state(node, N_POSSIBLE) if (alloc_mem_cgroup_per_zone_info(mem, node)) goto free_out; @@ -1033,7 +1038,7 @@ mem_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cont) for_each_node_state(node, N_POSSIBLE) free_mem_cgroup_per_zone_info(mem, node); if (cont->parent != NULL) - mem_cgroup_free(mem); + kfree(mem); return ERR_PTR(-ENOMEM); } @@ -1053,7 +1058,7 @@ static void mem_cgroup_destroy(struct cgroup_subsys *ss, for_each_node_state(node, N_POSSIBLE) free_mem_cgroup_per_zone_info(mem, node); - mem_cgroup_free(mem_cgroup_from_cont(cont)); + kfree(mem_cgroup_from_cont(cont)); } static int mem_cgroup_populate(struct cgroup_subsys *ss, @@ -1093,6 +1098,10 @@ static void mem_cgroup_move_task(struct cgroup_subsys *ss, if (!thread_group_leader(p)) goto out; + css_get(&mem->css); + rcu_assign_pointer(mm->mem_cgroup, mem); + css_put(&old_mem->css); + out: mmput(mm); } diff --git a/trunk/mm/mmap.c b/trunk/mm/mmap.c index fac66337da2a..677d184b0d42 100644 --- a/trunk/mm/mmap.c +++ b/trunk/mm/mmap.c @@ -230,11 +230,8 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma) might_sleep(); if (vma->vm_ops && vma->vm_ops->close) vma->vm_ops->close(vma); - if (vma->vm_file) { + if (vma->vm_file) fput(vma->vm_file); - if (vma->vm_flags & VM_EXECUTABLE) - removed_exe_file_vma(vma->vm_mm); - } mpol_put(vma_policy(vma)); kmem_cache_free(vm_area_cachep, vma); return next; @@ -626,11 +623,8 @@ again: remove_next = 1 + (end > next->vm_end); spin_unlock(&mapping->i_mmap_lock); if (remove_next) { - if (file) { + if (file) fput(file); - if (next->vm_flags & VM_EXECUTABLE) - removed_exe_file_vma(mm); - } mm->map_count--; mpol_put(vma_policy(next)); kmem_cache_free(vm_area_cachep, next); @@ -1160,8 +1154,6 @@ unsigned long mmap_region(struct file *file, unsigned long addr, error = file->f_op->mmap(file, vma); if (error) goto unmap_and_free_vma; - if (vm_flags & VM_EXECUTABLE) - added_exe_file_vma(mm); } else if (vm_flags & VM_SHARED) { error = shmem_zero_setup(vma); if (error) @@ -1193,8 +1185,6 @@ unsigned long mmap_region(struct file *file, unsigned long addr, mpol_put(vma_policy(vma)); kmem_cache_free(vm_area_cachep, vma); fput(file); - if (vm_flags & VM_EXECUTABLE) - removed_exe_file_vma(mm); } else { vma_link(mm, vma, prev, rb_link, rb_parent); file = vma->vm_file; @@ -1827,11 +1817,8 @@ int split_vma(struct mm_struct * mm, struct vm_area_struct * vma, } vma_set_policy(new, pol); - if (new->vm_file) { + if (new->vm_file) get_file(new->vm_file); - if (vma->vm_flags & VM_EXECUTABLE) - added_exe_file_vma(mm); - } if (new->vm_ops && new->vm_ops->open) new->vm_ops->open(new); @@ -2148,11 +2135,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap, new_vma->vm_start = addr; new_vma->vm_end = addr + len; new_vma->vm_pgoff = pgoff; - if (new_vma->vm_file) { + if (new_vma->vm_file) get_file(new_vma->vm_file); - if (vma->vm_flags & VM_EXECUTABLE) - added_exe_file_vma(mm); - } if (new_vma->vm_ops && new_vma->vm_ops->open) new_vma->vm_ops->open(new_vma); vma_link(mm, new_vma, prev, rb_link, rb_parent); diff --git a/trunk/mm/nommu.c b/trunk/mm/nommu.c index ef8c62cec697..1d32fe89d57b 100644 --- a/trunk/mm/nommu.c +++ b/trunk/mm/nommu.c @@ -966,13 +966,8 @@ unsigned long do_mmap_pgoff(struct file *file, INIT_LIST_HEAD(&vma->anon_vma_node); atomic_set(&vma->vm_usage, 1); - if (file) { + if (file) get_file(file); - if (vm_flags & VM_EXECUTABLE) { - added_exe_file_vma(current->mm); - vma->vm_mm = current->mm; - } - } vma->vm_file = file; vma->vm_flags = vm_flags; vma->vm_start = addr; @@ -1027,11 +1022,8 @@ unsigned long do_mmap_pgoff(struct file *file, up_write(&nommu_vma_sem); kfree(vml); if (vma) { - if (vma->vm_file) { + if (vma->vm_file) fput(vma->vm_file); - if (vma->vm_flags & VM_EXECUTABLE) - removed_exe_file_vma(vma->vm_mm); - } kfree(vma); } return ret; @@ -1061,7 +1053,7 @@ EXPORT_SYMBOL(do_mmap_pgoff); /* * handle mapping disposal for uClinux */ -static void put_vma(struct mm_struct *mm, struct vm_area_struct *vma) +static void put_vma(struct vm_area_struct *vma) { if (vma) { down_write(&nommu_vma_sem); @@ -1083,11 +1075,8 @@ static void put_vma(struct mm_struct *mm, struct vm_area_struct *vma) realalloc -= kobjsize(vma); askedalloc -= sizeof(*vma); - if (vma->vm_file) { + if (vma->vm_file) fput(vma->vm_file); - if (vma->vm_flags & VM_EXECUTABLE) - removed_exe_file_vma(mm); - } kfree(vma); } @@ -1124,7 +1113,7 @@ int do_munmap(struct mm_struct *mm, unsigned long addr, size_t len) found: vml = *parent; - put_vma(mm, vml->vma); + put_vma(vml->vma); *parent = vml->next; realalloc -= kobjsize(vml); @@ -1169,7 +1158,7 @@ void exit_mmap(struct mm_struct * mm) while ((tmp = mm->context.vmlist)) { mm->context.vmlist = tmp->next; - put_vma(mm, tmp->vma); + put_vma(tmp->vma); realalloc -= kobjsize(tmp); askedalloc -= sizeof(*tmp); diff --git a/trunk/mm/page_alloc.c b/trunk/mm/page_alloc.c index 0a502e99ee22..d1cf4f05dcda 100644 --- a/trunk/mm/page_alloc.c +++ b/trunk/mm/page_alloc.c @@ -1461,8 +1461,7 @@ __alloc_pages_internal(gfp_t gfp_mask, unsigned int order, struct task_struct *p = current; int do_retry; int alloc_flags; - unsigned long did_some_progress; - unsigned long pages_reclaimed = 0; + int did_some_progress; might_sleep_if(wait); @@ -1612,26 +1611,14 @@ __alloc_pages_internal(gfp_t gfp_mask, unsigned int order, * Don't let big-order allocations loop unless the caller explicitly * requests that. Wait for some write requests to complete then retry. * - * In this implementation, order <= PAGE_ALLOC_COSTLY_ORDER - * means __GFP_NOFAIL, but that may not be true in other - * implementations. - * - * For order > PAGE_ALLOC_COSTLY_ORDER, if __GFP_REPEAT is - * specified, then we retry until we no longer reclaim any pages - * (above), or we've reclaimed an order of pages at least as - * large as the allocation's order. In both cases, if the - * allocation still fails, we stop retrying. + * In this implementation, __GFP_REPEAT means __GFP_NOFAIL for order + * <= 3, but that may not be true in other implementations. */ - pages_reclaimed += did_some_progress; do_retry = 0; if (!(gfp_mask & __GFP_NORETRY)) { - if (order <= PAGE_ALLOC_COSTLY_ORDER) { + if ((order <= PAGE_ALLOC_COSTLY_ORDER) || + (gfp_mask & __GFP_REPEAT)) do_retry = 1; - } else { - if (gfp_mask & __GFP_REPEAT && - pages_reclaimed < (1 << order)) - do_retry = 1; - } if (gfp_mask & __GFP_NOFAIL) do_retry = 1; } @@ -2537,9 +2524,7 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone, struct page *page; unsigned long end_pfn = start_pfn + size; unsigned long pfn; - struct zone *z; - z = &NODE_DATA(nid)->node_zones[zone]; for (pfn = start_pfn; pfn < end_pfn; pfn++) { /* * There can be holes in boot-time mem_map[]s @@ -2557,6 +2542,7 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone, init_page_count(page); reset_page_mapcount(page); SetPageReserved(page); + /* * Mark the block movable so that blocks are reserved for * movable at startup. This will force kernel allocations @@ -2565,15 +2551,8 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone, * kernel allocations are made. Later some blocks near * the start are marked MIGRATE_RESERVE by * setup_zone_migrate_reserve() - * - * bitmap is created for zone's valid pfn range. but memmap - * can be created for invalid pages (for alignment) - * check here not to call set_pageblock_migratetype() against - * pfn out of zone. */ - if ((z->zone_start_pfn <= pfn) - && (pfn < z->zone_start_pfn + z->spanned_pages) - && !(pfn & (pageblock_nr_pages - 1))) + if ((pfn & (pageblock_nr_pages-1))) set_pageblock_migratetype(page, MIGRATE_MOVABLE); INIT_LIST_HEAD(&page->lru); @@ -4485,8 +4464,6 @@ void set_pageblock_flags_group(struct page *page, unsigned long flags, pfn = page_to_pfn(page); bitmap = get_pageblock_bitmap(zone, pfn); bitidx = pfn_to_bitidx(zone, pfn); - VM_BUG_ON(pfn < zone->zone_start_pfn); - VM_BUG_ON(pfn >= zone->zone_start_pfn + zone->spanned_pages); for (; start_bitidx <= end_bitidx; start_bitidx++, value <<= 1) if (flags & value) diff --git a/trunk/mm/slub.c b/trunk/mm/slub.c index b145e798bf3d..992ecd4f0d39 100644 --- a/trunk/mm/slub.c +++ b/trunk/mm/slub.c @@ -2978,7 +2978,7 @@ void __init kmem_cache_init(void) kmalloc_caches[0].refcount = -1; caches++; - hotplug_memory_notifier(slab_memory_callback, SLAB_CALLBACK_PRI); + hotplug_memory_notifier(slab_memory_callback, 1); #endif /* Able to allocate the per node structures */ diff --git a/trunk/mm/swapfile.c b/trunk/mm/swapfile.c index bd1bb5920306..67051be7083a 100644 --- a/trunk/mm/swapfile.c +++ b/trunk/mm/swapfile.c @@ -1426,7 +1426,11 @@ static const struct file_operations proc_swaps_operations = { static int __init procswaps_init(void) { - proc_create("swaps", 0, NULL, &proc_swaps_operations); + struct proc_dir_entry *entry; + + entry = create_proc_entry("swaps", 0, NULL); + if (entry) + entry->proc_fops = &proc_swaps_operations; return 0; } __initcall(procswaps_init); diff --git a/trunk/mm/vmscan.c b/trunk/mm/vmscan.c index 12e8627c9747..eceac9f9032f 100644 --- a/trunk/mm/vmscan.c +++ b/trunk/mm/vmscan.c @@ -1299,9 +1299,6 @@ static unsigned long shrink_zones(int priority, struct zonelist *zonelist, * hope that some of these pages can be written. But if the allocating task * holds filesystem locks which prevent writeout this might not work, and the * allocation attempt will fail. - * - * returns: 0, if no pages reclaimed - * else, the number of pages reclaimed */ static unsigned long do_try_to_free_pages(struct zonelist *zonelist, struct scan_control *sc) @@ -1350,7 +1347,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist, } total_scanned += sc->nr_scanned; if (nr_reclaimed >= sc->swap_cluster_max) { - ret = nr_reclaimed; + ret = 1; goto out; } @@ -1373,7 +1370,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist, } /* top priority shrink_caches still had more to do? don't OOM, then */ if (!sc->all_unreclaimable && scan_global_lru(sc)) - ret = nr_reclaimed; + ret = 1; out: /* * Now that we've scanned all the zones at this priority level, note diff --git a/trunk/net/core/dev.c b/trunk/net/core/dev.c index ed49da592051..e1df1ab3e04a 100644 --- a/trunk/net/core/dev.c +++ b/trunk/net/core/dev.c @@ -1524,7 +1524,7 @@ static int dev_gso_segment(struct sk_buff *skb) if (!segs) return 0; - if (IS_ERR(segs)) + if (unlikely(IS_ERR(segs))) return PTR_ERR(segs); skb->next = segs; diff --git a/trunk/net/ipv4/af_inet.c b/trunk/net/ipv4/af_inet.c index 24eca23c2db3..f2b5270efdaa 100644 --- a/trunk/net/ipv4/af_inet.c +++ b/trunk/net/ipv4/af_inet.c @@ -1234,7 +1234,7 @@ static struct sk_buff *inet_gso_segment(struct sk_buff *skb, int features) segs = ops->gso_segment(skb, features); rcu_read_unlock(); - if (!segs || IS_ERR(segs)) + if (!segs || unlikely(IS_ERR(segs))) goto out; skb = segs; diff --git a/trunk/net/irda/irnet/irnet_irda.c b/trunk/net/irda/irnet/irnet_irda.c index 75497e55927d..a4f1439ffdd8 100644 --- a/trunk/net/irda/irnet/irnet_irda.c +++ b/trunk/net/irda/irnet/irnet_irda.c @@ -9,7 +9,6 @@ */ #include "irnet_irda.h" /* Private header */ -#include /* * PPP disconnect work: we need to make sure we're in @@ -1718,23 +1717,34 @@ irnet_expiry_indication(discinfo_t * expiry, */ #ifdef CONFIG_PROC_FS +/*------------------------------------------------------------------*/ +/* + * Function irnet_proc_read (buf, start, offset, len, unused) + * + * Give some info to the /proc file system + */ static int -irnet_proc_show(struct seq_file *m, void *v) +irnet_proc_read(char * buf, + char ** start, + off_t offset, + int len) { irnet_socket * self; char * state; int i = 0; + len = 0; + /* Get the IrNET server information... */ - seq_printf(m, "IrNET server - "); - seq_printf(m, "IrDA state: %s, ", + len += sprintf(buf+len, "IrNET server - "); + len += sprintf(buf+len, "IrDA state: %s, ", (irnet_server.running ? "running" : "dead")); - seq_printf(m, "stsap_sel: %02x, ", irnet_server.s.stsap_sel); - seq_printf(m, "dtsap_sel: %02x\n", irnet_server.s.dtsap_sel); + len += sprintf(buf+len, "stsap_sel: %02x, ", irnet_server.s.stsap_sel); + len += sprintf(buf+len, "dtsap_sel: %02x\n", irnet_server.s.dtsap_sel); /* Do we need to continue ? */ if(!irnet_server.running) - return 0; + return len; /* Protect access to the instance list */ spin_lock_bh(&irnet_server.spinlock); @@ -1744,23 +1754,23 @@ irnet_proc_show(struct seq_file *m, void *v) while(self != NULL) { /* Start printing info about the socket. */ - seq_printf(m, "\nIrNET socket %d - ", i++); + len += sprintf(buf+len, "\nIrNET socket %d - ", i++); /* First, get the requested configuration */ - seq_printf(m, "Requested IrDA name: \"%s\", ", self->rname); - seq_printf(m, "daddr: %08x, ", self->rdaddr); - seq_printf(m, "saddr: %08x\n", self->rsaddr); + len += sprintf(buf+len, "Requested IrDA name: \"%s\", ", self->rname); + len += sprintf(buf+len, "daddr: %08x, ", self->rdaddr); + len += sprintf(buf+len, "saddr: %08x\n", self->rsaddr); /* Second, get all the PPP info */ - seq_printf(m, " PPP state: %s", + len += sprintf(buf+len, " PPP state: %s", (self->ppp_open ? "registered" : "unregistered")); if(self->ppp_open) { - seq_printf(m, ", unit: ppp%d", + len += sprintf(buf+len, ", unit: ppp%d", ppp_unit_number(&self->chan)); - seq_printf(m, ", channel: %d", + len += sprintf(buf+len, ", channel: %d", ppp_channel_index(&self->chan)); - seq_printf(m, ", mru: %d", + len += sprintf(buf+len, ", mru: %d", self->mru); /* Maybe add self->flags ? Later... */ } @@ -1779,10 +1789,10 @@ irnet_proc_show(struct seq_file *m, void *v) state = "weird"; else state = "idle"; - seq_printf(m, "\n IrDA state: %s, ", state); - seq_printf(m, "daddr: %08x, ", self->daddr); - seq_printf(m, "stsap_sel: %02x, ", self->stsap_sel); - seq_printf(m, "dtsap_sel: %02x\n", self->dtsap_sel); + len += sprintf(buf+len, "\n IrDA state: %s, ", state); + len += sprintf(buf+len, "daddr: %08x, ", self->daddr); + len += sprintf(buf+len, "stsap_sel: %02x, ", self->stsap_sel); + len += sprintf(buf+len, "dtsap_sel: %02x\n", self->dtsap_sel); /* Next socket, please... */ self = (irnet_socket *) hashbin_get_next(irnet_server.list); @@ -1791,21 +1801,8 @@ irnet_proc_show(struct seq_file *m, void *v) /* Spin lock end */ spin_unlock_bh(&irnet_server.spinlock); - return 0; + return len; } - -static int irnet_proc_open(struct inode *inode, struct file *file) -{ - return single_open(file, irnet_proc_show, NULL); -} - -static const struct file_operations irnet_proc_fops = { - .owner = THIS_MODULE, - .open = irnet_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; #endif /* PROC_FS */ @@ -1844,7 +1841,7 @@ irda_irnet_init(void) #ifdef CONFIG_PROC_FS /* Add a /proc file for irnet infos */ - proc_create("irnet", 0, proc_irda, &irnet_proc_fops); + create_proc_info_entry("irnet", 0, proc_irda, irnet_proc_read); #endif /* CONFIG_PROC_FS */ /* Setup the IrNET server */ diff --git a/trunk/net/irda/irnet/irnet_irda.h b/trunk/net/irda/irnet/irnet_irda.h index 3e408952a3f1..0ba92d0d5204 100644 --- a/trunk/net/irda/irnet/irnet_irda.h +++ b/trunk/net/irda/irnet/irnet_irda.h @@ -159,6 +159,14 @@ static void DISCOVERY_MODE, void *); #endif +/* -------------------------- PROC ENTRY -------------------------- */ +#ifdef CONFIG_PROC_FS +static int + irnet_proc_read(char *, + char **, + off_t, + int); +#endif /* CONFIG_PROC_FS */ /**************************** VARIABLES ****************************/ diff --git a/trunk/net/key/af_key.c b/trunk/net/key/af_key.c index 9e7236ff6bcc..2403a31fe0f6 100644 --- a/trunk/net/key/af_key.c +++ b/trunk/net/key/af_key.c @@ -1498,8 +1498,7 @@ static int pfkey_add(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hdr, err = xfrm_state_update(x); xfrm_audit_state_add(x, err ? 0 : 1, - audit_get_loginuid(current), - audit_get_sessionid(current), 0); + audit_get_loginuid(current), 0); if (err < 0) { x->km.state = XFRM_STATE_DEAD; @@ -1553,8 +1552,7 @@ static int pfkey_delete(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h km_state_notify(x, &c); out: xfrm_audit_state_delete(x, err ? 0 : 1, - audit_get_loginuid(current), - audit_get_sessionid(current), 0); + audit_get_loginuid(current), 0); xfrm_state_put(x); return err; @@ -1730,7 +1728,6 @@ static int pfkey_flush(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hd return -EINVAL; audit_info.loginuid = audit_get_loginuid(current); - audit_info.sessionid = audit_get_sessionid(current); audit_info.secid = 0; err = xfrm_state_flush(proto, &audit_info); if (err) @@ -2327,8 +2324,7 @@ static int pfkey_spdadd(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h hdr->sadb_msg_type != SADB_X_SPDUPDATE); xfrm_audit_policy_add(xp, err ? 0 : 1, - audit_get_loginuid(current), - audit_get_sessionid(current), 0); + audit_get_loginuid(current), 0); if (err) goto out; @@ -2410,8 +2406,7 @@ static int pfkey_spddelete(struct sock *sk, struct sk_buff *skb, struct sadb_msg return -ENOENT; xfrm_audit_policy_delete(xp, err ? 0 : 1, - audit_get_loginuid(current), - audit_get_sessionid(current), 0); + audit_get_loginuid(current), 0); if (err) goto out; @@ -2672,8 +2667,7 @@ static int pfkey_spdget(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h if (delete) { xfrm_audit_policy_delete(xp, err ? 0 : 1, - audit_get_loginuid(current), - audit_get_sessionid(current), 0); + audit_get_loginuid(current), 0); if (err) goto out; @@ -2773,7 +2767,6 @@ static int pfkey_spdflush(struct sock *sk, struct sk_buff *skb, struct sadb_msg int err; audit_info.loginuid = audit_get_loginuid(current); - audit_info.sessionid = audit_get_sessionid(current); audit_info.secid = 0; err = xfrm_policy_flush(XFRM_POLICY_TYPE_MAIN, &audit_info); if (err) diff --git a/trunk/net/netfilter/nf_queue.c b/trunk/net/netfilter/nf_queue.c index 582ec3efc8a5..bbd26893c0c4 100644 --- a/trunk/net/netfilter/nf_queue.c +++ b/trunk/net/netfilter/nf_queue.c @@ -214,7 +214,7 @@ int nf_queue(struct sk_buff *skb, segs = skb_gso_segment(skb, 0); kfree_skb(skb); - if (IS_ERR(segs)) + if (unlikely(IS_ERR(segs))) return 1; do { diff --git a/trunk/net/netlabel/netlabel_unlabeled.c b/trunk/net/netlabel/netlabel_unlabeled.c index 0099da5b2591..d282ad1570a7 100644 --- a/trunk/net/netlabel/netlabel_unlabeled.c +++ b/trunk/net/netlabel/netlabel_unlabeled.c @@ -1780,7 +1780,6 @@ int __init netlbl_unlabel_defconf(void) * messages so don't worry to much about these values. */ security_task_getsecid(current, &audit_info.secid); audit_info.loginuid = 0; - audit_info.sessionid = 0; entry = kzalloc(sizeof(*entry), GFP_KERNEL); if (entry == NULL) diff --git a/trunk/net/netlabel/netlabel_user.c b/trunk/net/netlabel/netlabel_user.c index 68706b4e3bf8..b17d4203806e 100644 --- a/trunk/net/netlabel/netlabel_user.c +++ b/trunk/net/netlabel/netlabel_user.c @@ -107,9 +107,7 @@ struct audit_buffer *netlbl_audit_start_common(int type, if (audit_buf == NULL) return NULL; - audit_log_format(audit_buf, "netlabel: auid=%u ses=%u", - audit_info->loginuid, - audit_info->sessionid); + audit_log_format(audit_buf, "netlabel: auid=%u", audit_info->loginuid); if (audit_info->secid != 0 && security_secid_to_secctx(audit_info->secid, diff --git a/trunk/net/netlabel/netlabel_user.h b/trunk/net/netlabel/netlabel_user.h index 6caef8b20611..6d7f4ab46c2b 100644 --- a/trunk/net/netlabel/netlabel_user.h +++ b/trunk/net/netlabel/netlabel_user.h @@ -51,7 +51,6 @@ static inline void netlbl_netlink_auditinfo(struct sk_buff *skb, { audit_info->secid = NETLINK_CB(skb).sid; audit_info->loginuid = NETLINK_CB(skb).loginuid; - audit_info->sessionid = NETLINK_CB(skb).sessionid; } /* NetLabel NETLINK I/O functions */ diff --git a/trunk/net/netlink/af_netlink.c b/trunk/net/netlink/af_netlink.c index 9b97f8006c9c..46f3e44bb83a 100644 --- a/trunk/net/netlink/af_netlink.c +++ b/trunk/net/netlink/af_netlink.c @@ -1248,7 +1248,6 @@ static int netlink_sendmsg(struct kiocb *kiocb, struct socket *sock, NETLINK_CB(skb).pid = nlk->pid; NETLINK_CB(skb).dst_group = dst_group; NETLINK_CB(skb).loginuid = audit_get_loginuid(current); - NETLINK_CB(skb).sessionid = audit_get_sessionid(current); security_task_getsecid(current, &(NETLINK_CB(skb).sid)); memcpy(NETLINK_CREDS(skb), &siocb->scm->creds, sizeof(struct ucred)); diff --git a/trunk/net/xfrm/xfrm_output.c b/trunk/net/xfrm/xfrm_output.c index 09cd9c0c2d80..2519129c6d21 100644 --- a/trunk/net/xfrm/xfrm_output.c +++ b/trunk/net/xfrm/xfrm_output.c @@ -150,7 +150,7 @@ static int xfrm_output_gso(struct sk_buff *skb) segs = skb_gso_segment(skb, 0); kfree_skb(skb); - if (IS_ERR(segs)) + if (unlikely(IS_ERR(segs))) return PTR_ERR(segs); do { diff --git a/trunk/net/xfrm/xfrm_policy.c b/trunk/net/xfrm/xfrm_policy.c index cae9fd815543..e0c0390613c0 100644 --- a/trunk/net/xfrm/xfrm_policy.c +++ b/trunk/net/xfrm/xfrm_policy.c @@ -762,7 +762,6 @@ xfrm_policy_flush_secctx_check(u8 type, struct xfrm_audit *audit_info) if (err) { xfrm_audit_policy_delete(pol, 0, audit_info->loginuid, - audit_info->sessionid, audit_info->secid); return err; } @@ -778,7 +777,6 @@ xfrm_policy_flush_secctx_check(u8 type, struct xfrm_audit *audit_info) if (err) { xfrm_audit_policy_delete(pol, 0, audit_info->loginuid, - audit_info->sessionid, audit_info->secid); return err; } @@ -821,7 +819,6 @@ int xfrm_policy_flush(u8 type, struct xfrm_audit *audit_info) write_unlock_bh(&xfrm_policy_lock); xfrm_audit_policy_delete(pol, 1, audit_info->loginuid, - audit_info->sessionid, audit_info->secid); xfrm_policy_kill(pol); @@ -844,7 +841,6 @@ int xfrm_policy_flush(u8 type, struct xfrm_audit *audit_info) xfrm_audit_policy_delete(pol, 1, audit_info->loginuid, - audit_info->sessionid, audit_info->secid); xfrm_policy_kill(pol); killed++; @@ -2476,14 +2472,14 @@ static void xfrm_audit_common_policyinfo(struct xfrm_policy *xp, } void xfrm_audit_policy_add(struct xfrm_policy *xp, int result, - uid_t auid, u32 sessionid, u32 secid) + u32 auid, u32 secid) { struct audit_buffer *audit_buf; audit_buf = xfrm_audit_start("SPD-add"); if (audit_buf == NULL) return; - xfrm_audit_helper_usrinfo(auid, sessionid, secid, audit_buf); + xfrm_audit_helper_usrinfo(auid, secid, audit_buf); audit_log_format(audit_buf, " res=%u", result); xfrm_audit_common_policyinfo(xp, audit_buf); audit_log_end(audit_buf); @@ -2491,14 +2487,14 @@ void xfrm_audit_policy_add(struct xfrm_policy *xp, int result, EXPORT_SYMBOL_GPL(xfrm_audit_policy_add); void xfrm_audit_policy_delete(struct xfrm_policy *xp, int result, - uid_t auid, u32 sessionid, u32 secid) + u32 auid, u32 secid) { struct audit_buffer *audit_buf; audit_buf = xfrm_audit_start("SPD-delete"); if (audit_buf == NULL) return; - xfrm_audit_helper_usrinfo(auid, sessionid, secid, audit_buf); + xfrm_audit_helper_usrinfo(auid, secid, audit_buf); audit_log_format(audit_buf, " res=%u", result); xfrm_audit_common_policyinfo(xp, audit_buf); audit_log_end(audit_buf); diff --git a/trunk/net/xfrm/xfrm_state.c b/trunk/net/xfrm/xfrm_state.c index 72fddafd891a..fac27ce770d5 100644 --- a/trunk/net/xfrm/xfrm_state.c +++ b/trunk/net/xfrm/xfrm_state.c @@ -496,8 +496,7 @@ static void xfrm_timer_handler(unsigned long data) km_state_expired(x, 1, 0); xfrm_audit_state_delete(x, err ? 0 : 1, - audit_get_loginuid(current), - audit_get_sessionid(current), 0); + audit_get_loginuid(current), 0); out: spin_unlock(&x->lock); @@ -604,7 +603,6 @@ xfrm_state_flush_secctx_check(u8 proto, struct xfrm_audit *audit_info) (err = security_xfrm_state_delete(x)) != 0) { xfrm_audit_state_delete(x, 0, audit_info->loginuid, - audit_info->sessionid, audit_info->secid); return err; } @@ -643,7 +641,6 @@ int xfrm_state_flush(u8 proto, struct xfrm_audit *audit_info) err = xfrm_state_delete(x); xfrm_audit_state_delete(x, err ? 0 : 1, audit_info->loginuid, - audit_info->sessionid, audit_info->secid); xfrm_state_put(x); @@ -2126,14 +2123,14 @@ static void xfrm_audit_helper_pktinfo(struct sk_buff *skb, u16 family, } void xfrm_audit_state_add(struct xfrm_state *x, int result, - uid_t auid, u32 sessionid, u32 secid) + u32 auid, u32 secid) { struct audit_buffer *audit_buf; audit_buf = xfrm_audit_start("SAD-add"); if (audit_buf == NULL) return; - xfrm_audit_helper_usrinfo(auid, sessionid, secid, audit_buf); + xfrm_audit_helper_usrinfo(auid, secid, audit_buf); xfrm_audit_helper_sainfo(x, audit_buf); audit_log_format(audit_buf, " res=%u", result); audit_log_end(audit_buf); @@ -2141,14 +2138,14 @@ void xfrm_audit_state_add(struct xfrm_state *x, int result, EXPORT_SYMBOL_GPL(xfrm_audit_state_add); void xfrm_audit_state_delete(struct xfrm_state *x, int result, - uid_t auid, u32 sessionid, u32 secid) + u32 auid, u32 secid) { struct audit_buffer *audit_buf; audit_buf = xfrm_audit_start("SAD-delete"); if (audit_buf == NULL) return; - xfrm_audit_helper_usrinfo(auid, sessionid, secid, audit_buf); + xfrm_audit_helper_usrinfo(auid, secid, audit_buf); xfrm_audit_helper_sainfo(x, audit_buf); audit_log_format(audit_buf, " res=%u", result); audit_log_end(audit_buf); diff --git a/trunk/net/xfrm/xfrm_user.c b/trunk/net/xfrm/xfrm_user.c index a1b0fbe3ea35..22a30ae582a2 100644 --- a/trunk/net/xfrm/xfrm_user.c +++ b/trunk/net/xfrm/xfrm_user.c @@ -407,9 +407,6 @@ static int xfrm_add_sa(struct sk_buff *skb, struct nlmsghdr *nlh, struct xfrm_state *x; int err; struct km_event c; - uid_t loginuid = NETLINK_CB(skb).loginuid; - u32 sessionid = NETLINK_CB(skb).sessionid; - u32 sid = NETLINK_CB(skb).sid; err = verify_newsa_info(p, attrs); if (err) @@ -425,7 +422,8 @@ static int xfrm_add_sa(struct sk_buff *skb, struct nlmsghdr *nlh, else err = xfrm_state_update(x); - xfrm_audit_state_add(x, err ? 0 : 1, loginuid, sessionid, sid); + xfrm_audit_state_add(x, err ? 0 : 1, NETLINK_CB(skb).loginuid, + NETLINK_CB(skb).sid); if (err < 0) { x->km.state = XFRM_STATE_DEAD; @@ -480,9 +478,6 @@ static int xfrm_del_sa(struct sk_buff *skb, struct nlmsghdr *nlh, int err = -ESRCH; struct km_event c; struct xfrm_usersa_id *p = nlmsg_data(nlh); - uid_t loginuid = NETLINK_CB(skb).loginuid; - u32 sessionid = NETLINK_CB(skb).sessionid; - u32 sid = NETLINK_CB(skb).sid; x = xfrm_user_state_lookup(p, attrs, &err); if (x == NULL) @@ -507,7 +502,8 @@ static int xfrm_del_sa(struct sk_buff *skb, struct nlmsghdr *nlh, km_state_notify(x, &c); out: - xfrm_audit_state_delete(x, err ? 0 : 1, loginuid, sessionid, sid); + xfrm_audit_state_delete(x, err ? 0 : 1, NETLINK_CB(skb).loginuid, + NETLINK_CB(skb).sid); xfrm_state_put(x); return err; } @@ -1127,9 +1123,6 @@ static int xfrm_add_policy(struct sk_buff *skb, struct nlmsghdr *nlh, struct km_event c; int err; int excl; - uid_t loginuid = NETLINK_CB(skb).loginuid; - u32 sessionid = NETLINK_CB(skb).sessionid; - u32 sid = NETLINK_CB(skb).sid; err = verify_newpolicy_info(p); if (err) @@ -1148,7 +1141,8 @@ static int xfrm_add_policy(struct sk_buff *skb, struct nlmsghdr *nlh, * a type XFRM_MSG_UPDPOLICY - JHS */ excl = nlh->nlmsg_type == XFRM_MSG_NEWPOLICY; err = xfrm_policy_insert(p->dir, xp, excl); - xfrm_audit_policy_add(xp, err ? 0 : 1, loginuid, sessionid, sid); + xfrm_audit_policy_add(xp, err ? 0 : 1, NETLINK_CB(skb).loginuid, + NETLINK_CB(skb).sid); if (err) { security_xfrm_policy_free(xp->security); @@ -1377,12 +1371,9 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh, NETLINK_CB(skb).pid); } } else { - uid_t loginuid = NETLINK_CB(skb).loginuid; - u32 sessionid = NETLINK_CB(skb).sessionid; - u32 sid = NETLINK_CB(skb).sid; - - xfrm_audit_policy_delete(xp, err ? 0 : 1, loginuid, sessionid, - sid); + xfrm_audit_policy_delete(xp, err ? 0 : 1, + NETLINK_CB(skb).loginuid, + NETLINK_CB(skb).sid); if (err != 0) goto out; @@ -1408,7 +1399,6 @@ static int xfrm_flush_sa(struct sk_buff *skb, struct nlmsghdr *nlh, int err; audit_info.loginuid = NETLINK_CB(skb).loginuid; - audit_info.sessionid = NETLINK_CB(skb).sessionid; audit_info.secid = NETLINK_CB(skb).sid; err = xfrm_state_flush(p->proto, &audit_info); if (err) @@ -1556,7 +1546,6 @@ static int xfrm_flush_policy(struct sk_buff *skb, struct nlmsghdr *nlh, return err; audit_info.loginuid = NETLINK_CB(skb).loginuid; - audit_info.sessionid = NETLINK_CB(skb).sessionid; audit_info.secid = NETLINK_CB(skb).sid; err = xfrm_policy_flush(type, &audit_info); if (err) @@ -1615,11 +1604,9 @@ static int xfrm_add_pol_expire(struct sk_buff *skb, struct nlmsghdr *nlh, read_unlock(&xp->lock); err = 0; if (up->hard) { - uid_t loginuid = NETLINK_CB(skb).loginuid; - uid_t sessionid = NETLINK_CB(skb).sessionid; - u32 sid = NETLINK_CB(skb).sid; xfrm_policy_delete(xp, p->dir); - xfrm_audit_policy_delete(xp, 1, loginuid, sessionid, sid); + xfrm_audit_policy_delete(xp, 1, NETLINK_CB(skb).loginuid, + NETLINK_CB(skb).sid); } else { // reset the timers here? @@ -1653,11 +1640,9 @@ static int xfrm_add_sa_expire(struct sk_buff *skb, struct nlmsghdr *nlh, km_state_expired(x, ue->hard, current->pid); if (ue->hard) { - uid_t loginuid = NETLINK_CB(skb).loginuid; - uid_t sessionid = NETLINK_CB(skb).sessionid; - u32 sid = NETLINK_CB(skb).sid; __xfrm_state_delete(x); - xfrm_audit_state_delete(x, 1, loginuid, sessionid, sid); + xfrm_audit_state_delete(x, 1, NETLINK_CB(skb).loginuid, + NETLINK_CB(skb).sid); } err = 0; out: diff --git a/trunk/samples/markers/marker-example.c b/trunk/samples/markers/marker-example.c index e90dc5d04392..05e438f8b4e2 100644 --- a/trunk/samples/markers/marker-example.c +++ b/trunk/samples/markers/marker-example.c @@ -33,8 +33,10 @@ static struct file_operations mark_ops = { static int example_init(void) { printk(KERN_ALERT "example init\n"); - pentry_example = proc_create("marker-example", 0444, NULL, &mark_ops); - if (!pentry_example) + pentry_example = create_proc_entry("marker-example", 0444, NULL); + if (pentry_example) + pentry_example->proc_fops = &mark_ops; + else return -EPERM; return 0; } diff --git a/trunk/scripts/Lindent b/trunk/scripts/Lindent index 9c4b3e2b7098..9468ec7971db 100755 --- a/trunk/scripts/Lindent +++ b/trunk/scripts/Lindent @@ -1,18 +1,2 @@ #!/bin/sh -PARAM="-npro -kr -i8 -ts8 -sob -l80 -ss -ncs -cp1" -RES=`indent --version` -V1=`echo $RES | cut -d' ' -f3 | cut -d'.' -f1` -V2=`echo $RES | cut -d' ' -f3 | cut -d'.' -f2` -V3=`echo $RES | cut -d' ' -f3 | cut -d'.' -f3` -if [ $V1 -gt 2 ]; then - PARAM="$PARAM -il0" -elif [ $V1 -eq 2 ]; then - if [ $V2 -gt 2 ]; then - PARAM="$PARAM -il0"; - elif [ $V2 -eq 2 ]; then - if [ $V3 -ge 10 ]; then - PARAM="$PARAM -il0" - fi - fi -fi -indent $PARAM "$@" +indent -npro -kr -i8 -ts8 -sob -l80 -ss -ncs -cp1 "$@" diff --git a/trunk/scripts/checkpatch.pl b/trunk/scripts/checkpatch.pl index b6bbbcdc557e..64ec4b8a51b5 100755 --- a/trunk/scripts/checkpatch.pl +++ b/trunk/scripts/checkpatch.pl @@ -9,7 +9,7 @@ my $P = $0; $P =~ s@.*/@@g; -my $V = '0.18'; +my $V = '0.16'; use Getopt::Long qw(:config no_auto_abbrev); @@ -131,17 +131,6 @@ our $Type; our $Declare; -our $UTF8 = qr { - [\x09\x0A\x0D\x20-\x7E] # ASCII - | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte - | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs - | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte - | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates - | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3 - | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15 - | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 -}x; - our @typeList = ( qr{void}, qr{char}, @@ -703,7 +692,7 @@ sub annotate_values { while (length($cur)) { @av_paren_type = ('E') if ($#av_paren_type < 0); print " <" . join('', @av_paren_type) . - "> <$type> <$av_pending>" if ($dbg_values > 1); + "> <$type> " if ($dbg_values > 1); if ($cur =~ /^(\s+)/o) { print "WS($1)\n" if ($dbg_values > 1); if ($1 =~ /\n/ && $av_preprocessor) { @@ -716,18 +705,9 @@ sub annotate_values { $type = 'T'; } elsif ($cur =~ /^(#\s*define\s*$Ident)(\(?)/o) { - print "DEFINE($1,$2)\n" if ($dbg_values > 1); + print "DEFINE($1)\n" if ($dbg_values > 1); $av_preprocessor = 1; - push(@av_paren_type, $type); - if ($2 ne '') { - $av_pending = 'N'; - } - $type = 'E'; - - } elsif ($cur =~ /^(#\s*undef\s*$Ident)/o) { - print "UNDEF($1)\n" if ($dbg_values > 1); - $av_preprocessor = 1; - push(@av_paren_type, $type); + $av_pending = 'N'; } elsif ($cur =~ /^(#\s*(?:ifdef|ifndef|if))/o) { print "PRE_START($1)\n" if ($dbg_values > 1); @@ -735,7 +715,7 @@ sub annotate_values { push(@av_paren_type, $type); push(@av_paren_type, $type); - $type = 'E'; + $type = 'N'; } elsif ($cur =~ /^(#\s*(?:else|elif))/o) { print "PRE_RESTART($1)\n" if ($dbg_values > 1); @@ -743,7 +723,7 @@ sub annotate_values { push(@av_paren_type, $av_paren_type[$#av_paren_type]); - $type = 'E'; + $type = 'N'; } elsif ($cur =~ /^(#\s*(?:endif))/o) { print "PRE_END($1)\n" if ($dbg_values > 1); @@ -754,16 +734,11 @@ sub annotate_values { # one does, and continue as if the #endif was not here. pop(@av_paren_type); push(@av_paren_type, $type); - $type = 'E'; + $type = 'N'; } elsif ($cur =~ /^(\\\n)/o) { print "PRECONT($1)\n" if ($dbg_values > 1); - } elsif ($cur =~ /^(__attribute__)\s*\(?/o) { - print "ATTR($1)\n" if ($dbg_values > 1); - $av_pending = $type; - $type = 'N'; - } elsif ($cur =~ /^(sizeof)\s*(\()?/o) { print "SIZEOF($1)\n" if ($dbg_values > 1); if (defined $2) { @@ -955,7 +930,7 @@ sub process { # edge is a close comment then we must be in a comment # at context start. my $edge; - for (my $ln = $linenr + 1; $ln < ($linenr + $realcnt); $ln++) { + for (my $ln = $linenr; $ln < ($linenr + $realcnt); $ln++) { next if ($line =~ /^-/); ($edge) = ($rawlines[$ln - 1] =~ m@(/\*|\*/)@); last if (defined $edge); @@ -976,9 +951,9 @@ sub process { ##print "COMMENT:$in_comment edge<$edge> $rawline\n"; sanitise_line_reset($in_comment); - } elsif ($realcnt && $rawline =~ /^(?:\+| |$)/) { + } elsif ($realcnt) { # Standardise the strings and chars within the input to - # simplify matching -- only bother with positive lines. + # simplify matching. $line = sanitise_line($rawline); } push(@lines, $line); @@ -1091,14 +1066,17 @@ sub process { # UTF-8 regex found at http://www.w3.org/International/questions/qa-forms-utf-8.en.php if (($realfile =~ /^$/ || $line =~ /^\+/) && - $rawline !~ m/^$UTF8*$/) { - my ($utf8_prefix) = ($rawline =~ /^($UTF8*)/); - - my $blank = copy_spacing($rawline); - my $ptr = substr($blank, 0, length($utf8_prefix)) . "^"; - my $hereptr = "$hereline$ptr\n"; - - ERROR("Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr); + !($rawline =~ m/^( + [\x09\x0A\x0D\x20-\x7E] # ASCII + | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte + | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs + | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte + | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates + | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3 + | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15 + | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 + )*$/x )) { + ERROR("Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $herecurr); } #ignore lines being removed @@ -1134,7 +1112,7 @@ sub process { if ($rawline =~ /^\+\s* \t\s*\S/ || $rawline =~ /^\+\s* \s*/) { my $herevet = "$here\n" . cat_vet($rawline) . "\n"; - ERROR("code indent should use tabs where possible\n" . $herevet); + ERROR("use tabs not spaces\n" . $herevet); } # check for RCS/CVS revision markers @@ -1143,40 +1121,35 @@ sub process { } # Check for potential 'bare' types - my ($stat, $cond); - if ($realcnt && $line =~ /.\s*\S/) { - ($stat, $cond) = ctx_statement_block($linenr, - $realcnt, 0); - $stat =~ s/\n./\n /g; - $cond =~ s/\n./\n /g; - - my $s = $stat; - $s =~ s/{.*$//s; + if ($realcnt) { + my ($s, $c) = ctx_statement_block($linenr, $realcnt, 0); + $s =~ s/\n./ /g; + $s =~ s/{.*$//; # Ignore goto labels. - if ($s =~ /$Ident:\*$/s) { + if ($s =~ /$Ident:\*$/) { # Ignore functions being called - } elsif ($s =~ /^.\s*$Ident\s*\(/s) { + } elsif ($s =~ /^.\s*$Ident\s*\(/) { # definitions in global scope can only start with types - } elsif ($s =~ /^.(?:$Storage\s+)?(?:$Inline\s+)?(?:const\s+)?($Ident)\b/s) { + } elsif ($s =~ /^.(?:$Storage\s+)?(?:$Inline\s+)?(?:const\s+)?($Ident)\b/) { possible($1, $s); # declarations always start with types - } elsif ($prev_values eq 'E' && $s =~ /^.\s*(?:$Storage\s+)?(?:const\s+)?($Ident)\b(:?\s+$Sparse)?\s*\**\s*$Ident\s*(?:;|=|,)/s) { + } elsif ($prev_values eq 'E' && $s =~ /^.\s*(?:$Storage\s+)?(?:const\s+)?($Ident)\b(:?\s+$Sparse)?\s*\**\s*$Ident\s*(?:;|=|,)/) { possible($1, $s); } # any (foo ... *) is a pointer cast, and foo is a type - while ($s =~ /\(($Ident)(?:\s+$Sparse)*\s*\*+\s*\)/sg) { + while ($s =~ /\(($Ident)(?:\s+$Sparse)*\s*\*+\s*\)/g) { possible($1, $s); } # Check for any sort of function declaration. # int foo(something bar, other baz); # void (*store_gdt)(x86_descr_ptr *); - if ($prev_values eq 'E' && $s =~ /^(.(?:typedef\s*)?(?:(?:$Storage|$Inline)\s*)*\s*$Type\s*(?:\b$Ident|\(\*\s*$Ident\))\s*)\(/s) { + if ($prev_values eq 'E' && $s =~ /^(.(?:typedef\s*)?(?:(?:$Storage|$Inline)\s*)*\s*$Type\s*(?:\b$Ident|\(\*\s*$Ident\))\s*)\(/) { my ($name_len) = length($1); my $ctx = $s; @@ -1309,19 +1282,18 @@ sub process { ($prevline !~ /^ }/) && ($prevline !~ /^.DECLARE_$Ident\(\Q$name\E\)/) && ($prevline !~ /^.LIST_HEAD\(\Q$name\E\)/) && - ($prevline !~ /^.$Type\s*\(\s*\*\s*\Q$name\E\s*\)\s*\(/) && ($prevline !~ /\b\Q$name\E(?:\s+$Attribute)?\s*(?:;|=|\[)/)) { WARN("EXPORT_SYMBOL(foo); should immediately follow its function/variable\n" . $herecurr); } } # check for external initialisers. - if ($line =~ /^.$Type\s*$Ident\s*=\s*(0|NULL|false)\s*;/) { + if ($line =~ /^.$Type\s*$Ident\s*=\s*(0|NULL);/) { ERROR("do not initialise externals to 0 or NULL\n" . $herecurr); } # check for static initialisers. - if ($line =~ /\s*static\s.*=\s*(0|NULL|false)\s*;/) { + if ($line =~ /\s*static\s.*=\s*(0|NULL);/) { ERROR("do not initialise statics to 0 or NULL\n" . $herecurr); } @@ -1540,10 +1512,7 @@ sub process { if ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) { ERROR("space required before that '$op' $at\n" . $hereptr); } - if ($op eq '*' && $cc =~/\s*const\b/) { - # A unary '*' may be const - - } elsif ($ctx =~ /.xW/) { + if ($ctx =~ /.xW/) { ERROR("space prohibited after that '$op' $at\n" . $hereptr); } @@ -1648,7 +1617,7 @@ sub process { # Check for illegal assignment in if conditional. if ($line =~ /\bif\s*\(/) { - my ($s, $c) = ($stat, $cond); + my ($s, $c) = ctx_statement_block($linenr, $realcnt, 0); if ($c =~ /\bif\s*\(.*[^<>!=]=[^=].*/) { ERROR("do not use assignment in if condition\n" . $herecurr); @@ -1726,7 +1695,7 @@ sub process { #warn if is #included and is available (uses RAW line) if ($tree && $rawline =~ m{^.\#\s*include\s*\}) { my $checkfile = "$root/include/linux/$1.h"; - if (-f $checkfile && $1 ne 'irq') { + if (-f $checkfile && $1 ne 'irq.h') { WARN("Use #include instead of \n" . $herecurr); } @@ -1941,8 +1910,7 @@ sub process { } # check for spinlock_t definitions without a comment. - if ($line =~ /^.\s*(struct\s+mutex|spinlock_t)\s+\S+;/ || - $line =~ /^.\s*(DEFINE_MUTEX)\s*\(/) { + if ($line =~ /^.\s*(struct\s+mutex|spinlock_t)\s+\S+;/) { my $which = $1; if (!ctx_has_comment($first_line, $linenr)) { CHK("$1 definition without comment\n" . $herecurr); @@ -1972,26 +1940,7 @@ sub process { } # check for new externs in .c files. - if ($realfile =~ /\.c$/ && defined $stat && - $stat =~ /^.\s*(?:extern\s+)?$Type\s+$Ident(\s*)\(/s) - { - my $paren_space = $1; - - my $s = $stat; - if (defined $cond) { - substr($s, 0, length($cond), ''); - } - if ($s =~ /^\s*;/) { - WARN("externs should be avoided in .c files\n" . $herecurr); - } - - if ($paren_space =~ /\n/) { - WARN("arguments for function declarations should follow identifier\n" . $herecurr); - } - - } elsif ($realfile =~ /\.c$/ && defined $stat && - $stat =~ /^.\s*extern\s+/) - { + if ($line =~ /^.\s*extern\s/ && ($realfile =~ /\.c$/)) { WARN("externs should be avoided in .c files\n" . $herecurr); } @@ -2015,11 +1964,11 @@ sub process { } # check for semaphores used as mutexes - if ($line =~ /^.\s*(DECLARE_MUTEX|init_MUTEX)\s*\(/) { + if ($line =~ /\b(DECLARE_MUTEX|init_MUTEX)\s*\(/) { WARN("mutexes are preferred for single holder semaphores\n" . $herecurr); } # check for semaphores used as mutexes - if ($line =~ /^.\s*init_MUTEX_LOCKED\s*\(/) { + if ($line =~ /\binit_MUTEX_LOCKED\s*\(/) { WARN("consider using a completion\n" . $herecurr); } # recommend strict_strto* over simple_strto* @@ -2030,24 +1979,11 @@ sub process { # use of NR_CPUS is usually wrong # ignore definitions of NR_CPUS and usage to define arrays as likely right if ($line =~ /\bNR_CPUS\b/ && - $line !~ /^.#\s*if\b.*\bNR_CPUS\b/ && - $line !~ /^.#\s*define\b.*\bNR_CPUS\b/ && - $line !~ /^.\s*$Declare\s.*\[[^\]]*NR_CPUS[^\]]*\]/ && - $line !~ /\[[^\]]*\.\.\.[^\]]*NR_CPUS[^\]]*\]/ && - $line !~ /\[[^\]]*NR_CPUS[^\]]*\.\.\.[^\]]*\]/) + $line !~ /^.#\s*define\s+NR_CPUS\s+/ && + $line !~ /^.\s*$Declare\s.*\[[^\]]*NR_CPUS[^\]]*\]/) { WARN("usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_possible_cpu(), etc\n" . $herecurr); } - -# check for %L{u,d,i} in strings - my $string; - while ($line =~ /(?:^|")([X\t]*)(?:"|$)/g) { - $string = substr($rawline, $-[1], $+[1] - $-[1]); - if ($string =~ /(?name); - - return 1; -} - /* Ignore any prefix, eg. v850 prepends _ */ static inline int sym_is(const char *symbol, const char *name) { @@ -713,10 +704,6 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, do_table(symval, sym->st_size, sizeof(struct virtio_device_id), "virtio", do_virtio_entry, mod); - else if (sym_is(symname, "__mod_i2c_device_table")) - do_table(symval, sym->st_size, - sizeof(struct i2c_device_id), "i2c", - do_i2c_entry, mod); free(zeros); } diff --git a/trunk/security/Makefile b/trunk/security/Makefile index 7ef1107a7287..9e8b02525014 100644 --- a/trunk/security/Makefile +++ b/trunk/security/Makefile @@ -18,4 +18,3 @@ obj-$(CONFIG_SECURITY_SELINUX) += selinux/built-in.o obj-$(CONFIG_SECURITY_SMACK) += commoncap.o smack/built-in.o obj-$(CONFIG_SECURITY_CAPABILITIES) += commoncap.o capability.o obj-$(CONFIG_SECURITY_ROOTPLUG) += commoncap.o root_plug.o -obj-$(CONFIG_CGROUP_DEVICE) += device_cgroup.o diff --git a/trunk/security/commoncap.c b/trunk/security/commoncap.c index 5edabc7542ae..e8c3f5e46705 100644 --- a/trunk/security/commoncap.c +++ b/trunk/security/commoncap.c @@ -383,8 +383,8 @@ int cap_bprm_secureexec (struct linux_binprm *bprm) current->egid != current->gid); } -int cap_inode_setxattr(struct dentry *dentry, const char *name, - const void *value, size_t size, int flags) +int cap_inode_setxattr(struct dentry *dentry, char *name, void *value, + size_t size, int flags) { if (!strcmp(name, XATTR_NAME_CAPS)) { if (!capable(CAP_SETFCAP)) @@ -397,7 +397,7 @@ int cap_inode_setxattr(struct dentry *dentry, const char *name, return 0; } -int cap_inode_removexattr(struct dentry *dentry, const char *name) +int cap_inode_removexattr(struct dentry *dentry, char *name) { if (!strcmp(name, XATTR_NAME_CAPS)) { if (!capable(CAP_SETFCAP)) diff --git a/trunk/security/device_cgroup.c b/trunk/security/device_cgroup.c deleted file mode 100644 index 4ea583689eec..000000000000 --- a/trunk/security/device_cgroup.c +++ /dev/null @@ -1,575 +0,0 @@ -/* - * dev_cgroup.c - device cgroup subsystem - * - * Copyright 2007 IBM Corp - */ - -#include -#include -#include -#include -#include -#include - -#define ACC_MKNOD 1 -#define ACC_READ 2 -#define ACC_WRITE 4 -#define ACC_MASK (ACC_MKNOD | ACC_READ | ACC_WRITE) - -#define DEV_BLOCK 1 -#define DEV_CHAR 2 -#define DEV_ALL 4 /* this represents all devices */ - -/* - * whitelist locking rules: - * cgroup_lock() cannot be taken under dev_cgroup->lock. - * dev_cgroup->lock can be taken with or without cgroup_lock(). - * - * modifications always require cgroup_lock - * modifications to a list which is visible require the - * dev_cgroup->lock *and* cgroup_lock() - * walking the list requires dev_cgroup->lock or cgroup_lock(). - * - * reasoning: dev_whitelist_copy() needs to kmalloc, so needs - * a mutex, which the cgroup_lock() is. Since modifying - * a visible list requires both locks, either lock can be - * taken for walking the list. - */ - -struct dev_whitelist_item { - u32 major, minor; - short type; - short access; - struct list_head list; -}; - -struct dev_cgroup { - struct cgroup_subsys_state css; - struct list_head whitelist; - spinlock_t lock; -}; - -static inline struct dev_cgroup *cgroup_to_devcgroup(struct cgroup *cgroup) -{ - return container_of(cgroup_subsys_state(cgroup, devices_subsys_id), - struct dev_cgroup, css); -} - -struct cgroup_subsys devices_subsys; - -static int devcgroup_can_attach(struct cgroup_subsys *ss, - struct cgroup *new_cgroup, struct task_struct *task) -{ - if (current != task && !capable(CAP_SYS_ADMIN)) - return -EPERM; - - return 0; -} - -/* - * called under cgroup_lock() - */ -static int dev_whitelist_copy(struct list_head *dest, struct list_head *orig) -{ - struct dev_whitelist_item *wh, *tmp, *new; - - list_for_each_entry(wh, orig, list) { - new = kmalloc(sizeof(*wh), GFP_KERNEL); - if (!new) - goto free_and_exit; - new->major = wh->major; - new->minor = wh->minor; - new->type = wh->type; - new->access = wh->access; - list_add_tail(&new->list, dest); - } - - return 0; - -free_and_exit: - list_for_each_entry_safe(wh, tmp, dest, list) { - list_del(&wh->list); - kfree(wh); - } - return -ENOMEM; -} - -/* Stupid prototype - don't bother combining existing entries */ -/* - * called under cgroup_lock() - * since the list is visible to other tasks, we need the spinlock also - */ -static int dev_whitelist_add(struct dev_cgroup *dev_cgroup, - struct dev_whitelist_item *wh) -{ - struct dev_whitelist_item *whcopy; - - whcopy = kmalloc(sizeof(*whcopy), GFP_KERNEL); - if (!whcopy) - return -ENOMEM; - - memcpy(whcopy, wh, sizeof(*whcopy)); - spin_lock(&dev_cgroup->lock); - list_add_tail(&whcopy->list, &dev_cgroup->whitelist); - spin_unlock(&dev_cgroup->lock); - return 0; -} - -/* - * called under cgroup_lock() - * since the list is visible to other tasks, we need the spinlock also - */ -static void dev_whitelist_rm(struct dev_cgroup *dev_cgroup, - struct dev_whitelist_item *wh) -{ - struct dev_whitelist_item *walk, *tmp; - - spin_lock(&dev_cgroup->lock); - list_for_each_entry_safe(walk, tmp, &dev_cgroup->whitelist, list) { - if (walk->type == DEV_ALL) - goto remove; - if (walk->type != wh->type) - continue; - if (walk->major != ~0 && walk->major != wh->major) - continue; - if (walk->minor != ~0 && walk->minor != wh->minor) - continue; - -remove: - walk->access &= ~wh->access; - if (!walk->access) { - list_del(&walk->list); - kfree(walk); - } - } - spin_unlock(&dev_cgroup->lock); -} - -/* - * called from kernel/cgroup.c with cgroup_lock() held. - */ -static struct cgroup_subsys_state *devcgroup_create(struct cgroup_subsys *ss, - struct cgroup *cgroup) -{ - struct dev_cgroup *dev_cgroup, *parent_dev_cgroup; - struct cgroup *parent_cgroup; - int ret; - - dev_cgroup = kzalloc(sizeof(*dev_cgroup), GFP_KERNEL); - if (!dev_cgroup) - return ERR_PTR(-ENOMEM); - INIT_LIST_HEAD(&dev_cgroup->whitelist); - parent_cgroup = cgroup->parent; - - if (parent_cgroup == NULL) { - struct dev_whitelist_item *wh; - wh = kmalloc(sizeof(*wh), GFP_KERNEL); - if (!wh) { - kfree(dev_cgroup); - return ERR_PTR(-ENOMEM); - } - wh->minor = wh->major = ~0; - wh->type = DEV_ALL; - wh->access = ACC_MKNOD | ACC_READ | ACC_WRITE; - list_add(&wh->list, &dev_cgroup->whitelist); - } else { - parent_dev_cgroup = cgroup_to_devcgroup(parent_cgroup); - ret = dev_whitelist_copy(&dev_cgroup->whitelist, - &parent_dev_cgroup->whitelist); - if (ret) { - kfree(dev_cgroup); - return ERR_PTR(ret); - } - } - - spin_lock_init(&dev_cgroup->lock); - return &dev_cgroup->css; -} - -static void devcgroup_destroy(struct cgroup_subsys *ss, - struct cgroup *cgroup) -{ - struct dev_cgroup *dev_cgroup; - struct dev_whitelist_item *wh, *tmp; - - dev_cgroup = cgroup_to_devcgroup(cgroup); - list_for_each_entry_safe(wh, tmp, &dev_cgroup->whitelist, list) { - list_del(&wh->list); - kfree(wh); - } - kfree(dev_cgroup); -} - -#define DEVCG_ALLOW 1 -#define DEVCG_DENY 2 -#define DEVCG_LIST 3 - -#define MAJMINLEN 10 -#define ACCLEN 4 - -static void set_access(char *acc, short access) -{ - int idx = 0; - memset(acc, 0, ACCLEN); - if (access & ACC_READ) - acc[idx++] = 'r'; - if (access & ACC_WRITE) - acc[idx++] = 'w'; - if (access & ACC_MKNOD) - acc[idx++] = 'm'; -} - -static char type_to_char(short type) -{ - if (type == DEV_ALL) - return 'a'; - if (type == DEV_CHAR) - return 'c'; - if (type == DEV_BLOCK) - return 'b'; - return 'X'; -} - -static void set_majmin(char *str, unsigned m) -{ - memset(str, 0, MAJMINLEN); - if (m == ~0) - sprintf(str, "*"); - else - snprintf(str, MAJMINLEN, "%d", m); -} - -static int devcgroup_seq_read(struct cgroup *cgroup, struct cftype *cft, - struct seq_file *m) -{ - struct dev_cgroup *devcgroup = cgroup_to_devcgroup(cgroup); - struct dev_whitelist_item *wh; - char maj[MAJMINLEN], min[MAJMINLEN], acc[ACCLEN]; - - spin_lock(&devcgroup->lock); - list_for_each_entry(wh, &devcgroup->whitelist, list) { - set_access(acc, wh->access); - set_majmin(maj, wh->major); - set_majmin(min, wh->minor); - seq_printf(m, "%c %s:%s %s\n", type_to_char(wh->type), - maj, min, acc); - } - spin_unlock(&devcgroup->lock); - - return 0; -} - -/* - * may_access_whitelist: - * does the access granted to dev_cgroup c contain the access - * requested in whitelist item refwh. - * return 1 if yes, 0 if no. - * call with c->lock held - */ -static int may_access_whitelist(struct dev_cgroup *c, - struct dev_whitelist_item *refwh) -{ - struct dev_whitelist_item *whitem; - - list_for_each_entry(whitem, &c->whitelist, list) { - if (whitem->type & DEV_ALL) - return 1; - if ((refwh->type & DEV_BLOCK) && !(whitem->type & DEV_BLOCK)) - continue; - if ((refwh->type & DEV_CHAR) && !(whitem->type & DEV_CHAR)) - continue; - if (whitem->major != ~0 && whitem->major != refwh->major) - continue; - if (whitem->minor != ~0 && whitem->minor != refwh->minor) - continue; - if (refwh->access & (~(whitem->access | ACC_MASK))) - continue; - return 1; - } - return 0; -} - -/* - * parent_has_perm: - * when adding a new allow rule to a device whitelist, the rule - * must be allowed in the parent device - */ -static int parent_has_perm(struct cgroup *childcg, - struct dev_whitelist_item *wh) -{ - struct cgroup *pcg = childcg->parent; - struct dev_cgroup *parent; - int ret; - - if (!pcg) - return 1; - parent = cgroup_to_devcgroup(pcg); - spin_lock(&parent->lock); - ret = may_access_whitelist(parent, wh); - spin_unlock(&parent->lock); - return ret; -} - -/* - * Modify the whitelist using allow/deny rules. - * CAP_SYS_ADMIN is needed for this. It's at least separate from CAP_MKNOD - * so we can give a container CAP_MKNOD to let it create devices but not - * modify the whitelist. - * It seems likely we'll want to add a CAP_CONTAINER capability to allow - * us to also grant CAP_SYS_ADMIN to containers without giving away the - * device whitelist controls, but for now we'll stick with CAP_SYS_ADMIN - * - * Taking rules away is always allowed (given CAP_SYS_ADMIN). Granting - * new access is only allowed if you're in the top-level cgroup, or your - * parent cgroup has the access you're asking for. - */ -static ssize_t devcgroup_access_write(struct cgroup *cgroup, struct cftype *cft, - struct file *file, const char __user *userbuf, - size_t nbytes, loff_t *ppos) -{ - struct cgroup *cur_cgroup; - struct dev_cgroup *devcgroup, *cur_devcgroup; - int filetype = cft->private; - char *buffer, *b; - int retval = 0, count; - struct dev_whitelist_item wh; - - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; - - devcgroup = cgroup_to_devcgroup(cgroup); - cur_cgroup = task_cgroup(current, devices_subsys.subsys_id); - cur_devcgroup = cgroup_to_devcgroup(cur_cgroup); - - buffer = kmalloc(nbytes+1, GFP_KERNEL); - if (!buffer) - return -ENOMEM; - - if (copy_from_user(buffer, userbuf, nbytes)) { - retval = -EFAULT; - goto out1; - } - buffer[nbytes] = 0; /* nul-terminate */ - - cgroup_lock(); - if (cgroup_is_removed(cgroup)) { - retval = -ENODEV; - goto out2; - } - - memset(&wh, 0, sizeof(wh)); - b = buffer; - - switch (*b) { - case 'a': - wh.type = DEV_ALL; - wh.access = ACC_MASK; - goto handle; - case 'b': - wh.type = DEV_BLOCK; - break; - case 'c': - wh.type = DEV_CHAR; - break; - default: - retval = -EINVAL; - goto out2; - } - b++; - if (!isspace(*b)) { - retval = -EINVAL; - goto out2; - } - b++; - if (*b == '*') { - wh.major = ~0; - b++; - } else if (isdigit(*b)) { - wh.major = 0; - while (isdigit(*b)) { - wh.major = wh.major*10+(*b-'0'); - b++; - } - } else { - retval = -EINVAL; - goto out2; - } - if (*b != ':') { - retval = -EINVAL; - goto out2; - } - b++; - - /* read minor */ - if (*b == '*') { - wh.minor = ~0; - b++; - } else if (isdigit(*b)) { - wh.minor = 0; - while (isdigit(*b)) { - wh.minor = wh.minor*10+(*b-'0'); - b++; - } - } else { - retval = -EINVAL; - goto out2; - } - if (!isspace(*b)) { - retval = -EINVAL; - goto out2; - } - for (b++, count = 0; count < 3; count++, b++) { - switch (*b) { - case 'r': - wh.access |= ACC_READ; - break; - case 'w': - wh.access |= ACC_WRITE; - break; - case 'm': - wh.access |= ACC_MKNOD; - break; - case '\n': - case '\0': - count = 3; - break; - default: - retval = -EINVAL; - goto out2; - } - } - -handle: - retval = 0; - switch (filetype) { - case DEVCG_ALLOW: - if (!parent_has_perm(cgroup, &wh)) - retval = -EPERM; - else - retval = dev_whitelist_add(devcgroup, &wh); - break; - case DEVCG_DENY: - dev_whitelist_rm(devcgroup, &wh); - break; - default: - retval = -EINVAL; - goto out2; - } - - if (retval == 0) - retval = nbytes; - -out2: - cgroup_unlock(); -out1: - kfree(buffer); - return retval; -} - -static struct cftype dev_cgroup_files[] = { - { - .name = "allow", - .write = devcgroup_access_write, - .private = DEVCG_ALLOW, - }, - { - .name = "deny", - .write = devcgroup_access_write, - .private = DEVCG_DENY, - }, - { - .name = "list", - .read_seq_string = devcgroup_seq_read, - .private = DEVCG_LIST, - }, -}; - -static int devcgroup_populate(struct cgroup_subsys *ss, - struct cgroup *cgroup) -{ - return cgroup_add_files(cgroup, ss, dev_cgroup_files, - ARRAY_SIZE(dev_cgroup_files)); -} - -struct cgroup_subsys devices_subsys = { - .name = "devices", - .can_attach = devcgroup_can_attach, - .create = devcgroup_create, - .destroy = devcgroup_destroy, - .populate = devcgroup_populate, - .subsys_id = devices_subsys_id, -}; - -int devcgroup_inode_permission(struct inode *inode, int mask) -{ - struct cgroup *cgroup; - struct dev_cgroup *dev_cgroup; - struct dev_whitelist_item *wh; - - dev_t device = inode->i_rdev; - if (!device) - return 0; - if (!S_ISBLK(inode->i_mode) && !S_ISCHR(inode->i_mode)) - return 0; - cgroup = task_cgroup(current, devices_subsys.subsys_id); - dev_cgroup = cgroup_to_devcgroup(cgroup); - if (!dev_cgroup) - return 0; - - spin_lock(&dev_cgroup->lock); - list_for_each_entry(wh, &dev_cgroup->whitelist, list) { - if (wh->type & DEV_ALL) - goto acc_check; - if ((wh->type & DEV_BLOCK) && !S_ISBLK(inode->i_mode)) - continue; - if ((wh->type & DEV_CHAR) && !S_ISCHR(inode->i_mode)) - continue; - if (wh->major != ~0 && wh->major != imajor(inode)) - continue; - if (wh->minor != ~0 && wh->minor != iminor(inode)) - continue; -acc_check: - if ((mask & MAY_WRITE) && !(wh->access & ACC_WRITE)) - continue; - if ((mask & MAY_READ) && !(wh->access & ACC_READ)) - continue; - spin_unlock(&dev_cgroup->lock); - return 0; - } - spin_unlock(&dev_cgroup->lock); - - return -EPERM; -} - -int devcgroup_inode_mknod(int mode, dev_t dev) -{ - struct cgroup *cgroup; - struct dev_cgroup *dev_cgroup; - struct dev_whitelist_item *wh; - - cgroup = task_cgroup(current, devices_subsys.subsys_id); - dev_cgroup = cgroup_to_devcgroup(cgroup); - if (!dev_cgroup) - return 0; - - spin_lock(&dev_cgroup->lock); - list_for_each_entry(wh, &dev_cgroup->whitelist, list) { - if (wh->type & DEV_ALL) - goto acc_check; - if ((wh->type & DEV_BLOCK) && !S_ISBLK(mode)) - continue; - if ((wh->type & DEV_CHAR) && !S_ISCHR(mode)) - continue; - if (wh->major != ~0 && wh->major != MAJOR(dev)) - continue; - if (wh->minor != ~0 && wh->minor != MINOR(dev)) - continue; -acc_check: - if (!(wh->access & ACC_MKNOD)) - continue; - spin_unlock(&dev_cgroup->lock); - return 0; - } - spin_unlock(&dev_cgroup->lock); - return -EPERM; -} diff --git a/trunk/security/dummy.c b/trunk/security/dummy.c index f50c6c3c32c9..58d4dd1af5c7 100644 --- a/trunk/security/dummy.c +++ b/trunk/security/dummy.c @@ -365,8 +365,8 @@ static void dummy_inode_delete (struct inode *ino) return; } -static int dummy_inode_setxattr (struct dentry *dentry, const char *name, - const void *value, size_t size, int flags) +static int dummy_inode_setxattr (struct dentry *dentry, char *name, void *value, + size_t size, int flags) { if (!strncmp(name, XATTR_SECURITY_PREFIX, sizeof(XATTR_SECURITY_PREFIX) - 1) && @@ -375,13 +375,12 @@ static int dummy_inode_setxattr (struct dentry *dentry, const char *name, return 0; } -static void dummy_inode_post_setxattr (struct dentry *dentry, const char *name, - const void *value, size_t size, - int flags) +static void dummy_inode_post_setxattr (struct dentry *dentry, char *name, void *value, + size_t size, int flags) { } -static int dummy_inode_getxattr (struct dentry *dentry, const char *name) +static int dummy_inode_getxattr (struct dentry *dentry, char *name) { return 0; } @@ -391,7 +390,7 @@ static int dummy_inode_listxattr (struct dentry *dentry) return 0; } -static int dummy_inode_removexattr (struct dentry *dentry, const char *name) +static int dummy_inode_removexattr (struct dentry *dentry, char *name) { if (!strncmp(name, XATTR_SECURITY_PREFIX, sizeof(XATTR_SECURITY_PREFIX) - 1) && @@ -968,7 +967,7 @@ static int dummy_secid_to_secctx(u32 secid, char **secdata, u32 *seclen) return -EOPNOTSUPP; } -static int dummy_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid) +static int dummy_secctx_to_secid(char *secdata, u32 seclen, u32 *secid) { return -EOPNOTSUPP; } @@ -994,13 +993,6 @@ static inline int dummy_key_permission(key_ref_t key_ref, { return 0; } - -static int dummy_key_getsecurity(struct key *key, char **_buffer) -{ - *_buffer = NULL; - return 0; -} - #endif /* CONFIG_KEYS */ #ifdef CONFIG_AUDIT @@ -1217,7 +1209,6 @@ void security_fixup_ops (struct security_operations *ops) set_to_dummy_if_null(ops, key_alloc); set_to_dummy_if_null(ops, key_free); set_to_dummy_if_null(ops, key_permission); - set_to_dummy_if_null(ops, key_getsecurity); #endif /* CONFIG_KEYS */ #ifdef CONFIG_AUDIT set_to_dummy_if_null(ops, audit_rule_init); diff --git a/trunk/security/keys/Makefile b/trunk/security/keys/Makefile index 747a464943af..5145adfb6a05 100644 --- a/trunk/security/keys/Makefile +++ b/trunk/security/keys/Makefile @@ -14,4 +14,3 @@ obj-y := \ obj-$(CONFIG_KEYS_COMPAT) += compat.o obj-$(CONFIG_PROC_FS) += proc.o -obj-$(CONFIG_SYSCTL) += sysctl.o diff --git a/trunk/security/keys/compat.c b/trunk/security/keys/compat.c index c766c68a63bc..e10ec995f275 100644 --- a/trunk/security/keys/compat.c +++ b/trunk/security/keys/compat.c @@ -79,9 +79,6 @@ asmlinkage long compat_sys_keyctl(u32 option, case KEYCTL_ASSUME_AUTHORITY: return keyctl_assume_authority(arg2); - case KEYCTL_GET_SECURITY: - return keyctl_get_security(arg2, compat_ptr(arg3), arg4); - default: return -EOPNOTSUPP; } diff --git a/trunk/security/keys/internal.h b/trunk/security/keys/internal.h index 8c05587f5018..7d894ef70370 100644 --- a/trunk/security/keys/internal.h +++ b/trunk/security/keys/internal.h @@ -57,6 +57,10 @@ struct key_user { int qnbytes; /* number of bytes allocated to this user */ }; +#define KEYQUOTA_MAX_KEYS 100 +#define KEYQUOTA_MAX_BYTES 10000 +#define KEYQUOTA_LINK_BYTES 4 /* a link in a keyring is worth 4 bytes */ + extern struct rb_root key_user_tree; extern spinlock_t key_user_lock; extern struct key_user root_key_user; @@ -64,16 +68,6 @@ extern struct key_user root_key_user; extern struct key_user *key_user_lookup(uid_t uid); extern void key_user_put(struct key_user *user); -/* - * key quota limits - * - root has its own separate limits to everyone else - */ -extern unsigned key_quota_root_maxkeys; -extern unsigned key_quota_root_maxbytes; -extern unsigned key_quota_maxkeys; -extern unsigned key_quota_maxbytes; - -#define KEYQUOTA_LINK_BYTES 4 /* a link in a keyring is worth 4 bytes */ extern struct rb_root key_serial_tree; @@ -83,6 +77,8 @@ extern struct mutex key_construction_mutex; extern wait_queue_head_t request_key_conswq; +extern void keyring_publish_name(struct key *keyring); + extern int __key_link(struct key *keyring, struct key *key); extern key_ref_t __keyring_search_one(key_ref_t keyring_ref, @@ -106,15 +102,14 @@ extern key_ref_t search_process_keyrings(struct key_type *type, key_match_func_t match, struct task_struct *tsk); -extern struct key *find_keyring_by_name(const char *name, bool skip_perm_check); +extern struct key *find_keyring_by_name(const char *name, key_serial_t bound); extern int install_thread_keyring(struct task_struct *tsk); extern int install_process_keyring(struct task_struct *tsk); extern struct key *request_key_and_link(struct key_type *type, const char *description, - const void *callout_info, - size_t callout_len, + const char *callout_info, void *aux, struct key *dest_keyring, unsigned long flags); @@ -125,15 +120,13 @@ extern struct key *request_key_and_link(struct key_type *type, struct request_key_auth { struct key *target_key; struct task_struct *context; - void *callout_info; - size_t callout_len; + char *callout_info; pid_t pid; }; extern struct key_type key_type_request_key_auth; extern struct key *request_key_auth_new(struct key *target, - const void *callout_info, - size_t callout_len); + const char *callout_info); extern struct key *key_get_instantiation_authkey(key_serial_t target_id); @@ -159,8 +152,7 @@ extern long keyctl_negate_key(key_serial_t, unsigned, key_serial_t); extern long keyctl_set_reqkey_keyring(int); extern long keyctl_set_timeout(key_serial_t, unsigned); extern long keyctl_assume_authority(key_serial_t); -extern long keyctl_get_security(key_serial_t keyid, char __user *buffer, - size_t buflen); + /* * debugging key validation diff --git a/trunk/security/keys/key.c b/trunk/security/keys/key.c index 14948cf83ef6..654d23baf352 100644 --- a/trunk/security/keys/key.c +++ b/trunk/security/keys/key.c @@ -1,6 +1,6 @@ /* Basic authentication token and access key management * - * Copyright (C) 2004-2008 Red Hat, Inc. All Rights Reserved. + * Copyright (C) 2004-2007 Red Hat, Inc. All Rights Reserved. * Written by David Howells (dhowells@redhat.com) * * This program is free software; you can redistribute it and/or @@ -27,11 +27,6 @@ DEFINE_SPINLOCK(key_serial_lock); struct rb_root key_user_tree; /* tree of quota records indexed by UID */ DEFINE_SPINLOCK(key_user_lock); -unsigned int key_quota_root_maxkeys = 200; /* root's key count quota */ -unsigned int key_quota_root_maxbytes = 20000; /* root's key space quota */ -unsigned int key_quota_maxkeys = 200; /* general key count quota */ -unsigned int key_quota_maxbytes = 20000; /* general key space quota */ - static LIST_HEAD(key_types_list); static DECLARE_RWSEM(key_types_sem); @@ -142,6 +137,36 @@ void key_user_put(struct key_user *user) } /* end key_user_put() */ +/*****************************************************************************/ +/* + * insert a key with a fixed serial number + */ +static void __init __key_insert_serial(struct key *key) +{ + struct rb_node *parent, **p; + struct key *xkey; + + parent = NULL; + p = &key_serial_tree.rb_node; + + while (*p) { + parent = *p; + xkey = rb_entry(parent, struct key, serial_node); + + if (key->serial < xkey->serial) + p = &(*p)->rb_left; + else if (key->serial > xkey->serial) + p = &(*p)->rb_right; + else + BUG(); + } + + /* we've found a suitable hole - arrange for this key to occupy it */ + rb_link_node(&key->serial_node, parent, p); + rb_insert_color(&key->serial_node, &key_serial_tree); + +} /* end __key_insert_serial() */ + /*****************************************************************************/ /* * assign a key the next unique serial number @@ -241,16 +266,11 @@ struct key *key_alloc(struct key_type *type, const char *desc, /* check that the user's quota permits allocation of another key and * its description */ if (!(flags & KEY_ALLOC_NOT_IN_QUOTA)) { - unsigned maxkeys = (uid == 0) ? - key_quota_root_maxkeys : key_quota_maxkeys; - unsigned maxbytes = (uid == 0) ? - key_quota_root_maxbytes : key_quota_maxbytes; - spin_lock(&user->lock); if (!(flags & KEY_ALLOC_QUOTA_OVERRUN)) { - if (user->qnkeys + 1 >= maxkeys || - user->qnbytes + quotalen >= maxbytes || - user->qnbytes + quotalen < user->qnbytes) + if (user->qnkeys + 1 >= KEYQUOTA_MAX_KEYS || + user->qnbytes + quotalen >= KEYQUOTA_MAX_BYTES + ) goto no_quota; } @@ -355,14 +375,11 @@ int key_payload_reserve(struct key *key, size_t datalen) /* contemplate the quota adjustment */ if (delta != 0 && test_bit(KEY_FLAG_IN_QUOTA, &key->flags)) { - unsigned maxbytes = (key->user->uid == 0) ? - key_quota_root_maxbytes : key_quota_maxbytes; - spin_lock(&key->user->lock); if (delta > 0 && - (key->user->qnbytes + delta >= maxbytes || - key->user->qnbytes + delta < key->user->qnbytes)) { + key->user->qnbytes + delta > KEYQUOTA_MAX_BYTES + ) { ret = -EDQUOT; } else { @@ -740,11 +757,11 @@ key_ref_t key_create_or_update(key_ref_t keyring_ref, const char *description, const void *payload, size_t plen, - key_perm_t perm, unsigned long flags) { struct key_type *ktype; struct key *keyring, *key = NULL; + key_perm_t perm; key_ref_t key_ref; int ret; @@ -789,17 +806,15 @@ key_ref_t key_create_or_update(key_ref_t keyring_ref, goto found_matching_key; } - /* if the client doesn't provide, decide on the permissions we want */ - if (perm == KEY_PERM_UNDEF) { - perm = KEY_POS_VIEW | KEY_POS_SEARCH | KEY_POS_LINK | KEY_POS_SETATTR; - perm |= KEY_USR_VIEW | KEY_USR_SEARCH | KEY_USR_LINK | KEY_USR_SETATTR; + /* decide on the permissions we want */ + perm = KEY_POS_VIEW | KEY_POS_SEARCH | KEY_POS_LINK | KEY_POS_SETATTR; + perm |= KEY_USR_VIEW | KEY_USR_SEARCH | KEY_USR_LINK | KEY_USR_SETATTR; - if (ktype->read) - perm |= KEY_POS_READ | KEY_USR_READ; + if (ktype->read) + perm |= KEY_POS_READ | KEY_USR_READ; - if (ktype == &key_type_keyring || ktype->update) - perm |= KEY_USR_WRITE; - } + if (ktype == &key_type_keyring || ktype->update) + perm |= KEY_USR_WRITE; /* allocate a new key */ key = key_alloc(ktype, description, current->fsuid, current->fsgid, @@ -1003,4 +1018,17 @@ void __init key_init(void) rb_insert_color(&root_key_user.node, &key_user_tree); + /* record root's user standard keyrings */ + key_check(&root_user_keyring); + key_check(&root_session_keyring); + + __key_insert_serial(&root_user_keyring); + __key_insert_serial(&root_session_keyring); + + keyring_publish_name(&root_user_keyring); + keyring_publish_name(&root_session_keyring); + + /* link the two root keyrings together */ + key_link(&root_session_keyring, &root_user_keyring); + } /* end key_init() */ diff --git a/trunk/security/keys/keyctl.c b/trunk/security/keys/keyctl.c index acc9c89e40a8..d9ca15c109cc 100644 --- a/trunk/security/keys/keyctl.c +++ b/trunk/security/keys/keyctl.c @@ -19,8 +19,6 @@ #include #include #include -#include -#include #include #include "internal.h" @@ -64,10 +62,9 @@ asmlinkage long sys_add_key(const char __user *_type, char type[32], *description; void *payload; long ret; - bool vm; ret = -EINVAL; - if (plen > 1024 * 1024 - 1) + if (plen > 32767) goto error; /* draw all the data into kernel space */ @@ -84,18 +81,11 @@ asmlinkage long sys_add_key(const char __user *_type, /* pull the payload in if one was supplied */ payload = NULL; - vm = false; if (_payload) { ret = -ENOMEM; payload = kmalloc(plen, GFP_KERNEL); - if (!payload) { - if (plen <= PAGE_SIZE) - goto error2; - vm = true; - payload = vmalloc(plen); - if (!payload) - goto error2; - } + if (!payload) + goto error2; ret = -EFAULT; if (copy_from_user(payload, _payload, plen) != 0) @@ -112,8 +102,7 @@ asmlinkage long sys_add_key(const char __user *_type, /* create or update the requested key and add it to the target * keyring */ key_ref = key_create_or_update(keyring_ref, type, description, - payload, plen, KEY_PERM_UNDEF, - KEY_ALLOC_IN_QUOTA); + payload, plen, KEY_ALLOC_IN_QUOTA); if (!IS_ERR(key_ref)) { ret = key_ref_to_ptr(key_ref)->serial; key_ref_put(key_ref); @@ -124,10 +113,7 @@ asmlinkage long sys_add_key(const char __user *_type, key_ref_put(keyring_ref); error3: - if (!vm) - kfree(payload); - else - vfree(payload); + kfree(payload); error2: kfree(description); error: @@ -154,7 +140,6 @@ asmlinkage long sys_request_key(const char __user *_type, struct key_type *ktype; struct key *key; key_ref_t dest_ref; - size_t callout_len; char type[32], *description, *callout_info; long ret; @@ -172,14 +157,12 @@ asmlinkage long sys_request_key(const char __user *_type, /* pull the callout info into kernel space */ callout_info = NULL; - callout_len = 0; if (_callout_info) { callout_info = strndup_user(_callout_info, PAGE_SIZE); if (IS_ERR(callout_info)) { ret = PTR_ERR(callout_info); goto error2; } - callout_len = strlen(callout_info); } /* get the destination keyring if specified */ @@ -200,8 +183,8 @@ asmlinkage long sys_request_key(const char __user *_type, } /* do the search */ - key = request_key_and_link(ktype, description, callout_info, - callout_len, NULL, key_ref_to_ptr(dest_ref), + key = request_key_and_link(ktype, description, callout_info, NULL, + key_ref_to_ptr(dest_ref), KEY_ALLOC_IN_QUOTA); if (IS_ERR(key)) { ret = PTR_ERR(key); @@ -731,16 +714,10 @@ long keyctl_chown_key(key_serial_t id, uid_t uid, gid_t gid) /* transfer the quota burden to the new user */ if (test_bit(KEY_FLAG_IN_QUOTA, &key->flags)) { - unsigned maxkeys = (uid == 0) ? - key_quota_root_maxkeys : key_quota_maxkeys; - unsigned maxbytes = (uid == 0) ? - key_quota_root_maxbytes : key_quota_maxbytes; - spin_lock(&newowner->lock); - if (newowner->qnkeys + 1 >= maxkeys || - newowner->qnbytes + key->quotalen >= maxbytes || - newowner->qnbytes + key->quotalen < - newowner->qnbytes) + if (newowner->qnkeys + 1 >= KEYQUOTA_MAX_KEYS || + newowner->qnbytes + key->quotalen >= + KEYQUOTA_MAX_BYTES) goto quota_overrun; newowner->qnkeys++; @@ -844,10 +821,9 @@ long keyctl_instantiate_key(key_serial_t id, key_ref_t keyring_ref; void *payload; long ret; - bool vm = false; ret = -EINVAL; - if (plen > 1024 * 1024 - 1) + if (plen > 32767) goto error; /* the appropriate instantiation authorisation key must have been @@ -867,14 +843,8 @@ long keyctl_instantiate_key(key_serial_t id, if (_payload) { ret = -ENOMEM; payload = kmalloc(plen, GFP_KERNEL); - if (!payload) { - if (plen <= PAGE_SIZE) - goto error; - vm = true; - payload = vmalloc(plen); - if (!payload) - goto error; - } + if (!payload) + goto error; ret = -EFAULT; if (copy_from_user(payload, _payload, plen) != 0) @@ -907,10 +877,7 @@ long keyctl_instantiate_key(key_serial_t id, } error2: - if (!vm) - kfree(payload); - else - vfree(payload); + kfree(payload); error: return ret; @@ -1088,66 +1055,6 @@ long keyctl_assume_authority(key_serial_t id) } /* end keyctl_assume_authority() */ -/* - * get the security label of a key - * - the key must grant us view permission - * - if there's a buffer, we place up to buflen bytes of data into it - * - unless there's an error, we return the amount of information available, - * irrespective of how much we may have copied (including the terminal NUL) - * - implements keyctl(KEYCTL_GET_SECURITY) - */ -long keyctl_get_security(key_serial_t keyid, - char __user *buffer, - size_t buflen) -{ - struct key *key, *instkey; - key_ref_t key_ref; - char *context; - long ret; - - key_ref = lookup_user_key(NULL, keyid, 0, 1, KEY_VIEW); - if (IS_ERR(key_ref)) { - if (PTR_ERR(key_ref) != -EACCES) - return PTR_ERR(key_ref); - - /* viewing a key under construction is also permitted if we - * have the authorisation token handy */ - instkey = key_get_instantiation_authkey(keyid); - if (IS_ERR(instkey)) - return PTR_ERR(key_ref); - key_put(instkey); - - key_ref = lookup_user_key(NULL, keyid, 0, 1, 0); - if (IS_ERR(key_ref)) - return PTR_ERR(key_ref); - } - - key = key_ref_to_ptr(key_ref); - ret = security_key_getsecurity(key, &context); - if (ret == 0) { - /* if no information was returned, give userspace an empty - * string */ - ret = 1; - if (buffer && buflen > 0 && - copy_to_user(buffer, "", 1) != 0) - ret = -EFAULT; - } else if (ret > 0) { - /* return as much data as there's room for */ - if (buffer && buflen > 0) { - if (buflen > ret) - buflen = ret; - - if (copy_to_user(buffer, context, buflen) != 0) - ret = -EFAULT; - } - - kfree(context); - } - - key_ref_put(key_ref); - return ret; -} - /*****************************************************************************/ /* * the key control system call @@ -1228,11 +1135,6 @@ asmlinkage long sys_keyctl(int option, unsigned long arg2, unsigned long arg3, case KEYCTL_ASSUME_AUTHORITY: return keyctl_assume_authority((key_serial_t) arg2); - case KEYCTL_GET_SECURITY: - return keyctl_get_security((key_serial_t) arg2, - (char *) arg3, - (size_t) arg4); - default: return -EOPNOTSUPP; } diff --git a/trunk/security/keys/keyring.c b/trunk/security/keys/keyring.c index a9ab8affc092..88292e3dee96 100644 --- a/trunk/security/keys/keyring.c +++ b/trunk/security/keys/keyring.c @@ -1,6 +1,6 @@ -/* Keyring handling +/* keyring.c: keyring handling * - * Copyright (C) 2004-2005, 2008 Red Hat, Inc. All Rights Reserved. + * Copyright (C) 2004-5 Red Hat, Inc. All Rights Reserved. * Written by David Howells (dhowells@redhat.com) * * This program is free software; you can redistribute it and/or @@ -79,7 +79,7 @@ static DECLARE_RWSEM(keyring_serialise_link_sem); * publish the name of a keyring so that it can be found by name (if it has * one) */ -static void keyring_publish_name(struct key *keyring) +void keyring_publish_name(struct key *keyring) { int bucket; @@ -292,7 +292,7 @@ key_ref_t keyring_search_aux(key_ref_t keyring_ref, struct keyring_list *keylist; struct timespec now; - unsigned long possessed, kflags; + unsigned long possessed; struct key *keyring, *key; key_ref_t key_ref; long err; @@ -319,32 +319,6 @@ key_ref_t keyring_search_aux(key_ref_t keyring_ref, err = -EAGAIN; sp = 0; - /* firstly we should check to see if this top-level keyring is what we - * are looking for */ - key_ref = ERR_PTR(-EAGAIN); - kflags = keyring->flags; - if (keyring->type == type && match(keyring, description)) { - key = keyring; - - /* check it isn't negative and hasn't expired or been - * revoked */ - if (kflags & (1 << KEY_FLAG_REVOKED)) - goto error_2; - if (key->expiry && now.tv_sec >= key->expiry) - goto error_2; - key_ref = ERR_PTR(-ENOKEY); - if (kflags & (1 << KEY_FLAG_NEGATIVE)) - goto error_2; - goto found; - } - - /* otherwise, the top keyring must not be revoked, expired, or - * negatively instantiated if we are to search it */ - key_ref = ERR_PTR(-EAGAIN); - if (kflags & ((1 << KEY_FLAG_REVOKED) | (1 << KEY_FLAG_NEGATIVE)) || - (keyring->expiry && now.tv_sec >= keyring->expiry)) - goto error_2; - /* start processing a new keyring */ descend: if (test_bit(KEY_FLAG_REVOKED, &keyring->flags)) @@ -357,14 +331,13 @@ key_ref_t keyring_search_aux(key_ref_t keyring_ref, /* iterate through the keys in this keyring first */ for (kix = 0; kix < keylist->nkeys; kix++) { key = keylist->keys[kix]; - kflags = key->flags; /* ignore keys not of this type */ if (key->type != type) continue; /* skip revoked keys and expired keys */ - if (kflags & (1 << KEY_FLAG_REVOKED)) + if (test_bit(KEY_FLAG_REVOKED, &key->flags)) continue; if (key->expiry && now.tv_sec >= key->expiry) @@ -379,8 +352,8 @@ key_ref_t keyring_search_aux(key_ref_t keyring_ref, context, KEY_SEARCH) < 0) continue; - /* we set a different error code if we pass a negative key */ - if (kflags & (1 << KEY_FLAG_NEGATIVE)) { + /* we set a different error code if we find a negative key */ + if (test_bit(KEY_FLAG_NEGATIVE, &key->flags)) { err = -ENOKEY; continue; } @@ -516,9 +489,10 @@ key_ref_t __keyring_search_one(key_ref_t keyring_ref, /* * find a keyring with the specified name * - all named keyrings are searched - * - normally only finds keyrings with search permission for the current process + * - only find keyrings with search permission for the process + * - only find keyrings with a serial number greater than the one specified */ -struct key *find_keyring_by_name(const char *name, bool skip_perm_check) +struct key *find_keyring_by_name(const char *name, key_serial_t bound) { struct key *keyring; int bucket; @@ -544,11 +518,15 @@ struct key *find_keyring_by_name(const char *name, bool skip_perm_check) if (strcmp(keyring->description, name) != 0) continue; - if (!skip_perm_check && - key_permission(make_key_ref(keyring, 0), + if (key_permission(make_key_ref(keyring, 0), KEY_SEARCH) < 0) continue; + /* found a potential candidate, but we still need to + * check the serial number */ + if (keyring->serial <= bound) + continue; + /* we've got a match */ atomic_inc(&keyring->usage); read_unlock(&keyring_name_lock); diff --git a/trunk/security/keys/proc.c b/trunk/security/keys/proc.c index f619170da760..694126003ed3 100644 --- a/trunk/security/keys/proc.c +++ b/trunk/security/keys/proc.c @@ -70,15 +70,19 @@ static int __init key_proc_init(void) struct proc_dir_entry *p; #ifdef CONFIG_KEYS_DEBUG_PROC_KEYS - p = proc_create("keys", 0, NULL, &proc_keys_fops); + p = create_proc_entry("keys", 0, NULL); if (!p) panic("Cannot create /proc/keys\n"); + + p->proc_fops = &proc_keys_fops; #endif - p = proc_create("key-users", 0, NULL, &proc_key_users_fops); + p = create_proc_entry("key-users", 0, NULL); if (!p) panic("Cannot create /proc/key-users\n"); + p->proc_fops = &proc_key_users_fops; + return 0; } /* end key_proc_init() */ @@ -242,10 +246,6 @@ static int proc_key_users_show(struct seq_file *m, void *v) { struct rb_node *_p = v; struct key_user *user = rb_entry(_p, struct key_user, node); - unsigned maxkeys = (user->uid == 0) ? - key_quota_root_maxkeys : key_quota_maxkeys; - unsigned maxbytes = (user->uid == 0) ? - key_quota_root_maxbytes : key_quota_maxbytes; seq_printf(m, "%5u: %5d %d/%d %d/%d %d/%d\n", user->uid, @@ -253,9 +253,10 @@ static int proc_key_users_show(struct seq_file *m, void *v) atomic_read(&user->nkeys), atomic_read(&user->nikeys), user->qnkeys, - maxkeys, + KEYQUOTA_MAX_KEYS, user->qnbytes, - maxbytes); + KEYQUOTA_MAX_BYTES + ); return 0; diff --git a/trunk/security/keys/process_keys.c b/trunk/security/keys/process_keys.c index 5be6d018759a..c886a2bb792a 100644 --- a/trunk/security/keys/process_keys.c +++ b/trunk/security/keys/process_keys.c @@ -1,6 +1,6 @@ -/* Management of a process's keyrings +/* process_keys.c: management of a process's keyrings * - * Copyright (C) 2004-2005, 2008 Red Hat, Inc. All Rights Reserved. + * Copyright (C) 2004-5 Red Hat, Inc. All Rights Reserved. * Written by David Howells (dhowells@redhat.com) * * This program is free software; you can redistribute it and/or @@ -23,9 +23,6 @@ /* session keyring create vs join semaphore */ static DEFINE_MUTEX(key_session_mutex); -/* user keyring creation semaphore */ -static DEFINE_MUTEX(key_user_keyring_mutex); - /* the root user's tracking struct */ struct key_user root_key_user = { .usage = ATOMIC_INIT(3), @@ -36,84 +33,78 @@ struct key_user root_key_user = { .uid = 0, }; +/* the root user's UID keyring */ +struct key root_user_keyring = { + .usage = ATOMIC_INIT(1), + .serial = 2, + .type = &key_type_keyring, + .user = &root_key_user, + .sem = __RWSEM_INITIALIZER(root_user_keyring.sem), + .perm = (KEY_POS_ALL & ~KEY_POS_SETATTR) | KEY_USR_ALL, + .flags = 1 << KEY_FLAG_INSTANTIATED, + .description = "_uid.0", +#ifdef KEY_DEBUGGING + .magic = KEY_DEBUG_MAGIC, +#endif +}; + +/* the root user's default session keyring */ +struct key root_session_keyring = { + .usage = ATOMIC_INIT(1), + .serial = 1, + .type = &key_type_keyring, + .user = &root_key_user, + .sem = __RWSEM_INITIALIZER(root_session_keyring.sem), + .perm = (KEY_POS_ALL & ~KEY_POS_SETATTR) | KEY_USR_ALL, + .flags = 1 << KEY_FLAG_INSTANTIATED, + .description = "_uid_ses.0", +#ifdef KEY_DEBUGGING + .magic = KEY_DEBUG_MAGIC, +#endif +}; + /*****************************************************************************/ /* - * install user and user session keyrings for a particular UID + * allocate the keyrings to be associated with a UID */ -static int install_user_keyrings(struct task_struct *tsk) +int alloc_uid_keyring(struct user_struct *user, + struct task_struct *ctx) { - struct user_struct *user = tsk->user; struct key *uid_keyring, *session_keyring; char buf[20]; int ret; - kenter("%p{%u}", user, user->uid); + /* concoct a default session keyring */ + sprintf(buf, "_uid_ses.%u", user->uid); - if (user->uid_keyring) { - kleave(" = 0 [exist]"); - return 0; + session_keyring = keyring_alloc(buf, user->uid, (gid_t) -1, ctx, + KEY_ALLOC_IN_QUOTA, NULL); + if (IS_ERR(session_keyring)) { + ret = PTR_ERR(session_keyring); + goto error; } - mutex_lock(&key_user_keyring_mutex); - ret = 0; - - if (!user->uid_keyring) { - /* get the UID-specific keyring - * - there may be one in existence already as it may have been - * pinned by a session, but the user_struct pointing to it - * may have been destroyed by setuid */ - sprintf(buf, "_uid.%u", user->uid); - - uid_keyring = find_keyring_by_name(buf, true); - if (IS_ERR(uid_keyring)) { - uid_keyring = keyring_alloc(buf, user->uid, (gid_t) -1, - tsk, KEY_ALLOC_IN_QUOTA, - NULL); - if (IS_ERR(uid_keyring)) { - ret = PTR_ERR(uid_keyring); - goto error; - } - } - - /* get a default session keyring (which might also exist - * already) */ - sprintf(buf, "_uid_ses.%u", user->uid); - - session_keyring = find_keyring_by_name(buf, true); - if (IS_ERR(session_keyring)) { - session_keyring = - keyring_alloc(buf, user->uid, (gid_t) -1, - tsk, KEY_ALLOC_IN_QUOTA, NULL); - if (IS_ERR(session_keyring)) { - ret = PTR_ERR(session_keyring); - goto error_release; - } - - /* we install a link from the user session keyring to - * the user keyring */ - ret = key_link(session_keyring, uid_keyring); - if (ret < 0) - goto error_release_both; - } + /* and a UID specific keyring, pointed to by the default session + * keyring */ + sprintf(buf, "_uid.%u", user->uid); - /* install the keyrings */ - user->uid_keyring = uid_keyring; - user->session_keyring = session_keyring; + uid_keyring = keyring_alloc(buf, user->uid, (gid_t) -1, ctx, + KEY_ALLOC_IN_QUOTA, session_keyring); + if (IS_ERR(uid_keyring)) { + key_put(session_keyring); + ret = PTR_ERR(uid_keyring); + goto error; } - mutex_unlock(&key_user_keyring_mutex); - kleave(" = 0"); - return 0; + /* install the keyrings */ + user->uid_keyring = uid_keyring; + user->session_keyring = session_keyring; + ret = 0; -error_release_both: - key_put(session_keyring); -error_release: - key_put(uid_keyring); error: - mutex_unlock(&key_user_keyring_mutex); - kleave(" = %d", ret); return ret; -} + +} /* end alloc_uid_keyring() */ /*****************************************************************************/ /* @@ -490,7 +481,7 @@ key_ref_t search_process_keyrings(struct key_type *type, } } /* or search the user-session keyring */ - else if (context->user->session_keyring) { + else { key_ref = keyring_search_aux( make_key_ref(context->user->session_keyring, 1), context, type, description, match); @@ -623,9 +614,6 @@ key_ref_t lookup_user_key(struct task_struct *context, key_serial_t id, if (!context->signal->session_keyring) { /* always install a session keyring upon access if one * doesn't exist yet */ - ret = install_user_keyrings(context); - if (ret < 0) - goto error; ret = install_session_keyring( context, context->user->session_keyring); if (ret < 0) @@ -640,24 +628,12 @@ key_ref_t lookup_user_key(struct task_struct *context, key_serial_t id, break; case KEY_SPEC_USER_KEYRING: - if (!context->user->uid_keyring) { - ret = install_user_keyrings(context); - if (ret < 0) - goto error; - } - key = context->user->uid_keyring; atomic_inc(&key->usage); key_ref = make_key_ref(key, 1); break; case KEY_SPEC_USER_SESSION_KEYRING: - if (!context->user->session_keyring) { - ret = install_user_keyrings(context); - if (ret < 0) - goto error; - } - key = context->user->session_keyring; atomic_inc(&key->usage); key_ref = make_key_ref(key, 1); @@ -768,7 +744,7 @@ long join_session_keyring(const char *name) mutex_lock(&key_session_mutex); /* look for an existing keyring of this name */ - keyring = find_keyring_by_name(name, false); + keyring = find_keyring_by_name(name, 0); if (PTR_ERR(keyring) == -ENOKEY) { /* not found - try and create a new one */ keyring = keyring_alloc(name, tsk->uid, tsk->gid, tsk, diff --git a/trunk/security/keys/request_key.c b/trunk/security/keys/request_key.c index ba32ca6469bd..5ecc5057fb54 100644 --- a/trunk/security/keys/request_key.c +++ b/trunk/security/keys/request_key.c @@ -16,7 +16,6 @@ #include #include #include -#include #include "internal.h" /* @@ -162,22 +161,21 @@ static int call_sbin_request_key(struct key_construction *cons, * call out to userspace for key construction * - we ignore program failure and go on key status instead */ -static int construct_key(struct key *key, const void *callout_info, - size_t callout_len, void *aux) +static int construct_key(struct key *key, const char *callout_info, void *aux) { struct key_construction *cons; request_key_actor_t actor; struct key *authkey; int ret; - kenter("%d,%p,%zu,%p", key->serial, callout_info, callout_len, aux); + kenter("%d,%s,%p", key->serial, callout_info, aux); cons = kmalloc(sizeof(*cons), GFP_KERNEL); if (!cons) return -ENOMEM; /* allocate an authorisation key */ - authkey = request_key_auth_new(key, callout_info, callout_len); + authkey = request_key_auth_new(key, callout_info); if (IS_ERR(authkey)) { kfree(cons); ret = PTR_ERR(authkey); @@ -333,7 +331,6 @@ static int construct_alloc_key(struct key_type *type, static struct key *construct_key_and_link(struct key_type *type, const char *description, const char *callout_info, - size_t callout_len, void *aux, struct key *dest_keyring, unsigned long flags) @@ -351,7 +348,7 @@ static struct key *construct_key_and_link(struct key_type *type, key_user_put(user); if (ret == 0) { - ret = construct_key(key, callout_info, callout_len, aux); + ret = construct_key(key, callout_info, aux); if (ret < 0) goto construction_failed; } @@ -373,8 +370,7 @@ static struct key *construct_key_and_link(struct key_type *type, */ struct key *request_key_and_link(struct key_type *type, const char *description, - const void *callout_info, - size_t callout_len, + const char *callout_info, void *aux, struct key *dest_keyring, unsigned long flags) @@ -382,8 +378,8 @@ struct key *request_key_and_link(struct key_type *type, struct key *key; key_ref_t key_ref; - kenter("%s,%s,%p,%zu,%p,%p,%lx", - type->name, description, callout_info, callout_len, aux, + kenter("%s,%s,%s,%p,%p,%lx", + type->name, description, callout_info, aux, dest_keyring, flags); /* search all the process keyrings for a key */ @@ -402,8 +398,7 @@ struct key *request_key_and_link(struct key_type *type, goto error; key = construct_key_and_link(type, description, callout_info, - callout_len, aux, dest_keyring, - flags); + aux, dest_keyring, flags); } error: @@ -439,13 +434,10 @@ struct key *request_key(struct key_type *type, const char *callout_info) { struct key *key; - size_t callout_len = 0; int ret; - if (callout_info) - callout_len = strlen(callout_info); - key = request_key_and_link(type, description, callout_info, callout_len, - NULL, NULL, KEY_ALLOC_IN_QUOTA); + key = request_key_and_link(type, description, callout_info, NULL, + NULL, KEY_ALLOC_IN_QUOTA); if (!IS_ERR(key)) { ret = wait_for_key_construction(key, false); if (ret < 0) { @@ -466,15 +458,14 @@ EXPORT_SYMBOL(request_key); */ struct key *request_key_with_auxdata(struct key_type *type, const char *description, - const void *callout_info, - size_t callout_len, + const char *callout_info, void *aux) { struct key *key; int ret; - key = request_key_and_link(type, description, callout_info, callout_len, - aux, NULL, KEY_ALLOC_IN_QUOTA); + key = request_key_and_link(type, description, callout_info, aux, + NULL, KEY_ALLOC_IN_QUOTA); if (!IS_ERR(key)) { ret = wait_for_key_construction(key, false); if (ret < 0) { @@ -494,12 +485,10 @@ EXPORT_SYMBOL(request_key_with_auxdata); */ struct key *request_key_async(struct key_type *type, const char *description, - const void *callout_info, - size_t callout_len) + const char *callout_info) { - return request_key_and_link(type, description, callout_info, - callout_len, NULL, NULL, - KEY_ALLOC_IN_QUOTA); + return request_key_and_link(type, description, callout_info, NULL, + NULL, KEY_ALLOC_IN_QUOTA); } EXPORT_SYMBOL(request_key_async); @@ -511,11 +500,10 @@ EXPORT_SYMBOL(request_key_async); */ struct key *request_key_async_with_auxdata(struct key_type *type, const char *description, - const void *callout_info, - size_t callout_len, + const char *callout_info, void *aux) { - return request_key_and_link(type, description, callout_info, - callout_len, aux, NULL, KEY_ALLOC_IN_QUOTA); + return request_key_and_link(type, description, callout_info, aux, + NULL, KEY_ALLOC_IN_QUOTA); } EXPORT_SYMBOL(request_key_async_with_auxdata); diff --git a/trunk/security/keys/request_key_auth.c b/trunk/security/keys/request_key_auth.c index bd237b0a6331..e42b5252486f 100644 --- a/trunk/security/keys/request_key_auth.c +++ b/trunk/security/keys/request_key_auth.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include "internal.h" @@ -62,7 +61,7 @@ static void request_key_auth_describe(const struct key *key, seq_puts(m, "key:"); seq_puts(m, key->description); - seq_printf(m, " pid:%d ci:%zu", rka->pid, rka->callout_len); + seq_printf(m, " pid:%d ci:%zu", rka->pid, strlen(rka->callout_info)); } /* end request_key_auth_describe() */ @@ -78,7 +77,7 @@ static long request_key_auth_read(const struct key *key, size_t datalen; long ret; - datalen = rka->callout_len; + datalen = strlen(rka->callout_info); ret = datalen; /* we can return the data as is */ @@ -138,8 +137,7 @@ static void request_key_auth_destroy(struct key *key) * create an authorisation token for /sbin/request-key or whoever to gain * access to the caller's security data */ -struct key *request_key_auth_new(struct key *target, const void *callout_info, - size_t callout_len) +struct key *request_key_auth_new(struct key *target, const char *callout_info) { struct request_key_auth *rka, *irka; struct key *authkey = NULL; @@ -154,7 +152,7 @@ struct key *request_key_auth_new(struct key *target, const void *callout_info, kleave(" = -ENOMEM"); return ERR_PTR(-ENOMEM); } - rka->callout_info = kmalloc(callout_len, GFP_KERNEL); + rka->callout_info = kmalloc(strlen(callout_info) + 1, GFP_KERNEL); if (!rka->callout_info) { kleave(" = -ENOMEM"); kfree(rka); @@ -188,8 +186,7 @@ struct key *request_key_auth_new(struct key *target, const void *callout_info, } rka->target_key = key_get(target); - memcpy(rka->callout_info, callout_info, callout_len); - rka->callout_len = callout_len; + strcpy(rka->callout_info, callout_info); /* allocate the auth key */ sprintf(desc, "%x", target->serial); diff --git a/trunk/security/keys/sysctl.c b/trunk/security/keys/sysctl.c deleted file mode 100644 index b611d493c2d8..000000000000 --- a/trunk/security/keys/sysctl.c +++ /dev/null @@ -1,50 +0,0 @@ -/* Key management controls - * - * Copyright (C) 2008 Red Hat, Inc. All Rights Reserved. - * Written by David Howells (dhowells@redhat.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public Licence - * as published by the Free Software Foundation; either version - * 2 of the Licence, or (at your option) any later version. - */ - -#include -#include -#include "internal.h" - -ctl_table key_sysctls[] = { - { - .ctl_name = CTL_UNNUMBERED, - .procname = "maxkeys", - .data = &key_quota_maxkeys, - .maxlen = sizeof(unsigned), - .mode = 0644, - .proc_handler = &proc_dointvec, - }, - { - .ctl_name = CTL_UNNUMBERED, - .procname = "maxbytes", - .data = &key_quota_maxbytes, - .maxlen = sizeof(unsigned), - .mode = 0644, - .proc_handler = &proc_dointvec, - }, - { - .ctl_name = CTL_UNNUMBERED, - .procname = "root_maxkeys", - .data = &key_quota_root_maxkeys, - .maxlen = sizeof(unsigned), - .mode = 0644, - .proc_handler = &proc_dointvec, - }, - { - .ctl_name = CTL_UNNUMBERED, - .procname = "root_maxbytes", - .data = &key_quota_root_maxbytes, - .maxlen = sizeof(unsigned), - .mode = 0644, - .proc_handler = &proc_dointvec, - }, - { .ctl_name = 0 } -}; diff --git a/trunk/security/security.c b/trunk/security/security.c index 59838a99b80e..d5cb5898d967 100644 --- a/trunk/security/security.c +++ b/trunk/security/security.c @@ -491,23 +491,23 @@ void security_inode_delete(struct inode *inode) security_ops->inode_delete(inode); } -int security_inode_setxattr(struct dentry *dentry, const char *name, - const void *value, size_t size, int flags) +int security_inode_setxattr(struct dentry *dentry, char *name, + void *value, size_t size, int flags) { if (unlikely(IS_PRIVATE(dentry->d_inode))) return 0; return security_ops->inode_setxattr(dentry, name, value, size, flags); } -void security_inode_post_setxattr(struct dentry *dentry, const char *name, - const void *value, size_t size, int flags) +void security_inode_post_setxattr(struct dentry *dentry, char *name, + void *value, size_t size, int flags) { if (unlikely(IS_PRIVATE(dentry->d_inode))) return; security_ops->inode_post_setxattr(dentry, name, value, size, flags); } -int security_inode_getxattr(struct dentry *dentry, const char *name) +int security_inode_getxattr(struct dentry *dentry, char *name) { if (unlikely(IS_PRIVATE(dentry->d_inode))) return 0; @@ -521,7 +521,7 @@ int security_inode_listxattr(struct dentry *dentry) return security_ops->inode_listxattr(dentry); } -int security_inode_removexattr(struct dentry *dentry, const char *name) +int security_inode_removexattr(struct dentry *dentry, char *name) { if (unlikely(IS_PRIVATE(dentry->d_inode))) return 0; @@ -886,7 +886,7 @@ int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen) } EXPORT_SYMBOL(security_secid_to_secctx); -int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid) +int security_secctx_to_secid(char *secdata, u32 seclen, u32 *secid) { return security_ops->secctx_to_secid(secdata, seclen, secid); } @@ -1156,11 +1156,6 @@ int security_key_permission(key_ref_t key_ref, return security_ops->key_permission(key_ref, context, perm); } -int security_key_getsecurity(struct key *key, char **_buffer) -{ - return security_ops->key_getsecurity(key, _buffer); -} - #endif /* CONFIG_KEYS */ #ifdef CONFIG_AUDIT diff --git a/trunk/security/selinux/avc.c b/trunk/security/selinux/avc.c index 114b4b4c97b2..95a8ef4a5073 100644 --- a/trunk/security/selinux/avc.c +++ b/trunk/security/selinux/avc.c @@ -646,7 +646,7 @@ void avc_audit(u32 ssid, u32 tsid, if (*p) audit_log_untrustedstring(ab, p); else - audit_log_n_hex(ab, p, len); + audit_log_hex(ab, p, len); break; } } diff --git a/trunk/security/selinux/hooks.c b/trunk/security/selinux/hooks.c index 85a220465a8f..04acb5af8317 100644 --- a/trunk/security/selinux/hooks.c +++ b/trunk/security/selinux/hooks.c @@ -2619,7 +2619,7 @@ static int selinux_inode_getattr(struct vfsmount *mnt, struct dentry *dentry) return dentry_has_perm(current, mnt, dentry, FILE__GETATTR); } -static int selinux_inode_setotherxattr(struct dentry *dentry, const char *name) +static int selinux_inode_setotherxattr(struct dentry *dentry, char *name) { if (!strncmp(name, XATTR_SECURITY_PREFIX, sizeof XATTR_SECURITY_PREFIX - 1)) { @@ -2638,8 +2638,7 @@ static int selinux_inode_setotherxattr(struct dentry *dentry, const char *name) return dentry_has_perm(current, NULL, dentry, FILE__SETATTR); } -static int selinux_inode_setxattr(struct dentry *dentry, const char *name, - const void *value, size_t size, int flags) +static int selinux_inode_setxattr(struct dentry *dentry, char *name, void *value, size_t size, int flags) { struct task_security_struct *tsec = current->security; struct inode *inode = dentry->d_inode; @@ -2688,9 +2687,8 @@ static int selinux_inode_setxattr(struct dentry *dentry, const char *name, &ad); } -static void selinux_inode_post_setxattr(struct dentry *dentry, const char *name, - const void *value, size_t size, - int flags) +static void selinux_inode_post_setxattr(struct dentry *dentry, char *name, + void *value, size_t size, int flags) { struct inode *inode = dentry->d_inode; struct inode_security_struct *isec = inode->i_security; @@ -2713,7 +2711,7 @@ static void selinux_inode_post_setxattr(struct dentry *dentry, const char *name, return; } -static int selinux_inode_getxattr(struct dentry *dentry, const char *name) +static int selinux_inode_getxattr(struct dentry *dentry, char *name) { return dentry_has_perm(current, NULL, dentry, FILE__GETATTR); } @@ -2723,7 +2721,7 @@ static int selinux_inode_listxattr(struct dentry *dentry) return dentry_has_perm(current, NULL, dentry, FILE__GETATTR); } -static int selinux_inode_removexattr(struct dentry *dentry, const char *name) +static int selinux_inode_removexattr(struct dentry *dentry, char *name) { if (strcmp(name, XATTR_NAME_SELINUX)) return selinux_inode_setotherxattr(dentry, name); @@ -5238,7 +5236,7 @@ static int selinux_secid_to_secctx(u32 secid, char **secdata, u32 *seclen) return security_sid_to_context(secid, secdata, seclen); } -static int selinux_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid) +static int selinux_secctx_to_secid(char *secdata, u32 seclen, u32 *secid) { return security_context_to_sid(secdata, seclen, secid); } @@ -5300,20 +5298,6 @@ static int selinux_key_permission(key_ref_t key_ref, SECCLASS_KEY, perm, NULL); } -static int selinux_key_getsecurity(struct key *key, char **_buffer) -{ - struct key_security_struct *ksec = key->security; - char *context = NULL; - unsigned len; - int rc; - - rc = security_sid_to_context(ksec->sid, &context, &len); - if (!rc) - rc = len; - *_buffer = context; - return rc; -} - #endif static struct security_operations selinux_ops = { @@ -5502,7 +5486,6 @@ static struct security_operations selinux_ops = { .key_alloc = selinux_key_alloc, .key_free = selinux_key_free, .key_permission = selinux_key_permission, - .key_getsecurity = selinux_key_getsecurity, #endif #ifdef CONFIG_AUDIT @@ -5551,6 +5534,14 @@ static __init int selinux_init(void) else printk(KERN_DEBUG "SELinux: Starting in permissive mode\n"); +#ifdef CONFIG_KEYS + /* Add security information to initial keyrings */ + selinux_key_alloc(&root_user_keyring, current, + KEY_ALLOC_NOT_IN_QUOTA); + selinux_key_alloc(&root_session_keyring, current, + KEY_ALLOC_NOT_IN_QUOTA); +#endif + return 0; } diff --git a/trunk/security/selinux/include/security.h b/trunk/security/selinux/include/security.h index ad30ac4273d6..6445b6440648 100644 --- a/trunk/security/selinux/include/security.h +++ b/trunk/security/selinux/include/security.h @@ -93,10 +93,10 @@ int security_change_sid(u32 ssid, u32 tsid, int security_sid_to_context(u32 sid, char **scontext, u32 *scontext_len); -int security_context_to_sid(const char *scontext, u32 scontext_len, +int security_context_to_sid(char *scontext, u32 scontext_len, u32 *out_sid); -int security_context_to_sid_default(const char *scontext, u32 scontext_len, +int security_context_to_sid_default(char *scontext, u32 scontext_len, u32 *out_sid, u32 def_sid, gfp_t gfp_flags); int security_get_user_sids(u32 callsid, char *username, diff --git a/trunk/security/selinux/ss/services.c b/trunk/security/selinux/ss/services.c index dcc2e1c4fd83..2daaddbb301d 100644 --- a/trunk/security/selinux/ss/services.c +++ b/trunk/security/selinux/ss/services.c @@ -708,7 +708,7 @@ int security_sid_to_context(u32 sid, char **scontext, u32 *scontext_len) } -static int security_context_to_sid_core(const char *scontext, u32 scontext_len, +static int security_context_to_sid_core(char *scontext, u32 scontext_len, u32 *sid, u32 def_sid, gfp_t gfp_flags) { char *scontext2; @@ -835,7 +835,7 @@ static int security_context_to_sid_core(const char *scontext, u32 scontext_len, * Returns -%EINVAL if the context is invalid, -%ENOMEM if insufficient * memory is available, or 0 on success. */ -int security_context_to_sid(const char *scontext, u32 scontext_len, u32 *sid) +int security_context_to_sid(char *scontext, u32 scontext_len, u32 *sid) { return security_context_to_sid_core(scontext, scontext_len, sid, SECSID_NULL, GFP_KERNEL); @@ -858,8 +858,8 @@ int security_context_to_sid(const char *scontext, u32 scontext_len, u32 *sid) * Returns -%EINVAL if the context is invalid, -%ENOMEM if insufficient * memory is available, or 0 on success. */ -int security_context_to_sid_default(const char *scontext, u32 scontext_len, - u32 *sid, u32 def_sid, gfp_t gfp_flags) +int security_context_to_sid_default(char *scontext, u32 scontext_len, u32 *sid, + u32 def_sid, gfp_t gfp_flags) { return security_context_to_sid_core(scontext, scontext_len, sid, def_sid, gfp_flags); diff --git a/trunk/security/smack/smack_lsm.c b/trunk/security/smack/smack_lsm.c index fe0ae1bf1650..77ec16a3b68b 100644 --- a/trunk/security/smack/smack_lsm.c +++ b/trunk/security/smack/smack_lsm.c @@ -26,7 +26,6 @@ #include #include #include -#include #include "smack.h" @@ -575,8 +574,8 @@ static int smack_inode_getattr(struct vfsmount *mnt, struct dentry *dentry) * * Returns 0 if access is permitted, an error code otherwise */ -static int smack_inode_setxattr(struct dentry *dentry, const char *name, - const void *value, size_t size, int flags) +static int smack_inode_setxattr(struct dentry *dentry, char *name, + void *value, size_t size, int flags) { int rc = 0; @@ -605,8 +604,8 @@ static int smack_inode_setxattr(struct dentry *dentry, const char *name, * Set the pointer in the inode blob to the entry found * in the master label list. */ -static void smack_inode_post_setxattr(struct dentry *dentry, const char *name, - const void *value, size_t size, int flags) +static void smack_inode_post_setxattr(struct dentry *dentry, char *name, + void *value, size_t size, int flags) { struct inode_smack *isp; char *nsp; @@ -642,7 +641,7 @@ static void smack_inode_post_setxattr(struct dentry *dentry, const char *name, * * Returns 0 if access is permitted, an error code otherwise */ -static int smack_inode_getxattr(struct dentry *dentry, const char *name) +static int smack_inode_getxattr(struct dentry *dentry, char *name) { return smk_curacc(smk_of_inode(dentry->d_inode), MAY_READ); } @@ -656,7 +655,7 @@ static int smack_inode_getxattr(struct dentry *dentry, const char *name) * * Returns 0 if access is permitted, an error code otherwise */ -static int smack_inode_removexattr(struct dentry *dentry, const char *name) +static int smack_inode_removexattr(struct dentry *dentry, char *name) { int rc = 0; @@ -753,18 +752,6 @@ static int smack_inode_listsecurity(struct inode *inode, char *buffer, return -EINVAL; } -/** - * smack_inode_getsecid - Extract inode's security id - * @inode: inode to extract the info from - * @secid: where result will be saved - */ -static void smack_inode_getsecid(const struct inode *inode, u32 *secid) -{ - struct inode_smack *isp = inode->i_security; - - *secid = smack_to_secid(isp->smk_inode); -} - /* * File Hooks */ @@ -1818,18 +1805,6 @@ static int smack_ipc_permission(struct kern_ipc_perm *ipp, short flag) return smk_curacc(isp, may); } -/** - * smack_ipc_getsecid - Extract smack security id - * @ipcp: the object permissions - * @secid: where result will be saved - */ -static void smack_ipc_getsecid(struct kern_ipc_perm *ipp, u32 *secid) -{ - char *smack = ipp->security; - - *secid = smack_to_secid(smack); -} - /* module stacking operations */ /** @@ -2406,124 +2381,6 @@ static int smack_key_permission(key_ref_t key_ref, } #endif /* CONFIG_KEYS */ -/* - * Smack Audit hooks - * - * Audit requires a unique representation of each Smack specific - * rule. This unique representation is used to distinguish the - * object to be audited from remaining kernel objects and also - * works as a glue between the audit hooks. - * - * Since repository entries are added but never deleted, we'll use - * the smack_known label address related to the given audit rule as - * the needed unique representation. This also better fits the smack - * model where nearly everything is a label. - */ -#ifdef CONFIG_AUDIT - -/** - * smack_audit_rule_init - Initialize a smack audit rule - * @field: audit rule fields given from user-space (audit.h) - * @op: required testing operator (=, !=, >, <, ...) - * @rulestr: smack label to be audited - * @vrule: pointer to save our own audit rule representation - * - * Prepare to audit cases where (@field @op @rulestr) is true. - * The label to be audited is created if necessay. - */ -static int smack_audit_rule_init(u32 field, u32 op, char *rulestr, void **vrule) -{ - char **rule = (char **)vrule; - *rule = NULL; - - if (field != AUDIT_SUBJ_USER && field != AUDIT_OBJ_USER) - return -EINVAL; - - if (op != AUDIT_EQUAL && op != AUDIT_NOT_EQUAL) - return -EINVAL; - - *rule = smk_import(rulestr, 0); - - return 0; -} - -/** - * smack_audit_rule_known - Distinguish Smack audit rules - * @krule: rule of interest, in Audit kernel representation format - * - * This is used to filter Smack rules from remaining Audit ones. - * If it's proved that this rule belongs to us, the - * audit_rule_match hook will be called to do the final judgement. - */ -static int smack_audit_rule_known(struct audit_krule *krule) -{ - struct audit_field *f; - int i; - - for (i = 0; i < krule->field_count; i++) { - f = &krule->fields[i]; - - if (f->type == AUDIT_SUBJ_USER || f->type == AUDIT_OBJ_USER) - return 1; - } - - return 0; -} - -/** - * smack_audit_rule_match - Audit given object ? - * @secid: security id for identifying the object to test - * @field: audit rule flags given from user-space - * @op: required testing operator - * @vrule: smack internal rule presentation - * @actx: audit context associated with the check - * - * The core Audit hook. It's used to take the decision of - * whether to audit or not to audit a given object. - */ -static int smack_audit_rule_match(u32 secid, u32 field, u32 op, void *vrule, - struct audit_context *actx) -{ - char *smack; - char *rule = vrule; - - if (!rule) { - audit_log(actx, GFP_KERNEL, AUDIT_SELINUX_ERR, - "Smack: missing rule\n"); - return -ENOENT; - } - - if (field != AUDIT_SUBJ_USER && field != AUDIT_OBJ_USER) - return 0; - - smack = smack_from_secid(secid); - - /* - * No need to do string comparisons. If a match occurs, - * both pointers will point to the same smack_known - * label. - */ - if (op == AUDIT_EQUAL) - return (rule == smack); - if (op == AUDIT_NOT_EQUAL) - return (rule != smack); - - return 0; -} - -/** - * smack_audit_rule_free - free smack rule representation - * @vrule: rule to be freed. - * - * No memory was allocated. - */ -static void smack_audit_rule_free(void *vrule) -{ - /* No-op */ -} - -#endif /* CONFIG_AUDIT */ - /* * smack_secid_to_secctx - return the smack label for a secid * @secid: incoming integer @@ -2549,7 +2406,7 @@ static int smack_secid_to_secctx(u32 secid, char **secdata, u32 *seclen) * * Exists for audit and networking code. */ -static int smack_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid) +static int smack_secctx_to_secid(char *secdata, u32 seclen, u32 *secid) { *secid = smack_to_secid(secdata); return 0; @@ -2610,7 +2467,6 @@ struct security_operations smack_ops = { .inode_getsecurity = smack_inode_getsecurity, .inode_setsecurity = smack_inode_setsecurity, .inode_listsecurity = smack_inode_listsecurity, - .inode_getsecid = smack_inode_getsecid, .file_permission = smack_file_permission, .file_alloc_security = smack_file_alloc_security, @@ -2642,7 +2498,6 @@ struct security_operations smack_ops = { .task_prctl = cap_task_prctl, .ipc_permission = smack_ipc_permission, - .ipc_getsecid = smack_ipc_getsecid, .msg_msg_alloc_security = smack_msg_msg_alloc_security, .msg_msg_free_security = smack_msg_msg_free_security, @@ -2687,22 +2542,12 @@ struct security_operations smack_ops = { .sk_free_security = smack_sk_free_security, .sock_graft = smack_sock_graft, .inet_conn_request = smack_inet_conn_request, - /* key management security hooks */ #ifdef CONFIG_KEYS .key_alloc = smack_key_alloc, .key_free = smack_key_free, .key_permission = smack_key_permission, #endif /* CONFIG_KEYS */ - - /* Audit hooks */ -#ifdef CONFIG_AUDIT - .audit_rule_init = smack_audit_rule_init, - .audit_rule_known = smack_audit_rule_known, - .audit_rule_match = smack_audit_rule_match, - .audit_rule_free = smack_audit_rule_free, -#endif /* CONFIG_AUDIT */ - .secid_to_secctx = smack_secid_to_secctx, .secctx_to_secid = smack_secctx_to_secid, .release_secctx = smack_release_secctx, diff --git a/trunk/security/smack/smackfs.c b/trunk/security/smack/smackfs.c index 271a835fbbe3..a5da5a8cfe9b 100644 --- a/trunk/security/smack/smackfs.c +++ b/trunk/security/smack/smackfs.c @@ -324,7 +324,6 @@ static void smk_cipso_doi(void) struct netlbl_audit audit_info; audit_info.loginuid = audit_get_loginuid(current); - audit_info.sessionid = audit_get_sessionid(current); audit_info.secid = smack_to_secid(current->security); rc = netlbl_cfg_map_del(NULL, &audit_info); @@ -357,7 +356,6 @@ static void smk_unlbl_ambient(char *oldambient) struct netlbl_audit audit_info; audit_info.loginuid = audit_get_loginuid(current); - audit_info.sessionid = audit_get_sessionid(current); audit_info.secid = smack_to_secid(current->security); if (oldambient != NULL) { diff --git a/trunk/sound/core/info.c b/trunk/sound/core/info.c index cb5ead3e202d..9977ec2eace3 100644 --- a/trunk/sound/core/info.c +++ b/trunk/sound/core/info.c @@ -544,7 +544,7 @@ int __init snd_info_init(void) { struct proc_dir_entry *p; - p = snd_create_proc_entry("asound", S_IFDIR | S_IRUGO | S_IXUGO, NULL); + p = snd_create_proc_entry("asound", S_IFDIR | S_IRUGO | S_IXUGO, &proc_root); if (p == NULL) return -ENOMEM; snd_proc_root = p; @@ -594,7 +594,7 @@ int __exit snd_info_done(void) #ifdef CONFIG_SND_OSSEMUL snd_info_free_entry(snd_oss_root); #endif - snd_remove_proc_entry(NULL, snd_proc_root); + snd_remove_proc_entry(&proc_root, snd_proc_root); } return 0; } diff --git a/trunk/sound/core/memalloc.c b/trunk/sound/core/memalloc.c index 23b7bc02728b..920e5780c228 100644 --- a/trunk/sound/core/memalloc.c +++ b/trunk/sound/core/memalloc.c @@ -629,8 +629,9 @@ static const struct file_operations snd_mem_proc_fops = { static int __init snd_mem_init(void) { #ifdef CONFIG_PROC_FS - snd_mem_proc = proc_create(SND_MEM_PROC_FILE, 0644, NULL, - &snd_mem_proc_fops); + snd_mem_proc = create_proc_entry(SND_MEM_PROC_FILE, 0644, NULL); + if (snd_mem_proc) + snd_mem_proc->proc_fops = &snd_mem_proc_fops; #endif return 0; } diff --git a/trunk/sound/drivers/Kconfig b/trunk/sound/drivers/Kconfig index a78a8d045175..fe85af1c5693 100644 --- a/trunk/sound/drivers/Kconfig +++ b/trunk/sound/drivers/Kconfig @@ -8,8 +8,6 @@ config SND_PCSP tristate "Internal PC speaker support" depends on X86_PC && HIGH_RES_TIMERS depends on INPUT - depends on SND - select SND_PCM help If you don't have a sound card in your computer, you can include a driver for the PC speaker which allows it to act like a primitive diff --git a/trunk/sound/drivers/mpu401/mpu401_uart.c b/trunk/sound/drivers/mpu401/mpu401_uart.c index 2af09996a3d0..18cca2457d44 100644 --- a/trunk/sound/drivers/mpu401/mpu401_uart.c +++ b/trunk/sound/drivers/mpu401/mpu401_uart.c @@ -243,7 +243,7 @@ static int snd_mpu401_uart_cmd(struct snd_mpu401 * mpu, unsigned char cmd, #endif } mpu->write(mpu, cmd, MPU401C(mpu)); - if (ack && !(mpu->info_flags & MPU401_INFO_NO_ACK)) { + if (ack) { ok = 0; timeout = 10000; while (!ok && timeout-- > 0) { diff --git a/trunk/sound/pci/hda/patch_realtek.c b/trunk/sound/pci/hda/patch_realtek.c index d9783a4263e0..cdda64b02f46 100644 --- a/trunk/sound/pci/hda/patch_realtek.c +++ b/trunk/sound/pci/hda/patch_realtek.c @@ -60,7 +60,6 @@ enum { ALC880_TCL_S700, ALC880_LG, ALC880_LG_LW, - ALC880_MEDION_RIM, #ifdef CONFIG_SND_DEBUG ALC880_TEST, #endif @@ -2276,75 +2275,6 @@ static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res) alc880_lg_lw_automute(codec); } -static struct snd_kcontrol_new alc880_medion_rim_mixer[] = { - HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT), - HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT), - HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), - HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), - HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), - HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT), - { } /* end */ -}; - -static struct hda_input_mux alc880_medion_rim_capture_source = { - .num_items = 2, - .items = { - { "Mic", 0x0 }, - { "Internal Mic", 0x1 }, - }, -}; - -static struct hda_verb alc880_medion_rim_init_verbs[] = { - {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ - - {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, - {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, - - /* Mic1 (rear panel) pin widget for input and vref at 80% */ - {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, - {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, - /* Mic2 (as headphone out) for HP output */ - {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, - {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, - /* Internal Speaker */ - {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, - {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, - - {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, - {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, - - {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, - { } -}; - -/* toggle speaker-output according to the hp-jack state */ -static void alc880_medion_rim_automute(struct hda_codec *codec) -{ - unsigned int present; - unsigned char bits; - - present = snd_hda_codec_read(codec, 0x14, 0, - AC_VERB_GET_PIN_SENSE, 0) - & AC_PINSENSE_PRESENCE; - bits = present ? HDA_AMP_MUTE : 0; - snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0, - HDA_AMP_MUTE, bits); - if (present) - snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0); - else - snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2); -} - -static void alc880_medion_rim_unsol_event(struct hda_codec *codec, - unsigned int res) -{ - /* Looks like the unsol event is incompatible with the standard - * definition. 4bit tag is placed at 28 bit! - */ - if ((res >> 28) == ALC880_HP_EVENT) - alc880_medion_rim_automute(codec); -} - #ifdef CONFIG_SND_HDA_POWER_SAVE static struct hda_amp_list alc880_loopbacks[] = { { 0x0b, HDA_INPUT, 0 }, @@ -2952,7 +2882,6 @@ static const char *alc880_models[ALC880_MODEL_LAST] = { [ALC880_F1734] = "F1734", [ALC880_LG] = "lg", [ALC880_LG_LW] = "lg-lw", - [ALC880_MEDION_RIM] = "medion", #ifdef CONFIG_SND_DEBUG [ALC880_TEST] = "test", #endif @@ -3004,7 +2933,6 @@ static struct snd_pci_quirk alc880_cfg_tbl[] = { SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL), SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53), SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810), - SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM), SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG), SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG), SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734), @@ -3299,20 +3227,6 @@ static struct alc_config_preset alc880_presets[] = { .unsol_event = alc880_lg_lw_unsol_event, .init_hook = alc880_lg_lw_automute, }, - [ALC880_MEDION_RIM] = { - .mixers = { alc880_medion_rim_mixer }, - .init_verbs = { alc880_volume_init_verbs, - alc880_medion_rim_init_verbs, - alc_gpio2_init_verbs }, - .num_dacs = ARRAY_SIZE(alc880_dac_nids), - .dac_nids = alc880_dac_nids, - .dig_out_nid = ALC880_DIGOUT_NID, - .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), - .channel_mode = alc880_2_jack_modes, - .input_mux = &alc880_medion_rim_capture_source, - .unsol_event = alc880_medion_rim_unsol_event, - .init_hook = alc880_medion_rim_automute, - }, #ifdef CONFIG_SND_DEBUG [ALC880_TEST] = { .mixers = { alc880_test_mixer }, diff --git a/trunk/sound/pci/ice1712/ice1724.c b/trunk/sound/pci/ice1712/ice1724.c index 67350901772c..4490422fb930 100644 --- a/trunk/sound/pci/ice1712/ice1724.c +++ b/trunk/sound/pci/ice1712/ice1724.c @@ -2429,7 +2429,6 @@ static int __devinit snd_vt1724_probe(struct pci_dev *pci, if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_ICE1712, ICEREG1724(ice, MPU_CTRL), (MPU401_INFO_INTEGRATED | - MPU401_INFO_NO_ACK | MPU401_INFO_TX_IRQ), ice->irq, 0, &ice->rmidi[0])) < 0) { @@ -2443,10 +2442,12 @@ static int __devinit snd_vt1724_probe(struct pci_dev *pci, outb(inb(ICEREG1724(ice, IRQMASK)) & ~(VT1724_IRQ_MPU_RX | VT1724_IRQ_MPU_TX), ICEREG1724(ice, IRQMASK)); +#if 0 /* for testing */ /* set watermarks */ outb(VT1724_MPU_RX_FIFO | 0x1, ICEREG1724(ice, MPU_FIFO_WM)); outb(0x1, ICEREG1724(ice, MPU_FIFO_WM)); +#endif } } diff --git a/trunk/sound/sh/aica.c b/trunk/sound/sh/aica.c index 9ca113326143..d49417bf78c6 100644 --- a/trunk/sound/sh/aica.c +++ b/trunk/sound/sh/aica.c @@ -663,7 +663,7 @@ static int __init aica_init(void) return err; pd = platform_device_register_simple(SND_AICA_DRIVER, -1, aica_memory_space, 2); - if (IS_ERR(pd)) { + if (unlikely(IS_ERR(pd))) { platform_driver_unregister(&snd_aica_driver); return PTR_ERR(pd); } diff --git a/trunk/sound/soc/Kconfig b/trunk/sound/soc/Kconfig index 18f28ac4bfe8..a3b51df2bea1 100644 --- a/trunk/sound/soc/Kconfig +++ b/trunk/sound/soc/Kconfig @@ -30,7 +30,6 @@ source "sound/soc/s3c24xx/Kconfig" source "sound/soc/sh/Kconfig" source "sound/soc/fsl/Kconfig" source "sound/soc/davinci/Kconfig" -source "sound/soc/omap/Kconfig" # Supported codecs source "sound/soc/codecs/Kconfig" diff --git a/trunk/sound/soc/Makefile b/trunk/sound/soc/Makefile index 782db2127108..e489dbdde458 100644 --- a/trunk/sound/soc/Makefile +++ b/trunk/sound/soc/Makefile @@ -1,4 +1,4 @@ snd-soc-core-objs := soc-core.o soc-dapm.o obj-$(CONFIG_SND_SOC) += snd-soc-core.o -obj-$(CONFIG_SND_SOC) += codecs/ at91/ pxa/ s3c24xx/ sh/ fsl/ davinci/ omap/ +obj-$(CONFIG_SND_SOC) += codecs/ at91/ pxa/ s3c24xx/ sh/ fsl/ davinci/ diff --git a/trunk/sound/soc/codecs/wm9712.c b/trunk/sound/soc/codecs/wm9712.c index 76c1e2d33e7d..d2d79e182a45 100644 --- a/trunk/sound/soc/codecs/wm9712.c +++ b/trunk/sound/soc/codecs/wm9712.c @@ -37,23 +37,23 @@ static int ac97_write(struct snd_soc_codec *codec, * WM9712 register cache */ static const u16 wm9712_reg[] = { - 0x6174, 0x8000, 0x8000, 0x8000, /* 6 */ - 0x0f0f, 0xaaa0, 0xc008, 0x6808, /* e */ - 0xe808, 0xaaa0, 0xad00, 0x8000, /* 16 */ - 0xe808, 0x3000, 0x8000, 0x0000, /* 1e */ - 0x0000, 0x0000, 0x0000, 0x000f, /* 26 */ - 0x0405, 0x0410, 0xbb80, 0xbb80, /* 2e */ - 0x0000, 0xbb80, 0x0000, 0x0000, /* 36 */ - 0x0000, 0x2000, 0x0000, 0x0000, /* 3e */ - 0x0000, 0x0000, 0x0000, 0x0000, /* 46 */ - 0x0000, 0x0000, 0xf83e, 0xffff, /* 4e */ - 0x0000, 0x0000, 0x0000, 0xf83e, /* 56 */ - 0x0008, 0x0000, 0x0000, 0x0000, /* 5e */ - 0xb032, 0x3e00, 0x0000, 0x0000, /* 66 */ - 0x0000, 0x0000, 0x0000, 0x0000, /* 6e */ - 0x0000, 0x0000, 0x0000, 0x0006, /* 76 */ - 0x0001, 0x0000, 0x574d, 0x4c12, /* 7e */ - 0x0000, 0x0000 /* virtual hp mixers */ + 0x6174, 0x8000, 0x8000, 0x8000, // 6 + 0x0f0f, 0xaaa0, 0xc008, 0x6808, // e + 0xe808, 0xaaa0, 0xad00, 0x8000, // 16 + 0xe808, 0x3000, 0x8000, 0x0000, // 1e + 0x0000, 0x0000, 0x0000, 0x000f, // 26 + 0x0405, 0x0410, 0xbb80, 0xbb80, // 2e + 0x0000, 0xbb80, 0x0000, 0x0000, // 36 + 0x0000, 0x2000, 0x0000, 0x0000, // 3e + 0x0000, 0x0000, 0x0000, 0x0000, // 46 + 0x0000, 0x0000, 0xf83e, 0xffff, // 4e + 0x0000, 0x0000, 0x0000, 0xf83e, // 56 + 0x0008, 0x0000, 0x0000, 0x0000, // 5e + 0xb032, 0x3e00, 0x0000, 0x0000, // 66 + 0x0000, 0x0000, 0x0000, 0x0000, // 6e + 0x0000, 0x0000, 0x0000, 0x0006, // 76 + 0x0001, 0x0000, 0x574d, 0x4c12, // 7e + 0x0000, 0x0000 // virtual hp mixers }; /* virtual HP mixers regs */ @@ -94,7 +94,7 @@ static const struct snd_kcontrol_new wm9712_snd_ac97_controls[] = { SOC_DOUBLE("Speaker Playback Volume", AC97_MASTER, 8, 0, 31, 1), SOC_SINGLE("Speaker Playback Switch", AC97_MASTER, 15, 1, 1), SOC_DOUBLE("Headphone Playback Volume", AC97_HEADPHONE, 8, 0, 31, 1), -SOC_SINGLE("Headphone Playback Switch", AC97_HEADPHONE, 15, 1, 1), +SOC_SINGLE("Headphone Playback Switch", AC97_HEADPHONE,15, 1, 1), SOC_DOUBLE("PCM Playback Volume", AC97_PCM, 8, 0, 31, 1), SOC_SINGLE("Speaker Playback ZC Switch", AC97_MASTER, 7, 1, 0), @@ -165,8 +165,7 @@ static int wm9712_add_controls(struct snd_soc_codec *codec) for (i = 0; i < ARRAY_SIZE(wm9712_snd_ac97_controls); i++) { err = snd_ctl_add(codec->card, - snd_soc_cnew(&wm9712_snd_ac97_controls[i], - codec, NULL)); + snd_soc_cnew(&wm9712_snd_ac97_controls[i],codec, NULL)); if (err < 0) return err; } @@ -364,6 +363,7 @@ static const char *audio_map[][3] = { {"Left HP Mixer", "PCM Playback Switch", "Left DAC"}, {"Left HP Mixer", "Mic Sidetone Switch", "Mic PGA"}, {"Left HP Mixer", NULL, "ALC Sidetone Mux"}, + //{"Right HP Mixer", NULL, "HP Mixer"}, /* Right HP mixer */ {"Right HP Mixer", "PCBeep Bypass Switch", "PCBEEP"}, @@ -454,13 +454,15 @@ static int wm9712_add_widgets(struct snd_soc_codec *codec) { int i; - for (i = 0; i < ARRAY_SIZE(wm9712_dapm_widgets); i++) + for(i = 0; i < ARRAY_SIZE(wm9712_dapm_widgets); i++) { snd_soc_dapm_new_control(codec, &wm9712_dapm_widgets[i]); + } - /* set up audio path connects */ - for (i = 0; audio_map[i][0] != NULL; i++) + /* set up audio path audio_mapnects */ + for(i = 0; audio_map[i][0] != NULL; i++) { snd_soc_dapm_connect_input(codec, audio_map[i][0], - audio_map[i][1], audio_map[i][2]); + audio_map[i][1], audio_map[i][2]); + } snd_soc_dapm_new_widgets(codec); return 0; @@ -538,8 +540,7 @@ static int ac97_aux_prepare(struct snd_pcm_substream *substream) } #define WM9712_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ - SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 |\ - SNDRV_PCM_RATE_48000) + SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000) struct snd_soc_codec_dai wm9712_dai[] = { { @@ -576,6 +577,8 @@ EXPORT_SYMBOL_GPL(wm9712_dai); static int wm9712_dapm_event(struct snd_soc_codec *codec, int event) { + u16 reg; + switch (event) { case SNDRV_CTL_POWER_D0: /* full On */ case SNDRV_CTL_POWER_D1: /* partial On */ @@ -630,7 +633,7 @@ static int wm9712_soc_resume(struct platform_device *pdev) u16 *cache = codec->reg_cache; ret = wm9712_reset(codec, 1); - if (ret < 0) { + if (ret < 0){ printk(KERN_ERR "could not reset AC97 codec\n"); return ret; } @@ -639,9 +642,9 @@ static int wm9712_soc_resume(struct platform_device *pdev) if (ret == 0) { /* Sync reg_cache with the hardware after cold reset */ - for (i = 2; i < ARRAY_SIZE(wm9712_reg) << 1; i += 2) { + for (i = 2; i < ARRAY_SIZE(wm9712_reg) << 1; i+=2) { if (i == AC97_INT_PAGING || i == AC97_POWERDOWN || - (i > 0x58 && i != 0x5c)) + (i > 0x58 && i != 0x5c)) continue; soc_ac97_ops.write(codec->ac97, i, cache[i>>1]); } @@ -754,6 +757,7 @@ struct snd_soc_codec_device soc_codec_dev_wm9712 = { .suspend = wm9712_soc_suspend, .resume = wm9712_soc_resume, }; + EXPORT_SYMBOL_GPL(soc_codec_dev_wm9712); MODULE_DESCRIPTION("ASoC WM9711/WM9712 driver"); diff --git a/trunk/sound/soc/omap/Kconfig b/trunk/sound/soc/omap/Kconfig deleted file mode 100644 index 0230d83e8e5e..000000000000 --- a/trunk/sound/soc/omap/Kconfig +++ /dev/null @@ -1,19 +0,0 @@ -menu "SoC Audio for the Texas Instruments OMAP" - -config SND_OMAP_SOC - tristate "SoC Audio for the Texas Instruments OMAP chips" - depends on ARCH_OMAP && SND_SOC - -config SND_OMAP_SOC_MCBSP - tristate - select OMAP_MCBSP - -config SND_OMAP_SOC_N810 - tristate "SoC Audio support for Nokia N810" - depends on SND_OMAP_SOC && MACH_NOKIA_N810 - select SND_OMAP_SOC_MCBSP - select SND_SOC_TLV320AIC3X - help - Say Y if you want to add support for SoC audio on Nokia N810. - -endmenu diff --git a/trunk/sound/soc/omap/Makefile b/trunk/sound/soc/omap/Makefile deleted file mode 100644 index d8d8d58075e3..000000000000 --- a/trunk/sound/soc/omap/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# OMAP Platform Support -snd-soc-omap-objs := omap-pcm.o -snd-soc-omap-mcbsp-objs := omap-mcbsp.o - -obj-$(CONFIG_SND_OMAP_SOC) += snd-soc-omap.o -obj-$(CONFIG_SND_OMAP_SOC_MCBSP) += snd-soc-omap-mcbsp.o - -# OMAP Machine Support -snd-soc-n810-objs := n810.o - -obj-$(CONFIG_SND_OMAP_SOC_N810) += snd-soc-n810.o diff --git a/trunk/sound/soc/omap/n810.c b/trunk/sound/soc/omap/n810.c deleted file mode 100644 index 83b1eb4e40f3..000000000000 --- a/trunk/sound/soc/omap/n810.c +++ /dev/null @@ -1,336 +0,0 @@ -/* - * n810.c -- SoC audio for Nokia N810 - * - * Copyright (C) 2008 Nokia Corporation - * - * Contact: Jarkko Nikula - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "omap-mcbsp.h" -#include "omap-pcm.h" -#include "../codecs/tlv320aic3x.h" - -#define RX44_HEADSET_AMP_GPIO 10 -#define RX44_SPEAKER_AMP_GPIO 101 - -static struct clk *sys_clkout2; -static struct clk *sys_clkout2_src; -static struct clk *func96m_clk; - -static int n810_spk_func; -static int n810_jack_func; - -static void n810_ext_control(struct snd_soc_codec *codec) -{ - snd_soc_dapm_set_endpoint(codec, "Ext Spk", n810_spk_func); - snd_soc_dapm_set_endpoint(codec, "Headphone Jack", n810_jack_func); - - snd_soc_dapm_sync_endpoints(codec); -} - -static int n810_startup(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_codec *codec = rtd->socdev->codec; - - n810_ext_control(codec); - return clk_enable(sys_clkout2); -} - -static void n810_shutdown(struct snd_pcm_substream *substream) -{ - clk_disable(sys_clkout2); -} - -static int n810_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_codec_dai *codec_dai = rtd->dai->codec_dai; - struct snd_soc_cpu_dai *cpu_dai = rtd->dai->cpu_dai; - int err; - - /* Set codec DAI configuration */ - err = codec_dai->dai_ops.set_fmt(codec_dai, - SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBM_CFM); - if (err < 0) - return err; - - /* Set cpu DAI configuration */ - err = cpu_dai->dai_ops.set_fmt(cpu_dai, - SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBM_CFM); - if (err < 0) - return err; - - /* Set the codec system clock for DAC and ADC */ - err = codec_dai->dai_ops.set_sysclk(codec_dai, 0, 12000000, - SND_SOC_CLOCK_IN); - - return err; -} - -static struct snd_soc_ops n810_ops = { - .startup = n810_startup, - .hw_params = n810_hw_params, - .shutdown = n810_shutdown, -}; - -static int n810_get_spk(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = n810_spk_func; - - return 0; -} - -static int n810_set_spk(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - - if (n810_spk_func == ucontrol->value.integer.value[0]) - return 0; - - n810_spk_func = ucontrol->value.integer.value[0]; - n810_ext_control(codec); - - return 1; -} - -static int n810_get_jack(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = n810_jack_func; - - return 0; -} - -static int n810_set_jack(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - - if (n810_jack_func == ucontrol->value.integer.value[0]) - return 0; - - n810_jack_func = ucontrol->value.integer.value[0]; - n810_ext_control(codec); - - return 1; -} - -static int n810_spk_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *k, int event) -{ - if (SND_SOC_DAPM_EVENT_ON(event)) - omap_set_gpio_dataout(RX44_SPEAKER_AMP_GPIO, 1); - else - omap_set_gpio_dataout(RX44_SPEAKER_AMP_GPIO, 0); - - return 0; -} - -static int n810_jack_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *k, int event) -{ - if (SND_SOC_DAPM_EVENT_ON(event)) - omap_set_gpio_dataout(RX44_HEADSET_AMP_GPIO, 1); - else - omap_set_gpio_dataout(RX44_HEADSET_AMP_GPIO, 0); - - return 0; -} - -static const struct snd_soc_dapm_widget aic33_dapm_widgets[] = { - SND_SOC_DAPM_SPK("Ext Spk", n810_spk_event), - SND_SOC_DAPM_HP("Headphone Jack", n810_jack_event), -}; - -static const char *audio_map[][3] = { - {"Headphone Jack", NULL, "HPLOUT"}, - {"Headphone Jack", NULL, "HPROUT"}, - - {"Ext Spk", NULL, "LLOUT"}, - {"Ext Spk", NULL, "RLOUT"}, -}; - -static const char *spk_function[] = {"Off", "On"}; -static const char *jack_function[] = {"Off", "Headphone"}; -static const struct soc_enum n810_enum[] = { - SOC_ENUM_SINGLE_EXT(2, spk_function), - SOC_ENUM_SINGLE_EXT(3, jack_function), -}; - -static const struct snd_kcontrol_new aic33_n810_controls[] = { - SOC_ENUM_EXT("Speaker Function", n810_enum[0], - n810_get_spk, n810_set_spk), - SOC_ENUM_EXT("Jack Function", n810_enum[1], - n810_get_jack, n810_set_jack), -}; - -static int n810_aic33_init(struct snd_soc_codec *codec) -{ - int i, err; - - /* Not connected */ - snd_soc_dapm_set_endpoint(codec, "MONO_LOUT", 0); - snd_soc_dapm_set_endpoint(codec, "HPLCOM", 0); - snd_soc_dapm_set_endpoint(codec, "HPRCOM", 0); - - /* Add N810 specific controls */ - for (i = 0; i < ARRAY_SIZE(aic33_n810_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&aic33_n810_controls[i], codec, NULL)); - if (err < 0) - return err; - } - - /* Add N810 specific widgets */ - for (i = 0; i < ARRAY_SIZE(aic33_dapm_widgets); i++) - snd_soc_dapm_new_control(codec, &aic33_dapm_widgets[i]); - - /* Set up N810 specific audio path audio_map */ - for (i = 0; i < ARRAY_SIZE(audio_map); i++) - snd_soc_dapm_connect_input(codec, audio_map[i][0], - audio_map[i][1], audio_map[i][2]); - - snd_soc_dapm_sync_endpoints(codec); - - return 0; -} - -/* Digital audio interface glue - connects codec <--> CPU */ -static struct snd_soc_dai_link n810_dai = { - .name = "TLV320AIC33", - .stream_name = "AIC33", - .cpu_dai = &omap_mcbsp_dai[0], - .codec_dai = &aic3x_dai, - .init = n810_aic33_init, - .ops = &n810_ops, -}; - -/* Audio machine driver */ -static struct snd_soc_machine snd_soc_machine_n810 = { - .name = "N810", - .dai_link = &n810_dai, - .num_links = 1, -}; - -/* Audio private data */ -static struct aic3x_setup_data n810_aic33_setup = { - .i2c_address = 0x18, -}; - -/* Audio subsystem */ -static struct snd_soc_device n810_snd_devdata = { - .machine = &snd_soc_machine_n810, - .platform = &omap_soc_platform, - .codec_dev = &soc_codec_dev_aic3x, - .codec_data = &n810_aic33_setup, -}; - -static struct platform_device *n810_snd_device; - -static int __init n810_soc_init(void) -{ - int err; - struct device *dev; - - if (!machine_is_nokia_n810()) - return -ENODEV; - - n810_snd_device = platform_device_alloc("soc-audio", -1); - if (!n810_snd_device) - return -ENOMEM; - - platform_set_drvdata(n810_snd_device, &n810_snd_devdata); - n810_snd_devdata.dev = &n810_snd_device->dev; - *(unsigned int *)n810_dai.cpu_dai->private_data = 1; /* McBSP2 */ - err = platform_device_add(n810_snd_device); - if (err) - goto err1; - - dev = &n810_snd_device->dev; - - sys_clkout2_src = clk_get(dev, "sys_clkout2_src"); - if (IS_ERR(sys_clkout2_src)) { - dev_err(dev, "Could not get sys_clkout2_src clock\n"); - return -ENODEV; - } - sys_clkout2 = clk_get(dev, "sys_clkout2"); - if (IS_ERR(sys_clkout2)) { - dev_err(dev, "Could not get sys_clkout2\n"); - goto err1; - } - /* - * Configure 12 MHz output on SYS_CLKOUT2. Therefore we must use - * 96 MHz as its parent in order to get 12 MHz - */ - func96m_clk = clk_get(dev, "func_96m_ck"); - if (IS_ERR(func96m_clk)) { - dev_err(dev, "Could not get func 96M clock\n"); - goto err2; - } - clk_set_parent(sys_clkout2_src, func96m_clk); - clk_set_rate(sys_clkout2, 12000000); - - if (omap_request_gpio(RX44_HEADSET_AMP_GPIO) < 0) - BUG(); - if (omap_request_gpio(RX44_SPEAKER_AMP_GPIO) < 0) - BUG(); - omap_set_gpio_direction(RX44_HEADSET_AMP_GPIO, 0); - omap_set_gpio_direction(RX44_SPEAKER_AMP_GPIO, 0); - - return 0; -err2: - clk_put(sys_clkout2); - platform_device_del(n810_snd_device); -err1: - platform_device_put(n810_snd_device); - - return err; - -} - -static void __exit n810_soc_exit(void) -{ - platform_device_unregister(n810_snd_device); -} - -module_init(n810_soc_init); -module_exit(n810_soc_exit); - -MODULE_AUTHOR("Jarkko Nikula "); -MODULE_DESCRIPTION("ALSA SoC Nokia N810"); -MODULE_LICENSE("GPL"); diff --git a/trunk/sound/soc/omap/omap-mcbsp.c b/trunk/sound/soc/omap/omap-mcbsp.c deleted file mode 100644 index 40d87e6d0de8..000000000000 --- a/trunk/sound/soc/omap/omap-mcbsp.c +++ /dev/null @@ -1,414 +0,0 @@ -/* - * omap-mcbsp.c -- OMAP ALSA SoC DAI driver using McBSP port - * - * Copyright (C) 2008 Nokia Corporation - * - * Contact: Jarkko Nikula - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include "omap-mcbsp.h" -#include "omap-pcm.h" - -#define OMAP_MCBSP_RATES (SNDRV_PCM_RATE_44100 | \ - SNDRV_PCM_RATE_48000 | \ - SNDRV_PCM_RATE_KNOT) - -struct omap_mcbsp_data { - unsigned int bus_id; - struct omap_mcbsp_reg_cfg regs; - /* - * Flags indicating is the bus already activated and configured by - * another substream - */ - int active; - int configured; -}; - -#define to_mcbsp(priv) container_of((priv), struct omap_mcbsp_data, bus_id) - -static struct omap_mcbsp_data mcbsp_data[NUM_LINKS]; - -/* - * Stream DMA parameters. DMA request line and port address are set runtime - * since they are different between OMAP1 and later OMAPs - */ -static struct omap_pcm_dma_data omap_mcbsp_dai_dma_params[NUM_LINKS][2] = { -{ - { .name = "I2S PCM Stereo out", }, - { .name = "I2S PCM Stereo in", }, -}, -}; - -#if defined(CONFIG_ARCH_OMAP15XX) || defined(CONFIG_ARCH_OMAP16XX) -static const int omap1_dma_reqs[][2] = { - { OMAP_DMA_MCBSP1_TX, OMAP_DMA_MCBSP1_RX }, - { OMAP_DMA_MCBSP2_TX, OMAP_DMA_MCBSP2_RX }, - { OMAP_DMA_MCBSP3_TX, OMAP_DMA_MCBSP3_RX }, -}; -static const unsigned long omap1_mcbsp_port[][2] = { - { OMAP1510_MCBSP1_BASE + OMAP_MCBSP_REG_DXR1, - OMAP1510_MCBSP1_BASE + OMAP_MCBSP_REG_DRR1 }, - { OMAP1510_MCBSP2_BASE + OMAP_MCBSP_REG_DXR1, - OMAP1510_MCBSP2_BASE + OMAP_MCBSP_REG_DRR1 }, - { OMAP1510_MCBSP3_BASE + OMAP_MCBSP_REG_DXR1, - OMAP1510_MCBSP3_BASE + OMAP_MCBSP_REG_DRR1 }, -}; -#else -static const int omap1_dma_reqs[][2] = {}; -static const unsigned long omap1_mcbsp_port[][2] = {}; -#endif -#if defined(CONFIG_ARCH_OMAP2420) -static const int omap2420_dma_reqs[][2] = { - { OMAP24XX_DMA_MCBSP1_TX, OMAP24XX_DMA_MCBSP1_RX }, - { OMAP24XX_DMA_MCBSP2_TX, OMAP24XX_DMA_MCBSP2_RX }, -}; -static const unsigned long omap2420_mcbsp_port[][2] = { - { OMAP24XX_MCBSP1_BASE + OMAP_MCBSP_REG_DXR1, - OMAP24XX_MCBSP1_BASE + OMAP_MCBSP_REG_DRR1 }, - { OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DXR1, - OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DRR1 }, -}; -#else -static const int omap2420_dma_reqs[][2] = {}; -static const unsigned long omap2420_mcbsp_port[][2] = {}; -#endif - -static int omap_mcbsp_dai_startup(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_cpu_dai *cpu_dai = rtd->dai->cpu_dai; - struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); - int err = 0; - - if (!cpu_dai->active) - err = omap_mcbsp_request(mcbsp_data->bus_id); - - return err; -} - -static void omap_mcbsp_dai_shutdown(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_cpu_dai *cpu_dai = rtd->dai->cpu_dai; - struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); - - if (!cpu_dai->active) { - omap_mcbsp_free(mcbsp_data->bus_id); - mcbsp_data->configured = 0; - } -} - -static int omap_mcbsp_dai_trigger(struct snd_pcm_substream *substream, int cmd) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_cpu_dai *cpu_dai = rtd->dai->cpu_dai; - struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); - int err = 0; - - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - case SNDRV_PCM_TRIGGER_RESUME: - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - if (!mcbsp_data->active++) - omap_mcbsp_start(mcbsp_data->bus_id); - break; - - case SNDRV_PCM_TRIGGER_STOP: - case SNDRV_PCM_TRIGGER_SUSPEND: - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - if (!--mcbsp_data->active) - omap_mcbsp_stop(mcbsp_data->bus_id); - break; - default: - err = -EINVAL; - } - - return err; -} - -static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_cpu_dai *cpu_dai = rtd->dai->cpu_dai; - struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); - struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; - int dma, bus_id = mcbsp_data->bus_id, id = cpu_dai->id; - unsigned long port; - - if (cpu_class_is_omap1()) { - dma = omap1_dma_reqs[bus_id][substream->stream]; - port = omap1_mcbsp_port[bus_id][substream->stream]; - } else if (cpu_is_omap2420()) { - dma = omap2420_dma_reqs[bus_id][substream->stream]; - port = omap2420_mcbsp_port[bus_id][substream->stream]; - } else { - /* - * TODO: Add support for 2430 and 3430 - */ - return -ENODEV; - } - omap_mcbsp_dai_dma_params[id][substream->stream].dma_req = dma; - omap_mcbsp_dai_dma_params[id][substream->stream].port_addr = port; - cpu_dai->dma_data = &omap_mcbsp_dai_dma_params[id][substream->stream]; - - if (mcbsp_data->configured) { - /* McBSP already configured by another stream */ - return 0; - } - - switch (params_channels(params)) { - case 2: - /* Set 1 word per (McBPSP) frame and use dual-phase frames */ - regs->rcr2 |= RFRLEN2(1 - 1) | RPHASE; - regs->rcr1 |= RFRLEN1(1 - 1); - regs->xcr2 |= XFRLEN2(1 - 1) | XPHASE; - regs->xcr1 |= XFRLEN1(1 - 1); - break; - default: - /* Unsupported number of channels */ - return -EINVAL; - } - - switch (params_format(params)) { - case SNDRV_PCM_FORMAT_S16_LE: - /* Set word lengths */ - regs->rcr2 |= RWDLEN2(OMAP_MCBSP_WORD_16); - regs->rcr1 |= RWDLEN1(OMAP_MCBSP_WORD_16); - regs->xcr2 |= XWDLEN2(OMAP_MCBSP_WORD_16); - regs->xcr1 |= XWDLEN1(OMAP_MCBSP_WORD_16); - /* Set FS period and length in terms of bit clock periods */ - regs->srgr2 |= FPER(16 * 2 - 1); - regs->srgr1 |= FWID(16 - 1); - break; - default: - /* Unsupported PCM format */ - return -EINVAL; - } - - omap_mcbsp_config(bus_id, &mcbsp_data->regs); - mcbsp_data->configured = 1; - - return 0; -} - -/* - * This must be called before _set_clkdiv and _set_sysclk since McBSP register - * cache is initialized here - */ -static int omap_mcbsp_dai_set_dai_fmt(struct snd_soc_cpu_dai *cpu_dai, - unsigned int fmt) -{ - struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); - struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; - - if (mcbsp_data->configured) - return 0; - - memset(regs, 0, sizeof(*regs)); - /* Generic McBSP register settings */ - regs->spcr2 |= XINTM(3) | FREE; - regs->spcr1 |= RINTM(3); - regs->rcr2 |= RFIG; - regs->xcr2 |= XFIG; - - switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { - case SND_SOC_DAIFMT_I2S: - /* 1-bit data delay */ - regs->rcr2 |= RDATDLY(1); - regs->xcr2 |= XDATDLY(1); - break; - default: - /* Unsupported data format */ - return -EINVAL; - } - - switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { - case SND_SOC_DAIFMT_CBS_CFS: - /* McBSP master. Set FS and bit clocks as outputs */ - regs->pcr0 |= FSXM | FSRM | - CLKXM | CLKRM; - /* Sample rate generator drives the FS */ - regs->srgr2 |= FSGM; - break; - case SND_SOC_DAIFMT_CBM_CFM: - /* McBSP slave */ - break; - default: - /* Unsupported master/slave configuration */ - return -EINVAL; - } - - /* Set bit clock (CLKX/CLKR) and FS polarities */ - switch (fmt & SND_SOC_DAIFMT_INV_MASK) { - case SND_SOC_DAIFMT_NB_NF: - /* - * Normal BCLK + FS. - * FS active low. TX data driven on falling edge of bit clock - * and RX data sampled on rising edge of bit clock. - */ - regs->pcr0 |= FSXP | FSRP | - CLKXP | CLKRP; - break; - case SND_SOC_DAIFMT_NB_IF: - regs->pcr0 |= CLKXP | CLKRP; - break; - case SND_SOC_DAIFMT_IB_NF: - regs->pcr0 |= FSXP | FSRP; - break; - case SND_SOC_DAIFMT_IB_IF: - break; - default: - return -EINVAL; - } - - return 0; -} - -static int omap_mcbsp_dai_set_clkdiv(struct snd_soc_cpu_dai *cpu_dai, - int div_id, int div) -{ - struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); - struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; - - if (div_id != OMAP_MCBSP_CLKGDV) - return -ENODEV; - - regs->srgr1 |= CLKGDV(div - 1); - - return 0; -} - -static int omap_mcbsp_dai_set_clks_src(struct omap_mcbsp_data *mcbsp_data, - int clk_id) -{ - int sel_bit; - u16 reg; - - if (cpu_class_is_omap1()) { - /* OMAP1's can use only external source clock */ - if (unlikely(clk_id == OMAP_MCBSP_SYSCLK_CLKS_FCLK)) - return -EINVAL; - else - return 0; - } - - switch (mcbsp_data->bus_id) { - case 0: - reg = OMAP2_CONTROL_DEVCONF0; - sel_bit = 2; - break; - case 1: - reg = OMAP2_CONTROL_DEVCONF0; - sel_bit = 6; - break; - /* TODO: Support for ports 3 - 5 in OMAP2430 and OMAP34xx */ - default: - return -EINVAL; - } - - if (cpu_class_is_omap2()) { - if (clk_id == OMAP_MCBSP_SYSCLK_CLKS_FCLK) { - omap_ctrl_writel(omap_ctrl_readl(reg) & - ~(1 << sel_bit), reg); - } else { - omap_ctrl_writel(omap_ctrl_readl(reg) | - (1 << sel_bit), reg); - } - } - - return 0; -} - -static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_cpu_dai *cpu_dai, - int clk_id, unsigned int freq, - int dir) -{ - struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data); - struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs; - int err = 0; - - switch (clk_id) { - case OMAP_MCBSP_SYSCLK_CLK: - regs->srgr2 |= CLKSM; - break; - case OMAP_MCBSP_SYSCLK_CLKS_FCLK: - case OMAP_MCBSP_SYSCLK_CLKS_EXT: - err = omap_mcbsp_dai_set_clks_src(mcbsp_data, clk_id); - break; - - case OMAP_MCBSP_SYSCLK_CLKX_EXT: - regs->srgr2 |= CLKSM; - case OMAP_MCBSP_SYSCLK_CLKR_EXT: - regs->pcr0 |= SCLKME; - break; - default: - err = -ENODEV; - } - - return err; -} - -struct snd_soc_cpu_dai omap_mcbsp_dai[NUM_LINKS] = { -{ - .name = "omap-mcbsp-dai", - .id = 0, - .type = SND_SOC_DAI_I2S, - .playback = { - .channels_min = 2, - .channels_max = 2, - .rates = OMAP_MCBSP_RATES, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - }, - .capture = { - .channels_min = 2, - .channels_max = 2, - .rates = OMAP_MCBSP_RATES, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - }, - .ops = { - .startup = omap_mcbsp_dai_startup, - .shutdown = omap_mcbsp_dai_shutdown, - .trigger = omap_mcbsp_dai_trigger, - .hw_params = omap_mcbsp_dai_hw_params, - }, - .dai_ops = { - .set_fmt = omap_mcbsp_dai_set_dai_fmt, - .set_clkdiv = omap_mcbsp_dai_set_clkdiv, - .set_sysclk = omap_mcbsp_dai_set_dai_sysclk, - }, - .private_data = &mcbsp_data[0].bus_id, -}, -}; -EXPORT_SYMBOL_GPL(omap_mcbsp_dai); - -MODULE_AUTHOR("Jarkko Nikula "); -MODULE_DESCRIPTION("OMAP I2S SoC Interface"); -MODULE_LICENSE("GPL"); diff --git a/trunk/sound/soc/omap/omap-mcbsp.h b/trunk/sound/soc/omap/omap-mcbsp.h deleted file mode 100644 index 9965fd4b0427..000000000000 --- a/trunk/sound/soc/omap/omap-mcbsp.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * omap-mcbsp.h - * - * Copyright (C) 2008 Nokia Corporation - * - * Contact: Jarkko Nikula - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#ifndef __OMAP_I2S_H__ -#define __OMAP_I2S_H__ - -/* Source clocks for McBSP sample rate generator */ -enum omap_mcbsp_clksrg_clk { - OMAP_MCBSP_SYSCLK_CLKS_FCLK, /* Internal FCLK */ - OMAP_MCBSP_SYSCLK_CLKS_EXT, /* External CLKS pin */ - OMAP_MCBSP_SYSCLK_CLK, /* Internal ICLK */ - OMAP_MCBSP_SYSCLK_CLKX_EXT, /* External CLKX pin */ - OMAP_MCBSP_SYSCLK_CLKR_EXT, /* External CLKR pin */ -}; - -/* McBSP dividers */ -enum omap_mcbsp_div { - OMAP_MCBSP_CLKGDV, /* Sample rate generator divider */ -}; - -/* - * REVISIT: Preparation for the ASoC v2. Let the number of available links to - * be same than number of McBSP ports found in OMAP(s) we are compiling for. - */ -#define NUM_LINKS 1 - -extern struct snd_soc_cpu_dai omap_mcbsp_dai[NUM_LINKS]; - -#endif diff --git a/trunk/sound/soc/omap/omap-pcm.c b/trunk/sound/soc/omap/omap-pcm.c deleted file mode 100644 index 62370202c649..000000000000 --- a/trunk/sound/soc/omap/omap-pcm.c +++ /dev/null @@ -1,357 +0,0 @@ -/* - * omap-pcm.c -- ALSA PCM interface for the OMAP SoC - * - * Copyright (C) 2008 Nokia Corporation - * - * Contact: Jarkko Nikula - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#include -#include -#include -#include -#include - -#include -#include "omap-pcm.h" - -static const struct snd_pcm_hardware omap_pcm_hardware = { - .info = SNDRV_PCM_INFO_MMAP | - SNDRV_PCM_INFO_MMAP_VALID | - SNDRV_PCM_INFO_INTERLEAVED | - SNDRV_PCM_INFO_PAUSE | - SNDRV_PCM_INFO_RESUME, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - .period_bytes_min = 32, - .period_bytes_max = 64 * 1024, - .periods_min = 2, - .periods_max = 255, - .buffer_bytes_max = 128 * 1024, -}; - -struct omap_runtime_data { - spinlock_t lock; - struct omap_pcm_dma_data *dma_data; - int dma_ch; - int period_index; -}; - -static void omap_pcm_dma_irq(int ch, u16 stat, void *data) -{ - struct snd_pcm_substream *substream = data; - struct snd_pcm_runtime *runtime = substream->runtime; - struct omap_runtime_data *prtd = runtime->private_data; - unsigned long flags; - - if (cpu_is_omap1510()) { - /* - * OMAP1510 doesn't support DMA chaining so have to restart - * the transfer after all periods are transferred - */ - spin_lock_irqsave(&prtd->lock, flags); - if (prtd->period_index >= 0) { - if (++prtd->period_index == runtime->periods) { - prtd->period_index = 0; - omap_start_dma(prtd->dma_ch); - } - } - spin_unlock_irqrestore(&prtd->lock, flags); - } - - snd_pcm_period_elapsed(substream); -} - -/* this may get called several times by oss emulation */ -static int omap_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct omap_runtime_data *prtd = runtime->private_data; - struct omap_pcm_dma_data *dma_data = rtd->dai->cpu_dai->dma_data; - int err = 0; - - if (!dma_data) - return -ENODEV; - - snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); - runtime->dma_bytes = params_buffer_bytes(params); - - if (prtd->dma_data) - return 0; - prtd->dma_data = dma_data; - err = omap_request_dma(dma_data->dma_req, dma_data->name, - omap_pcm_dma_irq, substream, &prtd->dma_ch); - if (!cpu_is_omap1510()) { - /* - * Link channel with itself so DMA doesn't need any - * reprogramming while looping the buffer - */ - omap_dma_link_lch(prtd->dma_ch, prtd->dma_ch); - } - - return err; -} - -static int omap_pcm_hw_free(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct omap_runtime_data *prtd = runtime->private_data; - - if (prtd->dma_data == NULL) - return 0; - - if (!cpu_is_omap1510()) - omap_dma_unlink_lch(prtd->dma_ch, prtd->dma_ch); - omap_free_dma(prtd->dma_ch); - prtd->dma_data = NULL; - - snd_pcm_set_runtime_buffer(substream, NULL); - - return 0; -} - -static int omap_pcm_prepare(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct omap_runtime_data *prtd = runtime->private_data; - struct omap_pcm_dma_data *dma_data = prtd->dma_data; - struct omap_dma_channel_params dma_params; - - memset(&dma_params, 0, sizeof(dma_params)); - /* - * Note: Regardless of interface data formats supported by OMAP McBSP - * or EAC blocks, internal representation is always fixed 16-bit/sample - */ - dma_params.data_type = OMAP_DMA_DATA_TYPE_S16; - dma_params.trigger = dma_data->dma_req; - dma_params.sync_mode = OMAP_DMA_SYNC_ELEMENT; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - dma_params.src_amode = OMAP_DMA_AMODE_POST_INC; - dma_params.dst_amode = OMAP_DMA_AMODE_CONSTANT; - dma_params.src_or_dst_synch = OMAP_DMA_DST_SYNC; - dma_params.src_start = runtime->dma_addr; - dma_params.dst_start = dma_data->port_addr; - } else { - dma_params.src_amode = OMAP_DMA_AMODE_CONSTANT; - dma_params.dst_amode = OMAP_DMA_AMODE_POST_INC; - dma_params.src_or_dst_synch = OMAP_DMA_SRC_SYNC; - dma_params.src_start = dma_data->port_addr; - dma_params.dst_start = runtime->dma_addr; - } - /* - * Set DMA transfer frame size equal to ALSA period size and frame - * count as no. of ALSA periods. Then with DMA frame interrupt enabled, - * we can transfer the whole ALSA buffer with single DMA transfer but - * still can get an interrupt at each period bounary - */ - dma_params.elem_count = snd_pcm_lib_period_bytes(substream) / 2; - dma_params.frame_count = runtime->periods; - omap_set_dma_params(prtd->dma_ch, &dma_params); - - omap_enable_dma_irq(prtd->dma_ch, OMAP_DMA_FRAME_IRQ); - - return 0; -} - -static int omap_pcm_trigger(struct snd_pcm_substream *substream, int cmd) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct omap_runtime_data *prtd = runtime->private_data; - int ret = 0; - - spin_lock_irq(&prtd->lock); - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - case SNDRV_PCM_TRIGGER_RESUME: - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - prtd->period_index = 0; - omap_start_dma(prtd->dma_ch); - break; - - case SNDRV_PCM_TRIGGER_STOP: - case SNDRV_PCM_TRIGGER_SUSPEND: - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - prtd->period_index = -1; - omap_stop_dma(prtd->dma_ch); - break; - default: - ret = -EINVAL; - } - spin_unlock_irq(&prtd->lock); - - return ret; -} - -static snd_pcm_uframes_t omap_pcm_pointer(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct omap_runtime_data *prtd = runtime->private_data; - dma_addr_t ptr; - snd_pcm_uframes_t offset; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - ptr = omap_get_dma_src_pos(prtd->dma_ch); - else - ptr = omap_get_dma_dst_pos(prtd->dma_ch); - - offset = bytes_to_frames(runtime, ptr - runtime->dma_addr); - if (offset >= runtime->buffer_size) - offset = 0; - - return offset; -} - -static int omap_pcm_open(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct omap_runtime_data *prtd; - int ret; - - snd_soc_set_runtime_hwparams(substream, &omap_pcm_hardware); - - /* Ensure that buffer size is a multiple of period size */ - ret = snd_pcm_hw_constraint_integer(runtime, - SNDRV_PCM_HW_PARAM_PERIODS); - if (ret < 0) - goto out; - - prtd = kzalloc(sizeof(prtd), GFP_KERNEL); - if (prtd == NULL) { - ret = -ENOMEM; - goto out; - } - spin_lock_init(&prtd->lock); - runtime->private_data = prtd; - -out: - return ret; -} - -static int omap_pcm_close(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - - kfree(runtime->private_data); - return 0; -} - -static int omap_pcm_mmap(struct snd_pcm_substream *substream, - struct vm_area_struct *vma) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - - return dma_mmap_writecombine(substream->pcm->card->dev, vma, - runtime->dma_area, - runtime->dma_addr, - runtime->dma_bytes); -} - -struct snd_pcm_ops omap_pcm_ops = { - .open = omap_pcm_open, - .close = omap_pcm_close, - .ioctl = snd_pcm_lib_ioctl, - .hw_params = omap_pcm_hw_params, - .hw_free = omap_pcm_hw_free, - .prepare = omap_pcm_prepare, - .trigger = omap_pcm_trigger, - .pointer = omap_pcm_pointer, - .mmap = omap_pcm_mmap, -}; - -static u64 omap_pcm_dmamask = DMA_BIT_MASK(32); - -static int omap_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, - int stream) -{ - struct snd_pcm_substream *substream = pcm->streams[stream].substream; - struct snd_dma_buffer *buf = &substream->dma_buffer; - size_t size = omap_pcm_hardware.buffer_bytes_max; - - buf->dev.type = SNDRV_DMA_TYPE_DEV; - buf->dev.dev = pcm->card->dev; - buf->private_data = NULL; - buf->area = dma_alloc_writecombine(pcm->card->dev, size, - &buf->addr, GFP_KERNEL); - if (!buf->area) - return -ENOMEM; - - buf->bytes = size; - return 0; -} - -static void omap_pcm_free_dma_buffers(struct snd_pcm *pcm) -{ - struct snd_pcm_substream *substream; - struct snd_dma_buffer *buf; - int stream; - - for (stream = 0; stream < 2; stream++) { - substream = pcm->streams[stream].substream; - if (!substream) - continue; - - buf = &substream->dma_buffer; - if (!buf->area) - continue; - - dma_free_writecombine(pcm->card->dev, buf->bytes, - buf->area, buf->addr); - buf->area = NULL; - } -} - -int omap_pcm_new(struct snd_card *card, struct snd_soc_codec_dai *dai, - struct snd_pcm *pcm) -{ - int ret = 0; - - if (!card->dev->dma_mask) - card->dev->dma_mask = &omap_pcm_dmamask; - if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask = DMA_32BIT_MASK; - - if (dai->playback.channels_min) { - ret = omap_pcm_preallocate_dma_buffer(pcm, - SNDRV_PCM_STREAM_PLAYBACK); - if (ret) - goto out; - } - - if (dai->capture.channels_min) { - ret = omap_pcm_preallocate_dma_buffer(pcm, - SNDRV_PCM_STREAM_CAPTURE); - if (ret) - goto out; - } - -out: - return ret; -} - -struct snd_soc_platform omap_soc_platform = { - .name = "omap-pcm-audio", - .pcm_ops = &omap_pcm_ops, - .pcm_new = omap_pcm_new, - .pcm_free = omap_pcm_free_dma_buffers, -}; -EXPORT_SYMBOL_GPL(omap_soc_platform); - -MODULE_AUTHOR("Jarkko Nikula "); -MODULE_DESCRIPTION("OMAP PCM DMA module"); -MODULE_LICENSE("GPL"); diff --git a/trunk/sound/soc/omap/omap-pcm.h b/trunk/sound/soc/omap/omap-pcm.h deleted file mode 100644 index e4369bdfd77d..000000000000 --- a/trunk/sound/soc/omap/omap-pcm.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * omap-pcm.h - * - * Copyright (C) 2008 Nokia Corporation - * - * Contact: Jarkko Nikula - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#ifndef __OMAP_PCM_H__ -#define __OMAP_PCM_H__ - -struct omap_pcm_dma_data { - char *name; /* stream identifier */ - int dma_req; /* DMA request line */ - unsigned long port_addr; /* transmit/receive register */ -}; - -extern struct snd_soc_platform omap_soc_platform; - -#endif